Editor: Add user preference toggle for content-only pattern sections#75459
Editor: Add user preference toggle for content-only pattern sections#75459fabiankaegy wants to merge 2 commits intotrunkfrom
Conversation
…ntent-only pattern sections Introduce a new `contentOnlyPatternSections` block editor setting (default `true`) that themes and plugins can set to `false` via the `block_editor_settings_all` PHP filter to globally disable content-only editing mode for unsynced pattern sections. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a toggle in Preferences > General > Interface that lets users disable content-only pattern editing. Follows the focusMode pattern where the PHP filter can force-disable the feature, and the user preference controls the toggle otherwise. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
There was a problem hiding this comment.
Pull request overview
Adds a user-facing Preferences toggle for the contentOnlyPatternSections editor setting (introduced in stacked PR #75457), allowing users to enable/disable content-only editing for unsynced pattern sections unless a PHP-level setting force-disables it.
Changes:
- Registers
contentOnlyPatternSections: trueas a default user preference for bothedit-siteandedit-post. - Adds a “Content-only pattern editing” toggle to Preferences > General > Interface, hidden when the server forces the feature off.
- Wires the block editor setting to reflect the user preference while respecting the PHP force-disable.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/editor/src/components/provider/use-block-editor-settings.js | Reads the user preference and merges it with server settings to produce final block editor settings. |
| packages/editor/src/components/preferences-modal/index.js | Adds a new preferences toggle and hides it when server settings force-disable the feature. |
| packages/edit-site/src/index.js | Registers default user preference for site editor. |
| packages/edit-post/src/index.js | Registers default user preference for post editor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| contentOnlyPatternSections && | ||
| ! forceDisableContentOnlyPatternSections, |
There was a problem hiding this comment.
contentOnlyPatternSections is combined as contentOnlyPatternSections && ! forceDisableContentOnlyPatternSections. If the user preference is undefined (e.g. in contexts where no default is registered, like native edit-post), this expression short-circuits to undefined even when PHP forces the setting to false, which defeats the “force-disable” behavior (downstream logic treats undefined as enabled via !== false). Consider flipping the logic so the force-disable check is evaluated first and the preference defaults to enabled (e.g. treat undefined as true).
| contentOnlyPatternSections && | |
| ! forceDisableContentOnlyPatternSections, | |
| ! forceDisableContentOnlyPatternSections && | |
| contentOnlyPatternSections !== false, |
|
Size Change: +146 B (0%) Total Size: 3.02 MB
ℹ️ View Unchanged
|
|
Thanks for the PR. My feedback here would be mostly the same to what I shared on the other one. As far as the precise place for where a toggle could sit, I think there's some longer term thinking going on in this PR which is extremely relevant, because it re-casts options to be per-editor-type preferences. In that sense if some of the motivation here is driven by "this is useful in site editor but I don't want it in the post editor", there's a framework there that might resonate. In the meantime, how would you feel about moving this preference under the "Blocks" tab? There's already an "Inserter" related option there, and this feels more related to that section than "General". |
Note
This PR is stacked on top of #75457
What?
Part of #71573
Follow up to #75457
Adds a user preference toggle in the editor Preferences modal for the
contentOnlyPatternSectionssetting introduced in the parent PR.Why?
The parent PR added the
contentOnlyPatternSectionsblock editor setting, controllable only via PHP filter. This PR gives users a UI toggle to control the behavior themselves, following the same pattern used byfocusMode/ Spotlight mode — where a PHP filter can force-disable the feature, but otherwise the user preference controls it.How?
contentOnlyPatternSections: trueas a default user preference in bothedit-siteandedit-postviapreferencesStore.setDefaults.use-block-editor-settings.js, reads the user preference and combines it with the PHP-level setting. If the PHP filter setscontentOnlyPatternSectionstofalse, it force-disables the feature regardless of the user preference.Testing Instructions
contentOnlyPatternSectionstofalsein the editor settings, reload, and verify the toggle is hidden and patterns are fully editable regardless of the stored preference.Testing Instructions for Keyboard
CleanShot.2026-02-12.at.10.16.12.mp4