Title: character gets cut
Last modified: August 21, 2016

---

# character gets cut

 *  Resolved [solhuebner](https://wordpress.org/support/users/solhuebner/)
 * (@solhuebner)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/character-gets-cut/)
 * Hi.
 * When my snippet start with “public” (like public function) then the “p” is removed
   when I save my snippet… If I put a line with for example “//” above it the “p”
   is fine…?!
 * [http://wordpress.org/plugins/code-snippets/](http://wordpress.org/plugins/code-snippets/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/character-gets-cut/#post-4066722)
 * 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).
 *  Thread Starter [solhuebner](https://wordpress.org/support/users/solhuebner/)
 * (@solhuebner)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/character-gets-cut/#post-4066737)
 * 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 🙂
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/character-gets-cut/#post-4066738)
 * 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`.
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/character-gets-cut/#post-4066796)
 * Okay, this has been fixed in the [development version](https://github.com/bungeshea/code-snippets/tree/develop),
   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.
 *  Thread Starter [solhuebner](https://wordpress.org/support/users/solhuebner/)
 * (@solhuebner)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/character-gets-cut/#post-4066797)
 * Thank you very much! I will try asap but it can take till monday 🙂
 *  Thread Starter [solhuebner](https://wordpress.org/support/users/solhuebner/)
 * (@solhuebner)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/character-gets-cut/#post-4066800)
 * No problems so far for me 🙂
 * Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘character gets cut’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [solhuebner](https://wordpress.org/support/users/solhuebner/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/character-gets-cut/#post-4066800)
 * Status: resolved