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:
Helen Hou-Sandi 2015-02-26 19:58:50 +00:00
parent 01eb7466ae
commit 195dabc136
1 changed files with 12 additions and 3 deletions

View File

@ -1289,11 +1289,20 @@ function do_settings_fields($page, $section) {
return;
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
echo '<tr>';
if ( !empty($field['args']['label_for']) )
$class = '';
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>';
else
} else {
echo '<th scope="row">' . $field['title'] . '</th>';
}
echo '<td>';
call_user_func($field['callback'], $field['args']);
echo '</td>';