Changeset 52329
- Timestamp:
- 12/06/2021 10:40:45 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r52321 r52329 356 356 * @since 5.8.0 357 357 * 358 * @param array $theme_json A structure that follows the theme.json schema.359 * @param string $origin Optional. What source of data this object represents.360 * One of 'default', 'theme', or 'custom'. Default 'theme'.358 * @param array $theme_json A structure that follows the theme.json schema. 359 * @param string $origin Optional. What source of data this object represents. 360 * One of 'default', 'theme', or 'custom'. Default 'theme'. 361 361 */ 362 362 public function __construct( $theme_json = array(), $origin = 'theme' ) { … … 777 777 } 778 778 779 /* 780 * Reset default browser margin on the root body element. 781 * This is set on the root selector **before** generating the ruleset 782 * from the `theme.json`. This is to ensure that if the `theme.json` declares 783 * `margin` in its `spacing` declaration for the `body` element then these 784 * user-generated values take precedence in the CSS cascade. 785 * @link https://github.com/WordPress/gutenberg/issues/36147. 786 */ 787 if ( self::ROOT_BLOCK_SELECTOR === $selector ) { 788 $block_rules .= 'body { margin: 0; }'; 789 } 790 779 791 // 2. Generate the rules that use the general selector. 780 792 $block_rules .= self::to_ruleset( $selector, $declarations ); … … 787 799 788 800 if ( self::ROOT_BLOCK_SELECTOR === $selector ) { 789 $block_rules .= 'body { margin: 0; }';790 801 $block_rules .= '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }'; 791 802 $block_rules .= '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }'; -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r52275 r52329 377 377 ); 378 378 379 $expected = 'body {--wp--style--block-gap: 1em;}body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }.wp-block-columns{--wp--style--block-gap: 24px;}';380 $this->assert Equals( $expected, $theme_json->get_stylesheet() );381 $this->assert Equals( $expected, $theme_json->get_stylesheet( array( 'styles' ) ) );379 $expected = 'body { margin: 0; }body{--wp--style--block-gap: 1em;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }.wp-block-columns{--wp--style--block-gap: 24px;}'; 380 $this->assertSame( $expected, $theme_json->get_stylesheet() ); 381 $this->assertSame( $expected, $theme_json->get_stylesheet( array( 'styles' ) ) ); 382 382 } 383 383 … … 507 507 508 508 $variables = 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}'; 509 $styles = 'body {color: var(--wp--preset--color--grey);}body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}';509 $styles = 'body { margin: 0; }body{color: var(--wp--preset--color--grey);}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}'; 510 510 $presets = '.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}'; 511 511 $all = $variables . $styles . $presets; 512 $this->assert Equals( $all, $theme_json->get_stylesheet() );513 $this->assert Equals( $styles, $theme_json->get_stylesheet( array( 'styles' ) ) );514 $this->assert Equals( $presets, $theme_json->get_stylesheet( array( 'presets' ) ) );515 $this->assert Equals( $variables, $theme_json->get_stylesheet( array( 'variables' ) ) );512 $this->assertSame( $all, $theme_json->get_stylesheet() ); 513 $this->assertSame( $styles, $theme_json->get_stylesheet( array( 'styles' ) ) ); 514 $this->assertSame( $presets, $theme_json->get_stylesheet( array( 'presets' ) ) ); 515 $this->assertSame( $variables, $theme_json->get_stylesheet( array( 'variables' ) ) ); 516 516 } 517 517
Note: See TracChangeset
for help on using the changeset viewer.