Ron Fredericks writes: In my last two posts:
- I discovered Dean Lee’s Code Highlighter plugin for WordPress as the blogging solution for my source code display needs.
- I fixed a word wrap problem in Dean’s plugin.
During my research to solve the word wrap problem, I discovered a few more issues leading me to update Dean’s plugin with the latest version of GeSHI (an open-source project: Generic Syntax Highlighter for php. Highlight many languages, including PHP, CSS, HTML, SQL, Java, Assembler, and C for XHTML compliant output) and removal of unused files. I thought other WordPress bloggers might like to take advantage of the latest code too, so I document the steps needed to build a clean plugin with the latest components.
Flow Chart / Swim Lanes Widget
Below is a Flash widget I built to document the steps needed so you can roll your own up-to-date plugin. Follow these steps and you won’t have to be a programmer to get the benefits from the latest versions of these program components. The widget actively links to the latest PHP files and CSS classes:
Why Roll Your Own Plugin?
I have been working with components and tools on various projects long enough to realize a common problem. Whenever components are used from different projects, such as Dean’s plugin integrated with the GeSHi language components, each file and/or component continues to receive bug fixes and enhancements in real-time without regard to the other components and files. This is natural because each componentâ€™s project is managed by a different group.
So now I have an idea on how to fix this evolving problem of diverging code bases: create a flow-chart showing how to assemble the individual components into a final product. Use swim-lanes to highlight the different component resources being used. Document the whole work-flow into a Flash document so links to other web pages and/or live video’s can be included as hot-links to demonstrate the process.
Detailed Notes on the Problems Solved Here
Here are the issues I solve in this blog post:
- The version of GeSHi included with Dean’s code-base is now obsolete. The latest version of GeSHi includes a few bug fixes and a few new supported languages for syntax highlighting. By the time you read this blog post, perhaps GeSHi will have yet an even more improved and stable code base.
- One of the optional modules supplied by GeSHi, PHP samples found in the “contrib” directory; include a recently-identified security risk if included on a web server – such as your WordPress blog installation. Dean’s plugin includes this GeSHi directory by default.
- Dean’s plugin also includes a Mac temporary file called .DS_Store that is not used by WordPress either.
The Components and Their Versions
Deanâ€™s original code has the following versions:
- WordPress should be version 1.5 or later
- Deanâ€™s Code Highlighter v1.1
- Download link:
- Deanâ€™s code includes the following GeSHi components:
geshi.php, contrib and geshi directories
- CSS classes for WordPress template style.css file
My rebuilt version of Deanâ€™s plugin has the following components and version detail:
- I’m using Worpress version 2.0.4
- geshi.php, and geshi directory
- New CSS classes for WordPress template style.css file
Version 1.0 from Embedded Components
A Final Note
The GeSHi code base continues to go through updates. At some point the logic behind my approach – mix and match the latest code from all resources required for Deanâ€™s WordPress plugin â€“ might break down. Perhaps GeSHi will adopt a new interface thatâ€™s not suitable to Deanâ€™s WordPress plugin code, for example. In any case, if you are having trouble getting Deanâ€™s plugin to work, I suggest the following:
Revert back to Deanâ€™s complete code base. Install it as he suggests and try it. If Deanâ€™s original code base does not work, then maybe you are not following the install instructions correctly or perhaps WordPress itself is at an incompatible version. If the plugin works, then try replacing code one step at a time. With each new file change, try your updated WordPress plugin to see if it still can be deactivated, reactivated, and highlights code correctly in a blog post. When the offending component has been identified, let me know so we can work out a new swim-lane diagram for others to follow.