remove_allowed_options() WordPress Function

The remove_allowed_options() function is used to remove allowed options for a particular option type. This is useful for removing options that are no longer needed or allowed.

remove_allowed_options( array $del_options, string|array $options = '' ) #

Removes a list of options from the allowed options list.


Parameters

$del_options

(array)(Required)

$options

(string|array)(Optional)

Default value: ''


Top ↑

Return

(array)


Top ↑

Source

File: wp-admin/includes/plugin.php

2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
function remove_allowed_options( $del_options, $options = '' ) {
    if ( '' === $options ) {
        global $allowed_options;
    } else {
        $allowed_options = $options;
    }
 
    foreach ( $del_options as $page => $keys ) {
        foreach ( $keys as $key ) {
            if ( isset( $allowed_options[ $page ] ) && is_array( $allowed_options[ $page ] ) ) {
                $pos = array_search( $key, $allowed_options[ $page ], true );
                if ( false !== $pos ) {
                    unset( $allowed_options[ $page ][ $pos ] );
                }
            }
        }
    }
 
    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.