0

When using stylesheets I like to use wp_enqueue_style to have wp handle the loading. For some reason this works perfectly fine when I am logged in. But when I am not logged in the include statment gets wrapped in html comments, thus the browser doesn load the stylesheet. When loading I use: wp_enqueue_style("a-unique-name-style", plugins_url('/css/filename.css',path);

I also tried

function name_enqueue_style() {  
    error_log(__LINE__);
    wp_enqueue_style("a-unique-name-style", plugins_url('/css/filename.css',path));   
    error_log(__LINE__);
}
add_action( 'wp_enqueue_scripts', 'name_enqueue_style' );

But name_enqueue_style does not load at all. (Nothing in the error log either.)

I run this from both the plugin "main" php as from functions that build widgets.

What is happening? I don't even know where to start looking.

4
  • 1
    Do you have any performance optimisation or caching plugins/features active? Also where/when does the code in your question executed ( the add_action call specifically )?
    – Tom J Nowell
    Dec 27, 2020 at 18:07
  • Thanks a lot, apparently I had to turn the caching off and on again to get rid of the comment. Maybe not an answer that fits all the requirements, but if you post it as an answer I'll accept it as such. Dec 27, 2020 at 20:23
  • Forgot to add that I did delete the cache, but that clearly wasn't enough. Dec 27, 2020 at 20:43
  • 1
    You were the one who confirmed it, you should post an answer and mention your caching solution by name
    – Tom J Nowell
    Dec 27, 2020 at 20:53

1 Answer 1

0

as Tom J Nowell asked in the comments a caching plugin was the culprit. In this case WP Fastest cache. Just deleting the cache did not work. Turning the caching off and on again fixed the problem.

update: I did some more digging and the fact it gets commented is correct. The caching plugin also runs a code minimizer. For some reason the minimized code did not use the stylesheet I added. Turning it off and on again forced a rerun of the minimizer (I guess).

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.