X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..38ac4bc40322ecdc4052db4263466573e01fa51f:/wp-admin/upload.php diff --git a/wp-admin/upload.php b/wp-admin/upload.php index cf6c1916..39fa165f 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -1,250 +1,294 @@ post_type == 'attachment' ) - if ( ! wp_delete_attachment($post_id_del) ) - wp_die( __('Error in deleting...') ); - } +if ( isset( $_GET['mode'] ) && in_array( $_GET['mode'], $modes ) ) { + $mode = $_GET['mode']; + update_user_option( get_current_user_id(), 'media_library_mode', $mode ); +} - $location = 'upload.php'; - if ( $referer = wp_get_referer() ) { - if ( false !== strpos($referer, 'upload.php') ) - $location = $referer; +if ( 'grid' === $mode ) { + wp_enqueue_media(); + wp_enqueue_script( 'media-grid' ); + wp_enqueue_script( 'media' ); + + $q = $_GET; + // let JS handle this + unset( $q['s'] ); + $vars = wp_edit_attachments_query_vars( $q ); + $ignore = array( 'mode', 'post_type', 'post_status', 'posts_per_page' ); + foreach ( $vars as $key => $value ) { + if ( ! $value || in_array( $key, $ignore ) ) { + unset( $vars[ $key ] ); + } } - $location = add_query_arg('message', 2, $location); - $location = remove_query_arg('posted', $location); - wp_redirect($location); - exit; -} elseif ( !empty($_GET['_wp_http_referer']) ) { - wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); + wp_localize_script( 'media-grid', '_wpMediaGridSettings', array( + 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ), + 'queryVars' => (object) $vars + ) ); + + get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __( 'Overview' ), + 'content' => + '

' . __( 'All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first.' ) . '

' . + '

' . __( 'You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.' ) . '

' . + '

' . __( 'To delete media items, click the Bulk Select button at the top of the screen. Select any items you wish to delete, then click the Delete Selected button. Clicking the Cancel Selection button takes you back to viewing your media.' ) . '

' + ) ); + + get_current_screen()->add_help_tab( array( + 'id' => 'attachment-details', + 'title' => __( 'Attachment Details' ), + 'content' => + '

' . __( 'Clicking an item will display an Attachment Details dialog, which allows you to preview media and make quick edits. Any changes you make to the attachment details will be automatically saved.' ) . '

' . + '

' . __( 'Use the arrow buttons at the top of the dialog, or the left and right arrow keys on your keyboard, to navigate between media items quickly.' ) . '

' . + '

' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '

' + ) ); + + get_current_screen()->set_help_sidebar( + '

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

' . + '

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

' . + '

' . __( 'Support Forums' ) . '

' + ); + + $title = __('Media Library'); + $parent_file = 'upload.php'; + + require_once( ABSPATH . 'wp-admin/admin-header.php' ); + ?> +
+

+ + +

+
+

Switch to the list view.' ); ?>

+
+
+ get_pagenum(); -if ( is_singular() ) - wp_enqueue_script( 'admin-comments' ); +// Handle bulk actions +$doaction = $wp_list_table->current_action(); -require_once('admin-header.php'); - -if ( !isset( $_GET['paged'] ) ) - $_GET['paged'] = 1; +if ( $doaction ) { + check_admin_referer('bulk-media'); -?> + if ( 'delete_all' == $doaction ) { + $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" ); + $doaction = 'delete'; + } elseif ( isset( $_REQUEST['media'] ) ) { + $post_ids = $_REQUEST['media']; + } elseif ( isset( $_REQUEST['ids'] ) ) { + $post_ids = explode( ',', $_REQUEST['ids'] ); + } -
+ $location = 'upload.php'; + if ( $referer = wp_get_referer() ) { + if ( false !== strpos( $referer, 'upload.php' ) ) + $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); + } -
-

post_title)); -} else { - $post_mime_type_label = _c('Manage Media|manage media header'); - if ( isset($_GET['post_mime_type']) && in_array( $_GET['post_mime_type'], array_keys($post_mime_types) ) ) - $post_mime_type_label = $post_mime_types[$_GET['post_mime_type']][1]; - if ( $post_listing_pageable && !is_archive() && !is_search() ) - $h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_mime_type_label) : sprintf(__('Latest %s'), $post_mime_type_label); - else - $h2_noun = $post_mime_type_label; - // Use $_GET instead of is_ since they can override each other - $h2_author = ''; - $_GET['author'] = (int) $_GET['author']; - if ( $_GET['author'] != 0 ) { - if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion - $h2_author = ' ' . __('by other authors'); - } else { - $author_user = get_userdata( get_query_var( 'author' ) ); - $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); - } + switch ( $doaction ) { + case 'detach': + wp_media_attach_action( $_REQUEST['parent_post_id'], 'detach' ); + break; + + case 'attach': + wp_media_attach_action( $_REQUEST['found_post_id'] ); + break; + + case 'trash': + if ( !isset( $post_ids ) ) + break; + foreach ( (array) $post_ids as $post_id ) { + if ( !current_user_can( 'delete_post', $post_id ) ) + wp_die( __( 'You are not allowed to move this post to the trash.' ) ); + + if ( !wp_trash_post( $post_id ) ) + wp_die( __( 'Error in moving to trash.' ) ); + } + $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); + break; + case 'untrash': + if ( !isset( $post_ids ) ) + break; + foreach ( (array) $post_ids as $post_id ) { + if ( !current_user_can( 'delete_post', $post_id ) ) + wp_die( __( 'You are not allowed to move this post out of the trash.' ) ); + + if ( !wp_untrash_post( $post_id ) ) + wp_die( __( 'Error in restoring from trash.' ) ); + } + $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); + break; + case 'delete': + if ( !isset( $post_ids ) ) + break; + foreach ( (array) $post_ids as $post_id_del ) { + if ( !current_user_can( 'delete_post', $post_id_del ) ) + wp_die( __( 'You are not allowed to delete this post.' ) ); + + if ( !wp_delete_attachment( $post_id_del ) ) + wp_die( __( 'Error in deleting.' ) ); + } + $location = add_query_arg( 'deleted', count( $post_ids ), $location ); + break; } - $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : ''; - $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : ''; - $h2_tag = isset($_GET['tag']) && $_GET['tag'] ? ' ' . sprintf( __('tagged with “%s”'), single_tag_title('', false) ) : ''; - $h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : ''; - printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month ); -} -?>

