天天下载:
  • 更改回复跟登陆下载方式,下载链接增加验证功能,超时失效...2024-07-25
  • 清理资源失效下载3W+,服务器未引用不关联沉淀图片8W+张...2024-06-25
  • 服务器系统升级,时间24小时,如发现站点bug请反馈...2024-06-15
  • 重新起航!开放注册中,站点有问题请反馈......2023-05-16

[WordPress教程]WordPress 如何实现删除文章并通知投稿作者不通过理由

更新时间:2023-04-08 16:04 分类: 建站教程 人气: (482) 0个评论

直接上代码,比较简单
[Wordpress教程]WordPress 如何实现删除文章并通知投稿作者不通过理由

add_action( 'post_submitbox_misc_actions', 'ttzip_delete_notice_metabox' );
function ttzip_delete_notice_metabox(){
global $post;
echo '<div class="misc-pub-section"><a href="javascript:;" class="submitdelete modown-delete-notice" data-id="'.$post->ID.'">移动至回收站并通知作者</a></div>

<script>
jQuery(".ttzip-delete-notice").click(function(){
var ret = prompt("删除理由", "");
if(ret !== null && ret != "") {
//console.log(ret);
jQuery.ajax({
url: ajaxurl,
data: {
pid: jQuery(this).data("id"),
why: ret,
action: "ttzip_delete_notice"
},
dataType: "json",
type: "POST",
success: function(t) {
if(t.status == 1){
location.href="/wp-admin/edit.php";
}else{
alert(t.msg);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {

}
})
}
});
</script>
';
}


function ttzip_delete_notice_callback(){
global $wpdb,$current_user;
date_default_timezone_set('Asia/Shanghai'); 
$status = 0;$msg = '处理失败';
if(current_user_can('administrator')){
$post_id = $_POST['pid'];
$cpost = get_post($post_id);
_mbt_add_notice($cpost->post_author, sprintf(__('您好,您发表的文章《%s》审核不通过,原因:'.$_POST['why'].'。','ttzip'), $cpost->post_title), 'post_trash', $post_id);
wp_trash_post($post_id);
$status = 1;
}

$result = array(
'status' => $status,
'msg' => $msg
);

header('Content-type: application/json');
echo json_encode($result);
exit;
}
add_action( 'wp_ajax_modown_delete_notice', 'ttzip_delete_notice_callback');
历史版本
版本下载点1下载点2
暂无下载暂无下载
暂无下载暂无下载
暂无下载暂无下载
除特别注明外,本站所有文章均为天天下载原创,转载请注明出处来自https://www.ttzip.com/wordpress-deleting-for-rejection.html
4人喜欢