Gets the CSS for View Transitions in the admin.
Source
function wp_get_view_transitions_admin_css(): string {
$affix = SCRIPT_DEBUG ? '' : '.min';
$path = ABSPATH . "wp-admin/css/view-transitions{$affix}.css";
return file_get_contents( $path );
}
Changelog
| Version | Description |
|---|---|
| 7.0.0 | Introduced. |
This function reads the raw CSS file content and returns it as a string, rather than returning a URL. This is because the view-transitions CSS ends up being registered as inline CSS (added directly inside a tag in wp-admin), not as a separate stylesheet file loaded via .
You can see this in practice: wp_default_styles() calls this function and passes the returned string to $styles->add_data(), using the ‘after’ key, so the CSS is printed inline right after the ‘wp-view-transitions-admin’ handle is enqueued.
Also note that the CSS file used depends on SCRIPT_DEBUG: if it’s true, the unminified ‘view-transitions.css’ is read; otherwise, the minified ‘view-transitions.min.css’ is used, following the same convention as other core styles/scripts.