WordPress.org

Forums

Code Snippets
[resolved] character gets cut (7 posts)

  1. solhuebner
    Member
    Posted 1 year ago #

    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/

  2. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    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).

  3. solhuebner
    Member
    Posted 1 year ago #

    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 :)

  4. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  5. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  6. solhuebner
    Member
    Posted 1 year ago #

    Thank you very much! I will try asap but it can take till monday :)

  7. solhuebner
    Member
    Posted 1 year ago #

    No problems so far for me :)

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.