Skip to content

Instantly share code, notes, and snippets.

View johnregan3's full-sized avatar

John Regan johnregan3

View GitHub Profile
@johnregan3
johnregan3 / wp-amp-tutorial-register-templates.php
Last active September 28, 2016 16:23
Registering a Custom Template with the WP AMP plugin
<?php
/**
* Add a custom AMP template file.
*
* Registers templates in a templates subdirectory by post type slug.
* (e.g., "./templates/book.php")
*
* @filter amp_post_template_file
*
* @param string $file The file name input.
@johnregan3
johnregan3 / wp-amp-tutorial-register-cpts.php
Last active July 21, 2016 17:54
Registering a Custom Post Type with the WP AMP plugin
<?php
/**
* Register CPTs to be included with AMP integration.
*
* Be sure to visit Settings > Permalinks and save twice
* to ensure the rewrite rules are flushed after adding this.
*
* @action amp_init
*/
function jr3_amp_register_post_types() {
@johnregan3
johnregan3 / jr3-improved-awp-rules.php
Last active February 13, 2016 01:56
My "improved" version of the AdvancedWP rules :D
<?php
/**
* Plugin Name: John Regan's Improved AWP Rules
* Plugin URI: https://gist.github.com/johnregan3/4a145185d97dd33806ad
* Version: 1.0
*
* @see http://www.advancedwp.org/awp-contribution-rules/
*
* Description: Yes, I get it -- this document was never intended to be technical, it's intended to be fun and readable.
* This is not intended to be a criticism of the original in any way; it's just a way for me to introduce myself to the group,
@johnregan3
johnregan3 / oop-plugin-basic.php
Last active December 27, 2019 00:42
Basic Demonstration of Using OOP in a WordPress Plugin
/*
* Plugin Header...
*
* Note: This particular block of code won't actually run because it doesn't have
* the details of the register_post_type and register_taxonomy functions filled in.
*/
class JR3_Books {
/**
@johnregan3
johnregan3 / genesis-custom-favicon.php
Last active November 1, 2017 22:06
Filter to add a custom favicon to your Genesis child theme.
<?php
/**
* Add custom Genesis favicon
*
* Dude, replace the default Genesis favicon so you don't look like a n00b.
* Create your custom favicon.ico and place it in your child theme's directory.
* Add this code to your child theme's functions.php
*
* Images can be converted to the .ico format here: http://www.favicon-generator.org/
### Keybase proof
I hereby claim:
* I am johnregan3 on github.
* I am johnxwp (https://keybase.io/johnxwp) on keybase.
* I have a public key whose fingerprint is 2D1B 7A65 8C07 4C6D C7F9 96B9 9204 900E DDA2 50A4
To claim this, I am signing this object:
@johnregan3
johnregan3 / hello-slj.php
Last active August 29, 2015 14:00
Hello Samuel L Jackson WordPress Plugin
<?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+
*/
@johnregan3
johnregan3 / stream-user-generator.php
Last active August 29, 2015 14:00
Stream User Generator
<?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 / vertical-featured-image.php
Last active January 2, 2016 00:49
Add Support for Featured Images in you WordPress theme. Requires CSS like ".vertical-image { float:left; }" to work correctly.
@johnregan3
johnregan3 / removing-duplicates.php
Created November 15, 2013 20:35
Removing duplicate brightcove ID's
$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