WP_Ability_Category::prepare_propertiesprotectedWP 6.9.0

Prepares and validates the properties used to instantiate the ability category.

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

Хуков нет.

Возвращает

Массив<Строку,. mixed> $args {

An associative array with validated and prepared ability category properties.
@type string               $label       The human-readable label for the ability category.
@type string               $description A description of the ability category.
@type array<string, mixed> $meta        Optional. Additional metadata for the ability category.

}

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_properties( $args ): array;
$args(массив) (обязательный)
.

Список изменений

С версии 6.9.0 Введена.

Код WP_Ability_Category::prepare_properties() WP 6.9

protected function prepare_properties( array $args ): array {
	// Required args must be present and of the correct type.
	if ( empty( $args['label'] ) || ! is_string( $args['label'] ) ) {
		throw new InvalidArgumentException(
			__( 'The ability category properties must contain a `label` string.' )
		);
	}

	if ( empty( $args['description'] ) || ! is_string( $args['description'] ) ) {
		throw new InvalidArgumentException(
			__( 'The ability category properties must contain a `description` string.' )
		);
	}

	// Optional args only need to be of the correct type if they are present.
	if ( isset( $args['meta'] ) && ! is_array( $args['meta'] ) ) {
		throw new InvalidArgumentException(
			__( 'The ability category properties should provide a valid `meta` array.' )
		);
	}

	return $args;
}