为WordPress文章发布按钮添加确(que)认对话框,为W文章可以通(tong)过以下步骤实现:(图片来源网络,发布侵删)
1、按钮打开WordPress后台,添加进入“外观”“编辑”,对话选择要编辑的为W文章主题的functions.php文件。

2、发布在functions.php文(wen)件末尾,按钮添加以(yi)下代码:

// 为发布按钮添加确认对话框function add_confirmation_dialog($content) { global $post; if (isset($post>ID)) { $content .= '<script type="text/javascript"> document.getElementById("publish").onclick = function() { if (!confirm("确定要发布吗?添加")) { return false; } }; </script>'; } return $content;}// 在(zai)发布按钮上显示确认对话框add_filter('the_content', 'add_confirmation_dialog');3、保存并关闭functions.php文件(jian)。对话

4、为W文(wen)章刷新WordPress后台,发布现在在点击发布按钮时,按钮会弹出确认对话框。添加(jia)
注意:这段代(dai)码将确认(ren)对话框添加到了发布按钮上(shang),对话如果需要(yao)将(jiang)其(qi)添加到其他按钮上,可以(yi)修(xiu)改document.getElementById("publish")中的"publish"为相应的按钮ID。
电话:19950435391
网 址:http://bindebake.cn/
邮 箱:35525274@qq.com
地 址:上海市长宁66号