rest_delete_widget хук-событиеWP 5.8.0

Fires after a widget is deleted via the REST API.

Использование

add_action( 'rest_delete_widget', 'wp_kama_rest_delete_widget_action', 10, 4 );

/**
 * Function for `rest_delete_widget` action-hook.
 * 
 * @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.
 *
 * @return void
 */
function wp_kama_rest_delete_widget_action( $widget_id, $sidebar_id, $response, $request ){

	// action...
}
$widget_id(строка)
ID of the widget marked for deletion.
$sidebar_id(строка)
ID of the sidebar the widget was deleted from.
$response(WP_REST_Response|WP_Error)
The response data, or WP_Error object on failure.
$request(WP_REST_Request)
The request sent to the API.

Список изменений

С версии 5.8.0 Введена.

Где вызывается хук

WP_REST_Widgets_Controller::delete_item()
rest_delete_widget
wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php 468
do_action( 'rest_delete_widget', $widget_id, $sidebar_id, $response, $request );

Где используется хук в WordPress

wp-includes/default-filters.php 276
add_action( $action, '_delete_option_fresh_site', 0 );