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-wp-optimize-updates.php +94 -11 4.5.3 → 4.7.0 View file →
@@ -38,14 +38,19 @@
38 38 ),
39 39 '3.7.0' => array('update_370_disable_auto_preload_after_purge_feature'),
40 40 '3.8.0' => array('update_380_404_detector_table_create'),
41 41 '4.3.1' => array(
42 - 'update_431_update_browser_cache_htaccess_config',
43 42 'update_431_db_table_analysis_wipe_usage_data',
44 43 ),
45 44 '4.4.0' => array(
46 45 'update_440_change_plugin_json_permissions',
47 46 ),
47 + '4.6.1' => array(
48 + 'update_461_update_post_meta_keys',
49 + ),
50 + '4.7.0' => array(
51 + 'update_470_update_browser_cache_htaccess_config',
52 + ),
48 53 );
49 54
50 55 /**
51 56 * See if any database schema updates are needed, and perform them if so.
@@ -67,8 +72,22 @@
67 72 }
68 73 }
69 74 update_option('wpo_update_version', WPO_VERSION);
70 75 }
76 +
77 + $wpo_version = get_option('wpo_version');
78 +
79 + // If the wpo_version option is not set, but the db_version is, we assume that the wpo_version should be set to the db_version.
80 + if (!$wpo_version) {
81 + $wpo_version = $db_version ?: WPO_VERSION;
82 + update_option('wpo_version', $wpo_version);
83 + }
84 +
85 + if ($wpo_version && version_compare($our_version, $wpo_version, '!=')) {
86 + update_option('wpo_version', WPO_VERSION);
87 + // Trigger the activation actions to ensure that any necessary setup is performed when the version changes.
88 + WPO_Activation::silence_activation_actions();
89 + }
71 90 }
72 91
73 92 /**
74 93 * Delete old semaphore locks from options database table.
@@ -346,18 +365,8 @@
346 365 WP_Optimize()->get_table_management()->create_plugin_tables();
347 366 }
348 367
349 368 /**
350 - * Update the browser cache htaccess config file with max-age values
351 - */
352 - private static function update_431_update_browser_cache_htaccess_config() {
353 - if (self::is_new_install()) return;
354 - if (!WP_Optimize()->get_options()->get_option('enable_browser_cache')) return;
355 -
356 - WP_Optimize()->get_browser_cache()->restore();
357 - }
358 -
359 - /**
360 369 * Wipe WPO_DB_Table_Analysis usage data
361 370 */
362 371 private static function update_431_db_table_analysis_wipe_usage_data() {
363 372 if (self::is_new_install()) return;
@@ -373,8 +382,82 @@
373 382 private static function update_440_change_plugin_json_permissions() {
374 383 if (self::is_new_install()) return;
375 384
376 385 WP_Optimize()->get_db_info()->change_plugin_json_permissions();
386 + }
387 +
388 + /**
389 + * Prefix WPO specific post meta keys with `_` to make it private.
390 + */
391 + private static function update_461_update_post_meta_keys() {
392 + if (self::is_new_install()) return;
393 +
394 + $keys_to_convert = array(
395 + 'smush-complete',
396 + 'smush-marked',
397 + 'smush-info',
398 + 'smush-stats',
399 + 'original-file',
400 + 'wpo-webp-conversion-complete',
401 + );
402 +
403 + if (is_multisite()) {
404 + $sites = WP_Optimize()->get_sites();
405 + foreach ($sites as $site) {
406 + $blog_id = $site->blog_id;
407 + switch_to_blog($blog_id);
408 + self::update_461_convert_post_meta_keys($keys_to_convert);
409 + restore_current_blog();
410 + }
411 + } else {
412 + self::update_461_convert_post_meta_keys($keys_to_convert);
413 + }
414 +
415 + }
416 +
417 + /**
418 + * Perform the post meta key renaming for the current blog.
419 + *
420 + * @param array $keys_to_convert List of meta keys to prefix.
421 + */
422 + private static function update_461_convert_post_meta_keys(array $keys_to_convert) {
423 + global $wpdb;
424 +
425 + foreach ($keys_to_convert as $old_key) {
426 + if ('wpo-webp-conversion-complete' !== $old_key) {
427 + $new_key = '_wpo-' . $old_key;
428 + } else {
429 + $new_key = '_' . $old_key;
430 + }
431 +
432 + $result = $wpdb->query($wpdb->prepare(
433 + "UPDATE {$wpdb->postmeta} SET meta_key = %s WHERE meta_key = %s",
434 + $new_key,
435 + $old_key
436 + ));
437 +
438 + if (false === $result) {
439 + WP_Optimize()->log(
440 + sprintf(
441 + 'Update 4.6.1: Failed to rename post meta key "%s" to "%s" on blog %d. DB error: %s',
442 + $old_key,
443 + $new_key,
444 + get_current_blog_id(),
445 + $wpdb->last_error
446 + )
447 + );
448 + }
449 + }
450 + }
451 +
452 + /**
453 + * Update the browser cache htaccess config due to updated rules.
454 + */
455 + private static function update_470_update_browser_cache_htaccess_config() {
456 + if (self::is_new_install()) return;
457 + if (!WP_Optimize()->get_options()->get_option('enable_browser_cache')) return;
458 +
459 + WP_Optimize()->get_browser_cache()->restore();
377 460 }
378 461 }
379 462
380 463 endif;