Skip to content
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

Turn off Layout for all blocks by default #46

Closed
mrwweb opened this issue Jun 23, 2022 · 3 comments
Closed

Turn off Layout for all blocks by default #46

mrwweb opened this issue Jun 23, 2022 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers On Hold

Comments

@mrwweb
Copy link
Owner

mrwweb commented Jun 23, 2022

The layout implementation for group blocks and others makes no sense as documented quite well in WordPress/gutenberg#31980.

Here's a good way to turn it off:

/**
 * Filter block type metadata to remove unwanted output from the editor.
 *
 * @param array $metadata Metadata for the currently processed block type.
 *
 * @return array Filtered metadata.
 */
public function filter_block_type_metadata( $metadata ) {

	/**
	 * Disable the layout panel for all blocks.
	 */
	if ( isset( $metadata['supports']['__experimentalLayout'] ) ) {
		$metadata['supports']['__experimentalLayout'] = false;
	}

	return $metadata;
}
	
add_filter( 'block_type_metadata', 'filter_block_type_metadata' );
@mrwweb mrwweb added enhancement New feature or request good first issue Good for newcomers labels Jun 23, 2022
@mrwweb mrwweb added this to the v2.10.0 milestone Jun 23, 2022
@mrwweb
Copy link
Owner Author

mrwweb commented Jul 13, 2022

After experimenting with the code snippet in the OG, it does not work as expected. It does effectively disable the "inherit layout" toggle, but it does so at the expense of allowing alignment of child blocks.

@mrwweb
Copy link
Owner Author

mrwweb commented Oct 13, 2022

Now that WP 6.1 defaults to the "Constrained" layout type, this may no longer be an issue. I'm not quite ready to close the issue, but I'm removing it from the 2.10 milestone for further consideration.

@mrwweb mrwweb added the On Hold label Oct 13, 2022
@mrwweb mrwweb removed this from the v2.10.0 milestone Oct 13, 2022
@mrwweb
Copy link
Owner Author

mrwweb commented Mar 24, 2023

I've been living with 6.1 for long enough that I'm convinced this issue has been resolved thanks to lobbying upstream! Yay!

@mrwweb mrwweb closed this as completed Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers On Hold
Projects
None yet
Development

No branches or pull requests

1 participant