Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose pluralised form of entity label #37828

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ async function loadPostTypeEntities() {
baseURLParams: { context: 'edit' },
name,
label: postType.labels.singular_name,
labelPlural: postType.labels.name,
Copy link
Contributor

Choose a reason for hiding this comment

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

the plural form is already available in postType.name, I don't mind having it here but I think the main problem right now is that the singular label is not available in the request using the "view" context. (The plural is available in all contexts)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeh agree. That's why I don't think we could merge a PR like this until the Types API returns more label information for view context requests.

Honestly I think it should be possible and feasible given that labels are not a sensitive piece of data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@spacedmonkey Do you see it as achievable that we could get the Types API endpoint to return full labels information about the Post Type for both view and edit contexts?

transientEdits: {
blocks: true,
selection: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ export default function EntityTypeList( {
select( coreStore ).getEntity( firstRecord.kind, firstRecord.name ),
[ firstRecord.kind, firstRecord.name ]
);

const { name } = firstRecord;
const entityLabel =
name === 'wp_template_part'
? _n( 'Template Part', 'Template Parts', list.length )
: entity.label;
const entityLabel = list.length > 1 ? entity.labelPlural : entity.label;
// Set description based on type of entity.
const description = getEntityDescription( name, list.length );

Expand Down