yoast(); $this->rank_math(); $this->seopress(); $this->aioseo(); $this->the_seo_framework(); $this->gravity_forms(); $this->wpforms(); $this->acf(); $this->contact_form_7(); $this->jetpack(); $this->memberpress(); $this->learndash(); $this->buddypress(); $this->bbpress(); $this->elementor(); $this->beaver(); $this->divi_builder(); $this->amp(); $this->woocommerce_extra(); $this->ewww(); $this->smush(); $this->autoptimize(); $this->cookie_consent(); $this->revolution_slider(); $this->events_calendar(); } private function exclude_delay( array $needles ) { add_filter( 'qwsc_delay_js_exclusions', function ( $list ) use ( $needles ) { return array_values( array_unique( array_merge( (array) $list, $needles ) ) ); } ); } private function bypass_uri( $pattern ) { add_filter( 'qwsc_cache_bypass', function ( $bypass ) use ( $pattern ) { if ( $bypass ) { return $bypass; } $uri = isset( $_SERVER['REQUEST_URI'] ) && is_string( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; return (bool) preg_match( $pattern, $uri ); } ); } private function yoast() { if ( ! defined( 'WPSEO_VERSION' ) ) { return; } $this->exclude_delay( array( 'yoast', 'wp-seo' ) ); $this->bypass_uri( '#sitemap.*\.xml#' ); } private function rank_math() { if ( ! defined( 'RANK_MATH_VERSION' ) ) { return; } $this->exclude_delay( array( 'rank-math', 'rank_math' ) ); $this->bypass_uri( '#sitemap.*\.xml#' ); } private function seopress() { if ( ! defined( 'SEOPRESS_VERSION' ) && ! function_exists( 'seopress_get_toggle_option' ) ) { return; } $this->exclude_delay( array( 'seopress' ) ); $this->bypass_uri( '#sitemaps?\.xml#' ); } private function aioseo() { if ( ! defined( 'AIOSEO_VERSION' ) ) { return; } $this->exclude_delay( array( 'aioseo', 'all-in-one-seo' ) ); } private function the_seo_framework() { if ( ! defined( 'THE_SEO_FRAMEWORK_VERSION' ) ) { return; } $this->exclude_delay( array( 'tsf', 'the-seo-framework' ) ); } private function gravity_forms() { if ( ! class_exists( 'GFCommon' ) ) { return; } $this->exclude_delay( array( 'gravityforms', 'gform_' ) ); add_filter( 'qwsc_js_safe_handles', function ( $h ) { $h[] = 'gform_gravityforms'; $h[] = 'jquery'; return $h; } ); } private function wpforms() { if ( ! defined( 'WPFORMS_VERSION' ) ) { return; } $this->exclude_delay( array( 'wpforms' ) ); } private function acf() { if ( ! class_exists( 'ACF' ) ) { return; } $this->exclude_delay( array( 'acf-input', 'acf-pro', 'acf-' ) ); } private function contact_form_7() { if ( ! defined( 'WPCF7_VERSION' ) ) { return; } $this->exclude_delay( array( 'contact-form-7', 'wpcf7' ) ); } private function jetpack() { if ( ! defined( 'JETPACK__VERSION' ) ) { return; } $this->exclude_delay( array( 'jetpack', 'photon' ) ); } private function memberpress() { if ( ! defined( 'MEPR_VERSION' ) ) { return; } $this->bypass_uri( '#/(account|login|membership)#' ); } private function learndash() { if ( ! defined( 'LEARNDASH_VERSION' ) ) { return; } $this->exclude_delay( array( 'learndash', 'ld-' ) ); } private function buddypress() { if ( ! function_exists( 'buddypress' ) ) { return; } add_filter( 'qwsc_cache_bypass', function ( $bypass ) { if ( $bypass ) { return $bypass; } return function_exists( 'is_buddypress' ) && is_buddypress(); } ); } private function bbpress() { if ( ! function_exists( 'is_bbpress' ) ) { return; } add_filter( 'qwsc_cache_bypass', function ( $bypass ) { if ( $bypass ) { return $bypass; } return is_bbpress(); } ); } private function elementor() { if ( ! defined( 'ELEMENTOR_VERSION' ) ) { return; } $this->exclude_delay( array( 'elementor', 'elementor-frontend', 'elementor-pro' ) ); add_filter( 'qwsc_cache_bypass', function ( $bypass ) { if ( $bypass ) { return $bypass; } return isset( $_GET['elementor-preview'] ); // phpcs:ignore WordPress.Security.NonceVerification } ); } private function beaver() { if ( ! class_exists( 'FLBuilderModel' ) ) { return; } $this->exclude_delay( array( 'fl-builder', 'fl-theme' ) ); add_filter( 'qwsc_cache_bypass', function ( $bypass ) { if ( $bypass ) { return $bypass; } return isset( $_GET['fl_builder'] ); // phpcs:ignore WordPress.Security.NonceVerification } ); } private function divi_builder() { if ( ! defined( 'ET_BUILDER_VERSION' ) && ! function_exists( 'et_setup_theme' ) ) { return; } $this->exclude_delay( array( 'divi', 'et-builder', 'et_pb_' ) ); } private function amp() { if ( ! function_exists( 'is_amp_endpoint' ) && ! defined( 'AMP__VERSION' ) ) { return; } add_filter( 'qwsc_should_optimize', function ( $ok ) { if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { return false; } return $ok; } ); add_filter( 'qwsc_cache_bypass', function ( $bypass ) { if ( $bypass ) { return $bypass; } return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint(); } ); } private function woocommerce_extra() { if ( ! class_exists( 'WooCommerce' ) ) { return; } $this->exclude_delay( array( 'woocommerce', 'wc-add-to-cart', 'wc-cart-fragments', 'stripe', 'paypal' ) ); } private function ewww() { if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_VERSION' ) ) { return; } // Avoid double WebP rewrite conflicts: prefer EWWW when active. add_filter( 'qwsc_media_webp_rewrite', '__return_false' ); } private function smush() { if ( ! defined( 'WP_SMUSH_VERSION' ) && ! class_exists( 'WP_Smush' ) ) { return; } add_filter( 'qwsc_media_webp_rewrite', '__return_false' ); } private function autoptimize() { if ( ! defined( 'AUTOPTIMIZE_PLUGIN_VERSION' ) ) { return; } // Soft notice only — ConflictDetector already lists AO. } private function cookie_consent() { $plugins = array( 'cookieyes' => defined( 'CKY_APP_VERSION' ) || defined( 'CLI_VERSION' ), 'complianz' => function_exists( 'cmplz_init' ) || defined( 'cmplz_version' ), 'cookiebot' => defined( 'Cookiebot_WP_VERSION' ), ); foreach ( $plugins as $needle => $active ) { if ( $active ) { $this->exclude_delay( array( $needle, 'cookie', 'consent' ) ); } } } private function revolution_slider() { if ( ! class_exists( 'RevSliderFront' ) && ! function_exists( 'rev_slider_shortcode' ) ) { return; } $this->exclude_delay( array( 'revslider', 'tp-tools', 'rs6' ) ); } private function events_calendar() { if ( ! class_exists( 'Tribe__Events__Main' ) ) { return; } $this->exclude_delay( array( 'tribe-events', 'tec-' ) ); $this->bypass_uri( '#/event/#' ); } }