REST API: Rename the `$creating` parameter of `rest_after_save_widget` action to `$update`.
This brings some consistency with similar actions for posts, e.g. `save_post` or `wp_insert_post`. Follow-up to [51068], [51069]. See #53317. Built from https://develop.svn.wordpress.org/trunk@51071 git-svn-id: http://core.svn.wordpress.org/trunk@50680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4e2a6681a0
commit
36cf03ca52
|
@ -213,8 +213,9 @@ class WP_REST_Sidebars_Controller extends WP_REST_Controller {
|
|||
* Fires after a sidebar is updated via the REST API.
|
||||
*
|
||||
* @since 5.8.0
|
||||
* @param array $sidebar The updated sidebar.
|
||||
* @param WP_REST_Request $request Request object.
|
||||
*
|
||||
* @param array $sidebar The updated sidebar.
|
||||
* @param WP_REST_Request $request Request object.
|
||||
*/
|
||||
do_action( 'rest_save_sidebar', $sidebar, $request );
|
||||
|
||||
|
|
|
@ -360,6 +360,7 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
|||
* 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 $response The response data.
|
||||
|
@ -413,14 +414,14 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
|||
$id_base = $parsed_id['id_base'];
|
||||
$number = isset( $parsed_id['number'] ) ? $parsed_id['number'] : null;
|
||||
$widget_object = $wp_widget_factory->get_widget_object( $id_base );
|
||||
$creating = false;
|
||||
$update = true;
|
||||
} elseif ( $request['id_base'] ) {
|
||||
// Saving a new widget.
|
||||
$id_base = $request['id_base'];
|
||||
$widget_object = $wp_widget_factory->get_widget_object( $id_base );
|
||||
$number = $widget_object ? next_widget_id_number( $id_base ) : null;
|
||||
$id = $widget_object ? $id_base . '-' . $number : $id_base;
|
||||
$creating = true;
|
||||
$update = false;
|
||||
} else {
|
||||
return new WP_Error(
|
||||
'rest_invalid_widget',
|
||||
|
@ -520,12 +521,13 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
|||
* Fires after a widget is created or updated via the REST API.
|
||||
*
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @param string $id ID of the widget being saved.
|
||||
* @param string $sidebar_id ID of the sidebar containing the widget being saved.
|
||||
* @param WP_REST_Request $request Request object.
|
||||
* @param bool $creating True when creating a widget, false when updating.
|
||||
* @param bool $update Whether this is an existing widget being updated.
|
||||
*/
|
||||
do_action( 'rest_after_save_widget', $id, $sidebar_id, $request, $creating );
|
||||
do_action( 'rest_after_save_widget', $id, $sidebar_id, $request, $update );
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-51070';
|
||||
$wp_version = '5.8-alpha-51071';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue