@@ -37,26 +37,23 @@ const registerPostTypeCommands = () => {
37
37
const postTypes = window . acf . data . customPostTypes ;
38
38
39
39
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 ) {
42
42
return ;
43
43
}
44
44
45
- const pluralLabel = postType . label || postType . name ;
46
- const singularLabel = postType . singular_label || pluralLabel ;
47
-
48
45
// Register "View All" command for this post type
49
46
commandStore . registerCommand ( {
50
47
name : `scf/cpt-${ postType . name } ` ,
51
48
label : sprintf (
52
49
__ ( 'All %s' , 'secure-custom-fields' ) ,
53
- pluralLabel
50
+ postType . label
54
51
) ,
55
52
icon : createElement ( Icon , { icon : 'admin-page' } ) ,
56
53
context : 'admin' ,
57
54
description : sprintf (
58
55
__ ( 'All %s' , 'secure-custom-fields' ) ,
59
- pluralLabel
56
+ postType . label
60
57
) ,
61
58
keywords : [
62
59
'post type' ,
@@ -78,13 +75,13 @@ const registerPostTypeCommands = () => {
78
75
name : `scf/new-${ postType . name } ` ,
79
76
label : sprintf (
80
77
__ ( 'Add %s' , 'secure-custom-fields' ) ,
81
- singularLabel
78
+ postType . singular_label
82
79
) ,
83
80
icon : createElement ( Icon , { icon : 'plus' } ) ,
84
81
context : 'admin' ,
85
82
description : sprintf (
86
83
__ ( 'Add %s' , 'secure-custom-fields' ) ,
87
- singularLabel
84
+ postType . singular_label
88
85
) ,
89
86
keywords : [
90
87
'add' ,
0 commit comments