diff --git a/wp-content/themes/cosmopet/comments.php b/wp-content/themes/cosmopet/comments.php index 386d6c1..0a96658 100644 --- a/wp-content/themes/cosmopet/comments.php +++ b/wp-content/themes/cosmopet/comments.php @@ -1,211 +1,10 @@ get_the_ID(), - 'status' => 'approve', - 'parent' => $comment_id, - 'order' => 'ASC' - )); - - if ($replies) { - $count += count($replies); - foreach ($replies as $reply) { - $count += count_nested_replies($reply->comment_ID); - } - } - - return $count; -} - -if (post_password_required()) { - return; -} - -if (!is_user_logged_in()) { - ?> -
-

- , -

-
- get_the_ID(), - 'status' => 'approve', - 'parent' => 0, - 'order' => 'ASC' -)); - -if ($top_level_comments) { - echo '
'; - - foreach ($top_level_comments as $comment) { - ?> -
-
- -
-
- -
-
-

-
- - - pll__('Ответить'), - 'depth' => 1, - 'max_depth' => get_option('thread_comments_depth'), - 'before' => '', - 'after' => '', - ), $comment->comment_ID, get_the_ID()); - ?> -
- -
- comment_ID); - - if (!empty($all_nested_replies)) { - $total_reply_count = count($all_nested_replies); - ?> - - -
-
- -
-
- -
-
-

-
- - - pll__('Ответить'), - 'depth' => 2, - 'max_depth' => get_option('thread_comments_depth'), - 'before' => '', - 'after' => '', - ), $reply->comment_ID, get_the_ID()); - ?> -
- -
- '; -} - -function get_all_nested_replies($comment_id) { - $all_replies = array(); - - $direct_replies = get_comments(array( - 'post_id' => get_the_ID(), - 'status' => 'approve', - 'parent' => $comment_id, - 'order' => 'ASC' - )); - - $all_replies = array_merge($all_replies, $direct_replies); - - foreach ($direct_replies as $reply) { - $deeper_replies = get_all_nested_replies_recursive($reply->comment_ID); - $all_replies = array_merge($all_replies, $deeper_replies); - } - - return $all_replies; -} - -function get_all_nested_replies_recursive($comment_id) { - $replies = get_comments(array( - 'post_id' => get_the_ID(), - 'status' => 'approve', - 'parent' => $comment_id, - 'order' => 'ASC' - )); - - $all_replies = $replies; - - foreach ($replies as $reply) { - $deeper_replies = get_all_nested_replies_recursive($reply->comment_ID); - $all_replies = array_merge($all_replies, $deeper_replies); - } - - return $all_replies; -} - -if (is_user_logged_in()) { - $commenter = wp_get_current_commenter(); - $args = array( - 'fields' => array( - 'author' => '', - 'email' => '', - 'url' => '', - 'cookies' => '', - ), - 'comment_field' => '
', - 'title_reply' => pll__('Оставить комментарий'), - 'title_reply_to' => pll__('Ответить %s'), - 'class_submit' => 'comment-submit-btn', - 'submit_button' => '', - 'submit_field' => '
%1$s %2$s
', - 'cancel_reply_link' => pll__('Отменить'), - 'id_form' => 'commentform', - 'id_submit' => 'submit', - 'title_reply_before' => '

', - 'title_reply_after' => '

