Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Admin

Table::prepare_items()publicWC 1.0

Prepare table list items.

Method of the class: Table{}

No Hooks.

Return

null. Nothing.

Usage

$Table = new Table();
$Table->prepare_items();

Table::prepare_items() code WC 7.1.1

public function prepare_items() {
	// phpcs:disable WordPress.Security.NonceVerification.Recommended
	// phpcs:disable WordPress.Security.NonceVerification.Missing
	$current_page = $this->get_pagenum();
	$per_page     = $this->get_items_per_page( 'edit_approved_directories_per_page' );
	$search       = sanitize_text_field( wp_unslash( $_REQUEST['s'] ?? '' ) );

	switch ( $_REQUEST['view'] ?? '' ) {
		case 'enabled':
			$enabled = true;
			break;

		case 'disabled':
			$enabled = false;
			break;

		default:
			$enabled = null;
			break;
	}
	// phpcs:enable

	$approved_directories = wc_get_container()->get( Register::class )->list(
		array(
			'page'     => $current_page,
			'per_page' => $per_page,
			'search'   => $search,
			'enabled'  => $enabled,
		)
	);

	$this->items = $approved_directories['approved_directories'];

	// Set the pagination.
	$this->set_pagination_args(
		array(
			'total_items' => $approved_directories['total_urls'],
			'total_pages' => $approved_directories['total_pages'],
			'per_page'    => $per_page,
		)
	);
}