From d55f5b35af49552f376b1dc51226fabd5faec73a Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 4 May 2011 18:28:31 +0000 Subject: [PATCH] Denote images that are headers or backgrounds in the media ui. Props ocean90. fixes #17291 git-svn-id: http://svn.automattic.com/wordpress/trunk@17793 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/custom-background.php | 1 + .../includes/class-wp-media-list-table.php | 2 +- wp-admin/includes/template.php | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/wp-admin/custom-background.php b/wp-admin/custom-background.php index 065550411..34fcd019b 100644 --- a/wp-admin/custom-background.php +++ b/wp-admin/custom-background.php @@ -345,6 +345,7 @@ if ( get_background_image() ) { // Add the meta-data wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + update_post_meta( $id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) ); set_theme_mod('background_image', esc_url($url)); diff --git a/wp-admin/includes/class-wp-media-list-table.php b/wp-admin/includes/class-wp-media-list-table.php index baa7afac4..b05f82fcc 100644 --- a/wp-admin/includes/class-wp-media-list-table.php +++ b/wp-admin/includes/class-wp-media-list-table.php @@ -215,7 +215,7 @@ foreach ( $columns as $column_name => $column_display_name ) { case 'title': ?> - >is_trash ) echo $att_title; else { ?> + >is_trash ) echo $att_title; else { ?>

ID ), $matches ) ) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index c37a936b7..bfcc368b9 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1651,6 +1651,36 @@ function _post_states($post) { echo ' - ' . get_post_format_string( get_post_format( $post->ID ) ) . ''; } +function _media_states( $post ) { + $media_states = array(); + $stylesheet = get_option('stylesheet'); + + if ( current_theme_supports( 'custom-header') ) { + $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true ); + if ( ! empty( $meta_header ) && $meta_header == $stylesheet ) + $media_states[] = __( 'Header Image' ); + } + + if ( current_theme_supports( 'custom-background') ) { + $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true ); + if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) + $media_states[] = __( 'Background Image' ); + } + + $media_states = apply_filters( 'display_media_states', $media_states ); + + if ( ! empty( $media_states ) ) { + $state_count = count( $media_states ); + $i = 0; + echo ' - '; + foreach ( $media_states as $state ) { + ++$i; + ( $i == $state_count ) ? $sep = '' : $sep = ', '; + echo "$state$sep"; + } + } +} + /** * Convert a screen string to a screen object *