apply_filters_deprecated( ‘whitelist_options’, array $allowed_options )

This hook has been deprecated. Use {@see ‘allowed_options’} instead.

Filters the allowed options list.

Parameters

$allowed_optionsarray
The allowed options list.

Source

$allowed_options = apply_filters_deprecated(
	'whitelist_options',
	array( $allowed_options ),
	'5.5.0',
	'allowed_options',
	__( 'Please consider writing more inclusive code.' )
);

Changelog

VersionDescription
5.5.0Use 'allowed_options' instead.
2.7.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Example how to add whitelist_options.

    $sections = array(
    	'section-one' => array(
    		'option-one',
    		'option-two'
    	),
    	'section-two' => array(
    		'option-one',
    		'option-two'
    	),
    );
    
    add_filter('whitelist_options', function($whitelist_options) use ($sections) {
    	foreach($sections as $section => $fields) {
    		foreach($fields as $field) {
    			$whitelist_options[$section][] = $field;
    		}
    	}
    	return $whitelist_options;
    });

You must log in before being able to contribute a note or feedback.