Advertisement
Guest User

code

a guest
Dec 10th, 2013
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.20 KB | None | 0 0
  1. /*===================================================================================*/
  2. /*  Функция отвечающая за рейтинг, в которую и надо вставить условие.
  3. /*==================================================================================*/
  4.  
  5. function add_rayting_comment($text){
  6. global $comment;
  7. global $user_ID;
  8. global $wpdb;
  9. global $comments_rayt;
  10.  
  11.     foreach((array)$comments_rayt as $val){
  12.         if($val->comment_id==$comment->comment_ID)
  13.             $sum_rayt = $sum_rayt + $val->rayting;
  14.     }
  15.    
  16.     $vote_results = '';
  17.    
  18.     if($sum_rayt&&$user_ID||$sum_rayt===0&&$user_ID) $vote_results = '<span id="vote-results-'.$comment->comment_ID.'" class="vote-results">?</span>';
  19.  
  20.     if(!$sum_rayt) $sum_rayt = 0;  
  21.     if($sum_rayt>0) $sum_rayt = '<span style="color:green">+'.$sum_rayt.'</span>';
  22.     if($sum_rayt<0) $sum_rayt = '<span style="color:red">'.$sum_rayt.'</span>';
  23.     // (условие здесь)
  24.    
  25.    
  26.     $rayt = '<span id="com-'.$comment->comment_ID.'" class="comment-rayt">';
  27.     $rayt .= '<span class="rayt-res"><span id="com-karma-'.$comment->comment_ID.'">'.$sum_rayt.'</span></span>';
  28.    
  29.     $golos = false;
  30.     foreach((array)$comments_rayt as $val){
  31.         if($val->comment_id==$comment->comment_ID&&$val->user==$user_ID||$comment->user_id==$user_ID) $golos = true;
  32.     }
  33.  
  34.         if($golos == false){
  35.             $count_rayt = get_option('count_rayt_comment');
  36.             if(!$count_rayt) $count_rayt = 1;
  37.             $id_rayt_plus = $comment->comment_ID + $count_rayt;
  38.             $id_rayt_plus = pow($id_rayt_plus, 2);
  39.             $id_rayt_minus = $comment->comment_ID - $count_rayt;
  40.             $id_rayt_minus = pow($id_rayt_minus, 2);
  41.             $rayt .= '<span id="'.$id_rayt_minus.'" class="minus_rayt rayt minus_rayt_comm"></span>
  42.             <span id="'.$id_rayt_plus.'" class="plus_rayt rayt plus_rayt_comm"></span>';
  43.         }
  44.  
  45.     $rayt .= '</span>';
  46.    
  47.     return $text.$rayt;
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
  54. /*===================================================================================*/
  55. /*  Comments
  56. /*==================================================================================*/
  57.  
  58.     $GLOBALS['comment'] = $comment;
  59.     switch ( $comment->comment_type ) :
  60.         case 'pingback' :
  61.         case 'trackback' :
  62.     ?>
  63.     <li class="post pingback">
  64.         <p><?php _e( 'Pingback:',); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit',), '<span class="edit-link">', '</span>' ); ?></p>
  65.     <?php
  66.             break;
  67.         default :
  68.     ?>
  69.     <li id="comment-<?php comment_ID(); ?>">
  70.         <div <?php comment_class('comment-wrapper'); ?> >
  71.                 <div class="comment-avatar">
  72.                     <?php
  73.                         $avatar_size = 65;
  74.                         if ( '0' != $comment->comment_parent )
  75.                             $avatar_size = 65;
  76.  
  77.                         echo get_avatar( $comment, $avatar_size );?>
  78.                 </div>
  79.                 <!--comment avatar-->
  80.                 <div class="comment-meta">
  81.                 <div class="author"><?php if ( $comment->user_id ): ?>
  82.     <a class="author-link" href="<?php echo get_author_posts_url( $comment->user_id ); ?>"><?php echo $comment->comment_author; ?></a>
  83. <?php else: ?>
  84. <span class="unregistered-comment"> <?php echo $comment->comment_author; ?> </span>
  85. <?php endif; ?>
  86. <?php if ( $comment->comment_author ): ?>
  87. <?php else: ?>
  88. <span class="unregistered-comment"> Анонимус </span>
  89. <?php endif; ?>
  90. </div>
  91. <span class="time"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()); ?></span>
  92. <a class="commentid-link" title="Сылка на комментарий" href="<?php echo get_comment_link( $comments->comment_id )?>"> # </a>
  93. <?php echo add_rayting_comment($text); ?>
  94.  
  95.  
  96.  
  97.  
  98.                 </div><!-- /comment-meta -->
  99.                 <?php if ( $comment->comment_approved == '0' ) : ?>
  100.                     <em class="comment-awaiting-moderation"><?php _e( 'Ваш комментарий ожидает модерации'); ?></em>
  101.                     <br />
  102.                 <?php endif; ?>
  103.  
  104.  
  105.             <div class="comment-content">
  106.                 <?php comment_text(); ?>
  107.             </div><!--/comment-content -->
  108.                 <div class="reply">
  109.            
  110.                     <?php edit_comment_link( __( 'Правка'), '<span class="edit-link">', '</span>' ); ?>
  111.                     <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Ответить'), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  112.                 </div> <!--/reply -->          
  113.         </div>  <!--/Comment-wrapper -->             
  114.     <?php
  115.             break;
  116.     endswitch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement