Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6fbc632
Try content width column as new layout type
tellthemachines Jul 28, 2022
81768a3
Consolidate root selector rules.
tellthemachines Jul 29, 2022
464139b
Undo rebase weirdness
tellthemachines Jul 29, 2022
5e8010d
Add deprecation and server-side legacy support
tellthemachines Jul 29, 2022
20499c0
Change group block approach
tellthemachines Aug 2, 2022
93a985a
Fix buggy align behaviour
tellthemachines Aug 3, 2022
f2fc2bb
Alignments should work for classic themes
tellthemachines Aug 4, 2022
f748fee
Set output to empty string.
tellthemachines Aug 4, 2022
f4e7d10
Add layout type fallback for alignments
tellthemachines Aug 4, 2022
f54f812
Regenerate fixtures
tellthemachines Aug 4, 2022
6af5ecd
Update snapshots
tellthemachines Aug 5, 2022
f52ba94
Change nested blocks to buttons
tellthemachines Aug 5, 2022
86f5ed9
Fix php test diffs
tellthemachines Aug 5, 2022
b6b2483
Fix rebase inconsistency in layout
tellthemachines Aug 5, 2022
454195f
Add test for content size variable output
tellthemachines Aug 5, 2022
47464ac
Add test for column layout.
tellthemachines Aug 5, 2022
7f5874b
Fix loss of layout attributes.
tellthemachines Aug 9, 2022
155885e
Make layout changes work for blocks without deprecation
tellthemachines Aug 9, 2022
5d3573f
Fix custom content size controls
tellthemachines Aug 9, 2022
6096d7d
Fix post title
tellthemachines Aug 12, 2022
de61635
Update new e2e snapshots
tellthemachines Aug 12, 2022
09756f3
Change layout type name to "constrained"
tellthemachines Aug 15, 2022
772906a
Update snapshots for new tests.
tellthemachines Aug 16, 2022
1f516f1
Content size variables should be output in the site editor.
tellthemachines Aug 17, 2022
17124fb
Fix custom content sizes in editor.
tellthemachines Aug 17, 2022
f22bee0
Tidy up PHP.
tellthemachines Aug 17, 2022
abd1baf
Add deprecation fixtures
tellthemachines Aug 17, 2022
78a3ed5
Fixed duplicated code after rebase hack job. Sorry!
ramonjd Aug 22, 2022
49b12fb
Increase block gap selector specificity.
tellthemachines Aug 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tidy up PHP.
  • Loading branch information
tellthemachines authored and ramonjd committed Aug 22, 2022
commit f22bee07a15d01ab25b5b19aab57b0d9e7a815d0
13 changes: 7 additions & 6 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,20 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
$has_block_gap_support = isset( $block_gap ) ? null !== $block_gap : false;
$default_block_layout = _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() );
$used_layout = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $default_block_layout;
$class_names = array();
$layout_definitions = _wp_array_get( $global_layout_settings, array( 'definitions' ), array() );
$block_classname = wp_get_block_default_classname( $block['blockName'] );
$container_class = wp_unique_id( 'wp-container-' );
$layout_classname = '';
$use_global_padding = gutenberg_get_global_settings( array( 'useRootPaddingAwareAlignments' ) ) && ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] );

if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] ) {
Copy link
Contributor

@glendaviesnz glendaviesnz Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a nit, could this be moved up to just after the $used_layout declaration as it seems like the other declarations are not needed if this returns early?

	$global_layout_settings = gutenberg_get_global_settings( array( 'layout' ) );
	$default_block_layout    = _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() );
	$used_layout                   = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $default_block_layout;

	if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] ) {
		if ( ! $global_layout_settings ) {
			return $block_content;
		}
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense!

if ( ! $global_layout_settings ) {
return $block_content;
}
}

$class_names = array();
$layout_definitions = _wp_array_get( $global_layout_settings, array( 'definitions' ), array() );
$block_classname = wp_get_block_default_classname( $block['blockName'] );
$container_class = wp_unique_id( 'wp-container-' );
$layout_classname = '';
$use_global_padding = gutenberg_get_global_settings( array( 'useRootPaddingAwareAlignments' ) ) && ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] );

// Set the correct layout type for blocks using legacy content width.
if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] ) {
$used_layout['type'] = 'constrained';
Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ function( $pseudo_selector ) use ( $selector ) {
* If there are content and wide widths in theme.json, output them
* as custom properties on the body element so all blocks can use them.
*/
if ( isset( $settings['layout']['contentSize'] ) && $settings['layout']['contentSize'] || isset( $settings['layout']['wideSize'] ) && $settings['layout']['wideSize'] ) {
if ( isset( $settings['layout']['contentSize'] ) || isset( $settings['layout']['wideSize'] ) ) {
$content_size = isset( $settings['layout']['contentSize'] ) ? $settings['layout']['contentSize'] : $settings['layout']['wideSize'];
$content_size = static::is_safe_css_declaration( 'max-width', $content_size ) ? $content_size : 'initial';
$wide_size = isset( $settings['layout']['wideSize'] ) ? $settings['layout']['wideSize'] : $settings['layout']['contentSize'];
Expand Down