Advertisement
cipher87

Featured Image Slider with Categories

Nov 23rd, 2016
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 27.03 KB | None | 0 0
  1. <?php
  2. /*
  3.  * http://www.kriesi.at/support/topic/add-categories-links-above-post-title-in-featured-image-slider/
  4.  */
  5. if ( !class_exists( 'avia_sc_featureimage_slider' ))
  6. {
  7.     class avia_sc_featureimage_slider extends aviaShortcodeTemplate
  8.     {
  9.        
  10.         static $slide_count = 0;
  11.        
  12.         /**
  13.          * Create the config array for the shortcode button
  14.          */
  15.         function shortcode_insert_button()
  16.         {
  17.             $this->config['name']       = __('Featured Image Slider', 'avia_framework' );
  18.             $this->config['tab']        = __('Media Elements', 'avia_framework' );
  19.             $this->config['icon']       = AviaBuilder::$path['imagesURL']."sc-postslider.png";
  20.             $this->config['order']      = 30;
  21.             $this->config['target']     = 'avia-target-insert';
  22.             $this->config['shortcode']  = 'av_feature_image_slider';
  23.             $this->config['tooltip']    = __('Display a Slideshow of featured images from various posts', 'avia_framework' );
  24.             $this->config['drag-level'] = 3;
  25.         }
  26.  
  27.         /**
  28.          * Popup Elements
  29.          *
  30.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  31.          * opens a modal window that allows to edit the element properties
  32.          *
  33.          * @return void
  34.          */
  35.         function popup_elements()
  36.         {
  37.             $this->elements = array(
  38.                
  39.                 array(
  40.                     "type"  => "tab_container", 'nodescription' => true
  41.                 ),
  42.                
  43.                 array(
  44.                     "type"  => "tab",
  45.                     "name"  => __("Slider Content" , 'avia_framework'),
  46.                     'nodescription' => true
  47.                 ),
  48.                
  49.                 array(
  50.                         "name"  => __("Which Entries?", 'avia_framework' ),
  51.                         "desc"  => __("Select which entries should be displayed by selecting a taxonomy", 'avia_framework' ),
  52.                         "id"    => "link",
  53.                         "fetchTMPL" => true,
  54.                         "type"  => "linkpicker",
  55.                         "subtype"  => array( __('Display Entries from:',  'avia_framework' )=>'taxonomy'),
  56.                         "multiple"  => 6,
  57.                         "std"   => "category"
  58.                 ),
  59.  
  60.                 array(
  61.                         "name"  => __("Entry Number", 'avia_framework' ),
  62.                         "desc"  => __("How many items should be displayed?", 'avia_framework' ),
  63.                         "id"    => "items",
  64.                         "type"  => "select",
  65.                         "std"   => "3",
  66.                         "subtype" => AviaHtmlHelper::number_array(1,100,1, array('All'=>'-1'))),
  67.  
  68.                 array(
  69.                     "name"  => __("Offset Number", 'avia_framework' ),
  70.                     "desc"  => __("The offset determines where the query begins pulling posts. Useful if you want to remove a certain number of posts because you already query them with another element.", 'avia_framework' ),
  71.                     "id"    => "offset",
  72.                     "type"  => "select",
  73.                     "std"   => "enforce_duplicates",
  74.                     "subtype" => AviaHtmlHelper::number_array(1,100,1,
  75.                    
  76.                         array(
  77.                            
  78.                         __('Deactivate offset','avia_framework')=>'0',
  79.                         __('Do not allow duplicate posts on the entire page (set offset automatically)', 'avia_framework' ) =>'no_duplicates',
  80.                         __('Enforce duplicates (if a blog element on the page should show the same entries as this slider use this setting)', 'avia_framework' ) =>'enforce_duplicates'
  81.                        
  82.                             )
  83.                     )
  84.                     ),
  85.  
  86.                 array(
  87.                         "name"  => __("Title and Read More Button",'avia_framework' ),
  88.                         "desc"  => __("Choose if you want to only display the post title or title and a call to action button",'avia_framework' ),
  89.                         "id"    => "contents",
  90.                         "type"  => "select",
  91.                         "std"   => "title",
  92.                         "subtype" => array(
  93.                             __('Only Title',  'avia_framework' ) =>'title',
  94.                             __('Title + Read More Button',  'avia_framework' ) =>'title_read_more',
  95.                             __('Title + Excerpt + Read More Button',  'avia_framework' ) =>'title_excerpt_read_more',
  96.                             )
  97.                     ),
  98.  
  99.                 array(
  100.                             "name"  => __("Slider Width/Height Ratio", 'avia_framework' ),
  101.                             "desc"  => __("The slider will always stretch the full available width. Here you can enter the coresponding height (eg: 4:3, 16:9) or a fixed height in px (eg: 300px)", 'avia_framework' ),
  102.                             "id"    => "slider_size",
  103.                             "type"  => "input",
  104.                             "std"   => "16:9",
  105.                     ),             
  106.  
  107.  
  108.                 array(
  109.                             "name"  => __("Preview Image Size", 'avia_framework' ),
  110.                             "desc"  => __("Set the image size of the preview images", 'avia_framework' ),
  111.                             "id"    => "preview_mode",
  112.                             "type"  => "select",
  113.                             "std"   => "auto",
  114.                             "subtype" => array(
  115.                            
  116.                             __('Set the preview image size automatically based on slider height','avia_framework' ) =>'auto',
  117.                             __('Choose the preview image size manually (select thumbnail size)','avia_framework' ) =>'custom')),
  118.  
  119.                 array(
  120.                             "name"  => __("Select custom preview image size", 'avia_framework' ),
  121.                             "desc"  => __("Choose image size for Preview Image", 'avia_framework' ),
  122.                             "id"    => "image_size",
  123.                             "type"  => "select",
  124.                             "required"  => array('preview_mode','equals','custom'),
  125.                             "std"   => "portfolio",
  126.                             "subtype" =>  AviaHelper::get_registered_image_sizes(array('logo'))
  127.                             ),
  128.                
  129.  
  130.                 array( 
  131.                         "name"  => __("Slideshow control styling?",'avia_framework' ),
  132.                         "desc"  => __("Here you can select if and how to display the slideshow controls",'avia_framework' ),
  133.                         "id"    => "control_layout",
  134.                         "type"  => "select",
  135.                         "std"   => "",
  136.                         "subtype" => array(__('Default','avia_framework' ) =>'av-control-default',__('Minimal White','avia_framework' ) =>'av-control-minimal', __('Minimal Black','avia_framework' ) =>'av-control-minimal av-control-minimal-dark',__('Hidden','avia_framework' ) =>'av-control-hidden')),   
  137.                    
  138.                    
  139.                    
  140.                 array(
  141.                 "type"  => "close_div",
  142.                 'nodescription' => true
  143.                     ),
  144.                
  145.                 array(
  146.                         "type"  => "tab",
  147.                         "name"  => __("Slider Transitions",'avia_framework' ),
  148.                         'nodescription' => true
  149.                     ),
  150.                    
  151.                 array(
  152.                             "name"  => __("Transition", 'avia_framework' ),
  153.                             "desc"  => __("Choose the transition for your Slider.", 'avia_framework' ),
  154.                             "id"    => "animation",
  155.                             "type"  => "select",
  156.                             "std"   => "fade",
  157.                             "subtype" => array(__('Slide','avia_framework' ) =>'slide',__('Fade','avia_framework' ) =>'fade'),
  158.                             ),
  159.  
  160.                
  161.                
  162.                 array(
  163.                         "name"  => __("Autorotation active?",'avia_framework' ),
  164.                         "desc"  => __("Check if the slideshow should rotate by default",'avia_framework' ),
  165.                         "id"    => "autoplay",
  166.                         "type"  => "select",
  167.                         "std"   => "no",
  168.                         "subtype" => array(__('Yes','avia_framework' ) =>'yes',__('No','avia_framework' ) =>'no')),
  169.  
  170.                 array(
  171.                     "name"  => __("Slideshow autorotation duration",'avia_framework' ),
  172.                     "desc"  => __("Slideshow will rotate every X seconds",'avia_framework' ),
  173.                     "id"    => "interval",
  174.                     "type"  => "select",
  175.                     "std"   => "5",
  176.                     "required"  => array('autoplay','equals','yes'),
  177.                     "subtype" =>
  178.                     array('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')),
  179.                    
  180.                 array(
  181.                 "type"  => "close_div",
  182.                 'nodescription' => true
  183.                 ), 
  184.                
  185.                
  186.                 array(
  187.                         "type"  => "tab",
  188.                         "name"  => __("Slide Overlay",'avia_framework' ),
  189.                         'nodescription' => true
  190.                     ), 
  191.                    
  192.                
  193.                
  194.                 array( 
  195.                                         "name"  => __("Enable Overlay?", 'avia_framework' ),
  196.                                         "desc"  => __("Check if you want to display a transparent color and/or pattern overlay above your slideshow image/video", 'avia_framework' ),
  197.                                         "id"    => "overlay_enable",
  198.                                         "std"   => "",
  199.                                         "type"  => "checkbox"),
  200.                                
  201.                                  array(
  202.                                     "name"  => __("Overlay Opacity",'avia_framework' ),
  203.                                     "desc"  => __("Set the opacity of your overlay: 0.1 is barely visible, 1.0 is opaque ", 'avia_framework' ),
  204.                                     "id"    => "overlay_opacity",
  205.                                     "type"  => "select",
  206.                                     "std"   => "0.5",
  207.                                     "required" => array('overlay_enable','not',''),
  208.                                     "subtype" => array(   __('0.1','avia_framework' )=>'0.1',
  209.                                                           __('0.2','avia_framework' )=>'0.2',
  210.                                                           __('0.3','avia_framework' )=>'0.3',
  211.                                                           __('0.4','avia_framework' )=>'0.4',
  212.                                                           __('0.5','avia_framework' )=>'0.5',
  213.                                                           __('0.6','avia_framework' )=>'0.6',
  214.                                                           __('0.7','avia_framework' )=>'0.7',
  215.                                                           __('0.8','avia_framework' )=>'0.8',
  216.                                                           __('0.9','avia_framework' )=>'0.9',
  217.                                                           __('1.0','avia_framework' )=>'1',
  218.                                                           )
  219.                                     ),
  220.                                    
  221.                                 array(
  222.                                         "name"  => __("Overlay Color", 'avia_framework' ),
  223.                                         "desc"  => __("Select a custom  color for your overlay here. Leave empty if you want no color overlay", 'avia_framework' ),
  224.                                         "id"    => "overlay_color",
  225.                                         "type"  => "colorpicker",
  226.                                         "required" => array('overlay_enable','not',''),
  227.                                         "std"   => "",
  228.                                     ),
  229.                                
  230.                                 array(
  231.                                     "required" => array('overlay_enable','not',''),
  232.                                     "id"    => "overlay_pattern",
  233.                                     "name"  => __("Background Image", 'avia_framework'),
  234.                                     "desc"  => __("Select an existing or upload a new background image", 'avia_framework'),
  235.                                     "type"  => "select",
  236.                                     "subtype" => array(__('No Background Image', 'avia_framework')=>'',__('Upload custom image', 'avia_framework')=>'custom'),
  237.                                     "std"   => "",
  238.                                     "folder" => "images/background-images/",
  239.                                     "folderlabel" => "",
  240.                                     "group" => "Select predefined pattern",
  241.                                     "exclude" => array('fullsize-', 'gradient')
  242.                                 ),
  243.                                
  244.                                
  245.                                 array(
  246.                                         "name"  => __("Custom Pattern",'avia_framework' ),
  247.                                         "desc"  => __("Upload your own seamless pattern",'avia_framework' ),
  248.                                         "id"    => "overlay_custom_pattern",
  249.                                         "type"  => "image",
  250.                                         "fetch" => "url",
  251.                                         "secondary_img"=>true,
  252.                                         "required" => array('overlay_pattern','equals','custom'),
  253.                                         "title" => __("Insert Pattern",'avia_framework' ),
  254.                                         "button" => __("Insert",'avia_framework' ),
  255.                                         "std"   => ""),
  256.                
  257.                
  258.                    
  259.                    
  260.                    
  261.                 array(
  262.                 "type"  => "close_div",
  263.                 'nodescription' => true
  264.                 ),
  265.  
  266.                 array(
  267.                 "type"  => "close_div",
  268.                 'nodescription' => true
  269.                 ),
  270.  
  271.                 );
  272.  
  273.  
  274.                 if(current_theme_supports('add_avia_builder_post_type_option'))
  275.                 {
  276.                     $element = array(
  277.                         "name"  => __("Select Post Type", 'avia_framework' ),
  278.                         "desc"  => __("Select which post types should be used. Note that your taxonomy will be ignored if you do not select an assign post type.
  279.                                      If yo don't select post type all registered post types will be used", 'avia_framework' ),
  280.                         "id"    => "post_type",
  281.                         "type"  => "select",
  282.                         "multiple"  => 6,
  283.                         "std"   => "",
  284.                         "subtype" => AviaHtmlHelper::get_registered_post_type_array()
  285.                     );
  286.  
  287.                     array_unshift($this->elements, $element);
  288.                 }
  289.         }
  290.  
  291.         /**
  292.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  293.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  294.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  295.          *
  296.          *
  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_element($params)
  301.             {  
  302.                 $params['innerHtml'] = "<img src='".$this->config['icon']."' title='".$this->config['name']."' />";
  303.                 $params['innerHtml'].= "<div class='avia-element-label'>".$this->config['name']."</div>";
  304.                
  305.                 $params['innerHtml'].= "<div class='avia-flex-element'>";
  306.                 $params['innerHtml'].=      __('This element will stretch across the whole screen by default.','avia_framework')."<br/>";
  307.                 $params['innerHtml'].=      __('If you put it inside a color section or column it will only take up the available space','avia_framework');
  308.                 $params['innerHtml'].= "    <div class='avia-flex-element-2nd'>".__('Currently:','avia_framework');
  309.                 $params['innerHtml'].= "    <span class='avia-flex-element-stretched'>&laquo; ".__('Stretch fullwidth','avia_framework')." &raquo;</span>";
  310.                 $params['innerHtml'].= "    <span class='avia-flex-element-content'>| ".__('Adjust to content width','avia_framework')." |</span>";
  311.                 $params['innerHtml'].= "</div></div>";
  312.                
  313.                 return $params;
  314.             }
  315.  
  316.  
  317.  
  318.         /**
  319.          * Frontend Shortcode Handler
  320.          *
  321.          * @param array $atts array of attributes
  322.          * @param string $content text within enclosing form of shortcode element
  323.          * @param string $shortcodename the shortcode found, when == callback name
  324.          * @return string $output returns the modified html string
  325.          */
  326.         function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
  327.         {
  328.             if(isset($atts['link']))
  329.             {
  330.                 $atts['link'] = explode(',', $atts['link'], 2 );
  331.                 $atts['taxonomy'] = $atts['link'][0];
  332.  
  333.                 if(isset($atts['link'][1]))
  334.                 {
  335.                     $atts['categories'] = $atts['link'][1];
  336.                 }
  337.             }
  338.  
  339.             // $atts['class'] = $meta['el_class'];
  340.            
  341.            
  342.            
  343.             extract($atts);
  344.             $output     = "";
  345.             $class = "";
  346.            
  347.            
  348.             $skipSecond = false;
  349.             avia_sc_featureimage_slider::$slide_count++;
  350.            
  351.             $params['class'] = "avia-featureimage-slider-wrap main_color  ".$meta['el_class'].$class;
  352.             $params['open_structure'] = false;
  353.  
  354.             $params['custom_markup'] = $atts['custom_markup'] = $meta['custom_markup'];
  355.            
  356.             //we dont need a closing structure if the element is the first one or if a previous fullwidth element was displayed before
  357.             if($meta['index'] == 0) $params['close'] = false;
  358.             if(!empty($meta['siblings']['prev']['tag']) && in_array($meta['siblings']['prev']['tag'], AviaBuilder::$full_el_no_section )) $params['close'] = false;
  359.            
  360.             if($meta['index'] != 0) $params['class'] .= " slider-not-first";
  361.            
  362.             $params['id'] = "avia_feature_image_slider_".avia_sc_slider_full::$slide_count;
  363.            
  364.            
  365.             $slider  = new avia_feature_image_slider($atts);
  366.             $slider->query_entries();
  367.             $slide_html = $slider->html();
  368.            
  369.            
  370.             //if the element is nested within a section or a column dont create the section shortcode around it
  371.             if(!ShortcodeHelper::is_top_level()) return $slide_html;
  372.            
  373.             // $slide_html  = "<div class='container'>" . $slide_html . "</div>";
  374.            
  375.             $output .=  avia_new_section($params);
  376.             $output .=  $slide_html;
  377.             $output .= "</div>"; //close section
  378.            
  379.            
  380.             //if the next tag is a section dont create a new section from this shortcode
  381.             if(!empty($meta['siblings']['next']['tag']) && in_array($meta['siblings']['next']['tag'],  AviaBuilder::$full_el ))
  382.             {
  383.                 $skipSecond = true;
  384.             }
  385.  
  386.             //if there is no next element dont create a new section.
  387.             if(empty($meta['siblings']['next']['tag']))
  388.             {
  389.                 $skipSecond = true;
  390.             }
  391.            
  392.             if(empty($skipSecond)) {
  393.            
  394.             $output .= avia_new_section(array('close'=>false, 'id' => "after_full_slider_".avia_sc_slider_full::$slide_count));
  395.            
  396.             }
  397.            
  398.             return $output;
  399.    
  400.         }
  401.  
  402.     }
  403. }
  404.  
  405.  
  406. if ( !class_exists( 'avia_feature_image_slider' ) )
  407. {
  408.     class avia_feature_image_slider
  409.     {
  410.         static  $slider = 0;
  411.         protected $slide_count = 0;
  412.         protected $atts;
  413.         protected $entries;
  414.  
  415.         function __construct($atts = array())
  416.         {
  417.             $this->atts = shortcode_atts(array( 'items'         => '16',
  418.                                                 'taxonomy'      => 'category',
  419.                                                 'post_type'     => get_post_types(),
  420.                                                 'contents'      => 'title',
  421.                                                 'preview_mode'  => 'auto',
  422.                                                 'image_size'    => 'portfolio',
  423.                                                 'autoplay'      => 'no',
  424.                                                 'animation'     => 'fade',
  425.                                                 'paginate'      => 'no',
  426.                                                 'use_main_query_pagination' => 'no',
  427.                                                 'interval'      => 5,
  428.                                                 'class'         => '',
  429.                                                 'categories'    => array(),
  430.                                                 'custom_query'  => array(),
  431.                                                 'lightbox_size' => 'large',
  432.                                                 'offset'        => 0,
  433.                                                 'bg_slider'     =>true,
  434.                                                 'keep_pading'   => true,
  435.                                                 'custom_markup' => '',
  436.                                                 'slider_size'   => '16:9',
  437.                                                 'control_layout'    => '',
  438.                                                 'overlay_enable'    => '',
  439.                                                 'overlay_opacity'   => '',
  440.                                                 'overlay_color'     => '',
  441.                                                 'overlay_pattern'   => '',
  442.                                                 'overlay_custom_pattern' => '',
  443.                                                
  444.                                                 ), $atts, 'av_feature_image_slider');
  445.                                                
  446.            if($this->atts['autoplay'] == "no")  
  447.             $this->atts['autoplay'] = false;                                   
  448.                                                
  449.         }
  450.  
  451.         public function html()
  452.         {
  453.             $html       = "";
  454.             $counter    = 0;
  455.             $style      = "";
  456.             $extraClass = "";
  457.             $style      = "";
  458.             avia_feature_image_slider::$slider++;
  459.            
  460.             if($this->slide_count == 0) return $html;
  461.            
  462.             if(!empty($this->atts['default-height']))
  463.             {
  464.                 $style = "style='padding-bottom: {{av-default-heightvar}}%;'";
  465.                 $extraClass .= " av-default-height-applied";
  466.             }
  467.            
  468.             if(strpos( $this->atts['slider_size'] , ":") !== false)
  469.             {
  470.                 $ratio = explode(':',trim($this->atts['slider_size']));
  471.                 if(empty($ratio[0])) $ratio[0] = 16;
  472.                 if(empty($ratio[1])) $ratio[1] = 9;
  473.                 $final_ratio = ((int) $ratio[0] / (int) $ratio[1]);
  474.                 $def_height = "padding-bottom:" . (100/$final_ratio). "%";
  475.                
  476.             }
  477.             else
  478.             {
  479.                 $def_height  = (int) $this->atts['slider_size'];
  480.                 $def_height  = "height: {$def_height}px";
  481.             }
  482.            
  483.            
  484.             $style = "style='{$def_height}'";
  485.             if(!empty($this->atts['control_layout'])) $extraClass .= " ".$this->atts['control_layout'];
  486.            
  487.             $markup = avia_markup_helper(array('context' => 'image','echo'=>false, 'custom_markup'=>$this->atts['custom_markup']));
  488.  
  489.             $data = AviaHelper::create_data_string($this->atts);
  490.  
  491.             $html .= "<div {$data} class='avia-slideshow avia-featureimage-slideshow avia-animated-caption avia-slideshow-".avia_sc_featureimage_slider::$slide_count." {$extraClass} avia-slideshow-".$this->atts['image_size']."  ".$this->atts['class']." avia-".$this->atts['animation']."-slider ' $markup>";
  492.            
  493.            
  494.             $html .= "<ul class='avia-slideshow-inner avia-slideshow-fixed-height' {$style}>";
  495.  
  496.             $html .= $this->default_slide();
  497.  
  498.             $html .= "</ul>";
  499.  
  500.             if($this->slide_count > 1)
  501.             {
  502.                 $html .= $this->slide_navigation_arrows();
  503.                 $html .= $this->slide_navigation_dots();
  504.             }
  505.            
  506.            
  507.             if(!empty($this->atts['caption_override'])) $html .= $this->atts['caption_override'];
  508.            
  509.  
  510.             $html .= "</div>";
  511.            
  512.             if(!empty($this->atts['default-height']))
  513.             {
  514.                 $html = str_replace('{{av-default-heightvar}}', $this->atts['default-height'], $html);
  515.             }
  516.            
  517.             return $html;
  518.         }
  519.        
  520.         //function that renders the usual slides. use when we didnt use sub-shorcodes to define the images but ids
  521.         protected function default_slide()
  522.         {
  523.             $html = "";
  524.             $counter = 0;
  525.            
  526.            
  527.                
  528.  
  529.             $markup_url = avia_markup_helper(array('context' => 'image_url','echo'=>false, 'custom_markup'=>$this->atts['custom_markup']));
  530.  
  531.             foreach ($this->entries->posts as $slide)
  532.             {
  533.                     $counter ++;
  534.                     $thumb_id = get_post_thumbnail_id( $slide->ID );
  535.                     $slide_class = "";
  536.                    
  537.                     $img     = wp_get_attachment_image_src($thumb_id, $this->atts['image_size']);
  538.                     $link    = get_permalink( $slide->ID );
  539.                     $title   = get_the_title( $slide->ID );
  540.                    
  541.                     $caption  = "";
  542.                     $caption .= ' <div class="caption_fullwidth av-slideshow-caption caption_center">';
  543.                     $caption .= ' <div class="container caption_container">';
  544.                     $caption .= ' <div class="slideshow_caption">';
  545.                     $caption .= ' <div class="slideshow_inner_caption">';
  546.                     $caption .= ' <div class="slideshow_align_caption">';
  547.  
  548.                     /*Modified Section: Nikko*/
  549.                     $slide_cats = get_the_category( $slide->ID );
  550.                     $separator = ', ';
  551.                     $slide_cat_output = '';
  552.                     if ( ! empty( $slide_cats ) ) {
  553.                         $caption .= '<div class="custom_slideshow_category">';
  554.                         foreach( $slide_cats as $slide_cat ) {
  555.                             $slide_cat_output .= '<a href="' . esc_url( get_category_link( $slide_cat->term_id ) ) . '" alt="' . esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $slide_cat->name ) ) . '">' . esc_html( $slide_cat->name ) . '</a>' . $separator;
  556.                         }
  557.                         $caption .= trim( $slide_cat_output, $separator );
  558.                         $caption .= '</div>';
  559.                     }
  560.                     /*End Modification*/
  561.  
  562.                     $caption .= ' <h2 class="avia-caption-title"><a href="'.$link.'">'.$title.'</a></h2>';
  563.            
  564.                     if(strpos($this->atts['contents'], 'excerpt')  !== false)
  565.                     {
  566.                         $excerpt = !empty($slide->post_excerpt) ? $slide->post_excerpt : avia_backend_truncate($slide->post_content, apply_filters( 'avf_feature_image_slider_excerpt_length' , 320) , apply_filters( 'avf_feature_image_slider_excerpt_delimiter' , " "), "…", true, '');
  567.                        
  568.                         if(!empty($excerpt)){
  569.                             $caption .= ' <div class="avia-caption-content " itemprop="description">';
  570.                             $caption .= wpautop($excerpt);
  571.                             $caption .= ' </div>';
  572.                         }
  573.                     }
  574.        
  575.                    
  576.                     if(strpos($this->atts['contents'], 'read_more')  !== false)
  577.                     {
  578.                         $caption .= ' <a href="'.$link.'" class="avia-slideshow-button avia-button avia-color-light " data-duration="800" data-easing="easeInOutQuad">'.__('Read more', 'avia_framework').'</a>';
  579.                    
  580.                     }
  581.                     $caption .= ' </div>';
  582.                     $caption .= ' </div>';
  583.                     $caption .= ' </div>';
  584.                     $caption .= ' </div>';
  585.                     $caption .= $this->create_overlay();
  586.                     $caption .= ' </div>';
  587.                    
  588.                     $slide_data = "data-img-url='".$img[0]."'";
  589.                    
  590.                     if(empty($img)) $slide_class .= " av-no-image-slider";
  591.                    
  592.                     $html .= "<li {$slide_data} class='slide-{$counter} {$slide_class} slide-id-".$slide->ID."'>";
  593.                     $html .= $caption;
  594.                     $html .= "</li>";
  595.             }
  596.  
  597.             return $html;
  598.         }
  599.        
  600.         protected function slide_navigation_dots()
  601.         {
  602.             $html   = "";
  603.             $html  .= "<div class='avia-slideshow-dots avia-slideshow-controls'>";
  604.             $active = "active";
  605.  
  606.             for($i = 1; $i <= $this->slide_count; $i++)
  607.             {
  608.                 $html .= "<a href='#{$i}' class='goto-slide {$active}' >{$i}</a>";
  609.                 $active = "";
  610.             }
  611.  
  612.             $html .= "</div>";
  613.  
  614.             return $html;
  615.         }
  616.        
  617.  
  618.         protected function slide_navigation_arrows()
  619.         {
  620.             $html  = "";
  621.             $html .= "<div class='avia-slideshow-arrows avia-slideshow-controls'>";
  622.             $html .=    "<a href='#prev' class='prev-slide' ".av_icon_string('prev_big').">".__('Previous','avia_framework' )."</a>";
  623.             $html .=    "<a href='#next' class='next-slide' ".av_icon_string('next_big').">".__('Next','avia_framework' )."</a>";
  624.             $html .= "</div>";
  625.  
  626.             return $html;
  627.         }
  628.        
  629.         protected function create_overlay()
  630.         {
  631.             extract($this->atts);
  632.            
  633.             /*check/create overlay*/
  634.             $overlay = "";
  635.             if(!empty($overlay_enable))
  636.             {
  637.                 $overlay_src = "";
  638.                 $overlay = "opacity: {$overlay_opacity}; ";
  639.                 if(!empty($overlay_color)) $overlay .= "background-color: {$overlay_color}; ";
  640.                 if(!empty($overlay_pattern))
  641.                 {
  642.                     if($overlay_pattern == "custom")
  643.                     {
  644.                         $overlay_src = $overlay_custom_pattern;
  645.                     }
  646.                     else
  647.                     {
  648.                         $overlay_src = str_replace('{{AVIA_BASE_URL}}', AVIA_BASE_URL, $overlay_pattern);
  649.                     }
  650.                 }
  651.                
  652.                 if(!empty($overlay_src)) $overlay .= "background-image: url({$overlay_src}); background-repeat: repeat;";
  653.                 $overlay = "<div class='av-section-color-overlay' style='{$overlay}'></div>";
  654.             }
  655.            
  656.             return $overlay;
  657.         }
  658.  
  659.         //fetch new entries
  660.         public function query_entries($params = array())
  661.         {
  662.             global $avia_config;
  663.  
  664.             if(empty($params)) $params = $this->atts;
  665.  
  666.             if(empty($params['custom_query']))
  667.             {
  668.                 $query = array();
  669.  
  670.                 if(!empty($params['categories']))
  671.                 {
  672.                     //get the portfolio categories
  673.                     $terms  = explode(',', $params['categories']);
  674.                 }
  675.  
  676.                 $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : get_query_var( 'page' );
  677.                 if(!$page || $params['paginate'] == 'no') $page = 1;
  678.  
  679.                 //if we find no terms for the taxonomy fetch all taxonomy terms
  680.                 if(empty($terms[0]) || is_null($terms[0]) || $terms[0] === "null")
  681.                 {
  682.                     $terms = array();
  683.                     $allTax = get_terms( $params['taxonomy']);
  684.                     foreach($allTax as $tax)
  685.                     {
  686.                         $terms[] = $tax->term_id;
  687.                     }
  688.  
  689.                 }
  690.  
  691.                 if($params['offset'] == 'no_duplicates')
  692.                 {
  693.                     $params['offset'] = 0;
  694.                     $no_duplicates = true;
  695.                 }
  696.                
  697.                 if($params['offset'] == 'enforce_duplicates')
  698.                 {
  699.                     $params['offset'] = 0;
  700.                     $no_duplicates = false;
  701.                 }
  702.                
  703.                 if(empty($params['post_type'])) $params['post_type'] = get_post_types();
  704.                 if(is_string($params['post_type'])) $params['post_type'] = explode(',', $params['post_type']);
  705.  
  706.                 $query = array( 'orderby'   => 'date',
  707.                                 'order'     => 'DESC',
  708.                                 'paged'     => $page,
  709.                                 'post_type' => $params['post_type'],
  710.                                 'posts_per_page' => $params['items'],
  711.                                 'offset' => $params['offset'],
  712.                                 'post__not_in' => (!empty($no_duplicates)) ? $avia_config['posts_on_current_page'] : array(),
  713.                                 'tax_query' => array(   array(  'taxonomy'  => $params['taxonomy'],
  714.                                                                 'field'     => 'id',
  715.                                                                 'terms'     => $terms,
  716.                                                                 'operator'  => 'IN')));
  717.                                                                
  718.             }
  719.             else
  720.             {
  721.                 $query = $params['custom_query'];
  722.             }
  723.  
  724.  
  725.             $query = apply_filters('avia_feature_image_slider_query', $query, $params);
  726.  
  727.             $this->entries = new WP_Query( $query );
  728.            
  729.             $this->slide_count = count($this->entries->posts);
  730.            
  731.             // store the queried post ids in
  732.             if( $this->entries->have_posts() && $params['offset'] != 'enforce_duplicates')
  733.             {
  734.                 while( $this->entries->have_posts() )
  735.                 {
  736.                     $this->entries->the_post();
  737.                     $avia_config['posts_on_current_page'][] = get_the_ID();
  738.                 }
  739.             }
  740.  
  741.         }
  742.     }
  743. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement