Advertisement
Viruthagiri

badges

Dec 26th, 2011
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // ^ (above PHP tag should not be needed in the pasting, btw)
  3.  
  4. // Insert this PHP stuff in Spectacu.la's includes/functions.php file under the function:
  5. // if ( ! function_exists( 'spec_find_stylesheets' ) ) {
  6. //  ... }
  7.  
  8. // You'll of course have to replace the badge names, filenames, and descriptions as needed
  9. // (try not to steal my awesome rank names :P)
  10. // This makes an array of array objects that contain the badges' file names and descriptions
  11. function showUserBadge( $userID ) {
  12.     $badge = array(
  13.             'n00b'         => array( 'n00b.png', 'n00b' ),
  14.             'rookie'        => array('rookie.png', 'Rookie' ),
  15.             'goomba'        => array( 'goomba.png', 'Goomba' ),
  16.             'apprentice'        => array( 'apprentice.png', 'Apprentice' ),
  17.             'lagomorph'         => array( 'lagomorph.png', 'Lagomorph' ),
  18.             'journeyman'            => array( 'journeyman.png', 'Journeyman' ),
  19.             'true'          => array( 'true-usagi.png', 'True Usagi' ),
  20.             'bro'       => array( 'brosagi.png', 'Brosagi' ),
  21.             'whosagi'           => array( 'dr-whosagi.png', 'Dr. Who-sagi' ),
  22.             'cog'       => array('cog-of-war.png', 'Cog of War' ),
  23.             'general'           => array( '5-star-general.png', '5-Star General' ),
  24.             'butler'            => array( 'kevin-butler.png', 'Kevin Butler' ),
  25.             'testa'         => array( 'chuck-testa.png', 'n00b... NOPE! Chuck Testa.' ),
  26.             'tankcat'       => array('tank-cat.png', 'Tank Cat is Strong' ),
  27.             'hollow'        => array('hollow.png', 'Hollow' ),
  28.             'cthulhu'       => array('cthulhu.png', 'Cthulhu'),
  29.             '1337'      => array('1337.png', '! @^^ 1337' ),
  30.             '1338'      => array('1338.png', '^^0|23 +#@// 1337' ),
  31.             'dang'      => array('dang.gif', 'Dang, I have a lot of points' ),
  32.             'one'           => array('one-rank.gif', 'One Rank to Rule Them All'),
  33.             'omega'         => array('omega.gif', 'The Alpha and the Usagi'),
  34.             '9000'          => array('9000.gif', 'OVER 9000!'),
  35.             'overlord'          => array('overlord.png', 'USAGI OVERLORD!!1!'),
  36.            
  37.     );
  38.    
  39.     // You can use the below section to manually assign badges to individual users if you want
  40.     /*
  41.     $userBadges = array(
  42.         2 => array( $badge['horde3'], $badge['crown'] ),
  43.         4 => array( $badge['crown'] ),
  44.         72 => array( $badge['patinhas'], $badge['parrot'] ),
  45.         171 => array( $badge['parrot'] ),
  46.         105 => array( $badge['parrot'] ),
  47.         97 => array( $badge['parrot'] ),
  48.         18 => array( $badge['parrot'] ),
  49.         28 => array( $badge['horde3'], $badge['tf2'], $badge['crown'] )
  50.     );
  51.  
  52.    
  53.     if( array_key_exists( $userID, $userBadges ) ) {
  54.         foreach( $userBadges[$userID] as $img ) {
  55.             echo '<img src="'.site_url().'/images/ranks/'.$img[0].'" title="'.$img[1].'" />';
  56.         }
  57.     } else {
  58.         echo '<img src="'.site_url().'/images/ranks/'.$badge['rankblank'].'" />';
  59.     }      
  60.     */
  61.    
  62.     // This huge if/else if block gets the user's points and checks which point level they're in
  63.     // and then echoes their appropriate rank image and title/description
  64.     // Could be made more efficient by putting cp_getPoints($userID) into its own variable if you want
  65.     if( cp_getPoints($userID) >= 0 && cp_getPoints($userID) <= 24 ) {
  66.         echo '<img src="'.site_url().'/images/ranks/'.$badge['n00b'][0].'" title="'.$badge['n00b'][1].'" />';
  67.     } else if( cp_getPoints($userID) >= 25 && cp_getPoints($userID) <= 49 ) {
  68.         echo '<img src="'.site_url().'/images/ranks/'.$badge['rookie'][0].'" title="'.$badge['rookie'][1].'" />';
  69.     } else if( cp_getPoints($userID) >= 50 && cp_getPoints($userID) <= 99 ) {
  70.         echo '<img src="'.site_url().'/images/ranks/'.$badge['goomba'][0].'" title="'.$badge['goomba'][1].'" />';
  71.     } else if( cp_getPoints($userID) >= 100 && cp_getPoints($userID) <= 149 ) {
  72.         echo '<img src="'.site_url().'/images/ranks/'.$badge['apprentice'][0].'" title="'.$badge['apprentice'][1].'" />';
  73.     } else if( cp_getPoints($userID) >= 150 && cp_getPoints($userID) <= 199 ) {
  74.         echo '<img src="'.site_url().'/images/ranks/'.$badge['lagomorph'][0].'" title="'.$badge['lagomorph'][1].'" />';
  75.     } else if( cp_getPoints($userID) >= 200 && cp_getPoints($userID) <= 249 ) {
  76.         echo '<img src="'.site_url().'/images/ranks/'.$badge['journeyman'][0].'" title="'.$badge['journeyman'][1].'" />';
  77.     } else if( cp_getPoints($userID) >= 250 && cp_getPoints($userID) <= 299 ) {
  78.         echo '<img src="'.site_url().'/images/ranks/'.$badge['true'][0].'" title="'.$badge['true'][1].'" />';
  79.     } else if( cp_getPoints($userID) >= 300 && cp_getPoints($userID) <= 399 ) {
  80.         echo '<img src="'.site_url().'/images/ranks/'.$badge['bro'][0].'" title="'.$badge['bro'][1].'" />';
  81.     } else if( cp_getPoints($userID) >= 400 && cp_getPoints($userID) <= 499 ) {
  82.         echo '<img src="'.site_url().'/images/ranks/'.$badge['whosagi'][0].'" title="'.$badge['whosagi'][1].'" />';
  83.     } else if( cp_getPoints($userID) >= 500 && cp_getPoints($userID) <= 599 ) {
  84.         echo '<img src="'.site_url().'/images/ranks/'.$badge['cog'][0].'" title="'.$badge['cog'][1].'" />';
  85.     } else if( cp_getPoints($userID) >= 600 && cp_getPoints($userID) <= 699 ) {
  86.         echo '<img src="'.site_url().'/images/ranks/'.$badge['general'][0].'" title="'.$badge['general'][1].'" />';
  87.     } else if( cp_getPoints($userID) >= 700 && cp_getPoints($userID) <= 799 ) {
  88.         echo '<img src="'.site_url().'/images/ranks/'.$badge['butler'][0].'" title="'.$badge['butler'][1].'" />';
  89.     } else if( cp_getPoints($userID) >= 800 && cp_getPoints($userID) <= 899 ) {
  90.         echo '<img src="'.site_url().'/images/ranks/'.$badge['testa'][0].'" title="'.$badge['testa'][1].'" />';
  91.     } else if( cp_getPoints($userID) >= 900 && cp_getPoints($userID) <= 999 ) {
  92.         echo '<img src="'.site_url().'/images/ranks/'.$badge['tankcat'][0].'" title="'.$badge['tankcat'][1].'" />';
  93.     } else if( cp_getPoints($userID) >= 1000 && cp_getPoints($userID) <= 1149 ) {
  94.         echo '<img src="'.site_url().'/images/ranks/'.$badge['hollow'][0].'" title="'.$badge['hollow'][1].'" />';
  95.     } else if( cp_getPoints($userID) >= 1150 && cp_getPoints($userID) <= 1336 ) {
  96.         echo '<img src="'.site_url().'/images/ranks/'.$badge['cthulhu'][0].'" title="'.$badge['cthulhu'][1].'" />';
  97.     } else if( cp_getPoints($userID) >= 1337 && cp_getPoints($userID) <= 1499 ) {
  98.         echo '<img src="'.site_url().'/images/ranks/'.$badge['1337'][0].'" title="'.$badge['1337'][1].'" />';
  99.     } else if( cp_getPoints($userID) >= 1500 && cp_getPoints($userID) <= 1599 ) {
  100.         echo '<img src="'.site_url().'/images/ranks/'.$badge['1338'][0].'" title="'.$badge['1338'][1].'" />';
  101.     } else if( cp_getPoints($userID) >= 1600 && cp_getPoints($userID) <= 1799 ) {
  102.         echo '<img src="'.site_url().'/images/ranks/'.$badge['dang'][0].'" title="'.$badge['dang'][1].'" />';
  103.     } else if( cp_getPoints($userID) >= 1800 && cp_getPoints($userID) <= 1999 ) {
  104.         echo '<img src="'.site_url().'/images/ranks/'.$badge['one'][0].'" title="'.$badge['one'][1].'" />';
  105.     } else if( cp_getPoints($userID) >= 2000 && cp_getPoints($userID) <= 9000 ) {
  106.         echo '<img src="'.site_url().'/images/ranks/'.$badge['omega'][0].'" title="'.$badge['omega'][1].'" />';
  107.     } else if( cp_getPoints($userID) >= 9000 && cp_getPoints($userID) <= 999999 ) {
  108.         echo '<img src="'.site_url().'/images/ranks/'.$badge['9000'][0].'" title="'.$badge['9000'][1].'" />';
  109.     } else if( cp_getPoints($userID) >= 1000000) {
  110.         echo '<img src="'.site_url().'/images/ranks/'.$badge['overlord'][0].'" title="'.$badge['overlord'][1].'" />';
  111.     }
  112.    
  113. }
  114.  
  115. ?>
  116.  
  117.  
  118.  
  119. <!-- insert this below:
  120.     <div id="div-comment-<?php comment_ID( ) ?>" class="comment-body">
  121.                 <?php //echo $comment->comment_date; ?>
  122.     in the function:
  123.     /*
  124.     Comment layout function used by WP27 walker .
  125.     @return null
  126.     */
  127.      if ( ! function_exists( 'spec_comment_layout' ) ) {
  128. -->
  129. <?php $user = get_userdata($comment->user_id); ?>
  130.  
  131. <!-- Insert this under the line: "<div class="comment-meta">" in the same function
  132. This displays the user badges -->
  133. <div style="float: right;">
  134.     <?php showUserBadge($user->ID); ?>
  135. </div>
  136.  
  137. <!--Insert the below line  after this line again in the same function:
  138. <cite class="fn"><span style="font-style:normal;"><?php comment_author_link( ); ?></span></cite>
  139. This gives you the nice point total after each username in the comments -->
  140. <?php if(function_exists('cp_displayPoints')) { echo  ' ['; cp_displayPoints($user->ID); echo ']'; }  ?><br/>
  141.  
  142. <!-- end Badges -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement