Back online

Ok, my blog is back online after about a year in the meanders of my hard drive. Most of the stuff here is probably out of date, such as the Worpdress plugins, most of them written for pre-1.5 versions. As I don't use WP anymore, I'm unlikely to come up with more stuff, unless I decide to come back to it at some stage.

I think I will now write about other things, what exacly I'm not sure yet...


Wordpress 1.5

I finally updated my other site, salamba.info to Wordpress 1.5 and there's no doubt about it, it's good, very good. The feature I really like is the ability for the plugins to have a configuration page. That was really missing from the previous verions.

Another thing is of course the ability to create "static" pages, for fixed content, although you need a separate template for them. This actually is the minus side for me, the complexification (is that even a word?) of the template system: much more flexible but much more work... <img src=" />


1 Comments on Hacker

This plugin allows you to show some text in 'hacker language', as shown below. The install instructions are repeated below in clear text if you have trouble reading this...

To install this plugin, download the gzip archive, unpack the hacker.php file within and upload it to your wp-content/plugins directory.

Once you have done this, activate it from the admin interface.

Any text between and tags will now show in what I call 'hacker style', or 'hacker language', but there must be a better name for this, so please let me know what it is...

That's it ! Pretty useless, but enjoy it anyway...

One big limitation of this version is that you can only have one block in each post due to regex problems. If you can fix that, please do ;)

Edit: The example doesn't work anymore because I'm not using Wordpress at this time. However, you can still download it (I hope ;).


5 Comments on A note to users of StatTraq extensions

The Problem

I have noticed that a little problem in StatTraq gives some trouble to my plugins using it. The problem is that when you use a permalink structure where the post id is not included, such as this one :

 /%year%/%monthnum%/%day%/%postname%/

The post id is not added to the statTraq table in the 'article_id' field. This causes the 'page views' StatTraq report to show only 'Mixed' page views, not the actual posts viewed by your visitors. It also confuses the hell out of my Popular posts plugin, forcing me to use mad hacks to have it report the correct thing... The solution is in fact quite simple.

The Solution (I hope)

In the stattraq.php file, there are the following lines (25 and 26)

