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

Revision 8682, 5.4 kB (checked in by ryan, 1 week ago)

Merge crazyhorse management pages. see #7552

  • Property svn:eol-style set to native
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">
12     <thead>
13     <tr>
14
15 <?php $posts_columns = wp_manage_media_columns(); ?>
16 <?php foreach($posts_columns as $post_column_key => $column_display_name) {
17     if ( 'cb' === $post_column_key )
18         $class = ' class="check-column"';
19     elseif ( 'comments' === $post_column_key )
20         $class = ' class="num"';
21     else
22         $class = '';
23 ?>
24     <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
25 <?php } ?>
26
27     </tr>
28     </thead>
29     <tbody id="the-list" class="list:post">
30 <?php
31 if ( have_posts() ) {
32 $bgcolor = '';
33 add_filter('the_title','wp_specialchars');
34 while (have_posts()) : the_post();
35 $class = 'alternate' == $class ? '' : 'alternate';
36 global $current_user;
37 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
38 $att_title = get_the_title();
39 if ( empty($att_title) )
40     $att_title = __('(no title)');
41
42 ?>
43     <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
44
45 <?php
46
47 foreach($posts_columns as $column_name=>$column_display_name) {
48
49     switch($column_name) {
50
51     case 'cb':
52         ?>
53         <th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
54         <?php
55         break;
56
57     case 'icon':
58         ?>
59         <td class="media-icon"><?php
60             if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
61 ?>
62
63                 <a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>">
64                     <?php echo $thumb; ?>
65                 </a>
66
67 <?php            }
68         ?></td>
69         <?php
70         // TODO
71         break;
72
73     case 'media':
74         ?>
75         <td><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 />
76         <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
77         <p>
78         <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> |
79         <a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a> |
80         <a href="#" class="delete"><?php _e('Delete'); ?></a>
81         </p>
82         <?php do_action('manage_media_media_column', $post->ID); ?>
83         </td>
84         <?php
85         break;
86
87     case 'tags':
88         ?>
89         <td><?php
90         $tags = get_the_tags();
91         if ( !empty( $tags ) ) {
92             $out = array();
93             foreach ( $tags as $c )
94                 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
95             echo join( ', ', $out );
96         } else {
97             _e('No Tags');
98         }
99         ?></td>
100         <?php
101         break;
102
103     case 'desc':
104         ?>
105         <td><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
106         <?php
107         break;
108
109     case 'date':
110         if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
111             $t_time = $h_time = __('Unpublished');
112         } else {
113             $t_time = get_the_time(__('Y/m/d g:i:s A'));
114             $m_time = $post->post_date;
115             $time = get_post_time( 'G', true );
116             if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
117                 if ( $t_diff < 0 )
118                     $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
119                 else
120                     $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
121             } else {
122                 $h_time = mysql2date(__('Y/m/d'), $m_time);
123             }
124         }
125         ?>
126         <td><?php echo $h_time ?></td>
127         <?php
128         break;
129
130     case 'parent':
131         $title = __('(no title)'); // override below
132         if ( $post->post_parent > 0 ) {
133             if ( get_post($post->post_parent) ) {
134                 $parent_title = get_the_title($post->post_parent);
135                 if ( !empty($parent_title) )
136                     $title = $parent_title;
137             }
138             ?>
139             <td><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>
140             <?php
141         } else {
142             ?>
143             <td>&nbsp;</td>
144             <?php
145         }
146
147         break;
148
149     case 'comments':
150         ?>
151         <td class="num"><div class="post-com-count-wrapper">
152         <?php
153         $left = get_pending_comments_num( $post->ID );
154         $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
155         if ( $left )
156             echo '<strong>';
157         comments_number("<a href='upload.php?attachment_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='upload.php?attachment_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='upload.php?attachment_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
158         if ( $left )
159             echo '</strong>';
160         ?>
161         </div></td>
162         <?php
163         break;
164
165     case 'actions':
166         ?>
167         <td>
168         <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> |
169         <a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a>
170         </td>
171         <?php
172         break;
173
174     default:
175         ?>
176         <td><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
177         <?php
178         break;
179     }
180 }
181 ?>
182     </tr>
183 <?php
184 endwhile;
185 } else {
186 ?>
187   <tr style='background-color: <?php echo $bgcolor; ?>'>
188     <td colspan="8"><?php _e('No posts found.') ?></td>
189   </tr>
190 <?php
191 } // end if ( have_posts() )
192 ?>
193     </tbody>
194 </table>
195
Note: See TracBrowser for help on using the browser.