Skip to content

Commit 1a4b29d

Browse files
committed
tabbed and repeater fields not resetting when using Section Reset
1 parent ea4664b commit 1a4b29d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

redux-core/inc/classes/class-redux-options-defaults.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ public function default_values( string $opt_name = '', array $sections = array()
8787

8888
$this->field_default_values( $opt_name, $field, $wp_data_class, false );
8989

90+
if ( 'tabbed' === $field['type'] ) {
91+
if ( ! empty( $field['tabs'] ) ) {
92+
foreach ( $field['tabs'] as $val ) {
93+
if ( ! empty( $val['fields'] ) ) {
94+
foreach ( $val['fields'] as $f ) {
95+
$this->field_default_values( $opt_name, $f, $wp_data_class, false, true );
96+
}
97+
}
98+
}
99+
}
100+
}
101+
90102
if ( 'repeater' === $field['type'] ) {
91103
if ( ! empty( $field['fields'] ) ) {
92104
foreach ( $field['fields'] as $f ) {
@@ -109,8 +121,9 @@ public function default_values( string $opt_name = '', array $sections = array()
109121
* @param array $field Field array.
110122
* @param null $wp_data_class WordPress data class.
111123
* @param bool $is_repeater Is a repeater field.
124+
* @param bool $is_tabbed Is a tabbed field.
112125
*/
113-
public function field_default_values( string $opt_name = '', array $field = array(), $wp_data_class = null, bool $is_repeater = false ) {
126+
public function field_default_values( string $opt_name = '', array $field = array(), $wp_data_class = null, bool $is_repeater = false, $is_tabbed = false ) {
114127
if ( 'repeater' === $field['type'] ) {
115128
if ( isset( $field['group_values'] ) && true === $field['group_values'] ) {
116129
$this->is_repeater_group = true;
@@ -139,6 +152,8 @@ public function field_default_values( string $opt_name = '', array $field = arra
139152
} else {
140153
$this->options_defaults[ $field['id'] ] = array( $def );
141154
}
155+
} elseif ( true === $is_tabbed ) {
156+
$this->options_defaults[ $field['id'] ] = $def;
142157
} else {
143158
$this->options_defaults[ $field['id'] ] = $def;
144159
}

0 commit comments

Comments
 (0)