Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // ^ (above PHP tag should not be needed in the pasting, btw)
- // Insert this PHP stuff in Spectacu.la's includes/functions.php file under the function:
- // if ( ! function_exists( 'spec_find_stylesheets' ) ) {
- // ... }
- // You'll of course have to replace the badge names, filenames, and descriptions as needed
- // (try not to steal my awesome rank names :P)
- // This makes an array of array objects that contain the badges' file names and descriptions
- function showUserBadge( $userID ) {
- $badge = array(
- 'n00b' => array( 'n00b.png', 'n00b' ),
- 'rookie' => array('rookie.png', 'Rookie' ),
- 'goomba' => array( 'goomba.png', 'Goomba' ),
- 'apprentice' => array( 'apprentice.png', 'Apprentice' ),
- 'lagomorph' => array( 'lagomorph.png', 'Lagomorph' ),
- 'journeyman' => array( 'journeyman.png', 'Journeyman' ),
- 'true' => array( 'true-usagi.png', 'True Usagi' ),
- 'bro' => array( 'brosagi.png', 'Brosagi' ),
- 'whosagi' => array( 'dr-whosagi.png', 'Dr. Who-sagi' ),
- 'cog' => array('cog-of-war.png', 'Cog of War' ),
- 'general' => array( '5-star-general.png', '5-Star General' ),
- 'butler' => array( 'kevin-butler.png', 'Kevin Butler' ),
- 'testa' => array( 'chuck-testa.png', 'n00b... NOPE! Chuck Testa.' ),
- 'tankcat' => array('tank-cat.png', 'Tank Cat is Strong' ),
- 'hollow' => array('hollow.png', 'Hollow' ),
- 'cthulhu' => array('cthulhu.png', 'Cthulhu'),
- '1337' => array('1337.png', '! @^^ 1337' ),
- '1338' => array('1338.png', '^^0|23 +#@// 1337' ),
- 'dang' => array('dang.gif', 'Dang, I have a lot of points' ),
- 'one' => array('one-rank.gif', 'One Rank to Rule Them All'),
- 'omega' => array('omega.gif', 'The Alpha and the Usagi'),
- '9000' => array('9000.gif', 'OVER 9000!'),
- 'overlord' => array('overlord.png', 'USAGI OVERLORD!!1!'),
- );
- // You can use the below section to manually assign badges to individual users if you want
- /*
- $userBadges = array(
- 2 => array( $badge['horde3'], $badge['crown'] ),
- 4 => array( $badge['crown'] ),
- 72 => array( $badge['patinhas'], $badge['parrot'] ),
- 171 => array( $badge['parrot'] ),
- 105 => array( $badge['parrot'] ),
- 97 => array( $badge['parrot'] ),
- 18 => array( $badge['parrot'] ),
- 28 => array( $badge['horde3'], $badge['tf2'], $badge['crown'] )
- );
- if( array_key_exists( $userID, $userBadges ) ) {
- foreach( $userBadges[$userID] as $img ) {
- echo '<img src="'.site_url().'/images/ranks/'.$img[0].'" title="'.$img[1].'" />';
- }
- } else {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['rankblank'].'" />';
- }
- */
- // This huge if/else if block gets the user's points and checks which point level they're in
- // and then echoes their appropriate rank image and title/description
- // Could be made more efficient by putting cp_getPoints($userID) into its own variable if you want
- if( cp_getPoints($userID) >= 0 && cp_getPoints($userID) <= 24 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['n00b'][0].'" title="'.$badge['n00b'][1].'" />';
- } else if( cp_getPoints($userID) >= 25 && cp_getPoints($userID) <= 49 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['rookie'][0].'" title="'.$badge['rookie'][1].'" />';
- } else if( cp_getPoints($userID) >= 50 && cp_getPoints($userID) <= 99 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['goomba'][0].'" title="'.$badge['goomba'][1].'" />';
- } else if( cp_getPoints($userID) >= 100 && cp_getPoints($userID) <= 149 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['apprentice'][0].'" title="'.$badge['apprentice'][1].'" />';
- } else if( cp_getPoints($userID) >= 150 && cp_getPoints($userID) <= 199 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['lagomorph'][0].'" title="'.$badge['lagomorph'][1].'" />';
- } else if( cp_getPoints($userID) >= 200 && cp_getPoints($userID) <= 249 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['journeyman'][0].'" title="'.$badge['journeyman'][1].'" />';
- } else if( cp_getPoints($userID) >= 250 && cp_getPoints($userID) <= 299 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['true'][0].'" title="'.$badge['true'][1].'" />';
- } else if( cp_getPoints($userID) >= 300 && cp_getPoints($userID) <= 399 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['bro'][0].'" title="'.$badge['bro'][1].'" />';
- } else if( cp_getPoints($userID) >= 400 && cp_getPoints($userID) <= 499 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['whosagi'][0].'" title="'.$badge['whosagi'][1].'" />';
- } else if( cp_getPoints($userID) >= 500 && cp_getPoints($userID) <= 599 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['cog'][0].'" title="'.$badge['cog'][1].'" />';
- } else if( cp_getPoints($userID) >= 600 && cp_getPoints($userID) <= 699 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['general'][0].'" title="'.$badge['general'][1].'" />';
- } else if( cp_getPoints($userID) >= 700 && cp_getPoints($userID) <= 799 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['butler'][0].'" title="'.$badge['butler'][1].'" />';
- } else if( cp_getPoints($userID) >= 800 && cp_getPoints($userID) <= 899 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['testa'][0].'" title="'.$badge['testa'][1].'" />';
- } else if( cp_getPoints($userID) >= 900 && cp_getPoints($userID) <= 999 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['tankcat'][0].'" title="'.$badge['tankcat'][1].'" />';
- } else if( cp_getPoints($userID) >= 1000 && cp_getPoints($userID) <= 1149 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['hollow'][0].'" title="'.$badge['hollow'][1].'" />';
- } else if( cp_getPoints($userID) >= 1150 && cp_getPoints($userID) <= 1336 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['cthulhu'][0].'" title="'.$badge['cthulhu'][1].'" />';
- } else if( cp_getPoints($userID) >= 1337 && cp_getPoints($userID) <= 1499 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['1337'][0].'" title="'.$badge['1337'][1].'" />';
- } else if( cp_getPoints($userID) >= 1500 && cp_getPoints($userID) <= 1599 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['1338'][0].'" title="'.$badge['1338'][1].'" />';
- } else if( cp_getPoints($userID) >= 1600 && cp_getPoints($userID) <= 1799 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['dang'][0].'" title="'.$badge['dang'][1].'" />';
- } else if( cp_getPoints($userID) >= 1800 && cp_getPoints($userID) <= 1999 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['one'][0].'" title="'.$badge['one'][1].'" />';
- } else if( cp_getPoints($userID) >= 2000 && cp_getPoints($userID) <= 9000 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['omega'][0].'" title="'.$badge['omega'][1].'" />';
- } else if( cp_getPoints($userID) >= 9000 && cp_getPoints($userID) <= 999999 ) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['9000'][0].'" title="'.$badge['9000'][1].'" />';
- } else if( cp_getPoints($userID) >= 1000000) {
- echo '<img src="'.site_url().'/images/ranks/'.$badge['overlord'][0].'" title="'.$badge['overlord'][1].'" />';
- }
- }
- ?>
- <!-- insert this below:
- <div id="div-comment-<?php comment_ID( ) ?>" class="comment-body">
- <?php //echo $comment->comment_date; ?>
- in the function:
- /*
- Comment layout function used by WP27 walker .
- @return null
- */
- if ( ! function_exists( 'spec_comment_layout' ) ) {
- -->
- <?php $user = get_userdata($comment->user_id); ?>
- <!-- Insert this under the line: "<div class="comment-meta">" in the same function
- This displays the user badges -->
- <div style="float: right;">
- <?php showUserBadge($user->ID); ?>
- </div>
- <!--Insert the below line after this line again in the same function:
- <cite class="fn"><span style="font-style:normal;"><?php comment_author_link( ); ?></span></cite>
- This gives you the nice point total after each username in the comments -->
- <?php if(function_exists('cp_displayPoints')) { echo ' ['; cp_displayPoints($user->ID); echo ']'; } ?><br/>
- <!-- end Badges -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement