Skip to content

Instantly share code, notes, and snippets.

@tomhemsley
tomhemsley / gist:aa4b1d9da39eb63b8d86
Last active August 29, 2015 14:04
Advanced Custom Fields - Date in Post Feed
/**
* Converts an ACF date field from DDMMYYYY to DD.MM.YYYY
*/
function metaslider_acf_date($content) {
$content = str_replace( "{start_date}", date( 'd.m.Y', strtotime( get_field('start_date') ) ) , $content );
return $content;
}
add_filter( "metaslider_post_feed_template", "metaslider_acf_date" );
@tomhemsley
tomhemsley / gist:9618a8a1e73dc23e0608
Created July 21, 2014 10:37
Default Thumbnail Plus Fix
function metaslider_default_thumbnail_plus_fix() {
global $pagenow;
if ( $pagenow == 'media-upload.php' && isset( $_GET['tab'] ) ) {
wp_dequeue_script( 'slt-file-select' );
}
}
add_action( 'admin_print_scripts', 'metaslider_default_thumbnail_plus_fix' );
@tomhemsley
tomhemsley / gist:100930dafd179bae2d1d
Created July 18, 2014 10:47
Meta Slider Post Feed - Restrict to current category
/**
* Alter the post feed query arguments to restrict the results to posts
* tagged to the current category.
*
* REQUIRES: Meta Slider Pro 2.4.5+
*/
function metaslider_restrict_to_current_category( $args, $slide, $slider_settings, $slide_settings ) {
// check slide ID so we only apply this functionality where it's needed
if ( $slide->ID == 101 && is_category() ) {
function metaslider_vimeo_color( $url, $slider_id, $slide_id) {
return $url .= "&color=ff0000";
}
add_filter( 'metaslider_vimeo_params', 'metaslider_vimeo_color', 10, 3 );
@tomhemsley
tomhemsley / gist:32fdb0829c5b3403f5a3
Created July 8, 2014 09:45
Meta Slider - Neo Theme Integration
// remove the default slider
remove_action( 'genesis_after_header', 'zp_full_slider' );
// add in meta slider
add_action( 'genesis_after_header', 'metaslider_full_slider' );
function metaslider_full_slider() {
echo do_shortcode("[metaslider id=20 restrict_to=home]");
}
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* Compatibility: Flex Slider.
*/
function metaslider_variable_heights($options, $slider_id, $settings) {
$options['start'][] = "setTimeout( function() { slider.trigger('resize') } , 500 );";
return $options;
}
add_filter('metaslider_flex_slider_parameters', 'metaslider_variable_heights', 11, 3);
@tomhemsley
tomhemsley / NoFollow
Created June 30, 2014 14:34
Add rel=nofollow to all Meta Slider links
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*/
function metaslider_nofollow($attributes, $slide, $slider_id) {
$attributes['rel'] = "nofollow";
return $attributes;
}
add_filter('metaslider_flex_slider_anchor_attributes', 'metaslider_nofollow', 10, 3);
add_filter('metaslider_nivo_slider_anchor_attributes', 'metaslider_nofollow', 10, 3);
add_filter('metaslider_responsive_slider_anchor_attributes', 'metaslider_nofollow', 10, 3);
@tomhemsley
tomhemsley / MetaSliderDisableTouch
Last active August 29, 2015 14:03
Disable Touch for Flex Slider
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* Compatibility: Flex Slider.
*/
function metaslider_flex_disable_touch($options, $slider_id, $settings) {
$options['touch'] = "false";
return $options;
}
add_filter('metaslider_flex_slider_parameters', 'metaslider_flex_disable_touch', 11, 3);
@tomhemsley
tomhemsley / Barcci
Created June 23, 2014 15:15
Fix for Barcci theme (YouTube & Vimeo selector)
/** Dequeue theme specific JS scripts from the YouTube and Vimeo tabs **/
function ms_dequeue_scripts() {
wp_dequeue_script( 'eye' );
wp_dequeue_script( 'utils' );
wp_dequeue_script( 'bg-cutom' );
}
add_action("metaslider_youtube_iframe", "ms_dequeue_scripts");
add_action("metaslider_vimeo_iframe", "ms_dequeue_scripts");
function metaslider_prepend_theme_css_selector($selector, $slider_id) {
return '#content ' . $selector;
}
add_filter('metaslider_theme_editor_css_selector', 'metaslider_prepend_theme_css_selector', 10, 2);