From d5e14166f3725d5ed84ace15554e1c8e6d71115b Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 13 Jul 2016 04:13:30 +0000 Subject: [PATCH] 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 --- wp-includes/meta.php | 10 ++++++++++ wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-includes/meta.php b/wp-includes/meta.php index dfc0695818..e341bd2bcc 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -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 diff --git a/wp-includes/version.php b/wp-includes/version.php index 3d4a2fcc07..64bf163f19 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.