This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WP-CodeBox

Description

WP-CodeBox provides clean syntax highlighting and AJAX advanced features for embedding source code within pages or posts.
It support wide range of popular languages highlighting with line numbers, code download, Copy to clipboard,
collapse codebox,automatic keywords link to API manual and maintains formatting while copying snippets of code from the browser.

It’s provide simple background configuration for highlighter style/formatting customization.
Since the plugin is developing, in the future it will support more options.(CSS option,Keywords display style,Auto Caps/Nocaps,Case Sensitivity etc. )

Basic Usage

Wrap code blocks with <pre lang="LANGUAGE" line="1" file="download.txt" colla="+"> and </pre>

Possible Parameters:

  • lang="LANGUAGE"LANGUAGE is a GeSHi supported language syntax.
  • file="download.txt" – The file will create a code downloading attribute.
  • line="N" – The N is the starting line number.
  • colla="+/-" – The +/- will expand/collapse the codebox.
  • line,file,colla is optional.

More usage examples

About Author

Eric Wang

Usage

Example 1: PHP, no line numbers

<pre lang="php">
<div id="foo">
<?php
  function foo() {
    echo "Hello World!\\n";
  }
  for (\$i = 0; \$i < 10 $i++) {
    foo();
  }
?>
</div>
</pre>

Example 2: Java, with line numbers,collapse codebox

<pre lang="java" line="1" colla="-">
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}
</pre>

Example 3: Ruby, with line numbers starting at 18, code downloading(ruby.txt)

<pre lang="ruby" line="18" file="ruby.txt">
class Example
  def example(arg1)
    return "Hello: " + arg1.to_s
  end
end
</pre><h3>Supported Languages</h3>

The following languages are supported in the lang attribute:

abap, actionscript, ada, apache, applescript, asm, asp, autoit, bash,
blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp-qt, cpp,
csharp, css, d, delphi, diff, div, dos, dot, eiffel, fortran, freebasic,
genero, gml, groovy, haskell, html4strict, idl, ini, inno, io, java,
java5, javascript, latex, lisp, lua, m68k, matlab, mirc, mpasm,
mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle8, pascal, per,
perl, php-brief, php, plsql, python, qbasic, rails, reg, robots,
ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text,
thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, xpp,
z80

(Bold languages just highlight the more popular ones.)

Languages HotLink

Actionscript,ADA,Apache Log ,AppleScript ,ASM ,ASP ,AutoIT,Backus-Naur form ,Bash ,BlitzBasic ,C ,C for Macs ,C# ,C++ ,CAD DCL ,CadLisp ,CFDG ,ColdFusion,CSS ,Delphi ,DIV ,DOS ,Eiffel,Fortran ,
FreeBasic ,GML ,Groovy,HTML ,Inno ,IO ,Java ,Java 5 ,Javascript,LaTeX,Lisp,Lua,Microprocessor ASM ,mIRC,MySQL,
NSIS,Objective C ,OCaml,OpenOffice BASIC,Oracle 8 SQL,Pascal ,Perl,PHP,PL/SQL ,Python,Q(uick)BASIC,robots.txt,Ruby ,SAS,Scheme ,SDLBasic,Smalltalk,Smarty,SQL,T-SQL ,TCL,thinBasic,Uno IDL ,VB.NET,Visual BASIC ,Visual Fox Pro ,Winbatch,X++,XML,Z80 ASM.

Release Notes

1.0 : First internal release; Use GeSHi v1.0.7.20;

1.0.1 : Add View Code AJAX feature;

1.1 : Add simple background configuration for highlighter style/formatting customization;

1.2 : css tuning and option i18n compatible;

1.2.1 : Use GeSHi v1.0.7.21;

1.2.2 : WP 2.5 compatible;

1.2.2.1 : Correct small bugs;Improve the css layout to stick the code header; Contributor:YiXia(http://www.e-xia.com).

1.2.3 : Use GeSHi v1.0.7.22, add the keywords link to API manual option;

1.3 : Jquery toggle, use GeSHi v1.0.8.

1.3.2 : Localization design.

1.3.3 : fixed for “download” “option page”. Spanish by Shakaran/www.shakaran.es

Screenshots

Installation

  1. Upload WP-CodeBox.zip to your WordPress plugins directory, usually wp-content/plugins/ and unzip the file. It will create a wp-content/plugins/wp-codebox/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. Go to Option->Wp-CodeBox set the default setting.
  4. Create a post/page that contains a code snippet following the proper usage syntax.

FAQ

When activate the plugin, popup the error:
“Fatal error: Cannot redeclare class GeSHi in ##/wp-content/plugins/wp-codebox/geshi/geshi.php on line 158”.

Answer:disactivate other Gashi based syntax highlighter plugin first.

Leave your FAQ

Reviews

nice plugin with one annoying issue

Nice plugin but one annoying feature.

When switching from the text view to visual view, it reverts the pre tags to only have the LANG and removes the line= and file= entries so i have to go back through all posts and re add them.

This was resolved by making the changes here in the main.php. Seems the names used in the pre tags cause an issue for html5.
https://wordpress.org/support/topic/plugin-wp-codebox-wordpress-editor-just-keep-lang-attribut/

Read all 1 review

Contributors & Developers

“WP-CodeBox” is open source software. The following people have contributed to this plugin.

Translate “WP-CodeBox” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.