0

I've got this in my main php file, but the scripts aren't loading

function class_table_scripts() {
    wp_register_script( 'JavaScript1', plugins_url('js/wcs.js'), array() );
    wp_register_script( 'JavaScript1', plugins_url('js/jquery.qtip-1.0.0-rc3.min.js'), array('jquery') );
}
add_action( 'wp_enqueue_scripts', 'class_table_scripts' );

I've never tried to use JS or JQuery on the options page before, this is my first go. Any pointers on where I'm going wrong here?


EDIT: Here's what finally worked for me:

function class_table_scripts() {
    wp_register_script( 'JavaScript1', plugins_url('js/wcs.js',__FILE__));
    wp_register_script( 'JQuery1', plugins_url('js/jquery.qtip-1.0.0-rc3.min.js',__FILE__) );
}
add_action( 'admin_init', 'class_table_scripts' );
  • Please add your solution as a new answer to this question and accept it. Or this question will pop up ever once in a while, as the Community bot regards it unanswered. – tfrommen Jan 1 '14 at 11:33
2

Hey use admin_enqueue_scripts.
if you want to load a set of CSS and/or Javascript documents to all admin pages. You can do this from within your plugin or from your themes function file using admin_enqueue_scripts:

function class_table_scripts() {
    wp_register_script( 'JavaScript1', plugins_url('js/wcs.css'), array() );
    wp_enqueue_script('JavaScript1');
    wp_register_script( 'JavaScript1', plugins_url('js/jquery.qtip-1.0.0-rc3.min.js'), array('jquery') );
    wp_enqueue_script('JavaScript1');
}
add_action( 'admin_enqueue_scripts', 'class_table_scripts' );
  • Answer is incomplete. Explain why the right hook to use is admin_enqueue_scripts please – JMau Dec 31 '13 at 11:31
  • This didn't do it for me. I did get it using admin_init tho. I updated with the code that finally worked. – KingRichard Jan 1 '14 at 8:52
0

Here's how I finally got it:

function class_table_scripts() {
    wp_register_script( 'JavaScript1', plugins_url('js/wcs.js',__FILE__));
    wp_register_script( 'JQuery1', plugins_url('js/jquery.qtip-1.0.0-rc3.min.js',__FILE__) );
}
add_action( 'admin_init', 'class_table_scripts' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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