wordpress logoWordPress is really powerful. It is powerful from the start, but its power also stems from the large offering of plugins it provides. However, I did not found one plugin that did what I wanted: receive notifications when one of your articles is modified by someone else. So I wrote my own, taking another one as a start.

It is very basic and may not be suited for everyone’s need, but anyway, you can download it.

This work is based on the draft notification plugin.

<?php
/*
Plugin Name: Post notifier
Plugin URI: https://www.x2b4.com/
Description: Sends an email to the post author when a post is modified.
Author: x2b4
Version: 1.0a
Author URI: https://www.x2b4.com/
*/

https://www.x2b4.com/based on http:https://www.x2b4.com/www.dagondesign.com/articles/draft-notification-plugin-for-wordpress/

function notification_process($id) {

 global $wpdb;

 $result = $wpdb->get_row("
 SELECT post_status, post_title, user_login, user_nicename, display_name, {$wpdb->users}.ID
 FROM {$wpdb->posts}, {$wpdb->users}
 WHERE {$wpdb->posts}.post_author = {$wpdb->users}.ID
 AND {$wpdb->posts}.ID = '$id'
 ");

 global $current_user;
 get_currentuserinfo();

 if (($result->ID != $current_user->ID))
 {
 $message = "";
 $message .= "A post has been edited on '" . get_bloginfo('name') . "'\n\n";
 $message .= "Title: " . $result->post_title . "\n\n";
 $message .= "Original author: " . $result->display_name . "\n\n";
 $message .= "Editor: " . $current_user->display_name . "\n\n";
 $message .= "Link: " . get_permalink($id) . "\n\n";

 $result2 = $wpdb->get_row("SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} WHERE `post_type` = 'revision' AND `post_parent` ='".$id."' ORDER BY `ID` DESC");
 $message .= "Diff: ".get_bloginfo("wpurl")."/wp-admin/revision.php?action=diff&right=".$id."&left=".$result2->ID;

 $subject = "Post '" . $result->post_title . "' updated on '" . get_bloginfo('name') . "' by " . $current_user->display_name;

 $user_info = get_userdata($result->ID);
 $recipient = $user_info->user_email;
 $headers = 'From: WordPress<wordpress@x2b4.com>' . "\r\n";
 mail($recipient, $subject, $message, $headers);
 }

}

add_action('publish_post', 'notification_process');

?>

wordpress.jpgCa y est, la version 2.3 de wordpress est sortie.

Pas de nouveautés avec cette version, dont notamment un système de tag qui se rajoute et complémente celui de catégorie. Sinon, il est plus rapide, propose plus d’options à l’édition, et normalement se mets à jour quasiment tout seul. Bref, que du bonheur. Comme d’habitude, la procédure de mise à jour prend deux secondes.