I found a solution to prevent this error from happening.
I use wpDataTables shortcodes on my website so Gravity Forms scripts are registered and enqueued after the execution of localize_hook_vars
.
I created a must-use plugin to call the gform_force_hooks_js_output
filter to force printing JS in the page header:
<?php
add_filter( 'gform_force_hooks_js_output', '__return_true' );
Warning: Currently, the documentation of gform_force_hooks_js_output
is wrong about the default value. The value passed to apply_filter()
is false
, so the default value is false
.