Site.php
998 Bytes
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
<?php
namespace AC\Plugin\Updater;
use AC\Plugin\Updater;
use AC\Plugin\Version;
use AC\Plugin\VersionStorage;
class Site extends Updater {
/**
* @var Version
*/
protected $version;
/**
* @var VersionStorage
*/
private $storage;
public function __construct( $version_key, Version $version ) {
$this->version = $version;
$this->storage = new VersionStorage( (string) $version_key );
// TODO add VersionStorage for previous storage
}
/**
* @return Version
*/
public function get_stored_version() {
return $this->storage->get();
}
protected function update_stored_version( Version $version = null ) {
$this->storage->save( $version ?: $this->version );
}
public function is_new_install() {
global $wpdb;
if ( $this->storage->get()->is_valid() ) {
return false;
}
// Before version 3.0.5
$results = $wpdb->get_results( "SELECT option_id FROM $wpdb->options WHERE option_name LIKE 'cpac_options_%' LIMIT 1" );
return empty( $results );
}
}