Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
#!/bin/sh
# A script that leverages Trac XML-RPC (I know, I know) to upload patches.
#
# This script is written specifically for the Mac, in that it reads from
# your keychain to derive your SVN password. You can change the SVN_PASS
# line below if you wanted to pull from ~/.svn/ or what not.
#
# Basic usage: `trac-attach.sh 12345` uploads a patch to ticket #12345,
# using the name 12345.diff. If there exists a 12345.diff, the patch is
@DrewAPicture
DrewAPicture / invalid_locations.php
Created February 16, 2013 21:34
Remove invalid menu locaitons
<?php
if ( is_array( $menu_locations ) ) {
foreach ( $menu_locations as $key => $value ) {
if ( ! is_string( $key ) )
unset( $menu_locations[$key] );
}
}
set_theme_mod( 'nav_menu_locations', $menu_locations );
@DrewAPicture
DrewAPicture / clean_404_emails.php
Last active September 27, 2023 09:03
Original snippet by wp-mix.com at http://wp-mix.com/wordpress-404-email-alerts/ With the improved OOP style, implementation is a lot more straightforward, just add <?php new Clean_404_Email; to the top of your 404.php template.
<?php
// Just require() this class via your theme's functions.php file.
/* Then instantiate this at the top of your 404.php file with:
if ( class_exists( 'Clean_404_Email' ) )
new Clean_404_Email;
*/
class Clean_404_Email {
var $time, $request, $blog, $email, $theme, $theme_data, $site, $referer, $string, $address, $remote, $agent, $message;
@DrewAPicture
DrewAPicture / term_singular.php
Last active December 14, 2015 13:48
Too "clever" for core? It's the battle of that one multi-line condition that forces curly braces.
<?php
if ( is_tax() )
$title = get_taxonomy( get_queried_object()->taxonomy )->labels->singular_name;
elseif ( something else )
vs
if ( is_tax() ) {
$term = get_queried_object();
$tax = get_taxonomy( $term->taxonomy );
<?php
add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );
<?php
// From wp-admin/nav-menus.php
break;
case 'locations':
check_admin_referer( 'save-menu-locations', 'save-menu-locations-nonce', false );
// Get existing menu locations assignments
$locations = get_registered_nav_menus();
$menu_locations = get_nav_menu_locations();
<?php
$children = wp_list_pages(array(
'title_li' => '',
'child_of' => $post_id,
'sort_column' => 'menu_order',
'post_status' => 'publish',
'echo' => 0
) );
$children = get_pages( array(
@DrewAPicture
DrewAPicture / old_domain_to_new.sql
Created April 1, 2013 23:36
Change old domain to a new one in WordPress. Props @krislagraff
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
@DrewAPicture
DrewAPicture / wp_core_doc_tags.sh
Last active December 15, 2015 22:19
This script returns counts for the ~20 most-used phpdoc @tags used in WordPress core as of 3.6 Beta 1. Uses ack to get the counts.
#!/bin/bash
# Return counts for 20 phpDoc @tags used in WordPress core
# @tags array
tags=( @var @package @subpackage @since @link @deprecated @param @return @access @name @copyright @author @license @version @see @uses @internal @TODO @global @result @option @method )
echo "Total @tags to search: ${#tags[*]}"
@DrewAPicture
DrewAPicture / gist:5506043
Created May 2, 2013 22:44
New Functions in 3.6
wp_add_id3_tag_data()
wp_read_video_metadata()
wp_read_audio_metadata()
wp_nav_menu_disabled_check()
wp_nav_menu_update_menu_items()
do_accordion_sections()
wp_slash()
wp_unslash()
wp_is_writable()
wp_auth_check_load()