Media: Redirect deprecated wp-admin/media.php file.

Redirect users visiting the `wp-admin/media.php` file to the media library, `wp-admin/upload.php`. An user facing warning is displayed when the media library is reached via a deprecated link.

Follow up to [55647].

Props jorbin, audrasjb, azaozz, NekoJonez, kebbet, costdev.
Fixes #57612.



git-svn-id: https://develop.svn.wordpress.org/trunk@55943 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson
2023-06-19 23:18:28 +00:00
parent 75d7208741
commit 6966e31934
3 changed files with 38 additions and 2 deletions

View File

@@ -9,4 +9,27 @@
* @subpackage Administration
*/
_deprecated_file( basename( __FILE__ ), '6.3.0', 'wp-admin/upload.php' );
/** Load WordPress Administration Bootstrap. */
require_once __DIR__ . '/admin.php';
$parent_file = 'upload.php';
$submenu_file = 'upload.php';
wp_reset_vars( array( 'action' ) );
switch ( $action ) {
case 'editattachment':
case 'edit':
if ( empty( $_GET['attachment_id'] ) ) {
wp_redirect( admin_url( 'upload.php?error=deprecated' ) );
exit;
}
$att_id = (int) $_GET['attachment_id'];
wp_redirect( admin_url( "upload.php?item={$att_id}&error=deprecated" ) );
exit;
default:
wp_redirect( admin_url( 'upload.php?error=deprecated' ) );
exit;
}

View File

@@ -141,7 +141,15 @@ if ( 'grid' === $mode ) {
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.

View File

@@ -373,6 +373,11 @@ function wp_print_media_templates() {
<?php // Template for the Attachment Details two columns layout. ?>
<script type="text/html" id="tmpl-attachment-details-two-column">
<div class="attachment-media-view {{ data.orientation }}">
<?php
if ( isset( $_GET['error'] ) && 'deprecated' === $_GET['error'] ) {
echo '<div id="message" class="error notice"><p>' . __( 'The Edit Media screen is deprecated as of WordPress 6.3. Please use the Media Library instead.' ) . '</p></div>';
}
?>
<h2 class="screen-reader-text"><?php /* translators: Hidden accessibility text. */ _e( 'Attachment Preview' ); ?></h2>
<div class="thumbnail thumbnail-{{ data.type }}">
<# if ( data.uploading ) { #>