Site.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Plugin\Setup; |
| 6 | |
| 7 | use AC\Plugin\InstallCollection; |
| 8 | use AC\Plugin\Setup; |
| 9 | use AC\Plugin\UpdateCollection; |
| 10 | use AC\Plugin\Version; |
| 11 | use AC\Storage\Option; |
| 12 | |
| 13 | final class Site extends Setup |
| 14 | { |
| 15 | public function __construct( |
| 16 | Option $storage, |
| 17 | Version $version, |
| 18 | ?InstallCollection $installers = null, |
| 19 | ?UpdateCollection $updates = null |
| 20 | ) { |
| 21 | parent::__construct($storage, $version, $installers, $updates); |
| 22 | } |
| 23 | |
| 24 | protected function is_new_install(): bool |
| 25 | { |
| 26 | global $wpdb; |
| 27 | |
| 28 | $sql = " |
| 29 | SELECT option_id |
| 30 | FROM $wpdb->options |
| 31 | WHERE option_name LIKE 'cpac_options_%' LIMIT 1 |
| 32 | "; |
| 33 | |
| 34 | $results = $wpdb->get_results($sql); |
| 35 | |
| 36 | if ($results) { |
| 37 | return false; |
| 38 | } |
| 39 | |
| 40 | return ! $this->get_stored_version()->is_valid(); |
| 41 | } |
| 42 | |
| 43 | } |
| 44 |