66 */
77class Register {
88
9+ const POST_TYPE = 'wpqt-task ' ;
10+
911 /**
1012 * Sets up all of the functionality to run in the proper hook
1113 */
@@ -24,6 +26,10 @@ public function setup() {
2426 // Performance improvement for VIP
2527 add_filter ( 'wpcom_async_transition_post_status_schedule_async ' , [ $ this , 'disable_post_transition ' ], 10 , 2 );
2628
29+ if ( true === Utils::debug_on () ) {
30+ add_action ( 'admin_menu ' , [ $ this , 'hide_admin_ui ' ] );
31+ }
32+
2733 }
2834
2935 /**
@@ -70,7 +76,7 @@ public function register_taxonomy() {
7076 'graphql_plural_name ' => 'queues ' ,
7177 ];
7278
73- register_taxonomy ( 'task-queue ' , ' wpqt-task ' , $ args );
79+ register_taxonomy ( 'task-queue ' , self :: POST_TYPE , $ args );
7480
7581 }
7682
@@ -119,7 +125,7 @@ public function register_post_type() {
119125 'graphql_plural_name ' => 'tasks ' ,
120126 ];
121127
122- register_post_type ( ' wpqt-task ' , $ args );
128+ register_post_type ( self :: POST_TYPE , $ args );
123129
124130 }
125131
@@ -137,7 +143,7 @@ public function blacklist_post_type( $post_types ) {
137143 $ post_types = [];
138144 }
139145
140- $ post_types [] = ' wpqt-task ' ;
146+ $ post_types [] = self :: POST_TYPE ;
141147
142148 return $ post_types ;
143149 }
@@ -157,12 +163,24 @@ public function disable_post_transition( $value, $args ) {
157163 return $ value ;
158164 }
159165
160- if ( ' wpqt-task ' === get_post_type ( absint ( $ args ['post_id ' ] ) ) ) {
166+ if ( self :: POST_TYPE === get_post_type ( absint ( $ args ['post_id ' ] ) ) ) {
161167 $ value = false ;
162168 }
163169
164170 return $ value ;
165171
166172 }
167173
174+ /**
175+ * Hides the admin UI when the plugin is in debug mode from non-admins
176+ *
177+ * @access public
178+ * @return void
179+ */
180+ public function hide_admin_ui () {
181+ if ( ! current_user_can ( 'manage_options ' ) ) {
182+ remove_menu_page ( 'edit.php?post_type= ' . self ::POST_TYPE );
183+ }
184+ }
185+
168186}
0 commit comments