-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix post editor layout when content block has no attributes. #5221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cd973da
bb0636e
b4e9242
cb423e8
2f8c135
3425504
b55f10e
9feab8e
c1c2f36
0e75e53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* | ||
| Theme Name: Block Theme Post Content Default | ||
| Theme URI: https://wordpress.org/ | ||
| Description: For testing purposes only. | ||
| Version: 1.0.0 | ||
| Text Domain: block-theme-post-content-default | ||
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <!-- wp:paragraph --> | ||
| <p>Index Template</p> | ||
| <!-- /wp:paragraph --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| <!-- wp:post-title {"level":1,"style":{"spacing":{"margin":{"bottom":"var:preset|spacing|40"}}}} /--> | ||
| <!-- wp:post-content /--> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| { | ||
| "version": 1, | ||
| "title": "Block theme", | ||
| "settings": { | ||
| "color": { | ||
| "palette": [ | ||
| { | ||
| "slug": "light", | ||
| "name": "Light", | ||
| "color": "#f5f7f9" | ||
| }, | ||
| { | ||
| "slug": "dark", | ||
| "name": "Dark", | ||
| "color": "#000" | ||
| } | ||
| ], | ||
| "gradients": [ | ||
| { | ||
| "name": "Custom gradient", | ||
| "gradient": "linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%)", | ||
| "slug": "custom-gradient" | ||
| } | ||
| ], | ||
| "duotone": [ | ||
| { | ||
| "colors": [ "#333333", "#aaaaaa" ], | ||
| "slug": "custom-duotone", | ||
| "name": "Custom Duotone" | ||
| } | ||
| ], | ||
| "custom": false, | ||
| "customGradient": false | ||
| }, | ||
| "typography": { | ||
| "fontSizes": [ | ||
| { | ||
| "name": "Custom", | ||
| "slug": "custom", | ||
| "size": "100px" | ||
| } | ||
| ], | ||
| "customFontSize": false, | ||
| "customLineHeight": true | ||
| }, | ||
| "spacing": { | ||
| "units": ["rem"], | ||
| "customPadding": true, | ||
| "blockGap": true | ||
| }, | ||
| "blocks": { | ||
| "core/paragraph": { | ||
| "color": { | ||
| "palette": [ | ||
| { | ||
| "slug": "light", | ||
| "name": "Light", | ||
| "color": "#f5f7f9" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "styles" : { | ||
| "blocks" :{ | ||
| "core/post-featured-image": { | ||
| "shadow": "10px 10px 5px 0px rgba(0,0,0,0.66)", | ||
| "filter": { | ||
| "duotone": "var(--wp--preset--duotone--custom-duotone)" | ||
| } | ||
| } | ||
| }, | ||
| "elements": { | ||
| "button": { | ||
| "shadow": "10px 10px 5px 0px rgba(0,0,0,0.66)" | ||
| }, | ||
| "link": { | ||
| "typography": { | ||
| "textDecoration": "none" | ||
| }, | ||
| "border": { | ||
| "bottom": { | ||
| "width": "2px", | ||
| "color": "currentColor", | ||
| "style": "solid" | ||
| } | ||
| }, | ||
| ":hover": { | ||
| "typography": { | ||
| "textDecoration": "none" | ||
| }, | ||
| "border": { | ||
| "bottom": { | ||
| "width": "2px", | ||
| "color": "#000", | ||
| "style": "dotted" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -446,14 +446,20 @@ public function test_wp_get_post_content_block_attributes() { | |
| 'type' => 'constrained', | ||
| ), | ||
| ); | ||
| // With no block theme, expect an empty array. | ||
| $this->assertSame( array(), wp_get_post_content_block_attributes() ); | ||
| // With no block theme, expect null. | ||
| $this->assertNull( wp_get_post_content_block_attributes() ); | ||
|
|
||
| switch_theme( 'block-theme' ); | ||
|
|
||
| $this->assertSame( $attributes_with_layout, wp_get_post_content_block_attributes() ); | ||
| } | ||
|
|
||
| public function test_wp_get_post_content_block_attributes_no_layout() { | ||
| switch_theme( 'block-theme-post-content-default' ); | ||
|
|
||
| $this->assertSame( array(), wp_get_post_content_block_attributes() ); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to my above feedback, maybe add another test for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original test already checks the return value for classic themes (when Post Content doesn't exist), do you think it would be worth splitting that check out into its own test?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tellthemachines I meant a test for the There is https://github.com/WordPress/wordpress-develop/blob/trunk/tests/phpunit/tests/blocks/editor.php#L524 which checks the presence of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh got it! Yeah that's a good idea.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a test in 0e75e53 |
||
|
|
||
| /** | ||
| * @ticket 53458 | ||
| */ | ||
|
|
@@ -527,6 +533,19 @@ public function test_get_block_editor_settings_theme_json_settings() { | |
| switch_theme( WP_DEFAULT_THEME ); | ||
| } | ||
|
|
||
| /** | ||
| * @ticket 59358 | ||
| */ | ||
| public function test_get_block_editor_settings_without_post_content_block() { | ||
|
|
||
| $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); | ||
|
|
||
| $settings = get_block_editor_settings( array(), $post_editor_context ); | ||
|
|
||
| $this->assertArrayNotHasKey( 'postContentAttributes', $settings ); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * @ticket 52920 | ||
| * @expectedDeprecated block_editor_settings | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.