Check caps when showing media edit and attach links. Clean up formatting. Props kurtpayne, DH-Shredder, solarissmoke. fixes #17419

git-svn-id: https://develop.svn.wordpress.org/trunk@19252 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2011-11-11 15:04:54 +00:00
parent d154749f87
commit 56c8b5dad5
1 changed files with 29 additions and 6 deletions

View File

@ -164,6 +164,7 @@ class WP_Media_List_Table extends WP_List_Table {
$alt = ''; $alt = '';
while ( have_posts() ) : the_post(); while ( have_posts() ) : the_post();
$user_can_edit = current_user_can( 'edit_post', $post->ID );
if ( $this->is_trash && $post->post_status != 'trash' if ( $this->is_trash && $post->post_status != 'trash'
|| !$this->is_trash && $post->post_status == 'trash' ) || !$this->is_trash && $post->post_status == 'trash' )
@ -190,7 +191,11 @@ foreach ( $columns as $column_name => $column_display_name ) {
case 'cb': case 'cb':
?> ?>
<th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /><?php } ?></th> <th scope="row" class="check-column">
<?php if ( $user_can_edit ) { ?>
<input type="checkbox" name="media[]" value="<?php the_ID(); ?>" />
<?php } ?>
</th>
<?php <?php
break; break;
@ -199,7 +204,7 @@ foreach ( $columns as $column_name => $column_display_name ) {
?> ?>
<td <?php echo $attributes ?>><?php <td <?php echo $attributes ?>><?php
if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) { if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
if ( $this->is_trash ) { if ( $this->is_trash || ! $user_can_edit ) {
echo $thumb; echo $thumb;
} else { } else {
?> ?>
@ -216,7 +221,15 @@ foreach ( $columns as $column_name => $column_display_name ) {
case 'title': case 'title':
?> ?>
<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> <td <?php echo $attributes ?>><strong>
<?php if ( $this->is_trash || ! $user_can_edit ) {
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>
<p> <p>
<?php <?php
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
@ -288,15 +301,25 @@ foreach ( $columns as $column_name => $column_display_name ) {
$title =_draft_or_post_title( $post->post_parent ); $title =_draft_or_post_title( $post->post_parent );
} }
?> ?>
<td <?php echo $attributes ?>> <td <?php echo $attributes ?>><strong>
<strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php if( current_user_can( 'edit_post', $post->post_parent ) ) { ?>
<a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
<?php echo $title ?></a>
<?php } else {
echo $title;
} ?></strong>,
<?php echo get_the_time( __( 'Y/m/d' ) ); ?> <?php echo get_the_time( __( 'Y/m/d' ) ); ?>
</td> </td>
<?php <?php
} else { } else {
?> ?>
<td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br /> <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
<a class="hide-if-no-js" onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' );return false;" href="#the-list"><?php _e( 'Attach' ); ?></a></td> <?php if( $user_can_edit ) {?>
<a class="hide-if-no-js"
onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
href="#the-list">
<?php _e( 'Attach' ); ?></a>
<?php } ?></td>
<?php <?php
} }
break; break;