1

I am trying to get my theme registered stylesheets in plugin, the purpose is I want to get all stylesheets in my plugin and then manipulate those registered styles.

stylesheets registered via

add_action('wp_enqueue_scripts', 'mytheme_register_styles', 1);

add_action('wp_enqueue_scripts', 'mytheme_enqueue_styles', 5);

and as you already know this action doesn't get fired in backend, so I want a hookable / callable way so it gets enqueued and I can modify / manipulate for my needs and resave them.

1

If you want the stylesheets registered in the backend, use the admin_enqueue_scripts action.

function wp94156_register_styles() {
    wp_register_style(
        'your-stylesheet',
        get_stylesheet_directory_uri() . '/your-stylesheet.css',
        $deps, // optional
        $version // optional
    );
    // since you only want it registered, we won't enqueue it
}
add_action( 'admin_enqueue_scripts', 'wp94156_register_styles' );
  • Thanks @Pat J, but I need to get theme registered stylesheets (it can be any stylesheet parent theme, child theme) and I want to get them as on frontend we can get with global $wp_styles, so I want something similar in backend, I have explored lots of plugins but none of them seems to be useful for my needs. – Syed Apr 3 '13 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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