Is it possible to change the path of a css file that is registered through wp_enqueue_style()?

I wonder if you are looking for the style_loader_src filter? For example: add_filter( ‘style_loader_src’, function ( $src ){ // … your stuff … return $src; } ); Similarly there exists the script_loader_src filter. There’s also the base_url property of the global $wp_scripts and $wp_styles objects, but I think that’s only used for enqueued native styles … Read more

Register script/style: Is it possible to customize the version query string via plugin?

Old answer (based on misconception that you wanted a cache buster): You can use add_query_arg() which adds/replaces query arguments. <?php /** * Plugin Name: wpse_84670 * Version: 0.0.1 * Description: replace script/style version with time as a cache buster */ /** * replace script or stylesheet version with current time * @param string $url the … Read more

How to detect if a function has been fired on any page so scripts/styles can be loaded conditionally

For scripts this is no-brainer – just enqueue inside my_gallery() function and they will be output in footer (since header already passed). However stylesheets are a challenge, they are only supposed to work in head section and enqueueing for footer is not supported. Essentially you need to know if function was called before it was … Read more

use add_action(‘wp_head’) in a widget

You can call wp_enqueue_script() directly in your Widget output, and WordPress will enqueue the script. No need to add it to a callback. Try changing this: else { add_action(‘wp_head’, ‘pieChartScripts’); function pieChartScripts() { wp_register_style(‘piechart-css’, get_template_directory_uri() . ‘/css/jquery.easy-pie-chart.css’); wp_enqueue_style(‘piechart-css’); } wp_register_script(‘piechart’, get_template_directory_uri() . ‘/js/jquery.easypiechart.min.js’, ”, ‘2.0.4’); wp_enqueue_script(‘piechart’); // etc } …to this: else { wp_register_style(‘piechart-css’, get_template_directory_uri() … Read more