From c5e2734b672d173e5da11aef2f579616e3019614 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 6 Sep 2022 08:35:35 +1000 Subject: [PATCH] Rename user-facing method `wp_style_engine_get_stylesheet_from_store` to `wp_style_engine_get_stylesheet_from_context` since it matches the incoming option parameter 'context' (#43841) --- lib/compat/wordpress-6.1/script-loader.php | 4 ++-- packages/style-engine/README.md | 10 ++++++---- packages/style-engine/class-wp-style-engine.php | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/compat/wordpress-6.1/script-loader.php b/lib/compat/wordpress-6.1/script-loader.php index 330e6b2614e1f2..63c84f66075deb 100644 --- a/lib/compat/wordpress-6.1/script-loader.php +++ b/lib/compat/wordpress-6.1/script-loader.php @@ -65,7 +65,7 @@ function gutenberg_enqueue_stored_styles() { } // Chain core store ids to signify what the styles contain. $style_tag_id .= '-' . $style_key; - $compiled_core_stylesheet .= gutenberg_style_engine_get_stylesheet_from_store( $style_key ); + $compiled_core_stylesheet .= gutenberg_style_engine_get_stylesheet_from_context( $style_key ); } // Combine Core styles. @@ -81,7 +81,7 @@ function gutenberg_enqueue_stored_styles() { if ( in_array( $store_name, $core_styles_keys, true ) ) { continue; } - $styles = gutenberg_style_engine_get_stylesheet_from_store( $store_name ); + $styles = gutenberg_style_engine_get_stylesheet_from_context( $store_name ); if ( ! empty( $styles ) ) { $key = "wp-style-engine-$store_name"; wp_register_style( $key, false, array(), true, true ); diff --git a/packages/style-engine/README.md b/packages/style-engine/README.md index b264ae55ef2402..1bd3e35e189f22 100644 --- a/packages/style-engine/README.md +++ b/packages/style-engine/README.md @@ -135,9 +135,9 @@ $stylesheet = wp_style_engine_get_stylesheet_from_css_rules( print_r( $stylesheet ); // .wp-pumpkin, .wp-kumquat {color:orange}.wp-tomato{color:red;padding:100px} ``` -### wp_style_engine_get_stylesheet_from_store() +### wp_style_engine_get_stylesheet_from_context() -Returns compiled CSS from a store, if found. +Returns compiled CSS from a stored context, if found. _Parameters_ @@ -167,8 +167,8 @@ $stylesheet = wp_style_engine_get_stylesheet_from_css_rules( ) ); -// Later, fetch compiled rules from store. -$stylesheet = gutenberg_style_engine_get_stylesheet_from_store( 'fruit-styles' ); +// Later, fetch compiled rules from context store. +$stylesheet = gutenberg_style_engine_get_stylesheet_from_context( 'fruit-styles' ); print_r( $stylesheet ); // .wp-apple{color:green;} if ( ! empty( $stylesheet ) ) { wp_register_style( 'my-stylesheet', false, array(), true, true ); @@ -229,6 +229,8 @@ A guide to the terms and variable names referenced by the Style Engine package.
Block style (Gutenberg internal)
An object comprising a block's style attribute that contains a block's style values. E.g., { spacing: { margin: '10px' }, color: { ... }, ... }
+
Context
+
An identifier for a group of styles that share a common origin or purpose, e.g., 'block-supports' or 'global-styles'. The context is also used as a key to fetch CSS rules from the store.
CSS declaration or (CSS property declaration)
A CSS property paired with a CSS value. E.g., color: pink
CSS declarations block
diff --git a/packages/style-engine/class-wp-style-engine.php b/packages/style-engine/class-wp-style-engine.php index c6ada9aec9c577..4c9f313606e8f1 100644 --- a/packages/style-engine/class-wp-style-engine.php +++ b/packages/style-engine/class-wp-style-engine.php @@ -636,7 +636,7 @@ function wp_style_engine_get_stylesheet_from_css_rules( $css_rules, $options = a * * @return string A compiled CSS string. */ -function wp_style_engine_get_stylesheet_from_store( $store_name ) { +function wp_style_engine_get_stylesheet_from_context( $store_name ) { if ( ! class_exists( 'WP_Style_Engine' ) || empty( $store_name ) ) { return ''; }