This is a very interesting problem that I am running into. I am appending a div with a pinterest button using javaScript but I am using PHP inside the Javascript to determine what the source of the image and the URL of the page to send to pinterest.
I am doing it this way instead of using plain HTML provided by pinterest because I have found that you can use your own branded pinterst button .jpg instead of the iFrame that pinterest uses and forces you to use their branding. I have used this javaScript successfully on other parts of my sites without using PHP. I am very new to PHP and JavaScript so I am not sure if I am missing anything but I have spent countless hours tinkering with this problem and need a fresh set of eyes. Thanks for all your help!
function add_social_media () {
?>
<p align="right">
<a href="http://twitter.com/home?status=<?php print(urlencode(get_permalink())); ?>+<?php print(urlencode(the_title())); ?>">
<img src="/sites/aerialist.localhost/files/images/twitter.jpg" alt="Share On Twitter" /></a>
<a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Ffamousartistprints.com%2F&media=http%3A%2F%2Ffamousartistprints.com%2F" ><img border="0" src="/sites/aerialist.localhost/files/images/twitter.jpg"/></a>
<script>
jQuery(document).ready(function() {
jQuery('#pinItDiv').append( '<a class="pin-it-button" href="http://pinterest.com/pin/create/button/?url='+
<?php the_permalink(); ?>+
'&media='+
//set your image path here
<?php if(function_exists('the_post_thumbnail')) echo wp_get_attachment_url(get_post_thumbnail_id()); ?>+
'&description='+<?php echo get_the_title(); ?>'">'+
'<img class="pinItSuite" title="Pin It" src="/sites/aerialist.localhost/files/images/pinSuite.jpg" alt="" border="0" /></a>');
});
</script>
<?php
}
add_action('thesis_hook_before_headline', 'add_social_media');