How can I get a list of all enqueued scripts and styles?

I’m creating a plugin and I want to get the list of all scripts and CSS used by other plugins. This is my function: function crunchify_print_scripts_styles() { $result = []; $result[‘scripts’] = []; $result[‘styles’] = []; // Print all loaded Scripts global $wp_scripts; foreach( $wp_scripts->queue as $script ) : $result[‘scripts’][] = $wp_scripts->registered[$script]->src . “;”; endforeach; … Read more

How important is it to enqueue a theme’s stylesheet?

I have trawled the net looking for an answer to this, but for some reason all I can find are actual examples, but without that particular explanation, which is clear say in the case of scripts. Can someone explain to me why it’s important/advantageous to enqueue styles when developing a theme, rather than just using … Read more

Is it ever okay to include inline CSS in plugins?

Normally in a plugin I would add styles using wp_enqueue_style. However, I am currently creating a plugin that only needs a few lines of CSS and I am wondering if it might be better to serve the styles inline to save a request. Obviously there are many advantages to using wp_enqueue_style, but are they worth … Read more

Why wp_register_style() is important while I’m using a complete wp_enqueue_style()? [duplicate]

This question already has answers here: When should I use wp_register_script() with wp_enqueue_script() vs just wp_enqueue_script()? (3 answers) Closed 8 years ago. Currently I’m working on a theme, and did some styles and scripts enqueue. When enqueued the scripts, I used wp_register_script() first, and then enqueued with wp_enqueue_script() – because I got that’s the proper … Read more

wp enqueue style on specific page templates

I am in the process of a theme, I would like to add landing pages using page-templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. Landing Page 1 – landing-page-template-one.php will need very different style and js than the blog or homepage. 6 If … Read more

Check if a script/style was enqueued/registered

Is it possible to test whether a script or a style was registered using wp_register_script/_style or wp_enqueue_script/_style? All functions doesn’t return a value and I’m completely clueless. I need it to switch between different functions depending on stylesheet-libraries and scripts I offer. Thank you! 2 There is a function called wp_script_is( $handle, $list ). $list … Read more

How do I dequeue a parent theme’s CSS file?

My parent theme (Starkers) adds a CSS file that I’m trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php: add_action( ‘wp_enqueue_scripts’, ‘script_enqueuer’ ); function script_enqueuer() { wp_register_script( ‘site’, get_template_directory_uri().’/js/site.js’, array( ‘jquery’ ) ); wp_enqueue_script( ‘site’ ); wp_register_style( ‘screen’, get_template_directory_uri().’/style.css’, ”, ”, … Read more