<!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>[58797] trunk: Block themes: Enable block-level background image styles</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/58797">58797</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/58797","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>noisysocks</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-07-24 00:24:31 +0000 (Wed, 24 Jul 2024)</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'>Block themes: Enable block-level background image styles

Allows defining background images for blocks in theme.json.

Syncs PHP changes from https://github.com/WordPress/gutenberg/pull/60100.

Props ramonopoly, aaronrobertshaw.
Fixes <a href="https://core.trac.wordpress.org/ticket/61588">#61588</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesblocksupportsbackgroundphp">trunk/src/wp-includes/block-supports/background.php</a></li>
<li><a href="#trunksrcwpincludesclasswpthemejsonresolverphp">trunk/src/wp-includes/class-wp-theme-json-resolver.php</a></li>
<li><a href="#trunksrcwpincludesclasswpthemejsonphp">trunk/src/wp-includes/class-wp-theme-json.php</a></li>
<li><a href="#trunksrcwpincludesglobalstylesandsettingsphp">trunk/src/wp-includes/global-styles-and-settings.php</a></li>
<li><a href="#trunktestsphpunitteststhemewpThemeJsonphp">trunk/tests/phpunit/tests/theme/wpThemeJson.php</a></li>
<li><a href="#trunktestsphpunitteststhemewpThemeJsonResolverphp">trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesblocksupportsbackgroundphp"></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/block-supports/background.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/background.php       2024-07-23 21:50:23 UTC (rev 58796)
+++ trunk/src/wp-includes/block-supports/background.php 2024-07-24 00:24:31 UTC (rev 58797)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,13 +62,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return $block_content;
</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">-        $background_styles                    = array();
-       $background_styles['backgroundImage'] = isset( $block_attributes['style']['background']['backgroundImage'] ) ? $block_attributes['style']['background']['backgroundImage'] : array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $background_styles                       = array();
+       $background_styles['backgroundImage']    = $block_attributes['style']['background']['backgroundImage'] ?? null;
+       $background_styles['backgroundSize']     = $block_attributes['style']['background']['backgroundSize'] ?? null;
+       $background_styles['backgroundPosition'] = $block_attributes['style']['background']['backgroundPosition'] ?? null;
+       $background_styles['backgroundRepeat']   = $block_attributes['style']['background']['backgroundRepeat'] ?? null;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! empty( $background_styles['backgroundImage'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $background_styles['backgroundSize']     = isset( $block_attributes['style']['background']['backgroundSize'] ) ? $block_attributes['style']['background']['backgroundSize'] : 'cover';
-               $background_styles['backgroundPosition'] = isset( $block_attributes['style']['background']['backgroundPosition'] ) ? $block_attributes['style']['background']['backgroundPosition'] : null;
-               $background_styles['backgroundRepeat']   = isset( $block_attributes['style']['background']['backgroundRepeat'] ) ? $block_attributes['style']['background']['backgroundRepeat'] : null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $background_styles['backgroundSize'] = $background_styles['backgroundSize'] ?? 'cover';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // If the background size is set to `contain` and no position is set, set the position to `center`.
</span><span class="cx" style="display: block; padding: 0 10px">                if ( 'contain' === $background_styles['backgroundSize'] && ! $background_styles['backgroundPosition'] ) {
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpthemejsonresolverphp"></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/class-wp-theme-json-resolver.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-theme-json-resolver.php    2024-07-23 21:50:23 UTC (rev 58796)
+++ trunk/src/wp-includes/class-wp-theme-json-resolver.php      2024-07-24 00:24:31 UTC (rev 58797)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -848,6 +848,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * as the value of `_link` object in REST API responses.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 6.6.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 6.7.0 Resolve relative paths in block styles.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param WP_Theme_JSON $theme_json A theme json instance.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return array An array of resolved paths.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -860,15 +861,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">                $theme_json_data = $theme_json->get_raw_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               // Top level styles.
-               $background_image_url = isset( $theme_json_data['styles']['background']['backgroundImage']['url'] ) ? $theme_json_data['styles']['background']['backgroundImage']['url'] : null;
-
</del><span class="cx" style="display: block; padding: 0 10px">                 /*
</span><span class="cx" style="display: block; padding: 0 10px">                 * The same file convention when registering web fonts.
</span><span class="cx" style="display: block; padding: 0 10px">                 * See: WP_Font_Face_Resolver::to_theme_file_uri.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                $placeholder = 'file:./';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               // Top level styles.
+               $background_image_url = $theme_json_data['styles']['background']['backgroundImage']['url'] ?? null;
</ins><span class="cx" style="display: block; padding: 0 10px">                 if (
</span><span class="cx" style="display: block; padding: 0 10px">                        isset( $background_image_url ) &&
</span><span class="cx" style="display: block; padding: 0 10px">                        is_string( $background_image_url ) &&
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -888,6 +888,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $resolved_theme_uris[] = $resolved_theme_uri;
</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">+                // Block styles.
+               if ( ! empty( $theme_json_data['styles']['blocks'] ) ) {
+                       foreach ( $theme_json_data['styles']['blocks'] as $block_name => $block_styles ) {
+                               if ( ! isset( $block_styles['background']['backgroundImage']['url'] ) ) {
+                                       continue;
+                               }
+                               $background_image_url = $block_styles['background']['backgroundImage']['url'];
+                               if (
+                                       is_string( $background_image_url ) &&
+                                       // Skip if the src doesn't start with the placeholder, as there's nothing to replace.
+                                       str_starts_with( $background_image_url, $placeholder )
+                               ) {
+                                       $file_type          = wp_check_filetype( $background_image_url );
+                                       $src_url            = str_replace( $placeholder, '', $background_image_url );
+                                       $resolved_theme_uri = array(
+                                               'name'   => $background_image_url,
+                                               'href'   => sanitize_url( get_theme_file_uri( $src_url ) ),
+                                               'target' => "styles.blocks.{$block_name}.background.backgroundImage.url",
+                                       );
+                                       if ( isset( $file_type['type'] ) ) {
+                                               $resolved_theme_uri['type'] = $file_type['type'];
+                                       }
+                                       $resolved_theme_uris[] = $resolved_theme_uri;
+                               }
+                       }
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $resolved_theme_uris;
</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="trunksrcwpincludesclasswpthemejsonphp"></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/class-wp-theme-json.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-theme-json.php     2024-07-23 21:50:23 UTC (rev 58796)
+++ trunk/src/wp-includes/class-wp-theme-json.php       2024-07-24 00:24:31 UTC (rev 58797)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -520,10 +520,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        const VALID_STYLES = array(
</span><span class="cx" style="display: block; padding: 0 10px">                'background' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'backgroundImage'    => 'top',
-                       'backgroundPosition' => 'top',
-                       'backgroundRepeat'   => 'top',
-                       'backgroundSize'     => 'top',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'backgroundImage'    => null,
+                       'backgroundPosition' => null,
+                       'backgroundRepeat'   => null,
+                       'backgroundSize'     => null,
</ins><span class="cx" style="display: block; padding: 0 10px">                 ),
</span><span class="cx" style="display: block; padding: 0 10px">                'border'     => array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'color'  => null,
</span></span></pre></div>
<a id="trunksrcwpincludesglobalstylesandsettingsphp"></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/global-styles-and-settings.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/global-styles-and-settings.php      2024-07-23 21:50:23 UTC (rev 58796)
+++ trunk/src/wp-includes/global-styles-and-settings.php        2024-07-24 00:24:31 UTC (rev 58797)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -247,6 +247,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Adds global style rules to the inline style for each block.
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.7.0 Resolve relative paths in block styles.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @global WP_Styles $wp_styles
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -254,6 +255,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        global $wp_styles;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $tree        = WP_Theme_JSON_Resolver::get_merged_data();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $tree        = WP_Theme_JSON_Resolver::resolve_theme_file_uris( $tree );
</ins><span class="cx" style="display: block; padding: 0 10px">         $block_nodes = $tree->get_styles_block_nodes();
</span><span class="cx" style="display: block; padding: 0 10px">        foreach ( $block_nodes as $metadata ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $block_css = $tree->get_styles_for_block( $metadata );
</span></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemeJsonphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/wpThemeJson.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeJson.php   2024-07-23 21:50:23 UTC (rev 58796)
+++ trunk/tests/phpunit/tests/theme/wpThemeJson.php     2024-07-24 00:24:31 UTC (rev 58797)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5021,7 +5021,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">                $expected_styles = "html{min-height: calc(100% - var(--wp-admin--admin-bar--height, 0px));}:root :where(body){background-image: url('http://example.org/image.png');background-position: center center;background-repeat: no-repeat;background-size: contain;}";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( $expected_styles, $theme_json->get_styles_for_block( $body_node ), 'Styles returned from "::get_stylesheet()" with top-level background styles type does not match expectations' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $expected_styles, $theme_json->get_styles_for_block( $body_node ), 'Styles returned from "::get_stylesheet()" with top-level background styles type do not match expectations' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $theme_json = new WP_Theme_JSON(
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5038,10 +5038,67 @@
</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">                $expected_styles = "html{min-height: calc(100% - var(--wp-admin--admin-bar--height, 0px));}:root :where(body){background-image: url('http://example.org/image.png');background-position: center center;background-repeat: no-repeat;background-size: contain;}";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( $expected_styles, $theme_json->get_styles_for_block( $body_node ), 'Styles returned from "::get_stylesheet()" with top-level background image as string type does not match expectations' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $expected_styles, $theme_json->get_styles_for_block( $body_node ), 'Styles returned from "::get_stylesheet()" with top-level background image as string type do not match expectations' );
</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">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @ticket 61588
+        */
+       public function test_get_block_background_image_styles() {
+               $theme_json = new WP_Theme_JSON(
+                       array(
+                               'version' => WP_Theme_JSON::LATEST_SCHEMA,
+                               'styles'  => array(
+                                       'blocks' => array(
+                                               'core/group' => array(
+                                                       'background' => array(
+                                                               'backgroundImage'    => "url('http://example.org/group.png')",
+                                                               'backgroundSize'     => 'cover',
+                                                               'backgroundRepeat'   => 'no-repeat',
+                                                               'backgroundPosition' => 'center center',
+                                                       ),
+                                               ),
+                                               'core/quote' => array(
+                                                       'background' => array(
+                                                               'backgroundImage'    => array(
+                                                                       'url' => 'http://example.org/quote.png',
+                                                               ),
+                                                               'backgroundSize'     => 'cover',
+                                                               'backgroundRepeat'   => 'no-repeat',
+                                                               'backgroundPosition' => 'center center',
+                                                       ),
+                                               ),
+                                       ),
+                               ),
+                       )
+               );
+
+               $quote_node = array(
+                       'name'      => 'core/quote',
+                       'path'      => array( 'styles', 'blocks', 'core/quote' ),
+                       'selector'  => '.wp-block-quote',
+                       'selectors' => array(
+                               'root' => '.wp-block-quote',
+                       ),
+               );
+
+               $quote_styles = ":root :where(.wp-block-quote){background-image: url('http://example.org/quote.png');background-position: center center;background-repeat: no-repeat;background-size: cover;}";
+               $this->assertSame( $quote_styles, $theme_json->get_styles_for_block( $quote_node ), 'Styles returned from "::get_styles_for_block()" with block-level background styles do not match expectations' );
+
+               $group_node = array(
+                       'name'      => 'core/group',
+                       'path'      => array( 'styles', 'blocks', 'core/group' ),
+                       'selector'  => '.wp-block-group',
+                       'selectors' => array(
+                               'root' => '.wp-block-group',
+                       ),
+               );
+
+               $group_styles = ":root :where(.wp-block-group){background-image: url('http://example.org/group.png');background-position: center center;background-repeat: no-repeat;background-size: cover;}";
+               $this->assertSame( $group_styles, $theme_json->get_styles_for_block( $group_node ), 'Styles returned from "::get_styles_for_block()" with block-level background styles as string type do not match expectations' );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Tests that base custom CSS is generated correctly.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 61395
</span></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemeJsonResolverphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php   2024-07-23 21:50:23 UTC (rev 58796)
+++ trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php     2024-07-24 00:24:31 UTC (rev 58797)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1257,6 +1257,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @covers WP_Theme_JSON_Resolver::resolve_theme_file_uris
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 61273
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @ticket 61588
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_resolve_theme_file_uris() {
</span><span class="cx" style="display: block; padding: 0 10px">                $theme_json = new WP_Theme_JSON(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1268,6 +1269,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                        'url' => 'file:./assets/image.png',
</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">+                                        'blocks'     => array(
+                                               'core/quote' => array(
+                                                       'background' => array(
+                                                               'backgroundImage' => array(
+                                                                       'url' => 'file:./assets/quote.png',
+                                                               ),
+                                                       ),
+                                               ),
+                                               'core/verse' => array(
+                                                       'background' => array(
+                                                               'backgroundImage' => array(
+                                                                       'url' => 'file:./assets/verse.png',
+                                                               ),
+                                                       ),
+                                               ),
+                                       ),
</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">                );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1280,6 +1297,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                'url' => 'https://example.org/wp-content/themes/example-theme/assets/image.png',
</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">+                                'blocks'     => array(
+                                       'core/quote' => array(
+                                               'background' => array(
+                                                       'backgroundImage' => array(
+                                                               'url' => 'https://example.org/wp-content/themes/example-theme/assets/quote.png',
+                                                       ),
+                                               ),
+                                       ),
+                                       'core/verse' => array(
+                                               'background' => array(
+                                                       'backgroundImage' => array(
+                                                               'url' => 'https://example.org/wp-content/themes/example-theme/assets/verse.png',
+                                                       ),
+                                               ),
+                                       ),
+                               ),
</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"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1293,6 +1326,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @covers WP_Theme_JSON_Resolver::get_resolved_theme_uris
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 61273
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @ticket 61588
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_resolved_theme_uris() {
</span><span class="cx" style="display: block; padding: 0 10px">                $theme_json = new WP_Theme_JSON(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1304,6 +1338,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                        'url' => 'file:./assets/image.png',
</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">+                                        'blocks'     => array(
+                                               'core/quote' => array(
+                                                       'background' => array(
+                                                               'backgroundImage' => array(
+                                                                       'url' => 'file:./assets/quote.jpg',
+                                                               ),
+                                                       ),
+                                               ),
+                                               'core/verse' => array(
+                                                       'background' => array(
+                                                               'backgroundImage' => array(
+                                                                       'url' => 'file:./assets/verse.gif',
+                                                               ),
+                                                       ),
+                                               ),
+                                       ),
</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">                );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1315,6 +1365,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'target' => 'styles.background.backgroundImage.url',
</span><span class="cx" style="display: block; padding: 0 10px">                                'type'   => 'image/png',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        array(
+                               'name'   => 'file:./assets/quote.jpg',
+                               'href'   => 'https://example.org/wp-content/themes/example-theme/assets/quote.jpg',
+                               'target' => 'styles.blocks.core/quote.background.backgroundImage.url',
+                               'type'   => 'image/jpeg',
+                       ),
+                       array(
+                               'name'   => 'file:./assets/verse.gif',
+                               'href'   => 'https://example.org/wp-content/themes/example-theme/assets/verse.gif',
+                               'target' => 'styles.blocks.core/verse.background.backgroundImage.url',
+                               'type'   => 'image/gif',
+                       ),
</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">                $actual = WP_Theme_JSON_Resolver::get_resolved_theme_uris( $theme_json );
</span></span></pre>
</div>
</div>

</body>
</html>