ACF_Repeater_Table::pagination()publicACF 6.0.0

Renders the table pagination. Mostly lifted from the WordPress core WP_List_Table class.

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

Хуков нет.

Возвращает

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

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

$ACF_Repeater_Table = new ACF_Repeater_Table();
$ACF_Repeater_Table->pagination();

Список изменений

С версии 6.0.0 Введена.

Код ACF_Repeater_Table::pagination() ACF 6.0.4

<?php
public function pagination() {
	if ( empty( $this->field['pagination'] ) ) {
		return;
	}

	$total_rows  = isset( $this->field['total_rows'] ) ? (int) $this->field['total_rows'] : 0;
	$total_pages = ceil( $total_rows / (int) $this->field['rows_per_page'] );
	$total_pages = max( $total_pages, 1 );

	$html_current_page = sprintf(
		"%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
		'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'acf' ) . '</label>',
		1,
		strlen( $total_pages )
	);

	$html_total_pages = sprintf( "<span class='acf-total-pages'>%s</span>", number_format_i18n( $total_pages ) );
	?>
	<div class="acf-tablenav tablenav-pages">
		<a class="first-page button acf-nav" aria-hidden="true" data-event="first-page" title="<?php esc_attr_e( 'First Page', 'acf' ); ?>">
			<span class="screen-reader-text"><?php esc_html_e( 'First Page', 'acf' ); ?></span>
			<span aria-hidden="true">&laquo;</span>
		</a>
		<a class="prev-page button acf-nav" aria-hidden="true" data-event="prev-page" title="<?php esc_attr_e( 'Previous Page', 'acf' ); ?>">
			<span class="screen-reader-text"><?php esc_html_e( 'Previous Page', 'acf' ); ?></span>
			<span aria-hidden="true">&lsaquo;</span>
		</a>
		<span class="paging-input">
			<label for="current-page-selector" class="screen-reader-text"><?php esc_html_e( 'Current Page', 'acf' ); ?></label>
			<span class="tablenav-paging-text" title="<?php esc_attr_e( 'Current Page', 'acf' ); ?>">
			<?php
			printf(
				/* translators: 1: Current page, 2: Total pages. */
				_x( '%1$s of %2$s', 'paging' ),
				$html_current_page,
				$html_total_pages
			);
			?>
			</span>
		</span>
		<a class="next-page button acf-nav" data-event="next-page" title="<?php esc_attr_e( 'Next Page', 'acf' ); ?>">
			<span class="screen-reader-text"><?php esc_html_e( 'Next Page', 'acf' ); ?></span>
			<span aria-hidden="true">&rsaquo;</span>
		</a>
		<a class="last-page button acf-nav" data-event="last-page" title="<?php esc_attr_e( 'Last Page', 'acf' ); ?>">
			<span class="screen-reader-text"><?php esc_html_e( 'Last Page', 'acf' ); ?></span>
			<span aria-hidden="true">&raquo;</span>
		</a>
	</div>
	<?php
}