Make WordPress Core


Ignore:
Timestamp:
10/13/2017 08:55:50 PM (8 years ago)
Author:
helen
Message:

File editor warning: Add a "Go back" button.

see #42100, #31779.

File:
1 edited

Legend:

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

    r41851 r41859  
    286286$dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
    287287if ( ! in_array( 'plugin_editor_notice', $dismissed_pointers, true ) ) :
     288    // Get a back URL
     289    $referer = wp_get_referer();
     290    $excluded_referer_basenames = array( 'plugin-editor.php', 'wp-login.php' );
     291
     292    if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
     293        $return_url = $referer;
     294    } else {
     295        $return_url = admin_url( '/' );
     296    }
    288297?>
    289298<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js">
     
    294303            <p><?php _e( 'You appear to be making direct edits to your plugin in the WordPress dashboard. We recommend that you don&#8217;t! Editing plugins directly may introduce incompatibilities that break your theme or other plugins, and can leave you unable to log back in to WordPress and undo changes.' ); ?></p>
    295304            <p><?php _e( 'If you absolutely have to edit this plugin, create a copy with a new name and hang on to the original version, so you can re-enable a functional version if something goes wrong.' ); ?></p>
    296             <p><button type="button" class="file-editor-warning-dismiss button-primary"><?php _e( 'I understand' ); ?></button></p>
     305            <p>
     306                <a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a>
     307                <button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button>
     308            </p>
    297309        </div>
    298310    </div>
Note: See TracChangeset for help on using the changeset viewer.