PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | includes/class-wpo-activation.php +34 -3 4.6.1 → 4.7.0 View file →
@@ -5,13 +5,21 @@
5 5
6 6 class WPO_Activation {
7 7
8 8 /**
9 + * Flag to prevent multiple silence activation actions from running when the plugin is reactivated.
10 + *
11 + * @var bool
12 + */
13 + private static $silence_activation_actions_done = false;
14 +
15 + /**
9 16 * Actions to be performed upon plugin activation
10 17 *
11 18 * @return void
12 19 */
13 20 public static function actions(): void {
21 +
14 22 self::check_minimum_requirements();
15 23 self::check_user_capability();
16 24 self::handle_activation_type();
17 25
@@ -21,10 +29,29 @@
21 29 WP_Optimize()->get_browser_cache()->restore();
22 30 WP_Optimize()->get_table_management()->create_plugin_tables();
23 31 WP_Optimize()->get_webp_instance()->plugin_activate();
24 32
33 + WP_Optimize_Page_Cache_Preloader::instance()->maybe_reschedule_preload_on_activation();
34 +
25 35 self::init_batch_processing();
36 + self::silence_activation_actions();
37 + }
38 +
39 + /**
40 + * When user uploads a plugin zip file on already activated plugin, WordPress doesn't run the activation hook.
41 + * This method is used to perform the necessary activation actions in such cases.
42 + *
43 + * @return void
44 + */
45 + public static function silence_activation_actions(): void {
46 + if (self::$silence_activation_actions_done) {
47 + return;
48 + }
49 +
50 + WP_Optimize()->cron_activate();
26 51 self::maybe_init_premium();
52 +
53 + self::$silence_activation_actions_done = true;
27 54 }
28 55
29 56 /**
30 57 * Check if minimum requirements are met, deactivate and die if not
@@ -55,10 +82,11 @@
55 82 *
56 83 * @return void
57 84 */
58 85 private static function handle_activation_type(): void {
86 + // Always record first-activation timestamp (no-ops if already set).
87 + self::set_as_newly_activated();
59 88 if (!self::is_reactivated()) {
60 - self::set_as_newly_activated();
61 89 WP_Optimize()->get_onboarding()->activate_onboarding_wizard();
62 90 }
63 91 }
64 92
@@ -82,14 +110,17 @@
82 110 return (bool) WP_Optimize()->get_options()->get_option('last-optimized');
83 111 }
84 112
85 113 /**
86 - * Set plugin option `newly-activated` as `true`
114 + * Records the first-ever activation timestamp.
115 + * No-ops if already set, so the original install date is never overwritten on reactivation.
87 116 *
88 117 * @return void
89 118 */
90 119 private static function set_as_newly_activated(): void {
91 - WP_Optimize()->get_options()->update_option('newly-activated', true);
120 + if (!WP_Optimize()->get_options()->get_option('newly-activated')) {
121 + WP_Optimize()->get_options()->update_option('newly-activated', time());
122 + }
92 123 }
93 124
94 125 /**
95 126 * Make use of Task Manager library