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