| @@ -14,10 +14,9 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | class ConvertKit_Cache_Plugins { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Holds external hosts to exclude from CSS and JS minification | |
| 19 | - * and lazy loading of images. | |
| 18 | + * Holds external hosts to exclude from CSS and JS minification. | |
| 20 | 19 | * |
| 21 | 20 | * @since 2.4.6 |
| 22 | 21 | * |
| 23 | 22 | * @var array |
| @@ -23,13 +22,10 @@ | ||
| 23 | 22 | * @var array |
| 24 | 23 | */ |
| 25 | 24 | public $exclude_hosts = array( |
| 26 | 25 | 'cdnjs.cloudflare.com', |
| 27 | - 'pages.kit.com', | |
| 28 | - 'kit.com', | |
| 29 | 26 | 'pages.convertkit.com', |
| 30 | 27 | 'convertkit.com', |
| 31 | - 'filekitcdn.com', | |
| 32 | 28 | ); |
| 33 | 29 | |
| 34 | 30 | /** |
| 35 | 31 | * Holds internal JS paths to exclude from JS minification. |
| @@ -52,14 +48,9 @@ | ||
| 52 | 48 | |
| 53 | 49 | // Autoptimize: Exclude Forms from JS defer. |
| 54 | 50 | add_filter( 'convertkit_output_script_footer', array( $this, 'autoptimize_exclude_js_defer' ) ); |
| 55 | 51 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'autoptimize_exclude_js_defer' ) ); |
| 56 | - add_filter( 'autoptimize_filter_imgopt_should_lazyload', array( $this, 'disable_image_lazy_loading_on_landing_pages' ) ); | |
| 57 | 52 | |
| 58 | - // Debloat: Exclude Forms from Delay Load JS. | |
| 59 | - add_filter( 'debloat/defer_js_excludes', array( $this, 'exclude_hosts' ) ); | |
| 60 | - add_filter( 'debloat/delay_js_excludes', array( $this, 'exclude_hosts' ) ); | |
| 61 | - | |
| 62 | 53 | // Jetpack Boost: Exclude Forms from JS defer. |
| 63 | 54 | add_filter( 'convertkit_output_script_footer', array( $this, 'jetpack_boost_exclude_js_defer' ) ); |
| 64 | 55 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'jetpack_boost_exclude_js_defer' ) ); |
| 65 | 56 | |
| @@ -66,30 +57,20 @@ | ||
| 66 | 57 | // LiteSpeed: Exclude Forms from JS defer. |
| 67 | 58 | add_filter( 'convertkit_output_script_footer', array( $this, 'litespeed_cache_exclude_js_defer' ) ); |
| 68 | 59 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'litespeed_cache_exclude_js_defer' ) ); |
| 69 | 60 | |
| 70 | - // LiteSpeed: Exclude Forms from JS optimization. | |
| 71 | - add_filter( 'convertkit_output_script_footer', array( $this, 'litespeed_cache_exclude_js_optimize' ) ); | |
| 72 | - add_filter( 'convertkit_resource_forms_output_script', array( $this, 'litespeed_cache_exclude_js_optimize' ) ); | |
| 73 | - | |
| 74 | 61 | // Perfmatters: Exclude Forms from Delay JavaScript. |
| 75 | 62 | add_filter( 'convertkit_output_script_footer', array( $this, 'perfmatters_exclude_delay_js' ) ); |
| 76 | 63 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'perfmatters_exclude_delay_js' ) ); |
| 77 | - add_filter( 'perfmatters_lazyload', array( $this, 'disable_image_lazy_loading_on_landing_pages' ) ); | |
| 64 | + add_filter( 'perfmatters_lazyload', array( $this, 'perfmatters_disable_lazy_loading_on_landing_pages' ) ); | |
| 78 | 65 | |
| 79 | 66 | // Siteground Speed Optimizer: Exclude Forms from JS combine. |
| 80 | 67 | add_filter( 'convertkit_output_script_footer', array( $this, 'siteground_speed_optimizer_exclude_js_combine' ) ); |
| 81 | 68 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'siteground_speed_optimizer_exclude_js_combine' ) ); |
| 82 | 69 | |
| 83 | - // Rocket LazyLoad: Exclude images from lazy loading. | |
| 84 | - add_filter( 'rocket_lazyload_excluded_src', array( $this, 'exclude_hosts' ) ); | |
| 85 | - | |
| 86 | 70 | // WP Rocket: Disable Caching and Minification on Landing Pages. |
| 87 | 71 | add_action( 'convertkit_output_landing_page_before', array( $this, 'wp_rocket_disable_caching_and_minification_on_landing_pages' ) ); |
| 88 | 72 | |
| 89 | - // WP Rocket: Exclude Forms from JS minification and combine. | |
| 90 | - add_filter( 'rocket_minify_excluded_external_js', array( $this, 'exclude_hosts' ) ); | |
| 91 | - | |
| 92 | 73 | // WP Rocket: Exclude Forms from Delay JavaScript execution. |
| 93 | 74 | add_filter( 'convertkit_output_script_footer', array( $this, 'wp_rocket_exclude_delay_js_execution' ) ); |
| 94 | 75 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'wp_rocket_exclude_delay_js_execution' ) ); |
| 95 | 76 | |
| @@ -160,28 +141,8 @@ | ||
| 160 | 141 | |
| 161 | 142 | } |
| 162 | 143 | |
| 163 | 144 | /** |
| 164 | - * Disable JS Optimization on Kit scripts when the LiteSpeed Cache Plugin is installed, active | |
| 165 | - * and its "JS Combine" setting is enabled. | |
| 166 | - * | |
| 167 | - * @since 3.3.1 | |
| 168 | - * | |
| 169 | - * @param array $script Script key/value pairs to output as <script> tag. | |
| 170 | - * @return array | |
| 171 | - */ | |
| 172 | - public function litespeed_cache_exclude_js_optimize( $script ) { | |
| 173 | - | |
| 174 | - return array_merge( | |
| 175 | - $script, | |
| 176 | - array( | |
| 177 | - 'data-no-optimize' => '1', | |
| 178 | - ) | |
| 179 | - ); | |
| 180 | - | |
| 181 | - } | |
| 182 | - | |
| 183 | - /** | |
| 184 | 145 | * Exclude ConvertKit scripts from Perfmatters' "Delay JS" setting. |
| 185 | 146 | * |
| 186 | 147 | * @since 2.4.7 |
| 187 | 148 | * |
| @@ -205,9 +166,9 @@ | ||
| 205 | 166 | |
| 206 | 167 | } |
| 207 | 168 | |
| 208 | 169 | /** |
| 209 | - * Disable image lazy loading when a WordPress Page configured to display a | |
| 170 | + * Disable lazy loading in Perfmatters when a WordPress Page configured to display a | |
| 210 | 171 | * ConvertKit Landing Page is viewed. |
| 211 | 172 | * |
| 212 | 173 | * @since 2.5.1 |
| 213 | 174 | * |
| @@ -213,9 +174,9 @@ | ||
| 213 | 174 | * |
| 214 | 175 | * @param bool $enabled Lazy loading enabled. |
| 215 | 176 | * @return bool |
| 216 | 177 | */ |
| 217 | - public function disable_image_lazy_loading_on_landing_pages( $enabled ) { | |
| 178 | + public function perfmatters_disable_lazy_loading_on_landing_pages( $enabled ) { | |
| 218 | 179 | |
| 219 | 180 | // If the request isn't for a Page, don't change lazy loading settings. |
| 220 | 181 | if ( ! is_page( get_the_ID() ) ) { |
| 221 | 182 | return $enabled; |
| @@ -227,9 +188,9 @@ | ||
| 227 | 188 | return $enabled; |
| 228 | 189 | } |
| 229 | 190 | |
| 230 | 191 | // ConvertKit Landing Page is going to be displayed. |
| 231 | - // Disable image lazy loading so that the Landing Page images display. | |
| 192 | + // Disable Perfmatters Lazy Loading so that the Landing Page images display. | |
| 232 | 193 | return false; |
| 233 | 194 | |
| 234 | 195 | } |
| 235 | 196 | |
| @@ -266,11 +227,12 @@ | ||
| 266 | 227 | * @since 2.4.6 |
| 267 | 228 | */ |
| 268 | 229 | public function wp_rocket_disable_caching_and_minification_on_landing_pages() { |
| 269 | 230 | |
| 270 | - add_filter( 'rocket_minify_excluded_external_js', array( $this, 'exclude_hosts' ) ); | |
| 271 | - add_filter( 'rocket_exclude_css', array( $this, 'exclude_hosts' ) ); | |
| 231 | + add_filter( 'rocket_minify_excluded_external_js', array( $this, 'exclude_hosts_from_minification' ) ); | |
| 232 | + add_filter( 'rocket_exclude_css', array( $this, 'exclude_hosts_from_minification' ) ); | |
| 272 | 233 | add_filter( 'rocket_exclude_js', array( $this, 'exclude_local_js_from_minification' ) ); |
| 234 | + add_filter( 'do_rocket_lazyload', '__return_false' ); | |
| 273 | 235 | |
| 274 | 236 | } |
| 275 | 237 | |
| 276 | 238 | /** |
| @@ -303,24 +265,8 @@ | ||
| 303 | 265 | * @param array $hosts External hosts to ignore. |
| 304 | 266 | * @return array |
| 305 | 267 | */ |
| 306 | 268 | public function exclude_hosts_from_minification( $hosts ) { |
| 307 | - | |
| 308 | - _doing_it_wrong( __FUNCTION__, 'Use exclude_hosts() instead.', '3.1.0' ); | |
| 309 | - | |
| 310 | - return $this->exclude_hosts( $hosts ); | |
| 311 | - | |
| 312 | - } | |
| 313 | - | |
| 314 | - /** | |
| 315 | - * Appends the $exclude_hosts property to an array of existing hosts. | |
| 316 | - * | |
| 317 | - * @since 3.1.0 | |
| 318 | - * | |
| 319 | - * @param array $hosts External hosts to ignore. | |
| 320 | - * @return array | |
| 321 | - */ | |
| 322 | - public function exclude_hosts( $hosts ) { | |
| 323 | 269 | |
| 324 | 270 | return array_merge( $hosts, $this->exclude_hosts ); |
| 325 | 271 | |
| 326 | 272 | } |