Created
May 22, 2014 17:40
-
-
Save zackkatz/61f409ec1af7f7c3c771 to your computer and use it in GitHub Desktop.
Require a title in the WordPress Edit Post screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').on( 'submit.edit-post', '#post', function () { | |
// If the title isn't set | |
if( $("#title").val().length === 0 ) { | |
// Show the alert | |
alert('A title is required.'); | |
// Hide the spinner | |
$('#major-publishing-actions .spinner').hide(); | |
// The buttons get "disabled" added to them on submit. Remove that class. | |
$('#major-publishing-actions').find( ':button, :submit, a.submitdelete, #post-preview' ).removeClass( 'disabled' ); | |
// Focus on the title field. | |
$("#title").focus(); | |
return false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment