Skip to content

Instantly share code, notes, and snippets.

View aaroncampbell's full-sized avatar

Aaron D. Campbell aaroncampbell

View GitHub Profile
<?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 / ithemes-exchange-inventory.php
Created March 27, 2015 03:45
Show different strings for stock level of 0, 1, and many items
<?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, ',' ) );
}
@aaroncampbell
aaroncampbell / two-factor-logo.svg
Last active June 15, 2016 17:54
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 / keybase.md
Created February 25, 2016 21:55
Keybase Verification for Aaron D. Campbell

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:

<?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 / twitter-build-list.sh
Last active November 3, 2017 21:56
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.
#!/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;;