Deprecate add_option_update_handler() and remove_option_update_handler() in favor of register_setting() and unregister_setting(). #11730
git-svn-id: http://svn.automattic.com/wordpress/trunk@13805 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3fb0afae96
commit
e507f32dd4
|
@ -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 );
|
||||
}
|
||||
|
||||
?>
|
|
@ -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>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1422,10 +1422,17 @@ function user_can_access_admin_page() {
|
|||
* @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
|
||||
* @return unknown
|
||||
*/
|
||||
function register_setting($option_group, $option_name, $sanitize_callback = '') {
|
||||
if ( 'misc' == $option_group )
|
||||
function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {
|
||||
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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1438,44 +1445,13 @@ function register_setting($option_group, $option_name, $sanitize_callback = '')
|
|||
* @param unknown_type $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 = '') {
|
||||
function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) {
|
||||
global $new_whitelist_options;
|
||||
|
||||
if ( 'misc' == $option_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 )
|
||||
if ( 'misc' == $option_group ) {
|
||||
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
|
||||
$option_group = 'general';
|
||||
}
|
||||
|
||||
$pos = array_search( $option_name, (array) $new_whitelist_options );
|
||||
if ( $pos !== false )
|
||||
|
@ -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>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue