Completed
Push — master ( 874476...6bd4da )
by Glynn
33s queued 12s
created
src/Registrar/Taxonomy_Registrar.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
 	 * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable
63 63
 	 * @return void
64 64
 	 */
65
-	public function register( Registerable $registerable ): void {
65
+	public function register(Registerable $registerable): void {
66 66
 		/** @var Taxonomy $registerable, Validation call below catches no Post_Type Registerables */
67 67
 
68
-		if ( ! $this->validator->validate( $registerable ) ) {
68
+		if ( ! $this->validator->validate($registerable)) {
69 69
 			throw new Exception(
70 70
 				sprintf(
71 71
 					'Failed validating taxonomy model(%s) with errors: %s',
72
-					get_class( $registerable ),
73
-					join( ', ', $this->validator->get_errors() )
72
+					get_class($registerable),
73
+					join(', ', $this->validator->get_errors())
74 74
 				)
75 75
 			);
76 76
 		}
@@ -81,18 +81,18 @@  discard block
 block discarded – undo
81 81
 				$registerable->slug,
82 82
 				$registerable->object_type,
83 83
 				/* @phpstan-ignore-next-line */
84
-				$this->compile_args( $registerable )
84
+				$this->compile_args($registerable)
85 85
 			);
86 86
 
87
-			if ( is_a( $result, \WP_Error::class ) ) {
88
-				throw new Exception( join( $result->get_error_messages() ) );
87
+			if (is_a($result, \WP_Error::class)) {
88
+				throw new Exception(join($result->get_error_messages()));
89 89
 			}
90
-		} catch ( \Throwable $th ) {
91
-			throw new Exception( "Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})" );
90
+		} catch (\Throwable $th) {
91
+			throw new Exception("Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})");
92 92
 		}
93 93
 
94 94
 		// Register any associated meta data.
95
-		$this->register_meta_data( $registerable );
95
+		$this->register_meta_data($registerable);
96 96
 
97 97
 	}
98 98
 
@@ -102,18 +102,18 @@  discard block
 block discarded – undo
102 102
 	 * @param \PinkCrab\Registerables\Taxonomy $taxonomy
103 103
 	 * @return void
104 104
 	 */
105
-	protected function register_meta_data( Taxonomy $taxonomy ): void {
105
+	protected function register_meta_data(Taxonomy $taxonomy): void {
106 106
 
107 107
 		// Get all meta fields for taxonomy.
108
-		$meta_fields = $taxonomy->meta_data( array() );
108
+		$meta_fields = $taxonomy->meta_data(array());
109 109
 
110 110
 		// Attempt to register all Meta for taxonomy.
111 111
 		try {
112
-			foreach ( $meta_fields as $meta_field ) {
113
-				$this->meta_data_registrar->register_for_term( $meta_field, $taxonomy->slug );
112
+			foreach ($meta_fields as $meta_field) {
113
+				$this->meta_data_registrar->register_for_term($meta_field, $taxonomy->slug);
114 114
 			}
115
-		} catch ( \Throwable $th ) {
116
-			throw new Exception( $th->getMessage() );
115
+		} catch (\Throwable $th) {
116
+			throw new Exception($th->getMessage());
117 117
 		}
118 118
 	}
119 119
 
@@ -123,59 +123,59 @@  discard block
 block discarded – undo
123 123
 	 * @param \PinkCrab\Registerables\Taxonomy $taxonomy
124 124
 	 * @return array<string, string|int|array<string, string>>
125 125
 	 */
126
-	protected function compile_args( Taxonomy $taxonomy ): array {
126
+	protected function compile_args(Taxonomy $taxonomy): array {
127 127
 		// Create the labels.
128 128
 		$base_labels = array(
129 129
 			'name'                  => $taxonomy->plural,
130 130
 			'singular_name'         => $taxonomy->singular,
131
-			'menu_name'             => \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ),
131
+			'menu_name'             => \ucfirst(\esc_attr($taxonomy->plural ?? '')),
132 132
 			/* translators: %s: Taxonomy plural name */
133
-			'search_items'          => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
133
+			'search_items'          => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
134 134
 			/* translators: %s: Taxonomy plural name */
135
-			'popular_items'         => wp_sprintf( _x( 'Popular %s', 'Label for the popular terms', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
135
+			'popular_items'         => wp_sprintf(_x('Popular %s', 'Label for the popular terms', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
136 136
 			/* translators: %s: Taxonomy singular name */
137
-			'edit_item'             => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
137
+			'edit_item'             => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
138 138
 			/* translators: %s: Taxonomy singular name */
139
-			'view_item'             => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
139
+			'view_item'             => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
140 140
 			/* translators: %s: Taxonomy singular name */
141
-			'update_item'           => wp_sprintf( _x( 'Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
141
+			'update_item'           => wp_sprintf(_x('Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
142 142
 			/* translators: %s: Taxonomy singular name */
143
-			'add_new_item'          => wp_sprintf( _x( 'Add New %s', 'Label for adding a new singular item. Default is ‘Add New {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
143
+			'add_new_item'          => wp_sprintf(_x('Add New %s', 'Label for adding a new singular item. Default is ‘Add New {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
144 144
 			/* translators: %s: Taxonomy singular name */
145
-			'new_item_name'         => wp_sprintf( _x( 'New %s', 'Label for the new item page title. Default is ‘New {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
145
+			'new_item_name'         => wp_sprintf(_x('New %s', 'Label for the new item page title. Default is ‘New {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
146 146
 			/* translators: %s: Taxonomy plural name */
147
-			'not_found'             => wp_sprintf( _x( 'No %s found', 'Label used when no items are found. Default is ‘No {taxonomy plural name} found’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
147
+			'not_found'             => wp_sprintf(_x('No %s found', 'Label used when no items are found. Default is ‘No {taxonomy plural name} found’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
148 148
 			/* translators: %s: Taxonomy plural name */
149
-			'items_list'            => wp_sprintf( _x( '%s list', 'Label for the table hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ),
149
+			'items_list'            => wp_sprintf(_x('%s list', 'Label for the table hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))),
150 150
 			/* translators: %s: Taxonomy plural name */
151
-			'items_list_navigation' => wp_sprintf( _x( '%s list navigation', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ),
151
+			'items_list_navigation' => wp_sprintf(_x('%s list navigation', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))),
152 152
 			/* translators: %s: Taxonomy plural name */
153
-			'all_items'             => wp_sprintf( _x( 'All %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ),
154
-			'most_used'             => _x( 'Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab' ),
153
+			'all_items'             => wp_sprintf(_x('All %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))),
154
+			'most_used'             => _x('Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab'),
155 155
 			/* translators: %s: Taxonomy plural name */
156
-			'back_to_items'         => wp_sprintf( _x( '← Back to %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ) ),
156
+			'back_to_items'         => wp_sprintf(_x('← Back to %s', 'Label for the pagination hidden heading. Default is ‘{taxonomy plural name} list’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->plural ?? ''))),
157 157
 			/* translators: %s: Taxonomy singular name */
158
-			'item_link'             => wp_sprintf( _x( '%s Link', 'Title for a navigation link block variation. Default is ‘{taxonomy singular name} Link’.', 'pinkcrab' ), \ucfirst( \esc_attr( $taxonomy->singular ?? '' ) ) ),
158
+			'item_link'             => wp_sprintf(_x('%s Link', 'Title for a navigation link block variation. Default is ‘{taxonomy singular name} Link’.', 'pinkcrab'), \ucfirst(\esc_attr($taxonomy->singular ?? ''))),
159 159
 			/* translators: %s: Taxonomy singular name */
160
-			'item_link_description' => wp_sprintf( _x( 'A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
160
+			'item_link_description' => wp_sprintf(_x('A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
161 161
 		);
162 162
 
163 163
 		$tag_labels = array(
164 164
 			/* translators: %s: Taxonomy plural name */
165
-			'separate_items_with_commas' => wp_sprintf( _x( 'Separate %s with commas', 'This label is only used for non-hierarchical taxonomies. Default \'Separate {taxonomy plural name} with commas\', used in the meta box.’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
165
+			'separate_items_with_commas' => wp_sprintf(_x('Separate %s with commas', 'This label is only used for non-hierarchical taxonomies. Default \'Separate {taxonomy plural name} with commas\', used in the meta box.’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
166 166
 			/* translators: %s: Taxonomy plural name */
167
-			'add_or_remove_items'        => wp_sprintf( _x( 'Add or remove %s', 'This label is only used for non-hierarchical taxonomies. Default \'Add or remove {taxonomy plural name}\', used in the meta box when JavaScript is disabled.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
167
+			'add_or_remove_items'        => wp_sprintf(_x('Add or remove %s', 'This label is only used for non-hierarchical taxonomies. Default \'Add or remove {taxonomy plural name}\', used in the meta box when JavaScript is disabled.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
168 168
 			/* translators: %s: Taxonomy plural name */
169
-			'choose_from_most_used'      => wp_sprintf( _x( 'Add or remove %s', 'This label is only used on non-hierarchical taxonomies. Default\'Choose from the most used {taxonomy plural name}\', used in the meta box.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
169
+			'choose_from_most_used'      => wp_sprintf(_x('Add or remove %s', 'This label is only used on non-hierarchical taxonomies. Default\'Choose from the most used {taxonomy plural name}\', used in the meta box.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
170 170
 		);
171 171
 
172 172
 		$hierarchical_labels = array(
173 173
 			/* translators: %s: Taxonomy singular name */
174
-			'parent_item_colon' => wp_sprintf( _x( 'Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical taxonomys. Default is ‘Parent {taxonomy plural name}:’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
174
+			'parent_item_colon' => wp_sprintf(_x('Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical taxonomys. Default is ‘Parent {taxonomy plural name}:’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
175 175
 			/* translators: %s: Taxonomy singular name */
176
-			'parent_item'       => wp_sprintf( _x( 'Parent %s', 'Label for the parent term', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
176
+			'parent_item'       => wp_sprintf(_x('Parent %s', 'Label for the parent term', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
177 177
 			/* translators: %s: Taxonomy singular name */
178
-			'filter_by_item'    => wp_sprintf( _x( 'Filter by %s', 'This label is only used for hierarchical taxonomies. Default \'Filter by {taxonomy singular name}\', used in the posts list table.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
178
+			'filter_by_item'    => wp_sprintf(_x('Filter by %s', 'This label is only used for hierarchical taxonomies. Default \'Filter by {taxonomy singular name}\', used in the posts list table.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
179 179
 		);
180 180
 
181 181
 		$labels = array_merge(
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		 * @param Taxonomy $taxonomy
192 192
 		 * @return array<string, string>
193 193
 		 */
194
-		$labels = apply_filters( Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels( $labels ), $taxonomy );
194
+		$labels = apply_filters(Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels($labels), $taxonomy);
195 195
 
196 196
 		// Compose args.
197 197
 		$args = array(
@@ -232,6 +232,6 @@  discard block
 block discarded – undo
232 232
 		 * @return array<string, string|bool|int|null|array<string, string>
233 233
 		 */
234 234
 		/* @phpstan-ignore-next-line, this is due to apply_filters type hints being wrong. */
235
-		return apply_filters( Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args( $args ), $taxonomy );
235
+		return apply_filters(Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args($args), $taxonomy);
236 236
 	}
237 237
 }
Please login to merge, or discard this patch.
src/Registration_Middleware/Registerable_Middleware.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param \PinkCrab\Loader\Hook_Loader $loader
53 53
 	 * @return void
54 54
 	 */
55
-	public function set_hook_loader( Hook_Loader $loader ) {
55
+	public function set_hook_loader(Hook_Loader $loader) {
56 56
 		$this->loader = $loader;
57 57
 	}
58 58
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param \PinkCrab\Perique\Interfaces\DI_Container $container
63 63
 	 * @return void
64 64
 	 */
65
-	public function set_di_container( DI_Container $container ): void {
65
+	public function set_di_container(DI_Container $container): void {
66 66
 		$this->container = $container;
67 67
 	}
68 68
 
@@ -72,27 +72,27 @@  discard block
 block discarded – undo
72 72
 	 * @param object|Registerable $class
73 73
 	 * @return object
74 74
 	 */
75
-	public function process( $class ) {
76
-		if ( ! is_a( $class, Registerable::class ) ) {
75
+	public function process($class) {
76
+		if ( ! is_a($class, Registerable::class)) {
77 77
 			return $class;
78 78
 		}
79 79
 
80 80
 		// Based on the registerable type.
81
-		switch ( true ) {
82
-			case is_a( $class, Post_Type::class ):
83
-				$this->process_post_type( $class );
81
+		switch (true) {
82
+			case is_a($class, Post_Type::class):
83
+				$this->process_post_type($class);
84 84
 				break;
85 85
 
86
-			case is_a( $class, Taxonomy::class ):
87
-				$this->process_taxonomy( $class );
86
+			case is_a($class, Taxonomy::class):
87
+				$this->process_taxonomy($class);
88 88
 				break;
89 89
 
90
-			case is_a( $class, Shared_Meta_Box_Controller::class ):
91
-				$this->process_shared_meta_box( $class );
90
+			case is_a($class, Shared_Meta_Box_Controller::class):
91
+				$this->process_shared_meta_box($class);
92 92
 				break;
93 93
 
94
-			case is_a( $class, Additional_Meta_Data_Controller::class ):
95
-				$this->process_additional_meta_data( $class );
94
+			case is_a($class, Additional_Meta_Data_Controller::class):
95
+				$this->process_additional_meta_data($class);
96 96
 				break;
97 97
 
98 98
 			default:
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 	 * @return void
111 111
 	 * @since 0.7.0
112 112
 	 */
113
-	protected function process_taxonomy( Taxonomy $taxonomy ): void {
113
+	protected function process_taxonomy(Taxonomy $taxonomy): void {
114 114
 		$this->loader->action(
115 115
 			'init',
116
-			static function() use ( $taxonomy ) {
116
+			static function() use ($taxonomy) {
117 117
 				Registrar_Factory::new()
118
-					->create_from_registerable( $taxonomy )
119
-					->register( $taxonomy );
118
+					->create_from_registerable($taxonomy)
119
+					->register($taxonomy);
120 120
 			}
121 121
 		);
122 122
 	}
@@ -128,21 +128,21 @@  discard block
 block discarded – undo
128 128
 	 * @return void
129 129
 	 * @since 0.7.0
130 130
 	 */
131
-	protected function process_post_type( Post_Type $post_type_registerable ) {
131
+	protected function process_post_type(Post_Type $post_type_registerable) {
132 132
 		// Register registerable.
133 133
 		$this->loader->action(
134 134
 			'init',
135
-			static function() use ( $post_type_registerable ) {
135
+			static function() use ($post_type_registerable) {
136 136
 				Registrar_Factory::new()
137
-					->create_from_registerable( $post_type_registerable )
138
-					->register( $post_type_registerable );
137
+					->create_from_registerable($post_type_registerable)
138
+					->register($post_type_registerable);
139 139
 			}
140 140
 		);
141 141
 
142 142
 		// Define use of gutenberg
143 143
 		$this->loader->filter(
144 144
 			'use_block_editor_for_post_type',
145
-			static function( bool $state, string $post_type ) use ( $post_type_registerable ): bool {
145
+			static function(bool $state, string $post_type) use ($post_type_registerable): bool {
146 146
 					return $post_type === $post_type_registerable->key
147 147
 						? (bool) $post_type_registerable->gutenberg
148 148
 						: $state;
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
 		);
153 153
 
154 154
 		// Register meta boxes.
155
-		$meta_boxes = $post_type_registerable->meta_boxes( array() );
155
+		$meta_boxes = $post_type_registerable->meta_boxes(array());
156 156
 
157
-		if ( ! empty( $meta_boxes ) ) {
157
+		if ( ! empty($meta_boxes)) {
158 158
 
159 159
 			// Create the registrar
160 160
 			$meta_box_registrar = $this->get_meta_box_registrar();
161 161
 
162 162
 			// Register each meta box.
163
-			foreach ( $meta_boxes as $meta_box ) {
164
-				$meta_box->screen( $post_type_registerable->key );
165
-				$meta_box_registrar->register( $meta_box );
163
+			foreach ($meta_boxes as $meta_box) {
164
+				$meta_box->screen($post_type_registerable->key);
165
+				$meta_box_registrar->register($meta_box);
166 166
 			}
167 167
 		}
168 168
 	}
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
 	 * @return void
176 176
 	 * @since 0.7.0
177 177
 	 */
178
-	public function process_shared_meta_box( Shared_Meta_Box_Controller $controller ): void {
178
+	public function process_shared_meta_box(Shared_Meta_Box_Controller $controller): void {
179 179
 		$registrar = new Shared_Meta_Box_Registrar(
180 180
 			$this->get_meta_box_registrar(),
181 181
 			Registrar_Factory::new()->meta_data_registrar()
182 182
 		);
183
-		$registrar->register( $controller );
183
+		$registrar->register($controller);
184 184
 	}
185 185
 
186 186
 	/**
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 	 * @return void
191 191
 	 * @since 0.8.0
192 192
 	 */
193
-	public function process_additional_meta_data( Additional_Meta_Data_Controller $controller ): void {
193
+	public function process_additional_meta_data(Additional_Meta_Data_Controller $controller): void {
194 194
 		$registrar = new Additional_Meta_Data_Registrar(
195 195
 			Registrar_Factory::new()->meta_data_registrar()
196 196
 		);
197
-		$registrar->register( $controller );
197
+		$registrar->register($controller);
198 198
 	}
199 199
 
200 200
 	/**
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @since 0.7.0
205 205
 	 */
206 206
 	public function get_meta_box_registrar(): Meta_Box_Registrar {
207
-		return Registrar_Factory::new()->meta_box_registrar( $this->container, $this->loader );
207
+		return Registrar_Factory::new()->meta_box_registrar($this->container, $this->loader);
208 208
 	}
209 209
 
210 210
 	public function setup(): void {
Please login to merge, or discard this patch.
src/Additional_Meta_Data_Controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,6 +38,6 @@
 block discarded – undo
38 38
 	 * @return Meta_Data[]
39 39
 	 * @codeCoverageIgnore
40 40
 	 */
41
-	abstract public function meta_data( array $meta_data ): array;
41
+	abstract public function meta_data(array $meta_data): array;
42 42
 
43 43
 }
Please login to merge, or discard this patch.
src/Registrar/Additional_Meta_Data_Registrar.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	protected $meta_data_registrar;
46 46
 
47
-	public function __construct( Meta_Data_Registrar $meta_data_registrar ) {
47
+	public function __construct(Meta_Data_Registrar $meta_data_registrar) {
48 48
 		$this->meta_data_registrar = $meta_data_registrar;
49 49
 	}
50 50
 
@@ -57,20 +57,20 @@  discard block
 block discarded – undo
57 57
 	 * @throws Exception If a none Additional_Meta_Data_Controller registerable is attempted to be registered.
58 58
 	 * @throws Exception If a meta type which is not POST, USER, TERM or COMMENT is attempted to be registered.
59 59
 	 */
60
-	public function register( Registerable $registerable ): void {
61
-		if ( ! is_a( $registerable, Additional_Meta_Data_Controller::class ) ) {
62
-			throw new Exception( 'Registerable must be an instance of Additional_Meta_Data_Controller' );
60
+	public function register(Registerable $registerable): void {
61
+		if ( ! is_a($registerable, Additional_Meta_Data_Controller::class)) {
62
+			throw new Exception('Registerable must be an instance of Additional_Meta_Data_Controller');
63 63
 		}
64 64
 
65 65
 		/** @var Additional_Meta_Data $registerable, Validation call below catches no Additional_Meta_Data Registerables */
66
-		$meta_data = $this->filter_meta_data( $registerable->meta_data( array() ) );
66
+		$meta_data = $this->filter_meta_data($registerable->meta_data(array()));
67 67
 
68 68
 		// Iterate through all meta data and register them.
69
-		foreach ( $meta_data as $meta_data_item ) {
70
-			switch ( $meta_data_item->get_meta_type() ) {
69
+		foreach ($meta_data as $meta_data_item) {
70
+			switch ($meta_data_item->get_meta_type()) {
71 71
 				case 'post':
72 72
 					// Throw if post type not defined.
73
-					if ( null === $meta_data_item->get_subtype() ) {
73
+					if (null === $meta_data_item->get_subtype()) {
74 74
 						throw new Exception(
75 75
 							sprintf(
76 76
 								'A post type must be defined when attempting to register post meta with meta key : %s',
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
 				case 'term':
89 89
 					// Throw if Taxonomy not defined.
90
-					if ( null === $meta_data_item->get_subtype() ) {
90
+					if (null === $meta_data_item->get_subtype()) {
91 91
 						throw new Exception(
92 92
 							sprintf(
93 93
 								'A taxonomy must be defined when attempting to register tern meta with meta key : %s',
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 					break;
116 116
 
117 117
 				default:
118
-					throw new Exception( 'Unexpected meta type' );
118
+					throw new Exception('Unexpected meta type');
119 119
 			}
120 120
 		}
121 121
 	}
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	 * @param mixed[] $meta_data
127 127
 	 * @return Meta_Data[]
128 128
 	 */
129
-	protected function filter_meta_data( array $meta_data ): array {
129
+	protected function filter_meta_data(array $meta_data): array {
130 130
 		return array_filter(
131 131
 			$meta_data,
132
-			function( $e ) {
133
-				return is_a( $e, Meta_Data::class );
132
+			function($e) {
133
+				return is_a($e, Meta_Data::class);
134 134
 			}
135 135
 		);
136 136
 	}
Please login to merge, or discard this patch.
src/Registrar/Meta_Data_Registrar.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 * @return bool
38 38
 	 * @throws \Exception if fails to register meta data.
39 39
 	 */
40
-	public function register_for_post_type( Meta_Data $meta, string $post_type ):bool {
41
-		return $this->register_meta( $meta, 'post', $post_type );
40
+	public function register_for_post_type(Meta_Data $meta, string $post_type):bool {
41
+		return $this->register_meta($meta, 'post', $post_type);
42 42
 	}
43 43
 
44 44
 	/**
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 * @return bool
50 50
 	 * @throws \Exception if fails to register meta data.
51 51
 	 */
52
-	public function register_for_term( Meta_Data $meta, string $taxonomy ):bool {
53
-		return $this->register_meta( $meta, 'term', $taxonomy );
52
+	public function register_for_term(Meta_Data $meta, string $taxonomy):bool {
53
+		return $this->register_meta($meta, 'term', $taxonomy);
54 54
 	}
55 55
 
56 56
 	/**
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	 * @return bool
61 61
 	 * @throws \Exception if fails to register meta data.
62 62
 	 */
63
-	public function register_for_user( Meta_Data $meta ): bool {
64
-		return $this->register_meta( $meta, 'user', '' );
63
+	public function register_for_user(Meta_Data $meta): bool {
64
+		return $this->register_meta($meta, 'user', '');
65 65
 	}
66 66
 
67 67
 	/**
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @return bool
72 72
 	 * @throws \Exception if fails to register meta data.
73 73
 	 */
74
-	public function register_for_comment( Meta_Data $meta ): bool {
75
-		return $this->register_meta( $meta, 'comment', '' );
74
+	public function register_for_comment(Meta_Data $meta): bool {
75
+		return $this->register_meta($meta, 'comment', '');
76 76
 	}
77 77
 
78 78
 	/**
@@ -86,25 +86,25 @@  discard block
 block discarded – undo
86 86
 	 * @return bool
87 87
 	 * @throws \Exception if fails to register meta data.
88 88
 	 */
89
-	protected function register_meta( Meta_Data $meta, string $meta_type, string $sub_type ): bool {
89
+	protected function register_meta(Meta_Data $meta, string $meta_type, string $sub_type): bool {
90 90
 		// Clone and set the post type, while enforcing it as a post meta.
91 91
 		$meta = clone $meta;
92
-		$meta->object_subtype( $sub_type );
93
-		$meta->meta_type( $meta_type );
92
+		$meta->object_subtype($sub_type);
93
+		$meta->meta_type($meta_type);
94 94
 
95 95
 		// Normalise rest schema model to array.
96
-		$meta = $this->normalise_rest_schema( $meta );
96
+		$meta = $this->normalise_rest_schema($meta);
97 97
 
98
-		$result = register_meta( $meta->get_meta_type(), $meta->get_meta_key(), $meta->parse_args() );
99
-		if ( ! $result ) {
98
+		$result = register_meta($meta->get_meta_type(), $meta->get_meta_key(), $meta->parse_args());
99
+		if ( ! $result) {
100 100
 			throw new \Exception(
101 101
 				"Failed to register {$meta->get_meta_key()} (meta) for {$sub_type} of {$meta_type} type"
102 102
 			);
103 103
 		}
104 104
 
105 105
 		// Maybe register rest fields.
106
-		if ( false !== $meta->get_rest_schema() ) {
107
-			$this->register_meta_rest_field( $meta );
106
+		if (false !== $meta->get_rest_schema()) {
107
+			$this->register_meta_rest_field($meta);
108 108
 		}
109 109
 
110 110
 		return $result;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
162 162
 	 * @param \PinkCrab\Registerables\Meta_Data $meta
163 163
 	 * @return callable(array<mixed>):void
164 164
 	 */
165
-	protected function create_rest_get_method( Meta_Data $meta ): callable {
166
-		return function( $model ) use ( $meta ) {
167
-			switch ( $meta->get_meta_type() ) {
165
+	protected function create_rest_get_method(Meta_Data $meta): callable {
166
+		return function($model) use ($meta) {
167
+			switch ($meta->get_meta_type()) {
168 168
 				case 'post':
169
-					$value = get_post_meta( $model['id'], $meta->get_meta_key(), true );
169
+					$value = get_post_meta($model['id'], $meta->get_meta_key(), true);
170 170
 					break;
171 171
 
172 172
 				case 'term':
173
-					$value = get_term_meta( $model['id'], $meta->get_meta_key(), true );
173
+					$value = get_term_meta($model['id'], $meta->get_meta_key(), true);
174 174
 					break;
175 175
 
176 176
 				case 'user':
177
-					$value = get_user_meta( $model['id'], $meta->get_meta_key(), true );
177
+					$value = get_user_meta($model['id'], $meta->get_meta_key(), true);
178 178
 					break;
179 179
 
180 180
 				case 'comment':
181
-					$value = get_comment_meta( $model['id'], $meta->get_meta_key(), true );
181
+					$value = get_comment_meta($model['id'], $meta->get_meta_key(), true);
182 182
 					break;
183 183
 
184 184
 				default:
@@ -196,31 +196,31 @@  discard block
 block discarded – undo
196 196
 	 * @param Meta_Data $meta
197 197
 	 * @return callable(mixed $value, \WP_Post|\WP_Term|\WP_User|\WP_Comment $object)
198 198
 	 */
199
-	protected function create_rest_update_method( Meta_Data $meta ): callable {
199
+	protected function create_rest_update_method(Meta_Data $meta): callable {
200 200
 		/**
201 201
 		 * @param mixed $value
202 202
 		 * @param \WP_Post|\WP_Term|\WP_User|\WP_Comment $object
203 203
 		 */
204
-		return function( $value, $object ) use ( $meta ) {
205
-			switch ( $meta->get_meta_type() ) {
204
+		return function($value, $object) use ($meta) {
205
+			switch ($meta->get_meta_type()) {
206 206
 				case 'post':
207 207
 					/** @var \WP_Post $object */
208
-					update_post_meta( $object->ID, $meta->get_meta_key(), $value );
208
+					update_post_meta($object->ID, $meta->get_meta_key(), $value);
209 209
 					break;
210 210
 
211 211
 				case 'term':
212 212
 					/** @var \WP_Term $object */
213
-					update_term_meta( $object->term_id, $meta->get_meta_key(), $value );
213
+					update_term_meta($object->term_id, $meta->get_meta_key(), $value);
214 214
 					break;
215 215
 
216 216
 				case 'user':
217 217
 					/** @var \WP_User $object */
218
-					update_user_meta( $object->ID, $meta->get_meta_key(), $value );
218
+					update_user_meta($object->ID, $meta->get_meta_key(), $value);
219 219
 					break;
220 220
 
221 221
 				case 'comment':
222 222
 					/** @var \WP_Comment $object */
223
-					update_comment_meta( (int) $object->comment_ID, $meta->get_meta_key(), $value );
223
+					update_comment_meta((int) $object->comment_ID, $meta->get_meta_key(), $value);
224 224
 					break;
225 225
 
226 226
 				default:
Please login to merge, or discard this patch.
src/Registrar/Post_Type_Registrar.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
 	 * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable
63 63
 	 * @return void
64 64
 	 */
65
-	public function register( Registerable $registerable ): void {
65
+	public function register(Registerable $registerable): void {
66 66
 		/** @var Post_Type $registerable, Validation call below catches no Post_Type Registerables */
67 67
 
68
-		if ( ! $this->validator->validate( $registerable ) ) {
68
+		if ( ! $this->validator->validate($registerable)) {
69 69
 			throw new Exception(
70 70
 				sprintf(
71 71
 					'Failed validating post type model(%s) with errors: %s',
72
-					get_class( $registerable ),
73
-					join( ', ', $this->validator->get_errors() )
72
+					get_class($registerable),
73
+					join(', ', $this->validator->get_errors())
74 74
 				)
75 75
 			);
76 76
 		}
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 		// Attempt to register the post type.
79 79
 		try {
80 80
 			/* @phpstan-ignore-next-line */
81
-			$result = register_post_type( $registerable->key, $this->compile_args( $registerable ) );
82
-			if ( is_a( $result, \WP_Error::class ) ) {
83
-				throw new Exception( join( $result->get_error_messages() ) );
81
+			$result = register_post_type($registerable->key, $this->compile_args($registerable));
82
+			if (is_a($result, \WP_Error::class)) {
83
+				throw new Exception(join($result->get_error_messages()));
84 84
 			}
85
-		} catch ( \Throwable $th ) {
86
-			throw new Exception( "Failed to register {$registerable->key} post type ({$th->getMessage()})" );
85
+		} catch (\Throwable $th) {
86
+			throw new Exception("Failed to register {$registerable->key} post type ({$th->getMessage()})");
87 87
 		}
88 88
 
89 89
 		// Register all meta data for post type.
90
-		$this->register_meta_data( $registerable );
90
+		$this->register_meta_data($registerable);
91 91
 	}
92 92
 
93 93
 	/**
@@ -96,18 +96,18 @@  discard block
 block discarded – undo
96 96
 	 * @param \PinkCrab\Registerables\Post_Type $post_type
97 97
 	 * @return void
98 98
 	 */
99
-	protected function register_meta_data( Post_Type $post_type ): void {
99
+	protected function register_meta_data(Post_Type $post_type): void {
100 100
 
101 101
 		// Get all meta fields for post_type.
102
-		$meta_fields = $post_type->meta_data( array() );
102
+		$meta_fields = $post_type->meta_data(array());
103 103
 		// Attempt to register all Meta for post_type.
104 104
 		try {
105
-			foreach ( $meta_fields as $meta_field ) {
105
+			foreach ($meta_fields as $meta_field) {
106 106
 				$this->meta_data_registrar
107
-					->register_for_post_type( $meta_field, $post_type->key );
107
+					->register_for_post_type($meta_field, $post_type->key);
108 108
 			}
109
-		} catch ( \Throwable $th ) {
110
-			throw new Exception( $th->getMessage() );
109
+		} catch (\Throwable $th) {
110
+			throw new Exception($th->getMessage());
111 111
 		}
112 112
 	}
113 113
 
@@ -119,64 +119,64 @@  discard block
 block discarded – undo
119 119
 	 * @param \PinkCrab\Registerables\Post_Type $post_type
120 120
 	 * @return array<string, string|int|array<string, string>>
121 121
 	 */
122
-	protected function compile_args( Post_Type $post_type ): array {
122
+	protected function compile_args(Post_Type $post_type): array {
123 123
 		// Create the labels.
124 124
 		$labels = array(
125 125
 			'name'                     => $post_type->plural,
126 126
 			'singular_name'            => $post_type->singular,
127
-			'add_new'                  => _x( 'Add New', 'Add new post label of custom post type', 'pinkcrab' ),
127
+			'add_new'                  => _x('Add New', 'Add new post label of custom post type', 'pinkcrab'),
128 128
 			/* translators: %s: Post type singular name */
129
-			'add_new_item'             => wp_sprintf( _x( 'Add New %s', 'Label for adding a new singular item. Default is ‘Add New {post type singular name}’.', 'pinkcrab' ), $post_type->singular ),
129
+			'add_new_item'             => wp_sprintf(_x('Add New %s', 'Label for adding a new singular item. Default is ‘Add New {post type singular name}’.', 'pinkcrab'), $post_type->singular),
130 130
 			/* translators: %s: Post type singular name */
131
-			'edit_item'                => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {post type singular name}’.', 'pinkcrab' ), $post_type->singular ),
131
+			'edit_item'                => wp_sprintf(_x('Edit %s', 'Label for editing a singular item. Default is ‘Edit {post type singular name}’.', 'pinkcrab'), $post_type->singular),
132 132
 			/* translators: %s: Post type singular name */
133
-			'new_item'                 => wp_sprintf( _x( 'New %s', 'Label for the new item page title. Default is ‘New {post type singular name}’.', 'pinkcrab' ), $post_type->singular ),
133
+			'new_item'                 => wp_sprintf(_x('New %s', 'Label for the new item page title. Default is ‘New {post type singular name}’.', 'pinkcrab'), $post_type->singular),
134 134
 			/* translators: %s: Post type singular name */
135
-			'view_item'                => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {post type singular name}’.', 'pinkcrab' ), $post_type->singular ),
135
+			'view_item'                => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {post type singular name}’.', 'pinkcrab'), $post_type->singular),
136 136
 			/* translators: %s: Post type plural name */
137
-			'view_items'               => wp_sprintf( _x( 'View %s', 'Label for viewing post type archives. Default is ‘View {post type plural name}’.', 'pinkcrab' ), $post_type->plural ),
137
+			'view_items'               => wp_sprintf(_x('View %s', 'Label for viewing post type archives. Default is ‘View {post type plural name}’.', 'pinkcrab'), $post_type->plural),
138 138
 			/* translators: %s: Post type singular name */
139
-			'search_items'             => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {post type plural name}’.', 'pinkcrab' ), $post_type->singular ),
139
+			'search_items'             => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {post type plural name}’.', 'pinkcrab'), $post_type->singular),
140 140
 			/* translators: %s: Post type plural name */
141
-			'not_found'                => wp_sprintf( _x( 'No %s found', 'Label used when no items are found. Default is ‘No {post type plural name} found’.', 'pinkcrab' ), $post_type->plural ),
141
+			'not_found'                => wp_sprintf(_x('No %s found', 'Label used when no items are found. Default is ‘No {post type plural name} found’.', 'pinkcrab'), $post_type->plural),
142 142
 			/* translators: %s: Post type plural name */
143
-			'not_found_in_trash'       => wp_sprintf( _x( 'No %s found in Trash', 'Label used when no items are in the Trash. Default is ‘No {post type plural name} found in Trash’.', 'pinkcrab' ), $post_type->plural ),
143
+			'not_found_in_trash'       => wp_sprintf(_x('No %s found in Trash', 'Label used when no items are in the Trash. Default is ‘No {post type plural name} found in Trash’.', 'pinkcrab'), $post_type->plural),
144 144
 			/* translators: %s: Post type singular name */
145
-			'parent_item_colon'        => wp_sprintf( _x( 'Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical post types. Default is ‘Parent {post type plural name}:’.', 'pinkcrab' ), $post_type->singular ),
145
+			'parent_item_colon'        => wp_sprintf(_x('Parent %s:', 'Label used to prefix parents of hierarchical items. Not used on non-hierarchical post types. Default is ‘Parent {post type plural name}:’.', 'pinkcrab'), $post_type->singular),
146 146
 			/* translators: %s: Post type singular name */
147
-			'all_items'                => wp_sprintf( _x( 'All %s', 'Label to signify all items in a submenu link. Default is ‘All {post type plural name}’.', 'pinkcrab' ), $post_type->plural ),
147
+			'all_items'                => wp_sprintf(_x('All %s', 'Label to signify all items in a submenu link. Default is ‘All {post type plural name}’.', 'pinkcrab'), $post_type->plural),
148 148
 			/* translators: %s: Post type plural name */
149
-			'archives'                 => wp_sprintf( _x( '%s Archives', ' Label for archives in nav menus. Default is ‘Post Archives’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ),
149
+			'archives'                 => wp_sprintf(_x('%s Archives', ' Label for archives in nav menus. Default is ‘Post Archives’.', 'pinkcrab'), \ucfirst($post_type->plural)),
150 150
 			/* translators: %s: Post type plural name */
151
-			'attributes'               => wp_sprintf( _x( '%s Attributes', 'Label for the attributes meta box. Default is ‘{post type plural name} Attributes’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ),
151
+			'attributes'               => wp_sprintf(_x('%s Attributes', 'Label for the attributes meta box. Default is ‘{post type plural name} Attributes’.', 'pinkcrab'), \ucfirst($post_type->plural)),
152 152
 			/* translators: %s: Post type singular name */
153
-			'insert_into_item'         => wp_sprintf( _x( 'Insert into %s', 'Label for the media frame button. Default is ‘Insert into {post type plural name}’.', 'pinkcrab' ), $post_type->singular ),
153
+			'insert_into_item'         => wp_sprintf(_x('Insert into %s', 'Label for the media frame button. Default is ‘Insert into {post type plural name}’.', 'pinkcrab'), $post_type->singular),
154 154
 			/* translators: %s: Post type singular name */
155
-			'uploaded_to_this_item'    => wp_sprintf( _x( 'Uploaded to this %s', 'Label for the media frame filter. Default is ‘Uploaded to this {post type plural name}’.', 'pinkcrab' ), $post_type->singular ),
156
-			'featured_image'           => _x( 'Featured image', 'Label for the featured image meta box title. Default is ‘Featured image’.', 'pinkcrab' ),
157
-			'set_featured_image'       => _x( 'Set featured image', 'Label for setting the featured image. Default is ‘Set featured image’.', 'pinkcrab' ),
158
-			'remove_featured_image'    => _x( 'Remove featured image', 'Label for removing the featured image. Default is ‘Remove featured image’.', 'pinkcrab' ),
159
-			'use_featured_image'       => _x( 'Use as featured image', 'Label in the media frame for using a featured image. Default is ‘Use as featured image’.', 'pinkcrab' ),
155
+			'uploaded_to_this_item'    => wp_sprintf(_x('Uploaded to this %s', 'Label for the media frame filter. Default is ‘Uploaded to this {post type plural name}’.', 'pinkcrab'), $post_type->singular),
156
+			'featured_image'           => _x('Featured image', 'Label for the featured image meta box title. Default is ‘Featured image’.', 'pinkcrab'),
157
+			'set_featured_image'       => _x('Set featured image', 'Label for setting the featured image. Default is ‘Set featured image’.', 'pinkcrab'),
158
+			'remove_featured_image'    => _x('Remove featured image', 'Label for removing the featured image. Default is ‘Remove featured image’.', 'pinkcrab'),
159
+			'use_featured_image'       => _x('Use as featured image', 'Label in the media frame for using a featured image. Default is ‘Use as featured image’.', 'pinkcrab'),
160 160
 			'menu_name'                => $post_type->plural,
161 161
 			/* translators: %s: Post type plural name */
162
-			'filter_items_list'        => wp_sprintf( _x( 'Filter %s list', 'Label for the table views hidden heading. Default is ‘Filter {post type plural name} list’.', 'pinkcrab' ), $post_type->plural ),
163
-			'filter_by_date'           => _x( 'Filter by date', 'Label for the date filter in list tables. Default is ‘Filter by date’.', 'pinkcrab' ),
162
+			'filter_items_list'        => wp_sprintf(_x('Filter %s list', 'Label for the table views hidden heading. Default is ‘Filter {post type plural name} list’.', 'pinkcrab'), $post_type->plural),
163
+			'filter_by_date'           => _x('Filter by date', 'Label for the date filter in list tables. Default is ‘Filter by date’.', 'pinkcrab'),
164 164
 			/* translators: %s: Post type plural name */
165
-			'items_list'               => wp_sprintf( _x( '%s list', 'Label for the table hidden heading. Default is ‘{post type plural name} list’.', 'pinkcrab' ), \ucfirst( $post_type->plural ) ),
165
+			'items_list'               => wp_sprintf(_x('%s list', 'Label for the table hidden heading. Default is ‘{post type plural name} list’.', 'pinkcrab'), \ucfirst($post_type->plural)),
166 166
 			/* translators: %s: Post type singular name */
167
-			'item_published'           => wp_sprintf( _x( '%s published', 'Label used when an item is published. Default is ‘{post type singular name} published’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ),
167
+			'item_published'           => wp_sprintf(_x('%s published', 'Label used when an item is published. Default is ‘{post type singular name} published’.', 'pinkcrab'), \ucfirst($post_type->singular)),
168 168
 			/* translators: %s: Post type singular name */
169
-			'item_published_privately' => wp_sprintf( _x( '%s published privately', 'Label used when an item is published with private visibility. Default is ‘{post type singular name} published privately.’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ),
169
+			'item_published_privately' => wp_sprintf(_x('%s published privately', 'Label used when an item is published with private visibility. Default is ‘{post type singular name} published privately.’.', 'pinkcrab'), \ucfirst($post_type->singular)),
170 170
 			/* translators: %s: Post type singular name */
171
-			'item_reverted_to_draft'   => wp_sprintf( _x( '%s reverted to draft', 'Label used when an item is switched to a draft. Default is ‘{post type singular name} reverted to draft’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ),
171
+			'item_reverted_to_draft'   => wp_sprintf(_x('%s reverted to draft', 'Label used when an item is switched to a draft. Default is ‘{post type singular name} reverted to draft’.', 'pinkcrab'), \ucfirst($post_type->singular)),
172 172
 			/* translators: %s: Post type singular name */
173
-			'item_scheduled'           => wp_sprintf( _x( '%s scheduled', 'Label used when an item is scheduled for publishing. Default is ‘{post type singular name} scheduled.’ ', 'pinkcrab' ), \ucfirst( $post_type->singular ) ),
173
+			'item_scheduled'           => wp_sprintf(_x('%s scheduled', 'Label used when an item is scheduled for publishing. Default is ‘{post type singular name} scheduled.’ ', 'pinkcrab'), \ucfirst($post_type->singular)),
174 174
 			/* translators: %s: Post type singular name */
175
-			'item_updated'             => wp_sprintf( _x( '%s updated', 'Label used when an item is updated. Default is ‘{post type singular name} updated.’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ),
175
+			'item_updated'             => wp_sprintf(_x('%s updated', 'Label used when an item is updated. Default is ‘{post type singular name} updated.’.', 'pinkcrab'), \ucfirst($post_type->singular)),
176 176
 			/* translators: %s: Post type singular name */
177
-			'item_link'                => wp_sprintf( _x( '%s Link', 'Title for a navigation link block variation. Default is ‘{post type singular name} Link’.', 'pinkcrab' ), \ucfirst( $post_type->singular ) ),
177
+			'item_link'                => wp_sprintf(_x('%s Link', 'Title for a navigation link block variation. Default is ‘{post type singular name} Link’.', 'pinkcrab'), \ucfirst($post_type->singular)),
178 178
 			/* translators: %s: Post type singular name */
179
-			'item_link_description'    => wp_sprintf( _x( 'A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {post type singular name}’.', 'pinkcrab' ), $post_type->singular ),
179
+			'item_link_description'    => wp_sprintf(_x('A link to a %s', 'Description for a navigation link block variation. Default is ‘A link to a {post type singular name}’.', 'pinkcrab'), $post_type->singular),
180 180
 		);
181 181
 
182 182
 		/**
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 		 * @param Post_Type $cpt
188 188
 		 * @return array<string, string>
189 189
 		 */
190
-		$labels = apply_filters( Registerable_Hooks::POST_TYPE_LABELS, $post_type->filter_labels( $labels ), $post_type );
190
+		$labels = apply_filters(Registerable_Hooks::POST_TYPE_LABELS, $post_type->filter_labels($labels), $post_type);
191 191
 
192 192
 		// Set the rewrite rules if not defined.
193
-		if ( is_null( $post_type->rewrite ) ) {
193
+		if (is_null($post_type->rewrite)) {
194 194
 			$post_type->rewrite = array(
195 195
 				'slug'       => $post_type->key,
196 196
 				'with_front' => true,
@@ -203,31 +203,31 @@  discard block
 block discarded – undo
203 203
 		$args = array(
204 204
 			'labels'                => $labels,
205 205
 			'description'           => $post_type->description ?? $post_type->plural,
206
-			'hierarchical'          => is_bool( $post_type->hierarchical ) ? $post_type->hierarchical : false,
206
+			'hierarchical'          => is_bool($post_type->hierarchical) ? $post_type->hierarchical : false,
207 207
 			'supports'              => $post_type->supports,
208
-			'public'                => is_bool( $post_type->public ) ? $post_type->public : true,
209
-			'show_ui'               => is_bool( $post_type->show_ui ) ? $post_type->show_ui : true,
210
-			'show_in_menu'          => is_bool( $post_type->show_in_menu ) ? $post_type->show_in_menu : true,
211
-			'show_in_admin_bar'     => is_bool( $post_type->show_in_admin_bar ) ? $post_type->show_in_admin_bar : true,
208
+			'public'                => is_bool($post_type->public) ? $post_type->public : true,
209
+			'show_ui'               => is_bool($post_type->show_ui) ? $post_type->show_ui : true,
210
+			'show_in_menu'          => is_bool($post_type->show_in_menu) ? $post_type->show_in_menu : true,
211
+			'show_in_admin_bar'     => is_bool($post_type->show_in_admin_bar) ? $post_type->show_in_admin_bar : true,
212 212
 			'menu_position'         => $post_type->menu_position,
213 213
 			'menu_icon'             => $post_type->dashicon,
214
-			'show_in_nav_menus'     => is_bool( $post_type->show_in_nav_menus ) ? $post_type->show_in_nav_menus : true,
215
-			'publicly_queryable'    => is_bool( $post_type->publicly_queryable ) ? $post_type->publicly_queryable : true,
216
-			'exclude_from_search'   => is_bool( $post_type->exclude_from_search ) ? $post_type->exclude_from_search : true,
217
-			'has_archive'           => is_bool( $post_type->has_archive ) ? $post_type->has_archive : true,
218
-			'query_var'             => is_bool( $post_type->query_var ) ? $post_type->query_var : false,
219
-			'can_export'            => is_bool( $post_type->can_export ) ? $post_type->can_export : true,
220
-			'rewrite'               => is_bool( $post_type->rewrite ) ? $post_type->rewrite : false,
214
+			'show_in_nav_menus'     => is_bool($post_type->show_in_nav_menus) ? $post_type->show_in_nav_menus : true,
215
+			'publicly_queryable'    => is_bool($post_type->publicly_queryable) ? $post_type->publicly_queryable : true,
216
+			'exclude_from_search'   => is_bool($post_type->exclude_from_search) ? $post_type->exclude_from_search : true,
217
+			'has_archive'           => is_bool($post_type->has_archive) ? $post_type->has_archive : true,
218
+			'query_var'             => is_bool($post_type->query_var) ? $post_type->query_var : false,
219
+			'can_export'            => is_bool($post_type->can_export) ? $post_type->can_export : true,
220
+			'rewrite'               => is_bool($post_type->rewrite) ? $post_type->rewrite : false,
221 221
 			'capability_type'       => $post_type->capability_type,
222 222
 			'capabilities'          => $post_type->capabilities,
223 223
 			'taxonomies'            => $post_type->taxonomies,
224
-			'show_in_rest'          => is_bool( $post_type->show_in_rest ) ? $post_type->show_in_rest : true,
224
+			'show_in_rest'          => is_bool($post_type->show_in_rest) ? $post_type->show_in_rest : true,
225 225
 			'rest_base'             => $post_type->rest_base ?? $post_type->key,
226
-			'rest_controller_class' => \class_exists( $post_type->rest_controller_class ) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class,
227
-			'delete_with_user'      => \is_bool( $post_type->delete_with_user ) ? $post_type->delete_with_user : null,
228
-			'template'              => \is_array( $post_type->template ) ? $post_type->template : array(),
229
-			'template_lock'         => \is_string( $post_type->template_lock ) ? $post_type->template_lock : false,
230
-			'map_meta_cap'          => \is_bool( $post_type->map_meta_cap ) ? $post_type->map_meta_cap : false,
226
+			'rest_controller_class' => \class_exists($post_type->rest_controller_class) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class,
227
+			'delete_with_user'      => \is_bool($post_type->delete_with_user) ? $post_type->delete_with_user : null,
228
+			'template'              => \is_array($post_type->template) ? $post_type->template : array(),
229
+			'template_lock'         => \is_string($post_type->template_lock) ? $post_type->template_lock : false,
230
+			'map_meta_cap'          => \is_bool($post_type->map_meta_cap) ? $post_type->map_meta_cap : false,
231 231
 		);
232 232
 
233 233
 		/**
@@ -239,6 +239,6 @@  discard block
 block discarded – undo
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
 }
Please login to merge, or discard this patch.