Automattic\WooCommerce\Internal\Utilities

FilesystemUtil::get_wp_filesystem_method_or_direct()public staticWC 1.0

Get the WP filesystem method, with a fallback to 'direct' if no FS_METHOD constant exists and there are not FTP related options/credentials set.

Method of the class: FilesystemUtil{}

No Hooks.

Return

String|false. The name of the WP filesystem method to use.

Usage

$result = FilesystemUtil::get_wp_filesystem_method_or_direct();

FilesystemUtil::get_wp_filesystem_method_or_direct() code WC 9.6.0

public static function get_wp_filesystem_method_or_direct() {
	$proxy = wc_get_container()->get( LegacyProxy::class );
	if ( ! self::constant_exists( 'FS_METHOD' ) && false === $proxy->call_function( 'get_option', 'ftp_credentials' ) && ! self::constant_exists( 'FTP_HOST' ) ) {
		return 'direct';
	}

	$method = $proxy->call_function( 'get_filesystem_method' );
	if ( $method ) {
		return $method;
	}

	return 'direct';
}