[ Index ]

PHP Cross Reference of Wordpress 2.9.1

title

Body

[close]

/wp-admin/ -> edit-attachment-rows.php (source)

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


Generated: Fri Jan 8 00:19:48 2010 Cross-referenced by PHPXref 0.7