Action hook 'rest_delete_widget'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php at line 473

View Source

rest_delete_widget

Action Hook
Description
Fires after a widget is deleted via the REST API.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php View on GitHub
Hook Type Action
Line Number 473

Hook Parameters

Type Name Description
string $widget_id ID of the widget marked for deletion.
string $sidebar_id ID of the sidebar the widget was deleted from.
WP_REST_Response|WP_Error $response The response data, or WP_Error object on failure.
WP_REST_Request $request The request sent to the API.

Usage Examples

Basic Usage
<?php
// Hook into rest_delete_widget
add_action('rest_delete_widget', 'my_custom_function', 10, 4);

function my_custom_function($widget_id, $sidebar_id, $response, $request) {
    // Your custom code here
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php:473 - How this hook is used in WordPress core
<?php
 468  		 * @param string                    $widget_id  ID of the widget marked for deletion.
 469  		 * @param string                    $sidebar_id ID of the sidebar the widget was deleted from.
 470  		 * @param WP_REST_Response|WP_Error $response   The response data, or WP_Error object on failure.
 471  		 * @param WP_REST_Request           $request    The request sent to the API.
 472  		 */
 473  		do_action( 'rest_delete_widget', $widget_id, $sidebar_id, $response, $request );
 474  
 475  		return $response;
 476  	}
 477  
 478  	/**

PHP Documentation

<?php
/**
		 * Fires after a widget is deleted via the REST API.
		 *
		 * @since 5.8.0
		 *
		 * @param string                    $widget_id  ID of the widget marked for deletion.
		 * @param string                    $sidebar_id ID of the sidebar the widget was deleted from.
		 * @param WP_REST_Response|WP_Error $response   The response data, or WP_Error object on failure.
		 * @param WP_REST_Request           $request    The request sent to the API.
		 */
Quick Info
  • Hook Type: Action
  • Parameters: 4
  • File: wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php
Related Hooks

Related hooks will be displayed here in future updates.