Skip to content

Commit f985a90

Browse files
added comnt deafualt switcher
1 parent c49d4db commit f985a90

File tree

3 files changed

+300
-13
lines changed

3 files changed

+300
-13
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"phpcbf": "@php ./vendor/bin/phpcbf --colors --extensions=php .",
3131
"analyze": "@php ./vendor/bin/phpstan analyze ./",
3232
"build": "@composer install --no-dev"
33-
},
33+
},
3434
"config": {
3535
"allow-plugins": {
3636
"dealerdirect/phpcodesniffer-composer-installer": true,

templates/comments.php

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
<?php
2+
// If the current post is protected by a password and the visitor has not yet
3+
// entered the password we will return early without loading the comments.
4+
// ----------------------------------------------------------------------------------------
5+
if ( post_password_required() ) {
6+
return;
7+
}
8+
9+
/*----------------------------------------
10+
CUSTOM COMMENNS WALKER
11+
-------------------------------------------*/
12+
if ( !function_exists('aae_addon_comment_style') ):
13+
14+
function aae_addon_comment_style( $comment, $args, $depth ) {
15+
if ( 'div' === $args[ 'style' ] ) {
16+
$tag = 'div';
17+
$add_below = 'comment';
18+
} else {
19+
$tag = 'li ';
20+
$add_below = 'div-comment';
21+
}
22+
?>
23+
24+
<<?php
25+
echo wp_kses_post( $tag );
26+
comment_class( empty( $args[ 'has_children' ] ) ? 'no-reply' : 'parent has-reply' );
27+
?> id="comment-<?php comment_ID() ?>"><?php if ( 'div' != $args[ 'style' ] ) { ?>
28+
<div id="div-comment-<?php comment_ID() ?>" class="comment-body"><?php }
29+
?>
30+
31+
<div class="default-details-comment-wrapper mb-50">
32+
<div class="default-details-comment-thumb">
33+
<?php
34+
if ( $args[ 'avatar_size' ] != 0 ) {
35+
echo get_avatar( $comment, $args[ 'avatar_size' ], '', '', array( 'class' => 'comment-avatar float-left' ) );
36+
}
37+
?>
38+
</div>
39+
<div class="default-details-comment-meta">
40+
<h3 class="default-details-comment-name">
41+
<?php
42+
echo get_comment_author_link();
43+
?>
44+
</h3>
45+
<p class="default-details-comment-date">
46+
<?php
47+
echo get_comment_date() .'<span></span>' . get_comment_time();
48+
?>
49+
</p>
50+
<div class="builder-comment-text"><?php comment_text(); ?></div>
51+
<?php
52+
comment_reply_link(
53+
array_merge(
54+
$args, array(
55+
'add_below' => $add_below,
56+
'depth' => $depth,
57+
'max_depth' => $args[ 'max_depth' ]
58+
) ) );
59+
?>
60+
<?php if ( $comment->comment_approved == '0' ) { ?>
61+
<p class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'animation-addons-for-elementor' ); ?></p><br/><?php }
62+
?>
63+
</div>
64+
65+
</div>
66+
<?php if ( 'div' != $args[ 'style' ] ) : ?>
67+
</div><?php
68+
endif;
69+
}
70+
endif;
71+
?>
72+
73+
<?php if ( have_comments() || comments_open()) : ?>
74+
<div id="comments" class="joya--comment joya--blog-post-comment font-heading-prata">
75+
<?php if ( have_comments()) : ?>
76+
77+
<h3 class="comment-num mb-50">
78+
<?php
79+
80+
if(get_comments_number() < 1){
81+
printf( '%1$s ' . esc_html__( 'Comment', 'animation-addons-for-elementor' ), get_comments_number() );
82+
}else{
83+
printf( '%1$s ' . esc_html__( 'Comments', 'animation-addons-for-elementor' ), get_comments_number() );
84+
}
85+
86+
?>
87+
</h3>
88+
89+
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
90+
<nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
91+
92+
<h1 class="screen-reader-text">
93+
<?php esc_html_e( 'Comment navigation', 'animation-addons-for-elementor' ); ?>
94+
</h1>
95+
<div class="nav-previous">
96+
<?php previous_comments_link( esc_html__( '&larr; Older Comments', 'animation-addons-for-elementor' ) ); ?>
97+
</div>
98+
<div class="nav-next">
99+
<?php next_comments_link( esc_html__( 'Newer Comments &rarr;', 'animation-addons-for-elementor' ) ); ?>
100+
</div>
101+
102+
</nav><!-- #comment-nav-above -->
103+
<?php endif; //check for comment navigation ?>
104+
105+
<ul class="joya--comments-list comments-list ">
106+
<?php
107+
wp_list_comments( array(
108+
'reply_text' => sprintf('<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M205 34.8c11.5 5.1 19 16.6 19 29.2v64H336c97.2 0 176 78.8 176 176c0 113.3-81.5 163.9-100.2 174.1c-2.5 1.4-5.3 1.9-8.1 1.9c-10.9 0-19.7-8.9-19.7-19.7c0-7.5 4.3-14.4 9.8-19.5c9.4-8.8 22.2-26.4 22.2-56.7c0-53-43-96-96-96H224v64c0 12.6-7.4 24.1-19 29.2s-25 3-34.4-5.4l-160-144C3.9 225.7 0 217.1 0 208s3.9-17.7 10.6-23.8l160-144c9.4-8.5 22.9-10.6 34.4-5.4z"/></svg> %s',esc_html__('Reply','animation-addons-for-elementor')),
109+
'callback' => 'aae_addon_comment_style',
110+
'style' => 'ul',
111+
'short_ping' => false,
112+
'type' => 'all',
113+
'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
114+
'avatar_size' => 60,
115+
) );
116+
?>
117+
</ul><!-- .comment-list -->
118+
119+
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
120+
<nav id="comment-nav-bellow" class="navigation comment-navigation" role="navigation">
121+
122+
<h1 class="screen-reader-text">
123+
<?php esc_html_e( 'Comment navigation', 'animation-addons-for-elementor' ); ?>
124+
</h1>
125+
126+
<div class="nav-previous">
127+
<?php previous_comments_link( esc_html__( '&larr; Older Comments', 'animation-addons-for-elementor' ) ); ?>
128+
</div>
129+
130+
<div class="nav-next">
131+
<?php next_comments_link( esc_html__( 'Newer Comments &rarr;', 'animation-addons-for-elementor' ) ); ?>
132+
</div>
133+
</nav><!-- #comment-nav-bellow -->
134+
<?php endif; //check for comment navigation ?>
135+
136+
<?php if ( !comments_open() ) : ?>
137+
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'animation-addons-for-elementor' ); ?></p>
138+
<?php endif; ?>
139+
140+
<?php endif; // comments have end ?>
141+
142+
<?php
143+
144+
$post_id = '';
145+
if ( null === $post_id )
146+
$post_id = get_the_ID();
147+
else
148+
$id = $post_id;
149+
150+
$commenter = wp_get_current_commenter();
151+
$user = wp_get_current_user();
152+
$user_identity = $user->exists() ? $user->display_name : '';
153+
154+
$req = get_option( 'require_name_email' );
155+
$aria_req = ( $req ? " aria-required='true'" : '' );
156+
157+
$fields = array(
158+
'author' => '<div class="grid-row"><div class="col-lg-6"><div class="elc-inbd-comment__field mb-30"><label for="author">' . esc_html__( 'Name*' ,'animation-addons-for-elementor' ) . '</label> <input placeholder="'. esc_attr__('Enter Name', 'animation-addons-for-elementor').'" id="author" class="form-input" name="author" type="text" value="' . esc_attr( $commenter[ 'comment_author' ] ) . '" size="30"' . $aria_req . ' /></div></div>',
159+
'email' => '<div class="col-lg-6"><div class="elc-inbd-comment__field mb-30"><label for="email">' . esc_html__( 'Email*' ,'animation-addons-for-elementor' ) . '</label><input placeholder="'. esc_attr__('Enter Email', 'animation-addons-for-elementor').'" id="email" name="email" class="form-input" type="email" value="' . esc_attr( $commenter[ 'comment_author_email' ] ) . '" size="30"' . $aria_req . ' /></div></div> </div>',
160+
);
161+
162+
if ( is_user_logged_in() ) {
163+
$cl = 'loginformuser';
164+
} else {
165+
$cl = '';
166+
}
167+
168+
$button_style = 'btn-hover-divide';
169+
$defaults = [
170+
'fields' => $fields,
171+
'comment_field' => '
172+
<div class="elc-inbd-comment__field order-4">
173+
<label for="name">Comment*</label>
174+
<textarea
175+
id="comment"
176+
name="comment"
177+
aria-required="true"
178+
placeholder="'. esc_attr__('Write your comments......', 'animation-addons-for-elementor').'"
179+
></textarea>
180+
</div>
181+
',
182+
/** This filter is documented in wp-includes/link-template.php */
183+
'must_log_in' => '
184+
<p class="must-log-in">
185+
'.esc_html__('You must be','animation-addons-for-elementor').' <a href="'.esc_url(wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) )).'">'.esc_html__('logged in','animation-addons-for-elementor').'</a> '.esc_html__('to post a comment.','animation-addons-for-elementor').'
186+
</p>',
187+
/** This filter is documented in wp-includes/link-template.php */
188+
'logged_in_as' => '
189+
<p class="logged-in-as">
190+
'.esc_html__('Logged in as','animation-addons-for-elementor').' <a href="'.esc_url(get_edit_user_link()).'">'.esc_html($user_identity).'</a>. <a href="'.esc_url(wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) )).'" title="'.esc_attr__('Log out of this account','animation-addons-for-elementor').'">'.esc_html__('Log out?','animation-addons-for-elementor').'</a>
191+
</p>',
192+
'id_form' => 'commentform',
193+
'id_submit' => 'submit',
194+
'class_form' => 'd-flex flex-column comment-form',
195+
'class_submit' => sprintf("wcf--theme-btn wc-btn-primary %s",esc_attr( $button_style )),
196+
'title_reply_before' => '<h3 id="reply-title" class="elc-inbd-comment__title mb-10">',
197+
'title_reply' => esc_html__( 'Leave a Reply', 'animation-addons-for-elementor' ),
198+
'title_reply_to' => esc_html__( 'Leave a Reply to %s', 'animation-addons-for-elementor' ),
199+
'cancel_reply_link' => esc_html__( 'Cancel Reply', 'animation-addons-for-elementor' ),
200+
'label_submit' => esc_html__( 'Submit Now', 'animation-addons-for-elementor' ),
201+
'submit_field' => '<div class="cf_btn default-details__cmtbtn mt-45 mb-45 order-5">%1$s %2$s</div>',
202+
'submit_button' => '<button name="%1$s" type="submit" id="%2$s" class="%3$s" > %4$s <i class="icon-wcf-checvron-right"></i></button>',
203+
'format' => 'xhtml',
204+
];
205+
206+
comment_form( $defaults );
207+
?>
208+
209+
</div><!-- #comments -->
210+
<?php endif;

0 commit comments

Comments
 (0)