Automattic\WooCommerce\Admin\Features\Navigation

Menu::add_plugin_item()public staticWC 1.0

Adds a plugin item.

Method of the class: Menu{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = Menu::add_plugin_item( $args );
$args(array) (required)
Array containing the necessary arguments.
php $args = array( 'id' => (string) The unique ID of the menu item. Required. 'title' => (string) Title of the menu item. Required. 'parent' => (string) Parent menu item ID. 'capability' => (string) Capability to view this menu item. 'url' => (string) URL or callback to be used. Required. 'migrate' => (bool) Whether or not to hide the item in the wp admin menu. 'order' => (int) Menu item order. 'matchExpression' => (string) A regular expression used to identify if the menu item is active. ).

Menu::add_plugin_item() code WC 8.6.1

public static function add_plugin_item( $args ) {
	if ( ! isset( $args['parent'] ) ) {
		unset( $args['order'] );
	}

	$item_args = array_merge(
		$args,
		array(
			'menuId' => 'plugins',
		)
	);

	$menu_id = self::get_item_menu_id( $item_args );

	if ( 'plugins' !== $menu_id ) {
		return;
	}

	self::add_item( $item_args );
}