WP ULike - Version 3.5.2

Version Description

  • Fixed: An important issue with buddypress comments.
  • Added: Class name issue on likers box.
  • Upgraded: "WordpressUlike" js functionality.
  • Added: some improvements on general functions.
Download this release

Release Info

Developer alimir
Plugin Icon 128x128 WP ULike
Version 3.5.2
Comparing to
See all releases

Code changes from version 3.5.1 to 3.5.2

admin/assets/js/plugins.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! WP ULike - v3.5.1
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
1
+ /*! WP ULike - v3.5.2
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
admin/assets/js/scripts.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! WP ULike - v3.5.1
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
1
+ /*! WP ULike - v3.5.2
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
assets/js/wp-ulike.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! WP ULike - v3.5.1
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
@@ -153,86 +153,64 @@
153
  $.extend(Plugin.prototype, {
154
  init: function () {
155
  //Call _ajaxify function on click button
156
- this.buttonElement.click( this._button.bind(this) );
157
-
158
  //Call _ajaxify function on click button
159
- this.generalElement.hover( this._likers.bind(this) );
160
  },
161
 
162
- _button: function(){
 
 
 
 
163
  $.ajax({
164
- type :'POST',
165
- cache : false,
166
- dataType : 'json',
167
- url : wp_ulike_params.ajax_url,
168
- data :{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  action: 'wp_ulike_process',
170
  id : this.settings.ID,
171
  nonce : this.settings.nonce,
172
  status: this.settings.likeStatus,
173
  type : this.settings.type
174
- },
175
- beforeSend:function(){
176
- $document.trigger( 'WordpressUlikeLoading', this.element );
177
- this.generalElement.addClass( 'wp_ulike_is_loading' );
178
- }.bind(this),
179
- success : function( response ){
180
- //remove loading class
181
  this.generalElement.removeClass( 'wp_ulike_is_loading' );
 
182
  if( response.success ) {
183
- this._update( response );
184
  } else {
185
- this._notif( 'error', response.data );
186
  }
187
-
 
 
188
  $document.trigger( 'WordpressUlikeUpdated', this.element );
189
- }.bind(this)
190
- });
191
  },
192
 
193
- _likers: function(){
194
- // Get likers box container element
195
- this.likersElement = this.$element.find( this.settings.likersSelector );
196
- // Make a request to generate or refresh the likers box
197
- if( !this.likersElement.length || this._refresh ) {
198
- $.ajax({
199
- type :'POST',
200
- cache : false,
201
- dataType : 'json',
202
- url : wp_ulike_params.ajax_url,
203
- data :{
204
- action : 'wp_ulike_get_likers',
205
- id : this.settings.ID,
206
- nonce : this.settings.nonce,
207
- type : this.settings.type,
208
- refresh: this._refresh ? 1 : 0
209
- },
210
- beforeSend:function(){
211
- // Add progress status class
212
- this.generalElement.addClass( 'wp_ulike_is_getting_likers_list' );
213
- }.bind(this),
214
- success : function( response ){
215
- // If the likers container is not exist, we've to add it.
216
- if( !this.likersElement.length ) {
217
- this.likersElement = $( '<div>', { class: response.data.class } ).appendTo( this.$element );
218
- }
219
- // Remove progress status class
220
- this.generalElement.removeClass( 'wp_ulike_is_getting_likers_list' );
221
- if( response.success ) {
222
- // Modify likers box innerHTML
223
- if( typeof response.data !== 'undefined' ){
224
- this.likersElement.html( response.data.template );
225
- } else {
226
- this.likersElement.remove();
227
- }
228
-
229
- }
230
- }.bind(this)
231
- });
232
- }
233
- },
234
-
235
- _update: function( response ){
236
  //check likeStatus
237
  switch( this.settings.likeStatus ) {
238
  case 1: /* Change the status of 'is not liked' to 'liked' */
@@ -241,7 +219,7 @@
241
  this.generalElement.addClass( 'wp_ulike_is_liked' ).removeClass( 'wp_ulike_is_not_liked' );
242
  this.generalElement.children().first().addClass( 'wp_ulike_click_is_disabled' );
243
  this.counterElement.text( response.data.data );
244
- this._actions( 'success', response.data.message, response.data.btnText, 4 );
245
  this._refresh = true;
246
  break;
247
  case 2: /* Change the status of 'liked' to 'unliked' */
@@ -249,7 +227,7 @@
249
  this.settings.likeStatus = 3;
250
  this.generalElement.addClass( 'wp_ulike_is_unliked' ).removeClass('wp_ulike_is_liked');
251
  this.counterElement.text( response.data.data );
252
- this._actions( 'error', response.data.message, response.data.btnText, 3 );
253
  this._refresh = true;
254
  break;
255
  case 3: /* Change the status of 'unliked' to 'liked' */
@@ -257,26 +235,66 @@
257
  this.settings.likeStatus = 2;
258
  this.generalElement.addClass('wp_ulike_is_liked').removeClass('wp_ulike_is_unliked');
259
  this.counterElement.text( response.data.data );
260
- this._actions( 'success', response.data.message, response.data.btnText, 2 );
261
  this._refresh = true;
262
  break;
263
  case 4: /* Just print the log-in warning message */
264
- this._actions( 'info', response.data.message, response.data.btnText, 4 );
265
  this.generalElement.children().first().addClass( 'wp_ulike_click_is_disabled' );
266
  break;
267
  default: /* Just print the permission faild message */
268
- this._actions( 'warning', response.data.message, response.data.btnText, 0 );
269
  }
270
 
271
  // Refresh likers box on data update
272
  if( this._refresh ) {
273
- this._likers();
274
- this._refresh = false;
275
  }
276
 
277
  },
278
 
