建立一个WordPress选项面板。它所做的一件事就是允许用户选择自定义颜色。我使用默认的样式表,然后调用样式来定制输入。不过,我只是将这些插入头中,而不是让这些自定义值驻留在它们自己的样式表中(因为我需要通过PHP调用用户的选择)。这应该在它自己的样式表中,以及如何? (PHP样式表?)
举个例子,我有一些代码在我的标题是这样的:
<style type="text/css">
p a { <?php echo get_option('to_custom_css'); ?> }
</style>
在我的功能:
array("name" => "Custom CSS",
"desc" => "Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:green}",
"id" => $shortname."_custom_css",
"type" => "text",
"std" => ""),
我怎么会有这种驻留在其自己的样式表,同时仍使用<?php echo get_option('to_custom_css'); ?>
调用用户输入?
...这是我一整天听到的最悲惨的消息。 – siouxfan45
请参阅由daiscog回答什么是解决方法。 – Sparky
@LucasWynne你可以将样式表的扩展名设置为.php。或者,如果您使用的是Apache,您可以设置任何特定的文件以供PHP处理,甚至可以使用mod_rewrite将some_file.css的所有请求传递给some_other_file.php。您只需要记住将PHP文件中的Content-type标头设置为“text/css”。 – megaflop