I have a CSS-file generated from PHP.
In my file it says…
header("Content-type: text/css");
define('WP_USE_THEMES', false);
include '../../../../wp-load.php';
I’ve read that including wp-load.php like this is not good. Why I do this is to get the environment in there.
What is the “correct” way of doing this?
EDIT
Forget my answer below. You could simply use
wp_register_style
andwp_enqueue_style
described in this answer.You could do it with an additional query variable.
$query_vars
array with thequery_vars
filterOn the
template_redirect
action, make sure yourcustom.php
-css file is included, if the query variable is set.Then you can add a simple css include in your header file.
Last but not least, you have to define your custom css file.
You could also get the contents from the css file with the builtin PHP function
file_get_contents()
and print the css directly to the sourcecode.