WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 7 weeks ago

#43638 reviewing enhancement

Introducing 'sanitize_post' filter

Reported by: enrico.sorcinelli Owned by: SergeyBiryukov
Milestone: 5.0 Priority: normal
Severity: normal Version: trunk
Component: Posts, Post Types Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

I was trying to do a post field sanitization on new post insertions that depended on the value of another field.

While it quite easy in administration context, using for example pre_{$field} or {$field_no_prefix}_save_pre filters in conjunction to $_POST and so on, it seems that there's no direct way using wp_insert_post since the filters above do not have references to the other fields or to the ID of the post (which is also useless in the case of new posts) but only refers to the value to be sanitized.

So this enhancement aims to introduce new sanitize_post filter.

PS: Of course I could sanitize values directly in wp_insert_post but only assuming I have control of the code or at the cost of duplicate the sanitization in each wp_insert_post calls. 

Attachments (2)

43638.patch (2.5 KB) - added by enrico.sorcinelli 3 months ago.
43638.2.patch (2.9 KB) - added by enrico.sorcinelli 7 weeks ago.

Download all attachments as: .zip

Change History (5)

#1 @enrico.sorcinelli
3 months ago

  • Keywords has-patch has-unit-tests added

#2 @SergeyBiryukov
3 months ago

  • Milestone changed from Awaiting Review to 5.0
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @enrico.sorcinelli
7 weeks ago

I just updated the patch by moving the filter at the end of sanitize_post() function.

Note: See TracTickets for help on using tickets.