Example #1
0
function msp_masterslider_wrapper_shortcode($atts, $content = null)
{
    $mixed = shortcode_atts(array('id' => '1', 'uid' => '', 'class' => '', 'margin' => 0, 'inline_style' => '', 'bg_color' => '', 'bg_image' => '', 'slider_type' => 'custom', 'width' => 300, 'height' => 150, 'start' => 1, 'space' => 0, 'grab_cursor' => 'true', 'swipe' => 'true', 'wheel' => 'false', 'mouse' => 'true', 'crop' => 'false', 'autoplay' => 'false', 'loop' => 'false', 'shuffle' => 'false', 'preload' => 0, 'wrapper_width' => '', 'wrapper_width_unit' => 'px', 'fullwidth' => 'false', 'fullheight' => 'false', 'autofill' => 'false', 'layout' => 'fillwidth', 'fullscreen_margin' => 0, 'height_limit' => 'false', 'auto_height' => 'false', 'smooth_height' => 'true', 'end_pause' => 'false', 'over_pause' => 'false', 'fill_mode' => 'fill', 'center_controls' => 'true', 'layers_mode' => 'center', 'hide_layers' => 'false', 'instant_show_layers' => 'false', 'speed' => 17, 'skin' => 'ms-skin-default', 'template' => '', 'template_class' => '', 'direction' => 'h', 'view' => 'basic', 'gfonts' => '', 'parallax_mode' => 'swipe', 'scroll_parallax' => 'false', 'scroll_parallax_move' => 30, 'scroll_parallax_fade' => 'true', 'scroll_parallax_bg_move' => 50, 'use_deep_link' => 'false', 'deep_link' => '', 'deep_link_type' => 'path', 'flickr_key' => '', 'flickr_id' => '', 'flickr_count' => 10, 'flickr_type' => 'photos', 'flickr_size' => 'c', 'flickr_thumb_size' => 'q', 'facebook_username' => '', 'facebook_albumid' => '', 'facebook_count' => 10, 'facebook_type' => 'album', 'facebook_size' => 'orginal', 'facebook_thumb_size' => '320', 'ps_post_type' => '', 'ps_tax_term_ids' => '', 'ps_post_count' => 10, 'ps_image_from' => 'auto', 'ps_order' => 'DESC', 'ps_orderby' => 'menu_order date', 'ps_posts_not_in' => '', 'ps_excerpt_len' => 100, 'ps_offset' => 0, 'ps_link_slide' => false, 'ps_link_target' => '_self', 'ps_slide_bg' => '', 'arrows' => 'true', 'arrows_autohide' => 'true', 'arrows_overvideo' => 'true', 'arrows_hideunder' => '', 'bullets' => 'false', 'bullets_autohide' => 'true', 'bullets_overvideo' => 'true', 'bullets_direction' => 'h', 'bullets_align' => 'bottom', 'bullets_space' => 5, 'bullets_margin' => '', 'bullets_hideunder' => '', 'thumbs' => 'false', 'thumbs_autohide' => 'true', 'thumbs_overvideo' => 'true', 'thumbs_direction' => 'h', 'thumbs_type' => 'thumbs', 'thumbs_speed' => 17, 'thumbs_inset' => 'true', 'thumbs_align' => 'bottom', 'thumbs_margin' => 0, 'thumbs_width' => 100, 'thumbs_height' => 80, 'thumbs_space' => 5, 'thumbs_hideunder' => '', 'thumbs_fillmode' => 'fill', 'scroll' => 'false', 'scroll_autohide' => 'true', 'scroll_overvideo' => 'true', 'scroll_direction' => 'h', 'scroll_align' => 'top', 'scroll_inset' => 'true', 'scroll_margin' => '', 'scroll_color' => '#3D3D3D', 'scroll_hideunder' => '', 'scroll_width' => '', 'circletimer' => 'false', 'circletimer_autohide' => 'true', 'circletimer_overvideo' => 'true', 'circletimer_color' => '#A2A2A2', 'circletimer_radius' => 4, 'circletimer_stroke' => 10, 'circletimer_margin' => '', 'circletimer_hideunder' => '', 'timebar' => 'false', 'timebar_autohide' => 'true', 'timebar_overvideo' => 'true', 'timebar_align' => 'bottom', 'timebar_color' => '#FFFFFF', 'timebar_hideunder' => '', 'timebar_width' => '', 'slideinfo' => 'false', 'slideinfo_autohide' => 'true', 'slideinfo_overvideo' => 'true', 'slideinfo_direction' => 'h', 'slideinfo_align' => 'bottom', 'slideinfo_inset' => 'false', 'slideinfo_margin' => '', 'slideinfo_hideunder' => '', 'slideinfo_width' => '', 'slideinfo_height' => '', 'on_change_start' => '', 'on_change_end' => '', 'on_waiting' => '', 'on_resize' => '', 'on_video_play' => '', 'on_video_close' => '', 'on_swipe_start' => '', 'on_swipe_move' => '', 'on_swipe_end' => ''), $atts, 'ms_slider');
    extract($mixed);
    // load masterslider script
    wp_enqueue_style('masterslider-main');
    wp_enqueue_script('masterslider-core');
    wp_enqueue_script('prettyPhoto');
    // create an unique id for slider
    $uid = empty($uid) ? uniqid("MS") : $uid;
    // unique id for parant wrapper
    $puid = 'P_' . $uid;
    // class name for slider template
    $template_class = empty($template_class) ? '' : esc_attr($template_class);
    $preload = is_numeric($preload) ? (int) $preload + 1 : "'{$preload}'";
    // add max-width to wrapper for boxed and partialview layout
    if (!empty($wrapper_width) && ('boxed' == $layout || 'partialview' == $layout)) {
        // validate wrapper_width_unit
        $wrapper_width_unit = in_array($wrapper_width_unit, array('px', '%', 'em')) ? $wrapper_width_unit : 'px';
        $inline_style .= sprintf('max-width:%s%s;', $wrapper_width, $wrapper_width_unit);
        // if wrapper_width is not set use slider width as default
    } elseif ('boxed' == $layout) {
        $inline_style .= sprintf('max-width:%spx;', $width);
        // if wrapper_width is not set the value to 100%
    } elseif ('partialview' == $layout) {
        $inline_style .= 'max-width:100%;';
    }
    $inline_style = empty($inline_style) ? '' : sprintf('style="%s" ', esc_attr($inline_style));
    $arrows_hideunder = empty($arrows_hideunder) ? '' : sprintf(', hideUnder:%s', $arrows_hideunder);
    $bullets_hideunder = empty($bullets_hideunder) ? '' : sprintf(', hideUnder:%s', $bullets_hideunder);
    $thumbs_hideunder = empty($thumbs_hideunder) ? '' : sprintf(', hideUnder:%s', $thumbs_hideunder);
    $scroll_hideunder = empty($scroll_hideunder) ? '' : sprintf(', hideUnder:%s', $scroll_hideunder);
    $timebar_hideunder = empty($timebar_hideunder) ? '' : sprintf(', hideUnder:%s', $timebar_hideunder);
    $slideinfo_hideunder = empty($slideinfo_hideunder) ? '' : sprintf(', hideUnder:%s', $slideinfo_hideunder);
    $circletimer_hideunder = empty($circletimer_hideunder) ? '' : sprintf(', hideUnder:%s', $circletimer_hideunder);
    $bullets_margin = empty($bullets_margin) ? '' : sprintf(', margin:%s', $bullets_margin);
    $circletimer_margin = empty($circletimer_margin) ? '' : sprintf(', margin:%s', $circletimer_margin);
    $scroll_margin = empty($scroll_margin) ? '' : sprintf(', margin:%s', $scroll_margin);
    $slideinfo_margin = empty($slideinfo_margin) ? '' : sprintf(', margin:%s', $slideinfo_margin);
    $timebar_width = empty($timebar_width) ? '' : sprintf(', width:%s', $timebar_width);
    $scroll_width = empty($scroll_width) ? '' : sprintf(', width:%s', $scroll_width);
    if (in_array($bullets_align, array('left', 'right'))) {
        $bullets_direction = 'v';
    }
    if (in_array($bullets_align, array('top', 'bottom'))) {
        $bullets_direction = 'h';
    }
    if (in_array($thumbs_align, array('left', 'right'))) {
        $thumbs_direction = 'v';
    }
    if (in_array($thumbs_align, array('top', 'bottom'))) {
        $thumbs_direction = 'h';
    }
    if (in_array($scroll_align, array('left', 'right'))) {
        $scroll_direction = 'v';
    }
    if (in_array($scroll_align, array('top', 'bottom'))) {
        $scroll_direction = 'h';
    }
    if (in_array($slideinfo_align, array('left', 'right'))) {
        $slideinfo_direction = 'v';
    }
    if (in_array($slideinfo_align, array('top', 'bottom'))) {
        $slideinfo_direction = 'h';
    }
    // set slideinfo size to spefified height is direction is horizontal, else set it to width
    if (empty($slideinfo_width) && empty($slideinfo_height)) {
        $slideinfo_size = '';
    } elseif ('h' == $slideinfo_direction) {
        $slideinfo_size = sprintf(', size:%s', $slideinfo_height);
    } else {
        $slideinfo_size = sprintf(', size:%s', $slideinfo_width);
    }
    $instance_suffix = substr($uid, -4);
    // slider javascript instance name
    $instance_name = "masterslider_" . $instance_suffix;
    // stores inner markup for some spesific templates
    $inner_template_container_open_tags = '';
    $inner_template_container_close_tags = '';
    if ('laptop' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-laptop-cont"><img src="%s" class="ms-laptop-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/laptop.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('display' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-display-cont"><img src="%s" class="ms-display-bg" /><div class="ms-dis-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/display.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('flat-laptop' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-laptop-cont"><img src="%s" class="ms-laptop-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/flat-laptop.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('flat-display' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-display-cont"><img src="%s" class="ms-display-bg" /><div class="ms-dis-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/flat-display.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('tablet' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-tablet-cont"><img src="%s" class="ms-tablet-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/tablet.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('flat-tablet' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-tablet-cont"><img src="%s" class="ms-tablet-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/flat-tablet.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('tablet-land' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-tablet-cont"><img src="%s" class="ms-tablet-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/tablet-land.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('flat-tablet-land' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-tablet-cont"><img src="%s" class="ms-tablet-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/flat-tablet-land.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('phone' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-phone-cont"><img src="%s" class="ms-phone-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/phone.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('flat-phone' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-phone-cont"><img src="%s" class="ms-phone-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/flat-phone.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('phone-land' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-phone-cont"><img src="%s" class="ms-phone-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/phone-land.png');
        $inner_template_container_close_tags = '</div></div>';
    } elseif ('flat-phone-land' == $template) {
        $inner_template_container_open_tags = sprintf('<div class="ms-phone-cont"><img src="%s" class="ms-phone-bg" /><div class="ms-lt-slider-cont">', MSWP_AVERTA_PUB_URL . '/assets/css/templates/flat-phone-land.png');
        $inner_template_container_close_tags = '</div></div>';
    }
    $inner_template_container_open_tags = apply_filters('masterslider_ms_slider_inner_template_container_open_tags', $inner_template_container_open_tags, $template, $mixed);
    $inner_template_container_close_tags = apply_filters('masterslider_ms_slider_inner_template_container_close_tags', $inner_template_container_close_tags, $template, $mixed);
    // class names for master slider wrapper
    $wrapper_classes = $class . ' ' . $template_class . ' ' . 'ms-parent-id-' . $id;
    ob_start();
    ?>

		<!-- MasterSlider -->
		<div id="<?php 
    echo $puid;
    ?>
" class="master-slider-parent <?php 
    echo trim($wrapper_classes);
    ?>
" <?php 
    echo $inline_style;
    ?>
 >
				
			<?php 
    echo $inner_template_container_open_tags;
    ?>

			<!-- MasterSlider Main -->
			<div id="<?php 
    echo $uid;
    ?>
" class="master-slider <?php 
    echo $skin;
    ?>
" >
				 <?php 
    // generate all ms slide shortcodes
    ?>
				 <?php 
    echo do_shortcode($content);
    ?>

			</div>
			<!-- END MasterSlider Main -->

			 <?php 
    echo $inner_template_container_close_tags;
    ?>

		</div>
		<!-- END MasterSlider --> 
		
		<script>
		(function ( $ ) {
			"use strict";

			$(function () {
				var <?php 
    echo $instance_name;
    ?>
 = new MasterSlider();

				// slider controls
<?php 
    if ($arrows == 'true' || 'image-gallery' == $template) {
        printf("\t\t\t\t{$instance_name}.control('%s'     ,{ autohide:%s, overVideo:%s %s });", 'arrows', msp_is_true($arrows_autohide), msp_is_true($arrows_overvideo), $arrows_hideunder);
    }
    ?>
                    
<?php 
    if ($bullets == 'true') {
        printf("\t\t\t\t{$instance_name}.control('%s'    ,{ autohide:%s, overVideo:%s, dir:'%s', align:'%s', space:%d %s %s });\n", 'bullets', msp_is_true($bullets_autohide), msp_is_true($bullets_overvideo), $bullets_direction, $bullets_align, $bullets_space, $bullets_margin, $bullets_hideunder);
    }
    if ($thumbs == 'true') {
        printf("\t\t\t\t{$instance_name}.control('%s'  ,{ autohide:%s, overVideo:%s, dir:'%s', speed:%d, inset:%s, align:'%s',type:'%s', margin:%d, width:%d, height:%d, space:%d, fillMode:'%s' %s });\n", 'thumblist', msp_is_true($thumbs_autohide), msp_is_true($thumbs_overvideo), $thumbs_direction, (int) $thumbs_speed, msp_is_true($thumbs_inset), $thumbs_align, $thumbs_type, (int) $thumbs_margin, (int) $thumbs_width, (int) $thumbs_height, (int) $thumbs_space, $thumbs_fillmode, $thumbs_hideunder);
    }
    if ($scroll == 'true') {
        printf("\t\t\t\t{$instance_name}.control('%s'  ,{ autohide:%s, overVideo:%s, dir:'%s', inset:%s, align:'%s', color:'%s' %s %s %s });\n", 'scrollbar', msp_is_true($scroll_autohide), msp_is_true($scroll_overvideo), $scroll_direction, msp_is_true($scroll_inset), $scroll_align, $scroll_color, $scroll_margin, $scroll_hideunder, $scroll_width);
    }
    if ($circletimer == 'true') {
        printf("\t\t\t\t{$instance_name}.control('%s',{ autohide:%s, overVideo:%s, color:'%s', radius:%d, stroke:%d %s %s });\n", "circletimer", msp_is_true($circletimer_autohide), msp_is_true($circletimer_overvideo), $circletimer_color, $circletimer_radius, $circletimer_stroke, $circletimer_margin, $circletimer_hideunder);
    }
    if ($timebar == 'true') {
        printf("\t\t\t\t{$instance_name}.control('%s'    ,{ autohide:%s, overVideo:%s, align:'%s', color:'%s' %s %s });\n", "timebar", msp_is_true($timebar_autohide), msp_is_true($timebar_overvideo), $timebar_align, $timebar_color, $timebar_hideunder, $timebar_width);
    }
    if ($slideinfo == 'true') {
        printf("\t\t\t\t{$instance_name}.control('%s'  ,{ autohide:%s, overVideo:%s, dir:'%s', align:'%s',inset:%s %s %s %s });\n", "slideinfo", msp_is_true($slideinfo_autohide), msp_is_true($slideinfo_overvideo), $slideinfo_direction, $slideinfo_align, msp_is_true($slideinfo_inset), $slideinfo_margin, $slideinfo_hideunder, $slideinfo_size);
    }
    ?>
				// slider setup
				<?php 
    echo $instance_name;
    ?>
.setup("<?php 
    echo $uid;
    ?>
", {
						width           : <?php 
    echo (int) $width;
    ?>
,
						height          : <?php 
    echo (int) $height;
    ?>
,
						space           : <?php 
    echo (int) $space;
    ?>
,
						start           : <?php 
    echo (int) $start;
    ?>
,
						grabCursor      : <?php 
    msp_is_true_e($grab_cursor);
    ?>
,
						swipe           : <?php 
    msp_is_true_e($swipe);
    ?>
,
						mouse           : <?php 
    msp_is_true_e($mouse);
    ?>
,
						layout          : "<?php 
    echo $layout;
    ?>
", 
						wheel           : <?php 
    msp_is_true_e($wheel);
    ?>
,
						autoplay        : <?php 
    msp_is_true_e($autoplay);
    ?>
,
						instantStartLayers:<?php 
    msp_is_true_e($instant_show_layers);
    ?>
,
						loop            : <?php 
    msp_is_true_e($loop);
    ?>
,
						shuffle         : <?php 
    msp_is_true_e($shuffle);
    ?>
,
						preload         : <?php 
    echo $preload;
    ?>
,
						heightLimit     : <?php 
    msp_is_true_e($height_limit);
    ?>
,
						autoHeight      : <?php 
    msp_is_true_e($auto_height);
    ?>
,
						smoothHeight    : <?php 
    msp_is_true_e($smooth_height);
    ?>
,
						endPause        : <?php 
    msp_is_true_e($end_pause);
    ?>
,
						overPause       : <?php 
    msp_is_true_e($over_pause);
    ?>
,
						fillMode        : "<?php 
    echo $fill_mode;
    ?>
", 
						centerControls  : <?php 
    msp_is_true_e($center_controls);
    ?>
,
						layersMode      : "<?php 
    echo $layers_mode;
    ?>
", 
						hideLayers      : <?php 
    msp_is_true_e($hide_layers);
    ?>
, 
						fullscreenMargin: <?php 
    echo (int) $fullscreen_margin;
    ?>
,
						speed           : <?php 
    echo (int) $speed;
    ?>
, 
						dir             : "<?php 
    echo $direction;
    ?>
", 
<?php 
    if ('staff-3' == $template) {
        echo "viewOption      : { centerSpace:1.6 },\n";
    }
    if ('off' != $parallax_mode) {
        echo "\t\t\t\t\t\tparallaxMode    : '{$parallax_mode}',\n";
    }
    if ('false' != $use_deep_link) {
        echo "\t\t\t\t\t\tdeepLink        : '{$deep_link}',\n";
        echo "\t\t\t\t\t\tdeepLinkType    : '{$deep_link_type}',\n";
    }
    ?>
						view            : "<?php 
    echo $view;
    ?>
"
				});
				

				<?php 
    if (!empty($on_change_start)) {
        printf("{$instance_name}.api.addEventListener(MSSliderEvent.CHANGE_START, %s );\n", msp_maybe_base64_decode($on_change_start));
    }
    if (!empty($on_change_end)) {
        printf("\t\t\t\t{$instance_name}.api.addEventListener(MSSliderEvent.CHANGE_END, %s );\n", msp_maybe_base64_decode($on_change_end));
    }
    if (!empty($on_waiting)) {
        printf("\t\t\t\t{$instance_name}.api.addEventListener(MSSliderEvent.WAITING, %s );\n", msp_maybe_base64_decode($on_waiting));
    }
    if (!empty($on_resize)) {
        printf("\t\t\t\t{$instance_name}.api.addEventListener(MSSliderEvent.RESIZE, %s );\n", msp_maybe_base64_decode($on_resize));
    }
    if (!empty($on_video_play)) {
        printf("\t\t\t\t{$instance_name}.api.addEventListener(MSSliderEvent.VIDEO_PLAY, %s );\n", msp_maybe_base64_decode($on_video_play));
    }
    if (!empty($on_video_close)) {
        printf("\t\t\t\t{$instance_name}.api.addEventListener(MSSliderEvent.VIDEO_CLOSE, %s );\n", msp_maybe_base64_decode($on_video_close));
    }
    if (!empty($on_swipe_start)) {
        printf("\t\t\t\t{$instance_name}.api.addEventListener(MSSliderEvent.SWIPE_START, %s );\n", msp_maybe_base64_decode($on_swipe_start));
    }
    if (!empty($on_swipe_move)) {
        printf("\t\t\t\t{$instance_name}.api.addEventListener(MSSliderEvent.SWIPE_MOVE, %s );\n", msp_maybe_base64_decode($on_swipe_move));
    }
    if (!empty($on_swipe_end)) {
        printf("\t\t\t\t{$instance_name}.api.addEventListener(MSSliderEvent.SWIPE_END, %s );\n", msp_maybe_base64_decode($on_swipe_end));
    }
    if ('image-gallery' == $template) {
        printf("new MSGallery( '%s' , %s).setup();", $puid, $instance_name);
    }
    if ('flickr' == $slider_type) {
        printf("new MSFlickrV2( %s, { key:'%s', id:'%s', count:%d, thumbSize:'%s',imgSize:'%s', type:'%s' });", $instance_name, $flickr_key, $flickr_id, $flickr_count, $flickr_thumb_size, $flickr_size, $flickr_type);
    } elseif ('facebook' == $slider_type) {
        $facebook_username_prop = empty($facebook_username) ? '' : sprintf("username:'******', ", $facebook_username);
        $facebook_albumid_prop = empty($facebook_albumid) ? '' : sprintf("albumId :'%s', ", $facebook_albumid);
        printf("new MSFacebookGallery( %s, { %s %s count:%d, thumbSize:'%s',imgSize:'%s', type:'%s' });", $instance_name, $facebook_username_prop, $facebook_albumid_prop, $facebook_count, $facebook_thumb_size, $facebook_size, $facebook_type);
    }
    if ('true' == $scroll_parallax) {
        printf("MSScrollParallax.setup( %s, %d, %d, %s );", $instance_name, $scroll_parallax_move, $scroll_parallax_bg_move, $scroll_parallax_fade);
    }
    if (!empty($gfonts)) {
        $link_tag = sprintf("<link rel='stylesheet' id='ms-fonts'  href='http://fonts.googleapis.com/css?family=%s' type='text/css' media='all' />", $gfonts);
        echo "\n\t\t\t\t" . sprintf('$("head").append( "%s" );', $link_tag) . "\n";
    }
    // add slider instance to global scope
    echo "\n\t\t\t\twindow.masterslider_instances = window.masterslider_instances || {};";
    echo "\n\t\t\t\twindow.masterslider_instances[\"{$id}_{$instance_suffix}\"] = {$instance_name};\n";
    ?>
			 });
			
		})(jQuery);
		</script> 
		
<?php 
    return apply_filters("masterslider_ms_slider_shortcode", ob_get_clean(), $mixed);
}
Example #2
0
 /**
  * Check and decode exported_data
  *
  * @param  string $exported_data  the exported string
  * @return bool/array   false if exported_data is invalid or decoded exported_data in array if it's valid
  */
 function decode_import_data($exported_data)
 {
     if (empty($exported_data)) {
         return false;
     }
     $exported_b64_decoded = msp_maybe_base64_decode($exported_data);
     $export_array = json_decode($exported_b64_decoded, true);
     // validate export data
     if (!is_array($export_array)) {
         echo __('Import data is not valid.', MSWP_TEXT_DOMAIN) . "<br />";
         return false;
     }
     return $export_array;
 }
 public function get_buttons_styles($raw_buttons)
 {
     $b64_decoded = msp_maybe_base64_decode($raw_buttons);
     $buttons_data = json_decode($b64_decoded);
     if (!isset($buttons_data->{'MSPanel.ButtonStyle'})) {
         return '';
     }
     $raw_buttons_styles = $buttons_data->{'MSPanel.ButtonStyle'};
     return $this->buttons_data_to_styles($raw_buttons_styles);
 }
Example #4
0
 /**
  * Import sliders and options by previousely exported data
  * 
  * @param  string $exported_data  the exported string
  * @return bool   true on success and false on failure
  */
 function import_data($exported_data)
 {
     if (empty($exported_data)) {
         return false;
     }
     $exported_b64_decoded = msp_maybe_base64_decode($exported_data);
     $export_array = json_decode($exported_b64_decoded, true);
     // validate export data
     if (!is_array($export_array)) {
         echo __('Import data is not valid.', 'master-slider') . "<br />";
         return false;
     }
     // if you need to change "origin_upload_baseurl" while importing content, just define MSWP_IMPORT_FETCH_DIR const
     if (defined('MSWP_IMPORT_FETCH_DIR')) {
         $this->origin_upload_baseurl = MSWP_IMPORT_FETCH_DIR;
         // set origin_upload_baseurl
     } elseif (isset($export_array['origin_uploads_url']) && !empty($export_array['origin_uploads_url'])) {
         $this->origin_upload_baseurl = $export_array['origin_uploads_url'];
     } else {
         $this->origin_upload_baseurl = MSWP_AVERTA_URL . '/samples';
     }
     // find and replace special template tags
     $this->origin_upload_baseurl = str_replace('{{masterslider}}', MSWP_AVERTA_URL, $this->origin_upload_baseurl);
     $this->origin_upload_baseurl = str_replace('{{theme_dir}}', get_template_directory_uri(), $this->origin_upload_baseurl);
     $this->origin_upload_baseurl = str_replace('{{child_theme_dir}}', get_stylesheet_directory_uri(), $this->origin_upload_baseurl);
     // import preset styles if it's included in export data
     if (isset($export_array['preset_styles']) && !empty($export_array['preset_styles'])) {
         msp_update_option('preset_style', $export_array['preset_styles']);
         echo __('Preset styles imported successfully.', 'master-slider') . "<br />";
     }
     // import preset effects if it's included in export data
     if (isset($export_array['preset_effects']) && !empty($export_array['preset_effects'])) {
         msp_update_option('preset_effect', $export_array['preset_effects']);
         echo __('Preset transitions imported successfully.', 'master-slider') . "<br />";
     }
     echo __('Importing slides ..', 'master-slider') . "<br /><br />";
     // import sliders
     if (isset($export_array['sliders_data'])) {
         // reset image import queue
         $this->image_import_queue = array();
         $this->last_new_slider_id = null;
         $this->import_add_sliders($export_array['sliders_data']);
     }
     echo "<br />" . __('All data imported successfully, have fun :)') . "<br />";
     printf('<a href="%s">%s</a>', admin_url('admin.php?page=' . MSWP_SLUG), __('Back to panel ..', 'master-slider'));
     return true;
 }