Make WordPress Core

Ticket #35658: 35658.24.diff

File 35658.24.diff, 1.9 KB (added by helen, 8 years ago)
  • src/wp-includes/meta.php

     
    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 Optional. Deprecated. Default null.
    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                );
     1040
    10401041                $has_old_sanitize_cb = true;
    10411042        } else {
    1042                 $args = $passed_args[0];
     1043                $args = (array) $args;
    10431044        }
    10441045
    1045         if ( isset( $passed_args[1] ) && is_callable( $passed_args[1] ) ) {
    1046                 $args['auth_callback'] = $passed_args[1];
     1046        if ( is_callable( $deprecated ) ) {
     1047                $args['auth_callback'] = $deprecated;
    10471048        }
    10481049
    10491050        $args = wp_parse_args( $args, $defaults );