BuddyPress - Version 2.2.6

Version Description

See: https://codex.buddypress.org/releases/version-2-2-6/

Download this release

Release Info

Developer netweb
Plugin Icon 128x128 BuddyPress
Version 2.2.6
Comparing to
See all releases

Code changes from version 2.3.7 to 2.2.6

Files changed (73) hide show
  1. bp-activity/admin/css/admin-rtl.css +0 -7
  2. bp-activity/admin/css/admin-rtl.min.css +1 -1
  3. bp-activity/admin/css/admin.css +0 -7
  4. bp-activity/admin/css/admin.min.css +1 -1
  5. bp-activity/admin/js/admin.min.js +1 -1
  6. bp-activity/bp-activity-actions.php +36 -41
  7. bp-activity/bp-activity-admin.php +37 -98
  8. bp-activity/bp-activity-akismet.php +64 -74
  9. bp-activity/bp-activity-cache.php +6 -6
  10. bp-activity/bp-activity-classes.php +2379 -3
  11. bp-activity/bp-activity-cssjs.php +2 -24
  12. bp-activity/bp-activity-filters.php +23 -50
  13. bp-activity/bp-activity-functions.php +217 -417
  14. bp-activity/bp-activity-loader.php +29 -32
  15. bp-activity/bp-activity-notifications.php +63 -69
  16. bp-activity/bp-activity-screens.php +13 -14
  17. bp-activity/bp-activity-template.php +341 -507
  18. bp-activity/classes/class-bp-activity-activity.php +0 -1800
  19. bp-activity/classes/class-bp-activity-feed.php +0 -446
  20. bp-activity/classes/class-bp-activity-query.php +0 -258
  21. bp-activity/js/mentions.js +29 -23
  22. bp-activity/js/mentions.min.js +2 -2
  23. bp-blogs/bp-blogs-activity.php +12 -6
  24. bp-blogs/bp-blogs-classes.php +564 -1
  25. bp-blogs/bp-blogs-filters.php +4 -6
  26. bp-blogs/bp-blogs-functions.php +22 -44
  27. bp-blogs/bp-blogs-loader.php +5 -25
  28. bp-blogs/bp-blogs-template.php +27 -45
  29. bp-blogs/bp-blogs-widgets.php +29 -45
  30. bp-blogs/classes/class-bp-blogs-blog.php +0 -608
  31. bp-core/admin/{bp-core-admin-actions.php → bp-core-actions.php} +29 -92
  32. bp-core/admin/{bp-core-admin-components.php → bp-core-components.php} +9 -29
  33. bp-core/admin/{bp-core-admin-functions.php → bp-core-functions.php} +28 -49
  34. bp-core/admin/{bp-core-admin-schema.php → bp-core-schema.php} +6 -19
  35. bp-core/admin/{bp-core-admin-settings.php → bp-core-settings.php} +25 -52
  36. bp-core/admin/{bp-core-admin-slugs.php → bp-core-slugs.php} +6 -36
  37. bp-core/admin/{bp-core-admin-tools.php → bp-core-tools.php} +5 -23
  38. bp-core/admin/css/common-rtl.css +0 -53
  39. bp-core/admin/css/common-rtl.min.css +1 -1
  40. bp-core/admin/css/common.css +0 -53
  41. bp-core/admin/css/common.min.css +1 -1
  42. bp-core/admin/images/avatar-ui.gif +0 -0
  43. bp-core/admin/images/member-types.png +0 -0
  44. bp-core/bp-core-actions.php +0 -1
  45. bp-core/bp-core-admin.php +125 -124
  46. bp-core/bp-core-attachments.php +0 -406
  47. bp-core/bp-core-avatars.php +204 -843
  48. bp-core/bp-core-buddybar.php +25 -43
  49. bp-core/bp-core-cache.php +0 -6
  50. bp-core/bp-core-caps.php +2 -64
  51. bp-core/bp-core-catchuri.php +30 -155
  52. bp-core/bp-core-classes.php +2965 -14
  53. bp-core/bp-core-component.php +47 -224
  54. bp-core/bp-core-cssjs.php +16 -91
  55. bp-core/bp-core-dependency.php +10 -266
  56. bp-core/bp-core-filters.php +8 -226
  57. bp-core/bp-core-functions.php +15 -423
  58. bp-core/bp-core-loader.php +9 -65
  59. bp-core/bp-core-moderation.php +2 -43
  60. bp-core/bp-core-options.php +6 -215
  61. bp-core/bp-core-taxonomy.php +0 -28
  62. bp-core/bp-core-template-loader.php +4 -90
  63. bp-core/bp-core-template.php +51 -552
  64. bp-core/bp-core-theme-compatibility.php +8 -78
  65. bp-core/bp-core-update.php +8 -90
  66. bp-core/bp-core-widgets.php +6 -45
  67. bp-core/classes/class-bp-attachment-avatar.php +0 -427
  68. bp-core/classes/class-bp-attachment.php +0 -518
  69. bp-core/classes/class-bp-button.php +0 -270
  70. bp-core/classes/class-bp-core-notification.php +0 -258
  71. bp-core/classes/class-bp-core-user.php +0 -958
  72. bp-core/classes/class-bp-date-query.php +0 -65
  73. bp-core/classes/class-bp-embed.php +0 -198
bp-activity/admin/css/admin-rtl.css CHANGED
@@ -44,7 +44,6 @@
44
  }
45
  #bp-activities-form .column-response img {
46
  float: right;
47
- margin-bottom: 5px;
48
  margin-left: 10px;
49
  margin-top: 1px;
50
  }
@@ -79,9 +78,3 @@
79
  .column-action {
80
  width: 12%;
81
  }
82
-
83
- @media screen and (max-width: 782px) {
84
- body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {
85
- display: table-cell;
86
- }
87
- }
44
  }
45
  #bp-activities-form .column-response img {
46
  float: right;
 
47
  margin-left: 10px;
48
  margin-top: 1px;
49
  }
78
  .column-action {
79
  width: 12%;
80
  }
 
 
 
 
 
 
bp-activity/admin/css/admin-rtl.min.css CHANGED
@@ -1 +1 @@
1
- .akismet-status{float:left}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:left;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:right;margin-bottom:5px;margin-left:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-right:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}@media screen and (max-width:782px){body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column){display:table-cell}}
1
+ .akismet-status{float:left}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:left;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:right;margin-left:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-right:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}
bp-activity/admin/css/admin.css CHANGED
@@ -44,7 +44,6 @@
44
  }
45
  #bp-activities-form .column-response img {
46
  float: left;
47
- margin-bottom: 5px;
48
  margin-right: 10px;
49
  margin-top: 1px;
50
  }
@@ -79,9 +78,3 @@
79
  .column-action {
80
  width: 12%;
81
  }
82
-
83
- @media screen and (max-width: 782px) {
84
- body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {
85
- display: table-cell;
86
- }
87
- }
44
  }
45
  #bp-activities-form .column-response img {
46
  float: left;
 
47
  margin-right: 10px;
48
  margin-top: 1px;
49
  }
78
  .column-action {
79
  width: 12%;
80
  }
 
 
 
 
 
 
bp-activity/admin/css/admin.min.css CHANGED
@@ -1 +1 @@
1
- .akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-bottom:5px;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}@media screen and (max-width:782px){body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column){display:table-cell}}
1
+ .akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}
bp-activity/admin/js/admin.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.3.5 - 2015-11-11 5:23:00 AM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
1
+ /*! buddypress - v2.2.4 - 2015-11-11 5:04:26 AM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
bp-activity/bp-activity-actions.php CHANGED
@@ -33,8 +33,9 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
33
  /**
34
  * Catch and route requests for single activity item permalinks.
35
  *
36
- * @since BuddyPress (1.2.0)
37
  *
 
38
  * @uses bp_is_activity_component()
39
  * @uses bp_is_current_action()
40
  * @uses bp_action_variable()
@@ -120,7 +121,7 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
120
  /**
121
  * Delete specific activity item and redirect to previous page.
122
  *
123
- * @since BuddyPress (1.1.0)
124
  *
125
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
126
  *
@@ -166,7 +167,7 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
166
  * @since BuddyPress (1.5.0)
167
  *
168
  * @param int $activity_id The activity ID.
169
- * @param int $user_id The user associated with the activity.
170
  */
171
  do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
172
 
@@ -182,7 +183,7 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
182
  * @since BuddyPress (1.1.0)
183
  *
184
  * @param int $activity_id The activity ID.
185
- * @param int $user_id The user associated with the activity.
186
  */
187
  do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
188
 
@@ -197,14 +198,14 @@ add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
197
  /**
198
  * Mark specific activity item as spam and redirect to previous page.
199
  *
200
- * @since BuddyPress (1.6.0)
201
  *
 
202
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
203
- *
204
  * @return bool False on failure.
205
  */
206
  function bp_activity_action_spam_activity( $activity_id = 0 ) {
207
- $bp = buddypress();
208
 
209
  // Not viewing activity, or action is not spam, or Akismet isn't present
210
  if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
@@ -235,7 +236,7 @@ function bp_activity_action_spam_activity( $activity_id = 0 ) {
235
  * @since BuddyPress (1.6.0)
236
  *
237
  * @param int $activity_id Activity ID to be marked as spam.
238
- * @param object $activity Activity object for the ID to be marked as spam.
239
  */
240
  do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
241
 
@@ -252,7 +253,7 @@ function bp_activity_action_spam_activity( $activity_id = 0 ) {
252
  * @since BuddyPress (1.6.0)
253
  *
254
  * @param int $activity_id Activity ID that was marked as spam.
255
- * @param int $user_id User ID associated with activity.
256
  */
257
  do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
258
 
@@ -267,7 +268,7 @@ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
267
  /**
268
  * Post user/group activity update.
269
  *
270
- * @since BuddyPress (1.2.0)
271
  *
272
  * @uses is_user_logged_in()
273
  * @uses bp_is_activity_component()
@@ -299,7 +300,7 @@ function bp_activity_action_post_update() {
299
  *
300
  * @since BuddyPress (1.2.0)
301
  *
302
- * @param string $value Activity message being posted.
303
  */
304
  $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
305
 
@@ -310,7 +311,7 @@ function bp_activity_action_post_update() {
310
  *
311
  * @since BuddyPress (1.2.0)
312
  *
313
- * @param string $value Item type to associate with.
314
  */
315
  $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
316
  }
@@ -322,7 +323,7 @@ function bp_activity_action_post_update() {
322
  *
323
  * @since BuddyPress (1.2.0)
324
  *
325
- * @param string $value Chosen component to post activity to.
326
  */
327
  $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
328
  }
@@ -350,7 +351,7 @@ function bp_activity_action_post_update() {
350
  *
351
  * @since BuddyPress (1.2.0)
352
  *
353
- * @param string $object Activity item being associated to.
354
  * @param string $item_id Component ID being posted to.
355
  * @param string $content Activity content being posted.
356
  */
@@ -371,7 +372,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
371
  /**
372
  * Post new activity comment.
373
  *
374
- * @since BuddyPress (1.2.0)
375
  *
376
  * @uses is_user_logged_in()
377
  * @uses bp_is_activity_component()
@@ -399,7 +400,7 @@ function bp_activity_action_post_comment() {
399
  *
400
  * @since BuddyPress (1.2.0)
401
  *
402
- * @param string $value ID of the activity being replied to.
403
  */
404
  $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
405
 
@@ -408,7 +409,7 @@ function bp_activity_action_post_comment() {
408
  *
409
  * @since BuddyPress (1.2.0)
410
  *
411
- * @param string $value Comment content being posted.
412
  */
413
  $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
414
 
@@ -435,7 +436,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
435
  /**
436
  * Mark activity as favorite.
437
  *
438
- * @since BuddyPress (1.2.0)
439
  *
440
  * @uses is_user_logged_in()
441
  * @uses bp_is_activity_component()
@@ -469,7 +470,7 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
469
  /**
470
  * Remove activity from favorites.
471
  *
472
- * @since BuddyPress (1.2.0)
473
  *
474
  * @uses is_user_logged_in()
475
  * @uses bp_is_activity_component()
@@ -503,8 +504,9 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
503
  /**
504
  * Load the sitewide activity feed.
505
  *
506
- * @since BuddyPress (1.0.0)
507
  *
 
508
  * @uses bp_is_activity_component()
509
  * @uses bp_is_current_action()
510
  * @uses bp_is_user()
@@ -513,7 +515,7 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
513
  * @return bool False on failure.
514
  */
515
  function bp_activity_action_sitewide_feed() {
516
- $bp = buddypress();
517
 
518
  if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
519
  return false;
@@ -535,7 +537,7 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
535
  /**
536
  * Load a user's personal activity feed.
537
  *
538
- * @since BuddyPress (1.0.0)
539
  *
540
  * @uses bp_is_user_activity()
541
  * @uses bp_is_current_action()
@@ -565,7 +567,7 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
565
  /**
566
  * Load a user's friends' activity feed.
567
  *
568
- * @since BuddyPress (1.0.0)
569
  *
570
  * @uses bp_is_active()
571
  * @uses bp_is_user_activity()
@@ -598,7 +600,7 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
598
  /**
599
  * Load the activity feed for a user's groups.
600
  *
601
- * @since BuddyPress (1.2.0)
602
  *
603
  * @uses bp_is_active()
604
  * @uses bp_is_user_activity()
@@ -639,7 +641,7 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
639
  /**
640
  * Load a user's @mentions feed.
641
  *
642
- * @since BuddyPress (1.2.0)
643
  *
644
  * @uses bp_is_user_activity()
645
  * @uses bp_is_current_action()
@@ -676,7 +678,7 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
676
  /**
677
  * Load a user's favorites feed.
678
  *
679
- * @since BuddyPress (1.2.0)
680
  *
681
  * @uses bp_is_user_activity()
682
  * @uses bp_is_current_action()
@@ -711,37 +713,30 @@ add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
711
  /**
712
  * Loads Akismet filtering for activity.
713
  *
714
- * @since BuddyPress (1.6.0)
715
- * @since BuddyPress (2.3.0) We only support Akismet 3+.
 
716
  */
717
  function bp_activity_setup_akismet() {
718
- $bp = buddypress();
719
 
720
  // Bail if Akismet is not active
721
- if ( ! defined( 'AKISMET_VERSION' ) ) {
722
- return;
723
- }
724
-
725
- // Bail if older version of Akismet
726
- if ( ! class_exists( 'Akismet' ) ) {
727
  return;
728
- }
729
 
730
  // Bail if no Akismet key is set
731
- if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) ) {
732
  return;
733
- }
734
 
735
  /**
736
  * Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
737
  *
738
  * @since BuddyPress (1.6.0)
739
  *
740
- * @param bool $value Return value of bp_is_akismet_active boolean function.
741
  */
742
- if ( ! apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
743
  return;
744
- }
745
 
746
  // Instantiate Akismet for BuddyPress
747
  $bp->activity->akismet = new BP_Akismet();
33
  /**
34
  * Catch and route requests for single activity item permalinks.
35
  *
36
+ * @since BuddyPress (1.2)
37
  *
38
+ * @global object $bp BuddyPress global settings
39
  * @uses bp_is_activity_component()
40
  * @uses bp_is_current_action()
41
  * @uses bp_action_variable()
121
  /**
122
  * Delete specific activity item and redirect to previous page.
123
  *
124
+ * @since BuddyPress (1.1)
125
  *
126
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
127
  *
167
  * @since BuddyPress (1.5.0)
168
  *
169
  * @param int $activity_id The activity ID.
170
+ * @param int $user_id The user associated with the activity.
171
  */
172
  do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
173
 
183
  * @since BuddyPress (1.1.0)
184
  *
185
  * @param int $activity_id The activity ID.
186
+ * @param int $user_id The user associated with the activity.
187
  */
188
  do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
189
 
198
  /**
199
  * Mark specific activity item as spam and redirect to previous page.
200
  *
201
+ * @since BuddyPress (1.6)
202
  *
203
+ * @global object $bp BuddyPress global settings
204
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
 
205
  * @return bool False on failure.
206
  */
207
  function bp_activity_action_spam_activity( $activity_id = 0 ) {
208
+ global $bp;
209
 
210
  // Not viewing activity, or action is not spam, or Akismet isn't present
211
  if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
236
  * @since BuddyPress (1.6.0)
237
  *
238
  * @param int $activity_id Activity ID to be marked as spam.
239
+ * @param object $activity Activity object for the ID to be marked as spam.
240
  */
241
  do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
242
 
253
  * @since BuddyPress (1.6.0)
254
  *
255
  * @param int $activity_id Activity ID that was marked as spam.
256
+ * @param int $user_id User ID associated with activity.
257
  */
258
  do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
259
 
268
  /**
269
  * Post user/group activity update.
270
  *
271
+ * @since BuddyPress (1.2)
272
  *
273
  * @uses is_user_logged_in()
274
  * @uses bp_is_activity_component()
300
  *
301
  * @since BuddyPress (1.2.0)
302
  *
303
+ * @param string $whats-new Activity message being posted.
304
  */
305
  $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
306
 
311
  *
312
  * @since BuddyPress (1.2.0)
313
  *
314
+ * @param string $whats-new-post-object Item type to associate with.
315
  */
316
  $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
317
  }
323
  *
324
  * @since BuddyPress (1.2.0)
325
  *
326
+ * @param string $whats-new-post-in Chosen component to post activity to.
327
  */
328
  $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
329
  }
351
  *
352
  * @since BuddyPress (1.2.0)
353
  *
354
+ * @param string $object Activity item being associated to.
355
  * @param string $item_id Component ID being posted to.
356
  * @param string $content Activity content being posted.
357
  */
372
  /**
373
  * Post new activity comment.
374
  *
375
+ * @since BuddyPress (1.2)
376
  *
377
  * @uses is_user_logged_in()
378
  * @uses bp_is_activity_component()
400
  *
401
  * @since BuddyPress (1.2.0)
402
  *
403
+ * @param string $comment_form_id ID of the activity being replied to.
404
  */
405
  $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
406
 
409
  *
410
  * @since BuddyPress (1.2.0)
411
  *
412
+ * @param string $ac_input_activity_id Comment content being posted.
413
  */
414
  $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
415
 
436
  /**
437
  * Mark activity as favorite.
438
  *
439
+ * @since BuddyPress (1.2)
440
  *
441
  * @uses is_user_logged_in()
442
  * @uses bp_is_activity_component()
470
  /**
471
  * Remove activity from favorites.
472
  *
473
+ * @since BuddyPress (1.2)
474
  *
475
  * @uses is_user_logged_in()
476
  * @uses bp_is_activity_component()
504
  /**
505
  * Load the sitewide activity feed.
506
  *
507
+ * @since BuddyPress (1.0)
508
  *
509
+ * @global object $bp BuddyPress global settings
510
  * @uses bp_is_activity_component()
511
  * @uses bp_is_current_action()
512
  * @uses bp_is_user()
515
  * @return bool False on failure.
516
  */
517
  function bp_activity_action_sitewide_feed() {
518
+ global $bp;
519
 
520
  if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
521
  return false;
537
  /**
538
  * Load a user's personal activity feed.
539
  *
540
+ * @since BuddyPress (1.0)
541
  *
542
  * @uses bp_is_user_activity()
543
  * @uses bp_is_current_action()
567
  /**
568
  * Load a user's friends' activity feed.
569
  *
570
+ * @since BuddyPress (1.0)
571
  *
572
  * @uses bp_is_active()
573
  * @uses bp_is_user_activity()
600
  /**
601
  * Load the activity feed for a user's groups.
602
  *
603
+ * @since BuddyPress (1.2)
604
  *
605
  * @uses bp_is_active()
606
  * @uses bp_is_user_activity()
641
  /**
642
  * Load a user's @mentions feed.
643
  *
644
+ * @since BuddyPress (1.2)
645
  *
646
  * @uses bp_is_user_activity()
647
  * @uses bp_is_current_action()
678
  /**
679
  * Load a user's favorites feed.
680
  *
681
+ * @since BuddyPress (1.2)
682
  *
683
  * @uses bp_is_user_activity()
684
  * @uses bp_is_current_action()
713
  /**
714
  * Loads Akismet filtering for activity.
715
  *
716
+ * @since BuddyPress (1.6)
717
+ *
718
+ * @global object $bp BuddyPress global settings
719
  */
720
  function bp_activity_setup_akismet() {
721
+ global $bp;
722
 
723
  // Bail if Akismet is not active
724
+ if ( ! defined( 'AKISMET_VERSION' ) )
 
 
 
 
 
725
  return;
 
726
 
727
  // Bail if no Akismet key is set
728
+ if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) )
729
  return;
 
730
 
731
  /**
732
  * Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
733
  *
734
  * @since BuddyPress (1.6.0)
735
  *
736
+ * @param bool bp_is_akismet_active Return value of bp_is_akismet_active boolean function.
737
  */
738
+ if ( ! apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) )
739
  return;
 
740
 
741
  // Instantiate Akismet for BuddyPress
742
  $bp->activity->akismet = new BP_Akismet();
bp-activity/bp-activity-admin.php CHANGED
@@ -52,8 +52,7 @@ add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
52
  * @since BuddyPress (1.7.0)
53
  *
54
  * @param array $custom_menus The list of top-level BP menu items.
55
- *
56
- * @return array $custom_menus List of top-level BP menu items, with Activity added.
57
  */
58
  function bp_activity_admin_menu_order( $custom_menus = array() ) {
59
  array_push( $custom_menus, 'bp-activity' );
@@ -139,10 +138,10 @@ add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
139
  *
140
  * @since BuddyPress (1.6.0)
141
  *
142
- * @param string $value Will always be false unless another plugin filters it first.
143
- * @param string $option Screen option name.
 
144
  * @param string $new_value Screen option form value.
145
- *
146
  * @return string Option value. False to abandon update.
147
  */
148
  function bp_activity_admin_screen_options( $value, $option, $new_value ) {
@@ -162,9 +161,7 @@ function bp_activity_admin_screen_options( $value, $option, $new_value ) {
162
  *
163
  * @since BuddyPress (1.6.0)
164
  *
165
- * @param array $hidden Array of items to hide.
166
  * @param WP_Screen $screen Screen identifier.
167
- *
168
  * @return array Hidden Meta Boxes.
169
  */
170
  function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
@@ -191,12 +188,12 @@ add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxe
191
  *
192
  * Does the following:
193
  * - Register contextual help and screen options for this admin page.
194
- * - Enqueues scripts and styles.
195
- * - Catches POST and GET requests related to Activity.
196
  *
197
  * @since BuddyPress (1.6.0)
198
  *
199
- * @global object $bp BuddyPress global settings.
200
  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
201
  */
202
  function bp_activity_admin_load() {
@@ -245,8 +242,8 @@ function bp_activity_admin_load() {
245
  // Help panel - sidebar links
246
  get_current_screen()->set_help_sidebar(
247
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
248
- '<p>' . __( '<a href="https://codex.buddypress.org/administrator-guide/activity-stream-management-panels/">Managing Activity</a>', 'buddypress' ) . '</p>' .
249
- '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
250
  );
251
 
252
  // Register metaboxes for the edit screen.
@@ -256,7 +253,7 @@ function bp_activity_admin_load() {
256
  add_meta_box( 'bp_activity_type', _x( 'Type', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_type', get_current_screen()->id, 'normal', 'core' );
257
  add_meta_box( 'bp_activity_userid', _x( 'Author ID', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_userid', get_current_screen()->id, 'normal', 'core' );
258
 
259
- // Enqueue JavaScript files
260
  wp_enqueue_script( 'postbox' );
261
  wp_enqueue_script( 'dashboard' );
262
  wp_enqueue_script( 'comment' );
@@ -290,7 +287,7 @@ function bp_activity_admin_load() {
290
  // Help panel - sidebar links
291
  get_current_screen()->set_help_sidebar(
292
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
293
- '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
294
  );
295
  }
296
 
@@ -414,8 +411,8 @@ function bp_activity_admin_load() {
414
  *
415
  * @since BuddyPress (1.6.0)
416
  *
417
- * @param array $value Array holding spam, not spam, deleted counts, error IDs.
418
- * @param string $redirect_to URL to redirect to.
419
  * @param array $activity_ids Original array of activity IDs.
420
  */
421
  do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids );
@@ -642,7 +639,7 @@ function bp_activity_admin_edit() {
642
  *
643
  * @since BuddyPress (1.6.0)
644
  *
645
- * @param array $value Array holding single activity object that was passed by reference.
646
  */
647
  do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
648
 
@@ -819,14 +816,16 @@ function bp_activity_admin_get_activity_actions() {
819
  }
820
 
821
  /**
822
- * Activity type metabox for the Activity admin edit screen.
823
  *
824
  * @since BuddyPress (1.6.0)
825
  *
 
 
826
  * @param object $item Activity item.
827
  */
828
  function bp_activity_admin_edit_metabox_type( $item ) {
829
- $bp = buddypress();
830
 
831
  $actions = array();
832
  $selected = $item->type;
@@ -891,8 +890,9 @@ function bp_activity_admin_edit_metabox_itemids( $item ) {
891
  *
892
  * @since BuddyPress (1.6.0)
893
  *
894
- * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
895
- * @global string $plugin_page The current plugin page.
 
896
  */
897
  function bp_activity_admin_index() {
898
  global $bp_activity_list_table, $plugin_page;
@@ -1004,7 +1004,7 @@ function bp_activity_admin_index() {
1004
  <a href="#" class="cancel button-secondary alignleft"><?php _e( 'Cancel', 'buddypress' ); ?></a>
1005
  <a href="#" class="save button-primary alignright"><?php _e( 'Reply', 'buddypress' ); ?></a>
1006
 
1007
- <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
1008
  <span class="error" style="display:none;"></span>
1009
  <br class="clear" />
1010
  </p>
@@ -1023,7 +1023,7 @@ function bp_activity_admin_index() {
1023
  /**
1024
  * List table class for the Activity component admin page.
1025
  *
1026
- * @since BuddyPress (1.6.0)
1027
  */
1028
  class BP_Activity_List_Table extends WP_List_Table {
1029
 
@@ -1054,7 +1054,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1054
  protected $activity_user_id = array();
1055
 
1056
  /**
1057
- * If users can comment on blog & forum activity items.
1058
  *
1059
  * @since BuddyPress (2.2.2)
1060
  *
@@ -1197,7 +1197,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1197
  $this->get_columns(),
1198
  array(),
1199
  $this->get_sortable_columns(),
1200
- $this->get_default_primary_column_name(),
1201
  );
1202
 
1203
  return $this->_column_headers;
@@ -1220,7 +1219,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1220
  function display() {
1221
  $this->display_tablenav( 'top' ); ?>
1222
 
1223
- <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
1224
  <thead>
1225
  <tr>
1226
  <?php $this->print_column_headers(); ?>
@@ -1277,11 +1276,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1277
  * @since BuddyPress (1.6.0)
1278
  */
1279
  function get_views() {
1280
- $url_base = add_query_arg( array( 'page' => 'bp-activity' ), bp_get_admin_url( 'admin.php' ) ); ?>
1281
 
1282
  <ul class="subsubsub">
1283
  <li class="all"><a href="<?php echo esc_url( $url_base ); ?>" class="<?php if ( 'spam' != $this->view ) echo 'current'; ?>"><?php _e( 'All', 'buddypress' ); ?></a> |</li>
1284
- <li class="spam"><a href="<?php echo esc_url( add_query_arg( array( 'activity_status' => 'spam' ), $url_base ) ); ?>" class="<?php if ( 'spam' == $this->view ) echo 'current'; ?>"><?php printf( __( 'Spam <span class="count">(%s)</span>', 'buddypress' ), number_format_i18n( $this->spam_count ) ); ?></a></li>
1285
 
1286
  <?php
1287
 
@@ -1291,7 +1290,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1291
  * @since BuddyPress (1.6.0)
1292
  *
1293
  * @param string $url_base Current URL base for view.
1294
- * @param string $view Current view being displayed.
1295
  */
1296
  do_action( 'bp_activity_list_table_get_views', $url_base, $this->view ); ?>
1297
  </ul>
@@ -1412,37 +1411,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1412
  <?php
1413
  }
1414
 
1415
- /**
1416
- * Override WP_List_Table::row_actions().
1417
- *
1418
- * Basically a duplicate of the row_actions() method, but removes the
1419
- * unnecessary <button> addition.
1420
- *
1421
- * @since 2.3.3
1422
- * @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0.
1423
- *
1424
- * @param array $actions The list of actions
1425
- * @param bool $always_visible Whether the actions should be always visible
1426
- * @return string
1427
- */
1428
- public function row_actions( $actions, $always_visible = false ) {
1429
- $action_count = count( $actions );
1430
- $i = 0;
1431
-
1432
- if ( !$action_count )
1433
- return '';
1434
-
1435
- $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
1436
- foreach ( $actions as $action => $link ) {
1437
- ++$i;
1438
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1439
- $out .= "<span class='$action'>$link$sep</span>";
1440
- }
1441
- $out .= '</div>';
1442
-
1443
- return $out;
1444
- }
1445
-
1446
  /**
1447
  * Checkbox column markup.
1448
  *
@@ -1525,7 +1493,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1525
 
1526
  // Rollover actions
1527
 
1528
- // Reply - JavaScript only; implemented by AJAX.
1529
  if ( 'spam' != $item_status ) {
1530
  if ( $this->can_comment( $item ) ) {
1531
  $actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', __( 'Reply', 'buddypress' ) );
@@ -1555,7 +1523,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1555
  * @since BuddyPress (1.6.0)
1556
  *
1557
  * @param array $actions Array of available actions user could use.
1558
- * @param array $item Current item being added to page.
1559
  */
1560
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1561
 
@@ -1601,47 +1569,33 @@ class BP_Activity_List_Table extends WP_List_Table {
1601
  */
1602
  function column_response( $item ) {
1603
  // Is $item is a root activity?
1604
- ?>
1605
-
1606
- <div class="response-links">
1607
-
1608
- <?php
1609
- // Activity permalink
1610
- $activity_permalink = '';
1611
- if ( ! $item['is_spam'] ) {
1612
- $activity_permalink = sprintf( __( '<a href="%1$s" class="comments-view-item-link">View Activity</a>', 'buddypress' ), bp_activity_get_permalink( $item['id'], (object) $item ) );
1613
- }
1614
 
1615
  /**
1616
  * Filters default list of default root activity types.
1617
  *
1618
  * @since BuddyPress (1.6.0)
1619
  *
1620
- * @param array $value Array of default activity types.
1621
- * @param array $item Current item being displayed.
1622
  */
1623
  if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) ) {
1624
- echo $activity_permalink;
1625
-
1626
  $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
1627
  $root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1628
 
1629
  // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
1630
  if ( $comment_count ) {
1631
  $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
1632
- printf( '<a href="%1$s" title="%2$s" class="post-com-count post-com-count-approved"><span class="comment-count comment-count-approved">%3$s</span></a>', esc_url( $root_activity_url ), esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
1633
  }
1634
 
1635
  // For non-root activities, display a link to the replied-to activity's author's profile
1636
  } else {
1637
  echo '<strong>' . get_avatar( $this->get_activity_user_id( $item['item_id'] ), '32' ) . ' ' . bp_core_get_userlink( $this->get_activity_user_id( $item['item_id'] ) ) . '</strong><br />';
1638
- echo $activity_permalink;
1639
  }
1640
- ?>
1641
 
1642
- </div>
1643
-
1644
- <?php
1645
  }
1646
 
1647
  /**
@@ -1653,7 +1607,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1653
  * @since BuddyPress (1.6.0)
1654
  *
1655
  * @param int $activity_id Activity ID to retrieve User ID for.
1656
- *
1657
  * @return int User ID of the activity item in question.
1658
  */
1659
  protected function get_activity_user_id( $activity_id ) {
@@ -1687,14 +1640,13 @@ class BP_Activity_List_Table extends WP_List_Table {
1687
  * Checks if an activity item can be replied to.
1688
  *
1689
  * This method merges functionality from {@link bp_activity_can_comment()} and
1690
- * {@link bp_blogs_disable_activity_commenting()}. This is done because the activity
1691
  * list table doesn't use a BuddyPress activity loop, which prevents those
1692
  * functions from working as intended.
1693
  *
1694
  * @since BuddyPress (2.0.0)
1695
  *
1696
  * @param array $item An array version of the BP_Activity_Activity object.
1697
- *
1698
  * @return bool
1699
  */
1700
  protected function can_comment( $item ) {
@@ -1759,7 +1711,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1759
  * @since BuddyPress (1.6.0)
1760
  *
1761
  * @param array $tree Source array.
1762
- *
1763
  * @return array Flattened array.
1764
  */
1765
  public static function flatten_activity_array( $tree ){
@@ -1776,16 +1727,4 @@ class BP_Activity_List_Table extends WP_List_Table {
1776
 
1777
  return $tree;
1778
  }
1779
-
1780
- /**
1781
- * Get name of default primary column
1782
- *
1783
- * @since BuddyPress (2.3.3)
1784
- * @access protected
1785
- *
1786
- * @return string
1787
- */
1788
- protected function get_default_primary_column_name() {
1789
- return 'author';
1790
- }
1791
  }
52
  * @since BuddyPress (1.7.0)
53
  *
54
  * @param array $custom_menus The list of top-level BP menu items.
55
+ * @return array $custom_menus List of top-level BP menu items, with Activity added
 
56
  */
57
  function bp_activity_admin_menu_order( $custom_menus = array() ) {
58
  array_push( $custom_menus, 'bp-activity' );
138
  *
139
  * @since BuddyPress (1.6.0)
140
  *
141
+ * @param string $value Will always be false unless another plugin filters it
142
+ * first.
143
+ * @param string $option Screen option name.
144
  * @param string $new_value Screen option form value.
 
145
  * @return string Option value. False to abandon update.
146
  */
147
  function bp_activity_admin_screen_options( $value, $option, $new_value ) {
161
  *
162
  * @since BuddyPress (1.6.0)
163
  *
 
164
  * @param WP_Screen $screen Screen identifier.
 
165
  * @return array Hidden Meta Boxes.
166
  */
167
  function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
188
  *
189
  * Does the following:
190
  * - Register contextual help and screen options for this admin page.
191
+ * - Enqueues scripts and styles
192
+ * - Catches POST and GET requests related to Activity
193
  *
194
  * @since BuddyPress (1.6.0)
195
  *
196
+ * @global object $bp BuddyPress global settings.
197
  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
198
  */
199
  function bp_activity_admin_load() {
242
  // Help panel - sidebar links
243
  get_current_screen()->set_help_sidebar(
244
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
245
+ '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-activity/">Managing Activity</a>', 'buddypress' ) . '</p>' .
246
+ '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
247
  );
248
 
249
  // Register metaboxes for the edit screen.
253
  add_meta_box( 'bp_activity_type', _x( 'Type', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_type', get_current_screen()->id, 'normal', 'core' );
254
  add_meta_box( 'bp_activity_userid', _x( 'Author ID', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_userid', get_current_screen()->id, 'normal', 'core' );
255
 
256
+ // Enqueue javascripts
257
  wp_enqueue_script( 'postbox' );
258
  wp_enqueue_script( 'dashboard' );
259
  wp_enqueue_script( 'comment' );
287
  // Help panel - sidebar links
288
  get_current_screen()->set_help_sidebar(
289
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
290
+ '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
291
  );
292
  }
293
 
411
  *
412
  * @since BuddyPress (1.6.0)
413
  *
414
+ * @param array Array holding spam, not spam, deleted counts, error IDs.
415
+ * @param string $redirect_to URL to redirect to.
416
  * @param array $activity_ids Original array of activity IDs.
417
  */
418
  do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids );
639
  *
640
  * @since BuddyPress (1.6.0)
641
  *
642
+ * @param array Array holding single activity object.
643
  */
644
  do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
645
 
816
  }
817
 
818
  /**
819
+ * Activity type metabox for the Activity admin edit screen
820
  *
821
  * @since BuddyPress (1.6.0)
822
  *
823
+ * @global object $bp BuddyPress global settings.
824
+ *
825
  * @param object $item Activity item.
826
  */
827
  function bp_activity_admin_edit_metabox_type( $item ) {
828
+ global $bp;
829
 
830
  $actions = array();
831
  $selected = $item->type;
890
  *
891
  * @since BuddyPress (1.6.0)
892
  *
893
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list
894
+ * table.
895
+ * @global string $plugin_page The current plugin page.
896
  */
897
  function bp_activity_admin_index() {
898
  global $bp_activity_list_table, $plugin_page;
1004
  <a href="#" class="cancel button-secondary alignleft"><?php _e( 'Cancel', 'buddypress' ); ?></a>
1005
  <a href="#" class="save button-primary alignright"><?php _e( 'Reply', 'buddypress' ); ?></a>
1006
 
1007
+ <img class="waiting" style="display:none;" src="<?php echo esc_url( bp_get_admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
1008
  <span class="error" style="display:none;"></span>
1009
  <br class="clear" />
1010
  </p>
1023
  /**
1024
  * List table class for the Activity component admin page.
1025
  *
1026
+ * @since BuddyPress (1.6)
1027
  */
1028
  class BP_Activity_List_Table extends WP_List_Table {
1029
 
1054
  protected $activity_user_id = array();
1055
 
1056
  /**
1057
+ * If users can comment on blog & forum activity items
1058
  *
1059
  * @since BuddyPress (2.2.2)
1060
  *
1197
  $this->get_columns(),
1198
  array(),
1199
  $this->get_sortable_columns(),
 
1200
  );
1201
 
1202
  return $this->_column_headers;
1219
  function display() {
1220
  $this->display_tablenav( 'top' ); ?>
1221
 
1222
+ <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
1223
  <thead>
1224
  <tr>
1225
  <?php $this->print_column_headers(); ?>
1276
  * @since BuddyPress (1.6.0)
1277
  */
1278
  function get_views() {
1279
+ $url_base = bp_get_admin_url( 'admin.php?page=bp-activity' ); ?>
1280
 
1281
  <ul class="subsubsub">
1282
  <li class="all"><a href="<?php echo esc_url( $url_base ); ?>" class="<?php if ( 'spam' != $this->view ) echo 'current'; ?>"><?php _e( 'All', 'buddypress' ); ?></a> |</li>
1283
+ <li class="spam"><a href="<?php echo esc_url( add_query_arg( 'activity_status', 'spam', $url_base ) ); ?>" class="<?php if ( 'spam' == $this->view ) echo 'current'; ?>"><?php printf( __( 'Spam <span class="count">(%s)</span>', 'buddypress' ), number_format_i18n( $this->spam_count ) ); ?></a></li>
1284
 
1285
  <?php
1286
 
1290
  * @since BuddyPress (1.6.0)
1291
  *
1292
  * @param string $url_base Current URL base for view.
1293
+ * @param string $view Current view being displayed.
1294
  */
1295
  do_action( 'bp_activity_list_table_get_views', $url_base, $this->view ); ?>
1296
  </ul>
1411
  <?php
1412
  }
1413
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1414
  /**
1415
  * Checkbox column markup.
1416
  *
1493
 
1494
  // Rollover actions
1495
 
1496
+ // Reply - javascript only; implemented by AJAX.
1497
  if ( 'spam' != $item_status ) {
1498
  if ( $this->can_comment( $item ) ) {
1499
  $actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', __( 'Reply', 'buddypress' ) );
1523
  * @since BuddyPress (1.6.0)
1524
  *
1525
  * @param array $actions Array of available actions user could use.
1526
+ * @param array $item Current item being added to page.
1527
  */
1528
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1529
 
1569
  */
1570
  function column_response( $item ) {
1571
  // Is $item is a root activity?
 
 
 
 
 
 
 
 
 
 
1572
 
1573
  /**
1574
  * Filters default list of default root activity types.
1575
  *
1576
  * @since BuddyPress (1.6.0)
1577
  *
1578
+ * @param array Array of default activity types.
1579
+ * @param array $item Current item being displayed.
1580
  */
1581
  if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) ) {
 
 
1582
  $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
1583
  $root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1584
 
1585
  // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
1586
  if ( $comment_count ) {
1587
  $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
1588
+ printf( '<a href="%1$s" title="%2$s" class="post-com-count"><span class="comment-count">%3$s</span></a>', esc_url( $root_activity_url ), esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
1589
  }
1590
 
1591
  // For non-root activities, display a link to the replied-to activity's author's profile
1592
  } else {
1593
  echo '<strong>' . get_avatar( $this->get_activity_user_id( $item['item_id'] ), '32' ) . ' ' . bp_core_get_userlink( $this->get_activity_user_id( $item['item_id'] ) ) . '</strong><br />';
 
1594
  }
 
1595
 
1596
+ // Activity permalink
1597
+ if ( ! $item['is_spam'] )
1598
+ printf( __( '<a href="%1$s">View Activity</a>', 'buddypress' ), bp_activity_get_permalink( $item['id'], (object) $item ) );
1599
  }
1600
 
1601
  /**
1607
  * @since BuddyPress (1.6.0)
1608
  *
1609
  * @param int $activity_id Activity ID to retrieve User ID for.
 
1610
  * @return int User ID of the activity item in question.
1611
  */
1612
  protected function get_activity_user_id( $activity_id ) {
1640
  * Checks if an activity item can be replied to.
1641
  *
1642
  * This method merges functionality from {@link bp_activity_can_comment()} and
1643
+ * {@link bp_blogs_disable_activity_commenting()}. This is done because the activity
1644
  * list table doesn't use a BuddyPress activity loop, which prevents those
1645
  * functions from working as intended.
1646
  *
1647
  * @since BuddyPress (2.0.0)
1648
  *
1649
  * @param array $item An array version of the BP_Activity_Activity object.
 
1650
  * @return bool
1651
  */
1652
  protected function can_comment( $item ) {
1711
  * @since BuddyPress (1.6.0)
1712
  *
1713
  * @param array $tree Source array.
 
1714
  * @return array Flattened array.
1715
  */
1716
  public static function flatten_activity_array( $tree ){
1727
 
1728
  return $tree;
1729
  }
 
 
 
 
 
 
 
 
 
 
 
 
1730
  }
bp-activity/bp-activity-akismet.php CHANGED
@@ -3,7 +3,7 @@
3
  * Akismet support for BuddyPress' Activity Stream.
4
  *
5
  * @package BuddyPress
6
- * @since BuddyPress (1.6.0)
7
  * @subpackage Activity
8
  */
9
 
@@ -13,8 +13,7 @@ defined( 'ABSPATH' ) || exit;
13
  /**
14
  * Akismet support for the Activity component.
15
  *
16
- * @since BuddyPress (1.6.0)
17
- * @since BuddyPress (2.3.0) We only support Akismet 3+.
18
  */
19
  class BP_Akismet {
20
  /**
@@ -22,14 +21,14 @@ class BP_Akismet {
22
  *
23
  * @access protected
24
  * @var BP_Activity_Activity
25
- * @since BuddyPress (1.6.0)
26
  */
27
  protected $last_activity = null;
28
 
29
  /**
30
  * Constructor.
31
  *
32
- * @since BuddyPress (1.6.0)
33
  */
34
  public function __construct() {
35
  $this->setup_actions();
@@ -38,7 +37,7 @@ class BP_Akismet {
38
  /**
39
  * Hook Akismet into the activity stream.
40
  *
41
- * @since BuddyPress (1.6.0)
42
  */
43
  protected function setup_actions() {
44
  // Add nonces to activity stream lists
@@ -70,11 +69,10 @@ class BP_Akismet {
70
  * This function lifted with love from the Akismet WordPress plugin's
71
  * akismet_comment_row_action() function. Thanks!
72
  *
73
- * @since BuddyPress (1.6.0)
74
  *
75
- * @param array $actions The hover links.
76
  * @param array $activity The activity for the current row being processed.
77
- *
78
  * @return array The hover links.
79
  */
80
  function comment_row_action( $actions, $activity ) {
@@ -131,9 +129,9 @@ class BP_Akismet {
131
  * the reply form of each activity item. The nonces are, in turn, used
132
  * by Akismet to help detect spam activity.
133
  *
134
- * @since BuddyPress (1.6.0)
135
  *
136
- * @see https://plugins.trac.wordpress.org/ticket/1232
137
  */
138
  public function add_activity_stream_nonce() {
139
  $form_id = '_bp_as_nonce';
@@ -160,13 +158,13 @@ class BP_Akismet {
160
  * This can't be done in BP_Akismet::check_activity() due to the
161
  * default AJAX implementation; see bp_dtheme_post_update().
162
  *
163
- * @since BuddyPress (1.6.0)
164
  *
165
  * @see bp_dtheme_post_update()
166
  *
167
- * @param string $content Activity update text.
168
- * @param int $user_id User ID.
169
- * @param int $activity_id Activity ID.
170
  */
171
  public function check_member_activity_update( $content, $user_id, $activity_id ) {
172
  // By default, only handle activity updates and activity comments.
@@ -186,7 +184,7 @@ class BP_Akismet {
186
  *
187
  * This function is intended to be used inside the activity stream loop.
188
  *
189
- * @since BuddyPress (1.6.0)
190
  */
191
  public function add_activity_spam_button() {
192
  if ( !bp_activity_user_can_mark_spam() )
@@ -214,7 +212,7 @@ class BP_Akismet {
214
  *
215
  * This function is intended to be used inside the activity stream loop.
216
  *
217
- * @since BuddyPress (1.6.0)
218
  */
219
  public function add_activity_comment_spam_button() {
220
  if ( !bp_activity_user_can_mark_spam() )
@@ -241,7 +239,7 @@ class BP_Akismet {
241
  /**
242
  * Get a filterable list of activity types that Akismet should automatically check for spam.
243
  *
244
- * @since BuddyPress (1.6.0)
245
  *
246
  * @static
247
  *
@@ -262,12 +260,10 @@ class BP_Akismet {
262
  /**
263
  * Mark activity item as spam.
264
  *
265
- * @since BuddyPress (1.6.0)
266
  *
267
- * @param BP_Activity_Activity $activity Activity item being spammed.
268
- * @param string $source Either "by_a_person" (e.g. a person has
269
- * manually marked the activity as spam) or
270
- * "by_akismet" (automatically spammed).
271
  */
272
  public function mark_as_spam( $activity, $source ) {
273
  // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
@@ -279,10 +275,7 @@ class BP_Akismet {
279
  * @since BuddyPress (1.6.0)
280
  *
281
  * @param BP_Activity_Activity $activity Activity object being marked as spam.
282
- * @param string $source Source of the whom marked as spam.
283
- * Either "by_a_person" (e.g. a person has
284
- * manually marked the activity as spam)
285
- * or "by_akismet".
286
  */
287
  do_action( 'bp_activity_akismet_mark_as_spam', $activity, $source );
288
  }
@@ -290,12 +283,10 @@ class BP_Akismet {
290
  /**
291
  * Mark activity item as ham.
292
  *
293
- * @since BuddyPress (1.6.0)
294
  *
295
- * @param BP_Activity_Activity $activity Activity item being hammed.
296
- * @param string $source Either "by_a_person" (e.g. a person has
297
- * manually marked the activity as ham) or
298
- * "by_akismet" (automatically hammed).
299
  */
300
  public function mark_as_ham( $activity, $source ) {
301
  // If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
@@ -308,10 +299,7 @@ class BP_Akismet {
308
  * @since BuddyPress (1.6.0)
309
  *
310
  * @param BP_Activity_Activity $activity Activity object being marked as ham.
311
- * @param string $source Source of the whom marked as ham.
312
- * Either "by_a_person" (e.g. a person has
313
- * manually marked the activity as ham) or
314
- * "by_akismet" (automatically hammed).
315
  */
316
  do_action( 'bp_activity_akismet_mark_as_ham', $activity, $source );
317
  }
@@ -319,14 +307,12 @@ class BP_Akismet {
319
  /**
320
  * Build a data package for the Akismet service to inspect.
321
  *
322
- * @since BuddyPress (1.6.0)
323
  *
324
  * @see http://akismet.com/development/api/#comment-check
325
  * @static
326
  *
327
  * @param BP_Activity_Activity $activity Activity item data.
328
- *
329
- * @return array
330
  */
331
  public static function build_akismet_data_package( $activity ) {
332
  $userdata = get_userdata( $activity->user_id );
@@ -340,7 +326,7 @@ class BP_Akismet {
340
  $activity_data['comment_type'] = $activity->type;
341
  $activity_data['permalink'] = bp_activity_get_permalink( $activity->id, $activity );
342
  $activity_data['user_ID'] = $userdata->ID;
343
- $activity_data['user_role'] = Akismet::get_user_roles( $userdata->ID );
344
 
345
  /**
346
  * Get the nonce if the new activity was submitted through the "what's up, Paul?" form.
@@ -361,8 +347,8 @@ class BP_Akismet {
361
  *
362
  * @since BuddyPress (1.6.0)
363
  *
364
- * @param array $activity_data Array of activity data for Akismet to inspect.
365
- * @param BP_Activity_Activity $activity Activity item data.
366
  */
367
  return apply_filters( 'bp_akismet_build_akismet_data_package', $activity_data, $activity );
368
  }
@@ -370,7 +356,7 @@ class BP_Akismet {
370
  /**
371
  * Check if the activity item is spam or ham.
372
  *
373
- * @since BuddyPress (1.6.0)
374
  *
375
  * @see http://akismet.com/development/api/
376
  * @todo Spam counter?
@@ -405,9 +391,8 @@ class BP_Akismet {
405
  *
406
  * @since BuddyPress (1.6.0)
407
  *
408
- * @param BP_Activity_Activity $activity The activity item proven to be spam.
409
- * @param array $activity_data Array of activity data for item including
410
- * Akismet check results data.
411
  */
412
  do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
413
 
@@ -422,7 +407,7 @@ class BP_Akismet {
422
  /**
423
  * Update activity meta after a manual spam change (user-initiated).
424
  *
425
- * @since BuddyPress (1.6.0)
426
  *
427
  * @param BP_Activity_Activity $activity The activity to check.
428
  */
@@ -439,7 +424,7 @@ class BP_Akismet {
439
  /**
440
  * Update activity meta after a manual ham change (user-initiated).
441
  *
442
- * @since BuddyPress (1.6.0)
443
  *
444
  * @param BP_Activity_Activity $activity The activity to check.
445
  */
@@ -456,7 +441,7 @@ class BP_Akismet {
456
  /**
457
  * Update activity meta after an automatic spam check (not user-initiated).
458
  *
459
- * @since BuddyPress (1.6.0)
460
  *
461
  * @param BP_Activity_Activity $activity The activity to check.
462
  */
@@ -494,15 +479,23 @@ class BP_Akismet {
494
  *
495
  * Props to WordPress core Akismet plugin for a lot of this.
496
  *
497
- * @since BuddyPress (1.6.0)
498
  *
499
- * @param array $activity_data Packet of information to submit to Akismet.
500
- * @param string $check "check" or "submit".
501
- * @param string $spam "spam" or "ham".
502
  *
 
 
 
503
  * @return array $activity_data Activity data, with Akismet data added.
504
  */
505
  public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
 
 
 
 
 
 
506
  $query_string = $path = '';
507
 
508
  $activity_data['blog'] = bp_get_option( 'home' );
@@ -512,7 +505,7 @@ class BP_Akismet {
512
  $activity_data['user_agent'] = bp_core_current_user_ua();
513
  $activity_data['user_ip'] = bp_core_current_user_ip();
514
 
515
- if ( Akismet::is_test_mode() )
516
  $activity_data['is_test'] = 'true';
517
 
518
  // Loop through _POST args and rekey strings
@@ -540,13 +533,13 @@ class BP_Akismet {
540
  $query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&';
541
 
542
  if ( 'check' == $check )
543
- $path = 'comment-check';
544
  elseif ( 'submit' == $check )
545
- $path = 'submit-' . $spam;
546
 
547
  // Send to Akismet
548
  add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
549
- $response = Akismet::http_post( $query_string, $path );
550
  remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
551
 
552
  // Get the response
@@ -565,10 +558,9 @@ class BP_Akismet {
565
  /**
566
  * Filters user agent when sending to Akismet to add BuddyPress info.
567
  *
568
- * @since BuddyPress (1.6.0)
569
  *
570
  * @param string $user_agent User agent string, as generated by Akismet.
571
- *
572
  * @return string $user_agent Modified user agent string.
573
  */
574
  public function buddypress_ua( $user_agent ) {
@@ -579,7 +571,7 @@ class BP_Akismet {
579
  /**
580
  * Adds a "History" meta box to the activity edit screen.
581
  *
582
- * @since BuddyPress (1.6.0)
583
  *
584
  * @param string $screen_action The type of screen that has been requested.
585
  */
@@ -595,9 +587,9 @@ class BP_Akismet {
595
  /**
596
  * History meta box for the Activity admin edit screen.
597
  *
598
- * @since BuddyPress (1.6.0)
599
  *
600
- * @see https://buddypress.trac.wordpress.org/ticket/3907
601
  * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
602
  *
603
  * @param object $item Activity item.
@@ -616,17 +608,17 @@ class BP_Akismet {
616
  /**
617
  * Update an activity item's Akismet history.
618
  *
619
- * @since BuddyPress (1.6.0)
620
  *
621
- * @param int $activity_id Activity item ID.
622
- * @param string $message Human-readable description of what's changed.
623
- * @param string $event The type of check we were carrying out.
624
  */
625
  public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
626
  $event = array(
627
  'event' => $event,
628
  'message' => $message,
629
- 'time' => Akismet::_get_microtime(),
630
  'user' => bp_loggedin_user_id(),
631
  );
632
 
@@ -637,10 +629,9 @@ class BP_Akismet {
637
  /**
638
  * Get an activity item's Akismet history.
639
  *
640
- * @since BuddyPress (1.6.0)
641
  *
642
  * @param int $activity_id Activity item ID.
643
- *
644
  * @return array The activity item's Akismet history.
645
  */
646
  public function get_activity_history( $activity_id = 0 ) {
@@ -656,19 +647,18 @@ class BP_Akismet {
656
  }
657
 
658
  /**
659
- * Delete old spam activity meta data.
660
  *
661
  * This is done as a clean-up mechanism, as _bp_akismet_submission meta can
662
  * grow to be quite large.
663
  *
664
- * @since BuddyPress (1.6.0)
665
  *
 
666
  * @global wpdb $wpdb WordPress database object.
667
  */
668
  function bp_activity_akismet_delete_old_metadata() {
669
- global $wpdb;
670
-
671
- $bp = buddypress();
672
 
673
  /**
674
  * Filters the threshold for how many days old Akismet metadata needs to be before being automatically deleted.
3
  * Akismet support for BuddyPress' Activity Stream.
4
  *
5
  * @package BuddyPress
6
+ * @since BuddyPress (1.6)
7
  * @subpackage Activity
8
  */
9
 
13
  /**
14
  * Akismet support for the Activity component.
15
  *
16
+ * @since BuddyPress (1.6)
 
17
  */
18
  class BP_Akismet {
19
  /**
21
  *
22
  * @access protected
23
  * @var BP_Activity_Activity
24
+ * @since BuddyPress (1.6)
25
  */
26
  protected $last_activity = null;
27
 
28
  /**
29
  * Constructor.
30
  *
31
+ * @since BuddyPress (1.6)
32
  */
33
  public function __construct() {
34
  $this->setup_actions();
37
  /**
38
  * Hook Akismet into the activity stream.
39
  *
40
+ * @since BuddyPress (1.6)
41
  */
42
  protected function setup_actions() {
43
  // Add nonces to activity stream lists
69
  * This function lifted with love from the Akismet WordPress plugin's
70
  * akismet_comment_row_action() function. Thanks!
71
  *
72
+ * @since BuddyPress (1.6)
73
  *
74
+ * @param array $actions The hover links.
75
  * @param array $activity The activity for the current row being processed.
 
76
  * @return array The hover links.
77
  */
78
  function comment_row_action( $actions, $activity ) {
129
  * the reply form of each activity item. The nonces are, in turn, used
130
  * by Akismet to help detect spam activity.
131
  *
132
+ * @since BuddyPress (1.6)
133
  *
134
+ * @see http://plugins.trac.wordpress.org/ticket/1232
135
  */
136
  public function add_activity_stream_nonce() {
137
  $form_id = '_bp_as_nonce';
158
  * This can't be done in BP_Akismet::check_activity() due to the
159
  * default AJAX implementation; see bp_dtheme_post_update().
160
  *
161
+ * @since BuddyPress (1.6)
162
  *
163
  * @see bp_dtheme_post_update()
164
  *
165
+ * @param string $content Activity update text.
166
+ * @param int $user_id User ID.
167
+ * @param int $activity_id Activity ID.
168
  */
169
  public function check_member_activity_update( $content, $user_id, $activity_id ) {
170
  // By default, only handle activity updates and activity comments.
184
  *
185
  * This function is intended to be used inside the activity stream loop.
186
  *
187
+ * @since BuddyPress (1.6)
188
  */
189
  public function add_activity_spam_button() {
190
  if ( !bp_activity_user_can_mark_spam() )
212
  *
213
  * This function is intended to be used inside the activity stream loop.
214
  *
215
+ * @since BuddyPress (1.6)
216
  */
217
  public function add_activity_comment_spam_button() {
218
  if ( !bp_activity_user_can_mark_spam() )
239
  /**
240
  * Get a filterable list of activity types that Akismet should automatically check for spam.
241
  *
242
+ * @since BuddyPress (1.6)
243
  *
244
  * @static
245
  *
260
  /**
261
  * Mark activity item as spam.
262
  *
263
+ * @since BuddyPress (1.6)
264
  *
265
+ * @param BP_Activity_Activity $activity
266
+ * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed).
 
 
267
  */
268
  public function mark_as_spam( $activity, $source ) {
269
  // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
275
  * @since BuddyPress (1.6.0)
276
  *
277
  * @param BP_Activity_Activity $activity Activity object being marked as spam.
278
+ * @param string $source Source of the whom marked as spam. Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet".
 
 
 
279
  */
280
  do_action( 'bp_activity_akismet_mark_as_spam', $activity, $source );
281
  }
283
  /**
284
  * Mark activity item as ham.
285
  *
286
+ * @since BuddyPress (1.6)
287
  *
288
+ * @param BP_Activity_Activity $activity
289
+ * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed).
 
 
290
  */
291
  public function mark_as_ham( $activity, $source ) {
292
  // If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
299
  * @since BuddyPress (1.6.0)
300
  *
301
  * @param BP_Activity_Activity $activity Activity object being marked as ham.
302
+ * @param string $source Source of the whom marked as ham. Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed).
 
 
 
303
  */
304
  do_action( 'bp_activity_akismet_mark_as_ham', $activity, $source );
305
  }
307
  /**
308
  * Build a data package for the Akismet service to inspect.
309
  *
310
+ * @since BuddyPress (1.6)
311
  *
312
  * @see http://akismet.com/development/api/#comment-check
313
  * @static
314
  *
315
  * @param BP_Activity_Activity $activity Activity item data.
 
 
316
  */
317
  public static function build_akismet_data_package( $activity ) {
318
  $userdata = get_userdata( $activity->user_id );
326
  $activity_data['comment_type'] = $activity->type;
327
  $activity_data['permalink'] = bp_activity_get_permalink( $activity->id, $activity );
328
  $activity_data['user_ID'] = $userdata->ID;
329
+ $activity_data['user_role'] = akismet_get_user_roles( $userdata->ID );
330
 
331
  /**
332
  * Get the nonce if the new activity was submitted through the "what's up, Paul?" form.
347
  *
348
  * @since BuddyPress (1.6.0)
349
  *
350
+ * @param array $activity_data Array of activity data for Akismet to inspect.
351
+ * @param BP_Activity_Activity $activity Activity item data.
352
  */
353
  return apply_filters( 'bp_akismet_build_akismet_data_package', $activity_data, $activity );
354
  }
356
  /**
357
  * Check if the activity item is spam or ham.
358
  *
359
+ * @since BuddyPress (1.6)
360
  *
361
  * @see http://akismet.com/development/api/
362
  * @todo Spam counter?
391
  *
392
  * @since BuddyPress (1.6.0)
393
  *
394
+ * @param BP_Activity_Activity $activity The activity item proven to be spam.
395
+ * @param array $activity_data Array of activity data for item including Akismet check results data.
 
396
  */
397
  do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
398
 
407
  /**
408
  * Update activity meta after a manual spam change (user-initiated).
409
  *
410
+ * @since BuddyPress (1.6)
411
  *
412
  * @param BP_Activity_Activity $activity The activity to check.
413
  */
424
  /**
425
  * Update activity meta after a manual ham change (user-initiated).
426
  *
427
+ * @since BuddyPress (1.6)
428
  *
429
  * @param BP_Activity_Activity $activity The activity to check.
430
  */
441
  /**
442
  * Update activity meta after an automatic spam check (not user-initiated).
443
  *
444
+ * @since BuddyPress (1.6)
445
  *
446
  * @param BP_Activity_Activity $activity The activity to check.
447
  */
479
  *
480
  * Props to WordPress core Akismet plugin for a lot of this.
481
  *
482
+ * @since BuddyPress (1.6)
483
  *
484
+ * @global string $akismet_api_host
485
+ * @global string $akismet_api_port
 
486
  *
487
+ * @param array $activity_data Packet of information to submit to Akismet.
488
+ * @param string $check "check" or "submit".
489
+ * @param string $spam "spam" or "ham".
490
  * @return array $activity_data Activity data, with Akismet data added.
491
  */
492
  public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
493
+ global $akismet_api_host, $akismet_api_port;
494
+
495
+ // Check that host and port are set, if not, set them
496
+ if ( function_exists( 'akismet_init' ) && ( empty( $akismet_api_host ) || empty( $akismet_api_port ) ) )
497
+ akismet_init();
498
+
499
  $query_string = $path = '';
500
 
501
  $activity_data['blog'] = bp_get_option( 'home' );
505
  $activity_data['user_agent'] = bp_core_current_user_ua();
506
  $activity_data['user_ip'] = bp_core_current_user_ip();
507
 
508
+ if ( akismet_test_mode() )
509
  $activity_data['is_test'] = 'true';
510
 
511
  // Loop through _POST args and rekey strings
533
  $query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&';
534
 
535
  if ( 'check' == $check )
536
+ $path = '/1.1/comment-check';
537
  elseif ( 'submit' == $check )
538
+ $path = '/1.1/submit-' . $spam;
539
 
540
  // Send to Akismet
541
  add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
542
+ $response = akismet_http_post( $query_string, $akismet_api_host, $path, $akismet_api_port );
543
  remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
544
 
545
  // Get the response
558
  /**
559
  * Filters user agent when sending to Akismet to add BuddyPress info.
560
  *
561
+ * @since BuddyPress (1.6)
562
  *
563
  * @param string $user_agent User agent string, as generated by Akismet.
 
564
  * @return string $user_agent Modified user agent string.
565
  */
566
  public function buddypress_ua( $user_agent ) {
571
  /**
572
  * Adds a "History" meta box to the activity edit screen.
573
  *
574
+ * @since BuddyPress (1.6)
575
  *
576
  * @param string $screen_action The type of screen that has been requested.
577
  */
587
  /**
588
  * History meta box for the Activity admin edit screen.
589
  *
590
+ * @since BuddyPress (1.6)
591
  *
592
+ * @see http://buddypress.trac.wordpress.org/ticket/3907
593
  * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
594
  *
595
  * @param object $item Activity item.
608
  /**
609
  * Update an activity item's Akismet history.
610
  *
611
+ * @since BuddyPress (1.6)
612
  *
613
+ * @param int $activity_id Activity item ID.
614
+ * @param string $message Human-readable description of what's changed.
615
+ * @param string $event The type of check we were carrying out.
616
  */
617
  public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
618
  $event = array(
619
  'event' => $event,
620
  'message' => $message,
621
+ 'time' => akismet_microtime(),
622
  'user' => bp_loggedin_user_id(),
623
  );
624
 
629
  /**
630
  * Get an activity item's Akismet history.
631
  *
632
+ * @since BuddyPress (1.6)
633
  *
634
  * @param int $activity_id Activity item ID.
 
635
  * @return array The activity item's Akismet history.
636
  */
637
  public function get_activity_history( $activity_id = 0 ) {
647
  }
648
 
649
  /**
650
+ * Delete old spam activity meta data
651
  *
652
  * This is done as a clean-up mechanism, as _bp_akismet_submission meta can
653
  * grow to be quite large.
654
  *
655
+ * @since BuddyPress (1.6)
656
  *
657
+ * @global object $bp BuddyPress global settings.
658
  * @global wpdb $wpdb WordPress database object.
659
  */
660
  function bp_activity_akismet_delete_old_metadata() {
661
+ global $bp, $wpdb;
 
 
662
 
663
  /**
664
  * Filters the threshold for how many days old Akismet metadata needs to be before being automatically deleted.
bp-activity/bp-activity-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * Functions related to the BuddyPress Activity component and the WP Cache.
5
  *
6
- * @since BuddyPress (1.6.0)
7
  */
8
 
9
  // Exit if accessed directly
@@ -16,11 +16,11 @@ defined( 'ABSPATH' ) || exit;
16
  * in $activity_ids and adds it to the WP cache. This improves efficiency when
17
  * using querying activitymeta inline.
18
  *
19
- * @param int|string|array|bool $activity_ids Accepts a single activity ID, or a comma-
20
- * separated list or array of activity ids
21
  */
22
  function bp_activity_update_meta_cache( $activity_ids = false ) {
23
- $bp = buddypress();
24
 
25
  $cache_args = array(
26
  'object_ids' => $activity_ids,
@@ -37,7 +37,7 @@ function bp_activity_update_meta_cache( $activity_ids = false ) {
37
  /**
38
  * Clear a cached activity item when that item is updated.
39
  *
40
- * @since BuddyPress (2.0.0)
41
  *
42
  * @param BP_Activity_Activity $activity
43
  */
@@ -50,7 +50,7 @@ add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' );
50
  /**
51
  * Clear cached data for deleted activity items.
52
  *
53
- * @since BuddyPress (2.0.0)
54
  *
55
  * @param array $deleted_ids IDs of deleted activity items.
56
  */
3
  /**
4
  * Functions related to the BuddyPress Activity component and the WP Cache.
5
  *
6
+ * @since BuddyPress (1.6)
7
  */
8
 
9
  // Exit if accessed directly
16
  * in $activity_ids and adds it to the WP cache. This improves efficiency when
17
  * using querying activitymeta inline.
18
  *
19
+ * @param int|str|array $activity_ids Accepts a single activity ID, or a comma-
20
+ * separated list or array of activity ids
21
  */
22
  function bp_activity_update_meta_cache( $activity_ids = false ) {
23
+ global $bp;
24
 
25
  $cache_args = array(
26
  'object_ids' => $activity_ids,
37
  /**
38
  * Clear a cached activity item when that item is updated.
39
  *
40
+ * @since 2.0
41
  *
42
  * @param BP_Activity_Activity $activity
43
  */
50
  /**
51
  * Clear cached data for deleted activity items.
52
  *
53
+ * @since 2.0
54
  *
55
  * @param array $deleted_ids IDs of deleted activity items.
56
  */
bp-activity/bp-activity-classes.php CHANGED
@@ -9,6 +9,2382 @@
9
  // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
- require dirname( __FILE__ ) . '/classes/class-bp-activity-activity.php';
13
- require dirname( __FILE__ ) . '/classes/class-bp-activity-feed.php';
14
- require dirname( __FILE__ ) . '/classes/class-bp-activity-query.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
+ /**
13
+ * Database interaction class for the BuddyPress activity component.
14
+ *
15
+ * Instance methods are available for creating/editing an activity,
16
+ * static methods for querying activities.
17
+ *
18
+ * @since BuddyPress (1.0)
19
+ */
20
+ class BP_Activity_Activity {
21
+
22
+ /** Properties ************************************************************/
23
+
24
+ /**
25
+ * ID of the activity item.
26
+ *
27
+ * @var int
28
+ */
29
+ var $id;
30
+
31
+ /**
32
+ * ID of the associated item.
33
+ *
34
+ * @var int
35
+ */
36
+ var $item_id;
37
+
38
+ /**
39
+ * ID of the associated secondary item.
40
+ *
41
+ * @var int
42
+ */
43
+ var $secondary_item_id;
44
+
45
+ /**
46
+ * ID of user associated with the activity item.
47
+ *
48
+ * @var int
49
+ */
50
+ var $user_id;
51
+
52
+ /**
53
+ * The primary URL for the activity in RSS feeds.
54
+ *
55
+ * @var string
56
+ */
57
+ var $primary_link;
58
+
59
+ /**
60
+ * BuddyPress component the activity item relates to.
61
+ *
62
+ * @var string
63
+ */
64
+ var $component;
65
+
66
+ /**
67
+ * Activity type, eg 'new_blog_post'.
68
+ *
69
+ * @var string
70
+ */
71
+ var $type;
72
+
73
+ /**
74
+ * Description of the activity, eg 'Alex updated his profile.'
75
+ *
76
+ * @var string
77
+ */
78
+ var $action;
79
+
80
+ /**
81
+ * The content of the activity item.
82
+ *
83
+ * @var string
84
+ */
85
+ var $content;
86
+
87
+ /**
88
+ * The date the activity item was recorded, in 'Y-m-d h:i:s' format.
89
+ *
90
+ * @var string
91
+ */
92
+ var $date_recorded;
93
+
94
+ /**
95
+ * Whether the item should be hidden in sitewide streams.
96
+ *
97
+ * @var int
98
+ */
99
+ var $hide_sitewide = false;
100
+
101
+ /**
102
+ * Node boundary start for activity or activity comment.
103
+ *
104
+ * @var int
105
+ */
106
+ var $mptt_left;
107
+
108
+ /**
109
+ * Node boundary end for activity or activity comment.
110
+ *
111
+ * @var int
112
+ */
113
+ var $mptt_right;
114
+
115
+ /**
116
+ * Whether this item is marked as spam.
117
+ *
118
+ * @var int
119
+ */
120
+ var $is_spam;
121
+
122
+ /**
123
+ * Constructor method.
124
+ *
125
+ * @param int $id Optional. The ID of a specific activity item.
126
+ */
127
+ public function __construct( $id = false ) {
128
+ if ( !empty( $id ) ) {
129
+ $this->id = $id;
130
+ $this->populate();
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Populate the object with data about the specific activity item.
136
+ */
137
+ public function populate() {
138
+ global $wpdb;
139
+
140
+ $row = wp_cache_get( $this->id, 'bp_activity' );
141
+
142
+ if ( false === $row ) {
143
+ $bp = buddypress();
144
+ $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
145
+
146
+ wp_cache_set( $this->id, $row, 'bp_activity' );
147
+ }
148
+
149
+ if ( ! empty( $row ) ) {
150
+ $this->id = (int) $row->id;
151
+ $this->item_id = (int) $row->item_id;
152
+ $this->secondary_item_id = (int) $row->secondary_item_id;
153
+ $this->user_id = (int) $row->user_id;
154
+ $this->primary_link = $row->primary_link;
155
+ $this->component = $row->component;
156
+ $this->type = $row->type;
157
+ $this->action = $row->action;
158
+ $this->content = $row->content;
159
+ $this->date_recorded = $row->date_recorded;
160
+ $this->hide_sitewide = $row->hide_sitewide;
161
+ $this->mptt_left = (int) $row->mptt_left;
162
+ $this->mptt_right = (int) $row->mptt_right;
163
+ $this->is_spam = $row->is_spam;
164
+ }
165
+
166
+ // Generate dynamic 'action' when possible
167
+ $action = bp_activity_generate_action_string( $this );
168
+ if ( false !== $action ) {
169
+ $this->action = $action;
170
+
171
+ // If no callback is available, use the literal string from
172
+ // the database row
173
+ } elseif ( ! empty( $row->action ) ) {
174
+ $this->action = $row->action;
175
+
176
+ // Provide a fallback to avoid PHP notices
177
+ } else {
178
+ $this->action = '';
179
+ }
180
+ }
181
+
182
+ /**
183
+ * Save the activity item to the database.
184
+ *
185
+ * @return bool True on success.
186
+ */
187
+ public function save() {
188
+ global $wpdb;
189
+
190
+ $bp = buddypress();
191
+
192
+ $this->id = apply_filters_ref_array( 'bp_activity_id_before_save', array( $this->id, &$this ) );
193
+ $this->item_id = apply_filters_ref_array( 'bp_activity_item_id_before_save', array( $this->item_id, &$this ) );
194
+ $this->secondary_item_id = apply_filters_ref_array( 'bp_activity_secondary_item_id_before_save', array( $this->secondary_item_id, &$this ) );
195
+ $this->user_id = apply_filters_ref_array( 'bp_activity_user_id_before_save', array( $this->user_id, &$this ) );
196
+ $this->primary_link = apply_filters_ref_array( 'bp_activity_primary_link_before_save', array( $this->primary_link, &$this ) );
197
+ $this->component = apply_filters_ref_array( 'bp_activity_component_before_save', array( $this->component, &$this ) );
198
+ $this->type = apply_filters_ref_array( 'bp_activity_type_before_save', array( $this->type, &$this ) );
199
+ $this->action = apply_filters_ref_array( 'bp_activity_action_before_save', array( $this->action, &$this ) );
200
+ $this->content = apply_filters_ref_array( 'bp_activity_content_before_save', array( $this->content, &$this ) );
201
+ $this->date_recorded = apply_filters_ref_array( 'bp_activity_date_recorded_before_save', array( $this->date_recorded, &$this ) );
202
+ $this->hide_sitewide = apply_filters_ref_array( 'bp_activity_hide_sitewide_before_save', array( $this->hide_sitewide, &$this ) );
203
+ $this->mptt_left = apply_filters_ref_array( 'bp_activity_mptt_left_before_save', array( $this->mptt_left, &$this ) );
204
+ $this->mptt_right = apply_filters_ref_array( 'bp_activity_mptt_right_before_save', array( $this->mptt_right, &$this ) );
205
+ $this->is_spam = apply_filters_ref_array( 'bp_activity_is_spam_before_save', array( $this->is_spam, &$this ) );
206
+
207
+ /**
208
+ * Fires before the current activity item gets saved.
209
+ *
210
+ * Please use this hook to filter the properties above. Each part will be passed in.
211
+ *
212
+ * @since BuddyPress (1.0.0)
213
+ *
214
+ * @param BP_Activity_Activity Current instance of the activity item being saved.
215
+ */
216
+ do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
217
+
218
+ if ( empty( $this->component ) || empty( $this->type ) ) {
219
+ return false;
220
+ }
221
+
222
+ if ( empty( $this->primary_link ) ) {
223
+ $this->primary_link = bp_loggedin_user_domain();
224
+ }
225
+
226
+ // If we have an existing ID, update the activity item, otherwise insert it.
227
+ if ( ! empty( $this->id ) ) {
228
+ $q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %d, secondary_item_id = %d, hide_sitewide = %d, is_spam = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam, $this->id );
229
+ } else {
230
+ $q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam );
231
+ }
232
+
233
+ if ( false === $wpdb->query( $q ) ) {
234
+ return false;
235
+ }
236
+
237
+ // If this is a new activity item, set the $id property
238
+ if ( empty( $this->id ) ) {
239
+ $this->id = $wpdb->insert_id;
240
+
241
+ // If an existing activity item, prevent any changes to the content generating new @mention notifications.
242
+ } else {
243
+ add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
244
+ }
245
+
246
+ /**
247
+ * Fires after an activity item has been saved to the database.
248
+ *
249
+ * @since BuddyPress (1.0.0)
250
+ *
251
+ * @param BP_Activity_Activity Reference to current instance of activity being saved.
252
+ */
253
+ do_action_ref_array( 'bp_activity_after_save', array( &$this ) );
254
+
255
+ return true;
256
+ }
257
+
258
+ /** Static Methods ***************************************************/
259
+
260
+ /**
261
+ * Get activity items, as specified by parameters
262
+ *
263
+ * @see BP_Activity_Activity::get_filter_sql() for a description of the
264
+ * 'filter' parameter.
265
+ * @see WP_Meta_Query::queries for a description of the 'meta_query'
266
+ * parameter format.
267
+ *
268
+ * @param array $args {
269
+ * An array of arguments. All items are optional.
270
+ *
271
+ * @type int $page Which page of results to fetch. Using page=1 without per_page will result
272
+ * in no pagination. Default: 1.
273
+ * @type int|bool $per_page Number of results per page. Default: 25.
274
+ * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
275
+ * @type string $sort ASC or DESC. Default: 'DESC'.
276
+ * @type array $exclude Array of activity IDs to exclude. Default: false.
277
+ * @type array $in Array of ids to limit query by (IN). Default: false.
278
+ * @type array $meta_query Array of meta_query conditions. See WP_Meta_Query::queries.
279
+ * @type array $date_query Array of date_query conditions. See first parameter of
280
+ * WP_Date_Query::__construct().
281
+ * @type array $filter_query Array of advanced query conditions. See BP_Activity_Query::__construct().
282
+ * @type string|array $scope Pre-determined set of activity arguments.
283
+ * @type array $filter See BP_Activity_Activity::get_filter_sql().
284
+ * @type string $search_terms Limit results by a search term. Default: false.
285
+ * @type bool $display_comments Whether to include activity comments. Default: false.
286
+ * @type bool $show_hidden Whether to show items marked hide_sitewide. Default: false.
287
+ * @type string $spam Spam status. Default: 'ham_only'.
288
+ * @type bool $update_meta_cache Whether to pre-fetch metadata for queried activity items. Default: true.
289
+ * @type string|bool $count_total If true, an additional DB query is run to count the total activity items
290
+ * for the query. Default: false.
291
+ * }
292
+ * @return array The array returned has two keys:
293
+ * - 'total' is the count of located activities
294
+ * - 'activities' is an array of the located activities
295
+ */
296
+ public static function get( $args = array() ) {
297
+ global $wpdb;
298
+
299
+ // Backward compatibility with old method of passing arguments
300
+ if ( !is_array( $args ) || func_num_args() > 1 ) {
301
+ _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
302
+
303
+ $old_args_keys = array(
304
+ 0 => 'max',
305
+ 1 => 'page',
306
+ 2 => 'per_page',
307
+ 3 => 'sort',
308
+ 4 => 'search_terms',
309
+ 5 => 'filter',
310
+ 6 => 'display_comments',
311
+ 7 => 'show_hidden',
312
+ 8 => 'exclude',
313
+ 9 => 'in',
314
+ 10 => 'spam'
315
+ );
316
+
317
+ $func_args = func_get_args();
318
+ $args = bp_core_parse_args_array( $old_args_keys, $func_args );
319
+ }
320
+
321
+ $bp = buddypress();
322
+ $r = wp_parse_args( $args, array(
323
+ 'page' => 1, // The current page
324
+ 'per_page' => 25, // Activity items per page
325
+ 'max' => false, // Max number of items to return
326
+ 'sort' => 'DESC', // ASC or DESC
327
+ 'exclude' => false, // Array of ids to exclude
328
+ 'in' => false, // Array of ids to limit query by (IN)
329
+ 'meta_query' => false, // Filter by activitymeta
330
+ 'date_query' => false, // Filter by date
331
+ 'filter_query' => false, // Advanced filtering - see BP_Activity_Query
332
+ 'filter' => false, // See self::get_filter_sql()
333
+ 'scope' => false, // Preset activity arguments
334
+ 'search_terms' => false, // Terms to search by
335
+ 'display_comments' => false, // Whether to include activity comments
336
+ 'show_hidden' => false, // Show items marked hide_sitewide
337
+ 'spam' => 'ham_only', // Spam status
338
+ 'update_meta_cache' => true,
339
+ 'count_total' => false,
340
+ ) );
341
+
342
+ // Select conditions
343
+ $select_sql = "SELECT DISTINCT a.id";
344
+
345
+ $from_sql = " FROM {$bp->activity->table_name} a";
346
+
347
+ $join_sql = '';
348
+
349
+ // Where conditions
350
+ $where_conditions = array();
351
+
352
+ // Excluded types
353
+ $excluded_types = array();
354
+
355
+ // Scope takes precedence
356
+ if ( ! empty( $r['scope'] ) ) {
357
+ $scope_query = self::get_scope_query_sql( $r['scope'], $r );
358
+
359
+ // Add our SQL conditions if matches were found
360
+ if ( ! empty( $scope_query['sql'] ) ) {
361
+ $where_conditions['scope_query_sql'] = $scope_query['sql'];
362
+ }
363
+
364
+ // override some arguments if needed
365
+ if ( ! empty( $scope_query['override'] ) ) {
366
+ $r = self::array_replace_recursive( $r, $scope_query['override'] );
367
+ }
368
+
369
+ // Advanced filtering
370
+ } elseif ( ! empty( $r['filter_query'] ) ) {
371
+ $filter_query = new BP_Activity_Query( $r['filter_query'] );
372
+ $sql = $filter_query->get_sql();
373
+ if ( ! empty( $sql ) ) {
374
+ $where_conditions['filter_query_sql'] = $sql;
375
+ }
376
+ }
377
+
378
+ // Regular filtering
379
+ if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
380
+ $where_conditions['filter_sql'] = $filter_sql;
381
+ }
382
+
383
+ // Spam
384
+ if ( 'ham_only' == $r['spam'] ) {
385
+ $where_conditions['spam_sql'] = 'a.is_spam = 0';
386
+ } elseif ( 'spam_only' == $r['spam'] ) {
387
+ $where_conditions['spam_sql'] = 'a.is_spam = 1';
388
+ }
389
+
390
+ // Searching
391
+ if ( $r['search_terms'] ) {
392
+ $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
393
+ $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
394
+ }
395
+
396
+ // Sorting
397
+ $sort = $r['sort'];
398
+ if ( $sort != 'ASC' && $sort != 'DESC' ) {
399
+ $sort = 'DESC';
400
+ }
401
+
402
+ // Hide Hidden Items?
403
+ if ( ! $r['show_hidden'] ) {
404
+ $where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
405
+ }
406
+
407
+ // Exclude specified items
408
+ if ( ! empty( $r['exclude'] ) ) {
409
+ $exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
410
+ $where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
411
+ }
412
+
413
+ // The specific ids to which you want to limit the query
414
+ if ( ! empty( $r['in'] ) ) {
415
+ $in = implode( ',', wp_parse_id_list( $r['in'] ) );
416
+ $where_conditions['in'] = "a.id IN ({$in})";
417
+ }
418
+
419
+ // Process meta_query into SQL
420
+ $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
421
+
422
+ if ( ! empty( $meta_query_sql['join'] ) ) {
423
+ $join_sql .= $meta_query_sql['join'];
424
+ }
425
+
426
+ if ( ! empty( $meta_query_sql['where'] ) ) {
427
+ $where_conditions[] = $meta_query_sql['where'];
428
+ }
429
+
430
+ // Process date_query into SQL
431
+ $date_query_sql = self::get_date_query_sql( $r['date_query'] );
432
+
433
+ if ( ! empty( $date_query_sql ) ) {
434
+ $where_conditions['date'] = $date_query_sql;
435
+ }
436
+
437
+ // Alter the query based on whether we want to show activity item
438
+ // comments in the stream like normal comments or threaded below
439
+ // the activity.
440
+ if ( false === $r['display_comments'] || 'threaded' === $r['display_comments'] ) {
441
+ $excluded_types[] = 'activity_comment';
442
+ }
443
+
444
+ // Exclude 'last_activity' items unless the 'action' filter has
445
+ // been explicitly set
446
+ if ( empty( $r['filter']['object'] ) ) {
447
+ $excluded_types[] = 'last_activity';
448
+ }
449
+
450
+ // Build the excluded type sql part
451
+ if ( ! empty( $excluded_types ) ) {
452
+ $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
453
+ $where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
454
+ }
455
+
456
+ /**
457
+ * Filters the MySQL WHERE conditions for the Activity items get method.
458
+ *
459
+ * @since BuddyPress (1.9.0)
460
+ *
461
+ * @param array $where_conditions Current conditions for MySQL WHERE statement.
462
+ * @param array $r Parsed arguments passed into method.
463
+ * @param string $select_sql Current SELECT MySQL statement at point of execution.
464
+ * @param string $from_sql Current FROM MySQL statement at point of execution.
465
+ * @param string $join_sql Current INNER JOIN MySQL statement at point of execution.
466
+ */
467
+ $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
468
+
469
+ // Join the where conditions together
470
+ $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
471
+
472
+ /**
473
+ * Filters the preferred order of indexes for activity item.
474
+ *
475
+ * @since BuddyPress (1.6.0)
476
+ *
477
+ * @param array Array of indexes in preferred order.
478
+ */
479
+ $indexes = apply_filters( 'bp_activity_preferred_index_order', array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ) );
480
+
481
+ foreach( $indexes as $key => $index ) {
482
+ if ( false !== strpos( $where_sql, $index ) ) {
483
+ $the_index = $index;
484
+ break; // Take the first one we find
485
+ }
486
+ }
487
+
488
+ if ( !empty( $the_index ) ) {
489
+ $index_hint_sql = "USE INDEX ({$the_index})";
490
+ } else {
491
+ $index_hint_sql = '';
492
+ }
493
+
494
+ // Sanitize page and per_page parameters
495
+ $page = absint( $r['page'] );
496
+ $per_page = absint( $r['per_page'] );
497
+
498
+ $retval = array(
499
+ 'activities' => null,
500
+ 'total' => null,
501
+ 'has_more_items' => null,
502
+ );
503
+
504
+ /**
505
+ * Filters if BuddyPress should use legacy query structure over current structure for version 2.0+.
506
+ *
507
+ * It is not recommended to use the legacy structure, but allowed to if needed.
508
+ *
509
+ * @since BuddyPress (2.0.0)
510
+ *
511
+ * @param bool Whether to use legacy structure or not.
512
+ * @param BP_Activity_Activity Current method being called.
513
+ * @param array $r Parsed arguments passed into method.
514
+ */
515
+ if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
516
+
517
+ // Legacy queries joined against the user table
518
+ $select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
519
+ $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
520
+
521
+ if ( ! empty( $page ) && ! empty( $per_page ) ) {
522
+ $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
523
+
524
+ /** this filter is documented in bp-activity/bp-activity-classes.php */
525
+ $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
526
+ } else {
527
+ $pag_sql = '';
528
+
529
+ /**
530
+ * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
531
+ *
532
+ * @since BuddyPress (1.5.0)
533
+ *
534
+ * @param string Concatenated MySQL statement pieces to be query results with for legacy query.
535
+ * @param string $select_sql Final SELECT MySQL statement portion for legacy query.
536
+ * @param string $from_sql Final FROM MySQL statement portion for legacy query.
537
+ * @param string $where_sql Final WHERE MySQL statement portion for legacy query.
538
+ * @param string $sort Final sort direction for legacy query.
539
+ */
540
+ $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
541
+ }
542
+
543
+ } else {
544
+ // Query first for activity IDs
545
+ $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
546
+
547
+ if ( ! empty( $per_page ) && ! empty( $page ) ) {
548
+ // We query for $per_page + 1 items in order to
549
+ // populate the has_more_items flag
550
+ $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
551
+ }
552
+
553
+ /**
554
+ * Filters the paged activities MySQL statement.
555
+ *
556
+ * @since BuddyPress (2.0.0)
557
+ *
558
+ * @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
559
+ * @param array $r Array of arguments passed into method.
560
+ */
561
+ $activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
562
+
563
+ $activity_ids = $wpdb->get_col( $activity_ids_sql );
564
+
565
+ $retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
566
+
567
+ // If we've fetched more than the $per_page value, we
568
+ // can discard the extra now
569
+ if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
570
+ array_pop( $activity_ids );
571
+ }
572
+
573
+ $activities = self::get_activity_data( $activity_ids );
574
+ }
575
+
576
+ // Get the fullnames of users so we don't have to query in the loop
577
+ $activities = self::append_user_fullnames( $activities );
578
+
579
+ // Get activity meta
580
+ $activity_ids = array();
581
+ foreach ( (array) $activities as $activity ) {
582
+ $activity_ids[] = $activity->id;
583
+ }
584
+
585
+ if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
586
+ bp_activity_update_meta_cache( $activity_ids );
587
+ }
588
+
589
+ if ( $activities && $r['display_comments'] ) {
590
+ $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
591
+ }
592
+
593
+ // Pre-fetch data associated with activity users and other objects
594
+ BP_Activity_Activity::prefetch_object_data( $activities );
595
+
596
+ // Generate action strings
597
+ $activities = BP_Activity_Activity::generate_action_strings( $activities );
598
+
599
+ $retval['activities'] = $activities;
600
+
601
+ // If $max is set, only return up to the max results
602
+ if ( ! empty( $r['count_total'] ) ) {
603
+
604
+ /**
605
+ * Filters the total activities MySQL statement.
606
+ *
607
+ * @since BuddyPress (1.5.0)
608
+ *
609
+ * @param string MySQL statement used to query for total activities.
610
+ * @param string $where_sql MySQL WHERE statement portion.
611
+ * @param string $sort sort direction for query.
612
+ */
613
+ $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
614
+ $total_activities = $wpdb->get_var( $total_activities_sql );
615
+
616
+ if ( !empty( $r['max'] ) ) {
617
+ if ( (int) $total_activities > (int) $r['max'] ) {
618
+ $total_activities = $r['max'];
619
+ }
620
+ }
621
+
622
+ $retval['total'] = $total_activities;
623
+ }
624
+
625
+ return $retval;
626
+ }
627
+
628
+ /**
629
+ * Convert activity IDs to activity objects, as expected in template loop.
630
+ *
631
+ * @since 2.0
632
+ *
633
+ * @param array $activity_ids Array of activity IDs.
634
+ * @return array
635
+ */
636
+ protected static function get_activity_data( $activity_ids = array() ) {
637
+ global $wpdb;
638
+
639
+ // Bail if no activity ID's passed
640
+ if ( empty( $activity_ids ) ) {
641
+ return array();
642
+ }
643
+
644
+ // Get BuddyPress
645
+ $bp = buddypress();
646
+
647
+ $activities = array();
648
+ $uncached_ids = bp_get_non_cached_ids( $activity_ids, 'bp_activity' );
649
+
650
+ // Prime caches as necessary
651
+ if ( ! empty( $uncached_ids ) ) {
652
+ // Format the activity ID's for use in the query below
653
+ $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
654
+
655
+ // Fetch data from activity table, preserving order
656
+ $queried_adata = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$uncached_ids_sql})");
657
+
658
+ // Put that data into the placeholders created earlier,
659
+ // and add it to the cache
660
+ foreach ( (array) $queried_adata as $adata ) {
661
+ wp_cache_set( $adata->id, $adata, 'bp_activity' );
662
+ }
663
+ }
664
+
665
+ // Now fetch data from the cache
666
+ foreach ( $activity_ids as $activity_id ) {
667
+ $activities[] = wp_cache_get( $activity_id, 'bp_activity' );
668
+ }
669
+
670
+ // Then fetch user data
671
+ $user_query = new BP_User_Query( array(
672
+ 'user_ids' => wp_list_pluck( $activities, 'user_id' ),
673
+ 'populate_extras' => false,
674
+ ) );
675
+
676
+ // Associated located user data with activity items
677
+ foreach ( $activities as $a_index => $a_item ) {
678
+ $a_user_id = intval( $a_item->user_id );
679
+ $a_user = isset( $user_query->results[ $a_user_id ] ) ? $user_query->results[ $a_user_id ] : '';
680
+
681
+ if ( !empty( $a_user ) ) {
682
+ $activities[ $a_index ]->user_email = $a_user->user_email;
683
+ $activities[ $a_index ]->user_nicename = $a_user->user_nicename;
684
+ $activities[ $a_index ]->user_login = $a_user->user_login;
685
+ $activities[ $a_index ]->display_name = $a_user->display_name;
686
+ }
687
+ }
688
+
689
+ return $activities;
690
+ }
691
+
692
+ /**
693
+ * Append xProfile fullnames to an activity array.
694
+ *
695
+ * @since BuddyPress (2.0.0)
696
+ *
697
+ * @param array $activities Activities array.
698
+ * @return array
699
+ */
700
+ protected static function append_user_fullnames( $activities ) {
701
+
702
+ if ( bp_is_active( 'xprofile' ) && ! empty( $activities ) ) {
703
+ $activity_user_ids = wp_list_pluck( $activities, 'user_id' );
704
+
705
+ if ( ! empty( $activity_user_ids ) ) {
706
+ $fullnames = bp_core_get_user_displaynames( $activity_user_ids );
707
+ if ( ! empty( $fullnames ) ) {
708
+ foreach ( (array) $activities as $i => $activity ) {
709
+ if ( ! empty( $fullnames[ $activity->user_id ] ) ) {
710
+ $activities[ $i ]->user_fullname = $fullnames[ $activity->user_id ];
711
+ }
712
+ }
713
+ }
714
+ }
715
+ }
716
+
717
+ return $activities;
718
+ }
719
+
720
+ /**
721
+ * Pre-fetch data for objects associated with activity items.
722
+ *
723
+ * Activity items are associated with users, and often with other
724
+ * BuddyPress data objects. Here, we pre-fetch data about these
725
+ * associated objects, so that inline lookups - done primarily when
726
+ * building action strings - do not result in excess database queries.
727
+ *
728
+ * The only object data required for activity component activity types
729
+ * (activity_update and activity_comment) is related to users, and that
730
+ * info is fetched separately in BP_Activity_Activity::get_activity_data().
731
+ * So this method contains nothing but a filter that allows other
732
+ * components, such as bp-friends and bp-groups, to hook in and prime
733
+ * their own caches at the beginning of an activity loop.
734
+ *
735
+ * @since BuddyPress (2.0.0)
736
+ *
737
+ * @param array $activities Array of activities.
738
+ */
739
+ protected static function prefetch_object_data( $activities ) {
740
+
741
+ /**
742
+ * Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
743
+ *
744
+ * @since BuddyPress (2.0.0)
745
+ *
746
+ * @param array $activities Array of activities.
747
+ */
748
+ return apply_filters( 'bp_activity_prefetch_object_data', $activities );
749
+ }
750
+
751
+ /**
752
+ * Generate action strings for the activities located in BP_Activity_Activity::get().
753
+ *
754
+ * If no string can be dynamically generated for a given item
755
+ * (typically because the activity type has not been properly
756
+ * registered), the static 'action' value pulled from the database will
757
+ * be left in place.
758
+ *
759
+ * @since BuddyPress (2.0.0)
760
+ *
761
+ * @param array $activities Array of activities.
762
+ * @return array
763
+ */
764
+ protected static function generate_action_strings( $activities ) {
765
+ foreach ( $activities as $key => $activity ) {
766
+ $generated_action = bp_activity_generate_action_string( $activity );
767
+ if ( false !== $generated_action ) {
768
+ $activity->action = $generated_action;
769
+ }
770
+
771
+ $activities[ $key ] = $activity;
772
+ }
773
+
774
+ return $activities;
775
+ }
776
+
777
+ /**
778
+ * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get().
779
+ *
780
+ * We use WP_Meta_Query to do the heavy lifting of parsing the
781
+ * meta_query array and creating the necessary SQL clauses. However,
782
+ * since BP_Activity_Activity::get() builds its SQL differently than
783
+ * WP_Query, we have to alter the return value (stripping the leading
784
+ * AND keyword from the 'where' clause).
785
+ *
786
+ * @since BuddyPress (1.8)
787
+ *
788
+ * @param array $meta_query An array of meta_query filters. See the
789
+ * documentation for WP_Meta_Query for details.
790
+ * @return array $sql_array 'join' and 'where' clauses.
791
+ */
792
+ public static function get_meta_query_sql( $meta_query = array() ) {
793
+ global $wpdb;
794
+
795
+ $sql_array = array(
796
+ 'join' => '',
797
+ 'where' => '',
798
+ );
799
+
800
+ if ( ! empty( $meta_query ) ) {
801
+ $activity_meta_query = new WP_Meta_Query( $meta_query );
802
+
803
+ // WP_Meta_Query expects the table name at
804
+ // $wpdb->activitymeta
805
+ $wpdb->activitymeta = buddypress()->activity->table_name_meta;
806
+
807
+ $meta_sql = $activity_meta_query->get_sql( 'activity', 'a', 'id' );
808
+
809
+ // Strip the leading AND - BP handles it in get()
810
+ $sql_array['where'] = preg_replace( '/^\sAND/', '', $meta_sql['where'] );
811
+ $sql_array['join'] = $meta_sql['join'];
812
+ }
813
+
814
+ return $sql_array;
815
+ }
816
+
817
+ /**
818
+ * Get the SQL for the 'date_query' param in BP_Activity_Activity::get().
819
+ *
820
+ * We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
821
+ * of parsing the date_query array and creating the necessary SQL clauses.
822
+ * However, since BP_Activity_Activity::get() builds its SQL differently than
823
+ * WP_Query, we have to alter the return value (stripping the leading AND
824
+ * keyword from the query).
825
+ *
826
+ * @since BuddyPress (2.1.0)
827
+ *
828
+ * @param array $date_query An array of date_query parameters. See the
829
+ * documentation for the first parameter of WP_Date_Query.
830
+ * @return string
831
+ */
832
+ public static function get_date_query_sql( $date_query = array() ) {
833
+ $sql = '';
834
+
835
+ // Date query
836
+ if ( ! empty( $date_query ) && is_array( $date_query ) && class_exists( 'BP_Date_Query' ) ) {
837
+ $date_query = new BP_Date_Query( $date_query, 'date_recorded' );
838
+ $sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
839
+ }
840
+
841
+ return $sql;
842
+ }
843
+
844
+ /**
845
+ * Get the SQL for the 'scope' param in BP_Activity_Activity::get().
846
+ *
847
+ * A scope is a predetermined set of activity arguments. This method is used
848
+ * to grab these activity arguments and override any existing args if needed.
849
+ *
850
+ * Can handle multiple scopes.
851
+ *
852
+ * @since BuddyPress (2.2.0)
853
+ *
854
+ * @param mixed $scope The activity scope. Accepts string or array of scopes
855
+ * @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),
856
+ * but merged with defaults.
857
+ * @return array 'sql' WHERE SQL string and 'override' activity args
858
+ */
859
+ public static function get_scope_query_sql( $scope = false, $r = array() ) {
860
+
861
+ // Define arrays for future use
862
+ $query_args = array();
863
+ $override = array();
864
+ $retval = array();
865
+
866
+ // Check for array of scopes
867
+ if ( is_array( $scope ) ) {
868
+ $scopes = $scope;
869
+
870
+ // Explode a comma separated string of scopes
871
+ } elseif ( is_string( $scope ) ) {
872
+ $scopes = explode( ',', $scope );
873
+ }
874
+
875
+ // Bail if no scope passed
876
+ if ( empty( $scopes ) ) {
877
+ return false;
878
+ }
879
+
880
+ // Helper to easily grab the 'user_id'
881
+ if ( ! empty( $r['filter']['user_id'] ) ) {
882
+ $r['user_id'] = $r['filter']['user_id'];
883
+ }
884
+
885
+ // parse each scope; yes! we handle multiples!
886
+ foreach ( $scopes as $scope ) {
887
+ $scope_args = array();
888
+
889
+ /**
890
+ * Plugins can hook here to set their activity arguments for custom scopes.
891
+ *
892
+ * This is a dynamic filter based on the activity scope. eg:
893
+ * - 'bp_activity_set_groups_scope_args'
894
+ * - 'bp_activity_set_friends_scope_args'
895
+ *
896
+ * To see how this filter is used, plugin devs should check out:
897
+ * - bp_groups_filter_activity_scope() - used for 'groups' scope
898
+ * - bp_friends_filter_activity_scope() - used for 'friends' scope
899
+ *
900
+ * @since BuddyPress (2.2.0)
901
+ *
902
+ * @param array {
903
+ * Activity query clauses.
904
+ *
905
+ * @type array {
906
+ * Activity arguments for your custom scope.
907
+ * See {@link BP_Activity_Query::_construct()} for more details.
908
+ * }
909
+ * @type array $override Optional. Override existing activity arguments passed by $r.
910
+ * }
911
+ * @param array $r Current activity arguments passed in BP_Activity_Activity::get()
912
+ */
913
+ $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r );
914
+
915
+ if ( ! empty( $scope_args ) ) {
916
+ // merge override properties from other scopes
917
+ // this might be a problem...
918
+ if ( ! empty( $scope_args['override'] ) ) {
919
+ $override = array_merge( $override, $scope_args['override'] );
920
+ unset( $scope_args['override'] );
921
+ }
922
+
923
+ // save scope args
924
+ if ( ! empty( $scope_args ) ) {
925
+ $query_args[] = $scope_args;
926
+ }
927
+ }
928
+ }
929
+
930
+ if ( ! empty( $query_args ) ) {
931
+ // set relation to OR
932
+ $query_args['relation'] = 'OR';
933
+
934
+ $query = new BP_Activity_Query( $query_args );
935
+ $sql = $query->get_sql();
936
+ if ( ! empty( $sql ) ) {
937
+ $retval['sql'] = $sql;
938
+ }
939
+ }
940
+
941
+ if ( ! empty( $override ) ) {
942
+ $retval['override'] = $override;
943
+ }
944
+
945
+ return $retval;
946
+ }
947
+
948
+ /**
949
+ * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
950
+ *
951
+ * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
952
+ *
953
+ * @since BuddyPress (1.2)
954
+ *
955
+ * @deprecated 1.5
956
+ * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
957
+ *
958
+ * @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve
959
+ * @param int $max Maximum number of results to return. (Optional; default is no maximum)
960
+ * @param int $page The set of results that the user is viewing. Used in pagination. (Optional; default is 1)
961
+ * @param int $per_page Specifies how many results per page. Used in pagination. (Optional; default is 25)
962
+ * @param string MySQL column sort; ASC or DESC. (Optional; default is DESC)
963
+ * @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false)
964
+ * @return array
965
+ */
966
+ public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
967
+ _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
968
+ return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
969
+ }
970
+
971
+ /**
972
+ * Get the first activity ID that matches a set of criteria.
973
+ *
974
+ * @param int $user_id User ID to filter by
975
+ * @param string $component Component to filter by
976
+ * @param string $type Activity type to filter by
977
+ * @param int $item_id Associated item to filter by
978
+ * @param int $secondary_item_id Secondary associated item to filter by
979
+ * @param string $action Action to filter by
980
+ * @param string $content Content to filter by
981
+ * @param string $date_recorded Date to filter by
982
+ *
983
+ * @todo Should parameters be optional?
984
+ *
985
+ * @return int|bool Activity ID on success, false if none is found.
986
+ */
987
+ public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
988
+ global $wpdb;
989
+
990
+ $bp = buddypress();
991
+
992
+ $where_args = false;
993
+
994
+ if ( ! empty( $user_id ) ) {
995
+ $where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
996
+ }
997
+
998
+ if ( ! empty( $component ) ) {
999
+ $where_args[] = $wpdb->prepare( "component = %s", $component );
1000
+ }
1001
+
1002
+ if ( ! empty( $type ) ) {
1003
+ $where_args[] = $wpdb->prepare( "type = %s", $type );
1004
+ }
1005
+
1006
+ if ( ! empty( $item_id ) ) {
1007
+ $where_args[] = $wpdb->prepare( "item_id = %d", $item_id );
1008
+ }
1009
+
1010
+ if ( ! empty( $secondary_item_id ) ) {
1011
+ $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id );
1012
+ }
1013
+
1014
+ if ( ! empty( $action ) ) {
1015
+ $where_args[] = $wpdb->prepare( "action = %s", $action );
1016
+ }
1017
+
1018
+ if ( ! empty( $content ) ) {
1019
+ $where_args[] = $wpdb->prepare( "content = %s", $content );
1020
+ }
1021
+
1022
+ if ( ! empty( $date_recorded ) ) {
1023
+ $where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
1024
+ }
1025
+
1026
+ if ( ! empty( $where_args ) ) {
1027
+ $where_sql = 'WHERE ' . join( ' AND ', $where_args );
1028
+ return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
1029
+ }
1030
+
1031
+ return false;
1032
+ }
1033
+
1034
+ /**
1035
+ * Delete activity items from the database.
1036
+ *
1037
+ * To delete a specific activity item, pass an 'id' parameter.
1038
+ * Otherwise use the filters.
1039
+ *
1040
+ * @since BuddyPress (1.2)
1041
+ *
1042
+ * @param array $args {
1043
+ * @int $id Optional. The ID of a specific item to delete.
1044
+ * @string $action Optional. The action to filter by.
1045
+ * @string $content Optional. The content to filter by.
1046
+ * @string $component Optional. The component name to filter by.
1047
+ * @string $type Optional. The activity type to filter by.
1048
+ * @string $primary_link Optional. The primary URL to filter by.
1049
+ * @int $user_id Optional. The user ID to filter by.
1050
+ * @int $item_id Optional. The associated item ID to filter by.
1051
+ * @int $secondary_item_id Optional. The secondary associated item ID to filter by.
1052
+ * @string $date_recorded Optional. The date to filter by.
1053
+ * @int $hide_sitewide Optional. Default: false.
1054
+ * }
1055
+ * @return array|bool An array of deleted activity IDs on success, false on failure.
1056
+ */
1057
+ public static function delete( $args = array() ) {
1058
+ global $wpdb;
1059
+
1060
+ $bp = buddypress();
1061
+
1062
+ $defaults = array(
1063
+ 'id' => false,
1064
+ 'action' => false,
1065
+ 'content' => false,
1066
+ 'component' => false,
1067
+ 'type' => false,
1068
+ 'primary_link' => false,
1069
+ 'user_id' => false,
1070
+ 'item_id' => false,
1071
+ 'secondary_item_id' => false,
1072
+ 'date_recorded' => false,
1073
+ 'hide_sitewide' => false
1074
+ );
1075
+ $params = wp_parse_args( $args, $defaults );
1076
+ extract( $params );
1077
+
1078
+ $where_args = false;
1079
+
1080
+ if ( !empty( $id ) )
1081
+ $where_args[] = $wpdb->prepare( "id = %d", $id );
1082
+
1083
+ if ( !empty( $user_id ) )
1084
+ $where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
1085
+
1086
+ if ( !empty( $action ) )
1087
+ $where_args[] = $wpdb->prepare( "action = %s", $action );
1088
+
1089
+ if ( !empty( $content ) )
1090
+ $where_args[] = $wpdb->prepare( "content = %s", $content );
1091
+
1092
+ if ( !empty( $component ) )
1093
+ $where_args[] = $wpdb->prepare( "component = %s", $component );
1094
+
1095
+ if ( !empty( $type ) )
1096
+ $where_args[] = $wpdb->prepare( "type = %s", $type );
1097
+
1098
+ if ( !empty( $primary_link ) )
1099
+ $where_args[] = $wpdb->prepare( "primary_link = %s", $primary_link );
1100
+
1101
+ if ( !empty( $item_id ) )
1102
+ $where_args[] = $wpdb->prepare( "item_id = %d", $item_id );
1103
+
1104
+ if ( !empty( $secondary_item_id ) )
1105
+ $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id );
1106
+
1107
+ if ( !empty( $date_recorded ) )
1108
+ $where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
1109
+
1110
+ if ( !empty( $hide_sitewide ) )
1111
+ $where_args[] = $wpdb->prepare( "hide_sitewide = %d", $hide_sitewide );
1112
+
1113
+ if ( !empty( $where_args ) )
1114
+ $where_sql = 'WHERE ' . join( ' AND ', $where_args );
1115
+ else
1116
+ return false;
1117
+
1118
+ // Fetch the activity IDs so we can delete any comments for this activity item
1119
+ $activity_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
1120
+
1121
+ if ( ! $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) ) {
1122
+ return false;
1123
+ }
1124
+
1125
+ // Handle accompanying activity comments and meta deletion
1126
+ if ( $activity_ids ) {
1127
+ $activity_ids_comma = implode( ',', wp_parse_id_list( $activity_ids ) );
1128
+ $activity_comments_where_sql = "WHERE type = 'activity_comment' AND item_id IN ({$activity_ids_comma})";
1129
+
1130
+ // Fetch the activity comment IDs for our deleted activity items
1131
+ $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$activity_comments_where_sql}" );
1132
+
1133
+ // We have activity comments!
1134
+ if ( ! empty( $activity_comment_ids ) ) {
1135
+ // Delete activity comments
1136
+ $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$activity_comments_where_sql}" );
1137
+
1138
+ // Merge activity IDs with activity comment IDs
1139
+ $activity_ids = array_merge( $activity_ids, $activity_comment_ids );
1140
+ }
1141
+
1142
+ // Delete all activity meta entries for activity items and activity comments
1143
+ BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
1144
+ }
1145
+
1146
+ return $activity_ids;
1147
+ }
1148
+
1149
+ /**
1150
+ * Delete the comments associated with a set of activity items.
1151
+ *
1152
+ * @since BuddyPress (1.2)
1153
+ *
1154
+ * @todo Mark as deprecated? Method is no longer used internally.
1155
+ *
1156
+ * @param array $activity_ids Activity IDs whose comments should be deleted.
1157
+ * @param bool $delete_meta Should we delete the activity meta items for these comments?
1158
+ * @return bool True on success.
1159
+ */
1160
+ public static function delete_activity_item_comments( $activity_ids = array(), $delete_meta = true ) {
1161
+ global $wpdb;
1162
+
1163
+ $bp = buddypress();
1164
+
1165
+ $delete_meta = (bool) $delete_meta;
1166
+ $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
1167
+
1168
+ if ( $delete_meta ) {
1169
+ // Fetch the activity comment IDs for our deleted activity items
1170
+ $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
1171
+
1172
+ if ( ! empty( $activity_comment_ids ) ) {
1173
+ self::delete_activity_meta_entries( $activity_comment_ids );
1174
+ }
1175
+ }
1176
+
1177
+ return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
1178
+ }
1179
+
1180
+ /**
1181
+ * Delete the meta entries associated with a set of activity items.
1182
+ *
1183
+ * @since BuddyPress (1.2)
1184
+ *
1185
+ * @param array $activity_ids Activity IDs whose meta should be deleted.
1186
+ * @return bool True on success.
1187
+ */
1188
+ public static function delete_activity_meta_entries( $activity_ids = array() ) {
1189
+ $activity_ids = wp_parse_id_list( $activity_ids );
1190
+
1191
+ foreach ( $activity_ids as $activity_id ) {
1192
+ bp_activity_delete_meta( $activity_id );
1193
+ }
1194
+
1195
+ return true;
1196
+ }
1197
+
1198
+ /**
1199
+ * Append activity comments to their associated activity items.
1200
+ *
1201
+ * @since BuddyPress (1.2)
1202
+ *
1203
+ * @global wpdb $wpdb WordPress database object
1204
+ *
1205
+ * @param array $activities Activities to fetch comments for.
1206
+ * @param bool $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
1207
+ * @return array The updated activities with nested comments.
1208
+ */
1209
+ public static function append_comments( $activities, $spam = 'ham_only' ) {
1210
+ $activity_comments = array();
1211
+
1212
+ // Now fetch the activity comments and parse them into the correct position in the activities array.
1213
+ foreach ( (array) $activities as $activity ) {
1214
+ $top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0;
1215
+ $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );
1216
+ }
1217
+
1218
+ // Merge the comments with the activity items
1219
+ foreach ( (array) $activities as $key => $activity ) {
1220
+ if ( isset( $activity_comments[$activity->id] ) ) {
1221
+ $activities[$key]->children = $activity_comments[$activity->id];
1222
+ }
1223
+ }
1224
+
1225
+ return $activities;
1226
+ }
1227
+
1228
+ /**
1229
+ * Get activity comments that are associated with a specific activity ID.
1230
+ *
1231
+ * @since BuddyPress (1.2)
1232
+ *
1233
+ * @global wpdb $wpdb WordPress database object.
1234
+ *
1235
+ * @param int $activity_id Activity ID to fetch comments for.
1236
+ * @param int $left Left-most node boundary.
1237
+ * @param into $right Right-most node boundary.
1238
+ * @param bool $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
1239
+ * @param int $top_level_parent_id Optional. The id of the root-level parent activity item.
1240
+ * @return array The updated activities with nested comments.
1241
+ */
1242
+ public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
1243
+ global $wpdb;
1244
+
1245
+ if ( empty( $top_level_parent_id ) ) {
1246
+ $top_level_parent_id = $activity_id;
1247
+ }
1248
+
1249
+ $comments = wp_cache_get( $activity_id, 'bp_activity_comments' );
1250
+
1251
+ // We store the string 'none' to cache the fact that the
1252
+ // activity item has no comments
1253
+ if ( 'none' === $comments ) {
1254
+ $comments = false;
1255
+
1256
+ // A true cache miss
1257
+ } elseif ( empty( $comments ) ) {
1258
+
1259
+ $bp = buddypress();
1260
+
1261
+ // Select the user's fullname with the query
1262
+ if ( bp_is_active( 'xprofile' ) ) {
1263
+ $fullname_select = ", pd.value as user_fullname";
1264
+ $fullname_from = ", {$bp->profile->table_name_data} pd ";
1265
+ $fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1";
1266
+
1267
+ // Prevent debug errors
1268
+ } else {
1269
+ $fullname_select = $fullname_from = $fullname_where = '';
1270
+ }
1271
+
1272
+ // Don't retrieve activity comments marked as spam
1273
+ if ( 'ham_only' == $spam ) {
1274
+ $spam_sql = 'AND a.is_spam = 0';
1275
+ } elseif ( 'spam_only' == $spam ) {
1276
+ $spam_sql = 'AND a.is_spam = 1';
1277
+ } else {
1278
+ $spam_sql = '';
1279
+ }
1280
+
1281
+ // Legacy query - not recommended
1282
+ $func_args = func_get_args();
1283
+
1284
+ /**
1285
+ * Filters if BuddyPress should use the legacy activity query.
1286
+ *
1287
+ * @since BuddyPress (2.0.0)
1288
+ *
1289
+ * @param bool Whether or not to use the legacy query.
1290
+ * @param BP_Activity_Activity Magic method referring to currently called method.
1291
+ * @param array $func_args Array of the method's argument list.
1292
+ */
1293
+ if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $func_args ) ) {
1294
+
1295
+ /**
1296
+ * Filters the MySQL prepared statement for the legacy activity query.
1297
+ *
1298
+ * @since BuddyPress (1.5.0)
1299
+ *
1300
+ * @param string Prepared statement for the activity query.
1301
+ * @param int $activity_id Activity ID to fetch comments for.
1302
+ * @param int $left Left-most node boundary.
1303
+ * @param int $right Right-most node boundary.
1304
+ * @param string $spam_sql SQL Statement portion to differentiate between ham or spam.
1305
+ */
1306
+ $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d AND a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right ), $activity_id, $left, $right, $spam_sql );
1307
+
1308
+ $descendants = $wpdb->get_results( $sql );
1309
+
1310
+ // We use the mptt BETWEEN clause to limit returned
1311
+ // descendants to the correct part of the tree.
1312
+ } else {
1313
+ $sql = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} a WHERE a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d and a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right );
1314
+
1315
+ $descendant_ids = $wpdb->get_col( $sql );
1316
+ $descendants = self::get_activity_data( $descendant_ids );
1317
+ $descendants = self::append_user_fullnames( $descendants );
1318
+ }
1319
+
1320
+ $ref = array();
1321
+
1322
+ // Loop descendants and build an assoc array
1323
+ foreach ( (array) $descendants as $d ) {
1324
+ $d->children = array();
1325
+
1326
+ // If we have a reference on the parent
1327
+ if ( isset( $ref[ $d->secondary_item_id ] ) ) {
1328
+ $ref[ $d->secondary_item_id ]->children[ $d->id ] = $d;
1329
+ $ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ];
1330
+
1331
+ // If we don't have a reference on the parent, put in the root level
1332
+ } else {
1333
+ $comments[ $d->id ] = $d;
1334
+ $ref[ $d->id ] =& $comments[ $d->id ];
1335
+ }
1336
+ }
1337
+
1338
+ // Calculate depth for each item
1339
+ foreach ( $ref as &$r ) {
1340
+ $depth = 1;
1341
+ $parent_id = $r->secondary_item_id;
1342
+ while ( $parent_id !== $r->item_id ) {
1343
+ $depth++;
1344
+
1345
+ // When display_comments=stream, the
1346
+ // parent comment may not be part of
1347
+ // the returned results, so we manually
1348
+ // fetch it
1349
+ if ( empty( $ref[ $parent_id ] ) ) {
1350
+ $direct_parent = new BP_Activity_Activity( $parent_id );
1351
+ if ( isset( $direct_parent->secondary_item_id ) ) {
1352
+ $parent_id = $direct_parent->secondary_item_id;
1353
+ } else {
1354
+ // Something went wrong
1355
+ // Short-circuit the
1356
+ // depth calculation
1357
+ $parent_id = $r->item_id;
1358
+ }
1359
+ } else {
1360
+ $parent_id = $ref[ $parent_id ]->secondary_item_id;
1361
+ }
1362
+ }
1363
+ $r->depth = $depth;
1364
+ }
1365
+
1366
+ // If we cache a value of false, it'll count as a cache
1367
+ // miss the next time the activity comments are fetched.
1368
+ // Storing the string 'none' is a hack workaround to
1369
+ // avoid unnecessary queries.
1370
+ if ( false === $comments ) {
1371
+ $cache_value = 'none';
1372
+ } else {
1373
+ $cache_value = $comments;
1374
+ }
1375
+
1376
+ wp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' );
1377
+ }
1378
+
1379
+ return $comments;
1380
+ }
1381
+
1382
+ /**
1383
+ * Rebuild nested comment tree under an activity or activity comment.
1384
+ *
1385
+ * @since BuddyPress (1.2)
1386
+ *
1387
+ * @global wpdb $wpdb WordPress database object
1388
+ *
1389
+ * @param int $parent_id ID of an activity or activity comment
1390
+ * @param int $left Node boundary start for activity or activity comment
1391
+ * @return int Right Node boundary of activity or activity comment
1392
+ */
1393
+ public static function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
1394
+ global $wpdb;
1395
+
1396
+ $bp = buddypress();
1397
+
1398
+ // The right value of this node is the left value + 1
1399
+ $right = intval( $left + 1 );
1400
+
1401
+ // Get all descendants of this node
1402
+ $comments = BP_Activity_Activity::get_child_comments( $parent_id );
1403
+ $descendants = wp_list_pluck( $comments, 'id' );
1404
+
1405
+ // Loop the descendants and recalculate the left and right values
1406
+ foreach ( (array) $descendants as $descendant_id ) {
1407
+ $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );
1408
+ }
1409
+
1410
+ // We've got the left value, and now that we've processed the children
1411
+ // of this node we also know the right value
1412
+ if ( 1 === $left ) {
1413
+ $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
1414
+ } else {
1415
+ $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id ) );
1416
+ }
1417
+
1418
+ // Return the right value of this node + 1
1419
+ return intval( $right + 1 );
1420
+ }
1421
+
1422
+ /**
1423
+ * Get child comments of an activity or activity comment.
1424
+ *
1425
+ * @since BuddyPress (1.2)
1426
+ *
1427
+ * @global wpdb $wpdb WordPress database object.
1428
+ *
1429
+ * @param int $parent_id ID of an activity or activity comment.
1430
+ * @return object Numerically indexed array of child comments.
1431
+ */
1432
+ public static function get_child_comments( $parent_id ) {
1433
+ global $wpdb;
1434
+
1435
+ $bp = buddypress();
1436
+
1437
+ return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
1438
+ }
1439
+
1440
+ /**
1441
+ * Get a list of components that have recorded activity associated with them.
1442
+ *
1443
+ * @param bool $skip_last_activity If true, components will not be
1444
+ * included if the only activity type associated with them is
1445
+ * 'last_activity'. (Since 2.0.0, 'last_activity' is stored in
1446
+ * the activity table, but these items are not full-fledged
1447
+ * activity items.) Default: true.
1448
+ * @return array List of component names.
1449
+ */
1450
+ public static function get_recorded_components( $skip_last_activity = true ) {
1451
+ global $wpdb;
1452
+
1453
+ $bp = buddypress();
1454
+
1455
+ if ( true === $skip_last_activity ) {
1456
+ $components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} WHERE action != '' AND action != 'last_activity' ORDER BY component ASC" );
1457
+ } else {
1458
+ $components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
1459
+ }
1460
+
1461
+ return $components;
1462
+ }
1463
+
1464
+ /**
1465
+ * Get sitewide activity items for use in an RSS feed.
1466
+ *
1467
+ * @param int $limit Optional. Number of items to fetch. Default: 35.
1468
+ * @return array $activity_feed List of activity items, with RSS data added.
1469
+ */
1470
+ public static function get_sitewide_items_for_feed( $limit = 35 ) {
1471
+ $activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
1472
+ $activity_feed = array();
1473
+
1474
+ for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
1475
+ $title = explode( '<span', $activities[$i]['content'] );
1476
+ $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
1477
+ $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
1478
+ $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
1479
+ $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
1480
+ }
1481
+
1482
+ return $activity_feed;
1483
+ }
1484
+
1485
+ /**
1486
+ * Create SQL IN clause for filter queries.
1487
+ *
1488
+ * @since BuddyPress (1.5)
1489
+ *
1490
+ * @see BP_Activity_Activity::get_filter_sql()
1491
+ *
1492
+ * @param string $field The database field.
1493
+ * @param array|bool $items The values for the IN clause, or false when none are found.
1494
+ */
1495
+ public static function get_in_operator_sql( $field, $items ) {
1496
+ global $wpdb;
1497
+
1498
+ // split items at the comma
1499
+ if ( ! is_array( $items ) ) {
1500
+ $items = explode( ',', $items );
1501
+ }
1502
+
1503
+ // array of prepared integers or quoted strings
1504
+ $items_prepared = array();
1505
+
1506
+ // clean up and format each item
1507
+ foreach ( $items as $item ) {
1508
+ // clean up the string
1509
+ $item = trim( $item );
1510
+ // pass everything through prepare for security and to safely quote strings
1511
+ $items_prepared[] = ( is_numeric( $item ) ) ? $wpdb->prepare( '%d', $item ) : $wpdb->prepare( '%s', $item );
1512
+ }
1513
+
1514
+ // build IN operator sql syntax
1515
+ if ( count( $items_prepared ) )
1516
+ return sprintf( '%s IN ( %s )', trim( $field ), implode( ',', $items_prepared ) );
1517
+ else
1518
+ return false;
1519
+ }
1520
+
1521
+ /**
1522
+ * Create filter SQL clauses.
1523
+ *
1524
+ * @since BuddyPress (1.5.0)
1525
+ *
1526
+ * @param array $filter_array {
1527
+ * Fields and values to filter by.
1528
+ * @type array|string|id $user_id User ID(s).
1529
+ * @type array|string $object Corresponds to the 'component'
1530
+ * column in the database.
1531
+ * @type array|string $action Corresponds to the 'type' column
1532
+ * in the database.
1533
+ * @type array|string|int $primary_id Corresponds to the 'item_id'
1534
+ * column in the database.
1535
+ * @type array|string|int $secondary_id Corresponds to the
1536
+ * 'secondary_item_id' column in the database.
1537
+ * @type int $offset Return only those items with an ID greater
1538
+ * than the offset value.
1539
+ * @type string $since Return only those items that have a
1540
+ * date_recorded value greater than a given MySQL-formatted
1541
+ * date.
1542
+ * }
1543
+ * @return string The filter clause, for use in a SQL query.
1544
+ */
1545
+ public static function get_filter_sql( $filter_array ) {
1546
+
1547
+ $filter_sql = array();
1548
+
1549
+ if ( !empty( $filter_array['user_id'] ) ) {
1550
+ $user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] );
1551
+ if ( !empty( $user_sql ) )
1552
+ $filter_sql[] = $user_sql;
1553
+ }
1554
+
1555
+ if ( !empty( $filter_array['object'] ) ) {
1556
+ $object_sql = BP_Activity_Activity::get_in_operator_sql( 'a.component', $filter_array['object'] );
1557
+ if ( !empty( $object_sql ) )
1558
+ $filter_sql[] = $object_sql;
1559
+ }
1560
+
1561
+ if ( !empty( $filter_array['action'] ) ) {
1562
+ $action_sql = BP_Activity_Activity::get_in_operator_sql( 'a.type', $filter_array['action'] );
1563
+ if ( ! empty( $action_sql ) )
1564
+ $filter_sql[] = $action_sql;
1565
+ }
1566
+
1567
+ if ( !empty( $filter_array['primary_id'] ) ) {
1568
+ $pid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.item_id', $filter_array['primary_id'] );
1569
+ if ( !empty( $pid_sql ) )
1570
+ $filter_sql[] = $pid_sql;
1571
+ }
1572
+
1573
+ if ( !empty( $filter_array['secondary_id'] ) ) {
1574
+ $sid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.secondary_item_id', $filter_array['secondary_id'] );
1575
+ if ( !empty( $sid_sql ) )
1576
+ $filter_sql[] = $sid_sql;
1577
+ }
1578
+
1579
+ if ( ! empty( $filter_array['offset'] ) ) {
1580
+ $sid_sql = absint( $filter_array['offset'] );
1581
+ $filter_sql[] = "a.id >= {$sid_sql}";
1582
+ }
1583
+
1584
+ if ( ! empty( $filter_array['since'] ) ) {
1585
+ // Validate that this is a proper Y-m-d H:i:s date
1586
+ // Trick: parse to UNIX date then translate back
1587
+ $translated_date = date( 'Y-m-d H:i:s', strtotime( $filter_array['since'] ) );
1588
+ if ( $translated_date === $filter_array['since'] ) {
1589
+ $filter_sql[] = "a.date_recorded > '{$translated_date}'";
1590
+ }
1591
+ }
1592
+
1593
+ if ( empty( $filter_sql ) )
1594
+ return false;
1595
+
1596
+ return join( ' AND ', $filter_sql );
1597
+ }
1598
+
1599
+ /**
1600
+ * Get the date/time of last recorded activity.
1601
+ *
1602
+ * @since BuddyPress (1.2)
1603
+ *
1604
+ * @return string ISO timestamp.
1605
+ */
1606
+ public static function get_last_updated() {
1607
+ global $wpdb;
1608
+
1609
+ $bp = buddypress();
1610
+
1611
+ return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
1612
+ }
1613
+
1614
+ /**
1615
+ * Get favorite count for a given user.
1616
+ *
1617
+ * @since BuddyPress (1.2)
1618
+ *
1619
+ * @param int The ID of the user whose favorites you're counting.
1620
+ * @return int A count of the user's favorites.
1621
+ */
1622
+ public static function total_favorite_count( $user_id ) {
1623
+
1624
+ // Get activities from user meta
1625
+ $favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
1626
+ if ( ! empty( $favorite_activity_entries ) ) {
1627
+ return count( maybe_unserialize( $favorite_activity_entries ) );
1628
+ }
1629
+
1630
+ // No favorites
1631
+ return 0;
1632
+ }
1633
+
1634
+ /**
1635
+ * Check whether an activity item exists with a given string content.
1636
+ *
1637
+ * @param string $content The content to filter by.
1638
+ * @return int|bool The ID of the first matching item if found, otherwise false.
1639
+ */
1640
+ public static function check_exists_by_content( $content ) {
1641
+ global $wpdb;
1642
+
1643
+ $bp = buddypress();
1644
+
1645
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
1646
+ }
1647
+
1648
+ /**
1649
+ * Hide all activity for a given user.
1650
+ *
1651
+ * @param int $user_id The ID of the user whose activity you want to mark hidden.
1652
+ * @param int
1653
+ */
1654
+ public static function hide_all_for_user( $user_id ) {
1655
+ global $wpdb;
1656
+
1657
+ $bp = buddypress();
1658
+
1659
+ return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
1660
+ }
1661
+
1662
+ /**
1663
+ * PHP-agnostic version of {@link array_replace_recursive()}.
1664
+ *
1665
+ * array_replace_recursive() is a PHP 5.3 function. BuddyPress (and
1666
+ * WordPress) currently supports down to PHP 5.2, so this method is a workaround
1667
+ * for PHP 5.2.
1668
+ *
1669
+ * Note: array_replace_recursive() supports infinite arguments, but for our use-
1670
+ * case, we only need to support two arguments.
1671
+ *
1672
+ * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
1673
+ *
1674
+ * @since BuddyPress (2.2.0)
1675
+ *
1676
+ * @see http://php.net/manual/en/function.array-replace-recursive.php#109390
1677
+ *
1678
+ * @param array $base Array with keys needing to be replaced
1679
+ * @param array $replacements Array with the replaced keys
1680
+ * @return array
1681
+ */
1682
+ protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
1683
+ if ( function_exists( 'array_replace_recursive' ) ) {
1684
+ return array_replace_recursive( $base, $replacements );
1685
+ }
1686
+
1687
+ // PHP 5.2-compatible version
1688
+ // http://php.net/manual/en/function.array-replace-recursive.php#109390
1689
+ foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
1690
+ $bref_stack = array( &$base );
1691
+ $head_stack = array( $replacements );
1692
+
1693
+ do {
1694
+ end( $bref_stack );
1695
+
1696
+ $bref = &$bref_stack[ key( $bref_stack ) ];
1697
+ $head = array_pop( $head_stack );
1698
+
1699
+ unset( $bref_stack[ key($bref_stack) ] );
1700
+
1701
+ foreach ( array_keys( $head ) as $key ) {
1702
+ if ( isset( $key, $bref ) && is_array( $bref[$key] ) && is_array( $head[$key] ) ) {
1703
+ $bref_stack[] = &$bref[ $key ];
1704
+ $head_stack[] = $head[ $key ];
1705
+ } else {
1706
+ $bref[ $key ] = $head[ $key ];
1707
+ }
1708
+ }
1709
+ } while( count( $head_stack ) );
1710
+ }
1711
+
1712
+ return $base;
1713
+ }
1714
+ }
1715
+
1716
+ /**
1717
+ * Class for generating the WHERE SQL clause for advanced activity fetching.
1718
+ *
1719
+ * This is notably used in {@link BP_Activity_Activity::get()} with the
1720
+ * 'filter_query' parameter.
1721
+ *
1722
+ * @since BuddyPress (2.2.0)
1723
+ */
1724
+ class BP_Activity_Query extends BP_Recursive_Query {
1725
+ /**
1726
+ * Array of activity queries.
1727
+ *
1728
+ * See {@see BP_Activity_Query::__construct()} for information on query arguments.
1729
+ *
1730
+ * @since BuddyPress (2.2.0)
1731
+ * @access public
1732
+ * @var array
1733
+ */
1734
+ public $queries = array();
1735
+
1736
+ /**
1737
+ * Table alias.
1738
+ *
1739
+ * @since BuddyPress (2.2.0)
1740
+ * @access public
1741
+ * @var string
1742
+ */
1743
+ public $table_alias = '';
1744
+
1745
+ /**
1746
+ * Supported DB columns.
1747
+ *
1748
+ * See the 'wp_bp_activity' DB table schema.
1749
+ *
1750
+ * @since BuddyPress (2.2.0)
1751
+ * @access public
1752
+ * @var array
1753
+ */
1754
+ public $db_columns = array(
1755
+ 'id', 'user_id', 'component', 'type', 'action', 'content',
1756
+ 'item_id', 'secondary_item_id', 'hide_sitewide', 'is_spam',
1757
+ );
1758
+
1759
+ /**
1760
+ * Constructor.
1761
+ *
1762
+ * @since BuddyPress (2.2.0)
1763
+ *
1764
+ * @param array $query {
1765
+ * Array of query clauses.
1766
+ *
1767
+ * @type array {
1768
+ * @type string $column Required. The column to query against. Basically, any DB column in the main
1769
+ * 'wp_bp_activity' table.
1770
+ * @type string $value Required. Value to filter by.
1771
+ * @type string $compare Optional. The comparison operator. Default '='.
1772
+ * Accepts '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'LIKE',
1773
+ * 'NOT LIKE', BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', 'RLIKE'
1774
+ * @type string $relation Optional. The boolean relationship between the activity queries.
1775
+ * Accepts 'OR', 'AND'. Default 'AND'.
1776
+ * @type array {
1777
+ * Optional. Another fully-formed activity query. See parameters above.
1778
+ * }
1779
+ * }
1780
+ * }
1781
+ */
1782
+ public function __construct( $query = array() ) {
1783
+ if ( ! is_array( $query ) ) {
1784
+ return;
1785
+ }
1786
+
1787
+ $this->queries = $this->sanitize_query( $query );
1788
+ }
1789
+
1790
+ /**
1791
+ * Generates WHERE SQL clause to be appended to a main query.
1792
+ *
1793
+ * @since BuddyPress (2.2.0)
1794
+ * @access public
1795
+ *
1796
+ * @param string $alias An existing table alias that is compatible with the current query clause.
1797
+ * Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
1798
+ * @return string SQL fragment to append to the main WHERE clause.
1799
+ */
1800
+ public function get_sql( $alias = 'a' ) {
1801
+ if ( ! empty( $alias ) ) {
1802
+ $this->table_alias = sanitize_title( $alias );
1803
+ }
1804
+
1805
+ $sql = $this->get_sql_clauses();
1806
+
1807
+ // we only need the 'where' clause
1808
+ //
1809
+ // also trim trailing "AND" clause from parent BP_Recursive_Query class
1810
+ // since it's not necessary for our needs
1811
+ return preg_replace( '/^\sAND/', '', $sql['where'] );
1812
+ }
1813
+
1814
+ /**
1815
+ * Generate WHERE clauses for a first-order clause.
1816
+ *
1817
+ * @since BuddyPress (2.2.0)
1818
+ * @access protected
1819
+ *
1820
+ * @param array $clause Array of arguments belonging to the clause.
1821
+ * @param array $parent_query Parent query to which the clause belongs.
1822
+ * @return array {
1823
+ * @type array $where Array of subclauses for the WHERE statement.
1824
+ * @type array $join Empty array. Not used.
1825
+ * }
1826
+ */
1827
+ protected function get_sql_for_clause( $clause, $parent_query ) {
1828
+ global $wpdb;
1829
+
1830
+ $sql_chunks = array(
1831
+ 'where' => array(),
1832
+ 'join' => array(),
1833
+ );
1834
+
1835
+ $column = isset( $clause['column'] ) ? $this->validate_column( $clause['column'] ) : '';
1836
+ $value = isset( $clause['value'] ) ? $clause['value'] : '';
1837
+ if ( empty( $column ) || ! isset( $clause['value'] ) ) {
1838
+ return $sql_chunks;
1839
+ }
1840
+
1841
+ if ( isset( $clause['compare'] ) ) {
1842
+ $clause['compare'] = strtoupper( $clause['compare'] );
1843
+ } else {
1844
+ $clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
1845
+ }
1846
+
1847
+ // default 'compare' to '=' if no valid operator is found
1848
+ if ( ! in_array( $clause['compare'], array(
1849
+ '=', '!=', '>', '>=', '<', '<=',
1850
+ 'LIKE', 'NOT LIKE',
1851
+ 'IN', 'NOT IN',
1852
+ 'BETWEEN', 'NOT BETWEEN',
1853
+ 'REGEXP', 'NOT REGEXP', 'RLIKE'
1854
+ ) ) ) {
1855
+ $clause['compare'] = '=';
1856
+ }
1857
+
1858
+ $compare = $clause['compare'];
1859
+
1860
+ $alias = ! empty( $this->table_alias ) ? "{$this->table_alias}." : '';
1861
+
1862
+ // Next, Build the WHERE clause.
1863
+ $where = '';
1864
+
1865
+ // value.
1866
+ if ( isset( $clause['value'] ) ) {
1867
+ if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
1868
+ if ( ! is_array( $value ) ) {
1869
+ $value = preg_split( '/[,\s]+/', $value );
1870
+ }
1871
+ }
1872
+
1873
+ // tinyint
1874
+ if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
1875
+ $sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
1876
+
1877
+ } else {
1878
+ switch ( $compare ) {
1879
+ // IN uses different syntax
1880
+ case 'IN' :
1881
+ case 'NOT IN' :
1882
+ $in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value );
1883
+
1884
+ // 'NOT IN' operator is as easy as a string replace!
1885
+ if ( 'NOT IN' === $compare ) {
1886
+ $in_sql = str_replace( 'IN', 'NOT IN', $in_sql );
1887
+ }
1888
+
1889
+ $sql_chunks['where'][] = $in_sql;
1890
+ break;
1891
+
1892
+ case 'BETWEEN' :
1893
+ case 'NOT BETWEEN' :
1894
+ $value = array_slice( $value, 0, 2 );
1895
+ $where = $wpdb->prepare( '%s AND %s', $value );
1896
+ break;
1897
+
1898
+ case 'LIKE' :
1899
+ case 'NOT LIKE' :
1900
+ $value = '%' . bp_esc_like( $value ) . '%';
1901
+ $where = $wpdb->prepare( '%s', $value );
1902
+ break;
1903
+
1904
+ default :
1905
+ $where = $wpdb->prepare( '%s', $value );
1906
+ break;
1907
+
1908
+ }
1909
+ }
1910
+
1911
+ if ( $where ) {
1912
+ $sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}";
1913
+ }
1914
+ }
1915
+
1916
+ /*
1917
+ * Multiple WHERE clauses should be joined in parentheses.
1918
+ */
1919
+ if ( 1 < count( $sql_chunks['where'] ) ) {
1920
+ $sql_chunks['where'] = array( '( ' . implode( ' AND ', $sql_chunks['where'] ) . ' )' );
1921
+ }
1922
+
1923
+ return $sql_chunks;
1924
+ }
1925
+
1926
+ /**
1927
+ * Determine whether a clause is first-order.
1928
+ *
1929
+ * @since BuddyPress (2.2.0)
1930
+ * @access protected
1931
+ *
1932
+ * @param array $query Clause to check.
1933
+ * @return bool
1934
+ */
1935
+ protected function is_first_order_clause( $query ) {
1936
+ return isset( $query['column'] ) || isset( $query['value'] );
1937
+ }
1938
+
1939
+ /**
1940
+ * Validates a column name parameter.
1941
+ *
1942
+ * Column names are checked against a whitelist of known tables.
1943
+ * See {@link BP_Activity_Query::db_tables}.
1944
+ *
1945
+ * @since BuddyPress (2.2.0)
1946
+ * @access public
1947
+ *
1948
+ * @param string $column The user-supplied column name.
1949
+ * @return string A validated column name value.
1950
+ */
1951
+ public function validate_column( $column = '' ) {
1952
+ if ( in_array( $column, $this->db_columns ) ) {
1953
+ return $column;
1954
+ } else {
1955
+ return '';
1956
+ }
1957
+ }
1958
+ }
1959
+
1960
+ /**
1961
+ * Create a RSS feed using the activity component.
1962
+ *
1963
+ * You should only construct a new feed when you've validated that you're on
1964
+ * the appropriate screen.
1965
+ *
1966
+ * See {@link bp_activity_action_sitewide_feed()} as an example.
1967
+ *
1968
+ * Accepted parameters:
1969
+ * id - internal id for the feed; should be alphanumeric only
1970
+ * (required)
1971
+ * title - RSS feed title
1972
+ * link - Relevant link for the RSS feed
1973
+ * description - RSS feed description
1974
+ * ttl - Time-to-live (see inline doc in constructor)
1975
+ * update_period - Part of the syndication module (see inline doc in
1976
+ * constructor for more info)
1977
+ * update_frequency - Part of the syndication module (see inline doc in
1978
+ * constructor for more info)
1979
+ * max - Number of feed items to display
1980
+ * activity_args - Arguments passed to {@link bp_has_activities()}
1981
+ *
1982
+ * @since BuddyPress (1.8)
1983
+ */
1984
+ class BP_Activity_Feed {
1985
+ /**
1986
+ * Holds our custom class properties.
1987
+ *
1988
+ * These variables are stored in a protected array that is magically
1989
+ * updated using PHP 5.2+ methods.
1990
+ *
1991
+ * @see BP_Feed::__construct() This is where $data is added
1992
+ * @var array
1993
+ */
1994
+ protected $data;
1995
+
1996
+ /**
1997
+ * Magic method for checking the existence of a certain data variable.
1998
+ *
1999
+ * @param string $key
2000
+ */
2001
+ public function __isset( $key ) { return isset( $this->data[$key] ); }
2002
+
2003
+ /**
2004
+ * Magic method for getting a certain data variable.
2005
+ *
2006
+ * @param string $key
2007
+ */
2008
+ public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
2009
+
2010
+ /**
2011
+ * Constructor.
2012
+ *
2013
+ * @param array $args Optional
2014
+ */
2015
+ public function __construct( $args = array() ) {
2016
+
2017
+ /**
2018
+ * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
2019
+ *
2020
+ * @since BuddyPress (1.8.0)
2021
+ *
2022
+ * @param bool true Default true aka feeds are enabled.
2023
+ */
2024
+ if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
2025
+ global $wp_query;
2026
+
2027
+ // set feed flag to false
2028
+ $wp_query->is_feed = false;
2029
+
2030
+ return false;
2031
+ }
2032
+
2033
+ // Setup data
2034
+ $this->data = wp_parse_args( $args, array(
2035
+ // Internal identifier for the RSS feed - should be alphanumeric only
2036
+ 'id' => '',
2037
+
2038
+ // RSS title - should be plain-text
2039
+ 'title' => '',
2040
+
2041
+ // relevant link for the RSS feed
2042
+ 'link' => '',
2043
+
2044
+ // RSS description - should be plain-text
2045
+ 'description' => '',
2046
+
2047
+ // Time-to-live - number of minutes to cache the data before an aggregator
2048
+ // requests it again. This is only acknowledged if the RSS client supports it
2049
+ //
2050
+ // See: http://www.rssboard.org/rss-profile#element-channel-ttl
2051
+ // http://www.kbcafe.com/rss/rssfeedstate.html#ttl
2052
+ 'ttl' => '30',
2053
+
2054
+ // Syndication module - similar to ttl, but not really supported by RSS
2055
+ // clients
2056
+ //
2057
+ // See: http://web.resource.org/rss/1.0/modules/syndication/#description
2058
+ // http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule
2059
+ 'update_period' => 'hourly',
2060
+ 'update_frequency' => 2,
2061
+
2062
+ // Number of items to display
2063
+ 'max' => 50,
2064
+
2065
+ // Activity arguments passed to bp_has_activities()
2066
+ 'activity_args' => array()
2067
+ ) );
2068
+
2069
+ /**
2070
+ * Fires before the feed is setup so plugins can modify.
2071
+ *
2072
+ * @since BuddyPress (1.8.0)
2073
+ *
2074
+ * @param BP_Activity_Feed Reference to current instance of activity feed.
2075
+ */
2076
+ do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
2077
+
2078
+ // Setup class properties
2079
+ $this->setup_properties();
2080
+
2081
+ // Check if id is valid
2082
+ if ( empty( $this->id ) ) {
2083
+ _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
2084
+ return false;
2085
+ }
2086
+
2087
+ /**
2088
+ * Fires after the feed is setup so plugins can modify.
2089
+ *
2090
+ * @since BuddyPress (1.8.0)
2091
+ *
2092
+ * @param BP_Activity_Feed Reference to current instance of activity feed.
2093
+ */
2094
+ do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
2095
+
2096
+ // Setup feed hooks
2097
+ $this->setup_hooks();
2098
+
2099
+ // Output the feed
2100
+ $this->output();
2101
+
2102
+ // Kill the rest of the output
2103
+ die();
2104
+ }
2105
+
2106
+ /** SETUP ****************************************************************/
2107
+
2108
+ /**
2109
+ * Setup and validate the class properties.
2110
+ *
2111
+ * @access protected
2112
+ */
2113
+ protected function setup_properties() {
2114
+ $this->id = sanitize_title( $this->id );
2115
+ $this->title = strip_tags( $this->title );
2116
+ $this->link = esc_url_raw( $this->link );
2117
+ $this->description = strip_tags( $this->description );
2118
+ $this->ttl = (int) $this->ttl;
2119
+ $this->update_period = strip_tags( $this->update_period );
2120
+ $this->update_frequency = (int) $this->update_frequency;
2121
+
2122
+ $this->activity_args = wp_parse_args( $this->activity_args, array(
2123
+ 'max' => $this->max,
2124
+ 'per_page' => $this->max,
2125
+ 'display_comments' => 'stream'
2126
+ ) );
2127
+
2128
+ }
2129
+
2130
+ /**
2131
+ * Setup some hooks that are used in the feed.
2132
+ *
2133
+ * Currently, these hooks are used to maintain backwards compatibility with
2134
+ * the RSS feeds previous to BP 1.8.
2135
+ *
2136
+ * @access protected
2137
+ */
2138
+ protected function setup_hooks() {
2139
+ add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
2140
+ add_action( 'bp_activity_feed_channel_elements', array( $this, 'backpat_channel_elements' ) );
2141
+ add_action( 'bp_activity_feed_item_elements', array( $this, 'backpat_item_elements' ) );
2142
+ }
2143
+
2144
+ /** BACKPAT HOOKS ********************************************************/
2145
+
2146
+ /**
2147
+ * Fire a hook to ensure backward compatibility for RSS attributes.
2148
+ */
2149
+ public function backpat_rss_attributes() {
2150
+
2151
+ /**
2152
+ * Fires inside backpat_rss_attributes method for backwards compatibility related to RSS attributes.
2153
+ *
2154
+ * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2155
+ *
2156
+ * @since BuddyPress (1.0.0)
2157
+ */
2158
+ do_action( 'bp_activity_' . $this->id . '_feed' );
2159
+ }
2160
+
2161
+ /**
2162
+ * Fire a hook to ensure backward compatibility for channel elements.
2163
+ */
2164
+ public function backpat_channel_elements() {
2165
+
2166
+ /**
2167
+ * Fires inside backpat_channel_elements method for backwards compatibility related to RSS channel elements.
2168
+ *
2169
+ * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2170
+ *
2171
+ * @since BuddyPress (1.0.0)
2172
+ */
2173
+ do_action( 'bp_activity_' . $this->id . '_feed_head' );
2174
+ }
2175
+
2176
+ /**
2177
+ * Fire a hook to ensure backward compatibility for item elements.
2178
+ */
2179
+ public function backpat_item_elements() {
2180
+ switch ( $this->id ) {
2181
+
2182
+ // sitewide and friends feeds use the 'personal' hook
2183
+ case 'sitewide' :
2184
+ case 'friends' :
2185
+ $id = 'personal';
2186
+
2187
+ break;
2188
+
2189
+ default :
2190
+ $id = $this->id;
2191
+
2192
+ break;
2193
+ }
2194
+
2195
+ /**
2196
+ * Fires inside backpat_item_elements method for backwards compatibility related to RSS item elements.
2197
+ *
2198
+ * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2199
+ *
2200
+ * @since BuddyPress (1.0.0)
2201
+ */
2202
+ do_action( 'bp_activity_' . $id . '_feed_item' );
2203
+ }
2204
+
2205
+ /** HELPERS **************************************************************/
2206
+
2207
+ /**
2208
+ * Output the feed's item content.
2209
+ *
2210
+ * @access protected
2211
+ */
2212
+ protected function feed_content() {
2213
+ bp_activity_content_body();
2214
+
2215
+ switch ( $this->id ) {
2216
+
2217
+ // also output parent activity item if we're on a specific feed
2218
+ case 'favorites' :
2219
+ case 'friends' :
2220
+ case 'mentions' :
2221
+ case 'personal' :
2222
+
2223
+ if ( 'activity_comment' == bp_get_activity_action_name() ) :
2224
+ ?>
2225
+ <strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
2226
+ <?php bp_activity_parent_content() ?>
2227
+ <?php
2228
+ endif;
2229
+
2230
+ break;
2231
+ }
2232
+ }
2233
+
2234
+ /**
2235
+ * Sets various HTTP headers related to Content-Type and browser caching.
2236
+ *
2237
+ * Most of this class method is derived from {@link WP::send_headers()}.
2238
+ *
2239
+ * @since BuddyPress (1.9.0)
2240
+ *
2241
+ * @access protected
2242
+ */
2243
+ protected function http_headers() {
2244
+ // set up some additional headers if not on a directory page
2245
+ // this is done b/c BP uses pseudo-pages
2246
+ if ( ! bp_is_directory() ) {
2247
+ global $wp_query;
2248
+
2249
+ $wp_query->is_404 = false;
2250
+ status_header( 200 );
2251
+ }
2252
+
2253
+ // Set content-type
2254
+ @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
2255
+ send_nosniff_header();
2256
+
2257
+ // Cache-related variables
2258
+ $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
2259
+ $modified_timestamp = strtotime( $last_modified );
2260
+ $etag = md5( $last_modified );
2261
+
2262
+ // Set cache-related headers
2263
+ @header( 'Last-Modified: ' . $last_modified );
2264
+ @header( 'Pragma: no-cache' );
2265
+ @header( 'ETag: ' . '"' . $etag . '"' );
2266
+
2267
+ // First commit of BuddyPress! (Easter egg)
2268
+ @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT');
2269
+
2270
+ // Get ETag from supported user agents
2271
+ if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
2272
+ $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
2273
+
2274
+ // Remove quotes from ETag
2275
+ $client_etag = trim( $client_etag, '"' );
2276
+
2277
+ // Strip suffixes from ETag if they exist (eg. "-gzip")
2278
+ $etag_suffix_pos = strpos( $client_etag, '-' );
2279
+ if ( ! empty( $etag_suffix_pos ) ) {
2280
+ $client_etag = substr( $client_etag, 0, $etag_suffix_pos );
2281
+ }
2282
+
2283
+ // No ETag found
2284
+ } else {
2285
+ $client_etag = false;
2286
+ }
2287
+
2288
+ // Get client last modified timestamp from supported user agents
2289
+ $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
2290
+ $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
2291
+
2292
+ // Set 304 status if feed hasn't been updated since last fetch
2293
+ if ( ( $client_last_modified && $client_etag ) ?
2294
+ ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) :
2295
+ ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) {
2296
+ $status = 304;
2297
+ } else {
2298
+ $status = false;
2299
+ }
2300
+
2301
+ // If feed hasn't changed as reported by the user agent, set 304 status header
2302
+ if ( ! empty( $status ) ) {
2303
+ status_header( $status );
2304
+
2305
+ // cached response, so stop now!
2306
+ if ( $status == 304 ) {
2307
+ exit();
2308
+ }
2309
+ }
2310
+ }
2311
+
2312
+ /** OUTPUT ***************************************************************/
2313
+
2314
+ /**
2315
+ * Output the RSS feed.
2316
+ *
2317
+ * @access protected
2318
+ */
2319
+ protected function output() {
2320
+ $this->http_headers();
2321
+ echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>';
2322
+ ?>
2323
+
2324
+ <rss version="2.0"
2325
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
2326
+ xmlns:atom="http://www.w3.org/2005/Atom"
2327
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
2328
+ xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
2329
+ <?php
2330
+
2331
+ /**
2332
+ * Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
2333
+ *
2334
+ * @since BuddyPress (1.8.0)
2335
+ */
2336
+ do_action( 'bp_activity_feed_rss_attributes' ); ?>
2337
+ >
2338
+
2339
+ <channel>
2340
+ <title><?php echo $this->title; ?></title>
2341
+ <link><?php echo $this->link; ?></link>
2342
+ <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
2343
+ <description><?php echo $this->description ?></description>
2344
+ <lastBuildDate><?php echo mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false ); ?></lastBuildDate>
2345
+ <generator>http://buddypress.org/?v=<?php bp_version(); ?></generator>
2346
+ <language><?php bloginfo_rss( 'language' ); ?></language>
2347
+ <ttl><?php echo $this->ttl; ?></ttl>
2348
+ <sy:updatePeriod><?php echo $this->update_period; ?></sy:updatePeriod>
2349
+ <sy:updateFrequency><?php echo $this->update_frequency; ?></sy:updateFrequency>
2350
+ <?php
2351
+
2352
+ /**
2353
+ * Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
2354
+ *
2355
+ * @since BuddyPress (1.8.0)
2356
+ */
2357
+ do_action( 'bp_activity_feed_channel_elements' ); ?>
2358
+
2359
+ <?php if ( bp_has_activities( $this->activity_args ) ) : ?>
2360
+ <?php while ( bp_activities() ) : bp_the_activity(); ?>
2361
+ <item>
2362
+ <guid isPermaLink="false"><?php bp_activity_feed_item_guid(); ?></guid>
2363
+ <title><?php echo stripslashes( bp_get_activity_feed_item_title() ); ?></title>
2364
+ <link><?php bp_activity_thread_permalink() ?></link>
2365
+ <pubDate><?php echo mysql2date( 'D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false ); ?></pubDate>
2366
+
2367
+ <?php if ( bp_get_activity_feed_item_description() ) : ?>
2368
+ <content:encoded><![CDATA[<?php $this->feed_content(); ?>]]></content:encoded>
2369
+ <?php endif; ?>
2370
+
2371
+ <?php if ( bp_activity_can_comment() ) : ?>
2372
+ <slash:comments><?php bp_activity_comment_count(); ?></slash:comments>
2373
+ <?php endif; ?>
2374
+
2375
+ <?php
2376
+
2377
+ /**
2378
+ * Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
2379
+ *
2380
+ * @since BuddyPress (1.8.0)
2381
+ */
2382
+ do_action( 'bp_activity_feed_item_elements' ); ?>
2383
+ </item>
2384
+ <?php endwhile; ?>
2385
+
2386
+ <?php endif; ?>
2387
+ </channel>
2388
+ </rss><?php
2389
+ }
2390
+ }
bp-activity/bp-activity-cssjs.php CHANGED
@@ -8,12 +8,12 @@
8
  */
9
 
10
  // Exit if accessed directly
11
- defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Enqueue @mentions JS.
15
  *
16
- * @since BuddyPress (2.1.0)
17
  */
18
  function bp_activity_mentions_script() {
19
  if ( ! bp_activity_maybe_load_mentions_scripts() ) {
@@ -41,9 +41,6 @@ function bp_activity_mentions_script() {
41
  wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
42
  }
43
 
44
- // If the script has been enqueued, let's attach our mentions TinyMCE init callback.
45
- add_filter( 'tiny_mce_before_init', 'bp_add_mentions_on_tinymce_init', 10, 2 );
46
-
47
  /**
48
  * Fires at the end of the Activity Mentions script.
49
  *
@@ -56,22 +53,3 @@ function bp_activity_mentions_script() {
56
  }
57
  add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' );
58
  add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
59
-
60
- /**
61
- * Bind the mentions listener to a wp_editor instance when TinyMCE initializes.
62
- *
63
- * @since BuddyPress (2.3.3)
64
- *
65
- * @param array $settings An array with TinyMCE config.
66
- * @param string $editor_id Unique editor identifier, e.g. 'content'.
67
- *
68
- * @return array $mceInit An array with TinyMCE config.
69
- */
70
- function bp_add_mentions_on_tinymce_init( $settings, $editor_id ) {
71
- // We only apply the mentions init to the visual post editor in the WP dashboard.
72
- if ( 'content' === $editor_id ) {
73
- $settings['init_instance_callback'] = 'window.bp.mentions.tinyMCEinit';
74
- }
75
-
76
- return $settings;
77
- }
8
  */
9
 
10
  // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
  * Enqueue @mentions JS.
15
  *
16
+ * @since BuddyPress (2.1)
17
  */
18
  function bp_activity_mentions_script() {
19
  if ( ! bp_activity_maybe_load_mentions_scripts() ) {
41
  wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
42
  }
43
 
 
 
 
44
  /**
45
  * Fires at the end of the Activity Mentions script.
46
  *
53
  }
54
  add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' );
55
  add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/bp-activity-filters.php CHANGED
@@ -179,7 +179,6 @@ function bp_activity_check_blacklist_keys( $activity ) {
179
  * @uses wp_kses()
180
  *
181
  * @param string $content The activity content.
182
- *
183
  * @return string $content Filtered activity content.
184
  */
185
  function bp_activity_filter_kses( $content ) {
@@ -210,7 +209,7 @@ function bp_activity_filter_kses( $content ) {
210
  *
211
  * @since BuddyPress (1.2.0)
212
  *
213
- * @param array $value Array of allowed HTML tags and attributes.
214
  */
215
  $activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
216
  return wp_kses( $content, $activity_allowedtags );
@@ -221,9 +220,8 @@ function bp_activity_filter_kses( $content ) {
221
  *
222
  * @since BuddyPress (1.2.0)
223
  *
224
- * @param string $content The contents of a given item.
225
- * @param int $activity_id The activity id. Deprecated.
226
- *
227
  * @return string $content Content filtered for mentions.
228
  */
229
  function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
@@ -320,7 +318,7 @@ function bp_activity_at_name_filter_updates( $activity ) {
320
  * @uses bp_activity_at_message_notification()
321
  * @uses bp_activity_update_mention_count_for_user()
322
  *
323
- * @param BP_Activity_Activity $activity The BP_Activity_Activity object.
324
  */
325
  function bp_activity_at_name_send_emails( $activity ) {
326
  // Are mentions disabled?
@@ -340,13 +338,12 @@ function bp_activity_at_name_send_emails( $activity ) {
340
 
341
  // Send @mentions and setup BP notifications
342
  foreach( (array) $usernames as $user_id => $username ) {
343
-
344
  /**
345
  * Filters BuddyPress' ability to send email notifications for @mentions.
346
  *
347
  * @since BuddyPress (1.6.0)
348
  *
349
- * @param bool $value Whether or not BuddyPress should send a notification to the mentioned users.
350
  * @param array $usernames Array of users potentially notified.
351
  */
352
  if ( apply_filters( 'bp_activity_at_name_do_notifications', true, $usernames ) ) {
@@ -364,7 +361,6 @@ function bp_activity_at_name_send_emails( $activity ) {
364
  * @since BuddyPress (1.2.0)
365
  *
366
  * @param string $text Activity text.
367
- *
368
  * @return string $text Text with rel=nofollow added to any links.
369
  */
370
  function bp_activity_make_nofollow_filter( $text ) {
@@ -376,9 +372,10 @@ function bp_activity_make_nofollow_filter( $text ) {
376
  *
377
  * @since BuddyPress (1.2.0)
378
  *
379
- * @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
380
  *
381
- * @return string $text Link with rel=nofollow added.
 
382
  */
383
  function bp_activity_make_nofollow_filter_callback( $matches ) {
384
  $text = $matches[1];
@@ -389,8 +386,6 @@ function bp_activity_make_nofollow_filter( $text ) {
389
  /**
390
  * Truncate long activity entries when viewed in activity streams.
391
  *
392
- * This method can only be used inside the Activity loop.
393
- *
394
  * @since BuddyPress (1.5.0)
395
  *
396
  * @uses bp_is_single_activity()
@@ -402,35 +397,21 @@ function bp_activity_make_nofollow_filter( $text ) {
402
  * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook.
403
  *
404
  * @param string $text The original activity entry text.
405
- *
406
  * @return string $excerpt The truncated text.
407
  */
408
  function bp_activity_truncate_entry( $text ) {
409
  global $activities_template;
410
 
411
- /**
412
- * Provides a filter that lets you choose whether to skip this filter on a per-activity basis.
413
- *
414
- * @since BuddyPress (2.3.0)
415
- *
416
- * @param bool $value If true, text should be checked to see if it needs truncating.
417
- */
418
- $maybe_truncate_text = apply_filters(
419
- 'bp_activity_maybe_truncate_entry',
420
- isset( $activities_template->activity->type ) && ! in_array( $activities_template->activity->type, array( 'new_blog_post', ), true )
421
- );
422
-
423
  // The full text of the activity update should always show on the single activity screen
424
- if ( ! $maybe_truncate_text || bp_is_single_activity() ) {
425
  return $text;
426
- }
427
 
428
  /**
429
  * Filters the appended text for the activity excerpt.
430
  *
431
  * @since BuddyPress (1.5.0)
432
  *
433
- * @param string $value Internationalized "Read more" text.
434
  */
435
  $append_text = apply_filters( 'bp_activity_excerpt_append_text', __( '[Read more]', 'buddypress' ) );
436
 
@@ -439,7 +420,7 @@ function bp_activity_truncate_entry( $text ) {
439
  *
440
  * @since BuddyPress (1.5.0)
441
  *
442
- * @param int $value Number indicating how many words to trim the excerpt down to.
443
  */
444
  $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
445
 
@@ -461,22 +442,21 @@ function bp_activity_truncate_entry( $text ) {
461
  *
462
  * @since BuddyPress (1.5.0)
463
  *
464
- * @param string $excerpt Excerpt text and markup to be displayed.
465
- * @param string $text The original activity entry text.
466
  * @param string $append_text The final append text applied.
467
  */
468
  return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text );
469
  }
470
 
471
  /**
472
- * Include extra JavaScript dependencies for activity component.
473
  *
474
  * @since BuddyPress (2.0.0)
475
  *
476
  * @uses bp_activity_do_heartbeat() to check if heartbeat is required.
477
  *
478
  * @param array $js_handles The original dependencies.
479
- *
480
  * @return array $js_handles The new dependencies.
481
  */
482
  function bp_activity_get_js_dependencies( $js_handles = array() ) {
@@ -497,7 +477,6 @@ add_filter( 'bp_core_get_js_dependencies', 'bp_activity_get_js_dependencies', 10
497
  * @since BuddyPress (2.0.0)
498
  *
499
  * @param string $classes
500
- *
501
  * @return string $classes
502
  */
503
  function bp_activity_newest_class( $classes = '' ) {
@@ -517,7 +496,6 @@ function bp_activity_newest_class( $classes = '' ) {
517
  * @since BuddyPress (2.0.0)
518
  *
519
  * @param string $classes
520
- *
521
  * @return string $classes
522
  */
523
  function bp_activity_timestamp_class( $classes = '' ) {
@@ -543,11 +521,10 @@ add_filter( 'bp_get_activity_css_class', 'bp_activity_timestamp_class', 9, 1 );
543
  *
544
  * @since BuddyPress (2.0.0)
545
  *
546
- * @uses bp_activity_get_last_updated() to get the recorded date of the last activity.
547
  *
548
  * @param array $response
549
  * @param array $data
550
- *
551
  * @return array $response
552
  */
553
  function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) {
@@ -609,7 +586,6 @@ add_filter( 'heartbeat_nopriv_received', 'bp_activity_heartbeat_last_recorded',
609
  * @since BuddyPress (2.0.0)
610
  *
611
  * @param array $strings Localized strings.
612
- *
613
  * @return array $strings
614
  */
615
  function bp_activity_heartbeat_strings( $strings = array() ) {
@@ -625,7 +601,7 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
625
  *
626
  * @since BuddyPress (2.0.0)
627
  *
628
- * @param array $value Heartbeat settings array.
629
  */
630
  $heartbeat_settings = apply_filters( 'heartbeat_settings', array() );
631
  if ( ! empty( $heartbeat_settings['interval'] ) ) {
@@ -638,7 +614,7 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
638
  *
639
  * @since BuddyPress (2.0.0)
640
  *
641
- * @param int $value The frequency in seconds between pulses.
642
  */
643
  $bp_activity_pulse = apply_filters( 'bp_activity_heartbeat_pulse', 15 );
644
 
@@ -670,9 +646,8 @@ add_filter( 'bp_core_get_js_strings', 'bp_activity_heartbeat_strings', 10, 1 );
670
  *
671
  * @since BuddyPress (2.2.0)
672
  *
673
- * @param array $retval Empty array by default.
674
- * @param array $filter Current activity arguments.
675
- *
676
  * @return array
677
  */
678
  function bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
@@ -720,9 +695,8 @@ add_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_sc
720
  *
721
  * @since BuddyPress (2.2.0)
722
  *
723
- * @param array $retval Empty array by default.
724
- * @param array $filter Current activity arguments.
725
- *
726
  * @return array
727
  */
728
  function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) {
@@ -778,9 +752,8 @@ add_filter( 'bp_activity_set_favorites_scope_args', 'bp_activity_filter_favorite
778
  *
779
  * @since BuddyPress (2.2.0)
780
  *
781
- * @param array $retval Empty array by default.
782
- * @param array $filter Current activity arguments.
783
- *
784
  * @return array
785
  */
786
  function bp_activity_filter_mentions_scope( $retval = array(), $filter = array() ) {
179
  * @uses wp_kses()
180
  *
181
  * @param string $content The activity content.
 
182
  * @return string $content Filtered activity content.
183
  */
184
  function bp_activity_filter_kses( $content ) {
209
  *
210
  * @since BuddyPress (1.2.0)
211
  *
212
+ * @param array Array of allowed HTML tags and attributes.
213
  */
214
  $activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
215
  return wp_kses( $content, $activity_allowedtags );
220
  *
221
  * @since BuddyPress (1.2.0)
222
  *
223
+ * @param string $content The contents of a given item.
224
+ * @param int $activity_id The activity id. Deprecated.
 
225
  * @return string $content Content filtered for mentions.
226
  */
227
  function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
318
  * @uses bp_activity_at_message_notification()
319
  * @uses bp_activity_update_mention_count_for_user()
320
  *
321
+ * @param BP_Activity_Activity $activity The BP_Activity_Activity object
322
  */
323
  function bp_activity_at_name_send_emails( $activity ) {
324
  // Are mentions disabled?
338
 
339
  // Send @mentions and setup BP notifications
340
  foreach( (array) $usernames as $user_id => $username ) {
 
341
  /**
342
  * Filters BuddyPress' ability to send email notifications for @mentions.
343
  *
344
  * @since BuddyPress (1.6.0)
345
  *
346
+ * @param bool Whether or not BuddyPress should send a notification to the mentioned users.
347
  * @param array $usernames Array of users potentially notified.
348
  */
349
  if ( apply_filters( 'bp_activity_at_name_do_notifications', true, $usernames ) ) {
361
  * @since BuddyPress (1.2.0)
362
  *
363
  * @param string $text Activity text.
 
364
  * @return string $text Text with rel=nofollow added to any links.
365
  */
366
  function bp_activity_make_nofollow_filter( $text ) {
372
  *
373
  * @since BuddyPress (1.2.0)
374
  *
375
+ * @param array $matches
376
  *
377
+ * @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
378
+ * @return string $text Link with rel=nofollow added
379
  */
380
  function bp_activity_make_nofollow_filter_callback( $matches ) {
381
  $text = $matches[1];
386
  /**
387
  * Truncate long activity entries when viewed in activity streams.
388
  *
 
 
389
  * @since BuddyPress (1.5.0)
390
  *
391
  * @uses bp_is_single_activity()
397
  * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook.
398
  *
399
  * @param string $text The original activity entry text.
 
400
  * @return string $excerpt The truncated text.
401
  */
402
  function bp_activity_truncate_entry( $text ) {
403
  global $activities_template;
404
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  // The full text of the activity update should always show on the single activity screen
406
+ if ( bp_is_single_activity() )
407
  return $text;
 
408
 
409
  /**
410
  * Filters the appended text for the activity excerpt.
411
  *
412
  * @since BuddyPress (1.5.0)
413
  *
414
+ * @param string $read_more Internationalized "Read more" text.
415
  */
416
  $append_text = apply_filters( 'bp_activity_excerpt_append_text', __( '[Read more]', 'buddypress' ) );
417
 
420
  *
421
  * @since BuddyPress (1.5.0)
422
  *
423
+ * @param int $excerpt_length Number indicating how many words to trim the excerpt down to.
424
  */
425
  $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
426
 
442
  *
443
  * @since BuddyPress (1.5.0)
444
  *
445
+ * @param string $excerpt Excerpt text and markup to be displayed.
446
+ * @param string $text The original activity entry text.
447
  * @param string $append_text The final append text applied.
448
  */
449
  return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text );
450
  }
451
 
452
  /**
453
+ * Include extra javascript dependencies for activity component.
454
  *
455
  * @since BuddyPress (2.0.0)
456
  *
457
  * @uses bp_activity_do_heartbeat() to check if heartbeat is required.
458
  *
459
  * @param array $js_handles The original dependencies.
 
460
  * @return array $js_handles The new dependencies.
461
  */
462
  function bp_activity_get_js_dependencies( $js_handles = array() ) {
477
  * @since BuddyPress (2.0.0)
478
  *
479
  * @param string $classes
 
480
  * @return string $classes
481
  */
482
  function bp_activity_newest_class( $classes = '' ) {
496
  * @since BuddyPress (2.0.0)
497
  *
498
  * @param string $classes
 
499
  * @return string $classes
500
  */
501
  function bp_activity_timestamp_class( $classes = '' ) {
521
  *
522
  * @since BuddyPress (2.0.0)
523
  *
524
+ * @uses bp_activity_get_last_updated() to get the recorded date of the last activity
525
  *
526
  * @param array $response
527
  * @param array $data
 
528
  * @return array $response
529
  */
530
  function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) {
586
  * @since BuddyPress (2.0.0)
587
  *
588
  * @param array $strings Localized strings.
 
589
  * @return array $strings
590
  */
591
  function bp_activity_heartbeat_strings( $strings = array() ) {
601
  *
602
  * @since BuddyPress (2.0.0)
603
  *
604
+ * @param array $settings Heartbeat settings array.
605
  */
606
  $heartbeat_settings = apply_filters( 'heartbeat_settings', array() );
607
  if ( ! empty( $heartbeat_settings['interval'] ) ) {
614
  *
615
  * @since BuddyPress (2.0.0)
616
  *
617
+ * @param int $frequency The frequency in seconds between pulses.
618
  */
619
  $bp_activity_pulse = apply_filters( 'bp_activity_heartbeat_pulse', 15 );
620
 
646
  *
647
  * @since BuddyPress (2.2.0)
648
  *
649
+ * @param array $retval Empty array by default
650
+ * @param array $filter Current activity arguments
 
651
  * @return array
652
  */
653
  function bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
695
  *
696
  * @since BuddyPress (2.2.0)
697
  *
698
+ * @param array $retval Empty array by default
699
+ * @param array $filter Current activity arguments
 
700
  * @return array
701
  */
702
  function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) {
752
  *
753
  * @since BuddyPress (2.2.0)
754
  *
755
+ * @param array $retval Empty array by default
756
+ * @param array $filter Current activity arguments
 
757
  * @return array
758
  */
759
  function bp_activity_filter_mentions_scope( $retval = array(), $filter = array() ) {
bp-activity/bp-activity-functions.php CHANGED
@@ -28,10 +28,10 @@ function bp_activity_has_directory() {
28
  *
29
  * The Mentions feature does a number of things, all of which will be turned
30
  * off if you disable mentions:
31
- * - Detecting and auto-linking @username in all BP/WP content.
32
  * - Sending BP notifications and emails to users when they are mentioned
33
- * using the @username syntax.
34
- * - The Public Message button on user profiles.
35
  *
36
  * Mentions are enabled by default. To disable, put the following line in
37
  * bp-custom.php or your theme's functions.php file:
@@ -60,9 +60,8 @@ function bp_activity_do_mentions() {
60
  * Should BuddyPress load the mentions scripts and related assets, including results to prime the
61
  * mentions suggestions?
62
  *
63
- * @since BuddyPress (2.1.0)
64
- *
65
  * @return bool True if mentions scripts should be loaded.
 
66
  */
67
  function bp_activity_maybe_load_mentions_scripts() {
68
  $mentions_enabled = bp_activity_do_mentions() && bp_is_user_active();
@@ -73,7 +72,7 @@ function bp_activity_maybe_load_mentions_scripts() {
73
  *
74
  * @since BuddyPress (2.1.0)
75
  *
76
- * @param bool $load_mentions True to load mentions assets, false otherwise.
77
  * @param bool $mentions_enabled True if mentions are enabled.
78
  */
79
  return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $load_mentions, $mentions_enabled );
@@ -85,10 +84,9 @@ function bp_activity_maybe_load_mentions_scripts() {
85
  * @since BuddyPress (1.5.0)
86
  *
87
  * @param string $content The content of the activity, usually found in
88
- * $activity->content.
89
- *
90
  * @return array|bool Associative array with user ID as key and username as
91
- * value. Boolean false if no mentions found.
92
  */
93
  function bp_activity_find_mentions( $content ) {
94
 
@@ -149,10 +147,8 @@ function bp_activity_clear_new_mentions( $user_id ) {
149
  * @uses bp_activity_find_mentions()
150
  * @uses bp_activity_update_mention_count_for_user()
151
  *
152
- * @param int $activity_id The unique id for the activity item.
153
- * @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
154
- *
155
- * @return bool
156
  */
157
  function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
158
 
@@ -189,10 +185,9 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
189
  * @uses bp_get_user_meta()
190
  * @uses bp_update_user_meta()
191
  *
192
- * @param int $user_id The user ID.
193
- * @param int $activity_id The unique ID for the activity item.
194
- * @param string $action 'delete' or 'add'. Default: 'add'.
195
- *
196
  * @return bool
197
  */
198
  function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
@@ -244,8 +239,6 @@ function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $act
244
  *
245
  * @since BuddyPress (1.9.0)
246
  *
247
- * @param int|string $user_id ID of the user to get @-mention name for.
248
- *
249
  * @return string User name appropriate for @-mentions.
250
  */
251
  function bp_activity_get_user_mentionname( $user_id ) {
@@ -269,8 +262,6 @@ function bp_activity_get_user_mentionname( $user_id ) {
269
  *
270
  * @since BuddyPress (1.9.0)
271
  *
272
- * @param string $mentionname Username of user in @-mentions.
273
- *
274
  * @return int|bool ID of the user, if one is found. Otherwise false.
275
  */
276
  function bp_activity_get_userid_from_mentionname( $mentionname ) {
@@ -324,15 +315,14 @@ function bp_activity_get_userid_from_mentionname( $mentionname ) {
324
  *
325
  * @since BuddyPress (1.1.0)
326
  *
327
- * @param string $component_id The unique string ID of the component.
328
- * @param string $type The action type.
329
- * @param string $description The action description.
330
- * @param callable|bool $format_callback Callback for formatting the action string.
331
- * @param string|bool $label String to describe this action in the activity stream filter dropdown.
332
- * @param array $context Optional. Activity stream contexts where the filter should appear.
333
- * Values: 'activity', 'member', 'member_groups', 'group'.
334
- * @param int $position Optional. The position of the action when listed in dropdowns.
335
- *
336
  * @return bool False if any param is empty, otherwise true.
337
  */
338
  function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array(), $position = 0 ) {
@@ -362,14 +352,14 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
362
  *
363
  * @since BuddyPress (1.1.0)
364
  *
365
- * @param array $array Array of arguments for action type being set.
366
- * @param string $component_id ID of the current component being set.
367
- * @param string $type Action type being set.
368
- * @param string $description Action description for action being set.
369
  * @param callable $format_callback Callback for formatting the action string.
370
- * @param string $label String to describe this action in the activity stream filter dropdown.
371
- * @param array $context Activity stream contexts where the filter should appear. 'activity', 'member',
372
- * 'member_groups', 'group'.
373
  */
374
  $bp->activity->actions->{$component_id}->{$type} = apply_filters( 'bp_activity_set_action', array(
375
  'key' => $type,
@@ -408,18 +398,17 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
408
  * @type callable $format_callback Callback for formatting the activity action string.
409
  * Default: 'bp_activity_format_activity_action_custom_post_type_post'.
410
  * @type array $contexts The directory contexts in which the filter will show.
411
- * Default: array( 'activity' ).
412
  * @type array $position Position of the item in filter dropdowns.
413
  * @type string $singular Singular, translatable name of the post type item. If no value is
414
  * provided, it's pulled from the 'singular_name' of the post type.
415
  * @type bool $activity_comment Whether to allow comments on the activity items. Defaults to true if
416
  * the post type does not natively support comments, otherwise false.
417
  * }
418
- *
419
- * @return bool
420
  */
421
  function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array() ) {
422
  global $wp_post_types;
 
423
 
424
  if ( empty( $wp_post_types[ $post_type ] ) || ! post_type_supports( $post_type, 'buddypress-activity' ) || ! is_array( $args ) ) {
425
  return false;
@@ -444,8 +433,7 @@ function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array
444
  *
445
  * @since BuddyPress (2.2.0)
446
  *
447
- * @param string $post_type Name of the post type.
448
- *
449
  * @return object The tracking arguments of the post type.
450
  */
451
  function bp_activity_get_post_type_tracking_args( $post_type ) {
@@ -502,7 +490,7 @@ function bp_activity_get_post_type_tracking_args( $post_type ) {
502
  * @since BuddyPress (2.2.0)
503
  *
504
  * @param object $post_type_activity The tracking arguments of the post type.
505
- * @param string $post_type Name of the post type.
506
  */
507
  return apply_filters( 'bp_activity_get_post_type_tracking_args', $post_type_activity, $post_type );
508
  }
@@ -545,7 +533,7 @@ function bp_activity_get_post_types_tracking_args() {
545
  *
546
  * @since BuddyPress (2.2.0)
547
  *
548
- * @return object Actions ordered by their position.
549
  */
550
  function bp_activity_get_actions() {
551
  $bp = buddypress();
@@ -594,8 +582,7 @@ function bp_activity_get_actions() {
594
  * @uses apply_filters() To call the 'bp_activity_get_action' hook.
595
  *
596
  * @param string $component_id The unique string ID of the component.
597
- * @param string $key The action key.
598
- *
599
  * @return string|bool Action value if found, otherwise false.
600
  */
601
  function bp_activity_get_action( $component_id, $key ) {
@@ -605,9 +592,10 @@ function bp_activity_get_action( $component_id, $key ) {
605
  return false;
606
  }
607
 
 
608
  $actions = bp_activity_get_actions();
609
- $retval = false;
610
 
 
611
  if ( isset( $actions->{$component_id}->{$key} ) ) {
612
  $retval = $actions->{$component_id}->{$key};
613
  }
@@ -667,7 +655,6 @@ function bp_activity_get_types() {
667
  * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
668
  *
669
  * @param int $user_id ID of the user whose favorites are being queried.
670
- *
671
  * @return array IDs of the user's favorite activity items.
672
  */
673
  function bp_activity_get_user_favorites( $user_id = 0 ) {
@@ -704,8 +691,7 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
704
  * @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook.
705
  *
706
  * @param int $activity_id ID of the activity item being favorited.
707
- * @param int $user_id ID of the user favoriting the activity item.
708
- *
709
  * @return bool True on success, false on failure.
710
  */
711
  function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
@@ -749,7 +735,7 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
749
  * @since BuddyPress (1.2.1)
750
  *
751
  * @param int $activity_id ID of the activity item being favorited.
752
- * @param int $user_id ID of the user doing the favoriting.
753
  */
754
  do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
755
 
@@ -765,7 +751,7 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
765
  * @since BuddyPress (1.5.0)
766
  *
767
  * @param int $activity_id ID of the activity item being favorited.
768
- * @param int $user_id ID of the user doing the favoriting.
769
  */
770
  do_action( 'bp_activity_add_user_favorite_fail', $activity_id, $user_id );
771
 
@@ -786,8 +772,7 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
786
  * @uses do_action() To call the 'bp_activity_remove_user_favorite' hook.
787
  *
788
  * @param int $activity_id ID of the activity item being unfavorited.
789
- * @param int $user_id ID of the user unfavoriting the activity item.
790
- *
791
  * @return bool True on success, false on failure.
792
  */
793
  function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
@@ -830,7 +815,7 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
830
  * @since BuddyPress (1.2.1)
831
  *
832
  * @param int $activity_id ID of the activity item being unfavorited.
833
- * @param int $user_id ID of the user doing the unfavoriting.
834
  */
835
  do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
836
 
@@ -862,7 +847,6 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
862
  * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
863
  *
864
  * @param string $content The content to filter by.
865
- *
866
  * @return int|null The ID of the located activity item. Null if none is found.
867
  */
868
  function bp_activity_check_exists_by_content( $content ) {
@@ -907,7 +891,6 @@ function bp_activity_get_last_updated() {
907
  * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
908
  *
909
  * @param int $user_id ID of the user whose favorite count is being requested.
910
- *
911
  * @return int Total favorite count for the user.
912
  */
913
  function bp_activity_total_favorites_for_user( $user_id = 0 ) {
@@ -928,18 +911,18 @@ function bp_activity_total_favorites_for_user( $user_id = 0 ) {
928
  * @since BuddyPress (1.2.0)
929
  *
930
  * @global object $wpdb WordPress database access object.
931
- *
932
- * @param int $activity_id ID of the activity item whose metadata is being deleted.
933
- * @param string $meta_key Optional. The key of the metadata being deleted. If
934
- * omitted, all metadata associated with the activity
935
- * item will be deleted.
936
- * @param string $meta_value Optional. If present, the metadata will only be
937
- * deleted if the meta_value matches this parameter.
938
- * @param bool $delete_all Optional. If true, delete matching metadata entries
939
- * for all objects, ignoring the specified object_id. Otherwise,
940
- * only delete matching metadata entries for the specified
941
- * activity item. Default: false.
942
- *
943
  * @return bool True on success, false on failure.
944
  */
945
  function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
@@ -973,14 +956,13 @@ function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = ''
973
  *
974
  * @uses apply_filters() To call the 'bp_activity_get_meta' hook.
975
  *
976
- * @param int $activity_id ID of the activity item whose metadata is being requested.
977
- * @param string $meta_key Optional. If present, only the metadata matching
978
- * that meta key will be returned. Otherwise, all metadata for the
979
- * activity item will be fetched.
980
- * @param bool $single Optional. If true, return only the first value of the
981
- * specified meta_key. This parameter has no effect if meta_key is not
982
- * specified. Default: true.
983
- *
984
  * @return mixed The meta value(s) being requested.
985
  */
986
  function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true ) {
@@ -993,10 +975,10 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
993
  *
994
  * @since BuddyPress (1.5.0)
995
  *
996
- * @param mixed $retval The meta values for the activity item.
997
  * @param int $activity_id ID of the activity item.
998
- * @param string $meta_key Meta key for the value being requested.
999
- * @param bool $single Whether to return one matched meta key row or all.
1000
  */
1001
  return apply_filters( 'bp_activity_get_meta', $retval, $activity_id, $meta_key, $single );
1002
  }
@@ -1006,15 +988,16 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
1006
  *
1007
  * @since BuddyPress (1.2.0)
1008
  *
1009
- * @param int $activity_id ID of the activity item whose metadata is being updated.
1010
- * @param string $meta_key Key of the metadata being updated.
1011
- * @param mixed $meta_value Value to be set.
1012
- * @param mixed $prev_value Optional. If specified, only update existing metadata entries
1013
- * with the specified value. Otherwise, update all entries.
1014
- *
 
1015
  * @return bool|int Returns false on failure. On successful update of existing
1016
- * metadata, returns true. On successful creation of new metadata,
1017
- * returns the integer ID of the new metadata row.
1018
  */
1019
  function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_value = '' ) {
1020
  add_filter( 'query', 'bp_filter_metaid_column_name' );
@@ -1029,13 +1012,12 @@ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_va
1029
  *
1030
  * @since BuddyPress (2.0.0)
1031
  *
1032
- * @param int $activity_id ID of the activity item.
1033
- * @param string $meta_key Metadata key.
1034
- * @param mixed $meta_value Metadata value.
1035
- * @param bool $unique Optional. Whether to enforce a single metadata value for the
1036
- * given key. If true, and the object already has a value for
1037
- * the key, no change will be made. Default: false.
1038
- *
1039
  * @return int|bool The meta ID on successful update, false on failure.
1040
  */
1041
  function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = false ) {
@@ -1060,8 +1042,6 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
1060
  * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook.
1061
  *
1062
  * @param int $user_id ID of the user whose activity is being deleted.
1063
- *
1064
- * @return bool
1065
  */
1066
  function bp_activity_remove_all_user_data( $user_id = 0 ) {
1067
 
@@ -1098,10 +1078,9 @@ add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
1098
  * @since BuddyPress (1.6.0)
1099
  *
1100
  * @global object $wpdb WordPress database access object.
 
1101
  *
1102
  * @param int $user_id ID of the user whose activity is being spammed.
1103
- *
1104
- * @return bool
1105
  */
1106
  function bp_activity_spam_all_user_data( $user_id = 0 ) {
1107
  global $wpdb;
@@ -1155,7 +1134,7 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
1155
  *
1156
  * @since BuddyPress (1.6.0)
1157
  *
1158
- * @param int $user_id ID of the user whose activity is being marked as spam.
1159
  * @param array $activities Array of activity items being marked as spam.
1160
  */
1161
  do_action( 'bp_activity_spam_all_user_data', $user_id, $activities['activities'] );
@@ -1168,10 +1147,9 @@ add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
1168
  * @since BuddyPress (1.6.0)
1169
  *
1170
  * @global object $wpdb WordPress database access object.
 
1171
  *
1172
  * @param int $user_id ID of the user whose activity is being hammed.
1173
- *
1174
- * @return bool
1175
  */
1176
  function bp_activity_ham_all_user_data( $user_id = 0 ) {
1177
  global $wpdb;
@@ -1226,7 +1204,7 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
1226
  *
1227
  * @since BuddyPress (1.6.0)
1228
  *
1229
- * @param int $user_id ID of the user whose activity is being marked as ham.
1230
  * @param array $activities Array of activity items being marked as ham.
1231
  */
1232
  do_action( 'bp_activity_ham_all_user_data', $user_id, $activities['activities'] );
@@ -1234,7 +1212,7 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
1234
  add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
1235
 
1236
  /**
1237
- * Register the activity stream actions for updates.
1238
  *
1239
  * @since BuddyPress (1.6.0)
1240
  */
@@ -1276,9 +1254,8 @@ add_action( 'bp_register_activity_actions', 'bp_activity_register_activity_actio
1276
  * Generate an activity action string for an activity item.
1277
  *
1278
  * @param object $activity Activity data object.
1279
- *
1280
  * @return string|bool Returns false if no callback is found, otherwise returns
1281
- * the formatted action string.
1282
  */
1283
  function bp_activity_generate_action_string( $activity ) {
1284
 
@@ -1301,7 +1278,7 @@ function bp_activity_generate_action_string( $activity ) {
1301
  *
1302
  * @since BuddyPress (2.0.0)
1303
  *
1304
- * @param BP_Activity_Activity $action Action string being requested.
1305
  * @param BP_Activity_Activity $activity Activity item object.
1306
  */
1307
  $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
@@ -1317,9 +1294,8 @@ function bp_activity_generate_action_string( $activity ) {
1317
  *
1318
  * @since BuddyPress (2.0.0)
1319
  *
1320
- * @param string $action Static activity action.
1321
  * @param object $activity Activity data object.
1322
- *
1323
  * @return string
1324
  */
1325
  function bp_activity_format_activity_action_activity_update( $action, $activity ) {
@@ -1330,7 +1306,7 @@ function bp_activity_format_activity_action_activity_update( $action, $activity
1330
  *
1331
  * @since BuddyPress (1.2.0)
1332
  *
1333
- * @param string $action Activity action string value.
1334
  * @param BP_Activity_Activity $activity Activity item object.
1335
  */
1336
  return apply_filters( 'bp_activity_new_update_action', $action, $activity );
@@ -1341,9 +1317,8 @@ function bp_activity_format_activity_action_activity_update( $action, $activity
1341
  *
1342
  * @since BuddyPress (2.0.0)
1343
  *
1344
- * @param string $action Static activity action.
1345
  * @param object $activity Activity data object.
1346
- *
1347
  * @return string
1348
  */
1349
  function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
@@ -1354,7 +1329,7 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
1354
  *
1355
  * @since BuddyPress (1.2.0)
1356
  *
1357
- * @param string $action Activity action string value.
1358
  * @param BP_Activity_Activity $activity Activity item object.
1359
  */
1360
  return apply_filters( 'bp_activity_comment_action', $action, $activity );
@@ -1367,7 +1342,6 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
1367
  *
1368
  * @param string $action Static activity action.
1369
  * @param object $activity Activity data object.
1370
- *
1371
  * @return string
1372
  */
1373
  function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) {
@@ -1412,7 +1386,7 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
1412
  *
1413
  * @since BuddyPress (2.2.0)
1414
  *
1415
- * @param string $action Activity action string value.
1416
  * @param BP_Activity_Activity $activity Activity item object.
1417
  */
1418
  return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity );
@@ -1444,8 +1418,7 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
1444
  * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
1445
  * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
1446
  *
1447
- * @param array|string $args See BP_Activity_Activity::get() for description.
1448
- *
1449
  * @return array $activity See BP_Activity_Activity::get() for description.
1450
  */
1451
  function bp_activity_get( $args = '' ) {
@@ -1536,7 +1509,7 @@ function bp_activity_get( $args = '' ) {
1536
  * @since BuddyPress (1.2.0)
1537
  *
1538
  * @param BP_Activity_Activity $activity Requested activity object.
1539
- * @param array $r Arguments used for the activity query.
1540
  */
1541
  return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
1542
  }
@@ -1546,12 +1519,12 @@ function bp_activity_get( $args = '' ) {
1546
  *
1547
  * @since BuddyPress (1.2.0)
1548
  *
1549
- * @see BP_Activity_Activity::get() For more information on accepted arguments.
1550
  * @uses wp_parse_args()
1551
- * @uses apply_filters() To call the 'bp_activity_get_specific' hook.
1552
  * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
1553
  *
1554
- * @param array|string $args {
1555
  * All arguments and defaults are shared with BP_Activity_Activity::get(),
1556
  * except for the following:
1557
  * @type string|int|array Single activity ID, comma-separated list of IDs,
@@ -1591,7 +1564,7 @@ function bp_activity_get_specific( $args = '' ) {
1591
  * @since BuddyPress (1.2.0)
1592
  *
1593
  * @param BP_Activity_Activity $activity Requested activity object.
1594
- * @param array $args Original passed in arguments.
1595
  * @param array $get_args Constructed arguments used with request.
1596
  */
1597
  return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
@@ -1606,38 +1579,38 @@ function bp_activity_get_specific( $args = '' ) {
1606
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
1607
  * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
1608
  * @uses wp_cache_delete()
1609
- * @uses do_action() To call the 'bp_activity_add' hook.
1610
  *
1611
- * @param array|string $args {
1612
  * An array of arguments.
1613
- * @type int|bool $id Pass an activity ID to update an existing item, or
1614
- * false to create a new item. Default: false.
1615
- * @type string $action Optional. The activity action/description, typically
1616
- * something like "Joe posted an update". Values passed to this param
1617
- * will be stored in the database and used as a fallback for when the
1618
- * activity item's format_callback cannot be found (eg, when the
1619
- * component is disabled). As long as you have registered a
1620
- * format_callback for your $type, it is unnecessary to include this
1621
- * argument - BP will generate it automatically.
1622
- * See {@link bp_activity_set_action()}.
1623
- * @type string $content Optional. The content of the activity item.
1624
- * @type string $component The unique name of the component associated with
1625
- * the activity item - 'groups', 'profile', etc.
1626
- * @type string $type The specific activity type, used for directory
1627
- * filtering. 'new_blog_post', 'activity_update', etc.
1628
- * @type string $primary_link Optional. The URL for this item, as used in
1629
- * RSS feeds. Defaults to the URL for this activity
1630
- * item's permalink page.
1631
- * @type int|bool $user_id Optional. The ID of the user associated with the activity
1632
- * item. May be set to false or 0 if the item is not related
1633
- * to any user. Default: the ID of the currently logged-in user.
1634
- * @type int $item_id Optional. The ID of the associated item.
1635
- * @type int $secondary_item_id Optional. The ID of a secondary associated item.
1636
- * @type string $date_recorded Optional. The GMT time, in Y-m-d h:i:s format, when
1637
- * the item was recorded. Defaults to the current time.
1638
- * @type bool $hide_sitewide Should the item be hidden on sitewide streams?
1639
- * Default: false.
1640
- * @type bool $is_spam Should the item be marked as spam? Default: false.
1641
  * }
1642
  * @return int|bool The ID of the activity on success. False on error.
1643
  */
@@ -1656,7 +1629,7 @@ function bp_activity_add( $args = '' ) {
1656
  'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
1657
  'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
1658
  'is_spam' => false, // Is this activity item to be marked as spam?
1659
- ), 'activity_add' );
1660
 
1661
  // Make sure we are backwards compatible
1662
  if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
@@ -1725,11 +1698,11 @@ function bp_activity_add( $args = '' ) {
1725
  * @uses wp_filter_kses()
1726
  * @uses do_action() To call the 'bp_activity_posted_update' hook.
1727
  *
1728
- * @param array|string $args {
1729
  * @type string $content The content of the activity update.
1730
- * @type int $user_id Optional. Defaults to the logged-in user.
1731
  * }
1732
- * @return int $activity_id The activity id.
1733
  */
1734
  function bp_activity_post_update( $args = '' ) {
1735
 
@@ -1782,7 +1755,7 @@ function bp_activity_post_update( $args = '' ) {
1782
  *
1783
  * @since BuddyPress (1.6.0)
1784
  *
1785
- * @param string $r Content of the activity update.
1786
  * @param string $activity_content Content of the activity update.
1787
  */
1788
  $activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content );
@@ -1798,8 +1771,8 @@ function bp_activity_post_update( $args = '' ) {
1798
  *
1799
  * @since BuddyPress (1.2.0)
1800
  *
1801
- * @param string $content Content of the activity post update.
1802
- * @param int $user_id ID of the user posting the activity update.
1803
  * @param int $activity_id ID of the activity item being updated.
1804
  */
1805
  do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
@@ -1815,10 +1788,10 @@ function bp_activity_post_update( $args = '' ) {
1815
  * @param int $post_id ID of the new post.
1816
  * @param WP_Post $post Post object.
1817
  * @param int $user_id ID of the post author.
1818
- *
1819
  * @return int|bool The ID of the activity on success. False on error.
1820
  */
1821
  function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0 ) {
 
1822
 
1823
  if ( ! is_a( $post, 'WP_Post' ) ) {
1824
  return;
@@ -1899,15 +1872,20 @@ function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0
1899
  'recorded_time' => $post->post_date_gmt,
1900
  );
1901
 
 
 
 
 
 
1902
  if ( ! empty( $activity_args['content'] ) ) {
1903
  // Create the excerpt.
1904
- $activity_summary = bp_activity_create_summary( $activity_args['content'], $activity_args );
1905
 
1906
  // Backward compatibility filter for blog posts.
1907
  if ( 'blogs' == $activity_post_object->component_id ) {
1908
- $activity_args['content'] = apply_filters( 'bp_blogs_record_activity_content', $activity_summary, $activity_args['content'], $activity_args, $post->post_type );
1909
  } else {
1910
- $activity_args['content'] = $activity_summary;
1911
  }
1912
  }
1913
 
@@ -1951,10 +1929,10 @@ function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0
1951
  * @since BuddyPress (2.2.0)
1952
  *
1953
  * @param WP_Post $post Post item.
1954
- *
1955
  * @return bool True on success, false on failure.
1956
  */
1957
  function bp_activity_post_type_update( $post = null ) {
 
1958
 
1959
  if ( ! is_a( $post, 'WP_Post' ) ) {
1960
  return;
@@ -1988,13 +1966,17 @@ function bp_activity_post_type_update( $post = null ) {
1988
  $activity = new BP_Activity_Activity( $activity_id );
1989
 
1990
  if ( ! empty( $post->post_content ) ) {
1991
- $activity_summary = bp_activity_create_summary( $post->post_content, (array) $activity );
 
 
 
 
1992
 
1993
  // Backward compatibility filter for the blogs component.
1994
  if ( 'blogs' == $activity_post_object->component_id ) {
1995
- $activity->content = apply_filters( 'bp_blogs_record_activity_content', $activity_summary, $post->post_content, (array) $activity, $post->post_type );
1996
  } else {
1997
- $activity->content = $activity_summary;
1998
  }
1999
  }
2000
 
@@ -2006,7 +1988,7 @@ function bp_activity_post_type_update( $post = null ) {
2006
  *
2007
  * @since BuddyPress (2.2.0)
2008
  *
2009
- * @param WP_Post $post Post object.
2010
  * @param BP_Activity_Activity $activity Activity object.
2011
  */
2012
  do_action( 'bp_activity_post_type_updated', $post, $activity );
@@ -2021,10 +2003,10 @@ function bp_activity_post_type_update( $post = null ) {
2021
  *
2022
  * @param int $post_id ID of the post being unpublished.
2023
  * @param WP_Post $post Post object.
2024
- *
2025
  * @return bool True on success, false on failure.
2026
  */
2027
  function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
 
2028
 
2029
  if ( ! is_a( $post, 'WP_Post' ) ) {
2030
  return;
@@ -2058,7 +2040,8 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2058
  *
2059
  * @param array $delete_activity_args Array of arguments for activity deletion.
2060
  * @param WP_Post $post Post object.
2061
- * @param bool $activity Whether or not the activity was successfully deleted.
 
2062
  */
2063
  do_action( 'bp_activity_post_type_unpublished', $delete_activity_args, $post, $deleted );
2064
 
@@ -2070,6 +2053,7 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2070
  *
2071
  * @since BuddyPress (1.2.0)
2072
  *
 
2073
  * @uses wp_parse_args()
2074
  * @uses bp_activity_add()
2075
  * @uses apply_filters() To call the 'bp_activity_comment_action' hook.
@@ -2077,16 +2061,16 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2077
  * @uses wp_cache_delete()
2078
  * @uses do_action() To call the 'bp_activity_comment_posted' hook.
2079
  *
2080
- * @param array|string $args {
2081
- * @type int $id Optional. Pass an ID to update an existing comment.
2082
- * @type string $content The content of the comment.
2083
- * @type int $user_id Optional. The ID of the user making the comment.
2084
- * Defaults to the ID of the logged-in user.
2085
- * @type int $activity_id The ID of the "root" activity item, ie the oldest
2086
- * ancestor of the comment.
2087
- * @type int $parent_id Optional. The ID of the parent activity item, ie the item to
2088
- * which the comment is an immediate reply. If not provided,
2089
- * this value defaults to the $activity_id.
2090
  * }
2091
  * @return int|bool The ID of the comment on success, otherwise false.
2092
  */
@@ -2175,8 +2159,8 @@ function bp_activity_new_comment( $args = '' ) {
2175
  * @since BuddyPress (1.2.0)
2176
  *
2177
  * @param int $comment_id ID of the newly posted activity comment.
2178
- * @param array $r Array of parsed comment arguments.
2179
- * @param int $activity ID of the activity item being commented on.
2180
  */
2181
  do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity );
2182
 
@@ -2198,8 +2182,7 @@ function bp_activity_new_comment( $args = '' ) {
2198
  * @uses apply_filters() To call the 'bp_activity_get_activity_id' hook.
2199
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
2200
  *
2201
- * @param array|string $args See BP_Activity_Activity::get() for description.
2202
- *
2203
  * @return int $activity_id The ID of the activity item found.
2204
  */
2205
  function bp_activity_get_activity_id( $args = '' ) {
@@ -2220,7 +2203,7 @@ function bp_activity_get_activity_id( $args = '' ) {
2220
  *
2221
  * @since BuddyPress (1.2.0)
2222
  *
2223
- * @param BP_Activity_Activity $value ID returned by BP_Activity_Activity get_id() method with provided arguments.
2224
  */
2225
  return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
2226
  $r['user_id'],
@@ -2260,12 +2243,10 @@ function bp_activity_get_activity_id( $args = '' ) {
2260
  * @uses do_action() To call the 'bp_activity_deleted_activities' hook.
2261
  * @uses wp_cache_delete()
2262
  *
2263
- * @param array|string $args To delete specific activity items, use
2264
- * $args = array( 'id' => $ids ); Otherwise, to use
2265
- * filters for item deletion, the argument format is
2266
- * the same as BP_Activity_Activity::get().
2267
- * See that method for a description.
2268
- *
2269
  * @return bool True on success, false on failure.
2270
  */
2271
  function bp_activity_delete( $args = '' ) {
@@ -2348,8 +2329,8 @@ function bp_activity_delete( $args = '' ) {
2348
  * @uses wp_parse_args()
2349
  * @uses bp_activity_delete()
2350
  *
2351
- * @param array|string $args See BP_Activity_Activity::get for a
2352
- * description of accepted arguments.
2353
  *
2354
  * @return bool True on success, false on failure.
2355
  */
@@ -2373,8 +2354,7 @@ function bp_activity_delete( $args = '' ) {
2373
  *
2374
  * @uses bp_activity_delete()
2375
  *
2376
- * @param int $activity_id ID of the activity item to be deleted.
2377
- *
2378
  * @return bool True on success, false on failure.
2379
  */
2380
  function bp_activity_delete_by_activity_id( $activity_id ) {
@@ -2391,11 +2371,10 @@ function bp_activity_delete( $args = '' ) {
2391
  *
2392
  * @uses bp_activity_delete()
2393
  *
2394
- * @param int $user_id The user id.
2395
- * @param string $content The activity id.
2396
  * @param string $component The activity component.
2397
- * @param string $type The activity type.
2398
- *
2399
  * @return bool True on success, false on failure.
2400
  */
2401
  function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
@@ -2417,9 +2396,8 @@ function bp_activity_delete( $args = '' ) {
2417
  *
2418
  * @uses bp_activity_delete()
2419
  *
2420
- * @param int $user_id The user id.
2421
  * @param string $component The activity component.
2422
- *
2423
  * @return bool True on success, false on failure.
2424
  */
2425
  function bp_activity_delete_for_user_by_component( $user_id, $component ) {
@@ -2446,9 +2424,8 @@ function bp_activity_delete( $args = '' ) {
2446
  *
2447
  * @param int $activity_id The ID of the "root" activity, ie the comment's
2448
  * oldest ancestor.
2449
- * @param int $comment_id The ID of the comment to be deleted.
2450
- *
2451
- * @return bool True on success, false on failure.
2452
  */
2453
  function bp_activity_delete_comment( $activity_id, $comment_id ) {
2454
 
@@ -2460,9 +2437,9 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2460
  *
2461
  * @since BuddyPress (1.2.0)
2462
  *
2463
- * @param bool $value Whether BuddyPress should continue or not.
2464
  * @param int $activity_id ID of the root activity item being deleted.
2465
- * @param int $comment_id ID of the comment being deleted.
2466
  */
2467
  if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
2468
  return false;
@@ -2488,7 +2465,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2488
  * @since BuddyPress (1.2.0)
2489
  *
2490
  * @param int $activity_id ID of the activity that has had a comment deleted from.
2491
- * @param int $comment_id ID of the comment that was deleted.
2492
  */
2493
  do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
2494
 
@@ -2505,8 +2482,8 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2505
  * @uses bp_activity_delete()
2506
  *
2507
  * @param int $activity_id The ID of the "root" activity, ie the
2508
- * comment's oldest ancestor.
2509
- * @param int $comment_id The ID of the comment to be deleted.
2510
  */
2511
  function bp_activity_delete_children( $activity_id, $comment_id ) {
2512
 
@@ -2542,9 +2519,8 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2542
  * @uses bp_get_activity_root_slug()
2543
  * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook.
2544
  *
2545
- * @param int $activity_id The unique id of the activity object.
2546
- * @param object|bool $activity_obj Optional. The activity object.
2547
- *
2548
  * @return string $link Permalink for the activity item.
2549
  */
2550
  function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
@@ -2597,7 +2573,6 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
2597
  * @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
2598
  *
2599
  * @param int $user_id The ID of the user whose activity is being hidden.
2600
- *
2601
  * @return bool True on success, false on failure.
2602
  */
2603
  function bp_activity_hide_user_activity( $user_id ) {
@@ -2614,21 +2589,18 @@ function bp_activity_hide_user_activity( $user_id ) {
2614
  * through the content, grabs the first image and converts it to a thumbnail,
2615
  * and removes the rest of the images from the string.
2616
  *
2617
- * As of BuddyPress 2.3, this function is no longer in use.
2618
- *
2619
  * @since BuddyPress (1.2.0)
2620
  *
2621
  * @uses esc_attr()
2622
- * @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook.
2623
- *
2624
- * @param string $content The content of the activity item.
2625
- * @param string|bool $link Optional. The unescaped URL that the image should link
2626
- * to. If absent, the image will not be a link.
2627
- * @param array|bool $args Optional. The args passed to the activity
2628
- * creation function (eg bp_blogs_record_activity()).
2629
  *
 
 
 
 
 
2630
  * @return string $content The content with images stripped and replaced with a
2631
- * single thumb.
2632
  */
2633
  function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
2634
 
@@ -2646,16 +2618,10 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
2646
  preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
2647
  preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
2648
 
2649
- if ( ! empty( $src ) ) {
2650
- $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
2651
-
2652
- if ( isset( $width[1] ) ) {
2653
- $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
2654
- }
2655
-
2656
- if ( isset( $height[1] ) ) {
2657
- $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
2658
- }
2659
 
2660
  if ( empty( $width ) || empty( $height ) ) {
2661
  $width = 100;
@@ -2682,173 +2648,11 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
2682
  *
2683
  * @param string $content Activity content that had images replaced in.
2684
  * @param array $matches Array of all image tags found in the posted content.
2685
- * @param array $args Arguments passed into function creating the activity update.
2686
  */
2687
  return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches, $args );
2688
  }
2689
 
2690
- /**
2691
- * Create a rich summary of an activity item for the activity stream.
2692
- *
2693
- * More than just a simple excerpt, the summary could contain oEmbeds and other types of media.
2694
- * Currently, it's only used for blog post items, but it will probably be used for all types of
2695
- * activity in the future.
2696
- *
2697
- * @since BuddyPress (2.3.0)
2698
- *
2699
- * @param string $content The content of the activity item.
2700
- * @param array $activity The data passed to bp_activity_add() or the values
2701
- * from an Activity obj.
2702
- *
2703
- * @return string
2704
- */
2705
- function bp_activity_create_summary( $content, $activity ) {
2706
- $args = array(
2707
- 'width' => isset( $GLOBALS['content_width'] ) ? (int) $GLOBALS['content_width'] : 'medium',
2708
- );
2709
-
2710
- // Get the WP_Post object if this activity type is a blog post.
2711
- if ( $activity['type'] === 'new_blog_post' ) {
2712
- $content = get_post( $activity['secondary_item_id'] );
2713
- }
2714
-
2715
- /**
2716
- * Filter the class name of the media extractor when creating an Activity summary.
2717
- *
2718
- * Use this filter to change the media extractor used to extract media info for the activity item.
2719
- *
2720
- * @since BuddyPress (2.3.0)
2721
- *
2722
- * @param string $extractor Class name.
2723
- * @param string $content The content of the activity item.
2724
- * @param array $activity The data passed to bp_activity_add() or the values from an Activity obj.
2725
- */
2726
- $extractor = apply_filters( 'bp_activity_create_summary_extractor_class', 'BP_Media_Extractor', $content, $activity );
2727
- $extractor = new $extractor;
2728
-
2729
- /**
2730
- * Filter the arguments passed to the media extractor when creating an Activity summary.
2731
- *
2732
- * @since BuddyPress (2.3.0)
2733
- *
2734
- * @param array $args Array of bespoke data for the media extractor.
2735
- * @param string $content The content of the activity item.
2736
- * @param array $activity The data passed to bp_activity_add() or the values from an Activity obj.
2737
- * @param BP_Media_Extractor $extractor The media extractor object.
2738
- */
2739
- $args = apply_filters( 'bp_activity_create_summary_extractor_args', $args, $content, $activity, $extractor );
2740
-
2741
-
2742
- // Extract media information from the $content.
2743
- $media = $extractor->extract( $content, BP_Media_Extractor::ALL, $args );
2744
-
2745
- // If we converted $content to an object earlier, flip it back to a string.
2746
- if ( is_a( $content, 'WP_Post' ) ) {
2747
- $content = $content->post_content;
2748
- }
2749
-
2750
- $para_count = substr_count( strtolower( wpautop( $content ) ), '<p>' );
2751
- $has_audio = ! empty( $media['has']['audio'] ) && $media['has']['audio'];
2752
- $has_videos = ! empty( $media['has']['videos'] ) && $media['has']['videos'];
2753
- $has_feat_image = ! empty( $media['has']['featured_images'] ) && $media['has']['featured_images'];
2754
- $has_galleries = ! empty( $media['has']['galleries'] ) && $media['has']['galleries'];
2755
- $has_images = ! empty( $media['has']['images'] ) && $media['has']['images'];
2756
- $has_embeds = false;
2757
-
2758
- // Embeds must be subtracted from the paragraph count.
2759
- if ( ! empty( $media['has']['embeds'] ) ) {
2760
- $has_embeds = $media['has']['embeds'] > 0;
2761
- $para_count -= count( $media['has']['embeds'] );
2762
- }
2763
-
2764
- $extracted_media = array();
2765
- $use_media_type = '';
2766
- $image_source = '';
2767
-
2768
- // If it's a short article and there's an embed/audio/video, use it.
2769
- if ( $para_count <= 3 ) {
2770
- if ( $has_embeds ) {
2771
- $use_media_type = 'embeds';
2772
- } elseif ( $has_audio ) {
2773
- $use_media_type = 'audio';
2774
- } elseif ( $has_videos ) {
2775
- $use_media_type = 'videos';
2776
- }
2777
- }
2778
-
2779
- // If not, or in any other situation, try to use an image.
2780
- if ( ! $use_media_type && $has_images ) {
2781
- $use_media_type = 'images';
2782
- $image_source = 'html';
2783
-
2784
- // Featured Image > Galleries > inline <img>.
2785
- if ( $has_feat_image ) {
2786
- $image_source = 'featured_images';
2787
-
2788
- } elseif ( $has_galleries ) {
2789
- $image_source = 'galleries';
2790
- }
2791
- }
2792
-
2793
- // Extract an item from the $media results.
2794
- if ( $use_media_type ) {
2795
- if ( $use_media_type === 'images' ) {
2796
- $extracted_media = wp_list_filter( $media[ $use_media_type ], array( 'source' => $image_source ) );
2797
- $extracted_media = array_shift( $extracted_media );
2798
- } else {
2799
- $extracted_media = array_shift( $media[ $use_media_type ] );
2800
- }
2801
-
2802
- /**
2803
- * Filter the results of the media extractor when creating an Activity summary.
2804
- *
2805
- * @since BuddyPress (2.3.0)
2806
- *
2807
- * @param array $extracted_media Extracted media item. See {@link BP_Media_Extractor::extract()} for format.
2808
- * @param string $content Content of the activity item.
2809
- * @param array $activity The data passed to bp_activity_add() or the values from an Activity obj.
2810
- * @param array $media All results from the media extraction.
2811
- * See {@link BP_Media_Extractor::extract()} for format.
2812
- * @param string $use_media_type The kind of media item that was preferentially extracted.
2813
- * @param string $image_source If $use_media_type was "images", the preferential source of the image.
2814
- * Otherwise empty.
2815
- */
2816
- $extracted_media = apply_filters(
2817
- 'bp_activity_create_summary_extractor_result',
2818
- $extracted_media,
2819
- $content,
2820
- $activity,
2821
- $media,
2822
- $use_media_type,
2823
- $image_source
2824
- );
2825
- }
2826
-
2827
- // Generate a text excerpt for this activity item (and remove any oEmbeds URLs).
2828
- $summary = strip_shortcodes( html_entity_decode( strip_tags( $content ) ) );
2829
- $summary = bp_create_excerpt( preg_replace( '#^\s*(https?://[^\s"]+)\s*$#im', '', $summary ) );
2830
-
2831
- if ( $use_media_type === 'embeds' ) {
2832
- $summary .= PHP_EOL . PHP_EOL . $extracted_media['url'];
2833
- } elseif ( $use_media_type === 'images' ) {
2834
- $summary .= sprintf( ' <img src="%s">', esc_url( $extracted_media['url'] ) );
2835
- } elseif ( in_array( $use_media_type, array( 'audio', 'videos' ), true ) ) {
2836
- $summary .= PHP_EOL . PHP_EOL . $extracted_media['original']; // Full shortcode.
2837
- }
2838
-
2839
- /**
2840
- * Filters the newly-generated summary for the activity item.
2841
- *
2842
- * @since BuddyPress (2.3.0)
2843
- *
2844
- * @param string $summary Activity summary HTML.
2845
- * @param string $content Content of the activity item.
2846
- * @param array $activity The data passed to bp_activity_add() or the values from an Activity obj.
2847
- * @param array $extracted_media Media item extracted. See {@link BP_Media_Extractor::extract()} for format.
2848
- */
2849
- return apply_filters( 'bp_activity_create_summary', $summary, $content, $activity, $extracted_media );
2850
- }
2851
-
2852
  /**
2853
  * Fetch whether the current user is allowed to mark items as spam.
2854
  *
@@ -2874,9 +2678,9 @@ function bp_activity_user_can_mark_spam() {
2874
  * @since BuddyPress (1.6.0)
2875
  *
2876
  * @param BP_Activity_Activity $activity The activity item to be spammed.
2877
- * @param string $source Optional. Default is "by_a_person" (ie, a person has
2878
- * manually marked the activity as spam). BP core also
2879
- * accepts 'by_akismet'.
2880
  */
2881
  function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
2882
  $bp = buddypress();
@@ -2909,8 +2713,8 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
2909
  * @since BuddyPress (1.6.0)
2910
  *
2911
  * @param BP_Activity_Activity $activity Activity item being marked as spam.
2912
- * @param string $source Source of determination of spam status. For example
2913
- * "by_a_person" or "by_akismet".
2914
  */
2915
  do_action( 'bp_activity_mark_as_spam', $activity, $source );
2916
  }
@@ -2920,10 +2724,10 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
2920
  *
2921
  * @since BuddyPress (1.6.0)
2922
  *
2923
- * @param BP_Activity_Activity $activity The activity item to be hammed. Passed by reference.
2924
- * @param string $source Optional. Default is "by_a_person" (ie, a person has
2925
- * manually marked the activity as spam). BP core also accepts
2926
- * 'by_akismet'.
2927
  */
2928
  function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
2929
  $bp = buddypress();
@@ -2956,8 +2760,8 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
2956
  * @since BuddyPress (1.6.0)
2957
  *
2958
  * @param BP_Activity_Activity $activity Activity item being marked as ham.
2959
- * @param string $source Source of determination of ham status. For example
2960
- * "by_a_person" or "by_akismet".
2961
  */
2962
  do_action( 'bp_activity_mark_as_ham', $activity, $source );
2963
  }
@@ -2980,7 +2784,6 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
2980
  * @see BP_Embed
2981
  * @see bp_embed_activity_cache()
2982
  * @see bp_embed_activity_save_cache()
2983
- *
2984
  * @uses add_filter() To attach 'bp_get_activity_id' to 'embed_post_id'.
2985
  * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
2986
  * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
@@ -3005,7 +2808,6 @@ add_action( 'activity_loop_start', 'bp_activity_embed' );
3005
  * @see BP_Embed
3006
  * @see bp_embed_activity_cache()
3007
  * @see bp_embed_activity_save_cache()
3008
- *
3009
  * @uses add_filter() To attach 'bp_get_activity_comment_id' to 'embed_post_id'.
3010
  * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
3011
  * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
@@ -3065,11 +2867,10 @@ add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurs
3065
  * @see BP_Embed::parse_oembed()
3066
  * @uses bp_activity_get_meta()
3067
  *
3068
- * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
3069
- * functions like this one to filter.
3070
- * @param int $id The ID of the activity item.
3071
  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
3072
- *
3073
  * @return mixed The cached embeds for this activity item.
3074
  */
3075
  function bp_embed_activity_cache( $cache, $id, $cachekey ) {
@@ -3086,11 +2887,10 @@ function bp_embed_activity_cache( $cache, $id, $cachekey ) {
3086
  * @see BP_Embed::parse_oembed()
3087
  * @uses bp_activity_update_meta()
3088
  *
3089
- * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
3090
- * functions like this one to filter.
3091
  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
3092
- * @param int $id The ID of the activity item.
3093
- *
3094
  * @return bool True on success, false on failure.
3095
  */
3096
  function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
28
  *
29
  * The Mentions feature does a number of things, all of which will be turned
30
  * off if you disable mentions:
31
+ * - Detecting and auto-linking @username in all BP/WP content
32
  * - Sending BP notifications and emails to users when they are mentioned
33
+ * using the @username syntax
34
+ * - The Public Message button on user profiles
35
  *
36
  * Mentions are enabled by default. To disable, put the following line in
37
  * bp-custom.php or your theme's functions.php file:
60
  * Should BuddyPress load the mentions scripts and related assets, including results to prime the
61
  * mentions suggestions?
62
  *
 
 
63
  * @return bool True if mentions scripts should be loaded.
64
+ * @since BuddyPress (2.1.0)
65
  */
66
  function bp_activity_maybe_load_mentions_scripts() {
67
  $mentions_enabled = bp_activity_do_mentions() && bp_is_user_active();
72
  *
73
  * @since BuddyPress (2.1.0)
74
  *
75
+ * @param bool $load_mentions True to load mentions assets, false otherwise.
76
  * @param bool $mentions_enabled True if mentions are enabled.
77
  */
78
  return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $load_mentions, $mentions_enabled );
84
  * @since BuddyPress (1.5.0)
85
  *
86
  * @param string $content The content of the activity, usually found in
87
+ * $activity->content.
 
88
  * @return array|bool Associative array with user ID as key and username as
89
+ * value. Boolean false if no mentions found.
90
  */
91
  function bp_activity_find_mentions( $content ) {
92
 
147
  * @uses bp_activity_find_mentions()
148
  * @uses bp_activity_update_mention_count_for_user()
149
  *
150
+ * @param int $activity_id The unique id for the activity item.
151
+ * @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
 
 
152
  */
153
  function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
154
 
185
  * @uses bp_get_user_meta()
186
  * @uses bp_update_user_meta()
187
  *
188
+ * @param int $user_id The user ID.
189
+ * @param int $activity_id The unique ID for the activity item.
190
+ * @param string $action 'delete' or 'add'. Default: 'add'.
 
191
  * @return bool
192
  */
193
  function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
239
  *
240
  * @since BuddyPress (1.9.0)
241
  *
 
 
242
  * @return string User name appropriate for @-mentions.
243
  */
244
  function bp_activity_get_user_mentionname( $user_id ) {
262
  *
263
  * @since BuddyPress (1.9.0)
264
  *
 
 
265
  * @return int|bool ID of the user, if one is found. Otherwise false.
266
  */
267
  function bp_activity_get_userid_from_mentionname( $mentionname ) {
315
  *
316
  * @since BuddyPress (1.1.0)
317
  *
318
+ * @param string $component_id The unique string ID of the component.
319
+ * @param string $type The action type.
320
+ * @param string $description The action description.
321
+ * @param callable $format_callback Callback for formatting the action string.
322
+ * @param string $label String to describe this action in the activity stream filter dropdown.
323
+ * @param array $context Optional. Activity stream contexts where the filter should appear.
324
+ * Values: 'activity', 'member', 'member_groups', 'group'
325
+ * @param int $position Optional. The position of the action when listed in dropdowns.
 
326
  * @return bool False if any param is empty, otherwise true.
327
  */
328
  function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array(), $position = 0 ) {
352
  *
353
  * @since BuddyPress (1.1.0)
354
  *
355
+ * @param array $array Array of arguments for action type being set.
356
+ * @param string $component_id ID of the current component being set.
357
+ * @param string $type Action type being set.
358
+ * @param string $description Action description for action being set.
359
  * @param callable $format_callback Callback for formatting the action string.
360
+ * @param string $label String to describe this action in the activity stream filter dropdown.
361
+ * @param array $context Activity stream contexts where the filter should appear. 'activity', 'member',
362
+ * 'member_groups', 'group'.
363
  */
364
  $bp->activity->actions->{$component_id}->{$type} = apply_filters( 'bp_activity_set_action', array(
365
  'key' => $type,
398
  * @type callable $format_callback Callback for formatting the activity action string.
399
  * Default: 'bp_activity_format_activity_action_custom_post_type_post'.
400
  * @type array $contexts The directory contexts in which the filter will show.
401
+ * Default: array( 'activity' ),
402
  * @type array $position Position of the item in filter dropdowns.
403
  * @type string $singular Singular, translatable name of the post type item. If no value is
404
  * provided, it's pulled from the 'singular_name' of the post type.
405
  * @type bool $activity_comment Whether to allow comments on the activity items. Defaults to true if
406
  * the post type does not natively support comments, otherwise false.
407
  * }
 
 
408
  */
409
  function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array() ) {
410
  global $wp_post_types;
411
+ $bp = buddypress();
412
 
413
  if ( empty( $wp_post_types[ $post_type ] ) || ! post_type_supports( $post_type, 'buddypress-activity' ) || ! is_array( $args ) ) {
414
  return false;
433
  *
434
  * @since BuddyPress (2.2.0)
435
  *
436
+ * @param string $post_type Name of the post type
 
437
  * @return object The tracking arguments of the post type.
438
  */
439
  function bp_activity_get_post_type_tracking_args( $post_type ) {
490
  * @since BuddyPress (2.2.0)
491
  *
492
  * @param object $post_type_activity The tracking arguments of the post type.
493
+ * @param string $post_type Name of the post type.
494
  */
495
  return apply_filters( 'bp_activity_get_post_type_tracking_args', $post_type_activity, $post_type );
496
  }
533
  *
534
  * @since BuddyPress (2.2.0)
535
  *
536
+ * @return object actions ordered by their position
537
  */
538
  function bp_activity_get_actions() {
539
  $bp = buddypress();
582
  * @uses apply_filters() To call the 'bp_activity_get_action' hook.
583
  *
584
  * @param string $component_id The unique string ID of the component.
585
+ * @param string $key The action key.
 
586
  * @return string|bool Action value if found, otherwise false.
587
  */
588
  function bp_activity_get_action( $component_id, $key ) {
592
  return false;
593
  }
594
 
595
+ $bp = buddypress();
596
  $actions = bp_activity_get_actions();
 
597
 
598
+ $retval = false;
599
  if ( isset( $actions->{$component_id}->{$key} ) ) {
600
  $retval = $actions->{$component_id}->{$key};
601
  }
655
  * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
656
  *
657
  * @param int $user_id ID of the user whose favorites are being queried.
 
658
  * @return array IDs of the user's favorite activity items.
659
  */
660
  function bp_activity_get_user_favorites( $user_id = 0 ) {
691
  * @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook.
692
  *
693
  * @param int $activity_id ID of the activity item being favorited.
694
+ * @param int $user_id ID of the user favoriting the activity item.
 
695
  * @return bool True on success, false on failure.
696
  */
697
  function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
735
  * @since BuddyPress (1.2.1)
736
  *
737
  * @param int $activity_id ID of the activity item being favorited.
738
+ * @param int $user_id ID of the user doing the favoriting.
739
  */
740
  do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
741
 
751
  * @since BuddyPress (1.5.0)
752
  *
753
  * @param int $activity_id ID of the activity item being favorited.
754
+ * @param int $user_id ID of the user doing the favoriting.
755
  */
756
  do_action( 'bp_activity_add_user_favorite_fail', $activity_id, $user_id );
757
 
772
  * @uses do_action() To call the 'bp_activity_remove_user_favorite' hook.
773
  *
774
  * @param int $activity_id ID of the activity item being unfavorited.
775
+ * @param int $user_id ID of the user unfavoriting the activity item.
 
776
  * @return bool True on success, false on failure.
777
  */
778
  function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
815
  * @since BuddyPress (1.2.1)
816
  *
817
  * @param int $activity_id ID of the activity item being unfavorited.
818
+ * @param int $user_id ID of the user doing the unfavoriting.
819
  */
820
  do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
821
 
847
  * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
848
  *
849
  * @param string $content The content to filter by.
 
850
  * @return int|null The ID of the located activity item. Null if none is found.
851
  */
852
  function bp_activity_check_exists_by_content( $content ) {
891
  * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
892
  *
893
  * @param int $user_id ID of the user whose favorite count is being requested.
 
894
  * @return int Total favorite count for the user.
895
  */
896
  function bp_activity_total_favorites_for_user( $user_id = 0 ) {
911
  * @since BuddyPress (1.2.0)
912
  *
913
  * @global object $wpdb WordPress database access object.
914
+ * @global object $bp BuddyPress global settings.
915
+ *
916
+ * @param int $activity_id ID of the activity item whose metadata is being deleted.
917
+ * @param string $meta_key Optional. The key of the metadata being deleted. If
918
+ * omitted, all metadata associated with the activity
919
+ * item will be deleted.
920
+ * @param string $meta_value Optional. If present, the metadata will only be
921
+ * deleted if the meta_value matches this parameter.
922
+ * @param bool $delete_all Optional. If true, delete matching metadata entries
923
+ * for all objects, ignoring the specified object_id. Otherwise,
924
+ * only delete matching metadata entries for the specified
925
+ * activity item. Default: false.
926
  * @return bool True on success, false on failure.
927
  */
928
  function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
956
  *
957
  * @uses apply_filters() To call the 'bp_activity_get_meta' hook.
958
  *
959
+ * @param int $activity_id ID of the activity item whose metadata is being requested.
960
+ * @param string $meta_key Optional. If present, only the metadata matching
961
+ * that meta key will be returned. Otherwise, all metadata for the
962
+ * activity item will be fetched.
963
+ * @param bool $single Optional. If true, return only the first value of the
964
+ * specified meta_key. This parameter has no effect if meta_key is not
965
+ * specified. Default: true.
 
966
  * @return mixed The meta value(s) being requested.
967
  */
968
  function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true ) {
975
  *
976
  * @since BuddyPress (1.5.0)
977
  *
978
+ * @param mixed $retval The meta values for the activity item.
979
  * @param int $activity_id ID of the activity item.
980
+ * @param string $meta_key Meta key for the value being requested.
981
+ * @param bool $single Whether to return one matched meta key row or all.
982
  */
983
  return apply_filters( 'bp_activity_get_meta', $retval, $activity_id, $meta_key, $single );
984
  }
988
  *
989
  * @since BuddyPress (1.2.0)
990
  *
991
+ * @param int $activity_id ID of the activity item whose metadata is being
992
+ * updated.
993
+ * @param string $meta_key Key of the metadata being updated.
994
+ * @param mixed $meta_value Value to be set.
995
+ * @param mixed $prev_value Optional. If specified, only update existing
996
+ * metadata entries with the specified value. Otherwise, update all
997
+ * entries.
998
  * @return bool|int Returns false on failure. On successful update of existing
999
+ * metadata, returns true. On successful creation of new metadata,
1000
+ * returns the integer ID of the new metadata row.
1001
  */
1002
  function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_value = '' ) {
1003
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1012
  *
1013
  * @since BuddyPress (2.0.0)
1014
  *
1015
+ * @param int $activity_id ID of the activity item.
1016
+ * @param string $meta_key Metadata key.
1017
+ * @param mixed $meta_value Metadata value.
1018
+ * @param bool $unique Optional. Whether to enforce a single metadata value
1019
+ * for the given key. If true, and the object already has a value for
1020
+ * the key, no change will be made. Default: false.
 
1021
  * @return int|bool The meta ID on successful update, false on failure.
1022
  */
1023
  function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = false ) {
1042
  * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook.
1043
  *
1044
  * @param int $user_id ID of the user whose activity is being deleted.
 
 
1045
  */
1046
  function bp_activity_remove_all_user_data( $user_id = 0 ) {
1047
 
1078
  * @since BuddyPress (1.6.0)
1079
  *
1080
  * @global object $wpdb WordPress database access object.
1081
+ * @global object $bp BuddyPress global settings.
1082
  *
1083
  * @param int $user_id ID of the user whose activity is being spammed.
 
 
1084
  */
1085
  function bp_activity_spam_all_user_data( $user_id = 0 ) {
1086
  global $wpdb;
1134
  *
1135
  * @since BuddyPress (1.6.0)
1136
  *
1137
+ * @param int $user_id ID of the user whose activity is being marked as spam.
1138
  * @param array $activities Array of activity items being marked as spam.
1139
  */
1140
  do_action( 'bp_activity_spam_all_user_data', $user_id, $activities['activities'] );
1147
  * @since BuddyPress (1.6.0)
1148
  *
1149
  * @global object $wpdb WordPress database access object.
1150
+ * @global object $bp BuddyPress global settings.
1151
  *
1152
  * @param int $user_id ID of the user whose activity is being hammed.
 
 
1153
  */
1154
  function bp_activity_ham_all_user_data( $user_id = 0 ) {
1155
  global $wpdb;
1204
  *
1205
  * @since BuddyPress (1.6.0)
1206
  *
1207
+ * @param int $user_id ID of the user whose activity is being marked as ham.
1208
  * @param array $activities Array of activity items being marked as ham.
1209
  */
1210
  do_action( 'bp_activity_ham_all_user_data', $user_id, $activities['activities'] );
1212
  add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
1213
 
1214
  /**
1215
+ * Register the activity stream actions for updates
1216
  *
1217
  * @since BuddyPress (1.6.0)
1218
  */
1254
  * Generate an activity action string for an activity item.
1255
  *
1256
  * @param object $activity Activity data object.
 
1257
  * @return string|bool Returns false if no callback is found, otherwise returns
1258
+ * the formatted action string.
1259
  */
1260
  function bp_activity_generate_action_string( $activity ) {
1261
 
1278
  *
1279
  * @since BuddyPress (2.0.0)
1280
  *
1281
+ * @param BP_Activity_Activity $action Action string being requested.
1282
  * @param BP_Activity_Activity $activity Activity item object.
1283
  */
1284
  $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
1294
  *
1295
  * @since BuddyPress (2.0.0)
1296
  *
1297
+ * @param string $action Static activity action.
1298
  * @param object $activity Activity data object.
 
1299
  * @return string
1300
  */
1301
  function bp_activity_format_activity_action_activity_update( $action, $activity ) {
1306
  *
1307
  * @since BuddyPress (1.2.0)
1308
  *
1309
+ * @param string $action Activity action string value.
1310
  * @param BP_Activity_Activity $activity Activity item object.
1311
  */
1312
  return apply_filters( 'bp_activity_new_update_action', $action, $activity );
1317
  *
1318
  * @since BuddyPress (2.0.0)
1319
  *
1320
+ * @param string $action Static activity action.
1321
  * @param object $activity Activity data object.
 
1322
  * @return string
1323
  */
1324
  function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
1329
  *
1330
  * @since BuddyPress (1.2.0)
1331
  *
1332
+ * @param string $action Activity action string value.
1333
  * @param BP_Activity_Activity $activity Activity item object.
1334
  */
1335
  return apply_filters( 'bp_activity_comment_action', $action, $activity );
1342
  *
1343
  * @param string $action Static activity action.
1344
  * @param object $activity Activity data object.
 
1345
  * @return string
1346
  */
1347
  function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) {
1386
  *
1387
  * @since BuddyPress (2.2.0)
1388
  *
1389
+ * @param string $action Activity action string value.
1390
  * @param BP_Activity_Activity $activity Activity item object.
1391
  */
1392
  return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity );
1418
  * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
1419
  * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
1420
  *
1421
+ * @param array $args See BP_Activity_Activity::get() for description.
 
1422
  * @return array $activity See BP_Activity_Activity::get() for description.
1423
  */
1424
  function bp_activity_get( $args = '' ) {
1509
  * @since BuddyPress (1.2.0)
1510
  *
1511
  * @param BP_Activity_Activity $activity Requested activity object.
1512
+ * @param array $r Arguments used for the activity query.
1513
  */
1514
  return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
1515
  }
1519
  *
1520
  * @since BuddyPress (1.2.0)
1521
  *
1522
+ * @see BP_Activity_Activity::get() For more information on accepted arguments
1523
  * @uses wp_parse_args()
1524
+ * @uses apply_filters() To call the 'bp_activity_get_specific' hook
1525
  * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
1526
  *
1527
+ * @param array $args {
1528
  * All arguments and defaults are shared with BP_Activity_Activity::get(),
1529
  * except for the following:
1530
  * @type string|int|array Single activity ID, comma-separated list of IDs,
1564
  * @since BuddyPress (1.2.0)
1565
  *
1566
  * @param BP_Activity_Activity $activity Requested activity object.
1567
+ * @param array $args Original passed in arguments.
1568
  * @param array $get_args Constructed arguments used with request.
1569
  */
1570
  return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
1579
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
1580
  * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
1581
  * @uses wp_cache_delete()
1582
+ * @uses do_action() To call the 'bp_activity_add' hook
1583
  *
1584
+ * @param array $args {
1585
  * An array of arguments.
1586
+ * @type int|bool $id Pass an activity ID to update an existing item, or
1587
+ * false to create a new item. Default: false.
1588
+ * @type string $action Optional. The activity action/description, typically
1589
+ * something like "Joe posted an update". Values passed to this param
1590
+ * will be stored in the database and used as a fallback for when the
1591
+ * activity item's format_callback cannot be found (eg, when the
1592
+ * component is disabled). As long as you have registered a
1593
+ * format_callback for your $type, it is unnecessary to include this
1594
+ * argument - BP will generate it automatically.
1595
+ * See {@link bp_activity_set_action()}.
1596
+ * @type string $content Optional. The content of the activity item.
1597
+ * @type string $component The unique name of the component associated with
1598
+ * the activity item - 'groups', 'profile', etc.
1599
+ * @type string $type The specific activity type, used for directory
1600
+ * filtering. 'new_blog_post', 'activity_update', etc.
1601
+ * @type string $primary_link Optional. The URL for this item, as used in
1602
+ * RSS feeds. Defaults to the URL for this activity item's permalink page.
1603
+ * @type int|bool $user_id Optional. The ID of the user associated with the
1604
+ * activity item. May be set to false or 0 if the item is not related
1605
+ * to any user. Default: the ID of the currently logged-in user.
1606
+ * @type int $item_id Optional. The ID of the associated item.
1607
+ * @type int $secondary_item_id Optional. The ID of a secondary associated
1608
+ * item.
1609
+ * @type string $date_recorded Optional. The GMT time, in Y-m-d h:i:s format,
1610
+ * when the item was recorded. Defaults to the current time.
1611
+ * @type bool $hide_sitewide Should the item be hidden on sitewide streams?
1612
+ * Default: false.
1613
+ * @type bool $is_spam Should the item be marked as spam? Default: false.
1614
  * }
1615
  * @return int|bool The ID of the activity on success. False on error.
1616
  */
1629
  'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
1630
  'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
1631
  'is_spam' => false, // Is this activity item to be marked as spam?
1632
+ ) );
1633
 
1634
  // Make sure we are backwards compatible
1635
  if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
1698
  * @uses wp_filter_kses()
1699
  * @uses do_action() To call the 'bp_activity_posted_update' hook.
1700
  *
1701
+ * @param array $args {
1702
  * @type string $content The content of the activity update.
1703
+ * @type int $user_id Optional. Defaults to the logged-in user.
1704
  * }
1705
+ * @return int $activity_id The activity id
1706
  */
1707
  function bp_activity_post_update( $args = '' ) {
1708
 
1755
  *
1756
  * @since BuddyPress (1.6.0)
1757
  *
1758
+ * @param string $r Content of the activity update.
1759
  * @param string $activity_content Content of the activity update.
1760
  */
1761
  $activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content );
1771
  *
1772
  * @since BuddyPress (1.2.0)
1773
  *
1774
+ * @param string $content Content of the activity post update.
1775
+ * @param int $user_id ID of the user posting the activity update.
1776
  * @param int $activity_id ID of the activity item being updated.
1777
  */
1778
  do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
1788
  * @param int $post_id ID of the new post.
1789
  * @param WP_Post $post Post object.
1790
  * @param int $user_id ID of the post author.
 
1791
  * @return int|bool The ID of the activity on success. False on error.
1792
  */
1793
  function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0 ) {
1794
+ $bp = buddypress();
1795
 
1796
  if ( ! is_a( $post, 'WP_Post' ) ) {
1797
  return;
1872
  'recorded_time' => $post->post_date_gmt,
1873
  );
1874
 
1875
+ // Remove large images and replace them with just one image thumbnail.
1876
+ if ( ! empty( $activity_args['content'] ) ) {
1877
+ $activity_args['content'] = bp_activity_thumbnail_content_images( $activity_args['content'], $activity_args['primary_link'], $activity_args );
1878
+ }
1879
+
1880
  if ( ! empty( $activity_args['content'] ) ) {
1881
  // Create the excerpt.
1882
+ $activity_excerpt = bp_create_excerpt( $activity_args['content'] );
1883
 
1884
  // Backward compatibility filter for blog posts.
1885
  if ( 'blogs' == $activity_post_object->component_id ) {
1886
+ $activity_args['content'] = apply_filters( 'bp_blogs_record_activity_content', $activity_excerpt, $activity_args['content'], $activity_args, $post->post_type );
1887
  } else {
1888
+ $activity_args['content'] = $activity_excerpt;
1889
  }
1890
  }
1891
 
1929
  * @since BuddyPress (2.2.0)
1930
  *
1931
  * @param WP_Post $post Post item.
 
1932
  * @return bool True on success, false on failure.
1933
  */
1934
  function bp_activity_post_type_update( $post = null ) {
1935
+ $bp = buddypress();
1936
 
1937
  if ( ! is_a( $post, 'WP_Post' ) ) {
1938
  return;
1966
  $activity = new BP_Activity_Activity( $activity_id );
1967
 
1968
  if ( ! empty( $post->post_content ) ) {
1969
+ // Make sure to update the thumbnail image.
1970
+ $post_content = bp_activity_thumbnail_content_images( $post->post_content, $activity->primary_link, (array) $activity );
1971
+
1972
+ // Generate an excerpt.
1973
+ $activity_excerpt = bp_create_excerpt( $post_content );
1974
 
1975
  // Backward compatibility filter for the blogs component.
1976
  if ( 'blogs' == $activity_post_object->component_id ) {
1977
+ $activity->content = apply_filters( 'bp_blogs_record_activity_content', $activity_excerpt, $post_content, (array) $activity, $post->post_type );
1978
  } else {
1979
+ $activity->content = $activity_excerpt;
1980
  }
1981
  }
1982
 
1988
  *
1989
  * @since BuddyPress (2.2.0)
1990
  *
1991
+ * @param WP_Post $post Post object.
1992
  * @param BP_Activity_Activity $activity Activity object.
1993
  */
1994
  do_action( 'bp_activity_post_type_updated', $post, $activity );
2003
  *
2004
  * @param int $post_id ID of the post being unpublished.
2005
  * @param WP_Post $post Post object.
 
2006
  * @return bool True on success, false on failure.
2007
  */
2008
  function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2009
+ $bp = buddypress();
2010
 
2011
  if ( ! is_a( $post, 'WP_Post' ) ) {
2012
  return;
2040
  *
2041
  * @param array $delete_activity_args Array of arguments for activity deletion.
2042
  * @param WP_Post $post Post object.
2043
+ * @param bool $activity Whether or not the activity
2044
+ * was successfully deleted.
2045
  */
2046
  do_action( 'bp_activity_post_type_unpublished', $delete_activity_args, $post, $deleted );
2047
 
2053
  *
2054
  * @since BuddyPress (1.2.0)
2055
  *
2056
+ * @global object $bp BuddyPress global settings.
2057
  * @uses wp_parse_args()
2058
  * @uses bp_activity_add()
2059
  * @uses apply_filters() To call the 'bp_activity_comment_action' hook.
2061
  * @uses wp_cache_delete()
2062
  * @uses do_action() To call the 'bp_activity_comment_posted' hook.
2063
  *
2064
+ * @param array $args {
2065
+ * @type int $id Optional. Pass an ID to update an existing comment.
2066
+ * @type string $content The content of the comment.
2067
+ * @type int $user_id Optional. The ID of the user making the comment.
2068
+ * Defaults to the ID of the logged-in user.
2069
+ * @type int $activity_id The ID of the "root" activity item, ie the oldest
2070
+ * ancestor of the comment.
2071
+ * @type int $parent_id Optional. The ID of the parent activity item, ie the
2072
+ * item to which the comment is an immediate reply. If not provided,
2073
+ * this value defaults to the $activity_id.
2074
  * }
2075
  * @return int|bool The ID of the comment on success, otherwise false.
2076
  */
2159
  * @since BuddyPress (1.2.0)
2160
  *
2161
  * @param int $comment_id ID of the newly posted activity comment.
2162
+ * @param array $r Array of parsed comment arguments.
2163
+ * @param int $activity ID of the activity item being commented on.
2164
  */
2165
  do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity );
2166
 
2182
  * @uses apply_filters() To call the 'bp_activity_get_activity_id' hook.
2183
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
2184
  *
2185
+ * @param array $args See BP_Activity_Activity::get() for description.
 
2186
  * @return int $activity_id The ID of the activity item found.
2187
  */
2188
  function bp_activity_get_activity_id( $args = '' ) {
2203
  *
2204
  * @since BuddyPress (1.2.0)
2205
  *
2206
+ * @param BP_Activity_Activity ID returned by BP_Activity_Activity get_id() method with provided arguments.
2207
  */
2208
  return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
2209
  $r['user_id'],
2243
  * @uses do_action() To call the 'bp_activity_deleted_activities' hook.
2244
  * @uses wp_cache_delete()
2245
  *
2246
+ * @param array $args To delete specific activity items, use
2247
+ * $args = array( 'id' => $ids );
2248
+ * Otherwise, to use filters for item deletion, the argument format is
2249
+ * the same as BP_Activity_Activity::get(). See that method for a description.
 
 
2250
  * @return bool True on success, false on failure.
2251
  */
2252
  function bp_activity_delete( $args = '' ) {
2329
  * @uses wp_parse_args()
2330
  * @uses bp_activity_delete()
2331
  *
2332
+ * @param array $args See BP_Activity_Activity::get for a description
2333
+ * of accepted arguments.
2334
  *
2335
  * @return bool True on success, false on failure.
2336
  */
2354
  *
2355
  * @uses bp_activity_delete()
2356
  *
2357
+ * @param int ID of the activity item to be deleted.
 
2358
  * @return bool True on success, false on failure.
2359
  */
2360
  function bp_activity_delete_by_activity_id( $activity_id ) {
2371
  *
2372
  * @uses bp_activity_delete()
2373
  *
2374
+ * @param int $user_id The user id.
2375
+ * @param string $content The activity id.
2376
  * @param string $component The activity component.
2377
+ * @param string $type The activity type.
 
2378
  * @return bool True on success, false on failure.
2379
  */
2380
  function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
2396
  *
2397
  * @uses bp_activity_delete()
2398
  *
2399
+ * @param int $user_id The user id.
2400
  * @param string $component The activity component.
 
2401
  * @return bool True on success, false on failure.
2402
  */
2403
  function bp_activity_delete_for_user_by_component( $user_id, $component ) {
2424
  *
2425
  * @param int $activity_id The ID of the "root" activity, ie the comment's
2426
  * oldest ancestor.
2427
+ * @param int $comment_id The ID of the comment to be deleted.
2428
+ * @return bool True on success, false on failure
 
2429
  */
2430
  function bp_activity_delete_comment( $activity_id, $comment_id ) {
2431
 
2437
  *
2438
  * @since BuddyPress (1.2.0)
2439
  *
2440
+ * @param bool $value Whether BuddyPress should continue or not.
2441
  * @param int $activity_id ID of the root activity item being deleted.
2442
+ * @param int $comment_id ID of the comment being deleted.
2443
  */
2444
  if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
2445
  return false;
2465
  * @since BuddyPress (1.2.0)
2466
  *
2467
  * @param int $activity_id ID of the activity that has had a comment deleted from.
2468
+ * @param int $comment_id ID of the comment that was deleted.
2469
  */
2470
  do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
2471
 
2482
  * @uses bp_activity_delete()
2483
  *
2484
  * @param int $activity_id The ID of the "root" activity, ie the
2485
+ * comment's oldest ancestor.
2486
+ * @param int $comment_id The ID of the comment to be deleted.
2487
  */
2488
  function bp_activity_delete_children( $activity_id, $comment_id ) {
2489
 
2519
  * @uses bp_get_activity_root_slug()
2520
  * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook.
2521
  *
2522
+ * @param int $activity_id The unique id of the activity object.
2523
+ * @param object $activity_obj Optional. The activity object.
 
2524
  * @return string $link Permalink for the activity item.
2525
  */
2526
  function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
2573
  * @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
2574
  *
2575
  * @param int $user_id The ID of the user whose activity is being hidden.
 
2576
  * @return bool True on success, false on failure.
2577
  */
2578
  function bp_activity_hide_user_activity( $user_id ) {
2589
  * through the content, grabs the first image and converts it to a thumbnail,
2590
  * and removes the rest of the images from the string.
2591
  *
 
 
2592
  * @since BuddyPress (1.2.0)
2593
  *
2594
  * @uses esc_attr()
2595
+ * @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook
 
 
 
 
 
 
2596
  *
2597
+ * @param string $content The content of the activity item.
2598
+ * @param string $link Optional. The unescaped URL that the image should link
2599
+ * to. If absent, the image will not be a link.
2600
+ * @param array $args Optional. The args passed to the activity
2601
+ * creation function (eg bp_blogs_record_activity()).
2602
  * @return string $content The content with images stripped and replaced with a
2603
+ * single thumb.
2604
  */
2605
  function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
2606
 
2618
  preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
2619
  preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
2620
 
2621
+ if ( !empty( $src ) ) {
2622
+ $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
2623
+ $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
2624
+ $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
 
 
 
 
 
 
2625
 
2626
  if ( empty( $width ) || empty( $height ) ) {
2627
  $width = 100;
2648
  *
2649
  * @param string $content Activity content that had images replaced in.
2650
  * @param array $matches Array of all image tags found in the posted content.
2651
+ * @param array $args Arguments passed into function creating the activity update.
2652
  */
2653
  return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches, $args );
2654
  }
2655
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2656
  /**
2657
  * Fetch whether the current user is allowed to mark items as spam.
2658
  *
2678
  * @since BuddyPress (1.6.0)
2679
  *
2680
  * @param BP_Activity_Activity $activity The activity item to be spammed.
2681
+ * @param string $source Optional. Default is "by_a_person" (ie, a person has
2682
+ * manually marked the activity as spam). BP core also accepts
2683
+ * 'by_akismet'.
2684
  */
2685
  function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
2686
  $bp = buddypress();
2713
  * @since BuddyPress (1.6.0)
2714
  *
2715
  * @param BP_Activity_Activity $activity Activity item being marked as spam.
2716
+ * @param string $source Source of determination of spam status. For example
2717
+ * "by_a_person" or "by_akismet".
2718
  */
2719
  do_action( 'bp_activity_mark_as_spam', $activity, $source );
2720
  }
2724
  *
2725
  * @since BuddyPress (1.6.0)
2726
  *
2727
+ * @param BP_Activity_Activity $activity The activity item to be hammed.
2728
+ * @param string $source Optional. Default is "by_a_person" (ie, a person has
2729
+ * manually marked the activity as spam). BP core also accepts
2730
+ * 'by_akismet'.
2731
  */
2732
  function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
2733
  $bp = buddypress();
2760
  * @since BuddyPress (1.6.0)
2761
  *
2762
  * @param BP_Activity_Activity $activity Activity item being marked as ham.
2763
+ * @param string $source Source of determination of ham status. For example
2764
+ * "by_a_person" or "by_akismet".
2765
  */
2766
  do_action( 'bp_activity_mark_as_ham', $activity, $source );
2767
  }
2784
  * @see BP_Embed
2785
  * @see bp_embed_activity_cache()
2786
  * @see bp_embed_activity_save_cache()
 
2787
  * @uses add_filter() To attach 'bp_get_activity_id' to 'embed_post_id'.
2788
  * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
2789
  * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
2808
  * @see BP_Embed
2809
  * @see bp_embed_activity_cache()
2810
  * @see bp_embed_activity_save_cache()
 
2811
  * @uses add_filter() To attach 'bp_get_activity_comment_id' to 'embed_post_id'.
2812
  * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
2813
  * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
2867
  * @see BP_Embed::parse_oembed()
2868
  * @uses bp_activity_get_meta()
2869
  *
2870
+ * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
2871
+ * functions like this one to filter.
2872
+ * @param int $id The ID of the activity item.
2873
  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
 
2874
  * @return mixed The cached embeds for this activity item.
2875
  */
2876
  function bp_embed_activity_cache( $cache, $id, $cachekey ) {
2887
  * @see BP_Embed::parse_oembed()
2888
  * @uses bp_activity_update_meta()
2889
  *
2890
+ * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
2891
+ * functions like this one to filter.
2892
  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
2893
+ * @param int $id The ID of the activity item.
 
2894
  * @return bool True on success, false on failure.
2895
  */
2896
  function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
bp-activity/bp-activity-loader.php CHANGED
@@ -15,14 +15,14 @@ defined( 'ABSPATH' ) || exit;
15
  /**
16
  * Main Activity Class.
17
  *
18
- * @since BuddyPress (1.5.0)
19
  */
20
  class BP_Activity_Component extends BP_Component {
21
 
22
  /**
23
  * Start the activity component setup process.
24
  *
25
- * @since BuddyPress (1.5.0)
26
  */
27
  public function __construct() {
28
  parent::start(
@@ -38,7 +38,7 @@ class BP_Activity_Component extends BP_Component {
38
  /**
39
  * Include component files.
40
  *
41
- * @since BuddyPress (1.5.0)
42
  *
43
  * @see BP_Component::includes() for a description of arguments.
44
  *
@@ -62,7 +62,7 @@ class BP_Activity_Component extends BP_Component {
62
  $akismet_key = bp_get_option( 'wordpress_api_key' );
63
 
64
  /** This filter is documented in bp-activity/bp-activity-actions.php */
65
- if ( defined( 'AKISMET_VERSION' ) && class_exists( 'Akismet' ) && ( ! empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
66
  $includes[] = 'akismet';
67
  }
68
 
@@ -79,7 +79,7 @@ class BP_Activity_Component extends BP_Component {
79
  * The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
80
  * backwards compatibility.
81
  *
82
- * @since BuddyPress (1.5.0)
83
  *
84
  * @see BP_Component::setup_globals() for a description of arguments.
85
  *
@@ -122,7 +122,7 @@ class BP_Activity_Component extends BP_Component {
122
  /**
123
  * Set up component navigation.
124
  *
125
- * @since BuddyPress (1.5.0)
126
  *
127
  * @see BP_Component::setup_nav() for a description of arguments.
128
  * @uses bp_is_active()
@@ -130,8 +130,10 @@ class BP_Activity_Component extends BP_Component {
130
  * @uses bp_get_friends_slug()
131
  * @uses bp_get_groups_slug()
132
  *
133
- * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
134
- * @param array $sub_nav Optional. See BP_Component::setup_nav() for description.
 
 
135
  */
136
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
137
 
@@ -185,17 +187,15 @@ class BP_Activity_Component extends BP_Component {
185
  }
186
 
187
  // Favorite activity items
188
- if ( bp_activity_can_favorite() ) {
189
- $sub_nav[] = array(
190
- 'name' => _x( 'Favorites', 'Profile activity screen sub nav', 'buddypress' ),
191
- 'slug' => 'favorites',
192
- 'parent_url' => $activity_link,
193
- 'parent_slug' => $this->slug,
194
- 'screen_function' => 'bp_activity_screen_favorites',
195
- 'position' => 30,
196
- 'item_css_id' => 'activity-favs'
197
- );
198
- }
199
 
200
  // Additional menu if friends is active
201
  if ( bp_is_active( 'friends' ) ) {
@@ -229,7 +229,7 @@ class BP_Activity_Component extends BP_Component {
229
  /**
230
  * Set up the component entries in the WordPress Admin Bar.
231
  *
232
- * @since BuddyPress (1.5.0)
233
  *
234
  * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
235
  * parameter array.
@@ -291,15 +291,12 @@ class BP_Activity_Component extends BP_Component {
291
  }
292
 
293
  // Favorites
294
- // Favorite activity items
295
- if ( bp_activity_can_favorite() ) {
296
- $wp_admin_nav[] = array(
297
- 'parent' => 'my-account-' . $this->id,
298
- 'id' => 'my-account-' . $this->id . '-favorites',
299
- 'title' => _x( 'Favorites', 'My Account Activity sub nav', 'buddypress' ),
300
- 'href' => trailingslashit( $activity_link . 'favorites' )
301
- );
302
- }
303
 
304
  // Friends?
305
  if ( bp_is_active( 'friends' ) ) {
@@ -328,7 +325,7 @@ class BP_Activity_Component extends BP_Component {
328
  /**
329
  * Set up the title for pages and <title>.
330
  *
331
- * @since BuddyPress (1.5.0)
332
  *
333
  * @uses bp_is_activity_component()
334
  * @uses bp_is_my_profile()
@@ -357,7 +354,7 @@ class BP_Activity_Component extends BP_Component {
357
  /**
358
  * Set up actions necessary for the component.
359
  *
360
- * @since BuddyPress (1.6.0)
361
  */
362
  public function setup_actions() {
363
  // Spam prevention
@@ -367,7 +364,7 @@ class BP_Activity_Component extends BP_Component {
367
  }
368
 
369
  /**
370
- * Setup cache groups.
371
  *
372
  * @since BuddyPress (2.2.0)
373
  */
15
  /**
16
  * Main Activity Class.
17
  *
18
+ * @since BuddyPress (1.5)
19
  */
20
  class BP_Activity_Component extends BP_Component {
21
 
22
  /**
23
  * Start the activity component setup process.
24
  *
25
+ * @since BuddyPress (1.5)
26
  */
27
  public function __construct() {
28
  parent::start(
38
  /**
39
  * Include component files.
40
  *
41
+ * @since BuddyPress (1.5)
42
  *
43
  * @see BP_Component::includes() for a description of arguments.
44
  *
62
  $akismet_key = bp_get_option( 'wordpress_api_key' );
63
 
64
  /** This filter is documented in bp-activity/bp-activity-actions.php */
65
+ if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
66
  $includes[] = 'akismet';
67
  }
68
 
79
  * The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
80
  * backwards compatibility.
81
  *
82
+ * @since BuddyPress (1.5)
83
  *
84
  * @see BP_Component::setup_globals() for a description of arguments.
85
  *
122
  /**
123
  * Set up component navigation.
124
  *
125
+ * @since BuddyPress (1.5)
126
  *
127
  * @see BP_Component::setup_nav() for a description of arguments.
128
  * @uses bp_is_active()
130
  * @uses bp_get_friends_slug()
131
  * @uses bp_get_groups_slug()
132
  *
133
+ * @param array $main_nav Optional. See BP_Component::setup_nav() for
134
+ * description.
135
+ * @param array $sub_nav Optional. See BP_Component::setup_nav() for
136
+ * description.
137
  */
138
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
139
 
187
  }
188
 
189
  // Favorite activity items
190
+ $sub_nav[] = array(
191
+ 'name' => _x( 'Favorites', 'Profile activity screen sub nav', 'buddypress' ),
192
+ 'slug' => 'favorites',
193
+ 'parent_url' => $activity_link,
194
+ 'parent_slug' => $this->slug,
195
+ 'screen_function' => 'bp_activity_screen_favorites',
196
+ 'position' => 30,
197
+ 'item_css_id' => 'activity-favs'
198
+ );
 
 
199
 
200
  // Additional menu if friends is active
201
  if ( bp_is_active( 'friends' ) ) {
229
  /**
230
  * Set up the component entries in the WordPress Admin Bar.
231
  *
232
+ * @since BuddyPress (1.5)
233
  *
234
  * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
235
  * parameter array.
291
  }
292
 
293
  // Favorites
294
+ $wp_admin_nav[] = array(
295
+ 'parent' => 'my-account-' . $this->id,
296
+ 'id' => 'my-account-' . $this->id . '-favorites',
297
+ 'title' => _x( 'Favorites', 'My Account Activity sub nav', 'buddypress' ),
298
+ 'href' => trailingslashit( $activity_link . 'favorites' )
299
+ );
 
 
 
300
 
301
  // Friends?
302
  if ( bp_is_active( 'friends' ) ) {
325
  /**
326
  * Set up the title for pages and <title>.
327
  *
328
+ * @since BuddyPress (1.5)
329
  *
330
  * @uses bp_is_activity_component()
331
  * @uses bp_is_my_profile()
354
  /**
355
  * Set up actions necessary for the component.
356
  *
357
+ * @since BuddyPress (1.6)
358
  */
359
  public function setup_actions() {
360
  // Spam prevention
364
  }
365
 
366
  /**
367
+ * Setup cache groups
368
  *
369
  * @since BuddyPress (2.2.0)
370
  */
bp-activity/bp-activity-notifications.php CHANGED
@@ -34,9 +34,9 @@ defined( 'ABSPATH' ) || exit;
34
  * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook.
35
  * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook.
36
  * @uses wp_mail()
37
- * @uses do_action() To call the 'bp_activity_sent_mention_email' hook.
38
  *
39
- * @param int $activity_id The ID of the activity update.
40
  * @param int $receiver_user_id The ID of the user who is receiving the update.
41
  */
42
  function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
@@ -113,7 +113,7 @@ To view and respond to the message, log in and visit: %3$s
113
  *
114
  * @since BuddyPress (1.2.0)
115
  *
116
- * @param string $subject Email notification subject text.
117
  * @param string $poster_name Name of the person who made the @mention.
118
  */
119
  $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
@@ -123,10 +123,10 @@ To view and respond to the message, log in and visit: %3$s
123
  *
124
  * @since BuddyPress (1.2.0)
125
  *
126
- * @param string $message Email notification message text.
127
- * @param string $poster_name Name of the person who made the @mention.
128
- * @param string $content Content of the @mention.
129
- * @param string $message_link URL permalink for the activity message.
130
  * @param string $settings_link URL permalink for the user's notification settings area.
131
  */
132
  $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
@@ -139,10 +139,10 @@ To view and respond to the message, log in and visit: %3$s
139
  *
140
  * @since BuddyPress (1.5.0)
141
  *
142
- * @param BP_Activity_Activity $activity Activity Item object.
143
- * @param string $subject Email notification subject text.
144
- * @param string $message Email notification message text.
145
- * @param string $content Content of the @mention.
146
  * @param int $receiver_user_id The ID of the user who is receiving the update.
147
  */
148
  do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id );
@@ -163,21 +163,19 @@ To view and respond to the message, log in and visit: %3$s
163
  * @uses wp_specialchars_decode()
164
  * @uses get_blog_option()
165
  * @uses bp_get_root_blog_id()
166
- * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook.
167
- * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook.
168
- * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook.
169
  * @uses wp_mail()
170
- * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook.
171
- * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook.
172
- * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook.
173
- * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook.
174
- * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook.
175
- *
176
- * @param int $comment_id The comment id.
177
- * @param int $commenter_id The ID of the user who posted the comment.
178
- * @param array $params {@link bp_activity_new_comment()}
179
  *
180
- * @return bool
 
 
181
  */
182
  function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
183
 
@@ -231,7 +229,7 @@ To view your original update and all comments, log in and visit: %3$s
231
  *
232
  * @since BuddyPress (1.2.0)
233
  *
234
- * @param string $subject Email notification subject text.
235
  * @param string $poster_name Name of the person who made the comment.
236
  */
237
  $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
@@ -241,10 +239,10 @@ To view your original update and all comments, log in and visit: %3$s
241
  *
242
  * @since BuddyPress (1.2.0)
243
  *
244
- * @param string $message Email notification message text.
245
- * @param string $poster_name Name of the person who made the comment.
246
- * @param string $content Content of the comment.
247
- * @param string $thread_link URL permalink for the activity thread.
248
  * @param string $settings_link URL permalink for the user's notification settings area.
249
  */
250
  $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link );
@@ -256,12 +254,12 @@ To view your original update and all comments, log in and visit: %3$s
256
  *
257
  * @since BuddyPress (1.5.0)
258
  *
259
- * @param int $user_id ID of the original activity item author.
260
- * @param string $subject Email notification subject text.
261
- * @param string $message Email notification message text.
262
- * @param int $comment_id ID for the newly received comment.
263
  * @param int $commenter_id ID of the user who made the comment.
264
- * @param array $params Arguments used with the original activity comment.
265
  */
266
  do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
267
  }
@@ -319,7 +317,7 @@ To view the original activity, your comment and all replies, log in and visit: %
319
  *
320
  * @since BuddyPress (1.2.0)
321
  *
322
- * @param string $subject Email notification subject text.
323
  * @param string $poster_name Name of the person who made the comment reply.
324
  */
325
  $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
@@ -329,11 +327,11 @@ To view the original activity, your comment and all replies, log in and visit: %
329
  *
330
  * @since BuddyPress (1.2.0)
331
  *
332
- * @param string $message Email notification message text.
333
- * @param string $poster_name Name of the person who made the comment reply.
334
- * @param string $content Content of the comment reply.
335
  * @param string $settings_link URL permalink for the user's notification settings area.
336
- * @param string $thread_link URL permalink for the activity thread.
337
  */
338
  $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link );
339
 
@@ -344,23 +342,22 @@ To view the original activity, your comment and all replies, log in and visit: %
344
  *
345
  * @since BuddyPress (1.5.0)
346
  *
347
- * @param int $user_id ID of the parent activity item author.
348
- * @param string $subject Email notification subject text.
349
- * @param string $message Email notification message text.
350
- * @param int $comment_id ID for the newly received comment.
351
  * @param int $commenter_id ID of the user who made the comment.
352
- * @param array $params Arguments used with the original activity comment.
353
  */
354
- do_action( 'bp_activity_sent_reply_to_reply_email', $parent_comment->user_id, $subject, $message, $comment_id, $commenter_id, $params );
355
  }
356
  }
357
 
358
  /**
359
- * Helper method to map action arguments to function parameters.
360
  *
361
  * @since BuddyPress (1.9.0)
362
- *
363
- * @param int $comment_id
364
  * @param array $params
365
  */
366
  function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
@@ -382,12 +379,11 @@ add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_
382
  * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
383
  * @uses do_action() To call 'activity_format_notifications' hook.
384
  *
385
- * @param string $action The type of activity item. Just 'new_at_mention' for now.
386
- * @param int $item_id The activity ID.
387
- * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
388
- * @param int $total_items The total number of notifications to format.
389
- * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
390
- *
391
  * @return string $return Formatted @mention notification.
392
  */
393
  function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
@@ -421,11 +417,11 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
421
  *
422
  * @since BuddyPress (1.5.0)
423
  *
424
- * @param string $string HTML anchor tag for the mention.
425
  * @param string $at_mention_link The permalink for the mention.
426
- * @param int $total_items How many items being notified about.
427
- * @param int $activity_id ID of the activity item being formatted.
428
- * @param int $poster_user_id ID of the user posting the mention.
429
  */
430
  $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
431
  } else {
@@ -439,11 +435,11 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
439
  *
440
  * @since BuddyPress (1.5.0)
441
  *
442
- * @param array $array Array holding the content and permalink for the mention notification.
443
  * @param string $at_mention_link The permalink for the mention.
444
- * @param int $total_items How many items being notified about.
445
- * @param int $activity_id ID of the activity item being formatted.
446
- * @param int $poster_user_id ID of the user posting the mention.
447
  */
448
  $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array(
449
  'text' => $text,
@@ -456,10 +452,10 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
456
  *
457
  * @since BuddyPress (1.2.0)
458
  *
459
- * @param string $action The type of activity item.
460
- * @param int $item_id The activity ID.
461
  * @param int $secondary_item_id @mention mentioner ID.
462
- * @param int $total_items Total amount of items to format.
463
  */
464
  do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
465
 
@@ -476,11 +472,11 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
476
  *
477
  * @since BuddyPress (1.9.0)
478
  *
479
- * @param object $activity
480
  * @param string $subject (not used)
481
  * @param string $message (not used)
482
  * @param string $content (not used)
483
- * @param int $receiver_user_id
484
  */
485
  function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
486
  if ( bp_is_active( 'notifications' ) ) {
@@ -522,8 +518,6 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notificati
522
  * Mark at-mention notification as read when user visits the activity with the mention.
523
  *
524
  * @since BuddyPress (2.0.0)
525
- *
526
- * @param object BP_Activity_Activity
527
  */
528
  function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
529
  if ( ! bp_is_active( 'notifications' ) ) {
34
  * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook.
35
  * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook.
36
  * @uses wp_mail()
37
+ * @uses do_action() To call the 'bp_activity_sent_mention_email' hook
38
  *
39
+ * @param int $activity_id The ID of the activity update.
40
  * @param int $receiver_user_id The ID of the user who is receiving the update.
41
  */
42
  function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
113
  *
114
  * @since BuddyPress (1.2.0)
115
  *
116
+ * @param string $subject Email notification subject text.
117
  * @param string $poster_name Name of the person who made the @mention.
118
  */
119
  $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
123
  *
124
  * @since BuddyPress (1.2.0)
125
  *
126
+ * @param string $message Email notification message text.
127
+ * @param string $poster_name Name of the person who made the @mention.
128
+ * @param string $content Content of the @mention.
129
+ * @param string $message_link URL permalink for the activity message.
130
  * @param string $settings_link URL permalink for the user's notification settings area.
131
  */
132
  $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
139
  *
140
  * @since BuddyPress (1.5.0)
141
  *
142
+ * @param BP_Activity_Activity $activity Activity Item object.
143
+ * @param string $subject Email notification subject text.
144
+ * @param string $message Email notification message text.
145
+ * @param string $content Content of the @mention.
146
  * @param int $receiver_user_id The ID of the user who is receiving the update.
147
  */
148
  do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id );
163
  * @uses wp_specialchars_decode()
164
  * @uses get_blog_option()
165
  * @uses bp_get_root_blog_id()
166
+ * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook
167
+ * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook
168
+ * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook
169
  * @uses wp_mail()
170
+ * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook
171
+ * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook
172
+ * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook
173
+ * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook
174
+ * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook
 
 
 
 
175
  *
176
+ * @param int $comment_id The comment id.
177
+ * @param int $commenter_id The ID of the user who posted the comment.
178
+ * @param array $params {@link bp_activity_new_comment()}
179
  */
180
  function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
181
 
229
  *
230
  * @since BuddyPress (1.2.0)
231
  *
232
+ * @param string $subject Email notification subject text.
233
  * @param string $poster_name Name of the person who made the comment.
234
  */
235
  $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
239
  *
240
  * @since BuddyPress (1.2.0)
241
  *
242
+ * @param string $message Email notification message text.
243
+ * @param string $poster_name Name of the person who made the comment.
244
+ * @param string $content Content of the comment.
245
+ * @param string $thread_link URL permalink for the activity thread.
246
  * @param string $settings_link URL permalink for the user's notification settings area.
247
  */
248
  $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link );
254
  *
255
  * @since BuddyPress (1.5.0)
256
  *
257
+ * @param int $user_id ID of the original activity item author.
258
+ * @param string $subject Email notification subject text.
259
+ * @param string $message Email notification message text.
260
+ * @param int $comment_id ID for the newly received comment.
261
  * @param int $commenter_id ID of the user who made the comment.
262
+ * @param array $params Arguments used with the original activity comment.
263
  */
264
  do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
265
  }
317
  *
318
  * @since BuddyPress (1.2.0)
319
  *
320
+ * @param string $subject Email notification subject text.
321
  * @param string $poster_name Name of the person who made the comment reply.
322
  */
323
  $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
327
  *
328
  * @since BuddyPress (1.2.0)
329
  *
330
+ * @param string $message Email notification message text.
331
+ * @param string $poster_name Name of the person who made the comment reply.
332
+ * @param string $content Content of the comment reply.
333
  * @param string $settings_link URL permalink for the user's notification settings area.
334
+ * @param string $thread_link URL permalink for the activity thread.
335
  */
336
  $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link );
337
 
342
  *
343
  * @since BuddyPress (1.5.0)
344
  *
345
+ * @param int $user_id ID of the original activity item author.
346
+ * @param string $subject Email notification subject text.
347
+ * @param string $message Email notification message text.
348
+ * @param int $comment_id ID for the newly received comment.
349
  * @param int $commenter_id ID of the user who made the comment.
350
+ * @param array $params Arguments used with the original activity comment.
351
  */
352
+ do_action( 'bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
353
  }
354
  }
355
 
356
  /**
357
+ * Helper method to map action arguments to function parameters
358
  *
359
  * @since BuddyPress (1.9.0)
360
+ * @param int $comment_id
 
361
  * @param array $params
362
  */
363
  function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
379
  * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
380
  * @uses do_action() To call 'activity_format_notifications' hook.
381
  *
382
+ * @param string $action The type of activity item. Just 'new_at_mention' for now.
383
+ * @param int $item_id The activity ID.
384
+ * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
385
+ * @param int $total_items The total number of notifications to format.
386
+ * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
 
387
  * @return string $return Formatted @mention notification.
388
  */
389
  function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
417
  *
418
  * @since BuddyPress (1.5.0)
419
  *
420
+ * @param string $string HTML anchor tag for the mention.
421
  * @param string $at_mention_link The permalink for the mention.
422
+ * @param int $total_items How many items being notified about.
423
+ * @param int $activity_id ID of the activity item being formatted.
424
+ * @param int $poster_user_id ID of the user posting the mention.
425
  */
426
  $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
427
  } else {
435
  *
436
  * @since BuddyPress (1.5.0)
437
  *
438
+ * @param array $array Array holding the content and permalink for the mention notification.
439
  * @param string $at_mention_link The permalink for the mention.
440
+ * @param int $total_items How many items being notified about.
441
+ * @param int $activity_id ID of the activity item being formatted.
442
+ * @param int $poster_user_id ID of the user posting the mention.
443
  */
444
  $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array(
445
  'text' => $text,
452
  *
453
  * @since BuddyPress (1.2.0)
454
  *
455
+ * @param string $action The type of activity item.
456
+ * @param int $item_id The activity ID.
457
  * @param int $secondary_item_id @mention mentioner ID.
458
+ * @param int $total_items Total amount of items to format.
459
  */
460
  do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
461
 
472
  *
473
  * @since BuddyPress (1.9.0)
474
  *
475
+ * @param obj $activity
476
  * @param string $subject (not used)
477
  * @param string $message (not used)
478
  * @param string $content (not used)
479
+ * @param int $receiver_user_id
480
  */
481
  function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
482
  if ( bp_is_active( 'notifications' ) ) {
518
  * Mark at-mention notification as read when user visits the activity with the mention.
519
  *
520
  * @since BuddyPress (2.0.0)
 
 
521
  */
522
  function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
523
  if ( ! bp_is_active( 'notifications' ) ) {
bp-activity/bp-activity-screens.php CHANGED
@@ -121,9 +121,9 @@ function bp_activity_screen_friends() {
121
  * @uses bp_is_active()
122
  * @uses bp_update_is_item_admin()
123
  * @uses bp_current_user_can()
124
- * @uses do_action() To call the 'bp_activity_screen_groups' hook.
125
  * @uses bp_core_load_template()
126
- * @uses apply_filters() To call the 'bp_activity_template_groups_activity' hook.
127
  */
128
  function bp_activity_screen_groups() {
129
  if ( !bp_is_active( 'groups' ) )
@@ -155,9 +155,9 @@ function bp_activity_screen_groups() {
155
  *
156
  * @uses bp_update_is_item_admin()
157
  * @uses bp_current_user_can()
158
- * @uses do_action() To call the 'bp_activity_screen_favorites' hook.
159
  * @uses bp_core_load_template()
160
- * @uses apply_filters() To call the 'bp_activity_template_favorite_activity' hook.
161
  */
162
  function bp_activity_screen_favorites() {
163
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
@@ -186,9 +186,9 @@ function bp_activity_screen_favorites() {
186
  *
187
  * @uses bp_update_is_item_admin()
188
  * @uses bp_current_user_can()
189
- * @uses do_action() To call the 'bp_activity_screen_mentions' hook.
190
  * @uses bp_core_load_template()
191
- * @uses apply_filters() To call the 'bp_activity_template_mention_activity' hook.
192
  */
193
  function bp_activity_screen_mentions() {
194
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
@@ -230,6 +230,7 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
230
  *
231
  * @since BuddyPress (1.2.0)
232
  *
 
233
  * @uses bp_is_activity_component()
234
  * @uses bp_activity_get_specific()
235
  * @uses bp_current_action()
@@ -238,8 +239,8 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
238
  * @uses bp_is_active()
239
  * @uses groups_get_group()
240
  * @uses groups_is_user_member()
241
- * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_access' hook.
242
- * @uses do_action() To call the 'bp_activity_screen_single_activity_permalink' hook.
243
  * @uses bp_core_add_message()
244
  * @uses is_user_logged_in()
245
  * @uses bp_core_redirect()
@@ -248,10 +249,10 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
248
  * @uses bp_get_root_domain()
249
  * @uses bp_get_activity_root_slug()
250
  * @uses bp_core_load_template()
251
- * @uses apply_filters() To call the 'bp_activity_template_profile_activity_permalink' hook.
252
  */
253
  function bp_activity_screen_single_activity_permalink() {
254
- $bp = buddypress();
255
 
256
  // No displayed user or not viewing activity component
257
  if ( !bp_is_activity_component() )
@@ -313,8 +314,8 @@ function bp_activity_screen_single_activity_permalink() {
313
  *
314
  * @since BuddyPress (1.2.0)
315
  *
316
- * @param BP_Activity_Activity $activity Object representing the current activity item being displayed.
317
- * @param bool $has_access Whether or not the current user has access to view activity.
318
  */
319
  do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
320
 
@@ -475,7 +476,6 @@ class BP_Activity_Theme_Compat {
475
  * @since BuddyPress (1.8.0)
476
  *
477
  * @param string $templates The templates from bp_get_theme_compat_templates().
478
- *
479
  * @return array $templates Array of custom templates to look for.
480
  */
481
  public function directory_template_hierarchy( $templates ) {
@@ -536,7 +536,6 @@ class BP_Activity_Theme_Compat {
536
  * @since BuddyPress (1.8.0)
537
  *
538
  * @param string $templates The templates from bp_get_theme_compat_templates().
539
- *
540
  * @return array $templates Array of custom templates to look for.
541
  */
542
  public function single_template_hierarchy( $templates ) {
121
  * @uses bp_is_active()
122
  * @uses bp_update_is_item_admin()
123
  * @uses bp_current_user_can()
124
+ * @uses do_action() To call the 'bp_activity_screen_groups' hook
125
  * @uses bp_core_load_template()
126
+ * @uses apply_filters() To call the 'bp_activity_template_groups_activity' hook
127
  */
128
  function bp_activity_screen_groups() {
129
  if ( !bp_is_active( 'groups' ) )
155
  *
156
  * @uses bp_update_is_item_admin()
157
  * @uses bp_current_user_can()
158
+ * @uses do_action() To call the 'bp_activity_screen_favorites' hook
159
  * @uses bp_core_load_template()
160
+ * @uses apply_filters() To call the 'bp_activity_template_favorite_activity' hook
161
  */
162
  function bp_activity_screen_favorites() {
163
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
186
  *
187
  * @uses bp_update_is_item_admin()
188
  * @uses bp_current_user_can()
189
+ * @uses do_action() To call the 'bp_activity_screen_mentions' hook
190
  * @uses bp_core_load_template()
191
+ * @uses apply_filters() To call the 'bp_activity_template_mention_activity' hook
192
  */
193
  function bp_activity_screen_mentions() {
194
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
230
  *
231
  * @since BuddyPress (1.2.0)
232
  *
233
+ * @global object $bp BuddyPress global settings
234
  * @uses bp_is_activity_component()
235
  * @uses bp_activity_get_specific()
236
  * @uses bp_current_action()
239
  * @uses bp_is_active()
240
  * @uses groups_get_group()
241
  * @uses groups_is_user_member()
242
+ * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_access' hook
243
+ * @uses do_action() To call the 'bp_activity_screen_single_activity_permalink' hook
244
  * @uses bp_core_add_message()
245
  * @uses is_user_logged_in()
246
  * @uses bp_core_redirect()
249
  * @uses bp_get_root_domain()
250
  * @uses bp_get_activity_root_slug()
251
  * @uses bp_core_load_template()
252
+ * @uses apply_filters() To call the 'bp_activity_template_profile_activity_permalink' hook
253
  */
254
  function bp_activity_screen_single_activity_permalink() {
255
+ global $bp;
256
 
257
  // No displayed user or not viewing activity component
258
  if ( !bp_is_activity_component() )
314
  *
315
  * @since BuddyPress (1.2.0)
316
  *
317
+ * @param BP_Activity_Activity $activity Object representing the current activity item being displayed.
318
+ * @param bool $has_access Whether or not the current user has access to view activity.
319
  */
320
  do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
321
 
476
  * @since BuddyPress (1.8.0)
477
  *
478
  * @param string $templates The templates from bp_get_theme_compat_templates().
 
479
  * @return array $templates Array of custom templates to look for.
480
  */
481
  public function directory_template_hierarchy( $templates ) {
536
  * @since BuddyPress (1.8.0)
537
  *
538
  * @param string $templates The templates from bp_get_theme_compat_templates().
 
539
  * @return array $templates Array of custom templates to look for.
540
  */
541
  public function single_template_hierarchy( $templates ) {
bp-activity/bp-activity-template.php CHANGED
@@ -80,10 +80,10 @@ function bp_activity_root_slug() {
80
  * @uses bp_get_activity_directory_permalink()
81
  */
82
  function bp_activity_directory_permalink() {
83
- echo esc_url( bp_get_activity_directory_permalink() );
84
  }
85
  /**
86
- * Return activity directory permalink.
87
  *
88
  * @since BuddyPress (1.5.0)
89
  *
@@ -114,59 +114,13 @@ function bp_activity_directory_permalink() {
114
  * @since BuddyPress (1.0.0)
115
  */
116
  class BP_Activity_Template {
117
- /**
118
- * The loop iterator.
119
- *
120
- * @since BuddyPress (1.5.0)
121
- * @access public
122
- * @var int
123
- */
124
- public $current_activity = -1;
125
 
126
- /**
127
- * The activity count.
128
- *
129
- * @since BuddyPress (1.5.0)
130
- * @access public
131
- * @var int
132
- */
133
- public $activity_count;
134
-
135
- /**
136
- * The total activity count.
137
- *
138
- * @since BuddyPress (1.5.0)
139
- * @access public
140
- * @var int
141
- */
142
- public $total_activity_count;
143
-
144
- /**
145
- * Array of activities located by the query.
146
- *
147
- * @since BuddyPress (1.5.0)
148
- * @access public
149
- * @var array
150
- */
151
- public $activities;
152
-
153
- /**
154
- * The activity object currently being iterated on.
155
- *
156
- * @since BuddyPress (1.5.0)
157
- * @access public
158
- * @var object
159
- */
160
- public $activity;
161
-
162
- /**
163
- * A flag for whether the loop is currently being iterated.
164
- *
165
- * @since BuddyPress (1.5.0)
166
- * @access public
167
- * @var bool
168
- */
169
- public $in_the_loop;
170
 
171
  /**
172
  * URL parameter key for activity pagination. Default: 'acpage'.
@@ -174,43 +128,13 @@ class BP_Activity_Template {
174
  * @since BuddyPress (2.1.0)
175
  * @var string
176
  */
177
- public $pag_arg;
178
 
179
- /**
180
- * The page number being requested.
181
- *
182
- * @since BuddyPress (1.5.0)
183
- * @access public
184
- * @var int
185
- */
186
- public $pag_page;
187
 
188
- /**
189
- * The number of items being requested per page.
190
- *
191
- * @since BuddyPress (1.5.0)
192
- * @access public
193
- * @var int
194
- */
195
- public $pag_num;
196
-
197
- /**
198
- * An HTML string containing pagination links.
199
- *
200
- * @since BuddyPress (1.5.0)
201
- * @access public
202
- * @var string
203
- */
204
- public $pag_links;
205
-
206
- /**
207
- * The displayed user's full name.
208
- *
209
- * @since BuddyPress (1.5.0)
210
- * @access public
211
- * @var string
212
- */
213
- public $full_name;
214
 
215
  /**
216
  * Constructor method.
@@ -226,21 +150,21 @@ class BP_Activity_Template {
226
  * BP_Activity_Activity::get(), as well as 'page_arg' and
227
  * 'include'. Default values for 'per_page' and 'display_comments'
228
  * differ from the originating function, and are described below.
229
- * @type string $page_arg The string used as a query parameter in
230
- * pagination links. Default: 'acpage'.
231
- * @type array|bool $include Pass an array of activity IDs to
232
- * retrieve only those items, or false to noop the 'include'
233
- * parameter. 'include' differs from 'in' in that 'in' forms
234
- * an IN clause that works in conjunction with other filters
235
- * passed to the function, while 'include' is interpreted as
236
- * an exact list of items to retrieve, which skips all other
237
- * filter-related parameters. Default: false.
238
- * @type int|bool $per_page Default: 20.
239
  * @type string|bool $display_comments Default: 'threaded'.
240
  * }
241
  */
242
- public function __construct( $args ) {
243
- $bp = buddypress();
244
 
245
  // Backward compatibility with old method of passing arguments
246
  if ( !is_array( $args ) || func_num_args() > 1 ) {
@@ -295,7 +219,7 @@ class BP_Activity_Template {
295
  $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
296
 
297
  // Check if blog/forum replies are disabled
298
- $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' );
299
 
300
  // Get an array of the logged in user's favorite activities
301
  $this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) );
@@ -366,21 +290,18 @@ class BP_Activity_Template {
366
 
367
  // Fetch parent content for activity comments so we do not have to query in the loop
368
  foreach ( (array) $this->activities as $activity ) {
369
- if ( 'activity_comment' != $activity->type ) {
370
  continue;
371
- }
372
 
373
  $parent_ids[] = $activity->item_id;
374
  }
375
 
376
- if ( !empty( $parent_ids ) ) {
377
  $activity_parents = bp_activity_get_specific( array( 'activity_ids' => $parent_ids ) );
378
- }
379
 
380
  if ( !empty( $activity_parents['activities'] ) ) {
381
- foreach( $activity_parents['activities'] as $parent ) {
382
  $this->activity_parents[$parent->id] = $parent;
383
- }
384
 
385
  unset( $activity_parents );
386
  }
@@ -407,9 +328,8 @@ class BP_Activity_Template {
407
  * @return bool True if there are items in the loop, otherwise false.
408
  */
409
  function has_activities() {
410
- if ( $this->activity_count ) {
411
  return true;
412
- }
413
 
414
  return false;
415
  }
@@ -419,9 +339,9 @@ class BP_Activity_Template {
419
  *
420
  * @return object The next activity item to iterate over.
421
  */
422
- public function next_activity() {
423
  $this->current_activity++;
424
- $this->activity = $this->activities[ $this->current_activity ];
425
 
426
  return $this->activity;
427
  }
@@ -429,7 +349,7 @@ class BP_Activity_Template {
429
  /**
430
  * Rewind the posts and reset post index.
431
  */
432
- public function rewind_activities() {
433
  $this->current_activity = -1;
434
  if ( $this->activity_count > 0 ) {
435
  $this->activity = $this->activities[0];
@@ -448,10 +368,10 @@ class BP_Activity_Template {
448
  * @return bool True if there are more activity items to show,
449
  * otherwise false.
450
  */
451
- public function user_activities() {
452
- if ( ( $this->current_activity + 1 ) < $this->activity_count ) {
453
  return true;
454
- } elseif ( ( $this->current_activity + 1 ) == $this->activity_count ) {
455
 
456
  /**
457
  * Fires right before the rewinding of activity posts.
@@ -459,13 +379,11 @@ class BP_Activity_Template {
459
  * @since BuddyPress (1.1.0)
460
  */
461
  do_action( 'activity_loop_end' );
462
-
463
  // Do some cleaning up after the loop
464
  $this->rewind_activities();
465
  }
466
 
467
  $this->in_the_loop = false;
468
-
469
  return false;
470
  }
471
 
@@ -478,17 +396,15 @@ class BP_Activity_Template {
478
  *
479
  * @see bp_the_activity()
480
  */
481
- public function the_activity() {
482
 
483
  $this->in_the_loop = true;
484
  $this->activity = $this->next_activity();
485
 
486
- if ( is_array( $this->activity ) ) {
487
  $this->activity = (object) $this->activity;
488
- }
489
 
490
- // loop has just started
491
- if ( $this->current_activity == 0 ) {
492
 
493
  /**
494
  * Fires if the current activity item is the first in the activity loop.
@@ -510,6 +426,7 @@ class BP_Activity_Template {
510
  * @since BuddyPress (1.0.0)
511
  *
512
  * @global object $activities_template {@link BP_Activity_Template}
 
513
  * @uses groups_is_user_member()
514
  * @uses bp_current_action()
515
  * @uses bp_is_current_action()
@@ -522,7 +439,7 @@ class BP_Activity_Template {
522
  * @uses bp_activity_get_user_favorites()
523
  * @uses apply_filters() To call the 'bp_has_activities' hook.
524
  *
525
- * @param array|string $args {
526
  * Arguments for limiting the contents of the activity loop. Most arguments
527
  * are in the same format as {@link BP_Activity_Activity::get()}. However,
528
  * because the format of the arguments accepted here differs in a number of
@@ -555,11 +472,11 @@ class BP_Activity_Template {
555
  * @type string $search_terms Limit results by a search term. Default: false.
556
  * @type string $scope Use a BuddyPress pre-built filter.
557
  * - 'just-me' retrieves items belonging only to a user; this is equivalent
558
- * to passing a 'user_id' argument.
559
- * - 'friends' retrieves items belonging to the friends of a user.
560
- * - 'groups' retrieves items belonging to groups to which a user belongs to.
561
- * - 'favorites' retrieves a user's favorited activity items.
562
- * - 'mentions' retrieves items where a user has received an @-mention.
563
  * The default value of 'scope' is set to one of the above if that value
564
  * appears in the appropriate place in the URL; eg, 'scope' will be 'groups'
565
  * when visiting http://example.com/members/joe/activity/groups/. Otherwise
@@ -591,16 +508,16 @@ class BP_Activity_Template {
591
  * Note that providing an offset will disable pagination. Default: false.
592
  * @type string|bool $display_comments How to handle activity comments. Possible values:
593
  * - 'threaded' - comments appear in a threaded tree, under their parent
594
- * items.
595
  * - 'stream' - the activity stream is presented in a flat manner, with
596
- * comments sorted in chronological order alongside other activity items.
597
- * - false - don't fetch activity comments at all.
598
  * Default: 'threaded'.
599
  * @type bool $show_hidden Whether to show items marked hide_sitewide. Defaults to false, except in
600
  * the following cases:
601
- * - User is viewing his own activity stream.
602
  * - User is viewing the activity stream of a non-public group of which he
603
- * is a member.
604
  * @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false to show all activity
605
  * regardless of spam status. Default: 'ham_only'.
606
  * @type bool $populate_extras Whether to pre-fetch the activity metadata for the queried items.
@@ -609,57 +526,62 @@ class BP_Activity_Template {
609
  * @return bool Returns true when activities are found, otherwise false.
610
  */
611
  function bp_has_activities( $args = '' ) {
612
- global $activities_template;
613
 
614
- // Get BuddyPress
615
- $bp = buddypress();
616
-
617
- /** Smart Defaults ********************************************************/
 
 
 
 
 
 
 
 
618
 
619
  // User filtering
620
- $user_id = bp_displayed_user_id()
621
- ? bp_displayed_user_id()
622
- : false;
623
 
624
  // Group filtering
625
- if ( bp_is_group() ) {
626
- $object = $bp->groups->id;
627
- $primary_id = bp_get_current_group_id();
628
- $show_hidden = (bool) ( groups_is_user_member( bp_loggedin_user_id(), $primary_id ) || bp_current_user_can( 'bp_moderate' ) );
629
- } else {
630
- $object = false;
631
- $primary_id = false;
632
- $show_hidden = false;
633
  }
634
 
635
  // The default scope should recognize custom slugs
636
- $scope = array_key_exists( bp_current_action(), (array) $bp->loaded_components )
637
- ? $bp->loaded_components[ bp_current_action() ]
638
- : bp_current_action();
 
 
639
 
640
  // Support for permalinks on single item pages: /groups/my-group/activity/124/
641
- $include = bp_is_current_action( bp_get_activity_slug() )
642
- ? bp_action_variable( 0 )
643
- : false;
644
-
645
- /** Parse Args ************************************************************/
646
 
647
- // Note: any params used for filtering can be a single value, or multiple
648
- // values comma separated.
649
- $r = bp_parse_args( $args, array(
650
  'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
651
  'include' => $include, // pass an activity_id or string of IDs comma-separated
652
- 'exclude' => false, // pass an activity_id or string of IDs comma-separated
653
- 'in' => false, // comma-separated list or array of activity IDs among which to search
654
  'sort' => 'DESC', // sort DESC or ASC
655
  'page' => 1, // which page to load
656
  'per_page' => 20, // number of items per page
657
- 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679
658
  'max' => false, // max number to return
659
  'count_total' => false,
660
  'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
661
  'spam' => 'ham_only', // Hide spammed items
662
 
 
 
663
  // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
664
  'scope' => $scope,
665
 
@@ -679,31 +601,30 @@ function bp_has_activities( $args = '' ) {
679
  // Searching
680
  'search_terms' => false, // specify terms to search on
681
  'update_meta_cache' => true,
682
- ), 'has_activities' );
683
 
684
- /** Smart Overrides *******************************************************/
 
685
 
686
  // Translate various values for 'display_comments'
687
  // This allows disabling comments via ?display_comments=0
688
  // or =none or =false. Final true is a strict type check. See #5029
689
- if ( in_array( $r['display_comments'], array( 0, '0', 'none', 'false' ), true ) ) {
690
- $r['display_comments'] = false;
691
  }
692
 
693
  // Ignore pagination if an offset is passed
694
- if ( ! empty( $r['offset'] ) ) {
695
- $r['page'] = 0;
696
  }
697
 
698
  // Search terms
699
- if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) {
700
- $r['search_terms'] = $_REQUEST['s'];
701
- }
702
 
703
  // Do not exceed the maximum per page
704
- if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
705
- $r['per_page'] = $r['max'];
706
- }
707
 
708
  /**
709
  * Filters whether BuddyPress should enable afilter support.
@@ -716,44 +637,51 @@ function bp_has_activities( $args = '' ) {
716
  *
717
  * @param bool $value True if BuddyPress should enable afilter support.
718
  */
719
- if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) ) {
720
- $r['filter'] = array(
721
- 'object' => $_GET['afilter']
722
- );
723
- } elseif ( ! empty( $r['user_id'] ) || ! empty( $r['object'] ) || ! empty( $r['action'] ) || ! empty( $r['primary_id'] ) || ! empty( $r['secondary_id'] ) || ! empty( $r['offset'] ) || ! empty( $r['since'] ) ) {
724
- $r['filter'] = array(
725
- 'user_id' => $r['user_id'],
726
- 'object' => $r['object'],
727
- 'action' => $r['action'],
728
- 'primary_id' => $r['primary_id'],
729
- 'secondary_id' => $r['secondary_id'],
730
- 'offset' => $r['offset'],
731
- 'since' => $r['since']
732
- );
733
- } else {
734
- $r['filter'] = false;
735
- }
736
-
737
- // If specific activity items have been requested, override the $hide_spam
738
- // argument. This prevents backpat errors with AJAX.
739
- if ( ! empty( $r['include'] ) && ( 'ham_only' === $r['spam'] ) ) {
740
- $r['spam'] = 'all';
741
- }
742
-
743
- /** Query *****************************************************************/
744
-
745
- $activities_template = new BP_Activity_Template( $r );
 
 
 
 
 
 
 
746
 
747
  /**
748
  * Filters whether or not there are activity items to display.
749
  *
750
  * @since BuddyPress (1.1.0)
751
  *
752
- * @param bool $value Whether or not there are activity items to display.
753
  * @param string $activities_template Current activities template being used.
754
- * @param array $r Array of arguments passed into the BP_Activity_Template class.
755
  */
756
- return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template, $r );
757
  }
758
 
759
  /**
@@ -795,7 +723,7 @@ function bp_activity_load_more_link() {
795
  echo esc_url( bp_get_activity_load_more_link() );
796
  }
797
  /**
798
- * Get the URL for the Load More link.
799
  *
800
  * @since BuddyPress (2.1.0)
801
  */
@@ -810,9 +738,9 @@ function bp_activity_load_more_link() {
810
  *
811
  * @since BuddyPress (2.1.0)
812
  *
813
- * @param string $link The "Load More" link URL with appropriate query args.
814
- * @param string $url The original URL.
815
- * @param object $activities_template The activity template loop global.
816
  */
817
  return apply_filters( 'bp_get_activity_load_more_link', $link, $url, $activities_template );
818
  }
@@ -847,13 +775,7 @@ function bp_activity_pagination_count() {
847
  $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
848
  $total = bp_core_number_format( $activities_template->total_activity_count );
849
 
850
- if ( 1 == $activities_template->total_activity_count ) {
851
- $message = __( 'Viewing 1 item', 'buddypress' );
852
- } else {
853
- $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s item', 'Viewing %1$s - %2$s of %3$s items', $activities_template->total_activity_count, 'buddypress' ), $from_num, $to_num, $total );
854
- }
855
-
856
- return $message;
857
  }
858
 
859
  /**
@@ -1047,7 +969,7 @@ function bp_activities_no_activity() {
1047
  * @since BuddyPress (1.0.0)
1048
  *
1049
  * @global string $bp_activity_no_activity
1050
- * @uses apply_filters() To call the 'bp_get_activities_no_activity' hook.
1051
  * @todo Deprecate.
1052
  *
1053
  * @return string
@@ -1202,7 +1124,7 @@ function bp_activity_date_recorded() {
1202
  }
1203
 
1204
  /**
1205
- * Output the display name of the member who posted the activity.
1206
  *
1207
  * @since BuddyPress (2.1.0)
1208
  *
@@ -1213,7 +1135,7 @@ function bp_activity_member_display_name() {
1213
  }
1214
 
1215
  /**
1216
- * Return the display name of the member who posted the activity.
1217
  *
1218
  * @since BuddyPress (2.1.0)
1219
  *
@@ -1421,7 +1343,7 @@ function bp_activity_user_link() {
1421
  * @see bp_get_activity_avatar() for description of arguments.
1422
  * @uses bp_get_activity_avatar()
1423
  *
1424
- * @param array|string $args See {@link bp_get_activity_avatar()} for description.
1425
  */
1426
  function bp_activity_avatar( $args = '' ) {
1427
  echo bp_get_activity_avatar( $args );
@@ -1433,25 +1355,26 @@ function bp_activity_avatar( $args = '' ) {
1433
  *
1434
  * @see bp_core_fetch_avatar() For a description of the arguments.
1435
  * @global object $activities_template {@link BP_Activity_Template}
 
1436
  * @uses bp_is_single_activity()
1437
  * @uses wp_parse_args()
1438
- * @uses apply_filters() To call the 'bp_get_activity_avatar_object_' . $current_activity_item->component hook.
1439
- * @uses apply_filters() To call the 'bp_get_activity_avatar_item_id' hook.
1440
  * @uses bp_core_fetch_avatar()
1441
- * @uses apply_filters() To call the 'bp_get_activity_avatar' hook.
1442
  *
1443
- * @param array|string $args {
1444
  * Arguments are listed here with an explanation of their defaults.
1445
  * For more information about the arguments, see
1446
  * {@link bp_core_fetch_avatar()}.
1447
- * @type string $alt Default: 'Profile picture of [user name]' if
1448
- * activity user name is available, otherwise 'Profile picture'.
1449
- * @type string $class Default: 'avatar'.
1450
- * @type string|bool $email Default: Email of the activity's
1451
- * associated user, if available. Otherwise false.
1452
- * @type string $type Default: 'full' when viewing a single activity
1453
- * permalink page, otherwise 'thumb'.
1454
- * @type int|bool $user_id Default: ID of the activity's user.
1455
  * }
1456
  * @return string User avatar string.
1457
  */
@@ -1525,9 +1448,8 @@ function bp_activity_avatar( $args = '' ) {
1525
  $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $item_id );
1526
 
1527
  // If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it.
1528
- if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) ) {
1529
  $email = $current_activity_item->user_email;
1530
- }
1531
 
1532
  /**
1533
  * Filters the value returned by bp_core_fetch_avatar.
@@ -1556,14 +1478,14 @@ function bp_activity_avatar( $args = '' ) {
1556
  * @see bp_get_activity_secondary_avatar() for description of arguments.
1557
  * @uses bp_get_activity_secondary_avatar()
1558
  *
1559
- * @param array|string $args See {@link bp_get_activity_secondary_avatar} for description.
1560
  */
1561
  function bp_activity_secondary_avatar( $args = '' ) {
1562
  echo bp_get_activity_secondary_avatar( $args );
1563
  }
1564
 
1565
  /**
1566
- * Return the avatar of the object that action was performed on.
1567
  *
1568
  * @since BuddyPress (1.2.0)
1569
  *
@@ -1576,15 +1498,15 @@ function bp_activity_secondary_avatar( $args = '' ) {
1576
  * @uses bp_core_fetch_avatar()
1577
  * @uses apply_filters() To call the 'bp_get_activity_secondary_avatar' hook.
1578
  *
1579
- * @param array|string $args {
1580
  * For a complete description of arguments, see {@link bp_core_fetch_avatar()}.
1581
- * @type string $alt Default value varies based on current activity
1582
- * item component.
1583
- * @type string $type Default: 'full' when viewing a single activity
1584
- * permalink page, otherwise 'thumb'.
1585
- * @type string $class Default: 'avatar'.
1586
- * @type string|bool $email Default: email of the activity's user.
1587
- * @type int|bool $user_id Default: ID of the activity's user.
1588
  * }
1589
  * @return string The secondary avatar
1590
  */
@@ -1606,10 +1528,6 @@ function bp_activity_secondary_avatar( $args = '' ) {
1606
  // Set item_id and object (default to user)
1607
  switch ( $activities_template->activity->component ) {
1608
  case 'groups' :
1609
- if ( bp_disable_group_avatar_uploads() ) {
1610
- return false;
1611
- }
1612
-
1613
  $object = 'group';
1614
  $item_id = $activities_template->activity->item_id;
1615
  $link = '';
@@ -1714,7 +1632,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1714
  *
1715
  * @since BuddyPress (1.7.0)
1716
  *
1717
- * @param string $link Link to wrap the avatar image in.
1718
  * @param string $component Activity component being acted on.
1719
  */
1720
  $link = apply_filters( 'bp_get_activity_secondary_avatar_link', $link, $activities_template->activity->component );
@@ -1724,7 +1642,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1724
  *
1725
  * @since BuddyPress (1.2.10)
1726
  *
1727
- * @param string $avatar Formatted HTML <img> element, or raw avatar URL.
1728
  */
1729
  $avatar = apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
1730
 
@@ -1740,7 +1658,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1740
  }
1741
 
1742
  /**
1743
- * Output the activity action.
1744
  *
1745
  * @since BuddyPress (1.2.0)
1746
  *
@@ -1752,28 +1670,32 @@ function bp_activity_action( $args = array() ) {
1752
  }
1753
 
1754
  /**
1755
- * Return the activity action.
1756
  *
1757
  * @since BuddyPress (1.2.0)
1758
  *
1759
  * @global object $activities_template {@link BP_Activity_Template}
1760
  * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
1761
- * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook.
1762
  * @uses bp_insert_activity_meta()
1763
  * @uses apply_filters_ref_array() To call the 'bp_get_activity_action' hook.
1764
  *
1765
  * @param array $args {
1766
  * @type bool $no_timestamp Whether to exclude the timestamp.
1767
  * }
1768
- *
1769
  * @return string The activity action.
1770
  */
1771
  function bp_get_activity_action( $args = array() ) {
1772
  global $activities_template;
1773
 
1774
- $r = wp_parse_args( $args, array(
1775
  'no_timestamp' => false,
1776
- ) );
 
 
 
 
 
1777
 
1778
  /**
1779
  * Filters the activity action before the action is inserted as meta.
@@ -1782,16 +1704,10 @@ function bp_activity_action( $args = array() ) {
1782
  *
1783
  * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1784
  */
1785
- $action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array(
1786
- $activities_template->activity->action,
1787
- &$activities_template->activity,
1788
- $r
1789
- ) );
1790
 
1791
- // Prepend the activity action meta (link, time since, etc...)
1792
- if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
1793
  $action = bp_insert_activity_meta( $action );
1794
- }
1795
 
1796
  /**
1797
  * Filters the activity action after the action has been inserted as meta.
@@ -1800,15 +1716,11 @@ function bp_activity_action( $args = array() ) {
1800
  *
1801
  * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1802
  */
1803
- return apply_filters_ref_array( 'bp_get_activity_action', array(
1804
- $action,
1805
- &$activities_template->activity,
1806
- $r
1807
- ) );
1808
  }
1809
 
1810
  /**
1811
- * Output the activity content body.
1812
  *
1813
  * @since BuddyPress (1.2.0)
1814
  *
@@ -1819,7 +1731,7 @@ function bp_activity_content_body() {
1819
  }
1820
 
1821
  /**
1822
- * Return the activity content body.
1823
  *
1824
  * @since BuddyPress (1.2.0)
1825
  *
@@ -1833,9 +1745,8 @@ function bp_activity_content_body() {
1833
  global $activities_template;
1834
 
1835
  // Backwards compatibility if action is not being used
1836
- if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) {
1837
  $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
1838
- }
1839
 
1840
  /**
1841
  * Filters the activity content body.
@@ -1859,9 +1770,8 @@ function bp_activity_content_body() {
1859
  function bp_activity_has_content() {
1860
  global $activities_template;
1861
 
1862
- if ( ! empty( $activities_template->activity->content ) ) {
1863
  return true;
1864
- }
1865
 
1866
  return false;
1867
  }
@@ -1898,7 +1808,7 @@ function bp_activity_content() {
1898
 
1899
  /**
1900
  * If you want to filter activity update content, please use
1901
- * the filter 'bp_get_activity_content_body'.
1902
  *
1903
  * This function is mainly for backwards compatibility.
1904
  */
@@ -1924,17 +1834,13 @@ function bp_activity_content() {
1924
  * @uses apply_filters() To call the 'bp_insert_activity_meta' hook.
1925
  *
1926
  * @param string $content The activity content.
1927
- *
1928
  * @return string The activity content with the metadata string attached.
1929
  */
1930
- function bp_insert_activity_meta( $content = '' ) {
1931
  global $activities_template;
1932
 
1933
  // Strip any legacy time since placeholders from BP 1.0-1.1
1934
- $new_content = str_replace( '<span class="time-since">%s</span>', '', $content );
1935
-
1936
- // Get the time since this activity was recorded
1937
- $date_recorded = bp_core_time_since( $activities_template->activity->date_recorded );
1938
 
1939
  /**
1940
  * Filters the activity item time since markup.
@@ -1943,22 +1849,10 @@ function bp_insert_activity_meta( $content = '' ) {
1943
  *
1944
  * @param array $value Array containing the time since markup and the current activity component.
1945
  */
1946
- $time_since = apply_filters_ref_array( 'bp_activity_time_since', array(
1947
- '<span class="time-since">' . $date_recorded . '</span>',
1948
- &$activities_template->activity
1949
- ) );
1950
 
1951
  // Insert the permalink
1952
- if ( ! bp_is_single_activity() ) {
1953
-
1954
- // Setup variables for activity meta
1955
- $activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
1956
- $activity_meta = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>',
1957
- $new_content,
1958
- $activity_permalink,
1959
- esc_attr__( 'View Discussion', 'buddypress' ),
1960
- $time_since
1961
- );
1962
 
1963
  /**
1964
  * Filters the activity permalink to be added to the activity content.
@@ -1967,12 +1861,9 @@ function bp_insert_activity_meta( $content = '' ) {
1967
  *
1968
  * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
1969
  */
1970
- $new_content = apply_filters_ref_array( 'bp_activity_permalink', array(
1971
- $activity_meta,
1972
- &$activities_template->activity
1973
- ) );
1974
  } else {
1975
- $new_content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH );
1976
  }
1977
 
1978
  /**
@@ -1982,7 +1873,7 @@ function bp_insert_activity_meta( $content = '' ) {
1982
  *
1983
  * @param string $content Activity content with the activity metadata added.
1984
  */
1985
- return apply_filters( 'bp_insert_activity_meta', $new_content, $content );
1986
  }
1987
 
1988
  /**
@@ -1991,10 +1882,9 @@ function bp_insert_activity_meta( $content = '' ) {
1991
  * @since BuddyPress (1.2.0)
1992
  *
1993
  * @global object $activities_template {@link BP_Activity_Template}
1994
- * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook.
1995
- *
1996
- * @param object|bool $activity Optional. Falls back on the current item in the loop.
1997
  *
 
1998
  * @return bool True if can delete, false otherwise.
1999
  */
2000
  function bp_activity_user_can_delete( $activity = false ) {
@@ -2040,7 +1930,7 @@ function bp_activity_user_can_delete( $activity = false ) {
2040
  * @since BuddyPress (1.5.0)
2041
  *
2042
  * @param bool $can_delete Whether the user can delete the item.
2043
- * @param object $activity Current activity item object.
2044
  */
2045
  return (bool) apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
2046
  }
@@ -2053,7 +1943,7 @@ function bp_activity_user_can_delete( $activity = false ) {
2053
  * @see bp_get_activity_parent_content() for a description of arguments.
2054
  * @uses bp_get_activity_parent_content()
2055
  *
2056
- * @param array|string $args See {@link bp_get_activity_parent_content} for description.
2057
  */
2058
  function bp_activity_parent_content( $args = '' ) {
2059
  echo bp_get_activity_parent_content($args);
@@ -2065,40 +1955,43 @@ function bp_activity_parent_content( $args = '' ) {
2065
  * @since BuddyPress (1.2.0)
2066
  *
2067
  * @global object $activities_template {@link BP_Activity_Template}
 
2068
  * @uses apply_filters() To call the 'bp_get_activity_parent_content' hook.
2069
  *
2070
- * @param string $args Unused. Left over from an earlier implementation.
2071
- *
2072
- * @return mixed False on failure, otherwise the activity parent content.
 
 
2073
  */
2074
  function bp_get_activity_parent_content( $args = '' ) {
2075
  global $activities_template;
2076
 
2077
- // Bail if no activity on no item ID
2078
- if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
2079
- return false;
2080
- }
 
 
2081
 
2082
  // Get the ID of the parent activity content
2083
- $parent_id = (int) $activities_template->activity->item_id;
 
2084
 
2085
  // Bail if no parent content
2086
- if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
2087
  return false;
2088
- }
2089
 
2090
  // Bail if no action
2091
- if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
2092
  return false;
2093
- }
2094
 
2095
  // Content always includes action
2096
- $content = $activities_template->activity_parents[ $parent_id ]->action;
2097
 
2098
  // Maybe append activity content, if it exists
2099
- if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
2100
- $content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
2101
- }
2102
 
2103
  // Remove the time since content for backwards compatibility
2104
  $content = str_replace( '<span class="time-since">%s</span>', '', $content );
@@ -2133,30 +2026,28 @@ function bp_activity_parent_user_id() {
2133
  * @global BP_Activity_Template $activities_template
2134
  *
2135
  * @return bool|int False if parent activity can't be found, otherwise
2136
- * the parent activity's user ID.
2137
  */
2138
  function bp_get_activity_parent_user_id() {
2139
  global $activities_template;
2140
 
2141
  // Bail if no activity on no item ID
2142
- if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
2143
  return false;
2144
- }
2145
 
2146
  // Get the ID of the parent activity content
2147
- $parent_id = (int) $activities_template->activity->item_id;
 
2148
 
2149
  // Bail if no parent item
2150
- if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
2151
  return false;
2152
- }
2153
 
2154
  // Bail if no parent user ID
2155
- if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) {
2156
  return false;
2157
- }
2158
 
2159
- $retval = $activities_template->activity_parents[ $parent_id ]->user_id;
2160
 
2161
  /**
2162
  * Filters the activity parent item's user ID.
@@ -2209,7 +2100,7 @@ function bp_activity_is_favorite() {
2209
  *
2210
  * @todo deprecate $args param
2211
  *
2212
- * @param array|string $args See {@link bp_activity_get_comments} for description.
2213
  */
2214
  function bp_activity_comments( $args = '' ) {
2215
  echo bp_activity_get_comments( $args );
@@ -2225,48 +2116,41 @@ function bp_activity_comments( $args = '' ) {
2225
  * @todo Given that checks for children already happen in bp_activity_recurse_comments(),
2226
  * this function can probably be streamlined or removed.
2227
  *
2228
- * @param string $args Unused. Left over from an earlier implementation.
2229
  *
2230
  * @global object $activities_template {@link BP_Activity_Template}
2231
  * @uses bp_activity_recurse_comments()
2232
- *
2233
- * @return bool
2234
  */
2235
  function bp_activity_get_comments( $args = '' ) {
2236
  global $activities_template;
2237
 
2238
- if ( empty( $activities_template->activity->children ) ) {
2239
  return false;
2240
- }
2241
 
2242
  bp_activity_recurse_comments( $activities_template->activity );
2243
  }
2244
 
2245
  /**
2246
- * Loops through a level of activity comments and loads the template for each.
2247
  *
2248
  * Note: The recursion itself used to happen entirely in this function. Now it is
2249
  * split between here and the comment.php template.
2250
  *
2251
  * @since BuddyPress (1.2.0)
2252
  *
2253
- * @param object $comment The activity object currently being recursed.
2254
  *
2255
  * @global object $activities_template {@link BP_Activity_Template}
2256
  * @uses locate_template()
2257
- *
2258
- * @return bool|string
2259
  */
2260
  function bp_activity_recurse_comments( $comment ) {
2261
  global $activities_template;
2262
 
2263
- if ( empty( $comment ) ) {
2264
  return false;
2265
- }
2266
 
2267
- if ( empty( $comment->children ) ) {
2268
  return false;
2269
- }
2270
 
2271
  /**
2272
  * Filters the opening tag for the template that lists activity comments.
@@ -2275,9 +2159,8 @@ function bp_activity_comments( $args = '' ) {
2275
  *
2276
  * @param string $value Opening tag for the HTML markup to use.
2277
  */
2278
- echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>' );
2279
  foreach ( (array) $comment->children as $comment_child ) {
2280
-
2281
  // Put the comment into the global so it's available to filters
2282
  $activities_template->activity->current_comment = $comment_child;
2283
 
@@ -2303,7 +2186,7 @@ function bp_activity_comments( $args = '' ) {
2303
  *
2304
  * @param string $value Closing tag for the HTML markup to use.
2305
  */
2306
- echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>' );
2307
  }
2308
 
2309
  /**
@@ -2315,14 +2198,12 @@ function bp_activity_comments( $args = '' ) {
2315
  * @uses apply_filters() To call the 'bp_activity_current_comment' hook.
2316
  *
2317
  * @return object|bool $current_comment The activity comment currently being
2318
- * displayed. False on failure.
2319
  */
2320
  function bp_activity_current_comment() {
2321
  global $activities_template;
2322
 
2323
- $current_comment = !empty( $activities_template->activity->current_comment )
2324
- ? $activities_template->activity->current_comment
2325
- : false;
2326
 
2327
  /**
2328
  * Filters the current comment being recursed.
@@ -2354,8 +2235,8 @@ function bp_activity_comment_id() {
2354
  * @global object $activities_template {@link BP_Activity_Template}
2355
  * @uses apply_filters() To call the 'bp_activity_comment_id' hook.
2356
  *
2357
- * @return int|bool $comment_id The ID of the activity comment currently
2358
- * being displayed, false if none is found.
2359
  */
2360
  function bp_get_activity_comment_id() {
2361
  global $activities_template;
@@ -2392,7 +2273,7 @@ function bp_activity_comment_user_id() {
2392
  * @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
2393
  *
2394
  * @return int|bool $user_id The user_id of the author of the displayed
2395
- * activity comment. False on failure.
2396
  */
2397
  function bp_get_activity_comment_user_id() {
2398
  global $activities_template;
@@ -2427,7 +2308,7 @@ function bp_activity_comment_user_link() {
2427
  *
2428
  * @uses bp_core_get_user_domain()
2429
  * @uses bp_get_activity_comment_user_id()
2430
- * @uses apply_filters() To call the 'bp_activity_comment_user_link' hook.
2431
  *
2432
  * @return string $user_link The URL of the activity comment author's profile.
2433
  */
@@ -2490,7 +2371,7 @@ function bp_activity_comment_name() {
2490
  }
2491
 
2492
  /**
2493
- * Output the formatted date_recorded of the activity comment currently being displayed.
2494
  *
2495
  * @since BuddyPress (1.5.0)
2496
  *
@@ -2501,17 +2382,24 @@ function bp_activity_comment_date_recorded() {
2501
  }
2502
 
2503
  /**
2504
- * Return the formatted date_recorded for the activity comment currently being displayed.
2505
  *
2506
  * @since BuddyPress (1.5.0)
2507
  *
 
2508
  * @uses bp_core_time_since()
2509
- * @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook.
2510
  *
2511
  * @return string|bool $date_recorded Time since the activity was recorded,
2512
- * in the form "%s ago". False on failure.
2513
  */
2514
  function bp_get_activity_comment_date_recorded() {
 
 
 
 
 
 
2515
 
2516
  /**
2517
  * Filters the recorded date of the activity comment currently being displayed.
@@ -2520,43 +2408,7 @@ function bp_activity_comment_date_recorded() {
2520
  *
2521
  * @param string|bool Date for the activity comment currently being displayed.
2522
  */
2523
- return apply_filters( 'bp_activity_comment_date_recorded', bp_core_time_since( bp_get_activity_comment_date_recorded_raw() ) );
2524
- }
2525
-
2526
- /**
2527
- * Output the date_recorded of the activity comment currently being displayed.
2528
- *
2529
- * @since BuddyPress (2.3.0)
2530
- *
2531
- * @uses bp_get_activity_comment_date_recorded()
2532
- */
2533
- function bp_activity_comment_date_recorded_raw() {
2534
- echo bp_get_activity_comment_date_recorded_raw();
2535
- }
2536
-
2537
- /**
2538
- * Return the date_recorded for the activity comment currently being displayed.
2539
- *
2540
- * @since BuddyPress (2.3.0)
2541
- *
2542
- * @global object $activities_template {@link BP_Activity_Template}
2543
- * @uses bp_core_time_since()
2544
- * @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook.
2545
- *
2546
- * @return string|bool $date_recorded Time since the activity was recorded,
2547
- * in the form "%s ago". False on failure.
2548
- */
2549
- function bp_get_activity_comment_date_recorded_raw() {
2550
- global $activities_template;
2551
-
2552
- /**
2553
- * Filters the raw recorded date of the activity comment currently being displayed.
2554
- *
2555
- * @since BuddyPress (2.3.0)
2556
- *
2557
- * @param string|bool Raw date for the activity comment currently being displayed.
2558
- */
2559
- return apply_filters( 'bp_activity_comment_date_recorded', $activities_template->activity->current_comment->date_recorded );
2560
  }
2561
 
2562
  /**
@@ -2571,7 +2423,7 @@ function bp_activity_comment_delete_link() {
2571
  }
2572
 
2573
  /**
2574
- * Gets the 'delete' URL for the activity comment currently being displayed.
2575
  *
2576
  * @since BuddyPress (1.5.0)
2577
  *
@@ -2582,7 +2434,7 @@ function bp_activity_comment_delete_link() {
2582
  * @uses apply_filters() To call the 'bp_activity_comment_delete_link' hook.
2583
  *
2584
  * @return string $link The nonced URL for deleting the current
2585
- * activity comment.
2586
  */
2587
  function bp_get_activity_comment_delete_link() {
2588
  $link = wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
@@ -2696,10 +2548,10 @@ function bp_activity_comment_count() {
2696
  * @since BuddyPress (1.2.0)
2697
  *
2698
  * @uses bp_activity_recurse_comment_count()
2699
- * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook.
2700
  *
2701
  * @param object $comment Activity comment object.
2702
- * @param int $count The current iteration count.
2703
  *
2704
  * @return int $count The activity comment count.
2705
  */
@@ -2722,8 +2574,8 @@ function bp_activity_comment_count() {
2722
  * @since BuddyPress (2.1.0)
2723
  *
2724
  * @param int $new_count New total count for the current comment.
2725
- * @param object $comment Activity comment object.
2726
- * @param int $count Current iteration count for the current comment.
2727
  */
2728
  return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
2729
  }
@@ -2741,7 +2593,7 @@ function bp_activity_comment_depth() {
2741
  *
2742
  * @since BuddyPress (2.0.0)
2743
  *
2744
- * @return int $depth Depth for the current activity comment.
2745
  */
2746
  function bp_activity_get_comment_depth() {
2747
  global $activities_template;
@@ -2791,7 +2643,7 @@ function bp_activity_comment_link() {
2791
  }
2792
 
2793
  /**
2794
- * Output the activity comment form no JavaScript display CSS.
2795
  *
2796
  * @since BuddyPress (1.2.0)
2797
  *
@@ -2802,21 +2654,19 @@ function bp_activity_comment_form_nojs_display() {
2802
  }
2803
 
2804
  /**
2805
- * Return the activity comment form no JavaScript display CSS.
2806
  *
2807
  * @since BuddyPress (1.2.0)
2808
  *
2809
  * @global object $activities_template {@link BP_Activity_Template}
2810
  *
2811
- * @return string|bool The activity comment form no JavaScript
2812
- * display CSS. False on failure.
2813
  */
2814
  function bp_get_activity_comment_form_nojs_display() {
2815
  global $activities_template;
2816
-
2817
- if ( isset( $_GET['ac'] ) && ( $_GET['ac'] === ( $activities_template->activity->id . '/' ) ) ) {
2818
  return 'style="display: block"';
2819
- }
2820
 
2821
  return false;
2822
  }
@@ -2964,7 +2814,7 @@ function bp_activity_comment_permalink() {
2964
  *
2965
  * @since BuddyPress (1.8.0)
2966
  *
2967
- * @param string $link Activity comment permalink.
2968
  * @param int $comment_id ID for the current activity comment.
2969
  */
2970
  return apply_filters( 'bp_get_activity_comment_permalink', $link, $comment_id );
@@ -2990,7 +2840,7 @@ function bp_activity_favorite_link() {
2990
  * @uses wp_nonce_url()
2991
  * @uses home_url()
2992
  * @uses bp_get_activity_root_slug()
2993
- * @uses apply_filters() To call the 'bp_get_activity_favorite_link' hook.
2994
  *
2995
  * @return string The activity favorite link.
2996
  */
@@ -3089,13 +2939,11 @@ function bp_activity_css_class() {
3089
 
3090
  $class = ' activity-item';
3091
 
3092
- if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) ) {
3093
  $class .= ' mini';
3094
- }
3095
 
3096
- if ( bp_activity_get_comment_count() && bp_activity_can_comment() ) {
3097
  $class .= ' has-comments';
3098
- }
3099
 
3100
  /**
3101
  * Filters the determined classes to add to the HTML element.
@@ -3133,7 +2981,7 @@ function bp_activity_delete_link() {
3133
  * @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
3134
  *
3135
  * @return string $link Activity delete link. Contains $redirect_to arg
3136
- * if on single activity page.
3137
  */
3138
  function bp_get_activity_delete_link() {
3139
 
@@ -3158,7 +3006,7 @@ function bp_activity_delete_link() {
3158
  }
3159
 
3160
  /**
3161
- * Output the URL to delete a single activity stream item.
3162
  *
3163
  * @since BuddyPress (2.1.0)
3164
  *
@@ -3168,7 +3016,7 @@ function bp_activity_delete_url() {
3168
  echo esc_url( bp_get_activity_delete_url() );
3169
  }
3170
  /**
3171
- * Return the URL to delete a single activity item.
3172
  *
3173
  * @since BuddyPress (2.1.0)
3174
  *
@@ -3183,7 +3031,7 @@ function bp_activity_delete_url() {
3183
  * @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
3184
  *
3185
  * @return string $link Activity delete link. Contains $redirect_to arg
3186
- * if on single activity page.
3187
  */
3188
  function bp_get_activity_delete_url() {
3189
  global $activities_template;
@@ -3229,30 +3077,26 @@ function bp_activity_latest_update( $user_id = 0 ) {
3229
  * @uses bp_is_user_inactive()
3230
  * @uses bp_core_is_user_deleted()
3231
  * @uses bp_get_user_meta()
3232
- * @uses apply_filters() To call the 'bp_get_activity_latest_update_excerpt' hook.
3233
  * @uses bp_create_excerpt()
3234
  * @uses bp_get_root_domain()
3235
  * @uses bp_get_activity_root_slug()
3236
- * @uses apply_filters() To call the 'bp_get_activity_latest_update' hook.
3237
  *
3238
  * @param int $user_id If empty, will fall back on displayed user.
3239
- *
3240
  * @return string|bool $latest_update The activity latest update link.
3241
- * False on failure.
3242
  */
3243
  function bp_get_activity_latest_update( $user_id = 0 ) {
3244
 
3245
- if ( empty( $user_id ) ) {
3246
  $user_id = bp_displayed_user_id();
3247
- }
3248
 
3249
- if ( bp_is_user_inactive( $user_id ) ) {
3250
  return false;
3251
- }
3252
 
3253
- if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) ) {
3254
  return false;
3255
- }
3256
 
3257
  /**
3258
  * Filters the latest update excerpt.
@@ -3288,7 +3132,7 @@ function bp_activity_latest_update( $user_id = 0 ) {
3288
  * @see bp_get_activity_filter_links() for description of parameters.
3289
  * @uses bp_get_activity_filter_links()
3290
  *
3291
- * @param array|bool $args See {@link bp_get_activity_filter_links()} for description.
3292
  */
3293
  function bp_activity_filter_links( $args = false ) {
3294
  echo bp_get_activity_filter_links( $args );
@@ -3307,18 +3151,21 @@ function bp_activity_filter_links( $args = false ) {
3307
  * @uses apply_filters() To call the 'bp_get_activity_filter_link_href' hook.
3308
  * @uses apply_filters() To call the 'bp_get_activity_filter_links' hook.
3309
  *
3310
- * @param array|bool $args {
3311
  * @type string $style The type of markup to use for the links.
3312
- * 'list', 'paragraph', or 'span'. Default: 'list'.
3313
  * }
3314
  * @return string|bool $component_links The activity filter links.
3315
  * False on failure.
3316
  */
3317
  function bp_get_activity_filter_links( $args = false ) {
3318
 
3319
- $r = wp_parse_args( $args, array(
3320
  'style' => 'list'
3321
- ) );
 
 
 
3322
 
3323
  // Define local variable
3324
  $component_links = array();
@@ -3326,26 +3173,23 @@ function bp_activity_filter_links( $args = false ) {
3326
  // Fetch the names of components that have activity recorded in the DB
3327
  $components = BP_Activity_Activity::get_recorded_components();
3328
 
3329
- if ( empty( $components ) ) {
3330
  return false;
3331
- }
3332
 
3333
  foreach ( (array) $components as $component ) {
3334
 
3335
  // Skip the activity comment filter
3336
- if ( 'activity' == $component ) {
3337
  continue;
3338
- }
3339
 
3340
- if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) {
3341
  $selected = ' class="selected"';
3342
- } else {
3343
- $selected = '';
3344
- }
3345
 
3346
  $component = esc_attr( $component );
3347
 
3348
- switch ( $r['style'] ) {
3349
  case 'list':
3350
  $tag = 'li';
3351
  $before = '<li id="afilter-' . $component . '"' . $selected . '>';
@@ -3371,7 +3215,7 @@ function bp_activity_filter_links( $args = false ) {
3371
  *
3372
  * @since BuddyPress (1.1.0)
3373
  *
3374
- * @param string $link The URL for the current component.
3375
  * @param string $component The current component getting links constructed for.
3376
  */
3377
  $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
@@ -3381,9 +3225,8 @@ function bp_activity_filter_links( $args = false ) {
3381
 
3382
  $link = remove_query_arg( 'afilter' , $link );
3383
 
3384
- if ( isset( $_GET['afilter'] ) ) {
3385
  $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_url( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
3386
- }
3387
 
3388
  /**
3389
  * Filters all of the constructed filter links.
@@ -3448,7 +3291,7 @@ function bp_activity_can_comment() {
3448
  *
3449
  * @since BuddyPress (1.5.0)
3450
  *
3451
- * @param bool $can_comment Status on if activity can be commented on.
3452
  * @param string $activity_action Current activity action being checked on.
3453
  */
3454
  return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
@@ -3459,11 +3302,11 @@ function bp_activity_can_comment() {
3459
  *
3460
  * @since BuddyPress (1.5.0)
3461
  *
3462
- * @param bool|object $comment Activity comment.
3463
- * @return bool $can_comment True if comment can receive comments,
3464
- * otherwise false.
3465
  */
3466
- function bp_activity_can_comment_reply( $comment = false ) {
3467
 
3468
  // Assume activity can be commented on
3469
  $can_comment = true;
@@ -3496,7 +3339,7 @@ function bp_activity_can_comment_reply( $comment = false ) {
3496
  * @since BuddyPress (1.5.0)
3497
  *
3498
  * @param bool $can_comment Status on if activity reply can be commented on.
3499
- * @param string $comment Current comment being checked on.
3500
  */
3501
  return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
3502
  }
@@ -3544,26 +3387,22 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
3544
  * @since BuddyPress (1.2.0)
3545
  *
3546
  * @uses bp_activity_total_favorites_for_user()
3547
- * @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook.
3548
  *
3549
  * @param int $user_id ID of user being queried. Default: displayed user ID.
3550
- *
3551
  * @return int The total favorite count for the specified user.
3552
  */
3553
  function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
3554
- $retval = false;
3555
 
3556
- if ( bp_activity_can_favorite() ) {
3557
- // Default to displayed user if none is passed
3558
- $user_id = empty( $user_id )
3559
- ? bp_displayed_user_id()
3560
- : $user_id;
3561
 
3562
- // Get user meta if user ID exists
3563
- if ( ! empty( $user_id ) ) {
3564
- $retval = bp_activity_total_favorites_for_user( $user_id );
3565
- }
3566
- }
3567
 
3568
  /**
3569
  * Filters the total favorite count for a user.
@@ -3599,7 +3438,6 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
3599
  * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
3600
  *
3601
  * @param int $user_id ID of user being queried. Default: displayed user ID.
3602
- *
3603
  * @return int The total mention count for the specified user.
3604
  */
3605
  function bp_get_total_mention_count_for_user( $user_id = 0 ) {
@@ -3645,7 +3483,7 @@ function bp_send_public_message_link() {
3645
  * @uses bp_is_user()
3646
  * @uses wp_nonce_url()
3647
  * @uses bp_get_activity_directory_permalink()
3648
- * @uses apply_filters() To call the 'bp_get_send_public_message_link' hook.
3649
  *
3650
  * @return string The public message link for the displayed user.
3651
  */
@@ -3677,7 +3515,6 @@ function bp_send_public_message_link() {
3677
  *
3678
  * @param array $activity Array of activities generated from {@link bp_activity_get()}.
3679
  * @param array $activity_ids Used for recursion purposes in this function.
3680
- *
3681
  * @return array
3682
  */
3683
  function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) {
@@ -3706,22 +3543,21 @@ function bp_activity_recurse_comments_activity_ids( $activity = array(), $activi
3706
  * @see bp_get_mentioned_user_display_name() for description of parameters.
3707
  * @uses bp_get_mentioned_user_display_name()
3708
  *
3709
- * @param int|string|bool $user_id_or_username See {@link bp_get_mentioned_user_display_name()}.
3710
  */
3711
  function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3712
  echo bp_get_mentioned_user_display_name( $user_id_or_username );
3713
  }
3714
 
3715
  /**
3716
- * Returns the mentioned user display name.
3717
  *
3718
  * @since BuddyPress (1.2.0)
3719
  *
3720
  * @uses bp_core_get_user_displayname()
3721
  * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
3722
  *
3723
- * @param int|string|bool User ID or username.
3724
- *
3725
  * @return string The mentioned user's display name.
3726
  */
3727
  function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
@@ -3739,7 +3575,7 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3739
  *
3740
  * @since BuddyPress (1.2.0)
3741
  *
3742
- * @param string $name Display name for the mentioned user.
3743
  * @param int|string $user_id_or_username User ID or username use for query.
3744
  */
3745
  return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
@@ -3753,7 +3589,7 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3753
  * @see bp_get_send_public_message_button() for description of parameters.
3754
  * @uses bp_get_send_public_message_button()
3755
  *
3756
- * @param array|string $args See {@link bp_get_send_public_message_button()}.
3757
  */
3758
  function bp_send_public_message_button( $args = '' ) {
3759
  echo bp_get_send_public_message_button( $args );
@@ -3769,20 +3605,20 @@ function bp_send_public_message_button( $args = '' ) {
3769
  * @uses bp_get_button()
3770
  * @uses apply_filters() To call the 'bp_get_send_public_message_button' hook.
3771
  *
3772
- * @param array|string $args {
3773
  * All arguments are optional. See {@link BP_Button} for complete
3774
  * descriptions.
3775
- * @type string $id Default: 'public_message'.
3776
- * @type string $component Default: 'activity'.
3777
- * @type bool $must_be_logged_in Default: true.
3778
- * @type bool $block_self Default: true.
3779
- * @type string $wrapper_id Default: 'post-mention'.
3780
- * @type string $link_href Default: the public message link for
3781
- * the current member in the loop.
3782
- * @type string $link_title Default: 'Send a public message on your
3783
- * activity stream.'.
3784
- * @type string $link_text Default: 'Public Message'.
3785
- * @type string $link_class Default: 'activity-button mention'.
3786
  * }
3787
  * @return string The button for sending a public message.
3788
  */
@@ -3910,7 +3746,7 @@ function bp_activity_comments_user_avatars( $args = array() ) {
3910
  * @since BuddyPress (1.7.0)
3911
  *
3912
  * @param string $retval HTML markup for the list of avatars.
3913
- * @param array $r Array of arguments used for each avatar.
3914
  * @param array $output Array of each avatar found, before imploded into single string.
3915
  */
3916
  echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );
@@ -3946,7 +3782,6 @@ function bp_activity_get_comments_user_ids() {
3946
  * @since BuddyPress (1.7.0)
3947
  *
3948
  * @param array $comments Array of {@link BP_Activity_Activity} items.
3949
- *
3950
  * @return array Array of user IDs.
3951
  */
3952
  function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
@@ -4017,13 +3852,13 @@ function bp_displayed_user_mentionname() {
4017
  *
4018
  * @since BuddyPress (1.7.0)
4019
  *
4020
- * @param string $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
4021
- * @param array|string $args {
4022
  * Optional extra arguments.
4023
- * @type string $checkbox_name When returning checkboxes, sets the 'name'
4024
- * attribute.
4025
- * @type array|string $selected A list of types that should be checked/
4026
- * selected.
4027
  * }
4028
  */
4029
  function bp_activity_types_list( $output = 'select', $args = '' ) {
@@ -4061,8 +3896,8 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
4061
  *
4062
  * @since BuddyPress (1.7.0)
4063
  *
4064
- * @param array $args Array of arguments passed into function.
4065
- * @param string $type Activity type being rendered in the output.
4066
  * @param string $description Description of the activity type being rendered.
4067
  */
4068
  do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
@@ -4293,7 +4128,7 @@ function bp_activity_feed_item_title() {
4293
  }
4294
 
4295
  /**
4296
- * Output the activity feed item link.
4297
  *
4298
  * @since BuddyPress (1.0.0)
4299
  *
@@ -4304,7 +4139,7 @@ function bp_activity_feed_item_link() {
4304
  }
4305
 
4306
  /**
4307
- * Return the activity feed item link.
4308
  *
4309
  * @since BuddyPress (1.0.0)
4310
  *
@@ -4437,7 +4272,7 @@ add_action( 'bp_head', 'bp_activity_sitewide_feed' );
4437
  * @since BuddyPress (2.1.0)
4438
  *
4439
  * @param string $context The current context. 'activity', 'member',
4440
- * 'member_groups', 'group'.
4441
  * @uses bp_get_activity_show_filters()
4442
  */
4443
  function bp_activity_show_filters( $context = '' ) {
@@ -4449,8 +4284,7 @@ function bp_activity_show_filters( $context = '' ) {
4449
  * @since BuddyPress (2.1.0)
4450
  *
4451
  * @param string $context The current context. 'activity', 'member',
4452
- * 'member_groups', 'group'.
4453
- *
4454
  * @return string HTML for <option> values.
4455
  */
4456
  function bp_get_activity_show_filters( $context = '' ) {
@@ -4500,7 +4334,7 @@ function bp_activity_show_filters( $context = '' ) {
4500
  *
4501
  * @since BuddyPress (2.2.0)
4502
  *
4503
- * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
4504
  * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
4505
  */
4506
  $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
@@ -4519,7 +4353,7 @@ function bp_activity_show_filters( $context = '' ) {
4519
  *
4520
  * @since BuddyPress (2.1.0)
4521
  *
4522
- * @param string $output HTML output for the activity filter dropdown.
4523
  * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
4524
  * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
4525
  */
80
  * @uses bp_get_activity_directory_permalink()
81
  */
82
  function bp_activity_directory_permalink() {
83
+ echo bp_get_activity_directory_permalink();
84
  }
85
  /**
86
+ * Return activity directory permalink
87
  *
88
  * @since BuddyPress (1.5.0)
89
  *
114
  * @since BuddyPress (1.0.0)
115
  */
116
  class BP_Activity_Template {
117
+ var $current_activity = -1;
118
+ var $activity_count;
119
+ var $total_activity_count;
120
+ var $activities;
121
+ var $activity;
 
 
 
122
 
123
+ var $in_the_loop;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
  /**
126
  * URL parameter key for activity pagination. Default: 'acpage'.
128
  * @since BuddyPress (2.1.0)
129
  * @var string
130
  */
131
+ var $pag_arg;
132
 
133
+ var $pag_page;
134
+ var $pag_num;
135
+ var $pag_links;
 
 
 
 
 
136
 
137
+ var $full_name;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  /**
140
  * Constructor method.
150
  * BP_Activity_Activity::get(), as well as 'page_arg' and
151
  * 'include'. Default values for 'per_page' and 'display_comments'
152
  * differ from the originating function, and are described below.
153
+ * @type string $page_arg The string used as a query parameter in
154
+ * pagination links. Default: 'acpage'.
155
+ * @type array|bool $include Pass an array of activity IDs to
156
+ * retrieve only those items, or false to noop the 'include'
157
+ * parameter. 'include' differs from 'in' in that 'in' forms
158
+ * an IN clause that works in conjunction with other filters
159
+ * passed to the function, while 'include' is interpreted as
160
+ * an exact list of items to retrieve, which skips all other
161
+ * filter-related parameters. Default: false.
162
+ * @type int|bool $per_page Default: 20.
163
  * @type string|bool $display_comments Default: 'threaded'.
164
  * }
165
  */
166
+ function __construct( $args ) {
167
+ global $bp;
168
 
169
  // Backward compatibility with old method of passing arguments
170
  if ( !is_array( $args ) || func_num_args() > 1 ) {
219
  $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
220
 
221
  // Check if blog/forum replies are disabled
222
+ $this->disable_blogforum_replies = isset( $bp->site_options['bp-disable-blogforum-comments'] ) ? $bp->site_options['bp-disable-blogforum-comments'] : false;
223
 
224
  // Get an array of the logged in user's favorite activities
225
  $this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) );
290
 
291
  // Fetch parent content for activity comments so we do not have to query in the loop
292
  foreach ( (array) $this->activities as $activity ) {
293
+ if ( 'activity_comment' != $activity->type )
294
  continue;
 
295
 
296
  $parent_ids[] = $activity->item_id;
297
  }
298
 
299
+ if ( !empty( $parent_ids ) )
300
  $activity_parents = bp_activity_get_specific( array( 'activity_ids' => $parent_ids ) );
 
301
 
302
  if ( !empty( $activity_parents['activities'] ) ) {
303
+ foreach( $activity_parents['activities'] as $parent )
304
  $this->activity_parents[$parent->id] = $parent;
 
305
 
306
  unset( $activity_parents );
307
  }
328
  * @return bool True if there are items in the loop, otherwise false.
329
  */
330
  function has_activities() {
331
+ if ( $this->activity_count )
332
  return true;
 
333
 
334
  return false;
335
  }
339
  *
340
  * @return object The next activity item to iterate over.
341
  */
342
+ function next_activity() {
343
  $this->current_activity++;
344
+ $this->activity = $this->activities[$this->current_activity];
345
 
346
  return $this->activity;
347
  }
349
  /**
350
  * Rewind the posts and reset post index.
351
  */
352
+ function rewind_activities() {
353
  $this->current_activity = -1;
354
  if ( $this->activity_count > 0 ) {
355
  $this->activity = $this->activities[0];
368
  * @return bool True if there are more activity items to show,
369
  * otherwise false.
370
  */
371
+ function user_activities() {
372
+ if ( $this->current_activity + 1 < $this->activity_count ) {
373
  return true;
374
+ } elseif ( $this->current_activity + 1 == $this->activity_count ) {
375
 
376
  /**
377
  * Fires right before the rewinding of activity posts.
379
  * @since BuddyPress (1.1.0)
380
  */
381
  do_action( 'activity_loop_end' );
 
382
  // Do some cleaning up after the loop
383
  $this->rewind_activities();
384
  }
385
 
386
  $this->in_the_loop = false;
 
387
  return false;
388
  }
389
 
396
  *
397
  * @see bp_the_activity()
398
  */
399
+ function the_activity() {
400
 
401
  $this->in_the_loop = true;
402
  $this->activity = $this->next_activity();
403
 
404
+ if ( is_array( $this->activity ) )
405
  $this->activity = (object) $this->activity;
 
406
 
407
+ if ( $this->current_activity == 0 ) { // loop has just started
 
408
 
409
  /**
410
  * Fires if the current activity item is the first in the activity loop.
426
  * @since BuddyPress (1.0.0)
427
  *
428
  * @global object $activities_template {@link BP_Activity_Template}
429
+ * @global object $bp BuddyPress global settings.
430
  * @uses groups_is_user_member()
431
  * @uses bp_current_action()
432
  * @uses bp_is_current_action()
439
  * @uses bp_activity_get_user_favorites()
440
  * @uses apply_filters() To call the 'bp_has_activities' hook.
441
  *
442
+ * @param array $args {
443
  * Arguments for limiting the contents of the activity loop. Most arguments
444
  * are in the same format as {@link BP_Activity_Activity::get()}. However,
445
  * because the format of the arguments accepted here differs in a number of
472
  * @type string $search_terms Limit results by a search term. Default: false.
473
  * @type string $scope Use a BuddyPress pre-built filter.
474
  * - 'just-me' retrieves items belonging only to a user; this is equivalent
475
+ * to passing a 'user_id' argument
476
+ * - 'friends' retrieves items belonging to the friends of a user
477
+ * - 'groups' retrieves items belonging to groups to which a user belongs to
478
+ * - 'favorites' retrieves a user's favorited activity items
479
+ * - 'mentions' retrieves items where a user has received an @-mention
480
  * The default value of 'scope' is set to one of the above if that value
481
  * appears in the appropriate place in the URL; eg, 'scope' will be 'groups'
482
  * when visiting http://example.com/members/joe/activity/groups/. Otherwise
508
  * Note that providing an offset will disable pagination. Default: false.
509
  * @type string|bool $display_comments How to handle activity comments. Possible values:
510
  * - 'threaded' - comments appear in a threaded tree, under their parent
511
+ * items
512
  * - 'stream' - the activity stream is presented in a flat manner, with
513
+ * comments sorted in chronological order alongside other activity items
514
+ * - false - don't fetch activity comments at all
515
  * Default: 'threaded'.
516
  * @type bool $show_hidden Whether to show items marked hide_sitewide. Defaults to false, except in
517
  * the following cases:
518
+ * - User is viewing his own activity stream
519
  * - User is viewing the activity stream of a non-public group of which he
520
+ * is a member
521
  * @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false to show all activity
522
  * regardless of spam status. Default: 'ham_only'.
523
  * @type bool $populate_extras Whether to pre-fetch the activity metadata for the queried items.
526
  * @return bool Returns true when activities are found, otherwise false.
527
  */
528
  function bp_has_activities( $args = '' ) {
529
+ global $activities_template, $bp;
530
 
531
+ /***
532
+ * Set the defaults based on the current page. Any of these will be overridden
533
+ * if arguments are directly passed into the loop. Custom plugins should always
534
+ * pass their parameters directly to the loop.
535
+ */
536
+ $user_id = false;
537
+ $include = false;
538
+ $exclude = false;
539
+ $in = false;
540
+ $show_hidden = false;
541
+ $object = false;
542
+ $primary_id = false;
543
 
544
  // User filtering
545
+ if ( bp_displayed_user_id() )
546
+ $user_id = bp_displayed_user_id();
 
547
 
548
  // Group filtering
549
+ if ( !empty( $bp->groups->current_group ) ) {
550
+ $object = $bp->groups->id;
551
+ $primary_id = $bp->groups->current_group->id;
552
+
553
+ if ( groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) || bp_current_user_can( 'bp_moderate' ) ) {
554
+ $show_hidden = true;
555
+ }
 
556
  }
557
 
558
  // The default scope should recognize custom slugs
559
+ if ( array_key_exists( bp_current_action(), (array) $bp->loaded_components ) ) {
560
+ $scope = $bp->loaded_components[bp_current_action()];
561
+ }
562
+ else
563
+ $scope = bp_current_action();
564
 
565
  // Support for permalinks on single item pages: /groups/my-group/activity/124/
566
+ if ( bp_is_current_action( bp_get_activity_slug() ) )
567
+ $include = bp_action_variable( 0 );
 
 
 
568
 
569
+ // Note: any params used for filtering can be a single value, or multiple values comma separated.
570
+ $defaults = array(
 
571
  'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
572
  'include' => $include, // pass an activity_id or string of IDs comma-separated
573
+ 'exclude' => $exclude, // pass an activity_id or string of IDs comma-separated
574
+ 'in' => $in, // comma-separated list or array of activity IDs among which to search
575
  'sort' => 'DESC', // sort DESC or ASC
576
  'page' => 1, // which page to load
577
  'per_page' => 20, // number of items per page
 
578
  'max' => false, // max number to return
579
  'count_total' => false,
580
  'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
581
  'spam' => 'ham_only', // Hide spammed items
582
 
583
+ 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679
584
+
585
  // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
586
  'scope' => $scope,
587
 
601
  // Searching
602
  'search_terms' => false, // specify terms to search on
603
  'update_meta_cache' => true,
604
+ );
605
 
606
+ $r = bp_parse_args( $args, $defaults, 'has_activities' );
607
+ extract( $r );
608
 
609
  // Translate various values for 'display_comments'
610
  // This allows disabling comments via ?display_comments=0
611
  // or =none or =false. Final true is a strict type check. See #5029
612
+ if ( in_array( $display_comments, array( 0, '0', 'none', 'false' ), true ) ) {
613
+ $display_comments = false;
614
  }
615
 
616
  // Ignore pagination if an offset is passed
617
+ if ( ! empty( $offset ) ) {
618
+ $page = 0;
619
  }
620
 
621
  // Search terms
622
+ if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) )
623
+ $search_terms = $_REQUEST['s'];
 
624
 
625
  // Do not exceed the maximum per page
626
+ if ( !empty( $max ) && ( (int) $per_page > (int) $max ) )
627
+ $per_page = $max;
 
628
 
629
  /**
630
  * Filters whether BuddyPress should enable afilter support.
637
  *
638
  * @param bool $value True if BuddyPress should enable afilter support.
639
  */
640
+ if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) )
641
+ $filter = array( 'object' => $_GET['afilter'] );
642
+ elseif ( ! empty( $user_id ) || ! empty( $object ) || ! empty( $action ) || ! empty( $primary_id ) || ! empty( $secondary_id ) || ! empty( $offset ) || ! empty( $since ) )
643
+ $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id, 'offset' => $offset, 'since' => $since );
644
+ else
645
+ $filter = false;
646
+
647
+ // If specific activity items have been requested, override the $hide_spam argument. This prevents backpat errors with AJAX.
648
+ if ( !empty( $include ) && ( 'ham_only' == $spam ) )
649
+ $spam = 'all';
650
+
651
+ $template_args = array(
652
+ 'page' => $page,
653
+ 'per_page' => $per_page,
654
+ 'page_arg' => $page_arg,
655
+ 'max' => $max,
656
+ 'count_total' => $count_total,
657
+ 'sort' => $sort,
658
+ 'include' => $include,
659
+ 'exclude' => $exclude,
660
+ 'in' => $in,
661
+ 'filter' => $filter,
662
+ 'scope' => $scope,
663
+ 'search_terms' => $search_terms,
664
+ 'meta_query' => $meta_query,
665
+ 'date_query' => $date_query,
666
+ 'filter_query' => $filter_query,
667
+ 'display_comments' => $display_comments,
668
+ 'show_hidden' => $show_hidden,
669
+ 'spam' => $spam,
670
+ 'update_meta_cache' => $update_meta_cache,
671
+ );
672
+
673
+ $activities_template = new BP_Activity_Template( $template_args );
674
 
675
  /**
676
  * Filters whether or not there are activity items to display.
677
  *
678
  * @since BuddyPress (1.1.0)
679
  *
680
+ * @param bool $has_activities Whether or not there are activity items to display.
681
  * @param string $activities_template Current activities template being used.
682
+ * @param array $template_args Array of arguments passed into the BP_Activity_Template class.
683
  */
684
+ return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template, $template_args );
685
  }
686
 
687
  /**
723
  echo esc_url( bp_get_activity_load_more_link() );
724
  }
725
  /**
726
+ * Get the URL for the Load More link
727
  *
728
  * @since BuddyPress (2.1.0)
729
  */
738
  *
739
  * @since BuddyPress (2.1.0)
740
  *
741
+ * @param string $link The "Load More" link URL with appropriate query args
742
+ * @param string $url The original URL
743
+ * @param object $activities_template The activity template loop global
744
  */
745
  return apply_filters( 'bp_get_activity_load_more_link', $link, $url, $activities_template );
746
  }
775
  $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
776
  $total = bp_core_number_format( $activities_template->total_activity_count );
777
 
778
+ return sprintf( _n( 'Viewing 1 item', 'Viewing %1$s - %2$s of %3$s items', $total, 'buddypress' ), $from_num, $to_num, $total );
 
 
 
 
 
 
779
  }
780
 
781
  /**
969
  * @since BuddyPress (1.0.0)
970
  *
971
  * @global string $bp_activity_no_activity
972
+ * @uses apply_filters() To call the 'bp_get_activities_no_activity' hook
973
  * @todo Deprecate.
974
  *
975
  * @return string
1124
  }
1125
 
1126
  /**
1127
+ * Output the display name of the member who posted the activity
1128
  *
1129
  * @since BuddyPress (2.1.0)
1130
  *
1135
  }
1136
 
1137
  /**
1138
+ * Return the display name of the member who posted the activity
1139
  *
1140
  * @since BuddyPress (2.1.0)
1141
  *
1343
  * @see bp_get_activity_avatar() for description of arguments.
1344
  * @uses bp_get_activity_avatar()
1345
  *
1346
+ * @param array $args See {@link bp_get_activity_avatar()} for description.
1347
  */
1348
  function bp_activity_avatar( $args = '' ) {
1349
  echo bp_get_activity_avatar( $args );
1355
  *
1356
  * @see bp_core_fetch_avatar() For a description of the arguments.
1357
  * @global object $activities_template {@link BP_Activity_Template}
1358
+ * @global object $bp BuddyPress global settings
1359
  * @uses bp_is_single_activity()
1360
  * @uses wp_parse_args()
1361
+ * @uses apply_filters() To call the 'bp_get_activity_avatar_object_' . $current_activity_item->component hook
1362
+ * @uses apply_filters() To call the 'bp_get_activity_avatar_item_id' hook
1363
  * @uses bp_core_fetch_avatar()
1364
+ * @uses apply_filters() To call the 'bp_get_activity_avatar' hook
1365
  *
1366
+ * @param array $args {
1367
  * Arguments are listed here with an explanation of their defaults.
1368
  * For more information about the arguments, see
1369
  * {@link bp_core_fetch_avatar()}.
1370
+ * @type string $alt Default: 'Profile picture of [user name]' if
1371
+ * activity user name is available, otherwise 'Profile picture'.
1372
+ * @type string $class Default: 'avatar'.
1373
+ * @type string|bool $email Default: Email of the activity's
1374
+ * associated user, if available. Otherwise false.
1375
+ * @type string $type Default: 'full' when viewing a single activity
1376
+ * permalink page, otherwise 'thumb'.
1377
+ * @type int|bool $user_id Default: ID of the activity's user.
1378
  * }
1379
  * @return string User avatar string.
1380
  */
1448
  $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $item_id );
1449
 
1450
  // If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it.
1451
+ if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) )
1452
  $email = $current_activity_item->user_email;
 
1453
 
1454
  /**
1455
  * Filters the value returned by bp_core_fetch_avatar.
1478
  * @see bp_get_activity_secondary_avatar() for description of arguments.
1479
  * @uses bp_get_activity_secondary_avatar()
1480
  *
1481
+ * @param array $args See {@link bp_get_activity_secondary_avatar} for description.
1482
  */
1483
  function bp_activity_secondary_avatar( $args = '' ) {
1484
  echo bp_get_activity_secondary_avatar( $args );
1485
  }
1486
 
1487
  /**
1488
+ * Return the avatar of the object that action was performed on
1489
  *
1490
  * @since BuddyPress (1.2.0)
1491
  *
1498
  * @uses bp_core_fetch_avatar()
1499
  * @uses apply_filters() To call the 'bp_get_activity_secondary_avatar' hook.
1500
  *
1501
+ * @param array $args {
1502
  * For a complete description of arguments, see {@link bp_core_fetch_avatar()}.
1503
+ * @type string $alt Default value varies based on current activity
1504
+ * item component.
1505
+ * @type string $type Default: 'full' when viewing a single activity
1506
+ * permalink page, otherwise 'thumb'.
1507
+ * @type string $class Default: 'avatar'.
1508
+ * @type string|bool $email Default: email of the activity's user.
1509
+ * @type int|bool $user_id Default: ID of the activity's user.
1510
  * }
1511
  * @return string The secondary avatar
1512
  */
1528
  // Set item_id and object (default to user)
1529
  switch ( $activities_template->activity->component ) {
1530
  case 'groups' :
 
 
 
 
1531
  $object = 'group';
1532
  $item_id = $activities_template->activity->item_id;
1533
  $link = '';
1632
  *
1633
  * @since BuddyPress (1.7.0)
1634
  *
1635
+ * @param string $link Link to wrap the avatar image in.
1636
  * @param string $component Activity component being acted on.
1637
  */
1638
  $link = apply_filters( 'bp_get_activity_secondary_avatar_link', $link, $activities_template->activity->component );
1642
  *
1643
  * @since BuddyPress (1.2.10)
1644
  *
1645
+ * @param string Formatted HTML <img> element, or raw avatar URL.
1646
  */
1647
  $avatar = apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
1648
 
1658
  }
1659
 
1660
  /**
1661
+ * Output the activity action
1662
  *
1663
  * @since BuddyPress (1.2.0)
1664
  *
1670
  }
1671
 
1672
  /**
1673
+ * Return the activity action
1674
  *
1675
  * @since BuddyPress (1.2.0)
1676
  *
1677
  * @global object $activities_template {@link BP_Activity_Template}
1678
  * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
1679
+ * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook
1680
  * @uses bp_insert_activity_meta()
1681
  * @uses apply_filters_ref_array() To call the 'bp_get_activity_action' hook.
1682
  *
1683
  * @param array $args {
1684
  * @type bool $no_timestamp Whether to exclude the timestamp.
1685
  * }
 
1686
  * @return string The activity action.
1687
  */
1688
  function bp_get_activity_action( $args = array() ) {
1689
  global $activities_template;
1690
 
1691
+ $defaults = array(
1692
  'no_timestamp' => false,
1693
+ );
1694
+
1695
+ $args = wp_parse_args( $args, $defaults );
1696
+ extract( $args, EXTR_SKIP );
1697
+
1698
+ $action = $activities_template->activity->action;
1699
 
1700
  /**
1701
  * Filters the activity action before the action is inserted as meta.
1704
  *
1705
  * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1706
  */
1707
+ $action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array( $action, &$activities_template->activity, $args ) );
 
 
 
 
1708
 
1709
+ if ( ! empty( $action ) && ! $no_timestamp )
 
1710
  $action = bp_insert_activity_meta( $action );
 
1711
 
1712
  /**
1713
  * Filters the activity action after the action has been inserted as meta.
1716
  *
1717
  * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1718
  */
1719
+ return apply_filters_ref_array( 'bp_get_activity_action', array( $action, &$activities_template->activity, $args ) );
 
 
 
 
1720
  }
1721
 
1722
  /**
1723
+ * Output the activity content body
1724
  *
1725
  * @since BuddyPress (1.2.0)
1726
  *
1731
  }
1732
 
1733
  /**
1734
+ * Return the activity content body
1735
  *
1736
  * @since BuddyPress (1.2.0)
1737
  *
1745
  global $activities_template;
1746
 
1747
  // Backwards compatibility if action is not being used
1748
+ if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) )
1749
  $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
 
1750
 
1751
  /**
1752
  * Filters the activity content body.
1770
  function bp_activity_has_content() {
1771
  global $activities_template;
1772
 
1773
+ if ( !empty( $activities_template->activity->content ) )
1774
  return true;
 
1775
 
1776
  return false;
1777
  }
1808
 
1809
  /**
1810
  * If you want to filter activity update content, please use
1811
+ * the filter 'bp_get_activity_content_body'
1812
  *
1813
  * This function is mainly for backwards compatibility.
1814
  */
1834
  * @uses apply_filters() To call the 'bp_insert_activity_meta' hook.
1835
  *
1836
  * @param string $content The activity content.
 
1837
  * @return string The activity content with the metadata string attached.
1838
  */
1839
+ function bp_insert_activity_meta( $content ) {
1840
  global $activities_template;
1841
 
1842
  // Strip any legacy time since placeholders from BP 1.0-1.1
1843
+ $content = str_replace( '<span class="time-since">%s</span>', '', $content );
 
 
 
1844
 
1845
  /**
1846
  * Filters the activity item time since markup.
1849
  *
1850
  * @param array $value Array containing the time since markup and the current activity component.
1851
  */
1852
+ $time_since = apply_filters_ref_array( 'bp_activity_time_since', array( '<span class="time-since">' . bp_core_time_since( $activities_template->activity->date_recorded ) . '</span>', &$activities_template->activity ) );
 
 
 
1853
 
1854
  // Insert the permalink
1855
+ if ( !bp_is_single_activity() ) {
 
 
 
 
 
 
 
 
 
1856
 
1857
  /**
1858
  * Filters the activity permalink to be added to the activity content.
1861
  *
1862
  * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
1863
  */
1864
+ $content = apply_filters_ref_array( 'bp_activity_permalink', array( sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ), esc_attr__( 'View Discussion', 'buddypress' ), $time_since ), &$activities_template->activity ) );
 
 
 
1865
  } else {
1866
+ $content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH );
1867
  }
1868
 
1869
  /**
1873
  *
1874
  * @param string $content Activity content with the activity metadata added.
1875
  */
1876
+ return apply_filters( 'bp_insert_activity_meta', $content );
1877
  }
1878
 
1879
  /**
1882
  * @since BuddyPress (1.2.0)
1883
  *
1884
  * @global object $activities_template {@link BP_Activity_Template}
1885
+ * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
 
 
1886
  *
1887
+ * @param object $activity Optional. Falls back on the current item in the loop.
1888
  * @return bool True if can delete, false otherwise.
1889
  */
1890
  function bp_activity_user_can_delete( $activity = false ) {
1930
  * @since BuddyPress (1.5.0)
1931
  *
1932
  * @param bool $can_delete Whether the user can delete the item.
1933
+ * @param object $activity Current activity item object.
1934
  */
1935
  return (bool) apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
1936
  }
1943
  * @see bp_get_activity_parent_content() for a description of arguments.
1944
  * @uses bp_get_activity_parent_content()
1945
  *
1946
+ * @param array $args See {@link bp_get_activity_parent_content} for description.
1947
  */
1948
  function bp_activity_parent_content( $args = '' ) {
1949
  echo bp_get_activity_parent_content($args);
1955
  * @since BuddyPress (1.2.0)
1956
  *
1957
  * @global object $activities_template {@link BP_Activity_Template}
1958
+ * @uses wp_parse_args()
1959
  * @uses apply_filters() To call the 'bp_get_activity_parent_content' hook.
1960
  *
1961
+ * @param array $args {
1962
+ * Array of optional arguments.
1963
+ * @deprecated bool $hide_user No longer used.
1964
+ * }
1965
+ * @return mixed False on failure, otherwise the activity parent content
1966
  */
1967
  function bp_get_activity_parent_content( $args = '' ) {
1968
  global $activities_template;
1969
 
1970
+ $defaults = array(
1971
+ 'hide_user' => false
1972
+ );
1973
+
1974
+ $r = wp_parse_args( $args, $defaults );
1975
+ extract( $r, EXTR_SKIP );
1976
 
1977
  // Get the ID of the parent activity content
1978
+ if ( !$parent_id = $activities_template->activity->item_id )
1979
+ return false;
1980
 
1981
  // Bail if no parent content
1982
+ if ( empty( $activities_template->activity_parents[$parent_id] ) )
1983
  return false;
 
1984
 
1985
  // Bail if no action
1986
+ if ( empty( $activities_template->activity_parents[$parent_id]->action ) )
1987
  return false;
 
1988
 
1989
  // Content always includes action
1990
+ $content = $activities_template->activity_parents[$parent_id]->action;
1991
 
1992
  // Maybe append activity content, if it exists
1993
+ if ( ! empty( $activities_template->activity_parents[$parent_id]->content ) )
1994
+ $content .= ' ' . $activities_template->activity_parents[$parent_id]->content;
 
1995
 
1996
  // Remove the time since content for backwards compatibility
1997
  $content = str_replace( '<span class="time-since">%s</span>', '', $content );
2026
  * @global BP_Activity_Template $activities_template
2027
  *
2028
  * @return bool|int False if parent activity can't be found, otherwise
2029
+ * the parent activity's user ID.
2030
  */
2031
  function bp_get_activity_parent_user_id() {
2032
  global $activities_template;
2033
 
2034
  // Bail if no activity on no item ID
2035
+ if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) )
2036
  return false;
 
2037
 
2038
  // Get the ID of the parent activity content
2039
+ if ( !$parent_id = $activities_template->activity->item_id )
2040
+ return false;
2041
 
2042
  // Bail if no parent item
2043
+ if ( empty( $activities_template->activity_parents[$parent_id] ) )
2044
  return false;
 
2045
 
2046
  // Bail if no parent user ID
2047
+ if ( empty( $activities_template->activity_parents[$parent_id]->user_id ) )
2048
  return false;
 
2049
 
2050
+ $retval = $activities_template->activity_parents[$parent_id]->user_id;
2051
 
2052
  /**
2053
  * Filters the activity parent item's user ID.
2100
  *
2101
  * @todo deprecate $args param
2102
  *
2103
+ * @param string $args Unused. Appears to be left over from an earlier implementation.
2104
  */
2105
  function bp_activity_comments( $args = '' ) {
2106
  echo bp_activity_get_comments( $args );
2116
  * @todo Given that checks for children already happen in bp_activity_recurse_comments(),
2117
  * this function can probably be streamlined or removed.
2118
  *
2119
+ * @param string $args Unused. Appears to be left over from an earlier implementation.
2120
  *
2121
  * @global object $activities_template {@link BP_Activity_Template}
2122
  * @uses bp_activity_recurse_comments()
 
 
2123
  */
2124
  function bp_activity_get_comments( $args = '' ) {
2125
  global $activities_template;
2126
 
2127
+ if ( !isset( $activities_template->activity->children ) || !$activities_template->activity->children )
2128
  return false;
 
2129
 
2130
  bp_activity_recurse_comments( $activities_template->activity );
2131
  }
2132
 
2133
  /**
2134
+ * Loops through a level of activity comments and loads the template for each
2135
  *
2136
  * Note: The recursion itself used to happen entirely in this function. Now it is
2137
  * split between here and the comment.php template.
2138
  *
2139
  * @since BuddyPress (1.2.0)
2140
  *
2141
+ * @param object $comment The activity object currently being recursed
2142
  *
2143
  * @global object $activities_template {@link BP_Activity_Template}
2144
  * @uses locate_template()
 
 
2145
  */
2146
  function bp_activity_recurse_comments( $comment ) {
2147
  global $activities_template;
2148
 
2149
+ if ( empty( $comment ) )
2150
  return false;
 
2151
 
2152
+ if ( empty( $comment->children ) )
2153
  return false;
 
2154
 
2155
  /**
2156
  * Filters the opening tag for the template that lists activity comments.
2159
  *
2160
  * @param string $value Opening tag for the HTML markup to use.
2161
  */
2162
+ echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>');
2163
  foreach ( (array) $comment->children as $comment_child ) {
 
2164
  // Put the comment into the global so it's available to filters
2165
  $activities_template->activity->current_comment = $comment_child;
2166
 
2186
  *
2187
  * @param string $value Closing tag for the HTML markup to use.
2188
  */
2189
+ echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>');
2190
  }
2191
 
2192
  /**
2198
  * @uses apply_filters() To call the 'bp_activity_current_comment' hook.
2199
  *
2200
  * @return object|bool $current_comment The activity comment currently being
2201
+ * displayed. False on failure.
2202
  */
2203
  function bp_activity_current_comment() {
2204
  global $activities_template;
2205
 
2206
+ $current_comment = !empty( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : false;
 
 
2207
 
2208
  /**
2209
  * Filters the current comment being recursed.
2235
  * @global object $activities_template {@link BP_Activity_Template}
2236
  * @uses apply_filters() To call the 'bp_activity_comment_id' hook.
2237
  *
2238
+ * @return int|bool $comment_id The ID of the activity comment
2239
+ * currently being displayed, false if none is found.
2240
  */
2241
  function bp_get_activity_comment_id() {
2242
  global $activities_template;
2273
  * @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
2274
  *
2275
  * @return int|bool $user_id The user_id of the author of the displayed
2276
+ * activity comment. False on failure.
2277
  */
2278
  function bp_get_activity_comment_user_id() {
2279
  global $activities_template;
2308
  *
2309
  * @uses bp_core_get_user_domain()
2310
  * @uses bp_get_activity_comment_user_id()
2311
+ * @uses apply_filters() To call the 'bp_activity_comment_user_link' hook
2312
  *
2313
  * @return string $user_link The URL of the activity comment author's profile.
2314
  */
2371
  }
2372
 
2373
  /**
2374
+ * Output the date_recorded of the activity comment currently being displayed.
2375
  *
2376
  * @since BuddyPress (1.5.0)
2377
  *
2382
  }
2383
 
2384
  /**
2385
+ * Return the date_recorded for the activity comment currently being displayed.
2386
  *
2387
  * @since BuddyPress (1.5.0)
2388
  *
2389
+ * @global object $activities_template {@link BP_Activity_Template}
2390
  * @uses bp_core_time_since()
2391
+ * @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook
2392
  *
2393
  * @return string|bool $date_recorded Time since the activity was recorded,
2394
+ * in the form "%s ago". False on failure.
2395
  */
2396
  function bp_get_activity_comment_date_recorded() {
2397
+ global $activities_template;
2398
+
2399
+ if ( empty( $activities_template->activity->current_comment->date_recorded ) )
2400
+ return false;
2401
+
2402
+ $date_recorded = bp_core_time_since( $activities_template->activity->current_comment->date_recorded );
2403
 
2404
  /**
2405
  * Filters the recorded date of the activity comment currently being displayed.
2408
  *
2409
  * @param string|bool Date for the activity comment currently being displayed.
2410
  */
2411
+ return apply_filters( 'bp_activity_comment_date_recorded', $date_recorded );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2412
  }
2413
 
2414
  /**
2423
  }
2424
 
2425
  /**
2426
+ * Gets the 'delete' URL for the activity comment currently being displayed
2427
  *
2428
  * @since BuddyPress (1.5.0)
2429
  *
2434
  * @uses apply_filters() To call the 'bp_activity_comment_delete_link' hook.
2435
  *
2436
  * @return string $link The nonced URL for deleting the current
2437
+ * activity comment.
2438
  */
2439
  function bp_get_activity_comment_delete_link() {
2440
  $link = wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
2548
  * @since BuddyPress (1.2.0)
2549
  *
2550
  * @uses bp_activity_recurse_comment_count()
2551
+ * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook
2552
  *
2553
  * @param object $comment Activity comment object.
2554
+ * @param int $count The current iteration count.
2555
  *
2556
  * @return int $count The activity comment count.
2557
  */
2574
  * @since BuddyPress (2.1.0)
2575
  *
2576
  * @param int $new_count New total count for the current comment.
2577
+ * @param object $comment Activity comment object.
2578
+ * @param int $count Current iteration count for the current comment.
2579
  */
2580
  return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
2581
  }
2593
  *
2594
  * @since BuddyPress (2.0.0)
2595
  *
2596
+ * @return int $depth Depth for the current activity comment
2597
  */
2598
  function bp_activity_get_comment_depth() {
2599
  global $activities_template;
2643
  }
2644
 
2645
  /**
2646
+ * Output the activity comment form no javascript display CSS.
2647
  *
2648
  * @since BuddyPress (1.2.0)
2649
  *
2654
  }
2655
 
2656
  /**
2657
+ * Return the activity comment form no javascript display CSS.
2658
  *
2659
  * @since BuddyPress (1.2.0)
2660
  *
2661
  * @global object $activities_template {@link BP_Activity_Template}
2662
  *
2663
+ * @return string|bool The activity comment form no javascript
2664
+ * display CSS. False on failure
2665
  */
2666
  function bp_get_activity_comment_form_nojs_display() {
2667
  global $activities_template;
2668
+ if ( isset( $_GET['ac'] ) && $_GET['ac'] == $activities_template->activity->id . '/' )
 
2669
  return 'style="display: block"';
 
2670
 
2671
  return false;
2672
  }
2814
  *
2815
  * @since BuddyPress (1.8.0)
2816
  *
2817
+ * @param string $link Activity comment permalink.
2818
  * @param int $comment_id ID for the current activity comment.
2819
  */
2820
  return apply_filters( 'bp_get_activity_comment_permalink', $link, $comment_id );
2840
  * @uses wp_nonce_url()
2841
  * @uses home_url()
2842
  * @uses bp_get_activity_root_slug()
2843
+ * @uses apply_filters() To call the 'bp_get_activity_favorite_link' hook
2844
  *
2845
  * @return string The activity favorite link.
2846
  */
2939
 
2940
  $class = ' activity-item';
2941
 
2942
+ if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) )
2943
  $class .= ' mini';
 
2944
 
2945
+ if ( bp_activity_get_comment_count() && bp_activity_can_comment() )
2946
  $class .= ' has-comments';
 
2947
 
2948
  /**
2949
  * Filters the determined classes to add to the HTML element.
2981
  * @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
2982
  *
2983
  * @return string $link Activity delete link. Contains $redirect_to arg
2984
+ * if on single activity page.
2985
  */
2986
  function bp_get_activity_delete_link() {
2987
 
3006
  }
3007
 
3008
  /**
3009
+ * Output the URL to delete a single activity stream item
3010
  *
3011
  * @since BuddyPress (2.1.0)
3012
  *
3016
  echo esc_url( bp_get_activity_delete_url() );
3017
  }
3018
  /**
3019
+ * Return the URL to delete a single activity item
3020
  *
3021
  * @since BuddyPress (2.1.0)
3022
  *
3031
  * @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
3032
  *
3033
  * @return string $link Activity delete link. Contains $redirect_to arg
3034
+ * if on single activity page.
3035
  */
3036
  function bp_get_activity_delete_url() {
3037
  global $activities_template;
3077
  * @uses bp_is_user_inactive()
3078
  * @uses bp_core_is_user_deleted()
3079
  * @uses bp_get_user_meta()
3080
+ * @uses apply_filters() To call the 'bp_get_activity_latest_update_excerpt' hook
3081
  * @uses bp_create_excerpt()
3082
  * @uses bp_get_root_domain()
3083
  * @uses bp_get_activity_root_slug()
3084
+ * @uses apply_filters() To call the 'bp_get_activity_latest_update' hook
3085
  *
3086
  * @param int $user_id If empty, will fall back on displayed user.
 
3087
  * @return string|bool $latest_update The activity latest update link.
3088
+ * False on failure
3089
  */
3090
  function bp_get_activity_latest_update( $user_id = 0 ) {
3091
 
3092
+ if ( empty( $user_id ) )
3093
  $user_id = bp_displayed_user_id();
 
3094
 
3095
+ if ( bp_is_user_inactive( $user_id ) )
3096
  return false;
 
3097
 
3098
+ if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) )
3099
  return false;
 
3100
 
3101
  /**
3102
  * Filters the latest update excerpt.
3132
  * @see bp_get_activity_filter_links() for description of parameters.
3133
  * @uses bp_get_activity_filter_links()
3134
  *
3135
+ * @param array $args See {@link bp_get_activity_filter_links()} for description.
3136
  */
3137
  function bp_activity_filter_links( $args = false ) {
3138
  echo bp_get_activity_filter_links( $args );
3151
  * @uses apply_filters() To call the 'bp_get_activity_filter_link_href' hook.
3152
  * @uses apply_filters() To call the 'bp_get_activity_filter_links' hook.
3153
  *
3154
+ * @param array $args {
3155
  * @type string $style The type of markup to use for the links.
3156
+ * 'list', 'paragraph', or 'span'. Default: 'list'.
3157
  * }
3158
  * @return string|bool $component_links The activity filter links.
3159
  * False on failure.
3160
  */
3161
  function bp_get_activity_filter_links( $args = false ) {
3162
 
3163
+ $defaults = array(
3164
  'style' => 'list'
3165
+ );
3166
+
3167
+ $r = wp_parse_args( $args, $defaults );
3168
+ extract( $r, EXTR_SKIP );
3169
 
3170
  // Define local variable
3171
  $component_links = array();
3173
  // Fetch the names of components that have activity recorded in the DB
3174
  $components = BP_Activity_Activity::get_recorded_components();
3175
 
3176
+ if ( empty( $components ) )
3177
  return false;
 
3178
 
3179
  foreach ( (array) $components as $component ) {
3180
 
3181
  // Skip the activity comment filter
3182
+ if ( 'activity' == $component )
3183
  continue;
 
3184
 
3185
+ if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] )
3186
  $selected = ' class="selected"';
3187
+ else
3188
+ unset($selected);
 
3189
 
3190
  $component = esc_attr( $component );
3191
 
3192
+ switch ( $style ) {
3193
  case 'list':
3194
  $tag = 'li';
3195
  $before = '<li id="afilter-' . $component . '"' . $selected . '>';
3215
  *
3216
  * @since BuddyPress (1.1.0)
3217
  *
3218
+ * @param string $link The URL for the current component.
3219
  * @param string $component The current component getting links constructed for.
3220
  */
3221
  $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
3225
 
3226
  $link = remove_query_arg( 'afilter' , $link );
3227
 
3228
+ if ( isset( $_GET['afilter'] ) )
3229
  $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_url( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
 
3230
 
3231
  /**
3232
  * Filters all of the constructed filter links.
3291
  *
3292
  * @since BuddyPress (1.5.0)
3293
  *
3294
+ * @param bool $can_comment Status on if activity can be commented on.
3295
  * @param string $activity_action Current activity action being checked on.
3296
  */
3297
  return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
3302
  *
3303
  * @since BuddyPress (1.5.0)
3304
  *
3305
+ * @param object $comment Activity comment.
3306
+ * @return bool $can_comment True if comment can receive comments, otherwise
3307
+ * false.
3308
  */
3309
+ function bp_activity_can_comment_reply( $comment = '' ) {
3310
 
3311
  // Assume activity can be commented on
3312
  $can_comment = true;
3339
  * @since BuddyPress (1.5.0)
3340
  *
3341
  * @param bool $can_comment Status on if activity reply can be commented on.
3342
+ * @param string $comment Current comment being checked on.
3343
  */
3344
  return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
3345
  }
3387
  * @since BuddyPress (1.2.0)
3388
  *
3389
  * @uses bp_activity_total_favorites_for_user()
3390
+ * @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook
3391
  *
3392
  * @param int $user_id ID of user being queried. Default: displayed user ID.
 
3393
  * @return int The total favorite count for the specified user.
3394
  */
3395
  function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
 
3396
 
3397
+ // Default to displayed user if none is passed
3398
+ $user_id = empty( $user_id )
3399
+ ? bp_displayed_user_id()
3400
+ : $user_id;
 
3401
 
3402
+ // Get user meta if user ID exists
3403
+ $retval = ! empty( $user_id )
3404
+ ? bp_activity_total_favorites_for_user( $user_id )
3405
+ : false;
 
3406
 
3407
  /**
3408
  * Filters the total favorite count for a user.
3438
  * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
3439
  *
3440
  * @param int $user_id ID of user being queried. Default: displayed user ID.
 
3441
  * @return int The total mention count for the specified user.
3442
  */
3443
  function bp_get_total_mention_count_for_user( $user_id = 0 ) {
3483
  * @uses bp_is_user()
3484
  * @uses wp_nonce_url()
3485
  * @uses bp_get_activity_directory_permalink()
3486
+ * @uses apply_filters() To call the 'bp_get_send_public_message_link' hook
3487
  *
3488
  * @return string The public message link for the displayed user.
3489
  */
3515
  *
3516
  * @param array $activity Array of activities generated from {@link bp_activity_get()}.
3517
  * @param array $activity_ids Used for recursion purposes in this function.
 
3518
  * @return array
3519
  */
3520
  function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) {
3543
  * @see bp_get_mentioned_user_display_name() for description of parameters.
3544
  * @uses bp_get_mentioned_user_display_name()
3545
  *
3546
+ * @param int|string $user_id_or_username See {@link bp_get_mentioned_user_display_name()}.
3547
  */
3548
  function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3549
  echo bp_get_mentioned_user_display_name( $user_id_or_username );
3550
  }
3551
 
3552
  /**
3553
+ * Returns the mentioned user display name
3554
  *
3555
  * @since BuddyPress (1.2.0)
3556
  *
3557
  * @uses bp_core_get_user_displayname()
3558
  * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
3559
  *
3560
+ * @param int|string User ID or username.
 
3561
  * @return string The mentioned user's display name.
3562
  */
3563
  function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
3575
  *
3576
  * @since BuddyPress (1.2.0)
3577
  *
3578
+ * @param string $name Display name for the mentioned user.
3579
  * @param int|string $user_id_or_username User ID or username use for query.
3580
  */
3581
  return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
3589
  * @see bp_get_send_public_message_button() for description of parameters.
3590
  * @uses bp_get_send_public_message_button()
3591
  *
3592
+ * @param array $args See {@link bp_get_send_public_message_button()}.
3593
  */
3594
  function bp_send_public_message_button( $args = '' ) {
3595
  echo bp_get_send_public_message_button( $args );
3605
  * @uses bp_get_button()
3606
  * @uses apply_filters() To call the 'bp_get_send_public_message_button' hook.
3607
  *
3608
+ * @param array $args {
3609
  * All arguments are optional. See {@link BP_Button} for complete
3610
  * descriptions.
3611
+ * @type string $id Default: 'public_message'.
3612
+ * @type string $component Default: 'activity'.
3613
+ * @type bool $must_be_logged_in Default: true.
3614
+ * @type bool $block_self Default: true.
3615
+ * @type string $wrapper_id Default: 'post-mention'.
3616
+ * @type string $link_href Default: the public message link for
3617
+ * the current member in the loop.
3618
+ * @type string $link_title Default: 'Send a public message on your
3619
+ * activity stream.'.
3620
+ * @type string $link_text Default: 'Public Message'.
3621
+ * @type string $link_class Default: 'activity-button mention'.
3622
  * }
3623
  * @return string The button for sending a public message.
3624
  */
3746
  * @since BuddyPress (1.7.0)
3747
  *
3748
  * @param string $retval HTML markup for the list of avatars.
3749
+ * @param array $r Array of arguments used for each avatar.
3750
  * @param array $output Array of each avatar found, before imploded into single string.
3751
  */
3752
  echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );
3782
  * @since BuddyPress (1.7.0)
3783
  *
3784
  * @param array $comments Array of {@link BP_Activity_Activity} items.
 
3785
  * @return array Array of user IDs.
3786
  */
3787
  function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
3852
  *
3853
  * @since BuddyPress (1.7.0)
3854
  *
3855
+ * @param string $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
3856
+ * @param array $args {
3857
  * Optional extra arguments.
3858
+ * @type string $checkbox_name When returning checkboxes, sets the 'name'
3859
+ * attribute.
3860
+ * @type array|string $selected A list of types that should be checked/
3861
+ * selected.
3862
  * }
3863
  */
3864
  function bp_activity_types_list( $output = 'select', $args = '' ) {
3896
  *
3897
  * @since BuddyPress (1.7.0)
3898
  *
3899
+ * @param array $args Array of arguments passed into function.
3900
+ * @param string $type Activity type being rendered in the output.
3901
  * @param string $description Description of the activity type being rendered.
3902
  */
3903
  do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
4128
  }
4129
 
4130
  /**
4131
+ * Output the activity feed item link
4132
  *
4133
  * @since BuddyPress (1.0.0)
4134
  *
4139
  }
4140
 
4141
  /**
4142
+ * Return the activity feed item link
4143
  *
4144
  * @since BuddyPress (1.0.0)
4145
  *
4272
  * @since BuddyPress (2.1.0)
4273
  *
4274
  * @param string $context The current context. 'activity', 'member',
4275
+ * 'member_groups', 'group'.
4276
  * @uses bp_get_activity_show_filters()
4277
  */
4278
  function bp_activity_show_filters( $context = '' ) {
4284
  * @since BuddyPress (2.1.0)
4285
  *
4286
  * @param string $context The current context. 'activity', 'member',
4287
+ * 'member_groups', 'group'
 
4288
  * @return string HTML for <option> values.
4289
  */
4290
  function bp_get_activity_show_filters( $context = '' ) {
4334
  *
4335
  * @since BuddyPress (2.2.0)
4336
  *
4337
+ * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
4338
  * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
4339
  */
4340
  $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
4353
  *
4354
  * @since BuddyPress (2.1.0)
4355
  *
4356
+ * @param string $output HTML output for the activity filter dropdown.
4357
  * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
4358
  * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
4359
  */
bp-activity/classes/class-bp-activity-activity.php DELETED
@@ -1,1800 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Activity Classes
4
- *
5
- * @package BuddyPress
6
- * @subpackage Activity
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * Database interaction class for the BuddyPress activity component.
14
- *
15
- * Instance methods are available for creating/editing an activity,
16
- * static methods for querying activities.
17
- *
18
- * @since BuddyPress (1.0.0)
19
- */
20
- class BP_Activity_Activity {
21
-
22
- /** Properties ************************************************************/
23
-
24
- /**
25
- * ID of the activity item.
26
- *
27
- * @var int
28
- */
29
- var $id;
30
-
31
- /**
32
- * ID of the associated item.
33
- *
34
- * @var int
35
- */
36
- var $item_id;
37
-
38
- /**
39
- * ID of the associated secondary item.
40
- *
41
- * @var int
42
- */
43
- var $secondary_item_id;
44
-
45
- /**
46
- * ID of user associated with the activity item.
47
- *
48
- * @var int
49
- */
50
- var $user_id;
51
-
52
- /**
53
- * The primary URL for the activity in RSS feeds.
54
- *
55
- * @var string
56
- */
57
- var $primary_link;
58
-
59
- /**
60
- * BuddyPress component the activity item relates to.
61
- *
62
- * @var string
63
- */
64
- var $component;
65
-
66
- /**
67
- * Activity type, eg 'new_blog_post'.
68
- *
69
- * @var string
70
- */
71
- var $type;
72
-
73
- /**
74
- * Description of the activity, eg 'Alex updated his profile.'.
75
- *
76
- * @var string
77
- */
78
- var $action;
79
-
80
- /**
81
- * The content of the activity item.
82
- *
83
- * @var string
84
- */
85
- var $content;
86
-
87
- /**
88
- * The date the activity item was recorded, in 'Y-m-d h:i:s' format.
89
- *
90
- * @var string
91
- */
92
- var $date_recorded;
93
-
94
- /**
95
- * Whether the item should be hidden in sitewide streams.
96
- *
97
- * @var int
98
- */
99
- var $hide_sitewide = false;
100
-
101
- /**
102
- * Node boundary start for activity or activity comment.
103
- *
104
- * @var int
105
- */
106
- var $mptt_left;
107
-
108
- /**
109
- * Node boundary end for activity or activity comment.
110
- *
111
- * @var int
112
- */
113
- var $mptt_right;
114
-
115
- /**
116
- * Whether this item is marked as spam.
117
- *
118
- * @var int
119
- */
120
- var $is_spam;
121
-
122
- /**
123
- * Constructor method.
124
- *
125
- * @param int|bool $id Optional. The ID of a specific activity item.
126
- */
127
- public function __construct( $id = false ) {
128
- if ( !empty( $id ) ) {
129
- $this->id = $id;
130
- $this->populate();
131
- }
132
- }
133
-
134
- /**
135
- * Populate the object with data about the specific activity item.
136
- */
137
- public function populate() {
138
- global $wpdb;
139
-
140
- $row = wp_cache_get( $this->id, 'bp_activity' );
141
-
142
- if ( false === $row ) {
143
- $bp = buddypress();
144
- $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
145
-
146
- wp_cache_set( $this->id, $row, 'bp_activity' );
147
- }
148
-
149
- if ( ! empty( $row ) ) {
150
- $this->id = (int) $row->id;
151
- $this->item_id = (int) $row->item_id;
152
- $this->secondary_item_id = (int) $row->secondary_item_id;
153
- $this->user_id = (int) $row->user_id;
154
- $this->primary_link = $row->primary_link;
155
- $this->component = $row->component;
156
- $this->type = $row->type;
157
- $this->action = $row->action;
158
- $this->content = $row->content;
159
- $this->date_recorded = $row->date_recorded;
160
- $this->hide_sitewide = $row->hide_sitewide;
161
- $this->mptt_left = (int) $row->mptt_left;
162
- $this->mptt_right = (int) $row->mptt_right;
163
- $this->is_spam = $row->is_spam;
164
- }
165
-
166
- // Generate dynamic 'action' when possible
167
- $action = bp_activity_generate_action_string( $this );
168
- if ( false !== $action ) {
169
- $this->action = $action;
170
-
171
- // If no callback is available, use the literal string from
172
- // the database row
173
- } elseif ( ! empty( $row->action ) ) {
174
- $this->action = $row->action;
175
-
176
- // Provide a fallback to avoid PHP notices
177
- } else {
178
- $this->action = '';
179
- }
180
- }
181
-
182
- /**
183
- * Save the activity item to the database.
184
- *
185
- * @return bool True on success.
186
- */
187
- public function save() {
188
- global $wpdb;
189
-
190
- $bp = buddypress();
191
-
192
- $this->id = apply_filters_ref_array( 'bp_activity_id_before_save', array( $this->id, &$this ) );
193
- $this->item_id = apply_filters_ref_array( 'bp_activity_item_id_before_save', array( $this->item_id, &$this ) );
194
- $this->secondary_item_id = apply_filters_ref_array( 'bp_activity_secondary_item_id_before_save', array( $this->secondary_item_id, &$this ) );
195
- $this->user_id = apply_filters_ref_array( 'bp_activity_user_id_before_save', array( $this->user_id, &$this ) );
196
- $this->primary_link = apply_filters_ref_array( 'bp_activity_primary_link_before_save', array( $this->primary_link, &$this ) );
197
- $this->component = apply_filters_ref_array( 'bp_activity_component_before_save', array( $this->component, &$this ) );
198
- $this->type = apply_filters_ref_array( 'bp_activity_type_before_save', array( $this->type, &$this ) );
199
- $this->action = apply_filters_ref_array( 'bp_activity_action_before_save', array( $this->action, &$this ) );
200
- $this->content = apply_filters_ref_array( 'bp_activity_content_before_save', array( $this->content, &$this ) );
201
- $this->date_recorded = apply_filters_ref_array( 'bp_activity_date_recorded_before_save', array( $this->date_recorded, &$this ) );
202
- $this->hide_sitewide = apply_filters_ref_array( 'bp_activity_hide_sitewide_before_save', array( $this->hide_sitewide, &$this ) );
203
- $this->mptt_left = apply_filters_ref_array( 'bp_activity_mptt_left_before_save', array( $this->mptt_left, &$this ) );
204
- $this->mptt_right = apply_filters_ref_array( 'bp_activity_mptt_right_before_save', array( $this->mptt_right, &$this ) );
205
- $this->is_spam = apply_filters_ref_array( 'bp_activity_is_spam_before_save', array( $this->is_spam, &$this ) );
206
-
207
- /**
208
- * Fires before the current activity item gets saved.
209
- *
210
- * Please use this hook to filter the properties above. Each part will be passed in.
211
- *
212
- * @since BuddyPress (1.0.0)
213
- *
214
- * @param BP_Activity_Activity $this Current instance of the activity item being saved. Passed by reference.
215
- */
216
- do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
217
-
218
- if ( empty( $this->component ) || empty( $this->type ) ) {
219
- return false;
220
- }
221
-
222
- if ( empty( $this->primary_link ) ) {
223
- $this->primary_link = bp_loggedin_user_domain();
224
- }
225
-
226
- // If we have an existing ID, update the activity item, otherwise insert it.
227
- if ( ! empty( $this->id ) ) {
228
- $q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %d, secondary_item_id = %d, hide_sitewide = %d, is_spam = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam, $this->id );
229
- } else {
230
- $q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam );
231
- }
232
-
233
- if ( false === $wpdb->query( $q ) ) {
234
- return false;
235
- }
236
-
237
- // If this is a new activity item, set the $id property
238
- if ( empty( $this->id ) ) {
239
- $this->id = $wpdb->insert_id;
240
-
241
- // If an existing activity item, prevent any changes to the content generating new @mention notifications.
242
- } else {
243
- add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
244
- }
245
-
246
- /**
247
- * Fires after an activity item has been saved to the database.
248
- *
249
- * @since BuddyPress (1.0.0)
250
- *
251
- * @param BP_Activity_Activity $this Current instance of activity item being saved. Passed by reference.
252
- */
253
- do_action_ref_array( 'bp_activity_after_save', array( &$this ) );
254
-
255
- return true;
256
- }
257
-
258
- /** Static Methods ***************************************************/
259
-
260
- /**
261
- * Get activity items, as specified by parameters.
262
- *
263
- * @see BP_Activity_Activity::get_filter_sql() for a description of the
264
- * 'filter' parameter.
265
- * @see WP_Meta_Query::queries for a description of the 'meta_query'
266
- * parameter format.
267
- *
268
- * @param array $args {
269
- * An array of arguments. All items are optional.
270
- *
271
- * @type int $page Which page of results to fetch. Using page=1 without per_page will result
272
- * in no pagination. Default: 1.
273
- * @type int|bool $per_page Number of results per page. Default: 25.
274
- * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
275
- * @type string $sort ASC or DESC. Default: 'DESC'.
276
- * @type array $exclude Array of activity IDs to exclude. Default: false.
277
- * @type array $in Array of ids to limit query by (IN). Default: false.
278
- * @type array $meta_query Array of meta_query conditions. See WP_Meta_Query::queries.
279
- * @type array $date_query Array of date_query conditions. See first parameter of
280
- * WP_Date_Query::__construct().
281
- * @type array $filter_query Array of advanced query conditions. See BP_Activity_Query::__construct().
282
- * @type string|array $scope Pre-determined set of activity arguments.
283
- * @type array $filter See BP_Activity_Activity::get_filter_sql().
284
- * @type string $search_terms Limit results by a search term. Default: false.
285
- * @type bool $display_comments Whether to include activity comments. Default: false.
286
- * @type bool $show_hidden Whether to show items marked hide_sitewide. Default: false.
287
- * @type string $spam Spam status. Default: 'ham_only'.
288
- * @type bool $update_meta_cache Whether to pre-fetch metadata for queried activity items. Default: true.
289
- * @type string|bool $count_total If true, an additional DB query is run to count the total activity items
290
- * for the query. Default: false.
291
- * }
292
- * @return array The array returned has two keys:
293
- * - 'total' is the count of located activities
294
- * - 'activities' is an array of the located activities
295
- */
296
- public static function get( $args = array() ) {
297
- global $wpdb;
298
-
299
- // Backward compatibility with old method of passing arguments
300
- if ( !is_array( $args ) || func_num_args() > 1 ) {
301
- _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
302
-
303
- $old_args_keys = array(
304
- 0 => 'max',
305
- 1 => 'page',
306
- 2 => 'per_page',
307
- 3 => 'sort',
308
- 4 => 'search_terms',
309
- 5 => 'filter',
310
- 6 => 'display_comments',
311
- 7 => 'show_hidden',
312
- 8 => 'exclude',
313
- 9 => 'in',
314
- 10 => 'spam'
315
- );
316
-
317
- $func_args = func_get_args();
318
- $args = bp_core_parse_args_array( $old_args_keys, $func_args );
319
- }
320
-
321
- $bp = buddypress();
322
- $r = wp_parse_args( $args, array(
323
- 'page' => 1, // The current page
324
- 'per_page' => 25, // Activity items per page
325
- 'max' => false, // Max number of items to return
326
- 'sort' => 'DESC', // ASC or DESC
327
- 'exclude' => false, // Array of ids to exclude
328
- 'in' => false, // Array of ids to limit query by (IN)
329
- 'meta_query' => false, // Filter by activitymeta
330
- 'date_query' => false, // Filter by date
331
- 'filter_query' => false, // Advanced filtering - see BP_Activity_Query
332
- 'filter' => false, // See self::get_filter_sql()
333
- 'scope' => false, // Preset activity arguments
334
- 'search_terms' => false, // Terms to search by
335
- 'display_comments' => false, // Whether to include activity comments
336
- 'show_hidden' => false, // Show items marked hide_sitewide
337
- 'spam' => 'ham_only', // Spam status
338
- 'update_meta_cache' => true,
339
- 'count_total' => false,
340
- ) );
341
-
342
- // Select conditions
343
- $select_sql = "SELECT DISTINCT a.id";
344
-
345
- $from_sql = " FROM {$bp->activity->table_name} a";
346
-
347
- $join_sql = '';
348
-
349
- // Where conditions
350
- $where_conditions = array();
351
-
352
- // Excluded types
353
- $excluded_types = array();
354
-
355
- // Scope takes precedence
356
- if ( ! empty( $r['scope'] ) ) {
357
- $scope_query = self::get_scope_query_sql( $r['scope'], $r );
358
-
359
- // Add our SQL conditions if matches were found
360
- if ( ! empty( $scope_query['sql'] ) ) {
361
- $where_conditions['scope_query_sql'] = $scope_query['sql'];
362
- }
363
-
364
- // override some arguments if needed
365
- if ( ! empty( $scope_query['override'] ) ) {
366
- $r = self::array_replace_recursive( $r, $scope_query['override'] );
367
- }
368
-
369
- // Advanced filtering
370
- } elseif ( ! empty( $r['filter_query'] ) ) {
371
- $filter_query = new BP_Activity_Query( $r['filter_query'] );
372
- $sql = $filter_query->get_sql();
373
- if ( ! empty( $sql ) ) {
374
- $where_conditions['filter_query_sql'] = $sql;
375
- }
376
- }
377
-
378
- // Regular filtering
379
- if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
380
- $where_conditions['filter_sql'] = $filter_sql;
381
- }
382
-
383
- // Spam
384
- if ( 'ham_only' == $r['spam'] ) {
385
- $where_conditions['spam_sql'] = 'a.is_spam = 0';
386
- } elseif ( 'spam_only' == $r['spam'] ) {
387
- $where_conditions['spam_sql'] = 'a.is_spam = 1';
388
- }
389
-
390
- // Searching
391
- if ( $r['search_terms'] ) {
392
- $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
393
- $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
394
- }
395
-
396
- // Sorting
397
- $sort = $r['sort'];
398
- if ( $sort != 'ASC' && $sort != 'DESC' ) {
399
- $sort = 'DESC';
400
- }
401
-
402
- // Hide Hidden Items?
403
- if ( ! $r['show_hidden'] ) {
404
- $where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
405
- }
406
-
407
- // Exclude specified items
408
- if ( ! empty( $r['exclude'] ) ) {
409
- $exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
410
- $where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
411
- }
412
-
413
- // The specific ids to which you want to limit the query
414
- if ( ! empty( $r['in'] ) ) {
415
- $in = implode( ',', wp_parse_id_list( $r['in'] ) );
416
- $where_conditions['in'] = "a.id IN ({$in})";
417
- }
418
-
419
- // Process meta_query into SQL
420
- $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
421
-
422
- if ( ! empty( $meta_query_sql['join'] ) ) {
423
- $join_sql .= $meta_query_sql['join'];
424
- }
425
-
426
- if ( ! empty( $meta_query_sql['where'] ) ) {
427
- $where_conditions[] = $meta_query_sql['where'];
428
- }
429
-
430
- // Process date_query into SQL
431
- $date_query_sql = self::get_date_query_sql( $r['date_query'] );
432
-
433
- if ( ! empty( $date_query_sql ) ) {
434
- $where_conditions['date'] = $date_query_sql;
435
- }
436
-
437
- // Alter the query based on whether we want to show activity item
438
- // comments in the stream like normal comments or threaded below
439
- // the activity.
440
- if ( false === $r['display_comments'] || 'threaded' === $r['display_comments'] ) {
441
- $excluded_types[] = 'activity_comment';
442
- }
443
-
444
- // Exclude 'last_activity' items unless the 'action' filter has
445
- // been explicitly set
446
- if ( empty( $r['filter']['object'] ) ) {
447
- $excluded_types[] = 'last_activity';
448
- }
449
-
450
- // Build the excluded type sql part
451
- if ( ! empty( $excluded_types ) ) {
452
- $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
453
- $where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
454
- }
455
-
456
- /**
457
- * Filters the MySQL WHERE conditions for the Activity items get method.
458
- *
459
- * @since BuddyPress (1.9.0)
460
- *
461
- * @param array $where_conditions Current conditions for MySQL WHERE statement.
462
- * @param array $r Parsed arguments passed into method.
463
- * @param string $select_sql Current SELECT MySQL statement at point of execution.
464
- * @param string $from_sql Current FROM MySQL statement at point of execution.
465
- * @param string $join_sql Current INNER JOIN MySQL statement at point of execution.
466
- */
467
- $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
468
-
469
- // Join the where conditions together
470
- $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
471
-
472
- /**
473
- * Filters the preferred order of indexes for activity item.
474
- *
475
- * @since BuddyPress (1.6.0)
476
- *
477
- * @param array Array of indexes in preferred order.
478
- */
479
- $indexes = apply_filters( 'bp_activity_preferred_index_order', array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ) );
480
-
481
- foreach( $indexes as $key => $index ) {
482
- if ( false !== strpos( $where_sql, $index ) ) {
483
- $the_index = $index;
484
- break; // Take the first one we find
485
- }
486
- }
487
-
488
- if ( !empty( $the_index ) ) {
489
- $index_hint_sql = "USE INDEX ({$the_index})";
490
- } else {
491
- $index_hint_sql = '';
492
- }
493
-
494
- // Sanitize page and per_page parameters
495
- $page = absint( $r['page'] );
496
- $per_page = absint( $r['per_page'] );
497
-
498
- $retval = array(
499
- 'activities' => null,
500
- 'total' => null,
501
- 'has_more_items' => null,
502
- );
503
-
504
- /**
505
- * Filters if BuddyPress should use legacy query structure over current structure for version 2.0+.
506
- *
507
- * It is not recommended to use the legacy structure, but allowed to if needed.
508
- *
509
- * @since BuddyPress (2.0.0)
510
- *
511
- * @param bool $value Whether to use legacy structure or not.
512
- * @param BP_Activity_Activity $value Current method being called.
513
- * @param array $r Parsed arguments passed into method.
514
- */
515
- if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
516
-
517
- // Legacy queries joined against the user table
518
- $select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
519
- $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
520
-
521
- if ( ! empty( $page ) && ! empty( $per_page ) ) {
522
- $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
523
-
524
- /** this filter is documented in bp-activity/bp-activity-classes.php */
525
- $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
526
- } else {
527
- $pag_sql = '';
528
-
529
- /**
530
- * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
531
- *
532
- * @since BuddyPress (1.5.0)
533
- *
534
- * @param string $value Concatenated MySQL statement pieces to be query results with for legacy query.
535
- * @param string $select_sql Final SELECT MySQL statement portion for legacy query.
536
- * @param string $from_sql Final FROM MySQL statement portion for legacy query.
537
- * @param string $where_sql Final WHERE MySQL statement portion for legacy query.
538
- * @param string $sort Final sort direction for legacy query.
539
- */
540
- $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
541
- }
542
-
543
- } else {
544
- // Query first for activity IDs
545
- $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
546
-
547
- if ( ! empty( $per_page ) && ! empty( $page ) ) {
548
- // We query for $per_page + 1 items in order to
549
- // populate the has_more_items flag
550
- $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
551
- }
552
-
553
- /**
554
- * Filters the paged activities MySQL statement.
555
- *
556
- * @since BuddyPress (2.0.0)
557
- *
558
- * @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
559
- * @param array $r Array of arguments passed into method.
560
- */
561
- $activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
562
-
563
- $activity_ids = $wpdb->get_col( $activity_ids_sql );
564
-
565
- $retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
566
-
567
- // If we've fetched more than the $per_page value, we
568
- // can discard the extra now
569
- if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
570
- array_pop( $activity_ids );
571
- }
572
-
573
- $activities = self::get_activity_data( $activity_ids );
574
- }
575
-
576
- // Get the fullnames of users so we don't have to query in the loop
577
- $activities = self::append_user_fullnames( $activities );
578
-
579
- // Get activity meta
580
- $activity_ids = array();
581
- foreach ( (array) $activities as $activity ) {
582
- $activity_ids[] = $activity->id;
583
- }
584
-
585
- if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
586
- bp_activity_update_meta_cache( $activity_ids );
587
- }
588
-
589
- if ( $activities && $r['display_comments'] ) {
590
- $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
591
- }
592
-
593
- // Pre-fetch data associated with activity users and other objects
594
- BP_Activity_Activity::prefetch_object_data( $activities );
595
-
596
- // Generate action strings
597
- $activities = BP_Activity_Activity::generate_action_strings( $activities );
598
-
599
- $retval['activities'] = $activities;
600
-
601
- // If $max is set, only return up to the max results
602
- if ( ! empty( $r['count_total'] ) ) {
603
-
604
- /**
605
- * Filters the total activities MySQL statement.
606
- *
607
- * @since BuddyPress (1.5.0)
608
- *
609
- * @param string $value MySQL statement used to query for total activities.
610
- * @param string $where_sql MySQL WHERE statement portion.
611
- * @param string $sort Sort direction for query.
612
- */
613
- $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
614
- $total_activities = $wpdb->get_var( $total_activities_sql );
615
-
616
- if ( !empty( $r['max'] ) ) {
617
- if ( (int) $total_activities > (int) $r['max'] ) {
618
- $total_activities = $r['max'];
619
- }
620
- }
621
-
622
- $retval['total'] = $total_activities;
623
- }
624
-
625
- return $retval;
626
- }
627
-
628
- /**
629
- * Convert activity IDs to activity objects, as expected in template loop.
630
- *
631
- * @since BuddyPress (2.0.0)
632
- *
633
- * @param array $activity_ids Array of activity IDs.
634
- *
635
- * @return array
636
- */
637
- protected static function get_activity_data( $activity_ids = array() ) {
638
- global $wpdb;
639
-
640
- // Bail if no activity ID's passed
641
- if ( empty( $activity_ids ) ) {
642
- return array();
643
- }
644
-
645
- // Get BuddyPress
646
- $bp = buddypress();
647
-
648
- $activities = array();
649
- $uncached_ids = bp_get_non_cached_ids( $activity_ids, 'bp_activity' );
650
-
651
- // Prime caches as necessary
652
- if ( ! empty( $uncached_ids ) ) {
653
- // Format the activity ID's for use in the query below
654
- $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
655
-
656
- // Fetch data from activity table, preserving order
657
- $queried_adata = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$uncached_ids_sql})");
658
-
659
- // Put that data into the placeholders created earlier,
660
- // and add it to the cache
661
- foreach ( (array) $queried_adata as $adata ) {
662
- wp_cache_set( $adata->id, $adata, 'bp_activity' );
663
- }
664
- }
665
-
666
- // Now fetch data from the cache
667
- foreach ( $activity_ids as $activity_id ) {
668
- $activities[] = wp_cache_get( $activity_id, 'bp_activity' );
669
- }
670
-
671
- // Then fetch user data
672
- $user_query = new BP_User_Query( array(
673
- 'user_ids' => wp_list_pluck( $activities, 'user_id' ),
674
- 'populate_extras' => false,
675
- ) );
676
-
677
- // Associated located user data with activity items
678
- foreach ( $activities as $a_index => $a_item ) {
679
- $a_user_id = intval( $a_item->user_id );
680
- $a_user = isset( $user_query->results[ $a_user_id ] ) ? $user_query->results[ $a_user_id ] : '';
681
-
682
- if ( !empty( $a_user ) ) {
683
- $activities[ $a_index ]->user_email = $a_user->user_email;
684
- $activities[ $a_index ]->user_nicename = $a_user->user_nicename;
685
- $activities[ $a_index ]->user_login = $a_user->user_login;
686
- $activities[ $a_index ]->display_name = $a_user->display_name;
687
- }
688
- }
689
-
690
- return $activities;
691
- }
692
-
693
- /**
694
- * Append xProfile fullnames to an activity array.
695
- *
696
- * @since BuddyPress (2.0.0)
697
- *
698
- * @param array $activities Activities array.
699
- *
700
- * @return array
701
- */
702
- protected static function append_user_fullnames( $activities ) {
703
-
704
- if ( bp_is_active( 'xprofile' ) && ! empty( $activities ) ) {
705
- $activity_user_ids = wp_list_pluck( $activities, 'user_id' );
706
-
707
- if ( ! empty( $activity_user_ids ) ) {
708
- $fullnames = bp_core_get_user_displaynames( $activity_user_ids );
709
- if ( ! empty( $fullnames ) ) {
710
- foreach ( (array) $activities as $i => $activity ) {
711
- if ( ! empty( $fullnames[ $activity->user_id ] ) ) {
712
- $activities[ $i ]->user_fullname = $fullnames[ $activity->user_id ];
713
- }
714
- }
715
- }
716
- }
717
- }
718
-
719
- return $activities;
720
- }
721
-
722
- /**
723
- * Pre-fetch data for objects associated with activity items.
724
- *
725
- * Activity items are associated with users, and often with other
726
- * BuddyPress data objects. Here, we pre-fetch data about these
727
- * associated objects, so that inline lookups - done primarily when
728
- * building action strings - do not result in excess database queries.
729
- *
730
- * The only object data required for activity component activity types
731
- * (activity_update and activity_comment) is related to users, and that
732
- * info is fetched separately in BP_Activity_Activity::get_activity_data().
733
- * So this method contains nothing but a filter that allows other
734
- * components, such as bp-friends and bp-groups, to hook in and prime
735
- * their own caches at the beginning of an activity loop.
736
- *
737
- * @since BuddyPress (2.0.0)
738
- *
739
- * @param array $activities Array of activities.
740
- *
741
- * @return array $activities Array of activities.
742
- */
743
- protected static function prefetch_object_data( $activities ) {
744
-
745
- /**
746
- * Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
747
- *
748
- * @since BuddyPress (2.0.0)
749
- *
750
- * @param array $activities Array of activities.
751
- */
752
- return apply_filters( 'bp_activity_prefetch_object_data', $activities );
753
- }
754
-
755
- /**
756
- * Generate action strings for the activities located in BP_Activity_Activity::get().
757
- *
758
- * If no string can be dynamically generated for a given item
759
- * (typically because the activity type has not been properly
760
- * registered), the static 'action' value pulled from the database will
761
- * be left in place.
762
- *
763
- * @since BuddyPress (2.0.0)
764
- *
765
- * @param array $activities Array of activities.
766
- *
767
- * @return array
768
- */
769
- protected static function generate_action_strings( $activities ) {
770
- foreach ( $activities as $key => $activity ) {
771
- $generated_action = bp_activity_generate_action_string( $activity );
772
- if ( false !== $generated_action ) {
773
- $activity->action = $generated_action;
774
- }
775
-
776
- $activities[ $key ] = $activity;
777
- }
778
-
779
- return $activities;
780
- }
781
-
782
- /**
783
- * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get().
784
- *
785
- * We use WP_Meta_Query to do the heavy lifting of parsing the
786
- * meta_query array and creating the necessary SQL clauses. However,
787
- * since BP_Activity_Activity::get() builds its SQL differently than
788
- * WP_Query, we have to alter the return value (stripping the leading
789
- * AND keyword from the 'where' clause).
790
- *
791
- * @since BuddyPress (1.8.0)
792
- *
793
- * @param array $meta_query An array of meta_query filters. See the
794
- * documentation for WP_Meta_Query for details.
795
- *
796
- * @return array $sql_array 'join' and 'where' clauses.
797
- */
798
- public static function get_meta_query_sql( $meta_query = array() ) {
799
- global $wpdb;
800
-
801
- $sql_array = array(
802
- 'join' => '',
803
- 'where' => '',
804
- );
805
-
806
- if ( ! empty( $meta_query ) ) {
807
- $activity_meta_query = new WP_Meta_Query( $meta_query );
808
-
809
- // WP_Meta_Query expects the table name at
810
- // $wpdb->activitymeta
811
- $wpdb->activitymeta = buddypress()->activity->table_name_meta;
812
-
813
- $meta_sql = $activity_meta_query->get_sql( 'activity', 'a', 'id' );
814
-
815
- // Strip the leading AND - BP handles it in get()
816
- $sql_array['where'] = preg_replace( '/^\sAND/', '', $meta_sql['where'] );
817
- $sql_array['join'] = $meta_sql['join'];
818
- }
819
-
820
- return $sql_array;
821
- }
822
-
823
- /**
824
- * Get the SQL for the 'date_query' param in BP_Activity_Activity::get().
825
- *
826
- * We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
827
- * of parsing the date_query array and creating the necessary SQL clauses.
828
- * However, since BP_Activity_Activity::get() builds its SQL differently than
829
- * WP_Query, we have to alter the return value (stripping the leading AND
830
- * keyword from the query).
831
- *
832
- * @since BuddyPress (2.1.0)
833
- *
834
- * @param array $date_query An array of date_query parameters. See the
835
- * documentation for the first parameter of WP_Date_Query.
836
- *
837
- * @return string
838
- */
839
- public static function get_date_query_sql( $date_query = array() ) {
840
- $sql = '';
841
-
842
- // Date query
843
- if ( ! empty( $date_query ) && is_array( $date_query ) && class_exists( 'BP_Date_Query' ) ) {
844
- $date_query = new BP_Date_Query( $date_query, 'date_recorded' );
845
- $sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
846
- }
847
-
848
- return $sql;
849
- }
850
-
851
- /**
852
- * Get the SQL for the 'scope' param in BP_Activity_Activity::get().
853
- *
854
- * A scope is a predetermined set of activity arguments. This method is used
855
- * to grab these activity arguments and override any existing args if needed.
856
- *
857
- * Can handle multiple scopes.
858
- *
859
- * @since BuddyPress (2.2.0)
860
- *
861
- * @param mixed $scope The activity scope. Accepts string or array of scopes.
862
- * @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),
863
- * but merged with defaults.
864
- *
865
- * @return array 'sql' WHERE SQL string and 'override' activity args.
866
- */
867
- public static function get_scope_query_sql( $scope = false, $r = array() ) {
868
-
869
- // Define arrays for future use
870
- $query_args = array();
871
- $override = array();
872
- $retval = array();
873
-
874
- // Check for array of scopes
875
- if ( is_array( $scope ) ) {
876
- $scopes = $scope;
877
-
878
- // Explode a comma separated string of scopes
879
- } elseif ( is_string( $scope ) ) {
880
- $scopes = explode( ',', $scope );
881
- }
882
-
883
- // Bail if no scope passed
884
- if ( empty( $scopes ) ) {
885
- return false;
886
- }
887
-
888
- // Helper to easily grab the 'user_id'
889
- if ( ! empty( $r['filter']['user_id'] ) ) {
890
- $r['user_id'] = $r['filter']['user_id'];
891
- }
892
-
893
- // parse each scope; yes! we handle multiples!
894
- foreach ( $scopes as $scope ) {
895
- $scope_args = array();
896
-
897
- /**
898
- * Plugins can hook here to set their activity arguments for custom scopes.
899
- *
900
- * This is a dynamic filter based on the activity scope. eg:
901
- * - 'bp_activity_set_groups_scope_args'
902
- * - 'bp_activity_set_friends_scope_args'
903
- *
904
- * To see how this filter is used, plugin devs should check out:
905
- * - bp_groups_filter_activity_scope() - used for 'groups' scope
906
- * - bp_friends_filter_activity_scope() - used for 'friends' scope
907
- *
908
- * @since BuddyPress (2.2.0)
909
- *
910
- * @param array {
911
- * Activity query clauses.
912
- *
913
- * @type array {
914
- * Activity arguments for your custom scope.
915
- * See {@link BP_Activity_Query::_construct()} for more details.
916
- * }
917
- * @type array $override Optional. Override existing activity arguments passed by $r.
918
- * }
919
- * @param array $r Current activity arguments passed in BP_Activity_Activity::get().
920
- */
921
- $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r );
922
-
923
- if ( ! empty( $scope_args ) ) {
924
- // merge override properties from other scopes
925
- // this might be a problem...
926
- if ( ! empty( $scope_args['override'] ) ) {
927
- $override = array_merge( $override, $scope_args['override'] );
928
- unset( $scope_args['override'] );
929
- }
930
-
931
- // save scope args
932
- if ( ! empty( $scope_args ) ) {
933
- $query_args[] = $scope_args;
934
- }
935
- }
936
- }
937
-
938
- if ( ! empty( $query_args ) ) {
939
- // set relation to OR
940
- $query_args['relation'] = 'OR';
941
-
942
- $query = new BP_Activity_Query( $query_args );
943
- $sql = $query->get_sql();
944
- if ( ! empty( $sql ) ) {
945
- $retval['sql'] = $sql;
946
- }
947
- }
948
-
949
- if ( ! empty( $override ) ) {
950
- $retval['override'] = $override;
951
- }
952
-
953
- return $retval;
954
- }
955
-
956
- /**
957
- * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
958
- *
959
- * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
960
- *
961
- * @since BuddyPress (1.2.0)
962
- *
963
- * @deprecated 1.5
964
- * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
965
- *
966
- * @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve.
967
- * @param int|bool $max Maximum number of results to return. (Optional; default is no maximum).
968
- * @param int $page The set of results that the user is viewing. Used in pagination. (Optional; default is 1).
969
- * @param int $per_page Specifies how many results per page. Used in pagination. (Optional; default is 25).
970
- * @param string $sort MySQL column sort; ASC or DESC. (Optional; default is DESC).
971
- * @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false).
972
- *
973
- * @return array
974
- */
975
- public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
976
- _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
977
- return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
978
- }
979
-
980
- /**
981
- * Get the first activity ID that matches a set of criteria.
982
- *
983
- * @param int $user_id User ID to filter by.
984
- * @param string $component Component to filter by.
985
- * @param string $type Activity type to filter by.
986
- * @param int $item_id Associated item to filter by.
987
- * @param int $secondary_item_id Secondary associated item to filter by.
988
- * @param string $action Action to filter by.
989
- * @param string $content Content to filter by.
990
- * @param string $date_recorded Date to filter by.
991
- *
992
- * @todo Should parameters be optional?
993
- *
994
- * @return int|bool Activity ID on success, false if none is found.
995
- */
996
- public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
997
- global $wpdb;
998
-
999
- $bp = buddypress();
1000
-
1001
- $where_args = false;
1002
-
1003
- if ( ! empty( $user_id ) ) {
1004
- $where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
1005
- }
1006
-
1007
- if ( ! empty( $component ) ) {
1008
- $where_args[] = $wpdb->prepare( "component = %s", $component );
1009
- }
1010
-
1011
- if ( ! empty( $type ) ) {
1012
- $where_args[] = $wpdb->prepare( "type = %s", $type );
1013
- }
1014
-
1015
- if ( ! empty( $item_id ) ) {
1016
- $where_args[] = $wpdb->prepare( "item_id = %d", $item_id );
1017
- }
1018
-
1019
- if ( ! empty( $secondary_item_id ) ) {
1020
- $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id );
1021
- }
1022
-
1023
- if ( ! empty( $action ) ) {
1024
- $where_args[] = $wpdb->prepare( "action = %s", $action );
1025
- }
1026
-
1027
- if ( ! empty( $content ) ) {
1028
- $where_args[] = $wpdb->prepare( "content = %s", $content );
1029
- }
1030
-
1031
- if ( ! empty( $date_recorded ) ) {
1032
- $where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
1033
- }
1034
-
1035
- if ( ! empty( $where_args ) ) {
1036
- $where_sql = 'WHERE ' . join( ' AND ', $where_args );
1037
- return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
1038
- }
1039
-
1040
- return false;
1041
- }
1042
-
1043
- /**
1044
- * Delete activity items from the database.
1045
- *
1046
- * To delete a specific activity item, pass an 'id' parameter.
1047
- * Otherwise use the filters.
1048
- *
1049
- * @since BuddyPress (1.2.0)
1050
- *
1051
- * @param array $args {
1052
- * @int $id Optional. The ID of a specific item to delete.
1053
- * @string $action Optional. The action to filter by.
1054
- * @string $content Optional. The content to filter by.
1055
- * @string $component Optional. The component name to filter by.
1056
- * @string $type Optional. The activity type to filter by.
1057
- * @string $primary_link Optional. The primary URL to filter by.
1058
- * @int $user_id Optional. The user ID to filter by.
1059
- * @int $item_id Optional. The associated item ID to filter by.
1060
- * @int $secondary_item_id Optional. The secondary associated item ID to filter by.
1061
- * @string $date_recorded Optional. The date to filter by.
1062
- * @int $hide_sitewide Optional. Default: false.
1063
- * }
1064
- *
1065
- * @return array|bool An array of deleted activity IDs on success, false on failure.
1066
- */
1067
- public static function delete( $args = array() ) {
1068
- global $wpdb;
1069
-
1070
- $bp = buddypress();
1071
- $r = wp_parse_args( $args, array(
1072
- 'id' => false,
1073
- 'action' => false,
1074
- 'content' => false,
1075
- 'component' => false,
1076
- 'type' => false,
1077
- 'primary_link' => false,
1078
- 'user_id' => false,
1079
- 'item_id' => false,
1080
- 'secondary_item_id' => false,
1081
- 'date_recorded' => false,
1082
- 'hide_sitewide' => false
1083
- ) );
1084
-
1085
- // Setup empty array from where query arguments
1086
- $where_args = array();
1087
-
1088
- // ID
1089
- if ( ! empty( $r['id'] ) ) {
1090
- $where_args[] = $wpdb->prepare( "id = %d", $r['id'] );
1091
- }
1092
-
1093
- // User ID
1094
- if ( ! empty( $r['user_id'] ) ) {
1095
- $where_args[] = $wpdb->prepare( "user_id = %d", $r['user_id'] );
1096
- }
1097
-
1098
- // Action
1099
- if ( ! empty( $r['action'] ) ) {
1100
- $where_args[] = $wpdb->prepare( "action = %s", $r['action'] );
1101
- }
1102
-
1103
- // Content
1104
- if ( ! empty( $r['content'] ) ) {
1105
- $where_args[] = $wpdb->prepare( "content = %s", $r['content'] );
1106
- }
1107
-
1108
- // Component
1109
- if ( ! empty( $r['component'] ) ) {
1110
- $where_args[] = $wpdb->prepare( "component = %s", $r['component'] );
1111
- }
1112
-
1113
- // Type
1114
- if ( ! empty( $r['type'] ) ) {
1115
- $where_args[] = $wpdb->prepare( "type = %s", $r['type'] );
1116
- }
1117
-
1118
- // Primary Link
1119
- if ( ! empty( $r['primary_link'] ) ) {
1120
- $where_args[] = $wpdb->prepare( "primary_link = %s", $r['primary_link'] );
1121
- }
1122
-
1123
- // Item ID
1124
- if ( ! empty( $r['item_id'] ) ) {
1125
- $where_args[] = $wpdb->prepare( "item_id = %d", $r['item_id'] );
1126
- }
1127
-
1128
- // Secondary item ID
1129
- if ( ! empty( $r['secondary_item_id'] ) ) {
1130
- $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $r['secondary_item_id'] );
1131
- }
1132
-
1133
- // Date Recorded
1134
- if ( ! empty( $r['date_recorded'] ) ) {
1135
- $where_args[] = $wpdb->prepare( "date_recorded = %s", $r['date_recorded'] );
1136
- }
1137
-
1138
- // Hidden sitewide
1139
- if ( ! empty( $r['hide_sitewide'] ) ) {
1140
- $where_args[] = $wpdb->prepare( "hide_sitewide = %d", $r['hide_sitewide'] );
1141
- }
1142
-
1143
- // Bail if no where arguments
1144
- if ( empty( $where_args ) ) {
1145
- return false;
1146
- }
1147
-
1148
- // Join the where arguments for querying
1149
- $where_sql = 'WHERE ' . join( ' AND ', $where_args );
1150
-
1151
- // Fetch all activities being deleted so we can perform more actions
1152
- $activities = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} {$where_sql}" );
1153
-
1154
- /**
1155
- * Action to allow intercepting activity items to be deleted.
1156
- *
1157
- * @since BuddyPress (2.3.0)
1158
- *
1159
- * @param array $activities Array of activities.
1160
- * @param array $r Array of parsed arguments.
1161
- */
1162
- do_action_ref_array( 'bp_activity_before_delete', array( $activities, $r ) );
1163
-
1164
- // Attempt to delete activities from the database
1165
- $deleted = $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" );
1166
-
1167
- // Bail if nothing was deleted
1168
- if ( empty( $deleted ) ) {
1169
- return false;
1170
- }
1171
-
1172
- /**
1173
- * Action to allow intercepting activity items just deleted.
1174
- *
1175
- * @since BuddyPress (2.3.0)
1176
- *
1177
- * @param array $activities Array of activities.
1178
- * @param array $r Array of parsed arguments.
1179
- */
1180
- do_action_ref_array( 'bp_activity_after_delete', array( $activities, $r ) );
1181
-
1182
- // Pluck the activity IDs out of the $activities array
1183
- $activity_ids = wp_parse_id_list( wp_list_pluck( $activities, 'id' ) );
1184
-
1185
- // Handle accompanying activity comments and meta deletion
1186
- if ( ! empty( $activity_ids ) ) {
1187
-
1188
- // Delete all activity meta entries for activity items
1189
- BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
1190
-
1191
- // Setup empty array for comments
1192
- $comment_ids = array();
1193
-
1194
- // Loop through activity ids and attempt to delete comments
1195
- foreach ( $activity_ids as $activity_id ) {
1196
-
1197
- // Attempt to delete comments
1198
- $comments = BP_Activity_Activity::delete( array(
1199
- 'type' => 'activity_comment',
1200
- 'item_id' => $activity_id
1201
- ) );
1202
-
1203
- // Merge IDs together
1204
- if ( ! empty( $comments ) ) {
1205
- $comment_ids = array_merge( $comment_ids, $comments );
1206
- }
1207
- }
1208
-
1209
- // Merge activity IDs with any deleted comment IDs
1210
- if ( ! empty( $comment_ids ) ) {
1211
- $activity_ids = array_unique( array_merge( $activity_ids, $comment_ids ) );
1212
- }
1213
- }
1214
-
1215
- return $activity_ids;
1216
- }
1217
-
1218
- /**
1219
- * Delete the comments associated with a set of activity items.
1220
- *
1221
- * This method is no longer used by BuddyPress, and it is recommended not to
1222
- * use it going forward, and use BP_Activity_Activity::delete() instead.
1223
- *
1224
- * @since BuddyPress (1.2.0)
1225
- * @deprecated BuddyPress (2.3.0)
1226
- *
1227
- * @param array $activity_ids Activity IDs whose comments should be deleted.
1228
- * @param bool $delete_meta Should we delete the activity meta items for these comments?
1229
- *
1230
- * @return bool True on success.
1231
- */
1232
- public static function delete_activity_item_comments( $activity_ids = array(), $delete_meta = true ) {
1233
- global $wpdb;
1234
-
1235
- $bp = buddypress();
1236
-
1237
- $delete_meta = (bool) $delete_meta;
1238
- $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
1239
-
1240
- if ( $delete_meta ) {
1241
- // Fetch the activity comment IDs for our deleted activity items
1242
- $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
1243
-
1244
- if ( ! empty( $activity_comment_ids ) ) {
1245
- self::delete_activity_meta_entries( $activity_comment_ids );
1246
- }
1247
- }
1248
-
1249
- return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
1250
- }
1251
-
1252
- /**
1253
- * Delete the meta entries associated with a set of activity items.
1254
- *
1255
- * @since BuddyPress (1.2.0)
1256
- *
1257
- * @param array $activity_ids Activity IDs whose meta should be deleted.
1258
- *
1259
- * @return bool True on success.
1260
- */
1261
- public static function delete_activity_meta_entries( $activity_ids = array() ) {
1262
- $activity_ids = wp_parse_id_list( $activity_ids );
1263
-
1264
- foreach ( $activity_ids as $activity_id ) {
1265
- bp_activity_delete_meta( $activity_id );
1266
- }
1267
-
1268
- return true;
1269
- }
1270
-
1271
- /**
1272
- * Append activity comments to their associated activity items.
1273
- *
1274
- * @since BuddyPress (1.2.0)
1275
- *
1276
- * @global wpdb $wpdb WordPress database object.
1277
- *
1278
- * @param array $activities Activities to fetch comments for.
1279
- * @param string $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
1280
- *
1281
- * @return array The updated activities with nested comments.
1282
- */
1283
- public static function append_comments( $activities, $spam = 'ham_only' ) {
1284
- $activity_comments = array();
1285
-
1286
- // Now fetch the activity comments and parse them into the correct position in the activities array.
1287
- foreach ( (array) $activities as $activity ) {
1288
- $top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0;
1289
- $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );
1290
- }
1291
-
1292
- // Merge the comments with the activity items
1293
- foreach ( (array) $activities as $key => $activity ) {
1294
- if ( isset( $activity_comments[$activity->id] ) ) {
1295
- $activities[$key]->children = $activity_comments[$activity->id];
1296
- }
1297
- }
1298
-
1299
- return $activities;
1300
- }
1301
-
1302
- /**
1303
- * Get activity comments that are associated with a specific activity ID.
1304
- *
1305
- * @since BuddyPress (1.2.0)
1306
- *
1307
- * @global wpdb $wpdb WordPress database object.
1308
- *
1309
- * @param int $activity_id Activity ID to fetch comments for.
1310
- * @param int $left Left-most node boundary.
1311
- * @param int $right Right-most node boundary.
1312
- * @param string $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
1313
- * @param int $top_level_parent_id Optional. The id of the root-level parent activity item.
1314
- *
1315
- * @return array The updated activities with nested comments.
1316
- */
1317
- public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
1318
- global $wpdb;
1319
-
1320
- if ( empty( $top_level_parent_id ) ) {
1321
- $top_level_parent_id = $activity_id;
1322
- }
1323
-
1324
- $comments = wp_cache_get( $activity_id, 'bp_activity_comments' );
1325
-
1326
- // We store the string 'none' to cache the fact that the
1327
- // activity item has no comments
1328
- if ( 'none' === $comments ) {
1329
- $comments = false;
1330
-
1331
- // A true cache miss
1332
- } elseif ( empty( $comments ) ) {
1333
-
1334
- $bp = buddypress();
1335
-
1336
- // Select the user's fullname with the query
1337
- if ( bp_is_active( 'xprofile' ) ) {
1338
- $fullname_select = ", pd.value as user_fullname";
1339
- $fullname_from = ", {$bp->profile->table_name_data} pd ";
1340
- $fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1";
1341
-
1342
- // Prevent debug errors
1343
- } else {
1344
- $fullname_select = $fullname_from = $fullname_where = '';
1345
- }
1346
-
1347
- // Don't retrieve activity comments marked as spam
1348
- if ( 'ham_only' == $spam ) {
1349
- $spam_sql = 'AND a.is_spam = 0';
1350
- } elseif ( 'spam_only' == $spam ) {
1351
- $spam_sql = 'AND a.is_spam = 1';
1352
- } else {
1353
- $spam_sql = '';
1354
- }
1355
-
1356
- // Legacy query - not recommended
1357
- $func_args = func_get_args();
1358
-
1359
- /**
1360
- * Filters if BuddyPress should use the legacy activity query.
1361
- *
1362
- * @since BuddyPress (2.0.0)
1363
- *
1364
- * @param bool $value Whether or not to use the legacy query.
1365
- * @param BP_Activity_Activity $value Magic method referring to currently called method.
1366
- * @param array $func_args Array of the method's argument list.
1367
- */
1368
- if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $func_args ) ) {
1369
-
1370
- /**
1371
- * Filters the MySQL prepared statement for the legacy activity query.
1372
- *
1373
- * @since BuddyPress (1.5.0)
1374
- *
1375
- * @param string $value Prepared statement for the activity query.
1376
- * @param int $activity_id Activity ID to fetch comments for.
1377
- * @param int $left Left-most node boundary.
1378
- * @param int $right Right-most node boundary.
1379
- * @param string $spam_sql SQL Statement portion to differentiate between ham or spam.
1380
- */
1381
- $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d AND a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right ), $activity_id, $left, $right, $spam_sql );
1382
-
1383
- $descendants = $wpdb->get_results( $sql );
1384
-
1385
- // We use the mptt BETWEEN clause to limit returned
1386
- // descendants to the correct part of the tree.
1387
- } else {
1388
- $sql = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} a WHERE a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d and a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right );
1389
-
1390
- $descendant_ids = $wpdb->get_col( $sql );
1391
- $descendants = self::get_activity_data( $descendant_ids );
1392
- $descendants = self::append_user_fullnames( $descendants );
1393
- }
1394
-
1395
- $ref = array();
1396
-
1397
- // Loop descendants and build an assoc array
1398
- foreach ( (array) $descendants as $d ) {
1399
- $d->children = array();
1400
-
1401
- // If we have a reference on the parent
1402
- if ( isset( $ref[ $d->secondary_item_id ] ) ) {
1403
- $ref[ $d->secondary_item_id ]->children[ $d->id ] = $d;
1404
- $ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ];
1405
-
1406
- // If we don't have a reference on the parent, put in the root level
1407
- } else {
1408
- $comments[ $d->id ] = $d;
1409
- $ref[ $d->id ] =& $comments[ $d->id ];
1410
- }
1411
- }
1412
-
1413
- // Calculate depth for each item
1414
- foreach ( $ref as &$r ) {
1415
- $depth = 1;
1416
- $parent_id = $r->secondary_item_id;
1417
- while ( $parent_id !== $r->item_id ) {
1418
- $depth++;
1419
-
1420
- // When display_comments=stream, the
1421
- // parent comment may not be part of
1422
- // the returned results, so we manually
1423
- // fetch it
1424
- if ( empty( $ref[ $parent_id ] ) ) {
1425
- $direct_parent = new BP_Activity_Activity( $parent_id );
1426
- if ( isset( $direct_parent->secondary_item_id ) ) {
1427
- $parent_id = $direct_parent->secondary_item_id;
1428
- } else {
1429
- // Something went wrong
1430
- // Short-circuit the
1431
- // depth calculation
1432
- $parent_id = $r->item_id;
1433
- }
1434
- } else {
1435
- $parent_id = $ref[ $parent_id ]->secondary_item_id;
1436
- }
1437
- }
1438
- $r->depth = $depth;
1439
- }
1440
-
1441
- // If we cache a value of false, it'll count as a cache
1442
- // miss the next time the activity comments are fetched.
1443
- // Storing the string 'none' is a hack workaround to
1444
- // avoid unnecessary queries.
1445
- if ( false === $comments ) {
1446
- $cache_value = 'none';
1447
- } else {
1448
- $cache_value = $comments;
1449
- }
1450
-
1451
- wp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' );
1452
- }
1453
-
1454
- return $comments;
1455
- }
1456
-
1457
- /**
1458
- * Rebuild nested comment tree under an activity or activity comment.
1459
- *
1460
- * @since BuddyPress (1.2.0)
1461
- *
1462
- * @global wpdb $wpdb WordPress database object.
1463
- *
1464
- * @param int $parent_id ID of an activity or activity comment.
1465
- * @param int $left Node boundary start for activity or activity comment.
1466
- * @return int Right Node boundary of activity or activity comment.
1467
- */
1468
- public static function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
1469
- global $wpdb;
1470
-
1471
- $bp = buddypress();
1472
-
1473
- // The right value of this node is the left value + 1
1474
- $right = intval( $left + 1 );
1475
-
1476
- // Get all descendants of this node
1477
- $comments = BP_Activity_Activity::get_child_comments( $parent_id );
1478
- $descendants = wp_list_pluck( $comments, 'id' );
1479
-
1480
- // Loop the descendants and recalculate the left and right values
1481
- foreach ( (array) $descendants as $descendant_id ) {
1482
- $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );
1483
- }
1484
-
1485
- // We've got the left value, and now that we've processed the children
1486
- // of this node we also know the right value
1487
- if ( 1 === $left ) {
1488
- $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
1489
- } else {
1490
- $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id ) );
1491
- }
1492
-
1493
- // Return the right value of this node + 1
1494
- return intval( $right + 1 );
1495
- }
1496
-
1497
- /**
1498
- * Get child comments of an activity or activity comment.
1499
- *
1500
- * @since BuddyPress (1.2.0)
1501
- *
1502
- * @global wpdb $wpdb WordPress database object.
1503
- *
1504
- * @param int $parent_id ID of an activity or activity comment.
1505
- *
1506
- * @return object Numerically indexed array of child comments.
1507
- */
1508
- public static function get_child_comments( $parent_id ) {
1509
- global $wpdb;
1510
-
1511
- $bp = buddypress();
1512
-
1513
- return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
1514
- }
1515
-
1516
- /**
1517
- * Get a list of components that have recorded activity associated with them.
1518
- *
1519
- * @param bool $skip_last_activity If true, components will not be
1520
- * included if the only activity type associated with them is
1521
- * 'last_activity'. (Since 2.0.0, 'last_activity' is stored in
1522
- * the activity table, but these items are not full-fledged
1523
- * activity items.) Default: true.
1524
- *
1525
- * @return array List of component names.
1526
- */
1527
- public static function get_recorded_components( $skip_last_activity = true ) {
1528
- global $wpdb;
1529
-
1530
- $bp = buddypress();
1531
-
1532
- if ( true === $skip_last_activity ) {
1533
- $components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} WHERE action != '' AND action != 'last_activity' ORDER BY component ASC" );
1534
- } else {
1535
- $components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
1536
- }
1537
-
1538
- return $components;
1539
- }
1540
-
1541
- /**
1542
- * Get sitewide activity items for use in an RSS feed.
1543
- *
1544
- * @param int $limit Optional. Number of items to fetch. Default: 35.
1545
- *
1546
- * @return array $activity_feed List of activity items, with RSS data added.
1547
- */
1548
- public static function get_sitewide_items_for_feed( $limit = 35 ) {
1549
- $activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
1550
- $activity_feed = array();
1551
-
1552
- for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
1553
- $title = explode( '<span', $activities[$i]['content'] );
1554
- $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
1555
- $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
1556
- $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
1557
- $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
1558
- }
1559
-
1560
- return $activity_feed;
1561
- }
1562
-
1563
- /**
1564
- * Create SQL IN clause for filter queries.
1565
- *
1566
- * @since BuddyPress (1.5.0)
1567
- *
1568
- * @see BP_Activity_Activity::get_filter_sql()
1569
- *
1570
- * @param string $field The database field.
1571
- * @param array|bool $items The values for the IN clause, or false when none are found.
1572
- *
1573
- * @return string|bool.
1574
- */
1575
- public static function get_in_operator_sql( $field, $items ) {
1576
- global $wpdb;
1577
-
1578
- // split items at the comma
1579
- if ( ! is_array( $items ) ) {
1580
- $items = explode( ',', $items );
1581
- }
1582
-
1583
- // array of prepared integers or quoted strings
1584
- $items_prepared = array();
1585
-
1586
- // clean up and format each item
1587
- foreach ( $items as $item ) {
1588
- // clean up the string
1589
- $item = trim( $item );
1590
- // pass everything through prepare for security and to safely quote strings
1591
- $items_prepared[] = ( is_numeric( $item ) ) ? $wpdb->prepare( '%d', $item ) : $wpdb->prepare( '%s', $item );
1592
- }
1593
-
1594
- // build IN operator sql syntax
1595
- if ( count( $items_prepared ) )
1596
- return sprintf( '%s IN ( %s )', trim( $field ), implode( ',', $items_prepared ) );
1597
- else
1598
- return false;
1599
- }
1600
-
1601
- /**
1602
- * Create filter SQL clauses.
1603
- *
1604
- * @since BuddyPress (1.5.0)
1605
- *
1606
- * @param array $filter_array {
1607
- * Fields and values to filter by.
1608
- *
1609
- * @type array|string|int $user_id User ID(s).
1610
- * @type array|string $object Corresponds to the 'component'
1611
- * column in the database.
1612
- * @type array|string $action Corresponds to the 'type' column
1613
- * in the database.
1614
- * @type array|string|int $primary_id Corresponds to the 'item_id'
1615
- * column in the database.
1616
- * @type array|string|int $secondary_id Corresponds to the
1617
- * 'secondary_item_id' column in the database.
1618
- * @type int $offset Return only those items with an ID greater
1619
- * than the offset value.
1620
- * @type string $since Return only those items that have a
1621
- * date_recorded value greater than a
1622
- * given MySQL-formatted date.
1623
- * }
1624
- *
1625
- * @return string The filter clause, for use in a SQL query.
1626
- */
1627
- public static function get_filter_sql( $filter_array ) {
1628
-
1629
- $filter_sql = array();
1630
-
1631
- if ( !empty( $filter_array['user_id'] ) ) {
1632
- $user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] );
1633
- if ( !empty( $user_sql ) )
1634
- $filter_sql[] = $user_sql;
1635
- }
1636
-
1637
- if ( !empty( $filter_array['object'] ) ) {
1638
- $object_sql = BP_Activity_Activity::get_in_operator_sql( 'a.component', $filter_array['object'] );
1639
- if ( !empty( $object_sql ) )
1640
- $filter_sql[] = $object_sql;
1641
- }
1642
-
1643
- if ( !empty( $filter_array['action'] ) ) {
1644
- $action_sql = BP_Activity_Activity::get_in_operator_sql( 'a.type', $filter_array['action'] );
1645
- if ( ! empty( $action_sql ) )
1646
- $filter_sql[] = $action_sql;
1647
- }
1648
-
1649
- if ( !empty( $filter_array['primary_id'] ) ) {
1650
- $pid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.item_id', $filter_array['primary_id'] );
1651
- if ( !empty( $pid_sql ) )
1652
- $filter_sql[] = $pid_sql;
1653
- }
1654
-
1655
- if ( !empty( $filter_array['secondary_id'] ) ) {
1656
- $sid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.secondary_item_id', $filter_array['secondary_id'] );
1657
- if ( !empty( $sid_sql ) )
1658
- $filter_sql[] = $sid_sql;
1659
- }
1660
-
1661
- if ( ! empty( $filter_array['offset'] ) ) {
1662
- $sid_sql = absint( $filter_array['offset'] );
1663
- $filter_sql[] = "a.id >= {$sid_sql}";
1664
- }
1665
-
1666
- if ( ! empty( $filter_array['since'] ) ) {
1667
- // Validate that this is a proper Y-m-d H:i:s date
1668
- // Trick: parse to UNIX date then translate back
1669
- $translated_date = date( 'Y-m-d H:i:s', strtotime( $filter_array['since'] ) );
1670
- if ( $translated_date === $filter_array['since'] ) {
1671
- $filter_sql[] = "a.date_recorded > '{$translated_date}'";
1672
- }
1673
- }
1674
-
1675
- if ( empty( $filter_sql ) )
1676
- return false;
1677
-
1678
- return join( ' AND ', $filter_sql );
1679
- }
1680
-
1681
- /**
1682
- * Get the date/time of last recorded activity.
1683
- *
1684
- * @since BuddyPress (1.2.0)
1685
- *
1686
- * @return string ISO timestamp.
1687
- */
1688
- public static function get_last_updated() {
1689
- global $wpdb;
1690
-
1691
- $bp = buddypress();
1692
-
1693
- return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
1694
- }
1695
-
1696
- /**
1697
- * Get favorite count for a given user.
1698
- *
1699
- * @since BuddyPress (1.2.0)
1700
- *
1701
- * @param int $user_id The ID of the user whose favorites you're counting.
1702
- *
1703
- * @return int $value A count of the user's favorites.
1704
- */
1705
- public static function total_favorite_count( $user_id ) {
1706
-
1707
- // Get activities from user meta
1708
- $favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
1709
- if ( ! empty( $favorite_activity_entries ) ) {
1710
- return count( maybe_unserialize( $favorite_activity_entries ) );
1711
- }
1712
-
1713
- // No favorites
1714
- return 0;
1715
- }
1716
-
1717
- /**
1718
- * Check whether an activity item exists with a given string content.
1719
- *
1720
- * @param string $content The content to filter by.
1721
- *
1722
- * @return int|bool The ID of the first matching item if found, otherwise false.
1723
- */
1724
- public static function check_exists_by_content( $content ) {
1725
- global $wpdb;
1726
-
1727
- $bp = buddypress();
1728
-
1729
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
1730
- }
1731
-
1732
- /**
1733
- * Hide all activity for a given user.
1734
- *
1735
- * @param int $user_id The ID of the user whose activity you want to mark hidden.
1736
- *
1737
- * @return mixed
1738
- */
1739
- public static function hide_all_for_user( $user_id ) {
1740
- global $wpdb;
1741
-
1742
- $bp = buddypress();
1743
-
1744
- return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
1745
- }
1746
-
1747
- /**
1748
- * PHP-agnostic version of {@link array_replace_recursive()}.
1749
- *
1750
- * array_replace_recursive() is a PHP 5.3 function. BuddyPress (and
1751
- * WordPress) currently supports down to PHP 5.2, so this method is a workaround
1752
- * for PHP 5.2.
1753
- *
1754
- * Note: array_replace_recursive() supports infinite arguments, but for our use-
1755
- * case, we only need to support two arguments.
1756
- *
1757
- * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
1758
- *
1759
- * @since BuddyPress (2.2.0)
1760
- *
1761
- * @see http://php.net/manual/en/function.array-replace-recursive.php#109390
1762
- *
1763
- * @param array $base Array with keys needing to be replaced.
1764
- * @param array $replacements Array with the replaced keys.
1765
- *
1766
- * @return array
1767
- */
1768
- protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
1769
- if ( function_exists( 'array_replace_recursive' ) ) {
1770
- return array_replace_recursive( $base, $replacements );
1771
- }
1772
-
1773
- // PHP 5.2-compatible version
1774
- // http://php.net/manual/en/function.array-replace-recursive.php#109390
1775
- foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
1776
- $bref_stack = array( &$base );
1777
- $head_stack = array( $replacements );
1778
-
1779
- do {
1780
- end( $bref_stack );
1781
-
1782
- $bref = &$bref_stack[ key( $bref_stack ) ];
1783
- $head = array_pop( $head_stack );
1784
-
1785
- unset( $bref_stack[ key($bref_stack) ] );
1786
-
1787
- foreach ( array_keys( $head ) as $key ) {
1788
- if ( isset( $key, $bref ) && is_array( $bref[$key] ) && is_array( $head[$key] ) ) {
1789
- $bref_stack[] = &$bref[ $key ];
1790
- $head_stack[] = $head[ $key ];
1791
- } else {
1792
- $bref[ $key ] = $head[ $key ];
1793
- }
1794
- }
1795
- } while( count( $head_stack ) );
1796
- }
1797
-
1798
- return $base;
1799
- }
1800
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/classes/class-bp-activity-feed.php DELETED
@@ -1,446 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Activity Classes
4
- *
5
- * @package BuddyPress
6
- * @subpackage Activity
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * Create a RSS feed using the activity component.
14
- *
15
- * You should only construct a new feed when you've validated that you're on
16
- * the appropriate screen.
17
- *
18
- * See {@link bp_activity_action_sitewide_feed()} as an example.
19
- *
20
- * @param array $args {
21
- * @type string $id Required. Internal id for the feed; should be alphanumeric only.
22
- * @type string $title Optional. RSS feed title.
23
- * @type string $link Optional. Relevant link for the RSS feed.
24
- * @type string $description Optional. RSS feed description.
25
- * @type string $ttl Optional. Time-to-live. (see inline doc in constructor)
26
- * @type string $update_period Optional. Part of the syndication module.
27
- * (see inline doc in constructor for more info)
28
- * @type string $update_frequency Optional. Part of the syndication module.
29
- * (see inline doc in constructor for more info)
30
- * @type string $max Optional. Number of feed items to display.
31
- * @type array $activity_args Optional. Arguments passed to {@link bp_has_activities()}
32
- * }
33
- * @since BuddyPress (1.8.0)
34
- */
35
- class BP_Activity_Feed {
36
-
37
- /**
38
- * Holds our custom class properties.
39
- *
40
- * These variables are stored in a protected array that is magically
41
- * updated using PHP 5.2+ methods.
42
- *
43
- * @see BP_Feed::__construct() This is where $data is added.
44
- * @var array
45
- */
46
- protected $data;
47
-
48
- /**
49
- * Magic method for checking the existence of a certain data variable.
50
- *
51
- * @param string $key
52
- *
53
- * @return bool Whether or not data variable exists.
54
- */
55
- public function __isset( $key ) { return isset( $this->data[$key] ); }
56
-
57
- /**
58
- * Magic method for getting a certain data variable.
59
- *
60
- * @param string $key
61
- *
62
- * @return mixed Data in variable if available or null.
63
- */
64
- public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
65
-
66
- /**
67
- * Constructor.
68
- *
69
- * @param array $args Optional.
70
- */
71
- public function __construct( $args = array() ) {
72
-
73
- /**
74
- * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
75
- *
76
- * @since BuddyPress (1.8.0)
77
- *
78
- * @param bool true Default true aka feeds are enabled.
79
- */
80
- if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
81
- global $wp_query;
82
-
83
- // set feed flag to false
84
- $wp_query->is_feed = false;
85
-
86
- return false;
87
- }
88
-
89
- // Setup data
90
- $this->data = wp_parse_args( $args, array(
91
- // Internal identifier for the RSS feed - should be alphanumeric only
92
- 'id' => '',
93
-
94
- // RSS title - should be plain-text
95
- 'title' => '',
96
-
97
- // relevant link for the RSS feed
98
- 'link' => '',
99
-
100
- // RSS description - should be plain-text
101
- 'description' => '',
102
-
103
- // Time-to-live - number of minutes to cache the data before an aggregator
104
- // requests it again. This is only acknowledged if the RSS client supports it
105
- //
106
- // See: http://www.rssboard.org/rss-profile#element-channel-ttl
107
- // http://www.kbcafe.com/rss/rssfeedstate.html#ttl
108
- 'ttl' => '30',
109
-
110
- // Syndication module - similar to ttl, but not really supported by RSS
111
- // clients
112
- //
113
- // See: http://web.resource.org/rss/1.0/modules/syndication/#description
114
- // http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule
115
- 'update_period' => 'hourly',
116
- 'update_frequency' => 2,
117
-
118
- // Number of items to display
119
- 'max' => 50,
120
-
121
- // Activity arguments passed to bp_has_activities()
122
- 'activity_args' => array()
123
- ) );
124
-
125
- /**
126
- * Fires before the feed is setup so plugins can modify.
127
- *
128
- * @since BuddyPress (1.8.0)
129
- *
130
- * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
131
- */
132
- do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
133
-
134
- // Setup class properties
135
- $this->setup_properties();
136
-
137
- // Check if id is valid
138
- if ( empty( $this->id ) ) {
139
- _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
140
- return false;
141
- }
142
-
143
- /**
144
- * Fires after the feed is setup so plugins can modify.
145
- *
146
- * @since BuddyPress (1.8.0)
147
- *
148
- * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
149
- */
150
- do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
151
-
152
- // Setup feed hooks
153
- $this->setup_hooks();
154
-
155
- // Output the feed
156
- $this->output();
157
-
158
- // Kill the rest of the output
159
- die();
160
- }
161
-
162
- /** SETUP ****************************************************************/
163
-
164
- /**
165
- * Setup and validate the class properties.
166
- *
167
- * @access protected
168
- */
169
- protected function setup_properties() {
170
- $this->id = sanitize_title( $this->id );
171
- $this->title = strip_tags( $this->title );
172
- $this->link = esc_url_raw( $this->link );
173
- $this->description = strip_tags( $this->description );
174
- $this->ttl = (int) $this->ttl;
175
- $this->update_period = strip_tags( $this->update_period );
176
- $this->update_frequency = (int) $this->update_frequency;
177
-
178
- $this->activity_args = wp_parse_args( $this->activity_args, array(
179
- 'max' => $this->max,
180
- 'per_page' => $this->max,
181
- 'display_comments' => 'stream'
182
- ) );
183
-
184
- }
185
-
186
- /**
187
- * Setup some hooks that are used in the feed.
188
- *
189
- * Currently, these hooks are used to maintain backwards compatibility with
190
- * the RSS feeds previous to BP 1.8.
191
- *
192
- * @access protected
193
- */
194
- protected function setup_hooks() {
195
- add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
196
- add_action( 'bp_activity_feed_channel_elements', array( $this, 'backpat_channel_elements' ) );
197
- add_action( 'bp_activity_feed_item_elements', array( $this, 'backpat_item_elements' ) );
198
- }
199
-
200
- /** BACKPAT HOOKS ********************************************************/
201
-
202
- /**
203
- * Fire a hook to ensure backward compatibility for RSS attributes.
204
- */
205
- public function backpat_rss_attributes() {
206
-
207
- /**
208
- * Fires inside backpat_rss_attributes method for backwards compatibility related to RSS attributes.
209
- *
210
- * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
211
- *
212
- * @since BuddyPress (1.0.0)
213
- */
214
- do_action( 'bp_activity_' . $this->id . '_feed' );
215
- }
216
-
217
- /**
218
- * Fire a hook to ensure backward compatibility for channel elements.
219
- */
220
- public function backpat_channel_elements() {
221
-
222
- /**
223
- * Fires inside backpat_channel_elements method for backwards compatibility related to RSS channel elements.
224
- *
225
- * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
226
- *
227
- * @since BuddyPress (1.0.0)
228
- */
229
- do_action( 'bp_activity_' . $this->id . '_feed_head' );
230
- }
231
-
232
- /**
233
- * Fire a hook to ensure backward compatibility for item elements.
234
- */
235
- public function backpat_item_elements() {
236
- switch ( $this->id ) {
237
-
238
- // sitewide and friends feeds use the 'personal' hook
239
- case 'sitewide' :
240
- case 'friends' :
241
- $id = 'personal';
242
-
243
- break;
244
-
245
- default :
246
- $id = $this->id;
247
-
248
- break;
249
- }
250
-
251
- /**
252
- * Fires inside backpat_item_elements method for backwards compatibility related to RSS item elements.
253
- *
254
- * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
255
- *
256
- * @since BuddyPress (1.0.0)
257
- */
258
- do_action( 'bp_activity_' . $id . '_feed_item' );
259
- }
260
-
261
- /** HELPERS **************************************************************/
262
-
263
- /**
264
- * Output the feed's item content.
265
- *
266
- * @access protected
267
- */
268
- protected function feed_content() {
269
- bp_activity_content_body();
270
-
271
- switch ( $this->id ) {
272
-
273
- // also output parent activity item if we're on a specific feed
274
- case 'favorites' :
275
- case 'friends' :
276
- case 'mentions' :
277
- case 'personal' :
278
-
279
- if ( 'activity_comment' == bp_get_activity_action_name() ) :
280
- ?>
281
- <strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
282
- <?php bp_activity_parent_content() ?>
283
- <?php
284
- endif;
285
-
286
- break;
287
- }
288
- }
289
-
290
- /**
291
- * Sets various HTTP headers related to Content-Type and browser caching.
292
- *
293
- * Most of this class method is derived from {@link WP::send_headers()}.
294
- *
295
- * @since BuddyPress (1.9.0)
296
- *
297
- * @access protected
298
- */
299
- protected function http_headers() {
300
- // set up some additional headers if not on a directory page
301
- // this is done b/c BP uses pseudo-pages
302
- if ( ! bp_is_directory() ) {
303
- global $wp_query;
304
-
305
- $wp_query->is_404 = false;
306
- status_header( 200 );
307
- }
308
-
309
- // Set content-type
310
- @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
311
- send_nosniff_header();
312
-
313
- // Cache-related variables
314
- $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
315
- $modified_timestamp = strtotime( $last_modified );
316
- $etag = md5( $last_modified );
317
-
318
- // Set cache-related headers
319
- @header( 'Last-Modified: ' . $last_modified );
320
- @header( 'Pragma: no-cache' );
321
- @header( 'ETag: ' . '"' . $etag . '"' );
322
-
323
- // First commit of BuddyPress! (Easter egg)
324
- @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT');
325
-
326
- // Get ETag from supported user agents
327
- if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
328
- $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
329
-
330
- // Remove quotes from ETag
331
- $client_etag = trim( $client_etag, '"' );
332
-
333
- // Strip suffixes from ETag if they exist (eg. "-gzip")
334
- $etag_suffix_pos = strpos( $client_etag, '-' );
335
- if ( ! empty( $etag_suffix_pos ) ) {
336
- $client_etag = substr( $client_etag, 0, $etag_suffix_pos );
337
- }
338
-
339
- // No ETag found
340
- } else {
341
- $client_etag = false;
342
- }
343
-
344
- // Get client last modified timestamp from supported user agents
345
- $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
346
- $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
347
-
348
- // Set 304 status if feed hasn't been updated since last fetch
349
- if ( ( $client_last_modified && $client_etag ) ?
350
- ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) :
351
- ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) {
352
- $status = 304;
353
- } else {
354
- $status = false;
355
- }
356
-
357
- // If feed hasn't changed as reported by the user agent, set 304 status header
358
- if ( ! empty( $status ) ) {
359
- status_header( $status );
360
-
361
- // cached response, so stop now!
362
- if ( $status == 304 ) {
363
- exit();
364
- }
365
- }
366
- }
367
-
368
- /** OUTPUT ***************************************************************/
369
-
370
- /**
371
- * Output the RSS feed.
372
- *
373
- * @access protected
374
- */
375
- protected function output() {
376
- $this->http_headers();
377
- echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>';
378
- ?>
379
-
380
- <rss version="2.0"
381
- xmlns:content="http://purl.org/rss/1.0/modules/content/"
382
- xmlns:atom="http://www.w3.org/2005/Atom"
383
- xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
384
- xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
385
- <?php
386
-
387
- /**
388
- * Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
389
- *
390
- * @since BuddyPress (1.8.0)
391
- */
392
- do_action( 'bp_activity_feed_rss_attributes' ); ?>
393
- >
394
-
395
- <channel>
396
- <title><?php echo $this->title; ?></title>
397
- <link><?php echo $this->link; ?></link>
398
- <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
399
- <description><?php echo $this->description ?></description>
400
- <lastBuildDate><?php echo mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false ); ?></lastBuildDate>
401
- <generator>https://buddypress.org/?v=<?php bp_version(); ?></generator>
402
- <language><?php bloginfo_rss( 'language' ); ?></language>
403
- <ttl><?php echo $this->ttl; ?></ttl>
404
- <sy:updatePeriod><?php echo $this->update_period; ?></sy:updatePeriod>
405
- <sy:updateFrequency><?php echo $this->update_frequency; ?></sy:updateFrequency>
406
- <?php
407
-
408
- /**
409
- * Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
410
- *
411
- * @since BuddyPress (1.8.0)
412
- */
413
- do_action( 'bp_activity_feed_channel_elements' ); ?>
414
-
415
- <?php if ( bp_has_activities( $this->activity_args ) ) : ?>
416
- <?php while ( bp_activities() ) : bp_the_activity(); ?>
417
- <item>
418
- <guid isPermaLink="false"><?php bp_activity_feed_item_guid(); ?></guid>
419
- <title><?php echo stripslashes( bp_get_activity_feed_item_title() ); ?></title>
420
- <link><?php bp_activity_thread_permalink() ?></link>
421
- <pubDate><?php echo mysql2date( 'D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false ); ?></pubDate>
422
-
423
- <?php if ( bp_get_activity_feed_item_description() ) : ?>
424
- <content:encoded><![CDATA[<?php $this->feed_content(); ?>]]></content:encoded>
425
- <?php endif; ?>
426
-
427
- <?php if ( bp_activity_can_comment() ) : ?>
428
- <slash:comments><?php bp_activity_comment_count(); ?></slash:comments>
429
- <?php endif; ?>
430
-
431
- <?php
432
-
433
- /**
434
- * Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
435
- *
436
- * @since BuddyPress (1.8.0)
437
- */
438
- do_action( 'bp_activity_feed_item_elements' ); ?>
439
- </item>
440
- <?php endwhile; ?>
441
-
442
- <?php endif; ?>
443
- </channel>
444
- </rss><?php
445
- }
446
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/classes/class-bp-activity-query.php DELETED
@@ -1,258 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Activity Classes
4
- *
5
- * @package BuddyPress
6
- * @subpackage Activity
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * Class for generating the WHERE SQL clause for advanced activity fetching.
14
- *
15
- * This is notably used in {@link BP_Activity_Activity::get()} with the
16
- * 'filter_query' parameter.
17
- *
18
- * @since BuddyPress (2.2.0)
19
- */
20
- class BP_Activity_Query extends BP_Recursive_Query {
21
- /**
22
- * Array of activity queries.
23
- *
24
- * See {@see BP_Activity_Query::__construct()} for information on query arguments.
25
- *
26
- * @since BuddyPress (2.2.0)
27
- * @access public
28
- * @var array
29
- */
30
- public $queries = array();
31
-
32
- /**
33
- * Table alias.
34
- *
35
- * @since BuddyPress (2.2.0)
36
- * @access public
37
- * @var string
38
- */
39
- public $table_alias = '';
40
-
41
- /**
42
- * Supported DB columns.
43
- *
44
- * See the 'wp_bp_activity' DB table schema.
45
- *
46
- * @since BuddyPress (2.2.0)
47
- * @access public
48
- * @var array
49
- */
50
- public $db_columns = array(
51
- 'id', 'user_id', 'component', 'type', 'action', 'content',
52
- 'item_id', 'secondary_item_id', 'hide_sitewide', 'is_spam',
53
- );
54
-
55
- /**
56
- * Constructor.
57
- *
58
- * @since BuddyPress (2.2.0)
59
- *
60
- * @param array $query {
61
- * Array of query clauses.
62
- *
63
- * @type array {
64
- * @type string $column Required. The column to query against. Basically, any DB column in the main
65
- * 'wp_bp_activity' table.
66
- * @type string $value Required. Value to filter by.
67
- * @type string $compare Optional. The comparison operator. Default '='.
68
- * Accepts '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'LIKE',
69
- * 'NOT LIKE', BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', 'RLIKE'.
70
- * @type string $relation Optional. The boolean relationship between the activity queries.
71
- * Accepts 'OR', 'AND'. Default 'AND'.
72
- * @type array {
73
- * Optional. Another fully-formed activity query. See parameters above.
74
- * }
75
- * }
76
- * }
77
- */
78
- public function __construct( $query = array() ) {
79
- if ( ! is_array( $query ) ) {
80
- return;
81
- }
82
-
83
- $this->queries = $this->sanitize_query( $query );
84
- }
85
-
86
- /**
87
- * Generates WHERE SQL clause to be appended to a main query.
88
- *
89
- * @since BuddyPress (2.2.0)
90
- * @access public
91
- *
92
- * @param string $alias An existing table alias that is compatible with the current query clause.
93
- * Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
94
- *
95
- * @return string SQL fragment to append to the main WHERE clause.
96
- */
97
- public function get_sql( $alias = 'a' ) {
98
- if ( ! empty( $alias ) ) {
99
- $this->table_alias = sanitize_title( $alias );
100
- }
101
-
102
- $sql = $this->get_sql_clauses();
103
-
104
- // we only need the 'where' clause
105
- //
106
- // also trim trailing "AND" clause from parent BP_Recursive_Query class
107
- // since it's not necessary for our needs
108
- return preg_replace( '/^\sAND/', '', $sql['where'] );
109
- }
110
-
111
- /**
112
- * Generate WHERE clauses for a first-order clause.
113
- *
114
- * @since BuddyPress (2.2.0)
115
- * @access protected
116
- *
117
- * @param array $clause Array of arguments belonging to the clause.
118
- * @param array $parent_query Parent query to which the clause belongs.
119
- *
120
- * @return array {
121
- * @type array $where Array of subclauses for the WHERE statement.
122
- * @type array $join Empty array. Not used.
123
- * }
124
- */
125
- protected function get_sql_for_clause( $clause, $parent_query ) {
126
- global $wpdb;
127
-
128
- $sql_chunks = array(
129
- 'where' => array(),
130
- 'join' => array(),
131
- );
132
-
133
- $column = isset( $clause['column'] ) ? $this->validate_column( $clause['column'] ) : '';
134
- $value = isset( $clause['value'] ) ? $clause['value'] : '';
135
- if ( empty( $column ) || ! isset( $clause['value'] ) ) {
136
- return $sql_chunks;
137
- }
138
-
139
- if ( isset( $clause['compare'] ) ) {
140
- $clause['compare'] = strtoupper( $clause['compare'] );
141
- } else {
142
- $clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
143
- }
144
-
145
- // default 'compare' to '=' if no valid operator is found
146
- if ( ! in_array( $clause['compare'], array(
147
- '=', '!=', '>', '>=', '<', '<=',
148
- 'LIKE', 'NOT LIKE',
149
- 'IN', 'NOT IN',
150
- 'BETWEEN', 'NOT BETWEEN',
151
- 'REGEXP', 'NOT REGEXP', 'RLIKE'
152
- ) ) ) {
153
- $clause['compare'] = '=';
154
- }
155
-
156
- $compare = $clause['compare'];
157
-
158
- $alias = ! empty( $this->table_alias ) ? "{$this->table_alias}." : '';
159
-
160
- // Next, Build the WHERE clause.
161
- $where = '';
162
-
163
- // value.
164
- if ( isset( $clause['value'] ) ) {
165
- if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
166
- if ( ! is_array( $value ) ) {
167
- $value = preg_split( '/[,\s]+/', $value );
168
- }
169
- }
170
-
171
- // tinyint
172
- if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
173
- $sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
174
-
175
- } else {
176
- switch ( $compare ) {
177
- // IN uses different syntax
178
- case 'IN' :
179
- case 'NOT IN' :
180
- $in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value );
181
-
182
- // 'NOT IN' operator is as easy as a string replace!
183
- if ( 'NOT IN' === $compare ) {
184
- $in_sql = str_replace( 'IN', 'NOT IN', $in_sql );
185
- }
186
-
187
- $sql_chunks['where'][] = $in_sql;
188
- break;
189
-
190
- case 'BETWEEN' :
191
- case 'NOT BETWEEN' :
192
- $value = array_slice( $value, 0, 2 );
193
- $where = $wpdb->prepare( '%s AND %s', $value );
194
- break;
195
-
196
- case 'LIKE' :
197
- case 'NOT LIKE' :
198
- $value = '%' . bp_esc_like( $value ) . '%';
199
- $where = $wpdb->prepare( '%s', $value );
200
- break;
201
-
202
- default :
203
- $where = $wpdb->prepare( '%s', $value );
204
- break;
205
-
206
- }
207
- }
208
-
209
- if ( $where ) {
210
- $sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}";
211
- }
212
- }
213
-
214
- /*
215
- * Multiple WHERE clauses should be joined in parentheses.
216
- */
217
- if ( 1 < count( $sql_chunks['where'] ) ) {
218
- $sql_chunks['where'] = array( '( ' . implode( ' AND ', $sql_chunks['where'] ) . ' )' );
219
- }
220
-
221
- return $sql_chunks;
222
- }
223
-
224
- /**
225
- * Determine whether a clause is first-order.
226
- *
227
- * @since BuddyPress (2.2.0)
228
- * @access protected
229
- *
230
- * @param array $query Clause to check.
231
- *
232
- * @return bool
233
- */
234
- protected function is_first_order_clause( $query ) {
235
- return isset( $query['column'] ) || isset( $query['value'] );
236
- }
237
-
238
- /**
239
- * Validates a column name parameter.
240
- *
241
- * Column names are checked against a whitelist of known tables.
242
- * See {@link BP_Activity_Query::db_tables}.
243
- *
244
- * @since BuddyPress (2.2.0)
245
- * @access public
246
- *
247
- * @param string $column The user-supplied column name.
248
- *
249
- * @return string A validated column name value.
250
- */
251
- public function validate_column( $column = '' ) {
252
- if ( in_array( $column, $this->db_columns ) ) {
253
- return $column;
254
- } else {
255
- return '';
256
- }
257
- }
258
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/js/mentions.js CHANGED
@@ -1,18 +1,7 @@
1
- /* global bp */
2
-
3
- window.bp = window.bp || {};
4
-
5
- ( function( bp, $, undefined ) {
6
  var mentionsQueryCache = [],
7
  mentionsItem;
8
 
9
- bp.mentions = bp.mentions || {};
10
- bp.mentions.users = window.bp.mentions.users || [];
11
-
12
- if ( typeof window.BP_Suggestions === 'object' ) {
13
- bp.mentions.users = window.BP_Suggestions.friends || bp.mentions.users;
14
- }
15
-
16
  /**
17
  * Adds BuddyPress @mentions to form inputs.
18
  *
@@ -239,17 +228,34 @@ window.bp = window.bp || {};
239
  };
240
 
241
  $( document ).ready(function() {
242
- // Activity/reply, post comments, dashboard post 'text' editor.
243
- $( '.bp-suggestions, #comments form textarea, .wp-editor-area' ).bp_mentions( bp.mentions.users );
244
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
 
246
- bp.mentions.tinyMCEinit = function() {
247
- if ( typeof window.tinyMCE === 'undefined' || window.tinyMCE.activeEditor === null || typeof window.tinyMCE.activeEditor === 'undefined' ) {
248
- return;
249
- } else {
250
  $( window.tinyMCE.activeEditor.contentDocument.activeElement )
251
  .atwho( 'setIframe', $( '#content_ifr' )[0] )
252
- .bp_mentions( bp.mentions.users );
253
- }
254
- };
255
- })( bp, jQuery );
 
 
 
 
 
 
1
+ (function( $, undefined ) {
 
 
 
 
2
  var mentionsQueryCache = [],
3
  mentionsItem;
4
 
 
 
 
 
 
 
 
5
  /**
6
  * Adds BuddyPress @mentions to form inputs.
7
  *
228
  };
229
 
230
  $( document ).ready(function() {
231
+ var loadMentionsInTinyMCE,
232
+ loadAttempts = 0,
233
+ users = [];
234
+
235
+ if ( typeof window.BP_Suggestions === 'object' ) {
236
+ users = window.BP_Suggestions.friends || users;
237
+ }
238
+
239
+ // Dashboard post 'visual' editor.
240
+ loadMentionsInTinyMCE = function() {
241
+ if ( loadAttempts < 4 || ! $( 'body' ).hasClass( 'wp-admin' ) ) {
242
+ loadAttempts++;
243
+
244
+ if ( typeof window.tinyMCE === 'undefined' || window.tinyMCE.activeEditor === null || typeof window.tinyMCE.activeEditor === 'undefined' ) {
245
+ setTimeout( loadMentionsInTinyMCE, 500 );
246
+ return;
247
+ }
248
+ }
249
 
 
 
 
 
250
  $( window.tinyMCE.activeEditor.contentDocument.activeElement )
251
  .atwho( 'setIframe', $( '#content_ifr' )[0] )
252
+ .bp_mentions( users );
253
+ };
254
+
255
+ // Activity/reply, post comments, dashboard post 'text' editor.
256
+ $( '.bp-suggestions, #comments form textarea, .wp-editor-area' ).bp_mentions( users );
257
+
258
+ // Dashboard post 'visual' editor.
259
+ loadMentionsInTinyMCE();
260
+ });
261
+ })( jQuery );
bp-activity/js/mentions.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.3.5 - 2015-11-11 5:23:00 AM UTC - https://wordpress.org/plugins/buddypress/ */
2
- window.bp=window.bp||{},function(a,b){var c,d=[];a.mentions=a.mentions||{},a.mentions.users=window.bp.mentions.users||[],"object"==typeof window.BP_Suggestions&&(a.mentions.users=window.BP_Suggestions.friends||a.mentions.users),b.fn.bp_mentions=function(a){b.isArray(a)&&(a={data:a});var e={delay:200,hide_without_suffix:!0,insert_tpl:"</>${atwho-data-value}</>",limit:10,start_with_space:!1,suffix:"",callbacks:{filter:function(a,b,c){var d,e,f,g=[],h=new RegExp("^"+a+"| "+a,"ig");for(e=0,f=b.length;f>e;e++)d=b[e],d[c].toLowerCase().match(h)&&g.push(d);return g},highlighter:function(a,b){if(!b)return a;var c=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+b.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return a.replace(c,function(a,b,c,d){return">"+b+"<strong>"+c+"</strong>"+d+"<"})},before_reposition:function(a){var c,d,e,f,g=b("#atwho-ground-"+this.id+" .atwho-view"),h=b("body"),i=this.$inputor.data("atwho");"undefined"!==i&&"undefined"!==i.iframe&&null!==i.iframe?(c=this.$inputor.caret("offset",{iframe:i.iframe}),e=b(i.iframe).offset(),"undefined"!==e&&(c.left+=e.left,c.top+=e.top)):c=this.$inputor.caret("offset"),c.left>h.width()/2?(g.addClass("right"),f=c.left-a.left-this.view.$el.width()):(g.removeClass("right"),f=c.left-a.left+1),h.width()<=400&&b(document).scrollTop(c.top-6),d=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10),(!d||5>d)&&(d=19),a.top=c.top+d,a.left+=f},inserting_wrapper:function(a,b,c){return""+b+c}}},f={callbacks:{remote_filter:function(a,e){var f=b(this),g={};return c=d[a],"object"==typeof c?void e(c):(f.xhr&&f.xhr.abort(),g={action:"bp_get_suggestions",term:a,type:"members"},b.isNumeric(this.$inputor.data("suggestions-group-id"))&&(g["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),void(f.xhr=b.getJSON(ajaxurl,g).done(function(c){if(c.success){var f=b.map(c.data,function(a){return a.search=a.search||a.ID+" "+a.name,a});d[a]=f,e(f)}})))}},data:b.map(a.data,function(a){return a.search=a.search||a.ID+" "+a.name,a}),at:"@",search_key:"search",tpl:'<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'},g=b.extend(!0,{},e,f,a);return b.fn.atwho.call(this,g)},b(document).ready(function(){b(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(a.mentions.users)}),a.mentions.tinyMCEinit=function(){"undefined"!=typeof window.tinyMCE&&null!==window.tinyMCE.activeEditor&&"undefined"!=typeof window.tinyMCE.activeEditor&&b(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",b("#content_ifr")[0]).bp_mentions(a.mentions.users)}}(bp,jQuery);
1
+ /*! buddypress - v2.2.4 - 2015-11-11 5:04:26 AM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ !function(a){var b,c=[];a.fn.bp_mentions=function(d){a.isArray(d)&&(d={data:d});var e={delay:200,hide_without_suffix:!0,insert_tpl:"</>${atwho-data-value}</>",limit:10,start_with_space:!1,suffix:"",callbacks:{filter:function(a,b,c){var d,e,f,g=[],h=new RegExp("^"+a+"| "+a,"ig");for(e=0,f=b.length;f>e;e++)d=b[e],d[c].toLowerCase().match(h)&&g.push(d);return g},highlighter:function(a,b){if(!b)return a;var c=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+b.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return a.replace(c,function(a,b,c,d){return">"+b+"<strong>"+c+"</strong>"+d+"<"})},before_reposition:function(b){var c,d,e,f,g=a("#atwho-ground-"+this.id+" .atwho-view"),h=a("body"),i=this.$inputor.data("atwho");"undefined"!==i&&"undefined"!==i.iframe&&null!==i.iframe?(c=this.$inputor.caret("offset",{iframe:i.iframe}),e=a(i.iframe).offset(),"undefined"!==e&&(c.left+=e.left,c.top+=e.top)):c=this.$inputor.caret("offset"),c.left>h.width()/2?(g.addClass("right"),f=c.left-b.left-this.view.$el.width()):(g.removeClass("right"),f=c.left-b.left+1),h.width()<=400&&a(document).scrollTop(c.top-6),d=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10),(!d||5>d)&&(d=19),b.top=c.top+d,b.left+=f},inserting_wrapper:function(a,b,c){return""+b+c}}},f={callbacks:{remote_filter:function(d,e){var f=a(this),g={};return b=c[d],"object"==typeof b?void e(b):(f.xhr&&f.xhr.abort(),g={action:"bp_get_suggestions",term:d,type:"members"},a.isNumeric(this.$inputor.data("suggestions-group-id"))&&(g["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),void(f.xhr=a.getJSON(ajaxurl,g).done(function(b){if(b.success){var f=a.map(b.data,function(a){return a.search=a.search||a.ID+" "+a.name,a});c[d]=f,e(f)}})))}},data:a.map(d.data,function(a){return a.search=a.search||a.ID+" "+a.name,a}),at:"@",search_key:"search",tpl:'<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'},g=a.extend(!0,{},e,f,d);return a.fn.atwho.call(this,g)},a(document).ready(function(){var b,c=0,d=[];"object"==typeof window.BP_Suggestions&&(d=window.BP_Suggestions.friends||d),b=function(){return(4>c||!a("body").hasClass("wp-admin"))&&(c++,"undefined"==typeof window.tinyMCE||null===window.tinyMCE.activeEditor||"undefined"==typeof window.tinyMCE.activeEditor)?void setTimeout(b,500):void a(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",a("#content_ifr")[0]).bp_mentions(d)},a(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(d),b()})}(jQuery);
bp-blogs/bp-blogs-activity.php CHANGED
@@ -15,10 +15,12 @@ defined( 'ABSPATH' ) || exit;
15
  *
16
  * @since BuddyPress (1.0.0)
17
  *
 
 
18
  * @return bool|null Returns false if activity component is not active.
19
  */
20
  function bp_blogs_register_activity_actions() {
21
- $bp = buddypress();
22
 
23
  // Bail if activity is not active
24
  if ( ! bp_is_active( 'activity' ) ) {
@@ -32,7 +34,6 @@ function bp_blogs_register_activity_actions() {
32
  __( 'New site created', 'buddypress' ),
33
  'bp_blogs_format_activity_action_new_blog',
34
  __( 'New Sites', 'buddypress' ),
35
- array( 'activity', 'member' ),
36
  0
37
  );
38
  }
@@ -320,6 +321,7 @@ add_filter( 'bp_activity_prefetch_object_data', 'bp_blogs_prefetch_activity_obje
320
  * @since BuddyPress (1.0.0)
321
  *
322
  * @see bp_activity_add() for description of parameters.
 
323
  *
324
  * @param array $args {
325
  * See {@link bp_activity_add()} for complete description of arguments.
@@ -330,14 +332,13 @@ add_filter( 'bp_activity_prefetch_object_data', 'bp_blogs_prefetch_activity_obje
330
  * @return int|bool On success, returns the activity ID. False on failure.
331
  */
332
  function bp_blogs_record_activity( $args = '' ) {
 
333
 
334
  // Bail if activity is not active
335
  if ( ! bp_is_active( 'activity' ) ) {
336
  return false;
337
  }
338
 
339
- $bp = buddypress();
340
-
341
  $defaults = array(
342
  'user_id' => bp_loggedin_user_id(),
343
  'action' => '',
@@ -353,6 +354,11 @@ function bp_blogs_record_activity( $args = '' ) {
353
 
354
  $r = wp_parse_args( $args, $defaults );
355
 
 
 
 
 
 
356
  if ( ! empty( $r['action'] ) ) {
357
 
358
  /**
@@ -372,11 +378,11 @@ function bp_blogs_record_activity( $args = '' ) {
372
  *
373
  * @since BuddyPress (1.2.0)
374
  *
375
- * @param string $value Generated summary from content for the activity stream.
376
  * @param string $value Content for the activity stream.
377
  * @param array $r Array of arguments used for the activity stream item.
378
  */
379
- $r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_activity_create_summary( $r['content'], $r ), $r['content'], $r );
380
  }
381
 
382
  // Check for an existing entry and update if one exists.
15
  *
16
  * @since BuddyPress (1.0.0)
17
  *
18
+ * @global object $bp The BuddyPress global settings object.
19
+ *
20
  * @return bool|null Returns false if activity component is not active.
21
  */
22
  function bp_blogs_register_activity_actions() {
23
+ global $bp;
24
 
25
  // Bail if activity is not active
26
  if ( ! bp_is_active( 'activity' ) ) {
34
  __( 'New site created', 'buddypress' ),
35
  'bp_blogs_format_activity_action_new_blog',
36
  __( 'New Sites', 'buddypress' ),
 
37
  0
38
  );
39
  }
321
  * @since BuddyPress (1.0.0)
322
  *
323
  * @see bp_activity_add() for description of parameters.
324
+ * @global object $bp The BuddyPress global settings object.
325
  *
326
  * @param array $args {
327
  * See {@link bp_activity_add()} for complete description of arguments.
332
  * @return int|bool On success, returns the activity ID. False on failure.
333
  */
334
  function bp_blogs_record_activity( $args = '' ) {
335
+ global $bp;
336
 
337
  // Bail if activity is not active
338
  if ( ! bp_is_active( 'activity' ) ) {
339
  return false;
340
  }
341
 
 
 
342
  $defaults = array(
343
  'user_id' => bp_loggedin_user_id(),
344
  'action' => '',
354
 
355
  $r = wp_parse_args( $args, $defaults );
356
 
357
+ // Remove large images and replace them with just one image thumbnail
358
+ if ( ! empty( $r['content'] ) ) {
359
+ $r['content'] = bp_activity_thumbnail_content_images( $r['content'], $r['primary_link'], $r );
360
+ }
361
+
362
  if ( ! empty( $r['action'] ) ) {
363
 
364
  /**
378
  *
379
  * @since BuddyPress (1.2.0)
380
  *
381
+ * @param string $value Generated excerpt from content for the activity stream.
382
  * @param string $value Content for the activity stream.
383
  * @param array $r Array of arguments used for the activity stream item.
384
  */
385
+ $r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $r['content'] ), $r['content'], $r );
386
  }
387
 
388
  // Check for an existing entry and update if one exists.
bp-blogs/bp-blogs-classes.php CHANGED
@@ -10,4 +10,567 @@
10
  // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
- require dirname( __FILE__ ) . '/classes/class-bp-blogs-blog.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
+ /**
14
+ * The main BuddyPress blog class.
15
+ *
16
+ * A BP_Blogs_Object represents a link between a specific WordPress blog on a
17
+ * network and a specific user on that blog.
18
+ *
19
+ * @since BuddyPress (1.0.0)
20
+ */
21
+ class BP_Blogs_Blog {
22
+ public $id;
23
+ public $user_id;
24
+ public $blog_id;
25
+
26
+ /**
27
+ * Constructor method.
28
+ *
29
+ * @param int $id Optional. The ID of the blog.
30
+ */
31
+ public function __construct( $id = null ) {
32
+ if ( !empty( $id ) ) {
33
+ $this->id = $id;
34
+ $this->populate();
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Populate the object with data about the specific activity item.
40
+ */
41
+ public function populate() {
42
+ global $wpdb, $bp;
43
+
44
+ $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
45
+
46
+ $this->user_id = $blog->user_id;
47
+ $this->blog_id = $blog->blog_id;
48
+ }
49
+
50
+ /**
51
+ * Save the BP blog data to the database.
52
+ *
53
+ * @return bool True on success, false on failure.
54
+ */
55
+ public function save() {
56
+ global $wpdb, $bp;
57
+
58
+ $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
59
+ $this->blog_id = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
60
+
61
+ /**
62
+ * Fires before the current blog item gets saved.
63
+ *
64
+ * Please use this hook to filter the properties above. Each part will be passed in.
65
+ *
66
+ * @since BuddyPress (1.0.0)
67
+ *
68
+ * @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
69
+ */
70
+ do_action_ref_array( 'bp_blogs_blog_before_save', array( &$this ) );
71
+
72
+ // Don't try and save if there is no user ID or blog ID set.
73
+ if ( !$this->user_id || !$this->blog_id )
74
+ return false;
75
+
76
+ // Don't save if this blog has already been recorded for the user.
77
+ if ( !$this->id && $this->exists() )
78
+ return false;
79
+
80
+ if ( $this->id ) {
81
+ // Update
82
+ $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id );
83
+ } else {
84
+ // Save
85
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id );
86
+ }
87
+
88
+ if ( !$wpdb->query($sql) )
89
+ return false;
90
+
91
+ /**
92
+ * Fires after the current blog item gets saved.
93
+ *
94
+ * Please use this hook to filter the properties above. Each part will be passed in.
95
+ *
96
+ * @since BuddyPress (1.0.0)
97
+ *
98
+ * @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
99
+ */
100
+ do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) );
101
+
102
+ if ( $this->id )
103
+ return $this->id;
104
+ else
105
+ return $wpdb->insert_id;
106
+ }
107
+
108
+ /**
109
+ * Check whether an association between this user and this blog exists.
110
+ *
111
+ * @return int The number of associations between the user and blog
112
+ * saved in the blog component tables.
113
+ */
114
+ public function exists() {
115
+ global $bp, $wpdb;
116
+
117
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
118
+ }
119
+
120
+ /** Static Methods ***************************************************/
121
+
122
+ /**
123
+ * Retrieve a set of blog-user associations.
124
+ *
125
+ * @param string $type The order in which results should be returned.
126
+ * 'active', 'alphabetical', 'newest', or 'random'.
127
+ * @param int|bool $limit Optional. The maximum records to return.
128
+ * Default: false.
129
+ * @param int|bool $page Optional. The page of records to return.
130
+ * Default: false (unlimited results).
131
+ * @param int $user_id Optional. ID of the user whose blogs are being
132
+ * retrieved. Default: 0.
133
+ * @param string|bool $search_terms Optional. Search by text stored in
134
+ * blogmeta (such as the blog name). Default: false.
135
+ * @param bool $update_meta_cache Whether to pre-fetch metadata for
136
+ * blogs. Default: true.
137
+ * @param array $include_blog_ids Array of blog IDs to include.
138
+ * @return array Multidimensional results array, structured as follows:
139
+ * 'blogs' - Array of located blog objects
140
+ * 'total' - A count of the total blogs matching the filter params
141
+ */
142
+ public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true, $include_blog_ids = false ) {
143
+ global $bp, $wpdb;
144
+
145
+ if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) )
146
+ $hidden_sql = "AND wb.public = 1";
147
+ else
148
+ $hidden_sql = '';
149
+
150
+ $pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
151
+
152
+ $user_sql = !empty( $user_id ) ? $wpdb->prepare( " AND b.user_id = %d", $user_id ) : '';
153
+
154
+ switch ( $type ) {
155
+ case 'active': default:
156
+ $order_sql = "ORDER BY bm.meta_value DESC";
157
+ break;
158
+ case 'alphabetical':
159
+ $order_sql = "ORDER BY bm_name.meta_value ASC";
160
+ break;
161
+ case 'newest':
162
+ $order_sql = "ORDER BY wb.registered DESC";
163
+ break;
164
+ case 'random':
165
+ $order_sql = "ORDER BY RAND()";
166
+ break;
167
+ }
168
+
169
+ $include_sql = '';
170
+ $include_blog_ids = array_filter( wp_parse_id_list( $include_blog_ids ) );
171
+ if ( ! empty( $include_blog_ids ) ) {
172
+ $blog_ids_sql = implode( ',', $include_blog_ids );
173
+ $include_sql = " AND b.blog_id IN ({$blog_ids_sql})";
174
+ }
175
+
176
+ if ( ! empty( $search_terms ) ) {
177
+ $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
178
+ $search_terms_sql = $wpdb->prepare( 'AND (bm_name.meta_value LIKE %s OR bm_description.meta_value LIKE %s)', $search_terms_like, $search_terms_like );
179
+ } else {
180
+ $search_terms_sql = '';
181
+ }
182
+
183
+ $paged_blogs = $wpdb->get_results( "
184
+ SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm_name.meta_value as name
185
+ FROM
186
+ {$bp->blogs->table_name} b
187
+ LEFT JOIN {$bp->blogs->table_name_blogmeta} bm ON (b.blog_id = bm.blog_id)
188
+ LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_name ON (b.blog_id = bm_name.blog_id)
189
+ LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_description ON (b.blog_id = bm_description.blog_id)
190
+ LEFT JOIN {$wpdb->base_prefix}blogs wb ON (b.blog_id = wb.blog_id)
191
+ LEFT JOIN {$wpdb->users} u ON (b.user_id = u.ID)
192
+ WHERE
193
+ wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}
194
+ AND bm.meta_key = 'last_activity' AND bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
195
+ {$search_terms_sql} {$user_sql} {$include_sql}
196
+ GROUP BY b.blog_id {$order_sql} {$pag_sql}
197
+ " );
198
+
199
+ $total_blogs = $wpdb->get_var( "
200
+ SELECT COUNT(DISTINCT b.blog_id)
201
+ FROM
202
+ {$bp->blogs->table_name} b
203
+ LEFT JOIN {$wpdb->base_prefix}blogs wb ON (b.blog_id = wb.blog_id)
204
+ LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_name ON (b.blog_id = bm_name.blog_id)
205
+ LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_description ON (b.blog_id = bm_description.blog_id)
206
+ WHERE
207
+ wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}
208
+ AND
209
+ bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
210
+ {$search_terms_sql} {$user_sql} {$include_sql}
211
+ " );
212
+
213
+ $blog_ids = array();
214
+ foreach ( (array) $paged_blogs as $blog ) {
215
+ $blog_ids[] = (int) $blog->blog_id;
216
+ }
217
+
218
+ $paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type );
219
+
220
+ if ( $update_meta_cache ) {
221
+ bp_blogs_update_meta_cache( $blog_ids );
222
+ }
223
+
224
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
225
+ }
226
+
227
+ /**
228
+ * Delete the record of a given blog for all users.
229
+ *
230
+ * @param int $blog_id The blog being removed from all users.
231
+ * @return int|bool Number of rows deleted on success, false on failure.
232
+ */
233
+ public static function delete_blog_for_all( $blog_id ) {
234
+ global $wpdb, $bp;
235
+
236
+ bp_blogs_delete_blogmeta( $blog_id );
237
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
238
+ }
239
+
240
+ /**
241
+ * Delete the record of a given blog for a specific user.
242
+ *
243
+ * @param int $blog_id The blog being removed.
244
+ * @param int $user_id Optional. The ID of the user from whom the blog
245
+ * is being removed. If absent, defaults to the logged-in user ID.
246
+ * @return int|bool Number of rows deleted on success, false on failure.
247
+ */
248
+ public static function delete_blog_for_user( $blog_id, $user_id = null ) {
249
+ global $wpdb, $bp;
250
+
251
+ if ( !$user_id )
252
+ $user_id = bp_loggedin_user_id();
253
+
254
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
255
+ }
256
+
257
+ /**
258
+ * Delete all of a user's blog associations in the BP tables.
259
+ *
260
+ * @param int $user_id Optional. The ID of the user whose blog
261
+ * associations are being deleted. If absent, defaults to
262
+ * logged-in user ID.
263
+ * @return int|bool Number of rows deleted on success, false on failure.
264
+ */
265
+ public static function delete_blogs_for_user( $user_id = null ) {
266
+ global $wpdb, $bp;
267
+
268
+ if ( !$user_id )
269
+ $user_id = bp_loggedin_user_id();
270
+
271
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
272
+ }
273
+
274
+ /**
275
+ * Get all of a user's blogs, as tracked by BuddyPress.
276
+ *
277
+ * Note that this is different from the WordPress function
278
+ * {@link get_blogs_of_user()}; the current method returns only those
279
+ * blogs that have been recorded by BuddyPress, while the WP function
280
+ * does a true query of a user's blog capabilities.
281
+ *
282
+ * @param int $user_id Optional. ID of the user whose blogs are being
283
+ * queried. Defaults to logged-in user.
284
+ * @param bool $show_hidden Optional. Whether to include blogs that are
285
+ * not marked public. Defaults to true when viewing one's own
286
+ * profile.
287
+ * @return array Multidimensional results array, structured as follows:
288
+ * 'blogs' - Array of located blog objects
289
+ * 'total' - A count of the total blogs for the user.
290
+ */
291
+ public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
292
+ global $bp, $wpdb;
293
+
294
+ if ( !$user_id )
295
+ $user_id = bp_displayed_user_id();
296
+
297
+ // Show logged in users their hidden blogs.
298
+ if ( !bp_is_my_profile() && !$show_hidden )
299
+ $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
300
+ else
301
+ $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
302
+
303
+ $total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
304
+
305
+ $user_blogs = array();
306
+ foreach ( (array) $blogs as $blog ) {
307
+ $user_blogs[$blog->blog_id] = new stdClass;
308
+ $user_blogs[$blog->blog_id]->id = $blog->id;
309
+ $user_blogs[$blog->blog_id]->blog_id = $blog->blog_id;
310
+ $user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
311
+ $user_blogs[$blog->blog_id]->name = $blog->name;
312
+ }
313
+
314
+ return array( 'blogs' => $user_blogs, 'count' => $total_blog_count );
315
+ }
316
+
317
+ /**
318
+ * Get IDs of all of a user's blogs, as tracked by BuddyPress.
319
+ *
320
+ * This method always includes hidden blogs.
321
+ *
322
+ * @param int $user_id Optional. ID of the user whose blogs are being
323
+ * queried. Defaults to logged-in user.
324
+ * @return int The number of blogs associated with the user.
325
+ */
326
+ public static function get_blog_ids_for_user( $user_id = 0 ) {
327
+ global $bp, $wpdb;
328
+
329
+ if ( !$user_id )
330
+ $user_id = bp_displayed_user_id();
331
+
332
+ return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
333
+ }
334
+
335
+ /**
336
+ * Check whether a blog has been recorded by BuddyPress.
337
+ *
338
+ * @param int $blog_id ID of the blog being queried.
339
+ * @return int|null The ID of the first located entry in the BP table
340
+ * on success, otherwise null.
341
+ */
342
+ public static function is_recorded( $blog_id ) {
343
+ global $bp, $wpdb;
344
+
345
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
346
+ }
347
+
348
+ /**
349
+ * Return a count of associated blogs for a given user.
350
+ *
351
+ * Includes hidden blogs when the logged-in user is the same as the
352
+ * $user_id parameter, or when the logged-in user has the bp_moderate
353
+ * cap.
354
+ *
355
+ * @param int $user_id Optional. ID of the user whose blogs are being
356
+ * queried. Defaults to logged-in user.
357
+ * @return int Blog count for the user.
358
+ */
359
+ public static function total_blog_count_for_user( $user_id = null ) {
360
+ global $bp, $wpdb;
361
+
362
+ if ( !$user_id )
363
+ $user_id = bp_displayed_user_id();
364
+
365
+ // If the user is logged in return the blog count including their hidden blogs.
366
+ if ( ( is_user_logged_in() && $user_id == bp_loggedin_user_id() ) || bp_current_user_can( 'bp_moderate' ) ) {
367
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) );
368
+ } else {
369
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) );
370
+ }
371
+ }
372
+
373
+ /**
374
+ * Return a list of blogs matching a search term.
375
+ *
376
+ * Matches against blog names and descriptions, as stored in the BP
377
+ * blogmeta table.
378
+ *
379
+ * @param string $filter The search term.
380
+ * @param int $limit Optional. The maximum number of items to return.
381
+ * Default: null (no limit).
382
+ * @param int $page Optional. The page of results to return. Default:
383
+ * null (no limit).
384
+ * @return array Multidimensional results array, structured as follows:
385
+ * 'blogs' - Array of located blog objects
386
+ * 'total' - A count of the total blogs matching the query.
387
+ */
388
+ public static function search_blogs( $filter, $limit = null, $page = null ) {
389
+ global $wpdb, $bp;
390
+
391
+ $search_terms_like = '%' . bp_esc_like( $filter ) . '%';
392
+ $search_terms_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $search_terms_like );
393
+
394
+ $hidden_sql = '';
395
+ if ( !bp_current_user_can( 'bp_moderate' ) )
396
+ $hidden_sql = "AND wb.public = 1";
397
+
398
+ $pag_sql = '';
399
+ if ( $limit && $page ) {
400
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
401
+ }
402
+
403
+ $paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
404
+ $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
405
+
406
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
407
+ }
408
+
409
+ /**
410
+ * Retrieve a list of all blogs.
411
+ *
412
+ * Query will include hidden blogs if the logged-in user has the
413
+ * 'bp_moderate' cap.
414
+ *
415
+ * @param int $limit Optional. The maximum number of items to return.
416
+ * Default: null (no limit).
417
+ * @param int $page Optional. The page of results to return. Default:
418
+ * null (no limit).
419
+ * @return array Multidimensional results array, structured as follows:
420
+ * 'blogs' - Array of located blog objects
421
+ * 'total' - A count of the total blogs.
422
+ */
423
+ public static function get_all( $limit = null, $page = null ) {
424
+ global $bp, $wpdb;
425
+
426
+ $hidden_sql = !bp_current_user_can( 'bp_moderate' ) ? "AND wb.public = 1" : '';
427
+ $pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
428
+
429
+ $paged_blogs = $wpdb->get_results( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" );
430
+ $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" );
431
+
432
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
433
+ }
434
+
435
+ /**
436
+ * Retrieve a list of blogs whose names start with a given letter.
437
+ *
438
+ * Query will include hidden blogs if the logged-in user has the
439
+ * 'bp_moderate' cap.
440
+ *
441
+ * @param string $letter. The letter you're looking for.
442
+ * @param int $limit Optional. The maximum number of items to return.
443
+ * Default: null (no limit).
444
+ * @param int $page Optional. The page of results to return. Default:
445
+ * null (no limit).
446
+ * @return array Multidimensional results array, structured as follows:
447
+ * 'blogs' - Array of located blog objects.
448
+ * 'total' - A count of the total blogs matching the query.
449
+ */
450
+ public static function get_by_letter( $letter, $limit = null, $page = null ) {
451
+ global $bp, $wpdb;
452
+
453
+ $letter_like = '%' . bp_esc_like( $letter ) . '%';
454
+ $letter_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $letter_like );
455
+
456
+ $hidden_sql = '';
457
+ if ( !bp_current_user_can( 'bp_moderate' ) )
458
+ $hidden_sql = "AND wb.public = 1";
459
+
460
+ $pag_sql = '';
461
+ if ( $limit && $page )
462
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
463
+
464
+ $paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" );
465
+ $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" );
466
+
467
+ return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
468
+ }
469
+
470
+ /**
471
+ * Fetch blog data not caught in the main query and append it to results array.
472
+ *
473
+ * Gets the following information, which is either unavailable at the
474
+ * time of the original query, or is more efficient to look up in one
475
+ * fell swoop:
476
+ * - The latest post for each blog, include Featured Image data
477
+ * - The blog description
478
+ *
479
+ * @param array $paged_blogs Array of results from the original query.
480
+ * @param array $blog_ids Array of IDs returned from the original query.
481
+ * @param string|bool $type Not currently used. Default: false.
482
+ * @return array $paged_blogs The located blogs array, with the extras added.
483
+ */
484
+ public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
485
+ global $bp, $wpdb;
486
+
487
+ if ( empty( $blog_ids ) )
488
+ return $paged_blogs;
489
+
490
+ $blog_ids = implode( ',', wp_parse_id_list( $blog_ids ) );
491
+
492
+ for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
493
+ $blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id );
494
+ $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT ID, post_content, post_title, post_excerpt, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
495
+ $images = array();
496
+
497
+ // Add URLs to any Featured Image this post might have
498
+ if ( ! empty( $paged_blogs[$i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) {
499
+
500
+ // Grab 4 sizes of the image. Thumbnail.
501
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'thumbnail', false );
502
+ if ( ! empty( $image ) )
503
+ $images['thumbnail'] = $image[0];
504
+
505
+ // Medium
506
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false );
507
+ if ( ! empty( $image ) )
508
+ $images['medium'] = $image[0];
509
+
510
+ // Large
511
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false );
512
+ if ( ! empty( $image ) )
513
+ $images['large'] = $image[0];
514
+
515
+ // Post thumbnail
516
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false );
517
+ if ( ! empty( $image ) )
518
+ $images['post-thumbnail'] = $image[0];
519
+
520
+ // Add the images to the latest_post object
521
+ $paged_blogs[$i]->latest_post->images = $images;
522
+ }
523
+ }
524
+
525
+ /* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
526
+ $blog_descs = $wpdb->get_results( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" );
527
+
528
+ for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
529
+ foreach ( (array) $blog_descs as $desc ) {
530
+ if ( $desc->blog_id == $paged_blogs[$i]->blog_id )
531
+ $paged_blogs[$i]->description = $desc->description;
532
+ }
533
+ }
534
+
535
+ return $paged_blogs;
536
+ }
537
+
538
+ /**
539
+ * Check whether a given blog is hidden.
540
+ *
541
+ * Checks the 'public' column in the wp_blogs table.
542
+ *
543
+ * @param int $blog_id The ID of the blog being checked.
544
+ * @return bool True if hidden (public = 0), false otherwise.
545
+ */
546
+ public static function is_hidden( $blog_id ) {
547
+ global $wpdb;
548
+
549
+ if ( !(int) $wpdb->get_var( $wpdb->prepare( "SELECT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) ) {
550
+ return true;
551
+ }
552
+
553
+ return false;
554
+ }
555
+
556
+ /**
557
+ * Get ID of user-blog link.
558
+ *
559
+ * @param int $user_id ID of user.
560
+ * @param int $blog_id ID of blog.
561
+ * @return int|bool ID of user-blog link, or false if not found.
562
+ */
563
+ public static function get_user_blog( $user_id, $blog_id ) {
564
+ global $bp, $wpdb;
565
+
566
+ $user_blog = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
567
+
568
+ if ( empty( $user_blog ) ) {
569
+ $user_blog = false;
570
+ } else {
571
+ $user_blog = intval( $user_blog );
572
+ }
573
+
574
+ return $user_blog;
575
+ }
576
+ }
bp-blogs/bp-blogs-filters.php CHANGED
@@ -41,7 +41,7 @@ function bp_blogs_creation_location( $url ) {
41
  *
42
  * @param string $value URL for the 'Create a new site' signup page.
43
  */
44
- return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_blogs_directory_permalink() . 'create' ), $url );
45
  }
46
  add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
47
 
@@ -86,13 +86,11 @@ function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0,
86
  * Stop infinite loops with WordPress MU Sitewide Tags.
87
  * That plugin changed the way its settings were stored at some point. Thus the dual check.
88
  */
89
- $sitewide_tags_blog_settings = bp_core_get_root_option( 'sitewide_tags_blog' );
90
- if ( ! empty( $sitewide_tags_blog_settings ) ) {
91
- $st_options = maybe_unserialize( $sitewide_tags_blog_settings );
92
  $tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0;
93
  } else {
94
- $tags_blog_id = bp_core_get_root_option( 'sitewide_tags_blog' );
95
- $tags_blog_id = intval( $tags_blog_id );
96
  }
97
 
98
  /**
41
  *
42
  * @param string $value URL for the 'Create a new site' signup page.
43
  */
44
+ return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create', $url ) );
45
  }
46
  add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
47
 
86
  * Stop infinite loops with WordPress MU Sitewide Tags.
87
  * That plugin changed the way its settings were stored at some point. Thus the dual check.
88
  */
89
+ if ( ! empty( $bp->site_options['sitewide_tags_blog'] ) ) {
90
+ $st_options = maybe_unserialize( $bp->site_options['sitewide_tags_blog'] );
 
91
  $tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0;
92
  } else {
93
+ $tags_blog_id = isset( $bp->site_options['tags_blog_id'] ) ? $bp->site_options['tags_blog_id'] : 0;
 
94
  }
95
 
96
  /**
bp-blogs/bp-blogs-functions.php CHANGED
@@ -14,10 +14,12 @@ defined( 'ABSPATH' ) || exit;
14
  *
15
  * @since BuddyPress (1.5.0)
16
  *
 
 
17
  * @return bool True if set, false if empty.
18
  */
19
  function bp_blogs_has_directory() {
20
- $bp = buddypress();
21
 
22
  return (bool) !empty( $bp->pages->blogs->id );
23
  }
@@ -234,12 +236,12 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
234
  return false;
235
 
236
  $name = get_blog_option( $blog_id, 'blogname' );
237
- $url = get_home_url( $blog_id );
238
 
239
  if ( empty( $name ) ) {
240
- $name = $url;
241
  }
242
 
 
243
  $description = get_blog_option( $blog_id, 'blogdescription' );
244
  $close_old_posts = get_blog_option( $blog_id, 'close_comments_for_old_posts' );
245
  $close_days_old = get_blog_option( $blog_id, 'close_comments_days_old' );
@@ -408,21 +410,6 @@ function bp_blogs_update_option_thread_comments_depth( $oldvalue, $newvalue ) {
408
  }
409
  add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
410
 
411
- /**
412
- * Deletes the 'url' blogmeta for a site.
413
- *
414
- * Hooked to 'refresh_blog_details', which is notably used when editing a site
415
- * under "Network Admin > Sites".
416
- *
417
- * @since BuddyPress (2.3.0)
418
- *
419
- * @param int $site_id The site ID
420
- */
421
- function bp_blogs_delete_url_blogmeta( $site_id = 0 ) {
422
- bp_blogs_delete_blogmeta( (int) $site_id, 'url' );
423
- }
424
- add_action( 'refresh_blog_details', 'bp_blogs_delete_url_blogmeta' );
425
-
426
  /**
427
  * Record activity metadata about a published blog post.
428
  *
@@ -819,7 +806,7 @@ add_action( 'remove_user_from_blog', 'bp_blogs_remove_user_from_blog', 10, 2 );
819
  * WordPress catches add-user-to-blog requests at init:10. In some cases, this
820
  * can precede BP's Blogs component. This function bumps the priority of the
821
  * core function, so that we can be sure that the Blogs component is loaded
822
- * first. See https://buddypress.trac.wordpress.org/ticket/3916.
823
  *
824
  * @since BuddyPress (1.6.0)
825
  * @access private
@@ -839,6 +826,7 @@ add_action( 'init', 'bp_blogs_maybe_add_user_to_blog', 1 );
839
  * @param int $blog_id ID of the blog being removed.
840
  */
841
  function bp_blogs_remove_blog( $blog_id ) {
 
842
 
843
  $blog_id = (int) $blog_id;
844
 
@@ -855,11 +843,7 @@ function bp_blogs_remove_blog( $blog_id ) {
855
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
856
 
857
  // Delete activity stream item
858
- bp_blogs_delete_activity( array(
859
- 'item_id' => $blog_id,
860
- 'component' => buddypress()->blogs->id,
861
- 'type' => 'new_blog'
862
- ) );
863
 
864
  /**
865
  * Fires after a "blog created" item has been removed from blogs
@@ -880,6 +864,7 @@ add_action( 'delete_blog', 'bp_blogs_remove_blog' );
880
  * @param int $blog_id ID of the blog being removed.
881
  */
882
  function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
 
883
 
884
  $blog_id = (int) $blog_id;
885
  $user_id = (int) $user_id;
@@ -899,7 +884,7 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
899
  // Delete activity stream item
900
  bp_blogs_delete_activity( array(
901
  'item_id' => $blog_id,
902
- 'component' => buddypress()->blogs->id,
903
  'type' => 'new_blog'
904
  ) );
905
 
@@ -924,7 +909,7 @@ add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
924
  * is currently unused in the function (but is passed to hooks).
925
  */
926
  function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
927
- global $wpdb;
928
 
929
  if ( empty( $wpdb->blogid ) )
930
  return false;
@@ -949,12 +934,7 @@ function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
949
  do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id );
950
 
951
  // Delete activity stream item
952
- bp_blogs_delete_activity( array(
953
- 'item_id' => $blog_id,
954
- 'secondary_item_id' => $post_id,
955
- 'component' => buddypress()->blogs->id,
956
- 'type' => 'new_blog_post'
957
- ) );
958
 
959
  /**
960
  * Fires after removal of a blog post activity item from the activity stream.
@@ -1083,11 +1063,14 @@ function bp_blogs_remove_associated_blog_comments( $activity_ids = array(), $for
1083
  *
1084
  * @since BuddyPress (1.6.0)
1085
  *
 
 
1086
  * @param string $new_status New comment status.
1087
  * @param string $old_status Previous comment status.
1088
  * @param object $comment Comment data.
1089
  */
1090
  function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
 
1091
 
1092
  // Check the Activity component is active
1093
  if ( ! bp_is_active( 'activity' ) )
@@ -1116,12 +1099,7 @@ function bp_blogs_transition_activity_status( $new_status, $old_status, $comment
1116
 
1117
  // Get the activity
1118
  if ( bp_disable_blogforum_comments() ) {
1119
- $activity_id = bp_activity_get_activity_id( array(
1120
- 'component' => buddypress()->blogs->id,
1121
- 'item_id' => get_current_blog_id(),
1122
- 'secondary_item_id' => $comment->comment_ID,
1123
- 'type' => 'new_blog_comment'
1124
- ) );
1125
  } else {
1126
  $activity_id = get_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', true );
1127
  }
@@ -1210,6 +1188,7 @@ function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
1210
  * @param int $blog_id The ID of the blog to expunge.
1211
  */
1212
  function bp_blogs_remove_data_for_blog( $blog_id ) {
 
1213
 
1214
  /**
1215
  * Fires before all data related to a given blog is removed from blogs tracker
@@ -1225,11 +1204,7 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
1225
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
1226
 
1227
  // Delete activity stream item
1228
- bp_blogs_delete_activity( array(
1229
- 'item_id' => $blog_id,
1230
- 'component' => buddypress()->blogs->id,
1231
- 'type' => false
1232
- ) );
1233
 
1234
  /**
1235
  * Fires after all data related to a given blog has been removed from blogs tracker
@@ -1308,6 +1283,7 @@ function bp_blogs_is_blog_hidden( $blog_id ) {
1308
  * Delete a metadata from the DB for a blog.
1309
  *
1310
  * @global object $wpdb WordPress database access object.
 
1311
  *
1312
  * @param int $blog_id ID of the blog whose metadata is being deleted.
1313
  * @param string $meta_key Optional. The key of the metadata being deleted. If
@@ -1321,7 +1297,7 @@ function bp_blogs_is_blog_hidden( $blog_id ) {
1321
  * @return bool True on success, false on failure.
1322
  */
1323
  function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
1324
- global $wpdb;
1325
 
1326
  // Legacy - if no meta_key is passed, delete all for the blog_id
1327
  if ( empty( $meta_key ) ) {
@@ -1349,6 +1325,7 @@ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = fa
1349
  * @since BuddyPress (1.2.0)
1350
  *
1351
  * @global object $wpdb WordPress database access object.
 
1352
  *
1353
  * @param int $blog_id ID of the blog whose metadata is being requested.
1354
  * @param string $meta_key Optional. If present, only the metadata matching
@@ -1371,6 +1348,7 @@ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) {
1371
  * Update a piece of blog meta.
1372
  *
1373
  * @global object $wpdb WordPress database access object.
 
1374
  *
1375
  * @param int $blog_id ID of the blog whose metadata is being updated.
1376
  * @param string $meta_key Key of the metadata being updated.
14
  *
15
  * @since BuddyPress (1.5.0)
16
  *
17
+ * @global BuddyPress $bp The one true BuddyPress instance.
18
+ *
19
  * @return bool True if set, false if empty.
20
  */
21
  function bp_blogs_has_directory() {
22
+ global $bp;
23
 
24
  return (bool) !empty( $bp->pages->blogs->id );
25
  }
236
  return false;
237
 
238
  $name = get_blog_option( $blog_id, 'blogname' );
 
239
 
240
  if ( empty( $name ) ) {
241
+ return false;
242
  }
243
 
244
+ $url = get_home_url( $blog_id );
245
  $description = get_blog_option( $blog_id, 'blogdescription' );
246
  $close_old_posts = get_blog_option( $blog_id, 'close_comments_for_old_posts' );
247
  $close_days_old = get_blog_option( $blog_id, 'close_comments_days_old' );
410
  }
411
  add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
412
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  /**
414
  * Record activity metadata about a published blog post.
415
  *
806
  * WordPress catches add-user-to-blog requests at init:10. In some cases, this
807
  * can precede BP's Blogs component. This function bumps the priority of the
808
  * core function, so that we can be sure that the Blogs component is loaded
809
+ * first. See http://buddypress.trac.wordpress.org/ticket/3916.
810
  *
811
  * @since BuddyPress (1.6.0)
812
  * @access private
826
  * @param int $blog_id ID of the blog being removed.
827
  */
828
  function bp_blogs_remove_blog( $blog_id ) {
829
+ global $bp;
830
 
831
  $blog_id = (int) $blog_id;
832
 
843
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
844
 
845
  // Delete activity stream item
846
+ bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->id, 'type' => 'new_blog' ) );
 
 
 
 
847
 
848
  /**
849
  * Fires after a "blog created" item has been removed from blogs
864
  * @param int $blog_id ID of the blog being removed.
865
  */
866
  function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
867
+ global $bp;
868
 
869
  $blog_id = (int) $blog_id;
870
  $user_id = (int) $user_id;
884
  // Delete activity stream item
885
  bp_blogs_delete_activity( array(
886
  'item_id' => $blog_id,
887
+ 'component' => $bp->blogs->id,
888
  'type' => 'new_blog'
889
  ) );
890
 
909
  * is currently unused in the function (but is passed to hooks).
910
  */
911
  function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
912
+ global $wpdb, $bp;
913
 
914
  if ( empty( $wpdb->blogid ) )
915
  return false;
934
  do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id );
935
 
936
  // Delete activity stream item
937
+ bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->id, 'type' => 'new_blog_post' ) );
 
 
 
 
 
938
 
939
  /**
940
  * Fires after removal of a blog post activity item from the activity stream.
1063
  *
1064
  * @since BuddyPress (1.6.0)
1065
  *
1066
+ * @global object $bp BuddyPress global settings.
1067
+ *
1068
  * @param string $new_status New comment status.
1069
  * @param string $old_status Previous comment status.
1070
  * @param object $comment Comment data.
1071
  */
1072
  function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
1073
+ global $bp;
1074
 
1075
  // Check the Activity component is active
1076
  if ( ! bp_is_active( 'activity' ) )
1099
 
1100
  // Get the activity
1101
  if ( bp_disable_blogforum_comments() ) {
1102
+ $activity_id = bp_activity_get_activity_id( array( 'component' => $bp->blogs->id, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $comment->comment_ID, 'type' => 'new_blog_comment', ) );
 
 
 
 
 
1103
  } else {
1104
  $activity_id = get_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', true );
1105
  }
1188
  * @param int $blog_id The ID of the blog to expunge.
1189
  */
1190
  function bp_blogs_remove_data_for_blog( $blog_id ) {
1191
+ global $bp;
1192
 
1193
  /**
1194
  * Fires before all data related to a given blog is removed from blogs tracker
1204
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
1205
 
1206
  // Delete activity stream item
1207
+ bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->id, 'type' => false ) );
 
 
 
 
1208
 
1209
  /**
1210
  * Fires after all data related to a given blog has been removed from blogs tracker
1283
  * Delete a metadata from the DB for a blog.
1284
  *
1285
  * @global object $wpdb WordPress database access object.
1286
+ * @global object $bp BuddyPress global settings.
1287
  *
1288
  * @param int $blog_id ID of the blog whose metadata is being deleted.
1289
  * @param string $meta_key Optional. The key of the metadata being deleted. If
1297
  * @return bool True on success, false on failure.
1298
  */
1299
  function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
1300
+ global $wpdb, $bp;
1301
 
1302
  // Legacy - if no meta_key is passed, delete all for the blog_id
1303
  if ( empty( $meta_key ) ) {
1325
  * @since BuddyPress (1.2.0)
1326
  *
1327
  * @global object $wpdb WordPress database access object.
1328
+ * @global object $bp BuddyPress global settings.
1329
  *
1330
  * @param int $blog_id ID of the blog whose metadata is being requested.
1331
  * @param string $meta_key Optional. If present, only the metadata matching
1348
  * Update a piece of blog meta.
1349
  *
1350
  * @global object $wpdb WordPress database access object.
1351
+ * @global object $bp BuddyPress global settings.
1352
  *
1353
  * @param int $blog_id ID of the blog whose metadata is being updated.
1354
  * @param string $meta_key Key of the metadata being updated.
bp-blogs/bp-blogs-loader.php CHANGED
@@ -66,7 +66,6 @@ class BP_Blogs_Component extends BP_Component {
66
  'slug' => BP_BLOGS_SLUG,
67
  'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
68
  'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site
69
- 'directory_title' => _x( 'Sites', 'component directory title', 'buddypress' ),
70
  'notification_callback' => 'bp_blogs_format_notifications',
71
  'search_string' => __( 'Search sites...', 'buddypress' ),
72
  'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
@@ -85,10 +84,9 @@ class BP_Blogs_Component extends BP_Component {
85
  if ( 0 !== apply_filters( 'bp_is_blog_public', (int) get_option( 'blog_public' ) ) || ! is_multisite() ) {
86
 
87
  /**
88
- * Filters the post types to track for the Blogs component.
89
  *
90
  * @since BuddyPress (1.5.0)
91
- * @deprecated BuddyPress (2.3.0)
92
  *
93
  * @param array $value Array of post types to track.
94
  */
@@ -155,11 +153,8 @@ class BP_Blogs_Component extends BP_Component {
155
  }
156
 
157
  // Add 'Sites' to the main navigation
158
- $count = (int) bp_get_total_blog_count_for_user();
159
- $class = ( 0 === $count ) ? 'no-count' : 'count';
160
- $nav_text = sprintf( __( 'Sites <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) );
161
- $main_nav = array(
162
- 'name' => $nav_text,
163
  'slug' => $this->slug,
164
  'position' => 30,
165
  'screen_function' => 'bp_blogs_screen_my_blogs',
@@ -298,23 +293,8 @@ class BP_Blogs_Component extends BP_Component {
298
  *
299
  * @see bp_activity_get_post_type_tracking_args() for information on parameters.
300
  */
301
- public function post_tracking_args( $params = null, $post_type = 0 ) {
302
- /**
303
- * Filters the post types to track for the Blogs component.
304
- *
305
- * @since BuddyPress (1.5.0)
306
- * @deprecated BuddyPress (2.3.0)
307
- *
308
- * Make sure plugins still using 'bp_blogs_record_post_post_types'
309
- * to track their post types will generate new_blog_post activities
310
- * See https://buddypress.trac.wordpress.org/ticket/6306
311
- *
312
- * @param array $value Array of post types to track.
313
- */
314
- $post_types = apply_filters( 'bp_blogs_record_post_post_types', array( 'post' ) );
315
- $post_types_array = array_flip( $post_types );
316
-
317
- if ( ! isset( $post_types_array[ $post_type ] ) ) {
318
  return $params;
319
  }
320
 
66
  'slug' => BP_BLOGS_SLUG,
67
  'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
68
  'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site
 
69
  'notification_callback' => 'bp_blogs_format_notifications',
70
  'search_string' => __( 'Search sites...', 'buddypress' ),
71
  'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
84
  if ( 0 !== apply_filters( 'bp_is_blog_public', (int) get_option( 'blog_public' ) ) || ! is_multisite() ) {
85
 
86
  /**
87
+ * Filters the post types to track for the Blog component.
88
  *
89
  * @since BuddyPress (1.5.0)
 
90
  *
91
  * @param array $value Array of post types to track.
92
  */
153
  }
154
 
155
  // Add 'Sites' to the main navigation
156
+ $main_nav = array(
157
+ 'name' => sprintf( __( 'Sites <span>%d</span>', 'buddypress' ), bp_get_total_blog_count_for_user() ),
 
 
 
158
  'slug' => $this->slug,
159
  'position' => 30,
160
  'screen_function' => 'bp_blogs_screen_my_blogs',
293
  *
294
  * @see bp_activity_get_post_type_tracking_args() for information on parameters.
295
  */
296
+ public function post_tracking_args( $params = array(), $post_type = 0 ) {
297
+ if ( 'post' != $post_type ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  return $params;
299
  }
300
 
bp-blogs/bp-blogs-template.php CHANGED
@@ -76,7 +76,7 @@ function bp_blogs_root_slug() {
76
  * @uses bp_get_blogs_directory_permalink()
77
  */
78
  function bp_blogs_directory_permalink() {
79
- echo esc_url( bp_get_blogs_directory_permalink() );
80
  }
81
  /**
82
  * Return blog directory permalink.
@@ -472,13 +472,7 @@ function bp_blogs_pagination_count() {
472
  $to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) );
473
  $total = bp_core_number_format( $blogs_template->total_blog_count );
474
 
475
- if ( 1 == $blogs_template->total_blog_count ) {
476
- $message = __( 'Viewing 1 site', 'buddypress' );
477
- } else {
478
- $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s site', 'Viewing %1$s - %2$s of %3$s sites', $blogs_template->total_blog_count, 'buddypress' ), $from_num, $to_num, $total );
479
- }
480
-
481
- echo $message;
482
  }
483
 
484
  /**
@@ -712,11 +706,9 @@ function bp_blog_description() {
712
  * Output the row class of the current blog in the loop.
713
  *
714
  * @since BuddyPress (1.7.0)
715
- *
716
- * @param array $classes Array of custom classes
717
  */
718
- function bp_blog_class( $classes = array() ) {
719
- echo bp_get_blog_class( $classes );
720
  }
721
  /**
722
  * Return the row class of the current blog in the loop.
@@ -724,22 +716,20 @@ function bp_blog_class( $classes = array() ) {
724
  * @since BuddyPress (1.7.0)
725
  *
726
  * @global BP_Blogs_Template $blogs_template
727
- * @param array $classes Array of custom classes
728
  *
729
  * @return string Row class of the site.
730
  */
731
- function bp_get_blog_class( $classes = array() ) {
732
  global $blogs_template;
733
 
734
- // Add even/odd classes, but only if there's more than 1 group
735
- if ( $blogs_template->blog_count > 1 ) {
736
- $pos_in_loop = (int) $blogs_template->current_blog;
737
- $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
738
 
739
- // If we've only one site in the loop, don't bother with odd and even
740
- } else {
 
 
741
  $classes[] = 'bp-single-blog';
742
- }
743
 
744
  /**
745
  * Filters the row class of the current blog in the loop.
@@ -750,8 +740,8 @@ function bp_blog_class( $classes = array() ) {
750
  */
751
  $classes = apply_filters( 'bp_get_blog_class', $classes );
752
  $classes = array_merge( $classes, array() );
753
- $retval = 'class="' . join( ' ', $classes ) . '"';
754
 
 
755
  return $retval;
756
  }
757
 
@@ -1124,11 +1114,9 @@ function bp_total_blog_count_for_user( $user_id = 0 ) {
1124
  * @return bool True if blog registration is enabled.
1125
  */
1126
  function bp_blog_signup_enabled() {
1127
- $bp = buddypress();
1128
 
1129
- $active_signup = isset( $bp->site_options['registration'] )
1130
- ? $bp->site_options['registration']
1131
- : 'all';
1132
 
1133
  /**
1134
  * Filters whether or not blog creation is enabled.
@@ -1387,25 +1375,18 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
1387
 
1388
  /**
1389
  * Output a "Create a Site" link for users viewing their own profiles.
1390
- *
1391
- * This function is not used by BuddyPress as of 1.2, but is kept here for older
1392
- * themes that may still be using it.
1393
  */
1394
  function bp_create_blog_link() {
 
1395
 
1396
- // Don't show this link when not on your own profile
1397
- if ( ! bp_is_my_profile() ) {
1398
- return;
1399
- }
1400
-
1401
- /**
1402
- * Filters "Create a Site" links for users viewing their own profiles.
1403
- *
1404
- * @since BuddyPress (1.0.0)
1405
- *
1406
- * @param string $value HTML link for creating a site.
1407
- */
1408
- echo apply_filters( 'bp_create_blog_link', '<a href="' . trailingslashit( bp_get_blogs_directory_permalink() . 'create' ) . '">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
1409
  }
1410
 
1411
  /**
@@ -1416,9 +1397,10 @@ function bp_create_blog_link() {
1416
  function bp_blogs_blog_tabs() {
1417
 
1418
  // Don't show these tabs on a user's own profile
1419
- if ( bp_is_my_profile() ) {
1420
  return false;
1421
- } ?>
 
1422
 
1423
  <ul class="content-header-nav">
1424
  <li<?php if ( bp_is_current_action( 'my-blogs' ) || !bp_current_action() ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_blogs_slug() . '/my-blogs' ); ?>"><?php printf( __( "%s's Sites", 'buddypress' ), bp_get_displayed_user_fullname() ); ?></a></li>
@@ -1488,7 +1470,7 @@ function bp_blog_create_button() {
1488
  'link_text' => __( 'Create a Site', 'buddypress' ),
1489
  'link_title' => __( 'Create a Site', 'buddypress' ),
1490
  'link_class' => 'blog-create no-ajax',
1491
- 'link_href' => trailingslashit( bp_get_blogs_directory_permalink() . 'create' ),
1492
  'wrapper' => false,
1493
  'block_self' => false,
1494
  );
76
  * @uses bp_get_blogs_directory_permalink()
77
  */
78
  function bp_blogs_directory_permalink() {
79
+ echo bp_get_blogs_directory_permalink();
80
  }
81
  /**
82
  * Return blog directory permalink.
472
  $to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) );
473
  $total = bp_core_number_format( $blogs_template->total_blog_count );
474
 
475
+ echo sprintf( _n( 'Viewing 1 site', 'Viewing %1$s - %2$s of %3$s sites', $total, 'buddypress' ), $from_num, $to_num, $total );
 
 
 
 
 
 
476
  }
477
 
478
  /**
706
  * Output the row class of the current blog in the loop.
707
  *
708
  * @since BuddyPress (1.7.0)
 
 
709
  */
710
+ function bp_blog_class() {
711
+ echo bp_get_blog_class();
712
  }
713
  /**
714
  * Return the row class of the current blog in the loop.
716
  * @since BuddyPress (1.7.0)
717
  *
718
  * @global BP_Blogs_Template $blogs_template
 
719
  *
720
  * @return string Row class of the site.
721
  */
722
+ function bp_get_blog_class() {
723
  global $blogs_template;
724
 
725
+ $classes = array();
726
+ $pos_in_loop = (int) $blogs_template->current_blog;
 
 
727
 
728
+ // If we've only one site in the loop, don't bother with odd and even.
729
+ if ( $blogs_template->blog_count > 1 )
730
+ $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
731
+ else
732
  $classes[] = 'bp-single-blog';
 
733
 
734
  /**
735
  * Filters the row class of the current blog in the loop.
740
  */
741
  $classes = apply_filters( 'bp_get_blog_class', $classes );
742
  $classes = array_merge( $classes, array() );
 
743
 
744
+ $retval = 'class="' . join( ' ', $classes ) . '"';
745
  return $retval;
746
  }
747
 
1114
  * @return bool True if blog registration is enabled.
1115
  */
1116
  function bp_blog_signup_enabled() {
1117
+ global $bp;
1118
 
1119
+ $active_signup = isset( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : 'all';
 
 
1120
 
1121
  /**
1122
  * Filters whether or not blog creation is enabled.
1375
 
1376
  /**
1377
  * Output a "Create a Site" link for users viewing their own profiles.
 
 
 
1378
  */
1379
  function bp_create_blog_link() {
1380
+ if ( bp_is_my_profile() )
1381
 
1382
+ /**
1383
+ * Filters "Create a Site" links for users viewing their own profiles.
1384
+ *
1385
+ * @since BuddyPress (1.0.0)
1386
+ *
1387
+ * @param string $value HTML link for creating a site.
1388
+ */
1389
+ echo apply_filters( 'bp_create_blog_link', '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
 
 
 
 
 
1390
  }
1391
 
1392
  /**
1397
  function bp_blogs_blog_tabs() {
1398
 
1399
  // Don't show these tabs on a user's own profile
1400
+ if ( bp_is_my_profile() )
1401
  return false;
1402
+
1403
+ ?>
1404
 
1405
  <ul class="content-header-nav">
1406
  <li<?php if ( bp_is_current_action( 'my-blogs' ) || !bp_current_action() ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_blogs_slug() . '/my-blogs' ); ?>"><?php printf( __( "%s's Sites", 'buddypress' ), bp_get_displayed_user_fullname() ); ?></a></li>
1470
  'link_text' => __( 'Create a Site', 'buddypress' ),
1471
  'link_title' => __( 'Create a Site', 'buddypress' ),
1472
  'link_class' => 'blog-create no-ajax',
1473
+ 'link_href' => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_blogs_root_slug() ) . trailingslashit( 'create' ),
1474
  'wrapper' => false,
1475
  'block_self' => false,
1476
  );
bp-blogs/bp-blogs-widgets.php CHANGED
@@ -16,9 +16,8 @@ defined( 'ABSPATH' ) || exit;
16
  function bp_blogs_register_widgets() {
17
  global $wpdb;
18
 
19
- if ( bp_is_active( 'activity' ) && bp_is_root_blog( $wpdb->blogid ) ) {
20
  add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Blogs_Recent_Posts_Widget");' ) );
21
- }
22
  }
23
  add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
24
 
@@ -30,7 +29,7 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
30
  /**
31
  * Constructor method.
32
  */
33
- public function __construct() {
34
  $widget_ops = array(
35
  'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ),
36
  'classname' => 'widget_bp_blogs_widget buddypress widget',
@@ -46,47 +45,31 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
46
  * @param array $args Widget arguments.
47
  * @param array $instance Widget settings, as saved by the user.
48
  */
49
- public function widget( $args, $instance ) {
50
 
51
- $title = ! empty( $instance['title'] )
52
- ? esc_html( $instance['title'] )
53
- : __( 'Recent Networkwide Posts', 'buddypress' );
54
 
55
  if ( ! empty( $instance['link_title'] ) ) {
56
- $title = '<a href="' . bp_get_blogs_directory_permalink() . '">' . esc_html( $title ) . '</a>';
57
  }
58
 
59
  /**
60
  * Filters the Blogs Recent Posts widget title.
61
  *
62
  * @since BuddyPress (2.2.0)
63
- * @since BuddyPress (2.3.0) Added 'instance' and 'id_base' to arguments passed to filter.
64
  *
65
- * @param string $title The widget title.
66
- * @param array $instance The settings for the particular instance of the widget.
67
- * @param string $id_base Root ID for all widgets of this type.
68
  */
69
- $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
70
 
71
  echo $args['before_widget'];
72
  echo $args['before_title'] . $title . $args['after_title'];
73
 
74
- if ( empty( $instance['max_posts'] ) || empty( $instance['max_posts'] ) ) {
75
- $instance['max_posts'] = 10;
76
- }
77
-
78
- // Override some of the contextually set parameters for bp_has_activities()
79
- $args = array(
80
- 'action' => 'new_blog_post',
81
- 'max' => $instance['max_posts'],
82
- 'per_page' => $instance['max_posts'],
83
- 'user_id' => 0,
84
- 'scope' => false,
85
- 'object' => false,
86
- 'primary_id' => false
87
- ); ?>
88
 
89
- <?php if ( bp_has_activities( $args ) ) : ?>
 
90
 
91
  <ul id="blog-post-list" class="activity-list item-list">
92
 
@@ -94,12 +77,15 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
94
 
95
  <li>
96
  <div class="activity-content" style="margin: 0">
97
- <div class="activity-header"><?php bp_activity_action(); ?></div>
98
-
99
- <?php if ( bp_get_activity_content_body() ) : ?>
100
 
101
- <div class="activity-inner"><?php bp_activity_content_body(); ?></div>
 
 
102
 
 
 
 
 
103
  <?php endif; ?>
104
 
105
  </div>
@@ -110,11 +96,9 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
110
  </ul>
111
 
112
  <?php else : ?>
113
-
114
  <div id="message" class="info">
115
- <p><?php _e( 'Sorry, there were no posts found. Why not write one?', 'buddypress' ); ?></p>
116
  </div>
117
-
118
  <?php endif; ?>
119
 
120
  <?php echo $args['after_widget']; ?>
@@ -128,10 +112,10 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
128
  * @param array $old_instance The old instance options.
129
  * @return array $instance The parsed options to be saved.
130
  */
131
- public function update( $new_instance, $old_instance ) {
132
- $instance = $old_instance;
133
- $instance['title'] = strip_tags( $new_instance['title'] );
134
- $instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
135
  $instance['link_title'] = (bool) $new_instance['link_title'];
136
 
137
  return $instance;
@@ -142,22 +126,22 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
142
  *
143
  * @param $instance Settings for this widget.
144
  */
145
- public function form( $instance ) {
146
  $instance = wp_parse_args( (array) $instance, array(
147
  'title' => __( 'Recent Networkwide Posts', 'buddypress' ),
148
  'max_posts' => 10,
149
  'link_title' => false,
150
  ) );
151
 
152
- $title = strip_tags( $instance['title'] );
153
- $max_posts = strip_tags( $instance['max_posts'] );
154
  $link_title = (bool) $instance['link_title'];
155
 
156
  ?>
157
 
158
- <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%;" /></label></p>
159
- <p><label for="<?php echo $this->get_field_id( 'link_title' ); ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ); ?>" value="1" <?php checked( $link_title ); ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' ); ?></label></p>
160
- <p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
161
  <?php
162
  }
163
  }
16
  function bp_blogs_register_widgets() {
17
  global $wpdb;
18
 
19
+ if ( bp_is_active( 'activity' ) && (int) $wpdb->blogid == bp_get_root_blog_id() )
20
  add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Blogs_Recent_Posts_Widget");' ) );
 
21
  }
22
  add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
23
 
29
  /**
30
  * Constructor method.
31
  */
32
+ function __construct() {
33
  $widget_ops = array(
34
  'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ),
35
  'classname' => 'widget_bp_blogs_widget buddypress widget',
45
  * @param array $args Widget arguments.
46
  * @param array $instance Widget settings, as saved by the user.
47
  */
48
+ function widget( $args, $instance ) {
49
 
50
+ $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : __( 'Recent Networkwide Posts', 'buddypress' );
 
 
51
 
52
  if ( ! empty( $instance['link_title'] ) ) {
53
+ $title = '<a href="' . trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_blogs_root_slug() ) . '">' . esc_html( $title ) . '</a>';
54
  }
55
 
56
  /**
57
  * Filters the Blogs Recent Posts widget title.
58
  *
59
  * @since BuddyPress (2.2.0)
 
60
  *
61
+ * @param string $title The widget title.
 
 
62
  */
63
+ $title = apply_filters( 'widget_title', $instance['title'] );
64
 
65
  echo $args['before_widget'];
66
  echo $args['before_title'] . $title . $args['after_title'];
67
 
68
+ if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] )
69
+ $instance['max_posts'] = 10; ?>
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
+ <?php // Override some of the contextually set parameters for bp_has_activities() ?>
72
+ <?php if ( bp_has_activities( array( 'action' => 'new_blog_post', 'max' => $instance['max_posts'], 'per_page' => $instance['max_posts'], 'user_id' => 0, 'scope' => false, 'object' => false, 'primary_id' => false ) ) ) : ?>
73
 
74
  <ul id="blog-post-list" class="activity-list item-list">
75
 
77
 
78
  <li>
79
  <div class="activity-content" style="margin: 0">
 
 
 
80
 
81
+ <div class="activity-header">
82
+ <?php bp_activity_action() ?>
83
+ </div>
84
 
85
+ <?php if ( bp_get_activity_content_body() ) : ?>
86
+ <div class="activity-inner">
87
+ <?php bp_activity_content_body() ?>
88
+ </div>
89
  <?php endif; ?>
90
 
91
  </div>
96
  </ul>
97
 
98
  <?php else : ?>
 
99
  <div id="message" class="info">
100
+ <p><?php _e( 'Sorry, there were no posts found. Why not write one?', 'buddypress' ) ?></p>
101
  </div>
 
102
  <?php endif; ?>
103
 
104
  <?php echo $args['after_widget']; ?>
112
  * @param array $old_instance The old instance options.
113
  * @return array $instance The parsed options to be saved.
114
  */
115
+ function update( $new_instance, $old_instance ) {
116
+ $instance = $old_instance;
117
+ $instance['title'] = strip_tags( $new_instance['title'] );
118
+ $instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
119
  $instance['link_title'] = (bool) $new_instance['link_title'];
120
 
121
  return $instance;
126
  *
127
  * @param $instance Settings for this widget.
128
  */
129
+ function form( $instance ) {
130
  $instance = wp_parse_args( (array) $instance, array(
131
  'title' => __( 'Recent Networkwide Posts', 'buddypress' ),
132
  'max_posts' => 10,
133
  'link_title' => false,
134
  ) );
135
 
136
+ $title = strip_tags( $instance['title'] );
137
+ $max_posts = strip_tags( $instance['max_posts'] );
138
  $link_title = (bool) $instance['link_title'];
139
 
140
  ?>
141
 
142
+ <p><label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ) ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ) ?>" name="<?php echo $this->get_field_name( 'title' ) ?>" type="text" value="<?php echo esc_attr( $title ) ?>" style="width: 100%;" /></label></p>
143
+ <p><label for="<?php echo $this->get_field_id( 'link_title' ) ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ) ?>" value="1" <?php checked( $link_title ) ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' ) ?></label></p>
144
+ <p><label for="<?php echo $this->get_field_id( 'max_posts' ) ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
145
  <?php
146
  }
147
  }
bp-blogs/classes/class-bp-blogs-blog.php DELETED
@@ -1,608 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Blogs Classes.
4
- *
5
- * @package BuddyPress
6
- * @subpackage BlogsClasses
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * The main BuddyPress blog class.
14
- *
15
- * A BP_Blogs_Object represents a link between a specific WordPress blog on a
16
- * network and a specific user on that blog.
17
- *
18
- * @since BuddyPress (1.0.0)
19
- */
20
- class BP_Blogs_Blog {
21
- public $id;
22
- public $user_id;
23
- public $blog_id;
24
-
25
- /**
26
- * Constructor method.
27
- *
28
- * @param int $id Optional. The ID of the blog.
29
- */
30
- public function __construct( $id = null ) {
31
- if ( !empty( $id ) ) {
32
- $this->id = $id;
33
- $this->populate();
34
- }
35
- }
36
-
37
- /**
38
- * Populate the object with data about the specific activity item.
39
- */
40
- public function populate() {
41
- global $wpdb;
42
-
43
- $bp = buddypress();
44
-
45
- $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
46
-
47
- $this->user_id = $blog->user_id;
48
- $this->blog_id = $blog->blog_id;
49
- }
50
-
51
- /**
52
- * Save the BP blog data to the database.
53
- *
54
- * @return bool True on success, false on failure.
55
- */
56
- public function save() {
57
- global $wpdb;
58
-
59
- $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
60
- $this->blog_id = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
61
-
62
- /**
63
- * Fires before the current blog item gets saved.
64
- *
65
- * Please use this hook to filter the properties above. Each part will be passed in.
66
- *
67
- * @since BuddyPress (1.0.0)
68
- *
69
- * @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
70
- */
71
- do_action_ref_array( 'bp_blogs_blog_before_save', array( &$this ) );
72
-
73
- // Don't try and save if there is no user ID or blog ID set.
74
- if ( !$this->user_id || !$this->blog_id )
75
- return false;
76
-
77
- // Don't save if this blog has already been recorded for the user.
78
- if ( !$this->id && $this->exists() )
79
- return false;
80
-
81
- $bp = buddypress();
82
-
83
- if ( $this->id ) {
84
- // Update
85
- $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id );
86
- } else {
87
- // Save
88
- $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id );
89
- }
90
-
91
- if ( !$wpdb->query($sql) )
92
- return false;
93
-
94
- /**
95
- * Fires after the current blog item gets saved.
96
- *
97
- * Please use this hook to filter the properties above. Each part will be passed in.
98
- *
99
- * @since BuddyPress (1.0.0)
100
- *
101
- * @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
102
- */
103
- do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) );
104
-
105
- if ( $this->id )
106
- return $this->id;
107
- else
108
- return $wpdb->insert_id;
109
- }
110
-
111
- /**
112
- * Check whether an association between this user and this blog exists.
113
- *
114
- * @return int The number of associations between the user and blog
115
- * saved in the blog component tables.
116
- */
117
- public function exists() {
118
- global $wpdb;
119
-
120
- $bp = buddypress();
121
-
122
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
123
- }
124
-
125
- /** Static Methods ***************************************************/
126
-
127
- /**
128
- * Retrieve a set of blog-user associations.
129
- *
130
- * @param string $type The order in which results should be returned.
131
- * 'active', 'alphabetical', 'newest', or 'random'.
132
- * @param int|bool $limit Optional. The maximum records to return.
133
- * Default: false.
134
- * @param int|bool $page Optional. The page of records to return.
135
- * Default: false (unlimited results).
136
- * @param int $user_id Optional. ID of the user whose blogs are being
137
- * retrieved. Default: 0.
138
- * @param string|bool $search_terms Optional. Search by text stored in
139
- * blogmeta (such as the blog name). Default: false.
140
- * @param bool $update_meta_cache Whether to pre-fetch metadata for
141
- * blogs. Default: true.
142
- * @param array $include_blog_ids Array of blog IDs to include.
143
- * @return array Multidimensional results array, structured as follows:
144
- * 'blogs' - Array of located blog objects
145
- * 'total' - A count of the total blogs matching the filter params
146
- */
147
- public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true, $include_blog_ids = false ) {
148
- global $wpdb;
149
-
150
- $bp = buddypress();
151
-
152
- if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) )
153
- $hidden_sql = "AND wb.public = 1";
154
- else
155
- $hidden_sql = '';
156
-
157
- $pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
158
-
159
- $user_sql = !empty( $user_id ) ? $wpdb->prepare( " AND b.user_id = %d", $user_id ) : '';
160
-
161
- switch ( $type ) {
162
- case 'active': default:
163
- $order_sql = "ORDER BY bm.meta_value DESC";
164
- break;
165
- case 'alphabetical':
166
- $order_sql = "ORDER BY bm_name.meta_value ASC";
167
- break;
168
- case 'newest':
169
- $order_sql = "ORDER BY wb.registered DESC";
170
- break;
171
- case 'random':
172
- $order_sql = "ORDER BY RAND()";
173
- break;
174
- }
175
-
176
- $include_sql = '';
177
- $include_blog_ids = array_filter( wp_parse_id_list( $include_blog_ids ) );
178
- if ( ! empty( $include_blog_ids ) ) {
179
- $blog_ids_sql = implode( ',', $include_blog_ids );
180
- $include_sql = " AND b.blog_id IN ({$blog_ids_sql})";
181
- }
182
-
183
- if ( ! empty( $search_terms ) ) {
184
- $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
185
- $search_terms_sql = $wpdb->prepare( 'AND (bm_name.meta_value LIKE %s OR bm_description.meta_value LIKE %s)', $search_terms_like, $search_terms_like );
186
- } else {
187
- $search_terms_sql = '';
188
- }
189
-
190
- $paged_blogs = $wpdb->get_results( "
191
- SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm_name.meta_value as name
192
- FROM
193
- {$bp->blogs->table_name} b
194
- LEFT JOIN {$bp->blogs->table_name_blogmeta} bm ON (b.blog_id = bm.blog_id)
195
- LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_name ON (b.blog_id = bm_name.blog_id)
196
- LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_description ON (b.blog_id = bm_description.blog_id)
197
- LEFT JOIN {$wpdb->base_prefix}blogs wb ON (b.blog_id = wb.blog_id)
198
- LEFT JOIN {$wpdb->users} u ON (b.user_id = u.ID)
199
- WHERE
200
- wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}
201
- AND bm.meta_key = 'last_activity' AND bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
202
- {$search_terms_sql} {$user_sql} {$include_sql}
203
- GROUP BY b.blog_id {$order_sql} {$pag_sql}
204
- " );
205
-
206
- $total_blogs = $wpdb->get_var( "
207
- SELECT COUNT(DISTINCT b.blog_id)
208
- FROM
209
- {$bp->blogs->table_name} b
210
- LEFT JOIN {$wpdb->base_prefix}blogs wb ON (b.blog_id = wb.blog_id)
211
- LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_name ON (b.blog_id = bm_name.blog_id)
212
- LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_description ON (b.blog_id = bm_description.blog_id)
213
- WHERE
214
- wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}
215
- AND
216
- bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
217
- {$search_terms_sql} {$user_sql} {$include_sql}
218
- " );
219
-
220
- $blog_ids = array();
221
- foreach ( (array) $paged_blogs as $blog ) {
222
- $blog_ids[] = (int) $blog->blog_id;
223
- }
224
-
225
- $paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type );
226
-
227
- if ( $update_meta_cache ) {
228
- bp_blogs_update_meta_cache( $blog_ids );
229
- }
230
-
231
- return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
232
- }
233
-
234
- /**
235
- * Delete the record of a given blog for all users.
236
- *
237
- * @param int $blog_id The blog being removed from all users.
238
- * @return int|bool Number of rows deleted on success, false on failure.
239
- */
240
- public static function delete_blog_for_all( $blog_id ) {
241
- global $wpdb;
242
-
243
- bp_blogs_delete_blogmeta( $blog_id );
244
-
245
- $bp = buddypress();
246
-
247
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
248
- }
249
-
250
- /**
251
- * Delete the record of a given blog for a specific user.
252
- *
253
- * @param int $blog_id The blog being removed.
254
- * @param int $user_id Optional. The ID of the user from whom the blog
255
- * is being removed. If absent, defaults to the logged-in user ID.
256
- * @return int|bool Number of rows deleted on success, false on failure.
257
- */
258
- public static function delete_blog_for_user( $blog_id, $user_id = null ) {
259
- global $wpdb;
260
-
261
- if ( !$user_id )
262
- $user_id = bp_loggedin_user_id();
263
-
264
- $bp = buddypress();
265
-
266
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
267
- }
268
-
269
- /**
270
- * Delete all of a user's blog associations in the BP tables.
271
- *
272
- * @param int $user_id Optional. The ID of the user whose blog
273
- * associations are being deleted. If absent, defaults to
274
- * logged-in user ID.
275
- * @return int|bool Number of rows deleted on success, false on failure.
276
- */
277
- public static function delete_blogs_for_user( $user_id = null ) {
278
- global $wpdb;
279
-
280
- if ( !$user_id )
281
- $user_id = bp_loggedin_user_id();
282
-
283
- $bp = buddypress();
284
-
285
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
286
- }
287
-
288
- /**
289
- * Get all of a user's blogs, as tracked by BuddyPress.
290
- *
291
- * Note that this is different from the WordPress function
292
- * {@link get_blogs_of_user()}; the current method returns only those
293
- * blogs that have been recorded by BuddyPress, while the WP function
294
- * does a true query of a user's blog capabilities.
295
- *
296
- * @param int $user_id Optional. ID of the user whose blogs are being
297
- * queried. Defaults to logged-in user.
298
- * @param bool $show_hidden Optional. Whether to include blogs that are
299
- * not marked public. Defaults to true when viewing one's own
300
- * profile.
301
- * @return array Multidimensional results array, structured as follows:
302
- * 'blogs' - Array of located blog objects
303
- * 'total' - A count of the total blogs for the user.
304
- */
305
- public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
306
- global $wpdb;
307
-
308
- $bp = buddypress();
309
-
310
- if ( !$user_id )
311
- $user_id = bp_displayed_user_id();
312
-
313
- // Show logged in users their hidden blogs.
314
- if ( !bp_is_my_profile() && !$show_hidden )
315
- $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
316
- else
317
- $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
318
-
319
- $total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
320
-
321
- $user_blogs = array();
322
- foreach ( (array) $blogs as $blog ) {
323
- $user_blogs[$blog->blog_id] = new stdClass;
324
- $user_blogs[$blog->blog_id]->id = $blog->id;
325
- $user_blogs[$blog->blog_id]->blog_id = $blog->blog_id;
326
- $user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
327
- $user_blogs[$blog->blog_id]->name = $blog->name;
328
- }
329
-
330
- return array( 'blogs' => $user_blogs, 'count' => $total_blog_count );
331
- }
332
-
333
- /**
334
- * Get IDs of all of a user's blogs, as tracked by BuddyPress.
335
- *
336
- * This method always includes hidden blogs.
337
- *
338
- * @param int $user_id Optional. ID of the user whose blogs are being
339
- * queried. Defaults to logged-in user.
340
- * @return int The number of blogs associated with the user.
341
- */
342
- public static function get_blog_ids_for_user( $user_id = 0 ) {
343
- global $wpdb;
344
-
345
- $bp = buddypress();
346
-
347
- if ( !$user_id )
348
- $user_id = bp_displayed_user_id();
349
-
350
- return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
351
- }
352
-
353
- /**
354
- * Check whether a blog has been recorded by BuddyPress.
355
- *
356
- * @param int $blog_id ID of the blog being queried.
357
- * @return int|null The ID of the first located entry in the BP table
358
- * on success, otherwise null.
359
- */
360
- public static function is_recorded( $blog_id ) {
361
- global $wpdb;
362
-
363
- $bp = buddypress();
364
-
365
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
366
- }
367
-
368
- /**
369
- * Return a count of associated blogs for a given user.
370
- *
371
- * Includes hidden blogs when the logged-in user is the same as the
372
- * $user_id parameter, or when the logged-in user has the bp_moderate
373
- * cap.
374
- *
375
- * @param int $user_id Optional. ID of the user whose blogs are being
376
- * queried. Defaults to logged-in user.
377
- * @return int Blog count for the user.
378
- */
379
- public static function total_blog_count_for_user( $user_id = null ) {
380
- global $wpdb;
381
-
382
- $bp = buddypress();
383
-
384
- if ( !$user_id )
385
- $user_id = bp_displayed_user_id();
386
-
387
- // If the user is logged in return the blog count including their hidden blogs.
388
- if ( ( is_user_logged_in() && $user_id == bp_loggedin_user_id() ) || bp_current_user_can( 'bp_moderate' ) ) {
389
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) );
390
- } else {
391
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) );
392
- }
393
- }
394
-
395
- /**
396
- * Return a list of blogs matching a search term.
397
- *
398
- * Matches against blog names and descriptions, as stored in the BP
399
- * blogmeta table.
400
- *
401
- * @param string $filter The search term.
402
- * @param int $limit Optional. The maximum number of items to return.
403
- * Default: null (no limit).
404
- * @param int $page Optional. The page of results to return. Default:
405
- * null (no limit).
406
- * @return array Multidimensional results array, structured as follows:
407
- * 'blogs' - Array of located blog objects
408
- * 'total' - A count of the total blogs matching the query.
409
- */
410
- public static function search_blogs( $filter, $limit = null, $page = null ) {
411
- global $wpdb;
412
-
413
- $search_terms_like = '%' . bp_esc_like( $filter ) . '%';
414
- $search_terms_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $search_terms_like );
415
-
416
- $hidden_sql = '';
417
- if ( !bp_current_user_can( 'bp_moderate' ) )
418
- $hidden_sql = "AND wb.public = 1";
419
-
420
- $pag_sql = '';
421
- if ( $limit && $page ) {
422
- $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
423
- }
424
-
425
- $bp = buddypress();
426
-
427
- $paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
428
- $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
429
-
430
- return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
431
- }
432
-
433
- /**
434
- * Retrieve a list of all blogs.
435
- *
436
- * Query will include hidden blogs if the logged-in user has the
437
- * 'bp_moderate' cap.
438
- *
439
- * @param int $limit Optional. The maximum number of items to return.
440
- * Default: null (no limit).
441
- * @param int $page Optional. The page of results to return. Default:
442
- * null (no limit).
443
- * @return array Multidimensional results array, structured as follows:
444
- * 'blogs' - Array of located blog objects
445
- * 'total' - A count of the total blogs.
446
- */
447
- public static function get_all( $limit = null, $page = null ) {
448
- global $wpdb;
449
-
450
- $bp = buddypress();
451
-
452
- $hidden_sql = !bp_current_user_can( 'bp_moderate' ) ? "AND wb.public = 1" : '';
453
- $pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
454
-
455
- $paged_blogs = $wpdb->get_results( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" );
456
- $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" );
457
-
458
- return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
459
- }
460
-
461
- /**
462
- * Retrieve a list of blogs whose names start with a given letter.
463
- *
464
- * Query will include hidden blogs if the logged-in user has the
465
- * 'bp_moderate' cap.
466
- *
467
- * @param string $letter. The letter you're looking for.
468
- * @param int $limit Optional. The maximum number of items to return.
469
- * Default: null (no limit).
470
- * @param int $page Optional. The page of results to return. Default:
471
- * null (no limit).
472
- * @return array Multidimensional results array, structured as follows:
473
- * 'blogs' - Array of located blog objects.
474
- * 'total' - A count of the total blogs matching the query.
475
- */
476
- public static function get_by_letter( $letter, $limit = null, $page = null ) {
477
- global $wpdb;
478
-
479
- $bp = buddypress();
480
-
481
- $letter_like = '%' . bp_esc_like( $letter ) . '%';
482
- $letter_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $letter_like );
483
-
484
- $hidden_sql = '';
485
- if ( !bp_current_user_can( 'bp_moderate' ) )
486
- $hidden_sql = "AND wb.public = 1";
487
-
488
- $pag_sql = '';
489
- if ( $limit && $page )
490
- $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
491
-
492
- $paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" );
493
- $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" );
494
-
495
- return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
496
- }
497
-
498
- /**
499
- * Fetch blog data not caught in the main query and append it to results array.
500
- *
501
- * Gets the following information, which is either unavailable at the
502
- * time of the original query, or is more efficient to look up in one
503
- * fell swoop:
504
- * - The latest post for each blog, include Featured Image data
505
- * - The blog description
506
- *
507
- * @param array $paged_blogs Array of results from the original query.
508
- * @param array $blog_ids Array of IDs returned from the original query.
509
- * @param string|bool $type Not currently used. Default: false.
510
- * @return array $paged_blogs The located blogs array, with the extras added.
511
- */
512
- public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
513
- global $wpdb;
514
-
515
- $bp = buddypress();
516
-
517
- if ( empty( $blog_ids ) )
518
- return $paged_blogs;
519
-
520
- $blog_ids = implode( ',', wp_parse_id_list( $blog_ids ) );
521
-
522
- for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
523
- $blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id );
524
- $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT ID, post_content, post_title, post_excerpt, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
525
- $images = array();
526
-
527
- // Add URLs to any Featured Image this post might have
528
- if ( ! empty( $paged_blogs[$i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) {
529
-
530
- // Grab 4 sizes of the image. Thumbnail.
531
- $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'thumbnail', false );
532
- if ( ! empty( $image ) )
533
- $images['thumbnail'] = $image[0];
534
-
535
- // Medium
536
- $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false );
537
- if ( ! empty( $image ) )
538
- $images['medium'] = $image[0];
539
-
540
- // Large
541
- $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false );
542
- if ( ! empty( $image ) )
543
- $images['large'] = $image[0];
544
-
545
- // Post thumbnail
546
- $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false );
547
- if ( ! empty( $image ) )
548
- $images['post-thumbnail'] = $image[0];
549
-
550
- // Add the images to the latest_post object
551
- $paged_blogs[$i]->latest_post->images = $images;
552
- }
553
- }
554
-
555
- /* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
556
- $blog_descs = $wpdb->get_results( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" );
557
-
558
- for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
559
- foreach ( (array) $blog_descs as $desc ) {
560
- if ( $desc->blog_id == $paged_blogs[$i]->blog_id )
561
- $paged_blogs[$i]->description = $desc->description;
562
- }
563
- }
564
-
565
- return $paged_blogs;
566
- }
567
-
568
- /**
569
- * Check whether a given blog is hidden.
570
- *
571
- * Checks the 'public' column in the wp_blogs table.
572
- *
573
- * @param int $blog_id The ID of the blog being checked.
574
- * @return bool True if hidden (public = 0), false otherwise.
575
- */
576
- public static function is_hidden( $blog_id ) {
577
- global $wpdb;
578
-
579
- if ( !(int) $wpdb->get_var( $wpdb->prepare( "SELECT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) ) {
580
- return true;
581
- }
582
-
583
- return false;
584
- }
585
-
586
- /**
587
- * Get ID of user-blog link.
588
- *
589
- * @param int $user_id ID of user.
590
- * @param int $blog_id ID of blog.
591
- * @return int|bool ID of user-blog link, or false if not found.
592
- */
593
- public static function get_user_blog( $user_id, $blog_id ) {
594
- global $wpdb;
595
-
596
- $bp = buddypress();
597
-
598
- $user_blog = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
599
-
600
- if ( empty( $user_blog ) ) {
601
- $user_blog = false;
602
- } else {
603
- $user_blog = intval( $user_blog );
604
- }
605
-
606
- return $user_blog;
607
- }
608
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/{bp-core-admin-actions.php → bp-core-actions.php} RENAMED
@@ -1,13 +1,13 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Admin Actions.
5
  *
6
  * This file contains the actions that are used through-out BuddyPress Admin. They
7
  * are consolidated here to make searching for them easier, and to help developers
8
  * understand at a glance the order in which things occur.
9
  *
10
- * There are a few common places that additional actions can currently be found.
11
  *
12
  * - BuddyPress: In {@link BuddyPress::setup_actions()} in BuddyPress.php
13
  * - Admin: More in {@link bp_Admin::setup_actions()} in admin.php
@@ -22,7 +22,7 @@
22
  defined( 'ABSPATH' ) || exit;
23
 
24
  /**
25
- * Attach BuddyPress to WordPress.
26
  *
27
  * BuddyPress uses its own internal actions to help aid in third-party plugin
28
  * development, and to limit the amount of potential future code changes when
@@ -60,16 +60,16 @@ add_action( 'bp_admin_menu', 'bp_admin_separator' );
60
 
61
  /**
62
  * When a new site is created in a multisite installation, run the activation
63
- * routine on that site.
64
  *
65
- * @since BuddyPress (1.7.0)
66
  *
67
  * @param int $blog_id
68
  * @param int $user_id
69
  * @param string $domain
70
  * @param string $path
71
  * @param int $site_id
72
- * @param array $meta
73
  */
74
  function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
75
 
@@ -80,18 +80,7 @@ function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
80
  // Switch to the new blog
81
  switch_to_blog( $blog_id );
82
 
83
- /**
84
- * Fires the activation routine for a new site created in a multisite installation.
85
- *
86
- * @since BuddyPress (1.7.0)
87
- *
88
- * @param int $blog_id ID of the blog being installed to.
89
- * @param int $user_id ID of the user the install is for.
90
- * @param string $domain Domain to use with the install.
91
- * @param string $path Path to use with the install.
92
- * @param int $site_id ID of the site being installed to.
93
- * @param array $meta Metadata to use with the site creation.
94
- */
95
  do_action( 'bp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta );
96
 
97
  // restore original blog
@@ -101,66 +90,42 @@ function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
101
  /** Sub-Actions ***************************************************************/
102
 
103
  /**
104
- * Piggy back admin_init action.
105
  *
106
- * @since BuddyPress (1.7.0)
107
- * @uses do_action() Calls 'bp_admin_init'.
108
  */
109
  function bp_admin_init() {
110
-
111
- /**
112
- * Fires inside the bp_admin_init function.
113
- *
114
- * @since BuddyPress (1.6.0)
115
- */
116
  do_action( 'bp_admin_init' );
117
  }
118
 
119
  /**
120
- * Piggy back admin_menu action.
121
  *
122
- * @since BuddyPress (1.7.0)
123
- * @uses do_action() Calls 'bp_admin_menu'.
124
  */
125
  function bp_admin_menu() {
126
-
127
- /**
128
- * Fires inside the bp_admin_menu function.
129
- *
130
- * @since BuddyPress (1.7.0)
131
- */
132
  do_action( 'bp_admin_menu' );
133
  }
134
 
135
  /**
136
- * Piggy back admin_head action.
137
  *
138
- * @since BuddyPress (1.7.0)
139
- * @uses do_action() Calls 'bp_admin_head'.
140
  */
141
  function bp_admin_head() {
142
-
143
- /**
144
- * Fires inside the bp_admin_head function.
145
- *
146
- * @since BuddyPress (1.6.0)
147
- */
148
  do_action( 'bp_admin_head' );
149
  }
150
 
151
  /**
152
- * Piggy back admin_notices action.
153
  *
154
- * @since BuddyPress (1.7.0)
155
- * @uses do_action() Calls 'bp_admin_notices'.
156
  */
157
  function bp_admin_notices() {
158
-
159
- /**
160
- * Fires inside the bp_admin_notices function.
161
- *
162
- * @since BuddyPress (1.5.0)
163
- */
164
  do_action( 'bp_admin_notices' );
165
  }
166
 
@@ -172,66 +137,38 @@ function bp_admin_notices() {
172
  * @uses do_action() Calls 'bp_admin_enqueue_scripts''.
173
  *
174
  * @param string $hook_suffix The current admin page, passed to
175
- * 'admin_enqueue_scripts'.
176
  */
177
  function bp_admin_enqueue_scripts( $hook_suffix = '' ) {
178
-
179
- /**
180
- * Fires inside the bp_admin_enqueue_scripts function.
181
- *
182
- * @since BuddyPress (1.7.0)
183
- *
184
- * @param string $hook_suffix The current admin page, passed to admin_enqueue_scripts.
185
- */
186
  do_action( 'bp_admin_enqueue_scripts', $hook_suffix );
187
  }
188
 
189
  /**
190
- * Dedicated action to register BuddyPress importers.
191
  *
192
- * @since BuddyPress (1.7.0)
193
- * @uses do_action() Calls 'bp_admin_notices'.
194
  */
195
  function bp_register_importers() {
196
-
197
- /**
198
- * Fires inside the bp_register_importers function.
199
- *
200
- * Used to register a BuddyPress importer.
201
- *
202
- * @since BuddyPress (1.7.0)
203
- */
204
  do_action( 'bp_register_importers' );
205
  }
206
 
207
  /**
208
- * Dedicated action to register admin styles.
209
  *
210
- * @since BuddyPress (1.7.0)
211
- * @uses do_action() Calls 'bp_admin_notices'.
212
  */
213
  function bp_register_admin_style() {
214
-
215
- /**
216
- * Fires inside the bp_register_admin_style function.
217
- *
218
- * @since BuddyPress (1.7.0)
219
- */
220
  do_action( 'bp_register_admin_style' );
221
  }
222
 
223
  /**
224
- * Dedicated action to register admin settings.
225
  *
226
- * @since BuddyPress (1.7.0)
227
- * @uses do_action() Calls 'bp_register_admin_settings'.
228
  */
229
  function bp_register_admin_settings() {
230
-
231
- /**
232
- * Fires inside the bp_register_admin_settings function.
233
- *
234
- * @since BuddyPress (1.6.0)
235
- */
236
  do_action( 'bp_register_admin_settings' );
237
  }
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Admin Actions
5
  *
6
  * This file contains the actions that are used through-out BuddyPress Admin. They
7
  * are consolidated here to make searching for them easier, and to help developers
8
  * understand at a glance the order in which things occur.
9
  *
10
+ * There are a few common places that additional actions can currently be found
11
  *
12
  * - BuddyPress: In {@link BuddyPress::setup_actions()} in BuddyPress.php
13
  * - Admin: More in {@link bp_Admin::setup_actions()} in admin.php
22
  defined( 'ABSPATH' ) || exit;
23
 
24
  /**
25
+ * Attach BuddyPress to WordPress
26
  *
27
  * BuddyPress uses its own internal actions to help aid in third-party plugin
28
  * development, and to limit the amount of potential future code changes when
60
 
61
  /**
62
  * When a new site is created in a multisite installation, run the activation
63
+ * routine on that site
64
  *
65
+ * @since BuddyPress (1.7)
66
  *
67
  * @param int $blog_id
68
  * @param int $user_id
69
  * @param string $domain
70
  * @param string $path
71
  * @param int $site_id
72
+ * @param array() $meta
73
  */
74
  function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
75
 
80
  // Switch to the new blog
81
  switch_to_blog( $blog_id );
82
 
83
+ // Do the BuddyPress activation routine
 
 
 
 
 
 
 
 
 
 
 
84
  do_action( 'bp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta );
85
 
86
  // restore original blog
90
  /** Sub-Actions ***************************************************************/
91
 
92
  /**
93
+ * Piggy back admin_init action
94
  *
95
+ * @since BuddyPress (1.7)
96
+ * @uses do_action() Calls 'bp_admin_init'
97
  */
98
  function bp_admin_init() {
 
 
 
 
 
 
99
  do_action( 'bp_admin_init' );
100
  }
101
 
102
  /**
103
+ * Piggy back admin_menu action
104
  *
105
+ * @since BuddyPress (1.7)
106
+ * @uses do_action() Calls 'bp_admin_menu'
107
  */
108
  function bp_admin_menu() {
 
 
 
 
 
 
109
  do_action( 'bp_admin_menu' );
110
  }
111
 
112
  /**
113
+ * Piggy back admin_head action
114
  *
115
+ * @since BuddyPress (1.7)
116
+ * @uses do_action() Calls 'bp_admin_head'
117
  */
118
  function bp_admin_head() {
 
 
 
 
 
 
119
  do_action( 'bp_admin_head' );
120
  }
121
 
122
  /**
123
+ * Piggy back admin_notices action
124
  *
125
+ * @since BuddyPress (1.7)
126
+ * @uses do_action() Calls 'bp_admin_notices'
127
  */
128
  function bp_admin_notices() {
 
 
 
 
 
 
129
  do_action( 'bp_admin_notices' );
130
  }
131
 
137
  * @uses do_action() Calls 'bp_admin_enqueue_scripts''.
138
  *
139
  * @param string $hook_suffix The current admin page, passed to
140
+ * 'admin_enqueue_scripts'.
141
  */
142
  function bp_admin_enqueue_scripts( $hook_suffix = '' ) {
 
 
 
 
 
 
 
 
143
  do_action( 'bp_admin_enqueue_scripts', $hook_suffix );
144
  }
145
 
146
  /**
147
+ * Dedicated action to register BuddyPress importers
148
  *
149
+ * @since BuddyPress (1.7)
150
+ * @uses do_action() Calls 'bp_admin_notices'
151
  */
152
  function bp_register_importers() {
 
 
 
 
 
 
 
 
153
  do_action( 'bp_register_importers' );
154
  }
155
 
156
  /**
157
+ * Dedicated action to register admin styles
158
  *
159
+ * @since BuddyPress (1.7)
160
+ * @uses do_action() Calls 'bp_admin_notices'
161
  */
162
  function bp_register_admin_style() {
 
 
 
 
 
 
163
  do_action( 'bp_register_admin_style' );
164
  }
165
 
166
  /**
167
+ * Dedicated action to register admin settings
168
  *
169
+ * @since BuddyPress (1.7)
170
+ * @uses do_action() Calls 'bp_register_admin_settings'
171
  */
172
  function bp_register_admin_settings() {
 
 
 
 
 
 
173
  do_action( 'bp_register_admin_settings' );
174
  }
bp-core/admin/{bp-core-admin-components.php → bp-core-components.php} RENAMED
@@ -14,7 +14,7 @@ defined( 'ABSPATH' ) || exit;
14
  * Renders the Component Setup admin panel.
15
  *
16
  * @package BuddyPress
17
- * @since BuddyPress (1.6.0)
18
  * @uses bp_core_admin_component_options()
19
  */
20
  function bp_core_admin_components_settings() {
@@ -44,21 +44,13 @@ function bp_core_admin_components_settings() {
44
  * Creates reusable markup for component setup on the Components and Pages dashboard panel.
45
  *
46
  * @package BuddyPress
47
- * @since BuddyPress (1.6.0)
48
  * @todo Use settings API
49
  */
50
  function bp_core_admin_components_options() {
51
 
52
  // Declare local variables
53
  $deactivated_components = array();
54
-
55
- /**
56
- * Filters the array of available components.
57
- *
58
- * @since BuddyPress (1.5.0)
59
- *
60
- * @param mixed $value Active components.
61
- */
62
  $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
63
 
64
  // The default components (if none are previously selected)
@@ -194,13 +186,11 @@ function bp_core_admin_components_options() {
194
 
195
  <?php endif; ?>
196
 
 
197
  </th>
198
  <td class="plugin-title" style="width: 190px;">
199
  <span></span>
200
- <label for="bp_components[<?php echo esc_attr( $name ); ?>]">
201
- <strong><?php echo esc_html( $labels['title'] ); ?></strong>
202
- </label>
203
-
204
  <div class="row-actions-visible">
205
 
206
  </div>
@@ -237,7 +227,7 @@ function bp_core_admin_components_options() {
237
  /**
238
  * Handle saving the Component settings
239
  *
240
- * @since BuddyPress (1.6.0)
241
  * @todo Use settings API when it supports saving network settings
242
  */
243
  function bp_core_admin_components_settings_handler() {
@@ -257,7 +247,7 @@ function bp_core_admin_components_settings_handler() {
257
  $bp = buddypress();
258
 
259
  // Save settings and upgrade schema
260
- require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
261
 
262
  $submitted = stripslashes_deep( $_POST['bp_components'] );
263
  $bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $submitted );
@@ -296,7 +286,7 @@ add_action( 'bp_admin_init', 'bp_core_admin_components_settings_handler' );
296
  * is not present, before merging the submitted components with the active
297
  * ones.
298
  *
299
- * @since BuddyPress (1.7.0)
300
  *
301
  * @param array This is the array of component settings coming from the POST
302
  * global. You should stripslashes_deep() before passing to this function
@@ -341,7 +331,7 @@ function bp_core_admin_get_active_components_from_submitted_settings( $submitted
341
  * We use this information both to build the markup for the admin screens, as
342
  * well as to do some processing on settings data submitted from those screens.
343
  *
344
- * @since BuddyPress (1.7.0)
345
  *
346
  * @param string $type 'all', 'optional', 'retired', 'required'
347
  * @return array An array of requested component data
@@ -364,7 +354,7 @@ function bp_core_admin_get_components( $type = 'all' ) {
364
  $retired_components = array(
365
  'forums' => array(
366
  'title' => __( 'Group Forums', 'buddypress' ),
367
- 'description' => sprintf( __( 'BuddyPress Forums are retired. Use %s.', 'buddypress' ), '<a href="https://bbpress.org/">bbPress</a>' )
368
  ),
369
  );
370
 
@@ -431,15 +421,5 @@ function bp_core_admin_get_components( $type = 'all' ) {
431
 
432
  }
433
 
434
- /**
435
- * Filters the list of component information.
436
- *
437
- * @since BuddyPress (2.0.0)
438
- *
439
- * @param array $components Array of component information.
440
- * @param string $type Type of component list requested.
441
- * Possible values include 'all', 'optional',
442
- * 'retired', 'required'.
443
- */
444
  return apply_filters( 'bp_core_admin_get_components', $components, $type );
445
  }
14
  * Renders the Component Setup admin panel.
15
  *
16
  * @package BuddyPress
17
+ * @since BuddyPress (1.6)
18
  * @uses bp_core_admin_component_options()
19
  */
20
  function bp_core_admin_components_settings() {
44
  * Creates reusable markup for component setup on the Components and Pages dashboard panel.
45
  *
46
  * @package BuddyPress
47
+ * @since BuddyPress (1.6)
48
  * @todo Use settings API
49
  */
50
  function bp_core_admin_components_options() {
51
 
52
  // Declare local variables
53
  $deactivated_components = array();
 
 
 
 
 
 
 
 
54
  $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
55
 
56
  // The default components (if none are previously selected)
186
 
187
  <?php endif; ?>
188
 
189
+ <label class="screen-reader-text" for="bp_components[<?php echo esc_attr( $name ); ?>]"><?php sprintf( __( 'Select %s', 'buddypress' ), esc_html( $labels['title'] ) ); ?></label>
190
  </th>
191
  <td class="plugin-title" style="width: 190px;">
192
  <span></span>
193
+ <strong><?php echo esc_html( $labels['title'] ); ?></strong>
 
 
 
194
  <div class="row-actions-visible">
195
 
196
  </div>
227
  /**
228
  * Handle saving the Component settings
229
  *
230
+ * @since BuddyPress (1.6)
231
  * @todo Use settings API when it supports saving network settings
232
  */
233
  function bp_core_admin_components_settings_handler() {
247
  $bp = buddypress();
248
 
249
  // Save settings and upgrade schema
250
+ require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-schema.php' );
251
 
252
  $submitted = stripslashes_deep( $_POST['bp_components'] );
253
  $bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $submitted );
286
  * is not present, before merging the submitted components with the active
287
  * ones.
288
  *
289
+ * @since (BuddyPress) 1.7
290
  *
291
  * @param array This is the array of component settings coming from the POST
292
  * global. You should stripslashes_deep() before passing to this function
331
  * We use this information both to build the markup for the admin screens, as
332
  * well as to do some processing on settings data submitted from those screens.
333
  *
334
+ * @since (BuddyPress) 1.7
335
  *
336
  * @param string $type 'all', 'optional', 'retired', 'required'
337
  * @return array An array of requested component data
354
  $retired_components = array(
355
  'forums' => array(
356
  'title' => __( 'Group Forums', 'buddypress' ),
357
+ 'description' => sprintf( __( 'BuddyPress Forums are retired. Use %s.', 'buddypress' ), '<a href="http://bbpress.org">bbPress</a>' )
358
  ),
359
  );
360
 
421
 
422
  }
423
 
 
 
 
 
 
 
 
 
 
 
424
  return apply_filters( 'bp_core_admin_get_components', $components, $type );
425
  }
bp-core/admin/{bp-core-admin-functions.php → bp-core-functions.php} RENAMED
@@ -32,7 +32,7 @@ function bp_core_admin_menu_init() {
32
  * @global array $_parent_pages
33
  * @global array $_registered_pages
34
  * @global array $submenu
35
- * @since BuddyPress (1.6.0)
36
  */
37
  function bp_core_admin_backpat_menu() {
38
  global $_parent_pages, $_registered_pages, $submenu;
@@ -71,7 +71,7 @@ add_action( bp_core_admin_hook(), 'bp_core_admin_backpat_menu', 999 );
71
  *
72
  * @global string $plugin_page
73
  * @global array $submenu
74
- * @since BuddyPress (1.6.0)
75
  */
76
  function bp_core_modify_admin_menu_highlight() {
77
  global $plugin_page, $submenu_file;
@@ -93,7 +93,7 @@ function bp_core_modify_admin_menu_highlight() {
93
  * will never appear.
94
  *
95
  * @see bp_core_admin_backpat_menu()
96
- * @since BuddyPress (1.6.0)
97
  * @todo Add convenience links into the markup once new positions are finalised.
98
  */
99
  function bp_core_admin_backpat_page() {
@@ -105,7 +105,7 @@ function bp_core_admin_backpat_page() {
105
  <h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
106
 
107
  <p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
108
- <p><?php printf( __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%s">Settings &gt; BuddyPress</a>. Profile Fields has been moved into the <a href="%s">Users</a> menu.', 'buddypress' ), esc_url( $settings_url ), bp_get_admin_url( 'users.php?page=bp-profile-setup' ) ); ?></p>
109
  </div>
110
 
111
  <?php
@@ -119,7 +119,7 @@ function bp_core_admin_backpat_page() {
119
  * BuddyPress combines all its messages into a single notice, to avoid a preponderance of yellow
120
  * boxes.
121
  *
122
- * @since BuddyPress (1.5.0)
123
  *
124
  * @uses bp_current_user_can() to check current user permissions before showing the notices
125
  * @uses bp_is_root_blog()
@@ -164,7 +164,7 @@ add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
164
  * box. It is recommended that you hook this function to admin_init, so that your messages are
165
  * loaded in time.
166
  *
167
- * @since BuddyPress (1.5.0)
168
  *
169
  * @param string $notice The notice you are adding to the queue.
170
  * @param string $type The notice type; optional. Usually either "updated" or "error".
@@ -199,7 +199,7 @@ function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) {
199
  *
200
  * @global WPDB $wpdb WordPress DB object
201
  * @global WP_Rewrite $wp_rewrite
202
- * @since BuddyPress (1.2.0)
203
  */
204
  function bp_core_activation_notice() {
205
  global $wp_rewrite, $wpdb;
@@ -329,7 +329,7 @@ function bp_core_activation_notice() {
329
  /**
330
  * Redirect user to BuddyPress's What's New page on activation
331
  *
332
- * @since BuddyPress (1.7.0)
333
  *
334
  * @internal Used internally to redirect BuddyPress to the about page on activation
335
  *
@@ -370,21 +370,13 @@ function bp_do_activation_redirect() {
370
  /**
371
  * Output the tabs in the admin area
372
  *
373
- * @since BuddyPress (1.5.0)
374
  * @param string $active_tab Name of the tab that is active. Optional.
375
  */
376
  function bp_core_admin_tabs( $active_tab = '' ) {
377
  $tabs_html = '';
378
  $idle_class = 'nav-tab';
379
  $active_class = 'nav-tab nav-tab-active';
380
-
381
- /**
382
- * Filters the admin tabs to be displayed.
383
- *
384
- * @since BuddyPress (1.9.0)
385
- *
386
- * @param array $value Array of tabs to output to the admin area.
387
- */
388
  $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) );
389
 
390
  // Loop through tabs and build navigation
@@ -395,12 +387,6 @@ function bp_core_admin_tabs( $active_tab = '' ) {
395
  }
396
 
397
  echo $tabs_html;
398
-
399
- /**
400
- * Fires after the output of tabs for the admin area.
401
- *
402
- * @since BuddyPress (1.5.0)
403
- */
404
  do_action( 'bp_admin_tabs' );
405
  }
406
 
@@ -442,9 +428,8 @@ function bp_core_get_admin_tabs( $active_tab = '' ) {
442
  /**
443
  * Filters the tab data used in our wp-admin screens.
444
  *
445
- * @since BuddyPress (2.2.0)
446
- *
447
  * @param array $tabs Tab data.
 
448
  */
449
  return apply_filters( 'bp_core_get_admin_tabs', $tabs );
450
  }
@@ -454,7 +439,7 @@ function bp_core_get_admin_tabs( $active_tab = '' ) {
454
  /**
455
  * adds contextual help to BuddyPress admin pages
456
  *
457
- * @since BuddyPress (1.7.0)
458
  * @todo Make this part of the BP_Component class and split into each component
459
  */
460
  function bp_core_add_contextual_help( $screen = '' ) {
@@ -476,8 +461,8 @@ function bp_core_add_contextual_help( $screen = '' ) {
476
  // help panel - sidebar links
477
  $screen->set_help_sidebar(
478
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
479
- '<p>' . __( '<a href="https://codex.buddypress.org/getting-started/configure-components/">Managing Components</a>', 'buddypress' ) . '</p>' .
480
- '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
481
  );
482
  break;
483
 
@@ -494,8 +479,8 @@ function bp_core_add_contextual_help( $screen = '' ) {
494
  // Help panel - sidebar links
495
  $screen->set_help_sidebar(
496
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
497
- '<p>' . __( '<a href="https://codex.buddypress.org/getting-started/configure-components/#settings-buddypress-pages">Managing Pages</a>', 'buddypress' ) . '</p>' .
498
- '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
499
  );
500
 
501
  break;
@@ -513,8 +498,8 @@ function bp_core_add_contextual_help( $screen = '' ) {
513
  // Help panel - sidebar links
514
  $screen->set_help_sidebar(
515
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
516
- '<p>' . __( '<a href="https://codex.buddypress.org/getting-started/configure-components/#settings-buddypress-settings">Managing Settings</a>', 'buddypress' ) . '</p>' .
517
- '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
518
  );
519
 
520
  break;
@@ -532,8 +517,8 @@ function bp_core_add_contextual_help( $screen = '' ) {
532
  // Help panel - sidebar links
533
  $screen->set_help_sidebar(
534
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
535
- '<p>' . __( '<a href="https://codex.buddypress.org/administrator-guide/extended-profiles/">Managing Profile Fields</a>', 'buddypress' ) . '</p>' .
536
- '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
537
  );
538
 
539
  break;
@@ -544,7 +529,7 @@ add_action( 'contextual_help', 'bp_core_add_contextual_help' );
544
  /**
545
  * renders contextual help content to contextual help tabs
546
  *
547
- * @since BuddyPress (1.7.0)
548
  */
549
  function bp_core_add_contextual_help_content( $tab = '' ) {
550
 
@@ -562,7 +547,7 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
562
  break;
563
 
564
  case 'bp-profile-overview' :
565
- $retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.<br /><br />Note: Any fields in the first group will appear on the signup page.', 'buddypress' );
566
  break;
567
 
568
  default:
@@ -583,7 +568,7 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
583
  /**
584
  * Add a separator to the WordPress admin menus
585
  *
586
- * @since BuddyPress (1.7.0)
587
  *
588
  * @uses bp_current_user_can() To check users capability on root blog
589
  */
@@ -618,7 +603,7 @@ function bp_admin_separator() {
618
  /**
619
  * Tell WordPress we have a custom menu order
620
  *
621
- * @since BuddyPress (1.7.0)
622
  *
623
  * @param bool $menu_order Menu order
624
  * @uses bp_current_user_can() To check users capability on root blog
@@ -637,7 +622,7 @@ function bp_admin_custom_menu_order( $menu_order = false ) {
637
  /**
638
  * Move our custom separator above our custom post types
639
  *
640
- * @since BuddyPress (1.7.0)
641
  *
642
  * @param array $menu_order Menu Order
643
  * @uses bp_current_user_can() To check users capability on root blog
@@ -656,13 +641,7 @@ function bp_admin_menu_order( $menu_order = array() ) {
656
  // Menu values
657
  $last_sep = is_network_admin() ? 'separator1' : 'separator2';
658
 
659
- /**
660
- * Filters the custom admin menus.
661
- *
662
- * @since BuddyPress (1.7.0)
663
- *
664
- * @param array $value Empty array.
665
- */
666
  $custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() );
667
 
668
  // Bail if no components have top level admin pages
@@ -708,7 +687,7 @@ function bp_admin_menu_order( $menu_order = array() ) {
708
  * and the inputs have different keys in the $_REQUEST array. This function
709
  * reconciles the two values and returns a single action being performed.
710
  *
711
- * @since BuddyPress (1.7.0)
712
  * @return string
713
  */
714
  function bp_admin_list_table_current_bulk_action() {
@@ -807,7 +786,7 @@ function bp_admin_do_wp_nav_menu_meta_box() {
807
  * - URL - This field is automatically generated by BP on output, so this
808
  * field is useless and can cause confusion.
809
  *
810
- * Note: These restrictions are only enforced if JavaScript is enabled.
811
  *
812
  * @since BuddyPress (1.9.0)
813
  */
@@ -909,7 +888,7 @@ function bp_core_admin_user_manage_spammers() {
909
  // Process the user
910
  bp_core_process_spammer_status( $user_id, $status );
911
 
912
- $redirect = add_query_arg( array( 'updated' => 'marked-' . $status ), $redirect );
913
 
914
  wp_redirect( $redirect );
915
  }
32
  * @global array $_parent_pages
33
  * @global array $_registered_pages
34
  * @global array $submenu
35
+ * @since BuddyPress (1.6)
36
  */
37
  function bp_core_admin_backpat_menu() {
38
  global $_parent_pages, $_registered_pages, $submenu;
71
  *
72
  * @global string $plugin_page
73
  * @global array $submenu
74
+ * @since BuddyPress (1.6)
75
  */
76
  function bp_core_modify_admin_menu_highlight() {
77
  global $plugin_page, $submenu_file;
93
  * will never appear.
94
  *
95
  * @see bp_core_admin_backpat_menu()
96
+ * @since BuddyPress (1.6)
97
  * @todo Add convenience links into the markup once new positions are finalised.
98
  */
99
  function bp_core_admin_backpat_page() {
105
  <h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
106
 
107
  <p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
108
+ <p><?php printf( __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%s">Settings &gt; BuddyPress</a>. Profile Fields has been moved into the <a href="%s">Users</a> menu.', 'buddypress' ), esc_url( $settings_url ), esc_url( bp_get_admin_url( 'users.php?page=bp-profile-setup' ) ) ); ?></p>
109
  </div>
110
 
111
  <?php
119
  * BuddyPress combines all its messages into a single notice, to avoid a preponderance of yellow
120
  * boxes.
121
  *
122
+ * @since BuddyPress (1.5)
123
  *
124
  * @uses bp_current_user_can() to check current user permissions before showing the notices
125
  * @uses bp_is_root_blog()
164
  * box. It is recommended that you hook this function to admin_init, so that your messages are
165
  * loaded in time.
166
  *
167
+ * @since BuddyPress (1.5)
168
  *
169
  * @param string $notice The notice you are adding to the queue.
170
  * @param string $type The notice type; optional. Usually either "updated" or "error".
199
  *
200
  * @global WPDB $wpdb WordPress DB object
201
  * @global WP_Rewrite $wp_rewrite
202
+ * @since BuddyPress (1.2)
203
  */
204
  function bp_core_activation_notice() {
205
  global $wp_rewrite, $wpdb;
329
  /**
330
  * Redirect user to BuddyPress's What's New page on activation
331
  *
332
+ * @since BuddyPress (1.7)
333
  *
334
  * @internal Used internally to redirect BuddyPress to the about page on activation
335
  *
370
  /**
371
  * Output the tabs in the admin area
372
  *
373
+ * @since BuddyPress (1.5)
374
  * @param string $active_tab Name of the tab that is active. Optional.
375
  */
376
  function bp_core_admin_tabs( $active_tab = '' ) {
377
  $tabs_html = '';
378
  $idle_class = 'nav-tab';
379
  $active_class = 'nav-tab nav-tab-active';
 
 
 
 
 
 
 
 
380
  $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) );
381
 
382
  // Loop through tabs and build navigation
387
  }
388
 
389
  echo $tabs_html;
 
 
 
 
 
 
390
  do_action( 'bp_admin_tabs' );
391
  }
392
 
428
  /**
429
  * Filters the tab data used in our wp-admin screens.
430
  *
 
 
431
  * @param array $tabs Tab data.
432
+ * @since BuddyPress (2.2.0)
433
  */
434
  return apply_filters( 'bp_core_get_admin_tabs', $tabs );
435
  }
439
  /**
440
  * adds contextual help to BuddyPress admin pages
441
  *
442
+ * @since BuddyPress (1.7)
443
  * @todo Make this part of the BP_Component class and split into each component
444
  */
445
  function bp_core_add_contextual_help( $screen = '' ) {
461
  // help panel - sidebar links
462
  $screen->set_help_sidebar(
463
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
464
+ '<p>' . __( '<a href="http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-components">Managing Components</a>', 'buddypress' ) . '</p>' .
465
+ '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
466
  );
467
  break;
468
 
479
  // Help panel - sidebar links
480
  $screen->set_help_sidebar(
481
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
482
+ '<p>' . __( '<a href="http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-pages">Managing Pages</a>', 'buddypress' ) . '</p>' .
483
+ '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
484
  );
485
 
486
  break;
498
  // Help panel - sidebar links
499
  $screen->set_help_sidebar(
500
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
501
+ '<p>' . __( '<a href="http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-settings">Managing Settings</a>', 'buddypress' ) . '</p>' .
502
+ '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
503
  );
504
 
505
  break;
517
  // Help panel - sidebar links
518
  $screen->set_help_sidebar(
519
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
520
+ '<p>' . __( '<a href="http://codex.buddypress.org/getting-started/configure-buddypress-components/#users-profile-fields">Managing Profile Fields</a>', 'buddypress' ) . '</p>' .
521
+ '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
522
  );
523
 
524
  break;
529
  /**
530
  * renders contextual help content to contextual help tabs
531
  *
532
+ * @since BuddyPress (1.7)
533
  */
534
  function bp_core_add_contextual_help_content( $tab = '' ) {
535
 
547
  break;
548
 
549
  case 'bp-profile-overview' :
550
+ $retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.</br></br>Note: Any fields in the first group will appear on the signup page.', 'buddypress' );
551
  break;
552
 
553
  default:
568
  /**
569
  * Add a separator to the WordPress admin menus
570
  *
571
+ * @since BuddyPress (1.7)
572
  *
573
  * @uses bp_current_user_can() To check users capability on root blog
574
  */
603
  /**
604
  * Tell WordPress we have a custom menu order
605
  *
606
+ * @since BuddyPress (1.7)
607
  *
608
  * @param bool $menu_order Menu order
609
  * @uses bp_current_user_can() To check users capability on root blog
622
  /**
623
  * Move our custom separator above our custom post types
624
  *
625
+ * @since BuddyPress (1.7)
626
  *
627
  * @param array $menu_order Menu Order
628
  * @uses bp_current_user_can() To check users capability on root blog
641
  // Menu values
642
  $last_sep = is_network_admin() ? 'separator1' : 'separator2';
643
 
644
+ // Filter the custom admin menus
 
 
 
 
 
 
645
  $custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() );
646
 
647
  // Bail if no components have top level admin pages
687
  * and the inputs have different keys in the $_REQUEST array. This function
688
  * reconciles the two values and returns a single action being performed.
689
  *
690
+ * @since BuddyPress (1.7)
691
  * @return string
692
  */
693
  function bp_admin_list_table_current_bulk_action() {
786
  * - URL - This field is automatically generated by BP on output, so this
787
  * field is useless and can cause confusion.
788
  *
789
+ * Note: These restrictions are only enforced if javascript is enabled.
790
  *
791
  * @since BuddyPress (1.9.0)
792
  */
888
  // Process the user
889
  bp_core_process_spammer_status( $user_id, $status );
890
 
891
+ $redirect = add_query_arg( array( 'updated' => 'marked-' . $status ), $redirect);
892
 
893
  wp_redirect( $redirect );
894
  }
bp-core/admin/{bp-core-admin-schema.php → bp-core-schema.php} RENAMED
@@ -38,12 +38,8 @@ function bp_core_set_charset() {
38
  */
39
  function bp_core_install( $active_components = false ) {
40
 
41
- bp_pre_schema_upgrade();
42
-
43
  // If no components passed, get all the active components from the main site
44
  if ( empty( $active_components ) ) {
45
-
46
- /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
47
  $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
48
  }
49
 
@@ -116,15 +112,6 @@ function bp_core_install_notifications() {
116
  KEY useritem (user_id,is_new)
117
  ) {$charset_collate};";
118
 
119
- $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications_meta (
120
- id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
121
- notification_id bigint(20) NOT NULL,
122
- meta_key varchar(255) DEFAULT NULL,
123
- meta_value longtext DEFAULT NULL,
124
- KEY notification_id (notification_id),
125
- KEY meta_key (meta_key(191))
126
- ) {$charset_collate};";
127
-
128
  dbDelta( $sql );
129
  }
130
 
@@ -175,7 +162,7 @@ function bp_core_install_activity_streams() {
175
  meta_key varchar(255) DEFAULT NULL,
176
  meta_value longtext DEFAULT NULL,
177
  KEY activity_id (activity_id),
178
- KEY meta_key (meta_key(191))
179
  ) {$charset_collate};";
180
 
181
  dbDelta( $sql );
@@ -263,7 +250,7 @@ function bp_core_install_groups() {
263
  meta_key varchar(255) DEFAULT NULL,
264
  meta_value longtext DEFAULT NULL,
265
  KEY group_id (group_id),
266
- KEY meta_key (meta_key(191))
267
  ) {$charset_collate};";
268
 
269
  dbDelta( $sql );
@@ -323,7 +310,7 @@ function bp_core_install_private_messaging() {
323
  meta_key varchar(255) DEFAULT NULL,
324
  meta_value longtext DEFAULT NULL,
325
  KEY message_id (message_id),
326
- KEY meta_key (meta_key(191))
327
  ) {$charset_collate};";
328
 
329
  dbDelta( $sql );
@@ -400,7 +387,7 @@ function bp_core_install_extended_profiles() {
400
  meta_key varchar(255) DEFAULT NULL,
401
  meta_value longtext DEFAULT NULL,
402
  KEY object_id (object_id),
403
- KEY meta_key (meta_key(191))
404
  ) {$charset_collate};";
405
 
406
  dbDelta( $sql );
@@ -447,7 +434,7 @@ function bp_core_install_blog_tracking() {
447
  meta_key varchar(255) DEFAULT NULL,
448
  meta_value longtext DEFAULT NULL,
449
  KEY blog_id (blog_id),
450
- KEY meta_key (meta_key(191))
451
  ) {$charset_collate};";
452
 
453
  dbDelta( $sql );
@@ -467,7 +454,7 @@ function bp_core_install_signups() {
467
  global $wpdb;
468
 
469
  // Signups is not there and we need it so let's create it
470
- require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
471
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
472
 
473
  // Never use bp_core_get_table_prefix() for any global users tables
38
  */
39
  function bp_core_install( $active_components = false ) {
40
 
 
 
41
  // If no components passed, get all the active components from the main site
42
  if ( empty( $active_components ) ) {
 
 
43
  $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
44
  }
45
 
112
  KEY useritem (user_id,is_new)
113
  ) {$charset_collate};";
114
 
 
 
 
 
 
 
 
 
 
115
  dbDelta( $sql );
116
  }
117
 
162
  meta_key varchar(255) DEFAULT NULL,
163
  meta_value longtext DEFAULT NULL,
164
  KEY activity_id (activity_id),
165
+ KEY meta_key (meta_key)
166
  ) {$charset_collate};";
167
 
168
  dbDelta( $sql );
250
  meta_key varchar(255) DEFAULT NULL,
251
  meta_value longtext DEFAULT NULL,
252
  KEY group_id (group_id),
253
+ KEY meta_key (meta_key)
254
  ) {$charset_collate};";
255
 
256
  dbDelta( $sql );
310
  meta_key varchar(255) DEFAULT NULL,
311
  meta_value longtext DEFAULT NULL,
312
  KEY message_id (message_id),
313
+ KEY meta_key (meta_key)
314
  ) {$charset_collate};";
315
 
316
  dbDelta( $sql );
387
  meta_key varchar(255) DEFAULT NULL,
388
  meta_value longtext DEFAULT NULL,
389
  KEY object_id (object_id),
390
+ KEY meta_key (meta_key)
391
  ) {$charset_collate};";
392
 
393
  dbDelta( $sql );
434
  meta_key varchar(255) DEFAULT NULL,
435
  meta_value longtext DEFAULT NULL,
436
  KEY blog_id (blog_id),
437
+ KEY meta_key (meta_key)
438
  ) {$charset_collate};";
439
 
440
  dbDelta( $sql );
454
  global $wpdb;
455
 
456
  // Signups is not there and we need it so let's create it
457
+ require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-schema.php' );
458
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
459
 
460
  // Never use bp_core_get_table_prefix() for any global users tables
bp-core/admin/{bp-core-admin-settings.php → bp-core-settings.php} RENAMED
@@ -13,14 +13,14 @@ defined( 'ABSPATH' ) || exit;
13
  /**
14
  * Main settings section description for the settings page
15
  *
16
- * @since BuddyPress (1.6.0)
17
  */
18
  function bp_admin_setting_callback_main_section() { }
19
 
20
  /**
21
  * Admin bar for logged out users setting field
22
  *
23
- * @since BuddyPress (1.6.0)
24
  *
25
  * @uses bp_form_option() To output the option value
26
  */
@@ -36,7 +36,7 @@ function bp_admin_setting_callback_admin_bar() {
36
  /**
37
  * Allow members to delete their accounts setting field
38
  *
39
- * @since BuddyPress (1.6.0)
40
  *
41
  * @uses checked() To display the checked attribute
42
  */
@@ -54,14 +54,14 @@ function bp_admin_setting_callback_account_deletion() {
54
  /**
55
  * Groups settings section description for the settings page
56
  *
57
- * @since BuddyPress (1.6.0)
58
  */
59
  function bp_admin_setting_callback_activity_section() { }
60
 
61
  /**
62
  * Allow Akismet setting field
63
  *
64
- * @since BuddyPress (1.6.0)
65
  *
66
  * @uses checked() To display the checked attribute
67
  */
@@ -77,7 +77,7 @@ function bp_admin_setting_callback_activity_akismet() {
77
  /**
78
  * Allow activity comments on blog posts and forum posts
79
  *
80
- * @since BuddyPress (1.6.0)
81
  */
82
  function bp_admin_setting_callback_blogforum_comments() {
83
  ?>
@@ -109,7 +109,7 @@ function bp_admin_setting_callback_heartbeat() {
109
  * legacy reasons, the option that we store is 1 if these comments are *disabled*. So we use this
110
  * function to flip the boolean before saving the intval.
111
  *
112
- * @since BuddyPress (1.6.0)
113
  */
114
  function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
115
  return $value ? 0 : 1;
@@ -120,14 +120,14 @@ function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
120
  /**
121
  * Profile settings section description for the settings page
122
  *
123
- * @since BuddyPress (1.6.0)
124
  */
125
  function bp_admin_setting_callback_xprofile_section() { }
126
 
127
  /**
128
  * Enable BP->WP profile syncing field
129
  *
130
- * @since BuddyPress (1.6.0)
131
  *
132
  * @uses bp_form_option() To output the option value
133
  */
@@ -143,7 +143,7 @@ function bp_admin_setting_callback_profile_sync() {
143
  /**
144
  * Allow members to upload avatars field
145
  *
146
- * @since BuddyPress (1.6.0)
147
  *
148
  * @uses checked() To display the checked attribute
149
  */
@@ -161,14 +161,14 @@ function bp_admin_setting_callback_avatar_uploads() {
161
  /**
162
  * Groups settings section description for the settings page
163
  *
164
- * @since BuddyPress (1.6.0)
165
  */
166
  function bp_admin_setting_callback_groups_section() { }
167
 
168
  /**
169
  * Allow all users to create groups field
170
  *
171
- * @since BuddyPress (1.6.0)
172
  *
173
  * @uses checked() To display the checked attribute
174
  */
@@ -182,31 +182,19 @@ function bp_admin_setting_callback_group_creation() {
182
  <?php
183
  }
184
 
185
- /**
186
- * 'Enable group avatars' field markup.
187
- *
188
- * @since BuddyPress (2.3.0)
189
- */
190
- function bp_admin_setting_callback_group_avatar_uploads() {
191
- ?>
192
- <input id="bp-disable-group-avatar-uploads" name="bp-disable-group-avatar-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_avatar_uploads() ); ?> />
193
- <label for="bp-disable-group-avatar-uploads"><?php _e( 'Allow customizable avatars for groups', 'buddypress' ); ?></label>
194
- <?php
195
- }
196
-
197
  /** Forums Section ************************************************************/
198
 
199
  /**
200
  * Forums settings section description for the settings page
201
  *
202
- * @since BuddyPress (1.6.0)
203
  */
204
  function bp_admin_setting_callback_bbpress_section() { }
205
 
206
  /**
207
  * bb-config.php location field
208
  *
209
- * @since BuddyPress (1.6.0)
210
  * @uses checked() To display the checked attribute
211
  * @uses bp_get_option() To get the config location
212
  * @uses bp_form_option() To get the sanitized form option
@@ -235,7 +223,7 @@ function bp_admin_setting_callback_bbpress_configuration() {
235
  /**
236
  * The main settings page
237
  *
238
- * @since BuddyPress (1.6.0)
239
  *
240
  * @uses screen_icon() To display the screen icon
241
  * @uses settings_fields() To output the hidden fields for the form
@@ -254,7 +242,7 @@ function bp_core_admin_settings() {
254
 
255
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Settings', 'buddypress' ) ); ?></h2>
256
 
257
- <form action="<?php echo esc_url( $form_action ) ?>" method="post">
258
 
259
  <?php settings_fields( 'buddypress' ); ?>
260
 
@@ -272,7 +260,7 @@ function bp_core_admin_settings() {
272
  /**
273
  * Save our settings
274
  *
275
- * @since BuddyPress (1.6.0)
276
  */
277
  function bp_core_admin_settings_save() {
278
  global $wp_settings_fields;
@@ -292,11 +280,10 @@ function bp_core_admin_settings_save() {
292
  }
293
  }
294
 
295
- // Some legacy options are not registered with the Settings API, or are reversed in the UI.
296
  $legacy_options = array(
297
  'bp-disable-account-deletion',
298
  'bp-disable-avatar-uploads',
299
- 'bp-disable-group-avatar-uploads',
300
  'bp_disable_blogforum_comments',
301
  'bp-disable-profile-sync',
302
  'bp_restrict_group_creation',
@@ -319,7 +306,7 @@ add_action( 'bp_admin_init', 'bp_core_admin_settings_save', 100 );
319
  /**
320
  * Output settings API option
321
  *
322
- * @since BuddyPress (1.6.0)
323
  *
324
  * @uses bp_get_bp_form_option()
325
  *
@@ -333,7 +320,7 @@ function bp_form_option( $option, $default = '' , $slug = false ) {
333
  /**
334
  * Return settings API option
335
  *
336
- * @since BuddyPress (1.6.0)
337
  *
338
  * @uses bp_get_option()
339
  * @uses esc_attr()
@@ -349,31 +336,17 @@ function bp_form_option( $option, $default = '' , $slug = false ) {
349
  $value = bp_get_option( $option, $default );
350
 
351
  // Slug?
352
- if ( true === $slug ) {
353
-
354
- /**
355
- * Filters the slug value in the form field.
356
- *
357
- * @since BuddyPress (1.6.0)
358
- *
359
- * @param string $value Value being returned for the requested option.
360
- */
361
  $value = esc_attr( apply_filters( 'editable_slug', $value ) );
362
- } else { // Not a slug
 
 
363
  $value = esc_attr( $value );
364
- }
365
 
366
  // Fallback to default
367
  if ( empty( $value ) )
368
  $value = $default;
369
 
370
- /**
371
- * Filters the settings API option.
372
- *
373
- * @since BuddyPress (1.6.0)
374
- *
375
- * @param string $value Value being returned for the requested option.
376
- * @param string $option Option whose value is being requested.
377
- */
378
  return apply_filters( 'bp_get_form_option', $value, $option );
379
  }
13
  /**
14
  * Main settings section description for the settings page
15
  *
16
+ * @since BuddyPress (1.6)
17
  */
18
  function bp_admin_setting_callback_main_section() { }
19
 
20
  /**
21
  * Admin bar for logged out users setting field
22
  *
23
+ * @since BuddyPress (1.6)
24
  *
25
  * @uses bp_form_option() To output the option value
26
  */
36
  /**
37
  * Allow members to delete their accounts setting field
38
  *
39
+ * @since BuddyPress (1.6)
40
  *
41
  * @uses checked() To display the checked attribute
42
  */
54
  /**
55
  * Groups settings section description for the settings page
56
  *
57
+ * @since BuddyPress (1.6)
58
  */
59
  function bp_admin_setting_callback_activity_section() { }
60
 
61
  /**
62
  * Allow Akismet setting field
63
  *
64
+ * @since BuddyPress (1.6)
65
  *
66
  * @uses checked() To display the checked attribute
67
  */
77
  /**
78
  * Allow activity comments on blog posts and forum posts
79
  *
80
+ * @since BuddyPress (1.6)
81
  */
82
  function bp_admin_setting_callback_blogforum_comments() {
83
  ?>
109
  * legacy reasons, the option that we store is 1 if these comments are *disabled*. So we use this
110
  * function to flip the boolean before saving the intval.
111
  *
112
+ * @since BuddyPress (1.6)
113
  */
114
  function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
115
  return $value ? 0 : 1;
120
  /**
121
  * Profile settings section description for the settings page
122
  *
123
+ * @since BuddyPress (1.6)
124
  */
125
  function bp_admin_setting_callback_xprofile_section() { }
126
 
127
  /**
128
  * Enable BP->WP profile syncing field
129
  *
130
+ * @since BuddyPress (1.6)
131
  *
132
  * @uses bp_form_option() To output the option value
133
  */
143
  /**
144
  * Allow members to upload avatars field
145
  *
146
+ * @since BuddyPress (1.6)
147
  *
148
  * @uses checked() To display the checked attribute
149
  */
161
  /**
162
  * Groups settings section description for the settings page
163
  *
164
+ * @since BuddyPress (1.6)
165
  */
166
  function bp_admin_setting_callback_groups_section() { }
167
 
168
  /**
169
  * Allow all users to create groups field
170
  *
171
+ * @since BuddyPress (1.6)
172
  *
173
  * @uses checked() To display the checked attribute
174
  */
182
  <?php
183
  }
184
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  /** Forums Section ************************************************************/
186
 
187
  /**
188
  * Forums settings section description for the settings page
189
  *
190
+ * @since BuddyPress (1.6)
191
  */
192
  function bp_admin_setting_callback_bbpress_section() { }
193
 
194
  /**
195
  * bb-config.php location field
196
  *
197
+ * @since BuddyPress (1.6)
198
  * @uses checked() To display the checked attribute
199
  * @uses bp_get_option() To get the config location
200
  * @uses bp_form_option() To get the sanitized form option
223
  /**
224
  * The main settings page
225
  *
226
+ * @since BuddyPress (1.6)
227
  *
228
  * @uses screen_icon() To display the screen icon
229
  * @uses settings_fields() To output the hidden fields for the form
242
 
243
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Settings', 'buddypress' ) ); ?></h2>
244
 
245
+ <form action="<?php echo esc_url( $form_action ); ?>" method="post">
246
 
247
  <?php settings_fields( 'buddypress' ); ?>
248
 
260
  /**
261
  * Save our settings
262
  *
263
+ * @since BuddyPress (1.6)
264
  */
265
  function bp_core_admin_settings_save() {
266
  global $wp_settings_fields;
280
  }
281
  }
282
 
283
+ // Some legacy options are not registered with the Settings API
284
  $legacy_options = array(
285
  'bp-disable-account-deletion',
286
  'bp-disable-avatar-uploads',
 
287
  'bp_disable_blogforum_comments',
288
  'bp-disable-profile-sync',
289
  'bp_restrict_group_creation',
306
  /**
307
  * Output settings API option
308
  *
309
+ * @since BuddyPress (1.6)
310
  *
311
  * @uses bp_get_bp_form_option()
312
  *
320
  /**
321
  * Return settings API option
322
  *
323
+ * @since BuddyPress (1.6)
324
  *
325
  * @uses bp_get_option()
326
  * @uses esc_attr()
336
  $value = bp_get_option( $option, $default );
337
 
338
  // Slug?
339
+ if ( true === $slug )
 
 
 
 
 
 
 
 
340
  $value = esc_attr( apply_filters( 'editable_slug', $value ) );
341
+
342
+ // Not a slug
343
+ else
344
  $value = esc_attr( $value );
 
345
 
346
  // Fallback to default
347
  if ( empty( $value ) )
348
  $value = $default;
349
 
350
+ // Allow plugins to further filter the output
 
 
 
 
 
 
 
351
  return apply_filters( 'bp_get_form_option', $value, $option );
352
  }
bp-core/admin/{bp-core-admin-slugs.php → bp-core-slugs.php} RENAMED
@@ -13,7 +13,7 @@ defined( 'ABSPATH' ) || exit;
13
  /**
14
  * Renders the page mapping admin panel.
15
  *
16
- * @since BuddyPress (1.6.0)
17
  * @todo Use settings API
18
  * @uses bp_core_admin_component_options()
19
  */
@@ -44,11 +44,11 @@ function bp_core_admin_slugs_settings() {
44
  * Creates reusable markup for page setup on the Components and Pages dashboard panel.
45
  *
46
  * @package BuddyPress
47
- * @since BuddyPress (1.6.0)
48
  * @todo Use settings API
49
  */
50
  function bp_core_admin_slugs_options() {
51
- $bp = buddypress();
52
 
53
  // Get the existing WP pages
54
  $existing_pages = bp_core_get_directory_page_ids();
@@ -72,13 +72,6 @@ function bp_core_admin_slugs_options() {
72
 
73
  /** Directory Display *****************************************************/
74
 
75
- /**
76
- * Filters the loaded components needing directory page association to a WordPress page.
77
- *
78
- * @since BuddyPress (1.5.0)
79
- *
80
- * @param array $directory_pages Array of available components to set associations for.
81
- */
82
  $directory_pages = apply_filters( 'bp_directory_pages', $directory_pages );
83
 
84
  if ( !empty( $directory_pages ) ) : ?>
@@ -122,16 +115,7 @@ function bp_core_admin_slugs_options() {
122
 
123
  <?php endforeach ?>
124
 
125
- <?php
126
-
127
- /**
128
- * Fires after the display of default directories.
129
- *
130
- * Allows plugins to add their own directory associations.
131
- *
132
- * @since BuddyPress (1.5.0)
133
- */
134
- do_action( 'bp_active_external_directories' ); ?>
135
 
136
  </tbody>
137
  </table>
@@ -148,13 +132,6 @@ function bp_core_admin_slugs_options() {
148
  'activate' => __( 'Activate', 'buddypress' ),
149
  );
150
 
151
- /**
152
- * Filters the default static pages for BuddyPress setup.
153
- *
154
- * @since BuddyPress (1.6.0)
155
- *
156
- * @param array $static_pages Array of static default static pages.
157
- */
158
  $static_pages = apply_filters( 'bp_static_pages', $static_pages );
159
 
160
  if ( !empty( $static_pages ) ) : ?>
@@ -197,14 +174,7 @@ function bp_core_admin_slugs_options() {
197
 
198
  <?php endforeach ?>
199
 
200
- <?php
201
-
202
- /**
203
- * Fires after the display of default static pages for BuddyPress setup.
204
- *
205
- * @since BuddyPress (1.5.0)
206
- */
207
- do_action( 'bp_active_external_pages' ); ?>
208
 
209
  </tbody>
210
  </table>
@@ -216,7 +186,7 @@ function bp_core_admin_slugs_options() {
216
  /**
217
  * Handle saving of the BuddyPress slugs
218
  *
219
- * @since BuddyPress (1.6.0)
220
  * @todo Use settings API
221
  */
222
  function bp_core_admin_slugs_setup_handler() {
13
  /**
14
  * Renders the page mapping admin panel.
15
  *
16
+ * @since BuddyPress (1.6)
17
  * @todo Use settings API
18
  * @uses bp_core_admin_component_options()
19
  */
44
  * Creates reusable markup for page setup on the Components and Pages dashboard panel.
45
  *
46
  * @package BuddyPress
47
+ * @since BuddyPress (1.6)
48
  * @todo Use settings API
49
  */
50
  function bp_core_admin_slugs_options() {
51
+ global $bp;
52
 
53
  // Get the existing WP pages
54
  $existing_pages = bp_core_get_directory_page_ids();
72
 
73
  /** Directory Display *****************************************************/
74
 
 
 
 
 
 
 
 
75
  $directory_pages = apply_filters( 'bp_directory_pages', $directory_pages );
76
 
77
  if ( !empty( $directory_pages ) ) : ?>
115
 
116
  <?php endforeach ?>
117
 
118
+ <?php do_action( 'bp_active_external_directories' ); ?>
 
 
 
 
 
 
 
 
 
119
 
120
  </tbody>
121
  </table>
132
  'activate' => __( 'Activate', 'buddypress' ),
133
  );
134
 
 
 
 
 
 
 
 
135
  $static_pages = apply_filters( 'bp_static_pages', $static_pages );
136
 
137
  if ( !empty( $static_pages ) ) : ?>
174
 
175
  <?php endforeach ?>
176
 
177
+ <?php do_action( 'bp_active_external_pages' ); ?>
 
 
 
 
 
 
 
178
 
179
  </tbody>
180
  </table>
186
  /**
187
  * Handle saving of the BuddyPress slugs
188
  *
189
+ * @since BuddyPress (1.6)
190
  * @todo Use settings API
191
  */
192
  function bp_core_admin_slugs_setup_handler() {
bp-core/admin/{bp-core-admin-tools.php → bp-core-tools.php} RENAMED
@@ -144,13 +144,6 @@ function bp_admin_repair_list() {
144
 
145
  ksort( $repair_list );
146
 
147
- /**
148
- * Filters the array of the repair list.
149
- *
150
- * @since BuddyPress (2.0.0)
151
- *
152
- * @param array $repair_list Array of values for the Repair list options.
153
- */
154
  return (array) apply_filters( 'bp_repair_list', $repair_list );
155
  }
156
 
@@ -162,7 +155,7 @@ function bp_admin_repair_list() {
162
  * @return array
163
  */
164
  function bp_admin_repair_friend_count() {
165
- global $wpdb;
166
 
167
  if ( ! bp_is_active( 'friends' ) ) {
168
  return;
@@ -176,8 +169,6 @@ function bp_admin_repair_friend_count() {
176
  return array( 1, sprintf( $statement, $result ) );
177
  }
178
 
179
- $bp = buddypress();
180
-
181
  // Walk through all users on the site
182
  $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
183
 
@@ -220,7 +211,7 @@ function bp_admin_repair_friend_count() {
220
  * @return array
221
  */
222
  function bp_admin_repair_group_count() {
223
- global $wpdb;
224
 
225
  if ( ! bp_is_active( 'groups' ) ) {
226
  return;
@@ -234,8 +225,6 @@ function bp_admin_repair_group_count() {
234
  return array( 1, sprintf( $statement, $result ) );
235
  }
236
 
237
- $bp = buddypress();
238
-
239
  // Walk through all users on the site
240
  $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
241
 
@@ -371,14 +360,7 @@ function bp_core_admin_available_tools_page() {
371
  <div class="wrap">
372
  <h2><?php esc_attr_e( 'Tools', 'buddypress' ) ?></h2>
373
 
374
- <?php
375
-
376
- /**
377
- * Fires inside the markup used to display the Available Tools page.
378
- *
379
- * @since BuddyPress (2.0.0)
380
- */
381
- do_action( 'bp_network_tool_box' ); ?>
382
 
383
  </div>
384
  <?php
@@ -397,8 +379,8 @@ function bp_core_admin_available_tools_intro() {
397
  $page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php' ;
398
  $url = add_query_arg( $query_arg, bp_get_admin_url( $page ) );
399
  ?>
400
- <div class="card tool-box">
401
- <h3><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h3>
402
  <p>
403
  <?php esc_html_e( 'BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?>
404
  <?php printf( esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ), '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Tools', 'buddypress' ) . '</a>' ); ?>
144
 
145
  ksort( $repair_list );
146
 
 
 
 
 
 
 
 
147
  return (array) apply_filters( 'bp_repair_list', $repair_list );
148
  }
149
 
155
  * @return array
156
  */
157
  function bp_admin_repair_friend_count() {
158
+ global $wpdb, $bp;
159
 
160
  if ( ! bp_is_active( 'friends' ) ) {
161
  return;
169
  return array( 1, sprintf( $statement, $result ) );
170
  }
171
 
 
 
172
  // Walk through all users on the site
173
  $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
174
 
211
  * @return array
212
  */
213
  function bp_admin_repair_group_count() {
214
+ global $wpdb, $bp;
215
 
216
  if ( ! bp_is_active( 'groups' ) ) {
217
  return;
225
  return array( 1, sprintf( $statement, $result ) );
226
  }
227
 
 
 
228
  // Walk through all users on the site
229
  $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
230
 
360
  <div class="wrap">
361
  <h2><?php esc_attr_e( 'Tools', 'buddypress' ) ?></h2>
362
 
363
+ <?php do_action( 'bp_network_tool_box' ); ?>
 
 
 
 
 
 
 
364
 
365
  </div>
366
  <?php
379
  $page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php' ;
380
  $url = add_query_arg( $query_arg, bp_get_admin_url( $page ) );
381
  ?>
382
+ <div class="tool-box">
383
+ <h3 class="title"><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h3>
384
  <p>
385
  <?php esc_html_e( 'BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?>
386
  <?php printf( esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ), '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Tools', 'buddypress' ) . '</a>' ); ?>
bp-core/admin/css/common-rtl.css CHANGED
@@ -24,48 +24,6 @@ body.index_page_bp-about span.dashicons {
24
  text-align: center;
25
  }
26
 
27
- /* About Page - since 2.3.3 (WP 4.3) */
28
-
29
- .about-wrap .two-col > div {
30
- position: relative;
31
- width: 47.6%;
32
- margin-left: 4.799999999%;
33
- float: right;
34
- }
35
-
36
- .about-wrap [class$=col] .last-feature {
37
- margin-left: 0;
38
- }
39
-
40
- .about-wrap .feature-list.finer-points h4,
41
- .about-wrap .feature-list.finer-points p {
42
- margin-right: 115px;
43
- }
44
-
45
- @media screen and ( max-width: 782px ) {
46
- .about-wrap .two-col > div {
47
- width: 100%;
48
- margin: 30px 0 0;
49
- padding: 0 0 30px;
50
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
51
- }
52
- body.dashboard_page_bp-about span.dashicons,
53
- body.index_page_bp-about span.dashicons {
54
- font-size: 55px;
55
- line-height: 70px;
56
- height: 70px;
57
- width: 70px;
58
- }
59
- .about-wrap .feature-list h2 {
60
- margin: 30px 0 0;
61
- text-align: center;
62
- }
63
- .about-wrap .feature-list.finer-points h4,
64
- .about-wrap .feature-list.finer-points p {
65
- margin-right: 90px;
66
- }
67
- }
68
-
69
  /* User's Lists
70
  ------------------------------------------------------------------------------*/
71
 
@@ -459,17 +417,6 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
459
  left: 0;
460
  }
461
 
462
- /* About Page - since 2.3.3 (WP 4.3) */
463
-
464
- @media only screen and (max-width: 500px) {
465
- .about-wrap .bp-badge {
466
- position: relative;
467
- margin: 10px auto;
468
- top: auto;
469
- left: auto;
470
- }
471
- }
472
-
473
  /* HiDPI
474
  ------------------------------------------------------------------------------*/
475
 
24
  text-align: center;
25
  }
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  /* User's Lists
28
  ------------------------------------------------------------------------------*/
29
 
417
  left: 0;
418
  }
419
 
 
 
 
 
 
 
 
 
 
 
 
420
  /* HiDPI
421
  ------------------------------------------------------------------------------*/
422
 
bp-core/admin/css/common-rtl.min.css CHANGED
@@ -1 +1 @@
1
- body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:right;clear:right;margin:15px 0 0 15px;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}.about-wrap .two-col>div{position:relative;width:47.6%;margin-left:4.799999999%;float:right}.about-wrap [class$=col] .last-feature{margin-left:0}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-right:115px}@media screen and (max-width:782px){.about-wrap .two-col>div{width:100%;margin:30px 0 0;padding:0 0 30px;border-bottom:1px solid rgba(0,0,0,.1)}body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{font-size:55px;line-height:70px;height:70px;width:70px}.about-wrap .feature-list h2{margin:30px 0 0;text-align:center}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-right:90px}}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:right;width:18px;height:18px;margin-left:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;left:0}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;left:auto}}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
1
+ body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:right;clear:right;margin:15px 0 0 15px;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:right;width:18px;height:18px;margin-left:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;left:0}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
bp-core/admin/css/common.css CHANGED
@@ -24,48 +24,6 @@ body.index_page_bp-about span.dashicons {
24
  text-align: center;
25
  }
26
 
27
- /* About Page - since 2.3.3 (WP 4.3) */
28
-
29
- .about-wrap .two-col > div {
30
- position: relative;
31
- width: 47.6%;
32
- margin-right: 4.799999999%;
33
- float: left;
34
- }
35
-
36
- .about-wrap [class$=col] .last-feature {
37
- margin-right: 0;
38
- }
39
-
40
- .about-wrap .feature-list.finer-points h4,
41
- .about-wrap .feature-list.finer-points p {
42
- margin-left: 115px;
43
- }
44
-
45
- @media screen and ( max-width: 782px ) {
46
- .about-wrap .two-col > div {
47
- width: 100%;
48
- margin: 30px 0 0;
49
- padding: 0 0 30px;
50
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
51
- }
52
- body.dashboard_page_bp-about span.dashicons,
53
- body.index_page_bp-about span.dashicons {
54
- font-size: 55px;
55
- line-height: 70px;
56
- height: 70px;
57
- width: 70px;
58
- }
59
- .about-wrap .feature-list h2 {
60
- margin: 30px 0 0;
61
- text-align: center;
62
- }
63
- .about-wrap .feature-list.finer-points h4,
64
- .about-wrap .feature-list.finer-points p {
65
- margin-left: 90px;
66
- }
67
- }
68
-
69
  /* User's Lists
70
  ------------------------------------------------------------------------------*/
71
 
@@ -459,17 +417,6 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
459
  right: 0;
460
  }
461
 
462
- /* About Page - since 2.3.3 (WP 4.3) */
463
-
464
- @media only screen and (max-width: 500px) {
465
- .about-wrap .bp-badge {
466
- position: relative;
467
- margin: 10px auto;
468
- top: auto;
469
- right: auto;
470
- }
471
- }
472
-
473
  /* HiDPI
474
  ------------------------------------------------------------------------------*/
475
 
24
  text-align: center;
25
  }
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  /* User's Lists
28
  ------------------------------------------------------------------------------*/
29
 
417
  right: 0;
418
  }
419
 
 
 
 
 
 
 
 
 
 
 
 
420
  /* HiDPI
421
  ------------------------------------------------------------------------------*/
422
 
bp-core/admin/css/common.min.css CHANGED
@@ -1 +1 @@
1
- body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:left;clear:left;margin:15px 15px 0 0;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}.about-wrap .two-col>div{position:relative;width:47.6%;margin-right:4.799999999%;float:left}.about-wrap [class$=col] .last-feature{margin-right:0}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-left:115px}@media screen and (max-width:782px){.about-wrap .two-col>div{width:100%;margin:30px 0 0;padding:0 0 30px;border-bottom:1px solid rgba(0,0,0,.1)}body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{font-size:55px;line-height:70px;height:70px;width:70px}.about-wrap .feature-list h2{margin:30px 0 0;text-align:center}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-left:90px}}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:left;width:18px;height:18px;margin-right:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;right:0}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;right:auto}}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
1
+ body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:left;clear:left;margin:15px 15px 0 0;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:left;width:18px;height:18px;margin-right:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;right:0}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
bp-core/admin/images/avatar-ui.gif DELETED
Binary file
bp-core/admin/images/member-types.png ADDED
Binary file
bp-core/bp-core-actions.php CHANGED
@@ -55,7 +55,6 @@ add_action( 'bp_loaded', 'bp_setup_components', 2 );
55
  add_action( 'bp_loaded', 'bp_include', 4 );
56
  add_action( 'bp_loaded', 'bp_setup_cache_groups', 5 );
57
  add_action( 'bp_loaded', 'bp_setup_widgets', 6 );
58
- add_action( 'bp_loaded', 'bp_register_member_types', 8 );
59
  add_action( 'bp_loaded', 'bp_register_theme_packages', 12 );
60
  add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
61
 
55
  add_action( 'bp_loaded', 'bp_include', 4 );
56
  add_action( 'bp_loaded', 'bp_setup_cache_groups', 5 );
57
  add_action( 'bp_loaded', 'bp_setup_widgets', 6 );
 
58
  add_action( 'bp_loaded', 'bp_register_theme_packages', 12 );
59
  add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
60
 
bp-core/bp-core-admin.php CHANGED
@@ -16,7 +16,6 @@ if ( !class_exists( 'BP_Admin' ) ) :
16
  *
17
  * @package BuddyPress
18
  * @subpackage CoreAdministration
19
- * @todo Break this apart into each applicable Component
20
  *
21
  * @since BuddyPress (1.6.0)
22
  */
@@ -117,12 +116,12 @@ class BP_Admin {
117
  * @access private
118
  */
119
  private function includes() {
120
- require( $this->admin_dir . 'bp-core-admin-actions.php' );
121
- require( $this->admin_dir . 'bp-core-admin-settings.php' );
122
- require( $this->admin_dir . 'bp-core-admin-functions.php' );
123
- require( $this->admin_dir . 'bp-core-admin-components.php' );
124
- require( $this->admin_dir . 'bp-core-admin-slugs.php' );
125
- require( $this->admin_dir . 'bp-core-admin-tools.php' );
126
  }
127
 
128
  /**
@@ -159,7 +158,7 @@ class BP_Admin {
159
  add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 15 );
160
 
161
  // Add a description of new BuddyPress tools in the available tools page
162
- add_action( 'tool_box', 'bp_core_admin_available_tools_intro' );
163
  add_action( 'bp_network_tool_box', 'bp_core_admin_available_tools_intro' );
164
 
165
  // On non-multisite, catch
@@ -179,7 +178,7 @@ class BP_Admin {
179
  /**
180
  * Add the navigational menu elements.
181
  *
182
- * @since BuddyPress (1.6.0)
183
  *
184
  * @uses add_management_page() To add the Recount page in Tools section.
185
  * @uses add_options_page() To add the Forums settings page in Settings
@@ -315,11 +314,11 @@ class BP_Admin {
315
  /** Main Section ******************************************************/
316
 
317
  // Add the main section
318
- add_settings_section( 'bp_main', __( 'Main Settings', 'buddypress' ), 'bp_admin_setting_callback_main_section', 'buddypress' );
319
 
320
  // Hide toolbar for logged out users setting
321
- add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
322
- register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
323
 
324
  // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade
325
  if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) {
@@ -329,7 +328,7 @@ class BP_Admin {
329
 
330
  // Allow account deletion
331
  add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
332
- register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
333
 
334
  /** XProfile Section **************************************************/
335
 
@@ -338,12 +337,11 @@ class BP_Admin {
338
  // Add the main section
339
  add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
340
 
341
- add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' );
342
- register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
343
 
344
  // Profile sync setting
345
- add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
346
- register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
347
  }
348
 
349
  /** Groups Section ****************************************************/
@@ -351,15 +349,15 @@ class BP_Admin {
351
  if ( bp_is_active( 'groups' ) ) {
352
 
353
  // Add the main section
354
- add_settings_section( 'bp_groups', __( 'Groups Settings', 'buddypress' ), 'bp_admin_setting_callback_groups_section', 'buddypress' );
355
 
356
- // Allow subscriptions setting
357
- add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation', 'buddypress' ), 'bp_admin_setting_callback_group_creation', 'buddypress', 'bp_groups' );
358
- register_setting( 'buddypress', 'bp_restrict_group_creation', 'intval' );
359
 
360
- // Allow group avatars.
361
- add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' );
362
- register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' );
363
  }
364
 
365
  /** Forums ************************************************************/
@@ -367,11 +365,11 @@ class BP_Admin {
367
  if ( bp_is_active( 'forums' ) ) {
368
 
369
  // Add the main section
370
- add_settings_section( 'bp_forums', __( 'Legacy Group Forums', 'buddypress' ), 'bp_admin_setting_callback_bbpress_section', 'buddypress' );
371
 
372
  // Allow subscriptions setting
373
  add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' );
374
- register_setting( 'buddypress', 'bb-config-location', '' );
375
  }
376
 
377
  /** Activity Section **************************************************/
@@ -379,7 +377,7 @@ class BP_Admin {
379
  if ( bp_is_active( 'activity' ) ) {
380
 
381
  // Add the main section
382
- add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' );
383
 
384
  // Activity commenting on blog and forum posts
385
  add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog &amp; Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' );
@@ -391,10 +389,18 @@ class BP_Admin {
391
 
392
  // Allow activity akismet
393
  if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) {
394
- add_settings_field( '_bp_enable_akismet', __( 'Akismet', 'buddypress' ), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity' );
395
- register_setting( 'buddypress', '_bp_enable_akismet', 'intval' );
396
  }
397
  }
 
 
 
 
 
 
 
 
398
  }
399
 
400
  /**
@@ -466,14 +472,6 @@ class BP_Admin {
466
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
467
 
468
  $file = $this->css_url . "common{$min}.css";
469
-
470
- /**
471
- * Filters the BuddyPress Core Admin CSS file path.
472
- *
473
- * @since BuddyPress (1.6.0)
474
- *
475
- * @param string $file File path for the admin CSS.
476
- */
477
  $file = apply_filters( 'bp_core_admin_common_css', $file );
478
  wp_enqueue_style( 'bp-admin-common-css', $file, array(), bp_get_version() );
479
 
@@ -506,7 +504,7 @@ class BP_Admin {
506
  <h3 style="margin:0"><?php _e( 'Getting Started with BuddyPress', 'buddypress' ); ?></h3>
507
  <div class="welcome-panel-column-container">
508
  <div class="welcome-panel-column">
509
- <h4><?php _e( 'Configure BuddyPress', 'buddypress' ); ?></h4>
510
  <ul>
511
  <li><?php printf(
512
  '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Set Up Components', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) ) )
@@ -539,84 +537,88 @@ class BP_Admin {
539
  </div>
540
  <div class="welcome-panel-column welcome-panel-last">
541
  <h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
542
- <p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Looking for help? The <a href="https://codex.buddypress.org/">BuddyPress Codex</a> has you covered.', 'buddypress' ) ?></p>
543
- <p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Can&#8217;t find what you need? Stop by <a href="https://buddypress.org/support/">our support forums</a>, where active BuddyPress users and developers are waiting to share tips and more.', 'buddypress' ) ?></p>
544
  </div>
545
  </div>
546
  </div>
547
  </div>
548
 
549
- <?php endif; ?>
550
 
551
- <div class="headline-feature">
552
- <h3><?php esc_html_e( 'Upload Profile Pictures with Drag and Drop', 'buddypress' ); ?></h3>
553
 
 
 
554
  <div class="featured-image">
555
- <img src="<?php echo esc_url( buddypress()->plugin_url . 'bp-core/admin/images/avatar-ui.gif' ); ?>" alt="<?php esc_attr_e( 'Revamped Profile Picture Upload UI', 'buddypress' ); ?>">
556
  </div>
557
 
558
  <div class="feature-section">
559
- <h3><?php esc_html_e( 'Built with the Attachments API, the new foundation for BuddyPress media management.', 'buddypress' ); ?></h3>
560
- <p><?php esc_html_e( 'You can drag and drop any image you choose to upload as your profile photo. The interface is mobile-ready and now includes integration with phone and laptop cameras. This is an example of what can be developed using the new Attachments API, the long-awaited foundation for media-related BuddyPress components and features.', 'buddypress' ); ?> <a href="https://codex.buddypress.org/plugindev/bp_attachment/"><?php esc_html_e( 'Learn more &rarr;', 'buddypress' ); ?></a></p>
 
 
561
  </div>
562
 
563
  <div class="clear"></div>
564
  </div>
565
 
566
- <div class="feature-list finer-points">
 
 
567
  <h2><?php esc_html_e( 'The Finer Points', 'buddypress' ); ?></h2>
568
 
569
  <div class="feature-section col two-col">
570
  <div>
571
- <span class=" dashicons dashicons-admin-users"></span>
572
- <h4><?php esc_html_e( 'Member Type Directories', 'buddypress' ); ?></h4>
573
- <p><?php esc_html_e( 'Create directories of member types in your site using the Member Type API.', 'buddypress' ); ?></p>
574
  </div>
575
 
576
  <div class="template-pack last-feature">
577
  <span class=" dashicons dashicons-admin-appearance"></span>
578
- <h4><?php esc_html_e( 'Companion Stylesheets For Themes', 'buddypress' ); ?></h4>
579
- <p><?php esc_html_e( 'Improved styling and integration of BuddyPress components with bundled WordPress themes, Twenty Fifteen and Twenty Fourteen.', 'buddypress' ); ?></p>
580
  </div>
581
 
582
  <div class="group-invites">
583
- <span class=" dashicons dashicons-admin-post"></span>
584
- <h4><?php esc_html_e( 'Blog Post Activity', 'buddypress' ); ?></h4>
585
- <p><?php esc_html_e( 'BuddyPress now generates better excerpts in the activity streams for posts containing images or other embedded media content.', 'buddypress' ); ?></p>
586
  </div>
587
 
588
  <div class="last-feature">
589
- <span class=" dashicons dashicons-star-filled"></span>
590
- <h4><?php esc_html_e( 'Star Private Messages ', 'buddypress' ); ?></h4>
591
- <p><?php esc_html_e( 'Mark important messages in your inbox from your friends with a star.', 'buddypress' ); ?></p>
592
  </div>
593
  </div>
594
  </div>
595
 
596
- <div class="feature-list">
 
 
597
  <h2><?php esc_html_e( 'Under the Hood', 'buddypress' ); ?></h2>
598
 
599
  <div class="feature-section col two-col">
600
  <div>
601
- <h4><?php esc_html_e( 'Components can register new features', 'buddypress' ); ?></h4>
602
- <p><?php _e( 'Plugin developers can register new features or check if a component feature is registered using the <code>BP_Component</code> class.', 'buddypress' ); ?></p>
603
 
604
  <h4><?php esc_html_e( 'Cache Improvements', 'buddypress' ); ?></h4>
605
- <p><?php esc_html_e( 'Improved caching for the following components: Messages, Profiles, Members &amp; Member Types, and Friends.', 'buddypress' ); ?></p>
606
  </div>
607
  <div class="last-feature">
608
  <h4><?php esc_html_e( 'Developer Reference', 'buddypress' ); ?></h4>
609
  <p><?php esc_html_e( 'Continued improvements to inline code documentation make it easier for developers to understand how BuddyPress works.', 'buddypress' ); ?></p>
610
 
611
- <h4><?php esc_html_e( 'User Documentation', 'buddypress' ); ?></h4>
612
- <p><?php esc_html_e( 'The BuddyPress Codex is maintained and updated regularly with new articles and tutorials.', 'buddypress' ); ?></p>
613
  </div>
614
  </div>
615
  </div>
616
 
617
- <p><?php _ex( 'Learn more:', 'About screen, website links', 'buddypress' ); ?> <a href="https://buddypress.org/blog/"><?php _ex( 'News', 'About screen, link to project blog', 'buddypress' ); ?></a> &bullet; <a href="https://buddypress.org/suppport/"><?php _ex( 'Support', 'About screen, link to support site', 'buddypress' ); ?></a> &bullet; <a href="https://codex.buddypress.org/"><?php _ex( 'Documentation', 'About screen, link to documentation', 'buddypress' ); ?></a> &bullet; <a href="https://bpdevel.wordpress.com/"><?php _ex( 'Development Blog', 'About screen, link to development blog', 'buddypress' ); ?></a></p>
618
- <p><?php _ex( 'Twitter:', 'official Twitter accounts:', 'buddypress' ); ?> <a href="https://twitter.com/buddypress/"><?php _ex( 'BuddyPress', '@buddypress twitter account name', 'buddypress' ); ?></a> &bullet; <a href="https://twitter.com/bptrac/"><?php _ex( 'Trac', '@bptrac twitter account name', 'buddypress' ); ?></a> &bullet; <a href="https://twitter.com/buddypressdev/"><?php _ex( 'Development', '@buddypressdev twitter account name', 'buddypress' ); ?></a></p>
619
-
620
  <?php
621
  }
622
 
@@ -642,18 +644,18 @@ class BP_Admin {
642
  <h4 class="wp-people-group"><?php _e( 'Project Leaders', 'buddypress' ); ?></h4>
643
  <ul class="wp-people-group " id="wp-people-group-project-leaders">
644
  <li class="wp-person" id="wp-person-johnjamesjacoby">
645
- <a href="https://profiles.wordpress.org/johnjamesjacoby"><img src="//www.gravatar.com/avatar/81ec16063d89b162d55efe72165c105f?s=60" class="gravatar" alt="John James Jacoby" /></a>
646
- <a class="web" href="https://profiles.wordpress.org/johnjamesjacoby">John James Jacoby</a>
647
  <span class="title"><?php _e( 'Project Lead', 'buddypress' ); ?></span>
648
  </li>
649
  <li class="wp-person" id="wp-person-boonebgorges">
650
- <a href="https://profiles.wordpress.org/boonebgorges"><img src="//www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c?s=60" class="gravatar" alt="Boone B. Gorges" /></a>
651
- <a class="web" href="https://profiles.wordpress.org/boonebgorges">Boone B. Gorges</a>
652
  <span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
653
  </li>
654
  <li class="wp-person" id="wp-person-djpaul">
655
- <a href="https://profiles.wordpress.org/djpaul"><img src="//www.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=60" class="gravatar" alt="Paul Gibbs" /></a>
656
- <a class="web" href="https://profiles.wordpress.org/djpaul">Paul Gibbs</a>
657
  <span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
658
  </li>
659
  </ul>
@@ -661,33 +663,28 @@ class BP_Admin {
661
  <h4 class="wp-people-group"><?php _e( 'Core Team', 'buddypress' ); ?></h4>
662
  <ul class="wp-people-group " id="wp-people-group-core-team">
663
  <li class="wp-person" id="wp-person-r-a-y">
664
- <a href="https://profiles.wordpress.org/r-a-y"><img src="//www.gravatar.com/avatar/3bfa556a62b5bfac1012b6ba5f42ebfa?s=60" class="gravatar" alt="Ray" /></a>
665
- <a class="web" href="https://profiles.wordpress.org/r-a-y">Ray</a>
666
  <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
667
  </li>
668
  <li class="wp-person" id="wp-person-imath">
669
- <a href="https://profiles.wordpress.org/imath"><img src="//www.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=60" class="gravatar" alt="Mathieu Viet" /></a>
670
- <a class="web" href="https://profiles.wordpress.org/imath">Mathieu Viet</a>
671
  <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
672
  </li>
673
  <li class="wp-person" id="wp-person-mercime">
674
- <a href="https://profiles.wordpress.org/mercime"><img src="//www.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=60" class="gravatar" alt="Mercime" /></a>
675
- <a class="web" href="https://profiles.wordpress.org/mercime">Mercime</a>
676
  <span class="title"><?php _e( 'Navigator', 'buddypress' ); ?></span>
677
  </li>
678
  <li class="wp-person" id="wp-person-dcavins">
679
- <a href="https://profiles.wordpress.org/dcavins"><img src="//www.gravatar.com/avatar/a5fa7e83d59cb45ebb616235a176595a?s=60" class="gravatar" alt="David Cavins" /></a>
680
- <a class="web" href="https://profiles.wordpress.org/dcavins">David Cavins</a>
681
  <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
682
  </li>
683
  <li class="wp-person" id="wp-person-tw2113">
684
- <a href="https://profiles.wordpress.org/tw2113"><img src="//www.gravatar.com/avatar/a5d7c934621fa1c025b83ee79bc62366?s=60" class="gravatar" alt="Michael Beckwith" /></a>
685
- <a class="web" href="https://profiles.wordpress.org/tw2113">Michael Beckwith</a>
686
- <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
687
- </li>
688
- <li class="wp-person" id="wp-person-hnla">
689
- <a href="https://profiles.wordpress.org/hnla"><img src="//www.gravatar.com/avatar/3860c955aa3f79f13b92826ae47d07fe?s=60" class="gravatar" alt="Hugo Ashmore" /></a>
690
- <a class="web" href="https://profiles.wordpress.org/hnla">Hugo</a>
691
  <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
692
  </li>
693
  </ul>
@@ -695,70 +692,74 @@ class BP_Admin {
695
  <h4 class="wp-people-group"><?php _e( 'Recent Rockstars', 'buddypress' ); ?></h4>
696
  <ul class="wp-people-group " id="wp-people-group-rockstars">
697
  <li class="wp-person" id="wp-person-henry-wright">
698
- <a href="https://profiles.wordpress.org/henry.wright"><img src="//www.gravatar.com/avatar/0da2f1a9340d6af196b870f6c107a248?s=60" class="gravatar" alt="Henry Wright" /></a>
699
- <a class="web" href="https://profiles.wordpress.org/henry.wright">Henry Wright</a>
700
  </li>
701
  <li class="wp-person" id="wp-person-danbp">
702
- <a href="https://profiles.wordpress.org/danbp"><img src="//www.gravatar.com/avatar/0deae2e7003027fbf153500cd3fa5501?s=60" class="gravatar" alt="danbp" /></a>
703
- <a class="web" href="https://profiles.wordpress.org/danbp">danbp</a>
704
  </li>
705
  <li class="wp-person" id="wp-person-shanebp">
706
- <a href="https://profiles.wordpress.org/shanebp"><img src="//www.gravatar.com/avatar/ffd294ab5833ba14aaf175f9acc71cc4?s=60" class="gravatar" alt="shanebp" /></a>
707
- <a class="web" href="https://profiles.wordpress.org/shanebp">shanebp</a>
708
  </li>
709
  <li class="wp-person" id="wp-person-netweb">
710
- <a href="https://profiles.wordpress.org/netweb"><img src="//www.gravatar.com/avatar/97e1620b501da675315ba7cfb740e80f?s=60" class="gravatar" alt="Stephen Edgar" /></a>
711
- <a class="web" href="https://profiles.wordpress.org/netweb">Stephen Edgar</a>
712
  </li>
713
- <li class="wp-person" id="wp-person-dimensionmedia">
714
- <a href="https://profiles.wordpress.org/dimensionmedia"><img src="//www.gravatar.com/avatar/7735aada1ec39d0c1118bd92ed4551f1?s=60" class="gravatar" alt="David Bisset" /></a>
715
- <a class="web" href="https://profiles.wordpress.org/dimensionmedia">David Bisset</a>
716
  </li>
717
-
718
  </ul>
719
 
720
  <h4 class="wp-people-group"><?php printf( esc_html__( 'Contributors to BuddyPress %s', 'buddypress' ), self::display_version() ); ?></h4>
721
  <p class="wp-credits-list">
722
- <a href="https://profiles.wordpress.org/jorbin/">Aaron Jorbin (aaronjorbin)</a>,
 
723
  <a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>,
724
- <a href="https://profiles.wordpress.org/sbrajesh/">Brajesh Singh (sbrajesh)</a>,
725
- <a href="https://profiles.wordpress.org/CristinaCannon/">CristinaCannon</a>,
 
 
 
726
  <a href="https://profiles.wordpress.org/dcavins/">David Cavins (dcavins)</a>,
727
- <a href="https://profiles.wordpress.org/wpdennis/">Dennis (wpdennis)</a>,
728
- <a href="https://profiles.wordpress.org/ocean90/">Dominik Schilling (ocean90)</a>,
729
- ecehren,
730
- <a href="https://profiles.wordpress.org/finzend/">finzend</a>,
731
  <a href="https://profiles.wordpress.org/Mamaduka/">George Mamadashvili (Mamaduka)</a>,
732
  <a href="https://profiles.wordpress.org/gregrickaby/">Greg Rickaby (gregrickaby)</a>,
733
- <a href="https://profiles.wordpress.org/henrywright/">Henry Wright (henry.wright)</a>,
734
  <a href="https://profiles.wordpress.org/hnla/">Hugo (hnla)</a>,
735
- <a href="https://profiles.wordpress.org/jaimieolmstead/">jaimieolmstead</a>,
 
736
  <a href="https://profiles.wordpress.org/johnjamesjacoby/">John James Jacoby (johnjamesjacoby)</a>,
 
737
  <a href="https://profiles.wordpress.org/jreeve/">jreeve</a>,
738
- <a href="https://profiles.wordpress.org/JustinSainton/">Justin Sainton (JustinSainton)</a>,
739
- <a href="https://profiles.wordpress.org/kadamwhite/">K.Adam White (kadamwhite)</a>,
740
  <a href="https://profiles.wordpress.org/Offereins">Laurens Offereins (Offereins)</a>
741
  <a href="https://profiles.wordpress.org/lenasterg/">lenasterg</a>,
742
- <a href="https://profiles.wordpress.org/natrio/">Marc (natrio)</a>,
743
- <a href="https://profiles.wordpress.org/mechter/">Markus Echterhoff (mechter)</a>,
744
  <a href="https://profiles.wordpress.org/imath/">Mathieu Viet (imath)</a>,
745
- <a href="https://profiles.wordpress.org/melhop/">melhop</a>,
746
  <a href="https://profiles.wordpress.org/mercime/">mercime</a>,
747
  <a href="https://profiles.wordpress.org/tw2113/">Michael Beckwith (tw2113)</a>,
748
- <a href="https://profiles.wordpress.org/pareshradadiya/">paresh.radadiya (pareshradadiya)</a>,
 
749
  <a href="https://profiles.wordpress.org/DJPaul/">Paul Gibbs (DJPaul)</a>,
750
- <a href="https://profiles.wordpress.org/prometheus-fire/">Prometheus Fire</a>,
 
751
  <a href="https://profiles.wordpress.org/r-a-y/">r-a-y</a>,
752
- <a href="https://profiles.wordpress.org/rogercoathup/">Roger Coathup (rogercoathup)</a>,
753
- <a href="https://profiles.wordpress.org/dtc7240/">Scott Seitz (dtc7240)</a>,
754
- <a href="https://profiles.wordpress.org/wonderboymusic/">Scott Taylor (wonderboymusic)</a>.
755
- <a href="https://profiles.wordpress.org/SergeyBiryukov/">Sergey Biryukov (SergeyBiryukov)</a>,
756
- <a href="https://profiles.wordpress.org/shanebp/">shanebp</a>,
757
  <a href="https://profiles.wordpress.org/netweb/">Stephen Edgar (netweb)</a>,
758
  <a href="https://profiles.wordpress.org/svenl77/">svenl77</a>,
759
- <a href="https://profiles.wordpress.org/WeddyWood/">WeddyWood</a>,
760
- <a href="https://profiles.wordpress.org/wolfhoundjesse/">wolfhoundjesse</a>,
761
- <a href="https://profiles.wordpress.org/xgz/">xgz</a>.
 
 
 
 
762
  </p>
763
 
764
  <h4 class="wp-people-group"><?php _e( 'External Libraries', 'buddypress' ); ?></h4>
16
  *
17
  * @package BuddyPress
18
  * @subpackage CoreAdministration
 
19
  *
20
  * @since BuddyPress (1.6.0)
21
  */
116
  * @access private
117
  */
118
  private function includes() {
119
+ require( $this->admin_dir . 'bp-core-actions.php' );
120
+ require( $this->admin_dir . 'bp-core-settings.php' );
121
+ require( $this->admin_dir . 'bp-core-functions.php' );
122
+ require( $this->admin_dir . 'bp-core-components.php' );
123
+ require( $this->admin_dir . 'bp-core-slugs.php' );
124
+ require( $this->admin_dir . 'bp-core-tools.php' );
125
  }
126
 
127
  /**
158
  add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 15 );
159
 
160
  // Add a description of new BuddyPress tools in the available tools page
161
+ add_action( 'tool_box', 'bp_core_admin_available_tools_intro' );
162
  add_action( 'bp_network_tool_box', 'bp_core_admin_available_tools_intro' );
163
 
164
  // On non-multisite, catch
178
  /**
179
  * Add the navigational menu elements.
180
  *
181
+ * @since BuddyPress (1.6)
182
  *
183
  * @uses add_management_page() To add the Recount page in Tools section.
184
  * @uses add_options_page() To add the Forums settings page in Settings
314
  /** Main Section ******************************************************/
315
 
316
  // Add the main section
317
+ add_settings_section( 'bp_main', __( 'Main Settings', 'buddypress' ), 'bp_admin_setting_callback_main_section', 'buddypress' );
318
 
319
  // Hide toolbar for logged out users setting
320
+ add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
321
+ register_setting ( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
322
 
323
  // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade
324
  if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) {
328
 
329
  // Allow account deletion
330
  add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
331
+ register_setting ( 'buddypress', 'bp-disable-account-deletion', 'intval' );
332
 
333
  /** XProfile Section **************************************************/
334
 
337
  // Add the main section
338
  add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
339
 
340
+ $avatar_setting = 'bp_xprofile';
 
341
 
342
  // Profile sync setting
343
+ add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
344
+ register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
345
  }
346
 
347
  /** Groups Section ****************************************************/
349
  if ( bp_is_active( 'groups' ) ) {
350
 
351
  // Add the main section
352
+ add_settings_section( 'bp_groups', __( 'Groups Settings', 'buddypress' ), 'bp_admin_setting_callback_groups_section', 'buddypress' );
353
 
354
+ if ( empty( $avatar_setting ) ) {
355
+ $avatar_setting = 'bp_groups';
356
+ }
357
 
358
+ // Allow subscriptions setting
359
+ add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation', 'buddypress' ), 'bp_admin_setting_callback_group_creation', 'buddypress', 'bp_groups' );
360
+ register_setting ( 'buddypress', 'bp_restrict_group_creation', 'intval' );
361
  }
362
 
363
  /** Forums ************************************************************/
365
  if ( bp_is_active( 'forums' ) ) {
366
 
367
  // Add the main section
368
+ add_settings_section( 'bp_forums', __( 'Legacy Group Forums', 'buddypress' ), 'bp_admin_setting_callback_bbpress_section', 'buddypress' );
369
 
370
  // Allow subscriptions setting
371
  add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' );
372
+ register_setting ( 'buddypress', 'bb-config-location', '' );
373
  }
374
 
375
  /** Activity Section **************************************************/
377
  if ( bp_is_active( 'activity' ) ) {
378
 
379
  // Add the main section
380
+ add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' );
381
 
382
  // Activity commenting on blog and forum posts
383
  add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog &amp; Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' );
389
 
390
  // Allow activity akismet
391
  if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) {
392
+ add_settings_field( '_bp_enable_akismet', __( 'Akismet', 'buddypress' ), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity' );
393
+ register_setting ( 'buddypress', '_bp_enable_akismet', 'intval' );
394
  }
395
  }
396
+
397
+ /** Avatar upload for users or groups ************************************/
398
+
399
+ if ( ! empty( $avatar_setting ) ) {
400
+ // Allow avatar uploads
401
+ add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', $avatar_setting );
402
+ register_setting ( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
403
+ }
404
  }
405
 
406
  /**
472
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
473
 
474
  $file = $this->css_url . "common{$min}.css";
 
 
 
 
 
 
 
 
475
  $file = apply_filters( 'bp_core_admin_common_css', $file );
476
  wp_enqueue_style( 'bp-admin-common-css', $file, array(), bp_get_version() );
477
 
504
  <h3 style="margin:0"><?php _e( 'Getting Started with BuddyPress', 'buddypress' ); ?></h3>
505
  <div class="welcome-panel-column-container">
506
  <div class="welcome-panel-column">
507
+ <h4><?php _e( 'Configure Buddypress', 'buddypress' ); ?></h4>
508
  <ul>
509
  <li><?php printf(
510
  '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Set Up Components', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) ) )
537
  </div>
538
  <div class="welcome-panel-column welcome-panel-last">
539
  <h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
540
+ <p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Looking for help? The <a href="http://codex.buddypress.org/">BuddyPress Codex</a> has you covered.', 'buddypress' ) ?></p>
541
+ <p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Can&#8217;t find what you need? Stop by <a href="http://buddypress.org/support/">our support forums</a>, where active BuddyPress users and developers are waiting to share tips and more.', 'buddypress' ) ?></p>
542
  </div>
543
  </div>
544
  </div>
545
  </div>
546
 
547
+ <hr />
548
 
549
+ <?php endif; ?>
 
550
 
551
+ <div class="changelog headline-feature">
552
+ <h2><?php esc_html_e( 'Member Types', 'buddypress' ); ?></h2>
553
  <div class="featured-image">
554
+ <img src="<?php echo esc_url( buddypress()->plugin_url . 'bp-core/admin/images/member-types.png' ); ?>" alt="<?php esc_attr_e( 'Member types metabox', 'buddypress' ); ?>">
555
  </div>
556
 
557
  <div class="feature-section">
558
+ <h3><?php esc_html_e( 'Native APIs for crafting great new member experiences.', 'buddypress' ); ?></h3>
559
+ <p><?php esc_html_e( 'Registering member types finally enables a strict separation of different and explicit types of community members.', 'buddypress' ); ?></p>
560
+ <p><?php esc_html_e( 'This amazing new feature is available to plugin developers starting with BuddyPress 2.2', 'buddypress' ); ?></p>
561
+ <p><a href="https://codex.buddypress.org/developer/member-types/"><?php esc_html_e( 'Learn more &rarr;', 'buddypress' ); ?></a></p>
562
  </div>
563
 
564
  <div class="clear"></div>
565
  </div>
566
 
567
+ <hr />
568
+
569
+ <div class="changelog feature-list finer-points">
570
  <h2><?php esc_html_e( 'The Finer Points', 'buddypress' ); ?></h2>
571
 
572
  <div class="feature-section col two-col">
573
  <div>
574
+ <span class=" dashicons dashicons-admin-post"></span>
575
+ <h4><?php esc_html_e( 'Post Types Activities', 'buddypress' ); ?></h4>
576
+ <p><?php esc_html_e( 'Register custom post types so they appear as activity stream items, complete with custom verbiage.', 'buddypress' ); ?></p>
577
  </div>
578
 
579
  <div class="template-pack last-feature">
580
  <span class=" dashicons dashicons-admin-appearance"></span>
581
+ <h4><?php esc_html_e( 'Template Pack', 'buddypress' ); ?></h4>
582
+ <p><?php esc_html_e( 'The Legacy template pack is now more responsive and accommodating to more WordPress themes.', 'buddypress' ); ?></p>
583
  </div>
584
 
585
  <div class="group-invites">
586
+ <span class=" dashicons dashicons-editor-code"></span>
587
+ <h4><?php esc_html_e( 'Message Meta', 'buddypress' ); ?></h4>
588
+ <p><?php esc_html_e( 'Private message conversations made infinitely more flexible with an additional metadata table.', 'buddypress' ); ?></p>
589
  </div>
590
 
591
  <div class="last-feature">
592
+ <span class=" dashicons dashicons-heart"></span>
593
+ <h4><?php esc_html_e( 'WordPress 3.6 - 4.1', 'buddypress' ); ?></h4>
594
+ <p><?php esc_html_e( 'We support a wide range of WordPress versions, even though you should always stay up-to-date.', 'buddypress' ); ?></p>
595
  </div>
596
  </div>
597
  </div>
598
 
599
+ <hr />
600
+
601
+ <div class="changelog feature-list">
602
  <h2><?php esc_html_e( 'Under the Hood', 'buddypress' ); ?></h2>
603
 
604
  <div class="feature-section col two-col">
605
  <div>
606
+ <h4><?php esc_html_e( 'Complex Activity Queries', 'buddypress' ); ?></h4>
607
+ <p><?php esc_html_e( 'Metadata, multiple scopes, actions, post types, and more are now easily queried using core APIs and functionality.', 'buddypress' ); ?></p>
608
 
609
  <h4><?php esc_html_e( 'Cache Improvements', 'buddypress' ); ?></h4>
610
+ <p><?php esc_html_e( 'We now properly group and cache several different types of queries and objects, with an emphasis on multi-network environments.', 'buddypress' ); ?></p>
611
  </div>
612
  <div class="last-feature">
613
  <h4><?php esc_html_e( 'Developer Reference', 'buddypress' ); ?></h4>
614
  <p><?php esc_html_e( 'Continued improvements to inline code documentation make it easier for developers to understand how BuddyPress works.', 'buddypress' ); ?></p>
615
 
616
+ <h4><?php esc_html_e( 'And so Much More', 'buddypress' ); ?></h4>
617
+ <p><?php esc_html_e( 'With over 130 bugs squashed and constant attention to improving unit-test coverage, we think this version is just the bee&#8217;s knees.', 'buddypress' ); ?></p>
618
  </div>
619
  </div>
620
  </div>
621
 
 
 
 
622
  <?php
623
  }
624
 
644
  <h4 class="wp-people-group"><?php _e( 'Project Leaders', 'buddypress' ); ?></h4>
645
  <ul class="wp-people-group " id="wp-people-group-project-leaders">
646
  <li class="wp-person" id="wp-person-johnjamesjacoby">
647
+ <a href="http://profiles.wordpress.org/johnjamesjacoby"><img src="http://0.gravatar.com/avatar/81ec16063d89b162d55efe72165c105f?s=60" class="gravatar" alt="John James Jacoby" /></a>
648
+ <a class="web" href="http://profiles.wordpress.org/johnjamesjacoby">John James Jacoby</a>
649
  <span class="title"><?php _e( 'Project Lead', 'buddypress' ); ?></span>
650
  </li>
651
  <li class="wp-person" id="wp-person-boonebgorges">
652
+ <a href="http://profiles.wordpress.org/boonebgorges"><img src="http://0.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c?s=60" class="gravatar" alt="Boone B. Gorges" /></a>
653
+ <a class="web" href="http://profiles.wordpress.org/boonebgorges">Boone B. Gorges</a>
654
  <span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
655
  </li>
656
  <li class="wp-person" id="wp-person-djpaul">
657
+ <a href="http://profiles.wordpress.org/djpaul"><img src="http://0.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=60" class="gravatar" alt="Paul Gibbs" /></a>
658
+ <a class="web" href="http://profiles.wordpress.org/djpaul">Paul Gibbs</a>
659
  <span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
660
  </li>
661
  </ul>
663
  <h4 class="wp-people-group"><?php _e( 'Core Team', 'buddypress' ); ?></h4>
664
  <ul class="wp-people-group " id="wp-people-group-core-team">
665
  <li class="wp-person" id="wp-person-r-a-y">
666
+ <a href="http://profiles.wordpress.org/r-a-y"><img src="http://0.gravatar.com/avatar/3bfa556a62b5bfac1012b6ba5f42ebfa?s=60" class="gravatar" alt="Ray" /></a>
667
+ <a class="web" href="http://profiles.wordpress.org/r-a-y">Ray</a>
668
  <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
669
  </li>
670
  <li class="wp-person" id="wp-person-imath">
671
+ <a href="http://profiles.wordpress.org/imath"><img src="http://0.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=60" class="gravatar" alt="Mathieu Viet" /></a>
672
+ <a class="web" href="http://profiles.wordpress.org/imath">Mathieu Viet</a>
673
  <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
674
  </li>
675
  <li class="wp-person" id="wp-person-mercime">
676
+ <a href="http://profiles.wordpress.org/mercime"><img src="http://0.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=60" class="gravatar" alt="Mercime" /></a>
677
+ <a class="web" href="http://profiles.wordpress.org/mercime">Mercime</a>
678
  <span class="title"><?php _e( 'Navigator', 'buddypress' ); ?></span>
679
  </li>
680
  <li class="wp-person" id="wp-person-dcavins">
681
+ <a href="http://profiles.wordpress.org/dcavins"><img src="http://0.gravatar.com/avatar/a5fa7e83d59cb45ebb616235a176595a?s=60" class="gravatar" alt="David Cavins" /></a>
682
+ <a class="web" href="http://profiles.wordpress.org/dcavins">David Cavins</a>
683
  <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
684
  </li>
685
  <li class="wp-person" id="wp-person-tw2113">
686
+ <a href="http://profiles.wordpress.org/tw2113"><img src="http://0.gravatar.com/avatar/a5d7c934621fa1c025b83ee79bc62366?s=60" class="gravatar" alt="Michael Beckwith" /></a>
687
+ <a class="web" href="http://profiles.wordpress.org/tw2113">Michael Beckwith</a>
 
 
 
 
 
688
  <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
689
  </li>
690
  </ul>
692
  <h4 class="wp-people-group"><?php _e( 'Recent Rockstars', 'buddypress' ); ?></h4>
693
  <ul class="wp-people-group " id="wp-people-group-rockstars">
694
  <li class="wp-person" id="wp-person-henry-wright">
695
+ <a href="http://profiles.wordpress.org/henry.wright"><img src="http://0.gravatar.com/avatar/0da2f1a9340d6af196b870f6c107a248?s=60" class="gravatar" alt="Henry Wright" /></a>
696
+ <a class="web" href="http://profiles.wordpress.org/henry.wright">Henry Wright</a>
697
  </li>
698
  <li class="wp-person" id="wp-person-danbp">
699
+ <a href="http://profiles.wordpress.org/danbp"><img src="http://0.gravatar.com/avatar/0deae2e7003027fbf153500cd3fa5501?s=60" class="gravatar" alt="danbp" /></a>
700
+ <a class="web" href="http://profiles.wordpress.org/danbp">danbp</a>
701
  </li>
702
  <li class="wp-person" id="wp-person-shanebp">
703
+ <a href="http://profiles.wordpress.org/shanebp"><img src="http://0.gravatar.com/avatar/ffd294ab5833ba14aaf175f9acc71cc4?s=60" class="gravatar" alt="shanebp" /></a>
704
+ <a class="web" href="http://profiles.wordpress.org/shanebp">shanebp</a>
705
  </li>
706
  <li class="wp-person" id="wp-person-netweb">
707
+ <a href="http://profiles.wordpress.org/netweb"><img src="http://0.gravatar.com/avatar/97e1620b501da675315ba7cfb740e80f?s=60" class="gravatar" alt="Stephen Edgar" /></a>
708
+ <a class="web" href="http://profiles.wordpress.org/netweb">Stephen Edgar</a>
709
  </li>
710
+ <li class="wp-person" id="wp-person-hnla">
711
+ <a href="http://profiles.wordpress.org/hnla"><img src="http://0.gravatar.com/avatar/3860c955aa3f79f13b92826ae47d07fe?s=60" class="gravatar" alt="Hugo Ashmore" /></a>
712
+ <a class="web" href="http://profiles.wordpress.org/hnla">Hugo</a>
713
  </li>
 
714
  </ul>
715
 
716
  <h4 class="wp-people-group"><?php printf( esc_html__( 'Contributors to BuddyPress %s', 'buddypress' ), self::display_version() ); ?></h4>
717
  <p class="wp-credits-list">
718
+ <a href="https://profiles.wordpress.org/andemann/">andemann</a>,
719
+ <a href="https://profiles.wordpress.org/dontdream/">Andrea Tarantini (dontdream)</a>,
720
  <a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>,
721
+ <a href="https://profiles.wordpress.org/thebrandonallen/">Brandon Allen (thebrandonallen)</a>,
722
+ <a href="https://profiles.wordpress.org/Clean-Cole/">Clean-Cole</a>,
723
+ <a href="https://profiles.wordpress.org/colabsadmin/">colabsadmin</a>,
724
+ <a href="https://profiles.wordpress.org/colorful-tones/">Damon Cook (colorful tones)</a>,
725
+ <a href="https://profiles.wordpress.org/danbp/">danbp</a>,
726
  <a href="https://profiles.wordpress.org/dcavins/">David Cavins (dcavins)</a>,
727
+ <a href="https://profiles.wordpress.org/fahmiadib/">Fahmi Adib (fahmiadib)</a>,
 
 
 
728
  <a href="https://profiles.wordpress.org/Mamaduka/">George Mamadashvili (Mamaduka)</a>,
729
  <a href="https://profiles.wordpress.org/gregrickaby/">Greg Rickaby (gregrickaby)</a>,
 
730
  <a href="https://profiles.wordpress.org/hnla/">Hugo (hnla)</a>,
731
+ <a href="https://profiles.wordpress.org/whyisjake/">Jake Spurlock (whyisjake)</a>,
732
+ <a href="https://profiles.wordpress.org/ev3rywh3re/">Jess Planck (ev3rywh3re)</a>,
733
  <a href="https://profiles.wordpress.org/johnjamesjacoby/">John James Jacoby (johnjamesjacoby)</a>,
734
+ <a href="https://profiles.wordpress.org/joshshashaty/">Josh (joshshashaty)</a>,
735
  <a href="https://profiles.wordpress.org/jreeve/">jreeve</a>,
736
+ <a href="https://profiles.wordpress.org/lakrisgubben/">lakrisgubben</a>,
 
737
  <a href="https://profiles.wordpress.org/Offereins">Laurens Offereins (Offereins)</a>
738
  <a href="https://profiles.wordpress.org/lenasterg/">lenasterg</a>,
739
+ <a href="https://profiles.wordpress.org/nofearinc/">Mario Peshev (nofearinc)</a>,
 
740
  <a href="https://profiles.wordpress.org/imath/">Mathieu Viet (imath)</a>,
 
741
  <a href="https://profiles.wordpress.org/mercime/">mercime</a>,
742
  <a href="https://profiles.wordpress.org/tw2113/">Michael Beckwith (tw2113)</a>,
743
+ <a href="https://profiles.wordpress.org/modemlooper/">modemlooper</a>,
744
+ <a href="https://profiles.wordpress.org/sooskriszta/">OC2PS (sooskriszta)</a>,
745
  <a href="https://profiles.wordpress.org/DJPaul/">Paul Gibbs (DJPaul)</a>,
746
+ <a href="https://profiles.wordpress.org/pro120/">pro120</a>,
747
+ <a href="https://profiles.wordpress.org/psycleuk/">psycleuk</a>,
748
  <a href="https://profiles.wordpress.org/r-a-y/">r-a-y</a>,
749
+ <a href="https://profiles.wordpress.org/espellcaste/">Renato Alves (espellcaste)</a>,
750
+ <a href="https://profiles.wordpress.org/SGr33n/">Sergio De Falco (SGr33n)</a>,
751
+ <a href="https://profiles.wordpress.org/shpitzyl/">shpitzyl</a>,
752
+ <a href="https://profiles.wordpress.org/slaFFik/">Slava UA (slaFFik)</a>,
753
+ <a href="https://profiles.wordpress.org/standardspace/">standardspace</a>,
754
  <a href="https://profiles.wordpress.org/netweb/">Stephen Edgar (netweb)</a>,
755
  <a href="https://profiles.wordpress.org/svenl77/">svenl77</a>,
756
+ <a href="https://profiles.wordpress.org/tharsheblows/">tharsheblows</a>,
757
+ <a href="https://profiles.wordpress.org/thebigA/">thebigA</a>,
758
+ <a href="https://profiles.wordpress.org/thomaslhotta/">thomaslhotta</a>,
759
+ <a href="https://profiles.wordpress.org/tometzky/">Tomasz Ostrowski (tometzky)</a>,
760
+ <a href="https://profiles.wordpress.org/unsalkorkmaz/">Unsal Korkmaz (unsalkorkmaz)</a>,
761
+ <a href="https://profiles.wordpress.org/vimes1984/">vimes1984</a>,
762
+ <a href="https://profiles.wordpress.org/wonderboymusic/">Scott Taylor (wonderboymusic)</a>.
763
  </p>
764
 
765
  <h4 class="wp-people-group"><?php _e( 'External Libraries', 'buddypress' ); ?></h4>
bp-core/bp-core-attachments.php DELETED
@@ -1,406 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Attachments functions.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Attachments
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * Check if the current WordPress version is using Plupload 2.1.1
14
- *
15
- * Plupload 2.1.1 was introduced in WordPress 3.9. Our bp-plupload.js
16
- * script requires it. So we need to make sure the current WordPress
17
- * match with our needs.
18
- *
19
- * @since BuddyPress (2.3.0)
20
- *
21
- * @return bool True if WordPress is 3.9+, false otherwise
22
- */
23
- function bp_attachments_is_wp_version_supported() {
24
- return (bool) version_compare( bp_get_major_wp_version(), '3.9', '>=' );
25
- }
26
-
27
- /**
28
- * Get the BuddyPress Plupload settings
29
- *
30
- * @since BuddyPress (2.3.0)
31
- *
32
- * @return array list of BuddyPress Plupload settings
33
- */
34
- function bp_attachments_get_plupload_default_settings() {
35
-
36
- $max_upload_size = wp_max_upload_size();
37
-
38
- if ( ! $max_upload_size ) {
39
- $max_upload_size = 0;
40
- }
41
-
42
- $defaults = array(
43
- 'runtimes' => 'html5,flash,silverlight,html4',
44
- 'file_data_name' => 'file',
45
- 'multipart_params' => array(
46
- 'action' => 'bp_upload_attachment',
47
- '_wpnonce' => wp_create_nonce( 'bp-uploader' ),
48
- ),
49
- 'url' => admin_url( 'admin-ajax.php', 'relative' ),
50
- 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
51
- 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
52
- 'filters' => array(
53
- 'max_file_size' => $max_upload_size . 'b',
54
- ),
55
- 'multipart' => true,
56
- 'urlstream_upload' => true,
57
- );
58
-
59
- // WordPress is not allowing multi selection for iOs 7 device.. See #29602.
60
- if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
61
- strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) {
62
-
63
- $defaults['multi_selection'] = false;
64
- }
65
-
66
- $settings = array(
67
- 'defaults' => $defaults,
68
- 'browser' => array(
69
- 'mobile' => wp_is_mobile(),
70
- 'supported' => _device_can_upload(),
71
- ),
72
- 'limitExceeded' => is_multisite() && ! is_upload_space_available(),
73
- );
74
-
75
- /**
76
- * Filter the BuddyPress Plupload default settings.
77
- *
78
- * @since 2.3.0
79
- *
80
- * @param array $params Default Plupload parameters array.
81
- */
82
- return apply_filters( 'bp_attachments_get_plupload_default_settings', $settings );
83
- }
84
-
85
- /**
86
- * Builds localization strings for the BuddyPress Uploader scripts
87
- *
88
- * @since BuddyPress (2.3.0)
89
- *
90
- * @return array Plupload default localization strings
91
- */
92
- function bp_attachments_get_plupload_l10n() {
93
- // Localization strings
94
- return apply_filters( 'bp_attachments_get_plupload_l10n', array(
95
- 'queue_limit_exceeded' => __( 'You have attempted to queue too many files.', 'buddypress' ),
96
- 'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.', 'buddypress' ),
97
- 'zero_byte_file' => __( 'This file is empty. Please try another.', 'buddypress' ),
98
- 'invalid_filetype' => __( 'This file type is not allowed. Please try another.', 'buddypress' ),
99
- 'not_an_image' => __( 'This file is not an image. Please try another.', 'buddypress' ),
100
- 'image_memory_exceeded' => __( 'Memory exceeded. Please try another smaller file.', 'buddypress' ),
101
- 'image_dimensions_exceeded' => __( 'This is larger than the maximum size. Please try another.', 'buddypress' ),
102
- 'default_error' => __( 'An error occurred. Please try again later.', 'buddypress' ),
103
- 'missing_upload_url' => __( 'There was a configuration error. Please contact the server administrator.', 'buddypress' ),
104
- 'upload_limit_exceeded' => __( 'You may only upload 1 file.', 'buddypress' ),
105
- 'http_error' => __( 'HTTP error.', 'buddypress' ),
106
- 'upload_failed' => __( 'Upload failed.', 'buddypress' ),
107
- 'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.', 'buddypress' ),
108
- 'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.', 'buddypress' ),
109
- 'io_error' => __( 'IO error.', 'buddypress' ),
110
- 'security_error' => __( 'Security error.', 'buddypress' ),
111
- 'file_cancelled' => __( 'File canceled.', 'buddypress' ),
112
- 'upload_stopped' => __( 'Upload stopped.', 'buddypress' ),
113
- 'dismiss' => __( 'Dismiss', 'buddypress' ),
114
- 'crunching' => __( 'Crunching&hellip;', 'buddypress' ),
115
- 'unique_file_warning' => __( 'Make sure to upload a unique file', 'buddypress' ),
116
- 'error_uploading' => __( '&#8220;%s&#8221; has failed to upload.', 'buddypress' ),
117
- 'has_avatar_warning' => __( 'If you&#39;d like to delete the existing profile photo but not upload a new one, please use the delete tab.', 'buddypress' )
118
- ) );
119
- }
120
-
121
- /**
122
- * Enqueues the script needed for the Uploader UI
123
- *
124
- * @see BP_Attachment::script_data() && BP_Attachment_Avatar::script_data() for examples showing how
125
- * to set specific script data
126
- *
127
- * @since BuddyPress (2.3.0)
128
- *
129
- * @param string $class name of the class extending BP_Attachment (eg: BP_Attachment_Avatar)
130
- */
131
- function bp_attachments_enqueue_scripts( $class = '' ) {
132
- // Enqueue me just once per page, please.
133
- if ( did_action( 'bp_attachments_enqueue_scripts' ) ) {
134
- return;
135
- }
136
-
137
- if ( ! $class || ! class_exists( $class ) ) {
138
- return new WP_Error( 'missing_parameter' );
139
- }
140
-
141
- // Get an instance of the class and get the script data
142
- $attachment = new $class;
143
- $script_data = $attachment->script_data();
144
-
145
- $args = bp_parse_args( $script_data, array(
146
- 'action' => '',
147
- 'file_data_name' => '',
148
- 'max_file_size' => 0,
149
- 'browse_button' => 'bp-browse-button',
150
- 'container' => 'bp-upload-ui',
151
- 'drop_element' => 'drag-drop-area',
152
- 'bp_params' => array(),
153
- 'extra_css' => array(),
154
- 'extra_js' => array(),
155
- 'feedback_messages' => array(),
156
- ), 'attachments_enqueue_scripts' );
157
-
158
- if ( empty( $args['action'] ) || empty( $args['file_data_name'] ) ) {
159
- return new WP_Error( 'missing_parameter' );
160
- }
161
-
162
- // Get the BuddyPress uploader strings
163
- $strings = bp_attachments_get_plupload_l10n();
164
-
165
- // Get the BuddyPress uploader settings
166
- $settings = bp_attachments_get_plupload_default_settings();
167
-
168
- // Set feedback messages
169
- if ( ! empty( $args['feedback_messages'] ) ) {
170
- $strings['feedback_messages'] = $args['feedback_messages'];
171
- }
172
-
173
- // Use a temporary var to ease manipulation
174
- $defaults = $settings['defaults'];
175
-
176
- // Set the upload action
177
- $defaults['multipart_params']['action'] = $args['action'];
178
-
179
- // Set BuddyPress upload parameters if provided
180
- if ( ! empty( $args['bp_params'] ) ) {
181
- $defaults['multipart_params']['bp_params'] = $args['bp_params'];
182
- }
183
-
184
- // Merge other arguments
185
- $ui_args = array_intersect_key( $args, array(
186
- 'file_data_name' => true,
187
- 'browse_button' => true,
188
- 'container' => true,
189
- 'drop_element' => true,
190
- ) );
191
-
192
- $defaults = array_merge( $defaults, $ui_args );
193
-
194
- if ( ! empty( $args['max_file_size'] ) ) {
195
- $defaults['filters']['max_file_size'] = $args['max_file_size'] . 'b';
196
- }
197
-
198
- // Specific to BuddyPress Avatars
199
- if ( 'bp_avatar_upload' === $defaults['multipart_params']['action'] ) {
200
-
201
- // Include the cropping informations for avatars
202
- $settings['crop'] = array(
203
- 'full_h' => bp_core_avatar_full_height(),
204
- 'full_w' => bp_core_avatar_full_width(),
205
- );
206
-
207
- // Avatar only need 1 file and 1 only!
208
- $defaults['multi_selection'] = false;
209
-
210
- // Does the object already has an avatar set
211
- $has_avatar = $defaults['multipart_params']['bp_params']['has_avatar'];
212
-
213
- // What is the object the avatar belongs to
214
- $object = $defaults['multipart_params']['bp_params']['object'];
215
-
216
- // Init the Avatar nav
217
- $avatar_nav = array(
218
- 'upload' => array( 'id' => 'upload', 'caption' => __( 'Upload', 'buddypress' ), 'order' => 0 ),
219
-
220
- // The delete view will only show if the object has an avatar
221
- 'delete' => array( 'id' => 'delete', 'caption' => __( 'Delete', 'buddypress' ), 'order' => 100, 'hide' => (int) ! $has_avatar ),
222
- );
223
-
224
- // Create the Camera Nav if the WebCam capture feature is enabled
225
- if ( bp_avatar_use_webcam() && 'user' === $object ) {
226
- $avatar_nav['camera'] = array( 'id' => 'camera', 'caption' => __( 'Take Photo', 'buddypress' ), 'order' => 10 );
227
-
228
- // Set warning messages
229
- $strings['camera_warnings'] = array(
230
- 'requesting' => __( 'Please allow us to access to your camera.', 'buddypress'),
231
- 'loading' => __( 'Please wait as we access your camera.', 'buddypress' ),
232
- 'loaded' => __( 'Camera loaded. Click on the "Capture" button to take your photo.', 'buddypress' ),
233
- 'noaccess' => __( 'It looks like you do not have a webcam or we were unable to get permission to use your webcam. Please upload a photo instead.', 'buddypress' ),
234
- 'errormsg' => __( 'Your browser is not supported. Please upload a photo instead.', 'buddypress' ),
235
- 'videoerror' => __( 'Video error. Please upload a photo instead.', 'buddypress' ),
236
- 'ready' => __( 'Your profile photo is ready. Click on the "Save" button to use this photo.', 'buddypress' ),
237
- 'nocapture' => __( 'No photo was captured. Click on the "Capture" button to take your photo.', 'buddypress' ),
238
- );
239
- }
240
-
241
- /**
242
- * Use this filter to add a navigation to a custom tool to set the object's avatar
243
- *
244
- * @since BuddyPress (2.3.0)
245
- *
246
- * @param array $avatar_nav An associative array of available nav items where each item is an array organized this way:
247
- * $avatar_nav[ $nav_item_id ] {
248
- * @type string $nav_item_id the nav item id in lower case without special characters or space
249
- * @type string $caption the name of the item nav that will be displayed in the nav
250
- * @type int $order An integer to specify the priority of the item nav, choose one
251
- * between 1 and 99 to be after the uploader nav item and before the delete nav item
252
- * @type int $hide if set to 1 the item nav will be hidden
253
- * (only used for the delete nav item)
254
- * }
255
- * @param string $object the object the avatar belongs to (eg: user or group)
256
- */
257
- $settings['nav'] = bp_sort_by_key( apply_filters( 'bp_attachments_avatar_nav', $avatar_nav, $object ), 'order', 'num' );
258
- }
259
-
260
- // Set Plupload settings
261
- $settings['defaults'] = $defaults;
262
-
263
- /**
264
- * Enqueue some extra styles if required
265
- *
266
- * Extra styles need to be registered.
267
- */
268
- if ( ! empty( $args['extra_css'] ) ) {
269
- foreach ( (array) $args['extra_css'] as $css ) {
270
- if ( empty( $css ) ) {
271
- continue;
272
- }
273
-
274
- wp_enqueue_style( $css );
275
- }
276
- }
277
-
278
- wp_enqueue_script ( 'bp-plupload' );
279
- wp_localize_script( 'bp-plupload', 'BP_Uploader', array( 'strings' => $strings, 'settings' => $settings ) );
280
-
281
- /**
282
- * Enqueue some extra scripts if required
283
- *
284
- * Extra scripts need to be registered.
285
- */
286
- if ( ! empty( $args['extra_js'] ) ) {
287
- foreach ( (array) $args['extra_js'] as $js ) {
288
- if ( empty( $js ) ) {
289
- continue;
290
- }
291
-
292
- wp_enqueue_script( $js );
293
- }
294
- }
295
-
296
- /**
297
- * Fires at the conclusion of bp_attachments_enqueue_scripts()
298
- * to avoid the scripts to be loaded more than once.
299
- *
300
- * @since BuddyPress 2.3.0
301
- */
302
- do_action( 'bp_attachments_enqueue_scripts' );
303
- }
304
-
305
- /**
306
- * Check the current user's capability to edit an avatar for a given object
307
- *
308
- * @since BuddyPress (2.3.0)
309
- *
310
- * @param string $capability the capability to check
311
- * @param array $args an array containing the item_id and the object to check
312
- */
313
- function bp_attachments_current_user_can( $capability, $args = array() ) {
314
- $can = false;
315
-
316
- if ( 'edit_avatar' === $capability ) {
317
- /**
318
- * Needed avatar arguments are set.
319
- */
320
- if ( isset( $args['item_id'] ) && isset( $args['object'] ) ) {
321
- // Group profile photo
322
- if ( bp_is_active( 'groups' ) && 'group' === $args['object'] ) {
323
- if ( bp_is_group_create() ) {
324
- $can = (bool) groups_is_user_creator( bp_loggedin_user_id(), $args['item_id'] ) || bp_current_user_can( 'bp_moderate' );
325
- } else {
326
- $can = (bool) groups_is_user_admin( bp_loggedin_user_id(), $args['item_id'] ) || bp_current_user_can( 'bp_moderate' );
327
- }
328
- // User profile photo
329
- } elseif ( bp_is_active( 'xprofile' ) && 'user' === $args['object'] ) {
330
- $can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can( 'bp_moderate' );
331
- }
332
- /**
333
- * No avatar arguments, fallback to bp_user_can_create_groups()
334
- * or bp_is_item_admin()
335
- */
336
- } else {
337
- if ( bp_is_group_create() ) {
338
- $can = bp_user_can_create_groups();
339
- } else {
340
- $can = bp_is_item_admin();
341
- }
342
- }
343
- }
344
-
345
- return apply_filters( 'bp_attachments_current_user_can', $can, $capability, $args );
346
- }
347
-
348
- /**
349
- * Send a JSON response back to an Ajax upload request.
350
- *
351
- * @since BuddyPress (2.3.0)
352
- *
353
- * @param bool true for a success, false otherwise
354
- * @param bool true if the Plupload runtime used is html4, false otherwise.
355
- * @param mixed $data Data to encode as JSON, then print and die.
356
- */
357
- function bp_attachments_json_response( $success, $is_html4 = false, $data = null ) {
358
- $response = array( 'success' => $success );
359
-
360
- if ( isset( $data ) ) {
361
- $response['data'] = $data;
362
- }
363
-
364
- // Send regular json response
365
- if ( ! $is_html4 ) {
366
- wp_send_json( $response );
367
-
368
- /**
369
- * Send specific json response
370
- * the html4 Plupload handler requires a text/html content-type for older IE.
371
- * See https://core.trac.wordpress.org/ticket/31037
372
- */
373
- } else {
374
- echo wp_json_encode( $response );
375
-
376
- wp_die();
377
- }
378
- }
379
-
380
- /**
381
- * Get an Attachment template part.
382
- *
383
- * @since BuddyPress (2.3.0)
384
- *
385
- * @param string Template part slug. eg 'uploader' for 'uploader.php'.
386
- */
387
- function bp_attachments_get_template_part( $slug ) {
388
- $attachment_template_part = 'assets/_attachments/' . $slug;
389
-
390
- // Load the attachment template in WP Administratin screens
391
- if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
392
- $attachment_admin_template_part = buddypress()->themes_dir . '/bp-legacy/buddypress/' . $attachment_template_part . '.php';
393
-
394
- // Check the template part exists
395
- if ( ! file_exists( $attachment_admin_template_part ) ) {
396
- return false;
397
- }
398
-
399
- // load the template part
400
- require( $attachment_admin_template_part );
401
-
402
- // Load the attachment template in WP_USE_THEMES env.
403
- } else {
404
- bp_get_template_part( $attachment_template_part );
405
- }
406
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-avatars.php CHANGED
@@ -31,11 +31,10 @@ function bp_core_set_avatar_constants() {
31
 
32
  if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) {
33
 
34
- $fileupload_maxk = bp_core_get_root_option( 'fileupload_maxk' );
35
- if ( '' === $fileupload_maxk ) {
36
  define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); // 5mb
37
  } else {
38
- define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $fileupload_maxk * 1024 );
39
  }
40
  }
41
 
@@ -87,11 +86,6 @@ function bp_core_set_avatar_globals() {
87
  if ( ! defined( 'BP_AVATAR_URL' ) )
88
  define( 'BP_AVATAR_URL', $bp->avatar->url );
89
 
90
- /**
91
- * Fires at the end of the core avatar globals setup.
92
- *
93
- * @since BuddyPress (1.5.0)
94
- */
95
  do_action( 'bp_core_set_avatar_globals' );
96
  }
97
  add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
@@ -231,15 +225,6 @@ function bp_core_fetch_avatar( $args = '' ) {
231
  break;
232
  }
233
 
234
- /**
235
- * Filters the ID of the item being requested.
236
- *
237
- * @since BuddyPress (1.1.0)
238
- *
239
- * @param string $value ID of avatar item being requested.
240
- * @param string $value Avatar type being requested.
241
- * @param array $params Array of parameters for the request.
242
- */
243
  $params['item_id'] = apply_filters( 'bp_core_avatar_item_id', $params['item_id'], $params['object'], $params );
244
 
245
  if ( empty( $params['item_id'] ) ) {
@@ -272,15 +257,6 @@ function bp_core_fetch_avatar( $args = '' ) {
272
  break;
273
  }
274
 
275
- /**
276
- * Filters the avatar directory to use.
277
- *
278
- * @since BuddyPress (1.1.0)
279
- *
280
- * @param string $value Name of the subdirectory where the requested avatar should be found.
281
- * @param string $value Avatar type being requested.
282
- * @param array $params Array of parameters for the request.
283
- */
284
  $params['avatar_dir'] = apply_filters( 'bp_core_avatar_dir', $params['avatar_dir'], $params['object'], $params );
285
 
286
  if ( empty( $params['avatar_dir'] ) ) {
@@ -308,16 +284,6 @@ function bp_core_fetch_avatar( $args = '' ) {
308
  break;
309
  }
310
 
311
- /**
312
- * Filters the alt attribute value to be applied to avatar.
313
- *
314
- * @since BuddyPress (1.5.0)
315
- *
316
- * @param string $value alt to be applied to avatar.
317
- * @param string $value ID of avatar item being requested.
318
- * @param string $value Avatar type being requested.
319
- * @param array $params Array of parameters for the request.
320
- */
321
  $item_name = apply_filters( 'bp_core_avatar_alt', $item_name, $params['item_id'], $params['object'], $params );
322
  $params['alt'] = sprintf( $params['alt'], $item_name );
323
  }
@@ -332,17 +298,6 @@ function bp_core_fetch_avatar( $args = '' ) {
332
 
333
  // Filter image title and create html string
334
  $html_title = '';
335
-
336
- /**
337
- * Filters the title attribute value to be applied to avatar.
338
- *
339
- * @since BuddyPress (1.5.0)
340
- *
341
- * @param string $value Title to be applied to avatar.
342
- * @param string $value ID of avatar item being requested.
343
- * @param string $value Avatar type being requested.
344
- * @param array $params Array of parameters for the request.
345
- */
346
  $params['title'] = apply_filters( 'bp_core_avatar_title', $params['title'], $params['item_id'], $params['object'], $params );
347
 
348
  if ( ! empty( $params['title'] ) ) {
@@ -351,17 +306,6 @@ function bp_core_fetch_avatar( $args = '' ) {
351
 
352
  // Set CSS ID and create html string
353
  $html_css_id = '';
354
-
355
- /**
356
- * Filters the ID attribute to be applied to avatar.
357
- *
358
- * @since BuddyPress (2.2.0)
359
- *
360
- * @param string $value ID to be applied to avatar.
361
- * @param string $value ID of avatar item being requested.
362
- * @param string $value Avatar type being requested.
363
- * @param array $params Array of parameters for the request.
364
- */
365
  $params['css_id'] = apply_filters( 'bp_core_css_id', $params['css_id'], $params['item_id'], $params['object'], $params );
366
 
367
  if ( ! empty( $params['css_id'] ) ) {
@@ -388,16 +332,7 @@ function bp_core_fetch_avatar( $args = '' ) {
388
  }
389
  $html_height = ' height="' . $params['height'] . '"';
390
 
391
- /**
392
- * Filters the classes to be applied to the avatar.
393
- *
394
- * @since BuddyPress (1.6.0)
395
- *
396
- * @param array|string $value Class(es) to be applied to the avatar.
397
- * @param string $value ID of the avatar item being requested.
398
- * @param string $value Avatar type being requested.
399
- * @param array $params Array of parameters for the request.
400
- */
401
  $params['class'] = apply_filters( 'bp_core_avatar_class', $params['class'], $params['item_id'], $params['object'], $params );
402
 
403
  // Use an alias to leave the param unchanged
@@ -424,29 +359,7 @@ function bp_core_fetch_avatar( $args = '' ) {
424
  $avatar_loc->url = trailingslashit( bp_core_avatar_url() );
425
 
426
  $avatar_loc->dir = trailingslashit( $params['avatar_dir'] );
427
-
428
- /**
429
- * Filters the avatar folder directory URL.
430
- *
431
- * @since BuddyPress (1.1.0)
432
- *
433
- * @param string $value Path to the avatar folder URL.
434
- * @param int $value ID of the avatar item being requested.
435
- * @param string $value Avatar type being requested.
436
- * @param string $value Subdirectory where the requested avatar should be found.
437
- */
438
  $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', ( $avatar_loc->url . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] );
439
-
440
- /**
441
- * Filters the avatar folder directory path.
442
- *
443
- * @since BuddyPress (1.1.0)
444
- *
445
- * @param string $value Path to the avatar folder directory.
446
- * @param int $value ID of the avatar item being requested.
447
- * @param string $value Avatar type being requested.
448
- * @param string $value Subdirectory where the requested avatar should be found.
449
- */
450
  $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', ( $avatar_loc->path . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] );
451
 
452
  /**
@@ -511,63 +424,24 @@ function bp_core_fetch_avatar( $args = '' ) {
511
 
512
  // Return it wrapped in an <img> element
513
  if ( true === $params['html'] ) {
514
-
515
- /**
516
- * Filters an avatar URL wrapped in an <img> element.
517
- *
518
- * @since BuddyPress (1.1.0)
519
- *
520
- * @param string $value Full <img> element for an avatar.
521
- * @param array $params Array of parameters for the request.
522
- * @param string $value ID of the item requested.
523
- * @param string $value Subdirectory where the requested avatar should be found.
524
- * @param string $html_css_id ID attribute for avatar.
525
- * @param string $html_width Width attribute for avatar.
526
- * @param string $html_height Height attribtue for avatar.
527
- * @param string $avatar_folder_url Avatar URL path.
528
- * @param string $avatar_folder_dir Avatar dir path.
529
- */
530
  return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '"' . $html_class . $html_css_id . $html_width . $html_height . $html_alt . $html_title . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
531
 
532
  // ...or only the URL
533
  } else {
534
-
535
- /**
536
- * Filters a locally uploaded avatar URL.
537
- *
538
- * @since BuddyPress (1.2.5)
539
- *
540
- * @param string $avatar_url URL for a locally uploaded avatar.
541
- * @param array $params Array of parameters for the request.
542
- */
543
  return apply_filters( 'bp_core_fetch_avatar_url', $avatar_url, $params );
544
  }
545
  }
546
  }
547
 
548
- /**
549
- * Filters whether or not to skip Gravatar check.
550
- *
551
- * @since BuddyPress (1.5.0)
552
- *
553
- * @param bool $value Whether or not to skip Gravatar.
554
- * @param array $params Array of parameters for the avatar request.
555
- */
556
  if ( ! apply_filters( 'bp_core_fetch_avatar_no_grav', $params['no_grav'], $params ) ) {
557
 
558
  // Set gravatar type
559
  if ( empty( $bp->grav_default->{$params['object']} ) ) {
560
  $default_grav = 'wavatar';
561
  } elseif ( 'mystery' == $bp->grav_default->{$params['object']} ) {
562
-
563
- /**
564
- * Filters the Mysteryman avatar src value.
565
- *
566
- * @since BuddyPress (1.2.0)
567
- *
568
- * @param string $value Avatar value.
569
- * @param string $value Width to display avatar at.
570
- */
571
  $default_grav = apply_filters( 'bp_core_mysteryman_src', 'mm', $params['width'] );
572
  } else {
573
  $default_grav = $bp->grav_default->{$params['object']};
@@ -582,26 +456,14 @@ function bp_core_fetch_avatar( $args = '' ) {
582
  }
583
  }
584
 
585
- $host = '//www.gravatar.com/avatar/';
 
 
 
 
586
 
587
- /**
588
- * Filters the Gravatar email to use.
589
- *
590
- * @since BuddyPress (1.1.0)
591
- *
592
- * @param string $value Email to use in Gravatar request.
593
- * @param string $value ID of the item being requested.
594
- * @param string $value Object type being requested.
595
- */
596
  $params['email'] = apply_filters( 'bp_core_gravatar_email', $params['email'], $params['item_id'], $params['object'] );
597
-
598
- /**
599
- * Filters the Gravatar URL path.
600
- *
601
- * @since BuddyPress (1.0.2)
602
- *
603
- * @param string $value Gravatar URL path.
604
- */
605
  $gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $params['email'] ) ) . '?d=' . $default_grav . '&amp;s=' . $params['width'];
606
 
607
  // Gravatar rating; http://bit.ly/89QxZA
@@ -612,27 +474,12 @@ function bp_core_fetch_avatar( $args = '' ) {
612
 
613
  // No avatar was found, and we've been told not to use a gravatar.
614
  } else {
615
-
616
- /**
617
- * Filters the avatar default when Gravatar is not used.
618
- *
619
- * This is a variable filter dependent on the avatar type being requested.
620
- *
621
- * @since BuddyPress (1.5.0)
622
- *
623
- * @param string $value Default avatar for non-gravatar requests.
624
- * @param array $params Array of parameters for the avatar request.
625
- */
626
  $gravatar = apply_filters( 'bp_core_default_avatar_' . $params['object'], bp_core_avatar_default( 'local' ), $params );
627
  }
628
 
629
  if ( true === $params['html'] ) {
630
-
631
- /** This filter is documented in bp-core/bp-core-avatars.php */
632
  return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '"' . $html_css_id . $html_class . $html_width . $html_height . $html_alt . $html_title . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
633
  } else {
634
-
635
- /** This filter is documented in bp-core/bp-core-avatars.php */
636
  return apply_filters( 'bp_core_fetch_avatar_url', $gravatar, $params );
637
  }
638
  }
@@ -671,7 +518,6 @@ function bp_core_delete_existing_avatar( $args = '' ) {
671
  elseif ( 'blog' == $object )
672
  $item_id = $current_blog->id;
673
 
674
- /** This filter is documented in bp-core/bp-core-avatars.php */
675
  $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
676
 
677
  if ( !$item_id ) return false;
@@ -685,13 +531,11 @@ function bp_core_delete_existing_avatar( $args = '' ) {
685
  elseif ( 'blog' == $object )
686
  $avatar_dir = 'blog-avatars';
687
 
688
- /** This filter is documented in bp-core/bp-core-avatars.php */
689
  $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
690
 
691
  if ( !$avatar_dir ) return false;
692
  }
693
 
694
- /** This filter is documented in bp-core/bp-core-avatars.php */
695
  $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
696
 
697
  if ( !file_exists( $avatar_folder_dir ) )
@@ -707,73 +551,11 @@ function bp_core_delete_existing_avatar( $args = '' ) {
707
 
708
  @rmdir( $avatar_folder_dir );
709
 
710
- /**
711
- * Fires after deleting an existing avatar.
712
- *
713
- * @since BuddyPress (1.1.0)
714
- *
715
- * @param array $args Array of arguments used for avatar deletion.
716
- */
717
  do_action( 'bp_core_delete_existing_avatar', $args );
718
 
719
  return true;
720
  }
721
 
722
- /**
723
- * Ajax delete an avatar for a given object and item id
724
- *
725
- * @since BuddyPress (2.3.0)
726
- *
727
- * @return string a json object containing success data if the avatar was deleted
728
- * error message otherwise
729
- */
730
- function bp_avatar_ajax_delete() {
731
- // Bail if not a POST action
732
- if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
733
- wp_send_json_error();
734
- }
735
-
736
- $avatar_data = $_POST;
737
-
738
- if ( empty( $avatar_data['object'] ) || empty( $avatar_data['item_id'] ) ) {
739
- wp_send_json_error();
740
- }
741
-
742
- $nonce = 'bp_delete_avatar_link';
743
- if ( 'group' === $avatar_data['object'] ) {
744
- $nonce = 'bp_group_avatar_delete';
745
- }
746
-
747
- // Check the nonce
748
- check_admin_referer( $nonce, 'nonce' );
749
-
750
- // Capability check
751
- if ( ! bp_attachments_current_user_can( 'edit_avatar', $avatar_data ) ) {
752
- wp_send_json_error();
753
- }
754
-
755
- // Handle delete
756
- if ( bp_core_delete_existing_avatar( array( 'item_id' => $avatar_data['item_id'], 'object' => $avatar_data['object'] ) ) ) {
757
- $return = array(
758
- 'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
759
- 'object' => $avatar_data['object'],
760
- 'item_id' => $avatar_data['item_id'],
761
- 'html' => false,
762
- 'type' => 'full',
763
- ) ) ),
764
- 'feedback_code' => 4,
765
- 'item_id' => $avatar_data['item_id'],
766
- );
767
-
768
- wp_send_json_success( $return );
769
- } else {
770
- wp_send_json_error( array(
771
- 'feedback_code' => 3,
772
- ) );
773
- }
774
- }
775
- add_action( 'wp_ajax_bp_avatar_delete', 'bp_avatar_ajax_delete' );
776
-
777
  /**
778
  * Handle avatar uploading.
779
  *
@@ -786,262 +568,130 @@ add_action( 'wp_ajax_bp_avatar_delete', 'bp_avatar_ajax_delete' );
786
  * @see bp_core_check_avatar_upload()
787
  * @see bp_core_check_avatar_type()
788
  *
789
- * @param array $file The appropriate entry the from $_FILES superglobal.
790
  * @param string $upload_dir_filter A filter to be applied to 'upload_dir'.
791
- *
792
  * @return bool True on success, false on failure.
793
  */
794
  function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
795
 
796
- /**
797
- * Filters whether or not to handle uploading.
798
- *
799
- * If you want to override this function, make sure you return false.
800
- *
801
- * @since BuddyPress (1.2.4)
802
- *
803
- * @param bool $value Whether or not to crop.
804
- * @param array $file Appropriate entry from $_FILES superglobal.
805
- * @parma string $upload_dir_filter A filter to be applied to 'upload_dir'.
806
  */
807
- if ( ! apply_filters( 'bp_core_pre_avatar_handle_upload', true, $file, $upload_dir_filter ) ) {
808
  return true;
809
- }
810
 
811
- // Setup some variables
812
- $bp = buddypress();
813
- $upload_path = bp_core_avatar_upload_path();
814
 
815
- // Upload the file
816
- $avatar_attachment = new BP_Attachment_Avatar();
817
- $bp->avatar_admin->original = $avatar_attachment->upload( $file, $upload_dir_filter );
 
 
 
 
 
818
 
819
- // In case of an error, stop the process and display a feedback to the user
820
- if ( ! empty( $bp->avatar_admin->original['error'] ) ) {
821
- bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
822
  return false;
823
  }
824
 
825
- // Maybe resize
826
- $bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'] );
827
- $bp->avatar_admin->image = new stdClass();
828
-
829
- // We only want to handle one image after resize.
830
- if ( empty( $bp->avatar_admin->resized ) ) {
831
- $bp->avatar_admin->image->file = $bp->avatar_admin->original['file'];
832
- $bp->avatar_admin->image->dir = str_replace( $upload_path, '', $bp->avatar_admin->original['file'] );
833
- } else {
834
- $bp->avatar_admin->image->file = $bp->avatar_admin->resized['path'];
835
- $bp->avatar_admin->image->dir = str_replace( $upload_path, '', $bp->avatar_admin->resized['path'] );
836
- @unlink( $bp->avatar_admin->original['file'] );
837
- }
838
-
839
- // Check for WP_Error on what should be an image
840
- if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
841
- bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
842
  return false;
843
  }
844
 
845
- // If the uploaded image is smaller than the "full" dimensions, throw a warning
846
- if ( $avatar_attachment->is_too_small( $bp->avatar_admin->image->file ) ) {
847
- bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %d x %d pixels.', 'buddypress' ), bp_core_avatar_full_width(), bp_core_avatar_full_height() ), 'error' );
848
- }
849
-
850
- // Set the url value for the image
851
- $bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
852
-
853
- return true;
854
- }
855
-
856
- /**
857
- * Ajax upload an avatar
858
- *
859
- * @since BuddyPress (2.3.0)
860
- *
861
- * @return string a json object containing success data if the upload succeeded
862
- * error message otherwise
863
- */
864
- function bp_avatar_ajax_upload() {
865
- // Bail if not a POST action
866
- if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
867
- wp_die();
868
  }
869
 
870
- /**
871
- * Sending the json response will be different if
872
- * the current Plupload runtime is html4
873
- */
874
- $is_html4 = false;
875
- if ( ! empty( $_POST['html4' ] ) ) {
876
- $is_html4 = true;
877
- }
878
 
879
- // Check the nonce
880
- check_admin_referer( 'bp-uploader' );
881
 
882
- // Init the BuddyPress parameters
883
- $bp_params = array();
884
 
885
- // We need it to carry on
886
- if ( ! empty( $_POST['bp_params' ] ) ) {
887
- $bp_params = $_POST['bp_params' ];
888
- } else {
889
- bp_attachments_json_response( false, $is_html4 );
890
- }
891
 
892
- // We need the object to set the uploads dir filter
893
- if ( empty( $bp_params['object'] ) ) {
894
- bp_attachments_json_response( false, $is_html4 );
 
895
  }
896
 
897
- // Capability check
898
- if ( ! bp_attachments_current_user_can( 'edit_avatar', $bp_params ) ) {
899
- bp_attachments_json_response( false, $is_html4 );
900
- }
901
 
902
- $bp = buddypress();
903
- $bp_params['upload_dir_filter'] = '';
904
- $needs_reset = array();
905
 
906
- if ( 'user' === $bp_params['object'] && bp_is_active( 'xprofile' ) ) {
907
- $bp_params['upload_dir_filter'] = 'xprofile_avatar_upload_dir';
908
 
909
- if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
910
- $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
911
- $bp->displayed_user->id = $bp_params['item_id'];
912
- }
913
- } elseif ( 'group' === $bp_params['object'] && bp_is_active( 'groups' ) ) {
914
- $bp_params['upload_dir_filter'] = 'groups_avatar_upload_dir';
915
-
916
- if ( ! bp_get_current_group_id() && ! empty( $bp_params['item_id'] ) ) {
917
- $needs_reset = array( 'component' => 'groups', 'key' => 'current_group', 'value' => $bp->groups->current_group );
918
- $bp->groups->current_group = groups_get_group( array(
919
- 'group_id' => $bp_params['item_id'],
920
- 'populate_extras' => false,
921
- ) );
922
- }
923
- } else {
924
- /**
925
- * Filter here to deal with other components
926
- *
927
- * @since BuddyPress (2.3.0)
928
- *
929
- * @var array $bp_params the BuddyPress Ajax parameters
930
- */
931
- $bp_params = apply_filters( 'bp_core_avatar_ajax_upload_params', $bp_params );
932
- }
933
 
934
- if ( ! isset( $bp->avatar_admin ) ) {
935
- $bp->avatar_admin = new stdClass();
936
- }
 
937
 
938
- // Upload the avatar
939
- $avatar = bp_core_avatar_handle_upload( $_FILES, $bp_params['upload_dir_filter'] );
 
 
940
 
941
- // Reset objects
942
- if ( ! empty( $needs_reset ) ) {
943
- if ( ! empty( $needs_reset['component'] ) ) {
944
- $bp->{$needs_reset['component']}->{$needs_reset['key']} = $needs_reset['value'];
945
  } else {
946
- $bp->{$needs_reset['key']} = $needs_reset['value'];
947
  }
948
- }
949
-
950
- // Init the feedback message
951
- $feedback_message = false;
952
-
953
- if ( ! empty( $bp->template_message ) ) {
954
- $feedback_message = $bp->template_message;
955
-
956
- // Remove template message.
957
- $bp->template_message = false;
958
- $bp->template_message_type = false;
959
- @setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );
960
- @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
961
- }
962
 
963
- if ( empty( $avatar ) ) {
964
- // Default upload error
965
- $message = __( 'Upload failed.', 'buddypress' );
966
-
967
- // Use the template message if set
968
- if ( ! empty( $feedback_message ) ) {
969
- $message = $feedback_message;
970
  }
971
-
972
- // Upload error reply
973
- bp_attachments_json_response( false, $is_html4, array(
974
- 'type' => 'upload_error',
975
- 'message' => $message,
976
- ) );
977
- }
978
-
979
- if ( empty( $bp->avatar_admin->image->file ) ) {
980
- bp_attachments_json_response( false, $is_html4 );
981
  }
982
 
983
- $uploaded_image = @getimagesize( $bp->avatar_admin->image->file );
984
-
985
- // Set the name of the file
986
- $name = $_FILES['file']['name'];
987
- $name_parts = pathinfo( $name );
988
- $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
989
-
990
- // Finally return the avatar to the editor
991
- bp_attachments_json_response( true, $is_html4, array(
992
- 'name' => $name,
993
- 'url' => $bp->avatar_admin->image->url,
994
- 'width' => $uploaded_image[0],
995
- 'height' => $uploaded_image[1],
996
- 'feedback' => $feedback_message,
997
- ) );
998
- }
999
- add_action( 'wp_ajax_bp_avatar_upload', 'bp_avatar_ajax_upload' );
1000
 
1001
- /**
1002
- * Handle avatar webcam capture.
1003
- *
1004
- * @since BuddyPress (2.3.0)
1005
- *
1006
- * @param string $data base64 encoded image.
1007
- * @param int $item_id.
1008
- * @return bool True on success, false on failure.
1009
- */
1010
- function bp_avatar_handle_capture( $data = '', $item_id = 0 ) {
1011
- if ( empty( $data ) || empty( $item_id ) ) {
1012
- return false;
1013
  }
1014
 
1015
- $avatar_dir = bp_core_avatar_upload_path() . '/avatars';
1016
-
1017
- // It's not a regular upload, we may need to create this folder
1018
- if ( ! file_exists( $avatar_dir ) ) {
1019
- if ( ! wp_mkdir_p( $avatar_dir ) ) {
1020
- return false;
1021
- }
1022
  }
1023
 
1024
- $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', $avatar_dir . '/' . $item_id, $item_id, 'user', 'avatars' );
1025
-
1026
- // It's not a regular upload, we may need to create this folder
1027
- if( ! is_dir( $avatar_folder_dir ) ) {
1028
- if ( ! wp_mkdir_p( $avatar_folder_dir ) ) {
1029
- return false;
1030
- }
1031
  }
1032
 
1033
- $original_file = $avatar_folder_dir . '/webcam-capture-' . $item_id . '.png';
1034
-
1035
- if ( file_put_contents( $original_file, $data ) ) {
1036
- $avatar_to_crop = str_replace( bp_core_avatar_upload_path(), '', $original_file );
1037
-
1038
- // Crop to default values
1039
- $crop_args = array( 'item_id' => $item_id, 'original_file' => $avatar_to_crop, 'crop_x' => 0, 'crop_y' => 0 );
1040
 
1041
- return bp_core_avatar_handle_crop( $crop_args );
1042
- } else {
1043
- return false;
1044
- }
1045
  }
1046
 
1047
  /**
@@ -1088,168 +738,110 @@ function bp_core_avatar_handle_crop( $args = '' ) {
1088
  'crop_y' => 0
1089
  ) );
1090
 
1091
- /**
1092
- * Filters whether or not to handle cropping.
1093
- *
1094
- * If you want to override this function, make sure you return false.
1095
- *
1096
- * @since BuddyPress (1.2.4)
1097
- *
1098
- * @param bool $value Whether or not to crop.
1099
- * @param array $r Array of parsed arguments for function
1100
  */
1101
- if ( ! apply_filters( 'bp_core_pre_avatar_handle_crop', true, $r ) ) {
1102
  return true;
 
 
 
 
 
 
 
 
 
 
1103
  }
1104
 
1105
- // Crop the file
1106
- $avatar_attachment = new BP_Attachment_Avatar();
1107
- $cropped = $avatar_attachment->crop( $r );
1108
 
1109
- // Check for errors
1110
- if ( empty( $cropped['full'] ) || empty( $cropped['thumb'] ) || is_wp_error( $cropped['full'] ) || is_wp_error( $cropped['thumb'] ) ) {
1111
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
1112
  }
1113
 
1114
- return true;
1115
- }
 
1116
 
1117
- /**
1118
- * Ajax set an avatar for a given object and item id
1119
- *
1120
- * @since BuddyPress (2.3.0)
1121
- *
1122
- * @return string a json object containing success data if the crop/capture succeeded
1123
- * error message otherwise
1124
- */
1125
- function bp_avatar_ajax_set() {
1126
- // Bail if not a POST action
1127
- if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
1128
- wp_send_json_error();
1129
  }
1130
 
1131
- // Check the nonce
1132
- check_admin_referer( 'bp_avatar_cropstore', 'nonce' );
 
 
 
1133
 
1134
- $avatar_data = wp_parse_args( $_POST, array(
1135
- 'crop_w' => bp_core_avatar_full_width(),
1136
- 'crop_h' => bp_core_avatar_full_height(),
1137
- 'crop_x' => 0,
1138
- 'crop_y' => 0
1139
  ) );
1140
 
1141
- if ( empty( $avatar_data['object'] ) || empty( $avatar_data['item_id'] ) || empty( $avatar_data['original_file'] ) ) {
1142
- wp_send_json_error();
1143
- }
 
 
 
1144
 
1145
- // Capability check
1146
- if ( ! bp_attachments_current_user_can( 'edit_avatar', $avatar_data ) ) {
1147
- wp_send_json_error();
1148
  }
1149
 
1150
- if ( ! empty( $avatar_data['type'] ) && 'camera' === $avatar_data['type'] && 'user' === $avatar_data['object'] ) {
1151
- $webcam_avatar = false;
1152
 
1153
- if ( ! empty( $avatar_data['original_file'] ) ) {
1154
- $webcam_avatar = str_replace( array( 'data:image/png;base64,', ' ' ), array( '', '+' ), $avatar_data['original_file'] );
1155
- $webcam_avatar = base64_decode( $webcam_avatar );
1156
- }
1157
-
1158
- if ( ! bp_avatar_handle_capture( $webcam_avatar, $avatar_data['item_id'] ) ) {
1159
- wp_send_json_error( array(
1160
- 'feedback_code' => 1
1161
- ) );
1162
 
1163
- } else {
1164
- $return = array(
1165
- 'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
1166
- 'object' => $avatar_data['object'],
1167
- 'item_id' => $avatar_data['item_id'],
1168
- 'html' => false,
1169
- 'type' => 'full',
1170
- ) ) ),
1171
- 'feedback_code' => 2,
1172
- 'item_id' => $avatar_data['item_id'],
1173
- );
1174
-
1175
- /**
1176
- * Fires if the new avatar was successfully captured.
1177
- *
1178
- * @since 1.1.0 Used to inform the avatar was successfully cropped
1179
- * @since 2.3.4 Add two new parameters to inform about the user id and
1180
- * about the way the avatar was set (eg: 'crop' or 'camera')
1181
- * Move the action at the right place, once the avatar is set
1182
- *
1183
- * @param string $item_id Inform about the user id the avatar was set for
1184
- * @param string $type Inform about the way the avatar was set ('camera')
1185
- */
1186
- do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'] );
1187
-
1188
- wp_send_json_success( $return );
1189
- }
1190
 
1191
- return;
 
1192
  }
1193
 
1194
- $original_file = str_replace( bp_core_avatar_url(), '', $avatar_data['original_file'] );
 
 
1195
 
1196
- // Set avatars dir & feedback part
1197
- if ( 'user' === $avatar_data['object'] ) {
1198
- $avatar_dir = 'avatars';
1199
 
1200
- // Defaults to object-avatars dir
1201
- } else {
1202
- $avatar_dir = sanitize_key( $avatar_data['object'] ) . '-avatars';
1203
- }
1204
 
1205
- // Crop args
1206
- $r = array(
1207
- 'item_id' => $avatar_data['item_id'],
1208
- 'object' => $avatar_data['object'],
1209
- 'avatar_dir' => $avatar_dir,
1210
- 'original_file' => $original_file,
1211
- 'crop_w' => $avatar_data['crop_w'],
1212
- 'crop_h' => $avatar_data['crop_h'],
1213
- 'crop_x' => $avatar_data['crop_x'],
1214
- 'crop_y' => $avatar_data['crop_y']
1215
- );
1216
 
1217
- // Handle crop
1218
- if ( bp_core_avatar_handle_crop( $r ) ) {
1219
- $return = array(
1220
- 'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
1221
- 'object' => $avatar_data['object'],
1222
- 'item_id' => $avatar_data['item_id'],
1223
- 'html' => false,
1224
- 'type' => 'full',
1225
- ) ) ),
1226
- 'feedback_code' => 2,
1227
- 'item_id' => $avatar_data['item_id'],
1228
- );
1229
-
1230
- if ( 'user' === $avatar_data['object'] ) {
1231
- /**
1232
- * Fires if the new avatar was successfully cropped.
1233
- *
1234
- * @since 1.1.0 Used to inform the avatar was successfully cropped
1235
- * @since 2.3.4 Add two new parameters to inform about the user id and
1236
- * about the way the avatar was set (eg: 'crop' or 'camera')
1237
- * Move the action at the right place, once the avatar is set
1238
- *
1239
- * @param string $item_id Inform about the user id the avatar was set for
1240
- * @param string $type Inform about the way the avatar was set ('crop')
1241
- */
1242
- do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'] );
1243
- }
1244
 
1245
- wp_send_json_success( $return );
1246
- } else {
1247
- wp_send_json_error( array(
1248
- 'feedback_code' => 1,
1249
- ) );
1250
- }
1251
  }
1252
- add_action( 'wp_ajax_bp_avatar_set', 'bp_avatar_ajax_set' );
1253
 
1254
  /**
1255
  * Replace default WordPress avatars with BP avatars, if available.
@@ -1344,53 +936,6 @@ function bp_core_check_avatar_size( $file ) {
1344
  return true;
1345
  }
1346
 
1347
- /**
1348
- * Get allowed avatar types
1349
- *
1350
- * @since BuddyPress (2.3.0)
1351
- */
1352
- function bp_core_get_allowed_avatar_types() {
1353
- $allowed_types = array( 'jpeg', 'gif', 'png' );
1354
-
1355
- /**
1356
- * Use this filter to restrict image types
1357
- *
1358
- * @since BuddyPress (2.3.0)
1359
- *
1360
- * @param array list of image types
1361
- */
1362
- $avatar_types = (array) apply_filters( 'bp_core_get_allowed_avatar_types', $allowed_types );
1363
-
1364
- if ( empty( $avatar_types ) ) {
1365
- $avatar_types = $allowed_types;
1366
- } else {
1367
- $avatar_types = array_intersect( $allowed_types, $avatar_types );
1368
- }
1369
-
1370
- return array_values( $avatar_types );
1371
- }
1372
-
1373
- /**
1374
- * Get allowed avatar mime types
1375
- *
1376
- * @since BuddyPress (2.3.0)
1377
- */
1378
- function bp_core_get_allowed_avatar_mimes() {
1379
- $allowed_types = bp_core_get_allowed_avatar_types();
1380
- $validate_mimes = wp_match_mime_types( join( ',', $allowed_types ), wp_get_mime_types() );
1381
- $allowed_mimes = array_map( 'implode', $validate_mimes );
1382
-
1383
- /**
1384
- * Include jpg type if needed so that bp_core_check_avatar_type()
1385
- * will check for jpeg and jpg extensions.
1386
- */
1387
- if ( isset( $allowed_mimes['jpeg'] ) ) {
1388
- $allowed_mimes['jpg'] = $allowed_mimes['jpeg'];
1389
- }
1390
-
1391
- return $allowed_mimes;
1392
- }
1393
-
1394
  /**
1395
  * Does the current avatar upload have an allowed file type?
1396
  *
@@ -1399,21 +944,26 @@ function bp_core_get_allowed_avatar_mimes() {
1399
  * @param array $file The $_FILES array.
1400
  * @return bool True if the file extension is permitted, otherwise false.
1401
  */
1402
- function bp_core_check_avatar_type( $file ) {
1403
- $avatar_filetype = wp_check_filetype_and_ext( $file['file']['tmp_name'], $file['file']['name'], bp_core_get_allowed_avatar_mimes() );
1404
-
1405
- if ( ! empty( $avatar_filetype['ext'] ) && ! empty( $avatar_filetype['type'] ) ) {
1406
- return true;
1407
- }
1408
 
1409
- return false;
1410
  }
1411
 
1412
  /**
1413
  * Fetch data from the BP root blog's upload directory.
1414
  *
 
 
 
 
 
 
1415
  * @since BuddyPress (1.8.0)
1416
  *
 
 
1417
  * @param string $type The variable we want to return from the $bp->avatars
1418
  * object. Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
1419
  * @return string The avatar upload directory path.
@@ -1455,9 +1005,16 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) {
1455
 
1456
  // No cache, so query for it
1457
  } else {
 
 
 
 
1458
 
1459
  // Get upload directory information from current site
1460
- $upload_dir = bp_upload_dir();
 
 
 
1461
 
1462
  // Stash upload directory data for later use
1463
  $bp->avatar->upload_dir = $upload_dir;
@@ -1489,38 +1046,22 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) {
1489
  /**
1490
  * Get the absolute upload path for the WP installation.
1491
  *
1492
- * @uses bp_core_get_upload_dir() To get upload directory info
1493
  *
1494
  * @return string Absolute path to WP upload directory.
1495
  */
1496
  function bp_core_avatar_upload_path() {
1497
-
1498
- /**
1499
- * Filters the absolute upload path for the WP installation.
1500
- *
1501
- * @since BuddyPress (1.2.0)
1502
- *
1503
- * @param string $value Absolute upload path for the WP installation.
1504
- */
1505
  return apply_filters( 'bp_core_avatar_upload_path', bp_core_get_upload_dir() );
1506
  }
1507
 
1508
  /**
1509
  * Get the raw base URL for root site upload location.
1510
  *
1511
- * @uses bp_core_get_upload_dir() To get upload directory info.
1512
  *
1513
  * @return string Full URL to current upload location.
1514
  */
1515
  function bp_core_avatar_url() {
1516
-
1517
- /**
1518
- * Filters the raw base URL for root site upload location.
1519
- *
1520
- * @since BuddyPress (1.2.0)
1521
- *
1522
- * @param string $value Raw base URL for the root site upload location.
1523
- */
1524
  return apply_filters( 'bp_core_avatar_url', bp_core_get_upload_dir( 'url' ) );
1525
  }
1526
 
@@ -1541,14 +1082,6 @@ function bp_get_user_has_avatar( $user_id = 0 ) {
1541
  if ( bp_core_fetch_avatar( array( 'item_id' => $user_id, 'no_grav' => true, 'html' => false ) ) != bp_core_avatar_default( 'local' ) )
1542
  $retval = true;
1543
 
1544
- /**
1545
- * Filters whether or not a user has an uploaded avatar.
1546
- *
1547
- * @since BuddyPress (1.6.0)
1548
- *
1549
- * @param bool $retval Whether or not a user has an uploaded avatar.
1550
- * @param int $user_id ID of the user being checked.
1551
- */
1552
  return (bool) apply_filters( 'bp_get_user_has_avatar', $retval, $user_id );
1553
  }
1554
 
@@ -1567,15 +1100,6 @@ function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
1567
  $bp = buddypress();
1568
  $dim = isset( $bp->avatar->{$type}->{$h_or_w} ) ? (int) $bp->avatar->{$type}->{$h_or_w} : false;
1569
 
1570
- /**
1571
- * Filters the avatar dimension setting.
1572
- *
1573
- * @since BuddyPress (1.5.0)
1574
- *
1575
- * @param int $dim Dimension setting for the type.
1576
- * @param string $type The type of avatar whose dimensions are requested. Default 'thumb'.
1577
- * @param string $h_or_w The dimension parameter being requested. Default 'height'.
1578
- */
1579
  return apply_filters( 'bp_core_avatar_dimension', $dim, $type, $h_or_w );
1580
  }
1581
 
@@ -1587,14 +1111,6 @@ function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
1587
  * @return int The 'thumb' width.
1588
  */
1589
  function bp_core_avatar_thumb_width() {
1590
-
1591
- /**
1592
- * Filters the 'thumb' avatar width setting.
1593
- *
1594
- * @since BuddyPress (1.5.0)
1595
- *
1596
- * @param int $value Value for the 'thumb' avatar width setting.
1597
- */
1598
  return apply_filters( 'bp_core_avatar_thumb_width', bp_core_avatar_dimension( 'thumb', 'width' ) );
1599
  }
1600
 
@@ -1606,14 +1122,6 @@ function bp_core_avatar_thumb_width() {
1606
  * @return int The 'thumb' height.
1607
  */
1608
  function bp_core_avatar_thumb_height() {
1609
-
1610
- /**
1611
- * Filters the 'thumb' avatar height setting.
1612
- *
1613
- * @since BuddyPress (1.5.0)
1614
- *
1615
- * @param int $value Value for the 'thumb' avatar height setting.
1616
- */
1617
  return apply_filters( 'bp_core_avatar_thumb_height', bp_core_avatar_dimension( 'thumb', 'height' ) );
1618
  }
1619
 
@@ -1625,14 +1133,6 @@ function bp_core_avatar_thumb_height() {
1625
  * @return int The 'full' width.
1626
  */
1627
  function bp_core_avatar_full_width() {
1628
-
1629
- /**
1630
- * Filters the 'full' avatar width setting.
1631
- *
1632
- * @since BuddyPress (1.5.0)
1633
- *
1634
- * @param int $value Value for the 'full' avatar width setting.
1635
- */
1636
  return apply_filters( 'bp_core_avatar_full_width', bp_core_avatar_dimension( 'full', 'width' ) );
1637
  }
1638
 
@@ -1644,14 +1144,6 @@ function bp_core_avatar_full_width() {
1644
  * @return int The 'full' height.
1645
  */
1646
  function bp_core_avatar_full_height() {
1647
-
1648
- /**
1649
- * Filters the 'full' avatar height setting.
1650
- *
1651
- * @since BuddyPress (1.5.0)
1652
- *
1653
- * @param int $value Value for the 'full' avatar height setting.
1654
- */
1655
  return apply_filters( 'bp_core_avatar_full_height', bp_core_avatar_dimension( 'full', 'height' ) );
1656
  }
1657
 
@@ -1663,14 +1155,6 @@ function bp_core_avatar_full_height() {
1663
  * @return int The max width for original avatar uploads.
1664
  */
1665
  function bp_core_avatar_original_max_width() {
1666
-
1667
- /**
1668
- * Filters the max width for original avatar uploads.
1669
- *
1670
- * @since BuddyPress (1.5.0)
1671
- *
1672
- * @param int $value Value for the max width.
1673
- */
1674
  return apply_filters( 'bp_core_avatar_original_max_width', (int) buddypress()->avatar->original_max_width );
1675
  }
1676
 
@@ -1682,14 +1166,6 @@ function bp_core_avatar_original_max_width() {
1682
  * @return int The max filesize for original avatar uploads.
1683
  */
1684
  function bp_core_avatar_original_max_filesize() {
1685
-
1686
- /**
1687
- * Filters the max filesize for original avatar uploads.
1688
- *
1689
- * @since BuddyPress (1.5.0)
1690
- *
1691
- * @param int $value Value for the max filesize.
1692
- */
1693
  return apply_filters( 'bp_core_avatar_original_max_filesize', (int) buddypress()->avatar->original_max_filesize );
1694
  }
1695
 
@@ -1714,16 +1190,15 @@ function bp_core_avatar_default( $type = 'gravatar' ) {
1714
 
1715
  // Use Gravatar's mystery man as fallback
1716
  } else {
1717
- $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_full_width();
 
 
 
 
 
 
1718
  }
1719
 
1720
- /**
1721
- * Filters the URL of the 'full' default avatar.
1722
- *
1723
- * @since BuddyPress (1.5.0)
1724
- *
1725
- * @param string $avatar URL of the default avatar.
1726
- */
1727
  return apply_filters( 'bp_core_avatar_default', $avatar );
1728
  }
1729
 
@@ -1751,16 +1226,15 @@ function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
1751
 
1752
  // Use Gravatar's mystery man as fallback
1753
  } else {
1754
- $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_thumb_width();
 
 
 
 
 
 
1755
  }
1756
 
1757
- /**
1758
- * Filters the URL of the 'thumb' default avatar.
1759
- *
1760
- * @since BuddyPress (1.5.0)
1761
- *
1762
- * @param string $avatar URL of the default avatar.
1763
- */
1764
  return apply_filters( 'bp_core_avatar_thumb', $avatar );
1765
  }
1766
 
@@ -1806,116 +1280,3 @@ function bp_core_avatar_reset_query( $posts_query = null ) {
1806
  }
1807
  }
1808
  add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );
1809
-
1810
- /**
1811
- * Checks whether Avatar UI should be loaded
1812
- *
1813
- * @since BuddyPress (2.3.0)
1814
- *
1815
- * @return bool True if Avatar UI should load, false otherwise
1816
- */
1817
- function bp_avatar_is_front_edit() {
1818
- $retval = false;
1819
-
1820
- // No need to carry on if the current WordPress version is not supported.
1821
- if ( ! bp_attachments_is_wp_version_supported() ) {
1822
- return $retval;
1823
- }
1824
-
1825
- if ( bp_is_user_change_avatar() && 'crop-image' !== bp_get_avatar_admin_step() ) {
1826
- $retval = ! bp_core_get_root_option( 'bp-disable-avatar-uploads' );
1827
- }
1828
-
1829
- if ( bp_is_active( 'groups' ) ) {
1830
- // Group creation
1831
- if ( bp_is_group_create() && bp_is_group_creation_step( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) {
1832
- $retval = ! bp_disable_group_avatar_uploads();
1833
-
1834
- // Group Manage
1835
- } elseif ( bp_is_group_admin_page() && bp_is_group_admin_screen( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) {
1836
- $retval = ! bp_disable_group_avatar_uploads();
1837
- }
1838
- }
1839
-
1840
- /**
1841
- * Use this filter if you need to :
1842
- * - Load the avatar UI for a component that is !groups or !user (return true regarding your conditions)
1843
- * - Completely disable the avatar UI introduced in 2.3 (eg: __return_false())
1844
- *
1845
- * @since BuddyPress (2.3.0)
1846
- *
1847
- * @var bool whether to load the Avatar UI
1848
- */
1849
- return apply_filters( 'bp_avatar_is_front_edit', $retval );
1850
- }
1851
-
1852
- /**
1853
- * Checks whether the Webcam Avatar UI part should be loaded
1854
- *
1855
- * @since BuddyPress (2.3.0)
1856
- *
1857
- * @global $is_safari
1858
- * @global $is_IE
1859
- * @return bool True to load the Webcam Avatar UI part. False otherwise.
1860
- */
1861
- function bp_avatar_use_webcam() {
1862
- global $is_safari, $is_IE;
1863
-
1864
- /**
1865
- * Do not use the webcam feature for mobile devices
1866
- * to avoid possible confusions.
1867
- */
1868
- if ( wp_is_mobile() ) {
1869
- return false;
1870
- }
1871
-
1872
- /**
1873
- * Bail when the browser does not support getUserMedia.
1874
- *
1875
- * @see http://caniuse.com/#feat=stream
1876
- */
1877
- if ( $is_safari || $is_IE ) {
1878
- return false;
1879
- }
1880
-
1881
- /**
1882
- * Use this filter if you need to disable the webcam capture feature
1883
- * by returning false.
1884
- *
1885
- * @since BuddyPress (2.3.0)
1886
- *
1887
- * @var bool whether to load Webcam Avatar UI part
1888
- */
1889
- return apply_filters( 'bp_avatar_use_webcam', true );
1890
- }
1891
-
1892
- /**
1893
- * Template function to load the Avatar UI javascript templates
1894
- *
1895
- * @since BuddyPress (2.3.0)
1896
- */
1897
- function bp_avatar_get_templates() {
1898
- if ( ! bp_avatar_is_front_edit() ) {
1899
- return;
1900
- }
1901
-
1902
- bp_attachments_get_template_part( 'avatars/index' );
1903
- }
1904
-
1905
- /**
1906
- * Trick to check if the theme's BuddyPress templates are up to date
1907
- *
1908
- * If the "avatar templates" are not including the new template tag, this will
1909
- * help users to get the avatar UI.
1910
- *
1911
- * @since BuddyPress (2.3.0)
1912
- */
1913
- function bp_avatar_template_check() {
1914
- if ( ! bp_avatar_is_front_edit() ) {
1915
- return;
1916
- }
1917
-
1918
- if ( ! did_action( 'bp_attachments_avatar_check_template' ) ) {
1919
- bp_attachments_get_template_part( 'avatars/index' );
1920
- }
1921
- }
31
 
32
  if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) {
33
 
34
+ if ( !isset( $bp->site_options['fileupload_maxk'] ) ) {
 
35
  define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); // 5mb
36
  } else {
37
+ define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $bp->site_options['fileupload_maxk'] * 1024 );
38
  }
39
  }
40
 
86
  if ( ! defined( 'BP_AVATAR_URL' ) )
87
  define( 'BP_AVATAR_URL', $bp->avatar->url );
88
 
 
 
 
 
 
89
  do_action( 'bp_core_set_avatar_globals' );
90
  }
91
  add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
225
  break;
226
  }
227
 
 
 
 
 
 
 
 
 
 
228
  $params['item_id'] = apply_filters( 'bp_core_avatar_item_id', $params['item_id'], $params['object'], $params );
229
 
230
  if ( empty( $params['item_id'] ) ) {
257
  break;
258
  }
259
 
 
 
 
 
 
 
 
 
 
260
  $params['avatar_dir'] = apply_filters( 'bp_core_avatar_dir', $params['avatar_dir'], $params['object'], $params );
261
 
262
  if ( empty( $params['avatar_dir'] ) ) {
284
  break;
285
  }
286
 
 
 
 
 
 
 
 
 
 
 
287
  $item_name = apply_filters( 'bp_core_avatar_alt', $item_name, $params['item_id'], $params['object'], $params );
288
  $params['alt'] = sprintf( $params['alt'], $item_name );
289
  }
298
 
299
  // Filter image title and create html string
300
  $html_title = '';
 
 
 
 
 
 
 
 
 
 
 
301
  $params['title'] = apply_filters( 'bp_core_avatar_title', $params['title'], $params['item_id'], $params['object'], $params );
302
 
303
  if ( ! empty( $params['title'] ) ) {
306
 
307
  // Set CSS ID and create html string
308
  $html_css_id = '';
 
 
 
 
 
 
 
 
 
 
 
309
  $params['css_id'] = apply_filters( 'bp_core_css_id', $params['css_id'], $params['item_id'], $params['object'], $params );
310
 
311
  if ( ! empty( $params['css_id'] ) ) {
332
  }
333
  $html_height = ' height="' . $params['height'] . '"';
334
 
335
+ // Create CSS class html string
 
 
 
 
 
 
 
 
 
336
  $params['class'] = apply_filters( 'bp_core_avatar_class', $params['class'], $params['item_id'], $params['object'], $params );
337
 
338
  // Use an alias to leave the param unchanged
359
  $avatar_loc->url = trailingslashit( bp_core_avatar_url() );
360
 
361
  $avatar_loc->dir = trailingslashit( $params['avatar_dir'] );
 
 
 
 
 
 
 
 
 
 
 
362
  $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', ( $avatar_loc->url . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] );
 
 
 
 
 
 
 
 
 
 
 
363
  $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', ( $avatar_loc->path . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] );
364
 
365
  /**
424
 
425
  // Return it wrapped in an <img> element
426
  if ( true === $params['html'] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '"' . $html_class . $html_css_id . $html_width . $html_height . $html_alt . $html_title . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
428
 
429
  // ...or only the URL
430
  } else {
 
 
 
 
 
 
 
 
 
431
  return apply_filters( 'bp_core_fetch_avatar_url', $avatar_url, $params );
432
  }
433
  }
434
  }
435
 
436
+ // If no avatars could be found, try to display a gravatar
437
+
438
+ // Skips gravatar check if $params['no_grav'] is passed
 
 
 
 
 
439
  if ( ! apply_filters( 'bp_core_fetch_avatar_no_grav', $params['no_grav'], $params ) ) {
440
 
441
  // Set gravatar type
442
  if ( empty( $bp->grav_default->{$params['object']} ) ) {
443
  $default_grav = 'wavatar';
444
  } elseif ( 'mystery' == $bp->grav_default->{$params['object']} ) {
 
 
 
 
 
 
 
 
 
445
  $default_grav = apply_filters( 'bp_core_mysteryman_src', 'mm', $params['width'] );
446
  } else {
447
  $default_grav = $bp->grav_default->{$params['object']};
456
  }
457
  }
458
 
459
+ // Set host based on if using ssl
460
+ $host = 'http://gravatar.com/avatar/';
461
+ if ( is_ssl() ) {
462
+ $host = 'https://secure.gravatar.com/avatar/';
463
+ }
464
 
465
+ // Filter gravatar vars
 
 
 
 
 
 
 
 
466
  $params['email'] = apply_filters( 'bp_core_gravatar_email', $params['email'], $params['item_id'], $params['object'] );
 
 
 
 
 
 
 
 
467
  $gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $params['email'] ) ) . '?d=' . $default_grav . '&amp;s=' . $params['width'];
468
 
469
  // Gravatar rating; http://bit.ly/89QxZA
474
 
475
  // No avatar was found, and we've been told not to use a gravatar.
476
  } else {
 
 
 
 
 
 
 
 
 
 
 
477
  $gravatar = apply_filters( 'bp_core_default_avatar_' . $params['object'], bp_core_avatar_default( 'local' ), $params );
478
  }
479
 
480
  if ( true === $params['html'] ) {
 
 
481
  return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '"' . $html_css_id . $html_class . $html_width . $html_height . $html_alt . $html_title . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
482
  } else {
 
 
483
  return apply_filters( 'bp_core_fetch_avatar_url', $gravatar, $params );
484
  }
485
  }
518
  elseif ( 'blog' == $object )
519
  $item_id = $current_blog->id;
520
 
 
521
  $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
522
 
523
  if ( !$item_id ) return false;
531
  elseif ( 'blog' == $object )
532
  $avatar_dir = 'blog-avatars';
533
 
 
534
  $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
535
 
536
  if ( !$avatar_dir ) return false;
537
  }
538
 
 
539
  $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
540
 
541
  if ( !file_exists( $avatar_folder_dir ) )
551
 
552
  @rmdir( $avatar_folder_dir );
553
 
 
 
 
 
 
 
 
554
  do_action( 'bp_core_delete_existing_avatar', $args );
555
 
556
  return true;
557
  }
558
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  /**
560
  * Handle avatar uploading.
561
  *
568
  * @see bp_core_check_avatar_upload()
569
  * @see bp_core_check_avatar_type()
570
  *
571
+ * @param array $file The appropriate entry the from $_FILES superglobal.
572
  * @param string $upload_dir_filter A filter to be applied to 'upload_dir'.
 
573
  * @return bool True on success, false on failure.
574
  */
575
  function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
576
 
577
+ /***
578
+ * You may want to hook into this filter if you want to override this function.
579
+ * Make sure you return false.
 
 
 
 
 
 
 
580
  */
581
+ if ( !apply_filters( 'bp_core_pre_avatar_handle_upload', true, $file, $upload_dir_filter ) )
582
  return true;
 
583
 
584
+ require_once( ABSPATH . '/wp-admin/includes/file.php' );
 
 
585
 
586
+ $uploadErrors = array(
587
+ 0 => __( 'The image was uploaded successfully', 'buddypress' ),
588
+ 1 => __( 'The image exceeds the maximum allowed file size of: ', 'buddypress' ) . size_format( bp_core_avatar_original_max_filesize() ),
589
+ 2 => __( 'The image exceeds the maximum allowed file size of: ', 'buddypress' ) . size_format( bp_core_avatar_original_max_filesize() ),
590
+ 3 => __( 'The uploaded file was only partially uploaded.', 'buddypress' ),
591
+ 4 => __( 'The image was not uploaded.', 'buddypress' ),
592
+ 6 => __( 'Missing a temporary folder.', 'buddypress' )
593
+ );
594
 
595
+ if ( ! bp_core_check_avatar_upload( $file ) ) {
596
+ bp_core_add_message( sprintf( __( 'Your upload failed. Please try again. Error was: %s', 'buddypress' ), $uploadErrors[$file['file']['error']] ), 'error' );
 
597
  return false;
598
  }
599
 
600
+ if ( ! bp_core_check_avatar_size( $file ) ) {
601
+ bp_core_add_message( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ), 'error' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602
  return false;
603
  }
604
 
605
+ if ( ! bp_core_check_avatar_type( $file ) ) {
606
+ bp_core_add_message( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ), 'error' );
607
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
  }
609
 
610
+ // Filter the upload location
611
+ add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
 
 
 
 
 
 
612
 
613
+ $bp = buddypress();
 
614
 
615
+ $bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) );
 
616
 
617
+ // Remove the upload_dir filter, so that other upload URLs on the page
618
+ // don't break
619
+ remove_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
 
 
 
620
 
621
+ // Move the file to the correct upload location.
622
+ if ( !empty( $bp->avatar_admin->original['error'] ) ) {
623
+ bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
624
+ return false;
625
  }
626
 
627
+ // Get image size
628
+ $size = @getimagesize( $bp->avatar_admin->original['file'] );
629
+ $error = false;
 
630
 
631
+ // Check image size and shrink if too large
632
+ if ( $size[0] > bp_core_avatar_original_max_width() ) {
633
+ $editor = wp_get_image_editor( $bp->avatar_admin->original['file'] );
634
 
635
+ if ( ! is_wp_error( $editor ) ) {
636
+ $editor->set_quality( 100 );
637
 
638
+ $resized = $editor->resize( bp_core_avatar_original_max_width(), bp_core_avatar_original_max_width(), false );
639
+ if ( ! is_wp_error( $resized ) ) {
640
+ $thumb = $editor->save( $editor->generate_filename() );
641
+ } else {
642
+ $error = $resized;
643
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
 
645
+ // Check for thumbnail creation errors
646
+ if ( false === $error && is_wp_error( $thumb ) ) {
647
+ $error = $thumb;
648
+ }
649
 
650
+ // Thumbnail is good so proceed
651
+ if ( false === $error ) {
652
+ $bp->avatar_admin->resized = $thumb;
653
+ }
654
 
 
 
 
 
655
  } else {
656
+ $error = $editor;
657
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
 
659
+ if ( false !== $error ) {
660
+ bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $error->get_error_message() ), 'error' );
661
+ return false;
 
 
 
 
662
  }
 
 
 
 
 
 
 
 
 
 
663
  }
664
 
665
+ if ( ! isset( $bp->avatar_admin->image ) )
666
+ $bp->avatar_admin->image = new stdClass();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
 
668
+ // We only want to handle one image after resize.
669
+ if ( empty( $bp->avatar_admin->resized ) ) {
670
+ $bp->avatar_admin->image->dir = str_replace( bp_core_avatar_upload_path(), '', $bp->avatar_admin->original['file'] );
671
+ } else {
672
+ $bp->avatar_admin->image->dir = str_replace( bp_core_avatar_upload_path(), '', $bp->avatar_admin->resized['path'] );
673
+ @unlink( $bp->avatar_admin->original['file'] );
 
 
 
 
 
 
674
  }
675
 
676
+ // Check for WP_Error on what should be an image
677
+ if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
678
+ bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
679
+ return false;
 
 
 
680
  }
681
 
682
+ // If the uploaded image is smaller than the "full" dimensions, throw
683
+ // a warning
684
+ $uploaded_image = @getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir );
685
+ $full_width = bp_core_avatar_full_width();
686
+ $full_height = bp_core_avatar_full_height();
687
+ if ( isset( $uploaded_image[0] ) && $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) {
688
+ bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %d x %d pixels.', 'buddypress' ), $full_width, $full_height ), 'error' );
689
  }
690
 
691
+ // Set the url value for the image
692
+ $bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
 
 
 
 
 
693
 
694
+ return true;
 
 
 
695
  }
696
 
697
  /**
738
  'crop_y' => 0
739
  ) );
740
 
741
+ /***
742
+ * You may want to hook into this filter if you want to override this function.
743
+ * Make sure you return false.
 
 
 
 
 
 
744
  */
745
+ if ( !apply_filters( 'bp_core_pre_avatar_handle_crop', true, $r ) )
746
  return true;
747
+
748
+ extract( $r, EXTR_SKIP );
749
+
750
+ if ( empty( $original_file ) )
751
+ return false;
752
+
753
+ if ( 'user' === $object ) {
754
+ $avatar_dir = 'avatars';
755
+ } else {
756
+ $avatar_dir = sanitize_key( $args['object'] ) . '-avatars';
757
  }
758
 
759
+ $original_file = sprintf( '%s/%s/%s/%s', bp_core_avatar_upload_path(), $avatar_dir, $item_id, basename( $original_file ) );
 
 
760
 
761
+ if ( !file_exists( $original_file ) )
 
762
  return false;
763
+
764
+ // Capability check.
765
+ $has_cap = bp_current_user_can( 'bp_moderate' );
766
+ if ( ! $has_cap ) {
767
+ if ( 'user' === $object ) {
768
+ $has_cap = bp_loggedin_user_id() === (int) $args['item_id'];
769
+ } elseif ( 'group' === $object && bp_is_active( 'groups' ) ) {
770
+ if ( bp_is_group_create() ) {
771
+ $has_cap = (bool) groups_is_user_creator( bp_loggedin_user_id(), $args['item_id'] );
772
+ } else {
773
+ $has_cap = (bool) groups_is_user_admin( bp_loggedin_user_id(), $args['item_id'] );
774
+ }
775
+ }
776
  }
777
 
778
+ if ( ! $has_cap ) {
779
+ return false;
780
+ }
781
 
782
+ if ( empty( $item_id ) ) {
783
+ $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', dirname( $original_file ), $item_id, $object, $avatar_dir );
784
+ } else {
785
+ $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
 
 
 
 
 
 
 
 
786
  }
787
 
788
+ if ( !file_exists( $avatar_folder_dir ) )
789
+ return false;
790
+
791
+ require_once( ABSPATH . '/wp-admin/includes/image.php' );
792
+ require_once( ABSPATH . '/wp-admin/includes/file.php' );
793
 
794
+ // Delete the existing avatar files for the object
795
+ $existing_avatar = bp_core_fetch_avatar( array(
796
+ 'object' => $object,
797
+ 'item_id' => $item_id,
798
+ 'html' => false,
799
  ) );
800
 
801
+ if ( ! empty( $existing_avatar ) ) {
802
+ // Check that the new avatar doesn't have the same name as the
803
+ // old one before deleting
804
+ $upload_dir = wp_upload_dir();
805
+ $existing_avatar_path = str_replace( $upload_dir['baseurl'], '', $existing_avatar );
806
+ $new_avatar_path = str_replace( $upload_dir['basedir'], '', $original_file );
807
 
808
+ if ( $existing_avatar_path !== $new_avatar_path ) {
809
+ bp_core_delete_existing_avatar( array( 'object' => $object, 'item_id' => $item_id, 'avatar_path' => $avatar_folder_dir ) );
810
+ }
811
  }
812
 
 
 
813
 
 
 
 
 
 
 
 
 
 
814
 
815
+ // Make sure we at least have a width and height for cropping
816
+ if ( empty( $crop_w ) ) {
817
+ $crop_w = bp_core_avatar_full_width();
818
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
819
 
820
+ if ( empty( $crop_h ) ) {
821
+ $crop_h = bp_core_avatar_full_height();
822
  }
823
 
824
+ // Get the file extension
825
+ $data = @getimagesize( $original_file );
826
+ $ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
827
 
828
+ // Set the full and thumb filenames
829
+ $full_filename = wp_hash( $original_file . time() ) . '-bpfull.' . $ext;
830
+ $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.' . $ext;
831
 
832
+ // Crop the image
833
+ $full_cropped = wp_crop_image( $original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_full_width(), bp_core_avatar_full_height(), false, $avatar_folder_dir . '/' . $full_filename );
834
+ $thumb_cropped = wp_crop_image( $original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_thumb_width(), bp_core_avatar_thumb_height(), false, $avatar_folder_dir . '/' . $thumb_filename );
 
835
 
836
+ // Check for errors
837
+ if ( empty( $full_cropped ) || empty( $thumb_cropped ) || is_wp_error( $full_cropped ) || is_wp_error( $thumb_cropped ) )
838
+ return false;
 
 
 
 
 
 
 
 
839
 
840
+ // Remove the original
841
+ @unlink( $original_file );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
842
 
843
+ return true;
 
 
 
 
 
844
  }
 
845
 
846
  /**
847
  * Replace default WordPress avatars with BP avatars, if available.
936
  return true;
937
  }
938
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
939
  /**
940
  * Does the current avatar upload have an allowed file type?
941
  *
944
  * @param array $file The $_FILES array.
945
  * @return bool True if the file extension is permitted, otherwise false.
946
  */
947
+ function bp_core_check_avatar_type($file) {
948
+ if ( ( !empty( $file['file']['type'] ) && !preg_match('/(jpe?g|gif|png)$/i', $file['file']['type'] ) ) || !preg_match( '/(jpe?g|gif|png)$/i', $file['file']['name'] ) )
949
+ return false;
 
 
 
950
 
951
+ return true;
952
  }
953
 
954
  /**
955
  * Fetch data from the BP root blog's upload directory.
956
  *
957
+ * Handy for multisite instances because all uploads are made on the BP root
958
+ * blog and we need to query the BP root blog for the upload directory data.
959
+ *
960
+ * This function ensures that we only need to use {@link switch_to_blog()}
961
+ * once to get what we need.
962
+ *
963
  * @since BuddyPress (1.8.0)
964
  *
965
+ * @uses wp_upload_dir()
966
+ *
967
  * @param string $type The variable we want to return from the $bp->avatars
968
  * object. Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
969
  * @return string The avatar upload directory path.
1005
 
1006
  // No cache, so query for it
1007
  } else {
1008
+ // We need to switch to the root blog on multisite installs
1009
+ if ( is_multisite() ) {
1010
+ switch_to_blog( bp_get_root_blog_id() );
1011
+ }
1012
 
1013
  // Get upload directory information from current site
1014
+ $upload_dir = wp_upload_dir();
1015
+
1016
+ // Will bail if not switched
1017
+ restore_current_blog();
1018
 
1019
  // Stash upload directory data for later use
1020
  $bp->avatar->upload_dir = $upload_dir;
1046
  /**
1047
  * Get the absolute upload path for the WP installation.
1048
  *
1049
+ * @uses wp_upload_dir To get upload directory info
1050
  *
1051
  * @return string Absolute path to WP upload directory.
1052
  */
1053
  function bp_core_avatar_upload_path() {
 
 
 
 
 
 
 
 
1054
  return apply_filters( 'bp_core_avatar_upload_path', bp_core_get_upload_dir() );
1055
  }
1056
 
1057
  /**
1058
  * Get the raw base URL for root site upload location.
1059
  *
1060
+ * @uses wp_upload_dir To get upload directory info.
1061
  *
1062
  * @return string Full URL to current upload location.
1063
  */
1064
  function bp_core_avatar_url() {
 
 
 
 
 
 
 
 
1065
  return apply_filters( 'bp_core_avatar_url', bp_core_get_upload_dir( 'url' ) );
1066
  }
1067
 
1082
  if ( bp_core_fetch_avatar( array( 'item_id' => $user_id, 'no_grav' => true, 'html' => false ) ) != bp_core_avatar_default( 'local' ) )
1083
  $retval = true;
1084
 
 
 
 
 
 
 
 
 
1085
  return (bool) apply_filters( 'bp_get_user_has_avatar', $retval, $user_id );
1086
  }
1087
 
1100
  $bp = buddypress();
1101
  $dim = isset( $bp->avatar->{$type}->{$h_or_w} ) ? (int) $bp->avatar->{$type}->{$h_or_w} : false;
1102
 
 
 
 
 
 
 
 
 
 
1103
  return apply_filters( 'bp_core_avatar_dimension', $dim, $type, $h_or_w );
1104
  }
1105
 
1111
  * @return int The 'thumb' width.
1112
  */
1113
  function bp_core_avatar_thumb_width() {
 
 
 
 
 
 
 
 
1114
  return apply_filters( 'bp_core_avatar_thumb_width', bp_core_avatar_dimension( 'thumb', 'width' ) );
1115
  }
1116
 
1122
  * @return int The 'thumb' height.
1123
  */
1124
  function bp_core_avatar_thumb_height() {
 
 
 
 
 
 
 
 
1125
  return apply_filters( 'bp_core_avatar_thumb_height', bp_core_avatar_dimension( 'thumb', 'height' ) );
1126
  }
1127
 
1133
  * @return int The 'full' width.
1134
  */
1135
  function bp_core_avatar_full_width() {
 
 
 
 
 
 
 
 
1136
  return apply_filters( 'bp_core_avatar_full_width', bp_core_avatar_dimension( 'full', 'width' ) );
1137
  }
1138
 
1144
  * @return int The 'full' height.
1145
  */
1146
  function bp_core_avatar_full_height() {
 
 
 
 
 
 
 
 
1147
  return apply_filters( 'bp_core_avatar_full_height', bp_core_avatar_dimension( 'full', 'height' ) );
1148
  }
1149
 
1155
  * @return int The max width for original avatar uploads.
1156
  */
1157
  function bp_core_avatar_original_max_width() {
 
 
 
 
 
 
 
 
1158
  return apply_filters( 'bp_core_avatar_original_max_width', (int) buddypress()->avatar->original_max_width );
1159
  }
1160
 
1166
  * @return int The max filesize for original avatar uploads.
1167
  */
1168
  function bp_core_avatar_original_max_filesize() {
 
 
 
 
 
 
 
 
1169
  return apply_filters( 'bp_core_avatar_original_max_filesize', (int) buddypress()->avatar->original_max_filesize );
1170
  }
1171
 
1190
 
1191
  // Use Gravatar's mystery man as fallback
1192
  } else {
1193
+ if ( is_ssl() ) {
1194
+ $host = 'https://secure.gravatar.com';
1195
+ } else {
1196
+ $host = 'http://www.gravatar.com';
1197
+ }
1198
+
1199
+ $avatar = $host . '/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_full_width();
1200
  }
1201
 
 
 
 
 
 
 
 
1202
  return apply_filters( 'bp_core_avatar_default', $avatar );
1203
  }
1204
 
1226
 
1227
  // Use Gravatar's mystery man as fallback
1228
  } else {
1229
+ if ( is_ssl() ) {
1230
+ $host = 'https://secure.gravatar.com';
1231
+ } else {
1232
+ $host = 'http://www.gravatar.com';
1233
+ }
1234
+
1235
+ $avatar = $host . '/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_thumb_width();
1236
  }
1237
 
 
 
 
 
 
 
 
1238
  return apply_filters( 'bp_core_avatar_thumb', $avatar );
1239
  }
1240
 
1280
  }
1281
  }
1282
  add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-buddybar.php CHANGED
@@ -14,6 +14,8 @@ defined( 'ABSPATH' ) || exit;
14
  /**
15
  * Add an item to the main BuddyPress navigation array.
16
  *
 
 
17
  * @param array $args {
18
  * Array describing the new nav item.
19
  * @type string $name Display name for the nav item.
@@ -36,7 +38,7 @@ defined( 'ABSPATH' ) || exit;
36
  * @return bool|null Returns false on failure.
37
  */
38
  function bp_core_new_nav_item( $args = '' ) {
39
- $bp = buddypress();
40
 
41
  $defaults = array(
42
  'name' => false, // Display name for the nav item
@@ -106,36 +108,19 @@ function bp_core_new_nav_item( $args = '' ) {
106
  }
107
 
108
  if ( !empty( $default_subnav_slug ) ) {
109
-
110
- /**
111
- * Filters the default component subnav item.
112
- *
113
- * @since BuddyPress (1.5.0)
114
- *
115
- * @param string $default_subnav_slug The slug of the default subnav item
116
- * to select when clicked.
117
- * @param array $r Parsed arguments for the nav item.
118
- */
119
  $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
120
  }
121
  }
122
  }
123
 
124
- /**
125
- * Fires after adding an item to the main BuddyPress navigation array.
126
- *
127
- * @since BuddyPress (1.5.0)
128
- *
129
- * @param array $r Parsed arguments for the nav item.
130
- * @param array $args Originally passed in arguments for the nav item.
131
- * @param array $defaults Default arguments for a nav item.
132
- */
133
  do_action( 'bp_core_new_nav_item', $r, $args, $defaults );
134
  }
135
 
136
  /**
137
  * Modify the default subnav item that loads when a top level nav item is clicked.
138
  *
 
 
139
  * @param array $args {
140
  * @type string $parent_slug The slug of the nav item whose default is
141
  * being changed.
@@ -145,7 +130,7 @@ function bp_core_new_nav_item( $args = '' ) {
145
  * }
146
  */
147
  function bp_core_new_nav_default( $args = '' ) {
148
- $bp = buddypress();
149
 
150
  $defaults = array(
151
  'parent_slug' => false, // Slug of the parent
@@ -210,10 +195,12 @@ function bp_core_new_nav_default( $args = '' ) {
210
  * The sorting is split into a separate function because it can only happen
211
  * after all plugins have had a chance to register their navigation items.
212
  *
 
 
213
  * @return bool|null Returns false on failure.
214
  */
215
  function bp_core_sort_nav_items() {
216
- $bp = buddypress();
217
 
218
  if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
219
  return false;
@@ -242,6 +229,8 @@ add_action( 'admin_head', 'bp_core_sort_nav_items' );
242
  /**
243
  * Add a subnav item to the BuddyPress navigation.
244
  *
 
 
245
  * @param array $args {
246
  * Array describing the new subnav item.
247
  * @type string $name Display name for the subnav item.
@@ -271,7 +260,7 @@ add_action( 'admin_head', 'bp_core_sort_nav_items' );
271
  * @return bool|null Returns false on failure.
272
  */
273
  function bp_core_new_subnav_item( $args = '' ) {
274
- $bp = buddypress();
275
 
276
  $r = wp_parse_args( $args, array(
277
  'name' => false, // Display name for the nav item
@@ -296,11 +285,11 @@ function bp_core_new_subnav_item( $args = '' ) {
296
 
297
  // Link was not forced, so create one
298
  if ( empty( $link ) ) {
299
- $link = trailingslashit( $parent_url . $slug );
300
 
301
  // If this sub item is the default for its parent, skip the slug
302
  if ( ! empty( $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) && $slug == $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) {
303
- $link = trailingslashit( $parent_url );
304
  }
305
  }
306
 
@@ -313,7 +302,7 @@ function bp_core_new_subnav_item( $args = '' ) {
313
 
314
  $subnav_item = array(
315
  'name' => $name,
316
- 'link' => $link,
317
  'slug' => $slug,
318
  'css_id' => $item_css_id,
319
  'position' => $position,
@@ -452,10 +441,12 @@ function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) {
452
  /**
453
  * Sort all subnavigation arrays.
454
  *
 
 
455
  * @return bool|null Returns false on failure.
456
  */
457
  function bp_core_sort_subnav_items() {
458
- $bp = buddypress();
459
 
460
  if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
461
  return false;
@@ -495,22 +486,13 @@ add_action( 'admin_head', 'bp_core_sort_subnav_items' );
495
  * items; false otherwise.
496
  */
497
  function bp_nav_item_has_subnav( $nav_item = '' ) {
498
- $bp = buddypress();
499
 
500
  if ( !$nav_item )
501
  $nav_item = bp_current_component();
502
 
503
  $has_subnav = isset( $bp->bp_options_nav[$nav_item] ) && count( $bp->bp_options_nav[$nav_item] ) > 0;
504
 
505
- /**
506
- * Filters whether or not a given nav item has subnav items.
507
- *
508
- * @since BuddyPress (1.5.0)
509
- *
510
- * @param bool $has_subnav Whether or not there is any subnav items.
511
- * @param string $nav_item The slug of the top-level nav item whose subnav
512
- * items you're checking.
513
- */
514
  return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item );
515
  }
516
 
@@ -521,7 +503,7 @@ function bp_nav_item_has_subnav( $nav_item = '' ) {
521
  * @param bool Returns false on failure, ie if the nav item can't be found.
522
  */
523
  function bp_core_remove_nav_item( $parent_id ) {
524
- $bp = buddypress();
525
 
526
  // Unset subnav items for this nav item
527
  if ( isset( $bp->bp_options_nav[$parent_id] ) && is_array( $bp->bp_options_nav[$parent_id] ) ) {
@@ -550,11 +532,9 @@ function bp_core_remove_nav_item( $parent_id ) {
550
  * @param string $slug The slug of the subnav item to be removed.
551
  */
552
  function bp_core_remove_subnav_item( $parent_id, $slug ) {
553
- $bp = buddypress();
554
 
555
- $screen_function = isset( $bp->bp_options_nav[$parent_id][$slug]['screen_function'] )
556
- ? $bp->bp_options_nav[$parent_id][$slug]['screen_function']
557
- : false;
558
 
559
  if ( ! empty( $screen_function ) ) {
560
  // Remove our screen hook if screen function is callable
@@ -572,10 +552,12 @@ function bp_core_remove_subnav_item( $parent_id, $slug ) {
572
  /**
573
  * Clear all subnav items from a specific nav item.
574
  *
 
 
575
  * @param string $parent_slug The slug of the parent navigation item.
576
  */
577
  function bp_core_reset_subnav_items( $parent_slug ) {
578
- $bp = buddypress();
579
 
580
  unset( $bp->bp_options_nav[$parent_slug] );
581
  }
14
  /**
15
  * Add an item to the main BuddyPress navigation array.
16
  *
17
+ * @global BuddyPress $bp The one true BuddyPress instance.
18
+ *
19
  * @param array $args {
20
  * Array describing the new nav item.
21
  * @type string $name Display name for the nav item.
38
  * @return bool|null Returns false on failure.
39
  */
40
  function bp_core_new_nav_item( $args = '' ) {
41
+ global $bp;
42
 
43
  $defaults = array(
44
  'name' => false, // Display name for the nav item
108
  }
109
 
110
  if ( !empty( $default_subnav_slug ) ) {
 
 
 
 
 
 
 
 
 
 
111
  $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
112
  }
113
  }
114
  }
115
 
 
 
 
 
 
 
 
 
 
116
  do_action( 'bp_core_new_nav_item', $r, $args, $defaults );
117
  }
118
 
119
  /**
120
  * Modify the default subnav item that loads when a top level nav item is clicked.
121
  *
122
+ * @global BuddyPress $bp The one true BuddyPress instance.
123
+ *
124
  * @param array $args {
125
  * @type string $parent_slug The slug of the nav item whose default is
126
  * being changed.
130
  * }
131
  */
132
  function bp_core_new_nav_default( $args = '' ) {
133
+ global $bp;
134
 
135
  $defaults = array(
136
  'parent_slug' => false, // Slug of the parent
195
  * The sorting is split into a separate function because it can only happen
196
  * after all plugins have had a chance to register their navigation items.
197
  *
198
+ * @global BuddyPress $bp The one true BuddyPress instance
199
+ *
200
  * @return bool|null Returns false on failure.
201
  */
202
  function bp_core_sort_nav_items() {
203
+ global $bp;
204
 
205
  if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
206
  return false;
229
  /**
230
  * Add a subnav item to the BuddyPress navigation.
231
  *
232
+ * @global BuddyPress $bp The one true BuddyPress instance.
233
+ *
234
  * @param array $args {
235
  * Array describing the new subnav item.
236
  * @type string $name Display name for the subnav item.
260
  * @return bool|null Returns false on failure.
261
  */
262
  function bp_core_new_subnav_item( $args = '' ) {
263
+ global $bp;
264
 
265
  $r = wp_parse_args( $args, array(
266
  'name' => false, // Display name for the nav item
285
 
286
  // Link was not forced, so create one
287
  if ( empty( $link ) ) {
288
+ $link = $parent_url . $slug;
289
 
290
  // If this sub item is the default for its parent, skip the slug
291
  if ( ! empty( $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) && $slug == $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) {
292
+ $link = $parent_url;
293
  }
294
  }
295
 
302
 
303
  $subnav_item = array(
304
  'name' => $name,
305
+ 'link' => trailingslashit( $link ),
306
  'slug' => $slug,
307
  'css_id' => $item_css_id,
308
  'position' => $position,
441
  /**
442
  * Sort all subnavigation arrays.
443
  *
444
+ * @global BuddyPress $bp The one true BuddyPress instance
445
+ *
446
  * @return bool|null Returns false on failure.
447
  */
448
  function bp_core_sort_subnav_items() {
449
+ global $bp;
450
 
451
  if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
452
  return false;
486
  * items; false otherwise.
487
  */
488
  function bp_nav_item_has_subnav( $nav_item = '' ) {
489
+ global $bp;
490
 
491
  if ( !$nav_item )
492
  $nav_item = bp_current_component();
493
 
494
  $has_subnav = isset( $bp->bp_options_nav[$nav_item] ) && count( $bp->bp_options_nav[$nav_item] ) > 0;
495
 
 
 
 
 
 
 
 
 
 
496
  return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item );
497
  }
498
 
503
  * @param bool Returns false on failure, ie if the nav item can't be found.
504
  */
505
  function bp_core_remove_nav_item( $parent_id ) {
506
+ global $bp;
507
 
508
  // Unset subnav items for this nav item
509
  if ( isset( $bp->bp_options_nav[$parent_id] ) && is_array( $bp->bp_options_nav[$parent_id] ) ) {
532
  * @param string $slug The slug of the subnav item to be removed.
533
  */
534
  function bp_core_remove_subnav_item( $parent_id, $slug ) {
535
+ global $bp;
536
 
537
+ $screen_function = isset( $bp->bp_options_nav[$parent_id][$slug]['screen_function'] ) ? $bp->bp_options_nav[$parent_id][$slug]['screen_function'] : false;
 
 
538
 
539
  if ( ! empty( $screen_function ) ) {
540
  // Remove our screen hook if screen function is callable
552
  /**
553
  * Clear all subnav items from a specific nav item.
554
  *
555
+ * @global BuddyPress $bp The one true BuddyPress instance.
556
+ *
557
  * @param string $parent_slug The slug of the parent navigation item.
558
  */
559
  function bp_core_reset_subnav_items( $parent_slug ) {
560
+ global $bp;
561
 
562
  unset( $bp->bp_options_nav[$parent_slug] );
563
  }
bp-core/bp-core-cache.php CHANGED
@@ -21,12 +21,6 @@ function bp_core_clear_cache() {
21
  global $cache_path;
22
 
23
  if ( function_exists( 'prune_super_cache' ) ) {
24
-
25
- /**
26
- * Fires before the pruning of WP Super Cache.
27
- *
28
- * @since BuddyPress (1.0.0)
29
- */
30
  do_action( 'bp_core_clear_cache' );
31
  return prune_super_cache( $cache_path, true );
32
  }
21
  global $cache_path;
22
 
23
  if ( function_exists( 'prune_super_cache' ) ) {
 
 
 
 
 
 
24
  do_action( 'bp_core_clear_cache' );
25
  return prune_super_cache( $cache_path, true );
26
  }
bp-core/bp-core-caps.php CHANGED
@@ -30,23 +30,10 @@ function bp_get_current_blog_roles() {
30
  ? $wp_roles->roles
31
  : array();
32
 
33
- /**
34
- * Filters the list of editable roles.
35
- *
36
- * @since BuddyPress (2.1.0)
37
- *
38
- * @param array $roles List of roles.
39
- */
40
  $roles = apply_filters( 'editable_roles', $roles );
41
 
42
- /**
43
- * Filters the array of roles from the currently loaded blog.
44
- *
45
- * @since BuddyPress (2.1.0)
46
- *
47
- * @param array $roles Available roles.
48
- * @param WP_Roles $wp_roles Object of WordPress roles.
49
- */
50
  return apply_filters( 'bp_get_current_blog_roles', $roles, $wp_roles );
51
  }
52
 
@@ -75,13 +62,6 @@ function bp_add_caps() {
75
  }
76
  }
77
 
78
- /**
79
- * Fires after the addition of capabilities to WordPress user roles.
80
- *
81
- * This is called on plugin activation.
82
- *
83
- * @since BuddyPress (1.6.0)
84
- */
85
  do_action( 'bp_add_caps' );
86
  }
87
 
@@ -110,13 +90,6 @@ function bp_remove_caps() {
110
  }
111
  }
112
 
113
- /**
114
- * Fires after the removal of capabilities from WordPress user roles.
115
- *
116
- * This is called on plugin deactivation.
117
- *
118
- * @since BuddyPress (1.6.0)
119
- */
120
  do_action( 'bp_remove_caps' );
121
  }
122
 
@@ -137,17 +110,6 @@ function bp_remove_caps() {
137
  * @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}.
138
  */
139
  function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
140
-
141
- /**
142
- * Filters the community caps mapping to be built in WordPress caps.
143
- *
144
- * @since BuddyPress (1.6.0)
145
- *
146
- * @param array $caps Returns the user's actual capabilities.
147
- * @param string $cap Capability name.
148
- * @param int $user_id The user ID.
149
- * @param array $args Adds the context to the cap. Typically the object ID.
150
- */
151
  return apply_filters( 'bp_map_meta_caps', $caps, $cap, $user_id, $args );
152
  }
153
 
@@ -165,13 +127,6 @@ function bp_get_community_caps() {
165
  // Forum meta caps
166
  $caps = array();
167
 
168
- /**
169
- * Filters community capabilities.
170
- *
171
- * @since BuddyPress (1.6.0)
172
- *
173
- * @param array $caps Array of capabilities to add. Empty by default.
174
- */
175
  return apply_filters( 'bp_get_community_caps', $caps );
176
  }
177
 
@@ -208,14 +163,6 @@ function bp_get_caps_for_role( $role = '' ) {
208
  break;
209
  }
210
 
211
- /**
212
- * Filters the array of capabilities based on the role that is being requested.
213
- *
214
- * @since BuddyPress (1.6.0)
215
- *
216
- * @param array $caps Array of capabilities to return.
217
- * @param string $role The role currently being loaded.
218
- */
219
  return apply_filters( 'bp_get_caps_for_role', $caps, $role );
220
  }
221
 
@@ -273,15 +220,6 @@ function bp_current_user_can( $capability, $blog_id = 0 ) {
273
 
274
  $retval = current_user_can_for_blog( $blog_id, $capability );
275
 
276
- /**
277
- * Filters whether or not the current user has a given capability.
278
- *
279
- * @since BuddyPress (1.6.0)
280
- *
281
- * @param bool $retval Whether or not the current user has the capability.
282
- * @param string $capability The capability being checked for.
283
- * @param int $blog_id Blog ID. Defaults to the BP root blog.
284
- */
285
  return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id );
286
  }
287
 
30
  ? $wp_roles->roles
31
  : array();
32
 
33
+ // Apply WordPress core filter to editable roles
 
 
 
 
 
 
34
  $roles = apply_filters( 'editable_roles', $roles );
35
 
36
+ // Return the editable roles
 
 
 
 
 
 
 
37
  return apply_filters( 'bp_get_current_blog_roles', $roles, $wp_roles );
38
  }
39
 
62
  }
63
  }
64
 
 
 
 
 
 
 
 
65
  do_action( 'bp_add_caps' );
66
  }
67
 
90
  }
91
  }
92
 
 
 
 
 
 
 
 
93
  do_action( 'bp_remove_caps' );
94
  }
95
 
110
  * @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}.
111
  */
112
  function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
 
 
 
 
 
 
 
 
 
 
 
113
  return apply_filters( 'bp_map_meta_caps', $caps, $cap, $user_id, $args );
114
  }
115
 
127
  // Forum meta caps
128
  $caps = array();
129
 
 
 
 
 
 
 
 
130
  return apply_filters( 'bp_get_community_caps', $caps );
131
  }
132
 
163
  break;
164
  }
165
 
 
 
 
 
 
 
 
 
166
  return apply_filters( 'bp_get_caps_for_role', $caps, $role );
167
  }
168
 
220
 
221
  $retval = current_user_can_for_blog( $blog_id, $capability );
222
 
 
 
 
 
 
 
 
 
 
223
  return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id );
224
  }
225
 
bp-core/bp-core-catchuri.php CHANGED
@@ -33,14 +33,12 @@ defined( 'ABSPATH' ) || exit;
33
  * @since BuddyPress (1.0.0)
34
  */
35
  function bp_core_set_uri_globals() {
36
- global $current_blog, $wp_rewrite;
37
 
38
  // Don't catch URIs on non-root blogs unless multiblog mode is on
39
  if ( !bp_is_root_blog() && !bp_is_multiblog_mode() )
40
  return false;
41
 
42
- $bp = buddypress();
43
-
44
  // Define local variables
45
  $root_profile = $match = false;
46
  $key_slugs = $matches = $uri_chunks = array();
@@ -51,17 +49,11 @@ function bp_core_set_uri_globals() {
51
 
52
  // Ajax or not?
53
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX || strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) )
54
- $path = bp_get_referer_path();
55
  else
56
  $path = esc_url( $_SERVER['REQUEST_URI'] );
57
 
58
- /**
59
- * Filters the BuddyPress global URI path.
60
- *
61
- * @since BuddyPress (1.0.0)
62
- *
63
- * @param string $path Path to set.
64
- */
65
  $path = apply_filters( 'bp_uri', $path );
66
 
67
  // Take GET variables off the URL to avoid problems
@@ -258,54 +250,37 @@ function bp_core_set_uri_globals() {
258
  // If members component, do more work to find the actual component
259
  if ( 'members' == $match->key ) {
260
 
261
- $after_member_slug = false;
262
- if ( ! empty( $bp_uri[ $uri_offset + 1 ] ) ) {
263
- $after_member_slug = $bp_uri[ $uri_offset + 1 ];
264
- }
265
 
266
- // Are we viewing a specific user?
267
- if ( $after_member_slug ) {
268
  // Switch the displayed_user based on compatibility mode
269
  if ( bp_is_username_compatibility_mode() ) {
270
- $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $after_member_slug ) );
271
  } else {
272
- $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( $after_member_slug );
273
  }
274
- }
275
 
276
- // Is this a member type directory?
277
- if ( ! bp_displayed_user_id() && $after_member_slug === apply_filters( 'bp_members_member_type_base', _x( 'type', 'member type URL base', 'buddypress' ) ) && ! empty( $bp_uri[ $uri_offset + 2 ] ) ) {
278
- $matched_types = bp_get_member_types( array(
279
- 'has_directory' => true,
280
- 'directory_slug' => $bp_uri[ $uri_offset + 2 ],
281
- ) );
282
 
283
- if ( ! empty( $matched_types ) ) {
284
- $bp->current_member_type = reset( $matched_types );
285
- unset( $bp_uri[ $uri_offset + 1 ] );
286
- }
287
- }
288
-
289
- // If the slug matches neither a member type nor a specific member, 404.
290
- if ( ! bp_displayed_user_id() && ! bp_get_current_member_type() && $after_member_slug ) {
291
- // Prevent components from loading their templates.
292
- $bp->current_component = '';
293
- bp_do_404();
294
- return;
295
- }
296
 
297
- // If the displayed user is marked as a spammer, 404 (unless logged-in user is a super admin)
298
- if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) {
299
- if ( bp_current_user_can( 'bp_moderate' ) ) {
300
- bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'warning' );
301
- } else {
302
  bp_do_404();
303
  return;
304
  }
305
- }
306
 
307
- // Bump the offset.
308
- if ( bp_displayed_user_id() ) {
 
 
 
 
 
 
 
 
 
 
309
  if ( isset( $bp_uri[$uri_offset + 2] ) ) {
310
  $bp_uri = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
311
  $bp->current_component = $bp_uri[0];
@@ -350,13 +325,6 @@ function bp_core_enable_root_profiles() {
350
  if ( defined( 'BP_ENABLE_ROOT_PROFILES' ) && ( true == BP_ENABLE_ROOT_PROFILES ) )
351
  $retval = true;
352
 
353
- /**
354
- * Filters whether or not root profiles are enabled and allowed.
355
- *
356
- * @since BuddyPress (1.6.0)
357
- *
358
- * @param bool $retval Whether or not root profiles are available.
359
- */
360
  return apply_filters( 'bp_core_enable_root_profiles', $retval );
361
  }
362
 
@@ -400,16 +368,7 @@ function bp_core_load_template( $templates ) {
400
  $template = '';
401
  }
402
 
403
- /**
404
- * Filters the template locations.
405
- *
406
- * Allows plugins to alter where the template files are located.
407
- *
408
- * @since BuddyPress (1.1.0)
409
- *
410
- * @param string $template Located template path.
411
- * @param array $filtered_templates Array of templates to attempt to load.
412
- */
413
  $located_template = apply_filters( 'bp_located_template', $template, $filtered_templates );
414
  if ( !empty( $located_template ) ) {
415
  // Template was located, lets set this as a valid page and not a 404.
@@ -418,31 +377,10 @@ function bp_core_load_template( $templates ) {
418
  $wp_query->is_singular = true;
419
  $wp_query->is_404 = false;
420
 
421
- /**
422
- * Fires before the loading of a located template file.
423
- *
424
- * @since BuddyPress (1.6.0)
425
- *
426
- * @param string $located_template Template found to be loaded.
427
- */
428
  do_action( 'bp_core_pre_load_template', $located_template );
429
 
430
- /**
431
- * Filters the selected template right before loading.
432
- *
433
- * @since BuddyPress (1.1.0)
434
- *
435
- * @param string $located_template Template found to be loaded.
436
- */
437
  load_template( apply_filters( 'bp_load_template', $located_template ) );
438
 
439
- /**
440
- * Fires after the loading of a located template file.
441
- *
442
- * @since BuddyPress (1.6.0)
443
- *
444
- * @param string $located_template Template found that was loaded.
445
- */
446
  do_action( 'bp_core_post_load_template', $located_template );
447
 
448
  // Kill any other output after this.
@@ -461,11 +399,6 @@ function bp_core_load_template( $templates ) {
461
  $wp_query->is_404 = false;
462
  }
463
 
464
- /**
465
- * Fires if there are no found templates to load and theme compat is needed.
466
- *
467
- * @since BuddyPress (1.7.0)
468
- */
469
  do_action( 'bp_setup_theme_compat' );
470
  }
471
  }
@@ -475,14 +408,6 @@ function bp_core_load_template( $templates ) {
475
  */
476
  function bp_core_catch_profile_uri() {
477
  if ( !bp_is_active( 'xprofile' ) ) {
478
-
479
- /**
480
- * Filters the path to redirect users to if XProfile is not enabled.
481
- *
482
- * @since BuddyPress (1.0.0)
483
- *
484
- * @param string $value Path to redirect users to.
485
- */
486
  bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'members/single/home' ) );
487
  }
488
  }
@@ -493,9 +418,7 @@ function bp_core_catch_profile_uri() {
493
  * @since BuddyPress (1.5.0)
494
  */
495
  function bp_core_catch_no_access() {
496
- global $wp_query;
497
-
498
- $bp = buddypress();
499
 
500
  // If coming from bp_core_redirect() and $bp_no_status_set is true,
501
  // we are redirecting to an accessible page so skip this check.
@@ -545,14 +468,6 @@ function bp_core_no_access( $args = '' ) {
545
  );
546
 
547
  $r = wp_parse_args( $args, $defaults );
548
-
549
- /**
550
- * Filters the arguments used for user redirecting when visiting access controlled areas.
551
- *
552
- * @since BuddyPress (1.6.0)
553
- *
554
- * @param array $r Array of parsed arguments for redirect determination.
555
- */
556
  $r = apply_filters( 'bp_core_no_access', $r );
557
  extract( $r, EXTR_SKIP );
558
 
@@ -610,14 +525,6 @@ function bp_core_no_access( $args = '' ) {
610
  function bp_core_no_access_wp_login_error() {
611
  global $error;
612
 
613
- /**
614
- * Filters the error message for wp-login.php when needing to log in before accessing.
615
- *
616
- * @since BuddyPress (1.5.0)
617
- *
618
- * @param string $value Error message to display.
619
- * @param string $value URL to redirect user to after successful login.
620
- */
621
  $error = apply_filters( 'bp_wp_login_error', __( 'You must log in to access the page you requested.', 'buddypress' ), $_REQUEST['redirect_to'] );
622
 
623
  // shake shake shake!
@@ -643,14 +550,8 @@ add_action( 'login_form_bpnoaccess', 'bp_core_no_access_wp_login_error' );
643
  * @uses bp_get_requested_url()
644
  */
645
  function bp_redirect_canonical() {
 
646
 
647
- /**
648
- * Filters whether or not to do canonical redirects on BuddyPress URLs.
649
- *
650
- * @since BuddyPress (1.6.0)
651
- *
652
- * @param bool $value Whether or not to do canonical redirects. Default true.
653
- */
654
  if ( !bp_is_blog_page() && apply_filters( 'bp_do_redirect_canonical', true ) ) {
655
  // If this is a POST request, don't do a canonical redirect.
656
  // This is for backward compatibility with plugins that submit form requests to
@@ -673,8 +574,6 @@ function bp_redirect_canonical() {
673
  // Only redirect if we've assembled a URL different from the request
674
  if ( $canonical_url !== $req_url_clean ) {
675
 
676
- $bp = buddypress();
677
-
678
  // Template messages have been deleted from the cookie by this point, so
679
  // they must be readded before redirecting
680
  if ( isset( $bp->template_message ) ) {
@@ -720,14 +619,13 @@ function bp_rel_canonical() {
720
  * @return string Canonical URL for the current page.
721
  */
722
  function bp_get_canonical_url( $args = array() ) {
 
723
 
724
  // For non-BP content, return the requested url, and let WP do the work
725
  if ( bp_is_blog_page() ) {
726
  return bp_get_requested_url();
727
  }
728
 
729
- $bp = buddypress();
730
-
731
  $defaults = array(
732
  'include_query_args' => false // Include URL arguments, eg ?foo=bar&foo2=bar2
733
  );
@@ -751,15 +649,7 @@ function bp_get_canonical_url( $args = array() ) {
751
  // and the current user is logged in. In this case we send to
752
  // the members directory to avoid redirect loops
753
  } elseif ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
754
-
755
- /**
756
- * Filters the logged in register page redirect URL.
757
- *
758
- * @since BuddyPress (1.5.1)
759
- *
760
- * @param string $value URL to redirect logged in members to.
761
- */
762
- $bp->canonical_stack['canonical_url'] = apply_filters( 'bp_loggedin_register_page_redirect_to', bp_get_members_directory_permalink() );
763
  }
764
  }
765
 
@@ -800,14 +690,6 @@ function bp_get_canonical_url( $args = array() ) {
800
  $canonical_url = array_pop( $canonical_url );
801
  }
802
 
803
- /**
804
- * Filters the canonical url of the current page.
805
- *
806
- * @since BuddyPress (1.6.0)
807
- *
808
- * @param string $canonical_url Canonical URL of the current page.
809
- * @param array $args Array of arguments to help determine canonical URL.
810
- */
811
  return apply_filters( 'bp_get_canonical_url', $canonical_url, $args );
812
  }
813
 
@@ -819,20 +701,13 @@ function bp_get_canonical_url( $args = array() ) {
819
  * @return string Requested URL string.
820
  */
821
  function bp_get_requested_url() {
822
- $bp = buddypress();
823
 
824
  if ( empty( $bp->canonical_stack['requested_url'] ) ) {
825
  $bp->canonical_stack['requested_url'] = is_ssl() ? 'https://' : 'http://';
826
  $bp->canonical_stack['requested_url'] .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
827
  }
828
 
829
- /**
830
- * Filters the URL as requested on the current page load by the user agent.
831
- *
832
- * @since BuddyPress (1.7.0)
833
- *
834
- * @param string $value Requested URL string.
835
- */
836
  return apply_filters( 'bp_get_requested_url', $bp->canonical_stack['requested_url'] );
837
  }
838
 
@@ -879,8 +754,8 @@ add_action( 'bp_init', '_bp_maybe_remove_redirect_canonical' );
879
  *
880
  * @since BuddyPress (1.6.1)
881
  *
882
- * @link https://buddypress.trac.wordpress.org/ticket/4329
883
- * @link https://buddypress.trac.wordpress.org/ticket/4415
884
  */
885
  function _bp_rehook_maybe_redirect_404() {
886
  if ( defined( 'NOBLOGREDIRECT' ) ) {
33
  * @since BuddyPress (1.0.0)
34
  */
35
  function bp_core_set_uri_globals() {
36
+ global $bp, $current_blog, $wp_rewrite;
37
 
38
  // Don't catch URIs on non-root blogs unless multiblog mode is on
39
  if ( !bp_is_root_blog() && !bp_is_multiblog_mode() )
40
  return false;
41
 
 
 
42
  // Define local variables
43
  $root_profile = $match = false;
44
  $key_slugs = $matches = $uri_chunks = array();
49
 
50
  // Ajax or not?
51
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX || strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) )
52
+ $path = bp_core_referrer();
53
  else
54
  $path = esc_url( $_SERVER['REQUEST_URI'] );
55
 
56
+ // Filter the path
 
 
 
 
 
 
57
  $path = apply_filters( 'bp_uri', $path );
58
 
59
  // Take GET variables off the URL to avoid problems
250
  // If members component, do more work to find the actual component
251
  if ( 'members' == $match->key ) {
252
 
253
+ // Viewing a specific user
254
+ if ( !empty( $bp_uri[$uri_offset + 1] ) ) {
 
 
255
 
 
 
256
  // Switch the displayed_user based on compatibility mode
257
  if ( bp_is_username_compatibility_mode() ) {
258
+ $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $bp_uri[$uri_offset + 1] ) );
259
  } else {
260
+ $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( urldecode( $bp_uri[$uri_offset + 1] ) );
261
  }
 
262
 
263
+ if ( !bp_displayed_user_id() ) {
 
 
 
 
 
264
 
265
+ // Prevent components from loading their templates
266
+ $bp->current_component = '';
 
 
 
 
 
 
 
 
 
 
 
267
 
 
 
 
 
 
268
  bp_do_404();
269
  return;
270
  }
 
271
 
272
+ // If the displayed user is marked as a spammer, 404 (unless logged-
273
+ // in user is a super admin)
274
+ if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) {
275
+ if ( bp_current_user_can( 'bp_moderate' ) ) {
276
+ bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'warning' );
277
+ } else {
278
+ bp_do_404();
279
+ return;
280
+ }
281
+ }
282
+
283
+ // Bump the offset
284
  if ( isset( $bp_uri[$uri_offset + 2] ) ) {
285
  $bp_uri = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
286
  $bp->current_component = $bp_uri[0];
325
  if ( defined( 'BP_ENABLE_ROOT_PROFILES' ) && ( true == BP_ENABLE_ROOT_PROFILES ) )
326
  $retval = true;
327
 
 
 
 
 
 
 
 
328
  return apply_filters( 'bp_core_enable_root_profiles', $retval );
329
  }
330
 
368
  $template = '';
369
  }
370
 
371
+ // Filter the template locations so that plugins can alter where they are located
 
 
 
 
 
 
 
 
 
372
  $located_template = apply_filters( 'bp_located_template', $template, $filtered_templates );
373
  if ( !empty( $located_template ) ) {
374
  // Template was located, lets set this as a valid page and not a 404.
377
  $wp_query->is_singular = true;
378
  $wp_query->is_404 = false;
379
 
 
 
 
 
 
 
 
380
  do_action( 'bp_core_pre_load_template', $located_template );
381
 
 
 
 
 
 
 
 
382
  load_template( apply_filters( 'bp_load_template', $located_template ) );
383
 
 
 
 
 
 
 
 
384
  do_action( 'bp_core_post_load_template', $located_template );
385
 
386
  // Kill any other output after this.
399
  $wp_query->is_404 = false;
400
  }
401
 
 
 
 
 
 
402
  do_action( 'bp_setup_theme_compat' );
403
  }
404
  }
408
  */
409
  function bp_core_catch_profile_uri() {
410
  if ( !bp_is_active( 'xprofile' ) ) {
 
 
 
 
 
 
 
 
411
  bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'members/single/home' ) );
412
  }
413
  }
418
  * @since BuddyPress (1.5.0)
419
  */
420
  function bp_core_catch_no_access() {
421
+ global $bp, $wp_query;
 
 
422
 
423
  // If coming from bp_core_redirect() and $bp_no_status_set is true,
424
  // we are redirecting to an accessible page so skip this check.
468
  );
469
 
470
  $r = wp_parse_args( $args, $defaults );
 
 
 
 
 
 
 
 
471
  $r = apply_filters( 'bp_core_no_access', $r );
472
  extract( $r, EXTR_SKIP );
473
 
525
  function bp_core_no_access_wp_login_error() {
526
  global $error;
527
 
 
 
 
 
 
 
 
 
528
  $error = apply_filters( 'bp_wp_login_error', __( 'You must log in to access the page you requested.', 'buddypress' ), $_REQUEST['redirect_to'] );
529
 
530
  // shake shake shake!
550
  * @uses bp_get_requested_url()
551
  */
552
  function bp_redirect_canonical() {
553
+ global $bp;
554
 
 
 
 
 
 
 
 
555
  if ( !bp_is_blog_page() && apply_filters( 'bp_do_redirect_canonical', true ) ) {
556
  // If this is a POST request, don't do a canonical redirect.
557
  // This is for backward compatibility with plugins that submit form requests to
574
  // Only redirect if we've assembled a URL different from the request
575
  if ( $canonical_url !== $req_url_clean ) {
576
 
 
 
577
  // Template messages have been deleted from the cookie by this point, so
578
  // they must be readded before redirecting
579
  if ( isset( $bp->template_message ) ) {
619
  * @return string Canonical URL for the current page.
620
  */
621
  function bp_get_canonical_url( $args = array() ) {
622
+ global $bp;
623
 
624
  // For non-BP content, return the requested url, and let WP do the work
625
  if ( bp_is_blog_page() ) {
626
  return bp_get_requested_url();
627
  }
628
 
 
 
629
  $defaults = array(
630
  'include_query_args' => false // Include URL arguments, eg ?foo=bar&foo2=bar2
631
  );
649
  // and the current user is logged in. In this case we send to
650
  // the members directory to avoid redirect loops
651
  } elseif ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
652
+ $bp->canonical_stack['canonical_url'] = apply_filters( 'bp_loggedin_register_page_redirect_to', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
 
 
 
 
 
 
 
 
653
  }
654
  }
655
 
690
  $canonical_url = array_pop( $canonical_url );
691
  }
692
 
 
 
 
 
 
 
 
 
693
  return apply_filters( 'bp_get_canonical_url', $canonical_url, $args );
694
  }
695
 
701
  * @return string Requested URL string.
702
  */
703
  function bp_get_requested_url() {
704
+ global $bp;
705
 
706
  if ( empty( $bp->canonical_stack['requested_url'] ) ) {
707
  $bp->canonical_stack['requested_url'] = is_ssl() ? 'https://' : 'http://';
708
  $bp->canonical_stack['requested_url'] .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
709
  }
710
 
 
 
 
 
 
 
 
711
  return apply_filters( 'bp_get_requested_url', $bp->canonical_stack['requested_url'] );
712
  }
713
 
754
  *
755
  * @since BuddyPress (1.6.1)
756
  *
757
+ * @link http://buddypress.trac.wordpress.org/ticket/4329
758
+ * @link http://buddypress.trac.wordpress.org/ticket/4415
759
  */
760
  function _bp_rehook_maybe_redirect_404() {
761
  if ( defined( 'NOBLOGREDIRECT' ) ) {
bp-core/bp-core-classes.php CHANGED
@@ -9,17 +9,2968 @@
9
  // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
- require dirname( __FILE__ ) . '/classes/class-bp-user-query.php';
13
- require dirname( __FILE__ ) . '/classes/class-bp-core-user.php';
14
- require dirname( __FILE__ ) . '/classes/class-bp-date-query.php';
15
- require dirname( __FILE__ ) . '/classes/class-bp-core-notification.php';
16
- require dirname( __FILE__ ) . '/classes/class-bp-button.php';
17
- require dirname( __FILE__ ) . '/classes/class-bp-embed.php';
18
- require dirname( __FILE__ ) . '/classes/class-bp-walker-nav-menu.php';
19
- require dirname( __FILE__ ) . '/classes/class-bp-walker-nav-menu-checklist.php';
20
- require dirname( __FILE__ ) . '/classes/class-bp-suggestions.php';
21
- require dirname( __FILE__ ) . '/classes/class-bp-members-suggestions.php';
22
- require dirname( __FILE__ ) . '/classes/class-bp-recursive-query.php';
23
- require dirname( __FILE__ ) . '/classes/class-bp-media-extractor.php';
24
- require dirname( __FILE__ ) . '/classes/class-bp-attachment.php';
25
- require dirname( __FILE__ ) . '/classes/class-bp-attachment-avatar.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
+ /**
13
+ * BuddyPress User Query class.
14
+ *
15
+ * Used for querying users in a BuddyPress context, in situations where WP_User_Query won't do the trick:
16
+ * Member directories, the Friends component, etc.
17
+ *
18
+ * @since BuddyPress (1.7.0)
19
+ *
20
+ * @param array $query {
21
+ * Query arguments. All items are optional.
22
+ * @type string $type Determines sort order. Select from 'newest', 'active', 'online',
23
+ * 'random', 'popular', 'alphabetical'. Default: 'newest'.
24
+ * @type int $per_page Number of results to return. Default: 0 (no limit).
25
+ * @type int $page Page offset (together with $per_page). Default: 1.
26
+ * @type int $user_id ID of a user. If present, and if the friends component is activated,
27
+ * results will be limited to the friends of that user. Default: 0.
28
+ * @type string|bool $search_terms Terms to search by. Search happens across xprofile fields. Requires
29
+ * XProfile component. Default: false.
30
+ * @type string $search_wildcard When searching with $search_terms, set where wildcards around the term
31
+ * should be positioned. Accepts 'both', 'left', 'right'. Default: 'both'.
32
+ * @type array|string|bool $include An array or comma-separated list of user IDs to which query should
33
+ * be limited. Default: false.
34
+ * @type array|string|bool $exclude An array or comma-separated list of user IDs that will be excluded from
35
+ * query results. Default: false.
36
+ * @type array|string|bool $user_ids An array or comma-separated list of IDs corresponding to the users
37
+ * that should be returned. When this parameter is passed, it will
38
+ * override all others; BP User objects will be constructed using these
39
+ * IDs only. Default: false.
40
+ * @type array|string $member_type Array or comma-separated list of member types to limit results to.
41
+ * @type string|bool $meta_key Limit results to users that have usermeta associated with this meta_key.
42
+ * Usually used with $meta_value. Default: false.
43
+ * @type string|bool $meta_value When used with $meta_key, limits results to users whose usermeta value
44
+ * associated with $meta_key matches $meta_value. Default: false.
45
+ * @type array $xprofile_query Filter results by xprofile data. Requires the xprofile component. See
46
+ * {@see BP_XProfile_Query} for details.
47
+ * @type bool $populate_extras True if you want to fetch extra metadata
48
+ * about returned users, such as total group and friend counts.
49
+ * @type string $count_total Determines how BP_User_Query will do a count of total users matching
50
+ * the other filter criteria. Default value is 'count_query', which does
51
+ * a separate SELECT COUNT query to determine the total.
52
+ * 'sql_count_found_rows' uses SQL_COUNT_FOUND_ROWS and
53
+ * SELECT FOUND_ROWS(). Pass an empty string to skip the total user
54
+ * count query.
55
+ * }
56
+ */
57
+ class BP_User_Query {
58
+
59
+ /** Variables *************************************************************/
60
+
61
+ /**
62
+ * Unaltered params as passed to the constructor.
63
+ *
64
+ * @since BuddyPress (1.8.0)
65
+ * @var array
66
+ */
67
+ public $query_vars_raw = array();
68
+
69
+ /**
70
+ * Array of variables to query with.
71
+ *
72
+ * @since BuddyPress (1.7.0)
73
+ * @var array
74
+ */
75
+ public $query_vars = array();
76
+
77
+ /**
78
+ * List of found users and their respective data.
79
+ *
80
+ * @access public To allow components to manipulate them.
81
+ * @since BuddyPress (1.7.0)
82
+ * @var array
83
+ */
84
+ public $results = array();
85
+
86
+ /**
87
+ * Total number of found users for the current query.
88
+ *
89
+ * @access public To allow components to manipulate it.
90
+ * @since BuddyPress (1.7.0)
91
+ * @var int
92
+ */
93
+ public $total_users = 0;
94
+
95
+ /**
96
+ * List of found user IDs.
97
+ *
98
+ * @access public To allow components to manipulate it.
99
+ * @since BuddyPress (1.7.0)
100
+ * @var array
101
+ */
102
+ public $user_ids = array();
103
+
104
+ /**
105
+ * SQL clauses for the user ID query.
106
+ *
107
+ * @access public To allow components to manipulate it.
108
+ * @since BuddyPress (1.7.0)
109
+ * @var array
110
+ */
111
+ public $uid_clauses = array();
112
+
113
+ /**
114
+ * SQL table where the user ID is being fetched from.
115
+ *
116
+ * @since BuddyPress (2.2.0)
117
+ * @access public
118
+ * @var string
119
+ */
120
+ public $uid_table = '';
121
+
122
+ /**
123
+ * SQL database column name to order by.
124
+ *
125
+ * @since BuddyPress (1.7.0)
126
+ * @var string
127
+ */
128
+ public $uid_name = '';
129
+
130
+ /**
131
+ * Standard response when the query should not return any rows.
132
+ *
133
+ * @access protected
134
+ * @since BuddyPress (1.7.0)
135
+ * @var string
136
+ */
137
+ protected $no_results = array( 'join' => '', 'where' => '0 = 1' );
138
+
139
+
140
+ /** Methods ***************************************************************/
141
+
142
+ /**
143
+ * Constructor.
144
+ *
145
+ * @since BuddyPress (1.7.0)
146
+ *
147
+ * @param string|array $query See {@link BP_User_Query}.
148
+ */
149
+ public function __construct( $query = null ) {
150
+
151
+ // Store the raw query vars for later access
152
+ $this->query_vars_raw = $query;
153
+
154
+ // Allow extending classes to register action/filter hooks
155
+ $this->setup_hooks();
156
+
157
+ if ( ! empty( $this->query_vars_raw ) ) {
158
+ $this->query_vars = wp_parse_args( $this->query_vars_raw, array(
159
+ 'type' => 'newest',
160
+ 'per_page' => 0,
161
+ 'page' => 1,
162
+ 'user_id' => 0,
163
+ 'search_terms' => false,
164
+ 'search_wildcard' => 'both',
165
+ 'include' => false,
166
+ 'exclude' => false,
167
+ 'user_ids' => false,
168
+ 'member_type' => '',
169
+ 'meta_key' => false,
170
+ 'meta_value' => false,
171
+ 'xprofile_query' => false,
172
+ 'populate_extras' => true,
173
+ 'count_total' => 'count_query'
174
+ ) );
175
+
176
+ // Plugins can use this filter to modify query args
177
+ // before the query is constructed
178
+ do_action_ref_array( 'bp_pre_user_query_construct', array( &$this ) );
179
+
180
+ // Get user ids
181
+ // If the user_ids param is present, we skip the query
182
+ if ( false !== $this->query_vars['user_ids'] ) {
183
+ $this->user_ids = wp_parse_id_list( $this->query_vars['user_ids'] );
184
+ } else {
185
+ $this->prepare_user_ids_query();
186
+ $this->do_user_ids_query();
187
+ }
188
+ }
189
+
190
+ // Bail if no user IDs were found
191
+ if ( empty( $this->user_ids ) ) {
192
+ return;
193
+ }
194
+
195
+ // Fetch additional data. First, using WP_User_Query
196
+ $this->do_wp_user_query();
197
+
198
+ // Get BuddyPress specific user data
199
+ $this->populate_extras();
200
+ }
201
+
202
+ /**
203
+ * Allow extending classes to set up action/filter hooks.
204
+ *
205
+ * When extending BP_User_Query, you may need to use some of its
206
+ * internal hooks to modify the output. It's not convenient to call
207
+ * add_action() or add_filter() in your class constructor, because
208
+ * BP_User_Query::__construct() contains a fair amount of logic that
209
+ * you may not want to override in your class. Define this method in
210
+ * your own class if you need a place where your extending class can
211
+ * add its hooks early in the query-building process. See
212
+ * {@link BP_Group_Member_Query::setup_hooks()} for an example.
213
+ *
214
+ * @since BuddyPress (1.8.0)
215
+ */
216
+ public function setup_hooks() {}
217
+
218
+ /**
219
+ * Prepare the query for user_ids.
220
+ *
221
+ * @since BuddyPress (1.7.0)
222
+ */
223
+ public function prepare_user_ids_query() {
224
+ global $wpdb, $bp;
225
+
226
+ // Default query variables used here
227
+ $type = '';
228
+ $per_page = 0;
229
+ $page = 1;
230
+ $user_id = 0;
231
+ $include = false;
232
+ $search_terms = false;
233
+ $exclude = false;
234
+ $meta_key = false;
235
+ $meta_value = false;
236
+
237
+ extract( $this->query_vars );
238
+
239
+ // Setup the main SQL query container
240
+ $sql = array(
241
+ 'select' => '',
242
+ 'where' => array(),
243
+ 'orderby' => '',
244
+ 'order' => '',
245
+ 'limit' => ''
246
+ );
247
+
248
+ /** TYPE **************************************************************/
249
+
250
+ // Determines the sort order, which means it also determines where the
251
+ // user IDs are drawn from (the SELECT and WHERE statements)
252
+ switch ( $type ) {
253
+
254
+ // 'online' query happens against the last_activity usermeta key
255
+ // Filter 'bp_user_query_online_interval' to modify the
256
+ // number of minutes used as an interval
257
+ case 'online' :
258
+ $this->uid_name = 'user_id';
259
+ $this->uid_table = $bp->members->table_name_last_activity;
260
+ $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
261
+ $sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id );
262
+ $sql['where'][] = $wpdb->prepare( "u.date_recorded >= DATE_SUB( UTC_TIMESTAMP(), INTERVAL %d MINUTE )", apply_filters( 'bp_user_query_online_interval', 15 ) );
263
+ $sql['orderby'] = "ORDER BY u.date_recorded";
264
+ $sql['order'] = "DESC";
265
+
266
+ break;
267
+
268
+ // 'active', 'newest', and 'random' queries
269
+ // all happen against the last_activity usermeta key
270
+ case 'active' :
271
+ case 'newest' :
272
+ case 'random' :
273
+ $this->uid_name = 'user_id';
274
+ $this->uid_table = $bp->members->table_name_last_activity;
275
+ $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
276
+ $sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id );
277
+
278
+ if ( 'newest' == $type ) {
279
+ $sql['orderby'] = "ORDER BY u.user_id";
280
+ $sql['order'] = "DESC";
281
+ } elseif ( 'random' == $type ) {
282
+ $sql['orderby'] = "ORDER BY rand()";
283
+ } else {
284
+ $sql['orderby'] = "ORDER BY u.date_recorded";
285
+ $sql['order'] = "DESC";
286
+ }
287
+
288
+ break;
289
+
290
+ // 'popular' sorts by the 'total_friend_count' usermeta
291
+ case 'popular' :
292
+ $this->uid_name = 'user_id';
293
+ $this->uid_table = $wpdb->usermeta;
294
+ $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
295
+ $sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );
296
+ $sql['orderby'] = "ORDER BY CONVERT(u.meta_value, SIGNED)";
297
+ $sql['order'] = "DESC";
298
+
299
+ break;
300
+
301
+ // 'alphabetical' sorts depend on the xprofile setup
302
+ case 'alphabetical' :
303
+
304
+ // We prefer to do alphabetical sorts against the display_name field
305
+ // of wp_users, because the table is smaller and better indexed. We
306
+ // can do so if xprofile sync is enabled, or if xprofile is inactive.
307
+ //
308
+ // @todo remove need for bp_is_active() check
309
+ if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) {
310
+ $this->uid_name = 'ID';
311
+ $this->uid_table = $wpdb->users;
312
+ $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
313
+ $sql['orderby'] = "ORDER BY u.display_name";
314
+ $sql['order'] = "ASC";
315
+
316
+ // When profile sync is disabled, alphabetical sorts must happen against
317
+ // the xprofile table
318
+ } else {
319
+ $this->uid_name = 'user_id';
320
+ $this->uid_table = $bp->profile->table_name_data;
321
+ $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
322
+ $sql['where'][] = $wpdb->prepare( "u.field_id = %d", bp_xprofile_fullname_field_id() );
323
+ $sql['orderby'] = "ORDER BY u.value";
324
+ $sql['order'] = "ASC";
325
+ }
326
+
327
+ // Alphabetical queries ignore last_activity, while BP uses last_activity
328
+ // to infer spam/deleted/non-activated users. To ensure that these users
329
+ // are filtered out, we add an appropriate sub-query.
330
+ $sql['where'][] = "u.{$this->uid_name} IN ( SELECT ID FROM {$wpdb->users} WHERE " . bp_core_get_status_sql( '' ) . " )";
331
+
332
+ break;
333
+
334
+ // Any other 'type' falls through
335
+ default :
336
+ $this->uid_name = 'ID';
337
+ $this->uid_table = $wpdb->users;
338
+ $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
339
+
340
+ // In this case, we assume that a plugin is
341
+ // handling order, so we leave those clauses
342
+ // blank
343
+
344
+ break;
345
+ }
346
+
347
+ /** WHERE *************************************************************/
348
+
349
+ // 'include' - User ids to include in the results
350
+ $include = false !== $include ? wp_parse_id_list( $include ) : array();
351
+ $include_ids = $this->get_include_ids( $include );
352
+ if ( ! empty( $include_ids ) ) {
353
+ $include_ids = implode( ',', wp_parse_id_list( $include_ids ) );
354
+ $sql['where'][] = "u.{$this->uid_name} IN ({$include_ids})";
355
+ }
356
+
357
+ // 'exclude' - User ids to exclude from the results
358
+ if ( false !== $exclude ) {
359
+ $exclude_ids = implode( ',', wp_parse_id_list( $exclude ) );
360
+ $sql['where'][] = "u.{$this->uid_name} NOT IN ({$exclude_ids})";
361
+ }
362
+
363
+ // 'user_id' - When a user id is passed, limit to the friends of the user
364
+ // @todo remove need for bp_is_active() check
365
+ if ( ! empty( $user_id ) && bp_is_active( 'friends' ) ) {
366
+ $friend_ids = friends_get_friend_user_ids( $user_id );
367
+ $friend_ids = implode( ',', wp_parse_id_list( $friend_ids ) );
368
+
369
+ if ( ! empty( $friend_ids ) ) {
370
+ $sql['where'][] = "u.{$this->uid_name} IN ({$friend_ids})";
371
+
372
+ // If the user has no friends, the query should always
373
+ // return no users
374
+ } else {
375
+ $sql['where'][] = $this->no_results['where'];
376
+ }
377
+ }
378
+
379
+ /** Search Terms ******************************************************/
380
+
381
+ // 'search_terms' searches user_login and user_nicename
382
+ // xprofile field matches happen in bp_xprofile_bp_user_query_search()
383
+ if ( false !== $search_terms ) {
384
+ $search_terms = bp_esc_like( wp_kses_normalize_entities( $search_terms ) );
385
+
386
+ if ( $search_wildcard === 'left' ) {
387
+ $search_terms_nospace = '%' . $search_terms;
388
+ $search_terms_space = '%' . $search_terms . ' %';
389
+ } elseif ( $search_wildcard === 'right' ) {
390
+ $search_terms_nospace = $search_terms . '%';
391
+ $search_terms_space = '% ' . $search_terms . '%';
392
+ } else {
393
+ $search_terms_nospace = '%' . $search_terms . '%';
394
+ $search_terms_space = '%' . $search_terms . '%';
395
+ }
396
+
397
+ $sql['where']['search'] = $wpdb->prepare(
398
+ "u.{$this->uid_name} IN ( SELECT ID FROM {$wpdb->users} WHERE ( user_login LIKE %s OR user_login LIKE %s OR user_nicename LIKE %s OR user_nicename LIKE %s ) )",
399
+ $search_terms_nospace,
400
+ $search_terms_space,
401
+ $search_terms_nospace,
402
+ $search_terms_space
403
+ );
404
+ }
405
+
406
+ // Member type.
407
+ if ( ! empty( $member_type ) ) {
408
+ $member_types = array();
409
+
410
+ if ( ! is_array( $member_type ) ) {
411
+ $member_type = preg_split( '/[,\s+]/', $member_type );
412
+ }
413
+
414
+ foreach ( $member_type as $mt ) {
415
+ if ( ! bp_get_member_type_object( $mt ) ) {
416
+ continue;
417
+ }
418
+
419
+ $member_types[] = $mt;
420
+ }
421
+
422
+ if ( ! empty( $member_types ) ) {
423
+ $member_type_tq = new WP_Tax_Query( array(
424
+ array(
425
+ 'taxonomy' => 'bp_member_type',
426
+ 'field' => 'name',
427
+ 'operator' => 'IN',
428
+ 'terms' => $member_types,
429
+ ),
430
+ ) );
431
+
432
+ // Switch to the root blog, where member type taxonomies live.
433
+ switch_to_blog( bp_get_root_blog_id() );
434
+
435
+ $member_type_sql_clauses = $member_type_tq->get_sql( 'u', $this->uid_name );
436
+ restore_current_blog();
437
+
438
+ // Grab the first term_relationships clause and convert to a subquery.
439
+ if ( preg_match( '/' . $wpdb->term_relationships . '\.term_taxonomy_id IN \([0-9, ]+\)/', $member_type_sql_clauses['where'], $matches ) ) {
440
+ $sql['where']['member_type'] = "u.{$this->uid_name} IN ( SELECT object_id FROM $wpdb->term_relationships WHERE {$matches[0]} )";
441
+ } elseif ( false !== strpos( $member_type_sql_clauses['where'], '0 = 1' ) ) {
442
+ $sql['where']['member_type'] = $this->no_results['where'];
443
+ }
444
+ }
445
+ }
446
+
447
+ // 'meta_key', 'meta_value' allow usermeta search
448
+ // To avoid global joins, do a separate query
449
+ if ( false !== $meta_key ) {
450
+ $meta_sql = $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = %s", $meta_key );
451
+
452
+ if ( false !== $meta_value ) {
453
+ $meta_sql .= $wpdb->prepare( " AND meta_value = %s", $meta_value );
454
+ }
455
+
456
+ $found_user_ids = $wpdb->get_col( $meta_sql );
457
+
458
+ if ( ! empty( $found_user_ids ) ) {
459
+ $sql['where'][] = "u.{$this->uid_name} IN (" . implode( ',', wp_parse_id_list( $found_user_ids ) ) . ")";
460
+ } else {
461
+ $sql['where'][] = '1 = 0';
462
+ }
463
+ }
464
+
465
+ // 'per_page', 'page' - handles LIMIT
466
+ if ( !empty( $per_page ) && !empty( $page ) ) {
467
+ $sql['limit'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
468
+ } else {
469
+ $sql['limit'] = '';
470
+ }
471
+
472
+ // Allow custom filters
473
+ $sql = apply_filters_ref_array( 'bp_user_query_uid_clauses', array( $sql, &$this ) );
474
+
475
+ // Assemble the query chunks
476
+ $this->uid_clauses['select'] = $sql['select'];
477
+ $this->uid_clauses['where'] = ! empty( $sql['where'] ) ? 'WHERE ' . implode( ' AND ', $sql['where'] ) : '';
478
+ $this->uid_clauses['orderby'] = $sql['orderby'];
479
+ $this->uid_clauses['order'] = $sql['order'];
480
+ $this->uid_clauses['limit'] = $sql['limit'];
481
+
482
+ do_action_ref_array( 'bp_pre_user_query', array( &$this ) );
483
+ }
484
+
485
+ /**
486
+ * Query for IDs of users that match the query parameters.
487
+ *
488
+ * Perform a database query to specifically get only user IDs, using
489
+ * existing query variables set previously in the constructor.
490
+ *
491
+ * Also used to quickly perform user total counts.
492
+ *
493
+ * @since BuddyPress (1.7.0)
494
+ */
495
+ public function do_user_ids_query() {
496
+ global $wpdb;
497
+
498
+ // If counting using SQL_CALC_FOUND_ROWS, set it up here
499
+ if ( 'sql_calc_found_rows' == $this->query_vars['count_total'] ) {
500
+ $this->uid_clauses['select'] = str_replace( 'SELECT', 'SELECT SQL_CALC_FOUND_ROWS', $this->uid_clauses['select'] );
501
+ }
502
+
503
+ // Get the specific user ids
504
+ $this->user_ids = $wpdb->get_col( "{$this->uid_clauses['select']} {$this->uid_clauses['where']} {$this->uid_clauses['orderby']} {$this->uid_clauses['order']} {$this->uid_clauses['limit']}" );
505
+
506
+ // Get the total user count
507
+ if ( 'sql_calc_found_rows' == $this->query_vars['count_total'] ) {
508
+ $this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "SELECT FOUND_ROWS()", $this ) );
509
+ } elseif ( 'count_query' == $this->query_vars['count_total'] ) {
510
+ $count_select = preg_replace( '/^SELECT.*?FROM (\S+) u/', "SELECT COUNT(u.{$this->uid_name}) FROM $1 u", $this->uid_clauses['select'] );
511
+ $this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "{$count_select} {$this->uid_clauses['where']}", $this ) );
512
+ }
513
+ }
514
+
515
+ /**
516
+ * Use WP_User_Query() to pull data for the user IDs retrieved in the main query.
517
+ *
518
+ * @since BuddyPress (1.7.0)
519
+ */
520
+ public function do_wp_user_query() {
521
+ $fields = array( 'ID', 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name' );
522
+
523
+ if ( is_multisite() ) {
524
+ $fields[] = 'spam';
525
+ $fields[] = 'deleted';
526
+ }
527
+
528
+ $wp_user_query = new WP_User_Query( apply_filters( 'bp_wp_user_query_args', array(
529
+
530
+ // Relevant
531
+ 'fields' => $fields,
532
+ 'include' => $this->user_ids,
533
+
534
+ // Overrides
535
+ 'blog_id' => 0, // BP does not require blog roles
536
+ 'count_total' => false // We already have a count
537
+
538
+ ), $this ) );
539
+
540
+ // WP_User_Query doesn't cache the data it pulls from wp_users,
541
+ // and it does not give us a way to save queries by fetching
542
+ // only uncached users. However, BP does cache this data, so
543
+ // we set it here.
544
+ foreach ( $wp_user_query->results as $u ) {
545
+ wp_cache_set( 'bp_core_userdata_' . $u->ID, $u, 'bp' );
546
+ }
547
+
548
+ // We calculate total_users using a standalone query, except
549
+ // when a whitelist of user_ids is passed to the constructor.
550
+ // This clause covers the latter situation, and ensures that
551
+ // pagination works when querying by $user_ids.
552
+ if ( empty( $this->total_users ) ) {
553
+ $this->total_users = count( $wp_user_query->results );
554
+ }
555
+
556
+ // Reindex for easier matching
557
+ $r = array();
558
+ foreach ( $wp_user_query->results as $u ) {
559
+ $r[ $u->ID ] = $u;
560
+ }
561
+
562
+ // Match up to the user ids from the main query
563
+ foreach ( $this->user_ids as $uid ) {
564
+ if ( isset( $r[ $uid ] ) ) {
565
+ $this->results[ $uid ] = $r[ $uid ];
566
+
567
+ // The BP template functions expect an 'id'
568
+ // (as opposed to 'ID') property
569
+ $this->results[ $uid ]->id = $uid;
570
+ }
571
+ }
572
+ }
573
+
574
+ /**
575
+ * Fetch the IDs of users to put in the IN clause of the main query.
576
+ *
577
+ * By default, returns the value passed to it
578
+ * ($this->query_vars['include']). Having this abstracted into a
579
+ * standalone method means that extending classes can override the
580
+ * logic, parsing together their own user_id limits with the 'include'
581
+ * ids passed to the class constructor. See {@link BP_Group_Member_Query}
582
+ * for an example.
583
+ *
584
+ * @since BuddyPress (1.8.0)
585
+ *
586
+ * @param array Sanitized array of user IDs, as passed to the 'include'
587
+ * parameter of the class constructor.
588
+ * @return array The list of users to which the main query should be
589
+ * limited.
590
+ */
591
+ public function get_include_ids( $include = array() ) {
592
+ return $include;
593
+ }
594
+
595
+ /**
596
+ * Perform a database query to populate any extra metadata we might need.
597
+ *
598
+ * Different components will hook into the 'bp_user_query_populate_extras'
599
+ * action to loop in the things they want.
600
+ *
601
+ * @since BuddyPress (1.7.0)
602
+ *
603
+ * @global WPDB $wpdb Global WordPress database access object.
604
+ */
605
+ public function populate_extras() {
606
+ global $wpdb;
607
+
608
+ // Bail if no users
609
+ if ( empty( $this->user_ids ) || empty( $this->results ) ) {
610
+ return;
611
+ }
612
+
613
+ // Bail if the populate_extras flag is set to false
614
+ // In the case of the 'popular' sort type, we force
615
+ // populate_extras to true, because we need the friend counts
616
+ if ( 'popular' == $this->query_vars['type'] ) {
617
+ $this->query_vars['populate_extras'] = 1;
618
+ }
619
+
620
+ if ( ! (bool) $this->query_vars['populate_extras'] ) {
621
+ return;
622
+ }
623
+
624
+ // Turn user ID's into a query-usable, comma separated value
625
+ $user_ids_sql = implode( ',', wp_parse_id_list( $this->user_ids ) );
626
+
627
+ /**
628
+ * Use this action to independently populate your own custom extras.
629
+ *
630
+ * Note that anything you add here should query using $user_ids_sql, to
631
+ * avoid running multiple queries per user in the loop.
632
+ *
633
+ * Two BuddyPress components currently do this:
634
+ * - XProfile: To override display names
635
+ * - Friends: To set whether or not a user is the current users friend
636
+ *
637
+ * @see bp_xprofile_filter_user_query_populate_extras()
638
+ * @see bp_friends_filter_user_query_populate_extras()
639
+ */
640
+ do_action_ref_array( 'bp_user_query_populate_extras', array( $this, $user_ids_sql ) );
641
+
642
+ // Fetch last_active data from the activity table
643
+ $last_activities = BP_Core_User::get_last_activity( $this->user_ids );
644
+
645
+ // Set a last_activity value for each user, even if it's empty
646
+ foreach ( $this->results as $user_id => $user ) {
647
+ $user_last_activity = isset( $last_activities[ $user_id ] ) ? $last_activities[ $user_id ]['date_recorded'] : '';
648
+ $this->results[ $user_id ]->last_activity = $user_last_activity;
649
+ }
650
+
651
+ // Fetch usermeta data
652
+ // We want the three following pieces of info from usermeta:
653
+ // - friend count
654
+ // - latest update
655
+ $total_friend_count_key = bp_get_user_meta_key( 'total_friend_count' );
656
+ $bp_latest_update_key = bp_get_user_meta_key( 'bp_latest_update' );
657
+
658
+ // total_friend_count must be set for each user, even if its
659
+ // value is 0
660
+ foreach ( $this->results as $uindex => $user ) {
661
+ $this->results[$uindex]->total_friend_count = 0;
662
+ }
663
+
664
+ // Create, prepare, and run the separate usermeta query
665
+ $user_metas = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, meta_key, meta_value FROM {$wpdb->usermeta} WHERE meta_key IN (%s,%s) AND user_id IN ({$user_ids_sql})", $total_friend_count_key, $bp_latest_update_key ) );
666
+
667
+ // The $members_template global expects the index key to be different
668
+ // from the meta_key in some cases, so we rejig things here.
669
+ foreach ( $user_metas as $user_meta ) {
670
+ switch ( $user_meta->meta_key ) {
671
+ case $total_friend_count_key :
672
+ $key = 'total_friend_count';
673
+ break;
674
+
675
+ case $bp_latest_update_key :
676
+ $key = 'latest_update';
677
+ break;
678
+ }
679
+
680
+ if ( isset( $this->results[ $user_meta->user_id ] ) ) {
681
+ $this->results[ $user_meta->user_id ]->{$key} = $user_meta->meta_value;
682
+ }
683
+ }
684
+
685
+ // When meta_key or meta_value have been passed to the query,
686
+ // fetch the resulting values for use in the template functions
687
+ if ( ! empty( $this->query_vars['meta_key'] ) ) {
688
+ $meta_sql = array(
689
+ 'select' => "SELECT user_id, meta_key, meta_value",
690
+ 'from' => "FROM $wpdb->usermeta",
691
+ 'where' => $wpdb->prepare( "WHERE meta_key = %s", $this->query_vars['meta_key'] )
692
+ );
693
+
694
+ if ( false !== $this->query_vars['meta_value'] ) {
695
+ $meta_sql['where'] .= $wpdb->prepare( " AND meta_value = %s", $this->query_vars['meta_value'] );
696
+ }
697
+
698
+ $metas = $wpdb->get_results( "{$meta_sql['select']} {$meta_sql['from']} {$meta_sql['where']}" );
699
+
700
+ if ( ! empty( $metas ) ) {
701
+ foreach ( $metas as $meta ) {
702
+ if ( isset( $this->results[ $meta->user_id ] ) ) {
703
+ $this->results[ $meta->user_id ]->meta_key = $meta->meta_key;
704
+
705
+ if ( ! empty( $meta->meta_value ) ) {
706
+ $this->results[ $meta->user_id ]->meta_value = $meta->meta_value;
707
+ }
708
+ }
709
+ }
710
+ }
711
+ }
712
+ }
713
+ }
714
+
715
+ /**
716
+ * Fetch data about a BuddyPress user.
717
+ *
718
+ * BP_Core_User class can be used by any component. It will fetch useful
719
+ * details for any user when provided with a user_id.
720
+ *
721
+ * Example:
722
+ * $user = new BP_Core_User( $user_id );
723
+ * $user_avatar = $user->avatar;
724
+ * $user_email = $user->email;
725
+ * $user_status = $user->status;
726
+ * etc.
727
+ */
728
+ class BP_Core_User {
729
+
730
+ /**
731
+ * ID of the user which the object relates to.
732
+ *
733
+ * @var integer
734
+ */
735
+ public $id;
736
+
737
+ /**
738
+ * The URL to the full size of the avatar for the user.
739
+ *
740
+ * @var string
741
+ */
742
+ public $avatar;
743
+
744
+ /**
745
+ * The URL to the thumb size of the avatar for the user.
746
+ *
747
+ * @var string
748
+ */
749
+ public $avatar_thumb;
750
+
751
+ /**
752
+ * The URL to the mini size of the avatar for the user.
753
+ *
754
+ * @var string
755
+ */
756
+ public $avatar_mini;
757
+
758
+ /**
759
+ * The full name of the user
760
+ *
761
+ * @var string
762
+ */
763
+ public $fullname;
764
+
765
+ /**
766
+ * The email for the user.
767
+ *
768
+ * @var string
769
+ */
770
+ public $email;
771
+
772
+ /**
773
+ * The absolute url for the user's profile.
774
+ *
775
+ * @var string
776
+ */
777
+ public $user_url;
778
+
779
+ /**
780
+ * The HTML for the user link, with the link text being the user's full name.
781
+ *
782
+ * @var string
783
+ */
784
+ public $user_link;
785
+
786
+ /**
787
+ * Contains a formatted string when the last time the user was active.
788
+ *
789
+ * Example: "active 2 hours and 50 minutes ago"
790
+ *
791
+ * @var string
792
+ */
793
+ public $last_active;
794
+
795
+ /* Extras */
796
+
797
+ /**
798
+ * The total number of "Friends" the user has on site.
799
+ *
800
+ * @var integer
801
+ */
802
+ public $total_friends;
803
+
804
+ /**
805
+ * The total number of blog posts posted by the user
806
+ *
807
+ * @var integer
808
+ * @deprecated No longer used
809
+ */
810
+ public $total_blogs;
811
+
812
+ /**
813
+ * The total number of groups the user is a part of.
814
+ *
815
+ * Example: "1 group", "2 groups"
816
+ *
817
+ * @var string
818
+ */
819
+ public $total_groups;
820
+
821
+ /**
822
+ * Profile information for the specific user.
823
+ *
824
+ * @since BuddyPress (1.2.0)
825
+ * @var array
826
+ */
827
+ public $profile_data;
828
+
829
+ /** Public Methods *******************************************************/
830
+
831
+ /**
832
+ * Class constructor.
833
+ *
834
+ * @param integer $user_id The ID for the user being queried.
835
+ * @param bool $populate_extras Whether to fetch extra information
836
+ * such as group/friendship counts or not. Default: false.
837
+ */
838
+ public function __construct( $user_id, $populate_extras = false ) {
839
+ if ( !empty( $user_id ) ) {
840
+ $this->id = $user_id;
841
+ $this->populate();
842
+
843
+ if ( !empty( $populate_extras ) ) {
844
+ $this->populate_extras();
845
+ }
846
+ }
847
+ }
848
+
849
+ /**
850
+ * Populate the instantiated class with data based on the User ID provided.
851
+ *
852
+ * @uses bp_core_get_userurl() Returns the URL with no HTML markup for
853
+ * a user based on their user id.
854
+ * @uses bp_core_get_userlink() Returns a HTML formatted link for a
855
+ * user with the user's full name as the link text.
856
+ * @uses bp_core_get_user_email() Returns the email address for the
857
+ * user based on user ID.
858
+ * @uses bp_get_user_meta() BP function returns the value of passed
859
+ * usermeta name from usermeta table.
860
+ * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
861
+ * @uses bp_profile_last_updated_date() Returns the last updated date
862
+ * for a user.
863
+ */
864
+ public function populate() {
865
+
866
+ if ( bp_is_active( 'xprofile' ) )
867
+ $this->profile_data = $this->get_profile_data();
868
+
869
+ if ( !empty( $this->profile_data ) ) {
870
+ $full_name_field_name = bp_xprofile_fullname_field_name();
871
+
872
+ $this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
873
+ $this->fullname = esc_attr( $this->profile_data[$full_name_field_name]['field_data'] );
874
+ $this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
875
+ $this->email = esc_attr( $this->profile_data['user_email'] );
876
+ } else {
877
+ $this->user_url = bp_core_get_user_domain( $this->id );
878
+ $this->user_link = bp_core_get_userlink( $this->id );
879
+ $this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
880
+ $this->email = esc_attr( bp_core_get_user_email( $this->id ) );
881
+ }
882
+
883
+ // Cache a few things that are fetched often
884
+ wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
885
+ wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
886
+ wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
887
+
888
+ $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
889
+ $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
890
+ $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ), 'width' => 30, 'height' => 30 ) );
891
+ $this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), __( 'active %s', 'buddypress' ) );
892
+ }
893
+
894
+ /**
895
+ * Populates extra fields such as group and friendship counts.
896
+ */
897
+ public function populate_extras() {
898
+
899
+ if ( bp_is_active( 'friends' ) ) {
900
+ $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
901
+ }
902
+
903
+ if ( bp_is_active( 'groups' ) ) {
904
+ $this->total_groups = BP_Groups_Member::total_group_count( $this->id );
905
+ $this->total_groups = sprintf( _n( '%d group', '%d groups', $this->total_groups, 'buddypress' ), $this->total_groups );
906
+ }
907
+ }
908
+
909
+ /**
910
+ * Fetch xprofile data for the current user.
911
+ *
912
+ * @see BP_XProfile_ProfileData::get_all_for_user() for description of
913
+ * return value.
914
+ *
915
+ * @return array See {@link BP_XProfile_Profile_Data::get_all_for_user()}.
916
+ */
917
+ public function get_profile_data() {
918
+ return BP_XProfile_ProfileData::get_all_for_user( $this->id );
919
+ }
920
+
921
+ /** Static Methods ********************************************************/
922
+
923
+ /**
924
+ * Get a list of users that match the query parameters.
925
+ *
926
+ * Since BuddyPress 1.7, use {@link BP_User_Query} instead.
927
+ *
928
+ * @deprecated 1.7.0 Use {@link BP_User_Query}.
929
+ *
930
+ * @see BP_User_Query for a description of parameters, most of which
931
+ * are used there in the same way.
932
+ *
933
+ * @param string $type See {@link BP_User_Query}.
934
+ * @param int $limit See {@link BP_User_Query}. Default: 0.
935
+ * @param int $page See {@link BP_User_Query}. Default: 1.
936
+ * @param int $user_id See {@link BP_User_Query}. Default: 0.
937
+ * @param mixed $include See {@link BP_User_Query}. Default: false.
938
+ * @param string|bool $search_terms See {@link BP_User_Query}.
939
+ * Default: false.
940
+ * @param bool $populate_extras See {@link BP_User_Query}.
941
+ * Default: true.
942
+ * @param mixed $exclude See {@link BP_User_Query}. Default: false.
943
+ * @param string|bool $meta_key See {@link BP_User_Query}.
944
+ * Default: false.
945
+ * @param string|bool $meta_value See {@link BP_User_Query}.
946
+ * Default: false.
947
+ * @return array {
948
+ * @type int $total_users Total number of users matched by query
949
+ * params.
950
+ * @type array $paged_users The current page of users matched by
951
+ * query params.
952
+ * }
953
+ */
954
+ public static function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) {
955
+ global $wpdb, $bp;
956
+
957
+ _deprecated_function( __METHOD__, '1.7', 'BP_User_Query' );
958
+
959
+ $sql = array();
960
+
961
+ $sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
962
+
963
+ if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
964
+ $sql['select_active'] = ", um.meta_value as last_activity";
965
+ }
966
+
967
+ if ( 'popular' == $type ) {
968
+ $sql['select_popular'] = ", um.meta_value as total_friend_count";
969
+ }
970
+
971
+ if ( 'alphabetical' == $type ) {
972
+ $sql['select_alpha'] = ", pd.value as fullname";
973
+ }
974
+
975
+ if ( $meta_key ) {
976
+ $sql['select_meta'] = ", umm.meta_key";
977
+
978
+ if ( $meta_value ) {
979
+ $sql['select_meta'] .= ", umm.meta_value";
980
+ }
981
+ }
982
+
983
+ $sql['from'] = "FROM {$wpdb->users} u LEFT JOIN {$wpdb->usermeta} um ON um.user_id = u.ID";
984
+
985
+ // We search against xprofile fields, so we must join the table
986
+ if ( $search_terms && bp_is_active( 'xprofile' ) ) {
987
+ $sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
988
+ }
989
+
990
+ // Alphabetical sorting is done by the xprofile Full Name field
991
+ if ( 'alphabetical' == $type ) {
992
+ $sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
993
+ }
994
+
995
+ if ( $meta_key ) {
996
+ $sql['join_meta'] = "LEFT JOIN {$wpdb->usermeta} umm ON umm.user_id = u.ID";
997
+ }
998
+
999
+ $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
1000
+
1001
+ if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
1002
+ $sql['where_active'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) );
1003
+ }
1004
+
1005
+ if ( 'popular' == $type ) {
1006
+ $sql['where_popular'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );
1007
+ }
1008
+
1009
+ if ( 'online' == $type ) {
1010
+ $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";
1011
+ }
1012
+
1013
+ if ( 'alphabetical' == $type ) {
1014
+ $sql['where_alpha'] = "AND pd.field_id = 1";
1015
+ }
1016
+
1017
+ if ( !empty( $exclude ) ) {
1018
+ $exclude = implode( ',', wp_parse_id_list( $exclude ) );
1019
+ $sql['where_exclude'] = "AND u.ID NOT IN ({$exclude})";
1020
+ }
1021
+
1022
+ // Passing an $include value of 0 or '0' will necessarily result in an empty set
1023
+ // returned. The default value of false will hit the 'else' clause.
1024
+ if ( 0 === $include || '0' === $include ) {
1025
+ $sql['where_users'] = "AND 0 = 1";
1026
+ } else {
1027
+ if ( !empty( $include ) ) {
1028
+ $include = implode( ',', wp_parse_id_list( $include ) );
1029
+ $sql['where_users'] = "AND u.ID IN ({$include})";
1030
+ } elseif ( !empty( $user_id ) && bp_is_active( 'friends' ) ) {
1031
+ $friend_ids = friends_get_friend_user_ids( $user_id );
1032
+
1033
+ if ( !empty( $friend_ids ) ) {
1034
+ $friend_ids = implode( ',', wp_parse_id_list( $friend_ids ) );
1035
+ $sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
1036
+
1037
+ // User has no friends, return false since there will be no users to fetch.
1038
+ } else {
1039
+ return false;
1040
+ }
1041
+ }
1042
+ }
1043
+
1044
+ if ( !empty( $search_terms ) && bp_is_active( 'xprofile' ) ) {
1045
+ $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
1046
+ $sql['where_searchterms'] = $wpdb->prepare( "AND spd.value LIKE %s", $search_terms_like );
1047
+ }
1048
+
1049
+ if ( !empty( $meta_key ) ) {
1050
+ $sql['where_meta'] = $wpdb->prepare( " AND umm.meta_key = %s", $meta_key );
1051
+
1052
+ // If a meta value is provided, match it
1053
+ if ( $meta_value ) {
1054
+ $sql['where_meta'] .= $wpdb->prepare( " AND umm.meta_value = %s", $meta_value );
1055
+ }
1056
+ }
1057
+
1058
+ switch ( $type ) {
1059
+ case 'active': case 'online': default:
1060
+ $sql[] = "ORDER BY um.meta_value DESC";
1061
+ break;
1062
+ case 'newest':
1063
+ $sql[] = "ORDER BY u.ID DESC";
1064
+ break;
1065
+ case 'alphabetical':
1066
+ $sql[] = "ORDER BY pd.value ASC";
1067
+ break;
1068
+ case 'random':
1069
+ $sql[] = "ORDER BY rand()";
1070
+ break;
1071
+ case 'popular':
1072
+ $sql[] = "ORDER BY CONVERT(um.meta_value, SIGNED) DESC";
1073
+ break;
1074
+ }
1075
+
1076
+ if ( !empty( $limit ) && !empty( $page ) ) {
1077
+ $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
1078
+ }
1079
+
1080
+ // Get paginated results
1081
+ $paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array) $sql ), $sql );
1082
+ $paged_users = $wpdb->get_results( $paged_users_sql );
1083
+
1084
+ // Re-jig the SQL so we can get the total user count
1085
+ unset( $sql['select_main'] );
1086
+
1087
+ if ( !empty( $sql['select_active'] ) ) {
1088
+ unset( $sql['select_active'] );
1089
+ }
1090
+
1091
+ if ( !empty( $sql['select_popular'] ) ) {
1092
+ unset( $sql['select_popular'] );
1093
+ }
1094
+
1095
+ if ( !empty( $sql['select_alpha'] ) ) {
1096
+ unset( $sql['select_alpha'] );
1097
+ }
1098
+
1099
+ if ( !empty( $sql['pagination'] ) ) {
1100
+ unset( $sql['pagination'] );
1101
+ }
1102
+
1103
+ array_unshift( $sql, "SELECT COUNT(u.ID)" );
1104
+
1105
+ // Get total user results
1106
+ $total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array) $sql ), $sql );
1107
+ $total_users = $wpdb->get_var( $total_users_sql );
1108
+
1109
+ /***
1110
+ * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
1111
+ * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
1112
+ */
1113
+ if ( !empty( $populate_extras ) ) {
1114
+ $user_ids = array();
1115
+
1116
+ foreach ( (array) $paged_users as $user ) {
1117
+ $user_ids[] = $user->id;
1118
+ }
1119
+
1120
+ // Add additional data to the returned results
1121
+ $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids, $type );
1122
+ }
1123
+
1124
+ return array( 'users' => $paged_users, 'total' => $total_users );
1125
+ }
1126
+
1127
+
1128
+ /**
1129
+ * Fetch the details for all users whose usernames start with the given letter.
1130
+ *
1131
+ * @global BuddyPress $bp The one true BuddyPress instance.
1132
+ * @global wpdb $wpdb WordPress database object.
1133
+ *
1134
+ * @param string $letter The letter the users names are to start with.
1135
+ * @param int $limit The number of users we wish to retrive.
1136
+ * @param int $page The page number we are currently on, used in
1137
+ * conjunction with $limit to get the start position for the
1138
+ * limit.
1139
+ * @param bool $populate_extras Populate extra user fields?
1140
+ * @param string $exclude Comma-separated IDs of users whose results
1141
+ * aren't to be fetched.
1142
+ * @return mixed False on error, otherwise associative array of results.
1143
+ */
1144
+ public static function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) {
1145
+ global $bp, $wpdb;
1146
+
1147
+ $pag_sql = '';
1148
+ if ( $limit && $page ) {
1149
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
1150
+ }
1151
+
1152
+ // Multibyte compliance
1153
+ if ( function_exists( 'mb_strlen' ) ) {
1154
+ if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
1155
+ return false;
1156
+ }
1157
+ } else {
1158
+ if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) {
1159
+ return false;
1160
+ }
1161
+ }
1162
+
1163
+ $letter_like = bp_esc_like( $letter ) . '%';
1164
+ $status_sql = bp_core_get_status_sql( 'u.' );
1165
+
1166
+ if ( !empty( $exclude ) ) {
1167
+ $exclude = implode( ',', wp_parse_id_list( $exclude ) );
1168
+ $exclude_sql = " AND u.id NOT IN ({$exclude})";
1169
+ } else {
1170
+ $exclude_sql = '';
1171
+ }
1172
+
1173
+ $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", bp_xprofile_fullname_field_name(), $letter_like ) );
1174
+ $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", bp_xprofile_fullname_field_name(), $letter_like ) );
1175
+
1176
+ $total_users = $wpdb->get_var( $total_users_sql );
1177
+ $paged_users = $wpdb->get_results( $paged_users_sql );
1178
+
1179
+ /***
1180
+ * Lets fetch some other useful data in a separate queries, this will be
1181
+ * faster than querying the data for every user in a list. We can't add
1182
+ * these to the main query above since only users who have this
1183
+ * information will be returned (since the much of the data is in
1184
+ * usermeta and won't support any type of directional join)
1185
+ */
1186
+ $user_ids = array();
1187
+ foreach ( (array) $paged_users as $user )
1188
+ $user_ids[] = (int) $user->id;
1189
+
1190
+ // Add additional data to the returned results
1191
+ if ( $populate_extras ) {
1192
+ $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
1193
+ }
1194
+
1195
+ return array( 'users' => $paged_users, 'total' => $total_users );
1196
+ }
1197
+
1198
+ /**
1199
+ * Get details of specific users from the database.
1200
+ *
1201
+ * Use {@link BP_User_Query} with the 'user_ids' param instead.
1202
+ *
1203
+ * @global wpdb $wpdb WordPress database object.
1204
+ * @param array $user_ids The user IDs of the users who we wish to
1205
+ * fetch information on.
1206
+ * @param int $limit The limit of results we want.
1207
+ * @param int $page The page we are on for pagination.
1208
+ * @param bool $populate_extras Populate extra user fields?
1209
+ * @return array Associative array.
1210
+ */
1211
+ public static function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {
1212
+ global $wpdb;
1213
+
1214
+ $pag_sql = '';
1215
+ if ( $limit && $page )
1216
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
1217
+
1218
+ $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
1219
+ $status_sql = bp_core_get_status_sql();
1220
+
1221
+ $total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids})" );
1222
+ $paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT ID as id, user_registered, user_nicename, user_login, user_email FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids}) {$pag_sql}" );
1223
+
1224
+ $total_users = $wpdb->get_var( $total_users_sql );
1225
+ $paged_users = $wpdb->get_results( $paged_users_sql );
1226
+
1227
+ /***
1228
+ * Lets fetch some other useful data in a separate queries, this will be
1229
+ * faster than querying the data for every user in a list. We can't add
1230
+ * these to the main query above since only users who have this
1231
+ * information will be returned (since the much of the data is in
1232
+ * usermeta and won't support any type of directional join)
1233
+ */
1234
+
1235
+ // Add additional data to the returned results
1236
+ if ( !empty( $populate_extras ) ) {
1237
+ $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
1238
+ }
1239
+
1240
+ return array( 'users' => $paged_users, 'total' => $total_users );
1241
+ }
1242
+
1243
+ /**
1244
+ * Find users who match on the value of an xprofile data.
1245
+ *
1246
+ * @global BuddyPress $bp The one true BuddyPress instance.
1247
+ * @global wpdb $wpdb WordPress database object.
1248
+ *
1249
+ * @param string $search_terms The terms to search the profile table
1250
+ * value column for.
1251
+ * @param integer $limit The limit of results we want.
1252
+ * @param integer $page The page we are on for pagination.
1253
+ * @param boolean $populate_extras Populate extra user fields?
1254
+ * @return array Associative array.
1255
+ */
1256
+ public static function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
1257
+ global $bp, $wpdb;
1258
+
1259
+ $user_ids = array();
1260
+ $pag_sql = $limit && $page ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ) : '';
1261
+
1262
+ $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
1263
+ $status_sql = bp_core_get_status_sql( 'u.' );
1264
+
1265
+ $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) as id FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", $search_terms_like ), $search_terms );
1266
+ $paged_users_sql = apply_filters( 'bp_core_search_users_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", $search_terms_like ), $search_terms, $pag_sql );
1267
+
1268
+ $total_users = $wpdb->get_var( $total_users_sql );
1269
+ $paged_users = $wpdb->get_results( $paged_users_sql );
1270
+
1271
+ /***
1272
+ * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
1273
+ * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
1274
+ */
1275
+ foreach ( (array) $paged_users as $user )
1276
+ $user_ids[] = $user->id;
1277
+
1278
+ // Add additional data to the returned results
1279
+ if ( $populate_extras )
1280
+ $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
1281
+
1282
+ return array( 'users' => $paged_users, 'total' => $total_users );
1283
+ }
1284
+
1285
+ /**
1286
+ * Fetch extra user information, such as friend count and last profile update message.
1287
+ *
1288
+ * Accepts multiple user IDs to fetch data for.
1289
+ *
1290
+ * @global BuddyPress $bp The one true BuddyPress instance.
1291
+ * @global wpdb $wpdb WordPress database object.
1292
+ *
1293
+ * @param array $paged_users An array of stdClass containing the users.
1294
+ * @param string $user_ids The user ids to select information about.
1295
+ * @param string $type The type of fields we wish to get.
1296
+ * @return mixed False on error, otherwise associative array of results.
1297
+ */
1298
+ public static function get_user_extras( &$paged_users, &$user_ids, $type = false ) {
1299
+ global $bp, $wpdb;
1300
+
1301
+ if ( empty( $user_ids ) )
1302
+ return $paged_users;
1303
+
1304
+ // Sanitize user IDs
1305
+ $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
1306
+
1307
+ // Fetch the user's full name
1308
+ if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
1309
+ $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name() ) );
1310
+ for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
1311
+ foreach ( (array) $names as $name ) {
1312
+ if ( $name->id == $paged_users[$i]->id )
1313
+ $paged_users[$i]->fullname = $name->fullname;
1314
+ }
1315
+ }
1316
+ }
1317
+
1318
+ // Fetch the user's total friend count
1319
+ if ( 'popular' != $type ) {
1320
+ $friend_count = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as total_friend_count FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'total_friend_count' ) ) );
1321
+ for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
1322
+ foreach ( (array) $friend_count as $fcount ) {
1323
+ if ( $fcount->id == $paged_users[$i]->id )
1324
+ $paged_users[$i]->total_friend_count = (int) $fcount->total_friend_count;
1325
+ }
1326
+ }
1327
+ }
1328
+
1329
+ // Fetch whether or not the user is a friend
1330
+ if ( bp_is_active( 'friends' ) ) {
1331
+ $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", bp_loggedin_user_id(), bp_loggedin_user_id() ) );
1332
+ for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
1333
+ foreach ( (array) $friend_status as $status ) {
1334
+ if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id )
1335
+ $paged_users[$i]->is_friend = $status->is_confirmed;
1336
+ }
1337
+ }
1338
+ }
1339
+
1340
+ if ( 'active' != $type ) {
1341
+ $user_activity = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'last_activity' ) ) );
1342
+ for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
1343
+ foreach ( (array) $user_activity as $activity ) {
1344
+ if ( $activity->id == $paged_users[$i]->id )
1345
+ $paged_users[$i]->last_activity = $activity->last_activity;
1346
+ }
1347
+ }
1348
+ }
1349
+
1350
+ // Fetch the user's last_activity
1351
+ if ( 'active' != $type ) {
1352
+ $user_activity = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'last_activity' ) ) );
1353
+ for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
1354
+ foreach ( (array) $user_activity as $activity ) {
1355
+ if ( $activity->id == $paged_users[$i]->id )
1356
+ $paged_users[$i]->last_activity = $activity->last_activity;
1357
+ }
1358
+ }
1359
+ }
1360
+
1361
+ // Fetch the user's latest update
1362
+ $user_update = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as latest_update FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'bp_latest_update' ) ) );
1363
+ for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
1364
+ foreach ( (array) $user_update as $update ) {
1365
+ if ( $update->id == $paged_users[$i]->id )
1366
+ $paged_users[$i]->latest_update = $update->latest_update;
1367
+ }
1368
+ }
1369
+
1370
+ return $paged_users;
1371
+ }
1372
+
1373
+ /**
1374
+ * Get WordPress user details for a specified user.
1375
+ *
1376
+ * @global wpdb $wpdb WordPress database object.
1377
+ *
1378
+ * @param integer $user_id User ID.
1379
+ * @return array Associative array.
1380
+ */
1381
+ public static function get_core_userdata( $user_id ) {
1382
+ global $wpdb;
1383
+
1384
+ if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) )
1385
+ return false;
1386
+
1387
+ return $user;
1388
+ }
1389
+
1390
+ /**
1391
+ * Get last activity data for a user or set of users.
1392
+ *
1393
+ * @param int|array User IDs or multiple user IDs.
1394
+ * @return array
1395
+ */
1396
+ public static function get_last_activity( $user_id ) {
1397
+ global $wpdb;
1398
+
1399
+ // Sanitize and remove empty values
1400
+ $user_ids = array_filter( wp_parse_id_list( $user_id ) );
1401
+
1402
+ if ( empty( $user_ids ) ) {
1403
+ return false;
1404
+ }
1405
+
1406
+ $uncached_user_ids = bp_get_non_cached_ids( $user_ids, 'bp_last_activity' );
1407
+ if ( ! empty( $uncached_user_ids ) ) {
1408
+ $bp = buddypress();
1409
+
1410
+ $user_ids_sql = implode( ',', $uncached_user_ids );
1411
+ $user_count = count( $uncached_user_ids );
1412
+
1413
+ $last_activities = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, date_recorded FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity' AND user_id IN ({$user_ids_sql}) LIMIT {$user_count}", $bp->members->id ) );
1414
+
1415
+ foreach ( $last_activities as $last_activity ) {
1416
+ wp_cache_set( $last_activity->user_id, array(
1417
+ 'user_id' => $last_activity->user_id,
1418
+ 'date_recorded' => $last_activity->date_recorded,
1419
+ 'activity_id' => $last_activity->id,
1420
+ ), 'bp_last_activity' );
1421
+ }
1422
+ }
1423
+
1424
+ // Fetch all user data from the cache
1425
+ $retval = array();
1426
+ foreach ( $user_ids as $user_id ) {
1427
+ $retval[ $user_id ] = wp_cache_get( $user_id, 'bp_last_activity' );
1428
+ }
1429
+
1430
+ return $retval;
1431
+ }
1432
+
1433
+ /**
1434
+ * Set a user's last_activity value.
1435
+ *
1436
+ * Will create a new entry if it does not exist. Otherwise updates the
1437
+ * existing entry.
1438
+ *
1439
+ * @since 2.0
1440
+ *
1441
+ * @param int $user_id ID of the user whose last_activity you are updating.
1442
+ * @param string $time MySQL-formatted time string.
1443
+ * @return bool True on success, false on failure.
1444
+ */
1445
+ public static function update_last_activity( $user_id, $time ) {
1446
+ global $wpdb;
1447
+
1448
+ $table_name = buddypress()->members->table_name_last_activity;
1449
+
1450
+ $activity = self::get_last_activity( $user_id );
1451
+
1452
+ if ( ! empty( $activity[ $user_id ] ) ) {
1453
+ $updated = $wpdb->update(
1454
+ $table_name,
1455
+
1456
+ // Data to update
1457
+ array(
1458
+ 'date_recorded' => $time,
1459
+ ),
1460
+
1461
+ // WHERE
1462
+ array(
1463
+ 'id' => $activity[ $user_id ]['activity_id'],
1464
+ ),
1465
+
1466
+ // Data sanitization format
1467
+ array(
1468
+ '%s',
1469
+ ),
1470
+
1471
+ // WHERE sanitization format
1472
+ array(
1473
+ '%d',
1474
+ )
1475
+ );
1476
+
1477
+ // add new date to existing activity entry for caching
1478
+ $activity[ $user_id ]['date_recorded'] = $time;
1479
+
1480
+ } else {
1481
+ $updated = $wpdb->insert(
1482
+ $table_name,
1483
+
1484
+ // Data
1485
+ array(
1486
+ 'user_id' => $user_id,
1487
+ 'component' => buddypress()->members->id,
1488
+ 'type' => 'last_activity',
1489
+ 'action' => '',
1490
+ 'content' => '',
1491
+ 'primary_link' => '',
1492
+ 'item_id' => 0,
1493
+ 'date_recorded' => $time,
1494
+ ),
1495
+
1496
+ // Data sanitization format
1497
+ array(
1498
+ '%d',
1499
+ '%s',
1500
+ '%s',
1501
+ '%s',
1502
+ '%s',
1503
+ '%s',
1504
+ '%d',
1505
+ '%s',
1506
+ )
1507
+ );
1508
+
1509
+ // set up activity array for caching
1510
+ // view the foreach loop in the get_last_activity() method for format
1511
+ $activity = array();
1512
+ $activity[ $user_id ] = array(
1513
+ 'user_id' => $user_id,
1514
+ 'date_recorded' => $time,
1515
+ 'activity_id' => $wpdb->insert_id,
1516
+ );
1517
+ }
1518
+
1519
+ // set cache
1520
+ wp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' );
1521
+
1522
+ return $updated;
1523
+ }
1524
+
1525
+ /**
1526
+ * Delete a user's last_activity value.
1527
+ *
1528
+ * @since 2.0
1529
+ *
1530
+ * @param int $user_id
1531
+ * @return bool True on success, false on failure or if no last_activity
1532
+ * is found for the user.
1533
+ */
1534
+ public static function delete_last_activity( $user_id ) {
1535
+ global $wpdb;
1536
+
1537
+ $existing = self::get_last_activity( $user_id );
1538
+
1539
+ if ( empty( $existing ) ) {
1540
+ return false;
1541
+ }
1542
+
1543
+ $deleted = $wpdb->delete(
1544
+ buddypress()->members->table_name_last_activity,
1545
+
1546
+ // WHERE
1547
+ array(
1548
+ 'id' => $existing[ $user_id ]['activity_id'],
1549
+ ),
1550
+
1551
+ // WHERE sanitization format
1552
+ array(
1553
+ '%s',
1554
+ )
1555
+ );
1556
+
1557
+ wp_cache_delete( $user_id, 'bp_last_activity' );
1558
+
1559
+ return $deleted;
1560
+ }
1561
+ }
1562
+
1563
+ if ( class_exists( 'WP_Date_Query' ) ) :
1564
+ /**
1565
+ * BuddyPress date query class.
1566
+ *
1567
+ * Extends the {@link WP_Date_Query} class for use with BuddyPress.
1568
+ *
1569
+ * @since BuddyPress (2.1.0)
1570
+ *
1571
+ * @param array $date_query {
1572
+ * Date query arguments. See first parameter of {@link WP_Date_Query::__construct()}.
1573
+ * }
1574
+ * @param string $column The DB column to query against.
1575
+ */
1576
+ class BP_Date_Query extends WP_Date_Query {
1577
+ /**
1578
+ * The column to query against. Can be changed via the query arguments.
1579
+ *
1580
+ * @var string
1581
+ */
1582
+ public $column;
1583
+
1584
+ /**
1585
+ * Constructor.
1586
+ *
1587
+ * @see WP_Date_Query::__construct()
1588
+ */
1589
+ public function __construct( $date_query, $column = '' ) {
1590
+ if ( ! empty( $column ) ) {
1591
+ $this->column = $column;
1592
+ add_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
1593
+ }
1594
+
1595
+ parent::__construct( $date_query, $column );
1596
+ }
1597
+
1598
+ /**
1599
+ * Destructor.
1600
+ */
1601
+ public function __destruct() {
1602
+ remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
1603
+ }
1604
+
1605
+ /**
1606
+ * Registers our date column with WP Date Query to pass validation.
1607
+ *
1608
+ * @param array $retval Current DB columns
1609
+ * @return array
1610
+ */
1611
+ public function register_date_column( $retval = array() ) {
1612
+ $retval[] = $this->column;
1613
+ return $retval;
1614
+ }
1615
+ }
1616
+ endif;
1617
+
1618
+ /**
1619
+ * BP_Core_Notification is deprecated.
1620
+ *
1621
+ * Use BP_Notifications_Notification instead.
1622
+ *
1623
+ * @package BuddyPress Core
1624
+ * @deprecated since BuddyPress (1.9)
1625
+ */
1626
+ class BP_Core_Notification {
1627
+
1628
+ /**
1629
+ * The notification id
1630
+ *
1631
+ * @var integer
1632
+ */
1633
+ public $id;
1634
+
1635
+ /**
1636
+ * The ID to which the notification relates to within the component.
1637
+ *
1638
+ * @var integer
1639
+ */
1640
+ public $item_id;
1641
+
1642
+ /**
1643
+ * The secondary ID to which the notification relates to within the component.
1644
+ *
1645
+ * @var integer
1646
+ */
1647
+ public $secondary_item_id = null;
1648
+
1649
+ /**
1650
+ * The user ID for who the notification is for.
1651
+ *
1652
+ * @var integer
1653
+ */
1654
+ public $user_id;
1655
+
1656
+ /**
1657
+ * The name of the component that the notification is for.
1658
+ *
1659
+ * @var string
1660
+ */
1661
+ public $component_name;
1662
+
1663
+ /**
1664
+ * The action within the component which the notification is related to.
1665
+ *
1666
+ * @var string
1667
+ */
1668
+ public $component_action;
1669
+
1670
+ /**
1671
+ * The date the notification was created.
1672
+ *
1673
+ * @var string
1674
+ */
1675
+ public $date_notified;
1676
+
1677
+ /**
1678
+ * Is the notification new or has it already been read.
1679
+ *
1680
+ * @var boolean
1681
+ */
1682
+ public $is_new;
1683
+
1684
+ /** Public Methods ********************************************************/
1685
+
1686
+ /**
1687
+ * Constructor
1688
+ *
1689
+ * @param integer $id
1690
+ */
1691
+ public function __construct( $id = 0 ) {
1692
+ if ( !empty( $id ) ) {
1693
+ $this->id = $id;
1694
+ $this->populate();
1695
+ }
1696
+ }
1697
+
1698
+ /**
1699
+ * Update or insert notification details into the database.
1700
+ *
1701
+ * @global BuddyPress $bp The one true BuddyPress instance
1702
+ * @global wpdb $wpdb WordPress database object
1703
+ * @return bool Success or failure
1704
+ */
1705
+ public function save() {
1706
+ global $bp, $wpdb;
1707
+
1708
+ // Update
1709
+ if ( !empty( $this->id ) ) {
1710
+ $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
1711
+
1712
+ // Save
1713
+ } else {
1714
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
1715
+ }
1716
+
1717
+ if ( !$result = $wpdb->query( $sql ) )
1718
+ return false;
1719
+
1720
+ $this->id = $wpdb->insert_id;
1721
+
1722
+ return true;
1723
+ }
1724
+
1725
+ /** Private Methods *******************************************************/
1726
+
1727
+ /**
1728
+ * Fetches the notification data from the database.
1729
+ *
1730
+ * @global BuddyPress $bp The one true BuddyPress instance
1731
+ * @global wpdb $wpdb WordPress database object
1732
+ */
1733
+ public function populate() {
1734
+ global $bp, $wpdb;
1735
+
1736
+ if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
1737
+ $this->item_id = $notification->item_id;
1738
+ $this->secondary_item_id = $notification->secondary_item_id;
1739
+ $this->user_id = $notification->user_id;
1740
+ $this->component_name = $notification->component_name;
1741
+ $this->component_action = $notification->component_action;
1742
+ $this->date_notified = $notification->date_notified;
1743
+ $this->is_new = $notification->is_new;
1744
+ }
1745
+ }
1746
+
1747
+ /** Static Methods ********************************************************/
1748
+
1749
+ public static function check_access( $user_id, $notification_id ) {
1750
+ global $wpdb, $bp;
1751
+
1752
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );
1753
+ }
1754
+
1755
+ /**
1756
+ * Fetches all the notifications in the database for a specific user.
1757
+ *
1758
+ * @global BuddyPress $bp The one true BuddyPress instance
1759
+ * @global wpdb $wpdb WordPress database object
1760
+ * @param integer $user_id User ID
1761
+ * @param string $status 'is_new' or 'all'
1762
+ * @return array Associative array
1763
+ * @static
1764
+ */
1765
+ public static function get_all_for_user( $user_id, $status = 'is_new' ) {
1766
+ global $bp, $wpdb;
1767
+
1768
+ $is_new = ( 'is_new' == $status ) ? ' AND is_new = 1 ' : '';
1769
+
1770
+ return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) );
1771
+ }
1772
+
1773
+ /**
1774
+ * Delete all the notifications for a user based on the component name and action.
1775
+ *
1776
+ * @global BuddyPress $bp The one true BuddyPress instance
1777
+ * @global wpdb $wpdb WordPress database object
1778
+ * @param integer $user_id
1779
+ * @param string $component_name
1780
+ * @param string $component_action
1781
+ * @static
1782
+ */
1783
+ public static function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
1784
+ global $bp, $wpdb;
1785
+
1786
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
1787
+ }
1788
+
1789
+ /**
1790
+ * Delete all the notifications that have a specific item id, component name and action.
1791
+ *
1792
+ * @global BuddyPress $bp The one true BuddyPress instance
1793
+ * @global wpdb $wpdb WordPress database object
1794
+ * @param integer $user_id The ID of the user who the notifications are for.
1795
+ * @param integer $item_id The item ID of the notifications we wish to delete.
1796
+ * @param string $component_name The name of the component that the notifications we wish to delete.
1797
+ * @param string $component_action The action of the component that the notifications we wish to delete.
1798
+ * @param integer $secondary_item_id (optional) The secondary item id of the notifications that we wish to use to delete.
1799
+ * @static
1800
+ */
1801
+ public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
1802
+ global $bp, $wpdb;
1803
+
1804
+ $secondary_item_sql = !empty( $secondary_item_id ) ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) : '';
1805
+
1806
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) );
1807
+ }
1808
+
1809
+ /**
1810
+ * Deletes all the notifications sent by a specific user, by component and action.
1811
+ *
1812
+ * @global BuddyPress $bp The one true BuddyPress instance
1813
+ * @global wpdb $wpdb WordPress database object
1814
+ * @param integer $user_id The ID of the user whose sent notifications we wish to delete.
1815
+ * @param string $component_name The name of the component the notification was sent from.
1816
+ * @param string $component_action The action of the component the notification was sent from.
1817
+ * @static
1818
+ */
1819
+ public static function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
1820
+ global $bp, $wpdb;
1821
+
1822
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
1823
+ }
1824
+
1825
+ /**
1826
+ * Deletes all the notifications for all users by item id, and optional secondary item id, and component name and action.
1827
+ *
1828
+ * @global BuddyPress $bp The one true BuddyPress instance
1829
+ * @global wpdb $wpdb WordPress database object
1830
+ * @param string $item_id The item id that they notifications are to be for.
1831
+ * @param string $component_name The component that the notifications are to be from.
1832
+ * @param string $component_action The action that the notifications are to be from.
1833
+ * @param string $secondary_item_id Optional secondary item id that the notifications are to have.
1834
+ * @static
1835
+ */
1836
+ public static function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
1837
+ global $bp, $wpdb;
1838
+
1839
+ if ( $component_action )
1840
+ $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
1841
+ else
1842
+ $component_action_sql = '';
1843
+
1844
+ if ( $secondary_item_id )
1845
+ $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
1846
+ else
1847
+ $secondary_item_sql = '';
1848
+
1849
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) );
1850
+ }
1851
+ }
1852
+
1853
+ /**
1854
+ * API to create BuddyPress buttons.
1855
+ *
1856
+ * @since BuddyPress (1.2.6)
1857
+ *
1858
+ * @param array $args {
1859
+ * Array of arguments.
1860
+ * @type string $id String describing the button type.
1861
+ * @type string $component The name of the component the button belongs to.
1862
+ * Default: 'core'.
1863
+ * @type bool $must_be_logged_in Optional. Does the user need to be logged
1864
+ * in to see this button? Default: true.
1865
+ * @type bool $block_self Optional. True if the button should be hidden
1866
+ * when a user is viewing his own profile. Default: true.
1867
+ * @type string|bool $wrapper Optional. HTML element type that should wrap
1868
+ * the button: 'div', 'span', 'p', or 'li'. False for no wrapper at
1869
+ * all. Default: 'div'.
1870
+ * @type string $wrapper_id Optional. DOM ID of the button wrapper element.
1871
+ * Default: ''.
1872
+ * @type string $wrapper_class Optional. DOM class of the button wrapper
1873
+ * element. Default: ''.
1874
+ * @type string $link_href Optional. Destination link of the button.
1875
+ * Default: ''.
1876
+ * @type string $link_class Optional. DOM class of the button. Default: ''.
1877
+ * @type string $link_id Optional. DOM ID of the button. Default: ''.
1878
+ * @type string $link_rel Optional. DOM 'rel' attribute of the button.
1879
+ * Default: ''.
1880
+ * @type string $link_title Optional. Title attribute of the button.
1881
+ * Default: ''.
1882
+ * @type string $link_text Optional. Text to appear on the button.
1883
+ * Default: ''.
1884
+ * }
1885
+ */
1886
+ class BP_Button {
1887
+
1888
+ /** Button properties *****************************************************/
1889
+
1890
+ /**
1891
+ * The button ID.
1892
+ *
1893
+ * @var string
1894
+ */
1895
+ public $id = '';
1896
+
1897
+ /**
1898
+ * The name of the component that the button belongs to.
1899
+ *
1900
+ * @var string
1901
+ */
1902
+ public $component = 'core';
1903
+
1904
+ /**
1905
+ * Does the user need to be logged in to see this button?
1906
+ *
1907
+ * @var bool
1908
+ */
1909
+ public $must_be_logged_in = true;
1910
+
1911
+ /**
1912
+ * Whether the button should be hidden when viewing your own profile.
1913
+ *
1914
+ * @var bool
1915
+ */
1916
+ public $block_self = true;
1917
+
1918
+ /** Wrapper ***************************************************************/
1919
+
1920
+ /**
1921
+ * The type of DOM element to use for a wrapper.
1922
+ *
1923
+ * @var string|bool 'div', 'span', 'p', 'li', or false for no wrapper.
1924
+ */
1925
+ public $wrapper = 'div';
1926
+
1927
+ /**
1928
+ * The DOM class of the button wrapper.
1929
+ *
1930
+ * @var string
1931
+ */
1932
+ public $wrapper_class = '';
1933
+
1934
+ /**
1935
+ * The DOM ID of the button wrapper.
1936
+ *
1937
+ * @var string
1938
+ */
1939
+ public $wrapper_id = '';
1940
+
1941
+ /** Button ****************************************************************/
1942
+
1943
+ /**
1944
+ * The destination link of the button.
1945
+ *
1946
+ * @var string
1947
+ */
1948
+ public $link_href = '';
1949
+
1950
+ /**
1951
+ * The DOM class of the button link.
1952
+ *
1953
+ * @var string
1954
+ */
1955
+ public $link_class = '';
1956
+
1957
+ /**
1958
+ * The DOM ID of the button link.
1959
+ *
1960
+ * @var string
1961
+ */
1962
+ public $link_id = '';
1963
+
1964
+ /**
1965
+ * The DOM rel value of the button link.
1966
+ *
1967
+ * @var string
1968
+ */
1969
+ public $link_rel = '';
1970
+
1971
+ /**
1972
+ * Title of the button link.
1973
+ *
1974
+ * @var string
1975
+ */
1976
+ public $link_title = '';
1977
+
1978
+ /**
1979
+ * The contents of the button link.
1980
+ *
1981
+ * @var string
1982
+ */
1983
+ public $link_text = '';
1984
+
1985
+ /** HTML result ***********************************************************/
1986
+
1987
+ public $contents = '';
1988
+
1989
+ /** Methods ***************************************************************/
1990
+
1991
+ /**
1992
+ * Builds the button based on class parameters.
1993
+ *
1994
+ * @since BuddyPress (1.2.6)
1995
+ *
1996
+ * @param array $args See {@BP_Button}.
1997
+ * @return bool|null Returns false when the button is not allowed for
1998
+ * the current context.
1999
+ */
2000
+ public function __construct( $args = '' ) {
2001
+
2002
+ $r = wp_parse_args( $args, get_class_vars( __CLASS__ ) );
2003
+
2004
+ // Required button properties
2005
+ $this->id = $r['id'];
2006
+ $this->component = $r['component'];
2007
+ $this->must_be_logged_in = (bool) $r['must_be_logged_in'];
2008
+ $this->block_self = (bool) $r['block_self'];
2009
+ $this->wrapper = $r['wrapper'];
2010
+
2011
+ // $id and $component are required
2012
+ if ( empty( $r['id'] ) || empty( $r['component'] ) )
2013
+ return false;
2014
+
2015
+ // No button if component is not active
2016
+ if ( ! bp_is_active( $this->component ) )
2017
+ return false;
2018
+
2019
+ // No button for guests if must be logged in
2020
+ if ( true == $this->must_be_logged_in && ! is_user_logged_in() )
2021
+ return false;
2022
+
2023
+ // block_self
2024
+ if ( true == $this->block_self ) {
2025
+ // No button if you are the current user in a members loop
2026
+ // This condition takes precedence, because members loops
2027
+ // can be found on user profiles
2028
+ if ( bp_get_member_user_id() ) {
2029
+ if ( is_user_logged_in() && bp_loggedin_user_id() == bp_get_member_user_id() ) {
2030
+ return false;
2031
+ }
2032
+
2033
+ // No button if viewing your own profile (and not in
2034
+ // a members loop)
2035
+ } elseif ( bp_is_my_profile() ) {
2036
+ return false;
2037
+ }
2038
+ }
2039
+
2040
+ // Wrapper properties
2041
+ if ( false !== $this->wrapper ) {
2042
+
2043
+ // Wrapper ID
2044
+ if ( !empty( $r['wrapper_id'] ) ) {
2045
+ $this->wrapper_id = ' id="' . $r['wrapper_id'] . '"';
2046
+ }
2047
+
2048
+ // Wrapper class
2049
+ if ( !empty( $r['wrapper_class'] ) ) {
2050
+ $this->wrapper_class = ' class="generic-button ' . $r['wrapper_class'] . '"';
2051
+ } else {
2052
+ $this->wrapper_class = ' class="generic-button"';
2053
+ }
2054
+
2055
+ // Set before and after
2056
+ $before = '<' . $r['wrapper'] . $this->wrapper_class . $this->wrapper_id . '>';
2057
+ $after = '</' . $r['wrapper'] . '>';
2058
+
2059
+ // No wrapper
2060
+ } else {
2061
+ $before = $after = '';
2062
+ }
2063
+
2064
+ // Link properties
2065
+ if ( !empty( $r['link_id'] ) ) $this->link_id = ' id="' . $r['link_id'] . '"';
2066
+ if ( !empty( $r['link_href'] ) ) $this->link_href = ' href="' . $r['link_href'] . '"';
2067
+ if ( !empty( $r['link_title'] ) ) $this->link_title = ' title="' . $r['link_title'] . '"';
2068
+ if ( !empty( $r['link_rel'] ) ) $this->link_rel = ' rel="' . $r['link_rel'] . '"';
2069
+ if ( !empty( $r['link_class'] ) ) $this->link_class = ' class="' . $r['link_class'] . '"';
2070
+ if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text'];
2071
+
2072
+ // Build the button
2073
+ $this->contents = $before . '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>' . $after;
2074
+
2075
+ // Allow button to be manipulated externally
2076
+ $this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after );
2077
+ }
2078
+
2079
+ /**
2080
+ * Return the markup for the generated button.
2081
+ *
2082
+ * @since BuddyPress (1.2.6)
2083
+ *
2084
+ * @return string Button markup.
2085
+ */
2086
+ public function contents() {
2087
+ return $this->contents;
2088
+ }
2089
+
2090
+ /**
2091
+ * Output the markup of button.
2092
+ *
2093
+ * @since BuddyPress (1.2.6)
2094
+ */
2095
+ public function display() {
2096
+ if ( !empty( $this->contents ) )
2097
+ echo $this->contents;
2098
+ }
2099
+ }
2100
+
2101
+ /**
2102
+ * Enable oEmbeds in BuddyPress contexts.
2103
+ *
2104
+ * Extends WP_Embed class for use with BuddyPress.
2105
+ *
2106
+ * @since BuddyPress (1.5.0)
2107
+ *
2108
+ * @see WP_Embed
2109
+ */
2110
+ class BP_Embed extends WP_Embed {
2111
+
2112
+ /**
2113
+ * Constructor
2114
+ *
2115
+ * @global WP_Embed $wp_embed
2116
+ */
2117
+ public function __construct() {
2118
+ global $wp_embed;
2119
+
2120
+ // Make sure we populate the WP_Embed handlers array.
2121
+ // These are providers that use a regex callback on the URL in question.
2122
+ // Do not confuse with oEmbed providers, which require an external ping.
2123
+ // Used in WP_Embed::shortcode()
2124
+ $this->handlers = $wp_embed->handlers;
2125
+
2126
+ if ( bp_use_embed_in_activity() ) {
2127
+ add_filter( 'bp_get_activity_content_body', array( &$this, 'autoembed' ), 8 );
2128
+ add_filter( 'bp_get_activity_content_body', array( &$this, 'run_shortcode' ), 7 );
2129
+ }
2130
+
2131
+ if ( bp_use_embed_in_activity_replies() ) {
2132
+ add_filter( 'bp_get_activity_content', array( &$this, 'autoembed' ), 8 );
2133
+ add_filter( 'bp_get_activity_content', array( &$this, 'run_shortcode' ), 7 );
2134
+ }
2135
+
2136
+ if ( bp_use_embed_in_forum_posts() ) {
2137
+ add_filter( 'bp_get_the_topic_post_content', array( &$this, 'autoembed' ), 8 );
2138
+ add_filter( 'bp_get_the_topic_post_content', array( &$this, 'run_shortcode' ), 7 );
2139
+ }
2140
+
2141
+ if ( bp_use_embed_in_private_messages() ) {
2142
+ add_filter( 'bp_get_the_thread_message_content', array( &$this, 'autoembed' ), 8 );
2143
+ add_filter( 'bp_get_the_thread_message_content', array( &$this, 'run_shortcode' ), 7 );
2144
+ }
2145
+
2146
+ do_action_ref_array( 'bp_core_setup_oembed', array( &$this ) );
2147
+ }
2148
+
2149
+ /**
2150
+ * The {@link do_shortcode()} callback function.
2151
+ *
2152
+ * Attempts to convert a URL into embed HTML. Starts by checking the
2153
+ * URL against the regex of the registered embed handlers. Next, checks
2154
+ * the URL against the regex of registered {@link WP_oEmbed} providers
2155
+ * if oEmbed discovery is false. If none of the regex matches and it's
2156
+ * enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()}
2157
+ * for oEmbed parsing.
2158
+ *
2159
+ * @uses wp_parse_args()
2160
+ * @uses wp_embed_defaults()
2161
+ * @uses current_user_can()
2162
+ * @uses _wp_oembed_get_object()
2163
+ * @uses WP_Embed::maybe_make_link()
2164
+ *
2165
+ * @param array $attr Shortcode attributes.
2166
+ * @param string $url The URL attempting to be embeded.
2167
+ * @return string The embed HTML on success, otherwise the original URL.
2168
+ */
2169
+ public function shortcode( $attr, $url = '' ) {
2170
+ if ( empty( $url ) )
2171
+ return '';
2172
+
2173
+ $rawattr = $attr;
2174
+ $attr = wp_parse_args( $attr, wp_embed_defaults() );
2175
+
2176
+ // kses converts & into &amp; and we need to undo this
2177
+ // See http://core.trac.wordpress.org/ticket/11311
2178
+ $url = str_replace( '&amp;', '&', $url );
2179
+
2180
+ // Look for known internal handlers
2181
+ ksort( $this->handlers );
2182
+ foreach ( $this->handlers as $priority => $handlers ) {
2183
+ foreach ( $handlers as $hid => $handler ) {
2184
+ if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
2185
+ if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) {
2186
+ return apply_filters( 'embed_handler_html', $return, $url, $attr );
2187
+ }
2188
+ }
2189
+ }
2190
+ }
2191
+
2192
+ // Get object ID
2193
+ $id = apply_filters( 'embed_post_id', 0 );
2194
+
2195
+ // Is oEmbed discovery on?
2196
+ $attr['discover'] = ( apply_filters( 'bp_embed_oembed_discover', false ) && current_user_can( 'unfiltered_html' ) );
2197
+
2198
+ // Set up a new WP oEmbed object to check URL with registered oEmbed providers
2199
+ require_once( ABSPATH . WPINC . '/class-oembed.php' );
2200
+ $oembed_obj = _wp_oembed_get_object();
2201
+
2202
+ // If oEmbed discovery is true, skip oEmbed provider check
2203
+ $is_oembed_link = false;
2204
+ if ( !$attr['discover'] ) {
2205
+ foreach ( (array) $oembed_obj->providers as $provider_matchmask => $provider ) {
2206
+ $regex = ( $is_regex = $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i';
2207
+
2208
+ if ( preg_match( $regex, $url ) )
2209
+ $is_oembed_link = true;
2210
+ }
2211
+
2212
+ // If url doesn't match a WP oEmbed provider, stop parsing
2213
+ if ( !$is_oembed_link )
2214
+ return $this->maybe_make_link( $url );
2215
+ }
2216
+
2217
+ return $this->parse_oembed( $id, $url, $attr, $rawattr );
2218
+ }
2219
+
2220
+ /**
2221
+ * Base function so BP components/plugins can parse links to be embedded.
2222
+ *
2223
+ * View an example to add support in {@link bp_activity_embed()}.
2224
+ *
2225
+ * @uses apply_filters() Filters cache.
2226
+ * @uses do_action() To save cache.
2227
+ * @uses wp_oembed_get() Connects to oEmbed provider and returns HTML
2228
+ * on success.
2229
+ * @uses WP_Embed::maybe_make_link() Process URL for hyperlinking on
2230
+ * oEmbed failure.
2231
+ *
2232
+ * @param int $id ID to do the caching for.
2233
+ * @param string $url The URL attempting to be embedded.
2234
+ * @param array $attr Shortcode attributes from {@link WP_Embed::shortcode()}.
2235
+ * @param array $rawattr Untouched shortcode attributes from
2236
+ * {@link WP_Embed::shortcode()}.
2237
+ * @return string The embed HTML on success, otherwise the original URL.
2238
+ */
2239
+ public function parse_oembed( $id, $url, $attr, $rawattr ) {
2240
+ $id = intval( $id );
2241
+
2242
+ if ( $id ) {
2243
+ // Setup the cachekey
2244
+ $cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
2245
+
2246
+ // Let components / plugins grab their cache
2247
+ $cache = '';
2248
+ $cache = apply_filters( 'bp_embed_get_cache', $cache, $id, $cachekey, $url, $attr, $rawattr );
2249
+
2250
+ // Grab cache and return it if available
2251
+ if ( !empty( $cache ) ) {
2252
+ return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr );
2253
+
2254
+ // If no cache, ping the oEmbed provider and cache the result
2255
+ } else {
2256
+ $html = wp_oembed_get( $url, $attr );
2257
+ $cache = ( $html ) ? $html : $url;
2258
+
2259
+ // Let components / plugins save their cache
2260
+ do_action( 'bp_embed_update_cache', $cache, $cachekey, $id );
2261
+
2262
+ // If there was a result, return it
2263
+ if ( $html )
2264
+ return apply_filters( 'bp_embed_oembed_html', $html, $url, $attr, $rawattr );
2265
+ }
2266
+ }
2267
+
2268
+ // Still unknown
2269
+ return $this->maybe_make_link( $url );
2270
+ }
2271
+ }
2272
+
2273
+ /**
2274
+ * Create HTML list of BP nav items.
2275
+ *
2276
+ * @since BuddyPress (1.7.0)
2277
+ */
2278
+ class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
2279
+
2280
+ /**
2281
+ * Description of fields indexes for building markup.
2282
+ *
2283
+ * @since BuddyPress (1.7.0)
2284
+ * @var array
2285
+ */
2286
+ var $db_fields = array( 'id' => 'css_id', 'parent' => 'parent' );
2287
+
2288
+ /**
2289
+ * Tree type.
2290
+ *
2291
+ * @since BuddyPress (1.7.0)
2292
+ * @var string
2293
+ */
2294
+ var $tree_type = array();
2295
+
2296
+ /**
2297
+ * Display array of elements hierarchically.
2298
+ *
2299
+ * This method is almost identical to the version in {@link Walker::walk()}.
2300
+ * The only change is on one line which has been commented. An IF was
2301
+ * comparing 0 to a non-empty string which was preventing child elements
2302
+ * being grouped under their parent menu element.
2303
+ *
2304
+ * This caused a problem for BuddyPress because our primary/secondary
2305
+ * navigations don't have a unique numerical ID that describes a
2306
+ * hierarchy (we use a slug). Obviously, WordPress Menus use Posts, and
2307
+ * those have ID/post_parent.
2308
+ *
2309
+ * @since BuddyPress (1.7.0)
2310
+ *
2311
+ * @see Walker::walk()
2312
+ *
2313
+ * @param array $elements See {@link Walker::walk()}.
2314
+ * @param int $max_depth See {@link Walker::walk()}.
2315
+ * @return string See {@link Walker::walk()}.
2316
+ */
2317
+ public function walk( $elements, $max_depth ) {
2318
+ $func_args = func_get_args();
2319
+
2320
+ $args = array_slice( $func_args, 2 );
2321
+ $output = '';
2322
+
2323
+ if ( $max_depth < -1 ) // invalid parameter
2324
+ return $output;
2325
+
2326
+ if ( empty( $elements ) ) // nothing to walk
2327
+ return $output;
2328
+
2329
+ $parent_field = $this->db_fields['parent'];
2330
+
2331
+ // flat display
2332
+ if ( -1 == $max_depth ) {
2333
+
2334
+ $empty_array = array();
2335
+ foreach ( $elements as $e )
2336
+ $this->display_element( $e, $empty_array, 1, 0, $args, $output );
2337
+
2338
+ return $output;
2339
+ }
2340
+
2341
+ /*
2342
+ * need to display in hierarchical order
2343
+ * separate elements into two buckets: top level and children elements
2344
+ * children_elements is two dimensional array, eg.
2345
+ * children_elements[10][] contains all sub-elements whose parent is 10.
2346
+ */
2347
+ $top_level_elements = array();
2348
+ $children_elements = array();
2349
+
2350
+ foreach ( $elements as $e ) {
2351
+ // BuddyPress: changed '==' to '==='. This is the only change from version in Walker::walk().
2352
+ if ( 0 === $e->$parent_field )
2353
+ $top_level_elements[] = $e;
2354
+ else
2355
+ $children_elements[$e->$parent_field][] = $e;
2356
+ }
2357
+
2358
+ /*
2359
+ * when none of the elements is top level
2360
+ * assume the first one must be root of the sub elements
2361
+ */
2362
+ if ( empty( $top_level_elements ) ) {
2363
+
2364
+ $first = array_slice( $elements, 0, 1 );
2365
+ $root = $first[0];
2366
+ $top_level_elements = array();
2367
+ $children_elements = array();
2368
+
2369
+ foreach ( $elements as $e ) {
2370
+ if ( $root->$parent_field == $e->$parent_field )
2371
+ $top_level_elements[] = $e;
2372
+ else
2373
+ $children_elements[$e->$parent_field][] = $e;
2374
+ }
2375
+ }
2376
+
2377
+ foreach ( $top_level_elements as $e )
2378
+ $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
2379
+
2380
+ /*
2381
+ * if we are displaying all levels, and remaining children_elements is not empty,
2382
+ * then we got orphans, which should be displayed regardless
2383
+ */
2384
+ if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
2385
+ $empty_array = array();
2386
+
2387
+ foreach ( $children_elements as $orphans )
2388
+ foreach ( $orphans as $op )
2389
+ $this->display_element( $op, $empty_array, 1, 0, $args, $output );
2390
+ }
2391
+
2392
+ return $output;
2393
+ }
2394
+
2395
+ /**
2396
+ * Display the current <li> that we are on.
2397
+ *
2398
+ * @see Walker::start_el() for complete description of parameters .
2399
+ *
2400
+ * @since BuddyPress (1.7.0)
2401
+ *
2402
+ * @param string $output Passed by reference. Used to append
2403
+ * additional content.
2404
+ * @param object $item Menu item data object.
2405
+ * @param int $depth Depth of menu item. Used for padding. Optional,
2406
+ * defaults to 0.
2407
+ * @param array $args Optional. See {@link Walker::start_el()}.
2408
+ * @param int $current_page Menu item ID. Optional.
2409
+ */
2410
+ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
2411
+ // If we're someway down the tree, indent the HTML with the appropriate number of tabs
2412
+ $indent = $depth ? str_repeat( "\t", $depth ) : '';
2413
+
2414
+ // Add HTML classes
2415
+ $class_names = join( ' ', apply_filters( 'bp_nav_menu_css_class', array_filter( $item->class ), $item, $args ) );
2416
+ $class_names = ! empty( $class_names ) ? ' class="' . esc_attr( $class_names ) . '"' : '';
2417
+
2418
+ // Add HTML ID
2419
+ $id = sanitize_html_class( $item->css_id . '-personal-li' ); // Backpat with BP pre-1.7
2420
+ $id = apply_filters( 'bp_nav_menu_item_id', $id, $item, $args );
2421
+ $id = ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
2422
+
2423
+ // Opening tag; closing tag is handled in Walker_Nav_Menu::end_el().
2424
+ $output .= $indent . '<li' . $id . $class_names . '>';
2425
+
2426
+ // Add href attribute
2427
+ $attributes = ! empty( $item->link ) ? ' href="' . esc_url( $item->link ) . '"' : '';
2428
+
2429
+ // Construct the link
2430
+ $item_output = $args->before;
2431
+ $item_output .= '<a' . $attributes . '>';
2432
+ $item_output .= $args->link_before . apply_filters( 'the_title', $item->name, 0 ) . $args->link_after;
2433
+ $item_output .= '</a>';
2434
+ $item_output .= $args->after;
2435
+
2436
+ // $output is byref
2437
+ $output .= apply_filters( 'bp_walker_nav_menu_start_el', $item_output, $item, $depth, $args );
2438
+ }
2439
+ }
2440
+
2441
+ /**
2442
+ * Create a set of BuddyPress-specific links for use in the Menus admin UI.
2443
+ *
2444
+ * Borrowed heavily from {@link Walker_Nav_Menu_Checklist}, but modified so as not
2445
+ * to require an actual post type or taxonomy, and to force certain CSS classes
2446
+ *
2447
+ * @since BuddyPress (1.9.0)
2448
+ */
2449
+ class BP_Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
2450
+
2451
+ /**
2452
+ * Constructor.
2453
+ *
2454
+ * @see Walker_Nav_Menu::__construct() for a description of parameters.
2455
+ *
2456
+ * @param array $fields See {@link Walker_Nav_Menu::__construct()}.
2457
+ */
2458
+ public function __construct( $fields = false ) {
2459
+ if ( $fields ) {
2460
+ $this->db_fields = $fields;
2461
+ }
2462
+ }
2463
+
2464
+ /**
2465
+ * Create the markup to start a tree level.
2466
+ *
2467
+ * @see Walker_Nav_Menu::start_lvl() for description of parameters.
2468
+ *
2469
+ * @param string $output See {@Walker_Nav_Menu::start_lvl()}.
2470
+ * @param int $depth See {@Walker_Nav_Menu::start_lvl()}.
2471
+ * @param array $args See {@Walker_Nav_Menu::start_lvl()}.
2472
+ */
2473
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {
2474
+ $indent = str_repeat( "\t", $depth );
2475
+ $output .= "\n$indent<ul class='children'>\n";
2476
+ }
2477
+
2478
+ /**
2479
+ * Create the markup to end a tree level.
2480
+ *
2481
+ * @see Walker_Nav_Menu::end_lvl() for description of parameters.
2482
+ *
2483
+ * @param string $output See {@Walker_Nav_Menu::end_lvl()}.
2484
+ * @param int $depth See {@Walker_Nav_Menu::end_lvl()}.
2485
+ * @param array $args See {@Walker_Nav_Menu::end_lvl()}.
2486
+ */
2487
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {
2488
+ $indent = str_repeat( "\t", $depth );
2489
+ $output .= "\n$indent</ul>";
2490
+ }
2491
+
2492
+ /**
2493
+ * Create the markup to start an element.
2494
+ *
2495
+ * @see Walker::start_el() for description of parameters.
2496
+ *
2497
+ * @param string $output Passed by reference. Used to append additional
2498
+ * content.
2499
+ * @param object $item Menu item data object.
2500
+ * @param int $depth Depth of menu item. Used for padding.
2501
+ * @param object $args See {@Walker::start_el()}.
2502
+ * @param int $id See {@Walker::start_el()}.
2503
+ */
2504
+ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
2505
+ global $_nav_menu_placeholder;
2506
+
2507
+ $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
2508
+ $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
2509
+ $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
2510
+
2511
+ $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
2512
+
2513
+ $output .= $indent . '<li>';
2514
+ $output .= '<label class="menu-item-title">';
2515
+ $output .= '<input type="checkbox" class="menu-item-checkbox';
2516
+
2517
+ if ( property_exists( $item, 'label' ) ) {
2518
+ $title = $item->label;
2519
+ }
2520
+
2521
+ $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> ';
2522
+ $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
2523
+ $output .= '</label>';
2524
+
2525
+ if ( empty( $item->url ) ) {
2526
+ $item->url = $item->guid;
2527
+ }
2528
+
2529
+ if ( ! in_array( array( 'bp-menu', 'bp-'. $item->post_excerpt .'-nav' ), $item->classes ) ) {
2530
+ $item->classes[] = 'bp-menu';
2531
+ $item->classes[] = 'bp-'. $item->post_excerpt .'-nav';
2532
+ }
2533
+
2534
+ // Menu item hidden fields
2535
+ $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
2536
+ $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
2537
+ $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />';
2538
+ $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="custom" />';
2539
+ $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
2540
+ $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
2541
+ $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
2542
+ $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
2543
+ $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />';
2544
+ $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
2545
+ }
2546
+ }
2547
+
2548
+ /**
2549
+ * Base class for the BuddyPress Suggestions API.
2550
+ *
2551
+ * Originally built to power BuddyPress' at-mentions suggestions, it's flexible enough to be used
2552
+ * for similar kinds of future core requirements, or those desired by third-party developers.
2553
+ *
2554
+ * To implement a new suggestions service, create a new class that extends this one, and update
2555
+ * the list of default services in {@link bp_core_get_suggestions()}. If you're building a plugin,
2556
+ * it's recommend that you use the `bp_suggestions_services` filter to do this. :)
2557
+ *
2558
+ * While the implementation of the query logic is left to you, it should be as quick and efficient
2559
+ * as possible. When implementing the abstract methods in this class, pay close attention to the
2560
+ * recommendations provided in the phpDoc blocks, particularly the expected return types.
2561
+ *
2562
+ * @since BuddyPress (2.1.0)
2563
+ */
2564
+ abstract class BP_Suggestions {
2565
+
2566
+ /**
2567
+ * Default arguments common to all suggestions services.
2568
+ *
2569
+ * If your custom service requires further defaults, add them here.
2570
+ *
2571
+ * @since BuddyPress (2.1.0)
2572
+ * @var array
2573
+ */
2574
+ protected $default_args = array(
2575
+ 'limit' => 16,
2576
+ 'term' => '',
2577
+ 'type' => '',
2578
+ );
2579
+
2580
+ /**
2581
+ * Holds the arguments for the query (about to made to the suggestions service).
2582
+ *
2583
+ * This includes `$default_args`, as well as the user-supplied values.
2584
+ *
2585
+ * @since BuddyPress (2.1.0)
2586
+ * @var array
2587
+ */
2588
+ protected $args = array(
2589
+ );
2590
+
2591
+
2592
+ /**
2593
+ * Constructor.
2594
+ *
2595
+ * @param array $args Optional. If set, used as the parameters for the suggestions service query.
2596
+ * @since BuddyPress (2.1.0)
2597
+ */
2598
+ public function __construct( array $args = array() ) {
2599
+ if ( ! empty( $args ) ) {
2600
+ $this->set_query( $args );
2601
+ }
2602
+ }
2603
+
2604
+ /**
2605
+ * Set the parameters for the suggestions service query.
2606
+ *
2607
+ * @param array $args {
2608
+ * @type int $limit Maximum number of results to display. Optional, default: 16.
2609
+ * @type string $type The name of the suggestion service to use for the request. Mandatory.
2610
+ * @type string $term The suggestion service will try to find results that contain this string.
2611
+ * Mandatory.
2612
+ * }
2613
+ * @since BuddyPress (2.1.0)
2614
+ */
2615
+ public function set_query( array $args = array() ) {
2616
+ $this->args = wp_parse_args( $args, $this->default_args );
2617
+ }
2618
+
2619
+ /**
2620
+ * Validate and sanitise the parameters for the suggestion service query.
2621
+ *
2622
+ * Be sure to call this class' version of this method when implementing it in your own service.
2623
+ * If validation fails, you must return a WP_Error object.
2624
+ *
2625
+ * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
2626
+ * @since BuddyPress (2.1.0)
2627
+ */
2628
+ public function validate() {
2629
+ $this->args['limit'] = absint( $this->args['limit'] );
2630
+ $this->args['term'] = trim( sanitize_text_field( $this->args['term'] ) );
2631
+ $this->args = apply_filters( 'bp_suggestions_args', $this->args, $this );
2632
+
2633
+
2634
+ // Check for invalid or missing mandatory parameters.
2635
+ if ( ! $this->args['limit'] || ! $this->args['term'] ) {
2636
+ return new WP_Error( 'missing_parameter' );
2637
+ }
2638
+
2639
+ // Check for blocked users (e.g. deleted accounts, or spammers).
2640
+ if ( is_user_logged_in() && ! bp_is_user_active( get_current_user_id() ) ) {
2641
+ return new WP_Error( 'invalid_user' );
2642
+ }
2643
+
2644
+ return apply_filters( 'bp_suggestions_validate_args', true, $this );
2645
+ }
2646
+
2647
+ /**
2648
+ * Find and return a list of suggestions that match the query.
2649
+ *
2650
+ * The return type is important. If no matches are found, an empty array must be returned.
2651
+ * Matches must be returned as objects in an array.
2652
+ *
2653
+ * The object format for each match must be: { 'ID': string, 'image': string, 'name': string }
2654
+ * For example: { 'ID': 'admin', 'image': 'http://example.com/logo.png', 'name': 'Name Surname' }
2655
+ *
2656
+ * @return array|WP_Error Array of results. If there were problems, returns a WP_Error object.
2657
+ * @since BuddyPress (2.1.0)
2658
+ */
2659
+ abstract public function get_suggestions();
2660
+ }
2661
+
2662
+ /**
2663
+ * Adds support for user at-mentions to the Suggestions API.
2664
+ *
2665
+ * This class is in the Core component because it's required by a class in the Groups component,
2666
+ * and Groups is loaded before Members (alphabetical order).
2667
+ *
2668
+ * @since BuddyPress (2.1.0)
2669
+ */
2670
+ class BP_Members_Suggestions extends BP_Suggestions {
2671
+
2672
+ /**
2673
+ * Default arguments for this suggestions service.
2674
+ *
2675
+ * @since BuddyPress (2.1.0)
2676
+ * @var array $args {
2677
+ * @type int $limit Maximum number of results to display. Default: 16.
2678
+ * @type bool $only_friends If true, only match the current user's friends. Default: false.
2679
+ * @type string $term The suggestion service will try to find results that contain this string.
2680
+ * Mandatory.
2681
+ * }
2682
+ */
2683
+ protected $default_args = array(
2684
+ 'limit' => 10,
2685
+ 'only_friends' => false,
2686
+ 'term' => '',
2687
+ 'type' => '',
2688
+ );
2689
+
2690
+
2691
+ /**
2692
+ * Validate and sanitise the parameters for the suggestion service query.
2693
+ *
2694
+ * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
2695
+ * @since BuddyPress (2.1.0)
2696
+ */
2697
+ public function validate() {
2698
+ $this->args['only_friends'] = (bool) $this->args['only_friends'];
2699
+ $this->args = apply_filters( 'bp_members_suggestions_args', $this->args, $this );
2700
+
2701
+ // Check for invalid or missing mandatory parameters.
2702
+ if ( $this->args['only_friends'] && ( ! bp_is_active( 'friends' ) || ! is_user_logged_in() ) ) {
2703
+ return new WP_Error( 'missing_requirement' );
2704
+ }
2705
+
2706
+ return apply_filters( 'bp_members_suggestions_validate_args', parent::validate(), $this );
2707
+ }
2708
+
2709
+ /**
2710
+ * Find and return a list of username suggestions that match the query.
2711
+ *
2712
+ * @return array|WP_Error Array of results. If there were problems, returns a WP_Error object.
2713
+ * @since BuddyPress (2.1.0)
2714
+ */
2715
+ public function get_suggestions() {
2716
+ $user_query = array(
2717
+ 'count_total' => '', // Prevents total count
2718
+ 'populate_extras' => false,
2719
+ 'type' => 'alphabetical',
2720
+
2721
+ 'page' => 1,
2722
+ 'per_page' => $this->args['limit'],
2723
+ 'search_terms' => $this->args['term'],
2724
+ 'search_wildcard' => 'right',
2725
+ );
2726
+
2727
+ // Only return matches of friends of this user.
2728
+ if ( $this->args['only_friends'] && is_user_logged_in() ) {
2729
+ $user_query['user_id'] = get_current_user_id();
2730
+ }
2731
+
2732
+ $user_query = apply_filters( 'bp_members_suggestions_query_args', $user_query, $this );
2733
+ if ( is_wp_error( $user_query ) ) {
2734
+ return $user_query;
2735
+ }
2736
+
2737
+
2738
+ $user_query = new BP_User_Query( $user_query );
2739
+ $results = array();
2740
+
2741
+ foreach ( $user_query->results as $user ) {
2742
+ $result = new stdClass();
2743
+ $result->ID = $user->user_nicename;
2744
+ $result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) );
2745
+ $result->name = bp_core_get_user_displayname( $user->ID );
2746
+
2747
+ $results[] = $result;
2748
+ }
2749
+
2750
+ return apply_filters( 'bp_members_suggestions_get_suggestions', $results, $this );
2751
+ }
2752
+ }
2753
+
2754
+ /**
2755
+ * Base class for creating query classes that generate SQL fragments for filtering results based on recursive query params.
2756
+ *
2757
+ * @since BuddyPress (2.2.0)
2758
+ */
2759
+ abstract class BP_Recursive_Query {
2760
+
2761
+ /**
2762
+ * Query arguments passed to the constructor.
2763
+ *
2764
+ * @since BuddyPress (2.2.0)
2765
+ * @access public
2766
+ * @var array
2767
+ */
2768
+ public $queries = array();
2769
+
2770
+ /**
2771
+ * Generate SQL clauses to be appended to a main query.
2772
+ *
2773
+ * Extending classes should call this method from within a publicly
2774
+ * accessible get_sql() method, and manipulate the SQL as necessary.
2775
+ * For example, {@link BP_XProfile_Query::get_sql()} is merely a wrapper for
2776
+ * get_sql_clauses(), while {@link BP_Activity_Query::get_sql()} discards
2777
+ * the empty 'join' clause, and only passes the 'where' clause.
2778
+ *
2779
+ * @since BuddyPress (2.2.0)
2780
+ * @access protected
2781
+ *
2782
+ * @param string $primary_table
2783
+ * @param string $primary_id_column
2784
+ * @return array
2785
+ */
2786
+ protected function get_sql_clauses() {
2787
+ $sql = $this->get_sql_for_query( $this->queries );
2788
+
2789
+ if ( ! empty( $sql['where'] ) ) {
2790
+ $sql['where'] = ' AND ' . "\n" . $sql['where'] . "\n";
2791
+ }
2792
+
2793
+ return $sql;
2794
+ }
2795
+
2796
+ /**
2797
+ * Generate SQL clauses for a single query array.
2798
+ *
2799
+ * If nested subqueries are found, this method recurses the tree to
2800
+ * produce the properly nested SQL.
2801
+ *
2802
+ * Subclasses generally do not need to call this method. It is invoked
2803
+ * automatically from get_sql_clauses().
2804
+ *
2805
+ * @since BuddyPress (2.2.0)
2806
+ * @access protected
2807
+ *
2808
+ * @param array $query Query to parse.
2809
+ * @param int $depth Optional. Number of tree levels deep we
2810
+ * currently are. Used to calculate indentation.
2811
+ * @return array
2812
+ */
2813
+ protected function get_sql_for_query( $query, $depth = 0 ) {
2814
+ $sql_chunks = array(
2815
+ 'join' => array(),
2816
+ 'where' => array(),
2817
+ );
2818
+
2819
+ $sql = array(
2820
+ 'join' => '',
2821
+ 'where' => '',
2822
+ );
2823
+
2824
+ $indent = '';
2825
+ for ( $i = 0; $i < $depth; $i++ ) {
2826
+ $indent .= "\t";
2827
+ }
2828
+
2829
+ foreach ( $query as $key => $clause ) {
2830
+ if ( 'relation' === $key ) {
2831
+ $relation = $query['relation'];
2832
+ } elseif ( is_array( $clause ) ) {
2833
+ // This is a first-order clause
2834
+ if ( $this->is_first_order_clause( $clause ) ) {
2835
+ $clause_sql = $this->get_sql_for_clause( $clause, $query );
2836
+
2837
+ $where_count = count( $clause_sql['where'] );
2838
+ if ( ! $where_count ) {
2839
+ $sql_chunks['where'][] = '';
2840
+ } elseif ( 1 === $where_count ) {
2841
+ $sql_chunks['where'][] = $clause_sql['where'][0];
2842
+ } else {
2843
+ $sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )';
2844
+ }
2845
+
2846
+ $sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] );
2847
+ // This is a subquery
2848
+ } else {
2849
+ $clause_sql = $this->get_sql_for_query( $clause, $depth + 1 );
2850
+
2851
+ $sql_chunks['where'][] = $clause_sql['where'];
2852
+ $sql_chunks['join'][] = $clause_sql['join'];
2853
+ }
2854
+ }
2855
+ }
2856
+
2857
+ // Filter empties
2858
+ $sql_chunks['join'] = array_filter( $sql_chunks['join'] );
2859
+ $sql_chunks['where'] = array_filter( $sql_chunks['where'] );
2860
+
2861
+ if ( empty( $relation ) ) {
2862
+ $relation = 'AND';
2863
+ }
2864
+
2865
+ if ( ! empty( $sql_chunks['join'] ) ) {
2866
+ $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) );
2867
+ }
2868
+
2869
+ if ( ! empty( $sql_chunks['where'] ) ) {
2870
+ $sql['where'] = '( ' . "\n\t" . $indent . implode( ' ' . "\n\t" . $indent . $relation . ' ' . "\n\t" . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')' . "\n";
2871
+ }
2872
+
2873
+ return $sql;
2874
+ }
2875
+
2876
+ /**
2877
+ * Recursive-friendly query sanitizer.
2878
+ *
2879
+ * Ensures that each query-level clause has a 'relation' key, and that
2880
+ * each first-order clause contains all the necessary keys from
2881
+ * $defaults.
2882
+ *
2883
+ * Extend this method if your class uses different sanitizing logic.
2884
+ *
2885
+ * @since BuddyPress (2.2.0)
2886
+ * @access public
2887
+ *
2888
+ * @param array $queries Array of query clauses.
2889
+ * @return array Sanitized array of query clauses.
2890
+ */
2891
+ protected function sanitize_query( $queries ) {
2892
+ $clean_queries = array();
2893
+
2894
+ if ( ! is_array( $queries ) ) {
2895
+ return $clean_queries;
2896
+ }
2897
+
2898
+ foreach ( $queries as $key => $query ) {
2899
+ if ( 'relation' === $key ) {
2900
+ $relation = $query;
2901
+
2902
+ } elseif ( ! is_array( $query ) ) {
2903
+ continue;
2904
+
2905
+ // First-order clause.
2906
+ } elseif ( $this->is_first_order_clause( $query ) ) {
2907
+ if ( isset( $query['value'] ) && array() === $query['value'] ) {
2908
+ unset( $query['value'] );
2909
+ }
2910
+
2911
+ $clean_queries[] = $query;
2912
+
2913
+ // Otherwise, it's a nested query, so we recurse.
2914
+ } else {
2915
+ $cleaned_query = $this->sanitize_query( $query );
2916
+
2917
+ if ( ! empty( $cleaned_query ) ) {
2918
+ $clean_queries[] = $cleaned_query;
2919
+ }
2920
+ }
2921
+ }
2922
+
2923
+ if ( empty( $clean_queries ) ) {
2924
+ return $clean_queries;
2925
+ }
2926
+
2927
+ // Sanitize the 'relation' key provided in the query.
2928
+ if ( isset( $relation ) && 'OR' === strtoupper( $relation ) ) {
2929
+ $clean_queries['relation'] = 'OR';
2930
+
2931
+ /*
2932
+ * If there is only a single clause, call the relation 'OR'.
2933
+ * This value will not actually be used to join clauses, but it
2934
+ * simplifies the logic around combining key-only queries.
2935
+ */
2936
+ } elseif ( 1 === count( $clean_queries ) ) {
2937
+ $clean_queries['relation'] = 'OR';
2938
+
2939
+ // Default to AND.
2940
+ } else {
2941
+ $clean_queries['relation'] = 'AND';
2942
+ }
2943
+
2944
+ return $clean_queries;
2945
+ }
2946
+
2947
+ /**
2948
+ * Generate JOIN and WHERE clauses for a first-order clause.
2949
+ *
2950
+ * Must be overridden in a subclass.
2951
+ *
2952
+ * @since BuddyPress (2.2.0)
2953
+ * @access protected
2954
+ *
2955
+ * @param array $clause Array of arguments belonging to the clause.
2956
+ * @param array $parent_query Parent query to which the clause belongs.
2957
+ * @return array {
2958
+ * @type array $join Array of subclauses for the JOIN statement.
2959
+ * @type array $where Array of subclauses for the WHERE statement.
2960
+ * }
2961
+ */
2962
+ abstract protected function get_sql_for_clause( $clause, $parent_query );
2963
+
2964
+ /**
2965
+ * Determine whether a clause is first-order.
2966
+ *
2967
+ * Must be overridden in a subclass.
2968
+ *
2969
+ * @since BuddyPress (2.2.0)
2970
+ * @access protected
2971
+ *
2972
+ * @param array $q Clause to check.
2973
+ * @return bool
2974
+ */
2975
+ abstract protected function is_first_order_clause( $query );
2976
+ }
bp-core/bp-core-component.php CHANGED
@@ -131,21 +131,19 @@ class BP_Component {
131
  * Component loader.
132
  *
133
  * @since BuddyPress (1.5.0)
134
- * @since BuddyPress (1.9.0) Added $params as a parameter.
135
- * @since BuddyPress (2.3.0) Added $params['features'] as a configurable value.
136
- *
137
- * @param string $id Unique ID. Letters, numbers, and underscores only.
138
- * @param string $name Unique name. This should be a translatable name, eg.
139
- * __( 'Groups', 'buddypress' ).
140
- * @param string $path The file path for the component's files. Used by {@link BP_Component::includes()}.
141
- * @param array $params {
142
- * Additional parameters used by the component.
143
- * @type int $adminbar_myaccount_order Set the position for our menu under the WP Toolbar's "My Account menu"
144
- * @type array $features An array of feature names. This is used to load additional files from your
145
- * component directory and for feature active checks. eg. array( 'awesome' )
146
- * would look for a file called "bp-{$this->id}-awesome.php" and you could use
147
- * bp_is_active( $this->id, 'awesome' ) to determine if the feature is active.
148
- * }
149
  */
150
  public function start( $id = '', $name = '', $path = '', $params = array() ) {
151
 
@@ -165,11 +163,6 @@ class BP_Component {
165
  $this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order'];
166
  }
167
 
168
- // Register features
169
- if ( ! empty( $params['features'] ) ) {
170
- $this->features = array_map( 'sanitize_title', (array) $params['features'] );
171
- }
172
-
173
  // Set defaults if not passed
174
  } else {
175
  // new component menus are added before the settings menu if not set
@@ -190,18 +183,24 @@ class BP_Component {
190
  *
191
  * @param array $args {
192
  * All values are optional.
193
- * @type string $slug The component slug. Used to construct certain URLs, such as 'friends' in
194
- * http://example.com/members/joe/friends/. Default: the value of $this->id.
195
- * @type string $root_slug The component root slug. Note that this value is generally unused if the
196
- * component has a root directory (the slug will be overridden by the
197
- * post_name of the directory page). Default: the slug of the directory page
198
- * if one is found, otherwise an empty string.
199
- * @type bool $has_directory Set to true if the component requires an associated WordPress page.
200
- * @type callable $notification_callback Optional. The callable function that formats the component's notifications.
201
- * @type string $search_term Optional. The placeholder text in the component directory search box. Eg,
202
- * 'Search Groups...'.
203
- * @type array $global_tables Optional. An array of database table names.
204
- * @type array $meta_tables Optional. An array of metadata table names.
 
 
 
 
 
 
205
  * }
206
  */
207
  public function setup_globals( $args = array() ) {
@@ -223,58 +222,22 @@ class BP_Component {
223
  'meta_tables' => '',
224
  ) );
225
 
226
- /**
227
- * Filters the slug to be used for the permalink URI chunk after root.
228
- *
229
- * @since BuddyPress (1.5.0)
230
- *
231
- * @param string $value Slug to use in permalink URI chunk.
232
- */
233
  $this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] );
234
 
235
- /**
236
- * Filters the slug used for root directory.
237
- *
238
- * @since BuddyPress (1.5.0)
239
- *
240
- * @param string $value Root directory slug.
241
- */
242
  $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] );
243
 
244
- /**
245
- * Filters the component's top-level directory if available.
246
- *
247
- * @since BuddyPress (1.5.0)
248
- *
249
- * @param bool $value Whether or not there is a top-level directory.
250
- */
251
  $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] );
252
 
253
- /**
254
- * Filters the component's directory title.
255
- *
256
- * @since BuddyPress (2.0.0)
257
- *
258
- * @param string $value Title to use for the directory.
259
- */
260
  $this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] );
261
 
262
- /**
263
- * Filters the placeholder text for search inputs for component.
264
- *
265
- * @since BuddyPress (1.5.0)
266
- *
267
- * @param string $value Name to use in search input placeholders.
268
- */
269
  $this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] );
270
 
271
- /**
272
- * Filters the callable function that formats the component's notifications.
273
- *
274
- * @since BuddyPress (1.5.0)
275
- *
276
- * @param string $value Function callback.
277
- */
278
  $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
279
 
280
  // Set the global table names, if applicable
@@ -292,13 +255,7 @@ class BP_Component {
292
  // Register this component in the loaded components array
293
  buddypress()->loaded_components[$this->slug] = $this->id;
294
 
295
- /**
296
- * Fires at the end of the setup_globals method inside BP_Component.
297
- *
298
- * This is a dynamic hook that is based on the component string ID.
299
- *
300
- * @since BuddyPress (1.5.0)
301
- */
302
  do_action( 'bp_' . $this->id . '_setup_globals' );
303
  }
304
 
@@ -363,13 +320,7 @@ class BP_Component {
363
  }
364
  }
365
 
366
- /**
367
- * Fires at the end of the includes method inside BP_Component.
368
- *
369
- * This is a dynamic hook that is based on the component string ID.
370
- *
371
- * @since BuddyPress (1.5.0)
372
- */
373
  do_action( 'bp_' . $this->id . '_includes' );
374
  }
375
 
@@ -429,13 +380,7 @@ class BP_Component {
429
  // Generate rewrite rules
430
  add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
431
 
432
- /**
433
- * Fires at the end of the setup_actions method inside BP_Component.
434
- *
435
- * This is a dynamic hook that is based on the component string ID.
436
- *
437
- * @since BuddyPress (1.5.0)
438
- */
439
  do_action( 'bp_' . $this->id . '_setup_actions' );
440
  }
441
 
@@ -474,13 +419,7 @@ class BP_Component {
474
  }
475
  }
476
 
477
- /**
478
- * Fires at the end of the setup_nav method inside BP_Component.
479
- *
480
- * This is a dynamic hook that is based on the component string ID.
481
- *
482
- * @since BuddyPress (1.5.0)
483
- */
484
  do_action( 'bp_' . $this->id . '_setup_nav' );
485
  }
486
 
@@ -508,15 +447,7 @@ class BP_Component {
508
  return;
509
  }
510
 
511
- /**
512
- * Filters the admin navigation passed into setup_admin_bar.
513
- *
514
- * This is a dynamic hook that is based on the component string ID.
515
- *
516
- * @since BuddyPress (1.9.0)
517
- *
518
- * @param array $wp_admin_nav Array of navigation items to add.
519
- */
520
  $wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
521
 
522
  // Do we have Toolbar menus to add?
@@ -534,13 +465,7 @@ class BP_Component {
534
  }
535
  }
536
 
537
- /**
538
- * Fires at the end of the setup_admin_bar method inside BP_Component.
539
- *
540
- * This is a dynamic hook that is based on the component string ID.
541
- *
542
- * @since BuddyPress (1.5.0)
543
- */
544
  do_action( 'bp_' . $this->id . '_setup_admin_bar' );
545
  }
546
 
@@ -552,14 +477,6 @@ class BP_Component {
552
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_setup_title'.
553
  */
554
  public function setup_title() {
555
-
556
- /**
557
- * Fires in the setup_title method inside BP_Component.
558
- *
559
- * This is a dynamic hook that is based on the component string ID.
560
- *
561
- * @since BuddyPress (1.5.0)
562
- */
563
  do_action( 'bp_' . $this->id . '_setup_title' );
564
  }
565
 
@@ -571,14 +488,6 @@ class BP_Component {
571
  * @uses do_action() Calls 'bp_setup_{@link bp_Component::name}_cache_groups'.
572
  */
573
  public function setup_cache_groups() {
574
-
575
- /**
576
- * Fires in the setup_cache_groups method inside BP_Component.
577
- *
578
- * This is a dynamic hook that is based on the component string ID.
579
- *
580
- * @since BuddyPress (2.2.0)
581
- */
582
  do_action( 'bp_' . $this->id . '_setup_cache_groups' );
583
  }
584
 
@@ -591,15 +500,8 @@ class BP_Component {
591
  */
592
  public function register_global_tables( $tables = array() ) {
593
 
594
- /**
595
- * Filters the global tables for the component, so that it may use WordPress' database API.
596
- *
597
- * This is a dynamic hook that is based on the component string ID.
598
- * It allows for component-specific filtering of table names. To filter
599
- * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
600
- *
601
- * @since BuddyPress (1.6.0)
602
- */
603
  $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
604
 
605
  // Add to the BuddyPress global object
@@ -612,13 +514,6 @@ class BP_Component {
612
  $this->global_tables = $tables;
613
  }
614
 
615
- /**
616
- * Fires at the end of the register_global_tables method inside BP_Component.
617
- *
618
- * This is a dynamic hook that is based on the component string ID.
619
- *
620
- * @since BuddyPress (2.0.0)
621
- */
622
  do_action( 'bp_' . $this->id . '_register_global_tables' );
623
  }
624
 
@@ -635,15 +530,8 @@ class BP_Component {
635
  public function register_meta_tables( $tables = array() ) {
636
  global $wpdb;
637
 
638
- /**
639
- * Filters the global meta_tables for the component.
640
- *
641
- * This is a dynamic hook that is based on the component string ID.
642
- * It allows for component-specific filtering of table names. To filter
643
- * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
644
- *
645
- * @since BuddyPress (2.0.0)
646
- */
647
  $tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables );
648
 
649
  /**
@@ -659,13 +547,6 @@ class BP_Component {
659
  $this->meta_tables = $tables;
660
  }
661
 
662
- /**
663
- * Fires at the end of the register_meta_tables method inside BP_Component.
664
- *
665
- * This is a dynamic hook that is based on the component string ID.
666
- *
667
- * @since BuddyPress (2.0.0)
668
- */
669
  do_action( 'bp_' . $this->id . '_register_meta_tables' );
670
  }
671
 
@@ -677,14 +558,6 @@ class BP_Component {
677
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_post_types'.
678
  */
679
  public function register_post_types() {
680
-
681
- /**
682
- * Fires in the register_post_types method inside BP_Component.
683
- *
684
- * This is a dynamic hook that is based on the component string ID.
685
- *
686
- * @since BuddyPress (1.5.0)
687
- */
688
  do_action( 'bp_' . $this->id . '_register_post_types' );
689
  }
690
 
@@ -696,14 +569,6 @@ class BP_Component {
696
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_taxonomies'.
697
  */
698
  public function register_taxonomies() {
699
-
700
- /**
701
- * Fires in the register_taxonomies method inside BP_Component.
702
- *
703
- * This is a dynamic hook that is based on the component string ID.
704
- *
705
- * @since BuddyPress (1.5.0)
706
- */
707
  do_action( 'bp_' . $this->id . '_register_taxonomies' );
708
  }
709
 
@@ -715,14 +580,6 @@ class BP_Component {
715
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_tags'.
716
  */
717
  public function add_rewrite_tags() {
718
-
719
- /**
720
- * Fires in the add_rewrite_tags method inside BP_Component.
721
- *
722
- * This is a dynamic hook that is based on the component string ID.
723
- *
724
- * @since BuddyPress (1.5.0)
725
- */
726
  do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
727
  }
728
 
@@ -734,14 +591,6 @@ class BP_Component {
734
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_rules'.
735
  */
736
  public function add_rewrite_rules() {
737
-
738
- /**
739
- * Fires in the add_rewrite_rules method inside BP_Component.
740
- *
741
- * This is a dynamic hook that is based on the component string ID.
742
- *
743
- * @since BuddyPress (1.9.0)
744
- */
745
  do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
746
  }
747
 
@@ -753,14 +602,6 @@ class BP_Component {
753
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_permastruct'
754
  */
755
  public function add_permastructs() {
756
-
757
- /**
758
- * Fires in the add_permastructs method inside BP_Component.
759
- *
760
- * This is a dynamic hook that is based on the component string ID.
761
- *
762
- * @since BuddyPress (1.9.0)
763
- */
764
  do_action( 'bp_' . $this->id . '_add_permastructs' );
765
  }
766
 
@@ -773,16 +614,6 @@ class BP_Component {
773
  * @param object The main WP_Query
774
  */
775
  public function parse_query( $query ) {
776
-
777
- /**
778
- * Fires in the parse_query method inside BP_Component.
779
- *
780
- * This is a dynamic hook that is based on the component string ID.
781
- *
782
- * @since BuddyPress (1.9.0)
783
- *
784
- * @param object $query Main WP_Query object. Passed by reference.
785
- */
786
  do_action_ref_array( 'bp_' . $this->id . '_parse_query', array( &$query ) );
787
  }
788
 
@@ -794,14 +625,6 @@ class BP_Component {
794
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_generate_rewrite_rules'
795
  */
796
  public function generate_rewrite_rules() {
797
-
798
- /**
799
- * Fires in the generate_rewrite_rules method inside BP_Component.
800
- *
801
- * This is a dynamic hook that is based on the component string ID.
802
- *
803
- * @since BuddyPress (1.5.0)
804
- */
805
  do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
806
  }
807
  }
131
  * Component loader.
132
  *
133
  * @since BuddyPress (1.5.0)
134
+ *
135
+ * @uses BP_Component::setup_actions() Set up the hooks and actions.
136
+ *
137
+ * @param string $id Unique ID (for internal identification). Letters,
138
+ * numbers, and underscores only.
139
+ * @param string $name Unique name. This should be a translatable name,
140
+ * eg __( 'Groups', 'buddypress' ).
141
+ * @param string $path The file path for the component's files. Used by
142
+ * {@link BP_Component::includes()}.
143
+ * @param array $params Additional parameters used by the component.
144
+ * The config array supports the following values:
145
+ * - 'adminbar_myaccount_order' Sets the position for our
146
+ * component menu under the WP Toolbar's "My Account" menu.
 
 
147
  */
148
  public function start( $id = '', $name = '', $path = '', $params = array() ) {
149
 
163
  $this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order'];
164
  }
165
 
 
 
 
 
 
166
  // Set defaults if not passed
167
  } else {
168
  // new component menus are added before the settings menu if not set
183
  *
184
  * @param array $args {
185
  * All values are optional.
186
+ * @type string $slug The component slug. Used to construct certain
187
+ * URLs, such as 'friends' in http://example.com/members/joe/friends/
188
+ * Default: the value of $this->id.
189
+ * @type string $root_slug The component root slug. Note that this
190
+ * value is generally unused if the component has a root
191
+ * directory (the slug will be overridden by the post_name of
192
+ * the directory page). Default: the slug of the directory
193
+ * page if one is found, otherwise an empty string.
194
+ * @type bool $has_directory Set to true if the component requires
195
+ * an associated WordPress page.
196
+ * @type callable $notification_callback Optional. The callable
197
+ * function that formats the component's notifications.
198
+ * @type string $search_term Optional. The placeholder text in the
199
+ * component directory search box. Eg, 'Search Groups...'.
200
+ * @type array $global_tables Optional. An array of database table
201
+ * names.
202
+ * @type array $meta_tables Optional. An array of metadata table
203
+ * names.
204
  * }
205
  */
206
  public function setup_globals( $args = array() ) {
222
  'meta_tables' => '',
223
  ) );
224
 
225
+ // Slug used for permalink URI chunk after root
 
 
 
 
 
 
226
  $this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] );
227
 
228
+ // Slug used for root directory
 
 
 
 
 
 
229
  $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] );
230
 
231
+ // Does this component have a top-level directory?
 
 
 
 
 
 
232
  $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] );
233
 
234
+ // Does this component have a top-level directory?
 
 
 
 
 
 
235
  $this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] );
236
 
237
+ // Search string
 
 
 
 
 
 
238
  $this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] );
239
 
240
+ // Notifications callback
 
 
 
 
 
 
241
  $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
242
 
243
  // Set the global table names, if applicable
255
  // Register this component in the loaded components array
256
  buddypress()->loaded_components[$this->slug] = $this->id;
257
 
258
+ // Call action
 
 
 
 
 
 
259
  do_action( 'bp_' . $this->id . '_setup_globals' );
260
  }
261
 
320
  }
321
  }
322
 
323
+ // Call action
 
 
 
 
 
 
324
  do_action( 'bp_' . $this->id . '_includes' );
325
  }
326
 
380
  // Generate rewrite rules
381
  add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
382
 
383
+ // Additional actions can be attached here
 
 
 
 
 
 
384
  do_action( 'bp_' . $this->id . '_setup_actions' );
385
  }
386
 
419
  }
420
  }
421
 
422
+ // Call action
 
 
 
 
 
 
423
  do_action( 'bp_' . $this->id . '_setup_nav' );
424
  }
425
 
447
  return;
448
  }
449
 
450
+ // Filter the passed admin nav
 
 
 
 
 
 
 
 
451
  $wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
452
 
453
  // Do we have Toolbar menus to add?
465
  }
466
  }
467
 
468
+ // Call action
 
 
 
 
 
 
469
  do_action( 'bp_' . $this->id . '_setup_admin_bar' );
470
  }
471
 
477
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_setup_title'.
478
  */
479
  public function setup_title() {
 
 
 
 
 
 
 
 
480
  do_action( 'bp_' . $this->id . '_setup_title' );
481
  }
482
 
488
  * @uses do_action() Calls 'bp_setup_{@link bp_Component::name}_cache_groups'.
489
  */
490
  public function setup_cache_groups() {
 
 
 
 
 
 
 
 
491
  do_action( 'bp_' . $this->id . '_setup_cache_groups' );
492
  }
493
 
500
  */
501
  public function register_global_tables( $tables = array() ) {
502
 
503
+ // This filter allows for component-specific filtering of table names
504
+ // To filter *all* tables, use the 'bp_core_get_table_prefix' filter instead
 
 
 
 
 
 
 
505
  $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
506
 
507
  // Add to the BuddyPress global object
514
  $this->global_tables = $tables;
515
  }
516
 
 
 
 
 
 
 
 
517
  do_action( 'bp_' . $this->id . '_register_global_tables' );
518
  }
519
 
530
  public function register_meta_tables( $tables = array() ) {
531
  global $wpdb;
532
 
533
+ // This filter allows for component-specific filtering of table names
534
+ // To filter *all* tables, use the 'bp_core_get_table_prefix' filter instead
 
 
 
 
 
 
 
535
  $tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables );
536
 
537
  /**
547
  $this->meta_tables = $tables;
548
  }
549
 
 
 
 
 
 
 
 
550
  do_action( 'bp_' . $this->id . '_register_meta_tables' );
551
  }
552
 
558
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_post_types'.
559
  */
560
  public function register_post_types() {
 
 
 
 
 
 
 
 
561
  do_action( 'bp_' . $this->id . '_register_post_types' );
562
  }
563
 
569
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_taxonomies'.
570
  */
571
  public function register_taxonomies() {
 
 
 
 
 
 
 
 
572
  do_action( 'bp_' . $this->id . '_register_taxonomies' );
573
  }
574
 
580
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_tags'.
581
  */
582
  public function add_rewrite_tags() {
 
 
 
 
 
 
 
 
583
  do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
584
  }
585
 
591
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_rules'.
592
  */
593
  public function add_rewrite_rules() {
 
 
 
 
 
 
 
 
594
  do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
595
  }
596
 
602
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_permastruct'
603
  */
604
  public function add_permastructs() {
 
 
 
 
 
 
 
 
605
  do_action( 'bp_' . $this->id . '_add_permastructs' );
606
  }
607
 
614
  * @param object The main WP_Query
615
  */
616
  public function parse_query( $query ) {
 
 
 
 
 
 
 
 
 
 
617
  do_action_ref_array( 'bp_' . $this->id . '_parse_query', array( &$query ) );
618
  }
619
 
625
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_generate_rewrite_rules'
626
  */
627
  public function generate_rewrite_rules() {
 
 
 
 
 
 
 
 
628
  do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
629
  }
630
  }
bp-core/bp-core-cssjs.php CHANGED
@@ -17,37 +17,23 @@ defined( 'ABSPATH' ) || exit;
17
  function bp_core_register_common_scripts() {
18
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
19
  $url = buddypress()->plugin_url . 'bp-core/js/';
20
-
21
- /**
22
- * Filters the BuddyPress Core javascript files to register.
23
- *
24
- * @since BuddyPress (2.1.0)
25
- *
26
- * @param array $value Array of javascript file information to register.
27
- */
28
  $scripts = apply_filters( 'bp_core_register_common_scripts', array(
29
 
30
  // Legacy
31
- 'bp-confirm' => array( 'file' => "{$url}confirm{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
32
- 'bp-widget-members' => array( 'file' => "{$url}widget-members{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
33
- 'bp-jquery-query' => array( 'file' => "{$url}jquery-query{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
34
- 'bp-jquery-cookie' => array( 'file' => "{$url}jquery-cookie{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
35
- 'bp-jquery-scroll-to' => array( 'file' => "{$url}jquery-scroll-to{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
36
 
37
  // 2.1
38
- 'jquery-caret' => array( 'file' => "{$url}jquery.caret{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => true ),
39
- 'jquery-atwho' => array( 'file' => "{$url}jquery.atwho{$min}.js", 'dependencies' => array( 'jquery', 'jquery-caret' ), 'footer' => true ),
40
-
41
- // 2.3
42
- 'bp-plupload' => array( 'file' => "{$url}bp-plupload{$min}.js", 'dependencies' => array( 'plupload', 'jquery', 'json2', 'wp-backbone' ), 'footer' => true ),
43
- 'bp-avatar' => array( 'file' => "{$url}avatar{$min}.js", 'dependencies' => array( 'jcrop' ), 'footer' => true ),
44
- 'bp-webcam' => array( 'file' => "{$url}webcam{$min}.js", 'dependencies' => array( 'bp-avatar' ), 'footer' => true ),
45
-
46
  ) );
47
 
48
  $version = bp_get_version();
49
  foreach ( $scripts as $id => $script ) {
50
- wp_register_script( $id, $script['file'], $script['dependencies'], $version, $script['footer'] );
51
  }
52
  }
53
  add_action( 'bp_enqueue_scripts', 'bp_core_register_common_scripts', 1 );
@@ -62,31 +48,11 @@ function bp_core_register_common_styles() {
62
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
63
  $url = buddypress()->plugin_url . 'bp-core/css/';
64
 
65
- /**
66
- * Filters the URL for the Admin Bar stylesheet.
67
- *
68
- * @since BuddyPress (1.1.0)
69
- *
70
- * @param string $value URL for the Admin Bar stylesheet.
71
- */
72
- $admin_bar_file = apply_filters( 'bp_core_admin_bar_css', "{$url}admin-bar{$min}.css" );
73
-
74
- /**
75
- * Filters the BuddyPress Core stylesheet files to register.
76
- *
77
- * @since BuddyPress (2.1.0)
78
- *
79
- * @param array $value Array of stylesheet file information to register.
80
- */
81
  $styles = apply_filters( 'bp_core_register_common_styles', array(
82
  'bp-admin-bar' => array(
83
- 'file' => $admin_bar_file,
84
  'dependencies' => array( 'admin-bar' )
85
- ),
86
- 'bp-avatar' => array(
87
- 'file' => "{$url}avatar{$min}.css",
88
- 'dependencies' => array( 'jcrop' )
89
- ),
90
  ) );
91
 
92
  foreach ( $styles as $id => $style ) {
@@ -116,28 +82,8 @@ function bp_core_confirmation_js() {
116
  ) );
117
 
118
  }
119
- add_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' );
120
- add_action( 'bp_admin_enqueue_scripts', 'bp_core_confirmation_js' );
121
-
122
- /**
123
- * Enqueues the css and js required by the Avatar UI
124
- *
125
- * @since BuddyPress (2.3.0)
126
- */
127
- function bp_core_avatar_scripts() {
128
- if ( ! bp_avatar_is_front_edit() ) {
129
- return false;
130
- }
131
-
132
- // Enqueue the Attachments scripts for the Avatar UI
133
- bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' );
134
-
135
- // Add Some actions for Theme backcompat
136
- add_action( 'bp_after_profile_avatar_upload_content', 'bp_avatar_template_check' );
137
- add_action( 'bp_after_group_admin_content', 'bp_avatar_template_check' );
138
- add_action( 'bp_after_group_avatar_creation_step', 'bp_avatar_template_check' );
139
- }
140
- add_action( 'bp_enqueue_scripts', 'bp_core_avatar_scripts' );
141
 
142
  /**
143
  * Enqueues jCrop library and hooks BP's custom cropper JS.
@@ -154,13 +100,7 @@ function bp_core_add_jquery_cropper() {
154
  */
155
  function bp_core_add_cropper_inline_js() {
156
 
157
- /**
158
- * Filters the return value of getimagesize to determine if an image was uploaded.
159
- *
160
- * @since BuddyPress (1.1.0)
161
- *
162
- * @param array $value Array of data found by getimagesize.
163
- */
164
  $image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir ) );
165
  if ( empty( $image ) ) {
166
  return;
@@ -223,6 +163,7 @@ function bp_core_add_cropper_inline_js() {
223
  aspectRatio: <?php echo (int) $aspect_ratio; ?>,
224
  setSelect: [ <?php echo (int) $crop_left; ?>, <?php echo (int) $crop_top; ?>, <?php echo (int) $crop_right; ?>, <?php echo (int) $crop_bottom; ?> ]
225
  });
 
226
  });
227
 
228
  function updateCoords(c) {
@@ -299,35 +240,19 @@ add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
299
  * @return string AJAX endpoint URL.
300
  */
301
  function bp_core_ajax_url() {
302
-
303
- /**
304
- * Filters the proper value for BuddyPress' ajaxurl.
305
- *
306
- * @since BuddyPress (1.7.0)
307
- *
308
- * @param string $value Proper ajaxurl value for BuddyPress.
309
- */
310
  return apply_filters( 'bp_core_ajax_url', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
311
  }
312
 
313
  /**
314
- * Get the JavaScript dependencies for buddypress.js.
315
  *
316
  * @since BuddyPress (2.0.0)
317
  *
318
  * @uses apply_filters() to allow other component to load extra dependencies
319
  *
320
- * @return array The JavaScript dependencies.
321
  */
322
  function bp_core_get_js_dependencies() {
323
-
324
- /**
325
- * Filters the javascript dependencies for buddypress.js.
326
- *
327
- * @since BuddyPress (2.0.0)
328
- *
329
- * @param array $value Array of javascript dependencies for buddypress.js.
330
- */
331
  return apply_filters( 'bp_core_get_js_dependencies', array(
332
  'jquery',
333
  'bp-confirm',
17
  function bp_core_register_common_scripts() {
18
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
19
  $url = buddypress()->plugin_url . 'bp-core/js/';
20
+
 
 
 
 
 
 
 
21
  $scripts = apply_filters( 'bp_core_register_common_scripts', array(
22
 
23
  // Legacy
24
+ 'bp-confirm' => array( 'file' => "{$url}confirm{$min}.js", 'dependencies' => array( 'jquery' ) ),
25
+ 'bp-widget-members' => array( 'file' => "{$url}widget-members{$min}.js", 'dependencies' => array( 'jquery' ) ),
26
+ 'bp-jquery-query' => array( 'file' => "{$url}jquery-query{$min}.js", 'dependencies' => array( 'jquery' ) ),
27
+ 'bp-jquery-cookie' => array( 'file' => "{$url}jquery-cookie{$min}.js", 'dependencies' => array( 'jquery' ) ),
 
28
 
29
  // 2.1
30
+ 'jquery-caret' => array( 'file' => "{$url}jquery.caret{$min}.js", 'dependencies' => array( 'jquery' ) ),
31
+ 'jquery-atwho' => array( 'file' => "{$url}jquery.atwho{$min}.js", 'dependencies' => array( 'jquery', 'jquery-caret' ) ),
 
 
 
 
 
 
32
  ) );
33
 
34
  $version = bp_get_version();
35
  foreach ( $scripts as $id => $script ) {
36
+ wp_register_script( $id, $script['file'], $script['dependencies'], $version );
37
  }
38
  }
39
  add_action( 'bp_enqueue_scripts', 'bp_core_register_common_scripts', 1 );
48
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
49
  $url = buddypress()->plugin_url . 'bp-core/css/';
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  $styles = apply_filters( 'bp_core_register_common_styles', array(
52
  'bp-admin-bar' => array(
53
+ 'file' => apply_filters( 'bp_core_admin_bar_css', "{$url}admin-bar{$min}.css" ),
54
  'dependencies' => array( 'admin-bar' )
55
+ )
 
 
 
 
56
  ) );
57
 
58
  foreach ( $styles as $id => $style ) {
82
  ) );
83
 
84
  }
85
+ add_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' );
86
+ add_action( 'admin_enqueue_scripts', 'bp_core_confirmation_js' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  /**
89
  * Enqueues jCrop library and hooks BP's custom cropper JS.
100
  */
101
  function bp_core_add_cropper_inline_js() {
102
 
103
+ // Bail if no image was uploaded
 
 
 
 
 
 
104
  $image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir ) );
105
  if ( empty( $image ) ) {
106
  return;
163
  aspectRatio: <?php echo (int) $aspect_ratio; ?>,
164
  setSelect: [ <?php echo (int) $crop_left; ?>, <?php echo (int) $crop_top; ?>, <?php echo (int) $crop_right; ?>, <?php echo (int) $crop_bottom; ?> ]
165
  });
166
+ updateCoords({x: <?php echo (int) $crop_left; ?>, y: <?php echo (int) $crop_top; ?>, w: <?php echo (int) $crop_right; ?>, h: <?php echo (int) $crop_bottom; ?>});
167
  });
168
 
169
  function updateCoords(c) {
240
  * @return string AJAX endpoint URL.
241
  */
242
  function bp_core_ajax_url() {
 
 
 
 
 
 
 
 
243
  return apply_filters( 'bp_core_ajax_url', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
244
  }
245
 
246
  /**
247
+ * Get the javascript dependencies for buddypress.js.
248
  *
249
  * @since BuddyPress (2.0.0)
250
  *
251
  * @uses apply_filters() to allow other component to load extra dependencies
252
  *
253
+ * @return array The javascript dependencies.
254
  */
255
  function bp_core_get_js_dependencies() {
 
 
 
 
 
 
 
 
256
  return apply_filters( 'bp_core_get_js_dependencies', array(
257
  'jquery',
258
  'bp-confirm',
bp-core/bp-core-dependency.php CHANGED
@@ -21,12 +21,6 @@
21
  * Fire the 'bp_include' action, where plugins should include files.
22
  */
23
  function bp_include() {
24
-
25
- /**
26
- * Fires inside the 'bp_include' function, where plugins should include files.
27
- *
28
- * @since BuddyPress (1.2.5)
29
- */
30
  do_action( 'bp_include' );
31
  }
32
 
@@ -34,12 +28,6 @@ function bp_include() {
34
  * Fire the 'bp_setup_components' action, where plugins should initialize components.
35
  */
36
  function bp_setup_components() {
37
-
38
- /**
39
- * Fires inside the 'bp_setup_components' function, where plugins should initialize components.
40
- *
41
- * @since BuddyPress (1.6.0)
42
- */
43
  do_action( 'bp_setup_components' );
44
  }
45
 
@@ -47,12 +35,6 @@ function bp_setup_components() {
47
  * Fire the 'bp_setup_canonical_stack' action, where plugins should set up their canonical URL.
48
  */
49
  function bp_setup_canonical_stack() {
50
-
51
- /**
52
- * Fires inside the 'bp_setup_canonical_stack' function, where plugins should set up their canonical URL.
53
- *
54
- * @since BuddyPress (2.1.0)
55
- */
56
  do_action( 'bp_setup_canonical_stack' );
57
  }
58
 
@@ -62,12 +44,6 @@ function bp_setup_canonical_stack() {
62
  * @since BuddyPress (2.2.0)
63
  */
64
  function bp_register_taxonomies() {
65
-
66
- /**
67
- * Fires inside the 'bp_register_taxonomies' function, where plugins should register taxonomies.
68
- *
69
- * @since BuddyPress (2.2.0)
70
- */
71
  do_action( 'bp_register_taxonomies' );
72
  }
73
 
@@ -75,12 +51,6 @@ function bp_register_taxonomies() {
75
  * Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
76
  */
77
  function bp_setup_globals() {
78
-
79
- /**
80
- * Fires inside the 'bp_setup_globals' function, where plugins should initialize global settings.
81
- *
82
- * @since BuddyPress (1.2.0)
83
- */
84
  do_action( 'bp_setup_globals' );
85
  }
86
 
@@ -88,12 +58,6 @@ function bp_setup_globals() {
88
  * Fire the 'bp_setup_nav' action, where plugins should register their navigation items.
89
  */
90
  function bp_setup_nav() {
91
-
92
- /**
93
- * Fires inside the 'bp_setup_nav' function, where plugins should register their navigation items.
94
- *
95
- * @since BuddyPress (1.2.0)
96
- */
97
  do_action( 'bp_setup_nav' );
98
  }
99
 
@@ -101,29 +65,14 @@ function bp_setup_nav() {
101
  * Fire the 'bp_setup_admin_bar' action, where plugins should add items to the WP admin bar.
102
  */
103
  function bp_setup_admin_bar() {
104
- if ( bp_use_wp_admin_bar() ) {
105
-
106
- /**
107
- * Fires inside the 'bp_setup_admin_bar' function, where plugins should add items to the WP admin bar.
108
- *
109
- * This hook will only fire if bp_use_wp_admin_bar() returns true.
110
- *
111
- * @since BuddyPress (1.5.0)
112
- */
113
  do_action( 'bp_setup_admin_bar' );
114
- }
115
  }
116
 
117
  /**
118
  * Fire the 'bp_setup_title' action, where plugins should modify the page title.
119
  */
120
  function bp_setup_title() {
121
-
122
- /**
123
- * Fires inside the 'bp_setup_title' function, where plugins should modify the page title.
124
- *
125
- * @since BuddyPress (1.5.0)
126
- */
127
  do_action( 'bp_setup_title' );
128
  }
129
 
@@ -131,53 +80,21 @@ function bp_setup_title() {
131
  * Fire the 'bp_register_widgets' action, where plugins should register widgets.
132
  */
133
  function bp_setup_widgets() {
134
-
135
- /**
136
- * Fires inside the 'bp_register_widgets' function, where plugins should register widgets.
137
- *
138
- * @since BuddyPress (1.2.0)
139
- */
140
  do_action( 'bp_register_widgets' );
141
  }
142
 
143
- /**
144
- * Fire the 'bp_register_member_types' action, where plugins should register member types.
145
- *
146
- * @since BuddyPress (2.3.0)
147
- */
148
- function bp_register_member_types() {
149
-
150
- /**
151
- * Fires inside bp_register_member_types(), so plugins can register member types.
152
- *
153
- * @since BuddyPress (2.3.0)
154
- */
155
- do_action( 'bp_register_member_types' );
156
- }
157
-
158
  /**
159
  * Fire the 'bp_setup_cache_groups' action, where cache groups are registered.
160
  *
161
  * @since BuddyPress (2.2.0)
162
  */
163
  function bp_setup_cache_groups() {
164
-
165
- /**
166
- * Fires inside the 'bp_setup_cache_groups' function, where cache groups are registered.
167
- *
168
- * @since BuddyPress (2.2.0)
169
- */
170
  do_action( 'bp_setup_cache_groups' );
171
  }
172
 
173
  /**
174
  * Set up the currently logged-in user.
175
  *
176
- * We white-list the WordPress customizer which purposely loads the user early.
177
- *
178
- * @link https://buddypress.trac.wordpress.org/ticket/6046
179
- * @link https://core.trac.wordpress.org/ticket/24169
180
- *
181
  * @uses did_action() To make sure the user isn't loaded out of order.
182
  * @uses do_action() Calls 'bp_setup_current_user'.
183
  */
@@ -185,15 +102,10 @@ function bp_setup_current_user() {
185
 
186
  // If the current user is being setup before the "init" action has fired,
187
  // strange (and difficult to debug) role/capability issues will occur.
188
- if ( ! isset( $GLOBALS['wp_customize'] ) && ! did_action( 'after_setup_theme' ) ) {
189
  _doing_it_wrong( __FUNCTION__, __( 'The current user is being initialized without using $wp->init().', 'buddypress' ), '1.7' );
190
  }
191
 
192
- /**
193
- * Fires to set up the current user setup process.
194
- *
195
- * @since BuddyPress (1.7.0)
196
- */
197
  do_action( 'bp_setup_current_user' );
198
  }
199
 
@@ -201,12 +113,6 @@ function bp_setup_current_user() {
201
  * Fire the 'bp_init' action, BuddyPress's main initialization hook.
202
  */
203
  function bp_init() {
204
-
205
- /**
206
- * Fires inside the 'bp_init' function, BuddyPress' main initialization hook.
207
- *
208
- * @since BuddyPress (1.2.0)
209
- */
210
  do_action( 'bp_init' );
211
  }
212
 
@@ -216,12 +122,6 @@ function bp_init() {
216
  * Attached to 'plugins_loaded'.
217
  */
218
  function bp_loaded() {
219
-
220
- /**
221
- * Fires inside the 'bp_loaded' function, which fires after BP's core plugin files have been loaded.
222
- *
223
- * @since BuddyPress (1.2.5)
224
- */
225
  do_action( 'bp_loaded' );
226
  }
227
 
@@ -231,12 +131,6 @@ function bp_loaded() {
231
  * Attached to 'wp'.
232
  */
233
  function bp_ready() {
234
-
235
- /**
236
- * Fires inside the 'bp_ready' function, which runs after BP is set up and the page is about to render.
237
- *
238
- * @since BuddyPress (1.6.0)
239
- */
240
  do_action( 'bp_ready' );
241
  }
242
 
@@ -247,12 +141,6 @@ function bp_ready() {
247
  * custom URLs.
248
  */
249
  function bp_actions() {
250
-
251
- /**
252
- * Fires inside the 'bp_actions' function, which runs just before rendering.
253
- *
254
- * @since BuddyPress (1.5.0)
255
- */
256
  do_action( 'bp_actions' );
257
  }
258
 
@@ -263,14 +151,6 @@ function bp_actions() {
263
  * loaders.
264
  */
265
  function bp_screens() {
266
-
267
- /**
268
- * Fires inside the 'bp_screens' function, which runs just before rendering.
269
- *
270
- * Runs just after 'bp_actions'. Use this hook to attach your template loaders.
271
- *
272
- * @since BuddyPress (1.5.0)
273
- */
274
  do_action( 'bp_screens' );
275
  }
276
 
@@ -280,14 +160,6 @@ function bp_screens() {
280
  * Hooked to 'widgets_init'.
281
  */
282
  function bp_widgets_init() {
283
-
284
- /**
285
- * Fires inside the 'bp_widgets_init' function, which runs after widgets have been set up.
286
- *
287
- * Hooked to 'widgets_init'.
288
- *
289
- * @since BuddyPress (1.6.0)
290
- */
291
  do_action ( 'bp_widgets_init' );
292
  }
293
 
@@ -314,12 +186,6 @@ function bp_head() {
314
  * @uses do_action()
315
  */
316
  function bp_template_redirect() {
317
-
318
- /**
319
- * Fires inside the 'bp_template_redirect' function.
320
- *
321
- * @since BuddyPress (1.6.0)
322
- */
323
  do_action( 'bp_template_redirect' );
324
  }
325
 
@@ -335,14 +201,6 @@ function bp_template_redirect() {
335
  * @uses do_action()
336
  */
337
  function bp_register_theme_directory() {
338
-
339
- /**
340
- * Fires inside the 'bp_register_theme_directory' function.
341
- *
342
- * The main action used registering theme directories.
343
- *
344
- * @since BuddyPress (1.7.0)
345
- */
346
  do_action( 'bp_register_theme_directory' );
347
  }
348
 
@@ -356,12 +214,6 @@ function bp_register_theme_directory() {
356
  * @uses do_action()
357
  */
358
  function bp_register_theme_packages() {
359
-
360
- /**
361
- * Fires inside the 'bp_register_theme_packages' function.
362
- *
363
- * @since BuddyPress (1.7.0)
364
- */
365
  do_action( 'bp_register_theme_packages' );
366
  }
367
 
@@ -373,12 +225,6 @@ function bp_register_theme_packages() {
373
  * @uses do_action() Calls 'bp_enqueue_scripts'.
374
  */
375
  function bp_enqueue_scripts() {
376
-
377
- /**
378
- * Fires inside the 'bp_enqueue_scripts' function, where BP enqueues its CSS and JS.
379
- *
380
- * @since BuddyPress (1.6.0)
381
- */
382
  do_action ( 'bp_enqueue_scripts' );
383
  }
384
 
@@ -390,12 +236,6 @@ function bp_enqueue_scripts() {
390
  * @uses do_action() Calls 'bp_add_rewrite_tags'.
391
  */
392
  function bp_add_rewrite_tags() {
393
-
394
- /**
395
- * Fires inside the 'bp_add_rewrite_tags' function, where BP adds its custom rewrite tags.
396
- *
397
- * @since BuddyPress (1.8.0)
398
- */
399
  do_action( 'bp_add_rewrite_tags' );
400
  }
401
 
@@ -407,12 +247,6 @@ function bp_add_rewrite_tags() {
407
  * @uses do_action() Calls 'bp_add_rewrite_rules'.
408
  */
409
  function bp_add_rewrite_rules() {
410
-
411
- /**
412
- * Fires inside the 'bp_add_rewrite_rules' function, where BP adds its custom rewrite rules.
413
- *
414
- * @since BuddyPress (1.9.0)
415
- */
416
  do_action( 'bp_add_rewrite_rules' );
417
  }
418
 
@@ -424,12 +258,6 @@ function bp_add_rewrite_rules() {
424
  * @uses do_action() Calls 'bp_add_permastructs'.
425
  */
426
  function bp_add_permastructs() {
427
-
428
- /**
429
- * Fires inside the 'bp_add_permastructs' function, where BP adds its BP-specific permalink structure.
430
- *
431
- * @since BuddyPress (1.9.0)
432
- */
433
  do_action( 'bp_add_permastructs' );
434
  }
435
 
@@ -444,12 +272,6 @@ function bp_add_permastructs() {
444
  * @uses do_action() Calls 'bp_setup_theme'.
445
  */
446
  function bp_setup_theme() {
447
-
448
- /**
449
- * Fires inside the 'bp_setup_theme' function.
450
- *
451
- * @since BuddyPress (1.6.0)
452
- */
453
  do_action ( 'bp_setup_theme' );
454
  }
455
 
@@ -468,12 +290,6 @@ function bp_setup_theme() {
468
  * @uses do_action() Calls 'bp_after_setup_theme'.
469
  */
470
  function bp_after_setup_theme() {
471
-
472
- /**
473
- * Fires inside the 'bp_after_setup_theme' function.
474
- *
475
- * @since BuddyPress (1.7.0)
476
- */
477
  do_action ( 'bp_after_setup_theme' );
478
  }
479
 
@@ -490,14 +306,6 @@ function bp_after_setup_theme() {
490
  * @return array $query_vars See {@link WP::parse_request()}.
491
  */
492
  function bp_request( $query_vars = array() ) {
493
-
494
- /**
495
- * Filters the query_vars for the current request.
496
- *
497
- * @since BuddyPress (1.7.0)
498
- *
499
- * @param array $query_vars Array of query variables.
500
- */
501
  return apply_filters( 'bp_request', $query_vars );
502
  }
503
 
@@ -508,21 +316,9 @@ function bp_request( $query_vars = array() ) {
508
  *
509
  * @param string $redirect_to See 'login_redirect'.
510
  * @param string $redirect_to_raw See 'login_redirect'.
511
- * @param bool $user See 'login_redirect'.
512
- *
513
- * @return string
514
  */
515
  function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = false ) {
516
-
517
- /**
518
- * Filters the URL to redirect to after login.
519
- *
520
- * @since BuddyPress (1.7.0)
521
- *
522
- * @param string $redirect_to The redirect destination URL.
523
- * @param string $redirect_to_raw The requested redirect destination URL passed as a parameter.
524
- * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
525
- */
526
  return apply_filters( 'bp_login_redirect', $redirect_to, $redirect_to_raw, $user );
527
  }
528
 
@@ -539,19 +335,11 @@ function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = fa
539
  * @return string Template file to use.
540
  */
541
  function bp_template_include( $template = '' ) {
542
-
543
- /**
544
- * Filters the template to use with template_include.
545
- *
546
- * @since BuddyPress (1.6.0)
547
- *
548
- * @param string $template The path of the template to include.
549
- */
550
  return apply_filters( 'bp_template_include', $template );
551
  }
552
 
553
  /**
554
- * Fire the 'bp_generate_rewrite_rules' action, where BP generates its rewrite rules.
555
  *
556
  * @since BuddyPress (1.7.0)
557
  *
@@ -560,14 +348,6 @@ function bp_template_include( $template = '' ) {
560
  * @param WP_Rewrite $wp_rewrite See 'generate_rewrite_rules'.
561
  */
562
  function bp_generate_rewrite_rules( $wp_rewrite ) {
563
-
564
- /**
565
- * Fires inside the 'bp_generate_rewrite_rules' function.
566
- *
567
- * @since BuddyPress (1.7.0)
568
- *
569
- * @param WP_Rewrite $wp_rewrite WP_Rewrite object. Passed by reference.
570
- */
571
  do_action_ref_array( 'bp_generate_rewrite_rules', array( &$wp_rewrite ) );
572
  }
573
 
@@ -581,14 +361,6 @@ function bp_generate_rewrite_rules( $wp_rewrite ) {
581
  * @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list.
582
  */
583
  function bp_allowed_themes( $themes ) {
584
-
585
- /**
586
- * Filters the allowed themes list for BuddyPress-specific themes.
587
- *
588
- * @since BuddyPress (1.7.0)
589
- *
590
- * @param string $template The path of the template to include.
591
- */
592
  return apply_filters( 'bp_allowed_themes', $themes );
593
  }
594
 
@@ -615,25 +387,11 @@ function bp_post_request() {
615
  // Sanitize the POST action
616
  $action = sanitize_key( $_POST['action'] );
617
 
618
- /**
619
- * Fires at the end of the bp_post_request function.
620
- *
621
- * This dynamic action is probably the one you want to use. It narrows down
622
- * the scope of the 'action' without needing to check it in your function.
623
- *
624
- * @since BuddyPress (1.9.0)
625
- */
626
  do_action( 'bp_post_request_' . $action );
627
 
628
- /**
629
- * Fires at the end of the bp_post_request function.
630
- *
631
- * Use this static action if you don't mind checking the 'action' yourself.
632
- *
633
- * @since BuddyPress (1.9.0)
634
- *
635
- * @param string $action The action being run.
636
- */
637
  do_action( 'bp_post_request', $action );
638
  }
639
 
@@ -658,24 +416,10 @@ function bp_get_request() {
658
  // Sanitize the GET action
659
  $action = sanitize_key( $_GET['action'] );
660
 
661
- /**
662
- * Fires at the end of the bp_get_request function.
663
- *
664
- * This dynamic action is probably the one you want to use. It narrows down
665
- * the scope of the 'action' without needing to check it in your function.
666
- *
667
- * @since BuddyPress (1.9.0)
668
- */
669
  do_action( 'bp_get_request_' . $action );
670
 
671
- /**
672
- * Fires at the end of the bp_get_request function.
673
- *
674
- * Use this static action if you don't mind checking the 'action' yourself.
675
- *
676
- * @since BuddyPress (1.9.0)
677
- *
678
- * @param string $action The action being run.
679
- */
680
  do_action( 'bp_get_request', $action );
681
  }
21
  * Fire the 'bp_include' action, where plugins should include files.
22
  */
23
  function bp_include() {
 
 
 
 
 
 
24
  do_action( 'bp_include' );
25
  }
26
 
28
  * Fire the 'bp_setup_components' action, where plugins should initialize components.
29
  */
30
  function bp_setup_components() {
 
 
 
 
 
 
31
  do_action( 'bp_setup_components' );
32
  }
33
 
35
  * Fire the 'bp_setup_canonical_stack' action, where plugins should set up their canonical URL.
36
  */
37
  function bp_setup_canonical_stack() {
 
 
 
 
 
 
38
  do_action( 'bp_setup_canonical_stack' );
39
  }
40
 
44
  * @since BuddyPress (2.2.0)
45
  */
46
  function bp_register_taxonomies() {
 
 
 
 
 
 
47
  do_action( 'bp_register_taxonomies' );
48
  }
49
 
51
  * Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
52
  */
53
  function bp_setup_globals() {
 
 
 
 
 
 
54
  do_action( 'bp_setup_globals' );
55
  }
56
 
58
  * Fire the 'bp_setup_nav' action, where plugins should register their navigation items.
59
  */
60
  function bp_setup_nav() {
 
 
 
 
 
 
61
  do_action( 'bp_setup_nav' );
62
  }
63
 
65
  * Fire the 'bp_setup_admin_bar' action, where plugins should add items to the WP admin bar.
66
  */
67
  function bp_setup_admin_bar() {
68
+ if ( bp_use_wp_admin_bar() )
 
 
 
 
 
 
 
 
69
  do_action( 'bp_setup_admin_bar' );
 
70
  }
71
 
72
  /**
73
  * Fire the 'bp_setup_title' action, where plugins should modify the page title.
74
  */
75
  function bp_setup_title() {
 
 
 
 
 
 
76
  do_action( 'bp_setup_title' );
77
  }
78
 
80
  * Fire the 'bp_register_widgets' action, where plugins should register widgets.
81
  */
82
  function bp_setup_widgets() {
 
 
 
 
 
 
83
  do_action( 'bp_register_widgets' );
84
  }
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  /**
87
  * Fire the 'bp_setup_cache_groups' action, where cache groups are registered.
88
  *
89
  * @since BuddyPress (2.2.0)
90
  */
91
  function bp_setup_cache_groups() {
 
 
 
 
 
 
92
  do_action( 'bp_setup_cache_groups' );
93
  }
94
 
95
  /**
96
  * Set up the currently logged-in user.
97
  *
 
 
 
 
 
98
  * @uses did_action() To make sure the user isn't loaded out of order.
99
  * @uses do_action() Calls 'bp_setup_current_user'.
100
  */
102
 
103
  // If the current user is being setup before the "init" action has fired,
104
  // strange (and difficult to debug) role/capability issues will occur.
105
+ if ( ! did_action( 'after_setup_theme' ) ) {
106
  _doing_it_wrong( __FUNCTION__, __( 'The current user is being initialized without using $wp->init().', 'buddypress' ), '1.7' );
107
  }
108
 
 
 
 
 
 
109
  do_action( 'bp_setup_current_user' );
110
  }
111
 
113
  * Fire the 'bp_init' action, BuddyPress's main initialization hook.
114
  */
115
  function bp_init() {
 
 
 
 
 
 
116
  do_action( 'bp_init' );
117
  }
118
 
122
  * Attached to 'plugins_loaded'.
123
  */
124
  function bp_loaded() {
 
 
 
 
 
 
125
  do_action( 'bp_loaded' );
126
  }
127
 
131
  * Attached to 'wp'.
132
  */
133
  function bp_ready() {
 
 
 
 
 
 
134
  do_action( 'bp_ready' );
135
  }
136
 
141
  * custom URLs.
142
  */
143
  function bp_actions() {
 
 
 
 
 
 
144
  do_action( 'bp_actions' );
145
  }
146
 
151
  * loaders.
152
  */
153
  function bp_screens() {
 
 
 
 
 
 
 
 
154
  do_action( 'bp_screens' );
155
  }
156
 
160
  * Hooked to 'widgets_init'.
161
  */
162
  function bp_widgets_init() {
 
 
 
 
 
 
 
 
163
  do_action ( 'bp_widgets_init' );
164
  }
165
 
186
  * @uses do_action()
187
  */
188
  function bp_template_redirect() {
 
 
 
 
 
 
189
  do_action( 'bp_template_redirect' );
190
  }
191
 
201
  * @uses do_action()
202
  */
203
  function bp_register_theme_directory() {
 
 
 
 
 
 
 
 
204
  do_action( 'bp_register_theme_directory' );
205
  }
206
 
214
  * @uses do_action()
215
  */
216
  function bp_register_theme_packages() {
 
 
 
 
 
 
217
  do_action( 'bp_register_theme_packages' );
218
  }
219
 
225
  * @uses do_action() Calls 'bp_enqueue_scripts'.
226
  */
227
  function bp_enqueue_scripts() {
 
 
 
 
 
 
228
  do_action ( 'bp_enqueue_scripts' );
229
  }
230
 
236
  * @uses do_action() Calls 'bp_add_rewrite_tags'.
237
  */
238
  function bp_add_rewrite_tags() {
 
 
 
 
 
 
239
  do_action( 'bp_add_rewrite_tags' );
240
  }
241
 
247
  * @uses do_action() Calls 'bp_add_rewrite_rules'.
248
  */
249
  function bp_add_rewrite_rules() {
 
 
 
 
 
 
250
  do_action( 'bp_add_rewrite_rules' );
251
  }
252
 
258
  * @uses do_action() Calls 'bp_add_permastructs'.
259
  */
260
  function bp_add_permastructs() {
 
 
 
 
 
 
261
  do_action( 'bp_add_permastructs' );
262
  }
263
 
272
  * @uses do_action() Calls 'bp_setup_theme'.
273
  */
274
  function bp_setup_theme() {
 
 
 
 
 
 
275
  do_action ( 'bp_setup_theme' );
276
  }
277
 
290
  * @uses do_action() Calls 'bp_after_setup_theme'.
291
  */
292
  function bp_after_setup_theme() {
 
 
 
 
 
 
293
  do_action ( 'bp_after_setup_theme' );
294
  }
295
 
306
  * @return array $query_vars See {@link WP::parse_request()}.
307
  */
308
  function bp_request( $query_vars = array() ) {
 
 
 
 
 
 
 
 
309
  return apply_filters( 'bp_request', $query_vars );
310
  }
311
 
316
  *
317
  * @param string $redirect_to See 'login_redirect'.
318
  * @param string $redirect_to_raw See 'login_redirect'.
319
+ * @param string $user See 'login_redirect'.
 
 
320
  */
321
  function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = false ) {
 
 
 
 
 
 
 
 
 
 
322
  return apply_filters( 'bp_login_redirect', $redirect_to, $redirect_to_raw, $user );
323
  }
324
 
335
  * @return string Template file to use.
336
  */
337
  function bp_template_include( $template = '' ) {
 
 
 
 
 
 
 
 
338
  return apply_filters( 'bp_template_include', $template );
339
  }
340
 
341
  /**
342
+ * Fire the 'bp_generate_rewrite_rules' filter, where BP generates its rewrite rules.
343
  *
344
  * @since BuddyPress (1.7.0)
345
  *
348
  * @param WP_Rewrite $wp_rewrite See 'generate_rewrite_rules'.
349
  */
350
  function bp_generate_rewrite_rules( $wp_rewrite ) {
 
 
 
 
 
 
 
 
351
  do_action_ref_array( 'bp_generate_rewrite_rules', array( &$wp_rewrite ) );
352
  }
353
 
361
  * @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list.
362
  */
363
  function bp_allowed_themes( $themes ) {
 
 
 
 
 
 
 
 
364
  return apply_filters( 'bp_allowed_themes', $themes );
365
  }
366
 
387
  // Sanitize the POST action
388
  $action = sanitize_key( $_POST['action'] );
389
 
390
+ // This dynamic action is probably the one you want to use. It narrows down
391
+ // the scope of the 'action' without needing to check it in your function.
 
 
 
 
 
 
392
  do_action( 'bp_post_request_' . $action );
393
 
394
+ // Use this static action if you don't mind checking the 'action' yourself.
 
 
 
 
 
 
 
 
395
  do_action( 'bp_post_request', $action );
396
  }
397
 
416
  // Sanitize the GET action
417
  $action = sanitize_key( $_GET['action'] );
418
 
419
+ // This dynamic action is probably the one you want to use. It narrows down
420
+ // the scope of the 'action' without needing to check it in your function.
 
 
 
 
 
 
421
  do_action( 'bp_get_request_' . $action );
422
 
423
+ // Use this static action if you don't mind checking the 'action' yourself.
 
 
 
 
 
 
 
 
424
  do_action( 'bp_get_request', $action );
425
  }
bp-core/bp-core-filters.php CHANGED
@@ -94,13 +94,6 @@ function bp_core_exclude_pages( $pages = array() ) {
94
  if ( !empty( $bp->pages->forums ) && ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) ) )
95
  $pages[] = $bp->pages->forums->id;
96
 
97
- /**
98
- * Filters specific pages that shouldn't show up on page listings.
99
- *
100
- * @since BuddyPress (1.5.0)
101
- *
102
- * @param array $pages Array of pages to exclude.
103
- */
104
  return apply_filters( 'bp_core_exclude_pages', $pages );
105
  }
106
  add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
@@ -241,14 +234,6 @@ add_filter( 'nav_menu_css_class', 'bp_core_menu_highlight_nav_menu_item', 10, 2
241
  * @return string The blog name for the root blog.
242
  */
243
  function bp_core_email_from_name_filter() {
244
-
245
- /**
246
- * Filters the "From" name in outgoing email to the site name.
247
- *
248
- * @since BuddyPress (1.2.0)
249
- *
250
- * @param string $value Value to set the "From" name to.
251
- */
252
  return apply_filters( 'bp_core_email_from_name_filter', bp_get_option( 'blogname', 'WordPress' ) );
253
  }
254
  add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
@@ -315,19 +300,7 @@ function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
315
  return $redirect_to;
316
  }
317
 
318
- /**
319
- * Filters whether or not to redirect.
320
- *
321
- * Allows plugins to have finer grained control of redirect upon login.
322
- *
323
- * @since BuddyPress (1.6.0)
324
- *
325
- * @param bool $value Whether or not to redirect.
326
- * @param string $redirect_to Sanitized URL to be redirected to.
327
- * @param string $redirect_to_raw Unsanitized URL to be redirected to.
328
- * @param WP_User $user The WP_User object corresponding to a
329
- * successfully logged in user.
330
- */
331
  $maybe_redirect = apply_filters( 'bp_core_login_redirect', false, $redirect_to, $redirect_to_raw, $user );
332
  if ( false !== $maybe_redirect ) {
333
  return $maybe_redirect;
@@ -344,13 +317,6 @@ function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
344
  return wp_get_referer();
345
  }
346
 
347
- /**
348
- * Filters the URL to redirect users to upon successful login.
349
- *
350
- * @since BuddyPress (1.9.0)
351
- *
352
- * @param string $value URL to redirect to.
353
- */
354
  return apply_filters( 'bp_core_login_redirect_to', bp_get_root_domain() );
355
  }
356
  add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
@@ -448,52 +414,9 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
448
  $message = sprintf( __( "%1\$s,\n\n\n\nThanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%2\$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%3\$s", 'buddypress' ), $user, $activate_url, esc_url( "http://{$domain}{$path}" ) );
449
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
450
 
451
- /**
452
- * Filters the email that the notification is going to upon successful registration with blog.
453
- *
454
- * @since BuddyPress (1.2.0)
455
- *
456
- * @param string $user_email The user's email address.
457
- * @param string $domain The new blog domain.
458
- * @param string $path The new blog path.
459
- * @param string $title The site title.
460
- * @param string $user The user's login name.
461
- * @param string $user_email The user's email address.
462
- * @param string $key The activation key created in wpmu_signup_blog().
463
- * @param array $meta Array of meta values for the created site.
464
- */
465
  $to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email, $domain, $path, $title, $user, $user_email, $key, $meta );
466
-
467
- /**
468
- * Filters the subject that the notification uses upon successful registration with blog.
469
- *
470
- * @since BuddyPress (1.2.0)
471
- *
472
- * @param string $subject The subject to use.
473
- * @param string $domain The new blog domain.
474
- * @param string $path The new blog path.
475
- * @param string $title The site title.
476
- * @param string $user The user's login name.
477
- * @param string $user_email The user's email address.
478
- * @param string $key The activation key created in wpmu_signup_blog().
479
- * @param array $meta Array of meta values for the created site.
480
- */
481
  $subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject, $domain, $path, $title, $user, $user_email, $key, $meta );
482
-
483
- /**
484
- * Filters the message that the notification uses upon successful registration with blog.
485
- *
486
- * @since BuddyPress (1.2.0)
487
- *
488
- * @param string $message The message to use.
489
- * @param string $domain The new blog domain.
490
- * @param string $path The new blog path.
491
- * @param string $title The site title.
492
- * @param string $user The user's login name.
493
- * @param string $user_email The user's email address.
494
- * @param string $key The activation key created in wpmu_signup_blog().
495
- * @param array $meta Array of meta values for the created site.
496
- */
497
  $message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message, $domain, $path, $title, $user, $user_email, $key, $meta );
498
 
499
  // Send the email
@@ -502,22 +425,6 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
502
  // Set up the $admin_email to pass to the filter
503
  $admin_email = bp_get_option( 'admin_email' );
504
 
505
- /**
506
- * Fires after the sending of the notification to new users for successful registration with blog.
507
- *
508
- * @since BuddyPress (1.5.0)
509
- *
510
- * @param string $admin_email Admin Email address for the site.
511
- * @param string $subject Subject used in the notification email.
512
- * @param string $message Message used in the notification email.
513
- * @param string domain The new blog domain.
514
- * @param string $path The new blog path.
515
- * @param string $title The site title.
516
- * @param string $user The user's login name.
517
- * @param string $user_email The user's email address.
518
- * @param string $key The activation key created in wpmu_signup_blog().
519
- * @param array $meta Array of meta values for the created site.
520
- */
521
  do_action( 'bp_core_sent_blog_signup_email', $admin_email, $subject, $message, $domain, $path, $title, $user, $user_email, $key, $meta );
522
 
523
  // Return false to stop the original WPMU function from continuing
@@ -572,43 +479,9 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
572
  $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
573
  $subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
574
 
575
- /**
576
- * Filters the email that the notification is going to upon successful registration without blog.
577
- *
578
- * @since BuddyPress (1.2.0)
579
- *
580
- * @param string $user_email The user's email address.
581
- * @param string $user The user's login name.
582
- * @param string $user_email The user's email address.
583
- * @param string $key The activation key created in wpmu_signup_blog().
584
- * @param array $meta Array of meta values for the created site.
585
- */
586
  $to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta );
587
-
588
- /**
589
- * Filters the subject that the notification uses upon successful registration without blog.
590
- *
591
- * @since BuddyPress (1.2.0)
592
- *
593
- * @param string $subject The subject to use.
594
- * @param string $user The user's login name.
595
- * @param string $user_email The user's email address.
596
- * @param string $key The activation key created in wpmu_signup_blog().
597
- * @param array $meta Array of meta values for the created site.
598
- */
599
  $subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta );
600
-
601
- /**
602
- * Filters the message that the notification uses upon successful registration without blog.
603
- *
604
- * @since BuddyPress (1.2.0)
605
- *
606
- * @param string $message The message to use.
607
- * @param string $user The user's login name.
608
- * @param string $user_email The user's email address.
609
- * @param string $key The activation key created in wpmu_signup_blog().
610
- * @param array $meta Array of meta values for the created site.
611
- */
612
  $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta );
613
 
614
  // Send the email
@@ -617,19 +490,6 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
617
  // Set up the $admin_email to pass to the filter
618
  $admin_email = bp_get_option( 'admin_email' );
619
 
620
- /**
621
- * Fires after the sending of the notification to new users for successful registration without blog.
622
- *
623
- * @since BuddyPress (1.5.0)
624
- *
625
- * @param string $admin_email Admin Email address for the site.
626
- * @param string $subject Subject used in the notification email.
627
- * @param string $message Message used in the notification email.
628
- * @param string $user The user's login name.
629
- * @param string $user_email The user's email address.
630
- * @param string $key The activation key created in wpmu_signup_blog().
631
- * @param array $meta Array of meta values for the created site. Default empty array.
632
- */
633
  do_action( 'bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta );
634
 
635
  // Return false to stop the original WPMU function from continuing
@@ -801,13 +661,9 @@ function bp_modify_page_title( $title = '', $sep = '&raquo;', $seplocation = 'ri
801
  }
802
 
803
  /**
804
- * Filters the page title for BuddyPress pages.
805
- *
806
- * @since BuddyPress (1.5.0)
807
- *
808
- * @param string $new_title The BuddyPress page title.
809
- * @param string $title The original WordPress page title.
810
- * @param string $sep The title parts separator.
811
  * @param string $seplocation Location of the separator (left or right).
812
  */
813
  return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation );
@@ -848,16 +704,9 @@ function bp_setup_nav_menu_item( $menu_item ) {
848
  return $menu_item;
849
  }
850
 
851
- // Prevent a notice error when using the customizer
852
- $menu_classes = $menu_item->classes;
853
-
854
- if ( is_array( $menu_classes ) ) {
855
- $menu_classes = implode( ' ', $menu_item->classes);
856
- }
857
-
858
  // We use information stored in the CSS class to determine what kind of
859
  // menu item this is, and how it should be treated
860
- preg_match( '/\sbp-(.*)-nav/', $menu_classes, $matches );
861
 
862
  // If this isn't a BP menu item, we can stop here
863
  if ( empty( $matches[1] ) ) {
@@ -911,12 +760,7 @@ function bp_setup_nav_menu_item( $menu_item ) {
911
  } else {
912
  $current = bp_get_requested_url();
913
  if ( strpos( $current, $menu_item->url ) !== false ) {
914
- if ( is_array( $menu_item->classes ) ) {
915
- $menu_item->classes[] = 'current_page_item';
916
- $menu_item->classes[] = 'current-menu-item';
917
- } else {
918
- $menu_item->classes = array( 'current_page_item', 'current-menu-item' );
919
- }
920
  }
921
  }
922
 
@@ -924,68 +768,6 @@ function bp_setup_nav_menu_item( $menu_item ) {
924
  }
925
  add_filter( 'wp_setup_nav_menu_item', 'bp_setup_nav_menu_item', 10, 1 );
926
 
927
- /**
928
- * Populate BuddyPress user nav items for the customizer
929
- *
930
- * @since BuddyPress (2.3.3)
931
- *
932
- * @param array $items The array of menu items
933
- * @param string $type The requested type
934
- * @param string $object The requested object name
935
- * @param integer $page The page num being requested
936
- * @return array The paginated BuddyPress user nav items.
937
- */
938
- function bp_customizer_nav_menus_get_items( $items = array(), $type = '', $object = '', $page = 0 ) {
939
- if ( 'bp_loggedin_nav' === $object ) {
940
- $bp_items = bp_nav_menu_get_loggedin_pages();
941
- } elseif ( 'bp_loggedout_nav' === $object ) {
942
- $bp_items = bp_nav_menu_get_loggedout_pages();
943
- } else {
944
- return $items;
945
- }
946
-
947
- foreach ( $bp_items as $bp_item ) {
948
- $items[] = array(
949
- 'id' => "bp-{$bp_item->post_excerpt}",
950
- 'title' => html_entity_decode( $bp_item->post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
951
- 'type' => $type,
952
- 'url' => esc_url_raw( $bp_item->guid ),
953
- 'classes' => "bp-menu bp-{$bp_item->post_excerpt}-nav",
954
- 'type_label' => _x( 'Custom Link', 'customizer menu type label', 'buddypress' ),
955
- 'object' => $object,
956
- 'object_id' => -1,
957
- );
958
- }
959
-
960
- return array_slice( $items, 10 * $page, 10 );
961
- }
962
- add_filter( 'customize_nav_menu_available_items', 'bp_customizer_nav_menus_get_items', 10, 4 );
963
-
964
- /**
965
- * Set BuddyPress item navs for the customizer
966
- *
967
- * @since BuddyPress (2.3.3)
968
- *
969
- * @param array $item_types an associative array structured for the customizer
970
- */
971
- function bp_customizer_nav_menus_set_item_types( $item_types = array() ) {
972
- $item_types = array_merge( $item_types, array(
973
- 'bp_loggedin_nav' => array(
974
- 'title' => _x( 'BuddyPress (logged-in)', 'customizer menu section title', 'buddypress' ),
975
- 'type' => 'bp_nav',
976
- 'object' => 'bp_loggedin_nav',
977
- ),
978
- 'bp_loggedout_nav' => array(
979
- 'title' => _x( 'BuddyPress (logged-out)', 'customizer menu section title', 'buddypress' ),
980
- 'type' => 'bp_nav',
981
- 'object' => 'bp_loggedout_nav',
982
- ),
983
- ) );
984
-
985
- return $item_types;
986
- }
987
- add_filter( 'customize_nav_menu_available_item_types', 'bp_customizer_nav_menus_set_item_types', 10, 1 );
988
-
989
  /**
990
  * Filter SQL query strings to swap out the 'meta_id' column.
991
  *
94
  if ( !empty( $bp->pages->forums ) && ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) ) )
95
  $pages[] = $bp->pages->forums->id;
96
 
 
 
 
 
 
 
 
97
  return apply_filters( 'bp_core_exclude_pages', $pages );
98
  }
99
  add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
234
  * @return string The blog name for the root blog.
235
  */
236
  function bp_core_email_from_name_filter() {
 
 
 
 
 
 
 
 
237
  return apply_filters( 'bp_core_email_from_name_filter', bp_get_option( 'blogname', 'WordPress' ) );
238
  }
239
  add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
300
  return $redirect_to;
301
  }
302
 
303
+ // Allow plugins to allow or disallow redirects, as desired
 
 
 
 
 
 
 
 
 
 
 
 
304
  $maybe_redirect = apply_filters( 'bp_core_login_redirect', false, $redirect_to, $redirect_to_raw, $user );
305
  if ( false !== $maybe_redirect ) {
306
  return $maybe_redirect;
317
  return wp_get_referer();
318
  }
319
 
 
 
 
 
 
 
 
320
  return apply_filters( 'bp_core_login_redirect_to', bp_get_root_domain() );
321
  }
322
  add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
414
  $message = sprintf( __( "%1\$s,\n\n\n\nThanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%2\$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%3\$s", 'buddypress' ), $user, $activate_url, esc_url( "http://{$domain}{$path}" ) );
415
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
416
 
417
+ // Email filters
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  $to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email, $domain, $path, $title, $user, $user_email, $key, $meta );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
  $subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject, $domain, $path, $title, $user, $user_email, $key, $meta );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  $message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message, $domain, $path, $title, $user, $user_email, $key, $meta );
421
 
422
  // Send the email
425
  // Set up the $admin_email to pass to the filter
426
  $admin_email = bp_get_option( 'admin_email' );
427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  do_action( 'bp_core_sent_blog_signup_email', $admin_email, $subject, $message, $domain, $path, $title, $user, $user_email, $key, $meta );
429
 
430
  // Return false to stop the original WPMU function from continuing
479
  $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
480
  $subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
481
 
482
+ // Email filters
 
 
 
 
 
 
 
 
 
 
483
  $to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta );
 
 
 
 
 
 
 
 
 
 
 
 
484
  $subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta );
 
 
 
 
 
 
 
 
 
 
 
 
485
  $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta );
486
 
487
  // Send the email
490
  // Set up the $admin_email to pass to the filter
491
  $admin_email = bp_get_option( 'admin_email' );
492
 
 
 
 
 
 
 
 
 
 
 
 
 
 
493
  do_action( 'bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta );
494
 
495
  // Return false to stop the original WPMU function from continuing
661
  }
662
 
663
  /**
664
+ * @param string the BuddyPress page title
665
+ * @param string $title the original WordPress page title
666
+ * @param string $sep the title parts separator
 
 
 
 
667
  * @param string $seplocation Location of the separator (left or right).
668
  */
669
  return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation );
704
  return $menu_item;
705
  }
706
 
 
 
 
 
 
 
 
707
  // We use information stored in the CSS class to determine what kind of
708
  // menu item this is, and how it should be treated
709
+ preg_match( '/\sbp-(.*)-nav/', implode( ' ', $menu_item->classes), $matches );
710
 
711
  // If this isn't a BP menu item, we can stop here
712
  if ( empty( $matches[1] ) ) {
760
  } else {
761
  $current = bp_get_requested_url();
762
  if ( strpos( $current, $menu_item->url ) !== false ) {
763
+ $menu_item->classes[] = 'current_page_item';
 
 
 
 
 
764
  }
765
  }
766
 
768
  }
769
  add_filter( 'wp_setup_nav_menu_item', 'bp_setup_nav_menu_item', 10, 1 );
770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
771
  /**
772
  * Filter SQL query strings to swap out the 'meta_id' column.
773
  *
bp-core/bp-core-functions.php CHANGED
@@ -71,7 +71,7 @@ function bp_db_version_raw() {
71
  * @return string The BuddyPress version direct from the database.
72
  */
73
  function bp_get_db_version_raw() {
74
- $bp = buddypress();
75
  return !empty( $bp->db_version_raw ) ? $bp->db_version_raw : 0;
76
  }
77
 
@@ -89,15 +89,6 @@ function bp_db_version_raw() {
89
  function bp_core_get_table_prefix() {
90
  global $wpdb;
91
 
92
- /**
93
- * Filters the $wpdb base prefix.
94
- *
95
- * Intended primarily for use in multinetwork installations.
96
- *
97
- * @since BuddyPress (1.2.6)
98
- *
99
- * @param string $base_prefix Base prefix to use.
100
- */
101
  return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix );
102
  }
103
 
@@ -180,15 +171,6 @@ function bp_core_number_format( $number = 0, $decimals = false ) {
180
  $number = 0;
181
  }
182
 
183
- /**
184
- * Filters the BuddyPress formatted number.
185
- *
186
- * @since BuddyPress (1.2.4)
187
- *
188
- * @param string $value BuddyPress formatted value.
189
- * @param int $number The number to be formatted.
190
- * @param bool $decimals Whether or not to use decimals.
191
- */
192
  return apply_filters( 'bp_core_number_format', number_format_i18n( $number, $decimals ), $number, $decimals );
193
  }
194
 
@@ -268,16 +250,6 @@ function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
268
 
269
  // Passively filter the args before the parse
270
  if ( !empty( $filter_key ) ) {
271
-
272
- /**
273
- * Filters the arguments key before parsing if filter key provided.
274
- *
275
- * This is a dynamic filter dependent on the specified key.
276
- *
277
- * @since BuddyPress (2.0.0)
278
- *
279
- * @param array $r Array of arguments to use.
280
- */
281
  $r = apply_filters( 'bp_before_' . $filter_key . '_parse_args', $r );
282
  }
283
 
@@ -288,16 +260,6 @@ function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
288
 
289
  // Aggressively filter the args after the parse
290
  if ( !empty( $filter_key ) ) {
291
-
292
- /**
293
- * Filters the arguments key after parsing if filter key provided.
294
- *
295
- * This is a dynamic filter dependent on the specified key.
296
- *
297
- * @since BuddyPress (2.0.0)
298
- *
299
- * @param array $r Array of parsed arguments.
300
- */
301
  $r = apply_filters( 'bp_after_' . $filter_key . '_parse_args', $r );
302
  }
303
 
@@ -388,14 +350,6 @@ function bp_esc_like( $text ) {
388
  * Default: false.
389
  */
390
  function bp_is_username_compatibility_mode() {
391
-
392
- /**
393
- * Filters whether or not to use username compatibility mode.
394
- *
395
- * @since BuddyPress (1.5.0)
396
- *
397
- * @param bool $value Whether or not username compatibility mode should be used.
398
- */
399
  return apply_filters( 'bp_is_username_compatibility_mode', defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) && BP_ENABLE_USERNAME_COMPATIBILITY_MODE );
400
  }
401
 
@@ -425,13 +379,6 @@ function bp_use_wp_admin_bar() {
425
  $use_admin_bar = false;
426
  }
427
 
428
- /**
429
- * Filters whether or not to use the admin bar.
430
- *
431
- * @since BuddyPress (1.5.0)
432
- *
433
- * @param bool $use_admin_bar Whether or not to use the admin bar.
434
- */
435
  return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
436
  }
437
 
@@ -505,13 +452,6 @@ function bp_core_get_directory_page_ids( $status = 'active' ) {
505
  }
506
  }
507
 
508
- /**
509
- * Filters the list of BP directory pages from the appropriate meta table.
510
- *
511
- * @since BuddyPress (1.5.0)
512
- *
513
- * @param array $page_ids Array of directory pages.
514
- */
515
  return apply_filters( 'bp_core_get_directory_page_ids', $page_ids );
516
  }
517
 
@@ -589,13 +529,6 @@ function bp_core_get_directory_pages() {
589
  wp_cache_set( 'directory_pages', $pages, 'bp' );
590
  }
591
 
592
- /**
593
- * Filters the names and slugs for BuddyPress component directory pages.
594
- *
595
- * @since BuddyPress (1.5.0)
596
- *
597
- * @param object $pages Object holding page names and slugs.
598
- */
599
  return apply_filters( 'bp_core_get_directory_pages', $pages );
600
  }
601
 
@@ -754,14 +687,6 @@ function bp_core_component_slug_from_root_slug( $root_slug ) {
754
  $slug_chunks = explode( '/', $root_slug );
755
  $slug = array_pop( $slug_chunks );
756
 
757
- /**
758
- * Filters the default component slug from a WP page root_slug.
759
- *
760
- * @since BuddyPress (1.5.0)
761
- *
762
- * @param string $slug Short slug for use in the middle of URLs.
763
- * @param string $root_slug The root slug which comes from $bp->pages-[component]->slug.
764
- */
765
  return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug );
766
  }
767
 
@@ -872,13 +797,6 @@ function bp_do_register_theme_directory() {
872
  $register = true;
873
  }
874
 
875
- /**
876
- * Filters whether BuddyPress should register the bp-themes directory.
877
- *
878
- * @since BuddyPress (1.9.0)
879
- *
880
- * @param bool $register If bp-themes should be registered.
881
- */
882
  return apply_filters( 'bp_do_register_theme_directory', $register );
883
  }
884
 
@@ -897,13 +815,6 @@ function bp_core_get_root_domain() {
897
 
898
  $domain = get_home_url( bp_get_root_blog_id() );
899
 
900
- /**
901
- * Filters the domain for the root blog.
902
- *
903
- * @since BuddyPress (1.0.1)
904
- *
905
- * @param string $domain The domain URL for the blog.
906
- */
907
  return apply_filters( 'bp_core_get_root_domain', $domain );
908
  }
909
 
@@ -934,31 +845,18 @@ function bp_core_redirect( $location = '', $status = 302 ) {
934
  }
935
 
936
  /**
937
- * Return the URL path of the referring page.
938
- *
939
- * This is a wrapper for `wp_get_referer()` that sanitizes the referer URL to
940
- * a webroot-relative path. For example, 'http://example.com/foo/' will be
941
- * reduced to '/foo/'.
942
  *
943
- * @since BuddyPress (2.3.0)
944
- *
945
- * @return bool|string Returns false on error, a URL path on success.
946
  */
947
- function bp_get_referer_path() {
948
- $referer = wp_get_referer();
949
-
950
- if ( false === $referer ) {
951
- return false;
952
- }
953
-
954
- // Turn into an absolute path.
955
- $referer = preg_replace( '|https?\://[^/]+/|', '/', $referer );
956
-
957
- return $referer;
958
  }
959
 
960
  /**
961
- * Get the path of the current site.
962
  *
963
  * @global object $current_site
964
  *
@@ -988,13 +886,6 @@ function bp_core_get_site_path() {
988
  }
989
  }
990
 
991
- /**
992
- * Filters the path of the current site.
993
- *
994
- * @since BuddyPress (1.2.0)
995
- *
996
- * @param string $site_path URL to the current site.
997
- */
998
  return apply_filters( 'bp_core_get_site_path', $site_path );
999
  }
1000
 
@@ -1011,14 +902,6 @@ function bp_core_get_site_path() {
1011
  * @return string Current time in 'Y-m-d h:i:s' format.
1012
  */
1013
  function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
1014
-
1015
- /**
1016
- * Filters the current GMT time to save into the DB.
1017
- *
1018
- * @since BuddyPress (1.2.6)
1019
- *
1020
- * @param string $value Current GMT time.
1021
- */
1022
  return apply_filters( 'bp_core_current_time', current_time( $type, $gmt ) );
1023
  }
1024
 
@@ -1050,45 +933,15 @@ function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
1050
  */
1051
  function bp_core_time_since( $older_date, $newer_date = false ) {
1052
 
1053
- /**
1054
- * Filters whether or not to bypass BuddyPress' time_since calculations.
1055
- *
1056
- * @since BuddyPress (1.7.0)
1057
- *
1058
- * @param bool $value Whether or not to bypass.
1059
- * @param string $older_date Earlier time from which we're calculating time elapsed.
1060
- * @param string $newer_date Unix timestamp of date to compare older time to.
1061
- */
1062
  $pre_value = apply_filters( 'bp_core_time_since_pre', false, $older_date, $newer_date );
1063
  if ( false !== $pre_value ) {
1064
  return $pre_value;
1065
  }
1066
 
1067
- /**
1068
- * Filters the value to use if the time since is unknown.
1069
- *
1070
- * @since BuddyPress (1.5.0)
1071
- *
1072
- * @param string $value String representing the time since the older date.
1073
- */
1074
  $unknown_text = apply_filters( 'bp_core_time_since_unknown_text', __( 'sometime', 'buddypress' ) );
1075
-
1076
- /**
1077
- * Filters the value to use if the time since is right now.
1078
- *
1079
- * @since BuddyPress (1.5.0)
1080
- *
1081
- * @param string $value String representing the time since the older date.
1082
- */
1083
  $right_now_text = apply_filters( 'bp_core_time_since_right_now_text', __( 'right now', 'buddypress' ) );
1084
-
1085
- /**
1086
- * Filters the value to use if the time since is some time ago.
1087
- *
1088
- * @since BuddyPress (1.5.0)
1089
- *
1090
- * @param string $value String representing the time since the older date.
1091
- */
1092
  $ago_text = apply_filters( 'bp_core_time_since_ago_text', __( '%s ago', 'buddypress' ) );
1093
 
1094
  // array of time period chunks
@@ -1219,15 +1072,6 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1219
  $output = sprintf( $ago_text, $output );
1220
  }
1221
 
1222
- /**
1223
- * Filters the English-language representation of the time elapsed since a given date.
1224
- *
1225
- * @since BuddyPress (1.7.0)
1226
- *
1227
- * @param string $output Final 'time since' string.
1228
- * @param string $older_date Earlier time from which we're calculating time elapsed.
1229
- * @param string $newer_date Unix timestamp of date to compare older time to.
1230
- */
1231
  return apply_filters( 'bp_core_time_since', $output, $older_date, $newer_date );
1232
  }
1233
 
@@ -1312,16 +1156,6 @@ function bp_core_render_message() {
1312
 
1313
  if ( !empty( $bp->template_message ) ) :
1314
  $type = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error';
1315
-
1316
- /**
1317
- * Filters the 'template_notices' feedback message content.
1318
- *
1319
- * @since BuddyPress (1.5.5)
1320
- *
1321
- * @param string $template_message Feedback message content.
1322
- * @param string $type The type of message being displayed.
1323
- * Either 'updated' or 'error'.
1324
- */
1325
  $content = apply_filters( 'bp_core_render_message_content', $bp->template_message, $type ); ?>
1326
 
1327
  <div id="message" class="bp-template-notice <?php echo esc_attr( $type ); ?>">
@@ -1332,11 +1166,6 @@ function bp_core_render_message() {
1332
 
1333
  <?php
1334
 
1335
- /**
1336
- * Fires after the display of any template_notices feedback messages.
1337
- *
1338
- * @since BuddyPress (1.1.0)
1339
- */
1340
  do_action( 'bp_core_render_message' );
1341
 
1342
  endif;
@@ -1385,16 +1214,6 @@ function bp_core_record_activity() {
1385
 
1386
  // Use this action to detect the very first activity for a given member
1387
  if ( empty( $activity ) ) {
1388
-
1389
- /**
1390
- * Fires inside the recording of an activity item.
1391
- *
1392
- * Use this action to detect the very first activity for a given member.
1393
- *
1394
- * @since BuddyPress (1.6.0)
1395
- *
1396
- * @param int $user_id ID of the user whose activity is recorded.
1397
- */
1398
  do_action( 'bp_first_activity_for_member', $user_id );
1399
  }
1400
 
@@ -1427,15 +1246,7 @@ function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1427
  ? __( 'Not recently active', 'buddypress' )
1428
  : sprintf( $string, bp_core_time_since( $last_activity_date ) );
1429
 
1430
- /**
1431
- * Filters last activity string based on time since date given.
1432
- *
1433
- * @since BuddyPress (1.2.0)
1434
- *
1435
- * @param string $last_active Last activity string based on time since date given.
1436
- * @param string $last_activity_date The date of last activity.
1437
- * @param string $string A sprintf()-able statement of the form 'active %s'.
1438
- */
1439
  return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
1440
  }
1441
 
@@ -1465,14 +1276,6 @@ function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1465
  * @return string $key The usermeta meta_key.
1466
  */
1467
  function bp_get_user_meta_key( $key = false ) {
1468
-
1469
- /**
1470
- * Filters the meta_key for a given piece of user metadata.
1471
- *
1472
- * @since BuddyPress (1.5.0)
1473
- *
1474
- * @param string $key The usermeta meta key.
1475
- */
1476
  return apply_filters( 'bp_get_user_meta_key', $key );
1477
  }
1478
 
@@ -1568,14 +1371,6 @@ add_action( 'bp_init', 'bp_embed_init', 9 );
1568
  * enabled. Default: true.
1569
  */
1570
  function bp_use_embed_in_activity() {
1571
-
1572
- /**
1573
- * Filters whether or not oEmbeds are allowed in activity items.
1574
- *
1575
- * @since BuddyPress (1.5.0)
1576
- *
1577
- * @param bool $value Whether or not oEmbeds are allowed.
1578
- */
1579
  return apply_filters( 'bp_use_oembed_in_activity', !defined( 'BP_EMBED_DISABLE_ACTIVITY' ) || !BP_EMBED_DISABLE_ACTIVITY );
1580
  }
1581
 
@@ -1588,14 +1383,6 @@ function bp_use_embed_in_activity() {
1588
  * when enabled. Default: true.
1589
  */
1590
  function bp_use_embed_in_activity_replies() {
1591
-
1592
- /**
1593
- * Filters whether or not oEmbeds are allowed in activity replies.
1594
- *
1595
- * @since BuddyPress (1.5.0)
1596
- *
1597
- * @param bool $value Whether or not oEmbeds are allowed.
1598
- */
1599
  return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES );
1600
  }
1601
 
@@ -1608,14 +1395,6 @@ function bp_use_embed_in_activity_replies() {
1608
  * enabled. Default: true.
1609
  */
1610
  function bp_use_embed_in_forum_posts() {
1611
-
1612
- /**
1613
- * Filters whether or not oEmbeds are allowed in forum posts.
1614
- *
1615
- * @since BuddyPress (1.5.0)
1616
- *
1617
- * @param bool $value Whether or not oEmbeds are allowed.
1618
- */
1619
  return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS );
1620
  }
1621
 
@@ -1628,14 +1407,6 @@ function bp_use_embed_in_forum_posts() {
1628
  * enabled. Default: true.
1629
  */
1630
  function bp_use_embed_in_private_messages() {
1631
-
1632
- /**
1633
- * Filters whether or not oEmbeds are allowed in private messages.
1634
- *
1635
- * @since BuddyPress (1.5.0)
1636
- *
1637
- * @param bool $value Whether or not oEmbeds are allowed.
1638
- */
1639
  return apply_filters( 'bp_use_embed_in_private_messages', !defined( 'BP_EMBED_DISABLE_PRIVATE_MESSAGES' ) || !BP_EMBED_DISABLE_PRIVATE_MESSAGES );
1640
  }
1641
 
@@ -1708,13 +1479,6 @@ function bp_core_do_network_admin() {
1708
  $retval = false;
1709
  }
1710
 
1711
- /**
1712
- * Filters whether or not BuddyPress should appear in network admin.
1713
- *
1714
- * @since BuddyPress (1.5.0)
1715
- *
1716
- * @param bool $retval Whether or not BuddyPress should be in the network admin.
1717
- */
1718
  return (bool) apply_filters( 'bp_core_do_network_admin', $retval );
1719
  }
1720
 
@@ -1733,13 +1497,6 @@ function bp_core_do_network_admin() {
1733
  function bp_core_admin_hook() {
1734
  $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
1735
 
1736
- /**
1737
- * Filters the action name that BuddyPress nav setup callbacks should be hooked to.
1738
- *
1739
- * @since BuddyPress (1.5.0)
1740
- *
1741
- * @param string $hook Action name to be attached to.
1742
- */
1743
  return apply_filters( 'bp_core_admin_hook', $hook );
1744
  }
1745
 
@@ -1768,13 +1525,6 @@ function bp_is_root_blog( $blog_id = 0 ) {
1768
  $is_root_blog = true;
1769
  }
1770
 
1771
- /**
1772
- * Filters whether or not we're on the root blog.
1773
- *
1774
- * @since BuddyPress (1.5.0)
1775
- *
1776
- * @param bool $is_root_blog Whether or not we're on the root blog.
1777
- */
1778
  return (bool) apply_filters( 'bp_is_root_blog', (bool) $is_root_blog );
1779
  }
1780
 
@@ -1790,14 +1540,6 @@ function bp_is_root_blog( $blog_id = 0 ) {
1790
  * @return int The root site ID.
1791
  */
1792
  function bp_get_root_blog_id() {
1793
-
1794
- /**
1795
- * Filters the ID for the root blog.
1796
- *
1797
- * @since BuddyPress (1.5.0)
1798
- *
1799
- * @param int $root_blog_id ID for the root blog.
1800
- */
1801
  return (int) apply_filters( 'bp_get_root_blog_id', (int) buddypress()->root_blog_id );
1802
  }
1803
 
@@ -1848,13 +1590,6 @@ function bp_is_multiblog_mode() {
1848
  $retval = true;
1849
  }
1850
 
1851
- /**
1852
- * Filters whether or not we're running in multiblog mode.
1853
- *
1854
- * @since BuddyPress (1.5.0)
1855
- *
1856
- * @param bool $retval Whether or not we're running multiblog mode.
1857
- */
1858
  return apply_filters( 'bp_is_multiblog_mode', $retval );
1859
  }
1860
 
@@ -1884,13 +1619,6 @@ function bp_is_network_activated() {
1884
  $retval = false;
1885
  }
1886
 
1887
- /**
1888
- * Filters whether or not we're active at the network level.
1889
- *
1890
- * @since BuddyPress (1.7.0)
1891
- *
1892
- * @param bool $retval Whether or not we're network activated.
1893
- */
1894
  return (bool) apply_filters( 'bp_is_network_activated', $retval );
1895
  }
1896
 
@@ -1909,14 +1637,6 @@ function bp_update_is_directory( $is_directory = false, $component = '' ) {
1909
  $component = bp_current_component();
1910
  }
1911
 
1912
- /**
1913
- * Filters the "is_directory" global value.
1914
- *
1915
- * @since BuddyPress (1.5.0)
1916
- *
1917
- * @param bool $is_directory Whether or not we're "is_directory".
1918
- * @param string $component Component name. Default: the current component.
1919
- */
1920
  buddypress()->is_directory = apply_filters( 'bp_update_is_directory', $is_directory, $component );
1921
  }
1922
 
@@ -1933,14 +1653,6 @@ function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
1933
  $component = bp_current_component();
1934
  }
1935
 
1936
- /**
1937
- * Filters the "is_item_admin" global value.
1938
- *
1939
- * @since BuddyPress (1.5.0)
1940
- *
1941
- * @param bool $is_item_admin Whether or not we're "is_item_admin".
1942
- * @param string $component Component name. Default: the current component.
1943
- */
1944
  buddypress()->is_item_admin = apply_filters( 'bp_update_is_item_admin', $is_item_admin, $component );
1945
  }
1946
 
@@ -1957,14 +1669,6 @@ function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1957
  $component = bp_current_component();
1958
  }
1959
 
1960
- /**
1961
- * Filters the "is_item_mod" global value.
1962
- *
1963
- * @since BuddyPress (1.5.0)
1964
- *
1965
- * @param bool $is_item_mod Whether or not we're "is_item_mod".
1966
- * @param string $component Component name. Default: the current component.
1967
- */
1968
  buddypress()->is_item_mod = apply_filters( 'bp_update_is_item_mod', $is_item_mod, $component );
1969
  }
1970
 
@@ -1981,14 +1685,6 @@ function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1981
  function bp_do_404( $redirect = 'remove_canonical_direct' ) {
1982
  global $wp_query;
1983
 
1984
- /**
1985
- * Fires inside the triggering of a 404.
1986
- *
1987
- * @since BuddyPress (1.5.0)
1988
- *
1989
- * @param string $redirect Redirect type used to determine if redirect_canonical
1990
- * function should be be removed.
1991
- */
1992
  do_action( 'bp_do_404', $redirect );
1993
 
1994
  $wp_query->set_404();
@@ -2048,15 +1744,7 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
2048
 
2049
  /** Look for match ********************************************************/
2050
 
2051
- /**
2052
- * Filters the requested URL being nonce-verified.
2053
- *
2054
- * Useful for configurations like reverse proxying.
2055
- *
2056
- * @since BuddyPress (1.9.0)
2057
- *
2058
- * @param string $requested_url The requested URL.
2059
- */
2060
  $matched_url = apply_filters( 'bp_verify_nonce_request_url', $requested_url );
2061
 
2062
  // Check the nonce
@@ -2067,14 +1755,7 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
2067
  $result = false;
2068
  }
2069
 
2070
- /**
2071
- * Fires at the end of the nonce verification check.
2072
- *
2073
- * @since BuddyPress (1.6.0)
2074
- *
2075
- * @param string $action Action nonce.
2076
- * @param bool $result Boolean result of nonce verification.
2077
- */
2078
  do_action( 'bp_verify_nonce_request', $action, $result );
2079
 
2080
  return $result;
@@ -2114,23 +1795,8 @@ function bp_is_get_request() {
2114
  */
2115
  function bp_core_load_buddypress_textdomain() {
2116
  $domain = 'buddypress';
2117
-
2118
- /**
2119
- * Filters the locale to be loaded for the language files.
2120
- *
2121
- * @since BuddyPress (1.0.2)
2122
- *
2123
- * @param string $value Current locale for the install.
2124
- */
2125
  $mofile_custom = sprintf( '%s-%s.mo', $domain, apply_filters( 'buddypress_locale', get_locale() ) );
2126
 
2127
- /**
2128
- * Filters the locations to load language files from.
2129
- *
2130
- * @since BuddyPress (2.2.0)
2131
- *
2132
- * @param array $value Array of directories to check for language files in.
2133
- */
2134
  $locations = apply_filters( 'buddypress_locale_locations', array(
2135
  trailingslashit( WP_LANG_DIR . '/' . $domain ),
2136
  trailingslashit( WP_LANG_DIR ),
@@ -2149,7 +1815,7 @@ function bp_core_load_buddypress_textdomain() {
2149
  add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
2150
 
2151
  /**
2152
- * A JavaScript-free implementation of the search functions in BuddyPress.
2153
  *
2154
  * @param string $slug The slug to redirect to for searching.
2155
  */
@@ -2210,14 +1876,6 @@ function bp_core_action_search_site( $slug = '' ) {
2210
  }
2211
  }
2212
 
2213
- /**
2214
- * Filters the constructed url for use with site searching.
2215
- *
2216
- * @since BuddyPress (1.0.0)
2217
- *
2218
- * @param string $value URL for use with site searching.
2219
- * @param array $search_terms Array of search terms.
2220
- */
2221
  bp_core_redirect( apply_filters( 'bp_core_search_site', home_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) );
2222
  }
2223
  add_action( 'bp_init', 'bp_core_action_search_site', 7 );
@@ -2456,18 +2114,7 @@ function bp_core_get_suggestions( $args ) {
2456
  }
2457
 
2458
  } else {
2459
-
2460
- /**
2461
- * Filters the default suggestions service to use.
2462
- *
2463
- * Use this hook to tell BP the name of your class
2464
- * if you've built a custom suggestions service.
2465
- *
2466
- * @since BuddyPress (2.1.0)
2467
- *
2468
- * @param string $value Custom class to use. Default: none.
2469
- * @param array $args Array of arguments for sugggestions.
2470
- */
2471
  $class = apply_filters( 'bp_suggestions_services', '', $args );
2472
  }
2473
 
@@ -2485,60 +2132,5 @@ function bp_core_get_suggestions( $args ) {
2485
  $retval = $suggestions->get_suggestions();
2486
  }
2487
 
2488
- /**
2489
- * Filters the available type of at-mentions.
2490
- *
2491
- * @since BuddyPress (2.1.0)
2492
- *
2493
- * @param array|WP_Error $retval Array of results or WP_Error object.
2494
- * @param array $args Array of arguments for suggestions.
2495
- */
2496
  return apply_filters( 'bp_core_get_suggestions', $retval, $args );
2497
  }
2498
-
2499
- /**
2500
- * Set data from the BP root blog's upload directory.
2501
- *
2502
- * Handy for multisite instances because all uploads are made on the BP root
2503
- * blog and we need to query the BP root blog for the upload directory data.
2504
- *
2505
- * This function ensures that we only need to use {@link switch_to_blog()}
2506
- * once to get what we need.
2507
- *
2508
- * @since BuddyPress (2.3.0)
2509
- *
2510
- * @uses is_multisite()
2511
- * @uses bp_is_root_blog()
2512
- * @uses switch_to_blog()
2513
- * @uses wp_upload_dir()
2514
- * @uses restore_current_blog()
2515
- */
2516
- function bp_upload_dir() {
2517
- $bp = buddypress();
2518
-
2519
- if ( empty( $bp->upload_dir ) ) {
2520
- $need_switch = (bool) ( is_multisite() && ! bp_is_root_blog() );
2521
-
2522
- // Maybe juggle to root blog
2523
- if ( true === $need_switch ) {
2524
- switch_to_blog( bp_get_root_blog_id() );
2525
- }
2526
-
2527
- // Get the upload directory (maybe for root blog)
2528
- $wp_upload_dir = wp_upload_dir();
2529
-
2530
- // Maybe juggle back to current blog
2531
- if ( true === $need_switch ) {
2532
- restore_current_blog();
2533
- }
2534
-
2535
- // Bail if an error occurred
2536
- if ( ! empty( $wp_upload_dir['error'] ) ) {
2537
- return false;
2538
- }
2539
-
2540
- $bp->upload_dir = $wp_upload_dir;
2541
- }
2542
-
2543
- return $bp->upload_dir;
2544
- }
71
  * @return string The BuddyPress version direct from the database.
72
  */
73
  function bp_get_db_version_raw() {
74
+ $bp = buddypress();
75
  return !empty( $bp->db_version_raw ) ? $bp->db_version_raw : 0;
76
  }
77
 
89
  function bp_core_get_table_prefix() {
90
  global $wpdb;
91
 
 
 
 
 
 
 
 
 
 
92
  return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix );
93
  }
94
 
171
  $number = 0;
172
  }
173
 
 
 
 
 
 
 
 
 
 
174
  return apply_filters( 'bp_core_number_format', number_format_i18n( $number, $decimals ), $number, $decimals );
175
  }
176
 
250
 
251
  // Passively filter the args before the parse
252
  if ( !empty( $filter_key ) ) {
 
 
 
 
 
 
 
 
 
 
253
  $r = apply_filters( 'bp_before_' . $filter_key . '_parse_args', $r );
254
  }
255
 
260
 
261
  // Aggressively filter the args after the parse
262
  if ( !empty( $filter_key ) ) {
 
 
 
 
 
 
 
 
 
 
263
  $r = apply_filters( 'bp_after_' . $filter_key . '_parse_args', $r );
264
  }
265
 
350
  * Default: false.
351
  */
352
  function bp_is_username_compatibility_mode() {
 
 
 
 
 
 
 
 
353
  return apply_filters( 'bp_is_username_compatibility_mode', defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) && BP_ENABLE_USERNAME_COMPATIBILITY_MODE );
354
  }
355
 
379
  $use_admin_bar = false;
380
  }
381
 
 
 
 
 
 
 
 
382
  return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
383
  }
384
 
452
  }
453
  }
454
 
 
 
 
 
 
 
 
455
  return apply_filters( 'bp_core_get_directory_page_ids', $page_ids );
456
  }
457
 
529
  wp_cache_set( 'directory_pages', $pages, 'bp' );
530
  }
531
 
 
 
 
 
 
 
 
532
  return apply_filters( 'bp_core_get_directory_pages', $pages );
533
  }
534
 
687
  $slug_chunks = explode( '/', $root_slug );
688
  $slug = array_pop( $slug_chunks );
689
 
 
 
 
 
 
 
 
 
690
  return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug );
691
  }
692
 
797
  $register = true;
798
  }
799
 
 
 
 
 
 
 
 
800
  return apply_filters( 'bp_do_register_theme_directory', $register );
801
  }
802
 
815
 
816
  $domain = get_home_url( bp_get_root_blog_id() );
817
 
 
 
 
 
 
 
 
818
  return apply_filters( 'bp_core_get_root_domain', $domain );
819
  }
820
 
845
  }
846
 
847
  /**
848
+ * Return the referrer URL without the http(s)://
 
 
 
 
849
  *
850
+ * @return string The referrer URL.
 
 
851
  */
852
+ function bp_core_referrer() {
853
+ $referer = explode( '/', wp_get_referer() );
854
+ unset( $referer[0], $referer[1], $referer[2] );
855
+ return implode( '/', $referer );
 
 
 
 
 
 
 
856
  }
857
 
858
  /**
859
+ * Get the path of of the current site.
860
  *
861
  * @global object $current_site
862
  *
886
  }
887
  }
888
 
 
 
 
 
 
 
 
889
  return apply_filters( 'bp_core_get_site_path', $site_path );
890
  }
891
 
902
  * @return string Current time in 'Y-m-d h:i:s' format.
903
  */
904
  function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
 
 
 
 
 
 
 
 
905
  return apply_filters( 'bp_core_current_time', current_time( $type, $gmt ) );
906
  }
907
 
933
  */
934
  function bp_core_time_since( $older_date, $newer_date = false ) {
935
 
936
+ // Use this filter to bypass BuddyPress's time_since calculations
 
 
 
 
 
 
 
 
937
  $pre_value = apply_filters( 'bp_core_time_since_pre', false, $older_date, $newer_date );
938
  if ( false !== $pre_value ) {
939
  return $pre_value;
940
  }
941
 
942
+ // Setup the strings
 
 
 
 
 
 
943
  $unknown_text = apply_filters( 'bp_core_time_since_unknown_text', __( 'sometime', 'buddypress' ) );
 
 
 
 
 
 
 
 
944
  $right_now_text = apply_filters( 'bp_core_time_since_right_now_text', __( 'right now', 'buddypress' ) );
 
 
 
 
 
 
 
 
945
  $ago_text = apply_filters( 'bp_core_time_since_ago_text', __( '%s ago', 'buddypress' ) );
946
 
947
  // array of time period chunks
1072
  $output = sprintf( $ago_text, $output );
1073
  }
1074
 
 
 
 
 
 
 
 
 
 
1075
  return apply_filters( 'bp_core_time_since', $output, $older_date, $newer_date );
1076
  }
1077
 
1156
 
1157
  if ( !empty( $bp->template_message ) ) :
1158
  $type = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error';
 
 
 
 
 
 
 
 
 
 
1159
  $content = apply_filters( 'bp_core_render_message_content', $bp->template_message, $type ); ?>
1160
 
1161
  <div id="message" class="bp-template-notice <?php echo esc_attr( $type ); ?>">
1166
 
1167
  <?php
1168
 
 
 
 
 
 
1169
  do_action( 'bp_core_render_message' );
1170
 
1171
  endif;
1214
 
1215
  // Use this action to detect the very first activity for a given member
1216
  if ( empty( $activity ) ) {
 
 
 
 
 
 
 
 
 
 
1217
  do_action( 'bp_first_activity_for_member', $user_id );
1218
  }
1219
 
1246
  ? __( 'Not recently active', 'buddypress' )
1247
  : sprintf( $string, bp_core_time_since( $last_activity_date ) );
1248
 
1249
+ // Filter and return
 
 
 
 
 
 
 
 
1250
  return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
1251
  }
1252
 
1276
  * @return string $key The usermeta meta_key.
1277
  */
1278
  function bp_get_user_meta_key( $key = false ) {
 
 
 
 
 
 
 
 
1279
  return apply_filters( 'bp_get_user_meta_key', $key );
1280
  }
1281
 
1371
  * enabled. Default: true.
1372
  */
1373
  function bp_use_embed_in_activity() {
 
 
 
 
 
 
 
 
1374
  return apply_filters( 'bp_use_oembed_in_activity', !defined( 'BP_EMBED_DISABLE_ACTIVITY' ) || !BP_EMBED_DISABLE_ACTIVITY );
1375
  }
1376
 
1383
  * when enabled. Default: true.
1384
  */
1385
  function bp_use_embed_in_activity_replies() {
 
 
 
 
 
 
 
 
1386
  return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES );
1387
  }
1388
 
1395
  * enabled. Default: true.
1396
  */
1397
  function bp_use_embed_in_forum_posts() {
 
 
 
 
 
 
 
 
1398
  return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS );
1399
  }
1400
 
1407
  * enabled. Default: true.
1408
  */
1409
  function bp_use_embed_in_private_messages() {
 
 
 
 
 
 
 
 
1410
  return apply_filters( 'bp_use_embed_in_private_messages', !defined( 'BP_EMBED_DISABLE_PRIVATE_MESSAGES' ) || !BP_EMBED_DISABLE_PRIVATE_MESSAGES );
1411
  }
1412
 
1479
  $retval = false;
1480
  }
1481
 
 
 
 
 
 
 
 
1482
  return (bool) apply_filters( 'bp_core_do_network_admin', $retval );
1483
  }
1484
 
1497
  function bp_core_admin_hook() {
1498
  $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
1499
 
 
 
 
 
 
 
 
1500
  return apply_filters( 'bp_core_admin_hook', $hook );
1501
  }
1502
 
1525
  $is_root_blog = true;
1526
  }
1527
 
 
 
 
 
 
 
 
1528
  return (bool) apply_filters( 'bp_is_root_blog', (bool) $is_root_blog );
1529
  }
1530
 
1540
  * @return int The root site ID.
1541
  */
1542
  function bp_get_root_blog_id() {
 
 
 
 
 
 
 
 
1543
  return (int) apply_filters( 'bp_get_root_blog_id', (int) buddypress()->root_blog_id );
1544
  }
1545
 
1590
  $retval = true;
1591
  }
1592
 
 
 
 
 
 
 
 
1593
  return apply_filters( 'bp_is_multiblog_mode', $retval );
1594
  }
1595
 
1619
  $retval = false;
1620
  }
1621
 
 
 
 
 
 
 
 
1622
  return (bool) apply_filters( 'bp_is_network_activated', $retval );
1623
  }
1624
 
1637
  $component = bp_current_component();
1638
  }
1639
 
 
 
 
 
 
 
 
 
1640
  buddypress()->is_directory = apply_filters( 'bp_update_is_directory', $is_directory, $component );
1641
  }
1642
 
1653
  $component = bp_current_component();
1654
  }
1655
 
 
 
 
 
 
 
 
 
1656
  buddypress()->is_item_admin = apply_filters( 'bp_update_is_item_admin', $is_item_admin, $component );
1657
  }
1658
 
1669
  $component = bp_current_component();
1670
  }
1671
 
 
 
 
 
 
 
 
 
1672
  buddypress()->is_item_mod = apply_filters( 'bp_update_is_item_mod', $is_item_mod, $component );
1673
  }
1674
 
1685
  function bp_do_404( $redirect = 'remove_canonical_direct' ) {
1686
  global $wp_query;
1687
 
 
 
 
 
 
 
 
 
1688
  do_action( 'bp_do_404', $redirect );
1689
 
1690
  $wp_query->set_404();
1744
 
1745
  /** Look for match ********************************************************/
1746
 
1747
+ // Filter the requested URL, for configurations like reverse proxying
 
 
 
 
 
 
 
 
1748
  $matched_url = apply_filters( 'bp_verify_nonce_request_url', $requested_url );
1749
 
1750
  // Check the nonce
1755
  $result = false;
1756
  }
1757
 
1758
+ // Do extra things
 
 
 
 
 
 
 
1759
  do_action( 'bp_verify_nonce_request', $action, $result );
1760
 
1761
  return $result;
1795
  */
1796
  function bp_core_load_buddypress_textdomain() {
1797
  $domain = 'buddypress';
 
 
 
 
 
 
 
 
1798
  $mofile_custom = sprintf( '%s-%s.mo', $domain, apply_filters( 'buddypress_locale', get_locale() ) );
1799
 
 
 
 
 
 
 
 
1800
  $locations = apply_filters( 'buddypress_locale_locations', array(
1801
  trailingslashit( WP_LANG_DIR . '/' . $domain ),
1802
  trailingslashit( WP_LANG_DIR ),
1815
  add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
1816
 
1817
  /**
1818
+ * A javascript-free implementation of the search functions in BuddyPress.
1819
  *
1820
  * @param string $slug The slug to redirect to for searching.
1821
  */
1876
  }
1877
  }
1878
 
 
 
 
 
 
 
 
 
1879
  bp_core_redirect( apply_filters( 'bp_core_search_site', home_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) );
1880
  }
1881
  add_action( 'bp_init', 'bp_core_action_search_site', 7 );
2114
  }
2115
 
2116
  } else {
2117
+ // If you've built a custom suggestions service, use this to tell BP the name of your class.
 
 
 
 
 
 
 
 
 
 
 
2118
  $class = apply_filters( 'bp_suggestions_services', '', $args );
2119
  }
2120
 
2132
  $retval = $suggestions->get_suggestions();
2133
  }
2134
 
 
 
 
 
 
 
 
 
2135
  return apply_filters( 'bp_core_get_suggestions', $retval, $args );
2136
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-loader.php CHANGED
@@ -43,47 +43,25 @@ class BP_Core extends BP_Component {
43
  $bp = buddypress();
44
 
45
  /**
46
- * Fires before the loading of individual components and after BuddyPress Core.
 
47
  *
48
- * Allows plugins to run code ahead of the other components.
49
- *
50
- * @since BuddyPress (1.2.0)
51
  */
52
  do_action( 'bp_core_loaded' );
53
 
54
  /** Components ********************************************************/
55
 
56
- /**
57
- * Filters the included and optional components.
58
- *
59
- * @since BuddyPress (1.5.0)
60
- *
61
- * @param array $value Array of included and optional components.
62
- */
63
  $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) );
64
 
65
- /**
66
- * Filters the required components.
67
- *
68
- * @since BuddyPress (1.5.0)
69
- *
70
- * @param array $value Array of required components.
71
- */
72
  $bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
73
 
74
  // Get a list of activated components
75
  if ( $active_components = bp_get_option( 'bp-active-components' ) ) {
76
-
77
- /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
78
  $bp->active_components = apply_filters( 'bp_active_components', $active_components );
79
-
80
- /**
81
- * Filters the deactivated components.
82
- *
83
- * @since BuddyPress (1.0.0)
84
- *
85
- * @param array $value Array of deactivated components.
86
- */
87
  $bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) );
88
 
89
  // Pre 1.5 Backwards compatibility
@@ -94,13 +72,13 @@ class BP_Core extends BP_Component {
94
  $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
95
  }
96
 
97
- /** This filter is documented in bp-core/bp-core-loader.php */
98
  $bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed );
99
 
100
  // Setup the active components
101
  $active_components = array_fill_keys( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ), '1' );
102
 
103
- /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
104
  $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
105
 
106
  // Default to all components active
@@ -112,7 +90,7 @@ class BP_Core extends BP_Component {
112
  // Setup the active components
113
  $active_components = array_fill_keys( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), '1' );
114
 
115
- /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
116
  $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
117
  }
118
 
@@ -133,11 +111,6 @@ class BP_Core extends BP_Component {
133
  // Add Core to required components
134
  $bp->required_components[] = 'core';
135
 
136
- /**
137
- * Fires after the loading of individual components.
138
- *
139
- * @since BuddyPress (2.0.0)
140
- */
141
  do_action( 'bp_core_components_included' );
142
  }
143
 
@@ -206,32 +179,8 @@ class BP_Core extends BP_Component {
206
 
207
  // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
208
  $bp->grav_default = new stdClass;
209
-
210
- /**
211
- * Filters the default user Gravatar.
212
- *
213
- * @since BuddyPress (1.1.0)
214
- *
215
- * @param string $value Default user Gravatar.
216
- */
217
  $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] );
218
-
219
- /**
220
- * Filters the default group Gravatar.
221
- *
222
- * @since BuddyPress (1.1.0)
223
- *
224
- * @param string $value Default group Gravatar.
225
- */
226
  $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user );
227
-
228
- /**
229
- * Filters the default blog Gravatar.
230
- *
231
- * @since BuddyPress (1.1.0)
232
- *
233
- * @param string $value Default blog Gravatar.
234
- */
235
  $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user );
236
 
237
  // Notifications table. Included here for legacy purposes. Use
@@ -251,11 +200,6 @@ class BP_Core extends BP_Component {
251
  // Is the logged in user is a mod for the current item?
252
  bp_update_is_item_mod( false, 'core' );
253
 
254
- /**
255
- * Fires at the end of the setup of bp-core globals setting.
256
- *
257
- * @since BuddyPress (1.1.0)
258
- */
259
  do_action( 'bp_core_setup_globals' );
260
  }
261
 
43
  $bp = buddypress();
44
 
45
  /**
46
+ * At this point in the stack, BuddyPress core has been loaded but
47
+ * individual components (friends/activity/groups/etc...) have not.
48
  *
49
+ * The 'bp_core_loaded' action lets you execute code ahead of the
50
+ * other components.
 
51
  */
52
  do_action( 'bp_core_loaded' );
53
 
54
  /** Components ********************************************************/
55
 
56
+ // Set the included and optional components.
 
 
 
 
 
 
57
  $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) );
58
 
59
+ // Set the required components
 
 
 
 
 
 
60
  $bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
61
 
62
  // Get a list of activated components
63
  if ( $active_components = bp_get_option( 'bp-active-components' ) ) {
 
 
64
  $bp->active_components = apply_filters( 'bp_active_components', $active_components );
 
 
 
 
 
 
 
 
65
  $bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) );
66
 
67
  // Pre 1.5 Backwards compatibility
72
  $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
73
  }
74
 
75
+ // Set globals
76
  $bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed );
77
 
78
  // Setup the active components
79
  $active_components = array_fill_keys( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ), '1' );
80
 
81
+ // Set the active component global
82
  $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
83
 
84
  // Default to all components active
90
  // Setup the active components
91
  $active_components = array_fill_keys( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), '1' );
92
 
93
+ // Set the active component global
94
  $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
95
  }
96
 
111
  // Add Core to required components
112
  $bp->required_components[] = 'core';
113
 
 
 
 
 
 
114
  do_action( 'bp_core_components_included' );
115
  }
116
 
179
 
180
  // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
181
  $bp->grav_default = new stdClass;
 
 
 
 
 
 
 
 
182
  $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] );
 
 
 
 
 
 
 
 
183
  $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user );
 
 
 
 
 
 
 
 
184
  $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user );
185
 
186
  // Notifications table. Included here for legacy purposes. Use
200
  // Is the logged in user is a mod for the current item?
201
  bp_update_is_item_mod( false, 'core' );
202
 
 
 
 
 
 
203
  do_action( 'bp_core_setup_globals' );
204
  }
205
 
bp-core/bp-core-moderation.php CHANGED
@@ -64,16 +64,7 @@ function bp_core_check_for_flood( $user_id = 0 ) {
64
  */
65
  function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {
66
 
67
- /**
68
- * Filters whether or not to bypass checking for moderation keys and too many links.
69
- *
70
- * @since BuddyPress (2.2.0)
71
- *
72
- * @param bool $value Whether or not to bypass checking. Default false.
73
- * @param int $user_id Topic of reply author ID.
74
- * @param string $title The title of the content.
75
- * @param string $content $the content being posted.
76
- */
77
  if ( apply_filters( 'bp_bypass_check_for_moderation', false, $user_id, $title, $content ) ) {
78
  return true;
79
  }
@@ -120,15 +111,6 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = ''
120
 
121
  // Allow for bumping the max to include the user's URL
122
  if ( ! empty( $_post['url'] ) ) {
123
-
124
- /**
125
- * Filters the maximum amount of links allowed to include the user's URL.
126
- *
127
- * @since BuddyPress (1.6.0)
128
- *
129
- * @param string $num_links How many links found.
130
- * @param string $value User's url.
131
- */
132
  $num_links = apply_filters( 'comment_max_links_url', $num_links, $_post['url'] );
133
  }
134
 
@@ -198,16 +180,7 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = ''
198
  */
199
  function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {
200
 
201
- /**
202
- * Filters whether or not to bypass checking for blocked keys.
203
- *
204
- * @since BuddyPress (2.2.0)
205
- *
206
- * @param bool $value Whether or not to bypass checking. Default false.
207
- * @param int $user_id Topic of reply author ID.
208
- * @param string $title The title of the content.
209
- * @param string $content $the content being posted.
210
- */
211
  if ( apply_filters( 'bp_bypass_check_for_blacklist', false, $user_id, $title, $content ) ) {
212
  return true;
213
  }
@@ -299,13 +272,6 @@ function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' )
299
  function bp_core_current_user_ip() {
300
  $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
301
 
302
- /**
303
- * Filters the current user's IP address.
304
- *
305
- * @since BuddyPress (1.6.0)
306
- *
307
- * @param string $retval Current user's IP Address.
308
- */
309
  return apply_filters( 'bp_core_current_user_ip', $retval );
310
  }
311
 
@@ -325,12 +291,5 @@ function bp_core_current_user_ua() {
325
  $retval = '';
326
  }
327
 
328
- /**
329
- * Filters the current user's user-agent.
330
- *
331
- * @since BuddyPress (1.6.0)
332
- *
333
- * @param string $retval Current user's user-agent
334
- */
335
  return apply_filters( 'bp_core_current_user_ua', $retval );
336
  }
64
  */
65
  function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {
66
 
67
+ // Allow for moderation check to be skipped
 
 
 
 
 
 
 
 
 
68
  if ( apply_filters( 'bp_bypass_check_for_moderation', false, $user_id, $title, $content ) ) {
69
  return true;
70
  }
111
 
112
  // Allow for bumping the max to include the user's URL
113
  if ( ! empty( $_post['url'] ) ) {
 
 
 
 
 
 
 
 
 
114
  $num_links = apply_filters( 'comment_max_links_url', $num_links, $_post['url'] );
115
  }
116
 
180
  */
181
  function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {
182
 
183
+ // Allow for blacklist check to be skipped
 
 
 
 
 
 
 
 
 
184
  if ( apply_filters( 'bp_bypass_check_for_blacklist', false, $user_id, $title, $content ) ) {
185
  return true;
186
  }
272
  function bp_core_current_user_ip() {
273
  $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
274
 
 
 
 
 
 
 
 
275
  return apply_filters( 'bp_core_current_user_ip', $retval );
276
  }
277
 
291
  $retval = '';
292
  }
293
 
 
 
 
 
 
 
 
294
  return apply_filters( 'bp_core_current_user_ua', $retval );
295
  }
bp-core/bp-core-options.php CHANGED
@@ -55,9 +55,6 @@ function bp_get_default_options() {
55
  // Avatar uploads
56
  'bp-disable-avatar-uploads' => false,
57
 
58
- // Group Profile Photos
59
- 'bp-disable-group-avatar-uploads' => false,
60
-
61
  // Allow users to delete their own accounts
62
  'bp-disable-account-deletion' => false,
63
 
@@ -103,13 +100,6 @@ function bp_get_default_options() {
103
  'widget_bp_messages_sitewide_notices_widget' => false,
104
  );
105
 
106
- /**
107
- * Filters the default options to be set upon activation.
108
- *
109
- * @since BuddyPress (1.6.0)
110
- *
111
- * @param array $options Array of default options to set.
112
- */
113
  return apply_filters( 'bp_get_default_options', $options );
114
  }
115
 
@@ -135,13 +125,7 @@ function bp_add_options() {
135
  bp_add_option( $key, $value );
136
  }
137
 
138
- /**
139
- * Fires after the addition of default options when BuddyPress is first activated.
140
- *
141
- * Allows previously activated plugins to append their own options.
142
- *
143
- * @since BuddyPress (1.6.0)
144
- */
145
  do_action( 'bp_add_options' );
146
  }
147
 
@@ -169,13 +153,7 @@ function bp_delete_options() {
169
  delete_option( $key );
170
  }
171
 
172
- /**
173
- * Fires after the deletion of default options when BuddyPress is first deactivated.
174
- *
175
- * Allows previously activated plugins to append their own options.
176
- *
177
- * @since BuddyPress (1.6.0)
178
- */
179
  do_action( 'bp_delete_options' );
180
  }
181
 
@@ -200,13 +178,7 @@ function bp_setup_option_filters() {
200
  add_filter( 'pre_option_' . $key, 'bp_pre_get_option' );
201
  }
202
 
203
- /**
204
- * Fires after the addition of filters to each BuddyPress option.
205
- *
206
- * Allows previously activated plugins to append their own options.
207
- *
208
- * @since BuddyPress (1.6.0)
209
- */
210
  do_action( 'bp_setup_option_filters' );
211
  }
212
 
@@ -215,7 +187,7 @@ function bp_setup_option_filters() {
215
  *
216
  * Currently unused.
217
  *
218
- * @since BuddyPress (1.6.0)
219
  *
220
  * @param bool $value Optional. Default value false
221
  * @return mixed false if not overloaded, mixed if set
@@ -246,7 +218,7 @@ function bp_pre_get_option( $value = false ) {
246
  *
247
  * The 'bp_get_option' filter is primarily for backward-compatibility.
248
  *
249
- * @since BuddyPress (1.2.0)
250
  *
251
  * @uses bp_get_root_blog_id()
252
  *
@@ -257,14 +229,6 @@ function bp_pre_get_option( $value = false ) {
257
  */
258
  function bp_get_option( $option_name, $default = '' ) {
259
  $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default );
260
-
261
- /**
262
- * Filters the option value for the requested option.
263
- *
264
- * @since BuddyPress (1.2.0)
265
- *
266
- * @param mixed $value The value for the option.
267
- */
268
  return apply_filters( 'bp_get_option', $value );
269
  }
270
 
@@ -332,10 +296,9 @@ function bp_delete_option( $option_name ) {
332
  * @deprecated 1.6.0
333
  */
334
  function bp_core_activate_site_options( $keys = array() ) {
 
335
 
336
  if ( !empty( $keys ) && is_array( $keys ) ) {
337
- $bp = buddypress();
338
-
339
  $errors = false;
340
 
341
  foreach ( $keys as $key => $default ) {
@@ -390,14 +353,6 @@ function bp_core_get_root_options() {
390
 
391
  // On Multisite installations, some options must always be fetched from sitemeta
392
  if ( is_multisite() ) {
393
-
394
- /**
395
- * Filters multisite options retrieved from sitemeta.
396
- *
397
- * @since BuddyPress (1.5.0)
398
- *
399
- * @param array $value Array of multisite options from sitemeta table.
400
- */
401
  $network_options = apply_filters( 'bp_core_network_options', array(
402
  'tags_blog_id' => '0',
403
  'sitewide_tags_blog' => '',
@@ -474,43 +429,9 @@ function bp_core_get_root_options() {
474
  wp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' );
475
  }
476
 
477
- /**
478
- * Filters the global BP options.
479
- *
480
- * @since BuddyPress (1.5.0)
481
- *
482
- * @param array $root_blog_options_meta Array of global BP options.
483
- */
484
  return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta );
485
  }
486
 
487
- /**
488
- * Get a root option.
489
- *
490
- * "Root options" are those that apply across an entire installation, and are fetched only a single
491
- * time during a pageload and stored in `buddypress()->site_options` to prevent future lookups.
492
- * See {@see bp_core_get_root_options()}.
493
- *
494
- * @since BuddyPress (2.3.0)
495
- *
496
- * @param string $option Name of the option key.
497
- * @return mixed Value, if found.
498
- */
499
- function bp_core_get_root_option( $option ) {
500
- $bp = buddypress();
501
-
502
- if ( ! isset( $bp->site_options ) ) {
503
- $bp->site_options = bp_core_get_root_options();
504
- }
505
-
506
- $value = '';
507
- if ( isset( $bp->site_options[ $option ] ) ) {
508
- $value = $bp->site_options[ $option ];
509
- }
510
-
511
- return $value;
512
- }
513
-
514
  /** Active? *******************************************************************/
515
 
516
  /**
@@ -525,14 +446,6 @@ function bp_core_get_root_option( $option ) {
525
  * @return bool True if profile sync is enabled, otherwise false.
526
  */
527
  function bp_disable_profile_sync( $default = false ) {
528
-
529
- /**
530
- * Filters whether or not profile syncing is disabled.
531
- *
532
- * @since BuddyPress (1.6.0)
533
- *
534
- * @param bool $value Whether or not syncing is disabled.
535
- */
536
  return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) );
537
  }
538
 
@@ -549,14 +462,6 @@ function bp_disable_profile_sync( $default = false ) {
549
  * otherwise false.
550
  */
551
  function bp_hide_loggedout_adminbar( $default = true ) {
552
-
553
- /**
554
- * Filters whether or not the toolbar is hidden for logged out users.
555
- *
556
- * @since BuddyPress (1.6.0)
557
- *
558
- * @param bool $value Whether or not the toolbar is hidden.
559
- */
560
  return (bool) apply_filters( 'bp_hide_loggedout_adminbar', (bool) bp_get_option( 'hide-loggedout-adminbar', $default ) );
561
  }
562
 
@@ -572,51 +477,9 @@ function bp_hide_loggedout_adminbar( $default = true ) {
572
  * @return bool True if avatar uploads are disabled, otherwise false.
573
  */
574
  function bp_disable_avatar_uploads( $default = true ) {
575
-
576
- /**
577
- * Filters whether or not members are able to upload their own avatars.
578
- *
579
- * @since BuddyPress (1.6.0)
580
- *
581
- * @param bool $value Whether or not members are able to upload their own avatars.
582
- */
583
  return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
584
  }
585
 
586
- /**
587
- * Are group avatars disabled?
588
- *
589
- * For backward compatibility, this option falls back on the value of 'bp-disable-avatar-uploads' when no value is
590
- * found in the database.
591
- *
592
- * @since BuddyPress (2.3.0)
593
- *
594
- * @param bool $default Optional. Fallback value if not found in the database.
595
- * Defaults to the value of `bp_disable_avatar_uploads()`.
596
- * @return bool True if group avatar uploads are disabled, otherwise false.
597
- */
598
- function bp_disable_group_avatar_uploads( $default = null ) {
599
- $disabled = bp_get_option( 'bp-disable-group-avatar-uploads', '' );
600
-
601
- if ( '' === $disabled ) {
602
- if ( is_null( $default ) ) {
603
- $disabled = bp_disable_avatar_uploads();
604
- } else {
605
- $disabled = $default;
606
- }
607
- }
608
-
609
- /**
610
- * Filters whether or not members are able to upload group avatars.
611
- *
612
- * @since BuddyPress (2.3.0)
613
- *
614
- * @param bool $disabled Whether or not members are able to upload their groups avatars.
615
- * @param bool $default Default value passed to the function.
616
- */
617
- return (bool) apply_filters( 'bp_disable_group_avatar_uploads', $disabled, $default );
618
- }
619
-
620
  /**
621
  * Are members able to delete their own accounts?
622
  *
@@ -630,14 +493,6 @@ function bp_disable_group_avatar_uploads( $default = null ) {
630
  * false.
631
  */
632
  function bp_disable_account_deletion( $default = false ) {
633
-
634
- /**
635
- * Filters whether or not members are able to delete their own accounts.
636
- *
637
- * @since BuddyPress (1.6.0)
638
- *
639
- * @param bool $value Whether or not members are able to delete their own accounts.
640
- */
641
  return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $default ) );
642
  }
643
 
@@ -655,14 +510,6 @@ function bp_disable_account_deletion( $default = false ) {
655
  * items, otherwise false.
656
  */
657
  function bp_disable_blogforum_comments( $default = false ) {
658
-
659
- /**
660
- * Filters whether or not blog and forum activity stream comments are disabled.
661
- *
662
- * @since BuddyPress (1.6.0)
663
- *
664
- * @param bool $value Whether or not blog and forum activity stream comments are disabled.
665
- */
666
  return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $default ) );
667
  }
668
 
@@ -679,14 +526,6 @@ function bp_disable_blogforum_comments( $default = false ) {
679
  * @return bool True if group creation is restricted, otherwise false.
680
  */
681
  function bp_restrict_group_creation( $default = true ) {
682
-
683
- /**
684
- * Filters whether or not group creation is turned off.
685
- *
686
- * @since BuddyPress (1.6.0)
687
- *
688
- * @param bool $value Whether or not group creation is turned off.
689
- */
690
  return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
691
  }
692
 
@@ -702,14 +541,6 @@ function bp_restrict_group_creation( $default = true ) {
702
  * @return bool True if the BuddyBar should be forced on, otherwise false.
703
  */
704
  function bp_force_buddybar( $default = true ) {
705
-
706
- /**
707
- * Filters whether or not BuddyBar should be forced in place of WP Admin Bar.
708
- *
709
- * @since BuddyPress (1.6.0)
710
- *
711
- * @param bool $value Whether or not BuddyBar should be forced in place of WP Admin Bar.
712
- */
713
  return (bool) apply_filters( 'bp_force_buddybar', (bool) bp_get_option( '_bp_force_buddybar', $default ) );
714
  }
715
 
@@ -734,14 +565,6 @@ function bp_group_forums_root_id( $default = '0' ) {
734
  * @return int The ID of the group forums root forum.
735
  */
736
  function bp_get_group_forums_root_id( $default = '0' ) {
737
-
738
- /**
739
- * Filters the group forums root parent forum id.
740
- *
741
- * @since BuddyPress (1.6.0)
742
- *
743
- * @param int $value The group forums root parent forum id.
744
- */
745
  return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) );
746
  }
747
 
@@ -757,14 +580,6 @@ function bp_group_forums_root_id( $default = '0' ) {
757
  * @return bool True if group forums are active, otherwise false.
758
  */
759
  function bp_is_group_forums_active( $default = true ) {
760
-
761
- /**
762
- * Filters whether or not BuddyPress Group Forums are enabled.
763
- *
764
- * @since BuddyPress (1.6.0)
765
- *
766
- * @param bool $value Whether or not BuddyPress Group Forums are enabled.
767
- */
768
  return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) );
769
  }
770
 
@@ -780,14 +595,6 @@ function bp_is_group_forums_active( $default = true ) {
780
  * @return bool True if Akismet is enabled, otherwise false.
781
  */
782
  function bp_is_akismet_active( $default = true ) {
783
-
784
- /**
785
- * Filters whether or not Akismet is enabled.
786
- *
787
- * @since BuddyPress (1.6.0)
788
- *
789
- * @param bool $value Whether or not Akismet is enabled.
790
- */
791
  return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $default ) );
792
  }
793
 
@@ -803,14 +610,6 @@ function bp_is_akismet_active( $default = true ) {
803
  * @return bool True if Heartbeat refresh is enabled, otherwise false.
804
  */
805
  function bp_is_activity_heartbeat_active( $default = true ) {
806
-
807
- /**
808
- * Filters whether or not Activity Heartbeat refresh is enabled.
809
- *
810
- * @since BuddyPress (2.0.0)
811
- *
812
- * @param bool $value Whether or not Activity Heartbeat refresh is enabled.
813
- */
814
  return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) );
815
  }
816
 
@@ -826,13 +625,5 @@ function bp_is_activity_heartbeat_active( $default = true ) {
826
  * @return string ID of the theme package.
827
  */
828
  function bp_get_theme_package_id( $default = 'legacy' ) {
829
-
830
- /**
831
- * Filters the current theme package ID.
832
- *
833
- * @since BuddyPress (1.7.0)
834
- *
835
- * @param string $value The current theme package ID.
836
- */
837
  return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $default ) );
838
  }
55
  // Avatar uploads
56
  'bp-disable-avatar-uploads' => false,
57
 
 
 
 
58
  // Allow users to delete their own accounts
59
  'bp-disable-account-deletion' => false,
60
 
100
  'widget_bp_messages_sitewide_notices_widget' => false,
101
  );
102
 
 
 
 
 
 
 
 
103
  return apply_filters( 'bp_get_default_options', $options );
104
  }
105
 
125
  bp_add_option( $key, $value );
126
  }
127
 
128
+ // Allow previously activated plugins to append their own options.
 
 
 
 
 
 
129
  do_action( 'bp_add_options' );
130
  }
131
 
153
  delete_option( $key );
154
  }
155
 
156
+ // Allow previously activated plugins to append their own options.
 
 
 
 
 
 
157
  do_action( 'bp_delete_options' );
158
  }
159
 
178
  add_filter( 'pre_option_' . $key, 'bp_pre_get_option' );
179
  }
180
 
181
+ // Allow previously activated plugins to append their own options.
 
 
 
 
 
 
182
  do_action( 'bp_setup_option_filters' );
183
  }
184
 
187
  *
188
  * Currently unused.
189
  *
190
+ * @since BuddyPress (1.6)
191
  *
192
  * @param bool $value Optional. Default value false
193
  * @return mixed false if not overloaded, mixed if set
218
  *
219
  * The 'bp_get_option' filter is primarily for backward-compatibility.
220
  *
221
+ * @since BuddyPress (1.5.0)
222
  *
223
  * @uses bp_get_root_blog_id()
224
  *
229
  */
230
  function bp_get_option( $option_name, $default = '' ) {
231
  $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default );
 
 
 
 
 
 
 
 
232
  return apply_filters( 'bp_get_option', $value );
233
  }
234
 
296
  * @deprecated 1.6.0
297
  */
298
  function bp_core_activate_site_options( $keys = array() ) {
299
+ global $bp;
300
 
301
  if ( !empty( $keys ) && is_array( $keys ) ) {
 
 
302
  $errors = false;
303
 
304
  foreach ( $keys as $key => $default ) {
353
 
354
  // On Multisite installations, some options must always be fetched from sitemeta
355
  if ( is_multisite() ) {
 
 
 
 
 
 
 
 
356
  $network_options = apply_filters( 'bp_core_network_options', array(
357
  'tags_blog_id' => '0',
358
  'sitewide_tags_blog' => '',
429
  wp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' );
430
  }
431
 
 
 
 
 
 
 
 
432
  return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta );
433
  }
434
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  /** Active? *******************************************************************/
436
 
437
  /**
446
  * @return bool True if profile sync is enabled, otherwise false.
447
  */
448
  function bp_disable_profile_sync( $default = false ) {
 
 
 
 
 
 
 
 
449
  return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) );
450
  }
451
 
462
  * otherwise false.
463
  */
464
  function bp_hide_loggedout_adminbar( $default = true ) {
 
 
 
 
 
 
 
 
465
  return (bool) apply_filters( 'bp_hide_loggedout_adminbar', (bool) bp_get_option( 'hide-loggedout-adminbar', $default ) );
466
  }
467
 
477
  * @return bool True if avatar uploads are disabled, otherwise false.
478
  */
479
  function bp_disable_avatar_uploads( $default = true ) {
 
 
 
 
 
 
 
 
480
  return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
481
  }
482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
  /**
484
  * Are members able to delete their own accounts?
485
  *
493
  * false.
494
  */
495
  function bp_disable_account_deletion( $default = false ) {
 
 
 
 
 
 
 
 
496
  return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $default ) );
497
  }
498
 
510
  * items, otherwise false.
511
  */
512
  function bp_disable_blogforum_comments( $default = false ) {
 
 
 
 
 
 
 
 
513
  return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $default ) );
514
  }
515
 
526
  * @return bool True if group creation is restricted, otherwise false.
527
  */
528
  function bp_restrict_group_creation( $default = true ) {
 
 
 
 
 
 
 
 
529
  return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
530
  }
531
 
541
  * @return bool True if the BuddyBar should be forced on, otherwise false.
542
  */
543
  function bp_force_buddybar( $default = true ) {
 
 
 
 
 
 
 
 
544
  return (bool) apply_filters( 'bp_force_buddybar', (bool) bp_get_option( '_bp_force_buddybar', $default ) );
545
  }
546
 
565
  * @return int The ID of the group forums root forum.
566
  */
567
  function bp_get_group_forums_root_id( $default = '0' ) {
 
 
 
 
 
 
 
 
568
  return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) );
569
  }
570
 
580
  * @return bool True if group forums are active, otherwise false.
581
  */
582
  function bp_is_group_forums_active( $default = true ) {
 
 
 
 
 
 
 
 
583
  return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) );
584
  }
585
 
595
  * @return bool True if Akismet is enabled, otherwise false.
596
  */
597
  function bp_is_akismet_active( $default = true ) {
 
 
 
 
 
 
 
 
598
  return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $default ) );
599
  }
600
 
610
  * @return bool True if Heartbeat refresh is enabled, otherwise false.
611
  */
612
  function bp_is_activity_heartbeat_active( $default = true ) {
 
 
 
 
 
 
 
 
613
  return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) );
614
  }
615
 
625
  * @return string ID of the theme package.
626
  */
627
  function bp_get_theme_package_id( $default = 'legacy' ) {
 
 
 
 
 
 
 
 
628
  return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $default ) );
629
  }
bp-core/bp-core-taxonomy.php CHANGED
@@ -79,31 +79,3 @@ function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
79
 
80
  return $retval;
81
  }
82
-
83
- /**
84
- * Remove taxonomy terms on a BuddyPress object.
85
- *
86
- * @since BuddyPress (2.3.0)
87
- *
88
- * @see wp_remove_object_terms() for a full description of function and parameters.
89
- *
90
- * @param int $object_id Object ID.
91
- * @param string|array $terms Term or terms to remove.
92
- * @param string $taxonomy Taxonomy name.
93
- * @return bool|WP_Error True on success, false or WP_Error on failure.
94
- */
95
- function bp_remove_object_terms( $object_id, $terms, $taxonomy ) {
96
- $is_root_blog = bp_is_root_blog();
97
-
98
- if ( ! $is_root_blog ) {
99
- switch_to_blog( bp_get_root_blog_id() );
100
- }
101
-
102
- $retval = wp_remove_object_terms( $object_id, $terms, $taxonomy );
103
-
104
- if ( ! $is_root_blog ) {
105
- restore_current_blog();
106
- }
107
-
108
- return $retval;
109
- }
79
 
80
  return $retval;
81
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-template-loader.php CHANGED
@@ -32,16 +32,6 @@ defined( 'ABSPATH' ) || exit;
32
  function bp_get_template_part( $slug, $name = null ) {
33
 
34
  // Execute code for this part
35
- /**
36
- * Fires at the start of bp_get_template_part().
37
- *
38
- * This is a variable hook that is dependent on the slug passed in.
39
- *
40
- * @since BuddyPress (1.7.0)
41
- *
42
- * @param string $slug Template part slug requested.
43
- * @param string $name Template part name requested.
44
- */
45
  do_action( 'get_template_part_' . $slug, $slug, $name );
46
 
47
  // Setup possible parts
@@ -52,15 +42,6 @@ function bp_get_template_part( $slug, $name = null ) {
52
  $templates[] = $slug . '.php';
53
 
54
  // Allow template parts to be filtered
55
- /**
56
- * Filters the template parts to be loaded.
57
- *
58
- * @since BuddyPress (1.7.0)
59
- *
60
- * @param array $templates Array of templates located.
61
- * @param string $slug Template part slug requested.
62
- * @param string $name Template part name requested.
63
- */
64
  $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name );
65
 
66
  // Return the part that is found
@@ -234,13 +215,6 @@ function bp_get_template_stack() {
234
  // Remove empties and duplicates
235
  $stack = array_unique( array_filter( $stack ) );
236
 
237
- /**
238
- * Filters the "template stack" list of registered directories where templates can be found.
239
- *
240
- * @since BuddyPress (1.7.0)
241
- *
242
- * @param array $stack Array of registered directories for template locations.
243
- */
244
  return (array) apply_filters( 'bp_get_template_stack', $stack ) ;
245
  }
246
 
@@ -304,41 +278,20 @@ function bp_get_query_template( $type, $templates = array() ) {
304
  $templates = array( "{$type}.php" );
305
  }
306
 
307
- /**
308
- * Filters possible file paths to check for for a template.
309
- *
310
- * This is a variable filter based on the type passed into
311
- * bp_get_query_template.
312
- *
313
- * @since BuddyPress (1.7.0)
314
- *
315
- * @param array $templates Array of template files already prepared.
316
- */
317
- $templates = apply_filters( "bp_get_{$type}_template", $templates );
318
-
319
  // Filter possible templates, try to match one, and set any BuddyPress theme
320
  // compat properties so they can be cross-checked later.
 
321
  $templates = bp_set_theme_compat_templates( $templates );
322
  $template = bp_locate_template( $templates );
323
  $template = bp_set_theme_compat_template( $template );
324
 
325
- /**
326
- * Filters the path to a template file.
327
- *
328
- * This is a variable filter based on the type passed into
329
- * bp_get_query_template.
330
- *
331
- * @since BuddyPress (1.7.0)
332
- *
333
- * @param string $template Path to the most appropriate found template file.
334
- */
335
  return apply_filters( "bp_{$type}_template", $template );
336
  }
337
 
338
  /**
339
  * Get the possible subdirectories to check for templates in
340
  *
341
- * @since BuddyPress (1.7.0)
342
  * @param array $templates Templates we are looking for
343
  * @return array Possible subfolders to look in
344
  */
@@ -348,15 +301,6 @@ function bp_get_template_locations( $templates = array() ) {
348
  'community',
349
  ''
350
  );
351
-
352
- /**
353
- * Filters the possible subdirectories to check for templates in.
354
- *
355
- * @since BuddyPress (1.7.0)
356
- *
357
- * @param array $locations Array of subfolders to look in.
358
- * @param array $templates Array of templates we are looking for.
359
- */
360
  return apply_filters( 'bp_get_template_locations', $locations, $templates );
361
  }
362
 
@@ -381,14 +325,6 @@ function bp_add_template_stack_locations( $stacks = array() ) {
381
  }
382
  }
383
 
384
- /**
385
- * Filters the template locations to template files being searched for.
386
- *
387
- * @since BuddyPress (1.7.0)
388
- *
389
- * @param array $value Array of all template locations registered so far.
390
- * @param array $stacks Array of template locations.
391
- */
392
  return apply_filters( 'bp_add_template_stack_locations', array_unique( $retval ), $stacks );
393
  }
394
 
@@ -416,15 +352,7 @@ function bp_parse_query( $posts_query ) {
416
  return;
417
  }
418
 
419
- /**
420
- * Fires at the end of the bp_parse_query function.
421
- *
422
- * Allow BuddyPress components to parse the main query.
423
- *
424
- * @since BuddyPress (1.7.0)
425
- *
426
- * @param WP_Query $posts_query WP_Query instance. Passed by reference.
427
- */
428
  do_action_ref_array( 'bp_parse_query', array( &$posts_query ) );
429
  }
430
 
@@ -445,14 +373,7 @@ function bp_parse_query( $posts_query ) {
445
  */
446
  function bp_template_include_theme_supports( $template = '' ) {
447
 
448
- /**
449
- * Filters whether or not to override the template being loaded in parent/child themes.
450
- *
451
- * @since BuddyPress (1.7.0)
452
- *
453
- * @param bool $value Whether or not there is a file override. Default false.
454
- * @param string $template The path to the template file that is being used.
455
- */
456
  $new_template = apply_filters( 'bp_get_root_template', false, $template );
457
 
458
  // A BuddyPress template file was located, so override the WordPress
@@ -461,13 +382,6 @@ function bp_template_include_theme_supports( $template = '' ) {
461
  $template = bp_set_template_included( $new_template );
462
  }
463
 
464
- /**
465
- * Filters the final template being loaded in parent/child themes.
466
- *
467
- * @since BuddyPress (1.7.0)
468
- *
469
- * @param string $template The path to the template file that is being used.
470
- */
471
  return apply_filters( 'bp_template_include_theme_supports', $template );
472
  }
473
 
32
  function bp_get_template_part( $slug, $name = null ) {
33
 
34
  // Execute code for this part
 
 
 
 
 
 
 
 
 
 
35
  do_action( 'get_template_part_' . $slug, $slug, $name );
36
 
37
  // Setup possible parts
42
  $templates[] = $slug . '.php';
43
 
44
  // Allow template parts to be filtered
 
 
 
 
 
 
 
 
 
45
  $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name );
46
 
47
  // Return the part that is found
215
  // Remove empties and duplicates
216
  $stack = array_unique( array_filter( $stack ) );
217
 
 
 
 
 
 
 
 
218
  return (array) apply_filters( 'bp_get_template_stack', $stack ) ;
219
  }
220
 
278
  $templates = array( "{$type}.php" );
279
  }
280
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  // Filter possible templates, try to match one, and set any BuddyPress theme
282
  // compat properties so they can be cross-checked later.
283
+ $templates = apply_filters( "bp_get_{$type}_template", $templates );
284
  $templates = bp_set_theme_compat_templates( $templates );
285
  $template = bp_locate_template( $templates );
286
  $template = bp_set_theme_compat_template( $template );
287
 
 
 
 
 
 
 
 
 
 
 
288
  return apply_filters( "bp_{$type}_template", $template );
289
  }
290
 
291
  /**
292
  * Get the possible subdirectories to check for templates in
293
  *
294
+ * @since BuddyPress (1.7)
295
  * @param array $templates Templates we are looking for
296
  * @return array Possible subfolders to look in
297
  */
301
  'community',
302
  ''
303
  );
 
 
 
 
 
 
 
 
 
304
  return apply_filters( 'bp_get_template_locations', $locations, $templates );
305
  }
306
 
325
  }
326
  }
327
 
 
 
 
 
 
 
 
 
328
  return apply_filters( 'bp_add_template_stack_locations', array_unique( $retval ), $stacks );
329
  }
330
 
352
  return;
353
  }
354
 
355
+ // Allow BuddyPress components to parse the main query
 
 
 
 
 
 
 
 
356
  do_action_ref_array( 'bp_parse_query', array( &$posts_query ) );
357
  }
358
 
373
  */
374
  function bp_template_include_theme_supports( $template = '' ) {
375
 
376
+ // Look for root BuddyPress template files in parent/child themes
 
 
 
 
 
 
 
377
  $new_template = apply_filters( 'bp_get_root_template', false, $template );
378
 
379
  // A BuddyPress template file was located, so override the WordPress
382
  $template = bp_set_template_included( $new_template );
383
  }
384
 
 
 
 
 
 
 
 
385
  return apply_filters( 'bp_template_include_theme_supports', $template );
386
  }
387
 
bp-core/bp-core-template.php CHANGED
@@ -71,18 +71,8 @@ function bp_get_options_nav( $parent_slug = '' ) {
71
  // List type depends on our current component
72
  $list_type = bp_is_group() ? 'groups' : 'personal';
73
 
74
- /**
75
- * Filters the "options nav", the secondary-level single item navigation menu.
76
- *
77
- * This is a dynamic filter that is dependent on the provided css_id value.
78
- *
79
- * @since BuddyPress (1.1.0)
80
- *
81
- * @param string $value HTML list item for the submenu item.
82
- * @param array $subnav_item Submenu array item being displayed.
83
- * @param string $selected_item Current action.
84
- */
85
- echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . esc_attr( $subnav_item['css_id'] . '-' . $list_type . '-li' ) . '" ' . $selected . '><a id="' . esc_attr( $subnav_item['css_id'] ) . '" href="' . esc_url( $subnav_item['link'] ) . '">' . $subnav_item['name'] . '</a></li>', $subnav_item, $selected_item );
86
  }
87
  }
88
 
@@ -124,14 +114,6 @@ function bp_get_directory_title( $component = '' ) {
124
  $title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
125
  }
126
 
127
- /**
128
- * Filters the directory title for a component.
129
- *
130
- * @since BuddyPress (2.0.0)
131
- *
132
- * @param string $title Text to be used in <title> tag.
133
- * @param string $component Current componet being displayed.
134
- */
135
  return apply_filters( 'bp_get_directory_title', $title, $component );
136
  }
137
 
@@ -218,13 +200,6 @@ function bp_avatar_admin_step() {
218
  ? $step = $bp->avatar_admin->step
219
  : 'upload-image';
220
 
221
- /**
222
- * Filters the current avatar upload step.
223
- *
224
- * @since BuddyPress (1.1.0)
225
- *
226
- * @param string $step The current avatar upload step.
227
- */
228
  return apply_filters( 'bp_get_avatar_admin_step', $step );
229
  }
230
 
@@ -245,13 +220,6 @@ function bp_avatar_to_crop() {
245
  ? $bp->avatar_admin->image->url
246
  : '';
247
 
248
- /**
249
- * Filters the URL of the avatar to crop.
250
- *
251
- * @since BuddyPress (1.1.0)
252
- *
253
- * @param string $url URL for the avatar.
254
- */
255
  return apply_filters( 'bp_get_avatar_to_crop', $url );
256
  }
257
 
@@ -272,13 +240,6 @@ function bp_avatar_to_crop_src() {
272
  ? str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir )
273
  : '';
274
 
275
- /**
276
- * Filters the relative file path to the avatar to crop.
277
- *
278
- * @since BuddyPress (1.1.0)
279
- *
280
- * @param string $src Relative file path for the avatar.
281
- */
282
  return apply_filters( 'bp_get_avatar_to_crop_src', $src );
283
  }
284
 
@@ -307,96 +268,49 @@ function bp_site_name() {
307
  * @since BuddyPress (1.6.0)
308
  */
309
  function bp_get_site_name() {
310
-
311
- /**
312
- * Filters the name of the BP site. Used in RSS headers.
313
- *
314
- * @since BuddyPress (1.0.0)
315
- *
316
- * @param string $value Current BP site name.
317
- */
318
  return apply_filters( 'bp_site_name', get_bloginfo( 'name', 'display' ) );
319
  }
320
 
321
  /**
322
- * Format a date based on a UNIX timestamp
323
  *
324
- * This function can be used to turn a UNIX timestamp into a properly formatted
325
- * (and possibly localized) string, userful for ouputting the date & time an
326
- * action took place.
327
- *
328
- * Not to be confused with `bp_core_time_since()`, this function is best used
329
- * for displaying a more exact date and time vs. a human-readable time.
330
- *
331
- * Note: This function may be improved or removed at a later date, as it is
332
- * hardly used and adds an additional layer of complexity to calculating dates
333
- * and times together with timezone offsets and i18n.
334
- *
335
- * @since BuddyPress (1.1.0)
336
- *
337
- * @param int $time The UNIX timestamp to be formatted.
338
- * @param bool $exclude_time Optional. True to return only the month + day, false
339
- * to return month, day, and time. Default: false.
340
- * @param bool $gmt Optional. True to display in local time, false to
341
- * leave in GMT. Default: true.
342
- *
343
- * @return mixed A string representation of $time, in the format
344
- * "March 18, 2014 at 2:00 pm" (or whatever your
345
- * 'date_format' and 'time_format' settings are
346
- * on your root blog). False on failure.
347
  */
348
- function bp_format_time( $time = '', $exclude_time = false, $gmt = true ) {
349
 
350
- // Bail if time is empty or not numeric
351
- // @todo We should output something smarter here
352
- if ( empty( $time ) || ! is_numeric( $time ) ) {
353
  return false;
354
  }
355
 
356
  // Get GMT offset from root blog
357
- if ( true === $gmt ) {
358
-
359
- // Use Timezone string if set
360
- $timezone_string = bp_get_option( 'timezone_string' );
361
- if ( ! empty( $timezone_string ) ) {
362
- $timezone_object = timezone_open( $timezone_string );
363
- $datetime_object = date_create( "@{$time}" );
364
- $timezone_offset = timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS;
365
-
366
- // Fall back on less reliable gmt_offset
367
- } else {
368
- $timezone_offset = bp_get_option( 'gmt_offset' );
369
- }
370
-
371
- // Calculate time based on the offset
372
- $calculated_time = $time + ( $timezone_offset * HOUR_IN_SECONDS );
373
-
374
- // No localizing, so just use the time that was submitted
375
- } else {
376
- $calculated_time = $time;
377
  }
378
 
379
- // Formatted date: "March 18, 2014"
380
- $formatted_date = date_i18n( bp_get_option( 'date_format' ), $calculated_time, $gmt );
381
 
382
- // Should we show the time also?
383
- if ( true !== $exclude_time ) {
384
 
385
- // Formatted time: "2:00 pm"
386
- $formatted_time = date_i18n( bp_get_option( 'time_format' ), $calculated_time, $gmt );
 
 
387
 
388
  // Return string formatted with date and time
389
- $formatted_date = sprintf( esc_html__( '%1$s at %2$s', 'buddypress' ), $formatted_date, $formatted_time );
390
  }
391
 
392
- /**
393
- * Filters the date based on a UNIX timestamp.
394
- *
395
- * @since BuddyPress (1.0.0)
396
- *
397
- * @param string $formatted_date Formatted date from the timestamp.
398
- */
399
- return apply_filters( 'bp_format_time', $formatted_date );
400
  }
401
 
402
  /**
@@ -425,18 +339,8 @@ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true
425
 
426
  if ( bp_displayed_user_id() == bp_loggedin_user_id() ) {
427
  if ( true == $echo ) {
428
-
429
- /**
430
- * Filters the text used based on context of own profile or someone else's profile.
431
- *
432
- * @since BuddyPress (1.0.0)
433
- *
434
- * @param string $youtext Context-determined string to display.
435
- */
436
  echo apply_filters( 'bp_word_or_name', $youtext );
437
  } else {
438
-
439
- /** This filter is documented in bp-core/bp-core-template.php */
440
  return apply_filters( 'bp_word_or_name', $youtext );
441
  }
442
  } else {
@@ -444,12 +348,8 @@ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true
444
  $fullname = (array) explode( ' ', $fullname );
445
  $nametext = sprintf( $nametext, $fullname[0] );
446
  if ( true == $echo ) {
447
-
448
- /** This filter is documented in bp-core/bp-core-template.php */
449
  echo apply_filters( 'bp_word_or_name', $nametext );
450
  } else {
451
-
452
- /** This filter is documented in bp-core/bp-core-template.php */
453
  return apply_filters( 'bp_word_or_name', $nametext );
454
  }
455
  }
@@ -475,14 +375,6 @@ function bp_styles() {
475
  * @return string URL action attribute for search forms, eg example.com/search/.
476
  */
477
  function bp_search_form_action() {
478
-
479
- /**
480
- * Filters the "action" attribute for search forms.
481
- *
482
- * @since BuddyPress (1.0.0)
483
- *
484
- * @param string $value Search form action url.
485
- */
486
  return apply_filters( 'bp_search_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_search_slug() ) );
487
  }
488
 
@@ -519,13 +411,6 @@ function bp_search_form_type_select() {
519
  $selection_box = '<label for="search-which" class="accessibly-hidden">' . _x( 'Search these:', 'search form', 'buddypress' ) . '</label>';
520
  $selection_box .= '<select name="search-which" id="search-which" style="width: auto">';
521
 
522
- /**
523
- * Filters all of the component options available for search scope.
524
- *
525
- * @since BuddyPress (1.5.0)
526
- *
527
- * @param array $options Array of options to add to select field.
528
- */
529
  $options = apply_filters( 'bp_search_form_type_select_options', $options );
530
  foreach( (array) $options as $option_value => $option_title ) {
531
  $selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title );
@@ -533,13 +418,6 @@ function bp_search_form_type_select() {
533
 
534
  $selection_box .= '</select>';
535
 
536
- /**
537
- * Filters the complete <select> input used for search scope.
538
- *
539
- * @since BuddyPress (1.0.0)
540
- *
541
- * @param string $selection_box <select> input for selecting search scope.
542
- */
543
  return apply_filters( 'bp_search_form_type_select', $selection_box );
544
  }
545
 
@@ -564,8 +442,7 @@ function bp_search_default_text( $component = '' ) {
564
  * @return string Placeholder text for search field.
565
  */
566
  function bp_get_search_default_text( $component = '' ) {
567
-
568
- $bp = buddypress();
569
 
570
  if ( empty( $component ) ) {
571
  $component = bp_current_component();
@@ -589,14 +466,6 @@ function bp_search_default_text( $component = '' ) {
589
  }
590
  }
591
 
592
- /**
593
- * Filters the default text for the search box for a given component.
594
- *
595
- * @since BuddyPress (1.5.0)
596
- *
597
- * @param string $default_text Default text for search box.
598
- * @param string $component Current component displayed.
599
- */
600
  return apply_filters( 'bp_get_search_default_text', $default_text, $component );
601
  }
602
 
@@ -716,16 +585,6 @@ function bp_button( $args = '' ) {
716
  */
717
  function bp_get_button( $args = '' ) {
718
  $button = new BP_Button( $args );
719
-
720
- /**
721
- * Filters the requested button output.
722
- *
723
- * @since BuddyPress (1.2.6)
724
- *
725
- * @param string $contents Button context to be used.
726
- * @param array $args Array of args for the button.
727
- * @param BP_Button $button BP_Button object.
728
- */
729
  return apply_filters( 'bp_get_button', $button->contents, $args, $button );
730
  }
731
 
@@ -776,22 +635,8 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
776
  // Save the original text, to be passed along to the filter
777
  $original_text = $text;
778
 
779
- /**
780
- * Filters the excerpt length to trim text to.
781
- *
782
- * @since BuddyPress (1.5.0)
783
- *
784
- * @param int $length Length of returned string, including ellipsis.
785
- */
786
  $length = apply_filters( 'bp_excerpt_length', $length );
787
-
788
- /**
789
- * Filters the excerpt appended text value.
790
- *
791
- * @since BuddyPress (1.5.0)
792
- *
793
- * @param string $value Text to append to the end of the excerpt.
794
- */
795
  $ending = apply_filters( 'bp_excerpt_append_text', $r['ending'] );
796
 
797
  // Remove shortcodes if necessary
@@ -812,10 +657,10 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
812
  $openTags = array();
813
  $truncate = '';
814
 
815
- // Find all the tags and HTML comments and put them in a stack for later use
816
- preg_match_all( '/(<\/?([\w+!]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER );
817
-
818
  foreach ( $tags as $tag ) {
 
819
  // Process tags that need to be closed
820
  if ( !preg_match( '/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s', $tag[2] ) ) {
821
  if ( preg_match( '/<[\w]+[^>]*>/s', $tag[0] ) ) {
@@ -865,70 +710,21 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
865
 
866
  // If $exact is false, we can't break on words
867
  if ( empty( $r['exact'] ) ) {
868
- // Find the position of the last space character not part of a tag.
869
- preg_match_all( '/<[a-z\!\/][^>]*>/', $truncate, $_truncate_tags, PREG_OFFSET_CAPTURE );
870
-
871
- // Rekey tags by the string index of their last character.
872
- $truncate_tags = array();
873
- if ( ! empty( $_truncate_tags[0] ) ) {
874
- foreach ( $_truncate_tags[0] as $_tt ) {
875
- $_tt['start'] = $_tt[1];
876
- $_tt['end'] = $_tt[1] + strlen( $_tt[0] );
877
- $truncate_tags[ $_tt['end'] ] = $_tt;
878
- }
879
- }
880
-
881
- $truncate_length = mb_strlen( $truncate );
882
- $spacepos = $truncate_length + 1;
883
- for ( $pos = $truncate_length - 1; $pos >= 0; $pos-- ) {
884
- // Word boundaries are spaces and the close of HTML tags, when the tag is preceded by a space.
885
- $is_word_boundary = ' ' === $truncate[ $pos ];
886
- if ( ! $is_word_boundary && isset( $truncate_tags[ $pos - 1 ] ) ) {
887
- $preceding_tag = $truncate_tags[ $pos - 1 ];
888
- if ( ' ' === $truncate[ $preceding_tag['start'] - 1 ] ) {
889
- $is_word_boundary = true;
890
- break;
891
- }
892
- }
893
-
894
- if ( ! $is_word_boundary ) {
895
- continue;
896
- }
897
-
898
- // If there are no tags in the string, the first space found is the right one.
899
- if ( empty( $truncate_tags ) ) {
900
- $spacepos = $pos;
901
- break;
902
- }
903
-
904
- // Look at each tag to see if the space is inside of it.
905
- $intag = false;
906
- foreach ( $truncate_tags as $tt ) {
907
- if ( $pos > $tt['start'] && $pos < $tt['end'] ) {
908
- $intag = true;
909
- break;
910
- }
911
- }
912
-
913
- if ( ! $intag ) {
914
- $spacepos = $pos;
915
- break;
916
- }
917
- }
918
-
919
- if ( $r['html'] ) {
920
- $bits = mb_substr( $truncate, $spacepos );
921
- preg_match_all( '/<\/([a-z]+)>/', $bits, $droppedTags, PREG_SET_ORDER );
922
- if ( !empty( $droppedTags ) ) {
923
- foreach ( $droppedTags as $closingTag ) {
924
- if ( !in_array( $closingTag[1], $openTags ) ) {
925
- array_unshift( $openTags, $closingTag[1] );
926
  }
927
  }
928
  }
 
929
  }
930
-
931
- $truncate = rtrim( mb_substr( $truncate, 0, $spacepos ) );
932
  }
933
  $truncate .= $ending;
934
 
@@ -938,16 +734,6 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
938
  }
939
  }
940
 
941
- /**
942
- * Filters the final generated excerpt.
943
- *
944
- * @since BuddyPress (1.1.0)
945
- *
946
- * @param string $truncate Generated excerpt.
947
- * @param string $original_text Original text provided.
948
- * @param int $length Length of returned string, including ellipsis.
949
- * @param array $options Array of HTML attributes and options.
950
- */
951
  return apply_filters( 'bp_create_excerpt', $truncate, $original_text, $length, $options );
952
  }
953
  add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
@@ -974,14 +760,6 @@ function bp_total_member_count() {
974
  * @return int Member count.
975
  */
976
  function bp_get_total_member_count() {
977
-
978
- /**
979
- * Filters the total member count in your BP instance.
980
- *
981
- * @since BuddyPress (1.2.0)
982
- *
983
- * @param int $value Member count.
984
- */
985
  return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() );
986
  }
987
  add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
@@ -1008,7 +786,7 @@ function bp_blog_signup_allowed() {
1008
  return false;
1009
  }
1010
 
1011
- $status = bp_core_get_root_option( 'registration' );
1012
  if ( ( 'none' !== $status ) && ( 'user' !== $status ) ) {
1013
  return true;
1014
  }
@@ -1041,14 +819,6 @@ function bp_account_was_activated() {
1041
  * @return bool True by default.
1042
  */
1043
  function bp_registration_needs_activation() {
1044
-
1045
- /**
1046
- * Filters whether registrations require activation on this installation.
1047
- *
1048
- * @since BuddyPress (1.2.0)
1049
- *
1050
- * @param bool $value Whether registrations require activation. Default true.
1051
- */
1052
  return apply_filters( 'bp_registration_needs_activation', true );
1053
  }
1054
 
@@ -1060,7 +830,7 @@ function bp_registration_needs_activation() {
1060
  *
1061
  * @since BuddyPress (1.7.0)
1062
  *
1063
- * @see https://buddypress.trac.wordpress.org/ticket/4401
1064
  *
1065
  * @param array $args {
1066
  * Array of optional parameters.
@@ -1086,14 +856,6 @@ function bp_get_email_subject( $args = array() ) {
1086
 
1087
  $subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text'];
1088
 
1089
- /**
1090
- * Filters a client friendly version of the root blog name.
1091
- *
1092
- * @since BuddyPress (1.7.0)
1093
- *
1094
- * @param string $subject Client friendy version of the root blog name.
1095
- * @param array $r Array of arguments for the email subject.
1096
- */
1097
  return apply_filters( 'bp_get_email_subject', $subject, $r );
1098
  }
1099
 
@@ -1117,16 +879,6 @@ function bp_ajax_querystring( $object = false ) {
1117
  $bp->ajax_querystring = '';
1118
  }
1119
 
1120
- /**
1121
- * Filters the template paramenters to be used in the query string.
1122
- *
1123
- * Allows templates to pass parameters into the template loops via AJAX.
1124
- *
1125
- * @since BuddyPress (1.2.0)
1126
- *
1127
- * @param string $ajax_querystring Current query string.
1128
- * @param string $object Current template component.
1129
- */
1130
  return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object );
1131
  }
1132
 
@@ -1143,13 +895,6 @@ function bp_current_component() {
1143
  ? $bp->current_component
1144
  : false;
1145
 
1146
- /**
1147
- * Filters the name of the current component.
1148
- *
1149
- * @since BuddyPress (1.0.0)
1150
- *
1151
- * @param string|bool $current_component Current component if available or false.
1152
- */
1153
  return apply_filters( 'bp_current_component', $current_component );
1154
  }
1155
 
@@ -1164,13 +909,6 @@ function bp_current_action() {
1164
  ? $bp->current_action
1165
  : '';
1166
 
1167
- /**
1168
- * Filters the name of the current action.
1169
- *
1170
- * @since BuddyPress (1.0.0)
1171
- *
1172
- * @param string $current_action Current action.
1173
- */
1174
  return apply_filters( 'bp_current_action', $current_action );
1175
  }
1176
 
@@ -1185,13 +923,6 @@ function bp_current_item() {
1185
  ? $bp->current_item
1186
  : false;
1187
 
1188
- /**
1189
- * Filters the name of the current item.
1190
- *
1191
- * @since BuddyPress (1.1.0)
1192
- *
1193
- * @param string|bool $current_item Current item if available or false.
1194
- */
1195
  return apply_filters( 'bp_current_item', $current_item );
1196
  }
1197
 
@@ -1207,13 +938,6 @@ function bp_action_variables() {
1207
  ? $bp->action_variables
1208
  : false;
1209
 
1210
- /**
1211
- * Filters the value of $bp->action_variables.
1212
- *
1213
- * @since BuddyPress (1.0.0)
1214
- *
1215
- * @param array|bool $action_variables Available action variables.
1216
- */
1217
  return apply_filters( 'bp_action_variables', $action_variables );
1218
  }
1219
 
@@ -1232,14 +956,6 @@ function bp_action_variable( $position = 0 ) {
1232
  ? $action_variables[ $position ]
1233
  : false;
1234
 
1235
- /**
1236
- * Filters the value of a given action variable.
1237
- *
1238
- * @since BuddyPress (1.5.0)
1239
- *
1240
- * @param string|bool $action_variable Requested action variable based on position.
1241
- * @param int $position The key of the action variable requested.
1242
- */
1243
  return apply_filters( 'bp_action_variable', $action_variable, $position );
1244
  }
1245
 
@@ -1264,13 +980,6 @@ function bp_root_domain() {
1264
  $bp->root_domain = $domain;
1265
  }
1266
 
1267
- /**
1268
- * Filters the "root domain", the URL of the BP root blog.
1269
- *
1270
- * @since BuddyPress (1.2.4)
1271
- *
1272
- * @param string $domain URL of the BP root blog.
1273
- */
1274
  return apply_filters( 'bp_get_root_domain', $domain );
1275
  }
1276
 
@@ -1343,14 +1052,6 @@ function bp_root_slug( $component = '' ) {
1343
  $root_slug = $component;
1344
  }
1345
 
1346
- /**
1347
- * Filters the root slug for given component.
1348
- *
1349
- * @since BuddyPress (1.5.0)
1350
- *
1351
- * @param string $root_slug Root slug for given component.
1352
- * @param string $component Current component.
1353
- */
1354
  return apply_filters( 'bp_get_root_slug', $root_slug, $component );
1355
  }
1356
 
@@ -1390,13 +1091,6 @@ function bp_user_has_access() {
1390
  ? true
1391
  : false;
1392
 
1393
- /**
1394
- * Filters whether or not a user has access.
1395
- *
1396
- * @since BuddyPress (1.2.4)
1397
- *
1398
- * @param bool $has_access Whether or not user has access.
1399
- */
1400
  return (bool) apply_filters( 'bp_user_has_access', $has_access );
1401
  }
1402
 
@@ -1418,14 +1112,6 @@ function bp_search_slug() {
1418
  * @return string The search slug. Default: 'search'.
1419
  */
1420
  function bp_get_search_slug() {
1421
-
1422
- /**
1423
- * Filters the search slug.
1424
- *
1425
- * @since BuddyPress (1.5.0)
1426
- *
1427
- * @param string BP_SEARCH_SLUG The search slug. Default "search".
1428
- */
1429
  return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
1430
  }
1431
 
@@ -1442,13 +1128,6 @@ function bp_displayed_user_id() {
1442
  ? $bp->displayed_user->id
1443
  : 0;
1444
 
1445
- /**
1446
- * Filters the ID of the currently displayed user.
1447
- *
1448
- * @since BuddyPress (1.0.0)
1449
- *
1450
- * @param int $id ID of the currently displayed user.
1451
- */
1452
  return (int) apply_filters( 'bp_displayed_user_id', $id );
1453
  }
1454
 
@@ -1465,13 +1144,6 @@ function bp_loggedin_user_id() {
1465
  ? $bp->loggedin_user->id
1466
  : 0;
1467
 
1468
- /**
1469
- * Filters the ID of the currently logged-in user.
1470
- *
1471
- * @since BuddyPress (1.0.0)
1472
- *
1473
- * @param int $id ID of the currently logged-in user.
1474
- */
1475
  return (int) apply_filters( 'bp_loggedin_user_id', $id );
1476
  }
1477
 
@@ -1551,14 +1223,6 @@ function bp_is_current_component( $component = '' ) {
1551
  }
1552
  }
1553
 
1554
- /**
1555
- * Filters whether the current page belongs to the specified component.
1556
- *
1557
- * @since BuddyPress (1.5.0)
1558
- *
1559
- * @param bool $is_current_component Whether or not the current page belongs to specified component.
1560
- * @param string $component Name of the component being checked.
1561
- */
1562
  return apply_filters( 'bp_is_current_component', $is_current_component, $component );
1563
  }
1564
 
@@ -1620,15 +1284,6 @@ function bp_is_action_variable( $action_variable = '', $position = false ) {
1620
  $is_action_variable = in_array( $action_variable, (array)bp_action_variables() );
1621
  }
1622
 
1623
- /**
1624
- * Filters whether the current page matches a given action_variable.
1625
- *
1626
- * @since BuddyPress (1.5.0)
1627
- *
1628
- * @param bool $is_action_variable Whether the current page matches a given action_variable.
1629
- * @param string $action_variable The action_variable being tested against.
1630
- * @param int $position The array key tested against.
1631
- */
1632
  return apply_filters( 'bp_is_action_variable', $is_action_variable, $action_variable, $position );
1633
  }
1634
 
@@ -1641,14 +1296,6 @@ function bp_is_action_variable( $action_variable = '', $position = false ) {
1641
  function bp_is_current_item( $item = '' ) {
1642
  $retval = ( $item === bp_current_item() );
1643
 
1644
- /**
1645
- * Filters whether or not an item is the current item.
1646
- *
1647
- * @since BuddyPress (2.1.0)
1648
- *
1649
- * @param bool $retval Whether or not an item is the current item.
1650
- * @param string $item The item being checked.
1651
- */
1652
  return (bool) apply_filters( 'bp_is_current_item', $retval, $item );
1653
  }
1654
 
@@ -1665,13 +1312,6 @@ function bp_is_single_item() {
1665
  $retval = $bp->is_single_item;
1666
  }
1667
 
1668
- /**
1669
- * Filters whether or not an item is the a single item. (group, user, etc)
1670
- *
1671
- * @since BuddyPress (2.1.0)
1672
- *
1673
- * @param bool $retval Whether or not an item is a single item.
1674
- */
1675
  return (bool) apply_filters( 'bp_is_single_item', $retval );
1676
  }
1677
 
@@ -1689,13 +1329,6 @@ function bp_is_item_admin() {
1689
  $retval = $bp->is_item_admin;
1690
  }
1691
 
1692
- /**
1693
- * Filters whether or not the logged-in user is an admin for the current item.
1694
- *
1695
- * @since BuddyPress (2.1.0)
1696
- *
1697
- * @param bool $retval Whether or not the logged-in user is an admin.
1698
- */
1699
  return (bool) apply_filters( 'bp_is_item_admin', $retval );
1700
  }
1701
 
@@ -1713,13 +1346,6 @@ function bp_is_item_mod() {
1713
  $retval = $bp->is_item_mod;
1714
  }
1715
 
1716
- /**
1717
- * Filters whether or not the logged-in user is a mod for the current item.
1718
- *
1719
- * @since BuddyPress (2.1.0)
1720
- *
1721
- * @param bool $retval Whether or not the logged-in user is a mod.
1722
- */
1723
  return (bool) apply_filters( 'bp_is_item_mod', $retval );
1724
  }
1725
 
@@ -1737,13 +1363,6 @@ function bp_is_directory() {
1737
  $retval = $bp->is_directory;
1738
  }
1739
 
1740
- /**
1741
- * Filters whether or not user is on a component directory page.
1742
- *
1743
- * @since BuddyPress (2.1.0)
1744
- *
1745
- * @param bool $retval Whether or not user is on a component directory page.
1746
- */
1747
  return (bool) apply_filters( 'bp_is_directory', $retval );
1748
  }
1749
 
@@ -1777,13 +1396,6 @@ function bp_is_root_component( $component_name = '' ) {
1777
  }
1778
  }
1779
 
1780
- /**
1781
- * Filters whether or not a component's URL should be in the root, not under a member page.
1782
- *
1783
- * @since BuddyPress (2.1.0)
1784
- *
1785
- * @param bool $retval Whether or not URL should be in the root.
1786
- */
1787
  return (bool) apply_filters( 'bp_is_root_component', $retval );
1788
  }
1789
 
@@ -1824,14 +1436,6 @@ function bp_is_component_front_page( $component = '' ) {
1824
  return false;
1825
  }
1826
 
1827
- /**
1828
- * Filters whether or not the specified BuddyPress component directory is set to be the front page.
1829
- *
1830
- * @since BuddyPress (1.5.0)
1831
- *
1832
- * @param bool $value Whether or not the specified component directory is set as front page.
1833
- * @param string $component Current component being checked.
1834
- */
1835
  return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );
1836
  }
1837
 
@@ -1854,13 +1458,6 @@ function bp_is_blog_page() {
1854
  $is_blog_page = true;
1855
  }
1856
 
1857
- /**
1858
- * Filters whether or not current page is a blog page or not.
1859
- *
1860
- * @since BuddyPress (1.5.0)
1861
- *
1862
- * @param bool $is_blog_page Whether or not current page is a blog page.
1863
- */
1864
  return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page );
1865
  }
1866
 
@@ -1881,29 +1478,18 @@ function bp_is_blog_page() {
1881
  function is_buddypress() {
1882
  $retval = (bool) ( bp_current_component() || bp_is_user() );
1883
 
1884
- /**
1885
- * Filters whether or not this is a BuddyPress component.
1886
- *
1887
- * @since BuddyPress (1.7.0)
1888
- *
1889
- * @param bool $retval Whether or not this is a BuddyPress component.
1890
- */
1891
  return apply_filters( 'is_buddypress', $retval );
1892
  }
1893
 
1894
  /** Components ****************************************************************/
1895
 
1896
  /**
1897
- * Check whether a given component (or feature of a component) is active.
1898
- *
1899
- * @since BuddyPress (1.2.0) See r2539.
1900
- * @since BuddyPress (2.3.0) Added $feature as a parameter.
1901
  *
1902
  * @param string $component The component name.
1903
- * @param string $feature The feature name.
1904
- * @return bool
1905
  */
1906
- function bp_is_active( $component = '', $feature = '' ) {
1907
  $retval = false;
1908
 
1909
  // Default to the current component if none is passed
@@ -1914,32 +1500,8 @@ function bp_is_active( $component = '', $feature = '' ) {
1914
  // Is component in either the active or required components arrays
1915
  if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
1916
  $retval = true;
1917
-
1918
- // Is feature active?
1919
- if ( ! empty( $feature ) ) {
1920
- if ( empty( buddypress()->$component->features ) || false === in_array( $feature, buddypress()->$component->features, true ) ) {
1921
- $retval = false;
1922
- }
1923
-
1924
- /**
1925
- * Filters whether or not a given feature for a component is active.
1926
- *
1927
- * @since BuddyPress (2.3.0)
1928
- *
1929
- * @param bool $retval
1930
- */
1931
- $retval = apply_filters( "bp_is_{$component}_{$feature}_active", $retval );
1932
- }
1933
  }
1934
 
1935
- /**
1936
- * Filters whether or not a given component has been activated by the admin.
1937
- *
1938
- * @since BuddyPress (2.1.0)
1939
- *
1940
- * @param bool $retval Whether or not a given component has been activated by the admin.
1941
- * @param string $component Current component being checked.
1942
- */
1943
  return apply_filters( 'bp_is_active', $retval, $component );
1944
  }
1945
 
@@ -2118,13 +1680,6 @@ function bp_is_my_profile() {
2118
  $my_profile = false;
2119
  }
2120
 
2121
- /**
2122
- * Filters whether or not current page is part of the profile for the logged-in user.
2123
- *
2124
- * @since BuddyPress (1.2.4)
2125
- *
2126
- * @param bool $my_profile Whether or not current page is part of the profile for the logged-in user.
2127
- */
2128
  return apply_filters( 'bp_is_my_profile', $my_profile );
2129
  }
2130
 
@@ -2946,16 +2501,6 @@ function bp_the_body_class() {
2946
  // Merge WP classes with BuddyPress classes and remove any duplicates
2947
  $classes = array_unique( array_merge( (array) $bp_classes, (array) $wp_classes ) );
2948
 
2949
- /**
2950
- * Filters the BuddyPress classes to be added to body_class()
2951
- *
2952
- * @since BuddyPress (1.1.0)
2953
- *
2954
- * @param array $classes Array of body classes to add.
2955
- * @param array $bp_classes Array of BuddyPress-based classes.
2956
- * @param array $wp_classes Array of WordPress-based classes.
2957
- * @param array $custom_classes Array of classes that were passed to get_body_class().
2958
- */
2959
  return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
2960
  }
2961
  add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );
@@ -3105,7 +2650,7 @@ function bp_get_nav_menu_items() {
3105
  continue;
3106
  }
3107
 
3108
- // Get the correct menu link. See https://buddypress.trac.wordpress.org/ticket/4624
3109
  $link = bp_loggedin_user_domain() ? str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav['link'] ) : trailingslashit( bp_displayed_user_domain() . $nav['link'] );
3110
 
3111
  // Add this menu
@@ -3124,13 +2669,6 @@ function bp_get_nav_menu_items() {
3124
  $menus[] = $menu;
3125
  }
3126
 
3127
- /**
3128
- * Filters the items registered in the primary and secondary BuddyPress navigation menus.
3129
- *
3130
- * @since BuddyPress (1.7.0)
3131
- *
3132
- * @param array $menus Array of items registered in the primary and secondary BuddyPress navigation.
3133
- */
3134
  return apply_filters( 'bp_get_nav_menu_items', $menus );
3135
  }
3136
 
@@ -3190,14 +2728,6 @@ function bp_nav_menu( $args = array() ) {
3190
  'walker' => '',
3191
  );
3192
  $args = wp_parse_args( $args, $defaults );
3193
-
3194
- /**
3195
- * Filters the parsed bp_nav_menu arguments.
3196
- *
3197
- * @since BuddyPress (1.7.0)
3198
- *
3199
- * @param array $args Array of parsed arguments.
3200
- */
3201
  $args = apply_filters( 'bp_nav_menu_args', $args );
3202
  $args = (object) $args;
3203
 
@@ -3215,14 +2745,6 @@ function bp_nav_menu( $args = array() ) {
3215
 
3216
  // Whether to wrap the ul, and what to wrap it with
3217
  if ( $args->container ) {
3218
-
3219
- /**
3220
- * Filters the allowed tags for the wp_nav_menu_container.
3221
- *
3222
- * @since BuddyPress (1.7.0)
3223
- *
3224
- * @param array $value Array of allowed tags. Default 'div' and 'nav'.
3225
- */
3226
  $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav', ) );
3227
 
3228
  if ( in_array( $args->container, $allowed_tags ) ) {
@@ -3234,14 +2756,7 @@ function bp_nav_menu( $args = array() ) {
3234
  }
3235
  }
3236
 
3237
- /**
3238
- * Filters the BuddyPress menu objects.
3239
- *
3240
- * @since BuddyPress (1.7.0)
3241
- *
3242
- * @param array $value Array of nav menu objects.
3243
- * @param array $args Array of arguments for the menu.
3244
- */
3245
  $menu_items = apply_filters( 'bp_nav_menu_objects', bp_get_nav_menu_items(), $args );
3246
  $items = walk_nav_menu_tree( $menu_items, $args->depth, $args );
3247
  unset( $menu_items );
@@ -3264,16 +2779,7 @@ function bp_nav_menu( $args = array() ) {
3264
  }
3265
  $menu_id_slugs[] = $wrap_id;
3266
 
3267
- /**
3268
- * Filters the BuddyPress menu items.
3269
- *
3270
- * Allow plugins to hook into the menu to add their own <li>'s
3271
- *
3272
- * @since BuddyPress (1.7.0)
3273
- *
3274
- * @param array $items Array of nav menu items.
3275
- * @param array $args Array of arguments for the menu.
3276
- */
3277
  $items = apply_filters( 'bp_nav_menu_items', $items, $args );
3278
 
3279
  // Build the output
@@ -3286,14 +2792,7 @@ function bp_nav_menu( $args = array() ) {
3286
  $nav_menu .= '</' . $args->container . '>';
3287
  }
3288
 
3289
- /**
3290
- * Filters the final BuddyPress menu output.
3291
- *
3292
- * @since BuddyPress (1.7.0)
3293
- *
3294
- * @param string $nav_menu Final nav menu output.
3295
- * @param array $args Array of arguments for the menu.
3296
- */
3297
  $nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args );
3298
 
3299
  if ( ! empty( $args->echo ) ) {
71
  // List type depends on our current component
72
  $list_type = bp_is_group() ? 'groups' : 'personal';
73
 
74
+ // echo out the final list item
75
+ echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . $subnav_item['css_id'] . '-' . $list_type . '-li" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item, $selected_item );
 
 
 
 
 
 
 
 
 
 
76
  }
77
  }
78
 
114
  $title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
115
  }
116
 
 
 
 
 
 
 
 
 
117
  return apply_filters( 'bp_get_directory_title', $title, $component );
118
  }
119
 
200
  ? $step = $bp->avatar_admin->step
201
  : 'upload-image';
202
 
 
 
 
 
 
 
 
203
  return apply_filters( 'bp_get_avatar_admin_step', $step );
204
  }
205
 
220
  ? $bp->avatar_admin->image->url
221
  : '';
222
 
 
 
 
 
 
 
 
223
  return apply_filters( 'bp_get_avatar_to_crop', $url );
224
  }
225
 
240
  ? str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir )
241
  : '';
242
 
 
 
 
 
 
 
 
243
  return apply_filters( 'bp_get_avatar_to_crop_src', $src );
244
  }
245
 
268
  * @since BuddyPress (1.6.0)
269
  */
270
  function bp_get_site_name() {
 
 
 
 
 
 
 
 
271
  return apply_filters( 'bp_site_name', get_bloginfo( 'name', 'display' ) );
272
  }
273
 
274
  /**
275
+ * Format a date.
276
  *
277
+ * @param int $time The UNIX timestamp to be formatted.
278
+ * @param bool $just_date Optional. True to return only the month + day, false
279
+ * to return month, day, and time. Default: false.
280
+ * @param bool $localize_time Optional. True to display in local time, false to
281
+ * leave in GMT. Default: true.
282
+ * @return string|bool $localize_time Optional. A string representation of
283
+ * $time, in the format "January 1, 2010 at 9:50pm" (or whatever your
284
+ * 'date_format' and 'time_format' settings are). False on failure.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  */
286
+ function bp_format_time( $time, $just_date = false, $localize_time = true ) {
287
 
288
+ if ( ! isset( $time ) || ! is_numeric( $time ) ) {
 
 
289
  return false;
290
  }
291
 
292
  // Get GMT offset from root blog
293
+ $root_blog_offset = false;
294
+ if ( ! empty( $localize_time ) ) {
295
+ $root_blog_offset = get_blog_option( bp_get_root_blog_id(), 'gmt_offset' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  }
297
 
298
+ // Calculate offset time
299
+ $time_offset = $time + ( $root_blog_offset * 3600 );
300
 
301
+ // Current date (January 1, 2010)
302
+ $date = date_i18n( get_option( 'date_format' ), $time_offset );
303
 
304
+ // Should we show the time also?
305
+ if ( empty( $just_date ) ) {
306
+ // Current time (9:50pm)
307
+ $time = date_i18n( get_option( 'time_format' ), $time_offset );
308
 
309
  // Return string formatted with date and time
310
+ $date = sprintf( __( '%1$s at %2$s', 'buddypress' ), $date, $time );
311
  }
312
 
313
+ return apply_filters( 'bp_format_time', $date );
 
 
 
 
 
 
 
314
  }
315
 
316
  /**
339
 
340
  if ( bp_displayed_user_id() == bp_loggedin_user_id() ) {
341
  if ( true == $echo ) {
 
 
 
 
 
 
 
 
342
  echo apply_filters( 'bp_word_or_name', $youtext );
343
  } else {
 
 
344
  return apply_filters( 'bp_word_or_name', $youtext );
345
  }
346
  } else {
348
  $fullname = (array) explode( ' ', $fullname );
349
  $nametext = sprintf( $nametext, $fullname[0] );
350
  if ( true == $echo ) {
 
 
351
  echo apply_filters( 'bp_word_or_name', $nametext );
352
  } else {
 
 
353
  return apply_filters( 'bp_word_or_name', $nametext );
354
  }
355
  }
375
  * @return string URL action attribute for search forms, eg example.com/search/.
376
  */
377
  function bp_search_form_action() {
 
 
 
 
 
 
 
 
378
  return apply_filters( 'bp_search_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_search_slug() ) );
379
  }
380
 
411
  $selection_box = '<label for="search-which" class="accessibly-hidden">' . _x( 'Search these:', 'search form', 'buddypress' ) . '</label>';
412
  $selection_box .= '<select name="search-which" id="search-which" style="width: auto">';
413
 
 
 
 
 
 
 
 
414
  $options = apply_filters( 'bp_search_form_type_select_options', $options );
415
  foreach( (array) $options as $option_value => $option_title ) {
416
  $selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title );
418
 
419
  $selection_box .= '</select>';
420
 
 
 
 
 
 
 
 
421
  return apply_filters( 'bp_search_form_type_select', $selection_box );
422
  }
423
 
442
  * @return string Placeholder text for search field.
443
  */
444
  function bp_get_search_default_text( $component = '' ) {
445
+ global $bp;
 
446
 
447
  if ( empty( $component ) ) {
448
  $component = bp_current_component();
466
  }
467
  }
468
 
 
 
 
 
 
 
 
 
469
  return apply_filters( 'bp_get_search_default_text', $default_text, $component );
470
  }
471
 
585
  */
586
  function bp_get_button( $args = '' ) {
587
  $button = new BP_Button( $args );
 
 
 
 
 
 
 
 
 
 
588
  return apply_filters( 'bp_get_button', $button->contents, $args, $button );
589
  }
590
 
635
  // Save the original text, to be passed along to the filter
636
  $original_text = $text;
637
 
638
+ // Allow plugins to modify these values globally
 
 
 
 
 
 
639
  $length = apply_filters( 'bp_excerpt_length', $length );
 
 
 
 
 
 
 
 
640
  $ending = apply_filters( 'bp_excerpt_append_text', $r['ending'] );
641
 
642
  // Remove shortcodes if necessary
657
  $openTags = array();
658
  $truncate = '';
659
 
660
+ // Find all the tags and put them in a stack for later use
661
+ preg_match_all( '/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER );
 
662
  foreach ( $tags as $tag ) {
663
+
664
  // Process tags that need to be closed
665
  if ( !preg_match( '/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s', $tag[2] ) ) {
666
  if ( preg_match( '/<[\w]+[^>]*>/s', $tag[0] ) ) {
710
 
711
  // If $exact is false, we can't break on words
712
  if ( empty( $r['exact'] ) ) {
713
+ $spacepos = mb_strrpos( $truncate, ' ' );
714
+ if ( isset( $spacepos ) ) {
715
+ if ( $r['html'] ) {
716
+ $bits = mb_substr( $truncate, $spacepos );
717
+ preg_match_all( '/<\/([a-z]+)>/', $bits, $droppedTags, PREG_SET_ORDER );
718
+ if ( !empty( $droppedTags ) ) {
719
+ foreach ( $droppedTags as $closingTag ) {
720
+ if ( !in_array( $closingTag[1], $openTags ) ) {
721
+ array_unshift( $openTags, $closingTag[1] );
722
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
723
  }
724
  }
725
  }
726
+ $truncate = mb_substr( $truncate, 0, $spacepos );
727
  }
 
 
728
  }
729
  $truncate .= $ending;
730
 
734
  }
735
  }
736
 
 
 
 
 
 
 
 
 
 
 
737
  return apply_filters( 'bp_create_excerpt', $truncate, $original_text, $length, $options );
738
  }
739
  add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
760
  * @return int Member count.
761
  */
762
  function bp_get_total_member_count() {
 
 
 
 
 
 
 
 
763
  return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() );
764
  }
765
  add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
786
  return false;
787
  }
788
 
789
+ $status = buddypress()->site_options['registration'];
790
  if ( ( 'none' !== $status ) && ( 'user' !== $status ) ) {
791
  return true;
792
  }
819
  * @return bool True by default.
820
  */
821
  function bp_registration_needs_activation() {
 
 
 
 
 
 
 
 
822
  return apply_filters( 'bp_registration_needs_activation', true );
823
  }
824
 
830
  *
831
  * @since BuddyPress (1.7.0)
832
  *
833
+ * @see http://buddypress.trac.wordpress.org/ticket/4401
834
  *
835
  * @param array $args {
836
  * Array of optional parameters.
856
 
857
  $subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text'];
858
 
 
 
 
 
 
 
 
 
859
  return apply_filters( 'bp_get_email_subject', $subject, $r );
860
  }
861
 
879
  $bp->ajax_querystring = '';
880
  }
881
 
 
 
 
 
 
 
 
 
 
 
882
  return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object );
883
  }
884
 
895
  ? $bp->current_component
896
  : false;
897
 
 
 
 
 
 
 
 
898
  return apply_filters( 'bp_current_component', $current_component );
899
  }
900
 
909
  ? $bp->current_action
910
  : '';
911
 
 
 
 
 
 
 
 
912
  return apply_filters( 'bp_current_action', $current_action );
913
  }
914
 
923
  ? $bp->current_item
924
  : false;
925
 
 
 
 
 
 
 
 
926
  return apply_filters( 'bp_current_item', $current_item );
927
  }
928
 
938
  ? $bp->action_variables
939
  : false;
940
 
 
 
 
 
 
 
 
941
  return apply_filters( 'bp_action_variables', $action_variables );
942
  }
943
 
956
  ? $action_variables[ $position ]
957
  : false;
958
 
 
 
 
 
 
 
 
 
959
  return apply_filters( 'bp_action_variable', $action_variable, $position );
960
  }
961
 
980
  $bp->root_domain = $domain;
981
  }
982
 
 
 
 
 
 
 
 
983
  return apply_filters( 'bp_get_root_domain', $domain );
984
  }
985
 
1052
  $root_slug = $component;
1053
  }
1054
 
 
 
 
 
 
 
 
 
1055
  return apply_filters( 'bp_get_root_slug', $root_slug, $component );
1056
  }
1057
 
1091
  ? true
1092
  : false;
1093
 
 
 
 
 
 
 
 
1094
  return (bool) apply_filters( 'bp_user_has_access', $has_access );
1095
  }
1096
 
1112
  * @return string The search slug. Default: 'search'.
1113
  */
1114
  function bp_get_search_slug() {
 
 
 
 
 
 
 
 
1115
  return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
1116
  }
1117
 
1128
  ? $bp->displayed_user->id
1129
  : 0;
1130
 
 
 
 
 
 
 
 
1131
  return (int) apply_filters( 'bp_displayed_user_id', $id );
1132
  }
1133
 
1144
  ? $bp->loggedin_user->id
1145
  : 0;
1146
 
 
 
 
 
 
 
 
1147
  return (int) apply_filters( 'bp_loggedin_user_id', $id );
1148
  }
1149
 
1223
  }
1224
  }
1225
 
 
 
 
 
 
 
 
 
1226
  return apply_filters( 'bp_is_current_component', $is_current_component, $component );
1227
  }
1228
 
1284
  $is_action_variable = in_array( $action_variable, (array)bp_action_variables() );
1285
  }
1286
 
 
 
 
 
 
 
 
 
 
1287
  return apply_filters( 'bp_is_action_variable', $is_action_variable, $action_variable, $position );
1288
  }
1289
 
1296
  function bp_is_current_item( $item = '' ) {
1297
  $retval = ( $item === bp_current_item() );
1298
 
 
 
 
 
 
 
 
 
1299
  return (bool) apply_filters( 'bp_is_current_item', $retval, $item );
1300
  }
1301
 
1312
  $retval = $bp->is_single_item;
1313
  }
1314
 
 
 
 
 
 
 
 
1315
  return (bool) apply_filters( 'bp_is_single_item', $retval );
1316
  }
1317
 
1329
  $retval = $bp->is_item_admin;
1330
  }
1331
 
 
 
 
 
 
 
 
1332
  return (bool) apply_filters( 'bp_is_item_admin', $retval );
1333
  }
1334
 
1346
  $retval = $bp->is_item_mod;
1347
  }
1348
 
 
 
 
 
 
 
 
1349
  return (bool) apply_filters( 'bp_is_item_mod', $retval );
1350
  }
1351
 
1363
  $retval = $bp->is_directory;
1364
  }
1365
 
 
 
 
 
 
 
 
1366
  return (bool) apply_filters( 'bp_is_directory', $retval );
1367
  }
1368
 
1396
  }
1397
  }
1398
 
 
 
 
 
 
 
 
1399
  return (bool) apply_filters( 'bp_is_root_component', $retval );
1400
  }
1401
 
1436
  return false;
1437
  }
1438
 
 
 
 
 
 
 
 
 
1439
  return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );
1440
  }
1441
 
1458
  $is_blog_page = true;
1459
  }
1460
 
 
 
 
 
 
 
 
1461
  return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page );
1462
  }
1463
 
1478
  function is_buddypress() {
1479
  $retval = (bool) ( bp_current_component() || bp_is_user() );
1480
 
 
 
 
 
 
 
 
1481
  return apply_filters( 'is_buddypress', $retval );
1482
  }
1483
 
1484
  /** Components ****************************************************************/
1485
 
1486
  /**
1487
+ * Check whether a given component has been activated by the admin.
 
 
 
1488
  *
1489
  * @param string $component The component name.
1490
+ * @return bool True if the component is active, otherwise false.
 
1491
  */
1492
+ function bp_is_active( $component = '' ) {
1493
  $retval = false;
1494
 
1495
  // Default to the current component if none is passed
1500
  // Is component in either the active or required components arrays
1501
  if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
1502
  $retval = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1503
  }
1504
 
 
 
 
 
 
 
 
 
1505
  return apply_filters( 'bp_is_active', $retval, $component );
1506
  }
1507
 
1680
  $my_profile = false;
1681
  }
1682
 
 
 
 
 
 
 
 
1683
  return apply_filters( 'bp_is_my_profile', $my_profile );
1684
  }
1685
 
2501
  // Merge WP classes with BuddyPress classes and remove any duplicates
2502
  $classes = array_unique( array_merge( (array) $bp_classes, (array) $wp_classes ) );
2503
 
 
 
 
 
 
 
 
 
 
 
2504
  return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
2505
  }
2506
  add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );
2650
  continue;
2651
  }
2652
 
2653
+ // Get the correct menu link. See http://buddypress.trac.wordpress.org/ticket/4624
2654
  $link = bp_loggedin_user_domain() ? str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav['link'] ) : trailingslashit( bp_displayed_user_domain() . $nav['link'] );
2655
 
2656
  // Add this menu
2669
  $menus[] = $menu;
2670
  }
2671
 
 
 
 
 
 
 
 
2672
  return apply_filters( 'bp_get_nav_menu_items', $menus );
2673
  }
2674
 
2728
  'walker' => '',
2729
  );
2730
  $args = wp_parse_args( $args, $defaults );
 
 
 
 
 
 
 
 
2731
  $args = apply_filters( 'bp_nav_menu_args', $args );
2732
  $args = (object) $args;
2733
 
2745
 
2746
  // Whether to wrap the ul, and what to wrap it with
2747
  if ( $args->container ) {
 
 
 
 
 
 
 
 
2748
  $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav', ) );
2749
 
2750
  if ( in_array( $args->container, $allowed_tags ) ) {
2756
  }
2757
  }
2758
 
2759
+ // Get the BuddyPress menu items
 
 
 
 
 
 
 
2760
  $menu_items = apply_filters( 'bp_nav_menu_objects', bp_get_nav_menu_items(), $args );
2761
  $items = walk_nav_menu_tree( $menu_items, $args->depth, $args );
2762
  unset( $menu_items );
2779
  }
2780
  $menu_id_slugs[] = $wrap_id;
2781
 
2782
+ // Allow plugins to hook into the menu to add their own <li>'s
 
 
 
 
 
 
 
 
 
2783
  $items = apply_filters( 'bp_nav_menu_items', $items, $args );
2784
 
2785
  // Build the output
2792
  $nav_menu .= '</' . $args->container . '>';
2793
  }
2794
 
2795
+ // Final chance to modify output
 
 
 
 
 
 
 
2796
  $nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args );
2797
 
2798
  if ( ! empty( $args->echo ) ) {
bp-core/bp-core-theme-compatibility.php CHANGED
@@ -164,14 +164,6 @@ function bp_setup_theme_compat( $theme = '' ) {
164
  * @return string ID of the theme package in use.
165
  */
166
  function bp_get_theme_compat_id() {
167
-
168
- /**
169
- * Filters the ID of the theme package being used.
170
- *
171
- * @since BuddyPress (1.7.0)
172
- *
173
- * @param string $id ID of the theme package in use.
174
- */
175
  return apply_filters( 'bp_get_theme_compat_id', buddypress()->theme_compat->theme->id );
176
  }
177
 
@@ -188,14 +180,6 @@ function bp_get_theme_compat_id() {
188
  * @return string Name of the theme package currently in use.
189
  */
190
  function bp_get_theme_compat_name() {
191
-
192
- /**
193
- * Filters the name of the theme package being used.
194
- *
195
- * @since BuddyPress (1.7.0)
196
- *
197
- * @param string $name Name of the theme package in use.
198
- */
199
  return apply_filters( 'bp_get_theme_compat_name', buddypress()->theme_compat->theme->name );
200
  }
201
 
@@ -212,14 +196,6 @@ function bp_get_theme_compat_name() {
212
  * @return string The version string of the theme package currently in use.
213
  */
214
  function bp_get_theme_compat_version() {
215
-
216
- /**
217
- * Filters the version of the theme package being used.
218
- *
219
- * @since BuddyPress (1.7.0)
220
- *
221
- * @param string $version The version string of the theme package in use.
222
- */
223
  return apply_filters( 'bp_get_theme_compat_version', buddypress()->theme_compat->theme->version );
224
  }
225
 
@@ -236,14 +212,6 @@ function bp_get_theme_compat_version() {
236
  * @return string The absolute path of the theme package currently in use.
237
  */
238
  function bp_get_theme_compat_dir() {
239
-
240
- /**
241
- * Filters the absolute path of the theme package being used.
242
- *
243
- * @since BuddyPress (1.7.0)
244
- *
245
- * @param string $dir The absolute path of the theme package in use.
246
- */
247
  return apply_filters( 'bp_get_theme_compat_dir', buddypress()->theme_compat->theme->dir );
248
  }
249
 
@@ -261,14 +229,6 @@ function bp_get_theme_compat_dir() {
261
  * @return string URL of the theme package currently in use.
262
  */
263
  function bp_get_theme_compat_url() {
264
-
265
- /**
266
- * Filters the URL of the theme package being used.
267
- *
268
- * @since BuddyPress (1.7.0)
269
- *
270
- * @param string $url URL of the theme package in use.
271
- */
272
  return apply_filters( 'bp_get_theme_compat_url', buddypress()->theme_compat->theme->url );
273
  }
274
 
@@ -289,13 +249,6 @@ function bp_use_theme_compat_with_current_theme() {
289
  bp_detect_theme_compat_with_current_theme();
290
  }
291
 
292
- /**
293
- * Filters whether or not to use theme compat for the active theme.
294
- *
295
- * @since BuddyPress (1.9.0)
296
- *
297
- * @param bool $use_with_current_theme True if the current theme needs theme compatibility.
298
- */
299
  return apply_filters( 'bp_use_theme_compat_with_current_theme', buddypress()->theme_compat->use_with_current_theme );
300
  }
301
 
@@ -453,7 +406,7 @@ function bp_is_theme_compat_original_template( $template = '' ) {
453
  * For an example of how this function is used, see:
454
  * {@link BuddyPress::register_theme_packages()}.
455
  *
456
- * @since BuddyPress (1.7.0)
457
  *
458
  * @see BP_Theme_Compat for a description of the $theme parameter arguments.
459
  *
@@ -597,7 +550,7 @@ function bp_theme_compat_reset_post( $args = array() ) {
597
  /**
598
  * Force the header back to 200 status if not a deliberate 404
599
  *
600
- * @see https://bbpress.trac.wordpress.org/ticket/1973
601
  */
602
  if ( ! $wp_query->is_404() ) {
603
  status_header( 200 );
@@ -644,13 +597,9 @@ function bp_template_include_theme_compat( $template = '' ) {
644
  }
645
 
646
  /**
647
- * Fires when resetting main query vars and filtering 'the_content' to output BuddyPress template parts.
648
- *
649
  * Use this action to execute code that will communicate to BuddyPress's
650
  * theme compatibility layer whether or not we're replacing the_content()
651
  * with some other template part.
652
- *
653
- * @since BuddyPress (1.7.0)
654
  */
655
  do_action( 'bp_template_include_reset_dummy_post_data' );
656
 
@@ -687,13 +636,6 @@ function bp_template_include_theme_compat( $template = '' ) {
687
  }
688
  }
689
 
690
- /**
691
- * Filters the template name to include.
692
- *
693
- * @since BuddyPress (1.7.0)
694
- *
695
- * @param string $template Template name.
696
- */
697
  return apply_filters( 'bp_template_include_theme_compat', $template );
698
  }
699
 
@@ -720,13 +662,7 @@ function bp_replace_the_content( $content = '' ) {
720
  // the_content() that execute before theme compat has unhooked itself.
721
  bp_set_theme_compat_active( false );
722
 
723
- /**
724
- * Filters the content to replace in the post.
725
- *
726
- * @since BuddyPress (1.7.0)
727
- *
728
- * @param string $content Original post content.
729
- */
730
  $new_content = apply_filters( 'bp_replace_the_content', $content );
731
 
732
  // Juggle the content around and try to prevent unsightly comments
@@ -887,15 +823,7 @@ function bp_comments_open( $open, $post_id = 0 ) {
887
 
888
  $retval = is_buddypress() ? false : $open;
889
 
890
- /**
891
- * Filters whether or not to force comments_status to closed for BuddyPress post types.
892
- *
893
- * @since BuddyPress (1.7.0)
894
- *
895
- * @param bool $retval Whether or not we are on a BuddyPress post type.
896
- * @param bool $open True if comments open, false if closed.
897
- * @param int $post_id Post ID for the checked post.
898
- */
899
  return apply_filters( 'bp_force_comment_status', $retval, $open, $post_id );
900
  }
901
 
@@ -920,7 +848,8 @@ function bp_comments_open( $open, $post_id = 0 ) {
920
  function bp_theme_compat_toggle_is_page( $retval = '' ) {
921
  global $wp_query;
922
 
923
- $wp_query->is_page = false;
 
924
 
925
  // Set a switch so we know that we've toggled these WP_Query properties
926
  buddypress()->theme_compat->is_page_toggled = true;
@@ -948,7 +877,8 @@ function bp_theme_compat_loop_end( $query ) {
948
  }
949
 
950
  // Revert our toggled WP_Query properties
951
- $query->is_page = true;
 
952
 
953
  // Unset our switch
954
  unset( $bp->theme_compat->is_page_toggled );
164
  * @return string ID of the theme package in use.
165
  */
166
  function bp_get_theme_compat_id() {
 
 
 
 
 
 
 
 
167
  return apply_filters( 'bp_get_theme_compat_id', buddypress()->theme_compat->theme->id );
168
  }
169
 
180
  * @return string Name of the theme package currently in use.
181
  */
182
  function bp_get_theme_compat_name() {
 
 
 
 
 
 
 
 
183
  return apply_filters( 'bp_get_theme_compat_name', buddypress()->theme_compat->theme->name );
184
  }
185
 
196
  * @return string The version string of the theme package currently in use.
197
  */
198
  function bp_get_theme_compat_version() {
 
 
 
 
 
 
 
 
199
  return apply_filters( 'bp_get_theme_compat_version', buddypress()->theme_compat->theme->version );
200
  }
201
 
212
  * @return string The absolute path of the theme package currently in use.
213
  */
214
  function bp_get_theme_compat_dir() {
 
 
 
 
 
 
 
 
215
  return apply_filters( 'bp_get_theme_compat_dir', buddypress()->theme_compat->theme->dir );
216
  }
217
 
229
  * @return string URL of the theme package currently in use.
230
  */
231
  function bp_get_theme_compat_url() {
 
 
 
 
 
 
 
 
232
  return apply_filters( 'bp_get_theme_compat_url', buddypress()->theme_compat->theme->url );
233
  }
234
 
249
  bp_detect_theme_compat_with_current_theme();
250
  }
251
 
 
 
 
 
 
 
 
252
  return apply_filters( 'bp_use_theme_compat_with_current_theme', buddypress()->theme_compat->use_with_current_theme );
253
  }
254
 
406
  * For an example of how this function is used, see:
407
  * {@link BuddyPress::register_theme_packages()}.
408
  *
409
+ * @since BuddyPress (1.7)
410
  *
411
  * @see BP_Theme_Compat for a description of the $theme parameter arguments.
412
  *
550
  /**
551
  * Force the header back to 200 status if not a deliberate 404
552
  *
553
+ * @see http://bbpress.trac.wordpress.org/ticket/1973
554
  */
555
  if ( ! $wp_query->is_404() ) {
556
  status_header( 200 );
597
  }
598
 
599
  /**
 
 
600
  * Use this action to execute code that will communicate to BuddyPress's
601
  * theme compatibility layer whether or not we're replacing the_content()
602
  * with some other template part.
 
 
603
  */
604
  do_action( 'bp_template_include_reset_dummy_post_data' );
605
 
636
  }
637
  }
638
 
 
 
 
 
 
 
 
639
  return apply_filters( 'bp_template_include_theme_compat', $template );
640
  }
641
 
662
  // the_content() that execute before theme compat has unhooked itself.
663
  bp_set_theme_compat_active( false );
664
 
665
+ // Do we have new content to replace the old content?
 
 
 
 
 
 
666
  $new_content = apply_filters( 'bp_replace_the_content', $content );
667
 
668
  // Juggle the content around and try to prevent unsightly comments
823
 
824
  $retval = is_buddypress() ? false : $open;
825
 
826
+ // Allow override of the override
 
 
 
 
 
 
 
 
827
  return apply_filters( 'bp_force_comment_status', $retval, $open, $post_id );
828
  }
829
 
848
  function bp_theme_compat_toggle_is_page( $retval = '' ) {
849
  global $wp_query;
850
 
851
+ $wp_query->is_single = false;
852
+ $wp_query->is_page = false;
853
 
854
  // Set a switch so we know that we've toggled these WP_Query properties
855
  buddypress()->theme_compat->is_page_toggled = true;
877
  }
878
 
879
  // Revert our toggled WP_Query properties
880
+ $query->is_single = true;
881
+ $query->is_page = true;
882
 
883
  // Unset our switch
884
  unset( $bp->theme_compat->is_page_toggled );
bp-core/bp-core-update.php CHANGED
@@ -187,13 +187,6 @@ function bp_version_updater() {
187
  // Get the raw database version
188
  $raw_db_version = (int) bp_get_db_version_raw();
189
 
190
- /**
191
- * Filters the default components to activate for a new install.
192
- *
193
- * @since BuddyPress (1.7.0)
194
- *
195
- * @param array $value Array of default components to activate.
196
- */
197
  $default_components = apply_filters( 'bp_new_install_default_components', array(
198
  'activity' => 1,
199
  'members' => 1,
@@ -202,7 +195,7 @@ function bp_version_updater() {
202
  'notifications' => 1,
203
  ) );
204
 
205
- require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
206
 
207
  // Install BP schema and activate only Activity and XProfile
208
  if ( bp_is_install() ) {
@@ -218,18 +211,18 @@ function bp_version_updater() {
218
  // Run the schema install to update tables
219
  bp_core_install();
220
 
221
- // 1.5.0
222
  if ( $raw_db_version < 1801 ) {
223
  bp_update_to_1_5();
224
  bp_core_add_page_mappings( $default_components, 'delete' );
225
  }
226
 
227
- // 1.6.0
228
  if ( $raw_db_version < 6067 ) {
229
  bp_update_to_1_6();
230
  }
231
 
232
- // 1.9.0
233
  if ( $raw_db_version < 7553 ) {
234
  bp_update_to_1_9();
235
  }
@@ -239,7 +232,7 @@ function bp_version_updater() {
239
  bp_update_to_1_9_2();
240
  }
241
 
242
- // 2.0.0
243
  if ( $raw_db_version < 7892 ) {
244
  bp_update_to_2_0();
245
  }
@@ -249,15 +242,10 @@ function bp_version_updater() {
249
  bp_update_to_2_0_1();
250
  }
251
 
252
- // 2.2.0
253
  if ( $raw_db_version < 9181 ) {
254
  bp_update_to_2_2();
255
  }
256
-
257
- // 2.3.0
258
- if ( $raw_db_version < 9615 ) {
259
- bp_update_to_2_3();
260
- }
261
  }
262
 
263
  /** All done! *************************************************************/
@@ -266,41 +254,6 @@ function bp_version_updater() {
266
  bp_version_bump();
267
  }
268
 
269
- /**
270
- * Perform database operations that must take place before the general schema upgrades.
271
- *
272
- * `dbDelta()` cannot handle certain operations - like changing indexes - so we do it here instead.
273
- *
274
- * @since BuddyPress (2.3.0)
275
- */
276
- function bp_pre_schema_upgrade() {
277
- global $wpdb;
278
-
279
- $raw_db_version = (int) bp_get_db_version_raw();
280
- $bp_prefix = bp_core_get_table_prefix();
281
-
282
- // 2.3.0: Change index lengths to account for utf8mb4.
283
- if ( $raw_db_version < 9695 ) {
284
- // table_name => columns.
285
- $tables = array(
286
- $bp_prefix . 'bp_activity_meta' => array( 'meta_key' ),
287
- $bp_prefix . 'bp_groups_groupmeta' => array( 'meta_key' ),
288
- $bp_prefix . 'bp_messages_meta' => array( 'meta_key' ),
289
- $bp_prefix . 'bp_notifications_meta' => array( 'meta_key' ),
290
- $bp_prefix . 'bp_user_blogs_blogmeta' => array( 'meta_key' ),
291
- $bp_prefix . 'bp_xprofile_meta' => array( 'meta_key' ),
292
- );
293
-
294
- foreach ( $tables as $table_name => $indexes ) {
295
- foreach ( $indexes as $index ) {
296
- if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", bp_esc_like( $table_name ) ) ) ) {
297
- $wpdb->query( "ALTER TABLE {$table_name} DROP INDEX {$index}" );
298
- }
299
- }
300
- }
301
- }
302
- }
303
-
304
  /** Upgrade Routines **********************************************************/
305
 
306
  /**
@@ -451,8 +404,6 @@ function bp_update_to_2_0_1() {
451
  * @since BuddyPress (2.2.0)
452
  */
453
  function bp_update_to_2_2() {
454
-
455
- // Also handled by `bp_core_install()`
456
  if ( bp_is_active( 'messages' ) ) {
457
  bp_core_install_private_messaging();
458
  }
@@ -466,21 +417,6 @@ function bp_update_to_2_2() {
466
  }
467
  }
468
 
469
- /**
470
- * 2.3.0 update routine.
471
- *
472
- * - Add notifications meta table
473
- *
474
- * @since BuddyPress (2.3.0)
475
- */
476
- function bp_update_to_2_3() {
477
-
478
- // Also handled by `bp_core_install()`
479
- if ( bp_is_active( 'notifications' ) ) {
480
- bp_core_install_notifications();
481
- }
482
- }
483
-
484
  /**
485
  * Updates the component field for new_members type.
486
  *
@@ -621,13 +557,7 @@ function bp_activation() {
621
  // Add options
622
  bp_add_options();
623
 
624
- /**
625
- * Fires during the activation of BuddyPress.
626
- *
627
- * Use as of (1.6.0)
628
- *
629
- * @since BuddyPress (1.6.0)
630
- */
631
  do_action( 'bp_activation' );
632
 
633
  // @deprecated as of (1.6)
@@ -656,13 +586,7 @@ function bp_deactivation() {
656
  update_option( 'stylesheet_root', get_raw_theme_root( WP_DEFAULT_THEME, true ) );
657
  }
658
 
659
- /**
660
- * Fires during the deactivation of BuddyPress.
661
- *
662
- * Use as of (1.6.0)
663
- *
664
- * @since BuddyPress (1.6.0)
665
- */
666
  do_action( 'bp_deactivation' );
667
 
668
  // @deprecated as of (1.6)
@@ -679,11 +603,5 @@ function bp_deactivation() {
679
  * @uses do_action() Calls 'bp_uninstall' hook.
680
  */
681
  function bp_uninstall() {
682
-
683
- /**
684
- * Fires during the uninstallation of BuddyPress.
685
- *
686
- * @since BuddyPress (1.6.0)
687
- */
688
  do_action( 'bp_uninstall' );
689
  }
187
  // Get the raw database version
188
  $raw_db_version = (int) bp_get_db_version_raw();
189
 
 
 
 
 
 
 
 
190
  $default_components = apply_filters( 'bp_new_install_default_components', array(
191
  'activity' => 1,
192
  'members' => 1,
195
  'notifications' => 1,
196
  ) );
197
 
198
+ require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-schema.php' );
199
 
200
  // Install BP schema and activate only Activity and XProfile
201
  if ( bp_is_install() ) {
211
  // Run the schema install to update tables
212
  bp_core_install();
213
 
214
+ // 1.5
215
  if ( $raw_db_version < 1801 ) {
216
  bp_update_to_1_5();
217
  bp_core_add_page_mappings( $default_components, 'delete' );
218
  }
219
 
220
+ // 1.6
221
  if ( $raw_db_version < 6067 ) {
222
  bp_update_to_1_6();
223
  }
224
 
225
+ // 1.9
226
  if ( $raw_db_version < 7553 ) {
227
  bp_update_to_1_9();
228
  }
232
  bp_update_to_1_9_2();
233
  }
234
 
235
+ // 2.0
236
  if ( $raw_db_version < 7892 ) {
237
  bp_update_to_2_0();
238
  }
242
  bp_update_to_2_0_1();
243
  }
244
 
245
+ // 2.2
246
  if ( $raw_db_version < 9181 ) {
247
  bp_update_to_2_2();
248
  }
 
 
 
 
 
249
  }
250
 
251
  /** All done! *************************************************************/
254
  bp_version_bump();
255
  }
256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  /** Upgrade Routines **********************************************************/
258
 
259
  /**
404
  * @since BuddyPress (2.2.0)
405
  */
406
  function bp_update_to_2_2() {
 
 
407
  if ( bp_is_active( 'messages' ) ) {
408
  bp_core_install_private_messaging();
409
  }
417
  }
418
  }
419
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  /**
421
  * Updates the component field for new_members type.
422
  *
557
  // Add options
558
  bp_add_options();
559
 
560
+ // Use as of (1.6)
 
 
 
 
 
 
561
  do_action( 'bp_activation' );
562
 
563
  // @deprecated as of (1.6)
586
  update_option( 'stylesheet_root', get_raw_theme_root( WP_DEFAULT_THEME, true ) );
587
  }
588
 
589
+ // Use as of (1.6)
 
 
 
 
 
 
590
  do_action( 'bp_deactivation' );
591
 
592
  // @deprecated as of (1.6)
603
  * @uses do_action() Calls 'bp_uninstall' hook.
604
  */
605
  function bp_uninstall() {
 
 
 
 
 
 
606
  do_action( 'bp_uninstall' );
607
  }
bp-core/bp-core-widgets.php CHANGED
@@ -50,18 +50,7 @@ class BP_Core_Login_Widget extends WP_Widget {
50
  */
51
  public function widget( $args, $instance ) {
52
  $title = isset( $instance['title'] ) ? $instance['title'] : '';
53
-
54
- /**
55
- * Filters the title of the Login widget.
56
- *
57
- * @since BuddyPress (1.9.0)
58
- * @since BuddyPress (2.3.0) Added 'instance' and 'id_base' to arguments passed to filter.
59
- *
60
- * @param string $title The widget title.
61
- * @param array $instance The settings for the particular instance of the widget.
62
- * @param string $id_base Root ID for all widgets of this type.
63
- */
64
- $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
65
 
66
  echo $args['before_widget'];
67
 
@@ -69,14 +58,7 @@ class BP_Core_Login_Widget extends WP_Widget {
69
 
70
  <?php if ( is_user_logged_in() ) : ?>
71
 
72
- <?php
73
-
74
- /**
75
- * Fires before the display of widget content if logged in.
76
- *
77
- * @since BuddyPress (1.9.0)
78
- */
79
- do_action( 'bp_before_login_widget_loggedin' ); ?>
80
 
81
  <div class="bp-login-widget-user-avatar">
82
  <a href="<?php echo bp_loggedin_user_domain(); ?>">
@@ -89,32 +71,18 @@ class BP_Core_Login_Widget extends WP_Widget {
89
  <div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( bp_get_requested_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div>
90
  </div>
91
 
92
- <?php
93
-
94
- /**
95
- * Fires after the display of widget content if logged in.
96
- *
97
- * @since BuddyPress (1.9.0)
98
- */
99
- do_action( 'bp_after_login_widget_loggedin' ); ?>
100
 
101
  <?php else : ?>
102
 
103
- <?php
104
-
105
- /**
106
- * Fires before the display of widget content if logged out.
107
- *
108
- * @since BuddyPress (1.9.0)
109
- */
110
- do_action( 'bp_before_login_widget_loggedout' ); ?>
111
 
112
  <form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
113
  <label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label>
114
  <input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
115
 
116
  <label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label>
117
- <input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" <?php bp_form_field_attributes( 'password' ) ?> />
118
 
119
  <div class="forgetmenot"><label><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div>
120
 
@@ -128,14 +96,7 @@ class BP_Core_Login_Widget extends WP_Widget {
128
 
129
  </form>
130
 
131
- <?php
132
-
133
- /**
134
- * Fires after the display of widget content if logged out.
135
- *
136
- * @since BuddyPress (1.9.0)
137
- */
138
- do_action( 'bp_after_login_widget_loggedout' ); ?>
139
 
140
  <?php endif;
141
 
50
  */
51
  public function widget( $args, $instance ) {
52
  $title = isset( $instance['title'] ) ? $instance['title'] : '';
53
+ $title = apply_filters( 'widget_title', $title );
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  echo $args['before_widget'];
56
 
58
 
59
  <?php if ( is_user_logged_in() ) : ?>
60
 
61
+ <?php do_action( 'bp_before_login_widget_loggedin' ); ?>
 
 
 
 
 
 
 
62
 
63
  <div class="bp-login-widget-user-avatar">
64
  <a href="<?php echo bp_loggedin_user_domain(); ?>">
71
  <div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( bp_get_requested_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div>
72
  </div>
73
 
74
+ <?php do_action( 'bp_after_login_widget_loggedin' ); ?>
 
 
 
 
 
 
 
75
 
76
  <?php else : ?>
77
 
78
+ <?php do_action( 'bp_before_login_widget_loggedout' ); ?>
 
 
 
 
 
 
 
79
 
80
  <form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
81
  <label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label>
82
  <input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
83
 
84
  <label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label>
85
+ <input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" />
86
 
87
  <div class="forgetmenot"><label><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div>
88
 
96
 
97
  </form>
98
 
99
+ <?php do_action( 'bp_after_login_widget_loggedout' ); ?>
 
 
 
 
 
 
 
100
 
101
  <?php endif;
102
 
bp-core/classes/class-bp-attachment-avatar.php DELETED
@@ -1,427 +0,0 @@
1
- <?php
2
- /**
3
- * Core Avatars attachment class
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * BP Attachment Avatar class
14
- *
15
- * Extends BP Attachment to manage the avatar uploads
16
- *
17
- * @since BuddyPress (2.3.0)
18
- */
19
- class BP_Attachment_Avatar extends BP_Attachment {
20
-
21
- /**
22
- * Construct Upload parameters
23
- *
24
- * @since BuddyPress (2.3.0)
25
- *
26
- * @see BP_Attachment::__construct() for list of parameters
27
- * @uses bp_core_avatar_original_max_filesize()
28
- * @uses BP_Attachment::__construct()
29
- */
30
- public function __construct() {
31
- // Allowed avatar types
32
- $allowed_types = bp_core_get_allowed_avatar_types();
33
-
34
- parent::__construct( array(
35
- 'action' => 'bp_avatar_upload',
36
- 'file_input' => 'file',
37
- 'original_max_filesize' => bp_core_avatar_original_max_filesize(),
38
-
39
- // Specific errors for avatars
40
- 'upload_error_strings' => array(
41
- 9 => sprintf( __( 'That photo is too big. Please upload one smaller than %s', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ),
42
- 10 => sprintf( _n( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'buddypress' ), self::get_avatar_types( $allowed_types ) ),
43
- ),
44
- ) );
45
- }
46
-
47
- /**
48
- * Gets the available avatar types
49
- *
50
- * @since BuddyPress (2.3.0)
51
- * @return string comma separated list of allowed avatar types
52
- */
53
- public static function get_avatar_types( $allowed_types = array() ) {
54
- $types = array_map( 'strtoupper', $allowed_types );
55
- $comma = _x( ',', 'avatar types separator', 'buddypress' );
56
- return join( $comma . ' ', $types );
57
- }
58
-
59
- /**
60
- * Set Upload Dir data for avatars
61
- *
62
- * @since BuddyPress (2.3.0)
63
- *
64
- * @uses bp_core_avatar_upload_path()
65
- * @uses bp_core_avatar_url()
66
- * @uses bp_upload_dir()
67
- * @uses BP_Attachment::set_upload_dir()
68
- */
69
- public function set_upload_dir() {
70
- if ( bp_core_avatar_upload_path() && bp_core_avatar_url() ) {
71
- $this->upload_path = bp_core_avatar_upload_path();
72
- $this->url = bp_core_avatar_url();
73
- $this->upload_dir = bp_upload_dir();
74
- } else {
75
- parent::set_upload_dir();
76
- }
77
- }
78
-
79
- /**
80
- * Avatar specific rules
81
- *
82
- * Adds an error if the avatar size or type don't match BuddyPress needs
83
- * The error code is the index of $upload_error_strings
84
- *
85
- * @since BuddyPress (2.3.0)
86
- *
87
- * @param array $file the temporary file attributes (before it has been moved)
88
- * @uses bp_core_check_avatar_size()
89
- * @uses bp_core_check_avatar_type()
90
- * @return array the file with extra errors if needed
91
- */
92
- public function validate_upload( $file = array() ) {
93
- // Bail if already an error
94
- if ( ! empty( $file['error'] ) ) {
95
- return $file;
96
- }
97
-
98
- // File size is too big
99
- if ( ! bp_core_check_avatar_size( array( 'file' => $file ) ) ) {
100
- $file['error'] = 9;
101
-
102
- // File is of invalid type
103
- } elseif ( ! bp_core_check_avatar_type( array( 'file' => $file ) ) ) {
104
- $file['error'] = 10;
105
- }
106
-
107
- // Return with error code attached
108
- return $file;
109
- }
110
-
111
- /**
112
- * Maybe shrink the attachment to fit maximum allowed width
113
- *
114
- * @since BuddyPress (2.3.0)
115
- *
116
- * @param string $file the absolute path to the file
117
- * @uses bp_core_avatar_original_max_width()
118
- * @uses wp_get_image_editor()
119
- * @return mixed
120
- */
121
- public static function shrink( $file = '' ) {
122
- // Get image size
123
- $size = @getimagesize( $file );
124
- $retval = false;
125
-
126
- // Check image size and shrink if too large
127
- if ( $size[0] > bp_core_avatar_original_max_width() ) {
128
- $editor = wp_get_image_editor( $file );
129
-
130
- if ( ! is_wp_error( $editor ) ) {
131
- $editor->set_quality( 100 );
132
-
133
- $resized = $editor->resize( bp_core_avatar_original_max_width(), bp_core_avatar_original_max_width(), false );
134
- if ( ! is_wp_error( $resized ) ) {
135
- $thumb = $editor->save( $editor->generate_filename() );
136
- } else {
137
- $retval = $resized;
138
- }
139
-
140
- // Check for thumbnail creation errors
141
- if ( ( false === $retval ) && is_wp_error( $thumb ) ) {
142
- $retval = $thumb;
143
- }
144
-
145
- // Thumbnail is good so proceed
146
- if ( false === $retval ) {
147
- $retval = $thumb;
148
- }
149
-
150
- } else {
151
- $retval = $editor;
152
- }
153
- }
154
-
155
- return $retval;
156
- }
157
-
158
- /**
159
- * Check if the image dimensions are smaller than full avatar dimensions
160
- *
161
- * @since BuddyPress (2.3.0)
162
- *
163
- * @param string $file the absolute path to the file
164
- * @uses bp_core_avatar_full_width()
165
- * @uses bp_core_avatar_full_height()
166
- * @return boolean
167
- */
168
- public static function is_too_small( $file = '' ) {
169
- $uploaded_image = @getimagesize( $file );
170
- $full_width = bp_core_avatar_full_width();
171
- $full_height = bp_core_avatar_full_height();
172
-
173
- if ( isset( $uploaded_image[0] ) && $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) {
174
- return true;
175
- }
176
-
177
- return false;
178
- }
179
-
180
- /**
181
- * Crop the avatar
182
- *
183
- * @since BuddyPress (2.3.0)
184
- *
185
- * @see BP_Attachment::crop for the list of parameters
186
- * @param array $args
187
- * @uses bp_core_fetch_avatar()
188
- * @uses bp_core_delete_existing_avatar()
189
- * @uses bp_core_avatar_full_width()
190
- * @uses bp_core_avatar_full_height()
191
- * @uses bp_core_avatar_dimension()
192
- * @uses BP_Attachment::crop
193
- * @return array the cropped avatars (full and thumb)
194
- */
195
- public function crop( $args = array() ) {
196
- // Bail if the original file is missing
197
- if ( empty( $args['original_file'] ) ) {
198
- return false;
199
- }
200
-
201
- if ( ! bp_attachments_current_user_can( 'edit_avatar', $args ) ) {
202
- return false;
203
- }
204
-
205
- if ( 'user' === $args['object'] ) {
206
- $avatar_dir = 'avatars';
207
- } else {
208
- $avatar_dir = sanitize_key( $args['object'] ) . '-avatars';
209
- }
210
-
211
- $args['item_id'] = (int) $args['item_id'];
212
-
213
- /**
214
- * Original file is a relative path to the image
215
- * eg: /avatars/1/avatar.jpg
216
- */
217
- $relative_path = sprintf( '/%s/%s/%s', $avatar_dir, $args['item_id'], basename( $args['original_file'] ) );
218
- $absolute_path = $this->upload_path . $relative_path;
219
-
220
- // Bail if the avatar is not available
221
- if ( ! file_exists( $absolute_path ) ) {
222
- return false;
223
- }
224
-
225
- if ( empty( $args['item_id'] ) ) {
226
-
227
- /** This filter is documented in bp-core/bp-core-avatars.php */
228
- $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', dirname( $absolute_path ), $args['item_id'], $args['object'], $args['avatar_dir'] );
229
- } else {
230
-
231
- /** This filter is documented in bp-core/bp-core-avatars.php */
232
- $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', $this->upload_path . '/' . $args['avatar_dir'] . '/' . $args['item_id'], $args['item_id'], $args['object'], $args['avatar_dir'] );
233
- }
234
-
235
- // Bail if the avatar folder is missing for this item_id
236
- if ( ! file_exists( $avatar_folder_dir ) ) {
237
- return false;
238
- }
239
-
240
- // Delete the existing avatar files for the object
241
- $existing_avatar = bp_core_fetch_avatar( array(
242
- 'object' => $args['object'],
243
- 'item_id' => $args['item_id'],
244
- 'html' => false,
245
- ) );
246
-
247
- /**
248
- * Check that the new avatar doesn't have the same name as the
249
- * old one before deleting
250
- */
251
- if ( ! empty( $existing_avatar ) && $existing_avatar !== $this->url . $relative_path ) {
252
- bp_core_delete_existing_avatar( array( 'object' => $args['object'], 'item_id' => $args['item_id'], 'avatar_path' => $avatar_folder_dir ) );
253
- }
254
-
255
- // Make sure we at least have minimal data for cropping
256
- if ( empty( $args['crop_w'] ) ) {
257
- $args['crop_w'] = bp_core_avatar_full_width();
258
- }
259
-
260
- if ( empty( $args['crop_h'] ) ) {
261
- $args['crop_h'] = bp_core_avatar_full_height();
262
- }
263
-
264
- // Get the file extension
265
- $data = @getimagesize( $absolute_path );
266
- $ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
267
-
268
- $args['original_file'] = $absolute_path;
269
- $args['src_abs'] = false;
270
- $avatar_types = array( 'full' => '', 'thumb' => '' );
271
-
272
- foreach ( $avatar_types as $key_type => $type ) {
273
- if ( 'thumb' === $key_type ) {
274
- $args['dst_w'] = bp_core_avatar_thumb_width();
275
- $args['dst_h'] = bp_core_avatar_thumb_height();
276
- } else {
277
- $args['dst_w'] = bp_core_avatar_full_width();
278
- $args['dst_h'] = bp_core_avatar_full_height();
279
- }
280
-
281
- $args['dst_file'] = $avatar_folder_dir . '/' . wp_hash( $absolute_path . time() ) . '-bp' . $key_type . '.' . $ext;
282
-
283
- $avatar_types[ $key_type ] = parent::crop( $args );
284
- }
285
-
286
- // Remove the original
287
- @unlink( $absolute_path );
288
-
289
- // Return the full and thumb cropped avatars
290
- return $avatar_types;
291
- }
292
-
293
- /**
294
- * Get the user id to set its avatar
295
- *
296
- * @since BuddyPress (2.3.0)
297
- *
298
- * @return integer the user ID
299
- */
300
- private function get_user_id() {
301
- $bp = buddypress();
302
- $user_id = 0;
303
-
304
- if ( bp_is_user() ) {
305
- $user_id = bp_displayed_user_id();
306
- }
307
-
308
- if ( ! empty( $bp->members->admin->user_id ) ) {
309
- $user_id = $bp->members->admin->user_id;
310
- }
311
-
312
- return $user_id;
313
- }
314
-
315
- /**
316
- * Get the group id to set its avatar
317
- *
318
- * @since BuddyPress (2.3.0)
319
- *
320
- * @return integer the group id
321
- */
322
- private function get_group_id() {
323
- $group_id = 0;
324
-
325
- if ( bp_is_group() ) {
326
- $group_id = bp_get_current_group_id();
327
- }
328
-
329
- return $group_id;
330
- }
331
-
332
- /**
333
- * Build script datas for the Uploader UI
334
- *
335
- * @since BuddyPress (2.3.0)
336
- *
337
- * @return array the javascript localization data
338
- */
339
- public function script_data() {
340
- // Get default script data
341
- $script_data = parent::script_data();
342
-
343
- // Defaults to Avatar Backbone script
344
- $js_scripts = array( 'bp-avatar' );
345
-
346
- // Default object
347
- $object = '';
348
-
349
- // Get the possible item ids
350
- $user_id = $this->get_user_id();
351
- $group_id = $this->get_group_id();
352
-
353
- if ( ! empty( $user_id ) ) {
354
- // Should we load the the Webcam Avatar javascript file
355
- if ( bp_avatar_use_webcam() ) {
356
- $js_scripts = array( 'bp-webcam' );
357
- }
358
-
359
- $script_data['bp_params'] = array(
360
- 'object' => 'user',
361
- 'item_id' => $user_id,
362
- 'has_avatar' => bp_get_user_has_avatar( $user_id ),
363
- 'nonces' => array(
364
- 'set' => wp_create_nonce( 'bp_avatar_cropstore' ),
365
- 'remove' => wp_create_nonce( 'bp_delete_avatar_link' ),
366
- ),
367
- );
368
-
369
- // Set feedback messages
370
- $script_data['feedback_messages'] = array(
371
- 1 => __( 'There was a problem cropping your profile photo.', 'buddypress' ),
372
- 2 => __( 'Your new profile photo was uploaded successfully.', 'buddypress' ),
373
- 3 => __( 'There was a problem deleting your profile photo. Please try again.', 'buddypress' ),
374
- 4 => __( 'Your profile photo was deleted successfully!', 'buddypress' ),
375
- );
376
- } elseif ( ! empty( $group_id ) ) {
377
- $script_data['bp_params'] = array(
378
- 'object' => 'group',
379
- 'item_id' => $group_id,
380
- 'has_avatar' => bp_get_group_has_avatar( $group_id ),
381
- 'nonces' => array(
382
- 'set' => wp_create_nonce( 'bp_avatar_cropstore' ),
383
- 'remove' => wp_create_nonce( 'bp_group_avatar_delete' ),
384
- ),
385
- );
386
-
387
- // Set feedback messages
388
- $script_data['feedback_messages'] = array(
389
- 1 => __( 'There was a problem cropping the group profile photo.', 'buddypress' ),
390
- 2 => __( 'The group profile photo was uploaded successfully.', 'buddypress' ),
391
- 3 => __( 'There was a problem deleting the group profile photo. Please try again.', 'buddypress' ),
392
- 4 => __( 'The group profile photo was deleted successfully!', 'buddypress' ),
393
- );
394
- } else {
395
- /**
396
- * Use this filter to include specific BuddyPress params for your object
397
- * e.g. Blavatar
398
- *
399
- * @since BuddyPress (2.3.0)
400
- *
401
- * @param array the avatar specific BuddyPress parameters
402
- */
403
- $script_data['bp_params'] = apply_filters( 'bp_attachment_avatar_params', array() );
404
- }
405
-
406
- // Include the specific css
407
- $script_data['extra_css'] = array( 'bp-avatar' );
408
-
409
- // Include the specific css
410
- $script_data['extra_js'] = $js_scripts;
411
-
412
- // Set the object to contextualize the filter
413
- if ( isset( $script_data['bp_params']['object'] ) ) {
414
- $object = $script_data['bp_params']['object'];
415
- }
416
-
417
- /**
418
- * Use this filter to override/extend the avatar script data
419
- *
420
- * @since BuddyPress (2.3.0)
421
- *
422
- * @param array $script_data the avatar script data
423
- * @param string $object the object the avatar belongs to (eg: user or group)
424
- */
425
- return apply_filters( 'bp_attachment_avatar_script_data', $script_data, $object );
426
- }
427
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-attachment.php DELETED
@@ -1,518 +0,0 @@
1
- <?php
2
- /**
3
- * Core attachment class.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * BP Attachment class
14
- *
15
- * Extend it to manage your component's uploads.
16
- *
17
- * @since BuddyPress (2.3.0)
18
- */
19
- abstract class BP_Attachment {
20
-
21
- /** Upload properties *****************************************************/
22
-
23
- /**
24
- * The file being uploaded
25
- *
26
- * @var array
27
- */
28
- public $attachment = array();
29
-
30
- /**
31
- * The default args to be merged with the
32
- * ones passed by the child class
33
- *
34
- * @var array
35
- */
36
- protected $default_args = array(
37
- 'original_max_filesize' => 0,
38
- 'allowed_mime_types' => array(),
39
- 'base_dir' => '',
40
- 'action' => '',
41
- 'file_input' => '',
42
- 'upload_error_strings' => array(),
43
- 'required_wp_files' => array( 'file' ),
44
- );
45
-
46
- /**
47
- * Construct Upload parameters
48
- *
49
- * @since BuddyPress (2.3.0)
50
- *
51
- * @param array $args {
52
- * @type int $original_max_filesize Maximum file size in kilobytes. Defaults to php.ini settings.
53
- * @type array $allowed_mime_types List of allowed file extensions (eg: array( 'jpg', 'gif', 'png' ) ).
54
- * Defaults to WordPress allowed mime types
55
- * @type string $base_dir Component's upload base directory. Defaults to WordPress 'uploads'
56
- * @type string $action The upload action used when uploading a file, $_POST['action'] must be set
57
- * and its value must equal $action {@link wp_handle_upload()} (required)
58
- * @type string $file_input The name attribute used in the file input. (required)
59
- * @type array $upload_error_strings A list of specific error messages (optional).
60
- * @type array $required_wp_files The list of required WordPress core files. Default: array( 'file' );
61
- * }
62
- * @uses sanitize_key()
63
- * @uses wp_max_upload_size()
64
- * @uses bp_parse_args()
65
- * @uses BP_Attachment->set_upload_error_strings()
66
- * @uses BP_Attachment->set_upload_dir()
67
- */
68
- public function __construct( $args = '' ) {
69
- // Upload action and the file input name are required parameters
70
- if ( empty( $args['action'] ) || empty( $args['file_input'] ) ) {
71
- return false;
72
- }
73
-
74
- // Sanitize the action ID and the file input name
75
- $this->action = sanitize_key( $args['action'] );
76
- $this->file_input = sanitize_key( $args['file_input'] );
77
-
78
- /**
79
- * Max file size defaults to php ini settings or, in the case of
80
- * a multisite config, the root site fileupload_maxk option
81
- */
82
- $this->default_args['original_max_filesize'] = (int) wp_max_upload_size();
83
-
84
- $params = bp_parse_args( $args, $this->default_args, $this->action . '_upload_params' );
85
-
86
- foreach ( $params as $key => $param ) {
87
- if ( 'upload_error_strings' === $key ) {
88
- $this->{$key} = $this->set_upload_error_strings( $param );
89
-
90
- // Sanitize the base dir
91
- } elseif ( 'base_dir' === $key ) {
92
- $this->{$key} = sanitize_title( $param );
93
-
94
- // Action & File input are already set and sanitized
95
- } elseif ( 'action' !== $key && 'file_input' !== $key ) {
96
- $this->{$key} = $param;
97
- }
98
- }
99
-
100
- // Set the path/url and base dir for uploads
101
- $this->set_upload_dir();
102
- }
103
-
104
- /**
105
- * Set upload path and url for the component.
106
- *
107
- * @since BuddyPress (2.3.0)
108
- *
109
- * @uses bp_upload_dir()
110
- */
111
- public function set_upload_dir() {
112
- // Set the directory, path, & url variables
113
- $this->upload_dir = bp_upload_dir();
114
-
115
- if ( empty( $this->upload_dir ) ) {
116
- return false;
117
- }
118
-
119
- $this->upload_path = $this->upload_dir['basedir'];
120
- $this->url = $this->upload_dir['baseurl'];
121
-
122
- // Ensure URL is https if SSL is set/forced
123
- if ( is_ssl() ) {
124
- $this->url = str_replace( 'http://', 'https://', $this->url );
125
- }
126
-
127
- /**
128
- * Custom base dir.
129
- *
130
- * If the component set this property, set the specific path, url and create the dir
131
- */
132
- if ( ! empty( $this->base_dir ) ) {
133
- $this->upload_path = trailingslashit( $this->upload_path ) . $this->base_dir;
134
- $this->url = trailingslashit( $this->url ) . $this->base_dir;
135
-
136
- // Finally create the base dir
137
- $this->create_dir();
138
- }
139
- }
140
-
141
- /**
142
- * Set Upload error messages
143
- *
144
- * Used into the $overrides argument of BP_Attachment->upload()
145
- *
146
- * @since BuddyPress (2.3.0)
147
- *
148
- * @param array $param a list of error messages to add to BuddyPress core ones
149
- * @return array the list of upload errors
150
- */
151
- public function set_upload_error_strings( $param = array() ) {
152
- /**
153
- * Index of the array is the error code
154
- * Custom errors will start at 9 code
155
- */
156
- $upload_errors = array(
157
- 0 => __( 'The file was uploaded successfully', 'buddypress' ),
158
- 1 => __( 'The uploaded file exceeds the maximum allowed file size for this site', 'buddypress' ),
159
- 2 => sprintf( __( 'The uploaded file exceeds the maximum allowed file size of: %s', 'buddypress' ), size_format( $this->original_max_filesize ) ),
160
- 3 => __( 'The uploaded file was only partially uploaded.', 'buddypress' ),
161
- 4 => __( 'No file was uploaded.', 'buddypress' ),
162
- 5 => '',
163
- 6 => __( 'Missing a temporary folder.', 'buddypress' ),
164
- 7 => __( 'Failed to write file to disk.', 'buddypress' ),
165
- 8 => __( 'File upload stopped by extension.', 'buddypress' ),
166
- );
167
-
168
- if ( ! array_intersect_key( $upload_errors, (array) $param ) ) {
169
- foreach ( $param as $key_error => $error_message ) {
170
- $upload_errors[ $key_error ] = $error_message;
171
- }
172
- }
173
-
174
- return $upload_errors;
175
- }
176
-
177
- /**
178
- * Include the WordPress core needed files
179
- *
180
- * @since BuddyPress (2.3.0)
181
- */
182
- public function includes() {
183
- foreach ( array_unique( $this->required_wp_files ) as $wp_file ) {
184
- if ( ! file_exists( ABSPATH . "/wp-admin/includes/{$wp_file}.php" ) ) {
185
- continue;
186
- }
187
-
188
- require_once( ABSPATH . "/wp-admin/includes/{$wp_file}.php" );
189
- }
190
- }
191
-
192
- /**
193
- * Upload the attachment
194
- *
195
- * @since BuddyPress (2.3.0)
196
- *
197
- * @param array $file The appropriate entry the from $_FILES superglobal.
198
- * @param string $upload_dir_filter A specific filter to be applied to 'upload_dir' (optional).
199
- * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
200
- * @uses wp_handle_upload() To upload the file
201
- * @uses add_filter() To temporarly overrides WordPress uploads data
202
- * @uses remove_filter() To stop overriding WordPress uploads data
203
- * @uses apply_filters() Call 'bp_attachment_upload_overrides' to include specific upload overrides
204
- *
205
- * @return array On success, returns an associative array of file attributes.
206
- * On failure, returns an array containing the error message
207
- * (eg: array( 'error' => $message ) )
208
- */
209
- public function upload( $file, $upload_dir_filter = '', $time = null ) {
210
- /**
211
- * Upload action and the file input name are required parameters
212
- * @see BP_Attachment:__construct()
213
- */
214
- if ( empty( $this->action ) || empty( $this->file_input ) ) {
215
- return false;
216
- }
217
-
218
- /**
219
- * Add custom rules before enabling the file upload
220
- */
221
- add_filter( "{$this->action}_prefilter", array( $this, 'validate_upload' ), 10, 1 );
222
-
223
- /**
224
- * The above dynamic filter was introduced in WordPress 4.0, as we support WordPress
225
- * back to 3.6, we need to also use the pre 4.0 static filter and remove it after
226
- * the upload was processed.
227
- */
228
- add_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 );
229
-
230
- // Set Default overrides
231
- $overrides = array(
232
- 'action' => $this->action,
233
- 'upload_error_strings' => $this->upload_error_strings,
234
- );
235
-
236
- /**
237
- * Add a mime override if needed
238
- * Used to restrict uploads by extensions
239
- */
240
- if ( ! empty( $this->allowed_mime_types ) ) {
241
- $mime_types = $this->validate_mime_types();
242
-
243
- if ( ! empty( $mime_types ) ) {
244
- $overrides['mimes'] = $mime_types;
245
- }
246
- }
247
-
248
- /**
249
- * If you need to add some overrides we haven't thought of
250
- *
251
- * @var array $overrides the wp_handle_upload overrides
252
- */
253
- $overrides = apply_filters( 'bp_attachment_upload_overrides', $overrides );
254
-
255
- $this->includes();
256
-
257
- /**
258
- * If the $base_dir was set when constructing the class,
259
- * and no specific filter has been requested, use a default
260
- * filter to create the specific $base dir
261
- * @see BP_Attachment->upload_dir_filter()
262
- */
263
- if ( empty( $upload_dir_filter ) && ! empty( $this->base_dir ) ) {
264
- $upload_dir_filter = array( $this, 'upload_dir_filter' );
265
- }
266
-
267
- // Make sure the file will be uploaded in the attachment directory
268
- if ( ! empty( $upload_dir_filter ) ) {
269
- add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
270
- }
271
-
272
- // Upload the attachment
273
- $this->attachment = wp_handle_upload( $file[ $this->file_input ], $overrides, $time );
274
-
275
- // Restore WordPress Uploads data
276
- if ( ! empty( $upload_dir_filter ) ) {
277
- remove_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
278
- }
279
-
280
- // Remove the pre WordPress 4.0 static filter
281
- remove_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 );
282
-
283
- // Finally return the uploaded file or the error
284
- return $this->attachment;
285
- }
286
-
287
- /**
288
- * Validate the allowed mime types using WordPress allowed mime types
289
- *
290
- * In case of a multisite, the mime types are already restricted by
291
- * the 'upload_filetypes' setting. BuddyPress will respect this setting.
292
- * @see check_upload_mimes()
293
- *
294
- * @since BuddyPress (2.3.0)
295
- *
296
- * @uses get_allowed_mime_types()
297
- */
298
- protected function validate_mime_types() {
299
- $wp_mimes = get_allowed_mime_types();
300
- $valid_mimes = array();
301
-
302
- // Set the allowed mimes for the upload
303
- foreach ( (array) $this->allowed_mime_types as $ext ) {
304
- foreach ( $wp_mimes as $ext_pattern => $mime ) {
305
- if ( $ext !== '' && strpos( $ext_pattern, $ext ) !== false ) {
306
- $valid_mimes[$ext_pattern] = $mime;
307
- }
308
- }
309
- }
310
- return $valid_mimes;
311
- }
312
-
313
- /**
314
- * Specific upload rules
315
- *
316
- * Override this function from your child class to build your specific rules
317
- * By default, if an original_max_filesize is provided, a check will be done
318
- * on the file size.
319
- *
320
- * @see BP_Attachment_Avatar->validate_upload() for an example of use
321
- *
322
- * @since BuddyPress (2.3.0)
323
- *
324
- * @param array $file the temporary file attributes (before it has been moved)
325
- * @return array the file
326
- */
327
- public function validate_upload( $file = array() ) {
328
- // Bail if already an error
329
- if ( ! empty( $file['error'] ) ) {
330
- return $file;
331
- }
332
-
333
- if ( ! empty( $this->original_max_filesize ) && $file['size'] > $this->original_max_filesize ) {
334
- $file['error'] = 2;
335
- }
336
-
337
- // Return the file
338
- return $file;
339
- }
340
-
341
- /**
342
- * Default filter to save the attachments
343
- *
344
- * @since BuddyPress (2.3.0)
345
- *
346
- * @uses apply_filters() call 'bp_attachment_upload_dir' to eventually override the upload location
347
- * regarding to context
348
- * @return array the upload directory data
349
- */
350
- public function upload_dir_filter() {
351
- /**
352
- * Filters the component's upload directory.
353
- *
354
- * @since BuddyPress (2.3.0)
355
- *
356
- * @param array $value Array containing the path, URL, and other helpful settings.
357
- */
358
- return apply_filters( 'bp_attachment_upload_dir', array(
359
- 'path' => $this->upload_path,
360
- 'url' => $this->url,
361
- 'subdir' => false,
362
- 'basedir' => $this->upload_path,
363
- 'baseurl' => $this->url,
364
- 'error' => false
365
- ) );
366
- }
367
-
368
- /**
369
- * Create the custom base directory for the component uploads
370
- *
371
- * Override this function in your child class to run specific actions
372
- * (eg: add an .htaccess file)
373
- *
374
- * @since BuddyPress (2.3.0)
375
- *
376
- * @uses wp_mkdir_p()
377
- */
378
- public function create_dir() {
379
- // Bail if no specific base dir is set
380
- if ( empty( $this->base_dir ) ) {
381
- return false;
382
- }
383
-
384
- // Check if upload path already exists
385
- if ( ! is_dir( $this->upload_path ) ) {
386
-
387
- // If path does not exist, attempt to create it
388
- if ( ! wp_mkdir_p( $this->upload_path ) ) {
389
- return false;
390
- }
391
- }
392
-
393
- // Directory exists
394
- return true;
395
- }
396
-
397
- /**
398
- * Crop an image file
399
- *
400
- * @since BuddyPress (2.3.0)
401
- *
402
- * @param array $args {
403
- * @type string $original_file The source file (absolute path) for the Attachment.
404
- * @type int $crop_x The start x position to crop from.
405
- * @type int $crop_y The start y position to crop from.
406
- * @type int $crop_w The width to crop.
407
- * @type int $crop_h The height to crop.
408
- * @type int $dst_w The destination width.
409
- * @type int $dst_h The destination height.
410
- * @type int $src_abs Optional. If the source crop points are absolute.
411
- * @type string $dst_file Optional. The destination file to write to.
412
- * }
413
- * @uses wp_crop_image()
414
- * @return string|WP_Error New filepath on success, WP_Error on failure.
415
- */
416
- public function crop( $args = array() ) {
417
- $wp_error = new WP_Error();
418
-
419
- $r = bp_parse_args( $args, array(
420
- 'original_file' => '',
421
- 'crop_x' => 0,
422
- 'crop_y' => 0,
423
- 'crop_w' => 0,
424
- 'crop_h' => 0,
425
- 'dst_w' => 0,
426
- 'dst_h' => 0,
427
- 'src_abs' => false,
428
- 'dst_file' => false,
429
- ), 'bp_attachment_crop_args' );
430
-
431
- if ( empty( $r['original_file'] ) || ! file_exists( $r['original_file'] ) ) {
432
- $wp_error->add( 'crop_error', __( 'Cropping the file failed: missing source file.', 'buddypress' ) );
433
- return $wp_error;
434
- }
435
-
436
- // Check image file pathes
437
- $path_error = __( 'Cropping the file failed: the file path is not allowed.', 'buddypress' );
438
-
439
- // Make sure it's coming from an uploaded file
440
- if ( false === strpos( $r['original_file'], $this->upload_path ) ) {
441
- $wp_error->add( 'crop_error', $path_error );
442
- return $wp_error;
443
- }
444
-
445
- /**
446
- * If no destination file is provided, WordPress will use a default name
447
- * and will write the file in the source file's folder.
448
- * If a destination file is provided, we need to make sure it's going into uploads
449
- */
450
- if ( ! empty( $r['dst_file'] ) && false === strpos( $r['dst_file'], $this->upload_path ) ) {
451
- $wp_error->add( 'crop_error', $path_error );
452
- return $wp_error;
453
- }
454
-
455
- // Check image file types
456
- $check_types = array( 'src_file' => array( 'file' => $r['original_file'], 'error' => _x( 'source file', 'Attachment source file', 'buddypress' ) ) );
457
- if ( ! empty( $r['dst_file'] ) ) {
458
- $check_types['dst_file'] = array( 'file' => $r['dst_file'], 'error' => _x( 'destination file', 'Attachment destination file', 'buddypress' ) );
459
- }
460
-
461
- /**
462
- * WordPress image supported types
463
- * @see wp_attachment_is()
464
- */
465
- $supported_image_types = array(
466
- 'jpg' => 1,
467
- 'jpeg' => 1,
468
- 'jpe' => 1,
469
- 'gif' => 1,
470
- 'png' => 1,
471
- );
472
-
473
- foreach ( $check_types as $file ) {
474
- $is_image = wp_check_filetype( $file['file'] );
475
- $ext = $is_image['ext'];
476
-
477
- if ( empty( $ext ) || empty( $supported_image_types[ $ext ] ) ) {
478
- $wp_error->add( 'crop_error', sprintf( __( 'Cropping the file failed: %s is not a supported image file.', 'buddypress' ), $file['error'] ) );
479
- return $wp_error;
480
- }
481
- }
482
-
483
- // Add the image.php to the required WordPress files, if it's not already the case
484
- $required_files = array_flip( $this->required_wp_files );
485
- if ( ! isset( $required_files['image'] ) ) {
486
- $this->required_wp_files[] = 'image';
487
- }
488
-
489
- // Load the files
490
- $this->includes();
491
-
492
- // Finally crop the image
493
- return wp_crop_image( $r['original_file'], (int) $r['crop_x'], (int) $r['crop_y'], (int) $r['crop_w'], (int) $r['crop_h'], (int) $r['dst_w'], (int) $r['dst_h'], $r['src_abs'], $r['dst_file'] );
494
- }
495
-
496
- /**
497
- * Build script datas for the Uploader UI
498
- *
499
- * Override this method from your child class to build the script datas
500
- *
501
- * @since BuddyPress (2.3.0)
502
- *
503
- * @return array the javascript localization data
504
- */
505
- public function script_data() {
506
- $script_data = array(
507
- 'action' => $this->action,
508
- 'file_data_name' => $this->file_input,
509
- 'max_file_size' => $this->original_max_filesize,
510
- 'feedback_messages' => array(
511
- 1 => __( 'Sorry, uploading the file failed.', 'buddypress' ),
512
- 2 => __( 'File successfully uploaded.', 'buddypress' ),
513
- ),
514
- );
515
-
516
- return $script_data;
517
- }
518
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-button.php DELETED
@@ -1,270 +0,0 @@
1
- <?php
2
- /**
3
- * Core component classes.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * API to create BuddyPress buttons.
14
- *
15
- * @since BuddyPress (1.2.6)
16
- *
17
- * @param array $args {
18
- * Array of arguments.
19
- * @type string $id String describing the button type.
20
- * @type string $component The name of the component the button belongs to.
21
- * Default: 'core'.
22
- * @type bool $must_be_logged_in Optional. Does the user need to be logged
23
- * in to see this button? Default: true.
24
- * @type bool $block_self Optional. True if the button should be hidden
25
- * when a user is viewing his own profile. Default: true.
26
- * @type string|bool $wrapper Optional. HTML element type that should wrap
27
- * the button: 'div', 'span', 'p', or 'li'. False for no wrapper at
28
- * all. Default: 'div'.
29
- * @type string $wrapper_id Optional. DOM ID of the button wrapper element.
30
- * Default: ''.
31
- * @type string $wrapper_class Optional. DOM class of the button wrapper
32
- * element. Default: ''.
33
- * @type string $link_href Optional. Destination link of the button.
34
- * Default: ''.
35
- * @type string $link_class Optional. DOM class of the button. Default: ''.
36
- * @type string $link_id Optional. DOM ID of the button. Default: ''.
37
- * @type string $link_rel Optional. DOM 'rel' attribute of the button.
38
- * Default: ''.
39
- * @type string $link_title Optional. Title attribute of the button.
40
- * Default: ''.
41
- * @type string $link_text Optional. Text to appear on the button.
42
- * Default: ''.
43
- * }
44
- */
45
- class BP_Button {
46
-
47
- /** Button properties *****************************************************/
48
-
49
- /**
50
- * The button ID.
51
- *
52
- * @var string
53
- */
54
- public $id = '';
55
-
56
- /**
57
- * The name of the component that the button belongs to.
58
- *
59
- * @var string
60
- */
61
- public $component = 'core';
62
-
63
- /**
64
- * Does the user need to be logged in to see this button?
65
- *
66
- * @var bool
67
- */
68
- public $must_be_logged_in = true;
69
-
70
- /**
71
- * Whether the button should be hidden when viewing your own profile.
72
- *
73
- * @var bool
74
- */
75
- public $block_self = true;
76
-
77
- /** Wrapper ***************************************************************/
78
-
79
- /**
80
- * The type of DOM element to use for a wrapper.
81
- *
82
- * @var string|bool 'div', 'span', 'p', 'li', or false for no wrapper.
83
- */
84
- public $wrapper = 'div';
85
-
86
- /**
87
- * The DOM class of the button wrapper.
88
- *
89
- * @var string
90
- */
91
- public $wrapper_class = '';
92
-
93
- /**
94
- * The DOM ID of the button wrapper.
95
- *
96
- * @var string
97
- */
98
- public $wrapper_id = '';
99
-
100
- /** Button ****************************************************************/
101
-
102
- /**
103
- * The destination link of the button.
104
- *
105
- * @var string
106
- */
107
- public $link_href = '';
108
-
109
- /**
110
- * The DOM class of the button link.
111
- *
112
- * @var string
113
- */
114
- public $link_class = '';
115
-
116
- /**
117
- * The DOM ID of the button link.
118
- *
119
- * @var string
120
- */
121
- public $link_id = '';
122
-
123
- /**
124
- * The DOM rel value of the button link.
125
- *
126
- * @var string
127
- */
128
- public $link_rel = '';
129
-
130
- /**
131
- * Title of the button link.
132
- *
133
- * @var string
134
- */
135
- public $link_title = '';
136
-
137
- /**
138
- * The contents of the button link.
139
- *
140
- * @var string
141
- */
142
- public $link_text = '';
143
-
144
- /** HTML result ***********************************************************/
145
-
146
- public $contents = '';
147
-
148
- /** Methods ***************************************************************/
149
-
150
- /**
151
- * Builds the button based on class parameters.
152
- *
153
- * @since BuddyPress (1.2.6)
154
- *
155
- * @param array $args See {@BP_Button}.
156
- * @return bool|null Returns false when the button is not allowed for
157
- * the current context.
158
- */
159
- public function __construct( $args = '' ) {
160
-
161
- $r = wp_parse_args( $args, get_class_vars( __CLASS__ ) );
162
-
163
- // Required button properties
164
- $this->id = $r['id'];
165
- $this->component = $r['component'];
166
- $this->must_be_logged_in = (bool) $r['must_be_logged_in'];
167
- $this->block_self = (bool) $r['block_self'];
168
- $this->wrapper = $r['wrapper'];
169
-
170
- // $id and $component are required
171
- if ( empty( $r['id'] ) || empty( $r['component'] ) )
172
- return false;
173
-
174
- // No button if component is not active
175
- if ( ! bp_is_active( $this->component ) )
176
- return false;
177
-
178
- // No button for guests if must be logged in
179
- if ( true == $this->must_be_logged_in && ! is_user_logged_in() )
180
- return false;
181
-
182
- // block_self
183
- if ( true == $this->block_self ) {
184
- // No button if you are the current user in a members loop
185
- // This condition takes precedence, because members loops
186
- // can be found on user profiles
187
- if ( bp_get_member_user_id() ) {
188
- if ( is_user_logged_in() && bp_loggedin_user_id() == bp_get_member_user_id() ) {
189
- return false;
190
- }
191
-
192
- // No button if viewing your own profile (and not in
193
- // a members loop)
194
- } elseif ( bp_is_my_profile() ) {
195
- return false;
196
- }
197
- }
198
-
199
- // Wrapper properties
200
- if ( false !== $this->wrapper ) {
201
-
202
- // Wrapper ID
203
- if ( !empty( $r['wrapper_id'] ) ) {
204
- $this->wrapper_id = ' id="' . $r['wrapper_id'] . '"';
205
- }
206
-
207
- // Wrapper class
208
- if ( !empty( $r['wrapper_class'] ) ) {
209
- $this->wrapper_class = ' class="generic-button ' . $r['wrapper_class'] . '"';
210
- } else {
211
- $this->wrapper_class = ' class="generic-button"';
212
- }
213
-
214
- // Set before and after
215
- $before = '<' . $r['wrapper'] . $this->wrapper_class . $this->wrapper_id . '>';
216
- $after = '</' . $r['wrapper'] . '>';
217
-
218
- // No wrapper
219
- } else {
220
- $before = $after = '';
221
- }
222
-
223
- // Link properties
224
- if ( !empty( $r['link_id'] ) ) $this->link_id = ' id="' . $r['link_id'] . '"';
225
- if ( !empty( $r['link_href'] ) ) $this->link_href = ' href="' . $r['link_href'] . '"';
226
- if ( !empty( $r['link_title'] ) ) $this->link_title = ' title="' . $r['link_title'] . '"';
227
- if ( !empty( $r['link_rel'] ) ) $this->link_rel = ' rel="' . $r['link_rel'] . '"';
228
- if ( !empty( $r['link_class'] ) ) $this->link_class = ' class="' . $r['link_class'] . '"';
229
- if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text'];
230
-
231
- // Build the button
232
- $this->contents = $before . '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>' . $after;
233
-
234
- /**
235
- * Filters the button based on class parameters.
236
- *
237
- * This filter is a dynamic filter based on component and component ID and
238
- * allows button to be manipulated externally.
239
- *
240
- * @since BuddyPress (1.2.6)
241
- *
242
- * @param string $contents HTML being used for the button.
243
- * @param BP_Button $this Current BP_Button instance.
244
- * @param string $before HTML appended before the actual button.
245
- * @param string $after HTML appended after the actual button.
246
- */
247
- $this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after );
248
- }
249
-
250
- /**
251
- * Return the markup for the generated button.
252
- *
253
- * @since BuddyPress (1.2.6)
254
- *
255
- * @return string Button markup.
256
- */
257
- public function contents() {
258
- return $this->contents;
259
- }
260
-
261
- /**
262
- * Output the markup of button.
263
- *
264
- * @since BuddyPress (1.2.6)
265
- */
266
- public function display() {
267
- if ( !empty( $this->contents ) )
268
- echo $this->contents;
269
- }
270
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-core-notification.php DELETED
@@ -1,258 +0,0 @@
1
- <?php
2
- /**
3
- * Core component classes.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * BP_Core_Notification is deprecated.
14
- *
15
- * Use BP_Notifications_Notification instead.
16
- *
17
- * @package BuddyPress Core
18
- * @deprecated since BuddyPress (1.9.0)
19
- */
20
- class BP_Core_Notification {
21
-
22
- /**
23
- * The notification id
24
- *
25
- * @var integer
26
- */
27
- public $id;
28
-
29
- /**
30
- * The ID to which the notification relates to within the component.
31
- *
32
- * @var integer
33
- */
34
- public $item_id;
35
-
36
- /**
37
- * The secondary ID to which the notification relates to within the component.
38
- *
39
- * @var integer
40
- */
41
- public $secondary_item_id = null;
42
-
43
- /**
44
- * The user ID for who the notification is for.
45
- *
46
- * @var integer
47
- */
48
- public $user_id;
49
-
50
- /**
51
- * The name of the component that the notification is for.
52
- *
53
- * @var string
54
- */
55
- public $component_name;
56
-
57
- /**
58
- * The action within the component which the notification is related to.
59
- *
60
- * @var string
61
- */
62
- public $component_action;
63
-
64
- /**
65
- * The date the notification was created.
66
- *
67
- * @var string
68
- */
69
- public $date_notified;
70
-
71
- /**
72
- * Is the notification new or has it already been read.
73
- *
74
- * @var boolean
75
- */
76
- public $is_new;
77
-
78
- /** Public Methods ********************************************************/
79
-
80
- /**
81
- * Constructor
82
- *
83
- * @param integer $id
84
- */
85
- public function __construct( $id = 0 ) {
86
- if ( !empty( $id ) ) {
87
- $this->id = $id;
88
- $this->populate();
89
- }
90
- }
91
-
92
- /**
93
- * Update or insert notification details into the database.
94
- *
95
- * @global wpdb $wpdb WordPress database object
96
- * @return bool Success or failure
97
- */
98
- public function save() {
99
- global $wpdb;
100
-
101
- $bp = buddypress();
102
-
103
- // Update
104
- if ( !empty( $this->id ) ) {
105
- $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
106
-
107
- // Save
108
- } else {
109
- $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
110
- }
111
-
112
- if ( !$result = $wpdb->query( $sql ) )
113
- return false;
114
-
115
- $this->id = $wpdb->insert_id;
116
-
117
- return true;
118
- }
119
-
120
- /** Private Methods *******************************************************/
121
-
122
- /**
123
- * Fetches the notification data from the database.
124
- *
125
- * @global wpdb $wpdb WordPress database object
126
- */
127
- public function populate() {
128
- global $wpdb;
129
-
130
- $bp = buddypress();
131
-
132
- if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
133
- $this->item_id = $notification->item_id;
134
- $this->secondary_item_id = $notification->secondary_item_id;
135
- $this->user_id = $notification->user_id;
136
- $this->component_name = $notification->component_name;
137
- $this->component_action = $notification->component_action;
138
- $this->date_notified = $notification->date_notified;
139
- $this->is_new = $notification->is_new;
140
- }
141
- }
142
-
143
- /** Static Methods ********************************************************/
144
-
145
- public static function check_access( $user_id, $notification_id ) {
146
- global $wpdb;
147
-
148
- $bp = buddypress();
149
-
150
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );
151
- }
152
-
153
- /**
154
- * Fetches all the notifications in the database for a specific user.
155
- *
156
- * @global wpdb $wpdb WordPress database object
157
- * @param integer $user_id User ID
158
- * @param string $status 'is_new' or 'all'
159
- * @return array Associative array
160
- * @static
161
- */
162
- public static function get_all_for_user( $user_id, $status = 'is_new' ) {
163
- global $wpdb;
164
-
165
- $bp = buddypress();
166
-
167
- $is_new = ( 'is_new' === $status )
168
- ? ' AND is_new = 1 '
169
- : '';
170
-
171
- return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) );
172
- }
173
-
174
- /**
175
- * Delete all the notifications for a user based on the component name and action.
176
- *
177
- * @global wpdb $wpdb WordPress database object
178
- * @param integer $user_id
179
- * @param string $component_name
180
- * @param string $component_action
181
- * @static
182
- */
183
- public static function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
184
- global $wpdb;
185
-
186
- $bp = buddypress();
187
-
188
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
189
- }
190
-
191
- /**
192
- * Delete all the notifications that have a specific item id, component name and action.
193
- *
194
- * @global wpdb $wpdb WordPress database object
195
- * @param integer $user_id The ID of the user who the notifications are for.
196
- * @param integer $item_id The item ID of the notifications we wish to delete.
197
- * @param string $component_name The name of the component that the notifications we wish to delete.
198
- * @param string $component_action The action of the component that the notifications we wish to delete.
199
- * @param integer $secondary_item_id (optional) The secondary item id of the notifications that we wish to use to delete.
200
- * @static
201
- */
202
- public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
203
- global $wpdb;
204
-
205
- $bp = buddypress();
206
-
207
- $secondary_item_sql = !empty( $secondary_item_id )
208
- ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id )
209
- : '';
210
-
211
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) );
212
- }
213
-
214
- /**
215
- * Deletes all the notifications sent by a specific user, by component and action.
216
- *
217
- * @global wpdb $wpdb WordPress database object
218
- * @param integer $user_id The ID of the user whose sent notifications we wish to delete.
219
- * @param string $component_name The name of the component the notification was sent from.
220
- * @param string $component_action The action of the component the notification was sent from.
221
- * @static
222
- */
223
- public static function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
224
- global $wpdb;
225
-
226
- $bp = buddypress();
227
-
228
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
229
- }
230
-
231
- /**
232
- * Deletes all the notifications for all users by item id, and optional secondary item id, and component name and action.
233
- *
234
- * @global wpdb $wpdb WordPress database object
235
- * @param string $item_id The item id that they notifications are to be for.
236
- * @param string $component_name The component that the notifications are to be from.
237
- * @param string $component_action The action that the notifications are to be from.
238
- * @param string $secondary_item_id Optional secondary item id that the notifications are to have.
239
- * @static
240
- */
241
- public static function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
242
- global $wpdb;
243
-
244
- if ( $component_action )
245
- $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
246
- else
247
- $component_action_sql = '';
248
-
249
- if ( $secondary_item_id )
250
- $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
251
- else
252
- $secondary_item_sql = '';
253
-
254
- $bp = buddypress();
255
-
256
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) );
257
- }
258
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-core-user.php DELETED
@@ -1,958 +0,0 @@
1
- <?php
2
- /**
3
- * Core component classes.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * Fetch data about a BuddyPress user.
14
- *
15
- * BP_Core_User class can be used by any component. It will fetch useful
16
- * details for any user when provided with a user_id.
17
- *
18
- * Example:
19
- * $user = new BP_Core_User( $user_id );
20
- * $user_avatar = $user->avatar;
21
- * $user_email = $user->email;
22
- * $user_status = $user->status;
23
- * etc.
24
- */
25
- class BP_Core_User {
26
-
27
- /**
28
- * ID of the user which the object relates to.
29
- *
30
- * @var integer
31
- */
32
- public $id;
33
-
34
- /**
35
- * The URL to the full size of the avatar for the user.
36
- *
37
- * @var string
38
- */
39
- public $avatar;
40
-
41
- /**
42
- * The URL to the thumb size of the avatar for the user.
43
- *
44
- * @var string
45
- */
46
- public $avatar_thumb;
47
-
48
- /**
49
- * The URL to the mini size of the avatar for the user.
50
- *
51
- * @var string
52
- */
53
- public $avatar_mini;
54
-
55
- /**
56
- * The full name of the user
57
- *
58
- * @var string
59
- */
60
- public $fullname;
61
-
62
- /**
63
- * The email for the user.
64
- *
65
- * @var string
66
- */
67
- public $email;
68
-
69
- /**
70
- * The absolute url for the user's profile.
71
- *
72
- * @var string
73
- */
74
- public $user_url;
75
-
76
- /**
77
- * The HTML for the user link, with the link text being the user's full name.
78
- *
79
- * @var string
80
- */
81
- public $user_link;
82
-
83
- /**
84
- * Contains a formatted string when the last time the user was active.
85
- *
86
- * Example: "active 2 hours and 50 minutes ago"
87
- *
88
- * @var string
89
- */
90
- public $last_active;
91
-
92
- /* Extras */
93
-
94
- /**
95
- * The total number of "Friends" the user has on site.
96
- *
97
- * @var integer
98
- */
99
- public $total_friends;
100
-
101
- /**
102
- * The total number of blog posts posted by the user
103
- *
104
- * @var integer
105
- * @deprecated No longer used
106
- */
107
- public $total_blogs;
108
-
109
- /**
110
- * The total number of groups the user is a part of.
111
- *
112
- * Example: "1 group", "2 groups"
113
- *
114
- * @var string
115
- */
116
- public $total_groups;
117
-
118
- /**
119
- * Profile information for the specific user.
120
- *
121
- * @since BuddyPress (1.2.0)
122
- * @var array
123
- */
124
- public $profile_data;
125
-
126
- /** Public Methods *******************************************************/
127
-
128
- /**
129
- * Class constructor.
130
- *
131
- * @param integer $user_id The ID for the user being queried.
132
- * @param bool $populate_extras Whether to fetch extra information
133
- * such as group/friendship counts or not. Default: false.
134
- */
135
- public function __construct( $user_id, $populate_extras = false ) {
136
- if ( !empty( $user_id ) ) {
137
- $this->id = $user_id;
138
- $this->populate();
139
-
140
- if ( !empty( $populate_extras ) ) {
141
- $this->populate_extras();
142
- }
143
- }
144
- }
145
-
146
- /**
147
- * Populate the instantiated class with data based on the User ID provided.
148
- *
149
- * @uses bp_core_get_userurl() Returns the URL with no HTML markup for
150
- * a user based on their user id.
151
- * @uses bp_core_get_userlink() Returns a HTML formatted link for a
152
- * user with the user's full name as the link text.
153
- * @uses bp_core_get_user_email() Returns the email address for the
154
- * user based on user ID.
155
- * @uses bp_get_user_meta() BP function returns the value of passed
156
- * usermeta name from usermeta table.
157
- * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
158
- * @uses bp_profile_last_updated_date() Returns the last updated date
159
- * for a user.
160
- */
161
- public function populate() {
162
-
163
- if ( bp_is_active( 'xprofile' ) )
164
- $this->profile_data = $this->get_profile_data();
165
-
166
- if ( !empty( $this->profile_data ) ) {
167
- $full_name_field_name = bp_xprofile_fullname_field_name();
168
-
169
- $this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
170
- $this->fullname = esc_attr( $this->profile_data[$full_name_field_name]['field_data'] );
171
- $this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
172
- $this->email = esc_attr( $this->profile_data['user_email'] );
173
- } else {
174
- $this->user_url = bp_core_get_user_domain( $this->id );
175
- $this->user_link = bp_core_get_userlink( $this->id );
176
- $this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
177
- $this->email = esc_attr( bp_core_get_user_email( $this->id ) );
178
- }
179
-
180
- // Cache a few things that are fetched often
181
- wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
182
- wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
183
- wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
184
-
185
- $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
186
- $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
187
- $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ), 'width' => 30, 'height' => 30 ) );
188
- $this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), __( 'active %s', 'buddypress' ) );
189
- }
190
-
191
- /**
192
- * Populates extra fields such as group and friendship counts.
193
- */
194
- public function populate_extras() {
195
-
196
- if ( bp_is_active( 'friends' ) ) {
197
- $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
198
- }
199
-
200
- if ( bp_is_active( 'groups' ) ) {
201
- $this->total_groups = BP_Groups_Member::total_group_count( $this->id );
202
- $this->total_groups = sprintf( _n( '%d group', '%d groups', $this->total_groups, 'buddypress' ), $this->total_groups );
203
- }
204
- }
205
-
206
- /**
207
- * Fetch xprofile data for the current user.
208
- *
209
- * @see BP_XProfile_ProfileData::get_all_for_user() for description of
210
- * return value.
211
- *
212
- * @return array See {@link BP_XProfile_Profile_Data::get_all_for_user()}.
213
- */
214
- public function get_profile_data() {
215
- return BP_XProfile_ProfileData::get_all_for_user( $this->id );
216
- }
217
-
218
- /** Static Methods ********************************************************/
219
-
220
- /**
221
- * Get a list of users that match the query parameters.
222
- *
223
- * Since BuddyPress 1.7, use {@link BP_User_Query} instead.
224
- *
225
- * @deprecated 1.7.0 Use {@link BP_User_Query}.
226
- *
227
- * @see BP_User_Query for a description of parameters, most of which
228
- * are used there in the same way.
229
- *
230
- * @param string $type See {@link BP_User_Query}.
231
- * @param int $limit See {@link BP_User_Query}. Default: 0.
232
- * @param int $page See {@link BP_User_Query}. Default: 1.
233
- * @param int $user_id See {@link BP_User_Query}. Default: 0.
234
- * @param mixed $include See {@link BP_User_Query}. Default: false.
235
- * @param string|bool $search_terms See {@link BP_User_Query}.
236
- * Default: false.
237
- * @param bool $populate_extras See {@link BP_User_Query}.
238
- * Default: true.
239
- * @param mixed $exclude See {@link BP_User_Query}. Default: false.
240
- * @param string|bool $meta_key See {@link BP_User_Query}.
241
- * Default: false.
242
- * @param string|bool $meta_value See {@link BP_User_Query}.
243
- * Default: false.
244
- * @return array {
245
- * @type int $total_users Total number of users matched by query
246
- * params.
247
- * @type array $paged_users The current page of users matched by
248
- * query params.
249
- * }
250
- */
251
- public static function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) {
252
- global $wpdb;
253
-
254
- _deprecated_function( __METHOD__, '1.7', 'BP_User_Query' );
255
-
256
- $bp = buddypress();
257
-
258
- $sql = array();
259
-
260
- $sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
261
-
262
- if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
263
- $sql['select_active'] = ", um.meta_value as last_activity";
264
- }
265
-
266
- if ( 'popular' == $type ) {
267
- $sql['select_popular'] = ", um.meta_value as total_friend_count";
268
- }
269
-
270
- if ( 'alphabetical' == $type ) {
271
- $sql['select_alpha'] = ", pd.value as fullname";
272
- }
273
-
274
- if ( $meta_key ) {
275
- $sql['select_meta'] = ", umm.meta_key";
276
-
277
- if ( $meta_value ) {
278
- $sql['select_meta'] .= ", umm.meta_value";
279
- }
280
- }
281
-
282
- $sql['from'] = "FROM {$wpdb->users} u LEFT JOIN {$wpdb->usermeta} um ON um.user_id = u.ID";
283
-
284
- // We search against xprofile fields, so we must join the table
285
- if ( $search_terms && bp_is_active( 'xprofile' ) ) {
286
- $sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
287
- }
288
-
289
- // Alphabetical sorting is done by the xprofile Full Name field
290
- if ( 'alphabetical' == $type ) {
291
- $sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
292
- }
293
-
294
- if ( $meta_key ) {
295
- $sql['join_meta'] = "LEFT JOIN {$wpdb->usermeta} umm ON umm.user_id = u.ID";
296
- }
297
-
298
- $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
299
-
300
- if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
301
- $sql['where_active'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) );
302
- }
303
-
304
- if ( 'popular' == $type ) {
305
- $sql['where_popular'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );
306
- }
307
-
308
- if ( 'online' == $type ) {
309
- $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";
310
- }
311
-
312
- if ( 'alphabetical' == $type ) {
313
- $sql['where_alpha'] = "AND pd.field_id = 1";
314
- }
315
-
316
- if ( !empty( $exclude ) ) {
317
- $exclude = implode( ',', wp_parse_id_list( $exclude ) );
318
- $sql['where_exclude'] = "AND u.ID NOT IN ({$exclude})";
319
- }
320
-
321
- // Passing an $include value of 0 or '0' will necessarily result in an empty set
322
- // returned. The default value of false will hit the 'else' clause.
323
- if ( 0 === $include || '0' === $include ) {
324
- $sql['where_users'] = "AND 0 = 1";
325
- } else {
326
- if ( !empty( $include ) ) {
327
- $include = implode( ',', wp_parse_id_list( $include ) );
328
- $sql['where_users'] = "AND u.ID IN ({$include})";
329
- } elseif ( !empty( $user_id ) && bp_is_active( 'friends' ) ) {
330
- $friend_ids = friends_get_friend_user_ids( $user_id );
331
-
332
- if ( !empty( $friend_ids ) ) {
333
- $friend_ids = implode( ',', wp_parse_id_list( $friend_ids ) );
334
- $sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
335
-
336
- // User has no friends, return false since there will be no users to fetch.
337
- } else {
338
- return false;
339
- }
340
- }
341
- }
342
-
343
- if ( !empty( $search_terms ) && bp_is_active( 'xprofile' ) ) {
344
- $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
345
- $sql['where_searchterms'] = $wpdb->prepare( "AND spd.value LIKE %s", $search_terms_like );
346
- }
347
-
348
- if ( !empty( $meta_key ) ) {
349
- $sql['where_meta'] = $wpdb->prepare( " AND umm.meta_key = %s", $meta_key );
350
-
351
- // If a meta value is provided, match it
352
- if ( $meta_value ) {
353
- $sql['where_meta'] .= $wpdb->prepare( " AND umm.meta_value = %s", $meta_value );
354
- }
355
- }
356
-
357
- switch ( $type ) {
358
- case 'active': case 'online': default:
359
- $sql[] = "ORDER BY um.meta_value DESC";
360
- break;
361
- case 'newest':
362
- $sql[] = "ORDER BY u.ID DESC";
363
- break;
364
- case 'alphabetical':
365
- $sql[] = "ORDER BY pd.value ASC";
366
- break;
367
- case 'random':
368
- $sql[] = "ORDER BY rand()";
369
- break;
370
- case 'popular':
371
- $sql[] = "ORDER BY CONVERT(um.meta_value, SIGNED) DESC";
372
- break;
373
- }
374
-
375
- if ( !empty( $limit ) && !empty( $page ) ) {
376
- $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
377
- }
378
-
379
- /**
380
- * Filters the SQL used to query for paged users.
381
- *
382
- * @since BuddyPress (1.2.6)
383
- *
384
- * @param string $value Concatenated SQL statement for the query.
385
- * @param array $sql Array of SQL statement parts for the query.
386
- */
387
- $paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array) $sql ), $sql );
388
- $paged_users = $wpdb->get_results( $paged_users_sql );
389
-
390
- // Re-jig the SQL so we can get the total user count
391
- unset( $sql['select_main'] );
392
-
393
- if ( !empty( $sql['select_active'] ) ) {
394
- unset( $sql['select_active'] );
395
- }
396
-
397
- if ( !empty( $sql['select_popular'] ) ) {
398
- unset( $sql['select_popular'] );
399
- }
400
-
401
- if ( !empty( $sql['select_alpha'] ) ) {
402
- unset( $sql['select_alpha'] );
403
- }
404
-
405
- if ( !empty( $sql['pagination'] ) ) {
406
- unset( $sql['pagination'] );
407
- }
408
-
409
- array_unshift( $sql, "SELECT COUNT(u.ID)" );
410
-
411
- /**
412
- * Filters the SQL used to query for total users.
413
- *
414
- * @since BuddyPress (1.2.6)
415
- *
416
- * @param string $value Concatenated SQL statement for the query.
417
- * @param array $sql Array of SQL statement parts for the query.
418
- */
419
- $total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array) $sql ), $sql );
420
- $total_users = $wpdb->get_var( $total_users_sql );
421
-
422
- /***
423
- * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
424
- * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
425
- */
426
- if ( !empty( $populate_extras ) ) {
427
- $user_ids = array();
428
-
429
- foreach ( (array) $paged_users as $user ) {
430
- $user_ids[] = $user->id;
431
- }
432
-
433
- // Add additional data to the returned results
434
- $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids, $type );
435
- }
436
-
437
- return array( 'users' => $paged_users, 'total' => $total_users );
438
- }
439
-
440
-
441
- /**
442
- * Fetch the details for all users whose usernames start with the given letter.
443
- *
444
- * @global wpdb $wpdb WordPress database object.
445
- *
446
- * @param string $letter The letter the users names are to start with.
447
- * @param int $limit The number of users we wish to retrive.
448
- * @param int $page The page number we are currently on, used in
449
- * conjunction with $limit to get the start position for the
450
- * limit.
451
- * @param bool $populate_extras Populate extra user fields?
452
- * @param string $exclude Comma-separated IDs of users whose results
453
- * aren't to be fetched.
454
- * @return mixed False on error, otherwise associative array of results.
455
- */
456
- public static function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) {
457
- global $wpdb;
458
-
459
- $pag_sql = '';
460
- if ( $limit && $page ) {
461
- $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
462
- }
463
-
464
- // Multibyte compliance
465
- if ( function_exists( 'mb_strlen' ) ) {
466
- if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
467
- return false;
468
- }
469
- } else {
470
- if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) {
471
- return false;
472
- }
473
- }
474
-
475
- $bp = buddypress();
476
-
477
- $letter_like = bp_esc_like( $letter ) . '%';
478
- $status_sql = bp_core_get_status_sql( 'u.' );
479
-
480
- if ( !empty( $exclude ) ) {
481
- $exclude = implode( ',', wp_parse_id_list( $exclude ) );
482
- $exclude_sql = " AND u.id NOT IN ({$exclude})";
483
- } else {
484
- $exclude_sql = '';
485
- }
486
-
487
- /**
488
- * Filters the SQL used to query for total user count by first letter.
489
- *
490
- * @since BuddyPress (1.0.0)
491
- *
492
- * @param string $value SQL prepared statement for the user count query.
493
- */
494
- $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", bp_xprofile_fullname_field_name(), $letter_like ) );
495
-
496
- /**
497
- * Filters the SQL used to query for users by first letter.
498
- *
499
- * @since BuddyPress (1.0.0)
500
- *
501
- * @param string $value SQL prepared statement for the user query.
502
- */
503
- $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", bp_xprofile_fullname_field_name(), $letter_like ) );
504
-
505
- $total_users = $wpdb->get_var( $total_users_sql );
506
- $paged_users = $wpdb->get_results( $paged_users_sql );
507
-
508
- /***
509
- * Lets fetch some other useful data in a separate queries, this will be
510
- * faster than querying the data for every user in a list. We can't add
511
- * these to the main query above since only users who have this
512
- * information will be returned (since the much of the data is in
513
- * usermeta and won't support any type of directional join)
514
- */
515
- $user_ids = array();
516
- foreach ( (array) $paged_users as $user )
517
- $user_ids[] = (int) $user->id;
518
-
519
- // Add additional data to the returned results
520
- if ( $populate_extras ) {
521
- $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
522
- }
523
-
524
- return array( 'users' => $paged_users, 'total' => $total_users );
525
- }
526
-
527
- /**
528
- * Get details of specific users from the database.
529
- *
530
- * Use {@link BP_User_Query} with the 'user_ids' param instead.
531
- *
532
- * @global wpdb $wpdb WordPress database object.
533
- * @param array $user_ids The user IDs of the users who we wish to
534
- * fetch information on.
535
- * @param int $limit The limit of results we want.
536
- * @param int $page The page we are on for pagination.
537
- * @param bool $populate_extras Populate extra user fields?
538
- * @return array Associative array.
539
- */
540
- public static function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {
541
- global $wpdb;
542
-
543
- $pag_sql = '';
544
- if ( $limit && $page )
545
- $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
546
-
547
- $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
548
- $status_sql = bp_core_get_status_sql();
549
-
550
- /**
551
- * Filter the SQL string used for querying specific user count.
552
- *
553
- * This same filter name is used for the paged user SQL, and so should be avoided.
554
- * Use 'bp_core_user_get_specific_users_count_sql' instead.
555
- *
556
- * @deprecated BuddyPress (2.3.0)
557
- *
558
- * @param string $sql SQL string.
559
- */
560
- $total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids})" );
561
-
562
- /**
563
- * Filter the SQL string used for querying specific user count results.
564
- *
565
- * Use this instead of the deprecated 'bp_core_get_specific_users_count_sql'.
566
- *
567
- * @since BuddyPress (2.3.0)
568
- *
569
- * @param string $sql SQL string.
570
- * @param array $user_ids Array of IDs of specific users to fetch.
571
- * @param int|null $limit Max number of records to return. Null for no limit.
572
- * @param int $page The page we're on for pagination.
573
- * @param bool $populate_extras Whether to populate extra user fields.
574
- */
575
- $total_users_sql = apply_filters( 'bp_core_user_get_specific_users_count_sql', $total_users_sql, $user_ids, $limit, $page, $populate_extras );
576
-
577
- /**
578
- * Filter the SQL string used for querying specific user paged results.
579
- *
580
- * This same filter name is used for the user count SQL, and so should be avoided.
581
- * Use 'bp_core_user_get_specific_users_paged_sql' instead.
582
- *
583
- * @deprecated BuddyPress (2.3.0)
584
- *
585
- * @param string $sql SQL string.
586
- */
587
- $paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT ID as id, user_registered, user_nicename, user_login, user_email FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids}) {$pag_sql}" );
588
-
589
- /**
590
- * Filter the SQL string used for querying specific user paged results.
591
- *
592
- * Use this instead of the deprecated 'bp_core_get_specific_users_count_sql'.
593
- *
594
- * @since BuddyPress (2.3.0)
595
- *
596
- * @param string $sql SQL string.
597
- * @param array $user_ids Array of IDs of specific users to fetch.
598
- * @param int|null $limit Max number of records to return. Null for no limit.
599
- * @param int $page The page we're on for pagination.
600
- * @param bool $populate_extras Whether to populate extra user fields.
601
- */
602
- $paged_users_sql = apply_filters( 'bp_core_user_get_specific_users_paged_sql', $paged_users_sql, $user_ids, $limit, $page, $populate_extras );
603
-
604
- $total_users = $wpdb->get_var( $total_users_sql );
605
- $paged_users = $wpdb->get_results( $paged_users_sql );
606
-
607
- /***
608
- * Lets fetch some other useful data in a separate queries, this will be
609
- * faster than querying the data for every user in a list. We can't add
610
- * these to the main query above since only users who have this
611
- * information will be returned (since the much of the data is in
612
- * usermeta and won't support any type of directional join)
613
- */
614
-
615
- // Add additional data to the returned results
616
- if ( !empty( $populate_extras ) ) {
617
- $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
618
- }
619
-
620
- return array( 'users' => $paged_users, 'total' => $total_users );
621
- }
622
-
623
- /**
624
- * Find users who match on the value of an xprofile data.
625
- *
626
- * @global wpdb $wpdb WordPress database object.
627
- *
628
- * @param string $search_terms The terms to search the profile table
629
- * value column for.
630
- * @param integer $limit The limit of results we want.
631
- * @param integer $page The page we are on for pagination.
632
- * @param boolean $populate_extras Populate extra user fields?
633
- * @return array Associative array.
634
- */
635
- public static function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
636
- global $wpdb;
637
-
638
- $bp = buddypress();
639
-
640
- $user_ids = array();
641
- $pag_sql = $limit && $page ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ) : '';
642
-
643
- $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
644
- $status_sql = bp_core_get_status_sql( 'u.' );
645
-
646
- /**
647
- * Filters the SQL used to query for searched users count.
648
- *
649
- * @since BuddyPress (1.0.0)
650
- *
651
- * @param string $value SQL statement for the searched users count query.
652
- */
653
- $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) as id FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", $search_terms_like ), $search_terms );
654
-
655
- /**
656
- * Filters the SQL used to query for searched users.
657
- *
658
- * @since BuddyPress (1.0.0)
659
- *
660
- * @param string $value SQL statement for the searched users query.
661
- */
662
- $paged_users_sql = apply_filters( 'bp_core_search_users_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", $search_terms_like ), $search_terms, $pag_sql );
663
-
664
- $total_users = $wpdb->get_var( $total_users_sql );
665
- $paged_users = $wpdb->get_results( $paged_users_sql );
666
-
667
- /***
668
- * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
669
- * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
670
- */
671
- foreach ( (array) $paged_users as $user )
672
- $user_ids[] = $user->id;
673
-
674
- // Add additional data to the returned results
675
- if ( $populate_extras )
676
- $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
677
-
678
- return array( 'users' => $paged_users, 'total' => $total_users );
679
- }
680
-
681
- /**
682
- * Fetch extra user information, such as friend count and last profile update message.
683
- *
684
- * Accepts multiple user IDs to fetch data for.
685
- *
686
- * @global wpdb $wpdb WordPress database object.
687
- *
688
- * @param array $paged_users An array of stdClass containing the users.
689
- * @param string $user_ids The user ids to select information about.
690
- * @param string $type The type of fields we wish to get.
691
- * @return mixed False on error, otherwise associative array of results.
692
- */
693
- public static function get_user_extras( &$paged_users, &$user_ids, $type = false ) {
694
- global $wpdb;
695
-
696
- $bp = buddypress();
697
-
698
- if ( empty( $user_ids ) )
699
- return $paged_users;
700
-
701
- // Sanitize user IDs
702
- $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
703
-
704
- // Fetch the user's full name
705
- if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
706
- $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name() ) );
707
- for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
708
- foreach ( (array) $names as $name ) {
709
- if ( $name->id == $paged_users[$i]->id )
710
- $paged_users[$i]->fullname = $name->fullname;
711
- }
712
- }
713
- }
714
-
715
- // Fetch the user's total friend count
716
- if ( 'popular' != $type ) {
717
- $friend_count = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as total_friend_count FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'total_friend_count' ) ) );
718
- for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
719
- foreach ( (array) $friend_count as $fcount ) {
720
- if ( $fcount->id == $paged_users[$i]->id )
721
- $paged_users[$i]->total_friend_count = (int) $fcount->total_friend_count;
722
- }
723
- }
724
- }
725
-
726
- // Fetch whether or not the user is a friend
727
- if ( bp_is_active( 'friends' ) ) {
728
- $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", bp_loggedin_user_id(), bp_loggedin_user_id() ) );
729
- for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
730
- foreach ( (array) $friend_status as $status ) {
731
- if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id )
732
- $paged_users[$i]->is_friend = $status->is_confirmed;
733
- }
734
- }
735
- }
736
-
737
- if ( 'active' != $type ) {
738
- $user_activity = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'last_activity' ) ) );
739
- for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
740
- foreach ( (array) $user_activity as $activity ) {
741
- if ( $activity->id == $paged_users[$i]->id )
742
- $paged_users[$i]->last_activity = $activity->last_activity;
743
- }
744
- }
745
- }
746
-
747
- // Fetch the user's last_activity
748
- if ( 'active' != $type ) {
749
- $user_activity = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'last_activity' ) ) );
750
- for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
751
- foreach ( (array) $user_activity as $activity ) {
752
- if ( $activity->id == $paged_users[$i]->id )
753
- $paged_users[$i]->last_activity = $activity->last_activity;
754
- }
755
- }
756
- }
757
-
758
- // Fetch the user's latest update
759
- $user_update = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as latest_update FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'bp_latest_update' ) ) );
760
- for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
761
- foreach ( (array) $user_update as $update ) {
762
- if ( $update->id == $paged_users[$i]->id )
763
- $paged_users[$i]->latest_update = $update->latest_update;
764
- }
765
- }
766
-
767
- return $paged_users;
768
- }
769
-
770
- /**
771
- * Get WordPress user details for a specified user.
772
- *
773
- * @global wpdb $wpdb WordPress database object.
774
- *
775
- * @param integer $user_id User ID.
776
- * @return array Associative array.
777
- */
778
- public static function get_core_userdata( $user_id ) {
779
- global $wpdb;
780
-
781
- if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) )
782
- return false;
783
-
784
- return $user;
785
- }
786
-
787
- /**
788
- * Get last activity data for a user or set of users.
789
- *
790
- * @param int|array User IDs or multiple user IDs.
791
- * @return array
792
- */
793
- public static function get_last_activity( $user_id ) {
794
- global $wpdb;
795
-
796
- // Sanitize and remove empty values
797
- $user_ids = array_filter( wp_parse_id_list( $user_id ) );
798
-
799
- if ( empty( $user_ids ) ) {
800
- return false;
801
- }
802
-
803
- $uncached_user_ids = bp_get_non_cached_ids( $user_ids, 'bp_last_activity' );
804
- if ( ! empty( $uncached_user_ids ) ) {
805
- $bp = buddypress();
806
-
807
- $user_ids_sql = implode( ',', $uncached_user_ids );
808
- $user_count = count( $uncached_user_ids );
809
-
810
- $last_activities = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, date_recorded FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity' AND user_id IN ({$user_ids_sql}) LIMIT {$user_count}", $bp->members->id ) );
811
-
812
- foreach ( $last_activities as $last_activity ) {
813
- wp_cache_set( $last_activity->user_id, array(
814
- 'user_id' => $last_activity->user_id,
815
- 'date_recorded' => $last_activity->date_recorded,
816
- 'activity_id' => $last_activity->id,
817
- ), 'bp_last_activity' );
818
- }
819
- }
820
-
821
- // Fetch all user data from the cache
822
- $retval = array();
823
- foreach ( $user_ids as $user_id ) {
824
- $retval[ $user_id ] = wp_cache_get( $user_id, 'bp_last_activity' );
825
- }
826
-
827
- return $retval;
828
- }
829
-
830
- /**
831
- * Set a user's last_activity value.
832
- *
833
- * Will create a new entry if it does not exist. Otherwise updates the
834
- * existing entry.
835
- *
836
- * @since BuddyPress (2.0.0)
837
- *
838
- * @param int $user_id ID of the user whose last_activity you are updating.
839
- * @param string $time MySQL-formatted time string.
840
- * @return bool True on success, false on failure.
841
- */
842
- public static function update_last_activity( $user_id, $time ) {
843
- global $wpdb;
844
-
845
- $table_name = buddypress()->members->table_name_last_activity;
846
-
847
- $activity = self::get_last_activity( $user_id );
848
-
849
- if ( ! empty( $activity[ $user_id ] ) ) {
850
- $updated = $wpdb->update(
851
- $table_name,
852
-
853
- // Data to update
854
- array(
855
- 'date_recorded' => $time,
856
- ),
857
-
858
- // WHERE
859
- array(
860
- 'id' => $activity[ $user_id ]['activity_id'],
861
- ),
862
-
863
- // Data sanitization format
864
- array(
865
- '%s',
866
- ),
867
-
868
- // WHERE sanitization format
869
- array(
870
- '%d',
871
- )
872
- );
873
-
874
- // add new date to existing activity entry for caching
875
- $activity[ $user_id ]['date_recorded'] = $time;
876
-
877
- } else {
878
- $updated = $wpdb->insert(
879
- $table_name,
880
-
881
- // Data
882
- array(
883
- 'user_id' => $user_id,
884
- 'component' => buddypress()->members->id,
885
- 'type' => 'last_activity',
886
- 'action' => '',
887
- 'content' => '',
888
- 'primary_link' => '',
889
- 'item_id' => 0,
890
- 'date_recorded' => $time,
891
- ),
892
-
893
- // Data sanitization format
894
- array(
895
- '%d',
896
- '%s',
897
- '%s',
898
- '%s',
899
- '%s',
900
- '%s',
901
- '%d',
902
- '%s',
903
- )
904
- );
905
-
906
- // set up activity array for caching
907
- // view the foreach loop in the get_last_activity() method for format
908
- $activity = array();
909
- $activity[ $user_id ] = array(
910
- 'user_id' => $user_id,
911
- 'date_recorded' => $time,
912
- 'activity_id' => $wpdb->insert_id,
913
- );
914
- }
915
-
916
- // set cache
917
- wp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' );
918
-
919
- return $updated;
920
- }
921
-
922
- /**
923
- * Delete a user's last_activity value.
924
- *
925
- * @since BuddyPress (2.0.0)
926
- *
927
- * @param int $user_id
928
- * @return bool True on success, false on failure or if no last_activity
929
- * is found for the user.
930
- */
931
- public static function delete_last_activity( $user_id ) {
932
- global $wpdb;
933
-
934
- $existing = self::get_last_activity( $user_id );
935
-
936
- if ( empty( $existing ) ) {
937
- return false;
938
- }
939
-
940
- $deleted = $wpdb->delete(
941
- buddypress()->members->table_name_last_activity,
942
-
943
- // WHERE
944
- array(
945
- 'id' => $existing[ $user_id ]['activity_id'],
946
- ),
947
-
948
- // WHERE sanitization format
949
- array(
950
- '%s',
951
- )
952
- );
953
-
954
- wp_cache_delete( $user_id, 'bp_last_activity' );
955
-
956
- return $deleted;
957
- }
958
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-date-query.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
- /**
3
- * Core component classes.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- if ( class_exists( 'WP_Date_Query' ) ) :
13
- /**
14
- * BuddyPress date query class.
15
- *
16
- * Extends the {@link WP_Date_Query} class for use with BuddyPress.
17
- *
18
- * @since BuddyPress (2.1.0)
19
- *
20
- * @param array $date_query {
21
- * Date query arguments. See first parameter of {@link WP_Date_Query::__construct()}.
22
- * }
23
- * @param string $column The DB column to query against.
24
- */
25
- class BP_Date_Query extends WP_Date_Query {
26
- /**
27
- * The column to query against. Can be changed via the query arguments.
28
- *
29
- * @var string
30
- */
31
- public $column;
32
-
33
- /**
34
- * Constructor.
35
- *
36
- * @see WP_Date_Query::__construct()
37
- */
38
- public function __construct( $date_query, $column = '' ) {
39
- if ( ! empty( $column ) ) {
40
- $this->column = $column;
41
- add_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
42
- }
43
-
44
- parent::__construct( $date_query, $column );
45
- }
46
-
47
- /**
48
- * Destructor.
49
- */
50
- public function __destruct() {
51
- remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
52
- }
53
-
54
- /**
55
- * Registers our date column with WP Date Query to pass validation.
56
- *
57
- * @param array $retval Current DB columns
58
- * @return array
59
- */
60
- public function register_date_column( $retval = array() ) {
61
- $retval[] = $this->column;
62
- return $retval;
63
- }
64
- }
65
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-embed.php DELETED
@@ -1,248 +0,0 @@
1
- <?php
2
- /**
3
- * Core component classes.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- */
8
-
9
- // Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- /**
13
- * Enable oEmbeds in BuddyPress contexts.
14
- *
15
- * Extends WP_Embed class for use with BuddyPress.
16
- *
17
- * @since BuddyPress (1.5.0)
18
- *
19
- * @see WP_Embed
20
- */
21
- class BP_Embed extends WP_Embed {
22
-
23
- /**
24
- * Constructor
25
- *
26
- * @global WP_Embed $wp_embed
27
- */
28
- public function __construct() {
29
- global $wp_embed;
30
-
31
- // Make sure we populate the WP_Embed handlers array.
32
- // These are providers that use a regex callback on the URL in question.
33
- // Do not confuse with oEmbed providers, which require an external ping.
34
- // Used in WP_Embed::shortcode()
35
- $this->handlers = $wp_embed->handlers;
36
-
37
- if ( bp_use_embed_in_activity() ) {
38
- add_filter( 'bp_get_activity_content_body', array( &$this, 'autoembed' ), 8 );
39
- add_filter( 'bp_get_activity_content_body', array( &$this, 'run_shortcode' ), 7 );
40
- }
41
-
42
- if ( bp_use_embed_in_activity_replies() ) {
43
- add_filter( 'bp_get_activity_content', array( &$this, 'autoembed' ), 8 );
44
- add_filter( 'bp_get_activity_content', array( &$this, 'run_shortcode' ), 7 );
45
- }
46
-
47
- if ( bp_use_embed_in_forum_posts() ) {
48
- add_filter( 'bp_get_the_topic_post_content', array( &$this, 'autoembed' ), 8 );
49
- add_filter( 'bp_get_the_topic_post_content', array( &$this, 'run_shortcode' ), 7 );
50
- }
51
-
52
- if ( bp_use_embed_in_private_messages() ) {
53
- add_filter( 'bp_get_the_thread_message_content', array( &$this, 'autoembed' ), 8 );
54
- add_filter( 'bp_get_the_thread_message_content', array( &$this, 'run_shortcode' ), 7 );
55
- }
56
-
57
- /**
58
- * Filters the BuddyPress Core oEmbed setup.
59
- *
60
- * @since BuddyPress (1.5.0)
61
- *
62
- * @param BP_Embed $this Current instance of the BP_Embed. Passed by reference.
63
- */
64
- do_action_ref_array( 'bp_core_setup_oembed', array( &$this ) );
65
- }
66
-
67
- /**
68
- * The {@link do_shortcode()} callback function.
69
- *
70
- * Attempts to convert a URL into embed HTML. Starts by checking the
71
- * URL against the regex of the registered embed handlers. Next, checks
72
- * the URL against the regex of registered {@link WP_oEmbed} providers
73
- * if oEmbed discovery is false. If none of the regex matches and it's
74
- * enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()}
75
- * for oEmbed parsing.
76
- *
77
- * @uses wp_parse_args()
78
- * @uses wp_embed_defaults()
79
- * @uses current_user_can()
80
- * @uses _wp_oembed_get_object()
81
- * @uses WP_Embed::maybe_make_link()
82
- *
83
- * @param array $attr Shortcode attributes.
84
- * @param string $url The URL attempting to be embeded.
85
- * @return string The embed HTML on success, otherwise the original URL.
86
- */
87
- public function shortcode( $attr, $url = '' ) {
88
- if ( empty( $url ) )
89
- return '';
90
-
91
- $rawattr = $attr;
92
- $attr = wp_parse_args( $attr, wp_embed_defaults() );
93
-
94
- // kses converts & into &amp; and we need to undo this
95
- // See https://core.trac.wordpress.org/ticket/11311
96
- $url = str_replace( '&amp;', '&', $url );
97
-
98
- // Look for known internal handlers
99
- ksort( $this->handlers );
100
- foreach ( $this->handlers as $priority => $handlers ) {
101
- foreach ( $handlers as $hid => $handler ) {
102
- if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
103
- if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) {
104
-
105
- /**
106
- * Filters the oEmbed handler result for the provided URL.
107
- *
108
- * @since BuddyPress (1.5.0)
109
- *
110
- * @param string $return Handler callback for the oEmbed.
111
- * @param string $url URL attempting to be embedded.
112
- * @param array $attr Shortcode attributes.
113
- */
114
- return apply_filters( 'embed_handler_html', $return, $url, $attr );
115
- }
116
- }
117
- }
118
- }
119
-
120
- /**
121
- * Filters the embed object ID.
122
- *
123
- * @since BuddyPress (1.5.0)
124
- *
125
- * @param int $value Value of zero.
126
- */
127
- $id = apply_filters( 'embed_post_id', 0 );
128
-
129
- /**
130
- * Filters whether or not oEmbed discovery is on.
131
- *
132
- * @since BuddyPress (1.5.0)
133
- *
134
- * @param bool $value Current status of oEmbed discovery.
135
- */
136
- $attr['discover'] = ( apply_filters( 'bp_embed_oembed_discover', false ) && current_user_can( 'unfiltered_html' ) );
137
-
138
- // Set up a new WP oEmbed object to check URL with registered oEmbed providers
139
- require_once( ABSPATH . WPINC . '/class-oembed.php' );
140
- $oembed_obj = _wp_oembed_get_object();
141
-
142
- // If oEmbed discovery is true, skip oEmbed provider check
143
- $is_oembed_link = false;
144
- if ( !$attr['discover'] ) {
145
- foreach ( (array) $oembed_obj->providers as $provider_matchmask => $provider ) {
146
- $regex = ( $is_regex = $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i';
147
-
148
- if ( preg_match( $regex, $url ) )
149
- $is_oembed_link = true;
150
- }
151
-
152
- // If url doesn't match a WP oEmbed provider, stop parsing
153
- if ( !$is_oembed_link )
154
- return $this->maybe_make_link( $url );
155
- }
156
-
157
- return $this->parse_oembed( $id, $url, $attr, $rawattr );
158
- }
159
-
160
- /**
161
- * Base function so BP components/plugins can parse links to be embedded.
162
- *
163
- * View an example to add support in {@link bp_activity_embed()}.
164
- *
165
- * @uses apply_filters() Filters cache.
166
- * @uses do_action() To save cache.
167
- * @uses wp_oembed_get() Connects to oEmbed provider and returns HTML
168
- * on success.
169
- * @uses WP_Embed::maybe_make_link() Process URL for hyperlinking on
170
- * oEmbed failure.
171
- *
172
- * @param int $id ID to do the caching for.
173
- * @param string $url The URL attempting to be embedded.
174
- * @param array $attr Shortcode attributes from {@link WP_Embed::shortcode()}.
175
- * @param array $rawattr Untouched shortcode attributes from
176
- * {@link WP_Embed::shortcode()}.
177
- * @return string The embed HTML on success, otherwise the original URL.
178
- */
179
- public function parse_oembed( $id, $url, $attr, $rawattr ) {
180
- $id = intval( $id );
181
-
182
- if ( $id ) {
183
- // Setup the cachekey
184
- $cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
185
-
186
- // Let components / plugins grab their cache
187
- $cache = '';
188
-
189
- /**
190
- * Filters the cache value to be used in the oEmbed, if exists.
191
- *
192
- * @since BuddyPress (1.5.0)
193
- *
194
- * @param string $cache Empty initial cache value.
195
- * @param int $id ID that the caching is for.
196
- * @param string $cachekey Key to use for the caching in the database.
197
- * @param string $url The URL attempting to be embedded.
198
- * @param array $attr Parsed short