add_blog_option

Definition:
function add_blog_option( $id, $key, $value ) {}

Add an option for a particular blog.

Parameters

  • int $id: The blog id
  • string $key: The option key
  • mixed $value: The option value

Return values

returns:True on success, false on failure.

Source code

function add_blog_option( $id, $key, $value ) {

	$id = (int) $id;



	switch_to_blog($id);

	$return = add_option( $key, $value );

	restore_current_blog();

	if ( $return )

		wp_cache_set( $id . '-' . $key . '-blog_option', $value, 'site-options' );

	return $return;

}

339

activate_sitewide_plugin

Definition:
function activate_sitewide_plugin() {}

Source code

function activate_sitewide_plugin() {

	_deprecated_function(__FUNCTION__, '3.0', 'activate_plugin()' );

	return false;

}

337

add_settings_section

Definition:
function add_settings_section($id, $title, $callback, $page) {}

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()

Parameters

  • string $id: Slug-name to identify the section. Used in the ‘id’ attribute of tags.
  • string $title: Formatted title of the section. Shown as the heading for the section.
  • string $callback: Function that echos out any content at the top of the section (between heading and fields).
  • 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();

Source code

function add_settings_section($id, $title, $callback, $page) {

	global $wp_settings_sections;



	if ( 'misc' == $page ) {

		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );

		$page = 'general';

	}



	if ( !isset($wp_settings_sections) )

		$wp_settings_sections = array();

	if ( !isset($wp_settings_sections[$page]) )

		$wp_settings_sections[$page] = array();

	if ( !isset($wp_settings_sections[$page][$id]) )

		$wp_settings_sections[$page][$id] = array();



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

}

301

add_settings_field

Definition:
function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array() {}

Add a new field to a section of a settings page
Part of the Settings API. Use this to define a settings field that will show as part of a settings section inside a settings page. The fields are shown using do_settings_fields() in do_settings-sections()

Parameters

  • string $id: Slug-name to identify the field. Used in the ‘id’ attribute of tags.
  • string $title: Formatted title of the field. Shown as the label for the field during output.
  • string $callback: Function that fills the field with the desired form inputs. The function should echo its output.
  • string $page: The slug-name of the settings page on which to show the section (general, reading, writing, …).
  • string $section: The slug-name of the section of the settings page in which to show the box (default, …).
  • array $args: Additional arguments

Source code

function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {

	global $wp_settings_fields;



	if ( 'misc' == $page ) {

		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );

		$page = 'general';

	}



	if ( !isset($wp_settings_fields) )

		$wp_settings_fields = array();

	if ( !isset($wp_settings_fields[$page]) )

		$wp_settings_fields[$page] = array();

	if ( !isset($wp_settings_fields[$page][$section]) )

		$wp_settings_fields[$page][$section] = array();



	$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);

}

299

add_settings_error

Definition:
function add_settings_error( $setting, $code, $message, $type = 'error' ) {}

Register a settings error to be displayed to the user
Part of the Settings API. Use this to show messages to users about settings validation problems, missing settings or anything else.

Parameters

  • string $setting: Slug title of the setting to which this error applies
  • string $code: Slug-name to identify the error. Used as part of ‘id’ attribute in HTML output.
  • string $message: The formatted message text to display to the user (will be shown inside styled <div> and <p>)
  • string $type: The type of message it is, controls HTML class. Use ‘error’ or ‘updated’.

Source code

function add_settings_error( $setting, $code, $message, $type = 'error' ) {

	global $wp_settings_errors;



	if ( !isset($wp_settings_errors) )

		$wp_settings_errors = array();



	$new_error = array(

		'setting' => $setting,

		'code' => $code,

		'message' => $message,

		'type' => $type

	);

	$wp_settings_errors[] = $new_error;

}

297