diff --git a/readme.txt b/readme.txt index 2ade231a..f1999bfd 100644 --- a/readme.txt +++ b/readme.txt @@ -574,6 +574,7 @@ Instructions for popular native integrations are below: * Added compatibility with WordPress Recovery Mode. * Added compatibility with Contact Form 7 v6.0. * Added compatibility with Akismet tag in Contact Form 7. +* Added compatibility with Elementor Element Caching. * Added activation and deactivation of plugins network wide if hCaptcha is set network wide. * Added ability to use shortcode in the Mailchimp for WP form. * Fixed racing condition when loading hCaptcha API. diff --git a/src/php/ElementorPro/HCaptchaHandler.php b/src/php/ElementorPro/HCaptchaHandler.php index 6a17b138..00d05608 100644 --- a/src/php/ElementorPro/HCaptchaHandler.php +++ b/src/php/ElementorPro/HCaptchaHandler.php @@ -128,6 +128,7 @@ public function init(): void { 3 ); add_filter( 'elementor_pro/forms/render/item', [ $this, 'filter_field_item' ] ); + add_filter( 'elementor/frontend/the_content', [ $this, 'elementor_content' ] ); add_filter( 'elementor_pro/editor/localize_settings', [ $this, 'localize_settings' ] ); if ( static::is_enabled() ) { @@ -451,6 +452,23 @@ public function filter_field_item( $item ): array { return $item; } + /** + * Filter Elementor content. + * + * @param string|mixed $content Content. + * + * @return string + */ + public function elementor_content( $content ): string { + $content = (string) $content; + + if ( ! hcaptcha()->form_shown && false !== strpos( $content, 'form_shown = true; + } + + return $content; + } + /** * Add the hCaptcha Elementor Pro script to footer. *