Make WordPress Core


Ignore:
Timestamp:
06/04/2021 11:12:56 PM (3 years ago)
Author:
SergeyBiryukov
Message:

REST API: Restore the $creating parameter of rest_after_save_widget action.

This is consistent with other similar REST API actions.

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

Props TimothyBlynJacobs.
See #53317.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php

    r51071 r51074  
    415415            $number        = isset( $parsed_id['number'] ) ? $parsed_id['number'] : null;
    416416            $widget_object = $wp_widget_factory->get_widget_object( $id_base );
    417             $update        = true;
     417            $creating      = false;
    418418        } elseif ( $request['id_base'] ) {
    419419            // Saving a new widget.
     
    422422            $number        = $widget_object ? next_widget_id_number( $id_base ) : null;
    423423            $id            = $widget_object ? $id_base . '-' . $number : $id_base;
    424             $update        = false;
     424            $creating      = true;
    425425        } else {
    426426            return new WP_Error(
     
    526526         * @param string          $sidebar_id ID of the sidebar containing the widget being saved.
    527527         * @param WP_REST_Request $request    Request object.
    528          * @param bool            $update     Whether this is an existing widget being updated.
     528         * @param bool            $creating   True when creating a widget, false when updating.
    529529         */
    530         do_action( 'rest_after_save_widget', $id, $sidebar_id, $request, $update );
     530        do_action( 'rest_after_save_widget', $id, $sidebar_id, $request, $creating );
    531531
    532532        return $id;
Note: See TracChangeset for help on using the changeset viewer.