handbook/references/internal-api/wp-cli-utils-get-flag-value.md
Pascal Birchler 264cb131bf
Fix handbook information architecture
- Organize files in folders according to the desired structure
- Use directory iterator to loop through all files and folders (makes generation more robust)
2025-06-25 15:38:39 +02:00

2.2 KiB

WP_CLI\Utils\get_flag_value()

Return the flag value or, if it's not set, the $default value.


Usage

WP_CLI\Utils\get_flag_value( $assoc_args, $flag, $default = null )
$assoc_args (array<string,string|bool>) Arguments array.
$flag (string) Flag to get the value.
$default (mixed) Default value for the flag. Default: NULL.
@return (mixed)

Notes

Because flags can be negated (e.g. --no-quiet to negate --quiet), this function provides a safer alternative to using isset( $assoc_args['quiet'] ) or similar.

Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.