Beispiel #1
0
    return;
}
?>
<hr>

<div class="space-top-3x comments-title" id="comments">
	<?php 
printf('<h3 class="text-gray text-right" id="comments-count">%1$s (%2$s)</h3>', _x('Comments', 'comments title', 'appica'), number_format_i18n(get_comments_number()));
?>
</div>

<!-- Comments -->
<div class="space-top-2x space-bottom-2x" id="comments-list">
	<?php 
if (have_comments()) {
    wp_list_comments(array('style' => 'div', 'callback' => 'appica_comment', 'end-callback' => 'appica_comment_end', 'max_depth' => appica_comments_nesting_level(), 'per_page' => -1, 'type' => 'comment', 'reply_text' => __('Reply', 'appica'), 'avatar_size' => 48, 'short_ping' => true));
}
// have_comments()
?>
</div>

<?php 
// If comments are closed and there are comments, let's leave a little note, shall we?
if (!comments_open() && '0' != get_comments_number() && post_type_supports(get_post_type(), 'comments')) {
    ?>
	<p class="no-comments"><?php 
    _e('Comments are closed.', 'appica');
    ?>
</p>
<?php 
}
Beispiel #2
0
/**
 * Comment form AJAX callback
 *
 * @param int $comment_ID     Comment ID
 * @param int $comment_status Comment status: 0 - not approved, 1 - approved
 */
function appica_ajax_comment_callback($comment_ID, $comment_status)
{
    if (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || 'xmlhttprequest' !== strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])) {
        die;
    }
    // Get the comment data
    $comment = get_comment($comment_ID);
    // Allow the email to the author to be sent
    wp_notify_postauthor($comment_ID);
    if (0 == $comment->comment_approved) {
        /**
         * Remove comment content, if not approved.
         * @see /appica/comments.php
         */
        $comment->comment_content = '';
    }
    $depth = appica_comments_nesting_level();
    $args = array('style' => 'div', 'callback' => 'appica_comment', 'end-callback' => 'appica_comment_end', 'max_depth' => $depth, 'per_page' => -1, 'type' => 'comment', 'reply_text' => __('Reply', 'appica'), 'avatar_size' => 48, 'short_ping' => true, 'echo' => false);
    $comments[0] = $comment;
    $response = wp_list_comments($args, $comments);
    /*
     * As we pass only one comment to wp_list_comments(), function returns html with .depth-1 class.
     * For top-level comments it is not a problem, but for replies (Appica 2 supports 2-level nested comments)
     * class have to be .depth-2 or higher
     *
     * Remove the Reply link, too!
     */
    if (!empty($depth) && (int) $comment->comment_parent > 0) {
        $response = str_replace('depth-1', "depth-{$depth}", $response);
        $response = preg_replace('/<a class=[\'|"]comment-reply-link \\b[^>]*>.*?<\\/a>/iu', '', $response, 1);
    }
    // Kill the script, returning the comment HTML
    wp_send_json_success(array('comment_id' => $comment_ID, 'comment' => $response));
}