WordPress at a glance
function is not described

Automattic\WooCommerce\Admin

PageController::register_page() public WC 1.0

Adds a JS powered page to wc-admin.

{} It's a method of the class: PageController{}

No Hooks.

Return

null. Nothing.

Usage

$PageController = new PageController();
$PageController->register_page( $options );
$options(array) (required)

Array describing the page.

  • id(string)
    Id to reference the page.

  • title(string)
    Page title. Used in menus and breadcrumbs.

  • parent(string|null)
    Parent ID. Null for new top level page.

  • path(string)
    Path for this page, full path in app context; ex /analytics/report

  • capability(string)
    Capability needed to access the page.

  • icon(string)
    Icon. Dashicons helper class, base64-encoded SVG, or 'none'.

  • position(int)
    Menu item position.

  • order(int)
    Navigation item order.

Code of PageController::register_page() WC 5.2.2

<?php
public function register_page( $options ) {
	$defaults = array(
		'id'         => null,
		'parent'     => null,
		'title'      => '',
		'capability' => 'view_woocommerce_reports',
		'path'       => '',
		'icon'       => '',
		'position'   => null,
		'js_page'    => true,
	);

	$options = wp_parse_args( $options, $defaults );

	if ( 0 !== strpos( $options['path'], self::PAGE_ROOT ) ) {
		$options['path'] = self::PAGE_ROOT . '&path=' . $options['path'];
	}

	if ( is_null( $options['parent'] ) ) {
		add_menu_page(
			$options['title'],
			$options['title'],
			$options['capability'],
			$options['path'],
			array( __CLASS__, 'page_wrapper' ),
			$options['icon'],
			$options['position']
		);
	} else {
		$parent_path = $this->get_path_from_id( $options['parent'] );
		// @todo check for null path.
		add_submenu_page(
			$parent_path,
			$options['title'],
			$options['title'],
			$options['capability'],
			$options['path'],
			array( __CLASS__, 'page_wrapper' )
		);
	}

	$this->connect_page( $options );
}