detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
parent::WP_List_Table( array(
'plural' => 'media'
) );
}
function check_permissions() {
if ( !current_user_can('upload_files') )
wp_die( __( 'You do not have permission to upload files.' ) );
}
function prepare_items() {
global $lost, $wpdb, $wp_query, $post_mime_types, $avail_post_mime_types;
$q = $_REQUEST;
if ( !empty( $lost ) )
$q['post__in'] = implode( ',', $lost );
list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $q );
$this->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status'];
$this->set_pagination_args( array(
'total_items' => $wp_query->found_posts,
'total_pages' => $wp_query->max_num_pages,
'per_page' => $wp_query->query_vars['posts_per_page'],
) );
}
function get_views() {
global $wpdb, $post_mime_types, $avail_post_mime_types;
$type_links = array();
$_num_posts = (array) wp_count_attachments();
$_total_posts = array_sum($_num_posts) - $_num_posts['trash'];
if ( !isset( $total_orphans ) )
$total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" );
$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
foreach ( $matches as $type => $reals )
foreach ( $reals as $real )
$num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
$class = ( empty($_GET['post_mime_type']) && !$this->detached && !isset($_GET['status']) ) ? ' class="current"' : '';
$type_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '';
foreach ( $post_mime_types as $mime_type => $label ) {
$class = '';
if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
continue;
if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
$class = ' class="current"';
if ( !empty( $num_posts[$mime_type] ) )
$type_links[$mime_type] = "" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '';
}
$type_links['detached'] = 'detached ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '';
if ( !empty($_num_posts['trash']) )
$type_links['trash'] = '' . sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '';
return $type_links;
}
function get_bulk_actions() {
$actions = array();
$actions['delete'] = __( 'Delete Permanently' );
if ( $this->detached )
$actions['attach'] = __( 'Attach to a post' );
return $actions;
}
function extra_tablenav( $which ) {
global $post_type;
$post_type_obj = get_post_type_object( $post_type );
?>
detached && !$this->is_trash ) {
$this->months_dropdown( $post_type );
do_action( 'restrict_manage_posts' );
submit_button( __( 'Filter' ), 'secondary', 'post-query-submit', false );
}
if ( $this->detached ) {
submit_button( __( 'Scan for lost attachments' ), 'secondary', 'find_detached', false );
} elseif ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false );
} ?>
detached ) {
?>
extra_tablenav( 'top' ); ?>
';
$posts_columns['icon'] = '';
/* translators: column name */
$posts_columns['title'] = _x( 'File', 'column name' );
$posts_columns['author'] = __( 'Author' );
//$posts_columns['tags'] = _x( 'Tags', 'column name' );
/* translators: column name */
if ( !$this->detached ) {
$posts_columns['parent'] = _x( 'Attached to', 'column name' );
$posts_columns['comments'] = '';
}
/* translators: column name */
$posts_columns['date'] = _x( 'Date', 'column name' );
$posts_columns = apply_filters( 'manage_media_columns', $posts_columns, $this->detached );
return $posts_columns;
}
function get_sortable_columns() {
return array(
'title' => 'title',
'author' => 'author',
'parent' => 'parent',
'comments' => 'comment_count',
'date' => 'date',
);
}
function display_rows() {
global $post, $id;
if ( $this->detached ) {
$this->display_orphans();
return;
}
add_filter( 'the_title','esc_html' );
$alt = '';
while ( have_posts() ) : the_post();
if ( $this->is_trash && $post->post_status != 'trash'
|| !$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();
?>
post_status ); ?>' valign="top">
get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$class = "class='$column_name column-$column_name'";
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
$attributes = $class . $style;
switch ( $column_name ) {
case 'cb':
?>
ID ) ) { ?> |
>ID, array( 80, 60 ), true ) ) {
if ( $this->is_trash ) {
echo $thumb;
} else {
?>
|
>is_trash ) echo $att_title; else { ?>
ID ), $matches ) )
echo esc_html( strtoupper( $matches[1] ) );
else
echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
?>
ID ) && !$this->is_trash )
$actions['edit'] = '' . __( 'Edit' ) . '';
if ( current_user_can( 'delete_post', $post->ID ) ) {
if ( $this->is_trash )
$actions['untrash'] = "ID ) . "'>" . __( 'Restore' ) . "";
elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
$actions['trash'] = "ID ) . "'>" . __( 'Trash' ) . "";
if ( $this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) {
$delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
$actions['delete'] = "ID ) . "'>" . __( 'Delete Permanently' ) . "";
}
}
if ( !$this->is_trash ) {
$title =_draft_or_post_title( $post->post_parent );
$actions['view'] = '' . __( 'View' ) . '';
}
$actions = apply_filters( 'media_row_actions', $actions, $post );
echo $this->row_actions( $actions );
?>
|
> |
>slug'> " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'post_tag', 'display' ) ) . "";
echo join( ', ', $out );
} else {
_e( 'No Tags' );
}
?>
|
>post_excerpt : ''; ?> |
post_date && 'date' == $column_name ) {
$t_time = $h_time = __( 'Unpublished' );
} else {
$t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $post, false );
if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
if ( $t_diff < 0 )
$h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
else
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
} else {
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
}
}
?>
> |
post_parent > 0 ) {
if ( get_post( $post->post_parent ) ) {
$title =_draft_or_post_title( $post->post_parent );
}
?>
>
,
|
>
|
>
ID );
$this->comments_bubble( $post->ID, $pending_comments );
?>
|
>
|
ID ) );
$edit_link = '%s';
?>
ID ) ) { ?>
|
ID, array( 80, 60 ), true ) ) {
printf( $edit_link, $thumb );
} ?>
|
ID ), $matches ) )
echo esc_html( strtoupper( $matches[1] ) );
else
echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
?>
ID ) )
$actions['edit'] = '' . __( 'Edit' ) . '';
if ( current_user_can( 'delete_post', $post->ID ) )
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
$actions['trash'] = "ID ) . "'>" . __( 'Trash' ) . "";
} else {
$delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
$actions['delete'] = "ID ) . "'>" . __( 'Delete Permanently' ) . "";
}
$actions['view'] = '' . __( 'View' ) . '';
if ( current_user_can( 'edit_post', $post->ID ) )
$actions['attach'] = ''.__( 'Attach' ).'';
$actions = apply_filters( 'media_row_actions', $actions, $post );
echo $this->row_actions( $actions );
?>
|
post_author ); echo $author->display_name; ?>
|
post_date && 'date' == $column_name ) {
$t_time = $h_time = __( 'Unpublished' );
} else {
$t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
$m_time = $post->post_date;
$time = get_post_time( 'G', true );
if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
if ( $t_diff < 0 )
$h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
else
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
} else {
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
}
}
?>
|