@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | { |
14 | 14 | parent::__construct( $metabox ); |
15 | 15 | |
16 | - remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] ); |
|
16 | + remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] ); |
|
17 | 17 | |
18 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
19 | - add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
|
18 | + add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 ); |
|
19 | + add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function _get_field_meta( $meta, array $field, $saved ) |
28 | 28 | { |
29 | - if( !$this->is_edit_screen() || empty( $field['id'] )) { |
|
29 | + if( !$this->is_edit_screen() || empty( $field[ 'id' ] ) ) { |
|
30 | 30 | return $meta; |
31 | 31 | } |
32 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
33 | - ? (new SiteMeta)->get( $this->meta_box['id'], $field['id'] ) |
|
34 | - : $field['std'] |
|
35 | - )); |
|
32 | + $meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved |
|
33 | + ? ( new SiteMeta )->get( $this->meta_box[ 'id' ], $field[ 'id' ] ) |
|
34 | + : $field[ 'std' ] |
|
35 | + ) ); |
|
36 | 36 | return $this->_normalize_field_meta( $meta, $field ); |
37 | 37 | } |
38 | 38 | |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function _normalize_field_meta( $meta, array $field ) |
44 | 44 | { |
45 | - if( !empty( $meta ) && is_array( $meta )) { |
|
45 | + if( !empty( $meta ) && is_array( $meta ) ) { |
|
46 | 46 | return $meta; |
47 | 47 | } |
48 | - if( $field['clone'] ) { |
|
49 | - return ['']; |
|
48 | + if( $field[ 'clone' ] ) { |
|
49 | + return [ '' ]; |
|
50 | 50 | } |
51 | - if( $field['multiple'] ) { |
|
52 | - return []; |
|
51 | + if( $field[ 'multiple' ] ) { |
|
52 | + return [ ]; |
|
53 | 53 | } |
54 | 54 | return $meta; |
55 | 55 | } |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | public function add_meta_boxes() |
61 | 61 | { |
62 | 62 | add_meta_box( |
63 | - $this->meta_box['id'], |
|
64 | - $this->meta_box['title'], |
|
65 | - [$this, 'show'], |
|
63 | + $this->meta_box[ 'id' ], |
|
64 | + $this->meta_box[ 'title' ], |
|
65 | + [ $this, 'show' ], |
|
66 | 66 | null, |
67 | - $this->meta_box['context'], |
|
68 | - $this->meta_box['priority'] |
|
67 | + $this->meta_box[ 'context' ], |
|
68 | + $this->meta_box[ 'priority' ] |
|
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function is_saved() |
84 | 84 | { |
85 | 85 | foreach( array_column( $this->fields, 'id' ) as $field ) { |
86 | - if( !is_null( (new SiteMeta)->get( $this->meta_box['id'], $field, null ))) { |
|
86 | + if( !is_null( ( new SiteMeta )->get( $this->meta_box[ 'id' ], $field, null ) ) ) { |
|
87 | 87 | return true; |
88 | 88 | } |
89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | public static function normalize( $metabox ) |
98 | 98 | { |
99 | 99 | $metabox = parent::normalize( $metabox ); |
100 | - $metabox['post_types'] = []; |
|
100 | + $metabox[ 'post_types' ] = [ ]; |
|
101 | 101 | return $metabox; |
102 | 102 | } |
103 | 103 | } |
@@ -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 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | if( !is_admin() || get_current_screen()->base != 'edit' )return; |
50 | 50 | $vars = &$query->query_vars; |
51 | 51 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
52 | - if( empty( $vars[$taxonomy] ))continue; |
|
53 | - $vars[$taxonomy] = get_term_by( 'id', $vars[$taxonomy], $taxonomy )->slug; |
|
52 | + if( empty( $vars[ $taxonomy ] ) )continue; |
|
53 | + $vars[ $taxonomy ] = get_term_by( 'id', $vars[ $taxonomy ], $taxonomy )->slug; |
|
54 | 54 | } |
55 | 55 | return $query; |
56 | 56 | } |
@@ -62,18 +62,18 @@ discard block |
||
62 | 62 | { |
63 | 63 | global $wp_query; |
64 | 64 | foreach( $this->taxonomies as $taxonomy => $args ) { |
65 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
66 | - $selected = isset( $wp_query->query[$taxonomy] ) |
|
67 | - ? $wp_query->query[$taxonomy] |
|
65 | + if( !in_array( get_current_screen()->post_type, $args[ 'post_types' ] ) )continue; |
|
66 | + $selected = isset( $wp_query->query[ $taxonomy ] ) |
|
67 | + ? $wp_query->query[ $taxonomy ] |
|
68 | 68 | : false; |
69 | - wp_dropdown_categories([ |
|
69 | + wp_dropdown_categories( [ |
|
70 | 70 | 'hide_if_empty' => true, |
71 | 71 | 'name' => $taxonomy, |
72 | 72 | 'orderby' => 'name', |
73 | 73 | 'selected' => $selected, |
74 | - 'show_option_all' => $args['labels']['all_items'], |
|
74 | + 'show_option_all' => $args[ 'labels' ][ 'all_items' ], |
|
75 | 75 | 'taxonomy' => $taxonomy, |
76 | - ]); |
|
76 | + ] ); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | public function register() |
84 | 84 | { |
85 | 85 | array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
86 | - register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( self::CUSTOM_KEYS ))); |
|
87 | - foreach( $args['post_types'] as $type ) { |
|
86 | + register_taxonomy( $taxonomy, $args[ 'post_types' ], array_diff_key( $args, array_flip( self::CUSTOM_KEYS ) ) ); |
|
87 | + foreach( $args[ 'post_types' ] as $type ) { |
|
88 | 88 | register_taxonomy_for_object_type( $taxonomy, $type ); |
89 | 89 | } |
90 | 90 | }); |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function normalize() |
97 | 97 | { |
98 | - foreach( $this->app->config['taxonomies'] as $taxonomy => $args ) { |
|
99 | - $this->taxonomies[$taxonomy] = apply_filters( 'pollux/taxonomy/args', |
|
98 | + foreach( $this->app->config[ 'taxonomies' ] as $taxonomy => $args ) { |
|
99 | + $this->taxonomies[ $taxonomy ] = apply_filters( 'pollux/taxonomy/args', |
|
100 | 100 | $this->normalizeThis( $args, self::TAXONOMY_DEFAULTS, $taxonomy ) |
101 | 101 | ); |
102 | 102 | } |
103 | 103 | $this->taxonomies = array_diff_key( |
104 | 104 | $this->taxonomies, |
105 | - get_taxonomies( ['_builtin' => true] ) |
|
105 | + get_taxonomies( [ '_builtin' => true ] ) |
|
106 | 106 | ); |
107 | 107 | } |
108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function normalizeLabels( $labels, array $args ) |
114 | 114 | { |
115 | - return wp_parse_args( $labels, $this->setLabels( $args )); |
|
115 | + return wp_parse_args( $labels, $this->setLabels( $args ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | protected function normalizeMenuName( $menuname, array $args ) |
123 | 123 | { |
124 | 124 | return empty( $menuname ) |
125 | - ? $args['plural'] |
|
125 | + ? $args[ 'plural' ] |
|
126 | 126 | : $menuname; |
127 | 127 | } |
128 | 128 | |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | protected function setLabels( array $args ) |
142 | 142 | { |
143 | 143 | return apply_filters( 'pollux/taxonomy/labels', [ |
144 | - 'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args['single'] ), |
|
145 | - 'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args['plural'] ), |
|
146 | - 'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args['single'] ), |
|
147 | - 'menu_name' => $this->normalizeMenuName( $args['menu_name'], $args ), |
|
148 | - 'name' => $args['plural'], |
|
149 | - 'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args['single'] ), |
|
150 | - 'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args['plural'] ), |
|
151 | - 'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args['plural'] ), |
|
152 | - 'singular_name' => $args['single'], |
|
153 | - 'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args['single'] ), |
|
154 | - 'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args['single'] ), |
|
144 | + 'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args[ 'single' ] ), |
|
145 | + 'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args[ 'plural' ] ), |
|
146 | + 'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args[ 'single' ] ), |
|
147 | + 'menu_name' => $this->normalizeMenuName( $args[ 'menu_name' ], $args ), |
|
148 | + 'name' => $args[ 'plural' ], |
|
149 | + 'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args[ 'single' ] ), |
|
150 | + 'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args[ 'plural' ] ), |
|
151 | + 'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args[ 'plural' ] ), |
|
152 | + 'singular_name' => $args[ 'single' ], |
|
153 | + 'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args[ 'single' ] ), |
|
154 | + 'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args[ 'single' ] ), |
|
155 | 155 | ], $args ); |
156 | 156 | } |
157 | 157 | } |