WP_Screen::add_option() WordPress Method

The WP_Screen::add_option() method is used to add an option to a WP_Screen object. The option can be either a string or an array. If the option is a string, it will be added as a new option with the value of true. If the option is an array, the array will be merged with the existing options.

WP_Screen::add_option( string $option, mixed $args = array() ) #

Adds an option for the screen.


Description

Call this in template files after admin.php is loaded and before admin-header.php is loaded to add screen options.


Top ↑

Parameters

$option

(string)(Required)Option ID.

$args

(mixed)(Optional)Option-dependent arguments.

Default value: array()


Top ↑

Source

File: wp-admin/includes/class-wp-screen.php

	public function add_option( $option, $args = array() ) {
		$this->_options[ $option ] = $args;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.