WP_CLI\Utils
get_flag_value()
Return the flag value or, if it's not set, the $default value.
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.
No Hooks.
Returns
Mixed.
Usage
get_flag_value( $assoc_args, $flag, $default );
- $assoc_args(array<string,string|bool>) (required)
- Arguments array.
- $flag(string) (required)
- Flag to get the value.
- $default(mixed)
- Default value for the flag.
Default:NULL
get_flag_value() get flag value code WP-CLI 2.13.0-alpha
function get_flag_value( $assoc_args, $flag, $default = null ) {
return isset( $assoc_args[ $flag ] ) ? $assoc_args[ $flag ] : $default;
}