WP_REST_Global_Styles_Controller::prepare_item_for_response( WP_Post $post, WP_REST_Request $request ): WP_REST_Response
- Since
- 5.9.0, 6.6.0
- Source
wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php:310
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- Global Styles post object.
$requestWP_REST_Request- Request object.
Return value
WP_REST_Response- Response object.
Performance profile
How much work a call to WP_REST_Global_Styles_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
- Heavy
- Scaling
- Scales with input
- Instructions
- 78–166
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_post().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 191.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- serializeserialisation
json_decode()called directly - querycontent query
get_post()one call below WP_REST_Global_Styles_Controller::prepare_item_for_response() - hookthird-party callbacks
apply_filters()one call below WP_REST_Global_Styles_Controller::prepare_item_for_response()
Further down the call graph this can also reach option, cache and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 72 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_REST_Global_Styles_Controller::prepare_item_for_response() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($raw_config) && !rest_is_field_included() | 78–97 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), rest_is_field_included() |
!isset($raw_config) | 85–98 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included() |
!isset($raw_config) | 85–99 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included() |
!isset($raw_config) && empty($value) | 86–105 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 91–110 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 92–113 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) | 92–100 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included() |
!isset($raw_config) && empty($value) | 93–106 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 93–107 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && !empty($value) | 95–115 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 97–118 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && empty($value) | 98–111 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links() |
60 further outcomes, up to 166 instructions
!isset($raw_config) && empty($value) | 98–112 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 99–114 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && empty($value) | 99–115 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && !empty($value) | 100–120 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 100–108 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && !empty($value) | 101–123 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 102–116 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 102–117 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 104–119 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && empty($value) | 104–120 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && empty($value) | 105–113 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && !empty($value) | 106–128 | json_decode(), ->get_fields_for_response(), 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(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 106–116 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && !empty($value) | 107–121 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 107–122 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 108–124 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 108–125 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 109–118 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 111–121 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && !empty($value) | 113–129 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 113–130 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) | 114–133 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included() |
!isset($raw_config) && !empty($value) | 114–123 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 115–126 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 120–131 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) | 121–134 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included() |
!isset($raw_config) | 121–134 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included() |
!isset($raw_config) && empty($value) | 122–141 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 127–146 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 128–149 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) | 128–135 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included() |
!isset($raw_config) && empty($value) | 129–142 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 129–142 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && !empty($value) | 131–151 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 133–154 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && empty($value) | 134–147 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 134–147 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && empty($value) | 135–150 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && empty($value) | 135–150 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && !empty($value) | 136–156 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 136–143 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && !empty($value) | 137–159 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 138–152 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 138–152 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 140–155 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && empty($value) | 140–155 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && empty($value) | 141–148 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links() |
!isset($raw_config) && !empty($value) | 142–164 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 142–151 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && !empty($value) | 143–157 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 143–157 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 144–160 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 144–160 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 145–153 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && empty($value) | 147–156 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links() |
!isset($raw_config) && !empty($value) | 149–165 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 149–165 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 150–158 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 151–161 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
!isset($raw_config) && !empty($value) | 156–166 | json_decode(), ->get_fields_for_response(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), rest_is_field_included(), get_the_title(), rest_is_field_included(), remove_filter(), rest_is_field_included(), remove_filter(), ->add_additional_fields_to_object(), ->filter_response_by_context(), rest_ensure_response(), rest_is_field_included(), rest_is_field_included(), ->prepare_links(), ::WP_Theme_JSON_Resolver(), ->add_links(), ->get_available_actions() |
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 | 191 | 78–166 | 20 | |
| 8.5 | 191 | 78–166 | 20 | |
| 8.4 | 191 | 78–166 | 20 | |
| 8.3 | 191 | 78–166 | 20 | |
| 8.2 | 191 | 78–166 | 20 | |
| 8.1 | 191 | 78–166 | 20 | 3 fewer instructions than PHP 7.4 |
| 7.4 | 194 | 78–167 | 20 |
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 · 13
- 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.
- add_filter()Adds a callback function to a filter hook.
- get_the_title()Retrieves the post title.
- remove_filter()Removes a callback function from a filter hook.
- rest_ensure_response()Ensures a REST response is a response object (for consistency).
- WP_Theme_JSON::__construct()Constructor.
- WP_REST_Global_Styles_Controller::get_fields_for_response()
- stdClass::__construct()
- WP_REST_Global_Styles_Controller::add_additional_fields_to_object()
- WP_REST_Global_Styles_Controller::filter_response_by_context()
- WP_REST_Global_Styles_Controller::prepare_links()Prepares links for the request.
- 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.
Show all 13
- WP_REST_Global_Styles_Controller::get_available_actions()Get the link relations available for the post and current user.
Source code
public function prepare_item_for_response( $post, $request ) { $raw_config = json_decode( $post->post_content, true ); $is_global_styles_user_theme_json = isset( $raw_config['isGlobalStylesUserThemeJSON'] ) && true === $raw_config['isGlobalStylesUserThemeJSON']; $config = array(); $theme_json = null; if ( $is_global_styles_user_theme_json ) { $theme_json = new WP_Theme_JSON( $raw_config, 'custom' ); $config = $theme_json->get_raw_data(); } // Base fields for every post. $fields = $this->get_fields_for_response( $request ); $data = array(); if ( rest_is_field_included( 'id', $fields ) ) { $data['id'] = $post->ID; } if ( rest_is_field_included( 'title', $fields ) ) { $data['title'] = array(); } if ( rest_is_field_included( 'title.raw', $fields ) ) { $data['title']['raw'] = $post->post_title; } if ( rest_is_field_included( 'title.rendered', $fields ) ) { add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); add_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); $data['title']['rendered'] = get_the_title( $post->ID ); remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); } if ( rest_is_field_included( 'settings', $fields ) ) { $data['settings'] = ! empty( $config['settings'] ) && $is_global_styles_user_theme_json ? $config['settings'] : new stdClass(); } if ( rest_is_field_included( 'styles', $fields ) ) { $data['styles'] = ! empty( $config['styles'] ) && $is_global_styles_user_theme_json ? $config['styles'] : new stdClass(); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); // Wrap the data in a response object. $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $links = $this->prepare_links( $post->ID ); // Only return resolved URIs for get requests to user theme JSON. if ( $theme_json ) { $resolved_theme_uris = WP_Theme_JSON_Resolver::get_resolved_theme_uris( $theme_json ); if ( ! empty( $resolved_theme_uris ) ) { $links['https://api.w.org/theme-file'] = $resolved_theme_uris; } } $response->add_links( $links ); if ( ! empty( $links['self']['href'] ) ) { $actions = $this->get_available_actions( $post, $request ); $self = $links['self']['href']; foreach ( $actions as $rel ) { $response->add_link( $rel, $self ); } } } return $response; }Changelog
Introduced in 5.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
_links.from the docblockAbout 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-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.