Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
for i in `cat unusual.txt`; do echo "$RANDOM $i"; done | sort | sed -E 's/^[0-9]+ //' > randorder.txt
@DrewAPicture
DrewAPicture / plugin_repo_bookmarklet.html
Last active December 19, 2015 18:09
Plugin Repo bookmarklet. Clicking this bookmarklet while on any WordPress.org-hosted plugin page or sub-page will jump you to the trunk directory of that plugin's SVN repository..
<a href="javascript:(function(){var split=window.location.pathname.split('/');location.href='http://plugins.svn.wordpress.org/' + split[2] + '/trunk/'})();">Plugin Repo</a>
@DrewAPicture
DrewAPicture / ww_svn_log_props.php
Last active December 19, 2015 13:18
SVN log props counter. WordPress function to trawl the commits log and count props. Counts are more accurate after removing the array_reduce(). Still not totally accurate.
<?php
/**
* List contributor props from most to least
*
* @param string $url (optional) The SVN repo URL.
*/
function ww_svn_log_props( $url = 'http://core.svn.wordpress.org/trunk' ) {
$log = get_transient( '36_log' ); // 12 Hour transient
if ( ! $log ) {
$log = shell_exec( 'svn log -r 23171:HEAD --xml ' . esc_url( $url ) );
@DrewAPicture
DrewAPicture / 36_props.sh
Last active December 19, 2015 13:09
WordPress props between two revisions. Requires ack or grep (just replace ack calls with grep).
svn log http://develop.svn.wordpress.org/trunk -r 26861:HEAD | ack -i "props" | ack -ic "DrewAPicture"
@DrewAPicture
DrewAPicture / first.css
Created June 13, 2013 17:54
Working with this list of footer links (it's coming from a wp_nav_menu() call), I need to select only the first href inside the first list item.
<nav>
<div>
<ul>
<li>
<a href="#">First</a>
</li>
<li>
<a href="#">Second</a>
</li>
<li>
@DrewAPicture
DrewAPicture / git.sh
Created May 30, 2013 03:59
Branch highlighting
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: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()
@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 / 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');
<?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(