Automattic\WooCommerce\Internal\Admin\Settings\SettingsUIPages

ProductsSettingsPageAdapter::get_page_optionsprivateWC 1.0

Build the page options for the shop page selector.

Method of the class: ProductsSettingsPageAdapter{}

No Hooks.

Returns

Array. array{label: string, value: string}>

Usage

// private - for code of main (parent) class only
$result = $this->get_page_options(): array;

ProductsSettingsPageAdapter::get_page_options() code WC 10.9.1

private function get_page_options(): array {
	$pages = get_pages(
		array(
			'sort_column' => 'menu_order',
			'sort_order'  => 'ASC',
			'post_status' => array( 'publish', 'private', 'draft' ),
		)
	);

	$options = array(
		array(
			'label' => __( 'Select a page...', 'woocommerce' ),
			'value' => '',
		),
	);

	if ( ! is_array( $pages ) ) {
		return $options;
	}

	foreach ( $pages as $page ) {
		$options[] = array(
			'label' => wp_strip_all_tags( $page->post_title ),
			'value' => (string) $page->ID,
		);
	}

	return $options;
}