Opened 7 years ago
Closed 6 years ago
#43638 closed enhancement (maybelater)
Introducing 'sanitize_post' filter
Reported by: | enrico.sorcinelli | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 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)
Change History (11)
#2
@
7 years ago
- Milestone changed from Awaiting Review to 5.0
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#7
in reply to:
↑ description
@
6 years 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.
#8
@
6 years ago
@enricosorcinelli To answer @SergeyBiryukov's question, does the wp_insert_post_data filter
work for your situation?
#9
@
6 years ago
- Milestone 5.3 deleted
- Resolution set to maybelater
- Status changed from reviewing to closed
I talked to @enrico.sorcinelli at WordCamp Torino. IIRC, wp_insert_post_data
should do the job here.
The consensus was that #21676 is more important, any efforts are better spent there.
Closing as maybelater
, feel free to reopen if still relevant.
I just updated the patch by moving the filter at the end of
sanitize_post()
function.