Skip to content

Instantly share code, notes, and snippets.

View mustardBees's full-sized avatar

Phil Wylie mustardBees

View GitHub Profile
@mustardBees
mustardBees / functions.php
Created August 27, 2013 16:30
Register a store post type in WordPress
<?php
/**
* Create store post type
*
* @author Phil Wylie
* @link http://goo.gl/bjc6XV
*/
function pw_register_store_post_type() {
$labels = array(
'name' => 'Stores',
@mustardBees
mustardBees / functions.php
Created August 27, 2013 17:36
Metabox to save store information
<?php
/**
* Metabox to save store information
*
* @author Phil Wylie
* @link http://goo.gl/zJwIk5
*/
function pw_register_store_metabox( $meta_boxes ) {
$prefix = '_cmb_'; // Prefix for all fields
@mustardBees
mustardBees / template.php
Created August 27, 2013 20:26
Using WP_Query to pull out our stores, loop through and output into a list
<?php
$args = array(
'posts_per_page' => -1,
'post_type' => 'store'
);
$stores = new WP_Query( $args );
?>
<?php if ( $stores->have_posts() ) : ?>
<div id="store-locations-map" style="width: 100%; height: 300px;"></div>
@mustardBees
mustardBees / script.js
Created August 27, 2013 20:29
JavaScript to display our map. Loop through list items, add markers to map.
( function( $ ) {
$( document ).ready( function() {
var myMapOptions = {
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map( document.getElementById( 'store-locations-map' ), myMapOptions );
var markerBounds = new google.maps.LatLngBounds();
@mustardBees
mustardBees / functions.php
Created August 27, 2013 21:03
Enqueue Google Maps API and our script to initialise the map
<?php
wp_register_script( 'pw-google-maps-api', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', null, null, true );
wp_enqueue_script( 'pw-store-locations', get_stylesheet_directory_uri() . '/js/store-locations.js', array( 'jquery', 'pw-google-maps-api' ), null, true );
@mustardBees
mustardBees / background-updates.php
Created October 25, 2013 09:46
Enable background updates for version controlled sites
<?php
/*
Plugin Name: Enable background updates for version controlled sites
Plugin URI: http://www.iweb.co.uk/
Description: Override the check for version controlled checkouts to allow automatic updates.
Version: 1.0
Author: iWeb
Author URI: http://www.iweb.co.uk/
*/
add_filter( 'automatic_updates_is_vcs_checkout', '__return_false' );
@mustardBees
mustardBees / disable-auto-update-emails.php
Created October 30, 2013 14:57
Disable all WordPress auto update email notifications
<?php
/*
Plugin Name: Disable all WordPress auto update email notifications
Plugin URI: http://www.iweb.co.uk/
Description: Disable all WordPress auto update email notifications following an automatic update.
Version: 1.0
Author: iWeb
Author URI: http://www.iweb.co.uk/
*/
add_filter( 'auto_core_update_send_email', '__return_false' );
@mustardBees
mustardBees / change-auto-update-email-address.php
Created October 30, 2013 15:16
Change WordPress auto update email address
<?php
/*
Plugin Name: Change WordPress auto update email address
Plugin URI: http://www.iweb.co.uk/
Description: Change the email address auto update notifications are sent to following an automatic update.
Version: 1.0
Author: iWeb
Author URI: http://www.iweb.co.uk/
*/
function iweb_filter_auto_update_email( $email ) {
@mustardBees
mustardBees / functions.php
Last active October 4, 2024 13:37
Filter a few parameters into WordPress YouTube oEmbed requests. Enable modest branding which hides the YouTube logo. Remove the video title and uploader information. Prevent related videos from being shown once the video has played.
<?php
/**
* Filter a few parameters into YouTube oEmbed requests
*
* @link http://goo.gl/yl5D3
*/
function iweb_modest_youtube_player( $html, $url, $args ) {
return str_replace( '?feature=oembed', '?feature=oembed&modestbranding=1&showinfo=0&rel=0', $html );
}
add_filter( 'oembed_result', 'iweb_modest_youtube_player', 10, 3 );
@mustardBees
mustardBees / plugin-file.php
Created December 20, 2013 19:12
WordPress snippet which prevents your plugin from being included in the list of plugins sent to WordPress.org to check for updates.
<?php
/**
* Don't update this plugin
*
* This prevents you from being prompted to update if there's a public plugin
* with the same name.
*
* @author Phil Wylie
* @link http://link.from.pw/1cFfcFZ
* @param array $r Request arguments