WPSEO_Bulk_List_Table::set_pagination()protectedYoast 1.0

Setting the pagination.

Total items is the number of all visible items.

Метод класса: WPSEO_Bulk_List_Table{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->set_pagination( $total_items );
$total_items(int) (обязательный)
Total items counts.

Код WPSEO_Bulk_List_Table::set_pagination() Yoast 22.4

protected function set_pagination( $total_items ) {
	// Calculate items per page.
	$per_page = $this->get_items_per_page( 'wpseo_posts_per_page', 10 );
	$paged    = isset( $_GET['paged'] ) && is_string( $_GET['paged'] ) ? esc_sql( sanitize_text_field( wp_unslash( $_GET['paged'] ) ) ) : '';

	if ( empty( $paged ) || ! is_numeric( $paged ) ) {
		$paged = 1;
	}
	else {
		$paged = (int) $paged;
	}

	if ( $paged <= 0 ) {
		$paged = 1;
	}

	$this->set_pagination_args(
		[
			'total_items' => $total_items,
			'total_pages' => ceil( $total_items / $per_page ),
			'per_page'    => $per_page,
		]
	);

	$this->pagination = [
		'per_page' => $per_page,
		'offset'   => ( ( $paged - 1 ) * $per_page ),
	];
}