diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/upload.php --- a/wp/wp-admin/upload.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/upload.php Fri Sep 05 18:40:08 2025 +0200 @@ -13,12 +13,128 @@ wp_die( __( 'Sorry, you are not allowed to upload files.' ) ); } -$mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid'; +$message = ''; +if ( ! empty( $_GET['posted'] ) ) { + $message = __( 'Media file updated.' ); + + $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'posted' ), $_SERVER['REQUEST_URI'] ); + unset( $_GET['posted'] ); +} + +if ( ! empty( $_GET['attached'] ) && absint( $_GET['attached'] ) ) { + $attached = absint( $_GET['attached'] ); + + if ( 1 === $attached ) { + $message = __( 'Media file attached.' ); + } else { + $message = sprintf( + /* translators: %s: Number of media files. */ + _n( '%s media file attached.', '%s media files attached.', $attached ), + number_format_i18n( $attached ) + ); + } + + $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); + unset( $_GET['detach'], $_GET['attached'] ); +} + +if ( ! empty( $_GET['detach'] ) && absint( $_GET['detach'] ) ) { + $detached = absint( $_GET['detach'] ); + + if ( 1 === $detached ) { + $message = __( 'Media file detached.' ); + } else { + $message = sprintf( + /* translators: %s: Number of media files. */ + _n( '%s media file detached.', '%s media files detached.', $detached ), + number_format_i18n( $detached ) + ); + } + + $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); + unset( $_GET['detach'], $_GET['attached'] ); +} + +if ( ! empty( $_GET['deleted'] ) && absint( $_GET['deleted'] ) ) { + $deleted = absint( $_GET['deleted'] ); + + if ( 1 === $deleted ) { + $message = __( 'Media file permanently deleted.' ); + } else { + $message = sprintf( + /* translators: %s: Number of media files. */ + _n( '%s media file permanently deleted.', '%s media files permanently deleted.', $deleted ), + number_format_i18n( $deleted ) + ); + } + + $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] ); + unset( $_GET['deleted'] ); +} + +if ( ! empty( $_GET['trashed'] ) && absint( $_GET['trashed'] ) ) { + $trashed = absint( $_GET['trashed'] ); + + if ( 1 === $trashed ) { + $message = __( 'Media file moved to the Trash.' ); + } else { + $message = sprintf( + /* translators: %s: Number of media files. */ + _n( '%s media file moved to the Trash.', '%s media files moved to the Trash.', $trashed ), + number_format_i18n( $trashed ) + ); + } + + $message .= sprintf( + ' %2$s', + esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ), + __( 'Undo' ) + ); + + $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'trashed' ), $_SERVER['REQUEST_URI'] ); + unset( $_GET['trashed'] ); +} + +if ( ! empty( $_GET['untrashed'] ) && absint( $_GET['untrashed'] ) ) { + $untrashed = absint( $_GET['untrashed'] ); + + if ( 1 === $untrashed ) { + $message = __( 'Media file restored from the Trash.' ); + } else { + $message = sprintf( + /* translators: %s: Number of media files. */ + _n( '%s media file restored from the Trash.', '%s media files restored from the Trash.', $untrashed ), + number_format_i18n( $untrashed ) + ); + } + + $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'untrashed' ), $_SERVER['REQUEST_URI'] ); + unset( $_GET['untrashed'] ); +} + +$messages[1] = __( 'Media file updated.' ); +$messages[2] = __( 'Media file permanently deleted.' ); +$messages[3] = __( 'Error saving media file.' ); +$messages[4] = __( 'Media file moved to the Trash.' ) . sprintf( + ' %2$s', + esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ), + __( 'Undo' ) +); +$messages[5] = __( 'Media file 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'] ); +} + $modes = array( 'grid', 'list' ); if ( isset( $_GET['mode'] ) && in_array( $_GET['mode'], $modes, true ) ) { $mode = $_GET['mode']; update_user_option( get_current_user_id(), 'media_library_mode', $mode ); +} else { + $mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid'; } if ( 'grid' === $mode ) { @@ -26,7 +142,15 @@ wp_enqueue_script( 'media-grid' ); wp_enqueue_script( 'media' ); - remove_action( 'admin_head', 'wp_admin_canonical_url' ); + // Remove the error parameter added by deprecation of wp-admin/media.php. + add_filter( + 'removable_query_args', + function () { + return array( 'error' ); + }, + 10, + 0 + ); $q = $_GET; // Let JS handle this. @@ -72,8 +196,8 @@ get_current_screen()->set_help_sidebar( '
' . __( 'For more information:' ) . '
' . - '' . __( 'Documentation on Media Library' ) . '
' . - '' . __( 'Support' ) . '
' + '' . __( 'Documentation on Media Library' ) . '
' . + '' . __( 'Support forums' ) . '
' ); // Used in the HTML title tag. @@ -88,24 +212,37 @@ - +' . __( '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.' ) . '
', + '' . __( 'Hovering over a row reveals action links that allow you to manage media items. You can perform the following actions:' ) . '
' . + '' . __( 'For more information:' ) . '
' . - '' . __( 'Documentation on Media Library' ) . '
' . - '' . __( 'Support' ) . '
' + '' . __( 'Documentation on Media Library' ) . '
' . + '' . __( 'Support forums' ) . '
' ); get_current_screen()->set_screen_reader_content( @@ -274,7 +419,7 @@ - + 'message', + 'additional_classes' => array( 'updated' ), + 'dismissible' => true, + ) + ); } - -if ( ! empty( $_GET['trashed'] ) && absint( $_GET['trashed'] ) ) { - $trashed = absint( $_GET['trashed'] ); - if ( 1 === $trashed ) { - $message = __( 'Media file moved to the Trash.' ); - } else { - /* translators: %s: Number of media files. */ - $message = _n( '%s media file moved to the Trash.', '%s media files moved to the Trash.', $trashed ); - } - $message = sprintf( $message, number_format_i18n( $trashed ) ); - $message .= ' ' . __( 'Undo' ) . ''; - $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'trashed' ), $_SERVER['REQUEST_URI'] ); -} - -if ( ! empty( $_GET['untrashed'] ) && absint( $_GET['untrashed'] ) ) { - $untrashed = absint( $_GET['untrashed'] ); - if ( 1 === $untrashed ) { - $message = __( 'Media file restored from the Trash.' ); - } else { - /* translators: %s: Number of media files. */ - $message = _n( '%s media file restored from the Trash.', '%s media files 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 file updated.' ); -$messages[2] = __( 'Media file permanently deleted.' ); -$messages[3] = __( 'Error saving media file.' ); -$messages[4] = __( 'Media file moved to the Trash.' ) . ' ' . __( 'Undo' ) . ''; -$messages[5] = __( 'Media file 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 ) ) { - ?> -