library/Controller/Single.php
public static function likeButton($id)
    {
        if (! is_user_logged_in()) {
            return;
        }

        $likes = get_comment_meta($id, '_likes', true);

        if (empty($likes) || is_array($likes) == false) {
            $count = 0;
        } else {
            $count = count($likes);
        }

        $classes = array('like-button');

        if (is_array($likes) == true && in_array(get_current_user_id(), $likes)) {
            $classes[] = 'active';
        }

        $output = '<a class="' . implode(' ', $classes) . '" href="javascript:void(0)" data-comment-id="' . $id . '">';
        $output .= '<span id="like-count">' . $count . '</span>';
        $output .= '</a>';

        return $output;
    }
public static function likeButton($id)
    {
        if (! is_user_logged_in()) {
            return;
        }

        $likes = get_comment_meta($id, '_likes', true);

        if (empty($likes) || is_array($likes) == false) {
            $count = 0;
        } else {
            $count = count($likes);
        }

        $classes = array('like-button');

        if (is_array($likes) == true && in_array(get_current_user_id(), $likes)) {
            $classes[] = 'active';
        }

        $output = '<a class="' . implode(' ', $classes) . '" href="javascript:void(0)" data-comment-id="' . $id . '">';
        $output .= '<span id="like-count">' . $count . '</span>';
        $output .= '</a>';

        return $output;
    }
public static function likeButton ( $ id ) { if ( ! is_user_logged_in ( ) ) { return ; } $ likes = get_comment_meta ( $ id , '_likes' , true ) ; if ( empty ( $ likes ) || is_array ( $ likes ) == false ) { $ count = 0 ; } else { $ count = count ( $ likes ) ; } $ classes = array ( 'like-button' ) ; if ( is_array ( $ likes ) == true && in_array ( get_current_user_id ( ) , $ likes ) ) { $ classes [ ] = 'active' ; } $ output = '<a class="' . implode ( ' ' , $ classes ) . '" href="javascript:void(0)" data-comment-id="' . $ id . '">' ; $ output .= '<span id="like-count">' . $ count . '</span>' ; $ output .= '</a>' ; return $ output ; }
Display comment like button
@param int $id Comment ID
@return string Markup to display button
Display comment like button