From 195dabc136e1a64b3935c96b28bcd49005f7e861 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 26 Feb 2015 19:58:50 +0000 Subject: [PATCH] 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 --- src/wp-admin/includes/template.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 0c5658cc0e..be58e75866 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -1289,11 +1289,20 @@ function do_settings_fields($page, $section) { return; foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { - echo ''; - if ( !empty($field['args']['label_for']) ) + $class = ''; + + if ( ! empty( $field['args']['class'] ) ) { + $class = ' class="' . esc_attr( $field['args']['class'] ) . '"'; + } + + echo ""; + + if ( ! empty( $field['args']['label_for'] ) ) { echo ''; - else + } else { echo '' . $field['title'] . ''; + } + echo ''; call_user_func($field['callback'], $field['args']); echo '';