diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 5aa1bc689..99fb4010d 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -98,7 +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-images' ) ) +if ( current_theme_supports( 'post-images', 'post' ) ) add_meta_box('postimagediv', __('Post Image'), 'post_image_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'); diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index e7d66d2f4..7bea6a7e1 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -80,7 +80,7 @@ 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'); -if ( current_theme_supports( 'post-images' ) ) +if ( current_theme_supports( 'post-images', 'page' ) ) add_meta_box('postimagediv', __('Page Image'), 'post_image_meta_box', 'page', 'side', 'low'); $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index b7a95fb85..8577f93e4 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -1239,7 +1239,7 @@ function get_media_item( $attachment_id, $args = null ) { } $thumbnail = ''; - if ( 'image' == $type && current_theme_supports( 'post-images' ) && get_post_image_id($_GET['post_id']) != $attachment_id ) + 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 ) $thumbnail = "" . esc_html__( "Use as post image" ) . ""; if ( ( $send || $thumbnail || $delete ) && !isset($form_fields['buttons']) ) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 7bbfb9b1e..463047bcc 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1320,9 +1320,14 @@ function add_custom_image_header($header_callback, $admin_header_callback) { */ function add_theme_support( $feature ) { global $_wp_theme_features; + if ( 'post-thumbnails' == $feature ) // This was changed during 2.9 beta. I'll be nice and not break things. $feature = 'post-images'; - $_wp_theme_features[$feature] = true; + + if ( func_num_args() == 1 ) + $_wp_theme_features[$feature] = true; + else + $_wp_theme_features[$feature] = array_slice( func_get_args(), 1 ); } /** @@ -1336,7 +1341,33 @@ function add_theme_support( $feature ) { function current_theme_supports( $feature ) { global $_wp_theme_features; - return ( isset( $_wp_theme_features[$feature] ) && $_wp_theme_features[$feature] ); + + if ( !isset( $_wp_theme_features[$feature] ) ) + return false; + + // If no args passed then no extra checks need be performed + if ( func_num_args() <= 1 ) + return true; + + $args = array_slice( func_get_args(), 1 ); + + // @todo Allow pluggable arg checking + switch ( $feature ) { + case 'post-images': + // post-thumbnails can be registered for only certain content/post types by passing + // an array of types to add_theme_support(). If no array was passed, then + // any type is accepted + if ( true === $_wp_theme_features[$feature] ) // Registered for all types + return true; + $content_type = $args[0]; + if ( in_array($content_type, $_wp_theme_features[$feature][0]) ) + return true; + else + return false; + break; + } + + return true; } /**