REST API: Set default sanitize callback if type is set.
Props joehoyle, ChopinBach, jnylen0. Fixes #38593. git-svn-id: https://develop.svn.wordpress.org/trunk@39091 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f9230a1c4d
commit
603d38f02e
|
@ -804,6 +804,11 @@ class WP_REST_Request implements ArrayAccess {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach ( $this->params[ $type ] as $key => $value ) {
|
foreach ( $this->params[ $type ] as $key => $value ) {
|
||||||
|
// 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';
|
||||||
|
}
|
||||||
// Check if this param has a sanitize_callback added.
|
// Check if this param has a sanitize_callback added.
|
||||||
if ( ! isset( $attributes['args'][ $key ] ) || empty( $attributes['args'][ $key ]['sanitize_callback'] ) ) {
|
if ( ! isset( $attributes['args'][ $key ] ) || empty( $attributes['args'][ $key ]['sanitize_callback'] ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue