add_allowed_options() WordPress Function

The add_allowed_options() function is used to add additional allowed options to an option group. This is useful for plugins and themes that want to add new options to an existing option group.

add_allowed_options( array $new_options, string|array $options = '' ) #

Adds an array of options to the list of allowed options.


Parameters

$new_options

(array)(Required)

$options

(string|array)(Optional)

Default value: ''


Top ↑

Return

(array)


Top ↑

Source

File: wp-admin/includes/plugin.php

function add_allowed_options( $new_options, $options = '' ) {
	if ( '' === $options ) {
		global $allowed_options;
	} else {
		$allowed_options = $options;
	}

	foreach ( $new_options as $page => $keys ) {
		foreach ( $keys as $key ) {
			if ( ! isset( $allowed_options[ $page ] ) || ! is_array( $allowed_options[ $page ] ) ) {
				$allowed_options[ $page ]   = array();
				$allowed_options[ $page ][] = $key;
			} else {
				$pos = array_search( $key, $allowed_options[ $page ], true );
				if ( false === $pos ) {
					$allowed_options[ $page ][] = $key;
				}
			}
		}
	}

	return $allowed_options;
}


Top ↑

Changelog

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