wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



rest_stabilize_value › WordPress Function

Seit5.5.0
Veraltetn/v
rest_stabilize_value ( $value )
Parameter:
  • (mixed) $value The value to stabilize. Must already be sanitized. Objects should have been converted to arrays.
    Erforderlich: Ja
Gibt zurück:
  • (mixed) The stabilized value.
Definiert in:
Codex:

Stabilizes a value following JSON Schema semantics.

For lists, order is preserved. For objects, properties are reordered alphabetically.


Quellcode

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;
}