Skip to content

Instantly share code, notes, and snippets.

View mboynes's full-sized avatar

Matthew Boynes mboynes

View GitHub Profile
@mboynes
mboynes / fieldmanager-demo-2.php
Last active August 29, 2015 14:19
Slideshow demo for Fieldmanager.org
<?php
// using Fieldmanager for a slideshow - any number of slides,
// with any number of related links
add_action( 'fm_post_post', function() {
$fm = new Fieldmanager_Group( array(
'name' => 'slideshow',
'limit' => 0,
'label' => __( 'New Slide', 'your-domain' ),
'label_macro' => array( __( 'Slide: %s', 'your-domain' ), 'title' ),
'add_more_label' => __( 'Add another slide', 'your-domain' ),
@mboynes
mboynes / sitemap-builder.php
Created February 9, 2012 00:05
Google XML Sitemaps Generator for WordPress 4.0beta8 Custom Post Type Fix
<?php
/*
$Id: sitemap-builder.php 420059 2011-08-06 14:31:30Z arnee $
*/
/**
* Default sitemap builder
*
* @author Arne Brachhold
<?php
add_action('publish_post', 'schedule_glossary_index', 10, 1);
function schedule_glossary_index($post_id) {
wp_schedule_single_event(time(), 'update_glossary_index', array( $post_id ));
}
add_action('update_glossary_index', 'do_update_glossary_index', 10, 1);
function do_update_glossary_index($post_id) {
global $wpdb;
global $wpdb;
$rows = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id FROM wp_blogs where blog_id > 1" ) );
foreach( $rows as $row ) {
print_r( "siteid ".$row->blog_id );
}
@mboynes
mboynes / class-pointers.php
Created September 5, 2012 14:10
Multisite tracking popup fix
<?php
/**
* @package Admin
*/
/**
* This class handles the pointers used in the introduction tour.
*
* @todo Add an introdutory pointer on the edit post page too.
*/
@mboynes
mboynes / term-split-update-examples.md
Last active December 7, 2015 19:57
Term split update examples

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:

@mboynes
mboynes / wp-tinymce-styles.php
Created January 11, 2013 22:12
WP & TinyMCE Styles Dropdown
<?php
/**
* Customize TinyMCE -- Add styles dropdown and add some custom styles. Selecting the style will add a class to the element.
*
**/
function my_tinymce_styles( $init ) {
$init['theme_advanced_buttons2_add_before'] = 'styleselect';
$init['theme_advanced_styles'] = 'Top Right Inset=insettop,Left Inset=insetleft,Right Inset=insetright';
return $init;
@mboynes
mboynes / .bash_git_color
Created February 6, 2013 15:03
Git Bash Tricks
c_purp=`tput setaf 4`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
<!DOCTYPE html>
<!--[if IE 6]>
<html id="ie6" lang="en-US">
<![endif]-->
<!--[if IE 7]>
<html id="ie7" lang="en-US">
<![endif]-->
<!--[if IE 8]>
<html id="ie8" lang="en-US">
@mboynes
mboynes / get-terms-by-overlap.php
Created June 7, 2013 21:38
Get terms from one taxonomy that relate to terms from another taxonomy through published posts.
<?php
/**
* Get terms from one taxonomy that relate to terms from another taxonomy through published posts.
* For instance, get all tags that are set on posts in the category "WordPress".
*
* @param array $args An array of options. Must contain at least 'term_ids' OR 'term_names'. Options are:
* string 'get_taxonomy' => the taxonomy whose terms you want to retrieve. Default is post_tag
* string 'through_taxonomy' => the taxonomy whose term(s) you're providing. Default is category
* array 'term_ids' => an array of term IDs through which to find overlapping terms