No image Organize Series plugin database optimization

While looking for posts in the series, this plugin makes two database queries for each post in the series : one to find out if the post is published, and another to get the part number in the series. So if you have 30 posts in the series, you will get 60 queries from this plugin alone on each post belonging to that series. I found this very wasteful, and rewrote one function so that it only uses one database query, no matter what the number of posts in the series. I think the author should be interested…

Basically, in the file series-utility.php, replace the function
function get_series_order($posts, $postid = 0, $skip = TRUE)
by the following one :

<?php
function get_series_order($posts, $postid = 0, $skip = TRUE) {
global $wpdb;
if (!isset($posts)) return false; //don’t have the posts array so can’t do anything.

if ( !is_array( $posts )
$posts = array($posts);

$series_posts = array();
$key = 0;

foreach ($posts as $spost) {
if (array_key_exists(‘object_id’, $posts)) {
if ($key!=0){
$spost_id .= “,”.$spost['object_id'];
}else{
$spost_id .= $spost['object_id'];
}
} else {
if ($key!=0){
$spost_id .= “,”.$spost;
}else{
$spost_id .= $spost;
}
}
$key++;
}

//Optimized : 1 SQL query instead of 2* number ofposts in series//
$results=$wpdb->get_results(“SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value
FROM $wpdb->posts LEFT JOIN $wpdb->postmeta
ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
WHERE post_status = ‘publish’ AND $wpdb->posts.ID
IN (“.$spost_id.”) AND ener_postmeta.meta_key=’”.SERIES_PART_KEY.”‘”);
/* 208 – fix by Matt Porter – to make sure unpublished posts are not made part of a series */
foreach ($results as $num=>$result) {
//echo “<h1>resultat”.$result->ID.$result->meta_value.”</h1>”;
$series_posts[$num]['id'] =$result->ID;
$series_posts[$num]['part'] = $result->meta_value;
}

if (count($series_posts) > 1)
usort( $series_posts, ‘_usort_series_by_part’ );

return $series_posts;
}
?>

And there you go, a faster blog…

Show comments

No image Amazon Wishlist plugin for wordpress 2.7

Hello all,
After quite a few years out of the wordpress world, I’m back using this great CMS, and of course, I had to rewrite one of my old plugins to work with the widget interface.

Well, the Amazon wishlist plugin was the one I like best, and found really useful, although no-one ever bought me a book ;( (hint hint !)

It does not work through the normal API, but just pulls the wishlist page with curl and parses it. I did that because the amazon API does not allow priority sorting, which I find more than useful. You will need curl for that, though…

The widget is configurable, as you can see from the image on the right.
You can see it in action on this site about renewable energy

Download it!

Show comments

No image Ma vie sur le web

Grâce aux pipes de yahoo, vous pouvez suivre toutes mes interventions publiques sur le web. Il s’agit en fait d’une aggrégation de tous les flux RSS que je produit en un seul, classé par date. J’en ai sûrement oubliés, mais je peux toujours les rajouter par la suite. Liste provisoire :
- Ce blog
- Les Energies Vertes
- Flickr
- Twitter
- et del.icio.us

Show comments
APRIL 17

Et ben quoi ?

Ben quoi alors? C’est pas parce que ça fait trois ans que j’ai pas écris dans ce blog que j’ai plus le droit de le faire quand même ! Je voulais juste écrire que je viens de mettre Wordpress 2.7 sur un site à propos d’énergies renouvelables, qu’on appelle aussi des énergies vertes, et qu’il n’y a pas de doutes, il esté infinimment supérieur au système de blog que j’utilise ici… Comme comparer une 2cv et une C5, je suppose. M’enfin bon, même s’il est plein de bugs et tout simple, c’est mon bébé.

même pas de page “statiques”, non mais vous vous rendez compte ! c’est un vrai blog dur de dur ! Bon enfin tout ça pour dire que si quelqu’un est intéressé par le code source, n’hésitez pas à demander dans les commentaires, je le mettrai en ligne. Je doute qu’il y ai une forte demande étant donné le peu d’intérêt de la chose, mais bon…

Show comments

Hmmm…

I recently installed the latest Wordpress on another website I designed, about renewable energy and it’s really powerful when I compare it to the ridiculous simplicity of this blog I’m using here… If anyone would like to try it, I’ll gladly pass on the source code, though I’m sure I will be so ashamed of showing my poor coding skills to the world… Anyway, leave a comment if you want to take a look at it.

Show comments
MARCH 7

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…

Show comments
APRIL 11

Wordpress 1.5

J’ai finallement mis a jour mon autre site, salamba.info, avec Wordpress 1.5, et pas doute, il est bien, tr?s bien m?me. Un des meilleurs ajouts est selon moi la possibilit? de configurer les plugins. Ca manquait vraiment dans les anciennes versions.

Une autre chose int?ressante est la possibilit? de cr?er des pages “statiques”, pour du contenu hors du syst?me normal du blog, mais c’est aussi un point faible, car le systeme de th?mes est devenu plus complexe. C’est plus flexible, mais en m?me temps plus de travail… ” />

Show comments
MARCH 17

Nouveau projet

Super, je viens de finir un projet qui me tenait coeur, un petit cat boat de 5 mètres, de croisière cotière et de raid pour deux personnes. vous trouverez plus de détails sur la page du CC5

Enfin bref, vu que c’est un peu plus calme en ce moment, j’ai décidé de faire un peu de stock (concevoir des voiliers ou cas ou un client serait interessé par quelque chose de similaire) pendant mon temps libre, et mon dévolu est tombé sur un vieux projet que je n’avais jamais mené à terme, la “barcasse”. C’est une petite plate de 3m50 environ, avec une voile au tiers, pour de la petite balade dans des eaux traquilles. Je suis sûr qu’il y en a qui traverseraient l’atlantique dessus, mais bon, l n’est pas le propos ” />.

J’aimerais le proposer en téléchargement gratuit sur marinetechs.com pour voir un peu les réactions qu’il peut y avoir…

Show comments
MARCH 14

Feeds

In case you’re using a syndication software that can read RSS2.0 feeds, and if you don’t like the layout of this blog ” /> I offer syndication feeds for its content as well as the comments posted on the posts. You can get feeds for the comments on individual posts from the link at the top of the comments section:

The main feeds are:

The entries rss feed

and the comments feed.

New! the My Life feed let’s you know everything I do on the web.

Show comments
MARCH 10

Captcha

Ok, I finally got the captcha working. Wasn’t that hard, but it was more the concept that was kind of eluding me… Where to send the data from the image and from the text box, how to compare them and so on.

I like the way my little script works, because if for whatever reason the commenter didn’t fil the captcha field properly, they wil be sent an email containing a link allowing them to publish their own comment. I’m wondering if spammers would learn how to make their robots do that… Anyway, doesn’t matter because I haven’t had a *single* comment spam since I changed over from wordpress yesterday. Wait and see, I guess.

Show comments