Ticket #35658: 35658.33.diff
File 35658.33.diff, 2.8 KB (added by , 8 years ago) |
---|
-
src/wp-includes/functions.php
5356 5356 // Strip timezone information 5357 5357 return preg_replace( '/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted ); 5358 5358 } 5359 5360 /** 5361 * Check if an object type exists. By default, these are `post`, `comment`, `user`, and `term`. 5362 * 5363 * @param string $object_type Object type to check. 5364 * @return bool True if the object type exists, false if not. 5365 */ 5366 function wp_object_type_exists( $object_type ) { 5367 /** 5368 * Filters WordPress object types. 5369 * 5370 * @since 4.6.0 5371 * 5372 * @param array $types Array of object types. 5373 */ 5374 $types = apply_filters( 'wp_object_types', array( 'post', 'comment', 'user', 'term' ) ); 5375 5376 if ( in_array( $object_type, $types ) ) { 5377 return true; 5378 } 5379 5380 return false; 5381 } -
src/wp-includes/meta.php
1015 1015 $wp_meta_keys = array(); 1016 1016 } 1017 1017 1018 /* translators: object type name */ 1019 if ( ! in_array( $object_type, array( 'post', 'comment', 'user', 'term' ) ) ) { 1020 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Invalid object type: %s.' ), $object_type ), '4.6.0' ); 1018 if ( ! wp_object_type_exists( $object_type ) ) { 1019 return new WP_Error( 'register_meta_failed', __( 'Meta can only be registered against a core object type.' ) ); 1021 1020 } 1022 1021 1023 1022 $defaults = array( … … 1063 1062 1064 1063 // Object subtype is required if using the args style of registration 1065 1064 if ( ! $has_old_sanitize_cb && empty( $args['object_subtype'] ) ) { 1066 return false;1065 return new WP_Error( 'register_meta_failed', __( 'Meta must be registered against an object subtype.' ) ); 1067 1066 } 1068 1067 1069 1068 // If `auth_callback` is not provided, fall back to `is_protected_meta()`. … … 1097 1096 return true; 1098 1097 } 1099 1098 1100 return false;1099 return new WP_Error( 'register_meta_failed', __( 'Sanitize and auth callbacks registered; meta key not registered.' ) ); 1101 1100 } 1102 1101 1103 1102 /** … … 1119 1118 } 1120 1119 1121 1120 // Only specific core object types are supported. 1122 if ( ! in_array( $object_type, array( 'post', 'comment', 'user', 'term' )) ) {1123 return false;1121 if ( ! wp_object_type_exists( $object_type ) ) { 1122 return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not a core object type.' ) ); 1124 1123 } 1125 1124 1126 1125 if ( ! isset( $wp_meta_keys[ $object_type ] ) ) { … … 1218 1217 return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not registered.' ) ); 1219 1218 } 1220 1219 1221 if ( ! in_array( $object_type, array( 'post', 'comment', 'user', 'term' )) ) {1220 if ( ! wp_object_type_exists( $object_type ) ) { 1222 1221 return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not a core object type.' ) ); 1223 1222 } 1224 1223