Text/Javascript in PHP?
Posted: Mon Sep 13, 2010 6:09 pm
I'm using a WordPress plugin called Photo Galleria. When the page is XHTML-validation checked the plugin causes two errors, both associated with the "<script>" codes. Basically, because text/javascript isn't declared it's not XHTML-valid. The hang-up being that when I declare the script type the plug-in crashes. Any help would be much appreciated.
Code: Select all
function photo_galleria_scripts_head(){
// Retreive our plugin options
$photo_galleria = get_option( 'photo_galleria' );
$design = $photo_galleria['design'];
if ($design == 'classic' || $design == '') {
$design = '/themes/classic/galleria.classic.js';}
elseif ($design == 'dots') {
$design = '/themes/dots/galleria.dots.js';}
elseif ($design == 'lightbox') {
$design = '/themes/lightbox/galleria.lightbox.js';}
$autoplay = $photo_galleria['autoplay'];
if ($autoplay == 1) { $autoplay = '5000'; }
if ($autoplay == 0) { $autoplay = 'false'; }
$height = $photo_galleria['height'];
if($height=="")
$height = 500;
$transition = $photo_galleria['transition'];
$color = $photo_galleria['color'];
$pluginURI = get_option('siteurl').'/wp-content/plugins/'.dirname(plugin_basename(__FILE__));
if(!is_admin()){
echo "<script>
// Load theme
Galleria.loadTheme('" . $pluginURI . "" . $design . "');
// run galleria and add some options
jQuery('#galleria').galleria({
autoplay: " . $autoplay . ",
height: " . $height . ",
transition: '" . $transition . "',
data_config: function(img) {
// will extract and return image captions from the source:
return {
title: jQuery(img).parent().next('strong').html(),
description: jQuery(img).parent().next('strong').next().html()
};
}
});
</script>
<style type='text/css'>.galleria-container {background-color: " . $color . "}</style>";
}
}
add_action('wp_footer','photo_galleria_scripts_head');