<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[55819] trunk/src/wp-includes: Docs: Improve Style Engine DocBlocks per the documentation standards.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/55819">55819</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/55819","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-05-17 11:56:47 +0000 (Wed, 17 May 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Docs: Improve Style Engine DocBlocks per the documentation standards.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/54156">[54156]</a>, <a href="https://core.trac.wordpress.org/changeset/55719">[55719]</a>, <a href="https://core.trac.wordpress.org/changeset/55733">[55733]</a>.
See <a href="https://core.trac.wordpress.org/ticket/57840">#57840</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
<li><a href="#trunksrcwpincludesstyleengineclasswpstyleenginecssdeclarationsphp">trunk/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php</a></li>
<li><a href="#trunksrcwpincludesstyleengineclasswpstyleenginecssrulephp">trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php</a></li>
<li><a href="#trunksrcwpincludesstyleengineclasswpstyleenginecssrulesstorephp">trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php</a></li>
<li><a href="#trunksrcwpincludesstyleengineclasswpstyleengineprocessorphp">trunk/src/wp-includes/style-engine/class-wp-style-engine-processor.php</a></li>
<li><a href="#trunksrcwpincludesstyleengineclasswpstyleenginephp">trunk/src/wp-includes/style-engine/class-wp-style-engine.php</a></li>
<li><a href="#trunksrcwpincludesstyleenginephp">trunk/src/wp-includes/style-engine.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2023-05-17 09:42:02 UTC (rev 55818)
+++ trunk/src/wp-includes/script-loader.php 2023-05-17 11:56:47 UTC (rev 55819)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3016,10 +3016,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Optional. An array of options to pass to wp_style_engine_get_stylesheet_from_context(). Default empty array.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Optional. An array of options to pass to wp_style_engine_get_stylesheet_from_context().
+ * Default empty array.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
- * @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type bool $optimize Whether to optimize the CSS output, e.g., combine rules.
+ * Default false.
+ * @type bool $prettify Whether to add new lines and indents to output.
+ * Default to whether the `SCRIPT_DEBUG` constant is defined.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_enqueue_stored_styles( $options = array() ) {
</span></span></pre></div>
<a id="trunksrcwpincludesstyleengineclasswpstyleenginecssdeclarationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php 2023-05-17 09:42:02 UTC (rev 55818)
+++ trunk/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php 2023-05-17 11:56:47 UTC (rev 55819)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,11 +30,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Constructor for this object.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * If a `$declarations` array is passed, it will be used to populate
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * the initial $declarations prop of the object by calling add_declarations().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * the initial `$declarations` prop of the object by calling add_declarations().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string[] $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string[] $declarations Optional. An associative array of CSS definitions,
+ * e.g. `array( "$property" => "$value", "$property" => "$value" )`.
+ * Default empty array.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $declarations = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->add_declarations( $declarations );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,7 +104,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string[] $properties An array of properties.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string[] $properties Optional. An array of properties. Default empty array.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_Style_Engine_CSS_Declarations Returns the object to allow chaining methods.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function remove_declarations( $properties = array() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -130,7 +132,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $property The CSS property.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $value The value to be filtered.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $spacer The spacer between the colon and the value. Defaults to an empty string.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $spacer Optional. The spacer between the colon and the value.
+ * Default empty string.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string The filtered declaration or an empty string.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected static function filter_declaration( $property, $value, $spacer = '' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -146,8 +149,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $should_prettify Whether to add spacing, new lines and indents.
- * @param int $indent_count The number of tab indents to apply to the rule. Applies if `prettify` is `true`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param bool $should_prettify Optional. Whether to add spacing, new lines and indents.
+ * Default false.
+ * @param int $indent_count Optional. The number of tab indents to apply to the rule.
+ * Applies if `prettify` is `true`. Default 0.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string The CSS declarations.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_declarations_string( $should_prettify = false, $indent_count = 0 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -164,6 +169,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $declarations_output .= "{$indent}{$filtered_declaration};$suffix";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return rtrim( $declarations_output );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesstyleengineclasswpstyleenginecssrulephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php 2023-05-17 09:42:02 UTC (rev 55818)
+++ trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php 2023-05-17 11:56:47 UTC (rev 55819)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,13 +36,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> protected $declarations;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Constructor
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Constructor.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $selector The CSS selector.
- * @param string[]|WP_Style_Engine_CSS_Declarations $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $selector Optional. The CSS selector. Default empty string.
+ * @param string[]|WP_Style_Engine_CSS_Declarations $declarations Optional. An associative array of CSS definitions,
+ * e.g. `array( "$property" => "$value", "$property" => "$value" )`,
</ins><span class="cx" style="display: block; padding: 0 10px"> * or a WP_Style_Engine_CSS_Declarations object.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Default empty array.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $selector = '', $declarations = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->set_selector( $selector );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -67,8 +69,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array|WP_Style_Engine_CSS_Declarations $declarations An array of declarations (property => value pairs),
- * or a WP_Style_Engine_CSS_Declarations object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string[]|WP_Style_Engine_CSS_Declarations $declarations An array of declarations (property => value pairs),
+ * or a WP_Style_Engine_CSS_Declarations object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_Style_Engine_CSS_Rule Returns the object to allow chaining of methods.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function add_declarations( $declarations ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,8 +116,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $should_prettify Whether to add spacing, new lines and indents.
- * @param int $indent_count The number of tab indents to apply to the rule. Applies if `prettify` is `true`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param bool $should_prettify Optional. Whether to add spacing, new lines and indents.
+ * Default false.
+ * @param int $indent_count Optional. The number of tab indents to apply to the rule.
+ * Applies if `prettify` is `true`. Default 0.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_css( $should_prettify = false, $indent_count = 0 ) {
</span></span></pre></div>
<a id="trunksrcwpincludesstyleengineclasswpstyleenginecssrulesstorephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php 2023-05-17 09:42:02 UTC (rev 55818)
+++ trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php 2023-05-17 11:56:47 UTC (rev 55819)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,7 +123,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $selector The CSS selector.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return WP_Style_Engine_CSS_Rule|void Returns a WP_Style_Engine_CSS_Rule object, or void if the selector is empty.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return WP_Style_Engine_CSS_Rule|void Returns a WP_Style_Engine_CSS_Rule object,
+ * or void if the selector is empty.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function add_rule( $selector ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $selector = trim( $selector );
</span></span></pre></div>
<a id="trunksrcwpincludesstyleengineclasswpstyleengineprocessorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/style-engine/class-wp-style-engine-processor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/style-engine/class-wp-style-engine-processor.php 2023-05-17 09:42:02 UTC (rev 55818)
+++ trunk/src/wp-includes/style-engine/class-wp-style-engine-processor.php 2023-05-17 11:56:47 UTC (rev 55819)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,7 +59,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Style_Engine_CSS_Rule|WP_Style_Engine_CSS_Rule[] $css_rules A single, or an array of, WP_Style_Engine_CSS_Rule objects from a store or otherwise.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Style_Engine_CSS_Rule|WP_Style_Engine_CSS_Rule[] $css_rules A single, or an array of,
+ * WP_Style_Engine_CSS_Rule objects
+ * from a store or otherwise.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_Style_Engine_Processor Returns the object to allow chaining methods.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function add_rules( $css_rules ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,8 +89,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. An array of options. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
- * @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type bool $optimize Whether to optimize the CSS output, e.g. combine rules.
+ * Default false.
+ * @type bool $prettify Whether to add new lines and indents to output.
+ * Defaults to whether the `SCRIPT_DEBUG` constant is defined.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string The computed CSS.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="trunksrcwpincludesstyleengineclasswpstyleenginephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/style-engine/class-wp-style-engine.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/style-engine/class-wp-style-engine.php 2023-05-17 09:42:02 UTC (rev 55818)
+++ trunk/src/wp-includes/style-engine/class-wp-style-engine.php 2023-05-17 11:56:47 UTC (rev 55819)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,12 +10,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The main class integrating all other WP_Style_Engine_* classes.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The Style Engine aims to provide a consistent API for rendering styling for blocks across both client-side and server-side applications.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The Style Engine aims to provide a consistent API for rendering styling for blocks
+ * across both client-side and server-side applications.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * This class is final and should not be extended.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * This class is for internal Core usage and is not supposed to be used by extenders (plugins and/or themes).
- * This is a low-level API that may need to do breaking changes. Please, use wp_style_engine_get_styles() instead.
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * This class is for internal Core usage and is not supposed to be used by extenders
+ * (plugins and/or themes). This is a low-level API that may need to do breaking changes.
+ * Please, use wp_style_engine_get_styles() instead.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access private
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,16 +27,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Style definitions that contain the instructions to
</span><span class="cx" style="display: block; padding: 0 10px"> * parse/output valid Gutenberg styles from a block's attributes.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * For every style definition, the follow properties are valid:
- * - classnames => (array) an array of classnames to be returned for block styles. The key is a classname or pattern.
- * A value of `true` means the classname should be applied always. Otherwise, a valid CSS property (string)
- * to match the incoming value, e.g., "color" to match var:preset|color|somePresetSlug.
- * - css_vars => (array) an array of key value pairs used to generate CSS var values. The key is a CSS var pattern, whose `$slug` fragment will be replaced with a preset slug.
- * The value should be a valid CSS property (string) to match the incoming value, e.g., "color" to match var:preset|color|somePresetSlug.
- * - property_keys => (array) array of keys whose values represent a valid CSS property, e.g., "margin" or "border".
- * - path => (array) a path that accesses the corresponding style value in the block style object.
- * - value_func => (string) the name of a function to generate a CSS definition array for a particular style object. The output of this function should be `array( "$property" => "$value", ... )`.
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * For every style definition, the following properties are valid:
+ *
+ * - classnames => (array) An array of classnames to be returned for block styles.
+ * The key is a classname or pattern.
+ * A value of `true` means the classname should be applied always.
+ * Otherwise, a valid CSS property (string) to match the incoming value,
+ * e.g. "color" to match var:preset|color|somePresetSlug.
+ * - css_vars => (array) An array of key value pairs used to generate CSS var values.
+ * The key is a CSS var pattern, whose `$slug` fragment will be replaced with a preset slug.
+ * The value should be a valid CSS property (string) to match the incoming value,
+ * e.g. "color" to match var:preset|color|somePresetSlug.
+ * - property_keys => (array) An array of keys whose values represent a valid CSS property,
+ * e.g. "margin" or "border".
+ * - path => (array) A path that accesses the corresponding style value in the block style object.
+ * - value_func => (string) The name of a function to generate a CSS definition array
+ * for a particular style object. The output of this function should be
+ * `array( "$property" => "$value", ... )`.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @var array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -227,16 +239,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Util: Extracts the slug in kebab case from a preset string, e.g., `heavenly-blue` from `var:preset|color|heavenlyBlue`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Util: Extracts the slug in kebab case from a preset string,
+ * e.g. `heavenly-blue` from `var:preset|color|heavenlyBlue`.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $style_value A single CSS preset value.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $property_key The CSS property that is the second element of the preset string. Used for matching.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $property_key The CSS property that is the second element of the preset string.
+ * Used for matching.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string The slug, or empty string if not found.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected static function get_slug_from_preset_value( $style_value, $property_key ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_string( $style_value ) && is_string( $property_key ) && str_contains( $style_value, "var:preset|{$property_key}|" ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_string( $style_value ) && is_string( $property_key )
+ && str_contains( $style_value, "var:preset|{$property_key}|" )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $index_to_splice = strrpos( $style_value, '|' ) + 1;
</span><span class="cx" style="display: block; padding: 0 10px"> return _wp_to_kebab_case( substr( $style_value, $index_to_splice ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -244,12 +260,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Util: Generates a CSS var string, e.g., `var(--wp--preset--color--background)` from a preset string such as `var:preset|space|50`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Util: Generates a CSS var string, e.g. `var(--wp--preset--color--background)`
+ * from a preset string such as `var:preset|space|50`.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $style_value A single CSS preset value.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string[] $css_vars An associate array of CSS var patterns used to generate the var string.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string[] $css_vars An associate array of CSS var patterns
+ * used to generate the var string.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string The CSS var, or an empty string if no match for slug found.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected static function get_css_var_value( $style_value, $css_vars ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,8 +302,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $store_name A valid store key.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $css_selector When a selector is passed, the function will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
- * @param string[] $css_declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $css_selector When a selector is passed, the function will return
+ * a full CSS rule `$selector { ...rules }`
+ * otherwise a concatenated string of properties and values.
+ * @param string[] $css_declarations An associative array of CSS definitions,
+ * e.g. `array( "$property" => "$value", "$property" => "$value" )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function store_css_rule( $store_name, $css_selector, $css_declarations ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $store_name ) || empty( $css_selector ) || empty( $css_declarations ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -308,6 +329,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Returns classnames and CSS based on the values in a styles object.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Return values are parsed based on the instructions in BLOCK_STYLE_DEFINITIONS_METADATA.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -316,13 +338,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. An array of options. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to `var( --wp--preset--* )` values. Default false.
- * @type string $selector Optional. When a selector is passed, the value of `$css` in the return value will comprise a full CSS rule `$selector { ...$css_declarations }`,
- * otherwise, the value will be a concatenated string of CSS declarations.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns,
+ * e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`,
+ * to `var( --wp--preset--* )` values. Default false.
+ * @type string $selector Optional. When a selector is passed,
+ * the value of `$css` in the return value will comprise
+ * a full CSS rule `$selector { ...$css_declarations }`,
+ * otherwise, the value will be a concatenated string
+ * of CSS declarations.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array {
</span><span class="cx" style="display: block; padding: 0 10px"> * @type string[] $classnames Array of class names.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string[] $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string[] $declarations An associative array of CSS definitions,
+ * e.g. `array( "$property" => "$value", "$property" => "$value" )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function parse_block_styles( $block_styles, $options ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -355,11 +383,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Returns classnames, and generates classname(s) from a CSS preset property pattern, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns classnames, and generates classname(s) from a CSS preset property pattern,
+ * e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $style_value A single raw style value or CSS preset property from the `$block_styles` array.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $style_value A single raw style value or CSS preset property
+ * from the `$block_styles` array.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $style_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string[] An array of CSS classnames, or empty array if there are none.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -402,11 +432,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. An array of options. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g.,
- * `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to `var( --wp--preset--* )` values.
- * Default false.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns,
+ * e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`,
+ * to `var( --wp--preset--* )` values. Default false.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string[] An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string[] An associative array of CSS definitions, e.g. `array( "$property" => "$value", "$property" => "$value" )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected static function get_css_declarations( $style_value, $style_definition, $options = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $style_definition['value_func'] ) && is_callable( $style_definition['value_func'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -480,13 +510,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $style_value A single raw style value from `$block_styles` array.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $individual_property_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA representing an individual property of a CSS property, e.g., 'top' in 'border-top'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $individual_property_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA
+ * representing an individual property of a CSS property,
+ * e.g. 'top' in 'border-top'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. An array of options. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to `var( --wp--preset--* )` values. Default false.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns,
+ * e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`,
+ * to `var( --wp--preset--* )` values. Default false.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string[] An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string[] An associative array of CSS definitions, e.g. `array( "$property" => "$value", "$property" => "$value" )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected static function get_individual_property_css_declarations( $style_value, $individual_property_definition, $options = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_array( $style_value ) || empty( $style_value ) || empty( $individual_property_definition['path'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -494,9 +528,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The first item in $individual_property_definition['path'] array tells us the style property, e.g., "border".
- * We use this to get a corresponding CSS style definition such as "color" or "width" from the same group.
- * The second item in $individual_property_definition['path'] array refers to the individual property marker, e.g., "top".
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The first item in $individual_property_definition['path'] array
+ * tells us the style property, e.g. "border". We use this to get a corresponding
+ * CSS style definition such as "color" or "width" from the same group.
+ *
+ * The second item in $individual_property_definition['path'] array
+ * refers to the individual property marker, e.g. "top".
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $definition_group_key = $individual_property_definition['path'][0];
</span><span class="cx" style="display: block; padding: 0 10px"> $individual_property_key = $individual_property_definition['path'][1];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -514,10 +551,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $style_definition && isset( $style_definition['property_keys']['individual'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Set a CSS var if there is a valid preset value.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_string( $value ) && str_contains( $value, 'var:' ) && ! $should_skip_css_vars && ! empty( $individual_property_definition['css_vars'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_string( $value ) && str_contains( $value, 'var:' )
+ && ! $should_skip_css_vars && ! empty( $individual_property_definition['css_vars'] )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $value = static::get_css_var_value( $value, $individual_property_definition['css_vars'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $individual_css_property = sprintf( $style_definition['property_keys']['individual'], $individual_property_key );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $individual_css_property = sprintf( $style_definition['property_keys']['individual'], $individual_property_key );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $css_declarations[ $individual_css_property ] = $value;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -529,8 +570,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string[] $css_declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
- * @param string $css_selector When a selector is passed, the function will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string[] $css_declarations An associative array of CSS definitions,
+ * e.g. `array( "$property" => "$value", "$property" => "$value" )`.
+ * @param string $css_selector When a selector is passed, the function will return
+ * a full CSS rule `$selector { ...rules }`,
+ * otherwise a concatenated string of properties and values.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string A compiled CSS string.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function compile_css( $css_declarations, $css_selector ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -553,14 +597,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Style_Engine_CSS_Rule[] $css_rules An array of WP_Style_Engine_CSS_Rule objects from a store or otherwise.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Style_Engine_CSS_Rule[] $css_rules An array of WP_Style_Engine_CSS_Rule objects
+ * from a store or otherwise.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. An array of options. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string|null $context An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is 'block-supports'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string|null $context An identifier describing the origin of the style object,
+ * e.g. 'block-supports' or 'global-styles'. Default 'block-supports'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * When set, the style engine will attempt to store the CSS rules.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
- * @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type bool $optimize Whether to optimize the CSS output, e.g. combine rules.
+ * Default false.
+ * @type bool $prettify Whether to add new lines and indents to output.
+ * Defaults to whether the `SCRIPT_DEBUG` constant is defined.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string A compiled stylesheet from stored CSS rules.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="trunksrcwpincludesstyleenginephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/style-engine.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/style-engine.php 2023-05-17 09:42:02 UTC (rev 55818)
+++ trunk/src/wp-includes/style-engine.php 2023-05-17 11:56:47 UTC (rev 55819)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,35 +11,52 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Global public interface method to generate styles from a single style object, e.g.,
- * the value of a block's attributes.style object or the top level styles in theme.json.
- * See: https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/#styles and
- * https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Global public interface method to generate styles from a single style object,
+ * e.g. the value of a block's attributes.style object or the top level styles in theme.json.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Example usage:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * $styles = wp_style_engine_get_styles( array( 'color' => array( 'text' => '#cccccc' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * $styles = wp_style_engine_get_styles(
+ * array(
+ * 'color' => array( 'text' => '#cccccc' ),
+ * )
+ * );
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Returns:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * array( 'css' => 'color: #cccccc', 'declarations' => array( 'color' => '#cccccc' ), 'classnames' => 'has-color' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * array(
+ * 'css' => 'color: #cccccc',
+ * 'declarations' => array( 'color' => '#cccccc' ),
+ * 'classnames' => 'has-color',
+ * )
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @access public
</del><span class="cx" style="display: block; padding: 0 10px"> * @since 6.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/#styles
+ * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $block_styles The style object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. An array of options. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string|null $context An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is `null`.
- * When set, the style engine will attempt to store the CSS rules, where a selector is also passed.
- * @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to `var( --wp--preset--* )` values. Default `false`.
- * @type string $selector Optional. When a selector is passed, the value of `$css` in the return value will comprise a full CSS rule `$selector { ...$css_declarations }`,
- * otherwise, the value will be a concatenated string of CSS declarations.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string|null $context An identifier describing the origin of the style object,
+ * e.g. 'block-supports' or 'global-styles'. Default null.
+ * When set, the style engine will attempt to store the CSS rules,
+ * where a selector is also passed.
+ * @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns,
+ * e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`,
+ * to `var( --wp--preset--* )` values. Default false.
+ * @type string $selector Optional. When a selector is passed,
+ * the value of `$css` in the return value will comprise
+ * a full CSS rule `$selector { ...$css_declarations }`,
+ * otherwise, the value will be a concatenated string
+ * of CSS declarations.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string $css A CSS ruleset or declarations block formatted to be placed in an HTML `style` attribute or tag.
- * @type string[] $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string $css A CSS ruleset or declarations block
+ * formatted to be placed in an HTML `style` attribute or tag.
+ * @type string[] $declarations An associative array of CSS definitions,
+ * e.g. `array( "$property" => "$value", "$property" => "$value" )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @type string $classnames Classnames separated by a space.
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -79,9 +96,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Example usage:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * $css_rules = array( array( 'selector' => '.elephant-are-cool', 'declarations' => array( 'color' => 'gray', 'width' => '3em' ) ) );
- * $css = wp_style_engine_get_stylesheet_from_css_rules( $css_rules );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * $css_rules = array(
+ * array(
+ * 'selector' => '.elephant-are-cool',
+ * 'declarations' => array(
+ * 'color' => 'gray',
+ * 'width' => '3em',
+ * ),
+ * ),
+ * );
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * $css = wp_style_engine_get_stylesheet_from_css_rules( $css_rules );
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Returns:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * .elephant-are-cool{color:gray;width:3em}
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -93,16 +119,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @type array ...$0 {
</span><span class="cx" style="display: block; padding: 0 10px"> * @type string $selector A CSS selector.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string[] $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string[] $declarations An associative array of CSS definitions,
+ * e.g. `array( "$property" => "$value", "$property" => "$value" )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. An array of options. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string|null $context An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is 'block-supports'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string|null $context An identifier describing the origin of the style object,
+ * e.g. 'block-supports' or 'global-styles'. Default 'block-supports'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * When set, the style engine will attempt to store the CSS rules.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
- * @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type bool $optimize Whether to optimize the CSS output, e.g. combine rules.
+ * Default false.
+ * @type bool $prettify Whether to add new lines and indents to output.
+ * Defaults to whether the `SCRIPT_DEBUG` constant is defined.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string A string of compiled CSS declarations, or empty string.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,8 +177,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $options {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. An array of options. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
- * @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type bool $optimize Whether to optimize the CSS output, e.g. combine rules.
+ * Default false.
+ * @type bool $prettify Whether to add new lines and indents to output.
+ * Defaults to whether the `SCRIPT_DEBUG` constant is defined.
</ins><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string A compiled CSS string.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre>
</div>
</div>
</body>
</html>