コード例 #1
0
	function blogger_deletePost($args) {

	  global $wpdb;

		$this->escape($args);

	  $post_ID     = $args[1];
	  $user_login  = $args[2];
	  $user_pass   = $args[3];
	  $publish     = $args[4];

	  if (!$this->login_pass_ok($user_login, $user_pass)) {
	    return $this->error;
	  }

	  $actual_post = wp_get_single_post($post_ID,ARRAY_A);

	  if (!$actual_post) {
	  	return new IXR_Error(404, 'Sorry, no such post.');
	  }

	  $user_data = get_userdatabylogin($user_login);

	  if (!user_can_delete_post($user_data->ID, $post_ID)) {
	    return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
	  }

	  $result = wp_delete_post($post_ID);

	  if (!$result) {
	  	return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be deleted.');
	  }

	  return true;
	}
コード例 #2
0
         if (get_option('default_pingback_flag')) {
             register_shutdown_function('pingback', $content, $post_ID);
         }
     }
     if ($post_status == 'static') {
         generate_page_rewrite_rules();
         if (!update_post_meta($post_ID, '_wp_page_template', $_POST['page_template'])) {
             add_post_meta($post_ID, '_wp_page_template', $_POST['page_template'], true);
         }
     }
     exit;
     break;
 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':