Skip to content

Commit

Permalink
REST API: Restore the $creating parameter of `rest_after_save_widge…
Browse files Browse the repository at this point in the history
…t` action.

This is consistent with other similar REST API actions.

Partially reverts [51071], except for DocBlock formatting fixes.

Props TimothyBlynJacobs.
See #53317.

git-svn-id: https://develop.svn.wordpress.org/trunk@51074 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Jun 4, 2021
1 parent 8aecdaa commit d935e0c
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -414,14 +414,14 @@ protected function save_widget( $request, $sidebar_id ) {
$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 );
$update = true;
$creating = false;
} 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;
$update = false;
$creating = true;
} else {
return new WP_Error(
'rest_invalid_widget',
Expand Down Expand Up @@ -525,9 +525,9 @@ protected function save_widget( $request, $sidebar_id ) {
* @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 $update Whether this is an existing widget being updated.
* @param bool $creating True when creating a widget, false when updating.
*/
do_action( 'rest_after_save_widget', $id, $sidebar_id, $request, $update );
do_action( 'rest_after_save_widget', $id, $sidebar_id, $request, $creating );

return $id;
}
Expand Down

0 comments on commit d935e0c

Please sign in to comment.