hi guzz i am create wordpress plugin and i want to access php variable on css style i include 'style.php'
file and i want to access php style variable on this file but how , my php code
<?php
function my_style_render(){
// mystyle file load
wp_enqueue_style('mystyle', MY_PLUGIN_URL."/css/my_style.css");
$color = '#149382';
ob_start();
include MY_PLUGIN_PATH . '/css/style.php';
$custom_css = ob_get_clean();
wp_add_inline_style( 'mystyle', $custom_css );
}
?>
//and my style.php file
.model_inline {
background-color: {$color};
}
but color in not apply on 'model_inline' class ... anyone suggestion ..
You can try following code.
For eg:
In HTML: You can call css file like this.
<link rel="stylesheet" type="text/css" href="style.php" />
in style you can add this code. Style.php
<?php
header('Content-type: text/css');
$var = /*Get the background color*/;
?>
.wrap{
background-color:<?php echo $var; ?>;
}