WP_REST_Global_Styles_Controller::update_item() – Updates a single global style config.

You appear to be a bot. Output may be restricted

Description

Updates a single global style config.

Usage

$WP_REST_Response|WP_Error = WP_REST_Global_Styles_Controller::update_item( $request );

Parameters

$request
( WP_REST_Request ) required – Full details about the request.

Returns

WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.

Source

File name: wordpress/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
Lines:

1 to 24 of 24
  public function update_item( $request ) {
    $post_before = $this->get_post( $request['id'] );
    if ( is_wp_error( $post_before ) ) {
      return $post_before;
    }

    $changes = $this->prepare_item_for_database( $request );
    $result  = wp_update_post( wp_slash( (array) $changes ), true, false );
    if ( is_wp_error( $result ) ) {
      return $result;
    }

    $post          = get_post( $request['id'] );
    $fields_update = $this->update_additional_fields_for_object( $post, $request );
    if ( is_wp_error( $fields_update ) ) {
      return $fields_update;
    }

    wp_after_insert_post( $post, true, $post_before );

    $response = $this->prepare_item_for_response( $post, $request );

    return rest_ensure_response( $response );
  }
 

 View on GitHub View on Trac