Meta: Remove filters when meta is unregistered.

If auth and/or sanitize callbacks are specified in the arguments for
`register_meta()`, filters are added to handle these callbacks. These
should be removed when calling `unregister_meta_key()` to avoid
unintentional filtering.

See #35658.

Built from https://develop.svn.wordpress.org/trunk@38040


git-svn-id: http://core.svn.wordpress.org/trunk@37981 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2016-07-13 04:13:30 +00:00
parent 532e8f0204
commit d5e14166f3
2 changed files with 11 additions and 1 deletions

View File

@ -1162,6 +1162,16 @@ function unregister_meta_key( $object_type, $object_subtype, $meta_key ) {
return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key' ) );
}
$args = $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ];
if ( isset( $args['sanitize_callback'] ) && is_callable( $args['sanitize_callback'] ) ) {
remove_filter( "sanitize_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['sanitize_callback'] );
}
if ( isset( $args['auth_callback'] ) && is_callable( $args['auth_callback'] ) ) {
remove_filter( "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['auth_callback'] );
}
unset( $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] );
// Do some clean up

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-beta2-38039';
$wp_version = '4.6-beta2-38040';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.