WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 3 weeks ago

#43638 reviewing enhancement

Introducing 'sanitize_post' filter

Reported by: enrico.sorcinelli Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.1
Component: Posts, Post Types Keywords: has-patch has-unit-tests reporter-feedback
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 13 months ago.
43638.2.patch (2.9 KB) - added by enrico.sorcinelli 12 months ago.

Download all attachments as: .zip

Change History (9)

#1 @enrico.sorcinelli
13 months ago

  • Keywords has-patch has-unit-tests added

#2 @SergeyBiryukov
13 months ago

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

#3 @enrico.sorcinelli
12 months ago

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

#4 @pento
6 months ago

  • Milestone changed from 5.0 to 5.1

#5 @pento
3 months ago

  • Milestone changed from 5.1 to 5.2

#6 @SergeyBiryukov
4 weeks ago

  • Milestone changed from 5.2 to 5.3

Missed the 5.2 Beta 1 deadline, moving to 5.3.

#7 in reply to: ↑ description @SergeyBiryukov
3 weeks ago

  • Keywords reporter-feedback added

Replying to enrico.sorcinelli:

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

What about using the wp_insert_post_data filter for that? Just want to make sure I understand the use case.

Note: See TracTickets for help on using tickets.