admin管理员组文章数量:1310169
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.
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.
Share Improve this question edited Dec 27, 2020 at 17:34 pietervanderstar asked Dec 27, 2020 at 17:18 pietervanderstarpietervanderstar 313 bronze badges 4 |1 Answer
Reset to default 0as 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).
本文标签: Enqueued style gets commented if not logged in
版权声明:本文标题:Enqueued style gets commented if not logged in 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741847281a2400856.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
add_action
call specifically )? – Tom J Nowell ♦ Commented Dec 27, 2020 at 18:07