Ticket #9173: 9173.diff
| File 9173.diff, 4.7 KB (added by beaulebens, 3 years ago) |
|---|
-
wp-includes/script-loader.php
377 377 378 378 $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery-ui-draggable', 'jquery-ui-resizable' ), '20090113' ); 379 379 $scripts->add_data( 'media', 'group', 1 ); 380 380 381 $scripts->add( 'codepress', '/wp-includes/js/codepress/codepress.js', false, '0.9.6' ); 381 382 } 382 383 } 383 384 -
wp-admin/includes/misc.php
238 238 echo "<p>$message</p>\n"; 239 239 } 240 240 241 /** 242 * Determines the language to use for CodePress syntax highlighting, 243 * based only on a filename. 244 * 245 * @since 2.8 246 * 247 * @param string $filename The name of the file to be highlighting 248 **/ 249 function codepress_get_lang( $filename ) { 250 $codepress_supported_langs = apply_filters( 'codepress_supported_langs', 251 array( 'css' => 'css', 252 'js' => 'javascript', 253 'php' => 'php', 254 'html' => 'html', 255 'htm' => 'html', 256 'txt' => 'text' 257 ) ); 258 $extension = mb_substr( $filename, mb_strrpos( $filename, '.' ) + 1 ); 259 return isset( $codepress_supported_langs[$extension] ) ? $codepress_supported_langs[$extension] : 'generic'; 260 } 261 262 /** 263 * Adds Javascript required to make CodePress work on the theme/plugin editors. 264 * 265 * This code is attached to the action admin_print_footer_scripts. 266 * 267 * @since 2.8 268 **/ 269 function codepress_footer_js() { 270 // Script-loader breaks CP's automatic path-detection, thus CodePress.path 271 // CP edits in an iframe, so we need to grab content back into normal form 272 ?><script type="text/javascript"> 273 /* <![CDATA[ */ 274 CodePress.path = '<?php echo get_option('siteurl') ?>/wp-includes/js/codepress/'; 275 jQuery('#template').submit(function(){ 276 jQuery('#newcontent_cp').val(newcontent.getCode()).removeAttr('disabled'); 277 }); 278 /* ]]> */ 279 </script> 280 <?php 281 } 282 241 283 ?> -
wp-admin/theme-editor.php
77 77 if ( !current_user_can('edit_themes') ) 78 78 wp_die('<p>'.__('You do not have sufficient permissions to edit themes for this blog.').'</p>'); 79 79 80 wp_enqueue_script( 'codepress' ); 81 add_action( 'admin_print_footer_scripts', 'codepress_footer_js' ); 80 82 require_once('admin-header.php'); 81 83 82 84 update_recently_edited($file); … … 88 90 $f = fopen($real_file, 'r'); 89 91 $content = fread($f, filesize($real_file)); 90 92 $content = htmlspecialchars($content); 93 $codepress_lang = codepress_get_lang($real_file); 91 94 } 92 95 93 96 ?> … … 182 185 ?> 183 186 <form name="template" id="template" action="theme-editor.php" method="post"> 184 187 <?php wp_nonce_field('edit-theme_' . $file . $theme) ?> 185 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" ><?php echo $content ?></textarea>188 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress <?php echo $codepress_lang ?>"><?php echo $content ?></textarea> 186 189 <input type="hidden" name="action" value="update" /> 187 190 <input type="hidden" name="file" value="<?php echo $file ?>" /> 188 191 <input type="hidden" name="theme" value="<?php echo $theme ?>" /> -
wp-admin/plugin-editor.php
74 74 exit; 75 75 } 76 76 77 wp_enqueue_script( 'codepress' ); 78 add_action( 'admin_print_footer_scripts', 'codepress_footer_js' ); 77 79 require_once('admin-header.php'); 78 80 79 81 update_recently_edited(WP_PLUGIN_DIR . '/' . $file); … … 81 83 if ( ! is_file($real_file) ) 82 84 $error = 1; 83 85 84 if ( ! $error ) 86 if ( ! $error ) { 85 87 $content = htmlspecialchars(file_get_contents($real_file)); 88 $codepress_lang = codepress_get_lang($real_file); 89 } 86 90 87 91 ?> 88 92 <?php if (isset($_GET['a'])) : ?> … … 131 135 <?php if ( ! $error ) { ?> 132 136 <form name="template" id="template" action="plugin-editor.php" method="post"> 133 137 <?php wp_nonce_field('edit-plugin_' . $file) ?> 134 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" ><?php echo $content ?></textarea>138 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress <?php echo $codepress_lang ?>"><?php echo $content ?></textarea> 135 139 <input type="hidden" name="action" value="update" /> 136 140 <input type="hidden" name="file" value="<?php echo $file ?>" /> 137 141 </div>
