Ticket #44238: 44238.diff
File 44238.diff, 2.3 KB (added by , 6 years ago) |
---|
-
src/wp-includes/meta.php
952 952 function is_protected_meta( $meta_key, $meta_type = null ) { 953 953 $protected = ( '_' == $meta_key[0] ); 954 954 955 if( $meta_type ) { 956 /** 957 * Filters whether a meta key is considered protected. 958 * 959 * @since 5.0.0 960 * 961 * @param bool $protected Whether the key is considered protected. 962 * @param string $meta_key Meta key. 963 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user). 964 */ 965 $protected = apply_filters( "protected_{$meta_type}_meta_{$meta_key}", $protected, $meta_key, $meta_type ); 966 } 955 967 /** 956 968 * Filters whether a meta key is considered protected. 957 969 * … … 1026 1038 $wp_meta_keys = array(); 1027 1039 } 1028 1040 1029 $defaults = array( 1030 'type' => 'string', 1031 'description' => '', 1032 'single' => false, 1033 'sanitize_callback' => null, 1034 'auth_callback' => null, 1035 'show_in_rest' => false, 1036 ); 1041 $defaults = [ 1042 'type' => 'string', 1043 'description' => '', 1044 'single' => false, 1045 'protected_callback' => null, 1046 'sanitize_callback' => null, 1047 'auth_callback' => null, 1048 'show_in_rest' => false, 1049 ]; 1037 1050 1038 1051 // There used to be individual args for sanitize and auth callbacks 1039 1052 $has_old_sanitize_cb = false; … … 1067 1080 $args = apply_filters( 'register_meta_args', $args, $defaults, $object_type, $meta_key ); 1068 1081 $args = wp_parse_args( $args, $defaults ); 1069 1082 1083 if ( is_callable( $args['protected_callback'] ) ) { 1084 add_filter( "protected_{$meta_type}_meta_{$meta_key}", $args['protected_callback'], 10, 1 ); 1085 } 1086 1070 1087 // If `auth_callback` is not provided, fall back to `is_protected_meta()`. 1071 1088 if ( empty( $args['auth_callback'] ) ) { 1072 1089 if ( is_protected_meta( $meta_key, $object_type ) ) { … … 1149 1166 remove_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'] ); 1150 1167 } 1151 1168 1169 if ( isset( $args['protected_callback'] ) && is_callable( $args['protected_callback'] ) ) { 1170 remove_filter( "protected_{$object_type}_meta_{$meta_key}", $args['protected_callback'] ); 1171 } 1172 1152 1173 unset( $wp_meta_keys[ $object_type ][ $meta_key ] ); 1153 1174 1154 1175 // Do some clean up