get_comment_class example


function comment_class( $css_class = '', $comment = null, $post = null, $display = true ) {
    // Separates classes with a single space, collates classes for comment DIV.     $css_class = 'class="' . implode( ' ', get_comment_class( $css_class$comment$post ) ) . '"';

    if ( $display ) {
        echo $css_class;
    } else {
        return $css_class;
    }
}

/** * Returns the classes for the comment div as an array. * * @since 2.7.0 * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object. * * @global int $comment_alt * @global int $comment_depth * @global int $comment_thread_alt * * @param string|string[] $css_class Optional. One or more classes to add to the class list. * Default empty. * @param int|WP_Comment $comment_id Optional. Comment ID or WP_Comment object. Default current comment. * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. * @return string[] An array of classes. */
public function single_row( $item ) {
        global $post$comment;

        $comment = $item;

        $the_comment_class = wp_get_comment_status( $comment );

        if ( ! $the_comment_class ) {
            $the_comment_class = '';
        }

        $the_comment_class = implode( ' ', get_comment_class( $the_comment_class$comment$comment->comment_post_ID ) );

        if ( $comment->comment_post_ID > 0 ) {
            $post = get_post( $comment->comment_post_ID );
        }

        $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );

        echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
        $this->single_row_columns( $comment );
        echo "</tr>\n";

        
Home | Imprint | This part of the site doesn't use cookies.