rest_delete_revision
Action HookDescription
Fires after a revision is deleted via the REST API.Hook Information
File Location |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
View on GitHub
|
Hook Type | Action |
Line Number | 516 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_Post|false|null
|
$result
|
The revision object (if it was deleted or moved to the Trash successfully) or false or null (failure). If the revision was moved to the Trash, $result represents its new state; if it was deleted, $result represents its state before deletion. |
WP_REST_Request
|
$request
|
The request sent to the API. |
Usage Examples
Basic Usage
<?php
// Hook into rest_delete_revision
add_action('rest_delete_revision', 'my_custom_function', 10, 2);
function my_custom_function($result, $request) {
// Your custom code here
}
Source Code Context
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php:516
- How this hook is used in WordPress core
<?php
511 * @param WP_Post|false|null $result The revision object (if it was deleted or moved to the Trash successfully)
512 * or false or null (failure). If the revision was moved to the Trash, $result represents
513 * its new state; if it was deleted, $result represents its state before deletion.
514 * @param WP_REST_Request $request The request sent to the API.
515 */
516 do_action( 'rest_delete_revision', $result, $request );
517
518 if ( ! $result ) {
519 return new WP_Error(
520 'rest_cannot_delete',
521 __( 'The post cannot be deleted.' ),
PHP Documentation
<?php
/**
* Fires after a revision is deleted via the REST API.
*
* @since 4.7.0
*
* @param WP_Post|false|null $result The revision object (if it was deleted or moved to the Trash successfully)
* or false or null (failure). If the revision was moved to the Trash, $result represents
* its new state; if it was deleted, $result represents its state before deletion.
* @param WP_REST_Request $request The request sent to the API.
*/
Quick Info
- Hook Type: Action
- Parameters: 2
- File: wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Related Hooks
Related hooks will be displayed here in future updates.