diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-includes/customize/class-wp-customize-nav-menu-setting.php --- a/wp/wp-includes/customize/class-wp-customize-nav-menu-setting.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-includes/customize/class-wp-customize-nav-menu-setting.php Tue Dec 15 13:49:49 2020 +0100 @@ -125,12 +125,12 @@ * * @since 4.3.0 * - * @param WP_Customize_Manager $manager Bootstrap Customizer instance. - * @param string $id An specific ID of the setting. Can be a - * theme mod or option name. + * @throws Exception If $id is not valid for this setting type. + * + * @param WP_Customize_Manager $manager Customizer bootstrap instance. + * @param string $id A specific ID of the setting. + * Can be a theme mod or option name. * @param array $args Optional. Setting arguments. - * - * @throws Exception If $id is not valid for this setting type. */ public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) { if ( empty( $manager->nav_menus ) ) { @@ -156,7 +156,7 @@ * @return array Instance data. */ public function value() { - if ( $this->is_previewed && $this->_previewed_blog_id === get_current_blog_id() ) { + if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) { $undefined = new stdClass(); // Symbol. $post_value = $this->post_value( $undefined ); @@ -179,7 +179,7 @@ $value['auto_add'] = false; if ( isset( $nav_menu_options['auto_add'] ) && is_array( $nav_menu_options['auto_add'] ) ) { - $value['auto_add'] = in_array( $term->term_id, $nav_menu_options['auto_add'] ); + $value['auto_add'] = in_array( $term->term_id, $nav_menu_options['auto_add'], true ); } } } @@ -188,6 +188,7 @@ $value = $this->default; } } + return $value; } @@ -285,7 +286,7 @@ ) ); } - // @todo add support for $args['hide_empty'] === true + // @todo Add support for $args['hide_empty'] === true. return $menus; } @@ -381,10 +382,10 @@ * @since 4.3.0 * * @param array $nav_menu_options Nav menu options including auto_add. - * @return array (Kaybe) modified nav menu options. + * @return array (Maybe) modified nav menu options. */ public function filter_nav_menu_options( $nav_menu_options ) { - if ( $this->_previewed_blog_id !== get_current_blog_id() ) { + if ( get_current_blog_id() !== $this->_previewed_blog_id ) { return $nav_menu_options; } @@ -517,7 +518,7 @@ $name_conflict_suffix = 1; while ( is_wp_error( $r ) && 'menu_exists' === $r->get_error_code() ) { $name_conflict_suffix += 1; - /* translators: 1: original menu name, 2: duplicate count */ + /* translators: 1: Original menu name, 2: Duplicate count. */ $menu_data['menu-name'] = sprintf( __( '%1$s (%2$d)' ), $original_name, $name_conflict_suffix ); $r = wp_update_nav_menu_object( $menu_id, wp_slash( $menu_data ) ); } @@ -555,7 +556,7 @@ } $post_value = $setting->post_value( null ); - if ( ! is_null( $post_value ) && $this->previous_term_id === intval( $post_value ) ) { + if ( ! is_null( $post_value ) && intval( $post_value ) === $this->previous_term_id ) { $this->manager->set_post_value( $setting->id, $this->term_id ); $setting->save(); } @@ -602,7 +603,8 @@ $nav_menu_options['auto_add'] = array(); } - $i = array_search( $menu_id, $nav_menu_options['auto_add'] ); + $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 ) {