Make WordPress Core

Ticket #35658: 35658.19.diff

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

     
    10321032
    10331033        $passed_args = array_slice( func_get_args(), 2 );
    10341034
    1035         // There used to be individual args for sanitize and auth callbacks     
    1036         $has_old_sanitize_cb = $has_old_auth_cb = false;
     1035        // There used to be individual args for sanitize and auth callbacks
     1036        $has_old_sanitize_cb = false;
    10371037
    10381038        if ( is_callable( $passed_args[0] ) ) {
    10391039                $args['sanitize_callback'] = $passed_args[0];
     
    10441044
    10451045        if ( isset( $passed_args[1] ) && is_callable( $passed_args[1] ) ) {
    10461046                $args['auth_callback'] = $passed_args[1];
    1047                 $has_old_auth_cb = true;
    10481047        }
    10491048
    10501049        $args = wp_parse_args( $args, $defaults );
     
    10661065                return false;
    10671066        }
    10681067
    1069         // Back-compat: old sanitize and auth callbacks applied to all of an object type
    1070         if ( $has_old_sanitize_cb ) {
    1071                 add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
    1072         } elseif ( is_callable( $args['sanitize_callback'] ) && ! empty( $object_subtype ) ) {
    1073                 add_filter( "sanitize_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
    1074         }
    1075 
    10761068        // If `auth_callback` is not provided, fall back to `is_protected_meta()`.
    10771069        if ( empty( $args['auth_callback'] ) ) {
    10781070                if ( is_protected_meta( $meta_key, $object_type ) ) {
     
    10821074                }
    10831075        }
    10841076
    1085         if ( $has_old_auth_cb ) {
     1077        // Back-compat: old sanitize and auth callbacks applied to all of an object type
     1078        if ( $has_old_sanitize_cb ) {
     1079                add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
    10861080                add_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
    1087         } elseif ( is_callable( $args['auth_callback'] ) && ! empty( $object_subtype ) ) {
    1088                 add_filter( "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
     1081        } else {
     1082                if ( is_callable( $args['sanitize_callback'] ) ) {
     1083                        add_filter( "sanitize_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['sanitize_callback'], 10, 4 );
     1084                }
     1085
     1086                if ( is_callable( $args['auth_callback'] ) ) {
     1087                        add_filter( "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}", $args['auth_callback'], 10, 6 );
     1088                }
    10891089        }
    10901090
    1091         $object_subtype = $args['object_subtype'];
    1092 
    10931091        // Global registry only contains meta keys registered in the new way with a subtype.
    1094         if ( ! empty( $object_subtype ) ) {
     1092        if ( ! empty( $args['object_subtype'] ) ) {
     1093                $object_subtype = $args['object_subtype'];
    10951094                $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] = $args;
    10961095
    10971096                return true;