Plugin Directory

Changeset 818500


Ignore:
Timestamp:
12/10/2013 10:26:42 PM (12 years ago)
Author:
flocsy
Message:

2.4: optimized for many authors, Serbian, Italian

Location:
authors/trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • authors/trunk/authors.php

    r720128 r818500  
    44Plugin URI: http://blog.fleischer.hu/wordpress/authors/
    55Description: Authors Widget shows the list or cloud of the authors, with the number of posts, link to RSS feed next to their name, avatar. It is useful in a multi-author blog, where you want to have the list in the sidemenu.
    6 Version: 2.3
     6Version: 2.4
    77Author: Gavriel Fleischer
    88Author URI: http://blog.fleischer.hu/author/gavriel/
     
    8787    if ( function_exists('seo_tag_cloud_generate') ) :
    8888    function widget_authors_cloud($args = '') {
    89         global $wpdb;
    90 
    9189        $defaults = array(
    9290            'optioncount' => false, 'exclude_admin' => true,
     
    104102        $return = '';
    105103
    106         if (empty($include)) {
    107             $include_sql = '';
    108             $exclude_sql = ' AND ID NOT IN (' . $exclude . ') AND user_login NOT IN (' . $exclude . ')';
    109         } else {
    110             $include_sql = ' AND (ID IN (' . $include . ') OR user_login IN (' . $include . '))';
    111             $exclude_sql = '';
    112         }
    113         $authors = $wpdb->get_results('SELECT ID, user_nicename, display_name FROM ' . $wpdb->users . ' WHERE 0=0' . ($exclude_admin ? ' AND ID <> 1' : '') . $exclude_sql . $include_sql . ' ORDER BY display_name');
    114 
    115         $author_count = array();
    116         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) {
    117             $author_count[$row->post_author] = $row->count;
    118         }
    119 
     104        $authors = widget_authors_get_authors( $include, $exclude );
     105        $author_count = widget_authors_count_authors ( $authors );
    120106        widget_authors_sort_by($orderby, $authors);
    121107
     
    124110            if ( $posts != 0 || !$hide_empty ) {
    125111                $author = get_userdata( $author->ID );
     112                if ($exclude_admin && 10 == $author->user_level)
     113                    continue;
    126114                $name = $author->display_name;
    127115                if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
     
    202190 */
    203191function widget_authors_list_authors($args = '') {
    204     global $wpdb;
    205 
    206192    $defaults = array(
    207193        'optioncount' => false, 'exclude_admin' => true,
     
    219205    $return = '';
    220206
    221     if (empty($include)) {
    222         $include_sql = '';
    223         $exclude_sql = ' AND ID NOT IN (' . $exclude . ') AND user_login NOT IN (' . $exclude . ')';
    224     } else {
    225         $include_sql = ' AND (ID IN (' . $include . ') OR user_login IN (' . $include . '))';
    226         $exclude_sql = '';
    227     }
    228     /** @todo Move select to get_authors(). */
    229     $authors = $wpdb->get_results('SELECT ID, user_nicename FROM ' . $wpdb->users . ' WHERE 0=0' . ($exclude_admin ? ' AND ID <> 1' : '') . $exclude_sql . $include_sql . ' ORDER BY display_name');
    230 
    231     $author_count = array();
    232     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) {
    233         $author_count[$row->post_author] = $row->count;
    234     }
    235 
     207    $authors = widget_authors_get_authors( $include, $exclude);
     208    $author_count = widget_authors_count_authors ( $authors );
    236209    widget_authors_sort_by($orderby, $authors);
    237210
     
    534507        return $newoptions;
    535508    }
     509    function widget_authors_get_authors( $include = array(), $exclude = array()) {
     510        if ( !empty( $include ) ) {
     511            $include = explode( ',', $include);
     512            foreach ( $include as $key => $val ) {
     513                if ( !is_int( $val ) ) {
     514                    $user = get_user_by( 'login', $val );
     515                    $include[$key] = $user->ID;
     516                }
     517            }
     518        }
     519        if ( !empty( $exclude ) ) {
     520            $exclude = explode( ',', $exclude);
     521            foreach ( $exclude as $key => $val ) {
     522                if ( !is_int( $val ) ) {
     523                    $user = get_user_by( 'login', $val );
     524                    $exclude[$key] = $user->ID;
     525                }
     526            }
     527        }
     528        $user_args = array(
     529            'fields' => array( 'ID', 'user_nicename', 'display_name' ),
     530            'who' => 'authors',
     531            'orderby' => 'display_name',
     532            'include' => $include,
     533            'exclude' => $exclude
     534        );
     535        $wp_user_search = new WP_User_Query( $user_args );
     536        $authors = $wp_user_search->get_results();
     537        return $authors;
     538    }
     539
     540    function widget_authors_count_authors( $authors ) {
     541        $author_ids = array();
     542        foreach( $authors as $author) {
     543            $author_ids[] = $author->ID;
     544        }
     545        $author_count = count_many_users_posts($author_ids);
     546        return $author_count;
     547    }
    536548
    537549    if ( !$options = get_option( 'widget_authors' ) )
  • authors/trunk/lang/authors.pot

    r642402 r818500  
    1 # Copyright (C) 2012 Authors Widget
     1# Copyright (C) 2013 Authors Widget
    22# This file is distributed under the same license as the Authors Widget package.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Authors Widget 2.2.1\n"
     5"Project-Id-Version: Authors Widget 2.4\n"
    66"Report-Msgid-Bugs-To: http://wordpress.org/tag/authors\n"
    7 "POT-Creation-Date: 2012-12-20 16:35:58+00:00\n"
     7"POT-Creation-Date: 2013-12-10 20:46:18+00:00\n"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=UTF-8\n"
    1010"Content-Transfer-Encoding: 8bit\n"
    11 "PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n"
     11"PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n"
    1212"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    1313"Language-Team: LANGUAGE <LL@li.org>\n"
    1414
    15 #: authors.php:151
     15#: authors.php:159
    1616msgid "Select Author..."
    1717msgstr ""
    1818
    19 #: authors.php:255
     19#: authors.php:248
    2020msgid "Posts by %s"
    2121msgstr ""
    2222
    23 #: authors.php:315 authors.php:533
     23#: authors.php:308 authors.php:557
    2424msgid "Authors"
    2525msgstr ""
    2626
    27 #: authors.php:350
     27#: authors.php:343
    2828msgid "Powered by %s"
    2929msgstr ""
    3030
    31 #: authors.php:350
     31#: authors.php:343
    3232msgid "Authors Widget Plugin for Wordpress"
    3333msgstr ""
    3434
    35 #. #-#-#-#-#  plugin.pot (Authors Widget 2.2.1)  #-#-#-#-#
     35#. #-#-#-#-#  authors.pot (Authors Widget 2.4)  #-#-#-#-#
    3636#. Plugin Name of the plugin/theme
    37 #: authors.php:350
     37#: authors.php:343
    3838msgid "Authors Widget"
    3939msgstr ""
    4040
    41 #: authors.php:461
     41#: authors.php:445
    4242msgid "Title"
    4343msgstr ""
    4444
    45 #: authors.php:463
     45#: authors.php:447
    4646msgid "Format"
    4747msgstr ""
    4848
    49 #: authors.php:464
     49#: authors.php:448
    5050msgid "List"
    5151msgstr ""
    5252
    53 #: authors.php:466
     53#: authors.php:450
    5454msgid "Cloud"
    5555msgstr ""
    5656
    57 #: authors.php:468
     57#: authors.php:452
    5858msgid "Dropdown"
    5959msgstr ""
    6060
    61 #: authors.php:471
     61#: authors.php:455
    6262msgid "Order by"
    6363msgstr ""
    6464
    65 #: authors.php:472
     65#: authors.php:456
    6666msgid "Display name"
    6767msgstr ""
    6868
    69 #: authors.php:473
     69#: authors.php:457
    7070msgid "First name"
    7171msgstr ""
    7272
    73 #: authors.php:474
     73#: authors.php:458
    7474msgid "Last name"
    7575msgstr ""
    7676
    77 #: authors.php:475
     77#: authors.php:459
    7878msgid "Post count"
    7979msgstr ""
    8080
    81 #: authors.php:477
     81#: authors.php:460
     82msgid "ID"
     83msgstr ""
     84
     85#: authors.php:462
    8286msgid "Number of authors to show"
    8387msgstr ""
    8488
    85 #: authors.php:478
     89#: authors.php:463
    8690msgid "Show full name"
    8791msgstr ""
    8892
    89 #: authors.php:479
     93#: authors.php:464
    9094msgid "Show avatar"
    9195msgstr ""
    9296
    93 #: authors.php:480
     97#: authors.php:465
    9498msgid "Avatar size"
    9599msgstr ""
    96100
    97 #: authors.php:481
     101#: authors.php:466
    98102msgid "Show RSS links"
    99103msgstr ""
    100104
    101 #: authors.php:482
     105#: authors.php:467
    102106msgid "Show post counts"
    103107msgstr ""
    104108
    105 #: authors.php:483
     109#: authors.php:468
    106110msgid "Hide empty"
    107111msgstr ""
    108112
    109 #: authors.php:484
     113#: authors.php:469
    110114msgid "Exclude admin"
    111115msgstr ""
    112116
    113 #: authors.php:485
     117#: authors.php:470
    114118msgid "Exclude"
    115119msgstr ""
    116120
    117 #: authors.php:486
     121#: authors.php:471
    118122msgid "Include"
    119123msgstr ""
    120124
    121 #: authors.php:488
     125#: authors.php:473
    122126msgid "How satisfied you are with the plugin?"
    123127msgstr ""
    124128
    125 #: authors.php:490
     129#: authors.php:475
    126130msgid "Donate"
    127131msgstr ""
    128132
    129 #: authors.php:491
    130 msgid "Display \"Powered by Authors widget\" link"
    131 msgstr ""
    132 
    133 #: authors.php:491
     133#: authors.php:476
    134134msgid "Show credit"
    135135msgstr ""
    136136
    137 #: authors.php:531
     137#: authors.php:555
    138138msgid "A list of the authors"
    139139msgstr ""
  • authors/trunk/readme.txt

    r720128 r818500  
    44Tags: authors, author, multi-author, multi-user, list, sidemenu, sidebar, links, widgets, widget, plugin, avatar, gravatar
    55Requires at least: 2.0.2
    6 Tested up to: 3.5.1
     6Tested up to: 3.8
    77Stable tag: trunk
    88
     
    5555* Belarusian / беларуская by [Alexander Ovsov](http://webhostinggeeks.com/science/ "Web Geek Sciense")
    5656* Polish / Polski [Krzysztof](http://pl2wp.prywatny.eu/)
     57* Serbian / srpski by [Borisa Djuraskovic]
     58* Italian / italiano by [Aurezio](http://www.sognoesondesto.it)
    5759
    5860= How can I exclude certain authors from being displayed? =
     
    8385
    8486== Changelog ==
     87
     88= 2.4 =
     89* Optimized for blogs with many authors
     90* Added Serbian translation
     91* Added Italian translation
    8592
    8693= 2.3 =
Note: See TracChangeset for help on using the changeset viewer.