Changeset 39351
- Timestamp:
- 04/08/08 23:33:24 (3 months ago)
- Files:
-
- add-local-avatar/trunk/avatars.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
add-local-avatar/trunk/avatars.php
r38938 r39351 5 5 Description: A plugin to manage public and private avatars. 6 6 Author: Peter Sterling 7 Version: 1.07 Version: 2.0 8 8 Changes: 0.1 - Initial version. 9 9 1.0 - Added pagination of users list. 10 2.0 - Added pagination of the commentors list too. 10 11 Author URI: http://www.sterling-adventures.co.uk/ 11 12 */ … … 176 177 )); 177 178 } 179 180 // How many per page (for commenters, if shown)? 181 $per_page = $user_search->users_per_page; 178 182 ?> 179 183 180 < ?php if($user_search->results_are_paged()) : ?>181 < div class="tablenav">184 <div class="tablenav"> 185 <?php if($user_search->results_are_paged()) : ?> 182 186 <div class="tablenav-pages"><?php $user_search->page_links(); ?></div> 183 <br class="clear" /> 184 </div> 187 <?php endif; ?> 185 188 <br class="clear" /> 186 <?php endif; ?> 189 </div> 190 <br class="clear" /> 187 191 188 192 <table class='widefat'> 189 193 <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> 191 195 </thead> 192 196 <tbody> … … 196 200 $user = new WP_User($id); 197 201 echo '<tr', ($i % 2 == 0 ? " class='alternate'" : ""), '>'; 198 echo '<td>', $i + 1, '.</td>';199 202 echo '<td><a href="', 'user-edit.php?user_id=', $id, '">', $user->user_login, '</a></td>'; 200 203 echo '<td>', $user->first_name, ' ', $user->last_name, (empty($user->nickname) ? '-' : ' (' . $user->nickname . ')'), '</a></td>'; … … 211 214 </table> 212 215 213 < ?php if($user_search->results_are_paged()) : ?>214 < div class="tablenav">216 <div class="tablenav"> 217 <?php if($user_search->results_are_paged()) : ?> 215 218 <div class="tablenav-pages"><?php $user_search->page_links(); ?></div> 216 <br class="clear" /> 217 </div> 219 <?php endif; ?> 218 220 <br class="clear" /> 219 <?php endif; ?> 221 </div> 222 <br class="clear" /> 220 223 221 224 <p><?php … … 224 227 ?></p> 225 228 <?php 229 $com_page = (isset($_GET['comspage']) ? $_GET['comspage'] : 1); 230 226 231 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&act=all&%_%', 241 'format' => 'comspage=%#%' 242 )); 243 } 244 228 245 if($coms) { ?> 229 246 <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 230 256 <table class='widefat'> 231 257 <thead> 232 <tr><th>N o.</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> 233 259 </thead> 234 260 <tbody> <?php … … 236 262 foreach($coms as $com) if(!empty($com->EML)) { 237 263 echo '<tr', ($i % 2 == 0 ? " class='alternate'" : ""), '>'; 238 echo '<td>', $i + 1, '.</td>';239 264 echo '<td>', $com->ATH, '</td>'; 240 265 echo '<td><a href="mailto:', $com->EML, '">', $com->EML, '</td>'; … … 245 270 } ?> 246 271 </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 } 249 282 } 250 283 ?> … … 286 319 <li>Default image if no public (global) or private (local) avatar found; defaulted to value set above.</li> 287 320 </ol></code></p> 321 <p>Examples for your theme's template files:<br /> 322 <ul> 323 <li>In <code>single.php</code> use <code><?php get_avatar($post->post_author); ?></code> to show the post author’s avatar.</li> 324 <li>Inside the comment loop of <code>comments.php</code> use <code><?php get_avatar($comment); ?></code> to show the comment author’s avatar.</li> 325 </ul></p> 288 326 </div> 289 327 <?php } … … 298 336 // Hooks... 299 337 add_action ('admin_menu', 'avatar_menu'); 338 339 ?>
