Skip to content

Instantly share code, notes, and snippets.

View boonebgorges's full-sized avatar

Boone Gorges boonebgorges

View GitHub Profile
@boonebgorges
boonebgorges / gist:19f5aef3c406e7d3739b
Created June 14, 2014 19:39
vim search and replace string for replacing extract() variables with reference to the $r array
s/\$\([a-z_]\{2,\}\)/$r['\1']/gc
<?php
// Bail if WP-CLI is not present.
if ( !defined( 'WP_CLI' ) ) return;
class BBG_Command extends WP_CLI_Command {
public function generate_shared_terms( $args, $assoc_args ) {
global $wpdb;
<?php
/**
* Change a site's domain.
*
* ## OPTIONS
*
* --from=<from>
* : The current domain of the site being changed.
*
* --to=<date>
@boonebgorges
boonebgorges / fix-changed-plugin-filename.php
Last active September 21, 2015 19:31
Fix changed plugin filename across a network
<?php
// Use: $ wp eval-file fix-changed-plugin-filename.php
global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
$p = 'list-category-posts/list_cat_posts.php';
$new_p = 'list-category-posts/list-category-posts.php';
foreach ( $blog_ids as $blog_id ) {
@boonebgorges
boonebgorges / gist:1331676
Created November 1, 2011 19:39
Display BuddyPress group content in the context of the associated groupblog
<?php
/**
* Does the grunt work
*/
function bbg_test_groupblog_idea2() {
global $wpdb, $bp, $current_blog;
// Never do this on the root blog
if ( bp_is_root_blog() )
@boonebgorges
boonebgorges / gist:2571318
Created May 1, 2012 20:56
Update Woo Framework for all WooThemes on an installation
<?php
/**
* Updates Woo Framework in all WooThemes on a WP installation
*
* To use:
*
* - Get the latest copy of the framework
* - Unzip to /wp-content/framework/
* - Visit wp-admin?cac_update_woo=1 as super admin
@boonebgorges
boonebgorges / gist:3430079
Created August 22, 2012 22:27 — forked from markjaquith/gist:2628225
Script to sync WordPress SVN to GitHub
#!/bin/bash
# cd into the directory
cd ~/gitsync/github-wordpress-sync/;
# Make sure we are not already running
if [ -f .sync-running ];then
if test ! `find ".sync-running" -mmin +10`;then
# Currently running, but not stuck
exit 1;
fi
fi;
@boonebgorges
boonebgorges / gist:3657745
Created September 6, 2012 15:54
WP filter to turn email-style quotes into blockquotes
<?php
/**
* Turn email-style quotes into blockquotes
*
* For example:
*
* My friend said:
*
* > You are handsome and also
@boonebgorges
boonebgorges / bbg-widget-setter.php
Created October 18, 2012 01:31
Class for clearing widget sidebars and adding widgets to sidebars
<?php
/**
* Recommended usage: Don't use this at all. Setting widgets programatically is generally a bad idea.
* Let your users do it - that's what the UI is for.
*
* However, if you must use it:
* BBG_Widget_Setter::clear_sidebar( 'sidebar-1' );
* to clear the widgets from the sidebar called 'sidebar-1' (they are moved to
* "Inactive Widgets".) And:
@boonebgorges
boonebgorges / bbg-is-admin.php
Created November 28, 2012 22:20
A function for reliably testing whether you're in the WordPress Dashboard
<?php
/**
* Are we looking at the WordPress admin?
*
* Because AJAX requests are sent to wp-admin/admin-ajax.php, WordPress's
* is_admin() function returns true when DOING_AJAX. This function contains
* logic to test whether AJAX requests are coming from the front end or from
* the Dashboard.
*
* @return bool