Пример #1
0
 function rev_slider_shortcode($args, $mid_content = null)
 {
     extract(shortcode_atts(array('alias' => ''), $args, 'rev_slider'));
     $sliderAlias = $alias != '' ? $alias : RevSliderFunctions::getVal($args, 0);
     $gal_ids = RevSliderFunctionsWP::check_for_shortcodes($mid_content);
     //check for example on gallery shortcode and do stuff
     ob_start();
     if (!empty($gal_ids)) {
         //add a gallery based slider
         $slider = RevSliderOutput::putSlider($sliderAlias, '', $gal_ids);
     } else {
         $slider = RevSliderOutput::putSlider($sliderAlias);
     }
     $content = ob_get_contents();
     ob_clean();
     ob_end_clean();
     // Do not output Slider if we are on mobile
     $disable_on_mobile = $slider->getParam("disable_on_mobile", "off");
     if ($disable_on_mobile == 'on') {
         $mobile = strstr($_SERVER['HTTP_USER_AGENT'], 'Android') || strstr($_SERVER['HTTP_USER_AGENT'], 'webOS') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPod') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad') || strstr($_SERVER['HTTP_USER_AGENT'], 'Windows Phone') || wp_is_mobile() ? true : false;
         if ($mobile) {
             return false;
         }
     }
     $show_alternate = $slider->getParam("show_alternative_type", "off");
     if ($show_alternate == 'mobile' || $show_alternate == 'mobile-ie8') {
         if (wp_is_mobile()) {
             $show_alternate_image = $slider->getParam("show_alternate_image", "");
             return '<img class="tp-slider-alternative-image" src="' . $show_alternate_image . '" data-no-retina>';
         }
     }
     //handle slider output types
     if (!empty($slider)) {
         $outputType = $slider->getParam("output_type", "");
         switch ($outputType) {
             case "compress":
                 $content = str_replace("\n", "", $content);
                 $content = str_replace("\r", "", $content);
                 return $content;
                 break;
             case "echo":
                 echo $content;
                 //bypass the filters
                 break;
             default:
                 return $content;
                 break;
         }
     } else {
         return $content;
     }
     //normal output
 }