Ticket #14365: 14365.api.diff
File 14365.api.diff, 4.5 KB (added by , 14 years ago) |
---|
-
public/wp-admin/includes/plugin.php
1593 1593 * Default whitelisted option key names include "general," "discussion," and "reading," among others. 1594 1594 * @param string $option_name The name of an option to sanitize and save. 1595 1595 * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value. 1596 * @param string $capability The capability required to edit this option. 1596 1597 * @return unknown 1597 1598 */ 1598 function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {1599 global $new_whitelist_options ;1599 function register_setting( $option_group, $option_name, $sanitize_callback = '', $capability = '' ) { 1600 global $new_whitelist_options, $option_group_caps; 1600 1601 1601 1602 if ( 'misc' == $option_group ) { 1602 1603 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); … … 1606 1607 $new_whitelist_options[ $option_group ][] = $option_name; 1607 1608 if ( $sanitize_callback != '' ) 1608 1609 add_filter( "sanitize_option_{$option_name}", $sanitize_callback ); 1610 1611 // Set the capability on the group for now - in the long run this could support per option caps 1612 if ( $capability != '' ) 1613 $option_group_caps[ $option_group ] = $capability; 1609 1614 } 1610 1615 1611 1616 /** -
public/wp-admin/options.php
24 24 25 25 wp_reset_vars(array('action', 'option_page')); 26 26 27 $capability = 'manage_options';28 29 27 if ( empty($option_page) ) // This is for back compat and will eventually be removed. 30 28 $option_page = 'options'; 31 else 32 $capability = apply_filters( "option_page_capability_{$option_page}", $capability ); 29 30 $capability = 'manage_options'; 31 if ( isset( $option_group_caps[ $option_page ] ) ) 32 $capability = $option_group_caps[ $option_page ]; 33 33 34 34 if ( !current_user_can( $capability ) ) 35 35 wp_die(__('Cheatin’ uh?')); -
public/wp-content/themes/twentyeleven/inc/theme-options.php
47 47 add_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() ); 48 48 49 49 register_setting( 50 'twentyeleven_options', // Options group, see settings_fields() call in theme_options_render_page() 51 'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options() 52 'twentyeleven_theme_options_validate' // The sanitization callback, see twentyeleven_theme_options_validate() 50 'twentyeleven_options', // Options group, see settings_fields() call in theme_options_render_page() 51 'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options() 52 'twentyeleven_theme_options_validate', // The sanitization callback, see twentyeleven_theme_options_validate() 53 'edit_theme_options' // The capability required to modify this option 53 54 ); 54 55 } 55 56 add_action( 'admin_init', 'twentyeleven_theme_options_init' ); 56 57 57 58 /** 58 * Change the capability required to save the 'twentyeleven_options' options group.59 *60 * @see twentyeleven_theme_options_init() First parameter to register_setting() is the name of the options group.61 * @see twentyeleven_theme_options_add_page() The edit_theme_options capability is used for viewing the page.62 *63 * By default, the options groups for all registered settings require the manage_options capability.64 * This filter is required to change our theme options page to edit_theme_options instead.65 * By default, only administrators have either of these capabilities, but the desire here is66 * to allow for finer-grained control for roles and users.67 *68 * @param string $capability The capability used for the page, which is manage_options by default.69 * @return string The capability to actually use.70 */71 function twentyeleven_option_page_capability( $capability ) {72 return 'edit_theme_options';73 }74 add_filter( 'option_page_capability_twentyeleven_options', 'twentyeleven_option_page_capability' );75 76 /**77 59 * Add our theme options page to the admin menu. 78 60 * 79 61 * This function is attached to the admin_menu action hook.