Guest User

slideshow.php

a guest
Nov 7th, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 40.56 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Slider
  4.  * Shortcode that allows to display a simple slideshow
  5.  */
  6.  
  7. if ( !class_exists( 'avia_sc_slider' ) )
  8. {
  9.     class avia_sc_slider extends aviaShortcodeTemplate
  10.     {
  11.             /**
  12.              * Create the config array for the shortcode button
  13.              */
  14.             function shortcode_insert_button()
  15.             {
  16.                 $this->config['name']           = __('Easy Slider', 'avia_framework' );
  17.                 $this->config['tab']            = __('Media Elements', 'avia_framework' );
  18.                 $this->config['icon']           = AviaBuilder::$path['imagesURL']."sc-slideshow.png";
  19.                 $this->config['order']          = 85;
  20.                 $this->config['target']         = 'avia-target-insert';
  21.                 $this->config['shortcode']      = 'av_slideshow';
  22.                 $this->config['shortcode_nested'] = array('av_slide');
  23.                 $this->config['tooltip']        = __('Display a simple slideshow element', 'avia_framework' );
  24.             }
  25.  
  26.             /**
  27.              * Popup Elements
  28.              *
  29.              * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  30.              * opens a modal window that allows to edit the element properties
  31.              *
  32.              * @return void
  33.              */
  34.             function popup_elements()
  35.             {
  36.                 $this->elements = array(
  37.  
  38.  
  39.                     array(
  40.                             "type"          => "modal_group",
  41.                             "id"            => "content",
  42.                             'container_class' =>"avia-element-fullwidth avia-multi-img",
  43.                             "modal_title"   => __("Edit Form Element", 'avia_framework' ),
  44.                             "add_label"     =>  __("Add single image or video", 'avia_framework' ),
  45.                             "std"           => array(),
  46.  
  47.                             'creator'       =>array(
  48.  
  49.                                 "name" => __("Add Images", 'avia_framework' ),
  50.                                 "desc" => __("Here you can add new Images to the slideshow.", 'avia_framework' ),
  51.                                 "id"    => "id",
  52.                                 "type"  => "multi_image",
  53.                                 "title" => __("Add multiple Images",'avia_framework' ),
  54.                                 "button" => __("Insert Images",'avia_framework' ),
  55.                                 "std"   => ""),
  56.  
  57.                             'subelements'   => array(
  58.                                     array( 
  59.                                         "name"  => __("Which type of slide is this?",'avia_framework' ),
  60.                                         "id"    => "slide_type",
  61.                                         "type"  => "select",
  62.                                         "std"   => "",
  63.                                         "subtype" => array(   __('Image Slide','avia_framework' )   =>'image',
  64.                                                               __('Video Slide','avia_framework' )   =>'video',
  65.                                                               )
  66.                                     ),
  67.                                    
  68.                                     array( 
  69.                                     "name"  => __("Choose another Image",'avia_framework' ),
  70.                                     "desc"  => __("Either upload a new, or choose an existing image from your media library",'avia_framework' ),
  71.                                     "id"    => "id",
  72.                                     "fetch" => "id",
  73.                                     "type"  => "image",
  74.                                     "required"=> array('slide_type','is_empty_or','image'),
  75.                                     "title" => __("Change Image",'avia_framework' ),
  76.                                     "button" => __("Change Image",'avia_framework' ),
  77.                                     "std"   => ""),
  78.                                    
  79.                                     array( 
  80.                                     "name"  => __("Video URL", 'avia_framework' ),
  81.                                     "desc"  => __('Enter the URL to the Video. Currently supported are Youtube, Vimeo and direct linking of web-video files (mp4, webm, ogv)', 'avia_framework' ) .'<br/><br/>'.
  82.                                     __('Working examples Youtube & Vimeo:', 'avia_framework' ).'<br/>
  83.                                 <strong>http://vimeo.com/1084537</strong><br/>
  84.                                 <strong>http://www.youtube.com/watch?v=5guMumPFBag</strong><br/><br/>',
  85.                                     "required"=> array('slide_type','equals','video'),
  86.                                     "id"    => "video",
  87.                                     "std"   => "http://",
  88.                                     "type"  => "video",
  89.                                     "title" => __("Upload Video",'avia_framework' ),
  90.                                     "button" => __("Use Video",'avia_framework' ),
  91.                                     ),
  92.                                    
  93.                                      array(
  94.                                     "name"  => __("Choose fallback image for mobile devices",'avia_framework' ),
  95.                                     "desc"  => __("Either upload a new, or choose an existing image from your media library",'avia_framework' )."<br/><small>".__("Video on most mobile devices can't be controlled properly with JavaScript, which is mandatory here, therefore you are required to select a fallback image which can be displayed instead", 'avia_framework' ) ."</small>" ,
  96.                                     "id"    => "mobile_image",
  97.                                     "fetch" => "id",
  98.                                     "type"  => "image",
  99.                                     "required"=> array('slide_type','equals','video'),
  100.                                     "title" => __("Choose Image",'avia_framework' ),
  101.                                     "button" => __("Choose Image",'avia_framework' ),
  102.                                     "std"   => ""),
  103.                                    
  104.                                     /*
  105.                                     array( 
  106.                                     "name"  => __("Video Size", 'avia_framework' ),
  107.                                     "desc"  => __("By default the video will try to match the default slideshow size that was selected in the slider settings at 'Slideshow Image and Video Size'", 'avia_framework' ),
  108.                                     "id"    => "video_format",
  109.                                     "type"  => "select",
  110.                                     "std"   => "",
  111.                                     "required"=> array('slide_type','equals','video'),
  112.                                     "subtype" => array(
  113.                                                         __('Try to match the default slideshow size (Video will not be cropped, but black borders will be visible at each side)',  'avia_framework' )   =>'',
  114.                                                         __('Try to match the default slideshow size but stretch the video to fill the whole slider (video will be cropped at top and bottom)',  'avia_framework' )  =>'stretch',
  115.                                                         __('Show the full Video without cropping',  'avia_framework' ) =>'full',
  116.                                                         )      
  117.                                     ),
  118.                                     */
  119.                                    
  120.                                     array( 
  121.                                     "name"  => __("Video Aspect Ratio", 'avia_framework' ),
  122.                                     "desc"  => __("In order to calculate the correct height and width for the video slide you need to enter a aspect ratio (width:height). usually: 16:9 or 4:3.", 'avia_framework' )."<br/>".__("If left empty 16:9 will be used", 'avia_framework' ) ,
  123.                                     "id"    => "video_ratio",
  124.                                     "std"   => "16:9",
  125.                                     "type"  => "input"),
  126.                                    
  127.                                    
  128.                                      array(
  129.                                     "name"  => __("Hide Video Controls", 'avia_framework' ),
  130.                                     "desc"  => __("Check if you want to hide the controls (works for youtube and self hosted videos)", 'avia_framework' ) ,
  131.                                     "id"    => "video_controls",
  132.                                     "required"=> array('slide_type','equals','video'),
  133.                                     "std"   => "",
  134.                                     "type"  => "checkbox"),
  135.                                    
  136.                                     array( 
  137.                                     "name"  => __("Mute Video Player", 'avia_framework' ),
  138.                                     "desc"  => __("Check if you want to mute the video", 'avia_framework' ) ,
  139.                                     "id"    => "video_mute",
  140.                                     "required"=> array('slide_type','equals','video'),
  141.                                     "std"   => "",
  142.                                     "type"  => "checkbox"),
  143.                                    
  144.                                     array( 
  145.                                     "name"  => __("Loop Video Player", 'avia_framework' ),
  146.                                     "desc"  => __("Check if you want to loop the video (instead of showing the next slide the video will play from the beginning again)", 'avia_framework' ) ,
  147.                                     "id"    => "video_loop",
  148.                                     "required"=> array('slide_type','equals','video'),
  149.                                     "std"   => "",
  150.                                     "type"  => "checkbox"),
  151.                                    
  152.                                     array( 
  153.                                     "name"  => __("Disable Autoplay", 'avia_framework' ),
  154.                                     "desc"  => __("Check if you want to disable video autoplay when this slide shows", 'avia_framework' ) ,
  155.                                     "id"    => "video_autoplay",
  156.                                     "required"=> array('slide_type','equals','video'),
  157.                                     "std"   => "",
  158.                                     "type"  => "checkbox"),
  159.                                    
  160.                                     array( 
  161.                                     "name"  => __("Caption Title", 'avia_framework' ),
  162.                                     "desc"  => __("Enter a caption title for the slide here", 'avia_framework' ) ,
  163.                                     "id"    => "title",
  164.                                     "std"   => "",
  165.                                     "type"  => "input"),
  166.                                    
  167.                                      array(
  168.                                     "name"  => __("Caption Text", 'avia_framework' ),
  169.                                     "desc"  => __("Enter some additional caption text", 'avia_framework' ) ,
  170.                                     "id"    => "content",
  171.                                     "type"  => "textarea",
  172.                                     "std"   => "",
  173.                                     ),
  174.                                    
  175.                                     array( 
  176.                                     "name"  => __("Apply a link to the slide?", 'avia_framework' ),
  177.                                     "desc"  => __("You can choose to apply the link to the whole image", 'avia_framework' ),
  178.                                     "id"    => "link_apply",
  179.                                     "type"  => "select",
  180.                                     "std"   => "",
  181.                                     "subtype" => array(
  182.                                         __('No Link for this slide',    'avia_framework' ) =>'',
  183.                                         __('Apply Link to Image',       'avia_framework' ) =>'image')),
  184.                                    
  185.                                    
  186.                                     array( 
  187.                                     "name"  => __("Image Link?", 'avia_framework' ),
  188.                                     "desc"  => __("Where should the Image link to?", 'avia_framework' ),
  189.                                     "id"    => "link",
  190.                                     "required"=> array('link_apply','equals','image'),
  191.                                     "type"  => "linkpicker",
  192.                                     "fetchTMPL" => true,
  193.                                     "subtype" => array(
  194.                                                         __('Open Image in Lightbox', 'avia_framework' ) =>'lightbox',
  195.                                                         __('Set Manually', 'avia_framework' ) =>'manually',
  196.                                                         __('Single Entry', 'avia_framework' ) => 'single',
  197.                                                         __('Taxonomy Overview Page',  'avia_framework' ) => 'taxonomy',
  198.                                                         ),
  199.                                     "std"   => ""),
  200.                            
  201.                                     array( 
  202.                                     "name"  => __("Open Link in new Window?", 'avia_framework' ),
  203.                                     "desc"  => __("Select here if you want to open the linked page in a new window", 'avia_framework' ),
  204.                                     "id"    => "link_target",
  205.                                     "type"  => "select",
  206.                                     "std"   => "",
  207.                                     "required"=> array('link','not_empty_and','lightbox'),
  208.                                     "subtype" => AviaHtmlHelper::linking_options()),  
  209.                         )
  210.                     ),
  211.  
  212.  
  213.  
  214.  
  215.                     array(
  216.                             "name"  => __("Slideshow Image Size", 'avia_framework' ),
  217.                             "desc"  => __("Choose the size of the image that loads into the slideshow.", 'avia_framework' ),
  218.                             "id"    => "size",
  219.                             "type"  => "select",
  220.                             "std"   => "featured",
  221.                             "subtype" =>  AviaHelper::get_registered_image_sizes(array('thumbnail','logo','widget','slider_thumb'))
  222.                             ),
  223.  
  224.                     array(
  225.                             "name"  => __("Slideshow Transition", 'avia_framework' ),
  226.                             "desc"  => __("Choose the transition for your Slideshow.", 'avia_framework' ),
  227.                             "id"    => "animation",
  228.                             "type"  => "select",
  229.                             "std"   => "slide",
  230.                             "subtype" => array(__('Slide sidewards','avia_framework' ) =>'slide', __('Slide up/down','avia_framework' ) =>'slide_up', __('Fade','avia_framework' ) =>'fade'),
  231.                             ),
  232.  
  233.                     array(
  234.                         "name"  => __("Autorotation active?",'avia_framework' ),
  235.                         "desc"  => __("Check if the slideshow should rotate by default",'avia_framework' ),
  236.                         "id"    => "autoplay",
  237.                         "type"  => "select",
  238.                         "std"   => "false",
  239.                         "subtype" => array(__('Yes','avia_framework' ) =>'true',__('No','avia_framework' ) =>'false')),
  240.                        
  241.                     array( 
  242.                         "name"  => __("Stop Autorotation with the last slide", 'avia_framework' ),
  243.                         "desc"  => __("Check if you want to disable autorotation when this last slide is displayed", 'avia_framework' ) ,
  244.                         "id"    => "autoplay_stopper",
  245.                         "required"=> array('autoplay','equals','true'),
  246.                         "std"   => "",
  247.                         "type"  => "checkbox"),
  248.  
  249.                     array(
  250.                         "name"  => __("Slideshow autorotation duration",'avia_framework' ),
  251.                         "desc"  => __("Images will be shown the selected amount of seconds.",'avia_framework' ),
  252.                         "id"    => "interval",
  253.                         "type"  => "select",
  254.                         "std"   => "5",
  255.                         "subtype" =>
  256.                         array('2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9','10'=>'10','15'=>'15','20'=>'20','30'=>'30','40'=>'40','60'=>'60','100'=>'100')),
  257.                        
  258.                         array( 
  259.                         "name"  => __("Slideshow control styling?",'avia_framework' ),
  260.                         "desc"  => __("Here you can select if and how to display the slideshow controls",'avia_framework' ),
  261.                         "id"    => "control_layout",
  262.                         "type"  => "select",
  263.                         "std"   => "",
  264.                         "subtype" => array(__('Default','avia_framework' ) =>'',__('Minimal','avia_framework' ) =>'av-control-minimal',__('Hidden','avia_framework' ) =>'av-control-hidden')), 
  265.  
  266.                        
  267.                     array( 
  268.                         "name"  => __("Use first slides caption as permanent caption", 'avia_framework' ),
  269.                         "desc"  => __("If checked the caption will be placed on top of the slider. Please be aware that all slideshow link settings and other captions will be ignored then", 'avia_framework' ) ,
  270.                         "id"    => "perma_caption",
  271.                         "std"   => "",
  272.                         "type"  => "checkbox"),
  273.                        
  274.                         );
  275.  
  276.             }
  277.  
  278.             /**
  279.              * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  280.              * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  281.              * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  282.              *
  283.              *
  284.              * @param array $params this array holds the default values for $content and $args.
  285.              * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  286.              */
  287.             function editor_element($params)
  288.             {
  289.                 $params['innerHtml'] = "<img src='".$this->config['icon']."' title='".$this->config['name']."' />";
  290.                 $params['innerHtml'].= "<div class='avia-element-label'>".$this->config['name']."</div>";
  291.                 return $params;
  292.             }
  293.  
  294.             /**
  295.              * Editor Sub Element - this function defines the visual appearance of an element that is displayed within a modal window and on click opens its own modal window
  296.              * Works in the same way as Editor Element
  297.              * @param array $params this array holds the default values for $content and $args.
  298.              * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  299.              */
  300.             function editor_sub_element($params)
  301.             {  
  302.                 $img_template       = $this->update_template("img_fakeArg", "{{img_fakeArg}}");
  303.                 $template           = $this->update_template("title", "{{title}}");
  304.                 $content            = $this->update_template("content", "{{content}}");
  305.                 $video              = $this->update_template("video", "{{video}}");
  306.                 $thumbnail = isset($params['args']['id']) ? wp_get_attachment_image($params['args']['id']) : "";
  307.                
  308.        
  309.                 $params['innerHtml']  = "";
  310.                 $params['innerHtml'] .= "<div class='avia_title_container'>";
  311.                 $params['innerHtml'] .= "   <div ".$this->class_by_arguments('slide_type' ,$params['args']).">";
  312.                 $params['innerHtml'] .= "       <span class='avia_slideshow_image' {$img_template} >{$thumbnail}</span>";
  313.                 $params['innerHtml'] .= "       <div class='avia_slideshow_content'>";
  314.                 $params['innerHtml'] .= "           <h4 class='avia_title_container_inner' {$template} >".$params['args']['title']."</h4>";
  315.                 $params['innerHtml'] .= "           <p class='avia_content_container' {$content}>".stripslashes($params['content'])."</p>";
  316.                 $params['innerHtml'] .= "           <small class='avia_video_url' {$video}>".stripslashes($params['args']['video'])."</small>";
  317.                 $params['innerHtml'] .= "       </div>";
  318.                 $params['innerHtml'] .= "   </div>";
  319.                 $params['innerHtml'] .= "</div>";
  320.                
  321.                
  322.                
  323.                 return $params;
  324.             }
  325.  
  326.  
  327.             /**
  328.              * Frontend Shortcode Handler
  329.              *
  330.              * @param array $atts array of attributes
  331.              * @param string $content text within enclosing form of shortcode element
  332.              * @param string $shortcodename the shortcode found, when == callback name
  333.              * @return string $output returns the modified html string
  334.              */
  335.             function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
  336.             {
  337.                 $atts = shortcode_atts(array(
  338.                 'size'          => 'featured',
  339.                 'animation'     => 'slide',
  340.                 'ids'           => '',
  341.                 'autoplay'      => 'false',
  342.                 'interval'      => 5,
  343.                 'control_layout'=> '',
  344.                 'perma_caption' => '',
  345.                 'handle'        => $shortcodename,
  346.                 'content'       => ShortcodeHelper::shortcode2array($content, 1),
  347.                 'class'         => $meta['el_class'],
  348.                 'custom_markup' => $meta['custom_markup'],
  349.                 'autoplay_stopper'=>'',
  350.  
  351.                 ), $atts, $this->config['shortcode']);
  352.  
  353.                 $slider = new avia_slideshow($atts);
  354.                 return $slider->html();
  355.             }
  356.  
  357.     }
  358. }
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368. if ( !class_exists( 'avia_slideshow' ) )
  369. {
  370.     class avia_slideshow
  371.     {
  372.         static  $slider = 0;                //slider count for the current page
  373.         protected $config;                  //base config set on initialization
  374.         protected $slides;                  //attachment posts for the current slider
  375.         protected $slide_count = 0;         //number of slides
  376.         protected $id_array = array();
  377.         function __construct($config)
  378.         {
  379.  
  380.             $this->config = array_merge(array(
  381.                 'size'          => 'featured',
  382.                 'lightbox_size' => 'large',
  383.                 'animation'     => 'slide',
  384.                 'ids'           => '',
  385.                 'video_counter' => 0,
  386.                 'autoplay'      => 'false',
  387.                 'bg_slider'     => 'false',
  388.                 'slide_height'  => '',
  389.                 'handle'        => '',
  390.                 'interval'      => 5,
  391.                 'class'         => "",
  392.                 'css_id'        => "",
  393.                 'scroll_down'   => "",
  394.                 'control_layout'=> '',
  395.                 'content'       => array(),
  396.                 'custom_markup' => '',
  397.                 'perma_caption' => '',
  398.                 'autoplay_stopper'=>''
  399.                 ), $config);
  400.  
  401.             $this->config = apply_filters('avf_slideshow_config', $this->config);
  402.  
  403.             //check how large the slider is and change the classname accordingly
  404.             global $_wp_additional_image_sizes;
  405.             $width = 1500;
  406.  
  407.             if(isset($_wp_additional_image_sizes[$this->config['size']]['width']))
  408.             {
  409.                 $width  = $_wp_additional_image_sizes[$this->config['size']]['width'];
  410.                 $height = $_wp_additional_image_sizes[$this->config['size']]['height'];
  411.                
  412.                 $this->config['default-height'] = (100/$width) * $height;
  413.                
  414.             }
  415.             else if($size = get_option( $this->config['size'].'_size_w' ))
  416.             {
  417.                 $width = $size;
  418.             }
  419.  
  420.             if($width < 600)
  421.             {
  422.                 $this->config['class'] .= " avia-small-width-slider";
  423.             }
  424.  
  425.             if($width < 305)
  426.             {
  427.                 $this->config['class'] .= " avia-super-small-width-slider";
  428.             }
  429.  
  430.             //if we got subslides overwrite the id array
  431.             if(!empty($config['content']))
  432.             {
  433.                 $this->extract_subslides($config['content']);
  434.             }
  435.            
  436.             if("aviaTBautoplay_stopper" == $this->config['autoplay_stopper'])
  437.             {
  438.                 $this->config['autoplay_stopper'] = true;
  439.             }
  440.             else
  441.             {
  442.                 $this->config['autoplay_stopper'] = false;
  443.             }
  444.  
  445.             $this->set_slides($this->config['ids']);
  446.         }
  447.  
  448.         public function set_slides($ids)
  449.         {
  450.             if(empty($ids) && empty($this->config['video_counter'])) return;
  451.  
  452.             $this->slides = get_posts(array(
  453.                 'include' => $ids,
  454.                 'post_status' => 'inherit',
  455.                 'post_type' => 'attachment',
  456.                 'post_mime_type' => 'image',
  457.                 'order' => 'ASC',
  458.                 'orderby' => 'post__in')
  459.                 );
  460.  
  461.  
  462.  
  463.             //resort slides so the id of each slide matches the post id
  464.             $new_slides = array();
  465.             foreach($this->slides as $slide)
  466.             {
  467.                 $new_slides[$slide->ID] = $slide;
  468.             }
  469.  
  470.             $slideshow_data = array();
  471.             $slideshow_data['slides'] = $new_slides;
  472.             $slideshow_data['id_array'] = explode(',',$this->config['ids']);
  473.             $slideshow_data['slide_count'] = count(array_filter($slideshow_data['id_array'])) + $this->config['video_counter'];
  474.            
  475.             $slideshow_data = apply_filters('avf_avia_builder_slideshow_filter', $slideshow_data);
  476.            
  477.             $this->slides = $slideshow_data['slides'];
  478.             $this->id_array = $slideshow_data['id_array'];
  479.             $this->slide_count = $slideshow_data['slide_count'];
  480.         }
  481.  
  482.         public function set_size($size)
  483.         {
  484.             $this->config['size'] = $size;
  485.         }
  486.  
  487.         public function set_extra_class($class)
  488.         {
  489.             $this->config['class'] .= " ".$class;
  490.         }
  491.  
  492.  
  493.  
  494.         public function html()
  495.         {
  496.             $html       = "";
  497.             $counter    = 0;
  498.             $style      = "";
  499.             $extraClass = "";
  500.             avia_slideshow::$slider++;
  501.             if($this->slide_count == 0) return $html;
  502.            
  503.             if(!empty($this->config['scroll_down']))
  504.             {  
  505.                 $html .= "<a href='#next-section' title='' class='scroll-down-link' ". av_icon_string( 'scrolldown' ). "></a>";
  506.                 $extraClass .= "av-slider-scroll-down-active";
  507.             }
  508.            
  509.             if(!empty($this->config['control_layout'])) $extraClass .= " ".$this->config['control_layout'];
  510.            
  511.             $style = "";
  512.             if(!empty($this->config['default-height']))
  513.             {
  514.                 $style = "style='padding-bottom: {{av-default-heightvar}}%;'";
  515.                 $extraClass .= " av-default-height-applied";
  516.             }
  517.            
  518.            
  519.             $markup = avia_markup_helper(array('context' => 'image','echo'=>false, 'custom_markup'=>$this->config['custom_markup']));
  520.  
  521.             $data = AviaHelper::create_data_string($this->config);
  522.  
  523.             $html .= "<div {$data} class='avia-slideshow avia-slideshow-".avia_slideshow::$slider." {$extraClass} avia-slideshow-".$this->config['size']." ".$this->config['handle']." ".$this->config['class']." avia-".$this->config['animation']."-slider ' $markup>";
  524.            
  525.            
  526.             $html .= "<ul class='avia-slideshow-inner' {$style}>";
  527.  
  528.             $html .= empty($this->subslides) ? $this->default_slide() : $this->advanced_slide();
  529.  
  530.             $html .= "</ul>";
  531.  
  532.             if($this->slide_count > 1)
  533.             {
  534.                 $html .= $this->slide_navigation_arrows();
  535.                 $html .= $this->slide_navigation_dots();
  536.             }
  537.            
  538.            
  539.             if(!empty($this->config['caption_override'])) $html .= $this->config['caption_override'];
  540.            
  541.  
  542.             $html .= "</div>";
  543.            
  544.             if(!empty($this->config['default-height']))
  545.             {
  546.                 $html = str_replace('{{av-default-heightvar}}', $this->config['default-height'], $html);
  547.             }
  548.            
  549.             return $html;
  550.         }
  551.  
  552.         //function that renders the usual slides. use when we didnt use sub-shorcodes to define the images but ids
  553.         protected function default_slide()
  554.         {
  555.             $html = "";
  556.             $counter = 0;
  557.  
  558.             $markup_url = avia_markup_helper(array('context' => 'image_url','echo'=>false, 'custom_markup'=>$this->config['custom_markup']));
  559.  
  560.             foreach($this->id_array as $id)
  561.             {
  562.                 if(isset($this->slides[$id]))
  563.                 {
  564.                     $slide = $this->slides[$id];
  565.  
  566.                     $counter ++;
  567.                     $img     = wp_get_attachment_image_src($slide->ID, $this->config['size']);
  568.                     $link    = wp_get_attachment_image_src($slide->ID, $this->config['lightbox_size']);
  569.                     $caption = trim($slide->post_excerpt) ? '<div class="avia-caption capt-bottom capt-left"><div class="avia-inner-caption">'.wptexturize($slide->post_excerpt)."</div></div>": "";
  570.  
  571.                     $imgalt = get_post_meta($slide->ID, '_wp_attachment_image_alt', true);
  572.                     $imgalt = !empty($imgalt) ? esc_attr($imgalt) : '';
  573.                     $imgtitle = trim($slide->post_title) ? esc_attr($slide->post_title) : "";
  574.                     if($imgtitle == "-") $imgtitle = "";
  575.                     $imgdescription = trim($slide->post_content) ? esc_attr($slide->post_content) : "";
  576.  
  577.                     $tags = apply_filters('avf_slideshow_link_tags', array("a href='".$link[0]."' title='".$imgdescription."'",'a')); // can be filtered and for example be replaced by array('div','div')
  578.                    
  579.                     $html .= "<li class='slide-{$counter} slide-id-".$slide->ID."'>";
  580.                     $html .= "<".$tags[0]." >{$caption}<img src='".$img[0]."' width='".$img[1]."' height='".$img[2]."' title='".$imgtitle."' alt='".$imgalt."' $markup_url /></ ".$tags[1]." >";
  581.                     $html .= "</li>";
  582.                 }
  583.                 else
  584.                 {
  585.                     $this->slide_count --;
  586.                 }
  587.             }
  588.  
  589.             return $html;
  590.         }
  591.  
  592.         //function that renders the slides. use when we did use sub-shorcodes to define the images
  593.         protected function advanced_slide()
  594.         {
  595.             $html = "";
  596.             $counter = 0;
  597.             $this->ie8_fallback = "";
  598.  
  599.             foreach($this->id_array as $key => $id)
  600.             {
  601.                 $meta = array_merge( array( 'content'       => $this->subslides[$key]['content'],
  602.                                             'title'         =>'',
  603.                                             'link_apply'    =>'',
  604.                                             //direct link from image
  605.                                             'link'          =>'',
  606.                                             'link_target'   =>'',
  607.                                             //button link 1
  608.                                             'button_label'  =>'',
  609.                                             'button_color'  =>'light',
  610.                                             'link1'         =>'',
  611.                                             'link_target1'  =>'',                                          
  612.                                             //button link 2
  613.                                             'button_label2' =>'',
  614.                                             'button_color2' =>'light',
  615.                                             'link2'         =>'',
  616.                                             'link_target2'  =>'',
  617.                                            
  618.                                             'position'      =>'center center',
  619.                                             'caption_pos'   =>'capt-bottom capt-left',
  620.                                             'video_cover'   =>'',
  621.                                             'video_controls'=>'',
  622.                                             'video_mute'    =>'',
  623.                                             'video_loop'    =>'',
  624.                                             'video_format'  =>'',
  625.                                             'video_autoplay'=>'',
  626.                                             'video_ratio'   =>'16:9',
  627.                                             'video_mobile_disabled'=>'',
  628.                                             'video_mobile'  =>'mobile-fallback-image',
  629.                                             'mobile_image'  => '',
  630.                                             'slide_type'    =>'',
  631.                                             'custom_markup' => '',
  632.                                             'custom_title_size' => '',
  633.                                             'custom_content_size' => '',
  634.                                             'font_color'    =>'',
  635.                                             'custom_title'  => '',
  636.                                             'custom_content' => '',
  637.                                             'overlay_enable' => '',
  638.                                             'overlay_opacity' => '',
  639.                                             'overlay_color' => '',
  640.                                             'overlay_pattern' => '',
  641.                                             'overlay_custom_pattern' => '',
  642.  
  643.  
  644.                                         ), $this->subslides[$key]['attr']);
  645.                
  646.                 extract($meta);
  647.                
  648.                 if(isset($this->slides[$id]) || $slide_type == 'video')
  649.                 {
  650.                     $img            = array('');
  651.                     $slide          = "";
  652.                     $attachment_id  = isset($this->slides[$id]) ? $id : false;
  653.                     $link           = AviaHelper::get_url($link, $attachment_id);
  654.                     $extra_class    = "";
  655.                     $linkdescription= "";
  656.                     $linkalt        = "";
  657.                     $this->service  = false;
  658.                     $slider_data    = "";
  659.                     $stretch_height = false;
  660.                     $final_ratio    = "";
  661.                     $viewport       = 16/9;
  662.  
  663.                     $markup_url = avia_markup_helper(array('context' => 'image_url','echo'=>false, 'id'=>$attachment_id, 'custom_markup'=>$custom_markup));
  664.                    
  665.                     if($slide_type == 'video')
  666.                     {
  667.                         $this->service    = avia_slideshow_video_helper::which_video_service($video);
  668.                         $video            = avia_slideshow_video_helper::set_video_slide($video, $this->service, $meta);
  669.                         $video_class      = !empty( $video_controls ) ? " av-hide-video-controls" : "";
  670.                         $video_class     .= !empty( $video_mute ) ? " av-mute-video" : "";
  671.                         $video_class     .= !empty( $video_loop ) ? " av-loop-video" : "";
  672.                         $video_class     .= !empty( $video_mobile ) ? " av-".$video_mobile : "";
  673.                        
  674.                         $extra_class    .= " av-video-slide ".$video_cover." av-video-service-".$this->service." ".$video_class;
  675.                         $slider_data    .= " data-controls='{$video_controls}' data-mute='{$video_mute}' data-loop='{$video_loop}' data-disable-autoplay='{$video_autoplay}' ";
  676.                        
  677.                         if($mobile_image){
  678.                             $fallback_img = wp_get_attachment_image_src($mobile_image, $this->config['size']);
  679.                             $slider_data .= " data-mobile-img='".$fallback_img[0]."'";
  680.                         }
  681.                        
  682.                         //if we dont use a fullscreen slider pass the video ratio to the slider
  683.                         if($this->config['bg_slider'] != "true")
  684.                         {
  685.                             global $avia_config;
  686.                             //if we use the small slideshow only allow the "full" $video_format
  687.                             if($this->config['handle'] == 'av_slideshow') $video_format = "full";
  688.                            
  689.                            
  690.                             //calculate the viewport ratio
  691.                             if(!empty($avia_config['imgSize'][$this->config['size']]))
  692.                             {
  693.                                 $viewport = $avia_config['imgSize'][$this->config['size']]['width'] / $avia_config['imgSize'][$this->config['size']]['height'];
  694.                             }
  695.                            
  696.                            
  697.                             //calculate the ratio when passed as a string (eg: 16:9, 4:3). fallback is 16:9
  698.                             $video_ratio = explode(':',trim($video_ratio));
  699.                             if(empty($video_ratio[0])) $video_ratio[0] = 16;
  700.                             if(empty($video_ratio[1])) $video_ratio[1] = 9;
  701.                             $final_ratio = ((int) $video_ratio[0] / (int) $video_ratio[1]);                        
  702.                            
  703.                             switch($video_format)
  704.                             {
  705.                                 case "":
  706.                                     $final_ratio = $viewport;
  707.                                 break;
  708.                                 case "stretch":
  709.                                     $final_ratio     = $viewport;
  710.                                     $stretch_height  = ceil( $viewport / ($video_ratio[0]/$video_ratio[1]) * 100 );
  711.                                     $stretch_pos     = (($stretch_height - 100) / 2) * -1;
  712.                                     $slider_data    .= " data-video-height='{$stretch_height}'";
  713.                                     $slider_data    .= " data-video-toppos='{$stretch_pos}'";
  714.                                     $extra_class    .= " av-video-stretch";
  715.                                 break;
  716.                                 case "full":
  717.                                     // do nothing and apply the entered ratio
  718.                                 break;
  719.                             }
  720.                            
  721.                             $slider_data .= " data-video-ratio='{$final_ratio}'";  
  722.                         }
  723.                        
  724.                     }
  725.                     else //img slide
  726.                     {
  727.                         $slide           = $this->slides[$id];
  728.                         $linktitle       = trim($slide->post_title) ? esc_attr($slide->post_title) : "";
  729.                         if($linktitle == "-") $linktitle = "";
  730.                         $linkdescription = (trim($slide->post_content) && empty($link)) ? "title='".esc_attr($slide->post_content)."'" : "";
  731.                         $linkalt         = get_post_meta($slide->ID, '_wp_attachment_image_alt', true);
  732.                         $linkalt         = !empty($linkalt) ? esc_attr($linkalt) : '';
  733.                         $img             = wp_get_attachment_image_src($slide->ID, $this->config['size']);
  734.                         $video           = "";
  735.                     }
  736.                    
  737.                     if($this->slide_count === 1) $extra_class .= " av-single-slide";
  738.                    
  739.                     $blank = (strpos($link_target, '_blank') !== false || $link_target == 'yes') ? ' target="_blank" ' : "";
  740.                     $blank .= strpos($link_target, 'nofollow') !== false ? ' rel="nofollow" ' : "";
  741.                     $tags           = (!empty($link) && $link_apply == 'image') ? array("a href='{$link}'{$blank}",'a') : array('div','div');
  742.                     $caption        = "";
  743.                     $button_html    = "";
  744.                     $counter ++;
  745.                     $button_count = "";
  746.                     if(strpos($link_apply, 'button-two') !== false){$button_count = "avia-multi-slideshow-button";}
  747.                    
  748.                    
  749.                     //if we got a CTA button apply the link to the button istead of the slide
  750.                     if(strpos($link_apply, 'button') !== false)
  751.                     {
  752.                         $button_html .= $this->slideshow_cta_button($link1, $link_target1, $button_color, $button_label, $button_count);
  753.                         $tags = array('div','div');
  754.                     }
  755.                    
  756.                     if(strpos($link_apply, 'button-two') !== false)
  757.                     {
  758.                         $button_count .= " avia-slideshow-button-2";
  759.                         $button_html .= $this->slideshow_cta_button($link2, $link_target2, $button_color2, $button_label2, $button_count);
  760.                     }
  761.                    
  762.                    
  763.                     //custom caption styles
  764.                    
  765.                     $title_styling       = !empty($custom_title_size) ? "font-size:{$custom_title_size}px; " : "";
  766.                     $content_styling     = !empty($custom_content_size) ? "font-size:{$custom_content_size}px; " : "";
  767.                     $content_class       = "";
  768.                    
  769.                     if($font_color == "custom")
  770.                     {
  771.                         $title_styling      .= !empty($custom_title) ? "color:{$custom_title}; " : "";
  772.                         $content_styling    .= !empty($custom_content) ? "color:{$custom_content}; " : "";
  773.                     }
  774.                    
  775.                     if($title_styling) $title_styling = " style='{$title_styling}'" ;
  776.                     if($content_styling)
  777.                     {
  778.                         $content_styling = " style='{$content_styling}'" ;
  779.                         $content_class   = "av_inherit_color";
  780.                     }
  781.                    
  782.                    
  783.                    
  784.                    
  785.                     //check if we got a caption
  786.                     $markup_description = avia_markup_helper(array('context' => 'description','echo'=>false, 'id'=>$attachment_id, 'custom_markup'=>$custom_markup));
  787.                     $markup_name = avia_markup_helper(array('context' => 'name','echo'=>false, 'id'=>$attachment_id, 'custom_markup'=>$custom_markup));
  788.                     if(trim($title) != "")   $title     = "<h2 {$title_styling} class='avia-caption-title' $markup_name>".trim(apply_filters('avf_slideshow_title', $title))."</h2>";
  789.                    
  790.                     if(is_array($content)) $content = implode(' ',$content); //temp fix for trim() expects string warning until I can actually reproduce the problem
  791.                     if(trim($content) != "") $content   = "<div class='avia-caption-content {$content_class}' {$markup_description} {$content_styling}>".ShortcodeHelper::avia_apply_autop(ShortcodeHelper::avia_remove_autop(trim($content)))."</div>";
  792.  
  793.                     if(trim($title.$content.$button_html) != "")
  794.                     {
  795.                         if(trim($title) != "" && trim($button_html) != "" && trim($content) == "") $content = "<br/>";
  796.  
  797.                         if($this->config['handle'] == 'av_slideshow_full' || $this->config['handle'] == 'av_fullscreen')
  798.                         {
  799.                             $caption .= '<div class = "caption_fullwidth av-slideshow-caption '.$caption_pos.'">';
  800.                             $caption .=     '<div class = "container caption_container">';
  801.                             $caption .=             '<div class = "slideshow_caption">';
  802.                             $caption .=                 '<div class = "slideshow_inner_caption">';
  803.                             $caption .=                     '<div class = "slideshow_align_caption">';
  804.                             $caption .=                     $title;
  805.                             $caption .=                     $content;
  806.                             $caption .=                     $button_html;
  807.                             $caption .=                     '</div>';
  808.                             $caption .=                 '</div>';
  809.                             $caption .=             '</div>';
  810.                             $caption .=     '</div>';
  811.                             $caption .= '</div>';
  812.                         }
  813.                         else
  814.                         {
  815.                             $caption = '<div class="avia-caption av-slideshow-caption"><div class="avia-inner-caption">'.$title.$content."</div></div>";
  816.                         }
  817.                     }
  818.  
  819.                     if(!empty($this->config['perma_caption']) && empty($this->config['caption_override']))
  820.                     {
  821.                         $this->config['caption_override'] = $caption;
  822.                     }
  823.                    
  824.                     if(!empty($this->config['caption_override'])) $caption = "";
  825.                    
  826.                    
  827.                     if(!empty($img[0]))
  828.                     {
  829.                         $slider_data .= $this->config['bg_slider'] == "true" ? "style='background-position:{$position};' data-img-url='".$img[0]."'" : "";
  830.                        
  831.                         if($slider_data )
  832.                         {
  833.                             if(empty($this->ie8_fallback))
  834.                             {
  835.                                 $this->ie8_fallback .= "<!--[if lte IE 8]>";
  836.                                 $this->ie8_fallback .= "<style type='text/css'>";
  837.                             }
  838.                             $this->ie8_fallback .= "\n #{$this->config['css_id']} .slide-{$counter}{";
  839.                             $this->ie8_fallback .= "\n -ms-filter: \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$img[0]}', sizingMethod='scale')\"; ";
  840.                             $this->ie8_fallback .= "\n filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$img[0]}', sizingMethod='scale'); ";
  841.                             $this->ie8_fallback .= "\n } \n";
  842.                         }
  843.                     }
  844.                    
  845.                    
  846.                    
  847.                    
  848.                     // $img[0] = 'http://www.kriesi.at/themes/enfold-photography/files/2014/08/darkened_girl.jpg';
  849.  
  850.  
  851.                     $html .= "<li {$slider_data} class='{$extra_class} slide-{$counter} ' >";
  852.                     $html .= "<".$tags[0]." data-rel='slideshow-".avia_slideshow::$slider."' class='avia-slide-wrap' {$linkdescription} >{$caption}";
  853.                     if($this->config['bg_slider'] != "true" && empty($video))
  854.                     {
  855.                         $html .= "<img src='".$img[0]."' width='".$img[1]."' height='".$img[2]."' title='".$linktitle."' alt='".$linkalt."' $markup_url />";
  856.                     }
  857.                     $html .= $video;
  858.                     $html .= $this->create_overlay($meta);
  859.                     $html .= "</".$tags[1].">";
  860.                     $html .= "</li>";
  861.                    
  862.                     if($counter === 1 && !empty($this->config['default-height']))
  863.                     {
  864.                         if(!empty($img[1]) && !empty($img[2]))
  865.                         {
  866.                             $this->config['default-height'] = (100/$img[1]) * $img[2];
  867.                         }
  868.                     }
  869.                    
  870.             }
  871.             else
  872.             {
  873.                 $this->slide_count --;
  874.             }
  875.         }
  876.  
  877.             if(!empty($this->ie8_fallback))
  878.             {
  879.                 $this->ie8_fallback .= "</style> <![endif]-->";
  880.                 add_action('wp_footer', array($this, 'add_ie8_fallback_to_footer'));
  881.             }
  882.  
  883.             return $html;
  884.         }
  885.  
  886.         public function add_ie8_fallback_to_footer()
  887.         {
  888.             // echo $this->ie8_fallback;
  889.         }
  890.        
  891.         protected function slideshow_cta_button($link, $link_target, $button_color, $button_label, $button_count)
  892.         {
  893.             $button_html = "";
  894.             $blank = (strpos($link_target, '_blank') !== false || $link_target == 'yes') ? ' target="_blank" ' : "";
  895.             $blank .= strpos($link_target, 'nofollow') !== false ? ' rel="nofollow" ' : "";
  896.            
  897.             $link = AviaHelper::get_url($link);
  898.            
  899.             $button_html .= "<a href='{$link}' {$blank} class='avia-slideshow-button avia-button avia-color-{$button_color} {$button_count}' data-duration='800' data-easing='easeInOutQuad'>";
  900.             $button_html .= $button_label;
  901.             $button_html .= "</a>";
  902.             return $button_html;
  903.         }
  904.  
  905.  
  906.         protected function slide_navigation_arrows()
  907.         {
  908.             global $avia_config;
  909.        
  910.             $html  = "";
  911.             $html .= "<div class='avia-slideshow-arrows avia-slideshow-controls'>";
  912.             $html .=    "<a href='#prev' class='prev-slide' ".av_icon_string('prev_big').">".__('Previous','avia_framework' )."</a>";
  913.             $html .=    "<a href='#next' class='next-slide' ".av_icon_string('next_big').">".__('Next','avia_framework' )."</a>";
  914.             $html .= "</div>";
  915.  
  916.             return $html;
  917.         }
  918.  
  919.         protected function slide_navigation_dots()
  920.         {
  921.             $html   = "";
  922.             $html  .= "<div class='avia-slideshow-dots avia-slideshow-controls'>";
  923.             $active = "active";
  924.  
  925.             for($i = 1; $i <= $this->slide_count; $i++)
  926.             {
  927.                 $html .= "<a href='#{$i}' class='goto-slide {$active}' >{$i}</a>";
  928.                 $active = "";
  929.             }
  930.  
  931.             $html .= "</div>";
  932.  
  933.             return $html;
  934.         }
  935.  
  936.         protected function extract_subslides($slide_array)
  937.         {
  938.             $this->config['ids']= array();
  939.             $this->subslides    = array();
  940.        
  941.             foreach($slide_array as $key => $slide)
  942.             {
  943.                 $this->subslides[$key] = $slide;
  944.                 $this->config['ids'][] = $slide['attr']['id'];
  945.            
  946.                 if( empty($slide['attr']['id']) && !empty($slide['attr']['video']) && $slide['attr']['slide_type'] === 'video')
  947.                 {
  948.                     $this->config['video_counter'] ++ ;
  949.                 }
  950.             }
  951.  
  952.             $this->config['ids'] = implode(',',$this->config['ids'] );
  953.            
  954.             unset($this->config['content']);
  955.         }
  956.        
  957.         protected function create_overlay($meta)
  958.         {
  959.             extract($meta);
  960.            
  961.             /*check/create overlay*/
  962.             $overlay = "";
  963.             if(!empty($overlay_enable))
  964.             {
  965.                 $overlay_src = "";
  966.                 $overlay = "opacity: {$overlay_opacity}; ";
  967.                 if(!empty($overlay_color)) $overlay .= "background-color: {$overlay_color}; ";
  968.                 if(!empty($overlay_pattern))
  969.                 {
  970.                     if($overlay_pattern == "custom")
  971.                     {
  972.                         $overlay_src = $overlay_custom_pattern;
  973.                     }
  974.                     else
  975.                     {
  976.                         $overlay_src = str_replace('{{AVIA_BASE_URL}}', AVIA_BASE_URL, $overlay_pattern);
  977.                     }
  978.                 }
  979.                
  980.                 if(!empty($overlay_src)) $overlay .= "background-image: url({$overlay_src}); background-repeat: repeat;";
  981.                 $overlay = "<div class='av-section-color-overlay' style='{$overlay}'></div>";
  982.             }
  983.            
  984.             return $overlay;
  985.         }
  986.        
  987.  
  988.        
  989.        
  990.     }
  991. }
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998. if ( !class_exists( 'avia_slideshow_video_helper' ) )
  999. {
  1000.     class avia_slideshow_video_helper
  1001.     {
  1002.         static function set_video_slide($video_url, $service = false, $meta = false)
  1003.         {
  1004.             $video = "";
  1005.             if(empty($service)) $service = self::which_video_service($video_url);
  1006.            
  1007.             $uid        = 'player_'.get_the_ID().'_'.mt_rand().'_'.mt_rand();
  1008.             $controls   = empty($meta['video_controls']) ? 1 : 0;
  1009.             $loop       = empty($meta['video_loop']) ? 0 : 1;
  1010.            
  1011.             switch( $service )
  1012.             {
  1013.                 case "html5": $video = "<div class='av-click-overlay'></div>".avia_html5_video_embed($video_url); break;
  1014.                 case "iframe":$video = $video_url; break;
  1015.                 case "youtube":
  1016.                    
  1017.                     $explode_at = strpos($video_url, 'youtu.be/') !== false ? "/" : "v=";
  1018.                     $video_url  = explode($explode_at, trim($video_url));
  1019.                     $video_url  = end($video_url);
  1020.                     $video_id   = $video_url;
  1021.                    
  1022.                     //if parameters are appended make sure to create the correct video id
  1023.                     if (strpos($video_url,'?') !== false || strpos($video_url,'?') !== false)
  1024.                     {
  1025.                         preg_match('!(.+)[&?]!',$video_url, $video_id);
  1026.                         $video_id = isset($video_id[1]) ? $video_id[1] : $video_id[0];
  1027.                     }
  1028.                    
  1029.                     $video_data = apply_filters( 'avf_youtube_video_data', array(
  1030.                             'autoplay'      => 0,
  1031.                             'videoid'       => $video_id,
  1032.                             'hd'            => 1,
  1033.                             'rel'           => 0,
  1034.                             'wmode'         => 'opaque',
  1035.                             'playlist'      => $uid,
  1036.                             'loop'          => 0,
  1037.                             'version'       => 3,
  1038.                             'autohide'      => 1,
  1039.                             'color'         => 'white',
  1040.                             'controls'      => $controls,
  1041.                             'showinfo'      => 0,
  1042.                             'iv_load_policy'=> 3
  1043.                         ));
  1044.                        
  1045.                     $data = AviaHelper::create_data_string($video_data);
  1046.                
  1047.                     $video  = "<div class='av-click-overlay'></div><div class='mejs-mediaelement'><div height='1600' width='900' class='av_youtube_frame' id='{$uid}' {$data}></div></div>";
  1048.                    
  1049.                 break;
  1050.                 case "vimeo":
  1051.            
  1052.                     $color      = ltrim( avia_get_option('colorset-main_color-primary'), '#');             
  1053.                     $autopause  = empty($meta['video_section_bg']) ? 1 : 0; //pause if another vimeo video plays?
  1054.                     $video_url  = explode('/', trim($video_url));
  1055.                     $video_url  = end($video_url);
  1056.                     $video_url  = esc_url(add_query_arg(
  1057.                         array(
  1058.                             'portrait'  => 0,
  1059.                             'byline'    => 0,
  1060.                             'title'     => 0,
  1061.                             'badge'     => 0,
  1062.                             'loop'      => $loop,
  1063.                             'autopause' => $autopause,
  1064.                             'api'       => 1,
  1065.                             'rel'       => 0,
  1066.                             'player_id' => $uid,
  1067.                             'color'     => $color
  1068.                         ),
  1069.                     '//player.vimeo.com/video/'.$video_url
  1070.                     ));
  1071.                    
  1072.                     $video_url = apply_filters( 'avf_vimeo_video_url' , $video_url);
  1073.                     $video  = "<div class='av-click-overlay'></div><div class='mejs-mediaelement'><iframe src='{$video_url}' height='1600' width='900'  frameborder='' class='av_vimeo_frame' id='{$uid}'></iframe></div>";
  1074.                    
  1075.                 break;
  1076.             }
  1077.            
  1078.            
  1079.            
  1080.             return $video;
  1081.            
  1082.         }
  1083.        
  1084.         //get the video service based on the url string fo the video
  1085.         static function which_video_service($video_url)
  1086.         {
  1087.             $service = "";
  1088.            
  1089.             if(avia_backend_is_file($video_url, 'html5video'))
  1090.             {
  1091.                 $service = "html5";
  1092.             }
  1093.             else if(strpos($video_url,'<iframe') !== false)
  1094.             {
  1095.                 $service = "iframe";
  1096.             }
  1097.             else
  1098.             {
  1099.                 if(strpos($video_url, 'youtube.com/watch') !== false || strpos($video_url, 'youtu.be/') !== false)
  1100.                 {
  1101.                     $service = "youtube";
  1102.                 }
  1103.                 else if(strpos($video_url, 'vimeo.com') !== false)
  1104.                 {
  1105.                     $service = "vimeo";
  1106.                 }
  1107.             }
  1108.            
  1109.             return $service;
  1110.         }
  1111.     }
  1112. }
Advertisement
Add Comment
Please, Sign In to add comment