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: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 );
@spacedmonkey
spacedmonkey / gist:8039923
Created December 19, 2013 14:29
Use wp_link_pages in twitter bootstrap 3
function spacedmonkey_pages($old){
$old['before'] = '<ul class="pagination"><li class="disabled"><span>Pages: </span></li>';
$old['after'] = '</ul>';
$old['link_before'] = '<span class="">';
$old['link_after'] = '</span>';
return $old;
}
add_filter( 'wp_link_pages_args', 'spacedmonkey_pages' );
@spacedmonkey
spacedmonkey / gist:8666689
Created January 28, 2014 12:19
Change wp seo markup
/**
Change the wrapper of breadcrums to span to ul
**/
function change_breadcrumb_output_wrapper($old){
return "ul";
}
add_filter( 'wpseo_breadcrumb_output_wrapper', 'change_breadcrumb_output_wrapper' );
/**
@spacedmonkey
spacedmonkey / gist:8666712
Created January 28, 2014 12:23
Add yoast breadcrumb - bootstrap
<?php if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('<nav class="breadcrumbs" role="navigation">','</nav>');
} ?>
@spacedmonkey
spacedmonkey / gist:9688152
Last active April 22, 2024 15:25
Export to CSV - WP CLI
/**
* Export users to a CSV file.
*
* ## OPTIONS
*
* <file>
* : The CSV file to export users to.
*
* ## EXAMPLES
*
@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;
}
}