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