WordPress.org

Make WordPress Core

Ticket #24423: 24423.patch

File 24423.patch, 613 bytes (added by scruffian, 21 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..a6cf10a 100644
    a b if ( post_type_supports( $post_type, 'comments' ) ) 
    464464 
    465465<?php if ( (isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message']) ) : ?> 
    466466<script type="text/javascript"> 
    467 try{document.post.title.focus();}catch(e){} 
     467try{ 
     468        var post_title = document.post.title; 
     469        if ( post_title.value === '' ) { 
     470                post_title.focus(); 
     471        } 
     472}catch(e){} 
    468473</script> 
    469474<?php endif; ?>