Make WordPress Core


Ignore:
Timestamp:
10/31/2016 04:06:54 PM (10 years ago)
Author:
joehoyle
Message:

REST API: Add support for "integer" type for meta and options

Previously Settings only supported "number" which meant it was possible to push floats to things like posts_per_page. This means now developers can also specify type => ineger in meta nad settings resgration.

Props flixos90.
Fixes #38393.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php

    r39046 r39058  
    133133                        case 'string':
    134134                                return (string) $value;
     135                        case 'integer':
     136                                return (int) $value;
    135137                        case 'number':
    136138                                return (float) $value;
     
    259261                         * to be updated with arbitrary values that we can't do decent sanitizing for.
    260262                         */
    261                         if ( ! in_array( $rest_args['schema']['type'], array( 'number', 'string', 'boolean' ), true ) ) {
     263                        if ( ! in_array( $rest_args['schema']['type'], array( 'number', 'integer', 'string', 'boolean' ), true ) ) {
    262264                                continue;
    263265                        }
Note: See TracChangeset for help on using the changeset viewer.