root/trunk/wp-admin/edit-attachment-rows.php

Revision 1530, 6.3 kB (checked in by donncha, 5 hours ago)

WP Merge with revision 9808

Line 
1 <?php
2 /**
3  * Edit attachments table for inclusion in administration panels.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 if ( ! defined('ABSPATH') ) die();
10 ?>
11 <table class="widefat fixed" cellspacing="0">
12     <thead>
13     <tr>
14 <?php print_column_headers('upload'); ?>
15     </tr>
16     </thead>
17    
18     <tfoot>
19     <tr>
20 <?php print_column_headers('upload', false); ?>
21     </tr>
22     </tfoot>
23    
24     <tbody id="the-list" class="list:post">
25 <?php
26 if ( have_posts() ) {
27 add_filter('the_title','wp_specialchars');
28 while (have_posts()) : the_post();
29 $alt = ( 'alternate' == $alt ) ? '' : 'alternate';
30 global $current_user;
31 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
32 $att_title = _draft_or_post_title();
33
34 ?>
35     <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
36
37 <?php
38 $posts_columns = wp_manage_media_columns();
39 $hidden = (array) get_user_option( 'manage-media-columns-hidden' );
40
41 foreach ($posts_columns as $column_name => $column_display_name ) {
42     $class = "class=\"$column_name column-$column_name\"";
43
44     $style = '';
45     if ( in_array($column_name, $hidden) )
46         $style = ' style="display:none;"';
47
48     $attributes = "$class$style";
49
50     switch($column_name) {
51
52     case 'cb':
53         ?>
54         <th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
55         <?php
56         break;
57
58     case 'icon':
59         $attributes = 'class="column-icon media-icon"' . $style;
60         ?>
61         <td <?php echo $attributes ?>><?php
62             if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
63 ?>
64
65                 <a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>">
66                     <?php echo $thumb; ?>
67                 </a>
68
69 <?php            }
70         ?></td>
71         <?php
72         // TODO
73         break;
74
75     case 'media':
76         ?>
77         <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
78         <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
79         <p>
80         <?php
81         $actions = array();
82         if ( current_user_can('edit_post', $post->ID) )
83             $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
84         if ( current_user_can('delete_post', $post->ID) )
85             $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
86         $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
87         $action_count = count($actions);
88         $i = 0;
89         foreach ( $actions as $action => $link ) {
90             ++$i;
91             ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
92             echo "<span class='$action'>$link$sep</span>";
93         }
94         ?></p></td>
95         <?php
96         break;
97
98     case 'author':
99         ?>
100         <td <?php echo $attributes ?>><?php the_author() ?></td>
101         <?php
102         break;
103
104     case 'tags':
105         ?>
106         <td <?php echo $attributes ?>><?php
107         $tags = get_the_tags();
108         if ( !empty( $tags ) ) {
109             $out = array();
110             foreach ( $tags as $c )
111                 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
112             echo join( ', ', $out );
113         } else {
114             _e('No Tags');
115         }
116         ?></td>
117         <?php
118         break;
119
120     case 'desc':
121         ?>
122         <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
123         <?php
124         break;
125
126     case 'date':
127         if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
128             $t_time = $h_time = __('Unpublished');
129         } else {
130             $t_time = get_the_time(__('Y/m/d g:i:s A'));
131             $m_time = $post->post_date;
132             $time = get_post_time( 'G', true, $post );
133             if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
134                 if ( $t_diff < 0 )
135                     $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
136                 else
137                     $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
138             } else {
139                 $h_time = mysql2date(__('Y/m/d'), $m_time);
140             }
141         }
142         ?>
143         <td <?php echo $attributes ?>><?php echo $h_time ?></td>
144         <?php
145         break;
146
147     case 'parent':
148         if ( $post->post_parent > 0 ) {
149             if ( get_post($post->post_parent) ) {
150                 $title =_draft_or_post_title($post->post_parent);
151             }
152             ?>
153             <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php echo get_the_time(__('Y/m/d')); ?></td>
154             <?php
155         } else {
156             ?>
157             <td <?php echo $attributes ?>>&nbsp;</td>
158             <?php
159         }
160
161         break;
162
163     case 'comments':
164         $attributes = 'class="comments column-comments num"' . $style;
165         ?>
166         <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
167         <?php
168         $left = get_pending_comments_num( $post->ID );
169         $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
170         if ( $left )
171             echo '<strong>';
172         comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
173         if ( $left )
174             echo '</strong>';
175         ?>
176         </div></td>
177         <?php
178         break;
179
180     case 'actions':
181         ?>
182         <td <?php echo $attributes ?>>
183         <a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php _e('Edit'); ?></a> |
184         <a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a>
185         </td>
186         <?php
187         break;
188
189     default:
190         ?>
191         <td <?php echo $attributes ?>><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
192         <?php
193         break;
194     }
195 }
196 ?>
197     </tr>
198 <?php
199 endwhile;
200 } else {
201 ?>
202   <tr>
203     <td colspan="8"><?php _e('No posts found.') ?></td>
204   </tr>
205 <?php
206 } // end if ( have_posts() )
207 ?>
208     </tbody>
209 </table>
210
Note: See TracBrowser for help on using the browser.