admin管理员组文章数量:1317742
I built a module with custom CSS. I'm not sure why the CSS isn't being applied, although it seems like the page is loading the CSS file (when I view source in a page, I can see my custom CSS file, and when I open that link, the content is what it should be). The div class name is pretty custom, so I don't think it's being overwritten.
Code in module:
function hbc_comicCanvas() {
wp_register_style('hbc_comicCanvas', plugins_url('css/hbc_comicCanvas.css',__FILE__));
wp_enqueue_style('hbc_comicCanvas');
wp_register_script( 'hbc_comicCanvas', plugins_url('js/comicCanvas.js', __FILE__));
wp_enqueue_script('hbc_comicCanvas');
}
add_action( 'admin_init','hbc_comicCanvas');
function insert_default_content($content) {
$content = "
<div id=\"hbc_drawingPanel\">drawingPanel id</div>
<div class=\"hbc_drawingPanel\">drawingPanel class</div>
<canvas style='height:500px;width:500px'>woot</canvas>
";
return $content;
}
add_filter( 'default_content', 'insert_default_content');
And the content of the CSS file:
div #hbc_drawingPanel{
background-color: purple;
}
div .hbc_drawingPanel{
background-color: purple;
}
Thanks for any help. I've looked at a bunch of suggestions, but nothing has panned out so far.
I built a module with custom CSS. I'm not sure why the CSS isn't being applied, although it seems like the page is loading the CSS file (when I view source in a page, I can see my custom CSS file, and when I open that link, the content is what it should be). The div class name is pretty custom, so I don't think it's being overwritten.
Code in module:
function hbc_comicCanvas() {
wp_register_style('hbc_comicCanvas', plugins_url('css/hbc_comicCanvas.css',__FILE__));
wp_enqueue_style('hbc_comicCanvas');
wp_register_script( 'hbc_comicCanvas', plugins_url('js/comicCanvas.js', __FILE__));
wp_enqueue_script('hbc_comicCanvas');
}
add_action( 'admin_init','hbc_comicCanvas');
function insert_default_content($content) {
$content = "
<div id=\"hbc_drawingPanel\">drawingPanel id</div>
<div class=\"hbc_drawingPanel\">drawingPanel class</div>
<canvas style='height:500px;width:500px'>woot</canvas>
";
return $content;
}
add_filter( 'default_content', 'insert_default_content');
And the content of the CSS file:
div #hbc_drawingPanel{
background-color: purple;
}
div .hbc_drawingPanel{
background-color: purple;
}
Thanks for any help. I've looked at a bunch of suggestions, but nothing has panned out so far.
Share Improve this question edited Oct 26, 2020 at 21:39 Tom J Nowell♦ 61k7 gold badges79 silver badges148 bronze badges asked Oct 26, 2020 at 14:04 Trevor NewhookTrevor Newhook 1012 bronze badges 4 |1 Answer
Reset to default 0The solution was to remove wp_normalize_path
本文标签: pluginsApplying module CSS to page
版权声明:本文标题:plugins - Applying module CSS to page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742019431a2414391.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp_normalize_path
? Also how is the register and enqueue code being called? If you registered the style you don't need the extra parameters inwp_enqueue
just the handle/first parameter like the docs say. That's also not howadd_filter
works,add_filter
expects a function/callable or the name of a function as the second paramter – Tom J Nowell ♦ Commented Oct 26, 2020 at 15:19wp_enqueue
andwp_register
script and style functions expect a URL, and URLs are always/
. Likewise, in PHP you can use/
and it will work everywhere, not just Linux TLDR always use/
even on Windows. Also code in comments doesn't work, can you edit your question to include that code? Note that's still not how filters work, filters always return something, basic beginners filters 101. Right now your code should be generating lots of PHP warnings and errors, and your CSS won't have anything to work on because of the incorrect use of filters – Tom J Nowell ♦ Commented Oct 26, 2020 at 17:01