魯ICP備15002128號-2
你有沒有不小心誤點發布按鈕而發表一篇文章嗎? 如果你使用了社交類插件,誤發布的同時會共享到社交網絡上,甚至可能被搜索引擎收錄,本文的一段代碼將有效防止誤操作的發生。
將下面的代碼添加到您的當前主題的 functions.php 文件:
// 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');
之后,點擊發布按鈕會有如上圖的提示,可以防止誤操作。