Skip to content

Instantly share code, notes, and snippets.

Aaron D. Campbell aaroncampbell

Block or report user

Report or block aaroncampbell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aaroncampbell
aaroncampbell / twitter-build-list.sh
Last active Nov 3, 2017
Creates a list with all twitter users linked from a given URL. Requires https://github.com/sferik/t and you must have already authorized your Twitter account using it.
View twitter-build-list.sh
#!/usr/bin/env bash
# Load in our options
while getopts "u:l:d:a" option
do
case ${option} in
u) url=${OPTARG};;
l) list_name=${OPTARG};;
d) list_description=${OPTARG};;
a) append=1;;
View test-reverse.php
<?php
function reverse( $arr ) {
$len = count( $arr );
for ( $i = 0; $i < $len/2; $i++ ) {
list( $arr[$i], $arr[$len-$i-1] ) = array( $arr[$len-$i-1], $arr[$i] );
}
return $arr;
}
$test = array('a', 'b', 'c', 'd', 'e');
var_dump( reverse( $test ) );
@aaroncampbell
aaroncampbell / keybase.md
Created Feb 25, 2016
Keybase Verification for Aaron D. Campbell
View keybase.md

Keybase proof

I hereby claim:

  • I am aaroncampbell on github.
  • I am aaroncampbell (https://keybase.io/aaroncampbell) on keybase.
  • I have a public key whose fingerprint is 442C 8E24 643A F2B0 1BFB 62D5 73C8 A0AF 8D6A C9C5

To claim this, I am signing this object:

@aaroncampbell
aaroncampbell / two-factor-logo.svg
Last active Jun 15, 2016
Two Factor Logo - SVG
View two-factor-logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aaroncampbell
aaroncampbell / ithemes-exchange-inventory.php
Created Mar 27, 2015
Show different strings for stock level of 0, 1, and many items
View ithemes-exchange-inventory.php
<?php
$inventory = it_exchange( 'product', 'inventory', 'return=true' );
if ( 0 == $inventory ) {
echo 'Too Late!'; // We're completely out
} elseif ( 1 == $inventory ) {
echo 'There can be only one!'; // There is one in stock
} else {
printf( 'We have %s in stock.', number_format( $inventory, 0, null, ',' ) );
}
View multiline-shortcode-tests.php
<?php
function test_multiple_shortcode_unautop() {
$test_strings = array(
"[footag][footag]\n",
"[footag]\n[footag]\n",
"[footag]\n\n[footag]\n",
);
foreach( $test_strings as $test_string ) {
$actual = shortcode_unautop( wpautop( $test_string ) );
@aaroncampbell
aaroncampbell / create-shopp-promo.php
Created Jan 10, 2014
This is how I create a promo code. I'm only using percentage off, but you can set it up however you want. I'm getting $_POST['percentage'] and $_POST['coupon-code'] from a front-end form, along with the nonces
View create-shopp-promo.php
<?php
if ( isset( $_POST['action'] ) && 'add-coupon-code' == $_POST['action'] ) {
if ( empty( $_POST['add_coupon_code_nonce'] ) || ! wp_verify_nonce( $_POST['add_coupon_code_nonce'], 'add_coupon_code' ) ) {
fc_message( "You don't have permissions to add a coupon code.", 'error' );
} else {
$_POST['percentage'] = filter_percentage( $_POST['percentage'] );
$_POST['coupon-code'] = sanitize_key( $_POST['coupon-code'] );
$Promotion = new ShoppPromo();
$data = array(
@aaroncampbell
aaroncampbell / background-updates-for-major-releases.php
Created Oct 24, 2013
WordPress plugin to enable automatic background updates for major versions.
View background-updates-for-major-releases.php
<?php
/**
* Plugin Name: Background Updates for Major Releases
* Plugin URI: http://ran.ge/
* Description: Enables background updates for major releases
* Version: 1.0.0
* Author: Aaron D. Campbell
* Author URI: http://ran.ge/
* License: GPLv2 or later
*/
@aaroncampbell
aaroncampbell / show-related-thumbs.php
Created Sep 18, 2013
Showing related post thumbnails using Efficient Related Posts for WordPress
View show-related-thumbs.php
@aaroncampbell
aaroncampbell / get_php_bin_from_path.php
Created Aug 21, 2013
Find the PHP binary in the path
View get_php_bin_from_path.php
<?php
/**
* Checks the path for the php binary and returns it's location if found
*
* @return false|string False on failure, String of binary location on success
*/
function get_php_bin_from_path() {
$paths = explode( PATH_SEPARATOR, getenv( 'PATH' ) );
foreach ( $paths as $path ) {
// Windows XAMPP sometimes has the actual bin as the path
You can’t perform that action at this time.