Settings API: Allow passing a class to add_settings_field()
via the $args
array.
While it's possible to target the wrapper element otherwise (currently a `tr`), this deficiency is made especially noticeable when custom code cannot take advantage of what core is doing, such as with avatars in #30168. props valendesigns. fixes #28975. see #30168. git-svn-id: https://develop.svn.wordpress.org/trunk@31560 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
01eb7466ae
commit
195dabc136
@ -1289,11 +1289,20 @@ function do_settings_fields($page, $section) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
|
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
|
||||||
echo '<tr>';
|
$class = '';
|
||||||
if ( !empty($field['args']['label_for']) )
|
|
||||||
|
if ( ! empty( $field['args']['class'] ) ) {
|
||||||
|
$class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<tr{$class}>";
|
||||||
|
|
||||||
|
if ( ! empty( $field['args']['label_for'] ) ) {
|
||||||
echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
|
echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
|
||||||
else
|
} else {
|
||||||
echo '<th scope="row">' . $field['title'] . '</th>';
|
echo '<th scope="row">' . $field['title'] . '</th>';
|
||||||
|
}
|
||||||
|
|
||||||
echo '<td>';
|
echo '<td>';
|
||||||
call_user_func($field['callback'], $field['args']);
|
call_user_func($field['callback'], $field['args']);
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
|
Loading…
Reference in New Issue
Block a user