Ticket #9173 (closed task (blessed): fixed)

Opened 3 years ago

Last modified 3 years ago

Add CodePress syntax highlighting to Theme and Plugin editors

Reported by: beaulebens 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

9173.diff Download (4.7 KB) - added by beaulebens 3 years ago.
Add CodePress support. You MUST download the CodePress library itself separately still.
9173-2.diff Download (4.5 KB) - added by beaulebens 3 years ago.
Updating patch to avoid problems since documentation lookups were added (#9184). Don't forget to download CodePress itself!
9173-3.diff Download (4.6 KB) - added by beaulebens 3 years ago.
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
codepress-js-mods.diff Download (477 bytes) - added by beaulebens 3 years ago.
Apply this patch to codepress.js (fixes some WP-specific stuff)

Change History

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

BTW: as per the CodePress library, this doesn't work on Safari or Opera, so it just stays the same as currently (normal textarea).

comment:2   ryan3 years ago

  • Type changed from enhancement to task (blessed)

Updating patch to avoid problems since documentation lookups were added (#9184). Don't forget to download CodePress itself!

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

Apply this patch to codepress.js (fixes some WP-specific stuff)

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

comment:4   DD323 years ago

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.

comment:6   DD323 years ago

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.

(In [10643]) Don't use mb_* functions when initializing CodePress, see #9173

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.