-
Notifications
You must be signed in to change notification settings - Fork 384
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
Ignore admin bar for AMP validation purposes #1921
Comments
Sounds like a plan! |
For perhaps a better alternative to this, see #2322. |
Also, this could be made obsolete especially for Native mode sites by #2326, as excessive CSS could be rejected from sanitization by default. |
I agree #2322 would be a better alternative - if there is excessive CSS, the admin bar CSS should be removed first. We would need to ensure though that we still keep the user informed about that. Also, what would happen to the admin bar markup (that would then appear broken)? |
The suggestion here is to remove the admin bar as a whole in those cases, not just the admin bar CSS. |
I agree. As a user I'd like to have the Admin bar in cases where there is no excess CSS since it provides easy access points that should be there if possible, and can automatically be disabled if needed. This way the prioritization of stylesheets would apply only for all the other site style sheets. |
Something else that comes to mind here is that when performing a validation request, we should prevent the admin bar from being shown at all. In other words: --- a/includes/validation/class-amp-validation-manager.php
+++ b/includes/validation/class-amp-validation-manager.php
@@ -212,6 +212,8 @@ class AMP_Validation_Manager {
}
if ( self::$should_locate_sources ) {
+ add_filter( 'show_admin_bar', '__return_false', PHP_INT_MAX );
+
self::add_validation_error_sourcing();
}
} This would actually align the behavior of user-initiated validation requests with validation requests performed via With that in place, then what remains is to ignore validation errors caused by the admin bar when rendering the page outside the context of a validation error, and thus allowing the admin bar to be included even though otherwise it causes the page to be strictly invalid AMP. |
Hello all What is the current status of this? I've came to the point where my theme seems to have a lot of css and the #wpadminbar is being striped out. Is there a way to keep showing it only for editors? I've tried what @westonruter suggest in its first post here ( I'm using the 1.2.0 version |
@HelaGone The status is what you have experienced. In #2346 the admin bar automatically gets removed when its CSS takes it over the 50KB limit. We still have to decide exactly what to do in regards to allowing the admin bar take the user above the 50KB limit while logged in. This will likely relate closely to #2326. |
We now have something in AMP tailored for this use case! There is a new I've inquired about having the AMP Validator extension account for this special case so that it doesn't show an error icon: ampproject/amphtml#24176. So this means that when the user is logged-in and the admin bar is showing, we can take the total amount of tree-shaken CSS for the admin bar and increase the 50KB limit by that amount, while also adding |
The support for |
Instead of passing the admin bar through through the sanitizers, now we can exempt it from sanitization (and adding |
Something else we also we can do here then is to eliminate bundling a forked |
A good idea from @schlessera is that there should be a way for
|
Testing instructions:
For more before/after screenshots for what to look for, see the description on #3187. |
The inclusion of the admin bar was included in AMP via #1205. However, the amount of admin bar CSS is so large (20KB) that it takes up about 40% of the total allowed CSS in AMP (50KB). For this reason it very frequently causes
excessive_css
validation errors when an authenticated user is browsing the frontend. As opposed to providing this option or trying to automatically disable the admin bar when there is too much CSS (#1800), we could instead just exclude admin bar CSS (including any styles that depend onadmin-bar
) from being considered in the 50KB budget.This can mean that an authenticated user will often be served an invalid AMP page, but this is of little importance since the unauthenticated visitor (including crawlers) will only get the valid AMP pages for indexing. The admin bar has an indicator of AMP validity already, so users who have the AMP validator browser extension would just need to trust the admin bar status rather than the browser toolbar, or else open the URL in an incognito window to double-check.AMP now supports an explicit “dev mode” (ampproject/amphtml#20974) for when invalid markup is intentionally being included in the page. The AMP validator browser extension will explicitly be aware of this mode (ampproject/amphtml#24176) so there will not be concerns about it alerting the user of errors. Initial support for dev mode in the AMP plugin landed with #3084.👉 For full list of changes, please refer to description in PR: #3187.
Done/Obsolete
show_admin_bar
filter along with a check for! is_amp_endpoint()
. Most users will benefit from the admin bar. Decisions not options. (Done in Introduce stylesheet prioritization when determining which to concatenate #2346 & Remove admin-bar class name from body when admin bar element removed due to excessive CSS #2405.)Add note in admin bar submenu for AMP that page is not valid due to admin bar, but otherwise it is OK.Add link to AMP admin bar menu to navigate to the current URL without the admin bar. A query param likehide_admin_bar
can be introduced. This URL can also automatically add#development=1
.Consider removing theamp
attribute from thehtml
element when the admin bar is showing to prevent the AMP Validator extension from screaming at the user.The text was updated successfully, but these errors were encountered: