This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VIDEO | |
// remove dimensions from oEmbed videos | |
add_filter( 'embed_oembed_html', 'tdd_oembed_filter', 10, 4 ) ; | |
function tdd_oembed_filter($html, $url, $attr, $post_ID) { | |
$return = '<figure class="video-container">'.$html.'</figure>'; | |
return $return; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AUTOMATICALLY ADD ALT TAGS TO IMAGES | |
add_filter('the_content', 'add_alt_tags', 99999); | |
function add_alt_tags($content) | |
{ | |
global $post; | |
preg_match_all('/<img (.*?)\/>/', $content, $images); | |
if(!is_null($images)) | |
{ | |
foreach($images[1] as $index => $value) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************** ADD FILE TYPES TO MEDIA LIBRARY FILTERS ****************/ | |
add_filter( 'post_mime_types', 'custom_mime_types' ); | |
function custom_mime_types( $post_mime_types ) { | |
$post_mime_types['application/msword'] = array( __( 'Word Docs' ), __( 'Manage Word Docs' ), _n_noop( 'Word Docs <span class="count">(%s)</span>', 'Word Docs <span class="count">(%s)</span>' ) ); | |
$post_mime_types['application/vnd.ms-excel'] = array( __( 'Excel Files' ), __( 'Manage Excel Files' ), _n_noop( 'Excel Files <span class="count">(%s)</span>', 'Excel Files <span class="count">(%s)</span>' ) ); | |
$post_mime_types['application/vnd.ms-powerpoint'] = array( __( 'PowerPoint Files' ), __( 'Manage PowerPoint Files' ), _n_noop( 'PowerPoint Files <span class="count">(%s)</span>', 'PowerPoint Files <span class="count">(%s)</span>' ) ); | |
$post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDFs <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) ); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$custom_terms = get_terms('custom_taxonomy'); | |
foreach($custom_terms as $custom_term) { | |
wp_reset_query(); | |
$args = array( | |
'post_type' => 'custom_post_type', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'custom_taxonomy', | |
'field' => 'slug', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
**** LIMIT WORDS IN EXCERPTS (or any supplied content) | |
Usage: | |
$text = get_the_excerpt(); | |
echo string_limit_words($text, 40); | |
*/ | |
function string_limit_words($string, $word_limit) { | |
$words = explode(' ', $string, ($word_limit + 1)); | |
if(count($words) > $word_limit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* See http://wordpress.stackexchange.com/a/28784/16 for all options | |
*/ | |
add_action( 'admin_menu', 'my_remove_menu_pages', 9999 ); | |
function my_remove_menu_pages() { | |
global $current_user; | |
$username = $current_user->user_login; | |
if ($username !== 'SPECIFIC-ADMIN-USERNAME-HERE') { | |
remove_menu_page('edit-comments.php'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HIDE MASTER ADMIN ACCOUNT SO IT CAN'T BE ACCIDENTALLY DELETED | |
add_action('pre_user_query','yoursite_pre_user_query'); | |
function yoursite_pre_user_query($user_search) { | |
global $current_user; | |
$username = $current_user->user_login; | |
if ($username !== 'MASTER_ADMIN_USERNAME_HERE') { | |
global $wpdb; | |
$user_search->query_where = str_replace('WHERE 1=1', | |
"WHERE 1=1 AND {$wpdb->users}.user_login != 'MASTER_ADMIN_USERNAME_HERE'",$user_search->query_where); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IF USING CUSTOM PERMALINKS LIKE CATEGORY/POSTNAME, PAGE NAVIGATION BREAKS ON PAGE 2. THIS IS THE FIX | |
// from http://barefootdevelopment.blogspot.com/2007/11/fix-for-wordpress-paging-problem.html | |
add_filter('request', 'remove_page_from_query_string'); | |
function remove_page_from_query_string($query_string) { | |
if ($query_string['name'] == 'page' && isset($query_string['page'])) { | |
unset($query_string['name']); | |
// 'page' in the query_string looks like '/2', so split it out | |
list($delim, $page_index) = split('/', $query_string['page']); | |
$query_string['paged'] = $page_index; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DISPLAY SIMPLE SECTION NAVIGATION VIA SHORTCODE | |
// adapted from the fantastic Simple Section Navigation plugin which is alas no longer being maintained | |
// http://wordpress.org/plugins/simple-section-navigation/ | |
add_shortcode('simplesidenav', 'mm_simplesidenav'); | |
function mm_simplesidenav( $atts, $content = null) { | |
extract( shortcode_atts( array( | |
'exclude' => '', | |
'topic' => '', | |
//'hierarchical' => 'false', | |
), $atts ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
$.getScript('//www.youtube.com/iframe_api'); | |
var cnt = 0; | |
$('.flexslider iframe[src*=youtube]').each(function() { | |
$(this).attr('id', 'youtubeplayer' + cnt); | |
cnt++; | |
}); | |
loadSlider(); |