WordPress converting my code

I am having difficulty with WordPress continually changing my code on me. IE:

FROM THIS:

Read More
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/swfobject.js" ></script>

TO:

<script src="&lt;?php echo get_stylesheet_directory_uri(); ?" type="text/javascript">// <![CDATA[
/js/swfobject.js" >
// ]]></script>

And it’s driving me crazy… is there anyway to disable this from happening?
I will be having other people edit these pages so to disable the “GUI EDITOR in the users profile” doesn’t seem like a good solution.

Any help is appreciated.

Related posts

Leave a Reply

2 comments

  1. <script> tags go in the document head, not in the document body (or, if in the document body, they should be the very last thing before the closing </body> tag.

    Besides, if you’re adding code of any sort in your post, you’re going to run into issues if you use the Visual editor, or, more likely, if you’re switching between the Visual and HTML editors.

  2. Aside from the bad practice of adding script tags in your post content, you’re actually including PHP calls, which is horrendous security practice.

    There are plugins that can make this possible, but I would strongly recommend against them, and measures to make this work will almost certainly cripple the effectiveness of your security. Defacement or malware hijack attacks would be highly likely, and if your client is in anyway tech savvy, they’ll likely demand their money back.

    Put this kind of call in the header.php or the footer, it should never be inside your post content.

    I cannot stress how big a flaw this is, and I would consider code like this to be an urgent issue, regardless of wether it worked or not, not just from a security and maintenance point of view, but from a code quality and design viewpoint. This sort of thing always comes back and bites you on the arse with more work to fix things.