if (($p != '')){
$p = intval($p);

But the $p variable only exists if the posts has been selected by id. If it has been selected by name, $p is null.

The variable that is passed in all cases (as far as I know) is $post, which is an object containg the posts data. So I changed the lines above for those :

 if (($post->ID != '')){
 $p = intval($post->ID);

And that seems to do the trick for all rewrite setups.


Referrer Spam

As you've probably seen on this blog if you've been here in the last few days, I have been subject to a case of referrer spam, made very useful by my use of the Referrer plugin.

I managed to delete most of these references to web sites of dubious content by going through the StatTraq table and eliminating all references to the particular IP address using these methods. That solved the immediate problem, but it could come back tomorrow and do the same thing. So I banned that IP address from submitting it's referrers to StatTraq. This was fairly easy to do: just adding the following line at around line 38 in the StatTraq plugin:

 if ($ipAddress=='217.159.201.131') $referrer='';

That should do the trick for this address. To be sure it doesn't happen anymore, I also banned referrers containing some words, giving this kind of rule :

  if ($ipAddress=='217.159.201.131' || ereg("Let|me|spare|you|these",$referrer)) $referrer='';

Another method I used is modify the Post Referrers plugin to use a Google redirection to link to the referers, so that spammers can't take advantage of my pagerank, which might hopefully deter them. Or am I too optimistic?

I hope that should do the trick. Please leave a comment if you notice that kind of stuff again, just in case I didn't pay enough attention...


11 Comments on Popular Posts Wordpress Plugin

This plugin is another StatTraq extension of my creation, so do not forget to download StatTraq. It simply pulls the most viewed post from the StatTraq table and displays them using the format of your choice.

Download the gzip archive (or view the source)

Extract the file and upload it to your wp-content/plugins directory, then activate from your admin interface.

To use the plugin, you must use the 'popular' function in your template, like this:

  <?php 
 popular('string',int);
 ?>

Where 'string' is a string representing the output format you want. The following is the default:

 '<li><a href="%u" title="%t">%t (%v views)</a></li>'

In this string, %u will be replaced by the post url, %t by the post title %v by the number of times the post has been read, so you can make up your own format.

The second integer parameter is simply the number of posts you want to display.

Enjoy!

Version History

0.1: Initial release
0.12: Should work with all permalink structures, please let me know if it doesn't. Applies filter for 'the_title'.


5 Comments on External Links Wordpress Plugin

External links:
The little images that appear after an external link on this site used to be created by pure CSS, using the following rules:

.commentlist a[href*="http"], .storycontent a[href*="http"]
{
    padding-right: 12px;
    background: url('/wp-images/ext-link.gif') right top no-repeat;
}
.commentlist a[href*="jfoucher.info"], .storycontent a[href*="jfoucher.info"]
{
    padding-right: 0;
    background-image: none;
}

But, as you may know, this does not work in Internet Explorer. So I decided to write a little plugin that would give a specific class attribute to all external links, so that they can be styled in a manner recognizable to IE.

Languages
Additionally, as this is a bilingual blog, I like to show an language text after each link, like this. I used to do it in pure CSS, like so:

 a[hreflang]:after {
      content:"000a0[" attr(hreflang) "]";
      color:#999;
      background:transparent;
      font-size:0.8em
 }

but you guessed it, it doesn't work in IE, so this little plugin takes care of that as well... All you need to do is add an hreflang="whatever" attribute to your links.

Installation:

  1. Download the gzip file
  2. Extract it
  3. Upload the resulting file to your wp-content/plugins directory
  4. Activate through the admin interface

That's it ! Now you can define styles:

For example:

 /* External links style */
 a.external-link, a.external-link:visited
 {
      padding-right:12px;
      background:url(/wp-images/ext-link.png) right top no-repeat;
      margin-right:0
 }
 /* Hovering external links */
 a.external-link:hover
 {
      padding-right:12px;
      background:url(/wp-images/ext-link-hover.png) right top no-repeat;
      margin-right:0
 }
 /* Language attribute */
 .hreflang {
      font-size:0.8em;
      color:#bbb
 }

3 Comments on Plugin Wordpress : Page Auteur

Cette extension de Wordpress créé une page spécifique pour chaque auteur, qui montre le nombre d'articles publiés, et les données du compte wordpress de cet utilisateur, tels que biographie, addresse du site web, etc... et optionellement l'adresse email (si vous n'avez pas peur du spam...) Il est aussi possible d'afficher un formulaire qui enverra un message l'auteur par email, mais sans que l'adresse soit visible.

Vous pouvez vous en servir comme d'une page ' propos' dans un blog personnel ou pour donner une présentation de chaque auteur dans un site collaboratif.

Pour l'installer, téléchargez le fichier gzip et décompressez-le

Envoyez le fichier résultant dans votre dossier wp-content/plugins et activez le depuis l'interface d'administration.

Pour l'utiliser, écrivez 'author()' dans votre fichier index.php, l ou normalement apparaît le message signalamnt l'absence d'article.

Dans le fichier index.php par défaut, ça ressemble ça :

 <?php endforeach; else: ?>
 <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
 <?php endif; ?>

Remplacez le par :

 <?php endforeach; else:
 author(true, 5,false);
 endif; ?>

Le premier paramètre booléen (optionel) vous permet de choisir si vous souhaitez afficher un formulaire de contact ou pas. 'true' est le paramètre par défault (affiche le formulaire).

Dans les versions 0.2+, le deuxième paramètre permet de définir le nombre de derniers articles afficher. Etabli 0 par défault (ne pas afficher les derniers articles publiés).

Pour les versions 0.22+, le troisième paramètre booléen permet d'afficher ou pas l'adresse email de l'auteur. Cette option est 'false' par défaut (ne pas afficher l'adresse email).

Les textes dans le plugin sont en Français, mais vous souhaiterez paut être les changer. Ne vous gênez pas ;)

Pour faire un lien vers la page de l'auteur, vous devez faire quelque chose comme ça :

 <a href="index.php?author_name=<?php the_author_login(); ?>">
 <?php the_author(); ?></a>

Si vous ne pouvez ou ne voulez pas utiliser les RewriteRules (règles de réécriture d'url Apache).

Sur ce site, j'utilise la règle de réécriture suivante :

RewriteRule ^author/?(.*)/? /index.php?author_name=$1 [QSA]

Donc le lien vers la page auteur est comme ceci :

 <a href="/author/<?php the_author_login(); ?>">
 <?php the_author(); ?></a>

Mais vous pourriez tout aussi bien utliser le règle suivante :

RewriteRule ^a-propos/? /index.php?author_name=login [QSA]

en remplacant 'login' par votre propre identifiant, et créér un lien vers cette page comme ceci :

 <a href="/a-propos/">A propos</a>

1 Comments on Référents de l'article

C'est un plugin pour Wordpress Qui montre les derniers sites d'où sont venus vos visiteurs. Vous aurez besoin du plugin Stattraq.

Installation :

  1. Téléchargez et installez Stattraq.
  2. Téléchargez post_referrers.gz
  3. Décompressez le fichier, en vous servant par example de WinRAR
  4. Envoyer le fichier résultant votre dossier /wp-content/plugins
  5. Activez le plugin dans votre interface d'administration

L'utilisation est simple :

Ajouter le code suivant dans votre fichier index.php

 post_referrers(8, "<li>", "</li>", "Pas encore...", "self");

où 8 est le nombre pe pages référentes afficher, '<li>' est le texte afficher avant chaque lien, '</li>' est le texte afficher après chaque lien, 'Pas encore...' est le texte afficher s'il n'y a pas encore de page référente. La dernière option sert exclure certains sites : En mettant 'self' (défault), les référents internes ne seront pas affichés. Sinon, vous pouvez ecrire une liste de sites ignorer, comme ceci :

 post_referrers('', '', '', '', 'google.com yahoo.com exemple.com');

Pour ne pas afficher les référents sur une page où il y a plusieurs articles, utilisez une condition comme ceci:

 if ($single) post_referrers();

Vous pouvez voir une démonstration en bas des pages de ce blog, et n'hésitez pas laisser un commentaire si vous avez des problèmes.

Version 0.21 : utilisation de la redirection Google pour essayer de diminuer les spams de référents.

English version


2 Comments on Censored Comment Wordpress plugin

Another wordpress plugin. This one shows a user definable text on comments that have been edited or censored. I got the idea from Michael Heilemann complaining about some useless comments on his site.

I would like to have a way of showing which comments have been moderated [...]

Well, there you go, Michael!

Download the source or the same in gzip format and put it in a php file in your wp-content/plugins directory. Activate it from the admin interface. That's it, good to go!

You can change the text that is displayed when a comment has been edited in the plugin source itself, you could even use a small image or whatever...


1 Comments on New generation acronym replacer

This post describes a new kind of acronym replacer, where you don't need to touch a line of PHP to define new acronyms, and can make them link directly to some place. For example, AOL could become AOL.

You can get the plugin here directly.

I haven't tried it myself, so I can't give you an opinion, but it does sound good, doesn't it?


1 Comments on Teaser Style Wordpress plugin

Another useless wordpress plugin from my little factory here :). This one takes the teaser text, delimited between the beginning of a post and the <!--more--> tag, and wraps it in a <div> with class morediv. This then allows you style it differently using your style sheet, doing for example:

 .morediv{
      font-weight:bold;
 }

which is exactly what I have here.

To install it, either put the source code in a php file or get the gzip file and uncompress it.

Upload the resulting file to your wp-content/plugins folder and activate it from the admin interface. That's all there is to it. You can then apply whichever style you want to that block.


30 Comments on Author page wordpress plugin

This plugin shows a specific page for each author, showing the number of posts published and some of the data entered in the Wordpress admin section, i.e. URL, AIM ICQ number, etc... except email! But it can provide a contact form that will send an email to the author's address.

You can use it as an 'About' page for a personnal weblog or to give each author their own page in a collaborative blog.

To install it, download the source code and save it in a php file or get the gzip file and unpack it.

Upload the resulting file to your wp-content/plugins directory and activate it from the admin interface.

To use it put the author() function in you index.php template, where it normally shows the message that there are no posts.

In the default template, it looks like this:

 <?php endforeach; else: ?>
 <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
 <?php endif; ?>

Replace this by :

 <?php endforeach; else: ?>
 <?php author(true, 5); ?>
 <?php endif; ?>

The first optionnal boolean parameter gives you the opportunity to show or hide a contact form for the author. Defaults to 'true' (show the form).

In version 0.2+, the second parameter is an integer an defines the number of latest posts to show. The default is '0'. You may want to change some of the text in the plugin file to your own language.

To do a link to the author page, you have to do something like this:

 <a href="index.php?author_name=<?php the_author_login(); ?>">
 <?php the_author(); ?></a>

if you do not wish to or can't use rewrite rules.

On this site, I use the following rewrite rule:

 RewriteRule ^about/? /index.php?author_name=jonathan [QSA]

With a link to the 'About' page simply like this :

 <a href="/about/">About</a>

On a multiuser blog, you could do this:

RewriteRule ^author/?(.*)/? /index.php?author_name=$1 [QSA]

and so the link to the page is like this:

 <a href="/author/<?php the_author_login(); ?>
 <?php the_author(); ?></a>

Version 0.3+ use native Wordpress functions to display the author data, making it more compatible (I hope) with future versions of Wordpress.

En Français


Wordpress and StatTraq

StatTraq seems to be getting more popular. Another Wordpress plugin using it has been published by Rich Boakes. It gives the number of times that a particular post has been viewed, and is quite attractive. I think I'll be installing it. Also don't forget to take a look at the latest version of StatTraq. A great many improvements.


13 Comments on Referrer Wordpress Plugin

Referrers is a plugin I coded to show the most recent referring urls to a particular post. I had seen the wp-refer plugin from NoPrerequisite but couldn't put it on my blog without hacking because it uses the meta fields to store its data, and as I display the metadata for other purposes in each post, it would get fairly cluttered.

Also, I am using the very good StatTraq plugin, so I thought I could make use of the fact that it already records referrers.

To install :

  1. Download and install Stattraq.
  2. Download post_referrers.php.txt
  3. Rename to post_referrers.php
  4. Or get the gzip file and uncompress it.
  5. Upload the resulting file to /wp-content/plugins
  6. Activate it in your admin interface

Using it is simple:

Add the following code to your index.php file, within the loop

 post_referrers(8, "&lt;li&gt;", "&lt;/li&gt;", "No referrers", "self");

Where '8' is the number of referrers to show, '<li>' is the text to show before each link, '</li>' is the text to showafter each link, 'No referrers' is... you guessed it! the text to show when there are no referrers yet and the last option marks the excluded hosts. If you use 'self', internal referrers only will be hidden. Otherwise, you can write a list of hosts (domain names) to ignore like this: "google.com yahoo.com example. org" and so on...

See it work at the bottom of this page, and leave a comment in case of problems.

Version 0.21 and up use Google redirection to help prevent referrer spam.

En Français


Jumble Up! Wordpress Plugin

You've pbarloby raed taht txet smerwheoe alaerdy :

Aoicncdrg to an Enligsh utsinvriey stduy the oedrr of lettres in a wrod desnot mttaer the only tnhig ttahs iatomnrpt is that the fisrt and lsat leettr of evrey wrod is in the crrcoet piotoisn the rest can be jbmeuld and one is siltl albe to read the txet whuoitt dflfciituy.

This is what the 'Jumble Up!' plugin will do to the commenters which you consider as spammers or trolls, based on their IP address. I took some inspiration from the Disemvoweler plugin for the spam targeting.

Install is not difficult : Download, rename to jumble.php, upload it to your wp-contents/plugins directory and activate it from the admin interface.

Now, to target specific IPs for jumble-isation, open jumble.php and edit the line where it says :
$jumbleIPs = array("0.0.0.0");
and add spammer IPs as such :


28 Comments on Stylesheet Chooser Version 0.2

I had tried for a while to find a way to allow users to choose their favorite theme for this website. I decided to do it as a Wordpress plugin, which I offer today for other Wordpress users. Installing it is quite simple: Download, rename to stylesheet_chooser.php, upload it to your wp-contents/plugins directory and activate it from the admin interface.

To define which stylesheets to use (no, it's not automatic...), you have to define an array called $styles, before you call any of the other functions.You can do it like this, for example :
$styles=array("styles/new","styles/default","styles/no-style"); if your stylesheets are in the styles directory. Omit the '.css' part. The first one in the list will be used as your default style. The plugin will automatically selectthe last part of the path (in this case new, default and no-style) and use them as the text in the selection box.

In the plugin file (stylesheet_chooser.php), change the two lines below to use text in your language:

   <span class="warning"><?php _e("Si votre navigateur en &eacute;tait capable, vous pourriez ")?></span>
 <label for="newstyle"><?php e('Change style...')?></label>

In your template (index.php) you have to insert two functions:

style_link() will insert the style sheets link. You have to put it between the <head> and </head> tags in your template.

The optional parameter - for example style_link(false) - can be set to 'true' (default) if you want to @import the style sheets (ignored by NS4), or to 'false' to get this kind of links: <link rel="stylesheet" title="....> for the current chosen style sheet and like this: <link rel="alternate stylesheet" title="....> for the other(s).

style_chooser() will insert the form that is used to select the stylesheet. Place it wherever you want, in your sidebar for example.

In version 0.23+, it is possible to have a short comment appear below the selection dropdown. For this, the only thing you have to do is insert it in your stylesheets like this:

/*
Comment: Write your comment here.
*/

And that's it, now each stylesheet has it's own "introduction text".

Now that you know all this, you can :