public function formBuilder($isMain, $uniqueId, $commentsCount, $current_user) { global $post; $isNameRequired = $this->optionsSerialized->isNameFieldRequired ? 'required="required"' : ''; $isEmailRequired = $this->optionsSerialized->isEmailFieldRequired ? 'required="required"' : ''; if (!$isMain || $commentsCount) { $textarea_placeholder = $this->optionsSerialized->phrases['wc_comment_join_text']; } else { $textarea_placeholder = $this->optionsSerialized->phrases['wc_comment_start_text']; } $commentTextMinLength = intval($this->optionsSerialized->commentTextMinLength); $commentTextMaxLength = intval($this->optionsSerialized->commentTextMaxLength); $commentTextLengthRange = $commentTextMinLength && $commentTextMaxLength ? 'data-validate-length-range="' . $commentTextMinLength . ',' . $commentTextMaxLength . '"' : ''; $textareaMaxLength = $commentTextMaxLength ? "maxlength={$commentTextMaxLength}" : ''; ?> <div class="wc-form-wrapper <?php echo !$isMain ? 'wc-secondary-form-wrapper' : 'wc-main-form-wrapper'; ?> " <?php echo !$isMain ? "id='wc-secondary-form-wrapper-{$uniqueId}' style='display: none;'" : "id='wc-main-form-wrapper-{$uniqueId}'"; ?> > <div class="wpdiscuz-comment-message" style="display: block;"></div> <?php if (!$isMain) { ?> <div class="wc-secondary-forms-social-content"></div> <?php } ?> <?php if ($this->isGuestCanComment($current_user->ID)) { ?> <form class="wc_comm_form <?php echo !$isMain ? 'wc-secondary-form-wrapper' : 'wc_main_comm_form'; ?> " method="post" action="" enctype="multipart/form-data"> <div class="wc-field-comment"> <?php if ($this->optionsSerialized->wordpressShowAvatars) { ?> <?php $authorName = $current_user->ID ? $current_user->display_name : 'avatar'; ?> <div class="wc-field-avatararea"> <?php echo get_avatar($current_user->ID, 48, '', $authorName); ?> </div> <?php } ?> <div class="wpdiscuz-item wc-field-textarea" <?php if (!$this->optionsSerialized->wordpressShowAvatars) { echo ' style="margin-left: 0;"'; } ?> > <div class="wpdiscuz-textarea-wrap <?php if ($this->optionsSerialized->isQuickTagsEnabled) { echo 'wpdiscuz-quicktags-enabled'; } ?> "> <textarea id="wc-textarea-<?php echo $uniqueId; ?> " <?php echo $commentTextLengthRange . ' ' . $textareaMaxLength; ?> placeholder="<?php echo $textarea_placeholder; ?> " required name="wc_comment" class="wc_comment wc_field_input"></textarea> <?php if (intval($this->optionsSerialized->commentTextMaxLength)) { ?> <div class="commentTextMaxLength"><?php echo $this->optionsSerialized->commentTextMaxLength; ?> </div> <?php } ?> <?php if (defined('WPDISCUZ_BOTTOM_TOOLBAR')) { ?> <div class="wpdiscuz-textarea-foot"> <?php do_action('wpdiscuz_button', $uniqueId, $current_user); ?> <div class="wpdiscuz-button-actions"><?php do_action('wpdiscuz_button_actions', $uniqueId, $current_user); ?> </div> </div> <?php } ?> </div> </div> <div class="clearfix"></div> </div> <div class="wc-form-footer" style="display: none;"> <?php if (!$current_user->ID) { ?> <?php $nameLengthRange = intval($this->optionsSerialized->commenterNameMinLength) >= 3 && (intval($this->optionsSerialized->commenterNameMaxLength) >= 3 && intval($this->optionsSerialized->commenterNameMaxLength) <= 50) ? 'data-validate-length-range="' . $this->optionsSerialized->commenterNameMinLength . ',' . $this->optionsSerialized->commenterNameMaxLength . '"' : ''; ?> <div class="wc-author-data"> <div class="wc-field-name wpdiscuz-item"> <input type="text" <?php echo $nameLengthRange; ?> maxlength="<?php echo $this->optionsSerialized->commenterNameMaxLength; ?> " placeholder="<?php echo $this->optionsSerialized->phrases['wc_name_text']; ?> " value="" <?php echo $isNameRequired; ?> name="wc_name" class="wc_name wc_field_input" /> </div> <div class="wc-field-email wpdiscuz-item"> <input type="email" placeholder="<?php echo $this->optionsSerialized->phrases['wc_email_text']; ?> " value="" <?php echo $isEmailRequired; ?> name="wc_email" class="wc_email wc_field_input email" /> </div> <?php if (!$current_user->ID && $this->optionsSerialized->weburlShowHide) { ?> <div class="wc-field-website wpdiscuz-item"> <input type="url" placeholder="<?php echo $this->optionsSerialized->phrases['wc_website_text']; ?> " value="" name="wc_website" class="wc_website wc_field_input"> </div> <?php } ?> <div class="clearfix"></div> </div> <?php } ?> <div class="wc-form-submit"> <?php if ($this->optionsSerialized->isGoodbyeCaptchaActive) { echo GdbcWordPressPublicModule::getInstance()->getTokenFieldHtml(); } else { if ($this->isShowCaptcha($current_user->ID)) { if (class_exists("wpDiscuzReCaptcha")) { global $wpDiscuzReCaptcha; $wpDiscuzReCaptcha->recaptchaHtml($uniqueId); } else { $this->generateCaptchaHtml(); } } } ?> <div class="wc-field-submit"> <?php if ($this->optionsSerialized->wordpressThreadComments || class_exists('Prompt_Comment_Form_Handling')) { ?> <?php $isShowSubscribeWrapper = false; if ($this->optionsSerialized->showHideReplyCheckbox) { if ($current_user->ID) { $subscriptionData = $this->dbManager->hasSubscription($post->ID, $current_user->user_email); $isShowSubscribeWrapper = !$subscriptionData || $subscriptionData && $subscriptionData['type'] == WpDiscuzConstants::SUBSCRIPTION_COMMENT ? true : false; } else { $isShowSubscribeWrapper = true; } } if ($isShowSubscribeWrapper) { $isReplyDefaultChecked = $this->optionsSerialized->isReplyDefaultChecked ? 'checked="checked"' : ''; ?> <div class="wc_notification_checkboxes" style="display:block"> <?php if (class_exists('Prompt_Comment_Form_Handling') && $this->optionsSerialized->usePostmaticForCommentNotification) { ?> <input id="wc_notification_new_comment-<?php echo $uniqueId; ?> " class="wc_notification_new_comment-<?php echo $uniqueId; ?> " value="post" type="checkbox" name="wpdiscuz_notification_type"/> <label class="wc-label-comment-notify" for="wc_notification_new_comment-<?php echo $uniqueId; ?> "><?php echo $this->optionsSerialized->phrases['wc_postmatic_subscription_label']; ?> </label><br /> <?php } else { ?> <input id="wc_notification_new_comment-<?php echo $uniqueId; ?> " class="wc_notification_new_comment-<?php echo $uniqueId; ?> " value="comment" type="checkbox" name="wpdiscuz_notification_type" <?php echo $isReplyDefaultChecked; ?> /> <label class="wc-label-comment-notify" for="wc_notification_new_comment-<?php echo $uniqueId; ?> "><?php echo $this->optionsSerialized->phrases['wc_notify_on_new_reply']; ?> </label><br /> <?php } ?> </div> <?php } ?> <?php } ?> <input type="button" class="wc_comm_submit button alt" value="<?php echo $this->optionsSerialized->phrases['wc_submit_text']; ?> " name="submit"> </div> <div class="clearfix"></div> </div> <div class="clearfix"></div> </div> <div class="clearfix"></div> <input type="hidden" class="wpdiscuz_unique_id" value="<?php echo $uniqueId; ?> " name="wpdiscuz_unique_id"> </form> <?php } else { ?> <p class="wc-must-login"> <?php echo $this->optionsSerialized->phrases['wc_you_must_be_text']; $login = wp_loginout(get_permalink(), false); $login = preg_replace('!>([^<]+)!is', '>' . $this->optionsSerialized->phrases['wc_logged_in_text'], $login); echo ' ' . $login . ' ' . $this->optionsSerialized->phrases['wc_to_post_comment_text']; ?> </p> <?php } ?> </div> <?php }
function __construct($dbmanager) { $this->dbManager = $dbmanager; $this->initPhrases(); $this->addOptions(); $this->initOptions(get_option(WpdiscuzCore::OPTION_SLUG_OPTIONS)); $this->wordpressCommentRegistration = get_option('comment_registration'); $this->wordpressDateFormat = get_option('date_format'); $this->wordpressTimeFormat = get_option('time_format'); $this->wordpressThreadComments = get_option('thread_comments'); $this->wordpressThreadCommentsDepth = get_option('thread_comments_depth'); $this->wordpressIsPaginate = get_option('page_comments'); $this->wordpressCommentOrder = get_option('comment_order'); $this->wordpressCommentPerPage = get_option('comments_per_page'); $this->wordpressShowAvatars = get_option('show_avatars'); $this->wordpressDefaultCommentsPage = get_option('default_comments_page'); $this->isGoodbyeCaptchaActive = is_callable(array('GdbcWordPressPublicModule', 'isCommentsProtectionActivated')) && GdbcWordPressPublicModule::isCommentsProtectionActivated(); add_action('init', array(&$this, 'initPhrasesOnLoad'), 2126); }