Make WordPress Core

Changeset 17793


Ignore:
Timestamp:
05/04/2011 06:28:31 PM (14 years ago)
Author:
ryan
Message:

Denote images that are headers or backgrounds in the media ui. Props ocean90. fixes #17291

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/custom-background.php

    r17771 r17793  
    346346        // Add the meta-data
    347347        wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
     348        update_post_meta( $id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) );
    348349
    349350        set_theme_mod('background_image', esc_url($url));
  • trunk/wp-admin/includes/class-wp-media-list-table.php

    r17771 r17793  
    216216    case 'title':
    217217?>
    218         <td <?php echo $attributes ?>><strong><?php if ( $this->is_trash ) echo $att_title; else { ?><a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>"><?php echo $att_title; ?></a><?php } ?></strong>
     218        <td <?php echo $attributes ?>><strong><?php if ( $this->is_trash ) echo $att_title; else { ?><a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>"><?php echo $att_title; ?></a><?php }; _media_states( $post ); ?></strong>
    219219            <p>
    220220<?php
  • trunk/wp-admin/includes/template.php

    r17656 r17793  
    16521652}
    16531653
     1654function _media_states( $post ) {
     1655    $media_states = array();
     1656    $stylesheet = get_option('stylesheet');
     1657
     1658    if ( current_theme_supports( 'custom-header') ) {
     1659        $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
     1660        if ( ! empty( $meta_header ) && $meta_header == $stylesheet )
     1661            $media_states[] = __( 'Header Image' );
     1662    }
     1663
     1664    if ( current_theme_supports( 'custom-background') ) {
     1665        $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
     1666        if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
     1667            $media_states[] = __( 'Background Image' );
     1668    }
     1669
     1670    $media_states = apply_filters( 'display_media_states', $media_states );
     1671
     1672    if ( ! empty( $media_states ) ) {
     1673        $state_count = count( $media_states );
     1674        $i = 0;
     1675        echo ' - ';
     1676        foreach ( $media_states as $state ) {
     1677            ++$i;
     1678            ( $i == $state_count ) ? $sep = '' : $sep = ', ';
     1679            echo "<span class='post-state'>$state$sep</span>";
     1680        }
     1681    }
     1682}
     1683
    16541684/**
    16551685 * Convert a screen string to a screen object
Note: See TracChangeset for help on using the changeset viewer.