Post Thumbnails: When using add_theme_support( ‘post-thumbnails’, array( $post_types) ) merge the supported post_types.

Allow the adding of post-thumbnail support for one or more post_types without unsetting any previously added post_types. This matches the behavior of other uses of `add_theme_support()` and the expectations of a function with a prefix of “add”.
To unset post-thumbnail support use `remove_theme_support()` instead.

Fixes #22080

Props alexkingorg, jmichaelward, and flixos90.

git-svn-id: https://develop.svn.wordpress.org/trunk@37308 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Rachel Baker
2016-04-26 17:04:25 +00:00
parent 274902b03a
commit 2ff19ab7d3
2 changed files with 35 additions and 0 deletions

View File

@@ -1535,6 +1535,24 @@ function add_theme_support( $feature ) {
$args = array_slice( func_get_args(), 1 );
switch ( $feature ) {
case 'post-thumbnails':
// All post types are already supported.
if ( true === get_theme_support( 'post-thumbnails' ) ) {
return;
}
/*
* Merge post types with any that already declared their support
* for post thumbnails.
*/
if ( is_array( $args[0] ) && is_array( $_wp_theme_features['post-thumbnails'][0] ) ) {
$post_types = array_unique( array_merge( $args[0], $_wp_theme_features['post-thumbnails'][0] ) );
$args = array( $post_types );
}
break;
case 'post-formats' :
if ( is_array( $args[0] ) ) {
$post_formats = get_post_format_slugs();