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'm writing (rewriting) my plugin to use

wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-dialog');

Which is great!

But to use the dialog I need to load a jquery style sheet with wp_enqueue_style, is there a way to load a built-in style, similar to the way you can load the built in scripts (as seen above)? Or do I need to make a call to an external resource?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

I'm a little confused by your question, can you not simply use wp_enqueue_style, which you actually wrote into this threads heading(not sure if you know the function exists or not).

wp_enqueue_style works in the same way as the wp_enqueue_script counterpart, but of course as you'd expect, enqueues stylesheets..

Here's a list of the enqueues i was able to find in WordPress core(those you can use without needing to register them or declare paths to).

wp_enqueue_style( 'global' );
wp_enqueue_style( 'wp-admin' );
wp_enqueue_style( 'colors' );
wp_enqueue_style( 'media' );
wp_enqueue_style( 'ie' );
wp_enqueue_style( 'imgareaselect' );
wp_enqueue_style( 'imgareaselect' );
wp_enqueue_style( 'plugin-install' );
wp_enqueue_style( 'press-this' );
wp_enqueue_style( 'press-this-ie');
wp_enqueue_style( 'colors' );
wp_enqueue_style( 'theme-install' );
wp_enqueue_style( 'thickbox' );

Beyond those above you'll need to declare the path inside the enqueue(because it's not a registered style), as you would for scripts..

wp_enqueue_style( 'myPluginStylesheet', WP_PLUGIN_URL . '/myPlugin/stylesheet.css' );

Or register the style..

wp_register_style( 'myPluginStylesheet', WP_PLUGIN_URL . '/myPlugin/stylesheet.css' );

..then call it when needed..

wp_enqueue_style( 'myPluginStylesheet' );

If you're using this on one plugin page, the registration part is a little pointless, and it's probably easier to declare the path straight inside the enqueue.. (you really only need register a script or style if it's going to be called in more than one place).

Hope that's the information you're looking for... ;)

share|improve this answer
1  
The list of style registrations is in wp_default_styles(), it is little hard to fund because it uses object methods directly instead of wrapper enqueue function. –  Rarst Nov 30 '10 at 10:43
    
Good call.. i used a regex search in files to find the enqueues, took me no more time then it would to track that function down.. thanks though.. :) –  t31os Nov 30 '10 at 10:48
    
so basically there is no default style for jQueryUI. I'll have to use Thickbox to blend in. –  Justin Alexander Nov 30 '10 at 11:41
    
Just enqueue the stylesheets you need manually.. is there something in particular you're aiming for here that i'm missing? –  t31os Nov 30 '10 at 12:14
add comment

You should use wp_enqueue_style like this:

// Inside a parent theme
wp_enqueue_style( 'my-style', get_template_directory_uri() . '/css/my-style.css', false, '1.0', 'all' );
// Inside a child theme
wp_enqueue_style( 'my-style', get_stylesheet_directory_uri() . '/css/my-style.css', false, '1.0', 'all' );
// Inside a plugin
wp_enqueue_style( 'my-style', plugins_url( '/css/my-style.css', __FILE__ ), false, '1.0', 'all' );
share|improve this answer
add comment

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.