-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Allow to disable settings for specific blocks #38767
Comments
This is also something that comes up again and again on client builds. The ability to control which settings get presented to the editor via a mechanism like In a way, I see this setting as similar to the The way this could be done without refactoring the width setting to be a block support like all the other settings, would be by using |
This allows theme developers to manage support for the Width panel on the Button block using theme.json. We toggle visibility for the panel in Button's edit component using useSetting to grab the new setting. Appropriate entries have been added for the new setting to both the theme.json schema as well as the core-blocks and theme-json-living documentation. Fixes WordPress#38767. See WordPress#19796
Hi everyone, I wanted to revisit this issue as it seems to still be relevant for many developers and clients dealing with tailored themes. After reviewing the previous comments and updates, it looks like there hasn’t been a concrete resolution or a native mechanism to disable certain block settings like the Width panel for the core/button block in theme.json. I see there was some progress with PR #42079 in 2022 to add support for toggling Width settings, but from what I can tell, it hasn't yet made its way into core. I wanted to check if there are any new global settings or updates that might now allow for this functionality, or if this is still being tracked under useSetting('layout.width') as mentioned earlier. I’d love to hear if anyone has found workarounds or other methods to manage this in the meantime. If this still needs a formal solution, I’d be happy to help with testing or contributing to the discussion on a potential fix. Do we think that revisiting the initial proposal in PR #42079 is the best way forward, or are there newer approaches in Gutenberg that could help address this issue? Looking forward to hearing your thoughts! cc: @roseg43 , @bph , @jordesign , @skorasaurus , @fabiankaegy , @Mamaduka , @vyskoczilova |
Hello everyone, I would like to seek clarification on the following points regarding this ticket:
Similarly, if you want to disable the padding setting for the Core Paragraph block, it would look like this:
|
@karthick-murugan Thanks for picking it up, although the WP is in difficult times now.
|
Thanks for your feedback @vyskoczilova I have checked the following code to effectively disable specific settings for default blocks in a custom theme:
This code allows for selective disabling of unnecessary settings for various default blocks, such as the Paragraph, Button, Heading, and Quote blocks. By defining the blocks and their respective settings to be disabled in the disabledBlocks object, developers can easily customize the editor experience in their themes. To implement this, simply include the code in a separate JavaScript file or within your theme's custom JavaScript file. Please note that this code does not affect the button width settings, which come from the edit.js file in the InspectorControls, as they are not included in the block.json file. Therefore, I have created a separate PR to address that specific issue. I would greatly appreciate any feedback or suggestions from fellow core developers regarding this implementation. Thank you for your time! |
Thank you for the JavaScript and your efforts on the InspectorControls issue. However, I still view this as a temporary solution. Ideally, the configuration should be managed in the theme.json file, and setting it to false seems logical. Additionally, maintaining this code and tracking down where and how the feature is disabled could become quite time-consuming. This should be a default part of the theme.json instead of a workaround in JavaScript. This is where using a simple FSE/Gutenberg theme can become frustrating. There are too many touchpoints to manage, and it is often unclear which interface to use for enabling or disabling features, whether it’s theme.json, PHP, or JavaScript. |
Thanks @vyskoczilova for your feedback. In the context of customising block styles via theme.json, we can see that using a JSON object like the one below, we can disable or modify various options in the "Styles" tab for specific blocks:
Using the above json object in current active theme's theme.json file, we can disable the following. Similarly we can follow the same approach for all of the default blocks for the options that are not needed by theme authors in the "Styles" tab. 1. Paragraph: The "Styles" tab in the block editor allows users to configure the visual styling of blocks (such as typography, color, spacing, borders, etc.). Using the theme.json file, theme developers can customize and disable all options within the "Styles" tab. On the other hand, the "Settings" tab contains controls for block behavior, such as alignment options, toggle features (like enabling or disabling captions), and other block-specific functionalities. Unlike the "Styles" tab, the options in the "Settings" tab are not configurable via theme.json or block.json. The reason for this is that "Settings" controls are more user-specific and pertain to the content or functional aspect of blocks, rather than their appearance. These settings allow the editor to adjust the behavior of the block while editing content, and they are context-sensitive to how the block is used. So for Settings tab of all default blocks, need some ideas to move forward. |
What problem does this address?
Please, think about tailor-made themes that are coded from design to WordPress.
We need to control block settings being to able to turn off user's modifications like Layout and Width panels (and other "new features"). There is no way to turn them off and they are causing many headaches - clients call you "why it doesn't work in our theme", but the designer hasn't prepared those options. And the reason why this happens is that the new WordPress is released. I mean - I want to use the latest release, but I don't want to use certain features that are not ready in design.
I haven't found a way to do it.
Looks like it's related to #19796 that was never solved.
What is your proposed solution?
Add theme.json settings that will easily allow setting panels off - in settings for all blocks, in blocks for separate blocks. I believe that theme.json should be the place for all edits. That would enable to quickly disable unwanted features and at the same time keep latest WP version.
The text was updated successfully, but these errors were encountered: