gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

hierarchical-term-selector not using modified `add_new_item` label

Open krisgale-zz opened this issue 8 years ago • 13 comments

the bug

Categories meta box not respecting changes made via taxonomy_labels_category, "Add new category" always used

to reproduce

implement taxonomy_labels_category and change default labeling for category taxonomy, go to edit a post, see "Add new category" shown in gutenberg-i-fied Categories meta box.

expected behavior

for "Add new category" label to use add_new_item label property in modified category taxonomy

image

krisgale-zz avatar Aug 03 '18 14:08 krisgale-zz

We're using new_item_name for this label, which seems more appropriate to me for the input's label.

The link is using add_new_item.

I think that's correct, so I'm closing, let's reopen if it's not.

youknowriad avatar Aug 08 '18 10:08 youknowriad

that's correct, but i feel this logic is not:

https://github.com/WordPress/gutenberg/blob/master/packages/editor/src/components/post-taxonomies/hierarchical-term-selector.js#L251

my specific use case was to re-label the built-in 'category' taxonomy, and saw the above-screencapped end result.

krisgale-zz avatar Aug 09 '18 02:08 krisgale-zz

In theory, this code gives priority to the labels specified in the register_taxonomy call. This logic is just a fallback in case there's no defined label. Is this your case?

youknowriad avatar Aug 09 '18 09:08 youknowriad

i definitely had set both new_item_name and add_new_item in a hook for taxonomy_labels_{$taxonomy} (taxonomy_labels_category) when i captured the above image...

krisgale-zz avatar Aug 09 '18 14:08 krisgale-zz

I'm reopening to investigate more, thanks

youknowriad avatar Aug 09 '18 14:08 youknowriad

@youknowriad is labelWithFallback necessary? does WP not set/provide defaults for taxonomy labels?

krisgale-zz avatar Aug 12 '18 23:08 krisgale-zz

@krisgale Some custom taxonomies don't provide labels.

youknowriad avatar Aug 13 '18 07:08 youknowriad

@youknowriad which is why wordpress sets defaults for all labels https://github.com/WordPress/WordPress/blob/master/wp-includes/taxonomy.php#L548

krisgale-zz avatar Aug 13 '18 15:08 krisgale-zz

Good observation, Maybe it's useless than :), we'll have to check if the REST API sends these fallback labels (even if unchanged). Feel free to PR it

youknowriad avatar Aug 13 '18 15:08 youknowriad

Adding this case to this issue, as I think it's probably an instance of the same basic issue. Noticed today custom taxonomies are using the generic "term" verbiage for all the various labels instead of the specific singular/plural labels set in the taxonomy arguments. This problem doesn't exist with the classic editor. Case in point, everything uses "speaker"/"speakers" when it's set to the classic editor. capture

fienen avatar Aug 24 '18 20:08 fienen

I confirm the above, I'd also expect the editor to utilize 'add_new_item' and other labels registered with a custom taxonomy.

pshemek avatar Aug 29 '18 17:08 pshemek

cc @jorgefilipecosta in case you have more context here.

youknowriad avatar Aug 29 '18 17:08 youknowriad

did a fresh install of wp and guten on a vm today and i plan to make some time tomorrow / this weekend to fork g7g to see if removing the duplication of labels in js results in the desired behavior (only using data provided by wp’s rest api)

krisgale-zz avatar Aug 30 '18 23:08 krisgale-zz