| @@ -1,15 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace WPAdminify\Inc\Classes; |
| 4 | 4 | |
| 5 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | - exit; // Exit if accessed directly. | |
| 7 | -} | |
| 5 | +class Upgrade { | |
| 8 | 6 | |
| 9 | -class Upgrade | |
| 10 | -{ | |
| 11 | - | |
| 12 | 7 | /** |
| 13 | 8 | * Plugin version option key |
| 14 | 9 | * |
| 15 | 10 | * @var string $option_name |
| @@ -21,12 +16,10 @@ | ||
| 21 | 16 | * |
| 22 | 17 | * @var string[] $upgrades |
| 23 | 18 | */ |
| 24 | 19 | protected $upgrades = [ |
| 25 | - '3.0.2' => 'Upgrades/upgrade-3.0.2.php', | |
| 26 | - '3.0.9' => 'Upgrades/upgrade-3.0.9.php', | |
| 27 | - '3.2.4.4' => 'Upgrades/upgrade-3.2.4.4.php', | |
| 28 | - '4.0.1' => 'Upgrades/upgrade-4.0.php' | |
| 20 | + '3.0.2' => 'Upgrades/upgrade-3.0.2.php', | |
| 21 | + '3.0.9' => 'Upgrades/upgrade-3.0.9.php', | |
| 29 | 22 | ]; |
| 30 | 23 | |
| 31 | 24 | /** |
| 32 | 25 | * Get plugin installed version |
| @@ -32,11 +25,10 @@ | ||
| 32 | 25 | * Get plugin installed version |
| 33 | 26 | * |
| 34 | 27 | * @return string |
| 35 | 28 | */ |
| 36 | - protected function get_installed_version() | |
| 37 | - { | |
| 38 | - return get_option($this->option_name, '1.0.0'); | |
| 29 | + protected function get_installed_version() { | |
| 30 | + return get_option( $this->option_name, '1.0.0' ); | |
| 39 | 31 | } |
| 40 | 32 | |
| 41 | 33 | /** |
| 42 | 34 | * Check if plugin's update is available |
| @@ -42,11 +34,10 @@ | ||
| 42 | 34 | * Check if plugin's update is available |
| 43 | 35 | * |
| 44 | 36 | * @return bool |
| 45 | 37 | */ |
| 46 | - public function if_updates_available() | |
| 47 | - { | |
| 48 | - if (version_compare($this->get_installed_version(), WP_ADMINIFY_VER, '<')) { | |
| 38 | + public function if_updates_available() { | |
| 39 | + if ( version_compare( $this->get_installed_version(), WP_ADMINIFY_VER, '<' ) ) { | |
| 49 | 40 | return true; |
| 50 | 41 | } |
| 51 | 42 | |
| 52 | 43 | return false; |
| @@ -56,15 +47,14 @@ | ||
| 56 | 47 | * Run plugin updates |
| 57 | 48 | * |
| 58 | 49 | * @return void |
| 59 | 50 | */ |
| 60 | - public function run_updates() | |
| 61 | - { | |
| 51 | + public function run_updates() { | |
| 62 | 52 | $installed_version = $this->get_installed_version(); |
| 63 | - $path = trailingslashit(__DIR__); | |
| 53 | + $path = trailingslashit( __DIR__ ); | |
| 64 | 54 | |
| 65 | - foreach ($this->upgrades as $version => $file) { | |
| 66 | - if (version_compare($installed_version, $version, '<')) { | |
| 55 | + foreach ( $this->upgrades as $version => $file ) { | |
| 56 | + if ( version_compare( $installed_version, $version, '<' ) ) { | |
| 67 | 57 | include $path . $file; |
| 68 | 58 | } |
| 69 | 59 | } |
| 70 | 60 | |
| @@ -69,5 +59,6 @@ | ||
| 69 | 59 | } |
| 70 | 60 | |
| 71 | 61 | // update_option( $this->option_name, WP_ADMINIFY_VER ); |
| 72 | 62 | } |
| 63 | + | |
| 73 | 64 | } |