Ticket #31779: 31779.5.diff
File 31779.5.diff, 7.7 KB (added by , 7 years ago) |
---|
-
src/wp-admin/admin-ajax.php
65 65 'generate-password', 'save-wporg-username', 'delete-plugin', 'search-plugins', 66 66 'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 'install-theme', 67 67 'get-post-thumbnail-html', 'get-community-events', 'edit-theme-plugin-file', 68 'edit-theme-plugin-warning-dismissed', 68 69 ); 69 70 70 71 // Deprecated -
src/wp-admin/css/common.css
3147 3147 line-height: 180%; 3148 3148 } 3149 3149 3150 #file-editor-warning .file-editor-warning-content { 3151 margin: 25px; 3152 } 3153 3150 3154 /* @todo: can we use a common class for these? */ 3151 3155 .nav-menus-php .item-edit:before, 3152 3156 .widget-top .widget-action .toggle-indicator:before, -
src/wp-admin/includes/ajax-actions.php
3989 3989 ) ); 3990 3990 } 3991 3991 } 3992 3993 /** 3994 * Update user meta when a user dismisses the 'Heads Up' warning modal displayed when using 3995 * the plugin or theme editor for the first time. 3996 */ 3997 function wp_ajax_edit_theme_plugin_warning_dismissed() { 3998 check_ajax_referer( 'dismiss-notice' ); 3999 4000 $dismissed = isset( $_POST['dismissed'] ) ? sanitize_text_field( $_POST['dismissed'] ) : 'themes'; 4001 update_user_meta( get_current_user_id(), 'hide_' . $dismissed . '_editor_notice', true ); 4002 wp_die( 1 ); 4003 } -
src/wp-admin/js/theme-plugin-editor.js
46 46 component.form.on( 'submit', component.submit ); 47 47 component.textarea = component.form.find( '#newcontent' ); 48 48 component.textarea.on( 'change', component.onChange ); 49 component.warning = $( '.file-editor-warning' ); 49 50 51 if ( component.warning.length > 0 ) { 52 $( 'body' ).addClass( 'modal-open' ); 53 component.warning.find( '.notice-dismiss' ).focus(); 54 component.warning.on( 'click', '.notice-dismiss', component.dismissWarning ); 55 }; 56 57 50 58 if ( false !== component.codeEditor ) { 51 59 /* 52 60 * Defer adding notices until after DOM ready as workaround for WP Admin injecting … … 67 75 }; 68 76 69 77 /** 78 * Dismiss the warning modal. 79 */ 80 component.dismissWarning = function() { 81 82 // update user meta 83 var request = wp.ajax.post( 'edit-theme-plugin-warning-dismissed', { 84 _ajax_nonce: wp.themePluginEditor.nonce, 85 dismissed: wp.themePluginEditor.themeOrPlugin 86 } ); 87 88 // hide modal 89 component.warning.remove(); 90 $( 'body' ).removeClass( 'modal-open' ); 91 92 // return focus - is this a trap? 93 component.instance.codemirror.focus(); 94 } 95 96 /** 70 97 * Callback for when a change happens. 71 98 * 72 99 * @since 4.9.0 -
src/wp-admin/plugin-editor.php
142 142 ); 143 143 wp_enqueue_script( 'wp-theme-plugin-editor' ); 144 144 wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) ); 145 wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.themeOrPlugin = "plugin";' ) ); 145 146 146 147 require_once(ABSPATH . 'wp-admin/admin-header.php'); 147 148 … … 280 281 <br class="clear" /> 281 282 </div> 282 283 <?php 284 $hide_notice = get_user_meta( get_current_user_id(), 'hide_plugin_editor_notice', true ); 285 if ( empty( $hide_notice ) ) : 286 ?> 287 <div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js"> 288 <div class="notification-dialog-background"></div> 289 <div class="notification-dialog" role="dialog" aria-labelledby="file-editor-warning-title" tabindex="0"> 290 <div class="file-editor-warning-content"> 291 <h1 id="file-editor-warning-title"><?php _e( 'Heads up!' ); ?></h1> 292 <p><?php _e( 'You appear to be making direct edits to your plugin in the WordPress dashboard. We recommend that you don’t! Editing plugins directly may introduce incompatibilities that break your site or even leave you staring at the dreaded “White Screen of Death”. Your changes may also be overwritten by future updates.' ); ?></p> 293 <p><?php _e( 'If you absolutely must edit a plugin this way, WordPress will attempt to prevent you from being locked out from the dashboard entirely, but cannot guarantee results. Once dismissed, this notice will not appear again.' ); ?></p> 294 </div> 295 <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php _e( 'Dismiss' ); ?></span></button> 296 </div> 297 </div> 298 <?php 299 endif; // editor warning notice 283 300 284 301 include(ABSPATH . "wp-admin/admin-footer.php"); -
src/wp-admin/theme-editor.php
127 127 ); 128 128 wp_enqueue_script( 'wp-theme-plugin-editor' ); 129 129 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";' ); 130 131 131 132 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 132 133 … … 309 310 <br class="clear" /> 310 311 </div> 311 312 <?php 313 $hide_notice = get_user_meta( get_current_user_id(), 'hide_theme_editor_notice', true ); 314 if ( empty( $hide_notice ) ) : 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><?php _e( 'You appear to be making direct edits to your theme in the WordPress dashboard. We recommend that you don’t! Editing this code directly is dangerous, and can leave you unable to log back in to WordPress and undo changes. There’s no need to change your CSS here — you can edit and live preview CSS changes in WordPress’s built in CSS editor.' ); ?></p> 322 <p><?php _e( 'If you decide to go ahead with direct edits anyway, make sure to back up all your site’s files before making changes so you can restore a functional version if something goes wrong. Once dismissed, this notice will not appear again.' ); ?></p> 323 </div> 324 <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php _e( 'Dismiss' ); ?></span></button> 325 </div> 326 </div> 327 <?php 328 endif; // editor warning notice 312 329 313 330 include(ABSPATH . 'wp-admin/admin-footer.php' ); -
src/wp-includes/script-loader.php
478 478 array( 'singular', 'plural' ) 479 479 ), 480 480 ) ) ) ); 481 did_action( 'init' ) && $scripts->add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.nonce = "%s";', wp_create_nonce( 'dismiss-notice' ) ) ); 481 482 482 483 $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 ); 483 484