Changeset 38040
- Timestamp:
- 07/13/2016 04:12:41 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/meta.php
r38027 r38040 1163 1163 } 1164 1164 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 1165 1175 unset( $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] ); 1166 1176 -
trunk/tests/phpunit/tests/meta/registerMeta.php
r37995 r38040 33 33 } 34 34 35 public function _new_auth_meta_cb( $allowed, $meta_key, $post_id, $user_id, $cap, $caps ) { 36 return $allowed; 37 } 38 35 39 public function test_register_meta_with_valid_object_type_and_object_subtype_returns_true() { 36 40 $result = register_meta( 'post', 'flight_number', array( 'object_subtype' => 'post' ) ); … … 201 205 unregister_meta_key( 'post', 'post', 'flight_number' ); 202 206 203 remove_filter( 'sanitize_post_post_meta_flight_number', array( $this, '_new_sanitize_meta_cb') );204 remove_filter( 'auth_post_post_meta_flight_number', '__return_true');205 206 207 $this->assertTrue( $result ); 207 208 } … … 213 214 unregister_meta_key( 'post', 'post', 'new_sanitized_key' ); 214 215 215 remove_filter( 'sanitize_post_post_meta_new_sanitized_key', array( $this, '_new_sanitize_meta_cb') );216 remove_filter( 'auth_post_post_meta_new_sanitized_key', '__return_true');217 218 216 $this->assertEquals( 'new_sanitized_key new sanitized', $meta ); 217 } 218 219 public function test_register_meta_unregistered_meta_key_removes_sanitize_filter() { 220 register_meta( 'post', 'new_sanitized_key', array( 'object_subtype' => 'post', 'sanitize_callback' => array( $this, '_new_sanitize_meta_cb' ) ) ); 221 unregister_meta_key( 'post', 'post', 'new_sanitized_key' ); 222 223 $has_filter = has_filter( 'sanitize_post_post_meta_new_sanitized_key', array( $this, '_new_sanitize_meta_cb' ) ); 224 225 $this->assertFalse( $has_filter ); 226 } 227 228 public function test_register_meta_unregistered_meta_key_removes_auth_filter() { 229 register_meta( 'post', 'new_auth_key', array( 'object_subtype' => 'post', 'auth_callback' => array( $this, '_new_auth_meta_cb' ) ) ); 230 unregister_meta_key( 'post', 'post', 'new_auth_key' ); 231 232 $has_filter = has_filter( 'auth_post_post_meta_new_auth_key', array( $this, '_new_auth_meta_cb' ) ); 233 234 $this->assertFalse( $has_filter ); 219 235 } 220 236
Note: See TracChangeset
for help on using the changeset viewer.