| @@ -678,8 +678,22 @@ | ||
| 678 | 678 | private const OPTIONAL_FOR_HANDOVER = array( |
| 679 | 679 | 'object-cache', |
| 680 | 680 | 'cdn', |
| 681 | 681 | 'preloader', |
| 682 | + /* | |
| 683 | + * `cache` is optional for the HANDOVER decision specifically, and it | |
| 684 | + * has to be, because the source itself is usually why it failed: the | |
| 685 | + * source holds advanced-cache.php, so page cache cannot apply, so we | |
| 686 | + * refuse to deactivate the source, so it keeps holding the drop-in. | |
| 687 | + * That loop is what left sites with no cache at all (#391). | |
| 688 | + * | |
| 689 | + * Deactivating first and enabling after is the resolution -- see | |
| 690 | + * MigrationModule::restore_own_environment(), which now turns caching | |
| 691 | + * on once the field is free. A cache failure is still reported to the | |
| 692 | + * user either way; it just no longer vetoes the switch-off the notice | |
| 693 | + * already promised. | |
| 694 | + */ | |
| 695 | + 'cache', | |
| 682 | 696 | ); |
| 683 | 697 | |
| 684 | 698 | /** |
| 685 | 699 | * Is it safe to switch the source plugin off? |
| @@ -730,10 +744,14 @@ | ||
| 730 | 744 | if ( ! class_exists( __NAMESPACE__ . '\\Object_Cache' ) ) { |
| 731 | 745 | return $result; |
| 732 | 746 | } |
| 733 | 747 | |
| 734 | - $opts = (array) Settings_Manager::get( 'object-cache' ); | |
| 735 | - $state = Object_Cache::enable( $opts ); | |
| 748 | + $opts = (array) Settings_Manager::get( 'object-cache' ); | |
| 749 | + // An import IS the user switching away from the source plugin, so it | |
| 750 | + // takes the same switch path: the source's own object cache is turned | |
| 751 | + // off through its settings (or the plugin deactivated) before ours goes | |
| 752 | + // in, instead of being overwritten while it stays on. (#686) | |
| 753 | + $state = Object_Cache::enable( $opts, array( 'takeover' => true ) ); | |
| 736 | 754 | |
| 737 | 755 | $result['ok'] = ! empty( $state['ok'] ); |
| 738 | 756 | $result['object_cache_ready'] = ! empty( $state['ok'] ); |
| 739 | 757 | if ( empty( $state['ok'] ) ) { |
| @@ -801,8 +819,11 @@ | ||
| 801 | 819 | 'lazy_images' => ! empty( $r['lazyload'] ), |
| 802 | 820 | 'lazy_iframes' => ! empty( $r['lazyload_iframes'] ), |
| 803 | 821 | 'lazy_videos' => ! empty( $r['lazyload_youtube'] ), |
| 804 | 822 | ); |
| 823 | + if ( ! empty( $r['lazyload_css_bg_img'] ) ) { | |
| 824 | + $patch['lazy']['lazy_background_images'] = true; | |
| 825 | + } | |
| 805 | 826 | |
| 806 | 827 | // Separate Mobile Cache — do NOT import this as ON. WP Rocket's |
| 807 | 828 | // "separate cache files for mobile" is frequently left on by habit even |
| 808 | 829 | // when the site serves identical HTML to every device, and xSpeed's |
| @@ -823,8 +844,19 @@ | ||
| 823 | 844 | $patch['preloader']['sitemap_urls'] = array_values( array_filter( array_map( 'strval', $r['sitemap_preload_url'] ) ) ); |
| 824 | 845 | } |
| 825 | 846 | } |
| 826 | 847 | |
| 848 | + // Bloat — WP Rocket's "Disable Emoji" and "Disable WordPress embeds". | |
| 849 | + $bloat = array_filter( | |
| 850 | + array( | |
| 851 | + 'disable_emojis' => ! empty( $r['emoji'] ), | |
| 852 | + 'disable_oembed' => ! empty( $r['embeds'] ), | |
| 853 | + ) | |
| 854 | + ); | |
| 855 | + if ( $bloat ) { | |
| 856 | + $patch['bloat'] = $bloat; | |
| 857 | + } | |
| 858 | + | |
| 827 | 859 | // CDN — WP Rocket stores CDN hosts in cdn_cnames (array). |
| 828 | 860 | if ( ! empty( $r['cdn'] ) && ! empty( $r['cdn_cnames'] ) && is_array( $r['cdn_cnames'] ) ) { |
| 829 | 861 | $first = (string) ( $r['cdn_cnames'][0] ?? '' ); |
| 830 | 862 | if ( '' !== $first ) { |
| @@ -1458,15 +1490,14 @@ | ||
| 1458 | 1490 | $patch['fonts'] = array( 'font_display_swap' => true ); |
| 1459 | 1491 | } |
| 1460 | 1492 | |
| 1461 | 1493 | // ── Disable bloat ───────────────────────────────────────────── |
| 1462 | - // Only map the one LiteSpeed "remove" toggle with a clean xSpeed | |
| 1463 | - // equivalent: removing the emoji + oEmbed scripts ≈ disable_oembed. | |
| 1464 | - // (LiteSpeed's optm-emoji_rm strips the wp-emoji + wp-embed pair.) | |
| 1465 | - // jQuery-migrate / dashicons / XML-RPC / RSS / REST aren't | |
| 1466 | - // LiteSpeed-managed, so we don't guess at them. | |
| 1494 | + // optm-emoji_rm is LiteSpeed's only bloat toggle. It used to map to | |
| 1495 | + // disable_oembed, which turned oEmbed off unasked and left emojis on | |
| 1496 | + // (#217, #532). jQuery-migrate / dashicons / XML-RPC / RSS / REST | |
| 1497 | + // aren't LiteSpeed-managed, so we don't guess at them. | |
| 1467 | 1498 | if ( $on( 'optm-emoji_rm' ) ) { |
| 1468 | - $patch['bloat'] = array( 'disable_oembed' => true ); | |
| 1499 | + $patch['bloat'] = array( 'disable_emojis' => true ); | |
| 1469 | 1500 | } |
| 1470 | 1501 | |
| 1471 | 1502 | // ── Browser cache (LiteSpeed: cache-browser) ────────────────── |
| 1472 | 1503 | if ( $on( 'cache-browser' ) ) { |