mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Media Library administration panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11 wp_enqueue_script( 'wp-ajax-response' );
mp-wp_genesis 12 wp_enqueue_script( 'jquery-ui-draggable' );
mp-wp_genesis 13 wp_enqueue_script( 'jquery-ui-resizable' );
mp-wp_genesis 14
mp-wp_genesis 15 if (!current_user_can('upload_files'))
mp-wp_genesis 16 wp_die(__('You do not have permission to upload files.'));
mp-wp_genesis 17
mp-wp_genesis 18 if ( isset($_GET['find_detached'] ) ) {
mp-wp_genesis 19 check_admin_referer('bulk-media');
mp-wp_genesis 20
mp-wp_genesis 21 if ( ! current_user_can('edit_posts') )
mp-wp_genesis 22 wp_die( __('You are not allowed to scan for lost attachments.') );
mp-wp_genesis 23
mp-wp_genesis 24 $all_posts = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'post' OR post_type = 'page'");
mp-wp_genesis 25 $all_att = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'attachment'");
mp-wp_genesis 26
mp-wp_genesis 27 $lost = array();
mp-wp_genesis 28 foreach ( (array) $all_att as $att ) {
mp-wp_genesis 29 if ( $att->post_parent > 0 && ! in_array($att->post_parent, $all_posts) )
mp-wp_genesis 30 $lost[] = $att->ID;
mp-wp_genesis 31 }
mp-wp_genesis 32 $_GET['detached'] = 1;
mp-wp_genesis 33
mp-wp_genesis 34 } elseif ( isset($_GET['found_post_id']) && isset($_GET['media']) ) {
mp-wp_genesis 35 check_admin_referer('bulk-media');
mp-wp_genesis 36
mp-wp_genesis 37 if ( ! ( $parent_id = (int) $_GET['found_post_id'] ) )
mp-wp_genesis 38 return;
mp-wp_genesis 39
mp-wp_genesis 40 $parent = &get_post($parent_id);
mp-wp_genesis 41 if ( !current_user_can('edit_post', $parent_id) )
mp-wp_genesis 42 wp_die( __('You are not allowed to edit this post.') );
mp-wp_genesis 43
mp-wp_genesis 44 $attach = array();
mp-wp_genesis 45 foreach( (array) $_GET['media'] as $att_id ) {
mp-wp_genesis 46 $att_id = (int) $att_id;
mp-wp_genesis 47
mp-wp_genesis 48 if ( !current_user_can('edit_post', $att_id) )
mp-wp_genesis 49 continue;
mp-wp_genesis 50
mp-wp_genesis 51 $attach[] = $att_id;
mp-wp_genesis 52 }
mp-wp_genesis 53
mp-wp_genesis 54 if ( ! empty($attach) ) {
mp-wp_genesis 55 $attach = implode(',', $attach);
mp-wp_genesis 56 $attached = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ($attach)", $parent_id) );
mp-wp_genesis 57 }
mp-wp_genesis 58
mp-wp_genesis 59 if ( isset($attached) ) {
mp-wp_genesis 60 $location = 'upload.php';
mp-wp_genesis 61 if ( $referer = wp_get_referer() ) {
mp-wp_genesis 62 if ( false !== strpos($referer, 'upload.php') )
mp-wp_genesis 63 $location = $referer;
mp-wp_genesis 64 }
mp-wp_genesis 65
mp-wp_genesis 66 $location = add_query_arg( array( 'detached' => 1, 'attached' => $attached ) , $location );
mp-wp_genesis 67 wp_redirect($location);
mp-wp_genesis 68 exit;
mp-wp_genesis 69 }
mp-wp_genesis 70
mp-wp_genesis 71 } elseif ( isset($_GET['action']) && isset($_GET['media']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
mp-wp_genesis 72 check_admin_referer('bulk-media');
mp-wp_genesis 73 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
mp-wp_genesis 74
mp-wp_genesis 75 if ( 'delete' == $doaction ) {
mp-wp_genesis 76 foreach( (array) $_GET['media'] as $post_id_del ) {
mp-wp_genesis 77 $post_del = & get_post($post_id_del);
mp-wp_genesis 78
mp-wp_genesis 79 if ( !current_user_can('delete_post', $post_id_del) )
mp-wp_genesis 80 wp_die( __('You are not allowed to delete this post.') );
mp-wp_genesis 81
mp-wp_genesis 82 if ( $post_del->post_type == 'attachment' )
mp-wp_genesis 83 if ( ! wp_delete_attachment($post_id_del) )
mp-wp_genesis 84 wp_die( __('Error in deleting...') );
mp-wp_genesis 85 }
mp-wp_genesis 86
mp-wp_genesis 87 $location = 'upload.php';
mp-wp_genesis 88 if ( $referer = wp_get_referer() ) {
mp-wp_genesis 89 if ( false !== strpos($referer, 'upload.php') )
mp-wp_genesis 90 $location = $referer;
mp-wp_genesis 91 }
mp-wp_genesis 92
mp-wp_genesis 93 $location = add_query_arg('message', 2, $location);
mp-wp_genesis 94 $location = remove_query_arg('posted', $location);
mp-wp_genesis 95 wp_redirect($location);
mp-wp_genesis 96 exit;
mp-wp_genesis 97 }
mp-wp_genesis 98 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
mp-wp_genesis 99 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
mp-wp_genesis 100 exit;
mp-wp_genesis 101 }
mp-wp_genesis 102
mp-wp_genesis 103 $title = __('Media Library');
mp-wp_genesis 104 $parent_file = 'upload.php';
mp-wp_genesis 105
mp-wp_genesis 106 if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
mp-wp_genesis 107 $_GET['paged'] = 1;
mp-wp_genesis 108
mp-wp_genesis 109 if ( isset($_GET['detached']) ) {
mp-wp_genesis 110
mp-wp_genesis 111 if ( !empty($lost) ) {
mp-wp_genesis 112 $start = ( $_GET['paged'] - 1 ) * 50;
mp-wp_genesis 113 $page_links_total = ceil(count($lost) / 50);
mp-wp_genesis 114 $lost = implode(',', $lost);
mp-wp_genesis 115
mp-wp_genesis 116 $orphans = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN ($lost) LIMIT $start, 50" );
mp-wp_genesis 117 } else {
mp-wp_genesis 118 $start = ( $_GET['paged'] - 1 ) * 25;
mp-wp_genesis 119 $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent < 1 LIMIT $start, 25" );
mp-wp_genesis 120 $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
mp-wp_genesis 121 }
mp-wp_genesis 122
mp-wp_genesis 123 $post_mime_types = array(
mp-wp_genesis 124 'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image (%s)', 'Images (%s)')),
mp-wp_genesis 125 'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio (%s)', 'Audio (%s)')),
mp-wp_genesis 126 'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video (%s)', 'Video (%s)')),
mp-wp_genesis 127 );
mp-wp_genesis 128 $post_mime_types = apply_filters('post_mime_types', $post_mime_types);
mp-wp_genesis 129
mp-wp_genesis 130 $avail_post_mime_types = get_available_post_mime_types('attachment');
mp-wp_genesis 131
mp-wp_genesis 132 if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )
mp-wp_genesis 133 unset($_GET['post_mime_type']);
mp-wp_genesis 134
mp-wp_genesis 135 } else {
mp-wp_genesis 136 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
mp-wp_genesis 137 }
mp-wp_genesis 138
mp-wp_genesis 139 require_once('admin-header.php'); ?>
mp-wp_genesis 140
mp-wp_genesis 141 <?php
mp-wp_genesis 142 if ( isset($_GET['posted']) && (int) $_GET['posted'] ) {
mp-wp_genesis 143 $_GET['message'] = '1';
mp-wp_genesis 144 $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 145 }
mp-wp_genesis 146
mp-wp_genesis 147 if ( isset($_GET['attached']) && (int) $_GET['attached'] ) {
mp-wp_genesis 148 $attached = (int) $_GET['attached'];
mp-wp_genesis 149 $message = sprintf( __ngettext('Reattached %d attachment', 'Reattached %d attachments', $attached), $attached );
mp-wp_genesis 150 $_SERVER['REQUEST_URI'] = remove_query_arg(array('attached'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 151 }
mp-wp_genesis 152
mp-wp_genesis 153 $messages[1] = __('Media attachment updated.');
mp-wp_genesis 154 $messages[2] = __('Media deleted.');
mp-wp_genesis 155 $messages[3] = __('Error saving media attachment.');
mp-wp_genesis 156
mp-wp_genesis 157 if ( isset($_GET['message']) && (int) $_GET['message'] ) {
mp-wp_genesis 158 $message = $messages[$_GET['message']];
mp-wp_genesis 159 $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 160 }
mp-wp_genesis 161 ?>
mp-wp_genesis 162
mp-wp_genesis 163 <?php do_action('restrict_manage_posts'); ?>
mp-wp_genesis 164
mp-wp_genesis 165 <div class="wrap">
mp-wp_genesis 166 <?php screen_icon(); ?>
mp-wp_genesis 167 <h2><?php echo wp_specialchars( $title );
mp-wp_genesis 168 if ( isset($_GET['s']) && $_GET['s'] )
mp-wp_genesis 169 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( get_search_query() ) ); ?>
mp-wp_genesis 170 </h2>
mp-wp_genesis 171
mp-wp_genesis 172 <?php
mp-wp_genesis 173 if ( isset($message) ) { ?>
mp-wp_genesis 174 <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
mp-wp_genesis 175 <?php
mp-wp_genesis 176 }
mp-wp_genesis 177 ?>
mp-wp_genesis 178
mp-wp_genesis 179 <ul class="subsubsub">
mp-wp_genesis 180 <?php
mp-wp_genesis 181 $type_links = array();
mp-wp_genesis 182 $_num_posts = (array) wp_count_attachments();
mp-wp_genesis 183 $_total_posts = array_sum( $_num_posts );
mp-wp_genesis 184 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
mp-wp_genesis 185 foreach ( $matches as $type => $reals )
mp-wp_genesis 186 foreach ( $reals as $real )
mp-wp_genesis 187 $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
mp-wp_genesis 188
mp-wp_genesis 189 $class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';
mp-wp_genesis 190 $type_links[] = "<li><a href='upload.php'$class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts ), number_format_i18n( $_total_posts ) ) . '</a>';
mp-wp_genesis 191 foreach ( $post_mime_types as $mime_type => $label ) {
mp-wp_genesis 192 $class = '';
mp-wp_genesis 193
mp-wp_genesis 194 if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
mp-wp_genesis 195 continue;
mp-wp_genesis 196
mp-wp_genesis 197 if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
mp-wp_genesis 198 $class = ' class="current"';
mp-wp_genesis 199
mp-wp_genesis 200 $type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( __ngettext( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
mp-wp_genesis 201 }
mp-wp_genesis 202 $class = isset($_GET['detached']) ? ' class="current"' : '';
mp-wp_genesis 203 $type_links[] = '<li><a href="upload.php?detached=1"' . $class . '>' . __('Unattached') . '</a>';
mp-wp_genesis 204
mp-wp_genesis 205 echo implode( " |</li>\n", $type_links) . '</li>';
mp-wp_genesis 206 unset($type_links);
mp-wp_genesis 207 ?>
mp-wp_genesis 208 </ul>
mp-wp_genesis 209
mp-wp_genesis 210 <form class="search-form" action="" method="get">
mp-wp_genesis 211 <p class="search-box">
mp-wp_genesis 212 <label class="hidden" for="media-search-input"><?php _e( 'Search Media' ); ?>:</label>
mp-wp_genesis 213 <input type="text" class="search-input" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
mp-wp_genesis 214 <input type="submit" value="<?php _e( 'Search Media' ); ?>" class="button" />
mp-wp_genesis 215 </p>
mp-wp_genesis 216 </form>
mp-wp_genesis 217
mp-wp_genesis 218 <form id="posts-filter" action="" method="get">
mp-wp_genesis 219 <div class="tablenav">
mp-wp_genesis 220 <?php
mp-wp_genesis 221 if ( ! isset($page_links_total) )
mp-wp_genesis 222 $page_links_total = $wp_query->max_num_pages;
mp-wp_genesis 223
mp-wp_genesis 224 $page_links = paginate_links( array(
mp-wp_genesis 225 'base' => add_query_arg( 'paged', '%#%' ),
mp-wp_genesis 226 'format' => '',
mp-wp_genesis 227 'prev_text' => __('«'),
mp-wp_genesis 228 'next_text' => __('»'),
mp-wp_genesis 229 'total' => $page_links_total,
mp-wp_genesis 230 'current' => $_GET['paged']
mp-wp_genesis 231 ));
mp-wp_genesis 232
mp-wp_genesis 233 if ( $page_links ) : ?>
mp-wp_genesis 234 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
mp-wp_genesis 235 number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
mp-wp_genesis 236 number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
mp-wp_genesis 237 number_format_i18n( $wp_query->found_posts ),
mp-wp_genesis 238 $page_links
mp-wp_genesis 239 ); echo $page_links_text; ?></div>
mp-wp_genesis 240 <?php endif; ?>
mp-wp_genesis 241
mp-wp_genesis 242 <div class="alignleft actions">
mp-wp_genesis 243 <select name="action" class="select-action">
mp-wp_genesis 244 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 245 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 246 <?php if ( isset($orphans) ) { ?>
mp-wp_genesis 247 <option value="attach"><?php _e('Attach to a post'); ?></option>
mp-wp_genesis 248 <?php } ?>
mp-wp_genesis 249 </select>
mp-wp_genesis 250 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
mp-wp_genesis 251 <?php wp_nonce_field('bulk-media'); ?>
mp-wp_genesis 252
mp-wp_genesis 253 <?php
mp-wp_genesis 254 if ( ! is_singular() && ! isset($_GET['detached']) ) {
mp-wp_genesis 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";
mp-wp_genesis 256
mp-wp_genesis 257 $arc_result = $wpdb->get_results( $arc_query );
mp-wp_genesis 258
mp-wp_genesis 259 $month_count = count($arc_result);
mp-wp_genesis 260
mp-wp_genesis 261 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?>
mp-wp_genesis 262 <select name='m'>
mp-wp_genesis 263 <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
mp-wp_genesis 264 <?php
mp-wp_genesis 265 foreach ($arc_result as $arc_row) {
mp-wp_genesis 266 if ( $arc_row->yyear == 0 )
mp-wp_genesis 267 continue;
mp-wp_genesis 268 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
mp-wp_genesis 269
mp-wp_genesis 270 if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
mp-wp_genesis 271 $default = ' selected="selected"';
mp-wp_genesis 272 else
mp-wp_genesis 273 $default = '';
mp-wp_genesis 274
mp-wp_genesis 275 echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>";
mp-wp_genesis 276 echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
mp-wp_genesis 277 echo "</option>\n";
mp-wp_genesis 278 }
mp-wp_genesis 279 ?>
mp-wp_genesis 280 </select>
mp-wp_genesis 281 <?php endif; // month_count ?>
mp-wp_genesis 282
mp-wp_genesis 283 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
mp-wp_genesis 284
mp-wp_genesis 285 <?php } // ! is_singular ?>
mp-wp_genesis 286
mp-wp_genesis 287 <?php if ( isset($_GET['detached']) ) { ?>
mp-wp_genesis 288 <input type="submit" id="find_detached" name="find_detached" value="<?php _e('Scan for lost attachments'); ?>" class="button-secondary" />
mp-wp_genesis 289 <?php } ?>
mp-wp_genesis 290
mp-wp_genesis 291 </div>
mp-wp_genesis 292
mp-wp_genesis 293 <br class="clear" />
mp-wp_genesis 294 </div>
mp-wp_genesis 295
mp-wp_genesis 296 <div class="clear"></div>
mp-wp_genesis 297
mp-wp_genesis 298 <?php if ( isset($orphans) ) { ?>
mp-wp_genesis 299 <table class="widefat" cellspacing="0">
mp-wp_genesis 300 <thead>
mp-wp_genesis 301 <tr>
mp-wp_genesis 302 <th scope="col" class="check-column"><input type="checkbox" /></th>
mp-wp_genesis 303 <th scope="col"></th>
mp-wp_genesis 304 <th scope="col"><?php echo _c('Media|media column header'); ?></th>
mp-wp_genesis 305 <th scope="col"><?php echo _c('Date Added|media column header'); ?></th>
mp-wp_genesis 306 </tr>
mp-wp_genesis 307 </thead>
mp-wp_genesis 308
mp-wp_genesis 309 <tfoot>
mp-wp_genesis 310 <tr>
mp-wp_genesis 311 <th scope="col" class="check-column"><input type="checkbox" /></th>
mp-wp_genesis 312 <th scope="col"></th>
mp-wp_genesis 313 <th scope="col"><?php echo _c('Media|media column header'); ?></th>
mp-wp_genesis 314 <th scope="col"><?php echo _c('Date Added|media column header'); ?></th>
mp-wp_genesis 315 </tr>
mp-wp_genesis 316 </tfoot>
mp-wp_genesis 317
mp-wp_genesis 318 <tbody id="the-list" class="list:post">
mp-wp_genesis 319 <?php
mp-wp_genesis 320 if ( $orphans ) {
mp-wp_genesis 321 foreach ( $orphans as $post ) {
mp-wp_genesis 322 $class = 'alternate' == $class ? '' : 'alternate';
mp-wp_genesis 323 $att_title = wp_specialchars( _draft_or_post_title($post->ID) );
mp-wp_genesis 324 ?>
mp-wp_genesis 325 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top">
mp-wp_genesis 326 <th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php echo $post->ID; ?>" /></th>
mp-wp_genesis 327
mp-wp_genesis 328 <td class="media-icon"><?php
mp-wp_genesis 329 if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { ?>
mp-wp_genesis 330 <a href="media.php?action=edit&attachment_id=<?php echo $post->ID; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $thumb; ?></a>
mp-wp_genesis 331 <?php } ?></td>
mp-wp_genesis 332
mp-wp_genesis 333 <td><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
mp-wp_genesis 334 <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
mp-wp_genesis 335
mp-wp_genesis 336 <p>
mp-wp_genesis 337 <?php
mp-wp_genesis 338 $actions = array();
mp-wp_genesis 339 if ( current_user_can('edit_post', $post->ID) )
mp-wp_genesis 340 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
mp-wp_genesis 341 if ( current_user_can('delete_post', $post->ID) )
mp-wp_genesis 342 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(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>";
mp-wp_genesis 343 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
mp-wp_genesis 344 if ( current_user_can('edit_post', $post->ID) )
mp-wp_genesis 345 $actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;">'.__('Attach').'</a>';
mp-wp_genesis 346 $action_count = count($actions);
mp-wp_genesis 347 $i = 0;
mp-wp_genesis 348 foreach ( $actions as $action => $link ) {
mp-wp_genesis 349 ++$i;
mp-wp_genesis 350 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 351 echo "<span class='$action'>$link$sep</span>";
mp-wp_genesis 352 } ?>
mp-wp_genesis 353 </p></td>
mp-wp_genesis 354
mp-wp_genesis 355 <?php if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
mp-wp_genesis 356 $t_time = $h_time = __('Unpublished');
mp-wp_genesis 357 } else {
mp-wp_genesis 358 $t_time = get_the_time(__('Y/m/d g:i:s A'));
mp-wp_genesis 359 $m_time = $post->post_date;
mp-wp_genesis 360 $time = get_post_time( 'G', true );
mp-wp_genesis 361 if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
mp-wp_genesis 362 if ( $t_diff < 0 )
mp-wp_genesis 363 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
mp-wp_genesis 364 else
mp-wp_genesis 365 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
mp-wp_genesis 366 } else {
mp-wp_genesis 367 $h_time = mysql2date(__('Y/m/d'), $m_time);
mp-wp_genesis 368 }
mp-wp_genesis 369 } ?>
mp-wp_genesis 370 <td><?php echo $h_time ?></td>
mp-wp_genesis 371 </tr>
mp-wp_genesis 372 <?php }
mp-wp_genesis 373
mp-wp_genesis 374 } else { ?>
mp-wp_genesis 375 <tr><td colspan="5"><?php _e('No posts found.') ?></td></tr>
mp-wp_genesis 376 <?php } ?>
mp-wp_genesis 377 </tbody>
mp-wp_genesis 378 </table>
mp-wp_genesis 379
mp-wp_genesis 380 <?php find_posts_div();
mp-wp_genesis 381
mp-wp_genesis 382 } else {
mp-wp_genesis 383 include( 'edit-attachment-rows.php' );
mp-wp_genesis 384 } ?>
mp-wp_genesis 385
mp-wp_genesis 386 <div id="ajax-response"></div>
mp-wp_genesis 387
mp-wp_genesis 388 <div class="tablenav">
mp-wp_genesis 389
mp-wp_genesis 390 <?php
mp-wp_genesis 391 if ( $page_links )
mp-wp_genesis 392 echo "<div class='tablenav-pages'>$page_links_text</div>";
mp-wp_genesis 393 ?>
mp-wp_genesis 394
mp-wp_genesis 395 <div class="alignleft actions">
mp-wp_genesis 396 <select name="action2" class="select-action">
mp-wp_genesis 397 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 398 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 399 <?php if ( isset($orphans) ) { ?>
mp-wp_genesis 400 <option value="attach"><?php _e('Attach to a post'); ?></option>
mp-wp_genesis 401 <?php } ?>
mp-wp_genesis 402 </select>
mp-wp_genesis 403 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
mp-wp_genesis 404 </div>
mp-wp_genesis 405
mp-wp_genesis 406 <br class="clear" />
mp-wp_genesis 407 </div>
mp-wp_genesis 408 </form>
mp-wp_genesis 409 <br class="clear" />
mp-wp_genesis 410
mp-wp_genesis 411 </div>
mp-wp_genesis 412
mp-wp_genesis 413 <script type="text/javascript">
mp-wp_genesis 414 /* <![CDATA[ */
mp-wp_genesis 415 (function($){
mp-wp_genesis 416 $(document).ready(function(){
mp-wp_genesis 417 $('#doaction, #doaction2').click(function(e){
mp-wp_genesis 418 if ( $('select[name^="action"]').val() == 'delete' ) {
mp-wp_genesis 419 var m = '<?php echo js_escape(__("You are about to delete the selected attachments.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
mp-wp_genesis 420 return showNotice.warn(m);
mp-wp_genesis 421 } else if ( $('select[name^="action"]').val() == 'attach' ) {
mp-wp_genesis 422 e.preventDefault();
mp-wp_genesis 423 findPosts.open();
mp-wp_genesis 424 }
mp-wp_genesis 425 });
mp-wp_genesis 426 });
mp-wp_genesis 427 })(jQuery);
mp-wp_genesis 428 columns.init('upload');
mp-wp_genesis 429 /* ]]> */
mp-wp_genesis 430 </script>
mp-wp_genesis 431
mp-wp_genesis 432 <?php
mp-wp_genesis 433
mp-wp_genesis 434 include('admin-footer.php');
mp-wp_genesis 435 ?>