WordPress.org

Make WordPress Core

Changeset 41859


Ignore:
Timestamp:
10/13/17 20:55:50 (10 days ago)
Author:
helen
Message:

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

see #42100, #31779.

Location:
trunk/src/wp-admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/edit.css

    r41563 r41859  
    530530} 
    531531 
    532 #post-lock-dialog .post-locked-message a.button { 
     532#post-lock-dialog .post-locked-message a.button, 
     533#file-editor-warning .button { 
    533534    margin-right: 10px; 
    534535} 
  • trunk/src/wp-admin/js/theme-plugin-editor.js

    r41851 r41859  
    5353        if ( component.warning.length > 0 ) { 
    5454            $( 'body' ).addClass( 'modal-open' ); 
    55             component.warning.find( '.file-editor-warning-dismiss' ).focus(); 
     55            component.warning.find( '.file-editor-warning-go-back' ).focus(); 
    5656            component.warning.on( 'click', '.file-editor-warning-dismiss', component.dismissWarning ); 
    5757        } 
  • 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> 
  • trunk/src/wp-admin/theme-editor.php

    r41851 r41859  
    291291$dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); 
    292292if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) : 
     293    // Get a back URL 
     294    $referer = wp_get_referer(); 
     295    $excluded_referer_basenames = array( 'theme-editor.php', 'wp-login.php' ); 
     296 
     297    if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) { 
     298        $return_url = $referer; 
     299    } else { 
     300        $return_url = admin_url( '/' ); 
     301    } 
    293302?> 
    294303<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js"> 
     
    301310                echo sprintf( 
    302311                    /* translators: %s is a link to Custom CSS section in the Customizer. */ 
    303                     __( 'You appear to be making direct edits to your theme in the WordPress Dashboard. We recommend that you don&#8217;t! Editing this code directly is dangerous, and can leave you unable to log back in to WordPress and undo changes. There&#8217;s no need to change your CSS here &mdash; you can edit and live preview CSS changes in WordPress&#8217;s <a href="%s">built in CSS editor</a>.' ), 
     312                    __( 'You appear to be making direct edits to your theme in the WordPress dashboard. We recommend that you don&#8217;t! Editing this code directly is dangerous, and can leave you unable to log back in to WordPress and undo changes. There&#8217;s no need to change your CSS here &mdash; you can edit and live preview CSS changes in WordPress&#8217;s <a href="%s">built in CSS editor</a>.' ), 
    304313                    esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) 
    305314                ); 
     
    307316            </p> 
    308317            <p><?php _e( 'If you decide to go ahead with direct edits anyway, make sure to back up all your site&#8217;s files before making changes so you can restore a functional version if something goes wrong.' ); ?></p> 
    309             <p><button type="button" class="file-editor-warning-dismiss button-primary"><?php _e( 'I understand' ); ?></button></p> 
     318            <p> 
     319                <a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a> 
     320                <button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button> 
     321            </p> 
    310322        </div> 
    311323    </div> 
Note: See TracChangeset for help on using the changeset viewer.