Publish Confirmation For WordPress Classic (2023)

By admin
Here’s a quick scrap of code that works. There are lots of outdated tutorials out there for old versions of

WordPress
ORG

. This one is tested to be working in

WordPress 6.3.2
PRODUCT

. This will pop up a confirmation dialogue when you try to publish, update, or schedule a post or page.

Add this to your theme’s functions.php file:

add_action( "admin_footer", "confirm_publish" ); function confirm_publish() { echo <<<

EOT
CARDINAL

<script> var publishButton = document.getElementById("publish"); if (publishButton !== null) { publishButton.onclick = function(event) { event.stopImmediatePropagation(); var publishValue = publishButton.value; return

confirm("Do
ORG

you want to " + publishValue + " this now?"); }; } </script>’

EOT
CARDINAL

; }