wppaste
WordPress

wp_font_library_wp_admin_enqueue_scripts( string $hook_suffix )

Source
wp-includes/build/pages/font-library/page-wp-admin.php:121
Enqueue scripts and styles for the font-library-wp-admin page.

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

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
6

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

Plugin surface
2 hooks

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.

Called by
0

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

What it touches

  • hookthird-party callbacksdo_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.

WhenInstructionsCalls it makes
always6wp_style_is()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev13869
8.513869
8.4138692 more instructions than PHP 8.3
8.313669
8.213669
8.113669
7.413669

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:

  1. do_action( font-library-wp-admin_init )actionline 141 (+20 into the body)
  2. 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

Show all 14

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.

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