Skip to content

Conversation

@westonruter
Copy link
Owner

I discovered when testing ampproject/amp-wp#4299, which adds block styles to AMP pages in Reader mode, that this plugin's stylesheet was not added. The reason for this is the plugin was using wp_enqueue_scripts to register the stylesheet, but this is not currently invoked in AMP's Reader mode (only enqueue_block_assets).

Most plugins would be using enqueue_block_assets to both register and enqueue stylesheets so they wouldn't be impacted by here. But in this plugin we defer printing the stylesheet until the block is printed.

Before:

image

After:

image

@allejo
Copy link
Contributor

allejo commented Feb 17, 2020

I take it that wp_default_styles is used instead of enqueue_block_assets because the editor isn't using the stylesheets?

@westonruter
Copy link
Owner Author

I suppose that's one reason as well. The main reason is pure registration works best in the wp_default_styles action, which is independent of the frontend or backend. This then also ensures the stylesheet is registered in AMP Reader mode, which doesn't use the wp_enqueue_scripts action.

@westonruter westonruter merged commit dc289cb into master Feb 17, 2020
@westonruter westonruter deleted the fix/style-registration branch February 17, 2020 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants