feat: add support for displaying tags as labels#4381
feat: add support for displaying tags as labels#4381jason10lee wants to merge 14 commits intotrunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds functionality to display selected post tags as labels, similar to how categories are displayed. The feature includes an admin interface for enabling tags as labels with optional custom label text, and works in conjunction with a companion PR in the newspack-theme repository.
- Added a new Tag_Labels class that manages tag label settings via term meta
- Created admin UI fields to enable tags as labels and customize label text
- Added helper methods for themes to retrieve tag labels for display
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 14 comments.
| File | Description |
|---|---|
| src/other-scripts/tag-labels/index.js | Adds jQuery-based client-side logic to enable/disable the label flag input based on checkbox state |
| includes/tag-labels/class-tag-labels.php | Implements the core Tag_Labels class with admin UI, data storage, and helper methods for retrieving tag labels |
| includes/class-newspack.php | Includes the new tag-labels class file to integrate it into the plugin |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
leogermani
left a comment
There was a problem hiding this comment.
This is looking good Jason, thanks for the work! I left some minor comments in the code.
I'll tag @thomasguillot and add a needs-design review for him to have a look and answer your questions around presentation. I think it should follow what Sponsors do as much as possible (which is to display the label above the title). Thomas, please also share your thought on how we name and present this feature in the UI. Is "Labels" a good name?
I also have an existencial question I'll copy for @laurelfulford : Since this is very tied to the theme, should this whole thing live in the theme instead? WDYT?
How come we don't have the checkbox and the label flag field when first creating? I must admit I thought I hadn't switched branch and it wasn't working at first. |
Thanks, @thomasguillot! That was a potential issue I flagged, and based on your and @leogermani's comments, I think it'll be worth making those options visible on creation. |
|
"Labels" works well. It's intuitive, distinct from the existing "Tags" terminology, and commonly understood in editorial contexts I think. For the fields, I'd suggest: (ae531b4) Checkbox: "Display as label" with help text: Show this tag as a highlighted label wherever posts are displayed. |
All good, and I'll be using the tweaks you made to the dependent field toggles for the |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
All Submissions:
Changes proposed in this Pull Request:
This PR is one of a set that adds the ability to display selected tags as labels. Changes live in the
feat/tag-labelstopic branch on the newspack-blocks, newspack-plugin, and newspack-theme projects.See also: Automattic/newspack-theme#2613
See also: Automattic/newspack-blocks#2282
In non-singular context (as part of a Content Loop block, for example), the tag label will show up in front of the headline.In singular context (on the individual post page, for example), the tag label will show up with the category label.By default, the text of the tag label will be the same as the tag name. Optionally, the label text can be customized (e.g., to something shorter and more suitable for use as a label).Labels will appear above the headline, after any category or sponsorship labels.
By default, the text of the tag label will be the same as the tag name. Optionally, the label text can be customized (e.g., to something shorter and more suitable for use as a label). Additionally, the label color can be customized in the Newspack Theme customizer.
Addresses NPPD-383: "Breaking News" or "Developing" Label.
How to test the changes in this Pull Request:
Basic operation:
Multiple labels:
Custom label text (flag):
Custom label color:
Other information: