From f5a3446e4d9e436de1e7f942e04eee41241dade2 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 19 Oct 2016 23:03:31 +0000 Subject: [PATCH] Customize: Improve the labelling of background and header images in the list mode of the media library. Props deltafactory, coreymcollins, desrosj Fixes #22857 Built from https://develop.svn.wordpress.org/trunk@38831 git-svn-id: http://core.svn.wordpress.org/trunk@38774 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 31 ++++++++++++++++++++++++++++--- wp-includes/version.php | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index d6fcab06ee..cd4c00f045 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1752,14 +1752,39 @@ function _media_states( $post ) { 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 ( is_random_header_image() ) { + $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' ); + + if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images ) ) { + $media_states[] = __( 'Header Image' ); + } + } else { + $header_image = get_header_image(); + + // Display "Header Image" if the image was ever used as a header image + if ( ! empty( $meta_header ) && $meta_header == $stylesheet && $header_image !== wp_get_attachment_url( $post->ID ) ) { + $media_states[] = __( 'Header Image' ); + } + + // Display "Current Header Image" if the image is currently the header image + if ( $header_image && $header_image == wp_get_attachment_url( $post->ID ) ) { + $media_states[] = __( 'Current 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 ) + + if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) { $media_states[] = __( 'Background Image' ); + + $background_image = get_background_image(); + if ( $background_image && $background_image == wp_get_attachment_url( $post->ID ) ) { + $media_states[] = __( 'Current Background Image' ); + } + } } if ( $post->ID == get_option( 'site_icon' ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 1e3fcae9a8..fbb04271b7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38830'; +$wp_version = '4.7-alpha-38831'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.