-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Style engine: enqueue block support styles (#42452)
* Enqueuing block support styles version 1. * Linter, this one's for you. * Post trunk merge cleanup and update tests. * Removed spacing around curly braces in CSS rules. Updated tests. We could maybe add a prettify option down the road. Juggling methods around to cater for adding styles to (any) store. Also making return values consistent. * Splitting `wp_style_engine_enqueue_block_supports_styles` and `wp_style_engine_get_block_supports_styles` so we can enqueue styles that don't need parsing, e.g., layout * Integrate the processor class * Migrate layout styles to style engine store. * Update packages/style-engine/class-wp-style-engine.php Co-authored-by: Ari Stathopoulos <aristath@gmail.com> * Tweaks for #42452 (#42691) * abstract stores * "else" not needed * compile_classnames method not needed * we have a method to get the store here * Make the wp_style_engine_add_to_store function always return a store * wp_style_engine_get_stylesheet - always return string * Merged with base branch. Added test for new method. Co-authored-by: ramonjd <ramonjd@gmail.com> Co-authored-by: Ramon <ramonjd@users.noreply.github.com> * Adding check for the context argument. Adding tests. * Updating the processor so that it's ignorant of stores. Why? So that it can be used to process any CSS and not just stored CSS. Updating layout for backwards compatibility in gutenberg_get_layout_style (returning the styles that are collected in the function body only) Created a new mode for incoming $css_rules to be a collection of selector + css_declaration keys. Removed wp_style_engine_get_stylesheet (from store) since we don't use it yet Added a new function wp_style_engine_get_stylesheet_from_css_rules() that will process and compile a collection of CSS rules, and not store them. * dump var_dump() * Improve the processor * remove trailing commas - compatibility with PHP < 7.2 * rename css_declarations to declarations * remove unused variable Removing unused function wp_style_engine_get_stylesheet_from_store Updating tests to check for merging and deduping * Switch parse_block_styles from public to protected static * Now that all methods are static, there's no need to call `get_instance()` * Revert get_instance() in wp_style_engine_add_to_store because we want to ensure the hook is enqueued here. * Adding a test for the 'enqueue' flag. * Update lib/block-supports/layout.php Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> * Adding a test for the 'enqueue' flag. * Add named stores to the processor * avoid setting var for something that only gets used once * Only use "else" if absolutely necessary * Add a set_name method * combine & simplify conditions * use empty() instead of isset() checks here * shorten it Co-authored-by: Ari Stathopoulos <aristath@gmail.com> Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
- Loading branch information
1 parent
56a185a
commit 3f58ed5
Showing
9 changed files
with
786 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.