Accessibility: Menus: Properly disable form controls on the Menus screen that cannot be used until at least one menu is created.
This ensures that the actual UI controls state matches the visually conveyed state. Props afercia, audrasjb, dinhtungdu, sathyapulse, simonjanin, welcher, SergeyBiryukov. Fixes #48409. Built from https://develop.svn.wordpress.org/trunk@46842 git-svn-id: http://core.svn.wordpress.org/trunk@46642 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
23f45f0346
commit
ac690426eb
|
@ -63,6 +63,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @global int $_nav_menu_placeholder
|
||||
* @global int|string $nav_menu_selected_id
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param object $item Menu item data object.
|
||||
|
@ -71,7 +72,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
* @param int $id Not used.
|
||||
*/
|
||||
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||
global $_nav_menu_placeholder;
|
||||
global $_nav_menu_placeholder, $nav_menu_selected_id;
|
||||
|
||||
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;
|
||||
$possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
|
||||
|
@ -81,7 +82,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
|
||||
$output .= $indent . '<li>';
|
||||
$output .= '<label class="menu-item-title">';
|
||||
$output .= '<input type="checkbox" class="menu-item-checkbox';
|
||||
$output .= '<input type="checkbox"' . wp_nav_menu_disabled_check( $nav_menu_selected_id, false ) . ' class="menu-item-checkbox';
|
||||
|
||||
if ( ! empty( $item->front_or_home ) ) {
|
||||
$output .= ' add-to-top';
|
||||
|
|
|
@ -255,23 +255,25 @@ function wp_nav_menu_taxonomy_meta_boxes() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check whether to disable the Menu Locations meta box submit button
|
||||
* Check whether to disable the Menu Locations meta box submit button and inputs.
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @since 5.3.1 The `$echo` parameter was added.
|
||||
*
|
||||
* @global bool $one_theme_location_no_menus to determine if no menus exist
|
||||
*
|
||||
* @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu
|
||||
* @return string Disabled attribute if at least one menu exists, false if not
|
||||
* @param int|string $nav_menu_selected_id ID, name, or slug of the currently selected menu.
|
||||
* @param bool $echo Whether to echo or just return the string.
|
||||
* @return string|false Disabled attribute if at least one menu exists, false if not.
|
||||
*/
|
||||
function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
|
||||
function wp_nav_menu_disabled_check( $nav_menu_selected_id, $echo = true ) {
|
||||
global $one_theme_location_no_menus;
|
||||
|
||||
if ( $one_theme_location_no_menus ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return disabled( $nav_menu_selected_id, 0 );
|
||||
return disabled( $nav_menu_selected_id, 0, $echo );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -292,12 +294,12 @@ function wp_nav_menu_item_link_meta_box() {
|
|||
<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
|
||||
<p id="menu-item-url-wrap" class="wp-clearfix">
|
||||
<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
|
||||
<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text" class="code menu-item-textbox" placeholder="https://" />
|
||||
<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="code menu-item-textbox" placeholder="https://" />
|
||||
</p>
|
||||
|
||||
<p id="menu-item-name-wrap" class="wp-clearfix">
|
||||
<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
|
||||
<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox" />
|
||||
<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="regular-text menu-item-textbox" />
|
||||
</p>
|
||||
|
||||
<p class="button-controls wp-clearfix">
|
||||
|
@ -569,7 +571,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
|
|||
?>
|
||||
<p class="quick-search-wrap">
|
||||
<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
|
||||
<input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" />
|
||||
<input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" />
|
||||
<span class="spinner"></span>
|
||||
<?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?>
|
||||
</p>
|
||||
|
@ -651,7 +653,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
|
|||
|
||||
<p class="button-controls wp-clearfix" data-items-type="posttype-<?php echo esc_attr( $post_type_name ); ?>">
|
||||
<span class="list-controls hide-if-no-js">
|
||||
<input type="checkbox" id="<?php echo esc_attr( $post_type_name . '-tab' ); ?>" class="select-all" />
|
||||
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $post_type_name . '-tab' ); ?>" class="select-all" />
|
||||
<label for="<?php echo esc_attr( $post_type_name . '-tab' ); ?>"><?php _e( 'Select All' ); ?></label>
|
||||
</span>
|
||||
|
||||
|
@ -880,7 +882,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
|
|||
|
||||
<p class="button-controls wp-clearfix" data-items-type="taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>">
|
||||
<span class="list-controls hide-if-no-js">
|
||||
<input type="checkbox" id="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>" class="select-all" />
|
||||
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>" class="select-all" />
|
||||
<label for="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>"><?php _e( 'Select All' ); ?></label>
|
||||
</span>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.4-alpha-46840';
|
||||
$wp_version = '5.4-alpha-46842';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue