Passed
Push — master ( 5f0760...eb71ac )
by Paul
02:39
created
src/Taxonomy.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 	const TAXONOMY_DEFAULTS = [
15 15
 		'hierarchical'      => true,
16
-		'labels'            => [],
16
+		'labels'            => [ ],
17 17
 		'menu_name'         => '',
18 18
 		'plural'            => '',
19
-		'post_types'        => [],
19
+		'post_types'        => [ ],
20 20
 		'public'            => true,
21 21
 		'rewrite'           => true,
22 22
 		'show_admin_column' => true,
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	{
37 37
 		$this->normalize();
38 38
 
39
-		add_filter( 'parse_query',           [ $this, 'filterBy'] );
40
-		add_action( 'restrict_manage_posts', [ $this, 'printFilters'] );
41
-		add_action( 'init',                  [ $this, 'register'] );
39
+		add_filter( 'parse_query', [ $this, 'filterBy' ] );
40
+		add_action( 'restrict_manage_posts', [ $this, 'printFilters' ] );
41
+		add_action( 'init', [ $this, 'register' ] );
42 42
 	}
43 43
 
44 44
 	/**
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 		$taxonomies = array_keys( $this->taxonomies );
53 53
 
54 54
 		array_walk( $taxonomies, function( $taxonomy ) use( &$vars ) {
55
-			if( !isset( $vars[$taxonomy] ))return;
56
-			if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) {
57
-				$vars[$taxonomy] = $term->slug;
55
+			if( !isset( $vars[ $taxonomy ] ) )return;
56
+			if( $term = get_term_by( 'id', $vars[ $taxonomy ], $taxonomy ) ) {
57
+				$vars[ $taxonomy ] = $term->slug;
58 58
 			}
59 59
 		});
60 60
 		return $query;
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
 	{
68 68
 		global $wp_query;
69 69
 		foreach( $this->taxonomies as $taxonomy => $args ) {
70
-			if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue;
71
-			$selected = isset( $wp_query->query[$taxonomy] )
72
-				? $wp_query->query[$taxonomy]
70
+			if( !in_array( get_current_screen()->post_type, $args[ 'post_types' ] ) )continue;
71
+			$selected = isset( $wp_query->query[ $taxonomy ] )
72
+				? $wp_query->query[ $taxonomy ]
73 73
 				: false;
74
-			wp_dropdown_categories([
74
+			wp_dropdown_categories( [
75 75
 				'hide_if_empty' => true,
76 76
 				'name' => $taxonomy,
77 77
 				'orderby' => 'name',
78 78
 				'selected' => $selected,
79
-				'show_option_all' => $args['labels']['all_items'],
79
+				'show_option_all' => $args[ 'labels' ][ 'all_items' ],
80 80
 				'taxonomy' => $taxonomy,
81
-			]);
81
+			] );
82 82
 		}
83 83
 	}
84 84
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	public function register()
89 89
 	{
90 90
 		array_walk( $this->taxonomies, function( $args, $taxonomy ) {
91
-			register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( self::CUSTOM_KEYS )));
92
-			foreach( $args['post_types'] as $type ) {
91
+			register_taxonomy( $taxonomy, $args[ 'post_types' ], array_diff_key( $args, array_flip( self::CUSTOM_KEYS ) ) );
92
+			foreach( $args[ 'post_types' ] as $type ) {
93 93
 				register_taxonomy_for_object_type( $taxonomy, $type );
94 94
 			}
95 95
 		});
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	protected function normalize()
102 102
 	{
103
-		foreach( $this->app->config['taxonomies'] as $taxonomy => $args ) {
104
-			$this->taxonomies[$taxonomy] = apply_filters( 'pollux/taxonomy/args',
103
+		foreach( $this->app->config[ 'taxonomies' ] as $taxonomy => $args ) {
104
+			$this->taxonomies[ $taxonomy ] = apply_filters( 'pollux/taxonomy/args',
105 105
 				$this->normalizeThis( $args, self::TAXONOMY_DEFAULTS, $taxonomy )
106 106
 			);
107 107
 		}
108 108
 		$this->taxonomies = array_diff_key(
109 109
 			$this->taxonomies,
110
-			get_taxonomies( ['_builtin' => true] )
110
+			get_taxonomies( [ '_builtin' => true ] )
111 111
 		);
112 112
 	}
113 113
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function normalizeLabels( $labels, array $args )
119 119
 	{
120
-		return wp_parse_args( $labels, $this->setLabels( $args ));
120
+		return wp_parse_args( $labels, $this->setLabels( $args ) );
121 121
 	}
122 122
 
123 123
 	/**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	protected function normalizeMenuName( $menuname, array $args )
128 128
 	{
129 129
 		return empty( $menuname )
130
-			? $args['plural']
130
+			? $args[ 'plural' ]
131 131
 			: $menuname;
132 132
 	}
133 133
 
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 	protected function setLabels( array $args )
147 147
 	{
148 148
 		return apply_filters( 'pollux/taxonomy/labels', [
149
-			'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args['single'] ),
150
-			'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args['plural'] ),
151
-			'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args['single'] ),
152
-			'menu_name' => $this->normalizeMenuName( $args['menu_name'], $args ),
153
-			'name' => $args['plural'],
154
-			'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args['single'] ),
155
-			'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args['plural'] ),
156
-			'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args['plural'] ),
157
-			'singular_name' => $args['single'],
158
-			'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args['single'] ),
159
-			'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args['single'] ),
149
+			'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args[ 'single' ] ),
150
+			'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args[ 'plural' ] ),
151
+			'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args[ 'single' ] ),
152
+			'menu_name' => $this->normalizeMenuName( $args[ 'menu_name' ], $args ),
153
+			'name' => $args[ 'plural' ],
154
+			'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args[ 'single' ] ),
155
+			'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args[ 'plural' ] ),
156
+			'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args[ 'plural' ] ),
157
+			'singular_name' => $args[ 'single' ],
158
+			'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args[ 'single' ] ),
159
+			'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args[ 'single' ] ),
160 160
 		], $args );
161 161
 	}
162 162
 }
Please login to merge, or discard this patch.