wp_font_library_wp_admin_enqueue_scripts( string $hook_suffix )
- Source
wp-includes/build/pages/font-library/page-wp-admin.php:121
Description
Hooked to admin_enqueue_scripts.
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.
Parameters
$hook_suffixstring- The current admin page.
Performance profile
How much work a call to wp_font_library_wp_admin_enqueue_scripts() 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
- Scaling
- Constant
- Instructions
- 6
- Plugin surface
- 2 hooks
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 138.
Third-party callbacks on 'font-library-wp-admin_init', 'font-library-wp-admin_boot_dependencies' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
do_action()called directly
Further down the call graph this can also reach option, cache, serialize, query 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 · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_font_library_wp_admin_enqueue_scripts() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 6 | wp_style_is() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 138 | 6 | 9 | |
| 8.5 | 138 | 6 | 9 | |
| 8.4 | 138 | 6 | 9 | 2 more instructions than PHP 8.3 |
| 8.3 | 136 | 6 | 9 | |
| 8.2 | 136 | 6 | 9 | |
| 8.1 | 136 | 6 | 9 | |
| 7.4 | 136 | 6 | 9 |
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.
Hooks and filters fired · 2
2 hooks fire while wp_font_library_wp_admin_enqueue_scripts() runs, in this order:
- do_action( font-library-wp-admin_init )actionline 141 (+20 into the body)
- apply_filters( font-library-wp-admin_boot_dependencies )filterline 241 (+120 into the body)
Filters the boot script-module dependencies for the font-library-wp-admin page.
Uses · 14
- get_current_screen()Get the current screen object
- do_action()Calls the callback functions that have been added to an action hook.
- wp_font_library_wp_admin_preload_data()Preload REST API data for the font-library-wp-admin page.
- wp_get_font_library_wp_admin_routes()Get all registered routes for the font-library-wp-admin page.
- wp_register_script()Registers a new script.
- wp_add_inline_script()Adds extra code to a registered script.
- wp_json_encode()Encodes a variable into JSON, with some confidence checks.
- wp_style_is()Checks whether a CSS stylesheet has been added to the queue.
- wp_register_style()Registers a CSS stylesheet.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_register_script_module()Registers the script module if no script module with that script module identifier has already been registered.
- wp_enqueue_script()Enqueues a script.
Show all 14
- wp_enqueue_script_module()Marks the script module to be enqueued in the page.
- wp_enqueue_style()Enqueues a CSS stylesheet.
Source code
function wp_font_library_wp_admin_enqueue_scripts( $hook_suffix ) { // Check all possible ways this page can be accessed: // 1. Menu page via admin.php?page=font-library-wp-admin (plugin) // 2. Direct file via font-library.php (Core) - screen ID will be 'font-library' $current_screen = get_current_screen(); $is_our_page = ( ( isset( $_GET['page'] ) && 'font-library-wp-admin' === $_GET['page'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended ( $current_screen && 'font-library' === $current_screen->id ) ); if ( ! $is_our_page ) { return; } // Load build constants $build_constants = require __DIR__ . '/../../constants.php'; /** * Fires when the font-library admin page is initialized so extensions can register routes and menu items. */ do_action( 'font-library-wp-admin_init' ); // Preload REST API data wp_font_library_wp_admin_preload_data(); // Get all registered routes $routes = wp_get_font_library_wp_admin_routes(); // Get boot module asset file for dependencies $asset_file = ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php'; if ( file_exists( $asset_file ) ) { $asset = require $asset_file; // This script serves two purposes: // 1. It ensures all the globals that are made available to the modules are loaded. // 2. It initializes the boot module as an inline script. wp_register_script( 'font-library-wp-admin-prerequisites', '', $asset['dependencies'], $asset['version'], true ); $init_modules = []; /* * Add inline script to initialize the app using initSinglePage (no menuItems). * The dynamic import is deferred until DOMContentLoaded so that all classic * script dependencies of @wordpress/boot (wp-private-apis, wp-components, * wp-theme, etc.) have finished parsing and executing before the boot module * evaluates. Otherwise, a modulepreloaded @wordpress/boot can win the race * against the classic-script-printing pass on fast CDN-fronted hosts in * Chrome, evaluating before wp.theme.privateApis is defined and throwing * "Cannot unlock an undefined object". See <https://core.trac.wordpress.org/ticket/65103>. */ $init_js_function = <<<'JS' ( mountId, routes, initModules ) => { const run = async () => { const mod = await import( "@wordpress/boot" ); mod.initSinglePage( { mountId, routes, initModules } ); }; if ( document.readyState === "loading" ) { document.addEventListener( "DOMContentLoaded", run ); } else { run(); } } JS; wp_add_inline_script( 'font-library-wp-admin-prerequisites', sprintf( '( %s )( %s, %s, %s );', $init_js_function, wp_json_encode( 'font-library-wp-admin-app', JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), wp_json_encode( $routes, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), wp_json_encode( $init_modules, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) ); // Register prerequisites style by filtering script dependencies to find registered styles $style_dependencies = array_filter( $asset['dependencies'], function ( $handle ) { return wp_style_is( $handle, 'registered' ); }Changelog
Unchanged from 7.0.4 through 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/font-library/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.