Guest User

Untitled

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