WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/03/2020 07:18:40 PM (11 months ago)
Author:
TimothyBlynJacobs
Message:

REST API: Support the uuid JSON Schema format.

This accepts a uuid of any version. A future commit could add support for restricting uuids to a specific version.

Props johnwatkins0.
Fixes #50053.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r47627 r47753  
    13921392                    /* translators: %s: IP address. */
    13931393                    return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not a valid IP address.' ), $param ) );
     1394                }
     1395                break;
     1396            case 'uuid':
     1397                if ( ! wp_is_uuid( $value ) ) {
     1398                    /* translators: %s is the name of a JSON field expecting a valid uuid. */
     1399                    return new WP_Error( 'rest_invalid_uuid', sprintf( __( '%s is not a valid UUID.' ), $param ) );
    13941400                }
    13951401                break;
     
    15501556            case 'ip':
    15511557                return sanitize_text_field( $value );
     1558
     1559            case 'uuid':
     1560                return sanitize_text_field( $value );
    15521561        }
    15531562    }
Note: See TracChangeset for help on using the changeset viewer.