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.
Return
Mixed
.
Usage
get_flag_value( $assoc_args, $flag, $default );
- $assoc_args(array) (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.8.0-alpha
function get_flag_value( $assoc_args, $flag, $default = null ) { return isset( $assoc_args[ $flag ] ) ? $assoc_args[ $flag ] : $default; }