Make WordPress Core


Ignore:
Timestamp:
06/04/2021 10:47:01 AM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

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

    r51068 r51071  
    361361         *
    362362         * @since 5.8.0
     363         *
    363364         * @param string           $widget_id  ID of the widget marked for deletion.
    364365         * @param string           $sidebar_id ID of the sidebar the widget was deleted from.
     
    414415            $number        = isset( $parsed_id['number'] ) ? $parsed_id['number'] : null;
    415416            $widget_object = $wp_widget_factory->get_widget_object( $id_base );
    416             $creating      = false;
     417            $update        = true;
    417418        } elseif ( $request['id_base'] ) {
    418419            // Saving a new widget.
     
    421422            $number        = $widget_object ? next_widget_id_number( $id_base ) : null;
    422423            $id            = $widget_object ? $id_base . '-' . $number : $id_base;
    423             $creating      = true;
     424            $update        = false;
    424425        } else {
    425426            return new WP_Error(
     
    521522         *
    522523         * @since 5.8.0
     524         *
    523525         * @param string          $id         ID of the widget being saved.
    524526         * @param string          $sidebar_id ID of the sidebar containing the widget being saved.
    525527         * @param WP_REST_Request $request    Request object.
    526          * @param bool            $creating   True when creating a widget, false when updating.
     528         * @param bool            $update     Whether this is an existing widget being updated.
    527529         */
    528         do_action( 'rest_after_save_widget', $id, $sidebar_id, $request, $creating );
     530        do_action( 'rest_after_save_widget', $id, $sidebar_id, $request, $update );
    529531
    530532        return $id;
Note: See TracChangeset for help on using the changeset viewer.