将Wordpress短代码附加到css类?

So...

After hours of trial and error, I can't seem to get this working.

I have a plugin called woodiscuz, which allows users to comment on products (it's an e-commerce store running woocommerce, nothing fancy).

Here's a screenshot of what it looks like: https://i.stack.imgur.com/2oH5T.png

I have another plugin called myCRED, which serves as a loyalty scheme. (get points when you spend, etc)

myCRED comes with badges, and you can display a users earned badges by using [mycred_my_badges]. I want this badge/shortcode to appear under the STAFF badge.

So i figured, hey why don't i just use the do_shortcode() function i learned recently... Nope.

This is the code I have tried to use:

$( ".wpc-comment-left" ).append( document.createTextNode(<?php echo do_shortcode(“[mycred_my_badges]”); ?>) );

Now, looking at the comment screenshot, the blue box is a css class called "wpc-comment-left", hence why i'm trying to append my shortcode to it. The red part is where i want the badges to appear.

I hope this makes sense to some of you. I don't know where else to look and I know very little PHP and JS so any help is highly appreciated.

Cheers!

</div>

You need to encode the string for javascript in case of quotes etc, and wrap the generated string in quotes:

$( ".wpc-comment-left" ).append( document.createTextNode("<?php echo json_encode(do_shortcode("[mycred_my_badges]")); ?>") );