Pages::register_page( array $options = array() )

Adds a page to tec-admin.


Parameters

$options

(array) (Optional) 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.
  • 'callback'
    (callable) The function to be called to output the content for the page.

Default value: array()


Top ↑

Return

(string) $page The resulting page's hook_suffix.


Top ↑

Source

File: src/Tribe/Admin/Pages.php

	public function register_page( $options = [] ) {
		$defaults = [
			'id'         => null,
			'parent'     => null,
			'title'      => '',
			'capability' => self::get_capability(),
			'path'       => '',
			'icon'       => '',
			'position'   => null,
			'callback'   => [ __CLASS__, 'render_page' ],
		];

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

		if ( is_null( $options['parent'] ) ) {
			$page = add_menu_page(
				$options['title'],
				$options['title'],
				$options['capability'],
				$options['path'],
				$options['callback'],
				$options['icon'],
				$options['position']
			);
		} else {
			$page = add_submenu_page(
				$options['parent'],
				$options['title'],
				$options['title'],
				$options['capability'],
				$options['path'],
				$options['callback']
			);
		}

		$this->connect_page( $options );

		return $page;
	}

Top ↑

Changelog

Changelog
Version Description
4.15.0 Introduced.