X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9cd344f9b14dd8e0743c1417fdb379b1431c3988..2376fb745f4ae8c6bd2353127524e0b28005143d:/wp-admin/upload.php diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 8ddb013f..355d4632 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -7,7 +7,7 @@ */ /** WordPress Administration Bootstrap */ -require_once('admin.php'); +require_once('./admin.php'); wp_enqueue_script( 'wp-ajax-response' ); wp_enqueue_script( 'jquery-ui-draggable' ); @@ -20,14 +20,8 @@ if ( isset($_GET['find_detached']) ) { if ( !current_user_can('edit_posts') ) wp_die( __('You are not allowed to scan for lost attachments.') ); - $all_posts = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'post' OR post_type = 'page'"); - $all_att = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'attachment'"); + $lost = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent > '0' and post_parent NOT IN ( SELECT ID FROM $wpdb->posts WHERE post_type NOT IN ('attachment', '" . join("', '", get_post_types( array( 'public' => false ) ) ) . "') )"); - $lost = array(); - foreach ( (array) $all_att as $att ) { - if ( $att->post_parent > 0 && ! in_array($att->post_parent, $all_posts) ) - $lost[] = $att->ID; - } $_GET['detached'] = 1; } elseif ( isset($_GET['found_post_id']) && isset($_GET['media']) ) { @@ -48,6 +42,7 @@ if ( isset($_GET['find_detached']) ) { continue; $attach[] = $att_id; + clean_attachment_cache($att_id); } if ( ! empty($attach) ) { @@ -95,7 +90,7 @@ if ( isset($_GET['find_detached']) ) { if ( !wp_trash_post($post_id) ) wp_die( __('Error in moving to trash...') ); } - $location = add_query_arg( array( 'message' => 4, 'ids' => join(',', $post_ids) ), $location ); + $location = add_query_arg( array( 'trashed' => count($post_ids), 'ids' => join(',', $post_ids) ), $location ); break; case 'untrash': foreach( (array) $post_ids as $post_id ) { @@ -105,7 +100,7 @@ if ( isset($_GET['find_detached']) ) { if ( !wp_untrash_post($post_id) ) wp_die( __('Error in restoring from trash...') ); } - $location = add_query_arg('message', 5, $location); + $location = add_query_arg('untrashed', count($post_ids), $location); break; case 'delete': foreach( (array) $post_ids as $post_id_del ) { @@ -115,13 +110,13 @@ if ( isset($_GET['find_detached']) ) { if ( !wp_delete_attachment($post_id_del) ) wp_die( __('Error in deleting...') ); } - $location = add_query_arg('message', 2, $location); + $location = add_query_arg('deleted', count($post_ids), $location); break; } wp_redirect($location); exit; -} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { +} elseif ( ! empty($_GET['_wp_http_referer']) ) { wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); exit; } @@ -134,7 +129,7 @@ if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 ) if ( isset($_GET['detached']) ) { - $media_per_page = (int) get_user_option( 'upload_per_page', 0, false ); + $media_per_page = (int) get_user_option( 'upload_per_page' ); if ( empty($media_per_page) || $media_per_page < 1 ) $media_per_page = 20; $media_per_page = apply_filters( 'upload_per_page', $media_per_page ); @@ -148,7 +143,10 @@ if ( isset($_GET['detached']) ) { } else { $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page; $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 ) ); - $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / $media_per_page); + $total_orphans = $wpdb->get_var( "SELECT FOUND_ROWS()" ); + $page_links_total = ceil( $total_orphans / $media_per_page ); + $wp_query->found_posts = $total_orphans; + $wp_query->query_vars['posts_per_page'] = $media_per_page; } $post_mime_types = get_post_mime_types(); @@ -164,43 +162,53 @@ if ( isset($_GET['detached']) ) { $is_trash = ( isset($_GET['status']) && $_GET['status'] == 'trash' ); wp_enqueue_script('media'); -require_once('admin-header.php'); -do_action('restrict_manage_posts'); +add_contextual_help( $current_screen, + '

' . __('All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the Screen Options tab to customize the display of this screen.') . '

' . + '

' . __('You can narrow the list by file type/status using the text link filters at the top of the screen. You also can refine the list by date using the dropdown menu above the media table.') . '

' . + '

' . __('Hovering over a row reveals action links: Edit, Delete Permanently, and View. Clicking Edit or on the media file’s name displays a simple screen to edit that individual file’s metadata. Clicking Delete Permanently will delete the file from the media library (as well as from any posts to which it is currently attached). View will take you to the display page for that file.') . '

' . + '

' . __('If a media file has not been attached to any post, you will see that in the Attached To column, and can click on Attach File to launch a small popup that will allow you to search for a post and attach the file.') . '

' . + '

' . __('For more information:') . '

' . + '

' . __('Media Library Documentation') . '

' . + '

' . __('Support Forums') . '

' +); + +require_once('./admin-header.php'); ?>

' . __('Search results for “%s”') . '', esc_html( get_search_query() ) ); ?> + printf( '' . __('Search results for “%s”') . '', get_search_query() ); ?>

' . __('Undo') . ''; $_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']); } if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { - $_GET['message'] = '5'; + $message = sprintf( _n( 'Media attachment restored from the trash.', '%d media attachments restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); $_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']); } @@ -216,7 +224,7 @@ if ( isset($_GET['message']) && (int) $_GET['message'] ) { } if ( !empty($message) ) { ?> -

+

@@ -480,4 +504,4 @@ if ( $page_links )