Automattic\WooCommerce\Admin\Features\Navigation

Menu::add_setting_item()public staticWC 1.0

Adds a plugin setting item.

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

Хуков нет.

Возвращает

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

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

$result = Menu::add_setting_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. '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. ).

Код Menu::add_setting_item() WC 8.7.0

public static function add_setting_item( $args ) {
	unset( $args['order'] );

	if ( isset( $args['parent'] ) || isset( $args['menuId'] ) ) {
		error_log(  // phpcs:ignore
			sprintf(
				/* translators: 1: Duplicate menu item path. */
				esc_html__( 'The item ID %1$s attempted to register using an invalid option. The arguments `menuId` and `parent` are not allowed for add_setting_item()', 'woocommerce' ),
				'`' . $args['id'] . '`'
			)
		);
	}

	$item_args = array_merge(
		$args,
		array(
			'menuId' => 'secondary',
			'parent' => 'woocommerce-settings',
		)
	);

	self::add_item( $item_args );
}