cipher87

Change meta format

May 17th, 2018
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 32.05 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Post Slider
  4.  *
  5.  * Display a Slideshow of Post Entries
  6.  * Element is in Beta and by default disabled. 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
  7.  *
  8.  * https://kriesi.at/support/topic/change-meta-infos-on-blog-grid/#post-957218
  9.  *
  10.  */
  11. if ( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  12.  
  13.  
  14. if ( !class_exists( 'avia_sc_postslider' ))
  15. {
  16.     class avia_sc_postslider extends aviaShortcodeTemplate
  17.     {
  18.  
  19.         /**
  20.          * Create the config array for the shortcode button
  21.          */
  22.         function shortcode_insert_button()
  23.         {
  24.             $this->config['self_closing']   =   'yes';
  25.            
  26.             $this->config['name']       = __('Post Slider', 'avia_framework' );
  27.             $this->config['tab']        = __('Content Elements', 'avia_framework' );
  28.             $this->config['icon']       = AviaBuilder::$path['imagesURL']."sc-postslider.png";
  29.             $this->config['order']      = 30;
  30.             $this->config['target']     = 'avia-target-insert';
  31.             $this->config['shortcode']  = 'av_postslider';
  32.             $this->config['tooltip']    = __('Display a Slideshow of Post Entries', 'avia_framework' );
  33.             $this->config['drag-level'] = 3;
  34.             $this->config['disabling_allowed'] = true;
  35.         }
  36.        
  37.        
  38.         function extra_assets()
  39.         {
  40.             //load css
  41.             wp_enqueue_style( 'avia-module-slideshow' , AviaBuilder::$path['pluginUrlRoot'].'avia-shortcodes/slideshow/slideshow.css' , array('avia-layout'), false );
  42.             wp_enqueue_style( 'avia-module-postslider' , AviaBuilder::$path['pluginUrlRoot'].'avia-shortcodes/postslider/postslider.css' , array('avia-module-slideshow'), false );
  43.            
  44.                 //load js
  45.             wp_enqueue_script( 'avia-module-slideshow' , AviaBuilder::$path['pluginUrlRoot'].'avia-shortcodes/slideshow/slideshow.js' , array('avia-shortcodes'), false, TRUE );
  46.  
  47.        
  48.         }
  49.  
  50.         /**
  51.          * Popup Elements
  52.          *
  53.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  54.          * opens a modal window that allows to edit the element properties
  55.          *
  56.          * @return void
  57.          */
  58.         function popup_elements()
  59.         {
  60.             $this->elements = array(
  61.                 array(
  62.                         "type"  => "tab_container", 'nodescription' => true
  63.                     ),
  64.                    
  65.                 array(
  66.                         "type"  => "tab",
  67.                         "name"  => __("Content" , 'avia_framework'),
  68.                         'nodescription' => true
  69.                     ),
  70.                 array(
  71.                         "name"  => __("Which Entries?", 'avia_framework' ),
  72.                         "desc"  => __("Select which entries should be displayed by selecting a taxonomy", 'avia_framework' ),
  73.                         "id"    => "link",
  74.                         "fetchTMPL" => true,
  75.                         "type"  => "linkpicker",
  76.                         "subtype"  => array( __('Display Entries from:',  'avia_framework' )=>'taxonomy'),
  77.                         "multiple"  => 6,
  78.                         "std"   => "category"
  79.                 ),
  80.                
  81.                 array(
  82.                         "name"  => __("WooCommerce Product visibility?", 'avia_framework' ),
  83.                         "desc"  => __("Select the visibility of WooCommerce products. Default setting can be set at Woocommerce -&gt Settings -&gt Products -&gt Inventory -&gt Out of stock visibility", 'avia_framework' ),
  84.                         "id"    => "wc_prod_visible",
  85.                         "type"  => "select",
  86.                         "std"   => "",
  87.                         "required" => array( 'link', 'parent_in_array', implode( ' ', get_object_taxonomies( 'product', 'names' ) ) ),
  88.                         "subtype" => array(
  89.                             __('Use default WooCommerce Setting (Settings -&gt; Products -&gt; Out of stock visibility)',  'avia_framework' ) => '',
  90.                             __('Hide products out of stock',  'avia_framework' ) => 'hide',
  91.                             __('Show products out of stock',  'avia_framework' )  => 'show')
  92.                     ),
  93.                
  94.                 array(
  95.                         "name"  => __( "Sorting Options", 'avia_framework' ),
  96.                         "desc"  => __( "Here you can choose how to sort the products. Default setting can be set at Woocommerce -&gt Settings -&gt Products -&gt Display -&gt Default product sorting", 'avia_framework' ),
  97.                         "id"    => "prod_order_by",
  98.                         "type"  => "select",
  99.                         "std"   => "",
  100.                         "required" => array( 'link', 'parent_in_array', implode( ' ', get_object_taxonomies( 'product', 'names' ) ) ),
  101.                         "subtype" => array(
  102.                                 __('Use defaut (defined at Woocommerce -&gt; Settings -&gt Default product sorting) ', 'avia_framework' ) =>    '',
  103.                                 __('Sort alphabetically', 'avia_framework' )            =>  'title',
  104.                                 __('Sort by most recent', 'avia_framework' )            =>  'date',
  105.                                 __('Sort by price', 'avia_framework' )                  =>  'price',
  106.                                 __('Sort by popularity', 'avia_framework' )             =>  'popularity',
  107.                                 __('Sort randomly', 'avia_framework' )                  =>  'rand'
  108.                             )
  109.                     ),
  110.                
  111.                 array(
  112.                         "name"  => __( "Sorting Order", 'avia_framework' ),
  113.                         "desc"  => __( "Here you can choose the order of the result products. Default setting can be set at Woocommerce -&gt Settings -&gt Products -&gt Display -&gt Default product sorting", 'avia_framework' ),
  114.                         "id"    => "prod_order",
  115.                         "type"  => "select",
  116.                         "std"   => "",
  117.                         "required" => array( 'link', 'parent_in_array', implode( ' ', get_object_taxonomies( 'product', 'names' ) ) ),
  118.                         "subtype" => array(
  119.                                 __('Use defaut (defined at Woocommerce -&gt Settings -&gt Default product sorting)', 'avia_framework' ) =>  '',
  120.                                 __('Ascending', 'avia_framework' )          =>  'ASC',
  121.                                 __('Descending', 'avia_framework' )         =>  'DESC'
  122.                             )
  123.                     ),
  124.  
  125.                 array(
  126.                         "name"  => __("Columns", 'avia_framework' ),
  127.                         "desc"  => __("How many columns should be displayed?", 'avia_framework' ),
  128.                         "id"    => "columns",
  129.                         "type"  => "select",
  130.                         "std"   => "3",
  131.                         "subtype" => array( __('1 Columns', 'avia_framework' )=>'1',
  132.                                             __('2 Columns', 'avia_framework' )=>'2',
  133.                                             __('3 Columns', 'avia_framework' )=>'3',
  134.                                             __('4 Columns', 'avia_framework' )=>'4',
  135.                                             __('5 Columns', 'avia_framework' )=>'5',
  136.                                             )),
  137.                 array(
  138.                         "name"  => __("Entry Number", 'avia_framework' ),
  139.                         "desc"  => __("How many items should be displayed?", 'avia_framework' ),
  140.                         "id"    => "items",
  141.                         "type"  => "select",
  142.                         "std"   => "9",
  143.                         "subtype" => AviaHtmlHelper::number_array(1,100,1, array('All'=>'-1'))),
  144.  
  145.                 array(
  146.                     "name"  => __("Offset Number", 'avia_framework' ),
  147.                     "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' ),
  148.                     "id"    => "offset",
  149.                     "type"  => "select",
  150.                     "std"   => "0",
  151.                     "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'))),
  152.  
  153.                 array(
  154.                         "name"  => __("Title and Excerpt",'avia_framework' ),
  155.                         "desc"  => __("Choose if you want to only display the post title or title and excerpt",'avia_framework' ),
  156.                         "id"    => "contents",
  157.                         "type"  => "select",
  158.                         "std"   => "excerpt",
  159.                         "subtype" => array(
  160.                             __('Title and Excerpt',  'avia_framework' ) =>'excerpt',
  161.                             __('Title and Excerpt + Read More Link',  'avia_framework' ) =>'excerpt_read_more',
  162.                             __('Only Title',  'avia_framework' ) =>'title',
  163.                             __('Only Title + Read More Link',  'avia_framework' ) =>'title_read_more',
  164.                             __('Only excerpt',  'avia_framework' ) =>'only_excerpt',
  165.                             __('Only excerpt + Read More Link',  'avia_framework' ) =>'only_excerpt_read_more',
  166.                             __('No Title and no excerpt',  'avia_framework' ) =>'no')),
  167.  
  168.                 array(
  169.                             "name"  => __("Preview Image Size", 'avia_framework' ),
  170.                             "desc"  => __("Set the image size of the preview images", 'avia_framework' ),
  171.                             "id"    => "preview_mode",
  172.                             "type"  => "select",
  173.                             "std"   => "auto",
  174.                             "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')),
  175.  
  176.                 array(
  177.                             "name"  => __("Select custom preview image size", 'avia_framework' ),
  178.                             "desc"  => __("Choose image size for Preview Image", 'avia_framework' ),
  179.                             "id"    => "image_size",
  180.                             "type"  => "select",
  181.                             "required"  => array('preview_mode','equals','custom'),
  182.                             "std"   => "portfolio",
  183.                             "subtype" =>  AviaHelper::get_registered_image_sizes(array('logo'))
  184.                             ),
  185.                
  186.                 /*
  187. array(
  188.                             "name"  => __("Post Slider Transition", 'avia_framework' ),
  189.                             "desc"  => __("Choose the transition for your Post Slider.", 'avia_framework' ),
  190.                             "id"    => "animation",
  191.                             "type"  => "select",
  192.                             "std"   => "fade",
  193.                             "subtype" => array(__('Slide','avia_framework' ) =>'slide',__('Fade','avia_framework' ) =>'fade'),
  194.                             ),
  195. */
  196.                
  197.                
  198.                 array(
  199.                         "name"  => __("Autorotation active?",'avia_framework' ),
  200.                         "desc"  => __("Check if the slideshow should rotate by default",'avia_framework' ),
  201.                         "id"    => "autoplay",
  202.                         "type"  => "select",
  203.                         "std"   => "no",
  204.                         "subtype" => array(__('Yes','avia_framework' ) =>'yes',__('No','avia_framework' ) =>'no')),
  205.  
  206.                 array(
  207.                     "name"  => __("Slideshow autorotation duration",'avia_framework' ),
  208.                     "desc"  => __("Slideshow will rotate every X seconds",'avia_framework' ),
  209.                     "id"    => "interval",
  210.                     "type"  => "select",
  211.                     "std"   => "5",
  212.                     "required"  => array('autoplay','equals','yes'),
  213.                     "subtype" =>
  214.                     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')),
  215.                    
  216.                    
  217.                 array(
  218.                             "type"  => "close_div",
  219.                             'nodescription' => true
  220.                         ),
  221.                        
  222.                        
  223.                                 array(
  224.                                     "type"  => "tab",
  225.                                     "name"  => __("Screen Options",'avia_framework' ),
  226.                                     'nodescription' => true
  227.                                 ),
  228.                                
  229.                                
  230.                                 array(
  231.                                 "name"  => __("Element Visibility",'avia_framework' ),
  232.                                 "desc"  => __("Set the visibility for this element, based on the device screensize.", 'avia_framework' ),
  233.                                 "type"  => "heading",
  234.                                 "description_class" => "av-builder-note av-neutral",
  235.                                 ),
  236.                            
  237.                                 array( 
  238.                                         "desc"  => __("Hide on large screens (wider than 990px - eg: Desktop)", 'avia_framework'),
  239.                                         "id"    => "av-desktop-hide",
  240.                                         "std"   => "",
  241.                                         "container_class" => 'av-multi-checkbox',
  242.                                         "type"  => "checkbox"),
  243.                                
  244.                                 array( 
  245.                                    
  246.                                         "desc"  => __("Hide on medium sized screens (between 768px and 989px - eg: Tablet Landscape)", 'avia_framework'),
  247.                                         "id"    => "av-medium-hide",
  248.                                         "std"   => "",
  249.                                         "container_class" => 'av-multi-checkbox',
  250.                                         "type"  => "checkbox"),
  251.                                        
  252.                                 array( 
  253.                                    
  254.                                         "desc"  => __("Hide on small screens (between 480px and 767px - eg: Tablet Portrait)", 'avia_framework'),
  255.                                         "id"    => "av-small-hide",
  256.                                         "std"   => "",
  257.                                         "container_class" => 'av-multi-checkbox',
  258.                                         "type"  => "checkbox"),
  259.                                        
  260.                                 array( 
  261.                                    
  262.                                         "desc"  => __("Hide on very small screens (smaller than 479px - eg: Smartphone Portrait)", 'avia_framework'),
  263.                                         "id"    => "av-mini-hide",
  264.                                         "std"   => "",
  265.                                         "container_class" => 'av-multi-checkbox',
  266.                                         "type"  => "checkbox"),
  267.    
  268.                                
  269.                             array(
  270.                                     "type"  => "close_div",
  271.                                     'nodescription' => true
  272.                                 ), 
  273.                                
  274.                                
  275.                        
  276.                        
  277.                     array(
  278.                         "type"  => "close_div",
  279.                         'nodescription' => true
  280.                     ), 
  281.                    
  282.  
  283.                 );
  284.  
  285.  
  286.                 if(current_theme_supports('add_avia_builder_post_type_option'))
  287.                 {
  288.                     $element = array(
  289.                         "name"  => __("Select Post Type", 'avia_framework' ),
  290.                         "desc"  => __("Select which post types should be used. Note that your taxonomy will be ignored if you do not select an assign post type.
  291.                                      If yo don't select post type all registered post types will be used", 'avia_framework' ),
  292.                         "id"    => "post_type",
  293.                         "type"  => "select",
  294.                         "multiple"  => 6,
  295.                         "std"   => "",
  296.                         "subtype" => AviaHtmlHelper::get_registered_post_type_array()
  297.                     );
  298.  
  299.                     array_splice($this->elements, 2, 0, array($element));
  300.                 }
  301.         }
  302.  
  303.         /**
  304.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  305.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  306.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  307.          *
  308.          *
  309.          * @param array $params this array holds the default values for $content and $args.
  310.          * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  311.          */
  312.         function editor_element($params)
  313.         {
  314.             $params['innerHtml'] = "<img src='".$this->config['icon']."' title='".$this->config['name']."' />";
  315.             $params['innerHtml'].= "<div class='avia-element-label'>".$this->config['name']."</div>";
  316.             $params['content']   = NULL; //remove to allow content elements
  317.             return $params;
  318.         }
  319.  
  320.  
  321.  
  322.         /**
  323.          * Frontend Shortcode Handler
  324.          *
  325.          * @param array $atts array of attributes
  326.          * @param string $content text within enclosing form of shortcode element
  327.          * @param string $shortcodename the shortcode found, when == callback name
  328.          * @return string $output returns the modified html string
  329.          */
  330.         function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
  331.         {  
  332.             $screen_sizes = AviaHelper::av_mobile_sizes($atts);
  333.            
  334.             if(isset($atts['link']))
  335.             {
  336.                 $atts['link'] = explode(',', $atts['link'], 2 );
  337.                 $atts['taxonomy'] = $atts['link'][0];
  338.  
  339.                 if(isset($atts['link'][1]))
  340.                 {
  341.                     $atts['categories'] = $atts['link'][1];
  342.                 }
  343.             }
  344.  
  345.             $atts['class'] = $meta['el_class'];
  346.             $atts = array_merge($atts, $screen_sizes);
  347.            
  348.             $slider = new avia_post_slider($atts);
  349.             $slider->query_entries();
  350.             return $slider->html();
  351.         }
  352.  
  353.     }
  354. }
  355.  
  356.  
  357.  
  358.  
  359. if ( !class_exists( 'avia_post_slider' ) )
  360. {
  361.     class avia_post_slider
  362.     {  
  363.         static  $slide = 0;
  364.         protected $atts;
  365.         protected $entries;
  366.  
  367.         function __construct($atts = array())
  368.         {
  369.             $this->atts = shortcode_atts(array( 'type'      => 'slider', // can also be used as grid
  370.                                                 'style'     => '', //no_margin
  371.                                                 'columns'   => '4',
  372.                                                 'items'     => '16',
  373.                                                 'taxonomy'  => 'category',
  374.                                                 'wc_prod_visible'   =>  '',
  375.                                                 'prod_order_by'     =>  '',
  376.                                                 'prod_order'        =>  '',
  377.                                                 'post_type'=> get_post_types(),
  378.                                                 'contents'  => 'excerpt',
  379.                                                 'preview_mode' => 'auto',
  380.                                                 'image_size' => 'portfolio',
  381.                                                 'autoplay'  => 'no',
  382.                                                 'animation' => 'fade',
  383.                                                 'paginate'  => 'no',
  384.                                                 'use_main_query_pagination' => 'no',
  385.                                                 'interval'  => 5,
  386.                                                 'class'     => '',
  387.                                                 'categories'=> array(),
  388.                                                 'custom_query'=> array(),
  389.                                                 'offset' => 0,
  390.                                                 'custom_markup' => '',
  391.                                                 'av_display_classes' => ''
  392.                                                 ), $atts, 'av_postslider');
  393.                                                
  394.                            
  395.         }
  396.  
  397.         public function html()
  398.         {
  399.             global $avia_config;
  400.  
  401.             $output = "";
  402.  
  403.             if(empty($this->entries) || empty($this->entries->posts)) return $output;
  404.  
  405.             avia_post_slider::$slide ++;
  406.             extract($this->atts);
  407.  
  408.             if($preview_mode == 'auto') $image_size = 'portfolio';
  409.             $extraClass         = 'first';
  410.             $grid               = 'one_third';
  411.             $post_loop_count    = 1;
  412.             $loop_counter       = 1;
  413.             $autoplay           = $autoplay == "no" ? false : true;
  414.             $total              = $columns % 2 ? "odd" : "even";
  415.             $blogstyle          = function_exists('avia_get_option') ? avia_get_option('blog_global_style','') : "";
  416.             $excerpt_length     = 60;
  417.            
  418.            
  419.             if($blogstyle !== "")
  420.             {
  421.                 $excerpt_length = 240;
  422.             }
  423.            
  424.             switch($columns)
  425.             {
  426.                 case "1": $grid = 'av_fullwidth';  if($preview_mode == 'auto') $image_size = 'large'; break;
  427.                 case "2": $grid = 'av_one_half';   break;
  428.                 case "3": $grid = 'av_one_third';  break;
  429.                 case "4": $grid = 'av_one_fourth'; if($preview_mode == 'auto') $image_size = 'portfolio_small'; break;
  430.                 case "5": $grid = 'av_one_fifth';  if($preview_mode == 'auto') $image_size = 'portfolio_small'; break;
  431.             }
  432.  
  433.  
  434.             $data = AviaHelper::create_data_string(array('autoplay'=>$autoplay, 'interval'=>$interval, 'animation' => $animation, 'show_slide_delay'=>90));
  435.  
  436.             $thumb_fallback = "";
  437.             $markup = avia_markup_helper(array('context' => 'blog','echo'=>false, 'custom_markup'=>$custom_markup));
  438.             $output .= "<div {$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>";
  439.             $output .=      "<div class='avia-content-slider-inner'>";
  440.  
  441.                 foreach ($this->entries->posts as $entry)
  442.                 {
  443.                     $the_id     = $entry->ID;
  444.                     $parity     = $loop_counter % 2 ? 'odd' : 'even';
  445.                     $last       = $this->entries->post_count == $post_loop_count ? " post-entry-last " : "";
  446.                     $post_class = "post-entry post-entry-{$the_id} slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";
  447.                     $link       = get_post_meta( $the_id ,'_portfolio_custom_link', true ) != "" ? get_post_meta( $the_id ,'_portfolio_custom_link_url', true ) : get_permalink( $the_id );
  448.                     $excerpt    = "";
  449.                     $title      = '';
  450.                     $show_meta  = !is_post_type_hierarchical($entry->post_type);
  451.                     $commentCount = get_comments_number($the_id);
  452.                     $thumbnail  = get_the_post_thumbnail( $the_id, $image_size );
  453.                     $format     = get_post_format( $the_id );
  454.                     if(empty($format)) $format = "standard";
  455.  
  456.                     if($thumbnail)
  457.                     {
  458.                         $thumb_fallback = $thumbnail;
  459.                         $thumb_class    = "real-thumbnail";
  460.                     }
  461.                     else
  462.                     {
  463.                         $thumbnail = "<span class=' fallback-post-type-icon' ".av_icon_string($format)."></span><span class='slider-fallback-image'>{{thumbnail}}</span>";
  464.                         $thumb_class    = "fake-thumbnail";
  465.                     }
  466.  
  467.  
  468.                     $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>';
  469.                     $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, '');
  470.  
  471.                             if($format == 'link')
  472.                             {
  473.                                     $current_post = array();
  474.                                     $current_post['content'] = $entry->post_content;
  475.                                     $current_post['title'] =  $entry->post_title;
  476.                                    
  477.                                     if(function_exists('avia_link_content_filter'))
  478.                                     {
  479.                                         $current_post = avia_link_content_filter($current_post);
  480.                                     }
  481.            
  482.                                     $link = $current_post['url'];
  483.                                 }
  484.                            
  485.                    
  486.                     switch($contents)
  487.                     {
  488.                         case "excerpt":
  489.                                 $excerpt = $prepare_excerpt;
  490.                                 $title = $entry->post_title;
  491.                                 break;
  492.                         case "excerpt_read_more":
  493.                                 $excerpt = $prepare_excerpt;
  494.                                 $excerpt .= $permalink;
  495.                                 $title = $entry->post_title;
  496.                                 break;
  497.                         case "title":
  498.                                 $excerpt = '';
  499.                                 $title = $entry->post_title;
  500.                                 break;
  501.                         case "title_read_more":
  502.                                 $excerpt = $permalink;
  503.                                 $title = $entry->post_title;
  504.                                 break;
  505.                         case "only_excerpt":
  506.                                 $excerpt = $prepare_excerpt;
  507.                                 $title = '';
  508.                                 break;
  509.                         case "only_excerpt_read_more":
  510.                                 $excerpt = $prepare_excerpt;
  511.                                 $excerpt .= $permalink;
  512.                                 $title = '';
  513.                                 break;
  514.                         case "no":
  515.                                 $excerpt = '';
  516.                                 $title = '';
  517.                                 break;
  518.                     }
  519.                    
  520.                     $title = apply_filters( 'avf_postslider_title', $title, $entry );
  521.                    
  522.                     if($loop_counter == 1) $output .= "<div class='slide-entry-wrap'>";
  523.                    
  524.                     $post_format = get_post_format($the_id) ? get_post_format($the_id) : 'standard';
  525.                    
  526.                     $markup = avia_markup_helper(array('context' => 'entry','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup));
  527.                     $output .= "<article class='slide-entry flex_column {$style} {$post_class} {$grid} {$extraClass} {$thumb_class}' $markup>";
  528.                     $output .= $thumbnail ? "<a href='{$link}' data-rel='slide-".avia_post_slider::$slide."' class='slide-image' title=''>{$thumbnail}</a>" : "";
  529.                    
  530.                     if($post_format == "audio")
  531.                     {  
  532.                         $current_post = array();
  533.                         $current_post['content'] = $entry->post_content;
  534.                         $current_post['title'] =  $entry->post_title;
  535.                        
  536.                         $current_post = apply_filters( 'post-format-'.$post_format, $current_post );
  537.                        
  538.                         if(!empty( $current_post['before_content'] )) $output .= '<div class="big-preview single-big audio-preview">'.$current_post['before_content'].'</div>';
  539.                     }
  540.                    
  541.                     $output .= "<div class='slide-content'>";
  542.  
  543.                     $markup = avia_markup_helper(array('context' => 'entry_title','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup));
  544.                     $output .= '<header class="entry-content-header">';
  545.                     $meta_out = "";
  546.                    
  547.                     if (!empty($title))
  548.                     {
  549.                         if($show_meta)
  550.                         {
  551.                             $taxonomies  = get_object_taxonomies(get_post_type($the_id));
  552.                             $cats = '';
  553.                             $excluded_taxonomies = array_merge( get_taxonomies( array( 'public' => false ) ), array('post_tag','post_format') );
  554.                             $excluded_taxonomies = apply_filters('avf_exclude_taxonomies', $excluded_taxonomies, get_post_type($the_id), $the_id);
  555.            
  556.                             if(!empty($taxonomies))
  557.                             {
  558.                                 foreach($taxonomies as $taxonomy)
  559.                                 {
  560.                                     if(!in_array($taxonomy, $excluded_taxonomies))
  561.                                     {
  562.                                         $cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
  563.                                     }
  564.                                 }
  565.                             }
  566.                            
  567.                             if(!empty($cats))
  568.                             {
  569.                                 $meta_out .= '<span class="blog-categories minor-meta">';
  570.                                 $meta_out .= $cats;
  571.                                 $meta_out .= '</span>';
  572.                             }
  573.                         }
  574.                        
  575.                         /**
  576.                          * Allow to change default output of categories - by default supressed for setting Default(Business) blog style
  577.                          *
  578.                          * @since 4.0.6
  579.                          * @param string $blogstyle                     '' | 'elegant-blog' | 'elegant-blog modern-blog'
  580.                          * @param avia_post_slider $this
  581.                          * @return string                               'show_elegant' | 'show_business' | 'use_theme_default' | 'no_show_cats'
  582.                          */
  583.                         $show_cats = apply_filters( 'avf_postslider_show_catergories', 'use_theme_default', $blogstyle, $this );
  584.                        
  585.                         switch( $show_cats )
  586.                         {
  587.                             case 'no_show_cats':
  588.                                 $new_blogstyle = '';
  589.                                 break;
  590.                             case 'show_elegant':
  591.                                 $new_blogstyle = 'elegant-blog';
  592.                                 break;
  593.                             case 'show_business':
  594.                                 $new_blogstyle = 'elegant-blog modern-blog';
  595.                                 break;
  596.                             case 'use_theme_default':
  597.                             default:
  598.                                 $new_blogstyle = $blogstyle;
  599.                                 break;
  600.                         }
  601.                        
  602.                             //  elegant style
  603.                         if( ( strpos( $new_blogstyle, 'modern-blog' ) === false ) && ( $new_blogstyle != "" ) )
  604.                         {
  605.                             $output .= $meta_out;
  606.                         }
  607.                        
  608.                         $output .=  "<h3 class='slide-entry-title entry-title' $markup><a href='{$link}' title='".esc_attr(strip_tags($title))."'>".$title."</a></h3>";
  609.                        
  610.                             //  modern business style
  611.                         if( ( strpos( $new_blogstyle, 'modern-blog' ) !== false ) && ( $new_blogstyle != "" ) )
  612.                         {
  613.                             $output .= $meta_out;
  614.                         }
  615.                        
  616.                         $output .= '<span class="av-vertical-delimiter"></span>';
  617.                     }
  618.                    
  619.                     $output .= '</header>';
  620.  
  621.                     if($show_meta && !empty($excerpt))
  622.                     {
  623.                         $meta  = "<div class='slide-meta'>";
  624.                         $markup = avia_markup_helper(array('context' => 'entry_time','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup));
  625.                         $meta .= "<time class='slide-meta-time updated' $markup>" .get_the_time(get_option('date_format'), $the_id)."</time><div class='slide-meta-del'>/</div>";
  626.                         $meta .= strtoupper( get_the_author() );
  627.                         if ( $commentCount != "0" || comments_open($the_id) && $entry->post_type != 'portfolio')
  628.                         {
  629.                             $link_add = $commentCount === "0" ? "#respond" : "#comments";
  630.                             $text_add = $commentCount === "1" ? __('Comment', 'avia_framework' ) : __('Comments', 'avia_framework' );
  631.  
  632.                             $meta .= "<div class='slide-meta-comments'><a href='{$link}{$link_add}'>{$commentCount} {$text_add}</a></div>";
  633.                         }
  634.                         $meta .= "</div>";
  635.                        
  636.                         if( strpos($blogstyle, 'elegant-blog') === false )
  637.                         {
  638.                             $output .= $meta;
  639.                             $meta = "";
  640.                         }
  641.                     }
  642.                     $markup = avia_markup_helper(array('context' => 'entry_content','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup));
  643.                     $excerpt = apply_filters( 'avf_post_slider_entry_excerpt', $excerpt, $prepare_excerpt, $permalink, $entry );
  644.                     $output .= !empty($excerpt) ? "<div class='slide-entry-excerpt entry-content' $markup>".$excerpt."</div>" : "";
  645.  
  646.                     $output .= "</div>";
  647.                     $output .= '<footer class="entry-footer">';
  648.                     if( !empty($meta) ) $output .= $meta;
  649.                     $output .= '</footer>';
  650.                    
  651.                     $output .= av_blog_entry_markup_helper( $the_id );
  652.                    
  653.                     $output .= "</article>";
  654.  
  655.                     $loop_counter ++;
  656.                     $post_loop_count ++;
  657.                     $extraClass = "";
  658.  
  659.                     if($loop_counter > $columns)
  660.                     {
  661.                         $loop_counter = 1;
  662.                         $extraClass = 'first';
  663.                     }
  664.  
  665.                     if($loop_counter == 1 || !empty($last))
  666.                     {
  667.                         $output .="</div>";
  668.                     }
  669.                 }
  670.  
  671.             $output .=      "</div>";
  672.  
  673.             if($post_loop_count -1 > $columns && $type == 'slider')
  674.             {
  675.                 $output .= $this->slide_navigation_arrows();
  676.             }
  677.            
  678.             global $wp_query;
  679.             if($use_main_query_pagination == 'yes' && $paginate == "yes")
  680.             {
  681.                 $avia_pagination = avia_pagination($wp_query->max_num_pages, 'nav');
  682.             }
  683.             else if($paginate == "yes")
  684.             {
  685.                 $avia_pagination = avia_pagination($this->entries, 'nav');
  686.             }
  687.  
  688.             if(!empty($avia_pagination)) $output .= "<div class='pagination-wrap pagination-slider'>{$avia_pagination}</div>";
  689.  
  690.  
  691.             $output .= "</div>";
  692.  
  693.             $output = str_replace('{{thumbnail}}', $thumb_fallback, $output);
  694.  
  695.             wp_reset_query();
  696.             return $output;
  697.         }
  698.  
  699.         protected function slide_navigation_arrows()
  700.         {
  701.             $html  = "";
  702.             $html .= "<div class='avia-slideshow-arrows avia-slideshow-controls'>";
  703.             $html .=    "<a href='#prev' class='prev-slide' ".av_icon_string('prev_big').">".__('Previous','avia_framework' )."</a>";
  704.             $html .=    "<a href='#next' class='next-slide' ".av_icon_string('next_big').">".__('Next','avia_framework' )."</a>";
  705.             $html .= "</div>";
  706.  
  707.             return $html;
  708.         }
  709.  
  710.         //fetch new entries
  711.         public function query_entries($params = array())
  712.         {  
  713.             global $avia_config;
  714.  
  715.             if(empty($params)) $params = $this->atts;
  716.  
  717.             if(empty($params['custom_query']))
  718.             {
  719.                 $query = array();
  720.  
  721.                 if(!empty($params['categories']))
  722.                 {
  723.                     //get the portfolio categories
  724.                     $terms  = explode(',', $params['categories']);
  725.                 }
  726.  
  727.                 $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : get_query_var( 'page' );
  728.                 if(!$page || $params['paginate'] == 'no') $page = 1;
  729.  
  730.                 //if we find no terms for the taxonomy fetch all taxonomy terms
  731.                 if(empty($terms[0]) || is_null($terms[0]) || $terms[0] === "null")
  732.                 {
  733.                     $terms = array();
  734.                     $allTax = get_terms( $params['taxonomy']);
  735.                     foreach($allTax as $tax)
  736.                     {
  737.                         $terms[] = $tax->term_id;
  738.                     }
  739.  
  740.                 }
  741.  
  742.                 if($params['offset'] == 'no_duplicates')
  743.                 {
  744.                     $params['offset'] = false;
  745.                     $no_duplicates = true;
  746.                 }
  747.                
  748.                
  749.                 //wordpress 4.4 offset fix
  750.                 if( $params['offset'] == 0 )
  751.                 {
  752.                     $params['offset'] = false;
  753.                 }
  754.                 else
  755.                 {  
  756.                     //if the offset is set the paged param is ignored. therefore we need to factor in the page number
  757.                     $params['offset'] = $params['offset'] + ( ($page -1 ) * $params['items']);
  758.                 }
  759.                
  760.                
  761.                 if(empty($params['post_type'])) $params['post_type'] = get_post_types();
  762.                 if(is_string($params['post_type'])) $params['post_type'] = explode(',', $params['post_type']);
  763.  
  764.                 $orderby = 'date';
  765.                 $order = 'DESC';
  766.                
  767.                 // Meta query - replaced by Tax query in WC 3.0.0
  768.                 $meta_query = array();
  769.                 $tax_query = array();
  770.  
  771.                 // check if taxonomy are set to product or product attributes
  772.                 $tax = get_taxonomy( $params['taxonomy'] );
  773.                
  774.                 if( class_exists( 'WooCommerce' ) && is_object( $tax ) && isset( $tax->object_type ) && in_array( 'product', (array) $tax->object_type ) )
  775.                 {
  776.                     $avia_config['woocommerce']['disable_sorting_options'] = true;
  777.                    
  778.                     avia_wc_set_out_of_stock_query_params( $meta_query, $tax_query, $params['wc_prod_visible'] );
  779.                    
  780.                         //  sets filter hooks !!
  781.                     $ordering_args = avia_wc_get_product_query_order_args( $params['prod_order_by'], $params['prod_order'] );
  782.                            
  783.                     $orderby = $ordering_args['orderby'];
  784.                     $order = $ordering_args['order'];
  785.                 }
  786.  
  787.                 if( ! empty( $terms ) )
  788.                 {
  789.                     $tax_query[] =  array(
  790.                                         'taxonomy'  =>  $params['taxonomy'],
  791.                                         'field'     =>  'id',
  792.                                         'terms'     =>  $terms,
  793.                                         'operator'  =>  'IN'
  794.                                 );
  795.                 }              
  796.                
  797.                 $query = array( 'orderby'       =>  $orderby,
  798.                                 'order'         =>  $order,
  799.                                 'paged'         =>  $page,
  800.                                 'post_type'     =>  $params['post_type'],
  801. //                              'post_status'   =>  'publish',
  802.                                 'offset'        =>  $params['offset'],
  803.                                 'posts_per_page' => $params['items'],
  804.                                 'post__not_in'  =>  ( ! empty( $no_duplicates ) ) ? $avia_config['posts_on_current_page'] : array(),
  805.                                 'meta_query'    =>  $meta_query,
  806.                                 'tax_query'     =>  $tax_query
  807.                             );
  808.                                                                
  809.             }
  810.             else
  811.             {
  812.                 $query = $params['custom_query'];
  813.             }
  814.  
  815.  
  816.             $query = apply_filters('avia_post_slide_query', $query, $params);
  817.  
  818.             @$this->entries = new WP_Query( $query ); //@ is used to prevent errors caused by wpml
  819.  
  820.             // store the queried post ids in
  821.             if( $this->entries->have_posts() )
  822.             {
  823.                 while( $this->entries->have_posts() )
  824.                 {
  825.                     $this->entries->the_post();
  826.                     $avia_config['posts_on_current_page'][] = get_the_ID();
  827.                 }
  828.             }
  829.            
  830.             if( function_exists( 'WC' ) )
  831.             {
  832.                 avia_wc_clear_catalog_ordering_args_filters();
  833.                 $avia_config['woocommerce']['disable_sorting_options'] = false;
  834.             }
  835.         }
  836.     }
  837. }
Advertisement
Add Comment
Please, Sign In to add comment