Skip to content

Commit 719c456

Browse files
committed
#3957 - Validation routines for metaboxes not completely working.
1 parent 4a88059 commit 719c456

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

redux-core/inc/classes/class-redux-validation.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function validate( array $plugin_options, array $options, array $sections
3535
foreach ( $sections as $k => $section ) {
3636
if ( isset( $section['fields'] ) ) {
3737
foreach ( $section['fields'] as $fkey => $field ) {
38-
3938
if ( is_array( $field ) ) {
4039
$field['section_id'] = $k;
4140
}
@@ -220,20 +219,22 @@ public function validate( array $plugin_options, array $options, array $sections
220219
$plugin_option = $plugin_options[ $field['id'] ] ?? null;
221220
$option = $options[ $field['id'] ] ?? null;
222221

223-
$callbackvalues = call_user_func( $callback, $field, $plugin_option, $option );
222+
if ( null !== $plugin_option ) {
223+
$callbackvalues = call_user_func( $callback, $field, $plugin_option, $option );
224224

225-
$plugin_options[ $field['id'] ] = $callbackvalues['value'];
225+
$plugin_options[ $field['id'] ] = $callbackvalues['value'];
226226

227-
if ( isset( $callbackvalues['error'] ) ) {
228-
$core->errors[] = $callbackvalues['error'];
229-
}
227+
if ( isset( $callbackvalues['error'] ) ) {
228+
$core->errors[] = $callbackvalues['error'];
229+
}
230230

231-
if ( isset( $callbackvalues['warning'] ) ) {
232-
$core->warnings[] = $callbackvalues['warning'];
233-
}
231+
if ( isset( $callbackvalues['warning'] ) ) {
232+
$core->warnings[] = $callbackvalues['warning'];
233+
}
234234

235-
if ( isset( $callbackvalues['sanitize'] ) ) {
236-
$core->sanitize[] = $callbackvalues['sanitize'];
235+
if ( isset( $callbackvalues['sanitize'] ) ) {
236+
$core->sanitize[] = $callbackvalues['sanitize'];
237+
}
237238
}
238239
}
239240
}

redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function init() {
276276

277277
foreach ( $this->boxes as $bk => $box ) {
278278

279-
// If the post ids for this box are set, we're limiting to the current post id.
279+
// If the post-ids for this box are set, we're limiting to the current post id.
280280
if ( ! empty( $box['post_ids'] ) ) {
281281
if ( ! is_array( $box['post_ids'] ) ) {
282282
$box['post_ids'] = array( $box['post_ids'] );
@@ -287,7 +287,7 @@ public function init() {
287287
}
288288

289289
if ( ! empty( $box['sections'] ) ) {
290-
$this->sections = $box['sections'];
290+
$this->sections = wp_parse_args( $this->sections, $box['sections'] );
291291

292292
$this->post_types = wp_parse_args( $this->post_types, $box['post_types'] );
293293

0 commit comments

Comments
 (0)