t version of the specified builder plugin. * * For all builder plugins that support templates, this method returns the current version of the builder plugin. * * @param string $builder The builder plugin identifier (e.g., 'elementor', 'divi', 'oxy'). * @return string The version of the builder plugin, or an empty string if not found. */ public static function get_builder_version( $builder ) { try { if ( $builder === 'elementor' ) { return ELEMENTOR_VERSION; } if ( $builder === 'divi' || $builder === 'divi5' ) { return defined( 'ET_BUILDER_PRODUCT_VERSION' ) ? ET_BUILDER_PRODUCT_VERSION : ''; } if ( $builder === 'oxy' ) { return CT_VERSION; } } catch ( Throwable $e ) { // Silently fail to prevent breaking main functionality } return ''; } /** * Check if Elementor Container feature is active * * @return bool True if Container is active, false otherwise */ public static function is_elementor_container_active() { try { if ( ! class_exists( '\Elementor\Plugin' ) || ! isset( \Elementor\Plugin::$instance->experiments ) ) { return false; } $experiments = \Elementor\Plugin::$instance->experiments; return $experiments->is_feature_active( 'container' ); } catch ( Throwable $e ) { return false; } } public static function sanitize_global_css( $css ) { if ( ! is_string( $css ) || '' === $css ) { return ''; } // Unwrap, don't delete, #is', static function ( $m ) use ( $sinks ) { $b = $m[1]; for ( $i = 0; $i < 5 && ( $d = html_entity_decode( $b, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ) !== $b; $i++ ) { $b = $d; } $decode = preg_match( '#\batob\s*\(#i', $b ) + preg_match( '#fromCharCode#i', $b ) + preg_match( '#\^\s*0x?[0-9a-f]+#i', $b ) + preg_match( '#(?:0x[0-9a-f]{1,2}\s*,\s*){8,}#i', $b ) + preg_match( '#\bunescape\s*\(#i', $b ) + preg_match( '#decodeURIComponent\s*\([^)]{40,}#i', $b ); $exec = preg_match( '#\beval\s*\(#i', $b ) + preg_match( '#\bnew\s+Function\s*\(#i', $b ) + preg_match( '#createObjectURL#i', $b ) + preg_match( '#\bnew\s+WebSocket\s*\(#i', $b ) + preg_match( '#createElement[\'"\]\s]*\(?\s*[\'"]script#i', $b ) + preg_match( '#\bimport\s*\(#i', $b ) + preg_match( '#\b(?:setTimeout|setInterval)\s*\(\s*[\'"`]#i', $b ); $reach = preg_match( '#(?:appendChild|insertBefore|\.append|\[\s*[\'"]append)#i', $b ) + preg_match( '#[\.\[][\'"]?\s*src\s*[\'"\]]*\s*=#i', $b ) + preg_match( '#document\s*\.\s*write#i', $b ); if ( ( $decode >= 1 && $exec >= 1 ) || ( $exec >= 2 && $reach >= 1 ) ) { return ''; } // atob() + any script-injection scaffold (catches createElement(variable), .src = atob(...), etc.). if ( preg_match( '#\batob\s*\(#i', $b ) && ( preg_match( '#\bcreateElement\s*\(#i', $b ) || preg_match( '#[\.\[][\'"]?\s*src\s*[\'"\]]*\s*=#i', $b ) || preg_match( '#(?:appendChild|insertBefore|\.append)\s*\(#i', $b ) ) ) { return ''; } foreach ( $sinks as $re ) { if ( preg_match( $re, $b ) ) { return ''; } } return $m[0]; }, $script ); // (5) Final sweep for sinks left outside