Automattic\WooCommerce\Internal\Admin\Logging\FileV2

FileListTable::prepare_items()publicWC 1.0

Prepares the list of items for displaying.

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

Хуков нет.

Возвращает

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

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

$FileListTable = new FileListTable();
$FileListTable->prepare_items(): void;

Код FileListTable::prepare_items() WC 9.7.1

public function prepare_items(): void {
	$per_page = $this->get_items_per_page(
		self::PER_PAGE_USER_OPTION_KEY,
		$this->get_per_page_default()
	);

	$defaults  = array(
		'per_page' => $per_page,
		'offset'   => ( $this->get_pagenum() - 1 ) * $per_page,
	);
	$file_args = wp_parse_args(
		$this->page_controller->get_query_params( array( 'order', 'orderby', 'source' ) ),
		$defaults
	);

	$total_items = $this->file_controller->get_files( $file_args, true );
	if ( is_wp_error( $total_items ) ) {
		printf(
			'<div class="notice notice-warning"><p>%s</p></div>',
			esc_html( $total_items->get_error_message() )
		);

		return;
	}

	$total_pages = ceil( $total_items / $per_page );
	$items       = $this->file_controller->get_files( $file_args );

	$this->items = $items;

	$this->set_pagination_args(
		array(
			'per_page'    => $per_page,
			'total_items' => $total_items,
			'total_pages' => $total_pages,
		)
	);
}