-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add view transitions in WP Admin #10699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Add view transitions in WP Admin #10699
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
src/wp-includes/view-transitions.php
Outdated
| * @return string The CSS. | ||
| */ | ||
| function wp_get_view_transitions_admin_css(): string { | ||
| $css = <<<CSS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to have this CSS in a file and then load it? See what is being merged soon in #10676
This would enable CSS linting as well as minification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! Will update to move this to a CSS file. Just would want to make sure that that file never gets loaded as its own HTTP request since that would be somewhat pointless with its 2 lines or so :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started working on this locally, but I think because this is "very" modern CSS, I think Core's linters don't like it because they're probably outdated.
I'm not familiar with that tooling, so I'm unsure whether we can simply update it or whether that would introduce a new set of problems to address. Do you have any insights on this?
Specifically, it's complaining about the <custom-ident> bit: ") expected" 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, CSS validation in the Customizer and Site Editor are outdated I know. See Core-64418. With the CSS linter, can it be suppressed with a comment? Which tool is failing? Maybe we can update the dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humm, I tried adding a src/wp-admin/css/view-transitions.css file containing:
@view-transition {
navigation: auto;
}
#adminmenu > .menu-top {
view-transition-name: attr( id type(<custom-ident>), none );
}Then I ran npm run build:dev and it successfully emitted a src/wp-admin/css/view-transitions.min.css containing:
/*! This file is auto-generated */
@view-transition{navigation:auto}#adminmenu>.menu-top{view-transition-name:attr(id type(<custom-ident>),none)}So it seems to be working fine.
|
@westonruter Do you have an idea how to best fix https://github.com/WordPress/wordpress-develop/actions/runs/20884023219/job/60004547145?pr=10699 or why it fails? My hunch is that it's because the |
|
@felixarntz That's strange, because for the E2E test it does a full build, right? For running PHPUnit tests, I know a build isn't done, and this causes all kinds of headaches when wordpress-develop/tests/phpunit/tests/formatting/emoji.php Lines 18 to 19 in 376539e
But I don't see how this would be needed for E2E tests if they were working correctly with |
|
To debug whether the build is the problem, maybe temporarily change: $affix = SCRIPT_DEBUG ? '' : '.min';To: $affix = ''; |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @felixarntz for the PR! Overall look solid to me. Left some feedback/Questions.
| $path = ABSPATH . "wp-admin/css/view-transitions{$affix}.css"; | ||
| return file_get_contents( $path ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $path = ABSPATH . "wp-admin/css/view-transitions{$affix}.css"; | |
| return file_get_contents( $path ); | |
| $path = ABSPATH . "wp-admin/css/view-transitions{$affix}.css"; | |
| if ( ! file_exists( $path ) || ! is_readable( $path ) ) { | |
| return ''; | |
| } | |
| return file_get_contents( $path ); |
Should we check whether the file exists and return an empty string if it doesn’t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we needs to add filter so we can extend the CSS? Something like:
return apply_filters( 'wp_view_transitions_admin_css', file_get_contents( $path ) );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check whether the file exists and return an empty string if it doesn’t?
It should exist. If not, it's an error. We don't do a file_exists() check in _print_emoji_detection_script(), for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds View Transitions support for the WordPress admin interface. It introduces a new view-transitions.php file with functions to enqueue view transitions CSS, registers a virtual CSS asset wp-view-transitions-admin with inline CSS for smooth transitions between admin menu items, and automatically enqueues this asset on admin pages via the admin_enqueue_scripts hook.
Changes:
- New
view-transitions.phpfile with helper functions for view transitions CSS - Virtual CSS asset registration with inline CSS in
script-loader.php - Hook to auto-enqueue on
admin_enqueue_scriptsindefault-filters.php - New CSS file with view transition rules for admin menu items
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/wp-includes/view-transitions.php |
New file containing functions to enqueue and retrieve view transitions CSS for admin |
src/wp-includes/script-loader.php |
Registers the wp-view-transitions-admin virtual CSS asset with inline styles |
src/wp-includes/default-filters.php |
Adds hook to auto-enqueue view transitions CSS on admin pages |
src/wp-settings.php |
Includes the new view-transitions.php file during WordPress initialization |
src/wp-admin/css/view-transitions.css |
CSS rules for view transitions on admin menu items |
tests/phpunit/tests/view-transitions/wpEnqueueViewTransitionsAdminCss.php |
Tests for view transitions functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 ); |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file_get_contents() call lacks error handling. If the file doesn't exist or can't be read (e.g., file permissions issue), this will generate a PHP warning and return false, which could cause issues when the CSS is added inline. Consider adding error handling with is_readable() check before reading the file, similar to the pattern used in script-loader.php line 3026.
| return file_get_contents( $path ); | |
| $contents = ''; | |
| if ( is_readable( $path ) ) { | |
| $contents = file_get_contents( $path ); | |
| } | |
| return is_string( $contents ) ? $contents : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file will always exist. So this isn't necessary.
tests/phpunit/tests/view-transitions/wpEnqueueViewTransitionsAdminCss.php
Show resolved
Hide resolved
|
Alas, E2E tests are still failing after 8ff0383: I'll revert the debug commit. |
|
Looks like 8bd1633 fixed the E2E test! The issue was the lack of checking whether the |
westonruter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixarntz This looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public function test_inline_css_included() { | ||
| $after_data = wp_styles()->get_data( 'wp-view-transitions-admin', 'after' ); | ||
| $this->assertIsArray( $after_data, 'Expected `after` data to be an array.' ); | ||
| $css = wp_get_view_transitions_admin_css(); | ||
| $this->assertStringContainsString( '@view-transition', $css ); | ||
| $this->assertContains( $css, $after_data ); |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test doesn't verify that the function handles missing CSS files gracefully. If the file doesn't exist (e.g., minified version), wp_get_view_transitions_admin_css() will throw a fatal error. Add a test case to verify error handling when the CSS file is not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will always exist. This isn't necessary.
|
As a companion to this core commit, a PR to disable the functionality in the plugin when it is present in core: WordPress/performance#2344 |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go for it 🚀
wp-view-transitions-adminwith inline CSS for basic view transitions in WP Admin, including smooth transitions between admin menu items.admin_enqueue_scriptsby default.view-transitions.phpfile rather than the genericscript-loader.phpfile.Trac ticket: https://core.trac.wordpress.org/ticket/64470
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.