This topic has 4 replies, 3 voices, and was last updated 9 years by Radu.

  • Author
  • #119832
     jbf388
    Participant

    I am using the myCRED plugin and they provide a code to get their “ranks” add on to show up next to the persons name in the comments section.

    The code is designed for the twenty-twelve theme so I was wondering if I am doing this correctly. I replaced all instances of “twentytwelve” and “twentytwelve_comment” with kleo and kleo_comment respectively.

    Do you mind taking a gander at this to see if there is anything that pops out as obviously wrong?

    I know this is not your plugin but I just want to make sure kleo_comment was right to use and if there is anything else you can see that needs fixed would be so helpful.

    Thank you

     

    //add custom comment class NOT WORKING

    add_filter( ‘comment_class’, ‘insert_rank_into_comment_class’, 10, 4 );

    function insert_rank_into_comment_class( $classes, $class, $comment_id, $post_id )

    {

    $comment = get_comment( $comment_id );

    if ( $comment->user_id == 0 ) return $classes;

    $classes[] = ‘rank-‘ . mycred_get_users_rank( $comment->user_id, ‘post_name’ );

    return $classes;

    }

    function kleo_comment( $comment, $args, $depth ) {

    $GLOBALS[‘comment’] = $comment;

    switch ( $comment->comment_type ) :

    case ‘pingback’ :

    case ‘trackback’ :

    // Display trackbacks differently than normal comments.

    ?>

    <li <?php comment_class(); ?> id=”comment-<?php comment_ID(); ?>”>

    <p><?php _e( ‘Pingback:’, ‘kleo’ ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( ‘(Edit)’, ‘kleo’ ), ‘<span class=”edit-link”>’, ‘</span>’ ); ?></p>

    <?php

    break;

    default :

    // 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

    echo get_avatar( $comment, 44 );

    // Insert rank logo

    if ( $comment->user_id != 0 )

    echo mycred_get_users_rank( $comment->user_id, ‘logo’, ‘post-thumbnail’, array( ‘class’ => ‘mycred-rank’ ) );

    printf( ‘<cite class=”fn”>%1$s %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> ‘ . __( ‘Post author’, ‘kleo’ ) . ‘</span>’ : ”

    );

    printf( ‘<a href=”%1$s”><time datetime=”%2$s”>%3$s</time></a>’,

    esc_url( get_comment_link( $comment->comment_ID ) ),

    get_comment_time( ‘c’ ),

    /* translators: 1: date, 2: time */

    sprintf( __( ‘%1$s at %2$s’, ‘kleo’ ), get_comment_date(), get_comment_time() )

    );

    // Insert rank title

    if ( $comment->user_id != 0 )

    echo ‘<div class=”fn authors-rank” style=”margin-left:6.071428571rem;”>Rank: ‘ . mycred_get_users_rank( $comment->user_id ) . ‘</div>’;

    ?>

    </header><!– .comment-meta –>

    <?php if ( ‘0’ == $comment->comment_approved ) : ?>

    <p class=”comment-awaiting-moderation”><?php _e( ‘Your comment is awaiting moderation.’, ‘kleo’ ); ?></p>

    <?php endif; ?>

    <section class=”comment-content comment”>

    <?php comment_text(); ?>

    <?php edit_comment_link( __( ‘Edit’, ‘kleo’ ), ‘<p class=”edit-link”>’, ‘</p>’ ); ?>

    </section><!– .comment-content –>

    <div class=”reply”>

    <?php comment_reply_link( array_merge( $args, array( ‘reply_text’ => __( ‘Reply’, ‘kleo’ ), ‘after’ => ‘ ↓’, ‘depth’ => $depth, ‘max_depth’ => $args[‘max_depth’] ) ) ); ?>

    </div><!– .reply –>

    </article><!– #comment-## –>

    <?php

    break;

    endswitch; // end comment_type check

     

    }

     

    #120073
     Laura
    Moderator
    Not marked as solution
    #120276
     Radu
    Moderator
    Not marked as solution
    #120329
     jbf388
    Participant
    Not marked as solution
    #120586
     Radu
    Moderator
    Not marked as solution
Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘Plugins questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?