| 1353 | case 'post-thumbnails': |
| 1354 | // merge in support for new post types |
| 1355 | $support = get_theme_support( 'post-thumbnails' ); |
| 1356 | if ( is_array( $support ) && is_array( $support[0] ) ) { |
| 1357 | // currently enabled for specific post types, merge |
| 1358 | if ( is_string( $args[0] ) ) { |
| 1359 | $args[0] = array( $args[0] ); |
| 1360 | } |
| 1361 | $args[0] = array_unique( array_merge( $support[0], $args[0] ) ); |
| 1362 | } |
| 1363 | else if ( $support ) { |
| 1364 | // currently enabled for all post types, keep as is |
| 1365 | $args = true; |
| 1366 | } |
| 1367 | break; |
| 1494 | |
| 1495 | case 'post-thumbnails': |
| 1496 | if ( func_num_args() == 2 ) { |
| 1497 | $support = get_theme_support( 'custom-background' ); |
| 1498 | $post_types = array_slice( func_get_args(), 1 ); |
| 1499 | switch ( $support ) { |
| 1500 | case true: |
| 1501 | // thumbnails globally enabled, cannot disable for post type |
| 1502 | return new WP_Error( 'remove_theme_support_error', __( 'post-thumbnails are enabled for all post types (try using remove_post_type_support( "my-post-type", "thumbnails" ); instead).' ) ); |
| 1503 | break; |
| 1504 | case false: |
| 1505 | // thumbnails globally disabled |
| 1506 | return new WP_Error( 'remove_theme_support_warn', __( 'post-thumbnails are disabled for all post types' ) ); |
| 1507 | break; |
| 1508 | default: |
| 1509 | // thumbnails enabled for specific post types |
| 1510 | if ( is_array( $support ) && is_array( $support[0] ) && is_array( $post_types ) ) { |
| 1511 | $_post_types = $found = array(); |
| 1512 | foreach ( $support[0] as $_post_type ) { |
| 1513 | if ( in_array( $_post_type, $post_types ) ) |
| 1514 | $found[] = $_post_type; |
| 1515 | else |
| 1516 | $_post_types[] = $_post_type; |
| 1517 | } |
| 1518 | if ( count( $post_types ) != count( $found ) ) { |
| 1519 | // some post types weren't found |
| 1520 | $diff = array_diff( $post_types, $found ); |
| 1521 | return new WP_Error( 'remove_theme_support_warn', __( 'post-thumbnails were already disabled for reuested post type(s)' ) , array( 'post-thumbnails' => $post_types, 'already-disabled' => $diff ) ); |
| 1522 | } |
| 1523 | else { |
| 1524 | $_wp_theme_features[ 'post-thumbnails' ] = $_post_types; |
| 1525 | // have to get out early to avoid unsetting the feature entirely |
| 1526 | return true; |
| 1527 | } |
| 1528 | } |
| 1529 | } |
| 1530 | } |
| 1531 | break; |