Advertisement
Guenni007

postslider

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