Hi @areoimiles,
Thanks very much for the prompt reply and the function.
A plugin option to override the rule isn’t necessary for recent versions of WordPress. Since WordPress 5.9.0, the function wp_get_layout_style
in file wp-includes/block-supports/layout.php (line 47 at the time of this writing) loads a max-width: none
rule for .alignwide
that is more specific than the plugin’s rule. I’ve tested this in the editor, and when a block is assigned .alignwide
the CSS inspector clearly shows it overriding the plugin’s rule, and indeed, the block displays at full width. There’s nothing to break by removing the plugin’s rule for WordPress 5.9.0 or newer.
Adding just a few styles to the plugin for strip, container, and row blocks to display at 100% in the editor addresses that need without forcing all other blocks which aren’t within one of those blocks to display in the editor at full width.
The use of this plugin should compliment the core block editor experience and not require that every post use its blocks as parent blocks for core blocks. This is especially true when the plugin is added to a site with existing post content, the layout of which will appear incorrect in the editor when the plugin is activated unless that content is updated to use the plugin’s blocks, an onerous task for a site with even a small amount of existing content.
For older versions of WordPress, if the plugin were to respect settings.layout.contentSize
in theme.json
by default (if that file and setting is present), with an option to override that in the plugin settings (either by using a user-entered value or by falling back to the plugin’s rule, the former of which I believe would be the only option for versions of WordPress older than 5.8.0 not using the Gutenberg plugin), that would solve the problem. Additionally, it would make sense to conditionally add the rule based on the version of WordPress, so it only applies to versions older than 5.9.0, where it might be of use. Again, removing the rule entirely and replacing it with styles for strip/container/row blocks to display at 100% would be a better solution.
There may be some edge cases I haven’t addressed here, but I believe these are the most common scenarios.