[wp-trac] [WordPress Trac] #42548: Widgets: Populate global $post with queried object on singular queries instead of nullifying it

WordPress Trac noreply at wordpress.org
Wed Nov 15 00:40:37 UTC 2017


#42548: Widgets: Populate global $post with queried object on singular queries
instead of nullifying it
--------------------------------------------------+------------------
 Reporter:  westonruter                           |       Owner:
     Type:  defect (bug)                          |      Status:  new
 Priority:  normal                                |   Milestone:  4.9
Component:  Widgets                               |     Version:  4.9
 Severity:  normal                                |  Resolution:
 Keywords:  has-patch needs-testing dev-feedback  |     Focuses:
--------------------------------------------------+------------------
Changes (by westonruter):

 * keywords:  has-patch needs-testing 2nd-opinion => has-patch needs-testing
     dev-feedback


Comment:

 [attachment:42548.6.diff] undoes the changes to `gallery_shortcode()`,
 since the changes weren't able to apply to plugins that filter
 `post_gallery` to override the default gallery behavior. In a future
 release we may want to revisit this to see if there is a better way to
 contextually render galleries when they are rendered in non-singular
 templates.

 In ≤4.8, gallery shortcodes without explicit `ids` appearing in Text
 widgets (when a plugin adds support shortcode support) already have the
 behavior: when a theme resets the `$post` global or it is not set to begin
 with (such as on the 404 template) then the gallery widget currently will
 list out all attachments. In #10457 this behavior was applied to every
 widget in whatever context, even singulars. So [attachment:42548.6.diff]
 makes sure that the `$post` is consistently the queried object (post) when
 `is_singular()`. Even before 4.9 if a user intended to have a widget
 appear in a sidebar and for it to rely on the post context, they should
 have already been using a sidebar that is dedicated for the singular
 template, or else use something like Jetpack Visibility to prevent the
 widget from appearing on anything aside from singular queries.

 See full discussion with arguments for why `gallery_shortcode()` remains
 unchanged in 4.9:
 https://wordpress.slack.com/archives/C02RQBWTW/p1510703055000030

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


More information about the wp-trac mailing list