﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	focuses
65043	Consider adding wp_doing_cli() to wrap WP_CLI constant checks	johnjamesjacoby		"See #42061.

I think WordPress core should come with a `wp_doing_cli()` function to provide a centrally supported, familiar, and filterable way for plugins and tools to check whether or not the `WP_CLI` constant is set.

While the WP-CLI project is an external library, it is obviously part of the WordPress Foundation, so it is the canonical command line interface for WordPress itself.

Mostly, honestly, I get annoyed seeing `defined( 'WP_CLI' ) && WP_CLI` everywhere. 😇

{{{
/**
 * Determines whether the current request is a WordPress CLI request.
 *
 * @since 7.1.0
 *
 * @return bool True if it's a WordPress CLI request, false otherwise.
 */
function wp_doing_cli() {
	/**
	 * Filters whether the current request is a WordPress CLI request.
	 *
	 * @since 7.1.0
	 *
	 * @param bool $wp_doing_cli Whether the current request is a WordPress CLI request.
	 */
	return apply_filters( 'wp_doing_cli', defined( 'WP_CLI' ) && WP_CLI );
}
}}}

(I set the Component to Bootstrap/Load because that's where this function would likely end up.)"	feature request	new	normal	Awaiting Review	Bootstrap/Load		normal		2nd-opinion		
