Changeset 8695 for trunk/wp-includes/comment-template.php
- Timestamp:
- 08/20/2008 11:48:09 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/comment-template.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
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.