Bontiv-Sourceer source code viewer
Root | Help
./wordpress-bontivStaff/bontivStaff.php
<?php
/**
 * @package bontiv_calendar
 * @author Rémi Bonnet (bontiv)
 * @version 0.1.0
 */
/*
Plugin Name: Bontiv Staff
Plugin URI: http://remi.bonnetchangai.free.fr/#
Description: Cet extention permet d'afficher les auteurs du blog dans le volet.
Author: Rémi Bonnet (bontiv)
Version: 0.1.0
Author URI: http://remi.bonnetchangai.free.fr/
*/


function bontiv_staff($args) {
    global
$wpdb;
   
extract($args);

   
$defaults = array(
       
'optioncount' => false, 'exclude_admin' => true,
       
'show_fullname' => false, 'hide_empty' => true,
           
'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
       
'style' => 'list', 'html' => true
   
);

   
$return = '<table border="0" width="100%">';

   
/** @todo Move select to get_authors(). */
   
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");

   
$author_count = array();
    foreach ((array)
$wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row) {
       
$author_count[$row->post_author] = $row->count;
    }

    foreach ( (array)
$authors as $author ) {

       
$link = '';

       
$author = get_userdata( $author->ID );
       
$posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;
       
$name = $author->display_name;

        if (
$posts != 0)
        {
           
$return .= '<tr>';
           
$link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">';
           
$return .= '<td>'.$link;
           
$return .= get_avatar($author->user_email, 30).'</td>';
           
$return .= '<td>'.$link.$name . '</a>';
           
$return .= ' ('. $posts . ')';
           
$return .= '</tr>';

        }

    }

   
$return = trim($return.'</table>', ', ');

    echo
$before_widget;
    echo
"{$before_title}Auteurs{$after_title}</h2>";
    echo
$return;
    echo
$after_widget;
}

register_sidebar_widget('Staff', 'bontiv_staff');

?>
Presented with Bontiv-Sourceer