do_settings_sections

The timeline below displays how wordpress function do_settings_sections 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 all settings sections added to a particular settings page.
 *
 * Part of the Settings API. Use this in a settings page callback function
 * to output all the sections and fields that were added to that $page with
 * add_settings_section() and add_settings_field()
 *
 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages.
 * @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections.
 * @since 2.7.0
 *
 * @param string $page The slug name of the page whose settings sections you want to output.
 */
function do_settings_sections($page)
{
    global $wp_settings_sections, $wp_settings_fields;
    if (!isset($wp_settings_sections[$page])) {
        return;
    }
    foreach ((array) $wp_settings_sections[$page] as $section) {
        if ('' !== $section['before_section']) {
            if ('' !== $section['section_class']) {
                echo wp_kses_post(sprintf($section['before_section'], esc_attr($section['section_class'])));
            } else {
                echo wp_kses_post($section['before_section']);
            }
        }
        if ($section['title']) {
            echo "<h2>{$section['title']}</h2>\n";
        }
        if ($section['callback']) {
            call_user_func($section['callback'], $section);
        }
        if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) {
            continue;
        }
        echo '<table class="form-table" role="presentation">';
        do_settings_fields($page, $section['id']);
        echo '</table>';
        if ('' !== $section['after_section']) {
            echo wp_kses_post($section['after_section']);
        }
    }
}

WordPress Version: 5.5

/**
 * Prints out all settings sections added to a particular settings page
 *
 * Part of the Settings API. Use this in a settings page callback function
 * to output all the sections and fields that were added to that $page with
 * add_settings_section() and add_settings_field()
 *
 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages.
 * @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections.
 * @since 2.7.0
 *
 * @param string $page The slug name of the page whose settings sections you want to output.
 */
function do_settings_sections($page)
{
    global $wp_settings_sections, $wp_settings_fields;
    if (!isset($wp_settings_sections[$page])) {
        return;
    }
    foreach ((array) $wp_settings_sections[$page] as $section) {
        if ($section['title']) {
            echo "<h2>{$section['title']}</h2>\n";
        }
        if ($section['callback']) {
            call_user_func($section['callback'], $section);
        }
        if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) {
            continue;
        }
        echo '<table class="form-table" role="presentation">';
        do_settings_fields($page, $section['id']);
        echo '</table>';
    }
}

WordPress Version: .20

/**
 * Prints out all settings sections added to a particular settings page
 *
 * Part of the Settings API. Use this in a settings page callback function
 * to output all the sections and fields that were added to that $page with
 * add_settings_section() and add_settings_field()
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
 * @since 2.7.0
 *
 * @param string $page The slug name of the page whose settings sections you want to output.
 */
function do_settings_sections($page)
{
    global $wp_settings_sections, $wp_settings_fields;
    if (!isset($wp_settings_sections[$page])) {
        return;
    }
    foreach ((array) $wp_settings_sections[$page] as $section) {
        if ($section['title']) {
            echo "<h2>{$section['title']}</h2>\n";
        }
        if ($section['callback']) {
            call_user_func($section['callback'], $section);
        }
        if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) {
            continue;
        }
        echo '<table class="form-table" role="presentation">';
        do_settings_fields($page, $section['id']);
        echo '</table>';
    }
}

WordPress Version: 2.2

/**
 * Prints out all settings sections added to a particular settings page
 *
 * Part of the Settings API. Use this in a settings page callback function
 * to output all the sections and fields that were added to that $page with
 * add_settings_section() and add_settings_field()
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
 * @since 2.7.0
 *
 * @param string $page The slug name of the page whose settings sections you want to output.
 */
function do_settings_sections($page)
{
    global $wp_settings_sections, $wp_settings_fields;
    if (!isset($wp_settings_sections[$page])) {
        return;
    }
    foreach ((array) $wp_settings_sections[$page] as $section) {
        if ($section['title']) {
            echo "<h2>{$section['title']}</h2>\n";
        }
        if ($section['callback']) {
            call_user_func($section['callback'], $section);
        }
        if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) {
            continue;
        }
        echo '<table class="form-table">';
        do_settings_fields($page, $section['id']);
        echo '</table>';
    }
}

