Skip to content

Instantly share code, notes, and snippets.

View jbrinley's full-sized avatar

Jonathan Brinley jbrinley

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jbrinley on github.
  • I am jbrinley (https://keybase.io/jbrinley) on keybase.
  • I have a public key whose fingerprint is C697 B2D2 BE92 218A 8008 BA4B 66AD FFFF 3754 7705

To claim this, I am signing this object:

@jbrinley
jbrinley / taxonomy.php
Created June 12, 2014 13:05
Add tags to community events submission form. Add this to the end of the modules/taxonomy.php template.
<?php
$tags_string = '';
if ( isset($_POST['tax_input']) && isset($_POST['tax_input']['post_tag']) ) {
$tags_string = $_POST['tax_input']['post_tag'];
} elseif ( get_post() && get_the_ID() ) { // is there a current post?
$current_tags = get_the_terms(get_the_ID(), 'post_tag');
$current_tags = wp_list_pluck( $current_tags, 'name' );
$tags_string = implode(', ', $current_tags);
@jbrinley
jbrinley / gist:10990289
Created April 17, 2014 15:04
Add this to functions.php in your theme to disable the automatic creation of future events.
add_action('init', 'disable_future_event_scheduling', 11, 0);
function disable_future_event_scheduling() {
TribeEventsRecurrenceMeta::get_scheduler()->remove_hooks();
}
<?php
/*
Plugin Name: The Events Calendar - Cleanup Recurrence Duplicates
Description: Some users upgrading from an earlier version of Events Calendar PRO may, in rare circumstances, end up with duplicates of recurring events.
Version: 3.5
Author: Modern Tribe, Inc.
Author URI: http://tri.be?ref=tec-plugin
Text Domain: tribe-events-calendar-recurrence-cleanup
License: GPLv2 or later
<?php
function tribe_filter_import_data_before( $post ) {
if ( $post['post_type'] == TribeEvents::POSTTYPE && !empty($post['post_parent']) ) {
$start_date = '';
if ( isset($post['postmeta']) && is_array($post['postmeta']) ) {
foreach ( $post['postmeta'] as $meta ) {
if ( $meta['key'] == '_EventStartDate' ) {
$start_date = $meta['value'];
<?php
require_once( 'wp-includes/class-wp-hook.php' );
require_once( 'wp-includes/class-wp-hook-iterator.php' );
function _wp_filter_build_unique_id($tag, $function, $priority) {
global $wp_filter;
static $filter_id_count = 0;
if ( is_string($function) )
@jbrinley
jbrinley / fill-the-db.php
Created February 19, 2014 14:42
Adds 1M actions to the Action Scheduler queue, with 20K of them already due, and another 100 coming due each minute.
<?php
function action_scheduler_load_testing() {
/** @var wpdb $wpdb */
global $wpdb;
$sql = "INSERT INTO {$wpdb->posts} (post_author, post_date, post_date_gmt, post_content, post_title, post_status, post_name, post_modified, post_modified_gmt, post_type) VALUES ";
for ( $i = -200 ; $i < 9800 ; $i++ ) {
$date = new DateTime($i.' minutes');
$action = md5($i);
<?php
/*
Plugin Name: The Events Calendar - Downgrade Recurrence
Description: Downgrading from 3.4 to an earlier version of The Events Calendar? Activate this plugin to restore recurrence settings.
Version: 1.0
Author: Modern Tribe, Inc.
Author URI: http://tri.be?ref=tec-plugin
Text Domain: tribe-events-calendar
License: GPLv2 or later
<?php
/**
* Switch the interal blog id.
*
* This changes the blog id used to create keys in blog specific groups.
*
* @since 3.5.0
*
* @param int $blog_id Blog ID
*/
@jbrinley
jbrinley / test_17817.php
Last active December 28, 2015 14:59
17817 Performance Test - Benchmarks the patch submitted at http://core.trac.wordpress.org/ticket/17817
<?php
require_once( dirname( __FILE__ ) . '/test_17817_shared.php' );
if ( isset($_SERVER['HTTP_HOST']) ) { echo "<pre>"; }
printf( "Running %d times with %d callbacks\n", TICKET_17817_LOOP_COUNT, TICKET_17817_CALLBACK_COUNT );
$old_path = dirname( __FILE__ ) . '/test_17817_old.php';
$new_path = dirname( __FILE__ ) . '/test_17817_new.php';
$old_results = unserialize( shell_exec( sprintf( 'php "%s"', $old_path ) ) );