Make WordPress Core

Ticket #21912: 21912.001.patch

File 21912.001.patch, 3.2 KB (added by DJPaul, 13 years ago)
  • wp-includes/theme.php

     
    14851485/**
    14861486 * Checks a theme's support for a given feature
    14871487 *
     1488 * @global array $_wp_theme_features
    14881489 * @since 2.9.0
    14891490 * @param string $feature the feature being checked
    14901491 * @return boolean
     
    14951496        if ( 'custom-header-uploads' == $feature )
    14961497                return current_theme_supports( 'custom-header', 'uploads' );
    14971498
    1498         if ( !isset( $_wp_theme_features[$feature] ) )
    1499                 return false;
     1499        $args   = func_get_args();
     1500        $retval = true;
    15001501
    1501         // If no args passed then no extra checks need be performed
    1502         if ( func_num_args() <= 1 )
    1503                 return true;
     1502        if ( ! isset( $_wp_theme_features[$feature] ) )
     1503                $retval = false;
    15041504
    1505         $args = array_slice( func_get_args(), 1 );
     1505        // If args passed, extra checks need to be performed
     1506        if ( $retval && func_num_args() > 1 ) {
     1507                $args = array_slice( $args, 1 );
    15061508
    1507         switch ( $feature ) {
    1508                 case 'post-thumbnails':
    1509                         // post-thumbnails can be registered for only certain content/post types by passing
    1510                         // an array of types to add_theme_support(). If no array was passed, then
    1511                         // any type is accepted
    1512                         if ( true === $_wp_theme_features[$feature] )  // Registered for all types
    1513                                 return true;
    1514                         $content_type = $args[0];
    1515                         return in_array( $content_type, $_wp_theme_features[$feature][0] );
    1516                         break;
     1509                switch ( $feature ) {
     1510                        case 'post-thumbnails':
     1511                                // post-thumbnails can be registered for only certain content/post types by passing
     1512                                // an array of types to add_theme_support(). If no array was passed, then
     1513                                // any type is accepted
     1514                                if ( true === $_wp_theme_features[$feature] ) {
     1515                                        // Registered for all types
     1516                                        $retval = true;
     1517                                        break;
     1518                                }
    15171519
    1518                 case 'post-formats':
    1519                         // specific post formats can be registered by passing an array of types to
    1520                         // add_theme_support()
    1521                         $post_format = $args[0];
    1522                         return in_array( $post_format, $_wp_theme_features[$feature][0] );
    1523                         break;
     1520                                $retval = in_array( $args[0], $_wp_theme_features[$feature][0] );
     1521                                break;
    15241522
    1525                 case 'custom-header':
    1526                 case 'custom-background' :
    1527                         // specific custom header and background capabilities can be registered by passing
    1528                         // an array to add_theme_support()
    1529                         $header_support = $args[0];
    1530                         return ( isset( $_wp_theme_features[$feature][0][$header_support] ) && $_wp_theme_features[$feature][0][$header_support] );
    1531                         break;
     1523                        case 'post-formats':
     1524                                // specific post formats can be registered by passing an array of types to
     1525                                // add_theme_support()
     1526                                $retval = in_array( $args[0], $_wp_theme_features[$feature][0] );
     1527                                break;
     1528
     1529                        case 'custom-header':
     1530                        case 'custom-background' :
     1531                                // specific custom header and background capabilities can be registered by passing
     1532                                // an array to add_theme_support()
     1533                                $retval = ! empty( $_wp_theme_features[$feature][0][$args[0]] );
     1534                                break;
     1535                }
    15321536        }
    15331537
    1534         return apply_filters('current_theme_supports-' . $feature, true, $args, $_wp_theme_features[$feature]);
     1538        return apply_filters( "current_theme_supports-{$feature}", $retval, $args, $_wp_theme_features[$feature] );
    15351539}
    15361540
    15371541/**