ThemeShaper Forums » Thematic

[closed]

Getting Comment Avatars from the Simple Facebook Connect Plugin

(4 posts)
  • Started 3 years ago by devonharper
  • Latest reply from JohnS
  • This topic is not resolved
  1. After installing the Simple Facebook Connect plugin for WordPress, I noticed that the Facebook avatar was not showing up in the comments list on the page or single view. After digging around a bit, I managed to come up with the following solution. I added the following functions to my childtheme.


    // creates the list comments arguments
    function childtheme_list_comments_arg() {
    $content = 'type=comment&callback=childtheme_comments';
    return $content;
    }
    add_filter('list_comments_arg', 'childtheme_list_comments_arg');


    // Produces an avatar image with the hCard-compliant photo class
    function childtheme_commenter_link() {
    global $comment;
    $commenter = get_comment_author_link();
    if ( ereg( '<a[^>]* class=[^>]+>', $commenter ) ) {
    $commenter = ereg_replace( '(<a[^>]* class=[\'"]?)', '\\1url ' , $commenter );
    } else {
    $commenter = ereg_replace( '(<a )/', '\\1class="url "' , $commenter );
    }
    $avatar_size = apply_filters( 'avatar_size', '80' ); // Available filter: avatar_size
    $avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $comment, $avatar_size ) );
    echo $avatar . ' <span class="fn n">' . $commenter . '</span>';
    } // end childtheme_commenter_link


    // Custom callback to list comments in the Thematic style
    function childtheme_comments($comment, $args, $depth) {
    $GLOBALS['comment'] = $comment;
    $GLOBALS['comment_depth'] = $depth;
    ?>
    <li id="comment-<?php comment_ID() ?>" class="<?php thematic_comment_class() ?>">
    <div class="comment-author vcard"><?php childtheme_commenter_link() ?></div>
    <div class="comment-meta">
    <?php
    printf(__('Posted %1$s at %2$s <span class="meta-sep">|</span> Permalink', 'thematic'),
    get_comment_date(),
    get_comment_time(),
    '#comment-' . get_comment_ID() );
    edit_comment_link(__('Edit', 'thematic'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>');
    ?>
    </div>
    <?php if ($comment->comment_approved == '0') : ?>
    <span class='unapproved'><?php _e("Your comment is awaiting moderation.", 'thematic') ?></span>
    <?php endif; ?>
    <div class="comment-content">
    <?php comment_text() ?>
    </div>
    <?php // echo the comment reply link with help from Justin Tadlock http://justintadlock.com/ and Will Norris http://willnorris.com/
    if($args['type'] == 'all' || get_comment_type() == 'comment') :
    comment_reply_link(array_merge($args, array(
    'reply_text' => __('Reply','thematic'),
    'login_text' => __('Log in to reply.','thematic'),
    'depth' => $depth,
    'before' => '<div class="comment-reply-link">',
    'after' => '</div>'
    )));
    endif;
    ?>
    <?php
    } // end of childtheme_comments

    All 3 functions are basically required to override the thematic_commenter_link() function. I think the Simple Facebook Connect plugin requires that the get_avatar function be given the $comment object as opposed to the $avatar_email variable.

    I am not sure if this messes up anything else in Thematic, but it seems to be working for me. If anyone has a better solution, I would love to hear it.

    Posted 3 years ago #
  2. Thanks. let me try...

    Posted 3 years ago #
  3. AnotherAndrew
    Member

    You are a genius.

    I have been looking at how to fix the same problem but in the Simple Twitter Connect plugin. Your code above works for the twitter plugin.

    I had been fiddling around with this code, but I now see I missed alot that needed to be edited.

    Thanks!

    Posted 2 years ago #
  4. JohnS
    Member

    Powerful. I am a beginning developer and this really, really helps me out man! Check it out on my where I talk about http://www.freewareoverzicht.nl/hack-tools/facebook-hacken

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.