I made a new Wordpress child-theme based on the Twentytwelve theme and I have some issues with the php comment_reply_link and js moveForm function.
My Problem: My comment reply link works fine on the first click, the comment form will be displayed under the comment and I can add comments or cancel the reply. But when I cancel the reply, the comment reply link will not be shown again. The comment reply link is there and looks correct, but nothing happens on click.
Example of Link generated by comment reply:
First click:
<a class="comment-reply-link" data-onclick="return addComment.moveForm("comment-55", "55", "respond", "129")" href="/ego_fotos_design01/?page_id=129&replytocom=55#respond">Kommentar schreiben</a>
Second click:
<a class="comment-reply-link" data-onclick="return addComment.moveForm("comment-55", "55", "respond", "129")" href="/ego_fotos_design01/?page_id=129&replytocom=55#respond">Kommentar schreiben</a>
This is the function I have written:
function createCommentOut($commentID, $author, $date, $content, $commentImageURL, $isChild){
if($isChild){ $commentType = "comment_type_child"; } else { $commentType = "comment_type_parent"; }
//Get the ID from Current page
$postID = getGundualPostID();
ob_start();
?>
<div id="<?php echo 'comment-' . $commentID; ?>" class ="<?php echo $commentType; ?> comment">
<div class="comment_head">
<span class="comment_headline"><?php echo $date; ?> | <strong><?php echo $author ?></strong></span>
</div>
<div class="comment_content">
<?php if($commentImageURL != false) : ?>
<a href=<?php echo $commentImageURL; ?>>
<img src=<?php echo getGundulaCommentThumb($commentImageURL);?>>
</a>
<?php endif; ?>
<span class="text"><?php echo $content;?></span>
</div>
<div id="" class="reply">
<?php
$replyLinkArray = array(
'reply_text' => __( 'Kommentar schreiben' ),
'depth' => isset( $args['args']['depth'] ) ? $args['args']['depth'] : (int) 1,
'max_depth' => isset( $args['args']['max_depth'] ) ? $args['args']['max_depth'] : (int) 2
);
if (!$isChild) {
comment_reply_link($replyLinkArray, $commentID, $postID);
}
?>
</div>
</div>
<?php
$commentContent = ob_get_contents();
ob_end_clean();
return $commentContent;
}
Remarks: For not logged in user the comment form will be not displayed. It is on the page, but hidden (display: none). So this must be more or less correct, because on the first click the form will be displayed.
My comment form function looks like this:
function twentytwelve_gundula_comment_form($isOnlyVisibleForLoggedInUsers = false){
// Get Current User
$currentUser = wp_get_current_user();
if($isOnlyVisibleForLoggedInUsers && !($currentUser->exists())){
echo '<div style="display: none;">'."
";
}
comment_form();
if($isOnlyVisibleForLoggedInUsers && !($currentUser->exists())){
echo '</div>'."
";
}
}
I think somthing went wrong with the js moveForm function. Do anybody has a clue what is going wrong?