Changeset 14718 for trunk/wp-admin/includes/misc.php
- Timestamp:
- 05/18/2010 03:48:22 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/misc.php
r14312 r14718 314 314 315 315 /** 316 * Determines the language to use for CodePress syntax highlighting,317 * based only on a filename.318 *319 * @since 2.8320 *321 * @param string $filename The name of the file to be highlighting322 **/323 function codepress_get_lang( $filename ) {324 $codepress_supported_langs = apply_filters( 'codepress_supported_langs',325 array( '.css' => 'css',326 '.js' => 'javascript',327 '.php' => 'php',328 '.html' => 'html',329 '.htm' => 'html',330 '.txt' => 'text'331 ) );332 $extension = substr( $filename, strrpos( $filename, '.' ) );333 if ( $extension && array_key_exists( $extension, $codepress_supported_langs ) )334 return $codepress_supported_langs[$extension];335 336 return 'generic';337 }338 339 /**340 * Adds Javascript required to make CodePress work on the theme/plugin editors.341 *342 * This code is attached to the action admin_print_footer_scripts.343 *344 * @since 2.8345 **/346 function codepress_footer_js() {347 // Script-loader breaks CP's automatic path-detection, thus CodePress.path348 // CP edits in an iframe, so we need to grab content back into normal form349 ?><script type="text/javascript">350 /* <![CDATA[ */351 var codepress_path = '<?php echo includes_url('js/codepress/'); ?>';352 jQuery('#template').submit(function(){353 if (jQuery('#newcontent_cp').length)354 jQuery('#newcontent_cp').val(newcontent.getCode()).removeAttr('disabled');355 });356 jQuery('#codepress-on').hide();357 jQuery('#codepress-off').show();358 /* ]]> */359 </script>360 <?php361 }362 363 /**364 * Determine whether to use CodePress.365 *366 * @since 2.8367 **/368 function use_codepress() {369 370 if ( isset($_GET['codepress']) ) {371 $on = 'on' == $_GET['codepress'] ? 'on' : 'off';372 set_user_setting( 'codepress', $on );373 } else {374 $on = get_user_setting('codepress', 'on');375 }376 377 if ( 'on' == $on ) {378 add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );379 return true;380 }381 382 return false;383 }384 385 /**386 316 * Saves option for number of rows when listing posts, pages, comments, etc. 387 317 *
Note: See TracChangeset
for help on using the changeset viewer.