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
Last active August 29, 2015 13:55
Hook into Gravity Forms after form submission in order to save latitude/longitude in the format expected by the CMB Field Type: Google Maps plugin.
<?php
/**
* Save latitude/longitude for display in a CMB field
*
* @author Phil Wylie
* @link http://link.from.pw/1ejMnDr
*/
function pw_save_latitude_longitude( $entry, $form ) {
$latitude = $entry[3]; // where 3 is the field ID for latitude
$longitude = $entry[4]; // where 4 is the field ID for longitude
@mustardBees
mustardBees / functions.php
Created June 4, 2014 14:44
WordPress login page tweaks
<?php
/**
* Filter the logo on the WordPress login page
*/
function iweb_login_logo(){
echo '<style type="text/css">h1 a {background-image:url(' . get_stylesheet_directory_uri() . '/logo.png' . ') !important; background-position: center center !important; background-size: auto !important; width: 265px !important; height: 80px !important;}</style>';
}
add_filter( 'login_head', 'iweb_login_logo' );
/**
<?php
/**
* Prevent Yoast SEO redirect 302 instead 404 on date archives
*
* @author Henry Ruhl
* @link http://goo.gl/s5d0Lo
*/
function iweb_remove_pagination_overflow_redirect() {
remove_action( 'wp', array($GLOBALS['wpseo_front'], 'pagination_overflow_redirect'), 99 );
}
<?php
/**
* Gets a number of terms and displays them as options
*
* Modified from CMB example code to save the term ID instead of slug.
*
* @link http://link.from.pw/1sLyqqv
* @param string $taxonomy Taxonomy terms to retrieve. Default is category
* @param string|array $args Optional. Change the defaults retrieving terms
* @return array An array of options that matches the CMB options array
@mustardBees
mustardBees / functions.php
Created August 18, 2014 09:13
Remove text colour button from editor
<?php
/**
* Remove text colour button from editor
*/
function iweb_remove_text_colour_button( $buttons ) {
if ( ( $key = array_search( 'forecolor', $buttons ) ) !== false ) {
unset( $buttons[$key] );
}
return $buttons;
@mustardBees
mustardBees / iweb_simple_post_list.php
Created October 14, 2014 10:47
WordPress Simple Post List Plugin
<?php
/*
Plugin Name: Simple Post List
Plugin URI: http://www.iwebcontrol.co.uk/
Description: Simple plugin to output a list of blog post URLs.
Version: 1.0.0
Author: Phil Wylie
Author URI: http://www.iwebcontrol.co.uk/
License: GPLv2+
*/
@mustardBees
mustardBees / functions.php
Last active August 29, 2015 14:11
WordPress - get the slug of your post or page
<?php
/**
* Get the slug of your post or page
*
* @author Tom Barrett
* @link http://goo.gl/95boK0
*/
function iweb_get_the_slug( $id = null ) {
if ( empty( $id ) ) {
global $post;
@mustardBees
mustardBees / functions.php
Created February 9, 2015 11:20
Generic function to return an array of posts formatted for CMB2. Simply pass in your WP_Query arguments and get back a beautifully formatted CMB2 options array.
<?php
/**
* Get a list of posts
*
* Generic function to return an array of posts formatted for CMB2. Simply pass
* in your WP_Query arguments and get back a beautifully formatted CMB2 options
* array.
*
* @param array $query_args WP_Query arguments
* @return array CMB2 options array
@mustardBees
mustardBees / .gitignore
Created February 19, 2015 10:25
Sample WordPress gitignore file
# OS or IDE folders/files to ignore
*~
._*
*.lock
*.DS_Store
*.swp
*.out
.cache
.project
.settings
@mustardBees
mustardBees / functions.php
Created April 13, 2015 16:31
Enable Jetpack Photon on HTTPS
<?php
/**
* Enable Jetpack Photon on HTTPS
*
* @author Jeremy Herve
* @link http://goo.gl/inSy5i
*/
add_filter( 'jetpack_photon_reject_https', '__return_false' );