From 97e8bd742dd038b8723c03b91b276ff23bb11a1a Mon Sep 17 00:00:00 2001 From: nacin Date: Sun, 22 May 2011 21:32:44 +0000 Subject: [PATCH] Leverage option_page_capability_* filter in Twenty Eleven. fixes #14365. git-svn-id: http://svn.automattic.com/wordpress/trunk@17987 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../themes/twentyeleven/inc/theme-options.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wp-content/themes/twentyeleven/inc/theme-options.php b/wp-content/themes/twentyeleven/inc/theme-options.php index 5ab441d3c..80f9a80b5 100644 --- a/wp-content/themes/twentyeleven/inc/theme-options.php +++ b/wp-content/themes/twentyeleven/inc/theme-options.php @@ -54,6 +54,25 @@ function twentyeleven_theme_options_init() { } add_action( 'admin_init', 'twentyeleven_theme_options_init' ); +/** + * Change the capability required to save the 'twentyeleven_options' options group. + * + * @see twentyeleven_theme_options_init() First parameter to register_setting() is the name of the options group. + * @see twentyeleven_theme_options_add_page() The edit_theme_options capability is used for viewing the page. + * + * By default, the options groups for all registered settings require the manage_options capability. + * This filter is required to change our theme options page to edit_theme_options instead. + * By default, only administrators have either of these capabilities, but the desire here is + * to allow for finer-grained control for roles and users. + * + * @param string $capability The capability used for the page, which is manage_options by default. + * @return string The capability to actually use. + */ +function twentyeleven_option_page_capability( $capability ) { + return 'edit_theme_options'; +} +add_filter( 'option_page_capability_twentyeleven_options', 'twentyeleven_option_page_capability' ); + /** * Add our theme options page to the admin menu. *