On this page
add_allowed_options( array $new_options, string|array $options = '' ): array
Adds an array of options to the list of allowed options.
Parameters
$new_optionsarray Required$optionsstring|array Optional-
Default:
''
Return
array
Source
File: wp-admin/includes/plugin.php. View all references
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;
}
Related
Used By
| Used By | Description |
|---|---|
| option_update_filter() wp-admin/includes/plugin.php | Refreshes the value of the allowed options list available via the ‘allowed_options’ hook. |
| add_option_whitelist() wp-includes/deprecated.php | Adds an array of options to the list of allowed options. |
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/add_allowed_options