-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Milestone
Description
In 0.7 we disabled the admin bar on the frontend when in AMP because of the additional CSS and JS it adds to the page that would cause it to be invalid:
However, now with tree-shaking this is less of a concern. In fact, I think we should restore showing the admin bar in AMP responses, but provide an additional checkbox on the general settings screen for whether to show the admin bar in AMP. This could be under Validation Handling since the admin bar could be a source for validation errors.
The following patch gets the admin bar working in AMP:
--- a/includes/class-amp-theme-support.php
+++ b/includes/class-amp-theme-support.php
@@ -350,11 +350,22 @@ class AMP_Theme_Support {
add_action( 'wp_footer', 'amp_print_analytics' );
- /*
- * Disable admin bar because admin-bar.css (28K) and Dashicons (48K) alone
- * combine to surpass the 50K limit imposed for the amp-custom style.
- */
- add_filter( 'show_admin_bar', '__return_false', 100 );
+ add_action( 'admin_bar_init', function() {
+ wp_dequeue_script( 'admin-bar' );
+ wp_add_inline_style( 'admin-bar', '#wpadminbar.nojs { display:block; } #wpadminbar.nojs li:focus-within > .ab-sub-wrapper { display:block; }' );
+ add_filter( 'body_class', function( $body_classes ) {
+ return array_merge(
+ array_diff(
+ $body_classes,
+ array( 'no-customize-support' )
+ ),
+ array( 'customize-support' )
+ );
+ } );
+ add_action( 'admin_bar_menu', function() {
+ remove_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
+ }, 41 );
+ } );
/*
* Start output buffering at very low priority for sake of plugins and themes that use template_redirectReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels