web/wp-admin/upload.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once('admin.php');
    10 require_once('admin.php');
    11 wp_enqueue_script( 'wp-ajax-response' );
    11 wp_enqueue_script( 'wp-ajax-response' );
    12 wp_enqueue_script( 'jquery-ui-draggable' );
    12 wp_enqueue_script( 'jquery-ui-draggable' );
    13 
    13 
    14 if (!current_user_can('upload_files'))
    14 if ( !current_user_can('upload_files') )
    15 	wp_die(__('You do not have permission to upload files.'));
    15 	wp_die(__('You do not have permission to upload files.'));
    16 
    16 
    17 if ( isset($_GET['find_detached'] ) ) {
    17 if ( isset($_GET['find_detached']) ) {
    18 	check_admin_referer('bulk-media');
    18 	check_admin_referer('bulk-media');
    19 
    19 
    20 	if ( ! current_user_can('edit_posts') )
    20 	if ( !current_user_can('edit_posts') )
    21 		wp_die( __('You are not allowed to scan for lost attachments.') );
    21 		wp_die( __('You are not allowed to scan for lost attachments.') );
    22 
    22 
    23 	$all_posts = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'post' OR post_type = 'page'");
    23 	$all_posts = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'post' OR post_type = 'page'");
    24 	$all_att = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'attachment'");
    24 	$all_att = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'attachment'");
    25 
    25 
    60 		if ( $referer = wp_get_referer() ) {
    60 		if ( $referer = wp_get_referer() ) {
    61 			if ( false !== strpos($referer, 'upload.php') )
    61 			if ( false !== strpos($referer, 'upload.php') )
    62 				$location = $referer;
    62 				$location = $referer;
    63 		}
    63 		}
    64 
    64 
    65 		$location = add_query_arg( array( 'detached' => 1, 'attached' => $attached ) , $location );
    65 		$location = add_query_arg( array( 'attached' => $attached ) , $location );
    66 		wp_redirect($location);
    66 		wp_redirect($location);
    67 		exit;
    67 		exit;
    68 	}
    68 	}
    69 
    69 
    70 } elseif ( isset($_GET['action']) && isset($_GET['media']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
    70 } elseif ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
    71 	check_admin_referer('bulk-media');
    71 	check_admin_referer('bulk-media');
    72 	$doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
    72 
    73 
    73 	if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
    74 	if ( 'delete' == $doaction ) {
    74 		$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
    75 		foreach( (array) $_GET['media'] as $post_id_del ) {
    75 		$doaction = 'delete';
    76 			$post_del = & get_post($post_id_del);
    76 	} elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['media']) || isset($_GET['ids']) ) ) {
    77 
    77 		$post_ids = isset($_GET['media']) ? $_GET['media'] : explode(',', $_GET['ids']);
    78 			if ( !current_user_can('delete_post', $post_id_del) )
    78 		$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
    79 				wp_die( __('You are not allowed to delete this post.') );
    79 	} else {
    80 
    80 		wp_redirect($_SERVER['HTTP_REFERER']);
    81 			if ( $post_del->post_type == 'attachment' )
    81 	}
    82 				if ( ! wp_delete_attachment($post_id_del) )
    82 
       
    83 	$location = 'upload.php';
       
    84 	if ( $referer = wp_get_referer() ) {
       
    85 		if ( false !== strpos($referer, 'upload.php') )
       
    86 			$location = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted'), $referer );
       
    87 	}
       
    88 
       
    89 	switch ( $doaction ) {
       
    90 		case 'trash':
       
    91 			foreach( (array) $post_ids as $post_id ) {
       
    92 				if ( !current_user_can('delete_post', $post_id) )
       
    93 					wp_die( __('You are not allowed to move this post to the trash.') );
       
    94 
       
    95 				if ( !wp_trash_post($post_id) )
       
    96 					wp_die( __('Error in moving to trash...') );
       
    97 			}
       
    98 			$location = add_query_arg( array( 'message' => 4, 'ids' => join(',', $post_ids) ), $location );
       
    99 			break;
       
   100 		case 'untrash':
       
   101 			foreach( (array) $post_ids as $post_id ) {
       
   102 				if ( !current_user_can('delete_post', $post_id) )
       
   103 					wp_die( __('You are not allowed to move this post out of the trash.') );
       
   104 
       
   105 				if ( !wp_untrash_post($post_id) )
       
   106 					wp_die( __('Error in restoring from trash...') );
       
   107 			}
       
   108 			$location = add_query_arg('message', 5, $location);
       
   109 			break;
       
   110 		case 'delete':
       
   111 			foreach( (array) $post_ids as $post_id_del ) {
       
   112 				if ( !current_user_can('delete_post', $post_id_del) )
       
   113 					wp_die( __('You are not allowed to delete this post.') );
       
   114 
       
   115 				if ( !wp_delete_attachment($post_id_del) )
    83 					wp_die( __('Error in deleting...') );
   116 					wp_die( __('Error in deleting...') );
    84 		}
   117 			}
    85 
   118 			$location = add_query_arg('message', 2, $location);
    86 		$location = 'upload.php';
   119 			break;
    87 		if ( $referer = wp_get_referer() ) {
   120 	}
    88 			if ( false !== strpos($referer, 'upload.php') )
   121 
    89 				$location = $referer;
   122 	wp_redirect($location);
    90 		}
   123 	exit;
    91 
       
    92 		$location = add_query_arg('message', 2, $location);
       
    93 		$location = remove_query_arg('posted', $location);
       
    94 		wp_redirect($location);
       
    95 		exit;
       
    96 	}
       
    97 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
   124 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
    98 	 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
   125 	 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
    99 	 exit;
   126 	 exit;
   100 }
   127 }
   101 
   128 
   105 if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
   132 if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
   106 	$_GET['paged'] = 1;
   133 	$_GET['paged'] = 1;
   107 
   134 
   108 if ( isset($_GET['detached']) ) {
   135 if ( isset($_GET['detached']) ) {
   109 
   136 
       
   137 	$media_per_page = (int) get_user_option( 'upload_per_page', 0, false );
       
   138 	if ( empty($media_per_page) || $media_per_page < 1 )
       
   139 		$media_per_page = 20;
       
   140 	$media_per_page = apply_filters( 'upload_per_page', $media_per_page );
       
   141 
   110 	if ( !empty($lost) ) {
   142 	if ( !empty($lost) ) {
   111 		$start = ( $_GET['paged'] - 1 ) * 50;
   143 		$start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
   112 		$page_links_total = ceil(count($lost) / 50);
   144 		$page_links_total = ceil(count($lost) / $media_per_page);
   113 		$lost = implode(',', $lost);
   145 		$lost = implode(',', $lost);
   114 
   146 
   115 		$orphans = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN ($lost) LIMIT $start, 50" );
   147 		$orphans = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN (%s) LIMIT %d, %d", $lost, $start, $media_per_page ) );
   116 	} else {
   148 	} else {
   117 		$start = ( $_GET['paged'] - 1 ) * 25;
   149 		$start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
   118 		$orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent < 1 LIMIT $start, 25" );
   150 		$orphans = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT %d, %d", $start, $media_per_page ) );
   119 		$page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
   151 		$page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / $media_per_page);
   120 	}
   152 	}
   121 
   153 
   122 	$post_mime_types = array(
   154 	$post_mime_types = get_post_mime_types();
   123 				'image' => array(__('Images'), __('Manage Images'), _n_noop('Image (%s)', 'Images (%s)')),
       
   124 				'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio (%s)', 'Audio (%s)')),
       
   125 				'video' => array(__('Video'), __('Manage Video'), _n_noop('Video (%s)', 'Video (%s)')),
       
   126 			);
       
   127 	$post_mime_types = apply_filters('post_mime_types', $post_mime_types);
       
   128 
       
   129 	$avail_post_mime_types = get_available_post_mime_types('attachment');
   155 	$avail_post_mime_types = get_available_post_mime_types('attachment');
   130 
   156 
   131 	if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )
   157 	if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )
   132 		unset($_GET['post_mime_type']);
   158 		unset($_GET['post_mime_type']);
   133 
   159 
   134 } else {
   160 } else {
   135 	list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
   161 	list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
   136 }
   162 }
   137 
   163 
       
   164 $is_trash = ( isset($_GET['status']) && $_GET['status'] == 'trash' );
       
   165 
   138 wp_enqueue_script('media');
   166 wp_enqueue_script('media');
   139 require_once('admin-header.php'); ?>
   167 require_once('admin-header.php');
   140 
   168 
   141 <?php
   169 do_action('restrict_manage_posts');
       
   170 ?>
       
   171 
       
   172 <div class="wrap">
       
   173 <?php screen_icon(); ?>
       
   174 <h2><?php echo esc_html( $title ); ?> <a href="media-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a> <?php
       
   175 if ( isset($_GET['s']) && $_GET['s'] )
       
   176 	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
       
   177 </h2>
       
   178 
       
   179 <?php
       
   180 $message = '';
   142 if ( isset($_GET['posted']) && (int) $_GET['posted'] ) {
   181 if ( isset($_GET['posted']) && (int) $_GET['posted'] ) {
   143 	$_GET['message'] = '1';
   182 	$_GET['message'] = '1';
   144 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
   183 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
   145 }
   184 }
   146 
   185 
   148 	$attached = (int) $_GET['attached'];
   187 	$attached = (int) $_GET['attached'];
   149 	$message = sprintf( _n('Reattached %d attachment', 'Reattached %d attachments', $attached), $attached );
   188 	$message = sprintf( _n('Reattached %d attachment', 'Reattached %d attachments', $attached), $attached );
   150 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('attached'), $_SERVER['REQUEST_URI']);
   189 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('attached'), $_SERVER['REQUEST_URI']);
   151 }
   190 }
   152 
   191 
       
   192 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
       
   193 	$_GET['message'] = '2';
       
   194 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
       
   195 }
       
   196 
       
   197 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
       
   198 	$_GET['message'] = '4';
       
   199 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']);
       
   200 }
       
   201 
       
   202 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
       
   203 	$_GET['message'] = '5';
       
   204 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']);
       
   205 }
       
   206 
   153 $messages[1] = __('Media attachment updated.');
   207 $messages[1] = __('Media attachment updated.');
   154 $messages[2] = __('Media deleted.');
   208 $messages[2] = __('Media permanently deleted.');
   155 $messages[3] = __('Error saving media attachment.');
   209 $messages[3] = __('Error saving media attachment.');
       
   210 $messages[4] = __('Media moved to the trash.') . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
       
   211 $messages[5] = __('Media restored from the trash.');
   156 
   212 
   157 if ( isset($_GET['message']) && (int) $_GET['message'] ) {
   213 if ( isset($_GET['message']) && (int) $_GET['message'] ) {
   158 	$message = $messages[$_GET['message']];
   214 	$message = $messages[$_GET['message']];
   159 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
   215 	$_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
   160 }
   216 }
   161 ?>
   217 
   162 
   218 if ( !empty($message) ) { ?>
   163 <?php do_action('restrict_manage_posts'); ?>
       
   164 
       
   165 <div class="wrap">
       
   166 <?php screen_icon(); ?>
       
   167 <h2><?php echo esc_html( $title );
       
   168 if ( isset($_GET['s']) && $_GET['s'] )
       
   169 	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
       
   170 </h2>
       
   171 
       
   172 <?php
       
   173 if ( isset($message) ) { ?>
       
   174 <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
   219 <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
   175 <?php
   220 <?php } ?>
   176 }
       
   177 ?>
       
   178 
   221 
   179 <ul class="subsubsub">
   222 <ul class="subsubsub">
   180 <?php
   223 <?php
   181 $type_links = array();
   224 $type_links = array();
   182 $_num_posts = (array) wp_count_attachments();
   225 $_num_posts = (array) wp_count_attachments();
   183 $_total_posts = array_sum( $_num_posts );
   226 $_total_posts = array_sum($_num_posts) - $_num_posts['trash'];
   184 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
   227 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
   185 foreach ( $matches as $type => $reals )
   228 foreach ( $matches as $type => $reals )
   186 	foreach ( $reals as $real )
   229 	foreach ( $reals as $real )
   187 		$num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
   230 		$num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
   188 
   231 
   189 $class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';
   232 $class = ( empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status']) ) ? ' class="current"' : '';
   190 $type_links[] = "<li><a href='upload.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</a>';
   233 $type_links[] = "<li><a href='upload.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</a>';
   191 foreach ( $post_mime_types as $mime_type => $label ) {
   234 foreach ( $post_mime_types as $mime_type => $label ) {
   192 	$class = '';
   235 	$class = '';
   193 
   236 
   194 	if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
   237 	if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
   197 	if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
   240 	if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
   198 		$class = ' class="current"';
   241 		$class = ' class="current"';
   199 
   242 
   200 	$type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
   243 	$type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
   201 }
   244 }
   202 $class = isset($_GET['detached']) ? ' class="current"' : '';
   245 $type_links[] = '<li><a href="upload.php?detached=1"' . ( isset($_GET['detached']) ? ' class="current"' : '' ) . '>' . __('Unattached') . '</a>';
   203 $type_links[] = '<li><a href="upload.php?detached=1"' . $class . '>' . __('Unattached') . '</a>';
   246 if ( EMPTY_TRASH_DAYS && ( MEDIA_TRASH || !empty($_num_posts['trash']) ) )
       
   247 	$type_links[] = '<li><a href="upload.php?status=trash"' . ( (isset($_GET['status']) && $_GET['status'] == 'trash' ) ? ' class="current"' : '') . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</a>';
   204 
   248 
   205 echo implode( " |</li>\n", $type_links) . '</li>';
   249 echo implode( " |</li>\n", $type_links) . '</li>';
   206 unset($type_links);
   250 unset($type_links);
   207 ?>
   251 ?>
   208 </ul>
   252 </ul>
   240 <?php endif; ?>
   284 <?php endif; ?>
   241 
   285 
   242 <div class="alignleft actions">
   286 <div class="alignleft actions">
   243 <select name="action" class="select-action">
   287 <select name="action" class="select-action">
   244 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
   288 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
   245 <option value="delete"><?php _e('Delete'); ?></option>
   289 <?php if ( $is_trash ) { ?>
   246 <?php if ( isset($orphans) ) { ?>
   290 <option value="untrash"><?php _e('Restore'); ?></option>
       
   291 <?php } if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { ?>
       
   292 <option value="delete"><?php _e('Delete Permanently'); ?></option>
       
   293 <?php } else { ?>
       
   294 <option value="trash"><?php _e('Move to Trash'); ?></option>
       
   295 <?php } if ( isset($orphans) ) { ?>
   247 <option value="attach"><?php _e('Attach to a post'); ?></option>
   296 <option value="attach"><?php _e('Attach to a post'); ?></option>
   248 <?php } ?>
   297 <?php } ?>
   249 </select>
   298 </select>
   250 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
   299 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
   251 <?php wp_nonce_field('bulk-media'); ?>
   300 <?php wp_nonce_field('bulk-media'); ?>
   252 
   301 
   253 <?php
   302 <?php
   254 if ( ! is_singular() && ! isset($_GET['detached']) ) {
   303 if ( !is_singular() && !isset($_GET['detached']) && !$is_trash ) {
   255 	$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
   304 	$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
   256 
   305 
   257 	$arc_result = $wpdb->get_results( $arc_query );
   306 	$arc_result = $wpdb->get_results( $arc_query );
   258 
   307 
   259 	$month_count = count($arc_result);
   308 	$month_count = count($arc_result);
   260 
   309 
   261 	if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?>
   310 	if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?>
   262 <select name='m'>
   311 <select name='m'>
   263 <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
   312 <option value='0'><?php _e('Show all dates'); ?></option>
   264 <?php
   313 <?php
   265 foreach ($arc_result as $arc_row) {
   314 foreach ($arc_result as $arc_row) {
   266 	if ( $arc_row->yyear == 0 )
   315 	if ( $arc_row->yyear == 0 )
   267 		continue;
   316 		continue;
   268 	$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
   317 	$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
   269 
   318 
   270 	if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
   319 	if ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) )
   271 		$default = ' selected="selected"';
   320 		$default = ' selected="selected"';
   272 	else
   321 	else
   273 		$default = '';
   322 		$default = '';
   274 
   323 
   275 	echo "<option$default value='" . esc_attr("$arc_row->yyear$arc_row->mmonth") . "'>";
   324 	echo "<option$default value='" . esc_attr("$arc_row->yyear$arc_row->mmonth") . "'>";
   284 
   333 
   285 <?php } // ! is_singular ?>
   334 <?php } // ! is_singular ?>
   286 
   335 
   287 <?php if ( isset($_GET['detached']) ) { ?>
   336 <?php if ( isset($_GET['detached']) ) { ?>
   288 	<input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" />
   337 	<input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" />
       
   338 <?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?>
       
   339 	<input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
   289 <?php } ?>
   340 <?php } ?>
   290 
   341 
   291 </div>
   342 </div>
   292 
   343 
   293 <br class="clear" />
   344 <br class="clear" />
   323 		foreach ( $orphans as $post ) {
   374 		foreach ( $orphans as $post ) {
   324 			$class = 'alternate' == $class ? '' : 'alternate';
   375 			$class = 'alternate' == $class ? '' : 'alternate';
   325 			$att_title = esc_html( _draft_or_post_title($post->ID) );
   376 			$att_title = esc_html( _draft_or_post_title($post->ID) );
   326 ?>
   377 ?>
   327 	<tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top">
   378 	<tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top">
   328 		<th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php echo esc_attr($post->ID); ?>" /></th>
   379 		<th scope="row" class="check-column"><?php if ( current_user_can('edit_post', $post->ID) ) { ?><input type="checkbox" name="media[]" value="<?php echo esc_attr($post->ID); ?>" /><?php } ?></th>
   329 
   380 
   330 		<td class="media-icon"><?php
   381 		<td class="media-icon"><?php
   331 		if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { ?>
   382 		if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { ?>
   332 			<a href="media.php?action=edit&amp;attachment_id=<?php echo $post->ID; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>"><?php echo $thumb; ?></a>
   383 			<a href="media.php?action=edit&amp;attachment_id=<?php echo $post->ID; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>"><?php echo $thumb; ?></a>
   333 <?php	} ?></td>
   384 <?php	} ?></td>
   339 		<?php
   390 		<?php
   340 		$actions = array();
   391 		$actions = array();
   341 		if ( current_user_can('edit_post', $post->ID) )
   392 		if ( current_user_can('edit_post', $post->ID) )
   342 			$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
   393 			$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
   343 		if ( current_user_can('delete_post', $post->ID) )
   394 		if ( current_user_can('delete_post', $post->ID) )
   344 			$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>";
   395 			if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
       
   396 				$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
       
   397 			} else {
       
   398 				$delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
       
   399 				$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>";
       
   400 			}
   345 		$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
   401 		$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
   346 		if ( current_user_can('edit_post', $post->ID) )
   402 		if ( current_user_can('edit_post', $post->ID) )
   347 			$actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;">'.__('Attach').'</a>';
   403 			$actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;" class="hide-if-no-js">'.__('Attach').'</a>';
   348 		$actions = apply_filters( 'media_row_actions', $actions, $post );
   404 		$actions = apply_filters( 'media_row_actions', $actions, $post );
   349 		$action_count = count($actions);
   405 		$action_count = count($actions);
   350 		$i = 0;
   406 		$i = 0;
   351 		foreach ( $actions as $action => $link ) {
   407 		foreach ( $actions as $action => $link ) {
   352 			++$i;
   408 			++$i;
   378 	<tr><td colspan="5"><?php _e('No media attachments found.') ?></td></tr>
   434 	<tr><td colspan="5"><?php _e('No media attachments found.') ?></td></tr>
   379 <?php } ?>
   435 <?php } ?>
   380 </tbody>
   436 </tbody>
   381 </table>
   437 </table>
   382 
   438 
   383 <?php find_posts_div();
   439 <?php
   384 
   440 
   385 } else {
   441 } else {
   386 	include( 'edit-attachment-rows.php' );
   442 	include( 'edit-attachment-rows.php' );
   387 } ?>
   443 } ?>
   388 
   444 
   396 ?>
   452 ?>
   397 
   453 
   398 <div class="alignleft actions">
   454 <div class="alignleft actions">
   399 <select name="action2" class="select-action">
   455 <select name="action2" class="select-action">
   400 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
   456 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
   401 <option value="delete"><?php _e('Delete'); ?></option>
   457 <?php if ($is_trash) { ?>
   402 <?php if ( isset($orphans) ) { ?>
   458 <option value="untrash"><?php _e('Restore'); ?></option>
       
   459 <?php } if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { ?>
       
   460 <option value="delete"><?php _e('Delete Permanently'); ?></option>
       
   461 <?php } else { ?>
       
   462 <option value="trash"><?php _e('Move to Trash'); ?></option>
       
   463 <?php } if (isset($orphans)) { ?>
   403 <option value="attach"><?php _e('Attach to a post'); ?></option>
   464 <option value="attach"><?php _e('Attach to a post'); ?></option>
   404 <?php } ?>
   465 <?php } ?>
   405 </select>
   466 </select>
   406 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
   467 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
       
   468 
       
   469 <?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?>
       
   470 	<input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
       
   471 <?php } ?>
   407 </div>
   472 </div>
   408 
   473 
   409 <br class="clear" />
   474 <br class="clear" />
   410 </div>
   475 </div>
       
   476 <?php find_posts_div(); ?>
   411 </form>
   477 </form>
   412 <br class="clear" />
   478 <br class="clear" />
   413 
   479 
   414 </div>
   480 </div>
   415 
   481