Support » Developing with WordPress » Do Not Load jquery and other script in admin panel

  • khl32

    (@khl32)


    hi
    this is my code:

    wp_register_script( 'CxC-js', plugins_url('resource/js/js.js',__FILE__), array('jquery','jquery-ui-core','jquery-ui-accordion' ),null,false);
    	wp_enqueue_script('CxC-js');
    
    add_action('admin_enqueue_scripts','CxC-js');

    but not load in admin panel.
    and my custom page is none jquery loaded.

    Please Help me.

    • This topic was modified 12 months ago by Steve Stern.
Viewing 3 replies - 1 through 3 (of 3 total)
  • tambovskya

    (@tambovskya)

    Does WordPress come included with jQuery UI Effects?

    khl32

    (@khl32)

    yes.
    i need jquery, jquery-ui, jquery-ui-accordion
    but my plugin dont load with:
    wp_register_script( ‘CxC-js’, plugins_url(‘resource/js/js.js’,__FILE__), array(‘jquery’,’jquery-ui-core’,’jquery-ui-accordion’ ),null,false);

    what problem?

    Moderator bcworkz

    (@bcworkz)

    You are passing your script handle to add_action(). This is incorrect. You must pass a callable function to all add_action() calls. It is within that callable where you should call wp_register_script(). Note that wp_register_script() alone will not cause your script to be listed in a page. It merely register’s a handle ( ‘CxC-js’ in your case) for use in other script functions. After registering, you still must enqueue with wp_enqueue_script().

    It’s possible to enqueue without registering, but you cannot register without enqueuing. I advise to always use slug name rules for any object handle — all lowercase with only hyphen special character. It’s too hard to remember where it matters and where it does not. Maybe it matters here, maybe it doesn’t, IDK. What is insidious is it’s not always immediately apparent when it matters. Doing it wrong can cause bizarre behavior that appears unrelated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Do Not Load jquery and other script in admin panel’ is closed to new replies.