Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
@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: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 / 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: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: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: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 / masonry-init.js
Created November 10, 2012 09:49
Masonry and WP post_class();
/**
* #content references the outer container selector
* .post references in the inner containers selectors
*/
jQuery(document).ready(function(){
jQuery( '#content' ).masonry({
itemSelector: '.post',
columnWidth: 320
});
@DrewAPicture
DrewAPicture / plupload_scaling.php
Last active October 12, 2015 18:38
Enable and set plupload scaling dimensions
function plupload_scaling( $defaults ) {
$defaults['resize'] = array(
'width' => 1024,
'height' => 1024,
'quality' => 100
);
return $defaults;
}
add_filter( 'plupload_default_settings', 'plupload_scaling' );
@DrewAPicture
DrewAPicture / gist:4103650
Created November 18, 2012 05:01
Unregister all Core widgets
/**
* Unregister Core Widgets
*
* Unregisters all core widgets based on their individual
* class names.
*
* @uses unregister_widget() to unregister from the Widget Factory class
*/
function remove_core_widgets() {
unregister_widget( 'WP_Widget_Calendar' );
<?php
//Plugin Name: Comments in Account Menu
new Comments_in_Account_Menu();
class Comments_in_Account_Menu {
function __construct() {
add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu' ) );