- - - -

|

- -

- -

- - - -

+$wp_list_table->prepare_items(); - - -
+$title = __('Media Library'); +$parent_file = 'upload.php'; + +wp_enqueue_script( 'media' ); + +add_screen_option( 'per_page' ); + +get_current_screen()->add_help_tab( array( +'id' => 'overview', +'title' => __('Overview'), +'content' => + '

' . __( '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.' ) . '

' . + '

' . __( 'You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.' ) . '

' +) ); +get_current_screen()->add_help_tab( array( +'id' => 'actions-links', +'title' => __('Available Actions'), +'content' => + '

' . __( '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.' ) . '

' +) ); +get_current_screen()->add_help_tab( array( +'id' => 'attaching-files', +'title' => __('Attaching Files'), +'content' => + '

' . __( '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.' ) . '

' +) ); + +get_current_screen()->set_help_sidebar( + '

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

' . + '

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

' . + '

' . __( 'Support Forums' ) . '

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

add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'total' => $wp_query->max_num_pages, - 'current' => $_GET['paged'] -)); - -if ( $page_links ) - echo "
$page_links
"; -?> +echo esc_html( $title ); +if ( current_user_can( 'upload_files' ) ) { ?> + ' . __('Search results for “%s”') . '', get_search_query() ); ?> +

-
- - posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; +if ( ! empty( $_GET['attached'] ) && $attached = absint( $_GET['attached'] ) ) { + $message = sprintf( _n( 'Reattached %d attachment.', 'Reattached %d attachments.', $attached ), $attached ); + $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); +} - $arc_result = $wpdb->get_results( $arc_query ); +if ( ! empty( $_GET['detach'] ) && $detached = absint( $_GET['detach'] ) ) { + $message = sprintf( _n( 'Detached %d attachment.', 'Detached %d attachments.', $detached ), $detached ); + $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); +} - $month_count = count($arc_result); +if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) { + if ( 1 == $deleted ) { + $message = __( 'Media attachment permanently deleted.' ); + } else { + $message = _n( '%d media attachment permanently deleted.', '%d media attachments permanently deleted.', $deleted ); + } + $message = sprintf( $message, number_format_i18n( $deleted ) ); + $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']); +} - if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?> - - - +if ( ! empty( $_GET['untrashed'] ) && $untrashed = absint( $_GET['untrashed'] ) ) { + if ( 1 == $untrashed ) { + $message = __( 'Media attachment restored from the trash.' ); + } else { + $message = _n( '%d media attachment restored from the trash.', '%d media attachments restored from the trash.', $untrashed ); + } + $message = sprintf( $message, number_format_i18n( $untrashed ) ); + $_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']); +} - +$messages[1] = __('Media attachment updated.'); +$messages[2] = __('Media permanently deleted.'); +$messages[3] = __('Error saving media attachment.'); +$messages[4] = __('Media moved to the trash.') . ' ' . __('Undo') . ''; +$messages[5] = __('Media restored from the trash.'); -
+if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) { + $message = $messages[ $_GET['message'] ]; + $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); +} -
-
+if ( !empty($message) ) { ?> +

+ -
+ - +views(); ?> - +display(); ?>
- -
- -$page_links
"; -?> - + +
-
- -get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) ); - if ( $comments ) : - // Make sure comments, post, and post_author are cached - update_comment_cache($comments); - $post = get_post($id); - $authordata = get_userdata($post->post_author); - ?> - -
- - - - - - - - - - -comment_ID, 'detail', false, false ); -?> - -
- - -
- - +include( ABSPATH . 'wp-admin/admin-footer.php' );