comment-form.php 33.6 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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
<?php
if (!defined("ABSPATH")) {
    exit();
}

$loadStartTime = WpdiscuzHelper::getMicrotime();
global $post;
$wpdiscuz = wpDiscuz();

$currentUser = $wpdiscuz->helper->getCurrentUser();
do_action("wpdiscuz_before_load", $post, $currentUser);

$load = apply_filters("wpdiscuz_load_template", true, $currentUser, $post);
if (!post_password_required($post->ID) && $load) {
    $commentsCount = get_comments_number();
    $wpCommClasses = [];
    $wpCommClasses[] = $currentUser && $currentUser->ID ? "wpdiscuz_auth" : "wpdiscuz_unauth";
    $wpCommClasses[] = $wpdiscuz->options->thread_styles["theme"];

    if (!$wpdiscuz->options->thread_layouts["showAvatars"] || !$wpdiscuz->options->wp["showAvatars"]) {
        $wpCommClasses[] = "wpdiscuz_no_avatar";
    }

    if ((isset($_GET["deleteComments"]) && $_GET["deleteComments"])) {
        $decodedEmail = get_transient(WpDiscuzConstants::TRS_USER_HASH . trim(sanitize_text_field($_GET["deleteComments"])));
        if ($decodedEmail) {
            $comments = get_comments(["author_email" => $decodedEmail, "status" => "all", "fields" => "ids"]);
            if ($comments) {
                foreach ($comments as $k => $cid) {
                    wp_delete_comment($cid, true);
                }
                ?>
                <script>
                    jQuery(document).ready(function ($) {
                        wpdMessagesOnInit('<?php esc_html_e($wpdiscuz->options->getPhrase("wc_comments_are_deleted")); ?>', 'success');
                    });
                </script>
                <?php
            }
        }
    } else if (isset($_GET["deleteSubscriptions"]) && $_GET["deleteSubscriptions"]) {
        $decodedEmail = get_transient(WpDiscuzConstants::TRS_USER_HASH . trim(sanitize_text_field($_GET["deleteSubscriptions"])));
        if ($decodedEmail) {
            $wpdiscuz->dbManager->unsubscribeByEmail($decodedEmail);
            ?>
            <script>
                jQuery(document).ready(function ($) {
                    wpdMessagesOnInit('<?php esc_html_e($wpdiscuz->options->getPhrase("wc_cancel_subs_success")); ?>', 'success');
                });
            </script>
            <?php
        }
    } else if (isset($_GET["deleteFollows"]) && $_GET["deleteFollows"]) {
        $decodedEmail = get_transient(WpDiscuzConstants::TRS_USER_HASH . trim(sanitize_text_field($_GET["deleteFollows"])));
        if (get_transient(WpDiscuzConstants::TRS_USER_HASH . md5($decodedEmail)) !== false) {
            $wpdiscuz->dbManager->unfollowByEmail($decodedEmail);
            ?>
            <script>
                jQuery(document).ready(function ($) {
                    wpdMessagesOnInit('<?php esc_html_e($wpdiscuz->options->getPhrase("wc_cancel_follows_success")); ?>', 'success');
                });
            </script>
            <?php
        }
    } else if (isset($_GET["wpdiscuzFollowID"]) && isset($_GET["wpdiscuzFollowKey"]) && isset($_GET["wpDiscuzComfirm"])) {
        if ($_GET["wpDiscuzComfirm"]) {
            if ($wpdiscuz->dbManager->confirmFollow(sanitize_text_field($_GET["wpdiscuzFollowID"]), sanitize_text_field($_GET["wpdiscuzFollowKey"]))) {
                ?>
                <script>
                    jQuery(document).ready(function ($) {
                        wpdMessagesOnInit('<?php esc_html_e($wpdiscuz->options->getPhrase("wc_follow_confirm_success")); ?>', 'success');
                    });
                </script>
                <?php
            }
        } else {
            if ($wpdiscuz->dbManager->cancelFollow(sanitize_text_field($_GET["wpdiscuzFollowID"]), sanitize_text_field($_GET["wpdiscuzFollowKey"]))) {
                ?>
                <script>
                    jQuery(document).ready(function ($) {
                        wpdMessagesOnInit('<?php esc_html_e($wpdiscuz->options->getPhrase("wc_follow_cancel_success")); ?>', 'success');
                    });
                </script>
                <?php
            }
        }
    }

    if (isset($_GET["wpdiscuzSubscribeID"]) && isset($_GET["key"])) {
        $wpdiscuz->dbManager->unsubscribe(sanitize_text_field($_GET["wpdiscuzSubscribeID"]), sanitize_text_field($_GET["key"]));
        ?>
        <script>
            jQuery(document).ready(function ($) {
                wpdMessagesOnInit('<?php esc_html_e($wpdiscuz->options->getPhrase("wc_unsubscribe_message")); ?>', 'success');
            });
        </script>
        <?php
    }

    if (isset($_GET["wpdiscuzConfirmID"]) && isset($_GET["wpdiscuzConfirmKey"]) && isset($_GET["wpDiscuzComfirm"])) {
        $wpdiscuz->dbManager->notificationConfirm(sanitize_text_field($_GET["wpdiscuzConfirmID"]), sanitize_text_field($_GET["wpdiscuzConfirmKey"]));
        ?>
        <script>
            jQuery(document).ready(function ($) {
                wpdMessagesOnInit('<?php esc_html_e($wpdiscuz->options->getPhrase("wc_comfirm_success_message")); ?>', 'success');
            });
        </script>
        <?php
    }
    ?>
    <div class="wpdiscuz_top_clearing"></div>
    <?php
    $form = $wpdiscuz->wpdiscuzForm->getForm($post->ID);

    $wpCommClasses[] = "wpd-layout-" . $form->getLayout();
    $commentsOpen = comments_open($post);
    $wpCommClasses[] = $commentsOpen ? "wpd-comments-open" : "wpd-comments-closed";
    $wpCommClasses = apply_filters("wpdiscuz_container_classes", $wpCommClasses);

    $wpCommClasses = implode(" ", $wpCommClasses);

    $currentUserId = 0;
    $currentUserEmail = isset($_COOKIE["comment_author_email_" . COOKIEHASH]) ? sanitize_email($_COOKIE["comment_author_email_" . COOKIEHASH]) : "";
    if ($currentUser && $currentUser->ID) {
        $currentUserId = $currentUser->ID;
        $currentUserEmail = $currentUser->user_email;
    }

    $isShowSubscribeBar = $form->isShowSubscriptionBar() && WpdiscuzHelper::isUserCanFollowOrSubscribe($currentUserEmail);
    $isPostmaticActive = !class_exists("Prompt_Comment_Form_Handling") || (class_exists("Prompt_Comment_Form_Handling") && !$wpdiscuz->options->subscription["usePostmaticForCommentNotification"]);

    $wpdiscuz->helper->superSocializerFix();
    if ($commentsOpen) {
        if ($formCustomCss = $form->getCustomCSS()) {
            echo "<style type='text/css'>" . $formCustomCss . "</style>";
        }
    } else {
        do_action("comment_form_closed");
        do_action("wpdiscuz_comment_form_closed", $post, $currentUser, $commentsCount);
    }
    do_action("wpdiscuz_comment_form_before");
    ?>
    <div id="wpdcom" class="<?php echo esc_attr($wpCommClasses); ?>">
        <?php
        if ($commentsOpen) {
            do_action("comment_form_before");
            ?>
            <div class="wc_social_plugin_wrapper">
                <?php  do_action("wpdiscuz_comment_form_top", $post, $currentUser, $commentsCount); ?>
            </div>
            <div class="wpd-form-wrap">
                <div class="wpd-form-head">
                    <?php
                    if ($isShowSubscribeBar && $isPostmaticActive) {
                        ?>
                        <div class="wpd-sbs-toggle">
                            <i class="far fa-envelope"></i> <span class="wpd-sbs-title"><?php esc_html_e($wpdiscuz->options->getPhrase("wc_subscribe_anchor")); ?></span> <i class="fas fa-caret-down"></i>
                        </div>
                        <?php
                    }
                    ?>
                    <div class="wpd-auth">
                        <?php do_action("comment_main_form_bar_top"); ?>
                        <div class="wpd-login">
                            <?php
                            if ($currentUser && $currentUser->ID) {
                                if ($wpdiscuz->options->login["showLoggedInUsername"]) {
                                    $user_url = get_author_posts_url($currentUser->ID);
                                    $user_url = $wpdiscuz->helper->getProfileUrl($user_url, $currentUser);
                                    $logout = wp_loginout(get_permalink(), false);
                                    $logout = preg_replace("!>([^<]+)!is", ">" . esc_html($wpdiscuz->options->getPhrase("wc_log_out")), $logout);
                                    if ($user_url) {
                                        $logout_text = esc_html($wpdiscuz->options->getPhrase("wc_logged_in_as")) . " <a href='" . esc_url_raw($user_url) . "'>" . esc_html($wpdiscuz->helper->getCurrentUserDisplayName($currentUser)) . "</a> | " . $logout;
                                    } else {
                                        $logout_text = esc_html($wpdiscuz->options->getPhrase("wc_logged_in_as")) . " " . esc_html($wpdiscuz->helper->getCurrentUserDisplayName($currentUser)) . " | " . $logout;
                                    }
                                    echo apply_filters("wpdiscuz_user_info_and_logout_link", $logout_text);
                                }
                            } else if ($wpdiscuz->options->login["showLoginLinkForGuests"]) {
                                if ($wpdiscuz->options->login["loginUrl"]) {
                                    $login = str_replace("[REDIRECT_URL]", get_permalink(), $wpdiscuz->options->login["loginUrl"]);
                                    $login = "<a href='" . esc_url_raw($login) . "'><i class='fas fa-sign-in-alt'></i> " . esc_html($wpdiscuz->options->getPhrase("wc_log_in")) . "</a>";
                                } else {
                                    $login = preg_replace("!>([^<]+)!is", "><i class='fas fa-sign-in-alt'></i> " . esc_html($wpdiscuz->options->getPhrase("wc_log_in")), wp_loginout(get_permalink(), false));
                                }
                                if ($wpdiscuz->options->isShowLoginButtons()) {
                                    echo "<div class='wpd-sep'></div>";
                                }
                                echo apply_filters("wpdiscuz_login_link", $login);
                            }
                            ?>
                        </div>
                    </div>
                </div>
                <?php do_action("comment_main_form_after_head"); ?>
                <?php
                if ($isShowSubscribeBar && $isPostmaticActive) {
                    $wpdiscuz->subscriptionData = $wpdiscuz->dbManager->hasSubscription($post->ID, $currentUser->user_email);
                    $subscriptionType = null;
                    if ($wpdiscuz->subscriptionData) {
                        $isConfirmed = $wpdiscuz->subscriptionData["confirm"];
                        $subscriptionType = $wpdiscuz->subscriptionData["type"];
                        if ($subscriptionType === WpdiscuzCore::SUBSCRIPTION_POST || $subscriptionType === WpdiscuzCore::SUBSCRIPTION_ALL_COMMENT) {
                            $unsubscribeLinkParams = $wpdiscuz->dbManager->getUnsubscribeLinkParams($post->ID, $currentUser->user_email);
                        }
                    }
                    ?>
                    <div class="wpdiscuz-subscribe-bar wpdiscuz-hidden">
                        <?php
                        if ($subscriptionType !== WpdiscuzCore::SUBSCRIPTION_POST) {
                            ?>
                            <form action="<?php echo esc_url_raw(admin_url("admin-ajax.php") . "?action=wpdAddSubscription"); ?>" method="post" id="wpdiscuz-subscribe-form">
                                <div class="wpdiscuz-subscribe-form-intro"><?php esc_html_e($wpdiscuz->options->getPhrase("wc_notify_of")); ?> </div>
                                <div class="wpdiscuz-subscribe-form-option" style="width:<?php echo!$currentUser->ID ? "40%" : "65%"; ?>;">
                                    <select class="wpdiscuz_select" name="wpdiscuzSubscriptionType" >
                                        <?php
                                        if ($wpdiscuz->options->subscription["subscriptionType"] != 3) {
                                            ?>
                                            <option value="<?php echo esc_attr(WpdiscuzCore::SUBSCRIPTION_POST); ?>"><?php esc_html_e($wpdiscuz->options->getPhrase("wc_notify_on_new_comment")); ?></option>
                                            <?php
                                        }
                                        ?>
                                        <?php
                                        if ($wpdiscuz->options->subscription["subscriptionType"] != 2) {
                                            ?>
                                            <option value="<?php echo esc_attr(WpdiscuzCore::SUBSCRIPTION_ALL_COMMENT); ?>" <?php echo isset($unsubscribeLinkParams) || !$wpdiscuz->options->wp["threadComments"] ? "disabled" : ""; ?>><?php esc_html_e($wpdiscuz->options->getPhrase("wc_notify_on_all_new_reply")); ?></option>
                                            <?php
                                        }
                                        ?>
                                    </select>
                                </div>
                                <?php
                                if (!$currentUser->ID) {
                                    ?>
                                    <div class="wpdiscuz-item wpdiscuz-subscribe-form-email">
                                        <input  class="email" type="email" name="wpdiscuzSubscriptionEmail" required="required" value="" placeholder="<?php echo esc_attr($wpdiscuz->options->getPhrase("wc_email_text")); ?>"/>
                                    </div>
                                    <?php
                                }
                                ?>
                                <div class="wpdiscuz-subscribe-form-button">
                                    <input id="wpdiscuz_subscription_button" class="wpd-prim-button wpd_not_clicked" type="submit" value="<?php echo esc_attr($wpdiscuz->options->getPhrase("wc_form_subscription_submit")); ?>" name="wpdiscuz_subscription_button" />
                                </div> 
                                <?php
                                if (!$currentUser->ID && $form->isShowSubscriptionBarAgreement()) {
                                    ?>
                                    <div class="wpdiscuz-subscribe-agreement">
                                        <input id="show_subscription_agreement" type="checkbox" required="required" name="show_subscription_agreement" value="1">
                                        <label for="show_subscription_agreement"><?php echo $form->subscriptionBarAgreementLabel(); ?></label>
                                    </div>
                                    <?php
                                }
                                wp_nonce_field("wpdiscuz_subscribe_form_nonce_action", "wpdiscuz_subscribe_form_nonce");
                                do_action("wpdiscuz_after_subscription_form");
                                $c = $form->getCaptchaFied();
                                $c->subscribtionRecaptchaHtml($wpdiscuz->options);
                                ?>
                            </form>
                            <?php
                        }
                        if (isset($unsubscribeLinkParams)) {
                            $subscribeMessage = $isConfirmed ? $wpdiscuz->options->getPhrase("wc_unsubscribe") : $wpdiscuz->options->getPhrase("wc_ignore_subscription");
                            if ($subscriptionType === "all_comment") {
                                $introText = $wpdiscuz->options->getPhrase("wc_subscribed_to") . " " . $wpdiscuz->options->getPhrase("wc_notify_on_all_new_reply");
                            } elseif ($subscriptionType === "post") {
                                $introText = $wpdiscuz->options->getPhrase("wc_subscribed_to") . " " . $wpdiscuz->options->getPhrase("wc_notify_on_new_comment");
                            }
                            echo "<div class='wpdiscuz_subscribe_status'>" . esc_html($introText) . " | <a class='wpd-unsubscribe' data-sid='" . esc_attr($unsubscribeLinkParams["id"]) . "' data-skey='" . esc_attr($unsubscribeLinkParams["activation_key"]) . "' href='#'>" . esc_html($subscribeMessage) . "</a></div>";
                        }
                        ?>
                    </div>
                    <?php
                }
                ob_start();
                $wpdiscuz->wpdiscuzForm->renderFrontForm($commentsCount, $currentUser);
                $output = ob_get_clean();
                echo apply_filters("wpdiscuz_form_render", $output, $commentsCount, $currentUser);
                if (empty($currentUser->ID) && !$form->isUserCanComment($currentUser, $post->ID)) {
                    ?>
                    <div class="wpd-login-to-comment"><?php esc_html_e($wpdiscuz->options->getPhrase("wc_login_to_comment")); ?></div>
                    <?php
                }
                ?>
            </div>
            <?php
            do_action("comment_form_after");
            do_action("wpdiscuz_comment_form_after", $post, $currentUser, $commentsCount);
        }
        do_action("wpdiscuz_before_comments", $post, $currentUser, $commentsCount);
        if ($form->isUserCanSeeComments($currentUser, $post->ID)) {
            $wooExists = class_exists("WooCommerce") && get_post_type($post->ID) === "product";
            ?>
            <div id="wpd-threads" class="wpd-thread-wrapper">
                <div class="wpd-thread-head">
                    <div class="wpd-thread-info <?php echo $wooExists ? "wpd-reviews-tab" : ""; ?>" data-comments-count="<?php echo esc_attr($commentsCount); ?>">
                        <?php
                        if (!$wooExists) {
                            echo "<span class='wpdtc' title='" . esc_attr($commentsCount) . "'>" . esc_html($wpdiscuz->helper->getNumber($commentsCount)) . "</span> " . esc_html(apply_filters("wpdiscuz_comment_count_phrase", (1 == $commentsCount ? $form->getHeaderTextSingle() : $form->getHeaderTextPlural()), $commentsCount));
                        } else {
                            echo "<svg id='Capa_1' enable-background='new 0 0 512 512' height='24' viewBox='0 0 512 512' width='24' xmlns='https://www.w3.org/2000/svg'><path d='m144.789 277.138-8.789-17.593-8.789 17.593c-2.183 4.365-6.357 7.397-11.177 8.13l-19.468 2.93 14.019 13.799c3.472 3.413 5.068 8.32 4.263 13.14l-3.223 19.409 17.461-9.067c2.168-1.128 4.541-1.685 6.914-1.685s4.746.557 6.914 1.685l17.461 9.067-3.223-19.409c-.806-4.819.791-9.727 4.263-13.14l14.019-13.799-19.468-2.93c-4.82-.733-8.994-3.765-11.177-8.13z'/><path d='m384.789 277.138-8.789-17.593-8.789 17.593c-2.183 4.365-6.357 7.397-11.177 8.13l-19.468 2.93 14.019 13.799c3.472 3.413 5.068 8.32 4.263 13.14l-3.223 19.409 17.461-9.067c2.168-1.128 4.541-1.685 6.914-1.685s4.746.557 6.914 1.685l17.461 9.067-3.223-19.409c-.806-4.819.791-9.727 4.263-13.14l14.019-13.799-19.468-2.93c-4.82-.733-8.994-3.765-11.177-8.13z'/><path d='m466 121h-125.387l3.864 23.291c2.827 16.904-4.043 33.691-17.944 43.784-14.046 10.247-32.347 11.21-47.139 3.56l-23.394-12.144-23.364 12.129c-14.788 7.63-33.115 6.727-47.227-3.589-13.843-10.049-20.713-26.836-17.886-43.77l3.864-23.261h-125.387c-24.814 0-46 20.186-46 45v240c0 24.814 21.186 45 46 45h164.18l33.105 53.954c2.739 4.38 7.544 7.046 12.715 7.046s9.976-2.666 12.715-7.046l33.105-53.954h164.18c24.814 0 46-20.186 46-45v-240c0-24.814-21.186-45-46-45zm-248.145 167.52-29.839 29.37 6.87 41.323c.938 5.61-1.377 11.25-5.977 14.59-4.492 3.281-10.576 3.851-15.732 1.187l-37.177-19.293-37.178 19.292c-5.054 2.607-11.177 2.153-15.732-1.187-4.6-3.34-6.914-8.979-5.977-14.59l6.87-41.323-29.839-29.37c-4.043-3.999-5.493-9.932-3.735-15.322 1.758-5.405 6.416-9.36 12.026-10.21l41.426-6.226 18.721-37.471c5.068-10.166 21.768-10.166 26.836 0l18.721 37.471 41.426 6.226c5.61.85 10.269 4.805 12.026 10.21 1.758 5.391.307 11.324-3.736 15.323zm240 0-29.839 29.37 6.87 41.323c.938 5.61-1.377 11.25-5.977 14.59-4.492 3.281-10.576 3.851-15.732 1.187l-37.177-19.293-37.178 19.292c-5.054 2.607-11.177 2.153-15.732-1.187-4.6-3.34-6.914-8.979-5.977-14.59l6.87-41.323-29.839-29.37c-4.043-3.999-5.493-9.932-3.735-15.322 1.758-5.405 6.416-9.36 12.026-10.21l41.426-6.226 18.721-37.471c5.068-10.166 21.768-10.166 26.836 0l18.721 37.471 41.426 6.226c5.61.85 10.269 4.805 12.026 10.21 1.758 5.391.307 11.324-3.736 15.323z'/><path d='m341.576 63.183c-1.758-5.391-6.416-9.346-12.026-10.195l-41.411-6.226-18.721-39.137c-5.098-10.166-21.738-10.166-26.836 0l-18.721 39.137-41.411 6.226c-5.61.85-10.269 4.805-12.026 10.195-1.758 5.405-.308 11.338 3.735 15.322l29.824 29.385-6.87 41.323c-.938 5.61 1.377 11.25 5.977 14.59 4.556 3.325 10.679 3.794 15.732 1.187l37.178-19.293 37.178 19.292c5.156 2.664 11.241 2.095 15.732-1.187 4.6-3.34 6.914-8.979 5.977-14.59l-6.87-41.323 29.824-29.385c4.043-3.983 5.493-9.916 3.735-15.321z'/></svg>";
                        }
                        ?>
                    </div>
                    <?php
                    if (($wpdiscuz->options->login["showActivityTab"] || $wpdiscuz->options->login["showSubscriptionsTab"] || $wpdiscuz->options->login["showFollowsTab"] || apply_filters("wpdiscuz_enable_content_modal", false)) && $currentUserEmail) {
                        echo apply_filters("wpdiscuz_user_settings_button", "<div class='wpdiscuz-user-settings wpd-info wpd-not-clicked' wpd-tooltip='" . esc_attr($wpdiscuz->options->getPhrase("wc_content_and_settings")) . "'  wpd-tooltip-position='right'><i class='fas fa-user-cog'></i></div>", $currentUser, $currentUserEmail);
                    }
                    ?>
                    <div class="wpd-space"></div>
                    <div class="wpd-thread-filter">
                        <?php
                        do_action("wpdiscuz_filtering_buttons", $currentUser, $wpdiscuz->options);
                        if (!$wpdiscuz->options->wp["isPaginate"] && $wpdiscuz->options->inline["showInlineFilterButton"] && $wpdiscuz->dbManager->postHasFeedbackForms($post->ID)) {
                            ?>
                            <div class="wpd-filter wpdf-inline wpd_not_clicked" data-filter-type="inline" wpd-tooltip="<?php echo esc_attr($wpdiscuz->options->getPhrase("wc_inline_comments")); ?>"><i class="fas fa-quote-left"></i></div>
                            <?php
                        }
                        if ($wpdiscuz->options->thread_display["showReactedFilterButton"]) {
                            ?>
                            <div class="wpd-filter wpdf-reacted wpd_not_clicked" wpd-tooltip="<?php echo esc_attr($wpdiscuz->options->getPhrase("wc_most_reacted_comment")); ?>"><i class="fas fa-bolt"></i></div>
                            <?php
                        }
                        if ($wpdiscuz->options->thread_display["showHottestFilterButton"]) {
                            ?>
                            <div class="wpd-filter wpdf-hottest wpd_not_clicked" wpd-tooltip="<?php echo esc_attr($wpdiscuz->options->getPhrase("wc_hottest_comment_thread")); ?>"><i class="fas fa-fire"></i></div>
                            <?php
                        }
                        $wpdiscuzCommentsOrder = $wpdiscuz->options->wp["commentOrder"];
                        if (!$wpdiscuz->options->wp["isPaginate"] && $wpdiscuz->options->thread_display["showSortingButtons"] && $wpdiscuz->options->thread_display["mostVotedByDefault"]) {
                            $wpdiscuzCommentsOrderBy = "by_vote";
                        } else {
                            $wpdiscuzCommentsOrderBy = $wpdiscuz->options->thread_display["orderCommentsBy"];
                        }
                        $wpdiscuzCommentsOrderBy = apply_filters("wpdiscuz_comments_order_by", $wpdiscuzCommentsOrderBy);
                        $wpdiscuzCommentsOrder = apply_filters("wpdiscuz_comments_order", $wpdiscuzCommentsOrder);
                        if ($commentsCount && $wpdiscuz->options->thread_display["showSortingButtons"] && !$wpdiscuz->options->wp["isPaginate"]) {
                            $sortingButtons = [
                                [
                                    "orderBy" => $wpdiscuz->options->thread_display["orderCommentsBy"],
                                    "order" => "desc",
                                    "class" => "wpdiscuz-date-sort-desc",
                                    "text" => $wpdiscuz->options->getPhrase("wc_newest"),
                                    "type" => "newest",
                                ],
                                [
                                    "orderBy" => $wpdiscuz->options->thread_display["orderCommentsBy"],
                                    "order" => "asc",
                                    "class" => "wpdiscuz-date-sort-asc",
                                    "text" => $wpdiscuz->options->getPhrase("wc_oldest"),
                                    "type" => "oldest",
                                ],
                            ];
                            if ($wpdiscuz->options->thread_layouts["showVotingButtons"]) {
                                $sortingButtons[] = [
                                    "orderBy" => "by_vote",
                                    "order" => $wpdiscuz->options->wp["commentOrder"],
                                    "class" => "wpdiscuz-vote-sort-up",
                                    "text" => $wpdiscuz->options->getPhrase("wc_most_voted"),
                                    "type" => "by_vote",
                                ];
                            }
                            $sortingButtons = apply_filters("wpdiscuz_sorting_buttons_array", $sortingButtons);
                            ?>
                            <div class="wpd-filter wpdf-sorting">
                                <?php
                                foreach ($sortingButtons as $key => $value) {
                                    if ($wpdiscuzCommentsOrderBy === $value["orderBy"] && $wpdiscuzCommentsOrder === $value["order"]) {
                                        ?>
                                        <span class="wpdiscuz-sort-button <?php echo esc_attr($value["class"]); ?> wpdiscuz-sort-button-active" data-sorting="<?php echo esc_attr($value["type"]); ?>"><?php esc_html_e($value["text"]); ?></span>
                                        <?php
                                        unset($sortingButtons[$key]);
                                        break;
                                    }
                                }
                                ?>
                                <i class="fas fa-sort-down"></i>
                                <div class="wpdiscuz-sort-buttons">
                                    <?php
                                    foreach ($sortingButtons as $key => $value) {
                                        ?>
                                        <span class="wpdiscuz-sort-button <?php echo esc_attr($value["class"]); ?>" data-sorting="<?php echo esc_attr($value["type"]); ?>"><?php esc_html_e($value["text"]); ?></span>
                                        <?php
                                    }
                                    ?>
                                </div>
                            </div>
                            <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="wpd-comment-info-bar">
                    <div class="wpd-current-view"><i class="fas fa-quote-left"></i> <?php esc_html_e($wpdiscuz->options->getPhrase("wc_inline_feedbacks")); ?></div>
                    <div class="wpd-filter-view-all"><?php esc_html_e($wpdiscuz->options->getPhrase("wc_inline_comments_view_all")); ?></div>
                </div>
                <?php do_action("wpdiscuz_before_thread_list", $post, $currentUser, $commentsCount); ?>
                <div class="wpd-thread-list">
                    <?php
                    if ($wpdiscuz->options->wp["isPaginate"] || !$wpdiscuz->options->thread_display["firstLoadWithAjax"]) {
                        $args = ["first_load" => 1, "orderby" => $wpdiscuzCommentsOrderBy, "order" => $wpdiscuzCommentsOrder];
                        $commentData = $wpdiscuz->getWPComments($args);
                        // $commentData["comment_list"] can not be escaped because this is returned by WP's wp_list_comments function
                        echo $commentData["comment_list"];
                    } else if ($wpdiscuz->options->thread_display["firstLoadWithAjax"] == 2 && $commentsCount) {
                        ?>
                        <div class="wpd-load-more-submit-wrap">
                            <button name="submit" class="wpd-load-comments wpd-prim-button">
                                <?php esc_html_e($wpdiscuz->options->getPhrase("wc_view_comments")); ?>
                            </button>
                        </div>
                        <?php
                    }
                    ?>
                    <div class="wpdiscuz-comment-pagination"<?php echo!$wpdiscuz->options->wp["isPaginate"] && $wpdiscuz->options->thread_display["firstLoadWithAjax"] ? " style='display:none;'" : ""; ?>>
                        <?php
                        if ($wpdiscuz->options->wp["isPaginate"]) {
                            paginate_comments_links();
                        } else if ($wpdiscuz->options->thread_display["firstLoadWithAjax"]) {
                            $loadMoreButtonText = $wpdiscuz->options->thread_display["commentListLoadType"] == 1 ? $wpdiscuz->options->getPhrase("wc_load_rest_comments_submit_text") : $wpdiscuz->options->getPhrase("wc_load_more_submit_text");
                            ?>
                            <div class="wpd-load-more-submit-wrap">
                                <button name="submit" data-lastparentid="0" class="wpd-load-more-submit wpd-loaded wpd-prim-button">
                                    <?php esc_html_e($loadMoreButtonText); ?>
                                </button>
                            </div>
                            <span id="wpdiscuzHasMoreComments" data-is_show_load_more="0"></span>
                            <?php
                        } else if ($commentData["is_show_load_more"]) {
                            $loadMoreButtonText = $wpdiscuz->options->thread_display["commentListLoadType"] == 1 ? $wpdiscuz->options->getPhrase("wc_load_rest_comments_submit_text") : $wpdiscuz->options->getPhrase("wc_load_more_submit_text");
                            ?>
                            <div class="wpd-load-more-submit-wrap">
                                <button name="submit" data-lastparentid="<?php echo esc_attr($commentData["last_parent_id"]); ?>" class="wpd-load-more-submit wpd-loaded wpd-prim-button">
                                    <?php esc_html_e($loadMoreButtonText); ?>
                                    <?php
                                    if (apply_filters("wpdiscuz_show_comments_left", false) && !empty($commentData["comments_left"])) {
                                        $commentsLeft = $commentData["comments_left"];
                                        $commentsLeftText = apply_filters(
                                                "wpdiscuz_comments_left_text",
                                                "({$commentsLeft})",
                                                ["post" => $post, "user" => $currentUser, "comments_left" => $commentsLeft]
                                        );
                                        ?>
                                        <span class="wpd-comments-left"><?php echo $commentsLeftText; ?></span>
                                        <?php
                                    }
                                    ?>
                                </button>
                            </div>
                            <span id="wpdiscuzHasMoreComments" data-is_show_load_more="<?php  echo esc_attr($commentData["is_show_load_more"]); ?>"></span>
                            <?php
                        }
                        ?>
                    </div>
                </div>
            </div>
            <?php
        }
        do_action("wpdiscuz_after_comments", $post, $currentUser, $commentsCount);
        if ($commentsCount) {
            if ($wpdiscuz->options->general["showPluginPoweredByLink"]) {
                ?>
                <div class="by-wpdiscuz">
                    <span id="awpdiscuz" onclick='document.getElementById("bywpdiscuz").style.display = "inline"; document.getElementById("awpdiscuz").style.display = "none";'>
                        <img alt="wpdiscuz" src="<?php echo esc_url_raw(plugins_url(WPDISCUZ_DIR_NAME . "/assets/img/plugin-icon/icon_info.png")); ?>" align="absmiddle" class="wpdimg"/>
                    </span>&nbsp;
                    <a href="https://wpdiscuz.com/" target="_blank" rel='noreferrer' id="bywpdiscuz" title="wpDiscuz v<?php echo esc_attr(get_option(WpdiscuzCore::OPTION_SLUG_VERSION)); ?> - Supercharged native comments">wpDiscuz</a>
                </div>
                <?php
            }
        }
        ?>
    </div>
    <?php
    $loadEndTime = WpdiscuzHelper::getMicrotime();
    if (isset($_GET["wpdLoadTime"])) {
        ?>
        <div><?php esc_html_e($loadEndTime - $loadStartTime); ?></div>
        <?php
    }
    ?>
    </div>
    <div id="wpdiscuz-loading-bar" class="<?php esc_html_e(!empty($currentUser->ID) ? "wpdiscuz-loading-bar-auth" : "wpdiscuz-loading-bar-unauth"); ?>"></div>
    <div id="wpdiscuz-comment-message" class="<?php esc_html_e(!empty($currentUser->ID) ? "wpdiscuz-comment-message-auth" : "wpdiscuz-comment-message-unauth"); ?>"></div>
    <?php
}