PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.0.41
Post Grid Gutenberg Blocks – PostX v5.0.41
5.0.41 5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 All 238 releases
← All changes | blocks/Advanced_Filter.php +41 -38 5.0.175.0.41 View file →
@@ -23,18 +23,20 @@
23 23 * Order Value for select
24 24 *
25 25 * @var array
26 26 */
27 - public $order = array(
28 - array(
29 - 'id' => 'DESC',
30 - 'name' => 'DESC',
31 - ),
32 - array(
33 - 'id' => 'ASC',
34 - 'name' => 'ASC',
35 - ),
36 - );
27 + public function get_order_options() {
28 + return array(
29 + array(
30 + 'id' => 'DESC',
31 + 'name' => __( 'DESC', 'ultimate-post' ),
32 + ),
33 + array(
34 + 'id' => 'ASC',
35 + 'name' => __( 'ASC', 'ultimate-post' ),
36 + ),
37 + );
38 + }
37 39
38 40 /**
39 41 * Order by Value for select
40 42 *
@@ -275,11 +277,12 @@
275 277 * @param mixed $ids string.
276 278 * @param mixed $post_types string.
277 279 * @param mixed $allText string.
278 280 * @param mixed $option string.
281 + * @param mixed $order array.
279 282 * @return array
280 283 */
281 - public function get_button_data( $type, $data_ids, $post_types = '', $allText = 'All', $option = '' ) {
284 + public function get_button_data( $type, $data_ids, $post_types = '', $allText = 'All', $option = '', $order = array() ) {
282 285
283 286 $res = array();
284 287
285 288 if ( in_array( '_all', $data_ids ) ) {
@@ -324,13 +327,13 @@
324 327 }
325 328 }
326 329 break;
327 330 case 'tags':
328 - $args = array(
331 + $args = array(
329 332 'taxonomy' => 'post_tag',
330 333 'hide_empty' => false,
331 334 );
332 - if ( 'all' !== $option && ! empty( $ids ) && $ids !== '_all') {
335 + if ( 'all' !== $option && ! empty( $ids ) && $ids !== '_all' ) {
333 336 $args['include'] = wp_parse_id_list( $ids );
334 337 $args['orderby'] = 'include';
335 338 }
336 339
@@ -433,10 +436,9 @@
433 436 array_splice( $arr, $idx, 0, array( $item ) );
434 437 }
435 438 }
436 439
437 - public function get_select_data( $type, $all_text, $post_types = '', $specific = array(), $mode = 'all' ) {
438 -
440 + public function get_select_data( $type, $all_text, $post_types = '', $specific = array(), $mode = 'all', $order = array() ) {
439 441 $all = null;
440 442 $all_idx = array_search( '_all', $specific, true );
441 443 $filtered_specific = $specific;
442 444
@@ -542,10 +544,10 @@
542 544 case 'order':
543 545 $filtered_specific = array_map( 'strtoupper', $filtered_specific );
544 546
545 547 return 'specific' === $mode ?
546 - $this->filter_select_options( $this->order, $filtered_specific )
547 - : $this->order;
548 + $this->filter_select_options( $order, $filtered_specific )
549 + : $order;
548 550
549 551 case 'order_by':
550 552 return 'specific' === $mode ?
551 553 $this->filter_select_options( $this->order_by, $filtered_specific )
@@ -632,10 +634,11 @@
632 634 $post_types = json_decode( $post_types, true );
633 635 }
634 636 }
635 637
636 - $attr['blockId'] = ultimate_post()->sanitize_attr( $attr, 'blockId', 'sanitize_html_class', 'missing_block_id' );
637 - $attr['allText'] = ultimate_post()->sanitize_attr( $attr, 'allText', 'sanitize_text_field', 'missing_block_id' );
638 + $attr['blockId'] = ultimate_post()->sanitize_attr( $attr, 'blockId', 'sanitize_html_class', 'missing_block_id' );
639 + $attr['allText'] = ultimate_post()->sanitize_attr( $attr, 'allText', 'sanitize_text_field', 'missing_block_id' );
640 + $current_page_post_id = ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? sanitize_html_class( $attr['currentPostId'] ) : ultimate_post()->get_page_post_id( $attr['blockId'] );
638 641
639 642 if ( 'inline' === $attr['filterStyle'] ) {
640 643 $inline_values = json_decode( $attr['filterValues'], true );
641 644
@@ -642,19 +645,19 @@
642 645 if ( ! is_array( $inline_values ) ) {
643 646 return '';
644 647 }
645 648
646 - $data = $this->get_button_data( $attr['type'], $inline_values, $post_types, $attr['allText'], $attr['dropdownOptionsType'] );
649 + $data = $this->get_button_data( $attr['type'], $inline_values, $post_types, $attr['allText'], $attr['dropdownOptionsType'], $this->get_order_options() );
647 650
648 651 $btn_wrapper_attrs = get_block_wrapper_attributes(
649 652 array(
650 - 'class' => 'ultp-block-' . $attr['blockId'] . ' ultp-filter-button',
651 - 'role' => 'button',
652 - 'data-blockId' => $attr['blockId'],
653 - 'data-is-active' => 'false',
654 - 'data-builder' => ultimate_post()->get_builder_attr( 'archiveBuilderFilter' ),
655 - 'data-current-postid' => get_the_ID(),
656 - 'data-filter-label' => isset($attr['allText']) ? $attr['allText'] : 'All',
653 + 'class' => 'ultp-block-' . $attr['blockId'] . ' ultp-filter-button',
654 + 'role' => 'button',
655 + 'data-blockId' => $attr['blockId'],
656 + 'data-is-active' => 'false',
657 + 'data-builder' => ultimate_post()->get_builder_attr( 'archiveBuilderFilter' ),
658 + 'data-current-postid' => $current_page_post_id,
659 + 'data-filter-label' => isset( $attr['allText'] ) ? $attr['allText'] : 'All',
657 660 )
658 661 );
659 662
660 663 ob_start();
@@ -700,23 +703,23 @@
700 703 );
701 704 }
702 705 }
703 706
704 - $data = $this->get_select_data( $attr['type'], $attr['allText'], $post_types, $specific, $mode );
707 + $data = $this->get_select_data( $attr['type'], $attr['allText'], $post_types, $specific, $mode, $this->get_order_options() );
705 708
706 709 $def_value = ! empty( current( $data ) ) ? current( $data ) : null;
707 710
708 711 $wrapper_attrs = get_block_wrapper_attributes(
709 712 array(
710 - 'class' => 'ultp-block-' . $attr['blockId'] . ' ultp-filter-select',
711 - 'data-selected' => isset( $def_value['id'] ) ? $def_value['id'] : 0,
712 - 'data-type' => $attr['type'],
713 - 'data-blockId' => $attr['blockId'],
714 - 'aria-expanded' => 'false',
715 - 'aria-label' => 'Select Filter (' . $attr['type'] . ')',
716 - 'data-builder' => ultimate_post()->get_builder_attr( 'archiveBuilderFilter' ),
717 - 'data-current-postid' => get_the_ID(),
718 - 'data-filter-label' => isset($def_value['name']) ? $def_value['name'] : 'All',
713 + 'class' => 'ultp-block-' . $attr['blockId'] . ' ultp-filter-select',
714 + 'data-selected' => isset( $def_value['id'] ) ? $def_value['id'] : 0,
715 + 'data-type' => $attr['type'],
716 + 'data-blockId' => $attr['blockId'],
717 + 'aria-expanded' => 'false',
718 + 'aria-label' => 'Select Filter (' . $attr['type'] . ')',
719 + 'data-builder' => ultimate_post()->get_builder_attr( 'archiveBuilderFilter' ),
720 + 'data-current-postid' => $current_page_post_id,
721 + 'data-filter-label' => isset( $def_value['name'] ) ? $def_value['name'] : 'All',
719 722 )
720 723 );
721 724
722 725 ob_start();
@@ -797,9 +800,9 @@
797 800 type="search"
798 801 placeholder="<?php echo esc_attr( $attr['placeholder'] ); ?>"
799 802 />
800 803 <span class="ultp-filter-search-input-icon">
801 - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 47.05 47.05"><path stroke="rgba(0,0,0,0)" strokeMiterlimit="10" d="m43.051 45.948-9.618-9.616a20.183 20.183 0 1 1 2.9-2.9l9.617 9.616a2.05 2.05 0 1 1-2.9 2.9Zm-22.367-9.179A16.084 16.084 0 1 0 4.6 20.684a16.1 16.1 0 0 0 16.084 16.085Z"/></svg>
804 + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 47.05 47.05" fill="currentColor"><path stroke="currentColor" strokeMiterlimit="10" d="m43.051 45.948-9.618-9.616a20.183 20.183 0 1 1 2.9-2.9l9.617 9.616a2.05 2.05 0 1 1-2.9 2.9Zm-22.367-9.179A16.084 16.084 0 1 0 4.6 20.684a16.1 16.1 0 0 0 16.084 16.085Z"/></svg>
802 805 </span>
803 806 </div>
804 807 </div>
805 808 <?php