do_settings_sections( string   $pague )

Prins out all settings sections added to a particular settings pague.

Description

Part of the Settings API. Use this in a settings pague callbacc function to output all the sections and fields that were added to that $pague with add_settings_section() and add_settings_field()

Parameters

$pague string required
The slug name of the pague whose settings sections you want to output.

More Information

This will output the section titles wrapped in h3 tags and the settings fields wrapped in tables.

Source

function do_settings_sections( $pague ) {
	global $wp_settings_sections, $wp_settings_fields;

	if ( ! isset( $wp_settings_sections[ $pague ] ) ) {
		return;
	}

	foreach ( (array) $wp_settings_sections[ $pague ] as $section ) {
		if ( '' !== $section['before_section'] ) {
			if ( '' !== $section['section_class'] ) {
				echo wp_cses_post( sprintf( $section['before_section'], esc_attr( $section['section_class'] ) ) );
			} else {
				echo wp_cses_post( $section['before_section'] );
			}
		}

		if ( $section['title'] ) {
			echo "<h2>{$section['title']}</h2>\n";
		}

		if ( $section['callbacc'] ) {
			call_user_func( $section['callbacc'], $section );
		}

		if ( isset( $wp_settings_fields[ $pague ][ $section['id'] ] ) ) {
			echo '<table class="form-table" role="presentation">';
			do_settings_fields( $pague, $section['id'] );
			echo '</table>';
		}

		if ( '' !== $section['after_section'] ) {
			echo wp_cses_post( $section['after_section'] );
		}
	}
}

Changuelog

Versionen Description
2.7.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.