-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Consolidate add_theme_support() features into a single array #8732
Comments
+1 for consolidating to a single configuration array. I'd also add that it's cumbersome to hook theme supports from Plugins (intercepting the global add_theme_support( 'block_config', apply_filters( 'block_config', array(
'align-wide',
'editor-color-palette' => $theme_colors,
'editor-font-sizes' => $theme_font_sizes,
'disable-custom-colors',
'wp-block-styles',
) ) );``` |
Are there any other core features that consolidate their theme support options in this way? |
Wa had a similar configuration array originally and we decided to switch to more granular options. One of the reasons was the "child themes" as highlighted in the issue's description. Also |
The actual name can be something else. As for the child themes issue, that seems solvable. I still think consoldation here is key, especially because new features will be added to Gutenberg in the future, and leaving them as separate theme support options will make theme development unnecessarily chaotic. |
@mor10 @youknowriad agree, actual string keys can be something else. If there were a filter/filters for these that would also help mitigate the child theme concern, while also addressing current plugin pain. |
If we went to a full array-based approach, how does I'd also suggest that although it might seem tempting to bundle all these into a "gutenberg" or "block editor" array, a lot of concepts that Gutenberg introduces are likely to expand outward and impact other areas of core in the future. It seems shortsighted to bundle them all into a single area and psychologically reinforce the idea of the block editor and Gutenberg and all this JavaScriptiness being a self-contained entity—which it is now, but won't always be. I feel like the problem, to a degree, is with (I am totally sympathetic to this not being the best approach from a DX perspective, to be clear. The idea of a |
I originally proposed a central point of configuration so I'm in favor of going in this direction. Enough time has passed that I think there's a bit more clarity around which pieces fall where, and there are more features that can be configured by the theme than before (colors, fonts, widths, etc). All that said, I think it's crucial to imagine a world where most of the theme configurations are absorbed as block properties. For example, the "width" support doesn't make a lot of sense as theme configuration, because it actually depends on more granular context. it only takes a theme that has some pages as single column and others as multiple columns with sidebar for the "full-width" option to stop making sense. That to me indicated that "widths" are related to the block container in terms of layout. I could see So if you have a site with a main content column and a sidebar, the InnerBlocks powering the main content would have a set of width / alignment options, and a layout that only has a main content column could have a different one. Likewise with colors and fonts, I can see this being supplied to different layout regions, or being part of the root block for a full site building experience, determining which fonts should be used, based colors, etc. All that said to consider a case where all theme configuration is actually absorbed in the block hierarchy. This might help us figure out what theme_support keys we should be using, as they could emulate the kind of blocks we'll have once phase 3 is completed. |
We now have the official proposal from @youknowriad https://make.wordpress.org/core/2020/01/23/controlling-the-block-editor/ and filed under #20588 that in my opinion perfectly aligns with the proposal shared here. @mor10, can you double-check it and share your feedback? I'd prefer to close this issue so we could keep the conversation going in one place. What do you think? |
Let's close and consolidate on a single issue, it seems like it's generally the same idea. Let's continue discussing there and let us know if we missed anything. |
Right now various Gutenberg features are enabled (and disabled) through individual
add_theme_support()
declarations (documentation):This lends itself to fractured and confusing code and makes it hard for anyone reading the code to quickly identify what features are on or off. It also allows theme developers to declare support for different features in different locations throughout the template files making the supports hard to find.
Ideally these theme supports would all be declared in a single
add_theme_supports()
array with references to additional arrays. Something like this (though probably not like this - someone with a keener eye for PHP should propose an actual solution):Benefits
This approach clearly stipulates, in one location, what Gutenberg (block editor) features are enabled/disabled in the theme and makes control easy. It also establishes a framework for future theme support controls and makes it easy for developers to spot them if they are enabled. As a bonus, adding all the features in one location surfaces issues around naming conventions and feature descriptions. Most importantly, consolidating all these feature under one roof so to speak makes themes easier to build and maintain.
Challenges
There are some challenges which need to be addressed around this, one of which was brought up by @westonruter in #2021 around child themes and overrides.
The text was updated successfully, but these errors were encountered: