From d082fbbb4f25a7e45ecf83ccf2b71b6b8d2ec48c Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 12 Oct 2010 19:43:54 +0000 Subject: [PATCH] Allow deleting a format. see #14746 git-svn-id: http://svn.automattic.com/wordpress/trunk@15779 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 350008095..51bebf83d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -510,7 +510,7 @@ function has_post_format( $format, $post = null ) { * Assign a format to a post * * @param int|object $post The post for which to assign a format - * @param string $format A format to assign. + * @param string $format A format to assign. Use an empty string or array to remove all formats from the post. * @return mixed WP_Error on error. Array of affected term IDs on success. */ function set_post_format( $post, $format ) { @@ -519,9 +519,10 @@ function set_post_format( $post, $format ) { if ( empty($post) ) return new WP_Error('invalid_post', __('Invalid post')); - $format = sanitize_key($format); + if ( !empty($format) ) + $format = 'post-format-' . sanitize_key($format); - return wp_set_post_terms($post->ID, array('post-format-' . $format), 'post_format'); + return wp_set_post_terms($post->ID, $format, 'post_format'); } /**