WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#9173 closed task (blessed) (fixed)

Add CodePress syntax highlighting to Theme and Plugin editors

Reported by: beaulebens Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7
Component: UI Keywords: has-patch needs-testing
Focuses: 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 (4)

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

Download all attachments as: .zip

Change History (14)

@beaulebens7 years ago

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

comment:1 @beaulebens7 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).

comment:2 @ryan7 years ago

  • Type changed from enhancement to task (blessed)

@beaulebens7 years ago

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

@beaulebens7 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

@beaulebens7 years ago

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

comment:3 @azaozz7 years ago

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

comment:4 @DD327 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.

comment:5 @azaozz7 years ago

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 @DD327 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)

comment:7 @azaozz7 years ago

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.

comment:8 @filosofo7 years ago

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.

comment:9 @azaozz7 years ago

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

comment:10 @ryan6 years ago

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