[wp-trac] [WordPress Trac] #39850: WordPress embedded links drop query vars from URL (was: Wordpress embedded links drop query vars from URL)

WordPress Trac noreply at wordpress.org
Sat Feb 11 23:20:27 UTC 2017


#39850: WordPress embedded links drop query vars from URL
-------------------------+------------------------------
 Reporter:  charleslf    |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Embeds       |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------
Description changed by swissspidy:

Old description:

> When embedding a wordpress page within another post, any query strings
> that are passed in the URL get dropped.
>
> For example, if embedding http://example.com/page-name/?foo=bar, the
> actual URL that gets passed to the oEmbed function (and later on to the
> template files) is http://example.com/page-name/embed/  (foo=bar gets
> dropped).
>
> The link inside the blockquote also drops the url query variable and
> links to http://example.com/page-name/ instead of http://example.com
> /page-name/?foo=bar
>
> As I see, this occurs because the `wp_filter_pre_oembed_result` function
> in `embed.php` uses `url_to_postid` to get the embeded post's ID, and
> later `get_post_embed_url` uses that ID to create the embed permalink. So
> naturally any url query vars are not preserved in the final URL
> construction.
> Similarly in `get_post_embed_html`, the function uses `esc_url(
> get_permalink( $post ) )`, thus  reconstructing the permalink without
> knowledge of the initial url.
>
> I encountered this when embedded a specific photo gallery (from
> nextcellent plugin), but I assume some other plugins such as
> language/translation ones may also be affected.
>
> I don't think the URL's should be dropping any of the query variables.
> However, if that is a requirement, it would be good to also pass on the
> original url in the `post_embed_url` hook to allow plugin developers to
> make sure to add any parameters from the original url that got dropped
> off in the embedded url.

New description:

 When embedding a WordPress page within another post, any query strings
 that are passed in the URL get dropped.

 For example, if embedding http://example.com/page-name/?foo=bar, the
 actual URL that gets passed to the oEmbed function (and later on to the
 template files) is http://example.com/page-name/embed/  (foo=bar gets
 dropped).

 The link inside the blockquote also drops the url query variable and links
 to http://example.com/page-name/ instead of http://example.com/page-
 name/?foo=bar

 As I see, this occurs because the `wp_filter_pre_oembed_result` function
 in `embed.php` uses `url_to_postid` to get the embeded post's ID, and
 later `get_post_embed_url` uses that ID to create the embed permalink. So
 naturally any url query vars are not preserved in the final URL
 construction.
 Similarly in `get_post_embed_html`, the function uses `esc_url(
 get_permalink( $post ) )`, thus  reconstructing the permalink without
 knowledge of the initial url.

 I encountered this when embedded a specific photo gallery (from
 nextcellent plugin), but I assume some other plugins such as
 language/translation ones may also be affected.

 I don't think the URL's should be dropping any of the query variables.
 However, if that is a requirement, it would be good to also pass on the
 original url in the `post_embed_url` hook to allow plugin developers to
 make sure to add any parameters from the original url that got dropped off
 in the embedded url.

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39850#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list