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:
parent
eb8878fbfc
commit
9f216ad715
|
@ -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