Last active
May 5, 2017 04:13
-
-
Save enqtran/9cd9c119d9b1dd3be509666a09323f9e to your computer and use it in GitHub Desktop.
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
/** | |
* [force_post_title_init] | |
*/ | |
function force_post_title_init() { | |
wp_enqueue_script('jquery'); | |
} | |
function force_post_title() { | |
echo "<script>jQuery('#publish').click(function(){ | |
var testervar = jQuery('[id^=titlediv]').find('#title'); | |
if (testervar.val().length < 1) | |
{ | |
jQuery('#title').css('border', '2px solid red'); | |
setTimeout(jQuery('#ajax-loading').css('visibility', 'hidden'), 100); | |
alert('POST TITLE is required'); | |
setTimeout(jQuery('#publish').removeClass('button-primary-disabled'), 100); | |
return false; | |
} | |
});</script>"; | |
} | |
add_action('admin_init', 'force_post_title_init'); | |
add_action('edit_form_advanced', 'force_post_title'); | |
add_action('edit_page_form', 'force_post_title'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment