@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function get( $group = null, $key = null, $fallback = null ) |
16 | 16 | { |
17 | - $options = get_option( apply_filters( 'pollux/settings/option', Settings::ID )); |
|
18 | - if( empty( $options )) { |
|
17 | + $options = get_option( apply_filters( 'pollux/settings/option', Settings::ID ) ); |
|
18 | + if( empty( $options ) ) { |
|
19 | 19 | return $fallback; |
20 | 20 | } |
21 | - if( !is_string( $group )) { |
|
21 | + if( !is_string( $group ) ) { |
|
22 | 22 | return $options; |
23 | 23 | } |
24 | 24 | $group = $this->normalize( $options, $group, $fallback ); |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected function normalize( array $options, $key, $fallback ) |
36 | 36 | { |
37 | - if( !array_key_exists( $key, $options )) { |
|
37 | + if( !array_key_exists( $key, $options ) ) { |
|
38 | 38 | return $fallback; |
39 | 39 | } |
40 | - $option = $options[$key]; |
|
40 | + $option = $options[ $key ]; |
|
41 | 41 | $option = is_array( $option ) |
42 | 42 | ? array_filter( $option ) |
43 | 43 | : trim( $option ); |
@@ -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, |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @var array |
29 | 29 | */ |
30 | - public $taxonomies = []; |
|
30 | + public $taxonomies = [ ]; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * {@inheritdoc} |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | { |
37 | 37 | $this->normalize(); |
38 | 38 | |
39 | - add_action( 'restrict_manage_posts', [ $this, 'printFilters'] ); |
|
40 | - add_action( 'init', [ $this, 'register'] ); |
|
41 | - add_filter( 'parse_query', [ $this, 'filterByTaxonomy'] ); |
|
39 | + add_action( 'restrict_manage_posts', [ $this, 'printFilters' ] ); |
|
40 | + add_action( 'init', [ $this, 'register' ] ); |
|
41 | + add_filter( 'parse_query', [ $this, 'filterByTaxonomy' ] ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | if( !is_admin() || $this->app->screen()->base != 'edit' )return; |
51 | 51 | $vars = &$query->query_vars; |
52 | 52 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
53 | - if( !isset( $vars[$taxonomy] ))return; |
|
54 | - if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
|
55 | - $vars[$taxonomy] = $term->slug; |
|
53 | + if( !isset( $vars[ $taxonomy ] ) )return; |
|
54 | + if( $term = get_term_by( 'id', $vars[ $taxonomy ], $taxonomy ) ) { |
|
55 | + $vars[ $taxonomy ] = $term->slug; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | return $query; |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | { |
67 | 67 | global $wp_query; |
68 | 68 | foreach( $this->taxonomies as $taxonomy => $args ) { |
69 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
70 | - $selected = isset( $wp_query->query[$taxonomy] ) |
|
71 | - ? $wp_query->query[$taxonomy] |
|
69 | + if( !in_array( get_current_screen()->post_type, $args[ 'post_types' ] ) )continue; |
|
70 | + $selected = isset( $wp_query->query[ $taxonomy ] ) |
|
71 | + ? $wp_query->query[ $taxonomy ] |
|
72 | 72 | : false; |
73 | - wp_dropdown_categories([ |
|
73 | + wp_dropdown_categories( [ |
|
74 | 74 | 'hide_if_empty' => true, |
75 | 75 | 'name' => $taxonomy, |
76 | 76 | 'orderby' => 'name', |
77 | 77 | 'selected' => $selected, |
78 | - 'show_option_all' => $args['labels']['all_items'], |
|
78 | + 'show_option_all' => $args[ 'labels' ][ 'all_items' ], |
|
79 | 79 | 'taxonomy' => $taxonomy, |
80 | - ]); |
|
80 | + ] ); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -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( static::CUSTOM_KEYS ))); |
|
92 | - foreach( $args['post_types'] as $type ) { |
|
91 | + register_taxonomy( $taxonomy, $args[ 'post_types' ], array_diff_key( $args, array_flip( static::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, static::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 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | protected function normalizeCondition( $conditions ) |
31 | 31 | { |
32 | 32 | $conditions = $this->toArray( $conditions ); |
33 | - if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) { |
|
33 | + if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) { |
|
34 | 34 | foreach( $conditions as $key ) { |
35 | - $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
35 | + $conditions[ str_replace( '!', '', $key ) ] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
36 | 36 | } |
37 | 37 | $conditions = array_filter( $conditions, function( $key ) { |
38 | 38 | return !is_numeric( $key ); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $hook = sprintf( 'pollux/%s/conditions', $this->getClassname() ); |
42 | 42 | return array_intersect_key( |
43 | 43 | $conditions, |
44 | - array_flip( apply_filters( $hook, static::$conditions )) |
|
44 | + array_flip( apply_filters( $hook, static::$conditions ) ) |
|
45 | 45 | ); |
46 | 46 | } |
47 | 47 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | protected function validateIsFrontPage( $value ) |
89 | 89 | { |
90 | - return $value == ( $this->getPostId() == get_option( 'page_on_front' )); |
|
90 | + return $value == ( $this->getPostId() == get_option( 'page_on_front' ) ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function validateIsHome( $value ) |
98 | 98 | { |
99 | - return $value == ( $this->getPostId() == get_option( 'page_for_posts' )); |
|
99 | + return $value == ( $this->getPostId() == get_option( 'page_for_posts' ) ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function validateIsPageTemplate( $value ) |
107 | 107 | { |
108 | - return basename( get_page_template_slug( $this->getPostId() )) == $value; |
|
108 | + return basename( get_page_template_slug( $this->getPostId() ) ) == $value; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -10,19 +10,19 @@ discard block |
||
10 | 10 | * @param string $metaKey |
11 | 11 | * @return mixed |
12 | 12 | */ |
13 | - public function get( $metaKey, array $args = [] ) |
|
13 | + public function get( $metaKey, array $args = [ ] ) |
|
14 | 14 | { |
15 | - if( empty( $metaKey ))return; |
|
15 | + if( empty( $metaKey ) )return; |
|
16 | 16 | |
17 | 17 | $args = $this->normalize( $args ); |
18 | - $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
|
19 | - $metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] ); |
|
18 | + $metaKey = $this->buildMetaKey( $metaKey, $args[ 'prefix' ] ); |
|
19 | + $metaValue = get_post_meta( $args[ 'id' ], $metaKey, $args[ 'single' ] ); |
|
20 | 20 | |
21 | - if( is_string( $metaValue )) { |
|
21 | + if( is_string( $metaValue ) ) { |
|
22 | 22 | $metaValue = trim( $metaValue ); |
23 | 23 | } |
24 | 24 | return empty( $metaValue ) |
25 | - ? $args['fallback'] |
|
25 | + ? $args[ 'fallback' ] |
|
26 | 26 | : $metaValue; |
27 | 27 | } |
28 | 28 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected function buildMetaKey( $metaKey, $prefix ) |
35 | 35 | { |
36 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) |
|
36 | + return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix ) ) |
|
37 | 37 | ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) |
38 | 38 | : $prefix . $metaKey; |
39 | 39 | } |
@@ -49,6 +49,6 @@ discard block |
||
49 | 49 | 'single' => true, |
50 | 50 | 'prefix' => apply_filters( 'pollux/prefix', Application::PREFIX ), |
51 | 51 | ]; |
52 | - return shortcode_atts( $defaults, array_change_key_case( $args )); |
|
52 | + return shortcode_atts( $defaults, array_change_key_case( $args ) ); |
|
53 | 53 | } |
54 | 54 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @var array |
19 | 19 | */ |
20 | - public $metaboxes = []; |
|
20 | + public $metaboxes = [ ]; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * {@inheritdoc} |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | { |
27 | 27 | $this->normalize(); |
28 | 28 | |
29 | - add_filter( 'rwmb_show', [$this, 'show'], 10, 2 ); |
|
30 | - add_filter( 'rwmb_meta_boxes', [$this, 'register'] ); |
|
29 | + add_filter( 'rwmb_show', [ $this, 'show' ], 10, 2 ); |
|
30 | + add_filter( 'rwmb_meta_boxes', [ $this, 'register' ] ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function register() |
38 | 38 | { |
39 | - if( current_user_can( 'switch_themes' )) { |
|
39 | + if( current_user_can( 'switch_themes' ) ) { |
|
40 | 40 | $this->addInstructions(); |
41 | 41 | } |
42 | 42 | $metaboxes = func_num_args() |
43 | - ? $this->toArray( func_get_arg(0) ) |
|
44 | - : []; |
|
43 | + ? $this->toArray( func_get_arg( 0 ) ) |
|
44 | + : [ ]; |
|
45 | 45 | return array_merge( $metaboxes, $this->metaboxes ); |
46 | 46 | } |
47 | 47 | |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | public function show( $bool, array $metabox ) |
53 | 53 | { |
54 | 54 | if( defined( 'DOING_AJAX' ) |
55 | - || !isset( $metabox['condition'] ) |
|
56 | - || !$this->hasPostType( $metabox )) { |
|
55 | + || !isset( $metabox[ 'condition' ] ) |
|
56 | + || !$this->hasPostType( $metabox ) ) { |
|
57 | 57 | return $bool; |
58 | 58 | } |
59 | - return $this->validate( $metabox['condition'] ); |
|
59 | + return $this->validate( $metabox[ 'condition' ] ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | protected function getPostId() |
66 | 66 | { |
67 | - if( !( $postId = filter_input( INPUT_GET, 'post' ))) { |
|
67 | + if( !( $postId = filter_input( INPUT_GET, 'post' ) ) ) { |
|
68 | 68 | $postId = filter_input( INPUT_POST, 'post_ID' ); |
69 | 69 | } |
70 | 70 | return intval( $postId ); |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | { |
78 | 78 | return array_unique( iterator_to_array( |
79 | 79 | new RecursiveIteratorIterator( |
80 | - new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' )) |
|
80 | + new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) ) |
|
81 | 81 | ), |
82 | 82 | false |
83 | - )); |
|
83 | + ) ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function hasPostType( array $metabox ) |
90 | 90 | { |
91 | - if( !isset( $metabox['post_types'] )) { |
|
91 | + if( !isset( $metabox[ 'post_types' ] ) ) { |
|
92 | 92 | return true; |
93 | 93 | } |
94 | - return in_array( get_post_type( $this->getPostId() ), $metabox['post_types'] ); |
|
94 | + return in_array( get_post_type( $this->getPostId() ), $metabox[ 'post_types' ] ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected function normalize() |
101 | 101 | { |
102 | - foreach( $this->app->config['meta_boxes'] as $id => $metabox ) { |
|
102 | + foreach( $this->app->config[ 'meta_boxes' ] as $id => $metabox ) { |
|
103 | 103 | $defaults = [ |
104 | - 'condition' => [], |
|
105 | - 'fields' => [], |
|
104 | + 'condition' => [ ], |
|
105 | + 'fields' => [ ], |
|
106 | 106 | 'id' => $id, |
107 | - 'post_types' => [], |
|
107 | + 'post_types' => [ ], |
|
108 | 108 | 'slug' => $id, |
109 | 109 | ]; |
110 | - $this->metaboxes[] = $this->setDependencies( |
|
110 | + $this->metaboxes[ ] = $this->setDependencies( |
|
111 | 111 | $this->normalizeThis( $metabox, $defaults, $id ) |
112 | 112 | ); |
113 | 113 | } |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | protected function normalizeFields( array $fields, array $data, $parentId ) |
132 | 132 | { |
133 | 133 | return array_map( function( $id, $field ) use( $parentId ) { |
134 | - $defaults = [ |
|
135 | - 'attributes' => [], |
|
134 | + $defaults = [ |
|
135 | + 'attributes' => [ ], |
|
136 | 136 | // 'condition' => [], |
137 | 137 | 'depends' => '', |
138 | 138 | 'id' => $id, |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function setDependencies( array $metabox ) |
169 | 169 | { |
170 | - $fields = &$metabox['fields']; |
|
170 | + $fields = &$metabox[ 'fields' ]; |
|
171 | 171 | $depends = array_column( $fields, 'depends' ); |
172 | 172 | array_walk( $depends, function( $value, $index ) use( &$fields ) { |
173 | - if( empty( $value ))return; |
|
174 | - $fields[$index]['attributes']['data-depends'] = $value; |
|
173 | + if( empty( $value ) )return; |
|
174 | + $fields[ $index ][ 'attributes' ][ 'data-depends' ] = $value; |
|
175 | 175 | }); |
176 | 176 | return $metabox; |
177 | 177 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | |
16 | 16 | const POST_TYPE_DEFAULTS = [ |
17 | 17 | 'capability_type' => 'post', |
18 | - 'columns' => [], |
|
18 | + 'columns' => [ ], |
|
19 | 19 | 'has_archive' => false, |
20 | 20 | 'hierarchical' => false, |
21 | - 'labels' => [], |
|
21 | + 'labels' => [ ], |
|
22 | 22 | 'map_meta_cap' => true, |
23 | 23 | 'menu_icon' => null, |
24 | 24 | 'menu_name' => '', |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | 'show_ui' => true, |
32 | 32 | 'single' => '', |
33 | 33 | 'slug' => '', |
34 | - 'supports' => ['title', 'editor', 'thumbnail'], |
|
35 | - 'taxonomies' => [], |
|
34 | + 'supports' => [ 'title', 'editor', 'thumbnail' ], |
|
35 | + 'taxonomies' => [ ], |
|
36 | 36 | ]; |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @var array |
40 | 40 | */ |
41 | - public $types = []; |
|
41 | + public $types = [ ]; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * {@inheritdoc} |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this->normalize(); |
50 | 50 | $this->initColumns(); |
51 | 51 | |
52 | - add_action( 'init', [$this, 'register'] ); |
|
52 | + add_action( 'init', [ $this, 'register' ] ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | { |
61 | 61 | $types = array_diff_key( |
62 | 62 | $this->types, |
63 | - get_post_types( ['_builtin' => true] ) |
|
63 | + get_post_types( [ '_builtin' => true ] ) |
|
64 | 64 | ); |
65 | 65 | array_walk( $types, function( $args, $type ) { |
66 | - register_post_type( $type, array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
|
66 | + register_post_type( $type, array_diff_key( $args, array_flip( static::CUSTOM_KEYS ) ) ); |
|
67 | 67 | }); |
68 | 68 | } |
69 | 69 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected function normalize() |
74 | 74 | { |
75 | - foreach( $this->app->config['post_types'] as $type => $args ) { |
|
76 | - $this->types[$type] = apply_filters( 'pollux/post_type/args', |
|
75 | + foreach( $this->app->config[ 'post_types' ] as $type => $args ) { |
|
76 | + $this->types[ $type ] = apply_filters( 'pollux/post_type/args', |
|
77 | 77 | $this->normalizeThis( $args, static::POST_TYPE_DEFAULTS, $type ), |
78 | 78 | $type |
79 | 79 | ); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected function normalizeLabels( $labels, array $args ) |
88 | 88 | { |
89 | - return wp_parse_args( $labels, $this->setLabels( $args )); |
|
89 | + return wp_parse_args( $labels, $this->setLabels( $args ) ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | protected function normalizeMenuName( $menuname, array $args ) |
97 | 97 | { |
98 | 98 | return empty( $menuname ) |
99 | - ? $args['plural'] |
|
99 | + ? $args[ 'plural' ] |
|
100 | 100 | : $menuname; |
101 | 101 | } |
102 | 102 | |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | protected function normalizeRewrite( $rewrite, array $args ) |
108 | 108 | { |
109 | 109 | if( $rewrite === true ) { |
110 | - $slug = empty( $args['slug'] ) |
|
111 | - ? sanitize_title( $args['plural'] ) |
|
112 | - : $args['slug']; |
|
113 | - $rewrite = ['slug' => $slug, 'with_front' => false]; |
|
110 | + $slug = empty( $args[ 'slug' ] ) |
|
111 | + ? sanitize_title( $args[ 'plural' ] ) |
|
112 | + : $args[ 'slug' ]; |
|
113 | + $rewrite = [ 'slug' => $slug, 'with_front' => false ]; |
|
114 | 114 | } |
115 | 115 | return $rewrite; |
116 | 116 | } |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | { |
123 | 123 | return apply_filters( 'pollux/post_type/labels', [ |
124 | 124 | 'add_new' => __( 'Add New', 'pollux' ), |
125 | - 'add_new_item' => sprintf( _x( 'Add New %s', 'Add new post', 'pollux' ), $args['single'] ), |
|
126 | - 'all_items' => sprintf( _x( 'All %s', 'All posts', 'pollux' ), $args['plural'] ), |
|
127 | - 'edit_item' => sprintf( _x( 'Edit %s', 'Edit post', 'pollux' ), $args['single'] ), |
|
128 | - 'menu_name' => $this->normalizeMenuName( $args['menu_name'], $args ), |
|
129 | - 'name' => $args['plural'], |
|
130 | - 'new_item' => sprintf( _x( 'New %s', 'New post', 'pollux' ), $args['single'] ), |
|
131 | - 'not_found' => sprintf( _x( 'No %s found', 'No posts found', 'pollux' ), $args['plural'] ), |
|
132 | - 'not_found_in_trash' => sprintf( _x( 'No %s found in Trash', 'No posts found in trash', 'pollux' ), $args['plural'] ), |
|
133 | - 'search_items' => sprintf( _x( 'Search %s', 'Search posts', 'pollux' ), $args['plural'] ), |
|
134 | - 'singular_name' => $args['single'], |
|
135 | - 'view_item' => sprintf( _x( 'View %s', 'View post', 'pollux' ), $args['single'] ), |
|
125 | + 'add_new_item' => sprintf( _x( 'Add New %s', 'Add new post', 'pollux' ), $args[ 'single' ] ), |
|
126 | + 'all_items' => sprintf( _x( 'All %s', 'All posts', 'pollux' ), $args[ 'plural' ] ), |
|
127 | + 'edit_item' => sprintf( _x( 'Edit %s', 'Edit post', 'pollux' ), $args[ 'single' ] ), |
|
128 | + 'menu_name' => $this->normalizeMenuName( $args[ 'menu_name' ], $args ), |
|
129 | + 'name' => $args[ 'plural' ], |
|
130 | + 'new_item' => sprintf( _x( 'New %s', 'New post', 'pollux' ), $args[ 'single' ] ), |
|
131 | + 'not_found' => sprintf( _x( 'No %s found', 'No posts found', 'pollux' ), $args[ 'plural' ] ), |
|
132 | + 'not_found_in_trash' => sprintf( _x( 'No %s found in Trash', 'No posts found in trash', 'pollux' ), $args[ 'plural' ] ), |
|
133 | + 'search_items' => sprintf( _x( 'Search %s', 'Search posts', 'pollux' ), $args[ 'plural' ] ), |
|
134 | + 'singular_name' => $args[ 'single' ], |
|
135 | + 'view_item' => sprintf( _x( 'View %s', 'View post', 'pollux' ), $args[ 'single' ] ), |
|
136 | 136 | ], $args ); |
137 | 137 | } |
138 | 138 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | |
24 | 24 | public function __construct() |
25 | 25 | { |
26 | - $this->file = realpath( dirname( dirname( __FILE__ )) . '/pollux.php' ); |
|
27 | - $this->gatekeeper = new GateKeeper( plugin_basename( $this->file )); |
|
26 | + $this->file = realpath( dirname( dirname( __FILE__ ) ) . '/pollux.php' ); |
|
27 | + $this->gatekeeper = new GateKeeper( plugin_basename( $this->file ) ); |
|
28 | 28 | |
29 | 29 | $data = get_file_data( $this->file, array( |
30 | 30 | 'id' => 'Text Domain', |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | |
48 | 48 | $controller = $this->make( 'Controller' ); |
49 | 49 | |
50 | - add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' )); |
|
51 | - add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' )); |
|
52 | - add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' )); |
|
53 | - add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' )); |
|
50 | + add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' ) ); |
|
51 | + add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' ) ); |
|
52 | + add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' ) ); |
|
53 | + add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' ) ); |
|
54 | 54 | |
55 | 55 | // Disallow indexing of the site on non-production environments |
56 | 56 | if( !$this->environment( 'production' ) && !is_admin() ) { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | Facade::clearResolvedInstances(); |
67 | 67 | Facade::setFacadeApplication( $this ); |
68 | - $this->config = (new Config( $this ))->get(); |
|
68 | + $this->config = ( new Config( $this ) )->get(); |
|
69 | 69 | $this->registerAliases(); |
70 | 70 | $classNames = array( |
71 | 71 | 'MetaBox\MetaBox', 'PostType\PostType', 'Settings\Settings', 'Taxonomy\Taxonomy', |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function buildClassName( $name, $path = '' ) |
84 | 84 | { |
85 | - $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ))); |
|
85 | + $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ) ) ); |
|
86 | 86 | $className = implode( '', $className ); |
87 | 87 | return !empty( $path ) |
88 | - ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className )) |
|
88 | + ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ) ) |
|
89 | 89 | : $className; |
90 | 90 | } |
91 | 91 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function buildMethodName( $name, $prefix = 'get' ) |
98 | 98 | { |
99 | - return lcfirst( $this->buildClassName( $prefix . '-' . $name )); |
|
99 | + return lcfirst( $this->buildClassName( $prefix . '-' . $name ) ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function environment( $checkFor = '' ) |
107 | 107 | { |
108 | 108 | $environment = defined( 'WP_ENV' ) ? WP_ENV : 'production'; |
109 | - if( !empty( $checkFor )) { |
|
109 | + if( !empty( $checkFor ) ) { |
|
110 | 110 | return $environment == $checkFor; |
111 | 111 | } |
112 | 112 | return $environment; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $option = apply_filters( 'pollux/settings/option', Settings::ID ); |
121 | 121 | $settings = get_option( $option ); |
122 | 122 | if( !$settings ) { |
123 | - update_option( $option, [] ); |
|
123 | + update_option( $option, [ ] ); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -171,6 +171,6 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function url( $path = '' ) |
173 | 173 | { |
174 | - return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' )); |
|
174 | + return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) ); |
|
175 | 175 | } |
176 | 176 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | parent::__construct( $metabox ); |
15 | 15 | $this->meta_box = static::normalize( $this->meta_box ); |
16 | 16 | |
17 | - remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] ); |
|
18 | - remove_action( 'save_post_post', [$this, 'save_post'] ); |
|
17 | + remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] ); |
|
18 | + remove_action( 'save_post_post', [ $this, 'save_post' ] ); |
|
19 | 19 | |
20 | - add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
|
21 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
20 | + add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] ); |
|
21 | + add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function _get_field_meta( $meta, array $field, $saved ) |
31 | 31 | { |
32 | - if( !$this->is_edit_screen() || !empty( $meta ) || empty( $field['slug'] )) { |
|
32 | + if( !$this->is_edit_screen() || !empty( $meta ) || empty( $field[ 'slug' ] ) ) { |
|
33 | 33 | return $meta; |
34 | 34 | } |
35 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
36 | - ? (new SiteMeta)->get( $this->meta_box['slug'], $field['slug'], $meta ) |
|
37 | - : $field['std'] |
|
38 | - )); |
|
35 | + $meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved |
|
36 | + ? ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field[ 'slug' ], $meta ) |
|
37 | + : $field[ 'std' ] |
|
38 | + ) ); |
|
39 | 39 | return $this->_normalize_field_meta( $meta, $field ); |
40 | 40 | } |
41 | 41 | |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function _normalize_field_meta( $meta, array $field ) |
47 | 47 | { |
48 | - if( !empty( $meta ) && is_array( $meta )) { |
|
48 | + if( !empty( $meta ) && is_array( $meta ) ) { |
|
49 | 49 | return $meta; |
50 | 50 | } |
51 | - if( $field['clone'] ) { |
|
52 | - return ['']; |
|
51 | + if( $field[ 'clone' ] ) { |
|
52 | + return [ '' ]; |
|
53 | 53 | } |
54 | - if( $field['multiple'] ) { |
|
55 | - return []; |
|
54 | + if( $field[ 'multiple' ] ) { |
|
55 | + return [ ]; |
|
56 | 56 | } |
57 | 57 | return $meta; |
58 | 58 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | public function add_meta_boxes() |
65 | 65 | { |
66 | 66 | add_meta_box( |
67 | - $this->meta_box['id'], |
|
68 | - $this->meta_box['title'], |
|
69 | - [$this, 'show'], |
|
67 | + $this->meta_box[ 'id' ], |
|
68 | + $this->meta_box[ 'title' ], |
|
69 | + [ $this, 'show' ], |
|
70 | 70 | null, |
71 | - $this->meta_box['context'], |
|
72 | - $this->meta_box['priority'] |
|
71 | + $this->meta_box[ 'context' ], |
|
72 | + $this->meta_box[ 'priority' ] |
|
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function is_edit_screen( $screen = null ) |
80 | 80 | { |
81 | - return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID )); |
|
81 | + return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | public function is_saved() |
88 | 88 | { |
89 | 89 | foreach( array_column( $this->fields, 'slug' ) as $field ) { |
90 | - if( !is_null( (new SiteMeta)->get( $this->meta_box['slug'], $field, null ))) { |
|
90 | + if( !is_null( ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field, null ) ) ) { |
|
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public static function normalize( $metabox ) |
102 | 102 | { |
103 | - unset( $metabox['post_types'] ); |
|
104 | - return wp_parse_args( $metabox, ['slug' => ''] ); |
|
103 | + unset( $metabox[ 'post_types' ] ); |
|
104 | + return wp_parse_args( $metabox, [ 'slug' => '' ] ); |
|
105 | 105 | } |
106 | 106 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * @var array |
11 | 11 | */ |
12 | - public $columns = []; |
|
12 | + public $columns = [ ]; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @var array |
16 | 16 | */ |
17 | - public $types = []; |
|
17 | + public $types = [ ]; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @var Application |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | public function initColumns() |
28 | 28 | { |
29 | 29 | foreach( $this->types as $type => $args ) { |
30 | - add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 ); |
|
30 | + add_action( "manage_{$type}_posts_custom_column", [ $this, 'printColumnValue' ], 10, 2 ); |
|
31 | 31 | add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) { |
32 | - return count( $args['columns'] ) > 1 |
|
33 | - ? $args['columns'] |
|
32 | + return count( $args[ 'columns' ] ) > 1 |
|
33 | + ? $args[ 'columns' ] |
|
34 | 34 | : $columns; |
35 | 35 | }); |
36 | 36 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | protected function getColumnImage( $postId ) |
58 | 58 | { |
59 | 59 | if( has_post_thumbnail( $postId ) ) { |
60 | - list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [96, 48] ); |
|
60 | + list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [ 96, 48 ] ); |
|
61 | 61 | $image = sprintf( '<img src="%s" alt="%s" width="%s" height="%s">', |
62 | - esc_url( set_url_scheme( $src )), |
|
63 | - esc_attr( get_the_title( $postId )), |
|
62 | + esc_url( set_url_scheme( $src ) ), |
|
63 | + esc_attr( get_the_title( $postId ) ), |
|
64 | 64 | $width, |
65 | 65 | $height |
66 | 66 | ); |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function getColumnMedia() |
77 | 77 | { |
78 | - return count( (new PostMeta)->get( 'media', [ |
|
79 | - 'fallback' => [], |
|
78 | + return count( ( new PostMeta )->get( 'media', [ |
|
79 | + 'fallback' => [ ], |
|
80 | 80 | 'single' => false, |
81 | - ])); |
|
81 | + ] ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | protected function normalizeColumns( array $columns ) |
97 | 97 | { |
98 | 98 | $columns = array_flip( $columns ); |
99 | - $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns )); |
|
100 | - return ['cb' => '<input type="checkbox">'] + $columns; |
|
99 | + $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ) ); |
|
100 | + return [ 'cb' => '<input type="checkbox">' ] + $columns; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | { |
108 | 108 | $comments = sprintf( |
109 | 109 | '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', |
110 | - $this->app->config['columns']['comments'] |
|
110 | + $this->app->config[ 'columns' ][ 'comments' ] |
|
111 | 111 | ); |
112 | - $columns = wp_parse_args( $this->app->config['columns'], [ |
|
112 | + $columns = wp_parse_args( $this->app->config[ 'columns' ], [ |
|
113 | 113 | 'comments' => $comments, |
114 | - ]); |
|
114 | + ] ); |
|
115 | 115 | $this->columns = apply_filters( 'pollux/post_type/columns', $columns ); |
116 | 116 | } |
117 | 117 | } |