Skip to content

Instantly share code, notes, and snippets.

View roborourke's full-sized avatar
🤠

Robert O'Rourke roborourke

🤠
View GitHub Profile
<?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 / 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
@roborourke
roborourke / wp-sslverify-hack.php
Created April 11, 2015 11:36
Hack to work with external APIs that require ssl verification on a local install of WordPress
<?php
// include the following in your wp-config.php or any file that is run before WP is loaded
global $wp_filter;
function hm_kill_sslverify( $args, $url ) {
$args['sslverify'] = false;
@roborourke
roborourke / ms-remove-permalink-blog-slug.php
Created May 12, 2015 14:09
Remove /blog slug from permalinks on WordPress multisite