Make WordPress Core

Ticket #37345: 37345_2.patch

File 37345_2.patch, 5.5 KB (added by vishalkakadiya, 9 years ago)

@@rmccue I think "37345.patch" will work for you. Let me know if anything else change you want.

  • wp-includes/meta.php

    diff --git a/wp-includes/meta.php b/wp-includes/meta.php
    index ff32086..bfbc61b 100644
    a b function sanitize_meta( $meta_key, $meta_value, $object_type, $object_subtype = 
    10051005 * }
    10061006 * @param string|array $deprecated Deprecated. Use `$args` instead.
    10071007 *
    1008  * @return bool|WP_error True if the meta key was successfully registered in the global array, WP_Error if not.
     1008 * @return bool|_doing_it_wrong True if the meta key was successfully registered in the global array, _doing_it_wrong() if not.
    10091009 *                       Registering a meta key with distinct sanitize and auth callbacks will fire those
    10101010 *                       callbacks, but will not add to the global registry as it requires a subtype.
    10111011 */
    function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { 
    10171017        }
    10181018
    10191019        if ( ! wp_object_type_exists( $object_type ) ) {
    1020                 return new WP_Error( 'register_meta_failed', __( 'Meta can only be registered against a core object type.' ) );
     1020                _doing_it_wrong( __FUNCTION__, __( 'Meta can only be registered against a core object type.' ), '4.6.0' );
     1021                return false;
    10211022        }
    10221023
    10231024        $defaults = array(
    function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { 
    10651066
    10661067        // Object subtype is required if using the args style of registration
    10671068        if ( ! $has_old_sanitize_cb && ! $has_old_auth_cb && empty( $args['object_subtype'] ) ) {
    1068                 return new WP_Error( 'register_meta_failed', __( 'Meta must be registered against an object subtype.' ) );
     1069                _doing_it_wrong( __FUNCTION__, __( 'Meta must be registered against an object subtype.' ), '4.6.0' );
     1070                return false;
    10691071        }
    10701072
    10711073        // If `auth_callback` is not provided, fall back to `is_protected_meta()`.
    function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { 
    11091111                return true;
    11101112        }
    11111113
    1112         return new WP_Error( 'register_meta_failed', __( 'Sanitize and auth callbacks registered; meta key not registered.' ) );
     1114        _doing_it_wrong( __FUNCTION__, __( 'Sanitize and auth callbacks are already registered, but meta key not yet registered.' ), '4.6.0' );
     1115        return false;
    11131116}
    11141117
    11151118/**
    function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { 
    11211124 * @param string $object_subtype The subtype of the object type.
    11221125 * @param string $meta_key       The meta key.
    11231126 *
    1124  * @return bool|WP_error True if the meta key is registered to the object type and subtype. False if not.
    1125  *                       WP_Error if an invalid object type is passed.
     1127 * @return bool|_doing_it_wrong True if the meta key is registered to the object type and subtype. False if not.
     1128 *                       _doing_it_wrong() if an invalid object type is passed.
    11261129 */
    11271130function registered_meta_key_exists( $object_type, $object_subtype, $meta_key ) {
    11281131        global $wp_meta_keys;
    function registered_meta_key_exists( $object_type, $object_subtype, $meta_key ) 
    11331136
    11341137        // Only specific core object types are supported.
    11351138        if ( ! wp_object_type_exists( $object_type ) ) {
    1136                 return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not a core object type.' ) );
     1139                _doing_it_wrong( __FUNCTION__, __( 'Object type is invalid, it must be a core object type.' ), '4.6.0' );
     1140                return false;
    11371141        }
    11381142
    11391143        if ( ! isset( $wp_meta_keys[ $object_type ] ) ) {
    function registered_meta_key_exists( $object_type, $object_subtype, $meta_key ) 
    11601164 * @param string $object_subtype The subtype of the object type.
    11611165 * @param string $meta_key       The meta key.
    11621166 *
    1163  * @return bool|WP_Error True if successful. WP_Error if the meta key is invalid.
     1167 * @return bool|_doing_it_wrong True if successful. _doing_it_wrong() if the meta key is invalid.
    11641168 */
    11651169function unregister_meta_key( $object_type, $object_subtype, $meta_key ) {
    11661170        global $wp_meta_keys;
    11671171
    11681172        if ( ! registered_meta_key_exists( $object_type, $object_subtype, $meta_key ) ) {
    1169                 return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key' ) );
     1173                _doing_it_wrong( __FUNCTION__, __( 'Invalid meta key' ), '4.6.0' );
     1174                return false;
    11701175        }
    11711176
    11721177        $args = $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ];
    function get_registered_meta_keys( $object_type, $object_subtype = '' ) { 
    12321237 * @param string $meta_key       Optional. Registered metadata key. If not specified, retrieve all registered
    12331238 *                               metadata for the specified object.
    12341239 *
    1235  * @return mixed|WP_Error
     1240 * @return mixed|_doing_it_wrong
    12361241 */
    12371242function get_registered_metadata( $object_type, $object_subtype, $object_id, $meta_key = '' ) {
    12381243        global $wp_meta_keys;
    12391244
    12401245        if ( ! is_array( $wp_meta_keys ) ) {
    1241                 return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not registered.' ) );
     1246                _doing_it_wrong( __FUNCTION__, __( 'Invalid meta key, it is not registered yet.' ), '4.6.0' );
     1247                return false;
    12421248        }
    12431249
    12441250        if ( ! wp_object_type_exists( $object_type ) ) {
    1245                 return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not a core object type.' ) );
     1251                _doing_it_wrong( __FUNCTION__, __( 'Object type is invalid, it must be a core object type.' ), '4.6.0' );
     1252                return false;
    12461253        }
    12471254
    12481255        if ( ! empty( $meta_key ) ) {
    12491256                if ( ! registered_meta_key_exists( $object_type, $object_subtype, $meta_key ) ) {
    1250                         return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not registered.' ) );
     1257                        _doing_it_wrong( __FUNCTION__, __( 'Invalid meta key, it is not registered yet.' ), '4.6.0' );
     1258                        return false;
    12511259                }
    12521260                $meta_keys = get_registered_meta_keys( $object_type, $object_subtype );
    12531261                $meta_key_data = $meta_keys[ $meta_key ];