Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



add_settings_section ›

Seit2.7.0
Veraltetn/v
add_settings_section ( $id, $title, $callback, $page )
Parameter: (4)
  • (string) $id Slug-name to identify the section. Used in the 'id' attribute of tags.
    Erforderlich: Ja
  • (string) $title Formatted title of the section. Shown as the heading for the section.
    Erforderlich: Ja
  • (callable) $callback Function that echos out any content at the top of the section (between heading and fields).
    Erforderlich: Ja
  • (string) $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page();
    Erforderlich: Ja
Definiert in:
Codex:

Add a new section to a settings page.

Part of the Settings API. Use this to define new settings sections for an admin page. Show settings sections in your admin page callback function with do_settings_sections(). Add settings fields to your section with add_settings_field()

The $callback argument should be the name of a function that echoes out any content you want to show at the top of the settings section before the actual fields. It can output nothing if you want.



Quellcode

function add_settings_section($id, $title, $callback, $page) {
	global $wp_settings_sections;

	if ( 'misc' == $page ) {
		_deprecated_argument( __FUNCTION__, '3.0.0',
			/* translators: %s: misc */
			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
				'misc'
			)
		);
		$page = 'general';
	}

	if ( 'privacy' == $page ) {
		_deprecated_argument( __FUNCTION__, '3.5.0',
			/* translators: %s: privacy */
			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
				'privacy'
			)
		);
		$page = 'reading';
	}

	$wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}