*/ public function add_keywords( $exclusions ) { $exclusions = is_array( $exclusions ) ? $exclusions : array(); return array_values( array_unique( array_merge( $exclusions, self::KEYWORDS ) ) ); } /** * Adds the widget's script handles to an exclusion list. * * @param mixed $handles Existing handles. * @return array */ public function add_handles( $handles ) { $handles = is_array( $handles ) ? $handles : array(); return array_values( array_unique( array_merge( $handles, array( Frontend::WIDGET_HANDLE, Frontend::HELPER_HANDLE ) ) ) ); } /** * Autoptimize's comma-separated exclusions. * * @param mixed $exclusions Existing exclusions. */ public function autoptimize( $exclusions ): string { $exclusions = is_string( $exclusions ) ? $exclusions : ''; $items = array_filter( array_map( 'trim', explode( ',', $exclusions ) ) ); return implode( ', ', array_unique( array_merge( $items, self::KEYWORDS ) ) ); } /** * Optimizers detected on this site, for the Chat widget screen and support. * * @return array */ public static function detected(): array { $found = array(); $checks = array( 'WP Rocket' => defined( 'WP_ROCKET_VERSION' ), 'Autoptimize' => defined( 'AUTOPTIMIZE_PLUGIN_VERSION' ), 'LiteSpeed Cache' => defined( 'LSCWP_V' ), 'SiteGround Optimizer' => defined( 'SiteGround_Optimizer\VERSION' ), 'W3 Total Cache' => defined( 'W3TC' ), 'Perfmatters' => defined( 'PERFMATTERS_VERSION' ), 'WP Fastest Cache' => class_exists( 'WpFastestCache' ), 'Jetpack Boost' => defined( 'JETPACK_BOOST_VERSION' ), ); foreach ( $checks as $name => $active ) { if ( $active ) { $found[] = array( 'name' => $name, 'handled' => in_array( $name, array( 'WP Rocket', 'Autoptimize', 'LiteSpeed Cache', 'SiteGround Optimizer' ), true ), ); } } return $found; } }