Skip to content

Commit f4d590a

Browse files
committed
Add label_for arg for fields
With this the Settings API will add the "for" attribute for labels. With this clicking a label will focus on the relevant input. This behavior is used across Wordpress options pages. Signed-off-by: Roi Dayan <[email protected]>
1 parent 52f96ac commit f4d590a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/class.settings-api.php

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function admin_init() {
130130

131131
$args = array(
132132
'id' => $option['name'],
133+
'label_for' => $args['label_for'] = "{$section}[{$option['name']}]",
133134
'desc' => isset( $option['desc'] ) ? $option['desc'] : '',
134135
'name' => $option['label'],
135136
'section' => $section,
@@ -139,6 +140,7 @@ function admin_init() {
139140
'sanitize_callback' => isset( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : '',
140141
'type' => $type,
141142
);
143+
142144
add_settings_field( $section . '[' . $option['name'] . ']', $option['label'], array( $this, 'callback_' . $type ), $section, $section, $args );
143145
}
144146
}

0 commit comments

Comments
 (0)