-
Notifications
You must be signed in to change notification settings - Fork 382
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
AMP error if admin bar styles are removed #7766
Comments
I don't think you should every fully deregister the style. Shouldn't you rather dequeue it? Use |
Thanks for the suggestion, I'll look into that. But adding an isset() is a good practice anyway, one should always check if a property exists before using it, don't you think so? |
Yes, that would be good defensive coding. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Description
If visiting a wordpress page where I removed admin bar styles, AMP throws
Warning: Undefined array key "admin-bar" in XXX/wp-content/plugins/amp/includes/class-amp-theme-support.php on line 1382
I removed the styles (and the whole admin bar) with
If I take out
wp_deregister_style( 'admin-bar' );
it works again.Expected Behaviour
Should not throw warning
Screenshots
No response
PHP Version
8.2
Plugin Version
2.5.3
AMP plugin template mode
Standard
WordPress Version
No response
Site Health
No response
Gutenberg Version
No response
OS(s) Affected
No response
Browser(s) Affected
No response
Device(s) Affected
No response
Acceptance Criteria
No response
Implementation Brief
on line 1382 includes/class-amp-theme-support.php you should replace
is_array( wp_styles()->registered['admin-bar']->deps ) && in_array( $handle, wp_styles()->registered['admin-bar']->deps, true ) ? [..]
by
isset( wp_styles()->registered['admin-bar']->deps ) && is_array( wp_styles()->registered['admin-bar']->deps ) && in_array( $handle, wp_styles()->registered['admin-bar']->deps, true ) ? [..]
(add an isset())
QA Testing Instructions
No response
Demo
No response
Changelog Entry
No response
The text was updated successfully, but these errors were encountered: