function dialogue_manage_comment_custom_column($col, $comment_id = 0)
{
    $comment = get_comment($comment_id, ARRAY_A);
    $cmid = $comment['comment_ID'];
    if ($col == 'comment_content') {
        echo '<strong>Opinião</strong><br />';
        echo '<div>' . get_comment_meta($cmid, 'opiniao', true) . '</div>';
        echo '<strong>Proposta</strong><br />';
        echo '<div>' . get_comment_meta($cmid, 'proposta', true) . '</div>';
        if (trim(get_comment_meta($cmid, 'contribuicao', true) != '')) {
            echo '<strong>Contribuição</strong>';
            echo '<div>' . get_comment_meta($cmid, 'contribuicao', true) . '</div>';
        }
    } else {
        if ($col == 'justificativa') {
            echo '<div>' . get_comment_meta($cmid, 'justificativa', true) . '</div>';
        } else {
            if ($col == 'dialogue_paragraph') {
                $post = get_post($comment["comment_post_ID"]);
                $pid = (string) get_comment_meta($comment['comment_ID'], DIALOGUE_CF_PARAGRAPH, true);
                $paragraphs = dialogue_api_parse_content(wpautop($post->post_content));
                $paragraph = $paragraphs[$pid];
                echo "<strong>{$pid}</strong> &mdash ";
                echo wp_html_excerpt($paragraph, 128) . '...';
            } else {
                if ($col == 'dialogue_tags') {
                    $cid = $comment["comment_ID"];
                    $tags = dialogue_api_get_comment_tags($cid);
                    $len = sizeof($tags);
                    for ($i = 0; $i < $len; $i++) {
                        $name = $tags[$i]->name;
                        if (trim($name) == "") {
                            continue;
                        }
                        echo "#{$name}" . ($i != $len - 1 ? ", " : "");
                    }
                }
            }
        }
    }
}
function dialogue_api_get_comments_without_paragraphs($post)
{
    global $wpdb;
    $sql = "SELECT\n      c.comment_ID, c.comment_post_ID, c.comment_author, c.comment_author_email, c.comment_author_IP,\n      c.comment_author_url, c.comment_date, c.comment_date_gmt,\n      c.comment_content, c.comment_karma, c.comment_agent,\n      c.comment_type, c.comment_parent, um.meta_value AS user_name\n    FROM\n      {$wpdb->usermeta} AS um,\n      {$wpdb->comments} AS c\n    INNER JOIN {$wpdb->prefix}commentmeta as m\n      ON (m.comment_ID = c.comment_ID)\n    WHERE c.comment_post_ID = %d\n      AND m.meta_key = '" . DIALOGUE_CF_PARAGRAPH . "'\n      AND m.meta_value = ''\n      AND c.comment_approved = 1\n      AND um.user_id = c.user_id\n      AND um.meta_key = 'nomecompleto'\n    ORDER BY c.comment_ID;";
    $query = $wpdb->prepare($sql, $post);
    $comments = $wpdb->get_results($query);
    /* Getting meta values for the comments */
    $result = array();
    foreach ($comments as $comment) {
        $comment->instituicao = esc_attr(get_the_author_meta('instituicao', $comment->user_id));
        $comment->user_meta = dialogue_api_get_user_meta($comment->comment_author_email);
        $comment->meta = array();
        $sql = "SELECT meta_key, meta_value\n        FROM {$wpdb->prefix}commentmeta\n        WHERE comment_id = {$comment->comment_ID}";
        foreach ($wpdb->get_results($sql) as $m) {
            $comment->meta[$m->meta_key] = $m->meta_value;
        }
        $comment->comment_author_email = null;
        $comment->tags = dialogue_api_get_comment_tags($comment->comment_ID);
        array_push($result, $comment);
    }
    return $result;
}
function dialogue_comment_div($cid, $pid, $post)
{
    $children = dialogue_api_get_children_paragraph_comments($cid);
    ?>
  <li>
    <?php 
    if (get_post_meta($pid, DIALOGUE_PMF_SHOW_COMMENTS, true) == "true") {
        echo get_avatar(get_comment_author_email(), '48');
        ?>
    <div class="comdados">
      <strong><?php 
        echo get_comment_author_link();
        ?>
</strong>
      em <?php 
        echo get_comment_date('d/m/Y H:i');
        ?>

      <?php 
        $tags = dialogue_api_get_comment_tags($cid);
        $len_tags = count($tags);
        if ($len_tags != 0) {
            ?>

      <div class="tags">
        <label>Tags:</label>
        <?php 
            for ($i = 0; $i < $len_tags; $i++) {
                echo $tags[$i]->name;
                if ($i < $len_tags - 1) {
                    echo ', ';
                }
            }
            ?>
      </div>
      <?php 
        }
        ?>

    </div>
    <?php 
    }
    ?>

    <div class="comdata">

      <?php 
    if (get_post_meta($pid, DIALOGUE_PMF_SHOW_COMMENTS, true) == "true") {
        ?>
      <strong>Texto do comentário:</strong>
      <div id="comment-area-<?php 
        echo $cid;
        ?>
">
        <?php 
        echo dialogue_comment_outline($cid, get_comment_text());
        ?>
      </div>
      <div style="display:none" id="comment-full-<?php 
        echo $cid;
        ?>
">
        <?php 
        comment_text();
        ?>
      </div>
      <?php 
        $new_text = get_comment_meta($cid, DIALOGUE_CF_NEWTEXTPROPOSAL, true);
        if (!empty($new_text)) {
            echo '<div class="newText clear">';
            echo '<strong>Proposta de nova redação:</strong> ';
            echo '<p>' . $new_text . '</p>';
            echo '</div>';
        }
        ?>
      <div class="responderspace">
        <button
           title="Clique aqui para responder ao autor deste comentário"
           onclick="jQuery('#comment-the-comment-<?php 
        echo $cid;
        ?>
').show();
                    jQuery(this).hide()">
          Responder
        </button>
      </div>
      <?php 
    }
    ?>

      <div style="display:none" id="comment-the-comment-<?php 
    echo $cid;
    ?>
">

        <form
           action="<?php 
    echo get_option('siteurl');
    ?>
/wp-comments-post.php"
           method="post" id="commentform-<?php 
    echo $pid . $cid;
    ?>
">

          <input type="hidden" name="dialogue_comment_paragraph"
                 value="<?php 
    echo $pid;
    ?>
">
          <input type="hidden" name="comment_post_ID"
                 value="<?php 
    echo $post->ID;
    ?>
">
          <input type="hidden" name="comment_parent"
                 value="<?php 
    echo $cid;
    ?>
" />

          <ol>
            <li>
              <label>Deixe seu comentário</label>
              <textarea name="comment"
                        class="comment required wider"></textarea>
            </li>
            <li class="tag">
              <label>Tags <em>(separadas por vírgula)</em></label>
              <input type="text" name="comment_tags" class="border wider"/>
            </li>
            <li class="newText">
              <input type="checkbox" name="new_text_check"
                     class="checkNewText" id="new_text_check" />
              <label for="new_text_check">
                Quero sugerir uma nova redação
              </label>
              <textarea name="dialogue_comment_new_text"
                        class="newText wider"></textarea>
            </li>
            <li class="last">
              <input type="submit" value="Enviar" />
            </li>
          </ol>

        </form>
      </div>
    </div>

    <?php 
    if (get_post_meta($pid, DIALOGUE_PMF_SHOW_COMMENTS, true) == "true") {
        echo dialogue_expand_children($children, $pid, $post);
    }
    ?>
  </li>
<?php 
}