*/
class WP_Media_List_Table extends WP_List_Table {
+ private $detached;
+
+ private $is_trash;
+
/**
* Constructor.
*
if ( !empty( $_GET['attachment-filter'] ) && strpos( $_GET['attachment-filter'], 'post_mime_type:' ) === 0 && wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $_GET['attachment-filter'] ) ) )
$selected = ' selected="selected"';
if ( !empty( $num_posts[$mime_type] ) )
- $type_links[$mime_type] = '<option value="post_mime_type:' . sanitize_mime_type( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
+ $type_links[$mime_type] = '<option value="post_mime_type:' . esc_attr( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
}
$type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</option>';
if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
return 'attach';
+ if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) )
+ return 'detach';
+
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
return 'delete_all';
_e( 'No media attachments found.' );
}
- /**
- * @param string $which
- */
- protected function pagination( $which ) {
- parent::pagination( $which );
- }
-
/**
* Override parent views so we can use the filter bar display.
*/
<div class="filter-items">
<?php $this->view_switcher( $mode ); ?>
- <select class="attachment-filters" name="attachment-filter">
+ <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label>
+ <select class="attachment-filters" name="attachment-filter" id="attachment-filter">
<?php
if ( ! empty( $views ) ) {
foreach ( $views as $class => $view ) {
global $post;
add_filter( 'the_title','esc_html' );
- $alt = '';
while ( have_posts() ) : the_post();
$user_can_edit = current_user_can( 'edit_post', $post->ID );
|| !$this->is_trash && $post->post_status == 'trash' )
continue;
- $alt = ( 'alternate' == $alt ) ? '' : 'alternate';
$post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other';
$att_title = _draft_or_post_title();
?>
- <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
+ <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
<?php
list( $columns, $hidden ) = $this->get_column_info();
echo $thumb;
} else {
?>
- <a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
+ <a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
<?php echo $thumb; ?>
</a>
<?php if ( $this->is_trash || ! $user_can_edit ) {
echo $att_title;
} else { ?>
- <a href="<?php echo get_edit_post_link( $post->ID, true ); ?>"
+ <a href="<?php echo get_edit_post_link( $post->ID ); ?>"
title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
<?php echo $att_title; ?></a>
<?php };
_media_states( $post ); ?></strong>
- <p>
-<?php
- if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
- echo esc_html( strtoupper( $matches[1] ) );
- else
- echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
-?>
- </p>
+ <p class="filename"><?php echo wp_basename( $post->guid ); ?></p>
<?php
echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
?>
} else {
echo $title;
} ?></strong>,
- <?php echo get_the_time( __( 'Y/m/d' ) ); ?>
+ <?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
+ <?php
+ if ( $user_can_edit ):
+ $detach_url = add_query_arg( array(
+ 'parent_post_id' => $post->post_parent,
+ 'media[]' => $post->ID,
+ '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
+ ), 'upload.php' ); ?>
+ <a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a>
+ <?php endif; ?>
</td>
<?php
} else {
if ( $this->detached ) {
if ( current_user_can( 'edit_post', $post->ID ) )
- $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>';
+ $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '">' . __( 'Edit' ) . '</a>';
if ( current_user_can( 'delete_post', $post->ID ) )
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
}
else {
if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash )
- $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>';
+ $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '">' . __( 'Edit' ) . '</a>';
if ( current_user_can( 'delete_post', $post->ID ) ) {
if ( $this->is_trash )
$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";