33 *
44 * Dynamic commands for user-created custom post types in Secure Custom Fields.
55 * This file generates navigation commands for each registered post type that
6- * the current user has access to, creating both "View All" and "Add New" commands.
6+ * the current user has access to, creating "View All", "Add New", and "Edit " commands.
77 *
88 * Post type data is provided via acf.data.customPostTypes, which is populated
99 * by the PHP side after capability checks ensure the user has appropriate access.
@@ -77,7 +77,7 @@ const registerPostTypeCommands = () => {
7777 'create' ,
7878 'content' ,
7979 postType . name ,
80- ... ( postType . label ? [ postType . label ] : [ ] ) ,
80+ postType . label ,
8181 ] ,
8282 callback : ( { close } ) => {
8383 document . location = addQueryArgs ( adminUrl + 'post-new.php' , {
@@ -86,6 +86,31 @@ const registerPostTypeCommands = () => {
8686 close ( ) ;
8787 } ,
8888 } ) ;
89+
90+ // Register "Edit Post Type" command for registered CPTs
91+ commandStore . registerCommand ( {
92+ name : `scf/edit-${ postType . name } ` ,
93+ label : sprintf ( __ ( 'Edit post type: %s' , 'secure-custom-fields' ) , postType . label ) ,
94+ icon : createElement ( Icon , { icon : 'edit' } ) ,
95+ context : 'admin' ,
96+ description : sprintf ( __ ( 'Edit the %s post type settings' , 'secure-custom-fields' ) , postType . label ) ,
97+ keywords : [
98+ 'edit' ,
99+ 'modify' ,
100+ 'post type' ,
101+ 'cpt' ,
102+ 'settings' ,
103+ postType . name ,
104+ postType . label ,
105+ ] ,
106+ callback : ( { close } ) => {
107+ document . location = addQueryArgs ( adminUrl + 'post.php' , {
108+ post : postType . id ,
109+ action : 'edit'
110+ } ) ;
111+ close ( ) ;
112+ } ,
113+ } ) ;
89114 } ) ;
90115} ;
91116
0 commit comments