I want to add a simple confirmation event to the Publish posts button, so when my client hits “Publish” it will ask him if he’s sure, to which he clicks “Yes” or “cancel” and the post then publishes or doesn’t.
I’m new to WordPress…or at least I’ve only done theme and limited plugin programming. I did find the metabox code for the “Publish” button in edit-form-advanced.php
:
add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core');
But to accomplish this, I suspect I’ll need to add the jQuery code elsewhere – preferably in my theme.
For site-specific reasons, I cannot add new plugins to this installation so any changes need to be confined to my theme’s functions.php
file.
You can hook into the post footer actions (based on this answer, not tested):
These actions are called in
wp-admin/admin-footer.php
:This code can be used in a plugin (preferred) or in your themeâs
functions.php
.See also:
There’s a WordPress plugin for that: