mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@38040 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user