Deprecate add_option_update_handler() and remove_option_update_handler() in favor of register_setting() and unregister_setting(). #11730

git-svn-id: https://develop.svn.wordpress.org/trunk@13805 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-03-22 23:03:31 +00:00
parent 0ac5c26d2d
commit e5f55c5b3d
3 changed files with 62 additions and 49 deletions

View File

@ -125,4 +125,41 @@ function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $le
}
}
/**
* Register a setting and its sanitization callback
*
* @since 2.7.0
* @deprecated 3.0.0
* @deprecated Use register_setting()
* @see register_setting()
*
* @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
* Default whitelisted option key names include "general," "discussion," and "reading," among others.
* @param string $option_name The name of an option to sanitize and save.
* @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
* @return unknown
*/
function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
_deprecated_function( __FUNCTION__, '3.0', 'register_setting()' );
return register_setting( $option_group, $option_name, $sanitize_callback );
}
/**
* Unregister a setting
*
* @since 2.7.0
* @deprecated 3.0.0
* @deprecated Use unregister_setting()
* @see unregister_setting()
*
* @param unknown_type $option_group
* @param unknown_type $option_name
* @param unknown_type $sanitize_callback
* @return unknown
*/
function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
_deprecated_function( __FUNCTION__, '3.0', 'unregister_setting()' );
return unregister_setting( $option_group, $option_name, $sanitize_callback );
}
?>

View File

@ -753,4 +753,15 @@ function ms_deprecated_blogs_file() {
}
add_action( 'admin_notices', 'ms_deprecated_blogs_file' );
/**
* Outputs the notice message for multisite regarding activation of plugin page.
*
* @since 3.0
* @return none
*/
function _admin_notice_multisite_activate_plugins_page() {
$message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href="ms-options.php#menu">' . __( 'Activate' ) . '</a>' );
echo "<div class='error'><p>$message</p></div>";
}
?>

View File

@ -1423,9 +1423,16 @@ function user_can_access_admin_page() {
* @return unknown
*/
function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {
if ( 'misc' == $option_group )
global $new_whitelist_options;
if ( 'misc' == $option_group ) {
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
return add_option_update_handler($option_group, $option_name, $sanitize_callback);
$option_group = 'general';
}
$new_whitelist_options[ $option_group ][] = $option_name;
if ( $sanitize_callback != '' )
add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
}
/**
@ -1439,44 +1446,13 @@ function register_setting($option_group, $option_name, $sanitize_callback = '')
* @return unknown
*/
function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) {
return remove_option_update_handler($option_group, $option_name, $sanitize_callback);
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $option_group
* @param unknown_type $option_name
* @param unknown_type $sanitize_callback
*/
function add_option_update_handler($option_group, $option_name, $sanitize_callback = '') {
global $new_whitelist_options;
if ( 'misc' == $option_group )
if ( 'misc' == $option_group ) {
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
$option_group = 'general';
$new_whitelist_options[ $option_group ][] = $option_name;
if ( $sanitize_callback != '' )
add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $option_group
* @param unknown_type $option_name
* @param unknown_type $sanitize_callback
*/
function remove_option_update_handler($option_group, $option_name, $sanitize_callback = '') {
global $new_whitelist_options;
if ( 'misc' == $option_group )
$option_group = 'general';
$pos = array_search( $option_name, (array) $new_whitelist_options );
if ( $pos !== false )
unset( $new_whitelist_options[ $option_group ][ $pos ] );
@ -1574,15 +1550,4 @@ function settings_fields($option_group) {
wp_nonce_field("$option_group-options");
}
/**
* Outputs the notice message for multisite regarding activation of plugin page.
*
* @since 3.0
* @return none
*/
function _admin_notice_multisite_activate_plugins_page() {
$message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href="ms-options.php#menu">' . __( 'Activate' ) . '</a>' );
echo "<div class='error'><p>$message</p></div>";
}
?>