Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#17895 closed enhancement (fixed)

delete_post_thumbnail()

Reported by: nacin's profile nacin Owned by: nacin's profile nacin
Milestone: 3.3 Priority: normal
Severity: normal Version:
Component: Post Thumbnails Keywords: has-patch needs-testing dev-feedback commit
Focuses: Cc:

Description

set_post_thumbnail() should allow deletes too, by passing false or 0 as the new ID. Or we can add delete_post_thumbnail().

The set-post-thumbnail admin-ajax branch will need a rework to support it.

Attachments (4)

17895-function.diff (732 bytes) - added by CoenJacobs 13 years ago.
delete_post_thumbnail() function isn't that hard
17895-set-change.diff (696 bytes) - added by CoenJacobs 13 years ago.
Or changed the set_post_thumbnail() function, passing 0 as the new id to remove.
17895.diff (1.3 KB) - added by duck_ 13 years ago.
17895.2.diff (1.2 KB) - added by duck_ 13 years ago.

Download all attachments as: .zip

Change History (18)

#1 @nacin
13 years ago

  • Type changed from defect (bug) to enhancement

#2 @kawauso
13 years ago

+1 for delete_post_thumbnail(), not sure false or 0 on a set function would be expected behaviour given other functions have a delete counterpart.

#3 @jtsternberg
13 years ago

+1 for delete_post_thumbnail(). what about update_post_thumbnail()?

@CoenJacobs
13 years ago

delete_post_thumbnail() function isn't that hard

#4 follow-up: @CoenJacobs
13 years ago

  • Keywords has-patch needs-testing added

Still need to work through the admin-ajax branch function.

@CoenJacobs
13 years ago

Or changed the set_post_thumbnail() function, passing 0 as the new id to remove.

#5 @nacin
13 years ago

  • Milestone changed from Future Release to 3.3
  • Summary changed from set_post_thumbnail() should allow deletes too to delete_post_thumbnail()

#6 @misternifty
13 years ago

  • Owner set to misternifty
  • Status changed from new to accepted

#7 @SergeyBiryukov
13 years ago

  • Keywords needs-patch removed

#8 @scribu
13 years ago

  • Keywords 3.3-early removed
  • Owner misternifty deleted
  • Status changed from accepted to assigned

I would go with delete_post_thumbnail().

#9 @jane
13 years ago

  • Keywords dev-feedback added

Leads/committers: please weigh in on commit vs. punt based on current patch, given freeze.

@duck_
13 years ago

#10 in reply to: ↑ 4 ; follow-up: @duck_
13 years ago

Replying to CoenJacobs:

Still need to work through the admin-ajax branch function.

17895.diff. Changed it to return the return value of delete_post_meta.

I'm a bit unsure about returning false if there's no post, but returning true if there's a post with no thumbnail. Seems to me that both cases should return the same? Otherwise should be good :)

#11 in reply to: ↑ 10 ; follow-up: @CoenJacobs
13 years ago

Replying to duck_:

17895.diff. Changed it to return the return value of delete_post_meta.

I'm a bit unsure about returning false if there's no post, but returning true if there's a post with no thumbnail. Seems to me that both cases should return the same? Otherwise should be good :)

Sounds good to me.

Returning false when the delete isn't executed because of no set value in the meta is a choice indeed. Doesn't delete_post_meta (and thus delete_metadata() ) return false too, if there are no records to delete?

@duck_
13 years ago

#12 in reply to: ↑ 11 @duck_
13 years ago

  • Keywords commit added

Replying to CoenJacobs:

Doesn't delete_post_meta (and thus delete_metadata() ) return false too, if there are no records to delete?

Correct. 17895.2.diff.

#13 @CoenJacobs
13 years ago

That deletes about half of my function, but yes this seems to be it. :)

#14 @nacin
13 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from assigned to closed

In [18767]:

delete_post_thumbnail(). props CoenJacobs, duck_. fixes #17895.

Note: See TracTickets for help on using tickets.