WP ULike - Version 3.3

Version Description

  • Added: AJAX refresh for likers box.
  • Added: Anonymize IP option for GDPR compliance.
  • Updated: Core functionalities.
  • Updated: Settings panel.
  • Fixed: Some important bugs.
Download this release

Release Info

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

Code changes from version 3.2 to 3.3

admin/admin-ajax.php CHANGED
@@ -14,10 +14,10 @@
14
  /**
15
  * AJAX handler to store the state of dismissible notices.
16
  *
17
- * @author Alimir
18
  * @since 2.9
19
  * @return Void
20
- */
21
  function wp_ulike_ajax_notice_handler() {
22
  // Store it in the options table
23
  update_option( 'wp-ulike-notice-dismissed', TRUE );
@@ -27,7 +27,7 @@ add_action( 'wp_ajax_wp_ulike_dismissed_notice', 'wp_ulike_ajax_notice_handler'
27
  /**
28
  * Remove logs from tables
29
  *
30
- * @author Alimir
31
  * @since 2.1
32
  * @return Void
33
  */
14
  /**
15
  * AJAX handler to store the state of dismissible notices.
16
  *
17
+ * @author Alimir
18
  * @since 2.9
19
  * @return Void
20
+ */
21
  function wp_ulike_ajax_notice_handler() {
22
  // Store it in the options table
23
  update_option( 'wp-ulike-notice-dismissed', TRUE );
27
  /**
28
  * Remove logs from tables
29
  *
30
+ * @author Alimir
31
  * @since 2.1
32
  * @return Void
33
  */
admin/admin-functions.php CHANGED
@@ -9,41 +9,41 @@
9
 
10
  /*******************************************************
11
  About Page
12
- *******************************************************/
13
 
14
  /**
15
  * Create WP ULike About page
16
  *
17
- * @author Alimir
18
  * @since 1.7
19
  * @return String
20
- */
21
  function wp_ulike_about_page() {
22
  ?>
23
  <div class="wrap about-wrap wp-ulike-about-page">
24
 
25
  <h1><?php echo _e( 'Welcome to WP ULike', WP_ULIKE_SLUG ) . ' ' . WP_ULIKE_VERSION; ?></h1>
26
  <div class="about-text"><?php echo _e('Thank you for choosing WP ULike! This version is our leanest and most powerful version yet.', WP_ULIKE_SLUG) ; ?><br />
27
-
28
  <?php add_thickbox(); ?>
29
  <a target="_blank" href="<?php echo WP_ULIKE_PLUGIN_URI . '?TB_iframe=true&amp;width=800&amp;height=600'; ?>" class="thickbox"> <?php _e('Visit our homepage',WP_ULIKE_SLUG); ?></a>
30
  </div>
31
  <div class="ulike-badge"><?php echo _e('Version',WP_ULIKE_SLUG) . ' ' . WP_ULIKE_VERSION; ?></div>
32
  <h2 class="nav-tab-wrapper">
33
- <a class="nav-tab <?php if(!isset($_GET["credit"])) echo 'nav-tab-active'; ?>" href="admin.php?page=wp-ulike-about"><?php echo _e('Getting Started',WP_ULIKE_SLUG); ?></a>
34
- <a class="nav-tab <?php if(isset($_GET["credit"])) echo 'nav-tab-active'; ?>" href="admin.php?page=wp-ulike-about&credit=true"><?php echo _e('Credits',WP_ULIKE_SLUG); ?></a>
35
- <a target="_blank" class="nav-tab" href="https://wordpress.org/support/plugin/wp-ulike"><?php echo _e('Support',WP_ULIKE_SLUG); ?></a>
36
- <a target="_blank" class="nav-tab" href="https://wordpress.org/plugins/wp-ulike/faq/"><?php echo _e('FAQ',WP_ULIKE_SLUG); ?></a>
37
- <a target="_blank" class="nav-tab" href="https://wordpress.org/support/view/plugin-reviews/wp-ulike"><?php echo _e('Reviews',WP_ULIKE_SLUG); ?></a>
38
  </h2>
39
-
40
  <?php if(!isset($_GET["credit"])): ?>
41
-
42
  <div class="changelog headline-feature">
43
  <h2><?php echo _e('Introducing WP ULike',WP_ULIKE_SLUG); ?> <img draggable="false" class="emoji" alt="emoji" src="https://s.w.org/images/core/emoji/2.2.1/svg/1f60a.svg"></h2>
44
  <div class="featured-image">
45
  <img alt="wp ulike intro" src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/wp-ulike-intro.png">
46
- </div>
47
 
48
  <div class="feature-section">
49
  <div class="col">
@@ -55,7 +55,7 @@ function wp_ulike_about_page() {
55
  'number' => 43,
56
  );
57
  wp_star_rating( $args ); ?>
58
- </div>
59
  <p class="lead-description"><?php echo _e('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.',WP_ULIKE_SLUG); ?></p>
60
  </div>
61
  </div>
@@ -106,26 +106,26 @@ function wp_ulike_about_page() {
106
  <h3><?php echo _e('Likers World Map',WP_ULIKE_SLUG); ?></h3>
107
  <p><?php echo _e('Since WP ULike 2.3, We have made a new ability that you can track your likers by their country in the world map & Top Liker widget.',WP_ULIKE_SLUG); ?></p>
108
  </div>
109
- </div>
110
-
111
  <div class="changelog feature-list">
112
  <div class="return-to-dashboard">
113
  <a href="admin.php?page=wp-ulike-statistics"><?php echo _e('WP ULike Statistics',WP_ULIKE_SLUG); ?> &rarr; <?php echo _e('Home',WP_ULIKE_SLUG); ?></a> <?php echo _e('OR',WP_ULIKE_SLUG); ?> <a href="admin.php?page=wp-ulike-settings"><?php echo _e('WP ULike Settings',WP_ULIKE_SLUG); ?></a>
114
  </div>
115
  </div>
116
-
117
  <?php else: ?>
118
-
119
- <p class="about-description"><?php echo _e('WP ULike is created by many love and time. Enjoy it :)',WP_ULIKE_SLUG); ?></p>
120
  <h3 class="wp-people-group"><?php echo _e('Project Leaders',WP_ULIKE_SLUG); ?></h3>
121
  <ul id="wp-people-group-project-leaders" class="wp-people-group">
122
  <li class="wp-person" id="wp-person-alimir">
123
  <a href="https://profiles.wordpress.org/alimir/"><?php echo get_avatar( 'info@alimir.ir', 64 ); ?></a>
124
  <a class="web" target="_blank" href="https://ir.linkedin.com/in/alimirir/">Ali Mirzaei</a>
125
  <span class="title"><?php echo _e('Project Lead & Developer',WP_ULIKE_SLUG); ?></span>
126
- </li>
127
  </ul>
128
-
129
  <h3 class="wp-people-group"><?php _e('Translations',WP_ULIKE_SLUG); ?></h3>
130
  <ul>
131
  <li>English (United States)</li>
@@ -164,28 +164,28 @@ function wp_ulike_about_page() {
164
  <li>Bosnian (Bosnia and Herzegovina)</li>
165
  <li>English (United Kingdom)</li>
166
  </ul>
167
-
168
- <p class="about-description"><?php _e('Would you like to help translate the plugin into more languages?',WP_ULIKE_SLUG); ?> <a target="_blank" href="https://www.transifex.com/projects/p/wp-ulike/" title"WP-Translations">[<?php _e('Join our WP-Translations Community',WP_ULIKE_SLUG); ?>]</a></p>
169
-
170
  <h3 class="wp-people-group"><?php echo _e('Other Plugins',WP_ULIKE_SLUG); ?></h3>
171
  <ul class="wp-people-group">
172
  <li class="wp-person" id="wp-person-alimirzaei">
173
  <a target="_blank" href="https://wordpress.org/plugins/blue-login-style"><img class="gravatar" src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/blue-login-themes.jpg" alt="Blue Login Themes" /></a>
174
  <a class="web" href="https://profiles.wordpress.org/alimir/">Ali Mirzaei</a>
175
  <span class="title">Blue Login Themes</span>
176
- </li>
177
  <li class="wp-person" id="wp-person-alimirzaei">
178
  <a target="_blank" href="https://wordpress.org/plugins/custom-fields-notifications/"><img class="gravatar" src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/custom-fileds-notifications.png" alt="Custom Fields Notifications" /></a>
179
  <a class="web" href="https://profiles.wordpress.org/alimir/">Ali Mirzaei</a>
180
  <span class="title">Custom Fields Notifications</span>
181
- </li>
182
  <li class="wp-person" id="wp-person-alimirzaei">
183
  <a target="_blank" href="http://wordpress.org/plugins/ajax-bootmodal-login/"><img class="gravatar" src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/ajax-bootmodal-login.jpg" alt="Ajax BootModal Login" /></a>
184
  <a class="web" href="https://profiles.wordpress.org/alimir/">Ali Mirzaei</a>
185
  <span class="title">Ajax BootModal Login</span>
186
- </li>
187
- </ul>
188
-
189
  <h3 class="wp-people-group"><?php _e('Like this plugin?',WP_ULIKE_SLUG); ?></h3>
190
  <div class="wp-ulike-notice">
191
  <img src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/wp-ulike-badge.png" alt="WP ULike Plugin">
@@ -196,29 +196,29 @@ function wp_ulike_about_page() {
196
  </p>
197
  </div>
198
  </div>
199
-
200
  <?php endif; ?>
201
-
202
  </div>
203
  <?php
204
  }
205
 
206
  /*******************************************************
207
  Logs Page
208
- *******************************************************/
209
  /**
210
  * Return per_page option value
211
  *
212
- * @author Alimir
213
  * @since 2.1
214
  * @return Integer
215
- */
216
  function wp_ulike_logs_return_per_page(){
217
  $user = get_current_user_id();
218
  $screen = get_current_screen();
219
  $option = $screen->get_option('per_page', 'option');
220
  $per_page = get_user_meta($user, $option, true);
221
-
222
  if ( empty ( $per_page) || $per_page < 1 ) {
223
  return 20;
224
  }
@@ -229,10 +229,10 @@ function wp_ulike_logs_return_per_page(){
229
  /**
230
  * Add screen option for per_page value
231
  *
232
- * @author Alimir
233
  * @since 2.1
234
  * @return String
235
- */
236
  function wp_ulike_logs_per_page() {
237
  $option = 'per_page';
238
  $args = array(
@@ -241,15 +241,15 @@ function wp_ulike_logs_per_page() {
241
  'option' => 'wp_ulike_logs_per_page'
242
  );
243
  add_screen_option( $option, $args );
244
- }
245
 
246
  /**
247
  * Create WP ULike Post Logs page with separate pagination
248
  *
249
- * @author Alimir
250
  * @since 1.7
251
  * @return String
252
- */
253
  function wp_ulike_post_likes_logs(){
254
  global $wpdb;
255
  $alternate = true;
@@ -258,22 +258,22 @@ function wp_ulike_post_likes_logs(){
258
  $p = new wp_ulike_pagination;
259
  $p->items($items);
260
  $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page
261
- $p->target("admin.php?page=wp-ulike-post-logs");
262
  $p->calculate(); // Calculates what to show
263
  $p->parameterName('page_number');
264
  $p->adjacents(1); //No. of page away from the current page
265
-
266
  if(!isset($_GET['page_number'])) {
267
  $p->page = 1;
268
  } else {
269
  $p->page = $_GET['page_number'];
270
  }
271
-
272
  //Query for limit page_number
273
  $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
274
-
275
  $get_ulike_logs = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ulike ORDER BY id DESC ".$limit."");
276
-
277
  ?>
278
  <div class="wrap">
279
  <h2><?php _e('WP ULike Logs', WP_ULIKE_SLUG); ?></h2>
@@ -299,7 +299,7 @@ function wp_ulike_post_likes_logs(){
299
  </thead>
300
  <tbody class="wp_ulike_logs">
301
  <?php
302
- foreach ( $get_ulike_logs as $get_ulike_log )
303
  {
304
  ?>
305
  <tr <?php if ($alternate == true) echo 'class="alternate"';?>>
@@ -328,20 +328,20 @@ function wp_ulike_post_likes_logs(){
328
  <?php echo $get_ulike_log->post_id; ?>
329
  </td>
330
  <td>
331
- <?php echo '<a href="'.get_permalink($get_ulike_log->post_id).'" title="'.get_the_title($get_ulike_log->post_id).'">'.get_the_title($get_ulike_log->post_id).'</a>'; ?>
332
  </td>
333
  <td>
334
  <?php
335
  echo wp_ulike_date_i18n($get_ulike_log->date_time);
336
- ?>
337
  </td>
338
  <td>
339
- <?php echo $get_ulike_log->ip; ?>
340
  </td>
341
  <td>
342
- <button class="wp_ulike_delete button" type="button" data-nonce="<?php echo wp_create_nonce( 'ulike' . $get_ulike_log->id ); ?>" data-id="<?php echo $get_ulike_log->id;?>" data-table="ulike"><i class="dashicons dashicons-trash"></i></button>
343
  </td>
344
- <?php
345
  $alternate = !$alternate;
346
  }
347
  ?>
@@ -360,11 +360,11 @@ function wp_ulike_post_likes_logs(){
360
  echo "<div class='error'><p>" . __('<strong>ERROR:</strong> No Record Found. (This problem is created because you don\'t have any data on this table)',WP_ULIKE_SLUG) . "</p></div>";
361
  }
362
  }
363
-
364
  /**
365
  * Create WP ULike Comment Logs page with separate pagination
366
  *
367
- * @author Alimir
368
  * @since 1.7
369
  * @return String
370
  */
@@ -376,20 +376,20 @@ function wp_ulike_comment_likes_logs(){
376
  $p = new wp_ulike_pagination;
377
  $p->items($items);
378
  $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page
379
- $p->target("admin.php?page=wp-ulike-comment-logs");
380
  $p->calculate(); // Calculates what to show
381
  $p->parameterName('page_number');
382
  $p->adjacents(1); //No. of page away from the current page
383
-
384
  if(!isset($_GET['page_number'])) {
385
  $p->page = 1;
386
  } else {
387
  $p->page = $_GET['page_number'];
388
  }
389
-
390
  //Query for limit page_number
391
  $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
392
-
393
  $get_ulike_logs = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ulike_comments ORDER BY id DESC ".$limit."");
394
  ?>
395
  <div class="wrap">
@@ -400,7 +400,7 @@ function wp_ulike_comment_likes_logs(){
400
  <span class="displaying-num"><?php echo $items . ' ' . __('Logs',WP_ULIKE_SLUG); ?></span>
401
  <?php echo $p->show(); // Echo out the list of paging. ?>
402
  </div>
403
- </div>
404
  <table class="widefat">
405
  <thead>
406
  <tr>
@@ -412,12 +412,12 @@ function wp_ulike_comment_likes_logs(){
412
  <th><?php _e('Comment Text', WP_ULIKE_SLUG); ?></th>
413
  <th width="20%"><?php _e('Date / Time', WP_ULIKE_SLUG); ?></th>
414
  <th><?php _e('IP', WP_ULIKE_SLUG); ?></th>
415
- <th><?php _e('Actions', WP_ULIKE_SLUG); ?></th>
416
  </tr>
417
  </thead>
418
  <tbody class="wp_ulike_logs">
419
  <?php
420
- foreach ( $get_ulike_logs as $get_ulike_log )
421
  {
422
  ?>
423
  <tr <?php if ($alternate == true) echo 'class="alternate"';?>>
@@ -446,23 +446,23 @@ function wp_ulike_comment_likes_logs(){
446
  <?php echo $get_ulike_log->comment_id; ?>
447
  </td>
448
  <td>
449
- <?php echo get_comment_author($get_ulike_log->comment_id) ?>
450
  </td>
451
  <td>
452
- <?php echo get_comment_text($get_ulike_log->comment_id) ?>
453
  </td>
454
- <td>
455
  <?php
456
- echo wp_ulike_date_i18n($get_ulike_log->date_time);
457
- ?>
458
  </td>
459
  <td>
460
- <?php echo $get_ulike_log->ip; ?>
461
  </td>
462
  <td>
463
- <button class="wp_ulike_delete button" type="button" data-nonce="<?php echo wp_create_nonce( 'ulike_comments' . $get_ulike_log->id ); ?>" data-id="<?php echo $get_ulike_log->id;?>" data-table="ulike_comments"><i class="dashicons dashicons-trash"></i></button>
464
- </td>
465
- <?php
466
  $alternate = !$alternate;
467
  }
468
  ?>
@@ -486,10 +486,10 @@ function wp_ulike_comment_likes_logs(){
486
  /**
487
  * Create WP ULike BuddyPress Logs page with separate pagination
488
  *
489
- * @author Alimir
490
  * @since 1.7
491
  * @return String
492
- */
493
  function wp_ulike_buddypress_likes_logs(){
494
 
495
  if( ! defined( 'BP_VERSION' ) ) {
@@ -504,22 +504,22 @@ function wp_ulike_buddypress_likes_logs(){
504
  $p = new wp_ulike_pagination;
505
  $p->items($items);
506
  $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page
507
- $p->target("admin.php?page=wp-ulike-bp-logs");
508
  $p->calculate(); // Calculates what to show
509
  $p->parameterName('page_number');
510
  $p->adjacents(1); //No. of page away from the current page
511
-
512
  if(!isset($_GET['page_number'])) {
513
  $p->page = 1;
514
  } else {
515
  $p->page = $_GET['page_number'];
516
  }
517
-
518
  //Query for limit page_number
519
  $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
520
-
521
  $get_ulike_logs = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ulike_activities ORDER BY id DESC ".$limit."");
522
-
523
  ?>
524
  <div class="wrap">
525
  <h2><?php _e('WP ULike Logs', WP_ULIKE_SLUG); ?></h2>
@@ -540,12 +540,12 @@ function wp_ulike_buddypress_likes_logs(){
540
  <th><?php _e('Permalink', WP_ULIKE_SLUG); ?></th>
541
  <th><?php _e('Date / Time', WP_ULIKE_SLUG); ?></th>
542
  <th><?php _e('IP', WP_ULIKE_SLUG); ?></th>
543
- <th><?php _e('Actions', WP_ULIKE_SLUG); ?></th>
544
  </tr>
545
  </thead>
546
  <tbody class="wp_ulike_logs">
547
  <?php
548
- foreach ( $get_ulike_logs as $get_ulike_log )
549
  {
550
  ?>
551
  <tr <?php if ($alternate == true) echo 'class="alternate"';?>>
@@ -578,16 +578,16 @@ function wp_ulike_buddypress_likes_logs(){
578
  </td>
579
  <td>
580
  <?php
581
- echo wp_ulike_date_i18n($get_ulike_log->date_time);
582
  ?>
583
  </td>
584
  <td>
585
- <?php echo $get_ulike_log->ip; ?>
586
  </td>
587
  <td>
588
- <button class="wp_ulike_delete button" type="button" data-nonce="<?php echo wp_create_nonce( 'ulike_activities' . $get_ulike_log->id ); ?>" data-id="<?php echo $get_ulike_log->id;?>" data-table="ulike_activities"><i class="dashicons dashicons-trash"></i></button>
589
- </td>
590
- <?php
591
  $alternate = !$alternate;
592
  }
593
  ?>
@@ -600,27 +600,27 @@ function wp_ulike_buddypress_likes_logs(){
600
  <?php echo $p->show(); // Echo out the list of paging. ?>
601
  </div>
602
  </div>
603
- </div>
604
-
605
  <?php
606
  } else {
607
  echo "<div class='error'><p>" . __('<strong>ERROR:</strong> No Record Found. (This problem is created because you don\'t have any data on this table)',WP_ULIKE_SLUG) . "</p></div>";
608
- }
609
  }
610
 
611
  /**
612
  * Create WP ULike bbPress Logs page with separate pagination
613
  *
614
- * @author Alimir
615
  * @since 2.2
616
  * @updated 2.4.2
617
  * @return String
618
- */
619
  function wp_ulike_bbpress_likes_logs(){
620
 
621
  if( ! function_exists( 'is_bbpress' ) ) {
622
  echo sprintf( '<div class="wrap">' . __( '%s is Not Activated!', WP_ULIKE_SLUG ) . '</div>' ,__( 'bbPress', WP_ULIKE_SLUG ) );
623
- return;
624
  }
625
 
626
  global $wpdb;
@@ -630,22 +630,22 @@ function wp_ulike_bbpress_likes_logs(){
630
  $p = new wp_ulike_pagination;
631
  $p->items($items);
632
  $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page
633
- $p->target("admin.php?page=wp-ulike-bbpress-logs");
634
  $p->calculate(); // Calculates what to show
635
  $p->parameterName('page_number');
636
  $p->adjacents(1); //No. of page away from the current page
637
-
638
  if(!isset($_GET['page_number'])) {
639
  $p->page = 1;
640
  } else {
641
  $p->page = $_GET['page_number'];
642
  }
643
-
644
  //Query for limit page_number
645
  $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
646
-
647
  $get_ulike_logs = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ulike_forums ORDER BY id DESC ".$limit."");
648
-
649
  ?>
650
  <div class="wrap">
651
  <h2><?php _e('WP ULike Logs', WP_ULIKE_SLUG); ?></h2>
@@ -671,7 +671,7 @@ function wp_ulike_bbpress_likes_logs(){
671
  </thead>
672
  <tbody class="wp_ulike_logs">
673
  <?php
674
- foreach ( $get_ulike_logs as $get_ulike_log )
675
  {
676
  ?>
677
  <tr <?php if ($alternate == true) echo 'class="alternate"';?>>
@@ -700,20 +700,20 @@ function wp_ulike_bbpress_likes_logs(){
700
  <?php echo $get_ulike_log->topic_id; ?>
701
  </td>
702
  <td>
703
- <?php echo '<a href="'.get_permalink($get_ulike_log->topic_id).'" title="'.get_the_title($get_ulike_log->topic_id).'">'.get_the_title($get_ulike_log->topic_id).'</a>'; ?>
704
  </td>
705
  <td>
706
  <?php
707
  echo wp_ulike_date_i18n($get_ulike_log->date_time);
708
- ?>
709
  </td>
710
  <td>
711
- <?php echo $get_ulike_log->ip; ?>
712
  </td>
713
  <td>
714
- <button class="wp_ulike_delete button" type="button" data-nonce="<?php echo wp_create_nonce( 'ulike_forums' . $get_ulike_log->id ); ?>" data-id="<?php echo $get_ulike_log->id;?>" data-table="ulike_forums"><i class="dashicons dashicons-trash"></i></button>
715
  </td>
716
- <?php
717
  $alternate = !$alternate;
718
  }
719
  ?>
@@ -727,47 +727,47 @@ function wp_ulike_bbpress_likes_logs(){
727
  </div>
728
  </div>
729
  </div>
730
-
731
  <?php
732
  } else {
733
  echo "<div class='error'><p>" . __('<strong>ERROR:</strong> No Record Found. (This problem is created because you don\'t have any data on this table)',WP_ULIKE_SLUG) . "</p></div>";
734
- }
735
  }
736
 
737
  /*******************************************************
738
  Statistics Page
739
- *******************************************************/
740
 
741
  /**
742
  * Register Screen Options
743
  *
744
- * @author Alimir
745
- * @since 2.1
746
  * @return Void
747
  */
748
  function wp_ulike_statistics_register_option(){
749
  $screen = get_current_screen();
750
  add_filter('screen_layout_columns', 'wp_ulike_statistics_display_option');
751
  $screen->add_option('wp_ulike_statistics_screen');
752
- }
753
 
754
  /**
755
  * Create WP ULike statistics with wp_ulike_stats class
756
  *
757
- * @author Alimir
758
  * @since 2.0
759
  * @return String
760
- */
761
  function wp_ulike_statistics(){
762
 
763
- global $wp_ulike_stats;
764
  $get_option = get_option( 'wp_ulike_statistics_screen' );
765
-
766
  echo '<div class="wrap">';
767
  echo '<h2>' . __( 'WP ULike Statistics', WP_ULIKE_SLUG ) . '</h2>';
768
 
769
  apply_filters( 'wp_ulike_advertisement', '__return_null' );
770
-
771
  /*******************************************************
772
  Welcome Panel
773
  *******************************************************/
@@ -808,14 +808,14 @@ function wp_ulike_statistics(){
808
  First Column
809
  *******************************************************/
810
  $total_likes = 0;
811
-
812
  echo '
813
  <div class="postbox-container" id="right-log">
814
  <div class="metabox-holder">
815
  <div class="meta-box-sortables ui-sortable">';
816
-
817
  if( isset($get_option) && $get_option['summary_like_stats'] == 1){
818
-
819
  $SummaryArr = array(
820
  "posts" => array(
821
  "id" => "posts_likes_stats",
@@ -849,8 +849,8 @@ function wp_ulike_statistics(){
849
  "dashicons" => "dashicons-admin-post",
850
  "title" => __('Topics Likes Summary',WP_ULIKE_SLUG)
851
  )
852
- );
853
-
854
  foreach ($SummaryArr as $SummaryTotal) {
855
  $total_likes += $wp_ulike_stats->get_all_data_date($SummaryTotal["table"],$SummaryTotal["key"]);
856
  }
@@ -859,62 +859,62 @@ function wp_ulike_statistics(){
859
  <div style="display: block;" class="postbox">
860
  <div class="handlediv" title="Click to toggle"><br></div>
861
  <h3 class="hndle"><span><i class="dashicons dashicons-chart-bar"></i> '.__('Summary',WP_ULIKE_SLUG).'</span></h3>
862
- <div class="inside">';
863
-
864
  foreach ($SummaryArr as $SummaryVal) {
865
-
866
  echo'<table class="widefat table-stats" id="summary-stats" width="100%"><tbody>';
867
-
868
  if($get_option[$SummaryVal['id']] == 1){
869
-
870
  if($SummaryVal["id"] == 'posts_likes_stats'){
871
  echo'
872
  <tr>
873
  <th><i class="dashicons dashicons-pressthis"></i> '.__('Total Likes',WP_ULIKE_SLUG).':</th>
874
  <th colspan="2" id="th-colspan"><span>'.$total_likes.'</span></th>
875
  </tr>';
876
- }
877
-
878
  echo'
879
 
880
  <tr>
881
  <th colspan="3" style="text-align: center; font-weight:bold;"><br><hr>'.$SummaryVal["title"].'<hr><br></th>
882
- </tr>
883
-
884
  <tr>
885
  <th><i class="dashicons dashicons-star-filled"></i> '. __('Today',WP_ULIKE_SLUG) .':</th>
886
  <th class="th-center"><span>'. $wp_ulike_stats->get_data_date($SummaryVal["type"],'today').'</span></th>
887
  </tr>
888
-
889
  <tr>
890
  <th><i class="dashicons dashicons-star-empty"></i> '. __('Yesterday',WP_ULIKE_SLUG) .':</th>
891
  <th class="th-center"><span>'. $wp_ulike_stats->get_data_date($SummaryVal["type"],'yesterday').'</span></th>
892
  </tr>
893
-
894
  <tr>
895
  <th><i class="dashicons dashicons-calendar"></i> '. __('Week',WP_ULIKE_SLUG) .':</th>
896
  <th class="th-center"><span>'. $wp_ulike_stats->get_data_date($SummaryVal["type"],'week').'</span></th>
897
  </tr>
898
-
899
  <tr>
900
  <th><i class="dashicons dashicons-flag"></i> '. __('Month',WP_ULIKE_SLUG) .':</th>
901
  <th class="th-center"><span>'. $wp_ulike_stats->get_data_date($SummaryVal["type"],'month').'</span></th>
902
  </tr>
903
-
904
  <tr>
905
  <th><i class="dashicons dashicons-chart-area"></i> '. __('Total',WP_ULIKE_SLUG) .':</th>
906
  <th class="th-center"><span>'. $wp_ulike_stats->get_all_data_date($SummaryVal["table"],$SummaryVal["key"]).'</span></th>
907
  </tr>';
908
-
909
  }
910
-
911
  echo '</tbody></table>';
912
-
913
  }
914
-
915
  echo '</div></div>';
916
  }
917
-
918
  if($get_option['likers_map'] == 1){
919
  echo '
920
  <div id="world_map" class="postbox">
@@ -929,7 +929,7 @@ function wp_ulike_statistics(){
929
  </div>
930
  </div>';
931
  }
932
-
933
  if($get_option['top_likers'] == 1){
934
  $get_top_likers = $wp_ulike_stats->get_top_likers();
935
  $top_users_counter = 1;
@@ -938,7 +938,7 @@ function wp_ulike_statistics(){
938
  <div class="handlediv" title="Click to toggle"><br></div>
939
  <h3 class="hndle"><span><i class="dashicons dashicons-awards"></i> '.__('Top Likers',WP_ULIKE_SLUG) . '</span></h3>
940
  <div class="inside">';
941
-
942
  foreach ($get_top_likers as $top_liker) {
943
  $get_top_user_id = stripslashes($top_liker->user_id);
944
  $get_top_user_info = get_userdata($get_top_user_id);
@@ -957,7 +957,7 @@ function wp_ulike_statistics(){
957
  }
958
  echo '</div></div>';
959
  }
960
-
961
  if($get_option['top_posts'] == 1){
962
  echo'
963
  <div class="postbox">
@@ -966,8 +966,8 @@ function wp_ulike_statistics(){
966
  <div class="inside"><div class="top-widget"><ol>';
967
  echo $wp_ulike_stats->get_tops('top_posts');
968
  echo '</ol></div></div></div>';
969
- }
970
-
971
  if($get_option['top_comments'] == 1){
972
  echo'
973
  <div class="postbox">
@@ -976,8 +976,8 @@ function wp_ulike_statistics(){
976
  <div class="inside"><div class="top-widget"><ol>';
977
  echo $wp_ulike_stats->get_tops('top_comments');
978
  echo '</ol></div></div></div>';
979
- }
980
-
981
  if($get_option['top_activities'] == 1){
982
  echo'
983
  <div class="postbox">
@@ -997,17 +997,17 @@ function wp_ulike_statistics(){
997
  echo $wp_ulike_stats->get_tops('top_topics');
998
  echo '</ol></div></div></div>';
999
  }
1000
-
1001
  echo '</div></div></div>';
1002
-
1003
-
1004
 
1005
  /*******************************************************
1006
  Second Column
1007
  *******************************************************/
1008
-
1009
  if(isset($get_option)){
1010
-
1011
  $ChartsArr = array(
1012
  "posts" => array(
1013
  "id" => "posts_likes_stats",
@@ -1020,7 +1020,7 @@ function wp_ulike_statistics(){
1020
  "view_logs" => ' <a style="text-decoration:none;" href="?page=wp-ulike-comment-logs" target="_blank"><i class="dashicons dashicons-visibility"></i> '. __('View Logs',WP_ULIKE_SLUG) .'</a>',
1021
  "title" => __('Comments Likes Stats',WP_ULIKE_SLUG) . ' - ' . sprintf(__('In The Last %s Days',WP_ULIKE_SLUG), $get_option['days_number']),
1022
  "chart" => "chart2"
1023
- ),
1024
  "activities" => array(
1025
  "id" => "activities_likes_stats",
1026
  "view_logs" => ' <a style="text-decoration:none;" href="?page=wp-ulike-bp-logs" target="_blank"><i class="dashicons dashicons-visibility"></i> '. __('View Logs',WP_ULIKE_SLUG) .'</a>',
@@ -1034,12 +1034,12 @@ function wp_ulike_statistics(){
1034
  "chart" => "chart4"
1035
  )
1036
  );
1037
-
1038
  echo '
1039
  <div class="postbox-container" id="left-log">
1040
  <div class="metabox-holder">
1041
- <div class="meta-box-sortables ui-sortable">';
1042
-
1043
  foreach ($ChartsArr as $ChartArr) {
1044
  if($get_option[$ChartArr['id']] == 1){
1045
  echo '
@@ -1056,7 +1056,7 @@ function wp_ulike_statistics(){
1056
  </div>';
1057
  }
1058
  }
1059
-
1060
  if($get_option['piechart_stats'] == 1){
1061
  echo '
1062
  <div id="piechart_stats" class="postbox">
@@ -1069,12 +1069,12 @@ function wp_ulike_statistics(){
1069
  </div>
1070
  </div>
1071
  </div>
1072
- </div>';
1073
  }
1074
-
1075
  echo '</div></div></div>';
1076
  }
1077
-
1078
  echo '</div>'; //end wrap class
1079
 
1080
  }
@@ -1083,10 +1083,10 @@ function wp_ulike_statistics(){
1083
  /**
1084
  * Display Screen Options
1085
  *
1086
- * @author Alimir
1087
- * @since 2.1
1088
  * @return Void
1089
- */
1090
  function wp_ulike_statistics_display_option(){
1091
  // get user options
1092
  $get_option = get_option( 'wp_ulike_statistics_screen' );
@@ -1110,7 +1110,7 @@ if( ! $get_option ){
1110
  'top_topics' => 1,
1111
  'days_number' => 20
1112
  );
1113
- update_option('wp_ulike_statistics_screen',$options);
1114
  }
1115
 
1116
  ?>
@@ -1146,17 +1146,17 @@ if( ! $get_option ){
1146
  /**
1147
  * The counter of last likes by the admin last login time.
1148
  *
1149
- * @author Alimir
1150
  * @since 2.4.2
1151
  * @return String
1152
  */
1153
  function wp_ulike_get_number_of_new_likes() {
1154
  global $wpdb;
1155
-
1156
  if( isset( $_GET["page"] ) && stripos( $_GET["page"], "wp-ulike-statistics" ) !== false && is_super_admin() ) {
1157
  update_option( 'wpulike_lastvisit', current_time( 'mysql' ) );
1158
  }
1159
-
1160
  $request = "SELECT
1161
  (SELECT COUNT(*) FROM ".$wpdb->prefix."ulike WHERE (date_time<=NOW() AND date_time>='".get_option( 'wpulike_lastvisit')."'))
1162
  +
@@ -1164,7 +1164,7 @@ function wp_ulike_get_number_of_new_likes() {
1164
  +
1165
  (SELECT COUNT(*) FROM ".$wpdb->prefix."ulike_comments WHERE (date_time<=NOW() AND date_time>='".get_option( 'wpulike_lastvisit')."'))
1166
  +
1167
- (SELECT COUNT(*) FROM ".$wpdb->prefix."ulike_forums WHERE (date_time<=NOW() AND date_time>='".get_option( 'wpulike_lastvisit')."'));";
1168
 
1169
  return $wpdb->get_var($request);
1170
- }
9
 
10
  /*******************************************************
11
  About Page
12
+ *******************************************************/
13
 
14
  /**
15
  * Create WP ULike About page
16
  *
17
+ * @author Alimir
18
  * @since 1.7
19
  * @return String
20
+ */
21
  function wp_ulike_about_page() {
22
  ?>
23
  <div class="wrap about-wrap wp-ulike-about-page">
24
 
25
  <h1><?php echo _e( 'Welcome to WP ULike', WP_ULIKE_SLUG ) . ' ' . WP_ULIKE_VERSION; ?></h1>
26
  <div class="about-text"><?php echo _e('Thank you for choosing WP ULike! This version is our leanest and most powerful version yet.', WP_ULIKE_SLUG) ; ?><br />
27
+
28
  <?php add_thickbox(); ?>
29
  <a target="_blank" href="<?php echo WP_ULIKE_PLUGIN_URI . '?TB_iframe=true&amp;width=800&amp;height=600'; ?>" class="thickbox"> <?php _e('Visit our homepage',WP_ULIKE_SLUG); ?></a>
30
  </div>
31
  <div class="ulike-badge"><?php echo _e('Version',WP_ULIKE_SLUG) . ' ' . WP_ULIKE_VERSION; ?></div>
32
  <h2 class="nav-tab-wrapper">
33
+ <a class="nav-tab <?php if(!isset($_GET["credit"])) echo 'nav-tab-active'; ?>" href="admin.php?page=wp-ulike-about"><?php echo _e('Getting Started',WP_ULIKE_SLUG); ?></a>
34
+ <a class="nav-tab <?php if(isset($_GET["credit"])) echo 'nav-tab-active'; ?>" href="admin.php?page=wp-ulike-about&credit=true"><?php echo _e('Credits',WP_ULIKE_SLUG); ?></a>
35
+ <a target="_blank" class="nav-tab" href="https://wordpress.org/support/plugin/wp-ulike"><?php echo _e('Support',WP_ULIKE_SLUG); ?></a>
36
+ <a target="_blank" class="nav-tab" href="https://wordpress.org/plugins/wp-ulike/faq/"><?php echo _e('FAQ',WP_ULIKE_SLUG); ?></a>
37
+ <a target="_blank" class="nav-tab" href="https://wordpress.org/support/view/plugin-reviews/wp-ulike"><?php echo _e('Reviews',WP_ULIKE_SLUG); ?></a>
38
  </h2>
39
+
40
  <?php if(!isset($_GET["credit"])): ?>
41
+
42
  <div class="changelog headline-feature">
43
  <h2><?php echo _e('Introducing WP ULike',WP_ULIKE_SLUG); ?> <img draggable="false" class="emoji" alt="emoji" src="https://s.w.org/images/core/emoji/2.2.1/svg/1f60a.svg"></h2>
44
  <div class="featured-image">
45
  <img alt="wp ulike intro" src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/wp-ulike-intro.png">
46
+ </div>
47
 
48
  <div class="feature-section">
49
  <div class="col">
55
  'number' => 43,
56
  );
57
  wp_star_rating( $args ); ?>
58
+ </div>
59
  <p class="lead-description"><?php echo _e('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.',WP_ULIKE_SLUG); ?></p>
60
  </div>
61
  </div>
106
  <h3><?php echo _e('Likers World Map',WP_ULIKE_SLUG); ?></h3>
107
  <p><?php echo _e('Since WP ULike 2.3, We have made a new ability that you can track your likers by their country in the world map & Top Liker widget.',WP_ULIKE_SLUG); ?></p>
108
  </div>
109
+ </div>
110
+
111
  <div class="changelog feature-list">
112
  <div class="return-to-dashboard">
113
  <a href="admin.php?page=wp-ulike-statistics"><?php echo _e('WP ULike Statistics',WP_ULIKE_SLUG); ?> &rarr; <?php echo _e('Home',WP_ULIKE_SLUG); ?></a> <?php echo _e('OR',WP_ULIKE_SLUG); ?> <a href="admin.php?page=wp-ulike-settings"><?php echo _e('WP ULike Settings',WP_ULIKE_SLUG); ?></a>
114
  </div>
115
  </div>
116
+
117
  <?php else: ?>
118
+
119
+ <p class="about-description"><?php echo _e('WP ULike is created by many love and time. Enjoy it :)',WP_ULIKE_SLUG); ?></p>
120
  <h3 class="wp-people-group"><?php echo _e('Project Leaders',WP_ULIKE_SLUG); ?></h3>
121
  <ul id="wp-people-group-project-leaders" class="wp-people-group">
122
  <li class="wp-person" id="wp-person-alimir">
123
  <a href="https://profiles.wordpress.org/alimir/"><?php echo get_avatar( 'info@alimir.ir', 64 ); ?></a>
124
  <a class="web" target="_blank" href="https://ir.linkedin.com/in/alimirir/">Ali Mirzaei</a>
125
  <span class="title"><?php echo _e('Project Lead & Developer',WP_ULIKE_SLUG); ?></span>
126
+ </li>
127
  </ul>
128
+
129
  <h3 class="wp-people-group"><?php _e('Translations',WP_ULIKE_SLUG); ?></h3>
130
  <ul>
131
  <li>English (United States)</li>
164
  <li>Bosnian (Bosnia and Herzegovina)</li>
165
  <li>English (United Kingdom)</li>
166
  </ul>
167
+
168
+ <p class="about-description"><?php _e('Would you like to help translate the plugin into more languages?',WP_ULIKE_SLUG); ?> <a target="_blank" href="https://www.transifex.com/projects/p/wp-ulike/" title"WP-Translations">[<?php _e('Join our WP-Translations Community',WP_ULIKE_SLUG); ?>]</a></p>
169
+
170
  <h3 class="wp-people-group"><?php echo _e('Other Plugins',WP_ULIKE_SLUG); ?></h3>
171
  <ul class="wp-people-group">
172
  <li class="wp-person" id="wp-person-alimirzaei">
173
  <a target="_blank" href="https://wordpress.org/plugins/blue-login-style"><img class="gravatar" src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/blue-login-themes.jpg" alt="Blue Login Themes" /></a>
174
  <a class="web" href="https://profiles.wordpress.org/alimir/">Ali Mirzaei</a>
175
  <span class="title">Blue Login Themes</span>
176
+ </li>
177
  <li class="wp-person" id="wp-person-alimirzaei">
178
  <a target="_blank" href="https://wordpress.org/plugins/custom-fields-notifications/"><img class="gravatar" src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/custom-fileds-notifications.png" alt="Custom Fields Notifications" /></a>
179
  <a class="web" href="https://profiles.wordpress.org/alimir/">Ali Mirzaei</a>
180
  <span class="title">Custom Fields Notifications</span>
181
+ </li>
182
  <li class="wp-person" id="wp-person-alimirzaei">
183
  <a target="_blank" href="http://wordpress.org/plugins/ajax-bootmodal-login/"><img class="gravatar" src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/ajax-bootmodal-login.jpg" alt="Ajax BootModal Login" /></a>
184
  <a class="web" href="https://profiles.wordpress.org/alimir/">Ali Mirzaei</a>
185
  <span class="title">Ajax BootModal Login</span>
186
+ </li>
187
+ </ul>
188
+
189
  <h3 class="wp-people-group"><?php _e('Like this plugin?',WP_ULIKE_SLUG); ?></h3>
190
  <div class="wp-ulike-notice">
191
  <img src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/wp-ulike-badge.png" alt="WP ULike Plugin">
196
  </p>
197
  </div>
198
  </div>
199
+
200
  <?php endif; ?>
201
+
202
  </div>
203
  <?php
204
  }
205
 
206
  /*******************************************************
207
  Logs Page
208
+ *******************************************************/
209
  /**
210
  * Return per_page option value
211
  *
212
+ * @author Alimir
213
  * @since 2.1
214
  * @return Integer
215
+ */
216
  function wp_ulike_logs_return_per_page(){
217
  $user = get_current_user_id();
218
  $screen = get_current_screen();
219
  $option = $screen->get_option('per_page', 'option');
220
  $per_page = get_user_meta($user, $option, true);
221
+
222
  if ( empty ( $per_page) || $per_page < 1 ) {
223
  return 20;
224
  }
229
  /**
230
  * Add screen option for per_page value
231
  *
232
+ * @author Alimir
233
  * @since 2.1
234
  * @return String
235
+ */
236
  function wp_ulike_logs_per_page() {
237
  $option = 'per_page';
238
  $args = array(
241
  'option' => 'wp_ulike_logs_per_page'
242
  );
243
  add_screen_option( $option, $args );
244
+ }
245
 
246
  /**
247
  * Create WP ULike Post Logs page with separate pagination
248
  *
249
+ * @author Alimir
250
  * @since 1.7
251
  * @return String
252
+ */
253
  function wp_ulike_post_likes_logs(){
254
  global $wpdb;
255
  $alternate = true;
258
  $p = new wp_ulike_pagination;
259
  $p->items($items);
260
  $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page
261
+ $p->target("admin.php?page=wp-ulike-post-logs");
262
  $p->calculate(); // Calculates what to show
263
  $p->parameterName('page_number');
264
  $p->adjacents(1); //No. of page away from the current page
265
+
266
  if(!isset($_GET['page_number'])) {
267
  $p->page = 1;
268
  } else {
269
  $p->page = $_GET['page_number'];
270
  }
271
+
272
  //Query for limit page_number
273
  $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
274
+
275
  $get_ulike_logs = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ulike ORDER BY id DESC ".$limit."");
276
+
277
  ?>
278
  <div class="wrap">
279
  <h2><?php _e('WP ULike Logs', WP_ULIKE_SLUG); ?></h2>
299
  </thead>
300
  <tbody class="wp_ulike_logs">
301
  <?php
302
+ foreach ( $get_ulike_logs as $get_ulike_log )
303
  {
304
  ?>
305
  <tr <?php if ($alternate == true) echo 'class="alternate"';?>>
328
  <?php echo $get_ulike_log->post_id; ?>
329
  </td>
330
  <td>
331
+ <?php echo '<a href="'.get_permalink($get_ulike_log->post_id).'" title="'.get_the_title($get_ulike_log->post_id).'">'.get_the_title($get_ulike_log->post_id).'</a>'; ?>
332
  </td>
333
  <td>
334
  <?php
335
  echo wp_ulike_date_i18n($get_ulike_log->date_time);
336
+ ?>
337
  </td>
338
  <td>
339
+ <?php echo $get_ulike_log->ip; ?>
340
  </td>
341
  <td>
342
+ <button class="wp_ulike_delete button" type="button" data-nonce="<?php echo wp_create_nonce( 'ulike' . $get_ulike_log->id ); ?>" data-id="<?php echo $get_ulike_log->id;?>" data-table="ulike"><i class="dashicons dashicons-trash"></i></button>
343
  </td>
344
+ <?php
345
  $alternate = !$alternate;
346
  }
347
  ?>
360
  echo "<div class='error'><p>" . __('<strong>ERROR:</strong> No Record Found. (This problem is created because you don\'t have any data on this table)',WP_ULIKE_SLUG) . "</p></div>";
361
  }
362
  }
363
+
364
  /**
365
  * Create WP ULike Comment Logs page with separate pagination
366
  *
367
+ * @author Alimir
368
  * @since 1.7
369
  * @return String
370
  */
376
  $p = new wp_ulike_pagination;
377
  $p->items($items);
378
  $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page
379
+ $p->target("admin.php?page=wp-ulike-comment-logs");
380
  $p->calculate(); // Calculates what to show
381
  $p->parameterName('page_number');
382
  $p->adjacents(1); //No. of page away from the current page
383
+
384
  if(!isset($_GET['page_number'])) {
385
  $p->page = 1;
386
  } else {
387
  $p->page = $_GET['page_number'];
388
  }
389
+
390
  //Query for limit page_number
391
  $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
392
+
393
  $get_ulike_logs = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ulike_comments ORDER BY id DESC ".$limit."");
394
  ?>
395
  <div class="wrap">
400
  <span class="displaying-num"><?php echo $items . ' ' . __('Logs',WP_ULIKE_SLUG); ?></span>
401
  <?php echo $p->show(); // Echo out the list of paging. ?>
402
  </div>
403
+ </div>
404
  <table class="widefat">
405
  <thead>
406
  <tr>
412
  <th><?php _e('Comment Text', WP_ULIKE_SLUG); ?></th>
413
  <th width="20%"><?php _e('Date / Time', WP_ULIKE_SLUG); ?></th>
414
  <th><?php _e('IP', WP_ULIKE_SLUG); ?></th>
415
+ <th><?php _e('Actions', WP_ULIKE_SLUG); ?></th>
416
  </tr>
417
  </thead>
418
  <tbody class="wp_ulike_logs">
419
  <?php
420
+ foreach ( $get_ulike_logs as $get_ulike_log )
421
  {
422
  ?>
423
  <tr <?php if ($alternate == true) echo 'class="alternate"';?>>
446
  <?php echo $get_ulike_log->comment_id; ?>
447
  </td>
448
  <td>
449
+ <?php echo get_comment_author($get_ulike_log->comment_id) ?>
450
  </td>
451
  <td>
452
+ <?php echo get_comment_text($get_ulike_log->comment_id) ?>
453
  </td>
454
+ <td>
455
  <?php
456
+ echo wp_ulike_date_i18n($get_ulike_log->date_time);
457
+ ?>
458
  </td>
459
  <td>
460
+ <?php echo $get_ulike_log->ip; ?>
461
  </td>
462
  <td>
463
+ <button class="wp_ulike_delete button" type="button" data-nonce="<?php echo wp_create_nonce( 'ulike_comments' . $get_ulike_log->id ); ?>" data-id="<?php echo $get_ulike_log->id;?>" data-table="ulike_comments"><i class="dashicons dashicons-trash"></i></button>
464
+ </td>
465
+ <?php
466
  $alternate = !$alternate;
467
  }
468
  ?>
486
  /**
487
  * Create WP ULike BuddyPress Logs page with separate pagination
488
  *
489
+ * @author Alimir
490
  * @since 1.7
491
  * @return String
492
+ */
493
  function wp_ulike_buddypress_likes_logs(){
494
 
495
  if( ! defined( 'BP_VERSION' ) ) {
504
  $p = new wp_ulike_pagination;
505
  $p->items($items);
506
  $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page
507
+ $p->target("admin.php?page=wp-ulike-bp-logs");
508
  $p->calculate(); // Calculates what to show
509
  $p->parameterName('page_number');
510
  $p->adjacents(1); //No. of page away from the current page
511
+
512
  if(!isset($_GET['page_number'])) {
513
  $p->page = 1;
514
  } else {
515
  $p->page = $_GET['page_number'];
516
  }
517
+
518
  //Query for limit page_number
519
  $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
520
+
521
  $get_ulike_logs = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ulike_activities ORDER BY id DESC ".$limit."");
522
+
523
  ?>
524
  <div class="wrap">
525
  <h2><?php _e('WP ULike Logs', WP_ULIKE_SLUG); ?></h2>
540
  <th><?php _e('Permalink', WP_ULIKE_SLUG); ?></th>
541
  <th><?php _e('Date / Time', WP_ULIKE_SLUG); ?></th>
542
  <th><?php _e('IP', WP_ULIKE_SLUG); ?></th>
543
+ <th><?php _e('Actions', WP_ULIKE_SLUG); ?></th>
544
  </tr>
545
  </thead>
546
  <tbody class="wp_ulike_logs">
547
  <?php
548
+ foreach ( $get_ulike_logs as $get_ulike_log )
549
  {
550
  ?>
551
  <tr <?php if ($alternate == true) echo 'class="alternate"';?>>
578
  </td>
579
  <td>
580
  <?php
581
+ echo wp_ulike_date_i18n($get_ulike_log->date_time);
582
  ?>
583
  </td>
584
  <td>
585
+ <?php echo $get_ulike_log->ip; ?>
586
  </td>
587
  <td>
588
+ <button class="wp_ulike_delete button" type="button" data-nonce="<?php echo wp_create_nonce( 'ulike_activities' . $get_ulike_log->id ); ?>" data-id="<?php echo $get_ulike_log->id;?>" data-table="ulike_activities"><i class="dashicons dashicons-trash"></i></button>
589
+ </td>
590
+ <?php
591
  $alternate = !$alternate;
592
  }
593
  ?>
600
  <?php echo $p->show(); // Echo out the list of paging. ?>
601
  </div>
602
  </div>
603
+ </div>
604
+
605
  <?php
606
  } else {
607
  echo "<div class='error'><p>" . __('<strong>ERROR:</strong> No Record Found. (This problem is created because you don\'t have any data on this table)',WP_ULIKE_SLUG) . "</p></div>";
608
+ }
609
  }
610
 
611
  /**
612
  * Create WP ULike bbPress Logs page with separate pagination
613
  *
614
+ * @author Alimir
615
  * @since 2.2
616
  * @updated 2.4.2
617
  * @return String
618
+ */
619
  function wp_ulike_bbpress_likes_logs(){
620
 
621
  if( ! function_exists( 'is_bbpress' ) ) {
622
  echo sprintf( '<div class="wrap">' . __( '%s is Not Activated!', WP_ULIKE_SLUG ) . '</div>' ,__( 'bbPress', WP_ULIKE_SLUG ) );
623
+ return;
624
  }
625
 
626
  global $wpdb;
630
  $p = new wp_ulike_pagination;
631
  $p->items($items);
632
  $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page
633
+ $p->target("admin.php?page=wp-ulike-bbpress-logs");
634
  $p->calculate(); // Calculates what to show
635
  $p->parameterName('page_number');
636
  $p->adjacents(1); //No. of page away from the current page
637
+
638
  if(!isset($_GET['page_number'])) {
639
  $p->page = 1;
640
  } else {
641
  $p->page = $_GET['page_number'];
642
  }
643
+
644
  //Query for limit page_number
645
  $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
646
+
647
  $get_ulike_logs = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ulike_forums ORDER BY id DESC ".$limit."");
648
+
649
  ?>
650
  <div class="wrap">
651
  <h2><?php _e('WP ULike Logs', WP_ULIKE_SLUG); ?></h2>
671
  </thead>
672
  <tbody class="wp_ulike_logs">
673
  <?php
674
+ foreach ( $get_ulike_logs as $get_ulike_log )
675
  {
676
  ?>
677
  <tr <?php if ($alternate == true) echo 'class="alternate"';?>>
700
  <?php echo $get_ulike_log->topic_id; ?>
701
  </td>
702
  <td>
703
+ <?php echo '<a href="'.get_permalink($get_ulike_log->topic_id).'" title="'.get_the_title($get_ulike_log->topic_id).'">'.get_the_title($get_ulike_log->topic_id).'</a>'; ?>
704
  </td>
705
  <td>
706
  <?php
707
  echo wp_ulike_date_i18n($get_ulike_log->date_time);
708
+ ?>
709
  </td>
710
  <td>
711
+ <?php echo $get_ulike_log->ip; ?>
712
  </td>
713
  <td>
714
+ <button class="wp_ulike_delete button" type="button" data-nonce="<?php echo wp_create_nonce( 'ulike_forums' . $get_ulike_log->id ); ?>" data-id="<?php echo $get_ulike_log->id;?>" data-table="ulike_forums"><i class="dashicons dashicons-trash"></i></button>
715
  </td>
716
+ <?php
717
  $alternate = !$alternate;
718
  }
719
  ?>
727
  </div>
728
  </div>
729
  </div>
730
+
731
  <?php
732
  } else {
733
  echo "<div class='error'><p>" . __('<strong>ERROR:</strong> No Record Found. (This problem is created because you don\'t have any data on this table)',WP_ULIKE_SLUG) . "</p></div>";
734
+ }
735
  }
736
 
737
  /*******************************************************
738
  Statistics Page
739
+ *******************************************************/
740
 
741
  /**
742
  * Register Screen Options
743
  *
744
+ * @author Alimir
745
+ * @since 2.1
746
  * @return Void
747
  */
748
  function wp_ulike_statistics_register_option(){
749
  $screen = get_current_screen();
750
  add_filter('screen_layout_columns', 'wp_ulike_statistics_display_option');
751
  $screen->add_option('wp_ulike_statistics_screen');
752
+ }
753
 
754
  /**
755
  * Create WP ULike statistics with wp_ulike_stats class
756
  *
757
+ * @author Alimir
758
  * @since 2.0
759
  * @return String
760
+ */
761
  function wp_ulike_statistics(){
762
 
763
+ global $wp_ulike_stats;
764
  $get_option = get_option( 'wp_ulike_statistics_screen' );
765
+
766
  echo '<div class="wrap">';
767
  echo '<h2>' . __( 'WP ULike Statistics', WP_ULIKE_SLUG ) . '</h2>';
768
 
769
  apply_filters( 'wp_ulike_advertisement', '__return_null' );
770
+
771
  /*******************************************************
772
  Welcome Panel
773
  *******************************************************/
808
  First Column
809
  *******************************************************/
810
  $total_likes = 0;
811
+
812
  echo '
813
  <div class="postbox-container" id="right-log">
814
  <div class="metabox-holder">
815
  <div class="meta-box-sortables ui-sortable">';
816
+
817
  if( isset($get_option) && $get_option['summary_like_stats'] == 1){
818
+
819
  $SummaryArr = array(
820
  "posts" => array(
821
  "id" => "posts_likes_stats",
849
  "dashicons" => "dashicons-admin-post",
850
  "title" => __('Topics Likes Summary',WP_ULIKE_SLUG)
851
  )
852
+ );
853
+
854
  foreach ($SummaryArr as $SummaryTotal) {
855
  $total_likes += $wp_ulike_stats->get_all_data_date($SummaryTotal["table"],$SummaryTotal["key"]);
856
  }
859
  <div style="display: block;" class="postbox">
860
  <div class="handlediv" title="Click to toggle"><br></div>
861
  <h3 class="hndle"><span><i class="dashicons dashicons-chart-bar"></i> '.__('Summary',WP_ULIKE_SLUG).'</span></h3>
862
+ <div class="inside">';
863
+
864
  foreach ($SummaryArr as $SummaryVal) {
865
+
866
  echo'<table class="widefat table-stats" id="summary-stats" width="100%"><tbody>';
867
+
868
  if($get_option[$SummaryVal['id']] == 1){
869
+
870
  if($SummaryVal["id"] == 'posts_likes_stats'){
871
  echo'
872
  <tr>
873
  <th><i class="dashicons dashicons-pressthis"></i> '.__('Total Likes',WP_ULIKE_SLUG).':</th>
874
  <th colspan="2" id="th-colspan"><span>'.$total_likes.'</span></th>
875
  </tr>';
876
+ }
877
+
878
  echo'
879
 
880
  <tr>
881
  <th colspan="3" style="text-align: center; font-weight:bold;"><br><hr>'.$SummaryVal["title"].'<hr><br></th>
882
+ </tr>
883
+
884
  <tr>
885
  <th><i class="dashicons dashicons-star-filled"></i> '. __('Today',WP_ULIKE_SLUG) .':</th>
886
  <th class="th-center"><span>'. $wp_ulike_stats->get_data_date($SummaryVal["type"],'today').'</span></th>
887
  </tr>
888
+
889
  <tr>
890
  <th><i class="dashicons dashicons-star-empty"></i> '. __('Yesterday',WP_ULIKE_SLUG) .':</th>
891
  <th class="th-center"><span>'. $wp_ulike_stats->get_data_date($SummaryVal["type"],'yesterday').'</span></th>
892
  </tr>
893
+
894
  <tr>
895
  <th><i class="dashicons dashicons-calendar"></i> '. __('Week',WP_ULIKE_SLUG) .':</th>
896
  <th class="th-center"><span>'. $wp_ulike_stats->get_data_date($SummaryVal["type"],'week').'</span></th>
897
  </tr>
898
+
899
  <tr>
900
  <th><i class="dashicons dashicons-flag"></i> '. __('Month',WP_ULIKE_SLUG) .':</th>
901
  <th class="th-center"><span>'. $wp_ulike_stats->get_data_date($SummaryVal["type"],'month').'</span></th>
902
  </tr>
903
+
904
  <tr>
905
  <th><i class="dashicons dashicons-chart-area"></i> '. __('Total',WP_ULIKE_SLUG) .':</th>
906
  <th class="th-center"><span>'. $wp_ulike_stats->get_all_data_date($SummaryVal["table"],$SummaryVal["key"]).'</span></th>
907
  </tr>';
908
+
909
  }
910
+
911
  echo '</tbody></table>';
912
+
913
  }
914
+
915
  echo '</div></div>';
916
  }
917
+
918
  if($get_option['likers_map'] == 1){
919
  echo '
920
  <div id="world_map" class="postbox">
929
  </div>
930
  </div>';
931
  }
932
+
933
  if($get_option['top_likers'] == 1){
934
  $get_top_likers = $wp_ulike_stats->get_top_likers();
935
  $top_users_counter = 1;
938
  <div class="handlediv" title="Click to toggle"><br></div>
939
  <h3 class="hndle"><span><i class="dashicons dashicons-awards"></i> '.__('Top Likers',WP_ULIKE_SLUG) . '</span></h3>
940
  <div class="inside">';
941
+
942
  foreach ($get_top_likers as $top_liker) {
943
  $get_top_user_id = stripslashes($top_liker->user_id);
944
  $get_top_user_info = get_userdata($get_top_user_id);
957
  }
958
  echo '</div></div>';
959
  }
960
+
961
  if($get_option['top_posts'] == 1){
962
  echo'
963
  <div class="postbox">
966
  <div class="inside"><div class="top-widget"><ol>';
967
  echo $wp_ulike_stats->get_tops('top_posts');
968
  echo '</ol></div></div></div>';
969
+ }
970
+
971
  if($get_option['top_comments'] == 1){
972
  echo'
973
  <div class="postbox">
976
  <div class="inside"><div class="top-widget"><ol>';
977
  echo $wp_ulike_stats->get_tops('top_comments');
978
  echo '</ol></div></div></div>';
979
+ }
980
+
981
  if($get_option['top_activities'] == 1){
982
  echo'
983
  <div class="postbox">
997
  echo $wp_ulike_stats->get_tops('top_topics');
998
  echo '</ol></div></div></div>';
999
  }
1000
+
1001
  echo '</div></div></div>';
1002
+
1003
+
1004
 
1005
  /*******************************************************
1006
  Second Column
1007
  *******************************************************/
1008
+
1009
  if(isset($get_option)){
1010
+
1011
  $ChartsArr = array(
1012
  "posts" => array(
1013
  "id" => "posts_likes_stats",
1020
  "view_logs" => ' <a style="text-decoration:none;" href="?page=wp-ulike-comment-logs" target="_blank"><i class="dashicons dashicons-visibility"></i> '. __('View Logs',WP_ULIKE_SLUG) .'</a>',
1021
  "title" => __('Comments Likes Stats',WP_ULIKE_SLUG) . ' - ' . sprintf(__('In The Last %s Days',WP_ULIKE_SLUG), $get_option['days_number']),
1022
  "chart" => "chart2"
1023
+ ),
1024
  "activities" => array(
1025
  "id" => "activities_likes_stats",
1026
  "view_logs" => ' <a style="text-decoration:none;" href="?page=wp-ulike-bp-logs" target="_blank"><i class="dashicons dashicons-visibility"></i> '. __('View Logs',WP_ULIKE_SLUG) .'</a>',
1034
  "chart" => "chart4"
1035
  )
1036
  );
1037
+
1038
  echo '
1039
  <div class="postbox-container" id="left-log">
1040
  <div class="metabox-holder">
1041
+ <div class="meta-box-sortables ui-sortable">';
1042
+
1043
  foreach ($ChartsArr as $ChartArr) {
1044
  if($get_option[$ChartArr['id']] == 1){
1045
  echo '
1056
  </div>';
1057
  }
1058
  }
1059
+
1060
  if($get_option['piechart_stats'] == 1){
1061
  echo '
1062
  <div id="piechart_stats" class="postbox">
1069
  </div>
1070
  </div>
1071
  </div>
1072
+ </div>';
1073
  }
1074
+
1075
  echo '</div></div></div>';
1076
  }
1077
+
1078
  echo '</div>'; //end wrap class
1079
 
1080
  }
1083
  /**
1084
  * Display Screen Options
1085
  *
1086
+ * @author Alimir
1087
+ * @since 2.1
1088
  * @return Void
1089
+ */
1090
  function wp_ulike_statistics_display_option(){
1091
  // get user options
1092
  $get_option = get_option( 'wp_ulike_statistics_screen' );
1110
  'top_topics' => 1,
1111
  'days_number' => 20
1112
  );
1113
+ update_option('wp_ulike_statistics_screen',$options);
1114
  }
1115
 
1116
  ?>
1146
  /**
1147
  * The counter of last likes by the admin last login time.
1148
  *
1149
+ * @author Alimir
1150
  * @since 2.4.2
1151
  * @return String
1152
  */
1153
  function wp_ulike_get_number_of_new_likes() {
1154
  global $wpdb;
1155
+
1156
  if( isset( $_GET["page"] ) && stripos( $_GET["page"], "wp-ulike-statistics" ) !== false && is_super_admin() ) {
1157
  update_option( 'wpulike_lastvisit', current_time( 'mysql' ) );
1158
  }
1159
+
1160
  $request = "SELECT
1161
  (SELECT COUNT(*) FROM ".$wpdb->prefix."ulike WHERE (date_time<=NOW() AND date_time>='".get_option( 'wpulike_lastvisit')."'))
1162
  +
1164
  +
1165
  (SELECT COUNT(*) FROM ".$wpdb->prefix."ulike_comments WHERE (date_time<=NOW() AND date_time>='".get_option( 'wpulike_lastvisit')."'))
1166
  +
1167
+ (SELECT COUNT(*) FROM ".$wpdb->prefix."ulike_forums WHERE (date_time<=NOW() AND date_time>='".get_option( 'wpulike_lastvisit')."'));";
1168
 
1169
  return $wpdb->get_var($request);
1170
+ }
admin/admin-hooks.php CHANGED
@@ -14,11 +14,11 @@
14
  /**
15
  * Add WP ULike CopyRight in footer
16
  *
17
- * @author Alimir
18
- * @param String $content
19
  * @since 2.0
20
  * @return String
21
- */
22
  function wp_ulike_copyright( $text ) {
23
  return sprintf( __( ' Thank you for choosing <a href="%s" title="Wordpress ULike" target="_blank">WP ULike</a>. Created by <a href="%s" title="Wordpress ULike" target="_blank">Ali Mirzaei</a>' ), 'http://wordpress.org/plugins/wp-ulike/', 'https://ir.linkedin.com/in/alimirir' );
24
  }
@@ -30,17 +30,17 @@ if( isset($_GET["page"]) && stripos($_GET["page"], "wp-ulike") !== false ) {
30
  /**
31
  * admin enqueue scripts
32
  *
33
- * @author Alimir
34
  * @since 2.1
35
  * @return Void
36
- */
37
  function wp_ulike_logs_enqueue_script( $hook ){
38
 
39
  // Enqueue admin styles
40
  wp_enqueue_style( 'wp-ulike-admin', WP_ULIKE_ADMIN_URL . '/assets/css/admin.css' );
41
 
42
  $currentScreen = get_current_screen();
43
-
44
  if ( $currentScreen->id !== $hook || ! preg_match( '/logs/', $currentScreen->id ) ) {
45
  return;
46
  }
@@ -53,36 +53,36 @@ function wp_ulike_logs_enqueue_script( $hook ){
53
  null,
54
  true
55
  );
56
-
57
  //localize script
58
  wp_localize_script( 'wp_ulike_stats', 'wp_ulike_logs', array(
59
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
60
  'message' => __('Are you sure to remove this item?!',WP_ULIKE_SLUG)
61
  ));
62
-
63
  }
64
  add_action('admin_enqueue_scripts', 'wp_ulike_logs_enqueue_script');
65
 
66
  /**
67
  * Set the option of per_page
68
  *
69
- * @author Alimir
70
  * @since 2.1
71
  * @return String
72
- */
73
  function wp_ulike_logs_per_page_set_option($status, $option, $value) {
74
  if ( 'wp_ulike_logs_per_page' == $option ) return $value;
75
  return $status;
76
- }
77
- add_filter('set-screen-option', 'wp_ulike_logs_per_page_set_option', 10, 3);
78
 
79
  /**
80
  * remove photo class from gravatar
81
  *
82
- * @author Alimir
83
  * @since 1.7
84
  * @return String
85
- */
86
  function wp_ulike_remove_photo_class($avatar) {
87
  return str_replace(' photo', ' gravatar', $avatar);
88
  }
@@ -92,10 +92,10 @@ add_filter('get_avatar', 'wp_ulike_remove_photo_class');
92
  /**
93
  * Save screen options with "update_option" mehtod
94
  *
95
- * @author Alimir
96
- * @since 2.1
97
  * @return Void
98
- */
99
  function wp_ulike_statistics_save_option(){
100
  if(isset($_POST['wp_ulike_statistics_screen']) AND wp_verify_nonce($_POST['wp_ulike_statistics_screen'], 'wp_ulike_statistics_nonce_field' ) ){
101
  $options = array(
@@ -124,49 +124,49 @@ add_action('admin_init', 'wp_ulike_statistics_save_option');
124
  /**
125
  * Add menu to admin
126
  *
127
- * @author Alimir
128
  * @since 1.0
129
  * @updated 2.2
130
  * @updated 2.4.2
131
  * @return String
132
  */
133
  function wp_ulike_admin_menu() {
134
-
135
  global $menu;
136
-
137
  //Post Like Logs Menu
138
  $posts_screen = add_submenu_page(null, __( 'Post Likes Logs', WP_ULIKE_SLUG ), __( 'Post Likes Logs', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-post-logs', 'wp_ulike_post_likes_logs');
139
  add_action("load-$posts_screen",'wp_ulike_logs_per_page');
140
-
141
  //Comment Like Logs Menu
142
  $comments_screen = add_submenu_page(null, __( 'Comment Likes Logs', WP_ULIKE_SLUG ), __( 'Comment Likes Logs', WP_ULIKE_SLUG ), 'manage_options','wp-ulike-comment-logs', 'wp_ulike_comment_likes_logs');
143
  add_action("load-$comments_screen",'wp_ulike_logs_per_page');
144
-
145
  //Activity Like Logs Menu
146
  $activities_screen = add_submenu_page(null, __( 'Activity Likes Logs', WP_ULIKE_SLUG ), __( 'Activity Likes Logs', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-bp-logs', 'wp_ulike_buddypress_likes_logs');
147
  add_action("load-$activities_screen",'wp_ulike_logs_per_page');
148
-
149
  //Activity Like Logs Menu
150
  $topics_screen = add_submenu_page(null, __( 'Topics Likes Logs', WP_ULIKE_SLUG ), __( 'Topics Likes Logs', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-bbpress-logs', 'wp_ulike_bbpress_likes_logs');
151
  add_action("load-$topics_screen",'wp_ulike_logs_per_page');
152
-
153
  //Statistics Menu
154
  $statistics_screen = add_submenu_page('wp-ulike-settings', __( 'WP ULike Statistics', WP_ULIKE_SLUG ), __( 'WP ULike Statistics', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-statistics', 'wp_ulike_statistics');
155
  add_action("load-$statistics_screen",'wp_ulike_statistics_register_option');
156
-
157
  //WP ULike About Menu
158
  add_submenu_page('wp-ulike-settings', __( 'About WP ULike', WP_ULIKE_SLUG ), __( 'About WP ULike', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-about', 'wp_ulike_about_page');
159
-
160
  $newvotes = wp_ulike_get_number_of_new_likes();
161
  $menu[313][0] .= $newvotes ? " <span class='update-plugins count-1'><span class='update-count'>". number_format_i18n($newvotes) ."</span></span> " : '';
162
-
163
  }
164
  add_action('admin_menu', 'wp_ulike_admin_menu');
165
 
166
  /**
167
  * Set the admin login time.
168
  *
169
- * @author Alimir
170
  * @since 2.4.2
171
  * @return Void
172
  */
@@ -181,10 +181,10 @@ add_action('wp_logout', 'wp_ulike_set_lastvisit');
181
  /**
182
  * Add rating us notification on wp-ulike admin pages
183
  *
184
- * @author Alimir
185
  * @since 2.7
186
  * @return String
187
- */
188
  function wp_ulike_admin_notice() {
189
  if( get_option( 'wp-ulike-notice-dismissed', FALSE ) ) return;
190
  ?>
@@ -196,7 +196,7 @@ function wp_ulike_admin_notice() {
196
  action: 'wp_ulike_dismissed_notice'
197
  }
198
  })
199
- });
200
  </script>
201
  <div class="notice wp-ulike-notice is-dismissible">
202
  <img src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/wp-ulike-badge.png" alt="WP ULike Plugin">
@@ -206,7 +206,7 @@ function wp_ulike_admin_notice() {
206
  <a href="https://wordpress.org/support/plugin/wp-ulike/reviews/?filter=5" target="_blank"><?php echo _e( "Sure, I'd love to!", WP_ULIKE_SLUG ); ?></a>
207
  </p>
208
  </div>
209
- </div>
210
  <?php
211
  }
212
  add_action( 'admin_notices', 'wp_ulike_admin_notice', 999);
@@ -214,10 +214,10 @@ add_action( 'admin_notices', 'wp_ulike_admin_notice', 999);
214
  /**
215
  * Simple Ads
216
  *
217
- * @author Alimir
218
  * @since 3.1
219
  * @return String
220
- */
221
  function wp_ulike_advertisement(){
222
  ?>
223
  <div class="welcome-panel wp-ulike-advertisement">
14
  /**
15
  * Add WP ULike CopyRight in footer
16
  *
17
+ * @author Alimir
18
+ * @param String $content
19
  * @since 2.0
20
  * @return String
21
+ */
22
  function wp_ulike_copyright( $text ) {
23
  return sprintf( __( ' Thank you for choosing <a href="%s" title="Wordpress ULike" target="_blank">WP ULike</a>. Created by <a href="%s" title="Wordpress ULike" target="_blank">Ali Mirzaei</a>' ), 'http://wordpress.org/plugins/wp-ulike/', 'https://ir.linkedin.com/in/alimirir' );
24
  }
30
  /**
31
  * admin enqueue scripts
32
  *
33
+ * @author Alimir
34
  * @since 2.1
35
  * @return Void
36
+ */
37
  function wp_ulike_logs_enqueue_script( $hook ){
38
 
39
  // Enqueue admin styles
40
  wp_enqueue_style( 'wp-ulike-admin', WP_ULIKE_ADMIN_URL . '/assets/css/admin.css' );
41
 
42
  $currentScreen = get_current_screen();
43
+
44
  if ( $currentScreen->id !== $hook || ! preg_match( '/logs/', $currentScreen->id ) ) {
45
  return;
46
  }
53
  null,
54
  true
55
  );
56
+
57
  //localize script
58
  wp_localize_script( 'wp_ulike_stats', 'wp_ulike_logs', array(
59
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
60
  'message' => __('Are you sure to remove this item?!',WP_ULIKE_SLUG)
61
  ));
62
+
63
  }
64
  add_action('admin_enqueue_scripts', 'wp_ulike_logs_enqueue_script');
65
 
66
  /**
67
  * Set the option of per_page
68
  *
69
+ * @author Alimir
70
  * @since 2.1
71
  * @return String
72
+ */
73
  function wp_ulike_logs_per_page_set_option($status, $option, $value) {
74
  if ( 'wp_ulike_logs_per_page' == $option ) return $value;
75
  return $status;
76
+ }
77
+ add_filter('set-screen-option', 'wp_ulike_logs_per_page_set_option', 10, 3);
78
 
79
  /**
80
  * remove photo class from gravatar
81
  *
82
+ * @author Alimir
83
  * @since 1.7
84
  * @return String
85
+ */
86
  function wp_ulike_remove_photo_class($avatar) {
87
  return str_replace(' photo', ' gravatar', $avatar);
88
  }
92
  /**
93
  * Save screen options with "update_option" mehtod
94
  *
95
+ * @author Alimir
96
+ * @since 2.1
97
  * @return Void
98
+ */
99
  function wp_ulike_statistics_save_option(){
100
  if(isset($_POST['wp_ulike_statistics_screen']) AND wp_verify_nonce($_POST['wp_ulike_statistics_screen'], 'wp_ulike_statistics_nonce_field' ) ){
101
  $options = array(
124
  /**
125
  * Add menu to admin
126
  *
127
+ * @author Alimir
128
  * @since 1.0
129
  * @updated 2.2
130
  * @updated 2.4.2
131
  * @return String
132
  */
133
  function wp_ulike_admin_menu() {
134
+
135
  global $menu;
136
+
137
  //Post Like Logs Menu
138
  $posts_screen = add_submenu_page(null, __( 'Post Likes Logs', WP_ULIKE_SLUG ), __( 'Post Likes Logs', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-post-logs', 'wp_ulike_post_likes_logs');
139
  add_action("load-$posts_screen",'wp_ulike_logs_per_page');
140
+
141
  //Comment Like Logs Menu
142
  $comments_screen = add_submenu_page(null, __( 'Comment Likes Logs', WP_ULIKE_SLUG ), __( 'Comment Likes Logs', WP_ULIKE_SLUG ), 'manage_options','wp-ulike-comment-logs', 'wp_ulike_comment_likes_logs');
143
  add_action("load-$comments_screen",'wp_ulike_logs_per_page');
144
+
145
  //Activity Like Logs Menu
146
  $activities_screen = add_submenu_page(null, __( 'Activity Likes Logs', WP_ULIKE_SLUG ), __( 'Activity Likes Logs', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-bp-logs', 'wp_ulike_buddypress_likes_logs');
147
  add_action("load-$activities_screen",'wp_ulike_logs_per_page');
148
+
149
  //Activity Like Logs Menu
150
  $topics_screen = add_submenu_page(null, __( 'Topics Likes Logs', WP_ULIKE_SLUG ), __( 'Topics Likes Logs', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-bbpress-logs', 'wp_ulike_bbpress_likes_logs');
151
  add_action("load-$topics_screen",'wp_ulike_logs_per_page');
152
+
153
  //Statistics Menu
154
  $statistics_screen = add_submenu_page('wp-ulike-settings', __( 'WP ULike Statistics', WP_ULIKE_SLUG ), __( 'WP ULike Statistics', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-statistics', 'wp_ulike_statistics');
155
  add_action("load-$statistics_screen",'wp_ulike_statistics_register_option');
156
+
157
  //WP ULike About Menu
158
  add_submenu_page('wp-ulike-settings', __( 'About WP ULike', WP_ULIKE_SLUG ), __( 'About WP ULike', WP_ULIKE_SLUG ), 'manage_options', 'wp-ulike-about', 'wp_ulike_about_page');
159
+
160
  $newvotes = wp_ulike_get_number_of_new_likes();
161
  $menu[313][0] .= $newvotes ? " <span class='update-plugins count-1'><span class='update-count'>". number_format_i18n($newvotes) ."</span></span> " : '';
162
+
163
  }
164
  add_action('admin_menu', 'wp_ulike_admin_menu');
165
 
166
  /**
167
  * Set the admin login time.
168
  *
169
+ * @author Alimir
170
  * @since 2.4.2
171
  * @return Void
172
  */
181
  /**
182
  * Add rating us notification on wp-ulike admin pages
183
  *
184
+ * @author Alimir
185
  * @since 2.7
186
  * @return String
187
+ */
188
  function wp_ulike_admin_notice() {
189
  if( get_option( 'wp-ulike-notice-dismissed', FALSE ) ) return;
190
  ?>
196
  action: 'wp_ulike_dismissed_notice'
197
  }
198
  })
199
+ });
200
  </script>
201
  <div class="notice wp-ulike-notice is-dismissible">
202
  <img src="<?php echo WP_ULIKE_ASSETS_URL; ?>/img/wp-ulike-badge.png" alt="WP ULike Plugin">
206
  <a href="https://wordpress.org/support/plugin/wp-ulike/reviews/?filter=5" target="_blank"><?php echo _e( "Sure, I'd love to!", WP_ULIKE_SLUG ); ?></a>
207
  </p>
208
  </div>
209
+ </div>
210
  <?php
211
  }
212
  add_action( 'admin_notices', 'wp_ulike_admin_notice', 999);
214
  /**
215
  * Simple Ads
216
  *
217
+ * @author Alimir
218
  * @since 3.1
219
  * @return String
220
+ */
221
  function wp_ulike_advertisement(){
222
  ?>
223
  <div class="welcome-panel wp-ulike-advertisement">
admin/assets/css/admin.css CHANGED
@@ -1,5 +1,5 @@
1
  /*
2
- /------------------------------------------\ _ __ _ _____ _ _ _ _
3
  | | / \ | | ___ \ | |(_)| | / /
4
  | | / /\ \ | | |_/ / _| || || |/ / ___
5
  | | / / \ \ | | __/ | | | || || | / _ \
@@ -102,12 +102,10 @@ form.wp-ulike .wp-ulike-settings-tabs h2 { float: left; padding: 10px 15px; marg
102
  form.wp-ulike .wp-ulike-settings-tabs h2:hover { background-color: #f9f9f9; }
103
  form.wp-ulike .wp-ulike-settings-tabs h2:last-child { border-right: 1px solid #e0e0e0; }
104
  form.wp-ulike .wp-ulike-settings-tabs h2.active { background-color: #ffffff; border-bottom: 1px solid #fff; margin-bottom: -1px; }
105
- form.wp-ulike .visual-select .radio-img-item { padding: 5px; border: 3px solid #424242; border-radius: 5px; cursor: pointer; width: 100px; height: 45px; margin: 0 5px; }
106
- form.wp-ulike .visual-select .radio-img-item.item-checked { border-color: #F2653A; }
107
  form.wp-ulike .toggle-switch input[type=checkbox] { display: none; }
108
  form.wp-ulike .toggle-switch label { cursor: pointer; text-indent: -9999px; width: 50px; height: 30px; background: #757575; display: block; border-radius: 100px; position: relative; }
109
  form.wp-ulike .toggle-switch label:after { content: ''; position: absolute; top: 5px; left: 5px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: 0.3s; }
110
- form.wp-ulike .toggle-switch input:checked + label { background: #F2653A; }
111
  form.wp-ulike .toggle-switch input:checked + label:after { left: calc(100% - 5px); transform: translateX(-100%); }
112
 
113
  .wp-ulike-settings-tab { padding: 2em; border: 1px solid #e0e0e0; clear: both; background: #fff; }
@@ -139,6 +137,12 @@ tr.hide-label td { padding-left: 0; }
139
  .wp-ulike-notice .notice-dismiss:before { color: #ffffff !important; }
140
  .wp-ulike-notice .notice-dismiss:hover { opacity: 1; }
141
 
 
 
 
 
 
 
142
  /** Statistics Page */
143
  #right-log { width: 31%; }
144
  #right-log a { text-decoration: none; }
1
  /*
2
+ /------------------------------------------\ _ __ _ _____ _ _ _ _
3
  | | / \ | | ___ \ | |(_)| | / /
4
  | | / /\ \ | | |_/ / _| || || |/ / ___
5
  | | / / \ \ | | __/ | | | || || | / _ \
102
  form.wp-ulike .wp-ulike-settings-tabs h2:hover { background-color: #f9f9f9; }
103
  form.wp-ulike .wp-ulike-settings-tabs h2:last-child { border-right: 1px solid #e0e0e0; }
104
  form.wp-ulike .wp-ulike-settings-tabs h2.active { background-color: #ffffff; border-bottom: 1px solid #fff; margin-bottom: -1px; }
 
 
105
  form.wp-ulike .toggle-switch input[type=checkbox] { display: none; }
106
  form.wp-ulike .toggle-switch label { cursor: pointer; text-indent: -9999px; width: 50px; height: 30px; background: #757575; display: block; border-radius: 100px; position: relative; }
107
  form.wp-ulike .toggle-switch label:after { content: ''; position: absolute; top: 5px; left: 5px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: 0.3s; }
108
+ form.wp-ulike .toggle-switch input:checked + label { background: #0077a3; }
109
  form.wp-ulike .toggle-switch input:checked + label:after { left: calc(100% - 5px); transform: translateX(-100%); }
110
 
111
  .wp-ulike-settings-tab { padding: 2em; border: 1px solid #e0e0e0; clear: both; background: #fff; }
137
  .wp-ulike-notice .notice-dismiss:before { color: #ffffff !important; }
138
  .wp-ulike-notice .notice-dismiss:hover { opacity: 1; }
139
 
140
+ /** Visual Select */
141
+ .wp-ulike-visual-select { height: auto; display: inline-block; width: 100%; max-width: 900px; }
142
+ .wp-ulike-visual-select .radio-img-item { display: inline-block; margin-right: 10px; border: 3px solid #d8d8d8; padding: 0 10px; width: 110px; height: 60px; cursor: pointer; }
143
+ .wp-ulike-visual-select .radio-img-item.item-checked { -webkit-filter: brightness(40%) sepia(100%) hue-rotate(170deg) saturate(250%); filter: brightness(40%) sepia(100%) hue-rotate(170deg) saturate(250%); }
144
+ .wp-ulike-visual-select .radio-img-item img { display: block; clear: both; width: 100%; height: 100%; }
145
+
146
  /** Statistics Page */
147
  #right-log { width: 31%; }
148
  #right-log a { text-decoration: none; }
admin/assets/js/settings.js CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  /*!
2
  * Radio image select
3
  **/
@@ -33,7 +42,7 @@
33
  });
34
  };
35
 
36
- // Parse args..
37
  options = $.extend(defaults, options);
38
 
39
  // Start jQuery loop on elements..
@@ -76,6 +85,10 @@
76
  }
77
  })(jQuery);
78
 
 
 
 
 
79
  /*!
80
  * Settings scripts
81
  **/
@@ -234,7 +247,7 @@ jQuery(document).ready(function($) {
234
  });
235
  });
236
 
237
- $('.visual-select input').radioImageSelect();
238
 
239
  $('.wp-ulike-settings-color').wpColorPicker();
240
 
1
+ /*! WP ULike - v3.3
2
+ * https://wpulike.com
3
+ * Alimir 2018;
4
+ */
5
+
6
+
7
+ /* ================== admin/assets/js/src/settings/visual-select.js =================== */
8
+
9
+
10
  /*!
11
  * Radio image select
12
  **/
42
  });
43
  };
44
 
45
+ // Parse args..
46
  options = $.extend(defaults, options);
47
 
48
  // Start jQuery loop on elements..
85
  }
86
  })(jQuery);
87
 
88
+
89
+ /* ================== admin/assets/js/src/settings/panel.js =================== */
90
+
91
+
92
  /*!
93
  * Settings scripts
94
  **/
247
  });
248
  });
249
 
250
+ $('.wp-ulike-visual-select input').radioImageSelect();
251
 
252
  $('.wp-ulike-settings-color').wpColorPicker();
253
 
admin/assets/js/statistics.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! WP ULike - v3.2
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
@@ -48,7 +48,7 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
48
 
49
  $('.wp_ulike_delete').click(function(e) {
50
  e.preventDefault();
51
- var parent = $(this).closest('tr');
52
  var value = $(this).data('id');
53
  var table = $(this).data('table');
54
  var nonce = $(this).data('nonce');
@@ -65,7 +65,7 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
65
  },
66
  beforeSend:function(){
67
  parent.css("background-color","#fff59d");
68
- },
69
  success: function( response ) {
70
  if( response.success ) {
71
  parent.fadeOut(300);
@@ -74,8 +74,8 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
74
  }
75
  }
76
  });
77
- }
78
- });
79
 
80
  if ( typeof wp_ulike_statistics === "undefined" ) return;
81
 
@@ -123,7 +123,7 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
123
  borderColor : "rgba(255, 143, 0,1)",
124
  pointBackgroundColor: "rgba(255,255,255,1)",
125
  borderWidth: 1
126
-
127
  }
128
  ]
129
  };
@@ -183,7 +183,7 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
183
  "#ffca28",
184
  "#F7464A",
185
  "#66bb6a",
186
- ],
187
  }],
188
 
189
  // These labels appear in the legend and in the tooltips when hovering different arcs
@@ -192,7 +192,7 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
192
  'Comments',
193
  'Activities',
194
  'Topics',
195
- ]
196
  };
197
 
198
 
@@ -201,7 +201,7 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
201
  var activitiesChart = document.getElementById('chart3');
202
  var topicsChart = document.getElementById('chart4');
203
  var allocationChart = document.getElementById('piechart');
204
-
205
  if ( postsChart !== null ) {
206
  if( posts_dataset_var !== null ){
207
  var ctx1 = postsChart.getContext("2d");
@@ -210,12 +210,12 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
210
  type: 'line',
211
  // The data for our dataset
212
  data: posts_date
213
- });
214
  }else{
215
- document.getElementById("posts_likes_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
216
  }
217
  }
218
-
219
  if ( commentsChart !== null ) {
220
  if( comments_dataset_var !== null ){
221
  var ctx2 = commentsChart.getContext("2d");
@@ -224,12 +224,12 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
224
  type: 'line',
225
  // The data for our dataset
226
  data: comments_date
227
- });
228
  }else{
229
- document.getElementById("comments_likes_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
230
  }
231
  }
232
-
233
  if ( activitiesChart !== null ) {
234
  if( activities_dataset_var !== null ){
235
  var ctx3 = activitiesChart.getContext("2d");
@@ -238,12 +238,12 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
238
  type: 'line',
239
  // The data for our dataset
240
  data: activities_date
241
- });
242
  }else{
243
- document.getElementById("activities_likes_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
244
  }
245
  }
246
-
247
  if ( topicsChart !== null ) {
248
  if( topics_dataset_var !== null ){
249
  var ctx4 = topicsChart.getContext("2d");
@@ -252,12 +252,12 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
252
  type: 'line',
253
  // The data for our dataset
254
  data: topics_date
255
- });
256
  }else{
257
- document.getElementById("topics_likes_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
258
  }
259
  }
260
-
261
  if( allocationChart !== null ) {
262
  if( activities_dataset_var !== null || topics_dataset_var !== null || comments_dataset_var || null && posts_dataset_var || null ){
263
  var ctx5 = allocationChart.getContext("2d");
@@ -266,11 +266,11 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
266
  type: 'pie',
267
  // The data for our dataset
268
  data: pieData
269
- });
270
  }else{
271
- document.getElementById("piechart_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
272
  }
273
- }
274
 
275
  jQuery('#vmap').vectorMap({
276
  map : 'world_en',
@@ -285,10 +285,10 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
285
  normalizeFunction : 'polynomial',
286
  onLabelShow : function (event, label, code) {
287
  if(world_map_data[code] > 0) {
288
- label.append(': '+world_map_data[code]+' Users');
289
  }
290
- }
291
- });
292
 
293
  postboxes.save_state = function(){
294
  return;
@@ -297,5 +297,5 @@ jQuery.fn.vectorMap('addMap', 'world_en', {"width":950,"height":550,"paths":{"id
297
  return;
298
  };
299
  postboxes.add_postbox_toggles();
300
-
301
  })( jQuery );
1
+ /*! WP ULike - v3.3
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
48
 
49
  $('.wp_ulike_delete').click(function(e) {
50
  e.preventDefault();
51
+ var parent = $(this).closest('tr');
52
  var value = $(this).data('id');
53
  var table = $(this).data('table');
54
  var nonce = $(this).data('nonce');
65
  },
66
  beforeSend:function(){
67
  parent.css("background-color","#fff59d");
68
+ },
69
  success: function( response ) {
70
  if( response.success ) {
71
  parent.fadeOut(300);
74
  }
75
  }
76
  });
77
+ }
78
+ });
79
 
80
  if ( typeof wp_ulike_statistics === "undefined" ) return;
81
 
123
  borderColor : "rgba(255, 143, 0,1)",
124
  pointBackgroundColor: "rgba(255,255,255,1)",
125
  borderWidth: 1
126
+
127
  }
128
  ]
129
  };
183
  "#ffca28",
184
  "#F7464A",
185
  "#66bb6a",
186
+ ],
187
  }],
188
 
189
  // These labels appear in the legend and in the tooltips when hovering different arcs
192
  'Comments',
193
  'Activities',
194
  'Topics',
195
+ ]
196
  };
197
 
198
 
201
  var activitiesChart = document.getElementById('chart3');
202
  var topicsChart = document.getElementById('chart4');
203
  var allocationChart = document.getElementById('piechart');
204
+
205
  if ( postsChart !== null ) {
206
  if( posts_dataset_var !== null ){
207
  var ctx1 = postsChart.getContext("2d");
210
  type: 'line',
211
  // The data for our dataset
212
  data: posts_date
213
+ });
214
  }else{
215
+ document.getElementById("posts_likes_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
216
  }
217
  }
218
+
219
  if ( commentsChart !== null ) {
220
  if( comments_dataset_var !== null ){
221
  var ctx2 = commentsChart.getContext("2d");
224
  type: 'line',
225
  // The data for our dataset
226
  data: comments_date
227
+ });
228
  }else{
229
+ document.getElementById("comments_likes_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
230
  }
231
  }
232
+
233
  if ( activitiesChart !== null ) {
234
  if( activities_dataset_var !== null ){
235
  var ctx3 = activitiesChart.getContext("2d");
238
  type: 'line',
239
  // The data for our dataset
240
  data: activities_date
241
+ });
242
  }else{
243
+ document.getElementById("activities_likes_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
244
  }
245
  }
246
+
247
  if ( topicsChart !== null ) {
248
  if( topics_dataset_var !== null ){
249
  var ctx4 = topicsChart.getContext("2d");
252
  type: 'line',
253
  // The data for our dataset
254
  data: topics_date
255
+ });
256
  }else{
257
+ document.getElementById("topics_likes_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
258
  }
259
  }
260
+
261
  if( allocationChart !== null ) {
262
  if( activities_dataset_var !== null || topics_dataset_var !== null || comments_dataset_var || null && posts_dataset_var || null ){
263
  var ctx5 = allocationChart.getContext("2d");
266
  type: 'pie',
267
  // The data for our dataset
268
  data: pieData
269
+ });
270
  }else{
271
+ document.getElementById("piechart_stats").getElementsByClassName("main")[0].innerHTML = "No Data Found!";
272
  }
273
+ }
274
 
275
  jQuery('#vmap').vectorMap({
276
  map : 'world_en',
285
  normalizeFunction : 'polynomial',
286
  onLabelShow : function (event, label, code) {
287
  if(world_map_data[code] > 0) {
288
+ label.append(': '+world_map_data[code]+' Users');
289
  }
290
+ }
291
+ });
292
 
293
  postboxes.save_state = function(){
294
  return;
297
  return;
298
  };
299
  postboxes.add_postbox_toggles();
300
+
301
  })( jQuery );
admin/classes/class-wp-ulike-pagination.php CHANGED
@@ -14,7 +14,7 @@ if ( ! class_exists( 'wp_ulike_pagination' ) ) {
14
  /*Default values*/
15
  var $total_pages = -1;//items
16
  var $limit = null;
17
- var $target = "";
18
  var $page = 1;
19
  var $adjacents = 2;
20
  var $showCounter = false;
@@ -30,22 +30,22 @@ if ( ! class_exists( 'wp_ulike_pagination' ) ) {
30
 
31
  /*****/
32
  var $calculate = false;
33
-
34
  #Total items
35
  function items($value){$this->total_pages = (int) $value;}
36
-
37
  #how many items to show per page
38
  function limit($value){$this->limit = (int) $value;}
39
-
40
  #Page to sent the page value
41
  function target($value){$this->target = $value;}
42
-
43
  #Current page
44
  function currentPage($value){$this->page = (int) $value;}
45
-
46
  #How many adjacent pages should be shown on each side of the current page?
47
  function adjacents($value){$this->adjacents = (int) $value;}
48
-
49
  #show counter?
50
  function showCounter($value=""){$this->showCounter=($value===true)?true:false;}
51
 
@@ -68,7 +68,7 @@ if ( ! class_exists( 'wp_ulike_pagination' ) ) {
68
  }
69
  $this->urlF=$value;
70
  }
71
-
72
  var $pagination;
73
 
74
  function pagination(){}
@@ -91,7 +91,7 @@ if ( ! class_exists( 'wp_ulike_pagination' ) ) {
91
  else
92
  return "$this->target&$this->parameterName=$id";
93
  }
94
-
95
  function calculate(){
96
  $this->pagination = "";
97
  $this->calculate == true;
@@ -114,27 +114,27 @@ if ( ! class_exists( 'wp_ulike_pagination' ) ) {
114
  $error = true;
115
  }
116
  if($error)return false;
117
-
118
  $n = trim($this->nextT.' '.$this->nextI);
119
  $p = trim($this->prevI.' '.$this->prevT);
120
-
121
  /* Setup vars for query. */
122
- if($this->page)
123
  $start = ($this->page - 1) * $this->limit; //first item to display on this page
124
  else
125
  $start = 0; //if no page var is given, set start to 0
126
-
127
  /* Setup page vars for display. */
128
  $prev = $this->page - 1; //previous page is page - 1
129
  $next = $this->page + 1; //next page is page + 1
130
  $lastpage = ceil($this->total_pages/$this->limit); //lastpage is = total pages / items per page, rounded up.
131
  $lpm1 = $lastpage - 1; //last page minus 1
132
-
133
- /*
134
- Now we apply our rules and draw the pagination object.
135
  We're actually saving the code to a variable in case we want to draw it more than once.
136
  */
137
-
138
  if($lastpage > 1){
139
  if($this->page){
140
  //anterior button
@@ -143,7 +143,7 @@ if ( ! class_exists( 'wp_ulike_pagination' ) ) {
143
  else
144
  $this->pagination .= "<span class=\"disabled\">$p</span>";
145
  }
146
- //pages
147
  if ($lastpage < 7 + ($this->adjacents * 2)){//not enough pages to bother breaking it up
148
  for ($counter = 1; $counter <= $lastpage; $counter++){
149
  if ($counter == $this->page)
14
  /*Default values*/
15
  var $total_pages = -1;//items
16
  var $limit = null;
17
+ var $target = "";
18
  var $page = 1;
19
  var $adjacents = 2;
20
  var $showCounter = false;
30
 
31
  /*****/
32
  var $calculate = false;
33
+
34
  #Total items
35
  function items($value){$this->total_pages = (int) $value;}
36
+
37
  #how many items to show per page
38
  function limit($value){$this->limit = (int) $value;}
39
+
40
  #Page to sent the page value
41
  function target($value){$this->target = $value;}
42
+
43
  #Current page
44
  function currentPage($value){$this->page = (int) $value;}
45
+
46
  #How many adjacent pages should be shown on each side of the current page?
47
  function adjacents($value){$this->adjacents = (int) $value;}
48
+
49
  #show counter?
50
  function showCounter($value=""){$this->showCounter=($value===true)?true:false;}
51
 
68
  }
69
  $this->urlF=$value;
70
  }
71
+
72
  var $pagination;
73
 
74
  function pagination(){}
91
  else
92
  return "$this->target&$this->parameterName=$id";
93
  }
94
+
95
  function calculate(){
96
  $this->pagination = "";
97
  $this->calculate == true;
114
  $error = true;
115
  }
116
  if($error)return false;
117
+
118
  $n = trim($this->nextT.' '.$this->nextI);
119
  $p = trim($this->prevI.' '.$this->prevT);
120
+
121
  /* Setup vars for query. */
122
+ if($this->page)
123
  $start = ($this->page - 1) * $this->limit; //first item to display on this page
124
  else
125
  $start = 0; //if no page var is given, set start to 0
126
+
127
  /* Setup page vars for display. */
128
  $prev = $this->page - 1; //previous page is page - 1
129
  $next = $this->page + 1; //next page is page + 1
130
  $lastpage = ceil($this->total_pages/$this->limit); //lastpage is = total pages / items per page, rounded up.
131
  $lpm1 = $lastpage - 1; //last page minus 1
132
+
133
+ /*
134
+ Now we apply our rules and draw the pagination object.
135
  We're actually saving the code to a variable in case we want to draw it more than once.
136
  */
137
+
138
  if($lastpage > 1){
139
  if($this->page){
140
  //anterior button
143
  else
144
  $this->pagination .= "<span class=\"disabled\">$p</span>";
145
  }
146
+ //pages
147
  if ($lastpage < 7 + ($this->adjacents * 2)){//not enough pages to bother breaking it up
148
  for ($counter = 1; $counter <= $lastpage; $counter++){
149
  if ($counter == $this->page)
admin/classes/class-wp-ulike-settings.php CHANGED
@@ -8,11 +8,11 @@
8
  */
9
 
10
  if ( !class_exists( 'wp_ulike_settings' ) ) {
11
-
12
  class wp_ulike_settings {
13
-
14
  private $page, $title, $menu, $admin_screen, $settings = array(), $empty = true, $notices = array();
15
-
16
  public function __construct( $page = 'custom_settings', $title = null, $menu = array(), $settings = array(), $args = array() ) {
17
  $this->page = $page;
18
  $this->title = $title ? $title : __( 'Custom Settings', WP_ULIKE_SLUG );
@@ -21,7 +21,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
21
  'title' => $this->title,
22
  'capability' => 'manage_options',
23
  'icon_url' => null,
24
- 'position' => null
25
  ), $menu ) : false;
26
  $this->apply_settings( $settings );
27
  $this->args = array_merge( array(
@@ -29,24 +29,24 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
29
  'submit' => __( 'Save Settings', WP_ULIKE_SLUG ),
30
  'reset' => __( 'Reset Settings', WP_ULIKE_SLUG ),
31
  'tabs' => false,
32
- 'updated' => null
33
  ), $args );
34
  add_action( 'admin_menu', array(
35
  $this,
36
- 'admin_menu'
37
  ) );
38
  add_action( 'admin_init', array(
39
  $this,
40
- 'admin_init'
41
  ) );
42
-
43
  add_action( 'activated_plugin', array(
44
  $this,
45
- 'plugin_priority'
46
  ) );
47
  }
48
-
49
-
50
  public function create_help_screen() {
51
  $current_screen = get_current_screen();
52
  $this->admin_screen = WP_Screen::get( $current_screen );
@@ -55,36 +55,36 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
55
  'id' => 'overview_tab',
56
  'content' => '<p>' . __( '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.', WP_ULIKE_SLUG ) . '</p>' . '<p>' . '<strong>' . __( 'Logging Method', WP_ULIKE_SLUG ) . ' : </strong></p>' . '<ul>' . '<li>' . __( 'If you select <strong>"Do Not Log"</strong> method: Any data logs can\'t save, There is no limitation in the like/dislike, unlike/undislike capacity do not work', WP_ULIKE_SLUG ) . '</li>' . '<li>' . __( 'If you select <strong>"Logged By Cookie"</strong> method: Any data logs can\'t save, The like/dislike condition will be limited by SetCookie, unlike/undislike capacity do not work', WP_ULIKE_SLUG ) . '</li>' . '<li>' . __( 'If you select <strong>"Logged By IP"</strong> method: Data logs will save for all users, the convey of like/dislike condition will check by user IP', WP_ULIKE_SLUG ) . '</li>' . '<li>' . __( 'If you select <strong>"Logged By Username"</strong> method: data logs only is saved for registered users, the convey of like/dislike condition will check by username, There is no permission for guest users to unlike/undislike', WP_ULIKE_SLUG ) . '</li>
57
  </ul>' . '<p>' . '<strong>' . __( 'Template Variables', WP_ULIKE_SLUG ) . ' : </strong></p>' . '<ul>' . '<li>' . '<code>%START_WHILE%</code> : ' . __( 'Start the loop of logs', WP_ULIKE_SLUG ) . ' <span style="color:red">(' . __( 'required', WP_ULIKE_SLUG ) . ')</span></li>' . '<li>' . '<code>%END_WHILE%</code> : ' . __( 'End of the while loop', WP_ULIKE_SLUG ) . ' <span style="color:red">(' . __( 'required', WP_ULIKE_SLUG ) . ')</span></li>' . '<li>' . '<code>%USER_NAME%</code> : ' . __( 'Display the liker name', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%USER_AVATAR%</code> : ' . __( 'Display the liker avatar (By Gravatar)', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%BP_PROFILE_URL%</code> : ' . __( 'Display the BuddyPress user profile url', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%UM_PROFILE_URL%</code> : ' . __( 'Display the UltimateMemebr user profile url', WP_ULIKE_SLUG ) . '</li><hr>' . '<li>' . '<code>%POST_LIKER%</code> : ' . __( 'Display the liker name', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%POST_PERMALINK%</code> : ' . __( 'Display the permalink', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%POST_COUNT%</code> : ' . __( 'Display the likes count number', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%POST_TITLE%</code> : ' . __( 'Display the post title', WP_ULIKE_SLUG ) . '</li><hr>' . '<li>' . '<code>%COMMENT_LIKER%</code> : ' . __( 'Display the liker name', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%COMMENT_PERMALINK%</code> : ' . __( 'Display the permalink', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%COMMENT_AUTHOR%</code> : ' . __( 'Display the comment author name', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%COMMENT_COUNT%</code> : ' . __( 'Display the likes count number', WP_ULIKE_SLUG ) . '</li>' . '</ul>',
58
- 'callback' => false
59
  ) );
60
  $this->admin_screen->add_help_tab( array(
61
  'title' => __( 'Posts', WP_ULIKE_SLUG ),
62
  'id' => 'posts_tab',
63
- 'content' => '<p>' . '<strong>' . __( 'Automatic display', WP_ULIKE_SLUG ) . ' : </strong></p><ul><li>' . __( 'If you disable this option, you have to put manually this code on wordpress while loop', WP_ULIKE_SLUG ) . '<br /><code dir="ltr">&lt;?php if(function_exists(\'wp_ulike\')) wp_ulike(\'get\'); ?&gt;</code>' . '</li></ul>' . '<p>' . '<strong>' . __( 'Users Like Box Template', WP_ULIKE_SLUG ) . ' - ' . __( 'Default Template:', WP_ULIKE_SLUG ) . ' </strong></p><ul><li><code>&lt;p style="margin-top:5px"&gt; ' . __( 'Users who have LIKED this post:', WP_ULIKE_SLUG ) . '&lt;/p&gt; &lt;ul class="tiles"&gt;%START_WHILE%&lt;li&gt;&lt;a href="%BP_PROFILE_URL%" title="%USER_NAME%"&gt;%USER_AVATAR%&lt;/a&gt;&lt;/li&gt;%END_WHILE%&lt;/ul&gt;</code>' . '</li></ul>',
64
-
65
- 'callback' => false
66
  ) );
67
  $this->admin_screen->add_help_tab( array(
68
  'title' => __( 'Comments', WP_ULIKE_SLUG ),
69
  'id' => 'comments_tab',
70
- 'content' => '<p>' . '<strong>' . __( 'Automatic display', WP_ULIKE_SLUG ) . ' : </strong></p><ul><li>' . __( 'If you disable this option, you have to put manually this code on comments text', WP_ULIKE_SLUG ) . '<br /><code dir="ltr">&lt;?php if(function_exists(\'wp_ulike_comments\')) wp_ulike_comments(\'get\'); ?&gt;</code>' . '</li></ul>' . '<p>' . '<strong>' . __( 'Users Like Box Template', WP_ULIKE_SLUG ) . ' - ' . __( 'Default Template:', WP_ULIKE_SLUG ) . ' </strong></p><ul><li><code>&lt;p style="margin-top:5px"&gt; ' . __( 'Users who have LIKED this comment:', WP_ULIKE_SLUG ) . '&lt;/p&gt; &lt;ul class="tiles"&gt;%START_WHILE%&lt;li&gt;&lt;a href="%BP_PROFILE_URL%" title="%USER_NAME%"&gt;%USER_AVATAR%&lt;/a&gt;&lt;/li&gt;%END_WHILE%&lt;/ul&gt;</code>' . '</li></ul>',
71
- 'callback' => false
72
  ) );
73
  $this->admin_screen->add_help_tab( array(
74
  'title' => __( 'BuddyPress', WP_ULIKE_SLUG ),
75
  'id' => 'bp_tab',
76
- 'content' => '<p>' . '<strong>' . __( 'Automatic display', WP_ULIKE_SLUG ) . ' : </strong></p><ul><li>' . __( 'If you disable this option, you have to put manually this code on buddypres activities content', WP_ULIKE_SLUG ) . '<br /><code dir="ltr">&lt;?php if(function_exists(\'wp_ulike_buddypress\')) wp_ulike_buddypress(\'get\'); ?&gt;</code>' . '</li></ul>' . '<p>' . '<strong>' . __( 'Users Like Box Template', WP_ULIKE_SLUG ) . ' - ' . __( 'Default Template:', WP_ULIKE_SLUG ) . ' </strong></p><ul><li><code>&lt;p style="margin-top:5px"&gt; ' . __( 'Users who have liked this activity:', WP_ULIKE_SLUG ) . '&lt;/p&gt; &lt;ul class="tiles"&gt;%START_WHILE%&lt;li&gt;&lt;a href="%BP_PROFILE_URL%" title="%USER_NAME%"&gt;%USER_AVATAR%&lt;/a&gt;&lt;/li&gt;%END_WHILE%&lt;/ul&gt;</code>' . '</li></ul>' . '<p>' . '<strong>' . __( 'Post Activity Text', WP_ULIKE_SLUG ) . ' - ' . __( 'Default Template:', WP_ULIKE_SLUG ) . ' </strong></p><ul><li><code>&lt;strong&gt;%POST_LIKER%&lt;/strong&gt; liked &lt;a href="%POST_PERMALINK%" title="%POST_TITLE%"&gt;%POST_TITLE%&lt;/a&gt;. (So far, This post has &lt;span class="badge"&gt;%POST_COUNT%&lt;/span&gt; likes)</code>' . '</li></ul>' . '<p>' . '<strong>' . __( 'Comment Activity Text', WP_ULIKE_SLUG ) . ' - ' . __( 'Default Template:', WP_ULIKE_SLUG ) . ' </strong></p><ul><li><code>&lt;strong&gt;%COMMENT_LIKER%&lt;/strong&gt; liked &lt;strong&gt;%COMMENT_AUTHOR%&lt;/strong&gt; comment. (So far, %COMMENT_AUTHOR% has &lt;span class="badge"&gt;%COMMENT_COUNT%&lt;/span&gt; likes for this comment)</code>' . '</li></ul>',
77
- 'callback' => false
78
  ) );
79
  $this->admin_screen->add_help_tab( array(
80
  'title' => __( 'bbPress', WP_ULIKE_SLUG ),
81
  'id' => 'bb_tab',
82
- 'content' => '<p>' . '<strong>' . __( 'Automatic display', WP_ULIKE_SLUG ) . ' : </strong></p><ul><li>' . __( 'If you disable this option, you have to put manually this code on buddypres activities content', WP_ULIKE_SLUG ) . '<br /><code dir="ltr">&lt;?php if(function_exists(\'wp_ulike_bbpress\')) wp_ulike_bbpress(\'get\'); ?&gt;</code>' . '</li></ul>' . '<p>' . '<strong>' . __( 'Users Like Box Template', WP_ULIKE_SLUG ) . ' - ' . __( 'Default Template:', WP_ULIKE_SLUG ) . ' </strong></p><ul><li><code>&lt;p style="margin-top:5px"&gt; ' . __( 'Users who have liked this activity:', WP_ULIKE_SLUG ) . '&lt;/p&gt; &lt;ul class="tiles"&gt;%START_WHILE%&lt;li&gt;&lt;a href="%BP_PROFILE_URL%" title="%USER_NAME%"&gt;%USER_AVATAR%&lt;/a&gt;&lt;/li&gt;%END_WHILE%&lt;/ul&gt;</code>' . '</li></ul>',
83
- 'callback' => false
84
  ) );
85
  $this->admin_screen->set_help_sidebar( '<p><strong>' . __( 'For more information:' ) . '</strong></p><p><a href="https://wordpress.org/plugins/wp-ulike/faq/" target="_blank">' . __( 'FAQ', WP_ULIKE_SLUG ) . '</a></p><p><a href="https://wordpress.org/support/plugin/wp-ulike" target="_blank">' . __( 'Support', WP_ULIKE_SLUG ) . '</a></p>' );
86
  }
87
-
88
  public function apply_settings( $settings ) {
89
  if ( is_array( $settings ) ) {
90
  foreach ( $settings as $setting => $section ) {
@@ -103,7 +103,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
103
  'sanitize' => null,
104
  'attributes' => array(),
105
  'options' => null,
106
- 'action' => null
107
  ), $field );
108
  $section['fields'][$name] = $field;
109
  } //$section['fields'] as $name => $field
@@ -114,14 +114,14 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
114
  } //$settings as $setting => $section
115
  } //is_array( $settings )
116
  }
117
-
118
  public function add_notice( $message, $type = 'info' ) {
119
  $this->notices[] = array(
120
  'message' => $message,
121
- 'type' => $type
122
  );
123
  }
124
-
125
  private function get_defaults( $setting ) {
126
  $defaults = array();
127
  foreach ( $this->settings[$setting]['fields'] as $name => $field ) {
@@ -131,26 +131,26 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
131
  } //$this->settings[$setting]['fields'] as $name => $field
132
  return $defaults;
133
  }
134
-
135
  private function reset() {
136
  foreach ( $this->settings as $setting => $section ) {
137
  $_POST[$setting] = array_merge( $_POST[$setting], $this->get_defaults( $setting ) );
138
  } //$this->settings as $setting => $section
139
  add_settings_error( $this->page, 'settings_reset', __( 'Default settings have been reset.', WP_ULIKE_SLUG ), 'updated' );
140
  }
141
-
142
  public function admin_menu() {
143
  if ( $this->menu ) {
144
  if ( $this->menu['parent'] ) {
145
  $page = add_submenu_page( $this->menu['parent'], $this->title, $this->menu['title'], $this->menu['capability'], $this->page, array(
146
  $this,
147
- 'do_page'
148
  ) );
149
  } //$this->menu['parent']
150
  else {
151
  $page = add_menu_page( $this->title, $this->menu['title'], $this->menu['capability'], $this->page, array(
152
  $this,
153
- 'do_page'
154
  ), $this->menu['icon_url'], $this->menu['position'] );
155
  if ( $this->title !== $this->menu['title'] ) {
156
  add_submenu_page( $this->page, $this->title, $this->title, $this->menu['capability'], $this->page );
@@ -158,21 +158,21 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
158
  }
159
  add_action( 'load-' . $page, array(
160
  $this,
161
- 'load_page'
162
  ) );
163
  add_action( 'load-' . $page, array(
164
  &$this,
165
- 'create_help_screen'
166
  ) );
167
  } //$this->menu
168
  }
169
-
170
  public function load_page() {
171
  global $wp_settings_errors;
172
  foreach ( $this->notices as $notice ) {
173
  $wp_settings_errors[] = array_merge( $notice, array(
174
  'setting' => $this->page,
175
- 'code' => $notice['type'] . '_notice'
176
  ) );
177
  } //$this->notices as $notice
178
  if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] ) {
@@ -194,24 +194,24 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
194
  } //isset( $_GET['settings-updated'] ) && $_GET['settings-updated']
195
  add_action( 'admin_enqueue_scripts', array(
196
  __CLASS__,
197
- 'admin_enqueue_scripts'
198
  ) );
199
  }
200
-
201
  public static function admin_enqueue_scripts() {
202
  wp_enqueue_media();
203
  wp_enqueue_script( 'wp-ulike-settings', WP_ULIKE_ADMIN_URL . '/assets/js/settings.js', array(
204
  'jquery',
205
- 'wp-color-picker'
206
  ) );
207
  wp_enqueue_script( "jquery-effects-core" );
208
  wp_localize_script( 'wp-ulike-settings', 'ajax', array(
209
  'url' => admin_url( 'admin-ajax.php' ),
210
- 'spinner' => admin_url( 'images/spinner.gif' )
211
  ) );
212
  wp_enqueue_style( 'wp-color-picker' );
213
  }
214
-
215
  public function do_page() {
216
  ?>
217
  <form action="options.php" method="POST" enctype="multipart/form-data" class="wrap wp-ulike">
@@ -234,7 +234,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
234
  submit_button( $this->args['submit'], 'large primary' );
235
  if ( $this->args['reset'] ) {
236
  submit_button( $this->args['reset'], 'small', "{$this->page}_reset", true, array(
237
- 'onclick' => "return confirm('" . __( 'Do you really want to reset all these settings to their default values ?', WP_ULIKE_SLUG ) . "');"
238
  ) );
239
  } //$this->args['reset']
240
  } //!$this->empty
@@ -242,16 +242,16 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
242
  </form>
243
  <?php
244
  }
245
-
246
  public function admin_init() {
247
  foreach ( $this->settings as $setting => $section ) {
248
  register_setting( $this->page, $setting, array(
249
  $this,
250
- 'sanitize_setting'
251
  ) );
252
  add_settings_section( $setting, $section['title'], array(
253
  $this,
254
- 'do_section'
255
  ), $this->page );
256
  if ( !empty( $section['fields'] ) ) {
257
  $this->empty = false;
@@ -259,14 +259,15 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
259
  foreach ( $section['fields'] as $name => $field ) {
260
  $id = $setting . '_' . $name;
261
  $field = array_merge( array(
262
- 'id' => $id,
263
- 'name' => $setting . '[' . $name . ']',
264
- 'value' => isset( $values[$name] ) ? $values[$name] : null,
265
- 'label_for' => $field['label'] === false ? 'hidden' : $id
 
266
  ), $field );
267
  add_settings_field( $name, $field['label'], array(
268
  __CLASS__,
269
- 'do_field'
270
  ), $this->page, $setting, $field );
271
  if ( $field['type'] === 'action' && is_callable( $field['action'] ) ) {
272
  add_action( "wp_ajax_{$setting}_{$name}", $field['action'] );
@@ -278,7 +279,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
278
  $this->reset();
279
  } //isset( $_POST["{$this->page}_reset"] )
280
  }
281
-
282
  public function do_section( $args ) {
283
  extract( $args );
284
  echo "<input name='{$id}[{$this->page}_setting]' type='hidden' value='{$id}' class='wp-ulike-settings-section' />";
@@ -286,7 +287,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
286
  echo wpautop( $text );
287
  } //$text = $this->settings[$id]['description']
288
  }
289
-
290
  public static function do_field( $args ) {
291
  extract( $args );
292
  $attrs = "name='{$name}'";
@@ -308,7 +309,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
308
  echo " {$desc}";
309
  } //$desc
310
  break;
311
-
312
  case 'radio':
313
  if ( !$options ) {
314
  _e( 'No options defined.', WP_ULIKE_SLUG );
@@ -321,7 +322,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
321
  echo implode( '<br />', $options );
322
  echo "{$desc}</fieldset>";
323
  break;
324
-
325
  case 'select':
326
  if ( !$options ) {
327
  _e( 'No options defined.', WP_ULIKE_SLUG );
@@ -336,12 +337,12 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
336
  } //$options as $v => $label
337
  echo "</select>{$desc}";
338
  break;
339
-
340
  case 'visual-select':
341
  if ( !$options ) {
342
  _e( 'No options defined.', WP_ULIKE_SLUG );
343
  } //!$options
344
- echo "<fieldset class='visual-select' id='{$id}'>";
345
  foreach ( $options as $v => $label ) {
346
  $name = $label['name'];
347
  $symbol = $label['symbol'];
@@ -351,7 +352,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
351
  echo implode( '', $options );
352
  echo "{$desc}</fieldset>";
353
  break;
354
-
355
  case 'media':
356
  echo "<fieldset class='wp-ulike-settings-media' id='{$id}'><input {$attrs} type='hidden' value='{$value}' />";
357
  echo "<p><a class='button button-large wp-ulike-select-media' title='{$label}'>" . sprintf( __( 'Select %s', WP_ULIKE_SLUG ), $label ) . "</a> ";
@@ -361,11 +362,11 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
361
  } //$value
362
  echo "{$desc}</fieldset>";
363
  break;
364
-
365
  case 'textarea':
366
  echo "<textarea {$attrs} id='{$id}' class='large-text'>{$value}</textarea>{$desc}";
367
  break;
368
-
369
  case 'multi':
370
  if ( !$options ) {
371
  _e( 'No options defined.', WP_ULIKE_SLUG );
@@ -379,26 +380,26 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
379
  echo implode( '<br />', $options );
380
  echo "{$desc}</fieldset>";
381
  break;
382
-
383
  case 'action':
384
  if ( !$action ) {
385
  _e( 'No action defined.', WP_ULIKE_SLUG );
386
  } //!$action
387
  echo "<p class='wp-ulike-settings-action'><input {$attrs} id='{$id}' type='button' class='button button-large' value='{$label}' /></p>{$desc}";
388
  break;
389
-
390
  case 'color':
391
  $v = esc_attr( $value );
392
  echo "<input {$attrs} id='{$id}' type='text' value='{$v}' class='wp-ulike-settings-color' />{$desc}";
393
  break;
394
-
395
  default:
396
  $v = esc_attr( $value );
397
  echo "<input {$attrs} id='{$id}' type='{$type}' value='{$v}' class='regular-text' />{$desc}";
398
  break;
399
  } //$type
400
  }
401
-
402
  public function sanitize_setting( $inputs ) {
403
  $values = array();
404
  if ( !empty( $inputs["{$this->page}_setting"] ) ) {
@@ -413,20 +414,20 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
413
  case 'checkbox':
414
  $values[$name] = $input ? 1 : 0;
415
  break;
416
-
417
  case 'radio':
418
  case 'select':
419
  $values[$name] = sanitize_key( $input );
420
  break;
421
-
422
  case 'media':
423
  $values[$name] = absint( $input );
424
  break;
425
-
426
  case 'color':
427
  $values[$name] = preg_match( '/^#[a-f0-9]{6}$/i', $input ) ? $input : '';
428
  break;
429
-
430
  case 'textarea':
431
  $text = '';
432
  $nl = "WP-ULIKE-SETTINGS-NEW-LINE";
@@ -437,7 +438,7 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
437
  } //$lines as $line
438
  $values[$name] = trim( $text );
439
  break;
440
-
441
  case 'multi':
442
  if ( !$input || empty( $field['options'] ) ) {
443
  break;
@@ -447,22 +448,22 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
447
  } //$field['options'] as $n => $opt
448
  $values[$name] = json_encode( $input );
449
  break;
450
-
451
  case 'action':
452
  break;
453
-
454
  case 'email':
455
  $values[$name] = sanitize_email( $input );
456
  break;
457
-
458
  case 'url':
459
  $values[$name] = esc_url_raw( $input );
460
  break;
461
-
462
  case 'number':
463
  $values[$name] = floatval( $input );
464
  break;
465
-
466
  default:
467
  $values[$name] = html_entity_decode( $input );
468
  break;
@@ -473,12 +474,12 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
473
  } //!empty( $inputs["{$this->page}_setting"] )
474
  return $inputs;
475
  }
476
-
477
  public static function parse_multi( $result ) {
478
  // Check if the result was recorded as JSON, and if so, returns an array instead
479
  return ( is_string( $result ) && $array = json_decode( $result, true ) ) ? $array : $result;
480
  }
481
-
482
  public static function plugin_priority() {
483
  $wp_ulike_settings = plugin_basename( __FILE__ );
484
  $active_plugins = get_option( 'active_plugins' );
@@ -489,5 +490,5 @@ if ( !class_exists( 'wp_ulike_settings' ) ) {
489
  } //$order = array_search( $wp_ulike_settings, $active_plugins )
490
  }
491
  }
492
-
493
  } //!class_exists( 'wp_ulike_settings' )
8
  */
9
 
10
  if ( !class_exists( 'wp_ulike_settings' ) ) {
11
+
12
  class wp_ulike_settings {
13
+
14
  private $page, $title, $menu, $admin_screen, $settings = array(), $empty = true, $notices = array();
15
+
16
  public function __construct( $page = 'custom_settings', $title = null, $menu = array(), $settings = array(), $args = array() ) {
17
  $this->page = $page;
18
  $this->title = $title ? $title : __( 'Custom Settings', WP_ULIKE_SLUG );
21
  'title' => $this->title,
22
  'capability' => 'manage_options',
23
  'icon_url' => null,
24
+ 'position' => null
25
  ), $menu ) : false;
26
  $this->apply_settings( $settings );
27
  $this->args = array_merge( array(
29
  'submit' => __( 'Save Settings', WP_ULIKE_SLUG ),
30
  'reset' => __( 'Reset Settings', WP_ULIKE_SLUG ),
31
  'tabs' => false,
32
+ 'updated' => null
33
  ), $args );
34
  add_action( 'admin_menu', array(
35
  $this,
36
+ 'admin_menu'
37
  ) );
38
  add_action( 'admin_init', array(
39
  $this,
40
+ 'admin_init'
41
  ) );
42
+
43
  add_action( 'activated_plugin', array(
44
  $this,
45
+ 'plugin_priority'
46
  ) );
47
  }
48
+
49
+
50
  public function create_help_screen() {
51
  $current_screen = get_current_screen();
52
  $this->admin_screen = WP_Screen::get( $current_screen );
55
  'id' => 'overview_tab',
56
  'content' => '<p>' . __( '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.', WP_ULIKE_SLUG ) . '</p>' . '<p>' . '<strong>' . __( 'Logging Method', WP_ULIKE_SLUG ) . ' : </strong></p>' . '<ul>' . '<li>' . __( 'If you select <strong>"Do Not Log"</strong> method: Any data logs can\'t save, There is no limitation in the like/dislike, unlike/undislike capacity do not work', WP_ULIKE_SLUG ) . '</li>' . '<li>' . __( 'If you select <strong>"Logged By Cookie"</strong> method: Any data logs can\'t save, The like/dislike condition will be limited by SetCookie, unlike/undislike capacity do not work', WP_ULIKE_SLUG ) . '</li>' . '<li>' . __( 'If you select <strong>"Logged By IP"</strong> method: Data logs will save for all users, the convey of like/dislike condition will check by user IP', WP_ULIKE_SLUG ) . '</li>' . '<li>' . __( 'If you select <strong>"Logged By Username"</strong> method: data logs only is saved for registered users, the convey of like/dislike condition will check by username, There is no permission for guest users to unlike/undislike', WP_ULIKE_SLUG ) . '</li>
57
  </ul>' . '<p>' . '<strong>' . __( 'Template Variables', WP_ULIKE_SLUG ) . ' : </strong></p>' . '<ul>' . '<li>' . '<code>%START_WHILE%</code> : ' . __( 'Start the loop of logs', WP_ULIKE_SLUG ) . ' <span style="color:red">(' . __( 'required', WP_ULIKE_SLUG ) . ')</span></li>' . '<li>' . '<code>%END_WHILE%</code> : ' . __( 'End of the while loop', WP_ULIKE_SLUG ) . ' <span style="color:red">(' . __( 'required', WP_ULIKE_SLUG ) . ')</span></li>' . '<li>' . '<code>%USER_NAME%</code> : ' . __( 'Display the liker name', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%USER_AVATAR%</code> : ' . __( 'Display the liker avatar (By Gravatar)', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%BP_PROFILE_URL%</code> : ' . __( 'Display the BuddyPress user profile url', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%UM_PROFILE_URL%</code> : ' . __( 'Display the UltimateMemebr user profile url', WP_ULIKE_SLUG ) . '</li><hr>' . '<li>' . '<code>%POST_LIKER%</code> : ' . __( 'Display the liker name', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%POST_PERMALINK%</code> : ' . __( 'Display the permalink', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%POST_COUNT%</code> : ' . __( 'Display the likes count number', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%POST_TITLE%</code> : ' . __( 'Display the post title', WP_ULIKE_SLUG ) . '</li><hr>' . '<li>' . '<code>%COMMENT_LIKER%</code> : ' . __( 'Display the liker name', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%COMMENT_PERMALINK%</code> : ' . __( 'Display the permalink', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%COMMENT_AUTHOR%</code> : ' . __( 'Display the comment author name', WP_ULIKE_SLUG ) . '</li>' . '<li>' . '<code>%COMMENT_COUNT%</code> : ' . __( 'Display the likes count number', WP_ULIKE_SLUG ) . '</li>' . '</ul>',
58
+ 'callback' => false
59
  ) );
60
  $this->admin_screen->add_help_tab( array(
61
  'title' => __( 'Posts', WP_ULIKE_SLUG ),
62
  'id' => 'posts_tab',
63
+ 'content' => '<p>' . '<strong>' . __( 'Automatic display', WP_ULIKE_SLUG ) . ' : </strong></p><ul><li>' . __( 'If you disable this option, you have to put manually this code on wordpress while loop', WP_ULIKE_SLUG ) . '<br /><code dir="ltr">&lt;?php if(function_exists(\'wp_ulike\')) wp_ulike(\'get\'); ?&gt;</code>' . '</li></ul>',
64
+
65
+ 'callback' => false
66
  ) );
67
  $this->admin_screen->add_help_tab( array(
68
  'title' => __( 'Comments', WP_ULIKE_SLUG ),
69
  'id' => 'comments_tab',
70
+ 'content' => '<p>' . '<strong>' . __( 'Automatic display', WP_ULIKE_SLUG ) . ' : </strong></p><ul><li>' . __( 'If you disable this option, you have to put manually this code on comments text', WP_ULIKE_SLUG ) . '<br /><code dir="ltr">&lt;?php if(function_exists(\'wp_ulike_comments\')) wp_ulike_comments(\'get\'); ?&gt;</code>' . '</li></ul>',
71
+ 'callback' => false
72
  ) );
73
  $this->admin_screen->add_help_tab( array(
74
  'title' => __( 'BuddyPress', WP_ULIKE_SLUG ),
75
  'id' => 'bp_tab',
76
+ 'content' => '<p>' . '<strong>' . __( 'Automatic display', WP_ULIKE_SLUG ) . ' : </strong></p><ul><li>' . __( 'If you disable this option, you have to put manually this code on buddypres activities content', WP_ULIKE_SLUG ) . '<br /><code dir="ltr">&lt;?php if(function_exists(\'wp_ulike_buddypress\')) wp_ulike_buddypress(\'get\'); ?&gt;</code>' . '</li></ul>',
77
+ 'callback' => false
78
  ) );
79
  $this->admin_screen->add_help_tab( array(
80
  'title' => __( 'bbPress', WP_ULIKE_SLUG ),
81
  'id' => 'bb_tab',
82
+ 'content' => '<p>' . '<strong>' . __( 'Automatic display', WP_ULIKE_SLUG ) . ' : </strong></p><ul><li>' . __( 'If you disable this option, you have to put manually this code on buddypres activities content', WP_ULIKE_SLUG ) . '<br /><code dir="ltr">&lt;?php if(function_exists(\'wp_ulike_bbpress\')) wp_ulike_bbpress(\'get\'); ?&gt;</code>' . '</li></ul>',
83
+ 'callback' => false
84
  ) );
85
  $this->admin_screen->set_help_sidebar( '<p><strong>' . __( 'For more information:' ) . '</strong></p><p><a href="https://wordpress.org/plugins/wp-ulike/faq/" target="_blank">' . __( 'FAQ', WP_ULIKE_SLUG ) . '</a></p><p><a href="https://wordpress.org/support/plugin/wp-ulike" target="_blank">' . __( 'Support', WP_ULIKE_SLUG ) . '</a></p>' );
86
  }
87
+
88
  public function apply_settings( $settings ) {
89
  if ( is_array( $settings ) ) {
90
  foreach ( $settings as $setting => $section ) {
103
  'sanitize' => null,
104
  'attributes' => array(),
105
  'options' => null,
106
+ 'action' => null
107
  ), $field );
108
  $section['fields'][$name] = $field;
109
  } //$section['fields'] as $name => $field
114
  } //$settings as $setting => $section
115
  } //is_array( $settings )
116
  }
117
+
118
  public function add_notice( $message, $type = 'info' ) {
119
  $this->notices[] = array(
120
  'message' => $message,
121
+ 'type' => $type
122
  );
123
  }
124
+
125
  private function get_defaults( $setting ) {
126
  $defaults = array();
127
  foreach ( $this->settings[$setting]['fields'] as $name => $field ) {
131
  } //$this->settings[$setting]['fields'] as $name => $field
132
  return $defaults;
133
  }
134
+
135
  private function reset() {
136
  foreach ( $this->settings as $setting => $section ) {
137
  $_POST[$setting] = array_merge( $_POST[$setting], $this->get_defaults( $setting ) );
138
  } //$this->settings as $setting => $section
139
  add_settings_error( $this->page, 'settings_reset', __( 'Default settings have been reset.', WP_ULIKE_SLUG ), 'updated' );
140
  }
141
+
142
  public function admin_menu() {
143
  if ( $this->menu ) {
144
  if ( $this->menu['parent'] ) {
145
  $page = add_submenu_page( $this->menu['parent'], $this->title, $this->menu['title'], $this->menu['capability'], $this->page, array(
146
  $this,
147
+ 'do_page'
148
  ) );
149
  } //$this->menu['parent']
150
  else {
151
  $page = add_menu_page( $this->title, $this->menu['title'], $this->menu['capability'], $this->page, array(
152
  $this,
153
+ 'do_page'
154
  ), $this->menu['icon_url'], $this->menu['position'] );
155
  if ( $this->title !== $this->menu['title'] ) {
156
  add_submenu_page( $this->page, $this->title, $this->title, $this->menu['capability'], $this->page );
158
  }
159
  add_action( 'load-' . $page, array(
160
  $this,
161
+ 'load_page'
162
  ) );
163
  add_action( 'load-' . $page, array(
164
  &$this,
165
+ 'create_help_screen'
166
  ) );
167
  } //$this->menu
168
  }
169
+
170
  public function load_page() {
171
  global $wp_settings_errors;
172
  foreach ( $this->notices as $notice ) {
173
  $wp_settings_errors[] = array_merge( $notice, array(
174
  'setting' => $this->page,
175
+ 'code' => $notice['type'] . '_notice'
176
  ) );
177
  } //$this->notices as $notice
178
  if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] ) {
194
  } //isset( $_GET['settings-updated'] ) && $_GET['settings-updated']
195
  add_action( 'admin_enqueue_scripts', array(
196
  __CLASS__,
197
+ 'admin_enqueue_scripts'
198
  ) );
199
  }
200
+
201
  public static function admin_enqueue_scripts() {
202
  wp_enqueue_media();
203
  wp_enqueue_script( 'wp-ulike-settings', WP_ULIKE_ADMIN_URL . '/assets/js/settings.js', array(
204
  'jquery',
205
+ 'wp-color-picker'
206
  ) );
207
  wp_enqueue_script( "jquery-effects-core" );
208
  wp_localize_script( 'wp-ulike-settings', 'ajax', array(
209
  'url' => admin_url( 'admin-ajax.php' ),
210
+ 'spinner' => admin_url( 'images/spinner.gif' )
211
  ) );
212
  wp_enqueue_style( 'wp-color-picker' );
213
  }
214
+
215
  public function do_page() {
216
  ?>
217
  <form action="options.php" method="POST" enctype="multipart/form-data" class="wrap wp-ulike">
234
  submit_button( $this->args['submit'], 'large primary' );
235
  if ( $this->args['reset'] ) {
236
  submit_button( $this->args['reset'], 'small', "{$this->page}_reset", true, array(
237
+ 'onclick' => "return confirm('" . __( 'Do you really want to reset all these settings to their default values ?', WP_ULIKE_SLUG ) . "');"
238
  ) );
239
  } //$this->args['reset']
240
  } //!$this->empty
242
  </form>
243
  <?php
244
  }
245
+
246
  public function admin_init() {
247
  foreach ( $this->settings as $setting => $section ) {
248
  register_setting( $this->page, $setting, array(
249
  $this,
250
+ 'sanitize_setting'
251
  ) );
252
  add_settings_section( $setting, $section['title'], array(
253
  $this,
254
+ 'do_section'
255
  ), $this->page );
256
  if ( !empty( $section['fields'] ) ) {
257
  $this->empty = false;
259
  foreach ( $section['fields'] as $name => $field ) {
260
  $id = $setting . '_' . $name;
261
  $field = array_merge( array(
262
+ 'id' => $id,
263
+ 'name' => $setting . '[' . $name . ']',
264
+ 'value' => isset( $values[$name] ) ? $values[$name] : null,
265
+ 'class' => $id,
266
+ 'label_for' => $field['label'] === false ? 'hidden' : $id
267
  ), $field );
268
  add_settings_field( $name, $field['label'], array(
269
  __CLASS__,
270
+ 'do_field'
271
  ), $this->page, $setting, $field );
272
  if ( $field['type'] === 'action' && is_callable( $field['action'] ) ) {
273
  add_action( "wp_ajax_{$setting}_{$name}", $field['action'] );
279
  $this->reset();
280
  } //isset( $_POST["{$this->page}_reset"] )
281
  }
282
+
283
  public function do_section( $args ) {
284
  extract( $args );
285
  echo "<input name='{$id}[{$this->page}_setting]' type='hidden' value='{$id}' class='wp-ulike-settings-section' />";
287
  echo wpautop( $text );
288
  } //$text = $this->settings[$id]['description']
289
  }
290
+
291
  public static function do_field( $args ) {
292
  extract( $args );
293
  $attrs = "name='{$name}'";
309
  echo " {$desc}";
310
  } //$desc
311
  break;
312
+
313
  case 'radio':
314
  if ( !$options ) {
315
  _e( 'No options defined.', WP_ULIKE_SLUG );
322
  echo implode( '<br />', $options );
323
  echo "{$desc}</fieldset>";
324
  break;
325
+
326
  case 'select':
327
  if ( !$options ) {
328
  _e( 'No options defined.', WP_ULIKE_SLUG );
337
  } //$options as $v => $label
338
  echo "</select>{$desc}";
339
  break;
340
+
341
  case 'visual-select':
342
  if ( !$options ) {
343
  _e( 'No options defined.', WP_ULIKE_SLUG );
344
  } //!$options
345
+ echo "<fieldset class='wp-ulike-visual-select' id='{$id}'>";
346
  foreach ( $options as $v => $label ) {
347
  $name = $label['name'];
348
  $symbol = $label['symbol'];
352
  echo implode( '', $options );
353
  echo "{$desc}</fieldset>";
354
  break;
355
+
356
  case 'media':
357
  echo "<fieldset class='wp-ulike-settings-media' id='{$id}'><input {$attrs} type='hidden' value='{$value}' />";
358
  echo "<p><a class='button button-large wp-ulike-select-media' title='{$label}'>" . sprintf( __( 'Select %s', WP_ULIKE_SLUG ), $label ) . "</a> ";
362
  } //$value
363
  echo "{$desc}</fieldset>";
364
  break;
365
+
366
  case 'textarea':
367
  echo "<textarea {$attrs} id='{$id}' class='large-text'>{$value}</textarea>{$desc}";
368
  break;
369
+
370
  case 'multi':
371
  if ( !$options ) {
372
  _e( 'No options defined.', WP_ULIKE_SLUG );
380
  echo implode( '<br />', $options );
381
  echo "{$desc}</fieldset>";
382
  break;
383
+
384
  case 'action':
385
  if ( !$action ) {
386
  _e( 'No action defined.', WP_ULIKE_SLUG );
387
  } //!$action
388
  echo "<p class='wp-ulike-settings-action'><input {$attrs} id='{$id}' type='button' class='button button-large' value='{$label}' /></p>{$desc}";
389
  break;
390
+
391
  case 'color':
392
  $v = esc_attr( $value );
393
  echo "<input {$attrs} id='{$id}' type='text' value='{$v}' class='wp-ulike-settings-color' />{$desc}";
394
  break;
395
+
396
  default:
397
  $v = esc_attr( $value );
398
  echo "<input {$attrs} id='{$id}' type='{$type}' value='{$v}' class='regular-text' />{$desc}";
399
  break;
400
  } //$type
401
  }
402
+
403
  public function sanitize_setting( $inputs ) {
404
  $values = array();
405
  if ( !empty( $inputs["{$this->page}_setting"] ) ) {
414
  case 'checkbox':
415
  $values[$name] = $input ? 1 : 0;
416
  break;
417
+
418
  case 'radio':
419
  case 'select':
420
  $values[$name] = sanitize_key( $input );
421
  break;
422
+
423
  case 'media':
424
  $values[$name] = absint( $input );
425
  break;
426
+
427
  case 'color':
428
  $values[$name] = preg_match( '/^#[a-f0-9]{6}$/i', $input ) ? $input : '';
429
  break;
430
+
431
  case 'textarea':
432
  $text = '';
433
  $nl = "WP-ULIKE-SETTINGS-NEW-LINE";
438
  } //$lines as $line
439
  $values[$name] = trim( $text );
440
  break;
441
+
442
  case 'multi':
443
  if ( !$input || empty( $field['options'] ) ) {
444
  break;
448
  } //$field['options'] as $n => $opt
449
  $values[$name] = json_encode( $input );
450
  break;
451
+
452
  case 'action':
453
  break;
454
+
455
  case 'email':
456
  $values[$name] = sanitize_email( $input );
457
  break;
458
+
459
  case 'url':
460
  $values[$name] = esc_url_raw( $input );
461
  break;
462
+
463
  case 'number':
464
  $values[$name] = floatval( $input );
465
  break;
466
+
467
  default:
468
  $values[$name] = html_entity_decode( $input );
469
  break;
474
  } //!empty( $inputs["{$this->page}_setting"] )
475
  return $inputs;
476
  }
477
+
478
  public static function parse_multi( $result ) {
479
  // Check if the result was recorded as JSON, and if so, returns an array instead
480
  return ( is_string( $result ) && $array = json_decode( $result, true ) ) ? $array : $result;
481
  }
482
+
483
  public static function plugin_priority() {
484
  $wp_ulike_settings = plugin_basename( __FILE__ );
485
  $active_plugins = get_option( 'active_plugins' );
490
  } //$order = array_search( $wp_ulike_settings, $active_plugins )
491
  }
492
  }
493
+
494
  } //!class_exists( 'wp_ulike_settings' )
admin/classes/class-wp-ulike-stats.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  * Class for statistics process
4
  *
@@ -17,11 +17,11 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
17
  *
18
  * @var object
19
  */
20
- protected static $instance = null;
21
-
22
  /**
23
  * Constructor
24
- */
25
  public function __construct()
26
  {
27
  global $wpdb;
@@ -37,7 +37,7 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
37
  * @updated 2.3
38
  * @updated 3.0
39
  * @return Void
40
- */
41
  public function enqueue_script($hook)
42
  {
43
  // $currentScreen = get_current_screen();
@@ -70,15 +70,15 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
70
 
71
  wp_enqueue_script('postbox');
72
  }
73
-
74
  /**
75
  * Get The Posts Data Set
76
  *
77
  * @author Alimir
78
  * @since 2.0
79
- * @updated 2.2
80
  * @return JSON Array
81
- */
82
  public function posts_dataset($type){
83
  $newarray = array();
84
  $return_type = $type != 'dataset' ? 'new_date_time' : 'count_date_time';
@@ -92,15 +92,15 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
92
  }
93
  return json_encode($newarray);
94
  }
95
-
96
  /**
97
  * Get The Comments Data Set
98
  *
99
  * @author Alimir
100
  * @since 2.0
101
  * @updated 2.2
102
- * @return JSON Array
103
- */
104
  public function comments_dataset($type){
105
  $newarray = array();
106
  $return_type = $type != 'dataset' ? 'new_date_time' : 'count_date_time';
@@ -111,7 +111,7 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
111
  }
112
  else
113
  $newarray[] = $val->$return_type;
114
- }
115
  return json_encode($newarray);
116
  }
117
 
@@ -121,8 +121,8 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
121
  * @author Alimir
122
  * @since 2.0
123
  * @updated 2.2
124
- * @return JSON Array
125
- */
126
  public function activities_dataset($type){
127
  $newarray = array();
128
  $return_type = $type != 'dataset' ? 'new_date_time' : 'count_date_time';
@@ -133,18 +133,18 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
133
  }
134
  else
135
  $newarray[] = $val->$return_type;
136
- }
137
  return json_encode($newarray);
138
  }
139
-
140
  /**
141
  * Get The Activities Data Set
142
  *
143
  * @author Alimir
144
  * @since 2.0
145
  * @updated 2.2
146
- * @return JSON Array
147
- */
148
  public function topics_dataset($type){
149
  $newarray = array();
150
  $return_type = $type != 'dataset' ? 'new_date_time' : 'count_date_time';
@@ -155,17 +155,17 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
155
  }
156
  else
157
  $newarray[] = $val->$return_type;
158
- }
159
  return json_encode($newarray);
160
  }
161
-
162
  /**
163
  * Get The Logs Data From Tables
164
  *
165
  * @author Alimir
166
  * @since 2.0
167
  * @return String
168
- */
169
  public function select_data($table){
170
  $get_option = get_option( 'wp_ulike_statistics_screen' );
171
  $set_number = $get_option['days_number'] != null ? $get_option['days_number'] : 20;
@@ -177,14 +177,14 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
177
  ");
178
  return $return_val;
179
  }
180
-
181
  /**
182
  * Get The Summary Of Like Data
183
  *
184
  * @author Alimir
185
  * @since 2.0
186
  * @return Integer
187
- */
188
  public function get_data_date($table,$time){
189
  if($time == 'today')
190
  $where_val = "DATE(date_time) = DATE(NOW())";
@@ -192,16 +192,16 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
192
  $where_val = "DATE(date_time) = DATE(subdate(current_date, 1))";
193
  else if($time == 'week')
194
  $where_val = "week(DATE(date_time)) = week(DATE(NOW()))";
195
- else
196
  $where_val = "month(DATE(date_time)) = month(DATE(NOW()))";
197
-
198
  $return_val = $this->wpdb->get_var(
199
  "
200
  SELECT COUNT(*)
201
  FROM ".$this->wpdb->prefix."$table
202
  WHERE $where_val
203
  ");
204
- return $return_val;
205
  }
206
 
207
  /**
@@ -211,7 +211,7 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
211
  * @since 2.0
212
  * @updated 2.1
213
  * @return Integer
214
- */
215
  public function get_all_data_date($table,$name){
216
  $table_name = $this->wpdb->prefix . $table;
217
  if( $this->wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name ) {
@@ -225,8 +225,8 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
225
  return ;
226
  }
227
  }
228
-
229
-
230
  /**
231
  * Get Data Map
232
  *
@@ -264,7 +264,7 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
264
  // Set transient
265
  set_transient( 'wp_ulike_get_likers_dispersal_statistics', $return_val, 24 * HOUR_IN_SECONDS );
266
  }
267
-
268
  foreach($return_val as $return){
269
  //$cdata = strtolower(wp_ulike_get_geoip($return->get_user_ip,'code'));
270
  $cdata = strtolower( getCountryFromIP( $return->get_user_ip, "code" ) );
@@ -273,10 +273,10 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
273
  }
274
  $country_data[$cdata] += $return->get_count_user_ip;
275
  }
276
-
277
  return json_encode( $country_data );
278
- }
279
-
280
  /**
281
  * Top Likers Summary
282
  *
@@ -284,7 +284,7 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
284
  * @since 2.3
285
  * @since 3.0
286
  * @return Array
287
- */
288
  public function get_top_likers(){
289
 
290
  if ( false === ( $result = get_transient( 'wp_ulike_get_top_likers' ) ) ) {
@@ -317,7 +317,7 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
317
 
318
  return $result;
319
  }
320
-
321
  /**
322
  * Tops Summaries
323
  *
@@ -325,7 +325,7 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
325
  * @since 2.6
326
  * @since 3.0
327
  * @return Array
328
- */
329
  public function get_tops( $type ){
330
  switch( $type ){
331
  case 'top_posts':
@@ -358,8 +358,8 @@ if ( ! class_exists( 'wp_ulike_stats' ) ) {
358
  }
359
 
360
  return self::$instance;
361
- }
362
 
363
  }
364
-
365
  }
1
+ <?php
2
  /**
3
  * Class for statistics process
4
  *
17
  *
18
  * @var object
19
  */
20
+ protected static $instance = null;
21
+
22
  /**
23
  * Constructor
24
+ */
25
  public function __construct()
26
  {
27
  global $wpdb;
37
  * @updated 2.3
38
  * @updated 3.0
39
  * @return Void
40
+ */
41
  public function enqueue_script($hook)
42
  {
43
  // $currentScreen = get_current_screen();
70
 
71
  wp_enqueue_script('postbox');
72
  }
73
+
74
  /**
75
  * Get The Posts Data Set
76
  *
77
  * @author Alimir
78
  * @since 2.0
79
+ * @updated 2.2
80
  * @return JSON Array
81
+ */
82
  public function posts_dataset($type){
83
  $newarray = array();
84
  $return_type = $type != 'dataset' ? 'new_date_time' : 'count_date_time';
92
  }
93
  return json_encode($newarray);
94
  }
95
+
96
  /**
97
  * Get The Comments Data Set
98
  *
99
  * @author Alimir
100
  * @since 2.0
101
  * @updated 2.2
102
+ * @return JSON Array
103
+ */
104
  public function comments_dataset($type){
105
  $newarray = array();
106
  $return_type = $type != 'dataset' ? 'new_date_time' : 'count_date_time';
111
  }
112
  else
113
  $newarray[] = $val->$return_type;
114
+ }
115
  return json_encode($newarray);
116
  }
117
 
121
  * @author Alimir
122
  * @since 2.0
123
  * @updated 2.2
124
+ * @return JSON Array
125
+ */
126
  public function activities_dataset($type){
127
  $newarray = array();
128
  $return_type = $type != 'dataset' ? 'new_date_time' : 'count_date_time';
133
  }
134
  else
135
  $newarray[] = $val->$return_type;
136
+ }
137
  return json_encode($newarray);
138
  }
139
+
140
  /**
141
  * Get The Activities Data Set
142
  *
143
  * @author Alimir
144
  * @since 2.0
145
  * @updated 2.2
146
+ * @return JSON Array
147
+ */
148
  public function topics_dataset($type){
149
  $newarray = array();
150
  $return_type = $type != 'dataset' ? 'new_date_time' : 'count_date_time';
155
  }
156
  else
157
  $newarray[] = $val->$return_type;
158
+ }
159
  return json_encode($newarray);
160
  }
161
+
162
  /**
163
  * Get The Logs Data From Tables
164
  *
165
  * @author Alimir
166
  * @since 2.0
167
  * @return String
168
+ */
169
  public function select_data($table){
170
  $get_option = get_option( 'wp_ulike_statistics_screen' );
171
  $set_number = $get_option['days_number'] != null ? $get_option['days_number'] : 20;
177
  ");
178
  return $return_val;
179
  }
180
+
181
  /**
182
  * Get The Summary Of Like Data
183
  *
184
  * @author Alimir
185
  * @since 2.0
186
  * @return Integer
187
+ */
188
  public function get_data_date($table,$time){
189
  if($time == 'today')
190
  $where_val = "DATE(date_time) = DATE(NOW())";
192
  $where_val = "DATE(date_time) = DATE(subdate(current_date, 1))";
193
  else if($time == 'week')
194
  $where_val = "week(DATE(date_time)) = week(DATE(NOW()))";
195
+ else
196
  $where_val = "month(DATE(date_time)) = month(DATE(NOW()))";
197
+
198
  $return_val = $this->wpdb->get_var(
199
  "
200
  SELECT COUNT(*)
201
  FROM ".$this->wpdb->prefix."$table
202
  WHERE $where_val
203
  ");
204
+ return $return_val;
205
  }
206
 
207
  /**
211
  * @since 2.0
212
  * @updated 2.1
213
  * @return Integer
214
+ */
215
  public function get_all_data_date($table,$name){
216
  $table_name = $this->wpdb->prefix . $table;
217
  if( $this->wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name ) {
225
  return ;
226
  }
227
  }
228
+
229
+
230
  /**
231
  * Get Data Map
232
  *
264
  // Set transient
265
  set_transient( 'wp_ulike_get_likers_dispersal_statistics', $return_val, 24 * HOUR_IN_SECONDS );
266
  }
267
+
268
  foreach($return_val as $return){
269
  //$cdata = strtolower(wp_ulike_get_geoip($return->get_user_ip,'code'));
270
  $cdata = strtolower( getCountryFromIP( $return->get_user_ip, "code" ) );
273
  }
274
  $country_data[$cdata] += $return->get_count_user_ip;
275
  }
276
+
277
  return json_encode( $country_data );
278
+ }
279
+
280
  /**
281
  * Top Likers Summary
282
  *
284
  * @since 2.3
285
  * @since 3.0
286
  * @return Array
287
+ */
288
  public function get_top_likers(){
289
 
290
  if ( false === ( $result = get_transient( 'wp_ulike_get_top_likers' ) ) ) {
317
 
318
  return $result;
319
  }
320
+
321
  /**
322
  * Tops Summaries
323
  *
325
  * @since 2.6
326
  * @since 3.0
327
  * @return Array
328
+ */
329
  public function get_tops( $type ){
330
  switch( $type ){
331
  case 'top_posts':
358
  }
359
 
360
  return self::$instance;
361
+ }
362
 
363
  }
364
+
365
  }
admin/classes/class-wp-ulike-widget.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  * Class for our widget support
4
  *
@@ -13,11 +13,11 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
13
 
14
  /**
15
  * Constructor
16
- */
17
  function __construct() {
18
  parent::__construct(
19
- 'wp_ulike',
20
- __('WP Ulike Widget', WP_ULIKE_SLUG),
21
  array( 'description' => __( 'An advanced widget that gives you all most liked records with different types', WP_ULIKE_SLUG ))
22
  );
23
  }
@@ -27,10 +27,10 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
27
  *
28
  * @author Alimir
29
  * @since 1.1
30
- * @updated 2.3
31
- * @updated 2.4
32
  * @return String
33
- */
34
  public function most_liked_posts( $args = array(), $result = '' ) {
35
  global $wpdb;
36
 
@@ -40,27 +40,27 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
40
  "sizeOf" => 32,
41
  "trim" => 10,
42
  "profile_url" => '',
43
- "show_count" => true,
44
  "show_thumb" => false,
45
  "before_item" => '<li>',
46
  "after_item" => '</li>'
47
  );
48
  // Parse args
49
- $settings = wp_parse_args( $args, $defaults );
50
  // Extract settings
51
  extract($settings);
52
 
53
  if ( false === ( $posts = get_transient( 'wp_ulike_get_most_liked_posts' ) ) ) {
54
  // Make new sql request
55
  $posts = $wpdb->get_results( "
56
- SELECT p.ID, p.post_title, p.post_content, m.meta_value
57
- FROM $wpdb->posts AS p, $wpdb->postmeta AS m, ".$wpdb->prefix."ulike AS l
58
- WHERE p.ID = m.post_ID
59
- AND m.post_ID = l.post_id
60
- AND p.post_status = 'publish'
61
- AND m.meta_key = '_liked'
62
- ".$this->period($period)."
63
- GROUP BY p.ID
64
  ORDER BY CAST( m.meta_value AS SIGNED ) DESC LIMIT $numberOf
65
  " );
66
 
@@ -71,7 +71,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
71
  $post_title = stripslashes($post->post_title);
72
  $permalink = get_permalink($post->ID);
73
  $post_count = $post->meta_value;
74
-
75
  $result .= $before_item;
76
  $result .= $show_thumb ? $this->get_post_thumbnail( $post->ID, $sizeOf ) : '';
77
  $result .= '<a href="' . $permalink . '" title="' . $post_title.'" rel="nofollow">'. wp_trim_words( $post_title, $num_words = $trim, $more = null ) . '</a>';
@@ -81,16 +81,16 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
81
 
82
  return $result;
83
  }
84
-
85
  /**
86
  * Most Liked Comments Function
87
  *
88
  * @author Alimir
89
  * @since 1.9
90
- * @updated 2.3
91
- * @updated 2.4
92
  * @return String
93
- */
94
  public function most_liked_comments( $args = array(), $result = '' ) {
95
  global $wpdb;
96
 
@@ -100,13 +100,13 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
100
  "sizeOf" => 32,
101
  "trim" => 10,
102
  "profile_url" => '',
103
- "show_count" => true,
104
  "show_thumb" => false,
105
  "before_item" => '<li>',
106
  "after_item" => '</li>'
107
  );
108
  // Parse args
109
- $settings = wp_parse_args( $args, $defaults );
110
  // Extract settings
111
  extract($settings);
112
 
@@ -114,18 +114,18 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
114
  // Make new sql request
115
  $comments = $wpdb->get_results( "
116
  SELECT *
117
- FROM $wpdb->comments AS c, $wpdb->commentmeta AS m, ".$wpdb->prefix."ulike_comments AS l
118
  WHERE c.comment_ID = m.comment_id
119
  AND m.comment_id = l.comment_id
120
- AND c.comment_approved = '1'
121
- AND m.meta_key = '_commentliked'
122
- ".$this->period($period)."
123
  GROUP BY c.comment_ID
124
  ORDER BY CAST( m.meta_value AS SIGNED ) DESC LIMIT $numberOf
125
  " );
126
 
127
  set_transient( 'wp_ulike_get_most_liked_comments', $comments, 6 * HOUR_IN_SECONDS );
128
- }
129
 
130
  foreach ($comments as $comment) {
131
  $comment_author = stripslashes($comment->comment_author);
@@ -133,7 +133,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
133
  $post_title = get_the_title($comment->comment_post_ID);
134
  $comment_permalink = get_permalink($comment->comment_ID);
135
  $comment_likes_count = $comment->meta_value;
136
-
137
  $result .= $before_item;
138
  $result .= $show_thumb ? get_avatar( $comment->comment_author_email, $sizeOf ) : '';
139
  $result .= '<span class="comment-author-link">' . $comment_author . '</span> ' . __('on',WP_ULIKE_SLUG);
@@ -143,7 +143,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
143
  }
144
 
145
  return $result;
146
- }
147
 
148
  /**
149
  * Last Posts Liked By Current User
@@ -153,7 +153,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
153
  * @updated 2.3
154
  * @updated 2.4
155
  * @return String
156
- */
157
  public function last_posts_liked_by_current_user( $args = array(), $result = '' ) {
158
  global $wpdb,$user_ID,$wp_user_IP;
159
 
@@ -163,7 +163,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
163
  "sizeOf" => 32,
164
  "trim" => 10,
165
  "profile_url" => '',
166
- "show_count" => true,
167
  "show_thumb" => false,
168
  "before_item" => '<li>',
169
  "after_item" => '</li>'
@@ -171,7 +171,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
171
  // Parse args
172
  $settings = wp_parse_args( $args, $defaults );
173
  // Extract settings
174
- extract($settings);
175
 
176
  $likes = $wpdb->get_results( "
177
  SELECT U.post_id, P.meta_value AS counter
@@ -182,7 +182,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
182
  GROUP BY U.post_id
183
  ORDER BY MAX(U.date_time) DESC LIMIT $numberOf
184
  " );
185
-
186
  if( $likes !== 0 ){
187
  foreach ($likes as $like) {
188
  $permalink = get_permalink($like->post_id);
@@ -197,13 +197,13 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
197
  }
198
  else{
199
  $result .= $before_item;
200
- $result .= __( 'you haven\'t liked any post yet!',WP_ULIKE_SLUG );
201
  $result .= $after_item;
202
  }
203
-
204
  return $result;
205
  }
206
-
207
  /**
208
  * Most Liked Topics Function
209
  *
@@ -211,13 +211,13 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
211
  * @since 2.3
212
  * @updated 2.4
213
  * @return String
214
- */
215
  public function most_liked_topics( $args = array(), $result = '' ) {
216
  global $wpdb;
217
 
218
  if( ! function_exists( 'is_bbpress' ) ) {
219
  return sprintf( __( '%s is Not Activated!', WP_ULIKE_SLUG ) ,__( 'bbPress', WP_ULIKE_SLUG ) );
220
- }
221
 
222
  $defaults = array(
223
  "numberOf" => 10,
@@ -225,33 +225,33 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
225
  "sizeOf" => 32,
226
  "trim" => 10,
227
  "profile_url" => '',
228
- "show_count" => true,
229
  "show_thumb" => false,
230
  "before_item" => '<li>',
231
  "after_item" => '</li>'
232
  );
233
  // Parse args
234
- $settings = wp_parse_args( $args, $defaults );
235
  // Extract settings
236
  extract($settings);
237
 
238
  if ( false === ( $posts = get_transient( 'wp_ulike_get_most_liked_topics' ) ) ) {
239
  // Make new sql request
240
  $posts = $wpdb->get_results( "
241
- SELECT p.ID, p.post_title, p.post_content, m.meta_value
242
- FROM $wpdb->posts AS p, $wpdb->postmeta AS m, ".$wpdb->prefix."ulike_forums AS l
243
- WHERE p.ID = m.post_ID
244
- AND m.post_ID = l.topic_id
245
- AND p.post_status = 'publish'
246
- AND m.meta_key = '_topicliked'
247
- ".$this->period($period)."
248
- GROUP BY p.ID
249
  ORDER BY CAST( m.meta_value AS SIGNED ) DESC LIMIT $numberOf
250
  " );
251
 
252
  set_transient( 'wp_ulike_get_most_liked_topics', $posts, 6 * HOUR_IN_SECONDS );
253
  }
254
-
255
  foreach ($posts as $post) {
256
  $post_title = empty($post->post_title) ? $post->post_content : stripslashes($post->post_title);
257
  $permalink = get_permalink($post->ID);
@@ -260,11 +260,11 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
260
  $result .= $before_item;
261
  $result .= '<a href="' . $permalink . '" title="' . $post_title.'" rel="nofollow">'. wp_trim_words( $post_title, $num_words = $trim, $more = null ) . '</a>';
262
  $result .= $show_count ? ' <span class="wp_counter_span">'.wp_ulike_format_number($post_count).'</span>' : '';
263
- $result .= $after_item;
264
  }
265
 
266
  return $result;
267
- }
268
 
269
  /**
270
  * Most Liked Activities Function
@@ -274,7 +274,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
274
  * @updated 2.4
275
  * @updated 2.6 //added post counter value
276
  * @return String
277
- */
278
  public function most_liked_activities( $args = array(), $result = '' ) {
279
  global $wpdb;
280
 
@@ -288,45 +288,45 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
288
  "sizeOf" => 32,
289
  "trim" => 18,
290
  "profile_url" => '',
291
- "show_count" => true,
292
  "show_thumb" => false,
293
  "before_item" => '<li>',
294
  "after_item" => '</li>'
295
  );
296
  // Parse args
297
- $settings = wp_parse_args( $args, $defaults );
298
  // Extract settings
299
  extract($settings);
300
 
301
  if ( is_multisite() ) {
302
  $bp_prefix = 'base_prefix';
303
  } else {
304
- $bp_prefix = 'prefix';
305
  }
306
 
307
  if ( false === ( $activities = get_transient( 'wp_ulike_get_most_liked_activities' ) ) ) {
308
  // Make new sql request
309
  $activities = $wpdb->get_results( "
310
- SELECT * FROM
311
- ".$wpdb->$bp_prefix."bp_activity AS b,
312
- ".$wpdb->$bp_prefix."bp_activity_meta AS m,
313
- ".$wpdb->prefix."ulike_activities AS l
314
  WHERE b.id = m.activity_id
315
  AND m.activity_id = l.activity_id
316
  AND m.meta_key = '_activityliked'
317
- ".$this->period($period)."
318
  GROUP BY b.id
319
  ORDER BY CAST( m.meta_value AS SIGNED ) DESC LIMIT $numberOf
320
  " );
321
 
322
  set_transient( 'wp_ulike_get_most_liked_activities', $activities, 6 * HOUR_IN_SECONDS );
323
- }
324
 
325
  foreach ($activities as $activity) {
326
  $activity_permalink = function_exists('bp_activity_get_permalink') ? bp_activity_get_permalink( $activity->activity_id ) : '';
327
  $activity_action = ! empty( $activity->content ) ? $activity->content : $activity->action;
328
  $post_count = $activity->meta_value;
329
-
330
  $result .= $before_item;
331
  $result .= '<a href="' . $activity_permalink . '" rel="nofollow">';
332
  $result .= wp_trim_words( $activity_action, $num_words = $trim, $more = null );
@@ -346,7 +346,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
346
  * @updated 2.3
347
  * @updated 2.4
348
  * @return String
349
- */
350
  public function most_liked_users( $args = array(), $result = '' ) {
351
  global $wpdb;
352
 
@@ -356,7 +356,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
356
  "sizeOf" => 32,
357
  "trim" => 10,
358
  "profile_url" => 'bp',
359
- "show_count" => true,
360
  "show_thumb" => false,
361
  "before_item" => '<li>',
362
  "after_item" => '</li>'
@@ -364,7 +364,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
364
  // Parse args
365
  $settings = wp_parse_args( $args, $defaults );
366
  // Extract settings
367
- extract($settings);
368
 
369
  if ( false === ( $likers = get_transient( 'wp_ulike_get_most_likers' ) ) ) {
370
  // Make new sql request
@@ -400,7 +400,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
400
  " );
401
 
402
  set_transient( 'wp_ulike_get_most_likers', $likers, 6 * HOUR_IN_SECONDS );
403
- }
404
 
405
  foreach ($likers as $liker) {
406
  $get_user_id = stripslashes($liker->user_id);
@@ -408,14 +408,14 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
408
  $get_likes_count = $liker->SumUser;
409
  $return_profile_url = '#';
410
  $echo_likes_count = $show_count ? ' ('.$get_likes_count . ' ' . __('Like',WP_ULIKE_SLUG).')' : '';
411
-
412
  if( $profile_url == 'bp' && function_exists('bp_core_get_user_domain') ) {
413
- $return_profile_url = bp_core_get_user_domain( $liker->user_id );
414
  } elseif( $profile_url == 'um' && function_exists('um_fetch_user') ) {
415
  um_fetch_user( $liker->user_id );
416
  $return_profile_url = um_user_profile_url();
417
  }
418
-
419
  if( ! empty( $get_user_info ) ){
420
  $result .= $before_item;
421
  $result .= '<a href="'.$return_profile_url.'" class="user-tooltip" title="'.$get_user_info->display_name . $echo_likes_count.'">'.get_avatar( $get_user_info->user_email, $sizeOf, '' , 'avatar').'</a>';
@@ -425,14 +425,14 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
425
 
426
  return $result;
427
  }
428
-
429
  /**
430
  * Get The Post Thumbnail
431
  *
432
  * @author Alimir
433
  * @since 2.3
434
  * @return String
435
- */
436
  public function get_post_thumbnail( $id, $sizeOf ){
437
  $thumbnail = get_the_post_thumbnail( $id, array( $sizeOf, $sizeOf), array( 'class' => 'wp_ulike_thumbnail' ) );
438
  if($thumbnail != ''){
@@ -441,14 +441,14 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
441
  return '<img src="'.WP_ULIKE_ASSETS_URL.'/img/no-thumbnail.png" class="wp_ulike_thumbnail" alt="no-thumbnail" width="'.$sizeOf.'"/>';
442
  }
443
  }
444
-
445
  /**
446
- * Set Period
447
  *
448
  * @author Alimir
449
  * @since 2.4
450
  * @return String
451
- */
452
  public function period($period){
453
  switch ($period) {
454
  case "today":
@@ -474,12 +474,12 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
474
  * @updated 2.3
475
  * @updated 2.4
476
  * @return String
477
- */
478
  public function widget( $args, $instance ) {
479
  $title = apply_filters('widget_title', $instance['title'] );
480
- $type = $instance['type'];
481
- $style = $instance['style'];
482
-
483
  $settings = array(
484
  "numberOf" => $instance['count'],
485
  "period" => $instance['period'],
@@ -491,7 +491,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
491
  "before_item" => '<li>',
492
  "after_item" => '</li>'
493
  );
494
-
495
  echo $args['before_widget'];
496
 
497
  if ( ! empty( $title ) ) {
@@ -516,7 +516,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
516
 
517
  echo $args['after_widget'];
518
  }
519
-
520
  /**
521
  * Widget Options
522
  *
@@ -525,10 +525,10 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
525
  * @updated 2.3
526
  * @updated 3.0
527
  * @return String
528
- */
529
  public function form( $instance ) {
530
  //Set up some default widget settings.
531
- $defaults = array(
532
  'title' => __('Most Liked', WP_ULIKE_SLUG),
533
  'count' => 10,
534
  'size' => 32,
@@ -547,7 +547,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
547
  <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', WP_ULIKE_SLUG); ?></label>
548
  <input id="<?php echo $this->get_field_id( 'title' ); ?>" class="widefat" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" type="text">
549
  </p>
550
-
551
  <p>
552
  <label for="<?php echo $this->get_field_id( 'type' ); ?>"><?php _e('Type:', WP_ULIKE_SLUG); ?></label>
553
  <select name="<?php echo $this->get_field_name( 'type' ); ?>" style="width:100%;">
@@ -557,13 +557,13 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
557
  <option value="topic" <?php selected( $instance['type'], "topic" ); ?>><?php echo _e('Most Liked Topics', WP_ULIKE_SLUG); ?></option>
558
  <option value="users" <?php selected( $instance['type'], "users" ); ?>><?php echo _e('Most Liked Users', WP_ULIKE_SLUG); ?></option>
559
  <option value="last_posts_liked" <?php selected( $instance['type'], "last_posts_liked" ); ?>><?php echo _e('Last Posts Liked By User', WP_ULIKE_SLUG); ?></option>
560
- </select>
561
  </p>
562
 
563
  <p>
564
  <label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e('Number of items to show:', WP_ULIKE_SLUG); ?></label>
565
  <input id="<?php echo $this->get_field_id( 'count' ); ?>" class="tiny-text" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo $instance['count']; ?>" step="1" min="1" size="3" type="number">
566
- </p>
567
 
568
  <p>
569
  <label for="<?php echo $this->get_field_id( 'period' ); ?>"><?php _e('Period:', WP_ULIKE_SLUG); ?></label>
@@ -576,45 +576,45 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
576
  <option value="today" <?php selected( $instance['period'], "today" ); ?>><?php echo _e('Today', WP_ULIKE_SLUG); ?></option>
577
  </select>
578
  </p>
579
-
580
  <p>
581
  <label for="<?php echo $this->get_field_id( 'style' ); ?>"><?php _e('Style:', WP_ULIKE_SLUG); ?></label>
582
  <select name="<?php echo $this->get_field_name( 'style' ); ?>" style="width:100%;">
583
  <option value="simple" <?php selected( $instance['style'], "simple" ); ?>><?php echo _e('Simple', WP_ULIKE_SLUG); ?></option>
584
  <option value="love" <?php selected( $instance['style'], "love" ); ?>><?php echo _e('Heart', WP_ULIKE_SLUG); ?></option>
585
- </select>
586
- </p>
587
-
588
  <p>
589
  <label for="<?php echo $this->get_field_id( 'trim' ); ?>"><?php _e('Title Trim (Length):', WP_ULIKE_SLUG); ?></label>
590
  <input id="<?php echo $this->get_field_name( 'trim' ); ?>" class="tiny-text" name="<?php echo $this->get_field_name( 'trim' ); ?>" value="<?php echo $instance['trim']; ?>" step="1" min="1" size="3" type="number">
591
  </p>
592
-
593
-
594
  <p>
595
  <label for="<?php echo $this->get_field_id( 'profile_url' ); ?>"><?php _e('Profile URL:', WP_ULIKE_SLUG); ?></label>
596
  <select name="<?php echo $this->get_field_name( 'profile_url' ); ?>" style="width:100%;">
597
  <option value="bp" <?php selected( $instance['profile_url'], "bp" ); ?>><?php echo _e('BuddyPress', WP_ULIKE_SLUG); ?></option>
598
  <option value="um" <?php selected( $instance['profile_url'], "um" ); ?>><?php echo _e('UltimateMember', WP_ULIKE_SLUG); ?></option>
599
- </select>
600
- </p>
601
 
602
  <p>
603
- <input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_count' ); ?>" name="<?php echo $this->get_field_name( 'show_count' ); ?>" <?php if($instance['show_count'] == true) echo 'checked="checked"'; ?> />
604
  <label for="<?php echo $this->get_field_id( 'show_count' ); ?>"><?php _e('Activate Like Counter', WP_ULIKE_SLUG); ?></label>
605
  </p>
606
-
607
  <p>
608
- <input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_thumb' ); ?>" name="<?php echo $this->get_field_name( 'show_thumb' ); ?>" <?php if($instance['show_thumb'] == true) echo 'checked="checked"'; ?> />
609
  <label for="<?php echo $this->get_field_id( 'show_thumb' ); ?>"><?php _e('Activate Thumbnail/Avatar', WP_ULIKE_SLUG); ?></label>
610
  </p>
611
 
612
  <p>
613
  <label for="<?php echo $this->get_field_id( 'size' ); ?>"><?php _e('Thumbnail/Avatar size:', WP_ULIKE_SLUG); ?><small> (min. 8)</small></label>
614
  <input id="<?php echo $this->get_field_id( 'size' ); ?>" class="tiny-text" name="<?php echo $this->get_field_name( 'size' ); ?>" value="<?php echo $instance['size']; ?>" step="1" min="8" size="3" type="number">
615
- </p>
616
-
617
- <?php
618
  }
619
 
620
  /**
@@ -625,7 +625,7 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
625
  * @updated 2.3
626
  * @updated 3.0
627
  * @return String
628
- */
629
  public function update( $new_instance, $old_instance ) {
630
  $instance = $old_instance;
631
 
@@ -634,15 +634,15 @@ if ( ! class_exists( 'wp_ulike_widget' ) ) {
634
  case 'post':
635
  delete_transient( 'wp_ulike_get_most_liked_posts' );
636
  break;
637
-
638
  case 'comment':
639
  delete_transient( 'wp_ulike_get_most_liked_comments' );
640
  break;
641
-
642
  case 'activity':
643
  delete_transient( 'wp_ulike_get_most_liked_activities' );
644
  break;
645
-
646
  case 'topic':
647
  delete_transient( 'wp_ulike_get_most_liked_topics' );
648
  break;
1
+ <?php
2
  /**
3
  * Class for our widget support
4
  *
13
 
14
  /**
15
  * Constructor
16
+ */
17
  function __construct() {
18
  parent::__construct(
19
+ 'wp_ulike',
20
+ __('WP Ulike Widget', WP_ULIKE_SLUG),
21
  array( 'description' => __( 'An advanced widget that gives you all most liked records with different types', WP_ULIKE_SLUG ))
22
  );
23
  }
27
  *
28
  * @author Alimir
29
  * @since 1.1
30
+ * @updated 2.3
31
+ * @updated 2.4
32
  * @return String
33
+ */
34
  public function most_liked_posts( $args = array(), $result = '' ) {
35
  global $wpdb;
36
 
40
  "sizeOf" => 32,
41
  "trim" => 10,
42
  "profile_url" => '',
43
+ "show_count" => true,
44
  "show_thumb" => false,
45
  "before_item" => '<li>',
46
  "after_item" => '</li>'
47
  );
48
  // Parse args
49
+ $settings = wp_parse_args( $args, $defaults );
50
  // Extract settings
51
  extract($settings);
52
 
53
  if ( false === ( $posts = get_transient( 'wp_ulike_get_most_liked_posts' ) ) ) {
54
  // Make new sql request
55
  $posts = $wpdb->get_results( "
56
+ SELECT p.ID, p.post_title, p.post_content, m.meta_value
57
+ FROM $wpdb->posts AS p, $wpdb->postmeta AS m, ".$wpdb->prefix."ulike AS l
58
+ WHERE p.ID = m.post_ID
59
+ AND m.post_ID = l.post_id
60
+ AND p.post_status = 'publish'
61
+ AND m.meta_key = '_liked'
62
+ ".$this->period($period)."
63
+ GROUP BY p.ID
64
  ORDER BY CAST( m.meta_value AS SIGNED ) DESC LIMIT $numberOf
65
  " );
66
 
71
  $post_title = stripslashes($post->post_title);
72
  $permalink = get_permalink($post->ID);
73
  $post_count = $post->meta_value;
74
+
75
  $result .= $before_item;
76
  $result .= $show_thumb ? $this->get_post_thumbnail( $post->ID, $sizeOf ) : '';
77
  $result .= '<a href="' . $permalink . '" title="' . $post_title.'" rel="nofollow">'. wp_trim_words( $post_title, $num_words = $trim, $more = null ) . '</a>';
81
 
82
  return $result;
83
  }
84
+
85
  /**
86
  * Most Liked Comments Function
87
  *
88
  * @author Alimir
89
  * @since 1.9
90
+ * @updated 2.3
91
+ * @updated 2.4
92
  * @return String
93
+ */
94
  public function most_liked_comments( $args = array(), $result = '' ) {
95
  global $wpdb;
96
 
100
  "sizeOf" => 32,
101
  "trim" => 10,
102
  "profile_url" => '',
103
+ "show_count" => true,
104
  "show_thumb" => false,
105
  "before_item" => '<li>',
106
  "after_item" => '</li>'
107
  );
108
  // Parse args
109
+ $settings = wp_parse_args( $args, $defaults );
110
  // Extract settings
111
  extract($settings);
112
 
114
  // Make new sql request
115
  $comments = $wpdb->get_results( "
116
  SELECT *
117
+ FROM $wpdb->comments AS c, $wpdb->commentmeta AS m, ".$wpdb->prefix."ulike_comments AS l
118
  WHERE c.comment_ID = m.comment_id
119
  AND m.comment_id = l.comment_id
120
+ AND c.comment_approved = '1'
121
+ AND m.meta_key = '_commentliked'
122
+ ".$this->period($period)."
123
  GROUP BY c.comment_ID
124
  ORDER BY CAST( m.meta_value AS SIGNED ) DESC LIMIT $numberOf
125
  " );
126
 
127
  set_transient( 'wp_ulike_get_most_liked_comments', $comments, 6 * HOUR_IN_SECONDS );
128
+ }
129
 
130
  foreach ($comments as $comment) {
131
  $comment_author = stripslashes($comment->comment_author);
133
  $post_title = get_the_title($comment->comment_post_ID);
134
  $comment_permalink = get_permalink($comment->comment_ID);
135
  $comment_likes_count = $comment->meta_value;
136
+
137
  $result .= $before_item;
138
  $result .= $show_thumb ? get_avatar( $comment->comment_author_email, $sizeOf ) : '';
139
  $result .= '<span class="comment-author-link">' . $comment_author . '</span> ' . __('on',WP_ULIKE_SLUG);
143
  }
144
 
145
  return $result;
146
+ }
147
 
148
  /**
149
  * Last Posts Liked By Current User
153
  * @updated 2.3
154
  * @updated 2.4
155
  * @return String
156
+ */
157
  public function last_posts_liked_by_current_user( $args = array(), $result = '' ) {
158
  global $wpdb,$user_ID,$wp_user_IP;
159
 
163
  "sizeOf" => 32,
164
  "trim" => 10,
165
  "profile_url" => '',
166
+ "show_count" => true,
167
  "show_thumb" => false,
168
  "before_item" => '<li>',
169
  "after_item" => '</li>'
171
  // Parse args
172
  $settings = wp_parse_args( $args, $defaults );
173
  // Extract settings
174
+ extract($settings);
175
 
176
  $likes = $wpdb->get_results( "
177
  SELECT U.post_id, P.meta_value AS counter
182
  GROUP BY U.post_id
183
  ORDER BY MAX(U.date_time) DESC LIMIT $numberOf
184
  " );
185
+
186
  if( $likes !== 0 ){
187
  foreach ($likes as $like) {
188
  $permalink = get_permalink($like->post_id);
197
  }
198
  else{
199
  $result .= $before_item;
200
+ $result .= __( 'you haven\'t liked any post yet!',WP_ULIKE_SLUG );
201
  $result .= $after_item;
202
  }
203
+
204
  return $result;
205
  }
206
+
207
  /**
208
  * Most Liked Topics Function
209
  *
211
  * @since 2.3
212
  * @updated 2.4
213
  * @return String
214
+ */
215
  public function most_liked_topics( $args = array(), $result = '' ) {
216
  global $wpdb;
217
 
218
  if( ! function_exists( 'is_bbpress' ) ) {
219
  return sprintf( __( '%s is Not Activated!', WP_ULIKE_SLUG ) ,__( 'bbPress', WP_ULIKE_SLUG ) );
220
+ }
221
 
222
  $defaults = array(
223
  "numberOf" => 10,
225
  "sizeOf" => 32,
226
  "trim" => 10,
227
  "profile_url" => '',
228
+ "show_count" => true,
229
  "show_thumb" => false,
230
  "before_item" => '<li>',
231
  "after_item" => '</li>'
232
  );
233
  // Parse args
234
+ $settings = wp_parse_args( $args, $defaults );
235
  // Extract settings
236
  extract($settings);
237
 
238
  if ( false === ( $posts = get_transient( 'wp_ulike_get_most_liked_topics' ) ) ) {
239
  // Make new sql request
240
  $posts = $wpdb->get_results( "
241
+ SELECT p.ID, p.post_title, p.post_content, m.meta_value
242
+ FROM $wpdb->posts AS p, $wpdb->postmeta AS m, ".$wpdb->prefix."ulike_forums AS l
243
+ WHERE p.ID = m.post_ID
244
+ AND m.post_ID = l.topic_id
245
+ AND p.post_status = 'publish'
246
+ AND m.meta_key = '_topicliked'
247
+ ".$this->period($period)."
248
+ GROUP BY p.ID
249
  ORDER BY CAST( m.meta_value AS SIGNED ) DESC LIMIT $numberOf
250
  " );
251
 
252
  set_transient( 'wp_ulike_get_most_liked_topics', $posts, 6 * HOUR_IN_SECONDS );
253
  }
254
+
255
  foreach ($posts as $post) {
256
  $post_title = empty($post->post_title) ? $post->post_content : stripslashes($post->post_title);
257
  $permalink = get_permalink($post->ID);
260
  $result .= $before_item;
261
  $result .= '<a href="' . $permalink . '" title="' . $post_title.'" rel="nofollow">'. wp_trim_words( $post_title, $num_words = $trim, $more = null ) . '</a>';
262
  $result .= $show_count ? ' <span class="wp_counter_span">'.wp_ulike_format_number($post_count).'</span>' : '';
263
+ $result .= $after_item;
264
  }
265
 
266
  return $result;
267
+ }
268
 
269
  /**
270
  * Most Liked Activities Function
274
  * @updated 2.4
275
  * @updated 2.6 //added post counter value
276
  * @return String
277
+ */
278
  public function most_liked_activities( $args = array(), $result = '' ) {
279
  global $wpdb;
280
 
288
  "sizeOf" => 32,
289
  "trim" => 18,
290
  "profile_url" => '',
291
+ "show_count" => true,
292
  "show_thumb" => false,
293
  "before_item" => '<li>',
294
  "after_item" => '</li>'
295
  );
296
  // Parse args
297
+ $settings = wp_parse_args( $args, $defaults );
298
  // Extract settings
299
  extract($settings);
300
 
301
  if ( is_multisite() ) {
302
  $bp_prefix = 'base_prefix';
303
  } else {
304
+ $bp_prefix = 'prefix';
305
  }
306
 
307
  if ( false === ( $activities = get_transient( 'wp_ulike_get_most_liked_activities' ) ) ) {
308
  // Make new sql request
309
  $activities = $wpdb->get_results( "
310
+ SELECT * FROM
311
+ ".$wpdb->$bp_prefix."bp_activity AS b,
312
+ ".$wpdb->$bp_prefix."bp_activity_meta AS m,
313
+ ".$wpdb->prefix."ulike_activities AS l
314
  WHERE b.id = m.activity_id
315
  AND m.activity_id = l.activity_id
316
  AND m.meta_key = '_activityliked'
317
+ ".$this->period($period)."
318
  GROUP BY b.id
319
  ORDER BY CAST( m.meta_value AS SIGNED ) DESC LIMIT $numberOf
320
  " );
321
 
322
  set_transient( 'wp_ulike_get_most_liked_activities', $activities, 6 * HOUR_IN_SECONDS );
323
+ }
324
 
325
  foreach ($activities as $activity) {
326
  $activity_permalink = function_exists('bp_activity_get_permalink') ? bp_activity_get_permalink( $activity->activity_id ) : '';
327
  $activity_action = ! empty( $activity->content ) ? $activity->content : $activity->action;
328
  $post_count = $activity->meta_value;
329
+
330
  $result .= $before_item;
331
  $result .= '<a href="' . $activity_permalink . '" rel="nofollow">';
332
  $result .= wp_trim_words( $activity_action, $num_words = $trim, $more = null );
346
  * @updated 2.3
347
  * @updated 2.4
348
  * @return String
349
+ */
350
  public function most_liked_users( $args = array(), $result = '' ) {
351
  global $wpdb;
352
 
356
  "sizeOf" => 32,
357
  "trim" => 10,
358
  "profile_url" => 'bp',
359
+ "show_count" => true,
360
  "show_thumb" => false,
361
  "before_item" => '<li>',
362
  "after_item" => '</li>'
364
  // Parse args
365
  $settings = wp_parse_args( $args, $defaults );
366
  // Extract settings
367
+ extract($settings);
368
 
369
  if ( false === ( $likers = get_transient( 'wp_ulike_get_most_likers' ) ) ) {
370
  // Make new sql request
400
  " );
401
 
402
  set_transient( 'wp_ulike_get_most_likers', $likers, 6 * HOUR_IN_SECONDS );
403
+ }
404
 
405
  foreach ($likers as $liker) {
406
  $get_user_id = stripslashes($liker->user_id);
408
  $get_likes_count = $liker->SumUser;
409
  $return_profile_url = '#';
410
  $echo_likes_count = $show_count ? ' ('.$get_likes_count . ' ' . __('Like',WP_ULIKE_SLUG).')' : '';
411
+
412
  if( $profile_url == 'bp' && function_exists('bp_core_get_user_domain') ) {
413
+ $return_profile_url = bp_core_get_user_domain( $liker->user_id );
414
  } elseif( $profile_url == 'um' && function_exists('um_fetch_user') ) {
415
  um_fetch_user( $liker->user_id );
416
  $return_profile_url = um_user_profile_url();
417
  }
418
+
419
  if( ! empty( $get_user_info ) ){
420
  $result .= $before_item;
421
  $result .= '<a href="'.$return_profile_url.'" class="user-tooltip" title="'.$get_user_info->display_name . $echo_likes_count.'">'.get_avatar( $get_user_info->user_email, $sizeOf, '' , 'avatar').'</a>';
425
 
426
  return $result;
427
  }
428
+
429
  /**
430
  * Get The Post Thumbnail
431
  *
432
  * @author Alimir
433
  * @since 2.3
434
  * @return String
435
+ */
436
  public function get_post_thumbnail( $id, $sizeOf ){
437
  $thumbnail = get_the_post_thumbnail( $id, array( $sizeOf, $sizeOf), array( 'class' => 'wp_ulike_thumbnail' ) );
438
  if($thumbnail != ''){
441
  return '<img src="'.WP_ULIKE_ASSETS_URL.'/img/no-thumbnail.png" class="wp_ulike_thumbnail" alt="no-thumbnail" width="'.$sizeOf.'"/>';
442
  }
443
  }
444
+
445
  /**
446
+ * Set Period
447
  *
448
  * @author Alimir
449
  * @since 2.4
450
  * @return String
451
+ */
452
  public function period($period){
453
  switch ($period) {
454
  case "today":
474
  * @updated 2.3
475
  * @updated 2.4
476
  * @return String
477
+ */
478
  public function widget( $args, $instance ) {
479
  $title = apply_filters('widget_title', $instance['title'] );
480
+ $type = $instance['type'];
481
+ $style = $instance['style'];
482
+
483
  $settings = array(
484
  "numberOf" => $instance['count'],
485
  "period" => $instance['period'],
491
  "before_item" => '<li>',
492
  "after_item" => '</li>'
493
  );
494
+
495
  echo $args['before_widget'];
496
 
497
  if ( ! empty( $title ) ) {
516
 
517
  echo $args['after_widget'];
518
  }
519
+
520
  /**
521
  * Widget Options
522
  *
525
  * @updated 2.3
526
  * @updated 3.0
527
  * @return String
528
+ */
529
  public function form( $instance ) {
530
  //Set up some default widget settings.
531
+ $defaults = array(
532
  'title' => __('Most Liked', WP_ULIKE_SLUG),
533
  'count' => 10,
534
  'size' => 32,
547
  <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', WP_ULIKE_SLUG); ?></label>
548
  <input id="<?php echo $this->get_field_id( 'title' ); ?>" class="widefat" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" type="text">
549
  </p>
550
+
551
  <p>
552
  <label for="<?php echo $this->get_field_id( 'type' ); ?>"><?php _e('Type:', WP_ULIKE_SLUG); ?></label>
553
  <select name="<?php echo $this->get_field_name( 'type' ); ?>" style="width:100%;">
557
  <option value="topic" <?php selected( $instance['type'], "topic" ); ?>><?php echo _e('Most Liked Topics', WP_ULIKE_SLUG); ?></option>
558
  <option value="users" <?php selected( $instance['type'], "users" ); ?>><?php echo _e('Most Liked Users', WP_ULIKE_SLUG); ?></option>
559
  <option value="last_posts_liked" <?php selected( $instance['type'], "last_posts_liked" ); ?>><?php echo _e('Last Posts Liked By User', WP_ULIKE_SLUG); ?></option>
560
+ </select>
561
  </p>
562
 
563
  <p>
564
  <label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e('Number of items to show:', WP_ULIKE_SLUG); ?></label>
565
  <input id="<?php echo $this->get_field_id( 'count' ); ?>" class="tiny-text" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo $instance['count']; ?>" step="1" min="1" size="3" type="number">
566
+ </p>
567
 
568
  <p>
569
  <label for="<?php echo $this->get_field_id( 'period' ); ?>"><?php _e('Period:', WP_ULIKE_SLUG); ?></label>
576
  <option value="today" <?php selected( $instance['period'], "today" ); ?>><?php echo _e('Today', WP_ULIKE_SLUG); ?></option>
577
  </select>
578
  </p>
579
+
580
  <p>
581
  <label for="<?php echo $this->get_field_id( 'style' ); ?>"><?php _e('Style:', WP_ULIKE_SLUG); ?></label>
582
  <select name="<?php echo $this->get_field_name( 'style' ); ?>" style="width:100%;">
583
  <option value="simple" <?php selected( $instance['style'], "simple" ); ?>><?php echo _e('Simple', WP_ULIKE_SLUG); ?></option>
584
  <option value="love" <?php selected( $instance['style'], "love" ); ?>><?php echo _e('Heart', WP_ULIKE_SLUG); ?></option>
585
+ </select>
586
+ </p>
587
+
588
  <p>
589
  <label for="<?php echo $this->get_field_id( 'trim' ); ?>"><?php _e('Title Trim (Length):', WP_ULIKE_SLUG); ?></label>
590
  <input id="<?php echo $this->get_field_name( 'trim' ); ?>" class="tiny-text" name="<?php echo $this->get_field_name( 'trim' ); ?>" value="<?php echo $instance['trim']; ?>" step="1" min="1" size="3" type="number">
591
  </p>
592
+
593
+
594
  <p>
595
  <label for="<?php echo $this->get_field_id( 'profile_url' ); ?>"><?php _e('Profile URL:', WP_ULIKE_SLUG); ?></label>
596
  <select name="<?php echo $this->get_field_name( 'profile_url' ); ?>" style="width:100%;">
597
  <option value="bp" <?php selected( $instance['profile_url'], "bp" ); ?>><?php echo _e('BuddyPress', WP_ULIKE_SLUG); ?></option>
598
  <option value="um" <?php selected( $instance['profile_url'], "um" ); ?>><?php echo _e('UltimateMember', WP_ULIKE_SLUG); ?></option>
599
+ </select>
600
+ </p>
601
 
602
  <p>
603
+ <input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_count' ); ?>" name="<?php echo $this->get_field_name( 'show_count' ); ?>" <?php if($instance['show_count'] == true) echo 'checked="checked"'; ?> />
604
  <label for="<?php echo $this->get_field_id( 'show_count' ); ?>"><?php _e('Activate Like Counter', WP_ULIKE_SLUG); ?></label>
605
  </p>
606
+
607
  <p>
608
+ <input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id( 'show_thumb' ); ?>" name="<?php echo $this->get_field_name( 'show_thumb' ); ?>" <?php if($instance['show_thumb'] == true) echo 'checked="checked"'; ?> />
609
  <label for="<?php echo $this->get_field_id( 'show_thumb' ); ?>"><?php _e('Activate Thumbnail/Avatar', WP_ULIKE_SLUG); ?></label>
610
  </p>
611
 
612
  <p>
613
  <label for="<?php echo $this->get_field_id( 'size' ); ?>"><?php _e('Thumbnail/Avatar size:', WP_ULIKE_SLUG); ?><small> (min. 8)</small></label>
614
  <input id="<?php echo $this->get_field_id( 'size' ); ?>" class="tiny-text" name="<?php echo $this->get_field_name( 'size' ); ?>" value="<?php echo $instance['size']; ?>" step="1" min="8" size="3" type="number">
615
+ </p>
616
+
617
+ <?php
618
  }
619
 
620
  /**
625
  * @updated 2.3
626
  * @updated 3.0
627
  * @return String
628
+ */
629
  public function update( $new_instance, $old_instance ) {
630
  $instance = $old_instance;
631
 
634
  case 'post':
635
  delete_transient( 'wp_ulike_get_most_liked_posts' );
636
  break;
637
+
638
  case 'comment':
639
  delete_transient( 'wp_ulike_get_most_liked_comments' );
640
  break;
641
+
642
  case 'activity':
643
  delete_transient( 'wp_ulike_get_most_liked_activities' );
644
  break;
645
+
646
  case 'topic':
647
  delete_transient( 'wp_ulike_get_most_liked_topics' );
648
  break;
assets/img/svg/default.svg CHANGED
@@ -8,7 +8,7 @@
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,84.000000) scale(0.100000,-0.100000)"
11
- fill="#212121" stroke="none">
12
  <path d="M1699 741 l-39 -39 0 -93 0 -93 -47 -48 -47 -48 47 -48 47 -48 0 -88
13
  0 -88 39 -39 39 -39 532 0 532 0 39 39 39 39 0 277 0 277 -39 39 -39 39 -532
14
  0 -532 0 -39 -39z m1111 -31 c19 -19 20 -33 20 -285 0 -252 -1 -266 -20 -285
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,84.000000) scale(0.100000,-0.100000)"
11
+ fill="#cdcdcd" fill-rule="evenodd" stroke="none">
12
  <path d="M1699 741 l-39 -39 0 -93 0 -93 -47 -48 -47 -48 47 -48 47 -48 0 -88
13
  0 -88 39 -39 39 -39 532 0 532 0 39 39 39 39 0 277 0 277 -39 39 -39 39 -532
14
  0 -532 0 -39 -39z m1111 -31 c19 -19 20 -33 20 -285 0 -252 -1 -266 -20 -285
assets/img/svg/heart.svg CHANGED
@@ -8,7 +8,7 @@
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,111.000000) scale(0.100000,-0.100000)"
11
- fill="#212121" stroke="none">
12
  <path d="M209 955 c-68 -44 -69 -52 -69 -436 l0 -342 50 -49 49 -48 1041 0
13
  c916 0 1041 2 1046 15 4 8 14 15 23 15 22 0 41 19 41 42 0 11 -7 18 -18 18
14
  -23 0 -42 -19 -42 -42 0 -21 -4 -22 -31 -5 -17 9 -23 9 -26 0 -5 -15 -63 -18
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,111.000000) scale(0.100000,-0.100000)"
11
+ fill="#cdcdcd" fill-rule="evenodd" stroke="none">
12
  <path d="M209 955 c-68 -44 -69 -52 -69 -436 l0 -342 50 -49 49 -48 1041 0
13
  c916 0 1041 2 1046 15 4 8 14 15 23 15 22 0 41 19 41 42 0 11 -7 18 -18 18
14
  -23 0 -42 -19 -42 -42 0 -21 -4 -22 -31 -5 -17 9 -23 9 -26 0 -5 -15 -63 -18
assets/img/svg/icon.svg CHANGED
@@ -8,7 +8,7 @@
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,99.000000) scale(0.100000,-0.100000)"
11
- fill="#212121" stroke="none">
12
  <path d="M163 775 c-23 -22 -23 -25 -23 -302 l0 -279 28 -27 28 -27 575 0 575
13
  0 27 28 27 28 0 274 0 274 -27 28 -27 28 -580 -1 -581 -1 -22 -23z m1181 -37
14
  c13 -26 16 -72 16 -272 -1 -224 -2 -243 -20 -264 l-20 -24 -549 0 c-498 1
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,99.000000) scale(0.100000,-0.100000)"
11
+ fill="#cdcdcd" fill-rule="evenodd" stroke="none">
12
  <path d="M163 775 c-23 -22 -23 -25 -23 -302 l0 -279 28 -27 28 -27 575 0 575
13
  0 27 28 27 28 0 274 0 274 -27 28 -27 28 -580 -1 -581 -1 -22 -23z m1181 -37
14
  c13 -26 16 -72 16 -272 -1 -224 -2 -243 -20 -264 l-20 -24 -549 0 c-498 1
assets/img/svg/text.svg CHANGED
@@ -8,7 +8,7 @@
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,87.000000) scale(0.100000,-0.100000)"
11
- fill="#212121" stroke="none">
12
  <path d="M103 715 c-23 -22 -23 -26 -23 -287 l0 -264 28 -27 28 -27 634 0 634
13
  0 28 27 28 27 0 261 0 261 -28 27 -28 27 -640 -1 -639 -1 -22 -23z m1301 -37
14
  c13 -25 16 -72 16 -260 0 -215 -1 -229 -20 -248 -20 -20 -33 -20 -623 -20
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,87.000000) scale(0.100000,-0.100000)"
11
+ fill="#cdcdcd" fill-rule="evenodd" stroke="none">
12
  <path d="M103 715 c-23 -22 -23 -26 -23 -287 l0 -264 28 -27 28 -27 634 0 634
13
  0 28 27 28 27 0 261 0 261 -28 27 -28 27 -640 -1 -639 -1 -22 -23z m1301 -37
14
  c13 -25 16 -72 16 -260 0 -215 -1 -229 -20 -248 -20 -20 -33 -20 -623 -20
assets/img/svg/twitter.svg CHANGED
@@ -8,7 +8,7 @@
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,102.000000) scale(0.100000,-0.100000)"
11
- fill="#212121" stroke="none">
12
  <path d="M330 834 c-14 -7 -32 -14 -41 -14 -20 0 -65 -47 -89 -95 -24 -46 -26
13
  -130 -6 -172 8 -15 23 -46 33 -68 10 -22 24 -44 31 -48 6 -4 12 -14 12 -21 0
14
  -15 136 -156 197 -203 22 -18 48 -33 58 -33 18 0 118 74 170 125 68 68 155
8
  Created by potrace 1.10, written by Peter Selinger 2001-2011
9
  </metadata>
10
  <g transform="translate(0.000000,102.000000) scale(0.100000,-0.100000)"
11
+ fill="#cdcdcd" fill-rule="evenodd" stroke="none">
12
  <path d="M330 834 c-14 -7 -32 -14 -41 -14 -20 0 -65 -47 -89 -95 -24 -46 -26
13
  -130 -6 -172 8 -15 23 -46 33 -68 10 -22 24 -44 31 -48 6 -4 12 -14 12 -21 0
14
  -15 136 -156 197 -203 22 -18 48 -33 58 -33 18 0 118 74 170 125 68 68 155
assets/js/wp-ulike.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! WP ULike - v3.2
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
@@ -15,9 +15,9 @@
15
  // Create the defaults once
16
  var pluginName = "WordpressUlikeNotifications",
17
  defaults = {
18
- messageType : 'success',
19
- messageText : 'Hello World!',
20
- messageElement: 'wpulike-message',
21
  notifContainer: 'wpulike-notification'
22
  };
23
  // The actual plugin constructor
@@ -78,8 +78,8 @@
78
  if( !$( '.' + self.settings.messageElement ).length ) {
79
  self.$notifContainer.remove();
80
  }
81
- }).trigger('WordpressUlikeRemoveNotification');
82
- }, 8000 );
83
  }
84
 
85
  });
@@ -112,9 +112,10 @@
112
  nonce : 0, /* Get nonce token */
113
  type : '', /* Values : likeThis (Posts),likeThisComment, likeThisActivity, likeThisTopic */
114
  likeStatus : 0, /* Values : 0 (Is not logged-in), 1 (Is not liked), 2 (Is liked), 3 (Is unliked), 4 (Already liked) */
115
- counterSelector: wp_ulike_params.counter_selector, /* You can change this value by add filter on 'wp_ulike_counter_selector' */
116
- generalSelector: wp_ulike_params.general_selector, /* You can change this value by add filter on 'wp_ulike_general_selector' */
117
- buttonSelector : wp_ulike_params.button_selector /* You can change this value by add filter on 'wp_ulike_button_selector' */
 
118
  },
119
  attributesMap = {
120
  'ulike-id' : 'ID',
@@ -130,9 +131,10 @@
130
  this.settings = $.extend( {}, defaults, options );
131
  this._defaults = defaults;
132
  this._name = pluginName;
133
-
134
  // Create main selectors
135
  this.buttonElement = this.$element.find(this.settings.buttonSelector);
 
136
  this.generalElement = this.$element.find(this.settings.generalSelector);
137
  this.counterElement = this.generalElement.find( this.settings.counterSelector );
138
 
@@ -152,7 +154,7 @@
152
  //Call _ajaxify function on click button
153
  this.buttonElement.click( this._ajaxify.bind(this) );
154
  },
155
-
156
  _ajaxify: function(){
157
  $.ajax({
158
  type:'POST',
@@ -172,24 +174,24 @@
172
  }.bind(this),
173
  success: function( response ){
174
  //remove loading class
175
- this.generalElement.removeClass( 'wp_ulike_is_loading' );
176
  if( response.success ) {
177
  this._update( response );
178
  } else {
179
  this._notif( 'error', response.data );
180
  }
181
-
182
  $document.trigger('WordpressUlikeUpdated');
183
  }.bind(this)
184
  });
185
  },
186
-
187
  _update: function( response ){
188
  //check likeStatus
189
  switch(this.settings.likeStatus) {
190
  case 1: /* Change the status of 'is not liked' to 'liked' */
191
  this.buttonElement.attr('data-ulike-status', 4);
192
- this.settings.likeStatus = 4;
193
  this.generalElement.addClass( 'wp_ulike_is_liked' ).removeClass( 'wp_ulike_is_not_liked' );
194
  this.generalElement.children().first().addClass( 'wp_ulike_click_is_disabled' );
195
  this.counterElement.text( response.data.data );
@@ -208,7 +210,7 @@
208
  this.generalElement.addClass('wp_ulike_is_liked').removeClass('wp_ulike_is_unliked');
209
  this.counterElement.text( response.data.data );
210
  this._actions( 'success', response.data.message, response.data.btnText, 2 );
211
- break;
212
  case 4: /* Just print the log-in warning message */
213
  this._actions( 'info', response.data.message, response.data.btnText, 4 );
214
  this.generalElement.children().first().addClass( 'wp_ulike_click_is_disabled' );
@@ -216,8 +218,13 @@
216
  default: /* Just print the permission faild message */
217
  this._actions( 'warning', response.data.message, response.data.btnText, 0 );
218
  }
 
 
 
 
 
219
  },
220
-
221
  _actions: function( messageType, messageText, btnText, likeStatus ){
222
  //check the button types
223
  if( wp_ulike_params.button_type === 'image' ) {
@@ -227,17 +234,26 @@
227
  } else if( wp_ulike_params.button_type === 'text' ) {
228
  this.buttonElement.find('span').html(btnText);
229
  }
230
-
231
  // Display Notifications
232
  this._notif( messageType, messageText );
233
  },
234
 
 
 
 
 
 
 
 
 
 
235
  _notif: function( messageType, messageText ){
236
  //Check notifications active mode
237
  if(wp_ulike_params.notifications !== '1') return;
238
  // Display Notification
239
  $(document.body).WordpressUlikeNotifications({
240
- messageType : messageType,
241
  messageText : messageText
242
  });
243
  }
@@ -270,7 +286,7 @@
270
  $(".wpulike").WordpressUlike();
271
  });
272
  });
273
-
274
  // init WordpressUlike
275
  $(".wpulike").WordpressUlike();
276
 
1
+ /*! WP ULike - v3.3
2
  * https://wpulike.com
3
  * Alimir 2018;
4
  */
15
  // Create the defaults once
16
  var pluginName = "WordpressUlikeNotifications",
17
  defaults = {
18
+ messageType : 'success',
19
+ messageText : 'Hello World!',
20
+ messageElement: 'wpulike-message',
21
  notifContainer: 'wpulike-notification'
22
  };
23
  // The actual plugin constructor
78
  if( !$( '.' + self.settings.messageElement ).length ) {
79
  self.$notifContainer.remove();
80
  }
81
+ }).trigger('WordpressUlikeRemoveNotification');
82
+ }, 8000 );
83
  }
84
 
85
  });
112
  nonce : 0, /* Get nonce token */
113
  type : '', /* Values : likeThis (Posts),likeThisComment, likeThisActivity, likeThisTopic */
114
  likeStatus : 0, /* Values : 0 (Is not logged-in), 1 (Is not liked), 2 (Is liked), 3 (Is unliked), 4 (Already liked) */
115
+ counterSelector: '.count-box',
116
+ generalSelector: '.wp_ulike_general_class',
117
+ buttonSelector : '.wp_ulike_btn',
118
+ likersSelector : '.wp_ulike_likers_wrapper',
119
  },
120
  attributesMap = {
121
  'ulike-id' : 'ID',
131
  this.settings = $.extend( {}, defaults, options );
132
  this._defaults = defaults;
133
  this._name = pluginName;
134
+
135
  // Create main selectors
136
  this.buttonElement = this.$element.find(this.settings.buttonSelector);
137
+ this.likersElement = this.$element.find( this.settings.likersSelector );
138
  this.generalElement = this.$element.find(this.settings.generalSelector);
139
  this.counterElement = this.generalElement.find( this.settings.counterSelector );
140
 
154
  //Call _ajaxify function on click button
155
  this.buttonElement.click( this._ajaxify.bind(this) );
156
  },
157
+
158
  _ajaxify: function(){
159
  $.ajax({
160
  type:'POST',
174
  }.bind(this),
175
  success: function( response ){
176
  //remove loading class
177
+ this.generalElement.removeClass( 'wp_ulike_is_loading' );
178
  if( response.success ) {
179
  this._update( response );
180
  } else {
181
  this._notif( 'error', response.data );
182
  }
183
+
184
  $document.trigger('WordpressUlikeUpdated');
185
  }.bind(this)
186
  });
187
  },
188
+
189
  _update: function( response ){
190
  //check likeStatus
191
  switch(this.settings.likeStatus) {
192
  case 1: /* Change the status of 'is not liked' to 'liked' */
193
  this.buttonElement.attr('data-ulike-status', 4);
194
+ this.settings.likeStatus = 4;
195
  this.generalElement.addClass( 'wp_ulike_is_liked' ).removeClass( 'wp_ulike_is_not_liked' );
196
  this.generalElement.children().first().addClass( 'wp_ulike_click_is_disabled' );
197
  this.counterElement.text( response.data.data );
210
  this.generalElement.addClass('wp_ulike_is_liked').removeClass('wp_ulike_is_unliked');
211
  this.counterElement.text( response.data.data );
212
  this._actions( 'success', response.data.message, response.data.btnText, 2 );
213
+ break;
214
  case 4: /* Just print the log-in warning message */
215
  this._actions( 'info', response.data.message, response.data.btnText, 4 );
216
  this.generalElement.children().first().addClass( 'wp_ulike_click_is_disabled' );
218
  default: /* Just print the permission faild message */
219
  this._actions( 'warning', response.data.message, response.data.btnText, 0 );
220
  }
221
+
222
+ // Update likers box
223
+ if( response.data.likers !== false ){
224
+ this._likers( response.data.likers );
225
+ }
226
  },
227
+
228
  _actions: function( messageType, messageText, btnText, likeStatus ){
229
  //check the button types
230
  if( wp_ulike_params.button_type === 'image' ) {
234
  } else if( wp_ulike_params.button_type === 'text' ) {
235
  this.buttonElement.find('span').html(btnText);
236
  }
237
+
238
  // Display Notifications
239
  this._notif( messageType, messageText );
240
  },
241
 
242
+ _likers: function( template ){
243
+ // Modify likers box innerHTML
244
+ if( template !== '' ) {
245
+ this.likersElement.html( template );
246
+ } else {
247
+ this.likersElement.empty();
248
+ }
249
+ },
250
+
251
  _notif: function( messageType, messageText ){
252
  //Check notifications active mode
253
  if(wp_ulike_params.notifications !== '1') return;
254
  // Display Notification
255
  $(document.body).WordpressUlikeNotifications({
256
+ messageType : messageType,
257
  messageText : messageText
258
  });
259
  }
286
  $(".wpulike").WordpressUlike();
287
  });
288
  });
289
+
290
  // init WordpressUlike
291
  $(".wpulike").WordpressUlike();
292
 
assets/js/wp-ulike.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,e,i,s){"use strict";var n="WordpressUlikeNotifications",a={messageType:"success",messageText:"Hello World!",messageElement:"wpulike-message",notifContainer:"wpulike-notification"};function o(e,i){this.element=e,this.$element=t(e),this.settings=t.extend({},a,i),this._defaults=a,this._name=n,this.init()}t.extend(o.prototype,{init:function(){this._message(),this._container(),this._append(),this._remove()},_message:function(){this.$messageElement=t("<div/>").addClass(this.settings.messageElement+" wpulike-"+this.settings.messageType).text(this.settings.messageText)},_container:function(){t("."+this.settings.notifContainer).length||this.$element.append(t("<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(){t(this).fadeOut(300,function(){t(this).remove(),t("."+e.settings.messageElement).length||e.$notifContainer.remove()}).trigger("WordpressUlikeRemoveNotification")}),setTimeout(function(){e.$messageElement.fadeOut(300,function(){t(this).remove(),t("."+e.settings.messageElement).length||e.$notifContainer.remove()}).trigger("WordpressUlikeRemoveNotification")},8e3)}}),t.fn[n]=function(t){return this.each(function(){new o(this,t)})}}(jQuery,window,document),function(t,e,i,s){"use strict";var n="WordpressUlike",a=(t(e),t(i)),o={ID:0,nonce:0,type:"",likeStatus:0,counterSelector:wp_ulike_params.counter_selector,generalSelector:wp_ulike_params.general_selector,buttonSelector:wp_ulike_params.button_selector},l={"ulike-id":"ID","ulike-nonce":"nonce","ulike-type":"type","ulike-status":"likeStatus"};function r(e,i){for(var a in this.element=e,this.$element=t(e),this.settings=t.extend({},o,i),this._defaults=o,this._name=n,this.buttonElement=this.$element.find(this.settings.buttonSelector),this.generalElement=this.$element.find(this.settings.generalSelector),this.counterElement=this.generalElement.find(this.settings.counterSelector),l){var r=this.buttonElement.data(a);r!==s&&(this.settings[l[a]]=r)}this.init()}t.extend(r.prototype,{init:function(){this.buttonElement.click(this._ajaxify.bind(this))},_ajaxify:function(){t.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(){a.trigger("WordpressUlikeLoading"),this.generalElement.addClass("wp_ulike_is_loading")}.bind(this),success:function(t){this.generalElement.removeClass("wp_ulike_is_loading"),t.success?this._update(t):this._notif("error",t.data),a.trigger("WordpressUlikeUpdated")}.bind(this)})},_update:function(t){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(t.data.data),this._actions("success",t.data.message,t.data.btnText,4);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(t.data.data),this._actions("error",t.data.message,t.data.btnText,3);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(t.data.data),this._actions("success",t.data.message,t.data.btnText,2);break;case 4:this._actions("info",t.data.message,t.data.btnText,4),this.generalElement.children().first().addClass("wp_ulike_click_is_disabled");break;default:this._actions("warning",t.data.message,t.data.btnText,0)}},_actions:function(t,e,i,s){"image"===wp_ulike_params.button_type?3!==s&&2!==s||this.buttonElement.toggleClass("image-unlike"):"text"===wp_ulike_params.button_type&&this.buttonElement.find("span").html(i),this._notif(t,e)},_notif:function(e,s){"1"===wp_ulike_params.notifications&&t(i.body).WordpressUlikeNotifications({messageType:e,messageText:s})}}),t.fn[n]=function(e){return this.each(function(){t.data(this,"plugin_"+n)||t.data(this,"plugin_"+n,new r(this,e))})}}(jQuery,window,document),function(t){t(function(){t(this).bind("DOMNodeInserted",function(e){t(".wpulike").WordpressUlike()})}),t(".wpulike").WordpressUlike(),t("p").filter(function(){return""==this.innerHTML}).remove()}(jQuery);
1
+ !function(e,t,i,s){"use strict";var n="WordpressUlikeNotifications",a={messageType:"success",messageText:"Hello World!",messageElement:"wpulike-message",notifContainer:"wpulike-notification"};function l(t,i){this.element=t,this.$element=e(t),this.settings=e.extend({},a,i),this._defaults=a,this._name=n,this.init()}e.extend(l.prototype,{init:function(){this._message(),this._container(),this._append(),this._remove()},_message:function(){this.$messageElement=e("<div/>").addClass(this.settings.messageElement+" wpulike-"+this.settings.messageType).text(this.settings.messageText)},_container:function(){e("."+this.settings.notifContainer).length||this.$element.append(e("<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 t=this;this.$messageElement.click(function(){e(this).fadeOut(300,function(){e(this).remove(),e("."+t.settings.messageElement).length||t.$notifContainer.remove()}).trigger("WordpressUlikeRemoveNotification")}),setTimeout(function(){t.$messageElement.fadeOut(300,function(){e(this).remove(),e("."+t.settings.messageElement).length||t.$notifContainer.remove()}).trigger("WordpressUlikeRemoveNotification")},8e3)}}),e.fn[n]=function(e){return this.each(function(){new l(this,e)})}}(jQuery,window,document),function(e,t,i,s){"use strict";var n="WordpressUlike",a=(e(t),e(i)),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(t,i){for(var a in this.element=t,this.$element=e(t),this.settings=e.extend({},l,i),this._defaults=l,this._name=n,this.buttonElement=this.$element.find(this.settings.buttonSelector),this.likersElement=this.$element.find(this.settings.likersSelector),this.generalElement=this.$element.find(this.settings.generalSelector),this.counterElement=this.generalElement.find(this.settings.counterSelector),o){var r=this.buttonElement.data(a);r!==s&&(this.settings[o[a]]=r)}this.init()}e.extend(r.prototype,{init:function(){this.buttonElement.click(this._ajaxify.bind(this))},_ajaxify:function(){e.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(){a.trigger("WordpressUlikeLoading"),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),a.trigger("WordpressUlikeUpdated")}.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);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);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);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)}!1!==e.data.likers&&this._likers(e.data.likers)},_actions:function(e,t,i,s){"image"===wp_ulike_params.button_type?3!==s&&2!==s||this.buttonElement.toggleClass("image-unlike"):"text"===wp_ulike_params.button_type&&this.buttonElement.find("span").html(i),this._notif(e,t)},_likers:function(e){""!==e?this.likersElement.html(e):this.likersElement.empty()},_notif:function(t,s){"1"===wp_ulike_params.notifications&&e(i.body).WordpressUlikeNotifications({messageType:t,messageText:s})}}),e.fn[n]=function(t){return this.each(function(){e.data(this,"plugin_"+n)||e.data(this,"plugin_"+n,new r(this,t))})}}(jQuery,window,document),function(e){e(function(){e(this).bind("DOMNodeInserted",function(t){e(".wpulike").WordpressUlike()})}),e(".wpulike").WordpressUlike(),e("p").filter(function(){return""==this.innerHTML}).remove()}(jQuery);
inc/classes/class-wp-ulike-mycred.php CHANGED
@@ -8,8 +8,9 @@
8
  */
9
 
10
  if ( class_exists( 'myCRED_Hook' ) ) :
 
11
  class wp_ulike_myCRED extends myCRED_Hook {
12
-
13
  /**
14
  * Construct
15
  */
@@ -39,41 +40,49 @@ if ( class_exists( 'myCRED_Hook' ) ) :
39
  )
40
  )
41
  ), $hook_prefs, $type );
42
-
43
  }
44
-
45
  /**
46
  * Run Actions
47
  *
48
  * @since 2.3
49
  */
50
  public function run() {
51
-
52
- if ( $this->prefs['add_like']['creds'] || $this->prefs['get_like']['creds'] ) {
53
- add_action( 'wp_ulike_mycred_like' , array( $this, 'like' ) , 10, 2 );
54
- }
55
 
56
- if ( $this->prefs['add_unlike']['creds'] || $this->prefs['get_unlike']['creds'] ) {
57
- add_action( 'wp_ulike_mycred_unlike', array( $this, 'unlike' ) , 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
-
60
  }
61
-
62
-
63
  public function bp_get_auhtor_id($activity_id) {
64
  $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'display_comments' => true ) );
65
  return $activity['activities'][0]->user_id;
66
  }
67
-
68
  /**
69
  * Add Like
70
  *
71
  * @since 2.3
72
  */
73
- public function like( $id , $key, $author_id = 0 ) {
74
-
75
- $user_id = get_current_user_id();
76
-
77
  // Check for exclusion
78
  if ( $this->core->exclude_user( $user_id ) ) return;
79
 
@@ -83,15 +92,15 @@ if ( class_exists( 'myCRED_Hook' ) ) :
83
  $author_id = get_post_field( 'post_author', $id );
84
  break;
85
  case '_commentliked':
86
- $comment_id = get_comment( $id );
87
- $author_id = $comment_id->user_id;
88
  break;
89
  case '_activityliked':
90
  $author_id = $this->bp_get_auhtor_id($id);
91
  break;
92
  }
93
-
94
-
95
  if ( $user_id != $author_id ){
96
 
97
  // Award the user liking
@@ -112,7 +121,7 @@ if ( class_exists( 'myCRED_Hook' ) ) :
112
  );
113
  }
114
  }
115
- }
116
 
117
  // Award post author for being liked
118
  if ( $this->prefs['get_like']['creds'] && $author_id ) {
@@ -133,7 +142,7 @@ if ( class_exists( 'myCRED_Hook' ) ) :
133
  }
134
  }
135
  }
136
-
137
  }
138
 
139
  }
@@ -143,10 +152,8 @@ if ( class_exists( 'myCRED_Hook' ) ) :
143
  *
144
  * @since 2.3
145
  */
146
- public function unlike( $id , $key, $author_id = 0 ) {
147
-
148
- $user_id = get_current_user_id();
149
-
150
  // Check for exclusion
151
  if ( $this->core->exclude_user( $user_id ) ) return;
152
 
@@ -156,15 +163,15 @@ if ( class_exists( 'myCRED_Hook' ) ) :
156
  $author_id = get_post_field( 'post_author', $id );
157
  break;
158
  case '_commentliked':
159
- $comment_id = get_comment( $id );
160
- $author_id = $comment_id->user_id;
161
  break;
162
  case '_activityliked':
163
  $author_id = $this->bp_get_auhtor_id( $id );
164
  break;
165
- }
166
-
167
-
168
  if ( $user_id != $author_id ){
169
 
170
  // Award the user liking
@@ -200,21 +207,21 @@ if ( class_exists( 'myCRED_Hook' ) ) :
200
  );
201
  }
202
  }
203
-
204
  }
205
 
206
  }
207
-
208
-
209
  /**
210
  * Preference for wp_ulike Hook
211
  *
212
  * @since 2.3
213
  */
214
  public function preferences() {
215
-
216
  $prefs = $this->prefs;
217
-
218
  ?>
219
  <label class="subheader"><?php echo _e( 'Points for Liking content', WP_ULIKE_SLUG ); ?></label>
220
  <ol>
@@ -225,7 +232,7 @@ if ( class_exists( 'myCRED_Hook' ) ) :
225
  <li>
226
  <label for="<?php echo $this->field_id( array( 'add_like' => 'limit' ) ); ?>"><?php _e( 'Limit', WP_ULIKE_SLUG ); ?></label>
227
  <?php echo $this->hook_limit_setting( $this->field_name( array( 'add_like' => 'limit' ) ), $this->field_id( array( 'add_like' => 'limit' ) ), $prefs['add_like']['limit'] ); ?>
228
- </li>
229
  <li class="empty"></li>
230
  <li>
231
  <label for="<?php echo $this->field_id( array( 'add_like' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
@@ -242,7 +249,7 @@ if ( class_exists( 'myCRED_Hook' ) ) :
242
  <li>
243
  <label for="<?php echo $this->field_id( array( 'get_like' => 'limit' ) ); ?>"><?php _e( 'Limit', WP_ULIKE_SLUG ); ?></label>
244
  <?php echo $this->hook_limit_setting( $this->field_name( array( 'get_like' => 'limit' ) ), $this->field_id( array( 'get_like' => 'limit' ) ), $prefs['get_like']['limit'] ); ?>
245
- </li>
246
  <li class="empty"></li>
247
  <li>
248
  <label for="<?php echo $this->field_id( array( 'get_like' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
@@ -276,7 +283,7 @@ if ( class_exists( 'myCRED_Hook' ) ) :
276
  </ol>
277
  <?php
278
  }
279
-
280
  /**
281
  * Sanitise Preferences
282
  *
@@ -302,4 +309,5 @@ if ( class_exists( 'myCRED_Hook' ) ) :
302
 
303
  }
304
  }
 
305
  endif;
8
  */
9
 
10
  if ( class_exists( 'myCRED_Hook' ) ) :
11
+
12
  class wp_ulike_myCRED extends myCRED_Hook {
13
+
14
  /**
15
  * Construct
16
  */
40
  )
41
  )
42
  ), $hook_prefs, $type );
43
+
44
  }
45
+
46
  /**
47
  * Run Actions
48
  *
49
  * @since 2.3
50
  */
51
  public function run() {
52
+ // Goto status function
53
+ add_action( 'wp_ulike_after_process', array( $this, 'status' ) , 10, 4 );
54
+ }
 
55
 
56
+ /**
57
+ * Start functions by status
58
+ *
59
+ * @since 2.3
60
+ */
61
+ public function status( $id , $key, $user_id, $status ) {
62
+
63
+ switch ( $status ) {
64
+ case 'like':
65
+ $this->like( $id , $key, $user_id );
66
+ break;
67
+
68
+ default:
69
+ $this->unlike( $id , $key, $user_id );
70
  }
71
+
72
  }
73
+
 
74
  public function bp_get_auhtor_id($activity_id) {
75
  $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'display_comments' => true ) );
76
  return $activity['activities'][0]->user_id;
77
  }
78
+
79
  /**
80
  * Add Like
81
  *
82
  * @since 2.3
83
  */
84
+ public function like( $id , $key, $user_id, $author_id = 0 ) {
85
+
 
 
86
  // Check for exclusion
87
  if ( $this->core->exclude_user( $user_id ) ) return;
88
 
92
  $author_id = get_post_field( 'post_author', $id );
93
  break;
94
  case '_commentliked':
95
+ $comment_id = get_comment( $id );
96
+ $author_id = $comment_id->user_id;
97
  break;
98
  case '_activityliked':
99
  $author_id = $this->bp_get_auhtor_id($id);
100
  break;
101
  }
102
+
103
+
104
  if ( $user_id != $author_id ){
105
 
106
  // Award the user liking
121
  );
122
  }
123
  }
124
+ }
125
 
126
  // Award post author for being liked
127
  if ( $this->prefs['get_like']['creds'] && $author_id ) {
142
  }
143
  }
144
  }
145
+
146
  }
147
 
148
  }
152
  *
153
  * @since 2.3
154
  */
155
+ public function unlike( $id , $key, $user_id, $author_id = 0 ) {
156
+
 
 
157
  // Check for exclusion
158
  if ( $this->core->exclude_user( $user_id ) ) return;
159
 
163
  $author_id = get_post_field( 'post_author', $id );
164
  break;
165
  case '_commentliked':
166
+ $comment_id = get_comment( $id );
167
+ $author_id = $comment_id->user_id;
168
  break;
169
  case '_activityliked':
170
  $author_id = $this->bp_get_auhtor_id( $id );
171
  break;
172
+ }
173
+
174
+
175
  if ( $user_id != $author_id ){
176
 
177
  // Award the user liking
207
  );
208
  }
209
  }
210
+
211
  }
212
 
213
  }
214
+
215
+
216
  /**
217
  * Preference for wp_ulike Hook
218
  *
219
  * @since 2.3
220
  */
221
  public function preferences() {
222
+
223
  $prefs = $this->prefs;
224
+
225
  ?>
226
  <label class="subheader"><?php echo _e( 'Points for Liking content', WP_ULIKE_SLUG ); ?></label>
227
  <ol>
232
  <li>
233
  <label for="<?php echo $this->field_id( array( 'add_like' => 'limit' ) ); ?>"><?php _e( 'Limit', WP_ULIKE_SLUG ); ?></label>
234
  <?php echo $this->hook_limit_setting( $this->field_name( array( 'add_like' => 'limit' ) ), $this->field_id( array( 'add_like' => 'limit' ) ), $prefs['add_like']['limit'] ); ?>
235
+ </li>
236
  <li class="empty"></li>
237
  <li>
238
  <label for="<?php echo $this->field_id( array( 'add_like' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
249
  <li>
250
  <label for="<?php echo $this->field_id( array( 'get_like' => 'limit' ) ); ?>"><?php _e( 'Limit', WP_ULIKE_SLUG ); ?></label>
251
  <?php echo $this->hook_limit_setting( $this->field_name( array( 'get_like' => 'limit' ) ), $this->field_id( array( 'get_like' => 'limit' ) ), $prefs['get_like']['limit'] ); ?>
252
+ </li>
253
  <li class="empty"></li>
254
  <li>
255
  <label for="<?php echo $this->field_id( array( 'get_like' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
283
  </ol>
284
  <?php
285
  }
286
+
287
  /**
288
  * Sanitise Preferences
289
  *
309
 
310
  }
311
  }
312
+
313
  endif;
inc/classes/class-wp-ulike.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  * WP ULike Process Class
4
  *
@@ -10,22 +10,23 @@
10
  if ( ! class_exists( 'wp_ulike' ) ) {
11
 
12
  class wp_ulike{
13
-
14
- private $wpdb;
15
  /**
16
  * Instance of this class.
17
  *
18
  * @var object
19
  */
20
- protected static $instance = null;
21
 
22
  /**
23
  * Constructor
24
- */
25
  public function __construct()
26
  {
27
  global $wpdb;
28
- $this->wpdb = $wpdb;
 
29
 
30
  // Enqueue Scripts
31
  add_action( 'wp_enqueue_scripts', array( $this, 'load_assets' ) );
@@ -37,7 +38,7 @@ if ( ! class_exists( 'wp_ulike' ) ) {
37
  * @author Alimir
38
  * @since 3.0
39
  * @return Void
40
- */
41
  public function load_assets() {
42
  // If user has been disabled this page in options, then return.
43
  if( ! is_wp_ulike( wp_ulike_get_setting( 'wp_ulike_general', 'plugin_files') ) ) {
@@ -49,28 +50,23 @@ if ( ! class_exists( 'wp_ulike' ) ) {
49
  //localize script
50
  wp_localize_script( 'wp_ulike', 'wp_ulike_params', array(
51
  'ajax_url' => admin_url( 'admin-ajax.php' ),
52
- 'counter_selector' => apply_filters('wp_ulike_counter_selector', '.count-box'),
53
- 'button_selector' => apply_filters('wp_ulike_button_selector', '.wp_ulike_btn'),
54
- 'general_selector' => apply_filters('wp_ulike_general_selector', '.wp_ulike_general_class'),
55
  'button_type' => wp_ulike_get_setting( 'wp_ulike_general', 'button_type'),
56
  'notifications' => wp_ulike_get_setting( 'wp_ulike_general', 'notifications')
57
  ));
58
  wp_enqueue_style( 'wp-ulike', WP_ULIKE_ASSETS_URL . '/css/wp-ulike.min.css' );
59
-
60
  //add your custom style from setting panel.
61
  wp_add_inline_style( 'wp-ulike', wp_ulike_get_custom_style() );
62
- }
63
-
64
  /**
65
  * Select the logging type
66
  *
67
  * @author Alimir
68
  * @param Array $data
69
  * @since 2.0
70
- * @updated 2.8 //Added switch statement
71
- * @updated 2.9
72
  * @return String
73
- */
74
  public function wp_get_ulike( array $data ){
75
  //get loggin method option
76
  $loggin_method = wp_ulike_get_setting( $data['setting'], 'logging_method');
@@ -97,44 +93,45 @@ if ( ! class_exists( 'wp_ulike' ) ) {
97
  * @param Array $data
98
  * @param String $output
99
  * @since 2.0
100
- * @updated 2.3
101
- * @updated 2.8 //Added 'get_template' changes & Removed some variables
102
- * @updated 2.9
103
  * @return String
104
- */
105
  public function do_not_log_method( array $data, $output = '' ){
106
  // Extract data
107
  extract( $data );
108
-
109
  if( $type == 'post' ){
110
  $output = $this->get_template( $data, 1 );
111
 
112
  } elseif( $type == 'process' ){
113
- // Update data
114
- $this->update_meta_data( $id, $key, $get_like + 1 );
115
  // Insert log data
116
- $this->wpdb->insert(
117
- $this->wpdb->prefix . $table,
118
- array(
119
- $column => $id,
120
  'date_time' => current_time( 'mysql' ),
121
  'ip' => $user_ip,
122
  'user_id' => $user_id,
123
- 'status' => 'like'
 
 
 
 
 
 
 
 
 
 
 
 
124
  )
125
  );
126
- // Add buddypress activity
127
- if( is_user_logged_in() ){
128
- wp_ulike_bp_activity_add( $user_id, $id, $key );
129
- }
130
- // Mycred points
131
- do_action( 'wp_ulike_mycred_like', $id, $key );
132
- // Output format
133
- $output = wp_ulike_format_number( $get_like + 1 );
134
 
135
  }
136
 
137
- return $output;
138
  }
139
 
140
  /**
@@ -144,14 +141,11 @@ if ( ! class_exists( 'wp_ulike' ) ) {
144
  * @param Array $data
145
  * @param String $output
146
  * @since 2.0
147
- * @updated 2.3
148
- * @updated 2.8 //Added 'get_template' changes & Removed some variables
149
- * @updated 2.9
150
  * @return String
151
- */
152
  public function loggedby_cookie_method( array $data, $output = '' ){
153
  // Extract data
154
- extract( $data );
155
 
156
  if( $type == 'post' ){
157
 
@@ -165,69 +159,64 @@ if ( ! class_exists( 'wp_ulike' ) ) {
165
  } elseif( $type == 'process' ) {
166
 
167
  if( ! isset( $_COOKIE[ $cookie . $id ] ) ){
168
- // Update data
169
- $this->update_meta_data( $id, $key, $get_like + 1 );
170
  // Set cookie
171
  setcookie( $cookie . $id, time(), 2147483647, '/' );
172
  // Insert log data
173
- $this->wpdb->insert(
174
- $this->wpdb->prefix . $table,
175
- array(
176
- $column => $id,
177
  'date_time' => current_time( 'mysql' ),
178
  'ip' => $user_ip,
179
  'user_id' => $user_id,
180
- 'status' => 'like'
181
  )
182
- );
183
- // Add buddypress activity
184
- if( is_user_logged_in() ){
185
- wp_ulike_bp_activity_add( $user_id, $id, $key );
186
- }
187
- // Mycred points
188
- do_action( 'wp_ulike_mycred_like', $id, $key );
189
- // Output format
190
- $output = wp_ulike_format_number( $get_like + 1 );
191
 
192
- } else {
193
- $output = wp_ulike_format_number( $get_like );
194
  }
 
 
 
 
 
 
 
 
 
 
 
 
195
 
196
  }
197
 
198
- return $output;
199
  }
200
-
201
  /**
202
  * Logged by IP method
203
  *
204
  * @author Alimir
205
  * @param Array $data
206
  * @since 2.0
207
- * @updated 2.3
208
- * @updated 2.8 //Added 'get_template' changes & Removed some variables
209
- * @updated 2.9
210
  * @return String
211
- */
212
  public function loggedby_ip_method( array $data, $output = '' ){
213
- // Extract data
214
- extract( $data );
215
  // Check the user's likes history
216
- $is_user_liked_before = $this->wpdb->get_var( "
217
- SELECT COUNT(*)
218
- FROM ".$this->wpdb->prefix.$table."
219
- WHERE $column = '$id'
220
- AND ip = '$user_ip'
221
- ");
222
  if( $type == 'post' ) {
223
 
224
- if( ! $is_user_liked_before ){
225
  $output = $this->get_template( $data, 3 );
226
 
227
  } else {
228
 
229
  if( $this->get_user_status( $table, $column, 'ip', $id, $user_ip ) == "like" ){
230
- $output = $this->get_template( $data, 2 );
231
  } else{
232
  $output = $this->get_template( $data, 3 );
233
  }
@@ -236,70 +225,59 @@ if ( ! class_exists( 'wp_ulike' ) ) {
236
 
237
  } elseif( $type == 'process' ) {
238
 
239
- if( ! $is_user_liked_before ){
240
- // Update data
241
- $this->update_meta_data( $id, $key, $get_like + 1 );
242
  // Insert log data
243
- $this->wpdb->insert(
244
- $this->wpdb->prefix . $table,
245
- array(
246
- $column => $id,
247
  'date_time' => current_time( 'mysql' ),
248
  'ip' => $user_ip,
249
  'user_id' => $user_id,
250
- 'status' => 'like'
251
  )
252
  );
253
- // Add buddypress activity
254
- if(is_user_logged_in()){
255
- wp_ulike_bp_activity_add( $user_id, $id, $key );
256
- }
257
- // Mycred points
258
- do_action( 'wp_ulike_mycred_like', $id, $key );
259
- // Output format
260
- $output = wp_ulike_format_number( $get_like + 1 );
261
 
262
  } else {
263
 
264
- if( $this->get_user_status( $table, $column,'ip', $id, $user_ip ) == "like" ){
265
- // Update data (Unlike)
266
- $this->update_meta_data( $id, $key, $get_like - 1 );
267
- // Update status to unlike
268
- $this->wpdb->update(
269
- $this->wpdb->prefix . $table,
270
- array(
271
- 'status' => 'unlike'
272
- ),
273
- array( $column => $id, 'ip' => $user_ip )
274
- );
275
- // Update Mycred points
276
- do_action( 'wp_ulike_mycred_unlike', $id, $key );
277
- // Output format
278
- $output = wp_ulike_format_number( $get_like - 1 );
279
-
280
  } else {
281
- // Update data
282
- $this->update_meta_data( $id, $key, $get_like + 1 );
283
- // Update status to like
284
- $this->wpdb->update(
285
- $this->wpdb->prefix . $table,
286
- array(
287
- 'status' => 'like'
288
- ),
289
- array( $column => $id, 'ip' => $user_ip )
290
- );
291
- // Update Mycred points
292
- do_action( 'wp_ulike_mycred_like', $id, $key );
293
- // Output format
294
- $output = wp_ulike_format_number( $get_like + 1 );
295
  }
 
 
 
 
 
 
 
 
296
  }
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  }
299
 
300
- return $output;
301
  }
302
-
303
  /**
304
  * Logged by IP/UserName method
305
  *
@@ -307,32 +285,20 @@ if ( ! class_exists( 'wp_ulike' ) ) {
307
  * @param Array $data
308
  * @param String $output
309
  * @since 2.0
310
- * @updated 2.3
311
- * @updated 2.4.2
312
- * @updated 2.8 // Added 'get_template' changes & Removed some variables
313
- * @updated 2.9 // Removed some old functionalities
314
  * @return String
315
- */
316
  public function loggedby_username( array $data, $output = '' ){
317
- // Extract data
318
- extract( $data );
319
  // Check the user's likes history
320
- $is_user_liked_before = $this->wpdb->get_var( "
321
- SELECT COUNT(*)
322
- FROM ".$this->wpdb->prefix.$table."
323
- WHERE $column = '$id'
324
- AND user_id = '$user_id'
325
- ");
326
- // check for user data
327
- // @TODO: Maybe we should skip this condition!
328
- // $is_user_exist = get_userdata( $user_id ) ? true : false;
329
-
330
  if( $type == 'post' ){
331
 
332
- if( ! $is_user_liked_before ){
333
  $output = $this->get_template( $data, 3 );
334
 
335
- } elseif( $is_user_liked_before /*&& $is_user_exist*/ ) {
336
 
337
  if( $this->get_user_status( $table, $column, 'user_id', $id, $user_id ) == "like" ) {
338
  $output = $this->get_template( $data, 2 );
@@ -341,75 +307,61 @@ if ( ! class_exists( 'wp_ulike' ) ) {
341
  $output = $this->get_template( $data, 3 );
342
  }
343
 
344
- }/* else {
345
- $output = $this->get_template( $data, 4 );
346
- }*/
347
 
348
  } elseif( $type == 'process' ) {
349
 
350
- if( ! $is_user_liked_before ){
351
- // Update meta data
352
- $this->update_meta_data( $id, $key, $get_like + 1 );
353
  // Insert log data
354
- $this->wpdb->insert(
355
- $this->wpdb->prefix . $table,
356
- array(
357
- $column => $id,
358
  'date_time' => current_time( 'mysql' ),
359
  'ip' => $user_ip,
360
  'user_id' => $user_id,
361
- 'status' => 'like'
362
  )
363
- );
364
- // Add buddypress activity
365
- if( is_user_logged_in() ){
366
- wp_ulike_bp_activity_add( $user_id, $id, $key );
367
- }
368
- // Update mycred points
369
- do_action( 'wp_ulike_mycred_like', $id, $key );
370
- // Set new output
371
- $output = wp_ulike_format_number( $get_like + 1 );
372
-
373
- } elseif( $is_user_liked_before /*&& $is_user_exist*/ ) {
374
-
375
- if( $this->get_user_status( $table, $column, 'user_id', $id, $user_id ) == "like") {
376
- $this->update_meta_data( $id, $key, $get_like - 1 );
377
- // Update status to unlike
378
- $this->wpdb->update(
379
- $this->wpdb->prefix . $table,
380
- array(
381
- 'status' => 'unlike'
382
- ),
383
- array( $column => $id, 'user_id' => $user_id )
384
- );
385
- // Update mycred points
386
- do_action( 'wp_ulike_mycred_unlike', $id, $key );
387
- // Set new output
388
- $output = wp_ulike_format_number( $get_like - 1 );
389
 
 
 
 
 
390
  } else {
391
- // Update meta data
392
- $this->update_meta_data( $id, $key, $get_like + 1 );
393
- // Update status to like
394
- $this->wpdb->update(
395
- $this->wpdb->prefix . $table,
396
- array(
397
- 'status' => 'like'
398
- ),
399
- array( $column => $id, 'user_id' => $user_id )
400
- );
401
- // Update mycred points
402
- do_action( 'wp_ulike_mycred_like', $id, $key );
403
- // Set new output
404
- $output = wp_ulike_format_number( $get_like + 1 );
405
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
 
407
- }/* else {
408
- $output = wp_ulike_format_number( $get_like );
409
- }*/
410
  }
411
 
412
- return $output;
413
  }
414
 
415
  /**
@@ -420,14 +372,9 @@ if ( ! class_exists( 'wp_ulike' ) ) {
420
  * @param String $key
421
  * @param Integer $data
422
  * @since 2.0
423
- * @updated 2.2
424
- * @updated 2.9
425
- * @updated 3.0
426
  * @return Void
427
- */
428
- public function update_meta_data($id, $key, $data){
429
- // Update Likers box by removing the old transient
430
- delete_transient( 'wp_ulike_likers_box_for_' . $key . $id );
431
  // Update Values
432
  switch ( $key ) {
433
  case '_liked' :
@@ -449,11 +396,11 @@ if ( ! class_exists( 'wp_ulike' ) ) {
449
  bp_activity_update_meta( $id, $key, $data );
450
  delete_transient( 'wp_ulike_get_most_liked_activities' );
451
  break;
452
- default:
453
- return 0;
454
  }
 
 
455
  }
456
-
457
 
458
  /**
459
  * Get template
@@ -462,19 +409,16 @@ if ( ! class_exists( 'wp_ulike' ) ) {
462
  * @param Array $args
463
  * @param Integer $status ( 0 = Is not logged, 1 = Is not liked, 2 = Is liked in the past, 3 = Is unliked, 4 = Is already liked )
464
  * @since 2.0
465
- * @updated 2.3
466
- * @updated 2.7 //Added 'wp_ulike_count_box_template' filter
467
- * @updated 2.8 //Removed some old variables & added a new functionality
468
  * @return String
469
- */
470
- public function get_template( array $args, $status ){
471
-
472
  $button_type = wp_ulike_get_setting( 'wp_ulike_general', 'button_type' );
473
  //Primary button class name
474
  $button_class_name = str_replace( ".", "", apply_filters( 'wp_ulike_button_selector', 'wp_ulike_btn' ) );
475
  //Button text value
476
  $button_text = '';
477
-
478
  if( $button_type == 'image' ){
479
  $button_class_name .= ' wp_ulike_put_image';
480
  if($status == 2){
@@ -488,9 +432,9 @@ if ( ! class_exists( 'wp_ulike' ) ) {
488
  $button_text = html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text' ) );
489
  }
490
  }
491
-
492
  $general_class_name = str_replace( ".", "", apply_filters( 'wp_ulike_general_selector', 'wp_ulike_general_class' ) );
493
-
494
  switch ($status){
495
  case 0:
496
  $general_class_name .= ' wp_ulike_is_not_logged';
@@ -505,44 +449,45 @@ if ( ! class_exists( 'wp_ulike' ) ) {
505
  $general_class_name .= ' wp_ulike_is_unliked';
506
  break;
507
  case 4:
508
- $general_class_name .= ' wp_ulike_is_already_liked';
509
- }
510
-
511
  $counter = apply_filters( 'wp_ulike_count_box_template', '<span class="count-box">'. wp_ulike_format_number( $args['get_like'] ) .'</span>' , $args['get_like'] );
512
-
513
  $wp_ulike_template = apply_filters( 'wp_ulike_add_templates_args', array(
514
- "ID" => $args['id'],
515
- "wrapper_class" => $args['wrapper_class'],
516
- "slug" => $args['slug'],
517
- "counter" => $counter,
518
- "type" => $args['method'],
519
- "status" => $status,
520
- "attributes" => $args['attributes'],
521
- "microdata" => $args['microdata'],
522
- "style" => $args['style'],
523
- "button_type" => $button_type,
524
- "button_text" => $button_text,
525
- "general_class" => $general_class_name,
526
- "button_class" => $button_class_name
 
527
  )
528
  );
529
-
530
-
531
  $wp_ulike_callback = call_user_func( 'wp_ulike_generate_templates_list' );
532
-
533
  $output = '';
534
-
535
  foreach( $wp_ulike_callback as $key => $value ){
536
  if ( $key === $args['style'] ) {
537
  $output = call_user_func( $value['callback'], $wp_ulike_template );
538
  break;
539
- }
540
  }
541
-
542
  return apply_filters( 'wp_ulike_return_final_templates', trim( preg_replace( '/\s+/',' ', $output ) ), $wp_ulike_template );
543
-
544
- }
545
-
546
  /**
547
  * Get User Status (like/dislike)
548
  *
@@ -558,84 +503,85 @@ if ( ! class_exists( 'wp_ulike' ) ) {
558
  public function get_user_status( $table, $first_column, $second_column, $first_val, $second_val ){
559
  // This will return like|unlike
560
  return $this->wpdb->get_var( "
561
- SELECT status
562
- FROM ".$this->wpdb->prefix."$table
563
- WHERE $first_column = '$first_val'
564
  AND $second_column = '$second_val'
565
  ");
566
  }
567
-
568
  /**
569
  * Get Liked User
570
  *
571
  * @author Alimir
572
  * @param Array $arg
573
  * @since 2.0
574
- * @updated 2.3
575
- * @updated 2.9
576
  * @return String
577
  */
578
- public function get_liked_users( array $args ){
579
  // Extract input array
580
  extract( $args );
581
  // If likers box has been disabled
582
  if ( ! wp_ulike_get_setting( $setting, 'users_liked_box' ) ) return;
583
- // Get any existing copy of our transient data
584
- if ( false === ( $users_list = get_transient( 'wp_ulike_likers_box_for_' . $key . $id ) ) ) {
585
- // Get user's limit number value
586
- $limit_num = wp_ulike_get_setting( $setting, 'number_of_users');
587
- // Set default value if limit_num equals to zero
588
- $limit_num = $limit_num != 0 ? $limit_num : 10;
589
- // Get likers list
590
- $get_users = $this->wpdb->get_results( "SELECT user_id FROM ".$this->wpdb->prefix."$table WHERE $column = '$id' AND status = 'like' AND user_id BETWEEN 1 AND 999999 GROUP BY user_id LIMIT $limit_num" );
591
-
592
- if( ! empty( $get_users ) ){
593
-
594
- // Get likers html template
595
- $get_template = wp_ulike_get_setting( $setting, 'users_liked_box_template' );
596
- // Set default template if get_template was empty
597
- $get_template = empty( $get_template ) ? '<br /><p style="margin-top:5px">'. __('Users who have LIKED this post:',WP_ULIKE_SLUG) .'</p> <ul class="tiles"> %START_WHILE% <li><a class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li> %END_WHILE%</ul>' : $get_template;
598
-
599
- $inner_template = $this->get_template_between( $get_template, "%START_WHILE%", "%END_WHILE%" );
600
-
601
- foreach ( $get_users as $get_user ) {
602
- $user_info = get_userdata($get_user->user_id);
603
- $out_template = $inner_template;
604
- if ($user_info):
605
- if( strpos( $out_template, '%USER_AVATAR%' ) !== false ) {
606
- $avatar_size = wp_ulike_get_setting( $setting, 'users_liked_box_avatar_size' );
607
- $USER_AVATAR = get_avatar( $user_info->user_email, $avatar_size, '' , 'avatar' );
608
- $out_template = str_replace( "%USER_AVATAR%", $USER_AVATAR, $out_template );
609
- }
610
- if( strpos( $out_template, '%USER_NAME%' ) !== false) {
611
- $USER_NAME = $user_info->display_name;
612
- $out_template = str_replace( "%USER_NAME%", $USER_NAME, $out_template );
613
- }
614
- if( strpos( $out_template, '%UM_PROFILE_URL%' ) !== false && function_exists('um_fetch_user') ) {
615
- global $ultimatemember;
616
- um_fetch_user( $user_info->ID );
617
- $UM_PROFILE_URL = um_user_profile_url();
618
- $out_template = str_replace( "%UM_PROFILE_URL%", $UM_PROFILE_URL, $out_template );
619
- }
620
- if( strpos( $out_template, '%BP_PROFILE_URL%' ) !== false && function_exists('bp_core_get_user_domain') ) {
621
- $BP_PROFILE_URL = bp_core_get_user_domain( $user_info->ID );
622
- $out_template = str_replace( "%BP_PROFILE_URL%", $BP_PROFILE_URL, $out_template );
623
- }
624
- $users_list .= $out_template;
625
- endif;
626
- }
627
 
628
- if( ! empty($users_list) ) {
629
- $users_list = $this->put_template_between( $get_template,$users_list, "%START_WHILE%", "%END_WHILE%" );
630
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
 
632
- set_transient( 'wp_ulike_likers_box_for_' . $key . $id, $users_list, 12 * HOUR_IN_SECONDS );
 
633
  }
 
 
 
 
 
 
 
634
  }
635
 
636
- return $users_list;
637
  }
638
-
639
  /**
640
  * Get Current User Likes List
641
  *
@@ -643,22 +589,40 @@ if ( ! class_exists( 'wp_ulike' ) ) {
643
  * @param Array $args
644
  * @since 2.3
645
  * @return Array
646
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  public function get_current_user_likes( array $args ){
648
  extract( $args );
649
  // Get user likes
650
  return $this->wpdb->get_results( "
651
- SELECT $col, date_time
652
- FROM ".$this->wpdb->prefix.$table."
653
- WHERE user_id = '$user_id'
654
- AND status = 'like'
655
- ORDER BY date_time
656
- DESC
657
- LIMIT $limit
658
- ");
659
  }
660
 
661
-
662
  /**
663
  * Get template between
664
  *
@@ -691,7 +655,7 @@ if ( ! class_exists( 'wp_ulike' ) ) {
691
  * @param String $end
692
  * @since 2.0
693
  * @return String
694
- */
695
  public function put_template_between( $string, $inner_string, $start, $end ){
696
  $string = " ".$string;
697
  $ini = strpos($string,$start);
@@ -702,7 +666,7 @@ if ( ! class_exists( 'wp_ulike' ) ) {
702
  $ini += strlen($start);
703
  $len = strpos($string,$end,$ini) - $ini;
704
  $newstr = substr_replace($string,$inner_string,$ini,$len);
705
-
706
  return str_replace(
707
  array( "%START_WHILE%", "%END_WHILE%" ),
708
  array( "", "" ),
@@ -716,17 +680,17 @@ if ( ! class_exists( 'wp_ulike' ) ) {
716
  * @author Alimir
717
  * @since 2.0
718
  * @return String
719
- */
720
  function get_reutrn_id(){
721
  global $user_ID,$wp_user_IP;
722
-
723
  if( ! is_user_logged_in() ){
724
  return ip2long($wp_user_IP);
725
  } else {
726
  return $user_ID;
727
  }
728
  }
729
-
730
  /**
731
  * Return an instance of this class.
732
  *
@@ -740,9 +704,9 @@ if ( ! class_exists( 'wp_ulike' ) ) {
740
  }
741
 
742
  return self::$instance;
743
- }
744
-
745
-
746
  }
747
-
748
  }
1
+ <?php
2
  /**
3
  * WP ULike Process Class
4
  *
10
  if ( ! class_exists( 'wp_ulike' ) ) {
11
 
12
  class wp_ulike{
13
+
14
+ private $wpdb, $status;
15
  /**
16
  * Instance of this class.
17
  *
18
  * @var object
19
  */
20
+ protected static $instance = null;
21
 
22
  /**
23
  * Constructor
24
+ */
25
  public function __construct()
26
  {
27
  global $wpdb;
28
+ $this->wpdb = $wpdb;
29
+ $this->status = 'like';
30
 
31
  // Enqueue Scripts
32
  add_action( 'wp_enqueue_scripts', array( $this, 'load_assets' ) );
38
  * @author Alimir
39
  * @since 3.0
40
  * @return Void
41
+ */
42
  public function load_assets() {
43
  // If user has been disabled this page in options, then return.
44
  if( ! is_wp_ulike( wp_ulike_get_setting( 'wp_ulike_general', 'plugin_files') ) ) {
50
  //localize script
51
  wp_localize_script( 'wp_ulike', 'wp_ulike_params', array(
52
  'ajax_url' => admin_url( 'admin-ajax.php' ),
 
 
 
53
  'button_type' => wp_ulike_get_setting( 'wp_ulike_general', 'button_type'),
54
  'notifications' => wp_ulike_get_setting( 'wp_ulike_general', 'notifications')
55
  ));
56
  wp_enqueue_style( 'wp-ulike', WP_ULIKE_ASSETS_URL . '/css/wp-ulike.min.css' );
57
+
58
  //add your custom style from setting panel.
59
  wp_add_inline_style( 'wp-ulike', wp_ulike_get_custom_style() );
60
+ }
61
+
62
  /**
63
  * Select the logging type
64
  *
65
  * @author Alimir
66
  * @param Array $data
67
  * @since 2.0
 
 
68
  * @return String
69
+ */
70
  public function wp_get_ulike( array $data ){
71
  //get loggin method option
72
  $loggin_method = wp_ulike_get_setting( $data['setting'], 'logging_method');
93
  * @param Array $data
94
  * @param String $output
95
  * @since 2.0
 
 
 
96
  * @return String
97
+ */
98
  public function do_not_log_method( array $data, $output = '' ){
99
  // Extract data
100
  extract( $data );
101
+
102
  if( $type == 'post' ){
103
  $output = $this->get_template( $data, 1 );
104
 
105
  } elseif( $type == 'process' ){
106
+ // Increment like counter
107
+ ++$get_like;
108
  // Insert log data
109
+ $this->wpdb->insert(
110
+ $this->wpdb->prefix . $table,
111
+ array(
112
+ $column => $id,
113
  'date_time' => current_time( 'mysql' ),
114
  'ip' => $user_ip,
115
  'user_id' => $user_id,
116
+ 'status' => $this->status
117
+ )
118
+ );
119
+ // Formatting the output
120
+ $output = wp_ulike_format_number( $this->update_meta_data( $id, $key, $get_like ) );
121
+ // After process hook
122
+ do_action_ref_array( 'wp_ulike_after_process',
123
+ array(
124
+ 'id' => $id,
125
+ 'key' => $key,
126
+ 'user_id' => $user_id,
127
+ 'status' => $this->status,
128
+ 'has_log' => $this->has_log( $data )
129
  )
130
  );
 
 
 
 
 
 
 
 
131
 
132
  }
133
 
134
+ return $output;
135
  }
136
 
137
  /**
141
  * @param Array $data
142
  * @param String $output
143
  * @since 2.0
 
 
 
144
  * @return String
145
+ */
146
  public function loggedby_cookie_method( array $data, $output = '' ){
147
  // Extract data
148
+ extract( $data );
149
 
150
  if( $type == 'post' ){
151
 
159
  } elseif( $type == 'process' ) {
160
 
161
  if( ! isset( $_COOKIE[ $cookie . $id ] ) ){
162
+ // Increment like counter
163
+ ++$get_like;
164
  // Set cookie
165
  setcookie( $cookie . $id, time(), 2147483647, '/' );
166
  // Insert log data
167
+ $this->wpdb->insert(
168
+ $this->wpdb->prefix . $table,
169
+ array(
170
+ $column => $id,
171
  'date_time' => current_time( 'mysql' ),
172
  'ip' => $user_ip,
173
  'user_id' => $user_id,
174
+ 'status' => $this->status
175
  )
176
+ );
 
 
 
 
 
 
 
 
177
 
 
 
178
  }
179
+ // Formatting the output
180
+ $output = wp_ulike_format_number( $this->update_meta_data( $id, $key, $get_like ) );
181
+ // After process hook
182
+ do_action_ref_array( 'wp_ulike_after_process',
183
+ array(
184
+ 'id' => $id,
185
+ 'key' => $key,
186
+ 'user_id' => $user_id,
187
+ 'status' => $this->status,
188
+ 'has_log' => $this->has_log( $data )
189
+ )
190
+ );
191
 
192
  }
193
 
194
+ return $output;
195
  }
196
+
197
  /**
198
  * Logged by IP method
199
  *
200
  * @author Alimir
201
  * @param Array $data
202
  * @since 2.0
 
 
 
203
  * @return String
204
+ */
205
  public function loggedby_ip_method( array $data, $output = '' ){
 
 
206
  // Check the user's likes history
207
+ $has_log = $this->has_log( $data );
208
+ // Extract data
209
+ extract( $data );
210
+
 
 
211
  if( $type == 'post' ) {
212
 
213
+ if( ! $has_log ){
214
  $output = $this->get_template( $data, 3 );
215
 
216
  } else {
217
 
218
  if( $this->get_user_status( $table, $column, 'ip', $id, $user_ip ) == "like" ){
219
+ $output = $this->get_template( $data, 2 );
220
  } else{
221
  $output = $this->get_template( $data, 3 );
222
  }
225
 
226
  } elseif( $type == 'process' ) {
227
 
228
+ if( ! $has_log ){
229
+ // Increment like counter
230
+ ++$get_like;
231
  // Insert log data
232
+ $this->wpdb->insert(
233
+ $this->wpdb->prefix . $table,
234
+ array(
235
+ $column => $id,
236
  'date_time' => current_time( 'mysql' ),
237
  'ip' => $user_ip,
238
  'user_id' => $user_id,
239
+ 'status' => $this->status
240
  )
241
  );
 
 
 
 
 
 
 
 
242
 
243
  } else {
244
 
245
+ if( $this->get_user_status( $table, $column, 'user_id', $id, $user_id ) === "like" ) {
246
+ // Decrement like counter
247
+ --$get_like;
248
+ $this->status = 'unlike';
 
 
 
 
 
 
 
 
 
 
 
 
249
  } else {
250
+ // Increment like counter
251
+ ++$get_like;
 
 
 
 
 
 
 
 
 
 
 
 
252
  }
253
+ // Update status
254
+ $this->wpdb->update(
255
+ $this->wpdb->prefix . $table,
256
+ array(
257
+ 'status' => $this->status
258
+ ),
259
+ array( $column => $id, 'user_id' => $user_id )
260
+ );
261
  }
262
 
263
+ // Formatting the output
264
+ $output = wp_ulike_format_number( $this->update_meta_data( $id, $key, $get_like ) );
265
+ // After process hook
266
+ do_action_ref_array( 'wp_ulike_after_process',
267
+ array(
268
+ 'id' => $id,
269
+ 'key' => $key,
270
+ 'user_id' => $user_id,
271
+ 'status' => $this->status,
272
+ 'has_log' => $has_log
273
+ )
274
+ );
275
+
276
  }
277
 
278
+ return $output;
279
  }
280
+
281
  /**
282
  * Logged by IP/UserName method
283
  *
285
  * @param Array $data
286
  * @param String $output
287
  * @since 2.0
 
 
 
 
288
  * @return String
289
+ */
290
  public function loggedby_username( array $data, $output = '' ){
 
 
291
  // Check the user's likes history
292
+ $has_log = $this->has_log( $data );
293
+ // Extract data
294
+ extract( $data );
295
+
 
 
 
 
 
 
296
  if( $type == 'post' ){
297
 
298
+ if( ! $has_log ){
299
  $output = $this->get_template( $data, 3 );
300
 
301
+ } else {
302
 
303
  if( $this->get_user_status( $table, $column, 'user_id', $id, $user_id ) == "like" ) {
304
  $output = $this->get_template( $data, 2 );
307
  $output = $this->get_template( $data, 3 );
308
  }
309
 
310
+ }
 
 
311
 
312
  } elseif( $type == 'process' ) {
313
 
314
+ if( ! $has_log ){
315
+ // Increment like counter
316
+ ++$get_like;
317
  // Insert log data
318
+ $this->wpdb->insert(
319
+ $this->wpdb->prefix . $table,
320
+ array(
321
+ $column => $id,
322
  'date_time' => current_time( 'mysql' ),
323
  'ip' => $user_ip,
324
  'user_id' => $user_id,
325
+ 'status' => $this->status
326
  )
327
+ );
328
+
329
+ } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
 
331
+ if( $this->get_user_status( $table, $column, 'user_id', $id, $user_id ) == "like" ) {
332
+ // Decrement like counter
333
+ --$get_like;
334
+ $this->status = 'unlike';
335
  } else {
336
+ // Increment like counter
337
+ ++$get_like;
 
 
 
 
 
 
 
 
 
 
 
 
338
  }
339
+ // Update status
340
+ $this->wpdb->update(
341
+ $this->wpdb->prefix . $table,
342
+ array(
343
+ 'status' => $this->status
344
+ ),
345
+ array( $column => $id, 'user_id' => $user_id )
346
+ );
347
+ }
348
+
349
+ // Formatting the output
350
+ $output = wp_ulike_format_number( $this->update_meta_data( $id, $key, $get_like ) );
351
+ // After process hook
352
+ do_action_ref_array( 'wp_ulike_after_process',
353
+ array(
354
+ 'id' => $id,
355
+ 'key' => $key,
356
+ 'user_id' => $user_id,
357
+ 'status' => $this->status,
358
+ 'has_log' => $has_log
359
+ )
360
+ );
361
 
 
 
 
362
  }
363
 
364
+ return $output;
365
  }
366
 
367
  /**
372
  * @param String $key
373
  * @param Integer $data
374
  * @since 2.0
 
 
 
375
  * @return Void
376
+ */
377
+ public function update_meta_data( $id, $key, $data ){
 
 
378
  // Update Values
379
  switch ( $key ) {
380
  case '_liked' :
396
  bp_activity_update_meta( $id, $key, $data );
397
  delete_transient( 'wp_ulike_get_most_liked_activities' );
398
  break;
 
 
399
  }
400
+
401
+ return $data;
402
  }
403
+
404
 
405
  /**
406
  * Get template
409
  * @param Array $args
410
  * @param Integer $status ( 0 = Is not logged, 1 = Is not liked, 2 = Is liked in the past, 3 = Is unliked, 4 = Is already liked )
411
  * @since 2.0
 
 
 
412
  * @return String
413
+ */
414
+ public function get_template( array $args, $status ){
415
+
416
  $button_type = wp_ulike_get_setting( 'wp_ulike_general', 'button_type' );
417
  //Primary button class name
418
  $button_class_name = str_replace( ".", "", apply_filters( 'wp_ulike_button_selector', 'wp_ulike_btn' ) );
419
  //Button text value
420
  $button_text = '';
421
+
422
  if( $button_type == 'image' ){
423
  $button_class_name .= ' wp_ulike_put_image';
424
  if($status == 2){
432
  $button_text = html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text' ) );
433
  }
434
  }
435
+
436
  $general_class_name = str_replace( ".", "", apply_filters( 'wp_ulike_general_selector', 'wp_ulike_general_class' ) );
437
+
438
  switch ($status){
439
  case 0:
440
  $general_class_name .= ' wp_ulike_is_not_logged';
449
  $general_class_name .= ' wp_ulike_is_unliked';
450
  break;
451
  case 4:
452
+ $general_class_name .= ' wp_ulike_is_already_liked';
453
+ }
454
+
455
  $counter = apply_filters( 'wp_ulike_count_box_template', '<span class="count-box">'. wp_ulike_format_number( $args['get_like'] ) .'</span>' , $args['get_like'] );
456
+
457
  $wp_ulike_template = apply_filters( 'wp_ulike_add_templates_args', array(
458
+ "ID" => $args['id'],
459
+ "wrapper_class" => $args['wrapper_class'],
460
+ "slug" => $args['slug'],
461
+ "counter" => $counter,
462
+ "type" => $args['method'],
463
+ "status" => $status,
464
+ "attributes" => $args['attributes'],
465
+ "microdata" => $args['microdata'],
466
+ "style" => $args['style'],
467
+ "button_type" => $button_type,
468
+ "button_text" => $button_text,
469
+ "general_class" => $general_class_name,
470
+ "button_class" => $button_class_name,
471
+ "display_likers" => $this->get_liked_users( $args )
472
  )
473
  );
474
+
475
+
476
  $wp_ulike_callback = call_user_func( 'wp_ulike_generate_templates_list' );
477
+
478
  $output = '';
479
+
480
  foreach( $wp_ulike_callback as $key => $value ){
481
  if ( $key === $args['style'] ) {
482
  $output = call_user_func( $value['callback'], $wp_ulike_template );
483
  break;
484
+ }
485
  }
486
+
487
  return apply_filters( 'wp_ulike_return_final_templates', trim( preg_replace( '/\s+/',' ', $output ) ), $wp_ulike_template );
488
+
489
+ }
490
+
491
  /**
492
  * Get User Status (like/dislike)
493
  *
503
  public function get_user_status( $table, $first_column, $second_column, $first_val, $second_val ){
504
  // This will return like|unlike
505
  return $this->wpdb->get_var( "
506
+ SELECT status
507
+ FROM ".$this->wpdb->prefix."$table
508
+ WHERE $first_column = '$first_val'
509
  AND $second_column = '$second_val'
510
  ");
511
  }
512
+
513
  /**
514
  * Get Liked User
515
  *
516
  * @author Alimir
517
  * @param Array $arg
518
  * @since 2.0
 
 
519
  * @return String
520
  */
521
+ public function get_liked_users( array $args, $skip_wrapper = false ){
522
  // Extract input array
523
  extract( $args );
524
  // If likers box has been disabled
525
  if ( ! wp_ulike_get_setting( $setting, 'users_liked_box' ) ) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
 
527
+ // Get user's limit number value
528
+ $limit_num = wp_ulike_get_setting( $setting, 'number_of_users');
529
+ // Set default value if limit_num equals to zero
530
+ $limit_num = $limit_num != 0 ? $limit_num : 10;
531
+ // Get likers list
532
+ $get_users = $this->wpdb->get_results( "SELECT user_id FROM ".$this->wpdb->prefix."$table WHERE $column = '$id' AND status = 'like' AND user_id BETWEEN 1 AND 999999 GROUP BY user_id LIMIT $limit_num" );
533
+
534
+ // Users list
535
+ $users_list = '';
536
+
537
+ if( ! empty( $get_users ) ) {
538
+
539
+ // Get likers html template
540
+ $get_template = wp_ulike_get_setting( $setting, 'users_liked_box_template', '<ul class="tiles">%START_WHILE%<li><a href="#" class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>' );
541
+
542
+ $inner_template = $this->get_template_between( $get_template, "%START_WHILE%", "%END_WHILE%" );
543
+
544
+ foreach ( $get_users as $get_user ) {
545
+ $user_info = get_userdata($get_user->user_id);
546
+ $out_template = $inner_template;
547
+ if ($user_info):
548
+ if( strpos( $out_template, '%USER_AVATAR%' ) !== false ) {
549
+ $avatar_size = wp_ulike_get_setting( $setting, 'users_liked_box_avatar_size' );
550
+ $USER_AVATAR = get_avatar( $user_info->user_email, $avatar_size, '' , 'avatar' );
551
+ $out_template = str_replace( "%USER_AVATAR%", $USER_AVATAR, $out_template );
552
+ }
553
+ if( strpos( $out_template, '%USER_NAME%' ) !== false) {
554
+ $USER_NAME = $user_info->display_name;
555
+ $out_template = str_replace( "%USER_NAME%", $USER_NAME, $out_template );
556
+ }
557
+ if( strpos( $out_template, '%UM_PROFILE_URL%' ) !== false && function_exists('um_fetch_user') ) {
558
+ global $ultimatemember;
559
+ um_fetch_user( $user_info->ID );
560
+ $UM_PROFILE_URL = um_user_profile_url();
561
+ $out_template = str_replace( "%UM_PROFILE_URL%", $UM_PROFILE_URL, $out_template );
562
+ }
563
+ if( strpos( $out_template, '%BP_PROFILE_URL%' ) !== false && function_exists('bp_core_get_user_domain') ) {
564
+ $BP_PROFILE_URL = bp_core_get_user_domain( $user_info->ID );
565
+ $out_template = str_replace( "%BP_PROFILE_URL%", $BP_PROFILE_URL, $out_template );
566
+ }
567
+ $users_list .= $out_template;
568
+ endif;
569
+ }
570
 
571
+ if( ! empty($users_list) ) {
572
+ $users_list = $this->put_template_between( $get_template,$users_list, "%START_WHILE%", "%END_WHILE%" );
573
  }
574
+
575
+ }
576
+
577
+ if( $skip_wrapper ) {
578
+ return $users_list;
579
+ } else {
580
+ return sprintf( '<div class="wp_ulike_likers_wrapper">%s</div>', $users_list );
581
  }
582
 
 
583
  }
584
+
585
  /**
586
  * Get Current User Likes List
587
  *
589
  * @param Array $args
590
  * @since 2.3
591
  * @return Array
592
+ */
593
+ public function has_log( array $args ){
594
+ extract( $args );
595
+ // Check the user's likes history
596
+ return $this->wpdb->get_var( "
597
+ SELECT COUNT(*)
598
+ FROM ".$this->wpdb->prefix.$table."
599
+ WHERE $column = '$id'
600
+ AND user_id = '$user_id'
601
+ " );
602
+ }
603
+
604
+ /**
605
+ * Get Current User Likes List
606
+ *
607
+ * @author Alimir
608
+ * @param Array $args
609
+ * @since 2.3
610
+ * @return Array
611
+ */
612
  public function get_current_user_likes( array $args ){
613
  extract( $args );
614
  // Get user likes
615
  return $this->wpdb->get_results( "
616
+ SELECT $col, date_time
617
+ FROM ".$this->wpdb->prefix.$table."
618
+ WHERE user_id = '$user_id'
619
+ AND status = 'like'
620
+ ORDER BY date_time
621
+ DESC
622
+ LIMIT $limit
623
+ " );
624
  }
625
 
 
626
  /**
627
  * Get template between
628
  *
655
  * @param String $end
656
  * @since 2.0
657
  * @return String
658
+ */
659
  public function put_template_between( $string, $inner_string, $start, $end ){
660
  $string = " ".$string;
661
  $ini = strpos($string,$start);
666
  $ini += strlen($start);
667
  $len = strpos($string,$end,$ini) - $ini;
668
  $newstr = substr_replace($string,$inner_string,$ini,$len);
669
+
670
  return str_replace(
671
  array( "%START_WHILE%", "%END_WHILE%" ),
672
  array( "", "" ),
680
  * @author Alimir
681
  * @since 2.0
682
  * @return String
683
+ */
684
  function get_reutrn_id(){
685
  global $user_ID,$wp_user_IP;
686
+
687
  if( ! is_user_logged_in() ){
688
  return ip2long($wp_user_IP);
689
  } else {
690
  return $user_ID;
691
  }
692
  }
693
+
694
  /**
695
  * Return an instance of this class.
696
  *
704
  }
705
 
706
  return self::$instance;
707
+ }
708
+
709
+
710
  }
711
+
712
  }
inc/frontend-ajax.php CHANGED
@@ -14,7 +14,7 @@
14
  /**
15
  * AJAX function for all like/unlike process
16
  *
17
- * @author Alimir
18
  * @since 1.0
19
  * @return String
20
  */
@@ -30,7 +30,7 @@ function wp_ulike_process(){
30
 
31
  if( $post_ID == null || ! wp_verify_nonce( $nonce_token, $post_type . $post_ID ) ) {
32
  wp_send_json_error( __( 'Error: Something Wrong Happened!', WP_ULIKE_SLUG ) );
33
- }
34
 
35
  switch ( $post_type ) {
36
  case 'likeThis':
@@ -41,16 +41,16 @@ function wp_ulike_process(){
41
  $meta_key = '_liked';
42
  $cookie_name = 'liked-';
43
  break;
44
-
45
  case 'likeThisComment':
46
  $get_meta_data = get_comment_meta($post_ID, '_commentliked', true);
47
  $setting_key = 'wp_ulike_comments';
48
  $table_name = 'ulike_comments';
49
  $column_name = 'comment_id';
50
  $meta_key = '_commentliked';
51
- $cookie_name = 'comment-liked-';
52
  break;
53
-
54
  case 'likeThisActivity':
55
  $get_meta_data = bp_activity_get_meta($post_ID, '_activityliked');
56
  $setting_key = 'wp_ulike_buddypress';
@@ -59,7 +59,7 @@ function wp_ulike_process(){
59
  $meta_key = '_activityliked';
60
  $cookie_name = 'activity-liked-';
61
  break;
62
-
63
  case 'likeThisTopic':
64
  $get_meta_data = get_post_meta($post_ID, '_topicliked', true);
65
  $setting_key = 'wp_ulike_bbpress';
@@ -68,14 +68,14 @@ function wp_ulike_process(){
68
  $meta_key = '_topicliked';
69
  $cookie_name = 'topic-liked-';
70
  break;
71
-
72
  default:
73
  wp_send_json_error( __( 'Error: This Method Is Not Exist!', WP_ULIKE_SLUG ) );
74
  }
75
-
76
  $get_like = $get_meta_data != '' ? $get_meta_data : 0;
77
  $return_userID = $wp_ulike_class->get_reutrn_id();
78
-
79
  $args = apply_filters( 'wp_ulike_ajax_process_atts', array(
80
  "id" => $post_ID, //Post ID
81
  "user_id" => $return_userID, //User ID (if the user is guest, we save ip as user_id with "ip2long" function)
@@ -85,12 +85,12 @@ function wp_ulike_process(){
85
  "setting" => $setting_key, //Setting Key
86
  "type" => 'process', //Function type (post/process)
87
  "table" => $table_name, //posts table
88
- "column" => $column_name, //ulike table column name
89
  "key" => $meta_key, //meta key
90
  "cookie" => $cookie_name //Cookie Name
91
  ), $post_ID
92
  );
93
-
94
  switch ( $like_status ){
95
  case 0:
96
  $response = array(
@@ -98,7 +98,7 @@ function wp_ulike_process(){
98
  'btnText' => html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text' ) ),
99
  'data' => NULL
100
  );
101
- break;
102
  case 1:
103
  $response = array(
104
  'message' => wp_ulike_get_setting( 'wp_ulike_general', 'like_notice' ),
@@ -112,7 +112,7 @@ function wp_ulike_process(){
112
  'btnText' => html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text' ) ),
113
  'data' => apply_filters( 'wp_ulike_respond_for_unliked_data', $wp_ulike_class->wp_get_ulike( $args ), $post_ID )
114
  );
115
- break;
116
  case 3:
117
  $response = array(
118
  'message' => wp_ulike_get_setting( 'wp_ulike_general', 'like_notice'),
@@ -128,8 +128,10 @@ function wp_ulike_process(){
128
  );
129
  }
130
 
 
 
131
  wp_send_json_success( $response );
132
  }
133
- // wp_ajax hooks for the custom AJAX requests
134
  add_action( 'wp_ajax_wp_ulike_process' , 'wp_ulike_process' );
135
- add_action( 'wp_ajax_nopriv_wp_ulike_process' , 'wp_ulike_process' );
14
  /**
15
  * AJAX function for all like/unlike process
16
  *
17
+ * @author Alimir
18
  * @since 1.0
19
  * @return String
20
  */
30
 
31
  if( $post_ID == null || ! wp_verify_nonce( $nonce_token, $post_type . $post_ID ) ) {
32
  wp_send_json_error( __( 'Error: Something Wrong Happened!', WP_ULIKE_SLUG ) );
33
+ }
34
 
35
  switch ( $post_type ) {
36
  case 'likeThis':
41
  $meta_key = '_liked';
42
  $cookie_name = 'liked-';
43
  break;
44
+
45
  case 'likeThisComment':
46
  $get_meta_data = get_comment_meta($post_ID, '_commentliked', true);
47
  $setting_key = 'wp_ulike_comments';
48
  $table_name = 'ulike_comments';
49
  $column_name = 'comment_id';
50
  $meta_key = '_commentliked';
51
+ $cookie_name = 'comment-liked-';
52
  break;
53
+
54
  case 'likeThisActivity':
55
  $get_meta_data = bp_activity_get_meta($post_ID, '_activityliked');
56
  $setting_key = 'wp_ulike_buddypress';
59
  $meta_key = '_activityliked';
60
  $cookie_name = 'activity-liked-';
61
  break;
62
+
63
  case 'likeThisTopic':
64
  $get_meta_data = get_post_meta($post_ID, '_topicliked', true);
65
  $setting_key = 'wp_ulike_bbpress';
68
  $meta_key = '_topicliked';
69
  $cookie_name = 'topic-liked-';
70
  break;
71
+
72
  default:
73
  wp_send_json_error( __( 'Error: This Method Is Not Exist!', WP_ULIKE_SLUG ) );
74
  }
75
+
76
  $get_like = $get_meta_data != '' ? $get_meta_data : 0;
77
  $return_userID = $wp_ulike_class->get_reutrn_id();
78
+
79
  $args = apply_filters( 'wp_ulike_ajax_process_atts', array(
80
  "id" => $post_ID, //Post ID
81
  "user_id" => $return_userID, //User ID (if the user is guest, we save ip as user_id with "ip2long" function)
85
  "setting" => $setting_key, //Setting Key
86
  "type" => 'process', //Function type (post/process)
87
  "table" => $table_name, //posts table
88
+ "column" => $column_name, //ulike table column name
89
  "key" => $meta_key, //meta key
90
  "cookie" => $cookie_name //Cookie Name
91
  ), $post_ID
92
  );
93
+
94
  switch ( $like_status ){
95
  case 0:
96
  $response = array(
98
  'btnText' => html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text' ) ),
99
  'data' => NULL
100
  );
101
+ break;
102
  case 1:
103
  $response = array(
104
  'message' => wp_ulike_get_setting( 'wp_ulike_general', 'like_notice' ),
112
  'btnText' => html_entity_decode( wp_ulike_get_setting( 'wp_ulike_general', 'button_text' ) ),
113
  'data' => apply_filters( 'wp_ulike_respond_for_unliked_data', $wp_ulike_class->wp_get_ulike( $args ), $post_ID )
114
  );
115
+ break;
116
  case 3:
117
  $response = array(
118
  'message' => wp_ulike_get_setting( 'wp_ulike_general', 'like_notice'),
128
  );
129
  }
130
 
131
+ $response['likers'] = is_user_logged_in() ? $wp_ulike_class->get_liked_users( $args, true ) : false;
132
+
133
  wp_send_json_success( $response );
134
  }
135
+ // wp_ajax hooks for the custom AJAX requests
136
  add_action( 'wp_ajax_wp_ulike_process' , 'wp_ulike_process' );
137
+ add_action( 'wp_ajax_nopriv_wp_ulike_process' , 'wp_ulike_process' );
inc/general-functions.php CHANGED
@@ -14,39 +14,39 @@
14
  /**
15
  * Get Settings Value
16
  *
17
- * @author Alimir
18
  * @since 1.0
19
  * @return Void
20
  */
21
  if( ! function_exists( 'wp_ulike_get_setting' ) ){
22
- function wp_ulike_get_setting( $setting, $option = false ) {
23
  $setting = get_option( $setting );
24
  if ( is_array( $setting ) ) {
25
  if ( $option ) {
26
- return isset( $setting[$option] ) ? wp_ulike_settings::parse_multi( $setting[$option] ) : false;
27
  }
28
  foreach ( $setting as $k => $v ) {
29
  $setting[$k] = wp_ulike_settings::parse_multi( $v );
30
  }
31
  return $setting;
32
  }
33
- return $option ? false : $setting;
34
  }
35
  }
36
 
37
  /**
38
- * Delete all likes number by ajax process.
39
  *
40
- * @author Alimir
41
  * @since 2.2
42
  * @return Void
43
  */
44
- if( ! function_exists( 'wp_ulike_delete_all_data' ) ){
45
  function wp_ulike_delete_all_data() {
46
  global $wpdb;
47
  $get_action = $_POST['action'];
48
  //$wpdb->hide_errors();
49
-
50
  if($get_action == 'wp_ulike_posts_delete_data'){
51
  $meta_table = $wpdb->prefix."postmeta";
52
  $meta_key = '_liked';
@@ -60,30 +60,30 @@ if( ! function_exists( 'wp_ulike_delete_all_data' ) ){
60
  $meta_table = $wpdb->prefix."postmeta";
61
  $meta_key = '_topicliked';
62
  }
63
-
64
  $do_action = $wpdb->delete($meta_table, array( 'meta_key' => $meta_key ));
65
-
66
  if ($do_action === FALSE) {
67
  wp_send_json_error( __( 'Failed! An Error Has Occurred While Deleting All ULike Logs/Data', WP_ULIKE_SLUG ));
68
  } else {
69
  wp_send_json_success( __( 'Success! All ULike Logs/Data Have Been Deleted', WP_ULIKE_SLUG ) );
70
- }
71
  }
72
  }
73
 
74
  /**
75
- * Delete all the users likes logs by ajax process.
76
  *
77
- * @author Alimir
78
  * @since 2.2
79
  * @return Void
80
  */
81
- if( ! function_exists( 'wp_ulike_delete_all_logs' ) ){
82
  function wp_ulike_delete_all_logs() {
83
  global $wpdb;
84
  $get_action = $_POST['action'];
85
  //$wpdb->hide_errors();
86
-
87
  if($get_action == 'wp_ulike_posts_delete_logs'){
88
  $logs_table = $wpdb->prefix."ulike";
89
  } else if($get_action == 'wp_ulike_comments_delete_logs'){
@@ -92,13 +92,13 @@ if( ! function_exists( 'wp_ulike_delete_all_logs' ) ){
92
  $logs_table = $wpdb->prefix."ulike_activities";
93
  } else if($get_action == 'wp_ulike_bbpress_delete_logs'){
94
  $logs_table = $wpdb->prefix."ulike_forums";
95
- }
96
-
97
  if ($wpdb->query("TRUNCATE TABLE $logs_table") === FALSE) {
98
  wp_send_json_error( __( 'Failed! An Error Has Occurred While Deleting All ULike Logs/Data', WP_ULIKE_SLUG ) );
99
  } else {
100
  wp_send_json_success( __( 'Success! All ULike Logs/Data Have Been Deleted', WP_ULIKE_SLUG ) );
101
- }
102
  }
103
  }
104
 
@@ -106,11 +106,11 @@ if( ! function_exists( 'wp_ulike_delete_all_logs' ) ){
106
  /**
107
  * Generate templates list
108
  *
109
- * @author Alimir
110
  * @since 2.8
111
  * @return Array
112
  */
113
- if( ! function_exists( 'wp_ulike_generate_templates_list' ) ){
114
  function wp_ulike_generate_templates_list(){
115
  $default = array(
116
  'wpulike-default' => array(
@@ -120,13 +120,13 @@ if( ! function_exists( 'wp_ulike_generate_templates_list' ) ){
120
  ),
121
  'wpulike-heart' => array(
122
  'name' => __('Heart', WP_ULIKE_SLUG),
123
- 'callback' => 'wp_ulike_set_simple_heart_template',
124
- 'symbol' => WP_ULIKE_ASSETS_URL . '/img/svg/heart.svg'
125
  ),
126
  'wpulike-robeen' => array(
127
  'name' => __('Robeen', WP_ULIKE_SLUG),
128
- 'callback' => 'wp_ulike_set_robeen_template',
129
- 'symbol' => WP_ULIKE_ASSETS_URL . '/img/svg/twitter.svg'
130
  )
131
  );
132
 
@@ -137,15 +137,15 @@ if( ! function_exists( 'wp_ulike_generate_templates_list' ) ){
137
  /**
138
  * Generate options info list
139
  *
140
- * @author Alimir
141
  * @since 3.1
142
  * @return Array
143
  */
144
- if( ! function_exists( 'wp_ulike_get_options_info' ) ){
145
  function wp_ulike_get_options_info( $type, $result = array() ) {
146
 
147
  switch ( $type ) {
148
- case 'general':
149
  $result = array(
150
  'title' => '<i class="dashicons-before dashicons-admin-settings"></i>' . ' ' . __( 'General',WP_ULIKE_SLUG),
151
  'fields' => array(
@@ -160,7 +160,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
160
  ),
161
  'text' => array(
162
  'name' => __('Text', WP_ULIKE_SLUG),
163
- 'symbol' => WP_ULIKE_ASSETS_URL . '/img/svg/text.svg'
164
  )
165
  )
166
  ),
@@ -181,7 +181,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
181
  'type' => 'media',
182
  'label' => __( 'Button Icon', WP_ULIKE_SLUG) . ' (' . __('Unlike', WP_ULIKE_SLUG) .')',
183
  'description' => __( 'Best size: 16x16',WP_ULIKE_SLUG)
184
- ),
185
  'permission_text' => array(
186
  'default' => __('You have not permission to unlike',WP_ULIKE_SLUG),
187
  'label' => __( 'Permission Text', WP_ULIKE_SLUG)
@@ -214,9 +214,9 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
214
  'buddypress' => __('BuddyPress Pages', WP_ULIKE_SLUG),
215
  'bbpress' => __('bbPress Pages', WP_ULIKE_SLUG),
216
  'woocommerce' => __('WooCommerce Pages', WP_ULIKE_SLUG)
217
- ),
218
  'description' => __('Remove the plugin\'s css and js file on these pages.', WP_ULIKE_SLUG)
219
- ),
220
  'format_number' => array(
221
  'type' => 'checkbox',
222
  'default' => 0,
@@ -231,6 +231,13 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
231
  'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
232
  'description' => __('Custom toast messages after each activity', WP_ULIKE_SLUG)
233
  ),
 
 
 
 
 
 
 
234
  'like_notice' => array(
235
  'default' => __('Thanks! You Liked This.',WP_ULIKE_SLUG),
236
  'label' => __( 'Liked Notice Message', WP_ULIKE_SLUG)
@@ -238,12 +245,12 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
238
  'unlike_notice' => array(
239
  'default' => __('Sorry! You unliked this.',WP_ULIKE_SLUG),
240
  'label' => __( 'Unliked Notice Message', WP_ULIKE_SLUG)
241
- )
242
  )
243
  );//end wp_ulike_general
244
  break;
245
 
246
- case 'posts':
247
  $result = array(
248
  'title' => '<i class="dashicons-before dashicons-admin-post"></i>' . ' ' . __( 'Posts',WP_ULIKE_SLUG),
249
  'fields' => array(
@@ -252,7 +259,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
252
  'default' => 'wpulike-default',
253
  'label' => __( 'Themes',WP_ULIKE_SLUG),
254
  'options' => call_user_func('wp_ulike_generate_templates_list')
255
- ),
256
  'auto_display' => array(
257
  'type' => 'checkbox',
258
  'default' => 1,
@@ -268,7 +275,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
268
  'bottom' => __('Bottom of Content', WP_ULIKE_SLUG),
269
  'top_bottom' => __('Top and Bottom', WP_ULIKE_SLUG)
270
  )
271
- ),
272
  'auto_display_filter' => array(
273
  'type' => 'multi',
274
  'label' => __( 'Auto Display Filter',WP_ULIKE_SLUG ),
@@ -330,7 +337,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
330
  ),
331
  'users_liked_box_template' => array(
332
  'type' => 'textarea',
333
- 'default' => '<br /><p style="margin-top:5px"> '.__('Users who have LIKED this post:',WP_ULIKE_SLUG).'</p> <ul class="tiles">%START_WHILE%<li><a class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>',
334
  'label' => __('Users Like Box Template', WP_ULIKE_SLUG),
335
  'description' => __('Allowed Variables:', WP_ULIKE_SLUG) . ' <code>%USER_AVATAR%</code> , <code>%BP_PROFILE_URL%</code> , <code>%UM_PROFILE_URL%</code> , <code>%USER_NAME%</code> , <code>%START_WHILE%</code> , <code>%END_WHILE%</code>'
336
  ),
@@ -339,7 +346,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
339
  'label' => __( 'Delete All Logs', WP_ULIKE_SLUG ),
340
  'description' => __( 'You Are About To Delete All Likes Logs. This Action Is Not Reversible.', WP_ULIKE_SLUG),
341
  'action' => 'wp_ulike_delete_all_logs'
342
- ),
343
  'delete_data' => array(
344
  'type' => 'action',
345
  'label' => __( 'Delete All Data', WP_ULIKE_SLUG ),
@@ -347,9 +354,9 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
347
  'action' => 'wp_ulike_delete_all_data'
348
  )
349
  )
350
- );//end wp_ulike_posts
351
  break;
352
-
353
  case 'comments':
354
  $result = array(
355
  'title' => '<i class="dashicons-before dashicons-admin-comments"></i>' . ' ' . __( 'Comments',WP_ULIKE_SLUG),
@@ -359,7 +366,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
359
  'default' => 'wpulike-heart',
360
  'label' => __( 'Themes',WP_ULIKE_SLUG),
361
  'options' => call_user_func('wp_ulike_generate_templates_list')
362
- ),
363
  'auto_display' => array(
364
  'type' => 'checkbox',
365
  'default' => 1,
@@ -375,7 +382,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
375
  'bottom' => __('Bottom of Content', WP_ULIKE_SLUG),
376
  'top_bottom' => __('Top and Bottom', WP_ULIKE_SLUG)
377
  )
378
- ),
379
  'only_registered_users' => array(
380
  'type' => 'checkbox',
381
  'default' => 0,
@@ -393,7 +400,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
393
  'by_ip' => __('Logged By IP', WP_ULIKE_SLUG),
394
  'by_username' => __('Logged By Username', WP_ULIKE_SLUG)
395
  )
396
- ),
397
  'users_liked_box' => array(
398
  'type' => 'checkbox',
399
  'default' => 1,
@@ -406,7 +413,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
406
  'default' => 32,
407
  'label' => __( 'Size of Gravatars', WP_ULIKE_SLUG),
408
  'description' => __('Size of Gravatars to return (max is 512)', WP_ULIKE_SLUG)
409
- ),
410
  'number_of_users' => array(
411
  'type' => 'number',
412
  'default' => 10,
@@ -415,7 +422,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
415
  ),
416
  'users_liked_box_template' => array(
417
  'type' => 'textarea',
418
- 'default' => '<br /><p style="margin-top:5px"> '.__('Users who have LIKED this comment:',WP_ULIKE_SLUG).'</p> <ul class="tiles">%START_WHILE%<li><a class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>',
419
  'label' => __('Users Like Box Template', WP_ULIKE_SLUG),
420
  'description' => __('Allowed Variables:', WP_ULIKE_SLUG) . ' <code>%USER_AVATAR%</code> , <code>%BP_PROFILE_URL%</code> , <code>%UM_PROFILE_URL%</code> , <code>%USER_NAME%</code> , <code>%START_WHILE%</code> , <code>%END_WHILE%</code>'
421
  ),
@@ -424,18 +431,18 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
424
  'label' => __( 'Delete All Logs', WP_ULIKE_SLUG ),
425
  'description' => __( 'You Are About To Delete All Likes Logs. This Action Is Not Reversible.', WP_ULIKE_SLUG),
426
  'action' => 'wp_ulike_delete_all_logs'
427
- ),
428
  'delete_data' => array(
429
  'type' => 'action',
430
  'label' => __( 'Delete All Data', WP_ULIKE_SLUG ),
431
  'description' => __( 'You Are About To Delete All Likes Data. This Action Is Not Reversible.', WP_ULIKE_SLUG),
432
  'action' => 'wp_ulike_delete_all_data'
433
- )
434
  )
435
- );//end wp_ulike_comments
436
  break;
437
-
438
- case 'buddypress':
439
  $result = ! function_exists('is_buddypress') ? array() : array(
440
  'title' => '<i class="dashicons-before dashicons-buddypress"></i>' . ' ' . __( 'BuddyPress',WP_ULIKE_SLUG),
441
  'fields' => array(
@@ -466,7 +473,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
466
  'label' => __('Activity Comment', WP_ULIKE_SLUG),
467
  'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
468
  'description' => __('Add the possibility to like Buddypress comments in the activity stream', WP_ULIKE_SLUG)
469
- ),
470
  'only_registered_users' => array(
471
  'type' => 'checkbox',
472
  'default' => 0,
@@ -484,7 +491,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
484
  'by_ip' => __('Logged By IP', WP_ULIKE_SLUG),
485
  'by_username' => __('Logged By Username', WP_ULIKE_SLUG)
486
  )
487
- ),
488
  'users_liked_box' => array(
489
  'type' => 'checkbox',
490
  'default' => 1,
@@ -506,7 +513,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
506
  ),
507
  'users_liked_box_template' => array(
508
  'type' => 'textarea',
509
- 'default' => '<br /><p style="margin-top:5px"> '.__('Users who have liked this activity:',WP_ULIKE_SLUG).'</p> <ul class="tiles">%START_WHILE%<li><a class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>',
510
  'label' => __('Users Like Box Template', WP_ULIKE_SLUG),
511
  'description' => __('Allowed Variables:', WP_ULIKE_SLUG) . ' <code>%USER_AVATAR%</code> , <code>%BP_PROFILE_URL%</code> , <code>%UM_PROFILE_URL%</code> , <code>%USER_NAME%</code> , <code>%START_WHILE%</code> , <code>%END_WHILE%</code>'
512
  ),
@@ -523,7 +530,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
523
  'label' => __('BuddyPress Custom Notification', WP_ULIKE_SLUG),
524
  'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
525
  'description' => __('Sends out notifications when you get a like from someone', WP_ULIKE_SLUG)
526
- ),
527
  'bp_post_activity_add_header' => array(
528
  'type' => 'textarea',
529
  'default' => '<strong>%POST_LIKER%</strong> liked <a href="%POST_PERMALINK%" title="%POST_TITLE%">%POST_TITLE%</a>. (So far, This post has <span class="badge">%POST_COUNT%</span> likes)',
@@ -541,17 +548,17 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
541
  'label' => __( 'Delete All Logs', WP_ULIKE_SLUG ),
542
  'description' => __( 'You Are About To Delete All Likes Logs. This Action Is Not Reversible.', WP_ULIKE_SLUG),
543
  'action' => 'wp_ulike_delete_all_logs'
544
- ),
545
  'delete_data' => array(
546
  'type' => 'action',
547
  'label' => __( 'Delete All Data', WP_ULIKE_SLUG ),
548
  'description' => __( 'You Are About To Delete All Likes Data. This Action Is Not Reversible.', WP_ULIKE_SLUG),
549
  'action' => 'wp_ulike_delete_all_data'
550
- )
551
  )
552
- );//end wp_ulike_buddypress
553
  break;
554
-
555
  case 'bbpress':
556
  $result = ! function_exists('is_bbpress') ? array() : array(
557
  'title' => '<i class="dashicons-before dashicons-bbpress"></i>' . ' ' . __( 'bbPress',WP_ULIKE_SLUG),
@@ -561,7 +568,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
561
  'default' => 'wpulike-default',
562
  'label' => __( 'Themes',WP_ULIKE_SLUG),
563
  'options' => call_user_func('wp_ulike_generate_templates_list')
564
- ),
565
  'auto_display' => array(
566
  'type' => 'checkbox',
567
  'default' => 1,
@@ -576,7 +583,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
576
  'top' => __('Top of Content', WP_ULIKE_SLUG),
577
  'bottom' => __('Bottom of Content', WP_ULIKE_SLUG)
578
  )
579
- ),
580
  'only_registered_users' => array(
581
  'type' => 'checkbox',
582
  'default' => 0,
@@ -616,27 +623,27 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
616
  ),
617
  'users_liked_box_template' => array(
618
  'type' => 'textarea',
619
- 'default' => '<br /><p style="margin-top:5px"> '.__('Users who have liked this topic:',WP_ULIKE_SLUG).'</p> <ul class="tiles">%START_WHILE%<li><a class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>',
620
  'label' => __('Users Like Box Template', WP_ULIKE_SLUG),
621
  'description' => __('Allowed Variables:', WP_ULIKE_SLUG) . ' <code>%USER_AVATAR%</code> , <code>%BP_PROFILE_URL%</code> , <code>%UM_PROFILE_URL%</code> , <code>%USER_NAME%</code> , <code>%START_WHILE%</code> , <code>%END_WHILE%</code>'
622
- ),
623
  'delete_logs' => array(
624
  'type' => 'action',
625
  'label' => __( 'Delete All Logs', WP_ULIKE_SLUG ),
626
  'description' => __( 'You Are About To Delete All Likes Logs. This Action Is Not Reversible.', WP_ULIKE_SLUG),
627
  'action' => 'wp_ulike_delete_all_logs'
628
- ),
629
  'delete_data' => array(
630
  'type' => 'action',
631
  'label' => __( 'Delete All Data', WP_ULIKE_SLUG ),
632
  'description' => __( 'You Are About To Delete All Likes Data. This Action Is Not Reversible.', WP_ULIKE_SLUG),
633
  'action' => 'wp_ulike_delete_all_data'
634
- )
635
  )
636
- );//end wp_ulike_buddypress
637
  break;
638
-
639
- case 'customizer':
640
  $result = array(
641
  'title' => '<i class="dashicons-before dashicons-art"></i>' . ' ' . __( 'Customize',WP_ULIKE_SLUG),
642
  'fields' => array(
@@ -647,9 +654,9 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
647
  'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
648
  'attributes' => array(
649
  'class' => 'wp_ulike_custom_style_activation'
650
- ),
651
  'description' => __('Active this option to see the custom style settings.', WP_ULIKE_SLUG)
652
- ),
653
  'btn_bg' => array(
654
  'type' => 'color',
655
  'label' => __('Button style', WP_ULIKE_SLUG),
@@ -671,7 +678,7 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
671
  'counter_border' => array(
672
  'type' => 'color',
673
  'description' => __('Border Color', WP_ULIKE_SLUG)
674
- ),
675
  'counter_color' => array(
676
  'type' => 'color',
677
  'description' => __('Text Color', WP_ULIKE_SLUG)
@@ -684,9 +691,9 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
684
  'custom_css' => array(
685
  'type' => 'textarea',
686
  'label' => __('Custom CSS', WP_ULIKE_SLUG),
687
- )
688
  )
689
- );//end wp_ulike_customize
690
  break;
691
  }
692
 
@@ -702,17 +709,17 @@ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
702
  /**
703
  * Display Like button for posts
704
  *
705
- * @author Alimir
706
  * @param String $type
707
  * @param Array $args
708
  * @since 1.0
709
  * @return String
710
  */
711
- if( ! function_exists( 'wp_ulike' ) ){
712
  function wp_ulike( $type = 'get', $args = array() ) {
713
  //global variables
714
  global $post, $wp_ulike_class, $wp_user_IP;
715
-
716
  $post_ID = isset( $args['id'] ) ? $args['id'] : $post->ID;
717
  $get_post_meta = get_post_meta( $post_ID, '_liked', true );
718
  $get_like = empty( $get_post_meta ) ? 0 : $get_post_meta;
@@ -720,7 +727,7 @@ if( ! function_exists( 'wp_ulike' ) ){
720
  $attributes = apply_filters( 'wp_ulike_posts_add_attr', null );
721
  $microdata = apply_filters( 'wp_ulike_posts_microdata', null );
722
  $style = wp_ulike_get_setting( 'wp_ulike_posts', 'theme' );
723
-
724
  //Main data
725
  $defaults = array(
726
  "id" => $post_ID, //Post ID
@@ -740,25 +747,22 @@ if( ! function_exists( 'wp_ulike' ) ){
740
  "attributes" => $attributes, //Get Attributes Filter
741
  "wrapper_class" => '' //Extra Wrapper class
742
  );
743
-
744
- $parsed_args = wp_parse_args( $args, $defaults );
745
-
746
  if( ( wp_ulike_get_setting( 'wp_ulike_posts', 'only_registered_users') != '1' ) or ( wp_ulike_get_setting( 'wp_ulike_posts', 'only_registered_users' ) == '1' && is_user_logged_in() ) ) {
747
- //call wp_get_ulike function from wp_ulike class
748
- $wp_ulike = $wp_ulike_class->wp_get_ulike( $parsed_args );
749
- $wp_ulike .= $wp_ulike_class->get_liked_users( $parsed_args );
750
 
751
  if ($type == 'put') {
752
- return $wp_ulike;
753
  }
754
  else {
755
- echo $wp_ulike;
756
  }
757
-
758
  }//end !only_registered_users condition
759
  elseif ( wp_ulike_get_setting( 'wp_ulike_posts', 'only_registered_users') == '1' && ! is_user_logged_in() ) {
760
  if(wp_ulike_get_setting( 'wp_ulike_general', 'login_type') == "button") {
761
- return $wp_ulike_class->get_template( $parsed_args, 0 ) . $wp_ulike_class->get_liked_users( $parsed_args );
762
  } else {
763
  return apply_filters('wp_ulike_login_alert_template', '<p class="alert alert-info fade in" role="alert">'.__('You need to login in order to like this post: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>');
764
  }
@@ -775,7 +779,7 @@ if( ! function_exists( 'wp_ulike' ) ){
775
  * @since 1.9
776
  * @return boolean
777
  */
778
- if( ! function_exists( 'is_wp_ulike' ) ){
779
  function is_wp_ulike( $options, $args = array() ){
780
 
781
  $defaults = array(
@@ -809,11 +813,11 @@ if( ! function_exists( 'is_wp_ulike' ) ){
809
  * Get Single Post likes number
810
  *
811
  * @author Alimir
812
- * @param Integer $post_ID
813
- * @since 1.7
814
  * @return String
815
  */
816
- if( ! function_exists( 'wp_ulike_get_post_likes' ) ){
817
  function wp_ulike_get_post_likes($post_ID){
818
  $val = get_post_meta($post_ID, '_liked', true);
819
  return wp_ulike_format_number($val);
@@ -826,10 +830,10 @@ if( ! function_exists( 'wp_ulike_get_post_likes' ) ){
826
  * @author Alimir
827
  * @param Integer $post_ID
828
  * @param Boolean $is_decimal
829
- * @since 2.7
830
  * @return String
831
  */
832
- if( ! function_exists( 'wp_ulike_get_rating_value' ) ){
833
  function wp_ulike_get_rating_value($post_ID, $is_decimal = true){
834
  global $wpdb;
835
  if (false === ($rating_value = wp_cache_get($cache_key = 'get_rich_rating_value_' . $post_ID, $cache_group = 'wp_ulike'))) {
@@ -898,29 +902,29 @@ if( ! function_exists( 'wp_ulike_get_rating_value' ) ){
898
  /*******************************************************
899
  Comments
900
  *******************************************************/
901
-
902
  /**
903
  * wp_ulike_comments function for comments like/unlike display
904
  *
905
  * @author Alimir
906
  * @param String $type
907
- * @param Array $args
908
  * @since 1.6
909
  * @return String
910
  */
911
- if( ! function_exists( 'wp_ulike_comments' ) ){
912
  function wp_ulike_comments( $type = 'get', $args = array() ) {
913
  //global variables
914
  global $wp_ulike_class, $wp_user_IP;
915
-
916
  $comment_ID = isset( $args['id'] ) ? $args['id'] : get_comment_ID();
917
  $comment_meta = get_comment_meta( $comment_ID, '_commentliked', true );
918
  $get_like = empty( $comment_meta ) ? 0 : $comment_meta;
919
  $return_userID = $wp_ulike_class->get_reutrn_id();
920
  $attributes = apply_filters( 'wp_ulike_comments_add_attr', null );
921
  $microdata = apply_filters( 'wp_ulike_comments_microdata', null );
922
- $style = wp_ulike_get_setting( 'wp_ulike_comments', 'theme' );
923
-
924
  //Main Data
925
  $defaults = array(
926
  "id" => $comment_ID, //Comment ID
@@ -940,25 +944,22 @@ if( ! function_exists( 'wp_ulike_comments' ) ){
940
  "attributes" => $attributes, //Get Attributes Filter
941
  "wrapper_class" => '' //Extra Wrapper class
942
  );
943
-
944
  $parsed_args = wp_parse_args( $args, $defaults );
945
-
946
- if( ( wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users' ) != '1' ) or ( wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users' ) == '1' && is_user_logged_in() ) ) {
947
- //call wp_get_ulike function from wp_ulike class
948
- $wp_ulike = $wp_ulike_class->wp_get_ulike( $parsed_args );
949
- $wp_ulike .= $wp_ulike_class->get_liked_users( $parsed_args );
950
 
951
  if ($type == 'put') {
952
- return $wp_ulike;
953
  }
954
  else {
955
- echo $wp_ulike;
956
  }
957
-
958
  }//end !only_registered_users condition
959
  elseif (wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users') == '1' && ! is_user_logged_in()){
960
  if( wp_ulike_get_setting( 'wp_ulike_general', 'login_type' ) == "button" ){
961
- return $wp_ulike_class->get_template( $parsed_args, 0 ) . $wp_ulike_class->get_liked_users( $parsed_args );
962
  } else {
963
  return apply_filters( 'wp_ulike_login_alert_template', '<p class="alert alert-info fade in" role="alert">'.__('You need to login in order to like this comment: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>' );
964
  }
@@ -974,7 +975,7 @@ if( ! function_exists( 'wp_ulike_comments' ) ){
974
  * @since 2.5
975
  * @return String
976
  */
977
- if( ! function_exists( 'wp_ulike_get_comment_likes' ) ){
978
  function wp_ulike_get_comment_likes( $comment_ID ){
979
  $val = get_comment_meta($comment_ID, '_commentliked', true);
980
  return wp_ulike_format_number($val);
@@ -990,7 +991,7 @@ if( ! function_exists( 'wp_ulike_get_comment_likes' ) ){
990
  *
991
  * @author Alimir
992
  * @param String $type
993
- * @param Array $args
994
  * @since 1.7
995
  * @return String
996
  */
@@ -998,20 +999,20 @@ if( ! function_exists( 'wp_ulike_buddypress' ) ){
998
  function wp_ulike_buddypress( $type = 'get', $args = array() ) {
999
  //global variables
1000
  global $wp_ulike_class, $wp_user_IP;
1001
-
1002
  if ( bp_get_activity_comment_id() != null ){
1003
  $activityID = isset( $args['id'] ) ? $args['id'] : bp_get_activity_comment_id();
1004
  } else {
1005
- $activityID = isset( $args['id'] ) ? $args['id'] : bp_get_activity_id();
1006
  }
1007
-
1008
  $bp_get_meta = bp_activity_get_meta($activityID, '_activityliked');
1009
  $get_like = empty( $bp_get_meta ) ? 0 : $bp_get_meta;
1010
  $return_userID = $wp_ulike_class->get_reutrn_id();
1011
  $attributes = apply_filters( 'wp_ulike_activities_add_attr', null );
1012
  $microdata = apply_filters( 'wp_ulike_activities_microdata', null );
1013
  $style = wp_ulike_get_setting( 'wp_ulike_buddypress', 'theme' );
1014
-
1015
  //Main Data
1016
  $defaults = array(
1017
  "id" => $activityID, //Activity ID
@@ -1022,7 +1023,7 @@ if( ! function_exists( 'wp_ulike_buddypress' ) ){
1022
  "setting" => 'wp_ulike_buddypress', //Setting Key
1023
  "type" => 'post', //Function type (post/process)
1024
  "table" => 'ulike_activities', //Activities table
1025
- "column" => 'activity_id', //ulike_activities table column name
1026
  "key" => '_activityliked', //meta key
1027
  "cookie" => 'activity-liked-', //Cookie Name
1028
  "slug" => 'activity', //Slug Name
@@ -1031,140 +1032,27 @@ if( ! function_exists( 'wp_ulike_buddypress' ) ){
1031
  "attributes" => $attributes, //Get Attributes Filter
1032
  "wrapper_class" => '' //Extra Wrapper class
1033
  );
1034
-
1035
  $parsed_args = wp_parse_args( $args, $defaults );
1036
-
1037
  if( ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'only_registered_users') != '1' ) or ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'only_registered_users' ) == '1' && is_user_logged_in() ) ) {
1038
- //call wp_get_ulike function from wp_ulike class
1039
- $wp_ulike = $wp_ulike_class->wp_get_ulike( $parsed_args );
1040
- $wp_ulike .= $wp_ulike_class->get_liked_users( $parsed_args );
1041
 
1042
  if ($type == 'put') {
1043
- return $wp_ulike;
1044
  }
1045
  else {
1046
- echo $wp_ulike;
1047
  }
1048
-
1049
  }//end !only_registered_users condition
1050
  elseif ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'only_registered_users') == '1' && ! is_user_logged_in() ) {
1051
  if( wp_ulike_get_setting( 'wp_ulike_general', 'login_type') == "button" ){
1052
- return $wp_ulike_class->get_template( $parsed_args, 0 ) . $wp_ulike_class->get_liked_users( $parsed_args );
1053
  }
1054
  else{
1055
  return apply_filters('wp_ulike_login_alert_template', '<p class="alert alert-info fade in" role="alert">'.__('You need to login in order to like this activity: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>');
1056
- }
1057
- }//end only_registered_users condition
1058
-
1059
- }
1060
- }
1061
-
1062
- /**
1063
- * Add new buddypress activities on each like.
1064
- *
1065
- * @author Alimir
1066
- * @param Integer $user_ID (User ID)
1067
- * @param Integer $cp_ID (Post/Comment ID)
1068
- * @param String $type (Simple Key for separate posts by comments)
1069
- * @since 1.6
1070
- * @return Void
1071
- */
1072
- if( ! function_exists( 'wp_ulike_bp_activity_add' ) ){
1073
- function wp_ulike_bp_activity_add( $user_ID, $cp_ID, $type ){
1074
-
1075
- //Create a new activity when an user likes something
1076
- if ( function_exists( 'bp_is_active' ) && wp_ulike_get_setting( 'wp_ulike_buddypress', 'new_likes_activity' ) == '1' ) {
1077
-
1078
- switch ( $type ) {
1079
- case '_liked':
1080
- // Replace the post variables
1081
- $post_template = wp_ulike_get_setting( 'wp_ulike_buddypress', 'bp_post_activity_add_header' );
1082
-
1083
- $post_template = $post_template == '' ? '<strong>%POST_LIKER%</strong> liked <a href="%POST_PERMALINK%" title="%POST_TITLE%">%POST_TITLE%</a>. (So far, This post has <span class="badge">%POST_COUNT%</span> likes)' : $post_template;
1084
-
1085
- if ( strpos( $post_template, '%POST_LIKER%' ) !== false ) {
1086
- $POST_LIKER = bp_core_get_userlink( $user_ID );
1087
- $post_template = str_replace( "%POST_LIKER%", $POST_LIKER, $post_template );
1088
- }
1089
- if ( strpos( $post_template, '%POST_PERMALINK%' ) !== false ) {
1090
- $POST_PERMALINK = get_permalink($cp_ID);
1091
- $post_template = str_replace( "%POST_PERMALINK%", $POST_PERMALINK, $post_template );
1092
- }
1093
- if ( strpos( $post_template, '%POST_COUNT%' ) !== false ) {
1094
- $POST_COUNT = get_post_meta( $cp_ID, '_liked', true );
1095
- $post_template = str_replace( "%POST_COUNT%", $POST_COUNT, $post_template );
1096
- }
1097
- if ( strpos( $post_template, '%POST_TITLE%' ) !== false ) {
1098
- $POST_TITLE = get_the_title( $cp_ID );
1099
- $post_template = str_replace( "%POST_TITLE%", $POST_TITLE, $post_template );
1100
- }
1101
- bp_activity_add( array(
1102
- 'user_id' => $user_ID,
1103
- 'action' => $post_template,
1104
- 'component' => 'activity',
1105
- 'type' => 'wp_like_group',
1106
- 'item_id' => $cp_ID
1107
- ));
1108
- break;
1109
-
1110
- case '_commentliked':
1111
- // Replace the comment variables
1112
- $comment_template = wp_ulike_get_setting( 'wp_ulike_buddypress', 'bp_comment_activity_add_header' );
1113
-
1114
- $comment_template = $comment_template == '' ? '<strong>%COMMENT_LIKER%</strong> liked <strong>%COMMENT_AUTHOR%</strong> comment. (So far, %COMMENT_AUTHOR% has <span class="badge">%COMMENT_COUNT%</span> likes for this comment)' : $comment_template;
1115
-
1116
- if ( strpos( $comment_template, '%COMMENT_LIKER%' ) !== false ) {
1117
- $COMMENT_LIKER = bp_core_get_userlink( $user_ID );
1118
- $comment_template = str_replace("%COMMENT_LIKER%", $COMMENT_LIKER, $comment_template );
1119
- }
1120
- if ( strpos( $comment_template, '%COMMENT_PERMALINK%' ) !== false ) {
1121
- $COMMENT_PERMALINK = get_comment_link( $cp_ID );
1122
- $comment_template = str_replace( "%COMMENT_PERMALINK%", $COMMENT_PERMALINK, $comment_template );
1123
- }
1124
- if ( strpos( $comment_template, '%COMMENT_AUTHOR%' ) !== false ) {
1125
- $COMMENT_AUTHOR = get_comment_author( $cp_ID );
1126
- $comment_template = str_replace( "%COMMENT_AUTHOR%", $COMMENT_AUTHOR, $comment_template );
1127
- }
1128
- if ( strpos( $comment_template, '%COMMENT_COUNT%' ) !== false ) {
1129
- $COMMENT_COUNT = get_comment_meta( $cp_ID, '_commentliked', true );
1130
- $comment_template = str_replace( "%COMMENT_COUNT%", $COMMENT_COUNT, $comment_template );
1131
- }
1132
- bp_activity_add( array(
1133
- 'user_id' => $user_ID,
1134
- 'action' => $comment_template,
1135
- 'component' => 'activity',
1136
- 'type' => 'wp_like_group',
1137
- 'item_id' => $cp_ID
1138
- ));
1139
- break;
1140
-
1141
- default:
1142
- break;
1143
- }
1144
-
1145
- }
1146
-
1147
- //Sends out notifications when you get a like from someone
1148
- if ( function_exists( 'bp_is_active' ) && wp_ulike_get_setting( 'wp_ulike_buddypress', 'custom_notification' ) == '1' ) {
1149
- // No notifications from Anonymous
1150
- if ( ! $user_ID ) {
1151
- return false;
1152
  }
1153
- $author_ID = wp_ulike_get_auhtor_id( $cp_ID, $type );
1154
- if ( ! $author_ID || $author_ID == $user_ID ) {
1155
- return false;
1156
- }
1157
- bp_notifications_add_notification( array(
1158
- 'user_id' => $author_ID,
1159
- 'item_id' => $cp_ID,
1160
- 'secondary_item_id' => '',
1161
- 'component_name' => 'wp_ulike',
1162
- 'component_action' => 'wp_ulike' . $type . '_action_' . $user_ID,
1163
- 'date_notified' => bp_core_current_time(),
1164
- 'is_new' => 1,
1165
- )
1166
- );
1167
- }
1168
 
1169
  }
1170
  }
@@ -1172,8 +1060,8 @@ if( ! function_exists( 'wp_ulike_bp_activity_add' ) ){
1172
  /**
1173
  * Get auther ID by the ulike types
1174
  *
1175
- * @author Alimir
1176
- * @param Integer $cp_ID (Post/Comment/... ID)
1177
  * @param String $type (Get ulike Type)
1178
  * @since 2.5
1179
  * @return String
@@ -1182,15 +1070,15 @@ if( ! function_exists( 'wp_ulike_get_auhtor_id' ) ){
1182
  function wp_ulike_get_auhtor_id($cp_ID,$type) {
1183
  if($type == '_liked' || $type == '_topicliked'){
1184
  $post_tmp = get_post($cp_ID);
1185
- return $post_tmp->post_author;
1186
  }
1187
  else if($type == '_commentliked'){
1188
  $comment = get_comment( $cp_ID );
1189
- return $comment->user_id;
1190
  }
1191
  else if( $type == '_activityliked' ){
1192
  $activity = bp_activity_get_specific( array( 'activity_ids' => $cp_ID, 'display_comments' => true ) );
1193
- return $activity['activities'][0]->user_id;
1194
  }
1195
  else return;
1196
  }
@@ -1199,7 +1087,7 @@ if( ! function_exists( 'wp_ulike_get_auhtor_id' ) ){
1199
  /**
1200
  * Wrapper for bbp_format_buddypress_notifications function as it is not returning $action
1201
  *
1202
- * @author Alimir
1203
  * @since 2.5.1
1204
  * @return String
1205
  */
@@ -1210,11 +1098,11 @@ if( ! function_exists( 'wp_ulike_bbp_format_buddypress_notifications' ) ) {
1210
  return;
1211
  }
1212
 
1213
- $result = bbp_format_buddypress_notifications(
1214
- $action,
1215
- $item_id,
1216
- $secondary_item_id,
1217
- $total_items,
1218
  $format
1219
  );
1220
 
@@ -1234,7 +1122,7 @@ if( ! function_exists( 'wp_ulike_bbp_format_buddypress_notifications' ) ) {
1234
  *
1235
  * @author Alimir
1236
  * @param String $type
1237
- * @param Array $args
1238
  * @since 2.2
1239
  * @return String
1240
  */
@@ -1242,19 +1130,19 @@ if( ! function_exists( 'wp_ulike_bbpress' ) ){
1242
  function wp_ulike_bbpress( $type = 'get', $args = array() ) {
1243
  //global variables
1244
  global $post,$wp_ulike_class,$wp_user_IP;
1245
-
1246
  //Thanks to @Yehonal for this commit
1247
  $replyID = bbp_get_reply_id();
1248
  $post_ID = !$replyID ? $post->ID : $replyID;
1249
  $post_ID = isset( $args['id'] ) ? $args['id'] : $post_ID;
1250
-
1251
  $get_post_meta = get_post_meta( $post_ID, '_topicliked', true );
1252
  $get_like = empty( $get_post_meta ) ? 0 : $get_post_meta;
1253
- $return_userID = $wp_ulike_class->get_reutrn_id();
1254
  $attributes = apply_filters( 'wp_ulike_topics_add_attr', null );
1255
  $microdata = apply_filters( 'wp_ulike_topics_microdata', null );
1256
- $style = wp_ulike_get_setting( 'wp_ulike_bbpress', 'theme' );
1257
-
1258
  //Main Data
1259
  $defaults = array(
1260
  "id" => $post_ID, //Post ID
@@ -1274,39 +1162,36 @@ if( ! function_exists( 'wp_ulike_bbpress' ) ){
1274
  "attributes" => $attributes, //Get Attributes Filter
1275
  "wrapper_class" => '' //Extra Wrapper class
1276
  );
1277
-
1278
  $parsed_args = wp_parse_args( $args, $defaults );
1279
-
1280
  if( ( wp_ulike_get_setting( 'wp_ulike_bbpress', 'only_registered_users' ) != '1' ) or ( wp_ulike_get_setting( 'wp_ulike_bbpress', 'only_registered_users' ) == '1' && is_user_logged_in() ) ) {
1281
- //call wp_get_ulike function from wp_ulike class
1282
- $wp_ulike = $wp_ulike_class->wp_get_ulike( $parsed_args );
1283
- $wp_ulike .= $wp_ulike_class->get_liked_users( $parsed_args );
1284
 
1285
  if ($type == 'put') {
1286
- return $wp_ulike;
1287
  }
1288
  else {
1289
- echo $wp_ulike;
1290
  }
1291
-
1292
  }//end !only_registered_users condition
1293
-
1294
  else if ( wp_ulike_get_setting( 'wp_ulike_bbpress', 'only_registered_users' ) == '1' && !is_user_logged_in()) {
1295
  if( wp_ulike_get_setting( 'wp_ulike_general', 'login_type') ){
1296
- return $wp_ulike_class->get_template( $parsed_args, 0 ) . $wp_ulike_class->get_liked_users( $parsed_args );
1297
  }
1298
  else {
1299
  return apply_filters('wp_ulike_login_alert_template', '<p class="alert alert-info fade in" role="alert">'.__('You need to login in order to like this post: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>');
1300
  }
1301
  }//end only_registered_users condition
1302
-
1303
  }
1304
  }
1305
 
1306
  /*******************************************************
1307
  General
1308
  *******************************************************/
1309
-
1310
  /**
1311
  * Get custom style setting from customize options
1312
  *
@@ -1314,9 +1199,9 @@ if( ! function_exists( 'wp_ulike_bbpress' ) ){
1314
  * @since 1.3
1315
  * @return Void (Print new CSS styles)
1316
  */
1317
- if( ! function_exists( 'wp_ulike_get_custom_style' ) ){
1318
  function wp_ulike_get_custom_style( $return_style = null ){
1319
-
1320
  // Like Icon
1321
  if( $get_like_icon = wp_get_attachment_url( wp_ulike_get_setting( 'wp_ulike_general', 'button_url' ) ) ) {
1322
  $return_style .= '.wp_ulike_btn.wp_ulike_put_image { background-image: url('.$get_like_icon.') !important; }';
@@ -1326,9 +1211,9 @@ if( ! function_exists( 'wp_ulike_get_custom_style' ) ){
1326
  if( $get_like_icon = wp_get_attachment_url( wp_ulike_get_setting( 'wp_ulike_general', 'button_url_u' ) ) ) {
1327
  $return_style .= '.wp_ulike_btn.wp_ulike_put_image.image-unlike { background-image: url('.$get_like_icon.') !important; }';
1328
  }
1329
-
1330
  if( wp_ulike_get_setting( 'wp_ulike_customize', 'custom_style' ) ) {
1331
-
1332
  //get custom options
1333
  $customstyle = get_option( 'wp_ulike_customize' );
1334
  $btn_style = '';
@@ -1338,33 +1223,33 @@ if( ! function_exists( 'wp_ulike_get_custom_style' ) ){
1338
  // Button Style
1339
  if( isset( $customstyle['btn_bg'] ) && ! empty( $customstyle['btn_bg'] ) ) {
1340
  $btn_style .= "background-color:".$customstyle['btn_bg'].";";
1341
- }
1342
  if( isset( $customstyle['btn_border'] ) && ! empty( $customstyle['btn_border'] ) ) {
1343
  $btn_style .= "border-color:".$customstyle['btn_border']."; ";
1344
- }
1345
  if( isset( $customstyle['btn_color'] ) && ! empty( $customstyle['btn_color'] ) ) {
1346
  $btn_style .= "color:".$customstyle['btn_color'].";text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.3);";
1347
  }
1348
 
1349
  if( $btn_style != '' ){
1350
  $return_style .= '.wpulike-default .wp_ulike_btn, .wpulike-default .wp_ulike_btn:hover, #bbpress-forums .wpulike-default .wp_ulike_btn, #bbpress-forums .wpulike-default .wp_ulike_btn:hover{'.$btn_style.'}.wpulike-heart .wp_ulike_general_class{'.$btn_style.'}';
1351
- }
1352
 
1353
  // Counter Style
1354
  if( isset( $customstyle['counter_bg'] ) && ! empty( $customstyle['counter_bg'] ) ) {
1355
  $counter_style .= "background-color:".$customstyle['counter_bg'].";";
1356
- }
1357
  if( isset( $customstyle['counter_border'] ) && ! empty( $customstyle['counter_border'] ) ) {
1358
  $counter_style .= "border-color:".$customstyle['counter_border']."; ";
1359
  $before_style = "border-color:transparent; border-bottom-color:".$customstyle['counter_border']."; border-left-color:".$customstyle['counter_border'].";";
1360
- }
1361
  if( isset( $customstyle['counter_color'] ) && ! empty( $customstyle['counter_color'] ) ) {
1362
  $counter_style .= "color:".$customstyle['counter_color'].";";
1363
  }
1364
 
1365
  if( $counter_style != '' ){
1366
  $return_style .= '.wpulike-default .count-box,.wpulike-default .count-box:before{'.$counter_style.'}.wpulike-default .count-box:before{'.$before_style.'}';
1367
- }
1368
 
1369
  // Loading Spinner
1370
  if( isset( $customstyle['loading_animation'] ) && ! empty( $customstyle['loading_animation'] ) ) {
@@ -1375,23 +1260,23 @@ if( ! function_exists( 'wp_ulike_get_custom_style' ) ){
1375
  if( isset( $customstyle['custom_css'] ) && ! empty( $customstyle['custom_css'] ) ) {
1376
  $return_style .= $customstyle['custom_css'];
1377
  }
1378
-
1379
  }
1380
 
1381
  return $return_style;
1382
  }
1383
 
1384
  }
1385
-
1386
  /**
1387
  * Convert numbers of Likes with string (kilobyte) format
1388
  *
1389
  * @author Alimir
1390
- * @param Integer $num (get like number)
1391
  * @since 1.5
1392
  * @return String
1393
  */
1394
- if( ! function_exists( 'wp_ulike_format_number' ) ){
1395
  function wp_ulike_format_number($num){
1396
  $plus = $num != 0 ? '+' : '';
1397
  if ($num >= 1000 && wp_ulike_get_setting( 'wp_ulike_general', 'format_number' ) == '1')
@@ -1402,8 +1287,8 @@ if( ! function_exists( 'wp_ulike_format_number' ) ){
1402
  return $value;
1403
  }
1404
  }
1405
-
1406
-
1407
  /**
1408
  * Date in localized format
1409
  *
@@ -1412,15 +1297,15 @@ if( ! function_exists( 'wp_ulike_format_number' ) ){
1412
  * @since 2.3
1413
  * @return String
1414
  */
1415
- if( ! function_exists( 'wp_ulike_date_i18n' ) ){
1416
  function wp_ulike_date_i18n($date){
1417
- return date_i18n(
1418
- get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ),
1419
  strtotime($date)
1420
- );
1421
  }
1422
  }
1423
-
1424
 
1425
  /*******************************************************
1426
  Templates
@@ -1429,11 +1314,11 @@ if( ! function_exists( 'wp_ulike_date_i18n' ) ){
1429
  /**
1430
  * Create simple default template
1431
  *
1432
- * @author Alimir
1433
  * @since 2.8
1434
  * @return Void
1435
  */
1436
- if( ! function_exists( 'wp_ulike_set_default_template' ) ){
1437
  function wp_ulike_set_default_template( array $wp_ulike_template ){
1438
  //This function will turn output buffering on
1439
  ob_start();
@@ -1453,7 +1338,11 @@ if( ! function_exists( 'wp_ulike_set_default_template' ) ){
1453
  </a>
1454
  <?php echo $counter; ?>
1455
  </div>
1456
- <?php echo $microdata; ?>
 
 
 
 
1457
  </div>
1458
  <?php
1459
  do_action( 'wp_ulike_after_template' );
@@ -1464,17 +1353,17 @@ if( ! function_exists( 'wp_ulike_set_default_template' ) ){
1464
  /**
1465
  * Create simple heart template
1466
  *
1467
- * @author Alimir
1468
  * @since 2.8
1469
  * @return Void
1470
  */
1471
- if( ! function_exists( 'wp_ulike_set_simple_heart_template' ) ){
1472
  function wp_ulike_set_simple_heart_template( array $wp_ulike_template ){
1473
  //This function will turn output buffering on
1474
  ob_start();
1475
  do_action( 'wp_ulike_before_template' );
1476
  // Extract input array
1477
- extract( $wp_ulike_template );
1478
  ?>
1479
  <div id="wp-ulike-<?php echo $slug . '-' . $ID; ?>" class="wpulike wpulike-heart <?php echo $wrapper_class; ?>" <?php echo $attributes; ?>>
1480
  <div class="<?php echo $general_class; ?>">
@@ -1488,7 +1377,11 @@ if( ! function_exists( 'wp_ulike_set_simple_heart_template' ) ){
1488
  </a>
1489
  <?php echo $counter; ?>
1490
  </div>
1491
- <?php echo $microdata; ?>
 
 
 
 
1492
  </div>
1493
  <?php
1494
  do_action( 'wp_ulike_after_template' );
@@ -1499,17 +1392,17 @@ if( ! function_exists( 'wp_ulike_set_simple_heart_template' ) ){
1499
  /**
1500
  * Create Robeen (Animated Heart) template
1501
  *
1502
- * @author Alimir
1503
  * @since 2.8
1504
  * @return Void
1505
  */
1506
- if( ! function_exists( 'wp_ulike_set_robeen_template' ) ){
1507
  function wp_ulike_set_robeen_template( array $wp_ulike_template ){
1508
  //This function will turn output buffering on
1509
  ob_start();
1510
- do_action( 'wp_ulike_before_template' );
1511
  // Extract input array
1512
- extract( $wp_ulike_template );
1513
  ?>
1514
  <div id="wp-ulike-<?php echo $slug . '-' . $ID; ?>" class="wpulike wpulike-robeen <?php echo $wrapper_class; ?>" <?php echo $attributes; ?>>
1515
  <div class="<?php echo $general_class; ?>">
@@ -1520,7 +1413,11 @@ if( ! function_exists( 'wp_ulike_set_robeen_template' ) ){
1520
  <?php echo $counter; ?>
1521
  </label>
1522
  </div>
1523
- <?php echo $microdata; ?>
 
 
 
 
1524
  </div>
1525
  <?php
1526
  do_action( 'wp_ulike_after_template' );
14
  /**
15
  * Get Settings Value
16
  *
17
+ * @author Alimir
18
  * @since 1.0
19
  * @return Void
20
  */
21
  if( ! function_exists( 'wp_ulike_get_setting' ) ){
22
+ function wp_ulike_get_setting( $setting, $option = false, $default = false ) {
23
  $setting = get_option( $setting );
24
  if ( is_array( $setting ) ) {
25
  if ( $option ) {
26
+ return isset( $setting[$option] ) ? wp_ulike_settings::parse_multi( $setting[$option] ) : $default;
27
  }
28
  foreach ( $setting as $k => $v ) {
29
  $setting[$k] = wp_ulike_settings::parse_multi( $v );
30
  }
31
  return $setting;
32
  }
33
+ return $option ? $default : $setting;
34
  }
35
  }
36
 
37
  /**
38
+ * Delete all likes number by ajax process.
39
  *
40
+ * @author Alimir
41
  * @since 2.2
42
  * @return Void
43
  */
44
+ if( ! function_exists( 'wp_ulike_delete_all_data' ) ){
45
  function wp_ulike_delete_all_data() {
46
  global $wpdb;
47
  $get_action = $_POST['action'];
48
  //$wpdb->hide_errors();
49
+
50
  if($get_action == 'wp_ulike_posts_delete_data'){
51
  $meta_table = $wpdb->prefix."postmeta";
52
  $meta_key = '_liked';
60
  $meta_table = $wpdb->prefix."postmeta";
61
  $meta_key = '_topicliked';
62
  }
63
+
64
  $do_action = $wpdb->delete($meta_table, array( 'meta_key' => $meta_key ));
65
+
66
  if ($do_action === FALSE) {
67
  wp_send_json_error( __( 'Failed! An Error Has Occurred While Deleting All ULike Logs/Data', WP_ULIKE_SLUG ));
68
  } else {
69
  wp_send_json_success( __( 'Success! All ULike Logs/Data Have Been Deleted', WP_ULIKE_SLUG ) );
70
+ }
71
  }
72
  }
73
 
74
  /**
75
+ * Delete all the users likes logs by ajax process.
76
  *
77
+ * @author Alimir
78
  * @since 2.2
79
  * @return Void
80
  */
81
+ if( ! function_exists( 'wp_ulike_delete_all_logs' ) ){
82
  function wp_ulike_delete_all_logs() {
83
  global $wpdb;
84
  $get_action = $_POST['action'];
85
  //$wpdb->hide_errors();
86
+
87
  if($get_action == 'wp_ulike_posts_delete_logs'){
88
  $logs_table = $wpdb->prefix."ulike";
89
  } else if($get_action == 'wp_ulike_comments_delete_logs'){
92
  $logs_table = $wpdb->prefix."ulike_activities";
93
  } else if($get_action == 'wp_ulike_bbpress_delete_logs'){
94
  $logs_table = $wpdb->prefix."ulike_forums";
95
+ }
96
+
97
  if ($wpdb->query("TRUNCATE TABLE $logs_table") === FALSE) {
98
  wp_send_json_error( __( 'Failed! An Error Has Occurred While Deleting All ULike Logs/Data', WP_ULIKE_SLUG ) );
99
  } else {
100
  wp_send_json_success( __( 'Success! All ULike Logs/Data Have Been Deleted', WP_ULIKE_SLUG ) );
101
+ }
102
  }
103
  }
104
 
106
  /**
107
  * Generate templates list
108
  *
109
+ * @author Alimir
110
  * @since 2.8
111
  * @return Array
112
  */
113
+ if( ! function_exists( 'wp_ulike_generate_templates_list' ) ){
114
  function wp_ulike_generate_templates_list(){
115
  $default = array(
116
  'wpulike-default' => array(
120
  ),
121
  'wpulike-heart' => array(
122
  'name' => __('Heart', WP_ULIKE_SLUG),
123
+ 'callback' => 'wp_ulike_set_simple_heart_template',
124
+ 'symbol' => WP_ULIKE_ASSETS_URL . '/img/svg/heart.svg'
125
  ),
126
  'wpulike-robeen' => array(
127
  'name' => __('Robeen', WP_ULIKE_SLUG),
128
+ 'callback' => 'wp_ulike_set_robeen_template',
129
+ 'symbol' => WP_ULIKE_ASSETS_URL . '/img/svg/twitter.svg'
130
  )
131
  );
132
 
137
  /**
138
  * Generate options info list
139
  *
140
+ * @author Alimir
141
  * @since 3.1
142
  * @return Array
143
  */
144
+ if( ! function_exists( 'wp_ulike_get_options_info' ) ){
145
  function wp_ulike_get_options_info( $type, $result = array() ) {
146
 
147
  switch ( $type ) {
148
+ case 'general':
149
  $result = array(
150
  'title' => '<i class="dashicons-before dashicons-admin-settings"></i>' . ' ' . __( 'General',WP_ULIKE_SLUG),
151
  'fields' => array(
160
  ),
161
  'text' => array(
162
  'name' => __('Text', WP_ULIKE_SLUG),
163
+ 'symbol' => WP_ULIKE_ASSETS_URL . '/img/svg/text.svg'
164
  )
165
  )
166
  ),
181
  'type' => 'media',
182
  'label' => __( 'Button Icon', WP_ULIKE_SLUG) . ' (' . __('Unlike', WP_ULIKE_SLUG) .')',
183
  'description' => __( 'Best size: 16x16',WP_ULIKE_SLUG)
184
+ ),
185
  'permission_text' => array(
186
  'default' => __('You have not permission to unlike',WP_ULIKE_SLUG),
187
  'label' => __( 'Permission Text', WP_ULIKE_SLUG)
214
  'buddypress' => __('BuddyPress Pages', WP_ULIKE_SLUG),
215
  'bbpress' => __('bbPress Pages', WP_ULIKE_SLUG),
216
  'woocommerce' => __('WooCommerce Pages', WP_ULIKE_SLUG)
217
+ ),
218
  'description' => __('Remove the plugin\'s css and js file on these pages.', WP_ULIKE_SLUG)
219
+ ),
220
  'format_number' => array(
221
  'type' => 'checkbox',
222
  'default' => 0,
231
  'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
232
  'description' => __('Custom toast messages after each activity', WP_ULIKE_SLUG)
233
  ),
234
+ 'anonymise' => array(
235
+ 'type' => 'checkbox',
236
+ 'default' => 1,
237
+ 'label' => __('Anonymize IP', WP_ULIKE_SLUG),
238
+ 'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
239
+ 'description' => __('Anonymize the IP address for GDPR Compliance', WP_ULIKE_SLUG)
240
+ ),
241
  'like_notice' => array(
242
  'default' => __('Thanks! You Liked This.',WP_ULIKE_SLUG),
243
  'label' => __( 'Liked Notice Message', WP_ULIKE_SLUG)
245
  'unlike_notice' => array(
246
  'default' => __('Sorry! You unliked this.',WP_ULIKE_SLUG),
247
  'label' => __( 'Unliked Notice Message', WP_ULIKE_SLUG)
248
+ )
249
  )
250
  );//end wp_ulike_general
251
  break;
252
 
253
+ case 'posts':
254
  $result = array(
255
  'title' => '<i class="dashicons-before dashicons-admin-post"></i>' . ' ' . __( 'Posts',WP_ULIKE_SLUG),
256
  'fields' => array(
259
  'default' => 'wpulike-default',
260
  'label' => __( 'Themes',WP_ULIKE_SLUG),
261
  'options' => call_user_func('wp_ulike_generate_templates_list')
262
+ ),
263
  'auto_display' => array(
264
  'type' => 'checkbox',
265
  'default' => 1,
275
  'bottom' => __('Bottom of Content', WP_ULIKE_SLUG),
276
  'top_bottom' => __('Top and Bottom', WP_ULIKE_SLUG)
277
  )
278
+ ),
279
  'auto_display_filter' => array(
280
  'type' => 'multi',
281
  'label' => __( 'Auto Display Filter',WP_ULIKE_SLUG ),
337
  ),
338
  'users_liked_box_template' => array(
339
  'type' => 'textarea',
340
+ 'default' => '<ul class="tiles">%START_WHILE%<li><a href="#" class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>',
341
  'label' => __('Users Like Box Template', WP_ULIKE_SLUG),
342
  'description' => __('Allowed Variables:', WP_ULIKE_SLUG) . ' <code>%USER_AVATAR%</code> , <code>%BP_PROFILE_URL%</code> , <code>%UM_PROFILE_URL%</code> , <code>%USER_NAME%</code> , <code>%START_WHILE%</code> , <code>%END_WHILE%</code>'
343
  ),
346
  'label' => __( 'Delete All Logs', WP_ULIKE_SLUG ),
347
  'description' => __( 'You Are About To Delete All Likes Logs. This Action Is Not Reversible.', WP_ULIKE_SLUG),
348
  'action' => 'wp_ulike_delete_all_logs'
349
+ ),
350
  'delete_data' => array(
351
  'type' => 'action',
352
  'label' => __( 'Delete All Data', WP_ULIKE_SLUG ),
354
  'action' => 'wp_ulike_delete_all_data'
355
  )
356
  )
357
+ );//end wp_ulike_posts
358
  break;
359
+
360
  case 'comments':
361
  $result = array(
362
  'title' => '<i class="dashicons-before dashicons-admin-comments"></i>' . ' ' . __( 'Comments',WP_ULIKE_SLUG),
366
  'default' => 'wpulike-heart',
367
  'label' => __( 'Themes',WP_ULIKE_SLUG),
368
  'options' => call_user_func('wp_ulike_generate_templates_list')
369
+ ),
370
  'auto_display' => array(
371
  'type' => 'checkbox',
372
  'default' => 1,
382
  'bottom' => __('Bottom of Content', WP_ULIKE_SLUG),
383
  'top_bottom' => __('Top and Bottom', WP_ULIKE_SLUG)
384
  )
385
+ ),
386
  'only_registered_users' => array(
387
  'type' => 'checkbox',
388
  'default' => 0,
400
  'by_ip' => __('Logged By IP', WP_ULIKE_SLUG),
401
  'by_username' => __('Logged By Username', WP_ULIKE_SLUG)
402
  )
403
+ ),
404
  'users_liked_box' => array(
405
  'type' => 'checkbox',
406
  'default' => 1,
413
  'default' => 32,
414
  'label' => __( 'Size of Gravatars', WP_ULIKE_SLUG),
415
  'description' => __('Size of Gravatars to return (max is 512)', WP_ULIKE_SLUG)
416
+ ),
417
  'number_of_users' => array(
418
  'type' => 'number',
419
  'default' => 10,
422
  ),
423
  'users_liked_box_template' => array(
424
  'type' => 'textarea',
425
+ 'default' => '<ul class="tiles">%START_WHILE%<li><a href="#" class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>',
426
  'label' => __('Users Like Box Template', WP_ULIKE_SLUG),
427
  'description' => __('Allowed Variables:', WP_ULIKE_SLUG) . ' <code>%USER_AVATAR%</code> , <code>%BP_PROFILE_URL%</code> , <code>%UM_PROFILE_URL%</code> , <code>%USER_NAME%</code> , <code>%START_WHILE%</code> , <code>%END_WHILE%</code>'
428
  ),
431
  'label' => __( 'Delete All Logs', WP_ULIKE_SLUG ),
432
  'description' => __( 'You Are About To Delete All Likes Logs. This Action Is Not Reversible.', WP_ULIKE_SLUG),
433
  'action' => 'wp_ulike_delete_all_logs'
434
+ ),
435
  'delete_data' => array(
436
  'type' => 'action',
437
  'label' => __( 'Delete All Data', WP_ULIKE_SLUG ),
438
  'description' => __( 'You Are About To Delete All Likes Data. This Action Is Not Reversible.', WP_ULIKE_SLUG),
439
  'action' => 'wp_ulike_delete_all_data'
440
+ )
441
  )
442
+ );//end wp_ulike_comments
443
  break;
444
+
445
+ case 'buddypress':
446
  $result = ! function_exists('is_buddypress') ? array() : array(
447
  'title' => '<i class="dashicons-before dashicons-buddypress"></i>' . ' ' . __( 'BuddyPress',WP_ULIKE_SLUG),
448
  'fields' => array(
473
  'label' => __('Activity Comment', WP_ULIKE_SLUG),
474
  'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
475
  'description' => __('Add the possibility to like Buddypress comments in the activity stream', WP_ULIKE_SLUG)
476
+ ),
477
  'only_registered_users' => array(
478
  'type' => 'checkbox',
479
  'default' => 0,
491
  'by_ip' => __('Logged By IP', WP_ULIKE_SLUG),
492
  'by_username' => __('Logged By Username', WP_ULIKE_SLUG)
493
  )
494
+ ),
495
  'users_liked_box' => array(
496
  'type' => 'checkbox',
497
  'default' => 1,
513
  ),
514
  'users_liked_box_template' => array(
515
  'type' => 'textarea',
516
+ 'default' => '<ul class="tiles">%START_WHILE%<li><a href="#" class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>',
517
  'label' => __('Users Like Box Template', WP_ULIKE_SLUG),
518
  'description' => __('Allowed Variables:', WP_ULIKE_SLUG) . ' <code>%USER_AVATAR%</code> , <code>%BP_PROFILE_URL%</code> , <code>%UM_PROFILE_URL%</code> , <code>%USER_NAME%</code> , <code>%START_WHILE%</code> , <code>%END_WHILE%</code>'
519
  ),
530
  'label' => __('BuddyPress Custom Notification', WP_ULIKE_SLUG),
531
  'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
532
  'description' => __('Sends out notifications when you get a like from someone', WP_ULIKE_SLUG)
533
+ ),
534
  'bp_post_activity_add_header' => array(
535
  'type' => 'textarea',
536
  'default' => '<strong>%POST_LIKER%</strong> liked <a href="%POST_PERMALINK%" title="%POST_TITLE%">%POST_TITLE%</a>. (So far, This post has <span class="badge">%POST_COUNT%</span> likes)',
548
  'label' => __( 'Delete All Logs', WP_ULIKE_SLUG ),
549
  'description' => __( 'You Are About To Delete All Likes Logs. This Action Is Not Reversible.', WP_ULIKE_SLUG),
550
  'action' => 'wp_ulike_delete_all_logs'
551
+ ),
552
  'delete_data' => array(
553
  'type' => 'action',
554
  'label' => __( 'Delete All Data', WP_ULIKE_SLUG ),
555
  'description' => __( 'You Are About To Delete All Likes Data. This Action Is Not Reversible.', WP_ULIKE_SLUG),
556
  'action' => 'wp_ulike_delete_all_data'
557
+ )
558
  )
559
+ );//end wp_ulike_buddypress
560
  break;
561
+
562
  case 'bbpress':
563
  $result = ! function_exists('is_bbpress') ? array() : array(
564
  'title' => '<i class="dashicons-before dashicons-bbpress"></i>' . ' ' . __( 'bbPress',WP_ULIKE_SLUG),
568
  'default' => 'wpulike-default',
569
  'label' => __( 'Themes',WP_ULIKE_SLUG),
570
  'options' => call_user_func('wp_ulike_generate_templates_list')
571
+ ),
572
  'auto_display' => array(
573
  'type' => 'checkbox',
574
  'default' => 1,
583
  'top' => __('Top of Content', WP_ULIKE_SLUG),
584
  'bottom' => __('Bottom of Content', WP_ULIKE_SLUG)
585
  )
586
+ ),
587
  'only_registered_users' => array(
588
  'type' => 'checkbox',
589
  'default' => 0,
623
  ),
624
  'users_liked_box_template' => array(
625
  'type' => 'textarea',
626
+ 'default' => '<ul class="tiles">%START_WHILE%<li><a href="#" class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li>%END_WHILE%</ul>',
627
  'label' => __('Users Like Box Template', WP_ULIKE_SLUG),
628
  'description' => __('Allowed Variables:', WP_ULIKE_SLUG) . ' <code>%USER_AVATAR%</code> , <code>%BP_PROFILE_URL%</code> , <code>%UM_PROFILE_URL%</code> , <code>%USER_NAME%</code> , <code>%START_WHILE%</code> , <code>%END_WHILE%</code>'
629
+ ),
630
  'delete_logs' => array(
631
  'type' => 'action',
632
  'label' => __( 'Delete All Logs', WP_ULIKE_SLUG ),
633
  'description' => __( 'You Are About To Delete All Likes Logs. This Action Is Not Reversible.', WP_ULIKE_SLUG),
634
  'action' => 'wp_ulike_delete_all_logs'
635
+ ),
636
  'delete_data' => array(
637
  'type' => 'action',
638
  'label' => __( 'Delete All Data', WP_ULIKE_SLUG ),
639
  'description' => __( 'You Are About To Delete All Likes Data. This Action Is Not Reversible.', WP_ULIKE_SLUG),
640
  'action' => 'wp_ulike_delete_all_data'
641
+ )
642
  )
643
+ );//end wp_ulike_buddypress
644
  break;
645
+
646
+ case 'customizer':
647
  $result = array(
648
  'title' => '<i class="dashicons-before dashicons-art"></i>' . ' ' . __( 'Customize',WP_ULIKE_SLUG),
649
  'fields' => array(
654
  'checkboxlabel' => __('Activate', WP_ULIKE_SLUG),
655
  'attributes' => array(
656
  'class' => 'wp_ulike_custom_style_activation'
657
+ ),
658
  'description' => __('Active this option to see the custom style settings.', WP_ULIKE_SLUG)
659
+ ),
660
  'btn_bg' => array(
661
  'type' => 'color',
662
  'label' => __('Button style', WP_ULIKE_SLUG),
678
  'counter_border' => array(
679
  'type' => 'color',
680
  'description' => __('Border Color', WP_ULIKE_SLUG)
681
+ ),
682
  'counter_color' => array(
683
  'type' => 'color',
684
  'description' => __('Text Color', WP_ULIKE_SLUG)
691
  'custom_css' => array(
692
  'type' => 'textarea',
693
  'label' => __('Custom CSS', WP_ULIKE_SLUG),
694
+ )
695
  )
696
+ );//end wp_ulike_customize
697
  break;
698
  }
699
 
709
  /**
710
  * Display Like button for posts
711
  *
712
+ * @author Alimir
713
  * @param String $type
714
  * @param Array $args
715
  * @since 1.0
716
  * @return String
717
  */
718
+ if( ! function_exists( 'wp_ulike' ) ){
719
  function wp_ulike( $type = 'get', $args = array() ) {
720
  //global variables
721
  global $post, $wp_ulike_class, $wp_user_IP;
722
+
723
  $post_ID = isset( $args['id'] ) ? $args['id'] : $post->ID;
724
  $get_post_meta = get_post_meta( $post_ID, '_liked', true );
725
  $get_like = empty( $get_post_meta ) ? 0 : $get_post_meta;
727
  $attributes = apply_filters( 'wp_ulike_posts_add_attr', null );
728
  $microdata = apply_filters( 'wp_ulike_posts_microdata', null );
729
  $style = wp_ulike_get_setting( 'wp_ulike_posts', 'theme' );
730
+
731
  //Main data
732
  $defaults = array(
733
  "id" => $post_ID, //Post ID
747
  "attributes" => $attributes, //Get Attributes Filter
748
  "wrapper_class" => '' //Extra Wrapper class
749
  );
750
+
751
+ $parsed_args = wp_parse_args( $args, $defaults );
752
+
753
  if( ( wp_ulike_get_setting( 'wp_ulike_posts', 'only_registered_users') != '1' ) or ( wp_ulike_get_setting( 'wp_ulike_posts', 'only_registered_users' ) == '1' && is_user_logged_in() ) ) {
 
 
 
754
 
755
  if ($type == 'put') {
756
+ return $wp_ulike_class->wp_get_ulike( $parsed_args );
757
  }
758
  else {
759
+ echo $wp_ulike_class->wp_get_ulike( $parsed_args );
760
  }
761
+
762
  }//end !only_registered_users condition
763
  elseif ( wp_ulike_get_setting( 'wp_ulike_posts', 'only_registered_users') == '1' && ! is_user_logged_in() ) {
764
  if(wp_ulike_get_setting( 'wp_ulike_general', 'login_type') == "button") {
765
+ return $wp_ulike_class->get_template( $parsed_args, 0 );
766
  } else {
767
  return apply_filters('wp_ulike_login_alert_template', '<p class="alert alert-info fade in" role="alert">'.__('You need to login in order to like this post: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>');
768
  }
779
  * @since 1.9
780
  * @return boolean
781
  */
782
+ if( ! function_exists( 'is_wp_ulike' ) ){
783
  function is_wp_ulike( $options, $args = array() ){
784
 
785
  $defaults = array(
813
  * Get Single Post likes number
814
  *
815
  * @author Alimir
816
+ * @param Integer $post_ID
817
+ * @since 1.7
818
  * @return String
819
  */
820
+ if( ! function_exists( 'wp_ulike_get_post_likes' ) ){
821
  function wp_ulike_get_post_likes($post_ID){
822
  $val = get_post_meta($post_ID, '_liked', true);
823
  return wp_ulike_format_number($val);
830
  * @author Alimir
831
  * @param Integer $post_ID
832
  * @param Boolean $is_decimal
833
+ * @since 2.7
834
  * @return String
835
  */
836
+ if( ! function_exists( 'wp_ulike_get_rating_value' ) ){
837
  function wp_ulike_get_rating_value($post_ID, $is_decimal = true){
838
  global $wpdb;
839
  if (false === ($rating_value = wp_cache_get($cache_key = 'get_rich_rating_value_' . $post_ID, $cache_group = 'wp_ulike'))) {
902
  /*******************************************************
903
  Comments
904
  *******************************************************/
905
+
906
  /**
907
  * wp_ulike_comments function for comments like/unlike display
908
  *
909
  * @author Alimir
910
  * @param String $type
911
+ * @param Array $args
912
  * @since 1.6
913
  * @return String
914
  */
915
+ if( ! function_exists( 'wp_ulike_comments' ) ){
916
  function wp_ulike_comments( $type = 'get', $args = array() ) {
917
  //global variables
918
  global $wp_ulike_class, $wp_user_IP;
919
+
920
  $comment_ID = isset( $args['id'] ) ? $args['id'] : get_comment_ID();
921
  $comment_meta = get_comment_meta( $comment_ID, '_commentliked', true );
922
  $get_like = empty( $comment_meta ) ? 0 : $comment_meta;
923
  $return_userID = $wp_ulike_class->get_reutrn_id();
924
  $attributes = apply_filters( 'wp_ulike_comments_add_attr', null );
925
  $microdata = apply_filters( 'wp_ulike_comments_microdata', null );
926
+ $style = wp_ulike_get_setting( 'wp_ulike_comments', 'theme' );
927
+
928
  //Main Data
929
  $defaults = array(
930
  "id" => $comment_ID, //Comment ID
944
  "attributes" => $attributes, //Get Attributes Filter
945
  "wrapper_class" => '' //Extra Wrapper class
946
  );
947
+
948
  $parsed_args = wp_parse_args( $args, $defaults );
949
+
950
+ if( ( wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users' ) != '1' ) or ( wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users' ) == '1' && is_user_logged_in() ) ) {
 
 
 
951
 
952
  if ($type == 'put') {
953
+ return $wp_ulike_class->wp_get_ulike( $parsed_args );
954
  }
955
  else {
956
+ echo $wp_ulike_class->wp_get_ulike( $parsed_args );
957
  }
958
+
959
  }//end !only_registered_users condition
960
  elseif (wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users') == '1' && ! is_user_logged_in()){
961
  if( wp_ulike_get_setting( 'wp_ulike_general', 'login_type' ) == "button" ){
962
+ return $wp_ulike_class->get_template( $parsed_args, 0 );
963
  } else {
964
  return apply_filters( 'wp_ulike_login_alert_template', '<p class="alert alert-info fade in" role="alert">'.__('You need to login in order to like this comment: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>' );
965
  }
975
  * @since 2.5
976
  * @return String
977
  */
978
+ if( ! function_exists( 'wp_ulike_get_comment_likes' ) ){
979
  function wp_ulike_get_comment_likes( $comment_ID ){
980
  $val = get_comment_meta($comment_ID, '_commentliked', true);
981
  return wp_ulike_format_number($val);
991
  *
992
  * @author Alimir
993
  * @param String $type
994
+ * @param Array $args
995
  * @since 1.7
996
  * @return String
997
  */
999
  function wp_ulike_buddypress( $type = 'get', $args = array() ) {
1000
  //global variables
1001
  global $wp_ulike_class, $wp_user_IP;
1002
+
1003
  if ( bp_get_activity_comment_id() != null ){
1004
  $activityID = isset( $args['id'] ) ? $args['id'] : bp_get_activity_comment_id();
1005
  } else {
1006
+ $activityID = isset( $args['id'] ) ? $args['id'] : bp_get_activity_id();
1007
  }
1008
+
1009
  $bp_get_meta = bp_activity_get_meta($activityID, '_activityliked');
1010
  $get_like = empty( $bp_get_meta ) ? 0 : $bp_get_meta;
1011
  $return_userID = $wp_ulike_class->get_reutrn_id();
1012
  $attributes = apply_filters( 'wp_ulike_activities_add_attr', null );
1013
  $microdata = apply_filters( 'wp_ulike_activities_microdata', null );
1014
  $style = wp_ulike_get_setting( 'wp_ulike_buddypress', 'theme' );
1015
+
1016
  //Main Data
1017
  $defaults = array(
1018
  "id" => $activityID, //Activity ID
1023
  "setting" => 'wp_ulike_buddypress', //Setting Key
1024
  "type" => 'post', //Function type (post/process)
1025
  "table" => 'ulike_activities', //Activities table
1026
+ "column" => 'activity_id', //ulike_activities table column name
1027
  "key" => '_activityliked', //meta key
1028
  "cookie" => 'activity-liked-', //Cookie Name
1029
  "slug" => 'activity', //Slug Name
1032
  "attributes" => $attributes, //Get Attributes Filter
1033
  "wrapper_class" => '' //Extra Wrapper class
1034
  );
1035
+
1036
  $parsed_args = wp_parse_args( $args, $defaults );
1037
+
1038
  if( ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'only_registered_users') != '1' ) or ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'only_registered_users' ) == '1' && is_user_logged_in() ) ) {
 
 
 
1039
 
1040
  if ($type == 'put') {
1041
+ return $wp_ulike_class->wp_get_ulike( $parsed_args );
1042
  }
1043
  else {
1044
+ echo $wp_ulike_class->wp_get_ulike( $parsed_args );
1045
  }
1046
+
1047
  }//end !only_registered_users condition
1048
  elseif ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'only_registered_users') == '1' && ! is_user_logged_in() ) {
1049
  if( wp_ulike_get_setting( 'wp_ulike_general', 'login_type') == "button" ){
1050
+ return $wp_ulike_class->get_template( $parsed_args, 0 );
1051
  }
1052
  else{
1053
  return apply_filters('wp_ulike_login_alert_template', '<p class="alert alert-info fade in" role="alert">'.__('You need to login in order to like this activity: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1054
  }
1055
+ }//end only_registered_users condition
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1056
 
1057
  }
1058
  }
1060
  /**
1061
  * Get auther ID by the ulike types
1062
  *
1063
+ * @author Alimir
1064
+ * @param Integer $cp_ID (Post/Comment/... ID)
1065
  * @param String $type (Get ulike Type)
1066
  * @since 2.5
1067
  * @return String
1070
  function wp_ulike_get_auhtor_id($cp_ID,$type) {
1071
  if($type == '_liked' || $type == '_topicliked'){
1072
  $post_tmp = get_post($cp_ID);
1073
+ return $post_tmp->post_author;
1074
  }
1075
  else if($type == '_commentliked'){
1076
  $comment = get_comment( $cp_ID );
1077
+ return $comment->user_id;
1078
  }
1079
  else if( $type == '_activityliked' ){
1080
  $activity = bp_activity_get_specific( array( 'activity_ids' => $cp_ID, 'display_comments' => true ) );
1081
+ return $activity['activities'][0]->user_id;
1082
  }
1083
  else return;
1084
  }
1087
  /**
1088
  * Wrapper for bbp_format_buddypress_notifications function as it is not returning $action
1089
  *
1090
+ * @author Alimir
1091
  * @since 2.5.1
1092
  * @return String
1093
  */
1098
  return;
1099
  }
1100
 
1101
+ $result = bbp_format_buddypress_notifications(
1102
+ $action,
1103
+ $item_id,
1104
+ $secondary_item_id,
1105
+ $total_items,
1106
  $format
1107
  );
1108
 
1122
  *
1123
  * @author Alimir
1124
  * @param String $type
1125
+ * @param Array $args
1126
  * @since 2.2
1127
  * @return String
1128
  */
1130
  function wp_ulike_bbpress( $type = 'get', $args = array() ) {
1131
  //global variables
1132
  global $post,$wp_ulike_class,$wp_user_IP;
1133
+
1134
  //Thanks to @Yehonal for this commit
1135
  $replyID = bbp_get_reply_id();
1136
  $post_ID = !$replyID ? $post->ID : $replyID;
1137
  $post_ID = isset( $args['id'] ) ? $args['id'] : $post_ID;
1138
+
1139
  $get_post_meta = get_post_meta( $post_ID, '_topicliked', true );
1140
  $get_like = empty( $get_post_meta ) ? 0 : $get_post_meta;
1141
+ $return_userID = $wp_ulike_class->get_reutrn_id();
1142
  $attributes = apply_filters( 'wp_ulike_topics_add_attr', null );
1143
  $microdata = apply_filters( 'wp_ulike_topics_microdata', null );
1144
+ $style = wp_ulike_get_setting( 'wp_ulike_bbpress', 'theme' );
1145
+
1146
  //Main Data
1147
  $defaults = array(
1148
  "id" => $post_ID, //Post ID
1162
  "attributes" => $attributes, //Get Attributes Filter
1163
  "wrapper_class" => '' //Extra Wrapper class
1164
  );
1165
+
1166
  $parsed_args = wp_parse_args( $args, $defaults );
1167
+
1168
  if( ( wp_ulike_get_setting( 'wp_ulike_bbpress', 'only_registered_users' ) != '1' ) or ( wp_ulike_get_setting( 'wp_ulike_bbpress', 'only_registered_users' ) == '1' && is_user_logged_in() ) ) {
 
 
 
1169
 
1170
  if ($type == 'put') {
1171
+ return $wp_ulike_class->wp_get_ulike( $parsed_args );
1172
  }
1173
  else {
1174
+ echo $wp_ulike_class->wp_get_ulike( $parsed_args );
1175
  }
1176
+
1177
  }//end !only_registered_users condition
1178
+
1179
  else if ( wp_ulike_get_setting( 'wp_ulike_bbpress', 'only_registered_users' ) == '1' && !is_user_logged_in()) {
1180
  if( wp_ulike_get_setting( 'wp_ulike_general', 'login_type') ){
1181
+ return $wp_ulike_class->get_template( $parsed_args, 0 );
1182
  }
1183
  else {
1184
  return apply_filters('wp_ulike_login_alert_template', '<p class="alert alert-info fade in" role="alert">'.__('You need to login in order to like this post: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>');
1185
  }
1186
  }//end only_registered_users condition
1187
+
1188
  }
1189
  }
1190
 
1191
  /*******************************************************
1192
  General
1193
  *******************************************************/
1194
+
1195
  /**
1196
  * Get custom style setting from customize options
1197
  *
1199
  * @since 1.3
1200
  * @return Void (Print new CSS styles)
1201
  */
1202
+ if( ! function_exists( 'wp_ulike_get_custom_style' ) ){
1203
  function wp_ulike_get_custom_style( $return_style = null ){
1204
+
1205
  // Like Icon
1206
  if( $get_like_icon = wp_get_attachment_url( wp_ulike_get_setting( 'wp_ulike_general', 'button_url' ) ) ) {
1207
  $return_style .= '.wp_ulike_btn.wp_ulike_put_image { background-image: url('.$get_like_icon.') !important; }';
1211
  if( $get_like_icon = wp_get_attachment_url( wp_ulike_get_setting( 'wp_ulike_general', 'button_url_u' ) ) ) {
1212
  $return_style .= '.wp_ulike_btn.wp_ulike_put_image.image-unlike { background-image: url('.$get_like_icon.') !important; }';
1213
  }
1214
+
1215
  if( wp_ulike_get_setting( 'wp_ulike_customize', 'custom_style' ) ) {
1216
+
1217
  //get custom options
1218
  $customstyle = get_option( 'wp_ulike_customize' );
1219
  $btn_style = '';
1223
  // Button Style
1224
  if( isset( $customstyle['btn_bg'] ) && ! empty( $customstyle['btn_bg'] ) ) {
1225
  $btn_style .= "background-color:".$customstyle['btn_bg'].";";
1226
+ }
1227
  if( isset( $customstyle['btn_border'] ) && ! empty( $customstyle['btn_border'] ) ) {
1228
  $btn_style .= "border-color:".$customstyle['btn_border']."; ";
1229
+ }
1230
  if( isset( $customstyle['btn_color'] ) && ! empty( $customstyle['btn_color'] ) ) {
1231
  $btn_style .= "color:".$customstyle['btn_color'].";text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.3);";
1232
  }
1233
 
1234
  if( $btn_style != '' ){
1235
  $return_style .= '.wpulike-default .wp_ulike_btn, .wpulike-default .wp_ulike_btn:hover, #bbpress-forums .wpulike-default .wp_ulike_btn, #bbpress-forums .wpulike-default .wp_ulike_btn:hover{'.$btn_style.'}.wpulike-heart .wp_ulike_general_class{'.$btn_style.'}';
1236
+ }
1237
 
1238
  // Counter Style
1239
  if( isset( $customstyle['counter_bg'] ) && ! empty( $customstyle['counter_bg'] ) ) {
1240
  $counter_style .= "background-color:".$customstyle['counter_bg'].";";
1241
+ }
1242
  if( isset( $customstyle['counter_border'] ) && ! empty( $customstyle['counter_border'] ) ) {
1243
  $counter_style .= "border-color:".$customstyle['counter_border']."; ";
1244
  $before_style = "border-color:transparent; border-bottom-color:".$customstyle['counter_border']."; border-left-color:".$customstyle['counter_border'].";";
1245
+ }
1246
  if( isset( $customstyle['counter_color'] ) && ! empty( $customstyle['counter_color'] ) ) {
1247
  $counter_style .= "color:".$customstyle['counter_color'].";";
1248
  }
1249
 
1250
  if( $counter_style != '' ){
1251
  $return_style .= '.wpulike-default .count-box,.wpulike-default .count-box:before{'.$counter_style.'}.wpulike-default .count-box:before{'.$before_style.'}';
1252
+ }
1253
 
1254
  // Loading Spinner
1255
  if( isset( $customstyle['loading_animation'] ) && ! empty( $customstyle['loading_animation'] ) ) {
1260
  if( isset( $customstyle['custom_css'] ) && ! empty( $customstyle['custom_css'] ) ) {
1261
  $return_style .= $customstyle['custom_css'];
1262
  }
1263
+
1264
  }
1265
 
1266
  return $return_style;
1267
  }
1268
 
1269
  }
1270
+
1271
  /**
1272
  * Convert numbers of Likes with string (kilobyte) format
1273
  *
1274
  * @author Alimir
1275
+ * @param Integer $num (get like number)
1276
  * @since 1.5
1277
  * @return String
1278
  */
1279
+ if( ! function_exists( 'wp_ulike_format_number' ) ){
1280
  function wp_ulike_format_number($num){
1281
  $plus = $num != 0 ? '+' : '';
1282
  if ($num >= 1000 && wp_ulike_get_setting( 'wp_ulike_general', 'format_number' ) == '1')
1287
  return $value;
1288
  }
1289
  }
1290
+
1291
+
1292
  /**
1293
  * Date in localized format
1294
  *
1297
  * @since 2.3
1298
  * @return String
1299
  */
1300
+ if( ! function_exists( 'wp_ulike_date_i18n' ) ){
1301
  function wp_ulike_date_i18n($date){
1302
+ return date_i18n(
1303
+ get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ),
1304
  strtotime($date)
1305
+ );
1306
  }
1307
  }
1308
+
1309
 
1310
  /*******************************************************
1311
  Templates
1314
  /**
1315
  * Create simple default template
1316
  *
1317
+ * @author Alimir
1318
  * @since 2.8
1319
  * @return Void
1320
  */
1321
+ if( ! function_exists( 'wp_ulike_set_default_template' ) ){
1322
  function wp_ulike_set_default_template( array $wp_ulike_template ){
1323
  //This function will turn output buffering on
1324
  ob_start();
1338
  </a>
1339
  <?php echo $counter; ?>
1340
  </div>
1341
+ <?php
1342
+ echo $microdata;
1343
+ echo $display_likers;
1344
+ do_action( 'wp_ulike_inside_template' );
1345
+ ?>
1346
  </div>
1347
  <?php
1348
  do_action( 'wp_ulike_after_template' );
1353
  /**
1354
  * Create simple heart template
1355
  *
1356
+ * @author Alimir
1357
  * @since 2.8
1358
  * @return Void
1359
  */
1360
+ if( ! function_exists( 'wp_ulike_set_simple_heart_template' ) ){
1361
  function wp_ulike_set_simple_heart_template( array $wp_ulike_template ){
1362
  //This function will turn output buffering on
1363
  ob_start();
1364
  do_action( 'wp_ulike_before_template' );
1365
  // Extract input array
1366
+ extract( $wp_ulike_template );
1367
  ?>
1368
  <div id="wp-ulike-<?php echo $slug . '-' . $ID; ?>" class="wpulike wpulike-heart <?php echo $wrapper_class; ?>" <?php echo $attributes; ?>>
1369
  <div class="<?php echo $general_class; ?>">
1377
  </a>
1378
  <?php echo $counter; ?>
1379
  </div>
1380
+ <?php
1381
+ echo $microdata;
1382
+ echo $display_likers;
1383
+ do_action( 'wp_ulike_inside_template' );
1384
+ ?>
1385
  </div>
1386
  <?php
1387
  do_action( 'wp_ulike_after_template' );
1392
  /**
1393
  * Create Robeen (Animated Heart) template
1394
  *
1395
+ * @author Alimir
1396
  * @since 2.8
1397
  * @return Void
1398
  */
1399
+ if( ! function_exists( 'wp_ulike_set_robeen_template' ) ){
1400
  function wp_ulike_set_robeen_template( array $wp_ulike_template ){
1401
  //This function will turn output buffering on
1402
  ob_start();
1403
+ do_action( 'wp_ulike_before_template' );
1404
  // Extract input array
1405
+ extract( $wp_ulike_template );
1406
  ?>
1407
  <div id="wp-ulike-<?php echo $slug . '-' . $ID; ?>" class="wpulike wpulike-robeen <?php echo $wrapper_class; ?>" <?php echo $attributes; ?>>
1408
  <div class="<?php echo $general_class; ?>">
1413
  <?php echo $counter; ?>
1414
  </label>
1415
  </div>
1416
+ <?php
1417
+ echo $microdata;
1418
+ echo $display_likers;
1419
+ do_action( 'wp_ulike_inside_template' );
1420
+ ?>
1421
  </div>
1422
  <?php
1423
  do_action( 'wp_ulike_after_template' );
inc/general-hooks.php CHANGED
@@ -15,7 +15,7 @@
15
  * Register WP ULike Widgets
16
  *
17
  * @author Alimir
18
- * @since 1.2
19
  * @return Void
20
  */
21
  if( ! function_exists( 'wp_ulike_register_widget' ) ){
@@ -50,15 +50,15 @@ if( ! function_exists( 'wp_ulike_shortcode' ) ){
50
  case 'comment':
51
  $result = $content . wp_ulike_comments( 'put', array_filter( $args ) );
52
  break;
53
-
54
  case 'activity':
55
  $result = $content . wp_ulike_buddypress( 'put', array_filter( $args ) );
56
  break;
57
-
58
  case 'topic':
59
  $result = $content . wp_ulike_bbpress( 'put', array_filter( $args ) );
60
  break;
61
-
62
  default:
63
  $result = $content . wp_ulike( 'put', array_filter( $args ) );
64
  }
@@ -75,22 +75,22 @@ if( ! function_exists( 'wp_ulike_shortcode' ) ){
75
  /**
76
  * Auto insert wp_ulike function in the posts/pages content
77
  *
78
- * @author Alimir
79
- * @param String $content
80
- * @since 1.0
81
  * @return filter on "the_content"
82
  */
83
- if( ! function_exists( 'wp_ulike_put_posts' ) ){
84
  function wp_ulike_put_posts($content) {
85
  //auto display position
86
  $position = wp_ulike_get_setting( 'wp_ulike_posts', 'auto_display_position');
87
  $button = '';
88
-
89
  //add wp_ulike function
90
  if( !is_feed() && is_wp_ulike( wp_ulike_get_setting( 'wp_ulike_posts', 'auto_display_filter') ) ){
91
  $button = wp_ulike('put');
92
  }
93
-
94
  //return by position
95
  if($position=='bottom')
96
  return $content . $button;
@@ -111,10 +111,10 @@ if( ! function_exists( 'wp_ulike_put_posts' ) ){
111
  * Add itemtype to wp_ulike_posts_add_attr filter
112
  *
113
  * @author Alimir
114
- * @since 2.7
115
  * @return String
116
  */
117
- if( ! function_exists( 'wp_ulike_get_posts_microdata_itemtype' ) ){
118
  function wp_ulike_get_posts_microdata_itemtype(){
119
  $get_ulike_count = get_post_meta(get_the_ID(), '_liked', true);
120
  if(!is_singular() || !wp_ulike_get_setting( 'wp_ulike_posts', 'google_rich_snippets') || $get_ulike_count == 0) return;
@@ -122,15 +122,15 @@ if( ! function_exists( 'wp_ulike_get_posts_microdata_itemtype' ) ){
122
  }
123
  add_filter('wp_ulike_posts_add_attr', 'wp_ulike_get_posts_microdata_itemtype');
124
  }
125
-
126
  /**
127
  * Add rich snippet for ratings in form of schema.org
128
  *
129
  * @author Alimir
130
- * @since 2.7
131
  * @return String
132
  */
133
- if( ! function_exists( 'wp_ulike_get_posts_microdata' ) ){
134
  function wp_ulike_get_posts_microdata(){
135
  $get_ulike_count = get_post_meta(get_the_ID(), '_liked', true);
136
  if(!is_singular() || !wp_ulike_get_setting( 'wp_ulike_posts', 'google_rich_snippets') || $get_ulike_count == 0) return;
@@ -158,18 +158,18 @@ if( ! function_exists( 'wp_ulike_get_posts_microdata' ) ){
158
  * Auto insert wp_ulike_comments in the comments content
159
  *
160
  * @author Alimir
161
- * @param String $content
162
- * @since 1.6
163
  * @return filter on "comment_text"
164
- */
165
- if( ! function_exists( 'wp_ulike_put_comments' ) ){
166
  function wp_ulike_put_comments($content) {
167
  //auto display position
168
  $position = wp_ulike_get_setting( 'wp_ulike_comments', 'auto_display_position');
169
-
170
  //add wp_ulike_comments function
171
  $button = wp_ulike_comments('put');
172
-
173
  //return by position
174
  if($position=='bottom')
175
  return $content . $button;
@@ -180,7 +180,7 @@ if( ! function_exists( 'wp_ulike_put_comments' ) ){
180
  else
181
  return $content . $button;
182
  }
183
-
184
  if ( wp_ulike_get_setting( 'wp_ulike_comments', 'auto_display' ) == '1' && ! is_admin() ) {
185
  add_filter('comment_text', 'wp_ulike_put_comments');
186
  }
@@ -196,12 +196,12 @@ if( defined( 'BP_VERSION' ) ) {
196
  /**
197
  * Auto insert wp_ulike_buddypress in the comments content
198
  *
199
- * @author Alimir
200
- * @param String $content
201
- * @since 1.7
202
  * @return filter on "bp_get_activity_action"
203
  */
204
- if( ! function_exists( 'wp_ulike_put_buddypress' ) ){
205
  function wp_ulike_put_buddypress() {
206
  wp_ulike_buddypress('get');
207
  }
@@ -215,19 +215,19 @@ if( defined( 'BP_VERSION' ) ) {
215
  }
216
  // Add wp ulike in buddpress comments
217
  if ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'activity_comment' ) == '1' ) {
218
- add_action( 'bp_activity_comment_options', 'wp_ulike_put_buddypress' );
219
  }
220
  }
221
  }
222
-
223
  /**
224
  * Register "WP ULike Activity" action
225
  *
226
  * @author Alimir
227
- * @since 1.7
228
  * @return Add action on "bp_register_activity_actions"
229
  */
230
- if( ! function_exists( 'wp_ulike_register_activity_actions' ) ){
231
  function wp_ulike_register_activity_actions() {
232
  global $bp;
233
  bp_activity_set_action(
@@ -236,34 +236,34 @@ if( defined( 'BP_VERSION' ) ) {
236
  __( 'WP ULike Activity', WP_ULIKE_SLUG )
237
  );
238
  }
239
- add_action( 'bp_register_activity_actions', 'wp_ulike_register_activity_actions' );
240
  }
241
 
242
  /**
243
  * Display likes option in BuddyPress activity filter
244
  *
245
- * @author Alimir
246
  * @since 2.5.1
247
  * @return Void
248
  */
249
- if( ! function_exists( 'wp_ulike_bp_activity_filter_options' ) ){
250
  function wp_ulike_bp_activity_filter_options() {
251
  echo "<option value='wp_like_group'>". __('Likes') ."</option>";
252
  }
253
  add_action( 'bp_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Activity Directory
254
  add_action( 'bp_member_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Member's profile activity
255
- add_action( 'bp_group_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Group's activity
256
  }
257
 
258
  /**
259
- * Register 'wp_ulike' to BuddyPress component.
260
  *
261
- * @author Alimir
262
- * @param Array $component_names
263
  * @since 2.5
264
  * @return String
265
  */
266
- if( ! function_exists( 'wp_ulike_filter_notifications_get_registered_components' ) ){
267
  function wp_ulike_filter_notifications_get_registered_components( $component_names = array() ) {
268
  // Force $component_names to be an array
269
  if ( ! is_array( $component_names ) ) {
@@ -277,64 +277,175 @@ if( defined( 'BP_VERSION' ) ) {
277
  add_filter( 'bp_notifications_get_registered_components', 'wp_ulike_filter_notifications_get_registered_components', 10 );
278
  }
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
  /**
282
  * Add custom format for 'wp_ulike' notifications.
283
  *
284
- * @author Alimir
285
  * @since 2.5
286
  * @return String
287
  */
288
- if( ! function_exists( 'wp_ulike_format_buddypress_notifications' ) ){
289
  function wp_ulike_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
290
- global $wp_filter,$wp_version;
291
- if (strpos($action, 'wp_ulike_') !== false) {
292
- $custom_link = '';
293
- //Extracting ulike type from the action value.
294
- preg_match('/wp_ulike_(.*?)_action/', $action, $type);
295
- //Extracting user id from the action value.
296
- preg_match('/action_([0-9]+)/', $action, $user_ID);
297
- $user_info = get_userdata($user_ID[1]);
298
- $custom_text = __('You have a new like from', WP_ULIKE_SLUG ) . ' "' . $user_info->display_name . '"';
299
- //checking the ulike types
300
- if($type[1] == 'liked'){
301
- $custom_link = get_permalink($item_id);
302
- }
303
- else if($type[1] == 'topicliked'){
304
- $custom_link = get_permalink($item_id);
305
- }
306
- else if($type[1] == 'commentliked'){
307
- $custom_link = get_comment_link( $item_id );
308
- }
309
- else if($type[1] == 'activityliked'){
310
- $custom_link = bp_activity_get_permalink( $item_id );
311
- }
312
- // WordPress Toolbar
313
- if ( 'string' === $format ) {
314
- $return = apply_filters( 'wp_ulike_bp_notifications_template', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_text ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link );
315
- // Deprecated BuddyBar
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  } else {
317
- $return = apply_filters( 'wp_ulike_bp_notifications_template', array(
318
- 'text' => $custom_text,
319
- 'link' => $custom_link
320
- ), $custom_link, (int) $total_items, $custom_text, $custom_text );
321
- }
322
- // global wp_filter to call bbPress wrapper function
323
- if (isset($wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications'])) {
324
- if (version_compare($wp_version, '4.7', '>=' )) {
325
- // https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
326
- $wp_filter['bp_notifications_get_notifications_for_user']->callbacks[10]['bbp_format_buddypress_notifications']['function'] = 'wp_ulike_bbp_format_buddypress_notifications';
327
- } else {
328
- $wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications']['function'] = 'wp_ulike_bbp_format_buddypress_notifications';
329
- }
330
  }
331
- return $return;
332
  }
333
- return $action;
 
334
  }
335
  add_filter( 'bp_notifications_get_notifications_for_user', 'wp_ulike_format_buddypress_notifications', 5, 5 );
336
  }
337
-
338
  }
339
 
340
  /*******************************************************
@@ -344,18 +455,18 @@ if( defined( 'BP_VERSION' ) ) {
344
  /**
345
  * Auto insert wp_ulike_bbpress in the topcis content
346
  *
347
- * @author Alimir
348
- * @param String $content
349
- * @since 2.2
350
  * @return filter on bbpPress hooks
351
  */
352
  if( ! function_exists( 'wp_ulike_put_bbpress' ) && function_exists( 'is_bbpress' ) ){
353
  function wp_ulike_put_bbpress() {
354
  wp_ulike_bbpress('get');
355
  }
356
- if (wp_ulike_get_setting( 'wp_ulike_bbpress', 'auto_display' ) == '1') {
357
  if (wp_ulike_get_setting( 'wp_ulike_bbpress', 'auto_display_position' ) == 'top') {
358
- add_action( 'bbp_theme_before_reply_content', 'wp_ulike_put_bbpress' );
359
  } else {
360
  add_action( 'bbp_theme_after_reply_content', 'wp_ulike_put_bbpress' );
361
  }
@@ -372,7 +483,7 @@ if( ! function_exists( 'wp_ulike_put_bbpress' ) && function_exists( 'is_bbpress'
372
  * @author Gabriel Lemarie & Alimir
373
  * @since 2.3
374
  */
375
- if( defined( 'myCRED_VERSION' ) ){
376
  if( ! function_exists( 'wp_ulike_register_myCRED_hook' ) ){
377
  function wp_ulike_register_myCRED_hook( $installed ) {
378
  $installed['wp_ulike'] = array(
@@ -412,17 +523,17 @@ if ( defined( 'ultimatemember_version' ) ) {
412
  */
413
  if( ! function_exists( 'wp_ulike_add_custom_profile_tab' ) ){
414
  function wp_ulike_add_custom_profile_tab( $tabs ) {
415
-
416
  $tabs['wp-ulike-posts'] = array(
417
  'name' => __('Recent Posts Liked',WP_ULIKE_SLUG),
418
  'icon' => 'um-faicon-thumbs-up',
419
  );
420
-
421
  $tabs['wp-ulike-comments'] = array(
422
  'name' => __('Recent Comments Liked',WP_ULIKE_SLUG),
423
  'icon' => 'um-faicon-thumbs-o-up',
424
  );
425
-
426
  return $tabs;
427
  }
428
  add_filter('um_profile_tabs', 'wp_ulike_add_custom_profile_tab', 1000 );
@@ -438,22 +549,22 @@ if ( defined( 'ultimatemember_version' ) ) {
438
  if( ! function_exists( 'wp_ulike_posts_um_profile_content' ) ){
439
  function wp_ulike_posts_um_profile_content( $args ) {
440
  global $wp_ulike_class,$ultimatemember;
441
-
442
  $args = array(
443
  "user_id" => um_profile_id(), //User ID
444
  "col" => 'post_id', //Table Column (post_id,comment_id,activity_id,topic_id)
445
  "table" => 'ulike', //Table Name
446
  "limit" => 10, //limit Number
447
- );
448
-
449
  $user_logs = $wp_ulike_class->get_current_user_likes($args);
450
-
451
  if($user_logs != null){
452
  echo '<div class="um-profile-note"><span>'. __('Recent Posts Liked',WP_ULIKE_SLUG).'</span></div>';
453
  foreach ($user_logs as $user_log) {
454
  $get_post = get_post(stripslashes($user_log->post_id));
455
  $get_date = $user_log->date_time;
456
-
457
  echo '<div class="um-item">';
458
  echo '<div class="um-item-link">
459
  <i class="um-icon-ios-paper"></i>
@@ -466,7 +577,7 @@ if ( defined( 'ultimatemember_version' ) ) {
466
  echo '</div>';
467
  }
468
  } else echo '<div style="display: block;" class="um-profile-note"><i class="um-faicon-frown-o"></i><span>'. __('This user has not made any likes.',WP_ULIKE_SLUG).'</span></div>';
469
- }
470
  add_action('um_profile_content_wp-ulike-posts_default', 'wp_ulike_posts_um_profile_content');
471
  }
472
 
@@ -476,26 +587,26 @@ if ( defined( 'ultimatemember_version' ) ) {
476
  * @author Alimir
477
  * @since 2.3
478
  * @return Void
479
- */
480
  if( ! function_exists( 'wp_ulike_comments_um_profile_content' ) ){
481
  function wp_ulike_comments_um_profile_content( $args ) {
482
  global $wp_ulike_class,$ultimatemember;
483
-
484
  $args = array(
485
  "user_id" => um_profile_id(), //User ID
486
  "col" => 'comment_id', //Table Column (post_id,comment_id,activity_id,topic_id)
487
  "table" => 'ulike_comments', //Table Name
488
  "limit" => 10, //limit Number
489
- );
490
-
491
  $user_logs = $wp_ulike_class->get_current_user_likes($args);
492
-
493
  if($user_logs != null){
494
  echo '<div class="um-profile-note"><span>'. __('Recent Comments Liked',WP_ULIKE_SLUG).'</span></div>';
495
  foreach ($user_logs as $user_log) {
496
  $comment = get_comment(stripslashes($user_log->comment_id));
497
  $get_date = $user_log->date_time;
498
-
499
  echo '<div class="um-item">';
500
  echo '<div class="um-item-link">
501
  <i class="um-icon-ios-chatboxes"></i>
@@ -512,4 +623,4 @@ if ( defined( 'ultimatemember_version' ) ) {
512
  }
513
  add_action('um_profile_content_wp-ulike-comments_default', 'wp_ulike_comments_um_profile_content');
514
  }
515
- }
15
  * Register WP ULike Widgets
16
  *
17
  * @author Alimir
18
+ * @since 1.2
19
  * @return Void
20
  */
21
  if( ! function_exists( 'wp_ulike_register_widget' ) ){
50
  case 'comment':
51
  $result = $content . wp_ulike_comments( 'put', array_filter( $args ) );
52
  break;
53
+
54
  case 'activity':
55
  $result = $content . wp_ulike_buddypress( 'put', array_filter( $args ) );
56
  break;
57
+
58
  case 'topic':
59
  $result = $content . wp_ulike_bbpress( 'put', array_filter( $args ) );
60
  break;
61
+
62
  default:
63
  $result = $content . wp_ulike( 'put', array_filter( $args ) );
64
  }
75
  /**
76
  * Auto insert wp_ulike function in the posts/pages content
77
  *
78
+ * @author Alimir
79
+ * @param String $content
80
+ * @since 1.0
81
  * @return filter on "the_content"
82
  */
83
+ if( ! function_exists( 'wp_ulike_put_posts' ) ){
84
  function wp_ulike_put_posts($content) {
85
  //auto display position
86
  $position = wp_ulike_get_setting( 'wp_ulike_posts', 'auto_display_position');
87
  $button = '';
88
+
89
  //add wp_ulike function
90
  if( !is_feed() && is_wp_ulike( wp_ulike_get_setting( 'wp_ulike_posts', 'auto_display_filter') ) ){
91
  $button = wp_ulike('put');
92
  }
93
+
94
  //return by position
95
  if($position=='bottom')
96
  return $content . $button;
111
  * Add itemtype to wp_ulike_posts_add_attr filter
112
  *
113
  * @author Alimir
114
+ * @since 2.7
115
  * @return String
116
  */
117
+ if( ! function_exists( 'wp_ulike_get_posts_microdata_itemtype' ) ){
118
  function wp_ulike_get_posts_microdata_itemtype(){
119
  $get_ulike_count = get_post_meta(get_the_ID(), '_liked', true);
120
  if(!is_singular() || !wp_ulike_get_setting( 'wp_ulike_posts', 'google_rich_snippets') || $get_ulike_count == 0) return;
122
  }
123
  add_filter('wp_ulike_posts_add_attr', 'wp_ulike_get_posts_microdata_itemtype');
124
  }
125
+
126
  /**
127
  * Add rich snippet for ratings in form of schema.org
128
  *
129
  * @author Alimir
130
+ * @since 2.7
131
  * @return String
132
  */
133
+ if( ! function_exists( 'wp_ulike_get_posts_microdata' ) ){
134
  function wp_ulike_get_posts_microdata(){
135
  $get_ulike_count = get_post_meta(get_the_ID(), '_liked', true);
136
  if(!is_singular() || !wp_ulike_get_setting( 'wp_ulike_posts', 'google_rich_snippets') || $get_ulike_count == 0) return;
158
  * Auto insert wp_ulike_comments in the comments content
159
  *
160
  * @author Alimir
161
+ * @param String $content
162
+ * @since 1.6
163
  * @return filter on "comment_text"
164
+ */
165
+ if( ! function_exists( 'wp_ulike_put_comments' ) ){
166
  function wp_ulike_put_comments($content) {
167
  //auto display position
168
  $position = wp_ulike_get_setting( 'wp_ulike_comments', 'auto_display_position');
169
+
170
  //add wp_ulike_comments function
171
  $button = wp_ulike_comments('put');
172
+
173
  //return by position
174
  if($position=='bottom')
175
  return $content . $button;
180
  else
181
  return $content . $button;
182
  }
183
+
184
  if ( wp_ulike_get_setting( 'wp_ulike_comments', 'auto_display' ) == '1' && ! is_admin() ) {
185
  add_filter('comment_text', 'wp_ulike_put_comments');
186
  }
196
  /**
197
  * Auto insert wp_ulike_buddypress in the comments content
198
  *
199
+ * @author Alimir
200
+ * @param String $content
201
+ * @since 1.7
202
  * @return filter on "bp_get_activity_action"
203
  */
204
+ if( ! function_exists( 'wp_ulike_put_buddypress' ) ){
205
  function wp_ulike_put_buddypress() {
206
  wp_ulike_buddypress('get');
207
  }
215
  }
216
  // Add wp ulike in buddpress comments
217
  if ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'activity_comment' ) == '1' ) {
218
+ add_action( 'bp_activity_comment_options', 'wp_ulike_put_buddypress' );
219
  }
220
  }
221
  }
222
+
223
  /**
224
  * Register "WP ULike Activity" action
225
  *
226
  * @author Alimir
227
+ * @since 1.7
228
  * @return Add action on "bp_register_activity_actions"
229
  */
230
+ if( ! function_exists( 'wp_ulike_register_activity_actions' ) ){
231
  function wp_ulike_register_activity_actions() {
232
  global $bp;
233
  bp_activity_set_action(
236
  __( 'WP ULike Activity', WP_ULIKE_SLUG )
237
  );
238
  }
239
+ add_action( 'bp_register_activity_actions', 'wp_ulike_register_activity_actions' );
240
  }
241
 
242
  /**
243
  * Display likes option in BuddyPress activity filter
244
  *
245
+ * @author Alimir
246
  * @since 2.5.1
247
  * @return Void
248
  */
249
+ if( ! function_exists( 'wp_ulike_bp_activity_filter_options' ) ){
250
  function wp_ulike_bp_activity_filter_options() {
251
  echo "<option value='wp_like_group'>". __('Likes') ."</option>";
252
  }
253
  add_action( 'bp_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Activity Directory
254
  add_action( 'bp_member_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Member's profile activity
255
+ add_action( 'bp_group_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Group's activity
256
  }
257
 
258
  /**
259
+ * Register 'wp_ulike' to BuddyPress component.
260
  *
261
+ * @author Alimir
262
+ * @param Array $component_names
263
  * @since 2.5
264
  * @return String
265
  */
266
+ if( ! function_exists( 'wp_ulike_filter_notifications_get_registered_components' ) ){
267
  function wp_ulike_filter_notifications_get_registered_components( $component_names = array() ) {
268
  // Force $component_names to be an array
269
  if ( ! is_array( $component_names ) ) {
277
  add_filter( 'bp_notifications_get_registered_components', 'wp_ulike_filter_notifications_get_registered_components', 10 );
278
  }
279
 
280
+ /**
281
+ * Add new buddypress activities on each like.
282
+ *
283
+ * @author Alimir
284
+ * @param Integer $user_ID (User ID)
285
+ * @param Integer $cp_ID (Post/Comment ID)
286
+ * @param String $type (Simple Key for separate posts by comments)
287
+ * @since 1.6
288
+ * @return Void
289
+ */
290
+ if( ! function_exists( 'wp_ulike_add_bp_notifications' ) ){
291
+ function wp_ulike_add_bp_notifications( $cp_ID, $type, $user_ID, $status, $has_log ){
292
+
293
+ // Return if user not logged in or an older data log exist
294
+ if( ! is_user_logged_in() || $has_log || ! function_exists( 'bp_is_active' ) ) return;
295
+
296
+ //Create a new activity when an user likes something
297
+ if ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'new_likes_activity' ) == '1' ) {
298
+
299
+ switch ( $type ) {
300
+ case '_liked':
301
+ // Replace the post variables
302
+ $post_template = wp_ulike_get_setting( 'wp_ulike_buddypress', 'bp_post_activity_add_header', '<strong>%POST_LIKER%</strong> liked <a href="%POST_PERMALINK%" title="%POST_TITLE%">%POST_TITLE%</a>. (So far, This post has <span class="badge">%POST_COUNT%</span> likes)' );
303
+
304
+ if ( strpos( $post_template, '%POST_LIKER%' ) !== false ) {
305
+ $POST_LIKER = bp_core_get_userlink( $user_ID );
306
+ $post_template = str_replace( "%POST_LIKER%", $POST_LIKER, $post_template );
307
+ }
308
+ if ( strpos( $post_template, '%POST_PERMALINK%' ) !== false ) {
309
+ $POST_PERMALINK = get_permalink($cp_ID);
310
+ $post_template = str_replace( "%POST_PERMALINK%", $POST_PERMALINK, $post_template );
311
+ }
312
+ if ( strpos( $post_template, '%POST_COUNT%' ) !== false ) {
313
+ $POST_COUNT = get_post_meta( $cp_ID, '_liked', true );
314
+ $post_template = str_replace( "%POST_COUNT%", $POST_COUNT, $post_template );
315
+ }
316
+ if ( strpos( $post_template, '%POST_TITLE%' ) !== false ) {
317
+ $POST_TITLE = get_the_title( $cp_ID );
318
+ $post_template = str_replace( "%POST_TITLE%", $POST_TITLE, $post_template );
319
+ }
320
+ bp_activity_add( array(
321
+ 'user_id' => $user_ID,
322
+ 'action' => $post_template,
323
+ 'component' => 'activity',
324
+ 'type' => 'wp_like_group',
325
+ 'item_id' => $cp_ID
326
+ ));
327
+ break;
328
+
329
+ case '_commentliked':
330
+ // Replace the comment variables
331
+ $comment_template = wp_ulike_get_setting( 'wp_ulike_buddypress', 'bp_comment_activity_add_header', '<strong>%COMMENT_LIKER%</strong> liked <strong>%COMMENT_AUTHOR%</strong> comment. (So far, %COMMENT_AUTHOR% has <span class="badge">%COMMENT_COUNT%</span> likes for this comment)' );
332
+
333
+ if ( strpos( $comment_template, '%COMMENT_LIKER%' ) !== false ) {
334
+ $COMMENT_LIKER = bp_core_get_userlink( $user_ID );
335
+ $comment_template = str_replace("%COMMENT_LIKER%", $COMMENT_LIKER, $comment_template );
336
+ }
337
+ if ( strpos( $comment_template, '%COMMENT_PERMALINK%' ) !== false ) {
338
+ $COMMENT_PERMALINK = get_comment_link( $cp_ID );
339
+ $comment_template = str_replace( "%COMMENT_PERMALINK%", $COMMENT_PERMALINK, $comment_template );
340
+ }
341
+ if ( strpos( $comment_template, '%COMMENT_AUTHOR%' ) !== false ) {
342
+ $COMMENT_AUTHOR = get_comment_author( $cp_ID );
343
+ $comment_template = str_replace( "%COMMENT_AUTHOR%", $COMMENT_AUTHOR, $comment_template );
344
+ }
345
+ if ( strpos( $comment_template, '%COMMENT_COUNT%' ) !== false ) {
346
+ $COMMENT_COUNT = get_comment_meta( $cp_ID, '_commentliked', true );
347
+ $comment_template = str_replace( "%COMMENT_COUNT%", $COMMENT_COUNT, $comment_template );
348
+ }
349
+ bp_activity_add( array(
350
+ 'user_id' => $user_ID,
351
+ 'action' => $comment_template,
352
+ 'component' => 'activity',
353
+ 'type' => 'wp_like_group',
354
+ 'item_id' => $cp_ID
355
+ ));
356
+ break;
357
+
358
+ default:
359
+ break;
360
+ }
361
+
362
+ }
363
+
364
+ //Sends out notifications when you get a like from someone
365
+ if ( wp_ulike_get_setting( 'wp_ulike_buddypress', 'custom_notification' ) == '1' ) {
366
+ // No notifications from Anonymous
367
+ if ( ! $user_ID ) {
368
+ return false;
369
+ }
370
+ $author_ID = wp_ulike_get_auhtor_id( $cp_ID, $type );
371
+ if ( ! $author_ID || $author_ID == $user_ID ) {
372
+ return false;
373
+ }
374
+ bp_notifications_add_notification( array(
375
+ 'user_id' => $author_ID,
376
+ 'item_id' => $cp_ID,
377
+ 'secondary_item_id' => $author_ID,
378
+ 'component_name' => 'wp_ulike',
379
+ 'component_action' => 'wp_ulike' . $type . '_action_' . $user_ID,
380
+ 'date_notified' => bp_core_current_time(),
381
+ 'is_new' => 1,
382
+ )
383
+ );
384
+ }
385
+
386
+ }
387
+ add_action( 'wp_ulike_after_process', 'wp_ulike_add_bp_notifications', 10, 5 );
388
+ }
389
 
390
  /**
391
  * Add custom format for 'wp_ulike' notifications.
392
  *
393
+ * @author Alimir
394
  * @since 2.5
395
  * @return String
396
  */
397
+ if( ! function_exists( 'wp_ulike_format_buddypress_notifications' ) ){
398
  function wp_ulike_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
399
+ global $wp_filter,$wp_version;
400
+ // Return value
401
+ $return = false;
402
+ if ( strpos( $action, 'wp_ulike_' ) !== false ) {
403
+ $custom_link = '';
404
+ //Extracting ulike type from the action value.
405
+ preg_match('/wp_ulike_(.*?)_action/', $action, $type);
406
+ //Extracting user id from the action value.
407
+ preg_match('/action_([0-9]+)/', $action, $user_ID);
408
+ $user_info = get_userdata($user_ID[1]);
409
+ $custom_text = __('You have a new like from', WP_ULIKE_SLUG ) . ' "' . $user_info->display_name . '"';
410
+ //checking the ulike types
411
+ if($type[1] == 'liked'){
412
+ $custom_link = get_permalink($item_id);
413
+ }
414
+ else if($type[1] == 'topicliked'){
415
+ $custom_link = get_permalink($item_id);
416
+ }
417
+ else if($type[1] == 'commentliked'){
418
+ $custom_link = get_comment_link( $item_id );
419
+ }
420
+ else if($type[1] == 'activityliked'){
421
+ $custom_link = bp_activity_get_permalink( $item_id );
422
+ }
423
+ // WordPress Toolbar
424
+ if ( 'string' === $format ) {
425
+ $return = apply_filters( 'wp_ulike_bp_notifications_template', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_text ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link );
426
+ // Deprecated BuddyBar
427
+ } else {
428
+ $return = apply_filters( 'wp_ulike_bp_notifications_template', array(
429
+ 'text' => $custom_text,
430
+ 'link' => $custom_link
431
+ ), $custom_link, (int) $total_items, $custom_text, $custom_text );
432
+ }
433
+ // global wp_filter to call bbPress wrapper function
434
+ if( isset( $wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications'] ) ) {
435
+ if( version_compare( $wp_version, '4.7', '>=' ) ) {
436
+ // https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
437
+ $wp_filter['bp_notifications_get_notifications_for_user']->callbacks[10]['bbp_format_buddypress_notifications']['function'] = 'wp_ulike_bbp_format_buddypress_notifications';
438
  } else {
439
+ $wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications']['function'] = 'wp_ulike_bbp_format_buddypress_notifications';
 
 
 
 
 
 
 
 
 
 
 
 
440
  }
441
+ }
442
  }
443
+
444
+ return $return;
445
  }
446
  add_filter( 'bp_notifications_get_notifications_for_user', 'wp_ulike_format_buddypress_notifications', 5, 5 );
447
  }
448
+
449
  }
450
 
451
  /*******************************************************
455
  /**
456
  * Auto insert wp_ulike_bbpress in the topcis content
457
  *
458
+ * @author Alimir
459
+ * @param String $content
460
+ * @since 2.2
461
  * @return filter on bbpPress hooks
462
  */
463
  if( ! function_exists( 'wp_ulike_put_bbpress' ) && function_exists( 'is_bbpress' ) ){
464
  function wp_ulike_put_bbpress() {
465
  wp_ulike_bbpress('get');
466
  }
467
+ if (wp_ulike_get_setting( 'wp_ulike_bbpress', 'auto_display' ) == '1') {
468
  if (wp_ulike_get_setting( 'wp_ulike_bbpress', 'auto_display_position' ) == 'top') {
469
+ add_action( 'bbp_theme_before_reply_content', 'wp_ulike_put_bbpress' );
470
  } else {
471
  add_action( 'bbp_theme_after_reply_content', 'wp_ulike_put_bbpress' );
472
  }
483
  * @author Gabriel Lemarie & Alimir
484
  * @since 2.3
485
  */
486
+ if( defined( 'myCRED_VERSION' ) ){
487
  if( ! function_exists( 'wp_ulike_register_myCRED_hook' ) ){
488
  function wp_ulike_register_myCRED_hook( $installed ) {
489
  $installed['wp_ulike'] = array(
523
  */
524
  if( ! function_exists( 'wp_ulike_add_custom_profile_tab' ) ){
525
  function wp_ulike_add_custom_profile_tab( $tabs ) {
526
+
527
  $tabs['wp-ulike-posts'] = array(
528
  'name' => __('Recent Posts Liked',WP_ULIKE_SLUG),
529
  'icon' => 'um-faicon-thumbs-up',
530
  );
531
+
532
  $tabs['wp-ulike-comments'] = array(
533
  'name' => __('Recent Comments Liked',WP_ULIKE_SLUG),
534
  'icon' => 'um-faicon-thumbs-o-up',
535
  );
536
+
537
  return $tabs;
538
  }
539
  add_filter('um_profile_tabs', 'wp_ulike_add_custom_profile_tab', 1000 );
549
  if( ! function_exists( 'wp_ulike_posts_um_profile_content' ) ){
550
  function wp_ulike_posts_um_profile_content( $args ) {
551
  global $wp_ulike_class,$ultimatemember;
552
+
553
  $args = array(
554
  "user_id" => um_profile_id(), //User ID
555
  "col" => 'post_id', //Table Column (post_id,comment_id,activity_id,topic_id)
556
  "table" => 'ulike', //Table Name
557
  "limit" => 10, //limit Number
558
+ );
559
+
560
  $user_logs = $wp_ulike_class->get_current_user_likes($args);
561
+
562
  if($user_logs != null){
563
  echo '<div class="um-profile-note"><span>'. __('Recent Posts Liked',WP_ULIKE_SLUG).'</span></div>';
564
  foreach ($user_logs as $user_log) {
565
  $get_post = get_post(stripslashes($user_log->post_id));
566
  $get_date = $user_log->date_time;
567
+
568
  echo '<div class="um-item">';
569
  echo '<div class="um-item-link">
570
  <i class="um-icon-ios-paper"></i>
577
  echo '</div>';
578
  }
579
  } else echo '<div style="display: block;" class="um-profile-note"><i class="um-faicon-frown-o"></i><span>'. __('This user has not made any likes.',WP_ULIKE_SLUG).'</span></div>';
580
+ }
581
  add_action('um_profile_content_wp-ulike-posts_default', 'wp_ulike_posts_um_profile_content');
582
  }
583
 
587
  * @author Alimir
588
  * @since 2.3
589
  * @return Void
590
+ */
591
  if( ! function_exists( 'wp_ulike_comments_um_profile_content' ) ){
592
  function wp_ulike_comments_um_profile_content( $args ) {
593
  global $wp_ulike_class,$ultimatemember;
594
+
595
  $args = array(
596
  "user_id" => um_profile_id(), //User ID
597
  "col" => 'comment_id', //Table Column (post_id,comment_id,activity_id,topic_id)
598
  "table" => 'ulike_comments', //Table Name
599
  "limit" => 10, //limit Number
600
+ );
601
+
602
  $user_logs = $wp_ulike_class->get_current_user_likes($args);
603
+
604
  if($user_logs != null){
605
  echo '<div class="um-profile-note"><span>'. __('Recent Comments Liked',WP_ULIKE_SLUG).'</span></div>';
606
  foreach ($user_logs as $user_log) {
607
  $comment = get_comment(stripslashes($user_log->comment_id));
608
  $get_date = $user_log->date_time;
609
+
610
  echo '<div class="um-item">';
611
  echo '<div class="um-item-link">
612
  <i class="um-icon-ios-chatboxes"></i>
623
  }
624
  add_action('um_profile_content_wp-ulike-comments_default', 'wp_ulike_comments_um_profile_content');
625
  }
626
+ }
readme.txt CHANGED
@@ -4,8 +4,8 @@ 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
7
- Tested up to: 4.9.5
8
- Stable tag: 3.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -24,7 +24,7 @@ Also WP ULike’s amazing statistics tools help you to track your content effect
24
  * Fork Us In [Github](https://github.com/Alimir/wp-ulike).
25
 
26
  = Features =
27
- * Clean Design + Pretty styles.
28
  * Full myCRED Points Support.
29
  * Flexible google rich snippets support. (Microdata)
30
  * Full Statistics tools with many widgets.
@@ -58,7 +58,7 @@ WP ULike has been translated into the following languages:
58
  * French (France)
59
  * Chinese (China)
60
  * Chinese (Taiwan)
61
- * Dutch (Netherlands)
62
  * Arabic
63
  * Portuguese (Brazil)
64
  * Turkish (Turkey)
@@ -162,18 +162,25 @@ Documentation : [Github](https://github.com/alimir/wp-ulike#how-to-get-comment-l
162
  Documentation : [Github](https://github.com/alimir/wp-ulike#how-to-sort-most-liked-posts)
163
 
164
  = How Can I Create Custom Template In Users Liked Box? =
165
- * We have provided some variables in setting panel. You can use them in textarea and then save the new options.
166
  * Attention: `%START_WHILE%` And `%END_WHILE%` variables are very important and you should use them out of the frequent string. (Such as `<li></li>` tags sample in default template)
167
 
168
  = Receive HTTP ERROR 500 on WP ULike > Statistics =
169
  * Increasing Your WordPress Memory Limit in wp-config.php to fix this error. It is located in your WordPress site's root folder, and you will need to use an FTP client or file manager in your web hosting control panel.
170
  * Next, you need to paste this code in wp-config.php file just before the line that says "That's all, stop editing! Happy blogging."
171
- <code>
172
  define( 'WP_MEMORY_LIMIT', '256M' );
173
  </code>
174
 
175
  == Changelog ==
176
 
 
 
 
 
 
 
 
177
  = 3.2 =
178
  * Added: A new lightweight notification system.
179
  * Added: A better AJAX response in front-end process
@@ -230,7 +237,7 @@ define( 'WP_MEMORY_LIMIT', '256M' );
230
  * Added: New response functionality with JSON.
231
  * Updated: 'wp_ulike' core class functionality.
232
  * Updated: FAQ documentation.
233
- * Removed: Old script files and enqueue new wp-ulike script.
234
  * Removed: Old version of 'mysql2date' function.
235
 
236
  = 2.7 =
@@ -439,7 +446,7 @@ define( 'WP_MEMORY_LIMIT', '256M' );
439
 
440
  = 1.2 =
441
  * Added: most liked users widget.
442
- * Added: Chinese (ZH_CN) language. (Thanks to Changmeng Hu)
443
 
444
  = 1.1 =
445
  * Added: loading spinner.
@@ -454,6 +461,9 @@ define( 'WP_MEMORY_LIMIT', '256M' );
454
 
455
  == Upgrade Notice ==
456
 
 
 
 
457
  = 3.2 =
458
  Attention Please! In this version, we have made some changes on plugin scripts! So, please clear your server cache after the plugin update.
459
 
@@ -485,7 +495,7 @@ In this version, we made some changes in the plugin scripts (wp-ulike-scripts.js
485
  In this version, we made some changes in the plugin scripts! So, please clear your browser cache after the plugin update.
486
 
487
  = 2.0 =
488
- In this version, we have mixed widgets in one packet. So you should upgrade your last widgets with new one. Have fun :)
489
 
490
  = 1.8 =
491
  In this version, we have made many changes on plugin functions and settings. So if you lose your last settings, try to add them again. :)
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
7
+ Tested up to: 4.9.6
8
+ Stable tag: 3.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
24
  * Fork Us In [Github](https://github.com/Alimir/wp-ulike).
25
 
26
  = Features =
27
+ * Clean Design + Pretty styles.
28
  * Full myCRED Points Support.
29
  * Flexible google rich snippets support. (Microdata)
30
  * Full Statistics tools with many widgets.
58
  * French (France)
59
  * Chinese (China)
60
  * Chinese (Taiwan)
61
+ * Dutch (Netherlands)
62
  * Arabic
63
  * Portuguese (Brazil)
64
  * Turkish (Turkey)
162
  Documentation : [Github](https://github.com/alimir/wp-ulike#how-to-sort-most-liked-posts)
163
 
164
  = How Can I Create Custom Template In Users Liked Box? =
165
+ * We have provided some variables in setting panel. You can use them in textarea and then save the new options.
166
  * Attention: `%START_WHILE%` And `%END_WHILE%` variables are very important and you should use them out of the frequent string. (Such as `<li></li>` tags sample in default template)
167
 
168
  = Receive HTTP ERROR 500 on WP ULike > Statistics =
169
  * Increasing Your WordPress Memory Limit in wp-config.php to fix this error. It is located in your WordPress site's root folder, and you will need to use an FTP client or file manager in your web hosting control panel.
170
  * Next, you need to paste this code in wp-config.php file just before the line that says "That's all, stop editing! Happy blogging."
171
+ <code>
172
  define( 'WP_MEMORY_LIMIT', '256M' );
173
  </code>
174
 
175
  == Changelog ==
176
 
177
+ = 3.3 =
178
+ * Added: AJAX refresh for likers box.
179
+ * Added: Anonymize IP option for GDPR compliance.
180
+ * Updated: Core functionalities.
181
+ * Updated: Settings panel.
182
+ * Fixed: Some important bugs.
183
+
184
  = 3.2 =
185
  * Added: A new lightweight notification system.
186
  * Added: A better AJAX response in front-end process
237
  * Added: New response functionality with JSON.
238
  * Updated: 'wp_ulike' core class functionality.
239
  * Updated: FAQ documentation.
240
+ * Removed: Old script files and enqueue new wp-ulike script.
241
  * Removed: Old version of 'mysql2date' function.
242
 
243
  = 2.7 =
446
 
447
  = 1.2 =
448
  * Added: most liked users widget.
449
+ * Added: Chinese (ZH_CN) language. (Thanks to Changmeng Hu)
450
 
451
  = 1.1 =
452
  * Added: loading spinner.
461
 
462
  == Upgrade Notice ==
463
 
464
+ = 3.3 =
465
+ Attention Please! In this version, we have made some changes on plugin scripts! So, please clear your server cache after the plugin update.
466
+
467
  = 3.2 =
468
  Attention Please! In this version, we have made some changes on plugin scripts! So, please clear your server cache after the plugin update.
469
 
495
  In this version, we made some changes in the plugin scripts! So, please clear your browser cache after the plugin update.
496
 
497
  = 2.0 =
498
+ In this version, we have mixed widgets in one packet. So you should upgrade your last widgets with new one. Have fun :)
499
 
500
  = 1.8 =
501
  In this version, we have made many changes on plugin functions and settings. So if you lose your last settings, try to add them again. :)
wp-assets/banner-1544x500.png ADDED
Binary file
wp-assets/banner-772x250.png ADDED
Binary file
wp-assets/icon-128x128.png ADDED
Binary file
wp-assets/icon-256x256.png ADDED
Binary file
wp-assets/screenshot-1.png ADDED
Binary file
wp-assets/screenshot-2.png ADDED
Binary file
wp-assets/screenshot-3.png ADDED
Binary file
wp-assets/screenshot-4.png ADDED
Binary file
wp-ulike.php CHANGED
@@ -1,34 +1,42 @@
1
  <?php
2
- /*
3
- Plugin Name: WP ULike
4
- Plugin URI: https://wpulike.com/
5
- 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.
6
- Version: 3.2
7
- Author: Ali Mirzaei
8
- Author URI: http://about.alimir.ir
9
- Text Domain: wp-ulike
10
- Domain Path: /lang/
11
- License: GPL2
12
-
13
- /------------------------------------------\
14
- _ __ _ _____ _ _ _ _
15
- | | / \ | | ___ \ | |(_)| | / /
16
- | | / /\ \ | | |_/ / _| || || |/ / ___
17
- | | / / \ \ | | __/ | | | || || | / _ \
18
- | |/ / \ \| | | | |_| | || || |\ \ __/
19
- \___/ \__/\_| \__,_|_||_||_| \_\___|
20
-
21
- \--> Alimir, 2018 <--/
22
-
23
- Thanks for using WP ULike plugin!
24
-
25
- \------------------------------------------/
26
-
 
 
 
 
 
 
 
 
27
  */
28
 
29
  // Do not change these values
30
  define( 'WP_ULIKE_PLUGIN_URI' , 'https://wpulike.com/' );
31
- define( 'WP_ULIKE_VERSION' , '3.2' );
32
  define( 'WP_ULIKE_SLUG' , 'wp-ulike' );
33
  define( 'WP_ULIKE_DB_VERSION' , '1.3' );
34
 
@@ -68,20 +76,20 @@ if ( ! class_exists( 'WPULIKE' ) ) :
68
  *
69
  * @since 3.1
70
  */
71
- private function __construct() {
72
 
73
- add_action( 'init', array( $this, 'init' ) );
74
  // Include Files
75
  $this->includes();
76
-
77
  // Activate plugin when new blog is added
78
  add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
79
-
80
  add_action( 'activated_plugin', array( $this, 'after_activation' ) );
81
-
82
  $prefix = is_network_admin() ? 'network_admin_' : '';
83
- add_filter( "{$prefix}plugin_action_links", array( $this, 'add_links' ), 10, 5 );
84
-
85
  // Loaded action
86
  do_action( 'wp_ulike_loaded' );
87
  }
@@ -102,9 +110,9 @@ if ( ! class_exists( 'WPULIKE' ) ) :
102
  // Merge on actions array
103
  $actions = array_merge( $about, $actions );
104
  $actions = array_merge( $stats, $actions );
105
- $actions = array_merge( $settings, $actions );
106
  }
107
-
108
  return $actions;
109
  }
110
 
@@ -143,7 +151,7 @@ if ( ! class_exists( 'WPULIKE' ) ) :
143
  'wp_ulike_bbpress' => apply_filters( 'wp_ulike_bbpress_settings' , wp_ulike_get_options_info('bbpress') ),
144
  'wp_ulike_customize' => apply_filters( 'wp_ulike_customize_settings' , wp_ulike_get_options_info('customizer') )
145
  )
146
- );
147
  }
148
 
149
 
@@ -173,7 +181,7 @@ if ( ! class_exists( 'WPULIKE' ) ) :
173
 
174
  }
175
 
176
- }
177
 
178
 
179
  /**
@@ -192,14 +200,14 @@ if ( ! class_exists( 'WPULIKE' ) ) :
192
  }
193
  spl_autoload_register( array( $this, 'autoload' ) );
194
 
195
- // global variable of user IP
196
- $wp_user_IP = $this->get_ip();
197
-
198
  // load common functionalities
199
  include_once( WP_ULIKE_INC_DIR . '/index.php' );
200
-
 
 
 
201
  // global wp_ulike_class
202
- $wp_ulike_class = wp_ulike::get_instance();
203
 
204
  // Dashboard and Administrative Functionality
205
  if ( is_admin() ) {
@@ -209,19 +217,19 @@ if ( ! class_exists( 'WPULIKE' ) ) :
209
  include( WP_ULIKE_ADMIN_DIR . '/admin-ajax.php' );
210
  }
211
  // Add Settings Page
212
- $this->settings();
213
-
214
  //include wp_ulike_stats class & geoIPloc functions
215
  if( isset( $_GET["page"] ) && stripos( $_GET["page"], "wp-ulike-statistics" ) !== false ){
216
  //include PHP GeoIPLocation Library
217
  require_once( WP_ULIKE_ADMIN_DIR . '/includes/geoiploc.php');
218
  // global variable
219
  global $wp_ulike_stats;
220
- $wp_ulike_stats = wp_ulike_stats::get_instance();
221
- };
222
 
223
  // Load admin spesific codes
224
- include( WP_ULIKE_ADMIN_DIR . '/index.php' );
225
  }
226
 
227
  }
@@ -248,15 +256,36 @@ if ( ! class_exists( 'WPULIKE' ) ) :
248
  } else {
249
  $ip = $_SERVER['REMOTE_ADDR'];
250
  }
251
-
252
 
253
  if ( ! filter_var( $ip, FILTER_VALIDATE_IP ) ) {
 
254
  return '127.0.0.1';
255
  } else {
256
- return $ip;
 
 
 
 
 
257
  }
258
 
259
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
  /**
262
  * Init the plugin when WordPress Initialises.
@@ -273,7 +302,6 @@ if ( ! class_exists( 'WPULIKE' ) ) :
273
  }
274
  }
275
 
276
-
277
  /**
278
  * Return an instance of this class.
279
  *
@@ -337,7 +365,7 @@ if ( ! class_exists( 'WPULIKE' ) ) :
337
  exit( wp_redirect( admin_url( 'admin.php?page=wp-ulike-about' ) ) );
338
  }
339
  }
340
- }
341
 
342
 
343
  /**
@@ -532,8 +560,8 @@ if ( ! class_exists( 'WPULIKE' ) ) :
532
  *
533
  * @since 3.1
534
  */
535
- function RUN_WPULIKE(){
536
- return WPULIKE::get_instance();
537
  }
538
  RUN_WPULIKE();
539
 
@@ -541,14 +569,14 @@ if ( ! class_exists( 'WPULIKE' ) ) :
541
  register_activation_hook ( __FILE__, array( 'WPULIKE', 'activate' ) );
542
  register_deactivation_hook( __FILE__, array( 'WPULIKE', 'deactivate' ) );
543
 
544
- else :
545
 
546
  function wp_ulike_two_instances_error() {
547
  $class = 'notice notice-error';
548
  $message = __( 'You are using two instances of WP ULike plugin at same time, please deactive one of them.', WP_ULIKE_SLUG );
549
- printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
550
  }
551
- add_action( 'admin_notices', 'wp_ulike_two_instances_error' );
552
 
553
  endif;
554
 
1
  <?php
2
+ /**
3
+ * All wp-ulike functionalities starting from here...
4
+ *
5
+ *
6
+ * @package wp-ulike
7
+ * @author Alimir 2018
8
+ * @link https://wpulike.com
9
+ *
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.3
14
+ * Author: Ali Mirzaei
15
+ * Author URI: http://alimir.ir
16
+ * Text Domain: wp-ulike
17
+ * License: GPL2
18
+ * License URI: https://www.gnu.org/licenses/gpl-2.0.html
19
+ * Domain Path: /lang
20
+ * Tested up to: 4.9.6
21
+
22
+ /------------------------------------------\
23
+ _ __ _ _____ _ _ _ _
24
+ | | / \ | | ___ \ | |(_)| | / /
25
+ | | / /\ \ | | |_/ / _| || || |/ / ___
26
+ | | / / \ \ | | __/ | | | || || | / _ \
27
+ | |/ / \ \| | | | |_| | || || |\ \ __/
28
+ \___/ \__/\_| \__,_|_||_||_| \_\___|
29
+
30
+ \--> Alimir, 2018 <--/
31
+
32
+ Thanks for using WP ULike plugin!
33
+
34
+ \------------------------------------------/
35
  */
36
 
37
  // Do not change these values
38
  define( 'WP_ULIKE_PLUGIN_URI' , 'https://wpulike.com/' );
39
+ define( 'WP_ULIKE_VERSION' , '3.3' );
40
  define( 'WP_ULIKE_SLUG' , 'wp-ulike' );
41
  define( 'WP_ULIKE_DB_VERSION' , '1.3' );
42
 
76
  *
77
  * @since 3.1
78
  */
79
+ private function __construct() {
80
 
81
+ add_action( 'init', array( $this, 'init' ) );
82
  // Include Files
83
  $this->includes();
84
+
85
  // Activate plugin when new blog is added
86
  add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
87
+
88
  add_action( 'activated_plugin', array( $this, 'after_activation' ) );
89
+
90
  $prefix = is_network_admin() ? 'network_admin_' : '';
91
+ add_filter( "{$prefix}plugin_action_links", array( $this, 'add_links' ), 10, 5 );
92
+
93
  // Loaded action
94
  do_action( 'wp_ulike_loaded' );
95
  }
110
  // Merge on actions array
111
  $actions = array_merge( $about, $actions );
112
  $actions = array_merge( $stats, $actions );
113
+ $actions = array_merge( $settings, $actions );
114
  }
115
+
116
  return $actions;
117
  }
118
 
151
  'wp_ulike_bbpress' => apply_filters( 'wp_ulike_bbpress_settings' , wp_ulike_get_options_info('bbpress') ),
152
  'wp_ulike_customize' => apply_filters( 'wp_ulike_customize_settings' , wp_ulike_get_options_info('customizer') )
153
  )
154
+ );
155
  }
156
 
157
 
181
 
182
  }
183
 
184
+ }
185
 
186
 
187
  /**
200
  }
201
  spl_autoload_register( array( $this, 'autoload' ) );
202
 
 
 
 
203
  // load common functionalities
204
  include_once( WP_ULIKE_INC_DIR . '/index.php' );
205
+
206
+ // global variable of user IP
207
+ $wp_user_IP = $this->get_ip();
208
+
209
  // global wp_ulike_class
210
+ $wp_ulike_class = wp_ulike::get_instance();
211
 
212
  // Dashboard and Administrative Functionality
213
  if ( is_admin() ) {
217
  include( WP_ULIKE_ADMIN_DIR . '/admin-ajax.php' );
218
  }
219
  // Add Settings Page
220
+ $this->settings();
221
+
222
  //include wp_ulike_stats class & geoIPloc functions
223
  if( isset( $_GET["page"] ) && stripos( $_GET["page"], "wp-ulike-statistics" ) !== false ){
224
  //include PHP GeoIPLocation Library
225
  require_once( WP_ULIKE_ADMIN_DIR . '/includes/geoiploc.php');
226
  // global variable
227
  global $wp_ulike_stats;
228
+ $wp_ulike_stats = wp_ulike_stats::get_instance();
229
+ };
230
 
231
  // Load admin spesific codes
232
+ include( WP_ULIKE_ADMIN_DIR . '/index.php' );
233
  }
234
 
235
  }
256
  } else {
257
  $ip = $_SERVER['REMOTE_ADDR'];
258
  }
259
+
260
 
261
  if ( ! filter_var( $ip, FILTER_VALIDATE_IP ) ) {
262
+ // Return local ip address
263
  return '127.0.0.1';
264
  } else {
265
+
266
+ if ( wp_ulike_get_setting( 'wp_ulike_general', 'anonymise', '0' ) == '1' ) {
267
+ return $this->anonymise_ip( $ip );
268
+ } else {
269
+ return $ip;
270
+ }
271
  }
272
 
273
+ }
274
+
275
+ /**
276
+ * Anonymise IP address
277
+ *
278
+ * @since 3.3
279
+ *
280
+ * @return String
281
+ */
282
+ public function anonymise_ip( $ip_address ) {
283
+ if ( strpos( $ip_address, "." ) == true ) {
284
+ return preg_replace('~[0-9]+$~', '000', $ip_address);
285
+ } else {
286
+ return preg_replace('~[0-9]*:[0-9]+$~', '0000:0000', $ip_address);
287
+ }
288
+ }
289
 
290
  /**
291
  * Init the plugin when WordPress Initialises.
302
  }
303
  }
304
 
 
305
  /**
306
  * Return an instance of this class.
307
  *
365
  exit( wp_redirect( admin_url( 'admin.php?page=wp-ulike-about' ) ) );
366
  }
367
  }
368
+ }
369
 
370
 
371
  /**
560
  *
561
  * @since 3.1
562
  */
563
+ function RUN_WPULIKE(){
564
+ return WPULIKE::get_instance();
565
  }
566
  RUN_WPULIKE();
567
 
569
  register_activation_hook ( __FILE__, array( 'WPULIKE', 'activate' ) );
570
  register_deactivation_hook( __FILE__, array( 'WPULIKE', 'deactivate' ) );
571
 
572
+ else :
573
 
574
  function wp_ulike_two_instances_error() {
575
  $class = 'notice notice-error';
576
  $message = __( 'You are using two instances of WP ULike plugin at same time, please deactive one of them.', WP_ULIKE_SLUG );
577
+ printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
578
  }
579
+ add_action( 'admin_notices', 'wp_ulike_two_instances_error' );
580
 
581
  endif;
582