### Archive

Posts Tagged ‘WordPress’

## Escaping WordPress shortcodes

July 15th, 2011 No comments

With WordPress 2.5 came the WordPress shortcodes, a simple set of functions to create macros to be used in WordPress posts. Quite a few plugins were developed subsequently to enable escaping of those shortcodes. This is necessary because the shortcode parser, as it tries to interprete everything between square brackets, makes it impossible to include a non-interpreted shortcode such as [gallery] into continuous text.

However, those plugins are actually obsolete. The issue has been fixed with the release of WordPress 2.8. Now there is an official syntax that allows you to escape shortcodes in your posts without the need for any additional pluging.
Simply double the square brackets to allow any shortcode in your post escape the parsing:

    [[shortcode]]


will be displayed as [shortcode] in your post.

Optional parameters to the shortcode are of course still possible, i.e.

    [[gallery link="file" columns="2"]]


will be displayed as [gallery link="file" columns="2"]

Categories: Uncategorized Tags:

## Typesetting formuals with MathJax

July 6th, 2011 No comments

Most hosting providers don’t have LaTeX packages installed on their servers and installing LaTeX yourself is usually only possible on rootservers, which are quite a bit more expensive (and therefore much less common) than regular hosting plans.

However, there is a great project called MathJax, that enables you to display formulas directly inside your wordpress posts without the need to install any LaTeX packages on your server. While you can install the javascript that is used to typeset your formula from either LaTeX or MathML code locally, the easiest way to use MathJax is probably to their content delivery network. For even more convenience, there is even a wordpress plugin that makes typesetting formulas easy as pie.

First, enable the CDN option in MathJax-Latex Plugin Options:

Enable "Use MathJax CDN Server" and save the changes

You can now use regular LaTeX code within your post:

$S = \frac{1}{(1 - P) + \frac{P}{N}}\leq\frac{1}{1-P}$


will be typesettet as

For a more detailed explanation, have a look at the plugin’s description.

Of course, there are quite a few other CDNs, that will typeset your LaTeX formulas. But usually, they just render an image that can be embedded in your post or use flash.
The main advantage of MathJax is that you get your formula as scalable instance that will fit nicely even if you resize your text. You can also access a formula’s source and copy and paste it into your math application (like Mathematica). Have you tried right-clicking the formula above?

Categories: Uncategorized Tags:

## BackUpWordPress plugin produces tarballs containing duplicates

July 18th, 2010 No comments

I’m using BackUpWordPress to do regular database and file tree backups of this blog. Unfortunately, there is a nasty bug in this plugin which may cause the tarball to contain every backuped file multiple times (to be precise, every file except the first one will go into the tarball exactly three times).

The problem is that the . and .. directories may appear in a somewhat random order and not necessarily as the first entries in a directory. This is probably host specific (I encountered this error for the first time after I relocated this blog to another server).

To fix BackUpWordPress v0.4.5, locate line 103 in Directory.php (resides in wp-content/plugins/backupwordpress/Archive/Reader/) and change the while-loop inside the next() function

...
while ($this->source === null || ($error = $this->source->next()) !== true) { ...  like this ...$file = null;
while ($this->source === null ||$file == '.' || $file == '..' || ($error = $this->source->next()) !== true) { ...  Alternatively, you can use the following patch: --- Directory.php.orig 2010-07-17 15:02:56.093238736 +0200 +++ Directory.php 2010-07-17 15:04:10.367237641 +0200 @@ -103,0 +104 @@ +$file = null;

@@ -104,0 +106 @@
+              $file == '.' ||$file == '..' ||



Resources:
http://pear.php.net/bugs/bug.php?id=6546

Categories: Uncategorized Tags:

## WordPress myStat plugin breaks rss feed

May 11th, 2010 No comments

I recently installed myStat to keep track of this blog’s rapidly increasing number of readers. Unfortunately, the plugin break the rss feed. The problem is the plugin’s myStat_footer() function, which does not check if the page is a feed before deciding to insert the myStat footer image into the page code.

To fix myStat v2.6, locate line 475 in mystat.php and change the myStat_footer() function

function myStat_footer() {
global $cmn; if($cmn->getParam("myStat_debug")==1){$cmn->setDebug('FOOTER LOAD');}; echo "<img style=(...); }  like this function myStat_footer() { global$cmn;
if($cmn->getParam("myStat_debug")==1){$cmn->setDebug('FOOTER LOAD');};
if (!is_feed()) {
echo "<img style=(...);
}
}

Categories: Uncategorized Tags:

## SyntaxHighlighter Evolved and line-height

May 9th, 2010 No comments

As you probably know, I’m using SyntaxHighlighter Evolved to post syntax-highlighted code. Some people mailed me, that in some of my posted code the underscores are not visible (although copy&paste works). Well, the culprit is the line-height attribute of the SyntaxHighlighter Evolved cascading stylesheet:

.syntaxhighlighter,
.syntaxhighlighter div,
.syntaxhighlighter code,
.syntaxhighlighter table,
.syntaxhighlighter table td,
.syntaxhighlighter table tr,
.syntaxhighlighter table tbody
{
margin: 0 !important;
border: 0 !important;
outline: 0 !important;
background: none !important;
text-align: left !important;
float: none !important;
vertical-align: baseline !important;
position: static !important;
left: auto !important;
top: auto !important;
right: auto !important;
bottom: auto !important;
height: auto !important;
width: auto !important;
line-height: 1.21 !important;
font-family: &quot;Consolas&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Courier New&quot;, Courier, monospace !important;
font-weight: normal !important;
font-style: normal !important;
font-size: 1em !important;
/*min-height: inherit !important; *//* For IE8, FF &amp; WebKit */
/*min-height: auto !important;*/ /* For IE7 */
direction: ltr !important;
}


Simply increasing the line-height from the default 1.1em to 1.21em in wp-content/plugins/syntaxhighlighter/syntaxhighlighter/styles/shCore.css did the trick.

Categories: Uncategorized Tags:

## Writing long articles w/ TOC

April 26th, 2009 No comments

Saw my last article about RF remotes and Fedora? Noticed the box in the top right corner containing a table of contents? Pretty cool, huh?

This really nice plugin by Hackadelic parses your headings automatically and puts them into a TOC-box. It’s even collapsable and you can change its position through shortcodes within the post.

Categories: Uncategorized Tags:

## Syntax highlighting reloaded

April 22nd, 2009 No comments

Recently (well, yesterday to be exact) I was really sold on a a syntax highlighting plugin for WordPress called WP-Syntax. Basically, I am still. It is still easy to use, looks good and comes with a huge variety of supported languages.

But if you ask the WordPress-guys it isn’t first choice. In their FAQ they point you to Alex Gorbatchev’s syntaxhighligher Google Code project. There are quite a lot of implementations availible including three different plugins for WordPress. So I looked a little closer at SyntaxHighlighter Evolved and I must admit that it is really nice.

public class Hello {
public static void main(String[] args) {
/* This line is highlighted. */
System.out.println("Hello world!");
}
}


Especially the line highlighting is very nice. It doesn’t support as many languages as WP-Syntax, but as I mainly use it for Java snippets that shouldn’t be a major problem.

Categories: Uncategorized Tags:

## Syntax highlighting ftw!

April 21st, 2009 No comments

I just ran into WP-Syntax which is a syntax highlighting plugin for WordPress using GeSHi. It supports a wide range of popular languages (including of course Java!).
Examples? Here we go:

1 2 3 4 5 public class Hello { public static void main(String[] args) { System.out.println("Hello world!"); } }

Pretty cool, huh?

Categories: Uncategorized Tags: