Advertisement
Guenni007

postslider

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