<?php
/*
Plugin Name:  Deliciousizer
Version: 0.1
Plugin URI: http://anti.cute-ninjas.com/
Description: Post new posts to del.icio.us
Author: Andreas Neukoetter
Author URI: http://anti.cute-ninjas.com/
*/

$DEL_USER="YES";
$DEL_PASS="SURE";

require_once(
'includes/class.delicious.php');

function 
delicious_add$user$pass$link$title$tag )
{
    
//$url = "http://$USER:$PASS@del.icio.us/api/posts/add?url=$link&description=$title&tags=$tags";
    
$del = new delicious$user$pass );
    
$now strftime"%C%y-%m-%dT%H:%M-%S" );
    
$del->add_post$link$title""$tag$now );

}
function 
post_to_delicious$id )
{
    global 
$wpdb$tableposts$tablepost2cat$tablecategories;
    global 
$DEL_USER$DEL_PASS;

    
$post_title $wpdb->get_var("SELECT post_title FROM $tableposts WHERE ID=$id;");
    
$title "Anti's Blog [".$id."] - ".$post_title;
    
$tags "[wp-anti] [wp-$id] blog";

    
$post_cats $wpdb->get_results"SELECT category_id FROM $tablepost2cat WHERE post_id=$id;" );
    foreach( 
$post_cats as $post_cat ){
        
$post_cat_title $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID=".$post_cat->category_id.";");
        
$tags $tags." ".$post_cat_title;
    }
    
$link get_permalink$id );

    
delicious_add$DEL_USER$DEL_PASS$link$title$tags );

    return( 
$id );
}

add_action'edit_post''post_to_delicious',);
add_action'publish_post''post_to_delicious',);
?>