@@ -13,10 +13,10 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | }  | 
                                                        
@@ -46,13 +46,18 @@ discard block  | 
                                                    ||
| 46 | 46 | */  | 
                                                        
| 47 | 47 | public function filterBy( WP_Query $query )  | 
                                                        
| 48 | 48 |  	{ | 
                                                        
| 49 | - if( !is_admin() || get_current_screen()->base != 'edit' )return;  | 
                                                        |
| 49 | +		if( !is_admin() || get_current_screen()->base != 'edit' ) { | 
                                                        |
| 50 | + return;  | 
                                                        |
| 51 | + }  | 
                                                        |
| 50 | 52 | |
| 51 | 53 | $vars = &$query->query_vars;  | 
                                                        
| 52 | 54 | $taxonomies = array_keys( $this->taxonomies );  | 
                                                        
| 53 | 55 | |
| 54 | -		array_walk( $taxonomies, function( $taxonomy ) use( &$vars ) { | 
                                                        |
| 55 | - if( !isset( $vars[$taxonomy] ))return;  | 
                                                        |
| 56 | + array_walk( $taxonomies, function( $taxonomy ) use( &$vars )  | 
                                                        |
| 57 | +		{ | 
                                                        |
| 58 | +			if( !isset( $vars[$taxonomy] )) { | 
                                                        |
| 59 | + return;  | 
                                                        |
| 60 | + }  | 
                                                        |
| 56 | 61 |  			if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { | 
                                                        
| 57 | 62 | $vars[$taxonomy] = $term->slug;  | 
                                                        
| 58 | 63 | }  | 
                                                        
@@ -67,7 +72,9 @@ discard block  | 
                                                    ||
| 67 | 72 |  	{ | 
                                                        
| 68 | 73 | global $wp_query;  | 
                                                        
| 69 | 74 |  		foreach( $this->taxonomies as $taxonomy => $args ) { | 
                                                        
| 70 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue;  | 
                                                        |
| 75 | +			if( !in_array( get_current_screen()->post_type, $args['post_types'] )) { | 
                                                        |
| 76 | + continue;  | 
                                                        |
| 77 | + }  | 
                                                        |
| 71 | 78 | $selected = isset( $wp_query->query[$taxonomy] )  | 
                                                        
| 72 | 79 | ? $wp_query->query[$taxonomy]  | 
                                                        
| 73 | 80 | : false;  | 
                                                        
@@ -87,7 +94,8 @@ discard block  | 
                                                    ||
| 87 | 94 | */  | 
                                                        
| 88 | 95 | public function register()  | 
                                                        
| 89 | 96 |  	{ | 
                                                        
| 90 | -		array_walk( $this->taxonomies, function( $args, $taxonomy ) { | 
                                                        |
| 97 | + array_walk( $this->taxonomies, function( $args, $taxonomy )  | 
                                                        |
| 98 | +		{ | 
                                                        |
| 91 | 99 | register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( self::CUSTOM_KEYS )));  | 
                                                        
| 92 | 100 |  			foreach( $args['post_types'] as $type ) { | 
                                                        
| 93 | 101 | register_taxonomy_for_object_type( $taxonomy, $type );  |