Make WordPress Core


Ignore:
Timestamp:
10/05/2017 04:24:52 AM (7 years ago)
Author:
helen
Message:

File Editors: Introduce an interstitial warning upon first visit.

This is an effort to provide a speed bump before heading into something potentially destructive and some education for users on better alternatives, even as we make the file editors safer to use. Each user, including existing users, will be shown a one-time dismissible modal warning on their first visit to each of the theme and plugin file editors.

Copy tweaks to come.

props michelleweber, Ipstenu, melchoyce, adamsilverstein, westonruter, toddnestor, aryamaaru, ZaneMatthew, cliffseal, helen.
fixes #31779.

File:
1 edited

Legend:

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

    r41721 r41774  
    128128    wp_enqueue_script( 'wp-theme-plugin-editor' );
    129129    wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) );
     130    wp_add_inline_script( 'wp-theme-plugin-editor', 'wp.themePluginEditor.themeOrPlugin = "theme";' );
    130131
    131132    require_once( ABSPATH . 'wp-admin/admin-header.php' );
     
    310311</div>
    311312<?php
     313$dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
     314if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
     315?>
     316<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js">
     317    <div class="notification-dialog-background"></div>
     318    <div class="notification-dialog" role="dialog" aria-labelledby="file-editor-warning-title" tabindex="0">
     319        <div class="file-editor-warning-content">
     320            <h1 id="file-editor-warning-title"><?php _e( 'Heads up!' ); ?></h1>
     321            <p>
     322                <?php
     323                echo sprintf(
     324                    /* translators: %s is a link to Custom CSS section in the Customizer. */
     325                    __( '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>.' ),
     326                    esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
     327                );
     328                ?>
     329            </p>
     330            <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>
     331            <p><button type="button" class="file-editor-warning-dismiss button-primary"><?php _e( 'I understand' ); ?></button></p>
     332        </div>
     333    </div>
     334</div>
     335<?php
     336endif; // editor warning notice
    312337
    313338include(ABSPATH . 'wp-admin/admin-footer.php' );
Note: See TracChangeset for help on using the changeset viewer.