| @@ -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 |
| @@ -27,9 +26,8 @@ | ||
| 27 | 26 | 'pages.kit.com', |
| 28 | 27 | 'kit.com', |
| 29 | 28 | 'pages.convertkit.com', |
| 30 | 29 | 'convertkit.com', |
| 31 | - 'filekitcdn.com', | |
| 32 | 30 | ); |
| 33 | 31 | |
| 34 | 32 | /** |
| 35 | 33 | * Holds internal JS paths to exclude from JS minification. |
| @@ -55,10 +53,10 @@ | ||
| 55 | 53 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'autoptimize_exclude_js_defer' ) ); |
| 56 | 54 | add_filter( 'autoptimize_filter_imgopt_should_lazyload', array( $this, 'disable_image_lazy_loading_on_landing_pages' ) ); |
| 57 | 55 | |
| 58 | 56 | // 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' ) ); | |
| 57 | + add_filter( 'debloat/defer_js_excludes', array( $this, 'exclude_hosts_from_minification' ) ); | |
| 58 | + add_filter( 'debloat/delay_js_excludes', array( $this, 'exclude_hosts_from_minification' ) ); | |
| 61 | 59 | |
| 62 | 60 | // Jetpack Boost: Exclude Forms from JS defer. |
| 63 | 61 | add_filter( 'convertkit_output_script_footer', array( $this, 'jetpack_boost_exclude_js_defer' ) ); |
| 64 | 62 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'jetpack_boost_exclude_js_defer' ) ); |
| @@ -66,12 +64,8 @@ | ||
| 66 | 64 | // LiteSpeed: Exclude Forms from JS defer. |
| 67 | 65 | add_filter( 'convertkit_output_script_footer', array( $this, 'litespeed_cache_exclude_js_defer' ) ); |
| 68 | 66 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'litespeed_cache_exclude_js_defer' ) ); |
| 69 | 67 | |
| 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 | 68 | // Perfmatters: Exclude Forms from Delay JavaScript. |
| 75 | 69 | add_filter( 'convertkit_output_script_footer', array( $this, 'perfmatters_exclude_delay_js' ) ); |
| 76 | 70 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'perfmatters_exclude_delay_js' ) ); |
| 77 | 71 | add_filter( 'perfmatters_lazyload', array( $this, 'disable_image_lazy_loading_on_landing_pages' ) ); |
| @@ -79,19 +73,13 @@ | ||
| 79 | 73 | // Siteground Speed Optimizer: Exclude Forms from JS combine. |
| 80 | 74 | add_filter( 'convertkit_output_script_footer', array( $this, 'siteground_speed_optimizer_exclude_js_combine' ) ); |
| 81 | 75 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'siteground_speed_optimizer_exclude_js_combine' ) ); |
| 82 | 76 | |
| 83 | - // Siteground Speed Optimizer: Set Member Content Pages in "Exclude URLs from Caching". | |
| 84 | - add_filter( 'sgo_exclude_urls_from_cache', array( $this, 'exclude_restrict_content_pages_from_caching' ) ); | |
| 85 | - | |
| 86 | - // Rocket LazyLoad: Exclude images from lazy loading. | |
| 87 | - add_filter( 'rocket_lazyload_excluded_src', array( $this, 'exclude_hosts' ) ); | |
| 88 | - | |
| 89 | 77 | // WP Rocket: Disable Caching and Minification on Landing Pages. |
| 90 | 78 | add_action( 'convertkit_output_landing_page_before', array( $this, 'wp_rocket_disable_caching_and_minification_on_landing_pages' ) ); |
| 91 | 79 | |
| 92 | 80 | // WP Rocket: Exclude Forms from JS minification and combine. |
| 93 | - add_filter( 'rocket_minify_excluded_external_js', array( $this, 'exclude_hosts' ) ); | |
| 81 | + add_filter( 'rocket_minify_excluded_external_js', array( $this, 'exclude_hosts_from_minification' ) ); | |
| 94 | 82 | |
| 95 | 83 | // WP Rocket: Exclude Forms from Delay JavaScript execution. |
| 96 | 84 | add_filter( 'convertkit_output_script_footer', array( $this, 'wp_rocket_exclude_delay_js_execution' ) ); |
| 97 | 85 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'wp_rocket_exclude_delay_js_execution' ) ); |
| @@ -163,28 +151,8 @@ | ||
| 163 | 151 | |
| 164 | 152 | } |
| 165 | 153 | |
| 166 | 154 | /** |
| 167 | - * Disable JS Optimization on Kit scripts when the LiteSpeed Cache Plugin is installed, active | |
| 168 | - * and its "JS Combine" setting is enabled. | |
| 169 | - * | |
| 170 | - * @since 3.3.1 | |
| 171 | - * | |
| 172 | - * @param array $script Script key/value pairs to output as <script> tag. | |
| 173 | - * @return array | |
| 174 | - */ | |
| 175 | - public function litespeed_cache_exclude_js_optimize( $script ) { | |
| 176 | - | |
| 177 | - return array_merge( | |
| 178 | - $script, | |
| 179 | - array( | |
| 180 | - 'data-no-optimize' => '1', | |
| 181 | - ) | |
| 182 | - ); | |
| 183 | - | |
| 184 | - } | |
| 185 | - | |
| 186 | - /** | |
| 187 | 155 | * Exclude ConvertKit scripts from Perfmatters' "Delay JS" setting. |
| 188 | 156 | * |
| 189 | 157 | * @since 2.4.7 |
| 190 | 158 | * |
| @@ -269,11 +237,12 @@ | ||
| 269 | 237 | * @since 2.4.6 |
| 270 | 238 | */ |
| 271 | 239 | public function wp_rocket_disable_caching_and_minification_on_landing_pages() { |
| 272 | 240 | |
| 273 | - add_filter( 'rocket_minify_excluded_external_js', array( $this, 'exclude_hosts' ) ); | |
| 274 | - add_filter( 'rocket_exclude_css', array( $this, 'exclude_hosts' ) ); | |
| 241 | + add_filter( 'rocket_minify_excluded_external_js', array( $this, 'exclude_hosts_from_minification' ) ); | |
| 242 | + add_filter( 'rocket_exclude_css', array( $this, 'exclude_hosts_from_minification' ) ); | |
| 275 | 243 | add_filter( 'rocket_exclude_js', array( $this, 'exclude_local_js_from_minification' ) ); |
| 244 | + add_filter( 'do_rocket_lazyload', '__return_false' ); | |
| 276 | 245 | |
| 277 | 246 | } |
| 278 | 247 | |
| 279 | 248 | /** |
| @@ -307,24 +276,8 @@ | ||
| 307 | 276 | * @return array |
| 308 | 277 | */ |
| 309 | 278 | public function exclude_hosts_from_minification( $hosts ) { |
| 310 | 279 | |
| 311 | - _doing_it_wrong( __FUNCTION__, 'Use exclude_hosts() instead.', '3.1.0' ); | |
| 312 | - | |
| 313 | - return $this->exclude_hosts( $hosts ); | |
| 314 | - | |
| 315 | - } | |
| 316 | - | |
| 317 | - /** | |
| 318 | - * Appends the $exclude_hosts property to an array of existing hosts. | |
| 319 | - * | |
| 320 | - * @since 3.1.0 | |
| 321 | - * | |
| 322 | - * @param array $hosts External hosts to ignore. | |
| 323 | - * @return array | |
| 324 | - */ | |
| 325 | - public function exclude_hosts( $hosts ) { | |
| 326 | - | |
| 327 | 280 | return array_merge( $hosts, $this->exclude_hosts ); |
| 328 | 281 | |
| 329 | 282 | } |
| 330 | 283 | |
| @@ -339,35 +292,8 @@ | ||
| 339 | 292 | */ |
| 340 | 293 | public function exclude_local_js_from_minification( $scripts ) { |
| 341 | 294 | |
| 342 | 295 | return array_merge( $scripts, $this->exclude_plugin_js ); |
| 343 | - | |
| 344 | - } | |
| 345 | - | |
| 346 | - /** | |
| 347 | - * Exclude Restrict Content Pages from caching when the Siteground Speed Optimizer Plugin is installed, active | |
| 348 | - * and its "Exclude URLs from Caching" setting is enabled. | |
| 349 | - * | |
| 350 | - * @since 3.3.6 | |
| 351 | - * | |
| 352 | - * @param array $excluded_urls URLs to exclude from caching. | |
| 353 | - * @return array | |
| 354 | - */ | |
| 355 | - public function exclude_restrict_content_pages_from_caching( $excluded_urls ) { | |
| 356 | - | |
| 357 | - // Get the list of relative URLs for posts with restrict_content enabled | |
| 358 | - // from the Plugin's cache. | |
| 359 | - $restrict_content_cache = WP_ConvertKit()->get_class( 'restrict_content_cache' ); | |
| 360 | - if ( ! $restrict_content_cache ) { | |
| 361 | - return $excluded_urls; | |
| 362 | - } | |
| 363 | - | |
| 364 | - // Cache stores Restrict Content pages as id => relative url pairs. | |
| 365 | - // Siteground just needs to the relative URLs. | |
| 366 | - $restrict_content_urls = array_values( $restrict_content_cache->get() ); | |
| 367 | - | |
| 368 | - // Merge the list of relative URLs with the list of URLs already excluded from caching. | |
| 369 | - return array_merge( $excluded_urls, $restrict_content_urls ); | |
| 370 | 296 | |
| 371 | 297 | } |
| 372 | 298 | |
| 373 | 299 | } |