Allow deleting a format. see #14746
git-svn-id: https://develop.svn.wordpress.org/trunk@15779 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0ccec0d6f1
commit
40dade4c0e
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user