WP_Customize_Nav_Menu_Setting::filter_nav_menu_options_value

Advertisement

Summery Summery

Updates a nav_menu_options array.

Syntax Syntax

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

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.

Return Return

(array) (Maybe) modified nav_menu_otions array.

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

Advertisement

Changelog Changelog

Changelog
Version Description
4.3.0 Introduced.

See also See also

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.