@@ 2880-2919 (lines=40) @@ | ||
2877 | * } |
|
2878 | * @return true|IXR_Error True, if success. |
|
2879 | */ |
|
2880 | public function wp_deletePage( $args ) { |
|
2881 | $this->escape( $args ); |
|
2882 | ||
2883 | $username = $args[1]; |
|
2884 | $password = $args[2]; |
|
2885 | $page_id = (int) $args[3]; |
|
2886 | ||
2887 | if ( !$user = $this->login($username, $password) ) |
|
2888 | return $this->error; |
|
2889 | ||
2890 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
|
2891 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
|
2892 | ||
2893 | // Get the current page based on the page_id and |
|
2894 | // make sure it is a page and not a post. |
|
2895 | $actual_page = get_post($page_id, ARRAY_A); |
|
2896 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
|
2897 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
|
2898 | ||
2899 | // Make sure the user can delete pages. |
|
2900 | if ( !current_user_can('delete_page', $page_id) ) |
|
2901 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this page.' ) ); |
|
2902 | ||
2903 | // Attempt to delete the page. |
|
2904 | $result = wp_delete_post($page_id); |
|
2905 | if ( !$result ) |
|
2906 | return new IXR_Error( 500, __( 'Failed to delete the page.' ) ); |
|
2907 | ||
2908 | /** |
|
2909 | * Fires after a page has been successfully deleted via XML-RPC. |
|
2910 | * |
|
2911 | * @since 3.4.0 |
|
2912 | * |
|
2913 | * @param int $page_id ID of the deleted page. |
|
2914 | * @param array $args An array of arguments to delete the page. |
|
2915 | */ |
|
2916 | do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args ); |
|
2917 | ||
2918 | return true; |
|
2919 | } |
|
2920 | ||
2921 | /** |
|
2922 | * Edit page. |
|
@@ 4855-4892 (lines=38) @@ | ||
4852 | * } |
|
4853 | * @return true|IXR_Error True when post is deleted. |
|
4854 | */ |
|
4855 | public function blogger_deletePost( $args ) { |
|
4856 | $this->escape( $args ); |
|
4857 | ||
4858 | $post_ID = (int) $args[1]; |
|
4859 | $username = $args[2]; |
|
4860 | $password = $args[3]; |
|
4861 | ||
4862 | if ( !$user = $this->login($username, $password) ) |
|
4863 | return $this->error; |
|
4864 | ||
4865 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
|
4866 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
|
4867 | ||
4868 | $actual_post = get_post( $post_ID, ARRAY_A ); |
|
4869 | ||
4870 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
|
4871 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
|
4872 | } |
|
4873 | ||
4874 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
|
4875 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
|
4876 | } |
|
4877 | ||
4878 | $result = wp_delete_post( $post_ID ); |
|
4879 | ||
4880 | if ( ! $result ) { |
|
4881 | return new IXR_Error( 500, __( 'The post cannot be deleted.' ) ); |
|
4882 | } |
|
4883 | ||
4884 | /** |
|
4885 | * Fires after a post has been successfully deleted via the XML-RPC Blogger API. |
|
4886 | * |
|
4887 | * @since 3.4.0 |
|
4888 | * |
|
4889 | * @param int $post_ID ID of the deleted post. |
|
4890 | * @param array $args An array of arguments to delete the post. |
|
4891 | */ |
|
4892 | do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args ); |
|
4893 | ||
4894 | return true; |
|
4895 | } |