@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function buildClassName( $name, $path = '' ) |
15 | 15 | { |
16 | - $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ))); |
|
16 | + $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ) ) ); |
|
17 | 17 | $className = implode( '', $className ); |
18 | 18 | return !empty( $path ) |
19 | - ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className )) |
|
19 | + ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ) ) |
|
20 | 20 | : $className; |
21 | 21 | } |
22 | 22 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function buildMethodName( $name, $prefix = 'get' ) |
29 | 29 | { |
30 | - return lcfirst( $this->buildClassName( $prefix . '-' . $name )); |
|
30 | + return lcfirst( $this->buildClassName( $prefix . '-' . $name ) ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function startsWith( $needle, $haystack ) |
78 | 78 | { |
79 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
79 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | parent::__construct( $metabox ); |
16 | 16 | $this->meta_box = static::normalize( $this->meta_box ); |
17 | 17 | |
18 | - remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] ); |
|
19 | - remove_action( 'save_post_post', [$this, 'save_post'] ); |
|
18 | + remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] ); |
|
19 | + remove_action( 'save_post_post', [ $this, 'save_post' ] ); |
|
20 | 20 | |
21 | - add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
|
22 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
21 | + add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] ); |
|
22 | + add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function _get_field_meta( $meta, array $field, $saved ) |
32 | 32 | { |
33 | - if( !$this->is_edit_screen() || !empty(( new Helper )->toArray( $meta )) || empty( $field['slug'] )) { |
|
33 | + if( !$this->is_edit_screen() || !empty( ( new Helper )->toArray( $meta ) ) || empty( $field[ 'slug' ] ) ) { |
|
34 | 34 | return $meta; |
35 | 35 | } |
36 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
37 | - ? SiteMeta::get( $this->meta_box['slug'], $field['slug'], $meta ) |
|
38 | - : $field['std'] |
|
39 | - )); |
|
36 | + $meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved |
|
37 | + ? SiteMeta::get( $this->meta_box[ 'slug' ], $field[ 'slug' ], $meta ) |
|
38 | + : $field[ 'std' ] |
|
39 | + ) ); |
|
40 | 40 | return $this->_normalize_field_meta( $meta, $field ); |
41 | 41 | } |
42 | 42 | |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function _normalize_field_meta( $meta, array $field ) |
48 | 48 | { |
49 | - if( !empty( $meta ) && is_array( $meta )) { |
|
49 | + if( !empty( $meta ) && is_array( $meta ) ) { |
|
50 | 50 | return $meta; |
51 | 51 | } |
52 | - if( $field['clone'] ) { |
|
53 | - return ['']; |
|
52 | + if( $field[ 'clone' ] ) { |
|
53 | + return [ '' ]; |
|
54 | 54 | } |
55 | - if( $field['multiple'] ) { |
|
56 | - return []; |
|
55 | + if( $field[ 'multiple' ] ) { |
|
56 | + return [ ]; |
|
57 | 57 | } |
58 | 58 | return $meta; |
59 | 59 | } |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | public function add_meta_boxes() |
66 | 66 | { |
67 | 67 | add_meta_box( |
68 | - $this->meta_box['id'], |
|
69 | - $this->meta_box['title'], |
|
70 | - [$this, 'show'], |
|
68 | + $this->meta_box[ 'id' ], |
|
69 | + $this->meta_box[ 'title' ], |
|
70 | + [ $this, 'show' ], |
|
71 | 71 | null, |
72 | - $this->meta_box['context'], |
|
73 | - $this->meta_box['priority'] |
|
72 | + $this->meta_box[ 'context' ], |
|
73 | + $this->meta_box[ 'priority' ] |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function is_saved() |
89 | 89 | { |
90 | 90 | foreach( array_column( $this->fields, 'slug' ) as $field ) { |
91 | - if( !is_null( SiteMeta::get( $this->meta_box['slug'], $field, null ))) { |
|
91 | + if( !is_null( SiteMeta::get( $this->meta_box[ 'slug' ], $field, null ) ) ) { |
|
92 | 92 | return true; |
93 | 93 | } |
94 | 94 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function normalize( $metabox ) |
103 | 103 | { |
104 | - unset( $metabox['post_types'] ); |
|
105 | - return wp_parse_args( $metabox, ['slug' => ''] ); |
|
104 | + unset( $metabox[ 'post_types' ] ); |
|
105 | + return wp_parse_args( $metabox, [ 'slug' => '' ] ); |
|
106 | 106 | } |
107 | 107 | } |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | // @todo: run GateKeeper to check dependencies and capability (make sure it it run on the correct hook!) |
45 | 45 | // if( !is_plugin_active( 'meta-box/meta-box.php' ))return; |
46 | 46 | |
47 | - $this->normalize( $this->app->config[ static::ID ]); |
|
47 | + $this->normalize( $this->app->config[ static::ID ] ); |
|
48 | 48 | |
49 | - add_action( 'admin_menu', [$this, 'addPage'] ); |
|
50 | - add_action( 'pollux/'.static::ID.'/init', [$this, 'addSubmitMetaBox'] ); |
|
51 | - add_action( 'current_screen', [$this, 'register'] ); |
|
52 | - add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
53 | - add_action( 'pollux/'.static::ID.'/init', [$this, 'reset'] ); |
|
54 | - add_action( 'admin_print_footer_scripts', [$this, 'renderFooterScript'] ); |
|
55 | - add_filter( 'pollux/'.static::ID.'/instruction', [$this, 'filterInstruction'], 10, 3 ); |
|
56 | - add_filter( 'wp_redirect', [$this, 'filterRedirectOnSave'] ); |
|
49 | + add_action( 'admin_menu', [ $this, 'addPage' ] ); |
|
50 | + add_action( 'pollux/' . static::ID . '/init', [ $this, 'addSubmitMetaBox' ] ); |
|
51 | + add_action( 'current_screen', [ $this, 'register' ] ); |
|
52 | + add_action( 'admin_menu', [ $this, 'registerSetting' ] ); |
|
53 | + add_action( 'pollux/' . static::ID . '/init', [ $this, 'reset' ] ); |
|
54 | + add_action( 'admin_print_footer_scripts', [ $this, 'renderFooterScript' ] ); |
|
55 | + add_filter( 'pollux/' . static::ID . '/instruction', [ $this, 'filterInstruction' ], 10, 3 ); |
|
56 | + add_filter( 'wp_redirect', [ $this, 'filterRedirectOnSave' ] ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | public function action() |
63 | 63 | { |
64 | 64 | $args = func_get_args(); |
65 | - $hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args )); |
|
66 | - return do_action_ref_array( $hook, array_filter( $args )); |
|
65 | + $hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args ) ); |
|
66 | + return do_action_ref_array( $hook, array_filter( $args ) ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | __( 'Site Settings', 'pollux' ), |
78 | 78 | 'edit_theme_options', |
79 | 79 | static::id(), |
80 | - [$this, 'renderPage'], |
|
80 | + [ $this, 'renderPage' ], |
|
81 | 81 | 'dashicons-screenoptions', |
82 | 82 | 1313 |
83 | - ])); |
|
83 | + ] ) ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | call_user_func_array( 'add_meta_box', $this->filter( 'metabox/submit', [ |
93 | 93 | 'submitdiv', |
94 | 94 | __( 'Save Settings', 'pollux' ), |
95 | - [$this, 'renderSubmitMetaBox'], |
|
95 | + [ $this, 'renderSubmitMetaBox' ], |
|
96 | 96 | $this->hook, |
97 | 97 | 'side', |
98 | 98 | 'high', |
99 | - ])); |
|
99 | + ] ) ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | public function filter() |
106 | 106 | { |
107 | 107 | $args = func_get_args(); |
108 | - $hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args )); |
|
109 | - return apply_filters_ref_array( $hook, array_filter( $args )); |
|
108 | + $hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args ) ); |
|
109 | + return apply_filters_ref_array( $hook, array_filter( $args ) ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | public function filterRedirectOnSave( $location ) |
130 | 130 | { |
131 | 131 | if( strpos( $location, 'settings-updated=true' ) === false |
132 | - || strpos( $location, sprintf( 'page=%s', static::id() )) === false ) { |
|
132 | + || strpos( $location, sprintf( 'page=%s', static::id() ) ) === false ) { |
|
133 | 133 | return $location; |
134 | 134 | } |
135 | - return add_query_arg([ |
|
135 | + return add_query_arg( [ |
|
136 | 136 | 'page' => static::id(), |
137 | 137 | 'settings-updated' => 'true', |
138 | - ], admin_url( 'admin.php' )); |
|
138 | + ], admin_url( 'admin.php' ) ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function filterSavedSettings( $settings ) |
147 | 147 | { |
148 | - if( is_null( $settings )) { |
|
149 | - $settings = []; |
|
148 | + if( is_null( $settings ) ) { |
|
149 | + $settings = [ ]; |
|
150 | 150 | } |
151 | 151 | $this->action( 'saved' ); |
152 | 152 | return $this->filter( 'save', $settings ); |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function register() |
160 | 160 | { |
161 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
161 | + if( ( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
162 | 162 | foreach( parent::register() as $metabox ) { |
163 | 163 | new RWMetaBox( $metabox ); |
164 | 164 | } |
165 | 165 | add_screen_option( 'layout_columns', [ |
166 | 166 | 'max' => 2, |
167 | 167 | 'default' => 2, |
168 | - ]); |
|
168 | + ] ); |
|
169 | 169 | $this->action( 'init' ); |
170 | 170 | } |
171 | 171 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function registerSetting() |
177 | 177 | { |
178 | - register_setting( static::id(), static::id(), [$this, 'filterSavedSettings'] ); |
|
178 | + register_setting( static::id(), static::id(), [ $this, 'filterSavedSettings' ] ); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function renderFooterScript() |
186 | 186 | { |
187 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
187 | + if( ( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
188 | 188 | $this->render( 'settings/script', [ |
189 | 189 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
190 | 190 | 'hook' => $this->hook, |
191 | 191 | 'id' => static::id(), |
192 | - ]); |
|
192 | + ] ); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'columns' => get_current_screen()->get_columns(), |
203 | 203 | 'heading' => __( 'Site Settings', 'pollux' ), |
204 | 204 | 'id' => static::id(), |
205 | - ]); |
|
205 | + ] ); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | ]; |
219 | 219 | $this->render( 'settings/submit', [ |
220 | 220 | 'reset' => __( 'Reset', 'pollux' ), |
221 | - 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ))), |
|
221 | + 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ) ) ), |
|
222 | 222 | 'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ), |
223 | - ]); |
|
223 | + ] ); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
233 | 233 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
234 | 234 | )return; |
235 | - if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
|
235 | + if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) { |
|
236 | 236 | update_option( static::id(), $this->getDefaults() ); |
237 | 237 | return add_settings_error( static::id(), 'reset', __( 'All values have been reset to defaults.', 'pollux' ), 'updated' ); |
238 | 238 | } |
239 | - add_settings_error( static::id(), 'reset', __( 'Failed to reset values. Please refresh the page and try again.', 'pollux' )); |
|
239 | + add_settings_error( static::id(), 'reset', __( 'Failed to reset values. Please refresh the page and try again.', 'pollux' ) ); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | protected function filterArrayByKey( array $array, $key ) |
247 | 247 | { |
248 | 248 | return array_filter( $array, function( $value ) use( $key ) { |
249 | - return !empty( $value[$key] ); |
|
249 | + return !empty( $value[ $key ] ); |
|
250 | 250 | }); |
251 | 251 | } |
252 | 252 | |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | |
260 | 260 | array_walk( $metaboxes, function( &$metabox ) { |
261 | 261 | $fields = array_map( function( $field ) { |
262 | - $field = wp_parse_args( $field, ['std' => ''] ); |
|
263 | - return [$field['slug'] => $field['std']]; |
|
264 | - }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
|
262 | + $field = wp_parse_args( $field, [ 'std' => '' ] ); |
|
263 | + return [ $field[ 'slug' ] => $field[ 'std' ] ]; |
|
264 | + }, $this->filterArrayByKey( $metabox[ 'fields' ], 'slug' ) ); |
|
265 | 265 | $metabox = [ |
266 | - $metabox['slug'] => call_user_func_array( 'array_merge', $fields ), |
|
266 | + $metabox[ 'slug' ] => call_user_func_array( 'array_merge', $fields ), |
|
267 | 267 | ]; |
268 | 268 | }); |
269 | 269 | return call_user_func_array( 'array_merge', $metaboxes ); |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | */ |
285 | 285 | protected function normalizeFieldName( $name, array $data, $parentId ) |
286 | 286 | { |
287 | - if( !empty( $name )) { |
|
287 | + if( !empty( $name ) ) { |
|
288 | 288 | return $name; |
289 | 289 | } |
290 | - $name = str_replace( sprintf( '%s-%s-', static::id(), $parentId ), '', $data['id'] ); |
|
290 | + $name = str_replace( sprintf( '%s-%s-', static::id(), $parentId ), '', $data[ 'id' ] ); |
|
291 | 291 | return sprintf( '%s[%s][%s]', static::id(), $parentId, $name ); |
292 | 292 | } |
293 | 293 |
@@ -158,7 +158,9 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function register() |
160 | 160 | { |
161 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
161 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
162 | + return; |
|
163 | + } |
|
162 | 164 | foreach( parent::register() as $metabox ) { |
163 | 165 | new RWMetaBox( $metabox ); |
164 | 166 | } |
@@ -184,7 +186,9 @@ discard block |
||
184 | 186 | */ |
185 | 187 | public function renderFooterScript() |
186 | 188 | { |
187 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
189 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
190 | + return; |
|
191 | + } |
|
188 | 192 | $this->render( 'settings/script', [ |
189 | 193 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
190 | 194 | 'hook' => $this->hook, |
@@ -231,7 +235,9 @@ discard block |
||
231 | 235 | { |
232 | 236 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
233 | 237 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
234 | - )return; |
|
238 | + ) { |
|
239 | + return; |
|
240 | + } |
|
235 | 241 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
236 | 242 | update_option( static::id(), $this->getDefaults() ); |
237 | 243 | return add_settings_error( static::id(), 'reset', __( 'All values have been reset to defaults.', 'pollux' ), 'updated' ); |
@@ -245,7 +251,8 @@ discard block |
||
245 | 251 | */ |
246 | 252 | protected function filterArrayByKey( array $array, $key ) |
247 | 253 | { |
248 | - return array_filter( $array, function( $value ) use( $key ) { |
|
254 | + return array_filter( $array, function( $value ) use( $key ) |
|
255 | + { |
|
249 | 256 | return !empty( $value[$key] ); |
250 | 257 | }); |
251 | 258 | } |
@@ -257,8 +264,10 @@ discard block |
||
257 | 264 | { |
258 | 265 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
259 | 266 | |
260 | - array_walk( $metaboxes, function( &$metabox ) { |
|
261 | - $fields = array_map( function( $field ) { |
|
267 | + array_walk( $metaboxes, function( &$metabox ) |
|
268 | + { |
|
269 | + $fields = array_map( function( $field ) |
|
270 | + { |
|
262 | 271 | $field = wp_parse_args( $field, ['std' => ''] ); |
263 | 272 | return [$field['slug'] => $field['std']]; |
264 | 273 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function filterWordPressFooter( $text ) |
27 | 27 | { |
28 | - if( $this->app->config['remove_wordpress_footer'] )return; |
|
28 | + if( $this->app->config[ 'remove_wordpress_footer' ] )return; |
|
29 | 29 | return $text; |
30 | 30 | } |
31 | 31 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | $screenId = ( new Helper )->getCurrentScreen()->id; |
39 | 39 | |
40 | - if(( new Helper )->endsWith( sprintf( '_page_%s', Archive::id() ), $screenId )) { |
|
40 | + if( ( new Helper )->endsWith( sprintf( '_page_%s', Archive::id() ), $screenId ) ) { |
|
41 | 41 | wp_enqueue_script( 'editor-expand' ); |
42 | 42 | wp_enqueue_script( 'common' ); |
43 | 43 | wp_enqueue_script( 'wp-lists' ); |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | wp_enqueue_script( 'jquery-touch-punch' ); |
47 | 47 | } |
48 | 48 | } |
49 | - if( $screenId == sprintf( 'toplevel_page_%s', Settings::id() )) { |
|
49 | + if( $screenId == sprintf( 'toplevel_page_%s', Settings::id() ) ) { |
|
50 | 50 | wp_enqueue_script( 'common' ); |
51 | 51 | wp_enqueue_script( 'wp-lists' ); |
52 | 52 | wp_enqueue_script( 'postbox' ); |
53 | 53 | } |
54 | 54 | wp_enqueue_style( 'pollux/main.css', |
55 | 55 | $this->app->url( 'assets/main.css' ), |
56 | - apply_filters( 'pollux/enqueue/css/deps', [] ), |
|
56 | + apply_filters( 'pollux/enqueue/css/deps', [ ] ), |
|
57 | 57 | $this->app->version |
58 | 58 | ); |
59 | 59 | wp_enqueue_script( 'pollux/main.js', |
60 | 60 | $this->app->url( 'assets/main.js' ), |
61 | - apply_filters( 'pollux/enqueue/js/deps', [] ), |
|
61 | + apply_filters( 'pollux/enqueue/js/deps', [ ] ), |
|
62 | 62 | $this->app->version |
63 | 63 | ); |
64 | 64 | wp_localize_script( 'pollux/main.js', |
65 | 65 | apply_filters( 'pollux/enqueue/js/localize/name', $this->app->id ), |
66 | - apply_filters( 'pollux/enqueue/js/localize/variables', [] ) |
|
66 | + apply_filters( 'pollux/enqueue/js/localize/variables', [ ] ) |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function removeDashboardWidgets() |
75 | 75 | { |
76 | - if( !$this->app->config['remove_dashboard_widgets'] )return; |
|
76 | + if( !$this->app->config[ 'remove_dashboard_widgets' ] )return; |
|
77 | 77 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
78 | 78 | 'dashboard_primary', |
79 | 79 | 'dashboard_quick_press', |
80 | - ]); |
|
80 | + ] ); |
|
81 | 81 | foreach( $widgets as $widget ) { |
82 | 82 | remove_meta_box( $widget, 'dashboard', 'normal' ); |
83 | 83 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function removeWordPressMenu() |
91 | 91 | { |
92 | - if( !$this->app->config['remove_wordpress_menu'] )return; |
|
92 | + if( !$this->app->config[ 'remove_wordpress_menu' ] )return; |
|
93 | 93 | global $wp_admin_bar; |
94 | 94 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
95 | 95 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public static function conditions() |
23 | 23 | { |
24 | - return apply_filters( 'pollux/conditions', static::$conditions, strtolower(( new Helper )->getClassname( static::class ))); |
|
24 | + return apply_filters( 'pollux/conditions', static::$conditions, strtolower( ( new Helper )->getClassname( static::class ) ) ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | protected function normalizeCondition( $conditions ) |
46 | 46 | { |
47 | 47 | $conditions = ( new Helper )->toArray( $conditions ); |
48 | - if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) { |
|
48 | + if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) { |
|
49 | 49 | foreach( $conditions as $key ) { |
50 | - $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
50 | + $conditions[ str_replace( '!', '', $key ) ] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
51 | 51 | } |
52 | 52 | $conditions = array_filter( $conditions, function( $key ) { |
53 | 53 | return !is_numeric( $key ); |
54 | 54 | }, ARRAY_FILTER_USE_KEY ); |
55 | 55 | } |
56 | - $hook = sprintf( 'pollux/%s/conditions', strtolower(( new Helper )->getClassname( $this ))); |
|
56 | + $hook = sprintf( 'pollux/%s/conditions', strtolower( ( new Helper )->getClassname( $this ) ) ); |
|
57 | 57 | return array_intersect_key( |
58 | 58 | $conditions, |
59 | - array_flip( apply_filters( $hook, static::conditions() )) |
|
59 | + array_flip( apply_filters( $hook, static::conditions() ) ) |
|
60 | 60 | ); |
61 | 61 | } |
62 | 62 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function validateIsFrontPage( $value ) |
104 | 104 | { |
105 | - return $value == ( $this->getPostId() == get_option( 'page_on_front' )); |
|
105 | + return $value == ( $this->getPostId() == get_option( 'page_on_front' ) ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function validateIsHome( $value ) |
113 | 113 | { |
114 | - return $value == ( $this->getPostId() == get_option( 'page_for_posts' )); |
|
114 | + return $value == ( $this->getPostId() == get_option( 'page_for_posts' ) ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function validateIsPageTemplate( $value ) |
122 | 122 | { |
123 | - return basename( get_page_template_slug( $this->getPostId() )) == $value; |
|
123 | + return basename( get_page_template_slug( $this->getPostId() ) ) == $value; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -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' => 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 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | public function get( $group = null, $key = null, $fallback = null ) |
16 | 16 | { |
17 | 17 | $options = $this->getOption(); |
18 | - if( empty( $options )) { |
|
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 ); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function getOption() |
34 | 34 | { |
35 | - return get_option( Settings::id(), [] ); |
|
35 | + return get_option( Settings::id(), [ ] ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | */ |
43 | 43 | protected function normalize( array $options, $key, $fallback ) |
44 | 44 | { |
45 | - if( !array_key_exists( $key, $options )) { |
|
45 | + if( !array_key_exists( $key, $options ) ) { |
|
46 | 46 | return $fallback; |
47 | 47 | } |
48 | - $option = $options[$key]; |
|
48 | + $option = $options[ $key ]; |
|
49 | 49 | $option = is_array( $option ) |
50 | 50 | ? array_filter( $option ) |
51 | 51 | : trim( $option ); |
@@ -12,6 +12,6 @@ |
||
12 | 12 | */ |
13 | 13 | protected function getOption() |
14 | 14 | { |
15 | - return get_option( apply_filters( 'pollux/archives/option', Archive::ID ), [] ); |
|
15 | + return get_option( apply_filters( 'pollux/archives/option', Archive::ID ), [ ] ); |
|
16 | 16 | } |
17 | 17 | } |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | { |
22 | 22 | parent::init(); |
23 | 23 | |
24 | - add_action( 'pollux/archives/saved', [$this, 'addCustomNoticeOnSave'] ); |
|
25 | - add_action( 'pollux/archives/editor', [$this, 'renderEditor'] ); |
|
26 | - add_filter( 'pollux/archives/metabox/submit', [$this, 'filterSubmitMetaBox'] ); |
|
24 | + add_action( 'pollux/archives/saved', [ $this, 'addCustomNoticeOnSave' ] ); |
|
25 | + add_action( 'pollux/archives/editor', [ $this, 'renderEditor' ] ); |
|
26 | + add_filter( 'pollux/archives/metabox/submit', [ $this, 'filterSubmitMetaBox' ] ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | __( 'Archive', 'pollux' ), |
50 | 50 | 'edit_theme_options', |
51 | 51 | static::id(), |
52 | - [$this, 'renderPage'], |
|
53 | - ])); |
|
52 | + [ $this, 'renderPage' ], |
|
53 | + ] ) ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function filterSubmitMetaBox( array $args ) |
73 | 73 | { |
74 | - $args[1] = __( 'Save Archive', 'pollux' ); |
|
74 | + $args[ 1 ] = __( 'Save Archive', 'pollux' ); |
|
75 | 75 | return $args; |
76 | 76 | } |
77 | 77 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'wp_autoresize_on' => true, |
92 | 92 | 'add_unload_trigger' => false, |
93 | 93 | ], |
94 | - ]); |
|
94 | + ] ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'heading' => sprintf( __( '%s Archive', 'pollux' ), 'Post' ), |
107 | 107 | 'id' => static::id(), |
108 | 108 | 'title' => ArchiveMeta::get( 'title' ), |
109 | - ]); |
|
109 | + ] ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function getDefaults() |
116 | 116 | { |
117 | - return []; |
|
117 | + return [ ]; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -12,7 +12,7 @@ |
||
12 | 12 | /** |
13 | 13 | * @var string |
14 | 14 | */ |
15 | - CONST ID = 'archives'; |
|
15 | + const ID = 'archives'; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * {@inheritdoc} |