Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / pmpro_member_data_shortcode.php
Created January 19, 2018 16:35 — forked from andrewlimaza/pmpro_member_data_shortcode.php
Shortcode to get membership level data for a user
<?php
/**
* Shortcode to retrieve information about a user startdate/enddate
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* www.paidmembershipspro.com - A membership plugin for WordPress.
*/
function pmpro_member_data_shortcode( $atts, $content=null, $code='' ) {
global $current_user;
@pbrocks
pbrocks / get-ip-address-optimized.php
Created February 2, 2018 22:54 — forked from cballou/get-ip-address-optimized.php
PHP - Advanced Method to Retrieve Client IP Address
<?php
function get_ip_address() {
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
// trim for safety measures
$ip = trim($ip);
// attempt to validate IP
if (validate_ip($ip)) {
@pbrocks
pbrocks / .htaccess
Created February 27, 2018 03:06 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@pbrocks
pbrocks / .htaccess
Created February 27, 2018 03:06 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@pbrocks
pbrocks / countries.json
Created February 28, 2018 21:27 — forked from keeguon/countries.json
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@pbrocks
pbrocks / my-pmpro-levels-array.php
Last active March 13, 2018 19:49 — forked from strangerstudios/my_pmpro_levels_array.php
Use pmpro_levels_array filter to remove specific levels from your levels array. In this case, we are removing Free levels, leaving only paid levels to be returned to your PMPro levels array.
/**
* The function my_pmpro_levels_array is an arbitrarily named function, which
* you can rename to something more meaningful, as long as it is uniquely
* named on this site.
*
* @param array $levels Input the array of levels from your site
* @return array Output all paid levels, ie NOT the free level(s)
*/
function my_pmpro_levels_array( $levels ) {
$newlevels = array();
@pbrocks
pbrocks / notes.md
Created March 18, 2018 11:17 — forked from GaryJones/notes.md
Add PHPCS + WPCS to Sublime Text 3

Install PHP_CodeSniffer (PHPCS) via git

You can use the .phar for PHPCS, but it's easier to pull the repo down from git to then choose what version to use.

cd ~
mkdir -p code
cd code
git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs
@pbrocks
pbrocks / js.js
Created March 18, 2018 12:39 — forked from GaryJones/js.js
Gravity Forms Countries dropdown with country codes
var countryCodes = {
'Afghanistan': '93',
'Albania': '355',
'Algeria': '213',
'American Samoa': '684',
'Andorra': '376',
'Angola': '244',
'Antigua and Barbuda': '1-268',
'Argentina': '54',
'Armenia': '374',
@pbrocks
pbrocks / icons.json
Created March 18, 2018 12:39 — forked from GaryJones/icons.json
Font Awesome 4.1.0 icons as JSON
{
"icons": [
{
"name": "Glass",
"id": "glass",
"unicode": "f000",
"created": 1,
"categories": [
"Web Application Icons"
]

Config Files

Development-related files that might be found in version-controlled projects. Doesn't include editor-specific files.

Files

  • .editorconfig - EditorConfig define and maintain consistent coding styles between different editors and IDEs.
  • .gitignore - ignore files from version control. Note, don't add system files - contributors should be globally ignoring these on their local machines. Only use for files created during project build, credentials files etc.