Make WordPress Core


Ignore:
Timestamp:
10/20/2015 07:07:58 PM (9 years ago)
Author:
westonruter
Message:

Customizer: Implement indicators for invalid nav menu items.

The same indicator on the nav menus admin page is now present for nav menu items in the Customizer. When a menu item is present for a post type that is no longer registered, the menu item will appear with the indicator.

Props kucrut, westonruter.
Fixes #33665.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-setting.php

    r35007 r35302  
    886886        'original_title'   => '',
    887887        'nav_menu_term_id' => 0, // This will be supplied as the $menu_id arg for wp_update_nav_menu_item().
    888         // @todo also expose invalid?
     888        '_invalid'         => false,
    889889    );
    890890
     
    11431143                $this->value[ $key ] = intval( $this->value[ $key ] );
    11441144            }
     1145        }
     1146
     1147        if ( ! isset( $this->value['_invalid'] ) ) {
     1148            $this->value['_invalid'] = (
     1149                ( 'post_type' === $this->value['type'] && ! post_type_exists( $this->value['object'] ) )
     1150                ||
     1151                ( 'taxonomy' === $this->value['type'] && ! taxonomy_exists( $this->value['object'] ) )
     1152            );
    11451153        }
    11461154
     
    12471255            false === $this_item
    12481256            ||
     1257            true === $this_item['_invalid']
     1258            ||
    12491259            (
    12501260                $this->original_nav_menu_term_id === $menu->term_id
     
    14181428            'original_title'   => '',
    14191429            'nav_menu_term_id' => 0,
     1430            '_invalid'         => false,
    14201431        );
    14211432        $menu_item_value = array_merge( $default, $menu_item_value );
     
    14491460            $menu_item_value['status'] = 'publish';
    14501461        }
     1462
     1463        $menu_item_value['_invalid'] = (bool) $menu_item_value['_invalid'];
    14511464
    14521465        /** This filter is documented in wp-includes/class-wp-customize-setting.php */
Note: See TracChangeset for help on using the changeset viewer.