@@ -15,7 +15,7 @@ |
||
15 | 15 | /** |
16 | 16 | * @var string |
17 | 17 | */ |
18 | - CONST ID = 'pollux-settings'; |
|
18 | + const ID = 'pollux-settings'; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var string |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | public function init() |
29 | 29 | { |
30 | 30 | // @todo: run GateKeeper here instead to check dependencies and capability |
31 | - if( !is_plugin_active( 'meta-box/meta-box.php' ))return; |
|
31 | + if( !is_plugin_active( 'meta-box/meta-box.php' ) )return; |
|
32 | 32 | |
33 | 33 | $this->normalize(); |
34 | 34 | |
35 | - add_action( 'admin_menu', [$this, 'addPage'] ); |
|
36 | - add_action( 'pollux/settings/init', [$this, 'addSubmitMetaBox'] ); |
|
37 | - add_filter( 'pollux/settings/instruction', [$this, 'filterInstruction'], 10, 3 ); |
|
38 | - add_filter( 'wp_redirect', [$this, 'filterRedirectOnSave'] ); |
|
39 | - add_action( 'current_screen', [$this, 'register'] ); |
|
40 | - add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
41 | - add_action( 'pollux/settings/init', [$this, 'reset'] ); |
|
42 | - add_action( 'admin_footer-toplevel_page_' . self::ID, [$this, 'renderFooterScript'] ); |
|
35 | + add_action( 'admin_menu', [ $this, 'addPage' ] ); |
|
36 | + add_action( 'pollux/settings/init', [ $this, 'addSubmitMetaBox' ] ); |
|
37 | + add_filter( 'pollux/settings/instruction', [ $this, 'filterInstruction' ], 10, 3 ); |
|
38 | + add_filter( 'wp_redirect', [ $this, 'filterRedirectOnSave' ] ); |
|
39 | + add_action( 'current_screen', [ $this, 'register' ] ); |
|
40 | + add_action( 'admin_menu', [ $this, 'registerSetting' ] ); |
|
41 | + add_action( 'pollux/settings/init', [ $this, 'reset' ] ); |
|
42 | + add_action( 'admin_footer-toplevel_page_' . self::ID, [ $this, 'renderFooterScript' ] ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | __( 'Site Settings', 'pollux' ), |
53 | 53 | 'edit_theme_options', |
54 | 54 | self::ID, |
55 | - [$this, 'renderPage'], |
|
55 | + [ $this, 'renderPage' ], |
|
56 | 56 | 'dashicons-screenoptions', |
57 | 57 | 1313 |
58 | - ])); |
|
58 | + ] ) ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | call_user_func_array( 'add_meta_box', apply_filters( 'pollux/settings/metabox/submit', [ |
67 | 67 | 'submitdiv', |
68 | 68 | __( 'Save Settings', 'pollux' ), |
69 | - [ $this, 'renderSubmitMetaBox'], |
|
69 | + [ $this, 'renderSubmitMetaBox' ], |
|
70 | 70 | $this->hook, |
71 | 71 | 'side', |
72 | 72 | 'high', |
73 | - ])); |
|
73 | + ] ) ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | public function filterRedirectOnSave( $location ) |
92 | 92 | { |
93 | 93 | if( strpos( $location, 'settings-updated=true' ) === false |
94 | - || strpos( $location, sprintf( 'page=%s', self::ID )) === false ) { |
|
94 | + || strpos( $location, sprintf( 'page=%s', self::ID ) ) === false ) { |
|
95 | 95 | return $location; |
96 | 96 | } |
97 | - return add_query_arg([ |
|
97 | + return add_query_arg( [ |
|
98 | 98 | 'page' => self::ID, |
99 | 99 | 'settings-updated' => 'true', |
100 | - ], admin_url( 'admin.php' )); |
|
100 | + ], admin_url( 'admin.php' ) ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @return void |
105 | 105 | */ |
106 | - public function register( $metaboxes = [] ) |
|
106 | + public function register( $metaboxes = [ ] ) |
|
107 | 107 | { |
108 | 108 | if( get_current_screen()->id != $this->hook )return; |
109 | 109 | foreach( parent::register() as $metabox ) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | add_screen_option( 'layout_columns', [ |
113 | 113 | 'max' => 2, |
114 | 114 | 'default' => 2, |
115 | - ]); |
|
115 | + ] ); |
|
116 | 116 | do_action( 'pollux/settings/init' ); |
117 | 117 | } |
118 | 118 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function registerSetting() |
123 | 123 | { |
124 | - register_setting( self::ID, self::ID, [$this, 'onSave'] ); |
|
124 | + register_setting( self::ID, self::ID, [ $this, 'onSave' ] ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | public function onSave( $settings ) |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
140 | 140 | 'hook' => $this->hook, |
141 | 141 | 'id' => self::ID, |
142 | - ]); |
|
142 | + ] ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | 'columns' => get_current_screen()->get_columns(), |
152 | 152 | 'id' => self::ID, |
153 | 153 | 'title' => __( 'Site Settings', 'pollux' ), |
154 | - ]); |
|
154 | + ] ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | ]; |
167 | 167 | $this->render( 'settings/submit', [ |
168 | 168 | 'reset' => __( 'Reset Settings', 'pollux' ), |
169 | - 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ))), |
|
169 | + 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ) ) ), |
|
170 | 170 | 'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ), |
171 | - ]); |
|
171 | + ] ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | if( filter_input( INPUT_GET, 'page' ) !== self::ID |
180 | 180 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
181 | 181 | )return; |
182 | - if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
|
182 | + if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) { |
|
183 | 183 | delete_option( self::ID ); |
184 | 184 | // @todo: now trigger save to restore defaults |
185 | 185 | return add_settings_error( self::ID, 'reset', __( 'Settings reset to defaults.', 'pollux' ), 'updated' ); |
186 | 186 | } |
187 | - add_settings_error( self::ID, 'reset', __( 'Failed to reset settings. Please refresh the page and try again.', 'pollux' )); |
|
187 | + add_settings_error( self::ID, 'reset', __( 'Failed to reset settings. Please refresh the page and try again.', 'pollux' ) ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | protected function getInstructions() |
194 | 194 | { |
195 | 195 | return array_filter( $this->metaboxes, function( $metabox ) { |
196 | - return $this->verifyMetaBoxCondition( $metabox['condition'] ); |
|
196 | + return $this->verifyMetaBoxCondition( $metabox[ 'condition' ] ); |
|
197 | 197 | }); |
198 | 198 | } |
199 | 199 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function getPostTypes() |
204 | 204 | { |
205 | - return []; |
|
205 | + return [ ]; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -210,15 +210,15 @@ discard block |
||
210 | 210 | */ |
211 | 211 | protected function normalize() |
212 | 212 | { |
213 | - $this->metaboxes = []; |
|
214 | - foreach( $this->app->config['settings'] as $id => $metabox ) { |
|
213 | + $this->metaboxes = [ ]; |
|
214 | + foreach( $this->app->config[ 'settings' ] as $id => $metabox ) { |
|
215 | 215 | $defaults = [ |
216 | - 'condition' => [], |
|
217 | - 'fields' => [], |
|
216 | + 'condition' => [ ], |
|
217 | + 'fields' => [ ], |
|
218 | 218 | 'id' => $id, |
219 | 219 | 'slug' => $id, |
220 | 220 | ]; |
221 | - $this->metaboxes[] = $this->normalizeThis( $metabox, $defaults, $id ); |
|
221 | + $this->metaboxes[ ] = $this->normalizeThis( $metabox, $defaults, $id ); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | */ |
230 | 230 | protected function normalizeFieldName( $name, array $data, $parentId ) |
231 | 231 | { |
232 | - if( !empty( $name )) { |
|
232 | + if( !empty( $name ) ) { |
|
233 | 233 | return $name; |
234 | 234 | } |
235 | - $name = str_replace( sprintf( '%s-%s-', self::ID, $parentId ), '', $data['id'] ); |
|
235 | + $name = str_replace( sprintf( '%s-%s-', self::ID, $parentId ), '', $data[ 'id' ] ); |
|
236 | 236 | return sprintf( '%s[%s][%s]', self::ID, $parentId, $name ); |
237 | 237 | } |
238 | 238 |
@@ -28,7 +28,9 @@ discard block |
||
28 | 28 | public function init() |
29 | 29 | { |
30 | 30 | // @todo: run GateKeeper here instead to check dependencies and capability |
31 | - if( !is_plugin_active( 'meta-box/meta-box.php' ))return; |
|
31 | + if( !is_plugin_active( 'meta-box/meta-box.php' )) { |
|
32 | + return; |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $this->normalize(); |
34 | 36 | |
@@ -105,7 +107,9 @@ discard block |
||
105 | 107 | */ |
106 | 108 | public function register( $metaboxes = [] ) |
107 | 109 | { |
108 | - if( get_current_screen()->id != $this->hook )return; |
|
110 | + if( get_current_screen()->id != $this->hook ) { |
|
111 | + return; |
|
112 | + } |
|
109 | 113 | foreach( parent::register() as $metabox ) { |
110 | 114 | new SettingsMetaBox( $metabox ); |
111 | 115 | } |
@@ -178,7 +182,9 @@ discard block |
||
178 | 182 | { |
179 | 183 | if( filter_input( INPUT_GET, 'page' ) !== self::ID |
180 | 184 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
181 | - )return; |
|
185 | + ) { |
|
186 | + return; |
|
187 | + } |
|
182 | 188 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
183 | 189 | delete_option( self::ID ); |
184 | 190 | // @todo: now trigger save to restore defaults |
@@ -192,7 +198,8 @@ discard block |
||
192 | 198 | */ |
193 | 199 | protected function getInstructions() |
194 | 200 | { |
195 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
201 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
202 | + { |
|
196 | 203 | return $this->verifyMetaBoxCondition( $metabox['condition'] ); |
197 | 204 | }); |
198 | 205 | } |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * @param string $view |
31 | 31 | * @return void |
32 | 32 | */ |
33 | - public function render( $view, array $data = [] ) |
|
33 | + public function render( $view, array $data = [ ] ) |
|
34 | 34 | { |
35 | 35 | $file = apply_filters( 'pollux/views/file', |
36 | - $this->app->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ))), |
|
36 | + $this->app->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) ), |
|
37 | 37 | $view, |
38 | 38 | $data |
39 | 39 | ); |
40 | - if( file_exists( $file )) { |
|
40 | + if( file_exists( $file ) ) { |
|
41 | 41 | extract( $data ); |
42 | 42 | return include $file; |
43 | 43 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function getClassname( $toLowerCase = true ) |
51 | 51 | { |
52 | - $paths = explode( '\\', get_class( $this )); |
|
52 | + $paths = explode( '\\', get_class( $this ) ); |
|
53 | 53 | return wp_validate_boolean( $toLowerCase ) |
54 | - ? strtolower( end( $paths )) |
|
54 | + ? strtolower( end( $paths ) ) |
|
55 | 55 | : end( $paths ); |
56 | 56 | } |
57 | 57 | |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $data = wp_parse_args( $data, $defaults ); |
65 | 65 | foreach( $defaults as $key => $value ) { |
66 | 66 | $method = $this->app->buildMethodName( $key, 'normalize' ); |
67 | - if( method_exists( $this, $method )) { |
|
68 | - $data[$key] = $this->$method( $data[$key], $data, $id ); |
|
67 | + if( method_exists( $this, $method ) ) { |
|
68 | + $data[ $key ] = $this->$method( $data[ $key ], $data, $id ); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | return $data; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public static function clearResolvedInstances() |
50 | 50 | { |
51 | - static::$resolvedInstance = []; |
|
51 | + static::$resolvedInstance = [ ]; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected static function resolveFacadeInstance( $name ) |
104 | 104 | { |
105 | - if( is_object( $name )) { |
|
105 | + if( is_object( $name ) ) { |
|
106 | 106 | return $name; |
107 | 107 | } |
108 | 108 | |
109 | - if( isset( static::$resolvedInstance[$name] )) { |
|
110 | - return static::$resolvedInstance[$name]; |
|
109 | + if( isset( static::$resolvedInstance[ $name ] ) ) { |
|
110 | + return static::$resolvedInstance[ $name ]; |
|
111 | 111 | } |
112 | 112 | |
113 | - return static::$resolvedInstance[$name] = static::$app->make( $name ); |
|
113 | + return static::$resolvedInstance[ $name ] = static::$app->make( $name ); |
|
114 | 114 | } |
115 | 115 | } |
@@ -42,6 +42,7 @@ |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | + * @param boolean $bool |
|
45 | 46 | * @return bool |
46 | 47 | */ |
47 | 48 | public function isVisible( $bool, array $metabox ) |
@@ -59,7 +59,8 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function verifyMetaBoxCondition( array $conditions ) |
61 | 61 | { |
62 | - array_walk( $conditions, function( &$value, $key ) { |
|
62 | + array_walk( $conditions, function( &$value, $key ) |
|
63 | + { |
|
63 | 64 | $method = $this->app->buildMethodName( $key, 'validate' ); |
64 | 65 | $value = method_exists( $this, $method ) |
65 | 66 | ? $this->$method( $value ) |
@@ -70,9 +71,12 @@ discard block |
||
70 | 71 | |
71 | 72 | protected function addInstructions() |
72 | 73 | { |
73 | - if( !count( array_filter( $this->metaboxes, function( $metabox ) { |
|
74 | + if( !count( array_filter( $this->metaboxes, function( $metabox ) |
|
75 | + { |
|
74 | 76 | return $this->isVisible( false, $metabox ); |
75 | - })))return; |
|
77 | + }))) { |
|
78 | + return; |
|
79 | + } |
|
76 | 80 | $this->metaboxes[] = [ |
77 | 81 | 'id' => 'infodiv', |
78 | 82 | 'post_types' => $this->getPostTypes(), |
@@ -91,8 +95,10 @@ discard block |
||
91 | 95 | */ |
92 | 96 | protected function generateInstructions() |
93 | 97 | { |
94 | - return array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
|
95 | - $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
98 | + return array_reduce( $this->getInstructions(), function( $html, $metabox ) |
|
99 | + { |
|
100 | + $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) |
|
101 | + { |
|
96 | 102 | $hook = sprintf( 'pollux/%s/instruction', $this->getClassname() ); |
97 | 103 | return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL; |
98 | 104 | }); |
@@ -108,7 +114,8 @@ discard block |
||
108 | 114 | */ |
109 | 115 | protected function getInstructions() |
110 | 116 | { |
111 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
117 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
118 | + { |
|
112 | 119 | return $this->verifyMetaBoxCondition( $metabox['condition'] ) |
113 | 120 | && $this->hasPostType( $metabox ); |
114 | 121 | }); |
@@ -178,7 +185,8 @@ discard block |
||
178 | 185 | foreach( $conditions as $key ) { |
179 | 186 | $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
180 | 187 | } |
181 | - $conditions = array_filter( $conditions, function( $key ) { |
|
188 | + $conditions = array_filter( $conditions, function( $key ) |
|
189 | + { |
|
182 | 190 | return !is_numeric( $key ); |
183 | 191 | }, ARRAY_FILTER_USE_KEY ); |
184 | 192 | } |
@@ -194,7 +202,8 @@ discard block |
||
194 | 202 | */ |
195 | 203 | protected function normalizeFields( array $fields, array $data, $parentId ) |
196 | 204 | { |
197 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
205 | + return array_map( function( $id, $field ) use( $parentId ) |
|
206 | + { |
|
198 | 207 | $defaults = [ |
199 | 208 | 'id' => $id, |
200 | 209 | 'field_name' => '', |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | { |
27 | 27 | $this->normalize(); |
28 | 28 | |
29 | - add_filter( 'rwmb_show', [$this, 'isVisible'], 10, 2 ); |
|
30 | - add_action( 'rwmb_meta_boxes', [$this, 'register'] ); |
|
29 | + add_filter( 'rwmb_show', [ $this, 'isVisible' ], 10, 2 ); |
|
30 | + add_action( 'rwmb_meta_boxes', [ $this, 'register' ] ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @return array |
35 | 35 | */ |
36 | - public function register( $metaboxes = [] ) |
|
36 | + public function register( $metaboxes = [ ] ) |
|
37 | 37 | { |
38 | - if( current_user_can( 'switch_themes' )) { |
|
38 | + if( current_user_can( 'switch_themes' ) ) { |
|
39 | 39 | $this->addInstructions(); |
40 | 40 | } |
41 | 41 | return array_merge( $metaboxes, $this->metaboxes ); |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | public function isVisible( $bool, array $metabox ) |
48 | 48 | { |
49 | 49 | if( defined( 'DOING_AJAX' ) |
50 | - || !isset( $metabox['condition'] ) |
|
51 | - || !$this->hasPostType( $metabox )) { |
|
50 | + || !isset( $metabox[ 'condition' ] ) |
|
51 | + || !$this->hasPostType( $metabox ) ) { |
|
52 | 52 | return $bool; |
53 | 53 | } |
54 | - return $this->verifyMetaBoxCondition( $metabox['condition'] ); |
|
54 | + return $this->verifyMetaBoxCondition( $metabox[ 'condition' ] ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | { |
73 | 73 | if( !count( array_filter( $this->metaboxes, function( $metabox ) { |
74 | 74 | return $this->isVisible( false, $metabox ); |
75 | - })))return; |
|
76 | - $this->metaboxes[] = [ |
|
75 | + }) ) )return; |
|
76 | + $this->metaboxes[ ] = [ |
|
77 | 77 | 'id' => 'infodiv', |
78 | 78 | 'post_types' => $this->getPostTypes(), |
79 | 79 | 'title' => __( 'How to use in your theme', 'pollux' ), |
80 | 80 | 'context' => 'side', |
81 | 81 | 'priority' => 'low', |
82 | - 'fields' => [[ |
|
82 | + 'fields' => [ [ |
|
83 | 83 | 'slug' => '', |
84 | 84 | 'std' => $this->generateInstructions(), |
85 | 85 | 'type' => 'custom_html', |
86 | - ]], |
|
86 | + ] ], |
|
87 | 87 | ]; |
88 | 88 | } |
89 | 89 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | protected function generateInstructions() |
94 | 94 | { |
95 | 95 | return array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
96 | - $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
96 | + $fields = array_reduce( array_column( $metabox[ 'fields' ], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
97 | 97 | $hook = sprintf( 'pollux/%s/instruction', $this->getClassname() ); |
98 | - return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL; |
|
98 | + return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox[ 'slug' ] ) . PHP_EOL; |
|
99 | 99 | }); |
100 | 100 | return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
101 | - $metabox['title'], |
|
101 | + $metabox[ 'title' ], |
|
102 | 102 | $fields |
103 | 103 | ); |
104 | 104 | }); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | protected function getInstructions() |
111 | 111 | { |
112 | 112 | return array_filter( $this->metaboxes, function( $metabox ) { |
113 | - return $this->verifyMetaBoxCondition( $metabox['condition'] ) |
|
113 | + return $this->verifyMetaBoxCondition( $metabox[ 'condition' ] ) |
|
114 | 114 | && $this->hasPostType( $metabox ); |
115 | 115 | }); |
116 | 116 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function getPostId() |
122 | 122 | { |
123 | - if( !( $postId = filter_input( INPUT_GET, 'post' ))) { |
|
123 | + if( !( $postId = filter_input( INPUT_GET, 'post' ) ) ) { |
|
124 | 124 | $postId = filter_input( INPUT_POST, 'post_ID' ); |
125 | 125 | } |
126 | 126 | return intval( $postId ); |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | { |
134 | 134 | return array_unique( iterator_to_array( |
135 | 135 | new RecursiveIteratorIterator( |
136 | - new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' )) |
|
136 | + new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) ) |
|
137 | 137 | ), |
138 | 138 | false |
139 | - )); |
|
139 | + ) ); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | */ |
145 | 145 | protected function hasPostType( array $metabox ) |
146 | 146 | { |
147 | - if( !isset( $metabox['post_types'] )) { |
|
147 | + if( !isset( $metabox[ 'post_types' ] ) ) { |
|
148 | 148 | return true; |
149 | 149 | } |
150 | - return in_array( get_post_type( $this->getPostId() ), $metabox['post_types'] ); |
|
150 | + return in_array( get_post_type( $this->getPostId() ), $metabox[ 'post_types' ] ); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function normalize() |
157 | 157 | { |
158 | - $this->metaboxes = []; |
|
159 | - foreach( $this->app->config['meta_boxes'] as $id => $metabox ) { |
|
158 | + $this->metaboxes = [ ]; |
|
159 | + foreach( $this->app->config[ 'meta_boxes' ] as $id => $metabox ) { |
|
160 | 160 | $defaults = [ |
161 | - 'condition' => [], |
|
162 | - 'fields' => [], |
|
161 | + 'condition' => [ ], |
|
162 | + 'fields' => [ ], |
|
163 | 163 | 'id' => $id, |
164 | - 'post_types' => [], |
|
164 | + 'post_types' => [ ], |
|
165 | 165 | 'slug' => $id, |
166 | 166 | ]; |
167 | - $this->metaboxes[] = $this->normalizeThis( $metabox, $defaults, $id ); |
|
167 | + $this->metaboxes[ ] = $this->normalizeThis( $metabox, $defaults, $id ); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | protected function normalizeCondition( $conditions ) |
176 | 176 | { |
177 | 177 | $conditions = $this->toArray( $conditions ); |
178 | - if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) { |
|
178 | + if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) { |
|
179 | 179 | foreach( $conditions as $key ) { |
180 | - $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
180 | + $conditions[ str_replace( '!', '', $key ) ] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
181 | 181 | } |
182 | 182 | $conditions = array_filter( $conditions, function( $key ) { |
183 | 183 | return !is_numeric( $key ); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $hook = sprintf( 'pollux/%s/conditions', $this->getClassname() ); |
187 | 187 | return array_intersect_key( |
188 | 188 | $conditions, |
189 | - array_flip( apply_filters( $hook, self::CONDITIONS )) |
|
189 | + array_flip( apply_filters( $hook, self::CONDITIONS ) ) |
|
190 | 190 | ); |
191 | 191 | } |
192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | protected function normalizeFields( array $fields, array $data, $parentId ) |
197 | 197 | { |
198 | 198 | return array_map( function( $id, $field ) use( $parentId ) { |
199 | - $defaults = [ |
|
199 | + $defaults = [ |
|
200 | 200 | 'id' => $id, |
201 | 201 | 'field_name' => '', |
202 | 202 | 'slug' => $id, |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | protected function validateIsFrontPage( $value ) |
243 | 243 | { |
244 | - return $value == ( $this->getPostId() == get_option( 'page_on_front' )); |
|
244 | + return $value == ( $this->getPostId() == get_option( 'page_on_front' ) ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function validateIsHome( $value ) |
252 | 252 | { |
253 | - return $value == ( $this->getPostId() == get_option( 'page_for_posts' )); |
|
253 | + return $value == ( $this->getPostId() == get_option( 'page_for_posts' ) ); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | protected function validateIsPageTemplate( $value ) |
261 | 261 | { |
262 | - return basename( get_page_template_slug( $this->getPostId() )) == $value; |
|
262 | + return basename( get_page_template_slug( $this->getPostId() ) ) == $value; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -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 | } |
@@ -12,7 +12,9 @@ |
||
12 | 12 | */ |
13 | 13 | public function get( $metaKey, array $args = [] ) |
14 | 14 | { |
15 | - if( empty( $metaKey ))return; |
|
15 | + if( empty( $metaKey )) { |
|
16 | + return; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $args = $this->normalize( $args ); |
18 | 20 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
@@ -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,9 +49,9 @@ 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( !isset( $vars[$taxonomy] ))return; |
|
53 | - if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
|
54 | - $vars[$taxonomy] = $term->slug; |
|
52 | + if( !isset( $vars[ $taxonomy ] ) )return; |
|
53 | + if( $term = get_term_by( 'id', $vars[ $taxonomy ], $taxonomy ) ) { |
|
54 | + $vars[ $taxonomy ] = $term->slug; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | return $query; |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | { |
65 | 65 | global $wp_query; |
66 | 66 | foreach( $this->taxonomies as $taxonomy => $args ) { |
67 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
68 | - $selected = isset( $wp_query->query[$taxonomy] ) |
|
69 | - ? $wp_query->query[$taxonomy] |
|
67 | + if( !in_array( get_current_screen()->post_type, $args[ 'post_types' ] ) )continue; |
|
68 | + $selected = isset( $wp_query->query[ $taxonomy ] ) |
|
69 | + ? $wp_query->query[ $taxonomy ] |
|
70 | 70 | : false; |
71 | - wp_dropdown_categories([ |
|
71 | + wp_dropdown_categories( [ |
|
72 | 72 | 'hide_if_empty' => true, |
73 | 73 | 'name' => $taxonomy, |
74 | 74 | 'orderby' => 'name', |
75 | 75 | 'selected' => $selected, |
76 | - 'show_option_all' => $args['labels']['all_items'], |
|
76 | + 'show_option_all' => $args[ 'labels' ][ 'all_items' ], |
|
77 | 77 | 'taxonomy' => $taxonomy, |
78 | - ]); |
|
78 | + ] ); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | public function register() |
86 | 86 | { |
87 | 87 | array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
88 | - register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( self::CUSTOM_KEYS ))); |
|
89 | - foreach( $args['post_types'] as $type ) { |
|
88 | + register_taxonomy( $taxonomy, $args[ 'post_types' ], array_diff_key( $args, array_flip( self::CUSTOM_KEYS ) ) ); |
|
89 | + foreach( $args[ 'post_types' ] as $type ) { |
|
90 | 90 | register_taxonomy_for_object_type( $taxonomy, $type ); |
91 | 91 | } |
92 | 92 | }); |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function normalize() |
99 | 99 | { |
100 | - foreach( $this->app->config['taxonomies'] as $taxonomy => $args ) { |
|
101 | - $this->taxonomies[$taxonomy] = apply_filters( 'pollux/taxonomy/args', |
|
100 | + foreach( $this->app->config[ 'taxonomies' ] as $taxonomy => $args ) { |
|
101 | + $this->taxonomies[ $taxonomy ] = apply_filters( 'pollux/taxonomy/args', |
|
102 | 102 | $this->normalizeThis( $args, self::TAXONOMY_DEFAULTS, $taxonomy ) |
103 | 103 | ); |
104 | 104 | } |
105 | 105 | $this->taxonomies = array_diff_key( |
106 | 106 | $this->taxonomies, |
107 | - get_taxonomies( ['_builtin' => true] ) |
|
107 | + get_taxonomies( [ '_builtin' => true ] ) |
|
108 | 108 | ); |
109 | 109 | } |
110 | 110 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function normalizeLabels( $labels, array $args ) |
116 | 116 | { |
117 | - return wp_parse_args( $labels, $this->setLabels( $args )); |
|
117 | + return wp_parse_args( $labels, $this->setLabels( $args ) ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | protected function normalizeMenuName( $menuname, array $args ) |
125 | 125 | { |
126 | 126 | return empty( $menuname ) |
127 | - ? $args['plural'] |
|
127 | + ? $args[ 'plural' ] |
|
128 | 128 | : $menuname; |
129 | 129 | } |
130 | 130 | |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | protected function setLabels( array $args ) |
144 | 144 | { |
145 | 145 | return apply_filters( 'pollux/taxonomy/labels', [ |
146 | - 'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args['single'] ), |
|
147 | - 'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args['plural'] ), |
|
148 | - 'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args['single'] ), |
|
149 | - 'menu_name' => $this->normalizeMenuName( $args['menu_name'], $args ), |
|
150 | - 'name' => $args['plural'], |
|
151 | - 'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args['single'] ), |
|
152 | - 'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args['plural'] ), |
|
153 | - 'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args['plural'] ), |
|
154 | - 'singular_name' => $args['single'], |
|
155 | - 'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args['single'] ), |
|
156 | - 'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args['single'] ), |
|
146 | + 'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args[ 'single' ] ), |
|
147 | + 'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args[ 'plural' ] ), |
|
148 | + 'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args[ 'single' ] ), |
|
149 | + 'menu_name' => $this->normalizeMenuName( $args[ 'menu_name' ], $args ), |
|
150 | + 'name' => $args[ 'plural' ], |
|
151 | + 'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args[ 'single' ] ), |
|
152 | + 'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args[ 'plural' ] ), |
|
153 | + 'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args[ 'plural' ] ), |
|
154 | + 'singular_name' => $args[ 'single' ], |
|
155 | + 'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args[ 'single' ] ), |
|
156 | + 'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args[ 'single' ] ), |
|
157 | 157 | ], $args ); |
158 | 158 | } |
159 | 159 | } |
@@ -46,10 +46,14 @@ 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 | $vars = &$query->query_vars; |
51 | 53 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
52 | - if( !isset( $vars[$taxonomy] ))return; |
|
54 | + if( !isset( $vars[$taxonomy] )) { |
|
55 | + return; |
|
56 | + } |
|
53 | 57 | if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
54 | 58 | $vars[$taxonomy] = $term->slug; |
55 | 59 | } |
@@ -64,7 +68,9 @@ discard block |
||
64 | 68 | { |
65 | 69 | global $wp_query; |
66 | 70 | foreach( $this->taxonomies as $taxonomy => $args ) { |
67 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
71 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] )) { |
|
72 | + continue; |
|
73 | + } |
|
68 | 74 | $selected = isset( $wp_query->query[$taxonomy] ) |
69 | 75 | ? $wp_query->query[$taxonomy] |
70 | 76 | : false; |
@@ -84,7 +90,8 @@ discard block |
||
84 | 90 | */ |
85 | 91 | public function register() |
86 | 92 | { |
87 | - array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
|
93 | + array_walk( $this->taxonomies, function( $args, $taxonomy ) |
|
94 | + { |
|
88 | 95 | register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( self::CUSTOM_KEYS ))); |
89 | 96 | foreach( $args['post_types'] as $type ) { |
90 | 97 | register_taxonomy_for_object_type( $taxonomy, $type ); |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | { |
14 | 14 | parent::__construct( $metabox ); |
15 | 15 | $this->meta_box = static::normalize( $this->meta_box ); |
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( $meta ) || empty( $field['slug'] )) { |
|
29 | + if( !$this->is_edit_screen() || !empty( $meta ) || empty( $field[ 'slug' ] ) ) { |
|
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['slug'], $field['slug'], $meta ) |
|
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[ 'slug' ], $field[ 'slug' ], $meta ) |
|
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, 'slug' ) as $field ) { |
86 | - if( !is_null( (new SiteMeta)->get( $this->meta_box['slug'], $field, null ))) { |
|
86 | + if( !is_null( ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field, null ) ) ) { |
|
87 | 87 | return true; |
88 | 88 | } |
89 | 89 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public static function normalize( $metabox ) |
98 | 98 | { |
99 | - $metabox['post_types'] = []; |
|
100 | - return wp_parse_args( $metabox, ['slug' => '']); |
|
99 | + $metabox[ 'post_types' ] = [ ]; |
|
100 | + return wp_parse_args( $metabox, [ 'slug' => '' ] ); |
|
101 | 101 | } |
102 | 102 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | public function get( $group = null, $key = null, $fallback = null ) |
16 | 16 | { |
17 | 17 | $options = get_option( Settings::ID ); |
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 ); |
@@ -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 ); |