: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace Yoast\WP\SEO\Actions\SEMrush;
use Yoast\WP\SEO\Config\SEMrush_Client;
use Yoast\WP\SEO\Exceptions\OAuth\Authentication_Failed_Exception;
* Class SEMrush_Login_Action
class SEMrush_Login_Action {
* The SEMrush_Client instance.
* SEMrush_Login_Action constructor.
* @param SEMrush_Client $client The API client.
public function __construct( SEMrush_Client $client ) {
* Authenticates with SEMrush to request the necessary tokens.
* @param string $code The authentication code to use to request a token with.
* @return object The response object.
public function authenticate( $code ) {
// Code has already been validated at this point. No need to do that again.
$tokens = $this->client->request_tokens( $code );
'tokens' => $tokens->to_array(),
} catch ( Authentication_Failed_Exception $e ) {
return $e->get_response();
* Performs the login request, if necessary.
public function login() {
if ( $this->client->has_valid_tokens() ) {
// Prompt with login screen.