apply_filters( ‘allowed_options’, array $allowed_options )

Filters the allowed options list.

Parameters

$allowed_optionsarray
The allowed options list.

Source

$allowed_options = apply_filters( 'allowed_options', $allowed_options );

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Example how to add allowed_options.

    (Adapted deprecated code by arnoutpullen)

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

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