Avoid accidental publishing of a WordPress article
As a WordPress website owner, some of you might have encountered accidental publication of articles. What does it mean to post articles by accident? Just pressing the publish button after an article has not been written or completed. It doesn’t matter if it was before. Because it can be deleted.
But today, it may not work. Because WordPress is now associated with the social network, it will be shared with the social network or news subscription when it is published, which will not be eliminated in a while. So, this accidentally published article can sometimes be catastrophic. So, the question now is how to avoid accidentally publishing articles?
1. Implementation of the practical plugin Publisher Confirmation
This plugin Publisher Confirmation will come up with a dialog box when the author clicks the “Publish” button:
However, this plugin has not been updated for more than 2 years, but the test can be run on the latest version. Perhaps the plugin is simple, and the author believes that there is no need to update.
Second, the use of code method
Some people don’t like to use plug-ins, it doesn’t matter. Copy the following code into your functions.php file, to also achieve this effect:
<pre>// This is the confirmation message that will appear.
$c_message = 'Are you SURE you want to publish this post?';
function confirm_publish(){
global $c_message;
echo '<script type="text/javascript"><!--
var publish = document.getElementById("publish");
if (publish !== null) publish.onclick = function(){
return confirm("'.$c_message.'");
};
// --></script>';
}
add_action('admin_footer', 'confirm_publish');</pre>
After following the steps above accidental publishing of WordPress article won’t be an issue anymore.