WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response( WP_Post $post, WP_REST_Request $request ): WP_REST_Response|WP_Error
- Since
- 6.3.0, 6.6.0
- Source
wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php:297
Compatibility
- WordPress
- since 6.6.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$postWP_Post- Post revision object.
$requestWP_REST_Request- Request object.
Return value
WP_REST_Response|WP_Error- Response object.
Performance profile
How much work a call to WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 111–176
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 195.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
do_action()one call below WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response()
What one call costs · 32 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !rest_is_field_included() && empty($resolved_theme_uris) | 111–138 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !rest_is_field_included() && !empty($resolved_theme_uris) | 115–142 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 118–145 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 118–145 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 121–148 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 121–148 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 122–149 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 122–149 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 125–152 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 125–152 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 125–152 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 128–155 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
20 further outcomes, up to 176 instructions
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 128–155 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 128–155 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 128–155 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 129–156 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 131–158 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 132–159 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 132–159 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 132–159 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 132–159 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 135–162 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 135–162 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 135–162 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 138–165 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && empty($resolved_theme_uris) | 138–165 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 139–166 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 139–166 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 142–169 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && !empty($resolved_theme_uris) | 142–169 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && rest_is_field_included() && empty($resolved_theme_uris) | 145–172 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver() |
!->is_method() && !is_wp_error() && !empty($global_styles_config) && empty($value) && rest_is_field_included() && !empty($resolved_theme_uris) | 149–176 | ->is_method(), ->get_parent(), ->get_decoded_global_styles_json(), is_wp_error(), ->get_fields_for_response(), ->get_raw_data(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->prepare_date_response(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), ::WP_Theme_JSON_Resolver(), https://api.w.org/theme-file() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 195 | 111–176 | 18 | |
| 8.5 | 195 | 111–176 | 18 | |
| 8.4 | 195 | 111–176 | 18 | |
| 8.3 | 195 | 111–176 | 18 | |
| 8.2 | 195 | 111–176 | 18 | |
| 8.1 | 195 | 111–176 | 18 | 3 fewer instructions than PHP 7.4 |
| 7.4 | 198 | 111–177 | 18 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 15
- is_wp_error()Checks whether the given variable is a WordPress Error.
- wp_register_block_style_variations_from_theme_json_partials()Registers block style variations read in from theme.json partials.
- rest_is_field_included()Given an array of fields to include in a response, some of which may be `nested.fields`, determine whether the provided field should be included in the response body.
- rest_ensure_response()Ensures a REST response is a response object (for consistency).
- WP_REST_Response::__construct()
- WP_REST_Global_Styles_Revisions_Controller::get_parent()
- WP_REST_Global_Styles_Revisions_Controller::get_decoded_global_styles_json()Returns decoded JSON from post content string, or a 404 if not found.
- WP_REST_Global_Styles_Revisions_Controller::get_fields_for_response()
- WP_Theme_JSON_Resolver::get_style_variations()Returns the style variations defined by the theme.
- WP_Theme_JSON::__construct()Constructor.
- stdClass::__construct()
- WP_REST_Global_Styles_Revisions_Controller::prepare_date_response()
Show all 15
- WP_REST_Global_Styles_Revisions_Controller::add_additional_fields_to_object()
- WP_REST_Global_Styles_Revisions_Controller::filter_response_by_context()
- WP_Theme_JSON_Resolver::get_resolved_theme_uris()Resolves relative paths in theme.json styles to theme absolute paths and returns them in an array that can be embedded as the value of `_link` object in REST API responses.
Used by · 1
- WP_REST_Global_Styles_Revisions_Controller::get_items()Returns paginated revisions of the given global styles config custom post type.
Source code
public function prepare_item_for_response( $post, $request ) { // Don't prepare the response body for HEAD requests. if ( $request->is_method( 'HEAD' ) ) { return new WP_REST_Response( array() ); } $parent = $this->get_parent( $request['parent'] ); $global_styles_config = $this->get_decoded_global_styles_json( $post->post_content ); if ( is_wp_error( $global_styles_config ) ) { return $global_styles_config; } $fields = $this->get_fields_for_response( $request ); $data = array(); $theme_json = null; if ( ! empty( $global_styles_config['styles'] ) || ! empty( $global_styles_config['settings'] ) ) { /* * Register block style variations from the theme data. * This is required so the variations pass sanitization of theme.json data. */ if ( ! empty( $global_styles_config['styles']['blocks'] ) ) { $variations = WP_Theme_JSON_Resolver::get_style_variations( 'block' ); wp_register_block_style_variations_from_theme_json_partials( $variations ); } $theme_json = new WP_Theme_JSON( $global_styles_config, 'custom' ); $global_styles_config = $theme_json->get_raw_data(); if ( rest_is_field_included( 'settings', $fields ) ) { $data['settings'] = ! empty( $global_styles_config['settings'] ) ? $global_styles_config['settings'] : new stdClass(); } if ( rest_is_field_included( 'styles', $fields ) ) { $data['styles'] = ! empty( $global_styles_config['styles'] ) ? $global_styles_config['styles'] : new stdClass(); } } if ( rest_is_field_included( 'author', $fields ) ) { $data['author'] = (int) $post->post_author; } if ( rest_is_field_included( 'date', $fields ) ) { $data['date'] = $this->prepare_date_response( $post->post_date_gmt, $post->post_date ); } if ( rest_is_field_included( 'date_gmt', $fields ) ) { $data['date_gmt'] = $this->prepare_date_response( $post->post_date_gmt ); } if ( rest_is_field_included( 'id', $fields ) ) { $data['id'] = (int) $post->ID; } if ( rest_is_field_included( 'modified', $fields ) ) { $data['modified'] = $this->prepare_date_response( $post->post_modified_gmt, $post->post_modified ); } if ( rest_is_field_included( 'modified_gmt', $fields ) ) { $data['modified_gmt'] = $this->prepare_date_response( $post->post_modified_gmt ); } if ( rest_is_field_included( 'parent', $fields ) ) { $data['parent'] = (int) $parent->ID; } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); $resolved_theme_uris = WP_Theme_JSON_Resolver::get_resolved_theme_uris( $theme_json ); if ( ! empty( $resolved_theme_uris ) ) { $response->add_links( array( 'https://api.w.org/theme-file' => $resolved_theme_uris, ) ); } return $response;Changelog
Introduced in 6.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.