WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#17895 closed enhancement (fixed)

delete_post_thumbnail()

Reported by: nacin Owned by: 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 4 years ago.
delete_post_thumbnail() function isn't that hard
17895-set-change.diff (696 bytes) - added by CoenJacobs 4 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_ 4 years ago.
17895.2.diff (1.2 KB) - added by duck_ 4 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 @nacin4 years ago

  • Type changed from defect (bug) to enhancement

comment:2 @kawauso4 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.

comment:3 @jtsternberg4 years ago

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

@CoenJacobs4 years ago

delete_post_thumbnail() function isn't that hard

comment:4 follow-up: @CoenJacobs4 years ago

  • Keywords has-patch needs-testing added

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

@CoenJacobs4 years ago

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

comment:5 @nacin4 years ago

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

comment:6 @misternifty4 years ago

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

comment:7 @SergeyBiryukov4 years ago

  • Keywords needs-patch removed

comment:8 @scribu4 years ago

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

I would go with delete_post_thumbnail().

comment:9 @jane4 years ago

  • Keywords dev-feedback added

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

@duck_4 years ago

comment:10 in reply to: ↑ 4 ; follow-up: @duck_4 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 :)

comment:11 in reply to: ↑ 10 ; follow-up: @CoenJacobs4 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_4 years ago

comment:12 in reply to: ↑ 11 @duck_4 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.

comment:13 @CoenJacobs4 years ago

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

comment:14 @nacin4 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.