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 / 010309.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
010309.php
89 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 WIOUpdate010309 extends Wbcr_Factory600_Update {
13
14 /**
15 * {inherit}
16 *
17 * @since 1.3.9
18 */
19 public function install() {
20
21 $db_version = RIO_Process_Queue::get_db_version();
22 $plugin_version_in_db = $this->get_plugin_version_in_db();
23 $current_plugin_version = $this->plugin->getPluginVersion();
24
25 $init_log_message = "Start plugin migration < %s.\r\n";
26 $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";
27 $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";
28 $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}";
29
30 WRIO_Plugin::app()->logger->info( sprintf( $init_log_message, '1.3.9' ) );
31
32 $this->add_indexes_in_db();
33
34 WBCR\Factory_Templates_759\Helpers::flushPageCache();
35
36 WRIO_Plugin::app()->logger->info( 'Plugin migration was successfull!' );
37 }
38
39 /**
40 * Get previous plugin version
41 *
42 * @return number
43 * @since 1.3.9
44 */
45 public function get_plugin_version_in_db() {
46 if ( WRIO_Plugin::app()->isNetworkActive() ) {
47 return get_site_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
48 }
49
50 return get_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
51 }
52
53 /**
54 * In older plugin relises, the option 'plugin_activated' did not exist. Therefore,
55 * if during migration it still does not exist, you need to add option with the current timestamp.
56 *
57 * @since 1.3.9
58 */
59 public function update_plugin_activation_time() {
60 if ( $this->plugin->isNetworkActive() ) {
61 $activated = get_site_option( $this->plugin->getOptionName( 'plugin_activated' ), 0 );
62 } else {
63 $activated = get_option( $this->plugin->getOptionName( 'plugin_activated' ), 0 );
64 }
65
66 if ( ! $activated ) {
67 if ( $this->plugin->isNetworkActive() ) {
68 update_site_option( $this->plugin->getOptionName( 'plugin_activated' ), time() );
69 update_site_option( $this->plugin->getOptionName( 'plugin_version' ), $this->plugin->getPluginVersion() );
70 } else {
71 update_option( $this->plugin->getOptionName( 'plugin_activated' ), time() );
72 update_option( $this->plugin->getOptionName( 'plugin_version' ), $this->plugin->getPluginVersion() );
73 }
74 }
75 }
76
77 /**
78 * Get previous plugin version
79 *
80 * @since 1.3.9
81 */
82 public function add_indexes_in_db() {
83 global $wpdb;
84
85 $table_name = RIO_Process_Queue::table_name();
86 $wpdb->query( "ALTER TABLE {$table_name} ADD INDEX `index-type-attachments` (`object_id`, `item_type`);" );
87 }
88 }
89