Changeset 39351

Show
Ignore:
Timestamp:
04/08/08 23:33:24 (3 months ago)
Author:
peterwsterling
Message:

paged commentors

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • add-local-avatar/trunk/avatars.php

    r38938 r39351  
    55      Description:      A plugin to manage public and private avatars. 
    66      Author:                 Peter Sterling 
    7       Version:          1.0 
     7      Version:          2.0 
    88      Changes:          0.1 - Initial version. 
    99                              1.0 - Added pagination of users list. 
     10                              2.0 - Added pagination of the commentors list too. 
    1011      Author URI:       http://www.sterling-adventures.co.uk/ 
    1112*/ 
     
    176177                        )); 
    177178                  } 
     179 
     180                  // How many per page (for commenters, if shown)? 
     181                  $per_page = $user_search->users_per_page; 
    178182            ?> 
    179183 
    180             <?php if($user_search->results_are_paged()) : ?
    181                   <div class="tablenav"
     184            <div class="tablenav"
     185                  <?php if($user_search->results_are_paged()) : ?
    182186                        <div class="tablenav-pages"><?php $user_search->page_links(); ?></div> 
    183                         <br class="clear" /> 
    184                   </div> 
     187                  <?php endif; ?> 
    185188                  <br class="clear" /> 
    186             <?php endif; ?> 
     189            </div> 
     190            <br class="clear" /> 
    187191 
    188192            <table class='widefat'> 
    189193                  <thead> 
    190                         <tr><th>No.</th><th>Username</th><th>Name (Nickname)</th><th>e-Mail</th><th>Private</th><th style="text-align: center;">Avatar</th><th>Type</th><th>Action</th></tr> 
     194                        <tr><th>Username</th><th>Name (Nickname)</th><th>e-Mail</th><th>Private</th><th style="text-align: center;">Avatar</th><th>Type</th><th>Action</th></tr> 
    191195                  </thead> 
    192196                  <tbody> 
     
    196200                              $user = new WP_User($id); 
    197201                              echo '<tr', ($i % 2 == 0 ? " class='alternate'" : ""), '>'; 
    198                               echo '<td>', $i + 1, '.</td>'; 
    199202                              echo '<td><a href="', 'user-edit.php?user_id=', $id, '">', $user->user_login, '</a></td>'; 
    200203                              echo '<td>', $user->first_name, ' ', $user->last_name, (empty($user->nickname) ? '-' : ' (' . $user->nickname . ')'), '</a></td>'; 
     
    211214            </table> 
    212215 
    213             <?php if($user_search->results_are_paged()) : ?
    214                   <div class="tablenav"
     216            <div class="tablenav"
     217                  <?php if($user_search->results_are_paged()) : ?
    215218                        <div class="tablenav-pages"><?php $user_search->page_links(); ?></div> 
    216                         <br class="clear" /> 
    217                   </div> 
     219                  <?php endif; ?> 
    218220                  <br class="clear" /> 
    219             <?php endif; ?> 
     221            </div> 
     222            <br class="clear" /> 
    220223 
    221224            <p><?php 
     
    224227            ?></p> 
    225228            <?php 
     229                  $com_page = (isset($_GET['comspage']) ? $_GET['comspage'] : 1); 
     230 
    226231                  if($all) { 
    227                         $coms = $wpdb->get_results("select comment_author_email EML, comment_author ATH, count(comment_content) CNT from $wpdb->comments group by EML order by CNT DESC"); 
     232                        $total = $wpdb->get_var("select count(distinct comment_author_email) from $wpdb->comments where comment_author_email != ''"); 
     233                        $limit_start = ($com_page - 1) * $per_page; 
     234                        $coms = $wpdb->get_results("select comment_author_email EML, comment_author ATH, count(comment_content) CNT from $wpdb->comments where comment_author_email != '' group by comment_author_email order by CNT DESC limit $limit_start, $per_page"); 
     235 
     236                        if($total > $per_page) { 
     237                              $paging_text = paginate_links(array( 
     238                                    'total' => ceil($total / $per_page), 
     239                                    'current' => $com_page, 
     240                                    'base' => 'users.php?page=avatars.php&amp;act=all&amp;%_%', 
     241                                    'format' => 'comspage=%#%' 
     242                              )); 
     243                        } 
     244 
    228245                        if($coms) { ?> 
    229246                              <h3>Commenter Avatars</h3> 
     247 
     248                              <div class="tablenav"> 
     249                                    <?php if($paging_text) : ?> 
     250                                          <div class="tablenav-pages"><?php echo $paging_text; ?></div> 
     251                                    <?php endif; ?> 
     252                                    <br class="clear" /> 
     253                              </div> 
     254                              <br class="clear" /> 
     255 
    230256                              <table class='widefat'> 
    231257                                    <thead> 
    232                                           <tr><th>No.</th><th>Name</th><th>e-Mail</th><th class="num"><div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div></th><th style="text-align: center;">Avatar</th></tr> 
     258                                          <tr><th>Name</th><th>e-Mail</th><th class="num"><div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div></th><th style="text-align: center;">Avatar</th></tr> 
    233259                                    </thead> 
    234260                                    <tbody> <?php 
     
    236262                                    foreach($coms as $com) if(!empty($com->EML)) { 
    237263                                          echo '<tr', ($i % 2 == 0 ? " class='alternate'" : ""), '>'; 
    238                                           echo '<td>', $i + 1, '.</td>'; 
    239264                                          echo '<td>', $com->ATH, '</td>'; 
    240265                                          echo '<td><a href="mailto:', $com->EML, '">', $com->EML, '</td>'; 
     
    245270                                    } ?> 
    246271                                    </tbody> 
    247                               </table> <?php 
    248                         } 
     272                              </table> 
     273 
     274                              <div class="tablenav"> 
     275                                    <?php if($paging_text) : ?> 
     276                                          <div class="tablenav-pages"><?php echo $paging_text; ?></div> 
     277                                    <?php endif; ?> 
     278                                    <br class="clear" /> 
     279                              </div> 
     280                              <br class="clear" /> 
     281                        <?php } 
    249282                  } 
    250283            ?> 
     
    286319                  <li>Default image if no public (global) or private (local) avatar found; defaulted to value set above.</li> 
    287320            </ol></code></p> 
     321            <p>Examples for your theme's template files:<br /> 
     322            <ul> 
     323                  <li>In <code>single.php</code> use <code>&lt;?php get_avatar($post->post_author); ?&gt;</code> to show the post author’s avatar.</li> 
     324                  <li>Inside the comment loop of <code>comments.php</code> use <code>&lt;?php get_avatar($comment); ?&gt;</code> to show the comment author’s avatar.</li> 
     325            </ul></p> 
    288326      </div> 
    289327<?php } 
     
    298336// Hooks... 
    299337add_action ('admin_menu', 'avatar_menu'); 
     338 
     339?>