Ticket #51020: 51020#.diff
| File 51020#.diff, 3.4 KB (added by , 6 years ago) |
|---|
-
src/wp-includes/rest-api/class-wp-rest-server.php
1297 1297 $endpoint_data['args'] = array(); 1298 1298 1299 1299 foreach ( $callback['args'] as $key => $opts ) { 1300 $arg_data = array( 1301 'required' => ! empty( $opts['required'] ), 1302 ); 1303 if ( isset( $opts['default'] ) ) { 1304 $arg_data['default'] = $opts['default']; 1305 } 1306 if ( isset( $opts['enum'] ) ) { 1307 $arg_data['enum'] = $opts['enum']; 1308 } 1309 if ( isset( $opts['description'] ) ) { 1310 $arg_data['description'] = $opts['description']; 1311 } 1312 if ( isset( $opts['type'] ) ) { 1313 $arg_data['type'] = $opts['type']; 1314 } 1315 if ( isset( $opts['items'] ) ) { 1316 $arg_data['items'] = $opts['items']; 1317 } 1318 $endpoint_data['args'][ $key ] = $arg_data; 1300 $arg_data = array( 'required' => ! empty( $opts['required'] ) ); 1301 1302 // take valid schema properties only 1303 foreach ( WP_REST_Controller::get_valid_schema_properties() as $valid_schema_property ) 1304 if ( array_key_exists( $valid_schema_property, $opts ) ) 1305 $arg_data[$valid_schema_property] = $opts[$valid_schema_property]; 1306 1307 $endpoint_data['args'][$key] = $arg_data; 1319 1308 } 1320 1309 } 1321 1310 -
src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
39 39 protected $schema; 40 40 41 41 /** 42 * All valid JSON schema properties. 43 * 44 * @since 5.6.0 45 * @var string[] 46 */ 47 private static $valid_schema_properties = array( 48 'type', 49 'format', 50 'enum', 51 'items', 52 'properties', 53 'additionalProperties', 54 'minimum', 55 'maximum', 56 'exclusiveMinimum', 57 'exclusiveMaximum', 58 'minLength', 59 'maxLength', 60 'pattern', 61 'minItems', 62 'maxItems', 63 'uniqueItems', 64 ); 65 66 /** 67 * Get all valid JSON schema properties. 68 * 69 * @since 5.6.0 70 * 71 * @return string[] All valid JSON schema properties. 72 */ 73 public static function get_valid_schema_properties() 74 { 75 return self::$valid_schema_properties; 76 } 77 78 /** 42 79 * Registers the routes for the objects of the controller. 43 80 * 44 81 * @since 4.7.0 … … 629 666 $schema = $this->get_item_schema(); 630 667 $schema_properties = ! empty( $schema['properties'] ) ? $schema['properties'] : array(); 631 668 $endpoint_args = array(); 632 $valid_schema_properties = array(633 'type',634 'format',635 'enum',636 'items',637 'properties',638 'additionalProperties',639 'minimum',640 'maximum',641 'exclusiveMinimum',642 'exclusiveMaximum',643 'minLength',644 'maxLength',645 'pattern',646 'minItems',647 'maxItems',648 'uniqueItems',649 );650 669 651 670 foreach ( $schema_properties as $field_id => $params ) { 652 671 … … 672 691 $endpoint_args[ $field_id ]['required'] = true; 673 692 } 674 693 675 foreach ( $valid_schema_properties as $schema_prop ) {694 foreach (self::$valid_schema_properties as $schema_prop ) { 676 695 if ( isset( $params[ $schema_prop ] ) ) { 677 696 $endpoint_args[ $field_id ][ $schema_prop ] = $params[ $schema_prop ]; 678 697 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)