WP_Ability_Category::prepare_properties
Prepares and validates the properties used to instantiate the ability category.
Method of the class: WP_Ability_Category{}
No Hooks.
Returns
Array$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.
}
Usage
// protected - for code of main (parent) or child class $result = $this->prepare_properties( $args ): array;
- $args(array) (required)
- .
Changelog
| Since 6.9.0 | Introduced. |
WP_Ability_Category::prepare_properties() WP Ability Category::prepare properties code WP 6.9.1
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;
}