REST API: Fix delete widget endpoint

Makes the `DELETE /wp/v2/widgets/:id?force=1` endpoint actually delete the
widget from the `"widget-$id_base"` option and not just remove it from
`'sidebars_widgets'`.

Fixes #53313.
Props TimothyBlynJacobs.


git-svn-id: https://develop.svn.wordpress.org/trunk@51059 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Robert Anderson
2021-06-02 01:21:17 +00:00
parent cf60c451b0
commit 08d48b9e21
2 changed files with 41 additions and 5 deletions

View File

@@ -1304,6 +1304,9 @@ class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase {
$response = rest_do_request( '/wp/v2/widgets/text-1' );
$this->assertEquals( 404, $response->get_status() );
$this->assertArrayNotHasKey( 'text-1', get_option( 'sidebars_widgets' )['sidebar-1'] );
$this->assertArrayNotHasKey( 1, get_option( 'widget_text' ) );
}
/**