On this page
rest_stabilize_value( mixed $value ): mixed
Stabilizes a value following JSON Schema semantics.
Description
For lists, order is preserved. For objects, properties are reordered alphabetically.
Parameters
$valuemixed Required-
The value to stabilize. Must already be sanitized. Objects should have been converted to arrays.
Return
mixed The stabilized value.
Source
File: wp-includes/rest-api.php. View all references
function rest_stabilize_value( $value ) {
if ( is_scalar( $value ) || is_null( $value ) ) {
return $value;
}
if ( is_object( $value ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Cannot stabilize objects. Convert the object to an array first.' ), '5.5.0' );
return $value;
}
ksort( $value );
foreach ( $value as $k => $v ) {
$value[ $k ] = rest_stabilize_value( $v );
}
return $value;
}
Related
Uses
| Uses | Description |
|---|---|
| rest_stabilize_value() wp-includes/rest-api.php | Stabilizes a value following JSON Schema semantics. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| _doing_it_wrong() wp-includes/functions.php | Marks something as being incorrectly called. |
Used By
| Used By | Description |
|---|---|
| rest_validate_array_contains_unique_items() wp-includes/rest-api.php | Checks if an array is made up of unique items. |
| rest_stabilize_value() wp-includes/rest-api.php | Stabilizes a value following JSON Schema semantics. |
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_stabilize_value