Changeset 8695
- Timestamp:
- 08/20/2008 11:48:09 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/classic/comments.php
r7361 r8695 13 13 14 14 <?php foreach ($comments as $comment) : ?> 15 <li id="comment-<?php comment_ID() ?>">15 <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>"> 16 16 <?php echo get_avatar( $comment, 32 ); ?> 17 17 <?php comment_text() ?> -
trunk/wp-content/themes/default/comments.php
r7888 r8695 15 15 16 16 /* This variable is for alternating comment background */ 17 $oddcomment = ' class="alt"';17 $oddcomment = 'alt'; 18 18 ?> 19 19 … … 27 27 <?php foreach ($comments as $comment) : ?> 28 28 29 <li <?php echo $oddcomment;?>id="comment-<?php comment_ID() ?>">29 <li <?php comment_class($oddcomment) ?>id="comment-<?php comment_ID() ?>"> 30 30 <?php echo get_avatar( $comment, 32 ); ?> 31 31 <cite><?php comment_author_link() ?></cite> Says: … … 43 43 <?php 44 44 /* Changes every other comment to a different class */ 45 $oddcomment = ( empty( $oddcomment ) ) ? ' class="alt"' : '';45 $oddcomment = ( empty( $oddcomment ) ) ? 'alt' : ''; 46 46 ?> 47 47 -
trunk/wp-includes/comment-template.php
r8600 r8695 217 217 function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { 218 218 echo get_comment_author_url_link( $linktext, $before, $after ); 219 } 220 221 /** 222 * Generates semantic classes for each comment element 223 * 224 * @since 2.7 225 * 226 * @param string|array $class One or more classes to add to the class list 227 * @param int $comment_id An optional comment ID 228 * @param int $post_id An optional post ID 229 */ 230 function comment_class( $class = '', $comment_id = null, $post_id = null ) { 231 // Separates classes with a single space, collates classes for post DIV 232 echo 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"'; 233 } 234 235 /** 236 * Returns the classes for the comment div as an array 237 * 238 * @since 2.7 239 * 240 * @param string|array $class One or more classes to add to the class list 241 * @param int $comment_id An optional comment ID 242 * @param int $post_id An optional post ID 243 * @return array Array of classes 244 */ 245 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { 246 static $comment_alt; 247 248 $comment = get_comment($comment_id); 249 250 $classes = array(); 251 252 // Get the comment type (comment, trackback), 253 $classes[] = $comment->comment_type; 254 255 // If the comment author has an id (registered), then print the log in name 256 if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) { 257 // For all registered users, 'byuser' 258 $classes[] = 'byuser comment-author-' . $user->user_nicename; 259 // For comment authors who are the author of the post 260 if ( $post = get_post($post_id) ) { 261 if ( $comment->user_id === $post->post_author ) 262 $classes[] = 'bypostauthor'; 263 } 264 } 265 266 if ( empty($comment_alt) ) 267 $comment_alt = 0; 268 269 if ( $comment_alt % 2 ) 270 $classes[] = 'odd'; 271 else 272 $classes[] = 'even'; 273 274 $comment_alt++; 275 276 if ( !empty($class) ) { 277 if ( !is_array( $class ) ) 278 $class = preg_split('#\s+#', $class); 279 $classes = array_merge($classes, $class); 280 } 281 282 return apply_filters('comment_class', $classes, $class, $comment_id, $post_id); 219 283 } 220 284
Note: See TracChangeset
for help on using the changeset viewer.