Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a question regarding this action hook: http://www.gravityhelp.com/documentation/page/Gform_editor_js.

I'm not sure where to put this action hook. Can I use this action hook in my child theme's functions.php to make a jQuery script available when the plugin is in edit mode?

.......

I placed the hook in the child theme's functions.php as below but it does not seem to be working. Have I missed something?

add_action("gform_editor_js", "my_jquery_function");

function my_jquery_function() {
    wp_enqueue_script('mytest1', get_stylesheet_directory_uri() . '/assets/javascripts/mytest1.js');
    wp_enqueue_script('mytest2', get_stylesheet_directory_uri() . '/assets/javascripts/mytest2.js');
}
share|improve this question

closed as off-topic by Mark Kaplun, birgire, mrwweb, Pieter Goosen, Johannes Pille Sep 3 at 9:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Mark Kaplun, birgire, mrwweb, Pieter Goosen, Johannes Pille
If this question can be reworded to fit the rules in the help center, please edit the question.

    
What is gform_editor_js? That's no native WordPress hook... –  kaiser Apr 28 at 12:16

1 Answer 1

You can either place the code snippet in the theme functions.php file or in a custom functionality plugin: http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users

Edit:

To enqueue custom scripts on the edit page you should use admin_enqueue_scripts e.g.

add_action( 'admin_enqueue_scripts', 'my_jquery_function' );
function my_jquery_function() {
    if ( rgget( 'page' ) != 'gf_edit_forms' )
        return;
    wp_enqueue_script('mytest1', get_stylesheet_directory_uri() . '/assets/javascripts/mytest1.js');
    wp_enqueue_script('mytest2', get_stylesheet_directory_uri() . '/assets/javascripts/mytest2.js');
}
share|improve this answer
    
I tried placing it in the child theme's functions.php but it's not working for me. See the edit above. Any comments on this? I haven't tried the custom functionality plugin yet. –  user1448031 Apr 28 at 11:34
    
check the revised answer above –  richardW8k Apr 28 at 11:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.