Comments – wpDiscuz - Version 4.1.0

Version Description

  • Speed: v4.1 comes with new acelerated engine, it's twice faster than older versions
  • Added: Lazy load improvement, loads comments once scroll position is on comment box
  • Added: With wpDiscuz v4.1 guest are also allowed to edit own comments
  • Added: Highlights new comments since user last visit.
  • Fixed Bug: Issues with live update function
  • Fixed Bug: Style issue on RTL pages if avatars are disabled
  • Fixed Bug: Lazy load doesn't work if scrollbar at the bottom of page after page loading

IMPORTANT:

  • If you have JetPack installed please deactivate Jetpack comments, it affects wpDiscuz
  • If you have a Cache Plugin, please delete all caches after wpDiscuz update.
  • If you use CDN and found some issue please purge it.
  • If your server PHP version is lower than 5.4, please change it to hogher
Download this release

Release Info

Developer AdvancedCoding
Plugin Icon 128x128 Comments – wpDiscuz
Version 4.1.0
Comparing to
See all releases

Code changes from version 4.0.15 to 4.1.0

assets/addons/online-users/header-off.png ADDED
Binary file
assets/addons/online-users/header.png ADDED
Binary file
assets/css/wpdiscuz-custom-form.css CHANGED
@@ -45,7 +45,7 @@
45
  #TB_ajaxContent .wpd-info{font-size:13px; color:#999999; font-style:italic; line-height:18px; width:90%; padding: 3px 0 1px; margin:0px;}
46
  #TB_ajaxContent .add-to-form-button-cont{text-align:right;}
47
  #TB_ajaxContent .wpdiscuz-tb-title{ font-size:20px; font-weight:400; color:#555; text-align:right; padding-bottom:10px; border-bottom:1px solid #eaeaea;}
48
- #TB_ajaxContent .wpd-field-button.button, #TB_ajaxContent .wpd-field-button.button{ margin:2px 1px 5px 1px;}
49
 
