<?php

$rgpd_lien = "https://indignation.info/rgpd/";

$current_post_ID  = get_query_var('current_post_ID');

$args = array(
    'post_id' => $current_post_ID,
);

$comments = get_comments($args);
$com_count = wp_count_comments( $current_post_ID );

if ($com_count->all == 0):

  echo "<h3>Aucun commentaire</h3>";

else:

  echo "<h3>Commentaires:</h3>";

endif;

foreach ( $comments as $comment ) :
  $com_parent = $comment->comment_parent;

  if ($com_parent == 0):

    $com_ID = $comment->comment_ID;
    set_query_var('com_ID', $com_ID);
    get_template_part( 'template-parts/comment-wrapper');

    $defaults = array(
        'format'       => 'tree',
        'status'       => 'all',
        'hierarchical' => 'threaded',
        //'orderby'      =>  'comment_ID',
        'orderby' => 'publish_date',
        'order' => 'ASC',
    );
    //TODO
    $children_com = $comment->get_children($defaults);

    foreach ($children_com as $child_com):

      $com_ID = $child_com->comment_ID;
      set_query_var('com_ID', $com_ID);

      get_template_part( 'template-parts/comment-wrapper');

    endforeach;

  endif;

endforeach;

?>

<?php

$args = array(
  'attribute' => "",
  'fields' => array(
//Author field
'author' => '<input id="author" name="author" aria-required="true" placeholder="Votre Nom"></input>',
//Email Field
'email' => '<input id="email" name="email" placeholder="Votre mail*"></input>
<br>
<p><i>*<a href="'. $rgpd_lien .'" target="_blank">Lire notre politique de confidentialité</a></i></p>
',
//URL Field
'url' => '',
//Cookies
'cookies' => ''

),
  'comment_field' => '<p class="comment-form-comment"><textarea id="comment" name="comment" placeholder="Rédiger un commentaire..." aria-required="true"></textarea></p>',

'title_reply'          => __( '' ),
'title_reply_to'       => __( '' ),
'title_reply_before'   => '',
'title_reply_after'    => '',
'comment_notes_before' => '',
'comment_notes_after'  => '',

);


comment_form( $args );

echo "
<br>
<br>
<br>
";
?>