Make WordPress Core

Ticket #35658: 35658.23.diff

File 35658.23.diff, 2.1 KB (added by ocean90, 8 years ago)
  • src/wp-includes/meta.php

     
    981981         */
    982982        return apply_filters( "sanitize_{$object_type}_meta_{$meta_key}", $meta_value, $meta_key, $object_type, $object_subtype );
    983983
    984        
     984
    985985}
    986986
    987987/**
     
    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.
    10051005 * }
    1006  * @param string|array $auth_callback Deprecated. Use `$args` instead.
     1006 * @param string|array $deprecated Deprecated. Use `$args` instead.
    10071007 *
    10081008 * @return bool True if the meta key was successfully registered in the global array, false 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 */
    1012 function register_meta( $object_type, $meta_key, $args, $auth_callback = null ) {
     1012function register_meta( $object_type, $meta_key, $args, $deprecated = null ) {
    10131013        global $wp_meta_keys;
    10141014
    10151015        if ( ! is_array( $wp_meta_keys ) ) {
     
    10301030                'show_in_rest'      => false,
    10311031        );
    10321032
    1033         $passed_args = array_slice( func_get_args(), 2 );
    1034 
    10351033        // There used to be individual args for sanitize and auth callbacks
    10361034        $has_old_sanitize_cb = false;
    10371035
    1038         if ( is_callable( $passed_args[0] ) ) {
    1039                 $args['sanitize_callback'] = $passed_args[0];
     1036        if ( is_callable( $args ) ) {
     1037                $args = array(
     1038                        'sanitize_callback' => $args,
     1039                );
    10401040                $has_old_sanitize_cb = true;
    10411041        } else {
    1042                 $args = $passed_args[0];
     1042                $args = (array) $args;
    10431043        }
    10441044
    1045         if ( isset( $passed_args[1] ) && is_callable( $passed_args[1] ) ) {
    1046                 $args['auth_callback'] = $passed_args[1];
     1045        if ( isset( $deprecated ) && is_callable( $deprecated ) ) {
     1046                $args['auth_callback'] = $deprecated;
    10471047        }
    10481048
    10491049        $args = wp_parse_args( $args, $defaults );