wppaste
WordPress

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
Prepare a global styles config output for response.

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

Reaches the database via get_post().

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
78–166

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 191.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • serializeserialisationjson_decode()called directly
  • querycontent queryget_post()one call below WP_REST_Global_Styles_Controller::prepare_item_for_response()
  • hookthird-party callbacksapply_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.

WhenInstructionsCalls it makes
!isset($raw_config) && !rest_is_field_included()78–97json_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–98json_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–99json_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–105json_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–110json_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–113json_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–100json_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–106json_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–107json_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–115json_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–118json_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–111json_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–112json_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–114json_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–115json_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–120json_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–108json_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–123json_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–116json_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–117json_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–119json_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–120json_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–113json_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–128json_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–116json_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–121json_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–122json_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–124json_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–125json_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–118json_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–121json_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–129json_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–130json_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–133json_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–123json_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–126json_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–131json_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–134json_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–134json_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–141json_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–146json_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–149json_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–135json_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–142json_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–142json_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–151json_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–154json_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–147json_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–147json_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–150json_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–150json_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–156json_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–143json_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–159json_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–152json_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–152json_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–155json_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–155json_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–148json_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–164json_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–151json_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–157json_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–157json_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–160json_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–160json_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–153json_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–156json_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–165json_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–165json_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–158json_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–161json_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–166json_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

PHPCompiledExecutedBranchesNotes
8.6-dev19178–16620
8.519178–16620
8.419178–16620
8.319178–16620
8.219178–16620
8.119178–166203 fewer instructions than PHP 7.4
7.419478–16720

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

Show all 13

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.6.0
Added custom relative theme file URIs to _links.from the docblock
5.9.0
Introduced.from the docblock

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-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.