Wp_inline_script_attributes does not work for the inline Legacy Settings 'Custom Javascript' in the Form settings

Hi, im trying to add a NONCE value to the <script type="text/javascript"> tag that warps the the custom javascript inline script added in the backend form settings.

(this code is outputted to the DOM like this:)

		<script type="text/javascript">

			( function( $ ) {

				$( document ).bind( 'gform_post_render', function() {......

Using the ‘wp_inline_script_attributes’ filter doesnt add the nonce to this script:

add_filter( 'wp_inline_script_attributes', 'add_nonce_to_inline_script', 10, 2 );
function add_nonce_to_inline_script( $attributes, $handle ) {
    $attributes['nonce'] = wp_create_nonce( 'inline_script_nonce' );
    return $attributes;
}

How do i make this work ?
Thanks

Hello Guy. Are you using this plugin for adding the Custom JavaScript?

If so, I recommend reaching out to Gravity Wiz to ask about the nonce. Thank you.

Hey Guy, Dave from Gravity Wiz here. I tested your code with our Custom Javascript plugin and it worked just fine for me. What JS code to you have in your Custom JS setting?

Hi Charis, no. im using the custom javascript code editor at the bottom of the form settings.(legacy settings)

Hi David,
im using the custom javascript code editor at the bottom of the form settings.(legacy settings) to add my code. it looks like its warpped with your code

		<script type="text/javascript">

			( function( $ ) {

				$( document ).bind( 'gform_post_render', function() {
                                          {my code appears here}
                                });
                  });

see here my code in the form settings

Thanks for your help David

Three things:

  1. What version of Custom JavaScript are you running? Based on that screenshot, it looks like it may be out-of-date.
  2. Just a note that you don’t need to wrap your code in a document ready. This is handled automatically by the plugin.
  3. Do you have a URL where I could view the generated code live?

Hi David,

  1. im using Version 1.6.1 (latest)
  2. can i send it to you privately ?