Skip to content

Commit

Permalink
Add compatibility with Elementor Element Caching.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Nov 4, 2024
1 parent 50035e7 commit 66597c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions src/php/ElementorPro/HCaptchaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) {
Expand Down Expand Up @@ -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, '<h-captcha' ) ) {
hcaptcha()->form_shown = true;
}

return $content;
}

/**
* Add the hCaptcha Elementor Pro script to footer.
*
Expand Down

0 comments on commit 66597c6

Please sign in to comment.