Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete widget action #32079

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add delete widget action
  • Loading branch information
tellthemachines committed May 26, 2021
commit 5b8bac2cb0fd138e2ce7bb0711947b09765dc9e6
6 changes: 5 additions & 1 deletion lib/class-wp-rest-widgets-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ public function delete_item_permissions_check( $request ) { // phpcs:ignore Vari
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function delete_item( $request ) {
public function delete_item( $request ) {
$widget_id = $request['id'];
$sidebar_id = wp_find_widgets_sidebar( $widget_id );
$id_base = wp_parse_widget_id( $widget_id )['id_base'];

if ( is_null( $sidebar_id ) ) {
return new WP_Error(
Expand Down Expand Up @@ -318,6 +319,9 @@ public function delete_item( $request ) {
);
}

/** This action is documented in wp-admin/widgets.php */
do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base );

return $prepared;
}

Expand Down