怎么为wordpress文章发布按钮添加确认对话框?
你有没有不小心误点发布按钮而发表一篇文章吗? 如果你使用了社交类插件,误发布的同时会共享到社交网络上,甚至可能被搜索引擎收录,本文的一段代码将有效防止误操作的发生。
将下面的代码添加到您的当前主题的functions.php文件:
//Thisistheconfirmationmessagethatwillappear.$c_message='AreyouSUREyouwanttopublishthispost?';functionconfirm_publish(){global$c_message;echo'<scripttype="text/javascript"><!--varpublish=document.getElementById("publish");if(publish!==null)publish.onclick=function(){returnconfirm("'.$c_message.'");};//--></script>';}add_action('admin_footer','confirm_publish');