Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#23399 closed enhancement (duplicate)

Add filter wp_insert_attachment_data mirroring wp_insert_post_data

Reported by: israelshirk's profile israelshirk Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.5
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

In commercial applications it's handy to use the wp_insert_post_data filter in wp_insert_post() to control attributes of a post being inserted based on the user's role and other variables. We're using this to force content to go through a complex approval process which runs off of the post status.

wp_insert_attachment() does not have a similar filter, which makes content approval processes difficult to implement.

This patch adds a filter named wp_insert_attachment_data filter to wp_insert_attachment() which mirrors the form and functionality in wp_insert_post().

Attachments (1)

wp_insert_attachment_data.diff (1.2 KB) - added by israelshirk 11 years ago.
Patch to post.php with wp_insert_attachment_data filter similar to wp_insert_post_data filter.

Download all attachments as: .zip

Change History (5)

@israelshirk
11 years ago

Patch to post.php with wp_insert_attachment_data filter similar to wp_insert_post_data filter.

#1 @SergeyBiryukov
11 years ago

  • Keywords has-patch added
  • Version changed from trunk to 3.5

#2 @ocean90
11 years ago

Related: #21963

#3 @bendoh
10 years ago

Bumping this.

I ran into a situation where this filter would have saved me an extra query: I would have been able to transform the data before it ever went into the database. But since there's no filter on this, there's no way to modify the attachment data going in via media_handle_slideload() before it hits the database, which means there's no opportunity for validation or data transformation.

Instead, the insert had to be performed before the validation / transformation step could be applied, which wasted a query.

#4 @helen
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

I actually think we should close this in favor of #21963, so I'm going to mark it as a dupe.

Note: See TracTickets for help on using tickets.