50
  .wpdiscuz-wrapper .wpd-form-row-wrap{box-sizing: border-box; min-height: 60px; margin-top:35px; position:relative; border:4px dashed #dedede;}
51
  .wpdiscuz-wrapper .wpd-form-row-wrap .wpd-form-row-actions{background: #dedede;}
45
  #TB_ajaxContent .wpd-info{font-size:13px; color:#999999; font-style:italic; line-height:18px; width:90%; padding: 3px 0 1px; margin:0px;}
46
  #TB_ajaxContent .add-to-form-button-cont{text-align:right;}
47
  #TB_ajaxContent .wpdiscuz-tb-title{ font-size:20px; font-weight:400; color:#555; text-align:right; padding-bottom:10px; border-bottom:1px solid #eaeaea;}
48
+ #TB_ajaxContent .wpd-field-button.button, #TB_ajaxContent .wpd-field-button.button{ margin:2px 1px 5px 1px; min-width: 32%;}
49
 
50
  .wpdiscuz-wrapper .wpd-form-row-wrap{box-sizing: border-box; min-height: 60px; margin-top:35px; position:relative; border:4px dashed #dedede;}
51
  .wpdiscuz-wrapper .wpd-form-row-wrap .wpd-form-row-actions{background: #dedede;}
assets/css/wpdiscuz-ratings-rtl.css ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ #wpcomm .wpd-top-custom-fields .wpd-custom-field.wpd-cf-rating .wpd-cf-label{ background:transparent; border:none; padding: 2px 2px 2px 10px; }
2
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating {float: right; padding:5px 1px 5px 0px; margin-right:-5px;}
3
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > label { float: left; }
4
+ #wpcomm .wpd-form-col-full .wpdiscuz-item.wpd-field-rating.wpd-has-desc .wpd-field-desc{ left:0px;margin-right:5px;}
5
+ #wpcomm .wpd-form-col-full .wpd-field-group .wpd-field-group-title{ padding:0px 0px 2px 0px;}
6
+ #wpcomm .wpd-form-col-full .wpdiscuz-item .wpdiscuz-rating{ padding:0px 0px 0px 6px; }
7
+ #wpcomm .wpd-form-col-full .wpd-item-wrap{ float:right; padding-left:7px; padding:0px 1px 1px 1px;}
8
+ .wpdiscuz-stars-label{padding:10px 3px 2px 0px;}
9
+ .wpdiscuz-activ-stars{ right:0;}
assets/css/wpdiscuz-ratings.css ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #wpcomm .wpd-top-custom-fields .wpd-custom-field.wpd-cf-rating .wpd-cf-label{ background:transparent; border:none; padding: 2px 10px 2px 2px; }
2
+ #wpcomm .wpd-top-custom-fields .wpd-custom-field.wpd-cf-rating .wpd-cf-value{font-size: 16px; border-bottom:none; padding: 1px 10px; }
3
+
4
+ #wpcomm .wpdiscuz-item.wpd-field-group.wpd-field-rating{ border-bottom:1px dotted #ddd; height:77px; margin-bottom:0px;}
5
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating {border: none; float: left; margin:0px; padding:5px 0px 5px 1px; margin-left:-5px;}
6
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input { visibility:hidden; position:absolute;}
7
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > label:before { margin: 3px; line-height: 18px; font-size: 1.4em; cursor:pointer;}
8
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > .half:before {position: absolute; cursor:pointer;}
9
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > label { float: right; }
10
+ #wpcomm .wpd-form-col-full .wpdiscuz-item.wpd-field-rating.wpd-has-desc .wpd-field-desc{ right:0px; top:0px; position:relative; font-size:14px; margin-left:5px; padding: 0 7px;}
11
+ #wpcomm .wpd-form-col-full .wpdiscuz-item.wpd-field-rating.wpd-has-desc .wpd-field-desc i.fa{ font-size:17px;}
12
+ #wpcomm .wpd-form-col-full .wpd-field-group .wpd-field-group-title{ display:inline-block; vertical-align:baseline; padding:0px 0px 2px 0px; margin-top:-2px;}
13
+ #wpcomm .wpd-form-col-full .wpdiscuz-item .wpdiscuz-rating{ padding:0px 6px 0px 0px; vertical-align:middle; line-height: 14px;}
14
+ #wpcomm .wpd-form-col-full .wpd-item-wrap{ display:inline-block; float:left; padding-right:7px; vertical-align:baseline; padding:0px 1px 1px 1px;}
15
+ .wpdiscuz-stars-label{ line-height:20px; padding:10px 0px 2px 3px; font-size:14px;}
16
+ .wpdiscuz-stars-wrapper{ display:block;}
17
+ .wpdiscuz-stars-wrapper-inner{ position: absolute;}
18
+ .wpdiscuz-activ-stars{ position: absolute; display: flex; font-size: 22px; top: 0; left:0;}
19
+ .wpdiscuz-pasiv-stars{ font-size: 22px; display: flex;}
20
+ .wpdiscuz-activ-stars{ overflow:hidden;}
21
+ .wpdiscuz-pasiv-stars i.fa, .wpdiscuz-activ-stars i.fa{ padding:0px 2px; font-size:20px;}
22
+ .wpdiscuz-post-rating-wrap.wpd-custom-field{display: flex;flex-wrap: wrap;}
23
+ .wpdiscuz-post-rating-wrap.wpd-custom-field > [class ^= wpdiscuz-post-rating-wrap-custom_field]{flex-basis: 25%;margin-bottom: 10px;}
24
+ @media screen and (max-width: 1024px){
25
+ .wpdiscuz-post-rating-wrap.wpd-custom-field > [class ^= wpdiscuz-post-rating-wrap-custom_field]{flex-basis: 33%;margin-bottom: 10px;}
26
+ }
27
+ @media screen and (max-width:650px){
28
+ .wpdiscuz-post-rating-wrap.wpd-custom-field > [class ^= wpdiscuz-post-rating-wrap-custom_field]{
29
+ flex-basis: 50%;
30
+ margin-bottom: 10px;
31
+ }
32
+ }
33
+ @media screen and (max-width:420px){
34
+ .wpdiscuz-post-rating-wrap.wpd-custom-field > [class ^= wpdiscuz-post-rating-wrap-custom_field]{
35
+ flex-basis: 100%;
36
+ margin-bottom: 10px;
37
+ }
38
+ }
39
+
40
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > label {color: #DDDDDD;}
41
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input ~ label:hover,
42
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input:not(:checked) ~ label:hover ~ label,
43
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input:not(:checked) ~ label:hover ~ label{color: #FFED85;}
44
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input:checked ~ label:hover,
45
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input:checked ~ label:hover,
46
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > label:hover ~ input:checked ~ label,
47
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input:checked + label:hover ~ label,
48
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input:checked ~ label:hover ~ label,
49
+ .wpd-custom-field .wcf-activ-star,
50
+ #wpcomm .wpdiscuz-item .wpdiscuz-rating > input:checked ~ label{ color:#FFD700;}
51
+ .wpd-custom-field .wcf-pasiv-star, #wpcomm .wpdiscuz-item .wpdiscuz-rating > label {color: #DDDDDD;}
assets/css/wpdiscuz-rtl.css CHANGED
@@ -58,7 +58,6 @@
58
  #wpcomm .wpdiscuz-subscribe-form-button{float:right;}
59
  #wpcomm .wpdiscuz-subscribe-form-button input[type="submit"]{padding:1px 3px 5px 3px!important;}
60
  #wpcomm .wc-comment-link{float:left;text-align:left;padding:0 10px 0 0;}
61
- .tooltipster-content input[type="text"].wc-comment-link-input{padding:2px;width:100%;font-size:13px;color:#777}
62
  #wpcomm .wc-form-footer{margin-right:65px}
63
  #wpcomm.wpdiscuz_no_avatar .wc-form-footer{margin-right:0}
64
  #wpcomm .wc-field-submit{padding:5px 5px 0 0;clear:right}
@@ -99,9 +98,8 @@
99
  /* SELECT */
100
  #wpcomm .wpd-form-row .wpd-form-col-right .wpdiscuz-item.wpd-field-select{ text-align:right;}
101
  #wpcomm .wpdiscuz-item.wpd-field-select {padding: 7px 0 3px;}
102
- #wpcomm .wpd-top-custom-fields .wpd-custom-field.wpd-cf-rating .wpd-cf-label{ background:transparent; border:none; padding: 2px 2px 2px 10px; }
103
-
104
  /* RATING */
 
105
  #wpcomm .wpdiscuz-item .wpdiscuz-rating {float: right; padding:5px 1px 5px 0px; margin-right:-5px;}
106
  #wpcomm .wpdiscuz-item .wpdiscuz-rating > label { float: left; }
107
  #wpcomm .wpd-form-col-full .wpdiscuz-item.wpd-field-rating.wpd-has-desc .wpd-field-desc{ left:0px;margin-right:5px;}
58
  #wpcomm .wpdiscuz-subscribe-form-button{float:right;}
59
  #wpcomm .wpdiscuz-subscribe-form-button input[type="submit"]{padding:1px 3px 5px 3px!important;}
60
  #wpcomm .wc-comment-link{float:left;text-align:left;padding:0 10px 0 0;}
 
61
  #wpcomm .wc-form-footer{margin-right:65px}
62
  #wpcomm.wpdiscuz_no_avatar .wc-form-footer{margin-right:0}
63
  #wpcomm .wc-field-submit{padding:5px 5px 0 0;clear:right}
98
  /* SELECT */
99
  #wpcomm .wpd-form-row .wpd-form-col-right .wpdiscuz-item.wpd-field-select{ text-align:right;}
100
  #wpcomm .wpdiscuz-item.wpd-field-select {padding: 7px 0 3px;}
 
 
101
  /* RATING */
102
+ #wpcomm .wpd-top-custom-fields .wpd-custom-field.wpd-cf-rating .wpd-cf-label{ background:transparent; border:none; padding: 2px 2px 2px 10px; }
103
  #wpcomm .wpdiscuz-item .wpdiscuz-rating {float: right; padding:5px 1px 5px 0px; margin-right:-5px;}
104
  #wpcomm .wpdiscuz-item .wpdiscuz-rating > label { float: left; }
105
  #wpcomm .wpd-form-col-full .wpdiscuz-item.wpd-field-rating.wpd-has-desc .wpd-field-desc{ left:0px;margin-right:5px;}
assets/css/wpdiscuz.css CHANGED
@@ -136,7 +136,6 @@
136
 
137
  #wpcomm .wpdiscuz_subscribe_status{font-size:12px;padding-top:6px}
138
  #wpcomm .wpdiscuz_subscribe_status a{font-size:12px}
139
- .tooltipster-content input[type="text"].wc-comment-link-input{padding:2px;width:100%;font-size:13px;color:#777}
140
  #wpcomm .page-numbers{padding:2px 7px;font-size:14px;margin:20px 1px;line-height:33px;background:#fff}
141
  #wpcomm span.current{color:#fff}
142
  #wpcomm .wc-form-footer{display:none;margin-left:65px}
136
 
137
  #wpcomm .wpdiscuz_subscribe_status{font-size:12px;padding-top:6px}
138
  #wpcomm .wpdiscuz_subscribe_status a{font-size:12px}
 
139
  #wpcomm .page-numbers{padding:2px 7px;font-size:14px;margin:20px 1px;line-height:33px;background:#fff}
140
  #wpcomm span.current{color:#fff}
141
  #wpcomm .wc-form-footer{display:none;margin-left:65px}
assets/js/wpdiscuz.js CHANGED
@@ -17,7 +17,7 @@ jQuery(document).ready(function ($) {
17
  var wpdiscuzCommentOrder = wpdiscuzAjaxObj.wpdiscuz_options.wordpress_comment_order;
18
  var commentsVoteOrder = wpdiscuzAjaxObj.wpdiscuz_options.commentsVoteOrder;
19
  var storeCommenterData = wpdiscuzAjaxObj.wpdiscuz_options.storeCommenterData;
20
- var wpdiscuzLoadCount = 1;
21
  var wpdiscuzCommentOrderBy = 'comment_date_gmt';
22
  var wpdiscuzReplyArray = [];
23
  var wpdiscuzCommentArray = [];
@@ -25,11 +25,17 @@ jQuery(document).ready(function ($) {
25
  var commentTextMaxLength = wpdiscuzAjaxObj.wpdiscuz_options.commentTextMaxLength;
26
  var wpdGoogleRecaptchaValid = true;
27
  var wpdiscuzReplyButton = '';
28
- var wpdiscuzCookiehash = wpdiscuzAjaxObj.wpdiscuz_options.cookiehash;;
29
-
30
  loginButtonsClone();
31
  displayShowHideReplies();
32
 
 
 
 
 
 
 
 
33
  if (commentsVoteOrder) {
34
  $('.wpdiscuz-vote-sort-up').addClass('wpdiscuz-sort-button-active');
35
  wpdiscuzCommentOrderBy = 'by_vote';
@@ -542,17 +548,26 @@ jQuery(document).ready(function ($) {
542
  }
543
  });
544
 
545
- var wpdiscuzHasMoreComments = $('#wpdiscuzHasMoreComments').val();
546
  var isRun = false;
547
  if (commentListLoadType == 2 && !wordpressIsPaginate) {
548
  $('.wc-load-more-submit').parents('.wpdiscuz-comment-pagination').hide();
 
549
  $(window).scroll(function () {
550
- var scrollHeight = document.getElementById('wcThreadWrapper').scrollHeight;
551
- if ($(window).scrollTop() >= scrollHeight && isRun === false && wpdiscuzHasMoreComments == 1) {
 
 
 
 
 
 
 
 
 
552
  isRun = true;
553
  wpdiscuzLoadComments($('.wc-load-more-submit'));
554
  }
555
- });
556
  }
557
 
558
  function wpdiscuzLoadComments(loadButton, loaded, loading) {
@@ -564,6 +579,7 @@ jQuery(document).ready(function ($) {
564
  data.append('orderBy', wpdiscuzCommentOrderBy);
565
  data.append('order', wpdiscuzCommentOrder);
566
  data.append('lastParentId', getLastParentID());
 
567
  wpdiscuzLoadCount++;
568
  getAjaxObj(data).done(function (response) {
569
  try {
@@ -572,6 +588,7 @@ jQuery(document).ready(function ($) {
572
  setLoadMoreVisibility(obj);
573
  $('.wpdiscuz_single').remove();
574
  isRun = false;
 
575
  displayShowHideReplies();
576
  } catch (e) {
577
  console.log(e);
@@ -584,17 +601,14 @@ jQuery(document).ready(function ($) {
584
  }
585
 
586
  function setLoadMoreVisibility(obj) {
587
- var hasMoreComments = 0;
588
  if (obj.is_show_load_more == false) {
589
- hasMoreComments = 0;
590
- wpdiscuzHasMoreComments = 0;
591
  $('.wc-load-more-submit').parents('.wpdiscuz-comment-pagination').hide();
592
  } else {
593
  setLastParentID(obj.last_parent_id);
594
- wpdiscuzHasMoreComments = 1;
595
- hasMoreComments = 1;
596
  }
597
- $('#wpdiscuzHasMoreComments').val(hasMoreComments);
598
  if (obj.callbackFunctions != null && obj.callbackFunctions != 'undefined' && obj.callbackFunctions.length) {
599
  $.each(obj.callbackFunctions, function (i) {
600
  if (typeof wpdiscuzAjaxObj[obj.callbackFunctions[i]] === "function") {
@@ -665,7 +679,6 @@ jQuery(document).ready(function ($) {
665
  //============================== VOTE ============================== //
666
  //============================== SORTING ============================== //
667
  $(document).delegate('.wpdiscuz-sort-button', 'click', function () {
668
- wpdiscuzHasMoreComments = $('#wpdiscuzHasMoreComments').val();
669
  if (!($(this).hasClass('wpdiscuz-sort-button-active'))) {
670
  var clickedBtn = $(this);
671
  if ($(this).hasClass('wpdiscuz-vote-sort-up')) {
@@ -743,7 +756,7 @@ jQuery(document).ready(function ($) {
743
  getSingleComment();
744
  //============================== SINGLE COMMENT ============================== //
745
  //============================== LIVE UPDATE ============================== //
746
- if (commentListUpdateType > 0 && loadLastCommentId && (isUserLoggedIn || (!isUserLoggedIn && !disableGuestsLiveUpdate))) {
747
  setInterval(liveUpdate, parseInt(commentListUpdateTimer) * 1000);
748
  }
749
 
17
  var wpdiscuzCommentOrder = wpdiscuzAjaxObj.wpdiscuz_options.wordpress_comment_order;
18
  var commentsVoteOrder = wpdiscuzAjaxObj.wpdiscuz_options.commentsVoteOrder;
19
  var storeCommenterData = wpdiscuzAjaxObj.wpdiscuz_options.storeCommenterData;
20
+ var wpdiscuzLoadCount = commentListLoadType == 2 ? 0 : 1;
21
  var wpdiscuzCommentOrderBy = 'comment_date_gmt';
22
  var wpdiscuzReplyArray = [];
23
  var wpdiscuzCommentArray = [];
25
  var commentTextMaxLength = wpdiscuzAjaxObj.wpdiscuz_options.commentTextMaxLength;
26
  var wpdGoogleRecaptchaValid = true;
27
  var wpdiscuzReplyButton = '';
28
+ var wpdiscuzCookiehash = wpdiscuzAjaxObj.wpdiscuz_options.cookiehash;
 
29
  loginButtonsClone();
30
  displayShowHideReplies();
31
 
32
+ if (!wpdiscuzAjaxObj.wpdiscuz_options.wordpressIsPaginate) {
33
+ var wpdiscuzLastVisitKey = wpdiscuzAjaxObj.wpdiscuz_options.lastVisitKey;
34
+ var wpdiscuzLastVisit = wpdiscuzAjaxObj.wpdiscuz_options.lastVisitCookie;
35
+ var wpdiscuzLastVisitExpires = wpdiscuzAjaxObj.wpdiscuz_options.lastVisitExpires;
36
+ Cookies.set(wpdiscuzLastVisitKey, (JSON.stringify(wpdiscuzLastVisit)), {expires: wpdiscuzLastVisitExpires, path: window.location});
37
+ }
38
+
39
  if (commentsVoteOrder) {
40
  $('.wpdiscuz-vote-sort-up').addClass('wpdiscuz-sort-button-active');
41
  wpdiscuzCommentOrderBy = 'by_vote';
548
  }
549
  });
550
 
 
551
  var isRun = false;
552
  if (commentListLoadType == 2 && !wordpressIsPaginate) {
553
  $('.wc-load-more-submit').parents('.wpdiscuz-comment-pagination').hide();
554
+ wpdiscuzScrollEvents();
555
  $(window).scroll(function () {
556
+ wpdiscuzScrollEvents();
557
+ });
558
+ }
559
+
560
+ function wpdiscuzScrollEvents() {
561
+ var wpdiscuzHasMoreComments = $('#wpdiscuzHasMoreComments').val();
562
+ var scrollHeight = $(document).height();
563
+ var scrollPosition = $(window).height() + $(window).scrollTop();
564
+ if (scrollHeight && scrollPosition) {
565
+ var scrollPercent = scrollPosition * 100 / scrollHeight;
566
+ if (scrollPercent >= 80 && isRun === false && wpdiscuzHasMoreComments == 1) {
567
  isRun = true;
568
  wpdiscuzLoadComments($('.wc-load-more-submit'));
569
  }
570
+ }
571
  }
572
 
573
  function wpdiscuzLoadComments(loadButton, loaded, loading) {
579
  data.append('orderBy', wpdiscuzCommentOrderBy);
580
  data.append('order', wpdiscuzCommentOrder);
581
  data.append('lastParentId', getLastParentID());
582
+ data.append(wpdiscuzLastVisitKey, Cookies.get(wpdiscuzLastVisitKey));
583
  wpdiscuzLoadCount++;
584
  getAjaxObj(data).done(function (response) {
585
  try {
588
  setLoadMoreVisibility(obj);
589
  $('.wpdiscuz_single').remove();
590
  isRun = false;
591
+ loadLastCommentId = obj.loadLastCommentId;
592
  displayShowHideReplies();
593
  } catch (e) {
594
  console.log(e);
601
  }
602
 
603
  function setLoadMoreVisibility(obj) {
 
604
  if (obj.is_show_load_more == false) {
605
+ $('#wpdiscuzHasMoreComments').val(0);
 
606
  $('.wc-load-more-submit').parents('.wpdiscuz-comment-pagination').hide();
607
  } else {
608
  setLastParentID(obj.last_parent_id);
609
+ $('#wpdiscuzHasMoreComments').val(1);
 
610
  }
611
+
612
  if (obj.callbackFunctions != null && obj.callbackFunctions != 'undefined' && obj.callbackFunctions.length) {
613
  $.each(obj.callbackFunctions, function (i) {
614
  if (typeof wpdiscuzAjaxObj[obj.callbackFunctions[i]] === "function") {
679
  //============================== VOTE ============================== //
680
  //============================== SORTING ============================== //
681
  $(document).delegate('.wpdiscuz-sort-button', 'click', function () {
 
682
  if (!($(this).hasClass('wpdiscuz-sort-button-active'))) {
683
  var clickedBtn = $(this);
684
  if ($(this).hasClass('wpdiscuz-vote-sort-up')) {
756
  getSingleComment();
757
  //============================== SINGLE COMMENT ============================== //
758
  //============================== LIVE UPDATE ============================== //
759
+ if (commentListUpdateType && loadLastCommentId && (isUserLoggedIn || (!isUserLoggedIn && !disableGuestsLiveUpdate))) {
760
  setInterval(liveUpdate, parseInt(commentListUpdateTimer) * 1000);
761
  }
762
 
class.WpdiscuzCore.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  * Plugin Name: wpDiscuz
5
  * Description: Better comment system. Wordpress post comments and discussion plugin. Allows your visitors discuss, vote for comments and share.
6
- * Version: 4.0.15
7
  * Author: gVectors Team (A. Chakhoyan, G. Zakaryan, H. Martirosyan)
8
  * Author URI: https://gvectors.com/
9
  * Plugin URI: http://wpdiscuz.com/
@@ -43,6 +43,9 @@ class WpdiscuzCore implements WpDiscuzConstants {
43
  public $commentsArgs;
44
  private $version;
45
  public $wpdiscuzForm;
 
 
 
46
 
47
  public function __construct() {
48
  $this->version = get_option(self::OPTION_SLUG_VERSION, '1.0.0');
@@ -55,12 +58,14 @@ class WpdiscuzCore implements WpDiscuzConstants {
55
  $this->optimizationHelper = new WpdiscuzOptimizationHelper($this->optionsSerialized, $this->dbManager, $this->emailHelper, $this->wpdiscuzForm);
56
  $this->css = new WpdiscuzCss($this->optionsSerialized, $this->helper);
57
  $this->wpdiscuzWalker = new WpdiscuzWalker($this->helper, $this->optimizationHelper, $this->dbManager, $this->optionsSerialized);
 
58
  register_activation_hook(__FILE__, array(&$this, 'pluginActivation'));
59
  register_deactivation_hook(__FILE__, array(&$this->wpdiscuzForm, 'removeAllFiles'));
60
  add_action('wpmu_new_blog', array(&$this, 'addNewBlog'));
61
  add_action('delete_blog', array(&$this, 'deleteBlog'));
62
  add_action('wp_head', array(&$this, 'initCurrentPostType'));
63
  add_action('wp_head', array(&$this->css, 'initCustomCss'));
 
64
 
65
  add_action('init', array(&$this, 'wpdiscuzTextDomain'));
66
  add_action('admin_init', array(&$this, 'pluginNewVersion'), 1);
@@ -119,6 +124,7 @@ class WpdiscuzCore implements WpDiscuzConstants {
119
  add_action('wp_loaded', array(&$this, 'addNewRoles'));
120
  add_filter('comments_template_query_args', array(&$this, 'commentsTemplateQueryArgs'));
121
  add_action('pre_get_comments', array(&$this, 'preGetComments'));
 
122
  }
123
 
124
  public function pluginActivation($networkwide) {
@@ -169,7 +175,7 @@ class WpdiscuzCore implements WpDiscuzConstants {
169
  }
170
 
171
  public function updateAutomatically() {
172
- $current_user = wp_get_current_user();
173
  $messageArray = array('code' => 0);
174
  $postId = isset($_POST['postId']) ? intval($_POST['postId']) : 0;
175
  $loadLastCommentId = isset($_POST['loadLastCommentId']) ? intval($_POST['loadLastCommentId']) : 0;
@@ -190,14 +196,16 @@ class WpdiscuzCore implements WpDiscuzConstants {
190
  if ($this->optionsSerialized->commentListUpdateType == 1) {
191
  $messageArray['message'] = array();
192
  foreach ($newCommentIds as $newCommentId) {
193
- $comment = get_comment($newCommentId);
194
- if (($comment->comment_parent && (in_array($comment->comment_parent, $visibleCommentIds) || in_array($comment->comment_parent, $newCommentIds))) || !$comment->comment_parent) {
195
- $commentHtml = wp_list_comments($commentListArgs, array($comment));
196
- $commentObject = array('comment_parent' => $comment->comment_parent, 'comment_html' => $commentHtml);
197
- if ($comment->comment_parent) {
198
- array_push($messageArray['message'], $commentObject);
199
- } else {
200
- array_unshift($messageArray['message'], $commentObject);
 
 
201
  }
202
  }
203
  }
@@ -211,14 +219,16 @@ class WpdiscuzCore implements WpDiscuzConstants {
211
  $messageArray['message']['author_replies'] = array();
212
  $messageArray['message']['comments'] = array();
213
  foreach ($newCommentIds as $newCommentId) {
214
- $comment = get_comment($newCommentId);
215
- if ($this->optimizationHelper->isReplyInAuthorTree($comment->comment_ID, $authorComments)) { // if is in author tree add as reply
216
- $messageArray['message']['author_replies'][] = $newCommentId;
217
- } else { // add as new comment
218
- if ($comment->comment_parent) {
219
- array_push($messageArray['message']['comments'], $newCommentId);
220
- } else {
221
- array_unshift($messageArray['message']['comments'], $newCommentId);
 
 
222
  }
223
  }
224
  }
@@ -236,7 +246,7 @@ class WpdiscuzCore implements WpDiscuzConstants {
236
  $newCommentIds = isset($_POST['newCommentIds']) ? trim($_POST['newCommentIds']) : '';
237
 
238
  if ($postId && $newCommentIds) {
239
- $current_user = wp_get_current_user();
240
  $messageArray['code'] = 1;
241
  $newCommentIds = explode(',', trim($newCommentIds, ','));
242
  $postId = trim(intval($postId));
@@ -270,7 +280,7 @@ class WpdiscuzCore implements WpDiscuzConstants {
270
  }
271
  $commentDepth = isset($_POST['wc_comment_depth']) && intval($_POST['wc_comment_depth']) ? intval($_POST['wc_comment_depth']) : 1;
272
  $isInSameContainer = '1';
273
- $current_user = wp_get_current_user();
274
  if ($commentDepth > $this->optionsSerialized->wordpressThreadCommentsDepth) {
275
  $commentDepth = $this->optionsSerialized->wordpressThreadCommentsDepth;
276
  $isInSameContainer = '0';
@@ -279,19 +289,19 @@ class WpdiscuzCore implements WpDiscuzConstants {
279
  }
280
  $notificationType = isset($_POST['wpdiscuz_notification_type']) ? $_POST['wpdiscuz_notification_type'] : '';
281
 
282
- $form->validateDefaultCaptcha($current_user);
283
- $form->validateFields($current_user);
284
 
285
  $website_url = '';
286
- if ($current_user && $current_user->ID) {
287
- $user_id = $current_user->ID;
288
- $name = $this->helper->getCurrentUserDisplayName($current_user);
289
- $email = $current_user->user_email;
290
  } else {
291
  $user_id = 0;
292
- $name = $form->validateDefaultName($current_user);
293
- $email = $form->validateDefaultEmail($current_user, $isAnonymous);
294
- $website_url = $form->validateDefaultWebsit($current_user);
295
  }
296
 
297
  $comment_content = $this->helper->replaceCommentContentCode(trim($_POST['wc_comment']));
@@ -342,8 +352,8 @@ class WpdiscuzCore implements WpDiscuzConstants {
342
  $_POST[Prompt_Comment_Form_Handling::SUBSCRIBE_CHECKBOX_NAME] = 1;
343
  Prompt_Comment_Form_Handling::handle_form($new_comment_id, $newComment->comment_approved);
344
  } else if (!$isAnonymous && $notificationType) {
345
- $noNeedMemberConfirm = ($current_user->ID && $this->optionsSerialized->disableMemberConfirm);
346
- $noNeedGuestsConfirm = (!$current_user->ID && $this->optionsSerialized->disableGuestsConfirm && $this->dbManager->hasConfirmedSubscription($email));
347
  if ($noNeedMemberConfirm || $noNeedGuestsConfirm) {
348
  $this->dbManager->addEmailNotification($new_comment_id, $postId, $email, self::SUBSCRIPTION_COMMENT, 1);
349
  } else {
@@ -363,8 +373,9 @@ class WpdiscuzCore implements WpDiscuzConstants {
363
  $messageArray['is_in_same_container'] = $isInSameContainer;
364
  $messageArray['wc_all_comments_count_new'] = $this->dbManager->getCommentsCount($postId);
365
  $commentListArgs = $this->getCommentListArgs($postId);
366
- $commentListArgs['current_user'] = $current_user;
367
  $commentListArgs['addComment'] = $commentDepth;
 
368
  $messageArray['message'] = wp_list_comments($commentListArgs, array($newComment));
369
  } else {
370
  $messageArray['code'] = 'wc_invalid_field';
@@ -392,10 +403,10 @@ class WpdiscuzCore implements WpDiscuzConstants {
392
  $messageArray['code'] = 1;
393
  $messageArray['message'] = $form->renderEditFrontCommentForm($comment);
394
  } else {
395
- $current_user = wp_get_current_user();
396
  $isInRange = $this->helper->isContentInRange($comment->comment_content);
397
  $isEditable = $this->optionsSerialized->commentEditableTime == 'unlimit' ? true && $isInRange : $this->helper->isCommentEditable($comment) && $isInRange;
398
- if ($current_user && $comment->user_id == $current_user->ID && $isEditable) {
399
  $messageArray['code'] = 1;
400
  $messageArray['message'] = $form->renderEditFrontCommentForm($comment);
401
  } else {
@@ -422,13 +433,13 @@ class WpdiscuzCore implements WpDiscuzConstants {
422
  }
423
  if ($commentId) {
424
  $comment = get_comment($commentId);
425
- $current_user = wp_get_current_user();
426
  $uniqueId = $comment->comment_ID . '_' . $comment->comment_parent;
427
- $isCurrentUserCanEdit = $current_user && ($comment->user_id == $current_user->ID || current_user_can('edit_comment', $comment->comment_ID));
428
  if ($this->helper->isContentInRange($trimmedContent) && $isCurrentUserCanEdit) {
429
  $form = $this->wpdiscuzForm->getForm($comment->comment_post_ID);
430
  $form->initFormFields();
431
- $form->validateFields($current_user);
432
  $messageArray['code'] = 1;
433
  if ($trimmedContent != $comment->comment_content) {
434
  $trimmedContent = $this->helper->replaceCommentContentCode($trimmedContent);
@@ -474,7 +485,7 @@ class WpdiscuzCore implements WpDiscuzConstants {
474
  }
475
 
476
  public function getSingleComment() {
477
- $current_user = wp_get_current_user();
478
  $messageArray = array('code' => 0);
479
  $commentId = isset($_POST['commentId']) ? intval($_POST['commentId']) : 0;
480
  $comment = get_comment($commentId);
@@ -519,7 +530,7 @@ class WpdiscuzCore implements WpDiscuzConstants {
519
  public function loadMoreComments() {
520
  $postId = isset($_POST['postId']) ? intval($_POST['postId']) : 0;
521
  $lastParentId = isset($_POST['lastParentId']) ? intval($_POST['lastParentId']) : 0;
522
- if ($lastParentId && $postId) {
523
  $limit = ($this->optionsSerialized->commentListLoadType == 1) ? 0 : $this->optionsSerialized->wordpressCommentPerPage;
524
  $args = array('limit' => $limit);
525
  $orderBy = isset($_POST['orderBy']) ? trim($_POST['orderBy']) : '';
@@ -531,7 +542,9 @@ class WpdiscuzCore implements WpDiscuzConstants {
531
  $args['last_parent_id'] = $lastParentId;
532
  }
533
  $args['post_id'] = $postId;
 
534
  $commentData = $this->getWPComments($args);
 
535
  $commentData['callbackFunctions'] = array();
536
  $commentData = apply_filters('wpdiscuz_wmu_lightbox', $commentData);
537
  wp_die(json_encode($commentData));
@@ -661,16 +674,18 @@ class WpdiscuzCore implements WpDiscuzConstants {
661
  */
662
  public function getWPComments($args = array()) {
663
  global $post;
664
- $currentUser = wp_get_current_user();
665
  $postId = $post && $post->ID ? $post->ID : '';
666
  $defaults = $this->getDefaultCommentsArgs($postId);
667
  $this->commentsArgs = wp_parse_args($args, $defaults);
 
668
  do_action('wpdiscuz_before_getcomments', $this->commentsArgs, $currentUser, $args);
669
  $commentData = array();
670
  $commentListArgs = $this->getCommentListArgs($this->commentsArgs['post_id']);
671
  $commentList = $this->_getWPComments($commentListArgs, $commentData);
672
  $commentListArgs['current_user'] = $currentUser;
673
- $wcWpComments = wp_list_comments($commentListArgs, $commentList);
 
674
  $commentData['comment_list'] = $wcWpComments;
675
  $this->commentsArgs['caller'] = '';
676
  return $commentData;
@@ -679,19 +694,28 @@ class WpdiscuzCore implements WpDiscuzConstants {
679
  private function _getWPComments(&$commentListArgs, &$commentData) {
680
  $commentList = array();
681
  if (!$this->optionsSerialized->wordpressIsPaginate) {
 
682
  $this->commentsArgs['comment__in'] = $this->dbManager->getCommentList($this->commentsArgs);
683
  $commentData['last_parent_id'] = $this->commentsArgs['comment__in'] ? $this->commentsArgs['comment__in'][count($this->commentsArgs['comment__in']) - 1] : 0;
 
 
 
 
 
 
684
  if ($this->commentsArgs['is_threaded']) {
685
- $parentComments = get_comments($this->commentsArgs);
686
- foreach ($parentComments as $parentComment) {
687
- $commentList[] = $parentComment;
688
- $childComments = $parentComment->get_children(array(
689
- 'format' => 'flat',
690
- 'status' => $this->commentsArgs['status'],
691
- 'orderby' => $this->commentsArgs['orderby']
692
- ));
693
- foreach ($childComments as $childComment) {
694
- $commentList[] = $childComment;
 
 
695
  }
696
  }
697
  } else {
@@ -699,7 +723,6 @@ class WpdiscuzCore implements WpDiscuzConstants {
699
  }
700
  $commentListArgs['page'] = 1;
701
  $commentListArgs['last_parent_id'] = $commentData['last_parent_id'];
702
- $commentData['is_show_load_more'] = $this->dbManager->isShowLoadMore;
703
  } else {
704
  unset($commentListArgs['reverse_top_level']);
705
  $commentList = null;
@@ -709,7 +732,7 @@ class WpdiscuzCore implements WpDiscuzConstants {
709
 
710
  public function commentsTemplateQueryArgs($args) {
711
  global $post;
712
- if ($this->helper->isLoadWpdiscuz($post) && !$this->optionsSerialized->wordpressIsPaginate) {
713
  $args['post__not_in'] = $post->ID;
714
  }
715
  return $args;
@@ -732,14 +755,11 @@ class WpdiscuzCore implements WpDiscuzConstants {
732
  if ($this->commentsArgs['caller'] === 'wpdiscuz' && $this->commentsArgs['comment__in']) {
733
  $orderby = '';
734
  $args['caller'] = $this->commentsArgs['caller'] = 'wpdiscuz-';
735
- if (!$this->optionsSerialized->votingButtonsShowHide) {
736
- $args['join'] .= "INNER JOIN " . $wpdb->commentmeta . " ON " . $wpdb->comments . ".comment_ID = " . $wpdb->commentmeta . ".comment_id";
737
- $args['where'] .= " AND (" . $wpdb->commentmeta . ".meta_key = '" . self::META_KEY_VOTES . "')";
738
- }
739
- if ($this->commentsArgs['orderby'] == 'by_vote') {
740
  $orderby = $wpdb->commentmeta . ".meta_value+0 DESC, ";
741
  }
742
- $args['orderby'] = $orderby . $wpdb->comments . ".comment_date_gmt ";
743
  $args['orderby'] .= isset($args['order']) ? '' : $this->commentsArgs['order'];
744
  }
745
  return $args;
@@ -843,11 +863,24 @@ class WpdiscuzCore implements WpDiscuzConstants {
843
  */
844
  public function frontEndStylesScripts() {
845
  global $post;
 
846
  if (!$this->optionsSerialized->disableFontAwesome) {
847
  wp_register_style('wpdiscuz-font-awesome', plugins_url(WPDISCUZ_DIR_NAME . '/assets/third-party/font-awesome-4.6.3/css/font-awesome.min.css'), null, '4.5.0');
848
  }
849
 
850
- if ($this->helper->isLoadWpdiscuz($post)) {
 
 
 
 
 
 
 
 
 
 
 
 
851
  if (!$this->optionsSerialized->disableFontAwesome) {
852
  wp_enqueue_style('wpdiscuz-font-awesome');
853
  }
@@ -864,11 +897,16 @@ class WpdiscuzCore implements WpDiscuzConstants {
864
  wp_enqueue_script('wpdiscuz-cookie-js');
865
  wp_register_script('autogrowtextarea-js', plugins_url(WPDISCUZ_DIR_NAME . '/assets/third-party/autogrow/jquery.autogrowtextarea.min.js'), array('jquery'), '3.0', false);
866
  wp_enqueue_script('autogrowtextarea-js');
 
 
867
  $this->wpdiscuzOptionsJs = $this->optionsSerialized->getOptionsForJs();
868
  $this->wpdiscuzOptionsJs['version'] = $this->version;
869
  $this->wpdiscuzOptionsJs['wc_post_id'] = $post->ID;
870
  $this->wpdiscuzOptionsJs['loadLastCommentId'] = 0;
871
- if($this->optionsSerialized->commentListUpdateType) {
 
 
 
872
  $cArgs = $this->getDefaultCommentsArgs($post->ID);
873
  $this->wpdiscuzOptionsJs['loadLastCommentId'] = $this->dbManager->getLastCommentId($cArgs);
874
  }
@@ -977,11 +1015,24 @@ class WpdiscuzCore implements WpDiscuzConstants {
977
 
978
  public function initCurrentPostType() {
979
  global $post;
980
- if ($this->helper->isLoadWpdiscuz($post)) {
981
  add_filter('comments_template', array(&$this, 'addCommentForm'), 10);
982
  }
983
  }
984
 
 
 
 
 
 
 
 
 
 
 
 
 
 
985
  public function addCommentForm($file) {
986
  $file = dirname(__FILE__) . '/templates/comment/comment-form.php';
987
  return $file;
3
  /*
4
  * Plugin Name: wpDiscuz
5
  * Description: Better comment system. Wordpress post comments and discussion plugin. Allows your visitors discuss, vote for comments and share.
6
+ * Version: 4.1.0
7
  * Author: gVectors Team (A. Chakhoyan, G. Zakaryan, H. Martirosyan)
8
  * Author URI: https://gvectors.com/
9
  * Plugin URI: http://wpdiscuz.com/
43
  public $commentsArgs;
44
  private $version;
45
  public $wpdiscuzForm;
46
+ public $subscriptionData;
47
+ public $isWpdiscuzLoaded;
48
+ public static $CURRENT_BLOG_ID;
49
 
50
  public function __construct() {
51
  $this->version = get_option(self::OPTION_SLUG_VERSION, '1.0.0');
58
  $this->optimizationHelper = new WpdiscuzOptimizationHelper($this->optionsSerialized, $this->dbManager, $this->emailHelper, $this->wpdiscuzForm);
59
  $this->css = new WpdiscuzCss($this->optionsSerialized, $this->helper);
60
  $this->wpdiscuzWalker = new WpdiscuzWalker($this->helper, $this->optimizationHelper, $this->dbManager, $this->optionsSerialized);
61
+ self::$CURRENT_BLOG_ID = get_current_blog_id();
62
  register_activation_hook(__FILE__, array(&$this, 'pluginActivation'));
63
  register_deactivation_hook(__FILE__, array(&$this->wpdiscuzForm, 'removeAllFiles'));
64
  add_action('wpmu_new_blog', array(&$this, 'addNewBlog'));
65
  add_action('delete_blog', array(&$this, 'deleteBlog'));
66
  add_action('wp_head', array(&$this, 'initCurrentPostType'));
67
  add_action('wp_head', array(&$this->css, 'initCustomCss'));
68
+ // add_action('get_header', array(&$this, 'setCookies'));
69
 
70
  add_action('init', array(&$this, 'wpdiscuzTextDomain'));
71
  add_action('admin_init', array(&$this, 'pluginNewVersion'), 1);
124
  add_action('wp_loaded', array(&$this, 'addNewRoles'));
125
  add_filter('comments_template_query_args', array(&$this, 'commentsTemplateQueryArgs'));
126
  add_action('pre_get_comments', array(&$this, 'preGetComments'));
127
+ add_action('deleted_comment', array(&$this->optimizationHelper, 'cleanCommentRelatedRows'));
128
  }
129
 
130
  public function pluginActivation($networkwide) {
175
  }
176
 
177
  public function updateAutomatically() {
178
+ $current_user = WpdiscuzHelper::getCurrentUser();
179
  $messageArray = array('code' => 0);
180
  $postId = isset($_POST['postId']) ? intval($_POST['postId']) : 0;
181
  $loadLastCommentId = isset($_POST['loadLastCommentId']) ? intval($_POST['loadLastCommentId']) : 0;
196
  if ($this->optionsSerialized->commentListUpdateType == 1) {
197
  $messageArray['message'] = array();
198
  foreach ($newCommentIds as $newCommentId) {
199
+ if (!in_array($newCommentId, $visibleCommentIds)) {
200
+ $comment = get_comment($newCommentId);
201
+ if (($comment->comment_parent && (in_array($comment->comment_parent, $visibleCommentIds) || in_array($comment->comment_parent, $newCommentIds))) || !$comment->comment_parent) {
202
+ $commentHtml = wp_list_comments($commentListArgs, array($comment));
203
+ $commentObject = array('comment_parent' => $comment->comment_parent, 'comment_html' => $commentHtml);
204
+ if ($comment->comment_parent) {
205
+ array_push($messageArray['message'], $commentObject);
206
+ } else {
207
+ array_unshift($messageArray['message'], $commentObject);
208
+ }
209
  }
210
  }
211
  }
219
  $messageArray['message']['author_replies'] = array();
220
  $messageArray['message']['comments'] = array();
221
  foreach ($newCommentIds as $newCommentId) {
222
+ if (!in_array($newCommentId, $visibleCommentIds)) {
223
+ $comment = get_comment($newCommentId);
224
+ if ($this->optimizationHelper->isReplyInAuthorTree($comment->comment_ID, $authorComments)) { // if is in author tree add as reply
225
+ $messageArray['message']['author_replies'][] = $newCommentId;
226
+ } else { // add as new comment
227
+ if ($comment->comment_parent) {
228
+ array_push($messageArray['message']['comments'], $newCommentId);
229
+ } else {
230
+ array_unshift($messageArray['message']['comments'], $newCommentId);
231
+ }
232
  }
233
  }
234
  }
246
  $newCommentIds = isset($_POST['newCommentIds']) ? trim($_POST['newCommentIds']) : '';
247
 
248
  if ($postId && $newCommentIds) {
249
+ $current_user = WpdiscuzHelper::getCurrentUser();
250
  $messageArray['code'] = 1;
251
  $newCommentIds = explode(',', trim($newCommentIds, ','));
252
  $postId = trim(intval($postId));
280
  }
281
  $commentDepth = isset($_POST['wc_comment_depth']) && intval($_POST['wc_comment_depth']) ? intval($_POST['wc_comment_depth']) : 1;
282
  $isInSameContainer = '1';
283
+ $currentUser = WpdiscuzHelper::getCurrentUser();
284
  if ($commentDepth > $this->optionsSerialized->wordpressThreadCommentsDepth) {
285
  $commentDepth = $this->optionsSerialized->wordpressThreadCommentsDepth;
286
  $isInSameContainer = '0';
289
  }
290
  $notificationType = isset($_POST['wpdiscuz_notification_type']) ? $_POST['wpdiscuz_notification_type'] : '';
291
 
292
+ $form->validateDefaultCaptcha($currentUser);
293
+ $form->validateFields($currentUser);
294
 
295
  $website_url = '';
296
+ if ($currentUser && $currentUser->ID) {
297
+ $user_id = $currentUser->ID;
298
+ $name = $this->helper->getCurrentUserDisplayName($currentUser);
299
+ $email = $currentUser->user_email;
300
  } else {
301
  $user_id = 0;
302
+ $name = $form->validateDefaultName($currentUser);
303
+ $email = $form->validateDefaultEmail($currentUser, $isAnonymous);
304
+ $website_url = $form->validateDefaultWebsit($currentUser);
305
  }
306
 
307
  $comment_content = $this->helper->replaceCommentContentCode(trim($_POST['wc_comment']));
352
  $_POST[Prompt_Comment_Form_Handling::SUBSCRIBE_CHECKBOX_NAME] = 1;
353
  Prompt_Comment_Form_Handling::handle_form($new_comment_id, $newComment->comment_approved);
354
  } else if (!$isAnonymous && $notificationType) {
355
+ $noNeedMemberConfirm = ($currentUser->ID && $this->optionsSerialized->disableMemberConfirm);
356
+ $noNeedGuestsConfirm = (!$currentUser->ID && $this->optionsSerialized->disableGuestsConfirm && $this->dbManager->hasConfirmedSubscription($email));
357
  if ($noNeedMemberConfirm || $noNeedGuestsConfirm) {
358
  $this->dbManager->addEmailNotification($new_comment_id, $postId, $email, self::SUBSCRIPTION_COMMENT, 1);
359
  } else {
373
  $messageArray['is_in_same_container'] = $isInSameContainer;
374
  $messageArray['wc_all_comments_count_new'] = $this->dbManager->getCommentsCount($postId);
375
  $commentListArgs = $this->getCommentListArgs($postId);
376
+ $commentListArgs['current_user'] = $currentUser;
377
  $commentListArgs['addComment'] = $commentDepth;
378
+ $commentListArgs['comment_author_email'] = $email;
379
  $messageArray['message'] = wp_list_comments($commentListArgs, array($newComment));
380
  } else {
381
  $messageArray['code'] = 'wc_invalid_field';
403
  $messageArray['code'] = 1;
404
  $messageArray['message'] = $form->renderEditFrontCommentForm($comment);
405
  } else {
406
+ $current_user = WpdiscuzHelper::getCurrentUser();
407
  $isInRange = $this->helper->isContentInRange($comment->comment_content);
408
  $isEditable = $this->optionsSerialized->commentEditableTime == 'unlimit' ? true && $isInRange : $this->helper->isCommentEditable($comment) && $isInRange;
409
+ if ($isEditable && $this->helper->canUserEditComment($comment, $currentUser)) {
410
  $messageArray['code'] = 1;
411
  $messageArray['message'] = $form->renderEditFrontCommentForm($comment);
412
  } else {
433
  }
434
  if ($commentId) {
435
  $comment = get_comment($commentId);
436
+ $currentUser = WpdiscuzHelper::getCurrentUser();
437
  $uniqueId = $comment->comment_ID . '_' . $comment->comment_parent;
438
+ $isCurrentUserCanEdit = $currentUser && ($comment->user_id == $currentUser->ID || current_user_can('edit_comment', $comment->comment_ID));
439
  if ($this->helper->isContentInRange($trimmedContent) && $isCurrentUserCanEdit) {
440
  $form = $this->wpdiscuzForm->getForm($comment->comment_post_ID);
441
  $form->initFormFields();
442
+ $form->validateFields($currentUser);
443
  $messageArray['code'] = 1;
444
  if ($trimmedContent != $comment->comment_content) {
445
  $trimmedContent = $this->helper->replaceCommentContentCode($trimmedContent);
485
  }
486
 
487
  public function getSingleComment() {
488
+ $current_user = WpdiscuzHelper::getCurrentUser();
489
  $messageArray = array('code' => 0);
490
  $commentId = isset($_POST['commentId']) ? intval($_POST['commentId']) : 0;
491
  $comment = get_comment($commentId);
530
  public function loadMoreComments() {
531
  $postId = isset($_POST['postId']) ? intval($_POST['postId']) : 0;
532
  $lastParentId = isset($_POST['lastParentId']) ? intval($_POST['lastParentId']) : 0;
533
+ if ($lastParentId >= 0 && $postId) {
534
  $limit = ($this->optionsSerialized->commentListLoadType == 1) ? 0 : $this->optionsSerialized->wordpressCommentPerPage;
535
  $args = array('limit' => $limit);
536
  $orderBy = isset($_POST['orderBy']) ? trim($_POST['orderBy']) : '';
542
  $args['last_parent_id'] = $lastParentId;
543
  }
544
  $args['post_id'] = $postId;
545
+ $args[self::COOKIE_LAST_VISIT] = isset($_POST[self::COOKIE_LAST_VISIT]) ? $_POST[self::COOKIE_LAST_VISIT] : '';
546
  $commentData = $this->getWPComments($args);
547
+ $commentData['loadLastCommentId'] = $this->dbManager->getLastCommentId($this->commentsArgs);
548
  $commentData['callbackFunctions'] = array();
549
  $commentData = apply_filters('wpdiscuz_wmu_lightbox', $commentData);
550
  wp_die(json_encode($commentData));
674
  */
675
  public function getWPComments($args = array()) {
676
  global $post;
677
+ $currentUser = WpdiscuzHelper::getCurrentUser();
678
  $postId = $post && $post->ID ? $post->ID : '';
679
  $defaults = $this->getDefaultCommentsArgs($postId);
680
  $this->commentsArgs = wp_parse_args($args, $defaults);
681
+ $isLazyFirstLoad = $this->commentsArgs['first_load'] && $this->optionsSerialized->commentListLoadType == 2;
682
  do_action('wpdiscuz_before_getcomments', $this->commentsArgs, $currentUser, $args);
683
  $commentData = array();
684
  $commentListArgs = $this->getCommentListArgs($this->commentsArgs['post_id']);
685
  $commentList = $this->_getWPComments($commentListArgs, $commentData);
686
  $commentListArgs['current_user'] = $currentUser;
687
+ $commentListArgs[self::COOKIE_LAST_VISIT] = isset($this->commentsArgs[self::COOKIE_LAST_VISIT]) ? $this->commentsArgs[self::COOKIE_LAST_VISIT] : '';
688
+ $wcWpComments = $isLazyFirstLoad ? '' : wp_list_comments($commentListArgs, $commentList);
689
  $commentData['comment_list'] = $wcWpComments;
690
  $this->commentsArgs['caller'] = '';
691
  return $commentData;
694
  private function _getWPComments(&$commentListArgs, &$commentData) {
695
  $commentList = array();
696
  if (!$this->optionsSerialized->wordpressIsPaginate) {
697
+ $isLazyFirstLoad = $this->commentsArgs['first_load'] && $this->optionsSerialized->commentListLoadType == 2;
698
  $this->commentsArgs['comment__in'] = $this->dbManager->getCommentList($this->commentsArgs);
699
  $commentData['last_parent_id'] = $this->commentsArgs['comment__in'] ? $this->commentsArgs['comment__in'][count($this->commentsArgs['comment__in']) - 1] : 0;
700
+ if ($isLazyFirstLoad) {
701
+ $commentData['last_parent_id'] = 0;
702
+ $this->dbManager->isShowLoadMore = $this->commentsArgs['comment__in'] ? true : false;
703
+ $this->commentsArgs['comment__in'] = '';
704
+ }
705
+ $commentData['is_show_load_more'] = $this->dbManager->isShowLoadMore;
706
  if ($this->commentsArgs['is_threaded']) {
707
+ if ($this->commentsArgs['comment__in']) {
708
+ $parentComments = get_comments($this->commentsArgs);
709
+ foreach ($parentComments as $parentComment) {
710
+ $commentList[] = $parentComment;
711
+ $childComments = $parentComment->get_children(array(
712
+ 'format' => 'flat',
713
+ 'status' => $this->commentsArgs['status'],
714
+ 'orderby' => $this->commentsArgs['orderby']
715
+ ));
716
+ foreach ($childComments as $childComment) {
717
+ $commentList[] = $childComment;
718
+ }
719
  }
720
  }
721
  } else {
723
  }
724
  $commentListArgs['page'] = 1;
725
  $commentListArgs['last_parent_id'] = $commentData['last_parent_id'];
 
726
  } else {
727
  unset($commentListArgs['reverse_top_level']);
728
  $commentList = null;
732
 
733
  public function commentsTemplateQueryArgs($args) {
734
  global $post;
735
+ if ($this->isWpdiscuzLoaded && !$this->optionsSerialized->wordpressIsPaginate) {
736
  $args['post__not_in'] = $post->ID;
737
  }
738
  return $args;
755
  if ($this->commentsArgs['caller'] === 'wpdiscuz' && $this->commentsArgs['comment__in']) {
756
  $orderby = '';
757
  $args['caller'] = $this->commentsArgs['caller'] = 'wpdiscuz-';
758
+ if (!$this->optionsSerialized->votingButtonsShowHide && $this->commentsArgs['orderby'] == 'by_vote') {
759
+ $args['join'] .= " LEFT JOIN " . $wpdb->commentmeta . " ON " . $wpdb->comments . ".comment_ID = " . $wpdb->commentmeta . ".comment_id AND (" . $wpdb->commentmeta . ".meta_key = '" . self::META_KEY_VOTES . "')";
 
 
 
760
  $orderby = $wpdb->commentmeta . ".meta_value+0 DESC, ";
761
  }
762
+ $args['orderby'] = $orderby . $wpdb->comments . '.comment_date_gmt ';
763
  $args['orderby'] .= isset($args['order']) ? '' : $this->commentsArgs['order'];
764
  }
765
  return $args;
863
  */
864
  public function frontEndStylesScripts() {
865
  global $post;
866
+ $this->isWpdiscuzLoaded = $this->helper->isLoadWpdiscuz($post);
867
  if (!$this->optionsSerialized->disableFontAwesome) {
868
  wp_register_style('wpdiscuz-font-awesome', plugins_url(WPDISCUZ_DIR_NAME . '/assets/third-party/font-awesome-4.6.3/css/font-awesome.min.css'), null, '4.5.0');
869
  }
870
 
871
+ if (!$this->isWpdiscuzLoaded && $this->optionsSerialized->ratingCssOnNoneSingular) {
872
+ if (!$this->optionsSerialized->disableFontAwesome) {
873
+ wp_enqueue_style('wpdiscuz-font-awesome');
874
+ }
875
+ wp_register_style('wpdiscuz-ratings', plugins_url(WPDISCUZ_DIR_NAME . '/assets/css/wpdiscuz-ratings.css'), null, $this->version);
876
+ wp_enqueue_style('wpdiscuz-ratings');
877
+ if (is_rtl()) {
878
+ wp_register_style('wpdiscuz-ratings-rtl', plugins_url(WPDISCUZ_DIR_NAME . '/assets/css/wpdiscuz-ratings-rtl.css'), null, $this->version);
879
+ wp_enqueue_style('wpdiscuz-ratings-rtl');
880
+ }
881
+ }
882
+
883
+ if ($this->isWpdiscuzLoaded) {
884
  if (!$this->optionsSerialized->disableFontAwesome) {
885
  wp_enqueue_style('wpdiscuz-font-awesome');
886
  }
897
  wp_enqueue_script('wpdiscuz-cookie-js');
898
  wp_register_script('autogrowtextarea-js', plugins_url(WPDISCUZ_DIR_NAME . '/assets/third-party/autogrow/jquery.autogrowtextarea.min.js'), array('jquery'), '3.0', false);
899
  wp_enqueue_script('autogrowtextarea-js');
900
+ $form = $this->wpdiscuzForm->getForm($post->ID);
901
+ $form->initFormMeta();
902
  $this->wpdiscuzOptionsJs = $this->optionsSerialized->getOptionsForJs();
903
  $this->wpdiscuzOptionsJs['version'] = $this->version;
904
  $this->wpdiscuzOptionsJs['wc_post_id'] = $post->ID;
905
  $this->wpdiscuzOptionsJs['loadLastCommentId'] = 0;
906
+ $this->wpdiscuzOptionsJs['lastVisitKey'] = self::COOKIE_LAST_VISIT;
907
+ $this->wpdiscuzOptionsJs['lastVisitExpires'] = current_time('timestamp') + MONTH_IN_SECONDS;
908
+ $this->wpdiscuzOptionsJs['lastVisitCookie'] = $this->getLastVisitCookie();
909
+ if ($this->optionsSerialized->commentListUpdateType) {
910
  $cArgs = $this->getDefaultCommentsArgs($post->ID);
911
  $this->wpdiscuzOptionsJs['loadLastCommentId'] = $this->dbManager->getLastCommentId($cArgs);
912
  }
1015
 
1016
  public function initCurrentPostType() {
1017
  global $post;
1018
+ if ($this->isWpdiscuzLoaded) {
1019
  add_filter('comments_template', array(&$this, 'addCommentForm'), 10);
1020
  }
1021
  }
1022
 
1023
+ public function getLastVisitCookie() {
1024
+ global $post;
1025
+ $lastVisit = array();
1026
+ if ($this->isWpdiscuzLoaded) {
1027
+ $time = current_time('timestamp');
1028
+ if (isset($_COOKIE[self::COOKIE_LAST_VISIT])) {
1029
+ $lastVisit = json_decode(stripslashes($_COOKIE[self::COOKIE_LAST_VISIT]), true);
1030
+ }
1031
+ $lastVisit[self::$CURRENT_BLOG_ID][$post->ID] = $time;
1032
+ }
1033
+ return $lastVisit;
1034
+ }
1035
+
1036
  public function addCommentForm($file) {
1037
  $file = dirname(__FILE__) . '/templates/comment/comment-form.php';
1038
  return $file;
forms/wpDiscuzForm.php CHANGED
@@ -59,7 +59,7 @@ class wpDiscuzForm implements wpdFormConst {
59
  $postID = filter_input(INPUT_POST, 'comment_post_ID', FILTER_SANITIZE_NUMBER_INT);
60
  $this->getForm($postID);
61
  if ($this->form) {
62
- $currentUser = wp_get_current_user();
63
  $this->form->initFormFields();
64
  $this->form->validateFields($currentUser);
65
  }
59
  $postID = filter_input(INPUT_POST, 'comment_post_ID', FILTER_SANITIZE_NUMBER_INT);
60
  $this->getForm($postID);
61
  if ($this->form) {
62
+ $currentUser = WpdiscuzHelper::getCurrentUser();
63
  $this->form->initFormFields();
64
  $this->form->validateFields($currentUser);
65
  }
forms/wpdFormAttr/Field/CheckboxField.php CHANGED
@@ -9,13 +9,13 @@ class CheckboxField extends Field {
9
  <div class="wpd-field-body" style="display: <?php echo $this->display; ?>">
10
  <div class="wpd-field-option wpdiscuz-item">
11
  <input class="wpd-field-type" type="hidden" value="<?php echo $this->type; ?>" name="<?php echo $this->fieldInputName; ?>[type]" />
12
- <label><?php _e('Name', 'wpdiscuz'); ?>:</label>
13
- <input class="wpd-field-name" type="text" value="<?php echo $this->fieldData['name']; ?>" name="<?php echo $this->fieldInputName; ?>[name]" required />
14
  <p class="wpd-info"><?php _e('Also used for field placeholder', 'wpdiscuz'); ?></p>
15
  </div>
16
  <div class="wpd-field-option">
17
- <label><?php _e('Description', 'wpdiscuz'); ?>:</label>
18
- <input type="text" value="<?php echo $this->fieldData['desc']; ?>" name="<?php echo $this->fieldInputName; ?>[desc]" />
19
  <p class="wpd-info"><?php _e('Field specific short description or some rule related to inserted information.', 'wpdiscuz'); ?></p>
20
  </div>
21
  <div class="wpd-field-option wpdiscuz-item">
@@ -25,32 +25,32 @@ class CheckboxField extends Field {
25
  $values .= $value . "\n";
26
  }
27
  ?>
28
- <label><?php _e('Values', 'wpdiscuz'); ?>:</label>
29
- <textarea required name="<?php echo $this->fieldInputName; ?>[values]" ><?php echo $values; ?></textarea>
30
  <p class="wpd-info"><?php _e('Please insert one value per line', 'wpdiscuz'); ?></p>
31
  </div>
32
  <div class="wpd-field-option">
33
- <label><?php _e('Field is required', 'wpdiscuz'); ?>:</label>
34
- <input type="checkbox" value="1" <?php checked($this->fieldData['required'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[required]" />
35
  </div>
36
  <div class="wpd-field-option">
37
- <label><?php _e('Display on reply form', 'wpdiscuz'); ?>:</label>
38
- <input type="checkbox" value="1" <?php checked($this->fieldData['is_show_sform'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[is_show_sform]" />
39
  </div>
40
  <div class="wpd-field-option">
41
- <label><?php _e('Display on comment', 'wpdiscuz'); ?>:</label>
42
- <input type="checkbox" value="1" <?php checked($this->fieldData['is_show_on_comment'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[is_show_on_comment]" />
43
  </div>
44
  <div class="wpd-advaced-options wpd-field-option">
45
  <small class="wpd-advaced-options-title"><?php _e('Advanced Options', 'wpdiscuz'); ?></small>
46
  <div class="wpd-field-option wpd-advaced-options-cont">
47
  <div class="wpd-field-option">
48
- <label><?php _e('Meta Key', 'wpdiscuz'); ?>:</label>
49
- <input type="text" value="<?php echo $this->name; ?>" name="<?php echo $this->fieldInputName; ?>[meta_key]" required="required"/>
50
  </div>
51
  <div class="wpd-field-option">
52
- <label><?php _e('Replace old meta key', 'wpdiscuz'); ?>:</label>
53
- <input type="checkbox" value="1" checked="checked" name="<?php echo $this->fieldInputName; ?>[meta_key_replace]" />
54
  </div>
55
  </div>
56
  </div>
@@ -130,7 +130,7 @@ class CheckboxField extends Field {
130
  return '';
131
  }
132
  $html = '<div class="wpd-custom-field wpd-cf-text">';
133
- $html .= '<div class="wpd-cf-label">' . $args['name'] . '</div> <div class="wpd-cf-value"> ' . apply_filters('wpdiscuz_custom_field_checkbox', implode(' , ', $value) , $args) . '</div>';
134
  $html .= '</div>';
135
  return $html;
136
  }
9
  <div class="wpd-field-body" style="display: <?php echo $this->display; ?>">
10
  <div class="wpd-field-option wpdiscuz-item">
11
  <input class="wpd-field-type" type="hidden" value="<?php echo $this->type; ?>" name="<?php echo $this->fieldInputName; ?>[type]" />
12
+ <label for="wpd-field-name"><?php _e('Name', 'wpdiscuz'); ?>:</label>
13
+ <input id="wpd-field-name" class="wpd-field-name" type="text" value="<?php echo $this->fieldData['name']; ?>" name="<?php echo $this->fieldInputName; ?>[name]" required />
14
  <p class="wpd-info"><?php _e('Also used for field placeholder', 'wpdiscuz'); ?></p>
15
  </div>
16
  <div class="wpd-field-option">
17
+ <label for="wpd-field-desc"><?php _e('Description', 'wpdiscuz'); ?>:</label>
18
+ <input id="wpd-field-desc" type="text" value="<?php echo $this->fieldData['desc']; ?>" name="<?php echo $this->fieldInputName; ?>[desc]" />
19
  <p class="wpd-info"><?php _e('Field specific short description or some rule related to inserted information.', 'wpdiscuz'); ?></p>
20
  </div>
21
  <div class="wpd-field-option wpdiscuz-item">
25
  $values .= $value . "\n";
26
  }
27
  ?>
28
+ <label for="wpd-field-values"><?php _e('Values', 'wpdiscuz'); ?>:</label>
29
+ <textarea id="wpd-field-values" required name="<?php echo $this->fieldInputName; ?>[values]" ><?php echo $values; ?></textarea>
30
  <p class="wpd-info"><?php _e('Please insert one value per line', 'wpdiscuz'); ?></p>
31
  </div>
32
  <div class="wpd-field-option">
33
+ <label for="wpd-field-is-required"><?php _e('Field is required', 'wpdiscuz'); ?>:</label>
34
+ <input id="wpd-field-is-required" type="checkbox" value="1" <?php checked($this->fieldData['required'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[required]" />
35
  </div>
36
  <div class="wpd-field-option">
37
+ <label for="wpd-field-is-show-sform"><?php _e('Display on reply form', 'wpdiscuz'); ?>:</label>
38
+ <input id="wpd-field-is-show-sform" type="checkbox" value="1" <?php checked($this->fieldData['is_show_sform'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[is_show_sform]" />
39
  </div>
40
  <div class="wpd-field-option">
41
+ <label for="wpd-field-is-show-on-comment"><?php _e('Display on comment', 'wpdiscuz'); ?>:</label>
42
+ <input id="wpd-field-is-show-on-comment" type="checkbox" value="1" <?php checked($this->fieldData['is_show_on_comment'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[is_show_on_comment]" />
43
  </div>
44
  <div class="wpd-advaced-options wpd-field-option">
45
  <small class="wpd-advaced-options-title"><?php _e('Advanced Options', 'wpdiscuz'); ?></small>
46
  <div class="wpd-field-option wpd-advaced-options-cont">
47
  <div class="wpd-field-option">
48
+ <label for="wpd-field-meta-key"><?php _e('Meta Key', 'wpdiscuz'); ?>:</label>
49
+ <input id="wpd-field-meta-key" type="text" value="<?php echo $this->name; ?>" name="<?php echo $this->fieldInputName; ?>[meta_key]" required="required"/>
50
  </div>
51
  <div class="wpd-field-option">
52
+ <label for="wpd-field-old-meta-key"><?php _e('Replace old meta key', 'wpdiscuz'); ?>:</label>
53
+ <input id="wpd-field-old-meta-key" type="checkbox" value="1" checked="checked" name="<?php echo $this->fieldInputName; ?>[meta_key_replace]" />
54
  </div>
55
  </div>
56
  </div>
130
  return '';
131
  }
132
  $html = '<div class="wpd-custom-field wpd-cf-text">';
133
+ $html .= '<div class="wpd-cf-label">' . $args['name'] . '</div> <div class="wpd-cf-value"> ' . apply_filters('wpdiscuz_custom_field_checkbox', implode(' , ', $value), $args) . '</div>';
134
  $html .= '</div>';
135
  return $html;
136
  }
forms/wpdFormAttr/Field/ColorField.php CHANGED
@@ -9,44 +9,44 @@ class ColorField extends Field {
9
  <div class="wpd-field-body" style="display: <?php echo $this->display; ?>">
10
  <div class="wpd-field-option wpdiscuz-item">
11
  <input class="wpd-field-type" type="hidden" value="<?php echo $this->type; ?>" name="<?php echo $this->fieldInputName; ?>[type]" />
12
- <label><?php _e('Name', 'wpdiscuz'); ?>:</label>
13
- <input class="wpd-field-name" type="text" value="<?php echo $this->fieldData['name']; ?>" name="<?php echo $this->fieldInputName; ?>[name]" required />
14
  <p class="wpd-info"><?php _e('Also used for field placeholder', 'wpdiscuz'); ?></p>
15
  </div>
16
  <div class="wpd-field-option">
17
- <label><?php _e('Description', 'wpdiscuz'); ?>:</label>
18
- <input type="text" value="<?php echo $this->fieldData['desc']; ?>" name="<?php echo $this->fieldInputName; ?>[desc]" />
19
  <p class="wpd-info"><?php _e('Field specific short description or some rule related to inserted information.', 'wpdiscuz'); ?></p>
20
  </div>
21
  <div class="wpd-field-option">
22
  <div class="input-group">
23
- <label><span class="input-group-addon"></span> <?php _e('Field icon', 'wpdiscuz'); ?>:</label>
24
- <input data-placement="bottom" class="icp icp-auto" value="<?php echo $this->fieldData['icon']; ?>" type="text" name="<?php echo $this->fieldInputName; ?>[icon]"/>
25
  </div>
26
  <p class="wpd-info"><?php _e('Font-awesome icon library.', 'wpdiscuz'); ?></p>
27
  </div>
28
  <div class="wpd-field-option">
29
- <label><?php _e('Field is required', 'wpdiscuz'); ?>:</label>
30
- <input type="checkbox" value="1" <?php checked($this->fieldData['required'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[required]" />
31
  </div>
32
  <div class="wpd-field-option">
33
  <label><?php _e('Display on reply form', 'wpdiscuz'); ?>:</label>
34
  <input type="checkbox" value="1" <?php checked($this->fieldData['is_show_sform'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[is_show_sform]" />
35
  </div>
36
  <div class="wpd-field-option">
37
- <label><?php _e('Display on comment', 'wpdiscuz'); ?>:</label>
38
- <input type="checkbox" value="1" <?php checked($this->fieldData['is_show_on_comment'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[is_show_on_comment]" />
39
  </div>
40
  <div class="wpd-advaced-options wpd-field-option">
41
  <small class="wpd-advaced-options-title"><?php _e('Advanced Options', 'wpdiscuz'); ?></small>
42
  <div class="wpd-field-option wpd-advaced-options-cont">
43
  <div class="wpd-field-option">
44
- <label><?php _e('Meta Key', 'wpdiscuz'); ?>:</label>
45
- <input type="text" value="<?php echo $this->name; ?>" name="<?php echo $this->fieldInputName; ?>[meta_key]" required="required"/>
46
  </div>
47
  <div class="wpd-field-option">
48
- <label><?php _e('Replace old meta key', 'wpdiscuz'); ?>:</label>
49
- <input type="checkbox" value="1" checked="checked" name="<?php echo $this->fieldInputName; ?>[meta_key_replace]" />
50
  </div>
51
  </div>
52
  </div>
@@ -56,7 +56,7 @@ class ColorField extends Field {
56
  }
57
 
58
  public function editCommentHtml($key, $value, $data, $comment) {
59
- if($comment->comment_parent && !$data['is_show_sform']){
60
  return '';
61
  }
62
  $html = '<tr><td class="first">';
@@ -71,7 +71,7 @@ class ColorField extends Field {
71
  }
72
 
73
  public function frontFormHtml($name, $args, $options, $currentUser, $uniqueId, $isMainForm) {
74
- if(!$isMainForm && !$args['is_show_sform']){
75
  return;
76
  }
77
  $hasIcon = $args['icon'] ? true : false;
@@ -94,17 +94,17 @@ class ColorField extends Field {
94
  }
95
 
96
  public function frontHtml($value, $args) {
97
- if(!$args['is_show_on_comment']){
98
  return '';
99
  }
100
  $html = '<div class="wpd-custom-field wpd-cf-color">';
101
- $html .= '<div class="wpd-cf-label">' . $args['name'] . '</div> <div class="wpd-cf-value" style="background:' . $value . ';"> ' . apply_filters('wpdiscuz_custom_field_color', $value , $args) . ' </div>';
102
  $html .= '</div>';
103
  return $html;
104
  }
105
 
106
  public function validateFieldData($fieldName, $args, $options, $currentUser) {
107
- if(!$this->isCommentParentZero() && !$args['is_show_sform']){
108
  return '';
109
  }
110
  $value = trim(filter_input(INPUT_POST, $fieldName, FILTER_SANITIZE_STRING));
9
  <div class="wpd-field-body" style="display: <?php echo $this->display; ?>">
10
  <div class="wpd-field-option wpdiscuz-item">
11
  <input class="wpd-field-type" type="hidden" value="<?php echo $this->type; ?>" name="<?php echo $this->fieldInputName; ?>[type]" />
12
+ <label for="wpd-field-name"><?php _e('Name', 'wpdiscuz'); ?>:</label>
13
+ <input id="wpd-field-name" class="wpd-field-name" type="text" value="<?php echo $this->fieldData['name']; ?>" name="<?php echo $this->fieldInputName; ?>[name]" required />
14
  <p class="wpd-info"><?php _e('Also used for field placeholder', 'wpdiscuz'); ?></p>
15
  </div>
16
  <div class="wpd-field-option">
17
+ <label for="wpd-field-desc"><?php _e('Description', 'wpdiscuz'); ?>:</label>
18
+ <input id="wpd-field-desc" type="text" value="<?php echo $this->fieldData['desc']; ?>" name="<?php echo $this->fieldInputName; ?>[desc]" />
19
  <p class="wpd-info"><?php _e('Field specific short description or some rule related to inserted information.', 'wpdiscuz'); ?></p>
20
  </div>
21
  <div class="wpd-field-option">
22
  <div class="input-group">
23
+ <label for="wpd-field-color"><span class="input-group-addon"></span> <?php _e('Field icon', 'wpdiscuz'); ?>:</label>
24
+ <input id="wpd-field-color" data-placement="bottom" class="icp icp-auto" value="<?php echo $this->fieldData['icon']; ?>" type="text" name="<?php echo $this->fieldInputName; ?>[icon]"/>
25
  </div>
26
  <p class="wpd-info"><?php _e('Font-awesome icon library.', 'wpdiscuz'); ?></p>
27
  </div>
28
  <div class="wpd-field-option">
29
+ <label for="wpd-field-is-required"><?php _e('Field is required', 'wpdiscuz'); ?>:</label>
30
+ <input id="wpd-field-is-required" type="checkbox" value="1" <?php checked($this->fieldData['required'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[required]" />
31
  </div>
32
  <div class="wpd-field-option">
33
  <label><?php _e('Display on reply form', 'wpdiscuz'); ?>:</label>
34
  <input type="checkbox" value="1" <?php checked($this->fieldData['is_show_sform'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[is_show_sform]" />
35
  </div>
36
  <div class="wpd-field-option">
37
+ <label for="wpd-field-is-show-on-comment"><?php _e('Display on comment', 'wpdiscuz'); ?>:</label>
38
+ <input id="wpd-field-is-show-on-comment" type="checkbox" value="1" <?php checked($this->fieldData['is_show_on_comment'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[is_show_on_comment]" />
39
  </div>
40
  <div class="wpd-advaced-options wpd-field-option">
41
  <small class="wpd-advaced-options-title"><?php _e('Advanced Options', 'wpdiscuz'); ?></small>
42
  <div class="wpd-field-option wpd-advaced-options-cont">
43
  <div class="wpd-field-option">
44
+ <label for="wpd-field-meta-key"><?php _e('Meta Key', 'wpdiscuz'); ?>:</label>
45
+ <input id="wpd-field-meta-key" type="text" value="<?php echo $this->name; ?>" name="<?php echo $this->fieldInputName; ?>[meta_key]" required="required"/>
46
  </div>
47
  <div class="wpd-field-option">
48
+ <label for="wpd-field-old-meta-key"><?php _e('Replace old meta key', 'wpdiscuz'); ?>:</label>
49
+ <input id="wpd-field-old-meta-key" type="checkbox" value="1" checked="checked" name="<?php echo $this->fieldInputName; ?>[meta_key_replace]" />
50
  </div>
51
  </div>
52
  </div>
56
  }
57
 
58
  public function editCommentHtml($key, $value, $data, $comment) {
59
+ if ($comment->comment_parent && !$data['is_show_sform']) {
60
  return '';
61
  }
62
  $html = '<tr><td class="first">';
71
  }
72
 
73
  public function frontFormHtml($name, $args, $options, $currentUser, $uniqueId, $isMainForm) {
74
+ if (!$isMainForm && !$args['is_show_sform']) {
75
  return;
76
  }
77
  $hasIcon = $args['icon'] ? true : false;
94
  }
95
 
96
  public function frontHtml($value, $args) {
97
+ if (!$args['is_show_on_comment']) {
98
  return '';
99
  }
100
  $html = '<div class="wpd-custom-field wpd-cf-color">';
101
+ $html .= '<div class="wpd-cf-label">' . $args['name'] . '</div> <div class="wpd-cf-value" style="background:' . $value . ';"> ' . apply_filters('wpdiscuz_custom_field_color', $value, $args) . ' </div>';
102
  $html .= '</div>';
103
  return $html;
104
  }
105
 
106
  public function validateFieldData($fieldName, $args, $options, $currentUser) {
107
+ if (!$this->isCommentParentZero() && !$args['is_show_sform']) {
108
  return '';
109
  }
110
  $value = trim(filter_input(INPUT_POST, $fieldName, FILTER_SANITIZE_STRING));
forms/wpdFormAttr/Field/DefaultField/Captcha.php CHANGED
@@ -32,19 +32,19 @@ class Captcha extends Field {
32
  <p class="wpd-info"><?php _e('Field specific short description or some rule related to inserted information.', 'wpdiscuz'); ?></p>
33
  </div>
34
  <div class="wpd-field-option">
35
- <label><?php _e('Show for guests', 'wpdiscuz'); ?>:</label>
36
- <input type="checkbox" value="1" <?php checked($this->fieldData['show_for_guests'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[show_for_guests]" />
37
  </div>
38
  <div class="wpd-field-option">
39
- <label><?php _e('Show for logged in users', 'wpdiscuz'); ?>:</label>
40
- <input type="checkbox" value="1" <?php checked($this->fieldData['show_for_users'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[show_for_users]" />
41
  </div>
42
  <div style="clear:both;"></div>
43
  </div>
44
  <?php
45
  }
46
 
47
- public function frontFormHtml($name, $args, $options, $currentUser, $uniqueId,$isMainForm) {
48
  if ($options->isGoodbyeCaptchaActive) {
49
  echo $options->goodbyeCaptchaTocken;
50
  } else {
@@ -53,7 +53,7 @@ class Captcha extends Field {
53
  global $wpDiscuzReCaptcha;
54
  $wpDiscuzReCaptcha->recaptchaHtml($uniqueId);
55
  } else {
56
- $this->generateCaptchaHtml($args,$options);
57
  }
58
  }
59
  }
@@ -78,8 +78,8 @@ class Captcha extends Field {
78
  return wp_parse_args($cleanData, $this->fieldDefaultData);
79
  }
80
 
81
- public function validateFieldData($fieldName,$args, $options, $currentUser) {
82
- if ($currentUser && $this->isShowCaptcha($currentUser->ID,$args) && !class_exists("wpDiscuzReCaptcha") && !$options->isGoodbyeCaptchaActive) {
83
  $captcha = isset($_POST[$fieldName]) ? trim($_POST[$fieldName]) : '';
84
  if ($options->isCaptchaInSession) {
85
  if (!session_id()) {
@@ -117,11 +117,11 @@ class Captcha extends Field {
117
  $this->msgPNGCreationDisabled = __('PNG image creation disabled', 'wpdiscuz');
118
  }
119
 
120
- private function generateCaptchaHtml($args,$options) {
121
  ?>
122
  <div class="wc-field-captcha wpdiscuz-item">
123
  <div class="wc-captcha-input">
124
- <input type="text" maxlength="5" value="" autocomplete="off" required="required" name="wc_captcha" class="wpd-field wc_field_captcha" placeholder="<?php echo $args['name']; ?>" title="Insert the CAPTCHA code">
125
  </div>
126
  <div class="wc-label wc-captcha-label">
127
  <?php
@@ -295,9 +295,13 @@ class Captcha extends Field {
295
  public function isShowCaptcha($isUserLoggedIn, $args) {
296
  return ($isUserLoggedIn && $args['show_for_users']) || (!$isUserLoggedIn && $args['show_for_guests']);
297
  }
298
-
299
- public function editCommentHtml($key, $value ,$data,$comment) {}
300
-
301
- public function frontHtml($value,$args) {}
 
 
 
 
302
 
303
  }
32
  <p class="wpd-info"><?php _e('Field specific short description or some rule related to inserted information.', 'wpdiscuz'); ?></p>
33
  </div>
34
  <div class="wpd-field-option">
35
+ <label for="wpd_captcha_show_for_guests"><?php _e('Show for guests', 'wpdiscuz'); ?>:</label>
36
+ <input id="wpd_captcha_show_for_guests" type="checkbox" value="1" <?php checked($this->fieldData['show_for_guests'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[show_for_guests]" />
37
  </div>
38
  <div class="wpd-field-option">
39
+ <label for="wpd_captcha_show_for_users"><?php _e('Show for logged in users', 'wpdiscuz'); ?>:</label>
40
+ <input id="wpd_captcha_show_for_users" type="checkbox" value="1" <?php checked($this->fieldData['show_for_users'], 1, true); ?> name="<?php echo $this->fieldInputName; ?>[show_for_users]" />
41
  </div>
42
  <div style="clear:both;"></div>
43
  </div>
44
  <?php
45
  }
46
 
47
+ public function frontFormHtml($name, $args, $options, $currentUser, $uniqueId, $isMainForm) {
48
  if ($options->isGoodbyeCaptchaActive) {
49
  echo $options->goodbyeCaptchaTocken;
50
  } else {
53
  global $wpDiscuzReCaptcha;
54
  $wpDiscuzReCaptcha->recaptchaHtml($uniqueId);
55
  } else {
56
+ $this->generateCaptchaHtml($args, $options);
57
  }
58
  }
59
  }
78
  return wp_parse_args($cleanData, $this->fieldDefaultData);
79
  }
80
 
81
+ public function validateFieldData($fieldName, $args, $options, $currentUser) {
82
+ if ($currentUser && $this->isShowCaptcha($currentUser->ID, $args) && !class_exists("wpDiscuzReCaptcha") && !$options->isGoodbyeCaptchaActive) {
83
  $captcha = isset($_POST[$fieldName]) ? trim($_POST[$fieldName]) : '';
84
  if ($options->isCaptchaInSession) {
85
  if (!session_id()) {
117
  $this->msgPNGCreationDisabled = __('PNG image creation disabled', 'wpdiscuz');
118
  }
119
 
120
+ private function generateCaptchaHtml($args, $options) {
121
  ?>
122
  <div class="wc-field-captcha wpdiscuz-item">
123
  <div class="wc-captcha-input">
124
+ <input type="text" maxlength="5" value="" autocomplete="off" required="required" name="wc_captcha" class="wpd-field wc_field_captcha" placeholder="<?php echo $args['name']; ?>" title="<?php _e('Insert the CAPTCHA code', 'wpdiscuz'); ?>">
125
  </div>
126
  <div class="wc-label wc-captcha-label">
127
  <?php
295
  public function isShowCaptcha($isUserLoggedIn, $args) {
296
  return ($isUserLoggedIn && $args['show_for_users']) || (!$isUserLoggedIn && $args['show_for_guests']);
297
  }
298
+
299
+ public function editCommentHtml($key, $value, $data, $comment) {
300
+
301
+ }
302
+
303
+ public function frontHtml($value, $args) {
304
+
305
+ }
306
 
307
  }
forms/wpdFormAttr/Field/DefaultField/Submit.php CHANGED
@@ -34,8 +34,7 @@ class Submit extends Field {
34
  $isShowSubscribeWrapper = false;
35
  if ($options->showHideReplyCheckbox) {
36
  if ($currentUser->ID) {
37
- $subscriptionData = $wpdiscuz->dbManager->hasSubscription($post->ID, $currentUser->user_email);
38
- $isShowSubscribeWrapper = !$subscriptionData || ($subscriptionData && $subscriptionData['type'] == $wpdiscuz::SUBSCRIPTION_COMMENT) ? true : false;
39
  } else {
40
  $isShowSubscribeWrapper = true;
41
  }
34
  $isShowSubscribeWrapper = false;
35
  if ($options->showHideReplyCheckbox) {
36
  if ($currentUser->ID) {
37
+ $isShowSubscribeWrapper = !$wpdiscuz->subscriptionData || ($wpdiscuz->subscriptionData && $wpdiscuz->subscriptionData['type'] == $wpdiscuz::SUBSCRIPTION_COMMENT) ? true : false;
 
38
  } else {
39
  $isShowSubscribeWrapper = true;
40
  }
forms/wpdFormAttr/Field/TextAreaField.php CHANGED
@@ -58,7 +58,7 @@ class TextAreaField extends Field {
58
  $html .= '</td><td>';
59
  $html .= '<div class="wpdiscuz-item">';
60
  $required = $data['required'] ? 'required="required"' : '';
61
- $html .= '<textarea ' . $required . ' class="wpd-field wpd-field-textarea" id="' . $key . '" name="' . $key . '">'.$value.'</textarea>';
62
  $html .= '</div>';
63
  $html .= '</td></tr >';
64
  return $html;
@@ -84,7 +84,7 @@ class TextAreaField extends Field {
84
  return '';
85
  }
86
  $html = '<div class="wpd-custom-field wpd-cf-text">';
87
- $html .= '<div class="wpd-cf-label">' . $args['name'] . '</div> <div class="wpd-cf-value"> ' . apply_filters('wpdiscuz_custom_field_textarea', $value , $args) . '</div>';
88
  $html .= '</div>';
89
  return $html;
90
  }
58
  $html .= '</td><td>';
59
  $html .= '<div class="wpdiscuz-item">';
60
  $required = $data['required'] ? 'required="required"' : '';
61
+ $html .= '<textarea ' . $required . ' class="wpd-field wpd-field-textarea" id="' . $key . '" name="' . $key . '">'.esc_html($value).'</textarea>';
62
  $html .= '</div>';
63
  $html .= '</td></tr >';
64
  return $html;
84
  return '';
85
  }
86
  $html = '<div class="wpd-custom-field wpd-cf-text">';
87
+ $html .= '<div class="wpd-cf-label">' . $args['name'] . '</div> <div class="wpd-cf-value"> ' . apply_filters('wpdiscuz_custom_field_textarea', nl2br($value) , $args) . '</div>';
88
  $html .= '</div>';
89
  return $html;
90
  }
forms/wpdFormAttr/Form.php CHANGED
@@ -259,7 +259,7 @@ class Form {
259
  'itemprop' => true
260
  ), $atts);
261
  $this->initFormFields();
262
- if ($this->ratingsExists && is_singular()) {
263
  $wpdiscuzRatingCountMeta = get_post_meta($post->ID, 'wpdiscuz_rating_count', true);
264
  $wpdiscuzRatingCount = $wpdiscuzRatingCountMeta && is_array($wpdiscuzRatingCountMeta) ? $wpdiscuzRatingCountMeta : array();
265
  $ratingList = array();
@@ -465,6 +465,7 @@ class Form {
465
  $commentTextMaxLength = intval($this->wpdOptions->commentTextMaxLength);
466
  $commentTextLengthRange = ($commentTextMinLength && $commentTextMaxLength) ? 'pattern=".{' . $commentTextMinLength . ',' . $commentTextMaxLength . '}"' : '';
467
  $textareaMaxLength = $commentTextMaxLength ? "maxlength=$commentTextMaxLength" : '';
 
468
  ?>
469
  <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'"; ?> >
470
  <div class="wpdiscuz-comment-message" style="display: block;"></div>
@@ -472,7 +473,7 @@ class Form {
472
  <div class="wc-secondary-forms-social-content"></div>
473
  <?php } ?>
474
  <?php
475
- if ($this->isGuestCanComment($currentUser->ID)) {
476
  ?>
477
  <form class="wc_comm_form <?php echo!$isMain ? 'wc-secondary-form-wrapper' : 'wc_main_comm_form'; ?>" method="post" enctype="multipart/form-data">
478
  <div class="wc-field-comment">
@@ -515,10 +516,14 @@ class Form {
515
  <?php } else { ?>
516
  <p class="wc-must-login">
517
  <?php
518
- echo $this->wpdOptions->phrases['wc_you_must_be_text'];
519
- $login = wp_loginout(get_permalink(), false);
520
- $login = preg_replace('!>([^<]+)!is', '>' . $this->wpdOptions->phrases['wc_logged_in_text'], $login);
521
- echo ' ' . $login . ' ' . $this->wpdOptions->phrases['wc_to_post_comment_text'];
 
 
 
 
522
  ?>
523
  </p>
524
  <?php
@@ -589,7 +594,7 @@ class Form {
589
  <?php $lang = isset($this->generalOptions['lang']) ? $this->generalOptions['lang'] : get_locale(); ?>
590
  <input required="" type="text" name="<?php echo wpdFormConst::WPDISCUZ_META_FORMS_GENERAL_OPTIONS; ?>[lang]" value="<?php echo $lang; ?>" >
591
  </td>
592
- </tr>
593
  <tr>
594
  <th>
595
  <?php _e('Allow guests to comment', 'wpdiscuz'); ?>
@@ -688,13 +693,22 @@ class Form {
688
  <?php
689
  }
690
 
691
- private function isGuestCanComment($isUserLoggedIn) {
 
692
  $user_can_comment = TRUE;
693
  if (!$this->generalOptions['guest_can_comment']) {
694
  if (!$isUserLoggedIn) {
695
  $user_can_comment = FALSE;
696
  }
697
  }
 
 
 
 
 
 
 
 
698
  return $user_can_comment;
699
  }
700
 
@@ -792,6 +806,7 @@ class Form {
792
 
793
  public function transferJSData($data) {
794
  $this->initFormFields();
 
795
  $data['wc_captcha_show_for_guest'] = $this->formFields[wpdFormConst::WPDISCUZ_FORMS_CAPTCHA_FIELD]['show_for_guests'];
796
  $data['wc_captcha_show_for_members'] = $this->formFields[wpdFormConst::WPDISCUZ_FORMS_CAPTCHA_FIELD]['show_for_users'];
797
  $data['is_email_field_required'] = $this->formFields[wpdFormConst::WPDISCUZ_FORMS_EMAIL_FIELD]['required'];
259
  'itemprop' => true
260
  ), $atts);
261
  $this->initFormFields();
262
+ if ($this->ratingsExists && (($this->wpdOptions->ratingCssOnNoneSingular && !is_singular()) || is_single())) {
263
  $wpdiscuzRatingCountMeta = get_post_meta($post->ID, 'wpdiscuz_rating_count', true);
264
  $wpdiscuzRatingCount = $wpdiscuzRatingCountMeta && is_array($wpdiscuzRatingCountMeta) ? $wpdiscuzRatingCountMeta : array();
265
  $ratingList = array();
465
  $commentTextMaxLength = intval($this->wpdOptions->commentTextMaxLength);
466
  $commentTextLengthRange = ($commentTextMinLength && $commentTextMaxLength) ? 'pattern=".{' . $commentTextMinLength . ',' . $commentTextMaxLength . '}"' : '';
467
  $textareaMaxLength = $commentTextMaxLength ? "maxlength=$commentTextMaxLength" : '';
468
+ $message = '';
469
  ?>
470
  <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'"; ?> >
471
  <div class="wpdiscuz-comment-message" style="display: block;"></div>
473
  <div class="wc-secondary-forms-social-content"></div>
474
  <?php } ?>
475
  <?php
476
+ if ($this->isUserCanComment($currentUser->ID, $message)) {
477
  ?>
478
  <form class="wc_comm_form <?php echo!$isMain ? 'wc-secondary-form-wrapper' : 'wc_main_comm_form'; ?>" method="post" enctype="multipart/form-data">
479
  <div class="wc-field-comment">
516
  <?php } else { ?>
517
  <p class="wc-must-login">
518
  <?php
519
+ if (!$message) {
520
+ echo $this->wpdOptions->phrases['wc_you_must_be_text'];
521
+ $login = wp_loginout(get_permalink(), false);
522
+ $login = preg_replace('!>([^<]+)!is', '>' . $this->wpdOptions->phrases['wc_logged_in_text'], $login);
523
+ echo ' ' . $login . ' ' . $this->wpdOptions->phrases['wc_to_post_comment_text'];
524
+ } else {
525
+ echo $message;
526
+ }
527
  ?>
528
  </p>
529
  <?php
594
  <?php $lang = isset($this->generalOptions['lang']) ? $this->generalOptions['lang'] : get_locale(); ?>
595
  <input required="" type="text" name="<?php echo wpdFormConst::WPDISCUZ_META_FORMS_GENERAL_OPTIONS; ?>[lang]" value="<?php echo $lang; ?>" >
596
  </td>
597
+ </tr>
598
  <tr>
599
  <th>
600
  <?php _e('Allow guests to comment', 'wpdiscuz'); ?>
693
  <?php
694
  }
695
 
696
+ private function isUserCanComment($isUserLoggedIn, &$message) {
697
+ global $post;
698
  $user_can_comment = TRUE;
699
  if (!$this->generalOptions['guest_can_comment']) {
700
  if (!$isUserLoggedIn) {
701
  $user_can_comment = FALSE;
702
  }
703
  }
704
+ if (class_exists('WooCommerce') && get_post_type($post->ID) == 'product') {
705
+ if (get_option('woocommerce_review_rating_verification_required') === 'no' || wc_customer_bought_product('', get_current_user_id(), $post->ID)) {
706
+ $user_can_comment = TRUE;
707
+ } else {
708
+ $user_can_comment = FALSE;
709
+ $message = '<p class="woocommerce-verification-required">' . __('Only logged in customers who have purchased this product may leave a review.', 'woocommerce') . '</p>';
710
+ }
711
+ }
712
  return $user_can_comment;
713
  }
714
 
806
 
807
  public function transferJSData($data) {
808
  $this->initFormFields();
809
+
810
  $data['wc_captcha_show_for_guest'] = $this->formFields[wpdFormConst::WPDISCUZ_FORMS_CAPTCHA_FIELD]['show_for_guests'];
811
  $data['wc_captcha_show_for_members'] = $this->formFields[wpdFormConst::WPDISCUZ_FORMS_CAPTCHA_FIELD]['show_for_users'];
812
  $data['is_email_field_required'] = $this->formFields[wpdFormConst::WPDISCUZ_FORMS_EMAIL_FIELD]['required'];
manager/class.WpdiscuzDBManager.php CHANGED
@@ -188,7 +188,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
188
  if ($args['post_id']) {
189
  $approved = '';
190
  if ($args['status'] != 'all') {
191
- $approved = " AND `comment_approved` = 1 ";
192
  }
193
  $sql = $this->db->prepare("SELECT MAX(`comment_ID`) FROM `" . $this->dbprefix . "comments` WHERE `comment_post_ID` = %d " . $approved . ";", $args['post_id']);
194
  } else {
@@ -203,7 +203,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
203
  public function getNewCommentIds($args, $loadLastCommentId, $email) {
204
  $approved = '';
205
  if ($args['status'] != 'all') {
206
- $approved = " AND `comment_approved` = 1 ";
207
  }
208
  $sqlCommentIds = $this->db->prepare("SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE `comment_post_ID` = %d AND `comment_ID` > %d AND `comment_author_email` != %s " . $approved . " ORDER BY `comment_date_gmt` ASC;", $args['post_id'], $loadLastCommentId, $email);
209
  return $this->db->get_col($sqlCommentIds);
@@ -215,7 +215,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
215
  * @return type array of author comment ids
216
  */
217
  public function getAuthorVisibleComments($args, $visibleCommentIds, $email) {
218
- $sql = $this->db->prepare("SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE `comment_approved` = 1 AND `comment_ID` IN($visibleCommentIds) AND `comment_author_email` = %s;", $email);
219
  return $this->db->get_col($sql);
220
  }
221
 
@@ -224,7 +224,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
224
  * @return type int, all comments count for current post
225
  */
226
  public function getCommentsCount($postId) {
227
- $sqlCommentsCount = $this->db->prepare("SELECT count(*) FROM `" . $this->dbprefix . "comments` WHERE `comment_post_ID` = %d AND `comment_approved` = 1;", $postId);
228
  return $this->db->get_var($sqlCommentsCount);
229
  }
230
 
@@ -284,10 +284,10 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
284
  $commentParent = $args['is_threaded'] ? 'AND `c`.`comment_parent` = 0' : '';
285
  $status = $this->getCommentsStatus($args['status'], '`c`.');
286
  if ($args['limit']) {
287
- $sqlPostVotedCommentIds = $this->db->prepare("SELECT `c`.`comment_ID` FROM `" . $this->dbprefix . "comments` AS `c` INNER JOIN `" . $this->dbprefix . "commentmeta` AS `cm` ON `c`.`comment_ID` = `cm`.`comment_id` WHERE `cm`.`meta_key` = '" . self::META_KEY_VOTES . "' AND `c`.`comment_post_ID` = %d AND $status $commentParent ORDER BY (`cm`.`meta_value`+0) desc, `c`.`comment_date_gmt` {$args['date_order']} LIMIT %d OFFSET %d", $args['post_id'], $args['limit'] + 1, $args['offset']);
288
  } else {
289
  $allParentCounts = count($this->getAllParentCommentCount($args['post_id'], $args['is_threaded']));
290
- $sqlPostVotedCommentIds = $this->db->prepare("SELECT `c`.`comment_ID` FROM `" . $this->dbprefix . "comments` AS `c` INNER JOIN `" . $this->dbprefix . "commentmeta` AS `cm` ON `c`.`comment_ID` = `cm`.`comment_id` WHERE `cm`.`meta_key` = '" . self::META_KEY_VOTES . "' AND `c`.`comment_post_ID` = %d AND $status $commentParent ORDER BY (`cm`.`meta_value`+0) desc, `c`.`comment_date_gmt` {$args['date_order']} LIMIT %d OFFSET %d", $args['post_id'], $allParentCounts, $args['offset']);
291
  }
292
  $data = $this->db->get_col($sqlPostVotedCommentIds);
293
  if (isset($args['limit']) && $args['limit'] != 0 && count($data) > $args['limit']) {
@@ -301,7 +301,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
301
  * @return type array of comment ids
302
  */
303
  public function getVotedCommentIds() {
304
- $sqlVotedCommentIds = "SELECT `c`.`comment_ID` FROM `" . $this->dbprefix . "comments` AS `c` INNER JOIN `" . $this->dbprefix . "commentmeta` AS `cm` ON `c`.`comment_ID` = `cm`.`comment_id` WHERE `cm`.`meta_key` = '" . self::META_KEY_VOTES . "' AND `c`.`comment_approved` = 1 AND `c`.`comment_parent` = 0;";
305
  return $this->db->get_col($sqlVotedCommentIds);
306
  }
307
 
@@ -316,7 +316,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
316
  public function getAllParentCommentCount($postId = 0, $isThreaded = 1) {
317
  $commentParent = $isThreaded ? '`comment_parent` = 0' : '1';
318
  if ($postId) {
319
- $sql_comments = $this->db->prepare("SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE $commentParent AND `comment_post_ID` = %d AND `comment_approved` = 1", $postId);
320
  } else {
321
  $sql_comments = "SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE $commentParent";
322
  }
@@ -327,7 +327,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
327
  * get first level comments by parent comment id
328
  */
329
  public function getCommentsByParentId($commentId) {
330
- $sql_comments = $this->db->prepare("SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE `comment_parent` = %d AND `comment_approved` = 1;", $commentId);
331
  return $this->db->get_col($sql_comments);
332
  }
333
 
@@ -357,7 +357,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
357
  * get count by parent comment id
358
  */
359
  public function getCommentsCountByParentId($comment_id) {
360
- $sql_comments = $this->db->prepare("SELECT COUNT(`comment_ID`) FROM `" . $this->dbprefix . "comments` WHERE `comment_approved` = 1 AND `comment_parent` = %d", $comment_id);
361
  return $this->db->get_var($sql_comments);
362
  }
363
 
@@ -377,11 +377,6 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
377
  $this->db->query($sql);
378
  }
379
 
380
- public function checkVoteData($postId) {
381
- $sql_query = $this->db->prepare("INSERT INTO `" . $this->dbprefix . "commentmeta`(`meta_id`,`comment_id`, `meta_key`, `meta_value`)(SELECT NULL, `c`.`comment_ID`,%s,'0' FROM `" . $this->dbprefix . "comments` AS `c` LEFT JOIN `" . $this->dbprefix . "commentmeta` AS `cm` ON `cm`.`comment_id` = `c`.`comment_ID` AND `cm`.`meta_key` = %s WHERE `cm`.`meta_key` IS NULL AND `c`.`comment_post_ID` = %d);", self::META_KEY_VOTES, self::META_KEY_VOTES, $postId);
382
- $this->db->query($sql_query);
383
- }
384
-
385
  public function addEmailNotification($subsriptionId, $postId, $email, $subscriptionType, $confirm = 0) {
386
  if ($subscriptionType != self::SUBSCRIPTION_COMMENT) {
387
  $this->deleteCommentNotifications($subsriptionId, $email);
@@ -500,7 +495,7 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
500
  }
501
 
502
  public function getOptimizedCommentIds($postId) {
503
- $sql = $this->db->prepare("SELECT `cm`.`comment_id` FROM `" . $this->dbprefix . "commentmeta` AS `cm` INNER JOIN `" . $this->dbprefix . "comments` AS `c` ON `c`.`comment_ID` = `cm`.`comment_id` WHERE `c`.`comment_post_ID` = %d AND `c`.`comment_approved` = 1 AND `cm`.`meta_key` = '" . self::META_KEY_CHILDREN . "' AND `cm`.`meta_value` != '';", $postId);
504
  return $this->db->get_col($sql);
505
  }
506
 
@@ -522,11 +517,11 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
522
  private function getCommentsStatus($status, $alias = '') {
523
  $s = '';
524
  if ($status == 'all') {
525
- $s = "($alias`comment_approved` = 0 OR $alias`comment_approved` = 1)";
526
  } else if ($status == 'hold') {
527
- $s = "($alias`comment_approved` = 0)";
528
  } else {
529
- $s = "$alias`comment_approved` = 1";
530
  }
531
  return $s;
532
  }
@@ -575,4 +570,18 @@ class WpdiscuzDBManager implements WpDiscuzConstants {
575
  $this->db->query("DROP TABLE IF EXISTS `{$this->users_voted}`");
576
  }
577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  }
188
  if ($args['post_id']) {
189
  $approved = '';
190
  if ($args['status'] != 'all') {
191
+ $approved = " AND `comment_approved` = '1' ";
192
  }
193
  $sql = $this->db->prepare("SELECT MAX(`comment_ID`) FROM `" . $this->dbprefix . "comments` WHERE `comment_post_ID` = %d " . $approved . ";", $args['post_id']);
194
  } else {
203
  public function getNewCommentIds($args, $loadLastCommentId, $email) {
204
  $approved = '';
205
  if ($args['status'] != 'all') {
206
+ $approved = " AND `comment_approved` = '1' ";
207
  }
208
  $sqlCommentIds = $this->db->prepare("SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE `comment_post_ID` = %d AND `comment_ID` > %d AND `comment_author_email` != %s " . $approved . " ORDER BY `comment_date_gmt` ASC;", $args['post_id'], $loadLastCommentId, $email);
209
  return $this->db->get_col($sqlCommentIds);
215
  * @return type array of author comment ids
216
  */
217
  public function getAuthorVisibleComments($args, $visibleCommentIds, $email) {
218
+ $sql = $this->db->prepare("SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE `comment_approved` = '1' AND `comment_ID` IN($visibleCommentIds) AND `comment_author_email` = %s;", $email);
219
  return $this->db->get_col($sql);
220
  }
221
 
224
  * @return type int, all comments count for current post
225
  */
226
  public function getCommentsCount($postId) {
227
+ $sqlCommentsCount = $this->db->prepare("SELECT count(*) FROM `" . $this->dbprefix . "comments` WHERE `comment_post_ID` = %d AND `comment_approved` = '1';", $postId);
228
  return $this->db->get_var($sqlCommentsCount);
229
  }
230
 
284
  $commentParent = $args['is_threaded'] ? 'AND `c`.`comment_parent` = 0' : '';
285
  $status = $this->getCommentsStatus($args['status'], '`c`.');
286
  if ($args['limit']) {
287
+ $sqlPostVotedCommentIds = $this->db->prepare("SELECT `c`.`comment_ID` FROM `" . $this->dbprefix . "comments` AS `c` LEFT JOIN `" . $this->dbprefix . "commentmeta` AS `cm` ON `c`.`comment_ID` = `cm`.`comment_id` AND `cm`.`meta_key` = '" . self::META_KEY_VOTES . "' WHERE `c`.`comment_post_ID` = %d AND $status $commentParent ORDER BY (`cm`.`meta_value`+0) desc, `c`.`comment_date_gmt` {$args['date_order']} LIMIT %d OFFSET %d", $args['post_id'], $args['limit'] + 1, $args['offset']);
288
  } else {
289
  $allParentCounts = count($this->getAllParentCommentCount($args['post_id'], $args['is_threaded']));
290
+ $sqlPostVotedCommentIds = $this->db->prepare("SELECT `c`.`comment_ID` FROM `" . $this->dbprefix . "comments` AS `c` LEFT JOIN `" . $this->dbprefix . "commentmeta` AS `cm` ON `c`.`comment_ID` = `cm`.`comment_id` AND `cm`.`meta_key` = '" . self::META_KEY_VOTES . "' WHERE `c`.`comment_post_ID` = %d AND $status $commentParent ORDER BY (`cm`.`meta_value`+0) desc, `c`.`comment_date_gmt` {$args['date_order']} LIMIT %d OFFSET %d", $args['post_id'], $allParentCounts, $args['offset']);
291
  }
292
  $data = $this->db->get_col($sqlPostVotedCommentIds);
293
  if (isset($args['limit']) && $args['limit'] != 0 && count($data) > $args['limit']) {
301
  * @return type array of comment ids
302
  */
303
  public function getVotedCommentIds() {
304
+ $sqlVotedCommentIds = "SELECT `c`.`comment_ID` FROM `" . $this->dbprefix . "comments` AS `c` INNER JOIN `" . $this->dbprefix . "commentmeta` AS `cm` ON `c`.`comment_ID` = `cm`.`comment_id` WHERE `cm`.`meta_key` = '" . self::META_KEY_VOTES . "' AND `c`.`comment_approved` = '1' AND `c`.`comment_parent` = 0;";
305
  return $this->db->get_col($sqlVotedCommentIds);
306
  }
307
 
316
  public function getAllParentCommentCount($postId = 0, $isThreaded = 1) {
317
  $commentParent = $isThreaded ? '`comment_parent` = 0' : '1';
318
  if ($postId) {
319
+ $sql_comments = $this->db->prepare("SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE $commentParent AND `comment_post_ID` = %d AND `comment_approved` = '1'", $postId);
320
  } else {
321
  $sql_comments = "SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE $commentParent";
322
  }
327
  * get first level comments by parent comment id
328
  */
329
  public function getCommentsByParentId($commentId) {
330
+ $sql_comments = $this->db->prepare("SELECT `comment_ID` FROM `" . $this->dbprefix . "comments` WHERE `comment_parent` = %d AND `comment_approved` = '1';", $commentId);
331
  return $this->db->get_col($sql_comments);
332
  }
333
 
357
  * get count by parent comment id
358
  */
359
  public function getCommentsCountByParentId($comment_id) {
360
+ $sql_comments = $this->db->prepare("SELECT COUNT(`comment_ID`) FROM `" . $this->dbprefix . "comments` WHERE `comment_approved` = '1' AND `comment_parent` = %d", $comment_id);
361
  return $this->db->get_var($sql_comments);
362
  }
363
 
377
  $this->db->query($sql);
378
  }
379
 
 
 
 
 
 
380
  public function addEmailNotification($subsriptionId, $postId, $email, $subscriptionType, $confirm = 0) {
381
  if ($subscriptionType != self::SUBSCRIPTION_COMMENT) {
382
  $this->deleteCommentNotifications($subsriptionId, $email);
495
  }
496
 
497
  public function getOptimizedCommentIds($postId) {
498
+ $sql = $this->db->prepare("SELECT `cm`.`comment_id` FROM `" . $this->dbprefix . "commentmeta` AS `cm` INNER JOIN `" . $this->dbprefix . "comments` AS `c` ON `c`.`comment_ID` = `cm`.`comment_id` WHERE `c`.`comment_post_ID` = %d AND `c`.`comment_approved` = '1' AND `cm`.`meta_key` = '" . self::META_KEY_CHILDREN . "' AND `cm`.`meta_value` != '';", $postId);
499
  return $this->db->get_col($sql);
500
  }
501
 
517
  private function getCommentsStatus($status, $alias = '') {
518
  $s = '';
519
  if ($status == 'all') {
520
+ $s = "($alias`comment_approved` = '0' OR $alias`comment_approved` = '1')";
521
  } else if ($status == 'hold') {
522
+ $s = "($alias`comment_approved` = '0')";
523
  } else {
524
+ $s = "$alias`comment_approved` = '1'";
525
  }
526
  return $s;
527
  }
570
  $this->db->query("DROP TABLE IF EXISTS `{$this->users_voted}`");
571
  }
572
 
573
+ public function deleteSubscriptions($commnetId) {
574
+ if ($cId = intval($commnetId)) {
575
+ $sql = $this->db->prepare("DELETE FROM `{$this->emailNotification}` WHERE `subscribtion_id` = %d;", $cId);
576
+ $this->db->query($sql);
577
+ }
578
+ }
579
+
580
+ public function deleteVotes($commnetId) {
581
+ if ($cId = intval($commnetId)) {
582
+ $sql = $this->db->prepare("DELETE FROM `{$this->users_voted}` WHERE `comment_id` = %d;", $cId);
583
+ $this->db->query($sql);
584
+ }
585
+ }
586
+
587
  }
options/class.WpdiscuzOptions.php CHANGED
@@ -70,6 +70,7 @@ class WpdiscuzOptions {
70
  $this->optionsSerialized->disableTips = isset($_POST['disableTips']) ? $_POST['disableTips'] : 0;
71
  $this->optionsSerialized->disableProfileURLs = isset($_POST['disableProfileURLs']) ? $_POST['disableProfileURLs'] : 0;
72
  $this->optionsSerialized->displayRatingOnPost = isset($_POST['displayRatingOnPost']) ? $_POST['displayRatingOnPost'] : array();
 
73
  $this->optionsSerialized->customCss = isset($_POST['wc_custom_css']) ? $_POST['wc_custom_css'] : '.comments-area{width:auto; margin: 0 auto;}';
74
  $this->optionsSerialized->showPluginPoweredByLink = isset($_POST['wc_show_plugin_powerid_by']) ? $_POST['wc_show_plugin_powerid_by'] : 0;
75
  $this->optionsSerialized->isUsePoMo = isset($_POST['wc_is_use_po_mo']) ? $_POST['wc_is_use_po_mo'] : 0;
@@ -253,6 +254,7 @@ class WpdiscuzOptions {
253
  $this->addons = array(
254
  'emoticons' => array('version' => '1.1.1', 'requires' => '4.0.0', 'class' => 'wpDiscuzSmile', 'title' => 'Emoticons', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'emoticons' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Brings an ocean of emotions to your comments. It comes with an awesome smile package.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-emoticons/'),
255
  'author-info' => array('version' => '1.0.0', 'requires' => '4.0.6', 'class' => 'WpdiscuzCommentAuthorInfo', 'title' => 'Comment Author Info', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'author-info' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Extended information about comment author with Profile, Activity, Votes and Subscriptions Tabs on pop-up window.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-comment-author-info/'),
 
256
  'subscriptions' => array('version' => '1.0.0', 'requires' => '4.0.4', 'class' => 'wpdSubscribeManager', 'title' => 'Subscription Manager', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'subscriptions' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Total control over comment subscriptions. Full list, monitor, manage, filter, unsubscribe, confirm...', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-subscribe-manager/'),
257
  'ads-manager' => array('version' => '1.0.0', 'requires' => '4.0.0', 'class' => 'WpdiscuzAdsManager', 'title' => 'Ads Manager', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'ads-manager' . WPDISCUZ_DS . 'header.png'), 'desc' => __('A full-fledged tool-kit for advertising in comment section of your website. Separate banner and ad managment.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-ads-manager/'),
258
  'user-mention' => array('version' => '1.0.0', 'requires' => '4.0.0', 'class' => 'Wpdiscuz_UCM', 'title' => 'User &amp; Comment Mentioning', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'user-mention' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Allows to mention comments and users in comment text using #comment-id and @username tags.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-user-comment-mentioning/'),
@@ -265,7 +267,7 @@ class WpdiscuzOptions {
265
  'uploader' => array('version' => '1.1.0', 'requires' => '4.0.0', 'class' => 'WpdiscuzMediaUploader', 'title' => 'Media Uploader', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'uploader' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Extended comment attachment system. Allows to upload images, videos, audios and other file types.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-media-uploader/'),
266
  'recaptcha' => array('version' => '1.0.5', 'requires' => '4.0.0', 'class' => 'WpdiscuzRecaptcha', 'title' => 'Google ReCaptcha', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'recaptcha' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Adds No CAPTCHA on all comment forms. Stops spam and bot comments with Google reCAPTCHA', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-recaptcha/'),
267
  'mycred' => array('version' => '1.0.5', 'requires' => '4.0.0', 'class' => 'myCRED_Hook_wpDiscuz_Vote', 'title' => 'myCRED Integration', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'mycred' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Integrates myCRED Badges and Ranks. Converts wpDiscuz comment votes/likes to myCRED points. ', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-mycred/'),
268
- 'censure' => array('version' => '1.0.2', 'requires' => '4.0.0', 'class' => 'CommentCensure', 'title' => 'Comment Censure', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'censure' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Allows censoring comment words. Filters comments and replaces those phrases with custom words.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/comment-censure/'),
269
  );
270
  }
271
 
70
  $this->optionsSerialized->disableTips = isset($_POST['disableTips']) ? $_POST['disableTips'] : 0;
71
  $this->optionsSerialized->disableProfileURLs = isset($_POST['disableProfileURLs']) ? $_POST['disableProfileURLs'] : 0;
72
  $this->optionsSerialized->displayRatingOnPost = isset($_POST['displayRatingOnPost']) ? $_POST['displayRatingOnPost'] : array();
73
+ $this->optionsSerialized->ratingCssOnNoneSingular = isset($_POST['ratingCssOnNoneSingular']) ? $_POST['ratingCssOnNoneSingular'] : 0;
74
  $this->optionsSerialized->customCss = isset($_POST['wc_custom_css']) ? $_POST['wc_custom_css'] : '.comments-area{width:auto; margin: 0 auto;}';
75
  $this->optionsSerialized->showPluginPoweredByLink = isset($_POST['wc_show_plugin_powerid_by']) ? $_POST['wc_show_plugin_powerid_by'] : 0;
76
  $this->optionsSerialized->isUsePoMo = isset($_POST['wc_is_use_po_mo']) ? $_POST['wc_is_use_po_mo'] : 0;
254
  $this->addons = array(
255
  'emoticons' => array('version' => '1.1.1', 'requires' => '4.0.0', 'class' => 'wpDiscuzSmile', 'title' => 'Emoticons', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'emoticons' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Brings an ocean of emotions to your comments. It comes with an awesome smile package.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-emoticons/'),
256
  'author-info' => array('version' => '1.0.0', 'requires' => '4.0.6', 'class' => 'WpdiscuzCommentAuthorInfo', 'title' => 'Comment Author Info', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'author-info' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Extended information about comment author with Profile, Activity, Votes and Subscriptions Tabs on pop-up window.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-comment-author-info/'),
257
+ // 'online-users' => array('version' => '1.0.0', 'requires' => '4.1.0', 'class' => 'WpdiscuzOnlineUsers', 'title' => 'Online Users', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'online-users' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Real-time online user checking, pop-up notification of new online users and online/offline badges.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-online-users/'),
258
  'subscriptions' => array('version' => '1.0.0', 'requires' => '4.0.4', 'class' => 'wpdSubscribeManager', 'title' => 'Subscription Manager', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'subscriptions' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Total control over comment subscriptions. Full list, monitor, manage, filter, unsubscribe, confirm...', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-subscribe-manager/'),
259
  'ads-manager' => array('version' => '1.0.0', 'requires' => '4.0.0', 'class' => 'WpdiscuzAdsManager', 'title' => 'Ads Manager', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'ads-manager' . WPDISCUZ_DS . 'header.png'), 'desc' => __('A full-fledged tool-kit for advertising in comment section of your website. Separate banner and ad managment.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-ads-manager/'),
260
  'user-mention' => array('version' => '1.0.0', 'requires' => '4.0.0', 'class' => 'Wpdiscuz_UCM', 'title' => 'User &amp; Comment Mentioning', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'user-mention' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Allows to mention comments and users in comment text using #comment-id and @username tags.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-user-comment-mentioning/'),
267
  'uploader' => array('version' => '1.1.0', 'requires' => '4.0.0', 'class' => 'WpdiscuzMediaUploader', 'title' => 'Media Uploader', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'uploader' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Extended comment attachment system. Allows to upload images, videos, audios and other file types.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-media-uploader/'),
268
  'recaptcha' => array('version' => '1.0.5', 'requires' => '4.0.0', 'class' => 'WpdiscuzRecaptcha', 'title' => 'Google ReCaptcha', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'recaptcha' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Adds No CAPTCHA on all comment forms. Stops spam and bot comments with Google reCAPTCHA', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-recaptcha/'),
269
  'mycred' => array('version' => '1.0.5', 'requires' => '4.0.0', 'class' => 'myCRED_Hook_wpDiscuz_Vote', 'title' => 'myCRED Integration', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'mycred' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Integrates myCRED Badges and Ranks. Converts wpDiscuz comment votes/likes to myCRED points. ', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/wpdiscuz-mycred/'),
270
+ 'censure' => array('version' => '1.0.2', 'requires' => '4.0.0', 'class' => 'CommentCensure', 'title' => 'Comment Censure', 'thumb' => plugins_url(WPDISCUZ_DIR_NAME . WPDISCUZ_DS . 'assets' . WPDISCUZ_DS . 'addons' . WPDISCUZ_DS . 'censure' . WPDISCUZ_DS . 'header.png'), 'desc' => __('Allows censoring comment words. Filters comments and replaces those phrases with custom words.', 'wpdiscuz'), 'url' => 'https://gvectors.com/product/comments-censure-pro/'),
271
  );
272
  }
273
 
options/class.WpdiscuzOptionsSerialized.php CHANGED
@@ -284,6 +284,14 @@ class WpdiscuzOptionsSerialized implements WpDiscuzConstants {
284
  * Default Value - after
285
  */
286
  public $displayRatingOnPost;
 
 
 
 
 
 
 
 
287
 
288
  // == RATING == //
289
 
@@ -523,7 +531,7 @@ class WpdiscuzOptionsSerialized implements WpDiscuzConstants {
523
  $this->wordpressCommentOrder = get_option('comment_order');
524
  $this->wordpressCommentPerPage = get_option('comments_per_page');
525
  $this->wordpressShowAvatars = get_option('show_avatars');
526
- $this->wordpressDefaultCommentsPage = get_option('default_comments_page');
527
  $this->initFormRelations();
528
  $this->initGoodbyeCaptchaField();
529
  add_action('init', array(&$this, 'initPhrasesOnLoad'), 2126);
@@ -573,6 +581,7 @@ class WpdiscuzOptionsSerialized implements WpDiscuzConstants {
573
  $this->disableTips = isset($options['disableTips']) ? $options['disableTips'] : 0;
574
  $this->disableProfileURLs = isset($options['disableProfileURLs']) ? $options['disableProfileURLs'] : 0;
575
  $this->displayRatingOnPost = isset($options['displayRatingOnPost']) ? $options['displayRatingOnPost'] : array();
 
576
  $this->customCss = isset($options['wc_custom_css']) ? $options['wc_custom_css'] : '.comments-area{width:auto; margin: 0 auto;}';
577
  $this->showPluginPoweredByLink = isset($options['wc_show_plugin_powerid_by']) ? $options['wc_show_plugin_powerid_by'] : 0;
578
  $this->isUsePoMo = isset($options['wc_is_use_po_mo']) ? $options['wc_is_use_po_mo'] : 0;
@@ -656,7 +665,7 @@ class WpdiscuzOptionsSerialized implements WpDiscuzConstants {
656
  'wc_second_text' => array('datetime' => array(__('second', 'wpdiscuz'), 6)),
657
  'wc_second_text_plural' => array('datetime' => array(__('seconds', 'wpdiscuz'), 6)), // PLURAL
658
  'wc_right_now_text' => __('right now', 'wpdiscuz'),
659
- 'wc_ago_text' => __('ago', 'wpdiscuz'),
660
  'wc_you_must_be_text' => __('You must be', 'wpdiscuz'),
661
  'wc_logged_in_as' => __('You are logged in as', 'wpdiscuz'),
662
  'wc_log_out' => __('Log out', 'wpdiscuz'),
@@ -741,6 +750,7 @@ class WpdiscuzOptionsSerialized implements WpDiscuzConstants {
741
  'disableTips' => $this->disableTips,
742
  'disableProfileURLs' => $this->disableProfileURLs,
743
  'displayRatingOnPost' => $this->displayRatingOnPost,
 
744
  'wc_custom_css' => $this->customCss,
745
  'wc_show_plugin_powerid_by' => $this->showPluginPoweredByLink,
746
  'wc_is_use_po_mo' => $this->isUsePoMo,
@@ -815,6 +825,7 @@ class WpdiscuzOptionsSerialized implements WpDiscuzConstants {
815
  'disableTips' => '0',
816
  'disableProfileURLs' => '0',
817
  'displayRatingOnPost' => array('after'),
 
818
  'wc_custom_css' => '.comments-area{width:auto;}',
819
  'wc_show_plugin_powerid_by' => '0',
820
  'wc_is_use_po_mo' => '0',
@@ -887,6 +898,7 @@ class WpdiscuzOptionsSerialized implements WpDiscuzConstants {
887
  $js_options['wordpressThreadCommentsDepth'] = $this->wordpressThreadCommentsDepth;
888
  $js_options['wordpressIsPaginate'] = $this->wordpressIsPaginate;
889
  $js_options['commentTextMaxLength'] = $this->commentTextMaxLength ? $this->commentTextMaxLength : null;
 
890
  if ($this->storeCommenterData < 0) {
891
  $js_options['storeCommenterData'] = 100000;
892
  } else if ($this->storeCommenterData == 0) {
284
  * Default Value - after
285
  */
286
  public $displayRatingOnPost;
287
+
288
+ /**
289
+ * Type - Checkbox
290
+ * Available Values - Checked/Unchecked
291
+ * Description - Display ratings on none single pages
292
+ * Default Value - Unchecked
293
+ */
294
+ public $ratingCssOnNoneSingular;
295
 
296
  // == RATING == //
297
 
531
  $this->wordpressCommentOrder = get_option('comment_order');
532
  $this->wordpressCommentPerPage = get_option('comments_per_page');
533
  $this->wordpressShowAvatars = get_option('show_avatars');
534
+ $this->wordpressDefaultCommentsPage = get_option('default_comments_page');
535
  $this->initFormRelations();
536
  $this->initGoodbyeCaptchaField();
537
  add_action('init', array(&$this, 'initPhrasesOnLoad'), 2126);
581
  $this->disableTips = isset($options['disableTips']) ? $options['disableTips'] : 0;
582
  $this->disableProfileURLs = isset($options['disableProfileURLs']) ? $options['disableProfileURLs'] : 0;
583
  $this->displayRatingOnPost = isset($options['displayRatingOnPost']) ? $options['displayRatingOnPost'] : array();
584
+ $this->ratingCssOnNoneSingular = isset($options['ratingCssOnNoneSingular']) ? $options['ratingCssOnNoneSingular'] : 0;
585
  $this->customCss = isset($options['wc_custom_css']) ? $options['wc_custom_css'] : '.comments-area{width:auto; margin: 0 auto;}';
586
  $this->showPluginPoweredByLink = isset($options['wc_show_plugin_powerid_by']) ? $options['wc_show_plugin_powerid_by'] : 0;
587
  $this->isUsePoMo = isset($options['wc_is_use_po_mo']) ? $options['wc_is_use_po_mo'] : 0;
665
  'wc_second_text' => array('datetime' => array(__('second', 'wpdiscuz'), 6)),
666
  'wc_second_text_plural' => array('datetime' => array(__('seconds', 'wpdiscuz'), 6)), // PLURAL
667
  'wc_right_now_text' => __('right now', 'wpdiscuz'),
668
+ 'wc_ago_text' => __('ago', 'wpdiscuz'),
669
  'wc_you_must_be_text' => __('You must be', 'wpdiscuz'),
670
  'wc_logged_in_as' => __('You are logged in as', 'wpdiscuz'),
671
  'wc_log_out' => __('Log out', 'wpdiscuz'),
750
  'disableTips' => $this->disableTips,
751
  'disableProfileURLs' => $this->disableProfileURLs,
752
  'displayRatingOnPost' => $this->displayRatingOnPost,
753
+ 'ratingCssOnNoneSingular' => $this->ratingCssOnNoneSingular,
754
  'wc_custom_css' => $this->customCss,
755
  'wc_show_plugin_powerid_by' => $this->showPluginPoweredByLink,
756
  'wc_is_use_po_mo' => $this->isUsePoMo,
825
  'disableTips' => '0',
826
  'disableProfileURLs' => '0',
827
  'displayRatingOnPost' => array('after'),
828
+ 'ratingCssOnNoneSingular' => 0,
829
  'wc_custom_css' => '.comments-area{width:auto;}',
830
  'wc_show_plugin_powerid_by' => '0',
831
  'wc_is_use_po_mo' => '0',
898
  $js_options['wordpressThreadCommentsDepth'] = $this->wordpressThreadCommentsDepth;
899
  $js_options['wordpressIsPaginate'] = $this->wordpressIsPaginate;
900
  $js_options['commentTextMaxLength'] = $this->commentTextMaxLength ? $this->commentTextMaxLength : null;
901
+ $js_options['wordpressIsPaginate'] = $this->wordpressIsPaginate;
902
  if ($this->storeCommenterData < 0) {
903
  $js_options['storeCommenterData'] = 100000;
904
  } else if ($this->storeCommenterData == 0) {
options/options-layouts/settings-show-hide.php CHANGED
@@ -150,7 +150,7 @@ if (!defined('ABSPATH')) {
150
  <td><input type="checkbox" <?php checked($this->optionsSerialized->disableProfileURLs == 1) ?> value="1" name="disableProfileURLs" id="disableProfileURLs" /></td>
151
  </tr>
152
  <tr valign="top">
153
- <th scope="row"><?php _e('Diplay Ratings', 'wpdiscuz'); ?></label></th>
154
  <td>
155
  <input type="checkbox" <?php checked(in_array('before', $this->optionsSerialized->displayRatingOnPost)) ?> value="before" name="displayRatingOnPost[]" id="displayRatingOnPostBefore" />
156
  <label for="displayRatingOnPostBefore"><?php _e('Before Content', 'wpdiscuz'); ?></label><br>
@@ -158,6 +158,10 @@ if (!defined('ABSPATH')) {
158
  <label for="displayRatingOnPostAfter"><?php _e('After Content', 'wpdiscuz'); ?></label>
159
  </td>
160
  </tr>
 
 
 
 
161
  </tbody>
162
  </table>
163
  </div>
150
  <td><input type="checkbox" <?php checked($this->optionsSerialized->disableProfileURLs == 1) ?> value="1" name="disableProfileURLs" id="disableProfileURLs" /></td>
151
  </tr>
152
  <tr valign="top">
153
+ <th scope="row"><?php _e('Display Ratings', 'wpdiscuz'); ?></label></th>
154
  <td>
155
  <input type="checkbox" <?php checked(in_array('before', $this->optionsSerialized->displayRatingOnPost)) ?> value="before" name="displayRatingOnPost[]" id="displayRatingOnPostBefore" />
156
  <label for="displayRatingOnPostBefore"><?php _e('Before Content', 'wpdiscuz'); ?></label><br>
158
  <label for="displayRatingOnPostAfter"><?php _e('After Content', 'wpdiscuz'); ?></label>
159
  </td>
160
  </tr>
161
+ <tr valign="top">
162
+ <th scope="row"><label for="ratingCssOnNoneSingular"><?php _e('Display ratings on none singular pages', 'wpdiscuz'); ?></label></th>
163
+ <td><input type="checkbox" <?php checked($this->optionsSerialized->ratingCssOnNoneSingular == 1) ?> value="1" name="ratingCssOnNoneSingular" id="ratingCssOnNoneSingular" /></td>
164
+ </tr>
165
  </tbody>
166
  </table>
167
  </div>
readme.txt CHANGED
@@ -2,12 +2,12 @@
2
  Contributors: gVectors Team
3
  Tags: comment, comments, ajax comments, custom comment form, custom comment field
4
  Requires at least: 4.4
5
- Tested up to: 4.8
6
- Stable tag: 4.0.15
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
- AJAX powered comments, realtime comments. Designed to extend WordPress native comments. Custom comment forms and fields.
11
 
12
  == Description ==
13
 
@@ -159,14 +159,15 @@ Nothing will be lost! **Comments - wpDiscuz** will show all old comments.
159
 
160
  == Changelog ==
161
 
162
- = 4.0.15 =
163
 
164
- * Now wpDiscuz requires at least WordPress 4.4 version
165
- * Added Option : Send notification to comment author when comment was approved
166
- * Added Phrase : Comment approved notification email subject
167
- * Added Phrase : Comment approved notification email message
168
- * Added Phrase : Top bar subscription submit button
169
- * Fixed Bug : Comment showing only after page refresh
 
170
 
171
 
172
  IMPORTANT:
@@ -176,6 +177,16 @@ IMPORTANT:
176
  - If you use CDN and found some issue please purge it.
177
  - If your server PHP version is lower than 5.4, [please change it to hogher](https://wordpress.org/support/topic/wpdiscuz-4-requires-php-5-4-and-higher/)
178
 
 
 
 
 
 
 
 
 
 
 
179
  = 4.0.14 =
180
 
181
  * Fixed Bug: Use backslash symbol in comment textarea: '\'
2
  Contributors: gVectors Team
3
  Tags: comment, comments, ajax comments, custom comment form, custom comment field
4
  Requires at least: 4.4
5
+ Tested up to: 4.9
6
+ Stable tag: 4.1.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
+ AJAX powered realtime comments. Designed to extend WordPress native comments. Custom comment forms and fields.
11
 
12
  == Description ==
13
 
159
 
160
  == Changelog ==
161
 
162
+ = 4.1.0 =
163
 
164
+ * Speed: v4.1 comes with new acelerated engine, it's twice faster than older versions
165
+ * Added: Lazy load improvement, loads comments once scroll position is on comment box
166
+ * Added: With wpDiscuz v4.1 guest are also allowed to edit own comments
167
+ * Added: Highlights new comments since user last visit.
168
+ * Fixed Bug: Issues with live update function
169
+ * Fixed Bug: Style issue on RTL pages if avatars are disabled
170
+ * Fixed Bug: Lazy load doesn't work if scrollbar at the bottom of page after page loading
171
 
172
 
173
  IMPORTANT:
177
  - If you use CDN and found some issue please purge it.
178
  - If your server PHP version is lower than 5.4, [please change it to hogher](https://wordpress.org/support/topic/wpdiscuz-4-requires-php-5-4-and-higher/)
179
 
180
+ = 4.0.15 =
181
+
182
+ * Now wpDiscuz requires at least WordPress 4.4 version
183
+ * Added Option : Send notification to comment author when comment was approved
184
+ * Added Phrase : Comment approved notification email subject
185
+ * Added Phrase : Comment approved notification email message
186
+ * Added Phrase : Top bar subscription submit button
187
+ * Fixed Bug : Comment showing only after page refresh
188
+
189
+
190
  = 4.0.14 =
191
 
192
  * Fixed Bug: Use backslash symbol in comment textarea: '\'
templates/comment/class.WpdiscuzWalker.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /** COMMENTS WALKER */
4
- class WpdiscuzWalker extends Walker_Comment {
5
 
6
  public $tree_type = 'comment';
7
  public $db_fields = array('parent' => 'comment_parent', 'id' => 'comment_ID');
@@ -23,7 +23,7 @@ class WpdiscuzWalker extends Walker_Comment {
23
  $GLOBALS['comment_depth'] = $depth;
24
  $GLOBALS['comment'] = $comment;
25
  // BEGIN
26
- $current_user = $args['current_user'];
27
  $depth = isset($args['addComment']) ? $args['addComment'] : $depth;
28
  $uniqueId = $comment->comment_ID . '_' . $comment->comment_parent;
29
  $commentContent = $comment->comment_content;
@@ -32,7 +32,7 @@ class WpdiscuzWalker extends Walker_Comment {
32
  if ($this->optionsSerialized->enableImageConversion) {
33
  $commentContent = $this->helper->makeClickable($commentContent);
34
  }
35
-
36
  $commentContent = apply_filters('comment_text', $commentContent, $comment, $args);
37
  $commentReadMoreLimit = $this->optionsSerialized->commentReadMoreLimit;
38
  if (strstr($commentContent, '[/spoiler]')) {
@@ -43,8 +43,15 @@ class WpdiscuzWalker extends Walker_Comment {
43
  $commentContent = $this->helper->getCommentExcerpt($commentContent, $uniqueId);
44
  }
45
  $commentContent .= $comment->comment_approved == 0 ? '<p class="wc_held_for_moderate">' . $this->optionsSerialized->phrases['wc_held_for_moderate'] . '</p>' : '';
 
 
 
 
 
 
 
 
46
 
47
- $hideAvatarStyle = $this->optionsSerialized->wordpressShowAvatars ? '' : 'style = "margin-left : 0;"';
48
  if ($this->optionsSerialized->wordpressIsPaginate && $comment->comment_parent) {
49
  $rootComment = $this->optimizationHelper->getCommentRoot($comment->comment_parent);
50
  }
@@ -57,6 +64,22 @@ class WpdiscuzWalker extends Walker_Comment {
57
  }
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  $commentAuthorUrl = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
61
  $commentAuthorUrl = esc_url($commentAuthorUrl, array('http', 'https'));
62
  $commentAuthorUrl = apply_filters('get_comment_author_url', $commentAuthorUrl, $comment->comment_ID, $comment);
@@ -118,7 +141,9 @@ class WpdiscuzWalker extends Walker_Comment {
118
  $authorName = apply_filters('wpdiscuz_comment_author', $authorName, $comment);
119
  $profileUrl = apply_filters('wpdiscuz_profile_url', $profileUrl, $user);
120
  $authorAvatarField = apply_filters('wpdiscuz_author_avatar_field', $authorAvatarField, $comment, $user, $profileUrl);
121
- $authorAvatar = $this->optionsSerialized->wordpressShowAvatars ? get_avatar($authorAvatarField, 64, '', $authorName) : '';
 
 
122
  $trackOrPingback = $comment->comment_type == 'pingback' || $comment->comment_type == 'trackback' ? true : false;
123
  if ($trackOrPingback) {
124
  $authorAvatar = '<img class="avatar avatar-64 photo" width="64" height="64" src="' . plugins_url(WPDISCUZ_DIR_NAME . '/assets/img/trackback.png') . '" alt="trackback">';
@@ -138,13 +163,13 @@ class WpdiscuzWalker extends Walker_Comment {
138
  }
139
  }
140
 
141
- if (!$this->optionsSerialized->isGuestCanVote && !$current_user->ID) {
142
- $voteClass = ' wc_tooltipster';
143
  $voteTitleText = $this->optionsSerialized->phrases['wc_login_to_vote'];
144
  $voteUp = $voteTitleText;
145
  $voteDown = $voteTitleText;
146
  } else {
147
- $voteClass = ' wc_vote wc_not_clicked wc_tooltipster';
148
  $voteUp = $this->optionsSerialized->phrases['wc_vote_up'];
149
  $voteDown = $this->optionsSerialized->phrases['wc_vote_down'];
150
  }
@@ -183,22 +208,22 @@ class WpdiscuzWalker extends Walker_Comment {
183
  $twitt_content = urlencode($twitt_content);
184
  $twCommentLink = urlencode($commentLink);
185
  $output .= '<span class="share_buttons_box">';
186
- $output .= (in_array('fb', $this->optionsSerialized->shareButtons) && $this->optionsSerialized->facebookAppID) ? '<span class="wc_fb"><i class="fa fa-facebook wpf-cta wc_tooltipster" aria-hidden="true" title=""></i><span>' . $this->optionsSerialized->phrases['wc_share_facebook'] . '</span></span>' : '';
187
- $output .= in_array('twitter', $this->optionsSerialized->shareButtons) ? '<a class="wc_tw" target="_blank" href="https://twitter.com/intent/tweet?text=' . $twitt_content . '&url='.$twCommentLink.'" title=""><i class="fa fa-twitter wpf-cta" aria-hidden="true"></i><span>' . $this->optionsSerialized->phrases['wc_share_twitter'] . '</span></a>' : '';
188
  $output .= in_array('google', $this->optionsSerialized->shareButtons) ? '<a class="wc_go" target="_blank" href="https://plus.google.com/share?url=' . get_permalink($comment->comment_post_ID) . '" title=""><i class="fa fa-google wpf-cta" aria-hidden="true"></i><span>' . $this->optionsSerialized->phrases['wc_share_google'] . '</span></a>' : '';
189
  $output .= in_array('vk', $this->optionsSerialized->shareButtons) ? '<a class="wc_vk" target="_blank" href="http://vk.com/share.php?url=' . get_permalink($comment->comment_post_ID) . '" title=""><i class="fa fa-vk wpf-cta" aria-hidden="true"></i><span>' . $this->optionsSerialized->phrases['wc_share_vk'] . '</span></a>' : '';
190
  $output .= in_array('ok', $this->optionsSerialized->shareButtons) ? '<a class="wc_ok" target="_blank" href="http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1&st._surl=' . get_permalink($comment->comment_post_ID) . '" title=""><i class="fa fa-odnoklassniki wpf-cta" aria-hidden="true"></i><span>' . $this->optionsSerialized->phrases['wc_share_ok'] . '</span></a>' : '';
191
  $output .= '</span>';
192
  }
193
 
194
- $output = apply_filters('wpdiscuz_before_comment_link', $output, $comment, $user, $current_user);
195
 
196
  if (!$this->optionsSerialized->showHideCommentLink) {
197
  $commentLinkImg = '<span class="wc-comment-img-link-wrap"><i class="fa fa-link wc-comment-img-link wpf-cta" aria-hidden="true"/></i><span><input type="text" class="wc-comment-link-input" value="' . $commentLink . '" /></span></span>';
198
  $output .= apply_filters('wpdiscuz_comment_link_img', $commentLinkImg, $comment);
199
  }
200
 
201
- $output = apply_filters('wpdiscuz_after_comment_link', $output, $comment, $user, $current_user);
202
 
203
  $output .= '</div>';
204
  $output .= '<div class="wpdiscuz_clear"></div>';
@@ -208,8 +233,6 @@ class WpdiscuzWalker extends Walker_Comment {
208
  if (isset($args['comment_status']) && is_array($args['comment_status']) && in_array($comment->comment_approved, $args['comment_status'])) {
209
  $output .= '<div class="wc-comment-footer">';
210
  $output .= '<div class="wc-footer-left">';
211
-
212
-
213
  if (!$this->optionsSerialized->votingButtonsShowHide) {
214
  if ($this->optionsSerialized->votingButtonsStyle) {
215
  $votesArr = $this->dbManager->getVotes($comment->comment_ID);
@@ -222,65 +245,64 @@ class WpdiscuzWalker extends Walker_Comment {
222
  }
223
  $output .= '<span class="wc-vote-link wc-up wc-separate ' . $voteClass . '">';
224
  $voteFaUpImg = '<i class="fa fa-thumbs-up fa-flip-horizontal wc-vote-img-up"></i><span>' . $voteUp . '</span>';
225
- $output .= apply_filters('wpdiscuz_vote_up_icon', $voteFaUpImg, $comment, $current_user);
226
  $output .= '</span>';
227
  $output .= '<span class="wc-vote-result wc-vote-result-like' . (($like) ? ' wc-positive' : '') . '">' . $like . '</span>';
228
  $output .= '<span class="wc-vote-result wc-vote-result-dislike' . (($dislike) ? ' wc-negative' : '') . '">' . $dislike . '</span>';
229
  $output .= '<span class="wc-vote-link wc-down wc-separate' . $voteClass . '">';
230
  $voteFaDownImg = '<i class="fa fa-thumbs-down wc-vote-img-down"></i><span>' . $voteDown . '</span>';
231
- $output .= apply_filters('wpdiscuz_vote_down_icon', $voteFaDownImg, $comment, $current_user);
232
  $output .= '</span>';
233
- $output = apply_filters('wpdiscuz_voters', $output, $uniqueId, $comment, $user, $current_user);
234
  } else {
235
- $voteCount = isset($comment->meta_value) ? $comment->meta_value : get_comment_meta($comment->comment_ID, WpdiscuzCore::META_KEY_VOTES, true);
236
- $output = apply_filters('wpdiscuz_voters', $output, $uniqueId, $comment, $user, $current_user);
237
  $output .= '<span class="wc-vote-link wc-up ' . $voteClass . '">';
238
  $voteFaUpImg = '<i class="fa fa-thumbs-up fa-flip-horizontal wc-vote-img-up"></i><span>' . $voteUp . '</span>';
239
- $output .= apply_filters('wpdiscuz_vote_up_icon', $voteFaUpImg, $comment, $current_user);
240
  $output .= '</span>';
241
  $output .= '<span class="wc-vote-result">' . intval($voteCount) . '</span>';
242
  $output .= '<span class="wc-vote-link wc-down ' . $voteClass . '">';
243
  $voteFaDownImg = '<i class="fa fa-thumbs-down wc-vote-img-down"></i><span>' . $voteDown . '</span>';
244
- $output .= apply_filters('wpdiscuz_vote_down_icon', $voteFaDownImg, $comment, $current_user);
245
  $output .= '</span>&nbsp;';
246
  }
247
  }
248
 
249
  if (comments_open($comment->comment_post_ID) && $this->optionsSerialized->wordpressThreadComments) {
250
  if (!$this->optionsSerialized->guestCanComment) {
251
- if (!$this->optionsSerialized->replyButtonMembersShowHide && $current_user->ID) {
252
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
253
- } else if (in_array('administrator', $current_user->roles)) {
254
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
255
  }
256
  } else {
257
  if (!$this->optionsSerialized->replyButtonMembersShowHide && !$this->optionsSerialized->replyButtonGuestsShowHide) {
258
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
259
- } else if (!$this->optionsSerialized->replyButtonMembersShowHide && $current_user->ID) {
260
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
261
- } else if (!$this->optionsSerialized->replyButtonGuestsShowHide && !$current_user->ID) {
262
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
263
- } else if (in_array('administrator', $current_user->roles)) {
264
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
265
  }
266
  }
267
  }
268
 
269
-
270
-
271
  if (current_user_can('edit_comment', $comment->comment_ID)) {
272
  $output .= '<span class="wc_editable_comment wc-cta-button"><i class="fa fa-pencil" aria-hidden="true"></i> ' . $this->optionsSerialized->phrases['wc_edit_text'] . '</span>';
273
  $output .= '<span class="wc_cancel_edit wc-cta-button-x"><i class="fa fa-ban" aria-hidden="true"></i> ' . $this->optionsSerialized->phrases['wc_comment_edit_cancel_button'] . '</span>';
274
  } else {
275
  $isInRange = $this->helper->isContentInRange($commentContent);
276
- $isEditable = $this->optionsSerialized->commentEditableTime == 'unlimit' ? true && $isInRange : $this->helper->isCommentEditable($comment) && $isInRange;
277
- if ($current_user && $current_user->ID && $current_user->ID == $comment->user_id && $isEditable) {
 
278
  $output .= '<span class="wc_editable_comment wc-cta-button"><i class="fa fa-pencil" aria-hidden="true"></i> ' . $this->optionsSerialized->phrases['wc_edit_text'] . '</span>';
279
- $output .= '<span class="wc_cancel_edit"><i class="fa fa-ban" aria-hidden="true"></i> ' . $this->optionsSerialized->phrases['wc_comment_edit_cancel_button'] . '</span>';
280
  }
281
  }
282
 
283
- $output = apply_filters('wpdiscuz_comment_buttons', $output, $comment, $user, $current_user);
284
 
285
  $output .= '</div>';
286
  $output .= '<div class="wc-footer-right">';
1
  <?php
2
 
3
  /** COMMENTS WALKER */
4
+ class WpdiscuzWalker extends Walker_Comment implements WpDiscuzConstants {
5
 
6
  public $tree_type = 'comment';
7
  public $db_fields = array('parent' => 'comment_parent', 'id' => 'comment_ID');
23
  $GLOBALS['comment_depth'] = $depth;
24
  $GLOBALS['comment'] = $comment;
25
  // BEGIN
26
+ $currentUser = $args['current_user'];
27
  $depth = isset($args['addComment']) ? $args['addComment'] : $depth;
28
  $uniqueId = $comment->comment_ID . '_' . $comment->comment_parent;
29
  $commentContent = $comment->comment_content;
32
  if ($this->optionsSerialized->enableImageConversion) {
33
  $commentContent = $this->helper->makeClickable($commentContent);
34
  }
35
+
36
  $commentContent = apply_filters('comment_text', $commentContent, $comment, $args);
37
  $commentReadMoreLimit = $this->optionsSerialized->commentReadMoreLimit;
38
  if (strstr($commentContent, '[/spoiler]')) {
43
  $commentContent = $this->helper->getCommentExcerpt($commentContent, $uniqueId);
44
  }
45
  $commentContent .= $comment->comment_approved == 0 ? '<p class="wc_held_for_moderate">' . $this->optionsSerialized->phrases['wc_held_for_moderate'] . '</p>' : '';
46
+ $hideAvatarStyle = '';
47
+ if (!$this->optionsSerialized->wordpressShowAvatars) {
48
+ if (is_rtl()) {
49
+ $hideAvatarStyle = 'style = "margin-right : 0;"';
50
+ } else {
51
+ $hideAvatarStyle = 'style = "margin-left : 0;"';
52
+ }
53
+ }
54
 
 
55
  if ($this->optionsSerialized->wordpressIsPaginate && $comment->comment_parent) {
56
  $rootComment = $this->optimizationHelper->getCommentRoot($comment->comment_parent);
57
  }
64
  }
65
  }
66
 
67
+ if (!$this->optionsSerialized->wordpressIsPaginate && isset($args[self::COOKIE_LAST_VISIT])) {
68
+ $blogId = WpdiscuzCore::$CURRENT_BLOG_ID;
69
+ $lastVisit = json_decode(stripslashes($args[self::COOKIE_LAST_VISIT]), true);
70
+ $lastVisitForPost = isset($lastVisit[$blogId][$comment->comment_post_ID]) ? $lastVisit[$blogId][$comment->comment_post_ID] : 0;
71
+ if (isset($args['comment_author_email'])) {
72
+ $storedCookieEmail = $args['comment_author_email'];
73
+ } else {
74
+ $storedCookieEmail = isset($_COOKIE['comment_author_email_' . COOKIEHASH]) ? $_COOKIE['comment_author_email_' . COOKIEHASH] : '';
75
+ }
76
+
77
+ $commentTime = strtotime($comment->comment_date);
78
+ if ($lastVisitForPost && $commentTime > $lastVisitForPost && $storedCookieEmail != $comment->comment_author_email) {
79
+ $commentWrapperClass = ' wc-new-loaded-comment ';
80
+ }
81
+ }
82
+
83
  $commentAuthorUrl = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
84
  $commentAuthorUrl = esc_url($commentAuthorUrl, array('http', 'https'));
85
  $commentAuthorUrl = apply_filters('get_comment_author_url', $commentAuthorUrl, $comment->comment_ID, $comment);
141
  $authorName = apply_filters('wpdiscuz_comment_author', $authorName, $comment);
142
  $profileUrl = apply_filters('wpdiscuz_profile_url', $profileUrl, $user);
143
  $authorAvatarField = apply_filters('wpdiscuz_author_avatar_field', $authorAvatarField, $comment, $user, $profileUrl);
144
+ $gravatarSize = 64;
145
+ $gravatarArgs = array('wpdiscuz_gravatar_field' => $authorAvatarField, 'wpdiscuz_gravatar_size' => $gravatarSize);
146
+ $authorAvatar = $this->optionsSerialized->wordpressShowAvatars ? get_avatar($authorAvatarField, $gravatarSize, '', $authorName, $gravatarArgs) : '';
147
  $trackOrPingback = $comment->comment_type == 'pingback' || $comment->comment_type == 'trackback' ? true : false;
148
  if ($trackOrPingback) {
149
  $authorAvatar = '<img class="avatar avatar-64 photo" width="64" height="64" src="' . plugins_url(WPDISCUZ_DIR_NAME . '/assets/img/trackback.png') . '" alt="trackback">';
163
  }
164
  }
165
 
166
+ if (!$this->optionsSerialized->isGuestCanVote && !$currentUser->ID) {
167
+ $voteClass = '';
168
  $voteTitleText = $this->optionsSerialized->phrases['wc_login_to_vote'];
169
  $voteUp = $voteTitleText;
170
  $voteDown = $voteTitleText;
171
  } else {
172
+ $voteClass = ' wc_vote wc_not_clicked';
173
  $voteUp = $this->optionsSerialized->phrases['wc_vote_up'];
174
  $voteDown = $this->optionsSerialized->phrases['wc_vote_down'];
175
  }
208
  $twitt_content = urlencode($twitt_content);
209
  $twCommentLink = urlencode($commentLink);
210
  $output .= '<span class="share_buttons_box">';
211
+ $output .= (in_array('fb', $this->optionsSerialized->shareButtons) && $this->optionsSerialized->facebookAppID) ? '<span class="wc_fb"><i class="fa fa-facebook wpf-cta" aria-hidden="true" title=""></i><span>' . $this->optionsSerialized->phrases['wc_share_facebook'] . '</span></span>' : '';
212
+ $output .= in_array('twitter', $this->optionsSerialized->shareButtons) ? '<a class="wc_tw" target="_blank" href="https://twitter.com/intent/tweet?text=' . $twitt_content . '&url=' . $twCommentLink . '" title=""><i class="fa fa-twitter wpf-cta" aria-hidden="true"></i><span>' . $this->optionsSerialized->phrases['wc_share_twitter'] . '</span></a>' : '';
213
  $output .= in_array('google', $this->optionsSerialized->shareButtons) ? '<a class="wc_go" target="_blank" href="https://plus.google.com/share?url=' . get_permalink($comment->comment_post_ID) . '" title=""><i class="fa fa-google wpf-cta" aria-hidden="true"></i><span>' . $this->optionsSerialized->phrases['wc_share_google'] . '</span></a>' : '';
214
  $output .= in_array('vk', $this->optionsSerialized->shareButtons) ? '<a class="wc_vk" target="_blank" href="http://vk.com/share.php?url=' . get_permalink($comment->comment_post_ID) . '" title=""><i class="fa fa-vk wpf-cta" aria-hidden="true"></i><span>' . $this->optionsSerialized->phrases['wc_share_vk'] . '</span></a>' : '';
215
  $output .= in_array('ok', $this->optionsSerialized->shareButtons) ? '<a class="wc_ok" target="_blank" href="http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1&st._surl=' . get_permalink($comment->comment_post_ID) . '" title=""><i class="fa fa-odnoklassniki wpf-cta" aria-hidden="true"></i><span>' . $this->optionsSerialized->phrases['wc_share_ok'] . '</span></a>' : '';
216
  $output .= '</span>';
217
  }
218
 
219
+ $output = apply_filters('wpdiscuz_before_comment_link', $output, $comment, $user, $currentUser);
220
 
221
  if (!$this->optionsSerialized->showHideCommentLink) {
222
  $commentLinkImg = '<span class="wc-comment-img-link-wrap"><i class="fa fa-link wc-comment-img-link wpf-cta" aria-hidden="true"/></i><span><input type="text" class="wc-comment-link-input" value="' . $commentLink . '" /></span></span>';
223
  $output .= apply_filters('wpdiscuz_comment_link_img', $commentLinkImg, $comment);
224
  }
225
 
226
+ $output = apply_filters('wpdiscuz_after_comment_link', $output, $comment, $user, $currentUser);
227
 
228
  $output .= '</div>';
229
  $output .= '<div class="wpdiscuz_clear"></div>';
233
  if (isset($args['comment_status']) && is_array($args['comment_status']) && in_array($comment->comment_approved, $args['comment_status'])) {
234
  $output .= '<div class="wc-comment-footer">';
235
  $output .= '<div class="wc-footer-left">';
 
 
236
  if (!$this->optionsSerialized->votingButtonsShowHide) {
237
  if ($this->optionsSerialized->votingButtonsStyle) {
238
  $votesArr = $this->dbManager->getVotes($comment->comment_ID);
245
  }
246
  $output .= '<span class="wc-vote-link wc-up wc-separate ' . $voteClass . '">';
247
  $voteFaUpImg = '<i class="fa fa-thumbs-up fa-flip-horizontal wc-vote-img-up"></i><span>' . $voteUp . '</span>';
248
+ $output .= apply_filters('wpdiscuz_vote_up_icon', $voteFaUpImg, $comment, $currentUser);
249
  $output .= '</span>';
250
  $output .= '<span class="wc-vote-result wc-vote-result-like' . (($like) ? ' wc-positive' : '') . '">' . $like . '</span>';
251
  $output .= '<span class="wc-vote-result wc-vote-result-dislike' . (($dislike) ? ' wc-negative' : '') . '">' . $dislike . '</span>';
252
  $output .= '<span class="wc-vote-link wc-down wc-separate' . $voteClass . '">';
253
  $voteFaDownImg = '<i class="fa fa-thumbs-down wc-vote-img-down"></i><span>' . $voteDown . '</span>';
254
+ $output .= apply_filters('wpdiscuz_vote_down_icon', $voteFaDownImg, $comment, $currentUser);
255
  $output .= '</span>';
256
+ $output = apply_filters('wpdiscuz_voters', $output, $uniqueId, $comment, $user, $currentUser);
257
  } else {
258
+ $voteCount = get_comment_meta($comment->comment_ID, WpdiscuzCore::META_KEY_VOTES, true);
259
+ $output = apply_filters('wpdiscuz_voters', $output, $uniqueId, $comment, $user, $currentUser);
260
  $output .= '<span class="wc-vote-link wc-up ' . $voteClass . '">';
261
  $voteFaUpImg = '<i class="fa fa-thumbs-up fa-flip-horizontal wc-vote-img-up"></i><span>' . $voteUp . '</span>';
262
+ $output .= apply_filters('wpdiscuz_vote_up_icon', $voteFaUpImg, $comment, $currentUser);
263
  $output .= '</span>';
264
  $output .= '<span class="wc-vote-result">' . intval($voteCount) . '</span>';
265
  $output .= '<span class="wc-vote-link wc-down ' . $voteClass . '">';
266
  $voteFaDownImg = '<i class="fa fa-thumbs-down wc-vote-img-down"></i><span>' . $voteDown . '</span>';
267
+ $output .= apply_filters('wpdiscuz_vote_down_icon', $voteFaDownImg, $comment, $currentUser);
268
  $output .= '</span>&nbsp;';
269
  }
270
  }
271
 
272
  if (comments_open($comment->comment_post_ID) && $this->optionsSerialized->wordpressThreadComments) {
273
  if (!$this->optionsSerialized->guestCanComment) {
274
+ if (!$this->optionsSerialized->replyButtonMembersShowHide && $currentUser->ID) {
275
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
276
+ } else if (in_array('administrator', $currentUser->roles)) {
277
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
278
  }
279
  } else {
280
  if (!$this->optionsSerialized->replyButtonMembersShowHide && !$this->optionsSerialized->replyButtonGuestsShowHide) {
281
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
282
+ } else if (!$this->optionsSerialized->replyButtonMembersShowHide && $currentUser->ID) {
283
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
284
+ } else if (!$this->optionsSerialized->replyButtonGuestsShowHide && !$currentUser->ID) {
285
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
286
+ } else if (in_array('administrator', $currentUser->roles)) {
287
  $output .= '<span class="wc-reply-button wc-cta-button" title="' . $replyText . '">' . '<i class="fa fa-reply" aria-hidden="true"></i> ' . $replyText . '</span>';
288
  }
289
  }
290
  }
291
 
 
 
292
  if (current_user_can('edit_comment', $comment->comment_ID)) {
293
  $output .= '<span class="wc_editable_comment wc-cta-button"><i class="fa fa-pencil" aria-hidden="true"></i> ' . $this->optionsSerialized->phrases['wc_edit_text'] . '</span>';
294
  $output .= '<span class="wc_cancel_edit wc-cta-button-x"><i class="fa fa-ban" aria-hidden="true"></i> ' . $this->optionsSerialized->phrases['wc_comment_edit_cancel_button'] . '</span>';
295
  } else {
296
  $isInRange = $this->helper->isContentInRange($commentContent);
297
+ $isEditable = $this->optionsSerialized->commentEditableTime == 'unlimit' ? $isInRange : $this->helper->isCommentEditable($comment) && $isInRange;
298
+
299
+ if ($isEditable && $this->helper->canUserEditComment($comment, $currentUser, $args)) {
300
  $output .= '<span class="wc_editable_comment wc-cta-button"><i class="fa fa-pencil" aria-hidden="true"></i> ' . $this->optionsSerialized->phrases['wc_edit_text'] . '</span>';
301
+ $output .= '<span class="wc_cancel_edit wc-cta-button-x"><i class="fa fa-ban" aria-hidden="true"></i> ' . $this->optionsSerialized->phrases['wc_comment_edit_cancel_button'] . '</span>';
302
  }
303
  }
304
 
305
+ $output = apply_filters('wpdiscuz_comment_buttons', $output, $comment, $user, $currentUser);
306
 
307
  $output .= '</div>';
308
  $output .= '<div class="wc-footer-right">';
templates/comment/comment-form.php CHANGED
@@ -22,19 +22,16 @@ if (!function_exists('wpdiscuz_close_divs')) {
22
 
23
  }
24
 
25
- $current_user = wp_get_current_user();
26
- do_action('wpdiscuz_before_load', $post, $current_user, null);
27
  if (!post_password_required($post->ID)) {
28
- if (!$wpdiscuz->optionsSerialized->votingButtonsShowHide) {
29
- $wpdiscuz->dbManager->checkVoteData($post->ID);
30
- }
31
- $commentsCount = get_comments_number();
32
  $header_text = '<span class="wc_header_text_count">' . $commentsCount . '</span> ';
33
  $header_text .= ($commentsCount > 1) ? $wpdiscuz->optionsSerialized->phrases['wc_header_text_plural'] : $wpdiscuz->optionsSerialized->phrases['wc_header_text'];
34
  $header_text .= ' ' . $wpdiscuz->optionsSerialized->phrases['wc_header_on_text'];
35
  $header_text .= ' "' . get_the_title($post) . '"';
36
 
37
- $wpCommClasses = $current_user && $current_user->ID ? 'wpdiscuz_auth' : 'wpdiscuz_unauth';
38
  $wpCommClasses .= $wpdiscuz->optionsSerialized->wordpressShowAvatars ? '' : ' wpdiscuz_no_avatar';
39
 
40
  $ob_stat = ini_get('output_buffering');
@@ -42,7 +39,7 @@ if (!post_password_required($post->ID)) {
42
  $wc_ob_allowed = true;
43
  ob_start();
44
  do_action('comment_form_top');
45
- do_action('wpdiscuz_comment_form_top', $post, $current_user, $commentsCount);
46
  $wc_comment_form_top_content = ob_get_contents();
47
  ob_get_clean();
48
  $wc_comment_form_top_content = wpdiscuz_close_divs($wc_comment_form_top_content);
@@ -76,8 +73,8 @@ if (!post_password_required($post->ID)) {
76
  $subscriptionMsg = __('Subscription not successed', 'wpdiscuz');
77
  } else {
78
  if (isset($_GET['subscriptionID']) && ($subscriptionID = trim($_GET['subscriptionID']))) {
79
- $noNeedMemberConfirm = ($current_user->ID && $wpdiscuz->optionsSerialized->disableMemberConfirm);
80
- $noNeedGuestsConfirm = (!$current_user->ID && $wpdiscuz->optionsSerialized->disableGuestsConfirm && $wpdiscuz->dbManager->hasConfirmedSubscriptionByID($subscriptionID));
81
  if ($noNeedMemberConfirm || $noNeedGuestsConfirm) {
82
  $subscriptionMsg = $wpdiscuz->optionsSerialized->phrases['wc_subscribe_message'];
83
  } else {
@@ -107,15 +104,15 @@ if (!post_password_required($post->ID)) {
107
  <h3 id="wc-comment-header"><?php echo $form->getHeaderText(); ?></h3>
108
  <?php
109
  if ($wpdiscuz->optionsSerialized->showHideLoggedInUsername) {
110
- if ($current_user && $current_user->ID) {
111
- $user_url = get_author_posts_url($current_user->ID);
112
  ?>
113
  <div id="wc_show_hide_loggedin_username">
114
  <span class="wc_show_hide_loggedin_username">
115
  <?php
116
  $logout = wp_loginout(get_permalink(), false);
117
  $logout = preg_replace('!>([^<]+)!is', '>' . $wpdiscuz->optionsSerialized->phrases['wc_log_out'], $logout);
118
- echo $wpdiscuz->optionsSerialized->phrases['wc_logged_in_as'] . ' <a href="' . $user_url . '">' . $wpdiscuz->helper->getCurrentUserDisplayName($current_user) . '</a> | ' . $logout;
119
  ?>
120
  </span>
121
  </div>
@@ -139,20 +136,20 @@ if (!post_password_required($post->ID)) {
139
  echo $wc_comment_form_top_content;
140
  } else {
141
  do_action('comment_form_top');
142
- do_action('wpdiscuz_comment_form_top', $post, $current_user, $commentsCount);
143
  }
144
  ?>
145
  </div>
146
  <?php
147
  $isPostmaticActive = !class_exists('Prompt_Comment_Form_Handling') || (class_exists('Prompt_Comment_Form_Handling') && !$wpdiscuz->optionsSerialized->usePostmaticForCommentNotification);
148
- if ($form->isShowSubscriptionBar() && $isPostmaticActive) {
149
- $subscriptionData = $wpdiscuz->dbManager->hasSubscription($post->ID, $current_user->user_email);
150
  $subscriptionType = null;
151
- if ($subscriptionData) {
152
- $isConfirmed = $subscriptionData['confirm'];
153
- $subscriptionType = $subscriptionData['type'];
154
  if ($subscriptionType == WpdiscuzCore::SUBSCRIPTION_POST || $subscriptionType == WpdiscuzCore::SUBSCRIPTION_ALL_COMMENT) {
155
- $unsubscribeLink = $wpdiscuz->dbManager->unsubscribeLink($post->ID, $current_user->user_email);
156
  }
157
  }
158
  ?>
@@ -162,7 +159,7 @@ if (!post_password_required($post->ID)) {
162
  ?>
163
  <form action="<?php echo admin_url('admin-ajax.php') . '?action=addSubscription'; ?>" method="post" id="wpdiscuz-subscribe-form">
164
  <div class="wpdiscuz-subscribe-form-intro"><?php echo $wpdiscuz->optionsSerialized->phrases['wc_notify_of']; ?> </div>
165
- <div class="wpdiscuz-subscribe-form-option" style="width:<?php echo (!$current_user->ID) ? '40%' : '65%'; ?>;">
166
  <select class="wpdiscuz_select" name="wpdiscuzSubscriptionType" >
167
  <?php if ($wpdiscuz->optionsSerialized->subscriptionType != 3) { ?>
168
  <option value="<?php echo WpdiscuzCore::SUBSCRIPTION_POST; ?>"><?php echo $wpdiscuz->optionsSerialized->phrases['wc_notify_on_new_comment']; ?></option>
@@ -172,7 +169,7 @@ if (!post_password_required($post->ID)) {
172
  <?php } ?>
173
  </select>
174
  </div>
175
- <?php if (!$current_user->ID) { ?>
176
  <div class="wpdiscuz-item wpdiscuz-subscribe-form-email">
177
  <input class="email" type="email" name="wpdiscuzSubscriptionEmail" required="required" value="" placeholder="<?php echo $wpdiscuz->optionsSerialized->phrases['wc_email_text']; ?>"/>
178
  </div>
@@ -198,9 +195,9 @@ if (!post_password_required($post->ID)) {
198
  </div>
199
  <?php
200
  }
201
- $wpdiscuz->wpdiscuzForm->renderFrontForm($commentsCount, $current_user);
202
  do_action('comment_form_after');
203
- do_action('wpdiscuz_comment_form_after', $post, $current_user, $commentsCount);
204
  } else {
205
  if ($commentsCount > 0) {
206
  $wpdiscuz->helper->superSocializerFix();
@@ -211,11 +208,11 @@ if (!post_password_required($post->ID)) {
211
  <?php } ?>
212
  <?php
213
  do_action('comment_form_closed');
214
- do_action('wpdiscuz_comment_form_closed', $post, $current_user, $commentsCount);
215
  ?>
216
  <div id="wpcomm" class="<?php echo $wpCommClasses; ?>" style="border:none;">
217
  <?php } ?>
218
- <?php do_action('wpdiscuz_before_comments', $post, $current_user, $commentsCount); ?>
219
 
220
  <?php if ($commentsCount && $wpdiscuz->optionsSerialized->showSortingButtons && !$wpdiscuz->optionsSerialized->wordpressIsPaginate) { ?>
221
  <div class="wpdiscuz-front-actions">
@@ -239,16 +236,21 @@ if (!post_password_required($post->ID)) {
239
  <?php } ?>
240
  <div id="wcThreadWrapper" class="wc-thread-wrapper">
241
  <?php
242
- $args = array();
243
  $showLoadeMore = 1;
244
  $lastParentId = filter_input(INPUT_GET, 'wpdParentID', FILTER_SANITIZE_NUMBER_INT);
245
  if ($lastParentId) {
246
- $args['last_parent_id'] = $lastParentId--;
247
  }
248
 
249
  if ($wpdiscuz->optionsSerialized->showSortingButtons && $wpdiscuz->optionsSerialized->mostVotedByDefault && !$wpdiscuz->optionsSerialized->votingButtonsShowHide) {
250
  $args['orderby'] = 'by_vote';
251
  }
 
 
 
 
 
252
  $commentData = $wpdiscuz->getWPComments($args);
253
  echo $commentData['comment_list'];
254
  ?>
@@ -258,7 +260,7 @@ if (!post_password_required($post->ID)) {
258
  $loadMoreButtonText = ($wpdiscuz->optionsSerialized->commentListLoadType == 1) ? $wpdiscuz->optionsSerialized->phrases['wc_load_rest_comments_submit_text'] : $wpdiscuz->optionsSerialized->phrases['wc_load_more_submit_text'];
259
  ?>
260
  <div class="wc-load-more-submit-wrap">
261
- <a class="wc-load-more-link" href="<?php echo $wpdiscuz->helper->loadMoreLink($commentData['last_parent_id'],$post->ID);?>">
262
  <button name="submit" class="wc-load-more-submit wc-loaded button">
263
  <?php echo $loadMoreButtonText; ?>
264
  </button>
@@ -266,14 +268,14 @@ if (!post_password_required($post->ID)) {
266
  </div>
267
  <input id="wpdiscuzHasMoreComments" type="hidden" value="<?php echo $commentData['is_show_load_more']; ?>" />
268
  <?php
269
- } else if($wpdiscuz->optionsSerialized->wordpressIsPaginate){
270
  paginate_comments_links();
271
  }
272
  ?>
273
  </div>
274
  </div>
275
  <div class="wpdiscuz_clear"></div>
276
- <?php do_action('wpdiscuz_after_comments', $post, $current_user, $commentsCount); ?>
277
  <?php if ($commentsCount) { ?>
278
  <?php if ($wpdiscuz->optionsSerialized->showPluginPoweredByLink) { ?>
279
  <div class="by-wpdiscuz">
@@ -286,6 +288,6 @@ if (!post_password_required($post->ID)) {
286
  <?php } ?>
287
  </div>
288
  </div>
289
- <div class="wpdiscuz-loading-bar <?php echo ($current_user->ID) ? 'wpdiscuz-loading-bar-auth' : 'wpdiscuz-loading-bar-unauth'; ?>"><img class="wpdiscuz-loading-bar-img" alt="<?php _e('wpDiscuz', 'wpdiscuz'); ?>" src="<?php echo plugins_url(WPDISCUZ_DIR_NAME . '/assets/img/loading.gif'); ?>" width="32" height="25" /></div>
290
  <?php
291
  }
22
 
23
  }
24
 
25
+ $currentUser = $wpdiscuz->helper->getCurrentUser();
26
+ do_action('wpdiscuz_before_load', $post, $currentUser, null);
27
  if (!post_password_required($post->ID)) {
28
+ $commentsCount = get_comments_number();
 
 
 
29
  $header_text = '<span class="wc_header_text_count">' . $commentsCount . '</span> ';
30
  $header_text .= ($commentsCount > 1) ? $wpdiscuz->optionsSerialized->phrases['wc_header_text_plural'] : $wpdiscuz->optionsSerialized->phrases['wc_header_text'];
31
  $header_text .= ' ' . $wpdiscuz->optionsSerialized->phrases['wc_header_on_text'];
32
  $header_text .= ' "' . get_the_title($post) . '"';
33
 
34
+ $wpCommClasses = $currentUser && $currentUser->ID ? 'wpdiscuz_auth' : 'wpdiscuz_unauth';
35
  $wpCommClasses .= $wpdiscuz->optionsSerialized->wordpressShowAvatars ? '' : ' wpdiscuz_no_avatar';
36
 
37
  $ob_stat = ini_get('output_buffering');
39
  $wc_ob_allowed = true;
40
  ob_start();
41
  do_action('comment_form_top');
42
+ do_action('wpdiscuz_comment_form_top', $post, $currentUser, $commentsCount);
43
  $wc_comment_form_top_content = ob_get_contents();
44
  ob_get_clean();
45
  $wc_comment_form_top_content = wpdiscuz_close_divs($wc_comment_form_top_content);
73
  $subscriptionMsg = __('Subscription not successed', 'wpdiscuz');
74
  } else {
75
  if (isset($_GET['subscriptionID']) && ($subscriptionID = trim($_GET['subscriptionID']))) {
76
+ $noNeedMemberConfirm = ($currentUser->ID && $wpdiscuz->optionsSerialized->disableMemberConfirm);
77
+ $noNeedGuestsConfirm = (!$currentUser->ID && $wpdiscuz->optionsSerialized->disableGuestsConfirm && $wpdiscuz->dbManager->hasConfirmedSubscriptionByID($subscriptionID));
78
  if ($noNeedMemberConfirm || $noNeedGuestsConfirm) {
79
  $subscriptionMsg = $wpdiscuz->optionsSerialized->phrases['wc_subscribe_message'];
80
  } else {
104
  <h3 id="wc-comment-header"><?php echo $form->getHeaderText(); ?></h3>
105
  <?php
106
  if ($wpdiscuz->optionsSerialized->showHideLoggedInUsername) {
107
+ if ($currentUser && $currentUser->ID) {
108
+ $user_url = get_author_posts_url($currentUser->ID);
109
  ?>
110
  <div id="wc_show_hide_loggedin_username">
111
  <span class="wc_show_hide_loggedin_username">
112
  <?php
113
  $logout = wp_loginout(get_permalink(), false);
114
  $logout = preg_replace('!>([^<]+)!is', '>' . $wpdiscuz->optionsSerialized->phrases['wc_log_out'], $logout);
115
+ echo $wpdiscuz->optionsSerialized->phrases['wc_logged_in_as'] . ' <a href="' . $user_url . '">' . $wpdiscuz->helper->getCurrentUserDisplayName($currentUser) . '</a> | ' . $logout;
116
  ?>
117
  </span>
118
  </div>
136
  echo $wc_comment_form_top_content;
137
  } else {
138
  do_action('comment_form_top');
139
+ do_action('wpdiscuz_comment_form_top', $post, $currentUser, $commentsCount);
140
  }
141
  ?>
142
  </div>
143
  <?php
144
  $isPostmaticActive = !class_exists('Prompt_Comment_Form_Handling') || (class_exists('Prompt_Comment_Form_Handling') && !$wpdiscuz->optionsSerialized->usePostmaticForCommentNotification);
145
+ if ($form->isShowSubscriptionBar() && $isPostmaticActive) {
146
+ $wpdiscuz->userSubscriptionData = $wpdiscuz->dbManager->hasSubscription($post->ID, $currentUser->user_email);
147
  $subscriptionType = null;
148
+ if ($wpdiscuz->subscriptionData) {
149
+ $isConfirmed = $wpdiscuz->subscriptionData['confirm'];
150
+ $subscriptionType = $wpdiscuz->subscriptionData['type'];
151
  if ($subscriptionType == WpdiscuzCore::SUBSCRIPTION_POST || $subscriptionType == WpdiscuzCore::SUBSCRIPTION_ALL_COMMENT) {
152
+ $unsubscribeLink = $wpdiscuz->dbManager->unsubscribeLink($post->ID, $currentUser->user_email);
153
  }
154
  }
155
  ?>
159
  ?>
160
  <form action="<?php echo admin_url('admin-ajax.php') . '?action=addSubscription'; ?>" method="post" id="wpdiscuz-subscribe-form">
161
  <div class="wpdiscuz-subscribe-form-intro"><?php echo $wpdiscuz->optionsSerialized->phrases['wc_notify_of']; ?> </div>
162
+ <div class="wpdiscuz-subscribe-form-option" style="width:<?php echo (!$currentUser->ID) ? '40%' : '65%'; ?>;">
163
  <select class="wpdiscuz_select" name="wpdiscuzSubscriptionType" >
164
  <?php if ($wpdiscuz->optionsSerialized->subscriptionType != 3) { ?>
165
  <option value="<?php echo WpdiscuzCore::SUBSCRIPTION_POST; ?>"><?php echo $wpdiscuz->optionsSerialized->phrases['wc_notify_on_new_comment']; ?></option>
169
  <?php } ?>
170
  </select>
171
  </div>
172
+ <?php if (!$currentUser->ID) { ?>
173
  <div class="wpdiscuz-item wpdiscuz-subscribe-form-email">
174
  <input class="email" type="email" name="wpdiscuzSubscriptionEmail" required="required" value="" placeholder="<?php echo $wpdiscuz->optionsSerialized->phrases['wc_email_text']; ?>"/>
175
  </div>
195
  </div>
196
  <?php
197
  }
198
+ $wpdiscuz->wpdiscuzForm->renderFrontForm($commentsCount, $currentUser);
199
  do_action('comment_form_after');
200
+ do_action('wpdiscuz_comment_form_after', $post, $currentUser, $commentsCount);
201
  } else {
202
  if ($commentsCount > 0) {
203
  $wpdiscuz->helper->superSocializerFix();
208
  <?php } ?>
209
  <?php
210
  do_action('comment_form_closed');
211
+ do_action('wpdiscuz_comment_form_closed', $post, $currentUser, $commentsCount);
212
  ?>
213
  <div id="wpcomm" class="<?php echo $wpCommClasses; ?>" style="border:none;">
214
  <?php } ?>
215
+ <?php do_action('wpdiscuz_before_comments', $post, $currentUser, $commentsCount); ?>
216
 
217
  <?php if ($commentsCount && $wpdiscuz->optionsSerialized->showSortingButtons && !$wpdiscuz->optionsSerialized->wordpressIsPaginate) { ?>
218
  <div class="wpdiscuz-front-actions">
236
  <?php } ?>
237
  <div id="wcThreadWrapper" class="wc-thread-wrapper">
238
  <?php
239
+ $args = array('first_load' => 1);
240
  $showLoadeMore = 1;
241
  $lastParentId = filter_input(INPUT_GET, 'wpdParentID', FILTER_SANITIZE_NUMBER_INT);
242
  if ($lastParentId) {
243
+ $args['last_parent_id'] = $lastParentId--;
244
  }
245
 
246
  if ($wpdiscuz->optionsSerialized->showSortingButtons && $wpdiscuz->optionsSerialized->mostVotedByDefault && !$wpdiscuz->optionsSerialized->votingButtonsShowHide) {
247
  $args['orderby'] = 'by_vote';
248
  }
249
+
250
+ if (isset($_COOKIE[WpDiscuzCore::COOKIE_LAST_VISIT])) {
251
+ $args[WpDiscuzCore::COOKIE_LAST_VISIT] = $_COOKIE[WpDiscuzCore::COOKIE_LAST_VISIT];
252
+ }
253
+
254
  $commentData = $wpdiscuz->getWPComments($args);
255
  echo $commentData['comment_list'];
256
  ?>
260
  $loadMoreButtonText = ($wpdiscuz->optionsSerialized->commentListLoadType == 1) ? $wpdiscuz->optionsSerialized->phrases['wc_load_rest_comments_submit_text'] : $wpdiscuz->optionsSerialized->phrases['wc_load_more_submit_text'];
261
  ?>
262
  <div class="wc-load-more-submit-wrap">
263
+ <a class="wc-load-more-link" href="<?php echo $wpdiscuz->helper->loadMoreLink($commentData['last_parent_id'], $post->ID); ?>">
264
  <button name="submit" class="wc-load-more-submit wc-loaded button">
265
  <?php echo $loadMoreButtonText; ?>
266
  </button>
268
  </div>
269
  <input id="wpdiscuzHasMoreComments" type="hidden" value="<?php echo $commentData['is_show_load_more']; ?>" />
270
  <?php
271
+ } else if ($wpdiscuz->optionsSerialized->wordpressIsPaginate) {
272
  paginate_comments_links();
273
  }
274
  ?>
275
  </div>
276
  </div>
277
  <div class="wpdiscuz_clear"></div>
278
+ <?php do_action('wpdiscuz_after_comments', $post, $currentUser, $commentsCount); ?>
279
  <?php if ($commentsCount) { ?>
280
  <?php if ($wpdiscuz->optionsSerialized->showPluginPoweredByLink) { ?>
281
  <div class="by-wpdiscuz">
288
  <?php } ?>
289
  </div>
290
  </div>
291
+ <div class="wpdiscuz-loading-bar <?php echo ($currentUser->ID) ? 'wpdiscuz-loading-bar-auth' : 'wpdiscuz-loading-bar-unauth'; ?>"><img class="wpdiscuz-loading-bar-img" alt="<?php _e('wpDiscuz', 'wpdiscuz'); ?>" src="<?php echo plugins_url(WPDISCUZ_DIR_NAME . '/assets/img/loading.gif'); ?>" width="32" height="25" /></div>
292
  <?php
293
  }
utils/class.WpdiscuzEmailHelper.php CHANGED
@@ -1,5 +1,9 @@
1
  <?php
2
 
 
 
 
 
3
  class WpdiscuzEmailHelper {
4
 
5
  private $optionsSerialized;
@@ -12,21 +16,21 @@ class WpdiscuzEmailHelper {
12
 
13
  public function addSubscription() {
14
  global $wp_rewrite;
15
- $current_user = wp_get_current_user();
16
  $subscribeFormNonce = filter_input(INPUT_POST, 'wpdiscuz_subscribe_form_nonce');
17
  $httpReferer = filter_input(INPUT_POST, '_wp_http_referer');
18
  $subscriptionType = filter_input(INPUT_POST, 'wpdiscuzSubscriptionType');
19
  $postId = filter_input(INPUT_POST, 'wpdiscuzSubscriptionPostId');
20
- if ($current_user && $current_user->ID) {
21
- $email = $current_user->user_email;
22
  } else {
23
  $email = filter_input(INPUT_POST, 'wpdiscuzSubscriptionEmail');
24
  }
25
 
26
  $success = 0;
27
  if (wp_verify_nonce($subscribeFormNonce, 'wpdiscuz_subscribe_form_nonce_action') && $email && filter_var($email, FILTER_VALIDATE_EMAIL) !== false && in_array($subscriptionType, array(WpdiscuzCore::SUBSCRIPTION_POST, WpdiscuzCore::SUBSCRIPTION_ALL_COMMENT)) && $postId) {
28
- $noNeedMemberConfirm = ($current_user->ID && $this->optionsSerialized->disableMemberConfirm);
29
- $noNeedGuestsConfirm = (!$current_user->ID && $this->optionsSerialized->disableGuestsConfirm && $this->dbManager->hasConfirmedSubscription($email));
30
  if ($noNeedMemberConfirm || $noNeedGuestsConfirm) {
31
  $confirmData = $this->dbManager->addEmailNotification($postId, $postId, $email, $subscriptionType, 1);
32
  if ($confirmData) {
@@ -106,9 +110,9 @@ class WpdiscuzEmailHelper {
106
  $comment_id = isset($_POST['comment_id']) ? intval($_POST['comment_id']) : 0;
107
  $email = isset($_POST['email']) ? trim($_POST['email']) : '';
108
  $isParent = isset($_POST['isParent']) ? intval($_POST['isParent']) : '';
109
- $current_user = wp_get_current_user();
110
- if ($current_user && $current_user->user_email) {
111
- $email = $current_user->user_email;
112
  }
113
  if ($comment_id && $email && $postId) {
114
  $this->notifyPostSubscribers($postId, $comment_id, $email);
1
  <?php
2
 
3
+ if (!defined('ABSPATH')) {
4
+ exit();
5
+ }
6
+
7
  class WpdiscuzEmailHelper {
8
 
9
  private $optionsSerialized;
16
 
17
  public function addSubscription() {
18
  global $wp_rewrite;
19
+ $currentUser = WpdiscuzHelper::getCurrentUser();
20
  $subscribeFormNonce = filter_input(INPUT_POST, 'wpdiscuz_subscribe_form_nonce');
21
  $httpReferer = filter_input(INPUT_POST, '_wp_http_referer');
22
  $subscriptionType = filter_input(INPUT_POST, 'wpdiscuzSubscriptionType');
23
  $postId = filter_input(INPUT_POST, 'wpdiscuzSubscriptionPostId');
24
+ if ($currentUser && $currentUser->ID) {
25
+ $email = $currentUser->user_email;
26
  } else {
27
  $email = filter_input(INPUT_POST, 'wpdiscuzSubscriptionEmail');
28
  }
29
 
30
  $success = 0;
31
  if (wp_verify_nonce($subscribeFormNonce, 'wpdiscuz_subscribe_form_nonce_action') && $email && filter_var($email, FILTER_VALIDATE_EMAIL) !== false && in_array($subscriptionType, array(WpdiscuzCore::SUBSCRIPTION_POST, WpdiscuzCore::SUBSCRIPTION_ALL_COMMENT)) && $postId) {
32
+ $noNeedMemberConfirm = ($currentUser->ID && $this->optionsSerialized->disableMemberConfirm);
33
+ $noNeedGuestsConfirm = (!$currentUser->ID && $this->optionsSerialized->disableGuestsConfirm && $this->dbManager->hasConfirmedSubscription($email));
34
  if ($noNeedMemberConfirm || $noNeedGuestsConfirm) {
35
  $confirmData = $this->dbManager->addEmailNotification($postId, $postId, $email, $subscriptionType, 1);
36
  if ($confirmData) {
110
  $comment_id = isset($_POST['comment_id']) ? intval($_POST['comment_id']) : 0;
111
  $email = isset($_POST['email']) ? trim($_POST['email']) : '';
112
  $isParent = isset($_POST['isParent']) ? intval($_POST['isParent']) : '';
113
+ $currentUser = WpdiscuzHelper::getCurrentUser();
114
+ if ($currentUser && $currentUser->user_email) {
115
+ $email = $currentUser->user_email;
116
  }
117
  if ($comment_id && $email && $postId) {
118
  $this->notifyPostSubscribers($postId, $comment_id, $email);
utils/class.WpdiscuzHelper.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  class WpdiscuzHelper {
4
 
@@ -20,7 +23,7 @@ class WpdiscuzHelper {
20
  private $dbManager;
21
  private $wpdiscuzForm;
22
 
23
- function __construct($optionsSerialized, $dbManager, $wpdiscuzForm) {
24
  $this->optionsSerialized = $optionsSerialized;
25
  $this->dbManager = $dbManager;
26
  $this->wpdiscuzForm = $wpdiscuzForm;
@@ -57,10 +60,10 @@ class WpdiscuzHelper {
57
 
58
  public function filterCommentText($commentContent) {
59
  kses_remove_filters();
60
- remove_filter( 'comment_text', 'wp_kses_post' );
61
- if ( ! current_user_can( 'unfiltered_html' ) ) {
62
- $commentContent = wp_kses($commentContent, $this->filterKses());
63
- }
64
  return $commentContent;
65
  }
66
 
@@ -274,6 +277,10 @@ class WpdiscuzHelper {
274
  } else {
275
  $ip = $_SERVER['REMOTE_ADDR'];
276
  }
 
 
 
 
277
  return $ip;
278
  }
279
 
@@ -287,7 +294,7 @@ class WpdiscuzHelper {
287
  ?>
288
  <div id="comments" style="width: 0;height: 0;clear: both;margin: 0;padding: 0;"></div>
289
  <div id="respond" class="comments-area">
290
- <?php } else { ?>
291
  <div id="comments" class="comments-area">
292
  <div id="respond" style="width: 0;height: 0;clear: both;margin: 0;padding: 0;"></div>
293
  <?php
@@ -407,13 +414,33 @@ class WpdiscuzHelper {
407
  $authorURL = apply_filters('author_link', $authorURL, $author_id, $author_nicename);
408
  return $authorURL;
409
  }
410
-
411
- public function loadMoreLink($parentCommentID,$post_id){
412
  global $wp_rewrite;
413
  $loadMoreLink = !$wp_rewrite->using_permalinks() ? get_permalink($post_id) . "&" : get_permalink($post_id) . "?";
414
- $loadMoreLink.= 'wpdParentID='.$parentCommentID;
415
  return $loadMoreLink;
416
  }
417
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  }
419
 
1
  <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit();
4
+ }
5
 
6
  class WpdiscuzHelper {
7
 
23
  private $dbManager;
24
  private $wpdiscuzForm;
25
 
26
+ public function __construct($optionsSerialized, $dbManager, $wpdiscuzForm) {
27
  $this->optionsSerialized = $optionsSerialized;
28
  $this->dbManager = $dbManager;
29
  $this->wpdiscuzForm = $wpdiscuzForm;
60
 
61
  public function filterCommentText($commentContent) {
62
  kses_remove_filters();
63
+ remove_filter('comment_text', 'wp_kses_post');
64
+ if (!current_user_can('unfiltered_html')) {
65
+ $commentContent = wp_kses($commentContent, $this->filterKses());
66
+ }
67
  return $commentContent;
68
  }
69
 
277
  } else {
278
  $ip = $_SERVER['REMOTE_ADDR'];
279
  }
280
+
281
+ if ($ip == '::1') {
282
+ $ip = '127.0.0.1';
283
+ }
284
  return $ip;
285
  }
286
 
294
  ?>
295
  <div id="comments" style="width: 0;height: 0;clear: both;margin: 0;padding: 0;"></div>
296
  <div id="respond" class="comments-area">
297
+ <?php } else { ?>
298
  <div id="comments" class="comments-area">
299
  <div id="respond" style="width: 0;height: 0;clear: both;margin: 0;padding: 0;"></div>
300
  <?php
414
  $authorURL = apply_filters('author_link', $authorURL, $author_id, $author_nicename);
415
  return $authorURL;
416
  }
417
+
418
+ public function loadMoreLink($parentCommentID, $post_id) {
419
  global $wp_rewrite;
420
  $loadMoreLink = !$wp_rewrite->using_permalinks() ? get_permalink($post_id) . "&" : get_permalink($post_id) . "?";
421
+ $loadMoreLink .= 'wpdParentID=' . $parentCommentID;
422
  return $loadMoreLink;
423
  }
424
 
425
+ public static function getCurrentUser() {
426
+ global $user_ID;
427
+ if ($user_ID) {
428
+ $user = get_userdata($user_ID);
429
+ } else {
430
+ $user = wp_set_current_user(0);
431
+ }
432
+ return $user;
433
+ }
434
+
435
+ public function canUserEditComment($comment, $currentUser, $commentListArgs = array()) {
436
+ $currentIP = $this->getRealIPAddr();
437
+ if (isset($commentListArgs['comment_author_email'])) {
438
+ $storedCookieEmail = $commentListArgs['comment_author_email'];
439
+ } else {
440
+ $storedCookieEmail = isset($_COOKIE['comment_author_email_' . COOKIEHASH]) ? $_COOKIE['comment_author_email_' . COOKIEHASH] : '';
441
+ }
442
+ return ($storedCookieEmail == $comment->comment_author_email && $currentIP == $comment->comment_author_IP) || ($currentUser && $currentUser->ID && $currentUser->ID == $comment->user_id);
443
+ }
444
+
445
  }
446
 
utils/class.WpdiscuzOptimizationHelper.php CHANGED
@@ -1,5 +1,9 @@
1
  <?php
2
 
 
 
 
 
3
  class WpdiscuzOptimizationHelper {
4
 
5
  private $optionsSerialized;
@@ -43,7 +47,6 @@ class WpdiscuzOptimizationHelper {
43
  }
44
  }
45
 
46
-
47
  /**
48
  * add new comment id in comment meta if status is approved
49
  * @param type $newStatus the comment new status
@@ -108,5 +111,10 @@ class WpdiscuzOptimizationHelper {
108
  wp_redirect(admin_url('edit-comments.php?page=' . WpdiscuzCore::PAGE_SETTINGS));
109
  }
110
  }
 
 
 
 
 
111
 
112
  }
1
  <?php
2
 
3
+ if (!defined('ABSPATH')) {
4
+ exit();
5
+ }
6
+
7
  class WpdiscuzOptimizationHelper {
8
 
9
  private $optionsSerialized;
47
  }
48
  }
49
 
 
50
  /**
51
  * add new comment id in comment meta if status is approved
52
  * @param type $newStatus the comment new status
111
  wp_redirect(admin_url('edit-comments.php?page=' . WpdiscuzCore::PAGE_SETTINGS));
112
  }
113
  }
114
+
115
+ public function cleanCommentRelatedRows($commentId) {
116
+ $this->dbManager->deleteSubscriptions($commentId);
117
+ $this->dbManager->deleteVotes($commentId);
118
+ }
119
 
120
  }
utils/interface.WpDiscuzConstants.php CHANGED
@@ -1,5 +1,9 @@
1
  <?php
2
 
 
 
 
 
3
  interface WpDiscuzConstants {
4
  /* === OPTIONS SLUGS === */
5
  const OPTION_SLUG_OPTIONS = 'wc_options';
@@ -21,4 +25,6 @@ interface WpDiscuzConstants {
21
  const ACTION_CAPTCHA_NONCE = 'wpdiscuz_captcha_nonce_action';
22
  /* === TRANSIENT KEYS === */
23
  const TRS_POSTS_AUTHORS = 'wpdiscuz_posts_authors';
 
 
24
  }
1
  <?php
2
 
3
+ if (!defined('ABSPATH')) {
4
+ exit();
5
+ }
6
+
7
  interface WpDiscuzConstants {
8
  /* === OPTIONS SLUGS === */
9
  const OPTION_SLUG_OPTIONS = 'wc_options';
25
  const ACTION_CAPTCHA_NONCE = 'wpdiscuz_captcha_nonce_action';
26
  /* === TRANSIENT KEYS === */
27
  const TRS_POSTS_AUTHORS = 'wpdiscuz_posts_authors';
28
+ /* === COOKIES === */
29
+ const COOKIE_LAST_VISIT = 'wpdiscuz_last_visit';
30
  }