Guenni007 icon

postslider

Guenni007 | PRO | 08/31/25 09:13:04 AM UTC (Edited) | 0 ⭐ | 10799 👁️ | Never ⏰ | []
PHP |

34.39 KB

|

None

|

0 👍

/

0 👎

<?php
/**
 * Post Slider
 *
 * Display a slideshow or grid of Post Entries
 *
 * 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
 *
 * This class does not support post css files
 * ==========================================
 */
if( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
 
 
if( ! class_exists( 'avia_sc_postslider', false ) )
{
    class avia_sc_postslider extends aviaShortcodeTemplate
    {
        /**
         * Create the config array for the shortcode button
         */
        protected function shortcode_insert_button()
        {
            $this->config['version']        = '1.0';
            $this->config['self_closing']   = 'yes';
            $this->config['base_element']   = 'yes';
 
            $this->config['name']           = __( 'Post Slider', 'avia_framework' );
            $this->config['tab']            = __( 'Content Elements', 'avia_framework' );
            $this->config['icon']           = AviaBuilder::$path['imagesURL'] . 'sc-postslider.png';
            $this->config['order']          = 30;
            $this->config['target']         = 'avia-target-insert';
            $this->config['shortcode']      = 'av_postslider';
            $this->config['tooltip']        = __( 'Display a Slideshow of Post Entries', 'avia_framework' );
            $this->config['drag-level']     = 3;
            $this->config['disabling_allowed'] = true;
            $this->config['id_name']        = 'id';
            $this->config['id_show']        = 'yes';
            $this->config['alb_desc_id']    = 'alb_description';
        }
 
        protected function extra_assets()
        {
            $ver = Avia_Builder()->get_theme_version();
            $min_js = avia_minify_extension( 'js' );
            $min_css = avia_minify_extension( 'css' );
 
            //load css
            wp_enqueue_style( 'avia-module-slideshow', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/slideshow/slideshow{$min_css}.css", array( 'avia-layout' ), $ver );
            wp_enqueue_style( 'avia-module-postslider', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/postslider/postslider{$min_css}.css", array( 'avia-module-slideshow' ), $ver );
 
                //load js
            wp_enqueue_script( 'avia-module-slideshow', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/slideshow/slideshow{$min_js}.js", array( 'avia-shortcodes' ), $ver, true );
        }
 
        /**
         * Popup Elements
         *
         * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
         * opens a modal window that allows to edit the element properties
         *
         * @return void
         */
        protected function popup_elements()
        {
            $this->elements = array(
 
                array(
                        'type'  => 'tab_container',
                        'nodescription' => true
                    ),
 
                array(
                        'type'  => 'tab',
                        'name'  => __( 'Content', 'avia_framework' ),
                        'nodescription' => true
                    ),
 
                    array(
                            'type'          => 'template',
                            'template_id'   => 'toggle_container',
                            'templates_include' => array(
                                                    $this->popup_key( 'content_slides' ),
                                                    $this->popup_key( 'content_filter' ),
                                                    $this->popup_key( 'content_excerpt' ),
                                                ),
                            'nodescription' => true
                        ),
 
                array(
                        'type'  => 'tab_close',
                        'nodescription' => true
                    ),
 
                array(
                        'type'  => 'tab',
                        'name'  => __( 'Styling', 'avia_framework' ),
                        'nodescription' => true
                    ),
 
                    array(
                            'type'          => 'template',
                            'template_id'   => 'toggle_container',
                            'templates_include' => array(
                                                    $this->popup_key( 'styling_columns' ),
                                                    $this->popup_key( 'styling_image' ),
                                                    $this->popup_key( 'styling_navigation' )
                                                ),
                            'nodescription' => true
                        ),
 
                array(
                        'type'  => 'tab_close',
                        'nodescription' => true
                    ),
 
                array(
                        'type'  => 'tab',
                        'name'  => __( 'Advanced', 'avia_framework' ),
                        'nodescription' => true
                    ),
 
                    array(
                            'type'  => 'toggle_container',
                            'nodescription' => true
                        ),
 
                        array(
                                'type'          => 'template',
                                'template_id'   => $this->popup_key( 'advanced_animation_slider' ),
                                'nodescription' => true
                            ),
 
                        array(
                                'type'          => 'template',
                                'template_id'   => 'lazy_loading_toggle',
                                'lockable'      => true
                            ),
 
                        array(
                                'type'          => 'template',
                                'template_id'   => 'screen_options_toggle',
                                'lockable'      => true
                            ),
 
                        array(
                                'type'          => 'template',
                                'template_id'   => 'developer_options_toggle',
                                'args'          => array( 'sc' => $this )
                            ),
 
                    array(
                            'type'  => 'toggle_container_close',
                            'nodescription' => true
                        ),
 
                array(
                        'type'  => 'tab_close',
                        'nodescription' => true
                    ),
 
                array(
                        'type'          => 'template',
                        'template_id'   => 'element_template_selection_tab',
                        'args'          => array( 'sc' => $this )
                    ),
 
                array(
                        'type'  => 'tab_container_close',
                        'nodescription' => true
                    )
 
                );
 
        }
 
        /**
         * Create and register templates for easier maintainance
         *
         * @since 4.6.4
         */
        protected function register_dynamic_templates()
        {
 
            /**
             * Content Tab
             * ===========
             */
 
            $c = array(
                        array(
                            'name'      => __( 'Which Entries Should Be Used', 'avia_framework' ),
                            'desc'      => __( 'Select which entries should be displayed by selecting a taxonomy', 'avia_framework' ),
                            'id'        => 'link',
                            'type'      => 'linkpicker',
                            'fetchTMPL' => true,
                            'multiple'  => 6,
                            'std'       => 'category',
                            'lockable'  => true,
                            'subtype'   => array( __( 'Display Entries from:', 'avia_framework' ) => 'taxonomy' )
                        ),
 
                        array(
                            'name'      => __( 'Multiple Categories/Terms Relation', 'avia_framework' ),
                            'desc'      => __( 'Select to use an OR or AND relation. In AND an entry must be in all selected categories/terms to be displayed. Defaults to OR', 'avia_framework' ),
                            'id'        => 'term_rel',
                            'type'      => 'select',
                            'std'       => '',
                            'lockable'  => true,
                            'subtype'   => array(
                                                __( 'OR', 'avia_framework' )    => '',
                                                __( 'AND', 'avia_framework' )   => 'AND'
                                            )
                        )
 
                );
 
            if( current_theme_supports( 'add_avia_builder_post_type_option' ) )
            {
                $element = array(
                                'type'          => 'template',
                                'template_id'   => 'avia_builder_post_type_option',
                                'lockable'      => true,
                            );
 
                array_unshift( $c, $element );
            }
 
            $template = array(
                            array(
                                'type'          => 'template',
                                'template_id'   => 'toggle',
                                'title'         => __( 'Entries', 'avia_framework' ),
                                'content'       => $c
                            ),
                    );
 
            AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_slides' ), $template );
 
            $c = array(
                        array(
                            'type'          => 'template',
                            'template_id'   => 'wc_options_non_products',
                            'lockable'      => true
                        ),
 
 
                        array(
                            'type'          => 'template',
                            'template_id'   => 'date_query',
                            'lockable'      => true,
                            'period'        => true
                        ),
 
                        array(
                            'name'      => __( 'Entry Number', 'avia_framework' ),
                            'desc'      => __( 'How many items should be displayed?', 'avia_framework' ),
                            'id'        => 'items',
                            'type'      => 'select',
                            'std'       => '9',
                            'lockable'  => true,
                            'subtype'   => AviaHtmlHelper::number_array( 1, 100, 1, array( 'All' => '-1' ) )
                        ),
 
                        array(
                            'name'      => __( 'Offset Number', 'avia_framework' ),
                            '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' ),
                            'id'        => 'offset',
                            'type'      => 'select',
                            'std'       => '0',
                            'lockable'  => true,
                            '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' ) )
                        ),
 
                        array(
                            'type'          => 'template',
                            'template_id'   => 'page_element_filter',
                            'lockable'      => true
                        )
                );
 
            $template = array(
                            array(
                                'type'          => 'template',
                                'template_id'   => 'toggle',
                                'title'         => __( 'Filters', 'avia_framework' ),
                                'content'       => $c
                            ),
                    );
 
            AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_filter' ), $template );
 
            $c = array(
                        array(
                            'name'      => __( 'Slide Content', 'avia_framework' ),
                            'desc'      => __( 'Select what information you want to display', 'avia_framework' ),
                            'id'        => 'contents',
                            'type'      => 'select',
                            'std'       => 'excerpt',
                            'lockable'  => true,
                            'subtype'   => array(
                                                __( 'Title and Excerpt', 'avia_framework' )                 => 'excerpt',
                                                __( 'Title, Excerpt and Read More Link', 'avia_framework' ) => 'excerpt_read_more',
                                                __( 'Only Title', 'avia_framework' )                        => 'title',
                                                __( 'Title and Read More Link', 'avia_framework' )          => 'title_read_more',
                                                __( 'Only Excerpt', 'avia_framework' )                      => 'only_excerpt',
                                                __( 'Excerpt and Read More Link', 'avia_framework' )        => 'only_excerpt_read_more',
                                                __( 'No Title, no Excerpt', 'avia_framework' )              => 'no'
                                            )
                        ),
 
                );
 
            $template = array(
                            array(
                                'type'          => 'template',
                                'template_id'   => 'toggle',
                                'title'         => __( 'Content', 'avia_framework' ),
                                'content'       => $c
                            ),
                    );
 
            AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_excerpt' ), $template );
 
 
            /**
             * Styling Tab
             * ===========
             */
 
            $c = array(
                        array(
                            'name'      => __( 'Columns', 'avia_framework' ),
                            'desc'      => __( 'How many columns should be displayed?', 'avia_framework' ),
                            'id'        => 'columns',
                            'type'      => 'select',
                            'std'       => '3',
                            'lockable'  => true,
                            'subtype'   => array(
                                                __( '1 Columns', 'avia_framework' ) => '1',
                                                __( '2 Columns', 'avia_framework' ) => '2',
                                                __( '3 Columns', 'avia_framework' ) => '3',
                                                __( '4 Columns', 'avia_framework' ) => '4',
                                                __( '5 Columns', 'avia_framework' ) => '5',
                                            )
                        )
 
                );
 
            $template = array(
                            array(
                                'type'          => 'template',
                                'template_id'   => 'toggle',
                                'title'         => __( 'Columns', 'avia_framework' ),
                                'content'       => $c
                            ),
                    );
 
            AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_columns' ), $template );
 
            $c = array(
                        array(
                            'name'      => __( 'Preview Image Size', 'avia_framework' ),
                            'desc'      => __( 'Set the image size of the preview images', 'avia_framework' ),
                            'id'        => 'preview_mode',
                            'type'      => 'select',
                            'std'       => 'auto',
                            'lockable'  => true,
                            'subtype'   => array(
                                                __( 'Set the preview image size automatically based on column width', 'avia_framework' )    => 'auto',
                                                __( 'Choose the preview image size manually (select thumbnail size)', 'avia_framework' )    => 'custom'
                                            )
                        ),
 
                        array(
                            'name'      => __( 'Select custom preview image size', 'avia_framework' ),
                            'desc'      => __( 'Choose image size for Preview Image', 'avia_framework' ),
                            'id'        => 'image_size',
                            'type'      => 'select',
                            'std'       => 'portfolio',
                            'lockable'  => true,
                            'required'  => array( 'preview_mode', 'equals', 'custom' ),
                            'subtype'   =>  AviaHelper::get_registered_image_sizes( array( 'logo' ) )
                        )
                );
 
            $template = array(
                            array(
                                'type'          => 'template',
                                'template_id'   => 'toggle',
                                'title'         => __( 'Preview Image', 'avia_framework' ),
                                'content'       => $c
                            ),
                    );
 
            AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_image' ), $template );
 
 
            $c = array(
 
                        array(
                            'type'          => 'template',
                            'template_id'   => 'slideshow_controls',
                            'std_nav'       => 'av-navigate-arrows',
                            'lockable'      => true
                        )
 
                );
 
            $template = array(
                            array(
                                'type'          => 'template',
                                'template_id'   => 'toggle',
                                'title'         => __( 'Navigation Controls', 'avia_framework' ),
                                'content'       => $c
                            ),
                    );
 
            AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_navigation' ), $template );
 
            /**
             * Advanced Tab
             * ===========
             */
 
            $c = array(
/*
                        array(
                            'name'      => __( 'Post Slider Transition', 'avia_framework' ),
                            'desc'      => __( 'Choose the transition for your Post Slider.', 'avia_framework' ),
                            'id'        => 'animation',
                            'type'      => 'select',
                            'std'       => 'fade',
                            'subtype'   => array(
                                                __( 'Slide', 'avia_framework' ) => 'slide',
                                                __( 'Fade', 'avia_framework' )  => 'fade'
                                            ),
                        ),
*/
 
                        array(
                            'type'          => 'template',
                            'template_id'   => 'slideshow_rotation',
                            'select_vals'   => 'yes,no',
                            'stop_id'       => 'autoplay_stopper',
                            'lockable'      => true
                        )
 
                );
 
            $template = array(
                            array(
                                'type'          => 'template',
                                'template_id'   => 'toggle',
                                'title'         => __( 'Slider Animation', 'avia_framework' ),
                                'content'       => $c
                            ),
                    );
 
            AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_animation_slider' ), $template );
 
        }
 
        /**
         * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
         * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
         * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
         *
         * @param array $params         holds the default values for $content and $args.
         * @return array                usually holds an innerHtml key that holds item specific markup.
         */
        public function editor_element( $params )
        {
            $params = parent::editor_element( $params );
            $params['content'] = null; //remove to allow content elements
 
            return $params;
        }
 
        /**
         * Frontend Shortcode Handler
         *
         * @param array $atts array of attributes
         * @param string $content text within enclosing form of shortcode element
         * @param string $shortcodename the shortcode found, when == callback name
         * @return string $output returns the modified html string
         */
        public function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
        {
            $default = avia_post_slider::get_defaults();
 
            $locked = array();
            Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content );
            Avia_Element_Templates()->add_template_class( $meta, $atts, $default );
 
            $screen_sizes = AviaHelper::av_mobile_sizes( $atts );
 
            if( isset( $atts['img_scrset'] ) && 'disabled' == $atts['img_scrset'] )
            {
                Av_Responsive_Images()->force_disable( 'disabled' );
            }
 
            if( isset( $atts['link'] ) )
            {
                $atts['link'] = explode(',', $atts['link'], 2 );
                $atts['taxonomy'] = $atts['link'][0];
 
                if( isset( $atts['link'][1] ) )
                {
                    $atts['categories'] = $atts['link'][1];
                }
            }
 
            $atts['class'] = $meta['el_class'];
            $atts['el_id'] = $meta['custom_el_id'];
 
            $atts = array_merge( $atts, $screen_sizes );
 
            /**
             * @since 4.5.5
             * @return array
             */
            $atts = apply_filters( 'avf_post_slider_args', $atts, $this->config['shortcode'], $this );
 
            $slider = new avia_post_slider( $atts );
            $slider->query_entries();
            $html = $slider->html();
 
            Av_Responsive_Images()->force_disable( 'reset' );
 
            return $html;
        }
 
    }
}
 
 
if ( ! class_exists( 'avia_post_slider', false ) )
{
    /**
     * This class does not support post css files
     * ==========================================
     */
    class avia_post_slider
    {
        /**
         * @since < 4.0
         * @var int
         */
        static public $slide = 0;
 
        /**
         *
         * @since < 4.0
         * @var array
         */
        protected $atts;
 
        /**
         *
         * @since < 4.0
         * @var WP_Query
         */
        protected $entries;
 
        /**
         *
         * @since 4.7.6.4
         * @var int
         */
        protected $current_page;
 
        /**
         * @since < 4.0
         * @since 5.6           added to pass a WP_Query object
         * @param array $atts
         */
        public function __construct( $atts = array() )
        {
            $this->entries = null;
            $this->current_page = 1;
 
            if( isset( $atts['wp_query'] ) && $atts['wp_query'] instanceof WP_Query )
            {
                $this->entries = $atts['wp_query'];
                $this->set_posts_on_current_page();
            }
 
            $this->atts = shortcode_atts( avia_post_slider::get_defaults(), $atts, 'av_postslider' );
 
            if( ! in_array( $this->atts['slider_navigation'], array( 'av-navigate-arrows', 'av-navigate-dots', 'av-navigate-arrows av-navigate-dots' ) ) )
            {
                $this->atts['slider_navigation'] = 'av-navigate-arrows';
            }
 
            if( $this->atts['term_rel'] != 'AND' )
            {
                $this->atts['term_rel'] = 'IN';
            }
        }
 
        /**
         * @since 4.5.5
         */
        public function __destruct()
        {
            unset( $this->atts );
            unset( $this->entries );
        }
 
        /**
         * Returns the defaults array
         *
         * @since 4.8
         * @return array
         */
        static public function get_defaults()
        {
            $defaults = array(
                            'type'                  => 'slider', // can also be used as grid
                            'style'                 => '', //no_margin
                            'columns'               => '4',
                            'items'                 => '16',
                            'taxonomy'              => 'category',
                            'term_rel'              => 'IN',
                            'control_layout'        => 'av-control-default',
                            'slider_navigation'     => 'av-navigate-arrows',
                            'nav_visibility_desktop'    => '',
                            'wc_prod_visible'       => '',
                            'wc_prod_hidden'        => '',
                            'wc_prod_featured'      => '',
                            'wc_prod_sale'          => '',
                            'prod_order_by'         => '',
                            'prod_order'            => '',
                            'show_meta_data'        => '',      //  '' | 'always' | 'on_empty_title' | 'on_empty_content' (use filter to change)
                            'post_type'             => get_post_types(),
                            'contents'              => 'excerpt',
                            'preview_mode'          => 'auto',
                            'image_size'            => 'portfolio',
                            'animation'             => 'fade',
                            'transition_speed'      => '',
                            'autoplay'              => 'no',
                            'interval'              => 5,
                            'autoplay_stopper'      => '',
                            'manual_stopper'        => '',
                            'paginate'              => 'no',
                            'use_main_query_pagination' => 'no',
                            'class'                 => '',
                            'el_id'                 => '',
                            'categories'            => array(),
                            'custom_query'          => array(),
                            'offset'                => 0,
                            'custom_markup'         => '',
                            'av_display_classes'    => '',
                            'date_filter'           => '',
                            'date_filter_start'     => '',
                            'date_filter_end'       => '',
                            'date_filter_format'    => 'yy/mm/dd',      //  'yy/mm/dd' | 'dd-mm-yy' | yyyymmdd
                            'period_filter_unit_1'  => '',
                            'period_filter_unit_2'  => '',
                            'page_element_filter'   => '',
                            'lazy_loading'          => 'disabled',
                            'img_scrset'            => ''
            );
 
            return $defaults;
        }
 
        /**
         * @since 5.4
         * @return array
         */
        public function get_atts()
        {
            return $this->atts;
        }
 
        /**
         *
         * @since < 4.0
         * @return string
         */
 
 
 
 
// Umgestaltung der Ausgabe (Auszug, innerhalb der Klasse avia_post_slider)
 
      public function html()
      {
          $output = '';
 
          if( empty( $this->entries ) || ! $this->entries instanceof WP_Query || empty( $this->entries->posts ) )
          {
              return $output;
          }
 
          avia_post_slider::$slide ++;
          extract( $this->atts );
 
          if( $preview_mode == 'auto' )
          {
              $image_size = 'portfolio';
          }
 
          $extraClass        = 'first';
          $grid              = 'one_third';
          $post_loop_count   = 1;
          $loop_counter      = 1;
          $autoplay            = $autoplay == 'no' ? false : true;
          $total            = $columns % 2 ? 'odd' : 'even';
          $blogstyle         = function_exists( 'avia_get_option' ) ? avia_get_option( 'blog_global_style', '' ) : '';
          $excerpt_length    = 60;
          $total_posts       = $this->entries->post_count;
          $output_class      = 'avia-content-slider-wrap avia-content-slider-active ' . $style . ' ' . $class;
          $data              = 'data-autoplay="' . $autoplay . '" data-interval="' . $interval . '" data-animation="' . $animation . '" ';
          $data             .= 'data-manual_stopper="' . $manual_stopper . '" data-loop_once="' . $autoplay_stopper . '" ';
          $total_thumb_count = 0;
 
 
          if( ! in_array( $columns, array( 1, 2, 3, 4, 5 ) ) )
          {
              $columns = 3;
          }
 
          switch( $columns )
          {
              case '1':
                  $grid = 'no_margin';
                  break;
              case '2':
                  $grid = 'one_half';
                  break;
              case '3':
                  $grid = 'one_third';
                  break;
              case '4':
                  $grid = 'one_fourth';
                  break;
              case '5':
                  $grid = 'one_fifth';
                  break;
          }
 
          $this->set_posts_on_current_page();
 
          $output .= '<div ' . $data . ' class="' . $output_class . '">';
          $output .= '<div class="avia-content-slider-inner">';
 
// Hier wird die neue Klasse hinzugefügt
          $output .= '<div class="slide-entry-wrap av-postslider-columns-' . $columns . '">';
 
          while ( $this->entries->have_posts() ) : $this->entries->the_post();
 
              $current_post_data  = array();
              $current_post_data['format'] = get_post_format();
              if( empty( $current_post_data['format'] ) )
              {
                  $current_post_data['format'] = 'standard';
              }
              
              $current_post_data['permalink'] = get_permalink();
              $current_post_data['title'] = get_the_title();
              $current_post_data['content'] = get_the_excerpt();
              $current_post_data['author'] = get_the_author();
              $current_post_data['date'] = get_the_time(get_option('date_format'));
              $current_post_data['image'] = get_the_post_thumbnail(get_the_ID(), $image_size);
 
              $output .= '<article class="slide-entry flex_column ' . $grid . ' ' . $current_post_data['format'] . '">';
              $output .= '<div class="slide-entry-inner">';
              
// Platzhalte falls kein featured image da ist
  
              $output .= '<a href="' . $current_post_data['permalink'] . '" data-rel="slide-'. avia_post_slider::$slide .'" class="slide-image">';
              $output .= '    <span class="slide-overlay"></span>';
 
              // NEUER CODE FÜR DEN ENFOLD-STANDARD-PLATZHALTER
              if( empty( $current_post_data['image'] ) )
              {
                  // Hier ist der von Ihnen bereitgestellte SVG-Code
                  $output .= '<span class="fallback-post-type-icon avia-svg-icon avia-font-svg_entypo-fontello" data-av_svg_icon="link" data-av_iconset="svg_entypo-fontello"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="26" height="32" viewBox="0 0 26 32" preserveAspectRatio="xMidYMid meet" role="graphics-symbol" aria-hidden="true"><path d="M9.408 23.488q0.448-0.448 1.088-0.448t1.152 0.448q1.024 1.088 0 2.24l-1.344 1.28q-1.792 1.792-4.224 1.792-2.496 0-4.288-1.792t-1.792-4.224q0-2.496 1.792-4.288l4.736-4.736q2.24-2.176 4.608-2.464t4.096 1.376q0.512 0.512 0.512 1.152t-0.512 1.152q-1.152 1.024-2.24 0-1.6-1.536-4.224 1.088l-4.736 4.672q-0.832 0.832-0.832 2.048t0.832 1.984q0.832 0.832 2.016 0.832t2.016-0.832zM23.808 5.12q1.792 1.792 1.792 4.224 0 2.496-1.792 4.288l-5.056 5.056q-2.368 2.304-4.8 2.304-1.984 0-3.584-1.6-0.448-0.448-0.448-1.088t0.448-1.152q0.448-0.448 1.12-0.448t1.12 0.448q1.6 1.536 3.904-0.768l5.056-4.992q0.896-0.896 0.896-2.048 0-1.216-0.896-1.984-0.768-0.832-1.792-0.992t-1.92 0.672l-1.6 1.6q-0.512 0.448-1.152 0.448t-1.088-0.448q-1.088-1.088 0-2.24l1.6-1.6q1.728-1.728 4.064-1.632t4.128 1.952z"></path></svg></span>';
              } else {
                  $output .= $current_post_data['image'];
              }
              $output .= '</a>';
 
 
 
 
 
              $output .= '    <div class="slide-content">';
              $output .= '        <header class="entry-content-header">';
              $output .= '            <h3 class="slide-content-title">';
              $output .= '                <a href="' . $current_post_data['permalink'] . '" title="' . $current_post_data['title'] . '">' . $current_post_data['title'] . '</a>';
              $output .= '            </h3>';
              $output .= '            <div class="slide-meta">';
              $output .= '                <span class="blog-author minor-meta">' . $current_post_data['author'] . '</span>';
              $output .= '                <span class="text-sep">|</span>';
              $output .= '                <span class="blog-date minor-meta">' . $current_post_data['date'] . '</span>';
              $output .= '            </div>';
              $output .= '        </header>';
              $output .= '        <div class="entry-content">';
              $output .= '            ' . $current_post_data['content'];
              $output .= '        </div>';
              $output .= '    </div>';
              $output .= '    <footer class="entry-footer">';
              $output .= '         <a class="more-link" href="' . $current_post_data['permalink'] . '">' . __('Read more','avia_framework') . '<span class="avia_continue_reading_arrow"></span></a>';
              $output .= '    </footer>';
              $output .= '</div>';
              $output .= '</article>';
 
              $post_loop_count++;
              if($post_loop_count > $columns || $loop_counter == $total_posts)
              {
                  $post_loop_count = 1;
                  $extraClass = '';
              }
 
              $loop_counter++;
 
          endwhile;
 
          $output .= '</div>'; // Schließt den einzigen Wrapper div.slide-entry-wrap
 
 
          $output .= '</div>';
 
          if( false !== strpos( $slider_navigation, 'av-navigate-arrows' ) )
          {
              $output .= '<div class="avia-slideshow-arrows avia-slideshow-controls">';
              $output .= '    <a href="#prev" class="prev-slide">' . __('Previous','avia_framework') . '</a>';
              $output .= '    <a href="#next" class="next-slide">' . __('Next','avia_framework') . '</a>';
              $output .= '</div>';
          }
 
 
          if( false !== strpos( $slider_navigation, 'av-navigate-dots' ) && 'av-control-hidden' != $control_layout )
          {
              $output .= '<div class="avia-slideshow-dots avia-slideshow-controls">';
              $output .= '    <a data-avia-slide-to="1" href="#1" class="active-slide">' . '1' . '</a>';
 
              $counter = 2;
              while($counter <= $total_posts)
              {
                  $output .= '    <a data-avia-slide-to="' . $counter . '" href="#' . $counter . '">' . $counter . '</a>';
                  $counter++;
              }
              $output .= '</div>';
          }
 
          $output .= '</div>';
 
          wp_reset_query();
 
          return $output;
      }
 
 
 
// public funciton html ende
 
 
        /**
         * Create arrows to scroll slides
         *
         * @since 4.8.3         reroute to aviaFrontTemplates
         * @return string
         */
        protected function slide_navigation_arrows()
        {
            $args = array(
                        'context'   => get_class( $this ),
                        'params'    => $this->atts,
                        'svg_icon'  => true
                    );
 
            return aviaFrontTemplates::slide_navigation_arrows( $args );
        }
 
        /**
         * Create dots to scroll tabs
         *
         * @since 5.0           reroute to aviaFrontTemplates
         * @return string
         */
        protected function slide_navigation_dots()
        {
            $args = array(
                        'class_main'        => 'avia-slideshow-dots avia-slideshow-controls avia-post-slider fade-in',
                        'total_entries'     => $this->entries->post_count,
                        'container_entries' => $this->atts['columns'],
                        'context'           => get_class( $this ),
                        'params'            => $this->atts
                    );
 
            return aviaFrontTemplates::slide_navigation_dots( $args );
        }
 
        /**
         * Fetch new entries
         *
         * @since < 4.0
         * @param array $params
         */
        public function query_entries( $params = array() )
        {
            global $avia_config;
 
            if( empty( $params ) )
            {
                $params = $this->atts;
            }
 
            if( empty( $params['custom_query'] ) )
            {
                $query = array();
                $terms = array();
 
                if( ! empty( $params['categories'] ) )
                {
                    //get the portfolio categories
                    $terms = explode( ',', $params['categories'] );
                }
 
                if( $params['use_main_query_pagination'] == 'yes' )
                {
                    $this->current_page = ( $params['paginate'] != 'no' ) ? avia_get_current_pagination_number() : 1;
                }
                else
                {
                    $this->current_page = ( $params['paginate'] != 'no' ) ? avia_get_current_pagination_number( 'avia-element-paging' ) : 1;
                }
 
                //if we find no terms for the taxonomy fetch all taxonomy terms
                if( empty( $terms[0] ) || is_null( $terms[0] ) || $terms[0] === 'null' )
                {
                    $term_args = array(
                                'taxonomy'      => $params['taxonomy'],
                                'hide_empty'    => true
                            );
                    /**
                     * To display private posts you need to set 'hide_empty' to false,
                     * otherwise a category with ONLY private posts will not be returned !!
                     *
                     * You also need to add post_status 'private' to the query params with filter avia_post_slide_query.
                     *
                     * @since 4.4.2
                     * @added_by Günter
                     * @param array $term_args
                     * @param array $params
                     * @return array
                     */
                    $term_args = apply_filters( 'avf_av_postslider_term_args', $term_args, $params );
 
                    $allTax = AviaHelper::get_terms( $term_args );
 
                    $terms = array();
                    foreach( $allTax as $tax )
                    {
                        $terms[] = $tax->term_id;
                    }
                }
 
                if( $params['offset'] == 'no_duplicates' )
                {
                    $params['offset'] = false;
                    $no_duplicates = true;
                }
 
                //wordpress 4.4 offset fix
                if( $params['offset'] == 0 )
                {
                    $params['offset'] = false;
                }
                else
                {
                    //if the offset is set the paged param is ignored. therefore we need to factor in the page number
                    $params['offset'] = $params['offset'] + ( ( $this->current_page - 1 ) * $params['items'] );
                }
 
                if( empty( $params['post_type'] ) )
                {
                    $params['post_type'] = get_post_types();
                }
 
                if( is_string($params['post_type'] ) )
                {
                    $params['post_type'] = explode( ',', $params['post_type'] );
                }
 
                $orderby = 'date';
                $order = 'DESC';
 
                $date_query = AviaHelper::date_query( array(), $params );
 
                // Meta query - replaced by Tax query in WC 3.0.0
                $meta_query = array();
                $tax_query = array();
 
 
                // check if taxonomy are set to product or product attributes
                $tax = get_taxonomy( $params['taxonomy'] );
 
                if( class_exists( 'WooCommerce', false ) && is_object( $tax ) && isset( $tax->object_type ) && in_array( 'product', (array) $tax->object_type ) )
                {
                    $avia_config['woocommerce']['disable_sorting_options'] = true;
 
                    avia_wc_set_out_of_stock_query_params( $meta_query, $tax_query, $params['wc_prod_visible'] );
                    avia_wc_set_hidden_prod_query_params( $meta_query, $tax_query, $params['wc_prod_hidden'] );
                    avia_wc_set_featured_prod_query_params( $meta_query, $tax_query, $params['wc_prod_featured'] );
                    avia_wc_set_on_sale_prod_query_params( $meta_query, $tax_query, $params['wc_prod_sale'] );
 
                        //  sets filter hooks !!
                    $ordering_args = avia_wc_get_product_query_order_args( $params['prod_order_by'], $params['prod_order'] );
 
                    $orderby = $ordering_args['orderby'];
                    $order = $ordering_args['order'];
                    $params['meta_key'] = $ordering_args['meta_key'];
                }
 
                if( ! empty( $terms ) )
                {
                    $tax_query[] = array(
                                        'taxonomy'  =>  $params['taxonomy'],
                                        'field'     =>  'id',
                                        'terms'     =>  $terms,
                                        'operator'  =>  count( $terms ) == 1 ? 'IN' : $params['term_rel']
                                );
                }
 
                $query = array(
                                'orderby'       => $orderby,
                                'order'         => $order,
                                'paged'         => $this->current_page,
                                'post_type'     => $params['post_type'],
//                              'post_status'   => 'publish',
                                'offset'        => $params['offset'],
                                'posts_per_page' => $params['items'],
                                'post__not_in'  => ( ! empty( $no_duplicates ) ) ? $avia_config['posts_on_current_page'] : array(),
                                'meta_query'    => $meta_query,
                                'tax_query'     => $tax_query,
                                'date_query'    => $date_query
                            );
            }
            else
            {
                $query = $params['custom_query'];
            }
 
            if( ! empty( $params['meta_key'] ) )
            {
                $query['meta_key'] = $params['meta_key'];
            }
 
            if( 'skip_current' == $params['page_element_filter'] )
            {
                $query['post__not_in'] = isset( $query['post__not_in'] ) ? $query['post__not_in'] : [];
                $query['post__not_in'][] = get_the_ID();
            }
 
            /**
             * @used_by             config-bbpress\config.php   avia_remove_bbpress_post_type_from_query()          10
             * @used_by             config-wpml\config.php      avia_translate_ids_from_query                       10
             * @used_by             avia_WPML::handler_avia_post_slide_query                                        20
             *
             * @since < 4.0
             * @param array $query
             * @param array $params
             * @return array
             */
            $query = apply_filters( 'avia_post_slide_query', $query, $params );
 
            @$this->entries = new WP_Query( $query ); //@ is used to prevent errors caused by wpml
 
            $this->set_posts_on_current_page();
 
            if( function_exists( 'WC' ) )
            {
                avia_wc_clear_catalog_ordering_args_filters();
                $avia_config['woocommerce']['disable_sorting_options'] = false;
            }
        }
 
        /**
         * Store the queried post ids in $avia_config
         *
         * @since 5.6
         */
        protected function set_posts_on_current_page()
        {
            global $avia_config;
 
            if( ! $this->entries instanceof WP_Query )
            {
                return;
            }
 
            if( $this->entries->post_count > 0 )
            {
                foreach( $this->entries->posts as $entry )
                {
                    $avia_config['posts_on_current_page'][] = $entry->ID;
                }
            }
        }
    }
}
 
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