Ticket #35658: 35658.19.diff
File 35658.19.diff, 2.6 KB (added by , 8 years ago) |
---|
-
src/wp-includes/meta.php
1032 1032 1033 1033 $passed_args = array_slice( func_get_args(), 2 ); 1034 1034 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; 1037 1037 1038 1038 if ( is_callable( $passed_args[0] ) ) { 1039 1039 $args['sanitize_callback'] = $passed_args[0]; … … 1044 1044 1045 1045 if ( isset( $passed_args[1] ) && is_callable( $passed_args[1] ) ) { 1046 1046 $args['auth_callback'] = $passed_args[1]; 1047 $has_old_auth_cb = true;1048 1047 } 1049 1048 1050 1049 $args = wp_parse_args( $args, $defaults ); … … 1066 1065 return false; 1067 1066 } 1068 1067 1069 // Back-compat: old sanitize and auth callbacks applied to all of an object type1070 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 1076 1068 // If `auth_callback` is not provided, fall back to `is_protected_meta()`. 1077 1069 if ( empty( $args['auth_callback'] ) ) { 1078 1070 if ( is_protected_meta( $meta_key, $object_type ) ) { … … 1082 1074 } 1083 1075 } 1084 1076 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 ); 1086 1080 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 } 1089 1089 } 1090 1090 1091 $object_subtype = $args['object_subtype'];1092 1093 1091 // 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']; 1095 1094 $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] = $args; 1096 1095 1097 1096 return true;