WP_Ability_Category::prepare_properties( $args ): array<string,

In this article

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

Parameters

mixed> $args $args { An associative array of arguments used to instantiate the ability category class.
@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.
}

Return

array<string, 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.
}

Source

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

Changelog

VersionDescription
6.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.