Advertisement
cipher87

Postslider - Swap Title and Date

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