Skip to content

Commit 3b547c3

Browse files
committed
Remove redundant client-side label calculation
1 parent ff6bb99 commit 3b547c3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

assets/src/js/commands/custom-post-type-commands.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,23 @@ const registerPostTypeCommands = () => {
3737
const postTypes = window.acf.data.customPostTypes;
3838

3939
postTypes.forEach( ( postType ) => {
40-
// Skip invalid post types
41-
if ( ! postType?.name ) {
40+
// Skip invalid post types or those missing required labels
41+
if ( ! postType?.name || ! postType?.label || ! postType?.singular_label ) {
4242
return;
4343
}
4444

45-
const pluralLabel = postType.label || postType.name;
46-
const singularLabel = postType.singular_label || pluralLabel;
47-
4845
// Register "View All" command for this post type
4946
commandStore.registerCommand( {
5047
name: `scf/cpt-${ postType.name }`,
5148
label: sprintf(
5249
__( 'All %s', 'secure-custom-fields' ),
53-
pluralLabel
50+
postType.label
5451
),
5552
icon: createElement( Icon, { icon: 'admin-page' } ),
5653
context: 'admin',
5754
description: sprintf(
5855
__( 'All %s', 'secure-custom-fields' ),
59-
pluralLabel
56+
postType.label
6057
),
6158
keywords: [
6259
'post type',
@@ -78,13 +75,13 @@ const registerPostTypeCommands = () => {
7875
name: `scf/new-${ postType.name }`,
7976
label: sprintf(
8077
__( 'Add %s', 'secure-custom-fields' ),
81-
singularLabel
78+
postType.singular_label
8279
),
8380
icon: createElement( Icon, { icon: 'plus' } ),
8481
context: 'admin',
8582
description: sprintf(
8683
__( 'Add %s', 'secure-custom-fields' ),
87-
singularLabel
84+
postType.singular_label
8885
),
8986
keywords: [
9087
'add',

0 commit comments

Comments
 (0)