@@ -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( 'pollux/'.static::ID.'/before/instructions', [$this, 'filterBeforeInstructions'] ); |
|
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( 'pollux/' . static::ID . '/before/instructions', [ $this, 'filterBeforeInstructions' ] ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | __( 'Site Settings', 'pollux' ), |
68 | 68 | 'edit_theme_options', |
69 | 69 | static::id(), |
70 | - [$this, 'renderPage'], |
|
70 | + [ $this, 'renderPage' ], |
|
71 | 71 | 'dashicons-screenoptions', |
72 | 72 | 1313 |
73 | - ])); |
|
73 | + ] ) ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | call_user_func_array( 'add_meta_box', $this->filter( 'metabox/submit', [ |
83 | 83 | 'submitdiv', |
84 | 84 | __( 'Save Settings', 'pollux' ), |
85 | - [$this, 'renderSubmitMetaBox'], |
|
85 | + [ $this, 'renderSubmitMetaBox' ], |
|
86 | 86 | $this->hook, |
87 | 87 | 'side', |
88 | 88 | 'high', |
89 | - ])); |
|
89 | + ] ) ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function filterInstruction( $instruction, array $field, array $metabox ) |
107 | 107 | { |
108 | - return sprintf( "SiteMeta::%s('%s');", $metabox['slug'], $field['slug'] ); |
|
108 | + return sprintf( "SiteMeta::%s('%s');", $metabox[ 'slug' ], $field[ 'slug' ] ); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function filterSavedSettings( $settings ) |
117 | 117 | { |
118 | - if( is_null( $settings )) { |
|
119 | - $settings = []; |
|
118 | + if( is_null( $settings ) ) { |
|
119 | + $settings = [ ]; |
|
120 | 120 | } |
121 | - return $this->filter( 'save', array_merge( $this->getSettings(), $settings )); |
|
121 | + return $this->filter( 'save', array_merge( $this->getSettings(), $settings ) ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function register() |
140 | 140 | { |
141 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
141 | + if( ( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
142 | 142 | foreach( parent::register() as $metabox ) { |
143 | 143 | new RWMetaBox( $metabox, static::ID, $this ); |
144 | 144 | } |
145 | 145 | add_screen_option( 'layout_columns', [ |
146 | 146 | 'max' => 2, |
147 | 147 | 'default' => 2, |
148 | - ]); |
|
148 | + ] ); |
|
149 | 149 | $this->action( 'init' ); |
150 | 150 | } |
151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function registerSetting() |
157 | 157 | { |
158 | - register_setting( static::id(), static::id(), [$this, 'filterSavedSettings'] ); |
|
158 | + register_setting( static::id(), static::id(), [ $this, 'filterSavedSettings' ] ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function renderFooterScript() |
166 | 166 | { |
167 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
167 | + if( ( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
168 | 168 | $this->render( 'settings/script', [ |
169 | 169 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
170 | 170 | 'hook' => $this->hook, |
171 | 171 | 'id' => static::id(), |
172 | - ]); |
|
172 | + ] ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'columns' => get_current_screen()->get_columns(), |
183 | 183 | 'heading' => __( 'Site Settings', 'pollux' ), |
184 | 184 | 'id' => static::id(), |
185 | - ]); |
|
185 | + ] ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | ]; |
200 | 200 | $this->render( 'settings/submit', [ |
201 | 201 | 'reset' => __( 'Reset all', 'pollux' ), |
202 | - 'reset_url' => esc_url( add_query_arg( $query, admin_url( $pagenow ))), |
|
202 | + 'reset_url' => esc_url( add_query_arg( $query, admin_url( $pagenow ) ) ), |
|
203 | 203 | 'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ), |
204 | - ]); |
|
204 | + ] ); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
214 | 214 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
215 | 215 | )return; |
216 | - if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
|
216 | + if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) { |
|
217 | 217 | update_option( static::id(), $this->getDefaults() ); |
218 | 218 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
219 | 219 | } |
220 | 220 | else { |
221 | - add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' )); |
|
221 | + add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ) ); |
|
222 | 222 | } |
223 | 223 | set_transient( 'settings_errors', get_settings_errors(), 30 ); |
224 | - wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() )); |
|
224 | + wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() ) ); |
|
225 | 225 | exit; |
226 | 226 | } |
227 | 227 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | protected function filterArrayByKey( array $array, $key ) |
233 | 233 | { |
234 | 234 | return array_filter( $array, function( $value ) use( $key ) { |
235 | - return !empty( $value[$key] ); |
|
235 | + return !empty( $value[ $key ] ); |
|
236 | 236 | }); |
237 | 237 | } |
238 | 238 | |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | |
246 | 246 | array_walk( $metaboxes, function( &$metabox ) { |
247 | 247 | $fields = array_map( function( $field ) { |
248 | - $field = wp_parse_args( $field, ['std' => ''] ); |
|
249 | - return [$field['slug'] => $field['std']]; |
|
250 | - }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
|
248 | + $field = wp_parse_args( $field, [ 'std' => '' ] ); |
|
249 | + return [ $field[ 'slug' ] => $field[ 'std' ] ]; |
|
250 | + }, $this->filterArrayByKey( $metabox[ 'fields' ], 'slug' ) ); |
|
251 | 251 | $metabox = [ |
252 | - $metabox['slug'] => call_user_func_array( 'array_merge', $fields ), |
|
252 | + $metabox[ 'slug' ] => call_user_func_array( 'array_merge', $fields ), |
|
253 | 253 | ]; |
254 | 254 | }); |
255 | 255 | return call_user_func_array( 'array_merge', $metaboxes ); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | protected function normalizeFieldName( $name, array $data, $parentId ) |
269 | 269 | { |
270 | - return sprintf( '%s[%s][%s]', static::id(), $parentId, $data['slug'] ); |
|
270 | + return sprintf( '%s[%s][%s]', static::id(), $parentId, $data[ 'slug' ] ); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | $this->pollux_caller = $caller; |
20 | 20 | $this->pollux_id = $id; |
21 | 21 | |
22 | - remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] ); |
|
23 | - remove_action( 'save_post_post', [$this, 'save_post'] ); |
|
22 | + remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] ); |
|
23 | + remove_action( 'save_post_post', [ $this, 'save_post' ] ); |
|
24 | 24 | |
25 | - add_action( 'pollux/archives/init', [$this, 'add_meta_boxes'] ); |
|
26 | - add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
|
27 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
25 | + add_action( 'pollux/archives/init', [ $this, 'add_meta_boxes' ] ); |
|
26 | + add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] ); |
|
27 | + add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function _get_field_meta( $meta, array $field, $saved ) |
37 | 37 | { |
38 | - if( !$this->is_edit_screen() || !empty(( new Helper )->toArray( $meta )) || empty( $field['slug'] )) { |
|
38 | + if( !$this->is_edit_screen() || !empty( ( new Helper )->toArray( $meta ) ) || empty( $field[ 'slug' ] ) ) { |
|
39 | 39 | return $meta; |
40 | 40 | } |
41 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
42 | - ? $this->pollux_caller->getMetaValue( $field['slug'], $meta, $this->meta_box['slug'] ) |
|
43 | - : $field['std'] |
|
44 | - )); |
|
41 | + $meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved |
|
42 | + ? $this->pollux_caller->getMetaValue( $field[ 'slug' ], $meta, $this->meta_box[ 'slug' ] ) |
|
43 | + : $field[ 'std' ] |
|
44 | + ) ); |
|
45 | 45 | return $this->_normalize_field_meta( $meta, $field ); |
46 | 46 | } |
47 | 47 | |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function _normalize_field_meta( $meta, array $field ) |
53 | 53 | { |
54 | - if( !empty( $meta ) && is_array( $meta )) { |
|
54 | + if( !empty( $meta ) && is_array( $meta ) ) { |
|
55 | 55 | return $meta; |
56 | 56 | } |
57 | - if( $field['clone'] ) { |
|
58 | - return ['']; |
|
57 | + if( $field[ 'clone' ] ) { |
|
58 | + return [ '' ]; |
|
59 | 59 | } |
60 | - if( $field['multiple'] ) { |
|
61 | - return []; |
|
60 | + if( $field[ 'multiple' ] ) { |
|
61 | + return [ ]; |
|
62 | 62 | } |
63 | 63 | return $meta; |
64 | 64 | } |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | public function add_meta_boxes() |
72 | 72 | { |
73 | 73 | add_meta_box( |
74 | - $this->meta_box['id'], |
|
75 | - $this->meta_box['title'], |
|
76 | - [$this, 'show'], |
|
74 | + $this->meta_box[ 'id' ], |
|
75 | + $this->meta_box[ 'title' ], |
|
76 | + [ $this, 'show' ], |
|
77 | 77 | null, |
78 | - $this->meta_box['context'], |
|
79 | - $this->meta_box['priority'] |
|
78 | + $this->meta_box[ 'context' ], |
|
79 | + $this->meta_box[ 'priority' ] |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public function is_saved() |
95 | 95 | { |
96 | 96 | foreach( array_column( $this->fields, 'slug' ) as $field ) { |
97 | - if( !is_null( $this->pollux_caller->getMetaValue( $field, null, $this->meta_box['slug'] ))) { |
|
97 | + if( !is_null( $this->pollux_caller->getMetaValue( $field, null, $this->meta_box[ 'slug' ] ) ) ) { |
|
98 | 98 | return true; |
99 | 99 | } |
100 | 100 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public static function normalize( $metabox ) |
109 | 109 | { |
110 | - unset( $metabox['post_types'] ); |
|
111 | - return wp_parse_args( $metabox, ['slug' => ''] ); |
|
110 | + unset( $metabox[ 'post_types' ] ); |
|
111 | + return wp_parse_args( $metabox, [ 'slug' => '' ] ); |
|
112 | 112 | } |
113 | 113 | } |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - public $metaboxes = []; |
|
27 | + public $metaboxes = [ ]; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * {@inheritdoc} |
31 | 31 | */ |
32 | 32 | public function init() |
33 | 33 | { |
34 | - $this->normalize( $this->app->config[static::ID], [ |
|
35 | - 'post_types' => [], |
|
36 | - ]); |
|
34 | + $this->normalize( $this->app->config[ static::ID ], [ |
|
35 | + 'post_types' => [ ], |
|
36 | + ] ); |
|
37 | 37 | |
38 | - add_filter( 'rwmb_show', [$this, 'show'], 10, 2 ); |
|
39 | - add_filter( 'rwmb_meta_boxes', [$this, 'register'] ); |
|
40 | - add_filter( 'rwmb_outer_html', [$this, 'renderField'], 10, 2 ); |
|
38 | + add_filter( 'rwmb_show', [ $this, 'show' ], 10, 2 ); |
|
39 | + add_filter( 'rwmb_meta_boxes', [ $this, 'register' ] ); |
|
40 | + add_filter( 'rwmb_outer_html', [ $this, 'renderField' ], 10, 2 ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | return PostMeta::get( $key, [ |
72 | 72 | 'id' => $this->getPostId(), |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function register() |
81 | 81 | { |
82 | - if( current_user_can( 'switch_themes' )) { |
|
82 | + if( current_user_can( 'switch_themes' ) ) { |
|
83 | 83 | $instructions = $this->initInstructions(); |
84 | - if( is_array( $instructions )) { |
|
84 | + if( is_array( $instructions ) ) { |
|
85 | 85 | $this->normalize( $instructions ); |
86 | 86 | } |
87 | 87 | } |
88 | 88 | $metaboxes = func_num_args() |
89 | - ? ( new Helper )->toArray( func_get_arg(0) ) |
|
90 | - : []; |
|
89 | + ? ( new Helper )->toArray( func_get_arg( 0 ) ) |
|
90 | + : [ ]; |
|
91 | 91 | return array_merge( $metaboxes, $this->metaboxes ); |
92 | 92 | } |
93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function renderField( $html, $field ) |
99 | 99 | { |
100 | - return $this->validate( $field['condition'] ) |
|
100 | + return $this->validate( $field[ 'condition' ] ) |
|
101 | 101 | ? $html |
102 | 102 | : ''; |
103 | 103 | } |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | public function show( $bool, array $metabox ) |
110 | 110 | { |
111 | 111 | if( defined( 'DOING_AJAX' ) |
112 | - || !isset( $metabox['condition'] ) |
|
113 | - || !$this->hasPostType( $metabox )) { |
|
112 | + || !isset( $metabox[ 'condition' ] ) |
|
113 | + || !$this->hasPostType( $metabox ) ) { |
|
114 | 114 | return $bool; |
115 | 115 | } |
116 | - return $this->validate( $metabox['condition'] ); |
|
116 | + return $this->validate( $metabox[ 'condition' ] ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function getPostId() |
123 | 123 | { |
124 | - if( !( $postId = filter_input( INPUT_GET, 'post' ))) { |
|
124 | + if( !( $postId = filter_input( INPUT_GET, 'post' ) ) ) { |
|
125 | 125 | $postId = filter_input( INPUT_POST, 'post_ID' ); |
126 | 126 | } |
127 | 127 | return intval( $postId ); |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | { |
135 | 135 | return array_unique( iterator_to_array( |
136 | 136 | new RecursiveIteratorIterator( |
137 | - new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' )) |
|
137 | + new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) ) |
|
138 | 138 | ), |
139 | 139 | false |
140 | - )); |
|
140 | + ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -145,26 +145,26 @@ discard block |
||
145 | 145 | */ |
146 | 146 | protected function hasPostType( array $metabox ) |
147 | 147 | { |
148 | - if( !isset( $metabox['post_types'] )) { |
|
148 | + if( !isset( $metabox[ 'post_types' ] ) ) { |
|
149 | 149 | return true; |
150 | 150 | } |
151 | - return in_array( get_post_type( $this->getPostId() ), $metabox['post_types'] ); |
|
151 | + return in_array( get_post_type( $this->getPostId() ), $metabox[ 'post_types' ] ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | 155 | * @return void |
156 | 156 | */ |
157 | - protected function normalize( array $metaboxes, array $defaults = [] ) |
|
157 | + protected function normalize( array $metaboxes, array $defaults = [ ] ) |
|
158 | 158 | { |
159 | 159 | foreach( $metaboxes as $id => $metabox ) { |
160 | 160 | $data = wp_parse_args( $defaults, [ |
161 | - 'condition' => [], |
|
162 | - 'fields' => [], |
|
161 | + 'condition' => [ ], |
|
162 | + 'fields' => [ ], |
|
163 | 163 | 'id' => $id, |
164 | 164 | 'slug' => $id, |
165 | - 'validation' => [], |
|
166 | - ]); |
|
167 | - $this->metaboxes[] = $this->setDependencies( |
|
165 | + 'validation' => [ ], |
|
166 | + ] ); |
|
167 | + $this->metaboxes[ ] = $this->setDependencies( |
|
168 | 168 | $this->normalizeThis( $metabox, $data, $id ) |
169 | 169 | ); |
170 | 170 | } |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | protected function normalizeFields( array $fields, array $data, $parentId ) |
199 | 199 | { |
200 | 200 | return array_map( function( $id, $field ) use( $parentId ) { |
201 | - $defaults = [ |
|
202 | - 'attributes' => [], |
|
201 | + $defaults = [ |
|
202 | + 'attributes' => [ ], |
|
203 | 203 | 'class' => '', |
204 | - 'condition' => [], |
|
204 | + 'condition' => [ ], |
|
205 | 205 | 'depends' => '', |
206 | 206 | 'field_name' => $id, |
207 | 207 | 'id' => $id, |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | */ |
236 | 236 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
237 | 237 | { |
238 | - foreach( ['messages', 'rules'] as $key ) { |
|
239 | - if( empty( $validation[$key] ))continue; |
|
240 | - foreach( $validation[$key] as $id => $value ) { |
|
241 | - $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
|
242 | - unset( $validation[$key][$id] ); |
|
238 | + foreach( [ 'messages', 'rules' ] as $key ) { |
|
239 | + if( empty( $validation[ $key ] ) )continue; |
|
240 | + foreach( $validation[ $key ] as $id => $value ) { |
|
241 | + $validation[ $key ][ $this->normalizeFieldName( $id, [ 'slug' => $id ], $parentId ) ] = $value; |
|
242 | + unset( $validation[ $key ][ $id ] ); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | return $validation; |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function setDependencies( array $metabox ) |
252 | 252 | { |
253 | - $fields = &$metabox['fields']; |
|
253 | + $fields = &$metabox[ 'fields' ]; |
|
254 | 254 | $depends = array_column( $fields, 'depends' ); |
255 | 255 | array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
256 | - if( empty( $value ))return; |
|
257 | - $dependency = array_search( $value, array_column( $fields, 'id' )); |
|
258 | - $fields[$index]['attributes']['data-depends'] = $value; |
|
259 | - if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] )) { |
|
260 | - $fields[$index]['class'] = trim( 'hidden ' . $fields[$index]['class'] ); |
|
256 | + if( empty( $value ) )return; |
|
257 | + $dependency = array_search( $value, array_column( $fields, 'id' ) ); |
|
258 | + $fields[ $index ][ 'attributes' ][ 'data-depends' ] = $value; |
|
259 | + if( !$this->getMetaValue( $fields[ $dependency ][ 'slug' ], '', $metabox[ 'slug' ] ) ) { |
|
260 | + $fields[ $index ][ 'class' ] = trim( 'hidden ' . $fields[ $index ][ 'class' ] ); |
|
261 | 261 | } |
262 | 262 | }); |
263 | 263 | return $metabox; |