Skip to content

Instantly share code, notes, and snippets.

View jimboobrien's full-sized avatar

Jimobrien jimboobrien

View GitHub Profile
@jimboobrien
jimboobrien / NetworkOut.sh
Created July 24, 2017 23:44 — forked from lewayotte/NetworkOut.sh
AWS Bandwidth Usage Report by Instance
#!/bin/bash
EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"
test -n "$EC2_INSTANCE_ID" || die 'cannot obtain instance-id'
EC2_AVAIL_ZONE="`wget -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone || die \"wget availability-zone has failed: $?\"`"
test -n "$EC2_AVAIL_ZONE" || die 'cannot obtain availability-zone'
EC2_REGION="`echo \"$EC2_AVAIL_ZONE\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"
@jimboobrien
jimboobrien / wcatl.php
Created July 24, 2017 23:44 — forked from lewayotte/wcatl.php
SAAS REST API for WordPress
<?php
function wcatl_api() {
if ( !empty( $_GET['wcatl'] ) ) {
try {
$input = file_get_contents( 'php://input' );
$post = json_decode( $input, TRUE );
if ( !empty( $post['post-id'] ) ) {
error_log( sprintf( 'New Post Published %s', $post['post-id'] ) );
}
@jimboobrien
jimboobrien / wcatl2016.php
Created July 24, 2017 23:44 — forked from lewayotte/wcatl2016.php
Custom RESTful API for WCATL 2016
<?php
function wcatl2016_api() {
if ( !empty( $_GET['wcatl2016'] ) ) {
switch( strtolower( $_GET['wcatl2016'] ) ) {
case 'get-users':
$response = wcatl2016_api_get_users();
break;
case 'add-user':
$response = wcatl2016_api_create_user();
@jimboobrien
jimboobrien / restricted-content.php
Created July 24, 2017 23:44 — forked from lewayotte/restricted-content.php
Restricted Content in WordPress - WordCamp ATL 2015
<?php
function restricted_content_filter( $content ) {
if ( !current_user_can( 'administrator' ) && is_content_restricted() ) {
$content = 'Restricted!';
}
return $content;
}
add_filter( 'the_content', 'restricted_content_filter' );
add_filter( 'the_excerpt', 'restricted_content_filter' );
@jimboobrien
jimboobrien / stripe-payment-button.php
Created July 24, 2017 23:44 — forked from lewayotte/stripe-payment-button.php
Stripe Payments - WordCamp ATL 2015
<?php
// Custom forms: https://stripe.com/docs/tutorials/forms
function stripe_payment_button() {
$payment_image = false;
$publishable_key = 'key';
$transaction_return_page = get_permalink( 1 ); //Whatever page ID you're using for your transaction return page
$description = 'S-Mart';
@jimboobrien
jimboobrien / paypal-payment-url.php
Created July 24, 2017 23:44 — forked from lewayotte/paypal-payment-url.php
PayPal Payments - WordCamp ATL 2015
<?php
if ( !defined( 'PAYPAL_PAYMENT_LIVE_URL' ) )
define( 'PAYPAL_PAYMENT_LIVE_URL', 'https://www.paypal.com/cgi-bin/webscr' );
if ( !defined( 'PAYPAL_PAYMENT_SANDBOX_URL' ) )
define( 'PAYPAL_PAYMENT_SANDBOX_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr' );
/* Insecure */
function insecure_paypal_payment_url() {
$paypal_email = 'you@domain.tld';
@jimboobrien
jimboobrien / post-content-appender.php
Created September 20, 2017 22:41 — forked from wpscholar/post-content-appender.php
Sample class to demonstrate how classes can be used in WordPress.
<?php
/**
* Class PostContentAppender
*/
class PostContentAppender {
protected $append = '';
public function __construct( $append ) {
@jimboobrien
jimboobrien / array-insert-before.php
Created September 20, 2017 22:41 — forked from wpscholar/array-insert-before.php
Insert a value or key/value pair before a specific key in an array. If key doesn't exist, value is prepended to the beginning of the array.
<?php
/**
* Insert a value or key/value pair before a specific key in an array. If key doesn't exist, value is prepended
* to the beginning of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@jimboobrien
jimboobrien / array-insert-after.php
Created September 20, 2017 22:41 — forked from wpscholar/array-insert-after.php
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
<?php
/**
* Drop this code into your main plugin file to hide plugin deactivation from the WordPress admin.
*/
add_filter( 'plugin_action_links', function ( $actions, $plugin_file ) {
if ( plugin_basename( __FILE__ ) === $plugin_file ) {
unset( $actions['deactivate'] );
}