Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
@DrewAPicture
DrewAPicture / gist:3962941
Created October 27, 2012 04:27
Add 'Customize' link under Appearance
function ww_add_customize_link() {
// add the Customize link to the admin menu
add_theme_page( 'Customize', 'Customize', 'edit_theme_options', 'customize.php' );
}
add_action ( 'admin_menu', 'ww_add_customize_link' );
@DrewAPicture
DrewAPicture / gist:3962923
Created October 27, 2012 04:19
Make 'First Last' default-style display name
/**
* Build 'First Last' user display name
*
* Sets up default-style Display Name for users on new registrations
*
* @param int $user_id
* @uses wp_insert_user()
*/
function ww_default_display_name( $user_id ) {
$first = get_user_meta( $user_id, 'first_name', true );
@DrewAPicture
DrewAPicture / gist:3962905
Created October 27, 2012 04:09
Add Network plugins links to WordPress Toolbar
/**
* Add plugin page links to Toolbar in Multisite
*
* Adds Toolbar link to the 'Plugins' list page in Network Admin
* Adds Toolbar link to 'Add New Plugin' in Network Admin
* @uses global $wp_admin_bar
*/
function ww_ms_plugin_toolbar_links() {
global $wp_admin_bar;
@DrewAPicture
DrewAPicture / gist:3016024
Created June 29, 2012 05:37
Post thumbnail args
<?php the_post_thumbnail( 'thumbnail', array( 'class' => 'fl' ) ); ?>
<?php the_post_thumbnail( array( 150, 150 ), array( 'class' => 'fr' ) ); ?>
@DrewAPicture
DrewAPicture / gist:2998325
Created June 26, 2012 19:39
Show git branch in Terminal (Mac)
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PS1="$GREEN\u@machine$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ "
@DrewAPicture
DrewAPicture / 0-env-url-override.php
Created June 20, 2012 15:35 — forked from mjangda/0-env-url-override.php
How to use WordPress across environments without needing to mess with URLs in the database.
<?php
// This is the meat of the plugin and should go in mu-plugins/0-env-url-override.php
// Only load these filters if we're not in the production environment
if ( defined( 'ENV_NOT_PRODUCTION' ) && ENV_NOT_PRODUCTION ) {
// This always needs to be filtered
add_filter( 'site_url', 'env_filter_site_url', 0 );
// We don't filter home_url in the admin so that we get production URLs for posts.
// This does break certain links like "Preview/View Post", however.
@DrewAPicture
DrewAPicture / gist:2928548
Created June 14, 2012 07:00
Verbose or compact?
<?php
if ( ! wp_is_large_network( 'users' ) ) {
$num = '<a href="' . network_admin_url('users.php') . '">' . $num . '</a>';
$text = '<a href="' . network_admin_url('users.php') . '">' . $text . '</a>';
} else {
$num = '<a href="' . network_admin_url('users.php') . '">10,000+</a>';
$text = '<a href="' . network_admin_url('users.php') . '">' . $text . '</a>';
?>
@DrewAPicture
DrewAPicture / gist:2906793
Created June 10, 2012 18:11
Link to SmugMug gallery from Events Archive + SmugMug thumb as link
<?php if ( $recent->have_posts() ) : while ( $recent->have_posts() ) : $recent->the_post();
// Pull the URL from the_content()
$link = esc_url( get_the_content() );
// Check if it's a properly formed URL, append http:// if not. Don't want user to struggle here
if ( ! preg_match('/^http:\/\//', $link ) )
$link = 'http://' . $link;
// Setup args for our oEmbed
@DrewAPicture
DrewAPicture / gist:2896578
Created June 8, 2012 16:18
Display unfiltered events content on single
if ( is_single() && in_category( 'recent-events' ) ) {
$content = get_the_content();
echo $content;
} else {
// Main loop content goes here
}
@DrewAPicture
DrewAPicture / subfolder_post_formats
Created April 2, 2012 20:51
Post Formats templates in sub-folder
<?php $format = get_post_format();
if ( $format === false )
$format = 'standard';
get_template_part( 'formats/content', $format ); ?>