Ticket #23601: 23601.diff
File 23601.diff, 12.4 KB (added by , 12 years ago) |
---|
-
wp-admin/css/wp-admin.css
diff --git wp-admin/css/wp-admin.css wp-admin/css/wp-admin.css index 7ca3745..8033047 100644
body.full-overlay-active { 5847 5847 width: 98%; 5848 5848 } 5849 5849 5850 #template div {5851 margin-right: 190px;5852 }5853 5854 5850 p.pagenav { 5855 5851 margin: 0; 5856 5852 display: inline; … … h3 span { 7921 7917 font-weight: normal; 7922 7918 } 7923 7919 7924 #template textarea { 7925 font-family: Consolas, Monaco, monospace; 7926 font-size: 12px; 7927 width: 97%; 7928 background: #f9f9f9; 7929 outline: none; 7920 #wp-ace-editor { 7921 position: relative; 7922 width: 75%; 7923 height: 400px; 7924 margin-right: 190px; 7925 } 7926 7927 #newcontent { 7928 display: none; 7929 } 7930 7931 #editor-mods { 7932 margin-bottom: 10px; 7930 7933 } 7931 7934 7932 7935 #template p { -
new file wp-admin/includes/code-editor.php
diff --git wp-admin/includes/code-editor.php wp-admin/includes/code-editor.php new file mode 100644 index 0000000..3d6e593
- + 1 <?php 2 $editor_modes = array( 3 'asciidoc' => 'ASCII Doc', 4 'c_cpp' => 'C/C++', 5 'clojure' => 'Clojure', 6 'coffee' => 'CoffeeScript', 7 'coldfusion' => 'ColdFusion', 8 'csharp' => 'C#', 9 'css' => '', 10 'curly' => 'Curly', 11 'dart' => 'Dart', 12 'diff' => 'Difference', 13 'django' => 'Django', 14 'dot' => 'Dot', 15 'golang' => 'Go', 16 'groovy' => 'Groovy', 17 'haml' => '', 18 'haxe' => 'Haxe', 19 'html' => '', 20 'jade' => 'Jade', 21 'java' => 'Java', 22 'javascript' => 'JavaScript', 23 'json' => '', 24 'jsp' => '', 25 'jsx' => '', 26 'latex' => 'Latex', 27 'less' => '', 28 'liquid' => 'Liquid', 29 'lisp' => 'Lisp', 30 'livescript' => 'LiveScript', 31 'lua' => 'Lua', 32 'luapage' => 'Lua Page', 33 'lucene' => 'Lucene', 34 'makefile' => 'Makefile', 35 'markdown' => 'Markdown', 36 'objectivec' => 'Objective-C', 37 'ocaml' => 'OCaml', 38 'perl' => 'Perl', 39 'pgsql' => 'PL/pgSQL', 40 'php' => '', 41 'powershell' => 'PowerShell', 42 'python' => 'Python', 43 'r' => '', 44 'rdoc' => 'RDoc', 45 'rhtml' => '', 46 'ruby' => 'Ruby', 47 'scad' => '', 48 'scala' => 'Scala', 49 'scheme' => 'Scheme', 50 'scss' => '', 51 'sh' => 'Shell', 52 'sql' => '', 53 'stylus' => 'Stylus', 54 'svg' => '', 55 'tcl' => '', 56 'tex' => 'TeX', 57 'text' => 'Text', 58 'textile' => 'Textile', 59 'tm_snippet' => 'Textmate Snippet', 60 'typescript' => 'TypeScript', 61 'vbscript' => 'VBScript', 62 'xml' => '', 63 'xquery' => 'XQuery', 64 'yaml' => '' 65 ); 66 67 $editor_themes = array( 68 'chaos', 'chrome', 'clouds', 'clouds_midnight', 'cobalt', 'crimson_editor', 69 'dawn', 'dreamweaver', 'eclipse', 'github', 'idle_fingers', 70 'kr', 'merbivore', 'mono_industrial', 'monokai', 'pastel_on_dark', 71 'solarized_dark', 'solarized_light', 'textmate', 'tomorrow', 72 'tomorrow_night', 'tomorrow_night_blue', 'tomorrow_night_bright', 'tomorrow_night_eighties', 73 'twilight', 'vibrant_link', 'xcode' 74 ); 75 76 $current_mode = ''; 77 if ( ! empty( $_GET['editor-mode'] ) ) 78 $current_mode = $_GET['editor-mode']; 79 80 if ( ! empty( $file ) ) { 81 $filetype = wp_check_filetype( $file ); 82 if ( empty( $filetype['ext'] ) && '.php' === substr( $file, -4 ) ) { 83 $current_mode = 'php'; 84 } elseif ( ! empty( $filetype['ext'] ) && in_array( $filetype['ext'], array_keys( $editor_modes ) ) ) { 85 $current_mode = $filetype['ext']; 86 } 87 } 88 ?> 89 <form id="editor-mods"> 90 <select name="editor-theme"> 91 <option value="">- <?php _e( 'Code Editor Theme' ) ?> -</option> 92 <?php foreach ( $editor_themes as $editor_theme ): ?> 93 <option <?php selected( ! empty( $_GET['editor-theme'] ) && $_GET['editor-theme'] === $editor_theme ) ?> value="<?php echo $editor_theme ?>"> 94 <?php echo ucwords( str_replace( '_', ' ', $editor_theme ) ) ?> 95 </option> 96 <?php endforeach ?> 97 </select> 98 <select name="editor-mode"> 99 <option value="">- <?php _e( 'Code Editor Mode' ) ?> -</option> 100 <?php foreach ( $editor_modes as $editor_mode => $label ): ?> 101 <option <?php selected( ! empty( $current_mode ) && $editor_mode === $current_mode ); 102 ?> value="<?php echo $editor_mode ?>"><?php 103 if ( empty( $label ) ) 104 echo strtoupper( $editor_mode ); 105 else 106 echo $label; 107 ?></option> 108 <?php endforeach ?> 109 </select> 110 <input type="submit" class="button" value="<?php esc_attr_e( 'Update Editor' ) ?>" /> 111 </form> 112 No newline at end of file -
wp-admin/plugin-editor.php
diff --git wp-admin/plugin-editor.php wp-admin/plugin-editor.php index 122362a..395577d 100644
$file = validate_file_to_edit($file, $plugin_files); 44 44 $real_file = WP_PLUGIN_DIR . '/' . $file; 45 45 $scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0; 46 46 47 $editor_mods = ''; 48 if ( ! empty( $_REQUEST['editor-theme'] ) || ! empty( $_REQUEST['editor-mode'] ) ) { 49 if ( ! empty( $_REQUEST['editor-theme'] ) ) 50 $editor_mods .= '&editor-theme=' . $_REQUEST['editor-theme']; 51 if ( ! empty( $_REQUEST['editor-mode'] ) ) 52 $editor_mods .= '&editor-mode=' . $_REQUEST['editor-mode']; 53 } 54 47 55 switch ( $action ) { 48 56 49 57 case 'update': … … case 'update': 69 77 wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide)); 70 78 exit; 71 79 } 72 wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto ") );80 wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto$editor_mods") ); 73 81 } else { 74 wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto ") );82 wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto$editor_mods") ); 75 83 } 76 84 exit; 77 85 … … default: 89 97 if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($file) ) || ! is_plugin_active($file) ) 90 98 activate_plugin($file, "plugin-editor.php?file=$file&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error 91 99 92 wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto ") );100 wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto$editor_mods") ); 93 101 exit; 94 102 } 95 103 … … default: 109 117 } 110 118 } 111 119 120 wp_enqueue_script( 'wp-ace' ); 121 112 122 get_current_screen()->add_help_tab( array( 113 123 'id' => 'overview', 114 124 'title' => __('Overview'), … … foreach ( $plugin_files as $plugin_file ) : 218 228 // No extension found 219 229 continue; 220 230 } 231 232 $url = sprintf( 'plugin-editor.php?file=%s&plugin=%s', urlencode( $plugin_file ), urlencode( $plugin ) ); 233 if ( ! empty( $_GET['editor-theme'] ) ) 234 $url .= '&editor-theme=' . urlencode( $_GET['editor-theme'] ); 235 if ( ! empty( $_GET['editor-mode'] ) ) 236 $url .= '&editor-mode=' . urlencode( $_GET['editor-mode'] ); 221 237 ?> 222 <li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href=" plugin-editor.php?file=<?php echo urlencode( $plugin_file ) ?>&plugin=<?php echo urlencode( $plugin )?>"><?php echo $plugin_file ?></a></li>238 <li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="<?php echo $url ?>"><?php echo $plugin_file ?></a></li> 223 239 <?php endforeach; ?> 224 240 </ul> 225 241 </div> 242 243 <?php include( ABSPATH . 'wp-admin/includes/code-editor.php' ); ?> 244 226 245 <form name="template" id="template" action="plugin-editor.php" method="post"> 227 246 <?php wp_nonce_field('edit-plugin_' . $file) ?> 228 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" aria-describedby="newcontent-description"><?php echo $content; ?></textarea> 247 <div id="wp-ace-editor" data-theme="<?php 248 if ( ! empty( $_GET['editor-theme'] ) ) 249 echo $_GET['editor-theme']; 250 ?>" data-mode="<?php echo $current_mode ?>"><?php echo $content; ?></div> 251 <textarea id="newcontent" name="newcontent"><?php echo $content; ?></textarea> 229 252 <input type="hidden" name="action" value="update" /> 253 <?php if ( ! empty( $_GET['editor-theme'] ) ): ?> 254 <input type="hidden" name="editor-theme" value="<?php echo esc_attr( $_GET['editor-theme'] ) ?>" /> 255 <?php endif ?> 256 <?php if ( ! empty( $_GET['editor-mode'] ) ): ?> 257 <input type="hidden" name="editor-mode" value="<?php echo esc_attr( $_GET['editor-mode'] ) ?>" /> 258 <?php endif ?> 230 259 <input type="hidden" name="file" value="<?php echo esc_attr($file) ?>" /> 231 260 <input type="hidden" name="plugin" value="<?php echo esc_attr($plugin) ?>" /> 232 261 <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" /> -
wp-admin/theme-editor.php
diff --git wp-admin/theme-editor.php wp-admin/theme-editor.php index 2033a23..2277d5f 100644
if ( empty( $file ) ) { 75 75 validate_file_to_edit( $file, $allowed_files ); 76 76 $scrollto = isset( $_REQUEST['scrollto'] ) ? (int) $_REQUEST['scrollto'] : 0; 77 77 78 $editor_mods = ''; 79 if ( ! empty( $_REQUEST['editor-theme'] ) || ! empty( $_REQUEST['editor-mode'] ) ) { 80 if ( ! empty( $_REQUEST['editor-theme'] ) ) 81 $editor_mods .= '&editor-theme=' . $_REQUEST['editor-theme']; 82 if ( ! empty( $_REQUEST['editor-mode'] ) ) 83 $editor_mods .= '&editor-mode=' . $_REQUEST['editor-mode']; 84 } 85 78 86 switch( $action ) { 79 87 case 'update': 80 88 check_admin_referer( 'edit-theme_' . $file . $stylesheet ); 81 89 $newcontent = wp_unslash( $_POST['newcontent'] ); 82 $location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto ;90 $location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto . $editor_mods; 83 91 if ( is_writeable( $file ) ) { 84 92 //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable 85 93 $f = fopen( $file, 'w+' ); … … break; 96 104 97 105 default: 98 106 107 wp_enqueue_script( 'wp-ace' ); 108 99 109 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 100 110 101 111 update_recently_edited( $file ); … … if ( $allowed_files ) : 186 196 187 197 if ( $absolute_filename == $file ) 188 198 $file_description = '<span class="highlight">' . $file_description . '</span>'; 199 200 $url = sprintf( 'theme-editor.php?file=%s&theme=%s', urlencode( $filename ), urlencode( $stylesheet ) ); 201 if ( ! empty( $_GET['editor-theme'] ) ) 202 $url .= '&editor-theme=' . urlencode( $_GET['editor-theme'] ); 203 if ( ! empty( $_GET['editor-mode'] ) ) 204 $url .= '&editor-mode=' . urlencode( $_GET['editor-mode'] ); 189 205 ?> 190 <li><a href=" theme-editor.php?file=<?php echo urlencode( $filename ) ?>&theme=<?php echo urlencode( $stylesheet )?>"><?php echo $file_description; ?></a></li>206 <li><a href="<?php echo $url ?>"><?php echo $file_description; ?></a></li> 191 207 <?php 192 208 endforeach; 193 209 ?> … … if ( $allowed_files ) : 197 213 <?php if ( $error ) : 198 214 echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>'; 199 215 else : ?> 216 217 <?php include( ABSPATH . 'wp-admin/includes/code-editor.php' ); ?> 218 200 219 <form name="template" id="template" action="theme-editor.php" method="post"> 201 220 <?php wp_nonce_field( 'edit-theme_' . $file . $stylesheet ); ?> 202 <div><textarea cols="70" rows="30" name="newcontent" id="newcontent" aria-describedby="newcontent-description"><?php echo $content; ?></textarea> 221 <div id="wp-ace-editor" data-theme="<?php 222 if ( ! empty( $_GET['editor-theme'] ) ) 223 echo $_GET['editor-theme']; 224 ?>" data-mode="<?php echo $current_mode ?>"><?php echo $content; ?></div> 225 <textarea id="newcontent" name="newcontent"><?php echo $content; ?></textarea> 203 226 <input type="hidden" name="action" value="update" /> 227 <?php if ( ! empty( $_GET['editor-theme'] ) ): ?> 228 <input type="hidden" name="editor-theme" value="<?php echo esc_attr( $_GET['editor-theme'] ) ?>" /> 229 <?php endif ?> 230 <?php if ( ! empty( $_GET['editor-mode'] ) ): ?> 231 <input type="hidden" name="editor-mode" value="<?php echo esc_attr( $_GET['editor-mode'] ) ?>" /> 232 <?php endif ?> 204 233 <input type="hidden" name="file" value="<?php echo esc_attr( $relative_file ); ?>" /> 205 234 <input type="hidden" name="theme" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" /> 206 235 <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" /> -
wp-includes/script-loader.php
diff --git wp-includes/script-loader.php wp-includes/script-loader.php index cfb865e..26637bc 100644
function wp_default_scripts( &$scripts ) { 197 197 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'), 198 198 'closeImage' => includes_url('js/thickbox/tb-close.png') 199 199 ) ); 200 $scripts->add( 'ace', "/wp-includes/js/ace/ace.js", array('jquery'), '1.0.0' ); 201 $scripts->add( 'wp-ace', "/wp-includes/js/wp-ace.js", array('ace'), '1.0.0' ); 200 202 201 203 $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.js", array('jquery'), '0.9.10'); 202 204