Changeset 58834
- Timestamp:
- 07/31/2024 02:39:46 AM (3 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/background.php
r58797 r58834 43 43 * @since 6.5.0 Added support for `backgroundPosition` and `backgroundRepeat` output. 44 44 * @since 6.6.0 Removed requirement for `backgroundImage.source`. A file/url is the default. 45 * @since 6.7.0 Added support for `backgroundAttachment` output. 45 46 * 46 47 * @access private … … 63 64 } 64 65 65 $background_styles = array(); 66 $background_styles['backgroundImage'] = $block_attributes['style']['background']['backgroundImage'] ?? null; 67 $background_styles['backgroundSize'] = $block_attributes['style']['background']['backgroundSize'] ?? null; 68 $background_styles['backgroundPosition'] = $block_attributes['style']['background']['backgroundPosition'] ?? null; 69 $background_styles['backgroundRepeat'] = $block_attributes['style']['background']['backgroundRepeat'] ?? null; 66 $background_styles = array(); 67 $background_styles['backgroundImage'] = $block_attributes['style']['background']['backgroundImage'] ?? null; 68 $background_styles['backgroundSize'] = $block_attributes['style']['background']['backgroundSize'] ?? null; 69 $background_styles['backgroundPosition'] = $block_attributes['style']['background']['backgroundPosition'] ?? null; 70 $background_styles['backgroundRepeat'] = $block_attributes['style']['background']['backgroundRepeat'] ?? null; 71 $background_styles['backgroundAttachment'] = $block_attributes['style']['background']['backgroundAttachment'] ?? null; 70 72 71 73 if ( ! empty( $background_styles['backgroundImage'] ) ) { -
trunk/src/wp-includes/class-wp-theme-json.php
r58797 r58834 227 227 * @since 6.5.0 Added `aspect-ratio` property. 228 228 * @since 6.6.0 Added `background-[image|position|repeat|size]` properties. 229 * @since 6.7.0 Added `background-attachment` property. 229 230 * 230 231 * @var array … … 238 239 'background-repeat' => array( 'background', 'backgroundRepeat' ), 239 240 'background-size' => array( 'background', 'backgroundSize' ), 241 'background-attachment' => array( 'background', 'backgroundAttachment' ), 240 242 'border-radius' => array( 'border', 'radius' ), 241 243 'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ), … … 521 523 const VALID_STYLES = array( 522 524 'background' => array( 523 'backgroundImage' => null, 524 'backgroundPosition' => null, 525 'backgroundRepeat' => null, 526 'backgroundSize' => null, 525 'backgroundImage' => null, 526 'backgroundPosition' => null, 527 'backgroundRepeat' => null, 528 'backgroundSize' => null, 529 'backgroundAttachment' => null, 527 530 ), 528 531 'border' => array( -
trunk/src/wp-includes/style-engine/class-wp-style-engine.php
r58311 r58834 51 51 const BLOCK_STYLE_DEFINITIONS_METADATA = array( 52 52 'background' => array( 53 'backgroundImage' => array(53 'backgroundImage' => array( 54 54 'property_keys' => array( 55 55 'default' => 'background-image', … … 58 58 'path' => array( 'background', 'backgroundImage' ), 59 59 ), 60 'backgroundPosition' => array(60 'backgroundPosition' => array( 61 61 'property_keys' => array( 62 62 'default' => 'background-position', … … 64 64 'path' => array( 'background', 'backgroundPosition' ), 65 65 ), 66 'backgroundRepeat' => array(66 'backgroundRepeat' => array( 67 67 'property_keys' => array( 68 68 'default' => 'background-repeat', … … 70 70 'path' => array( 'background', 'backgroundRepeat' ), 71 71 ), 72 'backgroundSize' => array(72 'backgroundSize' => array( 73 73 'property_keys' => array( 74 74 'default' => 'background-size', 75 75 ), 76 76 'path' => array( 'background', 'backgroundSize' ), 77 ), 78 'backgroundAttachment' => array( 79 'property_keys' => array( 80 'default' => 'background-attachment', 81 ), 82 'path' => array( 'background', 'backgroundAttachment' ), 77 83 ), 78 84 ), -
trunk/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php
r58222 r58834 70 70 * @ticket 60175 71 71 * @ticket 61123 72 * @ticket 61720 72 73 * 73 74 * @covers ::wp_render_background_support … … 140 141 'wrapper' => '<div>Content</div>', 141 142 ), 142 'background image style with contain, position, and repeat is applied' => array( 143 'theme_name' => 'block-theme-child-with-fluid-typography', 144 'block_name' => 'test/background-rules-are-output', 145 'background_settings' => array( 146 'backgroundImage' => true, 147 ), 148 'background_style' => array( 149 'backgroundImage' => array( 150 'url' => 'https://example.com/image.jpg', 151 ), 152 'backgroundRepeat' => 'no-repeat', 153 'backgroundSize' => 'contain', 154 ), 155 'expected_wrapper' => '<div class="has-background" style="background-image:url('https://example.com/image.jpg');background-position:center;background-repeat:no-repeat;background-size:contain;">Content</div>', 143 'background image style with contain, position, attachment, and repeat is applied' => array( 144 'theme_name' => 'block-theme-child-with-fluid-typography', 145 'block_name' => 'test/background-rules-are-output', 146 'background_settings' => array( 147 'backgroundImage' => true, 148 ), 149 'background_style' => array( 150 'backgroundImage' => array( 151 'url' => 'https://example.com/image.jpg', 152 ), 153 'backgroundRepeat' => 'no-repeat', 154 'backgroundSize' => 'contain', 155 'backgroundAttachment' => 'fixed', 156 ), 157 'expected_wrapper' => '<div class="has-background" style="background-image:url('https://example.com/image.jpg');background-position:center;background-repeat:no-repeat;background-size:contain;background-attachment:fixed;">Content</div>', 156 158 'wrapper' => '<div>Content</div>', 157 159 ), -
trunk/tests/phpunit/tests/style-engine/styleEngine.php
r58089 r58834 29 29 * @ticket 58590 30 30 * @ticket 60175 31 * @ticket 61720 31 32 * 32 33 * @covers ::wp_style_engine_get_styles … … 540 541 'block_styles' => array( 541 542 'background' => array( 542 'backgroundImage' => array(543 'backgroundImage' => array( 543 544 'url' => 'https://example.com/image.jpg', 544 545 ), 545 'backgroundPosition' => 'center', 546 'backgroundRepeat' => 'no-repeat', 547 'backgroundSize' => 'cover', 546 'backgroundPosition' => 'center', 547 'backgroundRepeat' => 'no-repeat', 548 'backgroundSize' => 'cover', 549 'backgroundAttachment' => 'fixed', 548 550 ), 549 551 ), 550 552 'options' => array(), 551 553 'expected_output' => array( 552 'css' => "background-image:url('https://example.com/image.jpg');background-position:center;background-repeat:no-repeat;background-size:cover;", 553 'declarations' => array( 554 'background-image' => "url('https://example.com/image.jpg')", 555 'background-position' => 'center', 556 'background-repeat' => 'no-repeat', 557 'background-size' => 'cover', 554 'css' => "background-image:url('https://example.com/image.jpg');background-position:center;background-repeat:no-repeat;background-size:cover;background-attachment:fixed;", 555 'declarations' => array( 556 'background-image' => "url('https://example.com/image.jpg')", 557 'background-position' => 'center', 558 'background-repeat' => 'no-repeat', 559 'background-size' => 'cover', 560 'background-attachment' => 'fixed', 558 561 ), 559 562 ), -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r58797 r58834 4998 4998 * @ticket 61123 4999 4999 * @ticket 61165 5000 * @ticket 61720 5000 5001 */ 5001 5002 public function test_get_top_level_background_image_styles() { … … 5005 5006 'styles' => array( 5006 5007 'background' => array( 5007 'backgroundImage' => array(5008 'backgroundImage' => array( 5008 5009 'url' => 'http://example.org/image.png', 5009 5010 ), 5010 'backgroundSize' => 'contain', 5011 'backgroundRepeat' => 'no-repeat', 5012 'backgroundPosition' => 'center center', 5011 'backgroundSize' => 'contain', 5012 'backgroundRepeat' => 'no-repeat', 5013 'backgroundPosition' => 'center center', 5014 'backgroundAttachment' => 'fixed', 5013 5015 ), 5014 5016 ), … … 5021 5023 ); 5022 5024 5023 $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; }";5025 $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;background-attachment: fixed;}"; 5024 5026 $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' ); 5025 5027 … … 5029 5031 'styles' => array( 5030 5032 'background' => array( 5031 'backgroundImage' => "url('http://example.org/image.png')",5032 'backgroundSize' => 'contain',5033 'backgroundRepeat' => 'no-repeat',5034 'backgroundPosition' => 'center center',5035 ),5036 ),5037 )5038 );5039 5040 $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;}"; 5033 'backgroundImage' => "url('http://example.org/image.png')", 5034 'backgroundSize' => 'contain', 5035 'backgroundRepeat' => 'no-repeat', 5036 'backgroundPosition' => 'center center', 5037 'backgroundAttachment' => 'fixed', 5038 ), 5039 ), 5040 ) 5041 ); 5042 5041 5043 $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' ); 5042 5044 } … … 5044 5046 /** 5045 5047 * @ticket 61588 5048 * @ticket 61720 5046 5049 */ 5047 5050 public function test_get_block_background_image_styles() { … … 5053 5056 'core/group' => array( 5054 5057 'background' => array( 5055 'backgroundImage' => "url('http://example.org/group.png')", 5056 'backgroundSize' => 'cover', 5057 'backgroundRepeat' => 'no-repeat', 5058 'backgroundPosition' => 'center center', 5058 'backgroundImage' => "url('http://example.org/group.png')", 5059 'backgroundSize' => 'cover', 5060 'backgroundRepeat' => 'no-repeat', 5061 'backgroundPosition' => 'center center', 5062 'backgroundAttachment' => 'fixed', 5059 5063 ), 5060 5064 ), … … 5095 5099 ); 5096 5100 5097 $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; }";5101 $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;background-attachment: fixed;}"; 5098 5102 $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' ); 5099 5103 }
Note: See TracChangeset
for help on using the changeset viewer.