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


Idec en route vers Cadix.

Francis Joyon, sur Idec, va tenter d'établir un nouveau record Cadix - San salvador (Bahamas) sur un parcours que l'on appelle la 'Route de la découverte'

Francis est « [...] sur le trimaran matin, midi et soir, je n'arrête pas de bricoler, car il y a toujours une foule de petites choses faire » Il fait tout lui même, sur un bateau qui est censé être mené par un équipage de gaillards surentraînés et pris en charge par une équipe terre imposante...

Il part prochainement de La Trinité afin de se placer en stand-by Cadix. Aucun temps n'a encore été établi sur ce parcours en solitaire, et la seule référence est le record de Playstation, bateau plus grand mené par un équipage au complet. Francis ne pense pas pouvoir battre ce record, mais essaira de « [...] (s') en approcher, dans la mesure du possible ».


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.