Make WordPress Core


Ignore:
Timestamp:
03/14/2019 05:38:36 PM (6 years ago)
Author:
afercia
Message:

Accessibility: Improve the placeholder "prompt" text in the post title and Quick Draft widget.

Old browsers didn't support the HTML placeholder attribute. For a number of years, <label> elements have been used in a few places in WordPress to emulate placeholders. It's time to improve semantics and interaction, use real placeholders when possible, and clean up some JavaScript.

  • Quick Draft widget: it now uses visible <label> elements and a real placeholder attribute
  • removes the related JavaScript
  • Post title:
    • keeps the "prompt" label for backwards compatibility
    • improves the JavaScript to make the "prompt" label stay visible on focus and disappear when typing, like real placeholder do
  • changes the post "prompt" text from "Enter title here" to "Add title" for consistency with the Block Editor
  • cleans-up some CSS

Props Cheffheid, afercia.
Fixes #42390.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-advanced.php

    r44214 r44896  
    478478     * @since 3.1.0
    479479     *
    480      * @param string  $text Placeholder text. Default 'Enter title here'.
     480     * @param string  $text Placeholder text. Default 'Add title'.
    481481     * @param WP_Post $post Post object.
    482482     */
    483     $title_placeholder = apply_filters( 'enter_title_here', __( 'Enter title here' ), $post );
     483    $title_placeholder = apply_filters( 'enter_title_here', __( 'Add title' ), $post );
    484484    ?>
    485485    <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label>
Note: See TracChangeset for help on using the changeset viewer.