Home Forums Weaver Xtreme Theme Youtube Shortcode not working

Topic Resolution: Resolved
Viewing 8 posts - 17 through 24 (of 24 total)
  • Author
  • #50769

    I have definitely confirmed this is a totally unexpected WordPress bug in the do_shortcode function. I can’t believe it.

    For some reason I don’t yet understand, there are some cases that the code that finds shortcodes is returning a match as “youtube id” or “vimeo id” instead of just plain “youtube” or “vimeo” – id for this example, but the first parameter in general.

    I can’t believe that hundreds of shortcode aren’t broken, or why this seems to be only for the video codes.


    The real answer:

    This is a UTF8 character encoding problem, and WP doesn’t consider it a bug.

    UTF8 has a character code for a regular space (hex:”\xc2\xa1″), and a different code for a non-breaking space (hex:ย “\xc2\xa0”). I’m not even sure how one ends up with the non-breaking space inside text, but that is what has happened to the original example in this thread. (Maybe the editor will convert an   to the character?) I think the example shortcode in the very first post must be in UTF8, and that space before the id is a non-breaking space. I copy/pasted it, and ended up with the same non-breaking space character in my own tests.

    The regular expression used to break out shortcodes looks for a regular space, but a non-breaking space ends up being treated as a normal character. Thus [foo(non-breaking-space)id=123] ends up getting recognized as “foo(non-breaking-space)id” instead of foo.

    If one has lots of these, you can add a filter:

    add_filter( ‘wp_insert_post_data’, ‘rm_wp_insert_post_data’, ’99’, 2 );
    function rm_wp_insert_post_data ( $data , $postarr ) {
    return str_replace(“\xc2\xa0″, ” “, $data);

    that will convert the non-breaking space to a regular space when you save a page/post from the editor. Or you can simply go into the editor, delete the existing space between the ‘video’ and ‘id’ and insert a new one with the space bar, and it should work then.ย This is how I finally figured out what was going on.

    Perhaps if enough people complain to the WordPress bug reporting system, it might get fixed. I think they are wrong to treat a non-breaking-space as a character instead of a blank.


    I hate invisible characters ๐Ÿ™‚


    Which is why I use the text editor together with Chrome’s “Paste as plain text” feature because I hate all the ย extra junk WYSIWYG editors add ๐Ÿ™‚


    they are not WYSIWYG, but WYSINWYG ๐Ÿ™‚


    Indeed ๐Ÿ™‚


    I just did as you suggested and it worked!

    How do I avoid entering a non-breaking space. What could I have done to get one?


    Stay away from smart text editor that add invisible formatting character.

    Be especially careful if you are going to copy paste from an editor source.

    Use something like Notepad on windows.

Viewing 8 posts - 17 through 24 (of 24 total)
  • You must be logged in to reply to this topic.