0

I have a Wordpress plugin. inside this plugin there is a php file.(for example name.php) this php file contains some codes which they are inside this code:

<script type="text/html" id="tmpl-dokan-single-variations">
//codes
</script>

Now I want to add some Javascript codes and I've tried this code:

<script type="text/html" id="tmpl-dokan-single-variations">
<script type="text/javascript">
//mycodes
</script> 
//codes
</script>

Also I've tried echo script but it doesn't work either. Please tell me how can I add some javascript code inside this file?

2 Answers 2

0

There is no way to include the raw string </script> inside a script element.

You would need to find some alternative representation of it (such as <!-- TEMPLATE: SCRIPT END TAG --> and then modify the code (which is presumably JavaScript) that reads the value of the <script type="text/html"> element so it can replace that alternative representation with the end tag you actually want.

Sign up to request clarification or add additional context in comments.

Comments

-1

I dont know what your php file looks like but you can echo your script like this

<?php 

    echo '
    <script>

    // your code here

    </script> 
    ';

?>

1 Comment

It doesn't matter how you output the code from the PHP. The HTML will still be wrong when it gets to the client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.