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

git-svn-id: http://svn.automattic.com/wordpress/trunk@18767 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2011-09-24 19:31:38 +00:00
parent eb8878fbfc
commit 9f216ad715
2 changed files with 19 additions and 2 deletions

View File

@ -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' );
if ( delete_post_thumbnail( $post_ID ) )
die( _wp_post_thumbnail_html() );
else
die( '0' );
}
if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )

View File

@ -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.
*