Automattic\WooCommerce\StoreApi\Schemas\V1

AbstractSchema::get_recursive_schema_property_defaults()protectedWC 1.0

Gets an array of schema defaults recursively.

Метод класса: AbstractSchema{}

Хуков нет.

Возвращает

Массив. Array of defaults, pulled from arg_options

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_recursive_schema_property_defaults( $properties );
$properties(массив) (обязательный)
Schema property data.

Код AbstractSchema::get_recursive_schema_property_defaults() WC 8.7.0

protected function get_recursive_schema_property_defaults( $properties ) {
	$defaults = [];

	foreach ( $properties as $property_key => $property_value ) {
		if ( isset( $property_value['arg_options']['default'] ) ) {
			$defaults[ $property_key ] = $property_value['arg_options']['default'];
		} elseif ( isset( $property_value['properties'] ) ) {
			$defaults[ $property_key ] = $this->get_recursive_schema_property_defaults( $property_value['properties'] );
		}
	}

	return $defaults;
}