#4477 closed defect (bug) (fixed)
Unfiltered post titles in Recent Comments widget
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.2.2 | Priority: | normal |
Severity: | normal | Version: | 2.2 |
Component: | General | Keywords: | widget, filter, has_patch |
Focuses: | Cc: |
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 (2)
Change History (8)
#2
@
16 years ago
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.
#3
@
16 years ago
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.
#4
@
16 years ago
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].
@
16 years ago
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.
Patch to add filter to post titles for Recent Comments widget