Make WordPress Core

Changeset 46843


Ignore:
Timestamp:
12/09/2019 01:48:37 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.
Merges [46842] to the 5.3 branch.
Fixes #48409.

Location:
branches/5.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

  • branches/5.3/src/wp-admin/includes/class-walker-nav-menu-checklist.php

    r46380 r46843  
    6363     * @since 3.0.0
    6464     *
    65      * @global int $_nav_menu_placeholder
     65     * @global int        $_nav_menu_placeholder
     66     * @global int|string $nav_menu_selected_id
    6667     *
    6768     * @param string $output Used to append additional content (passed by reference).
     
    7273     */
    7374    public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
    74         global $_nav_menu_placeholder;
     75        global $_nav_menu_placeholder, $nav_menu_selected_id;
    7576
    7677        $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;
     
    8283        $output .= $indent . '<li>';
    8384        $output .= '<label class="menu-item-title">';
    84         $output .= '<input type="checkbox" class="menu-item-checkbox';
     85        $output .= '<input type="checkbox"' . wp_nav_menu_disabled_check( $nav_menu_selected_id, false ) . ' class="menu-item-checkbox';
    8586
    8687        if ( ! empty( $item->front_or_home ) ) {
  • branches/5.3/src/wp-admin/includes/nav-menu.php

    r46330 r46843  
    256256
    257257/**
    258  * Check whether to disable the Menu Locations meta box submit button
     258 * Check whether to disable the Menu Locations meta box submit button and inputs.
    259259 *
    260260 * @since 3.6.0
     261 * @since 5.3.1 The `$echo` parameter was added.
    261262 *
    262263 * @global bool $one_theme_location_no_menus to determine if no menus exist
    263264 *
    264  * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu
    265  * @return string Disabled attribute if at least one menu exists, false if not
    266  */
    267 function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
     265 * @param int|string $nav_menu_selected_id ID, name, or slug of the currently selected menu.
     266 * @param bool       $echo                 Whether to echo or just return the string.
     267 * @return string|false Disabled attribute if at least one menu exists, false if not.
     268 */
     269function wp_nav_menu_disabled_check( $nav_menu_selected_id, $echo = true ) {
    268270    global $one_theme_location_no_menus;
    269271
     
    272274    }
    273275
    274     return disabled( $nav_menu_selected_id, 0 );
     276    return disabled( $nav_menu_selected_id, 0, $echo );
    275277}
    276278
     
    293295        <p id="menu-item-url-wrap" class="wp-clearfix">
    294296            <label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
    295             <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://" />
     297            <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://" />
    296298        </p>
    297299
    298300        <p id="menu-item-name-wrap" class="wp-clearfix">
    299301            <label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
    300             <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" />
     302            <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" />
    301303        </p>
    302304
     
    570572            <p class="quick-search-wrap">
    571573                <label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
    572                 <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; ?>" />
     574                <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; ?>" />
    573575                <span class="spinner"></span>
    574576                <?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?>
     
    652654        <p class="button-controls wp-clearfix" data-items-type="posttype-<?php echo esc_attr( $post_type_name ); ?>">
    653655            <span class="list-controls hide-if-no-js">
    654                 <input type="checkbox" id="<?php echo esc_attr( $post_type_name . '-tab' ); ?>" class="select-all" />
     656                <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" />
    655657                <label for="<?php echo esc_attr( $post_type_name . '-tab' ); ?>"><?php _e( 'Select All' ); ?></label>
    656658            </span>
     
    881883        <p class="button-controls wp-clearfix" data-items-type="taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>">
    882884            <span class="list-controls hide-if-no-js">
    883                 <input type="checkbox" id="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>" class="select-all" />
     885                <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>" class="select-all" />
    884886                <label for="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>"><?php _e( 'Select All' ); ?></label>
    885887            </span>
Note: See TracChangeset for help on using the changeset viewer.