Skip to content

Instantly share code, notes, and snippets.

Phil Wylie mustardBees

Block or report user

Report or block mustardBees

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mustardBees
mustardBees / gist:4434372
Last active Dec 10, 2015
Replace the WooCommerce registration function
View gist:4434372
/**
* Custom WooCommerce registration process
*/
function iweb_woocommerce_process_registration() {
// Duplicate of woocommerce_process_registration() with our modifications
}
/**
* Replace the WooCommerce registration function
*
@mustardBees
mustardBees / gist:4475788
Created Jan 7, 2013
Add Mixcloud oEmbed support to WordPress
View gist:4475788
/**
* Register additional oEmbed providers
*
* @author Syed Balkhi
* @link http://goo.gl/tccJh
*/
function iweb_register_additional_oembed_providers() {
wp_oembed_add_provider( 'http://www.mixcloud.com/*', 'http://www.mixcloud.com/oembed' );
}
add_action( 'init', 'iweb_register_additional_oembed_providers' );
@mustardBees
mustardBees / iweb-logout-url-shortcode.php
Created Feb 4, 2013
Allows you to place a logout link within the WordPress editor.
View iweb-logout-url-shortcode.php
/**
* Return logout URL and redirect to homepage
*
* Allows you to place a logout link within the WordPress editor. In visual
* view set the link to [logout-url], in text view, use
* <a href="[logout-url]">logout</a>.
*
* @author Phil Wylie
* @link http://goo.gl/025f5
*/
@mustardBees
mustardBees / iweb_get_dynamic_sidebar.php
Last active Dec 16, 2015
WordPress, get a sidebar as displayed on another page
View iweb_get_dynamic_sidebar.php
<?php
/**
* Get sidebar as displayed on another page
*
* A dirty way to grab a sidebar as it's displayed on another page. Useful for
* when widgets output a menu and you need to display the same menu on a post
* type archive/single page.
*
* @author Phil Wylie
* @link http://goo.gl/qYf8H
@mustardBees
mustardBees / functions.php
Created May 10, 2013
Add additional image sizes to the WordPress media upload/insert interface
View functions.php
<?php
/**
* Add additional image sizes to the WordPress media upload/insert interface
*
* @author Daniel Roizer
* @link http://goo.gl/0tKD0
*/
function iweb_additional_image_sizes( $sizes ) {
$additional_image_sizes = array(
'banner' => 'Banner'
@mustardBees
mustardBees / functions.php
Last active Dec 17, 2015
Get an excerpt from a specific post ID or post object with a variable excerpt length
View functions.php
<?php
/**
* Get the excerpt of a specific post ID or object
*
* @author Pippin Williamson
* @link http://goo.gl/lhtZD
* @param object/int $post The ID or object of the post to get the excerpt of
* @param int $length The length of the excerpt in words
* @param string $tags The allowed HTML tags. These will not be stripped out
* @param string $extra Text to append to the end of the excerpt
@mustardBees
mustardBees / metaboxes.php
Last active Dec 17, 2015
Example code to populate a CMB select field with posts from a custom post type.
View metaboxes.php
<?php
/**
* Get a list of downloads
*
* Return an array of downloads suitable for CMB's select field.
*
* Example CMB select field usage:
*
* array(
* 'name' => 'Download',
@mustardBees
mustardBees / front-page.php
Created Jun 3, 2013
WordPress template snippet to display an image from a CMB file field. Make sure you've registered your CMB field with 'save_id' => true. When the field is saved, the attachment ID will be saved in a custom field and can be accessed by appending _id to your chosen custom field id.
View front-page.php
<?php $attachment_id = get_post_meta( get_the_ID(), '_cmb_image_id', true ); ?>
<?php if ( ! empty( $attachment_id ) ) : ?>
<?php echo wp_get_attachment_image( $attachment_id, 'thumbnail' ); ?>
<?php endif; ?>
@mustardBees
mustardBees / functions.php
Last active Dec 18, 2015
Include CMB's init.php on the 'init' WordPress hook
View functions.php
<?php
/**
* Initialise CMB
*
* @author Phil Wylie
* @link http://goo.gl/MhJPe
*/
function pw_initialise_cmb() {
if ( ! class_exists( 'cmb_Meta_Box' ) ) {
require 'lib/init.php';
View map.js
$('a#show-map').click(function(e) {
e.preventDefault();
$('#map-container').show();
google.maps.event.trigger(map, 'resize');
map.setCenter(latLng);
});
You can’t perform that action at this time.