This file contains 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
function metaslider_add_style_to_preview() { | |
wp_enqueue_style( 'theme-css', get_template_directory_uri() . '/style.css', array(), '', true ); | |
} | |
add_action( 'admin_post_metaslider_preview', 'metaslider_add_style_to_preview', 9 ); |
This file contains 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
/** | |
* INSTALLATION: this code should be pasted into your theme's functions.php file. | |
*/ | |
function metaslider_pause_on_slide($options, $slider_id, $settings) { | |
$slide_to_pause = 3; // <- change this number | |
// do not edit below this line | |
$options['after'][] = "if (slider.currentSlide == ({$slide_to_pause} - 1)) { slider.pause(); }"; | |
This file contains 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
function metaslider_custom_caption($slide, $slideshow_id) { | |
// populate the caption using other fields | |
$slide['caption'] = $slide['caption'] . $slide['title'] . $slide['alt']; | |
return $slide; | |
} | |
add_filter('metaslider_image_slide_attributes', 'metaslider_custom_caption',10, 2); |
This file contains 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
function metaslider_reset_filmstrip($options, $slider_id, $settings) { | |
$options['before'][] = "if (slider.currentSlide + 1 == slider.count) { $('#metaslider_{$slider_id}_filmstrip').flexslider(0); }" ; | |
return $options; | |
} | |
add_filter('metaslider_flex_slider_parameters', 'metaslider_reset_filmstrip', 10, 3); |
This file contains 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
function ms_show_id($slider_id) { | |
echo "ID: " . $slider_id; | |
} | |
add_action('metaslider_admin_table_before', 'ms_show_id', 10, 1); |
This file contains 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
function metaslider_flex_params($options, $slider_id) { | |
$options['pausePlay'] = "true"; // enable pause/play | |
$options['pauseText'] = "'Pause'"; | |
$options['playText'] = "'Play'"; | |
$options['controlsContainer'] = "'#metaslider_container_100'"; // change 100 to your slideshow ID | |
return $options; | |
} | |
add_filter('metaslider_flex_slider_parameters', 'metaslider_flex_params', 10, 2); |
This file contains 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
/** | |
* Installation: | |
* | |
* Copy and paste this code into your themes functions.php file. | |
* | |
* Create a new custom field for your posts (to do this, edit one of your posts in WordPress, click 'Screen options' at the top of * the page and enable 'custom fields'). Name the custom field 'metaslider_thumb_caption' and enter the text for the caption as | |
* the value | |
* | |
*/ |
This file contains 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
/** | |
* Filter the shortcode attributes. | |
* If the ID parameter is not an integer, assume it is a slug. | |
* Convert the slug to an ID and return the attributes. | |
*/ | |
function metaslider_shortcode_slug( $atts ) { | |
if ( isset( $atts['id'] ) && ! is_int( $atts['id'] ) ) { | |
$slider = get_page_by_path( $atts['id'], OBJECT, 'ml-slider' ); |
This file contains 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
/** | |
* The default capability required to use Meta Slider is 'edit_others_posts'. | |
* You can change this to a different capability by pasting the code below into | |
* your themes functions.php file. | |
* | |
* You can use the 'User Role Editor' plugin to add a custom capability to WordPress | |
* specifically for Meta Slider users. | |
*/ | |
function metaslider_change_required_role($capability) { | |
return 'metaslider_use'; // this is the ID of a custom capability added using User Role Editor |
This file contains 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
/** | |
* INSTALLATION: this code should be pasted into your theme's functions.php file. | |
* | |
* To Use: Install 'WP Lightbox 2'. 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_wp_lightbox_2($attributes, $slide, $slider_id) { | |
if (!strlen($attributes['href'])) { | |
$attributes['href'] = wp_get_attachment_url($slide['id']); | |
$attributes['rel'] = "lightbox[{$slider_id}]"; |