Code Comments
Sorry, but there are better ways to do this now. This project has been deprecated and is no longer in development. This page will be kept online for archival purposes and in case anyone is still interested in the project despite being no longer maintained.
Recently Kaspars Dambis wrote a blog post explaining how to add the necessary code to your WordPress theme to allow your site visitors to post fragments of code in their comments (wrapped in <code>…</code>) which are automatically encoded instead of them having to convert them to HTML entities such as > and <. I have wrapped Kaspars (extremely handy) code into a WordPress plugin to use on my own site. You can download it below. To see a demonstration of the plugin in action, take a look at the comments section of this blog post.
Download PixoPoint Code Comments plugin Β»
To learn more about the code powering the plugin please visitΒ Kaspars’ blog post.
A beta version is also available.
Ryan says:
Testing out the plugin …
This is a <a href="#" rel="nofollow">link to google</a>
August 31, 2012 at 10:40 pm # //
Ryan says:
Testing it out again π
This is a <strong>strong</strong> tag and this is an <em>em</em> tag
August 30, 2013 at 7:19 pm # //
Theodore Gannon says:
Hey! There’s a corner-case bug in the code for this plugin (which I know isn’t yours, but I figure you’re the one maintaining it). It emerged when the following was posted:
9.5|
\o/
In the original text, there are pipes on both sides of the number, and a space preceding the second line. Both are gone (maintaining vertical alignment), but for what turns out to be entirely different reasons! Note that I am painfully ignorant of PHP so everything that follows is a secondhand description from the guy who fixed it. (Conveniently, the same guy whose post exposed it.)
The pipe is missing because the original code explicitly filters it out, by accident. The culprit is this line, which strips newlines from immediately before and after the
<code>
tag:array("/^[\r\|n]+/i", "/[\r|\n]+$/i"), "",
Kaspar’s intention was clearly for the pipe to be an OR symbol — but I’m told that inside a braced regex block, this isn’t needed and it’s interpreted literally. So it should instead be:
array("/^[\r\n]+/i", "/[\r\n]+$/i"), "",
That fixes the missing pipe, but I found that the leading space was still stripped from line two — this is simply default rendering behavior. Oddly, the person fixing this said that for him it all wound up on one line instead; probably just a difference in environment, and anyway it’s all fixed by the same thing: wrap the final output in
<pre>
as well as<code>
.return "<pre><code>" . htmlentities($matches[1]) . "</
code></pre>";'
This has the side-effect of applying any CSS ‘pre’ formatting to the block, which isn’t necessarily bad but should be taken into account.
November 20, 2013 at 10:30 pm # //
Ryan Hellyer says:
Thanks! I’m a little busy at the moment, but I intend to update this plugin at some point and will try to take your correct into account then.
I’ll get Kaspars to have a poke at it some time too. Neither of us have looked at this thing in a very long time and have both learned a lot since then, so can probably spruce it up a bit.`
Random aside: Kaspars and I who had never met until long after this plugin was made, ended up moving to Norway and working alongside one another in the same office.
November 20, 2013 at 10:39 pm # //
Ryan Hellyer says:
Nice blog design BTW π
November 20, 2013 at 10:40 pm # //
Theodore Gannon says:
Haha, thanks! I knew in advance what I wanted the title to look like, and reviewed a few dozen themes looking for an easy way to implement it. Hellish Simplicity has a nice clean look, and I found it very easy to modify, unlike some others I tried. My only hesitation was lack of menu support, but I don’t think I’ll need it for this blog. Plus, it led me to this great plugin! π
November 21, 2013 at 12:43 am # //
Ryan Hellyer says:
You can add menus to the sidebar π
I considered adding one to the top, but decided against it as I think it would look a little out of place with the rest of the theme design.
November 21, 2013 at 12:51 am # //
Theodore Gannon says:
The downside of using the sidebar for menus is how much space it takes. For example if you have numerous static pages, a menu can give well-organized access to all of them from a single spot on the page. In the sidebar, each page is another line, and it can get unwieldy. But I agree that the overall design is much cleaner this way, and I don’t anticipate ever having enough static pages on this site for it to matter!
This got me thinking, tho… I wonder if there’s a plugin that adds a pop-out menu widget for use in the sidebar? It seems very likely someone’s solved this.
November 21, 2013 at 6:37 am # //
igorlaszlo says:
WP website says that this plugin was not updated since 2 years, i just test it here if it works…
This is a code : my website and this is a link without coding : http://webdesign.igorlaszlo.com
December 29, 2013 at 10:53 pm # //
Ryan Hellyer says:
Not sure what you were trying to test there, but you didn’t add any code tags, just a regular link, which will work fine with a default install of WordPress anyway, no plugin needed.
December 30, 2013 at 8:40 am # //
igorlaszlo says:
Hello Ryan,
maybe i am wrong… i was looking for a plugin which allows people to write codes in wp comments without obligation to correct coding signs to html. I tried to add first a link with <a href=… etc. to show the link with codes but it shows the link without normally.
What do i have to do for that ? What i would like is that someone can put codes for discussion in its comment without beeing obliged to replace all “<" to &.l.t.; and &.g.t.;, if you see what i mean…
I confess, i did not check out your plugin enough, only superficially, i will do it today a bit later when i arrive home…
December 30, 2013 at 11:20 am # //
Ryan Hellyer says:
You need to put the code in <code> tags, then it will appear as raw code. Like this …
This is <strong>bold>/strong>, except it's not, because it's inside code tags
December 30, 2013 at 12:31 pm # //
igorlaszlo says:
So, this is
<a href="http://webdesign.igorlaszlo.com" target="_blank">this is my link</a>
Ok, i see, it works… great, i will use your plugin, this is what i was looking for π And thanks for your answers !
December 30, 2013 at 8:19 pm # //
igorlaszlo says:
So, it does not work… it is a pitty…
December 29, 2013 at 10:55 pm # //
Ryan Hellyer says:
Huh? It should work just fine. If not, I’ll get that fixed ASAP.
testing …
<strong>bold</strong>
December 30, 2013 at 8:38 am # //