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