WordPress.org

Make WordPress Core

Ticket #24423: 24423.2.patch

File 24423.2.patch, 639 bytes (added by scruffian, 10 months ago)

Only focus the post title when it is empty

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

    diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
    index 044e0b3..ffd376f 100644
    a b if ( post_type_supports( $post_type, 'comments' ) ) 
    462462        wp_comment_reply(); 
    463463?> 
    464464 
    465 <?php if ( (isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message']) ) : ?> 
    466465<script type="text/javascript"> 
    467 try{document.post.title.focus();}catch(e){} 
     466try{ 
     467        var post_title = document.post.title; 
     468        if ( post_title.value === '' ) { 
     469                post_title.focus(); 
     470        } 
     471}catch(e){} 
    468472</script> 
    469 <?php endif; ?>