| @@ -79,8 +79,11 @@ | ||
| 79 | 79 | // Siteground Speed Optimizer: Exclude Forms from JS combine. |
| 80 | 80 | add_filter( 'convertkit_output_script_footer', array( $this, 'siteground_speed_optimizer_exclude_js_combine' ) ); |
| 81 | 81 | add_filter( 'convertkit_resource_forms_output_script', array( $this, 'siteground_speed_optimizer_exclude_js_combine' ) ); |
| 82 | 82 | |
| 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 | + | |
| 83 | 86 | // Rocket LazyLoad: Exclude images from lazy loading. |
| 84 | 87 | add_filter( 'rocket_lazyload_excluded_src', array( $this, 'exclude_hosts' ) ); |
| 85 | 88 | |
| 86 | 89 | // WP Rocket: Disable Caching and Minification on Landing Pages. |
| @@ -336,8 +339,35 @@ | ||
| 336 | 339 | */ |
| 337 | 340 | public function exclude_local_js_from_minification( $scripts ) { |
| 338 | 341 | |
| 339 | 342 | 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 ); | |
| 340 | 370 | |
| 341 | 371 | } |
| 342 | 372 | |
| 343 | 373 | } |