建立一個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