Dynamic Style Sheet Support

  1. Luke Mlsna


    Dynamic style sheets are PHP files with a CSS header that allow CSS values to be changed on the fly. This is cleaner than using the style HTML tag and prevents collisions by using the wp_enqueue framework. This is already possible in the current version of WordPress, but I think more native support would be nice.

    in style.php:

    header( 'Content-type: text/css' );
    if( array_key_exists( 'css', $_GET ) )
    extract( unserialize( urldecode( $_GET['css'] ) ) ); ?>
    The rest proceeds like a normal style sheet,
    except that you can insert the values passed
    through the 'css' url query variable.
    For example:

    html {
    background-color:#<?php echo $bg_color; ?>;
    #header {
    background-image:url("<?php echo $header_url; ?>");
    background-size:<?php echo $header_width; ?> <?php echo $header_height; ?>;

    new function

    function wp_enqueue_dynamic_style( $handle, $url, $args, $deps, $version, $media ) {
    $args_string = '?css=' . urlencode( serialize( $args ) );
    wp_enqueue_style( $handle, $url . $args_string, $deps, $version, $media );

    If we had a way to bootstrap the WordPress functions directly into a dynamic style sheet, that would be ideal.

    Posted: 6 years ago #
  2. esmi

    In what way is this related to Accessibility?

    Posted: 6 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    3 Votes
  • Status

    This idea is under consideration