Make WordPress Core

Opened 14 years ago

Closed 12 years ago

#20547 closed enhancement (fixed)

Ability to define post attachment status on insertion

Reported by: griffinjt's profile griffinjt Owned by: wonderboymusic's profile wonderboymusic
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.4
Component: Media Keywords: dev-feedback
Focuses: Cc:

Description

By default, wp_insert_attachment will either set a new attachment as 'inherited' or 'private' - inherited being that it simply mimics the post status of its parent.

This is fine by default, but what about when wanting to run tests? For example, you have a live post that you want to add attachments to, but you want to ensure that the attachments (whatever they may be) are properly formatted before making them appear on your live post. By default, just uploading the attachment will push it live because it has inherited the published status of its parent.

Is this doable? What about filtering $object in the wp_parse_args function inside wp_insert_attachment to allow that property (along with the others - it makes sense to be able to filter them all) to be set?

Don't know how feasible it is, but if it's possible I'll work on a patch and tests.

Attachments (2)

20547.diff (974 bytes) - added by DrewAPicture 12 years ago.
filter docs
20547.2.diff (8.2 KB) - added by wonderboymusic 12 years ago.

Download all attachments as: .zip

Change History (15)

#1 @wonderboymusic
12 years ago

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

In 27130:

Add a filter wp_insert_attachment_data in wp_insert_attachment(). This is similar to the wp_insert_post_data filter in wp_insert_post().

Fixes #20547.

#2 @wonderboymusic
12 years ago

  • Milestone changed from Awaiting Review to 3.9

#3 @wonderboymusic
12 years ago

  • Focuses docs added
  • Keywords needs-docs added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#4 @wonderboymusic
12 years ago

  • Keywords dev-feedback removed

Needs filter docs for wp_insert_attachment_data.

@DrewAPicture
12 years ago

filter docs

#5 @DrewAPicture
12 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 27138:

Inline documentation for the wp_insert_attachment_data filter hook, added in [27130].

Fixes #20547.

#6 @helen
12 years ago

  • Keywords dev-feedback added; needs-docs removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm not sure about this - I closed a duplicate #23399 in favor of #21963. I guess since we'd keep the function as a wrapper it's not a lot of work to keep the hook going forward, but I'm reopening for more feedback.

#7 @DrewAPicture
12 years ago

  • Focuses docs removed

#8 follow-up: @wonderboymusic
12 years ago

are you daring me to combine the two functions? IN-VES-TI-GATING.

#9 @wonderboymusic
12 years ago

20547.2.diff makes wp_insert_attachment() a wrapper for wp_insert_post(), negating the need for this new filter.

#10 in reply to: ↑ 8 @helen
12 years ago

Replying to wonderboymusic:

are you daring me to combine the two functions? IN-VES-TI-GATING.

I'm actually daring you to go all-in on #21963 :)

#11 follow-up: @wonderboymusic
12 years ago

oh wait, that already did all of this over there, will look at refreshing that

#12 in reply to: ↑ 11 @nacin
12 years ago

Replying to wonderboymusic:

oh wait, that already did all of this over there, will look at refreshing that

Yes, let's keep it on #21963. The two functions have their quirks, you basically need to go line-by-line on them.

#13 @wonderboymusic
12 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

We are attacking the merging of code over here: #21963.

Note: See TracTickets for help on using tickets.