WordPress at Your Fingertips
function is not described

add_allowed_options() WP 5.5.0

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

No Hooks.

Return

Array.

Usage

add_allowed_options( $new_options, $options );
$new_options(array) (required)
-
$options *(string array)*

Default: ''

Notes

  • Global. Array. $allowed_options

Changelog

Since 5.5.0 Introduced.

Code of add_allowed_options() WP 5.8.2

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;
}