Should this be in his own style sheet, and how? (PHP in the style sheet?)


Building a WordPress options panel. One of the things it does is allow users to pick custom colors. I use a default stylesheet, then call styles for custom inputs. However, I simply insert this in the header instead of having these custom values reside in their own stylesheet (since I need to call the user's choice via PHP).

As an example, I have code in my header like this:

<style type="text/css">
p a { <?php echo get_option('to_custom_css'); ?> }

And in my functions:

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" => ""),

How would I have this reside in its own stylesheet while still using <?php echo get_option('to_custom_css'); ?> to call the users input?

You can create a stylesheet in PHP, but need to set the Content-type header to text/css. In your HTML:

  <link rel="stylesheet" type="text/css" href="user-styles.php" />
  <!-- ... -->

The in user-styles.php:


header('Content-type: text/css');

/*  now put your css here : */

p a {
    <?php echo get_option('to_custom_css'); ?>

/* and so on... */