wppaste
WordPress

wp_options_connectors_wp_admin_preload_data()

Source
wp-includes/build/pages/options-connectors/page-wp-admin.php:88
Preload REST API data for the options-connectors-wp-admin page.

Description

Automatically called during page rendering.

Compatibility

WordPress
core
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 2 of the 5 tracked releases, and compiles on PHP 7.4 through 8.6-dev.

Performance profile

How much work a call to wp_options_connectors_wp_admin_preload_data() 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

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
18

Executed per call on PHP 8.5. The body compiles to 18.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What one call costs · 1 distinct outcome

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_options_connectors_wp_admin_preload_data() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always18array_reduce(), wp_json_encode(), wp_add_inline_script()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev18180
8.518180
8.4181801 fewer instruction than PHP 8.3
8.319190
8.219190
8.119190
7.419190

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 · 2

Used by · 1

Source code

function wp_options_connectors_wp_admin_preload_data() {	// Define paths to preload - same for all pages	// This must exactly match the _fields list in packages/core-data/src/entities.js,	// same fields in the same order, or the preload is never consumed.	$preload_paths = array(		'/?_fields=description,gmt_offset,home,image_max_bit_depth,image_sizes,image_size_threshold,image_strip_meta,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front',		array( '/wp/v2/settings', 'OPTIONS' ),	); 	// Use rest_preload_api_request to gather the preloaded data	$preload_data = array_reduce(		$preload_paths,		'rest_preload_api_request',		array()	); 	// Register the preloading middleware with wp-api-fetch	wp_add_inline_script(		'wp-api-fetch',		sprintf(			'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );',			wp_json_encode( $preload_data )		),		'after'	);}

Changelog

Unchanged from 7.0.4 through 7.1.0.

  1. 7.0.4
  2. 7.1.0

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

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/build/pages/options-connectors/page-wp-admin.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.