The main subject of this blog will be web development and feature some interesting articles and tutorials ranging from PHP and jQuery to HTML and CSS. The problem I was facing when I built this theme was the lack of awesome code highlight plugin. I just couldn’t find one that was working for me.
I thought maybe more people were looking for a plugin that simply publish codes that looks great. I started to write my own, and the FV Code Highlight plugin was born and now open for the public. The features are plain and simple, read on.
Description
This plugin supports the highlighting of PHP, HTML, CSS and XML. The default tag-highlighter color scheme uses the same colors Adobe’s Dreamweaver is using. This makes it easy for your visitors to recognize what type of codes you wrote. These colors can be changed to your liking in the WPadmin section of your blog.
Features
- Easy to use
- Renders XHTML, CSS, XML, Javascript and PHP
- Default look: Dreamweaver style
- Customizable look of the code boxes
How to use this plugin?
- Upload the folder fv-code-highlighter to the /wp-content/plugins/ directory.
- Activate the plugin through the ‘Plugins’ menu in WordPress.
- Place
in your pages to use the highlighter.
Example
CSS Code
1 2 3 4 5 6 7 8 9 10 11 |
/* Comment */
@import url("main.css");
h3, .head2 {
font-family: "Sans-Serif";
font-weight: bold;
color: #336699 !important;
}
@media screen, print {
pre { margin: 0px 10px 10px; }
h1 { font-size: 14px; padding-top: 10px; }
}
|
(x)HTML Code
1 2 3 4 5 6 |
<style type="text/css"> headline {font-size: 24pt;} </style>
<!-- Comment -->
<td><a href="link">Plain Text </a>
<img src="image" alt="" width="15" />
<form action="action.pl"> <input type="submit" value="Press Me" />
</form>Text</td>
|
JavaScript Code
1 2 3 4 5 6 7 8 9 |
/* JavaScript */
function displayWords(arrayWords) {
for (i=0; i < arrayWords.length; i++) {
// inline comment
alert("Word " + i + " is " + arrayWords[i]);
}
}
var tokens = new Array("Hello", "world");
displayWords(tokens);
|
PHP Code
1 2 3 4 5 6 7 8 9 10 |
<?php
mysql_connect ($host, $user, $password);
$result = mysql_db_query ("database","select * from table");
while ($row = mysql_fetch_assoc ($result))
{
echo $row["user_id"];
echo $row["fullname"];
}
mysql_free_result ($result);
?>
|
Bugs
If you find any bug in the latest version of this plugin, I hope you’d be so kind to tell me about it. This will only improve the plugin, which is better for the users! You can do this on the bug reports forum.
Help Needed?
If you need any help, or have problems with this plugin, please create a post on the support forums.
Plugin Info
AUTHOR: Frank Verhoeven
AUTHOR URL: http://www.frank-verhoeven.com/
WORDPRESS VERSION: 3.2+
TESTED UP TO: 3.4
CURRENT VERSION: 1.8
Download
DEMO: Live Demo
DOWNLOAD: FV Code Highlighter
Support
If this plugin is helpful to you, please consider supporting it! You can help it’s development by making a small donation, or promote it by putting a link to this page on your site. Appreciate it!
Awesome plugin my friend! Use it all the time.
Thanks, and thanks again for all your help and support!!
Hi, ur plugin is very nice, i am using it…but this version still not support JAVA. Anyway, i have modify it so that it able to format some simple JAVA code. I am wating for ur next release, hope that coming release ll include JAVA formating.Thanks ya, nice job!
Hey bighead,
Thanks for the compliment!
At this moment I don’t know much about Java, but I will try to get it implemented in the next release.
Thank you for a great plugin Frank!
I got an error I wanted to run by you in case it is a bug. Of course it might just be my fault instead.
When I use the
codeon a code segment it all works well.
When I use the
codeon a code segment I get the error while the blog post is rendering:
Fatal error: Call to undefined function: htmlspecialchars_decode() in /home/itrating/public_html/wp-content/plugins/fv-code-highlighter/phpHighlighter.php on line 19
My WordPress engine is version 2.6.1
Thanks
tmax, thanks!
I guess you’re running PHP 4, since this function only works on 5.1 and up. However, the problem can be fixed!
Open the file phpHighlighter.php with notepad or your favorite text editor (it’s in the fv-code-highlighter directory), and search for the next line:
<?php $code = htmlspecialchars_decode($code, ENT_QUOTES); ?>It should be line number 19.
Now replace that line with this line:
$code = html_entity_decode($code, ENT_QUOTES, 'utf-8');And everything should work perfect!
In the next release this problem will be automatically fixed, since it will get a better PHP highlighter.
Thank you Frank!
I tried exactly what you said. I now get the following error:
“Warning: cannot yet handle MBCS in html_entity_decode()! in /home/itrating/public_html/wp-content/plugins/fv-code-highlighter/phpHighlighter.php on line 19″
Since you mentioned that this will get fixed in the next version I am happy to wait until that comes out instead of pestering you with this, though.
Thank you for the great plugin!
Too bad it didn’t help you
I hope to get version 1.1 ready within three weeks.
Very Good~!!
plug-in isn’t working for me – I’m running wp 2.6.2
I inserted the code
my code herebut it just displays as plain text. This is within an actual blog post. Is this plugin only for pages? thanks
It should work both in pages and posts,
be sure to use the right syntax as described aboveand download the latest version. If that still doesn’t work, please send me an email with your server details, so I am able to find the problem.Another satisfied customer! Works great.
hi!
i can’t use the plugin i have it active but i place the
and i can see the { code} and nothing higlighted
what am i doing wrong?
Hey,
You need to remove the = between code and type. So it becomes {code type=php}.
how can i put javascript theme in this, now days its more javascript then html.. can we have javascript option too please..
As soon as PHP is fixed (it now still has some bugs), I can easily add JavaScript support very easy. So it will come soon
Wow… thanks God ! I found You Franks… FV COde Highlighter it’s So helpfull
GREAT PLUGIN!
great plugin, work perfectly on wordpress 2.7. thanks
Great plugin! Any news on the js support?
I would love to use this plugin, but for some reason it’s giving me a fatal error on activation (Fatal error: Cannot redeclare class FVCodeHighlighting in /…/wp-content/plugins/fv-code-highlighter/FVCodeHighlighter.php on line 13)..
Any idea on what’s going wrong?
Okay, the fatal error is fixed now. Apparently I had an extra folder called trunk which caused this (just re-downloaded and there isn’t any trunk folder in that one.. odd..).
Still isn’t working though..
Great plugin. Cannot wait for PHP to start working. Also is there anything in the works for bash?
I love this Plugin, It’s great…
The colors are great, and its working fine in PHP code…
The only think I will suggest you to add are one or two functions…
A Copy All Button and why not, a Print Button
Well that are just ideas from others plugin…
(Sorry my english, I am from Argentina)
Are you working in more codes like JS C++ and more?
NeatHighlighter.com is a very easy to use highlighter and highlights code in standard colors
This brings me to an idea:…
Same problem as Hiranthi:
Fatal error: Cannot redeclare class FVCodeHighlighting in /home/.sites/***/***/wp-content/plugins/fv-code-highlighter/FVCodeHighlighter.php on line 13
Interestingly enough, the plugin works. All code is being displayed all pretty but the plugin is in the “inactive” category.
Any ideas what went wrong?
I think it doesn’t work with 2.8.4
Вообще, на мой взгляд, самое лучшее в личном блоге, так это самопознание.
Hi Frank, I was wondering if you have intention of extending the code highlight to other languages like ColdFusion (cfml), Flex (mxml).
If not, where could I jump in to modify the highlighting ? I’m a ColdFusion developer and I post codes in my blog.
Thanks for your attention.
Thanks! Good news
thanks for this!
<p>test
Silkroad Online (silk road gold) is a fantasy MMORPG set in the 7th century AD, along the Silk Road between China and Europe. The game requires no periodic subscription fee, but players can purchase premium items to customize or accelerate gameplay.
Silkroad Online is noted for silk road gold its “Triangular Conflict System” in which characters can select from the three jobs of trader, hunter, and thief to engage each other in player versus player combat. Thieves attack traders who are protected by hunters. Hunters kill thieves getting experience to level up to a higher level of hunter. Traders silk road gold complete trade runs to get experience to level up to a higher level of trader, and thieves kill traders and hunters to level up. Thieves can also steal goods dropped by traders to take to the thieves’ den to exchange for gold and thief experience.
Awesome Plugin, had a few niggles but after reading others users comments I had it working in no time CHEERS
Thanks for the compliment!
Great plugin! One question. Can you adjust the width of the code snippit without hardcoding a css value for the span class?
I have been trying to use this plug-in but have not succeeded. I use the syntax mentioned i.e.
CODEBLOCK. The codeblock is displayed but it is not highlighted. I am currently using wordpress version 2.9.2.
wonderful plugin!
Thanks a lot