apply_filters( 'allowed_options', array $allowed_options )

Filters the allowed options list.


Parameters Parameters

$allowed_options

(array) The allowed options list.


Top ↑

Source Source

File: wp-admin/options.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
5.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Jules Colle

    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.