do_settings_fields

The timeline below displays how wordpress function do_settings_fields has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Prints out the settings fields for a particular settings section.
 *
 * Part of the Settings API. Use this in a settings page to output
 * a specific section. Should normally be called by do_settings_sections()
 * rather than directly.
 *
 * @global array $wp_settings_fields Storage array of settings fields and their pages/sections.
 *
 * @since 2.7.0
 *
 * @param string $page Slug title of the admin page whose settings fields you want to show.
 * @param string $section Slug title of the settings section whose fields you want to show.
 */
function do_settings_fields($page, $section)
{
    global $wp_settings_fields;
    if (!isset($wp_settings_fields[$page][$section])) {
        return;
    }
    foreach ((array) $wp_settings_fields[$page][$section] as $field) {
        $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 {
            echo '<th scope="row">' . $field['title'] . '</th>';
        }
        echo '<td>';
        call_user_func($field['callback'], $field['args']);
        echo '</td>';
        echo '</tr>';
    }
}

WordPress Version: 5.5

/**
 * Print out the settings fields for a particular settings section.
 *
 * Part of the Settings API. Use this in a settings page to output
 * a specific section. Should normally be called by do_settings_sections()
 * rather than directly.
 *
 * @global array $wp_settings_fields Storage array of settings fields and their pages/sections.
 *
 * @since 2.7.0
 *
 * @param string $page Slug title of the admin page whose settings fields you want to show.
 * @param string $section Slug title of the settings section whose fields you want to show.
 */
function do_settings_fields($page, $section)
{
    global $wp_settings_fields;
    if (!isset($wp_settings_fields[$page][$section])) {
        return;
    }
    foreach ((array) $wp_settings_fields[$page][$section] as $field) {
        $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 {
            echo '<th scope="row">' . $field['title'] . '</th>';
        }
        echo '<td>';
        call_user_func($field['callback'], $field['args']);
        echo '</td>';
        echo '</tr>';
    }
}

WordPress Version: 5.1

/**
 * Print out the settings fields for a particular settings section.
 *
 * Part of the Settings API. Use this in a settings page to output
 * a specific section. Should normally be called by do_settings_sections()
 * rather than directly.
 *
 * @global $wp_settings_fields Storage array of settings fields and their pages/sections.
 *
 * @since 2.7.0
 *
 * @param string $page Slug title of the admin page whose settings fields you want to show.
 * @param string $section Slug title of the settings section whose fields you want to show.
 */
function do_settings_fields($page, $section)
{
    global $wp_settings_fields;
    if (!isset($wp_settings_fields[$page][$section])) {
        return;
    }
    foreach ((array) $wp_settings_fields[$page][$section] as $field) {
        $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 {
            echo '<th scope="row">' . $field['title'] . '</th>';
        }
        echo '<td>';
        call_user_func($field['callback'], $field['args']);
        echo '</td>';
        echo '</tr>';
    }
}

WordPress Version: 4.2

/**
 * Print out the settings fields for a particular settings section
 *
 * Part of the Settings API. Use this in a settings page to output
 * a specific section. Should normally be called by do_settings_sections()
 * rather than directly.
 *
 * @global $wp_settings_fields Storage array of settings fields and their pages/sections
 *
 * @since 2.7.0
 *
 * @param string $page Slug title of the admin page who's settings fields you want to show.
 * @param string $section Slug title of the settings section who's fields you want to show.
 */
function do_settings_fields($page, $section)
{
    global $wp_settings_fields;
    if (!isset($wp_settings_fields[$page][$section])) {
        return;
    }
    foreach ((array) $wp_settings_fields[$page][$section] as $field) {
        $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 {
            echo '<th scope="row">' . $field['title'] . '</th>';
        }
        echo '<td>';
        call_user_func($field['callback'], $field['args']);
        echo '</td>';
        echo '</tr>';
    }
}

WordPress Version: 4.1

/**
 * Print out the settings fields for a particular settings section
 *
 * Part of the Settings API. Use this in a settings page to output
 * a specific section. Should normally be called by do_settings_sections()
 * rather than directly.
 *
 * @global $wp_settings_fields Storage array of settings fields and their pages/sections
 *
 * @since 2.7.0
 *
 * @param string $page Slug title of the admin page who's settings fields you want to show.
 * @param string $section Slug title of the settings section who's fields you want to show.
 */
function do_settings_fields($page, $section)
{
    global $wp_settings_fields;
    if (!isset($wp_settings_fields[$page][$section])) {
        return;
    }
    foreach ((array) $wp_settings_fields[$page][$section] as $field) {
        echo '<tr>';
        if (!empty($field['args']['label_for'])) {
            echo '<th scope="row"><label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . '</label></th>';
        } else {
            echo '<th scope="row">' . $field['title'] . '</th>';
        }
        echo '<td>';
        call_user_func($field['callback'], $field['args']);
        echo '</td>';
        echo '</tr>';
    }
}

WordPress Version: 3.9

/**
 * Print out the settings fields for a particular settings section
 *
 * Part of the Settings API. Use this in a settings page to output
 * a specific section. Should normally be called by do_settings_sections()
 * rather than directly.
 *
 * @global $wp_settings_fields Storage array of settings fields and their pages/sections
 *
 * @since 2.7.0
 *
 * @param string $page Slug title of the admin page who's settings fields you want to show.
 * @param section $section Slug title of the settings section who's fields you want to show.
 */
function do_settings_fields($page, $section)
{
    global $wp_settings_fields;
    if (!isset($wp_settings_fields[$page][$section])) {
        return;
    }
    foreach ((array) $wp_settings_fields[$page][$section] as $field) {
        echo '<tr>';
        if (!empty($field['args']['label_for'])) {
            echo '<th scope="row"><label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . '</label></th>';
        } else {
            echo '<th scope="row">' . $field['title'] . '</th>';
        }
        echo '<td>';
        call_user_func($field['callback'], $field['args']);
        echo '</td>';
        echo '</tr>';
    }
}

WordPress Version: 3.7

/**
 * Print out the settings fields for a particular settings section
 *
 * Part of the Settings API. Use this in a settings page to output
 * a specific section. Should normally be called by do_settings_sections()
 * rather than directly.
 *
 * @global $wp_settings_fields Storage array of settings fields and their pages/sections
 *
 * @since 2.7.0
 *
 * @param string $page Slug title of the admin page who's settings fields you want to show.
 * @param section $section Slug title of the settings section who's fields you want to show.
 */
function do_settings_fields($page, $section)
{
    global $wp_settings_fields;
    if (!isset($wp_settings_fields[$page][$section])) {
        return;
    }
    foreach ((array) $wp_settings_fields[$page][$section] as $field) {
        echo '<tr valign="top">';
        if (!empty($field['args']['label_for'])) {
            echo '<th scope="row"><label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . '</label></th>';
        } else {
            echo '<th scope="row">' . $field['title'] . '</th>';
        }
        echo '<td>';
        call_user_func($field['callback'], $field['args']);
        echo '</td>';
        echo '</tr>';
    }
}