Make WordPress Core

Ticket #35658: 35658.20.diff

File 35658.20.diff, 1.5 KB (added by Faison, 8 years ago)

Fixed a bug in get_registered_metadata() and made sure 'single' is a valid option for registered meta

  • src/wp-includes/meta.php

     
    10021002 *     @type string $sanitize_callback A function or method to call when sanitizing `$meta_key` data.
    10031003 *     @type string $auth_callback     Optional. A function or method to call when performing edit_post_meta, add_post_meta, and delete_post_meta capability checks.
    10041004 *     @type bool   $show_in_rest      Whether data associated with this meta key can be considered public.
     1005 *     @type bool   $single            Whether the meta key has one value per object, or an array of values per object.
    10051006 * }
    10061007 * @param string|array $auth_callback Deprecated. Use `$args` instead.
    10071008 *
     
    10281029                'sanitize_callback' => null,
    10291030                'auth_callback'     => null,
    10301031                'show_in_rest'      => false,
     1032                'single'            => false,
    10311033        );
    10321034
    10331035        $passed_args = array_slice( func_get_args(), 2 );
     
    12271229                        return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not registered.' ) );
    12281230                }
    12291231                $meta_keys = get_registered_meta_keys( $object_type, $object_subtype );
    1230                 $meta_key_data = $meta_keys[ $object_type ][ $object_subtype ][ $meta_key ];
     1232                $meta_key_data = $meta_keys[ $meta_key ];
    12311233
    1232                 $data = get_metadata( $object_type, $object_id, $meta_key, $meta_key_data->single );
     1234                $data = get_metadata( $object_type, $object_id, $meta_key, $meta_key_data['single'] );
    12331235
    12341236                return $data;
    12351237        }