WordPress.org

Make WordPress Core

Ticket #11364: 11364.diff

File 11364.diff, 3.7 KB (added by ryan, 8 years ago)

Untested

  • wp-includes/theme.php

     
    13201320 */
    13211321function add_theme_support( $feature ) {
    13221322        global $_wp_theme_features;
    1323         $_wp_theme_features[$feature] = true;
     1323
     1324        if ( func_num_args() == 1 )
     1325                $_wp_theme_features[$feature] = true;
     1326        else
     1327                $_wp_theme_features[$feature] = array_slice( func_get_args(), 1 );
    13241328}
    13251329
    13261330/**
     
    13341338
    13351339function current_theme_supports( $feature ) {
    13361340        global $_wp_theme_features;
    1337         return ( isset( $_wp_theme_features[$feature] ) && $_wp_theme_features[$feature] );
     1341
     1342        if ( !isset( $_wp_theme_features[$feature] ) )
     1343                return false;
     1344
     1345        // If no args passed then no extra checks need be performed
     1346        if ( func_num_args() <= 1 )
     1347                return true;
     1348
     1349        $args = array_slice( func_get_args(), 1 );
     1350
     1351        // @todo Allow pluggable arg checking
     1352        switch ( $feature ) {
     1353                case 'post-thumbnails':
     1354                        // post-thumbnails can be registered for only certain content/post types by passing
     1355                        // an array of types to add_theme_support().  If no array was passed, then
     1356                        // any type is accepted
     1357                        if ( true === $_wp_theme_features[$feature] )  // Registered for all types
     1358                                return true;
     1359                        $content_type = $args[0];
     1360                        if ( in_array($content_type, $_wp_theme_features[$feature][0]) )
     1361                                return true;
     1362                        else
     1363                                return false;
     1364                        break;
     1365        }
     1366
     1367        return true;
    13381368}
    13391369
    13401370/**
  • wp-admin/includes/media.php

     
    12391239        }
    12401240
    12411241        $thumbnail = '';
    1242         if ( 'image' == $type && current_theme_supports( 'post-thumbnails' ) && get_post_image_id($_GET['post_id']) != $attachment_id )
     1242        if ( 'image' == $type && current_theme_supports( 'post-thumbnails', 'attachment:image' ) && 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 thumbnail" ) . "</a>";
    12441244
    12451245        if ( ( $send || $thumbnail || $delete ) && !isset($form_fields['buttons']) )
  • wp-admin/edit-page-form.php

     
    8080add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'page', 'normal', 'core');
    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-thumbnails' ) )
     83if ( current_theme_supports( 'post-thumbnails', 'page' ) )
    8484        add_meta_box('postthumbnaildiv', __('Page Thumbnail'), 'post_thumbnail_meta_box', 'page', 'side', 'low');
    8585
    8686$authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
  • wp-admin/edit-form-advanced.php

     
    9898}
    9999
    100100add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
    101 if ( current_theme_supports( 'post-thumbnails' ) )
     101if ( current_theme_supports( 'post-thumbnails', 'post' ) )
    102102        add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low');
    103103add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
    104104add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');