updated plugin WP Mail SMTP version 2.2.1

This commit is contained in:
2020-07-24 14:08:58 +00:00
committed by Gitium
parent 4b9aecd896
commit fa69c9daa6
40 changed files with 3546 additions and 2570 deletions

View File

@ -20,6 +20,7 @@ namespace Google\Auth;
use Google\Auth\Credentials\InsecureCredentials;
use Google\Auth\Credentials\ServiceAccountCredentials;
use Google\Auth\Credentials\UserRefreshCredentials;
use GuzzleHttp\ClientInterface;
/**
* CredentialsLoader contains the behaviour used to locate and find default
@ -54,6 +55,24 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
/**
* Returns the currently available major Guzzle version.
*
* @return int
*/
private static function getGuzzleMajorVersion()
{
if (defined('GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
return ClientInterface::MAJOR_VERSION;
}
if (defined('GuzzleHttp\ClientInterface::VERSION')) {
return (int) substr(ClientInterface::VERSION, 0, 1);
}
throw new \Exception('Version not supported');
}
/**
* Load a JSON key from the path specified in the environment.
*
@ -145,35 +164,30 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
callable $httpHandler = null,
callable $tokenCallback = null
) {
$version = \GuzzleHttp\ClientInterface::VERSION;
switch ($version[0]) {
case '5':
$client = new \GuzzleHttp\Client($httpClientOptions);
$client->setDefaultOption('auth', 'google_auth');
$subscriber = new Subscriber\AuthTokenSubscriber(
$fetcher,
$httpHandler,
$tokenCallback
);
$client->getEmitter()->attach($subscriber);
return $client;
case '6':
$middleware = new Middleware\AuthTokenMiddleware(
$fetcher,
$httpHandler,
$tokenCallback
);
$stack = \GuzzleHttp\HandlerStack::create();
$stack->push($middleware);
return new \GuzzleHttp\Client([
'handler' => $stack,
'auth' => 'google_auth',
] + $httpClientOptions);
default:
throw new \Exception('Version not supported');
if (self::getGuzzleMajorVersion() === 5) {
$client = new \GuzzleHttp\Client($httpClientOptions);
$client->setDefaultOption('auth', 'google_auth');
$subscriber = new Subscriber\AuthTokenSubscriber(
$fetcher,
$httpHandler,
$tokenCallback
);
$client->getEmitter()->attach($subscriber);
return $client;
}
$middleware = new Middleware\AuthTokenMiddleware(
$fetcher,
$httpHandler,
$tokenCallback
);
$stack = \GuzzleHttp\HandlerStack::create();
$stack->push($middleware);
return new \GuzzleHttp\Client([
'handler' => $stack,
'auth' => 'google_auth',
] + $httpClientOptions);
}
/**