Title: php tags getting mangled
Last modified: August 30, 2016

---

# php tags getting mangled

 *  Resolved [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/)
 * `<code><?php echo 'hi'; ?></code>`
    gets mangled to `<p><code><!--?php echo '
   hi'; ?--></code></p>` and even worse `<form action="<code><?php $GLOBALS['theme_dir'].'/
   setcimy.php';?></code>" method="post"></form>` gets mangled to `<form action="
   <code><?php $GLOBALS['theme_dir'] . '/setcimy.php';?></code>" method="post"></
   form>`
 * And yes, I have a plugin that let’s me use the php tags in posts and widgets.
 * Any ideas, anyone?
 * [https://wordpress.org/plugins/wp-edit/](https://wordpress.org/plugins/wp-edit/)

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/php-tags-getting-mangled/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-tags-getting-mangled/page/2/?output_format=md)

 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471403)
 * Oops! Disregard the previous. Here’s the correct post.
 * `<?php echo 'hi'; ?>`
    gets mangled to <p>`<!--?php echo 'hi'; ?-->`</p> and 
   even worse <form action=”`<?php $GLOBALS['theme_dir'] . '/setcimy.php';?>`” method
   =”post”></form> gets mangled to **` <form action=”<code><?php $GLOBALS[‘theme_dir’].‘/
   setcimy.php’;?></code>” method=”post”></form> ` And yes, I have a plugin that
   let’s me use the php tags in posts and widgets.
 * Any ideas, anyone?
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471407)
 * Oops! Disregard the previous. Here’s the correct post. I tried to edit the second
   one, but couldn’t figure it out. Sorry.
 * This editor corrects the second mangled code I’m trying to paste. It can be found
   here: [http://pastie.org/10373221](http://pastie.org/10373221)
 * `<?php echo 'hi'; ?>`
    gets mangled to <p>`<!--?php echo 'hi'; ?-->`</p> and 
   even worse <form action=”`<?php $GLOBALS['theme_dir'] . '/setcimy.php';?>`” method
   =”post”></form> gets mangled to **`**
 * <blockquote><form action=”`<?php $GLOBALS['theme_dir'] . '/setcimy.php';?>`” 
   method=”post”></form>
 * And yes, I have a plugin that let’s me use the php tags in posts and widgets.
 * Any ideas, anyone?
 *  Plugin Author [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471411)
 * Neither WP Edit nor WordPress allow php code to be evaluated from directly within
   the content editor. But, you already knew that 🙂
 * So, now it begs the question… What plugin are you using to allow PHP code in 
   posts and widgets?
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471420)
 * [https://wordpress.org/plugins/allow-php-execute/](https://wordpress.org/plugins/allow-php-execute/)
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471428)
 * It wouldn’t be a problem except for my other issue described here.
    [https://wordpress.org/support/topic/cant-get-admin_post_-to-work?replies=8#post-7340775](https://wordpress.org/support/topic/cant-get-admin_post_-to-work?replies=8#post-7340775)
 *  Plugin Author [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471543)
 * Okay, first I would submit a support ticket with the plugin developer:
    [https://wordpress.org/support/plugin/allow-php-execute](https://wordpress.org/support/plugin/allow-php-execute)
 * Then, I might try a different plugin that offers the same feature; just for comparison(
   does it do the same thing).
 * Lastly; I’ll experiment with the plugin as well, and see what I can determine.
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471554)
 * I’ve tried several different plugins, some using shortcodes ([php] … [/php]),
   others using the usual php codes (<?php … ?>). Using the former, the square brackets
   get mangled. It’s annoying, but not fatal. It just means that I have to hardwire
   the form’s action string rather than letting php determine the file location.
   `
   <form action="http://prospectparkna.org/wp-content/themes/frontier-child/setcimy.
   php" method="post">` instead of `<form action="<?php echo get_stylesheet_directory_uri);?
   >/setcimy.php" method="post">`
 * So I don’t think it’s a plugin problem, but more that the editor doesn’t save
   what’s entered in text mode without first processing it through a filter. In 
   other words, what shows up when the page is loaded is different than what shows
   in the editor. Switching from the text mode to visual and then back to text shows
   what actually happens.
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471631)
 * Here’s another example: `<script>alert('hi');</script>`
    gets turned into:
 * > `<script>// <![CDATA[
   >  alert(‘hi’); // ]]></script>`
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471650)
 * Even though I’m running Linux, in desperation I exited everything, and rebooted.
   Much to my surprise, everything works as expected and the problem went away. 
   Learned something! Even with Linux, try rebooting.
 *  Plugin Author [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471653)
 * Hey Mike… sorry for my delay.
 * Hmmm… I’m wondering if that really solved the issue?? It really looks like the
   default WordPress filters that are mangling the code.
 * Out of curiosity… please let me know after you experiment for a bit. I’d like
   to know if this really fixes the issue.
 * Thanks mate.
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471655)
 * I installed a plug-in called “Allow PHP Execute”, which allows one to put php
   in a page or post. To use, one enters the “text” mode of the editor, and simply
   adds `<?php some_php_code ?>`. Switching to visual, and then back to text, we
   see that the php is transformed into `<!--?php some_php_code ?-->`, which looks
   not quite right, but works just fine.
 * So, to summarize, `<html> some html stuff <?php phpstuff ?> more html <?php morephpstuff?
   > html stuff </html>` works as expected.
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471657)
 * Incidentally, there’s another plugin called “Shortcode Exec Php”, which allows
   one to enter php code in a text box, store it by name, and it produces shortcode
   for inclusion in pages, posts, and so on. What makes it special is that the code
   that you type in can be tested on the spot, so you can make sure it works before
   putting it in a page. Very handy.
 *  Plugin Author [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471667)
 * Excellent Mike.
    Thanks for the helpful tips. I appreciate you coming back here
   to share your experience. I’m sure it will be helpful for someone in the future.
 * Please have a great day.
 *  Thread Starter [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * (@mikemoum)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471674)
 * You’re welcome. The crazy thing is that I could have saved myself a lot of grief
   if I’d been using Windows, because rebooting is the universal solution. Rebooting
   never occurred to me with Linux – this is the first time in years that it’s ever
   fixed anything!
 *  Plugin Author [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/#post-6471675)
 * Lol… funny.
 * I’ve ran quite a few WordPress installs… some on Linux… some on Windows. I’ve
   found that Windows seems to “play better” with WordPress. Perhaps because I never
   thought of re-booting Linux 😉

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/php-tags-getting-mangled/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-tags-getting-mangled/page/2/?output_format=md)

The topic ‘php tags getting mangled’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-edit_ffffff.svg)
 * [WP Edit](https://wordpress.org/plugins/wp-edit/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-edit/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-edit/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-edit/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-edit/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-edit/reviews/)

 * 16 replies
 * 2 participants
 * Last reply from: [mikemoum](https://wordpress.org/support/users/mikemoum/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/php-tags-getting-mangled/page/2/#post-6471676)
 * Status: resolved