Version Description
- Fixed: Third-party plugin issues.
Download this release
Release Info
Developer | alimir |
Plugin | WP ULike |
Version | 4.3.1 |
Comparing to | |
See all releases |
Code changes from version 4.3.0 to 4.3.1
- admin/assets/js/plugins.js +1 -1
- assets/js/wp-ulike.js +1 -1
- inc/hooks/third-party.php +542 -522
- readme.txt +4 -1
- wp-ulike.php +2 -2
admin/assets/js/plugins.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
/*! WP ULike - v4.3.
|
2 |
* https://wpulike.com
|
3 |
* TechnoWich 2020;
|
4 |
*/
|
1 |
+
/*! WP ULike - v4.3.1
|
2 |
* https://wpulike.com
|
3 |
* TechnoWich 2020;
|
4 |
*/
|
assets/js/wp-ulike.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
/*! WP ULike - v4.3.
|
2 |
* https://wpulike.com
|
3 |
* TechnoWich 2020;
|
4 |
*/
|
1 |
+
/*! WP ULike - v4.3.1
|
2 |
* https://wpulike.com
|
3 |
* TechnoWich 2020;
|
4 |
*/
|
inc/hooks/third-party.php
CHANGED
@@ -16,434 +16,431 @@ if ( ! defined( 'WPINC' ) ) {
|
|
16 |
BuddyPress
|
17 |
*******************************************************/
|
18 |
|
19 |
-
if(
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
$options = wp_ulike_get_option( 'buddypress_group' );
|
30 |
-
$action = current_action();
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
switch ( $action ) {
|
37 |
-
case 'bp_activity_comment_options':
|
38 |
-
if( isset( $options['enable_comments'] ) && wp_ulike_is_true( $options['enable_comments'] ) ) {
|
39 |
-
if ( isset( $options['auto_display_position'] ) && $options['auto_display_position'] === 'meta' ){
|
40 |
-
echo $button;
|
41 |
-
}
|
42 |
-
}
|
43 |
-
break;
|
44 |
|
45 |
-
|
|
|
|
|
46 |
if ( isset( $options['auto_display_position'] ) && $options['auto_display_position'] === 'meta' ){
|
47 |
echo $button;
|
48 |
}
|
49 |
-
|
|
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
}
|
59 |
-
add_action( 'bp_activity_entry_meta', 'wp_ulike_put_buddypress', 15 );
|
60 |
-
add_action( 'bp_activity_comment_options', 'wp_ulike_put_buddypress', 15 );
|
61 |
-
add_action( 'bp_activity_entry_content', 'wp_ulike_put_buddypress', 15 );
|
62 |
}
|
|
|
|
|
|
|
|
|
63 |
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
}
|
81 |
}
|
82 |
-
|
83 |
-
|
|
|
84 |
|
85 |
-
}
|
86 |
-
add_action( 'bp_nouveau_get_single_activity_content', 'wp_ulike_buddypress_activity_content_ajax_display', 15, 1 );
|
87 |
}
|
|
|
|
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
}
|
105 |
}
|
106 |
}
|
107 |
-
|
108 |
-
return $content;
|
109 |
}
|
110 |
-
|
|
|
111 |
}
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
}
|
128 |
-
add_action( 'bp_register_activity_actions', 'wp_ulike_register_activity_actions' );
|
129 |
}
|
|
|
|
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
}
|
141 |
-
add_action( 'bp_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Activity Directory
|
142 |
-
add_action( 'bp_member_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Member's profile activity
|
143 |
-
add_action( 'bp_group_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Group's activity
|
144 |
}
|
|
|
|
|
|
|
|
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
}
|
159 |
-
// Add 'wp_ulike' component to registered components array
|
160 |
-
array_push( $component_names, 'wp_ulike' );
|
161 |
-
// Return component's with 'wp_ulike' appended
|
162 |
-
return $component_names;
|
163 |
}
|
164 |
-
|
|
|
|
|
|
|
165 |
}
|
|
|
|
|
166 |
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
// Return if user not logged in or an older data log exist
|
183 |
-
if( ! is_user_logged_in() || $has_log > 0 || ! function_exists( 'bp_is_active' ) ){
|
184 |
-
return;
|
185 |
-
}
|
186 |
|
187 |
-
|
|
|
|
|
|
|
188 |
|
189 |
-
|
190 |
-
if ( isset( $options['enable_add_bp_activity'] ) && wp_ulike_is_true( $options['enable_add_bp_activity'] ) ) {
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
// Replace the post variables
|
195 |
-
$post_template = wp_ulike_get_option( 'posts_notification_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)' );
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
if ( strpos( $post_template, '%POST_PERMALINK%' ) !== false ) {
|
202 |
-
$POST_PERMALINK = get_permalink($cp_ID);
|
203 |
-
$post_template = str_replace( "%POST_PERMALINK%", $POST_PERMALINK, $post_template );
|
204 |
-
}
|
205 |
-
if ( strpos( $post_template, '%POST_COUNT%' ) !== false ) {
|
206 |
-
$POST_COUNT = wp_ulike_get_post_likes( $cp_ID );
|
207 |
-
$post_template = str_replace( "%POST_COUNT%", $POST_COUNT, $post_template );
|
208 |
-
}
|
209 |
-
if ( strpos( $post_template, '%POST_TITLE%' ) !== false ) {
|
210 |
-
$POST_TITLE = get_the_title( $cp_ID );
|
211 |
-
$post_template = str_replace( "%POST_TITLE%", $POST_TITLE, $post_template );
|
212 |
-
}
|
213 |
-
bp_activity_add( array(
|
214 |
-
'user_id' => $user_ID,
|
215 |
-
'action' => $post_template,
|
216 |
-
'component' => 'activity',
|
217 |
-
'type' => 'wp_like_group',
|
218 |
-
'item_id' => $cp_ID
|
219 |
-
));
|
220 |
-
break;
|
221 |
-
|
222 |
-
case '_commentliked':
|
223 |
-
// Replace the comment variables
|
224 |
-
$comment_template = wp_ulike_get_option( 'comments_notification_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)' );
|
225 |
-
|
226 |
-
if ( strpos( $comment_template, '%COMMENT_LIKER%' ) !== false ) {
|
227 |
-
$COMMENT_LIKER = bp_core_get_userlink( $user_ID );
|
228 |
-
$comment_template = str_replace("%COMMENT_LIKER%", $COMMENT_LIKER, $comment_template );
|
229 |
-
}
|
230 |
-
if ( strpos( $comment_template, '%COMMENT_PERMALINK%' ) !== false ) {
|
231 |
-
$COMMENT_PERMALINK = get_comment_link( $cp_ID );
|
232 |
-
$comment_template = str_replace( "%COMMENT_PERMALINK%", $COMMENT_PERMALINK, $comment_template );
|
233 |
-
}
|
234 |
-
if ( strpos( $comment_template, '%COMMENT_AUTHOR%' ) !== false ) {
|
235 |
-
$COMMENT_AUTHOR = get_comment_author( $cp_ID );
|
236 |
-
$comment_template = str_replace( "%COMMENT_AUTHOR%", $COMMENT_AUTHOR, $comment_template );
|
237 |
-
}
|
238 |
-
if ( strpos( $comment_template, '%COMMENT_COUNT%' ) !== false ) {
|
239 |
-
$COMMENT_COUNT = wp_ulike_get_comment_likes( $cp_ID );
|
240 |
-
$comment_template = str_replace( "%COMMENT_COUNT%", $COMMENT_COUNT, $comment_template );
|
241 |
-
}
|
242 |
-
bp_activity_add( array(
|
243 |
-
'user_id' => $user_ID,
|
244 |
-
'action' => $comment_template,
|
245 |
-
'component' => 'activity',
|
246 |
-
'type' => 'wp_like_group',
|
247 |
-
'item_id' => $cp_ID
|
248 |
-
));
|
249 |
-
break;
|
250 |
-
|
251 |
-
default:
|
252 |
-
break;
|
253 |
-
}
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
|
257 |
-
|
258 |
-
if ( isset( $options['enable_add_notification'] ) && wp_ulike_is_true( $options['enable_add_notification'] ) ) {
|
259 |
-
// No notifications from Anonymous
|
260 |
-
if ( ! $user_ID || false === get_userdata( $user_ID ) ) {
|
261 |
-
return false;
|
262 |
-
}
|
263 |
-
$author_ID = wp_ulike_get_auhtor_id( $cp_ID, $type );
|
264 |
-
if ( ! $author_ID || $author_ID == $user_ID ) {
|
265 |
-
return false;
|
266 |
-
}
|
267 |
-
bp_notifications_add_notification( array(
|
268 |
-
'user_id' => $author_ID,
|
269 |
-
'item_id' => $cp_ID,
|
270 |
-
'secondary_item_id' => $user_ID,
|
271 |
-
'component_name' => 'wp_ulike',
|
272 |
-
'component_action' => 'wp_ulike' . $type . '_action',
|
273 |
-
'date_notified' => bp_core_current_time(),
|
274 |
-
'is_new' => 1,
|
275 |
-
)
|
276 |
-
);
|
277 |
-
}
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
}
|
280 |
-
|
281 |
}
|
|
|
|
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
}
|
357 |
}
|
358 |
}
|
359 |
-
|
360 |
-
return $content;
|
361 |
}
|
362 |
|
363 |
return $content;
|
364 |
}
|
365 |
-
add_filter( 'bp_notifications_get_notifications_for_user', 'wp_ulike_format_buddypress_notifications', 25, 8 );
|
366 |
-
}
|
367 |
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
* @return void
|
373 |
-
*/
|
374 |
-
function wp_ulike_notification_filters(){
|
375 |
-
$notifications = array(
|
376 |
-
array(
|
377 |
-
'id' => 'wp_ulike_activityliked_action',
|
378 |
-
'label' => __( 'New activity liked', WP_ULIKE_SLUG ),
|
379 |
-
'position' => 340,
|
380 |
-
),
|
381 |
-
array(
|
382 |
-
'id' => 'wp_ulike_commentliked_action',
|
383 |
-
'label' => __( 'New comment liked', WP_ULIKE_SLUG ),
|
384 |
-
'position' => 345,
|
385 |
-
),
|
386 |
-
array(
|
387 |
-
'id' => 'wp_ulike_liked_action',
|
388 |
-
'label' => __( 'New post liked', WP_ULIKE_SLUG ),
|
389 |
-
'position' => 355,
|
390 |
-
),
|
391 |
-
array(
|
392 |
-
'id' => 'wp_ulike_topicliked_action',
|
393 |
-
'label' => __( 'New topic liked', WP_ULIKE_SLUG ),
|
394 |
-
'position' => 365,
|
395 |
-
)
|
396 |
-
);
|
397 |
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
}
|
|
|
404 |
}
|
405 |
-
add_action( 'bp_nouveau_notifications_init_filters', 'wp_ulike_notification_filters' );
|
406 |
}
|
|
|
|
|
407 |
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
}
|
437 |
}
|
438 |
-
add_action( 'wp_loaded', 'wp_ulike_seen_bp_notifications' );
|
439 |
}
|
|
|
440 |
}
|
441 |
|
442 |
/*******************************************************
|
443 |
bbPress
|
444 |
*******************************************************/
|
445 |
|
446 |
-
if( ! function_exists( 'wp_ulike_put_bbpress' )
|
447 |
/**
|
448 |
* Auto insert wp_ulike_bbpress in the topics content
|
449 |
*
|
@@ -492,7 +489,7 @@ if( ! function_exists( 'wp_ulike_put_bbpress' ) && function_exists( 'is_bbpress'
|
|
492 |
*******************************************************/
|
493 |
|
494 |
// Litespeed cache plugin
|
495 |
-
if( ! function_exists( 'wp_ulike_purge_litespeed_cache' )
|
496 |
/**
|
497 |
* Purge litespeed post cache
|
498 |
*
|
@@ -501,6 +498,11 @@ if( ! function_exists( 'wp_ulike_purge_litespeed_cache' ) && class_exists( 'Lite
|
|
501 |
* @return void
|
502 |
*/
|
503 |
function wp_ulike_purge_litespeed_cache( $ID, $type ){
|
|
|
|
|
|
|
|
|
|
|
504 |
if( $type === '_liked' ){
|
505 |
if( get_post_type( $ID ) ){
|
506 |
do_action( 'litespeed_purge_post', $ID );
|
@@ -519,7 +521,7 @@ if( ! function_exists( 'wp_ulike_purge_litespeed_cache' ) && class_exists( 'Lite
|
|
519 |
}
|
520 |
|
521 |
// w3 total cache plugin
|
522 |
-
if( ! function_exists( 'wp_ulike_purge_w3_total_cache' )
|
523 |
/**
|
524 |
* Purge w3 total post cache
|
525 |
*
|
@@ -528,6 +530,11 @@ if( ! function_exists( 'wp_ulike_purge_w3_total_cache' ) && function_exists( 'w3
|
|
528 |
* @return void
|
529 |
*/
|
530 |
function wp_ulike_purge_w3_total_cache( $ID, $type ){
|
|
|
|
|
|
|
|
|
|
|
531 |
if( $type === '_liked' ){
|
532 |
if( get_post_type( $ID ) ){
|
533 |
w3tc_flush_post( $ID );
|
@@ -546,7 +553,7 @@ if( ! function_exists( 'wp_ulike_purge_w3_total_cache' ) && function_exists( 'w3
|
|
546 |
}
|
547 |
|
548 |
// wp fastest cache plugin
|
549 |
-
if( ! function_exists( 'wp_ulike_purge_wp_fastest_cache' )
|
550 |
/**
|
551 |
* Purge wp fastest cache
|
552 |
*
|
@@ -555,9 +562,11 @@ if( ! function_exists( 'wp_ulike_purge_wp_fastest_cache' ) && class_exists( 'WpF
|
|
555 |
* @return void
|
556 |
*/
|
557 |
function wp_ulike_purge_wp_fastest_cache( $ID, $type ){
|
558 |
-
|
|
|
559 |
return;
|
560 |
}
|
|
|
561 |
$cache_interface = $GLOBALS["wp_fastest_cache"];
|
562 |
|
563 |
// to remove cache if vote is from homepage or category page or tag
|
@@ -606,7 +615,7 @@ if( ! function_exists( 'wp_ulike_purge_wp_fastest_cache' ) && class_exists( 'WpF
|
|
606 |
}
|
607 |
|
608 |
// wp super cache plugin
|
609 |
-
if( ! function_exists( 'wp_ulike_purge_wp_super_cache' )
|
610 |
/**
|
611 |
* Purge super post cache
|
612 |
*
|
@@ -615,6 +624,11 @@ if( ! function_exists( 'wp_ulike_purge_wp_super_cache' ) && function_exists( 'wp
|
|
615 |
* @return void
|
616 |
*/
|
617 |
function wp_ulike_purge_wp_super_cache( $ID, $type ){
|
|
|
|
|
|
|
|
|
|
|
618 |
if( $type === '_liked' ){
|
619 |
if( get_post_type( $ID ) ){
|
620 |
wpsc_delete_post_cache( $ID );
|
@@ -633,7 +647,7 @@ if( ! function_exists( 'wp_ulike_purge_wp_super_cache' ) && function_exists( 'wp
|
|
633 |
}
|
634 |
|
635 |
// wp rocket cache plugin
|
636 |
-
if( ! function_exists( 'wp_ulike_purge_rocket_cache' )
|
637 |
/**
|
638 |
* Purge wp rocket cache
|
639 |
*
|
@@ -642,6 +656,11 @@ if( ! function_exists( 'wp_ulike_purge_rocket_cache' ) && function_exists( 'rock
|
|
642 |
* @return void
|
643 |
*/
|
644 |
function wp_ulike_purge_rocket_cache( $ID, $type ){
|
|
|
|
|
|
|
|
|
|
|
645 |
if( $type === '_liked' ){
|
646 |
// Check post type ID
|
647 |
if( get_post_type( $ID ) ){
|
@@ -661,7 +680,7 @@ if( ! function_exists( 'wp_ulike_purge_rocket_cache' ) && function_exists( 'rock
|
|
661 |
}
|
662 |
|
663 |
// wp optimize cache plugin
|
664 |
-
if( ! function_exists( 'wp_ulike_purge_wp_optimize_cache' )
|
665 |
/**
|
666 |
* Purge wp optimize cache
|
667 |
*
|
@@ -670,6 +689,11 @@ if( ! function_exists( 'wp_ulike_purge_wp_optimize_cache' ) && class_exists('WPO
|
|
670 |
* @return void
|
671 |
*/
|
672 |
function wp_ulike_purge_wp_optimize_cache( $ID, $type ){
|
|
|
|
|
|
|
|
|
|
|
673 |
if( $type === '_liked' ){
|
674 |
if( get_post_type( $ID ) ){
|
675 |
WPO_Page_Cache::delete_single_post_cache( $ID );
|
@@ -692,172 +716,168 @@ if( ! function_exists( 'wp_ulike_purge_wp_optimize_cache' ) && class_exists('WPO
|
|
692 |
*******************************************************/
|
693 |
|
694 |
// My Cred Plugin
|
695 |
-
if(
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
return $installed;
|
711 |
-
}
|
712 |
-
add_filter( 'mycred_setup_hooks', 'wp_ulike_register_myCRED_hook' );
|
713 |
}
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
}
|
|
|
731 |
}
|
732 |
|
733 |
// Ultimate Member plugin
|
734 |
-
if
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
function wp_ulike_add_custom_profile_tab( $tabs ) {
|
744 |
-
|
745 |
-
$tabs['wp-ulike-posts'] = array(
|
746 |
-
'name' => __('Recent Posts Liked',WP_ULIKE_SLUG),
|
747 |
-
'icon' => 'um-faicon-thumbs-up',
|
748 |
-
);
|
749 |
-
|
750 |
-
$tabs['wp-ulike-comments'] = array(
|
751 |
-
'name' => __('Recent Comments Liked',WP_ULIKE_SLUG),
|
752 |
-
'icon' => 'um-faicon-thumbs-o-up',
|
753 |
-
);
|
754 |
-
|
755 |
-
return $tabs;
|
756 |
-
}
|
757 |
-
add_filter('um_profile_tabs', 'wp_ulike_add_custom_profile_tab', 1000 );
|
758 |
-
}
|
759 |
-
|
760 |
-
if( ! function_exists( 'wp_ulike_posts_um_profile_content' ) ){
|
761 |
-
/**
|
762 |
-
* Add content to the wp-ulike-posts tab
|
763 |
-
*
|
764 |
-
* @since 2.3
|
765 |
-
* @param array $args
|
766 |
-
* @return void
|
767 |
-
*/
|
768 |
-
function wp_ulike_posts_um_profile_content() {
|
769 |
-
//Main data
|
770 |
-
$args = array(
|
771 |
-
"type" => 'post',
|
772 |
-
"rel_type" => 'post',
|
773 |
-
"status" => 'like',
|
774 |
-
"user_id" => um_profile_id(),
|
775 |
-
"is_popular" => false,
|
776 |
-
"limit" => 10
|
777 |
-
);
|
778 |
-
|
779 |
-
$get_items = wp_ulike_get_popular_items_ids( $args );
|
780 |
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
);
|
786 |
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
echo '<div class="um-item">';
|
792 |
-
echo '<div class="um-item-link">
|
793 |
-
<i class="um-icon-ios-paper"></i>
|
794 |
-
<a href="'.get_permalink().'">'.get_the_title().'</a>
|
795 |
-
</div>';
|
796 |
-
echo '<div class="um-item-meta">
|
797 |
-
<span>'.get_the_date().'</span>
|
798 |
-
<span class="badge"><i class="um-faicon-thumbs-o-up"></i> '.wp_ulike_get_post_likes( get_the_ID() ).'</span>
|
799 |
-
</div>';
|
800 |
-
echo '</div>';
|
801 |
-
endwhile;
|
802 |
-
else:
|
803 |
-
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>';
|
804 |
-
endif;
|
805 |
-
wp_reset_postdata();
|
806 |
|
807 |
-
|
808 |
-
add_action('um_profile_content_wp-ulike-posts_default', 'wp_ulike_posts_um_profile_content');
|
809 |
}
|
|
|
|
|
810 |
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
831 |
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
'posts_per_page' => $args['limit']
|
836 |
-
);
|
837 |
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
860 |
}
|
861 |
-
add_action('um_profile_content_wp-ulike-comments_default', 'wp_ulike_comments_um_profile_content');
|
862 |
}
|
|
|
863 |
}
|
16 |
BuddyPress
|
17 |
*******************************************************/
|
18 |
|
19 |
+
if( ! function_exists( 'wp_ulike_put_buddypress' ) ){
|
20 |
+
/**
|
21 |
+
* Auto insert wp_ulike_buddypress in the activities content
|
22 |
+
*
|
23 |
+
* @since 1.7
|
24 |
+
* @return void
|
25 |
+
*/
|
26 |
+
function wp_ulike_put_buddypress() {
|
27 |
+
$options = wp_ulike_get_option( 'buddypress_group' );
|
28 |
+
$action = current_action();
|
|
|
|
|
29 |
|
30 |
+
if ( isset( $options['enable_auto_display'] ) && wp_ulike_is_true( $options['enable_auto_display'] ) ) {
|
31 |
+
// Add wp_ulike function
|
32 |
+
$button = wp_ulike_buddypress('put');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
switch ( $action ) {
|
35 |
+
case 'bp_activity_comment_options':
|
36 |
+
if( isset( $options['enable_comments'] ) && wp_ulike_is_true( $options['enable_comments'] ) ) {
|
37 |
if ( isset( $options['auto_display_position'] ) && $options['auto_display_position'] === 'meta' ){
|
38 |
echo $button;
|
39 |
}
|
40 |
+
}
|
41 |
+
break;
|
42 |
|
43 |
+
case 'bp_activity_entry_meta':
|
44 |
+
if ( isset( $options['auto_display_position'] ) && $options['auto_display_position'] === 'meta' ){
|
45 |
+
echo $button;
|
46 |
+
}
|
47 |
+
break;
|
48 |
+
|
49 |
+
case 'bp_activity_entry_content':
|
50 |
+
if ( isset( $options['auto_display_position'] ) && $options['auto_display_position'] === 'content' ){
|
51 |
+
echo $button;
|
52 |
+
}
|
53 |
+
break;
|
54 |
}
|
55 |
}
|
|
|
|
|
|
|
56 |
}
|
57 |
+
add_action( 'bp_activity_entry_meta', 'wp_ulike_put_buddypress', 15 );
|
58 |
+
add_action( 'bp_activity_comment_options', 'wp_ulike_put_buddypress', 15 );
|
59 |
+
add_action( 'bp_activity_entry_content', 'wp_ulike_put_buddypress', 15 );
|
60 |
+
}
|
61 |
|
62 |
|
63 |
+
if( ! function_exists( 'wp_ulike_buddypress_activity_content_ajax_display' ) ){
|
64 |
+
/**
|
65 |
+
* BuddyPress activity content display for ajax load more
|
66 |
+
*
|
67 |
+
* @param string $content
|
68 |
+
* @return string
|
69 |
+
*/
|
70 |
+
function wp_ulike_buddypress_activity_content_ajax_display( &$activity ) {
|
71 |
+
$activityID = $activity->id;
|
72 |
|
73 |
+
add_filter( 'bp_get_activity_content_body', function( $content ) use ( $activityID ){
|
74 |
+
$options = wp_ulike_get_option( 'buddypress_group' );
|
75 |
+
if ( isset( $options['enable_auto_display'] ) && wp_ulike_is_true( $options['enable_auto_display'] ) ) {
|
76 |
+
if ( isset( $options['auto_display_position'] ) && $options['auto_display_position'] === 'content' ){
|
77 |
+
return $content . wp_ulike_buddypress( 'put', array( 'id' => $activityID ) );
|
|
|
78 |
}
|
79 |
+
}
|
80 |
+
return $content;
|
81 |
+
} );
|
82 |
|
|
|
|
|
83 |
}
|
84 |
+
add_action( 'bp_nouveau_get_single_activity_content', 'wp_ulike_buddypress_activity_content_ajax_display', 15, 1 );
|
85 |
+
}
|
86 |
|
87 |
+
if( ! function_exists( 'wp_ulike_buddypress_comment_content_display' ) ){
|
88 |
+
/**
|
89 |
+
* BuddyPress Comment Content auto display hook
|
90 |
+
*
|
91 |
+
* @param string $content
|
92 |
+
* @return string
|
93 |
+
*/
|
94 |
+
function wp_ulike_buddypress_comment_content_display( $content, $context ) {
|
95 |
+
$options = wp_ulike_get_option( 'buddypress_group' );
|
96 |
|
97 |
+
if ( isset( $options['enable_auto_display'] ) && wp_ulike_is_true( $options['enable_auto_display'] ) && $context === 'get' ) {
|
98 |
|
99 |
+
if( isset( $options['enable_comments'] ) && wp_ulike_is_true( $options['enable_comments'] ) ) {
|
100 |
+
if ( isset( $options['auto_display_position'] ) && $options['auto_display_position'] === 'content' ){
|
101 |
+
return $content . wp_ulike_buddypress('put');
|
|
|
102 |
}
|
103 |
}
|
|
|
|
|
104 |
}
|
105 |
+
|
106 |
+
return $content;
|
107 |
}
|
108 |
+
add_filter( 'bp_activity_comment_content', 'wp_ulike_buddypress_comment_content_display', 15, 2 );
|
109 |
+
}
|
110 |
|
111 |
+
if( ! function_exists( 'wp_ulike_register_activity_actions' ) ){
|
112 |
+
/**
|
113 |
+
* Register "WP ULike Activity" action
|
114 |
+
*
|
115 |
+
* @since 1.7
|
116 |
+
* @return void
|
117 |
+
*/
|
118 |
+
function wp_ulike_register_activity_actions() {
|
119 |
+
global $bp;
|
120 |
+
bp_activity_set_action(
|
121 |
+
$bp->activity->id,
|
122 |
+
'wp_like_group',
|
123 |
+
__( 'WP ULike Activity', WP_ULIKE_SLUG )
|
124 |
+
);
|
|
|
|
|
125 |
}
|
126 |
+
add_action( 'bp_register_activity_actions', 'wp_ulike_register_activity_actions' );
|
127 |
+
}
|
128 |
|
129 |
+
if( ! function_exists( 'wp_ulike_bp_activity_filter_options' ) ){
|
130 |
+
/**
|
131 |
+
* Display likes option in BuddyPress activity filter
|
132 |
+
*
|
133 |
+
* @since 2.5.1
|
134 |
+
* @return void
|
135 |
+
*/
|
136 |
+
function wp_ulike_bp_activity_filter_options() {
|
137 |
+
echo "<option value='wp_like_group'>". __( 'Votes', WP_ULIKE_SLUG ) ."</option>";
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
+
add_action( 'bp_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Activity Directory
|
140 |
+
add_action( 'bp_member_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Member's profile activity
|
141 |
+
add_action( 'bp_group_activity_filter_options', 'wp_ulike_bp_activity_filter_options' ); // Group's activity
|
142 |
+
}
|
143 |
|
144 |
+
if( ! function_exists( 'wp_ulike_filter_notifications_get_registered_components' ) ){
|
145 |
+
/**
|
146 |
+
* Register 'wp_ulike' to BuddyPress component
|
147 |
+
*
|
148 |
+
* @since 2.5
|
149 |
+
* @param array $component_names
|
150 |
+
* @return string
|
151 |
+
*/
|
152 |
+
function wp_ulike_filter_notifications_get_registered_components( $component_names = array() ) {
|
153 |
+
// Force $component_names to be an array
|
154 |
+
if ( ! is_array( $component_names ) ) {
|
155 |
+
$component_names = array();
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
+
// Add 'wp_ulike' component to registered components array
|
158 |
+
array_push( $component_names, 'wp_ulike' );
|
159 |
+
// Return component's with 'wp_ulike' appended
|
160 |
+
return $component_names;
|
161 |
}
|
162 |
+
add_filter( 'bp_notifications_get_registered_components', 'wp_ulike_filter_notifications_get_registered_components', 10 );
|
163 |
+
}
|
164 |
|
165 |
|
166 |
+
if( ! function_exists( 'wp_ulike_add_bp_notifications' ) ){
|
167 |
+
/**
|
168 |
+
* Add new buddypress activities on each like
|
169 |
+
*
|
170 |
+
* @since 1.6
|
171 |
+
* @param integer $cp_ID
|
172 |
+
* @param string $type
|
173 |
+
* @param integer $user_ID
|
174 |
+
* @param string $status
|
175 |
+
* @param boolean $has_log
|
176 |
+
* @return void
|
177 |
+
*/
|
178 |
+
function wp_ulike_add_bp_notifications( $cp_ID, $type, $user_ID, $status, $has_log ){
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
+
// Return if user not logged in or an older data log exist
|
181 |
+
if( ! is_user_logged_in() || $has_log > 0 || ! function_exists( 'bp_is_active' ) || ! defined( 'BP_VERSION' ) ){
|
182 |
+
return;
|
183 |
+
}
|
184 |
|
185 |
+
$options = wp_ulike_get_option( 'buddypress_group' );
|
|
|
186 |
|
187 |
+
//Create a new activity when an user likes something
|
188 |
+
if ( isset( $options['enable_add_bp_activity'] ) && wp_ulike_is_true( $options['enable_add_bp_activity'] ) ) {
|
|
|
|
|
189 |
|
190 |
+
switch ( $type ) {
|
191 |
+
case '_liked':
|
192 |
+
// Replace the post variables
|
193 |
+
$post_template = wp_ulike_get_option( 'posts_notification_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)' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
+
if ( strpos( $post_template, '%POST_LIKER%' ) !== false ) {
|
196 |
+
$POST_LIKER = bp_core_get_userlink( $user_ID );
|
197 |
+
$post_template = str_replace( "%POST_LIKER%", $POST_LIKER, $post_template );
|
198 |
+
}
|
199 |
+
if ( strpos( $post_template, '%POST_PERMALINK%' ) !== false ) {
|
200 |
+
$POST_PERMALINK = get_permalink($cp_ID);
|
201 |
+
$post_template = str_replace( "%POST_PERMALINK%", $POST_PERMALINK, $post_template );
|
202 |
+
}
|
203 |
+
if ( strpos( $post_template, '%POST_COUNT%' ) !== false ) {
|
204 |
+
$POST_COUNT = wp_ulike_get_post_likes( $cp_ID );
|
205 |
+
$post_template = str_replace( "%POST_COUNT%", $POST_COUNT, $post_template );
|
206 |
+
}
|
207 |
+
if ( strpos( $post_template, '%POST_TITLE%' ) !== false ) {
|
208 |
+
$POST_TITLE = get_the_title( $cp_ID );
|
209 |
+
$post_template = str_replace( "%POST_TITLE%", $POST_TITLE, $post_template );
|
210 |
+
}
|
211 |
+
bp_activity_add( array(
|
212 |
+
'user_id' => $user_ID,
|
213 |
+
'action' => $post_template,
|
214 |
+
'component' => 'activity',
|
215 |
+
'type' => 'wp_like_group',
|
216 |
+
'item_id' => $cp_ID
|
217 |
+
));
|
218 |
+
break;
|
219 |
+
|
220 |
+
case '_commentliked':
|
221 |
+
// Replace the comment variables
|
222 |
+
$comment_template = wp_ulike_get_option( 'comments_notification_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)' );
|
223 |
+
|
224 |
+
if ( strpos( $comment_template, '%COMMENT_LIKER%' ) !== false ) {
|
225 |
+
$COMMENT_LIKER = bp_core_get_userlink( $user_ID );
|
226 |
+
$comment_template = str_replace("%COMMENT_LIKER%", $COMMENT_LIKER, $comment_template );
|
227 |
+
}
|
228 |
+
if ( strpos( $comment_template, '%COMMENT_PERMALINK%' ) !== false ) {
|
229 |
+
$COMMENT_PERMALINK = get_comment_link( $cp_ID );
|
230 |
+
$comment_template = str_replace( "%COMMENT_PERMALINK%", $COMMENT_PERMALINK, $comment_template );
|
231 |
+
}
|
232 |
+
if ( strpos( $comment_template, '%COMMENT_AUTHOR%' ) !== false ) {
|
233 |
+
$COMMENT_AUTHOR = get_comment_author( $cp_ID );
|
234 |
+
$comment_template = str_replace( "%COMMENT_AUTHOR%", $COMMENT_AUTHOR, $comment_template );
|
235 |
+
}
|
236 |
+
if ( strpos( $comment_template, '%COMMENT_COUNT%' ) !== false ) {
|
237 |
+
$COMMENT_COUNT = wp_ulike_get_comment_likes( $cp_ID );
|
238 |
+
$comment_template = str_replace( "%COMMENT_COUNT%", $COMMENT_COUNT, $comment_template );
|
239 |
+
}
|
240 |
+
bp_activity_add( array(
|
241 |
+
'user_id' => $user_ID,
|
242 |
+
'action' => $comment_template,
|
243 |
+
'component' => 'activity',
|
244 |
+
'type' => 'wp_like_group',
|
245 |
+
'item_id' => $cp_ID
|
246 |
+
));
|
247 |
+
break;
|
248 |
+
|
249 |
+
default:
|
250 |
+
break;
|
251 |
}
|
252 |
|
253 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
+
//Sends out notifications when you get a like from someone
|
256 |
+
if ( isset( $options['enable_add_notification'] ) && wp_ulike_is_true( $options['enable_add_notification'] ) ) {
|
257 |
+
// No notifications from Anonymous
|
258 |
+
if ( ! $user_ID || false === get_userdata( $user_ID ) ) {
|
259 |
+
return false;
|
260 |
+
}
|
261 |
+
$author_ID = wp_ulike_get_auhtor_id( $cp_ID, $type );
|
262 |
+
if ( ! $author_ID || $author_ID == $user_ID ) {
|
263 |
+
return false;
|
264 |
+
}
|
265 |
+
bp_notifications_add_notification( array(
|
266 |
+
'user_id' => $author_ID,
|
267 |
+
'item_id' => $cp_ID,
|
268 |
+
'secondary_item_id' => $user_ID,
|
269 |
+
'component_name' => 'wp_ulike',
|
270 |
+
'component_action' => 'wp_ulike' . $type . '_action',
|
271 |
+
'date_notified' => bp_core_current_time(),
|
272 |
+
'is_new' => 1,
|
273 |
+
)
|
274 |
+
);
|
275 |
}
|
276 |
+
|
277 |
}
|
278 |
+
add_action( 'wp_ulike_after_process', 'wp_ulike_add_bp_notifications', 10, 5 );
|
279 |
+
}
|
280 |
|
281 |
+
if( ! function_exists( 'wp_ulike_format_buddypress_notifications' ) ){
|
282 |
+
/**
|
283 |
+
* Format notifications related to activity.
|
284 |
+
*
|
285 |
+
* @param string $content Component action. Deprecated. Do not do checks against this! Use
|
286 |
+
* the 6th parameter instead - $component_action_name.
|
287 |
+
* @param int $item_id Notification item ID.
|
288 |
+
* @param int $secondary_item_id Notification secondary item ID.
|
289 |
+
* @param int $total_items Number of notifications with the same action.
|
290 |
+
* @param string $format Format of return. Either 'string' or 'object'.
|
291 |
+
* @param string $action Canonical notification action.
|
292 |
+
* @param string $component Notification component ID.
|
293 |
+
* @param int $id Notification ID.
|
294 |
+
* @return string $return Formatted notification.
|
295 |
+
*/
|
296 |
+
function wp_ulike_format_buddypress_notifications( $content, $item_id, $secondary_item_id, $total_items, $format = 'string', $action, $component, $id ) {
|
297 |
+
global $wp_filter,$wp_version;
|
298 |
+
|
299 |
+
if ( strpos( $action, 'wp_ulike_' ) !== false ) {
|
300 |
+
//Extracting ulike type from the action value.
|
301 |
+
preg_match('/wp_ulike_(.*?)_action/', $action, $type);
|
302 |
+
//Extracting user id from old action name values.
|
303 |
+
preg_match('/action_([0-9]+)/', $action, $user_ID);
|
304 |
+
//Get user info
|
305 |
+
$user_ID = isset( $user_ID[1] ) ? $user_ID[1] : $secondary_item_id;
|
306 |
+
$action_type = __( 'posts' , WP_ULIKE_SLUG );
|
307 |
+
$custom_link = '';
|
308 |
+
|
309 |
+
// Check the the ulike types
|
310 |
+
switch ( $type[1] ) {
|
311 |
+
case 'commentliked':
|
312 |
+
$custom_link = get_comment_link( $item_id );
|
313 |
+
$action_type = __( 'comments' , WP_ULIKE_SLUG );
|
314 |
+
break;
|
315 |
+
|
316 |
+
case 'activityliked':
|
317 |
+
$custom_link = bp_activity_get_permalink( $item_id );
|
318 |
+
$action_type = __( 'activities' , WP_ULIKE_SLUG );
|
319 |
+
break;
|
320 |
+
|
321 |
+
default:
|
322 |
+
$custom_link = get_permalink( $item_id );
|
323 |
+
break;
|
324 |
+
}
|
325 |
|
326 |
+
// Setup the output strings
|
327 |
+
if ( (int) $total_items > 1 ) {
|
328 |
+
$custom_text = sprintf( __( 'You have %d new %s likes', WP_ULIKE_SLUG ), (int) $total_items, $action_type );
|
329 |
+
$custom_link = add_query_arg( 'type', $action, bp_get_notifications_permalink() );
|
330 |
+
} else {
|
331 |
+
$user_fullname = bp_core_get_user_displayname( $user_ID );
|
332 |
+
$custom_text = sprintf( __( '%s liked one of your %s', WP_ULIKE_SLUG ), $user_fullname, $action_type );
|
333 |
+
$custom_link = add_query_arg( 'read_ulike_notification', (int) $id, $custom_link );
|
334 |
+
}
|
335 |
|
336 |
+
// WordPress Toolbar
|
337 |
+
if ( 'string' === $format ) {
|
338 |
+
$content = apply_filters( 'wp_ulike_bp_notifications_template', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_text ) . '">' . esc_html( $custom_text ) . '</a>', $custom_link, (int) $total_items, $item_id, $user_ID );
|
339 |
+
// Deprecated BuddyBar
|
340 |
+
} else {
|
341 |
+
$content = apply_filters( 'wp_ulike_bp_notifications_template', array(
|
342 |
+
'text' => $custom_text,
|
343 |
+
'link' => $custom_link
|
344 |
+
), $custom_link, (int) $total_items, $item_id, $user_ID );
|
345 |
+
}
|
346 |
|
347 |
+
if ( function_exists('bbp_get_version') && version_compare( bbp_get_version(), '2.6.0' , '<') ) {
|
348 |
+
// global wp_filter to call bbPress wrapper function
|
349 |
+
if( isset( $wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications'] ) ) {
|
350 |
+
if( version_compare( $wp_version, '4.7', '>=' ) ) {
|
351 |
+
$wp_filter['bp_notifications_get_notifications_for_user']->callbacks[10]['bbp_format_buddypress_notifications']['function'] = 'wp_ulike_bbp_format_buddypress_notifications';
|
352 |
+
} else {
|
353 |
+
$wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications']['function'] = 'wp_ulike_bbp_format_buddypress_notifications';
|
|
|
354 |
}
|
355 |
}
|
|
|
|
|
356 |
}
|
357 |
|
358 |
return $content;
|
359 |
}
|
|
|
|
|
360 |
|
361 |
+
return $content;
|
362 |
+
}
|
363 |
+
add_filter( 'bp_notifications_get_notifications_for_user', 'wp_ulike_format_buddypress_notifications', 25, 8 );
|
364 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
+
if( ! function_exists( 'wp_ulike_notification_filters' ) ){
|
367 |
+
/**
|
368 |
+
* Add ulike notifications to initial buddyPress filters
|
369 |
+
*
|
370 |
+
* @return void
|
371 |
+
*/
|
372 |
+
function wp_ulike_notification_filters(){
|
373 |
+
$notifications = array(
|
374 |
+
array(
|
375 |
+
'id' => 'wp_ulike_activityliked_action',
|
376 |
+
'label' => __( 'New activity liked', WP_ULIKE_SLUG ),
|
377 |
+
'position' => 340,
|
378 |
+
),
|
379 |
+
array(
|
380 |
+
'id' => 'wp_ulike_commentliked_action',
|
381 |
+
'label' => __( 'New comment liked', WP_ULIKE_SLUG ),
|
382 |
+
'position' => 345,
|
383 |
+
),
|
384 |
+
array(
|
385 |
+
'id' => 'wp_ulike_liked_action',
|
386 |
+
'label' => __( 'New post liked', WP_ULIKE_SLUG ),
|
387 |
+
'position' => 355,
|
388 |
+
),
|
389 |
+
array(
|
390 |
+
'id' => 'wp_ulike_topicliked_action',
|
391 |
+
'label' => __( 'New topic liked', WP_ULIKE_SLUG ),
|
392 |
+
'position' => 365,
|
393 |
+
)
|
394 |
+
);
|
395 |
+
|
396 |
+
foreach ( $notifications as $notification ) {
|
397 |
+
if( ! wp_ulike_bbp_is_component_exist( $notification['id'] ) ){
|
398 |
+
continue;
|
399 |
}
|
400 |
+
bp_nouveau_notifications_register_filter( $notification );
|
401 |
}
|
|
|
402 |
}
|
403 |
+
add_action( 'bp_nouveau_notifications_init_filters', 'wp_ulike_notification_filters' );
|
404 |
+
}
|
405 |
|
406 |
+
if( ! function_exists( 'wp_ulike_seen_bp_notifications' ) ){
|
407 |
+
/**
|
408 |
+
* Mark notifications as read when a user visits an activity permalink.
|
409 |
+
*
|
410 |
+
* @since 3.6.0
|
411 |
+
*/
|
412 |
+
function wp_ulike_seen_bp_notifications() {
|
413 |
+
if ( ! is_user_logged_in() ) {
|
414 |
+
return;
|
415 |
+
}
|
416 |
|
417 |
+
$comment_id = 0;
|
418 |
+
// For replies to a parent update.
|
419 |
+
if ( isset( $_GET['read_ulike_notification'] ) && ! empty( $_GET['read_ulike_notification'] ) ) {
|
420 |
+
$comment_id = (int) $_GET['read_ulike_notification'];
|
421 |
+
}
|
422 |
|
423 |
+
// Mark individual activity reply notification as read.
|
424 |
+
if ( $comment_id ) {
|
425 |
+
BP_Notifications_Notification::update(
|
426 |
+
array(
|
427 |
+
'is_new' => false
|
428 |
+
),
|
429 |
+
array(
|
430 |
+
'user_id' => bp_loggedin_user_id(),
|
431 |
+
'id' => $comment_id
|
432 |
+
)
|
433 |
+
);
|
|
|
434 |
}
|
|
|
435 |
}
|
436 |
+
add_action( 'wp_loaded', 'wp_ulike_seen_bp_notifications' );
|
437 |
}
|
438 |
|
439 |
/*******************************************************
|
440 |
bbPress
|
441 |
*******************************************************/
|
442 |
|
443 |
+
if( ! function_exists( 'wp_ulike_put_bbpress' ) ){
|
444 |
/**
|
445 |
* Auto insert wp_ulike_bbpress in the topics content
|
446 |
*
|
489 |
*******************************************************/
|
490 |
|
491 |
// Litespeed cache plugin
|
492 |
+
if( ! function_exists( 'wp_ulike_purge_litespeed_cache' ) ){
|
493 |
/**
|
494 |
* Purge litespeed post cache
|
495 |
*
|
498 |
* @return void
|
499 |
*/
|
500 |
function wp_ulike_purge_litespeed_cache( $ID, $type ){
|
501 |
+
// Check functionality existence
|
502 |
+
if( ! class_exists('LiteSpeed\Core') ){
|
503 |
+
return;
|
504 |
+
}
|
505 |
+
|
506 |
if( $type === '_liked' ){
|
507 |
if( get_post_type( $ID ) ){
|
508 |
do_action( 'litespeed_purge_post', $ID );
|
521 |
}
|
522 |
|
523 |
// w3 total cache plugin
|
524 |
+
if( ! function_exists( 'wp_ulike_purge_w3_total_cache' ) ){
|
525 |
/**
|
526 |
* Purge w3 total post cache
|
527 |
*
|
530 |
* @return void
|
531 |
*/
|
532 |
function wp_ulike_purge_w3_total_cache( $ID, $type ){
|
533 |
+
// Check functionality existence
|
534 |
+
if( ! function_exists( 'w3tc_flush_post' ) ){
|
535 |
+
return;
|
536 |
+
}
|
537 |
+
|
538 |
if( $type === '_liked' ){
|
539 |
if( get_post_type( $ID ) ){
|
540 |
w3tc_flush_post( $ID );
|
553 |
}
|
554 |
|
555 |
// wp fastest cache plugin
|
556 |
+
if( ! function_exists( 'wp_ulike_purge_wp_fastest_cache' ) ){
|
557 |
/**
|
558 |
* Purge wp fastest cache
|
559 |
*
|
562 |
* @return void
|
563 |
*/
|
564 |
function wp_ulike_purge_wp_fastest_cache( $ID, $type ){
|
565 |
+
// Check functionality existence
|
566 |
+
if( ! isset( $GLOBALS["wp_fastest_cache"] ) || ! class_exists( 'WpFastestCache' ) ){
|
567 |
return;
|
568 |
}
|
569 |
+
|
570 |
$cache_interface = $GLOBALS["wp_fastest_cache"];
|
571 |
|
572 |
// to remove cache if vote is from homepage or category page or tag
|
615 |
}
|
616 |
|
617 |
// wp super cache plugin
|
618 |
+
if( ! function_exists( 'wp_ulike_purge_wp_super_cache' ) ){
|
619 |
/**
|
620 |
* Purge super post cache
|
621 |
*
|
624 |
* @return void
|
625 |
*/
|
626 |
function wp_ulike_purge_wp_super_cache( $ID, $type ){
|
627 |
+
// Check functionality existence
|
628 |
+
if( ! function_exists( 'wpsc_delete_post_cache' ) ){
|
629 |
+
return;
|
630 |
+
}
|
631 |
+
|
632 |
if( $type === '_liked' ){
|
633 |
if( get_post_type( $ID ) ){
|
634 |
wpsc_delete_post_cache( $ID );
|
647 |
}
|
648 |
|
649 |
// wp rocket cache plugin
|
650 |
+
if( ! function_exists( 'wp_ulike_purge_rocket_cache' ) ){
|
651 |
/**
|
652 |
* Purge wp rocket cache
|
653 |
*
|
656 |
* @return void
|
657 |
*/
|
658 |
function wp_ulike_purge_rocket_cache( $ID, $type ){
|
659 |
+
// Check functionality existence
|
660 |
+
if( ! function_exists( 'rocket_clean_post' ) ){
|
661 |
+
return;
|
662 |
+
}
|
663 |
+
|
664 |
if( $type === '_liked' ){
|
665 |
// Check post type ID
|
666 |
if( get_post_type( $ID ) ){
|
680 |
}
|
681 |
|
682 |
// wp optimize cache plugin
|
683 |
+
if( ! function_exists( 'wp_ulike_purge_wp_optimize_cache' ) ){
|
684 |
/**
|
685 |
* Purge wp optimize cache
|
686 |
*
|
689 |
* @return void
|
690 |
*/
|
691 |
function wp_ulike_purge_wp_optimize_cache( $ID, $type ){
|
692 |
+
// Check functionality existence
|
693 |
+
if( ! class_exists('WPO_Page_Cache') ){
|
694 |
+
return;
|
695 |
+
}
|
696 |
+
|
697 |
if( $type === '_liked' ){
|
698 |
if( get_post_type( $ID ) ){
|
699 |
WPO_Page_Cache::delete_single_post_cache( $ID );
|
716 |
*******************************************************/
|
717 |
|
718 |
// My Cred Plugin
|
719 |
+
if( ! function_exists( 'wp_ulike_register_myCRED_hook' ) ){
|
720 |
+
/**
|
721 |
+
* register wp_ulike in mycred setup
|
722 |
+
*
|
723 |
+
* @since 2.3
|
724 |
+
* @param array $installed
|
725 |
+
* @return void
|
726 |
+
*/
|
727 |
+
function wp_ulike_register_myCRED_hook( $installed ) {
|
728 |
+
$installed['wp_ulike'] = array(
|
729 |
+
'title' => WP_ULIKE_NAME,
|
730 |
+
'description' => __( 'This hook award / deducts points from users who Like/Unlike any content of WordPress, bbPress, BuddyPress & ...', WP_ULIKE_SLUG ),
|
731 |
+
'callback' => array( 'wp_ulike_myCRED' )
|
732 |
+
);
|
733 |
+
return $installed;
|
|
|
|
|
|
|
734 |
}
|
735 |
+
add_filter( 'mycred_setup_hooks', 'wp_ulike_register_myCRED_hook' );
|
736 |
+
}
|
737 |
+
if( ! function_exists( 'wp_ulike_myCRED_references' ) ){
|
738 |
+
/**
|
739 |
+
* Add ulike references
|
740 |
+
*
|
741 |
+
* @since 2.3
|
742 |
+
* @param array $list
|
743 |
+
* @return void
|
744 |
+
*/
|
745 |
+
function wp_ulike_myCRED_references( $list ) {
|
746 |
+
$list['wp_add_like'] = __( 'Liking Content', WP_ULIKE_SLUG );
|
747 |
+
$list['wp_get_like'] = __( 'Liked Content', WP_ULIKE_SLUG );
|
748 |
+
$list['wp_add_unlike'] = __( 'Unliking Content', WP_ULIKE_SLUG );
|
749 |
+
$list['wp_get_unlike'] = __( 'Unliked Content', WP_ULIKE_SLUG );
|
750 |
+
return $list;
|
751 |
}
|
752 |
+
add_filter( 'mycred_all_references', 'wp_ulike_myCRED_references' );
|
753 |
}
|
754 |
|
755 |
// Ultimate Member plugin
|
756 |
+
if( ! function_exists( 'wp_ulike_add_custom_profile_tab' ) ){
|
757 |
+
/**
|
758 |
+
* Add custom tabs in the UltimateMember profiles.
|
759 |
+
*
|
760 |
+
* @since 2.3
|
761 |
+
* @param array $tabs
|
762 |
+
* @return array $tabs
|
763 |
+
*/
|
764 |
+
function wp_ulike_add_custom_profile_tab( $tabs ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
765 |
|
766 |
+
$tabs['wp-ulike-posts'] = array(
|
767 |
+
'name' => __('Recent Posts Liked',WP_ULIKE_SLUG),
|
768 |
+
'icon' => 'um-faicon-thumbs-up',
|
769 |
+
);
|
|
|
770 |
|
771 |
+
$tabs['wp-ulike-comments'] = array(
|
772 |
+
'name' => __('Recent Comments Liked',WP_ULIKE_SLUG),
|
773 |
+
'icon' => 'um-faicon-thumbs-o-up',
|
774 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
775 |
|
776 |
+
return $tabs;
|
|
|
777 |
}
|
778 |
+
add_filter('um_profile_tabs', 'wp_ulike_add_custom_profile_tab', 1000 );
|
779 |
+
}
|
780 |
|
781 |
+
if( ! function_exists( 'wp_ulike_posts_um_profile_content' ) ){
|
782 |
+
/**
|
783 |
+
* Add content to the wp-ulike-posts tab
|
784 |
+
*
|
785 |
+
* @since 2.3
|
786 |
+
* @param array $args
|
787 |
+
* @return void
|
788 |
+
*/
|
789 |
+
function wp_ulike_posts_um_profile_content() {
|
790 |
+
//Main data
|
791 |
+
$args = array(
|
792 |
+
"type" => 'post',
|
793 |
+
"rel_type" => 'post',
|
794 |
+
"status" => 'like',
|
795 |
+
"user_id" => um_profile_id(),
|
796 |
+
"is_popular" => false,
|
797 |
+
"limit" => 10
|
798 |
+
);
|
799 |
+
|
800 |
+
$get_items = wp_ulike_get_popular_items_ids( $args );
|
801 |
+
|
802 |
+
$query_args = array(
|
803 |
+
'post__in' => $get_items,
|
804 |
+
'orderby' => 'post__in',
|
805 |
+
'posts_per_page' => $args['limit']
|
806 |
+
);
|
807 |
+
|
808 |
+
$query = new WP_Query( $query_args );
|
809 |
+
|
810 |
+
if( $query->have_posts() ):
|
811 |
+
while( $query->have_posts() ): $query->the_post();
|
812 |
+
echo '<div class="um-item">';
|
813 |
+
echo '<div class="um-item-link">
|
814 |
+
<i class="um-icon-ios-paper"></i>
|
815 |
+
<a href="'.get_permalink().'">'.get_the_title().'</a>
|
816 |
+
</div>';
|
817 |
+
echo '<div class="um-item-meta">
|
818 |
+
<span>'.get_the_date().'</span>
|
819 |
+
<span class="badge"><i class="um-faicon-thumbs-o-up"></i> '.wp_ulike_get_post_likes( get_the_ID() ).'</span>
|
820 |
+
</div>';
|
821 |
+
echo '</div>';
|
822 |
+
endwhile;
|
823 |
+
else:
|
824 |
+
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>';
|
825 |
+
endif;
|
826 |
+
wp_reset_postdata();
|
827 |
|
828 |
+
}
|
829 |
+
add_action('um_profile_content_wp-ulike-posts_default', 'wp_ulike_posts_um_profile_content');
|
830 |
+
}
|
|
|
|
|
831 |
|
832 |
+
if( ! function_exists( 'wp_ulike_comments_um_profile_content' ) ){
|
833 |
+
/**
|
834 |
+
* Add content to the wp-ulike-comments tab
|
835 |
+
*
|
836 |
+
* @since 2.3
|
837 |
+
* @param array $args
|
838 |
+
* @return void
|
839 |
+
*/
|
840 |
+
function wp_ulike_comments_um_profile_content() {
|
841 |
+
//Main data
|
842 |
+
$args = array(
|
843 |
+
"type" => 'comment',
|
844 |
+
"rel_type" => '',
|
845 |
+
"status" => 'like',
|
846 |
+
"user_id" => um_profile_id(),
|
847 |
+
"is_popular" => false,
|
848 |
+
"limit" => 10
|
849 |
+
);
|
850 |
+
|
851 |
+
$get_items = wp_ulike_get_popular_items_ids( $args );
|
852 |
+
|
853 |
+
$query_args = array(
|
854 |
+
'comment__in' => $get_items,
|
855 |
+
'orderby' => 'comment__in',
|
856 |
+
'posts_per_page' => $args['limit']
|
857 |
+
);
|
858 |
+
|
859 |
+
// The Query
|
860 |
+
$comments_query = new WP_Comment_Query;
|
861 |
+
$comments = $comments_query->query( $query_args );
|
862 |
+
|
863 |
+
// Comment Loop
|
864 |
+
if ( $comments ) {
|
865 |
+
foreach ( $comments as $comment ) {
|
866 |
+
echo '<div class="um-item">';
|
867 |
+
echo '<div class="um-item-link">
|
868 |
+
<i class="um-icon-ios-chatboxes"></i>
|
869 |
+
<a href="'.get_comment_link($comment->comment_ID).'">'.$comment->comment_content .'</a>
|
870 |
+
<em style="font-size:.7em;padding:0 10px;"><span class="um-faicon-quote-left"></span> '.$comment->comment_author.' <span class="um-faicon-quote-right"></span></em>
|
871 |
+
</div>';
|
872 |
+
echo '<div class="um-item-meta">
|
873 |
+
<span>'.get_comment_date( '', $comment->comment_ID ).'</span>
|
874 |
+
<span class="badge"><i class="um-faicon-thumbs-o-up"></i> '.wp_ulike_get_comment_likes( $comment->comment_ID ).'</span>
|
875 |
+
</div>';
|
876 |
+
echo '</div>';
|
877 |
+
}
|
878 |
+
} else {
|
879 |
+
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>';
|
880 |
}
|
|
|
881 |
}
|
882 |
+
add_action('um_profile_content_wp-ulike-comments_default', 'wp_ulike_comments_um_profile_content');
|
883 |
}
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ Tags: like, marketing, elementor, favorite, statistics, multisite, rating, votin
|
|
6 |
Requires PHP: 5.6
|
7 |
Requires at least: 5.0
|
8 |
Tested up to: 5.4.2
|
9 |
-
Stable tag: 4.3.
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
@@ -152,6 +152,9 @@ define( 'WP_MEMORY_LIMIT', '256M' );
|
|
152 |
|
153 |
== Changelog ==
|
154 |
|
|
|
|
|
|
|
155 |
= 4.3.0 =
|
156 |
* Added: New php classification for front-end processes.
|
157 |
* Added: Comment meta box options. [PRO]
|
6 |
Requires PHP: 5.6
|
7 |
Requires at least: 5.0
|
8 |
Tested up to: 5.4.2
|
9 |
+
Stable tag: 4.3.1
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
152 |
|
153 |
== Changelog ==
|
154 |
|
155 |
+
= 4.3.1 =
|
156 |
+
* Fixed: Third-party plugin issues.
|
157 |
+
|
158 |
= 4.3.0 =
|
159 |
* Added: New php classification for front-end processes.
|
160 |
* Added: Comment meta box options. [PRO]
|
wp-ulike.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
* Plugin Name: WP ULike
|
11 |
* Plugin URI: https://wpulike.com/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash
|
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: 4.3.
|
14 |
* Author: Ali Mirzaei
|
15 |
* Author URI: https://wpulike.com/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash
|
16 |
* Text Domain: wp-ulike
|
@@ -46,7 +46,7 @@ if ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) {
|
|
46 |
|
47 |
// Do not change these values
|
48 |
define( 'WP_ULIKE_PLUGIN_URI' , 'https://wpulike.com/' );
|
49 |
-
define( 'WP_ULIKE_VERSION' , '4.3.
|
50 |
define( 'WP_ULIKE_DB_VERSION' , '2.1' );
|
51 |
define( 'WP_ULIKE_SLUG' , 'wp-ulike' );
|
52 |
define( 'WP_ULIKE_NAME' , __( 'WP ULike', WP_ULIKE_SLUG ));
|
10 |
* Plugin Name: WP ULike
|
11 |
* Plugin URI: https://wpulike.com/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash
|
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: 4.3.1
|
14 |
* Author: Ali Mirzaei
|
15 |
* Author URI: https://wpulike.com/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash
|
16 |
* Text Domain: wp-ulike
|
46 |
|
47 |
// Do not change these values
|
48 |
define( 'WP_ULIKE_PLUGIN_URI' , 'https://wpulike.com/' );
|
49 |
+
define( 'WP_ULIKE_VERSION' , '4.3.1' );
|
50 |
define( 'WP_ULIKE_DB_VERSION' , '2.1' );
|
51 |
define( 'WP_ULIKE_SLUG' , 'wp-ulike' );
|
52 |
define( 'WP_ULIKE_NAME' , __( 'WP ULike', WP_ULIKE_SLUG ));
|