abstracts
9 months ago
admin
10 months ago
ads
9 months ago
compatibility
9 months ago
crons
1 year ago
frontend
11 months ago
groups
1 year ago
importers
1 year ago
installation
1 year ago
interfaces
1 year ago
placements
1 year ago
rest
1 year ago
traits
1 year ago
utilities
11 months ago
array_ad_conditions.php
1 year ago
cap_map.php
3 years ago
class-assets-registry.php
1 year ago
class-autoloader.php
1 year ago
class-constants.php
1 year ago
class-entities.php
1 year ago
class-modal.php
1 year ago
class-modules.php
1 year ago
class-options.php
1 year ago
class-plugin.php
1 year ago
class-post-data.php
10 months ago
class-shortcodes.php
1 year ago
class-upgrades.php
1 year ago
class-widget.php
11 months ago
default-hooks.php
1 year ago
functions-ad.php
1 year ago
functions-conditional.php
1 year ago
functions-core.php
1 year ago
functions-group.php
1 year ago
functions-placement.php
1 year ago
functions.php
1 year ago
index.php
2 years ago
load_modules.php
2 years ago
class-upgrades.php
90 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Upgrades. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.48.2 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds; |
| 11 | |
| 12 | use AdvancedAds\Framework\Updates; |
| 13 | use AdvancedAds\Framework\Interfaces\Initializer_Interface; |
| 14 | |
| 15 | defined( 'ABSPATH' ) || exit; |
| 16 | |
| 17 | /** |
| 18 | * Upgrades. |
| 19 | */ |
| 20 | class Upgrades extends Updates implements Initializer_Interface { |
| 21 | |
| 22 | const DB_VERSION = '1.53.1'; |
| 23 | |
| 24 | /** |
| 25 | * Get updates that need to run. |
| 26 | * |
| 27 | * @since 1.0.0 |
| 28 | * |
| 29 | * @return array |
| 30 | */ |
| 31 | public function get_updates(): array { |
| 32 | return [ |
| 33 | '1.48.4' => 'upgrade-1.48.4.php', |
| 34 | '1.48.5' => 'upgrade-1.48.5.php', |
| 35 | '1.52.1' => 'upgrade-1.52.1.php', |
| 36 | '2.0.0' => 'upgrade-2.0.0.php', |
| 37 | '2.0.8' => 'upgrade-2.0.8.php', |
| 38 | ]; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get folder path |
| 43 | * |
| 44 | * @since 1.0.0 |
| 45 | * |
| 46 | * @return string |
| 47 | */ |
| 48 | public function get_folder(): string { |
| 49 | return ADVADS_ABSPATH . 'upgrades/'; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Get plugin version number |
| 54 | * |
| 55 | * @since 1.0.0 |
| 56 | * |
| 57 | * @return string |
| 58 | */ |
| 59 | public function get_version(): string { |
| 60 | return self::DB_VERSION; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Get plugin option name. |
| 65 | * |
| 66 | * @since 1.0.0 |
| 67 | * |
| 68 | * @return string |
| 69 | */ |
| 70 | public function get_option_name(): string { |
| 71 | return 'advanced_ads_db_version'; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Runs this initializer. |
| 76 | * |
| 77 | * @return void |
| 78 | */ |
| 79 | public function initialize(): void { |
| 80 | // Force run the upgrades. |
| 81 | $is_first_time = empty( $this->get_installed_version() ); |
| 82 | $this->hooks(); |
| 83 | |
| 84 | if ( $is_first_time ) { |
| 85 | update_option( $this->get_option_name(), '1.0.0' ); |
| 86 | add_action( 'admin_init', [ $this, 'perform_updates' ] ); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 |