Changeset 48171 for trunk/src/wp-includes/rest-api.php
- Timestamp:
- 06/25/2020 10:11:09 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r48150 r48171 1780 1780 return $data; 1781 1781 } 1782 1783 /** 1784 * Sets the "additionalProperties" to false by default for all object definitions in the schema. 1785 * 1786 * @since 5.5.0 1787 * 1788 * @param array $schema The schema to modify. 1789 * @return array The modified schema. 1790 */ 1791 function rest_default_additional_properties_to_false( $schema ) { 1792 $type = (array) $schema['type']; 1793 1794 if ( in_array( 'object', $type, true ) ) { 1795 if ( isset( $schema['properties'] ) ) { 1796 foreach ( $schema['properties'] as $key => $child_schema ) { 1797 $schema['properties'][ $key ] = rest_default_additional_properties_to_false( $child_schema ); 1798 } 1799 } 1800 1801 if ( ! isset( $schema['additionalProperties'] ) ) { 1802 $schema['additionalProperties'] = false; 1803 } 1804 } 1805 1806 if ( in_array( 'array', $type, true ) ) { 1807 if ( isset( $schema['items'] ) ) { 1808 $schema['items'] = rest_default_additional_properties_to_false( $schema['items'] ); 1809 } 1810 } 1811 1812 return $schema; 1813 }
Note: See TracChangeset
for help on using the changeset viewer.