My plugin displays its output into a thickbox 'window', the contents of which are generated in load-edit.php. This is a completely bare page, but I want to use some of the admin css styles so that it integrates nicely with the rest of the UI. I can't do a regular admin_enqueue_scripts because nothing from wordpress is loaded anywhere. Now I'm already polling for the user admin styles, but I then need to check whether there's a .min.css available of the stylesheet (noticed in an older version that it's not), which I could do with file_exists(), but that needs an absolute path... which I don't have. I have get_site_url() but that only give the base url, not the part that's usually called 'wp-admin' (assuming here that this is something that could be different if the user installed it differently?).

here's what I'm trying to get working:

$adminbaseurl = /* this is what I'm mising */;
if (get_user_option('admin_color') == "classic") {
    if (file_exists($adminbaseurl . 'css/colors-classic.min.css')) {
        $colorschemeurl = $adminbaseurl . 'css/colors-classic.min.css';
    } else {
        $colorschemeurl = $adminbaseurl . 'css/colors-classic.css';
} else {        
    if (file_exists($adminbaseurl . 'css/colors-fresh.min.css')) {
        $colorschemeurl = $adminbaseurl . 'css/colors-fresh.min.css';
    } else {
        $colorschemeurl = $adminbaseurl . 'css/colors-fresh.css';

to be used later as:

<link rel='stylesheet' type='text/css' href='<?php echo $colorschemeurl; ?>' />

I guess the most simple answer could be that the wp-admin folder is ALWAYS called wp-admin, but I couldn't find that out...

Edit: looks like I can't use get_site_url anyway, since file_exists only takes the local path...

1 Answer 1


Directly answering your question, you should be able use the function admin_url() to get the base URL for the admin folder, and ABSPATH . 'wp-admin' to get the local file path to that folder. Certainly, the WordPress code itself doesn't expect the admin folder to be named anything different.

However, you should be able to enqueue those styles by style handle (thus forgetting about file_exists() calls) if you do this in your PHP file behind Thickbox:

require_once(ABSPATH . 'wp-admin/admin.php');
  • Brilliant! That was easy... just to be complete for anyone else looking for this, you can do wp_enqueue_style( 'colors' ); and then do_action('admin_print_styles'); directly after that and boom your done. Thanks webaware!
    – Ewout
    Commented Jan 23, 2013 at 17:52

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.