Skip to content

Instantly share code, notes, and snippets.

Avatar

Phil Wylie mustardBees

View GitHub Profile
@mustardBees
mustardBees / functions.php
Created Aug 27, 2013
Register a store post type in WordPress
View functions.php
<?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 Aug 27, 2013
Metabox to save store information
View functions.php
<?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 Aug 27, 2013
Using WP_Query to pull out our stores, loop through and output into a list
View template.php
<?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 Aug 27, 2013
JavaScript to display our map. Loop through list items, add markers to map.
View script.js
( 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 Aug 27, 2013
Enqueue Google Maps API and our script to initialise the map
View functions.php
<?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 Oct 25, 2013
Enable background updates for version controlled sites
View background-updates.php
<?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 Oct 30, 2013
Disable all WordPress auto update email notifications
View disable-auto-update-emails.php
<?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 Oct 30, 2013
Change WordPress auto update email address
View change-auto-update-email-address.php
<?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 Nov 20, 2020
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.
View functions.php
<?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 Dec 20, 2013
WordPress snippet which prevents your plugin from being included in the list of plugins sent to WordPress.org to check for updates.
View plugin-file.php
<?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
You can’t perform that action at this time.