@@ -64,30 +64,30 @@ discard block |
||
64 | 64 | * @param Meta_Box $meta_box |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - public function register( Meta_Box $meta_box ): void { |
|
67 | + public function register(Meta_Box $meta_box): void { |
|
68 | 68 | |
69 | - if ( ! $this->validator->verify_meta_box( $meta_box ) ) { |
|
69 | + if ( ! $this->validator->verify_meta_box($meta_box)) { |
|
70 | 70 | throw new Exception( |
71 | 71 | sprintf( |
72 | 72 | 'Failed validating meta box model(%s) with errors: %s', |
73 | - get_class( $meta_box ), |
|
74 | - join( ', ', $this->validator->get_errors() ) |
|
73 | + get_class($meta_box), |
|
74 | + join(', ', $this->validator->get_errors()) |
|
75 | 75 | ) |
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Set the view using View, if not traditional callback supplied and a defined template. |
80 | - if ( ! \is_callable( $meta_box->view ) && is_string( $meta_box->view_template ) ) { |
|
81 | - $meta_box = $this->set_view_callback_from_renderable( $meta_box ); |
|
80 | + if ( ! \is_callable($meta_box->view) && is_string($meta_box->view_template)) { |
|
81 | + $meta_box = $this->set_view_callback_from_renderable($meta_box); |
|
82 | 82 | } |
83 | - if ( \is_callable( $meta_box->view ) ) { |
|
84 | - $meta_box = $this->set_view_callback_from_callable( $meta_box ); |
|
83 | + if (\is_callable($meta_box->view)) { |
|
84 | + $meta_box = $this->set_view_callback_from_callable($meta_box); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Add meta_box to loader. |
88 | 88 | $this->loader->action( |
89 | 89 | 'add_meta_boxes', |
90 | - function() use ( $meta_box ) : void { |
|
90 | + function() use ($meta_box) : void { |
|
91 | 91 | \add_meta_box( |
92 | 92 | $meta_box->key, |
93 | 93 | $meta_box->label, |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | // Deffer adding meta box hooks until we can asses the current screen. |
104 | 104 | $this->loader->action( |
105 | 105 | 'current_screen', |
106 | - function() use ( $meta_box ) { |
|
106 | + function() use ($meta_box) { |
|
107 | 107 | // If we have any hook calls, add them to the loader. |
108 | - if ( $this->is_active( $meta_box ) && ! empty( $meta_box->actions ) ) { |
|
109 | - foreach ( $meta_box->actions as $handle => $hook ) { |
|
110 | - add_action( (string) $handle, $hook['callback'], $hook['priority'], $hook['params'] ); |
|
108 | + if ($this->is_active($meta_box) && ! empty($meta_box->actions)) { |
|
109 | + foreach ($meta_box->actions as $handle => $hook) { |
|
110 | + add_action((string) $handle, $hook['callback'], $hook['priority'], $hook['params']); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
@@ -121,21 +121,21 @@ discard block |
||
121 | 121 | * @param \PinkCrab\Registerables\Meta_Box $meta_box |
122 | 122 | * @return \PinkCrab\Registerables\Meta_Box |
123 | 123 | */ |
124 | - protected function set_view_callback_from_callable( Meta_Box $meta_box ): Meta_Box { |
|
124 | + protected function set_view_callback_from_callable(Meta_Box $meta_box): Meta_Box { |
|
125 | 125 | |
126 | 126 | // Get the current view callback. |
127 | 127 | $current_callback = $meta_box->view; |
128 | 128 | |
129 | 129 | $meta_box->view( |
130 | - function ( \WP_Post $post, array $args ) use ( $meta_box, $current_callback ) { |
|
130 | + function(\WP_Post $post, array $args) use ($meta_box, $current_callback) { |
|
131 | 131 | |
132 | 132 | // Set the view args |
133 | 133 | $args['args']['post'] = $post; |
134 | - $args['args'] = $this->filter_view_args( $meta_box, $post, $args['args'] ); |
|
134 | + $args['args'] = $this->filter_view_args($meta_box, $post, $args['args']); |
|
135 | 135 | |
136 | 136 | // Render the callback. |
137 | - if ( \is_callable( $current_callback ) ) { |
|
138 | - call_user_func( $current_callback, $post, $args ); |
|
137 | + if (\is_callable($current_callback)) { |
|
138 | + call_user_func($current_callback, $post, $args); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | ); |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | * @param \PinkCrab\Registerables\Meta_Box $meta_box |
150 | 150 | * @return \PinkCrab\Registerables\Meta_Box |
151 | 151 | */ |
152 | - protected function set_view_callback_from_renderable( Meta_Box $meta_box ): Meta_Box { |
|
152 | + protected function set_view_callback_from_renderable(Meta_Box $meta_box): Meta_Box { |
|
153 | 153 | |
154 | 154 | // Create View(View) |
155 | - $view = $this->container->create( View::class ); |
|
156 | - if ( is_null( $view ) || ! is_a( $view, View::class ) ) { |
|
157 | - throw new Exception( 'View not defined' ); |
|
155 | + $view = $this->container->create(View::class); |
|
156 | + if (is_null($view) || ! is_a($view, View::class)) { |
|
157 | + throw new Exception('View not defined'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | $meta_box->view( |
161 | - function ( \WP_Post $post, array $args ) use ( $meta_box, $view ) { |
|
161 | + function(\WP_Post $post, array $args) use ($meta_box, $view) { |
|
162 | 162 | |
163 | 163 | $args['args']['post'] = $post; |
164 | - $args['args'] = $this->filter_view_args( $meta_box, $post, $args['args'] ); |
|
164 | + $args['args'] = $this->filter_view_args($meta_box, $post, $args['args']); |
|
165 | 165 | |
166 | 166 | // @phpstan-ignore-next-line, template should already be checked for valid template path in register() method (which calls this) |
167 | - $view->render( $meta_box->view_template, $args['args'] ); |
|
167 | + $view->render($meta_box->view_template, $args['args']); |
|
168 | 168 | } |
169 | 169 | ); |
170 | 170 | |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return boolean |
178 | 178 | */ |
179 | - protected function is_active( Meta_Box $meta_box ): bool { |
|
179 | + protected function is_active(Meta_Box $meta_box): bool { |
|
180 | 180 | global $current_screen; |
181 | 181 | |
182 | - return ! is_null( $current_screen ) |
|
183 | - && ! empty( $current_screen->post_type ) |
|
184 | - && in_array( $current_screen->post_type, $meta_box->screen, true ); |
|
182 | + return ! is_null($current_screen) |
|
183 | + && ! empty($current_screen->post_type) |
|
184 | + && in_array($current_screen->post_type, $meta_box->screen, true); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * @param array<string, mixed> $view_args |
193 | 193 | * @return array<string, mixed> |
194 | 194 | */ |
195 | - public function filter_view_args( Meta_Box $meta_box, \WP_Post $post, array $view_args ): array { |
|
196 | - if ( is_callable( $meta_box->view_data_filter ) ) { |
|
197 | - $view_args = ( $meta_box->view_data_filter )( $post, $view_args ); |
|
195 | + public function filter_view_args(Meta_Box $meta_box, \WP_Post $post, array $view_args): array { |
|
196 | + if (is_callable($meta_box->view_data_filter)) { |
|
197 | + $view_args = ($meta_box->view_data_filter)($post, $view_args); |
|
198 | 198 | } |
199 | 199 | return $view_args; |
200 | 200 | } |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - public function register( Registerable $registerable ): void { |
|
67 | - if ( ! is_a( $registerable, Shared_Meta_Box_Controller::class ) ) { |
|
66 | + public function register(Registerable $registerable): void { |
|
67 | + if ( ! is_a($registerable, Shared_Meta_Box_Controller::class)) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | |
73 | 73 | // Get the meta box and meta data. |
74 | 74 | $meta_box = $registerable->meta_box(); |
75 | - $meta_data = $registerable->meta_data( array() ); |
|
75 | + $meta_data = $registerable->meta_data(array()); |
|
76 | 76 | |
77 | 77 | // Register the meta box. |
78 | - $this->meta_box_registrar->register( $meta_box ); |
|
78 | + $this->meta_box_registrar->register($meta_box); |
|
79 | 79 | |
80 | 80 | // Register all meta data. |
81 | - foreach ( $this->filter_meta_data( $meta_data ) as $meta_field ) { |
|
81 | + foreach ($this->filter_meta_data($meta_data) as $meta_field) { |
|
82 | 82 | // Register meta data for each post type. |
83 | - foreach ( $meta_box->screen as $post_type ) { |
|
84 | - $this->meta_data_registrar->register_for_post_type( $meta_field, $post_type ); |
|
83 | + foreach ($meta_box->screen as $post_type) { |
|
84 | + $this->meta_data_registrar->register_for_post_type($meta_field, $post_type); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param mixed[] $meta_data |
94 | 94 | * @return Meta_Data[] |
95 | 95 | */ |
96 | - protected function filter_meta_data( array $meta_data ): array { |
|
96 | + protected function filter_meta_data(array $meta_data): array { |
|
97 | 97 | return array_filter( |
98 | 98 | $meta_data, |
99 | - function( $e ) { |
|
100 | - return is_a( $e, Meta_Data::class ); |
|
99 | + function($e) { |
|
100 | + return is_a($e, Meta_Data::class); |
|
101 | 101 | } |
102 | 102 | ); |
103 | 103 | } |
@@ -107,11 +107,11 @@ |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | - * Registers a Meta Data object as defined REST field. |
|
111 | - * |
|
112 | - * @param \PinkCrab\Registerables\Meta_Data $meta |
|
113 | - * @return void |
|
114 | - */ |
|
110 | + * Registers a Meta Data object as defined REST field. |
|
111 | + * |
|
112 | + * @param \PinkCrab\Registerables\Meta_Data $meta |
|
113 | + * @return void |
|
114 | + */ |
|
115 | 115 | public function register_meta_rest_field( Meta_Data $meta ) { |
116 | 116 | // Skip if not sub type defined for post or term. |
117 | 117 | if ( null === $meta->get_subtype() ) { |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @return bool |
38 | 38 | * @throws \Exception if fails to register meta data. |
39 | 39 | */ |
40 | - public function register_for_post_type( Meta_Data $meta, string $post_type ):bool { |
|
41 | - return $this->register_meta( $meta, 'post', $post_type ); |
|
40 | + public function register_for_post_type(Meta_Data $meta, string $post_type):bool { |
|
41 | + return $this->register_meta($meta, 'post', $post_type); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * @return bool |
50 | 50 | * @throws \Exception if fails to register meta data. |
51 | 51 | */ |
52 | - public function register_for_term( Meta_Data $meta, string $taxonomy ):bool { |
|
53 | - return $this->register_meta( $meta, 'term', $taxonomy ); |
|
52 | + public function register_for_term(Meta_Data $meta, string $taxonomy):bool { |
|
53 | + return $this->register_meta($meta, 'term', $taxonomy); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | * @throws \Exception if fails to register meta data. |
62 | 62 | */ |
63 | - public function register_for_user( Meta_Data $meta ): bool { |
|
64 | - return $this->register_meta( $meta, 'user', '' ); |
|
63 | + public function register_for_user(Meta_Data $meta): bool { |
|
64 | + return $this->register_meta($meta, 'user', ''); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @return bool |
72 | 72 | * @throws \Exception if fails to register meta data. |
73 | 73 | */ |
74 | - public function register_for_comment( Meta_Data $meta ): bool { |
|
75 | - return $this->register_meta( $meta, 'comment', '' ); |
|
74 | + public function register_for_comment(Meta_Data $meta): bool { |
|
75 | + return $this->register_meta($meta, 'comment', ''); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -86,25 +86,25 @@ discard block |
||
86 | 86 | * @return bool |
87 | 87 | * @throws \Exception if fails to register meta data. |
88 | 88 | */ |
89 | - protected function register_meta( Meta_Data $meta, string $meta_type, string $sub_type ): bool { |
|
89 | + protected function register_meta(Meta_Data $meta, string $meta_type, string $sub_type): bool { |
|
90 | 90 | // Clone and set the post type, while enforcing it as a post meta. |
91 | 91 | $meta = clone $meta; |
92 | - $meta->object_subtype( $sub_type ); |
|
93 | - $meta->meta_type( $meta_type ); |
|
92 | + $meta->object_subtype($sub_type); |
|
93 | + $meta->meta_type($meta_type); |
|
94 | 94 | |
95 | 95 | // Normalise rest schema model to array. |
96 | - $meta = $this->normalise_rest_schema( $meta ); |
|
96 | + $meta = $this->normalise_rest_schema($meta); |
|
97 | 97 | |
98 | - $result = register_meta( $meta->get_meta_type(), $meta->get_meta_key(), $meta->parse_args() ); |
|
99 | - if ( ! $result ) { |
|
98 | + $result = register_meta($meta->get_meta_type(), $meta->get_meta_key(), $meta->parse_args()); |
|
99 | + if ( ! $result) { |
|
100 | 100 | throw new \Exception( |
101 | 101 | "Failed to register {$meta->get_meta_key()} (meta) for {$sub_type} of {$meta_type} type" |
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Maybe register rest fields. |
106 | - if ( false !== $meta->get_rest_schema() ) { |
|
107 | - $this->register_meta_rest_field( $meta ); |
|
106 | + if (false !== $meta->get_rest_schema()) { |
|
107 | + $this->register_meta_rest_field($meta); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | return $result; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * @param \PinkCrab\Registerables\Meta_Data $meta |
120 | 120 | * @return \PinkCrab\Registerables\Meta_Data |
121 | 121 | */ |
122 | - protected function normalise_rest_schema( Meta_Data $meta ): Meta_Data { |
|
123 | - if ( \class_exists( 'PinkCrab\WP_Rest_Schema\Argument\Argument' ) |
|
122 | + protected function normalise_rest_schema(Meta_Data $meta): Meta_Data { |
|
123 | + if (\class_exists('PinkCrab\WP_Rest_Schema\Argument\Argument') |
|
124 | 124 | && $meta->get_rest_schema() instanceof \PinkCrab\WP_Rest_Schema\Argument\Argument |
125 | 125 | ) { |
126 | - $meta->rest_schema( \PinkCrab\WP_Rest_Schema\Parser\Argument_Parser::for_meta_data( $meta->get_rest_schema() ) ); |
|
126 | + $meta->rest_schema(\PinkCrab\WP_Rest_Schema\Parser\Argument_Parser::for_meta_data($meta->get_rest_schema())); |
|
127 | 127 | } |
128 | 128 | return $meta; |
129 | 129 | } |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | * @param \PinkCrab\Registerables\Meta_Data $meta |
135 | 135 | * @return void |
136 | 136 | */ |
137 | - public function register_meta_rest_field( Meta_Data $meta ) { |
|
137 | + public function register_meta_rest_field(Meta_Data $meta) { |
|
138 | 138 | // Skip if not sub type defined for post or term. |
139 | - if ( null === $meta->get_subtype() ) { |
|
139 | + if (null === $meta->get_subtype()) { |
|
140 | 140 | return; |
141 | 141 | } |
142 | 142 | |
143 | 143 | add_action( |
144 | 144 | 'rest_api_init', |
145 | - function () use ( $meta ) { |
|
145 | + function() use ($meta) { |
|
146 | 146 | register_rest_field( |
147 | 147 | $meta->get_subtype(), |
148 | 148 | $meta->get_meta_key(), |
149 | 149 | array( // @phpstan-ignore-line WP Docblock doesn't give enough details of callable param types, so throws false positive |
150 | - 'get_callback' => $meta->get_rest_view() ?? $this->create_rest_get_method( $meta ), |
|
150 | + 'get_callback' => $meta->get_rest_view() ?? $this->create_rest_get_method($meta), |
|
151 | 151 | 'schema' => $meta->get_rest_schema(), |
152 | - 'update_callback' => $meta->get_rest_update() ?? $this->create_rest_update_method( $meta ), |
|
152 | + 'update_callback' => $meta->get_rest_update() ?? $this->create_rest_update_method($meta), |
|
153 | 153 | ) |
154 | 154 | ); |
155 | 155 | } |
@@ -162,23 +162,23 @@ discard block |
||
162 | 162 | * @param \PinkCrab\Registerables\Meta_Data $meta |
163 | 163 | * @return callable(array<mixed>):void |
164 | 164 | */ |
165 | - protected function create_rest_get_method( Meta_Data $meta ): callable { |
|
166 | - return function( $model ) use ( $meta ) { |
|
167 | - switch ( $meta->get_meta_type() ) { |
|
165 | + protected function create_rest_get_method(Meta_Data $meta): callable { |
|
166 | + return function($model) use ($meta) { |
|
167 | + switch ($meta->get_meta_type()) { |
|
168 | 168 | case 'post': |
169 | - $value = get_post_meta( $model['id'], $meta->get_meta_key(), true ); |
|
169 | + $value = get_post_meta($model['id'], $meta->get_meta_key(), true); |
|
170 | 170 | break; |
171 | 171 | |
172 | 172 | case 'term': |
173 | - $value = get_term_meta( $model['id'], $meta->get_meta_key(), true ); |
|
173 | + $value = get_term_meta($model['id'], $meta->get_meta_key(), true); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case 'user': |
177 | - $value = get_user_meta( $model['id'], $meta->get_meta_key(), true ); |
|
177 | + $value = get_user_meta($model['id'], $meta->get_meta_key(), true); |
|
178 | 178 | break; |
179 | 179 | |
180 | 180 | case 'comment': |
181 | - $value = get_comment_meta( $model['id'], $meta->get_meta_key(), true ); |
|
181 | + $value = get_comment_meta($model['id'], $meta->get_meta_key(), true); |
|
182 | 182 | break; |
183 | 183 | |
184 | 184 | default: |
@@ -196,31 +196,31 @@ discard block |
||
196 | 196 | * @param Meta_Data $meta |
197 | 197 | * @return \Closure(mixed, \WP_Post|\WP_Term|\WP_User|\WP_Comment): mixed |
198 | 198 | */ |
199 | - protected function create_rest_update_method( Meta_Data $meta ): \Closure { |
|
199 | + protected function create_rest_update_method(Meta_Data $meta): \Closure { |
|
200 | 200 | /** |
201 | 201 | * @param mixed $value |
202 | 202 | * @param \WP_Post|\WP_Term|\WP_User|\WP_Comment $object |
203 | 203 | */ |
204 | - return function( $value, $object ) use ( $meta ) { |
|
205 | - switch ( $meta->get_meta_type() ) { |
|
204 | + return function($value, $object) use ($meta) { |
|
205 | + switch ($meta->get_meta_type()) { |
|
206 | 206 | case 'post': |
207 | 207 | /** @var \WP_Post $object */ |
208 | - update_post_meta( $object->ID, $meta->get_meta_key(), $value ); |
|
208 | + update_post_meta($object->ID, $meta->get_meta_key(), $value); |
|
209 | 209 | break; |
210 | 210 | |
211 | 211 | case 'term': |
212 | 212 | /** @var \WP_Term $object */ |
213 | - update_term_meta( $object->term_id, $meta->get_meta_key(), $value ); |
|
213 | + update_term_meta($object->term_id, $meta->get_meta_key(), $value); |
|
214 | 214 | break; |
215 | 215 | |
216 | 216 | case 'user': |
217 | 217 | /** @var \WP_User $object */ |
218 | - update_user_meta( $object->ID, $meta->get_meta_key(), $value ); |
|
218 | + update_user_meta($object->ID, $meta->get_meta_key(), $value); |
|
219 | 219 | break; |
220 | 220 | |
221 | 221 | case 'comment': |
222 | 222 | /** @var \WP_Comment $object */ |
223 | - update_comment_meta( (int) $object->comment_ID, $meta->get_meta_key(), $value ); |
|
223 | + update_comment_meta((int) $object->comment_ID, $meta->get_meta_key(), $value); |
|
224 | 224 | break; |
225 | 225 | |
226 | 226 | default: |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | protected $default = ''; |
73 | 73 | |
74 | 74 | /** |
75 | - * The meta fields callbacks |
|
76 | - * |
|
77 | - * @var array{ |
|
78 | - * sanitize: null|callable, |
|
79 | - * permissions: null|callable, |
|
80 | - * rest_view: null|callable(mixed[]): void, |
|
81 | - * rest_update: null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment): void |
|
82 | - * } |
|
83 | - */ |
|
75 | + * The meta fields callbacks |
|
76 | + * |
|
77 | + * @var array{ |
|
78 | + * sanitize: null|callable, |
|
79 | + * permissions: null|callable, |
|
80 | + * rest_view: null|callable(mixed[]): void, |
|
81 | + * rest_update: null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment): void |
|
82 | + * } |
|
83 | + */ |
|
84 | 84 | protected $callbacks = array( |
85 | 85 | 'sanitize' => null, |
86 | 86 | 'permissions' => null, |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
236 | - * Sets the GET callback for REST requests. |
|
237 | - * |
|
238 | - * @param callable|null $callback |
|
239 | - * @return self |
|
240 | - */ |
|
236 | + * Sets the GET callback for REST requests. |
|
237 | + * |
|
238 | + * @param callable|null $callback |
|
239 | + * @return self |
|
240 | + */ |
|
241 | 241 | public function rest_view( ?callable $callback ): self { |
242 | 242 | $this->callbacks['rest_view'] = $callback; |
243 | 243 | return $this; |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | - * Gets the GET callback for REST requests. |
|
318 | - * |
|
319 | - * @return null|callable(mixed[]): void |
|
320 | - */ |
|
317 | + * Gets the GET callback for REST requests. |
|
318 | + * |
|
319 | + * @return null|callable(mixed[]): void |
|
320 | + */ |
|
321 | 321 | public function get_rest_view(): ?callable { |
322 | 322 | return $this->callbacks['rest_view']; |
323 | 323 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected $meta_key; |
104 | 104 | |
105 | - public function __construct( string $meta_key ) { |
|
105 | + public function __construct(string $meta_key) { |
|
106 | 106 | $this->meta_key = $meta_key; |
107 | 107 | } |
108 | 108 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param string $meta_type Object type meta applies to |
114 | 114 | * @return self |
115 | 115 | */ |
116 | - public function meta_type( string $meta_type ): self { |
|
116 | + public function meta_type(string $meta_type): self { |
|
117 | 117 | $this->meta_type = $meta_type; |
118 | 118 | return $this; |
119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param string|null $object_subtype Holds a secondary object type, used for post type and taxonomy. |
125 | 125 | * @return self |
126 | 126 | */ |
127 | - public function object_subtype( ?string $object_subtype ): self { |
|
127 | + public function object_subtype(?string $object_subtype): self { |
|
128 | 128 | $this->object_subtype = $object_subtype ?? ''; |
129 | 129 | return $this; |
130 | 130 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param string $type |
137 | 137 | * @return self |
138 | 138 | */ |
139 | - public function type( string $type ): self { |
|
139 | + public function type(string $type): self { |
|
140 | 140 | $this->type = $type; |
141 | 141 | return $this; |
142 | 142 | } |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @param string $post_type |
148 | 148 | * @return self |
149 | 149 | */ |
150 | - public function post_type( string $post_type ): self { |
|
151 | - $this->meta_type( 'post' ); |
|
152 | - $this->object_subtype( $post_type ); |
|
150 | + public function post_type(string $post_type): self { |
|
151 | + $this->meta_type('post'); |
|
152 | + $this->object_subtype($post_type); |
|
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | * @param string $taxonomy |
160 | 160 | * @return self |
161 | 161 | */ |
162 | - public function taxonomy( string $taxonomy ): self { |
|
163 | - $this->meta_type( 'term' ); |
|
164 | - $this->object_subtype( $taxonomy ); |
|
162 | + public function taxonomy(string $taxonomy): self { |
|
163 | + $this->meta_type('term'); |
|
164 | + $this->object_subtype($taxonomy); |
|
165 | 165 | return $this; |
166 | 166 | } |
167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return self |
174 | 174 | */ |
175 | - public function description( string $description ): self { |
|
175 | + public function description(string $description): self { |
|
176 | 176 | $this->description = $description; |
177 | 177 | return $this; |
178 | 178 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param bool $single Meta value is single value or array |
184 | 184 | * @return self |
185 | 185 | */ |
186 | - public function single( bool $single = true ): self { |
|
186 | + public function single(bool $single = true): self { |
|
187 | 187 | $this->single = $single; |
188 | 188 | return $this; |
189 | 189 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param mixed $default |
195 | 195 | * @return self |
196 | 196 | */ |
197 | - public function default( $default ): self { |
|
197 | + public function default($default): self { |
|
198 | 198 | $this->default = $default; |
199 | 199 | return $this; |
200 | 200 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param callable(mixed):mixed $callback |
206 | 206 | * @return self |
207 | 207 | */ |
208 | - public function sanitize( callable $callback ): self { |
|
208 | + public function sanitize(callable $callback): self { |
|
209 | 209 | $this->callbacks['sanitize'] = $callback; |
210 | 210 | return $this; |
211 | 211 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @param callable $callback |
217 | 217 | * @return self |
218 | 218 | */ |
219 | - public function permissions( callable $callback ): self { |
|
219 | + public function permissions(callable $callback): self { |
|
220 | 220 | $this->callbacks['permissions'] = $callback; |
221 | 221 | return $this; |
222 | 222 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param bool|array<mixed> $rest_schema|PinkCrab\WP_Rest_Schema\Argument\Argument Rest schema definitions |
228 | 228 | * @return self |
229 | 229 | */ |
230 | - public function rest_schema( $rest_schema ): self { |
|
230 | + public function rest_schema($rest_schema): self { |
|
231 | 231 | $this->rest_schema = $rest_schema; |
232 | 232 | return $this; |
233 | 233 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param callable|null $callback |
239 | 239 | * @return self |
240 | 240 | */ |
241 | - public function rest_view( ?callable $callback ): self { |
|
241 | + public function rest_view(?callable $callback): self { |
|
242 | 242 | $this->callbacks['rest_view'] = $callback; |
243 | 243 | return $this; |
244 | 244 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment):void $callback |
250 | 250 | * @return self |
251 | 251 | */ |
252 | - public function rest_update( ?callable $callback ): self { |
|
252 | + public function rest_update(?callable $callback): self { |
|
253 | 253 | $this->callbacks['rest_update'] = $callback; |
254 | 254 | return $this; |
255 | 255 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | ); |
272 | 272 | |
273 | 273 | // Set subtype. |
274 | - if ( $this->object_subtype !== null ) { |
|
274 | + if ($this->object_subtype !== null) { |
|
275 | 275 | $args['object_subtype'] = $this->object_subtype; |
276 | 276 | } |
277 | 277 | return $args; |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - public function register( Registerable $registerable ): void { |
|
65 | + public function register(Registerable $registerable): void { |
|
66 | 66 | /** @var Taxonomy $registerable, Validation call below catches no Post_Type Registerables */ |
67 | 67 | |
68 | - if ( ! $this->validator->validate( $registerable ) ) { |
|
68 | + if ( ! $this->validator->validate($registerable)) { |
|
69 | 69 | throw new Exception( |
70 | 70 | sprintf( |
71 | 71 | 'Failed validating taxonomy model(%s) with errors: %s', |
72 | - get_class( $registerable ), |
|
73 | - join( ', ', $this->validator->get_errors() ) |
|
72 | + get_class($registerable), |
|
73 | + join(', ', $this->validator->get_errors()) |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | } |
@@ -81,18 +81,18 @@ discard block |
||
81 | 81 | $registerable->slug, |
82 | 82 | $registerable->object_type, |
83 | 83 | /* @phpstan-ignore-next-line */ |
84 | - $this->compile_args( $registerable ) |
|
84 | + $this->compile_args($registerable) |
|
85 | 85 | ); |
86 | 86 | |
87 | - if ( is_a( $result, \WP_Error::class ) ) { |
|
88 | - throw new Exception( join( $result->get_error_messages() ) ); |
|
87 | + if (is_a($result, \WP_Error::class)) { |
|
88 | + throw new Exception(join($result->get_error_messages())); |
|
89 | 89 | } |
90 | - } catch ( \Throwable $th ) { |
|
91 | - throw new Exception( "Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})" ); |
|
90 | + } catch (\Throwable $th) { |
|
91 | + throw new Exception("Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})"); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // Register any associated meta data. |
95 | - $this->register_meta_data( $registerable ); |
|
95 | + $this->register_meta_data($registerable); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | * @param \PinkCrab\Registerables\Taxonomy $taxonomy |
103 | 103 | * @return void |
104 | 104 | */ |
105 | - protected function register_meta_data( Taxonomy $taxonomy ): void { |
|
105 | + protected function register_meta_data(Taxonomy $taxonomy): void { |
|
106 | 106 | |
107 | 107 | // Get all meta fields for taxonomy. |
108 | - $meta_fields = $taxonomy->meta_data( array() ); |
|
108 | + $meta_fields = $taxonomy->meta_data(array()); |
|
109 | 109 | |
110 | 110 | // Attempt to register all Meta for taxonomy. |
111 | 111 | try { |
112 | - foreach ( $meta_fields as $meta_field ) { |
|
113 | - $this->meta_data_registrar->register_for_term( $meta_field, $taxonomy->slug ); |
|
112 | + foreach ($meta_fields as $meta_field) { |
|
113 | + $this->meta_data_registrar->register_for_term($meta_field, $taxonomy->slug); |
|
114 | 114 | } |
115 | - } catch ( \Throwable $th ) { |
|
116 | - throw new Exception( $th->getMessage() ); |
|
115 | + } catch (\Throwable $th) { |
|
116 | + throw new Exception($th->getMessage()); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -123,59 +123,59 @@ discard block |
||
123 | 123 | * @param \PinkCrab\Registerables\Taxonomy $taxonomy |
124 | 124 | * @return array<string, string|int|array<string, string>> |
125 | 125 | */ |
126 | - protected function compile_args( Taxonomy $taxonomy ): array { |
|
126 | + protected function compile_args(Taxonomy $taxonomy): array { |
|
127 | 127 | // Create the labels. |
128 | 128 | $base_labels = array( |
129 | 129 | 'name' => $taxonomy->plural, |
130 | 130 | 'singular_name' => $taxonomy->singular, |
131 | - 'menu_name' => \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ), |
|
131 | + 'menu_name' => \ucfirst(\esc_attr($taxonomy->plural ?? '')), |
|
132 | 132 | /* translators: %s: Taxonomy plural name */ |
133 | - 'search_items' => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
133 | + 'search_items' => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
134 | 134 | /* translators: %s: Taxonomy plural name */ |
135 | - 'popular_items' => wp_sprintf( _x( 'Popular %s', 'Label for the popular terms', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
135 | + 'popular_items' => wp_sprintf(_x('Popular %s', 'Label for the popular terms', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
136 | 136 | /* translators: %s: Taxonomy singular name */ |
137 | - 'edit_item' => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
137 | + 'edit_item' => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
138 | 138 | /* translators: %s: Taxonomy singular name */ |
139 | - 'view_item' => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
139 | + 'view_item' => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
140 | 140 | /* translators: %s: Taxonomy singular name */ |
141 | - 'update_item' => wp_sprintf( _x( 'Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
141 | + 'update_item' => wp_sprintf(_x('Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
142 | 142 | /* translators: %s: Taxonomy singular name */ |
143 | - 'add_new_item' => wp_sprintf( _x( 'Add New %s', 'Label for adding a new singular item. Default is ‘Add New {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
143 | + 'add_new_item' => wp_sprintf(_x('Add New %s', 'Label for adding a new singular item. Default is ‘Add New {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
144 | 144 | /* translators: %s: Taxonomy singular name */ |
145 | - 'new_item_name' => wp_sprintf( _x( 'New %s', 'Label for the new item page title. Default is ‘New {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
145 | + 'new_item_name' => wp_sprintf(_x('New %s', 'Label for the new item page title. Default is ‘New {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
146 | 146 | /* translators: %s: Taxonomy plural name */ |
147 | - 'not_found' => wp_sprintf( _x( 'No %s found', 'Label used when no items are found. Default is ‘No {taxonomy plural name} found’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
147 | + 'not_found' => wp_sprintf(_x('No %s found', 'Label used when no items are found. Default is ‘No {taxonomy plural name} found’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
148 | 148 | /* translators: %s: Taxonomy plural name */ |
149 | - 'items_list' => wp_sprintf( _x( '%s list', 'Label for the table hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ), |
|
149 | + 'items_list' => wp_sprintf(_x('%s list', 'Label for the table hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))), |
|
150 | 150 | /* translators: %s: Taxonomy plural name */ |
151 | - 'items_list_navigation' => wp_sprintf( _x( '%s list navigation', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ), |
|
151 | + 'items_list_navigation' => wp_sprintf(_x('%s list navigation', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))), |
|
152 | 152 | /* translators: %s: Taxonomy plural name */ |
153 | - 'all_items' => wp_sprintf( _x( 'All %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ), |
|
154 | - 'most_used' => _x( 'Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab' ), |
|
153 | + 'all_items' => wp_sprintf(_x('All %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))), |
|
154 | + 'most_used' => _x('Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab'), |
|
155 | 155 | /* translators: %s: Taxonomy plural name */ |
156 | - 'back_to_items' => wp_sprintf( _x( '← Back to %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ), |
|
156 | + 'back_to_items' => wp_sprintf(_x('← Back to %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))), |
|
157 | 157 | /* translators: %s: Taxonomy singular name */ |
158 | - 'item_link' => wp_sprintf( _x( '%s Link', 'Title for a navigation link block variation. Default is ‘{taxonomy singular name} Link’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->singular ?? '' ) ) ), |
|
158 | + 'item_link' => wp_sprintf(_x('%s Link', 'Title for a navigation link block variation. Default is ‘{taxonomy singular name} Link’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->singular ?? ''))), |
|
159 | 159 | /* translators: %s: Taxonomy singular name */ |
160 | - 'item_link_description' => wp_sprintf( _x( 'A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
160 | + 'item_link_description' => wp_sprintf(_x('A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
161 | 161 | ); |
162 | 162 | |
163 | 163 | $tag_labels = array( |
164 | 164 | /* translators: %s: Taxonomy plural name */ |
165 | - 'separate_items_with_commas' => wp_sprintf( _x( 'Separate %s with commas', 'This label is only used for non-hierarchical taxonomies. Default \'Separate {taxonomy plural name} with commas\', used in the meta box.’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
165 | + 'separate_items_with_commas' => wp_sprintf(_x('Separate %s with commas', 'This label is only used for non-hierarchical taxonomies. Default \'Separate {taxonomy plural name} with commas\', used in the meta box.’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
166 | 166 | /* translators: %s: Taxonomy plural name */ |
167 | - 'add_or_remove_items' => wp_sprintf( _x( 'Add or remove %s', 'This label is only used for non-hierarchical taxonomies. Default \'Add or remove {taxonomy plural name}\', used in the meta box when JavaScript is disabled.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
167 | + 'add_or_remove_items' => wp_sprintf(_x('Add or remove %s', 'This label is only used for non-hierarchical taxonomies. Default \'Add or remove {taxonomy plural name}\', used in the meta box when JavaScript is disabled.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
168 | 168 | /* translators: %s: Taxonomy plural name */ |
169 | - 'choose_from_most_used' => wp_sprintf( _x( 'Add or remove %s', 'This label is only used on non-hierarchical taxonomies. Default\'Choose from the most used {taxonomy plural name}\', used in the meta box.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
169 | + 'choose_from_most_used' => wp_sprintf(_x('Add or remove %s', 'This label is only used on non-hierarchical taxonomies. Default\'Choose from the most used {taxonomy plural name}\', used in the meta box.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
170 | 170 | ); |
171 | 171 | |
172 | 172 | $hierarchical_labels = array( |
173 | 173 | /* translators: %s: Taxonomy singular name */ |
174 | - 'parent_item_colon' => wp_sprintf( _x( 'Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical taxonomys. Default is ‘Parent {taxonomy plural name}:’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
174 | + 'parent_item_colon' => wp_sprintf(_x('Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical taxonomys. Default is ‘Parent {taxonomy plural name}:’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
175 | 175 | /* translators: %s: Taxonomy singular name */ |
176 | - 'parent_item' => wp_sprintf( _x( 'Parent %s', 'Label for the parent term', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
176 | + 'parent_item' => wp_sprintf(_x('Parent %s', 'Label for the parent term', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
177 | 177 | /* translators: %s: Taxonomy singular name */ |
178 | - 'filter_by_item' => wp_sprintf( _x( 'Filter by %s', 'This label is only used for hierarchical taxonomies. Default \'Filter by {taxonomy singular name}\', used in the posts list table.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
178 | + 'filter_by_item' => wp_sprintf(_x('Filter by %s', 'This label is only used for hierarchical taxonomies. Default \'Filter by {taxonomy singular name}\', used in the posts list table.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
179 | 179 | ); |
180 | 180 | |
181 | 181 | $labels = array_merge( |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param Taxonomy $taxonomy |
192 | 192 | * @return array<string, string> |
193 | 193 | */ |
194 | - $labels = apply_filters( Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels( $labels ), $taxonomy ); |
|
194 | + $labels = apply_filters(Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels($labels), $taxonomy); |
|
195 | 195 | |
196 | 196 | // Compose args. |
197 | 197 | $args = array( |
@@ -232,6 +232,6 @@ discard block |
||
232 | 232 | * @return array<string, string|bool|int|null|array<string, string> |
233 | 233 | */ |
234 | 234 | /* @phpstan-ignore-next-line, this is due to apply_filters type hints being wrong. */ |
235 | - return apply_filters( Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args( $args ), $taxonomy ); |
|
235 | + return apply_filters(Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args($args), $taxonomy); |
|
236 | 236 | } |
237 | 237 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param \PinkCrab\Loader\Hook_Loader $loader |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function set_hook_loader( Hook_Loader $loader ) { |
|
55 | + public function set_hook_loader(Hook_Loader $loader) { |
|
56 | 56 | $this->loader = $loader; |
57 | 57 | } |
58 | 58 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param \PinkCrab\Perique\Interfaces\DI_Container $container |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - public function set_di_container( DI_Container $container ): void { |
|
65 | + public function set_di_container(DI_Container $container): void { |
|
66 | 66 | $this->container = $container; |
67 | 67 | } |
68 | 68 | |
@@ -72,27 +72,27 @@ discard block |
||
72 | 72 | * @param object|Registerable $class |
73 | 73 | * @return object |
74 | 74 | */ |
75 | - public function process( $class ) { |
|
76 | - if ( ! is_a( $class, Registerable::class ) ) { |
|
75 | + public function process($class) { |
|
76 | + if ( ! is_a($class, Registerable::class)) { |
|
77 | 77 | return $class; |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Based on the registerable type. |
81 | - switch ( true ) { |
|
82 | - case is_a( $class, Post_Type::class ): |
|
83 | - $this->process_post_type( $class ); |
|
81 | + switch (true) { |
|
82 | + case is_a($class, Post_Type::class): |
|
83 | + $this->process_post_type($class); |
|
84 | 84 | break; |
85 | 85 | |
86 | - case is_a( $class, Taxonomy::class ): |
|
87 | - $this->process_taxonomy( $class ); |
|
86 | + case is_a($class, Taxonomy::class): |
|
87 | + $this->process_taxonomy($class); |
|
88 | 88 | break; |
89 | 89 | |
90 | - case is_a( $class, Shared_Meta_Box_Controller::class ): |
|
91 | - $this->process_shared_meta_box( $class ); |
|
90 | + case is_a($class, Shared_Meta_Box_Controller::class): |
|
91 | + $this->process_shared_meta_box($class); |
|
92 | 92 | break; |
93 | 93 | |
94 | - case is_a( $class, Additional_Meta_Data_Controller::class ): |
|
95 | - $this->process_additional_meta_data( $class ); |
|
94 | + case is_a($class, Additional_Meta_Data_Controller::class): |
|
95 | + $this->process_additional_meta_data($class); |
|
96 | 96 | break; |
97 | 97 | |
98 | 98 | default: |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | * @return void |
111 | 111 | * @since 0.7.0 |
112 | 112 | */ |
113 | - protected function process_taxonomy( Taxonomy $taxonomy ): void { |
|
113 | + protected function process_taxonomy(Taxonomy $taxonomy): void { |
|
114 | 114 | $this->loader->action( |
115 | 115 | 'init', |
116 | - static function() use ( $taxonomy ) { |
|
116 | + static function() use ($taxonomy) { |
|
117 | 117 | Registrar_Factory::new() |
118 | - ->create_from_registerable( $taxonomy ) |
|
119 | - ->register( $taxonomy ); |
|
118 | + ->create_from_registerable($taxonomy) |
|
119 | + ->register($taxonomy); |
|
120 | 120 | } |
121 | 121 | ); |
122 | 122 | } |
@@ -128,21 +128,21 @@ discard block |
||
128 | 128 | * @return void |
129 | 129 | * @since 0.7.0 |
130 | 130 | */ |
131 | - protected function process_post_type( Post_Type $post_type_registerable ) { |
|
131 | + protected function process_post_type(Post_Type $post_type_registerable) { |
|
132 | 132 | // Register registerable. |
133 | 133 | $this->loader->action( |
134 | 134 | 'init', |
135 | - static function() use ( $post_type_registerable ) { |
|
135 | + static function() use ($post_type_registerable) { |
|
136 | 136 | Registrar_Factory::new() |
137 | - ->create_from_registerable( $post_type_registerable ) |
|
138 | - ->register( $post_type_registerable ); |
|
137 | + ->create_from_registerable($post_type_registerable) |
|
138 | + ->register($post_type_registerable); |
|
139 | 139 | } |
140 | 140 | ); |
141 | 141 | |
142 | 142 | // Define use of gutenberg |
143 | 143 | $this->loader->filter( |
144 | 144 | 'use_block_editor_for_post_type', |
145 | - static function( bool $state, string $post_type ) use ( $post_type_registerable ): bool { |
|
145 | + static function(bool $state, string $post_type) use ($post_type_registerable): bool { |
|
146 | 146 | return $post_type === $post_type_registerable->key |
147 | 147 | ? (bool) $post_type_registerable->gutenberg |
148 | 148 | : $state; |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | ); |
153 | 153 | |
154 | 154 | // Register meta boxes. |
155 | - $meta_boxes = $post_type_registerable->meta_boxes( array() ); |
|
155 | + $meta_boxes = $post_type_registerable->meta_boxes(array()); |
|
156 | 156 | |
157 | - if ( ! empty( $meta_boxes ) ) { |
|
157 | + if ( ! empty($meta_boxes)) { |
|
158 | 158 | |
159 | 159 | // Create the registrar |
160 | 160 | $meta_box_registrar = $this->get_meta_box_registrar(); |
161 | 161 | |
162 | 162 | // Register each meta box. |
163 | - foreach ( $meta_boxes as $meta_box ) { |
|
164 | - $meta_box->screen( $post_type_registerable->key ); |
|
165 | - $meta_box_registrar->register( $meta_box ); |
|
163 | + foreach ($meta_boxes as $meta_box) { |
|
164 | + $meta_box->screen($post_type_registerable->key); |
|
165 | + $meta_box_registrar->register($meta_box); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | } |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * @return void |
176 | 176 | * @since 0.7.0 |
177 | 177 | */ |
178 | - public function process_shared_meta_box( Shared_Meta_Box_Controller $controller ): void { |
|
178 | + public function process_shared_meta_box(Shared_Meta_Box_Controller $controller): void { |
|
179 | 179 | $registrar = new Shared_Meta_Box_Registrar( |
180 | 180 | $this->get_meta_box_registrar(), |
181 | 181 | Registrar_Factory::new()->meta_data_registrar() |
182 | 182 | ); |
183 | - $registrar->register( $controller ); |
|
183 | + $registrar->register($controller); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | * @return void |
191 | 191 | * @since 0.8.0 |
192 | 192 | */ |
193 | - public function process_additional_meta_data( Additional_Meta_Data_Controller $controller ): void { |
|
193 | + public function process_additional_meta_data(Additional_Meta_Data_Controller $controller): void { |
|
194 | 194 | $registrar = new Additional_Meta_Data_Registrar( |
195 | 195 | Registrar_Factory::new()->meta_data_registrar() |
196 | 196 | ); |
197 | - $registrar->register( $controller ); |
|
197 | + $registrar->register($controller); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @since 0.7.0 |
205 | 205 | */ |
206 | 206 | public function get_meta_box_registrar(): Meta_Box_Registrar { |
207 | - return Registrar_Factory::new()->meta_box_registrar( $this->container, $this->loader ); |
|
207 | + return Registrar_Factory::new()->meta_box_registrar($this->container, $this->loader); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | public function setup(): void { |
@@ -38,6 +38,6 @@ |
||
38 | 38 | * @return Meta_Data[] |
39 | 39 | * @codeCoverageIgnore |
40 | 40 | */ |
41 | - abstract public function meta_data( array $meta_data ): array; |
|
41 | + abstract public function meta_data(array $meta_data): array; |
|
42 | 42 | |
43 | 43 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected $meta_data_registrar; |
46 | 46 | |
47 | - public function __construct( Meta_Data_Registrar $meta_data_registrar ) { |
|
47 | + public function __construct(Meta_Data_Registrar $meta_data_registrar) { |
|
48 | 48 | $this->meta_data_registrar = $meta_data_registrar; |
49 | 49 | } |
50 | 50 | |
@@ -57,20 +57,20 @@ discard block |
||
57 | 57 | * @throws Exception If a none Additional_Meta_Data_Controller registerable is attempted to be registered. |
58 | 58 | * @throws Exception If a meta type which is not POST, USER, TERM or COMMENT is attempted to be registered. |
59 | 59 | */ |
60 | - public function register( Registerable $registerable ): void { |
|
61 | - if ( ! is_a( $registerable, Additional_Meta_Data_Controller::class ) ) { |
|
62 | - throw new Exception( 'Registerable must be an instance of Additional_Meta_Data_Controller' ); |
|
60 | + public function register(Registerable $registerable): void { |
|
61 | + if ( ! is_a($registerable, Additional_Meta_Data_Controller::class)) { |
|
62 | + throw new Exception('Registerable must be an instance of Additional_Meta_Data_Controller'); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** @var Additional_Meta_Data $registerable, Validation call below catches no Additional_Meta_Data Registerables */ |
66 | - $meta_data = $this->filter_meta_data( $registerable->meta_data( array() ) ); |
|
66 | + $meta_data = $this->filter_meta_data($registerable->meta_data(array())); |
|
67 | 67 | |
68 | 68 | // Iterate through all meta data and register them. |
69 | - foreach ( $meta_data as $meta_data_item ) { |
|
70 | - switch ( $meta_data_item->get_meta_type() ) { |
|
69 | + foreach ($meta_data as $meta_data_item) { |
|
70 | + switch ($meta_data_item->get_meta_type()) { |
|
71 | 71 | case 'post': |
72 | 72 | // Throw if post type not defined. |
73 | - if ( null === $meta_data_item->get_subtype() ) { |
|
73 | + if (null === $meta_data_item->get_subtype()) { |
|
74 | 74 | throw new Exception( |
75 | 75 | sprintf( |
76 | 76 | 'A post type must be defined when attempting to register post meta with meta key : %s', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | case 'term': |
89 | 89 | // Throw if Taxonomy not defined. |
90 | - if ( null === $meta_data_item->get_subtype() ) { |
|
90 | + if (null === $meta_data_item->get_subtype()) { |
|
91 | 91 | throw new Exception( |
92 | 92 | sprintf( |
93 | 93 | 'A taxonomy must be defined when attempting to register tern meta with meta key : %s', |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | break; |
116 | 116 | |
117 | 117 | default: |
118 | - throw new Exception( 'Unexpected meta type' ); |
|
118 | + throw new Exception('Unexpected meta type'); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | * @param mixed[] $meta_data |
127 | 127 | * @return Meta_Data[] |
128 | 128 | */ |
129 | - protected function filter_meta_data( array $meta_data ): array { |
|
129 | + protected function filter_meta_data(array $meta_data): array { |
|
130 | 130 | return array_filter( |
131 | 131 | $meta_data, |
132 | - function( $e ) { |
|
133 | - return is_a( $e, Meta_Data::class ); |
|
132 | + function($e) { |
|
133 | + return is_a($e, Meta_Data::class); |
|
134 | 134 | } |
135 | 135 | ); |
136 | 136 | } |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - public function register( Registerable $registerable ): void { |
|
65 | + public function register(Registerable $registerable): void { |
|
66 | 66 | /** @var Post_Type $registerable, Validation call below catches no Post_Type Registerables */ |
67 | 67 | |
68 | - if ( ! $this->validator->validate( $registerable ) ) { |
|
68 | + if ( ! $this->validator->validate($registerable)) { |
|
69 | 69 | throw new Exception( |
70 | 70 | sprintf( |
71 | 71 | 'Failed validating post type model(%s) with errors: %s', |
72 | - get_class( $registerable ), |
|
73 | - join( ', ', $this->validator->get_errors() ) |
|
72 | + get_class($registerable), |
|
73 | + join(', ', $this->validator->get_errors()) |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | } |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | // Attempt to register the post type. |
79 | 79 | try { |
80 | 80 | /* @phpstan-ignore-next-line */ |
81 | - $result = register_post_type( $registerable->key, $this->compile_args( $registerable ) ); |
|
82 | - if ( is_a( $result, \WP_Error::class ) ) { |
|
83 | - throw new Exception( join( $result->get_error_messages() ) ); |
|
81 | + $result = register_post_type($registerable->key, $this->compile_args($registerable)); |
|
82 | + if (is_a($result, \WP_Error::class)) { |
|
83 | + throw new Exception(join($result->get_error_messages())); |
|
84 | 84 | } |
85 | - } catch ( \Throwable $th ) { |
|
86 | - throw new Exception( "Failed to register {$registerable->key} post type ({$th->getMessage()})" ); |
|
85 | + } catch (\Throwable $th) { |
|
86 | + throw new Exception("Failed to register {$registerable->key} post type ({$th->getMessage()})"); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // Register all meta data for post type. |
90 | - $this->register_meta_data( $registerable ); |
|
90 | + $this->register_meta_data($registerable); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -96,18 +96,18 @@ discard block |
||
96 | 96 | * @param \PinkCrab\Registerables\Post_Type $post_type |
97 | 97 | * @return void |
98 | 98 | */ |
99 | - protected function register_meta_data( Post_Type $post_type ): void { |
|
99 | + protected function register_meta_data(Post_Type $post_type): void { |
|
100 | 100 | |
101 | 101 | // Get all meta fields for post_type. |
102 | - $meta_fields = $post_type->meta_data( array() ); |
|
102 | + $meta_fields = $post_type->meta_data(array()); |
|
103 | 103 | // Attempt to register all Meta for post_type. |
104 | 104 | try { |
105 | - foreach ( $meta_fields as $meta_field ) { |
|
105 | + foreach ($meta_fields as $meta_field) { |
|
106 | 106 | $this->meta_data_registrar |
107 | - ->register_for_post_type( $meta_field, $post_type->key ); |
|
107 | + ->register_for_post_type($meta_field, $post_type->key); |
|
108 | 108 | } |
109 | - } catch ( \Throwable $th ) { |
|
110 | - throw new Exception( $th->getMessage() ); |
|
109 | + } catch (\Throwable $th) { |
|
110 | + throw new Exception($th->getMessage()); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -119,64 +119,64 @@ discard block |
||
119 | 119 | * @param \PinkCrab\Registerables\Post_Type $post_type |
120 | 120 | * @return array<string, string|int|array<string, string>> |
121 | 121 | */ |
122 | - protected function compile_args( Post_Type $post_type ): array { |
|
122 | + protected function compile_args(Post_Type $post_type): array { |
|
123 | 123 | // Create the labels. |
124 | 124 | $labels = array( |
125 | 125 | 'name' => $post_type->plural, |
126 | 126 | 'singular_name' => $post_type->singular, |
127 | - 'add_new' => _x( 'Add New', 'Add new post label of custom post type', 'pinkcrab' ), |
|
127 | + 'add_new' => _x('Add New', 'Add new post label of custom post type', 'pinkcrab'), |
|
128 | 128 | /* translators: %s: Post type singular name */ |
129 | - 'add_new_item' => wp_sprintf( _x( 'Add New %s', 'Label for adding a new singular item. Default is ‘Add New {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
129 | + 'add_new_item' => wp_sprintf(_x('Add New %s', 'Label for adding a new singular item. Default is ‘Add New {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
130 | 130 | /* translators: %s: Post type singular name */ |
131 | - 'edit_item' => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
131 | + 'edit_item' => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
132 | 132 | /* translators: %s: Post type singular name */ |
133 | - 'new_item' => wp_sprintf( _x( 'New %s', 'Label for the new item page title. Default is ‘New {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
133 | + 'new_item' => wp_sprintf(_x('New %s', 'Label for the new item page title. Default is ‘New {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
134 | 134 | /* translators: %s: Post type singular name */ |
135 | - 'view_item' => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
135 | + 'view_item' => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
136 | 136 | /* translators: %s: Post type plural name */ |
137 | - 'view_items' => wp_sprintf( _x( 'View %s', 'Label for viewing post type archives. Default is ‘View {post type plural name}’.', 'pinkcrab' ), $post_type->plural ), |
|
137 | + 'view_items' => wp_sprintf(_x('View %s', 'Label for viewing post type archives. Default is ‘View {post type plural name}’.', 'pinkcrab'), $post_type->plural), |
|
138 | 138 | /* translators: %s: Post type singular name */ |
139 | - 'search_items' => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {post type plural name}’.', 'pinkcrab' ), $post_type->singular ), |
|
139 | + 'search_items' => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {post type plural name}’.', 'pinkcrab'), $post_type->singular), |
|
140 | 140 | /* translators: %s: Post type plural name */ |
141 | - 'not_found' => wp_sprintf( _x( 'No %s found', 'Label used when no items are found. Default is ‘No {post type plural name} found’.', 'pinkcrab' ), $post_type->plural ), |
|
141 | + 'not_found' => wp_sprintf(_x('No %s found', 'Label used when no items are found. Default is ‘No {post type plural name} found’.', 'pinkcrab'), $post_type->plural), |
|
142 | 142 | /* translators: %s: Post type plural name */ |
143 | - 'not_found_in_trash' => wp_sprintf( _x( 'No %s found in Trash', 'Label used when no items are in the Trash. Default is ‘No {post type plural name} found in Trash’.', 'pinkcrab' ), $post_type->plural ), |
|
143 | + 'not_found_in_trash' => wp_sprintf(_x('No %s found in Trash', 'Label used when no items are in the Trash. Default is ‘No {post type plural name} found in Trash’.', 'pinkcrab'), $post_type->plural), |
|
144 | 144 | /* translators: %s: Post type singular name */ |
145 | - 'parent_item_colon' => wp_sprintf( _x( 'Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical post types. Default is ‘Parent {post type plural name}:’.', 'pinkcrab' ), $post_type->singular ), |
|
145 | + 'parent_item_colon' => wp_sprintf(_x('Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical post types. Default is ‘Parent {post type plural name}:’.', 'pinkcrab'), $post_type->singular), |
|
146 | 146 | /* translators: %s: Post type singular name */ |
147 | - 'all_items' => wp_sprintf( _x( 'All %s', 'Label to signify all items in a submenu link. Default is ‘All {post type plural name}’.', 'pinkcrab' ), $post_type->plural ), |
|
147 | + 'all_items' => wp_sprintf(_x('All %s', 'Label to signify all items in a submenu link. Default is ‘All {post type plural name}’.', 'pinkcrab'), $post_type->plural), |
|
148 | 148 | /* translators: %s: Post type plural name */ |
149 | - 'archives' => wp_sprintf( _x( '%s Archives', ' Label for archives in nav menus. Default is ‘Post Archives’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ), |
|
149 | + 'archives' => wp_sprintf(_x('%s Archives', ' Label for archives in nav menus. Default is ‘Post Archives’.', 'pinkcrab'), \ucfirst($post_type->plural)), |
|
150 | 150 | /* translators: %s: Post type plural name */ |
151 | - 'attributes' => wp_sprintf( _x( '%s Attributes', 'Label for the attributes meta box. Default is ‘{post type plural name} Attributes’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ), |
|
151 | + 'attributes' => wp_sprintf(_x('%s Attributes', 'Label for the attributes meta box. Default is ‘{post type plural name} Attributes’.', 'pinkcrab'), \ucfirst($post_type->plural)), |
|
152 | 152 | /* translators: %s: Post type singular name */ |
153 | - 'insert_into_item' => wp_sprintf( _x( 'Insert into %s', 'Label for the media frame button. Default is ‘Insert into {post type plural name}’.', 'pinkcrab' ), $post_type->singular ), |
|
153 | + 'insert_into_item' => wp_sprintf(_x('Insert into %s', 'Label for the media frame button. Default is ‘Insert into {post type plural name}’.', 'pinkcrab'), $post_type->singular), |
|
154 | 154 | /* translators: %s: Post type singular name */ |
155 | - 'uploaded_to_this_item' => wp_sprintf( _x( 'Uploaded to this %s', 'Label for the media frame filter. Default is ‘Uploaded to this {post type plural name}’.', 'pinkcrab' ), $post_type->singular ), |
|
156 | - 'featured_image' => _x( 'Featured image', 'Label for the featured image meta box title. Default is ‘Featured image’.', 'pinkcrab' ), |
|
157 | - 'set_featured_image' => _x( 'Set featured image', 'Label for setting the featured image. Default is ‘Set featured image’.', 'pinkcrab' ), |
|
158 | - 'remove_featured_image' => _x( 'Remove featured image', 'Label for removing the featured image. Default is ‘Remove featured image’.', 'pinkcrab' ), |
|
159 | - 'use_featured_image' => _x( 'Use as featured image', 'Label in the media frame for using a featured image. Default is ‘Use as featured image’.', 'pinkcrab' ), |
|
155 | + 'uploaded_to_this_item' => wp_sprintf(_x('Uploaded to this %s', 'Label for the media frame filter. Default is ‘Uploaded to this {post type plural name}’.', 'pinkcrab'), $post_type->singular), |
|
156 | + 'featured_image' => _x('Featured image', 'Label for the featured image meta box title. Default is ‘Featured image’.', 'pinkcrab'), |
|
157 | + 'set_featured_image' => _x('Set featured image', 'Label for setting the featured image. Default is ‘Set featured image’.', 'pinkcrab'), |
|
158 | + 'remove_featured_image' => _x('Remove featured image', 'Label for removing the featured image. Default is ‘Remove featured image’.', 'pinkcrab'), |
|
159 | + 'use_featured_image' => _x('Use as featured image', 'Label in the media frame for using a featured image. Default is ‘Use as featured image’.', 'pinkcrab'), |
|
160 | 160 | 'menu_name' => $post_type->plural, |
161 | 161 | /* translators: %s: Post type plural name */ |
162 | - 'filter_items_list' => wp_sprintf( _x( 'Filter %s list', 'Label for the table views hidden heading. Default is ‘Filter {post type plural name} list’.', 'pinkcrab' ), $post_type->plural ), |
|
163 | - 'filter_by_date' => _x( 'Filter by date', 'Label for the date filter in list tables. Default is ‘Filter by date’.', 'pinkcrab' ), |
|
162 | + 'filter_items_list' => wp_sprintf(_x('Filter %s list', 'Label for the table views hidden heading. Default is ‘Filter {post type plural name} list’.', 'pinkcrab'), $post_type->plural), |
|
163 | + 'filter_by_date' => _x('Filter by date', 'Label for the date filter in list tables. Default is ‘Filter by date’.', 'pinkcrab'), |
|
164 | 164 | /* translators: %s: Post type plural name */ |
165 | - 'items_list' => wp_sprintf( _x( '%s list', 'Label for the table hidden heading. Default is ‘{post type plural name} list’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ), |
|
165 | + 'items_list' => wp_sprintf(_x('%s list', 'Label for the table hidden heading. Default is ‘{post type plural name} list’.', 'pinkcrab'), \ucfirst($post_type->plural)), |
|
166 | 166 | /* translators: %s: Post type singular name */ |
167 | - 'item_published' => wp_sprintf( _x( '%s published', 'Label used when an item is published. Default is ‘{post type singular name} published’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ), |
|
167 | + 'item_published' => wp_sprintf(_x('%s published', 'Label used when an item is published. Default is ‘{post type singular name} published’.', 'pinkcrab'), \ucfirst($post_type->singular)), |
|
168 | 168 | /* translators: %s: Post type singular name */ |
169 | - 'item_published_privately' => wp_sprintf( _x( '%s published privately', 'Label used when an item is published with private visibility. Default is ‘{post type singular name} published privately.’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ), |
|
169 | + 'item_published_privately' => wp_sprintf(_x('%s published privately', 'Label used when an item is published with private visibility. Default is ‘{post type singular name} published privately.’.', 'pinkcrab'), \ucfirst($post_type->singular)), |
|
170 | 170 | /* translators: %s: Post type singular name */ |
171 | - 'item_reverted_to_draft' => wp_sprintf( _x( '%s reverted to draft', 'Label used when an item is switched to a draft. Default is ‘{post type singular name} reverted to draft’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ), |
|
171 | + 'item_reverted_to_draft' => wp_sprintf(_x('%s reverted to draft', 'Label used when an item is switched to a draft. Default is ‘{post type singular name} reverted to draft’.', 'pinkcrab'), \ucfirst($post_type->singular)), |
|
172 | 172 | /* translators: %s: Post type singular name */ |
173 | - 'item_scheduled' => wp_sprintf( _x( '%s scheduled', 'Label used when an item is scheduled for publishing. Default is ‘{post type singular name} scheduled.’ ', 'pinkcrab' ), \ucfirst( $post_type->singular ) ), |
|
173 | + 'item_scheduled' => wp_sprintf(_x('%s scheduled', 'Label used when an item is scheduled for publishing. Default is ‘{post type singular name} scheduled.’ ', 'pinkcrab'), \ucfirst($post_type->singular)), |
|
174 | 174 | /* translators: %s: Post type singular name */ |
175 | - 'item_updated' => wp_sprintf( _x( '%s updated', 'Label used when an item is updated. Default is ‘{post type singular name} updated.’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ), |
|
175 | + 'item_updated' => wp_sprintf(_x('%s updated', 'Label used when an item is updated. Default is ‘{post type singular name} updated.’.', 'pinkcrab'), \ucfirst($post_type->singular)), |
|
176 | 176 | /* translators: %s: Post type singular name */ |
177 | - 'item_link' => wp_sprintf( _x( '%s Link', 'Title for a navigation link block variation. Default is ‘{post type singular name} Link’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ), |
|
177 | + 'item_link' => wp_sprintf(_x('%s Link', 'Title for a navigation link block variation. Default is ‘{post type singular name} Link’.', 'pinkcrab'), \ucfirst($post_type->singular)), |
|
178 | 178 | /* translators: %s: Post type singular name */ |
179 | - 'item_link_description' => wp_sprintf( _x( 'A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
179 | + 'item_link_description' => wp_sprintf(_x('A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
180 | 180 | ); |
181 | 181 | |
182 | 182 | /** |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | * @param Post_Type $cpt |
188 | 188 | * @return array<string, string> |
189 | 189 | */ |
190 | - $labels = apply_filters( Registerable_Hooks::POST_TYPE_LABELS, $post_type->filter_labels( $labels ), $post_type ); |
|
190 | + $labels = apply_filters(Registerable_Hooks::POST_TYPE_LABELS, $post_type->filter_labels($labels), $post_type); |
|
191 | 191 | |
192 | 192 | // Set the rewrite rules if not defined. |
193 | - if ( is_null( $post_type->rewrite ) ) { |
|
193 | + if (is_null($post_type->rewrite)) { |
|
194 | 194 | $post_type->rewrite = array( |
195 | 195 | 'slug' => $post_type->key, |
196 | 196 | 'with_front' => true, |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | // Set the meta cap based on its definition and if uses gutenberg. |
203 | 203 | // See https://github.com/Pink-Crab/Perique-Registerables/issues/66 |
204 | - if ( null === $post_type->map_meta_cap ) { |
|
204 | + if (null === $post_type->map_meta_cap) { |
|
205 | 205 | $meta_cap = $post_type->gutenberg ? true : false; |
206 | 206 | } else { |
207 | 207 | $meta_cap = $post_type->map_meta_cap ?? false; |
@@ -211,30 +211,30 @@ discard block |
||
211 | 211 | $args = array( |
212 | 212 | 'labels' => $labels, |
213 | 213 | 'description' => $post_type->description ?? $post_type->plural, |
214 | - 'hierarchical' => is_bool( $post_type->hierarchical ) ? $post_type->hierarchical : false, |
|
214 | + 'hierarchical' => is_bool($post_type->hierarchical) ? $post_type->hierarchical : false, |
|
215 | 215 | 'supports' => $post_type->supports, |
216 | - 'public' => is_bool( $post_type->public ) ? $post_type->public : true, |
|
217 | - 'show_ui' => is_bool( $post_type->show_ui ) ? $post_type->show_ui : true, |
|
218 | - 'show_in_menu' => is_bool( $post_type->show_in_menu ) ? $post_type->show_in_menu : true, |
|
219 | - 'show_in_admin_bar' => is_bool( $post_type->show_in_admin_bar ) ? $post_type->show_in_admin_bar : true, |
|
216 | + 'public' => is_bool($post_type->public) ? $post_type->public : true, |
|
217 | + 'show_ui' => is_bool($post_type->show_ui) ? $post_type->show_ui : true, |
|
218 | + 'show_in_menu' => is_bool($post_type->show_in_menu) ? $post_type->show_in_menu : true, |
|
219 | + 'show_in_admin_bar' => is_bool($post_type->show_in_admin_bar) ? $post_type->show_in_admin_bar : true, |
|
220 | 220 | 'menu_position' => $post_type->menu_position, |
221 | 221 | 'menu_icon' => $post_type->dashicon, |
222 | - 'show_in_nav_menus' => is_bool( $post_type->show_in_nav_menus ) ? $post_type->show_in_nav_menus : true, |
|
223 | - 'publicly_queryable' => is_bool( $post_type->publicly_queryable ) ? $post_type->publicly_queryable : true, |
|
224 | - 'exclude_from_search' => is_bool( $post_type->exclude_from_search ) ? $post_type->exclude_from_search : true, |
|
225 | - 'has_archive' => is_bool( $post_type->has_archive ) ? $post_type->has_archive : true, |
|
226 | - 'query_var' => is_bool( $post_type->query_var ) ? $post_type->query_var : false, |
|
227 | - 'can_export' => is_bool( $post_type->can_export ) ? $post_type->can_export : true, |
|
228 | - 'rewrite' => is_bool( $post_type->rewrite ) ? $post_type->rewrite : false, |
|
222 | + 'show_in_nav_menus' => is_bool($post_type->show_in_nav_menus) ? $post_type->show_in_nav_menus : true, |
|
223 | + 'publicly_queryable' => is_bool($post_type->publicly_queryable) ? $post_type->publicly_queryable : true, |
|
224 | + 'exclude_from_search' => is_bool($post_type->exclude_from_search) ? $post_type->exclude_from_search : true, |
|
225 | + 'has_archive' => is_bool($post_type->has_archive) ? $post_type->has_archive : true, |
|
226 | + 'query_var' => is_bool($post_type->query_var) ? $post_type->query_var : false, |
|
227 | + 'can_export' => is_bool($post_type->can_export) ? $post_type->can_export : true, |
|
228 | + 'rewrite' => is_bool($post_type->rewrite) ? $post_type->rewrite : false, |
|
229 | 229 | 'capability_type' => $post_type->capability_type, |
230 | 230 | 'capabilities' => $post_type->capabilities, |
231 | 231 | 'taxonomies' => $post_type->taxonomies, |
232 | - 'show_in_rest' => is_bool( $post_type->show_in_rest ) ? $post_type->show_in_rest : true, |
|
232 | + 'show_in_rest' => is_bool($post_type->show_in_rest) ? $post_type->show_in_rest : true, |
|
233 | 233 | 'rest_base' => $post_type->rest_base ?? $post_type->key, |
234 | - 'rest_controller_class' => \class_exists( $post_type->rest_controller_class ) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class, |
|
235 | - 'delete_with_user' => \is_bool( $post_type->delete_with_user ) ? $post_type->delete_with_user : null, |
|
236 | - 'template' => \is_array( $post_type->template ) ? $post_type->template : array(), |
|
237 | - 'template_lock' => \is_string( $post_type->template_lock ) ? $post_type->template_lock : false, |
|
234 | + 'rest_controller_class' => \class_exists($post_type->rest_controller_class) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class, |
|
235 | + 'delete_with_user' => \is_bool($post_type->delete_with_user) ? $post_type->delete_with_user : null, |
|
236 | + 'template' => \is_array($post_type->template) ? $post_type->template : array(), |
|
237 | + 'template_lock' => \is_string($post_type->template_lock) ? $post_type->template_lock : false, |
|
238 | 238 | 'map_meta_cap' => $meta_cap, |
239 | 239 | ); |
240 | 240 | |
@@ -247,6 +247,6 @@ discard block |
||
247 | 247 | * @return array<string, string|bool|int|null|array<string, string> |
248 | 248 | */ |
249 | 249 | /* @phpstan-ignore-next-line, this is due to apply_filters type hints being wrong. */ |
250 | - return apply_filters( Registerable_Hooks::POST_TYPE_ARGS, $post_type->filter_args( $args ), $post_type ); |
|
250 | + return apply_filters(Registerable_Hooks::POST_TYPE_ARGS, $post_type->filter_args($args), $post_type); |
|
251 | 251 | } |
252 | 252 | } |