Make WordPress Core


Ignore:
Timestamp:
03/06/2025 11:46:47 PM (18 months ago)
Author:
joedolson
Message:

Menus: Validate custom links and add accessible error messages.

Add URL validation in the admin navigation menu manager that matches the validation in the customizer when adding custom links. Improve accessibility of both custom link forms by adding aria-invalid and aria-describedby attributes with visible error messages and announcing the error using wp.a11y.speak().

Props joedolson, nikitasolanki1812, akrocks, pathan-amaankhan, rcreators, ironprogrammer, audrasjb, ankit-k-gupta, chaion07, rinkalpagdar, snehapatil02, jainil07, parthvataliya.
Fixes #60619, #60969.

File:
1 edited

Legend:

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

    r59825 r59948  
    12691269                                        <label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
    12701270                                        <input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" placeholder="https://">
     1271                                        <span id="custom-url-error" class="error-message" style="display: none;"><?php _e( 'Please provide a valid link.' ); ?></span>
    12711272                                </p>
    12721273                                <p id="menu-item-name-wrap" class="wp-clearfix">
    12731274                                        <label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
    12741275                                        <input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox">
     1276                                        <span id="custom-name-error" class="error-message" style="display: none;"><?php _e( 'The link text cannot be empty.' ); ?></span>
    12751277                                </p>
    12761278                                <p class="button-controls">
Note: See TracChangeset for help on using the changeset viewer.