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.

Built from https://develop.svn.wordpress.org/trunk@31560


git-svn-id: http://core.svn.wordpress.org/trunk@31541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2015-02-26 19:59:25 +00:00
parent a226da32d3
commit b95d99d1c1
2 changed files with 13 additions and 4 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>';

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31559';
$wp_version = '4.2-alpha-31560';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.