wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_options_connectors_wp_admin_preload_data › WordPress Function
Seitn/v
Veraltetn/v
› wp_options_connectors_wp_admin_preload_data ( Keine Parameter )
| Definiert in: | |
| Codex: |
Preload REST API data for the options-connectors-wp-admin page.
Automatically called during page rendering.Quellcode
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,generate_animated_image_subsizes,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' ),
);
/**
* Filters the REST API paths preloaded for this page.
*
* Each entry is either a string path (GET) or a `[ path, method ]` tuple.
* Pages that know which requests their JS will issue on mount can add
* them here so the responses are embedded in the initial HTML rather
* than fetched over the network after hydration.
*
* @param array<string|string[]> $preload_paths Paths to preload.
*/
$preload_paths = apply_filters( 'wp_options_connectors_wp_admin_preload_paths', $preload_paths );
// 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'
);
}