Ticket #4477 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Unfiltered post titles in Recent Comments widget

Reported by: jhodgdon Assigned to: anonymous
Priority: normal Milestone: 2.2.2
Component: General Version: 2.2
Severity: normal Keywords: widget, filter, has_patch
Cc: jhodgdon

Description

The Recent Comments widget puts its post titles on the screen without filtering them with the standard 'the_title' filter. Post titles should always be filtered.

Verified filter missing in [5708] in trunk. Would be nice to patch the 2.2 branch as well as trunk, if it's not too much trouble. I will attach a patch...

Attachments

widgets-php.diff (1.0 kB) - added by jhodgdon on 06/15/07 22:45:03.
Patch to add filter to post titles for Recent Comments widget
get-the-title.diff (4.1 kB) - added by jhodgdon on 06/16/07 13:22:35.
Alternative patch that puts the filtering into get_the_title. Also removes filtering from the users of get_the_title, since they won't need fitlering now.

Change History

06/15/07 22:45:03 changed by jhodgdon

  • attachment widgets-php.diff added.

Patch to add filter to post titles for Recent Comments widget

06/16/07 01:16:42 changed by ryan

We should just apply it in get_the_title instead of the_title.

06/16/07 02:01:26 changed by jhodgdon

I'm not sure what you're suggesting, Ryan.

All over WordPress, the get_the_xyz functions are unfiltered, and the the_xyz functions call get_the_xyz, filter, and echo. So I don't think adding the filter to get_the_title is probably a good idea, if that is what you're suggesting. get_the_title is used in 22 places in the code base...

Or maybe you are saying to use the_title() instead of get_the_title()? Unfortunately, the_title does not take the post ID as an argument, so that won't work either.

06/16/07 08:47:13 changed by ryan

I'm saying not filtering in the get functions is silly. We could do it in one place instead of applying these patches everywhere. If someone wants the field unfiltered, grab it from the post object.

06/16/07 13:21:17 changed by jhodgdon

Ah. That would certainly make my life easier, if all of the get_the_xyz functions had the filters built into them, or at least get_the_title. But I'm also wondering if it's a little dangerous to change the behavior of all the get_xyz functions at this point, given that plugins/themes could conceivably be using them for something. They've been unfiltered for quite a while.

I checked on the get_the_title() function in [5718] and it looks like putting the filters in it would help all but one of the 22 uses of the function in the core, rather than hurting anything. The one place I wasn't sure about was in the_title, which puts $before and $after onto the title text before filtering. I suppose a $filter=true argument could be added to get_the_title to take care of that.

So, I've made a patch for get_the_title... will leave it to you to decide whether it would break plugins to change the behavior of get_the_title to filtered by default. I did apply it in my own test blog, and it didn't appear to break anything. Also it fixed the reported bug with the Recent Comments widget. Again, tested in [5718].

06/16/07 13:22:35 changed by jhodgdon

  • attachment get-the-title.diff added.

Alternative patch that puts the filtering into get_the_title. Also removes filtering from the users of get_the_title, since they won't need fitlering now.

06/25/07 17:48:36 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [5752]) Move the_title filter to get_the_title. Props jhodgdon. fixes #4477

06/25/07 17:50:09 changed by ryan

That changes the behavior of the_title. I looked over a bunch of plugins to see how the_title was being used, and I think the change should be low impact.