Make WordPress Core

Opened 8 years ago

Closed 5 years ago

Last modified 4 years ago

#46228 closed enhancement (fixed)

wp_insert_post_data should include $update

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

Description

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 8 years ago.
Patch.

Download all attachments as: .zip

Change History (6)

@mukesh27
8 years ago

Patch.

#1 @mukesh27
8 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 8 years ago by mukesh27 (previous) (diff)

#2 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review6.0

#3 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

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
4 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
4 years ago

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