WordPress Version: .10

/**
 * Prints out all settings sections added to a particular settings page
 *
 * Part of the Settings API. Use this in a settings page callback function
 * to output all the sections and fields that were added to that $page with
 * add_settings_section() and add_settings_field()
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
 * @since 2.7.0
 *
 * @param string $page The slug name of the page whose settings sections you want to output.
 */
function do_settings_sections($page)
{
    global $wp_settings_sections, $wp_settings_fields;
    if (!isset($wp_settings_sections[$page])) {
        return;
    }
    foreach ((array) $wp_settings_sections[$page] as $section) {
        if ($section['title']) {
            echo "<h2>{$section['title']}</h2>\n";
        }
        if ($section['callback']) {
            call_user_func($section['callback'], $section);
        }
        if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) {
            continue;
        }
        echo '<table class="form-table" role="presentation">';
        do_settings_fields($page, $section['id']);
        echo '</table>';
    }
}

WordPress Version: 5.1

/**
 * Prints out all settings sections added to a particular settings page
 *
 * Part of the Settings API. Use this in a settings page callback function
 * to output all the sections and fields that were added to that $page with
 * add_settings_section() and add_settings_field()
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
 * @since 2.7.0
 *
 * @param string $page The slug name of the page whose settings sections you want to output.
 */
function do_settings_sections($page)
{
    global $wp_settings_sections, $wp_settings_fields;
    if (!isset($wp_settings_sections[$page])) {
        return;
    }
    foreach ((array) $wp_settings_sections[$page] as $section) {
        if ($section['title']) {
            echo "<h2>{$section['title']}</h2>\n";
        }
        if ($section['callback']) {
            call_user_func($section['callback'], $section);
        }
        if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) {
            continue;
        }
        echo '<table class="form-table">';
        do_settings_fields($page, $section['id']);
        echo '</table>';
    }
}

WordPress Version: 4.4

/**
 * Prints out all settings sections added to a particular settings page
 *
 * Part of the Settings API. Use this in a settings page callback function
 * to output all the sections and fields that were added to that $page with
 * add_settings_section() and add_settings_field()
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
 * @since 2.7.0
 *
 * @param string $page The slug name of the page whose settings sections you want to output
 */
function do_settings_sections($page)
{
    global $wp_settings_sections, $wp_settings_fields;
    if (!isset($wp_settings_sections[$page])) {
        return;
    }
    foreach ((array) $wp_settings_sections[$page] as $section) {
        if ($section['title']) {
            echo "<h2>{$section['title']}</h2>\n";
        }
        if ($section['callback']) {
            call_user_func($section['callback'], $section);
        }
        if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) {
            continue;
        }
        echo '<table class="form-table">';
        do_settings_fields($page, $section['id']);
        echo '</table>';
    }
}

WordPress Version: 3.7

/**
 * Prints out all settings sections added to a particular settings page
 *
 * Part of the Settings API. Use this in a settings page callback function
 * to output all the sections and fields that were added to that $page with
 * add_settings_section() and add_settings_field()
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
 * @since 2.7.0
 *
 * @param string $page The slug name of the page whos settings sections you want to output
 */
function do_settings_sections($page)
{
    global $wp_settings_sections, $wp_settings_fields;
    if (!isset($wp_settings_sections[$page])) {
        return;
    }
    foreach ((array) $wp_settings_sections[$page] as $section) {
        if ($section['title']) {
            echo "<h3>{$section['title']}</h3>\n";
        }
        if ($section['callback']) {
            call_user_func($section['callback'], $section);
        }
        if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) {
            continue;
        }
        echo '<table class="form-table">';
        do_settings_fields($page, $section['id']);
        echo '</table>';
    }
}