Skip to content

Instantly share code, notes, and snippets.

View spacedmonkey's full-sized avatar
🖐️
Open for work

Jonny Harris spacedmonkey

🖐️
Open for work
View GitHub Profile
@spacedmonkey
spacedmonkey / gist:0409ac984a58b2bf159b
Created October 6, 2014 19:09
Post Terms Command
<?php
/**
* Manage posts terms.
*
* @package wp-cli
*/
class Post_Terms_Command extends \WP_CLI\CommandWithDBObject {
protected $obj_type = 'post terms for';
$script_tag = "<script type='text/javascript' src='%s'></script>\n";
/**
* Filter the script tag.
*
* @since 4.1.0
*
* @param string $script_tag Script tag.
* @param string $src Source of script.
* @param string $handle Script handle.
* @param boolean $concat Is concat
// Ping the cron on the portal site to trigger term import now
$portal_site_url = get_home_url( $sync_destination );
$portal_site_url = apply_filters('aggregator_remote_get_url', $portal_site_url);
$args = array(
'blocking' => false,
'timeout' => WP_CRON_LOCK_TIMEOUT
);
$args = apply_filters('aggregator_remote_get_args', $args, $portal_site_url);
function change_aggregator_remote_get_url($url){
$parse = parse_url($url);
return str_replace($parse['host'], "localhost", $url);
}
add_filter('aggregator_remote_get_url', 'change_aggregator_remote_get_url');
function change_aggregator_remote_get_args($args, $url){
$parse = parse_url($url);
foreach ( $collection as $term ){
$term_post = get_post( $term->name );
if( is_a( $term_post, 'WP_Post' ) && $term_post->post_status == 'publish'){
$term->post = $term_post;
}
}
@spacedmonkey
spacedmonkey / gist:0ef1258e70341b81e445
Created May 8, 2015 14:59
WordPress load jquery from CDN
<?php
class jQuery_CDN {
/**
* @var int
*/
private $jquery_version = 0;
/**
* @var int
*/
<?php
/*
Plugin Name: Advanced Nav Caching
Description: Cache nav output
Version: 1.0.0
Author: Spacedmonkey
*/
class Advanced_Nav_Cache {
/**
* Retrieve site option value based on name of option.
*
* @since 2.8.0
*
* @see get_option()
*
* @global wpdb $wpdb
*
* @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
callback: function ( elem, op ) {
if( op === 'load' ) {
if (elem.getAttribute('data-echo-srcset') !== null) {
elem.setAttribute('srcset', elem.getAttribute('data-echo-srcset'));
}
}
}
@spacedmonkey
spacedmonkey / gist:7989920
Created December 16, 2013 16:31
Not load plugin text domain unless file found
/**
* Load the plugin text domain for translation.
*
* @since 2.0
*/
public function load_plugin_textdomain() {
$domain = $this->plugin_slug;
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );