Function Reference: geodir_payment_admin_pagination

Summary

Admin payment invoice pagination.

Parameters

$args
(array) (required) Pagination arguments.

Default: None
$which
(string) (required) Pagination position.

Default: None

Return Values

(string)
  • Pagination HTML.

Change Log

Since: 1.2.6

Source Code

function geodir_payment_admin_pagination( $args, $which = 'bottom' ) {
	if ( empty( $args ) || empty( $args['total_items'] ) ) {
		return;
	}

	$total_items = $args['total_items'];
	$total_pages = $args['total_pages'];
	$infinite_scroll = false;
	if ( isset( $args['infinite_scroll'] ) ) {
		$infinite_scroll = $args['infinite_scroll'];
	}

	$output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';

	$current = $args['pagenum'];

	$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );

	$current_url = esc_url( remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url ), '', '' );

	$page_links = array();

	$disable_first = $disable_last = '';
	if ( $current == 1 ) {
		$disable_first = ' disabled';
	}
	if ( $current == $total_pages ) {
		$disable_last = ' disabled';
	}
	$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
		'first-page' . $disable_first,
		esc_attr__( 'Go to the first page', 'geodir_payments' ),
		esc_url( remove_query_arg( 'paged', $current_url ) ),
		'&laquo;'
	);

	$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
		'prev-page' . $disable_first,
		esc_attr__( 'Go to the previous page', 'geodir_payments' ),
		esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
		'&lsaquo;'
	);

	$html_current_page = $current;
	
	$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
	$page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';

	$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
		'next-page' . $disable_last,
		esc_attr__( 'Go to the next page', 'geodir_payments' ),
		esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
		'&rsaquo;'
	);

	$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
		'last-page' . $disable_last,
		esc_attr__( 'Go to the last page', 'geodir_payments' ),
		esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
		'&raquo;'
	);

	$pagination_links_class = 'pagination-links';
	if ( ! empty( $infinite_scroll ) ) {
		$pagination_links_class = ' hide-if-js';
	}
	$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';

	if ( $total_pages ) {
		$page_class = $total_pages < 2 ? ' one-page' : '';
	} else {
		$page_class = ' no-pages';
	}
	$pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";

	return $pagination;
}