Make WordPress Core

Ticket #42390: 42390.patch

File 42390.patch, 4.7 KB (added by Cheffheid, 8 years ago)

Leaves label hidden with sr-text class, adds placeholder attributes on post title field and dashboard quick post widget.

  • wp-admin/edit-form-advanced.php

     
    571571        $title_placeholder = apply_filters( 'enter_title_here', __( 'Enter title here' ), $post );
    572572        ?>
    573573        <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label>
    574         <input type="text" name="post_title" size="30" value="<?php echo esc_attr( $post->post_title ); ?>" id="title" spellcheck="true" autocomplete="off" />
     574        <input type="text" placeholder="<?php echo esc_attr( $title_placeholder ); ?>" name="post_title" size="30" value="<?php echo esc_attr( $post->post_title ); ?>" id="title" spellcheck="true" autocomplete="off" />
    575575</div>
    576576<?php
    577577/**
  • wp-admin/includes/dashboard.php

     
    501501                <?php endif; ?>
    502502
    503503                <div class="input-text-wrap" id="title-wrap">
    504                         <label class="screen-reader-text prompt" for="title" id="title-prompt-text">
    505 
    506                                 <?php
    507                                 /** This filter is documented in wp-admin/edit-form-advanced.php */
    508                                 echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
    509                                 ?>
     504                        <?php
     505                        /** This filter is documented in wp-admin/edit-form-advanced.php */
     506                        $title_placeholder = apply_filters( 'enter_title_here', __( 'Title' ), $post );
     507                        ?>
     508                        <label class="screen-reader-text" for="title" id="title-prompt-text">
     509                                <?php echo esc_html( $title_placeholder ); ?>
    510510                        </label>
    511                         <input type="text" name="post_title" id="title" autocomplete="off" />
     511                        <input type="text" name="post_title" id="title" autocomplete="off" placeholder="<?php echo esc_attr( $title_placeholder ); ?>" />
    512512                </div>
    513513
    514514                <div class="textarea-wrap" id="description-wrap">
    515                         <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What&#8217;s on your mind?' ); ?></label>
    516                         <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
     515                        <?php $textarea_placeholder = __( 'What&#8217;s on your mind?' ); ?>
     516                        <label class="screen-reader-text prompt" for="content" id="content-prompt-text">
     517                                <?php echo esc_html( $textarea_placeholder ); ?>
     518                        </label>
     519                        <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off" placeholder="<?php echo esc_attr( $textarea_placeholder ); ?>"></textarea>
    517520                </div>
    518521
    519522                <p class="submit">
  • wp-admin/js/dashboard.js

     
    9393
    9494                $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
    9595
    96                 $('#title, #tags-input, #content').each( function() {
    97                         var input = $(this), prompt = $('#' + this.id + '-prompt-text');
    98 
    99                         if ( '' === this.value ) {
    100                                 prompt.removeClass('screen-reader-text');
    101                         }
    102 
    103                         prompt.click( function() {
    104                                 $(this).addClass('screen-reader-text');
    105                                 input.focus();
    106                         });
    107 
    108                         input.blur( function() {
    109                                 if ( '' === this.value ) {
    110                                         prompt.removeClass('screen-reader-text');
    111                                 }
    112                         });
    113 
    114                         input.focus( function() {
    115                                 prompt.addClass('screen-reader-text');
    116                         });
    117                 });
    118 
    11996                $('#quick-press').on( 'click focusin', function() {
    12097                        wpActiveEditor = 'content';
    12198                });
  • wp-admin/js/post.js

     
    10321032                editPermalink();
    10331033        });
    10341034
    1035         /**
    1036          * Add screen reader text to the title prompt when needed.
    1037          *
    1038          * @summary Title screen reader text handler.
    1039          *
    1040          * @param {string} id Optional. HTML ID to add the screen reader helper text to.
    1041          *
    1042          * @global
    1043          *
    1044          * @returns void
    1045          */
    1046         wptitlehint = function(id) {
    1047                 id = id || 'title';
    1048 
    1049                 var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text');
    1050 
    1051                 if ( '' === title.val() )
    1052                         titleprompt.removeClass('screen-reader-text');
    1053 
    1054                 titleprompt.click(function(){
    1055                         $(this).addClass('screen-reader-text');
    1056                         title.focus();
    1057                 });
    1058 
    1059                 title.blur(function(){
    1060                         if ( '' === this.value )
    1061                                 titleprompt.removeClass('screen-reader-text');
    1062                 }).focus(function(){
    1063                         titleprompt.addClass('screen-reader-text');
    1064                 }).keydown(function(e){
    1065                         titleprompt.addClass('screen-reader-text');
    1066                         $(this).unbind(e);
    1067                 });
    1068         };
    1069 
    1070         wptitlehint();
    1071 
    10721035        // Resize the WYSIWYG and plain text editors.
    10731036        ( function() {
    10741037                var editor, offset, mce,