Opened 3 years ago

Last modified 3 years ago

#15515 new enhancement

content_save_pre et al don't supply context

Reported by: johnbillion Owned by:
Priority: normal Milestone: Future Release
Component: Plugins Version:
Severity: normal Keywords: has-patch
Cc:

Description

All of the {field}_save_pre filters don't provide any additional parameters with context. The {field}_edit_pre (when editing) and post_{field} (when displaying) filters pass the $post_id variable as a second parameter. The {field}_save_pre filter is the odd one out.

Currently if a plugin uses (for example) the content_save_pre filter and needs to know anything about the post (eg. the post type) then it has to use the global $post object directly. It works, but it's not ideal.

Can we add some context to these hooks? All they need is a second parameter containing the $post_id variable to bring them in line with the other field filters.

Attachments (2)

15515.patch (795 bytes) - added by johnbillion 3 years ago.
15515.2.patch (504 bytes) - added by johnbillion 3 years ago.
Patch for commetn_save_pre

Download all attachments as: .zip

Change History (6)

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Excellent idea. Patches Welcome :-)

comment:2 follow-up: ↓ 3   SergeyBiryukov3 years ago

Should post ID be added to pre_{field}, pre_post_{field}, {field}_pre and comment ID to comment_save_pre as well? Or is {field}_save_pre the only one that needs modification?

comment:3 in reply to: ↑ 2   johnbillion3 years ago

  • Keywords has-patch added; needs-patch removed

Patch.

Replying to SergeyBiryukov:

Should post ID be added to pre_{field}, pre_post_{field}, {field}_pre and comment ID to comment_save_pre as well?

Yeah I've added it to pre_{field}, pre_post_{field} and {field}_pre too.

Patch for commetn_save_pre

Patch for comment_save_pre as suggested by SergeyBiryukov. However it might be worth discussing if the other comment fields should be filtered too at this point, for consistency.

Note: See TracTickets for help on using tickets.