WPDIR
Everything and everyone WordPress

Using style.php instead of style.css best practices?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #338 Reply
    Madison
    Guest

    https://stackoverflow.com/questions/47936877/use-css-style-on-php-file-wordpress-variable-access

    <link rel="stylesheet" type="text/css" href="style.php" />

    Is this a horrible idea or common solution for WordPress? and calling variables inside the style.php like their example

    <?php
    header('Content-type: text/css');
    $var = /*Get the background color*/;
    ?>
    .wrap{
    background-color:<?php echo $var; ?>;
    }

    #339 Reply
    Michael
    Guest

    It’s a little bit goofy but it works, and it’s safe… https://css-tricks.com/css-variables-with-php/

    the issue is that WordPress requires the style.css file anyways, so then you just have like this dead file sitting there.

    #340 Reply
    Stephen
    Guest

    The CSS Tricks link has some fantastic examples of how to use it actually.

    #437 Reply
    Robert
    Guest

    If you are coding custom WP themes, it’s not really necessary though… you can hard code your classes and styles. And for typical WP plebs they all want bloated page builder plugins and stuff now so this solution is rather niche

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Reply #340 in Using style.php instead of style.css best practices?