Repository navigation
Flexible Content: group layouts by category in the Add Layout menu - #573
Open
faisalahammad wants to merge 1 commit into
Open
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
- Add an optional "Category" setting to each layout in the field group editor. - Group the "Add Layout" menu by category, with a small heading per group. - Layouts without a category stay at the top, so existing menus look the same. - Categories follow the order of their first layout, layouts keep their order. - Translate the category like the layout label. - Add PHPUnit tests, schema description and docs. Long layout lists were hard to scan because the menu was one flat list. Fixes WordPress#570
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @Faton1995. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With many Flexible Content layouts, the "Add Layout" menu is one long flat list and related layouts are hard to find. This adds an optional "Category" setting per layout and groups the menu by it.
What changed
class-acf-field-flexible-content.phpcategorylayout setting (default'') inget_valid_layout(), so older layouts get the key too.translate_field()translates the category like the label.FlexibleContent/Render.phpadd_layout_menu()groups layouts by category. Layouts without a category stay at the top, so existing menus look exactly the same.<li class="acf-fc-popup-category">heading, escaped withesc_html(). No JS change was needed: the popup JS only targets[data-layout], so min/max badges, disabled state and clicks skip the heading.The optional search input from the issue is not part of this PR, it can be a follow-up.
How to test
categoryis kept.PHPUnit tests added for the default value, the flat menu, grouping order and escaping. Full PHP suite and Jest suite pass.
Closes #570
Use of AI Tools
Claude Code was used to help write the change and tests. I reviewed and tested the changes before submitting.