From 759b3f5e8292424e4cf53005cbeb344ab72cff65 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 25 Apr 2013 03:06:31 +0000 Subject: [PATCH] Fix redundant use of array_keys() around get_post_format_slugs(). props SergeyBirkukov, wonderboymusic. fixes #24089. git-svn-id: http://core.svn.wordpress.org/trunk@24082 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-formats.php | 14 +++++++------- wp-includes/theme.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wp-includes/post-formats.php b/wp-includes/post-formats.php index 4a20d07397..d7ddaa9064 100644 --- a/wp-includes/post-formats.php +++ b/wp-includes/post-formats.php @@ -56,20 +56,20 @@ function has_post_format( $format, $post = null ) { * @return mixed WP_Error on error. Array of affected term IDs on success. */ function set_post_format( $post, $format ) { - $post = get_post($post); + $post = get_post( $post ); - if ( empty($post) ) - return new WP_Error('invalid_post', __('Invalid post')); + if ( empty( $post ) ) + return new WP_Error( 'invalid_post', __( 'Invalid post' ) ); - if ( !empty($format) ) { - $format = sanitize_key($format); - if ( 'standard' == $format || !in_array( $format, array_keys( get_post_format_slugs() ) ) ) + if ( ! empty( $format ) ) { + $format = sanitize_key( $format ); + if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs() ) ) $format = ''; else $format = 'post-format-' . $format; } - return wp_set_post_terms($post->ID, $format, 'post_format'); + return wp_set_post_terms( $post->ID, $format, 'post_format' ); } /** diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 2150b46ecd..36f01b3f36 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1261,7 +1261,7 @@ function add_theme_support( $feature ) { switch ( $feature ) { case 'structured-post-formats' : if ( is_array( $args[0] ) ) - $args[0] = array_intersect( $args[0], array_keys( get_post_format_slugs() ) ); + $args[0] = array_intersect( $args[0], get_post_format_slugs() ); // structured-post-formats support automatically adds support for post-formats. $_wp_theme_features['post-formats'] = $args; case 'post-formats' : @@ -1269,7 +1269,7 @@ function add_theme_support( $feature ) { if ( current_theme_supports( 'structured-post-formats' ) ) $args = get_theme_support( 'structured-post-formats' ); elseif ( is_array( $args[0] ) ) - $args[0] = array_intersect( $args[0], array_keys( get_post_format_slugs() ) ); + $args[0] = array_intersect( $args[0], get_post_format_slugs() ); break; case 'custom-header-uploads' :