Skip to content

Instantly share code, notes, and snippets.

@mAAdhaTTah
mAAdhaTTah / npm-upgrade-bleeding.sh
Last active August 29, 2015 14:07 — forked from othiym23/npm-upgrade-bleeding.sh
Upgrade npm to latest/bleeding
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
@mAAdhaTTah
mAAdhaTTah / plugin-deploy.sh
Last active August 29, 2015 14:15 — forked from scribu/plugin-deploy.sh
Git-to-SVN Plugin Deploy by Scribu
#!/usr/bin/env bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)
DEST_DIR=~/svn/$DIR_NAME/$BRANCH
@mAAdhaTTah
mAAdhaTTah / write-log.php
Created February 16, 2015 01:10
WordPress Error Logging
if (!function_exists('write_log')) {
function write_log ( $log ) {
if ( true === WP_DEBUG ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
@mAAdhaTTah
mAAdhaTTah / composer.json
Last active August 29, 2015 14:15
WordPress Site Boilerplate
{
"name": "name/site",
"type": "project",
"license": "MIT",
"description": "A modern WordPress stack for Name.com",
"homepage": "http://name.com/",
"authors": [
{
"name": "James DiGioia",
"email": "jamesorodig@gmail.com",
@mAAdhaTTah
mAAdhaTTah / vagrantfile
Created February 16, 2015 01:10
Sync additional paths in Bedrock-Ansible's Vagrantfile
# Sync additional paths
extra_paths = [
['../../../plugins/wp-gistpen', File.join(bedrock_path_server, 'web/app/plugins/wp-gistpen')]
]
extra_paths.each do |paths|
extra_path = paths[0]
extra_path_server = paths[1]
initial_mount = File.join('/wptmp', File.basename(extra_path))
@mAAdhaTTah
mAAdhaTTah / class.php
Created February 16, 2015 01:10
Default Classes for WP-Gistpen
<?php
namespace WP_Gistpen;
/**
* This is the class description.
*
* @package WP_Gistpen
* @author James DiGioia <jamesorodig@gmail.com>
* @link http://jamesdigioia.com/wp-gistpen/
* @since [current version]
@mAAdhaTTah
mAAdhaTTah / 5-3-or-greater.php
Created February 16, 2015 01:10
PHP Version check for WP Boilerplate
public static function activate() {
if ( ! version_compare( PHP_VERSION, '5.3', '<' ) ) {
return;
}
deactivate_plugins( 'url-embedlifier' );
wp_die('<p>The <strong>URL Embedlifier</strong> plugin requires PHP version 5.3 or greater.</p>',
'Plugin Activation Error', array( 'response' => 200, 'back_link' => true ) );
}
@mAAdhaTTah
mAAdhaTTah / add-redirect-args.php
Created February 16, 2015 01:10
Using Redirect Args to Display Errors
if ( ! empty( $errors ) ) {
    add_filter('redirect_post_location', function( $location ) use ( $errors ) {
        return add_query_arg( 'gistpen-errors', implode( ",", $errors ), $location );
    });
}
@mAAdhaTTah
mAAdhaTTah / display-transient-errors.php
Created February 16, 2015 01:10
Using Transients to Display Errors
if ( $errors = get_transient( "my_save_post_errors_{$post_id}_{$user_id}" ) ) {
    foreach( $errors as $error ) { ?>
        <div class="error"><p>
            <?php echo $error; ?>
        </p></div><?php
    }
    delete_transient( "my_save_post_errors_{$post_id}" )
}
@mAAdhaTTah
mAAdhaTTah / display-session-errors.php
Created February 16, 2015 01:10
Using $_SESSION to Display Errors
if ( array_key_exists( 'my_plugin_errors', $_SESSION ) ) {
    foreach( $_SESSION['my_plugin_errors'] as $error ) {?>
        <div class="error"><p>
            <?php echo $error; ?>
        </p></div><?php
    }
    unset( $_SESSION['my_plugin_errors'] );
}