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'], ) ); $this->items = $wp_query->posts; /* -- Register the Columns -- */ $columns = $this->get_columns(); $hidden = array( 'id', ); $this->_column_headers = array( $columns, $hidden, $this->get_sortable_columns() ) ; remove_filter( 'posts_where', array( &$this, 'modify_post_status_to_private' ) ); } function modify_post_status_to_private( $where ) { return str_replace( "post_status = 'inherit' ", "post_status = 'arfaly-mass' ", $where ); } function get_bulk_actions() { $actions = array(); $actions['delete'] = __( 'Delete Permanently', 'arfaly-uploader' ); $actions['approve'] = __( 'Approve', 'arfaly-uploader' ); if ( $this->detached ) $actions['attach'] = __( 'Attach to a post', 'arfaly-uploader' ); return $actions; } function current_action() { if ( isset( $_REQUEST['find_detached'] ) ) return 'find_detached'; if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) return 'attach'; if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) return 'delete_all'; return parent::current_action(); } function has_items() { return have_posts(); } function no_items() { __( 'No media attachments found.', 'arfaly-uploader' ); } function get_columns() { $posts_columns = array(); $posts_columns['cb'] = ''; $posts_columns['icon'] = ''; /* translators: column name */ $posts_columns['title'] = _x( 'File', 'column name' ); $posts_columns['author'] = __( 'Author', 'arfaly-uploader' ); /* translators: column name */ if ( !$this->detached ) { $posts_columns['parent'] = _x( 'Attached to', 'column name' ); } /* translators: column name */ $posts_columns['date'] = _x( 'Date', 'column name' ); $posts_columns = apply_filters( 'manage_arfaly_media_columns', $posts_columns, $this->detached ); return $posts_columns; } function display_rows() { global $post, $id; 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; if ( $post->post_status == 'inherit' ) 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() ) ); ?>

row_actions( $this->_get_row_actions( $post, $att_title ) ); ?> >post_author==0)?'guest': get_the_author_meta('nickname',$post->post_author); ?> >slug'> " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'post_tag', 'display' ) ) . ""; echo join( ', ', $out ); } else { __( 'No Tags', 'arfaly-uploader' ); } ?> >post_excerpt : ''; ?> post_date && 'date' == $column_name ) { $t_time = $h_time = __( 'Unpublished', 'arfaly-uploader' ); } else { $t_time = get_the_time( __( 'Y/m/d g:i:s A', 'arfaly-uploader' ) ); $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', 'arfaly-uploader' ), human_time_diff( $time ) ); else $h_time = sprintf( __( '%s ago', 'arfaly-uploader' ), human_time_diff( $time ) ); } else { $h_time = mysql2date( __( 'Y/m/d', 'arfaly-uploader' ), $m_time ); } } ?> > post_parent > 0 ) { if ( get_post( $post->post_parent ) ) { $title =_draft_or_post_title( $post->post_parent ); } ?> > , > detached ) { if ( current_user_can( 'edit_post', $post->ID ) ) $actions['edit'] = '' . __( 'Edit', 'arfaly-uploader' ) . ''; if ( current_user_can( 'delete_post', $post->ID ) ) if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { $actions['trash'] = "ID ) . "'>" . __( 'Trash', 'arfaly-uploader' ) . ""; } else { $delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; // $actions['delete'] = "ID ) . "'>" . __( 'Delete Permanently', 'arfaly-uploader' ) . ""; $actions['delete'] = ''. __( 'Delete Permanently', 'arfaly-uploader' ) .''; } $actions['view'] = '' . __( 'View', 'arfaly-uploader' ) . ''; if ( current_user_can( 'edit_post', $post->ID ) ) $actions['attach'] = ''.__( 'Attach', 'arfaly-uploader' ).''; } else { if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) $actions['edit'] = '' . __( 'Edit', 'arfaly-uploader' ) . ''; if ( current_user_can( 'delete_post', $post->ID ) ) { if ( $this->is_trash ) $actions['untrash'] = "ID ) . "'>" . __( 'Restore', 'arfaly-uploader' ) . ""; elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) $actions['trash'] = "ID ) . "'>" . __( 'Trash', 'arfaly-uploader' ) . ""; 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', 'arfaly-uploader' ) . ""; } if ( $post->post_status == 'arfaly-mass' ) { $delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; $actions['pass'] = ''. __( 'Approve', 'arfaly-uploader' ) .''; $actions['delete'] = ''. __( 'Delete Permanently', 'arfaly-uploader' ) .''; } } if ( !$this->is_trash ) { $title =_draft_or_post_title( $post->post_parent ); $actions['view'] = '' . __( 'View', 'arfaly-uploader' ) . ''; } } $actions = apply_filters( 'media_row_actions', $actions, $post, $this->detached ); return $actions; } } // Add a nice little feature: // Re-attach Media // http://wordpress.org/support/topic/detach-amp-re-attach-media-attachment-images-from-posts add_filter( "manage_arfaly_media_columns", 'arfaly_upload_columns' ); add_action( "manage_arfaly_media_custom_column", 'arfaly_media_custom_columns', 0, 2 ); function arfaly_upload_columns( $columns ) { unset( $columns['parent'] ); $columns['better_parent'] = "Parent"; return $columns; } function arfaly_media_custom_columns( $column_name, $id ) { $post = get_post( $id ); if ( $column_name != 'better_parent' ) return; if ( $post->post_parent > 0 ) { if ( get_post( $post->post_parent ) ) { $title =_draft_or_post_title( $post->post_parent ); } else { $title = 'Untitled'; } ?>