WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#42226 closed defect (bug) (fixed)

Normalise access widget_title in WP_Widget_Media

Reported by: Bsop Owned by: westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.8
Component: Widgets Keywords: has-patch
Focuses: template Cc:
PR Number:

Description

It seems that in most default widgets, the filter widget_title is always available, even if the user did not provide a title. In the abstract class WP_Widget_Media however, this is not the case, the apply_filters function will only be called if a title property exists in $instance. This is of course impractical when one wants to apply a hook callback to all default widget titles.

Attachments (2)

normalise-widget-title.diff (863 bytes) - added by Bsop 2 years ago.
patch
normalise-widget-title.2.diff (851 bytes) - added by Bsop 2 years ago.
actually test for filtered title

Download all attachments as: .zip

Change History (5)

@Bsop
2 years ago

patch

@Bsop
2 years ago

actually test for filtered title

#1 @westonruter
2 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.9
  • Owner set to westonruter
  • Status changed from new to accepted
  • Version changed from trunk to 4.8

Good catch.

#2 @SergeyBiryukov
2 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 41866:

Widgets: In WP_Widget_Media, apply widget_title filter regardless of whether the title is empty, same as other widgets do.

Props Bsop.
Fixes #42226.

#3 @SergeyBiryukov
2 years ago

In 41867:

Widgets: Move empty title checks out of the apply_filters( 'widget_title' ) calls for clarity.

See #42226.

Note: See TracTickets for help on using tickets.