web/wp-content/themes/selecta/comments.php
changeset 1 0d28b7c10758
equal deleted inserted replaced
0:0d9a58d2c515 1:0d28b7c10758
       
     1 <?php 
       
     2 	global $comment_id, $i, $oddevan;
       
     3 	$oddeven = "";
       
     4 	if ($comments) :
       
     5 ?>       
       
     6 	<h2 class="post-section-title"><?php  echo $post->comment_count; ?> Comments <a name="comments"></a></h2>
       
     7 	<?php
       
     8         foreach ($comments as $comment) :
       
     9             if ($comment->comment_parent == 0) :
       
    10                 $comment_table = $wpdb->prefix . "ocmx_comment_meta";
       
    11                 $comment_meta_sql = "SELECT * FROM $comment_table WHERE commentId = ".$comment->comment_ID." LIMIT 1";
       
    12                 $comment_meta = $wpdb->get_row($comment_meta_sql);
       
    13 		        $comment_type = get_comment_type();
       
    14         ?>
       
    15 		<div class="comment clearfix">
       
    16             <?php if($comment_type == "comment") : ?>
       
    17                 <div class="user">
       
    18                     <?php echo get_avatar( $comment, 40 ); ?>
       
    19                     <a href="#" id="reply-<?php echo $comment->comment_ID ?>" class="reply-link">Reply</a>
       
    20                     
       
    21                 </div>
       
    22             <?php endif; ?>
       
    23 			<div class="comment-post">
       
    24 				<div class="container-header-light-normal"><span></span></div>
       
    25 				<div class="comment-content clearfix">
       
    26 					<h3><a href="<?php comment_author_url(); ?>" class="commentor_url" name="comment-<?php echo $comment->comment_ID; ?>" rel="nofollow"><?php comment_author(); ?></a><span class="comment-date"><?php comment_date() ?> <?php comment_time() ?></span></h3>
       
    27 				  	<?php if ($comment->comment_approved == '0') : ?>
       
    28                         <p>Comment is awaiting moderation.</p>
       
    29                     <?php else :
       
    30                         comment_text();
       
    31                     endif; ?>  
       
    32 				</div>
       
    33 				<div class="container-footer-light-normal"><span></span></div>
       
    34 			</div>
       
    35 			<?php
       
    36                 $comment_id = $comment->comment_ID;
       
    37                 if($comment_type == "comment") :
       
    38                     fetch_comments($comment_id, $i);
       
    39                 endif;
       
    40             ?>
       
    41 			<div style="display: none;" id="new-reply-<?php echo $comment->comment_ID; ?>"></div>
       
    42         </div>
       
    43         <div class="dynamic-footer"><div class="left"></div><div class="right"></div></div>
       
    44         <div style="display: none;" id="form-placement-<?php echo $comment->comment_ID ?>"></div>
       
    45 	<?php
       
    46             endif;
       
    47         endforeach;
       
    48     endif;
       
    49 ?>
       
    50 <div id="new_comments"></div>
       
    51 <div id="original_comment_location">
       
    52     <?php    
       
    53         if ('open' == $post->comment_status) : ?>
       
    54             <div id="comment_form_container">        
       
    55                 <?php if ( get_option('comment_registration') && !$user_ID ) : // If registration required and not logged in ?>
       
    56                     <p>You must be <a href="<?php echo wp_login_url( get_permalink() ); ?>" class="std_link">logged in</a> to post a comment.</p>      
       
    57                 <?php else : ?>
       
    58                     <div class="comment-form-content">
       
    59                        	<h2 class="post-section-title">Leave A Comment</h2>
       
    60 						<p id="commment-post-alert" class="no_display">Posting your comment...</p>
       
    61                         <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" class="comment_form" id="commentform"> 
       
    62                             <?php if ( $user_ID ) : ?>
       
    63                                <div class="checkbox">Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php" class="std_link"><?php echo $user_identity; ?></a>.
       
    64                                <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Logout &raquo;</a></div>
       
    65                             <?php else : ?>
       
    66                                 <?php do_action('fbc_display_login_button') ?>  
       
    67                                 <label>Name</label>
       
    68                                 <div class="comment-input"><input type="text" name="author" id="author" value="<?php if($comment_author != ""){echo $comment_author;}else{echo 'Name';} ?>" size="32" tabindex="1" /></div>
       
    69                                 <label>Email</label>
       
    70                                 <div class="comment-input"><input type="text" name="email" id="email" value="<?php if($comment_author_email != ""){echo $comment_author_email;}else{echo 'EMail Address';} ?>" size="32" tabindex="2" /></div>
       
    71                                 <label>URL</label>
       
    72                                 <div class="comment-input"><input type="text" name="url" id="url" value="<?php if($comment_author_url != ""){echo $comment_author_url;}else{echo 'Website URL';} ?>" size="32" tabindex="3" /></div>
       
    73                             <?php endif; ?>
       
    74                             <label>Twitter</label>
       
    75                             <div class="comment-input"><input type="text" name="twitter" id="twitter" value="<?php if($comment_author_url != ""){echo $comment_author_twitter;}else{echo 'Twitter Name';} ?>" size="32" tabindex="3" /></div>
       
    76                             <label>Message</label>
       
    77                             <div class="comment-texarea"><textarea name="comment" id="comment" cols="40" rows="10" tabindex="4" class="comment"></textarea></div>
       
    78                             <div class="checkbox">
       
    79                                 <input type="checkbox" id="email_subscribe" name="email_subscribe" />
       
    80                                 Subscribe to these comment via email
       
    81                             </div>                            
       
    82                             
       
    83                             <input type="image" src="<?php bloginfo('template_directory'); ?>/images/layout/submit-comment.png" class="submit_button" id="comment_submit" value="Submit Comment" name="cmdSubmit" />
       
    84                             <input type="hidden" id="comment_post_id" name="comment_post_ID" value="<?php echo $id; ?>" />
       
    85                             <input type="hidden" id="comment_parent_id" name="comment_parent_id" value="0" />                         
       
    86                             <?php do_action('comment_form', $post->ID); ?>
       
    87                         </form>
       
    88                     </div>
       
    89                 <?php endif; ?>
       
    90             </div>
       
    91     <?php
       
    92         endif; // if you delete this the sky will fall on your head
       
    93     ?>
       
    94 </div>
       
    95 
       
    96  <?php 
       
    97 		/*****************************/
       
    98 		/* Threaded Replies Function */
       
    99 		function fetch_comments($comment_id, $i)
       
   100 			{		
       
   101 				global $wpdb;
       
   102 				require('wp-load.php');
       
   103 				$sql = "SELECT * FROM $wpdb->comments WHERE comment_parent = ".$comment_id;
       
   104 				$child_comments =  $wpdb->get_results($sql);				
       
   105 				$thread_count = 0;
       
   106 				if(count($child_comments) !== 0) :
       
   107 					$thread_count++ 
       
   108 	?>
       
   109 					<div class="threaded-comments">
       
   110 						<?php
       
   111 							foreach($child_comments as $sub_comment) :
       
   112 								$this_comment = get_comment($sub_comment->comment_ID);
       
   113 								$comment_table = $wpdb->prefix . "ocmx_comment_meta";
       
   114 								$sub_comment_meta_sql = "SELECT * FROM $comment_table WHERE commentId = ".$sub_comment->comment_ID." LIMIT 1";
       
   115 								$sub_comment_meta = $wpdb->get_row($sub_comment_meta_sql);
       
   116 						?>
       
   117                             <div class="thread-comment">
       
   118                                 <div class="user">
       
   119 									<?php echo get_avatar( $this_comment, 40); ?>
       
   120                                 </div>
       
   121                                 <div class="comment-post">
       
   122                                     <div class="container-header-light-normal"><span></span></div>
       
   123                                     <div class="comment-content clearfix">
       
   124                                         <h3>
       
   125                                         	<?php if($sub_comment->comment_author_url !== "http://" && $sub_comment->comment_author_url !== "") : ?>
       
   126                                                <a href="<?php echo $sub_comment->comment_author_url; ?>" class="commentor_url" name="comment-<?php echo $sub_comment->comment_ID; ?>" rel="nofollow"> <?php echo $sub_comment->comment_author; ?></a>
       
   127                                             <?php else : ?>
       
   128                                                  <?php echo $sub_comment->comment_author; ?>
       
   129                                             <?php endif; ?>
       
   130                                             <?php if($sub_comment_meta->twitter !== "") : ?><span class="twitter-link"><a href="http://twitter.com/<?php echo $sub_comment_meta->twitter; ?>" class="commentor_url" rel="nofollow">@<?php echo $sub_comment_meta->twitter; ?></a></span><?php endif; ?>
       
   131                                         	<span class="comment-date"><?php echo date('F d Y', strtotime($sub_comment->comment_date)); ?> <?php echo date("H\:i a", strtotime($sub_comment->comment_date)); ?></span>
       
   132 										</h3>
       
   133                                         <?php if ($sub_comment->comment_approved == '0') : ?>
       
   134                                             <p>Comment is awaiting moderation.</p>
       
   135                                         <?php else :
       
   136                                             $use_comment = apply_filters('wp_texturize', $this_comment->comment_content);
       
   137                                             $use_comment = str_replace("\n", "<br>", $use_comment);
       
   138                                             echo "<p>".$use_comment."</p>";
       
   139                                         endif; ?>
       
   140                                     </div>
       
   141                                     <div class="container-footer-light-normal"><span></span></div>
       
   142                                 </div>
       
   143                             </div>
       
   144 						<?php
       
   145 							endforeach;
       
   146 						?>
       
   147 					</div>
       
   148 	<?php
       
   149 				endif;
       
   150 			}
       
   151 	?>