Skip to content
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

Add actions for plugins to register frontend and editor assets #1717

Merged
merged 8 commits into from
Jul 5, 2017

Conversation

nylen
Copy link
Member

@nylen nylen commented Jul 5, 2017

Adds actions so that someone can hook into where Gutenberg styles and scripts are loaded and bring in styles and scripts of their own, for both the frontend and the editor.

This modifies functionality added in #1418, adding a Gutenberg-specific action intended for plugin use in enqueuing front-end assets. It also adds a corresponding action for plugins to enqueue editor assets.

See also #422, #514, and #1420.

@nylen nylen changed the title Add actions for frontend and plugin styles Add actions for plugins to register frontend and editor assets Jul 5, 2017
nylen added 2 commits July 5, 2017 12:23
...and fire this action in both admin context and on the frontend.
@nylen
Copy link
Member Author

nylen commented Jul 5, 2017

As of 00e7c3a there are two actions here:

  • enqueue_block_assets - fires in both editor and admin contexts to allow enqueuing assets common to both. If enqueuing scripts here, plugin authors should use an if ( ! is_admin() ) check to ensure that they are only loaded on the frontend. We may want a third enqueue_block_frontend_assets action instead, but this should be added later if necessary.
  • enqueue_block_editor_assets - fires in the editor context to allow enqueuing scripts and styles specific to the editor (register the block, build and style its editing controls, etc.)

@swissspidy
Copy link
Member

We may want a third enqueue_block_frontend_assets action instead, but this should be added later if necessary.

Then gutenberg_frontend_scripts_and_styles is not an ideal function name when it's called in the admin as well.

@nylen
Copy link
Member Author

nylen commented Jul 5, 2017

Then gutenberg_frontend_scripts_and_styles is not an ideal function name when it's called in the admin as well.

👍 Changed to common in 214e177 [and further improved in def57fc].

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

// action for a couple of reasons: (1) we want to load these assets
// (usually stylesheets) in *both* frontend and editor contexts, and (2)
// one day we may need to be smarter about whether assets are included
// based on whether blocks are actually present on the page.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a multi-line comment, e.g.

/*
 * ddd
 */

(with one asterisk on the first line)

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.

4 participants