Function Reference: geodir_location_admin_pagination

Summary

Admin location pagination.

Package

GeoDirectory_Location_Manager

Parameters

$args
(array) (required) Pagination arguments.

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

Default: None

Return Values

(string)
  • Pagination HTML.

Change Log

Since: 1.0.0

Source File

geodir_location_admin_pagination() is located in geodir_location_manager/geodir_location_functions.php [Line: 2991]

Source Code

function geodir_location_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 = '' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '';

	$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( "%s",
		'first-page' . $disable_first,
		esc_attr__( 'Go to the first page', GEODIRLOCATION_TEXTDOMAIN ),
		esc_url( remove_query_arg( 'paged', $current_url ) ),
		'«'
	);

	$page_links[] = sprintf( "%s",
		'prev-page' . $disable_first,
		esc_attr__( 'Go to the previous page', GEODIRLOCATION_TEXTDOMAIN ),
		esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
		'‹'
	);

	$html_current_page = $current;
	
	$html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) );
	$page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '';

	$page_links[] = sprintf( "%s",
		'next-page' . $disable_last,
		esc_attr__( 'Go to the next page', GEODIRLOCATION_TEXTDOMAIN ),
		esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
		'›'
	);

	$page_links[] = sprintf( "%s",
		'last-page' . $disable_last,
		esc_attr__( 'Go to the last page', GEODIRLOCATION_TEXTDOMAIN ),
		esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
		'»'
	);

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

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