Description
This filter can be used to prevent scripts and stylesheets being printed when GFCommon::gform_do_shortcode() processes form shortcodes located in various form settings and confirmations after headers have been sent. Scripts and stylesheets would be enqueued instead.
Usage
The following would apply to all forms.
add_filter( 'gform_disable_print_form_scripts', 'your_function_name' );
Parameters
- $disable_print_form_script bool
Should printing of the scripts and stylesheets be disabled? Default is false.
-
$form Form Object
The form object for the shortcode being processed.
-
$is_ajax bool
Indicates if ajax was enabled on the shortcode.
Examples
1. Disable printing of scripts and stylesheets for all forms
add_filter( 'gform_disable_print_form_scripts', '__return_true' );
2. Target a specific form
add_filter( 'gform_disable_print_form_scripts', 'disable_print_form_scripts', 10, 2 ); function disable_print_form_scripts( $disable_print_form_script, $form) { if ( $form['id'] == 10 ) { return true; } return $gform_disable_print_form_scripts; }
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms 2.0.
Source Code
This filter is located in GFCommon::gform_do_shortcode() in common.php.