Skip to content

Instantly share code, notes, and snippets.

View boonebgorges's full-sized avatar

Boone Gorges boonebgorges

View GitHub Profile
@boonebgorges
boonebgorges / FormattedProblem.js
Created September 9, 2016 03:59
React component for content that may contain LaTeX chunks
import React from 'react';
import LaTeX from './LaTeX'
const FormattedProblem = React.createClass( {
getDefaultProps: function() {
return {
isVisible: true
}
},
@boonebgorges
boonebgorges / parsley-iff.html
Created September 8, 2016 20:30
Markup for parsley-iff
<input
name="password"
id="password"
data-parsley-trigger="blur"
data-parsley-iff="#password-confirm"
data-parsley-iff-message=""
/>
<input
name="password-confirm"
@boonebgorges
boonebgorges / parsley-iff.js
Last active September 8, 2016 20:31
Better "equalto" implementation for Parsley.js
var iffRecursion = false;
window.Parsley.addValidator( 'iff', {
validateString: function( value, requirement, instance ) {
var $partner = $( requirement );
var isValid = $partner.val() == value;
if ( iffRecursion ) {
iffRecursion = false;
} else {
iffRecursion = true;
@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 ) {
<?php
/**
* Change a site's domain.
*
* ## OPTIONS
*
* --from=<from>
* : The current domain of the site being changed.
*
* --to=<date>
@boonebgorges
boonebgorges / cac-asset-ver.php
Created June 16, 2015 13:50
Custom version querystring appending for WordPress JS and CSS assets
<?php
/**
* Note that CAC_VERSION is a custom constant. Replace as necessary.
*/
function cac_asset_ver( $tag, $handle, $src = '' ) {
// 'style_loader_tag' doesn't pass a src, so we sniff it from the tag.
if ( ! $src ) {
preg_match( '/href\=\'([^\']+)\'/', $tag, $src_matches );
if ( $src_matches ) {
$src = $src_matches[1];
<?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;

Preparing Plugins for Term Splitting

Historically, two terms in different taxonomies with the same slug (for instance, a tag and a category sharing the slug "news") have shared a single term ID. Beginning in WordPress 4.2, when one of these shared terms is updated, it will be split: the updated term will be assigned a new term ID.

In the vast majority of situations, this update will be seamless and uneventful. However, some plugins and themes store term IDs in options, post meta, user meta, or elsewhere. WP 4.2 will include two different tools to help authors of these plugins and themes with the transition.

The 'split_shared_term' action

When a shared term is assigned a new term ID, a new 'split_shared_term' action is fired. Plugins and themes that store term IDs should hook to this action to perform necessary migrations. The documentation for the hook is as follows:

@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
@boonebgorges
boonebgorges / bbg-csv-export.php
Created May 13, 2014 18:13
WordPress script for doing a .csv export of misc data
<?php
function bbg_csv_export() {
if ( ! is_super_admin() ) {
return;
}
if ( ! isset( $_GET['bbg_export'] ) ) {
return;
}