Skip to content

Instantly share code, notes, and snippets.

Avatar

Phil Wylie mustardBees

View GitHub Profile
View functions.php
<?php
/*
Plugin Name: Convert SMURF to CMB2 repeatable field groups
Plugin URI: http://www.iweb.co.uk/
Description: Go through and zero index each SMURF array.
Version: 1.0.0
Author: iWeb
Author URI: http://www.iweb.co.uk/
*/
@mustardBees
mustardBees / pw_convert_pw_gallery_to_file_list.php
Last active Feb 18, 2020
Convert pw_gallery to file_list
View pw_convert_pw_gallery_to_file_list.php
@jplhomer
jplhomer / disable-comments.sh
Created Feb 25, 2015
Disable all comments/pings in WordPress with WP-CLI
View disable-comments.sh
$ wp post list --format=ids | xargs wp post update --comment_status=closed
# Output:
# Success: Updated post 2514.
# Success: Updated post 2511.
# Success: Updated post 2504.
# Success: Updated post 2499.
# Success: Updated post 2441.
# etc...
@brianoz
brianoz / class-virtualthemedpage-bc.php
Created Feb 20, 2014
WordPress Virtual page with theme
View class-virtualthemedpage-bc.php
<?php
/*
* Virtual Themed Page class
*
* This class implements virtual pages for a plugin.
*
* It is designed to be included then called for each part of the plugin
* that wants virtual pages.
*
* It supports multiple virtual pages and content generation functions.
@nacin
nacin / auto-update.php
Last active Mar 11, 2019
This is how @dd32 and I test automatic background updates in WordPress 3.7. Then just do example.com/?wp_maybe_auto_update. (If you use a checkout of develop.svn.wordpress.org, you can run this on the `build` directory, then simply run `grunt copy` between updates to copy over the latest code from `src`. This is how we are able to make adjustmen…
View auto-update.php
<?php
// Add this as a mu-plugin.
if ( isset( $_GET['wp_maybe_auto_update'] ) ) {
add_filter( 'automatic_updates_is_vcs_checkout', '__return_false' );
add_action( 'template_redirect', function() {
$time = date( 'r' );
echo "Starting... $time<br />";
delete_site_option( 'auto_core_update_failed' );
@joshbetz
joshbetz / nav_walker_nav_menu.php
Last active Dec 12, 2015
WordPress nav menu without lists.
View nav_walker_nav_menu.php
<?php
class v12_Walker_Nav_Menu extends Walker_Nav_Menu {
function __construct() {
add_filter( 'wp_nav_menu_args', array( __CLASS__, 'items_wrap' ) );
}
/**
* @see wp_nav_menu()
View gist:3947426
<?php
$query = get_posts( array( 'posts_per_page' => 1, 'fields' => 'ids' ) );
@markoheijnen
markoheijnen / walker-page-parent-only.php
Created Oct 23, 2012
This walker for WordPress gives you the ability to only show the items that are selected
View walker-page-parent-only.php
<?php
/**
* Create HTML list of pages.
*
* @package WordPress
* @since 2.1.0
* @uses Walker
*/
class Walker_Page_Parent_Only extends Walker {
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012
Get the share counts from various APIs
View gist:2640302

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@mikejolley
mikejolley / gist:1622323
Created Jan 16, 2012
WooCommerce - Change default catalog sort order
View gist:1622323
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby');
function custom_default_catalog_orderby() {
return 'date'; // Can also use title and price
}
You can’t perform that action at this time.