Make WordPress Core

Changeset 12350


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

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

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r12343 r12350  
    9999
    100100add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
    101 if ( current_theme_supports( 'post-images' ) )
     101if ( current_theme_supports( 'post-images', 'post' ) )
    102102    add_meta_box('postimagediv', __('Post Image'), 'post_image_meta_box', 'post', 'side', 'low');
    103103add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
  • trunk/wp-admin/edit-page-form.php

    r12343 r12350  
    8181add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'page', 'normal', 'core');
    8282add_meta_box('slugdiv', __('Page Slug'), 'post_slug_meta_box', 'page', 'normal', 'core');
    83 if ( current_theme_supports( 'post-images' ) )
     83if ( current_theme_supports( 'post-images', 'page' ) )
    8484    add_meta_box('postimagediv', __('Page Image'), 'post_image_meta_box', 'page', 'side', 'low');
    8585
  • trunk/wp-admin/includes/media.php

    r12344 r12350  
    12401240
    12411241    $thumbnail = '';
    1242     if ( 'image' == $type && current_theme_supports( 'post-images' ) && get_post_image_id($_GET['post_id']) != $attachment_id )
     1242    if ( 'image' == $type && isset($_GET['post_id']) && current_theme_supports( 'post-images', get_post_type($_GET['post_id']) ) && get_post_image_id($_GET['post_id']) != $attachment_id )
    12431243        $thumbnail = "<a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as post image" ) . "</a>";
    12441244
  • 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.