Skip to content

Instantly share code, notes, and snippets.

@audrasjb
Created May 19, 2025 14:06
Show Gist options
  • Select an option

  • Save audrasjb/ea9bef76cb5b9c90e170415081d39e0e to your computer and use it in GitHub Desktop.

Select an option

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
<?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