Skip to content

Instantly share code, notes, and snippets.

View michaelmusgrove's full-sized avatar

Michael Musgrove michaelmusgrove

View GitHub Profile

Keybase proof

I hereby claim:

  • I am michaelmusgrove on github.
  • I am musgrove (https://keybase.io/musgrove) on keybase.
  • I have a public key ASBEzMlyXpizttxxKX5J63FKFWjmjtUoFBjv3_sNzPcLcgo

To claim this, I am signing this object:

@michaelmusgrove
michaelmusgrove / gravatar-swticheroo.php
Created January 18, 2016 02:00
Replace Gravatar in WP
add_filter( ‘avatar_defaults’, ‘newgravatar’ );
function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo(‘template_directory’) . ‘/images/gravataricon.gif’,‘/images/gravataricon.gif1’,‘/images/gravataricon.gif2’,‘/images/gravataricon.gif3’,‘/images/gravataricon.gif4’;
$avatar_defaults[$myavatar] = "webdesignPOP";
return $avatar_defaults;
}
function my_home_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '11'); } } add_action( 'pre_get_posts', 'my_home_category' );
@michaelmusgrove
michaelmusgrove / Woocommerce coupon box
Last active September 29, 2015 08:20
WooCommerce: Hide coupon box on checkout page if a coupon is already applied
<?php
/*
* Hide coupon notice on the checkout page if a coupon has been applied in cart
*/
add_filter( 'woocommerce_coupons_enabled', 'woocommerce_coupons_enabled_checkout' );
function woocommerce_coupons_enabled_checkout( $coupons_enabled ) {
global $woocommerce;
@michaelmusgrove
michaelmusgrove / responsive-image-shortcode.html
Created October 10, 2014 01:43
Make images responsive - create a shortcode
[responsive]<img src="image_url" alt="alt" title="title" />[/responsive]
@michaelmusgrove
michaelmusgrove / svg-upload.php
Created October 10, 2014 01:40
Add SVG upload support to your WordPress blog
add_filter('upload_mimes', 'my_upload_mimes');
function my_upload_mimes($mimes = array()) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
@michaelmusgrove
michaelmusgrove / Add-Cats-Tags-to-cpt.php
Last active August 29, 2015 14:07
Create Custom Post Type in WordPress. 2nd file enable adding cats and tags to the CPT.
'taxonomies' => array('category', 'post_tag'),
@michaelmusgrove
michaelmusgrove / add-category-tags-cpt.php
Created October 9, 2014 21:26
Function to add categories and tags to my custom post types
add_action('init', 'add_category_tags_to_cpt'); function add_category_tags_to_cpt() { register_taxonomy_for_object_type('category', 'your-cpt-name'); register_taxonomy_for_object_type('post_tag', 'your-cpt-name'); }
@michaelmusgrove
michaelmusgrove / custom_login.html
Created October 6, 2014 23:56
Customize the login panel - remember to change the URLs as needed.
/**
* @author Michael Musgrove
* @example http://wpplus.me/
* @copyright 2014 WP Plus me
*/
<div class="login-wrap">
<form name="loginform" id="loginform" action="http://www.example.dev/wp-login.php" method="post">
<p class="login-username">
<label for="user_login">Username</label>
<input type="text" name="log" id="user_login" class="input" value="" size="18" />
/*
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {