@@ -21,41 +21,41 @@ final class CPT {
2121 *
2222 * @var array
2323 */
24- public $ post_meta_array = array () ;
24+ public $ post_meta_array = [] ;
2525 /**
2626 * Rewrite
2727 *
2828 * @var array
2929 */
30- public $ rewrite = array () ;
30+ public $ rewrite = [] ;
3131
3232 /**
3333 * Constructor
3434 */
3535 public function __construct () {
36- $ args = array (
37- 'post_meta_array ' => array ( 'meta ' , 'settings ' ) ,
38- 'rewrite ' => array (
36+ $ args = [
37+ 'post_meta_array ' => [ 'meta ' , 'settings ' ] ,
38+ 'rewrite ' => [
3939 'template_path ' => 'test.php ' ,
4040 'slug ' => 'test ' ,
4141 'var ' => Plugin::$ snake . '_test ' ,
42- ) ,
43- ) ;
42+ ] ,
43+ ] ;
4444 $ this ->post_meta_array = $ args ['post_meta_array ' ];
45- $ this ->rewrite = $ args ['rewrite ' ] ?? array () ;
45+ $ this ->rewrite = $ args ['rewrite ' ] ?? [] ;
4646
47- \add_action ( 'init ' , array ( $ this , 'init ' ) );
47+ \add_action ( 'init ' , [ $ this , 'init ' ] );
4848
4949 if ( ! empty ( $ args ['post_meta_array ' ] ) ) {
50- \add_action ( 'rest_api_init ' , array ( $ this , 'add_post_meta ' ) );
50+ \add_action ( 'rest_api_init ' , [ $ this , 'add_post_meta ' ] );
5151 }
5252
53- \add_action ( 'load-post.php ' , array ( $ this , 'init_metabox ' ) );
54- \add_action ( 'load-post-new.php ' , array ( $ this , 'init_metabox ' ) );
53+ \add_action ( 'load-post.php ' , [ $ this , 'init_metabox ' ] );
54+ \add_action ( 'load-post-new.php ' , [ $ this , 'init_metabox ' ] );
5555
5656 if ( ! empty ( $ args ['rewrite ' ] ) ) {
57- \add_filter ( 'query_vars ' , array ( $ this , 'add_query_var ' ) );
58- \add_filter ( 'template_include ' , array ( $ this , 'load_custom_template ' ) , 99 );
57+ \add_filter ( 'query_vars ' , [ $ this , 'add_query_var ' ] );
58+ \add_filter ( 'template_include ' , [ $ this , 'load_custom_template ' ] , 99 );
5959 }
6060 }
6161
@@ -77,7 +77,7 @@ public function init(): void {
7777 */
7878 public static function register_cpt (): void {
7979
80- $ labels = array (
80+ $ labels = [
8181 'name ' => \esc_html__ ( 'my-app ' , 'wp_react_plugin ' ),
8282 'singular_name ' => \esc_html__ ( 'my-app ' , 'wp_react_plugin ' ),
8383 'add_new ' => \esc_html__ ( 'Add new ' , 'wp_react_plugin ' ),
@@ -109,8 +109,8 @@ public static function register_cpt(): void {
109109 'item_reverted_to_draft ' => \esc_html__ ( 'my-app reverted to draft ' , 'wp_react_plugin ' ),
110110 'item_scheduled ' => \esc_html__ ( 'my-app scheduled ' , 'wp_react_plugin ' ),
111111 'item_updated ' => \esc_html__ ( 'my-app updated ' , 'wp_react_plugin ' ),
112- ) ;
113- $ args = array (
112+ ] ;
113+ $ args = [
114114 'label ' => \esc_html__ ( 'my-app ' , 'wp_react_plugin ' ),
115115 'labels ' => $ labels ,
116116 'description ' => '' ,
@@ -131,13 +131,13 @@ public static function register_cpt(): void {
131131 'menu_position ' => 6 ,
132132 'menu_icon ' => 'dashicons-store ' ,
133133 'capability_type ' => 'post ' ,
134- 'supports ' => array ( 'title ' , 'editor ' , 'thumbnail ' , 'custom-fields ' , 'author ' ) ,
135- 'taxonomies ' => array () ,
134+ 'supports ' => [ 'title ' , 'editor ' , 'thumbnail ' , 'custom-fields ' , 'author ' ] ,
135+ 'taxonomies ' => [] ,
136136 'rest_controller_class ' => 'WP_REST_Posts_Controller ' ,
137- 'rewrite ' => array (
137+ 'rewrite ' => [
138138 'with_front ' => true ,
139- ) ,
140- ) ;
139+ ] ,
140+ ] ;
141141
142142 \register_post_type ( 'my-app ' , $ args );
143143 }
@@ -150,11 +150,11 @@ public function add_post_meta(): void {
150150 \register_meta (
151151 'post ' ,
152152 Plugin::$ snake . '_ ' . $ meta_key ,
153- array (
153+ [
154154 'type ' => 'string ' ,
155155 'show_in_rest ' => true ,
156156 'single ' => true ,
157- )
157+ ]
158158 );
159159 }
160160 }
@@ -163,9 +163,9 @@ public function add_post_meta(): void {
163163 * Meta box initialization.
164164 */
165165 public function init_metabox (): void {
166- \add_action ( 'add_meta_boxes ' , array ( $ this , 'add_metabox ' ) );
167- \add_action ( 'save_post ' , array ( $ this , 'save_metabox ' ) , 10 , 2 );
168- \add_filter ( 'rewrite_rules_array ' , array ( $ this , 'custom_post_type_rewrite_rules ' ) );
166+ \add_action ( 'add_meta_boxes ' , [ $ this , 'add_metabox ' ] );
167+ \add_action ( 'save_post ' , [ $ this , 'save_metabox ' ] , 10 , 2 );
168+ \add_filter ( 'rewrite_rules_array ' , [ $ this , 'custom_post_type_rewrite_rules ' ] );
169169 }
170170
171171 /**
@@ -174,11 +174,11 @@ public function init_metabox(): void {
174174 * @param string $post_type Post type.
175175 */
176176 public function add_metabox ( string $ post_type ): void {
177- if ( in_array ( $ post_type , array ( Plugin::$ kebab ) ) ) {
177+ if ( in_array ( $ post_type , [ Plugin::$ kebab ] ) ) {
178178 \add_meta_box (
179179 Plugin::$ kebab . '-metabox ' ,
180180 __ ( 'My App ' , 'wp_react_plugin ' ),
181- array ( $ this , 'render_meta_box ' ) ,
181+ [ $ this , 'render_meta_box ' ] ,
182182 $ post_type ,
183183 'advanced ' ,
184184 'high '
0 commit comments