Skip to content

Instantly share code, notes, and snippets.

View mustardBees's full-sized avatar

Phil Wylie mustardBees

View GitHub Profile
@mustardBees
mustardBees / gist:4030980
Created November 7, 2012 11:37
Prevent WordPress Admin Toolbar from being hidden via the user profile edit screen
/**
* Prevent Toolbar from being hidden
*
* Hide the "Show Toolbar when viewing site" option on the profile page editor.
*
* @author: Don Fischer
* @link http://goo.gl/P5FTK
*/
function iweb_hide_admin_bar_profile_option() {
echo '<style type="text/css">.show-admin-bar { display: none !important; }</style>';
@mustardBees
mustardBees / gist:4125347
Created November 21, 2012 15:14
Shortcode to retrieve a theme option within a post
/**
* Get option shortcode
*
* Make it easy to add theme options within posts. Example usage:
* [get-theme-option key="contact_telephone"]
*
* @param array $theme_option Shortcode key/values
* @return string The value returned by get_option()
*/
function iweb_get_option_shortcode( $theme_option ) {
@mustardBees
mustardBees / gist:4125424
Created November 21, 2012 15:27
Change WordPress email sender
/**
* Change wp_mail's from name
*/
function iweb_change_from_name( $name = '' ) {
return get_bloginfo( 'name' );
}
add_filter( 'wp_mail_from_name', 'iweb_change_from_name' );
/**
* Change wp_mail's from email
@mustardBees
mustardBees / gist:4125893
Created November 21, 2012 16:35
HTML script tag to load FitVids.js into WordPress
<script src="<?php echo get_stylesheet_directory_uri(); ?>/js/plugins/jquery.fitvids.js"></script>
@mustardBees
mustardBees / gist:4125913
Created November 21, 2012 16:38
Responsive video embedding with FitVids.JS and WordPress
jQuery(document).ready(function($) {
$('.post').fitVids();
});
@mustardBees
mustardBees / gist:4125935
Created November 21, 2012 16:42
Prevent large images from breaking your WordPress theme
if ( ! isset( $content_width ) ) {
$content_width = 560;
}
@mustardBees
mustardBees / gist:4125940
Created November 21, 2012 16:42
Prevent large images from breaking your WordPress theme
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( $content_width, 1024, false );
}
@mustardBees
mustardBees / gist:4125978
Created November 21, 2012 16:48
WordPress: Prevent images from being inserted with a link
/**
* Prevent images from being inserted with a link.
* User must specify if they really want to link to the attachment page
*/
update_option( 'image_default_link_type', 'none' );
@mustardBees
mustardBees / gist:4125995
Created November 21, 2012 16:51
WordPress 3.3 with bundled jQuery UI
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_style( 'jquery.ui.theme', get_stylesheet_directory_uri() . '/css/ui-lightness/jquery-ui-1.8.16.custom.css' );
@mustardBees
mustardBees / gist:4131320
Created November 22, 2012 14:01
Override post thumbnail attributes in your WordPress theme
$post_thumbnail_attributes = array(
'class' => 'our-image-class maybe-add-another-class',
'alt' => get_the_title(),
'title' => get_the_title()
);
the_post_thumbnail( 'post-thumbnail', $post_thumbnail_attributes );