PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.0
Post Grid Gutenberg Blocks – PostX v5.1.0
5.1.1 5.1.0 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 All 240 releases
ultimate-post / blocks / template / pagination_block.php

pagination_block.php in Post Grid Gutenberg Blocks – PostX 5.1.0, at blocks/template/pagination_block.php

90 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || exit;
3 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included inside block render methods; variables are local.
4
5 // Adv Filter Integration
6 $adv_filter_dataset = ultimate_post()->get_adv_data_attrs( $attr );
7
8 $pagi_block_html = '';
9
10 $paged = ! wp_doing_ajax() &&
11 isset( $_GET[ $attr['blockId'] . '_page' ] ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only page number for block pagination.
12 is_numeric( $_GET[ $attr['blockId'] . '_page' ] ) ? // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only page number for block pagination.
13 intval( $_GET[ $attr['blockId'] . '_page' ] ) : '1'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only page number for block pagination.
14
15 // Pagination
16 if ( $attr['advPaginationEnable'] && ( $attr['paginationType'] == 'pagination' ) ) {
17 $pagi_datasets = array(
18 'for' => 'ultp-block-' . $attr['blockId'],
19 'blockid' => sanitize_html_class( $attr['blockId'] ),
20 'expost' => isset( $curr_post_id ) ? $curr_post_id : '',
21 'paged' => $paged,
22 'pages' => $pageNum,
23 'blockname' => 'ultimate-post_' . $block_name,
24 'postid' => ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? sanitize_html_class( $attr['currentPostId'] ) : ultimate_post()->get_page_post_id( $attr['blockId'] ),
25 'selfpostid' => ( ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? 'yes' : 'no' ),
26 );
27
28 $f_pagi_datasets = ultimate_post()->get_formatted_datasets( $pagi_datasets );
29
30 $pagi_class = ' class="ultp-pagination-wrap' . ( $attr['paginationAjax'] ? ' ultp-pagination-ajax-action' : '' ) . '" ';
31
32
33 $pagi_block_html .= '<div' . $pagi_class . ultimate_post()->get_builder_attr( $attr['queryType'] ) . $adv_filter_dataset . $f_pagi_datasets . '>';
34
35 $pagi_block_html .= ultimate_post()->pagination( $pageNum, $attr['paginationNav'], $attr['paginationText'], $attr['paginationAjax'], '', $attr['blockId'] );
36
37 $pagi_block_html .= '</div>';
38 }
39
40 // Navigation bottom
41 if ( $attr['advPaginationEnable'] && ( $attr['paginationType'] == 'navigation' ) ) {
42 $pagi_datasets = array(
43 'for' => 'ultp-block-' . $attr['blockId'],
44 'blockid' => sanitize_html_class( $attr['blockId'] ),
45 'expost' => isset( $curr_post_id ) ? $curr_post_id : '',
46 'pagenum' => $paged,
47 'pages' => $pageNum,
48 'blockname' => 'ultimate-post_' . $block_name,
49 'postid' => ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? sanitize_html_class( $attr['currentPostId'] ) : ultimate_post()->get_page_post_id( $attr['blockId'] ),
50 'selfpostid' => ( ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? 'yes' : 'no' ),
51 );
52
53 $f_pagi_datasets = ultimate_post()->get_formatted_datasets( $pagi_datasets );
54 $pagi_class = ' class="ultp-next-prev-wrap" ';
55
56 $pagi_block_html .= '<div' . $pagi_class . ultimate_post()->get_builder_attr( $attr['queryType'] ) . $adv_filter_dataset . $f_pagi_datasets . '>';
57
58 if ( 1 != $pageNum ) {
59 $pagi_block_html .= ultimate_post()->next_prev();
60 }
61
62 $pagi_block_html .= '</div>';
63 }
64
65 // Load More
66 if ( $attr['advPaginationEnable'] && ( $attr['paginationType'] == 'loadMore' ) ) {
67 $allowed_html_tags = ultimate_post()->ultp_allowed_html_tags();
68
69 $attr['loadMoreText'] = isset( $attr['loadMoreText'] ) ? wp_kses( $attr['loadMoreText'], $allowed_html_tags ) : 'Load More';
70
71 $page_post_id = ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? sanitize_html_class( $attr['currentPostId'] ) : ultimate_post()->get_page_post_id( $attr['blockId'] );
72
73 $self_post_id = 'data-selfpostid="' . ( ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? 'yes' : 'no' ) . '"';
74
75 $exclude_id = isset( $curr_post_id ) ? $curr_post_id : '';
76
77 $pagi_class = ' class="ultp-loadmore-action" ';
78
79 $pagi_block_html .= '<div class="ultp-loadmore">';
80
81 if ( 1 != $pageNum ) {
82 $pagi_block_html .= '<span' . $pagi_class . ' tabindex="0" role="button" data-for="ultp-block-' . $attr['blockId'] . '" data-pages="' . $pageNum . '" data-pagenum="' . $paged . '" data-expost="' . $exclude_id . '" data-blockid="' . $attr['blockId'] . '" data-blockname="ultimate-post_' . $block_name . '" data-postid="' . $page_post_id . '" ' . ultimate_post()->get_builder_attr( $attr['queryType'] ) . $self_post_id . $adv_filter_dataset . '>' . $attr['loadMoreText'] . ' <span class="ultp-spin">' . ultimate_post()->get_svg_icon( 'refresh' ) . '</span></span>';
83 }
84
85 $pagi_block_html .= '</div>';
86 }
87
88 // $pagi_block_html = json_encode( array( 'html' => $pagi_block_html ) );
89 $pagi_block_html = '<div class="pagination-block-html" aria-hidden="true" style="display: none;">' . $pagi_block_html . '</div>';
90