Skip to content

Instantly share code, notes, and snippets.

@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);
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* This code will display a counter in the form of "X / Y" (where X is the current slide and Y is the total number of slides) below the slideshow.
*/
function metaslider_add_counter_div($options, $slider_id, $settings) {
$options['start'][] = "
var container = $('<div />').addClass('counter_{$slider_id}').css({
'text-align' : 'center',
/*
Always show arrows (Flex Slider)
Usage: Copy and paste this code into your themes style.css file
*/
.metaslider .flex-direction-nav .flex-prev {
opacity: 1;
left: 5px;
}
.metaslider .flex-direction-nav .flex-next {
opacity: 1;
@tomhemsley
tomhemsley / gist:a3337bfda80d61fabde7
Created March 31, 2015 16:04
Meta Slider - Filmstrip Alt Tags
function metaslider_filmstrip_alt_tags( $list_item, $post, $url ) {
$alt = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
$list_item = "<li class=\"ms-thumb slide-{$post->ID} slide-{$post->ID}\" style=\"display: none;\"><img src=\"{$url}\" alt=\"{$alt}\" /></li>";
return $list_item;
}
add_filter( 'metaslider_filmstrip_list_item', 'metaslider_filmstrip_alt_tags', 10, 3 );
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* To Use: Install 'Easy Fancybox'. Leave the URL blank on an image slide in Meta Slider.
* The slide will automatically be linked to it's full image in a lightbox
*/
function metaslider_easy_fancybox($attributes, $slide, $slider_id) {
if (!strlen($attributes['href'])) {
$attributes['href'] = wp_get_attachment_url($slide['id']);
$attributes['class'] = 'fancybox';
function metaslider_post_feed_and( $args, $slide, $slider_settings, $slide_settings ) {
if ( isset( $args['tax_query'][0] ) ) {
$args['tax_query'][0]['operator'] = 'AND';
}
return $args;
}
add_filter( 'metaslider_post_feed_args', 'metaslider_post_feed_and', 10, 4);
@tomhemsley
tomhemsley / gist:58387b44303a7214cbd5
Created March 7, 2016 11:37
Meta Slider Rocket Loader (TEST)
add_filter( 'script_loader_tag', 'disable_async_for_rocket_loader', 11, 2 );
function disable_async_for_rocket_loader( $tag, $handle ) {
if ( strpos( $handle, 'metaslider' ) !== FALSE ) {
$tag = str_replace( "<script type='text/javascript'", "<script data-cfasync='false'", $tag );
}
return $tag;
}