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.


Built from https://develop.svn.wordpress.org/trunk@55943


git-svn-id: http://core.svn.wordpress.org/trunk@55455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2023-06-19 23:20:21 +00:00
parent acc6e5d685
commit b5da380334
4 changed files with 39 additions and 3 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 ) { #>

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-55942';
$wp_version = '6.3-alpha-55943';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.