将 CSS 添加到 PHP Wordpress 插件 [英] Add CSS to Php Wordpress plugin

查看:65
本文介绍了将 CSS 添加到 PHP Wordpress 插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个简单的插件,它使用 wp_options 设置一些 css 代码.它看起来都像这样:

I wrote a simple plugin which sets some css code using wp_options. It all looks similar like this:

add_action('init','easy_style');

function easy_style()
{
    ?>
    <style>
    #header a {
        color: <?php echo get_option('topcolor'); ?>;
        font-size: <?php echo get_option('topsize'); ?>px;
        <?php
            if (get_option('topstyle') == "bold")
            { echo "font-weight: bold;"; echo "font-style: normal;"; }
            elseif (get_option('topstyle') == "italic")
            { echo "font-style: italic;"; echo "font-weight: normal;"; }
            elseif (get_option('topstyle') == "bolditalic")
            { echo "font-weight: bold;"; echo "font-style: italic;"; }
            else { echo "font-weight: normal;"; echo "font-style: normal;"; }
        ?>;
    }

    </style>
    <?php
}

现在这有效,但如果我激活我的联系表格 7"插件,联系表格 7 将不再工作.它不能发送任何邮件.所以我认为我的做法是错误的.如果我删除这段代码,联系表又可以工作了...

Now this works, but if I activate my "Contact Form 7" plugin, the contact form 7 doesn't work anymore. It can't send any mails. So I think what I do is wrong. If I remove this piece of code, the contact form works again...

我认为我做错了,因为 css 需要加载到标题中,不是吗?所以我认为我会做的测试是将相同的代码放在标题中.但是,其他一些 css(我不知道在哪里)会覆盖这些,所以这也不起作用.

I think I do it wrong because the css needs to be loaded in the header, no? So what I thought I would do as a test is put the same code in the header. However then some other css (i don't know where) overwrites these, so this also doesn't work.

我认为有一些 wp 函数可以将 css 代码添加到标题中,但我不知道具体如何.

I think there are some wp functions to add css code to the header but I don't know how exacly.

有什么想法吗?

谢谢

推荐答案

我通过加载styles.css文件解决了我的问题,编辑并再次保存

I solved my problem by loading in the styles.css file, edit it and save again

这篇关于将 CSS 添加到 PHP Wordpress 插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