Repository navigation
Expand file tree
/
Copy pathcomments.php
More file actions
175 lines (157 loc) · 8.34 KB
/
Copy pathcomments.php
File metadata and controls
175 lines (157 loc) · 8.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* The template for displaying comments
*
* This is the template that displays the area of the page that contains both the current comments
* and the comment form.
*
* @package jw_mymo
*/
/*
* If the current post is protected by a password and
* the visitor has not yet entered the password we will
* return early without loading the comments.
*/
if ( post_password_required() ) {
return;
}
?>
<div id="comments" class="bg-[#11171f] p-6 rounded shadow-md mt-8 border border-[#202a34]">
<?php
// You can start editing here -- including this checks!
if ( have_comments() ) :
?>
<h2 class="text-2xl font-bold mb-6 text-[#e6920e]">
<?php
$jw_mymo_comment_count = get_comments_number();
if ( '1' === $jw_mymo_comment_count ) {
printf(
/* translators: 1: title. */
esc_html__( 'One thought on “%1$s”', 'jw_mymo' ),
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
);
} else {
printf(
/* translators: 1: comment count number, 2: title. */
esc_html( _nx( '%1$s thought on “%2$s”', '%1$s thoughts on “%2$s”', $jw_mymo_comment_count, 'comments title', 'jw_mymo' ) ),
number_format_i18n( $jw_mymo_comment_count ),
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
);
}
?>
</h2><!-- .comments-title -->
<?php the_comments_navigation(); ?>
<ol class="comment-list space-y-6">
<?php
wp_list_comments(
array(
'style' => 'ol',
'short_ping' => true,
'avatar_size' => 48,
'callback' => function( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
?>
<li id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>>
<article id="div-comment-<?php comment_ID(); ?>" class="comment-body bg-[#151d25] p-4 rounded border border-[#2d3842]">
<footer class="comment-meta flex items-center mb-4">
<div class="comment-author vcard mr-4">
<?php
if ( 0 != $args['avatar_size'] ) {
echo get_avatar( $comment, $args['avatar_size'], '', '', array( 'class' => 'rounded-full border-2 border-brand-accent' ) );
}
?>
</div><!-- .comment-author -->
<div class="comment-metadata text-sm text-gray-400">
<b class="fn text-gray-200"><?php comment_author(); ?></b>
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>" class="hover:text-brand-accent transition-colors ml-2">
<time datetime="<?php comment_time( 'c' ); ?>">
<?php
printf(
/* translators: 1: date, 2: time. */
esc_html__( '%1$s at %2$s', 'jw_mymo' ),
get_comment_date( '', $comment ),
get_comment_time()
);
?>
</time>
</a>
<?php edit_comment_link( esc_html__( 'Edit', 'jw_mymo' ), '<span class="edit-link ml-2">', '</span>' ); ?>
</div><!-- .comment-metadata -->
<?php if ( '0' == $comment->comment_approved ) : ?>
<p class="comment-awaiting-moderation text-yellow-500 text-sm ml-auto"><?php esc_html_e( 'Your comment is awaiting moderation.', 'jw_mymo' ); ?></p>
<?php endif; ?>
</footer><!-- .comment-meta -->
<div class="comment-content text-gray-300 leading-relaxed [&_p]:mb-4 last:[&_p]:mb-0">
<?php comment_text(); ?>
</div><!-- .comment-content -->
<?php
comment_reply_link(
array_merge(
$args,
array(
'add_below' => 'div-comment',
'depth' => $depth,
'max_depth' => $args['max_depth'],
'before' => '<div class="reply mt-4">',
'after' => '</div>',
'reply_text' => '<span class="inline-flex items-center text-sm font-semibold text-brand-accent hover:text-white transition-colors cursor-pointer"><svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"></path></svg>' . esc_html__( 'Reply', 'jw_mymo' ) . '</span>',
)
)
);
?>
</article><!-- .comment-body -->
<?php
}
)
);
?>
</ol><!-- .comment-list -->
<?php
the_comments_navigation();
// If comments are closed and there are comments, let's leave a little note, shall we?
if ( ! comments_open() ) :
?>
<p class="no-comments text-gray-400 mt-6 italic"><?php esc_html_e( 'Comments are closed.', 'jw_mymo' ); ?></p>
<?php
endif;
endif; // Check for have_comments().
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$profile_url = get_edit_profile_url();
$profile_pages = get_pages( array(
'meta_key' => '_wp_page_template',
'meta_value' => 'templates/profile.php',
'number' => 1
) );
if ( !empty( $profile_pages ) ) {
$profile_url = get_permalink( $profile_pages[0]->ID );
}
$user = wp_get_current_user();
$user_identity = $user->exists() ? $user->display_name : '';
$logged_in_as = sprintf(
'<p class="logged-in-as mb-4 text-sm text-gray-400">%s <a href="%s" class="text-brand-accent hover:underline">%s</a>. <a href="%s" class="text-red-400 hover:text-red-500 hover:underline">%s</a></p>',
esc_html__( 'Logged in as', 'jw_mymo' ),
esc_url( $profile_url ),
esc_html( $user_identity ),
esc_url( wp_logout_url( apply_filters( 'the_permalink', get_permalink( get_the_ID() ), get_the_ID() ) ) ),
esc_html__( 'Log out?', 'jw_mymo' )
);
comment_form(
array(
'logged_in_as' => $logged_in_as,
'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title text-2xl font-bold mb-6 text-[#e6920e] mt-8 pt-8 border-t border-[#202a34]">',
'title_reply_after' => '</h2>',
'class_form' => 'comment-form space-y-4',
'comment_field' => '<div class="comment-form-comment"><label for="comment" class="sr-only">' . _x( 'Comment', 'noun', 'jw_mymo' ) . '</label><textarea id="comment" name="comment" cols="45" rows="5" maxlength="65525" required="required" placeholder="' . esc_attr__( 'Write your comment here...', 'jw_mymo' ) . '" class="w-full bg-[#151d25] border border-[#2d3842] rounded px-4 py-3 text-gray-300 focus:outline-none focus:border-brand-accent focus:ring-1 focus:ring-brand-accent"></textarea></div>',
'fields' => array(
'author' => '<div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div class="comment-form-author"><label for="author" class="sr-only">' . __( 'Name', 'jw_mymo' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label><input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245" placeholder="' . esc_attr__( 'Name *', 'jw_mymo' ) . '" ' . $aria_req . ' class="w-full bg-[#151d25] border border-[#2d3842] rounded px-4 py-3 text-gray-300 focus:outline-none focus:border-brand-accent focus:ring-1 focus:ring-brand-accent" /></div>',
'email' => '<div class="comment-form-email"><label for="email" class="sr-only">' . __( 'Email', 'jw_mymo' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label><input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes" placeholder="' . esc_attr__( 'Email *', 'jw_mymo' ) . '" ' . $aria_req . ' class="w-full bg-[#151d25] border border-[#2d3842] rounded px-4 py-3 text-gray-300 focus:outline-none focus:border-brand-accent focus:ring-1 focus:ring-brand-accent" /></div></div>',
'url' => '<div class="comment-form-url"><label for="url" class="sr-only">' . __( 'Website', 'jw_mymo' ) . '</label><input id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" placeholder="' . esc_attr__( 'Website', 'jw_mymo' ) . '" class="w-full bg-[#151d25] border border-[#2d3842] rounded px-4 py-3 text-gray-300 focus:outline-none focus:border-brand-accent focus:ring-1 focus:ring-brand-accent" /></div>',
),
'class_submit' => 'submit bg-brand-accent hover:bg-[#0099cc] text-white font-bold py-2 px-6 rounded transition-colors cursor-pointer',
'submit_button' => '<button name="%1$s" type="submit" id="%2$s" class="%3$s">%4$s</button>',
)
);
?>
</div><!-- #comments -->