2

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?

1 Answer 1

6

I'm a little confused by your question, can you not simply use wp_enqueue_style, given you mentioned it in the title of the question.

The wp_enqueue_style function works in the same way as the wp_enqueue_script counterpart, but as you'd expect, enqueues stylesheets in place of scripts.

Here's a list of the enqueues i was able to find in WordPress core, styles you can load without needing to register them or declare paths to (updated for 6.0 - holy post update batman!).

<?php
wp_enqueue_style('colors');
wp_enqueue_style('common');
wp_enqueue_style('forms');
wp_enqueue_style('admin-menu');
wp_enqueue_style('dashboard');
wp_enqueue_style('list-tables');
wp_enqueue_style('edit');
wp_enqueue_style('revisions');
wp_enqueue_style('media');
wp_enqueue_style('themes');
wp_enqueue_style('about');
wp_enqueue_style('nav-menus');
wp_enqueue_style('widgets');
wp_enqueue_style('site-icon');
wp_enqueue_style('l10n');
wp_enqueue_style('code-editor');
wp_enqueue_style('site-health');
wp_enqueue_style('wp-admin');
wp_enqueue_style('login');
wp_enqueue_style('install');
wp_enqueue_style('wp-color-picker');
wp_enqueue_style('customize-controls');
wp_enqueue_style('customize-widgets');
wp_enqueue_style('customize-nav-menus');
wp_enqueue_style('buttons');
wp_enqueue_style('dashicons');
wp_enqueue_style('admin-bar');
wp_enqueue_style('wp-auth-check');
wp_enqueue_style('editor-buttons');
wp_enqueue_style('media-views');
wp_enqueue_style('wp-pointer');
wp_enqueue_style('customize-preview');
wp_enqueue_style('wp-embed-template-ie');
wp_enqueue_style('imgareaselect');
wp_enqueue_style('wp-jquery-ui-dialog');
wp_enqueue_style('mediaelement');
wp_enqueue_style('wp-mediaelement');
wp_enqueue_style('thickbox');
wp_enqueue_style('wp-codemirror');
wp_enqueue_style('deprecated-media');
wp_enqueue_style('farbtastic');
wp_enqueue_style('jcrop');
wp_enqueue_style('colors-fresh');
wp_enqueue_style('open-sans');
wp_enqueue_style('wp-editor-font');
wp_enqueue_style('wp-block-library-theme');
wp_enqueue_style('wp-reset-editor-styles');
wp_enqueue_style('wp-editor-classic-layout-styles');
wp_enqueue_style('wp-edit-blocks');
wp_enqueue_style('wp-block-editor');
wp_enqueue_style('wp-block-library');
wp_enqueue_style('wp-block-directory');
wp_enqueue_style('wp-components');
wp_enqueue_style('wp-edit-post');
wp_enqueue_style('wp-editor');
wp_enqueue_style('wp-format-library');
wp_enqueue_style('wp-list-reusable-blocks');
wp_enqueue_style('wp-reusable-blocks');
wp_enqueue_style('wp-nux');
wp_enqueue_style('wp-widgets');
wp_enqueue_style('wp-edit-widgets');
wp_enqueue_style('wp-customize-widgets');
wp_enqueue_style('wp-edit-site');
?>

Beyond using the styles listed above you'll need to declare a path inside your enqueue as it's not a registered style, like you would for scripts.

Enqueue only

wp_enqueue_style( 'myPluginStylesheet', plugins_url( 'stylesheet.css', __FILE__ ) );

or..

Register

wp_register_style( 'myPluginStylesheet', plugins_url( 'stylesheet.css', __FILE__ ) );

And call

wp_enqueue_style( 'myPluginStylesheet' );

For use on a single plugin page i'd skip the registration part and make a single enqueue call.

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

4
  • 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
    Commented Nov 30, 2010 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
    Commented Nov 30, 2010 at 10:48
  • so basically there is no default style for jQueryUI. I'll have to use Thickbox to blend in. Commented Nov 30, 2010 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
    Commented Nov 30, 2010 at 12:14

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.