|
@@ 2788-2827 (lines=40) @@
|
| 2785 |
|
* } |
| 2786 |
|
* @return true|IXR_Error True, if success. |
| 2787 |
|
*/ |
| 2788 |
|
public function wp_deletePage( $args ) { |
| 2789 |
|
$this->escape( $args ); |
| 2790 |
|
|
| 2791 |
|
$username = $args[1]; |
| 2792 |
|
$password = $args[2]; |
| 2793 |
|
$page_id = (int) $args[3]; |
| 2794 |
|
|
| 2795 |
|
if ( !$user = $this->login($username, $password) ) |
| 2796 |
|
return $this->error; |
| 2797 |
|
|
| 2798 |
|
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2799 |
|
do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2800 |
|
|
| 2801 |
|
// Get the current page based on the page_id and |
| 2802 |
|
// make sure it is a page and not a post. |
| 2803 |
|
$actual_page = get_post($page_id, ARRAY_A); |
| 2804 |
|
if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2805 |
|
return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2806 |
|
|
| 2807 |
|
// Make sure the user can delete pages. |
| 2808 |
|
if ( !current_user_can('delete_page', $page_id) ) |
| 2809 |
|
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this page.' ) ); |
| 2810 |
|
|
| 2811 |
|
// Attempt to delete the page. |
| 2812 |
|
$result = wp_delete_post($page_id); |
| 2813 |
|
if ( !$result ) |
| 2814 |
|
return new IXR_Error( 500, __( 'Failed to delete the page.' ) ); |
| 2815 |
|
|
| 2816 |
|
/** |
| 2817 |
|
* Fires after a page has been successfully deleted via XML-RPC. |
| 2818 |
|
* |
| 2819 |
|
* @since 3.4.0 |
| 2820 |
|
* |
| 2821 |
|
* @param int $page_id ID of the deleted page. |
| 2822 |
|
* @param array $args An array of arguments to delete the page. |
| 2823 |
|
*/ |
| 2824 |
|
do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args ); |
| 2825 |
|
|
| 2826 |
|
return true; |
| 2827 |
|
} |
| 2828 |
|
|
| 2829 |
|
/** |
| 2830 |
|
* Edit page. |
|
@@ 4743-4783 (lines=41) @@
|
| 4740 |
|
* } |
| 4741 |
|
* @return true|IXR_Error True when post is deleted. |
| 4742 |
|
*/ |
| 4743 |
|
public function blogger_deletePost( $args ) { |
| 4744 |
|
$this->escape( $args ); |
| 4745 |
|
|
| 4746 |
|
$post_ID = (int) $args[1]; |
| 4747 |
|
$username = $args[2]; |
| 4748 |
|
$password = $args[3]; |
| 4749 |
|
|
| 4750 |
|
if ( !$user = $this->login($username, $password) ) |
| 4751 |
|
return $this->error; |
| 4752 |
|
|
| 4753 |
|
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4754 |
|
do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4755 |
|
|
| 4756 |
|
$actual_post = get_post( $post_ID, ARRAY_A ); |
| 4757 |
|
|
| 4758 |
|
if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4759 |
|
return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4760 |
|
} |
| 4761 |
|
|
| 4762 |
|
if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 4763 |
|
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 4764 |
|
} |
| 4765 |
|
|
| 4766 |
|
$result = wp_delete_post( $post_ID ); |
| 4767 |
|
|
| 4768 |
|
if ( ! $result ) { |
| 4769 |
|
return new IXR_Error( 500, __( 'The post cannot be deleted.' ) ); |
| 4770 |
|
} |
| 4771 |
|
|
| 4772 |
|
/** |
| 4773 |
|
* Fires after a post has been successfully deleted via the XML-RPC Blogger API. |
| 4774 |
|
* |
| 4775 |
|
* @since 3.4.0 |
| 4776 |
|
* |
| 4777 |
|
* @param int $post_ID ID of the deleted post. |
| 4778 |
|
* @param array $args An array of arguments to delete the post. |
| 4779 |
|
*/ |
| 4780 |
|
do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args ); |
| 4781 |
|
|
| 4782 |
|
return true; |
| 4783 |
|
} |
| 4784 |
|
|
| 4785 |
|
/* MetaWeblog API functions |
| 4786 |
|
* specs on wherever Dave Winer wants them to be |