updates
1 month ago
Admin.php
1 month ago
Ajax.php
1 month ago
Customizer.php
1 month ago
Elementor.php
1 month ago
Enqueue.php
1 month ago
Hooks.php
1 month ago
Install.php
1 month ago
Main.php
1 month ago
Update.php
1 month ago
functions.php
1 month ago
Update.php
58 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AI1WPSA; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | class Update { |
| 8 | |
| 9 | /** |
| 10 | * The upgrades |
| 11 | * |
| 12 | * @var array |
| 13 | */ |
| 14 | private static $upgrades = array('1.0.2'); |
| 15 | |
| 16 | public function installed_version() { |
| 17 | return get_option('ai1wpsa_version'); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Check if the plugin needs any update |
| 22 | * |
| 23 | * @return boolean |
| 24 | */ |
| 25 | public function needs_update() { |
| 26 | // may be it's the first install |
| 27 | if (empty($this->installed_version())) { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | //if previous version is higher |
| 32 | if (version_compare($this->installed_version(), AI1WPSA_VERSION, '>')) { |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Perform all the necessary upgrade routines |
| 41 | * |
| 42 | * @return void |
| 43 | */ |
| 44 | public function perform_updates() { |
| 45 | foreach (self::$upgrades as $version) { |
| 46 | if (version_compare($this->installed_version(), $version, '>')) { |
| 47 | $file = AI1WPSA_INCLUDES . "/updates/Update-$version.php"; |
| 48 | |
| 49 | if (file_exists($file)) { |
| 50 | include_once $file; |
| 51 | } |
| 52 | |
| 53 | update_option('ai1wpsa_version', $version); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 |