Redirections in WordPress [en]

When I moved the Going Solo site away from WordPress.com (which did its job well, btw) so that I could jiggle it around and make the Lausanne and Leeds events into separate sites, I ended up with a whole bunch of URLs like http://going-solo.net/programme which actually referred to the Lausanne event, and needed to point to http://lausanne08.going-solo.net/programme.

If you’ve been reading me for a while, you probably know that I’m not shy to go and fiddle around with my .htaccess file, but I’m also getting increasingly lazy as the years go by. So, here are two WordPress plugins (well, one isn’t strictly a plugin, but let’s not get tangled up in semantics) which can come in handy:

  • Redirection plugin: use this when you just need a 301/302 (prefer the latter) redirect/move — if you head to http://going-solo.net/programme, you’ll see it at work. It has a handy interface to let you manage all your redirects, and also does 404 logging for you. I’ve discovered (and fixed) quite a few broken links since I installed it.
  • “Redirect to” page template (thanks, Mark): this is actually a page template which does nothing but redirect somewhere else. I use it on the main Going Solo site to create navigation tabs to Lausanne and Leeds which redirect to the other sites. Create a page with the right title, select “Redirect” as the page template, and add a custom field named “redirect” with the destination URL as value.

Have fun!

Trying the Seesmic Video Plugin [en]

[fr] J'essaie le plugin seesmic pour mettre de la vidéo dans mes articles. Il paraît qu'on peut laisser aussi des commentaires vidéo!

When I visited Seesmic in San Francisco, Loïc told me they were working on a video comment and posting plugin.

Here I am, trying it out.

