Quantcast
Channel: Styles/Scripts Archives - Gravity Forms Documentation
Viewing all articles
Browse latest Browse all 13

gform_disable_print_form_scripts

$
0
0

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.

The post gform_disable_print_form_scripts appeared first on Gravity Forms Documentation.


Viewing all articles
Browse latest Browse all 13

Trending Articles