false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true ); $r = wp_parse_args( $args, $defaults ); extract($r, EXTR_SKIP); $return = ''; $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE ID <> 1 " : '') . "ORDER BY display_name"); # $wp_args = $args; # $wp_args['format'] = 'array'; # $authors = wp_list_authors($wp_args); #var_dump($authors); /* $return = apply_filters( 'wp_tag_cloud', $return, $args ); if ( 'array' == $args['format'] ) return $return; */ $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 $key => $author ) { $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0; if ( $posts != 0 || !$hide_empty ) { $author = get_userdata( $author->ID ); $name = $author->display_name; if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) $name = "$author->first_name $author->last_name"; # if ( !($posts == 0 && $hide_empty) ) # $return .= '
  • '; if ( $posts == 0 ) { if ( !$hide_empty ) # $link = $name; $link = ''; } else { # $link = 'display_name)) . '">' . $name . ''; $link = get_author_posts_url($author->ID, $author->user_nicename); /* if ( (! empty($feed_image)) || (! empty($feed)) ) { $link .= ' '; if (empty($feed_image)) $link .= '('; $link .= ''; else $link .= $name; $link .= ''; if ( empty($feed_image) ) $link .= ')'; } if ( $optioncount ) $link .= ' ('. $posts . ')'; */ } $authors[$key]->name = $name; $authors[$key]->count = $posts; $authors[$key]->link = $link; # $authors[$key]->name = $name; /* if ( !($posts == 0 && $hide_empty) ) $return .= $link . '
  • '; */ } else unset($authors[$key]); } $return = seo_tag_cloud_generate( $authors, $args ); // Here's where those top tags get sorted according to $args #$return .= 'DEBUG:'.print_r($authors,1); echo $return; } endif; function widget_authors($args, $widget_args = 1) { extract($args, EXTR_SKIP); if ( is_numeric($widget_args) ) $widget_args = array( 'number' => $widget_args ); $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); extract($widget_args, EXTR_SKIP); $options = get_option('widget_authors'); # if (!isset($options[$number])) # return; $title = empty($options[$number]['title']) ? __('Authors','authors') : apply_filters('widget_title', $options[$number]['title']); $format = $options[$number]['format']; $order = $options[$number]['order']; $feedlink = $options[$number]['feedlink'] ? '1' : '0'; $count = $options[$number]['count'] ? '1' : '0'; $exclude_admin = $options[$number]['exclude_admin'] ? '1' : '0'; ?> #', $a, $matches); $aC = is_array($matches) && count($matches) >= 2 ? intval($matches[1]) : 0; preg_match('#\(([0-9]*)\)#', $b, $matches); $bC = is_array($matches) && count($matches) >= 2 ? intval($matches[1]) : 0; return $aC < $bC ? 1 : -1; } function widget_authors_style() { ?> $widget_args ); $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); extract($widget_args, EXTR_SKIP); $options = get_option('widget_authors'); if ( !is_array( $options ) ) $options = array(); if ( !$updated && !empty($_POST['sidebar']) ) { $sidebar = (string) $_POST['sidebar']; $sidebars_widgets = wp_get_sidebars_widgets(); if ( isset($sidebars_widgets[$sidebar]) ) $this_sidebar =& $sidebars_widgets[$sidebar]; else $this_sidebar = array(); foreach ( (array) $this_sidebar as $_widget_id ) { if ( 'widget_authors' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; if ( !in_array( "authors-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. unset($options[$widget_number]); } } foreach ( (array) $_POST['widget-authors'] as $widget_number => $widget_authors ) { if ( !isset($widget_authors['title']) && isset($options[$widget_number]) ) // user clicked cancel continue; $title = trim(strip_tags(stripslashes($widget_authors['title']))); $format = !empty($widget_authors['format']) ? $widget_authors['format'] : 'list'; $order = !empty($widget_authors['order']) ? $widget_authors['order'] : 'name'; $feedlink = isset($widget_authors['feedlink']); $count = isset($widget_authors['count']); $exclude_admin = isset($widget_authors['exclude_admin']); $options[$widget_number] = compact( 'title', 'format', 'order', 'feedlink', 'count', 'exclude_admin' ); } update_option('widget_authors', $options); $updated = true; } if ( -1 == $number ) { $title = ''; $format = 'list'; $order = 'name'; $feedlink = false; $count = false; $exclude_admin = 0; $number = '%i%'; } else { $title = attribute_escape( $options[$number]['title'] ); $format = attribute_escape( $options[$number]['format'] ); $order = attribute_escape( $options[$number]['order'] ); $feedlink = (bool) $options[$number]['feedlink']; $count = (bool) $options[$number]['count']; $exclude_admin = (bool) $options[$number]['exclude_admin']; } ?>

    :

    :

    $options ); update_option( 'widget_authors', $newoptions ); $sidebars_widgets = get_option( 'sidebars_widgets' ); if ( is_array( $sidebars_widgets ) ) { foreach ( $sidebars_widgets as $sidebar => $widgets ) { if ( is_array( $widgets ) ) { foreach ( $widgets as $widget ) $new_widgets[$sidebar][] = ( $widget == 'authors' ) ? 'authors-1' : $widget; } else { $new_widgets[$sidebar] = $widgets; } } if ( $new_widgets != $sidebars_widgets ) update_option( 'sidebars_widgets', $new_widgets ); } return $newoptions; } if ( !$options = get_option( 'widget_authors' ) ) $options = array(); if ( isset($options['title']) ) $options = widget_authors_upgrade(); $widget_ops = array( 'classname' => 'widget_authors', 'description' => __( 'A list of the authors','authors' ) ); $name = __( 'Authors','authors' ); $id = false; foreach ( (array) array_keys($options) as $o ) { // Old widgets can have null values for some reason if ( !isset($options[$o]['title']) ) continue; $id = "authors-$o"; wp_register_sidebar_widget( $id, $name, 'widget_authors', $widget_ops, array( 'number' => $o ) ); wp_register_widget_control( $id, $name, 'widget_authors_control', array( 'id_base' => 'authors' ), array( 'number' => $o ) ); } // If there are none, we register the widget's existance with a generic template if ( !$id ) { wp_register_sidebar_widget( 'authors-1', $name, 'widget_authors', $widget_ops, array( 'number' => -1 ) ); wp_register_widget_control( 'authors-1', $name, 'widget_authors_control', array( 'id_base' => 'authors' ), array( 'number' => -1 ) ); } /* if ( is_active_widget('widget_authors') ) add_action('wp_head', 'widget_authors_style'); */ endif; } add_action('init', 'widget_authors_register'); ?>