- // if no sanitize_callback was specified, default to rest_parse_request_arg
- // if a type was specified in the args.
- if ( ! isset( $attributes['args'][ $key ]['sanitize_callback'] ) && ! empty( $attributes['args'][ $key ]['type'] ) ) {
- $attributes['args'][ $key ]['sanitize_callback'] = 'rest_parse_request_arg';
+ if ( ! isset( $attributes['args'][ $key ] ) ) {
+ continue;
+ }
+ $param_args = $attributes['args'][ $key ];
+
+ // If the arg has a type but no sanitize_callback attribute, default to rest_parse_request_arg.
+ if ( ! array_key_exists( 'sanitize_callback', $param_args ) && ! empty( $param_args['type'] ) ) {
+ $param_args['sanitize_callback'] = 'rest_parse_request_arg';