Advertisement
Guenni007

postslider

Aug 6th, 2023 (edited)
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 45.23 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Post Slider
  4.  *
  5.  * Display a slideshow or grid of Post Entries
  6.  *
  7.  * Todo: test with layerslider elements. currently throws error bc layerslider is only included if layerslider element is detected which is not the case with the post/page element
  8.  *
  9.  * This class does not support post css files
  10.  * ==========================================
  11.  */
  12. if( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  13.  
  14.  
  15. if( ! class_exists( 'avia_sc_postslider', false ) )
  16. {
  17.     class avia_sc_postslider extends aviaShortcodeTemplate
  18.     {
  19.         /**
  20.          * Create the config array for the shortcode button
  21.          */
  22.         protected function shortcode_insert_button()
  23.         {
  24.             $this->config['version']        = '1.0';
  25.             $this->config['self_closing']   = 'yes';
  26.             $this->config['base_element']   = 'yes';
  27.  
  28.             $this->config['name']           = __( 'Post Slider', 'avia_framework' );
  29.             $this->config['tab']            = __( 'Content Elements', 'avia_framework' );
  30.             $this->config['icon']           = AviaBuilder::$path['imagesURL'] . 'sc-postslider.png';
  31.             $this->config['order']          = 30;
  32.             $this->config['target']         = 'avia-target-insert';
  33.             $this->config['shortcode']      = 'av_postslider';
  34.             $this->config['tooltip']        = __( 'Display a Slideshow of Post Entries', 'avia_framework' );
  35.             $this->config['drag-level']     = 3;
  36.             $this->config['disabling_allowed'] = true;
  37.             $this->config['id_name']        = 'id';
  38.             $this->config['id_show']        = 'yes';
  39.             $this->config['alb_desc_id']    = 'alb_description';
  40.         }
  41.  
  42.         protected function extra_assets()
  43.         {
  44.             $ver = Avia_Builder()->get_theme_version();
  45.             $min_js = avia_minify_extension( 'js' );
  46.             $min_css = avia_minify_extension( 'css' );
  47.  
  48.             //load css
  49.             wp_enqueue_style( 'avia-module-slideshow', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/slideshow/slideshow{$min_css}.css", array( 'avia-layout' ), $ver );
  50.             wp_enqueue_style( 'avia-module-postslider', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/postslider/postslider{$min_css}.css", array( 'avia-module-slideshow' ), $ver );
  51.  
  52.                 //load js
  53.             wp_enqueue_script( 'avia-module-slideshow', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/slideshow/slideshow{$min_js}.js", array( 'avia-shortcodes' ), $ver, true );
  54.         }
  55.  
  56.         /**
  57.          * Popup Elements
  58.          *
  59.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  60.          * opens a modal window that allows to edit the element properties
  61.          *
  62.          * @return void
  63.          */
  64.         protected function popup_elements()
  65.         {
  66.             $this->elements = array(
  67.  
  68.                 array(
  69.                         'type'  => 'tab_container',
  70.                         'nodescription' => true
  71.                     ),
  72.  
  73.                 array(
  74.                         'type'  => 'tab',
  75.                         'name'  => __( 'Content', 'avia_framework' ),
  76.                         'nodescription' => true
  77.                     ),
  78.  
  79.                     array(
  80.                             'type'          => 'template',
  81.                             'template_id'   => 'toggle_container',
  82.                             'templates_include' => array(
  83.                                                     $this->popup_key( 'content_slides' ),
  84.                                                     $this->popup_key( 'content_filter' ),
  85.                                                     $this->popup_key( 'content_excerpt' ),
  86.                                                 ),
  87.                             'nodescription' => true
  88.                         ),
  89.  
  90.                 array(
  91.                         'type'  => 'tab_close',
  92.                         'nodescription' => true
  93.                     ),
  94.  
  95.                 array(
  96.                         'type'  => 'tab',
  97.                         'name'  => __( 'Styling', 'avia_framework' ),
  98.                         'nodescription' => true
  99.                     ),
  100.  
  101.                     array(
  102.                             'type'          => 'template',
  103.                             'template_id'   => 'toggle_container',
  104.                             'templates_include' => array(
  105.                                                     $this->popup_key( 'styling_columns' ),
  106.                                                     $this->popup_key( 'styling_image' ),
  107.                                                     $this->popup_key( 'styling_navigation' )
  108.                                                 ),
  109.                             'nodescription' => true
  110.                         ),
  111.  
  112.                 array(
  113.                         'type'  => 'tab_close',
  114.                         'nodescription' => true
  115.                     ),
  116.  
  117.                 array(
  118.                         'type'  => 'tab',
  119.                         'name'  => __( 'Advanced', 'avia_framework' ),
  120.                         'nodescription' => true
  121.                     ),
  122.  
  123.                     array(
  124.                             'type'  => 'toggle_container',
  125.                             'nodescription' => true
  126.                         ),
  127.  
  128.                         array(
  129.                                 'type'          => 'template',
  130.                                 'template_id'   => $this->popup_key( 'advanced_animation_slider' ),
  131.                                 'nodescription' => true
  132.                             ),
  133.  
  134.                         array(
  135.                                 'type'          => 'template',
  136.                                 'template_id'   => 'lazy_loading_toggle',
  137.                                 'lockable'      => true
  138.                             ),
  139.  
  140.                         array(
  141.                                 'type'          => 'template',
  142.                                 'template_id'   => 'screen_options_toggle',
  143.                                 'lockable'      => true
  144.                             ),
  145.  
  146.                         array(
  147.                                 'type'          => 'template',
  148.                                 'template_id'   => 'developer_options_toggle',
  149.                                 'args'          => array( 'sc' => $this )
  150.                             ),
  151.  
  152.                     array(
  153.                             'type'  => 'toggle_container_close',
  154.                             'nodescription' => true
  155.                         ),
  156.  
  157.                 array(
  158.                         'type'  => 'tab_close',
  159.                         'nodescription' => true
  160.                     ),
  161.  
  162.                 array(
  163.                         'type'          => 'template',
  164.                         'template_id'   => 'element_template_selection_tab',
  165.                         'args'          => array( 'sc' => $this )
  166.                     ),
  167.  
  168.                 array(
  169.                         'type'  => 'tab_container_close',
  170.                         'nodescription' => true
  171.                     )
  172.  
  173.                 );
  174.  
  175.         }
  176.  
  177.         /**
  178.          * Create and register templates for easier maintainance
  179.          *
  180.          * @since 4.6.4
  181.          */
  182.         protected function register_dynamic_templates()
  183.         {
  184.  
  185.             /**
  186.              * Content Tab
  187.              * ===========
  188.              */
  189.  
  190.             $c = array(
  191.                         array(
  192.                             'name'      => __( 'Which Entries Should Be Used', 'avia_framework' ),
  193.                             'desc'      => __( 'Select which entries should be displayed by selecting a taxonomy', 'avia_framework' ),
  194.                             'id'        => 'link',
  195.                             'type'      => 'linkpicker',
  196.                             'fetchTMPL' => true,
  197.                             'multiple'  => 6,
  198.                             'std'       => 'category',
  199.                             'lockable'  => true,
  200.                             'subtype'   => array( __( 'Display Entries from:', 'avia_framework' ) => 'taxonomy' )
  201.                         ),
  202.  
  203.                         array(
  204.                             'name'      => __( 'Multiple Categories/Terms Relation', 'avia_framework' ),
  205.                             'desc'      => __( 'Select to use an OR or AND relation. In AND an entry must be in all selected categories/terms to be displayed. Defaults to OR', 'avia_framework' ),
  206.                             'id'        => 'term_rel',
  207.                             'type'      => 'select',
  208.                             'std'       => '',
  209.                             'lockable'  => true,
  210.                             'subtype'   => array(
  211.                                                 __( 'OR', 'avia_framework' )    => '',
  212.                                                 __( 'AND', 'avia_framework' )   => 'AND'
  213.                                             )
  214.                         )
  215.  
  216.                 );
  217.  
  218.             if( current_theme_supports( 'add_avia_builder_post_type_option' ) )
  219.             {
  220.                 $element = array(
  221.                                 'type'          => 'template',
  222.                                 'template_id'   => 'avia_builder_post_type_option',
  223.                                 'lockable'      => true,
  224.                             );
  225.  
  226.                 array_unshift( $c, $element );
  227.             }
  228.  
  229.             $template = array(
  230.                             array(
  231.                                 'type'          => 'template',
  232.                                 'template_id'   => 'toggle',
  233.                                 'title'         => __( 'Entries', 'avia_framework' ),
  234.                                 'content'       => $c
  235.                             ),
  236.                     );
  237.  
  238.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_slides' ), $template );
  239.  
  240.             $c = array(
  241.                         array(
  242.                             'type'          => 'template',
  243.                             'template_id'   => 'wc_options_non_products',
  244.                             'lockable'      => true
  245.                         ),
  246.  
  247.  
  248.                         array(
  249.                             'type'          => 'template',
  250.                             'template_id'   => 'date_query',
  251.                             'lockable'      => true,
  252.                             'period'        => true
  253.                         ),
  254.  
  255.                         array(
  256.                             'name'      => __( 'Entry Number', 'avia_framework' ),
  257.                             'desc'      => __( 'How many items should be displayed?', 'avia_framework' ),
  258.                             'id'        => 'items',
  259.                             'type'      => 'select',
  260.                             'std'       => '9',
  261.                             'lockable'  => true,
  262.                             'subtype'   => AviaHtmlHelper::number_array( 1, 100, 1, array( 'All' => '-1' ) )
  263.                         ),
  264.  
  265.                         array(
  266.                             'name'      => __( 'Offset Number', 'avia_framework' ),
  267.                             '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 post slider element.', 'avia_framework' ),
  268.                             'id'        => 'offset',
  269.                             'type'      => 'select',
  270.                             'std'       => '0',
  271.                             'lockable'  => true,
  272.                             'subtype'   => AviaHtmlHelper::number_array( 1, 100, 1, array( __( 'Deactivate offset', 'avia_framework') => '0', __( 'Do not allow duplicate posts on the entire page (set offset automatically)', 'avia_framework' ) => 'no_duplicates' ) )
  273.                         ),
  274.  
  275.                         array(
  276.                             'type'          => 'template',
  277.                             'template_id'   => 'page_element_filter',
  278.                             'lockable'      => true
  279.                         )
  280.                 );
  281.  
  282.             $template = array(
  283.                             array(
  284.                                 'type'          => 'template',
  285.                                 'template_id'   => 'toggle',
  286.                                 'title'         => __( 'Filters', 'avia_framework' ),
  287.                                 'content'       => $c
  288.                             ),
  289.                     );
  290.  
  291.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_filter' ), $template );
  292.  
  293.             $c = array(
  294.                         array(
  295.                             'name'      => __( 'Slide Content', 'avia_framework' ),
  296.                             'desc'      => __( 'Select what information you want to display', 'avia_framework' ),
  297.                             'id'        => 'contents',
  298.                             'type'      => 'select',
  299.                             'std'       => 'excerpt',
  300.                             'lockable'  => true,
  301.                             'subtype'   => array(
  302.                                                 __( 'Title and Excerpt', 'avia_framework' )                 => 'excerpt',
  303.                                                 __( 'Title, Excerpt and Read More Link', 'avia_framework' ) => 'excerpt_read_more',
  304.                                                 __( 'Only Title', 'avia_framework' )                        => 'title',
  305.                                                 __( 'Title and Read More Link', 'avia_framework' )          => 'title_read_more',
  306.                                                 __( 'Only Excerpt', 'avia_framework' )                      => 'only_excerpt',
  307.                                                 __( 'Excerpt and Read More Link', 'avia_framework' )        => 'only_excerpt_read_more',
  308.                                                 __( 'No Title, no Excerpt', 'avia_framework' )              => 'no'
  309.                                             )
  310.                         ),
  311.  
  312.                 );
  313.  
  314.             $template = array(
  315.                             array(
  316.                                 'type'          => 'template',
  317.                                 'template_id'   => 'toggle',
  318.                                 'title'         => __( 'Content', 'avia_framework' ),
  319.                                 'content'       => $c
  320.                             ),
  321.                     );
  322.  
  323.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_excerpt' ), $template );
  324.  
  325.  
  326.             /**
  327.              * Styling Tab
  328.              * ===========
  329.              */
  330.  
  331.             $c = array(
  332.                         array(
  333.                             'name'      => __( 'Columns', 'avia_framework' ),
  334.                             'desc'      => __( 'How many columns should be displayed?', 'avia_framework' ),
  335.                             'id'        => 'columns',
  336.                             'type'      => 'select',
  337.                             'std'       => '3',
  338.                             'lockable'  => true,
  339.                             'subtype'   => array(
  340.                                                 __( '1 Columns', 'avia_framework' ) => '1',
  341.                                                 __( '2 Columns', 'avia_framework' ) => '2',
  342.                                                 __( '3 Columns', 'avia_framework' ) => '3',
  343.                                                 __( '4 Columns', 'avia_framework' ) => '4',
  344.                                                 __( '5 Columns', 'avia_framework' ) => '5',
  345.                                             )
  346.                         )
  347.  
  348.                 );
  349.  
  350.             $template = array(
  351.                             array(
  352.                                 'type'          => 'template',
  353.                                 'template_id'   => 'toggle',
  354.                                 'title'         => __( 'Columns', 'avia_framework' ),
  355.                                 'content'       => $c
  356.                             ),
  357.                     );
  358.  
  359.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_columns' ), $template );
  360.  
  361.             $c = array(
  362.                         array(
  363.                             'name'      => __( 'Preview Image Size', 'avia_framework' ),
  364.                             'desc'      => __( 'Set the image size of the preview images', 'avia_framework' ),
  365.                             'id'        => 'preview_mode',
  366.                             'type'      => 'select',
  367.                             'std'       => 'auto',
  368.                             'lockable'  => true,
  369.                             'subtype'   => array(
  370.                                                 __( 'Set the preview image size automatically based on column width', 'avia_framework' )    => 'auto',
  371.                                                 __( 'Choose the preview image size manually (select thumbnail size)', 'avia_framework' )    => 'custom'
  372.                                             )
  373.                         ),
  374.  
  375.                         array(
  376.                             'name'      => __( 'Select custom preview image size', 'avia_framework' ),
  377.                             'desc'      => __( 'Choose image size for Preview Image', 'avia_framework' ),
  378.                             'id'        => 'image_size',
  379.                             'type'      => 'select',
  380.                             'std'       => 'portfolio',
  381.                             'lockable'  => true,
  382.                             'required'  => array( 'preview_mode', 'equals', 'custom' ),
  383.                             'subtype'   =>  AviaHelper::get_registered_image_sizes( array( 'logo' ) )
  384.                         )
  385.                 );
  386.  
  387.             $template = array(
  388.                             array(
  389.                                 'type'          => 'template',
  390.                                 'template_id'   => 'toggle',
  391.                                 'title'         => __( 'Preview Image', 'avia_framework' ),
  392.                                 'content'       => $c
  393.                             ),
  394.                     );
  395.  
  396.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_image' ), $template );
  397.  
  398.  
  399.             $c = array(
  400.  
  401.                         array(
  402.                             'type'          => 'template',
  403.                             'template_id'   => 'slideshow_controls',
  404.                             'std_nav'       => 'av-navigate-arrows',
  405.                             'lockable'      => true
  406.                         )
  407.  
  408.                 );
  409.  
  410.             $template = array(
  411.                             array(
  412.                                 'type'          => 'template',
  413.                                 'template_id'   => 'toggle',
  414.                                 'title'         => __( 'Navigation Controls', 'avia_framework' ),
  415.                                 'content'       => $c
  416.                             ),
  417.                     );
  418.  
  419.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_navigation' ), $template );
  420.  
  421.             /**
  422.              * Advanced Tab
  423.              * ===========
  424.              */
  425.  
  426.             $c = array(
  427. /*
  428.                         array(
  429.                             'name'      => __( 'Post Slider Transition', 'avia_framework' ),
  430.                             'desc'      => __( 'Choose the transition for your Post Slider.', 'avia_framework' ),
  431.                             'id'        => 'animation',
  432.                             'type'      => 'select',
  433.                             'std'       => 'fade',
  434.                             'subtype'   => array(
  435.                                                 __( 'Slide', 'avia_framework' ) => 'slide',
  436.                                                 __( 'Fade', 'avia_framework' )  => 'fade'
  437.                                             ),
  438.                         ),
  439. */
  440.  
  441.                         array(
  442.                             'type'          => 'template',
  443.                             'template_id'   => 'slideshow_rotation',
  444.                             'select_vals'   => 'yes,no',
  445.                             'stop_id'       => 'autoplay_stopper',
  446.                             'lockable'      => true
  447.                         )
  448.  
  449.                 );
  450.  
  451.             $template = array(
  452.                             array(
  453.                                 'type'          => 'template',
  454.                                 'template_id'   => 'toggle',
  455.                                 'title'         => __( 'Slider Animation', 'avia_framework' ),
  456.                                 'content'       => $c
  457.                             ),
  458.                     );
  459.  
  460.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_animation_slider' ), $template );
  461.  
  462.         }
  463.  
  464.         /**
  465.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  466.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  467.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  468.          *
  469.          * @param array $params         holds the default values for $content and $args.
  470.          * @return array                usually holds an innerHtml key that holds item specific markup.
  471.          */
  472.         public function editor_element( $params )
  473.         {
  474.             $params = parent::editor_element( $params );
  475.             $params['content'] = null; //remove to allow content elements
  476.  
  477.             return $params;
  478.         }
  479.  
  480.         /**
  481.          * Frontend Shortcode Handler
  482.          *
  483.          * @param array $atts array of attributes
  484.          * @param string $content text within enclosing form of shortcode element
  485.          * @param string $shortcodename the shortcode found, when == callback name
  486.          * @return string $output returns the modified html string
  487.          */
  488.         public function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
  489.         {
  490.             $default = avia_post_slider::get_defaults();
  491.  
  492.             $locked = array();
  493.             Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content );
  494.             Avia_Element_Templates()->add_template_class( $meta, $atts, $default );
  495.  
  496.             $screen_sizes = AviaHelper::av_mobile_sizes( $atts );
  497.  
  498.             if( isset( $atts['img_scrset'] ) && 'disabled' == $atts['img_scrset'] )
  499.             {
  500.                 Av_Responsive_Images()->force_disable( 'disabled' );
  501.             }
  502.  
  503.             if( isset( $atts['link'] ) )
  504.             {
  505.                 $atts['link'] = explode(',', $atts['link'], 2 );
  506.                 $atts['taxonomy'] = $atts['link'][0];
  507.  
  508.                 if( isset( $atts['link'][1] ) )
  509.                 {
  510.                     $atts['categories'] = $atts['link'][1];
  511.                 }
  512.             }
  513.  
  514.             $atts['class'] = $meta['el_class'];
  515.             $atts['el_id'] = $meta['custom_el_id'];
  516.  
  517.             $atts = array_merge( $atts, $screen_sizes );
  518.  
  519.             /**
  520.              * @since 4.5.5
  521.              * @return array
  522.              */
  523.             $atts = apply_filters( 'avf_post_slider_args', $atts, $this->config['shortcode'], $this );
  524.  
  525.             $slider = new avia_post_slider( $atts );
  526.             $slider->query_entries();
  527.             $html = $slider->html();
  528.  
  529.             Av_Responsive_Images()->force_disable( 'reset' );
  530.  
  531.             return $html;
  532.         }
  533.  
  534.     }
  535. }
  536.  
  537.  
  538. if ( ! class_exists( 'avia_post_slider', false ) )
  539. {
  540.     /**
  541.      * This class does not support post css files
  542.      * ==========================================
  543.      */
  544.     class avia_post_slider
  545.     {
  546.         /**
  547.          * @since < 4.0
  548.          * @var int
  549.          */
  550.         static public $slide = 0;
  551.  
  552.         /**
  553.          *
  554.          * @since < 4.0
  555.          * @var array
  556.          */
  557.         protected $atts;
  558.  
  559.         /**
  560.          *
  561.          * @since < 4.0
  562.          * @var WP_Query
  563.          */
  564.         protected $entries;
  565.  
  566.         /**
  567.          *
  568.          * @since 4.7.6.4
  569.          * @var int
  570.          */
  571.         protected $current_page;
  572.  
  573.         /**
  574.          * @since < 4.0
  575.          * @since 5.6           added to pass a WP_Query object
  576.          * @param array $atts
  577.          */
  578.         public function __construct( $atts = array() )
  579.         {
  580.             $this->entries = null;
  581.             $this->current_page = 1;
  582.  
  583.             if( isset( $atts['wp_query'] ) && $atts['wp_query'] instanceof WP_Query )
  584.             {
  585.                 $this->entries = $atts['wp_query'];
  586.                 $this->set_posts_on_current_page();
  587.             }
  588.  
  589.             $this->atts = shortcode_atts( avia_post_slider::get_defaults(), $atts, 'av_postslider' );
  590.  
  591.             if( ! in_array( $this->atts['slider_navigation'], array( 'av-navigate-arrows', 'av-navigate-dots', 'av-navigate-arrows av-navigate-dots' ) ) )
  592.             {
  593.                 $this->atts['slider_navigation'] = 'av-navigate-arrows';
  594.             }
  595.  
  596.             if( $this->atts['term_rel'] != 'AND' )
  597.             {
  598.                 $this->atts['term_rel'] = 'IN';
  599.             }
  600.         }
  601.  
  602.         /**
  603.          * @since 4.5.5
  604.          */
  605.         public function __destruct()
  606.         {
  607.             unset( $this->atts );
  608.             unset( $this->entries );
  609.         }
  610.  
  611.         /**
  612.          * Returns the defaults array
  613.          *
  614.          * @since 4.8
  615.          * @return array
  616.          */
  617.         static public function get_defaults()
  618.         {
  619.             $defaults = array(
  620.                             'type'                  => 'slider', // can also be used as grid
  621.                             'style'                 => '', //no_margin
  622.                             'columns'               => '4',
  623.                             'items'                 => '16',
  624.                             'taxonomy'              => 'category',
  625.                             'term_rel'              => 'IN',
  626.                             'control_layout'        => 'av-control-default',
  627.                             'slider_navigation'     => 'av-navigate-arrows',
  628.                             'nav_visibility_desktop'    => '',
  629.                             'wc_prod_visible'       => '',
  630.                             'wc_prod_hidden'        => '',
  631.                             'wc_prod_featured'      => '',
  632.                             'prod_order_by'         => '',
  633.                             'prod_order'            => '',
  634.                             'show_meta_data'        => '',      //  '' | 'always' | 'on_empty_title' | 'on_empty_content' (use filter to change)
  635.                             'post_type'             => get_post_types(),
  636.                             'contents'              => 'excerpt',
  637.                             'preview_mode'          => 'auto',
  638.                             'image_size'            => 'portfolio',
  639.                             'animation'             => 'fade',
  640.                             'transition_speed'      => '',
  641.                             'autoplay'              => 'no',
  642.                             'interval'              => 5,
  643.                             'autoplay_stopper'      => '',
  644.                             'manual_stopper'        => '',
  645.                             'paginate'              => 'no',
  646.                             'use_main_query_pagination' => 'no',
  647.                             'class'                 => '',
  648.                             'el_id'                 => '',
  649.                             'categories'            => array(),
  650.                             'custom_query'          => array(),
  651.                             'offset'                => 0,
  652.                             'custom_markup'         => '',
  653.                             'av_display_classes'    => '',
  654.                             'date_filter'           => '',
  655.                             'date_filter_start'     => '',
  656.                             'date_filter_end'       => '',
  657.                             'date_filter_format'    => 'yy/mm/dd',      //  'yy/mm/dd' | 'dd-mm-yy' | yyyymmdd
  658.                             'period_filter_unit_1'  => '',
  659.                             'period_filter_unit_2'  => '',
  660.                             'page_element_filter'   => '',
  661.                             'lazy_loading'          => 'disabled',
  662.                             'img_scrset'            => ''
  663.             );
  664.  
  665.             return $defaults;
  666.         }
  667.  
  668.         /**
  669.          * @since 5.4
  670.          * @return array
  671.          */
  672.         public function get_atts()
  673.         {
  674.             return $this->atts;
  675.         }
  676.  
  677.         /**
  678.          *
  679.          * @since < 4.0
  680.          * @return string
  681.          */
  682.         public function html()
  683.         {
  684.             $output = '';
  685.  
  686.             if( empty( $this->entries ) || ! $this->entries instanceof WP_Query || empty( $this->entries->posts ) )
  687.             {
  688.                 return $output;
  689.             }
  690.  
  691.             avia_post_slider::$slide ++;
  692.             extract( $this->atts );
  693.  
  694.             if( $preview_mode == 'auto' )
  695.             {
  696.                 $image_size = 'portfolio';
  697.             }
  698.  
  699.             $extraClass         = 'first';
  700.             $grid               = 'one_third';
  701.             $post_loop_count    = 1;
  702.             $loop_counter       = 1;
  703.             $autoplay           = $autoplay == 'no' ? false : true;
  704.             $total              = $columns % 2 ? 'odd' : 'even';
  705.             $blogstyle          = function_exists( 'avia_get_option' ) ? avia_get_option( 'blog_global_style', '' ) : '';
  706.             $excerpt_length     = 60;
  707.  
  708.             $class .= " av-slideshow-ui {$control_layout} {$nav_visibility_desktop} ";
  709.  
  710.             if( 'av-control-hidden' == $control_layout )
  711.             {
  712.                 $class .= ' av-no-slider-navigation av-hide-nav-arrows';
  713.             }
  714.             else
  715.             {
  716.                 if( false === strpos( $slider_navigation, 'av-navigate-arrows' ) )
  717.                 {
  718.                     $class .= ' av-hide-nav-arrows';
  719.                 }
  720.  
  721.                 if( false === strpos( $slider_navigation, 'av-navigate-dots' ) )
  722.                 {
  723.                     $class .= ' av-no-slider-navigation';
  724.                 }
  725.             }
  726.  
  727.             if( 'true' == $autoplay )
  728.             {
  729.                 $class .= ' av-slideshow-autoplay';
  730.                 $val_autoplay = true;
  731.  
  732.                 if( ! empty( $autoplay_stopper ) )
  733.                 {
  734.                     $class .= ' av-loop-once';
  735.                     $val_loop = 'once';
  736.                 }
  737.                 else
  738.                 {
  739.                     $class .= ' av-loop-endless';
  740.                     $val_loop = 'endless';
  741.                 }
  742.             }
  743.             else
  744.             {
  745.                 $class .= ' av-slideshow-manual av-loop-once';
  746.                 $val_autoplay = false;
  747.                 $val_loop = 'once';
  748.             }
  749.  
  750.             if( '' == $interval )
  751.             {
  752.                 $interval = 5;
  753.             }
  754.  
  755.             if( false !== strpos( $manual_stopper, 'manual_stopper' ) )
  756.             {
  757.                 $class .= ' av-loop-manual-once';
  758.                 $val_loop_manual = 'manual-once';
  759.             }
  760.             else
  761.             {
  762.                 $class .= ' av-loop-manual-endless';
  763.                 $val_loop_manual = 'manual-endless';
  764.             }
  765.  
  766.             $slideshow_options = array(
  767.                                     'animation'         => $animation,
  768.                                     'autoplay'          => $val_autoplay,
  769.                                     'loop_autoplay'     => $val_loop,
  770.                                     'interval'          => $interval,
  771.                                     'loop_manual'       => $val_loop_manual,
  772.                                     'autoplay_stopper'  => 'aviaTBautoplay_stopper' == $autoplay_stopper,
  773.                                     'noNavigation'      => 'av-control-hidden' == $control_layout,
  774.                                     'show_slide_delay'  => 90
  775.                                 );
  776.  
  777.             $data = 'data-slideshow-options="' . esc_attr( json_encode( $slideshow_options ) ) . '"';
  778.  
  779.  
  780.  
  781.             if( $blogstyle !== '' )
  782.             {
  783.                 $excerpt_length = 240;
  784.             }
  785.  
  786.             switch( $columns )
  787.             {
  788.                 case '1':
  789.                     $grid = 'av_fullwidth';
  790.                     if( $preview_mode == 'auto' )
  791.                     {
  792.                         $image_size = 'large';
  793.                     }
  794.                     break;
  795.                 case '2':
  796.                     $grid = 'av_one_half';
  797.                     break;
  798.                 case '3':
  799.                     $grid = 'av_one_third';
  800.                     break;
  801.                 case '4':
  802.                     $grid = 'av_one_fourth';
  803.                     if( $preview_mode == 'auto' )
  804.                     {
  805.                         $image_size = 'portfolio_small';
  806.                     }
  807.                     break;
  808.                 case '5':
  809.                     $grid = 'av_one_fifth';
  810.                     if( $preview_mode == 'auto' )
  811.                     {
  812.                         $image_size = 'portfolio_small';
  813.                     }
  814.                     break;
  815.             }
  816.  
  817.  
  818.             $thumb_fallback = '';
  819.             $markup_container = avia_markup_helper( array( 'context' => 'blog', 'echo' => false, 'custom_markup' => $custom_markup ) );
  820.  
  821.  
  822.             $output .= "<div {$el_id} {$data} class='avia-content-slider avia-content-{$type}-active avia-content-slider" . avia_post_slider::$slide . " avia-content-slider-{$total} {$class} {$av_display_classes}' {$markup_container}>";
  823.             $output .=      '<div class="avia-content-slider-inner">';
  824.  
  825.             foreach( $this->entries->posts as $index => $entry )
  826.             {
  827.                 $the_id = $entry->ID;
  828.                 $parity = $loop_counter % 2 ? 'odd' : 'even';
  829.                 $last = $this->entries->post_count == $post_loop_count ? ' post-entry-last ' : '';
  830.                 $post_class = "post-entry post-entry-{$the_id} slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";
  831.                 $link = get_post_meta( $the_id , '_portfolio_custom_link', true ) != '' ? get_post_meta( $the_id , '_portfolio_custom_link_url', true ) : get_permalink( $the_id );
  832.                 $excerpt = '';
  833.                 $title = '';
  834.                 $show_meta = ! is_post_type_hierarchical( $entry->post_type );
  835.                 $commentCount = get_comments_number( $the_id );
  836.                 $format = get_post_format( $the_id );
  837.  
  838.                 /**
  839.                  * Allow to show meta data of post.
  840.                  * Overrule default behaviour prior 5.4
  841.                  *
  842.                  * @since 5.4
  843.                  * @param string $show_meta_data            '' | 'always' | 'on_empty_title' | 'on_empty_content'
  844.                  * @param int $index
  845.                  * @param WP_Post $entry
  846.                  * @param avia_post_slider $this
  847.                  * @return string
  848.                  */
  849.                 $show_meta_data_post = apply_filters( 'avf_postslider_posts_meta_data', $show_meta_data, $index, $entry, $this );
  850.  
  851.                 $post_thumbnail_id = get_post_thumbnail_id( $the_id );
  852.                 if( $lazy_loading != 'enabled' )
  853.                 {
  854.                     Av_Responsive_Images()->add_attachment_id_to_not_lazy_loading( $post_thumbnail_id );
  855.                 }
  856.  
  857.                 $thumbnail = get_the_post_thumbnail( $the_id, $image_size );
  858.  
  859.                 if( empty( $format ) )
  860.                 {
  861.                     $format = 'standard';
  862.                 }
  863.  
  864.                 if( $thumbnail )
  865.                 {
  866.                     $thumb_fallback = $thumbnail;
  867.                     $thumb_class    = 'real-thumbnail';
  868.                 }
  869.                 else
  870.                 {
  871.                     $thumbnail = "<span class='fallback-post-type-icon' " . av_icon_string( $format ) .  "></span><span class='slider-fallback-image'>{{thumbnail}}</span>";
  872.                     $thumb_class = 'fake-thumbnail';
  873.                 }
  874.  
  875.  
  876.                 $permalink = '<div class="read-more-link"><a href="' . get_permalink( $the_id ) . '" class="more-link">' . __( 'Read more', 'avia_framework' ) . '<span class="more-link-arrow"></span></a></div>';
  877.                 $prepare_excerpt = ! empty( $entry->post_excerpt ) ? $entry->post_excerpt : avia_backend_truncate( $entry->post_content, apply_filters( 'avf_postgrid_excerpt_length', $excerpt_length ), apply_filters( 'avf_postgrid_excerpt_delimiter', ' ' ), '…', true, '' );
  878.  
  879.                 if( $format == 'link' )
  880.                 {
  881.                     $current_post = array();
  882.                     $current_post['content'] = $entry->post_content;
  883.                     $current_post['title'] = avia_wp_get_the_title( $entry );
  884.  
  885.                     if( function_exists( 'avia_link_content_filter' ) )
  886.                     {
  887.                         $current_post = avia_link_content_filter( $current_post );
  888.                     }
  889.  
  890.                     $link = $current_post['url'];
  891.                 }
  892.  
  893.                 switch( $contents )
  894.                 {
  895.                     case 'excerpt':
  896.                     case 'excerpt_read_more':
  897.                             $excerpt = $prepare_excerpt;
  898.                             $title = avia_wp_get_the_title( $entry );
  899.                             break;
  900.                     case 'title':
  901.                     case 'title_read_more':
  902.                             $excerpt = '';
  903.                             $title = avia_wp_get_the_title( $entry );
  904.                             break;
  905.                     case 'only_excerpt':
  906.                             $excerpt = $prepare_excerpt;
  907.                             $title = '';
  908.                             break;
  909.                     case 'only_excerpt_read_more':
  910.                             $excerpt = $prepare_excerpt;
  911.                             $title = '';
  912.                             break;
  913.                     case 'no':
  914.                             $excerpt = '';
  915.                             $title = '';
  916.                             break;
  917.                 }
  918.  
  919.                 /**
  920.                  * @since < 4.0
  921.                  * @param string $title
  922.                  * @param WP_Post $entry
  923.                  * @return string
  924.                  */
  925.                 $title = apply_filters( 'avf_postslider_title', $title, $entry );
  926.  
  927.  
  928.                 /**
  929.                  * @since 4.7.3.1
  930.                  * @param string $image_link_title
  931.                  * @param WP_Post $entry
  932.                  * @return string
  933.                  */
  934.                 $image_link_title = apply_filters( 'avf_postslider_link_title_attr', esc_attr( avia_wp_get_the_title( $entry ) ), $entry );
  935.  
  936.                 $markup_article = avia_markup_helper( array( 'context' => 'entry', 'echo' => false, 'id' => $the_id, 'custom_markup' => $custom_markup ) );
  937.                 $markup_title = avia_markup_helper( array( 'context' => 'entry_title', 'echo' => false, 'id' => $the_id, 'custom_markup' => $custom_markup ) );
  938.                 $markup_time = avia_markup_helper( array( 'context' => 'entry_time', 'echo' => false, 'id' => $the_id, 'custom_markup' => $custom_markup ) );
  939.                 $markup_content = avia_markup_helper( array( 'context' => 'entry_content', 'echo' => false, 'id' => $the_id, 'custom_markup' => $custom_markup ) );
  940.  
  941.                 $post_format = get_post_format( $the_id ) ? get_post_format( $the_id ) : 'standard';
  942.  
  943.                 if( $loop_counter == 1 )
  944.                 {
  945.                     $output .= '<div class="slide-entry-wrap">';
  946.                 }
  947.  
  948.                 $posttype_class = 'posttype-' . get_post_type( $the_id );
  949.  
  950.                 $output .= "<article class='slide-entry flex_column {$style} {$post_class} {$grid} {$extraClass} {$thumb_class} {$posttype_class} post-format-{$post_format}' {$markup_article}>";
  951.                 $output .= $thumbnail ? "<a href='{$link}' data-rel='slide-" . avia_post_slider::$slide . "' class='slide-image' title='{$image_link_title}'>{$thumbnail}</a>" : '';
  952.  
  953.                 if( $post_format == 'audio' )
  954.                 {
  955.                     $current_post = array();
  956.                     $current_post['content'] = $entry->post_content;
  957.                     $current_post['title'] = avia_wp_get_the_title( $entry );
  958.                     $current_post['id'] = $entry->ID;
  959.  
  960.                     $current_post = apply_filters( 'post-format-' . $post_format, $current_post, $entry );
  961.  
  962.                     if( ! empty( $current_post['before_content'] ) )
  963.                     {
  964.                         $output .= '<div class="big-preview single-big audio-preview">' . $current_post['before_content'] . '</div>';
  965.                     }
  966.                 }
  967.  
  968.                 $output .= '<div class="slide-content">';
  969.  
  970.  
  971.                 $output .= '<header class="entry-content-header">';
  972.                 $meta_out = '';
  973.  
  974.                 if( ! empty( $title ) || in_array( $show_meta_data_post, array( 'always', 'on_empty_title' ) ) )
  975.                 {
  976.                     if( $show_meta )
  977.                     {
  978.                         $taxonomies = get_object_taxonomies( get_post_type( $the_id ) );
  979.                         $cats = '';
  980.                         $excluded_taxonomies = array_merge( get_taxonomies( array( 'public' => false ) ), array( 'post_tag', 'post_format' ) );
  981.                         $excluded_taxonomies = apply_filters( 'avf_exclude_taxonomies', $excluded_taxonomies, get_post_type( $the_id ), $the_id, __CLASS__ );
  982.  
  983.                         if( ! empty( $taxonomies ) )
  984.                         {
  985.                             foreach( $taxonomies as $taxonomy )
  986.                             {
  987.                                 if( ! in_array( $taxonomy, $excluded_taxonomies ) )
  988.                                 {
  989.                                     $cats .= get_the_term_list( $the_id, $taxonomy, '', ', ', '' ) . ' ';
  990.                                 }
  991.                             }
  992.                         }
  993.  
  994.                         if( ! empty( $cats ) )
  995.                         {
  996.                             $meta_out .= '<span class="blog-categories minor-meta">';
  997.                             $meta_out .=    $cats;
  998.                             $meta_out .= '</span>';
  999.                         }
  1000.                     }
  1001.  
  1002.                     /**
  1003.                      * Allow to change default output of categories - by default supressed for setting Default(Business) blog style
  1004.                      *
  1005.                      * @since 4.0.6
  1006.                      * @param string $blogstyle                     '' | 'elegant-blog' | 'elegant-blog modern-blog'
  1007.                      * @param avia_post_slider $this
  1008.                      * @return string                               'show_elegant' | 'show_business' | 'use_theme_default' | 'no_show_cats'
  1009.                      */
  1010.                     $show_cats = apply_filters( 'avf_postslider_show_catergories', 'use_theme_default', $blogstyle, $this );
  1011.  
  1012.                     switch( $show_cats )
  1013.                     {
  1014.                         case 'no_show_cats':
  1015.                             $new_blogstyle = '';
  1016.                             break;
  1017.                         case 'show_elegant':
  1018.                             $new_blogstyle = 'elegant-blog';
  1019.                             break;
  1020.                         case 'show_business':
  1021.                             $new_blogstyle = 'elegant-blog modern-blog';
  1022.                             break;
  1023.                         case 'use_theme_default':
  1024.                         default:
  1025.                             $new_blogstyle = $blogstyle;
  1026.                             break;
  1027.                     }
  1028.  
  1029.                     //  elegant style
  1030.                     if( ( strpos( $new_blogstyle, 'modern-blog' ) === false ) && ( $new_blogstyle != '' ) )
  1031.                     {
  1032.                         $output .= $meta_out;
  1033.                     }
  1034.  
  1035.                     $default_heading = 'h3';
  1036.                     $args = array(
  1037.                                 'heading'       => $default_heading,
  1038.                                 'extra_class'   => ''
  1039.                             );
  1040.  
  1041.                     $extra_args = array( $this, $index, $entry );
  1042.  
  1043.                     /**
  1044.                      * @since 4.5.5
  1045.                      * @return array
  1046.                      */
  1047.                     $args = apply_filters( 'avf_customize_heading_settings', $args, __CLASS__, $extra_args );
  1048.  
  1049.                     $heading = ! empty( $args['heading'] ) ? $args['heading'] : $default_heading;
  1050.                     $css = ! empty( $args['extra_class'] ) ? $args['extra_class'] : '';
  1051.  
  1052.  
  1053.                     $output .=  "<{$heading} class='slide-entry-title entry-title {$css}' {$markup_title}><a href='{$link}' title='" . esc_attr( strip_tags( $title ) ) . "'>{$title}</a></{$heading}>";
  1054.  
  1055.                     //  modern business style
  1056.                     if( ( strpos( $new_blogstyle, 'modern-blog' ) !== false ) && ( $new_blogstyle != '' ) )
  1057.                     {
  1058.                         $output .= $meta_out;
  1059.                     }
  1060.  
  1061.                     $output .= '<span class="av-vertical-delimiter"></span>';
  1062.                 }
  1063.  
  1064.                 $output .= '</header>';
  1065.  
  1066.                 if( ( $show_meta && ! empty( $excerpt ) ) || in_array( $show_meta_data_post, array( 'always', 'on_empty_content' ) ) )
  1067.                 {
  1068.                     $meta_array = array();
  1069.  
  1070.                     /**
  1071.                      * Allow to show/hide comment meta data of time. Overrule default behaviour prior 5.4
  1072.                      *
  1073.                      * @since 5.4
  1074.                      * @param boolean $show_meta_comment
  1075.                      * @param string $context
  1076.                      * @param int $index
  1077.                      * @param WP_Post $entry
  1078.                      * @param avia_post_slider $this
  1079.                      * @return boolean
  1080.                      */
  1081.                     $show_meta_time = apply_filters( 'avf_postslider_posts_meta_data_show', true, 'time', $index, $entry, $this );
  1082.  
  1083.                     if( $show_meta_time )
  1084.                     {
  1085.                         $meta_array['time'] = "<time class='slide-meta-time updated' {$markup_time}>" . get_the_time( get_option( 'date_format' ), $the_id ) . '</time>';
  1086.                     }
  1087.  
  1088.                     /**
  1089.                      * Allow to show/hide comment meta data of author. Overrule default behaviour prior 5.4
  1090.                      *
  1091.                      * @since 5.4
  1092.                      * @param boolean $show_meta_author
  1093.                      * @param string $context
  1094.                      * @param int $index
  1095.                      * @param WP_Post $entry
  1096.                      * @param avia_post_slider $this
  1097.                      * @return boolean
  1098.                      */
  1099.                     $show_meta_author = apply_filters( 'avf_postslider_posts_meta_data_show', false, 'author', $index, $entry, $this );
  1100.  
  1101.                     if( $show_meta_author )
  1102.                     {
  1103.                         $url = get_author_posts_url( $entry->post_author );
  1104.                         $user_data = get_userdata( $entry->post_author );
  1105.                         $author_nicename = ! empty( $user_data->user_nicename ) ? $user_data->user_nicename : '';
  1106.  
  1107.                         if( ! empty( $author_nicename ) )
  1108.                         {
  1109.                             $link = sprintf(
  1110.                                         '<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
  1111.                                         esc_url( $url ),
  1112.                                         esc_attr( sprintf( __( 'Posts by %s', 'avia_framework' ), $author_nicename ) ),
  1113.                                         $author_nicename
  1114.                                     );
  1115.  
  1116.                             $meta_author  = '<div class="slide-meta-author">' . __( 'by', 'avia_framework' ) . ' ';
  1117.                             $meta_author .=     '<span class="entry-author-link" ' . avia_markup_helper( array( 'context' => 'author_name', 'echo' => false ) ) . '>';
  1118.                             $meta_author .=         '<span class="author">';
  1119.                             $meta_author .=             '<span class="fn">';
  1120.                             $meta_author .=                 $link;
  1121.                             $meta_author .=             '</span>';
  1122.                             $meta_author .=         '</span>';
  1123.                             $meta_author .=     '</span>';
  1124.                             $meta_author .= '</div>';
  1125.  
  1126.                             $meta_array['author'] = $meta_author;
  1127.                         }
  1128.                     }
  1129.  
  1130.                     /**
  1131.                      * Allow to show/hide comment meta data of post. Overrule default behaviour prior 5.4
  1132.                      *
  1133.                      * @since 5.4
  1134.                      * @param boolean $show_meta_comment
  1135.                      * @param string $context
  1136.                      * @param int $index
  1137.                      * @param WP_Post $entry
  1138.                      * @param avia_post_slider $this
  1139.                      * @return boolean
  1140.                      */
  1141.                     $show_meta_comment = apply_filters( 'avf_postslider_posts_meta_data_show', true, 'comment_count', $index, $entry, $this );
  1142.  
  1143.                     if( $show_meta_comment )
  1144.                     {
  1145.                         if( $commentCount != '0' || comments_open( $the_id ) && $entry->post_type != 'portfolio' )
  1146.                         {
  1147.                             $link_add = $commentCount === '0' ? '#respond' : '#comments';
  1148.                             $text_add = $commentCount === '1' ? __( 'Comment', 'avia_framework' ) : __( 'Comments', 'avia_framework' );
  1149.  
  1150.                             $meta_comment  = '<div class="slide-meta-comments">';
  1151.                             $meta_comment .=    "<a href='{$link}{$link_add}'>{$commentCount} {$text_add}</a>";
  1152.                             $meta_comment .= '</div>';
  1153. //                          $meta_content .= '<div class="slide-meta-del">/</div>';
  1154.  
  1155.                             $meta_array['comment_count'] = $meta_comment;
  1156.                         }
  1157.                     }
  1158.  
  1159.                     /**
  1160.                      * Allow to show/hide tags meta data of post. Overrule default behaviour prior 5.4
  1161.                      *
  1162.                      * @since 5.4
  1163.                      * @param boolean $show_meta_comment
  1164.                      * @param string $context
  1165.                      * @param int $index
  1166.                      * @param WP_Post $entry
  1167.                      * @param avia_post_slider $this
  1168.                      * @return boolean
  1169.                      */
  1170.                     $show_meta_tags = apply_filters( 'avf_postslider_posts_meta_data_show', false, 'tags', $index, $entry, $this );
  1171.  
  1172.                     if( $show_meta_tags && has_tag( '', $entry->ID ) )
  1173.                     {
  1174.                         $meta_tags  = '<div class="slide-meta-tags">';
  1175.                         $meta_tags .=   get_the_tag_list( __( 'Tags:', 'avia_framework' ) . '<span> ', ', ', '</span>', $entry->ID );
  1176.                         $meta_tags .= '</div>';
  1177.  
  1178.                         $meta_array['tags'] = $meta_tags;
  1179.                     }
  1180.  
  1181.                     $meta_content = implode( '<div class="slide-meta-del">/</div>', $meta_array );
  1182.  
  1183.                     /**
  1184.                      *
  1185.                      * @since 4.8.8
  1186.                      * @since 5.4                       added $meta_array
  1187.                      * @param string $meta_content
  1188.                      * @param WP_Post $entry
  1189.                      * @param int $index
  1190.                      * @param array $this->atts
  1191.                      * @param array $meta_array
  1192.                      * @return string
  1193.                      */
  1194.                     $meta_content = apply_filters( 'avf_post_slider_meta_content', $meta_content, $entry, $index, $this->atts, $meta_array );
  1195.  
  1196.                     if( ! empty( $meta_content ) )
  1197.                     {
  1198.                         $meta  = '<div class="slide-meta">';
  1199.                         $meta .=    $meta_content;
  1200.                         $meta .= '</div>';
  1201.                     }
  1202.  
  1203.                     if( strpos( $blogstyle, 'elegant-blog' ) === false )
  1204.                     {
  1205.                         $output .= $meta;
  1206.                         $meta = '';
  1207.                     }
  1208.                 }
  1209.  
  1210.                 /**
  1211.                  * @since ???
  1212.                  * @since 4.8.7             added $this
  1213.                  * @param string $excerpt
  1214.                  * @param string $prepare_excerpt
  1215.                  * @param string $permalink
  1216.                  * @param WP_Post $entry
  1217.                  * @param avia_post_slider $this
  1218.                  * @return string
  1219.                  */
  1220.                 $excerpt = apply_filters( 'avf_post_slider_entry_excerpt', $excerpt, $prepare_excerpt, $permalink, $entry, $this );
  1221.  
  1222.  
  1223.                 $output .= ! empty( $excerpt ) ? "<div class='slide-entry-excerpt entry-content' {$markup_content}>{$excerpt}</div>" : '';
  1224.  
  1225.                 $output .= '</div>';
  1226.  
  1227.                 $output .= '<footer class="entry-footer">';
  1228.  
  1229.  
  1230.                     switch( $contents ){
  1231.                         case 'excerpt_read_more':
  1232.                         case 'title_read_more':
  1233.                         case 'only_excerpt_read_more':
  1234.                                 $output .= $permalink;
  1235.                                 break;
  1236.                     }
  1237.  
  1238.                 if( ! empty( $meta ) )
  1239.                 {
  1240.                     $output .= $meta;
  1241.                 }
  1242.  
  1243.                 $output .= '</footer>';
  1244.  
  1245.                 $output .= av_blog_entry_markup_helper( $the_id );
  1246.  
  1247.                 $output .= '</article>';
  1248.  
  1249.                 $loop_counter ++;
  1250.                 $post_loop_count ++;
  1251.                 $extraClass = '';
  1252.  
  1253.                 if( $loop_counter > $columns )
  1254.                 {
  1255.                     $loop_counter = 1;
  1256.                     $extraClass = 'first';
  1257.                 }
  1258.  
  1259.                 if( $loop_counter == 1 || ! empty( $last ) )
  1260.                 {
  1261.                     $output .= '</div>';
  1262.                 }
  1263.             }
  1264.  
  1265.             $output .=      '</div>';
  1266.  
  1267.             if( $post_loop_count -1 > $columns && $type == 'slider' )
  1268.             {
  1269.                 $output .= $this->slide_navigation_arrows();
  1270.  
  1271.                 if( 'av-control-hidden' != $control_layout && false !== strpos( $slider_navigation, 'av-navigate-dots' )  )
  1272.                 {
  1273.                     $output .= $this->slide_navigation_dots();
  1274.                 }
  1275.             }
  1276.  
  1277.             global $wp_query;
  1278.  
  1279.             $avia_pagination = '';
  1280.  
  1281.             if( $use_main_query_pagination == 'yes' && $paginate == 'yes' )
  1282.             {
  1283.                 $avia_pagination = avia_pagination( $wp_query->max_num_pages, 'nav' );
  1284.             }
  1285.             else if( $paginate == 'yes' )
  1286.             {
  1287.                 $avia_pagination = avia_pagination( $this->entries, 'nav', 'avia-element-paging', $this->current_page );
  1288.             }
  1289.  
  1290.             if( ! empty( $avia_pagination ) )
  1291.             {
  1292.                 $output .= "<div class='pagination-wrap pagination-slider'>{$avia_pagination}</div>";
  1293.             }
  1294.  
  1295.             $output .= '</div>';
  1296.  
  1297.             $output = str_replace( '{{thumbnail}}', $thumb_fallback, $output );
  1298.  
  1299.             wp_reset_query();
  1300.  
  1301.             return $output;
  1302.         }
  1303.  
  1304.         /**
  1305.          * Create arrows to scroll slides
  1306.          *
  1307.          * @since 4.8.3         reroute to aviaFrontTemplates
  1308.          * @return string
  1309.          */
  1310.         protected function slide_navigation_arrows()
  1311.         {
  1312.             $args = array(
  1313.                         'context'       => get_class(),
  1314.                         'params'        => $this->atts
  1315.                     );
  1316.  
  1317.             return aviaFrontTemplates::slide_navigation_arrows( $args );
  1318.         }
  1319.  
  1320.         /**
  1321.          * Create dots to scroll tabs
  1322.          *
  1323.          * @since 5.0           reroute to aviaFrontTemplates
  1324.          * @return string
  1325.          */
  1326.         protected function slide_navigation_dots()
  1327.         {
  1328.             $args = array(
  1329.                         'class_main'        => 'avia-slideshow-dots avia-slideshow-controls avia-post-slider fade-in',
  1330.                         'total_entries'     => $this->entries->post_count,
  1331.                         'container_entries' => $this->atts['columns'],
  1332.                         'context'           => get_class(),
  1333.                         'params'            => $this->atts
  1334.                     );
  1335.  
  1336.             return aviaFrontTemplates::slide_navigation_dots( $args );
  1337.         }
  1338.  
  1339.         /**
  1340.          * Fetch new entries
  1341.          *
  1342.          * @since < 4.0
  1343.          * @param array $params
  1344.          */
  1345.         public function query_entries( $params = array() )
  1346.         {
  1347.             global $avia_config;
  1348.  
  1349.             if( empty( $params ) )
  1350.             {
  1351.                 $params = $this->atts;
  1352.             }
  1353.  
  1354.             if( empty( $params['custom_query'] ) )
  1355.             {
  1356.                 $query = array();
  1357.                 $terms = array();
  1358.  
  1359.                 if( ! empty( $params['categories'] ) )
  1360.                 {
  1361.                     //get the portfolio categories
  1362.                     $terms = explode( ',', $params['categories'] );
  1363.                 }
  1364.  
  1365.                 if( $params['use_main_query_pagination'] == 'yes' )
  1366.                 {
  1367.                     $this->current_page = ( $params['paginate'] != 'no' ) ? avia_get_current_pagination_number() : 1;
  1368.                 }
  1369.                 else
  1370.                 {
  1371.                     $this->current_page = ( $params['paginate'] != 'no' ) ? avia_get_current_pagination_number( 'avia-element-paging' ) : 1;
  1372.                 }
  1373.  
  1374.                 //if we find no terms for the taxonomy fetch all taxonomy terms
  1375.                 if( empty( $terms[0] ) || is_null( $terms[0] ) || $terms[0] === 'null' )
  1376.                 {
  1377.                     $term_args = array(
  1378.                                 'taxonomy'      => $params['taxonomy'],
  1379.                                 'hide_empty'    => true
  1380.                             );
  1381.                     /**
  1382.                      * To display private posts you need to set 'hide_empty' to false,
  1383.                      * otherwise a category with ONLY private posts will not be returned !!
  1384.                      *
  1385.                      * You also need to add post_status 'private' to the query params with filter avia_post_slide_query.
  1386.                      *
  1387.                      * @since 4.4.2
  1388.                      * @added_by Günter
  1389.                      * @param array $term_args
  1390.                      * @param array $params
  1391.                      * @return array
  1392.                      */
  1393.                     $term_args = apply_filters( 'avf_av_postslider_term_args', $term_args, $params );
  1394.  
  1395.                     $allTax = AviaHelper::get_terms( $term_args );
  1396.  
  1397.                     $terms = array();
  1398.                     foreach( $allTax as $tax )
  1399.                     {
  1400.                         $terms[] = $tax->term_id;
  1401.                     }
  1402.                 }
  1403.  
  1404.                 if( $params['offset'] == 'no_duplicates' )
  1405.                 {
  1406.                     $params['offset'] = false;
  1407.                     $no_duplicates = true;
  1408.                 }
  1409.  
  1410.                 //wordpress 4.4 offset fix
  1411.                 if( $params['offset'] == 0 )
  1412.                 {
  1413.                     $params['offset'] = false;
  1414.                 }
  1415.                 else
  1416.                 {
  1417.                     //if the offset is set the paged param is ignored. therefore we need to factor in the page number
  1418.                     $params['offset'] = $params['offset'] + ( ( $this->current_page - 1 ) * $params['items'] );
  1419.                 }
  1420.  
  1421.                 if( empty( $params['post_type'] ) )
  1422.                 {
  1423.                     $params['post_type'] = get_post_types();
  1424.                 }
  1425.  
  1426.                 if( is_string($params['post_type'] ) )
  1427.                 {
  1428.                     $params['post_type'] = explode( ',', $params['post_type'] );
  1429.                 }
  1430.  
  1431.                 $orderby = 'date';
  1432.                 $order = 'DESC';
  1433.  
  1434.                 $date_query = AviaHelper::date_query( array(), $params );
  1435.  
  1436.                 // Meta query - replaced by Tax query in WC 3.0.0
  1437.                 $meta_query = array();
  1438.                 $tax_query = array();
  1439.  
  1440.  
  1441.                 // check if taxonomy are set to product or product attributes
  1442.                 $tax = get_taxonomy( $params['taxonomy'] );
  1443.  
  1444.                 if( class_exists( 'WooCommerce', false ) && is_object( $tax ) && isset( $tax->object_type ) && in_array( 'product', (array) $tax->object_type ) )
  1445.                 {
  1446.                     $avia_config['woocommerce']['disable_sorting_options'] = true;
  1447.  
  1448.                     avia_wc_set_out_of_stock_query_params( $meta_query, $tax_query, $params['wc_prod_visible'] );
  1449.                     avia_wc_set_hidden_prod_query_params( $meta_query, $tax_query, $params['wc_prod_hidden'] );
  1450.                     avia_wc_set_featured_prod_query_params( $meta_query, $tax_query, $params['wc_prod_featured'] );
  1451.  
  1452.                         //  sets filter hooks !!
  1453.                     $ordering_args = avia_wc_get_product_query_order_args( $params['prod_order_by'], $params['prod_order'] );
  1454.  
  1455.                     $orderby = $ordering_args['orderby'];
  1456.                     $order = $ordering_args['order'];
  1457.                     $params['meta_key'] = $ordering_args['meta_key'];
  1458.                 }
  1459.  
  1460.                 if( ! empty( $terms ) )
  1461.                 {
  1462.                     $tax_query[] = array(
  1463.                                         'taxonomy'  =>  $params['taxonomy'],
  1464.                                         'field'     =>  'id',
  1465.                                         'terms'     =>  $terms,
  1466.                                         'operator'  =>  count( $terms ) == 1 ? 'IN' : $params['term_rel']
  1467.                                 );
  1468.                 }
  1469.  
  1470.                 $query = array(
  1471.                                 'orderby'       => $orderby,
  1472.                                 'order'         => $order,
  1473.                                 'paged'         => $this->current_page,
  1474.                                 'post_type'     => $params['post_type'],
  1475. //                              'post_status'   => 'publish',
  1476.                                 'offset'        => $params['offset'],
  1477.                                 'posts_per_page' => $params['items'],
  1478.                                 'post__not_in'  => ( ! empty( $no_duplicates ) ) ? $avia_config['posts_on_current_page'] : array(),
  1479.                                 'meta_query'    => $meta_query,
  1480.                                 'tax_query'     => $tax_query,
  1481.                                 'date_query'    => $date_query
  1482.                             );
  1483.             }
  1484.             else
  1485.             {
  1486.                 $query = $params['custom_query'];
  1487.             }
  1488.  
  1489.             if( ! empty( $params['meta_key'] ) )
  1490.             {
  1491.                 $query['meta_key'] = $params['meta_key'];
  1492.             }
  1493.  
  1494.             if( 'skip_current' == $params['page_element_filter'] )
  1495.             {
  1496.                 $query['post__not_in'] = isset( $query['post__not_in'] ) ? $query['post__not_in'] : [];
  1497.                 $query['post__not_in'][] = get_the_ID();
  1498.             }
  1499.  
  1500.             /**
  1501.              * @used_by             config-bbpress\config.php   avia_remove_bbpress_post_type_from_query()          10
  1502.              * @used_by             config-wpml\config.php      avia_translate_ids_from_query                       10
  1503.              * @used_by             avia_WPML::handler_avia_post_slide_query                                        20
  1504.              *
  1505.              * @since < 4.0
  1506.              * @param array $query
  1507.              * @param array $params
  1508.              * @return array
  1509.              */
  1510.             $query = apply_filters( 'avia_post_slide_query', $query, $params );
  1511.  
  1512.             @$this->entries = new WP_Query( $query ); //@ is used to prevent errors caused by wpml
  1513.  
  1514.             $this->set_posts_on_current_page();
  1515.  
  1516.             if( function_exists( 'WC' ) )
  1517.             {
  1518.                 avia_wc_clear_catalog_ordering_args_filters();
  1519.                 $avia_config['woocommerce']['disable_sorting_options'] = false;
  1520.             }
  1521.         }
  1522.  
  1523.         /**
  1524.          * Store the queried post ids in $avia_config
  1525.          *
  1526.          * @since 5.6
  1527.          */
  1528.         protected function set_posts_on_current_page()
  1529.         {
  1530.             global $avia_config;
  1531.  
  1532.             if( ! $this->entries instanceof WP_Query )
  1533.             {
  1534.                 return;
  1535.             }
  1536.  
  1537.             if( $this->entries->post_count > 0 )
  1538.             {
  1539.                 foreach( $this->entries->posts as $entry )
  1540.                 {
  1541.                     $avia_config['posts_on_current_page'][] = $entry->ID;
  1542.                 }
  1543.             }
  1544.         }
  1545.     }
  1546. }
  1547.  
  1548.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement