0

Whilst jQuery is available on all admin pages, only selected jQuery UI libraries are added for certain pages (i.e. it is different for each admin page).

I am trying to find out where the jQuery UI libraries are actually registered for each admin page. For instance the widgets.php page has draggable, droppable added.

2 Answers 2

1

The core file for this is in wp-includes/script-loader.php for reference, but if you want to alter them use the built in script functions such as:

wp_register_script(),
wp_deregister_script(),
wp_enqueue_script(),
wp_dequeue_script()

1
  • Yeah, I've looked through that core file. It seems to setup all the default scripts and handles into one class instance. Each admin page has a different subset of these jQuery UI loaded, so I'm looking for where these are actually set for each admin page.
    – dgwyer
    Commented Jan 9, 2012 at 0:48
0

As an addition to @Wyck answer, you can take a look at this explanation about how to determine on which admin UI page you currently are.

Most of the scripts are already registered, but not enqueued, so not loaded. Just inspect them in the shutdown through dumping the $GLOBALS['wp_scripts'];.

You can use the following function that hooks into this hook:

function debug_my_scripts()
{
    global $wp_scripts;

    $output['Registered']  = var_export( array_keys( $wp_scripts->registered ), true );
    $output['Enqueued'] = var_export( $wp_scripts->queue, true );
    $output['Done'] = var_export( $wp_scripts->done, true );

    foreach ( $output as $title => $data )
        print "<h3>{$title}</h3><pre>{$data}</pre>";
}
if ( is_admin() )
    add_action( 'shutdown', 'debug_my_scripts', 9999 );
2
  • I'm already outputting the global $wp_scripts earlier than shutdown to inspect the libraries being added (as well as inspecting the source). I just wanted to find out what scripts were being enqueued in the core, and where. This is actually being done by dependencies in most cases rather than direct enqueues.
    – dgwyer
    Commented Jan 10, 2012 at 8:28
  • Yea, but earlier might be too early, as the shutdown hook runs close after admin_* hooks which are used to add scripts to the bottom of the pages body. So inspecting at shutdown is what you normally should go for. If you want to know what core adds, just add a theme that contains nothing than an empty style.css and a functions.php file with the function shown in my answer and you're fine - don't forget to turn off all your plugins.
    – kaiser
    Commented Jan 10, 2012 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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