WordPress.org

Make WordPress Core

Changeset 12132


Ignore:
Timestamp:
11/01/09 05:27:39 (4 years ago)
Author:
markjaquith
Message:

Introducing add_theme_support(feature) and current_theme_supports(feature) for announcing and checking theme support for various features. Implement it for post/page thumbanils, hiding UI if not supported.

Location:
trunk
Files:
3 edited

Legend:

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

    r12029 r12132  
    9999 
    100100add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core'); 
    101 add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low'); 
     101if ( current_theme_supports( 'post-thumbnails' ) ) 
     102    add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low'); 
    102103add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core'); 
    103104add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core'); 
  • trunk/wp-admin/edit-page-form.php

    r12056 r12132  
    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 add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'page', 'side', 'low'); 
     83if ( current_theme_supports( 'post-thumbnails' ) ) 
     84    add_meta_box('postthumbnaildiv', __('Page Thumbnail'), 'post_thumbnail_meta_box', 'page', 'side', 'low'); 
    8485 
    8586$authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM 
  • trunk/wp-includes/theme.php

    r12129 r12132  
    13041304} 
    13051305 
     1306/** 
     1307 * Allows a theme to register its support of a certain feature 
     1308 * 
     1309 * @author Mark Jaquith 
     1310 * @since 2.9 
     1311 * @param string $feature the feature being added 
     1312 */ 
     1313function add_theme_support( $feature ) { 
     1314    global $_wp_theme_features; 
     1315    $_wp_theme_features[$feature] = true; 
     1316} 
     1317 
     1318/** 
     1319 * Checks a theme's support for a given feature 
     1320 * 
     1321 * @author Mark Jaquith 
     1322 * @since 2.9 
     1323 * @param string $feature the feature being checked 
     1324 * @return boolean 
     1325 */ 
     1326 
     1327function current_theme_supports( $feature ) { 
     1328    global $_wp_theme_features; 
     1329    return ( isset( $_wp_theme_features[$feature] ) && $_wp_theme_features[$feature] ); 
     1330} 
     1331 
    13061332?> 
Note: See TracChangeset for help on using the changeset viewer.