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 |
---|---|---|
暂无下载 | 暂无下载 | |
暂无下载 | 暂无下载 | |
暂无下载 | 暂无下载 |