michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Capability Inheritance: Sub-Menu > Section > Field #208

Closed sambrodie closed 8 years ago

sambrodie commented 9 years ago

Currently it seems as though the required capabilities are automatically set at each level as manage_options. However, it would be better if Setting Fields inherited their default from the Setting Section, and Setting Sections inherited their default from the Sub Menu. Also, in the absence of a Setting Section, the Setting Field should inherit from the Sub Menu.

michaeluno commented 9 years ago

Hi,

Currently it seems as though the required capabilities are automatically set at each level as manage_options

You can change it by passing a capability in the third parameter in the constructor when you instantiate the class.

        new APF_Demo( 
            null, // option key 
            APFDEMO_FILE, // caller script path.
            'manage_options'  // <-- this one
        );

(https://github.com/michaeluno/admin-page-framework/blob/3.5.6/include/class/admin/demo/AdminPageFrameworkLoader_Demo_AdminPage.php#L31-L44)

it would be better if Setting Fields inherited their default from the Setting Section, and Setting Sections inherited their default from the Sub Menu. Also, in the absence of a Setting Section, the Setting Field should inherit from the Sub Menu.

Interesting idea.

To be clear, the elements that accept the capability argument including admin pages, in-page tabs, form sections, and form fields inherit the value set to the class mentioned above, manage_options as default.

To adopt your idea, setting sections should inherit the value from the in-page tab if exists; otherwise, the page. The page inherits the value from the value set to the class.

Thanks for the suggestion.

michaeluno commented 8 years ago

This is now available in the development branch. Download

Let me know if it works or not.