Publish Confirmation For WordPress Classic (2023)
Here's a quick scrap of code that works. There are lots of outdated tutorials out there for old versions of WordPress. This one is tested to be working in WordPress 6.3.2. This will pop up a confirmation dialogue when you try to publish, update, or schedule a post or page.
The Code
Add this to your theme's functions.php
file:
PHPadd_action( "admin_footer", "confirm_publish" );
function confirm_publish() {
echo <<< EOT
<script>
var publishButton = document.getElementById("publish");
if (publishButton !== null) {
publishButton.onclick = function(event) {
event.stopImmediatePropagation();
var publishValue = publishButton.value;
return confirm("Do you want to " + publishValue + " this now?");
};
}
</script>'
EOT;
}
Screenshots
Limitations
- Only for WordPress's classic editor. Won't work in Gutenberg.
- English only. Feel free to translate into other languages.
- After confirmation, your browser may say "This page is asking you to confirm that you want to leave — information you’ve entered may not be saved." - I don't know how to stop that.