Automattic\WooCommerce\Api\Infrastructure

ResolverHelpers::wp_filesystempublic staticWC 1.0

Lazy-initialize and return the WP_Filesystem global, or null when the direct method isn't available (e.g. credentials prompt would be needed).

Method of the class: ResolverHelpers{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = ResolverHelpers::wp_filesystem(): ?\WP_Filesystem_Base;

ResolverHelpers::wp_filesystem() code WC 10.9.1

public static function wp_filesystem(): ?\WP_Filesystem_Base {
	global $wp_filesystem;
	if ( ! $wp_filesystem ) {
		require_once ABSPATH . 'wp-admin/includes/file.php';
		if ( ! WP_Filesystem() ) {
			return null;
		}
	}
	return $wp_filesystem;
}