PluginProbe
Qi Blocks / 1.5.3
Qi Blocks v1.5.3
1.5.3 1.5.2 1.5.1 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 All 45 releases
qi-blocks / inc / comments / templates / comments-template.php

comments-template.php in Qi Blocks 1.5.3, at inc/comments/templates/comments-template.php

105 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 // Exit if accessed directly.
5 exit;
6 }
7
8 $post_ID = isset( $post_ID ) && ! empty( $post_ID ) ? intval( $post_ID ) : 0;
9 $attributes = isset( $attributes ) && ! empty( $attributes ) ? (array) $attributes : array();
10 $ajax = isset( $ajax ) && ! empty( $ajax );
11
12 if ( ! empty( $post_ID ) ) {
13 global $wp_rewrite;
14
15 if ( ! comments_open( $post_ID ) && get_comments_number( $post_ID ) && post_type_supports( get_post_type( $post_ID ), 'comments' ) ) {
16 esc_html_e( 'Comments for this post are not enabled.', 'qi-blocks' );
17 } elseif ( comments_open( $post_ID ) || get_comments_number( $post_ID ) ) {
18
19 $comment_query = new WP_Comment_Query(
20 qi_blocks_get_comments_list_args( $post_ID, $ajax )
21 );
22
23 // Get an array of comments for the current post.
24 $comments = ! empty( $comment_query ) ? $comment_query->get_comments() : 0;
25
26 // Check visibility.
27 $comments_enabled = isset( $attributes['showCommentsList'] ) && ! empty( $attributes['showCommentsList'] );
28 $form_enabled = isset( $attributes['showCommentsForm'] ) && ! empty( $attributes['showCommentsForm'] );
29
30 // Set default title tag for sections title.
31 $title_tag = isset( $attributes['titleTag'] ) && ! empty( $attributes['titleTag'] ) ? $attributes['titleTag'] : 'h3';
32
33 // Include comments form template.
34 if ( $comments_enabled && count( $comments ) > 0 ) {
35 $comments_number = get_comments_number( $post_ID );
36 $pagination_comments = $comments;
37
38 if ( $ajax ) {
39 $pagination_comments = ( new WP_Comment_Query( qi_blocks_get_comments_list_args( $post_ID ) ) )->get_comments();
40 }
41 ?>
42 <div id="qodef-comments-list">
43 <<?php echo qi_blocks_escape_title_tag( $title_tag ); ?> class="qodef-m-title"><?php
44 echo esc_html( _n( 'Comment', 'Comments', $comments_number, 'qi-blocks' ) );
45 ?></<?php echo qi_blocks_escape_title_tag( $title_tag ); ?>>
46 <ul class="qodef-m-comments">
47 <?php
48 wp_list_comments(
49 array(
50 'callback' => 'qi_blocks_get_comments_list_template',
51 ),
52 $comments
53 );
54 ?>
55 </ul>
56 <?php
57 // Include pagination comments template.
58 if ( get_comment_pages_count( $pagination_comments ) > 1 ) { ?>
59 <div class="qodef-m-pagination qodef--wp">
60 <?php
61 $pagination_args = array(
62 'base' => add_query_arg( 'cpage', '%#%' ),
63 'format' => '',
64 'total' => get_comment_pages_count( $pagination_comments ),
65 'current' => ! get_query_var( 'cpage' ) ? 1 : get_query_var( 'cpage' ),
66 'add_fragment' => '#comments',
67 'prev_text' => qi_blocks_get_svg_icon( 'icon-arrow-left' ),
68 'next_text' => qi_blocks_get_svg_icon( 'icon-arrow-right' ),
69 );
70
71 if ( $wp_rewrite->using_permalinks() ) {
72 $pagination_args['base'] = user_trailingslashit( trailingslashit( get_permalink() ) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged' );
73 }
74
75 echo _navigation_markup(
76 paginate_links( $pagination_args ),
77 'comments-pagination',
78 esc_html__( 'Comments navigation', 'qi-blocks' ),
79 esc_html__( 'Comments', 'qi-blocks' )
80 );
81 ?>
82 </div>
83 <?php } ?>
84 </div>
85 <?php
86 }
87
88 // Include comments form template.
89 if ( $form_enabled ) {
90 ?>
91 <div id="qodef-comments-form">
92 <?php
93 comment_form(
94 qi_blocks_get_comment_form_args( $attributes ),
95 $post_ID
96 );
97 ?>
98 </div>
99 <?php
100 }
101 } else {
102 esc_html_e( 'Comments on this post are not allowed.', 'qi-blocks' );
103 }
104 }
105