Skip to content

Instantly share code, notes, and snippets.

View roborourke's full-sized avatar
🤠

Robert O'Rourke roborourke

🤠
View GitHub Profile
@roborourke
roborourke / co-authors-plus-contactmethods.php
Last active December 27, 2015 18:29
Adds all contact methods to co-authors-plus plugin guest authors screen
<?php
// Adds all contact methods to co-authors-plus plugin guest authors screen
add_filter( 'coauthors_guest_author_fields', 'coauthors_contactmethods', 10, 2 );
function coauthors_contactmethods( $fields, $groups ) {
if ( ! in_array( 'contact-info', $groups ) && $groups[ 0 ] !== 'all' )
return $fields;
<?php
// use the script loader filter to target specific scripts by handle
add_filter( 'script_loader_src', function( $src, $handle ) {
if ( in_array( $handle, array( 'script-handle' ) )
add_filter( 'clean_url', 'mod_script_tag', 11, 1 );
return $src;
}, 10, 2 );
// change the return value to add any attributes you need on the script tag
@roborourke
roborourke / vine-oembed.php
Created April 23, 2014 16:28
A WordPress plugin for embedding content from vine
<?php
/*
Plugin Name: Vine oEmbed
Plugin URI: http://interconnectit.com
Description: Registers an oEmbed handler for Vine URLs
Version: 1.0
Author: Robert O'Rourke
Author URI: http://interconnectit.com
*/
@roborourke
roborourke / unautop-everything.php
Last active August 29, 2015 14:03
Magical unautopeerer
<?php
// unautop function for embed/images etc... with alignminet classes
add_filter( 'the_content', function( $pee ) {
$pee = preg_replace( '/<p>\s*((?:<a [^>]*?>)?<(img|iframe|object|embed) [^>]*?(\balign[a-z]+\b)? (?:[^>]*?)>(?:.*?<\/\2>)?(?:<\\/a>)?){1}\s*<\\/p>/sm', '<div class="media media-$2 $3">$1</div>', $pee );
return $pee;
}, 11 );
@roborourke
roborourke / category-dropdown-link-walker.php
Created August 27, 2014 14:45
Category dropdown with links for wordpress
@roborourke
roborourke / wp-cpt-prev-next-links.php
Created January 12, 2015 14:58
WordPress enable prev/next link for CPT / Taxonomy
@roborourke
roborourke / enqueue-html.php
Last active August 29, 2015 14:15
Enqueue HTML snippets using WP Dependencies API
<?php
add_action( 'init', array( 'Enqueue_HTML', 'get_instance' ) );
class Enqueue_HTML {
public $scripts = array();
protected static $instance;
@roborourke
roborourke / pantheon-wp-multisite.php
Last active October 27, 2022 21:46
Get subfolder multisite wordpress to work on getpantheon.com hosting
<?php
// hack to make pantheon work with subdirectory multisite
add_action( 'wpmu_new_blog', function( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
if ( defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL ) {
$abspath = untrailingslashit( ABSPATH );
$subpath = $abspath . untrailingslashit( $subpath );
if ( ! is_dir( $path ) )
@roborourke
roborourke / featured-external-image.php
Created March 20, 2015 21:45
Use any linked image in WordPress post content as a featured image
@roborourke
roborourke / strptime.php
Created April 9, 2015 17:02
strptime issue 5.5 problem
<?php
setlocale( LC_TIME, 'fr_FR' );
$date = strptime( '03 juin 2015 00:00:00', '%d %B %Y %H:%M:%S' );
$time = mktime( 0, 0, 0, $date['tm_mon'] + 1, $date['tm_mday'], $date['tm_year'] + 1900 );
var_dump( $date, $time, date( 'Y-m-d H:i:s', $time ) );
// on 5.5 returns false, 0, 1970-etc...
// on 5.6 returns array(), NNNNNNNNNN, 2015-06-03 00:00:00
// halps