Skip to content

Instantly share code, notes, and snippets.

@plasticmind
Created December 19, 2012 16:20
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save plasticmind/4337952 to your computer and use it in GitHub Desktop.
Save plasticmind/4337952 to your computer and use it in GitHub Desktop.
Adds a confirmation dialogue to the WordPress publish button.
/* = Add a "molly guard" to the publish button */
add_action( 'admin_print_footer_scripts', 'sr_publish_molly_guard' );
function sr_publish_molly_guard() {
echo <<<EOT
<script>
jQuery(document).ready(function($){
$('#publishing-action input[name="publish"]').click(function() {
if(confirm('Are you sure you want to publish this?')) {
return true;
} else {
$('#publishing-action .spinner').hide();
$('#publishing-action img').hide();
$(this).removeClass('button-primary-disabled');
return false;
}
});
});
</script>
EOT;
}
@jamescosta
Copy link

Tried to push a change but am not sure why it's not working - the first line should have to after "molly guard" and between the.

<3

@plasticmind
Copy link
Author

Nice catch, James... fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment