Command Palette: Fix macOs label for sites unable to determine UA via PHP#77638
Command Palette: Fix macOs label for sites unable to determine UA via PHP#77638peterwilsoncc wants to merge 10 commits intotrunkfrom
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
13af4cc to
4343e24
Compare
|
Flaky tests detected in 33e7592. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24975080814
|
| function gutenberg_add_admin_bar_script() { | ||
| if ( ! is_admin_bar_showing() ) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
do we only care about $_SERVER['HTTP_USER_AGENT']? if so could we skip the fallback if the string exists?
// If PHP already has a reliable UA, trust it and skip the JS fallback.
if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return;
}I was wondering why something like
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36';
wasn't forcing the Ctrl+K. Is it because the JS always loads here?
There was a problem hiding this comment.
@ramonjd I've switched to navigator.platform as it's more reliable than UA sniffing. Due to the additional reliability I think having the script in place all the time will be helpful. I've also made a few other changes based on the reviews in WordPress/wordpress-develop#11636
…DNs. Many CDNs will block the user agent from being sent to the application server in order to increase cache hits on the edge. This adds a JavaScript logic check for the UA string to the admin bar to ensure the text is correctly displayed if the UA is available via JavaScript.
Co-Authored-By: westonruter <westonruter@git.wordpress.org>
e724755 to
33e7592
Compare
What?
Adds a JavaScript check of the User-Agent for displaying the text in the admin bar.
Closes #77636.
See Core-65121
Why?
On sites served over a CDN is it relatively common for the CDN to strip the
User-AgentHTTP header, on macOS systems this causes the incorrect label to be displayed.How?
Adds a JavaScript fallback to test the UA and determine the best label to use.
Testing Instructions
wp-config.phpfile, add the code$_SERVER['HTTP_USER_AGENT'] = '';to emulate a site behind a CDN stripping the header/wp-adminTesting Instructions for Keyboard
N/A
Screenshots or screencast
Use of AI Tools
N/A