abstracts
1 day ago
admin
1 week ago
ads
1 week ago
compatibility
1 week ago
crons
1 week ago
frontend
1 week ago
groups
1 day ago
importers
1 day ago
installation
1 year ago
interfaces
5 months ago
license
3 months ago
placements
1 week ago
rest
1 day ago
traits
1 week ago
utilities
1 week ago
cap_map.php
3 years ago
class-assets-registry.php
4 weeks ago
class-autoloader.php
1 week ago
class-cache-invalidator.php
1 week ago
class-constants.php
1 year ago
class-content-injector.php
4 weeks ago
class-entities.php
3 months ago
class-modal.php
1 year ago
class-modules.php
1 year ago
class-options.php
1 year ago
class-plugin.php
1 week ago
class-post-data.php
10 months ago
class-shortcodes.php
1 week ago
class-upgrades.php
1 day ago
class-widget.php
11 months ago
default-hooks.php
5 months ago
functions-ad.php
1 week ago
functions-components.php
3 months ago
functions-conditional.php
1 year ago
functions-core.php
1 year ago
functions-group.php
1 day ago
functions-placement.php
1 week ago
functions.php
1 week ago
index.php
2 years ago
load_modules.php
2 years ago
class-upgrades.php
91 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 | '2.0.9' => 'upgrade-2.0.9.php', |
| 39 | ]; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get folder path |
| 44 | * |
| 45 | * @since 1.0.0 |
| 46 | * |
| 47 | * @return string |
| 48 | */ |
| 49 | public function get_folder(): string { |
| 50 | return ADVADS_ABSPATH . 'upgrades/'; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Get plugin version number |
| 55 | * |
| 56 | * @since 1.0.0 |
| 57 | * |
| 58 | * @return string |
| 59 | */ |
| 60 | public function get_version(): string { |
| 61 | return self::DB_VERSION; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get plugin option name. |
| 66 | * |
| 67 | * @since 1.0.0 |
| 68 | * |
| 69 | * @return string |
| 70 | */ |
| 71 | public function get_option_name(): string { |
| 72 | return 'advanced_ads_db_version'; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Runs this initializer. |
| 77 | * |
| 78 | * @return void |
| 79 | */ |
| 80 | public function initialize(): void { |
| 81 | // Force run the upgrades. |
| 82 | $is_first_time = empty( $this->get_installed_version() ); |
| 83 | $this->hooks(); |
| 84 | |
| 85 | if ( $is_first_time ) { |
| 86 | update_option( $this->get_option_name(), '1.0.0' ); |
| 87 | add_action( 'admin_init', [ $this, 'perform_updates' ] ); |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 |