Ticket #9173 (closed task (blessed): fixed)
Add CodePress syntax highlighting to Theme and Plugin editors
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.8 |
| Component: | UI | Version: | 2.7 |
| Severity: | normal | Keywords: | has-patch needs-testing |
| Cc: |
Description
Attached is a patch to add syntax highlighting to both the Plugin and Theme editors using the aptly-named, yet technically unrelated " CodePress" javascript library.
You'll want to download v0.9.6 of CodePress from here: http://codepress.sourceforge.net/download/codepress-v.0.9.6.zip and put it here: /wp-includes/js/codepress/
Currently, I have enabled highlighting for CSS, JS, PHP, HTML and TXT files. CodePress technically supports a few others, but you can actually only ever edit PHP or CSS files through the current editors, so I figured that was plenty.
After you have the JS in place, apply the patch and load up either editor and you should see syntax highlighting immediately.
You can also load the CodePress library on any other page/plugin/etc using:
wp_enqueue_script( 'codepress' );
Attachments
Change History
beaulebens — 3 years ago
-
attachment
9173.diff
added
comment:1
beaulebens — 3 years ago
BTW: as per the CodePress library, this doesn't work on Safari or Opera, so it just stays the same as currently (normal textarea).
beaulebens — 3 years ago
-
attachment
9173-2.diff
added
Updating patch to avoid problems since documentation lookups were added (#9184). Don't forget to download CodePress itself!
beaulebens — 3 years ago
-
attachment
9173-3.diff
added
New patch prevents CP from loading at all in WebKit browsers (not supported) and also avoids a JS error when CP wasn't cached in your browser. Please test/confirm. Esp on Opera/IE/Chrome
beaulebens — 3 years ago
-
attachment
codepress-js-mods.diff
added
Apply this patch to codepress.js (fixes some WP-specific stuff)
CodePress looks pretty in FF :)
Unfortunately for me, It doesnt support Opera, Fair enough.
However, Its marking the Textarea as disabled for me under Opera.
Seems to work in Opera 9.63 (current stable) but if it fails in 10.0 we will have to exclude Opera too.
Hm, If its working for you under 9.63(Really need to remember i'm running alpha's..) then all should be fine. It'll either be a regression in opera, or a bug in codepress (That i'll investigate myself at some point)
Actually it seem to have a line breaks problem in Opera and some (minor) glitches in FF 3. The latest stable release of CodePress is from couple of years ago and it looks like development has almost stopped.
Perhaps we should switch to CodeMirror that is being actively developed and supports all newer browsers, despite that it's a lot heavier.
I noticed that [10614] adds a couple of functions from the mbstring extension, which is not installed by default in PHP. It looks like where mb_* functions are used elsewhere in WordPress, it checks first to make sure they exist. The same should probably be done here.

Add CodePress support. You MUST download the CodePress library itself separately still.