Created
May 19, 2025 14:06
-
-
Save audrasjb/ea9bef76cb5b9c90e170415081d39e0e to your computer and use it in GitHub Desktop.
Gravity Forms + Altcha: Dequeue ALTCHA related scripts and styles when no GF block is displayed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Dequeues ALTCHA related scripts and styles when no Gravity Forms block is displayed on the current page. | |
| * @see https://wordpress.org/plugins/altcha-spam-protection/ | |
| */ | |
| function who_dequeue_altcha_assets() { | |
| global $post; | |
| if ( ! has_block( 'gravityforms/form', $post ) ) { | |
| wp_dequeue_style( 'altcha-widget-styles' ); | |
| wp_dequeue_script( 'altcha-widget' ); | |
| wp_dequeue_script( 'altcha-widget-wp' ); | |
| wp_dequeue_script( 'altcha-widget-custom-options' ); | |
| wp_dequeue_script( 'altcha-widget-custom' ); | |
| } | |
| } | |
| add_filter( 'wp_enqueue_scripts', 'who_dequeue_altcha_assets' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment