| @@ -1,5 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | +// phpcs:ignore | |
| 3 | +// @codingStandardsIgnoreFile | |
| 4 | +// @ignoreWarnings | |
| 2 | 5 | /** |
| 3 | 6 | * Require All Blocks and handle block ajax action |
| 4 | 7 | * |
| 5 | 8 | * @package ULTP\Blocks |
| @@ -6,9 +9,8 @@ | ||
| 6 | 9 | * @since 4.1.11 |
| 7 | 10 | */ |
| 8 | 11 | |
| 9 | 12 | namespace ULTP; |
| 10 | - | |
| 11 | 13 | defined( 'ABSPATH' ) || exit; |
| 12 | 14 | |
| 13 | 15 | /** |
| 14 | 16 | * Blocks class. |
| @@ -592,8 +594,19 @@ | ||
| 592 | 594 | * @return ARRAY |
| 593 | 595 | */ |
| 594 | 596 | public function filter_content_return( $blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy, $postId, &$toReturn, $widgetBlockId = '', $adv_filter_data = array(), $ultp_uniqueIds = array(), $ultp_current_unique_posts = array() ) { |
| 595 | 597 | foreach ( $blocks as $key => $value ) { |
| 598 | + if ( ( $value['blockName'] ?? '' ) === 'core/shortcode' ) { | |
| 599 | + if ( preg_match( '/id="([^"]+)"/', $value['innerHTML'] ?? '', $matches ) ) { | |
| 600 | + $template_post = get_post( $matches[1] ); | |
| 601 | + if ( $template_post && ! empty( $template_post->post_content ) ) { | |
| 602 | + $template_blocks = parse_blocks( $template_post->post_content ); | |
| 603 | + // recurse into the expanded blocks instead | |
| 604 | + $this->filter_content_return( $template_blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy, $postId, $toReturn, $widgetBlockId, $adv_filter_data, $ultp_uniqueIds, $ultp_current_unique_posts ); | |
| 605 | + continue; // skip the shortcode block itself | |
| 606 | + } | |
| 607 | + } | |
| 608 | + } | |
| 596 | 609 | if ( $blockName == $value['blockName'] ) { |
| 597 | 610 | if ( $value['attrs']['blockId'] == $blockId ) { |
| 598 | 611 | $objName = str_replace( ' ', '_', ucwords( str_replace( array( 'ultimate-post/', '-' ), array( '', ' ' ), $blockName ) ) ); |
| 599 | 612 | $new_obj = '\ULTP\blocks\\' . $objName; |
| @@ -648,13 +661,15 @@ | ||
| 648 | 661 | $filter_attributes['queryQuick'] = $adv_filter_data['adv_sort']; |
| 649 | 662 | $filter_attributes['queryOrderBy'] = |
| 650 | 663 | ! empty( $adv_filter_data['orderby'] ) ? $adv_filter_data['orderby'] : ( $value['attrs']['queryOrderBy'] ?? '' ); |
| 651 | 664 | } |
| 652 | - | |
| 665 | + $pagination = $this->pagination_for_filter( $attr, $postId, $blockRaw, $filter_attributes ); | |
| 653 | 666 | $toReturn = array( |
| 654 | 667 | 'blocks' => $objectBlock->content( $attr, true ), |
| 655 | 668 | 'notFound' => isset( $attr['notFoundMessage'] ) ? $attr['notFoundMessage'] : '', |
| 656 | - 'pagination' => $this->pagination_for_filter( $attr, $postId, $blockRaw, $filter_attributes ), | |
| 669 | + 'pagination' => $pagination['pagination_content'], | |
| 670 | + 'data_attrs' => $pagination['data_attrs'], | |
| 671 | + 'data_all_attrs' => $pagination['data_attrs'], | |
| 657 | 672 | 'paginationType' => $attr['paginationType'], |
| 658 | 673 | 'paginationShow' => $attr['paginationShow'], |
| 659 | 674 | ); |
| 660 | 675 | } |
| @@ -710,10 +725,28 @@ | ||
| 710 | 725 | |
| 711 | 726 | $wraper_after .= '</div>'; |
| 712 | 727 | } |
| 713 | 728 | wp_reset_query(); |
| 714 | - | |
| 715 | - return $wraper_after; | |
| 729 | + | |
| 730 | + // queryQuick | |
| 731 | + return array( | |
| 732 | + 'pagination_content' => $wraper_after, | |
| 733 | + 'data_attrs' => wp_json_encode( array( | |
| 734 | + 'paged' => 1, | |
| 735 | + 'blockid' => $attr['blockId'], | |
| 736 | + 'postid' => $postId, | |
| 737 | + 'pages' => $pageNum, | |
| 738 | + 'blockname' => $blockRaw, | |
| 739 | + 'filter_value' => isset( $filter_attributes['queryTaxValue'] ) ? $filter_attributes['queryTaxValue'] : '', | |
| 740 | + 'filter_type' => isset( $filter_attributes['queryTax'] ) ? $filter_attributes['queryTax'] : '', | |
| 741 | + 'filter_author' => isset( $filter_attributes['queryAuthor'] ) ? $filter_attributes['queryAuthor'] : '', | |
| 742 | + 'filter_order' => isset( $filter_attributes['queryOrder'] ) ? $filter_attributes['queryOrder'] : 'DESC', | |
| 743 | + 'filter_orderby' => isset( $filter_attributes['queryOrderBy'] ) ? $filter_attributes['queryOrderBy'] : '', | |
| 744 | + 'filter_search' => isset( $filter_attributes['querySearch'] ) ? $filter_attributes['querySearch'] : '', | |
| 745 | + 'filter_queryQuick' => isset( $filter_attributes['queryQuick'] ) ? $filter_attributes['queryQuick'] : '', | |
| 746 | + 'filter_for' => 'ultp-block-' . $attr['blockId'], | |
| 747 | + )), | |
| 748 | + ); | |
| 716 | 749 | } |
| 717 | 750 | |
| 718 | 751 | /** |
| 719 | 752 | * Nonce Generation Callback |