怎么为WordPress文章发布按钮添加确认对话框-WordPress

资源魔 66 0

怎样为WordPress文章公布按钮增加确认对话框?

你有无没有小心正点公布按钮而宣布一篇文章吗? 假如你应用了交际类插件,误公布的同时会同享到交际网络上,乃至可能被搜寻引擎收录,本文的一段代码将无效避免误操作的发作。

bbd6b2c6b1ffbc4c64e17dd660371f8.png

将上面的代码增加到您确当前主题的 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');

之后,点击公布按钮会有如上图的提醒,能够避免误操作。

更多WordPress主题,请返回WordPress模板栏目进行下载!

以上就是怎样为WordPress文章公布按钮增加确认对话框的具体内容,更多请存眷资源魔其它相干文章!

标签: WordPress wordpress教程 wordpress自学 wordpress技术

抱歉,评论功能暂时关闭!