Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*===================================================================================*/
- /* Функция отвечающая за рейтинг, в которую и надо вставить условие.
- /*==================================================================================*/
- function add_rayting_comment($text){
- global $comment;
- global $user_ID;
- global $wpdb;
- global $comments_rayt;
- foreach((array)$comments_rayt as $val){
- if($val->comment_id==$comment->comment_ID)
- $sum_rayt = $sum_rayt + $val->rayting;
- }
- $vote_results = '';
- if($sum_rayt&&$user_ID||$sum_rayt===0&&$user_ID) $vote_results = '<span id="vote-results-'.$comment->comment_ID.'" class="vote-results">?</span>';
- if(!$sum_rayt) $sum_rayt = 0;
- if($sum_rayt>0) $sum_rayt = '<span style="color:green">+'.$sum_rayt.'</span>';
- if($sum_rayt<0) $sum_rayt = '<span style="color:red">'.$sum_rayt.'</span>';
- // (условие здесь)
- $rayt = '<span id="com-'.$comment->comment_ID.'" class="comment-rayt">';
- $rayt .= '<span class="rayt-res"><span id="com-karma-'.$comment->comment_ID.'">'.$sum_rayt.'</span></span>';
- $golos = false;
- foreach((array)$comments_rayt as $val){
- if($val->comment_id==$comment->comment_ID&&$val->user==$user_ID||$comment->user_id==$user_ID) $golos = true;
- }
- if($golos == false){
- $count_rayt = get_option('count_rayt_comment');
- if(!$count_rayt) $count_rayt = 1;
- $id_rayt_plus = $comment->comment_ID + $count_rayt;
- $id_rayt_plus = pow($id_rayt_plus, 2);
- $id_rayt_minus = $comment->comment_ID - $count_rayt;
- $id_rayt_minus = pow($id_rayt_minus, 2);
- $rayt .= '<span id="'.$id_rayt_minus.'" class="minus_rayt rayt minus_rayt_comm"></span>
- <span id="'.$id_rayt_plus.'" class="plus_rayt rayt plus_rayt_comm"></span>';
- }
- $rayt .= '</span>';
- return $text.$rayt;
- }
- /*===================================================================================*/
- /* Comments
- /*==================================================================================*/
- $GLOBALS['comment'] = $comment;
- switch ( $comment->comment_type ) :
- case 'pingback' :
- case 'trackback' :
- ?>
- <li class="post pingback">
- <p><?php _e( 'Pingback:',); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit',), '<span class="edit-link">', '</span>' ); ?></p>
- <?php
- break;
- default :
- ?>
- <li id="comment-<?php comment_ID(); ?>">
- <div <?php comment_class('comment-wrapper'); ?> >
- <div class="comment-avatar">
- <?php
- $avatar_size = 65;
- if ( '0' != $comment->comment_parent )
- $avatar_size = 65;
- echo get_avatar( $comment, $avatar_size );?>
- </div>
- <!--comment avatar-->
- <div class="comment-meta">
- <div class="author"><?php if ( $comment->user_id ): ?>
- <a class="author-link" href="<?php echo get_author_posts_url( $comment->user_id ); ?>"><?php echo $comment->comment_author; ?></a>
- <?php else: ?>
- <span class="unregistered-comment"> <?php echo $comment->comment_author; ?> </span>
- <?php endif; ?>
- <?php if ( $comment->comment_author ): ?>
- <?php else: ?>
- <span class="unregistered-comment"> Анонимус </span>
- <?php endif; ?>
- </div>
- <span class="time"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()); ?></span>
- <a class="commentid-link" title="Сылка на комментарий" href="<?php echo get_comment_link( $comments->comment_id )?>"> # </a>
- <?php echo add_rayting_comment($text); ?>
- </div><!-- /comment-meta -->
- <?php if ( $comment->comment_approved == '0' ) : ?>
- <em class="comment-awaiting-moderation"><?php _e( 'Ваш комментарий ожидает модерации'); ?></em>
- <br />
- <?php endif; ?>
- <div class="comment-content">
- <?php comment_text(); ?>
- </div><!--/comment-content -->
- <div class="reply">
- <?php edit_comment_link( __( 'Правка'), '<span class="edit-link">', '</span>' ); ?>
- <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Ответить'), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
- </div> <!--/reply -->
- </div> <!--/Comment-wrapper -->
- <?php
- break;
- endswitch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement