web/wp-admin/edit-attachment-rows.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    28 <?php
    28 <?php
    29 add_filter('the_title','esc_html');
    29 add_filter('the_title','esc_html');
    30 $alt = '';
    30 $alt = '';
    31 $posts_columns = get_column_headers('upload');
    31 $posts_columns = get_column_headers('upload');
    32 $hidden = get_hidden_columns('upload');
    32 $hidden = get_hidden_columns('upload');
    33 while (have_posts()) : the_post();
    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 
    34 $alt = ( 'alternate' == $alt ) ? '' : 'alternate';
    41 $alt = ( 'alternate' == $alt ) ? '' : 'alternate';
    35 global $current_user;
    42 global $current_user;
    36 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
    43 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
    37 $att_title = _draft_or_post_title();
    44 $att_title = _draft_or_post_title();
    38 
       
    39 ?>
    45 ?>
    40 	<tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
    46 	<tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
    41 
    47 
    42 <?php
    48 <?php
    43 foreach ($posts_columns as $column_name => $column_display_name ) {
    49 foreach ($posts_columns as $column_name => $column_display_name ) {
    51 
    57 
    52 	switch($column_name) {
    58 	switch($column_name) {
    53 
    59 
    54 	case 'cb':
    60 	case 'cb':
    55 		?>
    61 		?>
    56 		<th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
    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>
    57 		<?php
    63 		<?php
    58 		break;
    64 		break;
    59 
    65 
    60 	case 'icon':
    66 	case 'icon':
    61 		$attributes = 'class="column-icon media-icon"' . $style;
    67 		$attributes = 'class="column-icon media-icon"' . $style;
    62 		?>
    68 		?>
    63 		<td <?php echo $attributes ?>><?php
    69 		<td <?php echo $attributes ?>><?php
    64 			if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
    70 			if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
    65 ?>
    71 				if ( $is_trash ) echo $thumb;
    66 
    72 				else {
       
    73 ?>
    67 				<a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>">
    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)); ?>">
    68 					<?php echo $thumb; ?>
    75 					<?php echo $thumb; ?>
    69 				</a>
    76 				</a>
    70 
    77 
    71 <?php			}
    78 <?php			}
       
    79 			}
    72 		?></td>
    80 		?></td>
    73 		<?php
    81 		<?php
    74 		// TODO
    82 		// TODO
    75 		break;
    83 		break;
    76 
    84 
    77 	case 'media':
    85 	case 'media':
    78 		?>
    86 		?>
    79 		<td <?php echo $attributes ?>><strong><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></strong><br />
    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 />
    80 		<?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
    88 		<?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
    81 		<p>
    89 		<p>
    82 		<?php
    90 		<?php
    83 		$actions = array();
    91 		$actions = array();
    84 		if ( current_user_can('edit_post', $post->ID) )
    92 		if ( current_user_can('edit_post', $post->ID) && !$is_trash )
    85 			$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
    93 			$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
    86 		if ( current_user_can('delete_post', $post->ID) )
    94 		if ( current_user_can('delete_post', $post->ID) ) {
    87 			$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(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>";
    95 			if ( $is_trash )
    88 		$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
    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 );
    89 		$action_count = count($actions);
   107 		$action_count = count($actions);
    90 		$i = 0;
   108 		$i = 0;
    91 		echo '<div class="row-actions">';
   109 		echo '<div class="row-actions">';
    92 		foreach ( $actions as $action => $link ) {
   110 		foreach ( $actions as $action => $link ) {
    93 			++$i;
   111 			++$i;
   156 			?>
   174 			?>
   157 			<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>
   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>
   158 			<?php
   176 			<?php
   159 		} else {
   177 		} else {
   160 			?>
   178 			?>
   161 			<td <?php echo $attributes ?>>&nbsp;</td>
   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>
   162 			<?php
   181 			<?php
   163 		}
   182 		}
   164 
   183 
   165 		break;
   184 		break;
   166 
   185 
   207 <p><?php _e('No media attachments found.') ?></p>
   226 <p><?php _e('No media attachments found.') ?></p>
   208 
   227 
   209 <?php
   228 <?php
   210 } // end if ( have_posts() )
   229 } // end if ( have_posts() )
   211 ?>
   230 ?>
       
   231