gform_noconflict_scripts

gform_noconflict_scripts

DescriptionUsageParametersExamplesPlacementSource Code

Description
When Gravity Forms is running with no-conflict mode enabled, it prevents any unknown scripts to be enqueued in the form editor page.
Use this filter to 「register」 your 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

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

Examples
This example registers 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 should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFForms::no_conflict_mode() in gravityforms.php.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注