Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#42547 closed defect (bug) (fixed)

Widgets: Nullify $post global in Custom HTML widget

Reported by: westonruter's profile westonruter Owned by: westonruter's profile westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.9
Component: Widgets Keywords: has-patch commit dev-reviewed
Focuses: Cc:

Description

Handling of shortcodes was added to the Text widget in #10457. When shortcodes are processed in the Text widget, the global $post is nullified so that the shortcodes run in a consistent non-post context, since a widget can appear on any template even 404.

The Custom HTML widget was introduced in 4.8.1 as a replacement for legacy use of the Text widget as a place to paste arbitrary HTML. Plugins also added shortcode support on the widget_text filter, which the Custom HTML widget also applies for backwards compatibility. However, the $post nullification logic from the Text widget was not also implemented in the Custom HTML widget, so there's currently a situation where if you try using a shortcode in the Custom HTML widget it could get rendered whereas it wouldn't in the Text widget.

Change History (7)

#1 @westonruter
7 years ago

  • Keywords has-patch dev-feedback commit added; needs-patch removed

See patch on #10457, which will resolve this ticket as well.

This ticket was mentioned in Slack in #core by westonruter. View the logs.


7 years ago

This ticket was mentioned in Slack in #core by westonruter. View the logs.


7 years ago

#4 @joemcgill
7 years ago

  • Keywords dev-reviewed added; dev-feedback removed

Reiterating my +1 from #42548.

#5 @westonruter
7 years ago

  • Owner set to westonruter
  • Resolution set to fixed
  • Status changed from new to closed

In 42185:

Widgets: Set global $post to current queried object instead of nullifying when is_singular() while applying filters (and shortcodes) in Text widget and (via plugin) Custom HTML widget.

Also prevent [gallery] shortcode from dumping out every attachment on the site when a containing Text widget is shown on an archive template.

Props westonruter, bobbingwide, joemcgill for testing.
See #10457.
Fixes #42548, #42547 for trunk.

#6 @westonruter
7 years ago

In 42186:

Widgets: Set global $post to current queried object instead of nullifying when is_singular() while applying filters (and shortcodes) in Text widget and (via plugin) Custom HTML widget.

Also prevent [gallery] shortcode from dumping out every attachment on the site when a containing Text widget is shown on an archive template.

Props westonruter, bobbingwide, joemcgill for testing.
See #10457.
Fixes #42548, #42547 for 4.9.

#7 @johnbillion
7 years ago

  • Milestone changed from 4.9.1 to 4.9
Note: See TracTickets for help on using tickets.