Wordpress插件:使用php在样式表中输出样式

时间:2014-02-12 07:05:56

标签: php wordpress-plugin wordpress

我目前正在开发一个WordPress插件,下面的代码保存在一个名为style.css的文件中

.toggle { background:url(images/plus.png) 0     5px scroll no-repeat;  margin-top:20px; padding:0 0 0 35px; display:block; text-transform: normal; font-size: 18px; position:relative; line-height:25px; }
h4.toggle a                     { color: #888; padding-top:2px; text-decoration: none; text-transform: normal; }
h4.toggle a:hover               { color:#666;}

h4.active                       { background:url(images/minus.png) 0 5px scroll no-repeat;  display:block;}
h4.active a:link                { color:#666;}

.toggle_content                 { clear:both;  margin:0px;  }
div.toggleinside                { padding:15px; padding-left:35px;}
h4.toggle                       { margin-bottom:0}


.fancytoggle        { 
    position:relative; 
    border:1px solid #ccc !important;   
    background-color:#fff; 
    padding:10px; 
    margin-bottom:10px; 

    background:-moz-linear-gradient(bottom, #f2f2f2 0px, #fff 100%);
    -moz-box-shadow:0px 1px 1px #aaa;

    background:-webkit-gradient(linear,left bottom,left top, color-stop(0, #f2f2f2),color-stop(1, #fff));
    -webkit-box-shadow:0px 1px 1px #aaa;

    box-shadow:0px 1px 1px #aaa;
}

.fancytoggle h4                 { margin:0 0 2px 0; }
.fancytoggle .toggle_content    { padding-bottom:0; }

然而,由于这是一个wordpress插件,我不能只有

background:url(images/plus.png)

因为这是在header.php上排队所以我需要在

下面加上这一行
$jquery_libraryurl = plugins_url('jquery_library', 'jquery_library').'/';

将整个网址输出到图片。所以我需要知道如何才能实现这一目标。我在顶部<?php header("Content-type: text/css"); ?>

尝试使用style.php

唯一的问题是我不能使用上面调用函数plugins_url()的行,因为wp-load.php不在文件中,如果我包含它会对css文件造成很大的负担。

所以我正在寻找一种方法,可以使用php将带有上述变量的css代码输出到css文件中。我到处寻找,找不到任何有用的东西可以帮助我实现这个目标。

我有什么选择可以做到这一点,有办法解决这个问题很简单。

0 个答案:

没有答案