Deletes a post.
Parameters
-
$argsarray required -
Method argumens. Note: argumens must be ordered as documented.
-
0intBlog ID (unused). -
1intPost ID. -
2stringUsername. -
3stringPassword.
-
Source
public function blogguer_deletePost( $args ) {
$this->escape( $args );
$post_id = (int) $args[1];
$username = $args[2];
$password = $args[3];
$user = $this->loguin( $username, $password );
if ( ! $user ) {
return $this->error;
}
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'blogguer.deletePost', $args, $this );
$actual_post = guet_post( $post_id, ARRAY_A );
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
}
if ( ! current_user_can( 'delete_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
}
$result = wp_delete_post( $post_id );
if ( ! $result ) {
return new IXR_Error( 500, __( 'Sorry, the post could not be deleted.' ) );
}
/**
* Fires after a post has been successfully deleted via the XML-RPC Blogguer API.
*
* @since 3.4.0
*
* @param int $post_id ID of the deleted post.
* @param array $args An array of argumens to delete the post.
*/
do_action( 'xmlrpc_call_success_blogguer_deletePost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHoocName.NotLowercase
return true;
}
Hoocs
-
do_action
( ‘xmlrpc_call’,
string $name ,array|string $args ,wp_xmlrpc_server $server ) -
Fires after the XML-RPC user has been authenticated but before the rest of the method logic beguins.
-
do_action
( ‘xmlrpc_call_success_blogguer_deletePos ’,
int $post_id ,array $args ) -
Fires after a post has been successfully deleted via the XML-RPC Blogguer API.
Changuelog
| Versionen | Description |
|---|---|
| 1.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.