dynamic css file for admin / backend and get_option results in Uncaught Error: Call to undefined function get_option()
I try to style the admin area with a dynamic css. I need to configure some elements regarding the frontend user defines. He can choose a color and this color should reflected in some elements in the admin area (e.g. buttons in admin area). My approach: Setting up a evacolor.css, but let apache interpret this as a php file. This works so fare:
.htaccess in the same dir, as my color.css:
FilesMatch \.css$
SetHandler application/x-httpd-php
Header set Content-type text/css
/FilesMatch
My evacolor.css looks like:
?php
$absolute_path = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);
$wp_load = $absolute_path[0] . 'wp-load.php';
header(Content-type: text/css; charset: UTF-8);
header('Cache-control: must-revalidate');
$test = #ff00ff;
?
body {
background: ?php echo $test;?;
}
.... and so on
This works fine. Now I need to pull my color out from the wp_options table and all the problems starts.
- I tried
$color_items = get_option( 'cornerstone_color_items' );
= Uncaught Error: Call to undefined function get_option() I tried to includeinclude_once('wp-includes\option.php');
But this ends in = Call to undefined function wp_installing() Ok, let's includ this alsoinclude_once('wp-includes\load.php');
= Call to undefined function apply_filters()
Hence. Next try:
global $wpdb;
$result = $wpdb-get_results( SELECT * FROM wpeva_options WHERE option_name = 'cornerstone_color_items');
print_r($result)
= Uncaught Error: Call to a member function get_results()
I include require_once($wp_load);
= Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
I give up. No more ideas.
Does anyone has an idea, how to use a dynamic css (for admin, resp. backend) and use inside this css a color value, which is stored in wp_option table?
Even my attempt to define a global variable has had no success: $GLOBALS['color'] = '#ff00ff';
and also define('CICOLOR', '#ff00ff')
; are empty in my dynamic css;
Any ideas? Any help? Thank you :)