Make WordPress Core


Ignore:
Timestamp:
07/13/2016 04:12:41 AM (9 years ago)
Author:
jeremyfelt
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/meta.php

    r38027 r38040  
    11631163    }
    11641164
     1165    $args = $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ];
     1166
     1167    if ( isset( $args['sanitize_callback'] ) && is_callable( $args['sanitize_callback'] ) ) {
     1168        remove_filter( "sanitize_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['sanitize_callback'] );
     1169    }
     1170
     1171    if ( isset( $args['auth_callback'] ) && is_callable( $args['auth_callback'] ) ) {
     1172        remove_filter( "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['auth_callback'] );
     1173    }
     1174
    11651175    unset( $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] );
    11661176
Note: See TracChangeset for help on using the changeset viewer.