| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
// Adv Filter Integration |
| 5 |
$adv_filter_dataset = ultimate_post()->get_adv_data_attrs( $attr ); |
| 6 |
|
| 7 |
$pagi_block_html = ''; |
| 8 |
|
| 9 |
$paged = ! wp_doing_ajax() && |
| 10 |
isset( $_GET[ $attr['blockId'] . '_page' ] ) && |
| 11 |
is_numeric( $_GET[ $attr['blockId'] . '_page' ] ) ? |
| 12 |
intval( $_GET[ $attr['blockId'] . '_page' ] ) : '1'; |
| 13 |
|
| 14 |
// Pagination |
| 15 |
if ( $attr['advPaginationEnable'] && ( $attr['paginationType'] == 'pagination' ) ) { |
| 16 |
$pagi_datasets = array( |
| 17 |
'for' => 'ultp-block-' . $attr['blockId'], |
| 18 |
'blockid' => sanitize_html_class( $attr['blockId'] ), |
| 19 |
'expost' => isset( $curr_post_id ) ? $curr_post_id : '', |
| 20 |
'paged' => $paged, |
| 21 |
'pages' => $pageNum, |
| 22 |
'blockname' => 'ultimate-post_' . $block_name, |
| 23 |
'postid' => ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? sanitize_html_class( $attr['currentPostId'] ) : ultimate_post()->get_page_post_id( $attr['blockId'] ), |
| 24 |
'selfpostid' => ( ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? 'yes' : 'no' ), |
| 25 |
); |
| 26 |
|
| 27 |
$f_pagi_datasets = ultimate_post()->get_formatted_datasets( $pagi_datasets ); |
| 28 |
|
| 29 |
$pagi_class = ' class="ultp-pagination-wrap' . ( $attr['paginationAjax'] ? ' ultp-pagination-ajax-action' : '' ) . '" '; |
| 30 |
|
| 31 |
|
| 32 |
$pagi_block_html .= '<div' . $pagi_class . ultimate_post()->get_builder_attr( $attr['queryType'] ) . $adv_filter_dataset . $f_pagi_datasets . '>'; |
| 33 |
|
| 34 |
$pagi_block_html .= ultimate_post()->pagination( $pageNum, $attr['paginationNav'], $attr['paginationText'], $attr['paginationAjax'], '', $attr['blockId'] ); |
| 35 |
|
| 36 |
$pagi_block_html .= '</div>'; |
| 37 |
} |
| 38 |
|
| 39 |
// Navigation bottom |
| 40 |
if ( $attr['advPaginationEnable'] && ( $attr['paginationType'] == 'navigation' ) ) { |
| 41 |
$pagi_datasets = array( |
| 42 |
'for' => 'ultp-block-' . $attr['blockId'], |
| 43 |
'blockid' => sanitize_html_class( $attr['blockId'] ), |
| 44 |
'expost' => isset( $curr_post_id ) ? $curr_post_id : '', |
| 45 |
'pagenum' => $paged, |
| 46 |
'pages' => $pageNum, |
| 47 |
'blockname' => 'ultimate-post_' . $block_name, |
| 48 |
'postid' => ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? sanitize_html_class( $attr['currentPostId'] ) : ultimate_post()->get_page_post_id( $attr['blockId'] ), |
| 49 |
'selfpostid' => ( ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? 'yes' : 'no' ), |
| 50 |
); |
| 51 |
|
| 52 |
$f_pagi_datasets = ultimate_post()->get_formatted_datasets( $pagi_datasets ); |
| 53 |
$pagi_class = ' class="ultp-next-prev-wrap" '; |
| 54 |
|
| 55 |
$pagi_block_html .= '<div' . $pagi_class . ultimate_post()->get_builder_attr( $attr['queryType'] ) . $adv_filter_dataset . $f_pagi_datasets . '>'; |
| 56 |
|
| 57 |
if ( 1 != $pageNum ) { |
| 58 |
$pagi_block_html .= ultimate_post()->next_prev(); |
| 59 |
} |
| 60 |
|
| 61 |
$pagi_block_html .= '</div>'; |
| 62 |
} |
| 63 |
|
| 64 |
// Load More |
| 65 |
if ( $attr['advPaginationEnable'] && ( $attr['paginationType'] == 'loadMore' ) ) { |
| 66 |
$allowed_html_tags = ultimate_post()->ultp_allowed_html_tags(); |
| 67 |
|
| 68 |
$attr['loadMoreText'] = isset( $attr['loadMoreText'] ) ? wp_kses( $attr['loadMoreText'], $allowed_html_tags ) : 'Load More'; |
| 69 |
|
| 70 |
$page_post_id = ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? sanitize_html_class( $attr['currentPostId'] ) : ultimate_post()->get_page_post_id( $attr['blockId'] ); |
| 71 |
|
| 72 |
$self_post_id = 'data-selfpostid="' . ( ( isset( $attr['currentPostId'] ) && $attr['currentPostId'] ) ? 'yes' : 'no' ) . '"'; |
| 73 |
|
| 74 |
$exclude_id = isset( $curr_post_id ) ? $curr_post_id : ''; |
| 75 |
|
| 76 |
$pagi_class = ' class="ultp-loadmore-action" '; |
| 77 |
|
| 78 |
$pagi_block_html .= '<div class="ultp-loadmore">'; |
| 79 |
|
| 80 |
if ( 1 != $pageNum ) { |
| 81 |
$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>'; |
| 82 |
} |
| 83 |
|
| 84 |
$pagi_block_html .= '</div>'; |
| 85 |
} |
| 86 |
|
| 87 |
// $pagi_block_html = json_encode( array( 'html' => $pagi_block_html ) ); |
| 88 |
$pagi_block_html = '<div class="pagination-block-html" aria-hidden="true" style="display: none;">' . $pagi_block_html . '</div>'; |
| 89 |
|