', - ); - - comment_form($args); -} -?> \ No newline at end of file +/** + * Start: comments.php + * Стандартный файл WordPress для отображения комментариев к записи + */ +include_component('blog', 'comments'); + +/** + * End: comments.php + */ \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/blog/components/comments/component-controller.php b/wp-content/themes/cosmopet/modules/blog/components/comments/component-controller.php new file mode 100644 index 0000000..9e6b01f --- /dev/null +++ b/wp-content/themes/cosmopet/modules/blog/components/comments/component-controller.php @@ -0,0 +1,53 @@ + $post->ID, + 'status' => 'approve', + 'parent' => 0, + 'order' => 'ASC' +]); + +$context['is_user_logged_in'] = is_user_logged_in(); +$context['comment_form_args'] = [ + 'comment_field' => '
', + 'title_reply' => pll__('Оставить комментарий'), + 'title_reply_to' => pll__('Ответить %s'), + 'cancel_reply_link' => pll__('Отменить'), + 'id_form' => 'commentform', + 'id_submit' => 'submit', + 'class_submit' => 'comment-submit-btn', + 'submit_button' => '', + 'submit_field' => '
%1$s %2$s
', + 'fields' => [ + 'author' => '', + 'email' => '', + 'url' => '', + 'cookies' => '', + ], +]; + +function get_all_nested_replies($comment_id, $post_id) { + $all_replies = []; + $direct_replies = get_comments([ + 'post_id' => $post_id, + 'status' => 'approve', + 'parent' => $comment_id, + 'order' => 'ASC' + ]); + $all_replies = array_merge($all_replies, $direct_replies); + foreach ($direct_replies as $reply) { + $all_replies = array_merge($all_replies, get_all_nested_replies($reply->comment_ID, $post_id)); + } + return $all_replies; +} + +foreach ($context['top_level_comments'] as $comment) { + $comment->replies = get_all_nested_replies($comment->comment_ID, $post->ID); +} + +Timber::render('/blog/comments/comments.twig', $context); +?> diff --git a/wp-content/themes/cosmopet/modules/blog/components/single/assets/css/gp-style-desktop.css b/wp-content/themes/cosmopet/modules/blog/components/single/assets/css/gp-style-desktop.css index 9f75a48..cc07306 100644 --- a/wp-content/themes/cosmopet/modules/blog/components/single/assets/css/gp-style-desktop.css +++ b/wp-content/themes/cosmopet/modules/blog/components/single/assets/css/gp-style-desktop.css @@ -359,9 +359,12 @@ p.discount-description__2 { color: var(--grey-black); } -.comment .comment-block p a { +.comment .comment-block p a, .comment .comment-block p button { color: var(--green-dark); + font-family: inherit; + font-size: inherit; text-decoration: underline; + font-weight: inherit; } .comment .comment-user { diff --git a/wp-content/themes/cosmopet/static/css/front-page.css b/wp-content/themes/cosmopet/static/css/front-page.css index 93de537..9d2022b 100644 --- a/wp-content/themes/cosmopet/static/css/front-page.css +++ b/wp-content/themes/cosmopet/static/css/front-page.css @@ -83,7 +83,7 @@ main { border-radius: 60px; position: relative; z-index: 2; - margin-top: -114px; + margin-top: 0px; padding: 46px 0px 97px; } .about .about_block{ @@ -2082,6 +2082,8 @@ width: 330px; .home { overflow: hidden; height: 100vh; + justify-content: center; + align-items: flex-start; } diff --git a/wp-content/themes/cosmopet/templates/blog/comments/comment-single.twig b/wp-content/themes/cosmopet/templates/blog/comments/comment-single.twig new file mode 100644 index 0000000..393b25e --- /dev/null +++ b/wp-content/themes/cosmopet/templates/blog/comments/comment-single.twig @@ -0,0 +1,63 @@ +
+
+ {{ fn('get_avatar', comment, 50) }} +
+
{{ comment.comment_author }}
+ {{ fn('get_comment_date', 'd F Y', comment) }} +
+
+

{{ comment.comment_content }}

+ +
+ + + + + {{ fn('comment_reply_link', { + reply_text: fn('pll_e', 'Ответить'), + depth: depth, + max_depth: fn('get_option', 'thread_comments_depth'), + before: '', + after: '' + }, comment.comment_ID, post.ID) }} +
+ + + + {% if comment.replies %} + + + {% for reply in comment.replies %} + {% include 'partials/comment.twig' with { comment: reply, depth: depth + 1 } %} + {% endfor %} + {% endif %} +
diff --git a/wp-content/themes/cosmopet/templates/blog/comments/comments.twig b/wp-content/themes/cosmopet/templates/blog/comments/comments.twig new file mode 100644 index 0000000..7489ee2 --- /dev/null +++ b/wp-content/themes/cosmopet/templates/blog/comments/comments.twig @@ -0,0 +1,23 @@ +{% if not post.password_required %} + {% if not is_user_logged_in %} +
+

+ , {{ fn('pll_e', 'чтобы оставлять комментарии') }} +

+
+ {% endif %} + + {% if top_level_comments %} +
+ {% for comment in top_level_comments %} + {% include 'blog/comments/comment-single.twig' with { comment: comment, depth: 1 } %} + {% endfor %} +
+ {% endif %} + + {% if is_user_logged_in %} +
+ {{ fn('comment_form', comment_form_args) }} +
+ {% endif %} +{% endif %}