Skip to content

Commit 3e18002

Browse files
committed
Merge branch 'roidayan-fix_saving_empty_multicheck'
2 parents 8987165 + f20dfa8 commit 3e18002

File tree

2 files changed

+3
-110
lines changed

2 files changed

+3
-110
lines changed

example/oop-example.php

Lines changed: 2 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,12 @@ function admin_menu() {
3434
function get_settings_sections() {
3535
$sections = array(
3636
array(
37-
'id' => 'wedevs_basics',
37+
'id' => 'wedevs_basics',
3838
'title' => __( 'Basic Settings', 'wedevs' )
3939
),
4040
array(
41-
'id' => 'wedevs_advanced',
41+
'id' => 'wedevs_advanced',
4242
'title' => __( 'Advanced Settings', 'wedevs' )
43-
),
44-
array(
45-
'id' => 'wedevs_others',
46-
'title' => __( 'Other Settings', 'wpuf' )
4743
)
4844
);
4945
return $sections;
@@ -95,18 +91,6 @@ function get_settings_fields() {
9591
'no' => 'No'
9692
)
9793
),
98-
array(
99-
'name' => 'multicheck',
100-
'label' => __( 'Multile checkbox', 'wedevs' ),
101-
'desc' => __( 'Multi checkbox description', 'wedevs' ),
102-
'type' => 'multicheck',
103-
'options' => array(
104-
'one' => 'One',
105-
'two' => 'Two',
106-
'three' => 'Three',
107-
'four' => 'Four'
108-
)
109-
),
11094
array(
11195
'name' => 'selectbox',
11296
'label' => __( 'A Dropdown', 'wedevs' ),
@@ -171,97 +155,6 @@ function get_settings_fields() {
171155
'four' => 'Four'
172156
)
173157
),
174-
array(
175-
'name' => 'selectbox',
176-
'label' => __( 'A Dropdown', 'wedevs' ),
177-
'desc' => __( 'Dropdown description', 'wedevs' ),
178-
'type' => 'select',
179-
'options' => array(
180-
'yes' => 'Yes',
181-
'no' => 'No'
182-
)
183-
),
184-
array(
185-
'name' => 'password',
186-
'label' => __( 'Password', 'wedevs' ),
187-
'desc' => __( 'Password description', 'wedevs' ),
188-
'type' => 'password',
189-
'default' => ''
190-
),
191-
array(
192-
'name' => 'file',
193-
'label' => __( 'File', 'wedevs' ),
194-
'desc' => __( 'File description', 'wedevs' ),
195-
'type' => 'file',
196-
'default' => ''
197-
)
198-
),
199-
'wedevs_others' => array(
200-
array(
201-
'name' => 'text',
202-
'label' => __( 'Text Input', 'wedevs' ),
203-
'desc' => __( 'Text input description', 'wedevs' ),
204-
'type' => 'text',
205-
'default' => 'Title'
206-
),
207-
array(
208-
'name' => 'textarea',
209-
'label' => __( 'Textarea Input', 'wedevs' ),
210-
'desc' => __( 'Textarea description', 'wedevs' ),
211-
'type' => 'textarea'
212-
),
213-
array(
214-
'name' => 'checkbox',
215-
'label' => __( 'Checkbox', 'wedevs' ),
216-
'desc' => __( 'Checkbox Label', 'wedevs' ),
217-
'type' => 'checkbox'
218-
),
219-
array(
220-
'name' => 'radio',
221-
'label' => __( 'Radio Button', 'wedevs' ),
222-
'desc' => __( 'A radio button', 'wedevs' ),
223-
'type' => 'radio',
224-
'options' => array(
225-
'yes' => 'Yes',
226-
'no' => 'No'
227-
)
228-
),
229-
array(
230-
'name' => 'multicheck',
231-
'label' => __( 'Multile checkbox', 'wedevs' ),
232-
'desc' => __( 'Multi checkbox description', 'wedevs' ),
233-
'type' => 'multicheck',
234-
'options' => array(
235-
'one' => 'One',
236-
'two' => 'Two',
237-
'three' => 'Three',
238-
'four' => 'Four'
239-
)
240-
),
241-
array(
242-
'name' => 'selectbox',
243-
'label' => __( 'A Dropdown', 'wedevs' ),
244-
'desc' => __( 'Dropdown description', 'wedevs' ),
245-
'type' => 'select',
246-
'options' => array(
247-
'yes' => 'Yes',
248-
'no' => 'No'
249-
)
250-
),
251-
array(
252-
'name' => 'password',
253-
'label' => __( 'Password', 'wedevs' ),
254-
'desc' => __( 'Password description', 'wedevs' ),
255-
'type' => 'password',
256-
'default' => ''
257-
),
258-
array(
259-
'name' => 'file',
260-
'label' => __( 'File', 'wedevs' ),
261-
'desc' => __( 'File description', 'wedevs' ),
262-
'type' => 'file',
263-
'default' => ''
264-
)
265158
)
266159
);
267160

src/class.settings-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function callback_multicheck( $args ) {
222222

223223
$value = $this->get_option( $args['id'], $args['section'], $args['std'] );
224224
$html = '<fieldset>';
225-
225+
$html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="" />', $args['section'], $args['id'] );
226226
foreach ( $args['options'] as $key => $label ) {
227227
$checked = isset( $value[$key] ) ? $value[$key] : '0';
228228
$html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );

0 commit comments

Comments
 (0)