ajax
5 months ago
assets
5 months ago
includes
5 months ago
pages
5 months ago
activation.php
5 months ago
boot.php
5 months ago
index.php
3 years ago
activation.php
96 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Activator for the Robin image optimizer |
| 5 | * |
| 6 | * @see Factory480_Activator |
| 7 | * @version 1.0 |
| 8 | */ |
| 9 | |
| 10 | // Exit if accessed directly |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; |
| 13 | } |
| 14 | |
| 15 | class WIO_Activation extends Wbcr_Factory480_Activator { |
| 16 | |
| 17 | /** |
| 18 | * Runs activation actions. |
| 19 | * |
| 20 | * @since 1.0.0 |
| 21 | * @throws \Exception |
| 22 | */ |
| 23 | public function activate() { |
| 24 | WRIO_Plugin::app()->logger->info( 'Parent plugin start installation!' ); |
| 25 | |
| 26 | WRIO_Plugin::app()->updatePopulateOption( 'backup_origin_images', 1 ); |
| 27 | WRIO_Plugin::app()->updatePopulateOption( 'save_exif_data', 1 ); |
| 28 | |
| 29 | // Enable auto-optimize on upload by default for new installations only. |
| 30 | if ( 0 === $this->get_plugin_version_in_db() ) { |
| 31 | WRIO_Plugin::app()->updatePopulateOption( 'auto_optimize_when_upload', 1 ); |
| 32 | WRIO_Plugin::app()->updatePopulateOption( 'convert_webp_format', 1 ); |
| 33 | } |
| 34 | |
| 35 | if ( function_exists( 'wrio_is_license_activate' ) && wrio_is_license_activate() ) { |
| 36 | WRIO_Plugin::app()->logger->info( 'Premium plugin start installation!' ); |
| 37 | require_once WRIO_PLUGIN_DIR . '/libs/addons/robin-image-optimizer-premium.php'; |
| 38 | wrio_premium_activate(); |
| 39 | WRIO_Plugin::app()->logger->info( 'Premium plugin installation complete!' ); |
| 40 | } |
| 41 | |
| 42 | $db_version = RIO_Process_Queue::get_db_version(); |
| 43 | $plugin_version_in_db = $this->get_plugin_version_in_db(); |
| 44 | $current_plugin_version = $this->plugin->getPluginVersion(); |
| 45 | |
| 46 | $create_table_log_message = "Plugin installation: try create plugin tables.\r\n"; |
| 47 | $create_table_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-DB Version: {$db_version}\r\n"; |
| 48 | $create_table_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Plugin Version in DB: {$plugin_version_in_db}\r\n"; |
| 49 | $create_table_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Current Plugin Version: {$current_plugin_version}"; |
| 50 | |
| 51 | WRIO_Plugin::app()->logger->info( $create_table_log_message ); |
| 52 | |
| 53 | RIO_Process_Queue::try_create_plugin_tables(); |
| 54 | |
| 55 | WBCR\Factory_Templates_134\Helpers::flushPageCache(); |
| 56 | |
| 57 | WRIO_Plugin::app()->logger->info( 'Parent plugin installation complete!' ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Get previous plugin version |
| 62 | * |
| 63 | * @since 1.3.8 |
| 64 | * @return number |
| 65 | */ |
| 66 | public function get_plugin_version_in_db() { |
| 67 | if ( WRIO_Plugin::app()->isNetworkActive() ) { |
| 68 | return get_site_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 ); |
| 69 | } |
| 70 | |
| 71 | return get_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 ); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Runs activation actions. |
| 76 | * |
| 77 | * @since 1.0.0 |
| 78 | */ |
| 79 | public function deactivate() { |
| 80 | WRIO_Plugin::app()->logger->info( 'Parent plugin start deactivation!' ); |
| 81 | |
| 82 | if ( class_exists( 'WRIO_Cron' ) ) { |
| 83 | WRIO_Cron::stop(); |
| 84 | } |
| 85 | |
| 86 | if ( function_exists( 'wrio_is_license_activate' ) && wrio_is_license_activate() ) { |
| 87 | WRIO_Plugin::app()->logger->info( 'Premium plugin start deactivation!' ); |
| 88 | require_once WRIO_PLUGIN_DIR . '/libs/addons/robin-image-optimizer-premium.php'; |
| 89 | wrio_premium_deactivate(); |
| 90 | WRIO_Plugin::app()->logger->info( 'Premium plugin deactivation complete!' ); |
| 91 | } |
| 92 | |
| 93 | WRIO_Plugin::app()->logger->info( 'Parent plugin deactivation complete!' ); |
| 94 | } |
| 95 | } |
| 96 |