{seesmic_video:{“url_thumbnail”:{“value”:”http://t.seesmic.com/thumbnail/NrZQ4aKmSu_th1.jpg”}”title”:{“value”:”My First Seesmic Video Post with the WordPress plugin.”}”videoUri”:{“value”:”http://www.seesmic.com/video/0i66jwr6zE”}}}

Becoming a Professional Networker: Tags in Address Book OSX Needed! [en]

[fr] Besoin, de toute urgence: plugin Address Book.app permettant de taguer ses contacts.

For some time now, I’ve been aware that I’m becoming a professional networker. Almost all I do to promote Going Solo, for example, relies on my reputation and the connections I have to other people.

Now, I’ve never been somebody to collect contacts just for the sake of collecting contacts, but until LeWeb3 last year, I had just been content with butterflying around and stacking business cards somewhere near by desk. At LeWeb3, when I started telling people about Going Solo, I also started realising that the people I met and contacts I made were going to have more importance for my business than before.

And if I’ve learnt something during these last two months, it’s the importance of getting back to people. I’ve figured out how iGTD and GMail can play nice together to help me with that, but it’s not sufficient. I need to keep track of who I’ve asked what, of who can help me with what, who has this or that connection. And yes, I have too many people in my business network to keep everything in my head.

As I explain in the video above, the lovely Cathy Brooks put me on the right track: use Address Book.app. I don’t really need to keep all the contact details related to a person close at hand (ie, phone number, e-mail, etc.) because I have that in LinkedIn, Facebook, GMail address book, or on business cards. I’m not interested in keeping an exhaustive repository of all the contact details of all the people I’ve met. What I’m interested in, however, is keeping the names of these people somewhere I can attach meaningful information to them.

Where we met. What we talked about. Stuff that’ll help me remember who people are.

So, I started simply adding names (Firstname Lastname) into my OSX address book, along with a few words in the Notes field. The nice thing about the Notes field is that you don’t have to toggle edit mode on to add stuff in the Notes. So, of course, I started using the notes field to tag people. Not too bad (smart folders allow me to “pull out” people with a certain tag) but not great either, because tags get mixed up with notes, and it’s a bit clunky.

Somebody suggested I create a custom “Tags” field (a “Names” type field is fine). Unfortunately, though this looks like a good idea at first, it fails because you have to edit a contact each time you want to add tags. Also, you can’t create a smart folder based on the contents of that field — you need to search through the whole card. Clunky too.

I don’t know how to write Address Book plugins, but I know they exist, and I have an idea for a plugin that would save my life (and probably countless others) and which doesn’t seem very complex to build. If there’s anybody out there listening… here’s a chance to be a hero.

I want a “tag your contacts” plugin for Address Book.app. What would it do? Simple, add a “Tags” field that behaves similarly to the “Notes” field. That would allow me to separate notes and tags — they aren’t quite the same thing, don’t you agree?

In addition to that, the plugin could display a list of all contacts tagged “thisorthat” when you double-clicked the tag. That would be nice.

Does anybody else want this? Does it already exist? Would anybody be willing to build it? (If other people are interested, I’d be willing to suggest we pool some cash to donate to the kind person building this life-saving plugin.)

Bunny's Print CSS Plugin Upgrade [en]

[fr] Deuxième version de mon plugin pour insérer automatiquement une feuille de style impression dans n'importe quel thème WordPress. Il y a maintenant un panneau d'administration qui permet d'éditer le CSS directement depuis WordPress -- et le CSS en question a été enrichi.

The little print CSS plugin I threw together the other day has had a little upgrade already, and is also now available in the WordPress plugin directory.

First, Kjell Knudsen was kind enough to add to the very basic CSS file I provided with the plugin. It’s now a little richer and should support K2, for example. It’s still open to improvement, so don’t hesitate to link to your propositions in the comments! Maybe at some point I’ll be able to offer more than one stylesheet with the option to choose between them.

Option? Oh yes, option. Because, you see, Print CSS now has an option panel. I’m pretty happy, because it’s my first plugin with an options panel, and I’ve been thinking I should learn how to do that for some time now. The options panel doesn’t do much, however: it simply allows you to edit the print CSS file through the WordPress admin area (if the file permissions are right — chmod 777 or something).

I’d like to extend all my thanks to Yaosan Yeo, who wrote the MyCSS plugin. I heavily lifted the code for the admin panel from it, as it does essentially the same thing: allow the user to edit a CSS file. I’m really loving MyCSS by the way, even if there is a little capitalization glitch in it, because I’m always adding CSS to my themes and it’s a real pain to copy-paste it all over the place each time I switch themes (or from one blog to another).

Off you go now, check out Bunny’s Print CSS in the WordPress plugin repository!

Bunny's Language Linker: New WordPress Plugin [en]

[fr] Un nouveau plugin WordPress que je viens d'écrire. Celui-ci vous permet de gérer les liens entre pages équivalentes de deux versions linguistiques d'un site. Par exemple, si vous avez http://stephanie-booth.com/en et http://stephanie-booth.com/fr (deux installations WordPress séparées!), le plugin vous aidera à faire en sorte qu'il y ait des liens entre http://stephanie-booth.com/en/about et http://stephanie-booth.com/fr/a-propos.

Ladies and Gentlemen, I’m proud to announce the WordPress plugin Bunny’s Language Linker (zip, phps).

I’ve been wanting to write this plugin for ages, and I’ve finally done it this evening. This is a plugin for people who have a WordPress site with content duplicated in more than one language, like I’m going to have with stephanie-booth.com. For example, you have an “about” page in English, and another “about” page in German. This plugin helps you create and manage links between such “sister” pages. (“Pages”, not “posts”. It doesn’t work with posts at all.)

The plugin adds an extra field to the page editing form, inviting you to input the page slug of the sister page:

Bunny's Language Linker - Admin view

The screenshot is a bit small, but there on the right, there is a little box with “a-propos” — the slug of the French sister page. It works with more than one other language, too. You just need to edit the settings in the plugin file to specify which languages you’re playing with (instructions are in the plugin file). If I had sites in 3 other languages, say French, Spanish, and German, my settings line in the plugin file would look like this:

$bll_other_languages=array('fr', 'es', 'de');

And the little box would provide three different fields for the page slugs of the different localized sites. (OK, I’m making this sound complicated, sorry.)

The plugin then automatically adds links to the sister pages you’ve indicated. Here’s what it could look like:

Bunny's Language Linker - Page view

There’s a readme file with the plugin which will give you some more details. I’ll soon have a client site in production using that plugin, so if these explanations weren’t very clear, hopefully the demonstration will help.

Nasty Problem With Basic Bilingual Plugin [en]

[fr] Un problème avec le plugin Basic Bilingual qui fait disparaître les extraits dans "l'autre langue". Je bosse sur une solution (voir commentaires).

Heck. I just spent the last 15 minutes digging through the Google cache to retrieve “other language excerpts” which had been wiped from a good dozen of my recent posts. Not all of them, mind you — almost all of them. I haven’t yet managed to reproduce the problem, but clearly, the meta fields get reset in some circumstances.

I suspect it might be something that has to do with editing posts. Maybe related to the old disappearing tags problem?

In any case, I’m afraid Basic Bilingual must be misbehaving. Be particularly cautious when editing posts. Let me know if you have the same problem or a path to a fix — I’m working on it now.

Update: if somebody has the French excerpt to my post Advisors, Boards, Companies, Partners, Oh My! in their newsreader or browser cache, could you please send it to me or copy-paste it here as a comment? Thanks a lot.

Update, 17:30: I think I solved the problem (see comments) and corrected the files available on my server, bumping up the version to 0.31. Please download the latest version if you’re using this plugin.

Ridding WordPress Plugins of Template Tags [en]

[fr] Cet article décrit une méthode permettant de se défaire des "template tags" qu'utilisent certains plugins. Plutôt que de copier le fameux template tag à 3 endroits différents dans son thème (comme c'était le cas auparavant pour Basic Bilingual), il est possible de modifier à peu de frais un plugin pour qu'il injecte automatiquement son contenu dans le blog.

If you’re like me and use a bunch of plugins to liven up your WordPress blog, you’ve probably noticed that adding template tags in your favourite (or favourite-of-the-week) theme files can quickly become a royal pain in the neck.

One of the things I wanted to do with Basic Bilingual, and which I did with the last release, was make the plugin inject the text for the “other excerpt” (the French text you can see at the top of this post) automatically into the templates and feeds.

Once I’d figured out how to do that, I realised I could modify other plugins, too. And I’m going to tell you how you can do it, too. This method should work for any plugin which generates a template tag, as long as you want the content generated by the plugin to go immediately after or before the post content. (I’m still working on advanced rules for cases where you want to make modifications elsewhere in the template.)

Christine‘s Inline Tag Thing put me on the track (thanks!), as it does just that. Here’s the trick:

  1. create a function which concatenates (= “adds”) the plugin output to the content
  2. add an action hook to the plugin to apply that function to “the_content”.

Fear not, I’ll explain all. You don’t need to really know much PHP to do this, as long as you’re comfortable wading through a bit of code and copy-pasting stuff and making a few small modifications.

Let’s take an example: the Similar Posts plugin, which I’m now using to point out posts related to the current one (normally, in a box at the top of the post if you’re on the website, and as a list at the end of the post if you’re reading the feed).

Similar Posts provides a template tag, <?php similar_posts(); ?>, which you can paste in your template where you like the related posts to appear. Personally, I want them to appear on the main blog page, on the individual archive pages, and on the monthly, category, and taggy archive pages. This means I need to paste the tag into at least 3-4 different template files. And if I decide that I want the tag at the top of the post rather than the bottom, or I decide to remove it, there I go again. Not optimal.

So, here’s how I made it “better” (for me):

A. First, I looked at the plugin code to figure out where the template tag function was; in this case, quite easy, it’s the function called similar_posts(), logically. Here are the last two lines of this function, which do the actual data output:

print $result;
if (defined('POC_CACHE')) print $cache_time;

I changed them to:

return $result;
if (defined('POC_CACHE')) return $cache_time;

So that they didn’t print directly (ie, output text), but just return the value of the data we want to insert.

Then, I created the following function:

function sp_embed_similar_posts($content) {
    $content = similar_posts() . $content;
    return $content;
}

This function takes one parameter ($content), and sticks the output of similar_posts() in front of it. Now you see why we needed to change the other function so that it didn’t print. We’re just modifying the value of the $content string. This new function returns the modified value for the content (in our case, imagine it as being the content of your post with the code for the similar posts listing stuck in front.

Now all that is left to do is to tell WordPress to actually use that function at some point (plugins are usually a collection of functions, followed by a series of “hooks” which actually execute the functions at certain chosen moments). Here’s the action we’ll use:

add_action('the_content', 'sp_embed_similar_posts');

Try it!

This will also add the list of similar posts to the feed.

So, in summary, here is what we have done:

  • modified the template tag function so that it returns a value instead of printing it (in some plugins, you’ll find a function that already does that!)
  • created a function to stick that value on the beginning or end of a parameter, $content
  • add an action hook on the_content to execute the function.

Happy hacking!

Basic Bilingual 0.3 for Multilingual Blogging [en]

[fr] Une mise à jour de mon plugin "Basic Bilingual" qui permet de rendre WordPress bilingue. Modification majeure: il n'y a plus besoin de bidouiller son template pour faire apparaître l'extrait du billet dans "l'autre langue". Par contre, c'est toujours nécessaire pour rajouter les attributs lang.

Long overdue, an upgrade of my plugin Basic Bilingual. Grab the tgz archive or check out the code.

Some explanations. First, you all know of my long-standing interest in all things multilingual and in multilingual blogging in particular.

Years ago, I switched to Movable Type and then to WordPress because I was blogging in two languages. Movable Type allowed me to assign more than one category to each post — so I used two huge categories, fr and en, to indicate what language I was blogging in. This soon made the rebuilds a real pain in the neck, and WordPress allowed me first of all to happily hack it into being multilingual, and then actually write a plugin to do it in a cleaner way. The plugin hasn’t changed much since, and this upgrade isn’t a major one, but it’s a step in the right direction.

Ideally, I’d like people to be able to use the plugin without having to modify their templates at all. I’d also like the plugin to allow filtering out one language if that is what the reader desires. I still hope that WordPress will one day “see the light” and let us define language at post-level (Matt saw the light for tagging ;-), so I do have hope). By the way, I stumbled upon this Ajax Language Switcher for Basic Bilingual earlier today, and it will probably greatly interest those courageous ones of you who tend to have translations of each post or page.

Back to the plugin. It installs normally (unzip everything in the /plugins directory). If you’re using other languages than French and English, you’ll have to manually change the language codes in the plugin file (not very difficult, you don’t have to know PHP to do it; just look for “en” and “fr” and put the language codes for your languages instead).

I’ve fixed an annoying problem with slashes that popped up at some point (somebody else gave me the fix, but I can’t remember who — let me know!).

But most of all, I’ve made the “other language excerpt” appear automatically in the post content. Yes, you hear me: no need to add <php bb_the_other_excerpt(); ?> in your templates anymore. Yay! Added bonus: it will show up in the feeds, too — for that reason, I’ve added a text separator between the excerpt and the post so that there is a separation between the languages.

Basic Bilingual in Google Reader

Obviously, you’ll want to hide these separators and style your posts a little. Here is roughly what I’m using right now:

.other-excerpt {
font-style: italic;
background: #fff;
padding-left: 1em;
padding-right: 1em;
border: 1px solid #ccc;
}

.other-excerpt:lang(fr) p.oe-first-child:before {
content: "[fr] ";
font-weight: bold;
}

.other-excerpt:lang(en) p.oe-first-child:before {
content: "[en] ";
font-weight: bold;
}

.bb-post-separator {
display: none;
}

div.hentry:lang(fr) .entry-title:after {
    content: " [fr] ";
    vertical-align: middle;
    font-size: 80%;
    color: #bbb;
}

div.hentry:lang(en) .entry-title:after {
    content: " [en] ";
    vertical-align: middle;
    font-size: 80%;
    color: #bbb;
}

Now, notice there is fancy stuff in there which relies on the lang attribute. If you’re mixing languages on a page, you should use the lang attribute to indicate which language is where. This means (unfortunately, until I become buddies with PHP’s ob_start() function) that you need to touch your template. It’s not that hard, though.

Find the outermost <div> for each post in the template (it should have the CSS class hentry, by now). Add this inside the tag: lang="<?php bb_the_language(); ?>". Do so on every theme template which produces posts. With the Sandbox theme, it would look like this:

&lt;div id=&quot;post-" class="" lang=""&gt;

That’s it!

If you’re using this plugin, please leave a link to your blog. I’m also always interested in hearing of other examples of multilingual blogging or multilingualism online.

WordPress Finally Has Tags! [en]

[fr] Après des années d'errance, WordPress implémente enfin un système de tags qui ne sont pas des catégories. Un billet un peu plus complet en français s'impose probablement. Qu'en pensez-vous?

I’ve known for some time that version 2.3 of WordPress would support real tagging. Today, Matt has just announced the deployment of tagging on WordPress.com.

From the start, I’ve been a very vocal supporter of the differentiation between tags and categories — and I really appreciate Matt acknowledging this in his announcement.

When I first met Matt offline for the first time nearly a year ago, at Blogtalk Reloaded in Vienna, I jumped on the occasion to pester him about tags and categories. He listened — but I don’t think he was convinced at the time.

A few months later, I was in San Francisco — and one of the first things Matt told me when we met again was “you know, I finally saw the light about tags and categories”. He told me version 2.3 would have both. I was overjoyed. I’ll never know exactly what role I played in Matt’s “seeing the light”, but I like to think I contributed 🙂

Looking back in time, Technorati started indexing tags in January 2005. They weren’t new for me then (I’d been tagging things on del.icio.us since May 2004 and on Flickr since October of the same year) but clearly, being able to tag posts was a great thing. You know me — my brain can’t sit still — two days later, I was rambling about some ways to combine tags in searches/sorting. Some of the stuff I talk about in there isn’t possible yet, but I hope it will someday.

Two days after that, I wrote my first WordPress plugin, Bunny’s Technorati Tags — which became quite popular and which I still use to this day.

I’m really glad to be able to retire this plugin, specially as Peter Westwood has written an importer for it. That means you should have no problems converting your bunny-tags into wp-tags. Thank you very much, Peter.

Bear with me while I dig though my archives: weighted tags by category is something I’d forgotten I’d wanted… does anything like that exist now?

My only gripe with the implementation of tags in WordPress, for the moment, is that they will be comma-separated. No! Please! We’ve been typing space-separated tags into Flickr and del.icio.us for three years now. Three years! When I chose space-separation for the tags in my plugin, it was because the existing interfaces for tags did it like that.

Spaces, please. Or at least an option to input them space-separated. Or a simple plugin. Tags separated by spaces, and multi-word tags between quotes.