WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/09/2009 03:39:20 PM (11 years ago)
Author:
ryan
Message:

Allow registering post image support per post type. fixes #11364

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r12345 r12350  
    13211321function add_theme_support( $feature ) {
    13221322    global $_wp_theme_features;
     1323
    13231324    if ( 'post-thumbnails' == $feature ) // This was changed during 2.9 beta. I'll be nice and not break things.
    13241325        $feature = 'post-images';
    1325     $_wp_theme_features[$feature] = true;
     1326
     1327    if ( func_num_args() == 1 )
     1328        $_wp_theme_features[$feature] = true;
     1329    else
     1330        $_wp_theme_features[$feature] = array_slice( func_get_args(), 1 );
    13261331}
    13271332
     
    13371342function current_theme_supports( $feature ) {
    13381343    global $_wp_theme_features;
    1339     return ( isset( $_wp_theme_features[$feature] ) && $_wp_theme_features[$feature] );
     1344
     1345    if ( !isset( $_wp_theme_features[$feature] ) )
     1346        return false;
     1347
     1348    // If no args passed then no extra checks need be performed
     1349    if ( func_num_args() <= 1 )
     1350        return true;
     1351
     1352    $args = array_slice( func_get_args(), 1 );
     1353
     1354    // @todo Allow pluggable arg checking
     1355    switch ( $feature ) {
     1356        case 'post-images':
     1357            // post-thumbnails can be registered for only certain content/post types by passing
     1358            // an array of types to add_theme_support().  If no array was passed, then
     1359            // any type is accepted
     1360            if ( true === $_wp_theme_features[$feature] )  // Registered for all types
     1361                return true;
     1362            $content_type = $args[0];
     1363            if ( in_array($content_type, $_wp_theme_features[$feature][0]) )
     1364                return true;
     1365            else
     1366                return false;
     1367            break;
     1368    }
     1369
     1370    return true;
    13401371}
    13411372
Note: See TracChangeset for help on using the changeset viewer.