delete_post_thumbnail(). props CoenJacobs, duck_. fixes #17895.
git-svn-id: https://develop.svn.wordpress.org/trunk@18767 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
be87523fed
commit
0f4a1e5e3c
|
@ -1473,8 +1473,10 @@ case 'set-post-thumbnail':
|
|||
check_ajax_referer( "set_post_thumbnail-$post_ID" );
|
||||
|
||||
if ( $thumbnail_id == '-1' ) {
|
||||
delete_post_meta( $post_ID, '_thumbnail_id' );
|
||||
die( _wp_post_thumbnail_html() );
|
||||
if ( delete_post_thumbnail( $post_ID ) )
|
||||
die( _wp_post_thumbnail_html() );
|
||||
else
|
||||
die( '0' );
|
||||
}
|
||||
|
||||
if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
|
||||
|
|
|
@ -5190,6 +5190,21 @@ function set_post_thumbnail( $post, $thumbnail_id ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a post thumbnail.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param int|object $post Post ID or object where thumbnail should be removed from.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
function delete_post_thumbnail( $post ) {
|
||||
$post = get_post( $post );
|
||||
if ( $post )
|
||||
return delete_post_meta( $post->ID, '_thumbnail_id' );
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to a post format index.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue