Created
November 4, 2014 09:47
-
-
Save jartes/1a06bf9185801c5cdee4 to your computer and use it in GitHub Desktop.
Comment Callback For WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Callback to render custom comment markup | |
*/ | |
function project_name_comment( $comment, $args, $depth ) { | |
$GLOBALS['comment'] = $comment; | |
// Proceed with normal comments. | |
global $post; | |
?> | |
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> | |
<article id="comment-<?php comment_ID(); ?>" class="comment"> | |
<header class="comment-meta comment-author vcard"> | |
<?php | |
if ( has_wpml_category( 'videos' ) ) { | |
$default_avatar_url = 'video-avatar.png'; | |
} | |
elseif ( has_wpml_category( 'imatges' ) ) { | |
$default_avatar_url = 'photo-avatar.png'; | |
} | |
elseif ( has_wpml_category( 'audios' ) ) { | |
$default_avatar_url = 'audio-avatar.png'; | |
} | |
else { | |
$default_avatar_url = 'text-avatar.png'; | |
} | |
$default_avatar_url = get_template_directory_uri() . "/images/" . $default_avatar_url; | |
?> | |
<?php echo get_avatar( $comment, 79, $default_avatar_url ); ?> | |
<div class="comment-on"> | |
<?php | |
printf( '<cite><b class="fn">%1$s</b> %2$s</cite> | ', | |
get_comment_author_link(), | |
// If current post author is also comment author, make it known visually. | |
( $comment->user_id === $post->post_author ) ? '<span>' . __( "Autor de l'entrada", 'minoria-absoluta' ) . '</span>' : '' | |
); | |
printf( '<time datetime="%1$s">%2$s</time></a>', | |
get_comment_time( 'c' ), | |
sprintf( __( '%1$s', 'minoria-absoluta' ), get_comment_date( 'd.m.Y' ) ) | |
); | |
?> | |
<?php if ( '0' == $comment->comment_approved ) : ?> | |
<p class="comment-awaiting-moderation"><?php _e( 'El comentari està esperant moderació.', 'minoria-absoluta' ); ?></p> | |
<?php endif; ?> | |
</div> | |
</header><!-- .comment-meta --> | |
<section class="comment-content comment"> | |
<?php comment_text(); ?> | |
</section><!-- .comment-content --> | |
</article><!-- #comment-## --> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment