semrush-options-action.php
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Yoast\WP\SEO\Actions\SEMrush;
use Yoast\WP\SEO\Helpers\Options_Helper;
/**
* Class SEMrush_Options_Action
*/
class SEMrush_Options_Action {
/**
* The Options_Helper instance.
*
* @var Options_Helper
*/
protected $options_helper;
/**
* SEMrush_Options_Action constructor.
*
* @param Options_Helper $options_helper The WPSEO options helper.
*/
public function __construct( Options_Helper $options_helper ) {
$this->options_helper = $options_helper;
}
/**
* Stores SEMrush country code in the WPSEO options.
*
* @param string $country_code The country code to store.
*
* @return object The response object.
*/
public function set_country_code( $country_code ) {
// The country code has already been validated at this point. No need to do that again.
$success = $this->options_helper->set( 'semrush_country_code', $country_code );
if ( $success ) {
return (object) [
'success' => true,
'status' => 200,
];
}
return (object) [
'success' => false,
'status' => 500,
'error' => 'Could not save option in the database',
];
}
}