Ticket #17419: 17419.formatted.1.diff

File 17419.formatted.1.diff, 3.1 KB (added by kurtpayne, 20 months ago)
Line 
1Index: wp-admin/includes/class-wp-media-list-table.php
2===================================================================
3--- wp-admin/includes/class-wp-media-list-table.php     (revision 18725)
4+++ wp-admin/includes/class-wp-media-list-table.php     (working copy)
5@@ -163,6 +163,7 @@
6                $alt = '';
7 
8                while ( have_posts() ) : the_post();
9+                       $user_can_edit = current_user_can( 'edit_post', $post->ID );
10 
11                        if ( $this->is_trash && $post->post_status != 'trash'
12                        ||  !$this->is_trash && $post->post_status == 'trash' )
13@@ -189,7 +190,11 @@
14 
15        case 'cb':
16 ?>
17-               <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>
18+               <th scope="row" class="check-column">
19+                       <?php if ( $user_can_edit ) { ?>
20+                               <input type="checkbox" name="media[]" value="<?php the_ID(); ?>" />
21+                       <?php } ?>
22+               </th>
23 <?php
24                break;
25 
26@@ -198,7 +203,7 @@
27 ?>
28                <td <?php echo $attributes ?>><?php
29                        if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
30-                               if ( $this->is_trash ) {
31+                               if ( $this->is_trash || ! $user_can_edit ) {
32                                        echo $thumb;
33                                } else {
34 ?>
35@@ -215,7 +220,15 @@
36 
37        case 'title':
38 ?>
39-               <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>
40+               <td <?php echo $attributes ?>><strong>
41+                       <?php if ( $this->is_trash || ! $user_can_edit ) {
42+                               echo $att_title;
43+                       } else { ?>
44+                       <a href="<?php echo get_edit_post_link( $post->ID, true ); ?>"
45+                               title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
46+                               <?php echo $att_title; ?></a>
47+                       <?php };
48+                       _media_states( $post ); ?></strong>
49                        <p>
50 <?php
51                        if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
52@@ -287,15 +300,25 @@
53                                $title =_draft_or_post_title( $post->post_parent );
54                        }
55 ?>
56-                       <td <?php echo $attributes ?>>
57-                               <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>,
58+                       <td <?php echo $attributes ?>><strong>
59+                               <?php if( current_user_can( 'edit_post', $post->post_parent ) ) { ?>
60+                                       <a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
61+                                               <?php echo $title ?></a>
62+                               <?php } else {
63+                                       echo $title;
64+                               } ?></strong>,
65                                <?php echo get_the_time( __( 'Y/m/d' ) ); ?>
66                        </td>
67 <?php
68                } else {
69 ?>
70                        <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
71-                       <a class="hide-if-no-js" onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' );return false;" href="#the-list"><?php _e( 'Attach' ); ?></a></td>
72+                       <?php if( $user_can_edit ) {?>
73+                               <a class="hide-if-no-js"
74+                                       onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
75+                                       href="#the-list">
76+                                       <?php _e( 'Attach' ); ?></a>
77+                       <?php } ?></td>
78 <?php
79                }
80                break;