Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Comments, trackbacks & pings (http://forum.bytesforall.com/forumdisplay.php?f=19)
-   -   recent comments and gravatar (http://forum.bytesforall.com/showthread.php?t=8358)

ylsnuha Jul 18, 2010 08:29 PM

recent comments and gravatar
 
hi,I want to change the Recent Comments code ,make it like the plugin WP-RecentComments.baceuse I think the BFA Recent Comments is not so easy to read and I can`t have the Gravatar. So I find these codes,they woked well on other theme,but I don`t know where to insert in this theme. ok, the codes are here
It`s what they say :copy these code to sidebar.php
Code:

<h3><?php _e('Recent Comments'); ?></h3>
<ul class="recentcomments">
<?php
$my_email = "'" . get_bloginfo ('admin_email') . "'";
$rc_comms = $wpdb->get_results("
  SELECT ID, post_title, comment_ID, comment_author, comment_author_email, comment_content
  FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts
  ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID)
  WHERE comment_approved = '1'
  AND comment_type = ''
  AND post_password = ''
  AND comment_author_email != $my_email
  ORDER BY comment_date_gmt
  DESC LIMIT 10
");
$rc_comments = '';
foreach ($rc_comms as $rc_comm) {
  $a = 'avatar/'.md5(strtolower($rc_comm->comment_author_email)).'.jpg';
  $rc_comments .= "<li><img src='" . $a . "' alt='' title='" . $rc_comm->comment_author
    . "' class='avatar' /><a href='"
    . get_permalink($rc_comm->ID) . "#comment-" . $rc_comm->comment_ID
  //. htmlspecialchars(get_comment_link( $rc_comm->comment_ID, array('type' => 'comment')))
    . "' title='on " . $rc_comm->post_title . "'>" . strip_tags($rc_comm->comment_content)
    . "</a></li>\n";
}
$rc_comments = convert_smilies($rc_comments);
echo $rc_comments;
?>
</ul>

and this code include the Gravatar cache,the codes:
first name a folder "avatar" at the same level as directory wp-content ,set 755.Use a default.jpg as the default gravatar
find function mytheme_comment($comment, $args, $depth) in comments.php or functions.php as this
Code:

<?php echo get_avatar($comment,$size='50',$default='<path_to_url>'  ); ?>
and changed to
Code:

<?php
$f = md5(strtolower($comment->comment_author_email));
$a = get_bloginfo('wpurl'). '/avatar/'. $f. '.jpg';
$e = ABSPATH. 'avatar/'. $f. '.jpg';
$t = 1209600; //  14 days
$d = get_bloginfo('wpurl'). '/avatar/default.jpg';
if ( !is_file($e) || (time() - filemtime($e)) > $t ){
  $r = get_option('avatar_rating');
  $g = 'http://www.gravatar.com/avatar/'. $f. '?s=50&d='. $d. '&r='.$r;
  copy($g, $e); $a = esc_attr($g);
}
if (filesize($e) < 500) copy($d, $e);
?>
<img src='<?php echo $a ?>' alt='' />

ok.codes are here,but I don`t know where I can insert
I don`t want to ues plugin WP-RecentComments and gravatar cache .please help me
I also hope in new version the BFA Recent Comments can be more beautful.

lmilesw Jul 19, 2010 11:57 AM

Why not style the BFA Recent Comments widget or turn off the avatar function on the WP-RecentComments widget? Adding code to the theme files is something I try to never do unless it's a bug fix as later upgrades are more cumbersome.


All times are GMT -6. The time now is 12:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.