Make WordPress Core

Changeset 55943


Ignore:
Timestamp:
06/19/2023 11:18:28 PM (15 months ago)
Author:
peterwilsoncc
Message:

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.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/media.php

    r55647 r55943  
    1010 */
    1111
    12 _deprecated_file( basename( __FILE__ ), '6.3.0', 'wp-admin/upload.php' );
     12/** Load WordPress Administration Bootstrap. */
     13require_once __DIR__ . '/admin.php';
     14
     15$parent_file  = 'upload.php';
     16$submenu_file = 'upload.php';
     17
     18wp_reset_vars( array( 'action' ) );
     19
     20switch ( $action ) {
     21    case 'editattachment':
     22    case 'edit':
     23        if ( empty( $_GET['attachment_id'] ) ) {
     24            wp_redirect( admin_url( 'upload.php?error=deprecated' ) );
     25            exit;
     26        }
     27        $att_id = (int) $_GET['attachment_id'];
     28
     29        wp_redirect( admin_url( "upload.php?item={$att_id}&error=deprecated" ) );
     30        exit;
     31
     32    default:
     33        wp_redirect( admin_url( 'upload.php?error=deprecated' ) );
     34        exit;
     35}
  • trunk/src/wp-admin/upload.php

    r55631 r55943  
    142142    wp_enqueue_script( 'media' );
    143143
    144     remove_action( 'admin_head', 'wp_admin_canonical_url' );
     144    // Remove the error parameter added by deprecation of wp-admin/media.php.
     145    add_filter(
     146        'removable_query_args',
     147        function() {
     148            return array( 'error' );
     149        },
     150        10,
     151        0
     152    );
    145153
    146154    $q = $_GET;
  • trunk/src/wp-includes/media-template.php

    r55827 r55943  
    374374    <script type="text/html" id="tmpl-attachment-details-two-column">
    375375        <div class="attachment-media-view {{ data.orientation }}">
     376            <?php
     377            if ( isset( $_GET['error'] ) && 'deprecated' === $_GET['error'] ) {
     378                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>';
     379            }
     380            ?>
    376381            <h2 class="screen-reader-text"><?php /* translators: Hidden accessibility text. */ _e( 'Attachment Preview' ); ?></h2>
    377382            <div class="thumbnail thumbnail-{{ data.type }}">
Note: See TracChangeset for help on using the changeset viewer.