Make WordPress Core


Ignore:
Timestamp:
02/21/2009 02:12:00 AM (18 years ago)
Author:
azaozz
Message:

Add CodePress syntax highlighting to Theme and Plugin editors (first run), props beaulebens, see #9173

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/misc.php

    r10607 r10614  
    273273}
    274274
     275/**
     276 * Determines the language to use for CodePress syntax highlighting,
     277 * based only on a filename.
     278 *
     279 * @since 2.8
     280 *
     281 * @param string $filename The name of the file to be highlighting
     282**/
     283function codepress_get_lang( $filename ) {
     284        $codepress_supported_langs = apply_filters( 'codepress_supported_langs',
     285                                                                        array( 'css' => 'css',
     286                                                                                        'js' => 'javascript',
     287                                                                                        'php' => 'php',
     288                                                                                        'html' => 'html',
     289                                                                                        'htm' => 'html',
     290                                                                                        'txt' => 'text'
     291                                                                                        ) );
     292        $extension = mb_substr( $filename, mb_strrpos( $filename, '.' ) + 1 );
     293        return isset( $codepress_supported_langs[$extension] ) ? $codepress_supported_langs[$extension] : 'generic';
     294}
     295
     296/**
     297 * Adds Javascript required to make CodePress work on the theme/plugin editors.
     298 *
     299 * This code is attached to the action admin_print_footer_scripts.
     300 *
     301 * @since 2.8
     302**/
     303function codepress_footer_js() {
     304        // Script-loader breaks CP's automatic path-detection, thus CodePress.path
     305        // CP edits in an iframe, so we need to grab content back into normal form
     306        ?><script type="text/javascript">
     307/* <![CDATA[ */
     308var codepress_path = '<?php echo get_option('home') ?>/wp-includes/js/codepress/';
     309jQuery('#template').submit(function(){
     310        if (jQuery('#newcontent_cp').length)
     311                jQuery('#newcontent_cp').val(newcontent.getCode()).removeAttr('disabled');
     312});
     313/* ]]> */
     314</script>
     315<?php
     316}
     317
    275318?>
Note: See TracChangeset for help on using the changeset viewer.