wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
site_editor_wp_admin_preload_data › WordPress Function
Seitn/v
Veraltetn/v
› site_editor_wp_admin_preload_data ( Keine Parameter )
| Definiert in: | |
| Codex: |
Preload REST API data for the site-editor-wp-admin page.
Automatically called during page rendering.Quellcode
function site_editor_wp_admin_preload_data() {
// Define paths to preload - same for all pages
$preload_paths = array(
'/?_fields=description,gmt_offset,home,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'
);
}
}