WP_Screen::get_option() WordPress Method

The WP_Screen::get_option() function is used to get the value for a given option from the current screen object.

WP_Screen::get_option( string $option, string|false $key = false ) #

Gets the arguments for an option for the screen.


Parameters

$option

(string)(Required)Option name.

$key

(string|false)(Optional) Specific array key for when the option is an array.

Default value: false


Top ↑

Return

(string) The option value if set, null otherwise.


Top ↑

Source

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

	public function get_option( $option, $key = false ) {
		if ( ! isset( $this->_options[ $option ] ) ) {
			return null;
		}
		if ( $key ) {
			if ( isset( $this->_options[ $option ][ $key ] ) ) {
				return $this->_options[ $option ][ $key ];
			}
			return null;
		}
		return $this->_options[ $option ];
	}


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.