Automattic\WooCommerce\Internal\Admin\Orders

PageController::register_menu()publicWC 1.0

Registers the "Orders" menu.

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

Хуков нет.

Возвращает

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

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

$PageController = new PageController();
$PageController->register_menu(): void;

Код PageController::register_menu() WC 9.4.2

public function register_menu(): void {
	$order_types = wc_get_order_types( 'admin-menu' );

	foreach ( $order_types as $order_type ) {
		$post_type = get_post_type_object( $order_type );

		add_submenu_page(
			'woocommerce',
			$post_type->labels->name,
			$post_type->labels->menu_name,
			$post_type->cap->edit_posts,
			'wc-orders' . ( 'shop_order' === $order_type ? '' : '--' . $order_type ),
			array( $this, 'output' )
		);
	}

	// In some cases (such as if the authoritative order store was changed earlier in the current request) we
	// need an extra step to remove the menu entry for the menu post type.
	add_action(
		'admin_init',
		function() use ( $order_types ) {
			foreach ( $order_types as $order_type ) {
				remove_submenu_page( 'woocommerce', 'edit.php?post_type=' . $order_type );
			}
		}
	);
}