@@ -45,10 +45,10 @@ |
||
45 | 45 | ## Unused methods |
46 | 46 | |
47 | 47 | /** @inheritDoc */ |
48 | - public function pre_boot( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
48 | + public function pre_boot(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
49 | 49 | /** @inheritDoc */ |
50 | - public function pre_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
50 | + public function pre_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
51 | 51 | /** @inheritDoc */ |
52 | - public function post_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
52 | + public function post_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
53 | 53 | |
54 | 54 | } |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | protected $default = ''; |
71 | 71 | |
72 | 72 | /** |
73 | - * The meta fields callbacks |
|
74 | - * |
|
75 | - * @var array{ |
|
76 | - * sanitize: null|callable, |
|
77 | - * permissions: null|callable, |
|
78 | - * rest_view: null|callable(mixed[]): void, |
|
79 | - * rest_update: null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment): void |
|
80 | - * } |
|
81 | - */ |
|
73 | + * The meta fields callbacks |
|
74 | + * |
|
75 | + * @var array{ |
|
76 | + * sanitize: null|callable, |
|
77 | + * permissions: null|callable, |
|
78 | + * rest_view: null|callable(mixed[]): void, |
|
79 | + * rest_update: null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment): void |
|
80 | + * } |
|
81 | + */ |
|
82 | 82 | protected array $callbacks = array( |
83 | 83 | 'sanitize' => null, |
84 | 84 | 'permissions' => null, |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | - * Sets the GET callback for REST requests. |
|
235 | - * |
|
236 | - * @param callable|null $callback |
|
237 | - * @return self |
|
238 | - */ |
|
234 | + * Sets the GET callback for REST requests. |
|
235 | + * |
|
236 | + * @param callable|null $callback |
|
237 | + * @return self |
|
238 | + */ |
|
239 | 239 | public function rest_view( ?callable $callback ): self { |
240 | 240 | $this->callbacks['rest_view'] = $callback; |
241 | 241 | return $this; |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
315 | - * Gets the GET callback for REST requests. |
|
316 | - * |
|
317 | - * @return null|callable(mixed[]): void |
|
318 | - */ |
|
315 | + * Gets the GET callback for REST requests. |
|
316 | + * |
|
317 | + * @return null|callable(mixed[]): void |
|
318 | + */ |
|
319 | 319 | public function get_rest_view(): ?callable { |
320 | 320 | return $this->callbacks['rest_view']; |
321 | 321 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected string $meta_key; |
102 | 102 | |
103 | - public function __construct( string $meta_key ) { |
|
103 | + public function __construct(string $meta_key) { |
|
104 | 104 | $this->meta_key = $meta_key; |
105 | 105 | } |
106 | 106 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $meta_type Object type meta applies to |
112 | 112 | * @return self |
113 | 113 | */ |
114 | - public function meta_type( string $meta_type ): self { |
|
114 | + public function meta_type(string $meta_type): self { |
|
115 | 115 | $this->meta_type = $meta_type; |
116 | 116 | return $this; |
117 | 117 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param string|null $object_subtype Holds a secondary object type, used for post type and taxonomy. |
123 | 123 | * @return self |
124 | 124 | */ |
125 | - public function object_subtype( ?string $object_subtype ): self { |
|
125 | + public function object_subtype(?string $object_subtype): self { |
|
126 | 126 | $this->object_subtype = $object_subtype ?? ''; |
127 | 127 | return $this; |
128 | 128 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param string $type |
135 | 135 | * @return self |
136 | 136 | */ |
137 | - public function type( string $type ): self { |
|
137 | + public function type(string $type): self { |
|
138 | 138 | $this->type = $type; |
139 | 139 | return $this; |
140 | 140 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * @param string $post_type |
146 | 146 | * @return self |
147 | 147 | */ |
148 | - public function post_type( string $post_type ): self { |
|
149 | - $this->meta_type( 'post' ); |
|
150 | - $this->object_subtype( $post_type ); |
|
148 | + public function post_type(string $post_type): self { |
|
149 | + $this->meta_type('post'); |
|
150 | + $this->object_subtype($post_type); |
|
151 | 151 | return $this; |
152 | 152 | } |
153 | 153 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param string $taxonomy |
158 | 158 | * @return self |
159 | 159 | */ |
160 | - public function taxonomy( string $taxonomy ): self { |
|
161 | - $this->meta_type( 'term' ); |
|
162 | - $this->object_subtype( $taxonomy ); |
|
160 | + public function taxonomy(string $taxonomy): self { |
|
161 | + $this->meta_type('term'); |
|
162 | + $this->object_subtype($taxonomy); |
|
163 | 163 | return $this; |
164 | 164 | } |
165 | 165 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return self |
172 | 172 | */ |
173 | - public function description( string $description ): self { |
|
173 | + public function description(string $description): self { |
|
174 | 174 | $this->description = $description; |
175 | 175 | return $this; |
176 | 176 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param bool $single Meta value is single value or array |
182 | 182 | * @return self |
183 | 183 | */ |
184 | - public function single( bool $single = true ): self { |
|
184 | + public function single(bool $single = true): self { |
|
185 | 185 | $this->single = $single; |
186 | 186 | return $this; |
187 | 187 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param mixed $default |
193 | 193 | * @return self |
194 | 194 | */ |
195 | - public function default( $default ): self { |
|
195 | + public function default($default): self { |
|
196 | 196 | $this->default = $default; |
197 | 197 | return $this; |
198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param callable(mixed):mixed $callback |
204 | 204 | * @return self |
205 | 205 | */ |
206 | - public function sanitize( callable $callback ): self { |
|
206 | + public function sanitize(callable $callback): self { |
|
207 | 207 | $this->callbacks['sanitize'] = $callback; |
208 | 208 | return $this; |
209 | 209 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param callable $callback |
215 | 215 | * @return self |
216 | 216 | */ |
217 | - public function permissions( callable $callback ): self { |
|
217 | + public function permissions(callable $callback): self { |
|
218 | 218 | $this->callbacks['permissions'] = $callback; |
219 | 219 | return $this; |
220 | 220 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param bool|array<mixed> $rest_schema|PinkCrab\WP_Rest_Schema\Argument\Argument Rest schema definitions |
226 | 226 | * @return self |
227 | 227 | */ |
228 | - public function rest_schema( $rest_schema ): self { |
|
228 | + public function rest_schema($rest_schema): self { |
|
229 | 229 | $this->rest_schema = $rest_schema; |
230 | 230 | return $this; |
231 | 231 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param callable|null $callback |
237 | 237 | * @return self |
238 | 238 | */ |
239 | - public function rest_view( ?callable $callback ): self { |
|
239 | + public function rest_view(?callable $callback): self { |
|
240 | 240 | $this->callbacks['rest_view'] = $callback; |
241 | 241 | return $this; |
242 | 242 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param null|callable(mixed,\WP_Post|\WP_Term|\WP_User|\WP_Comment):void $callback |
248 | 248 | * @return self |
249 | 249 | */ |
250 | - public function rest_update( ?callable $callback ): self { |
|
250 | + public function rest_update(?callable $callback): self { |
|
251 | 251 | $this->callbacks['rest_update'] = $callback; |
252 | 252 | return $this; |
253 | 253 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | ); |
270 | 270 | |
271 | 271 | // Set subtype. |
272 | - if ( $this->object_subtype !== null ) { |
|
272 | + if ($this->object_subtype !== null) { |
|
273 | 273 | $args['object_subtype'] = $this->object_subtype; |
274 | 274 | } |
275 | 275 | return $args; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | protected Meta_Data_Registrar $meta_data_registrar; |
39 | 39 | |
40 | - public function __construct( Meta_Data_Registrar $meta_data_registrar ) { |
|
40 | + public function __construct(Meta_Data_Registrar $meta_data_registrar) { |
|
41 | 41 | $this->meta_data_registrar = $meta_data_registrar; |
42 | 42 | } |
43 | 43 | |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | * @throws Exception If a none Additional_Meta_Data_Controller registerable is attempted to be registered. |
51 | 51 | * @throws Exception If a meta type which is not POST, USER, TERM or COMMENT is attempted to be registered. |
52 | 52 | */ |
53 | - public function register( Registerable $registerable ): void { |
|
54 | - if ( ! is_a( $registerable, Additional_Meta_Data_Controller::class ) ) { |
|
55 | - throw new Exception( 'Registerable must be an instance of Additional_Meta_Data_Controller' ); |
|
53 | + public function register(Registerable $registerable): void { |
|
54 | + if ( ! is_a($registerable, Additional_Meta_Data_Controller::class)) { |
|
55 | + throw new Exception('Registerable must be an instance of Additional_Meta_Data_Controller'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** @var Additional_Meta_Data $registerable, Validation call below catches no Additional_Meta_Data Registerables */ |
59 | - $meta_data = $this->filter_meta_data( $registerable->meta_data( array() ) ); |
|
59 | + $meta_data = $this->filter_meta_data($registerable->meta_data(array())); |
|
60 | 60 | |
61 | 61 | // Iterate through all meta data and register them. |
62 | - foreach ( $meta_data as $meta_data_item ) { |
|
63 | - switch ( $meta_data_item->get_meta_type() ) { |
|
62 | + foreach ($meta_data as $meta_data_item) { |
|
63 | + switch ($meta_data_item->get_meta_type()) { |
|
64 | 64 | case 'post': |
65 | 65 | // Throw if post type not defined. |
66 | - if ( null === $meta_data_item->get_subtype() ) { |
|
66 | + if (null === $meta_data_item->get_subtype()) { |
|
67 | 67 | throw new Exception( |
68 | 68 | sprintf( |
69 | 69 | 'A post type must be defined when attempting to register post meta with meta key : %s', |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | case 'term': |
82 | 82 | // Throw if Taxonomy not defined. |
83 | - if ( null === $meta_data_item->get_subtype() ) { |
|
83 | + if (null === $meta_data_item->get_subtype()) { |
|
84 | 84 | throw new Exception( |
85 | 85 | sprintf( |
86 | 86 | 'A taxonomy must be defined when attempting to register tern meta with meta key : %s', |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | break; |
109 | 109 | |
110 | 110 | default: |
111 | - throw new Exception( 'Unexpected meta type' ); |
|
111 | + throw new Exception('Unexpected meta type'); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * @param mixed[] $meta_data |
120 | 120 | * @return Meta_Data[] |
121 | 121 | */ |
122 | - protected function filter_meta_data( array $meta_data ): array { |
|
122 | + protected function filter_meta_data(array $meta_data): array { |
|
123 | 123 | return array_filter( |
124 | 124 | $meta_data, |
125 | - function( $e ) { |
|
126 | - return is_a( $e, Meta_Data::class ); |
|
125 | + function($e) { |
|
126 | + return is_a($e, Meta_Data::class); |
|
127 | 127 | } |
128 | 128 | ); |
129 | 129 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * @param \PinkCrab\Registerables\Module\Middleware\Registerable $registerable |
52 | 52 | * @return void |
53 | 53 | */ |
54 | - public function register( Registerable $registerable ): void { |
|
55 | - if ( ! is_a( $registerable, Shared_Meta_Box_Controller::class ) ) { |
|
54 | + public function register(Registerable $registerable): void { |
|
55 | + if ( ! is_a($registerable, Shared_Meta_Box_Controller::class)) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | |
61 | 61 | // Get the meta box and meta data. |
62 | 62 | $meta_box = $registerable->meta_box(); |
63 | - $meta_data = $registerable->meta_data( array() ); |
|
63 | + $meta_data = $registerable->meta_data(array()); |
|
64 | 64 | |
65 | 65 | // Register the meta box. |
66 | - $this->meta_box_registrar->register( $meta_box ); |
|
66 | + $this->meta_box_registrar->register($meta_box); |
|
67 | 67 | |
68 | 68 | // Register all meta data. |
69 | - foreach ( $this->filter_meta_data( $meta_data ) as $meta_field ) { |
|
69 | + foreach ($this->filter_meta_data($meta_data) as $meta_field) { |
|
70 | 70 | // Register meta data for each post type. |
71 | - foreach ( $meta_box->screen as $post_type ) { |
|
72 | - $this->meta_data_registrar->register_for_post_type( $meta_field, $post_type ); |
|
71 | + foreach ($meta_box->screen as $post_type) { |
|
72 | + $this->meta_data_registrar->register_for_post_type($meta_field, $post_type); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | * @param mixed[] $meta_data |
82 | 82 | * @return Meta_Data[] |
83 | 83 | */ |
84 | - protected function filter_meta_data( array $meta_data ): array { |
|
84 | + protected function filter_meta_data(array $meta_data): array { |
|
85 | 85 | return array_filter( |
86 | 86 | $meta_data, |
87 | - function( $e ) { |
|
88 | - return is_a( $e, Meta_Data::class ); |
|
87 | + function($e) { |
|
88 | + return is_a($e, Meta_Data::class); |
|
89 | 89 | } |
90 | 90 | ); |
91 | 91 | } |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | * @param \PinkCrab\Registerables\Module\Middleware\Registerable $registerable |
52 | 52 | * @return void |
53 | 53 | */ |
54 | - public function register( Registerable $registerable ): void { |
|
54 | + public function register(Registerable $registerable): void { |
|
55 | 55 | /** @var Post_Type $registerable, Validation call below catches no Post_Type Registerables */ |
56 | 56 | |
57 | - if ( ! $this->validator->validate( $registerable ) ) { |
|
57 | + if ( ! $this->validator->validate($registerable)) { |
|
58 | 58 | throw new Exception( |
59 | 59 | sprintf( |
60 | 60 | 'Failed validating post type model(%s) with errors: %s', |
61 | - get_class( $registerable ), |
|
62 | - join( ', ', $this->validator->get_errors() ) |
|
61 | + get_class($registerable), |
|
62 | + join(', ', $this->validator->get_errors()) |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | } |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | // Attempt to register the post type. |
68 | 68 | try { |
69 | 69 | /* @phpstan-ignore-next-line */ |
70 | - $result = register_post_type( $registerable->key, $this->compile_args( $registerable ) ); |
|
71 | - if ( is_a( $result, \WP_Error::class ) ) { |
|
72 | - throw new Exception( join( $result->get_error_messages() ) ); |
|
70 | + $result = register_post_type($registerable->key, $this->compile_args($registerable)); |
|
71 | + if (is_a($result, \WP_Error::class)) { |
|
72 | + throw new Exception(join($result->get_error_messages())); |
|
73 | 73 | } |
74 | - } catch ( \Throwable $th ) { |
|
75 | - throw new Exception( "Failed to register {$registerable->key} post type ({$th->getMessage()})" ); |
|
74 | + } catch (\Throwable $th) { |
|
75 | + throw new Exception("Failed to register {$registerable->key} post type ({$th->getMessage()})"); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Register all meta data for post type. |
79 | - $this->register_meta_data( $registerable ); |
|
79 | + $this->register_meta_data($registerable); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,18 +85,18 @@ discard block |
||
85 | 85 | * @param \PinkCrab\Registerables\Post_Type $post_type |
86 | 86 | * @return void |
87 | 87 | */ |
88 | - protected function register_meta_data( Post_Type $post_type ): void { |
|
88 | + protected function register_meta_data(Post_Type $post_type): void { |
|
89 | 89 | |
90 | 90 | // Get all meta fields for post_type. |
91 | - $meta_fields = $post_type->meta_data( array() ); |
|
91 | + $meta_fields = $post_type->meta_data(array()); |
|
92 | 92 | // Attempt to register all Meta for post_type. |
93 | 93 | try { |
94 | - foreach ( $meta_fields as $meta_field ) { |
|
94 | + foreach ($meta_fields as $meta_field) { |
|
95 | 95 | $this->meta_data_registrar |
96 | - ->register_for_post_type( $meta_field, $post_type->key ); |
|
96 | + ->register_for_post_type($meta_field, $post_type->key); |
|
97 | 97 | } |
98 | - } catch ( \Throwable $th ) { |
|
99 | - throw new Exception( $th->getMessage() ); |
|
98 | + } catch (\Throwable $th) { |
|
99 | + throw new Exception($th->getMessage()); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -108,64 +108,64 @@ discard block |
||
108 | 108 | * @param \PinkCrab\Registerables\Post_Type $post_type |
109 | 109 | * @return array<string, string|int|array<string, string>> |
110 | 110 | */ |
111 | - protected function compile_args( Post_Type $post_type ): array { |
|
111 | + protected function compile_args(Post_Type $post_type): array { |
|
112 | 112 | // Create the labels. |
113 | 113 | $labels = array( |
114 | 114 | 'name' => $post_type->plural, |
115 | 115 | 'singular_name' => $post_type->singular, |
116 | - 'add_new' => _x( 'Add New', 'Add new post label of custom post type', 'pinkcrab' ), |
|
116 | + 'add_new' => _x('Add New', 'Add new post label of custom post type', 'pinkcrab'), |
|
117 | 117 | /* translators: %s: Post type singular name */ |
118 | - '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 ), |
|
118 | + '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), |
|
119 | 119 | /* translators: %s: Post type singular name */ |
120 | - 'edit_item' => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
120 | + 'edit_item' => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
121 | 121 | /* translators: %s: Post type singular name */ |
122 | - '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 ), |
|
122 | + '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), |
|
123 | 123 | /* translators: %s: Post type singular name */ |
124 | - 'view_item' => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
124 | + 'view_item' => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
125 | 125 | /* translators: %s: Post type plural name */ |
126 | - 'view_items' => wp_sprintf( _x( 'View %s', 'Label for viewing post type archives. Default is ‘View {post type plural name}’.', 'pinkcrab' ), $post_type->plural ), |
|
126 | + 'view_items' => wp_sprintf(_x('View %s', 'Label for viewing post type archives. Default is ‘View {post type plural name}’.', 'pinkcrab'), $post_type->plural), |
|
127 | 127 | /* translators: %s: Post type singular name */ |
128 | - 'search_items' => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {post type plural name}’.', 'pinkcrab' ), $post_type->singular ), |
|
128 | + 'search_items' => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {post type plural name}’.', 'pinkcrab'), $post_type->singular), |
|
129 | 129 | /* translators: %s: Post type plural name */ |
130 | - '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 ), |
|
130 | + '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), |
|
131 | 131 | /* translators: %s: Post type plural name */ |
132 | - '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 ), |
|
132 | + '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), |
|
133 | 133 | /* translators: %s: Post type singular name */ |
134 | - '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 ), |
|
134 | + '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), |
|
135 | 135 | /* translators: %s: Post type singular name */ |
136 | - '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 ), |
|
136 | + '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), |
|
137 | 137 | /* translators: %s: Post type plural name */ |
138 | - 'archives' => wp_sprintf( _x( '%s Archives', ' Label for archives in nav menus. Default is ‘Post Archives’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ), |
|
138 | + 'archives' => wp_sprintf(_x('%s Archives', ' Label for archives in nav menus. Default is ‘Post Archives’.', 'pinkcrab'), \ucfirst($post_type->plural)), |
|
139 | 139 | /* translators: %s: Post type plural name */ |
140 | - 'attributes' => wp_sprintf( _x( '%s Attributes', 'Label for the attributes meta box. Default is ‘{post type plural name} Attributes’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ), |
|
140 | + 'attributes' => wp_sprintf(_x('%s Attributes', 'Label for the attributes meta box. Default is ‘{post type plural name} Attributes’.', 'pinkcrab'), \ucfirst($post_type->plural)), |
|
141 | 141 | /* translators: %s: Post type singular name */ |
142 | - '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 ), |
|
142 | + '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), |
|
143 | 143 | /* translators: %s: Post type singular name */ |
144 | - '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 ), |
|
145 | - 'featured_image' => _x( 'Featured image', 'Label for the featured image meta box title. Default is ‘Featured image’.', 'pinkcrab' ), |
|
146 | - 'set_featured_image' => _x( 'Set featured image', 'Label for setting the featured image. Default is ‘Set featured image’.', 'pinkcrab' ), |
|
147 | - 'remove_featured_image' => _x( 'Remove featured image', 'Label for removing the featured image. Default is ‘Remove featured image’.', 'pinkcrab' ), |
|
148 | - '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' ), |
|
144 | + '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), |
|
145 | + 'featured_image' => _x('Featured image', 'Label for the featured image meta box title. Default is ‘Featured image’.', 'pinkcrab'), |
|
146 | + 'set_featured_image' => _x('Set featured image', 'Label for setting the featured image. Default is ‘Set featured image’.', 'pinkcrab'), |
|
147 | + 'remove_featured_image' => _x('Remove featured image', 'Label for removing the featured image. Default is ‘Remove featured image’.', 'pinkcrab'), |
|
148 | + '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'), |
|
149 | 149 | 'menu_name' => $post_type->plural, |
150 | 150 | /* translators: %s: Post type plural name */ |
151 | - '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 ), |
|
152 | - 'filter_by_date' => _x( 'Filter by date', 'Label for the date filter in list tables. Default is ‘Filter by date’.', 'pinkcrab' ), |
|
151 | + '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), |
|
152 | + 'filter_by_date' => _x('Filter by date', 'Label for the date filter in list tables. Default is ‘Filter by date’.', 'pinkcrab'), |
|
153 | 153 | /* translators: %s: Post type plural name */ |
154 | - '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 ) ), |
|
154 | + '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)), |
|
155 | 155 | /* translators: %s: Post type singular name */ |
156 | - '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 ) ), |
|
156 | + '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)), |
|
157 | 157 | /* translators: %s: Post type singular name */ |
158 | - '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 ) ), |
|
158 | + '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)), |
|
159 | 159 | /* translators: %s: Post type singular name */ |
160 | - '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 ) ), |
|
160 | + '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)), |
|
161 | 161 | /* translators: %s: Post type singular name */ |
162 | - '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 ) ), |
|
162 | + '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)), |
|
163 | 163 | /* translators: %s: Post type singular name */ |
164 | - '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 ) ), |
|
164 | + '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)), |
|
165 | 165 | /* translators: %s: Post type singular name */ |
166 | - '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 ) ), |
|
166 | + '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)), |
|
167 | 167 | /* translators: %s: Post type singular name */ |
168 | - '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 ), |
|
168 | + '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), |
|
169 | 169 | ); |
170 | 170 | |
171 | 171 | /** |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | * @param Post_Type $cpt |
177 | 177 | * @return array<string, string> |
178 | 178 | */ |
179 | - $labels = apply_filters( Registerable_Hooks::POST_TYPE_LABELS, $post_type->filter_labels( $labels ), $post_type ); |
|
179 | + $labels = apply_filters(Registerable_Hooks::POST_TYPE_LABELS, $post_type->filter_labels($labels), $post_type); |
|
180 | 180 | |
181 | 181 | // Set the rewrite rules if not defined. |
182 | - if ( is_null( $post_type->rewrite ) ) { |
|
182 | + if (is_null($post_type->rewrite)) { |
|
183 | 183 | $post_type->rewrite = array( |
184 | 184 | 'slug' => $post_type->key, |
185 | 185 | 'with_front' => true, |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | // Set the meta cap based on its definition and if uses gutenberg. |
192 | 192 | // See https://github.com/Pink-Crab/Perique-Registerables/issues/66 |
193 | - if ( null === $post_type->map_meta_cap ) { |
|
193 | + if (null === $post_type->map_meta_cap) { |
|
194 | 194 | $meta_cap = $post_type->gutenberg ? true : false; |
195 | 195 | } else { |
196 | 196 | $meta_cap = $post_type->map_meta_cap ?? false; |
@@ -200,30 +200,30 @@ discard block |
||
200 | 200 | $args = array( |
201 | 201 | 'labels' => $labels, |
202 | 202 | 'description' => $post_type->description ?? $post_type->plural, |
203 | - 'hierarchical' => is_bool( $post_type->hierarchical ) ? $post_type->hierarchical : false, |
|
203 | + 'hierarchical' => is_bool($post_type->hierarchical) ? $post_type->hierarchical : false, |
|
204 | 204 | 'supports' => $post_type->supports, |
205 | - 'public' => is_bool( $post_type->public ) ? $post_type->public : true, |
|
206 | - 'show_ui' => is_bool( $post_type->show_ui ) ? $post_type->show_ui : true, |
|
207 | - 'show_in_menu' => is_bool( $post_type->show_in_menu ) ? $post_type->show_in_menu : true, |
|
208 | - 'show_in_admin_bar' => is_bool( $post_type->show_in_admin_bar ) ? $post_type->show_in_admin_bar : true, |
|
205 | + 'public' => is_bool($post_type->public) ? $post_type->public : true, |
|
206 | + 'show_ui' => is_bool($post_type->show_ui) ? $post_type->show_ui : true, |
|
207 | + 'show_in_menu' => is_bool($post_type->show_in_menu) ? $post_type->show_in_menu : true, |
|
208 | + 'show_in_admin_bar' => is_bool($post_type->show_in_admin_bar) ? $post_type->show_in_admin_bar : true, |
|
209 | 209 | 'menu_position' => $post_type->menu_position, |
210 | 210 | 'menu_icon' => $post_type->dashicon, |
211 | - 'show_in_nav_menus' => is_bool( $post_type->show_in_nav_menus ) ? $post_type->show_in_nav_menus : true, |
|
212 | - 'publicly_queryable' => is_bool( $post_type->publicly_queryable ) ? $post_type->publicly_queryable : true, |
|
213 | - 'exclude_from_search' => is_bool( $post_type->exclude_from_search ) ? $post_type->exclude_from_search : true, |
|
214 | - 'has_archive' => is_bool( $post_type->has_archive ) ? $post_type->has_archive : true, |
|
215 | - 'query_var' => is_bool( $post_type->query_var ) ? $post_type->query_var : false, |
|
216 | - 'can_export' => is_bool( $post_type->can_export ) ? $post_type->can_export : true, |
|
217 | - 'rewrite' => is_bool( $post_type->rewrite ) ? $post_type->rewrite : false, |
|
211 | + 'show_in_nav_menus' => is_bool($post_type->show_in_nav_menus) ? $post_type->show_in_nav_menus : true, |
|
212 | + 'publicly_queryable' => is_bool($post_type->publicly_queryable) ? $post_type->publicly_queryable : true, |
|
213 | + 'exclude_from_search' => is_bool($post_type->exclude_from_search) ? $post_type->exclude_from_search : true, |
|
214 | + 'has_archive' => is_bool($post_type->has_archive) ? $post_type->has_archive : true, |
|
215 | + 'query_var' => is_bool($post_type->query_var) ? $post_type->query_var : false, |
|
216 | + 'can_export' => is_bool($post_type->can_export) ? $post_type->can_export : true, |
|
217 | + 'rewrite' => is_bool($post_type->rewrite) ? $post_type->rewrite : false, |
|
218 | 218 | 'capability_type' => $post_type->capability_type, |
219 | 219 | 'capabilities' => $post_type->capabilities, |
220 | 220 | 'taxonomies' => $post_type->taxonomies, |
221 | - 'show_in_rest' => is_bool( $post_type->show_in_rest ) ? $post_type->show_in_rest : true, |
|
221 | + 'show_in_rest' => is_bool($post_type->show_in_rest) ? $post_type->show_in_rest : true, |
|
222 | 222 | 'rest_base' => $post_type->rest_base ?? $post_type->key, |
223 | - 'rest_controller_class' => \class_exists( $post_type->rest_controller_class ) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class, |
|
224 | - 'delete_with_user' => \is_bool( $post_type->delete_with_user ) ? $post_type->delete_with_user : null, |
|
225 | - 'template' => \is_array( $post_type->template ) ? $post_type->template : array(), |
|
226 | - 'template_lock' => \is_string( $post_type->template_lock ) ? $post_type->template_lock : false, |
|
223 | + 'rest_controller_class' => \class_exists($post_type->rest_controller_class) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class, |
|
224 | + 'delete_with_user' => \is_bool($post_type->delete_with_user) ? $post_type->delete_with_user : null, |
|
225 | + 'template' => \is_array($post_type->template) ? $post_type->template : array(), |
|
226 | + 'template_lock' => \is_string($post_type->template_lock) ? $post_type->template_lock : false, |
|
227 | 227 | 'map_meta_cap' => $meta_cap, |
228 | 228 | ); |
229 | 229 | |
@@ -236,6 +236,6 @@ discard block |
||
236 | 236 | * @return array<string, string|bool|int|null|array<string, string> |
237 | 237 | */ |
238 | 238 | /* @phpstan-ignore-next-line, this is due to apply_filters type hints being wrong. */ |
239 | - return apply_filters( Registerable_Hooks::POST_TYPE_ARGS, $post_type->filter_args( $args ), $post_type ); |
|
239 | + return apply_filters(Registerable_Hooks::POST_TYPE_ARGS, $post_type->filter_args($args), $post_type); |
|
240 | 240 | } |
241 | 241 | } |
@@ -35,5 +35,5 @@ |
||
35 | 35 | * @param \PinkCrab\Registerables\Module\Middleware\Registerable $registerable |
36 | 36 | * @return void |
37 | 37 | */ |
38 | - public function register( Registerable $registerable ): void; |
|
38 | + public function register(Registerable $registerable): void; |
|
39 | 39 | } |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | * @param \PinkCrab\Registerables\Module\Middleware\Registerable $registerable |
52 | 52 | * @return void |
53 | 53 | */ |
54 | - public function register( Registerable $registerable ): void { |
|
54 | + public function register(Registerable $registerable): void { |
|
55 | 55 | /** @var Taxonomy $registerable, Validation call below catches no Post_Type Registerables */ |
56 | 56 | |
57 | - if ( ! $this->validator->validate( $registerable ) ) { |
|
57 | + if ( ! $this->validator->validate($registerable)) { |
|
58 | 58 | throw new Exception( |
59 | 59 | sprintf( |
60 | 60 | 'Failed validating taxonomy model(%s) with errors: %s', |
61 | - get_class( $registerable ), |
|
62 | - join( ', ', $this->validator->get_errors() ) |
|
61 | + get_class($registerable), |
|
62 | + join(', ', $this->validator->get_errors()) |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | } |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | $registerable->slug, |
71 | 71 | $registerable->object_type, |
72 | 72 | /* @phpstan-ignore-next-line */ |
73 | - $this->compile_args( $registerable ) |
|
73 | + $this->compile_args($registerable) |
|
74 | 74 | ); |
75 | 75 | |
76 | - if ( is_a( $result, \WP_Error::class ) ) { |
|
77 | - throw new Exception( join( $result->get_error_messages() ) ); |
|
76 | + if (is_a($result, \WP_Error::class)) { |
|
77 | + throw new Exception(join($result->get_error_messages())); |
|
78 | 78 | } |
79 | - } catch ( \Throwable $th ) { |
|
80 | - throw new Exception( "Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})" ); |
|
79 | + } catch (\Throwable $th) { |
|
80 | + throw new Exception("Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})"); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // Register any associated meta data. |
84 | - $this->register_meta_data( $registerable ); |
|
84 | + $this->register_meta_data($registerable); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -91,18 +91,18 @@ discard block |
||
91 | 91 | * @param \PinkCrab\Registerables\Taxonomy $taxonomy |
92 | 92 | * @return void |
93 | 93 | */ |
94 | - protected function register_meta_data( Taxonomy $taxonomy ): void { |
|
94 | + protected function register_meta_data(Taxonomy $taxonomy): void { |
|
95 | 95 | |
96 | 96 | // Get all meta fields for taxonomy. |
97 | - $meta_fields = $taxonomy->meta_data( array() ); |
|
97 | + $meta_fields = $taxonomy->meta_data(array()); |
|
98 | 98 | |
99 | 99 | // Attempt to register all Meta for taxonomy. |
100 | 100 | try { |
101 | - foreach ( $meta_fields as $meta_field ) { |
|
102 | - $this->meta_data_registrar->register_for_term( $meta_field, $taxonomy->slug ); |
|
101 | + foreach ($meta_fields as $meta_field) { |
|
102 | + $this->meta_data_registrar->register_for_term($meta_field, $taxonomy->slug); |
|
103 | 103 | } |
104 | - } catch ( \Throwable $th ) { |
|
105 | - throw new Exception( $th->getMessage() ); |
|
104 | + } catch (\Throwable $th) { |
|
105 | + throw new Exception($th->getMessage()); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -112,59 +112,59 @@ discard block |
||
112 | 112 | * @param \PinkCrab\Registerables\Taxonomy $taxonomy |
113 | 113 | * @return array<string, string|int|array<string, string>> |
114 | 114 | */ |
115 | - protected function compile_args( Taxonomy $taxonomy ): array { |
|
115 | + protected function compile_args(Taxonomy $taxonomy): array { |
|
116 | 116 | // Create the labels. |
117 | 117 | $base_labels = array( |
118 | 118 | 'name' => $taxonomy->plural, |
119 | 119 | 'singular_name' => $taxonomy->singular, |
120 | - 'menu_name' => \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ), |
|
120 | + 'menu_name' => \ucfirst(\esc_attr($taxonomy->plural ?? '')), |
|
121 | 121 | /* translators: %s: Taxonomy plural name */ |
122 | - 'search_items' => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
122 | + 'search_items' => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
123 | 123 | /* translators: %s: Taxonomy plural name */ |
124 | - 'popular_items' => wp_sprintf( _x( 'Popular %s', 'Label for the popular terms', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
124 | + 'popular_items' => wp_sprintf(_x('Popular %s', 'Label for the popular terms', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
125 | 125 | /* translators: %s: Taxonomy singular name */ |
126 | - 'edit_item' => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
126 | + 'edit_item' => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
127 | 127 | /* translators: %s: Taxonomy singular name */ |
128 | - 'view_item' => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
128 | + 'view_item' => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
129 | 129 | /* translators: %s: Taxonomy singular name */ |
130 | - 'update_item' => wp_sprintf( _x( 'Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
130 | + 'update_item' => wp_sprintf(_x('Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
131 | 131 | /* translators: %s: Taxonomy singular name */ |
132 | - '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 ?? '' ) ), |
|
132 | + '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 ?? '')), |
|
133 | 133 | /* translators: %s: Taxonomy singular name */ |
134 | - '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 ?? '' ) ), |
|
134 | + '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 ?? '')), |
|
135 | 135 | /* translators: %s: Taxonomy plural name */ |
136 | - '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 ?? '' ) ), |
|
136 | + '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 ?? '')), |
|
137 | 137 | /* translators: %s: Taxonomy plural name */ |
138 | - '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 ?? '' ) ) ), |
|
138 | + '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 ?? ''))), |
|
139 | 139 | /* translators: %s: Taxonomy plural name */ |
140 | - '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 ?? '' ) ) ), |
|
140 | + '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 ?? ''))), |
|
141 | 141 | /* translators: %s: Taxonomy plural name */ |
142 | - '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 ?? '' ) ) ), |
|
143 | - 'most_used' => _x( 'Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab' ), |
|
142 | + '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 ?? ''))), |
|
143 | + 'most_used' => _x('Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab'), |
|
144 | 144 | /* translators: %s: Taxonomy plural name */ |
145 | - '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 ?? '' ) ) ), |
|
145 | + '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 ?? ''))), |
|
146 | 146 | /* translators: %s: Taxonomy singular name */ |
147 | - '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 ?? '' ) ) ), |
|
147 | + '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 ?? ''))), |
|
148 | 148 | /* translators: %s: Taxonomy singular name */ |
149 | - '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 ?? '' ) ), |
|
149 | + '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 ?? '')), |
|
150 | 150 | ); |
151 | 151 | |
152 | 152 | $tag_labels = array( |
153 | 153 | /* translators: %s: Taxonomy plural name */ |
154 | - '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 ?? '' ) ), |
|
154 | + '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 ?? '')), |
|
155 | 155 | /* translators: %s: Taxonomy plural name */ |
156 | - '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 ?? '' ) ), |
|
156 | + '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 ?? '')), |
|
157 | 157 | /* translators: %s: Taxonomy plural name */ |
158 | - '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 ?? '' ) ), |
|
158 | + '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 ?? '')), |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | $hierarchical_labels = array( |
162 | 162 | /* translators: %s: Taxonomy singular name */ |
163 | - '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 ?? '' ) ), |
|
163 | + '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 ?? '')), |
|
164 | 164 | /* translators: %s: Taxonomy singular name */ |
165 | - 'parent_item' => wp_sprintf( _x( 'Parent %s', 'Label for the parent term', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
165 | + 'parent_item' => wp_sprintf(_x('Parent %s', 'Label for the parent term', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
166 | 166 | /* translators: %s: Taxonomy singular name */ |
167 | - '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 ?? '' ) ), |
|
167 | + '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 ?? '')), |
|
168 | 168 | ); |
169 | 169 | |
170 | 170 | $labels = array_merge( |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param Taxonomy $taxonomy |
181 | 181 | * @return array<string, string> |
182 | 182 | */ |
183 | - $labels = apply_filters( Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels( $labels ), $taxonomy ); |
|
183 | + $labels = apply_filters(Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels($labels), $taxonomy); |
|
184 | 184 | |
185 | 185 | // Compose args. |
186 | 186 | $args = array( |
@@ -226,6 +226,6 @@ discard block |
||
226 | 226 | * @return array<string, string|bool|int|null|array<string, string> |
227 | 227 | */ |
228 | 228 | /* @phpstan-ignore-next-line, this is due to apply_filters type hints being wrong. */ |
229 | - return apply_filters( Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args( $args ), $taxonomy ); |
|
229 | + return apply_filters(Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args($args), $taxonomy); |
|
230 | 230 | } |
231 | 231 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | class Taxonomy_Validator extends Abstract_Validator { |
33 | 33 | |
34 | - protected const REQUIRED_FIELDS = array( 'slug', 'singular', 'plural' ); |
|
34 | + protected const REQUIRED_FIELDS = array('slug', 'singular', 'plural'); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Validates the class passed. |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | * @param \PinkCrab\Registerables\Module\Middleware\Registerable $object |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function validate( Registerable $object ): bool { |
|
42 | + public function validate(Registerable $object): bool { |
|
43 | 43 | // If this is not a valid taxonomy, just bail here. |
44 | - if ( ! is_a( $object, Taxonomy::class ) ) { |
|
45 | - $this->add_error( sprintf( '%s is not a valid Taxonomy Model', get_class( $object ) ) ); |
|
44 | + if ( ! is_a($object, Taxonomy::class)) { |
|
45 | + $this->add_error(sprintf('%s is not a valid Taxonomy Model', get_class($object))); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /* @var Taxonomy $object, already confirmed as a Taxonomy */ |
50 | 50 | |
51 | 51 | // Ensure all required fields are set. |
52 | - $this->has_required_fields( $object ); |
|
52 | + $this->has_required_fields($object); |
|
53 | 53 | |
54 | 54 | // Check if the passed object has any errors. |
55 | 55 | return ! $this->has_errors(); |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | * @param Taxonomy $taxonomy |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - protected function has_required_fields( Taxonomy $taxonomy ): void { |
|
65 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
66 | - if ( ! is_string( $taxonomy->{$field} ) |
|
67 | - || \mb_strlen( $taxonomy->{$field} ) === 0 |
|
64 | + protected function has_required_fields(Taxonomy $taxonomy): void { |
|
65 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
66 | + if ( ! is_string($taxonomy->{$field} ) |
|
67 | + || \mb_strlen($taxonomy->{$field} ) === 0 |
|
68 | 68 | ) { |
69 | - $this->add_error( sprintf( '%s is not set on %s Taxonomy Model', $field, get_class( $taxonomy ) ) ); |
|
69 | + $this->add_error(sprintf('%s is not set on %s Taxonomy Model', $field, get_class($taxonomy))); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | class Post_Type_Validator extends Abstract_Validator { |
33 | 33 | |
34 | - protected const REQUIRED_FIELDS = array( 'key', 'singular', 'plural' ); |
|
34 | + protected const REQUIRED_FIELDS = array('key', 'singular', 'plural'); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Validates the class passed. |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | * @param \PinkCrab\Registerables\Module\Middleware\Registerable $object |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function validate( Registerable $object ): bool { |
|
42 | + public function validate(Registerable $object): bool { |
|
43 | 43 | // If this is not a valid post type, just bail here. |
44 | - if ( ! is_a( $object, Post_Type::class ) ) { |
|
45 | - $this->add_error( sprintf( '%s is not a valid Post Type Model', get_class( $object ) ) ); |
|
44 | + if ( ! is_a($object, Post_Type::class)) { |
|
45 | + $this->add_error(sprintf('%s is not a valid Post Type Model', get_class($object))); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /* @var Post_Type $object, already confirmed as a post type */ |
50 | 50 | |
51 | 51 | // Ensure all required fields are set. |
52 | - $this->has_required_fields( $object ); |
|
52 | + $this->has_required_fields($object); |
|
53 | 53 | |
54 | 54 | // Check if the passed object has any errors. |
55 | 55 | return ! $this->has_errors(); |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | * @param Post_Type $post_type |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - protected function has_required_fields( Post_Type $post_type ): void { |
|
65 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
66 | - if ( ! is_string( $post_type->{$field} ) |
|
67 | - || \mb_strlen( $post_type->{$field} ) === 0 |
|
64 | + protected function has_required_fields(Post_Type $post_type): void { |
|
65 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
66 | + if ( ! is_string($post_type->{$field} ) |
|
67 | + || \mb_strlen($post_type->{$field} ) === 0 |
|
68 | 68 | ) { |
69 | - $this->add_error( sprintf( '%s is not set on %s Post Type Model', $field, get_class( $post_type ) ) ); |
|
69 | + $this->add_error(sprintf('%s is not set on %s Post Type Model', $field, get_class($post_type))); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |