WP_Customize_Nav_Menu_Setting::filter_nav_menu_options_value( array $nav_menu_options, int $menu_id, bool $auto_add )

Updates a nav_menu_options array.


Description Description

See also See also


Top ↑

Parameters Parameters

$nav_menu_options

(array) (Required) Array as returned by get_option( 'nav_menu_options' ).

$menu_id

(int) (Required) The term ID for the given menu.

$auto_add

(bool) (Required) Whether to auto-add or not.


Top ↑

Return Return

(array) (Maybe) modified nav_menu_otions array.


Top ↑

Source Source

File: wp-includes/customize/class-wp-customize-nav-menu-setting.php

	protected function filter_nav_menu_options_value( $nav_menu_options, $menu_id, $auto_add ) {
		$nav_menu_options = (array) $nav_menu_options;
		if ( ! isset( $nav_menu_options['auto_add'] ) ) {
			$nav_menu_options['auto_add'] = array();
		}

		$i = array_search( $menu_id, $nav_menu_options['auto_add'], true );

		if ( $auto_add && false === $i ) {
			array_push( $nav_menu_options['auto_add'], $this->term_id );
		} elseif ( ! $auto_add && false !== $i ) {
			array_splice( $nav_menu_options['auto_add'], $i, 1 );
		}

		return $nav_menu_options;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.