case 'delete': check_admin_referer(); $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']); if (!user_can_delete_post($user_ID, $post_id)) { die(__('You are not allowed to delete this post.')); } if (!wp_delete_post($post_id)) { die(__('Error in deleting...')); } $sendback = $_SERVER['HTTP_REFERER']; if (strstr($sendback, 'post.php')) { $sendback = get_settings('siteurl') . '/wp-admin/post.php'; } $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); header('Location: ' . $sendback); generate_page_rewrite_rules(); do_action('delete_post', $post_id); break; case 'editcomment': $title = __('Edit Comment'); $parent_file = 'edit.php'; require_once 'admin-header.php'; get_currentuserinfo(); $comment = (int) $_GET['comment']; $commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)')); if (!user_can_edit_post_comments($user_ID, $commentdata['comment_post_ID'])) { die(__('You are not allowed to edit comments on this post.')); } $content = $commentdata['comment_content']; $content = format_to_edit($content); $content = apply_filters('comment_edit_pre', $content);
function flush_rules() { generate_page_rewrite_rules(); delete_option('rewrite_rules'); $this->wp_rewrite_rules(); if ( function_exists('save_mod_rewrite_rules') ) save_mod_rewrite_rules(); }
function wp_delete_post($postid = 0) { global $wpdb; $postid = (int) $postid; if (!($post = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE ID = {$postid}"))) { return $post; } if ('attachment' == $post->post_status) { return wp_delete_attachment($postid); } do_action('delete_post', $postid); if ('publish' == $post->post_status) { $categories = wp_get_post_cats('', $post->ID); if (is_array($categories)) { foreach ($categories as $cat_id) { $wpdb->query("UPDATE {$wpdb->categories} SET category_count = category_count - 1 WHERE cat_ID = '{$cat_id}'"); wp_cache_delete($cat_id, 'category'); } } } if ('static' == $post->post_status) { $wpdb->query("UPDATE {$wpdb->posts} SET post_parent = {$post->post_parent} WHERE post_parent = {$postid} AND post_status = 'static'"); } $wpdb->query("DELETE FROM {$wpdb->posts} WHERE ID = {$postid}"); $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_post_ID = {$postid}"); $wpdb->query("DELETE FROM {$wpdb->post2cat} WHERE post_id = {$postid}"); $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$postid}"); if ('static' == $post->post_status) { generate_page_rewrite_rules(); } return $post; }