true, 'pagination_type' => get_theme_mod('pagination_global_type', 'simple'), 'last_page_text' => __('No more posts to load', 'blocksy') ] ); if (! $args['has_pagination']) { return ''; } global $wp_query, $wp_rewrite; $current_page = $wp_query->get( 'paged' ); if ( ! $current_page ) { $current_page = 1; } if ( $wp_query->max_num_pages <= 1 ) { return ''; } $button_output = ''; if ( $args['pagination_type'] === 'load_more' && intval($current_page) !== intval($wp_query->max_num_pages) ) { $label_button = get_theme_mod( 'load_more_label', __('Load More', 'blocksy') ); $button_output = '' . $label_button . ''; } if ( $args['pagination_type'] !== 'simple' && $args['pagination_type'] !== 'next_prev' ) { if (intval($current_page) === intval($wp_query->max_num_pages)) { return ''; } $button_output = '
' . $button_output; $button_output .= ''; $button_output .= '
' . $args['last_page_text'] . '
'; $button_output .= '
'; } $pagination_class = 'ct-pagination'; $divider_output = ''; $divider = get_theme_mod('paginationDivider', [ 'width' => 1, 'style' => 'none', 'color' => [ 'color' => 'rgba(224, 229, 235, 0.5)', ] ]); if ( $divider['style'] !== 'none' && $args['pagination_type'] !== 'infinite_scroll' ) { $divider_output = 'data-divider'; } $template = ' '; $links = paginate_links( [ 'mid_size' => 0, 'end_size' => 0, 'type' => 'array', 'prev_text' => '' . __('Prev', 'blocksy'), 'next_text' => __('Next', 'blocksy') . ' ', ] ); $proper_links = $links; if ($args['pagination_type'] === 'next_prev') { $proper_links = []; foreach ($links as $link) { preg_match('/class="[^"]+"/', $link, $matches); if (count($matches) > 0) { if ( strpos($matches[0], 'next') !== false || strpos($matches[0], 'prev') !== false ) { $proper_links[] = $link; } } } } return sprintf( $template, join("\n", $proper_links), $button_output ); }