Home › Forums › Weaver Xtreme Theme › Youtube Shortcode not working
- This topic has 23 replies, 4 voices, and was last updated 5 years, 5 months ago by
scrambler.
-
AuthorPosts
-
August 11, 2017 at 15:17 UTC - Views: 52 #50769
Weaver
KeymasterI 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.
August 12, 2017 at 00:42 UTC - Views: 55 #50774Weaver
KeymasterThe 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.
August 12, 2017 at 01:12 UTC - Views: 32 #50776scrambler
ModeratorI hate invisible characters ๐
August 12, 2017 at 01:28 UTC - Views: 30 #50778Gillian
ModeratorWhich 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 ๐
August 12, 2017 at 01:32 UTC - Views: 27 #50780scrambler
Moderatorthey are not WYSIWYG, but WYSINWYG ๐
August 12, 2017 at 01:55 UTC - Views: 25 #50783Gillian
ModeratorIndeed ๐
August 12, 2017 at 02:30 UTC - Views: 22 #50788bcslaam
ParticipantI 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?
August 12, 2017 at 03:02 UTC - Views: 21 #50791scrambler
ModeratorStay 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.
-
AuthorPosts
- You must be logged in to reply to this topic.