279
- _actions: function( messageType, messageText, btnText, likeStatus ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  //check the button types
281
  if( this.buttonElement.hasClass('wp_ulike_put_image') ) {
282
  if( likeStatus === 3 || likeStatus === 2){
@@ -287,12 +305,17 @@
287
  }
288
 
289
  // Display Notifications
290
- this._notif( messageType, messageText );
291
  },
292
 
293
- _notif: function( messageType, messageText ){
 
 
 
294
  //Check notifications active mode
295
- if(wp_ulike_params.notifications !== '1') return;
 
 
296
  // Display Notification
297
  $(document.body).WordpressUlikeNotifications({
298
  messageType : messageType,
1
+ /*! WP ULike - v3.5.2
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
153
  $.extend(Plugin.prototype, {
154
  init: function () {
155
  //Call _ajaxify function on click button
156
+ this.buttonElement.click( this._initLike.bind(this) );
 
157
  //Call _ajaxify function on click button
158
+ this.generalElement.hover( this._updateLikers.bind(this) );
159
  },
160
 
161
+ /**
162
+ * global AJAX callback
163
+ */
164
+ _ajax: function( args, callback ){
165
+ // Do Ajax & update default value
166
  $.ajax({
167
+ url : wp_ulike_params.ajax_url,
168
+ type : 'POST',
169
+ cache : false,
170
+ dataType: 'json',
171
+ data : args
172
+ }).done( callback );
173
+ },
174
+
175
+ /**
176
+ * init ulike core process
177
+ */
178
+ _initLike: function( event ){
179
+ // Prevents further propagation of the current event in the capturing and bubbling phases
180
+ event.stopPropagation();
181
+ // Disable button
182
+ $(event.currentTarget).prop( "disabled", true );
183
+ // Manipulations
184
+ $document.trigger( 'WordpressUlikeLoading', this.element );
185
+ // Add progress class
186
+ this.generalElement.addClass( 'wp_ulike_is_loading' );
187
+ // Start AJAX process
188
+ this._ajax( {
189
  action: 'wp_ulike_process',
190
  id : this.settings.ID,
191
  nonce : this.settings.nonce,
192
  status: this.settings.likeStatus,
193
  type : this.settings.type
194
+ }, function( response ){
195
+ //remove progress class
 
 
 
 
 
196
  this.generalElement.removeClass( 'wp_ulike_is_loading' );
197
+ // Make changes
198
  if( response.success ) {
199
+ this._updateMarkup( response );
200
  } else {
201
+ this._sendNotification( 'error', response.data );
202
  }
203
+ // Re-enable button
204
+ $(event.currentTarget).prop( "disabled", false );
205
+ // Add new trigger when process finished
206
  $document.trigger( 'WordpressUlikeUpdated', this.element );
207
+ }.bind(this) );
 
208
  },
209
 
210
+ /**
211
+ * update button markup and calling some actions
212
+ */
213
+ _updateMarkup: function( response ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  //check likeStatus
215
  switch( this.settings.likeStatus ) {
216
  case 1: /* Change the status of 'is not liked' to 'liked' */
219
  this.generalElement.addClass( 'wp_ulike_is_liked' ).removeClass( 'wp_ulike_is_not_liked' );
220
  this.generalElement.children().first().addClass( 'wp_ulike_click_is_disabled' );
221
  this.counterElement.text( response.data.data );
222
+ this._controlActions( 'success', response.data.message, response.data.btnText, 4 );
223
  this._refresh = true;
224
  break;
225
  case 2: /* Change the status of 'liked' to 'unliked' */
227
  this.settings.likeStatus = 3;
228
  this.generalElement.addClass( 'wp_ulike_is_unliked' ).removeClass('wp_ulike_is_liked');
229
  this.counterElement.text( response.data.data );
230
+ this._controlActions( 'error', response.data.message, response.data.btnText, 3 );
231
  this._refresh = true;
232
  break;
233
  case 3: /* Change the status of 'unliked' to 'liked' */
235
  this.settings.likeStatus = 2;
236
  this.generalElement.addClass('wp_ulike_is_liked').removeClass('wp_ulike_is_unliked');
237
  this.counterElement.text( response.data.data );
238
+ this._controlActions( 'success', response.data.message, response.data.btnText, 2 );
239
  this._refresh = true;
240
  break;
241
  case 4: /* Just print the log-in warning message */
242
+ this._controlActions( 'info', response.data.message, response.data.btnText, 4 );
243
  this.generalElement.children().first().addClass( 'wp_ulike_click_is_disabled' );
244
  break;
245
  default: /* Just print the permission faild message */
246
+ this._controlActions( 'warning', response.data.message, response.data.btnText, 0 );
247
  }
248
 
249
  // Refresh likers box on data update
250
  if( this._refresh ) {
251
+ this._updateLikers();
 
252
  }
253
 
254
  },
255
 
256
+ /**
257
+ * init & update likers box
258
+ */
259
+ _updateLikers: function(){
260
+ // Get likers box container element
261
+ this.likersElement = this.$element.find( this.settings.likersSelector );
262
+ // Make a request to generate or refresh the likers box
263
+ if( !this.likersElement.length || this._refresh ) {
264
+ // Add progress status class
265
+ this.generalElement.addClass( 'wp_ulike_is_getting_likers_list' );
266
+ // Start ajax process
267
+ this._ajax( {
268
+ action : 'wp_ulike_get_likers',
269
+ id : this.settings.ID,
270
+ nonce : this.settings.nonce,
271
+ type : this.settings.type,
272
+ refresh: this._refresh ? 1 : 0
273
+ }, function( response ){
274
+ // Remove progress status class
275
+ this.generalElement.removeClass( 'wp_ulike_is_getting_likers_list' );
276
+ // Change markup
277
+ if( response.success ) {
278
+ // If the likers container is not exist, we've to add it.
279
+ if( !this.likersElement.length ) {
280
+ this.likersElement = $( '<div>', { class: response.data.class } ).appendTo( this.$element );
281
+ }
282
+ // Modify likers box innerHTML
283
+ if( response.data.template ){
284
+ this.likersElement.show().html( response.data.template );
285
+ } else {
286
+ this.likersElement.hide();
287
+ }
288
+ }
289
+ this._refresh = false;
290
+ }.bind(this) );
291
+ }
292
+ },
293
+
294
+ /**
295
+ * Control actions
296
+ */
297
+ _controlActions: function( messageType, messageText, btnText, likeStatus ){
298
  //check the button types
299
  if( this.buttonElement.hasClass('wp_ulike_put_image') ) {
300
  if( likeStatus === 3 || likeStatus === 2){
305
  }
306
 
307
  // Display Notifications
308
+ this._sendNotification( messageType, messageText );
309
  },
310
 
311
+ /**
312
+ * Send notification by 'WordpressUlikeNotifications' plugin
313
+ */
314
+ _sendNotification: function( messageType, messageText ){
315
  //Check notifications active mode
316
+ if( wp_ulike_params.notifications !== '1' ){
317
+ return;
318
+ }
319
  // Display Notification
320
  $(document.body).WordpressUlikeNotifications({
321
  messageType : messageType,
assets/js/wp-ulike.min.js CHANGED
@@ -1 +1 @@
1
- !function(s,e,t,i){"use strict";var n="WordpressUlikeNotifications",a={messageType:"success",messageText:"Hello World!",messageElement:"wpulike-message",notifContainer:"wpulike-notification"};function l(e,t){this.element=e,this.$element=s(e),this.settings=s.extend({},a,t),this._defaults=a,this._name=n,this.init()}s.extend(l.prototype,{init:function(){this._message(),this._container(),this._append(),this._remove()},_message:function(){this.$messageElement=s("<div/>").addClass(this.settings.messageElement+" wpulike-"+this.settings.messageType).text(this.settings.messageText)},_container:function(){s("."+this.settings.notifContainer).length||this.$element.append(s("<div/>").addClass(this.settings.notifContainer)),this.$notifContainer=this.$element.find("."+this.settings.notifContainer)},_append:function(){this.$notifContainer.append(this.$messageElement).trigger("WordpressUlikeNotificationAppend")},_remove:function(){var e=this;this.$messageElement.click(function(){s(this).fadeOut(300,function(){s(this).remove(),s("."+e.settings.messageElement).length||e.$notifContainer.remove()}).trigger("WordpressUlikeRemoveNotification")}),setTimeout(function(){e.$messageElement.fadeOut(300,function(){s(this).remove(),s("."+e.settings.messageElement).length||e.$notifContainer.remove()}).trigger("WordpressUlikeRemoveNotification")},8e3)}}),s.fn[n]=function(e){return this.each(function(){new l(this,e)})}}(jQuery,window,document),function(n,e,s,t){"use strict";var a="WordpressUlike",i=(n(e),n(s)),l={ID:0,nonce:0,type:"",likeStatus:0,counterSelector:".count-box",generalSelector:".wp_ulike_general_class",buttonSelector:".wp_ulike_btn",likersSelector:".wp_ulike_likers_wrapper"},o={"ulike-id":"ID","ulike-nonce":"nonce","ulike-type":"type","ulike-status":"likeStatus"};function r(e,t){for(var s in this.element=e,this.$element=n(e),this.settings=n.extend({},l,t),this._defaults=l,this._name=a,this._refresh=!1,this.buttonElement=this.$element.find(this.settings.buttonSelector),this.generalElement=this.$element.find(this.settings.generalSelector),this.counterElement=this.generalElement.find(this.settings.counterSelector),o){var i=this.buttonElement.data(s);void 0!==i&&(this.settings[o[s]]=i)}this.init()}n.extend(r.prototype,{init:function(){this.buttonElement.click(this._button.bind(this)),this.generalElement.hover(this._likers.bind(this))},_button:function(){n.ajax({type:"POST",cache:!1,dataType:"json",url:wp_ulike_params.ajax_url,data:{action:"wp_ulike_process",id:this.settings.ID,nonce:this.settings.nonce,status:this.settings.likeStatus,type:this.settings.type},beforeSend:function(){i.trigger("WordpressUlikeLoading",this.element),this.generalElement.addClass("wp_ulike_is_loading")}.bind(this),success:function(e){this.generalElement.removeClass("wp_ulike_is_loading"),e.success?this._update(e):this._notif("error",e.data),i.trigger("WordpressUlikeUpdated",this.element)}.bind(this)})},_likers:function(){this.likersElement=this.$element.find(this.settings.likersSelector),this.likersElement.length&&!this._refresh||n.ajax({type:"POST",cache:!1,dataType:"json",url:wp_ulike_params.ajax_url,data:{action:"wp_ulike_get_likers",id:this.settings.ID,nonce:this.settings.nonce,type:this.settings.type,refresh:this._refresh?1:0},beforeSend:function(){this.generalElement.addClass("wp_ulike_is_getting_likers_list")}.bind(this),success:function(e){this.likersElement.length||(this.likersElement=n("<div>",{class:e.data.class}).appendTo(this.$element)),this.generalElement.removeClass("wp_ulike_is_getting_likers_list"),e.success&&(void 0!==e.data?this.likersElement.html(e.data.template):this.likersElement.remove())}.bind(this)})},_update:function(e){switch(this.settings.likeStatus){case 1:this.buttonElement.attr("data-ulike-status",4),this.settings.likeStatus=4,this.generalElement.addClass("wp_ulike_is_liked").removeClass("wp_ulike_is_not_liked"),this.generalElement.children().first().addClass("wp_ulike_click_is_disabled"),this.counterElement.text(e.data.data),this._actions("success",e.data.message,e.data.btnText,4),this._refresh=!0;break;case 2:this.buttonElement.attr("data-ulike-status",3),this.settings.likeStatus=3,this.generalElement.addClass("wp_ulike_is_unliked").removeClass("wp_ulike_is_liked"),this.counterElement.text(e.data.data),this._actions("error",e.data.message,e.data.btnText,3),this._refresh=!0;break;case 3:this.buttonElement.attr("data-ulike-status",2),this.settings.likeStatus=2,this.generalElement.addClass("wp_ulike_is_liked").removeClass("wp_ulike_is_unliked"),this.counterElement.text(e.data.data),this._actions("success",e.data.message,e.data.btnText,2),this._refresh=!0;break;case 4:this._actions("info",e.data.message,e.data.btnText,4),this.generalElement.children().first().addClass("wp_ulike_click_is_disabled");break;default:this._actions("warning",e.data.message,e.data.btnText,0)}this._refresh&&(this._likers(),this._refresh=!1)},_actions:function(e,t,s,i){this.buttonElement.hasClass("wp_ulike_put_image")?3!==i&&2!==i||this.buttonElement.toggleClass("image-unlike"):this.buttonElement.hasClass("wp_ulike_put_text")&&this.buttonElement.find("span").html(s),this._notif(e,t)},_notif:function(e,t){"1"===wp_ulike_params.notifications&&n(s.body).WordpressUlikeNotifications({messageType:e,messageText:t})}}),n.fn[a]=function(e){return this.each(function(){n.data(this,"plugin_"+a)||n.data(this,"plugin_"+a,new r(this,e))})}}(jQuery,window,document),function(t){t(function(){t(this).bind("DOMNodeInserted",function(e){t(".wpulike").WordpressUlike()})}),t(".wpulike").WordpressUlike()}(jQuery);
1
+ !function(s,e,t,i){"use strict";var n="WordpressUlikeNotifications",a={messageType:"success",messageText:"Hello World!",messageElement:"wpulike-message",notifContainer:"wpulike-notification"};function l(e,t){this.element=e,this.$element=s(e),this.settings=s.extend({},a,t),this._defaults=a,this._name=n,this.init()}s.extend(l.prototype,{init:function(){this._message(),this._container(),this._append(),this._remove()},_message:function(){this.$messageElement=s("<div/>").addClass(this.settings.messageElement+" wpulike-"+this.settings.messageType).text(this.settings.messageText)},_container:function(){s("."+this.settings.notifContainer).length||this.$element.append(s("<div/>").addClass(this.settings.notifContainer)),this.$notifContainer=this.$element.find("."+this.settings.notifContainer)},_append:function(){this.$notifContainer.append(this.$messageElement).trigger("WordpressUlikeNotificationAppend")},_remove:function(){var e=this;this.$messageElement.click(function(){s(this).fadeOut(300,function(){s(this).remove(),s("."+e.settings.messageElement).length||e.$notifContainer.remove()}).trigger("WordpressUlikeRemoveNotification")}),setTimeout(function(){e.$messageElement.fadeOut(300,function(){s(this).remove(),s("."+e.settings.messageElement).length||e.$notifContainer.remove()}).trigger("WordpressUlikeRemoveNotification")},8e3)}}),s.fn[n]=function(e){return this.each(function(){new l(this,e)})}}(jQuery,window,document),function(n,e,s,t){"use strict";var a="WordpressUlike",i=(n(e),n(s)),l={ID:0,nonce:0,type:"",likeStatus:0,counterSelector:".count-box",generalSelector:".wp_ulike_general_class",buttonSelector:".wp_ulike_btn",likersSelector:".wp_ulike_likers_wrapper"},o={"ulike-id":"ID","ulike-nonce":"nonce","ulike-type":"type","ulike-status":"likeStatus"};function r(e,t){for(var s in this.element=e,this.$element=n(e),this.settings=n.extend({},l,t),this._defaults=l,this._name=a,this._refresh=!1,this.buttonElement=this.$element.find(this.settings.buttonSelector),this.generalElement=this.$element.find(this.settings.generalSelector),this.counterElement=this.generalElement.find(this.settings.counterSelector),o){var i=this.buttonElement.data(s);void 0!==i&&(this.settings[o[s]]=i)}this.init()}n.extend(r.prototype,{init:function(){this.buttonElement.click(this._initLike.bind(this)),this.generalElement.hover(this._updateLikers.bind(this))},_ajax:function(e,t){n.ajax({url:wp_ulike_params.ajax_url,type:"POST",cache:!1,dataType:"json",data:e}).done(t)},_initLike:function(t){t.stopPropagation(),n(t.currentTarget).prop("disabled",!0),i.trigger("WordpressUlikeLoading",this.element),this.generalElement.addClass("wp_ulike_is_loading"),this._ajax({action:"wp_ulike_process",id:this.settings.ID,nonce:this.settings.nonce,status:this.settings.likeStatus,type:this.settings.type},function(e){this.generalElement.removeClass("wp_ulike_is_loading"),e.success?this._updateMarkup(e):this._sendNotification("error",e.data),n(t.currentTarget).prop("disabled",!1),i.trigger("WordpressUlikeUpdated",this.element)}.bind(this))},_updateMarkup:function(e){switch(this.settings.likeStatus){case 1:this.buttonElement.attr("data-ulike-status",4),this.settings.likeStatus=4,this.generalElement.addClass("wp_ulike_is_liked").removeClass("wp_ulike_is_not_liked"),this.generalElement.children().first().addClass("wp_ulike_click_is_disabled"),this.counterElement.text(e.data.data),this._controlActions("success",e.data.message,e.data.btnText,4),this._refresh=!0;break;case 2:this.buttonElement.attr("data-ulike-status",3),this.settings.likeStatus=3,this.generalElement.addClass("wp_ulike_is_unliked").removeClass("wp_ulike_is_liked"),this.counterElement.text(e.data.data),this._controlActions("error",e.data.message,e.data.btnText,3),this._refresh=!0;break;case 3:this.buttonElement.attr("data-ulike-status",2),this.settings.likeStatus=2,this.generalElement.addClass("wp_ulike_is_liked").removeClass("wp_ulike_is_unliked"),this.counterElement.text(e.data.data),this._controlActions("success",e.data.message,e.data.btnText,2),this._refresh=!0;break;case 4:this._controlActions("info",e.data.message,e.data.btnText,4),this.generalElement.children().first().addClass("wp_ulike_click_is_disabled");break;default:this._controlActions("warning",e.data.message,e.data.btnText,0)}this._refresh&&this._updateLikers()},_updateLikers:function(){this.likersElement=this.$element.find(this.settings.likersSelector),this.likersElement.length&&!this._refresh||(this.generalElement.addClass("wp_ulike_is_getting_likers_list"),this._ajax({action:"wp_ulike_get_likers",id:this.settings.ID,nonce:this.settings.nonce,type:this.settings.type,refresh:this._refresh?1:0},function(e){this.generalElement.removeClass("wp_ulike_is_getting_likers_list"),e.success&&(this.likersElement.length||(this.likersElement=n("<div>",{class:e.data.class}).appendTo(this.$element)),e.data.template?this.likersElement.show().html(e.data.template):this.likersElement.hide()),this._refresh=!1}.bind(this)))},_controlActions:function(e,t,s,i){this.buttonElement.hasClass("wp_ulike_put_image")?3!==i&&2!==i||this.buttonElement.toggleClass("image-unlike"):this.buttonElement.hasClass("wp_ulike_put_text")&&this.buttonElement.find("span").html(s),this._sendNotification(e,t)},_sendNotification:function(e,t){"1"===wp_ulike_params.notifications&&n(s.body).WordpressUlikeNotifications({messageType:e,messageText:t})}}),n.fn[a]=function(e){return this.each(function(){n.data(this,"plugin_"+a)||n.data(this,"plugin_"+a,new r(this,e))})}}(jQuery,window,document),function(t){t(function(){t(this).bind("DOMNodeInserted",function(e){t(".wpulike").WordpressUlike()})}),t(".wpulike").WordpressUlike()}(jQuery);
inc/classes/class-wp-ulike-frontend-assets.php CHANGED
@@ -41,7 +41,7 @@ if ( ! class_exists( 'wp_ulike_frontend_assets' ) ) {
41
  */
42
  public function load_styles() {
43
 
44
- wp_enqueue_style( 'wp-ulike', WP_ULIKE_ASSETS_URL . '/css/wp-ulike.min.css', array(), '3.5.1' );
45
 
46
  //add your custom style from setting panel.
47
  wp_add_inline_style( 'wp-ulike', wp_ulike_get_custom_style() );
@@ -56,7 +56,7 @@ if ( ! class_exists( 'wp_ulike_frontend_assets' ) ) {
56
  public function load_scripts() {
57
 
58
  //Add wp_ulike script file with special functions.
59
- wp_enqueue_script( 'wp_ulike', WP_ULIKE_ASSETS_URL . '/js/wp-ulike.min.js', array( 'jquery' ), '3.5.1', true );
60
 
61
  //localize script
62
  wp_localize_script( 'wp_ulike', 'wp_ulike_params', array(
41
  */
42
  public function load_styles() {
43
 
44
+ wp_enqueue_style( 'wp-ulike', WP_ULIKE_ASSETS_URL . '/css/wp-ulike.min.css', array(), WP_ULIKE_VERSION );
45
 
46
  //add your custom style from setting panel.
47
  wp_add_inline_style( 'wp-ulike', wp_ulike_get_custom_style() );
56
  public function load_scripts() {
57
 
58
  //Add wp_ulike script file with special functions.
59
+ wp_enqueue_script( 'wp_ulike', WP_ULIKE_ASSETS_URL . '/js/wp-ulike.min.js', array( 'jquery' ), WP_ULIKE_VERSION, true );
60
 
61
  //localize script
62
  wp_localize_script( 'wp_ulike', 'wp_ulike_params', array(
inc/frontend-ajax.php CHANGED
@@ -142,16 +142,11 @@ function wp_ulike_get_likers(){
142
  wp_send_json_error( __( 'Notice: The likers box is not activated!', WP_ULIKE_SLUG ) );
143
  }
144
 
145
- if( NULL !== ( $users_list = wp_ulike_get_likers_template( $table_name, $column_name, $post_ID, $setting_key ) ) ) {
146
- // Add specific class name with popover checkup
147
- $class_names = wp_ulike_get_setting( $setting_key, 'disable_likers_pophover', 0 ) ? 'wp_ulike_likers_wrapper wp_ulike_display_inline' : 'wp_ulike_likers_wrapper';
148
- // Return the list of users
149
- wp_send_json_success( array( 'template' => $users_list, 'class' => $class_names ) );
150
- }
151
-
152
- // Send blank success when the users list are empty
153
- wp_send_json_success();
154
 
 
155
  }
156
  // wp_ajax hooks for the custom AJAX requests
157
  add_action( 'wp_ajax_wp_ulike_get_likers' , 'wp_ulike_get_likers' );
142
  wp_send_json_error( __( 'Notice: The likers box is not activated!', WP_ULIKE_SLUG ) );
143
  }
144
 
145
+ // Add specific class name with popover checkup
146
+ $class_names = wp_ulike_get_setting( $setting_key, 'disable_likers_pophover', 0 ) ? 'wp_ulike_likers_wrapper wp_ulike_display_inline' : 'wp_ulike_likers_wrapper';
147
+ $users_list = wp_ulike_get_likers_template( $table_name, $column_name, $post_ID, $setting_key );
 
 
 
 
 
 
148
 
149
+ wp_send_json_success( array( 'template' => $users_list, 'class' => $class_names ) );
150
  }
151
  // wp_ajax hooks for the custom AJAX requests
152
  add_action( 'wp_ajax_wp_ulike_get_likers' , 'wp_ulike_get_likers' );
inc/general-functions.php CHANGED
@@ -1234,18 +1234,20 @@ if( ! function_exists( 'wp_ulike_get_post_settings_by_type' ) ){
1234
  * @since 2.0
1235
  * @return String
1236
  */
1237
- function wp_ulike_get_likers_list_per_post( $table_name, $column_name, $post_ID, $limit_num = 10 ){
1238
- // Global wordpress database object
1239
- global $wpdb;
1240
- // Get likers list
1241
- return $wpdb->get_results( "SELECT user_id
1242
- FROM ".$wpdb->prefix."$table_name
1243
- WHERE $column_name = '$post_ID'
1244
- AND status = 'like'
1245
- AND user_id BETWEEN 1 AND 999999
1246
- GROUP BY user_id
1247
- LIMIT $limit_num"
1248
- );
 
 
1249
  }
1250
 
1251
 
@@ -1260,55 +1262,57 @@ function wp_ulike_get_likers_list_per_post( $table_name, $column_name, $post_ID,
1260
  * @since 2.0
1261
  * @return String
1262
  */
1263
- function wp_ulike_get_likers_template( $table_name, $column_name, $post_ID, $setting_key ){
1264
-
1265
- // Get user's limit number value
1266
- $limit_num = wp_ulike_get_setting( $setting_key, 'number_of_users', 10 );
1267
- // Get likers list
1268
- $get_users = wp_ulike_get_likers_list_per_post( $table_name, $column_name, $post_ID, $limit_num );
1269
- // Bulk user list
1270
- $users_list = '';
1271
-
1272
- if( ! empty( $get_users ) ) {
1273
-
1274
- // Get likers html template
1275
- $get_template = wp_ulike_get_setting( $setting_key, 'users_liked_box_template', '<div class="wp-ulike-likers-list">%START_WHILE%<span class="wp-ulike-liker"><a href="#" title="%USER_NAME%">%USER_AVATAR%</a></span>%END_WHILE%</div>' );
1276
-
1277
- $inner_template = wp_ulike_get_template_between( $get_template, "%START_WHILE%", "%END_WHILE%" );
1278
-
1279
- foreach ( $get_users as $get_user ) {
1280
- $user_info = get_userdata( $get_user->user_id );
1281
- $out_template = $inner_template;
1282
- if ( $user_info ):
1283
- if( strpos( $out_template, '%USER_AVATAR%' ) !== false ) {
1284
- $avatar_size = wp_ulike_get_setting( $setting_key, 'users_liked_box_avatar_size' );
1285
- $USER_AVATAR = get_avatar( $user_info->user_email, $avatar_size, '' , 'avatar' );
1286
- $out_template = str_replace( "%USER_AVATAR%", $USER_AVATAR, $out_template );
1287
- }
1288
- if( strpos( $out_template, '%USER_NAME%' ) !== false) {
1289
- $USER_NAME = $user_info->display_name;
1290
- $out_template = str_replace( "%USER_NAME%", $USER_NAME, $out_template );
1291
- }
1292
- if( strpos( $out_template, '%UM_PROFILE_URL%' ) !== false && function_exists('um_fetch_user') ) {
1293
- global $ultimatemember;
1294
- um_fetch_user( $user_info->ID );
1295
- $UM_PROFILE_URL = um_user_profile_url();
1296
- $out_template = str_replace( "%UM_PROFILE_URL%", $UM_PROFILE_URL, $out_template );
1297
- }
1298
- if( strpos( $out_template, '%BP_PROFILE_URL%' ) !== false && function_exists('bp_core_get_user_domain') ) {
1299
- $BP_PROFILE_URL = bp_core_get_user_domain( $user_info->ID );
1300
- $out_template = str_replace( "%BP_PROFILE_URL%", $BP_PROFILE_URL, $out_template );
1301
- }
1302
- $users_list .= $out_template;
1303
- endif;
1304
- }
 
1305
 
1306
- if( ! empty( $users_list ) ) {
1307
- return wp_ulike_put_template_between( $get_template, $users_list, "%START_WHILE%", "%END_WHILE%" );
 
1308
  }
1309
- }
1310
 
1311
- return NULL;
 
1312
  }
1313
 
1314
  /**
@@ -1321,16 +1325,18 @@ function wp_ulike_get_likers_template( $table_name, $column_name, $post_ID, $set
1321
  * @since 2.0
1322
  * @return String
1323
  */
1324
- function wp_ulike_get_template_between( $string, $start, $end ){
1325
- $string = " ".$string;
1326
- $ini = strpos($string,$start);
1327
- if ( $ini == 0 ){
1328
- return "";
1329
- }
1330
- $ini += strlen($start);
1331
- $len = strpos($string,$end,$ini) - $ini;
 
1332
 
1333
- return substr( $string, $ini, $len );
 
1334
  }
1335
 
1336
  /**
@@ -1344,22 +1350,24 @@ function wp_ulike_get_template_between( $string, $start, $end ){
1344
  * @since 2.0
1345
  * @return String
1346
  */
1347
- function wp_ulike_put_template_between( $string, $inner_string, $start, $end ){
1348
- $string = " ".$string;
1349
- $ini = strpos($string,$start);
1350
- if ($ini == 0){
1351
- return "";
1352
- }
 
1353
 
1354
- $ini += strlen($start);
1355
- $len = strpos($string,$end,$ini) - $ini;
1356
- $newstr = substr_replace($string,$inner_string,$ini,$len);
1357
 
1358
- return str_replace(
1359
- array( "%START_WHILE%", "%END_WHILE%" ),
1360
- array( "", "" ),
1361
- $newstr
1362
- );
 
1363
  }
1364
 
1365
  /**
@@ -1516,18 +1524,20 @@ if( ! function_exists( 'wp_ulike_date_i18n' ) ){
1516
  * @since 3.4
1517
  * @return String
1518
  */
1519
- function wp_ulike_generate_user_id( $user_ip ) {
1520
-
1521
- if( filter_var( $user_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
1522
- return ip2long( $user_ip );
1523
- } else {
1524
- $binary_val = '';
1525
- foreach ( unpack( 'C*', inet_pton( $user_ip ) ) as $byte ) {
1526
- $binary_val .= decbin( $byte );
1527
- }
1528
- return base_convert( ltrim( $binary_val, '0' ), 2, 10 );
1529
- }
1530
 
 
 
 
 
 
 
 
 
 
 
 
1531
  }
1532
 
1533
  /*******************************************************
1234
  * @since 2.0
1235
  * @return String
1236
  */
1237
+ if( ! function_exists( 'wp_ulike_get_likers_list_per_post' ) ){
1238
+ function wp_ulike_get_likers_list_per_post( $table_name, $column_name, $post_ID, $limit_num = 10 ){
1239
+ // Global wordpress database object
1240
+ global $wpdb;
1241
+ // Get likers list
1242
+ return $wpdb->get_results( "SELECT user_id
1243
+ FROM ".$wpdb->prefix."$table_name
1244
+ WHERE $column_name = '$post_ID'
1245
+ AND status = 'like'
1246
+ AND user_id BETWEEN 1 AND 999999
1247
+ GROUP BY user_id
1248
+ LIMIT $limit_num"
1249
+ );
1250
+ }
1251
  }
1252
 
1253
 
1262
  * @since 2.0
1263
  * @return String
1264
  */
1265
+ if( ! function_exists( 'wp_ulike_get_likers_template' ) ){
1266
+ function wp_ulike_get_likers_template( $table_name, $column_name, $post_ID, $setting_key ){
1267
+
1268
+ // Get user's limit number value
1269
+ $limit_num = wp_ulike_get_setting( $setting_key, 'number_of_users', 10 );
1270
+ // Get likers list
1271
+ $get_users = wp_ulike_get_likers_list_per_post( $table_name, $column_name, $post_ID, $limit_num );
1272
+ // Bulk user list
1273
+ $users_list = '';
1274
+
1275
+ if( ! empty( $get_users ) ) {
1276
+
1277
+ // Get likers html template
1278
+ $get_template = wp_ulike_get_setting( $setting_key, 'users_liked_box_template', '<div class="wp-ulike-likers-list">%START_WHILE%<span class="wp-ulike-liker"><a href="#" title="%USER_NAME%">%USER_AVATAR%</a></span>%END_WHILE%</div>' );
1279
+
1280
+ $inner_template = wp_ulike_get_template_between( $get_template, "%START_WHILE%", "%END_WHILE%" );
1281
+
1282
+ foreach ( $get_users as $get_user ) {
1283
+ $user_info = get_userdata( $get_user->user_id );
1284
+ $out_template = $inner_template;
1285
+ if ( $user_info ):
1286
+ if( strpos( $out_template, '%USER_AVATAR%' ) !== false ) {
1287
+ $avatar_size = wp_ulike_get_setting( $setting_key, 'users_liked_box_avatar_size' );
1288
+ $USER_AVATAR = get_avatar( $user_info->user_email, $avatar_size, '' , 'avatar' );
1289
+ $out_template = str_replace( "%USER_AVATAR%", $USER_AVATAR, $out_template );
1290
+ }
1291
+ if( strpos( $out_template, '%USER_NAME%' ) !== false) {
1292
+ $USER_NAME = $user_info->display_name;
1293
+ $out_template = str_replace( "%USER_NAME%", $USER_NAME, $out_template );
1294
+ }
1295
+ if( strpos( $out_template, '%UM_PROFILE_URL%' ) !== false && function_exists('um_fetch_user') ) {
1296
+ global $ultimatemember;
1297
+ um_fetch_user( $user_info->ID );
1298
+ $UM_PROFILE_URL = um_user_profile_url();
1299
+ $out_template = str_replace( "%UM_PROFILE_URL%", $UM_PROFILE_URL, $out_template );
1300
+ }
1301
+ if( strpos( $out_template, '%BP_PROFILE_URL%' ) !== false && function_exists('bp_core_get_user_domain') ) {
1302
+ $BP_PROFILE_URL = bp_core_get_user_domain( $user_info->ID );
1303
+ $out_template = str_replace( "%BP_PROFILE_URL%", $BP_PROFILE_URL, $out_template );
1304
+ }
1305
+ $users_list .= $out_template;
1306
+ endif;
1307
+ }
1308
 
1309
+ if( ! empty( $users_list ) ) {
1310
+ return wp_ulike_put_template_between( $get_template, $users_list, "%START_WHILE%", "%END_WHILE%" );
1311
+ }
1312
  }
 
1313
 
1314
+ return NULL;
1315
+ }
1316
  }
1317
 
1318
  /**
1325
  * @since 2.0
1326
  * @return String
1327
  */
1328
+ if( ! function_exists( 'wp_ulike_get_template_between' ) ){
1329
+ function wp_ulike_get_template_between( $string, $start, $end ){
1330
+ $string = " ".$string;
1331
+ $ini = strpos($string,$start);
1332
+ if ( $ini == 0 ){
1333
+ return "";
1334
+ }
1335
+ $ini += strlen($start);
1336
+ $len = strpos($string,$end,$ini) - $ini;
1337
 
1338
+ return substr( $string, $ini, $len );
1339
+ }
1340
  }
1341
 
1342
  /**
1350
  * @since 2.0
1351
  * @return String
1352
  */
1353
+ if( ! function_exists( 'wp_ulike_put_template_between' ) ){
1354
+ function wp_ulike_put_template_between( $string, $inner_string, $start, $end ){
1355
+ $string = " ".$string;
1356
+ $ini = strpos($string,$start);
1357
+ if ($ini == 0){
1358
+ return "";
1359
+ }
1360
 
1361
+ $ini += strlen($start);
1362
+ $len = strpos($string,$end,$ini) - $ini;
1363
+ $newstr = substr_replace($string,$inner_string,$ini,$len);
1364
 
1365
+ return str_replace(
1366
+ array( "%START_WHILE%", "%END_WHILE%" ),
1367
+ array( "", "" ),
1368
+ $newstr
1369
+ );
1370
+ }
1371
  }
1372
 
1373
  /**
1524
  * @since 3.4
1525
  * @return String
1526
  */
1527
+ if( ! function_exists( 'wp_ulike_generate_user_id' ) ){
1528
+ function wp_ulike_generate_user_id( $user_ip ) {
 
 
 
 
 
 
 
 
 
1529
 
1530
+ if( filter_var( $user_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
1531
+ return ip2long( $user_ip );
1532
+ } else {
1533
+ $binary_val = '';
1534
+ foreach ( unpack( 'C*', inet_pton( $user_ip ) ) as $byte ) {
1535
+ $binary_val .= decbin( $byte );
1536
+ }
1537
+ return base_convert( ltrim( $binary_val, '0' ), 2, 10 );
1538
+ }
1539
+
1540
+ }
1541
  }
1542
 
1543
  /*******************************************************
inc/general-hooks.php CHANGED
@@ -293,7 +293,14 @@ if( defined( 'BP_VERSION' ) ) {
293
  add_action( 'bp_activity_entry_content', 'wp_ulike_put_buddypress' );
294
  // Add wp ulike in buddpress comments
295
  if( $display_comments == '1' ) {
296
- add_filter( 'bp_activity_comment_content', function( $content ) { return $content . wp_ulike_buddypress('put'); } );
 
 
 
 
 
 
 
297
  }
298
  }
299
  }
293
  add_action( 'bp_activity_entry_content', 'wp_ulike_put_buddypress' );
294
  // Add wp ulike in buddpress comments
295
  if( $display_comments == '1' ) {
296
+ add_filter( 'bp_get_activity_content', function( $content ) {
297
+ // We've changed thhe 'bp_activity_comment_content' hook for making some ajax issues on inserting activity
298
+ // If doing ajax, do not update it value
299
+ // if( wp_doing_ajax() ) {
300
+ // return $content;
301
+ // }
302
+ return $content . wp_ulike_buddypress('put');
303
+ } );
304
  }
305
  }
306
  }
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: alimir
3
  Donate link: https://m.do.co/c/13ad5bc24738
4
  Author: Ali Mirzaei
5
  Tags: wp ulike, wordpress youlike plugin, like button, rating, vote, voting, most liked posts, wordpress like page, wordpress like post, wordpress vote page, wordpress vote post, wp like page, wp like post, wp like plugin, buddypress like system, buddypress votes, comment like system, voting button, wordpress, buddypress, statistics, stats likes, bbpress, bbPress like, WP-Translations, forums, community, credit, points, mycred, users, ultimate member
6
- Requires at least: 3.5.1
7
  Tested up to: 4.9.8
8
- Stable tag: 3.5.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -174,6 +174,12 @@ define( 'WP_MEMORY_LIMIT', '256M' );
174
 
175
  == Changelog ==
176
 
 
 
 
 
 
 
177
  = 3.5.1 =
178
  * Fixed: The buddypress notifications issue.
179
  * Added: A new option to disable popover on likers box and make it inline display.
@@ -191,7 +197,7 @@ define( 'WP_MEMORY_LIMIT', '256M' );
191
  * Fixed: Some issues in button styles.
192
  * Fixed: Some issues in ulike js functionality.
193
  * Fixed: An issue with supporting ulike in ultimatememeber.
194
- * Fixed: Colorpicker issue in admin settings by replacing the wpColorPicker with spectrum plugin.
195
 
196
  = 3.4 =
197
  * Added: A new style for likers box with pophover effect.
@@ -494,6 +500,9 @@ define( 'WP_MEMORY_LIMIT', '256M' );
494
 
495
  == Upgrade Notice ==
496
 
 
 
 
497
  = 3.5.1 =
498
  Attention Please! In this version, we have made some changes on plugin scripts! So, please clear your server cache after the plugin update.
499
 
3
  Donate link: https://m.do.co/c/13ad5bc24738
4
  Author: Ali Mirzaei
5
  Tags: wp ulike, wordpress youlike plugin, like button, rating, vote, voting, most liked posts, wordpress like page, wordpress like post, wordpress vote page, wordpress vote post, wp like page, wp like post, wp like plugin, buddypress like system, buddypress votes, comment like system, voting button, wordpress, buddypress, statistics, stats likes, bbpress, bbPress like, WP-Translations, forums, community, credit, points, mycred, users, ultimate member
6
+ Requires at least: 3.5.0
7
  Tested up to: 4.9.8
8
+ Stable tag: 3.5.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
174
 
175
  == Changelog ==
176
 
177
+ = 3.5.2 =
178
+ * Fixed: An important issue with buddypress comments.
179
+ * Added: Class name issue on likers box.
180
+ * Upgraded: "WordpressUlike" js functionality.
181
+ * Added: some improvements on general functions.
182
+
183
  = 3.5.1 =
184
  * Fixed: The buddypress notifications issue.
185
  * Added: A new option to disable popover on likers box and make it inline display.
197
  * Fixed: Some issues in button styles.
198
  * Fixed: Some issues in ulike js functionality.
199
  * Fixed: An issue with supporting ulike in ultimatememeber.
200
+ * Fixed: Colorpicker issue in admin settings by replacing the wpColorPicker with spectrum plugin.
201
 
202
  = 3.4 =
203
  * Added: A new style for likers box with pophover effect.
500
 
501
  == Upgrade Notice ==
502
 
503
+ = 3.5.2 =
504
+ Attention Please! In this version, we have made some changes on plugin scripts! So, please clear your server cache after the plugin update.
505
+
506
  = 3.5.1 =
507
  Attention Please! In this version, we have made some changes on plugin scripts! So, please clear your server cache after the plugin update.
508
 
wp-ulike.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: WP ULike
11
  * Plugin URI: https://wpulike.com/
12
  * Description: WP ULike plugin allows to integrate a beautiful Ajax Like Button into your wordPress website to allow your visitors to like and unlike pages, posts, comments AND buddypress activities. Its very simple to use and supports many options.
13
- * Version: 3.5.1
14
  * Author: Ali Mirzaei
15
  * Author URI: http://alimir.ir
16
  * Text Domain: wp-ulike
@@ -36,7 +36,7 @@
36
 
37
  // Do not change these values
38
  define( 'WP_ULIKE_PLUGIN_URI' , 'https://wpulike.com/' );
39
- define( 'WP_ULIKE_VERSION' , '3.5.1' );
40
  define( 'WP_ULIKE_SLUG' , 'wp-ulike' );
41
  define( 'WP_ULIKE_DB_VERSION' , '1.5' );
42
 
10
  * Plugin Name: WP ULike
11
  * Plugin URI: https://wpulike.com/
12
  * Description: WP ULike plugin allows to integrate a beautiful Ajax Like Button into your wordPress website to allow your visitors to like and unlike pages, posts, comments AND buddypress activities. Its very simple to use and supports many options.
13
+ * Version: 3.5.2
14
  * Author: Ali Mirzaei
15
  * Author URI: http://alimir.ir
16
  * Text Domain: wp-ulike
36
 
37
  // Do not change these values
38
  define( 'WP_ULIKE_PLUGIN_URI' , 'https://wpulike.com/' );
39
+ define( 'WP_ULIKE_VERSION' , '3.5.2' );
40
  define( 'WP_ULIKE_SLUG' , 'wp-ulike' );
41
  define( 'WP_ULIKE_DB_VERSION' , '1.5' );
42