diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index d91e8a1368..2d64bca75e 100644 --- a/src/wp-admin/css/common.css +++ b/src/wp-admin/css/common.css @@ -3147,6 +3147,10 @@ img { line-height: 180%; } +#file-editor-warning .file-editor-warning-content { + margin: 25px; +} + /* @todo: can we use a common class for these? */ .nav-menus-php .item-edit:before, .widget-top .widget-action .toggle-indicator:before, diff --git a/src/wp-admin/js/theme-plugin-editor.js b/src/wp-admin/js/theme-plugin-editor.js index 3bb0788a6b..24c969fe55 100644 --- a/src/wp-admin/js/theme-plugin-editor.js +++ b/src/wp-admin/js/theme-plugin-editor.js @@ -46,6 +46,14 @@ wp.themePluginEditor = (function( $ ) { component.form.on( 'submit', component.submit ); component.textarea = component.form.find( '#newcontent' ); component.textarea.on( 'change', component.onChange ); + component.warning = $( '.file-editor-warning' ); + + if ( component.warning.length > 0 ) { + $( 'body' ).addClass( 'modal-open' ); + component.warning.find( '.file-editor-warning-dismiss' ).focus(); + component.warning.on( 'click', '.file-editor-warning-dismiss', component.dismissWarning ); + }; + if ( false !== component.codeEditor ) { /* @@ -66,6 +74,26 @@ wp.themePluginEditor = (function( $ ) { } ); }; + /** + * Dismiss the warning modal. + * + * @since 4.9.0 + * @returns {void} + */ + component.dismissWarning = function() { + + wp.ajax.post( 'dismiss-wp-pointer', { + pointer: component.themeOrPlugin + '_editor_notice' + }); + + // hide modal + component.warning.remove(); + $( 'body' ).removeClass( 'modal-open' ); + + // return focus - is this a trap? + component.instance.codemirror.focus(); + }; + /** * Callback for when a change happens. * diff --git a/src/wp-admin/plugin-editor.php b/src/wp-admin/plugin-editor.php index 636e1cf739..807cd5e09d 100644 --- a/src/wp-admin/plugin-editor.php +++ b/src/wp-admin/plugin-editor.php @@ -142,6 +142,7 @@ if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { ); wp_enqueue_script( 'wp-theme-plugin-editor' ); wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) ); + wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.themeOrPlugin = "plugin";' ) ); require_once(ABSPATH . 'wp-admin/admin-header.php'); @@ -280,5 +281,21 @@ if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
+
+
+ +
+ +
+
+ +
+