PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / 2.0.6
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF v2.0.6
2.0.6 2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / migrations / 010300.php
robin-image-optimizer / migrations Last commit date
010009.php 7 months ago 010300.php 7 months ago 010306.php 7 months ago 010309.php 7 months ago 010402.php 7 months ago 010501.php 3 months ago 010802.php 7 months ago 010803.php 3 months ago index.php 3 years ago
010300.php
84 lines
1 <?php #comp-page builds: premium
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * Updates for altering the table used to store statistics data.
10 * Adds new columns and renames existing ones in order to add support for the new social buttons.
11 */
12 class WIOUpdate010300 extends Wbcr_Factory600_Update {
13
14 /**
15 * @since 1.3.6
16 * @throws \Exception
17 */
18 public function install() {
19
20 $db_version = RIO_Process_Queue::get_db_version();
21 $plugin_version_in_db = $this->get_plugin_version_in_db();
22 $current_plugin_version = $this->plugin->getPluginVersion();
23
24 $init_log_message = "Start plugin migration < %s.\r\n";
25 $init_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";
26 $init_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";
27 $init_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}";
28
29 WRIO_Plugin::app()->logger->info( sprintf( $init_log_message, '1.3.0' ) );
30
31 RIO_Process_Queue::try_create_plugin_tables();
32
33 $this->clear_log();
34
35 WRIO_Plugin::app()->deleteOption( 'cron_running' );
36
37 if ( class_exists( 'WRIO_Cron' ) ) {
38 WRIO_Cron::stop();
39 }
40
41 WBCR\Factory_Templates_759\Helpers::flushPageCache();
42
43 WRIO_Plugin::app()->logger->info( 'Plugin migration was successfull!' );
44 }
45
46 /**
47 * Get previous plugin version
48 *
49 * @since 1.3.8
50 * @return number
51 */
52 public function get_plugin_version_in_db() {
53 if ( WRIO_Plugin::app()->isNetworkActive() ) {
54 return get_site_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
55 }
56
57 return get_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
58 }
59
60 /**
61 * Since version 1.3.0, we use a different path and a different algorithm for
62 * accumulating log files. Therefore, if there is an old log file, you need to clear it.
63 *
64 * @since 1.3.6
65 */
66 public function clear_log() {
67 $wp_upload_dir = wp_upload_dir();
68
69 if ( isset( $wp_upload_dir['error'] ) && $wp_upload_dir['error'] !== false ) {
70 WRIO_Plugin::app()->logger->error( sprintf( 'Plugin migration error: %s', $wp_upload_dir['error'] ) );
71
72 return;
73 }
74
75 $file_path = wp_normalize_path( trailingslashit( $wp_upload_dir['basedir'] ) . 'wio.log' );
76
77 if ( file_exists( $file_path ) ) {
78 if ( @unlink( $file_path ) ) {
79 WRIO_Plugin::app()->logger->info( 'Plugin migration: The old error log was successfully deleted!' );
80 }
81 }
82 }
83 }
84