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'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' );
share|improve this question
    
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. –  t f Jan 1 at 11:33

2 Answers 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' );
share|improve this answer
    
Answer is incomplete. Explain why the right hook to use is admin_enqueue_scripts please –  JMau Dec 31 '13 at 11:31
    
Thanks Jmau. I've updated –  shahpranaf Dec 31 '13 at 11:45
    
Thanks. Updated my vote too –  JMau Dec 31 '13 at 11:48
    
This didn't do it for me. I did get it using admin_init tho. I updated with the code that finally worked. –  CriketX Jan 1 at 8:52
up vote 0 down vote accepted

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' );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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