Skip to content

Instantly share code, notes, and snippets.

<h2>Shortcode models</h2>
For each heading below, you'll see shortcode content appear <i>if </i>you're in the right area.
To spoof being in an area, add this to your URL
<pre>http://mywebsite.com/?geoip&amp;country=US </pre>
Note that <pre> country </pre> and <pre> US </pre> can be any values you want.
---
@ryanshoover
ryanshoover / cpt-generator.php
Last active August 29, 2015 14:22
WordPress CPT Generator Class
<?php
class cptGenerator {
public static function create( $single = '', $plural = '', $args = array() ) {
if( empty( $plural ) )
$plural = $single . 's';
$labels = array(
'name' => __( ucfirst( $plural ), 'post type general name', 'tpc' ),
@ryanshoover
ryanshoover / add-google-analytics.php
Last active October 10, 2015 15:49
Add Google Analytics to WP <head>
<?php
// (Don't copy the opening PHP tag above)
/**
* Add Google Analytics in the header
*/
add_action( 'wp_head', 'wcraleigh_add_ga_tracking', 1 );
function wcraleigh_add_ga_tracking() {
?>
<!-- Start Google Analytics -->
@ryanshoover
ryanshoover / jira
Last active March 30, 2016 18:09
BASH script to automate a new JIRA task
#!/bin/bash
# Typical Usage
# $ jira MAR-1234-description
git checkout staging;
if [[ $? != 0 ]]; then
echo "git isn't clean. aborting."
exit 1;
@ryanshoover
ryanshoover / gitclean
Created March 30, 2016 16:55
Clean out dead branches from local and remote repos
#!/bin/bash
## Typical usage
# gitclean
# gitclean remote
say() { echo "$0: $*" >&2; }
die() { say "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }
@ryanshoover
ryanshoover / always-log-in.php
Last active June 23, 2016 16:15
WP Plugin for dev sites. You'll always log in if you submit the login form. NOT FOR PRODUCTION SITES
<?php
/*
Plugin Name: Always log in
Version: 0.1
Description: If authentication fails, just log in as user #1. ONLY FOR DEV SITES
Author: ryanshoover
*/
/**
* Always log in if you submit the login form
@ryanshoover
ryanshoover / staging.scss
Last active July 26, 2016 16:09
SCSS to style WP Engine Admin Bar in staging
// Style the wpadminbar based on site type
#wpadminbar {
body.developer & {
background-color: $teal;
}
body.devsite & {
background-color: $darkblue;
}
@ryanshoover
ryanshoover / staging.php
Created July 26, 2016 16:11
PHP to style WP Engine Admin Bar in staging
// Define the environment if we don't have one already
if ( ! defined( 'WPE_ENVIRONMENT' ) ) {
// Test to see if we're in staging
if ( isset( $_SERVER['IS_WPE_SNAPSHOT'] ) && $_SERVER['IS_WPE_SNAPSHOT'] ) {
define( 'WPE_ENVIRONMENT', 'staging' );
} else {
define( 'WPE_ENVIRONMENT', 'production' );
}
}
@ryanshoover
ryanshoover / wpatx-sites.php
Last active February 8, 2017 00:03
Multisite Plugin for the WP Austin Meetup Group
<?php
/*
Plugin Name: WP-ATX MS Demo
Plugin URI: http://wpaustin.com
Description: Demoing WordPress Multisite Features
Version: 0.1
Author: ryanshoover
License: GPLv2 or later
Text Domain: wpatxms
*/
@ryanshoover
ryanshoover / rowley-redirect.php
Last active February 14, 2017 17:39
WordPress - Redirect 404s that end in a post's name
<?php
/**
* Plugin Name: Rowley Redirect
* Description: Redirect old links for posts to the current link
* Author: Ryan Hoover
* Author URI: https://github.com/ryanshoover
* Version: 0.1
*/
/**