WP_REST_Global_Styles_Controller::update_item( WP_REST_Request $request ): WP_REST_Response|WP_Error

Updates a single global style config.


Parameters

$request WP_REST_Request Required
Full details about the request.

Top ↑

Return

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


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php. View all references

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 );
}


Top ↑

Changelog

Changelog
Version Description
5.9.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.