Skip to content

Commit dc3f750

Browse files
authored
Check if label is set
It's better to check if $option['label'] is set since we are not using the label in HTML field.
1 parent 88d5964 commit dc3f750

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/class.settings-api.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ function admin_init() {
120120
foreach ( $field as $option ) {
121121

122122
$type = isset( $option['type'] ) ? $option['type'] : 'text';
123+
$label = isset( $option['label'] ) ? $option['label'] : '';
123124

124125
$args = array(
125126
'id' => $option['name'],
126127
'label_for' => $args['label_for'] = "{$section}[{$option['name']}]",
127128
'desc' => isset( $option['desc'] ) ? $option['desc'] : '',
128-
'name' => $option['label'],
129+
'name' => $label,
129130
'section' => $section,
130131
'size' => isset( $option['size'] ) ? $option['size'] : null,
131132
'options' => isset( $option['options'] ) ? $option['options'] : '',
@@ -138,7 +139,7 @@ function admin_init() {
138139
'step' => isset( $option['step'] ) ? $option['step'] : '',
139140
);
140141

141-
add_settings_field( $section . '[' . $option['name'] . ']', $option['label'], (isset($option['callback']) ? $option['callback'] : array($this, 'callback_' . $type )), $section, $section, $args );
142+
add_settings_field( $section . '[' . $option['name'] . ']', $label, (isset($option['callback']) ? $option['callback'] : array($this, 'callback_' . $type )), $section, $section, $args );
142143
}
143144
}
144145

0 commit comments

Comments
 (0)