Skip to content

Instantly share code, notes, and snippets.

John Regan johnregan3

Block or report user

Report or block johnregan3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@johnregan3
johnregan3 / dynamically-generated-settings.php
Last active Sep 9, 2017
A method for dynamically generating Settings Fields in WordPress through the use of an anonymous function assigned to a variable variable. This could be expanded to generate different input types (hidden, text, textarea, and maybe a select), and to dynamically generate Setting Sections and Section Callbacks.
View dynamically-generated-settings.php
<?php
/*
* Dynamically Generated Checkboxes in a WordPress Settings Page
*
* This file is fully functional and ready to be used in a plugin or theme to generate this Settings Page
*
*/
Class Pizza_Shop {
@johnregan3
johnregan3 / cpt_in_wp_submenu.php
Last active Jan 5, 2018
Add Custom Post Type to WordPress Plugin Submenu (Hack)
View cpt_in_wp_submenu.php
<?php
/*
Plugin Name: Nerfherder Plugin
Plugin URI: https://gist.github.com/johnregan3/6133389
Description: Demonstration of how to add Custom Post Types to Submenu Items
Author: John Regan
Author URI: http://johnregan3.com
Version: 1.0
*/
@johnregan3
johnregan3 / mysql2date-unit-test.php
Created Aug 9, 2013
WordPress Unit Test for get_post_time(), get_post_modified_time() and mysql2date()
View mysql2date-unit-test.php
<?php
/**
* Tests if get_post_time() and get_post_modified_time() return GMT(UTC) times correctly.
*
* get_post_time() and get_post_modified_time() have a parameter for GMT(UTC) time.
* However, they use mysqldate(), which does not take such a parameter.
* mysql2date() expects the default timezone to be set to GMT(UTC), but when it is not,
* get_post_time() and get_post_modified_time() do not correctly return GMT(UTC) time.
* To prove this, test_get_post_time() and test_get_post_modified_time() should return two
@johnregan3
johnregan3 / save_post_post_type_test.php
Last active Dec 21, 2015
Unit Test for WordPress' save_post{$post_type}
View save_post_post_type_test.php
<?php
/**
* This has been tested using the diff for save_post_{$post_type}
* https://core.trac.wordpress.org/changeset/25050
*
* @todo Try different post type names
* @todo Create two posts and try to update them both at the same time
*/
@johnregan3
johnregan3 / schedule-event-tutorial.php
Last active Dec 29, 2015
Code for a wp_schedule_single_event Tutorial.
View schedule-event-tutorial.php
<?php
/**
* Plugin Name: Schedule Event Tutorial
* Description: Schedules single event to uncheck a checkbox on a custom Menu page
* Version: 0.1
* Author: John Regan
* Author URI: http://johnregan3.me
* Text Domain: setjr3
* License: GPLv2+
@johnregan3
johnregan3 / import_videos.php
Last active Dec 28, 2015
import_videos.php
View import_videos.php
<?php
// Untested Code!
//Generate New Page from Video
function copy_videos_to_pages( $post_id ) {
// Only if we're saving a flowplayer5 video
if ( 'flowplayer5' !== get_post_type( $post_id ) )
return $post_id;
@johnregan3
johnregan3 / removing-duplicates.php
Created Nov 15, 2013
Removing duplicate brightcove ID's
View removing-duplicates.php
$playlist = array(
[0] => WP Post Object
[ID] => 1;
[_brightcove_id] = 1
[1] => WP Post Object
[ID] => 2;
[_brightcove_id] = 2
[2] => WP Post Object
[ID] => 3;
[_brightcove_id] = 1
@johnregan3
johnregan3 / vertical-featured-image.php
Last active Jan 2, 2016
Add Support for Featured Images in you WordPress theme. Requires CSS like ".vertical-image { float:left; }" to work correctly.
View vertical-featured-image.php
@johnregan3
johnregan3 / stream-user-generator.php
Last active Aug 29, 2015
Stream User Generator
View stream-user-generator.php
<?php
/**
* Plugin Name: Stream User Generator
* Description: Generates X-Team users for testing
* Version: 0.1
* Author: johnregan3
* Author URI: http://johnregan3.me
*
* USE:
* Upload this into your Plugins directory.
@johnregan3
johnregan3 / hello-slj.php
Last active Aug 29, 2015
Hello Samuel L Jackson WordPress Plugin
View hello-slj.php
<?php
/**
* Plugin Name: Hello Samuel L Jackson
* Description: Inserts random movie quotes by Samuel L. Jackson into your Admin header.
* Version: 1.0
* Author: John Regan
* Author URI: http://johnregan3.me
* License: GPLv2+
*/
You can’t perform that action at this time.