wp_protect_special_option() WordPress Function

The wp_protect_special_option() function protects a special option from being modified by unauthorized users. Special options are options that are not meant to be modified by users, such as the WordPress core version number. This function is typically used by plugin and theme developers to prevent their code from being broken by unauthorized changes to special options.

wp_protect_special_option( string $option ) #

Protects WordPress special option from being modified.


Description

Will die if $option is in protected list. Protected options are ‘alloptions’ and ‘notoptions’ options.


Top ↑

Parameters

$option

(string)(Required)Option name.


Top ↑

Source

File: wp-includes/option.php

function wp_protect_special_option( $option ) {
	if ( 'alloptions' === $option || 'notoptions' === $option ) {
		wp_die(
			sprintf(
				/* translators: %s: Option name. */
				__( '%s is a protected WP option and may not be modified' ),
				esc_html( $option )
			)
		);
	}
}


Top ↑

Changelog

Changelog
VersionDescription
2.2.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.

Show More