Automattic\WooCommerce\Admin\Features\Navigation

Menu::add_plugin_item()public staticWC 1.0

Adds a plugin item.

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

Хуков нет.

Возвращает

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

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

$result = Menu::add_plugin_item( $args );
$args(массив) (обязательный)
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() WC 8.7.0

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 );
}