@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function init() |
37 | 37 | { |
38 | - if( empty( $this->app->config->taxonomies ))return; |
|
38 | + if( empty($this->app->config->taxonomies) )return; |
|
39 | 39 | |
40 | 40 | $this->normalize(); |
41 | 41 | |
42 | - add_action( 'restrict_manage_posts', [ $this, 'printFilters'] ); |
|
43 | - add_action( 'init', [ $this, 'register'] ); |
|
44 | - add_filter( 'parse_query', [ $this, 'filterByTaxonomy'] ); |
|
42 | + add_action( 'restrict_manage_posts', [$this, 'printFilters'] ); |
|
43 | + add_action( 'init', [$this, 'register'] ); |
|
44 | + add_filter( 'parse_query', [$this, 'filterByTaxonomy'] ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | if( !is_admin() || Helper::getCurrentScreen()->base != 'edit' )return; |
54 | 54 | $vars = &$query->query_vars; |
55 | 55 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
56 | - if( !isset( $vars[$taxonomy] ))return; |
|
57 | - if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
|
56 | + if( !isset($vars[$taxonomy]) )return; |
|
57 | + if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy ) ) { |
|
58 | 58 | $vars[$taxonomy] = $term->slug; |
59 | 59 | } |
60 | 60 | } |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | { |
70 | 70 | global $wp_query; |
71 | 71 | foreach( $this->taxonomies as $taxonomy => $args ) { |
72 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
73 | - $selected = isset( $wp_query->query[$taxonomy] ) |
|
72 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] ) )continue; |
|
73 | + $selected = isset($wp_query->query[$taxonomy]) |
|
74 | 74 | ? $wp_query->query[$taxonomy] |
75 | 75 | : false; |
76 | - wp_dropdown_categories([ |
|
76 | + wp_dropdown_categories( [ |
|
77 | 77 | 'hide_if_empty' => true, |
78 | 78 | 'name' => $taxonomy, |
79 | 79 | 'orderby' => 'name', |
80 | 80 | 'selected' => $selected, |
81 | 81 | 'show_option_all' => $args['labels']['all_items'], |
82 | 82 | 'taxonomy' => $taxonomy, |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | public function register() |
92 | 92 | { |
93 | 93 | array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
94 | - register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
|
94 | + register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ) ) ); |
|
95 | 95 | foreach( $args['post_types'] as $type ) { |
96 | 96 | register_taxonomy_for_object_type( $taxonomy, $type ); |
97 | 97 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function normalizeLabels( $labels, array $args ) |
122 | 122 | { |
123 | - return wp_parse_args( $labels, $this->setLabels( $args )); |
|
123 | + return wp_parse_args( $labels, $this->setLabels( $args ) ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | protected function normalizeMenuName( $menuname, array $args ) |
131 | 131 | { |
132 | - return empty( $menuname ) |
|
132 | + return empty($menuname) |
|
133 | 133 | ? $args['plural'] |
134 | 134 | : $menuname; |
135 | 135 | } |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function init() |
37 | 37 | { |
38 | - if( empty( $this->app->config->taxonomies ))return; |
|
38 | + if( empty( $this->app->config->taxonomies )) { |
|
39 | + return; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $this->normalize(); |
41 | 43 | |
@@ -50,10 +52,14 @@ discard block |
||
50 | 52 | */ |
51 | 53 | public function filterByTaxonomy( WP_Query $query ) |
52 | 54 | { |
53 | - if( !is_admin() || Helper::getCurrentScreen()->base != 'edit' )return; |
|
55 | + if( !is_admin() || Helper::getCurrentScreen()->base != 'edit' ) { |
|
56 | + return; |
|
57 | + } |
|
54 | 58 | $vars = &$query->query_vars; |
55 | 59 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
56 | - if( !isset( $vars[$taxonomy] ))return; |
|
60 | + if( !isset( $vars[$taxonomy] )) { |
|
61 | + return; |
|
62 | + } |
|
57 | 63 | if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
58 | 64 | $vars[$taxonomy] = $term->slug; |
59 | 65 | } |
@@ -69,7 +75,9 @@ discard block |
||
69 | 75 | { |
70 | 76 | global $wp_query; |
71 | 77 | foreach( $this->taxonomies as $taxonomy => $args ) { |
72 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
78 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] )) { |
|
79 | + continue; |
|
80 | + } |
|
73 | 81 | $selected = isset( $wp_query->query[$taxonomy] ) |
74 | 82 | ? $wp_query->query[$taxonomy] |
75 | 83 | : false; |