Passed
Push — master ( 5ec981...83bd91 )
by Glynn
05:52 queued 02:42
created
src/Registrar/Post_Type_Registrar.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	protected $validator;
42 42
 
43
-	public function __construct( Post_Type_Validator $validator ) {
43
+	public function __construct(Post_Type_Validator $validator) {
44 44
 		$this->validator = $validator;
45 45
 	}
46 46
 
@@ -50,31 +50,31 @@  discard block
 block discarded – undo
50 50
 	 * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable
51 51
 	 * @return void
52 52
 	 */
53
-	public function register( Registerable $registerable ): void {
53
+	public function register(Registerable $registerable): void {
54 54
 		/** @var Post_Type $registerable, Validation call below catches no Post_Type Registerables */
55 55
 
56
-		if ( ! $this->validator->validate( $registerable ) ) {
56
+		if ( ! $this->validator->validate($registerable)) {
57 57
 			throw new Exception(
58 58
 				sprintf(
59 59
 					'Failed validating post type model(%s) with errors: %s',
60
-					get_class( $registerable ),
61
-					join( ', ', $this->validator->get_errors() )
60
+					get_class($registerable),
61
+					join(', ', $this->validator->get_errors())
62 62
 				)
63 63
 			);
64 64
 		}
65 65
 
66 66
 		// Attempt to register the post type.
67 67
 		try {
68
-			$result = register_post_type( $registerable->key, $this->compile_args( $registerable ) );
69
-			if ( is_a( $result, \WP_Error::class ) ) {
70
-				throw new Exception( join( $result->get_error_messages() ) );
68
+			$result = register_post_type($registerable->key, $this->compile_args($registerable));
69
+			if (is_a($result, \WP_Error::class)) {
70
+				throw new Exception(join($result->get_error_messages()));
71 71
 			}
72
-		} catch ( \Throwable $th ) {
73
-			throw new Exception( "Failed to register {$registerable->key} post type ({$th->getMessage()})" );
72
+		} catch (\Throwable $th) {
73
+			throw new Exception("Failed to register {$registerable->key} post type ({$th->getMessage()})");
74 74
 		}
75 75
 
76 76
 		// Register all meta data for post type.
77
-		$this->register_meta_data( $registerable );
77
+		$this->register_meta_data($registerable);
78 78
 	}
79 79
 
80 80
 	/**
@@ -83,24 +83,24 @@  discard block
 block discarded – undo
83 83
 	 * @param \PinkCrab\Registerables\Post_Type $post_type
84 84
 	 * @return void
85 85
 	 */
86
-	protected function register_meta_data( Post_Type $post_type ): void {
86
+	protected function register_meta_data(Post_Type $post_type): void {
87 87
 
88 88
 		// Get all meta fields for post_type.
89
-		$meta_fields = $post_type->meta_data( array() );
89
+		$meta_fields = $post_type->meta_data(array());
90 90
 		// Attempt to register all Meta for post_type.
91 91
 		try {
92
-			foreach ( $meta_fields as $meta_field ) {
92
+			foreach ($meta_fields as $meta_field) {
93 93
 				// Set object data for this post_type.
94
-				$meta_field->object_subtype( $post_type->key );
95
-				$meta_field->meta_type( 'post' );
94
+				$meta_field->object_subtype($post_type->key);
95
+				$meta_field->meta_type('post');
96 96
 
97
-				$result = register_meta( $meta_field->get_meta_type(), $meta_field->get_meta_key(), $meta_field->parse_args() );
98
-				if ( ! $result ) {
99
-					throw new Exception( "Failed to register {$meta_field->get_meta_key()} (meta) for {$post_type->singular} post type" );
97
+				$result = register_meta($meta_field->get_meta_type(), $meta_field->get_meta_key(), $meta_field->parse_args());
98
+				if ( ! $result) {
99
+					throw new Exception("Failed to register {$meta_field->get_meta_key()} (meta) for {$post_type->singular} post type");
100 100
 				}
101 101
 			}
102
-		} catch ( \Throwable $th ) {
103
-			throw new Exception( $th->getMessage() );
102
+		} catch (\Throwable $th) {
103
+			throw new Exception($th->getMessage());
104 104
 		}
105 105
 	}
106 106
 
@@ -110,64 +110,64 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
 		$args = array(
195 195
 			'labels'                => $labels,
196 196
 			'description'           => $post_type->description ?: $post_type->plural,
197
-			'hierarchical'          => is_bool( $post_type->hierarchical ) ? $post_type->hierarchical : false,
197
+			'hierarchical'          => is_bool($post_type->hierarchical) ? $post_type->hierarchical : false,
198 198
 			'supports'              => $post_type->supports,
199
-			'public'                => is_bool( $post_type->public ) ? $post_type->public : true,
200
-			'show_ui'               => is_bool( $post_type->show_ui ) ? $post_type->show_ui : true,
201
-			'show_in_menu'          => is_bool( $post_type->show_in_menu ) ? $post_type->show_in_menu : true,
202
-			'show_in_admin_bar'     => is_bool( $post_type->show_in_admin_bar ) ? $post_type->show_in_admin_bar : true,
199
+			'public'                => is_bool($post_type->public) ? $post_type->public : true,
200
+			'show_ui'               => is_bool($post_type->show_ui) ? $post_type->show_ui : true,
201
+			'show_in_menu'          => is_bool($post_type->show_in_menu) ? $post_type->show_in_menu : true,
202
+			'show_in_admin_bar'     => is_bool($post_type->show_in_admin_bar) ? $post_type->show_in_admin_bar : true,
203 203
 			'menu_position'         => $post_type->menu_position ?: 60,
204 204
 			'menu_icon'             => $post_type->dashicon ?: 'dashicons-pets',
205
-			'show_in_nav_menus'     => is_bool( $post_type->show_in_nav_menus ) ? $post_type->show_in_nav_menus : true,
206
-			'publicly_queryable'    => is_bool( $post_type->publicly_queryable ) ? $post_type->publicly_queryable : true,
207
-			'exclude_from_search'   => is_bool( $post_type->exclude_from_search ) ? $post_type->exclude_from_search : true,
208
-			'has_archive'           => is_bool( $post_type->has_archive ) ? $post_type->has_archive : true,
209
-			'query_var'             => is_bool( $post_type->query_var ) ? $post_type->query_var : false,
210
-			'can_export'            => is_bool( $post_type->can_export ) ? $post_type->can_export : true,
211
-			'rewrite'               => is_bool( $post_type->rewrite ) ? $post_type->rewrite : false,
205
+			'show_in_nav_menus'     => is_bool($post_type->show_in_nav_menus) ? $post_type->show_in_nav_menus : true,
206
+			'publicly_queryable'    => is_bool($post_type->publicly_queryable) ? $post_type->publicly_queryable : true,
207
+			'exclude_from_search'   => is_bool($post_type->exclude_from_search) ? $post_type->exclude_from_search : true,
208
+			'has_archive'           => is_bool($post_type->has_archive) ? $post_type->has_archive : true,
209
+			'query_var'             => is_bool($post_type->query_var) ? $post_type->query_var : false,
210
+			'can_export'            => is_bool($post_type->can_export) ? $post_type->can_export : true,
211
+			'rewrite'               => is_bool($post_type->rewrite) ? $post_type->rewrite : false,
212 212
 			'capability_type'       => $post_type->capability_type ?: 'page',
213 213
 			'capabilities'          => $post_type->capabilities ?: array(),
214 214
 			'taxonomies'            => $post_type->taxonomies ?: array(),
215
-			'show_in_rest'          => is_bool( $post_type->show_in_rest ) ? $post_type->show_in_rest : true,
215
+			'show_in_rest'          => is_bool($post_type->show_in_rest) ? $post_type->show_in_rest : true,
216 216
 			'rest_base'             => $post_type->rest_base ?? $post_type->key,
217
-			'rest_controller_class' => \class_exists( $post_type->rest_controller_class ) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class,
218
-			'delete_with_user'      => \is_bool( $post_type->delete_with_user ) ? $post_type->delete_with_user : null,
219
-			'template'              => \is_array( $post_type->templates ) ? $post_type->templates : array(),
220
-			'template_lock'         => \is_string( $post_type->template_lock ) ? $post_type->template_lock : false,
217
+			'rest_controller_class' => \class_exists($post_type->rest_controller_class) ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class,
218
+			'delete_with_user'      => \is_bool($post_type->delete_with_user) ? $post_type->delete_with_user : null,
219
+			'template'              => \is_array($post_type->templates) ? $post_type->templates : array(),
220
+			'template_lock'         => \is_string($post_type->template_lock) ? $post_type->template_lock : false,
221 221
 		);
222 222
 
223 223
 		/**
@@ -227,6 +227,6 @@  discard block
 block discarded – undo
227 227
 		 * @param Post_Type $cpt
228 228
 		 * @return array<string, string|bool|int|null|array<string, string>
229 229
 		 */
230
-		return apply_filters( Registerable_Hooks::POST_TYPE_ARGS, $post_type->filter_args( $args ), $post_type );
230
+		return apply_filters(Registerable_Hooks::POST_TYPE_ARGS, $post_type->filter_args($args), $post_type);
231 231
 	}
232 232
 }
Please login to merge, or discard this patch.
src/Registrar/Taxonomy_Registrar.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	protected $validator;
42 42
 
43
-	public function __construct( Taxonomy_Validator $validator ) {
43
+	public function __construct(Taxonomy_Validator $validator) {
44 44
 		$this->validator = $validator;
45 45
 	}
46 46
 
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
 	 * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable
51 51
 	 * @return void
52 52
 	 */
53
-	public function register( Registerable $registerable ): void {
53
+	public function register(Registerable $registerable): void {
54 54
 		/** @var Taxonomy $registerable, Validation call below catches no Post_Type Registerables */
55 55
 
56
-		if ( ! $this->validator->validate( $registerable ) ) {
56
+		if ( ! $this->validator->validate($registerable)) {
57 57
 			throw new Exception(
58 58
 				sprintf(
59 59
 					'Failed validating taxonomy model(%s) with errors: %s',
60
-					get_class( $registerable ),
61
-					join( ', ', $this->validator->get_errors() )
60
+					get_class($registerable),
61
+					join(', ', $this->validator->get_errors())
62 62
 				)
63 63
 			);
64 64
 		}
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 			$result = \register_taxonomy(
69 69
 				$registerable->slug,
70 70
 				$registerable->object_type,
71
-				$this->compile_args( $registerable )
71
+				$this->compile_args($registerable)
72 72
 			);
73 73
 
74
-			if ( is_a( $result, \WP_Error::class ) ) {
75
-				throw new Exception( join( $result->get_error_messages() ) );
74
+			if (is_a($result, \WP_Error::class)) {
75
+				throw new Exception(join($result->get_error_messages()));
76 76
 			}
77
-		} catch ( \Throwable $th ) {
78
-			throw new Exception( "Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})" );
77
+		} catch (\Throwable $th) {
78
+			throw new Exception("Failed to register {$registerable->slug} taxonomy ({$th->getMessage()})");
79 79
 		}
80 80
 
81 81
 		// Register any associated meta data.
82
-		$this->register_meta_data( $registerable );
82
+		$this->register_meta_data($registerable);
83 83
 
84 84
 	}
85 85
 
@@ -89,25 +89,25 @@  discard block
 block discarded – undo
89 89
 	 * @param \PinkCrab\Registerables\Taxonomy $taxonomy
90 90
 	 * @return void
91 91
 	 */
92
-	protected function register_meta_data( Taxonomy $taxonomy ): void {
92
+	protected function register_meta_data(Taxonomy $taxonomy): void {
93 93
 
94 94
 		// Get all meta fields for taxonomy.
95
-		$meta_fields = $taxonomy->meta_data( array() );
95
+		$meta_fields = $taxonomy->meta_data(array());
96 96
 
97 97
 		// Attempt to register all Meta for taxonomy.
98 98
 		try {
99
-			foreach ( $meta_fields as $meta_field ) {
99
+			foreach ($meta_fields as $meta_field) {
100 100
 				// Set object data for this taxonomy.
101
-				$meta_field->object_subtype( $taxonomy->slug );
102
-				$meta_field->meta_type( 'term' );
101
+				$meta_field->object_subtype($taxonomy->slug);
102
+				$meta_field->meta_type('term');
103 103
 
104
-				$result = register_meta( $meta_field->get_meta_type(), $meta_field->get_meta_key(), $meta_field->parse_args() );
105
-				if ( ! $result ) {
106
-					throw new Exception( "Failed to register {$meta_field->get_meta_key()} (meta) for {$taxonomy->singular} taxonomy" );
104
+				$result = register_meta($meta_field->get_meta_type(), $meta_field->get_meta_key(), $meta_field->parse_args());
105
+				if ( ! $result) {
106
+					throw new Exception("Failed to register {$meta_field->get_meta_key()} (meta) for {$taxonomy->singular} taxonomy");
107 107
 				}
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
 
@@ -117,59 +117,59 @@  discard block
 block discarded – undo
117 117
 	 * @param \PinkCrab\Registerables\Taxonomy $taxonomy
118 118
 	 * @return array<string, string|int|array<string, string>>
119 119
 	 */
120
-	protected function compile_args( Taxonomy $taxonomy ): array {
120
+	protected function compile_args(Taxonomy $taxonomy): array {
121 121
 		// Create the labels.
122 122
 		$base_labels = array(
123 123
 			'name'                  => $taxonomy->plural,
124 124
 			'singular_name'         => $taxonomy->singular,
125
-			'menu_name'             => \ucfirst( \esc_attr( $taxonomy->plural ?? '' ) ),
125
+			'menu_name'             => \ucfirst(\esc_attr($taxonomy->plural ?? '')),
126 126
 			/* translators: %s: Taxonomy plural name */
127
-			'search_items'          => wp_sprintf( _x( 'Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
127
+			'search_items'          => wp_sprintf(_x('Search %s', 'Label for searching plural items. Default is ‘Search {taxonomy plural name}’.', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
128 128
 			/* translators: %s: Taxonomy plural name */
129
-			'popular_items'         => wp_sprintf( _x( 'Popular %s', '**', 'pinkcrab' ), \esc_attr( $taxonomy->plural ?? '' ) ),
129
+			'popular_items'         => wp_sprintf(_x('Popular %s', '**', 'pinkcrab'), \esc_attr($taxonomy->plural ?? '')),
130 130
 			/* translators: %s: Taxonomy singular name */
131
-			'edit_item'             => wp_sprintf( _x( 'Edit %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
131
+			'edit_item'             => wp_sprintf(_x('Edit %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
-			'view_item'             => wp_sprintf( _x( 'View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
133
+			'view_item'             => wp_sprintf(_x('View %s', 'Label for viewing a singular item. Default is ‘View {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
134 134
 			/* translators: %s: Taxonomy singular name */
135
-			'update_item'           => wp_sprintf( _x( 'Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
135
+			'update_item'           => wp_sprintf(_x('Update %s', 'Label for editing a singular item. Default is ‘Edit {taxonomy singular name}’.', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
136 136
 			/* translators: %s: Taxonomy singular name */
137
-			'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 ?? '' ) ),
137
+			'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 ?? '')),
138 138
 			/* translators: %s: Taxonomy singular name */
139
-			'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 ?? '' ) ),
139
+			'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 ?? '')),
140 140
 			/* translators: %s: Taxonomy plural name */
141
-			'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 ?? '' ) ),
141
+			'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 ?? '')),
142 142
 			/* translators: %s: Taxonomy plural name */
143
-			'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 ?? '' ) ) ),
143
+			'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 ?? ''))),
144 144
 			/* translators: %s: Taxonomy plural name */
145
-			'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 ?? '' ) ) ),
145
+			'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 ?? ''))),
146 146
 			/* translators: %s: Taxonomy plural name */
147
-			'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 ?? '' ) ) ),
148
-			'most_used'             => _x( 'Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab' ),
147
+			'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 ?? ''))),
148
+			'most_used'             => _x('Most Used', 'Title for the Most Used tab. Default \'Most Used\'.', 'pinkcrab'),
149 149
 			/* translators: %s: Taxonomy plural name */
150
-			'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 ?? '' ) ) ),
150
+			'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 ?? ''))),
151 151
 			/* translators: %s: Taxonomy singular name */
152
-			'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 ?? '' ) ) ),
152
+			'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 ?? ''))),
153 153
 			/* translators: %s: Taxonomy singular name */
154
-			'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 ?? '' ) ),
154
+			'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 ?? '')),
155 155
 		);
156 156
 
157 157
 		$tag_labels = array(
158 158
 			/* translators: %s: Taxonomy plural name */
159
-			'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 ?? '' ) ),
159
+			'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 ?? '')),
160 160
 			/* translators: %s: Taxonomy plural name */
161
-			'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 ?? '' ) ),
161
+			'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 ?? '')),
162 162
 			/* translators: %s: Taxonomy plural name */
163
-			'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 ?? '' ) ),
163
+			'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 ?? '')),
164 164
 		);
165 165
 
166 166
 		$hierarchical_labels = array(
167 167
 			/* translators: %s: Taxonomy singular name */
168
-			'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 ?? '' ) ),
168
+			'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 ?? '')),
169 169
 			/* translators: %s: Taxonomy singular name */
170
-			'parent_item'       => wp_sprintf( _x( 'Parent %s', '**', 'pinkcrab' ), \esc_attr( $taxonomy->singular ?? '' ) ),
170
+			'parent_item'       => wp_sprintf(_x('Parent %s', '**', 'pinkcrab'), \esc_attr($taxonomy->singular ?? '')),
171 171
 			/* translators: %s: Taxonomy singular name */
172
-			'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 ?? '' ) ),
172
+			'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 ?? '')),
173 173
 		);
174 174
 
175 175
 		$labels = array_merge(
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		 * @param Taxonomy $taxonomy
186 186
 		 * @return array<string, string>
187 187
 		 */
188
-		$labels = apply_filters( Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels( $labels ), $taxonomy );
188
+		$labels = apply_filters(Registerable_Hooks::TAXONOMY_LABELS, $taxonomy->filter_labels($labels), $taxonomy);
189 189
 
190 190
 		// Compose args.
191 191
 		$args = array(
@@ -225,6 +225,6 @@  discard block
 block discarded – undo
225 225
 		 * @param Taxonomy $taxonomy
226 226
 		 * @return array<string, string|bool|int|null|array<string, string>
227 227
 		 */
228
-		return apply_filters( Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args( $args ), $taxonomy );
228
+		return apply_filters(Registerable_Hooks::TAXONOMY_ARGS, $taxonomy->filter_args($args), $taxonomy);
229 229
 	}
230 230
 }
Please login to merge, or discard this patch.
src/Registrar/Meta_Box_Registrar.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -64,27 +64,27 @@  discard block
 block discarded – undo
64 64
 	 * @param Meta_Box $meta_box
65 65
 	 * @return void
66 66
 	 */
67
-	public function register( Meta_Box $meta_box ): void {
67
+	public function register(Meta_Box $meta_box): void {
68 68
 
69
-		if ( ! $this->validator->verify_meta_box( $meta_box ) ) {
69
+		if ( ! $this->validator->verify_meta_box($meta_box)) {
70 70
 			throw new Exception(
71 71
 				sprintf(
72 72
 					'Failed validating meta box model(%s) with errors: %s',
73
-					get_class( $meta_box ),
74
-					join( ', ', $this->validator->get_errors() )
73
+					get_class($meta_box),
74
+					join(', ', $this->validator->get_errors())
75 75
 				)
76 76
 			);
77 77
 		}
78 78
 
79 79
 		// Set the view using View, if not traditional callback supplied and a defined template.
80
-		if ( ! \is_callable( $meta_box->view ) && is_string( $meta_box->view_template ) ) {
81
-			$meta_box = $this->set_view_callback_from_view( $meta_box );
80
+		if ( ! \is_callable($meta_box->view) && is_string($meta_box->view_template)) {
81
+			$meta_box = $this->set_view_callback_from_view($meta_box);
82 82
 		}
83 83
 
84 84
 		// Add meta_box to loader.
85 85
 		$this->loader->action(
86 86
 			'add_meta_boxes',
87
-			function() use ( $meta_box ) : void {
87
+			function() use ($meta_box) : void {
88 88
 				\add_meta_box(
89 89
 					$meta_box->key,
90 90
 					$meta_box->label,
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		);
99 99
 		// If we have any hook calls, add them to the loader.
100
-		if ( $this->is_active( $meta_box ) && ! empty( $meta_box->actions ) ) {
101
-			foreach ( $meta_box->actions as $handle => $hook ) {
102
-				$this->loader->action( (string) $handle, $hook['callback'], $hook['priority'], $hook['params'] );
100
+		if ($this->is_active($meta_box) && ! empty($meta_box->actions)) {
101
+			foreach ($meta_box->actions as $handle => $hook) {
102
+				$this->loader->action((string) $handle, $hook['callback'], $hook['priority'], $hook['params']);
103 103
 			}
104 104
 		}
105 105
 
@@ -111,20 +111,20 @@  discard block
 block discarded – undo
111 111
 	 * @param \PinkCrab\Registerables\Meta_Box $meta_box
112 112
 	 * @return \PinkCrab\Registerables\Meta_Box
113 113
 	 */
114
-	protected function set_view_callback_from_view( Meta_Box $meta_box ): Meta_Box {
114
+	protected function set_view_callback_from_view(Meta_Box $meta_box): Meta_Box {
115 115
 
116 116
 		// Create View(View)
117
-		$view = $this->container->create( View::class );
118
-		if ( is_null( $view ) || ! is_a( $view, View::class ) ) {
119
-			throw new Exception( 'View not defined' );
117
+		$view = $this->container->create(View::class);
118
+		if (is_null($view) || ! is_a($view, View::class)) {
119
+			throw new Exception('View not defined');
120 120
 		}
121 121
 
122 122
 		$meta_box->view(
123
-			function ( \WP_Post $post, array $args ) use ( $meta_box, $view ) {
123
+			function(\WP_Post $post, array $args) use ($meta_box, $view) {
124 124
 				$args['args']['post'] = $post;
125 125
 
126 126
 				// @phpstan-ignore-next-line, template should already be checked for valid template path in register() method (which calls this)
127
-				$view->render( $meta_box->view_template, $args['args'] );
127
+				$view->render($meta_box->view_template, $args['args']);
128 128
 			}
129 129
 		);
130 130
 
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return boolean
138 138
 	 */
139
-	protected function is_active( Meta_Box $meta_box ): bool {
139
+	protected function is_active(Meta_Box $meta_box): bool {
140 140
 		global $current_screen;
141 141
 
142
-		return ! is_null( $current_screen )
143
-		&& ! empty( $current_screen->post_type )
144
-		&& in_array( $current_screen->post_type, $meta_box->screen, true );
142
+		return ! is_null($current_screen)
143
+		&& ! empty($current_screen->post_type)
144
+		&& in_array($current_screen->post_type, $meta_box->screen, true);
145 145
 	}
146 146
 }
Please login to merge, or discard this patch.