Make WordPress Core

Changeset 31560


Ignore:
Timestamp:
02/26/2015 07:58:50 PM (10 years ago)
Author:
helen
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/template.php

    r31551 r31560  
    12901290
    12911291    foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
    1292         echo '<tr>';
    1293         if ( !empty($field['args']['label_for']) )
     1292        $class = '';
     1293
     1294        if ( ! empty( $field['args']['class'] ) ) {
     1295            $class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
     1296        }
     1297
     1298        echo "<tr{$class}>";
     1299
     1300        if ( ! empty( $field['args']['label_for'] ) ) {
    12941301            echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
    1295         else
     1302        } else {
    12961303            echo '<th scope="row">' . $field['title'] . '</th>';
     1304        }
     1305
    12971306        echo '<td>';
    12981307        call_user_func($field['callback'], $field['args']);
Note: See TracChangeset for help on using the changeset viewer.