WordPress Plugin – FV Code Highlighter
Posted by Frank on September 10, 2008The 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 an awesome code highlighter plugin. I just couldn’t find one that was working for me.
I thought maybe more people were looking for a plugin that simply publishes codes that look 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 more. 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 WP Admin section of your blog.
Features
- Easy to use
- Renders PHP, HTML, CSS, XML, Javascript and more
- Customizable look of the code boxes
How to use this plugin?
- Upload the folder
fv-code-highlighter
to the/wp-content/plugins/
directory. - Make sure the cache dir
/wp-content/plugins/fv-code-highlighter/cache
is writable by your webserver. - Activate the plugin through the ‘Plugins’ menu in WordPress.
- Choose your preferred settings on the options page: WP Admin > Appearance > Code Highlighter.
- Place your code between
<pre lang=codetype>...</pre>
tags to use the highlighter.
Example
General Code
<pre>...</pre>
:
extension String { |
|
var banana : String { |
|
let shortName = String(characters.dropFirst(1)) |
|
return "\(self) \(self) Bo B\(shortName) Banana Fana Fo F\(shortName)" |
|
} |
|
} |
|
|
|
let bananaName = "Jimmy".banana |
CSS Code
<pre lang="css">...</pre>
:
/* 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
<pre lang="html">...</pre>
:
<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.php" style="border: 1px solid #eee;"> |
|
<input type="submit" value="Press Me"> |
|
</form> |
|
<p>Text</p> |
|
</td> |
|
<script type="text/javascript"> |
|
if (document.getElementById('hi')) { |
|
window.alert('Hello World!'); |
|
} |
|
</script> |
JavaScript Code
<pre lang="javascript">...</pre>
:
/* 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
<pre lang="php">...</pre>
:
<?php |
|
/* Connect to a MySQL database using driver invocation */ |
|
$dsn = 'mysql:dbname=testdb;host=127.0.0.1'; |
|
$user = 'dbuser'; |
|
$password = 'dbpass'; |
|
|
|
try { |
|
$conn = new PDO($dsn, $user, $password); |
|
$sql = 'SELECT name, color, calories FROM fruit ORDER BY name'; |
|
|
|
/* @var array $row */ |
|
foreach ($conn->query($sql) as $row) { |
|
displayFruit($row['name'], $row['color'], $row['calories']); |
|
} |
|
} catch (PDOException $e) { |
|
echo 'Connection failed: ' . $e->getMessage(); |
|
} |
|
?> |
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: https://frankverhoeven.me/
CURRENT VERSION: 2.1.2
WORDPRESS VERSION: 4.0+
PHP VERSION: 7.0+
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!
Hi there,
Where must I put the code. I would like to use it on wordpress theme editor. I put the code on theme-editor.php, but I can not see any difference.
Thanks
Valentin
Hi,
first of all thank you very much for this great plugin.
And I have a question, why does this plugin write some tags in there which do not exist in my code? Look at the screenshot:
http://emdesigns.de/demo/code1.jpg
and
http://emdesigns.de/demo/code2.jpg
I hope you can help me.
Pingback: 29 Plugin ที่ผมใช้งาน ตอนที่ 1 | krapalm.com | กระปาล์ม ดอทคอม
Pingback: 12 plugin để làm nổi bật code trong WordPress
wonderful plugin!
Thanks a lot 🙂
Pingback: How To Use Tr.im URL shortening with the WordPress Twitter Tools plugin | Leo Lincourt
Pingback: Top Code Edit Plugins For Wordpress « Click on post
Pingback: day 4. Wordpress, code display, and other fun | icebluebanana.com
I have been trying to use this plug-in but have not succeeded. I use the syntax mentioned i.e.
. The codeblock is displayed but it is not highlighted. I am currently using wordpress version 2.9.2.
Great plugin! One question. Can you adjust the width of the code snippit without hardcoding a css value for the span class?
Pingback: WordPress – Snipers » Blog Archive » Wordpress Plugin – FV Code Highlighter
Pingback: 10 Plugins dùng để làm nổi bật code trong bài viết - RubicVn
Thanks for the compliment!
Awesome Plugin, had a few niggles but after reading others users comments I had it working in no time CHEERS
Pingback: Highlighting Code within WordPress: Five Tips | WPTemplates.net | Free Wordpress Themes
Pingback: Du code dans ses billets | Tutoweb
Pingback: 10 Wordpress Code Editor Plugin | WordPressPlanet.com
Pingback: New PHP Highlighter In Town - Frank Verhoeven
Pingback: Afisare de cod Javascript sau Php pe wordpress | Wordpress
Pingback: 12 Wordpress Plugins to Display and Highlight Code within your Blog | VNAMEDIA Sharing Center
Pingback: Kod renklendiriciler | вuяαк кαşıкcı.com - wördpires
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.
Pingback: Bqqmf » Code Highlighter, on dit…
Pingback: 12 Wordpress Plugins To Display and Highlight Code Within Blog
thanks for this!
<p>test
Thanks! Good news 🙂
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.
Вообще, на мой взгляд, самое лучшее в личном блоге, так это самопознание.
I think it doesn’t work with 2.8.4
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?
Pingback: Workpress.net » Blog Archive » How to display raw code in your blog post
Pingback: Kod Renklendiriciler | Code Highlighters | Aruha
Pingback: Interesting Code Highlighters for blogs and websites « Jasper Blog
This brings me to an idea:…
Pingback: Kod Renklendiriciler-Code Highlighters | Blogcularin Mekani