Options, Meta APIs: Introduce `register_setting` and `unregister_setting` actions.
Props Howdy_McGee, Pionect. Fixes #37245. Built from https://develop.svn.wordpress.org/trunk@48321 git-svn-id: http://core.svn.wordpress.org/trunk@48090 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
93abb3b3d0
commit
b0703f3749
|
@ -2212,6 +2212,7 @@ function register_setting( $option_group, $option_name, $args = array() ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_whitelist_options[ $option_group ][] = $option_name;
|
$new_whitelist_options[ $option_group ][] = $option_name;
|
||||||
|
|
||||||
if ( ! empty( $args['sanitize_callback'] ) ) {
|
if ( ! empty( $args['sanitize_callback'] ) ) {
|
||||||
add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'] );
|
add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'] );
|
||||||
}
|
}
|
||||||
|
@ -2219,6 +2220,17 @@ function register_setting( $option_group, $option_name, $args = array() ) {
|
||||||
add_filter( "default_option_{$option_name}", 'filter_default_option', 10, 3 );
|
add_filter( "default_option_{$option_name}", 'filter_default_option', 10, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires immediately before the setting is registered but after its filters are in place.
|
||||||
|
*
|
||||||
|
* @since 5.5.0
|
||||||
|
*
|
||||||
|
* @param string $option_group Setting group.
|
||||||
|
* @param string $option_name Setting name.
|
||||||
|
* @param array $args Array of setting registration arguments.
|
||||||
|
*/
|
||||||
|
do_action( 'register_setting', $option_group, $option_name, $args );
|
||||||
|
|
||||||
$wp_registered_settings[ $option_name ] = $args;
|
$wp_registered_settings[ $option_name ] = $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2265,9 +2277,11 @@ function unregister_setting( $option_group, $option_name, $deprecated = '' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ], true );
|
$pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ], true );
|
||||||
|
|
||||||
if ( false !== $pos ) {
|
if ( false !== $pos ) {
|
||||||
unset( $new_whitelist_options[ $option_group ][ $pos ] );
|
unset( $new_whitelist_options[ $option_group ][ $pos ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( '' !== $deprecated ) {
|
if ( '' !== $deprecated ) {
|
||||||
_deprecated_argument(
|
_deprecated_argument(
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
|
@ -2293,6 +2307,16 @@ function unregister_setting( $option_group, $option_name, $deprecated = '' ) {
|
||||||
remove_filter( "default_option_{$option_name}", 'filter_default_option', 10 );
|
remove_filter( "default_option_{$option_name}", 'filter_default_option', 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires immediately before the setting is unregistered and after its filters have been removed.
|
||||||
|
*
|
||||||
|
* @since 5.5.0
|
||||||
|
*
|
||||||
|
* @param string $option_group Setting group.
|
||||||
|
* @param string $option_name Setting name.
|
||||||
|
*/
|
||||||
|
do_action( 'unregister_setting', $option_group, $option_name );
|
||||||
|
|
||||||
unset( $wp_registered_settings[ $option_name ] );
|
unset( $wp_registered_settings[ $option_name ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.5-alpha-48320';
|
$wp_version = '5.5-alpha-48321';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue