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

来源:undefined 2024-12-27 10:29:53 1059

怎么为

你有没有不小心误点发布按钮而发表一篇文章吗?  如果你使用了社交类插件,误发布的同时会共享到社交网络上,甚至可能被搜索引擎收录,本文的一段代码将有效防止误操作的发生。

将下面的代码添加到您的当前主题的 functions.php 文件:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

// 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><!--

var publish = document.getElementById("publish");

if (publish !== null) publish.onclick = function(){

return confirm("&#39;.$c_message.&#39;");

};

// --></script>;

}

add_action(admin_footer, confirm_publish);

登录后复制

之后,点击发布按钮会有如上图的提示,可以防止误操作。

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

以上就是怎么为WordPress文章发布按钮添加确认对话框的详细内容,更多请关注php中文网其它相关文章!

最新文章