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.
git-svn-id: http://svn.automattic.com/wordpress/trunk@12132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
475b2737ba
commit
a8c96db902
|
@ -98,6 +98,7 @@ foreach ( get_object_taxonomies('post') as $tax_name ) {
|
|||
}
|
||||
|
||||
add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
|
||||
if ( current_theme_supports( 'post-thumbnails' ) )
|
||||
add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low');
|
||||
add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
|
||||
add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');
|
||||
|
|
|
@ -80,7 +80,8 @@ add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', 'pag
|
|||
add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'page', 'normal', 'core');
|
||||
add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'page', 'normal', 'core');
|
||||
add_meta_box('slugdiv', __('Page Slug'), 'post_slug_meta_box', 'page', 'normal', 'core');
|
||||
add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'page', 'side', 'low');
|
||||
if ( current_theme_supports( 'post-thumbnails' ) )
|
||||
add_meta_box('postthumbnaildiv', __('Page Thumbnail'), 'post_thumbnail_meta_box', 'page', 'side', 'low');
|
||||
|
||||
$authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
|
||||
if ( $post->post_author && !in_array($post->post_author, $authors) )
|
||||
|
|
|
@ -1303,4 +1303,30 @@ function add_custom_image_header($header_callback, $admin_header_callback) {
|
|||
add_action('admin_menu', array(&$GLOBALS['custom_image_header'], 'init'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows a theme to register its support of a certain feature
|
||||
*
|
||||
* @author Mark Jaquith
|
||||
* @since 2.9
|
||||
* @param string $feature the feature being added
|
||||
*/
|
||||
function add_theme_support( $feature ) {
|
||||
global $_wp_theme_features;
|
||||
$_wp_theme_features[$feature] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a theme's support for a given feature
|
||||
*
|
||||
* @author Mark Jaquith
|
||||
* @since 2.9
|
||||
* @param string $feature the feature being checked
|
||||
* @return boolean
|
||||
*/
|
||||
|
||||
function current_theme_supports( $feature ) {
|
||||
global $_wp_theme_features;
|
||||
return ( isset( $_wp_theme_features[$feature] ) && $_wp_theme_features[$feature] );
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue