Skip to content

Used labels provided by the rest API on taxonomies.#4767

Merged
jorgefilipecosta merged 1 commit intomasterfrom
fix/taxonomies-labels
Feb 7, 2018
Merged

Used labels provided by the rest API on taxonomies.#4767
jorgefilipecosta merged 1 commit intomasterfrom
fix/taxonomies-labels

Conversation

@jorgefilipecosta
Copy link
Copy Markdown
Member

This uses labels provided by the rest API on taxonomies. Until now we were using hardcoded values.
This made labels like "Add new gender" on custom taxonomies useless and instead "Add new term" was used.

How Has This Been Tested?

Verify categories and tags work as expected.
Add a new taxonomy with custom labels and verify correct labels are used. (easily done with a plugin like Custom Post Type UI)

@jorgefilipecosta jorgefilipecosta added the [Type] Enhancement A suggestion for improvement. label Jan 30, 2018
@jorgefilipecosta jorgefilipecosta self-assigned this Jan 30, 2018
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: The array notation for the get function is a little bit more performant per @aduth's advice ;)

get( this.props.taxonomy, [ 'data', 'labels', 'singular_name' ] )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use - %s - here? Is this how it's done in the old editor?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly I ported the behavior from the old editor.

@youknowriad
Copy link
Copy Markdown
Contributor

On a regular post, the panels are not showing up. Am I doing something wrong?

screen shot 2018-01-31 at 12 31 36

@jorgefilipecosta
Copy link
Copy Markdown
Member Author

On a regular post, the panels are not showing up. Am I doing something wrong?

That's strange I'm not being able to replicate this problem. I will look further to check if I find the cause.

const noParentOption = slug === 'category' ? _x( 'None', 'category' ) : _x( 'None', 'term' );
const newTermSubmitLabel = slug === 'category' ? __( 'Add Category' ) : __( 'Add Term' );
const { labels } = taxonomy.data;
const newTermButtonLabel = labels.add_new_item;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want a fallback value to be shown in the case that the data is not loaded yet?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aduth, fallback labels were added.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/taxonomies-labels branch 2 times, most recently from 9fec641 to d983b3a Compare February 7, 2018 13:20
@jorgefilipecosta
Copy link
Copy Markdown
Member Author

Hi @youknowriad, this suffered some changes, can you confirm if in your tests taxonomies are still not being shown?

Copy link
Copy Markdown
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work well now 👍

@youknowriad
Copy link
Copy Markdown
Contributor

(you might want to check the tests)

Until now we were using hardcoded values.
@jorgefilipecosta jorgefilipecosta merged commit 7713486 into master Feb 7, 2018
@jorgefilipecosta jorgefilipecosta deleted the fix/taxonomies-labels branch February 7, 2018 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants