class-wpml-tm-upgrade-wpml-site-id-ate.php
1.5 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Upgrades the former option to the new one.
*/
class WPML_TM_Upgrade_WPML_Site_ID_ATE implements IWPML_Upgrade_Command {
/**
* Runs the upgrade process.
*
* @return bool
*/
public function run() {
if ( $this->must_run() ) {
$site_id = new WPML_Site_ID();
$old_value = $site_id->get_site_id( WPML_Site_ID::SITE_SCOPES_GLOBAL );
return update_option( WPML_Site_ID::SITE_ID_KEY . ':' . WPML_TM_ATE::SITE_ID_SCOPE, $old_value, false );
}
return true;
}
/**
* True if all conditions are met.
*
* @return bool
*/
private function must_run() {
return WPML_TM_ATE_Status::is_enabled_and_activated() && (bool) get_option( WPML_TM_Wizard_Options::WIZARD_COMPLETE_FOR_MANAGER, false ) && $this->site_id_ate_does_not_exist();
}
/**
* Checks has the old option.
*
* @return bool
*/
protected function site_id_ate_does_not_exist() {
get_option( WPML_Site_ID::SITE_ID_KEY . ':' . WPML_TM_ATE::SITE_ID_SCOPE, null );
$notoptions = wp_cache_get( 'notoptions', 'options' );
return ( array_key_exists( WPML_Site_ID::SITE_ID_KEY . ':' . WPML_TM_ATE::SITE_ID_SCOPE, $notoptions ) );
}
/**
* Runs in admin pages.
*
* @return bool
*/
public function run_admin() {
return $this->run();
}
/**
* Unused.
*
* @return null
*/
public function run_ajax() {
return null;
}
/**
* Unused.
*
* @return null
*/
public function run_frontend() {
return null;
}
/**
* Unused.
*
* @return null
*/
public function get_results() {
return null;
}
}