@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | class Meta_Box_Validator extends Abstract_Validator { |
34 | 34 | |
35 | - protected const REQUIRED_FIELDS = array( 'key', 'label' ); |
|
35 | + protected const REQUIRED_FIELDS = array('key', 'label'); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Validates the class passed. |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param \PinkCrab\Registerables\Module\Middleware\Registerable $object_instance |
41 | 41 | * @return bool |
42 | 42 | */ |
43 | - public function validate( Registerable $object_instance ): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass |
|
43 | + public function validate(Registerable $object_instance): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass |
|
44 | 44 | return false; //no op |
45 | 45 | } |
46 | 46 | |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | * @param mixed $meta_box |
51 | 51 | * @return bool |
52 | 52 | */ |
53 | - public function verify_meta_box( $meta_box ): bool { |
|
53 | + public function verify_meta_box($meta_box): bool { |
|
54 | 54 | // If this is not a valid post type, just bail here. |
55 | - if ( ! is_object( $meta_box ) || ! is_a( $meta_box, Meta_Box::class ) ) { |
|
56 | - $this->add_error( sprintf( '%s is not a valid Meta Box Model', is_object( $meta_box ) ? get_class( $meta_box ) : \gettype( $meta_box ) ) ); |
|
55 | + if ( ! is_object($meta_box) || ! is_a($meta_box, Meta_Box::class)) { |
|
56 | + $this->add_error(sprintf('%s is not a valid Meta Box Model', is_object($meta_box) ? get_class($meta_box) : \gettype($meta_box))); |
|
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | |
60 | 60 | /* @var Meta_Box $object, already confirmed as a post type */ |
61 | 61 | |
62 | 62 | // Ensure all required fields are set. |
63 | - $this->has_required_fields( $meta_box ); |
|
63 | + $this->has_required_fields($meta_box); |
|
64 | 64 | |
65 | 65 | // Ensure can render view. |
66 | - $this->has_valid_view( $meta_box ); |
|
66 | + $this->has_valid_view($meta_box); |
|
67 | 67 | |
68 | 68 | // Check if the passed object has any errors. |
69 | 69 | return ! $this->has_errors(); |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * @param Meta_Box $meta_box |
76 | 76 | * @return void |
77 | 77 | */ |
78 | - protected function has_required_fields( Meta_Box $meta_box ): void { |
|
79 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
80 | - if ( ! is_string( $meta_box->{$field} ) |
|
81 | - || \mb_strlen( $meta_box->{$field} ) === 0 |
|
78 | + protected function has_required_fields(Meta_Box $meta_box): void { |
|
79 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
80 | + if ( ! is_string($meta_box->{$field} ) |
|
81 | + || \mb_strlen($meta_box->{$field} ) === 0 |
|
82 | 82 | ) { |
83 | - $this->add_error( sprintf( '%s is not set on %s Meta Box Model', $field, get_class( $meta_box ) ) ); |
|
83 | + $this->add_error(sprintf('%s is not set on %s Meta Box Model', $field, get_class($meta_box))); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | * @param \PinkCrab\Registerables\Meta_Box $meta_box |
93 | 93 | * @return void |
94 | 94 | */ |
95 | - protected function has_valid_view( Meta_Box $meta_box ): void { |
|
96 | - if ( ! \is_callable( $meta_box->view ) |
|
97 | - && ( ! is_string( $meta_box->view_template ) || \mb_strlen( $meta_box->view_template ) === 0 ) |
|
95 | + protected function has_valid_view(Meta_Box $meta_box): void { |
|
96 | + if ( ! \is_callable($meta_box->view) |
|
97 | + && ( ! is_string($meta_box->view_template) || \mb_strlen($meta_box->view_template) === 0) |
|
98 | 98 | ) { |
99 | - $this->add_error( sprintf( '%s doesn\'t have a valid view defined.', get_class( $meta_box ) ) ); |
|
99 | + $this->add_error(sprintf('%s doesn\'t have a valid view defined.', get_class($meta_box))); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @param string $key |
109 | 109 | */ |
110 | - final public function __construct( string $key ) { |
|
110 | + final public function __construct(string $key) { |
|
111 | 111 | $this->key = $key; |
112 | 112 | } |
113 | 113 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * @param string $key |
118 | 118 | * @return self |
119 | 119 | */ |
120 | - public static function normal( string $key ): self { |
|
121 | - $meta_box = new static( $key ); |
|
120 | + public static function normal(string $key): self { |
|
121 | + $meta_box = new static($key); |
|
122 | 122 | $meta_box->context = 'normal'; |
123 | 123 | return $meta_box; |
124 | 124 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param string $key |
130 | 130 | * @return self |
131 | 131 | */ |
132 | - public static function side( string $key ): self { |
|
133 | - $meta_box = new static( $key ); |
|
132 | + public static function side(string $key): self { |
|
133 | + $meta_box = new static($key); |
|
134 | 134 | $meta_box->context = 'side'; |
135 | 135 | return $meta_box; |
136 | 136 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param string $label |
142 | 142 | * @return self |
143 | 143 | */ |
144 | - public function label( string $label ): self { |
|
144 | + public function label(string $label): self { |
|
145 | 145 | $this->label = $label; |
146 | 146 | return $this; |
147 | 147 | } |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @param string|array<mixed>|\WP_Screen $screen |
153 | 153 | * @return self |
154 | 154 | */ |
155 | - public function screen( $screen ): self { |
|
156 | - array_push( $this->screen, $screen ); |
|
155 | + public function screen($screen): self { |
|
156 | + array_push($this->screen, $screen); |
|
157 | 157 | return $this; |
158 | 158 | } |
159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param array<string, mixed> $view_vars |
164 | 164 | * @return self |
165 | 165 | */ |
166 | - public function view_vars( array $view_vars ): self { |
|
166 | + public function view_vars(array $view_vars): self { |
|
167 | 167 | $this->view_vars = $view_vars; |
168 | 168 | return $this; |
169 | 169 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param string $view_template |
176 | 176 | * @return self |
177 | 177 | */ |
178 | - public function view_template( string $view_template ): self { |
|
178 | + public function view_template(string $view_template): self { |
|
179 | 179 | $this->view_template = $view_template; |
180 | 180 | return $this; |
181 | 181 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param callable $view_callback |
188 | 188 | * @return self |
189 | 189 | */ |
190 | - public function view( $view_callback ): self { |
|
190 | + public function view($view_callback): self { |
|
191 | 191 | $this->view = $view_callback; |
192 | 192 | return $this; |
193 | 193 | } |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param int $params |
202 | 202 | * @return self |
203 | 203 | */ |
204 | - public function add_action( string $hook, callable $callback, int $priority = 10, int $params = 1 ): self { |
|
205 | - $this->actions[ $hook ] = |
|
204 | + public function add_action(string $hook, callable $callback, int $priority = 10, int $params = 1): self { |
|
205 | + $this->actions[$hook] = |
|
206 | 206 | array( |
207 | 207 | 'callback' => $callback, |
208 | 208 | 'priority' => $priority, |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param callable(\WP_Post $post,array<string, mixed> $args):array<string, mixed> $view_data_filter |
219 | 219 | * @return self |
220 | 220 | */ |
221 | - public function view_data_filter( callable $view_data_filter ): self { |
|
221 | + public function view_data_filter(callable $view_data_filter): self { |
|
222 | 222 | $this->view_data_filter = $view_data_filter; |
223 | 223 | return $this; |
224 | 224 | } |
@@ -51,27 +51,27 @@ discard block |
||
51 | 51 | * @param Registerable $class_instance |
52 | 52 | * @return object |
53 | 53 | */ |
54 | - public function process( object $class_instance ): object { |
|
55 | - if ( ! is_a( $class_instance, Registerable::class ) ) { |
|
54 | + public function process(object $class_instance): object { |
|
55 | + if ( ! is_a($class_instance, Registerable::class)) { |
|
56 | 56 | return $class_instance; |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Based on the registerable type. |
60 | - switch ( true ) { |
|
61 | - case is_a( $class_instance, Post_Type::class ): |
|
62 | - $this->process_post_type( $class_instance ); |
|
60 | + switch (true) { |
|
61 | + case is_a($class_instance, Post_Type::class): |
|
62 | + $this->process_post_type($class_instance); |
|
63 | 63 | break; |
64 | 64 | |
65 | - case is_a( $class_instance, Taxonomy::class ): |
|
66 | - $this->process_taxonomy( $class_instance ); |
|
65 | + case is_a($class_instance, Taxonomy::class): |
|
66 | + $this->process_taxonomy($class_instance); |
|
67 | 67 | break; |
68 | 68 | |
69 | - case is_a( $class_instance, Shared_Meta_Box_Controller::class ): |
|
70 | - $this->process_shared_meta_box( $class_instance ); |
|
69 | + case is_a($class_instance, Shared_Meta_Box_Controller::class): |
|
70 | + $this->process_shared_meta_box($class_instance); |
|
71 | 71 | break; |
72 | 72 | |
73 | - case is_a( $class_instance, Additional_Meta_Data_Controller::class ): |
|
74 | - $this->process_additional_meta_data( $class_instance ); |
|
73 | + case is_a($class_instance, Additional_Meta_Data_Controller::class): |
|
74 | + $this->process_additional_meta_data($class_instance); |
|
75 | 75 | break; |
76 | 76 | |
77 | 77 | default: |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | * @since 0.7.0 |
91 | 91 | */ |
92 | - protected function process_taxonomy( Taxonomy $taxonomy ): void { |
|
92 | + protected function process_taxonomy(Taxonomy $taxonomy): void { |
|
93 | 93 | $this->loader->action( |
94 | 94 | 'init', |
95 | - static function () use ( $taxonomy ) { |
|
95 | + static function() use ($taxonomy) { |
|
96 | 96 | Registrar_Factory::new() |
97 | - ->create_from_registerable( $taxonomy ) |
|
98 | - ->register( $taxonomy ); |
|
97 | + ->create_from_registerable($taxonomy) |
|
98 | + ->register($taxonomy); |
|
99 | 99 | } |
100 | 100 | ); |
101 | 101 | } |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | * @return void |
108 | 108 | * @since 0.7.0 |
109 | 109 | */ |
110 | - protected function process_post_type( Post_Type $post_type_registerable ) { |
|
110 | + protected function process_post_type(Post_Type $post_type_registerable) { |
|
111 | 111 | // Register registerable. |
112 | 112 | $this->loader->action( |
113 | 113 | 'init', |
114 | - static function () use ( $post_type_registerable ) { |
|
114 | + static function() use ($post_type_registerable) { |
|
115 | 115 | Registrar_Factory::new() |
116 | - ->create_from_registerable( $post_type_registerable ) |
|
117 | - ->register( $post_type_registerable ); |
|
116 | + ->create_from_registerable($post_type_registerable) |
|
117 | + ->register($post_type_registerable); |
|
118 | 118 | } |
119 | 119 | ); |
120 | 120 | |
121 | 121 | // Define use of gutenberg |
122 | 122 | $this->loader->filter( |
123 | 123 | 'use_block_editor_for_post_type', |
124 | - static function ( bool $state, string $post_type ) use ( $post_type_registerable ): bool { |
|
124 | + static function(bool $state, string $post_type) use ($post_type_registerable): bool { |
|
125 | 125 | return $post_type === $post_type_registerable->key |
126 | 126 | ? (bool) $post_type_registerable->gutenberg |
127 | 127 | : $state; |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | ); |
132 | 132 | |
133 | 133 | // Register meta boxes. |
134 | - $meta_boxes = $post_type_registerable->meta_boxes( array() ); |
|
134 | + $meta_boxes = $post_type_registerable->meta_boxes(array()); |
|
135 | 135 | |
136 | - if ( ! empty( $meta_boxes ) ) { |
|
136 | + if ( ! empty($meta_boxes)) { |
|
137 | 137 | |
138 | 138 | // Create the registrar |
139 | 139 | $meta_box_registrar = $this->get_meta_box_registrar(); |
140 | 140 | |
141 | 141 | // Register each meta box. |
142 | - foreach ( $meta_boxes as $meta_box ) { |
|
143 | - $meta_box->screen( $post_type_registerable->key ); |
|
144 | - $meta_box_registrar->register( $meta_box ); |
|
142 | + foreach ($meta_boxes as $meta_box) { |
|
143 | + $meta_box->screen($post_type_registerable->key); |
|
144 | + $meta_box_registrar->register($meta_box); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | * @return void |
155 | 155 | * @since 0.7.0 |
156 | 156 | */ |
157 | - public function process_shared_meta_box( Shared_Meta_Box_Controller $controller ): void { |
|
157 | + public function process_shared_meta_box(Shared_Meta_Box_Controller $controller): void { |
|
158 | 158 | $registrar = new Shared_Meta_Box_Registrar( |
159 | 159 | $this->get_meta_box_registrar(), |
160 | 160 | Registrar_Factory::new()->meta_data_registrar() |
161 | 161 | ); |
162 | - $registrar->register( $controller ); |
|
162 | + $registrar->register($controller); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @return void |
170 | 170 | * @since 0.8.0 |
171 | 171 | */ |
172 | - public function process_additional_meta_data( Additional_Meta_Data_Controller $controller ): void { |
|
172 | + public function process_additional_meta_data(Additional_Meta_Data_Controller $controller): void { |
|
173 | 173 | $registrar = new Additional_Meta_Data_Registrar( |
174 | 174 | Registrar_Factory::new()->meta_data_registrar() |
175 | 175 | ); |
176 | - $registrar->register( $controller ); |
|
176 | + $registrar->register($controller); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @since 0.7.0 |
184 | 184 | */ |
185 | 185 | public function get_meta_box_registrar(): Meta_Box_Registrar { |
186 | - return Registrar_Factory::new()->meta_box_registrar( $this->di_container, $this->loader ); |
|
186 | + return Registrar_Factory::new()->meta_box_registrar($this->di_container, $this->loader); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | public function setup(): void { |
@@ -45,7 +45,7 @@ |
||
45 | 45 | * @return Meta_Data[] |
46 | 46 | * @codeCoverageIgnore |
47 | 47 | */ |
48 | - public function meta_data( array $meta_data ): array { |
|
48 | + public function meta_data(array $meta_data): array { |
|
49 | 49 | return $meta_data; |
50 | 50 | } |
51 | 51 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | public function register( Registerable $registerable ): void { |
55 | 55 | /** |
56 | - * @var Taxonomy $registerable, Validation call below catches no Post_Type Registerables |
|
56 | + * @var Taxonomy $registerable, Validation call below catches no Post_Type Registerables |
|
57 | 57 | */ |
58 | 58 | |
59 | 59 | if ( ! $this->validator->validate( $registerable ) ) { |
@@ -51,17 +51,17 @@ 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 | /** |
56 | 56 | * @var Taxonomy $registerable, Validation call below catches no Post_Type Registerables |
57 | 57 | */ |
58 | 58 | |
59 | - if ( ! $this->validator->validate( $registerable ) ) { |
|
59 | + if ( ! $this->validator->validate($registerable)) { |
|
60 | 60 | throw new Exception( |
61 | 61 | sprintf( |
62 | 62 | 'Failed validating taxonomy model(%s) with errors: %s', |
63 | - esc_html( get_class( $registerable ) ), |
|
64 | - esc_html( join( ', ', $this->validator->get_errors() ) ) |
|
63 | + esc_html(get_class($registerable)), |
|
64 | + esc_html(join(', ', $this->validator->get_errors())) |
|
65 | 65 | ) |
66 | 66 | ); |
67 | 67 | } |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | $registerable->slug, |
73 | 73 | $registerable->object_type, |
74 | 74 | /* @phpstan-ignore-next-line */ |
75 | - $this->compile_args( $registerable ) |
|
75 | + $this->compile_args($registerable) |
|
76 | 76 | ); |
77 | 77 | |
78 | - if ( is_a( $result, \WP_Error::class ) ) { |
|
79 | - throw new Exception( join( $result->get_error_messages() ) ); |
|
78 | + if (is_a($result, \WP_Error::class)) { |
|
79 | + throw new Exception(join($result->get_error_messages())); |
|
80 | 80 | } |
81 | - } catch ( \Throwable $th ) { |
|
82 | - throw new Exception( esc_html( "Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})" ) ); |
|
81 | + } catch (\Throwable $th) { |
|
82 | + throw new Exception(esc_html("Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})")); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // Register any associated meta data. |
86 | - $this->register_meta_data( $registerable ); |
|
86 | + $this->register_meta_data($registerable); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,18 +92,18 @@ discard block |
||
92 | 92 | * @param \PinkCrab\Registerables\Taxonomy $taxonomy |
93 | 93 | * @return void |
94 | 94 | */ |
95 | - protected function register_meta_data( Taxonomy $taxonomy ): void { |
|
95 | + protected function register_meta_data(Taxonomy $taxonomy): void { |
|
96 | 96 | |
97 | 97 | // Get all meta fields for taxonomy. |
98 | - $meta_fields = $taxonomy->meta_data( array() ); |
|
98 | + $meta_fields = $taxonomy->meta_data(array()); |
|
99 | 99 | |
100 | 100 | // Attempt to register all Meta for taxonomy. |
101 | 101 | try { |
102 | - foreach ( $meta_fields as $meta_field ) { |
|
103 | - $this->meta_data_registrar->register_for_term( $meta_field, $taxonomy->slug ); |
|
102 | + foreach ($meta_fields as $meta_field) { |
|
103 | + $this->meta_data_registrar->register_for_term($meta_field, $taxonomy->slug); |
|
104 | 104 | } |
105 | - } catch ( \Throwable $th ) { |
|
106 | - throw new Exception( esc_html( $th->getMessage() ) ); |
|
105 | + } catch (\Throwable $th) { |
|
106 | + throw new Exception(esc_html($th->getMessage())); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
@@ -113,59 +113,59 @@ discard block |
||
113 | 113 | * @param \PinkCrab\Registerables\Taxonomy $taxonomy |
114 | 114 | * @return array<string, string|int|array<string, string>> |
115 | 115 | */ |
116 | - protected function compile_args( Taxonomy $taxonomy ): array { |
|
116 | + protected function compile_args(Taxonomy $taxonomy): array { |
|
117 | 117 | // Create the labels. |
118 | 118 | $base_labels = array( |
119 | 119 | 'name' => $taxonomy->plural, |
120 | 120 | 'singular_name' => $taxonomy->singular, |
121 | - 'menu_name' => \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ), |
|
121 | + 'menu_name' => \ucfirst(\esc_attr($taxonomy->plural ?? '')), |
|
122 | 122 | /* translators: %s: Taxonomy plural name */ |
123 | - 'search_items' => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
123 | + 'search_items' => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
124 | 124 | /* translators: %s: Taxonomy plural name */ |
125 | - 'popular_items' => wp_sprintf( _x( 'Popular %s', 'Label for the popular terms', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ), |
|
125 | + 'popular_items' => wp_sprintf(_x('Popular %s', 'Label for the popular terms', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')), |
|
126 | 126 | /* translators: %s: Taxonomy singular name */ |
127 | - '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 | + 'edit_item' => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
128 | 128 | /* translators: %s: Taxonomy singular name */ |
129 | - '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 | + 'view_item' => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
130 | 130 | /* translators: %s: Taxonomy singular name */ |
131 | - '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 | + 'update_item' => wp_sprintf(_x('Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
132 | 132 | /* translators: %s: Taxonomy singular name */ |
133 | - '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 | + '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 ?? '')), |
|
134 | 134 | /* translators: %s: Taxonomy singular name */ |
135 | - '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 | + '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 ?? '')), |
|
136 | 136 | /* translators: %s: Taxonomy plural name */ |
137 | - '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 | + '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 ?? '')), |
|
138 | 138 | /* translators: %s: Taxonomy plural name */ |
139 | - '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 | + '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 ?? ''))), |
|
140 | 140 | /* translators: %s: Taxonomy plural name */ |
141 | - '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 | + '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 ?? ''))), |
|
142 | 142 | /* translators: %s: Taxonomy plural name */ |
143 | - '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 ?? '' ) ) ), |
|
144 | - 'most_used' => _x( 'Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab' ), |
|
143 | + '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 ?? ''))), |
|
144 | + 'most_used' => _x('Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab'), |
|
145 | 145 | /* translators: %s: Taxonomy plural name */ |
146 | - '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 | + '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 ?? ''))), |
|
147 | 147 | /* translators: %s: Taxonomy singular name */ |
148 | - '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 | + '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 ?? ''))), |
|
149 | 149 | /* translators: %s: Taxonomy singular name */ |
150 | - '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 | + '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 ?? '')), |
|
151 | 151 | ); |
152 | 152 | |
153 | 153 | $tag_labels = array( |
154 | 154 | /* translators: %s: Taxonomy plural name */ |
155 | - '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 | + '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 ?? '')), |
|
156 | 156 | /* translators: %s: Taxonomy plural name */ |
157 | - '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 | + '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 ?? '')), |
|
158 | 158 | /* translators: %s: Taxonomy plural name */ |
159 | - '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 | + '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 ?? '')), |
|
160 | 160 | ); |
161 | 161 | |
162 | 162 | $hierarchical_labels = array( |
163 | 163 | /* translators: %s: Taxonomy singular name */ |
164 | - '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 | + '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 ?? '')), |
|
165 | 165 | /* translators: %s: Taxonomy singular name */ |
166 | - 'parent_item' => wp_sprintf( _x( 'Parent %s', 'Label for the parent term', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ), |
|
166 | + 'parent_item' => wp_sprintf(_x('Parent %s', 'Label for the parent term', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')), |
|
167 | 167 | /* translators: %s: Taxonomy singular name */ |
168 | - '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 | + '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 ?? '')), |
|
169 | 169 | ); |
170 | 170 | |
171 | 171 | $labels = array_merge( |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param Taxonomy $taxonomy |
182 | 182 | * @return array<string, string> |
183 | 183 | */ |
184 | - $labels = apply_filters( Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels( $labels ), $taxonomy ); |
|
184 | + $labels = apply_filters(Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels($labels), $taxonomy); |
|
185 | 185 | |
186 | 186 | // Compose args. |
187 | 187 | $args = array( |
@@ -228,6 +228,6 @@ discard block |
||
228 | 228 | * @return array<string, string|bool|int|null|array<string, string>> |
229 | 229 | */ |
230 | 230 | /* @phpstan-ignore-next-line, this is due to apply_filters type hints being wrong. */ |
231 | - return apply_filters( Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args( $args ), $taxonomy ); |
|
231 | + return apply_filters(Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args($args), $taxonomy); |
|
232 | 232 | } |
233 | 233 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | - * @var Additional_Meta_Data $registerable, Validation call below catches no Additional_Meta_Data Registerables |
|
59 | + * @var Additional_Meta_Data $registerable, Validation call below catches no Additional_Meta_Data Registerables |
|
60 | 60 | */ |
61 | 61 | $meta_data = $this->filter_meta_data( $registerable->meta_data( array() ) ); |
62 | 62 |
@@ -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,26 +50,26 @@ 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 | /** |
59 | 59 | * @var Additional_Meta_Data $registerable, Validation call below catches no Additional_Meta_Data Registerables |
60 | 60 | */ |
61 | - $meta_data = $this->filter_meta_data( $registerable->meta_data( array() ) ); |
|
61 | + $meta_data = $this->filter_meta_data($registerable->meta_data(array())); |
|
62 | 62 | |
63 | 63 | // Iterate through all meta data and register them. |
64 | - foreach ( $meta_data as $meta_data_item ) { |
|
65 | - switch ( $meta_data_item->get_meta_type() ) { |
|
64 | + foreach ($meta_data as $meta_data_item) { |
|
65 | + switch ($meta_data_item->get_meta_type()) { |
|
66 | 66 | case 'post': |
67 | 67 | // Throw if post type not defined. |
68 | - if ( null === $meta_data_item->get_subtype() ) { |
|
68 | + if (null === $meta_data_item->get_subtype()) { |
|
69 | 69 | throw new Exception( |
70 | 70 | sprintf( |
71 | 71 | 'A post type must be defined when attempting to register post meta with meta key : %s', |
72 | - esc_attr( $meta_data_item->get_meta_key() ) |
|
72 | + esc_attr($meta_data_item->get_meta_key()) |
|
73 | 73 | ) |
74 | 74 | ); |
75 | 75 | } |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | |
83 | 83 | case 'term': |
84 | 84 | // Throw if Taxonomy not defined. |
85 | - if ( null === $meta_data_item->get_subtype() ) { |
|
85 | + if (null === $meta_data_item->get_subtype()) { |
|
86 | 86 | throw new Exception( |
87 | 87 | sprintf( |
88 | 88 | 'A taxonomy must be defined when attempting to register tern meta with meta key : %s', |
89 | - esc_attr( $meta_data_item->get_meta_key() ) |
|
89 | + esc_attr($meta_data_item->get_meta_key()) |
|
90 | 90 | ) |
91 | 91 | ); |
92 | 92 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | break; |
111 | 111 | |
112 | 112 | default: |
113 | - throw new Exception( 'Unexpected meta type' ); |
|
113 | + throw new Exception('Unexpected meta type'); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | * @param mixed[] $meta_data |
122 | 122 | * @return Meta_Data[] |
123 | 123 | */ |
124 | - protected function filter_meta_data( array $meta_data ): array { |
|
124 | + protected function filter_meta_data(array $meta_data): array { |
|
125 | 125 | return array_filter( |
126 | 126 | $meta_data, |
127 | - function ( $e ) { |
|
128 | - return is_a( $e, Meta_Data::class ); |
|
127 | + function($e) { |
|
128 | + return is_a($e, Meta_Data::class); |
|
129 | 129 | } |
130 | 130 | ); |
131 | 131 | } |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * Registers a Meta Data object as defined REST field. |
|
133 | - * |
|
134 | - * @param \PinkCrab\Registerables\Meta_Data $meta |
|
135 | - * @return void |
|
136 | - */ |
|
132 | + * Registers a Meta Data object as defined REST field. |
|
133 | + * |
|
134 | + * @param \PinkCrab\Registerables\Meta_Data $meta |
|
135 | + * @return void |
|
136 | + */ |
|
137 | 137 | public function register_meta_rest_field( Meta_Data $meta ) { |
138 | 138 | // Skip if not sub type defined for post or term. |
139 | 139 | if ( null === $meta->get_subtype() ) { |
@@ -205,28 +205,28 @@ discard block |
||
205 | 205 | switch ( $meta->get_meta_type() ) { |
206 | 206 | case 'post': |
207 | 207 | /** |
208 | - * @var \WP_Post $object_instance |
|
208 | + * @var \WP_Post $object_instance |
|
209 | 209 | */ |
210 | 210 | update_post_meta( $object_instance->ID, $meta->get_meta_key(), $value ); |
211 | 211 | break; |
212 | 212 | |
213 | 213 | case 'term': |
214 | 214 | /** |
215 | - * @var \WP_Term $object_instance |
|
215 | + * @var \WP_Term $object_instance |
|
216 | 216 | */ |
217 | 217 | update_term_meta( $object_instance->term_id, $meta->get_meta_key(), $value ); |
218 | 218 | break; |
219 | 219 | |
220 | 220 | case 'user': |
221 | 221 | /** |
222 | - * @var \WP_User $object_instance |
|
222 | + * @var \WP_User $object_instance |
|
223 | 223 | */ |
224 | 224 | update_user_meta( $object_instance->ID, $meta->get_meta_key(), $value ); |
225 | 225 | break; |
226 | 226 | |
227 | 227 | case 'comment': |
228 | 228 | /** |
229 | - * @var \WP_Comment $object_instance |
|
229 | + * @var \WP_Comment $object_instance |
|
230 | 230 | */ |
231 | 231 | update_comment_meta( (int) $object_instance->comment_ID, $meta->get_meta_key(), $value ); |
232 | 232 | break; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @return boolean |
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 boolean |
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 boolean |
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 boolean |
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 boolean |
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 | - esc_html( "Failed to register {$meta->get_meta_key()} (meta) for {$sub_type} of {$meta_type} type" ) |
|
101 | + esc_html("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,39 +196,39 @@ 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_instance |
203 | 203 | */ |
204 | - return function ( $value, $object_instance ) use ( $meta ) { |
|
205 | - switch ( $meta->get_meta_type() ) { |
|
204 | + return function($value, $object_instance) use ($meta) { |
|
205 | + switch ($meta->get_meta_type()) { |
|
206 | 206 | case 'post': |
207 | 207 | /** |
208 | 208 | * @var \WP_Post $object_instance |
209 | 209 | */ |
210 | - update_post_meta( $object_instance->ID, $meta->get_meta_key(), $value ); |
|
210 | + update_post_meta($object_instance->ID, $meta->get_meta_key(), $value); |
|
211 | 211 | break; |
212 | 212 | |
213 | 213 | case 'term': |
214 | 214 | /** |
215 | 215 | * @var \WP_Term $object_instance |
216 | 216 | */ |
217 | - update_term_meta( $object_instance->term_id, $meta->get_meta_key(), $value ); |
|
217 | + update_term_meta($object_instance->term_id, $meta->get_meta_key(), $value); |
|
218 | 218 | break; |
219 | 219 | |
220 | 220 | case 'user': |
221 | 221 | /** |
222 | 222 | * @var \WP_User $object_instance |
223 | 223 | */ |
224 | - update_user_meta( $object_instance->ID, $meta->get_meta_key(), $value ); |
|
224 | + update_user_meta($object_instance->ID, $meta->get_meta_key(), $value); |
|
225 | 225 | break; |
226 | 226 | |
227 | 227 | case 'comment': |
228 | 228 | /** |
229 | 229 | * @var \WP_Comment $object_instance |
230 | 230 | */ |
231 | - update_comment_meta( (int) $object_instance->comment_ID, $meta->get_meta_key(), $value ); |
|
231 | + update_comment_meta((int) $object_instance->comment_ID, $meta->get_meta_key(), $value); |
|
232 | 232 | break; |
233 | 233 | |
234 | 234 | default: |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | * @return Registrar |
55 | 55 | * @throws Exception If not valid registerable type passed. |
56 | 56 | */ |
57 | - public function create_from_registerable( Registerable $registerable ): Registrar { |
|
58 | - switch ( true ) { |
|
59 | - case is_a( $registerable, Post_Type::class ): |
|
60 | - return new Post_Type_Registrar( new Post_Type_Validator(), new Meta_Data_Registrar() ); |
|
57 | + public function create_from_registerable(Registerable $registerable): Registrar { |
|
58 | + switch (true) { |
|
59 | + case is_a($registerable, Post_Type::class): |
|
60 | + return new Post_Type_Registrar(new Post_Type_Validator(), new Meta_Data_Registrar()); |
|
61 | 61 | |
62 | - case is_a( $registerable, Taxonomy::class ): |
|
63 | - return new Taxonomy_Registrar( new Taxonomy_Validator(), new Meta_Data_Registrar() ); |
|
62 | + case is_a($registerable, Taxonomy::class): |
|
63 | + return new Taxonomy_Registrar(new Taxonomy_Validator(), new Meta_Data_Registrar()); |
|
64 | 64 | |
65 | 65 | default: |
66 | - $type = get_class( $registerable ); |
|
67 | - throw new Exception( esc_html( 'Invalid registerable (' . $type . ')type (no dispatcher exists)' ) ); |
|
66 | + $type = get_class($registerable); |
|
67 | + throw new Exception(esc_html('Invalid registerable (' . $type . ')type (no dispatcher exists)')); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @param \PinkCrab\Loader\Hook_Loader $loader |
76 | 76 | * @return Meta_Box_Registrar |
77 | 77 | */ |
78 | - public function meta_box_registrar( DI_Container $container, Hook_Loader $loader ): Meta_Box_Registrar { |
|
79 | - return new Meta_Box_Registrar( new Meta_Box_Validator(), $container, $loader ); |
|
78 | + public function meta_box_registrar(DI_Container $container, Hook_Loader $loader): Meta_Box_Registrar { |
|
79 | + return new Meta_Box_Registrar(new Meta_Box_Validator(), $container, $loader); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | public function register( Registerable $registerable ): void { |
55 | 55 | /** |
56 | - * @var Post_Type $registerable, Validation call below catches no Post_Type Registerables |
|
56 | + * @var Post_Type $registerable, Validation call below catches no Post_Type Registerables |
|
57 | 57 | */ |
58 | 58 | |
59 | 59 | if ( ! $this->validator->validate( $registerable ) ) { |
@@ -51,17 +51,17 @@ 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 | /** |
56 | 56 | * @var Post_Type $registerable, Validation call below catches no Post_Type Registerables |
57 | 57 | */ |
58 | 58 | |
59 | - if ( ! $this->validator->validate( $registerable ) ) { |
|
59 | + if ( ! $this->validator->validate($registerable)) { |
|
60 | 60 | throw new Exception( |
61 | 61 | sprintf( |
62 | 62 | 'Failed validating post type model(%s) with errors: %s', |
63 | - esc_html( get_class( $registerable ) ), |
|
64 | - esc_html( join( ', ', $this->validator->get_errors() ) ) |
|
63 | + esc_html(get_class($registerable)), |
|
64 | + esc_html(join(', ', $this->validator->get_errors())) |
|
65 | 65 | ) |
66 | 66 | ); |
67 | 67 | } |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | // Attempt to register the post type. |
70 | 70 | try { |
71 | 71 | /* @phpstan-ignore-next-line */ |
72 | - $result = register_post_type( $registerable->key, $this->compile_args( $registerable ) ); |
|
73 | - if ( is_a( $result, \WP_Error::class ) ) { |
|
74 | - throw new Exception( join( $result->get_error_messages() ) ); |
|
72 | + $result = register_post_type($registerable->key, $this->compile_args($registerable)); |
|
73 | + if (is_a($result, \WP_Error::class)) { |
|
74 | + throw new Exception(join($result->get_error_messages())); |
|
75 | 75 | } |
76 | - } catch ( \Throwable $th ) { |
|
77 | - throw new Exception( esc_html( "Failed to register {$registerable->key} post type ({$th->getMessage()})" ) ); |
|
76 | + } catch (\Throwable $th) { |
|
77 | + throw new Exception(esc_html("Failed to register {$registerable->key} post type ({$th->getMessage()})")); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Register all meta data for post type. |
81 | - $this->register_meta_data( $registerable ); |
|
81 | + $this->register_meta_data($registerable); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | * @param \PinkCrab\Registerables\Post_Type $post_type |
88 | 88 | * @return void |
89 | 89 | */ |
90 | - protected function register_meta_data( Post_Type $post_type ): void { |
|
90 | + protected function register_meta_data(Post_Type $post_type): void { |
|
91 | 91 | |
92 | 92 | // Get all meta fields for post_type. |
93 | - $meta_fields = $post_type->meta_data( array() ); |
|
93 | + $meta_fields = $post_type->meta_data(array()); |
|
94 | 94 | // Attempt to register all Meta for post_type. |
95 | 95 | try { |
96 | - foreach ( $meta_fields as $meta_field ) { |
|
96 | + foreach ($meta_fields as $meta_field) { |
|
97 | 97 | $this->meta_data_registrar |
98 | - ->register_for_post_type( $meta_field, $post_type->key ); |
|
98 | + ->register_for_post_type($meta_field, $post_type->key); |
|
99 | 99 | } |
100 | - } catch ( \Throwable $th ) { |
|
101 | - throw new Exception( esc_html( $th->getMessage() ) ); |
|
100 | + } catch (\Throwable $th) { |
|
101 | + throw new Exception(esc_html($th->getMessage())); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -110,64 +110,64 @@ discard block |
||
110 | 110 | * @param \PinkCrab\Registerables\Post_Type $post_type |
111 | 111 | * @return array<string, string|int|array<string, string>> |
112 | 112 | */ |
113 | - protected function compile_args( Post_Type $post_type ): array { |
|
113 | + protected function compile_args(Post_Type $post_type): array { |
|
114 | 114 | // Create the labels. |
115 | 115 | $labels = array( |
116 | 116 | 'name' => $post_type->plural, |
117 | 117 | 'singular_name' => $post_type->singular, |
118 | - 'add_new' => _x( 'Add New', 'Add new post label of custom post type', 'pinkcrab' ), |
|
118 | + 'add_new' => _x('Add New', 'Add new post label of custom post type', 'pinkcrab'), |
|
119 | 119 | /* translators: %s: Post type singular name */ |
120 | - '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 ), |
|
120 | + '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), |
|
121 | 121 | /* translators: %s: Post type singular name */ |
122 | - 'edit_item' => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
122 | + 'edit_item' => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
123 | 123 | /* translators: %s: Post type singular name */ |
124 | - '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 ), |
|
124 | + '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), |
|
125 | 125 | /* translators: %s: Post type singular name */ |
126 | - 'view_item' => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {post type singular name}’.', 'pinkcrab' ), $post_type->singular ), |
|
126 | + 'view_item' => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {post type singular name}’.', 'pinkcrab'), $post_type->singular), |
|
127 | 127 | /* translators: %s: Post type plural name */ |
128 | - 'view_items' => wp_sprintf( _x( 'View %s', 'Label for viewing post type archives. Default is ‘View {post type plural name}’.', 'pinkcrab' ), $post_type->plural ), |
|
128 | + 'view_items' => wp_sprintf(_x('View %s', 'Label for viewing post type archives. Default is ‘View {post type plural name}’.', 'pinkcrab'), $post_type->plural), |
|
129 | 129 | /* translators: %s: Post type singular name */ |
130 | - 'search_items' => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {post type plural name}’.', 'pinkcrab' ), $post_type->singular ), |
|
130 | + 'search_items' => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {post type plural name}’.', 'pinkcrab'), $post_type->singular), |
|
131 | 131 | /* translators: %s: Post type plural name */ |
132 | - '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 ), |
|
132 | + '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), |
|
133 | 133 | /* translators: %s: Post type plural name */ |
134 | - '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 ), |
|
134 | + '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), |
|
135 | 135 | /* translators: %s: Post type singular name */ |
136 | - '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 ), |
|
136 | + '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), |
|
137 | 137 | /* translators: %s: Post type singular name */ |
138 | - '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 ), |
|
138 | + '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), |
|
139 | 139 | /* translators: %s: Post type plural name */ |
140 | - 'archives' => wp_sprintf( _x( '%s Archives', ' Label for archives in nav menus. Default is ‘Post Archives’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ), |
|
140 | + 'archives' => wp_sprintf(_x('%s Archives', ' Label for archives in nav menus. Default is ‘Post Archives’.', 'pinkcrab'), \ucfirst($post_type->plural)), |
|
141 | 141 | /* translators: %s: Post type plural name */ |
142 | - 'attributes' => wp_sprintf( _x( '%s Attributes', 'Label for the attributes meta box. Default is ‘{post type plural name} Attributes’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ), |
|
142 | + 'attributes' => wp_sprintf(_x('%s Attributes', 'Label for the attributes meta box. Default is ‘{post type plural name} Attributes’.', 'pinkcrab'), \ucfirst($post_type->plural)), |
|
143 | 143 | /* translators: %s: Post type singular name */ |
144 | - '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 ), |
|
144 | + '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), |
|
145 | 145 | /* translators: %s: Post type singular name */ |
146 | - '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 ), |
|
147 | - 'featured_image' => _x( 'Featured image', 'Label for the featured image meta box title. Default is ‘Featured image’.', 'pinkcrab' ), |
|
148 | - 'set_featured_image' => _x( 'Set featured image', 'Label for setting the featured image. Default is ‘Set featured image’.', 'pinkcrab' ), |
|
149 | - 'remove_featured_image' => _x( 'Remove featured image', 'Label for removing the featured image. Default is ‘Remove featured image’.', 'pinkcrab' ), |
|
150 | - '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' ), |
|
146 | + '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), |
|
147 | + 'featured_image' => _x('Featured image', 'Label for the featured image meta box title. Default is ‘Featured image’.', 'pinkcrab'), |
|
148 | + 'set_featured_image' => _x('Set featured image', 'Label for setting the featured image. Default is ‘Set featured image’.', 'pinkcrab'), |
|
149 | + 'remove_featured_image' => _x('Remove featured image', 'Label for removing the featured image. Default is ‘Remove featured image’.', 'pinkcrab'), |
|
150 | + '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'), |
|
151 | 151 | 'menu_name' => $post_type->plural, |
152 | 152 | /* translators: %s: Post type plural name */ |
153 | - '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 ), |
|
154 | - 'filter_by_date' => _x( 'Filter by date', 'Label for the date filter in list tables. Default is ‘Filter by date’.', 'pinkcrab' ), |
|
153 | + '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), |
|
154 | + 'filter_by_date' => _x('Filter by date', 'Label for the date filter in list tables. Default is ‘Filter by date’.', 'pinkcrab'), |
|
155 | 155 | /* translators: %s: Post type plural name */ |
156 | - '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 ) ), |
|
156 | + '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)), |
|
157 | 157 | /* translators: %s: Post type singular name */ |
158 | - '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 ) ), |
|
158 | + '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)), |
|
159 | 159 | /* translators: %s: Post type singular name */ |
160 | - '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 ) ), |
|
160 | + '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)), |
|
161 | 161 | /* translators: %s: Post type singular name */ |
162 | - '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 ) ), |
|
162 | + '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)), |
|
163 | 163 | /* translators: %s: Post type singular name */ |
164 | - '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 ) ), |
|
164 | + '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)), |
|
165 | 165 | /* translators: %s: Post type singular name */ |
166 | - '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 ) ), |
|
166 | + '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)), |
|
167 | 167 | /* translators: %s: Post type singular name */ |
168 | - '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 ) ), |
|
168 | + '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)), |
|
169 | 169 | /* translators: %s: Post type singular name */ |
170 | - '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 ), |
|
170 | + '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), |
|
171 | 171 | ); |
172 | 172 | |
173 | 173 | /** |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | * @param Post_Type $cpt |
179 | 179 | * @return array<string, string> |
180 | 180 | */ |
181 | - $labels = apply_filters( Registerable_Hooks::POST_TYPE_LABELS, $post_type->filter_labels( $labels ), $post_type ); |
|
181 | + $labels = apply_filters(Registerable_Hooks::POST_TYPE_LABELS, $post_type->filter_labels($labels), $post_type); |
|
182 | 182 | |
183 | 183 | // Set the rewrite rules if not defined. |
184 | - if ( is_null( $post_type->rewrite ) ) { |
|
184 | + if (is_null($post_type->rewrite)) { |
|
185 | 185 | $post_type->rewrite = array( |
186 | 186 | 'slug' => $post_type->key, |
187 | 187 | 'with_front' => true, |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | // Set the meta cap based on its definition and if uses gutenberg. |
194 | 194 | // See https://github.com/Pink-Crab/Perique-Registerables/issues/66 |
195 | - if ( null === $post_type->map_meta_cap ) { |
|
195 | + if (null === $post_type->map_meta_cap) { |
|
196 | 196 | $meta_cap = $post_type->gutenberg ? true : false; |
197 | 197 | } else { |
198 | 198 | $meta_cap = $post_type->map_meta_cap ?? false; |
@@ -202,30 +202,30 @@ discard block |
||
202 | 202 | $args = array( |
203 | 203 | 'labels' => $labels, |
204 | 204 | 'description' => $post_type->description ?? $post_type->plural, |
205 | - 'hierarchical' => is_bool( $post_type->hierarchical ) ? $post_type->hierarchical : false, |
|
205 | + 'hierarchical' => is_bool($post_type->hierarchical) ? $post_type->hierarchical : false, |
|
206 | 206 | 'supports' => $post_type->supports, |
207 | - 'public' => is_bool( $post_type->public ) ? $post_type->public : true, |
|
208 | - 'show_ui' => is_bool( $post_type->show_ui ) ? $post_type->show_ui : true, |
|
209 | - 'show_in_menu' => is_bool( $post_type->show_in_menu ) ? $post_type->show_in_menu : true, |
|
210 | - 'show_in_admin_bar' => is_bool( $post_type->show_in_admin_bar ) ? $post_type->show_in_admin_bar : true, |
|
207 | + 'public' => is_bool($post_type->public) ? $post_type->public : true, |
|
208 | + 'show_ui' => is_bool($post_type->show_ui) ? $post_type->show_ui : true, |
|
209 | + 'show_in_menu' => is_bool($post_type->show_in_menu) ? $post_type->show_in_menu : true, |
|
210 | + 'show_in_admin_bar' => is_bool($post_type->show_in_admin_bar) ? $post_type->show_in_admin_bar : true, |
|
211 | 211 | 'menu_position' => $post_type->menu_position, |
212 | 212 | 'menu_icon' => $post_type->dashicon, |
213 | - 'show_in_nav_menus' => is_bool( $post_type->show_in_nav_menus ) ? $post_type->show_in_nav_menus : true, |
|
214 | - 'publicly_queryable' => is_bool( $post_type->publicly_queryable ) ? $post_type->publicly_queryable : true, |
|
215 | - 'exclude_from_search' => is_bool( $post_type->exclude_from_search ) ? $post_type->exclude_from_search : true, |
|
216 | - 'has_archive' => is_bool( $post_type->has_archive ) ? $post_type->has_archive : true, |
|
217 | - 'query_var' => is_bool( $post_type->query_var ) ? $post_type->query_var : false, |
|
218 | - 'can_export' => is_bool( $post_type->can_export ) ? $post_type->can_export : true, |
|
219 | - 'rewrite' => is_bool( $post_type->rewrite ) ? $post_type->rewrite : false, |
|
213 | + 'show_in_nav_menus' => is_bool($post_type->show_in_nav_menus) ? $post_type->show_in_nav_menus : true, |
|
214 | + 'publicly_queryable' => is_bool($post_type->publicly_queryable) ? $post_type->publicly_queryable : true, |
|
215 | + 'exclude_from_search' => is_bool($post_type->exclude_from_search) ? $post_type->exclude_from_search : true, |
|
216 | + 'has_archive' => is_bool($post_type->has_archive) ? $post_type->has_archive : true, |
|
217 | + 'query_var' => is_bool($post_type->query_var) ? $post_type->query_var : false, |
|
218 | + 'can_export' => is_bool($post_type->can_export) ? $post_type->can_export : true, |
|
219 | + 'rewrite' => is_bool($post_type->rewrite) ? $post_type->rewrite : false, |
|
220 | 220 | 'capability_type' => $post_type->capability_type, |
221 | 221 | 'capabilities' => $post_type->capabilities, |
222 | 222 | 'taxonomies' => $post_type->taxonomies, |
223 | - 'show_in_rest' => is_bool( $post_type->show_in_rest ) ? $post_type->show_in_rest : true, |
|
223 | + 'show_in_rest' => is_bool($post_type->show_in_rest) ? $post_type->show_in_rest : true, |
|
224 | 224 | 'rest_base' => $post_type->rest_base ?? $post_type->key, |
225 | - 'rest_controller_class' => \class_exists( $post_type->rest_controller_class ) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class, |
|
226 | - 'delete_with_user' => \is_bool( $post_type->delete_with_user ) ? $post_type->delete_with_user : null, |
|
227 | - 'template' => \is_array( $post_type->template ) ? $post_type->template : array(), |
|
228 | - 'template_lock' => \is_string( $post_type->template_lock ) ? $post_type->template_lock : false, |
|
225 | + 'rest_controller_class' => \class_exists($post_type->rest_controller_class) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class, |
|
226 | + 'delete_with_user' => \is_bool($post_type->delete_with_user) ? $post_type->delete_with_user : null, |
|
227 | + 'template' => \is_array($post_type->template) ? $post_type->template : array(), |
|
228 | + 'template_lock' => \is_string($post_type->template_lock) ? $post_type->template_lock : false, |
|
229 | 229 | 'map_meta_cap' => $meta_cap, |
230 | 230 | ); |
231 | 231 | |
@@ -239,6 +239,6 @@ discard block |
||
239 | 239 | * @return array<string, string|bool|int|null|array<string, string>> |
240 | 240 | */ |
241 | 241 | /* @phpstan-ignore-next-line, this is due to apply_filters type hints being wrong. */ |
242 | - return apply_filters( Registerable_Hooks::POST_TYPE_ARGS, $post_type->filter_args( $args ), $post_type ); |
|
242 | + return apply_filters(Registerable_Hooks::POST_TYPE_ARGS, $post_type->filter_args($args), $post_type); |
|
243 | 243 | } |
244 | 244 | } |