Projects : mp-wp : mp-wp_genesis
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 | if ( have_posts() ) { ?> |
12 | <table class="widefat fixed" cellspacing="0"> |
13 | <thead> |
14 | <tr> |
15 | <?php print_column_headers('upload'); ?> |
16 | </tr> |
17 | </thead> |
18 | |
19 | <tfoot> |
20 | <tr> |
21 | <?php print_column_headers('upload', false); ?> |
22 | </tr> |
23 | </tfoot> |
24 | |
25 | <tbody id="the-list" class="list:post"> |
26 | <?php |
27 | add_filter('the_title','wp_specialchars'); |
28 | $alt = ''; |
29 | $posts_columns = get_column_headers('upload'); |
30 | $hidden = get_hidden_columns('upload'); |
31 | while (have_posts()) : the_post(); |
32 | $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; |
33 | global $current_user; |
34 | $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); |
35 | $att_title = _draft_or_post_title(); |
36 | |
37 | ?> |
38 | <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top"> |
39 | |
40 | <?php |
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&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&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 | echo '<div class="row-actions">'; |
90 | foreach ( $actions as $action => $link ) { |
91 | ++$i; |
92 | ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
93 | echo "<span class='$action'>$link$sep</span>"; |
94 | } |
95 | echo '</div>'; |
96 | ?></p></td> |
97 | <?php |
98 | break; |
99 | |
100 | case 'author': |
101 | ?> |
102 | <td <?php echo $attributes ?>><?php the_author() ?></td> |
103 | <?php |
104 | break; |
105 | |
106 | case 'tags': |
107 | ?> |
108 | <td <?php echo $attributes ?>><?php |
109 | $tags = get_the_tags(); |
110 | if ( !empty( $tags ) ) { |
111 | $out = array(); |
112 | foreach ( $tags as $c ) |
113 | $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; |
114 | echo join( ', ', $out ); |
115 | } else { |
116 | _e('No Tags'); |
117 | } |
118 | ?></td> |
119 | <?php |
120 | break; |
121 | |
122 | case 'desc': |
123 | ?> |
124 | <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td> |
125 | <?php |
126 | break; |
127 | |
128 | case 'date': |
129 | if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { |
130 | $t_time = $h_time = __('Unpublished'); |
131 | } else { |
132 | $t_time = get_the_time(__('Y/m/d g:i:s A')); |
133 | $m_time = $post->post_date; |
134 | $time = get_post_time( 'G', true, $post ); |
135 | if ( ( abs($t_diff = time() - $time) ) < 86400 ) { |
136 | if ( $t_diff < 0 ) |
137 | $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); |
138 | else |
139 | $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); |
140 | } else { |
141 | $h_time = mysql2date(__('Y/m/d'), $m_time); |
142 | } |
143 | } |
144 | ?> |
145 | <td <?php echo $attributes ?>><?php echo $h_time ?></td> |
146 | <?php |
147 | break; |
148 | |
149 | case 'parent': |
150 | if ( $post->post_parent > 0 ) { |
151 | if ( get_post($post->post_parent) ) { |
152 | $title =_draft_or_post_title($post->post_parent); |
153 | } |
154 | ?> |
155 | <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> |
156 | <?php |
157 | } else { |
158 | ?> |
159 | <td <?php echo $attributes ?>> </td> |
160 | <?php |
161 | } |
162 | |
163 | break; |
164 | |
165 | case 'comments': |
166 | $attributes = 'class="comments column-comments num"' . $style; |
167 | ?> |
168 | <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> |
169 | <?php |
170 | $left = get_pending_comments_num( $post->ID ); |
171 | $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); |
172 | if ( $left ) |
173 | echo '<strong>'; |
174 | 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>'); |
175 | if ( $left ) |
176 | echo '</strong>'; |
177 | ?> |
178 | </div></td> |
179 | <?php |
180 | break; |
181 | |
182 | case 'actions': |
183 | ?> |
184 | <td <?php echo $attributes ?>> |
185 | <a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php _e('Edit'); ?></a> | |
186 | <a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a> |
187 | </td> |
188 | <?php |
189 | break; |
190 | |
191 | default: |
192 | ?> |
193 | <td <?php echo $attributes ?>><?php do_action('manage_media_custom_column', $column_name, $id); ?></td> |
194 | <?php |
195 | break; |
196 | } |
197 | } |
198 | ?> |
199 | </tr> |
200 | <?php endwhile; ?> |
201 | </tbody> |
202 | </table> |
203 | <?php } else { ?> |
204 | |
205 | <p><?php _e('No posts found.') ?></p> |
206 | |
207 | <?php |
208 | } // end if ( have_posts() ) |
209 | ?> |
210 |