Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../src/config
File: wincher-client.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Config;
[2] Fix | Delete
[3] Fix | Delete
use WPSEO_Utils;
[4] Fix | Delete
use Yoast\WP\SEO\Exceptions\OAuth\Authentication_Failed_Exception;
[5] Fix | Delete
use Yoast\WP\SEO\Exceptions\OAuth\Tokens\Empty_Property_Exception;
[6] Fix | Delete
use Yoast\WP\SEO\Exceptions\OAuth\Tokens\Empty_Token_Exception;
[7] Fix | Delete
use Yoast\WP\SEO\Helpers\Options_Helper;
[8] Fix | Delete
use Yoast\WP\SEO\Values\OAuth\OAuth_Token;
[9] Fix | Delete
use Yoast\WP\SEO\Wrappers\WP_Remote_Handler;
[10] Fix | Delete
use YoastSEO_Vendor\GuzzleHttp\Client;
[11] Fix | Delete
use YoastSEO_Vendor\League\OAuth2\Client\Provider\Exception\IdentityProviderException;
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Class Wincher_Client
[15] Fix | Delete
*/
[16] Fix | Delete
class Wincher_Client extends OAuth_Client {
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* The option's key.
[20] Fix | Delete
*/
[21] Fix | Delete
public const TOKEN_OPTION = 'wincher_tokens';
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Name of the temporary PKCE cookie.
[25] Fix | Delete
*/
[26] Fix | Delete
public const PKCE_TRANSIENT_NAME = 'yoast_wincher_pkce';
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* The WP_Remote_Handler instance.
[30] Fix | Delete
*
[31] Fix | Delete
* @var WP_Remote_Handler
[32] Fix | Delete
*/
[33] Fix | Delete
protected $wp_remote_handler;
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Wincher_Client constructor.
[37] Fix | Delete
*
[38] Fix | Delete
* @param Options_Helper $options_helper The Options_Helper instance.
[39] Fix | Delete
* @param WP_Remote_Handler $wp_remote_handler The request handler.
[40] Fix | Delete
*
[41] Fix | Delete
* @throws Empty_Property_Exception Exception thrown if a token property is empty.
[42] Fix | Delete
*/
[43] Fix | Delete
public function __construct(
[44] Fix | Delete
Options_Helper $options_helper,
[45] Fix | Delete
WP_Remote_Handler $wp_remote_handler
[46] Fix | Delete
) {
[47] Fix | Delete
[48] Fix | Delete
$provider = new Wincher_PKCE_Provider(
[49] Fix | Delete
[
[50] Fix | Delete
'clientId' => 'yoast',
[51] Fix | Delete
'redirectUri' => 'https://auth.wincher.com/yoast/setup',
[52] Fix | Delete
'urlAuthorize' => 'https://auth.wincher.com/connect/authorize',
[53] Fix | Delete
'urlAccessToken' => 'https://auth.wincher.com/connect/token',
[54] Fix | Delete
'urlResourceOwnerDetails' => 'https://api.wincher.com/beta/user',
[55] Fix | Delete
'scopes' => [ 'profile', 'account', 'websites:read', 'websites:write', 'offline_access' ],
[56] Fix | Delete
'scopeSeparator' => ' ',
[57] Fix | Delete
'pkceMethod' => 'S256',
[58] Fix | Delete
],
[59] Fix | Delete
[
[60] Fix | Delete
'httpClient' => new Client( [ 'handler' => $wp_remote_handler ] ),
[61] Fix | Delete
]
[62] Fix | Delete
);
[63] Fix | Delete
[64] Fix | Delete
parent::__construct(
[65] Fix | Delete
self::TOKEN_OPTION,
[66] Fix | Delete
$provider,
[67] Fix | Delete
$options_helper
[68] Fix | Delete
);
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Return the authorization URL.
[73] Fix | Delete
*
[74] Fix | Delete
* @return string The authentication URL.
[75] Fix | Delete
*/
[76] Fix | Delete
public function get_authorization_url() {
[77] Fix | Delete
$parsed_site_url = \wp_parse_url( \get_site_url() );
[78] Fix | Delete
[79] Fix | Delete
$url = $this->provider->getAuthorizationUrl(
[80] Fix | Delete
[
[81] Fix | Delete
'state' => WPSEO_Utils::format_json_encode( [ 'domain' => $parsed_site_url['host'] ] ),
[82] Fix | Delete
]
[83] Fix | Delete
);
[84] Fix | Delete
[85] Fix | Delete
$pkce_code = $this->provider->getPkceCode();
[86] Fix | Delete
[87] Fix | Delete
// Store a transient value with the PKCE code that we need in order to
[88] Fix | Delete
// exchange the returned code for a token after authorization.
[89] Fix | Delete
\set_transient( self::PKCE_TRANSIENT_NAME, $pkce_code, \DAY_IN_SECONDS );
[90] Fix | Delete
[91] Fix | Delete
return $url;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Requests the access token and refresh token based on the passed code.
[96] Fix | Delete
*
[97] Fix | Delete
* @param string $code The code to send.
[98] Fix | Delete
*
[99] Fix | Delete
* @return OAuth_Token The requested tokens.
[100] Fix | Delete
*
[101] Fix | Delete
* @throws Authentication_Failed_Exception Exception thrown if authentication has failed.
[102] Fix | Delete
*/
[103] Fix | Delete
public function request_tokens( $code ) {
[104] Fix | Delete
$pkce_code = \get_transient( self::PKCE_TRANSIENT_NAME );
[105] Fix | Delete
if ( $pkce_code ) {
[106] Fix | Delete
$this->provider->setPkceCode( $pkce_code );
[107] Fix | Delete
}
[108] Fix | Delete
return parent::request_tokens( $code );
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Performs the specified request.
[113] Fix | Delete
*
[114] Fix | Delete
* @codeCoverageIgnore
[115] Fix | Delete
*
[116] Fix | Delete
* @param string $method The HTTP method to use.
[117] Fix | Delete
* @param string $url The URL to send the request to.
[118] Fix | Delete
* @param array $options The options to pass along to the request.
[119] Fix | Delete
*
[120] Fix | Delete
* @return mixed The parsed API response.
[121] Fix | Delete
*
[122] Fix | Delete
* @throws IdentityProviderException Exception thrown if there's something wrong with the identifying data.
[123] Fix | Delete
* @throws Authentication_Failed_Exception Exception thrown if authentication has failed.
[124] Fix | Delete
* @throws Empty_Token_Exception Exception thrown if the token is empty.
[125] Fix | Delete
*/
[126] Fix | Delete
protected function do_request( $method, $url, array $options ) {
[127] Fix | Delete
$options['headers'] = [ 'Content-Type' => 'application/json' ];
[128] Fix | Delete
return parent::do_request( $method, $url, $options );
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function