gform_noconflict_scripts

Description

When Gravity Forms is running with no-conflict mode enabled, it prevents any unknown scripts to be enqueued in the form editor page.

The gform_noconflict_scripts filter allows developers to “register” their script with Gravity Forms, making sure it gets enqueued in the form editor page when no-conflict mode is enabled.

Usage

add_filter( 'gform_noconflict_scripts', 'register_script' );

Parameters

ParameterTypeDescription
$scriptsarrayAn array of script handles to be filtered. Add scripts to this array to register them, (i.e. $scripts[] = 'my-script-handle';).

Examples

Register a custom script with Gravity Forms.

add_action( 'admin_enqueue_scripts', 'enqueue_form_editor_script' );
function enqueue_form_editor_script() {

	if ( RGForms::is_gravity_page() ) {
		//enqueing my script on gravity form pages
		wp_enqueue_script( 'my_script', plugins_url( 'my-script.js', 'my-plugin' ) );
	}
}

add_filter( 'gform_noconflict_scripts', 'register_script' );
function register_script( $scripts ) {

	//registering my script with Gravity Forms so that it gets enqueued when running on no-conflict mode
	$scripts[] = 'my_script';
	return $scripts;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in GFForms::no_conflict_mode() in gravityforms.php.