Advertisement
Guenni007

postslider

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