ACF_Location_Nav_Menu::get_valuespublicACF 5.9.0

Returns an array of possible values for this rule type.

Method of the class: ACF_Location_Nav_Menu{}

No Hooks.

Returns

Array.

Usage

$ACF_Location_Nav_Menu = new ACF_Location_Nav_Menu();
$ACF_Location_Nav_Menu->get_values( $rule );
$rule(array) (required)
A location rule.

Changelog

Since 5.9.0 Introduced.

ACF_Location_Nav_Menu::get_values() code ACF 6.0.4

public function get_values( $rule ) {
	$choices = array(
		'all' => __( 'All', 'acf' ),
	);

	// Append locations.
	$nav_locations = get_registered_nav_menus();
	if ( $nav_locations ) {
		$cat = __( 'Menu Locations', 'acf' );
		foreach ( $nav_locations as $slug => $title ) {
			$choices[ $cat ][ "location/$slug" ] = $title;
		}
	}

	// Append menu IDs.
	$nav_menus = wp_get_nav_menus();
	if ( $nav_menus ) {
		$cat = __( 'Menus', 'acf' );
		foreach ( $nav_menus as $nav_menu ) {
			$choices[ $cat ][ $nav_menu->term_id ] = $nav_menu->name;
		}
	}

	// Return choices.
	return $choices;
}