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

see #42100, #31779.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2017-10-13 20:56:50 +00:00
parent d975dccac9
commit e48b16d96a
9 changed files with 36 additions and 10 deletions

View File

@ -529,7 +529,8 @@ span.wp-media-buttons-icon:before {
margin: 25px;
}
#post-lock-dialog .post-locked-message a.button {
#post-lock-dialog .post-locked-message a.button,
#file-editor-warning .button {
margin-left: 10px;
}

File diff suppressed because one or more lines are too long

View File

@ -529,7 +529,8 @@ span.wp-media-buttons-icon:before {
margin: 25px;
}
#post-lock-dialog .post-locked-message a.button {
#post-lock-dialog .post-locked-message a.button,
#file-editor-warning .button {
margin-right: 10px;
}

File diff suppressed because one or more lines are too long

View File

@ -52,7 +52,7 @@ wp.themePluginEditor = (function( $ ) {
if ( component.warning.length > 0 ) {
$( 'body' ).addClass( 'modal-open' );
component.warning.find( '.file-editor-warning-dismiss' ).focus();
component.warning.find( '.file-editor-warning-go-back' ).focus();
component.warning.on( 'click', '.file-editor-warning-dismiss', component.dismissWarning );
}

File diff suppressed because one or more lines are too long

View File

@ -285,6 +285,15 @@ if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
<?php
$dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
if ( ! in_array( 'plugin_editor_notice', $dismissed_pointers, true ) ) :
// Get a back URL
$referer = wp_get_referer();
$excluded_referer_basenames = array( 'plugin-editor.php', 'wp-login.php' );
if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
$return_url = $referer;
} else {
$return_url = admin_url( '/' );
}
?>
<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js">
<div class="notification-dialog-background"></div>
@ -293,7 +302,10 @@ if ( ! in_array( 'plugin_editor_notice', $dismissed_pointers, true ) ) :
<h1 id="file-editor-warning-title"><?php _e( 'Heads up!' ); ?></h1>
<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>
<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>
<p><button type="button" class="file-editor-warning-dismiss button-primary"><?php _e( 'I understand' ); ?></button></p>
<p>
<a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a>
<button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button>
</p>
</div>
</div>
</div>

View File

@ -290,6 +290,15 @@ endif; // $error
<?php
$dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
// Get a back URL
$referer = wp_get_referer();
$excluded_referer_basenames = array( 'theme-editor.php', 'wp-login.php' );
if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
$return_url = $referer;
} else {
$return_url = admin_url( '/' );
}
?>
<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js">
<div class="notification-dialog-background"></div>
@ -300,13 +309,16 @@ if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
<?php
echo sprintf(
/* translators: %s is a link to Custom CSS section in the Customizer. */
__( '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>.' ),
__( '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>.' ),
esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
);
?>
</p>
<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>
<p><button type="button" class="file-editor-warning-dismiss button-primary"><?php _e( 'I understand' ); ?></button></p>
<p>
<a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a>
<button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button>
</p>
</div>
</div>
</div>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta2-41858';
$wp_version = '4.9-beta2-41859';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.