Changeset 16229
- Timestamp:
- 11/06/2010 11:00:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-media-list-table.php
r16228 r16229 169 169 global $post, $id; 170 170 171 if ( $this->detached ) {172 $this->display_orphans();173 return;174 }175 176 171 add_filter( 'the_title','esc_html' ); 177 172 $alt = ''; … … 240 235 </p> 241 236 <?php 242 $actions = array(); 243 if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) 244 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>'; 245 if ( current_user_can( 'delete_post', $post->ID ) ) { 246 if ( $this->is_trash ) 247 $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-attachment_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; 248 elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) 249 $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-attachment_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; 250 if ( $this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { 251 $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; 252 $actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-attachment_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>"; 253 } 254 } 255 if ( !$this->is_trash ) { 256 $title =_draft_or_post_title( $post->post_parent ); 257 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>'; 258 } 259 $actions = apply_filters( 'media_row_actions', $actions, $post ); 260 echo $this->row_actions( $actions ); 237 echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); 261 238 ?> 262 239 </td> … … 362 339 } 363 340 364 function display_orphans() { 365 global $post; 366 367 $class = ''; 368 369 while ( have_posts() ) : the_post(); 370 371 $class = ( 'alternate' == $class ) ? '' : 'alternate'; 372 $att_title = esc_html( _draft_or_post_title( $post->ID ) ); 373 374 $edit_link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ) . '">%s</a>'; 375 ?> 376 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top"> 377 <th scope="row" class="check-column"> 378 <?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?> 379 <input type="checkbox" name="media[]" value="<?php echo esc_attr( $post->ID ); ?>" /> 380 <?php } ?> 381 </th> 382 383 <td class="media-icon"> 384 <?php if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) { 385 printf( $edit_link, $thumb ); 386 } ?> 387 </td> 388 389 <td class="media column-media"> 390 <strong><?php printf( $edit_link, $att_title ); ?></strong><br /> 391 <?php 392 if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) 393 echo esc_html( strtoupper( $matches[1] ) ); 394 else 395 echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) ); 396 ?> 397 <?php 398 $actions = array(); 341 function _get_row_actions( $post, $att_title ) { 342 $actions = array(); 343 344 if ( $this->detached ) { 399 345 if ( current_user_can( 'edit_post', $post->ID ) ) 400 346 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>'; … … 409 355 if ( current_user_can( 'edit_post', $post->ID ) ) 410 356 $actions['attach'] = '<a href="#the-list" onclick="findPosts.open( \'media[]\',\''.$post->ID.'\' );return false;" class="hide-if-no-js">'.__( 'Attach' ).'</a>'; 411 $actions = apply_filters( 'media_row_actions', $actions, $post ); 412 413 echo $this->row_actions( $actions ); 414 ?> 415 </td> 416 <td class="author column-author"> 417 <?php $author = get_userdata( $post->post_author ); echo $author->display_name; ?> 418 </td> 419 <?php 420 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { 421 $t_time = $h_time = __( 'Unpublished' ); 422 } else { 423 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) ); 424 $m_time = $post->post_date; 425 $time = get_post_time( 'G', true ); 426 if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) { 427 if ( $t_diff < 0 ) 428 $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); 429 else 430 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); 431 } else { 432 $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); 433 } 434 } 435 ?> 436 <td class="date column-date"><?php echo $h_time ?></td> 437 </tr> 438 <?php 439 endwhile; 357 } 358 else { 359 if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) 360 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>'; 361 if ( current_user_can( 'delete_post', $post->ID ) ) { 362 if ( $this->is_trash ) 363 $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-attachment_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; 364 elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) 365 $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-attachment_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; 366 if ( $this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { 367 $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; 368 $actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-attachment_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>"; 369 } 370 } 371 if ( !$this->is_trash ) { 372 $title =_draft_or_post_title( $post->post_parent ); 373 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>'; 374 } 375 } 376 377 $actions = apply_filters( 'media_row_actions', $actions, $post, $this->detached ); 378 379 return $actions; 440 380 } 441 381 }
Note: See TracChangeset
for help on using the changeset viewer.