Changeset 42343 for trunk/src/wp-admin/upload.php
- Timestamp:
- 11/30/2017 11:09:33 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/upload.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/upload.php
r42228 r42343 10 10 require_once( dirname( __FILE__ ) . '/admin.php' ); 11 11 12 if ( ! current_user_can('upload_files') )12 if ( ! current_user_can( 'upload_files' ) ) { 13 13 wp_die( __( 'Sorry, you are not allowed to upload files.' ) ); 14 15 $mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid'; 14 } 15 16 $mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid'; 16 17 $modes = array( 'grid', 'list' ); 17 18 … … 31 32 // let JS handle this 32 33 unset( $q['s'] ); 33 $vars = wp_edit_attachments_query_vars( $q );34 $vars = wp_edit_attachments_query_vars( $q ); 34 35 $ignore = array( 'mode', 'post_type', 'post_status', 'posts_per_page' ); 35 36 foreach ( $vars as $key => $value ) { … … 39 40 } 40 41 41 wp_localize_script( 'media-grid', '_wpMediaGridSettings', array( 42 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ), 43 'queryVars' => (object) $vars 44 ) ); 45 46 get_current_screen()->add_help_tab( array( 47 'id' => 'overview', 48 'title' => __( 'Overview' ), 49 'content' => 50 '<p>' . __( 'All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first.' ) . '</p>' . 51 '<p>' . __( '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.' ) . '</p>' . 52 '<p>' . __( '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.' ) . '</p>' 53 ) ); 54 55 get_current_screen()->add_help_tab( array( 56 'id' => 'attachment-details', 57 'title' => __( 'Attachment Details' ), 58 'content' => 59 '<p>' . __( '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.' ) . '</p>' . 60 '<p>' . __( '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.' ) . '</p>' . 61 '<p>' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '</p>' 62 ) ); 42 wp_localize_script( 43 'media-grid', '_wpMediaGridSettings', array( 44 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ), 45 'queryVars' => (object) $vars, 46 ) 47 ); 48 49 get_current_screen()->add_help_tab( 50 array( 51 'id' => 'overview', 52 'title' => __( 'Overview' ), 53 'content' => 54 '<p>' . __( 'All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first.' ) . '</p>' . 55 '<p>' . __( '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.' ) . '</p>' . 56 '<p>' . __( '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.' ) . '</p>', 57 ) 58 ); 59 60 get_current_screen()->add_help_tab( 61 array( 62 'id' => 'attachment-details', 63 'title' => __( 'Attachment Details' ), 64 'content' => 65 '<p>' . __( '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.' ) . '</p>' . 66 '<p>' . __( '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.' ) . '</p>' . 67 '<p>' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '</p>', 68 ) 69 ); 63 70 64 71 get_current_screen()->set_help_sidebar( … … 68 75 ); 69 76 70 $title = __('Media Library');77 $title = __( 'Media Library' ); 71 78 $parent_file = 'upload.php'; 72 79 73 80 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 74 81 ?> 75 <div class="wrap" id="wp-media-grid" data-search="<?php _admin_search_query() ?>">82 <div class="wrap" id="wp-media-grid" data-search="<?php _admin_search_query(); ?>"> 76 83 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> 77 84 78 85 <?php 79 if ( current_user_can( 'upload_files' ) ) { ?> 80 <a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action aria-button-if-js"><?php echo esc_html_x( 'Add New', 'file' ); ?></a><?php 86 if ( current_user_can( 'upload_files' ) ) { 87 ?> 88 <a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action aria-button-if-js"><?php echo esc_html_x( 'Add New', 'file' ); ?></a> 89 <?php 81 90 } 82 91 ?> … … 85 94 86 95 <div class="error hide-if-js"> 87 <p><?php printf( 96 <p> 97 <?php 98 printf( 88 99 /* translators: %s: list view URL */ 89 100 __( 'The grid view for the Media Library requires JavaScript. <a href="%s">Switch to the list view</a>.' ), 90 101 'upload.php?mode=list' 91 ); ?></p> 102 ); 103 ?> 104 </p> 92 105 </div> 93 106 </div> … … 97 110 } 98 111 99 $wp_list_table = _get_list_table( 'WP_Media_List_Table');100 $pagenum = $wp_list_table->get_pagenum();112 $wp_list_table = _get_list_table( 'WP_Media_List_Table' ); 113 $pagenum = $wp_list_table->get_pagenum(); 101 114 102 115 // Handle bulk actions … … 104 117 105 118 if ( $doaction ) { 106 check_admin_referer( 'bulk-media');119 check_admin_referer( 'bulk-media' ); 107 120 108 121 if ( 'delete_all' == $doaction ) { … … 117 130 $location = 'upload.php'; 118 131 if ( $referer = wp_get_referer() ) { 119 if ( false !== strpos( $referer, 'upload.php' ) ) 132 if ( false !== strpos( $referer, 'upload.php' ) ) { 120 133 $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); 134 } 121 135 } 122 136 … … 131 145 132 146 case 'trash': 133 if ( ! isset( $post_ids ) )147 if ( ! isset( $post_ids ) ) { 134 148 break; 149 } 135 150 foreach ( (array) $post_ids as $post_id ) { 136 if ( ! current_user_can( 'delete_post', $post_id ) )151 if ( ! current_user_can( 'delete_post', $post_id ) ) { 137 152 wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); 138 139 if ( !wp_trash_post( $post_id ) ) 153 } 154 155 if ( ! wp_trash_post( $post_id ) ) { 140 156 wp_die( __( 'Error in moving to Trash.' ) ); 141 } 142 $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); 157 } 158 } 159 $location = add_query_arg( 160 array( 161 'trashed' => count( $post_ids ), 162 'ids' => join( ',', $post_ids ), 163 ), $location 164 ); 143 165 break; 144 166 case 'untrash': 145 if ( ! isset( $post_ids ) )167 if ( ! isset( $post_ids ) ) { 146 168 break; 169 } 147 170 foreach ( (array) $post_ids as $post_id ) { 148 if ( ! current_user_can( 'delete_post', $post_id ) )171 if ( ! current_user_can( 'delete_post', $post_id ) ) { 149 172 wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); 150 151 if ( !wp_untrash_post( $post_id ) ) 173 } 174 175 if ( ! wp_untrash_post( $post_id ) ) { 152 176 wp_die( __( 'Error in restoring from Trash.' ) ); 177 } 153 178 } 154 179 $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); 155 180 break; 156 181 case 'delete': 157 if ( ! isset( $post_ids ) )182 if ( ! isset( $post_ids ) ) { 158 183 break; 184 } 159 185 foreach ( (array) $post_ids as $post_id_del ) { 160 if ( ! current_user_can( 'delete_post', $post_id_del ) )186 if ( ! current_user_can( 'delete_post', $post_id_del ) ) { 161 187 wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); 162 163 if ( !wp_delete_attachment( $post_id_del ) ) 188 } 189 190 if ( ! wp_delete_attachment( $post_id_del ) ) { 164 191 wp_die( __( 'Error in deleting.' ) ); 192 } 165 193 } 166 194 $location = add_query_arg( 'deleted', count( $post_ids ), $location ); … … 180 208 $wp_list_table->prepare_items(); 181 209 182 $title = __('Media Library');210 $title = __( 'Media Library' ); 183 211 $parent_file = 'upload.php'; 184 212 … … 187 215 add_screen_option( 'per_page' ); 188 216 189 get_current_screen()->add_help_tab( array( 190 'id' => 'overview', 191 'title' => __('Overview'), 192 'content' => 193 '<p>' . __( '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.' ) . '</p>' . 194 '<p>' . __( 'You can narrow the list by file type/status or by date using the dropdown menus above the media table.' ) . '</p>' . 195 '<p>' . __( '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.' ) . '</p>' 196 ) ); 197 get_current_screen()->add_help_tab( array( 198 'id' => 'actions-links', 199 'title' => __('Available Actions'), 200 'content' => 201 '<p>' . __( '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.' ) . '</p>' 202 ) ); 203 get_current_screen()->add_help_tab( array( 204 'id' => 'attaching-files', 205 'title' => __('Attaching Files'), 206 'content' => 207 '<p>' . __( 'If a media file has not been attached to any content, you will see that in the Uploaded To column, and can click on Attach to launch a small popup that will allow you to search for existing content and attach the file.' ) . '</p>' 208 ) ); 217 get_current_screen()->add_help_tab( 218 array( 219 'id' => 'overview', 220 'title' => __( 'Overview' ), 221 'content' => 222 '<p>' . __( '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.' ) . '</p>' . 223 '<p>' . __( 'You can narrow the list by file type/status or by date using the dropdown menus above the media table.' ) . '</p>' . 224 '<p>' . __( '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.' ) . '</p>', 225 ) 226 ); 227 get_current_screen()->add_help_tab( 228 array( 229 'id' => 'actions-links', 230 'title' => __( 'Available Actions' ), 231 'content' => 232 '<p>' . __( '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.' ) . '</p>', 233 ) 234 ); 235 get_current_screen()->add_help_tab( 236 array( 237 'id' => 'attaching-files', 238 'title' => __( 'Attaching Files' ), 239 'content' => 240 '<p>' . __( 'If a media file has not been attached to any content, you will see that in the Uploaded To column, and can click on Attach to launch a small popup that will allow you to search for existing content and attach the file.' ) . '</p>', 241 ) 242 ); 209 243 210 244 get_current_screen()->set_help_sidebar( … … 214 248 ); 215 249 216 get_current_screen()->set_screen_reader_content( array( 217 'heading_views' => __( 'Filter media items list' ), 218 'heading_pagination' => __( 'Media items list navigation' ), 219 'heading_list' => __( 'Media items list' ), 220 ) ); 250 get_current_screen()->set_screen_reader_content( 251 array( 252 'heading_views' => __( 'Filter media items list' ), 253 'heading_pagination' => __( 'Media items list navigation' ), 254 'heading_list' => __( 'Media items list' ), 255 ) 256 ); 221 257 222 258 require_once( ABSPATH . 'wp-admin/admin-header.php' ); … … 227 263 228 264 <?php 229 if ( current_user_can( 'upload_files' ) ) { ?> 230 <a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a><?php 265 if ( current_user_can( 'upload_files' ) ) { 266 ?> 267 <a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a> 268 <?php 231 269 } 232 270 … … 242 280 $message = ''; 243 281 if ( ! empty( $_GET['posted'] ) ) { 244 $message = __( 'Media file updated.' );245 $_SERVER['REQUEST_URI'] = remove_query_arg( array('posted'), $_SERVER['REQUEST_URI']);282 $message = __( 'Media file updated.' ); 283 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'posted' ), $_SERVER['REQUEST_URI'] ); 246 284 } 247 285 … … 253 291 $message = _n( '%s media file attached.', '%s media files attached.', $attached ); 254 292 } 255 $message = sprintf( $message, number_format_i18n( $attached ) );293 $message = sprintf( $message, number_format_i18n( $attached ) ); 256 294 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); 257 295 } … … 264 302 $message = _n( '%s media file detached.', '%s media files detached.', $detached ); 265 303 } 266 $message = sprintf( $message, number_format_i18n( $detached ) );304 $message = sprintf( $message, number_format_i18n( $detached ) ); 267 305 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); 268 306 } … … 275 313 $message = _n( '%s media file permanently deleted.', '%s media files permanently deleted.', $deleted ); 276 314 } 277 $message = sprintf( $message, number_format_i18n( $deleted ) );278 $_SERVER['REQUEST_URI'] = remove_query_arg( array('deleted'), $_SERVER['REQUEST_URI']);315 $message = sprintf( $message, number_format_i18n( $deleted ) ); 316 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] ); 279 317 } 280 318 … … 286 324 $message = _n( '%s media file moved to the trash.', '%s media files moved to the trash.', $trashed ); 287 325 } 288 $message = sprintf( $message, number_format_i18n( $trashed ) );289 $message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';290 $_SERVER['REQUEST_URI'] = remove_query_arg( array('trashed'), $_SERVER['REQUEST_URI']);326 $message = sprintf( $message, number_format_i18n( $trashed ) ); 327 $message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ) . '">' . __( 'Undo' ) . '</a>'; 328 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'trashed' ), $_SERVER['REQUEST_URI'] ); 291 329 } 292 330 … … 298 336 $message = _n( '%s media file restored from the trash.', '%s media files restored from the trash.', $untrashed ); 299 337 } 300 $message = sprintf( $message, number_format_i18n( $untrashed ) );301 $_SERVER['REQUEST_URI'] = remove_query_arg( array('untrashed'), $_SERVER['REQUEST_URI']);338 $message = sprintf( $message, number_format_i18n( $untrashed ) ); 339 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'untrashed' ), $_SERVER['REQUEST_URI'] ); 302 340 } 303 341 … … 305 343 $messages[2] = __( 'Media file permanently deleted.' ); 306 344 $messages[3] = __( 'Error saving media file.' ); 307 $messages[4] = __( 'Media file 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>';345 $messages[4] = __( 'Media file 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>'; 308 346 $messages[5] = __( 'Media file restored from the trash.' ); 309 347 310 348 if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) { 311 $message = $messages[ $_GET['message'] ]; 312 $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); 313 } 314 315 if ( !empty($message) ) { ?> 349 $message = $messages[ $_GET['message'] ]; 350 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' ), $_SERVER['REQUEST_URI'] ); 351 } 352 353 if ( ! empty( $message ) ) { 354 ?> 316 355 <div id="message" class="updated notice is-dismissible"><p><?php echo $message; ?></p></div> 317 356 <?php } ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)