mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add support for column and row spans in grid children. #6493
Closed
tellthemachines
wants to merge
7
commits into
WordPress:trunk
from
tellthemachines:add/grid-column-row-spans
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c9a0514
Add support for column and row spans in grid children.
tellthemachines 66a0692
Check child layout exists before generating classname.
tellthemachines ed8549d
Add a test for child layout classes
tellthemachines 0b97584
Use `wp_unique_prefixed_id` instead of `wp_unique_id`
tellthemachines e0c0cba
Convert filter to named function.
tellthemachines 81a54f5
Update comment and ticket annotation.
tellthemachines 0926acf
Add unit test for `wp_add_parent_layout_to_parsed_block`
tellthemachines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,7 @@ public function test_outer_container_not_restored_for_aligned_image_block_with_t | |
* @ticket 57584 | ||
* @ticket 58548 | ||
* @ticket 60292 | ||
* @ticket 61111 | ||
* | ||
* @dataProvider data_layout_support_flag_renders_classnames_on_wrapper | ||
* | ||
|
@@ -181,6 +182,7 @@ public function test_outer_container_not_restored_for_aligned_image_block_with_t | |
* @param string $expected_output The expected output. | ||
*/ | ||
public function test_layout_support_flag_renders_classnames_on_wrapper( $args, $expected_output ) { | ||
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. I notice this function includes references to the tickets directly above it. Should the linked trac ticket be added to that list? |
||
switch_theme( 'default' ); | ||
$actual_output = wp_render_layout_support_flag( $args['block_content'], $args['block'] ); | ||
$this->assertSame( $expected_output, $actual_output ); | ||
} | ||
|
@@ -251,6 +253,27 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() { | |
), | ||
'expected_output' => '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper is-layout-flow wp-block-group-is-layout-flow"></div></div>', | ||
), | ||
'block with child layout' => array( | ||
'args' => array( | ||
'block_content' => '<p>Some text.</p>', | ||
'block' => array( | ||
'blockName' => 'core/paragraph', | ||
'attrs' => array( | ||
'style' => array( | ||
'layout' => array( | ||
'columnSpan' => '2', | ||
), | ||
), | ||
), | ||
'innerBlocks' => array(), | ||
'innerHTML' => '<p>Some text.</p>', | ||
'innerContent' => array( | ||
'<p>Some text.</p>', | ||
), | ||
), | ||
), | ||
'expected_output' => '<p class="wp-container-content-1">Some text.</p>', // The generated classname number assumes `wp_unique_prefixed_id( 'wp-container-content-' )` will not have run previously in this test. | ||
), | ||
'skip classname output if block does not support layout and there are no child layout classes to be output' => array( | ||
'args' => array( | ||
'block_content' => '<p>A paragraph</p>', | ||
|
@@ -362,4 +385,81 @@ public function data_restore_group_inner_container() { | |
), | ||
); | ||
} | ||
|
||
/** | ||
* Checks that `wp_add_parent_layout_to_parsed_block` adds the parent layout attribute to the block object. | ||
* | ||
* @ticket 61111 | ||
* | ||
* @covers ::wp_add_parent_layout_to_parsed_block | ||
* | ||
* @dataProvider data_wp_add_parent_layout_to_parsed_block | ||
* | ||
* @param array $block The block object. | ||
* @param WP_Block $parent_block The parent block object. | ||
* @param array $expected The expected block object. | ||
*/ | ||
public function test_wp_add_parent_layout_to_parsed_block( $block, $parent_block, $expected ) { | ||
$actual = wp_add_parent_layout_to_parsed_block( $block, array(), $parent_block ); | ||
$this->assertSame( $expected, $actual ); | ||
} | ||
|
||
/** | ||
* Data provider for test_wp_add_parent_layout_to_parsed_block. | ||
* | ||
* @return array | ||
*/ | ||
public function data_wp_add_parent_layout_to_parsed_block() { | ||
return array( | ||
'block with no parent layout' => array( | ||
'block' => array( | ||
'blockName' => 'core/group', | ||
'attrs' => array( | ||
'layout' => array( | ||
'type' => 'default', | ||
), | ||
), | ||
), | ||
'parent_block' => array(), | ||
'expected' => array( | ||
'blockName' => 'core/group', | ||
'attrs' => array( | ||
'layout' => array( | ||
'type' => 'default', | ||
), | ||
), | ||
), | ||
), | ||
'block with parent layout' => array( | ||
'block' => array( | ||
'blockName' => 'core/group', | ||
'attrs' => array( | ||
'layout' => array( | ||
'type' => 'default', | ||
), | ||
), | ||
), | ||
'parent_block' => new WP_Block( | ||
array( | ||
'attrs' => array( | ||
'layout' => array( | ||
'type' => 'grid', | ||
), | ||
), | ||
) | ||
), | ||
'expected' => array( | ||
'blockName' => 'core/group', | ||
'attrs' => array( | ||
'layout' => array( | ||
'type' => 'default', | ||
), | ||
), | ||
'parentLayout' => array( | ||
'type' => 'grid', | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add unit test for new filter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests added!