This is a known bug. It comes from the functionality that automatically removes the <?php
from the beginning of a snippet – it removes all characters individually, instead of the string as a whole.
I’ll try and fix this in a future version, perhaps by using a regex instead of using the ltrim
and rtrim
functions.
I’m not sure why you’re creating a public function outside of a class anyway…? Try starting the snippet with a different character for the time being (or using /**/
at the beginning of the snippet).
I just copied some snippet from a forum and saved it before editing 🙂 And then… where is the p? 😉
I do only use “normal” functions but wanted to tell it 🙂
I agree that this bug needs to be fixed, but I’m not very good with regex and still trying to find a working solution. It doesn’t come up much (if at all) because most snippets start with either function
, add_action
, add_filter
, or add_shortcode
.
Okay, this has been fixed in the development version, and the fix will be included in the next stable release.
I have replaced the *trim()
functions with some regex I wrote, which works much more reliably. Not only does it not strip extra characters (such as ‘p’ and ‘h’), it also doesn’t remove extra whitespace around the snippet.
Thank you very much! I will try asap but it can take till monday 🙂
No problems so far for me 🙂
Thank you!