WP_REST_Menus_Controller::get_menu_auto_add() WordPress Method

The WP_REST_Menus_Controller::get_menu_auto_add() method is used to get the list of menu items that should be automatically added to a menu. This is useful for creating menus from scratch or for adding new content to an existing menu.

WP_REST_Menus_Controller::get_menu_auto_add( int $menu_id ) #

Returns the value of a menu’s auto_add setting.


Parameters

$menu_id

(int)(Required)The menu id to query.


Top ↑

Return

(bool) The value of auto_add.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php

	protected function get_menu_auto_add( $menu_id ) {
		$nav_menu_option = (array) get_option( 'nav_menu_options', array( 'auto_add' => array() ) );

		return in_array( $menu_id, $nav_menu_option['auto_add'], true );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.