views:

221

answers:

3

I'm using the following code in one of my WordPress plugin files:

else if($filetype == 'swf'){
print
<<<EOT
<script type="text/javascript" language="javascript">
jQuery(document).ready(function(){
var embed = '<div>[kml_flashembed movie="$img" /]</div>';
jQuery("#header").prepend(jQuery(embed));
});
</script>
<style type="text/css">
#$headerID {
background: none;   
}
.flashmovie {
position: absolute;
}
</style>
EOT;}

But instead of parsing the [kml_flashembed] block, it gets spit out as it is. I manually put it in my header.php file and there it rendered fine, so the problem is in the way the JavaScript is injecting it into the HTML.

Can someone shed some light on what I should change to get the tag to parse instead of getting rendered literally?

(The tag is for the WordPress Kimili Flashembed plugin.)

Thanks.

A: 

Does this help?

John at CashCommons
Thanks but no, it doesn't. The jQuery is loading fine and the code is working, it's just that the shortcode isn't getting parsed. Thanks though.
pthesis
A: 

Try using the do_shortcode function to expand the shortcode.

Richard M
I changed it to the following: else if($filetype == 'swf'){ $content = do_shortcode("[kml_flashembed movie=\"$img\" /]"); print <<<EOT <script type="text/javascript" language="javascript"> jQuery(document).ready(function(){ alert($content); jQuery("#$headerID").prepend(jQuery($content)); }); </script>Firebug tells me:`missing ] after element list`Any thoughts or suggestions?
pthesis
+1  A: 

You can't expect PHP to replace the [kml_flashembed movie="$img" /] if you place it inside of a heredoc block

else if($filetype == 'swf'){
print <<<EOT
<script type="text/javascript" language="javascript">
jQuery(document).ready(function(){
var embed = '<div>
EOT;
[kml_flashembed movie="$img" /]
print <<<EOT2
</div>';
jQuery("#header").prepend(jQuery(embed));
});
</script>
<style type="text/css">
#$headerID {
background: none;   
}
.flashmovie {
position: absolute;
}
</style>
EOT2;}
jitter
This makes total sense, but it's not working for me. I don't see any errors in Firebug, the page just spits out blank. When I comment out this code the page loads fine, so the problem is here somewhere. I made sure there aren't any spaces before or after the `EOT;` and `EOT2;` tags.What else could it be? Thanks for your help.
pthesis
Slightly changed the code retry please. Maybe also prepend a print to the `[kml....]` block
jitter
No luck unfortunately. Without `print` in front of the block it prints a blank page. With the `print` it spits out the`[kml...]` block literally like it was doing before.
pthesis