Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * The Template Part for displaying Comments.
- *
- * @license For the full license information, please view the Licensing folder
- * that was distributed with this source code.
- *
- * @package snax
- * @subpackage Theme
- */
- // Prevent direct script access.
- if ( ! defined( 'ABSPATH' ) ) {
- die( 'No direct script access allowed' );
- }
- if ( post_password_required() ) {
- return;
- }
- ?>
- <?php if ( get_comments_number() || comments_open() ) : ?>
- <?php if ( comments_open() ) {
- $post_id = $post->ID ;
- if ( ! comments_open( $post_id ) ) {
- return;
- }
- $max_lenght = apply_filters( 'snax_item_comment_max_length', 250 );
- $action = site_url( '/wp-comments-post.php' );
- $disable_guest_comments = get_option( 'comment_registration' );
- $disable_anonymous_comments = get_option( 'require_name_email' );
- $comments_permalink = apply_filters( 'the_permalink', get_permalink( $post_id ) ) . '/#respond';
- $login_permalink = wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) );
- $must_login_message = sprintf(
- __( 'You must be <a href="%s">logged in</a> to post a comment.' ),
- $login_permalink
- );
- $must_give_data_message = sprintf(
- __( 'Anonymous comments are not allowed, please post with the <a href="%s">full comment form</a>' ),
- $comments_permalink
- );
- if ( ! is_user_logged_in() && $disable_guest_comments ) {
- echo '<p class="must-log-in">' . wp_kses_post( $must_login_message ) . '</p>';
- return;
- }
- if ( ! is_user_logged_in() && $disable_anonymous_comments ) {
- echo '<p class="must-log-in">' . wp_kses_post( $must_give_data_message ) . '</p>';
- return;
- }
- ?>
- <div id="respond" class="comment-respond">
- <small>
- <?php cancel_comment_reply_link( __( 'Cancel reply' ) ); ?>
- </small>
- <form action="<?php echo esc_url( $action ); ?>" method="post" id="commentform" class="comment-form" novalidate="">
- <?php do_action( 'comment_form_top' );?>
- <textarea id="comment" placeholder="<?php echo esc_attr(_x( 'Write a comment…', 'snax' )) ?>*" maxlength="<?php echo esc_attr( $max_lenght ); ?>" name="comment" cols="45" rows="1" aria-required="true"></textarea>
- <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="<?php echo esc_attr__( 'Post', 'snax' ) ?>" disabled="disabled">
- <?php comment_id_fields( $post_id );?>
- </p>
- <?php wp_comment_form_unfiltered_html_nonce();?>
- </form>
- </div>
- <?php
- } ?>
- <section class="comments-area" itemscope itemtype="http://schema.org/UserComments">
- <?php
- $per_page = apply_filters( 'snax_item_on_list_comments_per_page',3 );
- $args = array(
- 'post_id' => $post->ID,
- );
- $comments = get_comments( $args );
- $top_level_comments_count = 0;
- foreach ( $comments as $comment ) {
- if ( ! $comment->comment_parent ) {
- $top_level_comments_count += 1;
- }
- }
- if ( $top_level_comments_count > $per_page ) {
- add_filter( 'snax_display_see_more_for_comment', '__return_true' );
- } else {
- add_filter( 'snax_display_see_more_for_comment', '__return_false' );
- }
- ?>
- <ol class="comment-list" data-snax-top-level-comments="<?php echo esc_attr( $top_level_comments_count ); ?>">
- <?php
- wp_list_comments( array(
- 'type' => 'comment',
- 'per_page' => $per_page,
- ), $comments );
- ?>
- </ol>
- </section><!-- #comments -->
- <?php endif;
Add Comment
Please, Sign In to add comment