Make WordPress Core

Opened 5 years ago

Closed 2 years ago

Last modified 2 years ago

#46228 closed enhancement (fixed)

wp_insert_post_data should include $update

Reported by: nhadsall's profile nhadsall Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.0 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch dev-feedback add-to-field-guide
Focuses: Cc:


wp_insert_post() has a great filter: 'wp_insert_post_data', but it doesn't contain the status of $update (if the post is being updated or new). So, our options are 1. check again if this is an update (redundant) or 2. wait for the 'save_post' action and resave the post with changes (making redundant DB calls). So, it seems the best solution is 3. simply add $update as a parameter to wp_insert_post_data.

Attachments (1)

46228.diff (681 bytes) - added by mukesh27 5 years ago.

Download all attachments as: .zip

Change History (6)

5 years ago


#1 @mukesh27
5 years ago

  • Keywords has-patch dev-feedback added

Hi @nhadsall, Welcome to WordPress Trac! Thank you for your ticket.

+1 on your thought as it's great to add $update variable in filter.

Last edited 5 years ago by mukesh27 (previous) (diff)

#2 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 6.0

#3 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 52691:

Posts, Post Types: Pass the $update parameter to wp_insert_post_data and wp_insert_attachment_data filters.

This makes it easier to determine in a callback function whether this is an existing post being updated or not.

Follow-up to [8635], [8702], [27130], [27138], [28106], [28788], [47633].

Props nhadsall, mukesh27.
Fixes #46228.

#4 @milana_cap
2 years ago

  • Keywords needs-dev-note added

Marking for dev note just to be mentioned in Field guide, rather than having dedicated dev note.

#5 @milana_cap
2 years ago

  • Keywords add-to-field-guide added; needs-dev-note removed
Note: See TracTickets for help on using tickets.