I want to mix jQuery and php in wordpress.
This is my current code:
function theme_output($url) {
echo "<script language='text/javascript'>
jQuery(function($) {
var $products,
$current_product = 'default';
// List all the products here
$products = {
";
$themes = array('cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'lumen', 'paper', 'readable', 'sandstone', 'simplex', 'slate', 'spacelab', 'superhero', 'united', 'yeti');
foreach ($themes as $theme) {
echo
$theme." : {
name : '".ucfirst($theme)."',
tag : 'phpBB',
img : '".css_file($theme)."',
url : '".$url."?theme=".$theme."',
purchase : 'http://www.google.de',
},";
};
echo "
};
});
</script>";
};
So there is a "header" in jquery/javascript and then a foreach php part and at least a jquery "footer" part.
The problem is, that the wordpress no conflict (I guess this is the reason), deletes all the $variables.
Can somebody help me to fix this?
Thank you