wp-shortcake / shortcake-bakery

A fine selection of shortcodes for WordPress
42 stars 16 forks source link

youtube playlist id missing from embed url on frontend only #145

Closed montchr closed 8 years ago

montchr commented 8 years ago

If I add a YouTube video with a playlist ID in the URL, the shortcode text includes the full URL I supplied it, and the in-editor rendering of the <iframe> uses this URL and the resulting embed indicates that the video is in a playlist:

However, when I view the post on the frontend, the URL for the <iframe> does not include the playlist ID, and the embed treats the video as a single video:

danielbachhuber commented 8 years ago

Huh. Can you share the full shortcode?

There isn't any functional difference between the frontend and the backend: https://github.com/wp-shortcake/shortcake-bakery/blob/master/inc/shortcodes/class-youtube.php#L46-L75

montchr commented 8 years ago

[youtube url="https://www.youtube.com/watch?v=f9y9Snt1g5E&list=PL6F6DE2FF0854D7C6"]

danielbachhuber commented 8 years ago

Hm. The shortcode you provided works as expected for me locally.

Are you running Jetpack? Or do you have other plugins which could be interfering?

montchr commented 8 years ago

I just tested on a fresh install and the issue is still happening. Fresh clones of the Shortcake and Shortcake Bakery repos too.

danielbachhuber commented 8 years ago

Ok. I was able to reproduce. The problem seems to be specific to previewing a post.

When the shortcode is rendered during a preview, the passed URL is:

https://www.youtube.com/watch?v=f9y9Snt1g5E&#038;list=PL6F6DE2FF0854D7C6

When the shortcode is rendered after the post is saved and the permalink is accessed, the passed URL is:

https://www.youtube.com/watch?v=f9y9Snt1g5E&list=PL6F6DE2FF0854D7C6

parse_url() doesn't properly handle the #038; encoded version of the ampersand. However, I'm not sure why it's being encoded this way.

danielbachhuber commented 8 years ago

:hammer: