sio*_*n45 1 css php wordpress header
构建一个WordPress选项面板.它所做的一件事是允许用户选择自定义颜色.我使用默认样式表,然后调用自定义输入样式.但是,我只是将其插入到标题中,而不是将这些自定义值驻留在它们自己的样式表中(因为我需要通过PHP调用用户的选择).
举个例子,我的头文件中的代码如下:
<style type="text/css">
p a { <?php echo get_option('to_custom_css'); ?> }
</style>
Run Code Online (Sandbox Code Playgroud)
在我的功能:
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" => ""),
Run Code Online (Sandbox Code Playgroud)
如何在仍然<?php echo get_option('to_custom_css'); ?>用于调用用户输入的同时将它驻留在自己的样式表中?
您可以在PHP中创建样式表,但需要将Content-type标头设置为text/css.在您的HTML中:
<head>
<link rel="stylesheet" type="text/css" href="user-styles.php" />
<!-- ... -->
Run Code Online (Sandbox Code Playgroud)
在user-styles.php中:
<?php
header('Content-type: text/css');
?>
/* now put your css here : */
p a {
<?php echo get_option('to_custom_css'); ?>
}
/* and so on... */
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
117 次 |
| 最近记录: |