Loading
0

WordPress教程 在WordPress发布文章时跳出弹窗确认提示方法

很多站长在使用WordPress的时候会遇到没完成编辑就不小心点击了发布按钮,虽然影响不大,但是等发布后可以继续编辑,但是对于一些站长而言,是不能忍受的,那么在WordPress发布文章时跳出弹窗确认提示方法是什么?

WordPress教程 在WordPress发布文章时跳出弹窗确认提示方法

下面是实现代码,加入到主题的 functions.php 中即可。

//WordPress发布文章弹窗提示

function publish_confirm() {

echo "

<script>

jQuery(document).ready(function($){

$('#publishing-action input[name=\"publish\"]').click(function() {

if(confirm('确定现在发布文章吗?')) {

return true;

} else {

$('#publishing-action .spinner').hide();

$('#publishing-action img').hide();

$(this).removeClass('button-primary-disabled');

return false;

}

});

});

</script>";

}

//add_action('admin_footer-post.php', 'publish_confirm');//文章修改等页面加载

add_action('admin_footer-post-new.php', 'publish_confirm');//文章发表页面加载

//add_action( 'admin_print_footer_scripts', 'publish_confirm' );//所有后台底部加载