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 +85 -15 4.6.0 → 4.7.0 View file →
@@ -38,17 +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 ),
48 - '4.6.0' => array(
49 - 'update_460_update_browser_cache_htaccess_config',
47 + '4.6.1' => array(
48 + 'update_461_update_post_meta_keys',
50 49 ),
50 + '4.7.0' => array(
51 + 'update_470_update_browser_cache_htaccess_config',
52 + ),
51 53 );
52 54
53 55 /**
54 56 * See if any database schema updates are needed, and perform them if so.
@@ -70,8 +72,22 @@
70 72 }
71 73 }
72 74 update_option('wpo_update_version', WPO_VERSION);
73 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 + }
74 90 }
75 91
76 92 /**
77 93 * Delete old semaphore locks from options database table.
@@ -349,18 +365,8 @@
349 365 WP_Optimize()->get_table_management()->create_plugin_tables();
350 366 }
351 367
352 368 /**
353 - * Update the browser cache htaccess config file with max-age values
354 - */
355 - private static function update_431_update_browser_cache_htaccess_config() {
356 - if (self::is_new_install()) return;
357 - if (!WP_Optimize()->get_options()->get_option('enable_browser_cache')) return;
358 -
359 - WP_Optimize()->get_browser_cache()->restore();
360 - }
361 -
362 - /**
363 369 * Wipe WPO_DB_Table_Analysis usage data
364 370 */
365 371 private static function update_431_db_table_analysis_wipe_usage_data() {
366 372 if (self::is_new_install()) return;
@@ -379,11 +385,75 @@
379 385 WP_Optimize()->get_db_info()->change_plugin_json_permissions();
380 386 }
381 387
382 388 /**
383 - * Update the browser cache htaccess config file with fix disabling cache for php files and /wp-admin/ dir
389 + * Prefix WPO specific post meta keys with `_` to make it private.
384 390 */
385 - private static function update_460_update_browser_cache_htaccess_config() {
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() {
386 456 if (self::is_new_install()) return;
387 457 if (!WP_Optimize()->get_options()->get_option('enable_browser_cache')) return;
388 458
389 459 WP_Optimize()->get_browser_cache()->restore();