BuddyPress - Version 2.2-beta1

Version Description

= 2.1 = See: http://codex.buddypress.org/releases/version-2-1/

= 2.0.3 = See: http://codex.buddypress.org/releases/version-2-0-3/

= 2.0.2 = See: http://codex.buddypress.org/releases/version-2-0-2/

= 2.0.1 = See: http://codex.buddypress.org/releases/version-2-0-1/

= 2.0 = See: http://codex.buddypress.org/releases/version-2-0/

= 1.9.2 = See: http://codex.buddypress.org/releases/version-1-9-2/

= 1.9.1 = See: http://codex.buddypress.org/releases/version-1-9-1/

= 1.9 = See: http://codex.buddypress.org/releases/version-1-9/

= 1.8.1 = See: http://codex.buddypress.org/releases/version-1-8-1/

= 1.8 = See: http://codex.buddypress.org/releases/version-1-8/

= 1.7.3 = See: http://codex.buddypress.org/releases/version-1-7-3/

= 1.7.2 = See: http://codex.buddypress.org/releases/version-1-7-2/

= 1.7.1 = See: http://codex.buddypress.org/releases/version-1-7-1/

= 1.7 = See: http://codex.buddypress.org/releases/version-1-7/

= 1.6.5 = See: http://codex.buddypress.org/releases/version-1-6-5/

= 1.6.4 = See: http://codex.buddypress.org/releases/version-1-6-4/

= 1.6.3 = See: http://codex.buddypress.org/releases/version-1-6-3/

= 1.6.2 = Compatibility with WordPress 3.5

= 1.6.1 = Fixes 4 bugs

= 1.6 = See: http://codex.buddypress.org/releases/version-1-6/

= 1.5 = See: http://codex.buddypress.org/releases/version-1-5/

= 1.2.9 = Compatibility with WordPress 3.2

= 1.2.8 = Compatibility with WordPress 3.1

= 1.2.7 = Fixes over 10 bugs.

Download this release

Release Info

Developer johnjamesjacoby
Plugin Icon 128x128 BuddyPress
Version 2.2-beta1
Comparing to
See all releases

Code changes from version 2.1.1 to 2.2-beta1

Files changed (142) hide show
  1. bp-activity/admin/css/admin-rtl.min.css +1 -1
  2. bp-activity/admin/css/admin.min.css +1 -1
  3. bp-activity/admin/js/admin.js +4 -2
  4. bp-activity/admin/js/admin.min.js +2 -2
  5. bp-activity/bp-activity-actions.php +161 -16
  6. bp-activity/bp-activity-admin.php +132 -17
  7. bp-activity/bp-activity-akismet.php +56 -3
  8. bp-activity/bp-activity-classes.php +655 -77
  9. bp-activity/bp-activity-cssjs.php +9 -2
  10. bp-activity/bp-activity-filters.php +168 -18
  11. bp-activity/bp-activity-functions.php +877 -44
  12. bp-activity/bp-activity-loader.php +19 -0
  13. bp-activity/bp-activity-notifications.php +169 -11
  14. bp-activity/bp-activity-screens.php +160 -28
  15. bp-activity/bp-activity-template.php +1003 -356
  16. bp-activity/css/mentions-rtl.css +17 -4
  17. bp-activity/css/mentions-rtl.min.css +2 -2
  18. bp-activity/css/mentions.css +17 -4
  19. bp-activity/css/mentions.min.css +2 -2
  20. bp-activity/js/mentions.js +70 -13
  21. bp-activity/js/mentions.min.js +2 -2
  22. bp-blogs/bp-blogs-activity.php +81 -20
  23. bp-blogs/bp-blogs-cache.php +7 -15
  24. bp-blogs/bp-blogs-classes.php +51 -6
  25. bp-blogs/bp-blogs-filters.php +71 -3
  26. bp-blogs/bp-blogs-functions.php +173 -181
  27. bp-blogs/bp-blogs-loader.php +64 -1
  28. bp-blogs/bp-blogs-screens.php +42 -9
  29. bp-blogs/bp-blogs-template.php +338 -10
  30. bp-blogs/bp-blogs-widgets.php +9 -0
  31. bp-core/admin/bp-core-functions.php +71 -52
  32. bp-core/admin/bp-core-schema.php +18 -9
  33. bp-core/admin/bp-core-slugs.php +1 -7
  34. bp-core/admin/bp-core-tools.php +1 -1
  35. bp-core/admin/css/common-rtl.min.css +1 -1
  36. bp-core/admin/css/common.min.css +1 -1
  37. bp-core/bp-core-actions.php +2 -0
  38. bp-core/bp-core-admin.php +2 -5
  39. bp-core/bp-core-adminbar.php +1 -1
  40. bp-core/bp-core-avatars.php +147 -112
  41. bp-core/bp-core-buddybar.php +26 -20
  42. bp-core/bp-core-cache.php +0 -10
  43. bp-core/bp-core-caps.php +2 -2
  44. bp-core/bp-core-catchuri.php +8 -31
  45. bp-core/bp-core-classes.php +331 -54
  46. bp-core/bp-core-component.php +15 -1
  47. bp-core/bp-core-cssjs.php +2 -2
  48. bp-core/bp-core-dependency.php +19 -1
  49. bp-core/bp-core-filters.php +186 -24
  50. bp-core/bp-core-functions.php +82 -31
  51. bp-core/bp-core-loader.php +16 -1
  52. bp-core/bp-core-options.php +1 -1
  53. bp-core/bp-core-taxonomy.php +73 -0
  54. bp-core/bp-core-template-loader.php +32 -0
  55. bp-core/bp-core-template.php +97 -23
  56. bp-core/bp-core-theme-compatibility.php +8 -8
  57. bp-core/bp-core-update.php +79 -0
  58. bp-core/bp-core-widgets.php +2 -440
  59. bp-core/bp-core-wpabstraction.php +3 -3
  60. bp-core/css/admin-bar-rtl.min.css +1 -1
  61. bp-core/css/admin-bar.min.css +1 -1
  62. bp-core/css/buddybar-rtl.min.css +1 -1
  63. bp-core/css/buddybar.min.css +1 -1
  64. bp-core/deprecated/1.9.php +1 -1
  65. bp-core/deprecated/2.1.php +2 -2
  66. bp-core/deprecated/2.2.php +106 -0
  67. bp-core/deprecated/css/autocomplete/jquery.autocompletefb-rtl.min.css +1 -1
  68. bp-core/deprecated/css/autocomplete/jquery.autocompletefb.min.css +1 -1
  69. bp-core/deprecated/js/autocomplete/jquery.autocomplete.js +25 -2
  70. bp-core/deprecated/js/autocomplete/jquery.autocomplete.min.js +2 -2
  71. bp-core/deprecated/js/autocomplete/jquery.autocompletefb.min.js +1 -1
  72. bp-core/deprecated/js/autocomplete/jquery.bgiframe.min.js +1 -1
  73. bp-core/deprecated/js/autocomplete/jquery.dimensions.min.js +1 -1
  74. bp-core/deprecated/js/jquery-scroll-to.min.js +1 -1
  75. bp-core/js/confirm.min.js +1 -1
  76. bp-core/js/jquery-cookie.min.js +1 -1
  77. bp-core/js/jquery-query.min.js +1 -1
  78. bp-core/js/jquery.atwho.js +117 -66
  79. bp-core/js/jquery.atwho.min.js +2 -2
  80. bp-core/js/jquery.caret.js +36 -23
  81. bp-core/js/jquery.caret.min.js +2 -2
  82. bp-core/js/widget-members.js +2 -2
  83. bp-core/js/widget-members.min.js +2 -2
  84. bp-forums/bp-forums-bbpress-sa.php +4 -4
  85. bp-forums/bp-forums-functions.php +2 -2
  86. bp-forums/bp-forums-screens.php +3 -3
  87. bp-forums/bp-forums-template.php +13 -10
  88. bp-forums/deprecated/1.6.php +1 -1
  89. bp-friends/bp-friends-actions.php +2 -2
  90. bp-friends/bp-friends-activity.php +124 -15
  91. bp-friends/bp-friends-classes.php +15 -1
  92. bp-friends/bp-friends-functions.php +167 -19
  93. bp-friends/bp-friends-loader.php +15 -0
  94. bp-friends/bp-friends-notifications.php +122 -10
  95. bp-friends/bp-friends-screens.php +32 -1
  96. bp-friends/bp-friends-template.php +104 -6
  97. bp-friends/bp-friends-widgets.php +8 -1
  98. bp-friends/js/widget-friends.js +2 -2
  99. bp-friends/js/widget-friends.min.js +2 -2
  100. bp-groups/admin/css/admin-rtl.min.css +1 -1
  101. bp-groups/admin/css/admin.min.css +1 -1
  102. bp-groups/admin/js/admin.min.js +1 -1
  103. bp-groups/bp-groups-actions.php +8 -5
  104. bp-groups/bp-groups-activity.php +162 -0
  105. bp-groups/bp-groups-admin.php +34 -8
  106. bp-groups/bp-groups-adminbar.php +33 -58
  107. bp-groups/bp-groups-classes.php +50 -22
  108. bp-groups/bp-groups-filters.php +22 -0
  109. bp-groups/bp-groups-functions.php +38 -11
  110. bp-groups/bp-groups-loader.php +71 -2
  111. bp-groups/bp-groups-notifications.php +393 -39
  112. bp-groups/bp-groups-screens.php +30 -33
  113. bp-groups/bp-groups-template.php +526 -118
  114. bp-groups/bp-groups-widgets.php +3 -3
  115. bp-groups/js/widget-groups.js +2 -2
  116. bp-groups/js/widget-groups.min.js +2 -2
  117. bp-loader.php +30 -18
  118. bp-members/admin/bp-members-classes.php +46 -3
  119. bp-members/admin/css/admin-rtl.min.css +1 -1
  120. bp-members/admin/css/admin.min.css +1 -1
  121. bp-members/admin/js/admin.min.js +1 -1
  122. bp-members/bp-members-actions.php +3 -3
  123. bp-members/bp-members-activity.php +96 -0
  124. bp-members/bp-members-admin.php +202 -38
  125. bp-members/bp-members-cache.php +49 -0
  126. bp-members/bp-members-classes.php +133 -7
  127. bp-members/bp-members-filters.php +9 -0
  128. bp-members/bp-members-functions.php +573 -58
  129. bp-members/bp-members-loader.php +32 -1
  130. bp-members/bp-members-screens.php +153 -16
  131. bp-members/bp-members-template.php +487 -53
  132. bp-members/bp-members-widgets.php +470 -0
  133. bp-messages/bp-messages-actions.php +155 -1
  134. bp-messages/bp-messages-cache.php +23 -0
  135. bp-messages/bp-messages-classes.php +279 -45
  136. bp-messages/bp-messages-functions.php +116 -1
  137. bp-messages/bp-messages-loader.php +31 -9
  138. bp-messages/bp-messages-notifications.php +73 -5
  139. bp-messages/bp-messages-screens.php +83 -6
  140. bp-messages/bp-messages-template.php +739 -65
  141. bp-messages/bp-messages-widgets.php +8 -0
  142. bp-notifications/bp-notifications-actions.php +37 -0
bp-activity/admin/css/admin-rtl.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  .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%}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  .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.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  .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%}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  .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.js CHANGED
@@ -165,9 +165,11 @@ $(document).ready( function () {
165
  $( '#bp_activity_action h3, #bp_activity_content h3' ).unbind( 'click' );
166
 
167
  // redo the post box toggles to reset the one made by comment.js in favor
168
- // of activity administration page id so that metaboxes are still collapsible
169
  // in single Activity Administration screen.
170
- postboxes.add_postbox_toggles( bp_activity_admin_vars.page );
 
 
171
  });
172
 
173
  })(jQuery);
165
  $( '#bp_activity_action h3, #bp_activity_content h3' ).unbind( 'click' );
166
 
167
  // redo the post box toggles to reset the one made by comment.js in favor
168
+ // of activity administration page id so that metaboxes are still collapsible
169
  // in single Activity Administration screen.
170
+ if ( typeof postboxes !== 'undefined' ) {
171
+ postboxes.add_postbox_toggles( bp_activity_admin_vars.page );
172
+ }
173
  });
174
 
175
  })(jQuery);
bp-activity/admin/js/admin.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM 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"),postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM 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
@@ -15,11 +15,17 @@ if ( !defined( 'ABSPATH' ) ) exit;
15
  /**
16
  * Allow core components and dependent plugins to register activity actions.
17
  *
18
- * @since BuddyPress (1.2)
19
  *
20
  * @uses do_action() To call 'bp_register_activity_actions' hook.
21
  */
22
  function bp_register_activity_actions() {
 
 
 
 
 
 
23
  do_action( 'bp_register_activity_actions' );
24
  }
25
  add_action( 'bp_init', 'bp_register_activity_actions', 8 );
@@ -85,7 +91,7 @@ function bp_activity_action_permalink_router() {
85
  }
86
 
87
  // Set redirect to users' activity stream
88
- } else if ( ! empty( $activity->user_id ) ) {
89
  $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
90
  }
91
 
@@ -96,7 +102,13 @@ function bp_activity_action_permalink_router() {
96
  $redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect );
97
  }
98
 
99
- // Allow redirect to be filtered
 
 
 
 
 
 
100
  if ( ! $redirect = apply_filters_ref_array( 'bp_activity_permalink_redirect_url', array( $redirect, &$activity ) ) ) {
101
  bp_core_redirect( bp_get_root_domain() );
102
  }
@@ -149,7 +161,14 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
149
  if ( ! bp_activity_user_can_delete( $activity ) )
150
  return false;
151
 
152
- // Call the action before the delete so plugins can still fetch information about it
 
 
 
 
 
 
 
153
  do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
154
 
155
  // Delete the activity item and provide user feedback
@@ -158,6 +177,14 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
158
  else
159
  bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
160
 
 
 
 
 
 
 
 
 
161
  do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
162
 
163
  // Check for the redirect query arg, otherwise let WP handle things
@@ -203,16 +230,31 @@ function bp_activity_action_spam_activity( $activity_id = 0 ) {
203
  // Check nonce
204
  check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
205
 
206
- // Call an action before the spamming so plugins can modify things if they want to
 
 
 
 
 
 
 
207
  do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
208
 
209
  // Mark as spam
210
  bp_activity_mark_as_spam( $activity );
211
  $activity->save();
212
 
213
- // Tell the user the spamming has been succesful
214
  bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
215
 
 
 
 
 
 
 
 
 
216
  do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
217
 
218
  // Check for the redirect query arg, otherwise let WP handle things
@@ -253,14 +295,36 @@ function bp_activity_action_post_update() {
253
  // Check the nonce
254
  check_admin_referer( 'post_update', '_wpnonce_post_update' );
255
 
256
- // Get activity info
 
 
 
 
 
 
257
  $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
258
 
259
  if ( ! empty( $_POST['whats-new-post-object'] ) ) {
 
 
 
 
 
 
 
 
260
  $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
261
  }
262
 
263
  if ( ! empty( $_POST['whats-new-post-in'] ) ) {
 
 
 
 
 
 
 
 
264
  $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
265
  }
266
 
@@ -275,13 +339,22 @@ function bp_activity_action_post_update() {
275
  $activity_id = bp_activity_post_update( array( 'content' => $content ) );
276
 
277
  // Post to groups object
278
- } else if ( 'groups' == $object && bp_is_active( 'groups' ) ) {
279
  if ( (int) $item_id ) {
280
  $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
281
  }
282
 
283
- // Special circumstance so let filters handle it
284
  } else {
 
 
 
 
 
 
 
 
 
 
285
  $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
286
  }
287
 
@@ -289,7 +362,7 @@ function bp_activity_action_post_update() {
289
  if ( !empty( $activity_id ) )
290
  bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
291
  else
292
- bp_core_add_message( __( 'There was an error when posting your update, please try again.', 'buddypress' ), 'error' );
293
 
294
  // Redirect
295
  bp_core_redirect( wp_get_referer() );
@@ -322,7 +395,22 @@ function bp_activity_action_post_comment() {
322
  // Check the nonce
323
  check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
324
 
 
 
 
 
 
 
 
325
  $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
 
 
 
 
 
 
 
 
326
  $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
327
 
328
  if ( empty( $content ) ) {
@@ -339,7 +427,7 @@ function bp_activity_action_post_comment() {
339
  if ( !empty( $comment_id ) )
340
  bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) );
341
  else
342
- bp_core_add_message( __( 'There was an error posting that reply, please try again.', 'buddypress' ), 'error' );
343
 
344
  bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
345
  }
@@ -373,7 +461,7 @@ function bp_activity_action_mark_favorite() {
373
  if ( bp_activity_add_user_favorite( bp_action_variable( 0 ) ) )
374
  bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
375
  else
376
- bp_core_add_message( __( 'There was an error marking that activity as a favorite, please try again.', 'buddypress' ), 'error' );
377
 
378
  bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
379
  }
@@ -407,7 +495,7 @@ function bp_activity_action_remove_favorite() {
407
  if ( bp_activity_remove_user_favorite( bp_action_variable( 0 ) ) )
408
  bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) );
409
  else
410
- bp_core_add_message( __( 'There was an error removing that activity as a favorite, please try again.', 'buddypress' ), 'error' );
411
 
412
  bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
413
  }
@@ -640,7 +728,13 @@ function bp_activity_setup_akismet() {
640
  if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) )
641
  return;
642
 
643
- // Bail if BuddyPress Activity Akismet support has been disabled by another plugin
 
 
 
 
 
 
644
  if ( ! apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) )
645
  return;
646
 
@@ -659,10 +753,17 @@ function bp_ajax_get_suggestions() {
659
  exit;
660
  }
661
 
662
- $results = bp_core_get_suggestions( array(
663
  'term' => sanitize_text_field( $_GET['term'] ),
664
  'type' => sanitize_text_field( $_GET['type'] ),
665
- ) );
 
 
 
 
 
 
 
666
 
667
  if ( is_wp_error( $results ) ) {
668
  wp_send_json_error( $results->get_error_message() );
@@ -672,3 +773,47 @@ function bp_ajax_get_suggestions() {
672
  wp_send_json_success( $results );
673
  }
674
  add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  /**
16
  * Allow core components and dependent plugins to register activity actions.
17
  *
18
+ * @since BuddyPress (1.2.0)
19
  *
20
  * @uses do_action() To call 'bp_register_activity_actions' hook.
21
  */
22
  function bp_register_activity_actions() {
23
+
24
+ /**
25
+ * Fires on bp_init to allow core components and dependent plugins to register activity actions.
26
+ *
27
+ * @since BuddyPress (1.2.0)
28
+ */
29
  do_action( 'bp_register_activity_actions' );
30
  }
31
  add_action( 'bp_init', 'bp_register_activity_actions', 8 );
91
  }
92
 
93
  // Set redirect to users' activity stream
94
+ } elseif ( ! empty( $activity->user_id ) ) {
95
  $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
96
  }
97
 
102
  $redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect );
103
  }
104
 
105
+ /**
106
+ * Filter the intended redirect url before the redirect occurs for the single activity item.
107
+ *
108
+ * @since BuddyPress (1.2.2)
109
+ *
110
+ * @param array Array with url to redirect to and activity related to the redirect.
111
+ */
112
  if ( ! $redirect = apply_filters_ref_array( 'bp_activity_permalink_redirect_url', array( $redirect, &$activity ) ) ) {
113
  bp_core_redirect( bp_get_root_domain() );
114
  }
161
  if ( ! bp_activity_user_can_delete( $activity ) )
162
  return false;
163
 
164
+ /**
165
+ * Fires before the deletion so plugins can still fetch information about it.
166
+ *
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
 
174
  // Delete the activity item and provide user feedback
177
  else
178
  bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
179
 
180
+ /**
181
+ * Fires after the deletion so plugins can act afterwards based on the activity.
182
+ *
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
 
190
  // Check for the redirect query arg, otherwise let WP handle things
230
  // Check nonce
231
  check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
232
 
233
+ /**
234
+ * Fires before the marking activity as spam so plugins can modify things if they want to.
235
+ *
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
 
243
  // Mark as spam
244
  bp_activity_mark_as_spam( $activity );
245
  $activity->save();
246
 
247
+ // Tell the user the spamming has been successful
248
  bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
249
 
250
+ /**
251
+ * Fires after the marking activity as spam so plugins can act afterwards based on the activity.
252
+ *
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
 
260
  // Check for the redirect query arg, otherwise let WP handle things
295
  // Check the nonce
296
  check_admin_referer( 'post_update', '_wpnonce_post_update' );
297
 
298
+ /**
299
+ * Filters the content provided in the activity input field.
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
 
307
  if ( ! empty( $_POST['whats-new-post-object'] ) ) {
308
+
309
+ /**
310
+ * Filters the item type that the activity update should be associated with.
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
  }
318
 
319
  if ( ! empty( $_POST['whats-new-post-in'] ) ) {
320
+
321
+ /**
322
+ * Filters what component the activity is being to.
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
  }
330
 
339
  $activity_id = bp_activity_post_update( array( 'content' => $content ) );
340
 
341
  // Post to groups object
342
+ } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) {
343
  if ( (int) $item_id ) {
344
  $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
345
  }
346
 
 
347
  } else {
348
+
349
+ /**
350
+ * Filters activity object for BuddyPress core and plugin authors before posting activity update.
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
+ */
358
  $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
359
  }
360
 
362
  if ( !empty( $activity_id ) )
363
  bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
364
  else
365
+ bp_core_add_message( __( 'There was an error when posting your update. Please try again.', 'buddypress' ), 'error' );
366
 
367
  // Redirect
368
  bp_core_redirect( wp_get_referer() );
395
  // Check the nonce
396
  check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
397
 
398
+ /**
399
+ * Filters the activity ID a comment will be in reply to.
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
+
407
+ /**
408
+ * Filters the comment content for a comment reply.
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
 
416
  if ( empty( $content ) ) {
427
  if ( !empty( $comment_id ) )
428
  bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) );
429
  else
430
+ bp_core_add_message( __( 'There was an error posting that reply. Please try again.', 'buddypress' ), 'error' );
431
 
432
  bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
433
  }
461
  if ( bp_activity_add_user_favorite( bp_action_variable( 0 ) ) )
462
  bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
463
  else
464
+ bp_core_add_message( __( 'There was an error marking that activity as a favorite. Please try again.', 'buddypress' ), 'error' );
465
 
466
  bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
467
  }
495
  if ( bp_activity_remove_user_favorite( bp_action_variable( 0 ) ) )
496
  bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) );
497
  else
498
+ bp_core_add_message( __( 'There was an error removing that activity as a favorite. Please try again.', 'buddypress' ), 'error' );
499
 
500
  bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
501
  }
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
 
753
  exit;
754
  }
755
 
756
+ $args = array(
757
  'term' => sanitize_text_field( $_GET['term'] ),
758
  'type' => sanitize_text_field( $_GET['type'] ),
759
+ );
760
+
761
+ // Support per-Group suggestions.
762
+ if ( ! empty( $_GET['group-id'] ) ) {
763
+ $args['group_id'] = absint( $_GET['group-id'] );
764
+ }
765
+
766
+ $results = bp_core_get_suggestions( $args );
767
 
768
  if ( is_wp_error( $results ) ) {
769
  wp_send_json_error( $results->get_error_message() );
773
  wp_send_json_success( $results );
774
  }
775
  add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
776
+
777
+ /**
778
+ * Detect a change in post type status, and initiate an activity update if necessary.
779
+ *
780
+ * @since BuddyPress (2.2.0)
781
+ *
782
+ * @todo Support untrashing better.
783
+ *
784
+ * @param string $new_status New status for the post.
785
+ * @param string $old_status Old status for the post.
786
+ * @param object $post Post data.
787
+ */
788
+ function bp_activity_catch_transition_post_type_status( $new_status, $old_status, $post ) {
789
+ if ( ! post_type_supports( $post->post_type, 'buddypress-activity' ) ) {
790
+ return;
791
+ }
792
+
793
+ // This is an edit.
794
+ if ( $new_status === $old_status ) {
795
+ // An edit of an existing post should update the existing activity item.
796
+ if ( $new_status == 'publish' ) {
797
+ bp_activity_post_type_update( $post );
798
+ }
799
+
800
+ return;
801
+ }
802
+
803
+ // Publishing a previously unpublished post.
804
+ if ( 'publish' === $new_status ) {
805
+ // Untrashing the post type - nothing here yet.
806
+ if ( 'trash' == $old_status ) {
807
+ do_action( 'bp_activity_post_type_untrash_' . $post->post_type, $post );
808
+ } else {
809
+ // Record the post.
810
+ bp_activity_post_type_publish( $post->ID, $post );
811
+ }
812
+
813
+ // Unpublishing a previously published post.
814
+ } elseif ( 'publish' === $old_status ) {
815
+ // Some form of pending status - only remove the activity entry
816
+ bp_activity_post_type_unpublish( $post->ID, $post );
817
+ }
818
+ }
819
+ add_action( 'transition_post_status', 'bp_activity_catch_transition_post_type_status', 10, 3 );
bp-activity/bp-activity-admin.php CHANGED
@@ -171,6 +171,14 @@ function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
171
  // Hide the primary link meta box by default
172
  $hidden = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) );
173
 
 
 
 
 
 
 
 
 
174
  return apply_filters( 'bp_hide_meta_boxes', array_unique( $hidden ), $screen );
175
  }
176
  add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
@@ -198,7 +206,13 @@ function bp_activity_admin_load() {
198
 
199
  $doaction = bp_admin_list_table_current_bulk_action();
200
 
201
- // Call an action for plugins to hook in early
 
 
 
 
 
 
202
  do_action( 'bp_activity_admin_load', $doaction );
203
 
204
  // Edit screen
@@ -300,7 +314,13 @@ function bp_activity_admin_load() {
300
  // Get activity IDs
301
  $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
302
 
303
- // Call a filter for plugins to modify the requested activities to load
 
 
 
 
 
 
304
  $activity_ids = apply_filters( 'bp_activity_admin_action_activity_ids', $activity_ids );
305
 
306
  // Is this a bulk request?
@@ -384,7 +404,17 @@ function bp_activity_admin_load() {
384
  unset( $activity );
385
  }
386
 
387
- // Call actions for plugins to do something before we redirect
 
 
 
 
 
 
 
 
 
 
388
  do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids );
389
 
390
  // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
@@ -401,7 +431,13 @@ function bp_activity_admin_load() {
401
  if ( ! empty( $errors ) )
402
  $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to );
403
 
404
- // Redirect
 
 
 
 
 
 
405
  wp_redirect( apply_filters( 'bp_activity_admin_action_redirect', $redirect_to ) );
406
  exit;
407
 
@@ -512,7 +548,13 @@ function bp_activity_admin_load() {
512
  if ( false === $result )
513
  $error = $activity->id;
514
 
515
- // Call actions for plugins to do something before we redirect
 
 
 
 
 
 
516
  do_action_ref_array( 'bp_activity_admin_edit_after', array( &$activity, $error ) );
517
 
518
  // If an error occurred, pass back the activity ID that failed
@@ -521,7 +563,13 @@ function bp_activity_admin_load() {
521
  else
522
  $redirect_to = add_query_arg( 'updated', (int) $activity->id, $redirect_to );
523
 
524
- // Redirect
 
 
 
 
 
 
525
  wp_redirect( apply_filters( 'bp_activity_admin_edit_redirect', $redirect_to ) );
526
  exit;
527
 
@@ -586,7 +634,13 @@ function bp_activity_admin_edit() {
586
  $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
587
  $form_url = add_query_arg( 'action', 'save', $form_url );
588
 
589
- // Call an action for plugins to modify the activity before we display the edit form
 
 
 
 
 
 
590
  do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
591
 
592
  <div class="wrap">
@@ -744,7 +798,7 @@ function bp_activity_admin_get_activity_actions() {
744
  $actions = array();
745
 
746
  // Walk through the registered actions, and build an array of actions/values.
747
- foreach ( buddypress()->activity->actions as $action ) {
748
  $action = array_values( (array) $action );
749
 
750
  for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
@@ -777,7 +831,7 @@ function bp_activity_admin_edit_metabox_type( $item ) {
777
  $selected = $item->type;
778
 
779
  // Walk through the registered actions, and build an array of actions/values.
780
- foreach ( $bp->activity->actions as $action ) {
781
  $action = array_values( (array) $action );
782
 
783
  for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
@@ -894,13 +948,19 @@ function bp_activity_admin_index() {
894
  $messages[] = sprintf( _n( '%s activity item has been successfully unspammed.', '%s activity items have been successfully unspammed.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) );
895
 
896
  if ( $updated > 0 )
897
- $messages[] = __( 'The activity item has been updated succesfully.', 'buddypress' );
898
  }
899
 
900
  // Prepare the activity items for display
901
  $bp_activity_list_table->prepare_items();
902
 
903
- // Call an action for plugins to modify the activity before we display the edit form
 
 
 
 
 
 
904
  do_action( 'bp_activity_admin_index', $messages ); ?>
905
 
906
  <div class="wrap">
@@ -1082,7 +1142,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1082
  'count_total' => 'count_query',
1083
  ) );
1084
 
1085
- // If we're viewing a specific activity, flatten all activites into a single array.
1086
  if ( $include_id ) {
1087
  $activities['activities'] = BP_Activity_List_Table::flatten_activity_array( $activities['activities'] );
1088
  $activities['total'] = count( $activities['activities'] );
@@ -1096,7 +1156,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1096
  foreach ( $activities['activities'] as $activity_item ) {
1097
  $new_activities[] = (array) $activity_item;
1098
 
1099
- // Build an array of activity-to-user ID mappings for better efficency in the In Response To column
1100
  $this->activity_user_id[$activity_item->id] = $activity_item->user_id;
1101
  }
1102
 
@@ -1211,7 +1271,17 @@ class BP_Activity_List_Table extends WP_List_Table {
1211
  <li class="all"><a href="<?php echo esc_attr( esc_url( $url_base ) ); ?>" class="<?php if ( 'spam' != $this->view ) echo 'current'; ?>"><?php _e( 'All', 'buddypress' ); ?></a> |</li>
1212
  <li class="spam"><a href="<?php echo esc_attr( 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>
1213
 
1214
- <?php do_action( 'bp_activity_list_table_get_views', $url_base, $this->view ); ?>
 
 
 
 
 
 
 
 
 
 
1215
  </ul>
1216
  <?php
1217
  }
@@ -1229,6 +1299,13 @@ class BP_Activity_List_Table extends WP_List_Table {
1229
  $actions['bulk_ham'] = __( 'Not Spam', 'buddypress' );
1230
  $actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
1231
 
 
 
 
 
 
 
 
1232
  return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
1233
  }
1234
 
@@ -1288,7 +1365,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1288
  $selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : '';
1289
 
1290
  // Get the actions
1291
- $activity_actions = buddypress()->activity->actions; ?>
1292
 
1293
  <div class="alignleft actions">
1294
  <select name="activity_type">
@@ -1429,7 +1506,14 @@ class BP_Activity_List_Table extends WP_List_Table {
1429
  // Start timestamp
1430
  echo '<div class="submitted-on">';
1431
 
1432
- // Other plugins can filter which actions are shown
 
 
 
 
 
 
 
1433
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1434
 
1435
  /* translators: 2: activity admin ui date/time */
@@ -1440,8 +1524,23 @@ class BP_Activity_List_Table extends WP_List_Table {
1440
 
1441
  // Get activity content - if not set, use the action
1442
  if ( ! empty( $item['content'] ) ) {
 
 
 
 
 
 
 
 
1443
  $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'] ) );
1444
  } else {
 
 
 
 
 
 
 
1445
  $content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'] ) );
1446
  }
1447
 
@@ -1459,6 +1558,15 @@ class BP_Activity_List_Table extends WP_List_Table {
1459
  */
1460
  function column_response( $item ) {
1461
  // Is $item is a root activity?
 
 
 
 
 
 
 
 
 
1462
  if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) ) {
1463
  $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
1464
  $root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
@@ -1504,7 +1612,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1504
 
1505
  /**
1506
  * If, somehow, the referenced activity has been deleted, leaving its associated
1507
- * activites as orphans, use the logged in user's ID to avoid errors.
1508
  */
1509
  if ( empty( $activity['activities'] ) )
1510
  return bp_loggedin_user_id();
@@ -1573,6 +1681,13 @@ class BP_Activity_List_Table extends WP_List_Table {
1573
  }
1574
  }
1575
 
 
 
 
 
 
 
 
1576
  return apply_filters( 'bp_activity_list_table_can_comment', $can_comment );
1577
  }
1578
 
171
  // Hide the primary link meta box by default
172
  $hidden = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) );
173
 
174
+ /**
175
+ * Filters default hidden metaboxes so plugins can alter list.
176
+ *
177
+ * @since BuddyPress (1.6.0)
178
+ *
179
+ * @param array $hidden Default metaboxes to hide.
180
+ * @param WP_Screen $screen Screen identifier.
181
+ */
182
  return apply_filters( 'bp_hide_meta_boxes', array_unique( $hidden ), $screen );
183
  }
184
  add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
206
 
207
  $doaction = bp_admin_list_table_current_bulk_action();
208
 
209
+ /**
210
+ * Fires at top of Activity admin page.
211
+ *
212
+ * @since BuddyPress (1.6.0)
213
+ *
214
+ * @param string $doaction Current $_GET action being performed in admin screen.
215
+ */
216
  do_action( 'bp_activity_admin_load', $doaction );
217
 
218
  // Edit screen
314
  // Get activity IDs
315
  $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
316
 
317
+ /**
318
+ * Filters list of IDs being spammed/un-spammed/deleted.
319
+ *
320
+ * @since BuddyPress (1.6.0)
321
+ *
322
+ * @param array $activity_ids Activity IDs to spam/un-spam/delete.
323
+ */
324
  $activity_ids = apply_filters( 'bp_activity_admin_action_activity_ids', $activity_ids );
325
 
326
  // Is this a bulk request?
404
  unset( $activity );
405
  }
406
 
407
+ /**
408
+ * Fires before redirect for plugins to do something with activity.
409
+ *
410
+ * Passes an activity array counts how many were spam, not spam, deleted, and IDs that were errors.
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 );
419
 
420
  // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
431
  if ( ! empty( $errors ) )
432
  $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to );
433
 
434
+ /**
435
+ * Filters redirect URL after activity spamming/un-spamming/deletion occurs.
436
+ *
437
+ * @since BuddyPress (1.6.0)
438
+ *
439
+ * @param string $redirect_to URL to redirect to.
440
+ */
441
  wp_redirect( apply_filters( 'bp_activity_admin_action_redirect', $redirect_to ) );
442
  exit;
443
 
548
  if ( false === $result )
549
  $error = $activity->id;
550
 
551
+ /**
552
+ * Fires before redirect so plugins can do something first on save action.
553
+ *
554
+ * @since BuddyPress (1.6.0)
555
+ *
556
+ * @param array Array holding activity object and ID that holds error.
557
+ */
558
  do_action_ref_array( 'bp_activity_admin_edit_after', array( &$activity, $error ) );
559
 
560
  // If an error occurred, pass back the activity ID that failed
563
  else
564
  $redirect_to = add_query_arg( 'updated', (int) $activity->id, $redirect_to );
565
 
566
+ /**
567
+ * Filters URL to redirect to after saving.
568
+ *
569
+ * @since BuddyPress (1.6.0)
570
+ *
571
+ * @param string $redirect_to URL to redirect to.
572
+ */
573
  wp_redirect( apply_filters( 'bp_activity_admin_edit_redirect', $redirect_to ) );
574
  exit;
575
 
634
  $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
635
  $form_url = add_query_arg( 'action', 'save', $form_url );
636
 
637
+ /**
638
+ * Fires before activity edit form is displays so plugins can modify the activity.
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
 
646
  <div class="wrap">
798
  $actions = array();
799
 
800
  // Walk through the registered actions, and build an array of actions/values.
801
+ foreach ( bp_activity_get_actions() as $action ) {
802
  $action = array_values( (array) $action );
803
 
804
  for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
831
  $selected = $item->type;
832
 
833
  // Walk through the registered actions, and build an array of actions/values.
834
+ foreach ( bp_activity_get_actions() as $action ) {
835
  $action = array_values( (array) $action );
836
 
837
  for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
948
  $messages[] = sprintf( _n( '%s activity item has been successfully unspammed.', '%s activity items have been successfully unspammed.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) );
949
 
950
  if ( $updated > 0 )
951
+ $messages[] = __( 'The activity item has been updated successfully.', 'buddypress' );
952
  }
953
 
954
  // Prepare the activity items for display
955
  $bp_activity_list_table->prepare_items();
956
 
957
+ /**
958
+ * Fires before edit form is displayed so plugins can modify the activity messages.
959
+ *
960
+ * @since BuddyPress (1.6.0)
961
+ *
962
+ * @param array $messages Array of messages to display at top of page.
963
+ */
964
  do_action( 'bp_activity_admin_index', $messages ); ?>
965
 
966
  <div class="wrap">
1142
  'count_total' => 'count_query',
1143
  ) );
1144
 
1145
+ // If we're viewing a specific activity, flatten all activities into a single array.
1146
  if ( $include_id ) {
1147
  $activities['activities'] = BP_Activity_List_Table::flatten_activity_array( $activities['activities'] );
1148
  $activities['total'] = count( $activities['activities'] );
1156
  foreach ( $activities['activities'] as $activity_item ) {
1157
  $new_activities[] = (array) $activity_item;
1158
 
1159
+ // Build an array of activity-to-user ID mappings for better efficiency in the In Response To column
1160
  $this->activity_user_id[$activity_item->id] = $activity_item->user_id;
1161
  }
1162
 
1271
  <li class="all"><a href="<?php echo esc_attr( esc_url( $url_base ) ); ?>" class="<?php if ( 'spam' != $this->view ) echo 'current'; ?>"><?php _e( 'All', 'buddypress' ); ?></a> |</li>
1272
  <li class="spam"><a href="<?php echo esc_attr( 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>
1273
 
1274
+ <?php
1275
+
1276
+ /**
1277
+ * Fires inside listing of views so plugins can add their own.
1278
+ *
1279
+ * @since BuddyPress (1.6.0)
1280
+ *
1281
+ * @param string $url_base Current URL base for view.
1282
+ * @param string $view Current view being displayed.
1283
+ */
1284
+ do_action( 'bp_activity_list_table_get_views', $url_base, $this->view ); ?>
1285
  </ul>
1286
  <?php
1287
  }
1299
  $actions['bulk_ham'] = __( 'Not Spam', 'buddypress' );
1300
  $actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
1301
 
1302
+ /**
1303
+ * Filters the default bulk actions so plugins can add custom actions.
1304
+ *
1305
+ * @since BuddyPress (1.6.0)
1306
+ *
1307
+ * @param array $actions Default available actions for bulk operations.
1308
+ */
1309
  return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
1310
  }
1311
 
1365
  $selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : '';
1366
 
1367
  // Get the actions
1368
+ $activity_actions = bp_activity_get_actions(); ?>
1369
 
1370
  <div class="alignleft actions">
1371
  <select name="activity_type">
1506
  // Start timestamp
1507
  echo '<div class="submitted-on">';
1508
 
1509
+ /**
1510
+ * Filters available actions for plugins to alter.
1511
+ *
1512
+ * @since BuddyPress (1.6.0)
1513
+ *
1514
+ * @param array $actions Array of available actions user could use.
1515
+ * @param array $item Current item being added to page.
1516
+ */
1517
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1518
 
1519
  /* translators: 2: activity admin ui date/time */
1524
 
1525
  // Get activity content - if not set, use the action
1526
  if ( ! empty( $item['content'] ) ) {
1527
+
1528
+ /**
1529
+ * Filters current activity item content.
1530
+ *
1531
+ * @since BuddyPress (1.2.0)
1532
+ *
1533
+ * @param array $item Array index holding current activity item content.
1534
+ */
1535
  $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'] ) );
1536
  } else {
1537
+ /**
1538
+ * Filters current activity item action.
1539
+ *
1540
+ * @since BuddyPress (1.2.0)
1541
+ *
1542
+ * @var array $item Array index holding current activity item action.
1543
+ */
1544
  $content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'] ) );
1545
  }
1546
 
1558
  */
1559
  function column_response( $item ) {
1560
  // Is $item is a root activity?
1561
+
1562
+ /**
1563
+ * Filters default list of default root activity types.
1564
+ *
1565
+ * @since BuddyPress (1.6.0)
1566
+ *
1567
+ * @param array Array of default activity types.
1568
+ * @param array $item Current item being displayed.
1569
+ */
1570
  if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) ) {
1571
  $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
1572
  $root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1612
 
1613
  /**
1614
  * If, somehow, the referenced activity has been deleted, leaving its associated
1615
+ * activities as orphans, use the logged in user's ID to avoid errors.
1616
  */
1617
  if ( empty( $activity['activities'] ) )
1618
  return bp_loggedin_user_id();
1681
  }
1682
  }
1683
 
1684
+ /**
1685
+ * Filters if an activity item can be commented on or not.
1686
+ *
1687
+ * @since BuddyPress (2.0.0)
1688
+ *
1689
+ * @param bool $can_comment Whether an activity item can be commented on or not.
1690
+ */
1691
  return apply_filters( 'bp_activity_list_table_can_comment', $can_comment );
1692
  }
1693
 
bp-activity/bp-activity-akismet.php CHANGED
@@ -112,6 +112,13 @@ class BP_Akismet {
112
  if ( $desc )
113
  echo '<span class="akismet-status"><a href="' . esc_url( bp_get_admin_url( 'admin.php?page=bp-activity&amp;action=edit&aid=' . $activity['id'] ) ) . '#bp_activity_history">' . htmlspecialchars( $desc ) . '</a></span>';
114
 
 
 
 
 
 
 
 
115
  return apply_filters( 'bp_akismet_comment_row_action', $actions );
116
  }
117
 
@@ -239,6 +246,14 @@ class BP_Akismet {
239
  * @return array List of activity types.
240
  */
241
  public static function get_activity_types() {
 
 
 
 
 
 
 
 
242
  return apply_filters( 'bp_akismet_get_activity_types', array( 'activity_comment', 'activity_update' ) );
243
  }
244
 
@@ -254,6 +269,14 @@ class BP_Akismet {
254
  // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
255
  $this->last_activity = $activity;
256
 
 
 
 
 
 
 
 
 
257
  do_action( 'bp_activity_akismet_mark_as_spam', $activity, $source );
258
  }
259
 
@@ -270,6 +293,14 @@ class BP_Akismet {
270
  if ( 'true' == bp_activity_get_meta( $activity->id, '_bp_akismet_result' ) && !bp_activity_get_meta( $activity->id, '_bp_akismet_user_result' ) )
271
  $activity->content = bp_activity_at_name_filter( $activity->content, $activity->id );
272
 
 
 
 
 
 
 
 
 
273
  do_action( 'bp_activity_akismet_mark_as_ham', $activity, $source );
274
  }
275
 
@@ -311,6 +342,14 @@ class BP_Akismet {
311
  elseif ( !empty( $activity->secondary_item_id ) && !empty( $_POST['_bp_as_nonce_' . $activity->secondary_item_id] ) )
312
  $activity_data['akismet_comment_nonce'] = wp_verify_nonce( $_POST["_bp_as_nonce_{$activity->secondary_item_id}"], "_bp_as_nonce_{$userdata->ID}_{$activity->secondary_item_id}" ) ? 'passed' : 'failed';
313
 
 
 
 
 
 
 
 
 
314
  return apply_filters( 'bp_akismet_build_akismet_data_package', $activity_data, $activity );
315
  }
316
 
@@ -347,7 +386,14 @@ class BP_Akismet {
347
 
348
  // Spam
349
  if ( 'true' == $activity_data['bp_as_result'] ) {
350
- // Action for plugin authors
 
 
 
 
 
 
 
351
  do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
352
 
353
  // Mark as spam
@@ -431,7 +477,7 @@ class BP_Akismet {
431
  /**
432
  * Contact Akismet to check if this is spam or ham.
433
  *
434
- * Props to WordPress core Akismet plugin for alot of this.
435
  *
436
  * @since BuddyPress (1.6)
437
  *
@@ -450,7 +496,7 @@ class BP_Akismet {
450
  if ( function_exists( 'akismet_init' ) && ( empty( $akismet_api_host ) || empty( $akismet_api_port ) ) )
451
  akismet_init();
452
 
453
- $query_string = $path = $response = '';
454
 
455
  $activity_data['blog'] = bp_get_option( 'home' );
456
  $activity_data['blog_charset'] = bp_get_option( 'blog_charset' );
@@ -614,6 +660,13 @@ class BP_Akismet {
614
  function bp_activity_akismet_delete_old_metadata() {
615
  global $bp, $wpdb;
616
 
 
 
 
 
 
 
 
617
  $interval = apply_filters( 'bp_activity_akismet_delete_meta_interval', 15 );
618
 
619
  // Enforce a minimum of 1 day
112
  if ( $desc )
113
  echo '<span class="akismet-status"><a href="' . esc_url( bp_get_admin_url( 'admin.php?page=bp-activity&amp;action=edit&aid=' . $activity['id'] ) ) . '#bp_activity_history">' . htmlspecialchars( $desc ) . '</a></span>';
114
 
115
+ /**
116
+ * Filters the list of actions for the current activity's row.
117
+ *
118
+ * @since BuddyPress (1.6.0)
119
+ *
120
+ * @param array $actions Array of available actions for the current activity item's row.
121
+ */
122
  return apply_filters( 'bp_akismet_comment_row_action', $actions );
123
  }
124
 
246
  * @return array List of activity types.
247
  */
248
  public static function get_activity_types() {
249
+
250
+ /**
251
+ * Filters the list of activity types that Akismet should automatically check for spam.
252
+ *
253
+ * @since BuddyPress (1.6.0)
254
+ *
255
+ * @param array Array of default activity types for Akismet to check.
256
+ */
257
  return apply_filters( 'bp_akismet_get_activity_types', array( 'activity_comment', 'activity_update' ) );
258
  }
259
 
269
  // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
270
  $this->last_activity = $activity;
271
 
272
+ /**
273
+ * Fires after marking an activity item has been marked as spam.
274
+ *
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
  }
282
 
293
  if ( 'true' == bp_activity_get_meta( $activity->id, '_bp_akismet_result' ) && !bp_activity_get_meta( $activity->id, '_bp_akismet_user_result' ) )
294
  $activity->content = bp_activity_at_name_filter( $activity->content, $activity->id );
295
 
296
+ /**
297
+ * Fires after marking an activity item has been marked as ham.
298
+ *
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
  }
306
 
342
  elseif ( !empty( $activity->secondary_item_id ) && !empty( $_POST['_bp_as_nonce_' . $activity->secondary_item_id] ) )
343
  $activity_data['akismet_comment_nonce'] = wp_verify_nonce( $_POST["_bp_as_nonce_{$activity->secondary_item_id}"], "_bp_as_nonce_{$userdata->ID}_{$activity->secondary_item_id}" ) ? 'passed' : 'failed';
344
 
345
+ /**
346
+ * Filters activity data before being sent to Akismet to inspect.
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
  }
355
 
386
 
387
  // Spam
388
  if ( 'true' == $activity_data['bp_as_result'] ) {
389
+ /**
390
+ * Fires after an activity item has been proven to be spam, but before officially being marked as spam.
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
 
399
  // Mark as spam
477
  /**
478
  * Contact Akismet to check if this is spam or ham.
479
  *
480
+ * Props to WordPress core Akismet plugin for a lot of this.
481
  *
482
  * @since BuddyPress (1.6)
483
  *
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' );
502
  $activity_data['blog_charset'] = bp_get_option( 'blog_charset' );
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.
665
+ *
666
+ * @since BuddyPress (1.6.0)
667
+ *
668
+ * @param integer 15 How many days old metadata needs to be.
669
+ */
670
  $interval = apply_filters( 'bp_activity_akismet_delete_meta_interval', 15 );
671
 
672
  // Enforce a minimum of 1 day
bp-activity/bp-activity-classes.php CHANGED
@@ -169,7 +169,7 @@ class BP_Activity_Activity {
169
 
170
  // If no callback is available, use the literal string from
171
  // the database row
172
- } else if ( ! empty( $row->action ) ) {
173
  $this->action = $row->action;
174
 
175
  // Provide a fallback to avoid PHP notices
@@ -201,7 +201,15 @@ class BP_Activity_Activity {
201
  $this->mptt_right = apply_filters_ref_array( 'bp_activity_mptt_right_before_save', array( $this->mptt_right, &$this ) );
202
  $this->is_spam = apply_filters_ref_array( 'bp_activity_is_spam_before_save', array( $this->is_spam, &$this ) );
203
 
204
- // Use this, not the filters above
 
 
 
 
 
 
 
 
205
  do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
206
 
207
  if ( !$this->component || !$this->type )
@@ -227,6 +235,13 @@ class BP_Activity_Activity {
227
  else
228
  add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
229
 
 
 
 
 
 
 
 
230
  do_action_ref_array( 'bp_activity_after_save', array( &$this ) );
231
 
232
  return true;
@@ -244,35 +259,27 @@ class BP_Activity_Activity {
244
  *
245
  * @param array $args {
246
  * An array of arguments. All items are optional.
247
- * @type int $page Which page of results to fetch. Using page=1
248
- * without per_page will result in no pagination.
249
- * Default: 1.
250
- * @type int|bool $per_page Number of results per page. Default: 25.
251
- * @type int|bool $max Maximum number of results to return.
252
- * Default: false (unlimited).
253
- * @type string $sort ASC or DESC. Default: 'DESC'.
254
- * @type array $exclude Array of activity IDs to exclude.
255
- * Default: false.
256
- * @type array $in Array of ids to limit query by (IN).
257
- * Default: false.
258
- * @type array $meta_query An array of meta_query conditions.
259
- * See WP_Meta_Query::queries for description.
260
- * @type array $date_query An array of date_query conditions.
261
- * See first parameter of WP_Date_Query::__construct()
262
- * for description.
263
- * @type array $filter See BP_Activity_Activity::get_filter_sql().
264
- * @type string $search_terms Limit results by a search term.
265
- * Default: false.
266
- * @type bool $display_comments Whether to include activity comments.
267
- * Default: false.
268
- * @type bool $show_hidden Whether to show items marked hide_sitewide.
269
- * Default: false.
270
- * @type string $spam Spam status. Default: 'ham_only'.
271
- * @type bool $update_meta_cache Whether to pre-fetch metadata for
272
- * queried activity items. Default: true.
273
- * @type string|bool $count_total If true, an additional DB query
274
- * is run to count the total activity items for the query.
275
- * Default: false.
276
  * }
277
  * @return array The array returned has two keys:
278
  * - 'total' is the count of located activities
@@ -312,7 +319,9 @@ class BP_Activity_Activity {
312
  'in' => false, // Array of ids to limit query by (IN)
313
  'meta_query' => false, // Filter by activitymeta
314
  'date_query' => false, // Filter by date
 
315
  'filter' => false, // See self::get_filter_sql()
 
316
  'search_terms' => false, // Terms to search by
317
  'display_comments' => false, // Whether to include activity comments
318
  'show_hidden' => false, // Show items marked hide_sitewide
@@ -321,7 +330,6 @@ class BP_Activity_Activity {
321
  'count_total' => false,
322
  );
323
  $r = wp_parse_args( $args, $defaults );
324
- extract( $r );
325
 
326
  // Select conditions
327
  $select_sql = "SELECT DISTINCT a.id";
@@ -336,44 +344,73 @@ class BP_Activity_Activity {
336
  // Excluded types
337
  $excluded_types = array();
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  // Spam
340
- if ( 'ham_only' == $spam )
341
  $where_conditions['spam_sql'] = 'a.is_spam = 0';
342
- elseif ( 'spam_only' == $spam )
343
  $where_conditions['spam_sql'] = 'a.is_spam = 1';
 
344
 
345
  // Searching
346
- if ( $search_terms ) {
347
- $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
348
  $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
349
  }
350
 
351
- // Filtering
352
- if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) )
353
- $where_conditions['filter_sql'] = $filter_sql;
354
-
355
  // Sorting
356
- if ( $sort != 'ASC' && $sort != 'DESC' )
 
357
  $sort = 'DESC';
 
358
 
359
  // Hide Hidden Items?
360
- if ( !$show_hidden )
361
  $where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
362
 
363
  // Exclude specified items
364
- if ( !empty( $exclude ) ) {
365
- $exclude = implode( ',', wp_parse_id_list( $exclude ) );
366
  $where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
367
  }
368
 
369
  // The specific ids to which you want to limit the query
370
- if ( !empty( $in ) ) {
371
- $in = implode( ',', wp_parse_id_list( $in ) );
372
  $where_conditions['in'] = "a.id IN ({$in})";
373
  }
374
 
375
  // Process meta_query into SQL
376
- $meta_query_sql = self::get_meta_query_sql( $meta_query );
377
 
378
  if ( ! empty( $meta_query_sql['join'] ) ) {
379
  $join_sql .= $meta_query_sql['join'];
@@ -384,7 +421,7 @@ class BP_Activity_Activity {
384
  }
385
 
386
  // Process date_query into SQL
387
- $date_query_sql = self::get_date_query_sql( $date_query );
388
 
389
  if ( ! empty( $date_query_sql ) ) {
390
  $where_conditions['date'] = $date_query_sql;
@@ -393,34 +430,45 @@ class BP_Activity_Activity {
393
  // Alter the query based on whether we want to show activity item
394
  // comments in the stream like normal comments or threaded below
395
  // the activity.
396
- if ( false === $display_comments || 'threaded' === $display_comments ) {
397
  $excluded_types[] = 'activity_comment';
398
  }
399
 
400
  // Exclude 'last_activity' items unless the 'action' filter has
401
  // been explicitly set
402
- if ( empty( $filter['object'] ) ) {
403
  $excluded_types[] = 'last_activity';
404
  }
405
 
406
- // Exclude 'new_member' items if xprofile component is not active
407
- if ( ! bp_is_active( 'xprofile' ) ) {
408
- $excluded_types[] = 'new_member';
409
- }
410
-
411
  // Build the excluded type sql part
412
  if ( ! empty( $excluded_types ) ) {
413
  $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
414
  $where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
415
  }
416
 
417
- // Filter the where conditions
 
 
 
 
 
 
 
 
 
 
418
  $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
419
 
420
  // Join the where conditions together
421
  $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
422
 
423
- // Define the preferred order for indexes
 
 
 
 
 
 
424
  $indexes = apply_filters( 'bp_activity_preferred_index_order', array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ) );
425
 
426
  foreach( $indexes as $key => $index ) {
@@ -437,8 +485,8 @@ class BP_Activity_Activity {
437
  }
438
 
439
  // Sanitize page and per_page parameters
440
- $page = absint( $page );
441
- $per_page = absint( $per_page );
442
 
443
  $retval = array(
444
  'activities' => null,
@@ -446,7 +494,17 @@ class BP_Activity_Activity {
446
  'has_more_items' => null,
447
  );
448
 
449
- // Filter and return true to use the legacy query structure (not recommended)
 
 
 
 
 
 
 
 
 
 
450
  if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
451
 
452
  // Legacy queries joined against the user table
@@ -455,13 +513,27 @@ class BP_Activity_Activity {
455
 
456
  if ( ! empty( $page ) && ! empty( $per_page ) ) {
457
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
 
 
458
  $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 ) );
459
  } else {
460
- $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 ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  }
462
 
463
  } else {
464
-
465
  // Query first for activity IDs
466
  $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
467
 
@@ -471,6 +543,14 @@ class BP_Activity_Activity {
471
  $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
472
  }
473
 
 
 
 
 
 
 
 
 
474
  $activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
475
 
476
  $activity_ids = $wpdb->get_col( $activity_ids_sql );
@@ -495,12 +575,13 @@ class BP_Activity_Activity {
495
  $activity_ids[] = $activity->id;
496
  }
497
 
498
- if ( ! empty( $activity_ids ) && $update_meta_cache ) {
499
  bp_activity_update_meta_cache( $activity_ids );
500
  }
501
 
502
- if ( $activities && $display_comments )
503
- $activities = BP_Activity_Activity::append_comments( $activities, $spam );
 
504
 
505
  // Pre-fetch data associated with activity users and other objects
506
  BP_Activity_Activity::prefetch_object_data( $activities );
@@ -513,12 +594,21 @@ class BP_Activity_Activity {
513
  // If $max is set, only return up to the max results
514
  if ( ! empty( $r['count_total'] ) ) {
515
 
 
 
 
 
 
 
 
 
 
516
  $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 );
517
  $total_activities = $wpdb->get_var( $total_activities_sql );
518
 
519
- if ( !empty( $max ) ) {
520
- if ( (int) $total_activities > (int) $max )
521
- $total_activities = $max;
522
  }
523
 
524
  $retval['total'] = $total_activities;
@@ -639,6 +729,14 @@ class BP_Activity_Activity {
639
  * @param array $activities Array of activities.
640
  */
641
  protected static function prefetch_object_data( $activities ) {
 
 
 
 
 
 
 
 
642
  return apply_filters( 'bp_activity_prefetch_object_data', $activities );
643
  }
644
 
@@ -735,6 +833,103 @@ class BP_Activity_Activity {
735
  return $sql;
736
  }
737
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
738
  /**
739
  * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
740
  *
@@ -1029,7 +1224,7 @@ class BP_Activity_Activity {
1029
  $comments = false;
1030
 
1031
  // A true cache miss
1032
- } else if ( empty( $comments ) ) {
1033
 
1034
  // Select the user's fullname with the query
1035
  if ( bp_is_active( 'xprofile' ) ) {
@@ -1053,7 +1248,29 @@ class BP_Activity_Activity {
1053
 
1054
  // Legacy query - not recommended
1055
  $func_args = func_get_args();
 
 
 
 
 
 
 
 
 
 
1056
  if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $func_args ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
1057
  $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 );
1058
 
1059
  $descendants = $wpdb->get_results( $sql );
@@ -1138,7 +1355,7 @@ class BP_Activity_Activity {
1138
  * @global BuddyPress $bp The one true BuddyPress instance.
1139
  * @global wpdb $wpdb WordPress database object.
1140
  *
1141
- * @param int $parent_id ID of an activty or activity comment.
1142
  * @param int $left Node boundary start for activity or activity comment.
1143
  * @return int Right node boundary of activity or activity comment.
1144
  */
@@ -1174,7 +1391,7 @@ class BP_Activity_Activity {
1174
  * @global BuddyPress $bp The one true BuddyPress instance.
1175
  * @global wpdb $wpdb WordPress database object.
1176
  *
1177
- * @param int $parent_id ID of an activty or activity comment.
1178
  * @return object Numerically indexed array of child comments.
1179
  */
1180
  public static function get_child_comments( $parent_id ) {
@@ -1391,6 +1608,303 @@ class BP_Activity_Activity {
1391
 
1392
  return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
1393
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1394
  }
1395
 
1396
  /**
@@ -1449,7 +1963,14 @@ class BP_Activity_Feed {
1449
  * @param array $args Optional
1450
  */
1451
  public function __construct( $args = array() ) {
1452
- // If feeds are disabled, stop now!
 
 
 
 
 
 
 
1453
  if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
1454
  global $wp_query;
1455
 
@@ -1495,7 +2016,13 @@ class BP_Activity_Feed {
1495
  'activity_args' => array()
1496
  ) );
1497
 
1498
- // Plugins can use this filter to modify the feed before it is setup
 
 
 
 
 
 
1499
  do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
1500
 
1501
  // Setup class properties
@@ -1507,7 +2034,13 @@ class BP_Activity_Feed {
1507
  return false;
1508
  }
1509
 
1510
- // Plugins can use this filter to modify the feed after it's setup
 
 
 
 
 
 
1511
  do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
1512
 
1513
  // Setup feed hooks
@@ -1564,6 +2097,14 @@ class BP_Activity_Feed {
1564
  * Fire a hook to ensure backward compatibility for RSS attributes.
1565
  */
1566
  public function backpat_rss_attributes() {
 
 
 
 
 
 
 
 
1567
  do_action( 'bp_activity_' . $this->id . '_feed' );
1568
  }
1569
 
@@ -1571,6 +2112,14 @@ class BP_Activity_Feed {
1571
  * Fire a hook to ensure backward compatibility for channel elements.
1572
  */
1573
  public function backpat_channel_elements() {
 
 
 
 
 
 
 
 
1574
  do_action( 'bp_activity_' . $this->id . '_feed_head' );
1575
  }
1576
 
@@ -1593,6 +2142,13 @@ class BP_Activity_Feed {
1593
  break;
1594
  }
1595
 
 
 
 
 
 
 
 
1596
  do_action( 'bp_activity_' . $id . '_feed_item' );
1597
  }
1598
 
@@ -1646,6 +2202,7 @@ class BP_Activity_Feed {
1646
 
1647
  // Set content-type
1648
  @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
 
1649
 
1650
  // Cache-related variables
1651
  $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
@@ -1718,7 +2275,14 @@ class BP_Activity_Feed {
1718
  xmlns:atom="http://www.w3.org/2005/Atom"
1719
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
1720
  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
1721
- <?php do_action( 'bp_activity_feed_rss_attributes' ); ?>
 
 
 
 
 
 
 
1722
  >
1723
 
1724
  <channel>
@@ -1732,7 +2296,14 @@ class BP_Activity_Feed {
1732
  <ttl><?php echo $this->ttl; ?></ttl>
1733
  <sy:updatePeriod><?php echo $this->update_period; ?></sy:updatePeriod>
1734
  <sy:updateFrequency><?php echo $this->update_frequency; ?></sy:updateFrequency>
1735
- <?php do_action( 'bp_activity_feed_channel_elements' ); ?>
 
 
 
 
 
 
 
1736
 
1737
  <?php if ( bp_has_activities( $this->activity_args ) ) : ?>
1738
  <?php while ( bp_activities() ) : bp_the_activity(); ?>
@@ -1750,7 +2321,14 @@ class BP_Activity_Feed {
1750
  <slash:comments><?php bp_activity_comment_count(); ?></slash:comments>
1751
  <?php endif; ?>
1752
 
1753
- <?php do_action( 'bp_activity_feed_item_elements' ); ?>
 
 
 
 
 
 
 
1754
  </item>
1755
  <?php endwhile; ?>
1756
 
169
 
170
  // If no callback is available, use the literal string from
171
  // the database row
172
+ } elseif ( ! empty( $row->action ) ) {
173
  $this->action = $row->action;
174
 
175
  // Provide a fallback to avoid PHP notices
201
  $this->mptt_right = apply_filters_ref_array( 'bp_activity_mptt_right_before_save', array( $this->mptt_right, &$this ) );
202
  $this->is_spam = apply_filters_ref_array( 'bp_activity_is_spam_before_save', array( $this->is_spam, &$this ) );
203
 
204
+ /**
205
+ * Fires before the current activity item gets saved.
206
+ *
207
+ * Please use this hook to filter the properties above. Each part will be passed in.
208
+ *
209
+ * @since BuddyPress (1.0.0)
210
+ *
211
+ * @param BP_Activity_Activity Current instance of the activity item being saved.
212
+ */
213
  do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
214
 
215
  if ( !$this->component || !$this->type )
235
  else
236
  add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
237
 
238
+ /**
239
+ * Fires after an activity item has been saved to the database.
240
+ *
241
+ * @since BuddyPress (1.0.0)
242
+ *
243
+ * @param BP_Activity_Activity Reference to current instance of activity being saved.
244
+ */
245
  do_action_ref_array( 'bp_activity_after_save', array( &$this ) );
246
 
247
  return true;
259
  *
260
  * @param array $args {
261
  * An array of arguments. All items are optional.
262
+ *
263
+ * @type int $page Which page of results to fetch. Using page=1 without per_page will result
264
+ * in no pagination. Default: 1.
265
+ * @type int|bool $per_page Number of results per page. Default: 25.
266
+ * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
267
+ * @type string $sort ASC or DESC. Default: 'DESC'.
268
+ * @type array $exclude Array of activity IDs to exclude. Default: false.
269
+ * @type array $in Array of ids to limit query by (IN). Default: false.
270
+ * @type array $meta_query Array of meta_query conditions. See WP_Meta_Query::queries.
271
+ * @type array $date_query Array of date_query conditions. See first parameter of
272
+ * WP_Date_Query::__construct().
273
+ * @type array $filter_query Array of advanced query conditions. See BP_Activity_Query::__construct().
274
+ * @type string|array $scope Pre-determined set of activity arguments.
275
+ * @type array $filter See BP_Activity_Activity::get_filter_sql().
276
+ * @type string $search_terms Limit results by a search term. Default: false.
277
+ * @type bool $display_comments Whether to include activity comments. Default: false.
278
+ * @type bool $show_hidden Whether to show items marked hide_sitewide. Default: false.
279
+ * @type string $spam Spam status. Default: 'ham_only'.
280
+ * @type bool $update_meta_cache Whether to pre-fetch metadata for queried activity items. Default: true.
281
+ * @type string|bool $count_total If true, an additional DB query is run to count the total activity items
282
+ * for the query. Default: false.
 
 
 
 
 
 
 
 
283
  * }
284
  * @return array The array returned has two keys:
285
  * - 'total' is the count of located activities
319
  'in' => false, // Array of ids to limit query by (IN)
320
  'meta_query' => false, // Filter by activitymeta
321
  'date_query' => false, // Filter by date
322
+ 'filter_query' => false, // Advanced filtering - see BP_Activity_Query
323
  'filter' => false, // See self::get_filter_sql()
324
+ 'scope' => false, // Preset activity arguments
325
  'search_terms' => false, // Terms to search by
326
  'display_comments' => false, // Whether to include activity comments
327
  'show_hidden' => false, // Show items marked hide_sitewide
330
  'count_total' => false,
331
  );
332
  $r = wp_parse_args( $args, $defaults );
 
333
 
334
  // Select conditions
335
  $select_sql = "SELECT DISTINCT a.id";
344
  // Excluded types
345
  $excluded_types = array();
346
 
347
+ // Scope takes precedence
348
+ if ( ! empty( $r['scope'] ) ) {
349
+ $scope_query = self::get_scope_query_sql( $r['scope'], $r );
350
+
351
+ // Add our SQL conditions if matches were found
352
+ if ( ! empty( $scope_query['sql'] ) ) {
353
+ $where_conditions['scope_query_sql'] = $scope_query['sql'];
354
+
355
+ // No matches, so we should alter the SQL statement to match nothing
356
+ } else {
357
+ $where_conditions['scope_no_results'] = '0 = 1';
358
+ }
359
+
360
+ // override some arguments if needed
361
+ if ( ! empty( $scope_query['override'] ) ) {
362
+ $r = self::array_replace_recursive( $r, $scope_query['override'] );
363
+ }
364
+ // Advanced filtering
365
+ } elseif ( ! empty( $r['filter_query'] ) ) {
366
+ $filter_query = new BP_Activity_Query( $r['filter_query'] );
367
+ if ( $sql = $filter_query->get_sql() ) {
368
+ $where_conditions['filter_query_sql'] = $sql;
369
+ }
370
+ }
371
+
372
+ // Regular filtering
373
+ if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
374
+ $where_conditions['filter_sql'] = $filter_sql;
375
+ }
376
+
377
  // Spam
378
+ if ( 'ham_only' == $r['spam'] ) {
379
  $where_conditions['spam_sql'] = 'a.is_spam = 0';
380
+ } elseif ( 'spam_only' == $r['spam'] ) {
381
  $where_conditions['spam_sql'] = 'a.is_spam = 1';
382
+ }
383
 
384
  // Searching
385
+ if ( $r['search_terms'] ) {
386
+ $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
387
  $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
388
  }
389
 
 
 
 
 
390
  // Sorting
391
+ $sort = $r['sort'];
392
+ if ( $sort != 'ASC' && $sort != 'DESC' ) {
393
  $sort = 'DESC';
394
+ }
395
 
396
  // Hide Hidden Items?
397
+ if ( ! $r['show_hidden'] )
398
  $where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
399
 
400
  // Exclude specified items
401
+ if ( ! empty( $r['exclude'] ) ) {
402
+ $exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
403
  $where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
404
  }
405
 
406
  // The specific ids to which you want to limit the query
407
+ if ( ! empty( $r['in'] ) ) {
408
+ $in = implode( ',', wp_parse_id_list( $r['in'] ) );
409
  $where_conditions['in'] = "a.id IN ({$in})";
410
  }
411
 
412
  // Process meta_query into SQL
413
+ $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
414
 
415
  if ( ! empty( $meta_query_sql['join'] ) ) {
416
  $join_sql .= $meta_query_sql['join'];
421
  }
422
 
423
  // Process date_query into SQL
424
+ $date_query_sql = self::get_date_query_sql( $r['date_query'] );
425
 
426
  if ( ! empty( $date_query_sql ) ) {
427
  $where_conditions['date'] = $date_query_sql;
430
  // Alter the query based on whether we want to show activity item
431
  // comments in the stream like normal comments or threaded below
432
  // the activity.
433
+ if ( false === $r['display_comments'] || 'threaded' === $r['display_comments'] ) {
434
  $excluded_types[] = 'activity_comment';
435
  }
436
 
437
  // Exclude 'last_activity' items unless the 'action' filter has
438
  // been explicitly set
439
+ if ( empty( $r['filter']['object'] ) ) {
440
  $excluded_types[] = 'last_activity';
441
  }
442
 
 
 
 
 
 
443
  // Build the excluded type sql part
444
  if ( ! empty( $excluded_types ) ) {
445
  $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
446
  $where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
447
  }
448
 
449
+ /**
450
+ * Filters the MySQL WHERE conditions for the Activity items get method.
451
+ *
452
+ * @since BuddyPress (1.9.0)
453
+ *
454
+ * @param array $where_conditions Current conditions for MySQL WHERE statement.
455
+ * @param array $r Parsed arguments passed into method.
456
+ * @param string $select_sql Current SELECT MySQL statement at point of execution.
457
+ * @param string $from_sql Current FROM MySQL statement at point of execution.
458
+ * @param string $join_sql Current INNER JOIN MySQL statement at point of execution.
459
+ */
460
  $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
461
 
462
  // Join the where conditions together
463
  $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
464
 
465
+ /**
466
+ * Filters the preferred order of indexes for activity item.
467
+ *
468
+ * @since Buddypress (1.6.0)
469
+ *
470
+ * @param array Array of indexes in preferred order.
471
+ */
472
  $indexes = apply_filters( 'bp_activity_preferred_index_order', array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ) );
473
 
474
  foreach( $indexes as $key => $index ) {
485
  }
486
 
487
  // Sanitize page and per_page parameters
488
+ $page = absint( $r['page'] );
489
+ $per_page = absint( $r['per_page'] );
490
 
491
  $retval = array(
492
  'activities' => null,
494
  'has_more_items' => null,
495
  );
496
 
497
+ /**
498
+ * Filters if BuddyPress should use legacy query structure over current structure for version 2.0+.
499
+ *
500
+ * It is not recommended to use the legacy structure, but allowed to if needed.
501
+ *
502
+ * @since BuddyPress (2.0.0)
503
+ *
504
+ * @param bool Whether to use legacy structure or not.
505
+ * @param BP_Activity_Activity Current method being called.
506
+ * @param array $r Parsed arguments passed into method.
507
+ */
508
  if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
509
 
510
  // Legacy queries joined against the user table
513
 
514
  if ( ! empty( $page ) && ! empty( $per_page ) ) {
515
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
516
+
517
+ /** this filter is documented in bp-activity/bp-activity-classes.php */
518
  $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 ) );
519
  } else {
520
+ $pag_sql = '';
521
+
522
+ /**
523
+ * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
524
+ *
525
+ * @since BuddyPress (1.5.0)
526
+ *
527
+ * @param string Concatenated MySQL statement pieces to be query results with for legacy query.
528
+ * @param string $select_sql Final SELECT MySQL statement portion for legacy query.
529
+ * @param string $from_sql Final FROM MySQL statement portion for legacy query.
530
+ * @param string $where_sql Final WHERE MySQL statement portion for legacy query.
531
+ * @param string $sort Final sort direction for legacy query.
532
+ */
533
+ $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 ) );
534
  }
535
 
536
  } else {
 
537
  // Query first for activity IDs
538
  $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
539
 
543
  $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
544
  }
545
 
546
+ /**
547
+ * Filters the paged activities MySQL statement.
548
+ *
549
+ * @since BuddyPress (2.0.0)
550
+ *
551
+ * @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
552
+ * @param array $r Array of arguments passed into method.
553
+ */
554
  $activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
555
 
556
  $activity_ids = $wpdb->get_col( $activity_ids_sql );
575
  $activity_ids[] = $activity->id;
576
  }
577
 
578
+ if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
579
  bp_activity_update_meta_cache( $activity_ids );
580
  }
581
 
582
+ if ( $activities && $r['display_comments'] ) {
583
+ $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
584
+ }
585
 
586
  // Pre-fetch data associated with activity users and other objects
587
  BP_Activity_Activity::prefetch_object_data( $activities );
594
  // If $max is set, only return up to the max results
595
  if ( ! empty( $r['count_total'] ) ) {
596
 
597
+ /**
598
+ * Filters the total activities MySQL statement.
599
+ *
600
+ * @since BuddyPress (1.5.0)
601
+ *
602
+ * @param string MySQL statement used to query for total activities.
603
+ * @param string $where_sql MySQL WHERE statement portion.
604
+ * @param string $sort sort direction for query.
605
+ */
606
  $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 );
607
  $total_activities = $wpdb->get_var( $total_activities_sql );
608
 
609
+ if ( !empty( $r['max'] ) ) {
610
+ if ( (int) $total_activities > (int) $r['max'] )
611
+ $total_activities = $r['max'];
612
  }
613
 
614
  $retval['total'] = $total_activities;
729
  * @param array $activities Array of activities.
730
  */
731
  protected static function prefetch_object_data( $activities ) {
732
+
733
+ /**
734
+ * Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
735
+ *
736
+ * @since BuddyPress (2.0.0)
737
+ *
738
+ * @param array $activities Array of activities.
739
+ */
740
  return apply_filters( 'bp_activity_prefetch_object_data', $activities );
741
  }
742
 
833
  return $sql;
834
  }
835
 
836
+ /**
837
+ * Get the SQL for the 'scope' param in BP_Activity_Activity::get().
838
+ *
839
+ * A scope is a predetermined set of activity arguments. This method is used
840
+ * to grab these activity arguments and override any existing args if needed.
841
+ *
842
+ * Can handle multiple scopes.
843
+ *
844
+ * @since BuddyPress (2.2.0)
845
+ *
846
+ * @param string $scope The activity scope
847
+ * @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),
848
+ * but merged with defaults.
849
+ * @return array 'sql' WHERE SQL string and 'override' activity args
850
+ */
851
+ public static function get_scope_query_sql( $scope = '', $r = array() ) {
852
+ $query_args = array();
853
+ $override = array();
854
+ $retval = array();
855
+
856
+ if ( ! is_array( $scope ) ) {
857
+ $scopes = explode( ',', $scope );
858
+ } else {
859
+ $scopes = $scope;
860
+ }
861
+
862
+ if ( empty( $scopes ) ) {
863
+ return $sql;
864
+ }
865
+
866
+ // helper to easily grab the 'user_id'
867
+ if ( ! empty( $r['filter']['user_id'] ) ) {
868
+ $r['user_id'] = $r['filter']['user_id'];
869
+ }
870
+
871
+ // parse each scope; yes! we handle multiples!
872
+ foreach ( $scopes as $scope ) {
873
+ $scope_args = array();
874
+
875
+ /**
876
+ * Plugins can hook here to set their activity arguments for custom scopes.
877
+ *
878
+ * This is a dynamic filter based on the activity scope. eg:
879
+ * - 'bp_activity_set_groups_scope_args'
880
+ * - 'bp_activity_set_friends_scope_args'
881
+ *
882
+ * To see how this filter is used, plugin devs should check out:
883
+ * - bp_groups_filter_activity_scope() - used for 'groups' scope
884
+ * - bp_friends_filter_activity_scope() - used for 'friends' scope
885
+ *
886
+ * @since BuddyPress (2.2.0)
887
+ *
888
+ * @param array {
889
+ * Activity query clauses.
890
+ *
891
+ * @type array {
892
+ * Activity arguments for your custom scope.
893
+ * See {@link BP_Activity_Query::_construct()} for more details.
894
+ * }
895
+ * @type array $override Optional. Override existing activity arguments passed by $r.
896
+ * }
897
+ * @param array $r Current activity arguments passed in BP_Activity_Activity::get()
898
+ */
899
+ $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r );
900
+
901
+ if ( ! empty( $scope_args ) ) {
902
+ // merge override properties from other scopes
903
+ // this might be a problem...
904
+ if ( ! empty( $scope_args['override'] ) ) {
905
+ $override = array_merge( $override, $scope_args['override'] );
906
+ unset( $scope_args['override'] );
907
+ }
908
+
909
+ // save scope args
910
+ if ( ! empty( $scope_args ) ) {
911
+ $query_args[] = $scope_args;
912
+ }
913
+ }
914
+ }
915
+
916
+ if ( ! empty( $query_args ) ) {
917
+ // set relation to OR
918
+ $query_args['relation'] = 'OR';
919
+
920
+ $query = new BP_Activity_Query( $query_args );
921
+ if ( $sql = $query->get_sql() ) {
922
+ $retval['sql'] = $sql;
923
+ }
924
+ }
925
+
926
+ if ( ! empty( $override ) ) {
927
+ $retval['override'] = $override;
928
+ }
929
+
930
+ return $retval;
931
+ }
932
+
933
  /**
934
  * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
935
  *
1224
  $comments = false;
1225
 
1226
  // A true cache miss
1227
+ } elseif ( empty( $comments ) ) {
1228
 
1229
  // Select the user's fullname with the query
1230
  if ( bp_is_active( 'xprofile' ) ) {
1248
 
1249
  // Legacy query - not recommended
1250
  $func_args = func_get_args();
1251
+
1252
+ /**
1253
+ * Filters if BuddyPress should use the legacy activity query.
1254
+ *
1255
+ * @since BuddyPress (2.0.0)
1256
+ *
1257
+ * @param bool Whether or not to use the legacy query.
1258
+ * @param BP_Activity_Activity Magic method referring to currently called method.
1259
+ * @param array $func_args Array of the method's argument list.
1260
+ */
1261
  if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $func_args ) ) {
1262
+
1263
+ /**
1264
+ * Filters the MySQL prepared statement for the legacy activity query.
1265
+ *
1266
+ * @since BuddyPress (1.5.0)
1267
+ *
1268
+ * @param string Prepared statement for the activity query.
1269
+ * @param int $activity_id Activity ID to fetch comments for.
1270
+ * @param int $left Left-most node boundary.
1271
+ * @param int $right Right-most node boundary.
1272
+ * @param string $spam_sql SQL Statement portion to differentiate between ham or spam.
1273
+ */
1274
  $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 );
1275
 
1276
  $descendants = $wpdb->get_results( $sql );
1355
  * @global BuddyPress $bp The one true BuddyPress instance.
1356
  * @global wpdb $wpdb WordPress database object.
1357
  *
1358
+ * @param int $parent_id ID of an activity or activity comment.
1359
  * @param int $left Node boundary start for activity or activity comment.
1360
  * @return int Right node boundary of activity or activity comment.
1361
  */
1391
  * @global BuddyPress $bp The one true BuddyPress instance.
1392
  * @global wpdb $wpdb WordPress database object.
1393
  *
1394
+ * @param int $parent_id ID of an activity or activity comment.
1395
  * @return object Numerically indexed array of child comments.
1396
  */
1397
  public static function get_child_comments( $parent_id ) {
1608
 
1609
  return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
1610
  }
1611
+
1612
+ /**
1613
+ * PHP-agnostic version of {@link array_replace_recursive()}.
1614
+ *
1615
+ * array_replace_recursive() is a PHP 5.3 function. BuddyPress (and
1616
+ * WordPress) currently supports down to PHP 5.2, so this method is a workaround
1617
+ * for PHP 5.2.
1618
+ *
1619
+ * Note: array_replace_recursive() supports infinite arguments, but for our use-
1620
+ * case, we only need to support two arguments.
1621
+ *
1622
+ * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
1623
+ *
1624
+ * @since BuddyPress (2.2.0)
1625
+ *
1626
+ * @see http://php.net/manual/en/function.array-replace-recursive.php#109390
1627
+ *
1628
+ * @param array $base Array with keys needing to be replaced
1629
+ * @param array $replacements Array with the replaced keys
1630
+ * @return array
1631
+ */
1632
+ protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
1633
+ if ( function_exists( 'array_replace_recursive' ) ) {
1634
+ return array_replace_recursive( $base, $replacements );
1635
+ }
1636
+
1637
+ // PHP 5.2-compatible version
1638
+ // http://php.net/manual/en/function.array-replace-recursive.php#109390
1639
+ foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
1640
+ $bref_stack = array( &$base );
1641
+ $head_stack = array( $replacements );
1642
+
1643
+ do {
1644
+ end( $bref_stack );
1645
+
1646
+ $bref = &$bref_stack[ key( $bref_stack ) ];
1647
+ $head = array_pop( $head_stack );
1648
+
1649
+ unset( $bref_stack[ key($bref_stack) ] );
1650
+
1651
+ foreach ( array_keys( $head ) as $key ) {
1652
+ if ( isset( $key, $bref ) && is_array( $bref[$key] ) && is_array( $head[$key] ) ) {
1653
+ $bref_stack[] = &$bref[ $key ];
1654
+ $head_stack[] = $head[ $key ];
1655
+ } else {
1656
+ $bref[ $key ] = $head[ $key ];
1657
+ }
1658
+ }
1659
+ } while( count( $head_stack ) );
1660
+ }
1661
+
1662
+ return $base;
1663
+ }
1664
+ }
1665
+
1666
+ /**
1667
+ * Class for generating the WHERE SQL clause for advanced activity fetching.
1668
+ *
1669
+ * This is notably used in {@link BP_Activity_Activity::get()} with the
1670
+ * 'filter_query' parameter.
1671
+ *
1672
+ * @since BuddyPress (2.2.0)
1673
+ */
1674
+ class BP_Activity_Query extends BP_Recursive_Query {
1675
+ /**
1676
+ * Array of activity queries.
1677
+ *
1678
+ * See {@see BP_Activity_Query::__construct()} for information on query arguments.
1679
+ *
1680
+ * @since BuddyPress (2.2.0)
1681
+ * @access public
1682
+ * @var array
1683
+ */
1684
+ public $queries = array();
1685
+
1686
+ /**
1687
+ * Table alias.
1688
+ *
1689
+ * @since BuddyPress (2.2.0)
1690
+ * @access public
1691
+ * @var string
1692
+ */
1693
+ public $table_alias = '';
1694
+
1695
+ /**
1696
+ * Supported DB columns.
1697
+ *
1698
+ * See the 'wp_bp_activity' DB table schema.
1699
+ *
1700
+ * @since BuddyPress (2.2.0)
1701
+ * @access public
1702
+ * @var array
1703
+ */
1704
+ public $db_columns = array(
1705
+ 'id', 'user_id', 'component', 'type', 'action', 'content',
1706
+ 'item_id', 'secondary_item_id', 'hide_sitewide', 'is_spam',
1707
+ );
1708
+
1709
+ /**
1710
+ * Constructor.
1711
+ *
1712
+ * @since BuddyPress (2.2.0)
1713
+ *
1714
+ * @param array $query {
1715
+ * Array of query clauses.
1716
+ *
1717
+ * @type array {
1718
+ * @type string $column Required. The column to query against. Basically, any DB column in the main
1719
+ * 'wp_bp_activity' table.
1720
+ * @type string $value Required. Value to filter by.
1721
+ * @type string $compare Optional. The comparison operator. Default '='.
1722
+ * Accepts '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'LIKE',
1723
+ * 'NOT LIKE', BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', 'RLIKE'
1724
+ * @type string $relation Optional. The boolean relationship between the activity queries.
1725
+ * Accepts 'OR', 'AND'. Default 'AND'.
1726
+ * @type array {
1727
+ * Optional. Another fully-formed activity query. See parameters above.
1728
+ * }
1729
+ * }
1730
+ * }
1731
+ */
1732
+ public function __construct( $query = array() ) {
1733
+ if ( ! is_array( $query ) ) {
1734
+ return;
1735
+ }
1736
+
1737
+ $this->queries = $this->sanitize_query( $query );
1738
+ }
1739
+
1740
+ /**
1741
+ * Generates WHERE SQL clause to be appended to a main query.
1742
+ *
1743
+ * @since BuddyPress (2.2.0)
1744
+ * @access public
1745
+ *
1746
+ * @param string $alias An existing table alias that is compatible with the current query clause.
1747
+ * Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
1748
+ * @return string SQL fragment to append to the main WHERE clause.
1749
+ */
1750
+ public function get_sql( $alias = 'a' ) {
1751
+ if ( ! empty( $alias ) ) {
1752
+ $this->table_alias = sanitize_title( $alias );
1753
+ }
1754
+
1755
+ $sql = $this->get_sql_clauses();
1756
+
1757
+ // we only need the 'where' clause
1758
+ //
1759
+ // also trim trailing "AND" clause from parent BP_Recursive_Query class
1760
+ // since it's not necessary for our needs
1761
+ return preg_replace( '/^\sAND/', '', $sql['where'] );
1762
+ }
1763
+
1764
+ /**
1765
+ * Generate WHERE clauses for a first-order clause.
1766
+ *
1767
+ * @since BuddyPress (2.2.0)
1768
+ * @access protected
1769
+ *
1770
+ * @param array $clause Array of arguments belonging to the clause.
1771
+ * @param array $parent_query Parent query to which the clause belongs.
1772
+ * @return array {
1773
+ * @type array $where Array of subclauses for the WHERE statement.
1774
+ * @type array $join Empty array. Not used.
1775
+ * }
1776
+ */
1777
+ protected function get_sql_for_clause( $clause, $parent_query ) {
1778
+ global $wpdb;
1779
+
1780
+ $sql_chunks = array(
1781
+ 'where' => array(),
1782
+ 'join' => array(),
1783
+ );
1784
+
1785
+ $column = isset( $clause['column'] ) ? $this->validate_column( $clause['column'] ) : '';
1786
+ $value = isset( $clause['value'] ) ? $clause['value'] : '';
1787
+ if ( empty( $column ) || ! isset( $clause['value'] ) ) {
1788
+ return $sql_chunks;
1789
+ }
1790
+
1791
+ if ( isset( $clause['compare'] ) ) {
1792
+ $clause['compare'] = strtoupper( $clause['compare'] );
1793
+ } else {
1794
+ $clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
1795
+ }
1796
+
1797
+ // default 'compare' to '=' if no valid operator is found
1798
+ if ( ! in_array( $clause['compare'], array(
1799
+ '=', '!=', '>', '>=', '<', '<=',
1800
+ 'LIKE', 'NOT LIKE',
1801
+ 'IN', 'NOT IN',
1802
+ 'BETWEEN', 'NOT BETWEEN',
1803
+ 'REGEXP', 'NOT REGEXP', 'RLIKE'
1804
+ ) ) ) {
1805
+ $clause['compare'] = '=';
1806
+ }
1807
+
1808
+ $compare = $clause['compare'];
1809
+
1810
+ $alias = ! empty( $this->table_alias ) ? "{$this->table_alias}." : '';
1811
+
1812
+ // Next, Build the WHERE clause.
1813
+ $where = '';
1814
+
1815
+ // value.
1816
+ if ( isset( $clause['value'] ) ) {
1817
+ if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
1818
+ if ( ! is_array( $value ) ) {
1819
+ $value = preg_split( '/[,\s]+/', $value );
1820
+ }
1821
+ }
1822
+
1823
+ // tinyint
1824
+ if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
1825
+ $sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
1826
+
1827
+ } else {
1828
+ switch ( $compare ) {
1829
+ // IN uses different syntax
1830
+ case 'IN' :
1831
+ case 'NOT IN' :
1832
+ $in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value );
1833
+
1834
+ // 'NOT IN' operator is as easy as a string replace!
1835
+ if ( 'NOT IN' === $compare ) {
1836
+ $in_sql = str_replace( 'IN', 'NOT IN', $in_sql );
1837
+ }
1838
+
1839
+ $sql_chunks['where'][] = $in_sql;
1840
+ break;
1841
+
1842
+ case 'BETWEEN' :
1843
+ case 'NOT BETWEEN' :
1844
+ $value = array_slice( $value, 0, 2 );
1845
+ $where = $wpdb->prepare( '%s AND %s', $value );
1846
+ break;
1847
+
1848
+ case 'LIKE' :
1849
+ case 'NOT LIKE' :
1850
+ $value = '%' . bp_esc_like( $value ) . '%';
1851
+ $where = $wpdb->prepare( '%s', $value );
1852
+ break;
1853
+
1854
+ default :
1855
+ $where = $wpdb->prepare( '%s', $value );
1856
+ break;
1857
+
1858
+ }
1859
+ }
1860
+
1861
+ if ( $where ) {
1862
+ $sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}";
1863
+ }
1864
+ }
1865
+
1866
+ /*
1867
+ * Multiple WHERE clauses should be joined in parentheses.
1868
+ */
1869
+ if ( 1 < count( $sql_chunks['where'] ) ) {
1870
+ $sql_chunks['where'] = array( '( ' . implode( ' AND ', $sql_chunks['where'] ) . ' )' );
1871
+ }
1872
+
1873
+ return $sql_chunks;
1874
+ }
1875
+
1876
+ /**
1877
+ * Determine whether a clause is first-order.
1878
+ *
1879
+ * @since BuddyPress (2.2.0)
1880
+ * @access protected
1881
+ *
1882
+ * @param array $q Clause to check.
1883
+ * @return bool
1884
+ */
1885
+ protected function is_first_order_clause( $query ) {
1886
+ return isset( $query['column'] ) || isset( $query['value'] );
1887
+ }
1888
+
1889
+ /**
1890
+ * Validates a column name parameter.
1891
+ *
1892
+ * Column names are checked against a whitelist of known tables.
1893
+ * See {@link BP_Activity_Query::db_tables}.
1894
+ *
1895
+ * @since BuddyPress (2.2.0)
1896
+ * @access public
1897
+ *
1898
+ * @param string $column The user-supplied column name.
1899
+ * @return string A validated column name value.
1900
+ */
1901
+ public function validate_column( $column = '' ) {
1902
+ if ( in_array( $column, $this->db_columns ) ) {
1903
+ return $column;
1904
+ } else {
1905
+ return '';
1906
+ }
1907
+ }
1908
  }
1909
 
1910
  /**
1963
  * @param array $args Optional
1964
  */
1965
  public function __construct( $args = array() ) {
1966
+
1967
+ /**
1968
+ * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
1969
+ *
1970
+ * @since BuddyPress (1.8.0)
1971
+ *
1972
+ * @param bool true Default true aka feeds are enabled.
1973
+ */
1974
  if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
1975
  global $wp_query;
1976
 
2016
  'activity_args' => array()
2017
  ) );
2018
 
2019
+ /**
2020
+ * Fires before the feed is setup so plugins can modify.
2021
+ *
2022
+ * @since BuddyPress (1.8.0)
2023
+ *
2024
+ * @param BP_Activity_Feed Reference to current instance of activity feed.
2025
+ */
2026
  do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
2027
 
2028
  // Setup class properties
2034
  return false;
2035
  }
2036
 
2037
+ /**
2038
+ * Fires after the feed is setup so plugins can modify.
2039
+ *
2040
+ * @since BuddyPress (1.8.0)
2041
+ *
2042
+ * @param BP_Activity_Feed Reference to current instance of activity feed.
2043
+ */
2044
  do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
2045
 
2046
  // Setup feed hooks
2097
  * Fire a hook to ensure backward compatibility for RSS attributes.
2098
  */
2099
  public function backpat_rss_attributes() {
2100
+
2101
+ /**
2102
+ * Fires inside backpat_rss_attributes method for backwards compatibility related to RSS attributes.
2103
+ *
2104
+ * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2105
+ *
2106
+ * @since BuddyPress (1.0.0)
2107
+ */
2108
  do_action( 'bp_activity_' . $this->id . '_feed' );
2109
  }
2110
 
2112
  * Fire a hook to ensure backward compatibility for channel elements.
2113
  */
2114
  public function backpat_channel_elements() {
2115
+
2116
+ /**
2117
+ * Fires inside backpat_channel_elements method for backwards compatibility related to RSS channel elements.
2118
+ *
2119
+ * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2120
+ *
2121
+ * @since BuddyPress (1.0.0)
2122
+ */
2123
  do_action( 'bp_activity_' . $this->id . '_feed_head' );
2124
  }
2125
 
2142
  break;
2143
  }
2144
 
2145
+ /**
2146
+ * Fires inside backpat_item_elements method for backwards compatibility related to RSS item elements.
2147
+ *
2148
+ * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2149
+ *
2150
+ * @since BuddyPress (1.0.0)
2151
+ */
2152
  do_action( 'bp_activity_' . $id . '_feed_item' );
2153
  }
2154
 
2202
 
2203
  // Set content-type
2204
  @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
2205
+ send_nosniff_header();
2206
 
2207
  // Cache-related variables
2208
  $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
2275
  xmlns:atom="http://www.w3.org/2005/Atom"
2276
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
2277
  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
2278
+ <?php
2279
+
2280
+ /**
2281
+ * Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
2282
+ *
2283
+ * @since BuddyPress (1.8.0)
2284
+ */
2285
+ do_action( 'bp_activity_feed_rss_attributes' ); ?>
2286
  >
2287
 
2288
  <channel>
2296
  <ttl><?php echo $this->ttl; ?></ttl>
2297
  <sy:updatePeriod><?php echo $this->update_period; ?></sy:updatePeriod>
2298
  <sy:updateFrequency><?php echo $this->update_frequency; ?></sy:updateFrequency>
2299
+ <?php
2300
+
2301
+ /**
2302
+ * Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
2303
+ *
2304
+ * @since BuddyPress (1.8.0)
2305
+ */
2306
+ do_action( 'bp_activity_feed_channel_elements' ); ?>
2307
 
2308
  <?php if ( bp_has_activities( $this->activity_args ) ) : ?>
2309
  <?php while ( bp_activities() ) : bp_the_activity(); ?>
2321
  <slash:comments><?php bp_activity_comment_count(); ?></slash:comments>
2322
  <?php endif; ?>
2323
 
2324
+ <?php
2325
+
2326
+ /**
2327
+ * Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
2328
+ *
2329
+ * @since BuddyPress (1.8.0)
2330
+ */
2331
+ do_action( 'bp_activity_feed_item_elements' ); ?>
2332
  </item>
2333
  <?php endwhile; ?>
2334
 
bp-activity/bp-activity-cssjs.php CHANGED
@@ -41,8 +41,15 @@ function bp_activity_mentions_script() {
41
  wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
42
  }
43
 
44
- // Print a list of the current user's friends to the page for quicker @mentions lookups.
 
 
 
 
 
 
 
45
  do_action( 'bp_activity_mentions_prime_results' );
46
  }
47
  add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' );
48
- add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
41
  wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
42
  }
43
 
44
+ /**
45
+ * Fires at the end of the Activity Mentions script.
46
+ *
47
+ * This is the hook where BP components can add their own prefetched results
48
+ * friends to the page for quicker @mentions lookups.
49
+ *
50
+ * @since BuddyPress (2.1.0)
51
+ */
52
  do_action( 'bp_activity_mentions_prime_results' );
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
@@ -113,7 +113,7 @@ add_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1
113
  /**
114
  * Types of activity stream items to moderate.
115
  *
116
- * @since BuddyPress (1.6)
117
  *
118
  * @return array $types List of the activity types to moderate.
119
  */
@@ -122,13 +122,21 @@ function bp_activity_get_moderated_activity_types() {
122
  'activity_comment',
123
  'activity_update'
124
  );
 
 
 
 
 
 
 
 
125
  return apply_filters( 'bp_activity_check_activity_types', $types );
126
  }
127
 
128
  /**
129
  * Moderate the posted activity item, if it contains moderate keywords.
130
  *
131
- * @since BuddyPress (1.6)
132
  *
133
  * @param BP_Activity_Activity $activity The activity object to check.
134
  */
@@ -147,7 +155,7 @@ function bp_activity_check_moderation_keys( $activity ) {
147
  /**
148
  * Mark the posted activity as spam, if it contains blacklist keywords.
149
  *
150
- * @since BuddyPress (1.6)
151
  *
152
  * @param BP_Activity_Activity $activity The activity object to check.
153
  */
@@ -165,7 +173,7 @@ function bp_activity_check_blacklist_keys( $activity ) {
165
  /**
166
  * Custom kses filtering for activity content.
167
  *
168
- * @since BuddyPress (1.1)
169
  *
170
  * @uses apply_filters() To call the 'bp_activity_allowed_tags' hook.
171
  * @uses wp_kses()
@@ -177,11 +185,13 @@ function bp_activity_filter_kses( $content ) {
177
  global $allowedtags;
178
 
179
  $activity_allowedtags = $allowedtags;
180
- $activity_allowedtags['span'] = array();
181
- $activity_allowedtags['span']['class'] = array();
182
  $activity_allowedtags['a']['class'] = array();
183
  $activity_allowedtags['a']['id'] = array();
184
  $activity_allowedtags['a']['rel'] = array();
 
 
 
 
185
  $activity_allowedtags['img'] = array();
186
  $activity_allowedtags['img']['src'] = array();
187
  $activity_allowedtags['img']['alt'] = array();
@@ -190,8 +200,17 @@ function bp_activity_filter_kses( $content ) {
190
  $activity_allowedtags['img']['class'] = array();
191
  $activity_allowedtags['img']['id'] = array();
192
  $activity_allowedtags['img']['title'] = array();
193
- $activity_allowedtags['code'] = array();
 
 
194
 
 
 
 
 
 
 
 
195
  $activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
196
  return wp_kses( $content, $activity_allowedtags );
197
  }
@@ -257,7 +276,7 @@ function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
257
  * If mentions are found, replace @mention text with user links and add our
258
  * hook to send mention notifications after the activity item is saved.
259
  *
260
- * @since BuddyPress (1.5)
261
  *
262
  * @uses bp_activity_find_mentions()
263
  *
@@ -294,7 +313,7 @@ function bp_activity_at_name_filter_updates( $activity ) {
294
  /**
295
  * Sends emails and BP notifications for users @-mentioned in an activity item.
296
  *
297
- * @since BuddyPress (1.7)
298
  *
299
  * @uses bp_activity_at_message_notification()
300
  * @uses bp_activity_update_mention_count_for_user()
@@ -319,7 +338,14 @@ function bp_activity_at_name_send_emails( $activity ) {
319
 
320
  // Send @mentions and setup BP notifications
321
  foreach( (array) $usernames as $user_id => $username ) {
322
- // If you want to disable notifications, you can use this filter to stop email sending
 
 
 
 
 
 
 
323
  if ( apply_filters( 'bp_activity_at_name_do_notifications', true, $usernames ) ) {
324
  bp_activity_at_message_notification( $activity->id, $user_id );
325
  }
@@ -332,7 +358,7 @@ function bp_activity_at_name_send_emails( $activity ) {
332
  /**
333
  * Catch links in activity text so rel=nofollow can be added.
334
  *
335
- * @since BuddyPress (1.2)
336
  *
337
  * @param string $text Activity text.
338
  * @return string $text Text with rel=nofollow added to any links.
@@ -344,7 +370,7 @@ function bp_activity_make_nofollow_filter( $text ) {
344
  /**
345
  * Add rel=nofollow to a link.
346
  *
347
- * @since BuddyPress (1.2)
348
  *
349
  * @param array $matches
350
  *
@@ -360,7 +386,7 @@ function bp_activity_make_nofollow_filter( $text ) {
360
  /**
361
  * Truncate long activity entries when viewed in activity streams.
362
  *
363
- * @since BuddyPress (1.5)
364
  *
365
  * @uses bp_is_single_activity()
366
  * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook.
@@ -380,7 +406,22 @@ function bp_activity_truncate_entry( $text ) {
380
  if ( bp_is_single_activity() )
381
  return $text;
382
 
 
 
 
 
 
 
 
383
  $append_text = apply_filters( 'bp_activity_excerpt_append_text', __( '[Read more]', 'buddypress' ) );
 
 
 
 
 
 
 
 
384
  $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
385
 
386
  // Run the text through the excerpt function. If it's too short, the original text will be
@@ -396,6 +437,15 @@ function bp_activity_truncate_entry( $text ) {
396
  $excerpt = sprintf( '%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text );
397
  }
398
 
 
 
 
 
 
 
 
 
 
399
  return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text );
400
  }
401
 
@@ -478,8 +528,6 @@ add_filter( 'bp_get_activity_css_class', 'bp_activity_timestamp_class', 9, 1 );
478
  * @return array $response
479
  */
480
  function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) {
481
- $bp = buddypress();
482
-
483
  if ( empty( $data['bp_activity_last_recorded'] ) ) {
484
  return $response;
485
  }
@@ -499,7 +547,7 @@ function bp_activity_heartbeat_last_recorded( $response = array(), $data = array
499
  $newest_activities = array();
500
  $last_activity_recorded = 0;
501
 
502
- // Temporarly add a just-posted class for new activity items
503
  add_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
504
 
505
  ob_start();
@@ -548,14 +596,26 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
548
 
549
  $global_pulse = 0;
550
 
551
- // Check whether the global heartbeat settings already exist.
 
 
 
 
 
 
552
  $heartbeat_settings = apply_filters( 'heartbeat_settings', array() );
553
  if ( ! empty( $heartbeat_settings['interval'] ) ) {
554
  // 'Fast' is 5
555
  $global_pulse = is_numeric( $heartbeat_settings['interval'] ) ? absint( $heartbeat_settings['interval'] ) : 5;
556
  }
557
 
558
- // Filter here to specify a BP-specific pulse frequency
 
 
 
 
 
 
559
  $bp_activity_pulse = apply_filters( 'bp_activity_heartbeat_pulse', 15 );
560
 
561
  /**
@@ -578,3 +638,93 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
578
  return $strings;
579
  }
580
  add_filter( 'bp_core_get_js_strings', 'bp_activity_heartbeat_strings', 10, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  /**
114
  * Types of activity stream items to moderate.
115
  *
116
+ * @since BuddyPress (1.6.0)
117
  *
118
  * @return array $types List of the activity types to moderate.
119
  */
122
  'activity_comment',
123
  'activity_update'
124
  );
125
+
126
+ /**
127
+ * Filters the default activity types that BuddyPress should moderate.
128
+ *
129
+ * @since BuddyPress (1.6.0)
130
+ *
131
+ * @param array $types Default activity types to moderate.
132
+ */
133
  return apply_filters( 'bp_activity_check_activity_types', $types );
134
  }
135
 
136
  /**
137
  * Moderate the posted activity item, if it contains moderate keywords.
138
  *
139
+ * @since BuddyPress (1.6.0)
140
  *
141
  * @param BP_Activity_Activity $activity The activity object to check.
142
  */
155
  /**
156
  * Mark the posted activity as spam, if it contains blacklist keywords.
157
  *
158
+ * @since BuddyPress (1.6.0)
159
  *
160
  * @param BP_Activity_Activity $activity The activity object to check.
161
  */
173
  /**
174
  * Custom kses filtering for activity content.
175
  *
176
+ * @since BuddyPress (1.1.0)
177
  *
178
  * @uses apply_filters() To call the 'bp_activity_allowed_tags' hook.
179
  * @uses wp_kses()
185
  global $allowedtags;
186
 
187
  $activity_allowedtags = $allowedtags;
 
 
188
  $activity_allowedtags['a']['class'] = array();
189
  $activity_allowedtags['a']['id'] = array();
190
  $activity_allowedtags['a']['rel'] = array();
191
+ $activity_allowedtags['a']['title'] = array();
192
+ $activity_allowedtags['b'] = array();
193
+ $activity_allowedtags['code'] = array();
194
+ $activity_allowedtags['i'] = array();
195
  $activity_allowedtags['img'] = array();
196
  $activity_allowedtags['img']['src'] = array();
197
  $activity_allowedtags['img']['alt'] = array();
200
  $activity_allowedtags['img']['class'] = array();
201
  $activity_allowedtags['img']['id'] = array();
202
  $activity_allowedtags['img']['title'] = array();
203
+ $activity_allowedtags['span'] = array();
204
+ $activity_allowedtags['span']['class'] = array();
205
+
206
 
207
+ /**
208
+ * Filters the allowed HTML tags for BuddyPress Activity 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 );
216
  }
276
  * If mentions are found, replace @mention text with user links and add our
277
  * hook to send mention notifications after the activity item is saved.
278
  *
279
+ * @since BuddyPress (1.5.0)
280
  *
281
  * @uses bp_activity_find_mentions()
282
  *
313
  /**
314
  * Sends emails and BP notifications for users @-mentioned in an activity item.
315
  *
316
+ * @since BuddyPress (1.7.0)
317
  *
318
  * @uses bp_activity_at_message_notification()
319
  * @uses bp_activity_update_mention_count_for_user()
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 ) ) {
350
  bp_activity_at_message_notification( $activity->id, $user_id );
351
  }
358
  /**
359
  * Catch links in activity text so rel=nofollow can be added.
360
  *
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.
370
  /**
371
  * Add rel=nofollow to a link.
372
  *
373
+ * @since BuddyPress (1.2.0)
374
  *
375
  * @param array $matches
376
  *
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()
392
  * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook.
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
+
418
+ /**
419
+ * Filters the excerpt length for the activity excerpt.
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
 
427
  // Run the text through the excerpt function. If it's too short, the original text will be
437
  $excerpt = sprintf( '%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text );
438
  }
439
 
440
+ /**
441
+ * Filters the composite activity excerpt entry.
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
 
528
  * @return array $response
529
  */
530
  function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) {
 
 
531
  if ( empty( $data['bp_activity_last_recorded'] ) ) {
532
  return $response;
533
  }
547
  $newest_activities = array();
548
  $last_activity_recorded = 0;
549
 
550
+ // Temporarily add a just-posted class for new activity items
551
  add_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
552
 
553
  ob_start();
596
 
597
  $global_pulse = 0;
598
 
599
+ /**
600
+ * Filter that checks whether the global heartbeat settings already exist.
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'] ) ) {
608
  // 'Fast' is 5
609
  $global_pulse = is_numeric( $heartbeat_settings['interval'] ) ? absint( $heartbeat_settings['interval'] ) : 5;
610
  }
611
 
612
+ /**
613
+ * Filters the pulse frequency to be used for the BuddyPress Activity heartbeat.
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
 
621
  /**
638
  return $strings;
639
  }
640
  add_filter( 'bp_core_get_js_strings', 'bp_activity_heartbeat_strings', 10, 1 );
641
+
642
+ /** SCOPES **************************************************************/
643
+
644
+ /**
645
+ * Set up activity arguments for use with the 'just-me' scope.
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, $filter ) {
654
+ $retval = array(
655
+ 'column' => 'user_id',
656
+ 'value' => $filter['user_id']
657
+ );
658
+
659
+ $retval['override']['display_comments'] = 'stream';
660
+
661
+ // wipe out the user ID
662
+ $retval['override']['filter']['user_id'] = 0;
663
+
664
+ return $retval;
665
+ }
666
+ add_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_scope', 10, 2 );
667
+
668
+ /**
669
+ * Set up activity arguments for use with the 'favorites' scope.
670
+ *
671
+ * @since BuddyPress (2.2.0)
672
+ *
673
+ * @param array $retval Empty array by default
674
+ * @param array $filter Current activity arguments
675
+ * @return array
676
+ */
677
+ function bp_activity_filter_favorites_scope( $retval, $filter ) {
678
+ $favs = bp_activity_get_user_favorites( $filter['user_id'] );
679
+ if ( empty( $favs ) ) {
680
+ return $retval;
681
+ }
682
+
683
+ $retval = array(
684
+ 'column' => 'id',
685
+ 'compare' => 'IN',
686
+ 'value' => (array) $favs
687
+ );
688
+ $retval['override']['display_comments'] = true;
689
+
690
+ // wipe out the user ID
691
+ $retval['override']['filter']['user_id'] = 0;
692
+
693
+ return $retval;
694
+ }
695
+ add_filter( 'bp_activity_set_favorites_scope_args', 'bp_activity_filter_favorites_scope', 10, 2 );
696
+
697
+
698
+ /**
699
+ * Set up activity arguments for use with the 'favorites' scope.
700
+ *
701
+ * @since BuddyPress (2.2.0)
702
+ *
703
+ * @param array $retval Empty array by default
704
+ * @param array $filter Current activity arguments
705
+ * @return array
706
+ */
707
+ function bp_activity_filter_mentions_scope( $retval, $filter ) {
708
+ // Are mentions disabled?
709
+ if ( ! bp_activity_do_mentions() ) {
710
+ return $retval;
711
+ }
712
+
713
+ $retval = array(
714
+ 'column' => 'content',
715
+ 'compare' => 'LIKE',
716
+
717
+ // Start search at @ symbol and stop search at closing tag delimiter.
718
+ 'value' => '@' . bp_activity_get_user_mentionname( $filter['user_id'] ) . '<'
719
+ );
720
+
721
+ // wipe out current search terms if any
722
+ // this is so the 'mentions' scope can be combined with other scopes
723
+ $retval['override']['search_terms'] = false;
724
+
725
+ $retval['override']['display_comments'] = 'stream';
726
+ $retval['override']['filter']['user_id'] = 0;
727
+
728
+ return $retval;
729
+ }
730
+ add_filter( 'bp_activity_set_mentions_scope_args', 'bp_activity_filter_mentions_scope', 10, 2 );
bp-activity/bp-activity-functions.php CHANGED
@@ -45,6 +45,14 @@ function bp_activity_has_directory() {
45
  * @return bool $retval True to enable mentions, false to disable.
46
  */
47
  function bp_activity_do_mentions() {
 
 
 
 
 
 
 
 
48
  return (bool) apply_filters( 'bp_activity_do_mentions', true );
49
  }
50
 
@@ -56,12 +64,18 @@ function bp_activity_do_mentions() {
56
  * @since BuddyPress (2.1.0)
57
  */
58
  function bp_activity_maybe_load_mentions_scripts() {
59
- $retval =
60
- bp_activity_do_mentions() &&
61
- bp_is_user_active() &&
62
- ( bp_is_activity_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin() );
63
 
64
- return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $retval );
 
 
 
 
 
 
 
 
65
  }
66
 
67
  /**
@@ -301,17 +315,17 @@ function bp_activity_get_userid_from_mentionname( $mentionname ) {
301
  *
302
  * @since BuddyPress (1.1.0)
303
  *
304
- * @param string $component_id The unique string ID of the component.
305
- * @param string $type The action type.
306
- * @param string $description The action description.
307
- * @param callable $format_callback Callback for formatting the action string.
308
- * @param string $label String to describe this action in the activity stream
309
- * filter dropdown.
310
- * @param array $context Activity stream contexts where the filter should appear.
311
- * 'activity', 'member', 'member_groups', 'group'
312
  * @return bool False if any param is empty, otherwise true.
313
  */
314
- function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array() ) {
315
  $bp = buddypress();
316
 
317
  // Return false if any of the above values are not set
@@ -333,19 +347,219 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
333
  $bp->activity->actions->{$component_id} = new stdClass;
334
  }
335
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  $bp->activity->actions->{$component_id}->{$type} = apply_filters( 'bp_activity_set_action', array(
337
  'key' => $type,
338
  'value' => $description,
339
  'format_callback' => $format_callback,
340
  'label' => $label,
341
  'context' => $context,
 
342
  ), $component_id, $type, $description, $format_callback, $label, $context );
343
 
344
  return true;
345
  }
346
 
347
  /**
348
- * Retreive the current action from a component and key.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  *
350
  * @since BuddyPress (1.1.0)
351
  *
@@ -362,11 +576,23 @@ function bp_activity_get_action( $component_id, $key ) {
362
  return false;
363
  }
364
 
365
- $bp = buddypress();
366
- $retval = isset( $bp->activity->actions->{$component_id}->{$key} )
367
- ? $bp->activity->actions->{$component_id}->{$key}
368
- : false;
 
 
 
369
 
 
 
 
 
 
 
 
 
 
370
  return apply_filters( 'bp_activity_get_action', $retval, $component_id, $key );
371
  }
372
 
@@ -381,7 +607,7 @@ function bp_activity_get_types() {
381
  $actions = array();
382
 
383
  // Walk through the registered actions, and build an array of actions/values.
384
- foreach ( buddypress()->activity->actions as $action ) {
385
  $action = array_values( (array) $action );
386
 
387
  for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
@@ -392,6 +618,13 @@ function bp_activity_get_types() {
392
  // This was a mis-named activity type from before BP 1.6
393
  unset( $actions['friends_register_activity_action'] );
394
 
 
 
 
 
 
 
 
395
  return apply_filters( 'bp_activity_get_types', $actions );
396
  }
397
 
@@ -418,6 +651,13 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
418
  // Get favorites for user
419
  $favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
420
 
 
 
 
 
 
 
 
421
  return apply_filters( 'bp_activity_get_user_favorites', $favs );
422
  }
423
 
@@ -473,7 +713,14 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
473
  // Update activity meta counts
474
  if ( bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ) ) {
475
 
476
- // Execute additional code
 
 
 
 
 
 
 
477
  do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
478
 
479
  // Success
@@ -481,7 +728,15 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
481
 
482
  // Saving meta was unsuccessful for an unknown reason
483
  } else {
484
- // Execute additional code
 
 
 
 
 
 
 
 
485
  do_action( 'bp_activity_add_user_favorite_fail', $activity_id, $user_id );
486
 
487
  return false;
@@ -538,7 +793,14 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
538
  // Update users favorites
539
  if ( bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs ) ) {
540
 
541
- // Execute additional code
 
 
 
 
 
 
 
542
  do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
543
 
544
  // Success
@@ -572,6 +834,14 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
572
  * @return int|null The ID of the located activity item. Null if none is found.
573
  */
574
  function bp_activity_check_exists_by_content( $content ) {
 
 
 
 
 
 
 
 
575
  return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
576
  }
577
 
@@ -586,6 +856,14 @@ function bp_activity_check_exists_by_content( $content ) {
586
  * @return string Date last updated.
587
  */
588
  function bp_activity_get_last_updated() {
 
 
 
 
 
 
 
 
589
  return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
590
  }
591
 
@@ -676,7 +954,16 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
676
  $retval = get_metadata( 'activity', $activity_id, $meta_key, $single );
677
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
678
 
679
- // Filter result before returning
 
 
 
 
 
 
 
 
 
680
  return apply_filters( 'bp_activity_get_meta', $retval, $activity_id, $meta_key, $single );
681
  }
682
 
@@ -757,7 +1044,13 @@ function bp_activity_remove_all_user_data( $user_id = 0 ) {
757
  // Execute additional code
758
  do_action( 'bp_activity_remove_data', $user_id ); // Deprecated! Do not use!
759
 
760
- // Use this going forward
 
 
 
 
 
 
761
  do_action( 'bp_activity_remove_all_user_data', $user_id );
762
  }
763
  add_action( 'wpmu_delete_user', 'bp_activity_remove_all_user_data' );
@@ -806,7 +1099,7 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
806
  * If Akismet is present, update the activity history meta.
807
  *
808
  * This is usually taken care of when BP_Activity_Activity::save() happens, but
809
- * as we're going to be updating all the activity statuses directly, for efficency,
810
  * we need to update manually.
811
  */
812
  if ( ! empty( $bp->activity->akismet ) ) {
@@ -820,7 +1113,14 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
820
  // Mark all of this user's activities as spam
821
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id ) );
822
 
823
- // Call an action for plugins to use
 
 
 
 
 
 
 
824
  do_action( 'bp_activity_spam_all_user_data', $user_id, $activities['activities'] );
825
  }
826
  add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
@@ -869,7 +1169,7 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
869
  * If Akismet is present, update the activity history meta.
870
  *
871
  * This is usually taken care of when BP_Activity_Activity::save() happens, but
872
- * as we're going to be updating all the activity statuses directly, for efficency,
873
  * we need to update manually.
874
  */
875
  if ( ! empty( $bp->activity->akismet ) ) {
@@ -880,10 +1180,17 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
880
  unset( $activity_obj );
881
  }
882
 
883
- // Mark all of this user's activities as spam
884
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 0 WHERE user_id = %d", $user_id ) );
885
 
886
- // Call an action for plugins to use
 
 
 
 
 
 
 
887
  do_action( 'bp_activity_ham_all_user_data', $user_id, $activities['activities'] );
888
  }
889
  add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
@@ -913,6 +1220,13 @@ function bp_activity_register_activity_actions() {
913
  __( 'Activity Comments', 'buddypress' )
914
  );
915
 
 
 
 
 
 
 
 
916
  do_action( 'bp_activity_register_activity_actions' );
917
 
918
  // Backpat. Don't use this.
@@ -942,7 +1256,14 @@ function bp_activity_generate_action_string( $activity ) {
942
  // We apply the format_callback as a filter
943
  add_filter( 'bp_activity_generate_action_string', buddypress()->activity->actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
944
 
945
- // Generate the action string (run through the filter defined above)
 
 
 
 
 
 
 
946
  $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
947
 
948
  // Remove the filter for future activity items
@@ -962,6 +1283,15 @@ function bp_activity_generate_action_string( $activity ) {
962
  */
963
  function bp_activity_format_activity_action_activity_update( $action, $activity ) {
964
  $action = sprintf( __( '%s posted an update', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
 
 
 
 
 
 
 
 
 
965
  return apply_filters( 'bp_activity_new_update_action', $action, $activity );
966
  }
967
 
@@ -976,9 +1306,75 @@ function bp_activity_format_activity_action_activity_update( $action, $activity
976
  */
977
  function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
978
  $action = sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
 
 
 
 
 
 
 
 
 
979
  return apply_filters( 'bp_activity_comment_action', $action, $activity );
980
  }
981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
982
  /******************************************************************************
983
  * Business functions are where all the magic happens in BuddyPress. They will
984
  * handle the actual saving or manipulation of information. Usually they will
@@ -1020,12 +1416,14 @@ function bp_activity_get( $args = '' ) {
1020
  'search_terms' => false, // Pass search terms as a string
1021
  'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format
1022
  'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format
 
1023
  'show_hidden' => false, // Show activity items that are hidden site-wide?
1024
  'exclude' => false, // Comma-separated list of activity IDs to exclude
1025
  'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query
1026
  'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
1027
  'update_meta_cache' => true,
1028
  'count_total' => false,
 
1029
 
1030
  /**
1031
  * Pass filters as an array -- all filter items can be multiple values comma separated:
@@ -1041,7 +1439,7 @@ function bp_activity_get( $args = '' ) {
1041
  ) );
1042
 
1043
  // Attempt to return a cached copy of the first page of sitewide activity.
1044
- if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
1045
 
1046
  $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
1047
  if ( false === $activity ) {
@@ -1054,7 +1452,9 @@ function bp_activity_get( $args = '' ) {
1054
  'search_terms' => $r['search_terms'],
1055
  'meta_query' => $r['meta_query'],
1056
  'date_query' => $r['date_query'],
 
1057
  'filter' => $r['filter'],
 
1058
  'display_comments' => $r['display_comments'],
1059
  'show_hidden' => $r['show_hidden'],
1060
  'spam' => $r['spam'],
@@ -1074,7 +1474,9 @@ function bp_activity_get( $args = '' ) {
1074
  'search_terms' => $r['search_terms'],
1075
  'meta_query' => $r['meta_query'],
1076
  'date_query' => $r['date_query'],
 
1077
  'filter' => $r['filter'],
 
1078
  'display_comments' => $r['display_comments'],
1079
  'show_hidden' => $r['show_hidden'],
1080
  'exclude' => $r['exclude'],
@@ -1084,6 +1486,14 @@ function bp_activity_get( $args = '' ) {
1084
  ) );
1085
  }
1086
 
 
 
 
 
 
 
 
 
1087
  return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
1088
  }
1089
 
@@ -1131,6 +1541,15 @@ function bp_activity_get_specific( $args = '' ) {
1131
  'update_meta_cache' => $r['update_meta_cache'],
1132
  );
1133
 
 
 
 
 
 
 
 
 
 
1134
  return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
1135
  }
1136
 
@@ -1233,6 +1652,14 @@ function bp_activity_add( $args = '' ) {
1233
  }
1234
 
1235
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
 
 
 
 
 
 
 
 
1236
  do_action( 'bp_activity_add', $r );
1237
 
1238
  return $activity->id;
@@ -1279,15 +1706,41 @@ function bp_activity_post_update( $args = '' ) {
1279
  $activity_content = $r['content'];
1280
  $primary_link = bp_core_get_userlink( $r['user_id'], false, true );
1281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1282
  // Now write the values
1283
  $activity_id = bp_activity_add( array(
1284
  'user_id' => $r['user_id'],
1285
- 'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
1286
- 'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
1287
  'component' => buddypress()->activity->id,
1288
  'type' => 'activity_update',
1289
  ) );
1290
 
 
 
 
 
 
 
 
 
1291
  $activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content );
1292
 
1293
  // Add this update to the "latest update" usermeta so it can be fetched anywhere.
@@ -1296,11 +1749,249 @@ function bp_activity_post_update( $args = '' ) {
1296
  'content' => $activity_content
1297
  ) );
1298
 
 
 
 
 
 
 
 
 
 
1299
  do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
1300
 
1301
  return $activity_id;
1302
  }
1303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1304
  /**
1305
  * Add an activity comment.
1306
  *
@@ -1311,7 +2002,6 @@ function bp_activity_post_update( $args = '' ) {
1311
  * @uses bp_activity_add()
1312
  * @uses apply_filters() To call the 'bp_activity_comment_action' hook.
1313
  * @uses apply_filters() To call the 'bp_activity_comment_content' hook.
1314
- * @uses bp_activity_new_comment_notification()
1315
  * @uses wp_cache_delete()
1316
  * @uses do_action() To call the 'bp_activity_comment_posted' hook.
1317
  *
@@ -1329,6 +2019,13 @@ function bp_activity_post_update( $args = '' ) {
1329
  * @return int|bool The ID of the comment on success, otherwise false.
1330
  */
1331
  function bp_activity_new_comment( $args = '' ) {
 
 
 
 
 
 
 
1332
 
1333
  $r = wp_parse_args( $args, array(
1334
  'id' => false,
@@ -1340,6 +2037,9 @@ function bp_activity_new_comment( $args = '' ) {
1340
 
1341
  // Bail if missing necessary data
1342
  if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
 
 
 
1343
  return false;
1344
  }
1345
 
@@ -1350,14 +2050,33 @@ function bp_activity_new_comment( $args = '' ) {
1350
 
1351
  $activity_id = $r['activity_id'];
1352
 
1353
- // Check to see if the parent activity is hidden, and if so, hide this comment publically.
1354
  $activity = new BP_Activity_Activity( $activity_id );
 
 
 
 
 
 
 
 
 
 
1355
  $is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
1356
 
 
 
 
 
 
 
 
 
 
1357
  // Insert the activity comment
1358
  $comment_id = bp_activity_add( array(
1359
  'id' => $r['id'],
1360
- 'content' => apply_filters( 'bp_activity_comment_content', $r['content'] ),
1361
  'component' => buddypress()->activity->id,
1362
  'type' => 'activity_comment',
1363
  'user_id' => $r['user_id'],
@@ -1378,8 +2097,22 @@ function bp_activity_new_comment( $args = '' ) {
1378
  }
1379
  wp_cache_delete( $activity_id, 'bp_activity' );
1380
 
 
 
 
 
 
 
 
 
 
1381
  do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity );
1382
 
 
 
 
 
 
1383
  return $comment_id;
1384
  }
1385
 
@@ -1409,6 +2142,13 @@ function bp_activity_get_activity_id( $args = '' ) {
1409
  'date_recorded' => false,
1410
  ) );
1411
 
 
 
 
 
 
 
 
1412
  return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
1413
  $r['user_id'],
1414
  $r['component'],
@@ -1470,6 +2210,13 @@ function bp_activity_delete( $args = '' ) {
1470
  'hide_sitewide' => false
1471
  ) );
1472
 
 
 
 
 
 
 
 
1473
  do_action( 'bp_before_activity_delete', $args );
1474
 
1475
  // Adjust the new mention count of any mentioned member
@@ -1492,7 +2239,22 @@ function bp_activity_delete( $args = '' ) {
1492
  }
1493
  }
1494
 
 
 
 
 
 
 
 
1495
  do_action( 'bp_activity_delete', $args );
 
 
 
 
 
 
 
 
1496
  do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
1497
 
1498
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
@@ -1506,7 +2268,7 @@ function bp_activity_delete( $args = '' ) {
1506
  * You should use bp_activity_delete() instead.
1507
  *
1508
  * @since BuddyPress (1.1.0)
1509
- * @deprecated BuddyPress (1.2)
1510
  *
1511
  * @uses wp_parse_args()
1512
  * @uses bp_activity_delete()
@@ -1549,7 +2311,7 @@ function bp_activity_delete( $args = '' ) {
1549
  * You should use bp_activity_delete() instead.
1550
  *
1551
  * @since BuddyPress (1.1.0)
1552
- * @deprecated BuddyPress (1.2)
1553
  *
1554
  * @uses bp_activity_delete()
1555
  *
@@ -1574,7 +2336,7 @@ function bp_activity_delete( $args = '' ) {
1574
  * You should use bp_activity_delete() instead.
1575
  *
1576
  * @since BuddyPress (1.1.0)
1577
- * @deprecated BuddyPress (1.2)
1578
  *
1579
  * @uses bp_activity_delete()
1580
  *
@@ -1610,9 +2372,18 @@ function bp_activity_delete( $args = '' ) {
1610
  * @return bool True on success, false on failure
1611
  */
1612
  function bp_activity_delete_comment( $activity_id, $comment_id ) {
1613
- /***
 
 
 
1614
  * You may want to hook into this filter if you want to override this function and
1615
  * handle the deletion of child comments differently. Make sure you return false.
 
 
 
 
 
 
1616
  */
1617
  if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
1618
  return false;
@@ -1632,6 +2403,14 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1632
  // Recalculate the comment tree
1633
  BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
1634
 
 
 
 
 
 
 
 
 
1635
  do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
1636
 
1637
  return true;
@@ -1661,7 +2440,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1661
  bp_activity_delete_children( $activity_id, $child->id );
1662
  }
1663
  }
1664
-
1665
  // Delete the comment itself
1666
  bp_activity_delete( array(
1667
  'secondary_item_id' => $comment_id,
@@ -1689,6 +2468,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1689
  * @return string $link Permalink for the activity item.
1690
  */
1691
  function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
 
1692
 
1693
  if ( empty( $activity_obj ) ) {
1694
  $activity_obj = new BP_Activity_Activity( $activity_id );
@@ -1698,7 +2478,18 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
1698
  $activity_obj = $activity_obj->current_comment;
1699
  }
1700
 
1701
- if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type ) {
 
 
 
 
 
 
 
 
 
 
 
1702
  $link = $activity_obj->primary_link;
1703
  } else {
1704
  if ( 'activity_comment' == $activity_obj->type ) {
@@ -1708,6 +2499,13 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
1708
  }
1709
  }
1710
 
 
 
 
 
 
 
 
1711
  return apply_filters_ref_array( 'bp_activity_get_permalink', array( $link, &$activity_obj ) );
1712
  }
1713
 
@@ -1787,6 +2585,15 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
1787
  }
1788
  }
1789
 
 
 
 
 
 
 
 
 
 
1790
  return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches, $args );
1791
  }
1792
 
@@ -1798,6 +2605,14 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
1798
  * @return bool True if user is allowed to mark activity items as spam.
1799
  */
1800
  function bp_activity_user_can_mark_spam() {
 
 
 
 
 
 
 
 
1801
  return apply_filters( 'bp_activity_user_can_mark_spam', bp_current_user_can( 'bp_moderate' ) );
1802
  }
1803
 
@@ -1836,6 +2651,15 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
1836
  add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_spam_meta' ), 1, 1 );
1837
  }
1838
 
 
 
 
 
 
 
 
 
 
1839
  do_action( 'bp_activity_mark_as_spam', $activity, $source );
1840
  }
1841
 
@@ -1874,6 +2698,15 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
1874
  add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_ham_meta' ), 1, 1 );
1875
  }
1876
 
 
 
 
 
 
 
 
 
 
1877
  do_action( 'bp_activity_mark_as_ham', $activity, $source );
1878
  }
1879
 
@@ -2013,7 +2846,7 @@ function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
2013
  *
2014
  * @since BuddyPress (2.0.0)
2015
  *
2016
- * @uses bp_is_activity_heartbeat_active() to check if heatbeat setting is on.
2017
  * @uses bp_is_activity_directory() to check if the current page is the activity
2018
  * directory.
2019
  * @uses bp_is_active() to check if the group component is active.
45
  * @return bool $retval True to enable mentions, false to disable.
46
  */
47
  function bp_activity_do_mentions() {
48
+
49
+ /**
50
+ * Filters whether or not mentions are enabled.
51
+ *
52
+ * @since BuddyPress (1.8.0)
53
+ *
54
+ * @param bool $enabled True to enable mentions, false to disable.
55
+ */
56
  return (bool) apply_filters( 'bp_activity_do_mentions', true );
57
  }
58
 
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();
68
+ $load_mentions = $mentions_enabled && ( bp_is_activity_component() || is_admin() );
 
 
69
 
70
+ /**
71
+ * Filters whether or not BuddyPress should load mentions scripts and assets.
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 );
79
  }
80
 
81
  /**
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 ) {
329
  $bp = buddypress();
330
 
331
  // Return false if any of the above values are not set
347
  $bp->activity->actions->{$component_id} = new stdClass;
348
  }
349
 
350
+ /**
351
+ * Filters the action type being set for the current activity item.
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,
366
  'value' => $description,
367
  'format_callback' => $format_callback,
368
  'label' => $label,
369
  'context' => $context,
370
+ 'position' => $position,
371
  ), $component_id, $type, $description, $format_callback, $label, $context );
372
 
373
  return true;
374
  }
375
 
376
  /**
377
+ * Set tracking arguments for a given post type.
378
+ *
379
+ * @since BuddyPress (2.2.0)
380
+ *
381
+ * @global $wp_post_types
382
+ *
383
+ * @param string $post_type The name of the post type, as registered with WordPress. Eg 'post' or 'page'.
384
+ * @param array $args {
385
+ * An associative array of tracking parameters. All items are optional.
386
+ *
387
+ * @type string $bp_activity_admin_filter String to use in the Dashboard > Activity dropdown.
388
+ * @type string $bp_activity_front_filter String to use in frontend dropdown.
389
+ * @type string $bp_activity_new_post String format to use for generating the activity action. Should be a
390
+ * translatable string where %1$s is replaced by a user link and %2$s is
391
+ * the URL of the newly created post.
392
+ * @type string $bp_activity_new_post_ms String format to use for generating the activity action on Multisite.
393
+ * Should be a translatable string where %1$s is replaced by a user link,
394
+ * %2$s is the URL of the newly created post, and %3$s is a link to
395
+ * the site.
396
+ * @type string $component_id ID of the BuddyPress component to associate the activity item.
397
+ * @type string $action_id Value for the 'type' param of the new activity item.
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;
415
+ }
416
+
417
+ // Labels are loaded into the post type object.
418
+ foreach ( array( 'bp_activity_admin_filter', 'bp_activity_front_filter', 'bp_activity_new_post', 'bp_activity_new_post_ms' ) as $label_type ) {
419
+ if ( ! empty( $args[ $label_type ] ) ) {
420
+ $wp_post_types[ $post_type ]->labels->{$label_type} = $args[ $label_type ];
421
+ unset( $args[ $post_type ] );
422
+ }
423
+ }
424
+
425
+ // If there are any additional args, put them in the bp_activity attribute of the post type.
426
+ if ( ! empty( $args ) ) {
427
+ $wp_post_types[ $post_type ]->bp_activity = $args;
428
+ }
429
+ }
430
+
431
+ /**
432
+ * Get tracking arguments for a specific post type.
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 ) {
440
+ if ( ! post_type_supports( $post_type, 'buddypress-activity' ) ) {
441
+ return false;
442
+ }
443
+
444
+ $post_type_object = get_post_type_object( $post_type );
445
+
446
+ $post_type_activity = array(
447
+ 'component_id' => buddypress()->activity->id,
448
+ 'action_id' => 'new_' . $post_type,
449
+ 'format_callback' => 'bp_activity_format_activity_action_custom_post_type_post',
450
+ 'front_filter' => $post_type_object->labels->name,
451
+ 'contexts' => array( 'activity' ),
452
+ 'position' => 0,
453
+ 'singular' => strtolower( $post_type_object->labels->singular_name ),
454
+ 'activity_comment' => ! post_type_supports( $post_type, 'comments' ),
455
+ );
456
+
457
+ if ( ! empty( $post_type_object->bp_activity ) ) {
458
+ $post_type_activity = bp_parse_args( (array) $post_type_object->bp_activity, $post_type_activity, $post_type . '_tracking_args' );
459
+ }
460
+
461
+ $post_type_activity = (object) $post_type_activity;
462
+
463
+ // Try to get the admin filter from the post type labels.
464
+ if ( ! empty( $post_type_object->labels->bp_activity_admin_filter ) ) {
465
+ $post_type_activity->admin_filter = $post_type_object->labels->bp_activity_admin_filter;
466
+
467
+ // Fall back to a generic name.
468
+ } else {
469
+ $post_type_activity->admin_filter = _x( 'New item published', 'Post Type generic activity post admin filter', 'buddypress' );
470
+ }
471
+
472
+ // Check for the front filter in the post type labels.
473
+ if ( ! empty( $post_type_object->labels->bp_activity_front_filter ) ) {
474
+ $post_type_activity->front_filter = $post_type_object->labels->bp_activity_front_filter;
475
+ }
476
+
477
+ // Try to get the action for new post type action on non-multisite installations.
478
+ if ( ! empty( $post_type_object->labels->bp_activity_new_post ) ) {
479
+ $post_type_activity->new_post_type_action = $post_type_object->labels->bp_activity_new_post;
480
+ }
481
+
482
+ // Try to get the action for new post type action on multisite installations.
483
+ if ( ! empty( $post_type_object->labels->bp_activity_new_post_ms ) ) {
484
+ $post_type_activity->new_post_type_action_ms = $post_type_object->labels->bp_activity_new_post_ms;
485
+ }
486
+
487
+ return apply_filters( 'bp_activity_get_post_type_tracking_args', $post_type_activity, $post_type );
488
+ }
489
+
490
+ /**
491
+ * Get tracking arguments for all post types.
492
+ *
493
+ * @since BuddyPress (2.2.0)
494
+ *
495
+ * @return array List of post types with their tracking arguments.
496
+ */
497
+ function bp_activity_get_post_types_tracking_args() {
498
+ // Fetch all public post types
499
+ $post_types = get_post_types( array( 'public' => true ), 'names' );
500
+
501
+ $post_types_tracking_args = array();
502
+
503
+ foreach ( $post_types as $post_type ) {
504
+ $track_post_type = bp_activity_get_post_type_tracking_args( $post_type );
505
+
506
+ if ( ! empty( $track_post_type ) ) {
507
+ $post_types_tracking_args[ $track_post_type->action_id ] = $track_post_type;
508
+ }
509
+
510
+ }
511
+
512
+ return apply_filters( 'bp_activity_get_post_types_tracking_args', $post_types_tracking_args );
513
+ }
514
+
515
+ /**
516
+ * Get all components' activity actions, sorted by their position attribute.
517
+ *
518
+ * @since BuddyPress (2.2.0)
519
+ *
520
+ * @return object actions ordered by their position
521
+ */
522
+ function bp_activity_get_actions() {
523
+ $bp = buddypress();
524
+
525
+ $post_types = bp_activity_get_post_types_tracking_args();
526
+
527
+ // Create the actions for the post types, if they haven't already been created.
528
+ if ( ! empty( $post_types ) ) {
529
+ foreach ( $post_types as $post_type ) {
530
+ if ( isset( $bp->activity->actions->{$post_type->component_id}->{$post_type->action_id} ) ) {
531
+ continue;
532
+ }
533
+
534
+ bp_activity_set_action(
535
+ $post_type->component_id,
536
+ $post_type->action_id,
537
+ $post_type->admin_filter,
538
+ $post_type->format_callback,
539
+ $post_type->front_filter,
540
+ $post_type->contexts,
541
+ $post_type->position
542
+ );
543
+ }
544
+ }
545
+
546
+ // Sort the actions by their position within each component.
547
+ foreach ( $bp->activity->actions as $component => $actions ) {
548
+ $actions = (array) $actions;
549
+ $temp = bp_sort_by_key( $actions, 'position', 'num' );
550
+
551
+ // Restore keys.
552
+ $bp->activity->actions->{$component} = new stdClass;
553
+ foreach ( $temp as $key_ordered ) {
554
+ $bp->activity->actions->{$component}->{$key_ordered['key']} = $key_ordered;
555
+ }
556
+ }
557
+
558
+ return $bp->activity->actions;
559
+ }
560
+
561
+ /**
562
+ * Retrieve the current action from a component and key.
563
  *
564
  * @since BuddyPress (1.1.0)
565
  *
576
  return false;
577
  }
578
 
579
+ $bp = buddypress();
580
+ $actions = bp_activity_get_actions();
581
+
582
+ $retval = false;
583
+ if ( isset( $actions->{$component_id}->{$key} ) ) {
584
+ $retval = $actions->{$component_id}->{$key};
585
+ }
586
 
587
+ /**
588
+ * Filters the current action by component and key.
589
+ *
590
+ * @since BuddyPress (1.1.0)
591
+ *
592
+ * @param string|bool $retval The action key.
593
+ * @param string $component_id The unique string ID of the component.
594
+ * @param string $key The action key.
595
+ */
596
  return apply_filters( 'bp_activity_get_action', $retval, $component_id, $key );
597
  }
598
 
607
  $actions = array();
608
 
609
  // Walk through the registered actions, and build an array of actions/values.
610
+ foreach ( bp_activity_get_actions() as $action ) {
611
  $action = array_values( (array) $action );
612
 
613
  for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
618
  // This was a mis-named activity type from before BP 1.6
619
  unset( $actions['friends_register_activity_action'] );
620
 
621
+ /**
622
+ * Filters the available activity types.
623
+ *
624
+ * @since BuddyPress (1.7.0)
625
+ *
626
+ * @param array $actions Array of registered activity types.
627
+ */
628
  return apply_filters( 'bp_activity_get_types', $actions );
629
  }
630
 
651
  // Get favorites for user
652
  $favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
653
 
654
+ /**
655
+ * Filters the favorited activity items for a specified user.
656
+ *
657
+ * @since BuddyPress (1.2.0)
658
+ *
659
+ * @param array $favs Array of user's favorited activity items.
660
+ */
661
  return apply_filters( 'bp_activity_get_user_favorites', $favs );
662
  }
663
 
713
  // Update activity meta counts
714
  if ( bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ) ) {
715
 
716
+ /**
717
+ * Fires if bp_activity_update_meta() for favorite_count is successful and before returning a true value for success.
718
+ *
719
+ * @since BuddyPress (1.2.1)
720
+ *
721
+ * @param int $activity_id ID of the activity item being favorited.
722
+ * @param int $user_id ID of the user doing the favoriting.
723
+ */
724
  do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
725
 
726
  // Success
728
 
729
  // Saving meta was unsuccessful for an unknown reason
730
  } else {
731
+
732
+ /**
733
+ * Fires if bp_activity_update_meta() for favorite_count is unsuccessful and before returning a false value for failure.
734
+ *
735
+ * @since BuddyPress (1.5.0)
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_fail', $activity_id, $user_id );
741
 
742
  return false;
793
  // Update users favorites
794
  if ( bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs ) ) {
795
 
796
+ /**
797
+ * Fires if bp_update_user_meta() is successful and before returning a true value for success.
798
+ *
799
+ * @since BuddyPress (1.2.1)
800
+ *
801
+ * @param int $activity_id ID of the activity item being unfavorited.
802
+ * @param int $user_id ID of the user doing the unfavoriting.
803
+ */
804
  do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
805
 
806
  // Success
834
  * @return int|null The ID of the located activity item. Null if none is found.
835
  */
836
  function bp_activity_check_exists_by_content( $content ) {
837
+
838
+ /**
839
+ * Filters the results of the check for whether an activity item exists by specified content.
840
+ *
841
+ * @since BuddyPress (1.1.0)
842
+ *
843
+ * @param BP_Activity_Activity $content_exists ID of the activity if found, else null.
844
+ */
845
  return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
846
  }
847
 
856
  * @return string Date last updated.
857
  */
858
  function bp_activity_get_last_updated() {
859
+
860
+ /**
861
+ * Filters the value for the last updated time for an activity item.
862
+ *
863
+ * @since BuddyPress (1.1.0)
864
+ *
865
+ * @param BP_Activity_Activity $last_updated Date last updated.
866
+ */
867
  return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
868
  }
869
 
954
  $retval = get_metadata( 'activity', $activity_id, $meta_key, $single );
955
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
956
 
957
+ /**
958
+ * Filters the metadata for a specified activity item.
959
+ *
960
+ * @since BuddyPress (1.5.0)
961
+ *
962
+ * @param mixed $retval The meta values for the activity item.
963
+ * @param int $activity_id ID of the activity item.
964
+ * @param string $meta_key Meta key for the value being requested.
965
+ * @param bool $single Whether to return one matched meta key row or all.
966
+ */
967
  return apply_filters( 'bp_activity_get_meta', $retval, $activity_id, $meta_key, $single );
968
  }
969
 
1044
  // Execute additional code
1045
  do_action( 'bp_activity_remove_data', $user_id ); // Deprecated! Do not use!
1046
 
1047
+ /**
1048
+ * Fires after the removal of all of a user's activity data.
1049
+ *
1050
+ * @since BuddyPress (1.5.0)
1051
+ *
1052
+ * @param int $user_id ID of the user being deleted.
1053
+ */
1054
  do_action( 'bp_activity_remove_all_user_data', $user_id );
1055
  }
1056
  add_action( 'wpmu_delete_user', 'bp_activity_remove_all_user_data' );
1099
  * If Akismet is present, update the activity history meta.
1100
  *
1101
  * This is usually taken care of when BP_Activity_Activity::save() happens, but
1102
+ * as we're going to be updating all the activity statuses directly, for efficiency,
1103
  * we need to update manually.
1104
  */
1105
  if ( ! empty( $bp->activity->akismet ) ) {
1113
  // Mark all of this user's activities as spam
1114
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id ) );
1115
 
1116
+ /**
1117
+ * Fires after all activity data from a user has been marked as spam.
1118
+ *
1119
+ * @since BuddyPress (1.6.0)
1120
+ *
1121
+ * @param int $user_id ID of the user whose activity is being marked as spam.
1122
+ * @param array $activities Array of activity items being marked as spam.
1123
+ */
1124
  do_action( 'bp_activity_spam_all_user_data', $user_id, $activities['activities'] );
1125
  }
1126
  add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
1169
  * If Akismet is present, update the activity history meta.
1170
  *
1171
  * This is usually taken care of when BP_Activity_Activity::save() happens, but
1172
+ * as we're going to be updating all the activity statuses directly, for efficiency,
1173
  * we need to update manually.
1174
  */
1175
  if ( ! empty( $bp->activity->akismet ) ) {
1180
  unset( $activity_obj );
1181
  }
1182
 
1183
+ // Mark all of this user's activities as not spam
1184
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 0 WHERE user_id = %d", $user_id ) );
1185
 
1186
+ /**
1187
+ * Fires after all activity data from a user has been marked as ham.
1188
+ *
1189
+ * @since BuddyPress (1.6.0)
1190
+ *
1191
+ * @param int $user_id ID of the user whose activity is being marked as ham.
1192
+ * @param array $activities Array of activity items being marked as ham.
1193
+ */
1194
  do_action( 'bp_activity_ham_all_user_data', $user_id, $activities['activities'] );
1195
  }
1196
  add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
1220
  __( 'Activity Comments', 'buddypress' )
1221
  );
1222
 
1223
+ /**
1224
+ * Fires at the end of the activity actions registration.
1225
+ *
1226
+ * Allows plugin authors to add their own activity actions alongside the core actions.
1227
+ *
1228
+ * @since BuddyPress (1.6.0)
1229
+ */
1230
  do_action( 'bp_activity_register_activity_actions' );
1231
 
1232
  // Backpat. Don't use this.
1256
  // We apply the format_callback as a filter
1257
  add_filter( 'bp_activity_generate_action_string', buddypress()->activity->actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
1258
 
1259
+ /**
1260
+ * Filters the string for the activity action being returned.
1261
+ *
1262
+ * @since BuddyPress (2.0.0)
1263
+ *
1264
+ * @param BP_Activity_Activity $action Action string being requested.
1265
+ * @param BP_Activity_Activity $activity Activity item object.
1266
+ */
1267
  $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
1268
 
1269
  // Remove the filter for future activity items
1283
  */
1284
  function bp_activity_format_activity_action_activity_update( $action, $activity ) {
1285
  $action = sprintf( __( '%s posted an update', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
1286
+
1287
+ /**
1288
+ * Filters the formatted activity action update string.
1289
+ *
1290
+ * @since BuddyPress (1.2.0)
1291
+ *
1292
+ * @param string $action Activity action string value.
1293
+ * @param BP_Activity_Activity $activity Activity item object.
1294
+ */
1295
  return apply_filters( 'bp_activity_new_update_action', $action, $activity );
1296
  }
1297
 
1306
  */
1307
  function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
1308
  $action = sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
1309
+
1310
+ /**
1311
+ * Filters the formatted activity action comment string.
1312
+ *
1313
+ * @since BuddyPress (1.2.0)
1314
+ *
1315
+ * @param string $action Activity action string value.
1316
+ * @param BP_Activity_Activity $activity Activity item object.
1317
+ */
1318
  return apply_filters( 'bp_activity_comment_action', $action, $activity );
1319
  }
1320
 
1321
+ /**
1322
+ * Format activity action strings for custom post types.
1323
+ *
1324
+ * @since BuddyPress (2.2.0)
1325
+ *
1326
+ * @param string $action Static activity action.
1327
+ * @param object $activity Activity data object.
1328
+ * @return string
1329
+ */
1330
+ function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) {
1331
+ $bp = buddypress();
1332
+
1333
+ // Fetch all the tracked post types once.
1334
+ if ( empty( $bp->activity->track ) ) {
1335
+ $bp->activity->track = bp_activity_get_post_types_tracking_args();
1336
+ }
1337
+
1338
+ if ( empty( $activity->type ) || empty( $bp->activity->track[ $activity->type ] ) ) {
1339
+ return $action;
1340
+ }
1341
+
1342
+ $user_link = bp_core_get_userlink( $activity->user_id );
1343
+ $blog_url = get_home_url( $activity->item_id );
1344
+
1345
+ if ( empty( $activity->post_url ) ) {
1346
+ $post_url = add_query_arg( 'p', $activity->secondary_item_id, trailingslashit( $blog_url ) );
1347
+ } else {
1348
+ $post_url = $activity->post_url;
1349
+ }
1350
+
1351
+ if ( is_multisite() ) {
1352
+ $blog_link = '<a href="' . $blog_url . '">' . get_blog_option( $activity->item_id, 'blogname' ) . '</a>';
1353
+
1354
+ if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action_ms ) ) {
1355
+ $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action_ms, $user_link, $post_url, $blog_link );
1356
+ } else {
1357
+ $action = sprintf( _x( '%1$s wrote a new <a href="%2$s">item</a>, on the site %3$s', 'Activity Custom Post Type post action', 'buddypress' ), $user_link, $post_url, $blog_link );
1358
+ }
1359
+ } else {
1360
+ if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action ) ) {
1361
+ $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action, $user_link, $post_url );
1362
+ } else {
1363
+ $action = sprintf( _x( '%1$s wrote a new <a href="%2$s">item</a>', 'Activity Custom Post Type post action', 'buddypress' ), $user_link, $post_url );
1364
+ }
1365
+ }
1366
+
1367
+ /**
1368
+ * Filters the formatted custom post type activity post action string.
1369
+ *
1370
+ * @since BuddyPress (2.2.0)
1371
+ *
1372
+ * @param string $action Activity action string value.
1373
+ * @param BP_Activity_Activity $activity Activity item object.
1374
+ */
1375
+ return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity );
1376
+ }
1377
+
1378
  /******************************************************************************
1379
  * Business functions are where all the magic happens in BuddyPress. They will
1380
  * handle the actual saving or manipulation of information. Usually they will
1416
  'search_terms' => false, // Pass search terms as a string
1417
  'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format
1418
  'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format
1419
+ 'filter_query' => false,
1420
  'show_hidden' => false, // Show activity items that are hidden site-wide?
1421
  'exclude' => false, // Comma-separated list of activity IDs to exclude
1422
  'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query
1423
  'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
1424
  'update_meta_cache' => true,
1425
  'count_total' => false,
1426
+ 'scope' => false,
1427
 
1428
  /**
1429
  * Pass filters as an array -- all filter items can be multiple values comma separated:
1439
  ) );
1440
 
1441
  // Attempt to return a cached copy of the first page of sitewide activity.
1442
+ if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['scope'] )&& empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
1443
 
1444
  $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
1445
  if ( false === $activity ) {
1452
  'search_terms' => $r['search_terms'],
1453
  'meta_query' => $r['meta_query'],
1454
  'date_query' => $r['date_query'],
1455
+ 'filter_query' => $r['filter_query'],
1456
  'filter' => $r['filter'],
1457
+ 'scope' => $r['scope'],
1458
  'display_comments' => $r['display_comments'],
1459
  'show_hidden' => $r['show_hidden'],
1460
  'spam' => $r['spam'],
1474
  'search_terms' => $r['search_terms'],
1475
  'meta_query' => $r['meta_query'],
1476
  'date_query' => $r['date_query'],
1477
+ 'filter_query' => $r['filter_query'],
1478
  'filter' => $r['filter'],
1479
+ 'scope' => $r['scope'],
1480
  'display_comments' => $r['display_comments'],
1481
  'show_hidden' => $r['show_hidden'],
1482
  'exclude' => $r['exclude'],
1486
  ) );
1487
  }
1488
 
1489
+ /**
1490
+ * Filters the requested activity item(s).
1491
+ *
1492
+ * @since BuddyPress (1.2.0)
1493
+ *
1494
+ * @param BP_Activity_Activity $activity Requested activity object.
1495
+ * @param array $r Arguments used for the activity query.
1496
+ */
1497
  return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
1498
  }
1499
 
1541
  'update_meta_cache' => $r['update_meta_cache'],
1542
  );
1543
 
1544
+ /**
1545
+ * Filters the requested specific activity item.
1546
+ *
1547
+ * @since BuddyPress (1.2.0)
1548
+ *
1549
+ * @param BP_Activity_Activity $activity Requested activity object.
1550
+ * @param array $args Original passed in arguments.
1551
+ * @param array $get_args Constructed arguments used with request.
1552
+ */
1553
  return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
1554
  }
1555
 
1652
  }
1653
 
1654
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
1655
+
1656
+ /**
1657
+ * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID.
1658
+ *
1659
+ * @since BuddyPress (1.1.0)
1660
+ *
1661
+ * @param array $r Array of parsed arguments for the activity item being added.
1662
+ */
1663
  do_action( 'bp_activity_add', $r );
1664
 
1665
  return $activity->id;
1706
  $activity_content = $r['content'];
1707
  $primary_link = bp_core_get_userlink( $r['user_id'], false, true );
1708
 
1709
+ /**
1710
+ * Filters the new activity content for current activity item.
1711
+ *
1712
+ * @since BuddyPress (1.2.0)
1713
+ *
1714
+ * @param string $activity_content Activity content posted by user.
1715
+ */
1716
+ $add_content = apply_filters( 'bp_activity_new_update_content', $activity_content );
1717
+
1718
+ /**
1719
+ * Filters the activity primary link for current activity item.
1720
+ *
1721
+ * @since BuddyPress (1.2.0)
1722
+ *
1723
+ * @param string $primary_link Link to the profile for the user who posted the activity.
1724
+ */
1725
+ $add_primary_link = apply_filters( 'bp_activity_new_update_primary_link', $primary_link );
1726
+
1727
  // Now write the values
1728
  $activity_id = bp_activity_add( array(
1729
  'user_id' => $r['user_id'],
1730
+ 'content' => $add_content,
1731
+ 'primary_link' => $add_primary_link,
1732
  'component' => buddypress()->activity->id,
1733
  'type' => 'activity_update',
1734
  ) );
1735
 
1736
+ /**
1737
+ * Filters the latest update content for the activity item.
1738
+ *
1739
+ * @since BuddyPress (1.6.0)
1740
+ *
1741
+ * @param string $r Content of the activity update.
1742
+ * @param string $activity_content Content of the activity update.
1743
+ */
1744
  $activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content );
1745
 
1746
  // Add this update to the "latest update" usermeta so it can be fetched anywhere.
1749
  'content' => $activity_content
1750
  ) );
1751
 
1752
+ /**
1753
+ * Fires at the end of an activity post update, before returning the updated activity item ID.
1754
+ *
1755
+ * @since BuddyPress (1.2.0)
1756
+ *
1757
+ * @param string $content Content of the activity post update.
1758
+ * @param int $user_id ID of the user posting the activity update.
1759
+ * @param int $activity_id ID of the activity item being updated.
1760
+ */
1761
  do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
1762
 
1763
  return $activity_id;
1764
  }
1765
 
1766
+ /**
1767
+ * Create an activity item for a newly published post type post.
1768
+ *
1769
+ * @since BuddyPress (2.2.0)
1770
+ *
1771
+ * @param int $post_id ID of the new post.
1772
+ * @param WP_Post $post Post object.
1773
+ * @param int $user_id ID of the post author.
1774
+ * @return int|bool The ID of the activity on success. False on error.
1775
+ */
1776
+ function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0 ) {
1777
+ $bp = buddypress();
1778
+
1779
+ if ( ! is_a( $post, 'WP_Post' ) ) {
1780
+ return;
1781
+ }
1782
+
1783
+ // Get the post type tracking args.
1784
+ $activity_post_object = bp_activity_get_post_type_tracking_args( $post->post_type );
1785
+
1786
+ if ( 'publish' != $post->post_status || ! empty( $post->post_password ) || empty( $activity_post_object->action_id ) ) {
1787
+ return;
1788
+ }
1789
+
1790
+ if ( empty( $post_id ) ) {
1791
+ $post_id = $post->ID;
1792
+ }
1793
+
1794
+ $blog_id = get_current_blog_id();
1795
+
1796
+ if ( empty( $user_id ) ) {
1797
+ $user_id = (int) $post->post_author;
1798
+ }
1799
+
1800
+ // Bail if an activity item already exists for this post.
1801
+ $existing = bp_activity_get( array(
1802
+ 'filter' => array(
1803
+ 'action' => $activity_post_object->action_id,
1804
+ 'primary_id' => $blog_id,
1805
+ 'secondary_id' => $post_id,
1806
+ )
1807
+ ) );
1808
+
1809
+ if ( ! empty( $existing['activities'] ) ) {
1810
+ return;
1811
+ }
1812
+
1813
+ // Let components/plugins bail before the activity is posted.
1814
+ if ( false === apply_filters( "bp_activity_{$post->post_type}_pre_publish", true, $blog_id, $post_id, $user_id ) ) {
1815
+ return;
1816
+ }
1817
+
1818
+ // Record this in activity streams.
1819
+ $blog_url = get_home_url( $blog_id );
1820
+ $post_url = add_query_arg(
1821
+ 'p',
1822
+ $post_id,
1823
+ trailingslashit( $blog_url )
1824
+ );
1825
+
1826
+ // Backward compatibility filters for the 'blogs' component.
1827
+ if ( 'blogs' == $activity_post_object->component_id ) {
1828
+ $activity_content = apply_filters( 'bp_blogs_activity_new_post_content', $post->post_content, $post, $post_url, $post->post_type );
1829
+ $activity_primary_link = apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_url, $post_id, $post->post_type );
1830
+ } else {
1831
+ $activity_content = $post->post_content;
1832
+ $activity_primary_link = $post_url;
1833
+ }
1834
+
1835
+ $activity_args = array(
1836
+ 'user_id' => $user_id,
1837
+ 'content' => $activity_content,
1838
+ 'primary_link' => $activity_primary_link,
1839
+ 'component' => $activity_post_object->component_id,
1840
+ 'type' => $activity_post_object->action_id,
1841
+ 'item_id' => $blog_id,
1842
+ 'secondary_item_id' => $post_id,
1843
+ 'recorded_time' => $post->post_date_gmt,
1844
+ );
1845
+
1846
+ // Remove large images and replace them with just one image thumbnail.
1847
+ if ( ! empty( $activity_args['content'] ) ) {
1848
+ $activity_args['content'] = bp_activity_thumbnail_content_images( $activity_args['content'], $activity_args['primary_link'], $activity_args );
1849
+ }
1850
+
1851
+ if ( ! empty( $activity_args['content'] ) ) {
1852
+ // Create the excerpt.
1853
+ $activity_excerpt = bp_create_excerpt( $activity_args['content'] );
1854
+
1855
+ // Backward compatibility filter for blog posts.
1856
+ if ( 'blogs' == $activity_post_object->component_id ) {
1857
+ $activity_args['content'] = apply_filters( 'bp_blogs_record_activity_content', $activity_excerpt, $activity_args['content'], $activity_args, $post->post_type );
1858
+ } else {
1859
+ $activity_args['content'] = $activity_excerpt;
1860
+ }
1861
+ }
1862
+
1863
+ // Set up the action by using the format functions.
1864
+ $action_args = array_merge( $activity_args, array(
1865
+ 'post_title' => $post->post_title,
1866
+ 'post_url' => $post_url,
1867
+ ) );
1868
+
1869
+ $activity_args['action'] = call_user_func_array( $activity_post_object->format_callback, array( '', (object) $action_args ) );
1870
+
1871
+ // Make sure the action is set.
1872
+ if ( empty( $activity_args['action'] ) ) {
1873
+ return;
1874
+ } else {
1875
+ // Backward compatibility filter for the blogs component.
1876
+ if ( 'blogs' == $activity_post_object->component_id ) {
1877
+ $activity_args['action'] = apply_filters( 'bp_blogs_record_activity_action', $activity_args['action'] );
1878
+ }
1879
+ }
1880
+
1881
+ $activity_id = bp_activity_add( $activity_args );
1882
+
1883
+ do_action( 'bp_activity_post_type_published', $activity_id, $post, $activity_args );
1884
+
1885
+ return $activity_id;
1886
+ }
1887
+
1888
+ /**
1889
+ * Update the activity item for a custom post type entry.
1890
+ *
1891
+ * @since BuddyPress (2.2.0)
1892
+ *
1893
+ * @param WP_Post $post Post item.
1894
+ * @return bool True on success, false on failure.
1895
+ */
1896
+ function bp_activity_post_type_update( $post = null ) {
1897
+ $bp = buddypress();
1898
+
1899
+ if ( ! is_a( $post, 'WP_Post' ) ) {
1900
+ return;
1901
+ }
1902
+
1903
+ // Get the post type tracking args.
1904
+ $activity_post_object = bp_activity_get_post_type_tracking_args( $post->post_type );
1905
+
1906
+ if ( empty( $activity_post_object->action_id ) ) {
1907
+ return;
1908
+ }
1909
+
1910
+ $activity_id = bp_activity_get_activity_id( array(
1911
+ 'component' => $activity_post_object->component_id,
1912
+ 'item_id' => get_current_blog_id(),
1913
+ 'secondary_item_id' => $post->ID,
1914
+ 'type' => $activity_post_object->action_id,
1915
+ ) );
1916
+
1917
+ // Activity ID doesn't exist, so stop!
1918
+ if ( empty( $activity_id ) ) {
1919
+ return;
1920
+ }
1921
+
1922
+ // Delete the activity if the post was updated with a password.
1923
+ if ( ! empty( $post->post_password ) ) {
1924
+ bp_activity_delete( array( 'id' => $activity_id ) );
1925
+ }
1926
+
1927
+ // Update the activity entry.
1928
+ $activity = new BP_Activity_Activity( $activity_id );
1929
+
1930
+ if ( ! empty( $post->post_content ) ) {
1931
+ // Make sure to update the thumbnail image.
1932
+ $post_content = bp_activity_thumbnail_content_images( $post->post_content, $activity->primary_link, (array) $activity );
1933
+
1934
+ // Generate an excerpt.
1935
+ $activity_excerpt = bp_create_excerpt( $post_content );
1936
+
1937
+ // Backward compatibility filter for the blogs component.
1938
+ if ( 'blogs' == $activity_post_object->component_id ) {
1939
+ $activity->content = apply_filters( 'bp_blogs_record_activity_content', $activity_excerpt, $post_content, (array) $activity, $post->post_type );
1940
+ } else {
1941
+ $activity->content = $activity_excerpt;
1942
+ }
1943
+ }
1944
+
1945
+ // Save the updated activity.
1946
+ $updated = $activity->save();
1947
+
1948
+ do_action( 'bp_activity_post_type_updated', $post, $activity );
1949
+
1950
+ return $updated;
1951
+ }
1952
+
1953
+ /**
1954
+ * Unpublish an activity for the custom post type.
1955
+ *
1956
+ * @since BuddyPress (2.2.0)
1957
+ *
1958
+ * @param int $post_id ID of the post being unpublished.
1959
+ * @param WP_Post $post Post object.
1960
+ * @return bool True on success, false on failure.
1961
+ */
1962
+ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
1963
+ $bp = buddypress();
1964
+
1965
+ if ( ! is_a( $post, 'WP_Post' ) ) {
1966
+ return;
1967
+ }
1968
+
1969
+ // Get the post type tracking args
1970
+ $activity_post_object = bp_activity_get_post_type_tracking_args( $post->post_type );
1971
+
1972
+ if ( empty( $activity_post_object->action_id ) ) {
1973
+ return;
1974
+ }
1975
+
1976
+ if ( empty( $post_id ) ) {
1977
+ $post_id = $post->ID;
1978
+ }
1979
+
1980
+ $delete_activity_args = array(
1981
+ 'item_id' => get_current_blog_id(),
1982
+ 'secondary_item_id' => $post_id,
1983
+ 'component' => $activity_post_object->component_id,
1984
+ 'type' => $activity_post_object->action_id,
1985
+ 'user_id' => false,
1986
+ );
1987
+
1988
+ $deleted = bp_activity_delete_by_item_id( $delete_activity_args );
1989
+
1990
+ do_action( 'bp_activity_post_type_unpublished', $delete_activity_args, $post, $deleted );
1991
+
1992
+ return $deleted;
1993
+ }
1994
+
1995
  /**
1996
  * Add an activity comment.
1997
  *
2002
  * @uses bp_activity_add()
2003
  * @uses apply_filters() To call the 'bp_activity_comment_action' hook.
2004
  * @uses apply_filters() To call the 'bp_activity_comment_content' hook.
 
2005
  * @uses wp_cache_delete()
2006
  * @uses do_action() To call the 'bp_activity_comment_posted' hook.
2007
  *
2019
  * @return int|bool The ID of the comment on success, otherwise false.
2020
  */
2021
  function bp_activity_new_comment( $args = '' ) {
2022
+ $bp = buddypress();
2023
+ $errors = new WP_Error();
2024
+ $feedback = __( 'There was an error posting your reply. Please try again.', 'buddypress' );
2025
+
2026
+ if ( empty( $bp->activity->errors ) ) {
2027
+ $bp->activity->errors = array();
2028
+ }
2029
 
2030
  $r = wp_parse_args( $args, array(
2031
  'id' => false,
2037
 
2038
  // Bail if missing necessary data
2039
  if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
2040
+ $errors->add( 'missing_data', $feedback );
2041
+ $bp->activity->errors['new_comment'] = $errors;
2042
+
2043
  return false;
2044
  }
2045
 
2050
 
2051
  $activity_id = $r['activity_id'];
2052
 
2053
+ // Get the parent activity
2054
  $activity = new BP_Activity_Activity( $activity_id );
2055
+
2056
+ // Bail if the parent activity does not exist
2057
+ if ( empty( $activity->date_recorded ) ) {
2058
+ $errors->add( 'missing_activity', __( 'Sorry, the item you are replying to no longer exists.', 'buddypress' ) );
2059
+ $bp->activity->errors['new_comment'] = $errors;
2060
+
2061
+ return false;
2062
+ }
2063
+
2064
+ // Check to see if the parent activity is hidden, and if so, hide this comment publicly.
2065
  $is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
2066
 
2067
+ /**
2068
+ * Filters the content of a new comment.
2069
+ *
2070
+ * @since BuddyPress (1.2.0)
2071
+ *
2072
+ * @param string $r Content for the newly posted comment.
2073
+ */
2074
+ $comment_content = apply_filters( 'bp_activity_comment_content', $r['content'] );
2075
+
2076
  // Insert the activity comment
2077
  $comment_id = bp_activity_add( array(
2078
  'id' => $r['id'],
2079
+ 'content' => $comment_content,
2080
  'component' => buddypress()->activity->id,
2081
  'type' => 'activity_comment',
2082
  'user_id' => $r['user_id'],
2097
  }
2098
  wp_cache_delete( $activity_id, 'bp_activity' );
2099
 
2100
+ /**
2101
+ * Fires near the end of an activity comment posting, before the returning of the comment ID.
2102
+ *
2103
+ * @since BuddyPress (1.2.0)
2104
+ *
2105
+ * @param int $comment_id ID of the newly posted activity comment.
2106
+ * @param array $r Array of parsed comment arguments.
2107
+ * @param int $activity ID of the activity item being commented on.
2108
+ */
2109
  do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity );
2110
 
2111
+ if ( empty( $comment_id ) ) {
2112
+ $errors->add( 'comment_failed', $feedback );
2113
+ $bp->activity->errors['new_comment'] = $errors;
2114
+ }
2115
+
2116
  return $comment_id;
2117
  }
2118
 
2142
  'date_recorded' => false,
2143
  ) );
2144
 
2145
+ /**
2146
+ * Filters the activity ID being requested.
2147
+ *
2148
+ * @since BuddyPress (1.2.0)
2149
+ *
2150
+ * @param BP_Activity_Activity ID returned by BP_Activity_Activity get_id() method with provided arguments.
2151
+ */
2152
  return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
2153
  $r['user_id'],
2154
  $r['component'],
2210
  'hide_sitewide' => false
2211
  ) );
2212
 
2213
+ /**
2214
+ * Fires before an activity item proceeds to be deleted.
2215
+ *
2216
+ * @since BuddyPress (1.5.0)
2217
+ *
2218
+ * @param array $args Array of arguments to be used with the activity deletion.
2219
+ */
2220
  do_action( 'bp_before_activity_delete', $args );
2221
 
2222
  // Adjust the new mention count of any mentioned member
2239
  }
2240
  }
2241
 
2242
+ /**
2243
+ * Fires after the activity item has been deleted.
2244
+ *
2245
+ * @since BuddyPress (1.0.0)
2246
+ *
2247
+ * @param array $args Array of arguments used with the activity deletion.
2248
+ */
2249
  do_action( 'bp_activity_delete', $args );
2250
+
2251
+ /**
2252
+ * Fires after the activity item has been deleted.
2253
+ *
2254
+ * @since BuddyPress (1.2.0)
2255
+ *
2256
+ * @param array $activity_ids_deleted Array of affected activity item IDs.
2257
+ */
2258
  do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
2259
 
2260
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
2268
  * You should use bp_activity_delete() instead.
2269
  *
2270
  * @since BuddyPress (1.1.0)
2271
+ * @deprecated BuddyPress (1.2.0)
2272
  *
2273
  * @uses wp_parse_args()
2274
  * @uses bp_activity_delete()
2311
  * You should use bp_activity_delete() instead.
2312
  *
2313
  * @since BuddyPress (1.1.0)
2314
+ * @deprecated BuddyPress (1.2.0)
2315
  *
2316
  * @uses bp_activity_delete()
2317
  *
2336
  * You should use bp_activity_delete() instead.
2337
  *
2338
  * @since BuddyPress (1.1.0)
2339
+ * @deprecated BuddyPress (1.2.0)
2340
  *
2341
  * @uses bp_activity_delete()
2342
  *
2372
  * @return bool True on success, false on failure
2373
  */
2374
  function bp_activity_delete_comment( $activity_id, $comment_id ) {
2375
+
2376
+ /**
2377
+ * Filters whether BuddyPress should delete an activity comment or not.
2378
+ *
2379
  * You may want to hook into this filter if you want to override this function and
2380
  * handle the deletion of child comments differently. Make sure you return false.
2381
+ *
2382
+ * @since BuddyPress (1.2.0)
2383
+ *
2384
+ * @param bool $value Whether BuddyPress should continue or not.
2385
+ * @param int $activity_id ID of the root activity item being deleted.
2386
+ * @param int $comment_id ID of the comment being deleted.
2387
  */
2388
  if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
2389
  return false;
2403
  // Recalculate the comment tree
2404
  BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
2405
 
2406
+ /**
2407
+ * Fires at the end of the deletion of an activity comment, before returning success.
2408
+ *
2409
+ * @since BuddyPress (1.2.0)
2410
+ *
2411
+ * @param int $activity_id ID of the activity that has had a comment deleted from.
2412
+ * @param int $comment_id ID of the comment that was deleted.
2413
+ */
2414
  do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
2415
 
2416
  return true;
2440
  bp_activity_delete_children( $activity_id, $child->id );
2441
  }
2442
  }
2443
+
2444
  // Delete the comment itself
2445
  bp_activity_delete( array(
2446
  'secondary_item_id' => $comment_id,
2468
  * @return string $link Permalink for the activity item.
2469
  */
2470
  function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
2471
+ $bp = buddypress();
2472
 
2473
  if ( empty( $activity_obj ) ) {
2474
  $activity_obj = new BP_Activity_Activity( $activity_id );
2478
  $activity_obj = $activity_obj->current_comment;
2479
  }
2480
 
2481
+ $use_primary_links = array(
2482
+ 'new_blog_post',
2483
+ 'new_blog_comment',
2484
+ 'new_forum_topic',
2485
+ 'new_forum_post',
2486
+ );
2487
+
2488
+ if ( ! empty( $bp->activity->track ) ) {
2489
+ $use_primary_links = array_merge( $use_primary_links, array_keys( $bp->activity->track ) );
2490
+ }
2491
+
2492
+ if ( false !== array_search( $activity_obj->type, $use_primary_links ) ) {
2493
  $link = $activity_obj->primary_link;
2494
  } else {
2495
  if ( 'activity_comment' == $activity_obj->type ) {
2499
  }
2500
  }
2501
 
2502
+ /**
2503
+ * Filters the activity permalink for the specified activity item.
2504
+ *
2505
+ * @since BuddyPress (1.2.0)
2506
+ *
2507
+ * @param array $array Array holding activity permalink and activity item object.
2508
+ */
2509
  return apply_filters_ref_array( 'bp_activity_get_permalink', array( $link, &$activity_obj ) );
2510
  }
2511
 
2585
  }
2586
  }
2587
 
2588
+ /**
2589
+ * Filters the activity content that had a thumbnail replace images.
2590
+ *
2591
+ * @since BuddyPress (1.2.0)
2592
+ *
2593
+ * @param string $content Activity content that had images replaced in.
2594
+ * @param array $matches Array of all image tags found in the posted content.
2595
+ * @param array $args Arguments passed into function creating the activity update.
2596
+ */
2597
  return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches, $args );
2598
  }
2599
 
2605
  * @return bool True if user is allowed to mark activity items as spam.
2606
  */
2607
  function bp_activity_user_can_mark_spam() {
2608
+
2609
+ /**
2610
+ * Filters whether the current user should be able to mark items as spam.
2611
+ *
2612
+ * @since BuddyPress (1.6.0)
2613
+ *
2614
+ * @param bool $moderate Whether or not the current user has bp_moderate capability.
2615
+ */
2616
  return apply_filters( 'bp_activity_user_can_mark_spam', bp_current_user_can( 'bp_moderate' ) );
2617
  }
2618
 
2651
  add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_spam_meta' ), 1, 1 );
2652
  }
2653
 
2654
+ /**
2655
+ * Fires at the end of the process to mark an activity item as spam.
2656
+ *
2657
+ * @since BuddyPress (1.6.0)
2658
+ *
2659
+ * @param BP_Activity_Activity $activity Activity item being marked as spam.
2660
+ * @param string $source Source of determination of spam status. For example
2661
+ * "by_a_person" or "by_akismet".
2662
+ */
2663
  do_action( 'bp_activity_mark_as_spam', $activity, $source );
2664
  }
2665
 
2698
  add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_ham_meta' ), 1, 1 );
2699
  }
2700
 
2701
+ /**
2702
+ * Fires at the end of the process to mark an activity item as ham.
2703
+ *
2704
+ * @since BuddyPress (1.6.0)
2705
+ *
2706
+ * @param BP_Activity_Activity $activity Activity item being marked as ham.
2707
+ * @param string $source Source of determination of ham status. For example
2708
+ * "by_a_person" or "by_akismet".
2709
+ */
2710
  do_action( 'bp_activity_mark_as_ham', $activity, $source );
2711
  }
2712
 
2846
  *
2847
  * @since BuddyPress (2.0.0)
2848
  *
2849
+ * @uses bp_is_activity_heartbeat_active() to check if heartbeat setting is on.
2850
  * @uses bp_is_activity_directory() to check if the current page is the activity
2851
  * directory.
2852
  * @uses bp_is_active() to check if the group component is active.
bp-activity/bp-activity-loader.php CHANGED
@@ -60,6 +60,8 @@ class BP_Activity_Component extends BP_Component {
60
 
61
  // Load Akismet support if Akismet is configured
62
  $akismet_key = bp_get_option( 'wordpress_api_key' );
 
 
63
  if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
64
  $includes[] = 'akismet';
65
  }
@@ -360,6 +362,23 @@ class BP_Activity_Component extends BP_Component {
360
 
361
  parent::setup_actions();
362
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  }
364
 
365
  /**
60
 
61
  // Load Akismet support if Akismet is configured
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
  }
362
 
363
  parent::setup_actions();
364
  }
365
+
366
+ /**
367
+ * Setup cache groups
368
+ *
369
+ * @since BuddyPress (2.2.0)
370
+ */
371
+ public function setup_cache_groups() {
372
+
373
+ // Global groups
374
+ wp_cache_add_global_groups( array(
375
+ 'bp_activity',
376
+ 'bp_activity_comments',
377
+ 'activity_meta'
378
+ ) );
379
+
380
+ parent::setup_cache_groups();
381
+ }
382
  }
383
 
384
  /**
bp-activity/bp-activity-notifications.php CHANGED
@@ -15,7 +15,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
15
  /**
16
  * Send email and BP notifications when a user is mentioned in an update.
17
  *
18
- * @since BuddyPress (1.2)
19
  *
20
  * @uses bp_notifications_add_notification()
21
  * @uses bp_get_user_meta()
@@ -99,21 +99,59 @@ To view and respond to the message, log in and visit: %3$s
99
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
100
  }
101
 
102
- // Send the message
 
 
 
 
 
 
103
  $to = apply_filters( 'bp_activity_at_message_notification_to', $to );
 
 
 
 
 
 
 
 
 
104
  $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
 
 
 
 
 
 
 
 
 
 
 
 
105
  $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
106
 
107
  wp_mail( $to, $subject, $message );
108
  }
109
 
 
 
 
 
 
 
 
 
 
 
 
110
  do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id );
111
  }
112
 
113
  /**
114
  * Send email and BP notifications when an activity item receives a comment.
115
  *
116
- * @since BuddyPress (1.2)
117
  *
118
  * @uses bp_get_user_meta()
119
  * @uses bp_core_get_user_displayname()
@@ -177,13 +215,52 @@ To view your original update and all comments, log in and visit: %3$s
177
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
178
  }
179
 
180
- /* Send the message */
 
 
 
 
 
 
181
  $to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
 
 
 
 
 
 
 
 
 
182
  $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
 
 
 
 
 
 
 
 
 
 
 
 
183
  $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link );
184
 
185
  wp_mail( $to, $subject, $message );
186
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
188
  }
189
 
@@ -226,13 +303,52 @@ To view the original activity, your comment and all replies, log in and visit: %
226
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
227
  }
228
 
229
- /* Send the message */
 
 
 
 
 
 
230
  $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to );
 
 
 
 
 
 
 
 
 
231
  $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
 
 
 
 
 
 
 
 
 
 
 
 
232
  $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link );
233
 
234
  wp_mail( $to, $subject, $message );
235
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  do_action( 'bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
237
  }
238
  }
@@ -254,7 +370,7 @@ add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_
254
  /**
255
  * Format notifications related to activity.
256
  *
257
- * @since BuddyPress (1.5)
258
  *
259
  * @uses bp_loggedin_user_domain()
260
  * @uses bp_get_activity_slug()
@@ -278,27 +394,69 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
278
  $poster_user_id = $secondary_item_id;
279
  $at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
280
  $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );
 
281
 
282
  if ( (int) $total_items > 1 ) {
283
  $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
284
- $filter = 'bp_activity_multiple_at_mentions_notification';
285
  } else {
286
  $user_fullname = bp_core_get_user_displayname( $poster_user_id );
287
  $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
288
- $filter = 'bp_activity_single_at_mentions_notification';
289
  }
290
  break;
291
  }
292
 
293
  if ( 'string' == $format ) {
294
- $return = apply_filters( $filter, '<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 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  } else {
296
- $return = apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  'text' => $text,
298
  'link' => $at_mention_link
299
  ), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
300
  }
301
 
 
 
 
 
 
 
 
 
 
 
302
  do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
303
 
304
  return $return;
@@ -338,7 +496,7 @@ add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notifi
338
  /**
339
  * Mark at-mention notifications as read when users visit their Mentions page.
340
  *
341
- * @since BuddyPress (1.5)
342
  *
343
  * @uses bp_notifications_mark_all_notifications_by_type()
344
  */
15
  /**
16
  * Send email and BP notifications when a user is mentioned in an update.
17
  *
18
+ * @since BuddyPress (1.2.0)
19
  *
20
  * @uses bp_notifications_add_notification()
21
  * @uses bp_get_user_meta()
99
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
100
  }
101
 
102
+ /**
103
+ * Filters the user email that the @mention notification will be sent to.
104
+ *
105
+ * @since BuddyPress (1.2.0)
106
+ *
107
+ * @param string $to User email the notification is being sent to.
108
+ */
109
  $to = apply_filters( 'bp_activity_at_message_notification_to', $to );
110
+
111
+ /**
112
+ * Filters the @mention notification subject that will be sent to user.
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 );
120
+
121
+ /**
122
+ * Filters the @mention notification message that will be sent to user.
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 );
133
 
134
  wp_mail( $to, $subject, $message );
135
  }
136
 
137
+ /**
138
+ * Fires after the sending of an @mention email notification.
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 );
149
  }
150
 
151
  /**
152
  * Send email and BP notifications when an activity item receives a comment.
153
  *
154
+ * @since BuddyPress (1.2.0)
155
  *
156
  * @uses bp_get_user_meta()
157
  * @uses bp_core_get_user_displayname()
215
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
216
  }
217
 
218
+ /**
219
+ * Filters the user email that the new comment notification will be sent to.
220
+ *
221
+ * @since BuddyPress (1.2.0)
222
+ *
223
+ * @param string $to User email the notification is being sent to.
224
+ */
225
  $to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
226
+
227
+ /**
228
+ * Filters the new comment notification subject that will be sent to user.
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 );
236
+
237
+ /**
238
+ * Filters the new comment notification message that will be sent to user.
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 );
249
 
250
  wp_mail( $to, $subject, $message );
251
 
252
+ /**
253
+ * Fires after the sending of a reply to an update email notification.
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
  }
266
 
303
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
304
  }
305
 
306
+ /**
307
+ * Filters the user email that the new comment reply notification will be sent to.
308
+ *
309
+ * @since BuddyPress (1.2.0)
310
+ *
311
+ * @param string $to User email the notification is being sent to.
312
+ */
313
  $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to );
314
+
315
+ /**
316
+ * Filters the new comment reply notification subject that will be sent to user.
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 );
324
+
325
+ /**
326
+ * Filters the new comment reply notification message that will be sent to user.
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
 
338
  wp_mail( $to, $subject, $message );
339
 
340
+ /**
341
+ * Fires after the sending of a reply to a reply email notification.
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
  }
370
  /**
371
  * Format notifications related to activity.
372
  *
373
+ * @since BuddyPress (1.5.0)
374
  *
375
  * @uses bp_loggedin_user_domain()
376
  * @uses bp_get_activity_slug()
394
  $poster_user_id = $secondary_item_id;
395
  $at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
396
  $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );
397
+ $amount = 'single';
398
 
399
  if ( (int) $total_items > 1 ) {
400
  $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
401
+ $amount = 'multiple';
402
  } else {
403
  $user_fullname = bp_core_get_user_displayname( $poster_user_id );
404
  $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
 
405
  }
406
  break;
407
  }
408
 
409
  if ( 'string' == $format ) {
410
+
411
+ /**
412
+ * Filters the @mention notification for the string format.
413
+ *
414
+ * This is a variable filter that is dependent on how many items
415
+ * need notified about. The two possible hooks are bp_activity_single_at_mentions_notification
416
+ * or bp_activity_multiple_at_mentions_notification.
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 {
428
+
429
+ /**
430
+ * Filters the @mention notification for any non-string format.
431
+ *
432
+ * This is a variable filter that is dependent on how many items need notified about.
433
+ * The two possible hooks are bp_activity_single_at_mentions_notification
434
+ * or bp_activity_multiple_at_mentions_notification.
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,
446
  'link' => $at_mention_link
447
  ), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
448
  }
449
 
450
+ /**
451
+ * Fires right before returning the formatted activity notifications.
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
 
462
  return $return;
496
  /**
497
  * Mark at-mention notifications as read when users visit their Mentions page.
498
  *
499
+ * @since BuddyPress (1.5.0)
500
  *
501
  * @uses bp_notifications_mark_all_notifications_by_type()
502
  */
bp-activity/bp-activity-screens.php CHANGED
@@ -17,7 +17,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
17
  /**
18
  * Load the Activity directory.
19
  *
20
- * @since BuddyPress (1.5)
21
  *
22
  * @uses bp_displayed_user_id()
23
  * @uses bp_is_activity_component()
@@ -31,8 +31,20 @@ function bp_activity_screen_index() {
31
  if ( bp_is_activity_directory() ) {
32
  bp_update_is_directory( true, 'activity' );
33
 
 
 
 
 
 
34
  do_action( 'bp_activity_screen_index' );
35
 
 
 
 
 
 
 
 
36
  bp_core_load_template( apply_filters( 'bp_activity_screen_index', 'activity/index' ) );
37
  }
38
  }
@@ -41,21 +53,35 @@ add_action( 'bp_screens', 'bp_activity_screen_index' );
41
  /**
42
  * Load the 'My Activity' page.
43
  *
44
- * @since BuddyPress (1.0)
45
  *
46
  * @uses do_action() To call the 'bp_activity_screen_my_activity' hook.
47
  * @uses bp_core_load_template()
48
  * @uses apply_filters() To call the 'bp_activity_template_my_activity' hook.
49
  */
50
  function bp_activity_screen_my_activity() {
 
 
 
 
 
 
51
  do_action( 'bp_activity_screen_my_activity' );
 
 
 
 
 
 
 
 
52
  bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) );
53
  }
54
 
55
  /**
56
  * Load the 'My Friends' activity page.
57
  *
58
- * @since BuddyPress (1.0)
59
  *
60
  * @uses bp_is_active()
61
  * @uses bp_update_is_item_admin()
@@ -69,14 +95,28 @@ function bp_activity_screen_friends() {
69
  return false;
70
 
71
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
 
 
 
 
 
 
72
  do_action( 'bp_activity_screen_friends' );
 
 
 
 
 
 
 
 
73
  bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) );
74
  }
75
 
76
  /**
77
  * Load the 'My Groups' activity page.
78
  *
79
- * @since BuddyPress (1.2)
80
  *
81
  * @uses bp_is_active()
82
  * @uses bp_update_is_item_admin()
@@ -90,14 +130,28 @@ function bp_activity_screen_groups() {
90
  return false;
91
 
92
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
 
 
 
 
 
 
93
  do_action( 'bp_activity_screen_groups' );
 
 
 
 
 
 
 
 
94
  bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) );
95
  }
96
 
97
  /**
98
  * Load the 'Favorites' activity page.
99
  *
100
- * @since BuddyPress (1.2)
101
  *
102
  * @uses bp_update_is_item_admin()
103
  * @uses bp_current_user_can()
@@ -107,14 +161,28 @@ function bp_activity_screen_groups() {
107
  */
108
  function bp_activity_screen_favorites() {
109
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
 
 
 
 
 
 
110
  do_action( 'bp_activity_screen_favorites' );
 
 
 
 
 
 
 
 
111
  bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) );
112
  }
113
 
114
  /**
115
  * Load the 'Mentions' activity page.
116
  *
117
- * @since BuddyPress (1.2)
118
  *
119
  * @uses bp_update_is_item_admin()
120
  * @uses bp_current_user_can()
@@ -124,14 +192,28 @@ function bp_activity_screen_favorites() {
124
  */
125
  function bp_activity_screen_mentions() {
126
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
 
 
 
 
 
 
127
  do_action( 'bp_activity_screen_mentions' );
 
 
 
 
 
 
 
 
128
  bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
129
  }
130
 
131
  /**
132
  * Reset the logged-in user's new mentions data when he visits his mentions screen.
133
  *
134
- * @since BuddyPress (1.5)
135
  *
136
  * @uses bp_is_my_profile()
137
  * @uses bp_activity_clear_new_mentions()
@@ -146,7 +228,7 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
146
  /**
147
  * Load the page for a single activity item.
148
  *
149
- * @since BuddyPress (1.2)
150
  *
151
  * @global object $bp BuddyPress global settings
152
  * @uses bp_is_activity_component()
@@ -218,10 +300,23 @@ function bp_activity_screen_single_activity_permalink() {
218
  }
219
  }
220
 
221
- // Allow access to be filtered
 
 
 
 
 
 
222
  $has_access = apply_filters_ref_array( 'bp_activity_permalink_access', array( $has_access, &$activity ) );
223
 
224
- // Allow additional code execution
 
 
 
 
 
 
 
225
  do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
226
 
227
  // Access is specifically disallowed
@@ -231,11 +326,26 @@ function bp_activity_screen_single_activity_permalink() {
231
  bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
232
 
233
  // Redirect based on logged in status
234
- is_user_logged_in() ?
235
- bp_core_redirect( bp_loggedin_user_domain() ) :
236
- bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . esc_url( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . bp_current_action() . '/' ) ) );
 
 
 
 
 
 
 
 
237
  }
238
 
 
 
 
 
 
 
 
239
  bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
240
  }
241
  add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
@@ -243,7 +353,7 @@ add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
243
  /**
244
  * Add activity notifications settings to the notifications settings page.
245
  *
246
- * @since BuddyPress (1.2)
247
  *
248
  * @uses bp_get_user_meta()
249
  * @uses bp_core_get_username()
@@ -290,7 +400,14 @@ function bp_activity_screen_notification_settings() {
290
  <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php checked( $reply, 'no', true ) ?>/></td>
291
  </tr>
292
 
293
- <?php do_action( 'bp_activity_screen_notification_settings' ) ?>
 
 
 
 
 
 
 
294
  </tbody>
295
  </table>
296
 
@@ -298,22 +415,22 @@ function bp_activity_screen_notification_settings() {
298
  }
299
  add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
300
 
301
- /** Theme Compatability *******************************************************/
302
 
303
  /**
304
  * The main theme compat class for BuddyPress Activity.
305
  *
306
- * This class sets up the necessary theme compatability actions to safely output
307
  * activity template parts to the_title and the_content areas of a theme.
308
  *
309
- * @since BuddyPress (1.7)
310
  */
311
  class BP_Activity_Theme_Compat {
312
 
313
  /**
314
  * Set up the activity component theme compatibility.
315
  *
316
- * @since BuddyPress (1.7)
317
  */
318
  public function __construct() {
319
  add_action( 'bp_setup_theme_compat', array( $this, 'is_activity' ) );
@@ -322,7 +439,7 @@ class BP_Activity_Theme_Compat {
322
  /**
323
  * Set up the theme compatibility hooks, if we're looking at an activity page.
324
  *
325
- * @since BuddyPress (1.7)
326
  */
327
  public function is_activity() {
328
 
@@ -334,6 +451,7 @@ class BP_Activity_Theme_Compat {
334
  if ( ! bp_displayed_user_id() && ! bp_current_action() ) {
335
  bp_update_is_directory( true, 'activity' );
336
 
 
337
  do_action( 'bp_activity_screen_index' );
338
 
339
  add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) );
@@ -355,13 +473,20 @@ class BP_Activity_Theme_Compat {
355
  *
356
  * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
357
  *
358
- * @since BuddyPress (1.8)
359
  *
360
  * @param string $templates The templates from bp_get_theme_compat_templates().
361
  * @return array $templates Array of custom templates to look for.
362
  */
363
  public function directory_template_hierarchy( $templates ) {
364
- // Setup our templates based on priority
 
 
 
 
 
 
 
365
  $new_templates = apply_filters( 'bp_template_hierarchy_activity_directory', array(
366
  'activity/index-directory.php'
367
  ) );
@@ -376,7 +501,7 @@ class BP_Activity_Theme_Compat {
376
  /**
377
  * Update the global $post with directory data.
378
  *
379
- * @since BuddyPress (1.7)
380
  */
381
  public function directory_dummy_post() {
382
  bp_theme_compat_reset_post( array(
@@ -395,7 +520,7 @@ class BP_Activity_Theme_Compat {
395
  /**
396
  * Filter the_content with the groups index template part.
397
  *
398
- * @since BuddyPress (1.7)
399
  */
400
  public function directory_content() {
401
  return bp_buffer_template_part( 'activity/index', null, false );
@@ -408,13 +533,20 @@ class BP_Activity_Theme_Compat {
408
  *
409
  * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
410
  *
411
- * @since BuddyPress (1.8)
412
  *
413
  * @param string $templates The templates from bp_get_theme_compat_templates().
414
  * @return array $templates Array of custom templates to look for.
415
  */
416
  public function single_template_hierarchy( $templates ) {
417
- // Setup our templates based on priority
 
 
 
 
 
 
 
418
  $new_templates = apply_filters( 'bp_template_hierarchy_activity_single_item', array(
419
  'activity/single/index.php'
420
  ) );
@@ -429,7 +561,7 @@ class BP_Activity_Theme_Compat {
429
  /**
430
  * Update the global $post with the displayed user's data.
431
  *
432
- * @since BuddyPress (1.7)
433
  */
434
  public function single_dummy_post() {
435
  bp_theme_compat_reset_post( array(
@@ -448,7 +580,7 @@ class BP_Activity_Theme_Compat {
448
  /**
449
  * Filter the_content with the members' activity permalink template part.
450
  *
451
- * @since BuddyPress (1.7)
452
  */
453
  public function single_dummy_content() {
454
  return bp_buffer_template_part( 'activity/single/home', null, false );
17
  /**
18
  * Load the Activity directory.
19
  *
20
+ * @since BuddyPress (1.5.0)
21
  *
22
  * @uses bp_displayed_user_id()
23
  * @uses bp_is_activity_component()
31
  if ( bp_is_activity_directory() ) {
32
  bp_update_is_directory( true, 'activity' );
33
 
34
+ /**
35
+ * Fires right before the loading of the Activity directory screen template file.
36
+ *
37
+ * @since BuddyPress (1.5.0)
38
+ */
39
  do_action( 'bp_activity_screen_index' );
40
 
41
+ /**
42
+ * Filters the template to load for the Activity directory screen.
43
+ *
44
+ * @since BuddyPress (1.5.0)
45
+ *
46
+ * @param string $template Path to the activity template to load.
47
+ */
48
  bp_core_load_template( apply_filters( 'bp_activity_screen_index', 'activity/index' ) );
49
  }
50
  }
53
  /**
54
  * Load the 'My Activity' page.
55
  *
56
+ * @since BuddyPress (1.0.0)
57
  *
58
  * @uses do_action() To call the 'bp_activity_screen_my_activity' hook.
59
  * @uses bp_core_load_template()
60
  * @uses apply_filters() To call the 'bp_activity_template_my_activity' hook.
61
  */
62
  function bp_activity_screen_my_activity() {
63
+
64
+ /**
65
+ * Fires right before the loading of the "My Activity" screen template file.
66
+ *
67
+ * @since BuddyPress (1.0.0)
68
+ */
69
  do_action( 'bp_activity_screen_my_activity' );
70
+
71
+ /**
72
+ * Filters the template to load for the "My Activity" screen.
73
+ *
74
+ * @since BuddyPress (1.0.0)
75
+ *
76
+ * @param string $template Path to the activity template to load.
77
+ */
78
  bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) );
79
  }
80
 
81
  /**
82
  * Load the 'My Friends' activity page.
83
  *
84
+ * @since BuddyPress (1.0.0)
85
  *
86
  * @uses bp_is_active()
87
  * @uses bp_update_is_item_admin()
95
  return false;
96
 
97
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
98
+
99
+ /**
100
+ * Fires right before the loading of the "My Friends" screen template file.
101
+ *
102
+ * @since BuddyPress (1.2.0)
103
+ */
104
  do_action( 'bp_activity_screen_friends' );
105
+
106
+ /**
107
+ * Filters the template to load for the "My Friends" screen.
108
+ *
109
+ * @since BuddyPress (1.0.0)
110
+ *
111
+ * @param string $template Path to the activity template to load.
112
+ */
113
  bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) );
114
  }
115
 
116
  /**
117
  * Load the 'My Groups' activity page.
118
  *
119
+ * @since BuddyPress (1.2.0)
120
  *
121
  * @uses bp_is_active()
122
  * @uses bp_update_is_item_admin()
130
  return false;
131
 
132
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
133
+
134
+ /**
135
+ * Fires right before the loading of the "My Groups" screen template file.
136
+ *
137
+ * @since BuddyPress (1.2.0)
138
+ */
139
  do_action( 'bp_activity_screen_groups' );
140
+
141
+ /**
142
+ * Filters the template to load for the "My Groups" screen.
143
+ *
144
+ * @since BuddyPress (1.2.0)
145
+ *
146
+ * @param string $template Path to the activity template to load.
147
+ */
148
  bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) );
149
  }
150
 
151
  /**
152
  * Load the 'Favorites' activity page.
153
  *
154
+ * @since BuddyPress (1.2.0)
155
  *
156
  * @uses bp_update_is_item_admin()
157
  * @uses bp_current_user_can()
161
  */
162
  function bp_activity_screen_favorites() {
163
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
164
+
165
+ /**
166
+ * Fires right before the loading of the "Favorites" screen template file.
167
+ *
168
+ * @since BuddyPress (1.2.0)
169
+ */
170
  do_action( 'bp_activity_screen_favorites' );
171
+
172
+ /**
173
+ * Filters the template to load for the "Favorites" screen.
174
+ *
175
+ * @since BuddyPress (1.2.0)
176
+ *
177
+ * @param string $template Path to the activity template to load.
178
+ */
179
  bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) );
180
  }
181
 
182
  /**
183
  * Load the 'Mentions' activity page.
184
  *
185
+ * @since BuddyPress (1.2.0)
186
  *
187
  * @uses bp_update_is_item_admin()
188
  * @uses bp_current_user_can()
192
  */
193
  function bp_activity_screen_mentions() {
194
  bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
195
+
196
+ /**
197
+ * Fires right before the loading of the "Mentions" screen template file.
198
+ *
199
+ * @since BuddyPress (1.2.0)
200
+ */
201
  do_action( 'bp_activity_screen_mentions' );
202
+
203
+ /**
204
+ * Filters the template to load for the "Mentions" screen.
205
+ *
206
+ * @since BuddyPress (1.2.0)
207
+ *
208
+ * @param string $template Path to the activity template to load.
209
+ */
210
  bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
211
  }
212
 
213
  /**
214
  * Reset the logged-in user's new mentions data when he visits his mentions screen.
215
  *
216
+ * @since BuddyPress (1.5.0)
217
  *
218
  * @uses bp_is_my_profile()
219
  * @uses bp_activity_clear_new_mentions()
228
  /**
229
  * Load the page for a single activity item.
230
  *
231
+ * @since BuddyPress (1.2.0)
232
  *
233
  * @global object $bp BuddyPress global settings
234
  * @uses bp_is_activity_component()
300
  }
301
  }
302
 
303
+ /**
304
+ * Filters the access permission for a single activity view.
305
+ *
306
+ * @since BuddyPress (1.2.0)
307
+ *
308
+ * @param array $access Array holding the current $has_access value and current activity item instance.
309
+ */
310
  $has_access = apply_filters_ref_array( 'bp_activity_permalink_access', array( $has_access, &$activity ) );
311
 
312
+ /**
313
+ * Fires before the loading of a single activity template file.
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
 
322
  // Access is specifically disallowed
326
  bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
327
 
328
  // Redirect based on logged in status
329
+ if ( is_user_logged_in() ) {
330
+ $url = bp_loggedin_user_domain();
331
+
332
+ } else {
333
+ $url = sprintf(
334
+ site_url( 'wp-login.php?redirect_to=%s' ),
335
+ urlencode( esc_url_raw( bp_activity_get_permalink( (int) bp_current_action() ) ) )
336
+ );
337
+ }
338
+
339
+ bp_core_redirect( $url );
340
  }
341
 
342
+ /**
343
+ * Filters the template to load for a single activity screen.
344
+ *
345
+ * @since BuddyPress (1.0.0)
346
+ *
347
+ * @param string $template Path to the activity template to load.
348
+ */
349
  bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
350
  }
351
  add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
353
  /**
354
  * Add activity notifications settings to the notifications settings page.
355
  *
356
+ * @since BuddyPress (1.2.0)
357
  *
358
  * @uses bp_get_user_meta()
359
  * @uses bp_core_get_username()
400
  <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php checked( $reply, 'no', true ) ?>/></td>
401
  </tr>
402
 
403
+ <?php
404
+
405
+ /**
406
+ * Fires inside the closing </tbody> tag for activity screen notification settings.
407
+ *
408
+ * @since BuddyPress (1.2.0)
409
+ */
410
+ do_action( 'bp_activity_screen_notification_settings' ) ?>
411
  </tbody>
412
  </table>
413
 
415
  }
416
  add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
417
 
418
+ /** Theme Compatibility *******************************************************/
419
 
420
  /**
421
  * The main theme compat class for BuddyPress Activity.
422
  *
423
+ * This class sets up the necessary theme compatibility actions to safely output
424
  * activity template parts to the_title and the_content areas of a theme.
425
  *
426
+ * @since BuddyPress (1.7.0)
427
  */
428
  class BP_Activity_Theme_Compat {
429
 
430
  /**
431
  * Set up the activity component theme compatibility.
432
  *
433
+ * @since BuddyPress (1.7.0)
434
  */
435
  public function __construct() {
436
  add_action( 'bp_setup_theme_compat', array( $this, 'is_activity' ) );
439
  /**
440
  * Set up the theme compatibility hooks, if we're looking at an activity page.
441
  *
442
+ * @since BuddyPress (1.7.0)
443
  */
444
  public function is_activity() {
445
 
451
  if ( ! bp_displayed_user_id() && ! bp_current_action() ) {
452
  bp_update_is_directory( true, 'activity' );
453
 
454
+ /** This action is documented in bp-activity/bp-activity-screens.php */
455
  do_action( 'bp_activity_screen_index' );
456
 
457
  add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) );
473
  *
474
  * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
475
  *
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 ) {
482
+
483
+ /**
484
+ * Filters the template hierarchy for the activity directory page.
485
+ *
486
+ * @since BuddyPress (1.8.0)
487
+ *
488
+ * @param array $index-directory Array holding template names to be merged into template list.
489
+ */
490
  $new_templates = apply_filters( 'bp_template_hierarchy_activity_directory', array(
491
  'activity/index-directory.php'
492
  ) );
501
  /**
502
  * Update the global $post with directory data.
503
  *
504
+ * @since BuddyPress (1.7.0)
505
  */
506
  public function directory_dummy_post() {
507
  bp_theme_compat_reset_post( array(
520
  /**
521
  * Filter the_content with the groups index template part.
522
  *
523
+ * @since BuddyPress (1.7.0)
524
  */
525
  public function directory_content() {
526
  return bp_buffer_template_part( 'activity/index', null, false );
533
  *
534
  * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
535
  *
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 ) {
542
+
543
+ /**
544
+ * Filters the template hierarchy for the activity permalink pages.
545
+ *
546
+ * @since BuddyPress (1.8.0)
547
+ *
548
+ * @param array $index Array holding template names to be merged into template list.
549
+ */
550
  $new_templates = apply_filters( 'bp_template_hierarchy_activity_single_item', array(
551
  'activity/single/index.php'
552
  ) );
561
  /**
562
  * Update the global $post with the displayed user's data.
563
  *
564
+ * @since BuddyPress (1.7.0)
565
  */
566
  public function single_dummy_post() {
567
  bp_theme_compat_reset_post( array(
580
  /**
581
  * Filter the_content with the members' activity permalink template part.
582
  *
583
+ * @since BuddyPress (1.7.0)
584
  */
585
  public function single_dummy_content() {
586
  return bp_buffer_template_part( 'activity/single/home', null, false );
bp-activity/bp-activity-template.php CHANGED
@@ -13,7 +13,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
13
  /**
14
  * Output the activity component slug.
15
  *
16
- * @since BuddyPress (1.5)
17
  *
18
  * @uses bp_get_activity_slug()
19
  */
@@ -23,20 +23,28 @@ function bp_activity_slug() {
23
  /**
24
  * Return the activity component slug.
25
  *
26
- * @since BuddyPress (1.5)
27
  *
28
  * @uses apply_filters() To call the 'bp_get_activity_slug' hook.
29
  *
30
  * @return string The activity component slug.
31
  */
32
  function bp_get_activity_slug() {
 
 
 
 
 
 
 
 
33
  return apply_filters( 'bp_get_activity_slug', buddypress()->activity->slug );
34
  }
35
 
36
  /**
37
  * Output the activity component root slug.
38
  *
39
- * @since BuddyPress (1.5)
40
  *
41
  * @uses bp_get_activity_root_slug()
42
  */
@@ -46,20 +54,28 @@ function bp_activity_root_slug() {
46
  /**
47
  * Return the activity component root slug.
48
  *
49
- * @since BuddyPress (1.5)
50
  *
51
  * @uses apply_filters() To call the 'bp_get_activity_root_slug' hook.
52
  *
53
  * @return string The activity component root slug.
54
  */
55
  function bp_get_activity_root_slug() {
 
 
 
 
 
 
 
 
56
  return apply_filters( 'bp_get_activity_root_slug', buddypress()->activity->root_slug );
57
  }
58
 
59
  /**
60
  * Output activity directory permalink.
61
  *
62
- * @since BuddyPress (1.5)
63
  *
64
  * @uses bp_get_activity_directory_permalink()
65
  */
@@ -69,9 +85,9 @@ function bp_activity_directory_permalink() {
69
  /**
70
  * Return activity directory permalink
71
  *
72
- * @since BuddyPress (1.5)
73
  *
74
- * @uses traisingslashit()
75
  * @uses bp_get_root_domain()
76
  * @uses bp_get_activity_root_slug()
77
  * @uses apply_filters() To call the 'bp_get_activity_directory_permalink' hook.
@@ -79,6 +95,14 @@ function bp_activity_directory_permalink() {
79
  * @return string Activity directory permalink.
80
  */
81
  function bp_get_activity_directory_permalink() {
 
 
 
 
 
 
 
 
82
  return apply_filters( 'bp_get_activity_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() ) );
83
  }
84
 
@@ -87,7 +111,7 @@ function bp_activity_directory_permalink() {
87
  *
88
  * This is responsible for loading a group of activity items and displaying them.
89
  *
90
- * @since BuddyPress (1.0)
91
  */
92
  class BP_Activity_Template {
93
  var $current_activity = -1;
@@ -171,14 +195,17 @@ class BP_Activity_Template {
171
  'per_page' => 20,
172
  'page_arg' => 'acpage',
173
  'max' => false,
 
174
  'sort' => false,
175
  'include' => false,
176
  'exclude' => false,
177
  'in' => false,
178
  'filter' => false,
 
179
  'search_terms' => false,
180
  'meta_query' => false,
181
  'date_query' => false,
 
182
  'display_comments' => 'threaded',
183
  'show_hidden' => false,
184
  'spam' => 'ham_only',
@@ -202,6 +229,7 @@ class BP_Activity_Template {
202
  $this->activities = bp_activity_get_specific( array(
203
  'activity_ids' => explode( ',', $include ),
204
  'max' => $max,
 
205
  'page' => $this->pag_page,
206
  'per_page' => $this->pag_num,
207
  'sort' => $sort,
@@ -216,13 +244,16 @@ class BP_Activity_Template {
216
  $this->activities = bp_activity_get( array(
217
  'display_comments' => $display_comments,
218
  'max' => $max,
 
219
  'per_page' => $this->pag_num,
220
  'page' => $this->pag_page,
221
  'sort' => $sort,
222
  'search_terms' => $search_terms,
223
  'meta_query' => $meta_query,
224
  'date_query' => $date_query,
 
225
  'filter' => $filter,
 
226
  'show_hidden' => $show_hidden,
227
  'exclude' => $exclude,
228
  'in' => $in,
@@ -283,7 +314,8 @@ class BP_Activity_Template {
283
  'current' => (int) $this->pag_page,
284
  'prev_text' => _x( '&larr;', 'Activity pagination previous text', 'buddypress' ),
285
  'next_text' => _x( '&rarr;', 'Activity pagination next text', 'buddypress' ),
286
- 'mid_size' => 1
 
287
  ) );
288
  }
289
  }
@@ -340,7 +372,13 @@ class BP_Activity_Template {
340
  if ( $this->current_activity + 1 < $this->activity_count ) {
341
  return true;
342
  } elseif ( $this->current_activity + 1 == $this->activity_count ) {
343
- do_action('activity_loop_end');
 
 
 
 
 
 
344
  // Do some cleaning up after the loop
345
  $this->rewind_activities();
346
  }
@@ -366,8 +404,15 @@ class BP_Activity_Template {
366
  if ( is_array( $this->activity ) )
367
  $this->activity = (object) $this->activity;
368
 
369
- if ( $this->current_activity == 0 ) // loop has just started
 
 
 
 
 
 
370
  do_action('activity_loop_start');
 
371
  }
372
  }
373
 
@@ -378,7 +423,7 @@ class BP_Activity_Template {
378
  * $activities_template global, enabling the use of BuddyPress templates and
379
  * template functions to display a list of activity items.
380
  *
381
- * @since BuddyPress (1.0)
382
  *
383
  * @global object $activities_template {@link BP_Activity_Template}
384
  * @global object $bp BuddyPress global settings.
@@ -395,108 +440,88 @@ class BP_Activity_Template {
395
  * @uses apply_filters() To call the 'bp_has_activities' hook.
396
  *
397
  * @param array $args {
398
- * Arguments for limiting the contents of the activity loop. Most
399
- * arguments are in the same format as {@link BP_Activity_Activity::get()}.
400
- * However, because the format of the arguments accepted here differs in
401
- * a number of ways, and because bp_has_activities() determines some
402
- * default arguments in a dynamic fashion, we list all accepted arguments
403
- * here as well.
404
- *
405
- * Arguments can be passed as an associative array, or as a URL query
406
- * string (eg, 'user_id=4&display_comments=threaded').
407
- *
408
- * @type int $page Which page of results to fetch. Using page=1 without
409
- * per_page will result in no pagination. Default: 1.
410
- * @type int|bool $per_page Number of results per page. Default: 20.
411
- * @type string $page_arg The string used as a query parameter in
412
- * pagination links. Default: 'acpage'.
413
- * @type int|bool $max Maximum number of results to return.
414
- * Default: false (unlimited).
415
- * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
416
- * @type array|bool $exclude Array of activity IDs to exclude. Default: false.
417
- * @type array|bool $in Array of IDs to limit query by (IN). 'in' is
418
- * intended to be used in conjunction with other filter parameters.
419
- * Default: false.
420
- * @type array|bool $include Array of exact activity IDs to query.
421
- * Providing an 'include' array will override all other filters
422
- * passed in the argument array. When viewing a the permalink page
423
- * for a single activity item, this value defaults to the ID of that
424
- * item. Otherwise the default is false.
425
- * @type array $meta_query Limit by activitymeta by passing an array of
426
- * meta_query conditions. See {@link WP_Meta_Query::queries} for a
427
- * description of the syntax.
428
- * @type string $search_terms Limit results by a search term. Default: false.
429
- * @type string|bool $scope Use one of BuddyPress's pre-built filters. In
430
- * each case, the term 'current user' refers to the displayed user
431
- * when looking at a user profile, and otherwise to the logged-in user.
432
- * - 'just-me' retrieves items belonging only to the logged-in user;
433
- * this is equivalent to passing a 'user_id' argument
434
- * - 'friends' retrieves items belonging to the friends of the
435
- * current user
436
- * - 'groups' retrieves items associated with the groups to which
437
- * the current user belongs
438
- * - 'favorites' retrieves the current user's favorited activity
439
- * items
440
- * - 'mentions' retrieves activity items where the current user has
441
- * received an @-mention
442
- * The default value of 'scope' is set to one of the above if that
443
- * value appears in the appropriate place in the URL; eg, 'scope' will
444
- * be 'groups' when visiting http://example.com/members/joe/activity/groups/.
445
- * Otherwise defaults to false.
446
- * @type int|array|bool $user_id The ID(s) of user(s) whose activity should
447
- * be fetched. Pass a single ID or an array of IDs. When viewing a
448
- * user profile page (but not that user's activity subpages, ie My
449
- * Friends, My Groups, etc), 'user_id' defaults to the ID of the
450
- * displayed user. Otherwise the default is false.
451
- * @type string|array|bool $object Filters by the `component` column in the
452
- * database, which is generally the component ID in the case of
453
- * BuddyPress components, or the plugin slug in the case of plugins.
454
- * For example, 'groups' will limit results to those that are
455
- * associated with the BP Groups component. Accepts a single
456
- * component string, or an array of multiple components. Defaults to
457
- * 'groups' when viewing the page of a single group, the My Groups
458
- * activity filter, or the Activity > Groups filter of a user profile.
459
- * Otherwise defaults to false.
460
- * @type string|array|bool $action Filters by the `type` column in the
461
- * database, which is a string categorizing the activity item (eg,
462
- * 'new_blog_post', 'created_group'). Accepts a single type string,
463
- * or an array of multiple types. Defaults to false.
464
- * @type int|array|bool $primary_id Filters by the `item_id` column in the
465
- * database. The meaning of 'primary_id' differs between components/
466
- * types; for example, in the case of 'created_group', 'primary_id'
467
- * is the ID of the group. Accepts a single ID, or an array of
468
- * multiple IDs. When viewing a single group, defaults to the current
469
- * group ID. When viewing a user's Groups stream page, defaults to
470
- * the IDs of the user's groups. Otherwise defaults to false.
471
- * @type int|array|bool $secondary_id Filters by the `secondary_item_id`
472
- * column in the database. The meaning of 'secondary_id' differs
473
- * between components/types. Accepts a single ID, or an array of
474
- * multiple IDs. Defaults to false.
475
- * @type int $offset Return only activity items with an ID greater than or
476
- * equal to this one. Note that providing an offset will disable
477
- * pagination. Default: false.
478
- * @type string|bool $display_comments How to handle activity comments.
479
- * Possible values:
480
- * - 'threaded' - comments appear in a threaded tree, under their
481
- * parent items
482
- * - 'stream' - the activity stream is presented in a flat manner,
483
- * with comments sorted in chronological order alongside other
484
- * activity items
485
- * - false - don't fetch activity comments at all
486
- * Default: 'threaded'.
487
- * @type bool $show_hidden Whether to show items marked hide_sitewide.
488
- * Defaults to false, except in the following cases:
489
- * - User is viewing his own activity stream
490
- * - User is viewing the activity stream of a non-public group of
491
- * which he is a member
492
- * @type bool $show_hidden Normally defaults to false, except when:
493
- * - a user is viewing his own activity stream
494
- * - a user is viewing the activity stream of a non-public group of
495
- * which he is a member
496
- * @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false
497
- * to show all activity regardless of spam status. Default: 'ham_only'.
498
- * @type bool $populate_extras Whether to pre-fetch the activity metadata
499
- * for the queried items. Default: true.
500
  * }
501
  * @return bool Returns true when activities are found, otherwise false.
502
  */
@@ -551,6 +576,7 @@ function bp_has_activities( $args = '' ) {
551
  'page' => 1, // which page to load
552
  'per_page' => 20, // number of items per page
553
  'max' => false, // max number to return
 
554
  'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
555
  'spam' => 'ham_only', // Hide spammed items
556
 
@@ -570,6 +596,7 @@ function bp_has_activities( $args = '' ) {
570
 
571
  'meta_query' => false, // filter on activity meta. See WP_Meta_Query for format
572
  'date_query' => false, // filter by date. See first parameter of WP_Date_Query for format
 
573
 
574
  // Searching
575
  'search_terms' => false, // specify terms to search on
@@ -591,65 +618,20 @@ function bp_has_activities( $args = '' ) {
591
  $page = 0;
592
  }
593
 
 
594
  if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) )
595
  $search_terms = $_REQUEST['s'];
596
 
597
- // If you have passed a "scope" then this will override any filters you have passed.
598
- if ( 'just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope ) {
599
- if ( 'just-me' == $scope )
600
- $display_comments = 'stream';
601
-
602
- // determine which user_id applies
603
- if ( empty( $user_id ) )
604
  $user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id();
 
605
 
606
- // are we displaying user specific activity?
607
- if ( is_numeric( $user_id ) ) {
608
- $show_hidden = ( $user_id == bp_loggedin_user_id() && $scope != 'friends' ) ? 1 : 0;
609
-
610
- switch ( $scope ) {
611
- case 'friends':
612
- if ( bp_is_active( 'friends' ) )
613
- $friends = friends_get_friend_user_ids( $user_id );
614
- if ( empty( $friends ) )
615
- return false;
616
-
617
- $user_id = implode( ',', (array) $friends );
618
- break;
619
- case 'groups':
620
- if ( bp_is_active( 'groups' ) ) {
621
- $groups = groups_get_user_groups( $user_id );
622
- if ( empty( $groups['groups'] ) )
623
- return false;
624
-
625
- $object = $bp->groups->id;
626
- $primary_id = implode( ',', (array) $groups['groups'] );
627
-
628
- $user_id = 0;
629
- }
630
- break;
631
- case 'favorites':
632
- $favs = bp_activity_get_user_favorites( $user_id );
633
- if ( empty( $favs ) )
634
- return false;
635
-
636
- $in = implode( ',', (array) $favs );
637
- $display_comments = true;
638
- $user_id = 0;
639
- break;
640
- case 'mentions':
641
-
642
- // Are mentions disabled?
643
- if ( ! bp_activity_do_mentions() ) {
644
- return false;
645
- }
646
-
647
- // Start search at @ symbol and stop search at closing tag delimiter.
648
- $search_terms = '@' . bp_activity_get_user_mentionname( $user_id ) . '<';
649
- $display_comments = 'stream';
650
- $user_id = 0;
651
- break;
652
- }
653
  }
654
  }
655
 
@@ -657,12 +639,20 @@ function bp_has_activities( $args = '' ) {
657
  if ( !empty( $max ) && ( (int) $per_page > (int) $max ) )
658
  $per_page = $max;
659
 
660
- // Support for basic filters in earlier BP versions is disabled by default. To enable, put
661
- // add_filter( 'bp_activity_enable_afilter_support', '__return_true' );
662
- // into bp-custom.php or your theme's functions.php
 
 
 
 
 
 
 
 
663
  if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) )
664
  $filter = array( 'object' => $_GET['afilter'] );
665
- else if ( ! empty( $user_id ) || ! empty( $object ) || ! empty( $action ) || ! empty( $primary_id ) || ! empty( $secondary_id ) || ! empty( $offset ) || ! empty( $since ) )
666
  $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id, 'offset' => $offset, 'since' => $since );
667
  else
668
  $filter = false;
@@ -676,14 +666,17 @@ function bp_has_activities( $args = '' ) {
676
  'per_page' => $per_page,
677
  'page_arg' => $page_arg,
678
  'max' => $max,
 
679
  'sort' => $sort,
680
  'include' => $include,
681
  'exclude' => $exclude,
682
  'in' => $in,
683
  'filter' => $filter,
 
684
  'search_terms' => $search_terms,
685
  'meta_query' => $meta_query,
686
  'date_query' => $date_query,
 
687
  'display_comments' => $display_comments,
688
  'show_hidden' => $show_hidden,
689
  'spam' => $spam,
@@ -692,13 +685,22 @@ function bp_has_activities( $args = '' ) {
692
 
693
  $activities_template = new BP_Activity_Template( $template_args );
694
 
 
 
 
 
 
 
 
 
 
695
  return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template, $template_args );
696
  }
697
 
698
  /**
699
  * Determine if there are still activities left in the loop.
700
  *
701
- * @since BuddyPress (1.0)
702
  *
703
  * @global object $activities_template {@link BP_Activity_Template}
704
  * @uses BP_Activity_Template::user_activities() {@link BP_Activity_Template::user_activities()}
@@ -713,7 +715,7 @@ function bp_activities() {
713
  /**
714
  * Get the current activity object in the loop.
715
  *
716
- * @since BuddyPress (1.0)
717
  *
718
  * @global object $activities_template {@link BP_Activity_Template}
719
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
@@ -739,13 +741,20 @@ function bp_activity_load_more_link() {
739
  $link = bp_get_requested_url();
740
  $link = add_query_arg( $activities_template->pag_arg, $activities_template->pag_page + 1, $link );
741
 
 
 
 
 
 
 
 
742
  return apply_filters( 'bp_get_activity_load_more_link', $link );
743
  }
744
 
745
  /**
746
  * Output the activity pagination count.
747
  *
748
- * @since BuddyPress (1.0)
749
  *
750
  * @global object $activities_template {@link BP_Activity_Template}
751
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
@@ -757,7 +766,7 @@ function bp_activity_pagination_count() {
757
  /**
758
  * Return the activity pagination count.
759
  *
760
- * @since BuddyPress (1.2)
761
  *
762
  * @global object $activities_template {@link BP_Activity_Template}
763
  * @uses bp_core_number_format()
@@ -778,7 +787,7 @@ function bp_activity_pagination_count() {
778
  /**
779
  * Output the activity pagination links.
780
  *
781
- * @since BuddyPress (1.0)
782
  *
783
  * @uses bp_get_activity_pagination_links()
784
  */
@@ -789,7 +798,7 @@ function bp_activity_pagination_links() {
789
  /**
790
  * Return the activity pagination links.
791
  *
792
- * @since BuddyPress (1.0)
793
  *
794
  * @global object $activities_template {@link BP_Activity_Template}
795
  * @uses apply_filters() To call the 'bp_get_activity_pagination_links' hook.
@@ -799,13 +808,20 @@ function bp_activity_pagination_links() {
799
  function bp_get_activity_pagination_links() {
800
  global $activities_template;
801
 
 
 
 
 
 
 
 
802
  return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
803
  }
804
 
805
  /**
806
  * Return true when there are more activity items to be shown than currently appear.
807
  *
808
- * @since BuddyPress (1.5)
809
  *
810
  * @global object $activities_template {@link BP_Activity_Template}
811
  * @uses apply_filters() To call the 'bp_activity_has_more_items' hook.
@@ -827,13 +843,20 @@ function bp_activity_has_more_items() {
827
  $has_more_items = (int) $remaining_pages > 0;
828
  }
829
 
 
 
 
 
 
 
 
830
  return apply_filters( 'bp_activity_has_more_items', $has_more_items );
831
  }
832
 
833
  /**
834
  * Output the activity count.
835
  *
836
- * @since BuddyPress (1.2)
837
  *
838
  * @uses bp_get_activity_count()
839
  */
@@ -844,7 +867,7 @@ function bp_activity_count() {
844
  /**
845
  * Return the activity count.
846
  *
847
- * @since BuddyPress (1.2)
848
  *
849
  * @global object $activities_template {@link BP_Activity_Template}
850
  * @uses apply_filters() To call the 'bp_get_activity_count' hook.
@@ -854,13 +877,20 @@ function bp_activity_count() {
854
  function bp_get_activity_count() {
855
  global $activities_template;
856
 
 
 
 
 
 
 
 
857
  return apply_filters( 'bp_get_activity_count', (int) $activities_template->activity_count );
858
  }
859
 
860
  /**
861
  * Output the number of activities per page.
862
  *
863
- * @since BuddyPress (1.2)
864
  *
865
  * @uses bp_get_activity_per_page()
866
  */
@@ -871,7 +901,7 @@ function bp_activity_per_page() {
871
  /**
872
  * Return the number of activities per page.
873
  *
874
- * @since BuddyPress (1.2)
875
  *
876
  * @global object $activities_template {@link BP_Activity_Template}
877
  * @uses apply_filters() To call the 'bp_get_activity_per_page' hook.
@@ -881,13 +911,20 @@ function bp_activity_per_page() {
881
  function bp_get_activity_per_page() {
882
  global $activities_template;
883
 
 
 
 
 
 
 
 
884
  return apply_filters( 'bp_get_activity_per_page', (int) $activities_template->pag_num );
885
  }
886
 
887
  /**
888
  * Output the activities title.
889
  *
890
- * @since BuddyPress (1.0)
891
  *
892
  * @uses bp_get_activities_title()
893
  * @todo Deprecate.
@@ -899,24 +936,31 @@ function bp_activities_title() {
899
  /**
900
  * Return the activities title.
901
  *
902
- * @since BuddyPress (1.0)
903
  *
904
  * @global string $bp_activity_title
905
  * @uses apply_filters() To call the 'bp_get_activities_title' hook.
906
  * @todo Deprecate.
907
  *
908
- * @return int The activities title.
909
  */
910
  function bp_get_activities_title() {
911
  global $bp_activity_title;
912
 
 
 
 
 
 
 
 
913
  return apply_filters( 'bp_get_activities_title', $bp_activity_title );
914
  }
915
 
916
  /**
917
  * {@internal Missing Description}
918
  *
919
- * @since BuddyPress (1.0)
920
  *
921
  * @uses bp_get_activities_no_activity()
922
  * @todo Deprecate.
@@ -928,7 +972,7 @@ function bp_activities_no_activity() {
928
  /**
929
  * {@internal Missing Description}
930
  *
931
- * @since BuddyPress (1.0)
932
  *
933
  * @global string $bp_activity_no_activity
934
  * @uses apply_filters() To call the 'bp_get_activities_no_activity' hook
@@ -939,13 +983,20 @@ function bp_activities_no_activity() {
939
  function bp_get_activities_no_activity() {
940
  global $bp_activity_no_activity;
941
 
 
 
 
 
 
 
 
942
  return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
943
  }
944
 
945
  /**
946
  * Output the activity ID.
947
  *
948
- * @since BuddyPress (1.2)
949
  *
950
  * @uses bp_get_activity_id()
951
  */
@@ -956,7 +1007,7 @@ function bp_activity_id() {
956
  /**
957
  * Return the activity ID.
958
  *
959
- * @since BuddyPress (1.2)
960
  *
961
  * @global object $activities_template {@link BP_Activity_Template}
962
  * @uses apply_filters() To call the 'bp_get_activity_id' hook.
@@ -965,13 +1016,21 @@ function bp_activity_id() {
965
  */
966
  function bp_get_activity_id() {
967
  global $activities_template;
 
 
 
 
 
 
 
 
968
  return apply_filters( 'bp_get_activity_id', $activities_template->activity->id );
969
  }
970
 
971
  /**
972
  * Output the activity item ID.
973
  *
974
- * @since BuddyPress (1.2)
975
  *
976
  * @uses bp_get_activity_item_id()
977
  */
@@ -982,7 +1041,7 @@ function bp_activity_item_id() {
982
  /**
983
  * Return the activity item ID.
984
  *
985
- * @since BuddyPress (1.2)
986
  *
987
  * @global object $activities_template {@link BP_Activity_Template}
988
  * @uses apply_filters() To call the 'bp_get_activity_item_id' hook.
@@ -991,13 +1050,21 @@ function bp_activity_item_id() {
991
  */
992
  function bp_get_activity_item_id() {
993
  global $activities_template;
 
 
 
 
 
 
 
 
994
  return apply_filters( 'bp_get_activity_item_id', $activities_template->activity->item_id );
995
  }
996
 
997
  /**
998
  * Output the activity secondary item ID.
999
  *
1000
- * @since BuddyPress (1.2)
1001
  *
1002
  * @uses bp_get_activity_secondary_item_id()
1003
  */
@@ -1008,7 +1075,7 @@ function bp_activity_secondary_item_id() {
1008
  /**
1009
  * Return the activity secondary item ID.
1010
  *
1011
- * @since BuddyPress (1.2)
1012
  *
1013
  * @global object $activities_template {@link BP_Activity_Template}
1014
  * @uses apply_filters() To call the 'bp_get_activity_secondary_item_id' hook.
@@ -1017,13 +1084,21 @@ function bp_activity_secondary_item_id() {
1017
  */
1018
  function bp_get_activity_secondary_item_id() {
1019
  global $activities_template;
 
 
 
 
 
 
 
 
1020
  return apply_filters( 'bp_get_activity_secondary_item_id', $activities_template->activity->secondary_item_id );
1021
  }
1022
 
1023
  /**
1024
  * Output the date the activity was recorded.
1025
  *
1026
- * @since BuddyPress (1.2)
1027
  *
1028
  * @uses bp_get_activity_date_recorded()
1029
  */
@@ -1034,7 +1109,7 @@ function bp_activity_date_recorded() {
1034
  /**
1035
  * Return the date the activity was recorded.
1036
  *
1037
- * @since BuddyPress (1.2)
1038
  *
1039
  * @global object $activities_template {@link BP_Activity_Template}
1040
  * @uses apply_filters() To call the 'bp_get_activity_date_recorded' hook.
@@ -1043,6 +1118,14 @@ function bp_activity_date_recorded() {
1043
  */
1044
  function bp_get_activity_date_recorded() {
1045
  global $activities_template;
 
 
 
 
 
 
 
 
1046
  return apply_filters( 'bp_get_activity_date_recorded', $activities_template->activity->date_recorded );
1047
  }
1048
 
@@ -1074,13 +1157,20 @@ function bp_activity_member_display_name() {
1074
  ? $activities_template->activity->display_name
1075
  : '';
1076
 
 
 
 
 
 
 
 
1077
  return apply_filters( 'bp_get_activity_member_display_name', $retval );
1078
  }
1079
 
1080
  /**
1081
  * Output the activity object name.
1082
  *
1083
- * @since BuddyPress (1.2)
1084
  *
1085
  * @uses bp_get_activity_object_name()
1086
  */
@@ -1091,7 +1181,7 @@ function bp_activity_object_name() {
1091
  /**
1092
  * Return the activity object name.
1093
  *
1094
- * @since BuddyPress (1.2)
1095
  *
1096
  * @global object $activities_template {@link BP_Activity_Template}
1097
  * @uses apply_filters() To call the 'bp_get_activity_object_name' hook.
@@ -1100,13 +1190,21 @@ function bp_activity_object_name() {
1100
  */
1101
  function bp_get_activity_object_name() {
1102
  global $activities_template;
 
 
 
 
 
 
 
 
1103
  return apply_filters( 'bp_get_activity_object_name', $activities_template->activity->component );
1104
  }
1105
 
1106
  /**
1107
  * Output the activity type.
1108
  *
1109
- * @since BuddyPress (1.2)
1110
  *
1111
  * @uses bp_get_activity_type()
1112
  */
@@ -1117,7 +1215,7 @@ function bp_activity_type() {
1117
  /**
1118
  * Return the activity type.
1119
  *
1120
- * @since BuddyPress (1.2)
1121
  *
1122
  * @global object $activities_template {@link BP_Activity_Template}
1123
  * @uses apply_filters() To call the 'bp_get_activity_type' hook.
@@ -1126,6 +1224,14 @@ function bp_activity_type() {
1126
  */
1127
  function bp_get_activity_type() {
1128
  global $activities_template;
 
 
 
 
 
 
 
 
1129
  return apply_filters( 'bp_get_activity_type', $activities_template->activity->type );
1130
  }
1131
 
@@ -1134,8 +1240,8 @@ function bp_activity_type() {
1134
  *
1135
  * Just a wrapper for bp_activity_type().
1136
  *
1137
- * @since BuddyPress (1.2)
1138
- * @deprecated BuddyPress (1.5)
1139
  *
1140
  * @todo Properly deprecate in favor of bp_activity_type() and
1141
  * remove redundant echo
@@ -1149,8 +1255,8 @@ function bp_activity_type() {
1149
  *
1150
  * Just a wrapper for bp_get_activity_type().
1151
  *
1152
- * @since BuddyPress (1.2)
1153
- * @deprecated BuddyPress (1.5)
1154
  *
1155
  * @todo Properly deprecate in favor of bp_get_activity_type().
1156
  *
@@ -1163,7 +1269,7 @@ function bp_activity_type() {
1163
  /**
1164
  * Output the activity user ID.
1165
  *
1166
- * @since BuddyPress (1.1)
1167
  *
1168
  * @uses bp_get_activity_user_id()
1169
  */
@@ -1174,7 +1280,7 @@ function bp_activity_user_id() {
1174
  /**
1175
  * Return the activity user ID.
1176
  *
1177
- * @since BuddyPress (1.1)
1178
  *
1179
  * @global object $activities_template {@link BP_Activity_Template}
1180
  * @uses apply_filters() To call the 'bp_get_activity_user_id' hook.
@@ -1183,13 +1289,21 @@ function bp_activity_user_id() {
1183
  */
1184
  function bp_get_activity_user_id() {
1185
  global $activities_template;
 
 
 
 
 
 
 
 
1186
  return apply_filters( 'bp_get_activity_user_id', $activities_template->activity->user_id );
1187
  }
1188
 
1189
  /**
1190
  * Output the activity user link.
1191
  *
1192
- * @since BuddyPress (1.2)
1193
  *
1194
  * @uses bp_get_activity_user_link()
1195
  */
@@ -1200,7 +1314,7 @@ function bp_activity_user_link() {
1200
  /**
1201
  * Return the activity user link.
1202
  *
1203
- * @since BuddyPress (1.2)
1204
  *
1205
  * @global object $activities_template {@link BP_Activity_Template}
1206
  * @uses bp_core_get_user_domain()
@@ -1217,13 +1331,20 @@ function bp_activity_user_link() {
1217
  $link = bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login );
1218
  }
1219
 
 
 
 
 
 
 
 
1220
  return apply_filters( 'bp_get_activity_user_link', $link );
1221
  }
1222
 
1223
  /**
1224
  * Output the avatar of the user that performed the action.
1225
  *
1226
- * @since BuddyPress (1.1)
1227
  *
1228
  * @see bp_get_activity_avatar() for description of arguments.
1229
  * @uses bp_get_activity_avatar()
@@ -1236,7 +1357,7 @@ function bp_activity_avatar( $args = '' ) {
1236
  /**
1237
  * Return the avatar of the user that performed the action.
1238
  *
1239
- * @since BuddyPress (1.1)
1240
  *
1241
  * @see bp_core_fetch_avatar() For a description of the arguments.
1242
  * @global object $activities_template {@link BP_Activity_Template}
@@ -1309,15 +1430,40 @@ function bp_activity_avatar( $args = '' ) {
1309
  }
1310
  }
1311
 
1312
- // Primary activity avatar is always a user, but can be modified via a filter
 
 
 
 
 
 
 
 
 
 
1313
  $object = apply_filters( 'bp_get_activity_avatar_object_' . $current_activity_item->component, 'user' );
1314
  $item_id = !empty( $user_id ) ? $user_id : $current_activity_item->user_id;
 
 
 
 
 
 
 
 
1315
  $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $item_id );
1316
 
1317
- // If this is a user object pass the users' email address for Gravatar so we don't have to refetch it.
1318
  if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) )
1319
  $email = $current_activity_item->user_email;
1320
 
 
 
 
 
 
 
 
1321
  return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array(
1322
  'item_id' => $item_id,
1323
  'object' => $object,
@@ -1333,7 +1479,7 @@ function bp_activity_avatar( $args = '' ) {
1333
  /**
1334
  * Output the avatar of the object that action was performed on.
1335
  *
1336
- * @since BuddyPress (1.2)
1337
  *
1338
  * @see bp_get_activity_secondary_avatar() for description of arguments.
1339
  * @uses bp_get_activity_secondary_avatar()
@@ -1347,7 +1493,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1347
  /**
1348
  * Return the avatar of the object that action was performed on
1349
  *
1350
- * @since BuddyPress (1.2)
1351
  *
1352
  * @see bp_core_fetch_avatar() for description of arguments.
1353
  * @global object $activities_template {@link BP_Activity_Template}
@@ -1446,8 +1592,26 @@ function bp_activity_secondary_avatar( $args = '' ) {
1446
  break;
1447
  }
1448
 
1449
- // Allow object, item_id, and link to be filtered
 
 
 
 
 
 
 
 
 
 
1450
  $object = apply_filters( 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component, $object );
 
 
 
 
 
 
 
 
1451
  $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
1452
 
1453
  // If we have no item_id or object, there is no avatar to display
@@ -1468,23 +1632,41 @@ function bp_activity_secondary_avatar( $args = '' ) {
1468
  ) );
1469
 
1470
  if ( !empty( $linked ) ) {
 
 
 
 
 
 
 
 
 
1471
  $link = apply_filters( 'bp_get_activity_secondary_avatar_link', $link, $activities_template->activity->component );
1472
 
 
 
 
 
 
 
 
 
 
1473
  return sprintf( '<a href="%s" class="%s">%s</a>',
1474
  $link,
1475
  $link_class,
1476
- apply_filters( 'bp_get_activity_secondary_avatar', $avatar )
1477
  );
1478
  }
1479
 
1480
- // else
1481
  return apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
1482
  }
1483
 
1484
  /**
1485
  * Output the activity action
1486
  *
1487
- * @since BuddyPress (1.2)
1488
  *
1489
  * @param array $args See bp_get_activity_action()
1490
  * @uses bp_get_activity_action()
@@ -1496,7 +1678,7 @@ function bp_activity_action( $args = array() ) {
1496
  /**
1497
  * Return the activity action
1498
  *
1499
- * @since BuddyPress (1.2)
1500
  *
1501
  * @global object $activities_template {@link BP_Activity_Template}
1502
  * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
@@ -1520,18 +1702,33 @@ function bp_activity_action( $args = array() ) {
1520
  extract( $args, EXTR_SKIP );
1521
 
1522
  $action = $activities_template->activity->action;
 
 
 
 
 
 
 
 
1523
  $action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array( $action, &$activities_template->activity, $args ) );
1524
 
1525
  if ( ! empty( $action ) && ! $no_timestamp )
1526
  $action = bp_insert_activity_meta( $action );
1527
 
 
 
 
 
 
 
 
1528
  return apply_filters_ref_array( 'bp_get_activity_action', array( $action, &$activities_template->activity, $args ) );
1529
  }
1530
 
1531
  /**
1532
  * Output the activity content body
1533
  *
1534
- * @since BuddyPress (1.2)
1535
  *
1536
  * @uses bp_get_activity_content_body()
1537
  */
@@ -1542,7 +1739,7 @@ function bp_activity_content_body() {
1542
  /**
1543
  * Return the activity content body
1544
  *
1545
- * @since BuddyPress (1.2)
1546
  *
1547
  * @global object $activities_template {@link BP_Activity_Template}
1548
  * @uses bp_insert_activity_meta()
@@ -1557,13 +1754,20 @@ function bp_activity_content_body() {
1557
  if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) )
1558
  $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
1559
 
 
 
 
 
 
 
 
1560
  return apply_filters_ref_array( 'bp_get_activity_content_body', array( $activities_template->activity->content, &$activities_template->activity ) );
1561
  }
1562
 
1563
  /**
1564
  * Does the activity have content?
1565
  *
1566
- * @since BuddyPress (1.2)
1567
  *
1568
  * @global object $activities_template {@link BP_Activity_Template}
1569
  *
@@ -1581,8 +1785,8 @@ function bp_activity_has_content() {
1581
  /**
1582
  * Output the activity content.
1583
  *
1584
- * @since BuddyPress (1.0)
1585
- * @deprecated BuddyPress (1.5)
1586
  *
1587
  * @todo properly deprecate this function.
1588
  *
@@ -1595,8 +1799,8 @@ function bp_activity_content() {
1595
  /**
1596
  * Return the activity content.
1597
  *
1598
- * @since BuddyPress (1.0)
1599
- * @deprecated BuddyPress (1.5)
1600
  *
1601
  * @todo properly deprecate this function.
1602
  *
@@ -1607,13 +1811,13 @@ function bp_activity_content() {
1607
  * @return string The activity content.
1608
  */
1609
  function bp_get_activity_content() {
 
1610
  /**
1611
  * If you want to filter activity update content, please use
1612
  * the filter 'bp_get_activity_content_body'
1613
  *
1614
- * This function is mainly for backwards comptibility.
1615
  */
1616
-
1617
  $content = bp_get_activity_action() . ' ' . bp_get_activity_content_body();
1618
  return apply_filters( 'bp_get_activity_content', $content );
1619
  }
@@ -1624,7 +1828,7 @@ function bp_activity_content() {
1624
  * This metadata includes the time since the item was posted (which will appear
1625
  * as a link to the item's permalink).
1626
  *
1627
- * @since BuddyPress (1.2)
1628
  *
1629
  * @global object $activities_template {@link BP_Activity_Template}
1630
  * @uses bp_core_time_since()
@@ -1644,22 +1848,44 @@ function bp_insert_activity_meta( $content ) {
1644
  // Strip any legacy time since placeholders from BP 1.0-1.1
1645
  $content = str_replace( '<span class="time-since">%s</span>', '', $content );
1646
 
1647
- // Insert the time since.
 
 
 
 
 
 
1648
  $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 ) );
1649
 
1650
  // Insert the permalink
1651
- if ( !bp_is_single_activity() )
 
 
 
 
 
 
 
 
1652
  $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 ) );
1653
- else
1654
  $content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH );
 
1655
 
 
 
 
 
 
 
 
1656
  return apply_filters( 'bp_insert_activity_meta', $content );
1657
  }
1658
 
1659
  /**
1660
  * Determine if the current user can delete an activity item.
1661
  *
1662
- * @since BuddyPress (1.2)
1663
  *
1664
  * @global object $activities_template {@link BP_Activity_Template}
1665
  * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
@@ -1704,13 +1930,21 @@ function bp_activity_user_can_delete( $activity = false ) {
1704
  }
1705
  }
1706
 
 
 
 
 
 
 
 
 
1707
  return (bool) apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
1708
  }
1709
 
1710
  /**
1711
  * Output the activity parent content.
1712
  *
1713
- * @since BuddyPress (1.2)
1714
  *
1715
  * @see bp_get_activity_parent_content() for a description of arguments.
1716
  * @uses bp_get_activity_parent_content()
@@ -1724,7 +1958,7 @@ function bp_activity_parent_content( $args = '' ) {
1724
  /**
1725
  * Return the activity content.
1726
  *
1727
- * @since BuddyPress (1.2)
1728
  *
1729
  * @global object $activities_template {@link BP_Activity_Template}
1730
  * @uses wp_parse_args()
@@ -1771,13 +2005,20 @@ function bp_activity_parent_content( $args = '' ) {
1771
  // Remove images
1772
  $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
1773
 
 
 
 
 
 
 
 
1774
  return apply_filters( 'bp_get_activity_parent_content', $content );
1775
  }
1776
 
1777
  /**
1778
  * Output the parent activity's user ID.
1779
  *
1780
- * @since BuddyPress (1.7)
1781
  */
1782
  function bp_activity_parent_user_id() {
1783
  echo bp_get_activity_parent_user_id();
@@ -1786,7 +2027,7 @@ function bp_activity_parent_user_id() {
1786
  /**
1787
  * Return the parent activity's user ID.
1788
  *
1789
- * @since BuddyPress (1.7)
1790
  *
1791
  * @global BP_Activity_Template $activities_template
1792
  *
@@ -1814,13 +2055,20 @@ function bp_activity_parent_user_id() {
1814
 
1815
  $retval = $activities_template->activity_parents[$parent_id]->user_id;
1816
 
 
 
 
 
 
 
 
1817
  return (int) apply_filters( 'bp_get_activity_parent_user_id', $retval );
1818
  }
1819
 
1820
  /**
1821
  * Output whether or not the current activity is in a current user's favorites.
1822
  *
1823
- * @since BuddyPress (1.2)
1824
  *
1825
  * @uses bp_get_activity_is_favorite()
1826
  */
@@ -1831,7 +2079,7 @@ function bp_activity_is_favorite() {
1831
  /**
1832
  * Return whether the current activity is in a current user's favorites.
1833
  *
1834
- * @since BuddyPress (1.2)
1835
  *
1836
  * @global object $activities_template {@link BP_Activity_Template}
1837
  * @uses apply_filters() To call the 'bp_get_activity_is_favorite' hook.
@@ -1841,13 +2089,20 @@ function bp_activity_is_favorite() {
1841
  function bp_get_activity_is_favorite() {
1842
  global $activities_template;
1843
 
 
 
 
 
 
 
 
1844
  return (bool) apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array) $activities_template->my_favs ) );
1845
  }
1846
 
1847
  /**
1848
  * Output the comment markup for an activity item.
1849
  *
1850
- * @since BuddyPress (1.2)
1851
  *
1852
  * @todo deprecate $args param
1853
  *
@@ -1860,7 +2115,7 @@ function bp_activity_comments( $args = '' ) {
1860
  /**
1861
  * Get the comment markup for an activity item.
1862
  *
1863
- * @since BuddyPress (1.2)
1864
  *
1865
  * @todo deprecate $args param
1866
  *
@@ -1887,7 +2142,7 @@ function bp_activity_comments( $args = '' ) {
1887
  * Note: The recursion itself used to happen entirely in this function. Now it is
1888
  * split between here and the comment.php template.
1889
  *
1890
- * @since BuddyPress (1.2)
1891
  *
1892
  * @param object $comment The activity object currently being recursed
1893
  *
@@ -1903,6 +2158,13 @@ function bp_activity_comments( $args = '' ) {
1903
  if ( empty( $comment->children ) )
1904
  return false;
1905
 
 
 
 
 
 
 
 
1906
  echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>');
1907
  foreach ( (array) $comment->children as $comment_child ) {
1908
  // Put the comment into the global so it's available to filters
@@ -1922,13 +2184,21 @@ function bp_activity_comments( $args = '' ) {
1922
 
1923
  unset( $activities_template->activity->current_comment );
1924
  }
 
 
 
 
 
 
 
 
1925
  echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>');
1926
  }
1927
 
1928
  /**
1929
  * Utility function that returns the comment currently being recursed.
1930
  *
1931
- * @since BuddyPress (1.5)
1932
  *
1933
  * @global object $activities_template {@link BP_Activity_Template}
1934
  * @uses apply_filters() To call the 'bp_activity_current_comment' hook.
@@ -1941,6 +2211,13 @@ function bp_activity_current_comment() {
1941
 
1942
  $current_comment = !empty( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : false;
1943
 
 
 
 
 
 
 
 
1944
  return apply_filters( 'bp_activity_current_comment', $current_comment );
1945
  }
1946
 
@@ -1948,7 +2225,7 @@ function bp_activity_current_comment() {
1948
  /**
1949
  * Output the ID of the activity comment currently being displayed.
1950
  *
1951
- * @since BuddyPress (1.5)
1952
  *
1953
  * @uses bp_get_activity_comment_id()
1954
  */
@@ -1959,7 +2236,7 @@ function bp_activity_comment_id() {
1959
  /**
1960
  * Return the ID of the activity comment currently being displayed.
1961
  *
1962
- * @since BuddyPress (1.5)
1963
  *
1964
  * @global object $activities_template {@link BP_Activity_Template}
1965
  * @uses apply_filters() To call the 'bp_activity_comment_id' hook.
@@ -1972,13 +2249,20 @@ function bp_activity_comment_id() {
1972
 
1973
  $comment_id = isset( $activities_template->activity->current_comment->id ) ? $activities_template->activity->current_comment->id : false;
1974
 
 
 
 
 
 
 
 
1975
  return apply_filters( 'bp_activity_comment_id', $comment_id );
1976
  }
1977
 
1978
  /**
1979
  * Output the ID of the author of the activity comment currently being displayed.
1980
  *
1981
- * @since BuddyPress (1.5)
1982
  *
1983
  * @uses bp_get_activity_comment_user_id()
1984
  */
@@ -1989,7 +2273,7 @@ function bp_activity_comment_user_id() {
1989
  /**
1990
  * Return the ID of the author of the activity comment currently being displayed.
1991
  *
1992
- * @since BuddyPress (1.5)
1993
  *
1994
  * @global object $activities_template {@link BP_Activity_Template}
1995
  * @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
@@ -2002,13 +2286,20 @@ function bp_activity_comment_user_id() {
2002
 
2003
  $user_id = isset( $activities_template->activity->current_comment->user_id ) ? $activities_template->activity->current_comment->user_id : false;
2004
 
 
 
 
 
 
 
 
2005
  return apply_filters( 'bp_activity_comment_user_id', $user_id );
2006
  }
2007
 
2008
  /**
2009
  * Output the author link for the activity comment currently being displayed.
2010
  *
2011
- * @since BuddyPress (1.5)
2012
  *
2013
  * @uses bp_get_activity_comment_user_link()
2014
  */
@@ -2019,7 +2310,7 @@ function bp_activity_comment_user_link() {
2019
  /**
2020
  * Return the author link for the activity comment currently being displayed.
2021
  *
2022
- * @since BuddyPress (1.5)
2023
  *
2024
  * @uses bp_core_get_user_domain()
2025
  * @uses bp_get_activity_comment_user_id()
@@ -2030,13 +2321,20 @@ function bp_activity_comment_user_link() {
2030
  function bp_get_activity_comment_user_link() {
2031
  $user_link = bp_core_get_user_domain( bp_get_activity_comment_user_id() );
2032
 
 
 
 
 
 
 
 
2033
  return apply_filters( 'bp_activity_comment_user_link', $user_link );
2034
  }
2035
 
2036
  /**
2037
  * Output the author name for the activity comment currently being displayed.
2038
  *
2039
- * @since BuddyPress (1.5)
2040
  *
2041
  * @uses bp_get_activity_comment_name()
2042
  */
@@ -2050,7 +2348,7 @@ function bp_activity_comment_name() {
2050
  * The use of the 'bp_acomment_name' filter is deprecated. Please use
2051
  * 'bp_activity_comment_name'.
2052
  *
2053
- * @since BuddyPress (1.5)
2054
  *
2055
  * @global object $activities_template {@link BP_Activity_Template}
2056
  * @uses apply_filters() To call the 'bp_acomment_name' hook.
@@ -2061,18 +2359,27 @@ function bp_activity_comment_name() {
2061
  function bp_get_activity_comment_name() {
2062
  global $activities_template;
2063
 
2064
- if ( isset( $activities_template->activity->current_comment->user_fullname ) )
 
2065
  $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment ); // backward compatibility
2066
- else
2067
  $name = $activities_template->activity->current_comment->display_name;
 
2068
 
 
 
 
 
 
 
 
2069
  return apply_filters( 'bp_activity_comment_name', $name );
2070
  }
2071
 
2072
  /**
2073
  * Output the date_recorded of the activity comment currently being displayed.
2074
  *
2075
- * @since BuddyPress (1.5)
2076
  *
2077
  * @uses bp_get_activity_comment_date_recorded()
2078
  */
@@ -2083,7 +2390,7 @@ function bp_activity_comment_date_recorded() {
2083
  /**
2084
  * Return the date_recorded for the activity comment currently being displayed.
2085
  *
2086
- * @since BuddyPress (1.5)
2087
  *
2088
  * @global object $activities_template {@link BP_Activity_Template}
2089
  * @uses bp_core_time_since()
@@ -2100,13 +2407,20 @@ function bp_activity_comment_date_recorded() {
2100
 
2101
  $date_recorded = bp_core_time_since( $activities_template->activity->current_comment->date_recorded );
2102
 
 
 
 
 
 
 
 
2103
  return apply_filters( 'bp_activity_comment_date_recorded', $date_recorded );
2104
  }
2105
 
2106
  /**
2107
  * Output the 'delete' URL for the activity comment currently being displayed.
2108
  *
2109
- * @since BuddyPress (1.5)
2110
  *
2111
  * @uses bp_get_activity_comment_delete_link()
2112
  */
@@ -2117,7 +2431,7 @@ function bp_activity_comment_delete_link() {
2117
  /**
2118
  * Gets the 'delete' URL for the activity comment currently being displayed
2119
  *
2120
- * @since BuddyPress (1.5)
2121
  *
2122
  * @uses wp_nonce_url()
2123
  * @uses bp_get_root_domain()
@@ -2131,13 +2445,20 @@ function bp_activity_comment_delete_link() {
2131
  function bp_get_activity_comment_delete_link() {
2132
  $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' );
2133
 
 
 
 
 
 
 
 
2134
  return apply_filters( 'bp_activity_comment_delete_link', $link );
2135
  }
2136
 
2137
  /**
2138
  * Output the content of the activity comment currently being displayed.
2139
  *
2140
- * @since BuddyPress (1.5)
2141
  *
2142
  * @uses bp_get_activity_comment_content()
2143
  */
@@ -2153,7 +2474,7 @@ function bp_activity_comment_content() {
2153
  * 'bp_activity_comment_content' to modify the content of activity
2154
  * comments only.
2155
  *
2156
- * @since BuddyPress (1.5)
2157
  *
2158
  * @global object $activities_template {@link BP_Activity_Template}
2159
  * @uses apply_filters() To call the 'bp_get_activity_content' hook.
@@ -2164,15 +2485,23 @@ function bp_activity_comment_content() {
2164
  function bp_get_activity_comment_content() {
2165
  global $activities_template;
2166
 
 
2167
  $content = apply_filters( 'bp_get_activity_content', $activities_template->activity->current_comment->content );
2168
 
 
 
 
 
 
 
 
2169
  return apply_filters( 'bp_activity_comment_content', $content );
2170
  }
2171
 
2172
  /**
2173
  * Output the activity comment count.
2174
  *
2175
- * @since BuddyPress (1.2)
2176
  *
2177
  * @uses bp_activity_get_comment_count()
2178
  */
@@ -2183,7 +2512,7 @@ function bp_activity_comment_count() {
2183
  /**
2184
  * Return the comment count of an activity item.
2185
  *
2186
- * @since BuddyPress (1.2)
2187
  *
2188
  * @global object $activities_template {@link BP_Activity_Template}
2189
  * @uses bp_activity_recurse_comment_count()
@@ -2206,6 +2535,13 @@ function bp_activity_comment_count() {
2206
  ? bp_activity_recurse_comment_count( $activities_template->activity )
2207
  : 0;
2208
 
 
 
 
 
 
 
 
2209
  return apply_filters( 'bp_activity_get_comment_count', (int) $count );
2210
  }
2211
 
@@ -2215,7 +2551,7 @@ function bp_activity_comment_count() {
2215
  * This function recursively adds the total number of comments each
2216
  * activity child has, and returns them.
2217
  *
2218
- * @since BuddyPress (1.2)
2219
  *
2220
  * @uses bp_activity_recurse_comment_count()
2221
  * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook
@@ -2238,7 +2574,15 @@ function bp_activity_comment_count() {
2238
  }
2239
  }
2240
 
2241
- // Filter and return
 
 
 
 
 
 
 
 
2242
  return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
2243
  }
2244
 
@@ -2255,17 +2599,25 @@ function bp_activity_comment_depth() {
2255
  *
2256
  * @since BuddyPress (2.0.0)
2257
  *
2258
- * @return int
2259
  */
2260
  function bp_activity_get_comment_depth() {
2261
  global $activities_template;
 
 
 
 
 
 
 
 
2262
  return apply_filters( 'bp_activity_get_comment_depth', $activities_template->activity->current_comment->depth );
2263
  }
2264
 
2265
  /**
2266
  * Output the activity comment link.
2267
  *
2268
- * @since BuddyPress (1.2)
2269
  *
2270
  * @uses bp_get_activity_comment_link()
2271
  */
@@ -2276,7 +2628,7 @@ function bp_activity_comment_link() {
2276
  /**
2277
  * Return the activity comment link.
2278
  *
2279
- * @since BuddyPress (1.2)
2280
  *
2281
  * @global object $activities_template {@link BP_Activity_Template}
2282
  * @uses apply_filters() To call the 'bp_get_activity_comment_link' hook.
@@ -2285,13 +2637,21 @@ function bp_activity_comment_link() {
2285
  */
2286
  function bp_get_activity_comment_link() {
2287
  global $activities_template;
 
 
 
 
 
 
 
 
2288
  return apply_filters( 'bp_get_activity_comment_link', '?ac=' . $activities_template->activity->id . '/#ac-form-' . $activities_template->activity->id );
2289
  }
2290
 
2291
  /**
2292
  * Output the activity comment form no javascript display CSS.
2293
  *
2294
- * @since BuddyPress (1.2)
2295
  *
2296
  * @uses bp_get_activity_comment_form_nojs_display()
2297
  */
@@ -2302,7 +2662,7 @@ function bp_activity_comment_form_nojs_display() {
2302
  /**
2303
  * Return the activity comment form no javascript display CSS.
2304
  *
2305
- * @since BuddyPress (1.2)
2306
  *
2307
  * @global object $activities_template {@link BP_Activity_Template}
2308
  *
@@ -2320,7 +2680,7 @@ function bp_activity_comment_form_nojs_display() {
2320
  /**
2321
  * Output the activity comment form action.
2322
  *
2323
- * @since BuddyPress (1.2)
2324
  *
2325
  * @uses bp_get_activity_comment_form_action()
2326
  */
@@ -2331,7 +2691,7 @@ function bp_activity_comment_form_action() {
2331
  /**
2332
  * Return the activity comment form action.
2333
  *
2334
- * @since BuddyPress (1.2)
2335
  *
2336
  * @uses home_url()
2337
  * @uses bp_get_activity_root_slug()
@@ -2340,13 +2700,21 @@ function bp_activity_comment_form_action() {
2340
  * @return string The activity comment form action.
2341
  */
2342
  function bp_get_activity_comment_form_action() {
 
 
 
 
 
 
 
 
2343
  return apply_filters( 'bp_get_activity_comment_form_action', home_url( bp_get_activity_root_slug() . '/reply/' ) );
2344
  }
2345
 
2346
  /**
2347
  * Output the activity permalink ID.
2348
  *
2349
- * @since BuddyPress (1.2)
2350
  *
2351
  * @uses bp_get_activity_permalink_id()
2352
  */
@@ -2357,20 +2725,28 @@ function bp_activity_permalink_id() {
2357
  /**
2358
  * Return the activity permalink ID.
2359
  *
2360
- * @since BuddyPress (1.2)
2361
  *
2362
  * @uses apply_filters() To call the 'bp_get_activity_permalink_id' hook.
2363
  *
2364
  * @return string The activity permalink ID.
2365
  */
2366
  function bp_get_activity_permalink_id() {
 
 
 
 
 
 
 
 
2367
  return apply_filters( 'bp_get_activity_permalink_id', bp_current_action() );
2368
  }
2369
 
2370
  /**
2371
  * Output the activity thread permalink.
2372
  *
2373
- * @since BuddyPress (1.2)
2374
  *
2375
  * @uses bp_get_activity_permalink_id()
2376
  */
@@ -2381,7 +2757,7 @@ function bp_activity_thread_permalink() {
2381
  /**
2382
  * Return the activity thread permalink.
2383
  *
2384
- * @since BuddyPress (1.2)
2385
  *
2386
  * @uses bp_activity_get_permalink()
2387
  * @uses apply_filters() To call the 'bp_get_activity_thread_permalink' hook.
@@ -2393,13 +2769,20 @@ function bp_activity_thread_permalink() {
2393
 
2394
  $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
2395
 
 
 
 
 
 
 
 
2396
  return apply_filters( 'bp_get_activity_thread_permalink', $link );
2397
  }
2398
 
2399
  /**
2400
  * Output the activity comment permalink.
2401
  *
2402
- * @since BuddyPress (1.8)
2403
  *
2404
  * @uses bp_get_activity_permalink_id()
2405
  */
@@ -2409,7 +2792,7 @@ function bp_activity_comment_permalink() {
2409
  /**
2410
  * Return the activity comment permalink.
2411
  *
2412
- * @since BuddyPress (1.8)
2413
  *
2414
  * @uses bp_activity_get_permalink()
2415
  * @uses apply_filters() To call the 'bp_get_activity_comment_permalink' hook.
@@ -2432,13 +2815,21 @@ function bp_activity_comment_permalink() {
2432
  // Append comment ID to end of activity permalink
2433
  $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link;
2434
 
 
 
 
 
 
 
 
 
2435
  return apply_filters( 'bp_get_activity_comment_permalink', $link, $comment_id );
2436
  }
2437
 
2438
  /**
2439
  * Output the activity favorite link.
2440
  *
2441
- * @since BuddyPress (1.2)
2442
  *
2443
  * @uses bp_get_activity_favorite_link()
2444
  */
@@ -2449,7 +2840,7 @@ function bp_activity_favorite_link() {
2449
  /**
2450
  * Return the activity favorite link.
2451
  *
2452
- * @since BuddyPress (1.2)
2453
  *
2454
  * @global object $activities_template {@link BP_Activity_Template}
2455
  * @uses wp_nonce_url()
@@ -2461,13 +2852,21 @@ function bp_activity_favorite_link() {
2461
  */
2462
  function bp_get_activity_favorite_link() {
2463
  global $activities_template;
 
 
 
 
 
 
 
 
2464
  return apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/favorite/' . $activities_template->activity->id . '/' ), 'mark_favorite' ) );
2465
  }
2466
 
2467
  /**
2468
  * Output the activity unfavorite link.
2469
  *
2470
- * @since BuddyPress (1.2)
2471
  *
2472
  * @uses bp_get_activity_unfavorite_link()
2473
  */
@@ -2478,7 +2877,7 @@ function bp_activity_unfavorite_link() {
2478
  /**
2479
  * Return the activity unfavorite link.
2480
  *
2481
- * @since BuddyPress (1.2)
2482
  *
2483
  * @global object $activities_template {@link BP_Activity_Template}
2484
  * @uses wp_nonce_url()
@@ -2490,13 +2889,21 @@ function bp_activity_unfavorite_link() {
2490
  */
2491
  function bp_get_activity_unfavorite_link() {
2492
  global $activities_template;
 
 
 
 
 
 
 
 
2493
  return apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/unfavorite/' . $activities_template->activity->id . '/' ), 'unmark_favorite' ) );
2494
  }
2495
 
2496
  /**
2497
  * Output the activity CSS class.
2498
  *
2499
- * @since BuddyPress (1.0)
2500
  *
2501
  * @uses bp_get_activity_css_class()
2502
  */
@@ -2507,7 +2914,7 @@ function bp_activity_css_class() {
2507
  /**
2508
  * Return the current activity item's CSS class.
2509
  *
2510
- * @since BuddyPress (1.0)
2511
  *
2512
  * @global object $activities_template {@link BP_Activity_Template}
2513
  * @uses apply_filters() To call the 'bp_activity_mini_activity_types' hook.
@@ -2520,6 +2927,13 @@ function bp_activity_css_class() {
2520
  function bp_get_activity_css_class() {
2521
  global $activities_template;
2522
 
 
 
 
 
 
 
 
2523
  $mini_activity_actions = apply_filters( 'bp_activity_mini_activity_types', array(
2524
  'friendship_accepted',
2525
  'friendship_created',
@@ -2537,13 +2951,20 @@ function bp_activity_css_class() {
2537
  if ( bp_activity_get_comment_count() && bp_activity_can_comment() )
2538
  $class .= ' has-comments';
2539
 
 
 
 
 
 
 
 
2540
  return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class );
2541
  }
2542
 
2543
  /**
2544
  * Output the activity delete link.
2545
  *
2546
- * @since BuddyPress (1.1)
2547
  *
2548
  * @uses bp_get_activity_delete_link()
2549
  */
@@ -2554,7 +2975,7 @@ function bp_activity_delete_link() {
2554
  /**
2555
  * Return the activity delete link.
2556
  *
2557
- * @since BuddyPress (1.1)
2558
  *
2559
  * @global object $activities_template {@link BP_Activity_Template}
2560
  * @uses bp_get_root_domain()
@@ -2581,6 +3002,13 @@ function bp_activity_delete_link() {
2581
 
2582
  $link = '<a href="' . esc_url( $url ) . '" class="button item-button bp-secondary-action ' . $class . ' confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>';
2583
 
 
 
 
 
 
 
 
2584
  return apply_filters( 'bp_get_activity_delete_link', $link );
2585
  }
2586
 
@@ -2624,13 +3052,20 @@ function bp_activity_delete_url() {
2624
 
2625
  $url = wp_nonce_url( $url, 'bp_activity_delete_link' );
2626
 
 
 
 
 
 
 
 
2627
  return apply_filters( 'bp_get_activity_delete_url', $url );
2628
  }
2629
 
2630
  /**
2631
  * Output the activity latest update link.
2632
  *
2633
- * @since BuddyPress (1.2)
2634
  *
2635
  * @see bp_get_activity_latest_update() for description of parameters.
2636
  * @uses bp_get_activity_latest_update()
@@ -2644,7 +3079,7 @@ function bp_activity_latest_update( $user_id = 0 ) {
2644
  /**
2645
  * Return the activity latest update link.
2646
  *
2647
- * @since BuddyPress (1.2)
2648
  *
2649
  * @uses bp_is_user_inactive()
2650
  * @uses bp_core_is_user_deleted()
@@ -2670,16 +3105,36 @@ function bp_activity_latest_update( $user_id = 0 ) {
2670
  if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) )
2671
  return false;
2672
 
 
 
 
 
 
 
 
2673
  $latest_update = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 358 ) ) ) );
2674
- $latest_update .= ' <a href="' . bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $update['id'] . '/"> ' . __( 'View', 'buddypress' ) . '</a>';
2675
 
2676
- return apply_filters( 'bp_get_activity_latest_update', $latest_update );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2677
  }
2678
 
2679
  /**
2680
  * Output the activity filter links.
2681
  *
2682
- * @since BuddyPress (1.1)
2683
  *
2684
  * @see bp_get_activity_filter_links() for description of parameters.
2685
  * @uses bp_get_activity_filter_links()
@@ -2693,7 +3148,7 @@ function bp_activity_filter_links( $args = false ) {
2693
  /**
2694
  * Return the activity filter links.
2695
  *
2696
- * @since BuddyPress (1.1)
2697
  *
2698
  * @uses wp_parse_args()
2699
  * @uses BP_Activity_Activity::get_recorded_components() {@link BP_Activity_Activity}
@@ -2761,6 +3216,15 @@ function bp_activity_filter_links( $args = false ) {
2761
 
2762
  $link = add_query_arg( 'afilter', $component );
2763
  $link = remove_query_arg( 'acpage' , $link );
 
 
 
 
 
 
 
 
 
2764
  $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
2765
 
2766
  $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( $component ) . '</a>' . $after;
@@ -2771,13 +3235,20 @@ function bp_activity_filter_links( $args = false ) {
2771
  if ( isset( $_GET['afilter'] ) )
2772
  $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_attr( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
2773
 
 
 
 
 
 
 
 
2774
  return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
2775
  }
2776
 
2777
  /**
2778
  * Determine if a comment can be made on an activity item.
2779
  *
2780
- * @since BuddyPress (1.2)
2781
  *
2782
  * @global object $activities_template {@link BP_Activity_Template}
2783
  * @uses bp_get_activity_action_name()
@@ -2787,30 +3258,49 @@ function bp_activity_filter_links( $args = false ) {
2787
  */
2788
  function bp_activity_can_comment() {
2789
  global $activities_template;
 
2790
 
2791
  // Assume activity can be commented on
2792
  $can_comment = true;
2793
 
2794
  // Determine ability to comment based on activity action name
2795
  $activity_action = bp_get_activity_action_name();
2796
- switch ( $activity_action ) {
2797
-
2798
- // Maybe turn off for blog and forum updates
2799
- case 'new_blog_post' :
2800
- case 'new_blog_comment' :
2801
- case 'new_forum_topic' :
2802
- case 'new_forum_post' :
2803
- if ( ! empty( $activities_template->disable_blogforum_replies ) ) {
2804
- $can_comment = false;
2805
- }
2806
- break;
2807
 
2808
- // Turn off for activity comments
2809
- case 'activity_comment' :
2810
- $can_comment = false;
2811
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
2812
  }
2813
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2814
  return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
2815
  }
2816
 
@@ -2850,28 +3340,44 @@ function bp_activity_can_comment_reply( $comment = '' ) {
2850
  }
2851
  }
2852
 
 
 
 
 
 
 
 
 
2853
  return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
2854
  }
2855
 
2856
  /**
2857
- * Determine if an favorites are allowed.
2858
  *
2859
  * Defaults to true, but can be modified by plugins.
2860
  *
2861
- * @since BuddyPress (1.5)
2862
  *
2863
  * @uses apply_filters() To call the 'bp_activity_can_favorite' hook.
2864
  *
2865
  * @return bool True if comment can receive comments.
2866
  */
2867
  function bp_activity_can_favorite() {
 
 
 
 
 
 
 
 
2868
  return apply_filters( 'bp_activity_can_favorite', true );
2869
  }
2870
 
2871
  /**
2872
  * Output the total favorite count for a specified user.
2873
  *
2874
- * @since BuddyPress (1.2)
2875
  *
2876
  * @see bp_get_total_favorite_count_for_user() for description of parameters.
2877
  * @uses bp_get_total_favorite_count_for_user()
@@ -2885,7 +3391,7 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
2885
  /**
2886
  * Return the total favorite count for a specified user.
2887
  *
2888
- * @since BuddyPress (1.2)
2889
  *
2890
  * @uses bp_activity_total_favorites_for_user()
2891
  * @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook
@@ -2905,6 +3411,13 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
2905
  ? bp_activity_total_favorites_for_user( $user_id )
2906
  : false;
2907
 
 
 
 
 
 
 
 
2908
  return apply_filters( 'bp_get_total_favorite_count_for_user', $retval );
2909
  }
2910
 
@@ -2912,7 +3425,7 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
2912
  /**
2913
  * Output the total mention count for a specified user.
2914
  *
2915
- * @since BuddyPress (1.2)
2916
  *
2917
  * @see bp_get_total_mention_count_for_user() for description of parameters.
2918
  * @uses bp_get_total_favorite_count_for_user()
@@ -2926,7 +3439,7 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
2926
  /**
2927
  * Return the total mention count for a specified user.
2928
  *
2929
- * @since BuddyPress (1.2)
2930
  *
2931
  * @uses bp_get_user_meta()
2932
  * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
@@ -2946,13 +3459,20 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
2946
  ? bp_get_user_meta( $user_id, 'bp_new_mention_count', true )
2947
  : false;
2948
 
 
 
 
 
 
 
 
2949
  return apply_filters( 'bp_get_total_mention_count_for_user', $retval );
2950
  }
2951
 
2952
  /**
2953
  * Output the public message link for displayed user.
2954
  *
2955
- * @since BuddyPress (1.2)
2956
  *
2957
  * @uses bp_get_send_public_message_link()
2958
  */
@@ -2963,7 +3483,7 @@ function bp_send_public_message_link() {
2963
  /**
2964
  * Return the public message link for the displayed user.
2965
  *
2966
- * @since BuddyPress (1.2)
2967
  *
2968
  * @uses is_user_logged_in()
2969
  * @uses bp_is_my_profile()
@@ -2985,6 +3505,13 @@ function bp_send_public_message_link() {
2985
  $retval = wp_nonce_url( $url );
2986
  }
2987
 
 
 
 
 
 
 
 
2988
  return apply_filters( 'bp_get_send_public_message_link', $retval );
2989
  }
2990
 
@@ -3018,7 +3545,7 @@ function bp_activity_recurse_comments_activity_ids( $activity = array(), $activi
3018
  /**
3019
  * Output the mentioned user display name.
3020
  *
3021
- * @since BuddyPress (1.2)
3022
  *
3023
  * @see bp_get_mentioned_user_display_name() for description of parameters.
3024
  * @uses bp_get_mentioned_user_display_name()
@@ -3032,7 +3559,7 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3032
  /**
3033
  * Returns the mentioned user display name
3034
  *
3035
- * @since BuddyPress (1.2)
3036
  *
3037
  * @uses bp_core_get_user_displayname()
3038
  * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
@@ -3050,13 +3577,21 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3050
  $name = __( 'a user', 'buddypress' );
3051
  }
3052
 
 
 
 
 
 
 
 
 
3053
  return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
3054
  }
3055
 
3056
  /**
3057
  * Output button for sending a public message (an @-mention).
3058
  *
3059
- * @since BuddyPress (1.2)
3060
  *
3061
  * @see bp_get_send_public_message_button() for description of parameters.
3062
  * @uses bp_get_send_public_message_button()
@@ -3070,7 +3605,7 @@ function bp_send_public_message_button( $args = '' ) {
3070
  /**
3071
  * Return button for sending a public message (an @-mention).
3072
  *
3073
- * @since BuddyPress (1.2)
3074
  *
3075
  * @uses bp_get_send_public_message_link()
3076
  * @uses wp_parse_args()
@@ -3108,14 +3643,20 @@ function bp_send_public_message_button( $args = '' ) {
3108
  'link_class' => 'activity-button mention'
3109
  ) );
3110
 
3111
- // Filter and return the HTML button
 
 
 
 
 
 
3112
  return bp_get_button( apply_filters( 'bp_get_send_public_message_button', $r ) );
3113
  }
3114
 
3115
  /**
3116
  * Output the activity post form action.
3117
  *
3118
- * @since BuddyPress (1.2)
3119
  *
3120
  * @uses bp_get_activity_post_form_action()
3121
  */
@@ -3126,7 +3667,7 @@ function bp_activity_post_form_action() {
3126
  /**
3127
  * Return the activity post form action.
3128
  *
3129
- * @since BuddyPress (1.2)
3130
  *
3131
  * @uses home_url()
3132
  * @uses bp_get_activity_root_slug()
@@ -3135,6 +3676,14 @@ function bp_activity_post_form_action() {
3135
  * @return string The activity post form action.
3136
  */
3137
  function bp_get_activity_post_form_action() {
 
 
 
 
 
 
 
 
3138
  return apply_filters( 'bp_get_activity_post_form_action', home_url( bp_get_activity_root_slug() . '/post/' ) );
3139
  }
3140
 
@@ -3146,7 +3695,7 @@ function bp_activity_post_form_action() {
3146
  * Avatars are wrapped in <li> elements, but you've got to provide your own
3147
  * <ul> or <ol> wrapper markup.
3148
  *
3149
- * @since BuddyPress (1.7)
3150
  *
3151
  * @see bp_core_fetch_avatar() for a description of arguments.
3152
  *
@@ -3198,13 +3747,22 @@ function bp_activity_comments_user_avatars( $args = array() ) {
3198
  }
3199
  }
3200
 
 
 
 
 
 
 
 
 
 
3201
  echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );
3202
  }
3203
 
3204
  /**
3205
  * Return the IDs of every user who's left a comment on the current activity item.
3206
  *
3207
- * @since BuddyPress (1.7)
3208
  *
3209
  * @return bool|array An array of IDs, or false if none are found.
3210
  */
@@ -3215,13 +3773,20 @@ function bp_activity_get_comments_user_ids() {
3215
  ? (array) bp_activity_recurse_comments_user_ids( $activities_template->activity->children )
3216
  : array();
3217
 
 
 
 
 
 
 
 
3218
  return apply_filters( 'bp_activity_get_comments_user_ids', array_unique( $user_ids ) );
3219
  }
3220
 
3221
  /**
3222
  * Recurse through all activity comments and collect the IDs of the users who wrote them.
3223
  *
3224
- * @since BuddyPress (1.7)
3225
  *
3226
  * @param array $comments Array of {@link BP_Activity_Activity} items.
3227
  * @return array Array of user IDs.
@@ -3251,7 +3816,14 @@ function bp_activity_get_comments_user_ids() {
3251
  }
3252
  }
3253
 
3254
- // Filter and return
 
 
 
 
 
 
 
3255
  return apply_filters( 'bp_activity_recurse_comments_user_ids', $user_ids, $comments );
3256
  }
3257
 
@@ -3271,13 +3843,21 @@ function bp_displayed_user_mentionname() {
3271
  * @return string Mentionname for the displayed user, if available.
3272
  */
3273
  function bp_get_displayed_user_mentionname() {
 
 
 
 
 
 
 
 
3274
  return apply_filters( 'bp_get_displayed_user_mentionname', bp_activity_get_user_mentionname( bp_displayed_user_id() ) );
3275
  }
3276
 
3277
  /**
3278
  * Echo a list of all registered activity types for use in dropdowns or checkbox lists.
3279
  *
3280
- * @since BuddyPress (1.7)
3281
  *
3282
  * @param string $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
3283
  * @param array $args {
@@ -3315,7 +3895,18 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
3315
  break;
3316
  }
3317
 
3318
- // Allow custom markup
 
 
 
 
 
 
 
 
 
 
 
3319
  do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
3320
  }
3321
 
@@ -3331,7 +3922,7 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
3331
  /**
3332
  * Output the sitewide activity feed link.
3333
  *
3334
- * @since BuddyPress (1.0)
3335
  *
3336
  * @uses bp_get_sitewide_activity_feed_link()
3337
  */
@@ -3342,7 +3933,7 @@ function bp_sitewide_activity_feed_link() {
3342
  /**
3343
  * Returns the sitewide activity feed link.
3344
  *
3345
- * @since BuddyPress (1.0)
3346
  *
3347
  * @uses home_url()
3348
  * @uses bp_get_activity_root_slug()
@@ -3351,13 +3942,21 @@ function bp_sitewide_activity_feed_link() {
3351
  * @return string The sitewide activity feed link.
3352
  */
3353
  function bp_get_sitewide_activity_feed_link() {
 
 
 
 
 
 
 
 
3354
  return apply_filters( 'bp_get_sitewide_activity_feed_link', bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/feed/' );
3355
  }
3356
 
3357
  /**
3358
  * Output the member activity feed link.
3359
  *
3360
- * @since BuddyPress (1.2)
3361
  *
3362
  * @uses bp_get_member_activity_feed_link()
3363
  */
@@ -3368,8 +3967,8 @@ function bp_member_activity_feed_link() {
3368
  /**
3369
  * Output the member activity feed link.
3370
  *
3371
- * @since BuddyPress (1.0)
3372
- * @deprecated BuddyPress (1.2)
3373
  *
3374
  * @todo properly deprecate in favor of bp_member_activity_feed_link().
3375
  *
@@ -3380,7 +3979,7 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
3380
  /**
3381
  * Return the member activity feed link.
3382
  *
3383
- * @since BuddyPress (1.2)
3384
  *
3385
  * @uses bp_is_profile_component()
3386
  * @uses bp_is_current_action()
@@ -3420,14 +4019,21 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
3420
  $link = '';
3421
  }
3422
 
 
 
 
 
 
 
 
3423
  return apply_filters( 'bp_get_activities_member_rss_link', $link );
3424
  }
3425
 
3426
  /**
3427
  * Return the member activity feed link.
3428
  *
3429
- * @since BuddyPress (1.0)
3430
- * @deprecated BuddyPress (1.2)
3431
  *
3432
  * @todo properly deprecate in favor of bp_get_member_activity_feed_link().
3433
  *
@@ -3443,7 +4049,7 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
3443
  /**
3444
  * Outputs the activity feed item guid.
3445
  *
3446
- * @since BuddyPress (1.0)
3447
  *
3448
  * @uses bp_activity_feed_item_guid()
3449
  */
@@ -3454,7 +4060,7 @@ function bp_activity_feed_item_guid() {
3454
  /**
3455
  * Returns the activity feed item guid.
3456
  *
3457
- * @since BuddyPress (1.2)
3458
  *
3459
  * @global object $activities_template {@link BP_Activity_Template}
3460
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_guid' hook.
@@ -3464,13 +4070,20 @@ function bp_activity_feed_item_guid() {
3464
  function bp_get_activity_feed_item_guid() {
3465
  global $activities_template;
3466
 
 
 
 
 
 
 
 
3467
  return apply_filters( 'bp_get_activity_feed_item_guid', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) );
3468
  }
3469
 
3470
  /**
3471
  * Output the activity feed item title.
3472
  *
3473
- * @since BuddyPress (1.0)
3474
  *
3475
  * @uses bp_get_activity_feed_item_title()
3476
  */
@@ -3481,7 +4094,7 @@ function bp_activity_feed_item_title() {
3481
  /**
3482
  * Return the activity feed item title.
3483
  *
3484
- * @since BuddyPress (1.0)
3485
  *
3486
  * @global object $activities_template {@link BP_Activity_Template}
3487
  * @uses ent2ncr()
@@ -3511,13 +4124,20 @@ function bp_activity_feed_item_title() {
3511
  $title .= ': ' . strip_tags( ent2ncr( trim( convert_chars( bp_create_excerpt( $activities_template->activity->content, 70, array( 'ending' => " [&#133;]" ) ) ) ) ) );
3512
  }
3513
 
 
 
 
 
 
 
 
3514
  return apply_filters( 'bp_get_activity_feed_item_title', $title );
3515
  }
3516
 
3517
  /**
3518
  * Output the activity feed item link
3519
  *
3520
- * @since BuddyPress (1.0)
3521
  *
3522
  * @uses bp_get_activity_feed_item_link()
3523
  */
@@ -3528,7 +4148,7 @@ function bp_activity_feed_item_link() {
3528
  /**
3529
  * Return the activity feed item link
3530
  *
3531
- * @since BuddyPress (1.0)
3532
  *
3533
  * @global object $activities_template {@link BP_Activity_Template}
3534
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_link' hook.
@@ -3542,13 +4162,20 @@ function bp_activity_feed_item_link() {
3542
  ? $activities_template->activity->primary_link
3543
  : '';
3544
 
 
 
 
 
 
 
 
3545
  return apply_filters( 'bp_get_activity_feed_item_link', $retval );
3546
  }
3547
 
3548
  /**
3549
  * Output the activity feed item date.
3550
  *
3551
- * @since BuddyPress (1.0)
3552
  *
3553
  * @uses bp_get_activity_feed_item_date()
3554
  */
@@ -3559,7 +4186,7 @@ function bp_activity_feed_item_date() {
3559
  /**
3560
  * Return the activity feed item date.
3561
  *
3562
- * @since BuddyPress (1.0)
3563
  *
3564
  * @global object $activities_template {@link BP_Activity_Template}
3565
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_date' hook.
@@ -3573,13 +4200,20 @@ function bp_activity_feed_item_date() {
3573
  ? $activities_template->activity->date_recorded
3574
  : '';
3575
 
 
 
 
 
 
 
 
3576
  return apply_filters( 'bp_get_activity_feed_item_date', $retval );
3577
  }
3578
 
3579
  /**
3580
  * Output the activity feed item description.
3581
  *
3582
- * @since BuddyPress (1.0)
3583
  *
3584
  * @uses bp_get_activity_feed_item_description()
3585
  */
@@ -3590,7 +4224,7 @@ function bp_activity_feed_item_description() {
3590
  /**
3591
  * Return the activity feed item description.
3592
  *
3593
- * @since BuddyPress (1.0)
3594
  *
3595
  * @global object $activities_template {@link BP_Activity_Template}
3596
  * @uses ent2ncr()
@@ -3612,13 +4246,20 @@ function bp_activity_feed_item_description() {
3612
  $content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) );
3613
  }
3614
 
 
 
 
 
 
 
 
3615
  return apply_filters( 'bp_get_activity_feed_item_description', $content );
3616
  }
3617
 
3618
  /**
3619
  * Template tag so we can hook activity feed to <head>.
3620
  *
3621
- * @since BuddyPress (1.5)
3622
  *
3623
  * @uses bloginfo()
3624
  * @uses bp_sitewide_activity_feed_link()
@@ -3667,7 +4308,7 @@ function bp_activity_show_filters( $context = '' ) {
3667
  }
3668
 
3669
  // On individual group pages, default to 'group'
3670
- } else if ( bp_is_active( 'groups' ) && bp_is_group() ) {
3671
  $context = 'group';
3672
 
3673
  // 'activity' everywhere else
@@ -3680,7 +4321,7 @@ function bp_activity_show_filters( $context = '' ) {
3680
 
3681
  // Walk through the registered actions, and prepare an the
3682
  // select box options.
3683
- foreach ( buddypress()->activity->actions as $actions ) {
3684
  foreach ( $actions as $action ) {
3685
  if ( ! in_array( $context, (array) $action['context'] ) ) {
3686
  continue;
@@ -3696,17 +4337,14 @@ function bp_activity_show_filters( $context = '' ) {
3696
  }
3697
 
3698
  /**
3699
- * Modify the filter options available in the activity filter dropdown.
3700
  *
3701
- * @since BuddyPress (2.1.0)
3702
  *
3703
- * @param array $filters Array of filter options for the given
3704
- * context, in the following format:
3705
- * $option_value => $option_name
3706
- * @param string $context Context for the filter. 'activity'
3707
- * 'member', 'member_groups', 'group'.
3708
  */
3709
- $filters = apply_filters( 'bp_get_activity_show_filters', $filters, $context );
3710
 
3711
  // Build the options output
3712
  $output = '';
@@ -3717,5 +4355,14 @@ function bp_activity_show_filters( $context = '' ) {
3717
  }
3718
  }
3719
 
 
 
 
 
 
 
 
 
 
3720
  return apply_filters( 'bp_get_activity_show_filters', $output, $filters, $context );
3721
  }
13
  /**
14
  * Output the activity component slug.
15
  *
16
+ * @since BuddyPress (1.5.0)
17
  *
18
  * @uses bp_get_activity_slug()
19
  */
23
  /**
24
  * Return the activity component slug.
25
  *
26
+ * @since BuddyPress (1.5.0)
27
  *
28
  * @uses apply_filters() To call the 'bp_get_activity_slug' hook.
29
  *
30
  * @return string The activity component slug.
31
  */
32
  function bp_get_activity_slug() {
33
+
34
+ /**
35
+ * Filters the activity component slug.
36
+ *
37
+ * @since BuddyPress (1.5.0)
38
+ *
39
+ * @param string $slug Activity component slug.
40
+ */
41
  return apply_filters( 'bp_get_activity_slug', buddypress()->activity->slug );
42
  }
43
 
44
  /**
45
  * Output the activity component root slug.
46
  *
47
+ * @since BuddyPress (1.5.0)
48
  *
49
  * @uses bp_get_activity_root_slug()
50
  */
54
  /**
55
  * Return the activity component root slug.
56
  *
57
+ * @since BuddyPress (1.5.0)
58
  *
59
  * @uses apply_filters() To call the 'bp_get_activity_root_slug' hook.
60
  *
61
  * @return string The activity component root slug.
62
  */
63
  function bp_get_activity_root_slug() {
64
+
65
+ /**
66
+ * Filters the activity component root slug.
67
+ *
68
+ * @since BuddyPress (1.5.0)
69
+ *
70
+ * @param string $root_slug Activity component root slug.
71
+ */
72
  return apply_filters( 'bp_get_activity_root_slug', buddypress()->activity->root_slug );
73
  }
74
 
75
  /**
76
  * Output activity directory permalink.
77
  *
78
+ * @since BuddyPress (1.5.0)
79
  *
80
  * @uses bp_get_activity_directory_permalink()
81
  */
85
  /**
86
  * Return activity directory permalink
87
  *
88
+ * @since BuddyPress (1.5.0)
89
  *
90
+ * @uses trailingslashit()
91
  * @uses bp_get_root_domain()
92
  * @uses bp_get_activity_root_slug()
93
  * @uses apply_filters() To call the 'bp_get_activity_directory_permalink' hook.
95
  * @return string Activity directory permalink.
96
  */
97
  function bp_get_activity_directory_permalink() {
98
+
99
+ /**
100
+ * Filters the activity directory permalink.
101
+ *
102
+ * @since BuddyPress (1.5.0)
103
+ *
104
+ * @param string $url Permalink url for the activity directory.
105
+ */
106
  return apply_filters( 'bp_get_activity_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() ) );
107
  }
108
 
111
  *
112
  * This is responsible for loading a group of activity items and displaying them.
113
  *
114
+ * @since BuddyPress (1.0.0)
115
  */
116
  class BP_Activity_Template {
117
  var $current_activity = -1;
195
  'per_page' => 20,
196
  'page_arg' => 'acpage',
197
  'max' => false,
198
+ 'count_total' => false,
199
  'sort' => false,
200
  'include' => false,
201
  'exclude' => false,
202
  'in' => false,
203
  'filter' => false,
204
+ 'scope' => false,
205
  'search_terms' => false,
206
  'meta_query' => false,
207
  'date_query' => false,
208
+ 'filter_query' => false,
209
  'display_comments' => 'threaded',
210
  'show_hidden' => false,
211
  'spam' => 'ham_only',
229
  $this->activities = bp_activity_get_specific( array(
230
  'activity_ids' => explode( ',', $include ),
231
  'max' => $max,
232
+ 'count_total' => $count_total,
233
  'page' => $this->pag_page,
234
  'per_page' => $this->pag_num,
235
  'sort' => $sort,
244
  $this->activities = bp_activity_get( array(
245
  'display_comments' => $display_comments,
246
  'max' => $max,
247
+ 'count_total' => $count_total,
248
  'per_page' => $this->pag_num,
249
  'page' => $this->pag_page,
250
  'sort' => $sort,
251
  'search_terms' => $search_terms,
252
  'meta_query' => $meta_query,
253
  'date_query' => $date_query,
254
+ 'filter_query' => $filter_query,
255
  'filter' => $filter,
256
+ 'scope' => $scope,
257
  'show_hidden' => $show_hidden,
258
  'exclude' => $exclude,
259
  'in' => $in,
314
  'current' => (int) $this->pag_page,
315
  'prev_text' => _x( '&larr;', 'Activity pagination previous text', 'buddypress' ),
316
  'next_text' => _x( '&rarr;', 'Activity pagination next text', 'buddypress' ),
317
+ 'mid_size' => 1,
318
+ 'add_args' => array(),
319
  ) );
320
  }
321
  }
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.
378
+ *
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
  }
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.
411
+ *
412
+ * @since BuddyPress (1.1.0)
413
+ */
414
  do_action('activity_loop_start');
415
+ }
416
  }
417
  }
418
 
423
  * $activities_template global, enabling the use of BuddyPress templates and
424
  * template functions to display a list of activity items.
425
  *
426
+ * @since BuddyPress (1.0.0)
427
  *
428
  * @global object $activities_template {@link BP_Activity_Template}
429
  * @global object $bp BuddyPress global settings.
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
446
+ * ways, and because bp_has_activities() determines some default arguments in
447
+ * a dynamic fashion, we list all accepted arguments here as well.
448
+ *
449
+ * Arguments can be passed as an associative array, or as a URL querystring
450
+ * (eg, 'user_id=4&display_comments=threaded').
451
+ *
452
+ * @type int $page Which page of results to fetch. Using page=1 without per_page will result
453
+ * in no pagination. Default: 1.
454
+ * @type int|bool $per_page Number of results per page. Default: 20.
455
+ * @type string $page_arg String used as a query parameter in pagination links. Default: 'acpage'.
456
+ * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
457
+ * @type string|bool $count_total If true, an additional DB query is run to count the total activity items
458
+ * for the query. Default: false.
459
+ * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
460
+ * @type array|bool $exclude Array of activity IDs to exclude. Default: false.
461
+ * @type array|bool $in Array of IDs to limit query by (IN). 'in' is intended to be used in
462
+ * conjunction with other filter parameters. Default: false.
463
+ * @type array|bool $include Array of exact activity IDs to query. Providing an 'include' array will
464
+ * override all other filters passed in the argument array. When viewing the
465
+ * permalink page for a single activity item, this value defaults to the ID of
466
+ * that item. Otherwise the default is false.
467
+ * @type array $meta_query Limit by activitymeta by passing an array of meta_query conditions. See
468
+ * {@link WP_Meta_Query::queries} for a description of the syntax.
469
+ * @type array $date_query Limit by date by passing an array of date_query conditions. See first
470
+ * parameter of {@link WP_Date_Query::__construct()} for syntax.
471
+ * @type array $filter_query Advanced activity filtering. See {@link BP_Activity_Query::__construct()}.
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
483
+ * defaults to false.
484
+ * @type int|array|bool $user_id The ID(s) of user(s) whose activity should be fetched. Pass a single ID or
485
+ * an array of IDs. When viewing a user profile page (but not that user's
486
+ * activity subpages, ie My Friends, My Groups, etc), 'user_id' defaults to
487
+ * the ID of the displayed user. Otherwise the default is false.
488
+ * @type string|array|bool $object Filters by the `component` column in the database, which is generally the
489
+ * component ID in the case of BuddyPress components, or the plugin slug in
490
+ * the case of plugins. For example, 'groups' will limit results to those that
491
+ * are associated with the BP Groups component. Accepts a single component
492
+ * string, or an array of multiple components. Defaults to 'groups' when
493
+ * viewing the page of a single group, the My Groups activity filter, or the
494
+ * Activity > Groups filter of a user profile. Otherwise defaults to false.
495
+ * @type string|array|bool $action Filters by the `type` column in the database, which is a string
496
+ * categorizing the activity item (eg, 'new_blog_post', 'created_group').
497
+ * Accepts a comma-delimited string or an array of types. Default: false.
498
+ * @type int|array|bool $primary_id Filters by the `item_id` column in the database. The meaning of
499
+ * 'primary_id' differs between components/types; for example, in the case of
500
+ * 'created_group', 'primary_id' is the ID of the group. Accepts a single ID,
501
+ * or an array of multiple IDs. When viewing a single group, defaults to the
502
+ * current group ID. When viewing a user's Groups stream page, defaults to the
503
+ * IDs of the user's groups. Otherwise defaults to false.
504
+ * @type int|array|bool $secondary_id Filters by the `secondary_item_id` column in the database. The meaning of
505
+ * 'secondary_id' differs between components/types. Accepts a single ID, or an
506
+ * array of multiple IDs. Defaults to false.
507
+ * @type int $offset Return only activity items with an ID greater than or equal to this one.
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.
524
+ * Default: true.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  * }
526
  * @return bool Returns true when activities are found, otherwise false.
527
  */
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
 
596
 
597
  'meta_query' => false, // filter on activity meta. See WP_Meta_Query for format
598
  'date_query' => false, // filter by date. See first parameter of WP_Date_Query for format
599
+ 'filter_query' => false, // advanced filtering. See BP_Activity_Query for format
600
 
601
  // Searching
602
  'search_terms' => false, // specify terms to search on
618
  $page = 0;
619
  }
620
 
621
+ // Search terms
622
  if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) )
623
  $search_terms = $_REQUEST['s'];
624
 
625
+ // Set some default arguments when using a scope
626
+ if ( ! empty( $scope ) ) {
627
+ // Determine which user ID applies
628
+ if ( empty( $user_id ) ) {
 
 
 
629
  $user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id();
630
+ }
631
 
632
+ // Should we show all items regardless of sitewide visibility?
633
+ if ( ! empty( $user_id ) ) {
634
+ $show_hidden = ( $user_id == bp_loggedin_user_id() ) ? 1 : 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
  }
636
  }
637
 
639
  if ( !empty( $max ) && ( (int) $per_page > (int) $max ) )
640
  $per_page = $max;
641
 
642
+ /**
643
+ * Filters whether BuddyPress should enable afilter support.
644
+ *
645
+ * Support for basic filters in earlier BP versions is disabled by default.
646
+ * To enable, put add_filter( 'bp_activity_enable_afilter_support', '__return_true' );
647
+ * into bp-custom.php or your theme's functions.php.
648
+ *
649
+ * @since BuddyPress (1.6.0)
650
+ *
651
+ * @param bool $value True if BuddyPress should enable afilter support.
652
+ */
653
  if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) )
654
  $filter = array( 'object' => $_GET['afilter'] );
655
+ elseif ( ! empty( $user_id ) || ! empty( $object ) || ! empty( $action ) || ! empty( $primary_id ) || ! empty( $secondary_id ) || ! empty( $offset ) || ! empty( $since ) )
656
  $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id, 'offset' => $offset, 'since' => $since );
657
  else
658
  $filter = false;
666
  'per_page' => $per_page,
667
  'page_arg' => $page_arg,
668
  'max' => $max,
669
+ 'count_total' => $count_total,
670
  'sort' => $sort,
671
  'include' => $include,
672
  'exclude' => $exclude,
673
  'in' => $in,
674
  'filter' => $filter,
675
+ 'scope' => $scope,
676
  'search_terms' => $search_terms,
677
  'meta_query' => $meta_query,
678
  'date_query' => $date_query,
679
+ 'filter_query' => $filter_query,
680
  'display_comments' => $display_comments,
681
  'show_hidden' => $show_hidden,
682
  'spam' => $spam,
685
 
686
  $activities_template = new BP_Activity_Template( $template_args );
687
 
688
+ /**
689
+ * Filters whether or not there are activity items to display.
690
+ *
691
+ * @since BuddyPress (1.1.0)
692
+ *
693
+ * @param bool $has_activities Whether or not there are activity items to display.
694
+ * @param string $activities_template Current activities template being used.
695
+ * @param array $template_args Array of arguments passed into the BP_Activity_Template class.
696
+ */
697
  return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template, $template_args );
698
  }
699
 
700
  /**
701
  * Determine if there are still activities left in the loop.
702
  *
703
+ * @since BuddyPress (1.0.0)
704
  *
705
  * @global object $activities_template {@link BP_Activity_Template}
706
  * @uses BP_Activity_Template::user_activities() {@link BP_Activity_Template::user_activities()}
715
  /**
716
  * Get the current activity object in the loop.
717
  *
718
+ * @since BuddyPress (1.0.0)
719
  *
720
  * @global object $activities_template {@link BP_Activity_Template}
721
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
741
  $link = bp_get_requested_url();
742
  $link = add_query_arg( $activities_template->pag_arg, $activities_template->pag_page + 1, $link );
743
 
744
+ /**
745
+ * Filters the Load More link URL.
746
+ *
747
+ * @since BuddyPress (2.1.0)
748
+ *
749
+ * @param string $link The Load More link URL.
750
+ */
751
  return apply_filters( 'bp_get_activity_load_more_link', $link );
752
  }
753
 
754
  /**
755
  * Output the activity pagination count.
756
  *
757
+ * @since BuddyPress (1.0.0)
758
  *
759
  * @global object $activities_template {@link BP_Activity_Template}
760
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
766
  /**
767
  * Return the activity pagination count.
768
  *
769
+ * @since BuddyPress (1.2.0)
770
  *
771
  * @global object $activities_template {@link BP_Activity_Template}
772
  * @uses bp_core_number_format()
787
  /**
788
  * Output the activity pagination links.
789
  *
790
+ * @since BuddyPress (1.0.0)
791
  *
792
  * @uses bp_get_activity_pagination_links()
793
  */
798
  /**
799
  * Return the activity pagination links.
800
  *
801
+ * @since BuddyPress (1.0.0)
802
  *
803
  * @global object $activities_template {@link BP_Activity_Template}
804
  * @uses apply_filters() To call the 'bp_get_activity_pagination_links' hook.
808
  function bp_get_activity_pagination_links() {
809
  global $activities_template;
810
 
811
+ /**
812
+ * Filters the activity pagination link output.
813
+ *
814
+ * @since BuddyPress (1.0.0)
815
+ *
816
+ * @param string $pag_links Output for the activity pagination links.
817
+ */
818
  return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
819
  }
820
 
821
  /**
822
  * Return true when there are more activity items to be shown than currently appear.
823
  *
824
+ * @since BuddyPress (1.5.0)
825
  *
826
  * @global object $activities_template {@link BP_Activity_Template}
827
  * @uses apply_filters() To call the 'bp_activity_has_more_items' hook.
843
  $has_more_items = (int) $remaining_pages > 0;
844
  }
845
 
846
+ /**
847
+ * Filters whether there are more activity items to display.
848
+ *
849
+ * @since BuddyPress (1.5.0)
850
+ *
851
+ * @param bool $has_more_items Whether or not there are more activity items to display.
852
+ */
853
  return apply_filters( 'bp_activity_has_more_items', $has_more_items );
854
  }
855
 
856
  /**
857
  * Output the activity count.
858
  *
859
+ * @since BuddyPress (1.2.0)
860
  *
861
  * @uses bp_get_activity_count()
862
  */
867
  /**
868
  * Return the activity count.
869
  *
870
+ * @since BuddyPress (1.2.0)
871
  *
872
  * @global object $activities_template {@link BP_Activity_Template}
873
  * @uses apply_filters() To call the 'bp_get_activity_count' hook.
877
  function bp_get_activity_count() {
878
  global $activities_template;
879
 
880
+ /**
881
+ * Filters the activity count for the activity template.
882
+ *
883
+ * @since BuddyPress (1.2.0)
884
+ *
885
+ * @param int $activity_count The count for total activity.
886
+ */
887
  return apply_filters( 'bp_get_activity_count', (int) $activities_template->activity_count );
888
  }
889
 
890
  /**
891
  * Output the number of activities per page.
892
  *
893
+ * @since BuddyPress (1.2.0)
894
  *
895
  * @uses bp_get_activity_per_page()
896
  */
901
  /**
902
  * Return the number of activities per page.
903
  *
904
+ * @since BuddyPress (1.2.0)
905
  *
906
  * @global object $activities_template {@link BP_Activity_Template}
907
  * @uses apply_filters() To call the 'bp_get_activity_per_page' hook.
911
  function bp_get_activity_per_page() {
912
  global $activities_template;
913
 
914
+ /**
915
+ * Filters the activity posts per page value.
916
+ *
917
+ * @since BuddyPress (1.2.0)
918
+ *
919
+ * @param int $pag_num How many post should be displayed for pagination.
920
+ */
921
  return apply_filters( 'bp_get_activity_per_page', (int) $activities_template->pag_num );
922
  }
923
 
924
  /**
925
  * Output the activities title.
926
  *
927
+ * @since BuddyPress (1.0.0)
928
  *
929
  * @uses bp_get_activities_title()
930
  * @todo Deprecate.
936
  /**
937
  * Return the activities title.
938
  *
939
+ * @since BuddyPress (1.0.0)
940
  *
941
  * @global string $bp_activity_title
942
  * @uses apply_filters() To call the 'bp_get_activities_title' hook.
943
  * @todo Deprecate.
944
  *
945
+ * @return string The activities title.
946
  */
947
  function bp_get_activities_title() {
948
  global $bp_activity_title;
949
 
950
+ /**
951
+ * Filters the activities title for the activity template.
952
+ *
953
+ * @since BuddyPress (1.0.0)
954
+ *
955
+ * @param string $bp_activity_title The title to be displayed.
956
+ */
957
  return apply_filters( 'bp_get_activities_title', $bp_activity_title );
958
  }
959
 
960
  /**
961
  * {@internal Missing Description}
962
  *
963
+ * @since BuddyPress (1.0.0)
964
  *
965
  * @uses bp_get_activities_no_activity()
966
  * @todo Deprecate.
972
  /**
973
  * {@internal Missing Description}
974
  *
975
+ * @since BuddyPress (1.0.0)
976
  *
977
  * @global string $bp_activity_no_activity
978
  * @uses apply_filters() To call the 'bp_get_activities_no_activity' hook
983
  function bp_get_activities_no_activity() {
984
  global $bp_activity_no_activity;
985
 
986
+ /**
987
+ * Filters the text used when there is no activity to display.
988
+ *
989
+ * @since BuddyPress (1.0.0)
990
+ *
991
+ * @param string $bp_activity_no_activity Text to display for no activity.
992
+ */
993
  return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
994
  }
995
 
996
  /**
997
  * Output the activity ID.
998
  *
999
+ * @since BuddyPress (1.2.0)
1000
  *
1001
  * @uses bp_get_activity_id()
1002
  */
1007
  /**
1008
  * Return the activity ID.
1009
  *
1010
+ * @since BuddyPress (1.2.0)
1011
  *
1012
  * @global object $activities_template {@link BP_Activity_Template}
1013
  * @uses apply_filters() To call the 'bp_get_activity_id' hook.
1016
  */
1017
  function bp_get_activity_id() {
1018
  global $activities_template;
1019
+
1020
+ /**
1021
+ * Filters the activity ID being displayed.
1022
+ *
1023
+ * @since BuddyPress (1.2.0)
1024
+ *
1025
+ * @param int $id The activity ID.
1026
+ */
1027
  return apply_filters( 'bp_get_activity_id', $activities_template->activity->id );
1028
  }
1029
 
1030
  /**
1031
  * Output the activity item ID.
1032
  *
1033
+ * @since BuddyPress (1.2.0)
1034
  *
1035
  * @uses bp_get_activity_item_id()
1036
  */
1041
  /**
1042
  * Return the activity item ID.
1043
  *
1044
+ * @since BuddyPress (1.2.0)
1045
  *
1046
  * @global object $activities_template {@link BP_Activity_Template}
1047
  * @uses apply_filters() To call the 'bp_get_activity_item_id' hook.
1050
  */
1051
  function bp_get_activity_item_id() {
1052
  global $activities_template;
1053
+
1054
+ /**
1055
+ * Filters the activity item ID being displayed.
1056
+ *
1057
+ * @since BuddyPress (1.2.0)
1058
+ *
1059
+ * @param int $item_id The activity item ID.
1060
+ */
1061
  return apply_filters( 'bp_get_activity_item_id', $activities_template->activity->item_id );
1062
  }
1063
 
1064
  /**
1065
  * Output the activity secondary item ID.
1066
  *
1067
+ * @since BuddyPress (1.2.0)
1068
  *
1069
  * @uses bp_get_activity_secondary_item_id()
1070
  */
1075
  /**
1076
  * Return the activity secondary item ID.
1077
  *
1078
+ * @since BuddyPress (1.2.0)
1079
  *
1080
  * @global object $activities_template {@link BP_Activity_Template}
1081
  * @uses apply_filters() To call the 'bp_get_activity_secondary_item_id' hook.
1084
  */
1085
  function bp_get_activity_secondary_item_id() {
1086
  global $activities_template;
1087
+
1088
+ /**
1089
+ * Filters the activity secondary item ID being displayed.
1090
+ *
1091
+ * @since BuddyPress (1.2.0)
1092
+ *
1093
+ * @param int $secondary_item_id The activity secondary item ID.
1094
+ */
1095
  return apply_filters( 'bp_get_activity_secondary_item_id', $activities_template->activity->secondary_item_id );
1096
  }
1097
 
1098
  /**
1099
  * Output the date the activity was recorded.
1100
  *
1101
+ * @since BuddyPress (1.2.0)
1102
  *
1103
  * @uses bp_get_activity_date_recorded()
1104
  */
1109
  /**
1110
  * Return the date the activity was recorded.
1111
  *
1112
+ * @since BuddyPress (1.2.0)
1113
  *
1114
  * @global object $activities_template {@link BP_Activity_Template}
1115
  * @uses apply_filters() To call the 'bp_get_activity_date_recorded' hook.
1118
  */
1119
  function bp_get_activity_date_recorded() {
1120
  global $activities_template;
1121
+
1122
+ /**
1123
+ * Filters the date the activity was recorded.
1124
+ *
1125
+ * @since BuddyPress (1.2.0)
1126
+ *
1127
+ * @param int $date_recorded The activity's date.
1128
+ */
1129
  return apply_filters( 'bp_get_activity_date_recorded', $activities_template->activity->date_recorded );
1130
  }
1131
 
1157
  ? $activities_template->activity->display_name
1158
  : '';
1159
 
1160
+ /**
1161
+ * Filters the display name of the member who posted the activity.
1162
+ *
1163
+ * @since BuddyPress (2.1.0)
1164
+ *
1165
+ * @param int $retval Display name for the member who posted.
1166
+ */
1167
  return apply_filters( 'bp_get_activity_member_display_name', $retval );
1168
  }
1169
 
1170
  /**
1171
  * Output the activity object name.
1172
  *
1173
+ * @since BuddyPress (1.2.0)
1174
  *
1175
  * @uses bp_get_activity_object_name()
1176
  */
1181
  /**
1182
  * Return the activity object name.
1183
  *
1184
+ * @since BuddyPress (1.2.0)
1185
  *
1186
  * @global object $activities_template {@link BP_Activity_Template}
1187
  * @uses apply_filters() To call the 'bp_get_activity_object_name' hook.
1190
  */
1191
  function bp_get_activity_object_name() {
1192
  global $activities_template;
1193
+
1194
+ /**
1195
+ * Filters the activity object name.
1196
+ *
1197
+ * @since BuddyPress (1.2.0)
1198
+ *
1199
+ * @param string $activity_component The activity object name.
1200
+ */
1201
  return apply_filters( 'bp_get_activity_object_name', $activities_template->activity->component );
1202
  }
1203
 
1204
  /**
1205
  * Output the activity type.
1206
  *
1207
+ * @since BuddyPress (1.2.0)
1208
  *
1209
  * @uses bp_get_activity_type()
1210
  */
1215
  /**
1216
  * Return the activity type.
1217
  *
1218
+ * @since BuddyPress (1.2.0)
1219
  *
1220
  * @global object $activities_template {@link BP_Activity_Template}
1221
  * @uses apply_filters() To call the 'bp_get_activity_type' hook.
1224
  */
1225
  function bp_get_activity_type() {
1226
  global $activities_template;
1227
+
1228
+ /**
1229
+ * Filters the activity type.
1230
+ *
1231
+ * @since BuddyPress (1.2.0)
1232
+ *
1233
+ * @param string $activity_type The activity type.
1234
+ */
1235
  return apply_filters( 'bp_get_activity_type', $activities_template->activity->type );
1236
  }
1237
 
1240
  *
1241
  * Just a wrapper for bp_activity_type().
1242
  *
1243
+ * @since BuddyPress (1.2.0)
1244
+ * @deprecated BuddyPress (1.5.0)
1245
  *
1246
  * @todo Properly deprecate in favor of bp_activity_type() and
1247
  * remove redundant echo
1255
  *
1256
  * Just a wrapper for bp_get_activity_type().
1257
  *
1258
+ * @since BuddyPress (1.2.0)
1259
+ * @deprecated BuddyPress (1.5.0)
1260
  *
1261
  * @todo Properly deprecate in favor of bp_get_activity_type().
1262
  *
1269
  /**
1270
  * Output the activity user ID.
1271
  *
1272
+ * @since BuddyPress (1.1.0)
1273
  *
1274
  * @uses bp_get_activity_user_id()
1275
  */
1280
  /**
1281
  * Return the activity user ID.
1282
  *
1283
+ * @since BuddyPress (1.1.0)
1284
  *
1285
  * @global object $activities_template {@link BP_Activity_Template}
1286
  * @uses apply_filters() To call the 'bp_get_activity_user_id' hook.
1289
  */
1290
  function bp_get_activity_user_id() {
1291
  global $activities_template;
1292
+
1293
+ /**
1294
+ * Filters the activity user ID.
1295
+ *
1296
+ * @since BuddyPress (1.1.0)
1297
+ *
1298
+ * @param int $user_id The activity user ID.
1299
+ */
1300
  return apply_filters( 'bp_get_activity_user_id', $activities_template->activity->user_id );
1301
  }
1302
 
1303
  /**
1304
  * Output the activity user link.
1305
  *
1306
+ * @since BuddyPress (1.2.0)
1307
  *
1308
  * @uses bp_get_activity_user_link()
1309
  */
1314
  /**
1315
  * Return the activity user link.
1316
  *
1317
+ * @since BuddyPress (1.2.0)
1318
  *
1319
  * @global object $activities_template {@link BP_Activity_Template}
1320
  * @uses bp_core_get_user_domain()
1331
  $link = bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login );
1332
  }
1333
 
1334
+ /**
1335
+ * Filters the activity user link.
1336
+ *
1337
+ * @since BuddyPress (1.2.0)
1338
+ *
1339
+ * @param string $link The activity user link.
1340
+ */
1341
  return apply_filters( 'bp_get_activity_user_link', $link );
1342
  }
1343
 
1344
  /**
1345
  * Output the avatar of the user that performed the action.
1346
  *
1347
+ * @since BuddyPress (1.1.0)
1348
  *
1349
  * @see bp_get_activity_avatar() for description of arguments.
1350
  * @uses bp_get_activity_avatar()
1357
  /**
1358
  * Return the avatar of the user that performed the action.
1359
  *
1360
+ * @since BuddyPress (1.1.0)
1361
  *
1362
  * @see bp_core_fetch_avatar() For a description of the arguments.
1363
  * @global object $activities_template {@link BP_Activity_Template}
1430
  }
1431
  }
1432
 
1433
+ /**
1434
+ * Filters the activity avatar object based on current activity item component.
1435
+ *
1436
+ * This is a variable filter dependent on the component used.
1437
+ * Possible hooks are bp_get_activity_avatar_object_blog,
1438
+ * bp_get_activity_avatar_object_group, and bp_get_activity_avatar_object_user.
1439
+ *
1440
+ * @since BuddyPress (1.1.0)
1441
+ *
1442
+ * @param string $component Component being displayed.
1443
+ */
1444
  $object = apply_filters( 'bp_get_activity_avatar_object_' . $current_activity_item->component, 'user' );
1445
  $item_id = !empty( $user_id ) ? $user_id : $current_activity_item->user_id;
1446
+
1447
+ /**
1448
+ * Filters the activity avatar item ID.
1449
+ *
1450
+ * @since BuddyPress (1.2.10)
1451
+ *
1452
+ * @param int $item_id Item ID for the activity avatar.
1453
+ */
1454
  $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $item_id );
1455
 
1456
+ // If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it.
1457
  if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) )
1458
  $email = $current_activity_item->user_email;
1459
 
1460
+ /**
1461
+ * Filters the value returned by bp_core_fetch_avatar.
1462
+ *
1463
+ * @since BuddyPress (1.1.3)
1464
+ *
1465
+ * @param array $value Array of arguments calculated for use with bp_core_fetch_avatar.
1466
+ */
1467
  return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array(
1468
  'item_id' => $item_id,
1469
  'object' => $object,
1479
  /**
1480
  * Output the avatar of the object that action was performed on.
1481
  *
1482
+ * @since BuddyPress (1.2.0)
1483
  *
1484
  * @see bp_get_activity_secondary_avatar() for description of arguments.
1485
  * @uses bp_get_activity_secondary_avatar()
1493
  /**
1494
  * Return the avatar of the object that action was performed on
1495
  *
1496
+ * @since BuddyPress (1.2.0)
1497
  *
1498
  * @see bp_core_fetch_avatar() for description of arguments.
1499
  * @global object $activities_template {@link BP_Activity_Template}
1592
  break;
1593
  }
1594
 
1595
+ /**
1596
+ * Filters the activity secondary avatar object based on current activity item component.
1597
+ *
1598
+ * This is a variable filter dependent on the component used. Possible hooks are
1599
+ * bp_get_activity_secondary_avatar_object_blog, bp_get_activity_secondary_avatar_object_group,
1600
+ * and bp_get_activity_secondary_avatar_object_user.
1601
+ *
1602
+ * @since BuddyPress (1.2.10)
1603
+ *
1604
+ * @param string $object Component being displayed.
1605
+ */
1606
  $object = apply_filters( 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component, $object );
1607
+
1608
+ /**
1609
+ * Filters the activity secondary avatar item ID.
1610
+ *
1611
+ * @since BuddyPress (1.2.10)
1612
+ *
1613
+ * @param int $item_id ID for the secondary avatar item.
1614
+ */
1615
  $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
1616
 
1617
  // If we have no item_id or object, there is no avatar to display
1632
  ) );
1633
 
1634
  if ( !empty( $linked ) ) {
1635
+
1636
+ /**
1637
+ * Filters the secondary avatar link for current activity.
1638
+ *
1639
+ * @since BuddyPress (1.7.0)
1640
+ *
1641
+ * @param string $link Link to wrap the avatar image in.
1642
+ * @param string $component Activity component being acted on.
1643
+ */
1644
  $link = apply_filters( 'bp_get_activity_secondary_avatar_link', $link, $activities_template->activity->component );
1645
 
1646
+ /**
1647
+ * Filters the determined avatar for the secondary activity item.
1648
+ *
1649
+ * @since BuddyPress (1.2.10)
1650
+ *
1651
+ * @param string Formatted HTML <img> element, or raw avatar URL.
1652
+ */
1653
+ $avatar = apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
1654
+
1655
  return sprintf( '<a href="%s" class="%s">%s</a>',
1656
  $link,
1657
  $link_class,
1658
+ $avatar
1659
  );
1660
  }
1661
 
1662
+ /** This filter is documented in bp-activity/bp-activity-template.php */
1663
  return apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
1664
  }
1665
 
1666
  /**
1667
  * Output the activity action
1668
  *
1669
+ * @since BuddyPress (1.2.0)
1670
  *
1671
  * @param array $args See bp_get_activity_action()
1672
  * @uses bp_get_activity_action()
1678
  /**
1679
  * Return the activity action
1680
  *
1681
+ * @since BuddyPress (1.2.0)
1682
  *
1683
  * @global object $activities_template {@link BP_Activity_Template}
1684
  * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
1702
  extract( $args, EXTR_SKIP );
1703
 
1704
  $action = $activities_template->activity->action;
1705
+
1706
+ /**
1707
+ * Filters the activity action before the action is inserted as meta.
1708
+ *
1709
+ * @since BuddyPress (1.2.10)
1710
+ *
1711
+ * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1712
+ */
1713
  $action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array( $action, &$activities_template->activity, $args ) );
1714
 
1715
  if ( ! empty( $action ) && ! $no_timestamp )
1716
  $action = bp_insert_activity_meta( $action );
1717
 
1718
+ /**
1719
+ * Filters the activity action after the action has been inserted as meta.
1720
+ *
1721
+ * @since BuddyPress (1.2.0)
1722
+ *
1723
+ * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1724
+ */
1725
  return apply_filters_ref_array( 'bp_get_activity_action', array( $action, &$activities_template->activity, $args ) );
1726
  }
1727
 
1728
  /**
1729
  * Output the activity content body
1730
  *
1731
+ * @since BuddyPress (1.2.0)
1732
  *
1733
  * @uses bp_get_activity_content_body()
1734
  */
1739
  /**
1740
  * Return the activity content body
1741
  *
1742
+ * @since BuddyPress (1.2.0)
1743
  *
1744
  * @global object $activities_template {@link BP_Activity_Template}
1745
  * @uses bp_insert_activity_meta()
1754
  if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) )
1755
  $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
1756
 
1757
+ /**
1758
+ * Filters the activity content body.
1759
+ *
1760
+ * @since BuddyPress (1.2.0)
1761
+ *
1762
+ * @param array $value Array containing the current activity content body and the current activity.
1763
+ */
1764
  return apply_filters_ref_array( 'bp_get_activity_content_body', array( $activities_template->activity->content, &$activities_template->activity ) );
1765
  }
1766
 
1767
  /**
1768
  * Does the activity have content?
1769
  *
1770
+ * @since BuddyPress (1.2.0)
1771
  *
1772
  * @global object $activities_template {@link BP_Activity_Template}
1773
  *
1785
  /**
1786
  * Output the activity content.
1787
  *
1788
+ * @since BuddyPress (1.0.0)
1789
+ * @deprecated BuddyPress (1.5.0)
1790
  *
1791
  * @todo properly deprecate this function.
1792
  *
1799
  /**
1800
  * Return the activity content.
1801
  *
1802
+ * @since BuddyPress (1.0.0)
1803
+ * @deprecated BuddyPress (1.5.0)
1804
  *
1805
  * @todo properly deprecate this function.
1806
  *
1811
  * @return string The activity content.
1812
  */
1813
  function bp_get_activity_content() {
1814
+
1815
  /**
1816
  * If you want to filter activity update content, please use
1817
  * the filter 'bp_get_activity_content_body'
1818
  *
1819
+ * This function is mainly for backwards compatibility.
1820
  */
 
1821
  $content = bp_get_activity_action() . ' ' . bp_get_activity_content_body();
1822
  return apply_filters( 'bp_get_activity_content', $content );
1823
  }
1828
  * This metadata includes the time since the item was posted (which will appear
1829
  * as a link to the item's permalink).
1830
  *
1831
+ * @since BuddyPress (1.2.0)
1832
  *
1833
  * @global object $activities_template {@link BP_Activity_Template}
1834
  * @uses bp_core_time_since()
1848
  // Strip any legacy time since placeholders from BP 1.0-1.1
1849
  $content = str_replace( '<span class="time-since">%s</span>', '', $content );
1850
 
1851
+ /**
1852
+ * Filters the activity item time since markup.
1853
+ *
1854
+ * @since BuddyPress (1.2.0)
1855
+ *
1856
+ * @param array $value Array containing the time since markup and the current activity component.
1857
+ */
1858
  $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 ) );
1859
 
1860
  // Insert the permalink
1861
+ if ( !bp_is_single_activity() ) {
1862
+
1863
+ /**
1864
+ * Filters the activity permalink to be added to the activity content.
1865
+ *
1866
+ * @since BuddyPress (1.2.0)
1867
+ *
1868
+ * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
1869
+ */
1870
  $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 ) );
1871
+ } else {
1872
  $content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH );
1873
+ }
1874
 
1875
+ /**
1876
+ * Filters the activity content after activity metadata has been attached.
1877
+ *
1878
+ * @since BuddyPress (1.2.0)
1879
+ *
1880
+ * @param string $content Activity content with the activity metadata added.
1881
+ */
1882
  return apply_filters( 'bp_insert_activity_meta', $content );
1883
  }
1884
 
1885
  /**
1886
  * Determine if the current user can delete an activity item.
1887
  *
1888
+ * @since BuddyPress (1.2.0)
1889
  *
1890
  * @global object $activities_template {@link BP_Activity_Template}
1891
  * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
1930
  }
1931
  }
1932
 
1933
+ /**
1934
+ * Filters whether the current user can delete an activity item.
1935
+ *
1936
+ * @since BuddyPress (1.5.0)
1937
+ *
1938
+ * @param bool $can_delete Whether the user can delete the item.
1939
+ * @param object $activity Current activity item object.
1940
+ */
1941
  return (bool) apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
1942
  }
1943
 
1944
  /**
1945
  * Output the activity parent content.
1946
  *
1947
+ * @since BuddyPress (1.2.0)
1948
  *
1949
  * @see bp_get_activity_parent_content() for a description of arguments.
1950
  * @uses bp_get_activity_parent_content()
1958
  /**
1959
  * Return the activity content.
1960
  *
1961
+ * @since BuddyPress (1.2.0)
1962
  *
1963
  * @global object $activities_template {@link BP_Activity_Template}
1964
  * @uses wp_parse_args()
2005
  // Remove images
2006
  $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
2007
 
2008
+ /**
2009
+ * Filters the activity parent content.
2010
+ *
2011
+ * @since BuddyPress (1.2.0)
2012
+ *
2013
+ * @param string $content Content set to be displayed as parent content.
2014
+ */
2015
  return apply_filters( 'bp_get_activity_parent_content', $content );
2016
  }
2017
 
2018
  /**
2019
  * Output the parent activity's user ID.
2020
  *
2021
+ * @since BuddyPress (1.7.0)
2022
  */
2023
  function bp_activity_parent_user_id() {
2024
  echo bp_get_activity_parent_user_id();
2027
  /**
2028
  * Return the parent activity's user ID.
2029
  *
2030
+ * @since BuddyPress (1.7.0)
2031
  *
2032
  * @global BP_Activity_Template $activities_template
2033
  *
2055
 
2056
  $retval = $activities_template->activity_parents[$parent_id]->user_id;
2057
 
2058
+ /**
2059
+ * Filters the activity parent item's user ID.
2060
+ *
2061
+ * @since BuddyPress (1.7.0)
2062
+ *
2063
+ * @param int $retval ID for the activity parent's user.
2064
+ */
2065
  return (int) apply_filters( 'bp_get_activity_parent_user_id', $retval );
2066
  }
2067
 
2068
  /**
2069
  * Output whether or not the current activity is in a current user's favorites.
2070
  *
2071
+ * @since BuddyPress (1.2.0)
2072
  *
2073
  * @uses bp_get_activity_is_favorite()
2074
  */
2079
  /**
2080
  * Return whether the current activity is in a current user's favorites.
2081
  *
2082
+ * @since BuddyPress (1.2.0)
2083
  *
2084
  * @global object $activities_template {@link BP_Activity_Template}
2085
  * @uses apply_filters() To call the 'bp_get_activity_is_favorite' hook.
2089
  function bp_get_activity_is_favorite() {
2090
  global $activities_template;
2091
 
2092
+ /**
2093
+ * Filters whether the current activity item is in the current user's favorites.
2094
+ *
2095
+ * @since BuddyPress (1.2.0)
2096
+ *
2097
+ * @param bool $value Whether or not the current activity item is in the current user's favorites.
2098
+ */
2099
  return (bool) apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array) $activities_template->my_favs ) );
2100
  }
2101
 
2102
  /**
2103
  * Output the comment markup for an activity item.
2104
  *
2105
+ * @since BuddyPress (1.2.0)
2106
  *
2107
  * @todo deprecate $args param
2108
  *
2115
  /**
2116
  * Get the comment markup for an activity item.
2117
  *
2118
+ * @since BuddyPress (1.2.0)
2119
  *
2120
  * @todo deprecate $args param
2121
  *
2142
  * Note: The recursion itself used to happen entirely in this function. Now it is
2143
  * split between here and the comment.php template.
2144
  *
2145
+ * @since BuddyPress (1.2.0)
2146
  *
2147
  * @param object $comment The activity object currently being recursed
2148
  *
2158
  if ( empty( $comment->children ) )
2159
  return false;
2160
 
2161
+ /**
2162
+ * Filters the opening tag for the template that lists activity comments.
2163
+ *
2164
+ * @since BuddyPress (1.6.0)
2165
+ *
2166
+ * @param string $value Opening tag for the HTML markup to use.
2167
+ */
2168
  echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>');
2169
  foreach ( (array) $comment->children as $comment_child ) {
2170
  // Put the comment into the global so it's available to filters
2184
 
2185
  unset( $activities_template->activity->current_comment );
2186
  }
2187
+
2188
+ /**
2189
+ * Filters the closing tag for the template that list activity comments.
2190
+ *
2191
+ * @since BuddyPress (1.6.0)
2192
+ *
2193
+ * @param string $value Closing tag for the HTML markup to use.
2194
+ */
2195
  echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>');
2196
  }
2197
 
2198
  /**
2199
  * Utility function that returns the comment currently being recursed.
2200
  *
2201
+ * @since BuddyPress (1.5.0)
2202
  *
2203
  * @global object $activities_template {@link BP_Activity_Template}
2204
  * @uses apply_filters() To call the 'bp_activity_current_comment' hook.
2211
 
2212
  $current_comment = !empty( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : false;
2213
 
2214
+ /**
2215
+ * Filters the current comment being recursed.
2216
+ *
2217
+ * @since BuddyPress (1.5.0)
2218
+ *
2219
+ * @param object|bool $current_comment The activity comment currently being displayed. False on failure.
2220
+ */
2221
  return apply_filters( 'bp_activity_current_comment', $current_comment );
2222
  }
2223
 
2225
  /**
2226
  * Output the ID of the activity comment currently being displayed.
2227
  *
2228
+ * @since BuddyPress (1.5.0)
2229
  *
2230
  * @uses bp_get_activity_comment_id()
2231
  */
2236
  /**
2237
  * Return the ID of the activity comment currently being displayed.
2238
  *
2239
+ * @since BuddyPress (1.5.0)
2240
  *
2241
  * @global object $activities_template {@link BP_Activity_Template}
2242
  * @uses apply_filters() To call the 'bp_activity_comment_id' hook.
2249
 
2250
  $comment_id = isset( $activities_template->activity->current_comment->id ) ? $activities_template->activity->current_comment->id : false;
2251
 
2252
+ /**
2253
+ * Filters the ID of the activity comment currently being displayed.
2254
+ *
2255
+ * @since BuddyPress (1.5.0)
2256
+ *
2257
+ * @param int|bool $comment_id ID for the comment currently being displayed.
2258
+ */
2259
  return apply_filters( 'bp_activity_comment_id', $comment_id );
2260
  }
2261
 
2262
  /**
2263
  * Output the ID of the author of the activity comment currently being displayed.
2264
  *
2265
+ * @since BuddyPress (1.5.0)
2266
  *
2267
  * @uses bp_get_activity_comment_user_id()
2268
  */
2273
  /**
2274
  * Return the ID of the author of the activity comment currently being displayed.
2275
  *
2276
+ * @since BuddyPress (1.5.0)
2277
  *
2278
  * @global object $activities_template {@link BP_Activity_Template}
2279
  * @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
2286
 
2287
  $user_id = isset( $activities_template->activity->current_comment->user_id ) ? $activities_template->activity->current_comment->user_id : false;
2288
 
2289
+ /**
2290
+ * Filters the ID of the author of the activity comment currently being displayed.
2291
+ *
2292
+ * @since BuddyPress (1.5.0)
2293
+ *
2294
+ * @param int|bool $user_id ID for the author of the comment currently being displayed.
2295
+ */
2296
  return apply_filters( 'bp_activity_comment_user_id', $user_id );
2297
  }
2298
 
2299
  /**
2300
  * Output the author link for the activity comment currently being displayed.
2301
  *
2302
+ * @since BuddyPress (1.5.0)
2303
  *
2304
  * @uses bp_get_activity_comment_user_link()
2305
  */
2310
  /**
2311
  * Return the author link for the activity comment currently being displayed.
2312
  *
2313
+ * @since BuddyPress (1.5.0)
2314
  *
2315
  * @uses bp_core_get_user_domain()
2316
  * @uses bp_get_activity_comment_user_id()
2321
  function bp_get_activity_comment_user_link() {
2322
  $user_link = bp_core_get_user_domain( bp_get_activity_comment_user_id() );
2323
 
2324
+ /**
2325
+ * Filters the author link for the activity comment currently being displayed.
2326
+ *
2327
+ * @since BuddyPress (1.5.0)
2328
+ *
2329
+ * @param string $user_link Link for the author of the activity comment currently being displayed.
2330
+ */
2331
  return apply_filters( 'bp_activity_comment_user_link', $user_link );
2332
  }
2333
 
2334
  /**
2335
  * Output the author name for the activity comment currently being displayed.
2336
  *
2337
+ * @since BuddyPress (1.5.0)
2338
  *
2339
  * @uses bp_get_activity_comment_name()
2340
  */
2348
  * The use of the 'bp_acomment_name' filter is deprecated. Please use
2349
  * 'bp_activity_comment_name'.
2350
  *
2351
+ * @since BuddyPress (1.5.0)
2352
  *
2353
  * @global object $activities_template {@link BP_Activity_Template}
2354
  * @uses apply_filters() To call the 'bp_acomment_name' hook.
2359
  function bp_get_activity_comment_name() {
2360
  global $activities_template;
2361
 
2362
+ if ( isset( $activities_template->activity->current_comment->user_fullname ) ) {
2363
+
2364
  $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment ); // backward compatibility
2365
+ } else {
2366
  $name = $activities_template->activity->current_comment->display_name;
2367
+ }
2368
 
2369
+ /**
2370
+ * Filters the name of the author for the activity comment.
2371
+ *
2372
+ * @since BuddyPress (1.5.0)
2373
+ *
2374
+ * @param string $name Name to be displayed with the activity comment.
2375
+ */
2376
  return apply_filters( 'bp_activity_comment_name', $name );
2377
  }
2378
 
2379
  /**
2380
  * Output the date_recorded of the activity comment currently being displayed.
2381
  *
2382
+ * @since BuddyPress (1.5.0)
2383
  *
2384
  * @uses bp_get_activity_comment_date_recorded()
2385
  */
2390
  /**
2391
  * Return the date_recorded for the activity comment currently being displayed.
2392
  *
2393
+ * @since BuddyPress (1.5.0)
2394
  *
2395
  * @global object $activities_template {@link BP_Activity_Template}
2396
  * @uses bp_core_time_since()
2407
 
2408
  $date_recorded = bp_core_time_since( $activities_template->activity->current_comment->date_recorded );
2409
 
2410
+ /**
2411
+ * Filters the recorded date of the activity comment currently being displayed.
2412
+ *
2413
+ * @since BuddyPress (1.5.0)
2414
+ *
2415
+ * @param string|bool Date for the activity comment currently being displayed.
2416
+ */
2417
  return apply_filters( 'bp_activity_comment_date_recorded', $date_recorded );
2418
  }
2419
 
2420
  /**
2421
  * Output the 'delete' URL for the activity comment currently being displayed.
2422
  *
2423
+ * @since BuddyPress (1.5.0)
2424
  *
2425
  * @uses bp_get_activity_comment_delete_link()
2426
  */
2431
  /**
2432
  * Gets the 'delete' URL for the activity comment currently being displayed
2433
  *
2434
+ * @since BuddyPress (1.5.0)
2435
  *
2436
  * @uses wp_nonce_url()
2437
  * @uses bp_get_root_domain()
2445
  function bp_get_activity_comment_delete_link() {
2446
  $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' );
2447
 
2448
+ /**
2449
+ * Filters the link used for deleting the activity comment currently being displayed.
2450
+ *
2451
+ * @since BuddyPress (1.5.0)
2452
+ *
2453
+ * @param string $link Link to use for deleting the currently displayed activity comment.
2454
+ */
2455
  return apply_filters( 'bp_activity_comment_delete_link', $link );
2456
  }
2457
 
2458
  /**
2459
  * Output the content of the activity comment currently being displayed.
2460
  *
2461
+ * @since BuddyPress (1.5.0)
2462
  *
2463
  * @uses bp_get_activity_comment_content()
2464
  */
2474
  * 'bp_activity_comment_content' to modify the content of activity
2475
  * comments only.
2476
  *
2477
+ * @since BuddyPress (1.5.0)
2478
  *
2479
  * @global object $activities_template {@link BP_Activity_Template}
2480
  * @uses apply_filters() To call the 'bp_get_activity_content' hook.
2485
  function bp_get_activity_comment_content() {
2486
  global $activities_template;
2487
 
2488
+ /** This filter is documented in bp-activity/bp-activity-template.php */
2489
  $content = apply_filters( 'bp_get_activity_content', $activities_template->activity->current_comment->content );
2490
 
2491
+ /**
2492
+ * Filters the content of the current activity comment.
2493
+ *
2494
+ * @since BuddyPress (1.2.0)
2495
+ *
2496
+ * @param string $content The content of the current activity comment.
2497
+ */
2498
  return apply_filters( 'bp_activity_comment_content', $content );
2499
  }
2500
 
2501
  /**
2502
  * Output the activity comment count.
2503
  *
2504
+ * @since BuddyPress (1.2.0)
2505
  *
2506
  * @uses bp_activity_get_comment_count()
2507
  */
2512
  /**
2513
  * Return the comment count of an activity item.
2514
  *
2515
+ * @since BuddyPress (1.2.0)
2516
  *
2517
  * @global object $activities_template {@link BP_Activity_Template}
2518
  * @uses bp_activity_recurse_comment_count()
2535
  ? bp_activity_recurse_comment_count( $activities_template->activity )
2536
  : 0;
2537
 
2538
+ /**
2539
+ * Filters the activity comment count.
2540
+ *
2541
+ * @since BuddyPress (1.2.0)
2542
+ *
2543
+ * @param int $count The activity comment count.
2544
+ */
2545
  return apply_filters( 'bp_activity_get_comment_count', (int) $count );
2546
  }
2547
 
2551
  * This function recursively adds the total number of comments each
2552
  * activity child has, and returns them.
2553
  *
2554
+ * @since BuddyPress (1.2.0)
2555
  *
2556
  * @uses bp_activity_recurse_comment_count()
2557
  * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook
2574
  }
2575
  }
2576
 
2577
+ /**
2578
+ * Filters the total number of comments for the current comment.
2579
+ *
2580
+ * @since BuddyPress (2.1.0)
2581
+ *
2582
+ * @param int $new_count New total count for the current comment.
2583
+ * @param object $comment Activity comment object.
2584
+ * @param int $count Current iteration count for the current comment.
2585
+ */
2586
  return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
2587
  }
2588
 
2599
  *
2600
  * @since BuddyPress (2.0.0)
2601
  *
2602
+ * @return int $depth Depth for the current activity comment
2603
  */
2604
  function bp_activity_get_comment_depth() {
2605
  global $activities_template;
2606
+
2607
+ /**
2608
+ * Filters the comment depth of the current activity comment.
2609
+ *
2610
+ * @since BuddyPress (2.0.0)
2611
+ *
2612
+ * @param int $depth Depth for the current activity comment.
2613
+ */
2614
  return apply_filters( 'bp_activity_get_comment_depth', $activities_template->activity->current_comment->depth );
2615
  }
2616
 
2617
  /**
2618
  * Output the activity comment link.
2619
  *
2620
+ * @since BuddyPress (1.2.0)
2621
  *
2622
  * @uses bp_get_activity_comment_link()
2623
  */
2628
  /**
2629
  * Return the activity comment link.
2630
  *
2631
+ * @since BuddyPress (1.2.0)
2632
  *
2633
  * @global object $activities_template {@link BP_Activity_Template}
2634
  * @uses apply_filters() To call the 'bp_get_activity_comment_link' hook.
2637
  */
2638
  function bp_get_activity_comment_link() {
2639
  global $activities_template;
2640
+
2641
+ /**
2642
+ * Filters the comment link for the current activity comment.
2643
+ *
2644
+ * @since BuddyPress (1.2.0)
2645
+ *
2646
+ * @param string $value Constructed URL parameters with activity IDs.
2647
+ */
2648
  return apply_filters( 'bp_get_activity_comment_link', '?ac=' . $activities_template->activity->id . '/#ac-form-' . $activities_template->activity->id );
2649
  }
2650
 
2651
  /**
2652
  * Output the activity comment form no javascript display CSS.
2653
  *
2654
+ * @since BuddyPress (1.2.0)
2655
  *
2656
  * @uses bp_get_activity_comment_form_nojs_display()
2657
  */
2662
  /**
2663
  * Return the activity comment form no javascript display CSS.
2664
  *
2665
+ * @since BuddyPress (1.2.0)
2666
  *
2667
  * @global object $activities_template {@link BP_Activity_Template}
2668
  *
2680
  /**
2681
  * Output the activity comment form action.
2682
  *
2683
+ * @since BuddyPress (1.2.0)
2684
  *
2685
  * @uses bp_get_activity_comment_form_action()
2686
  */
2691
  /**
2692
  * Return the activity comment form action.
2693
  *
2694
+ * @since BuddyPress (1.2.0)
2695
  *
2696
  * @uses home_url()
2697
  * @uses bp_get_activity_root_slug()
2700
  * @return string The activity comment form action.
2701
  */
2702
  function bp_get_activity_comment_form_action() {
2703
+
2704
+ /**
2705
+ * Filters the activity comment form action URL.
2706
+ *
2707
+ * @since BuddyPress (1.2.0)
2708
+ *
2709
+ * @param string $value URL to use in the comment form's action attribute.
2710
+ */
2711
  return apply_filters( 'bp_get_activity_comment_form_action', home_url( bp_get_activity_root_slug() . '/reply/' ) );
2712
  }
2713
 
2714
  /**
2715
  * Output the activity permalink ID.
2716
  *
2717
+ * @since BuddyPress (1.2.0)
2718
  *
2719
  * @uses bp_get_activity_permalink_id()
2720
  */
2725
  /**
2726
  * Return the activity permalink ID.
2727
  *
2728
+ * @since BuddyPress (1.2.0)
2729
  *
2730
  * @uses apply_filters() To call the 'bp_get_activity_permalink_id' hook.
2731
  *
2732
  * @return string The activity permalink ID.
2733
  */
2734
  function bp_get_activity_permalink_id() {
2735
+
2736
+ /**
2737
+ * Filters the activity action permalink ID.
2738
+ *
2739
+ * @since BuddyPress (1.2.0)
2740
+ *
2741
+ * @param string $value Current action for the activity item.
2742
+ */
2743
  return apply_filters( 'bp_get_activity_permalink_id', bp_current_action() );
2744
  }
2745
 
2746
  /**
2747
  * Output the activity thread permalink.
2748
  *
2749
+ * @since BuddyPress (1.2.0)
2750
  *
2751
  * @uses bp_get_activity_permalink_id()
2752
  */
2757
  /**
2758
  * Return the activity thread permalink.
2759
  *
2760
+ * @since BuddyPress (1.2.0)
2761
  *
2762
  * @uses bp_activity_get_permalink()
2763
  * @uses apply_filters() To call the 'bp_get_activity_thread_permalink' hook.
2769
 
2770
  $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
2771
 
2772
+ /**
2773
+ * Filters the activity thread permalink.
2774
+ *
2775
+ * @since BuddyPress (1.2.0)
2776
+ *
2777
+ * @param string $link The activity thread permalink.
2778
+ */
2779
  return apply_filters( 'bp_get_activity_thread_permalink', $link );
2780
  }
2781
 
2782
  /**
2783
  * Output the activity comment permalink.
2784
  *
2785
+ * @since BuddyPress (1.8.0)
2786
  *
2787
  * @uses bp_get_activity_permalink_id()
2788
  */
2792
  /**
2793
  * Return the activity comment permalink.
2794
  *
2795
+ * @since BuddyPress (1.8.0)
2796
  *
2797
  * @uses bp_activity_get_permalink()
2798
  * @uses apply_filters() To call the 'bp_get_activity_comment_permalink' hook.
2815
  // Append comment ID to end of activity permalink
2816
  $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link;
2817
 
2818
+ /**
2819
+ * Filters the activity comment permalink.
2820
+ *
2821
+ * @since BuddyPress (1.8.0)
2822
+ *
2823
+ * @param string $link Activity comment permalink.
2824
+ * @param int $comment_id ID for the current activity comment.
2825
+ */
2826
  return apply_filters( 'bp_get_activity_comment_permalink', $link, $comment_id );
2827
  }
2828
 
2829
  /**
2830
  * Output the activity favorite link.
2831
  *
2832
+ * @since BuddyPress (1.2.0)
2833
  *
2834
  * @uses bp_get_activity_favorite_link()
2835
  */
2840
  /**
2841
  * Return the activity favorite link.
2842
  *
2843
+ * @since BuddyPress (1.2.0)
2844
  *
2845
  * @global object $activities_template {@link BP_Activity_Template}
2846
  * @uses wp_nonce_url()
2852
  */
2853
  function bp_get_activity_favorite_link() {
2854
  global $activities_template;
2855
+
2856
+ /**
2857
+ * Filters the activity favorite link.
2858
+ *
2859
+ * @since BuddyPress (1.2.0)
2860
+ *
2861
+ * @param string $value Constructed link for favoriting the activity comment.
2862
+ */
2863
  return apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/favorite/' . $activities_template->activity->id . '/' ), 'mark_favorite' ) );
2864
  }
2865
 
2866
  /**
2867
  * Output the activity unfavorite link.
2868
  *
2869
+ * @since BuddyPress (1.2.0)
2870
  *
2871
  * @uses bp_get_activity_unfavorite_link()
2872
  */
2877
  /**
2878
  * Return the activity unfavorite link.
2879
  *
2880
+ * @since BuddyPress (1.2.0)
2881
  *
2882
  * @global object $activities_template {@link BP_Activity_Template}
2883
  * @uses wp_nonce_url()
2889
  */
2890
  function bp_get_activity_unfavorite_link() {
2891
  global $activities_template;
2892
+
2893
+ /**
2894
+ * Filters the activity unfavorite link.
2895
+ *
2896
+ * @since BuddyPress (1.2.0)
2897
+ *
2898
+ * @param string $value Constructed link for unfavoriting the activity comment.
2899
+ */
2900
  return apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/unfavorite/' . $activities_template->activity->id . '/' ), 'unmark_favorite' ) );
2901
  }
2902
 
2903
  /**
2904
  * Output the activity CSS class.
2905
  *
2906
+ * @since BuddyPress (1.0.0)
2907
  *
2908
  * @uses bp_get_activity_css_class()
2909
  */
2914
  /**
2915
  * Return the current activity item's CSS class.
2916
  *
2917
+ * @since BuddyPress (1.0.0)
2918
  *
2919
  * @global object $activities_template {@link BP_Activity_Template}
2920
  * @uses apply_filters() To call the 'bp_activity_mini_activity_types' hook.
2927
  function bp_get_activity_css_class() {
2928
  global $activities_template;
2929
 
2930
+ /**
2931
+ * Filters the available mini activity actions available as CSS classes.
2932
+ *
2933
+ * @since BuddyPress (1.2.0)
2934
+ *
2935
+ * @param array $value Array of classes used to determine classes applied to HTML element.
2936
+ */
2937
  $mini_activity_actions = apply_filters( 'bp_activity_mini_activity_types', array(
2938
  'friendship_accepted',
2939
  'friendship_created',
2951
  if ( bp_activity_get_comment_count() && bp_activity_can_comment() )
2952
  $class .= ' has-comments';
2953
 
2954
+ /**
2955
+ * Filters the determined classes to add to the HTML element.
2956
+ *
2957
+ * @since BuddyPress (1.0.0)
2958
+ *
2959
+ * @param string $value Classes to be added to the HTML element.
2960
+ */
2961
  return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class );
2962
  }
2963
 
2964
  /**
2965
  * Output the activity delete link.
2966
  *
2967
+ * @since BuddyPress (1.1.0)
2968
  *
2969
  * @uses bp_get_activity_delete_link()
2970
  */
2975
  /**
2976
  * Return the activity delete link.
2977
  *
2978
+ * @since BuddyPress (1.1.0)
2979
  *
2980
  * @global object $activities_template {@link BP_Activity_Template}
2981
  * @uses bp_get_root_domain()
3002
 
3003
  $link = '<a href="' . esc_url( $url ) . '" class="button item-button bp-secondary-action ' . $class . ' confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>';
3004
 
3005
+ /**
3006
+ * Filters the activity delete link.
3007
+ *
3008
+ * @since BuddyPress (1.1.0)
3009
+ *
3010
+ * @param string $link Activity delete HTML link.
3011
+ */
3012
  return apply_filters( 'bp_get_activity_delete_link', $link );
3013
  }
3014
 
3052
 
3053
  $url = wp_nonce_url( $url, 'bp_activity_delete_link' );
3054
 
3055
+ /**
3056
+ * Filters the activity delete URL.
3057
+ *
3058
+ * @since BuddyPress (2.1.0)
3059
+ *
3060
+ * @param string $url Activity delete URL.
3061
+ */
3062
  return apply_filters( 'bp_get_activity_delete_url', $url );
3063
  }
3064
 
3065
  /**
3066
  * Output the activity latest update link.
3067
  *
3068
+ * @since BuddyPress (1.2.0)
3069
  *
3070
  * @see bp_get_activity_latest_update() for description of parameters.
3071
  * @uses bp_get_activity_latest_update()
3079
  /**
3080
  * Return the activity latest update link.
3081
  *
3082
+ * @since BuddyPress (1.2.0)
3083
  *
3084
  * @uses bp_is_user_inactive()
3085
  * @uses bp_core_is_user_deleted()
3105
  if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) )
3106
  return false;
3107
 
3108
+ /**
3109
+ * Filters the latest update excerpt.
3110
+ *
3111
+ * @since BuddyPress (1.2.10)
3112
+ *
3113
+ * @param string $value The excerpt for the latest update.
3114
+ */
3115
  $latest_update = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 358 ) ) ) );
 
3116
 
3117
+ $latest_update = sprintf(
3118
+ '%s <a href="%s">%s</a>',
3119
+ $latest_update,
3120
+ esc_url_raw( bp_activity_get_permalink( $update['id'] ) ),
3121
+ esc_attr__( 'View', 'buddypress' )
3122
+ );
3123
+
3124
+ /**
3125
+ * Filters the latest update excerpt with view link appended to the end.
3126
+ *
3127
+ * @since BuddyPress (1.2.0)
3128
+ *
3129
+ * @param string $latest_update The latest update with "view" link appended to it.
3130
+ */
3131
+ return apply_filters( 'bp_get_activity_latest_update', $latest_update );
3132
  }
3133
 
3134
  /**
3135
  * Output the activity filter links.
3136
  *
3137
+ * @since BuddyPress (1.1.0)
3138
  *
3139
  * @see bp_get_activity_filter_links() for description of parameters.
3140
  * @uses bp_get_activity_filter_links()
3148
  /**
3149
  * Return the activity filter links.
3150
  *
3151
+ * @since BuddyPress (1.1.0)
3152
  *
3153
  * @uses wp_parse_args()
3154
  * @uses BP_Activity_Activity::get_recorded_components() {@link BP_Activity_Activity}
3216
 
3217
  $link = add_query_arg( 'afilter', $component );
3218
  $link = remove_query_arg( 'acpage' , $link );
3219
+
3220
+ /**
3221
+ * Filters the activity filter link URL for the current activity component.
3222
+ *
3223
+ * @since BuddyPress (1.1.0)
3224
+ *
3225
+ * @param string $link The URL for the current component.
3226
+ * @param string $component The current component getting links constructed for.
3227
+ */
3228
  $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
3229
 
3230
  $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( $component ) . '</a>' . $after;
3235
  if ( isset( $_GET['afilter'] ) )
3236
  $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_attr( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
3237
 
3238
+ /**
3239
+ * Filters all of the constructed filter links.
3240
+ *
3241
+ * @since BuddyPress (1.1.0)
3242
+ *
3243
+ * @param string $value All of the links to be displayed to the user.
3244
+ */
3245
  return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
3246
  }
3247
 
3248
  /**
3249
  * Determine if a comment can be made on an activity item.
3250
  *
3251
+ * @since BuddyPress (1.2.0)
3252
  *
3253
  * @global object $activities_template {@link BP_Activity_Template}
3254
  * @uses bp_get_activity_action_name()
3258
  */
3259
  function bp_activity_can_comment() {
3260
  global $activities_template;
3261
+ $bp = buddypress();
3262
 
3263
  // Assume activity can be commented on
3264
  $can_comment = true;
3265
 
3266
  // Determine ability to comment based on activity action name
3267
  $activity_action = bp_get_activity_action_name();
 
 
 
 
 
 
 
 
 
 
 
3268
 
3269
+ $turn_off = 0;
3270
+ if ( ! empty( $activities_template->disable_blogforum_replies ) ) {
3271
+ $turn_off = 1;
3272
+ }
3273
+
3274
+ $maybe_turn_off = array_fill_keys( array(
3275
+ 'new_blog_post',
3276
+ 'new_blog_comment',
3277
+ 'new_forum_topic',
3278
+ 'new_forum_post',
3279
+ ), $turn_off );
3280
+
3281
+ $maybe_turn_off['activity_comment'] = 1;
3282
+
3283
+ // Fetch all the tracked post types once.
3284
+ if ( empty( $bp->activity->track ) ) {
3285
+ $bp->activity->track = bp_activity_get_post_types_tracking_args();
3286
  }
3287
 
3288
+ foreach ( $bp->activity->track as $action => $tracking_args ) {
3289
+ if ( empty( $tracking_args->activity_comment ) ) {
3290
+ $maybe_turn_off[ $action ] = $turn_off;
3291
+ }
3292
+ }
3293
+
3294
+ $can_comment = empty( $maybe_turn_off[ $activity_action ] );
3295
+
3296
+ /**
3297
+ * Filters whether a comment can be made on an activity item.
3298
+ *
3299
+ * @since BuddyPress (1.5.0)
3300
+ *
3301
+ * @param bool $can_comment Status on if activity can be commented on.
3302
+ * @param string $activity_action Current activity action being checked on.
3303
+ */
3304
  return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
3305
  }
3306
 
3340
  }
3341
  }
3342
 
3343
+ /**
3344
+ * Filters whether a comment can be made on an activity reply item.
3345
+ *
3346
+ * @since BuddyPress (1.5.0)
3347
+ *
3348
+ * @param bool $can_comment Status on if activity reply can be commented on.
3349
+ * @param string $comment Current comment being checked on.
3350
+ */
3351
  return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
3352
  }
3353
 
3354
  /**
3355
+ * Determine whether favorites are allowed.
3356
  *
3357
  * Defaults to true, but can be modified by plugins.
3358
  *
3359
+ * @since BuddyPress (1.5.0)
3360
  *
3361
  * @uses apply_filters() To call the 'bp_activity_can_favorite' hook.
3362
  *
3363
  * @return bool True if comment can receive comments.
3364
  */
3365
  function bp_activity_can_favorite() {
3366
+
3367
+ /**
3368
+ * Filters whether or not users can favorite activity items.
3369
+ *
3370
+ * @since BuddyPress (1.5.0)
3371
+ *
3372
+ * @param bool $value Whether or not favoriting is enabled.
3373
+ */
3374
  return apply_filters( 'bp_activity_can_favorite', true );
3375
  }
3376
 
3377
  /**
3378
  * Output the total favorite count for a specified user.
3379
  *
3380
+ * @since BuddyPress (1.2.0)
3381
  *
3382
  * @see bp_get_total_favorite_count_for_user() for description of parameters.
3383
  * @uses bp_get_total_favorite_count_for_user()
3391
  /**
3392
  * Return the total favorite count for a specified user.
3393
  *
3394
+ * @since BuddyPress (1.2.0)
3395
  *
3396
  * @uses bp_activity_total_favorites_for_user()
3397
  * @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook
3411
  ? bp_activity_total_favorites_for_user( $user_id )
3412
  : false;
3413
 
3414
+ /**
3415
+ * Filters the total favorite count for a user.
3416
+ *
3417
+ * @since BuddyPress (1.2.0)
3418
+ *
3419
+ * @param int|bool $retval Total favorite count for a user. False on no favorites.
3420
+ */
3421
  return apply_filters( 'bp_get_total_favorite_count_for_user', $retval );
3422
  }
3423
 
3425
  /**
3426
  * Output the total mention count for a specified user.
3427
  *
3428
+ * @since BuddyPress (1.2.0)
3429
  *
3430
  * @see bp_get_total_mention_count_for_user() for description of parameters.
3431
  * @uses bp_get_total_favorite_count_for_user()
3439
  /**
3440
  * Return the total mention count for a specified user.
3441
  *
3442
+ * @since BuddyPress (1.2.0)
3443
  *
3444
  * @uses bp_get_user_meta()
3445
  * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
3459
  ? bp_get_user_meta( $user_id, 'bp_new_mention_count', true )
3460
  : false;
3461
 
3462
+ /**
3463
+ * Filters the total mention count for a user.
3464
+ *
3465
+ * @since BuddyPress (1.2.0)
3466
+ *
3467
+ * @param int|bool $retval Total mention count for a user. False on no mentions.
3468
+ */
3469
  return apply_filters( 'bp_get_total_mention_count_for_user', $retval );
3470
  }
3471
 
3472
  /**
3473
  * Output the public message link for displayed user.
3474
  *
3475
+ * @since BuddyPress (1.2.0)
3476
  *
3477
  * @uses bp_get_send_public_message_link()
3478
  */
3483
  /**
3484
  * Return the public message link for the displayed user.
3485
  *
3486
+ * @since BuddyPress (1.2.0)
3487
  *
3488
  * @uses is_user_logged_in()
3489
  * @uses bp_is_my_profile()
3505
  $retval = wp_nonce_url( $url );
3506
  }
3507
 
3508
+ /**
3509
+ * Filters the public message link for the displayed user.
3510
+ *
3511
+ * @since BuddyPress (1.2.0)
3512
+ *
3513
+ * @param string $retval The URL for the public message link.
3514
+ */
3515
  return apply_filters( 'bp_get_send_public_message_link', $retval );
3516
  }
3517
 
3545
  /**
3546
  * Output the mentioned user display name.
3547
  *
3548
+ * @since BuddyPress (1.2.0)
3549
  *
3550
  * @see bp_get_mentioned_user_display_name() for description of parameters.
3551
  * @uses bp_get_mentioned_user_display_name()
3559
  /**
3560
  * Returns the mentioned user display name
3561
  *
3562
+ * @since BuddyPress (1.2.0)
3563
  *
3564
  * @uses bp_core_get_user_displayname()
3565
  * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
3577
  $name = __( 'a user', 'buddypress' );
3578
  }
3579
 
3580
+ /**
3581
+ * Filters the mentioned user display name.
3582
+ *
3583
+ * @since BuddyPress (1.2.0)
3584
+ *
3585
+ * @param string $name Display name for the mentioned user.
3586
+ * @param int|string $user_id_or_username User ID or username use for query.
3587
+ */
3588
  return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
3589
  }
3590
 
3591
  /**
3592
  * Output button for sending a public message (an @-mention).
3593
  *
3594
+ * @since BuddyPress (1.2.0)
3595
  *
3596
  * @see bp_get_send_public_message_button() for description of parameters.
3597
  * @uses bp_get_send_public_message_button()
3605
  /**
3606
  * Return button for sending a public message (an @-mention).
3607
  *
3608
+ * @since BuddyPress (1.2.0)
3609
  *
3610
  * @uses bp_get_send_public_message_link()
3611
  * @uses wp_parse_args()
3643
  'link_class' => 'activity-button mention'
3644
  ) );
3645
 
3646
+ /**
3647
+ * Filters the public message button HTML.
3648
+ *
3649
+ * @since BuddyPress (1.2.10)
3650
+ *
3651
+ * @param array $r Array of arguments for the public message button HTML.
3652
+ */
3653
  return bp_get_button( apply_filters( 'bp_get_send_public_message_button', $r ) );
3654
  }
3655
 
3656
  /**
3657
  * Output the activity post form action.
3658
  *
3659
+ * @since BuddyPress (1.2.0)
3660
  *
3661
  * @uses bp_get_activity_post_form_action()
3662
  */
3667
  /**
3668
  * Return the activity post form action.
3669
  *
3670
+ * @since BuddyPress (1.2.0)
3671
  *
3672
  * @uses home_url()
3673
  * @uses bp_get_activity_root_slug()
3676
  * @return string The activity post form action.
3677
  */
3678
  function bp_get_activity_post_form_action() {
3679
+
3680
+ /**
3681
+ * Filters the action url used for the activity post form.
3682
+ *
3683
+ * @since BuddyPress (1.2.0)
3684
+ *
3685
+ * @param string $value URL to be used for the activity post form.
3686
+ */
3687
  return apply_filters( 'bp_get_activity_post_form_action', home_url( bp_get_activity_root_slug() . '/post/' ) );
3688
  }
3689
 
3695
  * Avatars are wrapped in <li> elements, but you've got to provide your own
3696
  * <ul> or <ol> wrapper markup.
3697
  *
3698
+ * @since BuddyPress (1.7.0)
3699
  *
3700
  * @see bp_core_fetch_avatar() for a description of arguments.
3701
  *
3747
  }
3748
  }
3749
 
3750
+ /**
3751
+ * Filters the list of linked avatars for users who have commented on the current activity item.
3752
+ *
3753
+ * @since BuddyPress (1.7.0)
3754
+ *
3755
+ * @param string $retval HTML markup for the list of avatars.
3756
+ * @param array $r Array of arguments used for each avatar.
3757
+ * @param array $output Array of each avatar found, before imploded into single string.
3758
+ */
3759
  echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );
3760
  }
3761
 
3762
  /**
3763
  * Return the IDs of every user who's left a comment on the current activity item.
3764
  *
3765
+ * @since BuddyPress (1.7.0)
3766
  *
3767
  * @return bool|array An array of IDs, or false if none are found.
3768
  */
3773
  ? (array) bp_activity_recurse_comments_user_ids( $activities_template->activity->children )
3774
  : array();
3775
 
3776
+ /**
3777
+ * Filters the list of user IDs for the current activity item.
3778
+ *
3779
+ * @since BuddyPress (1.7.0)
3780
+ *
3781
+ * @param array $value Array of unique user IDs for the current activity item.
3782
+ */
3783
  return apply_filters( 'bp_activity_get_comments_user_ids', array_unique( $user_ids ) );
3784
  }
3785
 
3786
  /**
3787
  * Recurse through all activity comments and collect the IDs of the users who wrote them.
3788
  *
3789
+ * @since BuddyPress (1.7.0)
3790
  *
3791
  * @param array $comments Array of {@link BP_Activity_Activity} items.
3792
  * @return array Array of user IDs.
3816
  }
3817
  }
3818
 
3819
+ /**
3820
+ * Filters the list of user IDs for the current activity comment item.
3821
+ *
3822
+ * @since BuddyPress (2.1.0)
3823
+ *
3824
+ * @param array $user_ids Array of user IDs for the current activity comment item.
3825
+ * @param array $comments Array of comments being checked for user IDs.
3826
+ */
3827
  return apply_filters( 'bp_activity_recurse_comments_user_ids', $user_ids, $comments );
3828
  }
3829
 
3843
  * @return string Mentionname for the displayed user, if available.
3844
  */
3845
  function bp_get_displayed_user_mentionname() {
3846
+
3847
+ /**
3848
+ * Filters the mentionname for the displayed user.
3849
+ *
3850
+ * @since BuddyPress (1.9.0)
3851
+ *
3852
+ * @param string $value The mentionanme for the displayed user.
3853
+ */
3854
  return apply_filters( 'bp_get_displayed_user_mentionname', bp_activity_get_user_mentionname( bp_displayed_user_id() ) );
3855
  }
3856
 
3857
  /**
3858
  * Echo a list of all registered activity types for use in dropdowns or checkbox lists.
3859
  *
3860
+ * @since BuddyPress (1.7.0)
3861
  *
3862
  * @param string $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
3863
  * @param array $args {
3895
  break;
3896
  }
3897
 
3898
+ /**
3899
+ * Fires at the end of the listing of activity types.
3900
+ *
3901
+ * This is a variable action hook. The actual hook to use will depend on the output type specified.
3902
+ * Two default hooks are bp_activity_types_list_select and bp_activity_types_list_checkbox.
3903
+ *
3904
+ * @since BuddyPress (1.7.0)
3905
+ *
3906
+ * @param array $args Array of arguments passed into function.
3907
+ * @param string $type Activity type being rendered in the output.
3908
+ * @param string $description Description of the activity type being rendered.
3909
+ */
3910
  do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
3911
  }
3912
 
3922
  /**
3923
  * Output the sitewide activity feed link.
3924
  *
3925
+ * @since BuddyPress (1.0.0)
3926
  *
3927
  * @uses bp_get_sitewide_activity_feed_link()
3928
  */
3933
  /**
3934
  * Returns the sitewide activity feed link.
3935
  *
3936
+ * @since BuddyPress (1.0.0)
3937
  *
3938
  * @uses home_url()
3939
  * @uses bp_get_activity_root_slug()
3942
  * @return string The sitewide activity feed link.
3943
  */
3944
  function bp_get_sitewide_activity_feed_link() {
3945
+
3946
+ /**
3947
+ * Filters the sidewide activity feed link.
3948
+ *
3949
+ * @since BuddyPress (1.0.0)
3950
+ *
3951
+ * @param string $value The feed link for sitewide activity.
3952
+ */
3953
  return apply_filters( 'bp_get_sitewide_activity_feed_link', bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/feed/' );
3954
  }
3955
 
3956
  /**
3957
  * Output the member activity feed link.
3958
  *
3959
+ * @since BuddyPress (1.2.0)
3960
  *
3961
  * @uses bp_get_member_activity_feed_link()
3962
  */
3967
  /**
3968
  * Output the member activity feed link.
3969
  *
3970
+ * @since BuddyPress (1.0.0)
3971
+ * @deprecated BuddyPress (1.2.0)
3972
  *
3973
  * @todo properly deprecate in favor of bp_member_activity_feed_link().
3974
  *
3979
  /**
3980
  * Return the member activity feed link.
3981
  *
3982
+ * @since BuddyPress (1.2.0)
3983
  *
3984
  * @uses bp_is_profile_component()
3985
  * @uses bp_is_current_action()
4019
  $link = '';
4020
  }
4021
 
4022
+ /**
4023
+ * Filters the member activity feed link.
4024
+ *
4025
+ * @since BuddyPress (1.0.0)
4026
+ *
4027
+ * @param string $link URL for the member activity feed.
4028
+ */
4029
  return apply_filters( 'bp_get_activities_member_rss_link', $link );
4030
  }
4031
 
4032
  /**
4033
  * Return the member activity feed link.
4034
  *
4035
+ * @since BuddyPress (1.0.0)
4036
+ * @deprecated BuddyPress (1.2.0)
4037
  *
4038
  * @todo properly deprecate in favor of bp_get_member_activity_feed_link().
4039
  *
4049
  /**
4050
  * Outputs the activity feed item guid.
4051
  *
4052
+ * @since BuddyPress (1.0.0)
4053
  *
4054
  * @uses bp_activity_feed_item_guid()
4055
  */
4060
  /**
4061
  * Returns the activity feed item guid.
4062
  *
4063
+ * @since BuddyPress (1.2.0)
4064
  *
4065
  * @global object $activities_template {@link BP_Activity_Template}
4066
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_guid' hook.
4070
  function bp_get_activity_feed_item_guid() {
4071
  global $activities_template;
4072
 
4073
+ /**
4074
+ * Filters the activity feed item guid.
4075
+ *
4076
+ * @since BuddyPress (1.1.3)
4077
+ *
4078
+ * @param string $value Calculated md5 value for the activity feed item.
4079
+ */
4080
  return apply_filters( 'bp_get_activity_feed_item_guid', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) );
4081
  }
4082
 
4083
  /**
4084
  * Output the activity feed item title.
4085
  *
4086
+ * @since BuddyPress (1.0.0)
4087
  *
4088
  * @uses bp_get_activity_feed_item_title()
4089
  */
4094
  /**
4095
  * Return the activity feed item title.
4096
  *
4097
+ * @since BuddyPress (1.0.0)
4098
  *
4099
  * @global object $activities_template {@link BP_Activity_Template}
4100
  * @uses ent2ncr()
4124
  $title .= ': ' . strip_tags( ent2ncr( trim( convert_chars( bp_create_excerpt( $activities_template->activity->content, 70, array( 'ending' => " [&#133;]" ) ) ) ) ) );
4125
  }
4126
 
4127
+ /**
4128
+ * Filters the activity feed item title.
4129
+ *
4130
+ * @since BuddyPress (1.0.0)
4131
+ *
4132
+ * @param string $title The title for the activity feed item.
4133
+ */
4134
  return apply_filters( 'bp_get_activity_feed_item_title', $title );
4135
  }
4136
 
4137
  /**
4138
  * Output the activity feed item link
4139
  *
4140
+ * @since BuddyPress (1.0.0)
4141
  *
4142
  * @uses bp_get_activity_feed_item_link()
4143
  */
4148
  /**
4149
  * Return the activity feed item link
4150
  *
4151
+ * @since BuddyPress (1.0.0)
4152
  *
4153
  * @global object $activities_template {@link BP_Activity_Template}
4154
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_link' hook.
4162
  ? $activities_template->activity->primary_link
4163
  : '';
4164
 
4165
+ /**
4166
+ * Filters the activity feed item link.
4167
+ *
4168
+ * @since BuddyPress (1.0.0)
4169
+ *
4170
+ * @param string $retval The URL for the activity feed item.
4171
+ */
4172
  return apply_filters( 'bp_get_activity_feed_item_link', $retval );
4173
  }
4174
 
4175
  /**
4176
  * Output the activity feed item date.
4177
  *
4178
+ * @since BuddyPress (1.0.0)
4179
  *
4180
  * @uses bp_get_activity_feed_item_date()
4181
  */
4186
  /**
4187
  * Return the activity feed item date.
4188
  *
4189
+ * @since BuddyPress (1.0.0)
4190
  *
4191
  * @global object $activities_template {@link BP_Activity_Template}
4192
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_date' hook.
4200
  ? $activities_template->activity->date_recorded
4201
  : '';
4202
 
4203
+ /**
4204
+ * Filters the activity feed item date.
4205
+ *
4206
+ * @since BuddyPress (1.0.0)
4207
+ *
4208
+ * @param string $retval The date for the activity feed item.
4209
+ */
4210
  return apply_filters( 'bp_get_activity_feed_item_date', $retval );
4211
  }
4212
 
4213
  /**
4214
  * Output the activity feed item description.
4215
  *
4216
+ * @since BuddyPress (1.0.0)
4217
  *
4218
  * @uses bp_get_activity_feed_item_description()
4219
  */
4224
  /**
4225
  * Return the activity feed item description.
4226
  *
4227
+ * @since BuddyPress (1.0.0)
4228
  *
4229
  * @global object $activities_template {@link BP_Activity_Template}
4230
  * @uses ent2ncr()
4246
  $content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) );
4247
  }
4248
 
4249
+ /**
4250
+ * Filters the activity feed item description.
4251
+ *
4252
+ * @since BuddyPress (1.0.0)
4253
+ *
4254
+ * @param string $content The description for the activity feed item.
4255
+ */
4256
  return apply_filters( 'bp_get_activity_feed_item_description', $content );
4257
  }
4258
 
4259
  /**
4260
  * Template tag so we can hook activity feed to <head>.
4261
  *
4262
+ * @since BuddyPress (1.5.0)
4263
  *
4264
  * @uses bloginfo()
4265
  * @uses bp_sitewide_activity_feed_link()
4308
  }
4309
 
4310
  // On individual group pages, default to 'group'
4311
+ } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) {
4312
  $context = 'group';
4313
 
4314
  // 'activity' everywhere else
4321
 
4322
  // Walk through the registered actions, and prepare an the
4323
  // select box options.
4324
+ foreach ( bp_activity_get_actions() as $actions ) {
4325
  foreach ( $actions as $action ) {
4326
  if ( ! in_array( $context, (array) $action['context'] ) ) {
4327
  continue;
4337
  }
4338
 
4339
  /**
4340
+ * Filters the options available in the activity filter dropdown.
4341
  *
4342
+ * @since BuddyPress (2.2.0)
4343
  *
4344
+ * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
4345
+ * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
 
 
 
4346
  */
4347
+ $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
4348
 
4349
  // Build the options output
4350
  $output = '';
4355
  }
4356
  }
4357
 
4358
+ /**
4359
+ * Filters the HTML markup result for the activity filter dropdown.
4360
+ *
4361
+ * @since BuddyPress (2.1.0)
4362
+ *
4363
+ * @param string $output HTML output for the activity filter dropdown.
4364
+ * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
4365
+ * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
4366
+ */
4367
  return apply_filters( 'bp_get_activity_show_filters', $output, $filters, $context );
4368
  }
bp-activity/css/mentions-rtl.css CHANGED
@@ -1,5 +1,5 @@
1
  .atwho-view {
2
- background: #FFF;
3
  border-radius: 2px;
4
  border: 1px solid rgb(204, 204, 204);
5
  box-shadow: 0 0 5px rgba(204, 204, 204, 0.25), 0 0 1px #FFF;
@@ -16,6 +16,7 @@
16
  left: 0;
17
  }
18
  .atwho-view ul {
 
19
  list-style: none;
20
  margin: auto;
21
  padding: 0;
@@ -62,9 +63,6 @@
62
  float: right;
63
  margin: 0 0 0 10px;
64
  }
65
- .atwho-view small {
66
- display: none;
67
- }
68
  }
69
  @media (max-width: 400px) {
70
  .atwho-view ul li {
@@ -77,4 +75,19 @@
77
  margin-top: -5px;
78
  width: 30px;
79
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
1
  .atwho-view {
2
+ background: rgba(204, 204, 204, 0.8);
3
  border-radius: 2px;
4
  border: 1px solid rgb(204, 204, 204);
5
  box-shadow: 0 0 5px rgba(204, 204, 204, 0.25), 0 0 1px #FFF;
16
  left: 0;
17
  }
18
  .atwho-view ul {
19
+ background: #FFF;
20
  list-style: none;
21
  margin: auto;
22
  padding: 0;
63
  float: right;
64
  margin: 0 0 0 10px;
65
  }
 
 
 
66
  }
67
  @media (max-width: 400px) {
68
  .atwho-view ul li {
75
  margin-top: -5px;
76
  width: 30px;
77
  }
78
+ .atwho-view {
79
+ border-radius: 0;
80
+ height: 100%;
81
+ right: 0 !important;
82
+ width: 100%;
83
+ }
84
+ .atwho-view ul li .username {
85
+ display: inline-block;
86
+ margin: -10px 0 0 0;
87
+ padding: 10px 0;
88
+ }
89
+ .atwho-view ul li small {
90
+ display: inline-block;
91
+ margin-right: 20px;
92
+ }
93
  }
bp-activity/css/mentions-rtl.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- .atwho-view{background:#FFF;border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #FFF;color:#D84800;display:none;font-family:sans-serif;margin-top:18px;position:absolute;top:0;z-index:1000;left:0}.atwho-view ul{list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #EFEFEF;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:left;height:20px;margin-top:0;width:20px}.atwho-view strong{background:#EFEFEF;font:700}.atwho-view .username strong{color:#D54E21}.atwho-view small{color:#AAA;float:left;font-size:smaller;font-weight:400;margin:0 40px 0 10px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:right;margin:0 0 0 10px}.atwho-view small{display:none}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ .atwho-view{background:rgba(204,204,204,.8);border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #FFF;color:#D84800;display:none;font-family:sans-serif;margin-top:18px;position:absolute;top:0;z-index:1000;left:0}.atwho-view ul{background:#FFF;list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #EFEFEF;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:left;height:20px;margin-top:0;width:20px}.atwho-view strong{background:#EFEFEF;font:700}.atwho-view .username strong{color:#D54E21}.atwho-view small{color:#AAA;float:left;font-size:smaller;font-weight:400;margin:0 40px 0 10px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:right;margin:0 0 0 10px}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}.atwho-view{border-radius:0;height:100%;right:0!important;width:100%}.atwho-view ul li .username{display:inline-block;margin:-10px 0 0;padding:10px 0}.atwho-view ul li small{display:inline-block;margin-right:20px}}
bp-activity/css/mentions.css CHANGED
@@ -1,5 +1,5 @@
1
  .atwho-view {
2
- background: #FFF;
3
  border-radius: 2px;
4
  border: 1px solid rgb(204, 204, 204);
5
  box-shadow: 0 0 5px rgba(204, 204, 204, 0.25), 0 0 1px #FFF;
@@ -16,6 +16,7 @@
16
  left: 0;
17
  }
18
  .atwho-view ul {
 
19
  list-style: none;
20
  margin: auto;
21
  padding: 0;
@@ -62,9 +63,6 @@
62
  float: left;
63
  margin: 0 10px 0 0;
64
  }
65
- .atwho-view small {
66
- display: none;
67
- }
68
  }
69
  @media (max-width: 400px) {
70
  .atwho-view ul li {
@@ -77,4 +75,19 @@
77
  margin-top: -5px;
78
  width: 30px;
79
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
1
  .atwho-view {
2
+ background: rgba(204, 204, 204, 0.8);
3
  border-radius: 2px;
4
  border: 1px solid rgb(204, 204, 204);
5
  box-shadow: 0 0 5px rgba(204, 204, 204, 0.25), 0 0 1px #FFF;
16
  left: 0;
17
  }
18
  .atwho-view ul {
19
+ background: #FFF;
20
  list-style: none;
21
  margin: auto;
22
  padding: 0;
63
  float: left;
64
  margin: 0 10px 0 0;
65
  }
 
 
 
66
  }
67
  @media (max-width: 400px) {
68
  .atwho-view ul li {
75
  margin-top: -5px;
76
  width: 30px;
77
  }
78
+ .atwho-view {
79
+ border-radius: 0;
80
+ height: 100%;
81
+ left: 0 !important;
82
+ width: 100%;
83
+ }
84
+ .atwho-view ul li .username {
85
+ display: inline-block;
86
+ margin: -10px 0 0 0;
87
+ padding: 10px 0;
88
+ }
89
+ .atwho-view ul li small {
90
+ display: inline-block;
91
+ margin-left: 20px;
92
+ }
93
  }
bp-activity/css/mentions.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- .atwho-view{background:#FFF;border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #FFF;color:#D84800;display:none;font-family:sans-serif;margin-top:18px;position:absolute;top:0;z-index:1000;left:0}.atwho-view ul{list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #EFEFEF;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:right;height:20px;margin-top:0;width:20px}.atwho-view strong{background:#EFEFEF;font:700}.atwho-view .username strong{color:#D54E21}.atwho-view small{color:#AAA;float:right;font-size:smaller;font-weight:400;margin:0 10px 0 40px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:left;margin:0 10px 0 0}.atwho-view small{display:none}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ .atwho-view{background:rgba(204,204,204,.8);border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #FFF;color:#D84800;display:none;font-family:sans-serif;margin-top:18px;position:absolute;top:0;z-index:1000;left:0}.atwho-view ul{background:#FFF;list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #EFEFEF;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:right;height:20px;margin-top:0;width:20px}.atwho-view strong{background:#EFEFEF;font:700}.atwho-view .username strong{color:#D54E21}.atwho-view small{color:#AAA;float:right;font-size:smaller;font-weight:400;margin:0 10px 0 40px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:left;margin:0 10px 0 0}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}.atwho-view{border-radius:0;height:100%;left:0!important;width:100%}.atwho-view ul li .username{display:inline-block;margin:-10px 0 0;padding:10px 0}.atwho-view ul li small{display:inline-block;margin-left:20px}}
bp-activity/js/mentions.js CHANGED
@@ -76,20 +76,50 @@
76
  * @since BuddyPress (2.1.0)
77
  */
78
  before_reposition: function( offset ) {
79
- var $view = $( '#atwho-ground-' + this.id + ' .atwho-view' ),
80
- caret = this.$inputor.caret( 'offset', { iframe: $( '#content_ifr' )[0] } ).left,
81
- move;
 
 
 
 
 
82
 
83
- // If the caret is past horizontal half, then flip it, yo.
84
- if ( caret > ( $( 'body' ).width() / 2 ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  $view.addClass( 'right' );
86
- move = caret - offset.left - this.view.$el.width();
87
  } else {
88
  $view.removeClass( 'right' );
89
- move = caret - offset.left + 1;
90
  }
91
 
92
- offset.top += 1;
 
 
 
 
 
 
 
 
 
 
 
 
93
  offset.left += move;
94
  },
95
 
@@ -103,8 +133,7 @@
103
  * @since BuddyPress (2.1.0)
104
  */
105
  inserting_wrapper: function( $inputor, content, suffix ) {
106
- var new_suffix = ( suffix === '' ) ? suffix : suffix || ' ';
107
- return '' + content + new_suffix;
108
  }
109
  }
110
  },
@@ -122,7 +151,8 @@
122
  * @since BuddyPress (2.1.0)
123
  */
124
  remote_filter: function( query, render_view ) {
125
- var self = $( this );
 
126
 
127
  mentionsItem = mentionsQueryCache[ query ];
128
  if ( typeof mentionsItem === 'object' ) {
@@ -134,7 +164,13 @@
134
  self.xhr.abort();
135
  }
136
 
137
- self.xhr = $.getJSON( ajaxurl, { 'action': 'bp_get_suggestions', 'term': query, 'type': 'members' } )
 
 
 
 
 
 
138
  /**
139
  * Success callback for the @suggestions lookup.
140
  *
@@ -192,13 +228,34 @@
192
  };
193
 
194
  $( document ).ready(function() {
195
- var users = [];
 
 
196
 
197
  if ( typeof window.BP_Suggestions === 'object' ) {
198
  users = window.BP_Suggestions.friends || users;
199
  }
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  // Activity/reply, post comments, dashboard post 'text' editor.
202
  $( '.bp-suggestions, #comments form textarea, .wp-editor-area' ).bp_mentions( users );
 
 
 
203
  });
204
  })( jQuery );
76
  * @since BuddyPress (2.1.0)
77
  */
78
  before_reposition: function( offset ) {
79
+ // get the iframe, if any, already applied with atwho
80
+ var caret,
81
+ line,
82
+ iframeOffset,
83
+ move,
84
+ $view = $( '#atwho-ground-' + this.id + ' .atwho-view' ),
85
+ $body = $( 'body' ),
86
+ atwhoDataValue = this.$inputor.data( 'atwho' );
87
 
88
+ if ( 'undefined' !== atwhoDataValue && 'undefined' !== atwhoDataValue.iframe && null !== atwhoDataValue.iframe ) {
89
+ caret = this.$inputor.caret( 'offset', { iframe: atwhoDataValue.iframe } );
90
+ // Caret.js no longer calculates iframe caret position from the window (it's now just within the iframe).
91
+ // We need to get the iframe offset from the window and merge that into our object.
92
+ iframeOffset = $( atwhoDataValue.iframe ).offset();
93
+ if ( 'undefined' !== iframeOffset ) {
94
+ caret.left += iframeOffset.left;
95
+ caret.top += iframeOffset.top;
96
+ }
97
+ } else {
98
+ caret = this.$inputor.caret( 'offset' );
99
+ }
100
+
101
+ // If the caret is past horizontal half, then flip it, yo
102
+ if ( caret.left > ( $body.width() / 2 ) ) {
103
  $view.addClass( 'right' );
104
+ move = caret.left - offset.left - this.view.$el.width();
105
  } else {
106
  $view.removeClass( 'right' );
107
+ move = caret.left - offset.left + 1;
108
  }
109
 
110
+ // If we're on a small screen, scroll to caret
111
+ if ( $body.width() <= 400 ) {
112
+ $( document ).scrollTop( caret.top - 6 );
113
+ }
114
+
115
+ // New position is under the caret (never above) and positioned to follow
116
+ // Dynamic sizing based on the input area (remove 'px' from end)
117
+ line = parseInt( this.$inputor.css( 'line-height' ).substr( 0, this.$inputor.css( 'line-height' ).length - 2 ), 10 );
118
+ if ( !line || line < 5 ) { // sanity check, and catch no line-height
119
+ line = 19;
120
+ }
121
+
122
+ offset.top = caret.top + line;
123
  offset.left += move;
124
  },
125
 
133
  * @since BuddyPress (2.1.0)
134
  */
135
  inserting_wrapper: function( $inputor, content, suffix ) {
136
+ return '' + content + suffix;
 
137
  }
138
  }
139
  },
151
  * @since BuddyPress (2.1.0)
152
  */
153
  remote_filter: function( query, render_view ) {
154
+ var self = $( this ),
155
+ params = {};
156
 
157
  mentionsItem = mentionsQueryCache[ query ];
158
  if ( typeof mentionsItem === 'object' ) {
164
  self.xhr.abort();
165
  }
166
 
167
+ params = { 'action': 'bp_get_suggestions', 'term': query, 'type': 'members' };
168
+
169
+ if ( $.isNumeric( this.$inputor.data( 'suggestions-group-id' ) ) ) {
170
+ params['group-id'] = parseInt( this.$inputor.data( 'suggestions-group-id' ), 10 );
171
+ }
172
+
173
+ self.xhr = $.getJSON( ajaxurl, params )
174
  /**
175
  * Success callback for the @suggestions lookup.
176
  *
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.1.0 - 2014-10-06 9:39:07 PM 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=a("#atwho-ground-"+this.id+" .atwho-view"),e=this.$inputor.caret("offset",{iframe:a("#content_ifr")[0]}).left;e>a("body").width()/2?(d.addClass("right"),c=e-b.left-this.view.$el.width()):(d.removeClass("right"),c=e-b.left+1),b.top+=1,b.left+=c},inserting_wrapper:function(a,b,c){var d=""===c?c:c||" ";return""+b+d}}},f={callbacks:{remote_filter:function(d,e){var f=a(this);return b=c[d],"object"==typeof b?void e(b):(f.xhr&&f.xhr.abort(),void(f.xhr=a.getJSON(ajaxurl,{action:"bp_get_suggestions",term:d,type:"members"}).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=[];"object"==typeof window.BP_Suggestions&&(b=window.BP_Suggestions.friends||b),a(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(b)})}(jQuery);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM 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
@@ -33,28 +33,29 @@ function bp_blogs_register_activity_actions() {
33
  'new_blog',
34
  __( 'New site created', 'buddypress' ),
35
  'bp_blogs_format_activity_action_new_blog',
36
- __( 'New Sites', 'buddypress' )
 
37
  );
38
  }
39
 
40
- bp_activity_set_action(
41
- $bp->blogs->id,
42
- 'new_blog_post',
43
- __( 'New post published', 'buddypress' ),
44
- 'bp_blogs_format_activity_action_new_blog_post',
45
- __( 'Posts', 'buddypress' ),
46
- array( 'activity', 'member' )
47
- );
48
-
49
- bp_activity_set_action(
50
- $bp->blogs->id,
51
- 'new_blog_comment',
52
- __( 'New post comment posted', 'buddypress' ),
53
- 'bp_blogs_format_activity_action_new_blog_comment',
54
- __( 'Comments', 'buddypress' ),
55
- array( 'activity', 'member' )
56
- );
57
 
 
 
 
 
 
58
  do_action( 'bp_blogs_register_activity_actions' );
59
  }
60
  add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions' );
@@ -85,6 +86,14 @@ function bp_blogs_format_activity_action_new_blog( $action, $activity ) {
85
  }
86
  }
87
 
 
 
 
 
 
 
 
 
88
  return apply_filters( 'bp_blogs_format_activity_action_new_blog', $action, $activity );
89
  }
90
 
@@ -108,9 +117,17 @@ function bp_blogs_format_activity_action_new_blog_post( $action, $activity ) {
108
  bp_blogs_update_blogmeta( $activity->item_id, 'name', $blog_name );
109
  }
110
 
111
- $post_url = add_query_arg( 'p', $activity->secondary_item_id, trailingslashit( $blog_url ) );
 
 
 
 
112
 
113
- $post_title = bp_activity_get_meta( $activity->id, 'post_title' );
 
 
 
 
114
 
115
  // Should only be empty at the time of post creation
116
  if ( empty( $post_title ) ) {
@@ -146,6 +163,14 @@ function bp_blogs_format_activity_action_new_blog_post( $action, $activity ) {
146
  }
147
  }
148
 
 
 
 
 
 
 
 
 
149
  return apply_filters( 'bp_blogs_format_activity_action_new_blog_post', $action, $activity );
150
  }
151
 
@@ -213,6 +238,14 @@ function bp_blogs_format_activity_action_new_blog_comment( $action, $activity )
213
  }
214
  }
215
 
 
 
 
 
 
 
 
 
216
  return apply_filters( 'bp_blogs_format_activity_action_new_blog_comment', $action, $activity );
217
  }
218
 
@@ -294,10 +327,28 @@ function bp_blogs_record_activity( $args = '' ) {
294
  }
295
 
296
  if ( ! empty( $r['action'] ) ) {
 
 
 
 
 
 
 
 
297
  $r['action'] = apply_filters( 'bp_blogs_record_activity_action', $r['action'] );
298
  }
299
 
300
  if ( ! empty( $r['content'] ) ) {
 
 
 
 
 
 
 
 
 
 
301
  $r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $r['content'] ), $r['content'], $r );
302
  }
303
 
@@ -527,6 +578,16 @@ function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_
527
  // add the comment hook back
528
  add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
529
 
 
 
 
 
 
 
 
 
 
 
530
  do_action( 'bp_blogs_sync_add_from_activity_comment', $comment_id, $args, $parent_activity, $user );
531
  }
532
  add_action( 'bp_activity_comment_posted', 'bp_blogs_sync_add_from_activity_comment', 10, 3 );
33
  'new_blog',
34
  __( 'New site created', 'buddypress' ),
35
  'bp_blogs_format_activity_action_new_blog',
36
+ __( 'New Sites', 'buddypress' ),
37
+ 0
38
  );
39
  }
40
 
41
+ // Only add the comment type if the 'post' post type is trackable
42
+ if ( post_type_supports( 'post', 'buddypress-activity' ) ) {
43
+ bp_activity_set_action(
44
+ $bp->blogs->id,
45
+ 'new_blog_comment',
46
+ __( 'New post comment posted', 'buddypress' ),
47
+ 'bp_blogs_format_activity_action_new_blog_comment',
48
+ __( 'Comments', 'buddypress' ),
49
+ array( 'activity', 'member' ),
50
+ 10
51
+ );
52
+ }
 
 
 
 
 
53
 
54
+ /**
55
+ * Fires after the registry of the default blog component activity actions.
56
+ *
57
+ * @since BuddyPress (1.1.0)
58
+ */
59
  do_action( 'bp_blogs_register_activity_actions' );
60
  }
61
  add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions' );
86
  }
87
  }
88
 
89
+ /**
90
+ * Filters the new blog activity action for the new blog.
91
+ *
92
+ * @since BuddyPress (2.0.0)
93
+ *
94
+ * @param string $action Constructed activity action.
95
+ * @param obj $activity Activity data object.
96
+ */
97
  return apply_filters( 'bp_blogs_format_activity_action_new_blog', $action, $activity );
98
  }
99
 
117
  bp_blogs_update_blogmeta( $activity->item_id, 'name', $blog_name );
118
  }
119
 
120
+ if ( empty( $activity->post_url ) ) {
121
+ $post_url = add_query_arg( 'p', $activity->secondary_item_id, trailingslashit( $blog_url ) );
122
+ } else {
123
+ $post_url = $activity->post_url;
124
+ }
125
 
126
+ if ( empty( $activity->post_title ) ) {
127
+ $post_title = bp_activity_get_meta( $activity->id, 'post_title' );
128
+ } else {
129
+ $post_title = $activity->post_title;
130
+ }
131
 
132
  // Should only be empty at the time of post creation
133
  if ( empty( $post_title ) ) {
163
  }
164
  }
165
 
166
+ /**
167
+ * Filters the new blog post action for the new blog.
168
+ *
169
+ * @since BuddyPress (2.0.0)
170
+ *
171
+ * @param string $action Constructed activity action.
172
+ * @param obj $activity Activity data object.
173
+ */
174
  return apply_filters( 'bp_blogs_format_activity_action_new_blog_post', $action, $activity );
175
  }
176
 
238
  }
239
  }
240
 
241
+ /**
242
+ * Filters the new blog comment action for the new blog.
243
+ *
244
+ * @since BuddyPress (2.0.0)
245
+ *
246
+ * @param string $action Constructed activity action.
247
+ * @param obj $activity Activity data object.
248
+ */
249
  return apply_filters( 'bp_blogs_format_activity_action_new_blog_comment', $action, $activity );
250
  }
251
 
327
  }
328
 
329
  if ( ! empty( $r['action'] ) ) {
330
+
331
+ /**
332
+ * Filters the action associated with activity for activity stream.
333
+ *
334
+ * @since BuddyPress (1.2.0)
335
+ *
336
+ * @param string $value Action for the activity stream.
337
+ */
338
  $r['action'] = apply_filters( 'bp_blogs_record_activity_action', $r['action'] );
339
  }
340
 
341
  if ( ! empty( $r['content'] ) ) {
342
+
343
+ /**
344
+ * Filters the content associated with activity for activity stream.
345
+ *
346
+ * @since BuddyPress (1.2.0)
347
+ *
348
+ * @param string $value Generated excerpt from content for the activity stream.
349
+ * @param string $value Content for the activity stream.
350
+ * @param array $r Array of arguments used for the activity stream item.
351
+ */
352
  $r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $r['content'] ), $r['content'], $r );
353
  }
354
 
578
  // add the comment hook back
579
  add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
580
 
581
+ /**
582
+ * Fires after activity comments have been synced and posted as blog comments.
583
+ *
584
+ * @since BuddyPress (2.0.0)
585
+ *
586
+ * @param int $comment_id The activity ID for the posted activity comment.
587
+ * @param array $args Array of args used for the comment syncing.
588
+ * @param object $parent_activity Parameters of the blog post parent activity item.
589
+ * @param object $user User data object for the blog comment.
590
+ */
591
  do_action( 'bp_blogs_sync_add_from_activity_comment', $comment_id, $args, $parent_activity, $user );
592
  }
593
  add_action( 'bp_activity_comment_posted', 'bp_blogs_sync_add_from_activity_comment', 10, 3 );
bp-blogs/bp-blogs-cache.php CHANGED
@@ -42,27 +42,19 @@ function bp_blogs_update_meta_cache( $blog_ids = false ) {
42
  * @param int $blog_id ID of the current blog.
43
  * @param int $user_id ID of the user whose blog cache should be cleared.
44
  */
45
- function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
46
- wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
47
- wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
48
- }
 
49
 
50
- /**
51
- * Clear cache when a new blog is created.
52
- *
53
- * @since BuddyPress (1.0.0)
54
- *
55
- * @param BP_Blogs_Blog $recorded_blog_obj The recorded blog, passed by
56
- * 'bp_blogs_new_blog'.
57
- */
58
- function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
59
- bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
60
  wp_cache_delete( 'bp_total_blogs', 'bp' );
61
  }
62
 
63
  // List actions to clear object caches on
64
  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
65
- add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
 
66
 
67
  // List actions to clear super cached pages on, if super cache is installed
68
  add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
42
  * @param int $blog_id ID of the current blog.
43
  * @param int $user_id ID of the user whose blog cache should be cleared.
44
  */
45
+ function bp_blogs_clear_blog_object_cache( $blog_id = 0, $user_id = 0 ) {
46
+ if ( ! empty( $user_id ) ) {
47
+ wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
48
+ wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
49
+ }
50
 
 
 
 
 
 
 
 
 
 
 
51
  wp_cache_delete( 'bp_total_blogs', 'bp' );
52
  }
53
 
54
  // List actions to clear object caches on
55
  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
56
+ add_action( 'wpmu_new_blog', 'bp_blogs_clear_blog_object_cache', 10, 2 );
57
+ add_action( 'bp_blogs_remove_blog', 'bp_blogs_clear_blog_object_cache' );
58
 
59
  // List actions to clear super cached pages on, if super cache is installed
60
  add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
bp-blogs/bp-blogs-classes.php CHANGED
@@ -58,6 +58,15 @@ class BP_Blogs_Blog {
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
  do_action_ref_array( 'bp_blogs_blog_before_save', array( &$this ) );
62
 
63
  // Don't try and save if there is no user ID or blog ID set.
@@ -79,6 +88,15 @@ class BP_Blogs_Blog {
79
  if ( !$wpdb->query($sql) )
80
  return false;
81
 
 
 
 
 
 
 
 
 
 
82
  do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) );
83
 
84
  if ( $this->id )
@@ -155,16 +173,43 @@ class BP_Blogs_Blog {
155
  $include_sql = " AND b.blog_id IN ({$blog_ids_sql})";
156
  }
157
 
158
- if ( !empty( $search_terms ) ) {
159
  $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
160
- $search_terms_sql = $wpdb->prepare( 'bm2.meta_value LIKE %s', $search_terms_like );
161
- $paged_blogs = $wpdb->get_results( "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, bm2.meta_value as name FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND {$search_terms_sql} {$user_sql} {$include_sql} GROUP BY b.blog_id {$order_sql} {$pag_sql}" );
162
- $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND bm.blog_id = b.blog_id AND bm2.blog_id = b.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'name' AND bm2.meta_key = 'description' AND {$search_terms_sql} {$user_sql} {$include_sql}" );
163
  } else {
164
- $paged_blogs = $wpdb->get_results( "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, bm2.meta_value as name FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' {$include_sql} GROUP BY b.blog_id {$order_sql} {$pag_sql}" );
165
- $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$include_sql} {$hidden_sql}" );
166
  }
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  $blog_ids = array();
169
  foreach ( (array) $paged_blogs as $blog ) {
170
  $blog_ids[] = (int) $blog->blog_id;
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.
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 )
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;
bp-blogs/bp-blogs-filters.php CHANGED
@@ -33,6 +33,14 @@ add_filter( 'bp_blog_latest_post_content', 'prepend_attachment' );
33
  * @return string The new URL.
34
  */
35
  function bp_blogs_creation_location( $url ) {
 
 
 
 
 
 
 
 
36
  return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create', $url ) );
37
  }
38
  add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
@@ -42,13 +50,73 @@ add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
42
  *
43
  * @since BuddyPress (2.1.0)
44
  *
45
- * @see bp_blogs_update_post()
46
  *
47
  * @param array Current SQL clauses in array format
48
  * @return array
49
  */
50
  function bp_blogs_comments_clauses_select_by_id( $retval ) {
51
  $retval['fields'] = 'comment_ID';
52
-
53
  return $retval;
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  * @return string The new URL.
34
  */
35
  function bp_blogs_creation_location( $url ) {
36
+
37
+ /**
38
+ * Filters the 'Create a new site' link URL.
39
+ *
40
+ * @since BuddyPress (1.6.0)
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' );
50
  *
51
  * @since BuddyPress (2.1.0)
52
  *
53
+ * @see bp_blogs_update_post_activity_meta()
54
  *
55
  * @param array Current SQL clauses in array format
56
  * @return array
57
  */
58
  function bp_blogs_comments_clauses_select_by_id( $retval ) {
59
  $retval['fields'] = 'comment_ID';
60
+
61
  return $retval;
62
+ }
63
+
64
+ /**
65
+ * Check whether the current post can be published.
66
+ *
67
+ * Abstracted from the deprecated `bp_blogs_record_post()`.
68
+ *
69
+ * @since BuddyPress (2.2.0)
70
+ *
71
+ * @param bool $return Whether the post should be published.
72
+ * @param int $blog_id ID of the blog.
73
+ * @param int $post_id ID of the post.
74
+ * @param int $user_id ID of the post author.
75
+ * @return bool True to authorize the post to be published, otherwise false.
76
+ */
77
+ function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0, $user_id = 0 ) {
78
+ $bp = buddypress();
79
+
80
+ // If blog is not trackable, do not record the activity.
81
+ if ( ! bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) {
82
+ return false;
83
+ }
84
+
85
+ /*
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
+ /**
97
+ * Filters whether or not BuddyPress should block sitewide tags activity.
98
+ *
99
+ * @since BuddyPress (2.2.0)
100
+ *
101
+ * @param bool $value Current status of the sitewide tags activity.
102
+ */
103
+ if ( (int) $blog_id == $tags_blog_id && apply_filters( 'bp_blogs_block_sitewide_tags_activity', true ) ) {
104
+ return false;
105
+ }
106
+
107
+ /**
108
+ * Filters whether or not the current blog is public.
109
+ *
110
+ * @since BuddyPress (2.2.0)
111
+ *
112
+ * @param int $value Value from the blog_public option for the current blog.
113
+ */
114
+ $is_blog_public = apply_filters( 'bp_is_blog_public', (int) get_blog_option( $blog_id, 'blog_public' ) );
115
+
116
+ if ( 0 === $is_blog_public && is_multisite() ) {
117
+ return false;
118
+ }
119
+
120
+ return $return;
121
+ }
122
+ add_filter( 'bp_activity_post_pre_publish', 'bp_blogs_post_pre_publish', 10, 4 );
bp-blogs/bp-blogs-functions.php CHANGED
@@ -283,6 +283,15 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
283
  ) );
284
  }
285
 
 
 
 
 
 
 
 
 
 
286
  do_action_ref_array( 'bp_blogs_new_blog', array( &$recorded_blog, $is_private, $is_recorded ) );
287
  }
288
  add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
@@ -402,199 +411,63 @@ function bp_blogs_update_option_thread_comments_depth( $oldvalue, $newvalue ) {
402
  add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
403
 
404
  /**
405
- * Detect a change in post status, and initiate an activity update if necessary.
406
- *
407
- * Posts get new activity updates when (a) they are being published, and (b)
408
- * they have not already been published. This enables proper posting for
409
- * regular posts as well as scheduled posts, while preventing post bumping.
410
  *
411
- * See #4090, #3746, #2546 for background.
412
  *
413
- * @since BuddyPress (2.0.0)
414
- *
415
- * @todo Support untrashing better
416
- *
417
- * @param string $new_status New status for the post.
418
- * @param string $old_status Old status for the post.
419
- * @param object $post Post data.
420
  */
421
- function bp_blogs_catch_transition_post_status( $new_status, $old_status, $post ) {
422
-
423
- // This is an edit
424
- if ( $new_status === $old_status ) {
425
- if ( $new_status == 'publish' ) {
426
- bp_blogs_update_post( $post );
427
- return;
428
- }
429
- }
430
-
431
- // Publishing a previously unpublished post
432
- if ( 'publish' === $new_status ) {
433
- // Untrashing the post
434
- // Nothing here yet
435
- if ( 'trash' == $old_status ) {}
436
-
437
- // Record the post
438
- bp_blogs_record_post( $post->ID, $post );
439
-
440
- // Unpublishing a previously published post
441
- } else if ( 'publish' === $old_status ) {
442
- // Some form of pending status
443
- // Only remove the activity entry
444
- bp_blogs_delete_activity( array(
445
- 'item_id' => get_current_blog_id(),
446
- 'secondary_item_id' => $post->ID,
447
- 'component' => buddypress()->blogs->id,
448
- 'type' => 'new_blog_post'
449
- ) );
450
  }
451
- }
452
- add_action( 'transition_post_status', 'bp_blogs_catch_transition_post_status', 10, 3 );
453
 
454
- /**
455
- * Record a new blog post in the BuddyPress activity stream.
456
- *
457
- * @param int $post_id ID of the post being recorded.
458
- * @param object $post The WP post object passed to the 'save_post' action.
459
- * @param int $user_id Optional. The user to whom the activity item will be
460
- * associated. Defaults to the post_author.
461
- * @return bool|null Returns false on failure.
462
- */
463
- function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
464
- global $bp, $wpdb;
465
 
466
- $post_id = (int) $post_id;
467
- $blog_id = (int) $wpdb->blogid;
468
-
469
- // If blog is not trackable, do not record the activity.
470
- if ( ! bp_blogs_is_blog_trackable( $blog_id, $user_id ) )
471
- return false;
472
-
473
- if ( !$user_id )
474
- $user_id = (int) $post->post_author;
475
-
476
- // Stop infinite loops with WordPress MU Sitewide Tags.
477
- // That plugin changed the way its settings were stored at some point. Thus the dual check.
478
- if ( !empty( $bp->site_options['sitewide_tags_blog'] ) ) {
479
- $st_options = maybe_unserialize( $bp->site_options['sitewide_tags_blog'] );
480
- $tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0;
481
  } else {
482
- $tags_blog_id = isset( $bp->site_options['tags_blog_id'] ) ? $bp->site_options['tags_blog_id'] : 0;
483
  }
484
 
485
- if ( (int) $blog_id == $tags_blog_id && apply_filters( 'bp_blogs_block_sitewide_tags_activity', true ) )
486
- return false;
487
-
488
- // Don't record this if it's not a post
489
- if ( !in_array( $post->post_type, apply_filters( 'bp_blogs_record_post_post_types', array( 'post' ) ) ) )
490
- return false;
491
 
492
- $is_blog_public = apply_filters( 'bp_is_blog_public', (int)get_blog_option( $blog_id, 'blog_public' ) );
 
493
 
494
- if ( 'publish' == $post->post_status && empty( $post->post_password ) ) {
495
- if ( $is_blog_public || !is_multisite() ) {
496
-
497
- // Record this in activity streams
498
- $post_permalink = add_query_arg(
499
- 'p',
500
- $post_id,
501
- trailingslashit( get_home_url( $blog_id ) )
502
- );
503
-
504
- if ( is_multisite() )
505
- $activity_action = sprintf( __( '%1$s wrote a new post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' );
506
- else
507
- $activity_action = sprintf( __( '%1$s wrote a new post, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
508
-
509
- // Make sure there's not an existing entry for this post (prevent bumping)
510
- if ( bp_is_active( 'activity' ) ) {
511
- $existing = bp_activity_get( array(
512
- 'filter' => array(
513
- 'action' => 'new_blog_post',
514
- 'primary_id' => $blog_id,
515
- 'secondary_id' => $post_id,
516
- )
517
- ) );
518
-
519
- if ( !empty( $existing['activities'] ) ) {
520
- return;
521
- }
522
- }
523
-
524
- $activity_content = $post->post_content;
525
-
526
- $activity_id = bp_blogs_record_activity( array(
527
- 'user_id' => (int) $post->post_author,
528
- 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, $post, $post_permalink ),
529
- 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
530
- 'type' => 'new_blog_post',
531
- 'item_id' => $blog_id,
532
- 'secondary_item_id' => $post_id,
533
- 'recorded_time' => $post->post_date_gmt,
534
- ) );
535
-
536
- // save post title in activity meta
537
- if ( bp_is_active( 'activity' ) ) {
538
- bp_activity_update_meta( $activity_id, 'post_title', $post->post_title );
539
- bp_activity_update_meta( $activity_id, 'post_url', $post_permalink );
540
- }
541
- }
542
-
543
- // Update the blogs last activity
544
- bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() );
545
- } else {
546
- bp_blogs_remove_post( $post_id, $blog_id, $user_id );
547
- }
548
-
549
- do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id );
550
  }
 
551
 
552
  /**
553
- * Updates a blog post's corresponding activity entry during a post edit.
554
- *
555
- * @since BuddyPress (2.0.0)
556
  *
557
- * @see bp_blogs_catch_transition_post_status()
558
  *
559
- * @param WP_Post $post
 
560
  */
561
- function bp_blogs_update_post( $post ) {
562
- if ( ! bp_is_active( 'activity' ) ) {
563
  return;
564
  }
565
 
566
- $activity_id = bp_activity_get_activity_id( array(
567
- 'component' => buddypress()->blogs->id,
568
- 'item_id' => get_current_blog_id(),
569
- 'secondary_item_id' => $post->ID,
570
- 'type' => 'new_blog_post',
571
- ) );
572
-
573
- // activity ID doesn't exist, so stop!
574
- if ( empty( $activity_id ) ) {
575
- return;
576
- }
577
-
578
- // update the activity entry
579
- $activity = new BP_Activity_Activity( $activity_id );
580
-
581
- if ( ! empty( $post->post_content ) ) {
582
- // Make sure to update the thumbnail image
583
- $post_content = bp_activity_thumbnail_content_images( $post->post_content, $activity->primary_link, (array) $activity );
584
-
585
- // Make sure to apply the blop post excerpt
586
- $activity->content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $post_content ), $post_content, (array) $activity );
587
- }
588
-
589
- // Save the updated activity
590
- $activity->save();
591
-
592
- // update post title in activity meta
593
- $existing_title = bp_activity_get_meta( $activity_id, 'post_title' );
594
  if ( $post->post_title !== $existing_title ) {
595
- bp_activity_update_meta( $activity_id, 'post_title', $post->post_title );
596
 
597
- // now update activity meta for post comments... sigh
598
  add_filter( 'comments_clauses', 'bp_blogs_comments_clauses_select_by_id' );
599
  $comments = get_comments( array( 'post_id' => $post->ID ) );
600
  remove_filter( 'comments_clauses', 'bp_blogs_comments_clauses_select_by_id' );
@@ -603,14 +476,14 @@ function bp_blogs_update_post( $post ) {
603
  $activity_ids = array();
604
  $comment_ids = wp_list_pluck( $comments, 'comment_ID' );
605
 
606
- // setup activity args
607
  $args = array(
608
  'update_meta_cache' => false,
609
  'show_hidden' => true,
610
  'per_page' => 99999,
611
  );
612
 
613
- // query for old-style "new_blog_comment" activity items
614
  $args['filter'] = array(
615
  'object' => buddypress()->blogs->id,
616
  'action' => 'new_blog_comment',
@@ -622,7 +495,7 @@ function bp_blogs_update_post( $post ) {
622
  $activity_ids = (array) wp_list_pluck( $activities['activities'], 'id' );
623
  }
624
 
625
- // query for activity comments connected to a blog post
626
  unset( $args['filter'] );
627
  $args['meta_query'] = array( array(
628
  'key' => 'bp_blogs_post_comment_id',
@@ -637,7 +510,7 @@ function bp_blogs_update_post( $post ) {
637
  $activity_ids = array_merge( $activity_ids, (array) wp_list_pluck( $activities['activities'], 'id' ) );
638
  }
639
 
640
- // update activity meta for all found activity items
641
  if ( ! empty( $activity_ids ) ) {
642
  foreach ( $activity_ids as $aid ) {
643
  bp_activity_update_meta( $aid, 'post_title', $post->post_title );
@@ -648,13 +521,14 @@ function bp_blogs_update_post( $post ) {
648
  }
649
  }
650
 
651
- // add post comment status to activity meta if closed
652
  if( 'closed' == $post->comment_status ) {
653
- bp_activity_update_meta( $activity_id, 'post_comment_status', $post->comment_status );
654
  } else {
655
- bp_activity_delete_meta( $activity_id, 'post_comment_status' );
656
  }
657
  }
 
658
 
659
  /**
660
  * Record a new blog comment in the BuddyPress activity stream.
@@ -934,7 +808,7 @@ add_action( 'remove_user_from_blog', 'bp_blogs_remove_user_from_blog', 10, 2 );
934
  * core function, so that we can be sure that the Blogs component is loaded
935
  * first. See http://buddypress.trac.wordpress.org/ticket/3916.
936
  *
937
- * @since BuddyPress (1.6)
938
  * @access private
939
  */
940
  function bp_blogs_maybe_add_user_to_blog() {
@@ -955,6 +829,15 @@ function bp_blogs_remove_blog( $blog_id ) {
955
  global $bp;
956
 
957
  $blog_id = (int) $blog_id;
 
 
 
 
 
 
 
 
 
958
  do_action( 'bp_blogs_before_remove_blog', $blog_id );
959
 
960
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
@@ -962,6 +845,14 @@ function bp_blogs_remove_blog( $blog_id ) {
962
  // Delete activity stream item
963
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->id, 'type' => 'new_blog' ) );
964
 
 
 
 
 
 
 
 
 
965
  do_action( 'bp_blogs_remove_blog', $blog_id );
966
  }
967
  add_action( 'delete_blog', 'bp_blogs_remove_blog' );
@@ -978,6 +869,14 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
978
  $blog_id = (int) $blog_id;
979
  $user_id = (int) $user_id;
980
 
 
 
 
 
 
 
 
 
981
  do_action( 'bp_blogs_before_remove_blog_for_user', $blog_id, $user_id );
982
 
983
  BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
@@ -989,6 +888,14 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
989
  'type' => 'new_blog'
990
  ) );
991
 
 
 
 
 
 
 
 
 
992
  do_action( 'bp_blogs_remove_blog_for_user', $blog_id, $user_id );
993
  }
994
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
@@ -1015,11 +922,29 @@ function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
1015
  if ( !$user_id )
1016
  $user_id = bp_loggedin_user_id();
1017
 
 
 
 
 
 
 
 
 
 
1018
  do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id );
1019
 
1020
  // Delete activity stream item
1021
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->id, 'type' => 'new_blog_post' ) );
1022
 
 
 
 
 
 
 
 
 
 
1023
  do_action( 'bp_blogs_remove_post', $blog_id, $post_id, $user_id );
1024
  }
1025
  add_action( 'delete_post', 'bp_blogs_remove_post' );
@@ -1079,6 +1004,15 @@ function bp_blogs_remove_comment( $comment_id ) {
1079
  }
1080
  }
1081
 
 
 
 
 
 
 
 
 
 
1082
  do_action( 'bp_blogs_remove_comment', $wpdb->blogid, $comment_id, bp_loggedin_user_id() );
1083
  }
1084
  add_action( 'delete_comment', 'bp_blogs_remove_comment' );
@@ -1210,7 +1144,9 @@ add_action( 'transition_comment_status', 'bp_blogs_transition_activity_status',
1210
  * @return int $count Total blog count.
1211
  */
1212
  function bp_blogs_total_blogs() {
1213
- if ( !$count = wp_cache_get( 'bp_total_blogs', 'bp' ) ) {
 
 
1214
  $blogs = BP_Blogs_Blog::get_all();
1215
  $count = $blogs['total'];
1216
  wp_cache_set( 'bp_total_blogs', $count, 'bp' );
@@ -1254,6 +1190,14 @@ function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
1254
  function bp_blogs_remove_data_for_blog( $blog_id ) {
1255
  global $bp;
1256
 
 
 
 
 
 
 
 
 
1257
  do_action( 'bp_blogs_before_remove_data_for_blog', $blog_id );
1258
 
1259
  // If this is regular blog, delete all data for that blog.
@@ -1262,6 +1206,14 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
1262
  // Delete activity stream item
1263
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->id, 'type' => false ) );
1264
 
 
 
 
 
 
 
 
 
1265
  do_action( 'bp_blogs_remove_data_for_blog', $blog_id );
1266
  }
1267
  add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
@@ -1328,7 +1280,7 @@ function bp_blogs_is_blog_hidden( $blog_id ) {
1328
  */
1329
 
1330
  /**
1331
- * Delete a metadta from the DB for a blog.
1332
  *
1333
  * @global object $wpdb WordPress database access object.
1334
  * @global object $bp BuddyPress global settings.
@@ -1446,13 +1398,53 @@ function bp_blogs_remove_data( $user_id ) {
1446
  if ( !is_multisite() )
1447
  return false;
1448
 
 
 
 
 
 
 
 
1449
  do_action( 'bp_blogs_before_remove_data', $user_id );
1450
 
1451
  // If this is regular blog, delete all data for that blog.
1452
  BP_Blogs_Blog::delete_blogs_for_user( $user_id );
1453
 
 
 
 
 
 
 
 
1454
  do_action( 'bp_blogs_remove_data', $user_id );
1455
  }
1456
  add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' );
1457
  add_action( 'delete_user', 'bp_blogs_remove_data' );
1458
  add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  ) );
284
  }
285
 
286
+ /**
287
+ * Fires after BuddyPress has been made aware of a new site for activity tracking.
288
+ *
289
+ * @since BuddyPress (1.0.0)
290
+ *
291
+ * @param BP_Blogs_Blog $recorded_blog Current blog being recorded. Passed by reference.
292
+ * @param bool $is_private Whether or not the current blog being recorded is private.
293
+ * @param bool $is_recorded Whether or not the current blog was recorded.
294
+ */
295
  do_action_ref_array( 'bp_blogs_new_blog', array( &$recorded_blog, $is_private, $is_recorded ) );
296
  }
297
  add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
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
  *
416
+ * @since BuddyPress (2.2.0)
417
  *
418
+ * @param int $activity_id ID of the activity item.
419
+ * @param WP_Post $post Post object.
 
 
 
 
 
420
  */
421
+ function bp_blogs_publish_post_activity_meta( $activity_id, $post, $args ) {
422
+ if ( empty( $activity_id ) || 'post' != $post->post_type ) {
423
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  }
 
 
425
 
426
+ bp_activity_update_meta( $activity_id, 'post_title', $post->post_title );
 
 
 
 
 
 
 
 
 
 
427
 
428
+ if ( ! empty( $args['post_url'] ) ) {
429
+ $post_permalink = $args['post_url'];
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  } else {
431
+ $post_permalink = $post->guid;
432
  }
433
 
434
+ bp_activity_update_meta( $activity_id, 'post_url', $post_permalink );
 
 
 
 
 
435
 
436
+ // Update the blog's last activity.
437
+ bp_blogs_update_blogmeta( $args['item_id'], 'last_activity', bp_core_current_time() );
438
 
439
+ /**
440
+ * Fires after BuddyPress has recorded metadata about a published blog post.
441
+ *
442
+ * @since BuddyPress (1.0.0)
443
+ *
444
+ * @param int $ID ID of the blog post being recorded.
445
+ * @param WP_Post $post WP_Post object for the current blog post.
446
+ * @param string $value ID of the user associated with the current blog post.
447
+ */
448
+ do_action( 'bp_blogs_new_blog_post', $post->ID, $post, $args['user_id'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  }
450
+ add_action( 'bp_activity_post_type_published', 'bp_blogs_publish_post_activity_meta', 10, 3 );
451
 
452
  /**
453
+ * Updates a blog post's activity meta entry during a post edit.
 
 
454
  *
455
+ * @since BuddyPress (2.2.0)
456
  *
457
+ * @param WP_Post $post Post object.
458
+ * @param BP_Activity_Activity $activity Activity object.
459
  */
460
+ function bp_blogs_update_post_activity_meta( $post, $activity ) {
461
+ if ( empty( $activity->id ) || 'post' != $post->post_type ) {
462
  return;
463
  }
464
 
465
+ // Update post title in activity meta.
466
+ $existing_title = bp_activity_get_meta( $activity->id, 'post_title' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  if ( $post->post_title !== $existing_title ) {
468
+ bp_activity_update_meta( $activity->id, 'post_title', $post->post_title );
469
 
470
+ // Now update activity meta for post comments... sigh.
471
  add_filter( 'comments_clauses', 'bp_blogs_comments_clauses_select_by_id' );
472
  $comments = get_comments( array( 'post_id' => $post->ID ) );
473
  remove_filter( 'comments_clauses', 'bp_blogs_comments_clauses_select_by_id' );
476
  $activity_ids = array();
477
  $comment_ids = wp_list_pluck( $comments, 'comment_ID' );
478
 
479
+ // Set up activity args.
480
  $args = array(
481
  'update_meta_cache' => false,
482
  'show_hidden' => true,
483
  'per_page' => 99999,
484
  );
485
 
486
+ // Query for old-style "new_blog_comment" activity items.
487
  $args['filter'] = array(
488
  'object' => buddypress()->blogs->id,
489
  'action' => 'new_blog_comment',
495
  $activity_ids = (array) wp_list_pluck( $activities['activities'], 'id' );
496
  }
497
 
498
+ // Query for activity comments connected to a blog post.
499
  unset( $args['filter'] );
500
  $args['meta_query'] = array( array(
501
  'key' => 'bp_blogs_post_comment_id',
510
  $activity_ids = array_merge( $activity_ids, (array) wp_list_pluck( $activities['activities'], 'id' ) );
511
  }
512
 
513
+ // Update activity meta for all found activity items.
514
  if ( ! empty( $activity_ids ) ) {
515
  foreach ( $activity_ids as $aid ) {
516
  bp_activity_update_meta( $aid, 'post_title', $post->post_title );
521
  }
522
  }
523
 
524
+ // Add post comment status to activity meta if closed.
525
  if( 'closed' == $post->comment_status ) {
526
+ bp_activity_update_meta( $activity->id, 'post_comment_status', $post->comment_status );
527
  } else {
528
+ bp_activity_delete_meta( $activity->id, 'post_comment_status' );
529
  }
530
  }
531
+ add_action( 'bp_activity_post_type_updated', 'bp_blogs_update_post_activity_meta', 10, 2 );
532
 
533
  /**
534
  * Record a new blog comment in the BuddyPress activity stream.
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
813
  */
814
  function bp_blogs_maybe_add_user_to_blog() {
829
  global $bp;
830
 
831
  $blog_id = (int) $blog_id;
832
+
833
+ /**
834
+ * Fires before a "blog created" item is removed from blogs
835
+ * tracker and activity stream.
836
+ *
837
+ * @since BuddyPress (1.5.0)
838
+ *
839
+ * @param int $blog_id ID of the blog having its item removed.
840
+ */
841
  do_action( 'bp_blogs_before_remove_blog', $blog_id );
842
 
843
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
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
850
+ * tracker and activity stream.
851
+ *
852
+ * @since BuddyPress (1.0.0)
853
+ *
854
+ * @param int $blog_id ID of the blog who had its item removed.
855
+ */
856
  do_action( 'bp_blogs_remove_blog', $blog_id );
857
  }
858
  add_action( 'delete_blog', 'bp_blogs_remove_blog' );
869
  $blog_id = (int) $blog_id;
870
  $user_id = (int) $user_id;
871
 
872
+ /**
873
+ * Fires before a blog is removed from the tracker for a specific user.
874
+ *
875
+ * @since BuddyPress (1.5.0)
876
+ *
877
+ * @param int $blog_id ID of the blog being removed.
878
+ * @param int $user_id ID of the user having the blog removed for.
879
+ */
880
  do_action( 'bp_blogs_before_remove_blog_for_user', $blog_id, $user_id );
881
 
882
  BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
888
  'type' => 'new_blog'
889
  ) );
890
 
891
+ /**
892
+ * Fires after a blog has been removed from the tracker for a specific user.
893
+ *
894
+ * @since BuddyPress (1.0.0)
895
+ *
896
+ * @param int $blog_id ID of the blog that was removed.
897
+ * @param int $user_id ID of the user having the blog removed for.
898
+ */
899
  do_action( 'bp_blogs_remove_blog_for_user', $blog_id, $user_id );
900
  }
901
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
922
  if ( !$user_id )
923
  $user_id = bp_loggedin_user_id();
924
 
925
+ /**
926
+ * Fires before removal of a blog post activity item from the activity stream.
927
+ *
928
+ * @since BuddyPress (1.5.0)
929
+ *
930
+ * @param int $blog_id ID of the blog associated with the post that was removed.
931
+ * @param int $post_id ID of the post that was removed.
932
+ * @param int $user_id ID of the user having the blog removed for.
933
+ */
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.
941
+ *
942
+ * @since BuddyPress (1.0.0)
943
+ *
944
+ * @param int $blog_id ID of the blog associated with the post that was removed.
945
+ * @param int $post_id ID of the post that was removed.
946
+ * @param int $user_id ID of the user having the blog removed for.
947
+ */
948
  do_action( 'bp_blogs_remove_post', $blog_id, $post_id, $user_id );
949
  }
950
  add_action( 'delete_post', 'bp_blogs_remove_post' );
1004
  }
1005
  }
1006
 
1007
+ /**
1008
+ * Fires after a blog comment activity item was removed from activity stream.
1009
+ *
1010
+ * @since BuddyPress (1.0.0)
1011
+ *
1012
+ * @param int $blogid Item ID for the blog associated with the removed comment.
1013
+ * @param int $comment_id ID of the comment being removed.
1014
+ * @param int $value ID of the current logged in user.
1015
+ */
1016
  do_action( 'bp_blogs_remove_comment', $wpdb->blogid, $comment_id, bp_loggedin_user_id() );
1017
  }
1018
  add_action( 'delete_comment', 'bp_blogs_remove_comment' );
1144
  * @return int $count Total blog count.
1145
  */
1146
  function bp_blogs_total_blogs() {
1147
+ $count = wp_cache_get( 'bp_total_blogs', 'bp' );
1148
+
1149
+ if ( false === $count ) {
1150
  $blogs = BP_Blogs_Blog::get_all();
1151
  $count = $blogs['total'];
1152
  wp_cache_set( 'bp_total_blogs', $count, 'bp' );
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
1195
+ * and activity stream.
1196
+ *
1197
+ * @since BuddyPress (1.5.0)
1198
+ *
1199
+ * @param int $blog_id ID of the blog whose data is being removed.
1200
+ */
1201
  do_action( 'bp_blogs_before_remove_data_for_blog', $blog_id );
1202
 
1203
  // If this is regular blog, delete all data for that blog.
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
1211
+ * and activity stream.
1212
+ *
1213
+ * @since BuddyPress (1.0.0)
1214
+ *
1215
+ * @param int $blog_id ID of the blog whose data is being removed.
1216
+ */
1217
  do_action( 'bp_blogs_remove_data_for_blog', $blog_id );
1218
  }
1219
  add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
1280
  */
1281
 
1282
  /**
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.
1398
  if ( !is_multisite() )
1399
  return false;
1400
 
1401
+ /**
1402
+ * Fires before all blog associations are removed for a given user.
1403
+ *
1404
+ * @since BuddyPress (1.5.0)
1405
+ *
1406
+ * @param int $user_id ID of the user whose blog associations are being removed.
1407
+ */
1408
  do_action( 'bp_blogs_before_remove_data', $user_id );
1409
 
1410
  // If this is regular blog, delete all data for that blog.
1411
  BP_Blogs_Blog::delete_blogs_for_user( $user_id );
1412
 
1413
+ /**
1414
+ * Fires after all blog associations are removed for a given user.
1415
+ *
1416
+ * @since BuddyPress (1.0.0)
1417
+ *
1418
+ * @param int $user_id ID of the user whose blog associations were removed.
1419
+ */
1420
  do_action( 'bp_blogs_remove_data', $user_id );
1421
  }
1422
  add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' );
1423
  add_action( 'delete_user', 'bp_blogs_remove_data' );
1424
  add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
1425
+
1426
+ /**
1427
+ * Restore all blog associations for a given user
1428
+ *
1429
+ * @since BuddyPress (2.2.0)
1430
+ *
1431
+ * @param int $user_id ID whose blog data should be restored.
1432
+ */
1433
+ function bp_blogs_restore_data( $user_id = 0 ) {
1434
+ if ( ! is_multisite() ) {
1435
+ return;
1436
+ }
1437
+
1438
+ // Get the user's blogs
1439
+ $user_blogs = get_blogs_of_user( $user_id );
1440
+ if ( empty( $user_blogs ) ) {
1441
+ return;
1442
+ }
1443
+
1444
+ $blogs = array_keys( $user_blogs );
1445
+
1446
+ foreach ( $blogs as $blog_id ) {
1447
+ bp_blogs_add_user_to_blog( $user_id, false, $blog_id );
1448
+ }
1449
+ }
1450
+ add_action( 'bp_make_ham_user', 'bp_blogs_restore_data', 10, 1 );
bp-blogs/bp-blogs-loader.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * The blogs component tracks posts and comments to member activity streams,
7
  * shows blogs the member can post to in their profiles, and caches useful
8
- * information from those blogs to make quering blogs in bulk more performant.
9
  *
10
  * @package BuddyPress
11
  * @subpackage Blogs Core
@@ -75,6 +75,30 @@ class BP_Blogs_Component extends BP_Component {
75
 
76
  // Setup the globals
77
  parent::setup_globals( $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
 
80
  /**
@@ -246,6 +270,45 @@ class BP_Blogs_Component extends BP_Component {
246
 
247
  parent::setup_title();
248
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
250
 
251
  /**
5
  *
6
  * The blogs component tracks posts and comments to member activity streams,
7
  * shows blogs the member can post to in their profiles, and caches useful
8
+ * information from those blogs to make querying blogs in bulk more performant.
9
  *
10
  * @package BuddyPress
11
  * @subpackage Blogs Core
75
 
76
  // Setup the globals
77
  parent::setup_globals( $args );
78
+
79
+ /*
80
+ * Set up the post post type to track.
81
+ *
82
+ * In case the config is not multisite, the blog_public option is ignored.
83
+ */
84
+ if ( 0 !== (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
+ */
93
+ $post_types = apply_filters( 'bp_blogs_record_post_post_types', array( 'post' ) );
94
+
95
+ foreach ( $post_types as $post_type ) {
96
+ add_post_type_support( $post_type, 'buddypress-activity' );
97
+ }
98
+ }
99
+
100
+ // Filter the generic track parameters for the 'post' post type.
101
+ add_filter( 'bp_activity_get_post_type_tracking_args', array( $this, 'post_tracking_args' ), 10, 2 );
102
  }
103
 
104
  /**
270
 
271
  parent::setup_title();
272
  }
273
+
274
+ /**
275
+ * Setup cache groups
276
+ *
277
+ * @since BuddyPress (2.2.0)
278
+ */
279
+ public function setup_cache_groups() {
280
+
281
+ // Global groups
282
+ wp_cache_add_global_groups( array(
283
+ 'blog_meta'
284
+ ) );
285
+
286
+ parent::setup_cache_groups();
287
+ }
288
+
289
+ /**
290
+ * Set up the tracking arguments for the 'post' post type.
291
+ *
292
+ * @since BuddyPress (2.2.0)
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
+
301
+ // Set specific params for the 'post' post type.
302
+ $params->component_id = $this->id;
303
+ $params->action_id = 'new_blog_post';
304
+ $params->admin_filter = __( 'New post published', 'buddypress' );
305
+ $params->format_callback = 'bp_blogs_format_activity_action_new_blog_post';
306
+ $params->front_filter = __( 'Posts', 'buddypress' );
307
+ $params->contexts = array( 'activity', 'member' );
308
+ $params->position = 5;
309
+
310
+ return $params;
311
+ }
312
  }
313
 
314
  /**
bp-blogs/bp-blogs-screens.php CHANGED
@@ -17,6 +17,11 @@ function bp_blogs_screen_my_blogs() {
17
  if ( !is_multisite() )
18
  return false;
19
 
 
 
 
 
 
20
  do_action( 'bp_blogs_screen_my_blogs' );
21
 
22
  bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
@@ -33,6 +38,11 @@ function bp_blogs_screen_create_a_blog() {
33
  if ( !is_user_logged_in() || !bp_blog_signup_enabled() )
34
  return false;
35
 
 
 
 
 
 
36
  do_action( 'bp_blogs_screen_create_a_blog' );
37
 
38
  bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
@@ -46,6 +56,11 @@ function bp_blogs_screen_index() {
46
  if ( bp_is_blogs_directory() ) {
47
  bp_update_is_directory( true, 'blogs' );
48
 
 
 
 
 
 
49
  do_action( 'bp_blogs_screen_index' );
50
 
51
  bp_core_load_template( apply_filters( 'bp_blogs_screen_index', 'blogs/index' ) );
@@ -53,12 +68,12 @@ function bp_blogs_screen_index() {
53
  }
54
  add_action( 'bp_screens', 'bp_blogs_screen_index', 2 );
55
 
56
- /** Theme Compatability *******************************************************/
57
 
58
  /**
59
  * The main theme compat class for BuddyPress Blogs
60
  *
61
- * This class sets up the necessary theme compatability actions to safely output
62
  * group template parts to the_title and the_content areas of a theme.
63
  *
64
  * @since BuddyPress (1.7.0)
@@ -75,7 +90,7 @@ class BP_Blogs_Theme_Compat {
75
  }
76
 
77
  /**
78
- * Are we looking at something that needs Blogs theme compatability?
79
  *
80
  * @since BuddyPress (1.7.0)
81
  */
@@ -93,6 +108,12 @@ class BP_Blogs_Theme_Compat {
93
  if ( is_multisite() && ! bp_current_action() ) {
94
  bp_update_is_directory( true, 'blogs' );
95
 
 
 
 
 
 
 
96
  do_action( 'bp_blogs_screen_index' );
97
 
98
  add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) );
@@ -122,7 +143,14 @@ class BP_Blogs_Theme_Compat {
122
  * @return array $templates Array of custom templates to look for.
123
  */
124
  public function directory_template_hierarchy( $templates ) {
125
- // Setup our templates based on priority
 
 
 
 
 
 
 
126
  $new_templates = apply_filters( 'bp_template_hierarchy_blogs_create', array(
127
  'blogs/index-directory.php'
128
  ) );
@@ -141,11 +169,9 @@ class BP_Blogs_Theme_Compat {
141
  */
142
  public function directory_dummy_post() {
143
 
144
- $title = apply_filters( 'bp_blogs_directory_header', __( 'Sites', 'buddypress' ) );
145
-
146
  bp_theme_compat_reset_post( array(
147
  'ID' => 0,
148
- 'post_title' => $title,
149
  'post_author' => 0,
150
  'post_date' => 0,
151
  'post_content' => '',
@@ -180,7 +206,14 @@ class BP_Blogs_Theme_Compat {
180
  * @return array $templates Array of custom templates to look for.
181
  */
182
  public function create_template_hierarchy( $templates ) {
183
- // Setup our templates based on priority
 
 
 
 
 
 
 
184
  $new_templates = apply_filters( 'bp_template_hierarchy_blogs_create', array(
185
  'blogs/index-create.php'
186
  ) );
@@ -201,7 +234,7 @@ class BP_Blogs_Theme_Compat {
201
 
202
  // Title based on ability to create blogs
203
  if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
204
- $title = '<a class="button bp-title-button" href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) . '">' . __( 'Sites', 'buddypress' ) . '</a>&nbsp;' . __( 'Create a Site', 'buddypress' );
205
  } else {
206
  $title = __( 'Sites', 'buddypress' );
207
  }
17
  if ( !is_multisite() )
18
  return false;
19
 
20
+ /**
21
+ * Fires right before the loading of the My Blogs screen template file.
22
+ *
23
+ * @since BuddyPress (1.0.0)
24
+ */
25
  do_action( 'bp_blogs_screen_my_blogs' );
26
 
27
  bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
38
  if ( !is_user_logged_in() || !bp_blog_signup_enabled() )
39
  return false;
40
 
41
+ /**
42
+ * Fires right before the loading of the Create A Blog screen template file.
43
+ *
44
+ * @since BuddyPress (1.0.0)
45
+ */
46
  do_action( 'bp_blogs_screen_create_a_blog' );
47
 
48
  bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
56
  if ( bp_is_blogs_directory() ) {
57
  bp_update_is_directory( true, 'blogs' );
58
 
59
+ /**
60
+ * Fires right before the loading of the top-level Blogs screen template file.
61
+ *
62
+ * @since BuddyPress (1.0.0)
63
+ */
64
  do_action( 'bp_blogs_screen_index' );
65
 
66
  bp_core_load_template( apply_filters( 'bp_blogs_screen_index', 'blogs/index' ) );
68
  }
69
  add_action( 'bp_screens', 'bp_blogs_screen_index', 2 );
70
 
71
+ /** Theme Compatibility *******************************************************/
72
 
73
  /**
74
  * The main theme compat class for BuddyPress Blogs
75
  *
76
+ * This class sets up the necessary theme compatibility actions to safely output
77
  * group template parts to the_title and the_content areas of a theme.
78
  *
79
  * @since BuddyPress (1.7.0)
90
  }
91
 
92
  /**
93
+ * Are we looking at something that needs Blogs theme compatibility?
94
  *
95
  * @since BuddyPress (1.7.0)
96
  */
108
  if ( is_multisite() && ! bp_current_action() ) {
109
  bp_update_is_directory( true, 'blogs' );
110
 
111
+ /**
112
+ * Fires if in the blog directory and BuddyPress needs Blog theme compatibility,
113
+ * before the actions and filters are added.
114
+ *
115
+ * @since BuddyPress (1.5.0)
116
+ */
117
  do_action( 'bp_blogs_screen_index' );
118
 
119
  add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) );
143
  * @return array $templates Array of custom templates to look for.
144
  */
145
  public function directory_template_hierarchy( $templates ) {
146
+
147
+ /**
148
+ * Filters the custom templates used for theme compat with the blog directory page.
149
+ *
150
+ * @since BuddyPress (1.8.0)
151
+ *
152
+ * @param array $value Array of template paths to add to template list to look for.
153
+ */
154
  $new_templates = apply_filters( 'bp_template_hierarchy_blogs_create', array(
155
  'blogs/index-directory.php'
156
  ) );
169
  */
170
  public function directory_dummy_post() {
171
 
 
 
172
  bp_theme_compat_reset_post( array(
173
  'ID' => 0,
174
+ 'post_title' => __( 'Sites', 'buddypress' ),
175
  'post_author' => 0,
176
  'post_date' => 0,
177
  'post_content' => '',
206
  * @return array $templates Array of custom templates to look for.
207
  */
208
  public function create_template_hierarchy( $templates ) {
209
+
210
+ /**
211
+ * Filters the custom templates used for theme compat with the blog create page.
212
+ *
213
+ * @since BuddyPress (1.8.0)
214
+ *
215
+ * @param array $value Array of template paths to add to template list to look for.
216
+ */
217
  $new_templates = apply_filters( 'bp_template_hierarchy_blogs_create', array(
218
  'blogs/index-create.php'
219
  ) );
234
 
235
  // Title based on ability to create blogs
236
  if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
237
+ $title = __( 'Create a Site', 'buddypress' );
238
  } else {
239
  $title = __( 'Sites', 'buddypress' );
240
  }
bp-blogs/bp-blogs-template.php CHANGED
@@ -28,6 +28,14 @@ function bp_blogs_slug() {
28
  * @return string The 'blogs' slug.
29
  */
30
  function bp_get_blogs_slug() {
 
 
 
 
 
 
 
 
31
  return apply_filters( 'bp_get_blogs_slug', buddypress()->blogs->slug );
32
  }
33
 
@@ -49,6 +57,14 @@ function bp_blogs_root_slug() {
49
  * @return string The 'blogs' root slug.
50
  */
51
  function bp_get_blogs_root_slug() {
 
 
 
 
 
 
 
 
52
  return apply_filters( 'bp_get_blogs_root_slug', buddypress()->blogs->root_slug );
53
  }
54
 
@@ -74,6 +90,14 @@ function bp_blogs_directory_permalink() {
74
  * @return string The URL of the Blogs directory.
75
  */
76
  function bp_get_blogs_directory_permalink() {
 
 
 
 
 
 
 
 
77
  return apply_filters( 'bp_get_blogs_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) );
78
  }
79
 
@@ -224,7 +248,8 @@ class BP_Blogs_Template {
224
  'current' => (int) $this->pag_page,
225
  'prev_text' => _x( '&larr;', 'Blog pagination previous text', 'buddypress' ),
226
  'next_text' => _x( '&rarr;', 'Blog pagination next text', 'buddypress' ),
227
- 'mid_size' => 1
 
228
  ) );
229
  }
230
  }
@@ -277,6 +302,12 @@ class BP_Blogs_Template {
277
  if ( ( $this->current_blog + 1 ) < $this->blog_count ) {
278
  return true;
279
  } elseif ( ( $this->current_blog + 1 ) === $this->blog_count ) {
 
 
 
 
 
 
280
  do_action( 'blog_loop_end' );
281
  // Do some cleaning up after the loop
282
  $this->rewind_blogs();
@@ -302,6 +333,12 @@ class BP_Blogs_Template {
302
 
303
  // loop has just started
304
  if ( 0 === $this->current_blog ) {
 
 
 
 
 
 
305
  do_action( 'blog_loop_start' );
306
  }
307
  }
@@ -357,7 +394,7 @@ function bp_rewind_blogs() {
357
  function bp_has_blogs( $args = '' ) {
358
  global $blogs_template;
359
 
360
- // Checkfor and use search terms
361
  $search_terms = ! empty( $_REQUEST['s'] )
362
  ? $_REQUEST['s']
363
  : false;
@@ -383,7 +420,15 @@ function bp_has_blogs( $args = '' ) {
383
  // Get the blogs
384
  $blogs_template = new BP_Blogs_Template( $r['type'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['search_terms'], $r['page_arg'], $r['update_meta_cache'], $r['include_blog_ids'] );
385
 
386
- // Filter and return
 
 
 
 
 
 
 
 
387
  return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template, $r );
388
  }
389
 
@@ -445,6 +490,13 @@ function bp_blogs_pagination_links() {
445
  function bp_get_blogs_pagination_links() {
446
  global $blogs_template;
447
 
 
 
 
 
 
 
 
448
  return apply_filters( 'bp_get_blogs_pagination_links', $blogs_template->pag_links );
449
  }
450
 
@@ -526,6 +578,16 @@ function bp_blog_avatar( $args = '' ) {
526
  */
527
  $avatar = apply_filters( 'bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar );
528
 
 
 
 
 
 
 
 
 
 
 
529
  return apply_filters( 'bp_get_blog_avatar', $avatar, $blogs_template->blog->blog_id, $r );
530
  }
531
 
@@ -545,6 +607,13 @@ function bp_blog_permalink() {
545
  $permalink = $protocol . $blogs_template->blog->domain . $blogs_template->blog->path;
546
  }
547
 
 
 
 
 
 
 
 
548
  return apply_filters( 'bp_get_blog_permalink', $permalink );
549
  }
550
 
@@ -562,6 +631,13 @@ function bp_blog_name() {
562
  function bp_get_blog_name() {
563
  global $blogs_template;
564
 
 
 
 
 
 
 
 
565
  return apply_filters( 'bp_get_blog_name', $blogs_template->blog->name );
566
  }
567
 
@@ -583,6 +659,13 @@ function bp_blog_id() {
583
  function bp_get_blog_id() {
584
  global $blogs_template;
585
 
 
 
 
 
 
 
 
586
  return apply_filters( 'bp_get_blog_id', $blogs_template->blog->blog_id );
587
  }
588
 
@@ -590,6 +673,14 @@ function bp_blog_id() {
590
  * Output the description of the current blog in the loop.
591
  */
592
  function bp_blog_description() {
 
 
 
 
 
 
 
 
593
  echo apply_filters( 'bp_blog_description', bp_get_blog_description() );
594
  }
595
  /**
@@ -600,6 +691,13 @@ function bp_blog_description() {
600
  function bp_get_blog_description() {
601
  global $blogs_template;
602
 
 
 
 
 
 
 
 
603
  return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description );
604
  }
605
 
@@ -632,6 +730,13 @@ function bp_blog_class() {
632
  else
633
  $classes[] = 'bp-single-blog';
634
 
 
 
 
 
 
 
 
635
  $classes = apply_filters( 'bp_get_blog_class', $classes );
636
  $classes = array_merge( $classes, array() );
637
 
@@ -665,7 +770,7 @@ function bp_blog_last_active( $args = array() ) {
665
  'active_format' => true
666
  ) );
667
 
668
- // Backwards compatibilty for anyone forcing a 'true' active_format
669
  if ( true === $r['active_format'] ) {
670
  $r['active_format'] = __( 'active %s', 'buddypress' );
671
  }
@@ -683,6 +788,14 @@ function bp_blog_last_active( $args = array() ) {
683
  $last_activity = __( 'Never active', 'buddypress' );
684
  }
685
 
 
 
 
 
 
 
 
 
686
  return apply_filters( 'bp_blog_last_active', $last_activity, $r );
687
  }
688
 
@@ -716,12 +829,29 @@ function bp_blog_latest_post( $args = array() ) {
716
 
717
  if ( ! empty( $retval ) ) {
718
  if ( ! empty( $r['latest_format'] ) ) {
 
 
 
 
 
 
 
 
719
  $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
720
  } else {
 
 
721
  $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>';
722
  }
723
  }
724
 
 
 
 
 
 
 
 
725
  return apply_filters( 'bp_get_blog_latest_post', $retval );
726
  }
727
 
@@ -752,6 +882,13 @@ function bp_blog_latest_post_title() {
752
  if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->post_title ) )
753
  $retval = $blogs_template->blog->latest_post->post_title;
754
 
 
 
 
 
 
 
 
755
  return apply_filters( 'bp_get_blog_latest_post_title', $retval );
756
  }
757
 
@@ -782,6 +919,13 @@ function bp_blog_latest_post_permalink() {
782
  if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->ID ) )
783
  $retval = add_query_arg( 'p', $blogs_template->blog->latest_post->ID, bp_get_blog_permalink() );
784
 
 
 
 
 
 
 
 
785
  return apply_filters( 'bp_get_blog_latest_post_permalink', $retval );
786
  }
787
 
@@ -812,6 +956,13 @@ function bp_blog_latest_post_content() {
812
  if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->post_content ) )
813
  $retval = $blogs_template->blog->latest_post->post_content;
814
 
 
 
 
 
 
 
 
815
  return apply_filters( 'bp_get_blog_latest_post_content', $retval );
816
  }
817
 
@@ -846,6 +997,13 @@ function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
846
  if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->images[$size] ) )
847
  $retval = $blogs_template->blog->latest_post->images[$size];
848
 
 
 
 
 
 
 
 
849
  return apply_filters( 'bp_get_blog_latest_post_featured_image', $retval );
850
  }
851
 
@@ -862,6 +1020,15 @@ function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
862
  function bp_blog_latest_post_has_featured_image( $thumbnail = 'thumbnail' ) {
863
  $image = bp_get_blog_latest_post_featured_image( $thumbnail );
864
 
 
 
 
 
 
 
 
 
 
865
  return apply_filters( 'bp_blog_latest_post_has_featured_image', ! empty( $image ), $thumbnail, $image );
866
  }
867
 
@@ -895,6 +1062,14 @@ function bp_total_blog_count() {
895
  * @return int Total number of blogs.
896
  */
897
  function bp_get_total_blog_count() {
 
 
 
 
 
 
 
 
898
  return apply_filters( 'bp_get_total_blog_count', bp_blogs_total_blogs() );
899
  }
900
  add_filter( 'bp_get_total_blog_count', 'bp_core_number_format' );
@@ -914,6 +1089,14 @@ function bp_total_blog_count_for_user( $user_id = 0 ) {
914
  * @return int Total number of blogs for the user.
915
  */
916
  function bp_get_total_blog_count_for_user( $user_id = 0 ) {
 
 
 
 
 
 
 
 
917
  return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) );
918
  }
919
  add_filter( 'bp_get_total_blog_count_for_user', 'bp_core_number_format' );
@@ -934,6 +1117,13 @@ function bp_blog_signup_enabled() {
934
 
935
  $active_signup = isset( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : 'all';
936
 
 
 
 
 
 
 
 
937
  $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
938
 
939
  if ( 'none' == $active_signup || 'user' == $active_signup )
@@ -960,7 +1150,17 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
960
  $errors = new WP_Error();
961
  }
962
 
963
- // allow definition of default variables
 
 
 
 
 
 
 
 
 
 
964
  $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
965
  $blogname = $filtered_results['blogname'];
966
  $blog_title = $filtered_results['blog_title'];
@@ -977,7 +1177,14 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
977
  <form class="standard-form" id="setupform" method="post" action="">
978
 
979
  <input type="hidden" name="stage" value="gimmeanotherblog" />
980
- <?php do_action( 'signup_hidden_fields' ); ?>
 
 
 
 
 
 
 
981
 
982
  <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
983
  <p>
@@ -1016,7 +1223,7 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
1016
  if ( !is_subdomain_install() )
1017
  echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span> <input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" /><br />';
1018
  else
1019
- echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" /> <span class="suffix_address">.' . bp_blogs_get_subdomain_base() . '</span><br />';
1020
 
1021
  if ( !is_user_logged_in() ) {
1022
  print '(<strong>' . __( 'Your address will be ' , 'buddypress');
@@ -1058,6 +1265,14 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
1058
  </p>
1059
 
1060
  <?php
 
 
 
 
 
 
 
 
1061
  do_action('signup_blogform', $errors);
1062
  }
1063
 
@@ -1091,6 +1306,17 @@ function bp_blogs_validate_blog_signup() {
1091
  $public = (int) $_POST['blog_public'];
1092
 
1093
  $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated
 
 
 
 
 
 
 
 
 
 
 
1094
  $meta = apply_filters( 'add_signup_meta', $meta );
1095
 
1096
  // If this is a subdomain install, set up the site inside the root domain.
@@ -1137,6 +1363,12 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
1137
  </p>
1138
 
1139
  <?php
 
 
 
 
 
 
1140
  do_action('signup_finished');
1141
  }
1142
 
@@ -1145,6 +1377,14 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
1145
  */
1146
  function bp_create_blog_link() {
1147
  if ( bp_is_my_profile() )
 
 
 
 
 
 
 
 
1148
  echo apply_filters( 'bp_create_blog_link', '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
1149
  }
1150
 
@@ -1168,6 +1408,12 @@ function bp_blogs_blog_tabs() {
1168
  </ul>
1169
 
1170
  <?php
 
 
 
 
 
 
1171
  do_action( 'bp_blogs_blog_tabs' );
1172
  }
1173
 
@@ -1183,6 +1429,13 @@ function bp_directory_blogs_search_form() {
1183
  <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
1184
  </form>';
1185
 
 
 
 
 
 
 
 
1186
  echo apply_filters( 'bp_directory_blogs_search_form', $search_form_html );
1187
  }
1188
 
@@ -1215,14 +1468,76 @@ function bp_blog_create_button() {
1215
  'component' => 'blogs',
1216
  'link_text' => __( 'Create a Site', 'buddypress' ),
1217
  'link_title' => __( 'Create a Site', 'buddypress' ),
1218
- 'link_class' => 'button blog-create bp-title-button',
1219
  'link_href' => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_blogs_root_slug() ) . trailingslashit( 'create' ),
1220
  'wrapper' => false,
 
1221
  );
1222
 
 
 
 
 
 
 
 
1223
  return bp_get_button( apply_filters( 'bp_get_blog_create_button', $button_args ) );
1224
  }
1225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1226
  /**
1227
  * Output button for visiting a blog in a loop.
1228
  *
@@ -1269,7 +1584,13 @@ function bp_blogs_visit_blog_button( $args = '' ) {
1269
 
1270
  $button = wp_parse_args( $args, $defaults );
1271
 
1272
- // Filter and return the HTML button
 
 
 
 
 
 
1273
  return bp_get_button( apply_filters( 'bp_get_blogs_visit_blog_button', $button ) );
1274
  }
1275
 
@@ -1323,6 +1644,13 @@ function bp_blogs_get_profile_stats( $args = '' ) {
1323
  }
1324
  }
1325
 
1326
- // Filter and return
 
 
 
 
 
 
 
1327
  return apply_filters( 'bp_blogs_get_profile_stats', $r['output'], $r );
1328
  }
28
  * @return string The 'blogs' slug.
29
  */
30
  function bp_get_blogs_slug() {
31
+
32
+ /**
33
+ * Filters the blogs component slug.
34
+ *
35
+ * @since BuddyPress (1.5.0)
36
+ *
37
+ * @param string $slug Slug for the blogs component.
38
+ */
39
  return apply_filters( 'bp_get_blogs_slug', buddypress()->blogs->slug );
40
  }
41
 
57
  * @return string The 'blogs' root slug.
58
  */
59
  function bp_get_blogs_root_slug() {
60
+
61
+ /**
62
+ * Filters the blogs component root slug.
63
+ *
64
+ * @since BuddyPress (1.5.0)
65
+ *
66
+ * @param string $root_slug Root slug for the blogs component.
67
+ */
68
  return apply_filters( 'bp_get_blogs_root_slug', buddypress()->blogs->root_slug );
69
  }
70
 
90
  * @return string The URL of the Blogs directory.
91
  */
92
  function bp_get_blogs_directory_permalink() {
93
+
94
+ /**
95
+ * Filters the blog directory permalink.
96
+ *
97
+ * @since BuddyPress (1.5.0)
98
+ *
99
+ * @param string $value Permalink URL for the blog directory.
100
+ */
101
  return apply_filters( 'bp_get_blogs_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) );
102
  }
103
 
248
  'current' => (int) $this->pag_page,
249
  'prev_text' => _x( '&larr;', 'Blog pagination previous text', 'buddypress' ),
250
  'next_text' => _x( '&rarr;', 'Blog pagination next text', 'buddypress' ),
251
+ 'mid_size' => 1,
252
+ 'add_args' => array(),
253
  ) );
254
  }
255
  }
302
  if ( ( $this->current_blog + 1 ) < $this->blog_count ) {
303
  return true;
304
  } elseif ( ( $this->current_blog + 1 ) === $this->blog_count ) {
305
+
306
+ /**
307
+ * Fires right before the rewinding of blogs listing after all are shown.
308
+ *
309
+ * @since BuddyPress (1.5.0)
310
+ */
311
  do_action( 'blog_loop_end' );
312
  // Do some cleaning up after the loop
313
  $this->rewind_blogs();
333
 
334
  // loop has just started
335
  if ( 0 === $this->current_blog ) {
336
+
337
+ /**
338
+ * Fires if on the first blog in the loop.
339
+ *
340
+ * @since BuddyPress (1.5.0)
341
+ */
342
  do_action( 'blog_loop_start' );
343
  }
344
  }
394
  function bp_has_blogs( $args = '' ) {
395
  global $blogs_template;
396
 
397
+ // Check for and use search terms
398
  $search_terms = ! empty( $_REQUEST['s'] )
399
  ? $_REQUEST['s']
400
  : false;
420
  // Get the blogs
421
  $blogs_template = new BP_Blogs_Template( $r['type'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['search_terms'], $r['page_arg'], $r['update_meta_cache'], $r['include_blog_ids'] );
422
 
423
+ /**
424
+ * Filters whether or not there are blogs to list.
425
+ *
426
+ * @since BuddyPress (1.1.0)
427
+ *
428
+ * @param bool $value Whether or not there are blogs to list.
429
+ * @param BP_Blogs_Template $blogs_template Current blogs template object.
430
+ * @param array $r Parsed arguments used in blogs template query.
431
+ */
432
  return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template, $r );
433
  }
434
 
490
  function bp_get_blogs_pagination_links() {
491
  global $blogs_template;
492
 
493
+ /**
494
+ * Filters the blogs pagination links.
495
+ *
496
+ * @since BuddyPress (1.0.0)
497
+ *
498
+ * @param string $pag_links HTML pagination links.
499
+ */
500
  return apply_filters( 'bp_get_blogs_pagination_links', $blogs_template->pag_links );
501
  }
502
 
578
  */
579
  $avatar = apply_filters( 'bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar );
580
 
581
+ /**
582
+ * Filters a blog's avatar.
583
+ *
584
+ * @since BuddyPress (1.5.0)
585
+ *
586
+ * @param string $avatar Formatted HTML <img> element, or raw avatar
587
+ * URL based on $html arg.
588
+ * @param int $blog_id ID of the blog whose avatar is being displayed.
589
+ * @param array $r Array of arguments used when fetching avatar.
590
+ */
591
  return apply_filters( 'bp_get_blog_avatar', $avatar, $blogs_template->blog->blog_id, $r );
592
  }
593
 
607
  $permalink = $protocol . $blogs_template->blog->domain . $blogs_template->blog->path;
608
  }
609
 
610
+ /**
611
+ * Filters the blog permalink.
612
+ *
613
+ * @since BuddyPress (1.0.0)
614
+ *
615
+ * @param string $permalink Permalink URL for the blog.
616
+ */
617
  return apply_filters( 'bp_get_blog_permalink', $permalink );
618
  }
619
 
631
  function bp_get_blog_name() {
632
  global $blogs_template;
633
 
634
+ /**
635
+ * Filters the name of the current blog in the loop.
636
+ *
637
+ * @since BuddyPress (1.2.0)
638
+ *
639
+ * @param string $name Name of the current blog in the loop.
640
+ */
641
  return apply_filters( 'bp_get_blog_name', $blogs_template->blog->name );
642
  }
643
 
659
  function bp_get_blog_id() {
660
  global $blogs_template;
661
 
662
+ /**
663
+ * Filters the ID of the current blog in the loop.
664
+ *
665
+ * @since BuddyPress (1.7.0)
666
+ *
667
+ * @param int $blog_id ID of the current blog in the loop.
668
+ */
669
  return apply_filters( 'bp_get_blog_id', $blogs_template->blog->blog_id );
670
  }
671
 
673
  * Output the description of the current blog in the loop.
674
  */
675
  function bp_blog_description() {
676
+
677
+ /**
678
+ * Filters the description of the current blog in the loop.
679
+ *
680
+ * @since BuddyPress (1.2.0)
681
+ *
682
+ * @param string $value Description of the current blog in the loop.
683
+ */
684
  echo apply_filters( 'bp_blog_description', bp_get_blog_description() );
685
  }
686
  /**
691
  function bp_get_blog_description() {
692
  global $blogs_template;
693
 
694
+ /**
695
+ * Filters the description of the current blog in the loop.
696
+ *
697
+ * @since BuddyPress (1.0.0)
698
+ *
699
+ * @param string $value Description of the current blog in the loop.
700
+ */
701
  return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description );
702
  }
703
 
730
  else
731
  $classes[] = 'bp-single-blog';
732
 
733
+ /**
734
+ * Filters the row class of the current blog in the loop.
735
+ *
736
+ * @since BuddyPress (1.7.0)
737
+ *
738
+ * @param array $classes Array of classes to be applied to row.
739
+ */
740
  $classes = apply_filters( 'bp_get_blog_class', $classes );
741
  $classes = array_merge( $classes, array() );
742
 
770
  'active_format' => true
771
  ) );
772
 
773
+ // Backwards compatibility for anyone forcing a 'true' active_format
774
  if ( true === $r['active_format'] ) {
775
  $r['active_format'] = __( 'active %s', 'buddypress' );
776
  }
788
  $last_activity = __( 'Never active', 'buddypress' );
789
  }
790
 
791
+ /**
792
+ * Filters the last active date of the current blog in the loop.
793
+ *
794
+ * @since
795
+ *
796
+ * @param string $last_activity Last active date.
797
+ * @param array $r Array of parsed args used to determine formatting.
798
+ */
799
  return apply_filters( 'bp_blog_last_active', $last_activity, $r );
800
  }
801
 
829
 
830
  if ( ! empty( $retval ) ) {
831
  if ( ! empty( $r['latest_format'] ) ) {
832
+
833
+ /**
834
+ * Filters the title text of the latest post for the current blog in loop.
835
+ *
836
+ * @since BuddyPress (1.0.0)
837
+ *
838
+ * @param string $retval Title of the latest post.
839
+ */
840
  $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
841
  } else {
842
+
843
+ /** This filter is documented in bp-blogs/bp-blogs-template.php */
844
  $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>';
845
  }
846
  }
847
 
848
+ /**
849
+ * Filters the HTML markup result for the latest blog post in loop.
850
+ *
851
+ * @since BuddyPress (1.2.0)
852
+ *
853
+ * @param string $retval HTML markup for the latest post.
854
+ */
855
  return apply_filters( 'bp_get_blog_latest_post', $retval );
856
  }
857
 
882
  if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->post_title ) )
883
  $retval = $blogs_template->blog->latest_post->post_title;
884
 
885
+ /**
886
+ * Filters the title text of the latest post on the current blog in the loop.
887
+ *
888
+ * @since BuddyPress (1.7.0)
889
+ *
890
+ * @param string $retval Title text for the latest post.
891
+ */
892
  return apply_filters( 'bp_get_blog_latest_post_title', $retval );
893
  }
894
 
919
  if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->ID ) )
920
  $retval = add_query_arg( 'p', $blogs_template->blog->latest_post->ID, bp_get_blog_permalink() );
921
 
922
+ /**
923
+ * Filters the permalink of the latest post on the current blog in the loop.
924
+ *
925
+ * @since BuddyPress (1.7.0)
926
+ *
927
+ * @param string $retval Permalink URL of the latest post.
928
+ */
929
  return apply_filters( 'bp_get_blog_latest_post_permalink', $retval );
930
  }
931
 
956
  if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->post_content ) )
957
  $retval = $blogs_template->blog->latest_post->post_content;
958
 
959
+ /**
960
+ * Filters the content of the latest post on the current blog in the loop.
961
+ *
962
+ * @since BuddyPress (1.7.0)
963
+ *
964
+ * @param string $retval Content of the latest post on the current blog in the loop.
965
+ */
966
  return apply_filters( 'bp_get_blog_latest_post_content', $retval );
967
  }
968
 
997
  if ( ! empty( $blogs_template->blog->latest_post ) && ! empty( $blogs_template->blog->latest_post->images[$size] ) )
998
  $retval = $blogs_template->blog->latest_post->images[$size];
999
 
1000
+ /**
1001
+ * Filters the featured image of the latest post on the current blog in the loop.
1002
+ *
1003
+ * @since BuddyPress (1.7.0)
1004
+ *
1005
+ * @param string $retval The featured image of the latest post on the current blog in the loop.
1006
+ */
1007
  return apply_filters( 'bp_get_blog_latest_post_featured_image', $retval );
1008
  }
1009
 
1020
  function bp_blog_latest_post_has_featured_image( $thumbnail = 'thumbnail' ) {
1021
  $image = bp_get_blog_latest_post_featured_image( $thumbnail );
1022
 
1023
+ /**
1024
+ * Filters whether or not the latest blog post has a featured image.
1025
+ *
1026
+ * @since BuddyPress (1.7.0)
1027
+ *
1028
+ * @param bool $value Whether or not the latest blog post has a featured image.
1029
+ * @param string $thumbnail Image version to return.
1030
+ * @param string $image Returned value from bp_get_blog_latest_post_featured_image.
1031
+ */
1032
  return apply_filters( 'bp_blog_latest_post_has_featured_image', ! empty( $image ), $thumbnail, $image );
1033
  }
1034
 
1062
  * @return int Total number of blogs.
1063
  */
1064
  function bp_get_total_blog_count() {
1065
+
1066
+ /**
1067
+ * Filters the total number of blogs on the site.
1068
+ *
1069
+ * @since BuddyPress (1.2.0)
1070
+ *
1071
+ * @param int $value Total number of blogs on the site.
1072
+ */
1073
  return apply_filters( 'bp_get_total_blog_count', bp_blogs_total_blogs() );
1074
  }
1075
  add_filter( 'bp_get_total_blog_count', 'bp_core_number_format' );
1089
  * @return int Total number of blogs for the user.
1090
  */
1091
  function bp_get_total_blog_count_for_user( $user_id = 0 ) {
1092
+
1093
+ /**
1094
+ * Filters the total number of blogs for a given user.
1095
+ *
1096
+ * @since BuddyPress (1.2.0)
1097
+ *
1098
+ * @param int $value Total number of blogs for a given user.
1099
+ */
1100
  return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) );
1101
  }
1102
  add_filter( 'bp_get_total_blog_count_for_user', 'bp_core_number_format' );
1117
 
1118
  $active_signup = isset( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : 'all';
1119
 
1120
+ /**
1121
+ * Filters whether or not blog creation is enabled.
1122
+ *
1123
+ * @since BuddyPress (1.0.0)
1124
+ *
1125
+ * @param string $active_signup Value of the registration site option creation status.
1126
+ */
1127
  $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
1128
 
1129
  if ( 'none' == $active_signup || 'user' == $active_signup )
1150
  $errors = new WP_Error();
1151
  }
1152
 
1153
+ /**
1154
+ * Filters the default values for Blog name, title, and any current errors.
1155
+ *
1156
+ * @since BuddyPress (1.0.0)
1157
+ *
1158
+ * @param array $value {
1159
+ * string $blogname Default blog name provided.
1160
+ * string $blog_title Default blog title provided.
1161
+ * WP_Error $errors WP_Error object.
1162
+ * }
1163
+ */
1164
  $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
1165
  $blogname = $filtered_results['blogname'];
1166
  $blog_title = $filtered_results['blog_title'];
1177
  <form class="standard-form" id="setupform" method="post" action="">
1178
 
1179
  <input type="hidden" name="stage" value="gimmeanotherblog" />
1180
+ <?php
1181
+
1182
+ /**
1183
+ * Fires after the default hidden fields in blog signup form markup.
1184
+ *
1185
+ * @since BuddyPress (1.0.0)
1186
+ */
1187
+ do_action( 'signup_hidden_fields' ); ?>
1188
 
1189
  <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
1190
  <p>
1223
  if ( !is_subdomain_install() )
1224
  echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span> <input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" /><br />';
1225
  else
1226
+ echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" ' . bp_get_form_field_attributes( 'blogname' ) . '/> <span class="suffix_address">.' . bp_blogs_get_subdomain_base() . '</span><br />';
1227
 
1228
  if ( !is_user_logged_in() ) {
1229
  print '(<strong>' . __( 'Your address will be ' , 'buddypress');
1265
  </p>
1266
 
1267
  <?php
1268
+
1269
+ /**
1270
+ * Fires at the end of all of the default input fields for blog creation form.
1271
+ *
1272
+ * @since BuddyPress (1.0.0)
1273
+ *
1274
+ * @param WP_Error $errors WP_Error object if any present.
1275
+ */
1276
  do_action('signup_blogform', $errors);
1277
  }
1278
 
1306
  $public = (int) $_POST['blog_public'];
1307
 
1308
  $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated
1309
+
1310
+ /**
1311
+ * Filters the default values for Blog meta.
1312
+ *
1313
+ * @since BuddyPress (1.0.0)
1314
+ *
1315
+ * @param array $meta {
1316
+ * string $value Default blog language ID.
1317
+ * string $public Default public status.
1318
+ * }
1319
+ */
1320
  $meta = apply_filters( 'add_signup_meta', $meta );
1321
 
1322
  // If this is a subdomain install, set up the site inside the root domain.
1363
  </p>
1364
 
1365
  <?php
1366
+
1367
+ /**
1368
+ * Fires after the default successful blog registration message markup.
1369
+ *
1370
+ * @since BuddyPress (1.0.0)
1371
+ */
1372
  do_action('signup_finished');
1373
  }
1374
 
1377
  */
1378
  function bp_create_blog_link() {
1379
  if ( bp_is_my_profile() )
1380
+
1381
+ /**
1382
+ * Filters "Create a Site" links for users viewing their own profiles.
1383
+ *
1384
+ * @since BuddyPress (1.0.0)
1385
+ *
1386
+ * @param string $value HTML link for creating a site.
1387
+ */
1388
  echo apply_filters( 'bp_create_blog_link', '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
1389
  }
1390
 
1408
  </ul>
1409
 
1410
  <?php
1411
+
1412
+ /**
1413
+ * Fires after the markup for the navigation tabs for a user Blogs page.
1414
+ *
1415
+ * @since BuddyPress (1.0.0)
1416
+ */
1417
  do_action( 'bp_blogs_blog_tabs' );
1418
  }
1419
 
1429
  <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
1430
  </form>';
1431
 
1432
+ /**
1433
+ * Filters the output for the blog directory search form.
1434
+ *
1435
+ * @since BuddyPress (1.9.0)
1436
+ *
1437
+ * @param string $search_form_html HTML markup for blog directory search form.
1438
+ */
1439
  echo apply_filters( 'bp_directory_blogs_search_form', $search_form_html );
1440
  }
1441
 
1468
  'component' => 'blogs',
1469
  'link_text' => __( 'Create a Site', 'buddypress' ),
1470
  'link_title' => __( 'Create a Site', 'buddypress' ),
1471
+ 'link_class' => 'blog-create no-ajax',
1472
  'link_href' => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_blogs_root_slug() ) . trailingslashit( 'create' ),
1473
  'wrapper' => false,
1474
+ 'block_self' => false,
1475
  );
1476
 
1477
+ /**
1478
+ * Filters the Create a Site button.
1479
+ *
1480
+ * @since BuddyPress (2.0.0)
1481
+ *
1482
+ * @param array $button_args Array of arguments to be used for the Create a Site button.
1483
+ */
1484
  return bp_get_button( apply_filters( 'bp_get_blog_create_button', $button_args ) );
1485
  }
1486
 
1487
+ /**
1488
+ * Output the Create a Site nav item.
1489
+ *
1490
+ * @since BuddyPress (2.2.0)
1491
+ */
1492
+ function bp_blog_create_nav_item() {
1493
+ echo bp_get_blog_create_nav_item();
1494
+ }
1495
+
1496
+ /**
1497
+ * Get the Create a Site nav item.
1498
+ *
1499
+ * @since BuddyPress (2.2.0)
1500
+ *
1501
+ * @return string
1502
+ */
1503
+ function bp_get_blog_create_nav_item() {
1504
+ // Get the create a site button
1505
+ $create_blog_button = bp_get_blog_create_button();
1506
+
1507
+ // Make sure the button is available
1508
+ if ( empty( $create_blog_button ) ) {
1509
+ return;
1510
+ }
1511
+
1512
+ $output = '<li id="blog-create-nav">' . $create_blog_button . '</li>';
1513
+
1514
+ return apply_filters( 'bp_get_blog_create_nav_item', $output );
1515
+ }
1516
+
1517
+ /**
1518
+ * Checks if a specific theme is still filtering the Blogs directory title
1519
+ * if so, transform the title button into a Blogs directory nav item.
1520
+ *
1521
+ * @since BuddyPress (2.2.0)
1522
+ *
1523
+ * @uses bp_blog_create_nav_item() to output the Create a Site nav item
1524
+ * @return string HTML Output
1525
+ */
1526
+ function bp_blog_backcompat_create_nav_item() {
1527
+ // Bail if Blogs nav item is already used by bp-legacy
1528
+ if ( has_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 ) ) {
1529
+ return;
1530
+ }
1531
+
1532
+ // Bail if the theme is not filtering the Blogs directory title
1533
+ if ( ! has_filter( 'bp_blogs_directory_header' ) ) {
1534
+ return;
1535
+ }
1536
+
1537
+ bp_blog_create_nav_item();
1538
+ }
1539
+ add_action( 'bp_blogs_directory_blog_types', 'bp_blog_backcompat_create_nav_item', 1000 );
1540
+
1541
  /**
1542
  * Output button for visiting a blog in a loop.
1543
  *
1584
 
1585
  $button = wp_parse_args( $args, $defaults );
1586
 
1587
+ /**
1588
+ * Filters the button for visiting a blog in a loop.
1589
+ *
1590
+ * @since BuddyPress (1.2.10)
1591
+ *
1592
+ * @param array $button Array of arguments to be used for the button to visit a blog.
1593
+ */
1594
  return bp_get_button( apply_filters( 'bp_get_blogs_visit_blog_button', $button ) );
1595
  }
1596
 
1644
  }
1645
  }
1646
 
1647
+ /**
1648
+ * Filters the number of blogs in user's profile.
1649
+ *
1650
+ * @since BuddyPress (2.0.0)
1651
+ *
1652
+ * @param string $value Output determined for the profile stats.
1653
+ * @param array $r Array of arguments used for default output if none provided.
1654
+ */
1655
  return apply_filters( 'bp_blogs_get_profile_stats', $r['output'], $r );
1656
  }
bp-blogs/bp-blogs-widgets.php CHANGED
@@ -53,6 +53,15 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
53
  $title = '<a href="' . trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_blogs_root_slug() ) . '">' . esc_html( $title ) . '</a>';
54
  }
55
 
 
 
 
 
 
 
 
 
 
56
  echo $args['before_widget'];
57
  echo $args['before_title'] . $title . $args['after_title'];
58
 
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
 
bp-core/admin/bp-core-functions.php CHANGED
@@ -74,11 +74,12 @@ add_action( bp_core_admin_hook(), 'bp_core_admin_backpat_menu', 999 );
74
  * @since BuddyPress (1.6)
75
  */
76
  function bp_core_modify_admin_menu_highlight() {
77
- global $pagenow, $plugin_page, $submenu_file;
78
 
79
  // This tweaks the Settings subnav menu to show only one BuddyPress menu item
80
- if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings', ) ) )
81
  $submenu_file = 'bp-components';
 
82
 
83
  // Network Admin > Tools
84
  if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ) ) ) {
@@ -118,7 +119,6 @@ function bp_core_admin_backpat_page() {
118
  * BuddyPress combines all its messages into a single notice, to avoid a preponderance of yellow
119
  * boxes.
120
  *
121
- * @package BuddyPress Core
122
  * @since BuddyPress (1.5)
123
  *
124
  * @uses bp_current_user_can() to check current user permissions before showing the notices
@@ -137,23 +137,22 @@ function bp_core_print_admin_notices() {
137
  return;
138
  }
139
 
140
- // Get the admin notices
141
- $admin_notices = buddypress()->admin->notices;
142
-
143
- // Show the messages
144
- if ( !empty( $admin_notices ) ) : ?>
145
-
146
- <div id="message" class="updated fade">
147
-
148
- <?php foreach ( $admin_notices as $notice ) : ?>
149
-
150
- <p><?php echo $notice; ?></p>
151
 
152
- <?php endforeach; ?>
 
 
153
 
154
- </div>
 
 
155
 
156
- <?php endif;
 
157
  }
158
  add_action( 'admin_notices', 'bp_core_print_admin_notices' );
159
  add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
@@ -165,12 +164,12 @@ add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
165
  * box. It is recommended that you hook this function to admin_init, so that your messages are
166
  * loaded in time.
167
  *
168
- * @package BuddyPress Core
169
  * @since BuddyPress (1.5)
170
  *
171
- * @param string $notice The notice you are adding to the queue
 
172
  */
173
- function bp_core_add_admin_notice( $notice = '' ) {
174
 
175
  // Do not add if the notice is empty
176
  if ( empty( $notice ) ) {
@@ -183,7 +182,10 @@ function bp_core_add_admin_notice( $notice = '' ) {
183
  }
184
 
185
  // Add the notice
186
- buddypress()->admin->notices[] = $notice;
 
 
 
187
  }
188
 
189
  /**
@@ -238,7 +240,7 @@ function bp_core_activation_notice() {
238
 
239
  // Add notice if no rewrite rules are enabled
240
  if ( empty( $wp_rewrite->permalink_structure ) ) {
241
- bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) );
242
  }
243
 
244
  // Get BuddyPress instance
@@ -274,7 +276,7 @@ function bp_core_activation_notice() {
274
  );
275
  }
276
 
277
- // On the first admin screen after a new installation, this isn't set, so grab it to supress a misleading error message.
278
  if ( empty( $bp->pages->members ) ) {
279
  $bp->pages = bp_core_get_directory_pages();
280
  }
@@ -341,15 +343,17 @@ function bp_core_activation_notice() {
341
  function bp_do_activation_redirect() {
342
 
343
  // Bail if no activation redirect
344
- if ( ! get_transient( '_bp_activation_redirect' ) )
345
  return;
 
346
 
347
  // Delete the redirect transient
348
  delete_transient( '_bp_activation_redirect' );
349
 
350
  // Bail if activating from network, or bulk
351
- if ( isset( $_GET['activate-multi'] ) )
352
  return;
 
353
 
354
  $query_args = array( 'page' => 'bp-about' );
355
  if ( get_transient( '_bp_is_new_install' ) ) {
@@ -367,16 +371,32 @@ function bp_do_activation_redirect() {
367
  * Output the tabs in the admin area
368
  *
369
  * @since BuddyPress (1.5)
370
- * @param string $active_tab Name of the tab that is active
371
  */
372
  function bp_core_admin_tabs( $active_tab = '' ) {
373
-
374
- // Declare local variables
375
  $tabs_html = '';
376
  $idle_class = 'nav-tab';
377
  $active_class = 'nav-tab nav-tab-active';
 
 
 
 
 
 
 
 
 
 
 
 
378
 
379
- // Setup core admin tabs
 
 
 
 
 
 
380
  $tabs = array(
381
  '0' => array(
382
  'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
@@ -405,21 +425,13 @@ function bp_core_admin_tabs( $active_tab = '' ) {
405
  );
406
  }
407
 
408
- // Allow the tabs to be filtered
409
- $tabs = apply_filters( 'bp_core_admin_tabs', $tabs );
410
-
411
- // Loop through tabs and build navigation
412
- foreach ( array_values( $tabs ) as $tab_data ) {
413
- $is_current = (bool) ( $tab_data['name'] == $active_tab );
414
- $tab_class = $is_current ? $active_class : $idle_class;
415
- $tabs_html .= '<a href="' . esc_url( $tab_data['href'] ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab_data['name'] ) . '</a>';
416
- }
417
-
418
- // Output the tabs
419
- echo $tabs_html;
420
-
421
- // Do other fun things
422
- do_action( 'bp_admin_tabs' );
423
  }
424
 
425
  /** Help **********************************************************************/
@@ -436,7 +448,7 @@ function bp_core_add_contextual_help( $screen = '' ) {
436
 
437
  switch ( $screen->id ) {
438
 
439
- // Compontent page
440
  case 'settings_page_bp-components' :
441
 
442
  // help tabs
@@ -563,21 +575,25 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
563
  function bp_admin_separator() {
564
 
565
  // Bail if BuddyPress is not network activated and viewing network admin
566
- if ( is_network_admin() && ! bp_is_network_activated() )
567
  return;
 
568
 
569
  // Bail if BuddyPress is network activated and viewing site admin
570
- if ( ! is_network_admin() && bp_is_network_activated() )
571
  return;
 
572
 
573
  // Prevent duplicate separators when no core menu items exist
574
- if ( ! bp_current_user_can( 'bp_moderate' ) )
575
  return;
 
576
 
577
  // Bail if there are no components with admin UI's. Hardcoded for now, until
578
  // there's a real API for determining this later.
579
- if ( ! bp_is_active( 'activity' ) && ! bp_is_active( 'groups' ) )
580
  return;
 
581
 
582
  global $menu;
583
 
@@ -596,8 +612,9 @@ function bp_admin_separator() {
596
  function bp_admin_custom_menu_order( $menu_order = false ) {
597
 
598
  // Bail if user cannot see admin pages
599
- if ( ! bp_current_user_can( 'bp_moderate' ) )
600
  return $menu_order;
 
601
 
602
  return true;
603
  }
@@ -614,8 +631,9 @@ function bp_admin_custom_menu_order( $menu_order = false ) {
614
  function bp_admin_menu_order( $menu_order = array() ) {
615
 
616
  // Bail if user cannot see admin pages
617
- if ( empty( $menu_order ) || ! bp_current_user_can( 'bp_moderate' ) )
618
  return $menu_order;
 
619
 
620
  // Initialize our custom order array
621
  $bp_menu_order = array();
@@ -627,8 +645,9 @@ function bp_admin_menu_order( $menu_order = array() ) {
627
  $custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() );
628
 
629
  // Bail if no components have top level admin pages
630
- if ( empty( $custom_menus ) )
631
  return $menu_order;
 
632
 
633
  // Add our separator to beginning of array
634
  array_unshift( $custom_menus, 'separator-buddypress' );
74
  * @since BuddyPress (1.6)
75
  */
76
  function bp_core_modify_admin_menu_highlight() {
77
+ global $plugin_page, $submenu_file;
78
 
79
  // This tweaks the Settings subnav menu to show only one BuddyPress menu item
80
+ if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings', ) ) ) {
81
  $submenu_file = 'bp-components';
82
+ }
83
 
84
  // Network Admin > Tools
85
  if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ) ) ) {
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
137
  return;
138
  }
139
 
140
+ $notice_types = array();
141
+ foreach ( buddypress()->admin->notices as $notice ) {
142
+ $notice_types[] = $notice['type'];
143
+ }
144
+ $notice_types = array_unique( $notice_types );
 
 
 
 
 
 
145
 
146
+ foreach ( $notice_types as $type ) {
147
+ $notices = wp_list_filter( buddypress()->admin->notices, array( 'type' => $type ) );
148
+ printf( '<div id="message" class="fade %s">', sanitize_html_class( $type ) );
149
 
150
+ foreach ( $notices as $notice ) {
151
+ printf( '<p>%s</p>', $notice['message'] );
152
+ }
153
 
154
+ printf( '</div>' );
155
+ }
156
  }
157
  add_action( 'admin_notices', 'bp_core_print_admin_notices' );
158
  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)
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".
171
  */
172
+ function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) {
173
 
174
  // Do not add if the notice is empty
175
  if ( empty( $notice ) ) {
182
  }
183
 
184
  // Add the notice
185
+ buddypress()->admin->notices[] = array(
186
+ 'message' => $notice,
187
+ 'type' => $type,
188
+ );
189
  }
190
 
191
  /**
240
 
241
  // Add notice if no rewrite rules are enabled
242
  if ( empty( $wp_rewrite->permalink_structure ) ) {
243
+ bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ), 'error' );
244
  }
245
 
246
  // Get BuddyPress instance
276
  );
277
  }
278
 
279
+ // On the first admin screen after a new installation, this isn't set, so grab it to suppress a misleading error message.
280
  if ( empty( $bp->pages->members ) ) {
281
  $bp->pages = bp_core_get_directory_pages();
282
  }
343
  function bp_do_activation_redirect() {
344
 
345
  // Bail if no activation redirect
346
+ if ( ! get_transient( '_bp_activation_redirect' ) ) {
347
  return;
348
+ }
349
 
350
  // Delete the redirect transient
351
  delete_transient( '_bp_activation_redirect' );
352
 
353
  // Bail if activating from network, or bulk
354
+ if ( isset( $_GET['activate-multi'] ) ) {
355
  return;
356
+ }
357
 
358
  $query_args = array( 'page' => 'bp-about' );
359
  if ( get_transient( '_bp_is_new_install' ) ) {
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
383
+ foreach ( array_values( $tabs ) as $tab_data ) {
384
+ $is_current = (bool) ( $tab_data['name'] == $active_tab );
385
+ $tab_class = $is_current ? $active_class : $idle_class;
386
+ $tabs_html .= '<a href="' . esc_url( $tab_data['href'] ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab_data['name'] ) . '</a>';
387
+ }
388
+
389
+ echo $tabs_html;
390
+ do_action( 'bp_admin_tabs' );
391
+ }
392
 
393
+ /**
394
+ * Get the data for the tabs in the admin area.
395
+ *
396
+ * @since BuddyPress (2.2.0)
397
+ * @param string $active_tab Name of the tab that is active. Optional.
398
+ */
399
+ function bp_core_get_admin_tabs( $active_tab = '' ) {
400
  $tabs = array(
401
  '0' => array(
402
  'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
425
  );
426
  }
427
 
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
  }
436
 
437
  /** Help **********************************************************************/
448
 
449
  switch ( $screen->id ) {
450
 
451
+ // Component page
452
  case 'settings_page_bp-components' :
453
 
454
  // help tabs
575
  function bp_admin_separator() {
576
 
577
  // Bail if BuddyPress is not network activated and viewing network admin
578
+ if ( is_network_admin() && ! bp_is_network_activated() ) {
579
  return;
580
+ }
581
 
582
  // Bail if BuddyPress is network activated and viewing site admin
583
+ if ( ! is_network_admin() && bp_is_network_activated() ) {
584
  return;
585
+ }
586
 
587
  // Prevent duplicate separators when no core menu items exist
588
+ if ( ! bp_current_user_can( 'bp_moderate' ) ) {
589
  return;
590
+ }
591
 
592
  // Bail if there are no components with admin UI's. Hardcoded for now, until
593
  // there's a real API for determining this later.
594
+ if ( ! bp_is_active( 'activity' ) && ! bp_is_active( 'groups' ) ) {
595
  return;
596
+ }
597
 
598
  global $menu;
599
 
612
  function bp_admin_custom_menu_order( $menu_order = false ) {
613
 
614
  // Bail if user cannot see admin pages
615
+ if ( ! bp_current_user_can( 'bp_moderate' ) ) {
616
  return $menu_order;
617
+ }
618
 
619
  return true;
620
  }
631
  function bp_admin_menu_order( $menu_order = array() ) {
632
 
633
  // Bail if user cannot see admin pages
634
+ if ( empty( $menu_order ) || ! bp_current_user_can( 'bp_moderate' ) ) {
635
  return $menu_order;
636
+ }
637
 
638
  // Initialize our custom order array
639
  $bp_menu_order = array();
645
  $custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() );
646
 
647
  // Bail if no components have top level admin pages
648
+ if ( empty( $custom_menus ) ) {
649
  return $menu_order;
650
+ }
651
 
652
  // Add our separator to beginning of array
653
  array_unshift( $custom_menus, 'separator-buddypress' );
bp-core/admin/bp-core-schema.php CHANGED
@@ -84,7 +84,7 @@ function bp_core_install( $active_components = false ) {
84
  * Install database tables for the Notifications component
85
  *
86
  * @since BuddyPress (1.0.0)
87
- *
88
  * @uses bp_core_set_charset()
89
  * @uses bp_core_get_table_prefix()
90
  * @uses dbDelta()
@@ -119,7 +119,7 @@ function bp_core_install_notifications() {
119
  * Install database tables for the Activity component
120
  *
121
  * @since BuddyPress (1.0.0)
122
- *
123
  * @uses bp_core_set_charset()
124
  * @uses bp_core_get_table_prefix()
125
  * @uses dbDelta()
@@ -136,7 +136,7 @@ function bp_core_install_activity_streams() {
136
  type varchar(75) NOT NULL,
137
  action text NOT NULL,
138
  content longtext NOT NULL,
139
- primary_link varchar(255) NOT NULL,
140
  item_id bigint(20) NOT NULL,
141
  secondary_item_id bigint(20) DEFAULT NULL,
142
  date_recorded datetime NOT NULL,
@@ -172,7 +172,7 @@ function bp_core_install_activity_streams() {
172
  * Install database tables for the Notifications component
173
  *
174
  * @since BuddyPress (1.0.0)
175
- *
176
  * @uses bp_core_set_charset()
177
  * @uses bp_core_get_table_prefix()
178
  * @uses dbDelta()
@@ -200,7 +200,7 @@ function bp_core_install_friends() {
200
  * Install database tables for the Groups component
201
  *
202
  * @since BuddyPress (1.0.0)
203
- *
204
  * @uses bp_core_set_charset()
205
  * @uses bp_core_get_table_prefix()
206
  * @uses dbDelta()
@@ -257,10 +257,10 @@ function bp_core_install_groups() {
257
  }
258
 
259
  /**
260
- * Install database tables for the Messsages component
261
  *
262
  * @since BuddyPress (1.0.0)
263
- *
264
  * @uses bp_core_set_charset()
265
  * @uses bp_core_get_table_prefix()
266
  * @uses dbDelta()
@@ -304,6 +304,15 @@ function bp_core_install_private_messaging() {
304
  KEY is_active (is_active)
305
  ) {$charset_collate};";
306
 
 
 
 
 
 
 
 
 
 
307
  dbDelta( $sql );
308
  }
309
 
@@ -311,7 +320,7 @@ function bp_core_install_private_messaging() {
311
  * Install database tables for the Profiles component
312
  *
313
  * @since BuddyPress (1.0.0)
314
- *
315
  * @uses bp_core_set_charset()
316
  * @uses bp_core_get_table_prefix()
317
  * @uses dbDelta()
@@ -401,7 +410,7 @@ function bp_core_install_extended_profiles() {
401
  * Install database tables for the Sites component
402
  *
403
  * @since BuddyPress (1.0.0)
404
- *
405
  * @uses bp_core_set_charset()
406
  * @uses bp_core_get_table_prefix()
407
  * @uses dbDelta()
84
  * Install database tables for the Notifications component
85
  *
86
  * @since BuddyPress (1.0.0)
87
+ *
88
  * @uses bp_core_set_charset()
89
  * @uses bp_core_get_table_prefix()
90
  * @uses dbDelta()
119
  * Install database tables for the Activity component
120
  *
121
  * @since BuddyPress (1.0.0)
122
+ *
123
  * @uses bp_core_set_charset()
124
  * @uses bp_core_get_table_prefix()
125
  * @uses dbDelta()
136
  type varchar(75) NOT NULL,
137
  action text NOT NULL,
138
  content longtext NOT NULL,
139
+ primary_link text NOT NULL,
140
  item_id bigint(20) NOT NULL,
141
  secondary_item_id bigint(20) DEFAULT NULL,
142
  date_recorded datetime NOT NULL,
172
  * Install database tables for the Notifications component
173
  *
174
  * @since BuddyPress (1.0.0)
175
+ *
176
  * @uses bp_core_set_charset()
177
  * @uses bp_core_get_table_prefix()
178
  * @uses dbDelta()
200
  * Install database tables for the Groups component
201
  *
202
  * @since BuddyPress (1.0.0)
203
+ *
204
  * @uses bp_core_set_charset()
205
  * @uses bp_core_get_table_prefix()
206
  * @uses dbDelta()
257
  }
258
 
259
  /**
260
+ * Install database tables for the Messages component
261
  *
262
  * @since BuddyPress (1.0.0)
263
+ *
264
  * @uses bp_core_set_charset()
265
  * @uses bp_core_get_table_prefix()
266
  * @uses dbDelta()
304
  KEY is_active (is_active)
305
  ) {$charset_collate};";
306
 
307
+ $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_meta (
308
+ id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
309
+ message_id bigint(20) NOT NULL,
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 );
317
  }
318
 
320
  * Install database tables for the Profiles component
321
  *
322
  * @since BuddyPress (1.0.0)
323
+ *
324
  * @uses bp_core_set_charset()
325
  * @uses bp_core_get_table_prefix()
326
  * @uses dbDelta()
410
  * Install database tables for the Sites component
411
  *
412
  * @since BuddyPress (1.0.0)
413
+ *
414
  * @uses bp_core_set_charset()
415
  * @uses bp_core_get_table_prefix()
416
  * @uses dbDelta()
bp-core/admin/bp-core-slugs.php CHANGED
@@ -101,9 +101,6 @@ function bp_core_admin_slugs_options() {
101
  'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
102
  ) ); ?>
103
 
104
- <a href="<?php echo admin_url( add_query_arg( array( 'post_type' => 'page' ), 'post-new.php' ) ); ?>" class="button-secondary"><?php _e( 'New Page', 'buddypress' ); ?></a>
105
- <input class="button-primary" type="submit" name="bp-admin-pages-single" value="<?php esc_attr_e( 'Save', 'buddypress' ) ?>" />
106
-
107
  <?php if ( !empty( $existing_pages[$name] ) ) : ?>
108
 
109
  <a href="<?php echo get_permalink( $existing_pages[$name] ); ?>" class="button-secondary" target="_bp"><?php _e( 'View', 'buddypress' ); ?></a>
@@ -164,9 +161,6 @@ function bp_core_admin_slugs_options() {
164
  'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
165
  ) ) ?>
166
 
167
- <a href="<?php echo admin_url( add_query_arg( array( 'post_type' => 'page' ), 'post-new.php' ) ); ?>" class="button-secondary"><?php _e( 'New Page', 'buddypress' ); ?></a>
168
- <input class="button-primary" type="submit" name="bp-admin-pages-single" value="<?php esc_attr_e( 'Save', 'buddypress' ) ?>" />
169
-
170
  <?php if ( !empty( $existing_pages[$name] ) ) : ?>
171
 
172
  <a href="<?php echo get_permalink( $existing_pages[$name] ); ?>" class="button-secondary" target="_bp"><?php _e( 'View', 'buddypress' ); ?></a>
@@ -197,7 +191,7 @@ function bp_core_admin_slugs_options() {
197
  */
198
  function bp_core_admin_slugs_setup_handler() {
199
 
200
- if ( isset( $_POST['bp-admin-pages-submit'] ) || isset( $_POST['bp-admin-pages-single'] ) ) {
201
  if ( !check_admin_referer( 'bp-admin-pages-setup' ) )
202
  return false;
203
 
101
  'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
102
  ) ); ?>
103
 
 
 
 
104
  <?php if ( !empty( $existing_pages[$name] ) ) : ?>
105
 
106
  <a href="<?php echo get_permalink( $existing_pages[$name] ); ?>" class="button-secondary" target="_bp"><?php _e( 'View', 'buddypress' ); ?></a>
161
  'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
162
  ) ) ?>
163
 
 
 
 
164
  <?php if ( !empty( $existing_pages[$name] ) ) : ?>
165
 
166
  <a href="<?php echo get_permalink( $existing_pages[$name] ); ?>" class="button-secondary" target="_bp"><?php _e( 'View', 'buddypress' ); ?></a>
191
  */
192
  function bp_core_admin_slugs_setup_handler() {
193
 
194
+ if ( isset( $_POST['bp-admin-pages-submit'] ) ) {
195
  if ( !check_admin_referer( 'bp-admin-pages-setup' ) )
196
  return false;
197
 
bp-core/admin/bp-core-tools.php CHANGED
@@ -257,7 +257,7 @@ function bp_admin_repair_group_count() {
257
  */
258
  function bp_admin_repair_blog_records() {
259
 
260
- // Description of this tool, dispalyed to the user
261
  $statement = __( 'Repopulating Blogs records&hellip; %s', 'buddypress' );
262
 
263
  // Default to failure text
257
  */
258
  function bp_admin_repair_blog_records() {
259
 
260
+ // Description of this tool, displayed to the user
261
  $statement = __( 'Repopulating Blogs records&hellip; %s', 'buddypress' );
262
 
263
  // Default to failure text
bp-core/admin/css/common-rtl.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  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}}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  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.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  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}}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  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/bp-core-actions.php CHANGED
@@ -53,6 +53,7 @@ add_action( 'generate_rewrite_rules', 'bp_generate_rewrite_rules', 10 );
53
  */
54
  add_action( 'bp_loaded', 'bp_setup_components', 2 );
55
  add_action( 'bp_loaded', 'bp_include', 4 );
 
56
  add_action( 'bp_loaded', 'bp_setup_widgets', 6 );
57
  add_action( 'bp_loaded', 'bp_register_theme_packages', 12 );
58
  add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
@@ -65,6 +66,7 @@ add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
65
  * v---Load order
66
  */
67
  add_action( 'bp_init', 'bp_core_set_uri_globals', 2 );
 
68
  add_action( 'bp_init', 'bp_setup_globals', 4 );
69
  add_action( 'bp_init', 'bp_setup_canonical_stack', 5 );
70
  add_action( 'bp_init', 'bp_setup_nav', 6 );
53
  */
54
  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_theme_packages', 12 );
59
  add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
66
  * v---Load order
67
  */
68
  add_action( 'bp_init', 'bp_core_set_uri_globals', 2 );
69
+ add_action( 'bp_init', 'bp_register_taxonomies', 3 );
70
  add_action( 'bp_init', 'bp_setup_globals', 4 );
71
  add_action( 'bp_init', 'bp_setup_canonical_stack', 5 );
72
  add_action( 'bp_init', 'bp_setup_nav', 6 );
bp-core/bp-core-admin.php CHANGED
@@ -486,11 +486,8 @@ class BP_Admin {
486
  * @since BuddyPress (1.7.0)
487
  */
488
  public function about_screen() {
489
- global $wp_rewrite;
490
-
491
- $is_new_install = ! empty( $_GET['is_new_install'] );
492
- $pretty_permalinks_enabled = ! empty( $wp_rewrite->permalink_structure );
493
- list( $display_version ) = explode( '-', bp_get_version() ); ?>
494
 
495
  <div class="wrap about-wrap">
496
  <h1><?php printf( __( 'Welcome to BuddyPress %s', 'buddypress' ), $display_version ); ?></h1>
486
  * @since BuddyPress (1.7.0)
487
  */
488
  public function about_screen() {
489
+ $is_new_install = ! empty( $_GET['is_new_install'] );
490
+ list( $display_version ) = explode( '-', bp_get_version() ); ?>
 
 
 
491
 
492
  <div class="wrap about-wrap">
493
  <h1><?php printf( __( 'Welcome to BuddyPress %s', 'buddypress' ), $display_version ); ?></h1>
bp-core/bp-core-adminbar.php CHANGED
@@ -96,7 +96,7 @@ function bp_core_load_admin_bar() {
96
  add_action( 'init', 'bp_core_load_admin_bar', 9 );
97
 
98
  /**
99
- * Handle the enqueuing of toolbar CSS.
100
  *
101
  * This function exists mostly for backwards compatibility reasons, so anyone
102
  * previously unhooking this function can continue to do so. It's hooked to
96
  add_action( 'init', 'bp_core_load_admin_bar', 9 );
97
 
98
  /**
99
+ * Handle the enqueueing of toolbar CSS.
100
  *
101
  * This function exists mostly for backwards compatibility reasons, so anyone
102
  * previously unhooking this function can continue to do so. It's hooked to
bp-core/bp-core-avatars.php CHANGED
@@ -174,184 +174,185 @@ add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
174
  * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg.
175
  */
176
  function bp_core_fetch_avatar( $args = '' ) {
 
177
 
178
  // If avatars are disabled for the root site, obey that request and bail
179
- if ( ! buddypress()->avatar->show_avatars )
180
  return;
 
181
 
182
  global $current_blog;
183
 
184
- $bp = buddypress();
185
-
186
- // Set a few default variables
187
- $def_object = 'user';
188
- $def_type = 'thumb';
189
- $def_class = 'avatar';
190
-
191
- // Set the default variables array
192
  $params = wp_parse_args( $args, array(
193
  'item_id' => false,
194
- 'object' => $def_object, // user/group/blog/custom type (if you use filters)
195
- 'type' => $def_type, // thumb or full
196
- 'avatar_dir' => false, // Specify a custom avatar directory for your object
197
- 'width' => false, // Custom width (int)
198
- 'height' => false, // Custom height (int)
199
- 'class' => $def_class, // Custom <img> class (string)
200
- 'css_id' => false, // Custom <img> ID (string)
201
- 'alt' => '', // Custom <img> alt (string)
202
- 'email' => false, // Pass the user email (for gravatar) to prevent querying the DB for it
203
- 'no_grav' => false, // If there is no avatar found, return false instead of a grav?
204
- 'html' => true, // Wrap the return img URL in <img />
205
- 'title' => '' // Custom <img> title (string)
206
  ) );
207
- extract( $params, EXTR_SKIP );
208
 
209
  /** Set item_id ***********************************************************/
210
 
211
- if ( empty( $item_id ) ) {
212
 
213
- switch ( $object ) {
214
 
215
  case 'blog' :
216
- $item_id = $current_blog->id;
217
  break;
218
 
219
  case 'group' :
220
  if ( bp_is_active( 'groups' ) ) {
221
- $item_id = $bp->groups->current_group->id;
222
  } else {
223
- $item_id = false;
224
  }
225
 
226
  break;
227
 
228
  case 'user' :
229
  default :
230
- $item_id = bp_displayed_user_id();
231
  break;
232
  }
233
 
234
- $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object, $params );
235
 
236
- if ( empty( $item_id ) ) {
237
  return false;
238
  }
239
  }
240
 
241
- $class = apply_filters( 'bp_core_avatar_class', $class, $item_id, $object, $params );
242
-
243
  /** Set avatar_dir ********************************************************/
244
 
245
- if ( empty( $avatar_dir ) ) {
246
 
247
- switch ( $object ) {
248
 
249
  case 'blog' :
250
- $avatar_dir = 'blog-avatars';
251
  break;
252
 
253
  case 'group' :
254
  if ( bp_is_active( 'groups' ) ) {
255
- $avatar_dir = 'group-avatars';
256
  } else {
257
- $avatar_dir = false;
258
  }
259
 
260
  break;
261
 
262
  case 'user' :
263
  default :
264
- $avatar_dir = 'avatars';
265
  break;
266
  }
267
 
268
- $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object, $params );
269
 
270
- if ( empty( $avatar_dir ) ) {
271
  return false;
272
  }
273
  }
274
 
275
  /** <img> alt *************************************************************/
276
 
277
- if ( false !== strpos( $alt, '%s' ) || false !== strpos( $alt, '%1$s' ) ) {
278
 
279
- switch ( $object ) {
280
 
281
  case 'blog' :
282
- $item_name = get_blog_option( $item_id, 'blogname' );
283
  break;
284
 
285
  case 'group' :
286
- $item_name = bp_get_group_name( groups_get_group( array( 'group_id' => $item_id ) ) );
287
  break;
288
 
289
  case 'user' :
290
  default :
291
- $item_name = bp_core_get_user_displayname( $item_id );
292
  break;
293
  }
294
 
295
- $item_name = apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object, $params );
296
- $alt = sprintf( $alt, $item_name );
297
  }
298
 
299
  /** Sanity Checks *********************************************************/
300
 
301
- // Get a fallback for the 'alt' parameter
302
- if ( empty( $alt ) )
303
- $alt = __( 'Profile Photo', 'buddypress' );
 
 
304
 
305
- $html_alt = ' alt="' . esc_attr( $alt ) . '"';
 
 
306
 
307
- // Set title tag, if it's been provided
308
- if ( !empty( $title ) ) {
309
- $title = " title='" . esc_attr( apply_filters( 'bp_core_avatar_title', $title, $item_id, $object, $params ) ) . "'";
310
  }
311
 
312
- // Set CSS ID if passed
313
- if ( !empty( $css_id ) ) {
314
- $css_id = ' id="' . esc_attr( $css_id ) . '"';
 
 
 
315
  }
316
 
317
  // Set image width
318
- if ( false !== $width ) {
319
- $html_width = ' width="' . $width . '"';
320
- } elseif ( 'thumb' == $type ) {
321
- $html_width = ' width="' . bp_core_avatar_thumb_width() . '"';
322
  } else {
323
- $html_width = ' width="' . bp_core_avatar_full_width() . '"';
324
  }
 
325
 
326
  // Set image height
327
- if ( false !== $height ) {
328
- $html_height = ' height="' . $height . '"';
329
- } elseif ( 'thumb' == $type ) {
330
- $html_height = ' height="' . bp_core_avatar_thumb_height() . '"';
331
  } else {
332
- $html_height = ' height="' . bp_core_avatar_full_height() . '"';
333
  }
 
 
 
 
 
334
 
335
  // Set img URL and DIR based on prepopulated constants
336
  $avatar_loc = new stdClass();
337
  $avatar_loc->path = trailingslashit( bp_core_avatar_upload_path() );
338
  $avatar_loc->url = trailingslashit( bp_core_avatar_url() );
339
 
340
- $avatar_loc->dir = trailingslashit( $avatar_dir );
341
- $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', ( $avatar_loc->url . $avatar_loc->dir . $item_id ), $item_id, $object, $avatar_dir );
342
- $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', ( $avatar_loc->path . $avatar_loc->dir . $item_id ), $item_id, $object, $avatar_dir );
343
-
344
- // Add an identifying class
345
- $class .= ' ' . $object . '-' . $item_id . '-avatar ' . sanitize_html_class( "avatar-$width" ) . ' photo';
346
 
347
  /**
348
  * Look for uploaded avatar first. Use it if it exists.
349
  * Set the file names to search for, to select the full size
350
  * or thumbnail image.
351
  */
352
- $avatar_size = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';
353
- $legacy_user_avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1';
354
- $legacy_group_avatar_name = ( 'full' == $type ) ? '-groupavatar-full' : '-groupavatar-thumb';
355
 
356
  // Check for directory
357
  if ( file_exists( $avatar_folder_dir ) ) {
@@ -405,8 +406,8 @@ function bp_core_fetch_avatar( $args = '' ) {
405
  if ( isset( $avatar_url ) ) {
406
 
407
  // Return it wrapped in an <img> element
408
- if ( true === $html ) {
409
- return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" class="' . esc_attr( $class ) . '"' . $css_id . $html_width . $html_height . $html_alt . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
410
 
411
  // ...or only the URL
412
  } else {
@@ -417,33 +418,24 @@ function bp_core_fetch_avatar( $args = '' ) {
417
 
418
  // If no avatars could be found, try to display a gravatar
419
 
420
- // Skips gravatar check if $no_grav is passed
421
- if ( ! apply_filters( 'bp_core_fetch_avatar_no_grav', $no_grav ) ) {
422
-
423
- // Set gravatar size
424
- if ( false !== $width ) {
425
- $grav_size = $width;
426
- } else if ( 'full' == $type ) {
427
- $grav_size = bp_core_avatar_full_width();
428
- } else if ( 'thumb' == $type ) {
429
- $grav_size = bp_core_avatar_thumb_width();
430
- }
431
 
432
  // Set gravatar type
433
- if ( empty( $bp->grav_default->{$object} ) ) {
434
  $default_grav = 'wavatar';
435
- } else if ( 'mystery' == $bp->grav_default->{$object} ) {
436
- $default_grav = apply_filters( 'bp_core_mysteryman_src', 'mm', $grav_size );
437
  } else {
438
- $default_grav = $bp->grav_default->{$object};
439
  }
440
 
441
  // Set gravatar object
442
- if ( empty( $email ) ) {
443
- if ( 'user' == $object ) {
444
- $email = bp_core_get_user_email( $item_id );
445
- } else if ( 'group' == $object || 'blog' == $object ) {
446
- $email = "{$item_id}-{$object}@{bp_get_root_domain()}";
447
  }
448
  }
449
 
@@ -454,8 +446,8 @@ function bp_core_fetch_avatar( $args = '' ) {
454
  }
455
 
456
  // Filter gravatar vars
457
- $email = apply_filters( 'bp_core_gravatar_email', $email, $item_id, $object );
458
- $gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $email ) ) . '?d=' . $default_grav . '&amp;s=' . $grav_size;
459
 
460
  // Gravatar rating; http://bit.ly/89QxZA
461
  $rating = get_option( 'avatar_rating' );
@@ -465,11 +457,11 @@ function bp_core_fetch_avatar( $args = '' ) {
465
 
466
  // No avatar was found, and we've been told not to use a gravatar.
467
  } else {
468
- $gravatar = apply_filters( "bp_core_default_avatar_$object", bp_core_avatar_default( 'local' ), $params );
469
  }
470
 
471
- if ( true === $html ) {
472
- return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '" class="' . esc_attr( $class ) . '"' . $css_id . $html_width . $html_height . $html_alt . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
473
  } else {
474
  return apply_filters( 'bp_core_fetch_avatar_url', $gravatar, $params );
475
  }
@@ -504,9 +496,9 @@ function bp_core_delete_existing_avatar( $args = '' ) {
504
  if ( empty( $item_id ) ) {
505
  if ( 'user' == $object )
506
  $item_id = bp_displayed_user_id();
507
- else if ( 'group' == $object )
508
  $item_id = buddypress()->groups->current_group->id;
509
- else if ( 'blog' == $object )
510
  $item_id = $current_blog->id;
511
 
512
  $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
@@ -517,9 +509,9 @@ function bp_core_delete_existing_avatar( $args = '' ) {
517
  if ( empty( $avatar_dir ) ) {
518
  if ( 'user' == $object )
519
  $avatar_dir = 'avatars';
520
- else if ( 'group' == $object )
521
  $avatar_dir = 'group-avatars';
522
- else if ( 'blog' == $object )
523
  $avatar_dir = 'blog-avatars';
524
 
525
  $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
@@ -584,7 +576,7 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
584
  );
585
 
586
  if ( ! bp_core_check_avatar_upload( $file ) ) {
587
- bp_core_add_message( sprintf( __( 'Your upload failed, please try again. Error was: %s', 'buddypress' ), $uploadErrors[$file['file']['error']] ), 'error' );
588
  return false;
589
  }
590
 
@@ -705,7 +697,7 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
705
  * @type string $avatar_dir Subdirectory where avatar should be stored.
706
  * Default: 'avatars'.
707
  * @type bool|int $item_id ID of the item that the avatar belongs to.
708
- * @type bool|string $original_file Absolute papth to the original avatar
709
  * file.
710
  * @type int $crop_w Crop width. Default: the global 'full' avatar width,
711
  * as retrieved by bp_core_avatar_full_width().
@@ -838,7 +830,7 @@ function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = ''
838
  }
839
 
840
  // If passed a number, assume it was a $user_id
841
- } else if ( is_numeric( $user ) ) {
842
  $id = $user;
843
 
844
  // If passed a string and that string returns a user, get the $id
@@ -1152,7 +1144,7 @@ function bp_core_avatar_default( $type = 'gravatar' ) {
1152
  $avatar = BP_AVATAR_DEFAULT;
1153
 
1154
  // Use the local default image
1155
- } else if ( 'local' === $type ) {
1156
  $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man.jpg';
1157
 
1158
  // Use Gravatar's mystery man as fallback
@@ -1188,7 +1180,7 @@ function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
1188
  $avatar = BP_AVATAR_DEFAULT_THUMB;
1189
 
1190
  // Use the local default image
1191
- } else if ( 'local' === $type ) {
1192
  $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man-50.jpg';
1193
 
1194
  // Use Gravatar's mystery man as fallback
@@ -1204,3 +1196,46 @@ function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
1204
 
1205
  return apply_filters( 'bp_core_avatar_thumb', $avatar );
1206
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg.
175
  */
176
  function bp_core_fetch_avatar( $args = '' ) {
177
+ $bp = buddypress();
178
 
179
  // If avatars are disabled for the root site, obey that request and bail
180
+ if ( ! $bp->avatar->show_avatars ) {
181
  return;
182
+ }
183
 
184
  global $current_blog;
185
 
186
+ // Set the default variables array and parse it against incoming $args array.
 
 
 
 
 
 
 
187
  $params = wp_parse_args( $args, array(
188
  'item_id' => false,
189
+ 'object' => 'user',
190
+ 'type' => 'thumb',
191
+ 'avatar_dir' => false,
192
+ 'width' => false,
193
+ 'height' => false,
194
+ 'class' => 'avatar',
195
+ 'css_id' => false,
196
+ 'alt' => '',
197
+ 'email' => false,
198
+ 'no_grav' => false,
199
+ 'html' => true,
200
+ 'title' => '',
201
  ) );
 
202
 
203
  /** Set item_id ***********************************************************/
204
 
205
+ if ( empty( $params['item_id'] ) ) {
206
 
207
+ switch ( $params['object'] ) {
208
 
209
  case 'blog' :
210
+ $params['item_id'] = $current_blog->id;
211
  break;
212
 
213
  case 'group' :
214
  if ( bp_is_active( 'groups' ) ) {
215
+ $params['item_id'] = $bp->groups->current_group->id;
216
  } else {
217
+ $params['item_id'] = false;
218
  }
219
 
220
  break;
221
 
222
  case 'user' :
223
  default :
224
+ $params['item_id'] = bp_displayed_user_id();
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'] ) ) {
231
  return false;
232
  }
233
  }
234
 
 
 
235
  /** Set avatar_dir ********************************************************/
236
 
237
+ if ( empty( $params['avatar_dir'] ) ) {
238
 
239
+ switch ( $params['object'] ) {
240
 
241
  case 'blog' :
242
+ $params['avatar_dir'] = 'blog-avatars';
243
  break;
244
 
245
  case 'group' :
246
  if ( bp_is_active( 'groups' ) ) {
247
+ $params['avatar_dir'] = 'group-avatars';
248
  } else {
249
+ $params['avatar_dir'] = false;
250
  }
251
 
252
  break;
253
 
254
  case 'user' :
255
  default :
256
+ $params['avatar_dir'] = 'avatars';
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'] ) ) {
263
  return false;
264
  }
265
  }
266
 
267
  /** <img> alt *************************************************************/
268
 
269
+ if ( false !== strpos( $params['alt'], '%s' ) || false !== strpos( $params['alt'], '%1$s' ) ) {
270
 
271
+ switch ( $params['object'] ) {
272
 
273
  case 'blog' :
274
+ $item_name = get_blog_option( $params['item_id'], 'blogname' );
275
  break;
276
 
277
  case 'group' :
278
+ $item_name = bp_get_group_name( groups_get_group( array( 'group_id' => $params['item_id'] ) ) );
279
  break;
280
 
281
  case 'user' :
282
  default :
283
+ $item_name = bp_core_get_user_displayname( $params['item_id'] );
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
  }
290
 
291
  /** Sanity Checks *********************************************************/
292
 
293
+ // Get a fallback for the 'alt' parameter, create html output
294
+ if ( empty( $params['alt'] ) ) {
295
+ $params['alt'] = __( 'Profile Photo', 'buddypress' );
296
+ }
297
+ $html_alt = ' alt="' . esc_attr( $params['alt'] ) . '"';
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'] ) ) {
304
+ $html_title = ' title="' . esc_attr( $params['title'] ) . '"';
 
305
  }
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'] ) ) {
312
+ $html_css_id = ' id="' . esc_attr( $params['css_id'] ) . '"';
313
  }
314
 
315
  // Set image width
316
+ if ( false !== $params['width'] ) {
317
+ // Width has been specified. No modification necessary.
318
+ } elseif ( 'thumb' == $params['type'] ) {
319
+ $params['width'] = bp_core_avatar_thumb_width();
320
  } else {
321
+ $params['width'] = bp_core_avatar_full_width();
322
  }
323
+ $html_width = ' width="' . $params['width'] . '"';
324
 
325
  // Set image height
326
+ if ( false !== $params['height'] ) {
327
+ // Height has been specified. No modification necessary.
328
+ } elseif ( 'thumb' == $params['type'] ) {
329
+ $params['height'] = bp_core_avatar_thumb_height();
330
  } else {
331
+ $params['height'] = bp_core_avatar_full_height();
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
+ $html_class = ' class="' . sanitize_html_class( $params['class'] ) . ' ' . sanitize_html_class( $params['object'] . '-' . $params['item_id'] . '-avatar' ) . ' ' . sanitize_html_class( 'avatar-' . $params['width'] ) . ' photo"';
338
 
339
  // Set img URL and DIR based on prepopulated constants
340
  $avatar_loc = new stdClass();
341
  $avatar_loc->path = trailingslashit( bp_core_avatar_upload_path() );
342
  $avatar_loc->url = trailingslashit( bp_core_avatar_url() );
343
 
344
+ $avatar_loc->dir = trailingslashit( $params['avatar_dir'] );
345
+ $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'] );
346
+ $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'] );
 
 
 
347
 
348
  /**
349
  * Look for uploaded avatar first. Use it if it exists.
350
  * Set the file names to search for, to select the full size
351
  * or thumbnail image.
352
  */
353
+ $avatar_size = ( 'full' == $params['type'] ) ? '-bpfull' : '-bpthumb';
354
+ $legacy_user_avatar_name = ( 'full' == $params['type'] ) ? '-avatar2' : '-avatar1';
355
+ $legacy_group_avatar_name = ( 'full' == $params['type'] ) ? '-groupavatar-full' : '-groupavatar-thumb';
356
 
357
  // Check for directory
358
  if ( file_exists( $avatar_folder_dir ) ) {
406
  if ( isset( $avatar_url ) ) {
407
 
408
  // Return it wrapped in an <img> element
409
+ if ( true === $params['html'] ) {
410
+ 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 );
411
 
412
  // ...or only the URL
413
  } else {
418
 
419
  // If no avatars could be found, try to display a gravatar
420
 
421
+ // Skips gravatar check if $params['no_grav'] is passed
422
+ if ( ! apply_filters( 'bp_core_fetch_avatar_no_grav', $params['no_grav'], $params ) ) {
 
 
 
 
 
 
 
 
 
423
 
424
  // Set gravatar type
425
+ if ( empty( $bp->grav_default->{$params['object']} ) ) {
426
  $default_grav = 'wavatar';
427
+ } elseif ( 'mystery' == $bp->grav_default->{$params['object']} ) {
428
+ $default_grav = apply_filters( 'bp_core_mysteryman_src', 'mm', $params['width'] );
429
  } else {
430
+ $default_grav = $bp->grav_default->{$params['object']};
431
  }
432
 
433
  // Set gravatar object
434
+ if ( empty( $params['email'] ) ) {
435
+ if ( 'user' == $params['object'] ) {
436
+ $params['email'] = bp_core_get_user_email( $params['item_id'] );
437
+ } elseif ( 'group' == $params['object'] || 'blog' == $params['object'] ) {
438
+ $params['email'] = $params['item_id'] . '-' . $params['object'] . '@' . bp_get_root_domain();
439
  }
440
  }
441
 
446
  }
447
 
448
  // Filter gravatar vars
449
+ $params['email'] = apply_filters( 'bp_core_gravatar_email', $params['email'], $params['item_id'], $params['object'] );
450
+ $gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $params['email'] ) ) . '?d=' . $default_grav . '&amp;s=' . $params['width'];
451
 
452
  // Gravatar rating; http://bit.ly/89QxZA
453
  $rating = get_option( 'avatar_rating' );
457
 
458
  // No avatar was found, and we've been told not to use a gravatar.
459
  } else {
460
+ $gravatar = apply_filters( 'bp_core_default_avatar_' . $params['object'], bp_core_avatar_default( 'local' ), $params );
461
  }
462
 
463
+ if ( true === $params['html'] ) {
464
+ 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 );
465
  } else {
466
  return apply_filters( 'bp_core_fetch_avatar_url', $gravatar, $params );
467
  }
496
  if ( empty( $item_id ) ) {
497
  if ( 'user' == $object )
498
  $item_id = bp_displayed_user_id();
499
+ elseif ( 'group' == $object )
500
  $item_id = buddypress()->groups->current_group->id;
501
+ elseif ( 'blog' == $object )
502
  $item_id = $current_blog->id;
503
 
504
  $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
509
  if ( empty( $avatar_dir ) ) {
510
  if ( 'user' == $object )
511
  $avatar_dir = 'avatars';
512
+ elseif ( 'group' == $object )
513
  $avatar_dir = 'group-avatars';
514
+ elseif ( 'blog' == $object )
515
  $avatar_dir = 'blog-avatars';
516
 
517
  $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
576
  );
577
 
578
  if ( ! bp_core_check_avatar_upload( $file ) ) {
579
+ bp_core_add_message( sprintf( __( 'Your upload failed. Please try again. Error was: %s', 'buddypress' ), $uploadErrors[$file['file']['error']] ), 'error' );
580
  return false;
581
  }
582
 
697
  * @type string $avatar_dir Subdirectory where avatar should be stored.
698
  * Default: 'avatars'.
699
  * @type bool|int $item_id ID of the item that the avatar belongs to.
700
+ * @type bool|string $original_file Absolute path to the original avatar
701
  * file.
702
  * @type int $crop_w Crop width. Default: the global 'full' avatar width,
703
  * as retrieved by bp_core_avatar_full_width().
830
  }
831
 
832
  // If passed a number, assume it was a $user_id
833
+ } elseif ( is_numeric( $user ) ) {
834
  $id = $user;
835
 
836
  // If passed a string and that string returns a user, get the $id
1144
  $avatar = BP_AVATAR_DEFAULT;
1145
 
1146
  // Use the local default image
1147
+ } elseif ( 'local' === $type ) {
1148
  $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man.jpg';
1149
 
1150
  // Use Gravatar's mystery man as fallback
1180
  $avatar = BP_AVATAR_DEFAULT_THUMB;
1181
 
1182
  // Use the local default image
1183
+ } elseif ( 'local' === $type ) {
1184
  $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man-50.jpg';
1185
 
1186
  // Use Gravatar's mystery man as fallback
1196
 
1197
  return apply_filters( 'bp_core_avatar_thumb', $avatar );
1198
  }
1199
+
1200
+ /**
1201
+ * Reset the week parameter of the WordPress main query if needed
1202
+ *
1203
+ * When cropping an avatar, a $_POST['w'] var is sent, setting the 'week'
1204
+ * parameter of the WordPress main query to this posted var. To avoid
1205
+ * notices, we need to make sure this 'week' query var is reset to 0
1206
+ *
1207
+ * @since BuddyPress (2.2.0)
1208
+ *
1209
+ * @param WP_Query $posts_query the main query object
1210
+ * @uses bp_is_group_create()
1211
+ * @uses bp_is_group_admin_page()
1212
+ * @uses bp_is_group_admin_screen() to check for a group admin screen
1213
+ * @uses bp_action_variable() to check for the group's avatar creation step
1214
+ * @uses bp_is_user_change_avatar() to check for the user's change profile screen
1215
+ */
1216
+ function bp_core_avatar_reset_query( $posts_query = null ) {
1217
+ $reset_w = false;
1218
+
1219
+ // Group's avatar edit screen
1220
+ if ( bp_is_group_admin_page() ) {
1221
+ $reset_w = bp_is_group_admin_screen( 'group-avatar' );
1222
+
1223
+ // Group's avatar create screen
1224
+ } elseif ( bp_is_group_create() ) {
1225
+ /**
1226
+ * we can't use bp_get_groups_current_create_step()
1227
+ * as it's not set yet
1228
+ */
1229
+ $reset_w = 'group-avatar' === bp_action_variable( 1 );
1230
+
1231
+ // User's change avatar screen
1232
+ } else {
1233
+ $reset_w = bp_is_user_change_avatar();
1234
+ }
1235
+
1236
+ // A user or a group is cropping an avatar
1237
+ if ( true === $reset_w && isset( $_POST['avatar-crop-submit'] ) ) {
1238
+ $posts_query->set( 'w', 0 );
1239
+ }
1240
+ }
1241
+ add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );
bp-core/bp-core-buddybar.php CHANGED
@@ -253,6 +253,9 @@ add_action( 'admin_head', 'bp_core_sort_nav_items' );
253
  * when the nav item is clicked.
254
  * @type string $link Optional. The URL that the subnav item should point
255
  * to. Defaults to a value generated from the $parent_url + $slug.
 
 
 
256
  * }
257
  * @return bool|null Returns false on failure.
258
  */
@@ -260,17 +263,18 @@ function bp_core_new_subnav_item( $args = '' ) {
260
  global $bp;
261
 
262
  $r = wp_parse_args( $args, array(
263
- 'name' => false, // Display name for the nav item
264
- 'slug' => false, // URL slug for the nav item
265
- 'parent_slug' => false, // URL slug of the parent nav item
266
- 'parent_url' => false, // URL of the parent item
267
- 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
268
- 'user_has_access' => true, // Can the logged in user see this nav item?
269
- 'no_access_url' => '',
270
- 'site_admin_only' => false, // Can only site admins see this nav item?
271
- 'position' => 90, // Index of where this nav item should be positioned
272
- 'screen_function' => false, // The name of the function to run when clicked
273
- 'link' => '' // The link for the subnav item; optional, not usually required.
 
274
  ) );
275
 
276
  extract( $r, EXTR_SKIP );
@@ -297,15 +301,17 @@ function bp_core_new_subnav_item( $args = '' ) {
297
  $item_css_id = $slug;
298
 
299
  $subnav_item = array(
300
- 'name' => $name,
301
- 'link' => trailingslashit( $link ),
302
- 'slug' => $slug,
303
- 'css_id' => $item_css_id,
304
- 'position' => $position,
305
- 'user_has_access' => $user_has_access,
306
- 'no_access_url' => $no_access_url,
307
- 'screen_function' => &$screen_function
 
308
  );
 
309
  $bp->bp_options_nav[$parent_slug][$slug] = $subnav_item;
310
 
311
  /**
@@ -385,7 +391,7 @@ function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) {
385
 
386
  // In the case of a user page, we try to assume a
387
  // redirect URL
388
- } else if ( bp_is_user() ) {
389
 
390
  // Redirect to the displayed user's default
391
  // component, as long as that component is
253
  * when the nav item is clicked.
254
  * @type string $link Optional. The URL that the subnav item should point
255
  * to. Defaults to a value generated from the $parent_url + $slug.
256
+ * @type bool $show_in_admin_bar Optional. Whether the nav item should be
257
+ * added into the group's "Edit" Admin Bar menu for group admins.
258
+ * Default: false.
259
  * }
260
  * @return bool|null Returns false on failure.
261
  */
263
  global $bp;
264
 
265
  $r = wp_parse_args( $args, array(
266
+ 'name' => false, // Display name for the nav item
267
+ 'slug' => false, // URL slug for the nav item
268
+ 'parent_slug' => false, // URL slug of the parent nav item
269
+ 'parent_url' => false, // URL of the parent item
270
+ 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
271
+ 'user_has_access' => true, // Can the logged in user see this nav item?
272
+ 'no_access_url' => '',
273
+ 'site_admin_only' => false, // Can only site admins see this nav item?
274
+ 'position' => 90, // Index of where this nav item should be positioned
275
+ 'screen_function' => false, // The name of the function to run when clicked
276
+ 'link' => '', // The link for the subnav item; optional, not usually required.
277
+ 'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu
278
  ) );
279
 
280
  extract( $r, EXTR_SKIP );
301
  $item_css_id = $slug;
302
 
303
  $subnav_item = array(
304
+ 'name' => $name,
305
+ 'link' => trailingslashit( $link ),
306
+ 'slug' => $slug,
307
+ 'css_id' => $item_css_id,
308
+ 'position' => $position,
309
+ 'user_has_access' => $user_has_access,
310
+ 'no_access_url' => $no_access_url,
311
+ 'screen_function' => &$screen_function,
312
+ 'show_in_admin_bar' => (bool) $r['show_in_admin_bar'],
313
  );
314
+
315
  $bp->bp_options_nav[$parent_slug][$slug] = $subnav_item;
316
 
317
  /**
391
 
392
  // In the case of a user page, we try to assume a
393
  // redirect URL
394
+ } elseif ( bp_is_user() ) {
395
 
396
  // Redirect to the displayed user's default
397
  // component, as long as that component is
bp-core/bp-core-cache.php CHANGED
@@ -26,16 +26,6 @@ function bp_core_clear_cache() {
26
  }
27
  }
28
 
29
- /**
30
- * Add 'bp' to global group of network wide cachable objects.
31
- */
32
- function bp_core_add_global_group() {
33
- if ( function_exists( 'wp_cache_add_global_groups' ) ) {
34
- wp_cache_add_global_groups( array( 'bp' ) );
35
- }
36
- }
37
- add_action( 'bp_loaded', 'bp_core_add_global_group' );
38
-
39
  /**
40
  * Clear all cached objects for a user, or those that a user is part of.
41
  */
26
  }
27
  }
28
 
 
 
 
 
 
 
 
 
 
 
29
  /**
30
  * Clear all cached objects for a user, or those that a user is part of.
31
  */
bp-core/bp-core-caps.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Capabilites.
5
  *
6
  * @package BuddyPress
7
  * @subpackage Capabilities
@@ -16,7 +16,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
16
  * WordPress roles are dynamically flipped when calls to switch_to_blog() and
17
  * restore_current_blog() are made, so we use and trust WordPress core to have
18
  * loaded the correct results for us here. As enhancements are made to
19
- * WordPresss's RBAC, so should our capability functions here.
20
  *
21
  * @since BuddyPress (2.1.0)
22
  *
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Capabilities.
5
  *
6
  * @package BuddyPress
7
  * @subpackage Capabilities
16
  * WordPress roles are dynamically flipped when calls to switch_to_blog() and
17
  * restore_current_blog() are made, so we use and trust WordPress core to have
18
  * loaded the correct results for us here. As enhancements are made to
19
+ * WordPress's RBAC, so should our capability functions here.
20
  *
21
  * @since BuddyPress (2.1.0)
22
  *
bp-core/bp-core-catchuri.php CHANGED
@@ -253,7 +253,7 @@ function bp_core_set_uri_globals() {
253
  // Viewing a specific user
254
  if ( !empty( $bp_uri[$uri_offset + 1] ) ) {
255
 
256
- // Switch the displayed_user based on compatbility 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 {
@@ -342,34 +342,12 @@ function bp_core_enable_root_profiles() {
342
  function bp_core_load_template( $templates ) {
343
  global $wp_query;
344
 
345
- // check if BP page belongs to, or is a child of, a BP directory page
346
- $page_id = false;
347
- foreach ( (array) buddypress()->pages as $page ) {
348
- if ( $page->name == buddypress()->unfiltered_uri[buddypress()->unfiltered_uri_offset] ) {
349
- $page_id = $page->id;
350
- break;
351
- }
352
- }
353
-
354
- // Set up reset post args
355
- $reset_post_args = array(
356
  'is_404' => true,
357
  'post_status' => 'publish',
358
- );
359
-
360
- // BP page exists - fill in the $wp_query->post object
361
- //
362
- // bp_theme_compat_reset_post() looks at the $wp_query->post object to fill in
363
- // the post globals
364
- if ( ! empty( $page_id ) ) {
365
- $wp_query->post = get_post( $page_id );
366
- $reset_post_args['ID'] = $page_id;
367
- } else {
368
- $reset_post_args['ID'] = 0;
369
- }
370
-
371
- // Reset the post
372
- bp_theme_compat_reset_post( $reset_post_args );
373
 
374
  // Set theme compat to false since the reset post function automatically sets
375
  // theme compat to true
@@ -393,7 +371,6 @@ function bp_core_load_template( $templates ) {
393
  // Filter the template locations so that plugins can alter where they are located
394
  $located_template = apply_filters( 'bp_located_template', $template, $filtered_templates );
395
  if ( !empty( $located_template ) ) {
396
-
397
  // Template was located, lets set this as a valid page and not a 404.
398
  status_header( 200 );
399
  $wp_query->is_page = true;
@@ -409,7 +386,7 @@ function bp_core_load_template( $templates ) {
409
  // Kill any other output after this.
410
  exit();
411
 
412
- // No template found, so setup theme compatability
413
  // @todo Some other 404 handling if theme compat doesn't kick in
414
  } else {
415
 
@@ -464,7 +441,7 @@ add_action( 'bp_template_redirect', 'bp_core_catch_no_access', 1 );
464
  * @since BuddyPress (1.5.0)
465
  *
466
  * @param array $args {
467
- * @type int $mode Specifies the destintation of the redirect. 1 will
468
  * direct to the root domain (home page), which assumes you have a
469
  * log-in form there; 2 directs to wp-login.php. Default: 2.
470
  * @type string $redirect The URL the user will be redirected to after
@@ -670,7 +647,7 @@ function bp_get_canonical_url( $args = array() ) {
670
  // Except when the front page is set to the registration page
671
  // and the current user is logged in. In this case we send to
672
  // the members directory to avoid redirect loops
673
- } else if ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
674
  $bp->canonical_stack['canonical_url'] = apply_filters( 'bp_loggedin_register_page_redirect_to', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
675
  }
676
  }
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 {
342
  function bp_core_load_template( $templates ) {
343
  global $wp_query;
344
 
345
+ // Reset the post
346
+ bp_theme_compat_reset_post( array(
347
+ 'ID' => 0,
 
 
 
 
 
 
 
 
348
  'is_404' => true,
349
  'post_status' => 'publish',
350
+ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
 
352
  // Set theme compat to false since the reset post function automatically sets
353
  // theme compat to true
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.
375
  status_header( 200 );
376
  $wp_query->is_page = true;
386
  // Kill any other output after this.
387
  exit();
388
 
389
+ // No template found, so setup theme compatibility
390
  // @todo Some other 404 handling if theme compat doesn't kick in
391
  } else {
392
 
441
  * @since BuddyPress (1.5.0)
442
  *
443
  * @param array $args {
444
+ * @type int $mode Specifies the destination of the redirect. 1 will
445
  * direct to the root domain (home page), which assumes you have a
446
  * log-in form there; 2 directs to wp-login.php. Default: 2.
447
  * @type string $redirect The URL the user will be redirected to after
647
  // Except when the front page is set to the registration page
648
  // and the current user is logged in. In this case we send to
649
  // the members directory to avoid redirect loops
650
+ } elseif ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
651
  $bp->canonical_stack['canonical_url'] = apply_filters( 'bp_loggedin_register_page_redirect_to', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
652
  }
653
  }
bp-core/bp-core-classes.php CHANGED
@@ -12,50 +12,46 @@ if ( !defined( 'ABSPATH' ) ) exit;
12
  /**
13
  * BuddyPress User Query class.
14
  *
15
- * Used for querying users in a BuddyPress context, in situations where
16
- * WP_User_Query won't do the trick: Member directories, the Friends component,
17
- * etc.
18
  *
19
  * @since BuddyPress (1.7.0)
20
  *
21
  * @param array $query {
22
  * Query arguments. All items are optional.
23
- * @type string $type Determines sort order. Select from 'newest', 'active',
24
- * 'online', 'random', 'popular', 'alphabetical'. Default: 'newest'.
25
- * @type int $per_page Number of results to return. Default: 0 (no limit).
26
- * @type int $page Page offset (together with $per_page). Default: 1.
27
- * @type int $user_id ID of a user. If present, and if the friends
28
- * component is activated, results will be limited to the friends of
29
- * that user. Default: 0.
30
- * @type string|bool $search_terms Terms to search by. Search happens
31
- * across xprofile fields. Requires XProfile component.
32
- * Default: false.
33
- * @type string $search_wildcard When searching with $search_terms,
34
- * set where wildcards around the term should be positioned.
35
- * Default: 'both'. Other values: 'left', 'right'.
36
- * @type array|string|bool $include An array or comma-separated list of
37
- * user IDs to which query should be limited.
38
- * Default: false.
39
- * @type array|string|bool $exclude An array or comma-separated list of
40
- * user IDs that will be excluded from query results. Default: false.
41
- * @type array|string|bool $user_ids An array or comma-separated list of
42
- * IDs corresponding to the users that should be returned. When this
43
- * parameter is passed, it will override all others; BP User objects
44
- * will be constructed using these IDs only. Default: false.
45
- * @type string|bool $meta_key Limit results to users that have usermeta
46
- * associated with this meta_key. Usually used with $meta_value.
47
- * Default: false.
48
- * @type string|bool $meta_value When used with $meta_key, limits results
49
- * to users whose usermeta value associated with $meta_key matches
50
- * $meta_value. Default: false.
51
- * @type bool $populate_extras True if you want to fetch extra metadata
52
- * about returned users, such as total group and friend counts.
53
- * @type string $count_total Determines how BP_User_Query will do a count
54
- * of total users matching the other filter criteria. Default value
55
- * is 'count_query', which does a separate SELECT COUNT query to
56
- * determine the total. 'sql_count_found_rows' uses
57
- * SQL_COUNT_FOUND_ROWS and SELECT FOUND_ROWS(). Pass an empty string
58
- * to skip the total user count query.
59
  * }
60
  */
61
  class BP_User_Query {
@@ -114,6 +110,15 @@ class BP_User_Query {
114
  */
115
  public $uid_clauses = array();
116
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * SQL database column name to order by.
119
  *
@@ -160,8 +165,10 @@ class BP_User_Query {
160
  'include' => false,
161
  'exclude' => false,
162
  'user_ids' => false,
 
163
  'meta_key' => false,
164
  'meta_value' => false,
 
165
  'populate_extras' => true,
166
  'count_total' => 'count_query'
167
  ) );
@@ -249,7 +256,8 @@ class BP_User_Query {
249
  // number of minutes used as an interval
250
  case 'online' :
251
  $this->uid_name = 'user_id';
252
- $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$bp->members->table_name_last_activity} u";
 
253
  $sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id );
254
  $sql['where'][] = $wpdb->prepare( "u.date_recorded >= DATE_SUB( UTC_TIMESTAMP(), INTERVAL %d MINUTE )", apply_filters( 'bp_user_query_online_interval', 15 ) );
255
  $sql['orderby'] = "ORDER BY u.date_recorded";
@@ -263,13 +271,14 @@ class BP_User_Query {
263
  case 'newest' :
264
  case 'random' :
265
  $this->uid_name = 'user_id';
266
- $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$bp->members->table_name_last_activity} u";
 
267
  $sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id );
268
 
269
  if ( 'newest' == $type ) {
270
  $sql['orderby'] = "ORDER BY u.user_id";
271
  $sql['order'] = "DESC";
272
- } else if ( 'random' == $type ) {
273
  $sql['orderby'] = "ORDER BY rand()";
274
  } else {
275
  $sql['orderby'] = "ORDER BY u.date_recorded";
@@ -281,7 +290,8 @@ class BP_User_Query {
281
  // 'popular' sorts by the 'total_friend_count' usermeta
282
  case 'popular' :
283
  $this->uid_name = 'user_id';
284
- $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->usermeta} u";
 
285
  $sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );
286
  $sql['orderby'] = "ORDER BY CONVERT(u.meta_value, SIGNED)";
287
  $sql['order'] = "DESC";
@@ -298,7 +308,8 @@ class BP_User_Query {
298
  // @todo remove need for bp_is_active() check
299
  if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) {
300
  $this->uid_name = 'ID';
301
- $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->users} u";
 
302
  $sql['orderby'] = "ORDER BY u.display_name";
303
  $sql['order'] = "ASC";
304
 
@@ -306,7 +317,8 @@ class BP_User_Query {
306
  // the xprofile table
307
  } else {
308
  $this->uid_name = 'user_id';
309
- $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$bp->profile->table_name_data} u";
 
310
  $sql['where'][] = $wpdb->prepare( "u.field_id = %d", bp_xprofile_fullname_field_id() );
311
  $sql['orderby'] = "ORDER BY u.value";
312
  $sql['order'] = "ASC";
@@ -322,7 +334,8 @@ class BP_User_Query {
322
  // Any other 'type' falls through
323
  default :
324
  $this->uid_name = 'ID';
325
- $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->users} u";
 
326
 
327
  // In this case, we assume that a plugin is
328
  // handling order, so we leave those clauses
@@ -390,6 +403,47 @@ class BP_User_Query {
390
  );
391
  }
392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
393
  // 'meta_key', 'meta_value' allow usermeta search
394
  // To avoid global joins, do a separate query
395
  if ( false !== $meta_key ) {
@@ -403,6 +457,8 @@ class BP_User_Query {
403
 
404
  if ( ! empty( $found_user_ids ) ) {
405
  $sql['where'][] = "u.{$this->uid_name} IN (" . implode( ',', wp_parse_id_list( $found_user_ids ) ) . ")";
 
 
406
  }
407
  }
408
 
@@ -544,7 +600,6 @@ class BP_User_Query {
544
  *
545
  * @since BuddyPress (1.7.0)
546
  *
547
- * @global BuddyPress $bp Global BuddyPress settings object.
548
  * @global WPDB $wpdb Global WordPress database access object.
549
  */
550
  public function populate_extras() {
@@ -569,8 +624,6 @@ class BP_User_Query {
569
  // Turn user ID's into a query-usable, comma separated value
570
  $user_ids_sql = implode( ',', wp_parse_id_list( $this->user_ids ) );
571
 
572
- $bp = buddypress();
573
-
574
  /**
575
  * Use this action to independently populate your own custom extras.
576
  *
@@ -608,7 +661,7 @@ class BP_User_Query {
608
  $this->results[$uindex]->total_friend_count = 0;
609
  }
610
 
611
- // Create, prepare, and run the seperate usermeta query
612
  $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 ) );
613
 
614
  // The $members_template global expects the index key to be different
@@ -1546,7 +1599,7 @@ class BP_Date_Query extends WP_Date_Query {
1546
  * Destructor.
1547
  */
1548
  public function __destruct() {
1549
- remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
1550
  }
1551
 
1552
  /**
@@ -1776,7 +1829,7 @@ class BP_Core_Notification {
1776
  * @global wpdb $wpdb WordPress database object
1777
  * @param string $item_id The item id that they notifications are to be for.
1778
  * @param string $component_name The component that the notifications are to be from.
1779
- * @param string $component_action The action that the notificationsa are to be from.
1780
  * @param string $secondary_item_id Optional secondary item id that the notifications are to have.
1781
  * @static
1782
  */
@@ -1979,7 +2032,7 @@ class BP_Button {
1979
 
1980
  // No button if viewing your own profile (and not in
1981
  // a members loop)
1982
- } else if ( bp_is_my_profile() ) {
1983
  return false;
1984
  }
1985
  }
@@ -2273,7 +2326,6 @@ class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
2273
  if ( empty( $elements ) ) // nothing to walk
2274
  return $output;
2275
 
2276
- $id_field = $this->db_fields['id'];
2277
  $parent_field = $this->db_fields['parent'];
2278
 
2279
  // flat display
@@ -2698,3 +2750,228 @@ class BP_Members_Suggestions extends BP_Suggestions {
2698
  return apply_filters( 'bp_members_suggestions_get_suggestions', $results, $this );
2699
  }
2700
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 {
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
  *
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
  ) );
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";
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";
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";
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
 
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";
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
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
+
439
+
440
+ // Grab the first term_relationships clause and convert to a subquery.
441
+ if ( preg_match( '/' . $wpdb->term_relationships . '\.term_taxonomy_id IN \([0-9, ]+\)/', $member_type_sql_clauses['where'], $matches ) ) {
442
+ $sql['where']['member_type'] = "u.{$this->uid_name} IN ( SELECT object_id FROM $wpdb->term_relationships WHERE {$matches[0]} )";
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 ) {
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
 
600
  *
601
  * @since BuddyPress (1.7.0)
602
  *
 
603
  * @global WPDB $wpdb Global WordPress database access object.
604
  */
605
  public function populate_extras() {
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
  *
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
1599
  * Destructor.
1600
  */
1601
  public function __destruct() {
1602
+ remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
1603
  }
1604
 
1605
  /**
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
  */
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
  }
2326
  if ( empty( $elements ) ) // nothing to walk
2327
  return $output;
2328
 
 
2329
  $parent_field = $this->db_fields['parent'];
2330
 
2331
  // flat display
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
+
2858
+ // Filter empties
2859
+ $sql_chunks['join'] = array_filter( $sql_chunks['join'] );
2860
+ $sql_chunks['where'] = array_filter( $sql_chunks['where'] );
2861
+
2862
+ if ( empty( $relation ) ) {
2863
+ $relation = 'AND';
2864
+ }
2865
+
2866
+ if ( ! empty( $sql_chunks['join'] ) ) {
2867
+ $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) );
2868
+ }
2869
+
2870
+ if ( ! empty( $sql_chunks['where'] ) ) {
2871
+ $sql['where'] = '( ' . "\n\t" . $indent . implode( ' ' . "\n\t" . $indent . $relation . ' ' . "\n\t" . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')' . "\n";
2872
+ }
2873
+
2874
+ return $sql;
2875
+ }
2876
+
2877
+ /**
2878
+ * Recursive-friendly query sanitizer.
2879
+ *
2880
+ * Ensures that each query-level clause has a 'relation' key, and that
2881
+ * each first-order clause contains all the necessary keys from
2882
+ * $defaults.
2883
+ *
2884
+ * Extend this method if your class uses different sanitizing logic.
2885
+ *
2886
+ * @since BuddyPress (2.2.0)
2887
+ * @access public
2888
+ *
2889
+ * @param array $queries Array of query clauses.
2890
+ * @return array Sanitized array of query clauses.
2891
+ */
2892
+ protected function sanitize_query( $queries ) {
2893
+ $clean_queries = array();
2894
+
2895
+ if ( ! is_array( $queries ) ) {
2896
+ return $clean_queries;
2897
+ }
2898
+
2899
+ foreach ( $queries as $key => $query ) {
2900
+ if ( 'relation' === $key ) {
2901
+ $relation = $query;
2902
+
2903
+ } elseif ( ! is_array( $query ) ) {
2904
+ continue;
2905
+
2906
+ // First-order clause.
2907
+ } elseif ( $this->is_first_order_clause( $query ) ) {
2908
+ if ( isset( $query['value'] ) && array() === $query['value'] ) {
2909
+ unset( $query['value'] );
2910
+ }
2911
+
2912
+ $clean_queries[] = $query;
2913
+
2914
+ // Otherwise, it's a nested query, so we recurse.
2915
+ } else {
2916
+ $cleaned_query = $this->sanitize_query( $query );
2917
+
2918
+ if ( ! empty( $cleaned_query ) ) {
2919
+ $clean_queries[] = $cleaned_query;
2920
+ }
2921
+ }
2922
+ }
2923
+
2924
+ if ( empty( $clean_queries ) ) {
2925
+ return $clean_queries;
2926
+ }
2927
+
2928
+ // Sanitize the 'relation' key provided in the query.
2929
+ if ( isset( $relation ) && 'OR' === strtoupper( $relation ) ) {
2930
+ $clean_queries['relation'] = 'OR';
2931
+
2932
+ /*
2933
+ * If there is only a single clause, call the relation 'OR'.
2934
+ * This value will not actually be used to join clauses, but it
2935
+ * simplifies the logic around combining key-only queries.
2936
+ */
2937
+ } elseif ( 1 === count( $clean_queries ) ) {
2938
+ $clean_queries['relation'] = 'OR';
2939
+
2940
+ // Default to AND.
2941
+ } else {
2942
+ $clean_queries['relation'] = 'AND';
2943
+ }
2944
+
2945
+ return $clean_queries;
2946
+ }
2947
+
2948
+ /**
2949
+ * Generate JOIN and WHERE clauses for a first-order clause.
2950
+ *
2951
+ * Must be overridden in a subclass.
2952
+ *
2953
+ * @since BuddyPress (2.2.0)
2954
+ * @access protected
2955
+ *
2956
+ * @param array $clause Array of arguments belonging to the clause.
2957
+ * @param array $parent_query Parent query to which the clause belongs.
2958
+ * @return array {
2959
+ * @type array $join Array of subclauses for the JOIN statement.
2960
+ * @type array $where Array of subclauses for the WHERE statement.
2961
+ * }
2962
+ */
2963
+ abstract protected function get_sql_for_clause( $clause, $parent_query );
2964
+
2965
+ /**
2966
+ * Determine whether a clause is first-order.
2967
+ *
2968
+ * Must be overridden in a subclass.
2969
+ *
2970
+ * @since BuddyPress (2.2.0)
2971
+ * @access protected
2972
+ *
2973
+ * @param array $q Clause to check.
2974
+ * @return bool
2975
+ */
2976
+ abstract protected function is_first_order_clause( $query );
2977
+ }
bp-core/bp-core-component.php CHANGED
@@ -356,6 +356,9 @@ class BP_Component {
356
  // Setup component title
357
  add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 );
358
 
 
 
 
359
  // Register post types
360
  add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 );
361
 
@@ -471,12 +474,23 @@ class BP_Component {
471
  *
472
  * @since BuddyPress (1.5.0)
473
  *
474
- * @uses do_action() Calls 'bp_{@link bp_Component::name}setup_title'.
475
  */
476
  public function setup_title() {
477
  do_action( 'bp_' . $this->id . '_setup_title' );
478
  }
479
 
 
 
 
 
 
 
 
 
 
 
 
480
  /**
481
  * Register global tables for the component, so that it may use WordPress's database API.
482
  *
356
  // Setup component title
357
  add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 );
358
 
359
+ // Setup cache groups
360
+ add_action( 'bp_setup_cache_groups', array( $this, 'setup_cache_groups' ), 10 );
361
+
362
  // Register post types
363
  add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 );
364
 
474
  *
475
  * @since BuddyPress (1.5.0)
476
  *
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
 
483
+ /**
484
+ * Setup component-specific cache groups.
485
+ *
486
+ * @since BuddyPress (2.2.0)
487
+ *
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
+
494
  /**
495
  * Register global tables for the component, so that it may use WordPress's database API.
496
  *
bp-core/bp-core-cssjs.php CHANGED
@@ -125,7 +125,7 @@ function bp_core_add_cropper_inline_js() {
125
  $crop_right = $image[0];
126
 
127
  // Less than 2x full-width: cropper defaults to full-width
128
- } else if ( $image[0] < ( $full_width * 2 ) ) {
129
  $padding_w = round( ( $image[0] - $full_width ) / 2 );
130
  $crop_left = $padding_w;
131
  $crop_right = $image[0] - $padding_w;
@@ -142,7 +142,7 @@ function bp_core_add_cropper_inline_js() {
142
  $crop_bottom = $image[1];
143
 
144
  // Less than double full-height: cropper defaults to full-height
145
- } else if ( $image[1] < ( $full_height * 2 ) ) {
146
  $padding_h = round( ( $image[1] - $full_height ) / 2 );
147
  $crop_top = $padding_h;
148
  $crop_bottom = $image[1] - $padding_h;
125
  $crop_right = $image[0];
126
 
127
  // Less than 2x full-width: cropper defaults to full-width
128
+ } elseif ( $image[0] < ( $full_width * 2 ) ) {
129
  $padding_w = round( ( $image[0] - $full_width ) / 2 );
130
  $crop_left = $padding_w;
131
  $crop_right = $image[0] - $padding_w;
142
  $crop_bottom = $image[1];
143
 
144
  // Less than double full-height: cropper defaults to full-height
145
+ } elseif ( $image[1] < ( $full_height * 2 ) ) {
146
  $padding_h = round( ( $image[1] - $full_height ) / 2 );
147
  $crop_top = $padding_h;
148
  $crop_bottom = $image[1] - $padding_h;
bp-core/bp-core-dependency.php CHANGED
@@ -14,7 +14,7 @@
14
  * The following functions are wrappers for hooks, allowing them to be
15
  * manually called and/or piggy-backed on top of other hooks if needed.
16
  *
17
- * @todo use anonymous functions when PHP minimun requirement allows (5.3)
18
  */
19
 
20
  /**
@@ -38,6 +38,15 @@ function bp_setup_canonical_stack() {
38
  do_action( 'bp_setup_canonical_stack' );
39
  }
40
 
 
 
 
 
 
 
 
 
 
41
  /**
42
  * Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
43
  */
@@ -74,6 +83,15 @@ function bp_setup_widgets() {
74
  do_action( 'bp_register_widgets' );
75
  }
76
 
 
 
 
 
 
 
 
 
 
77
  /**
78
  * Set up the currently logged-in user.
79
  *
14
  * The following functions are wrappers for hooks, allowing them to be
15
  * manually called and/or piggy-backed on top of other hooks if needed.
16
  *
17
+ * @todo use anonymous functions when PHP minimum requirement allows (5.3)
18
  */
19
 
20
  /**
38
  do_action( 'bp_setup_canonical_stack' );
39
  }
40
 
41
+ /**
42
+ * Fire the 'bp_register_taxonomies' action, where plugins should register taxonomies.
43
+ *
44
+ * @since BuddyPress (2.2.0)
45
+ */
46
+ function bp_register_taxonomies() {
47
+ do_action( 'bp_register_taxonomies' );
48
+ }
49
+
50
  /**
51
  * Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
52
  */
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
  *
bp-core/bp-core-filters.php CHANGED
@@ -139,6 +139,93 @@ function bp_core_exclude_pages_from_nav_menu_admin( $object = null ) {
139
  }
140
  add_filter( 'nav_menu_meta_box_object', 'bp_core_exclude_pages_from_nav_menu_admin', 11, 1 );
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  /**
143
  * Set "From" name in outgoing email to the site name.
144
  *
@@ -375,7 +462,7 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
375
  * And the super admin goes in pending accounts to resend it. In this case, as the
376
  * meta['password'] is not set, the activation url must be WordPress one
377
  */
378
- } else if ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
379
  $is_hashpass_in_meta = maybe_unserialize( $meta );
380
 
381
  if ( empty( $is_hashpass_in_meta['password'] ) ) {
@@ -423,12 +510,13 @@ add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_not
423
  * @param string $seplocation Direction to display title.
424
  * @return string New page title.
425
  */
426
- function bp_modify_page_title( $title, $sep, $seplocation ) {
427
  global $bp;
428
 
429
  // If this is not a BP page, just return the title produced by WP
430
- if ( bp_is_blog_page() )
431
  return $title;
 
432
 
433
  // If this is a 404, let WordPress handle it
434
  if ( is_404() ) {
@@ -436,43 +524,77 @@ function bp_modify_page_title( $title, $sep, $seplocation ) {
436
  }
437
 
438
  // If this is the front page of the site, return WP's title
439
- if ( is_front_page() || is_home() )
440
  return $title;
 
441
 
442
  $title = '';
443
 
444
  // Displayed user
445
- if ( bp_get_displayed_user_fullname() && !is_404() ) {
446
-
447
- // Get the component's ID to try and get it's name
448
  $component_id = $component_name = bp_current_component();
449
 
450
- // Use the actual component name
451
- if ( !empty( $bp->{$component_id}->name ) ) {
452
- $component_name = $bp->{$component_id}->name;
 
 
 
453
 
454
- // Fall back on the component ID (probably same as current_component)
455
- } elseif ( !empty( $bp->{$component_id}->id ) ) {
456
- $component_name = $bp->{$component_id}->id;
 
 
 
 
457
  }
458
 
459
- // Construct the page title. 1 = user name, 2 = seperator, 3 = component name
460
- $title = strip_tags( sprintf( _x( '%1$s %3$s %2$s', 'Construct the page title. 1 = user name, 2 = component name, 3 = seperator', 'buddypress' ), bp_get_displayed_user_fullname(), ucwords( $component_name ), $sep ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
 
462
  // A single group
463
- } elseif ( bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) && !empty( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ) {
464
- $subnav = isset( $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name'] ) ? $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name'] : '';
465
- // translators: "group name | group nav section name"
466
- $title = sprintf( __( '%1$s | %2$s', 'buddypress' ), $bp->bp_options_title, $subnav );
467
 
468
  // A single item from a component other than groups
469
  } elseif ( bp_is_single_item() ) {
470
- // translators: "component item name | component nav section name | root component name"
471
- $title = sprintf( __( '%1$s | %2$s | %3$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[bp_current_item()][bp_current_action()]['name'], bp_get_name_from_root_slug( bp_get_root_slug() ) );
472
 
473
  // An index or directory
474
  } elseif ( bp_is_directory() ) {
475
-
476
  $current_component = bp_current_component();
477
 
478
  // No current component (when does this happen?)
@@ -524,7 +646,7 @@ function bp_setup_nav_menu_item( $menu_item ) {
524
 
525
  // We use information stored in the CSS class to determine what kind of
526
  // menu item this is, and how it should be treated
527
- $css_target = preg_match( '/\sbp-(.*)-nav/', implode( ' ', $menu_item->classes), $matches );
528
 
529
  // If this isn't a BP menu item, we can stop here
530
  if ( empty( $matches[1] ) ) {
@@ -603,7 +725,25 @@ add_filter( 'wp_setup_nav_menu_item', 'bp_setup_nav_menu_item', 10, 1 );
603
  * @return string
604
  */
605
  function bp_filter_metaid_column_name( $q ) {
606
- return str_replace( 'meta_id', 'id', $q );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  }
608
 
609
  /**
@@ -623,3 +763,25 @@ function bp_core_filter_edit_post_link( $edit_link = '', $post_id = 0 ) {
623
 
624
  return $edit_link;
625
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
  add_filter( 'nav_menu_meta_box_object', 'bp_core_exclude_pages_from_nav_menu_admin', 11, 1 );
141
 
142
+ /**
143
+ * Adds current page CSS classes to the parent BP page in a WP Page Menu.
144
+ *
145
+ * Because BuddyPress primarily uses virtual pages, we need a way to highlight
146
+ * the BP parent page during WP menu generation. This function checks the
147
+ * current BP component against the current page in the WP menu to see if we
148
+ * should highlight the WP page.
149
+ *
150
+ * @since BuddyPress (2.2.0)
151
+ *
152
+ * @param array $retval CSS classes for the current menu page in the menu
153
+ * @param WP_Post $page The page properties for the current menu item
154
+ * @return array
155
+ */
156
+ function bp_core_menu_highlight_parent_page( $retval, $page ) {
157
+ if ( ! is_buddypress() ) {
158
+ return $retval;
159
+ }
160
+
161
+ $page_id = false;
162
+
163
+ // loop against all BP component pages
164
+ foreach ( (array) buddypress()->pages as $component => $bp_page ) {
165
+ // handles the majority of components
166
+ if ( bp_is_current_component( $component ) ) {
167
+ $page_id = (int) $bp_page->id;
168
+ }
169
+
170
+ // stop if not on a user page
171
+ if ( ! bp_is_user() && ! empty( $page_id ) ) {
172
+ break;
173
+ }
174
+
175
+ // members component requires an explicit check due to overlapping components
176
+ if ( bp_is_user() && 'members' === $component ) {
177
+ $page_id = (int) $bp_page->id;
178
+ break;
179
+ }
180
+ }
181
+
182
+ // duplicate some logic from Walker_Page::start_el() to highlight menu items
183
+ if ( ! empty( $page_id ) ) {
184
+ $_bp_page = get_post( $page_id );
185
+ if ( in_array( $page->ID, $_bp_page->ancestors, true ) ) {
186
+ $retval[] = 'current_page_ancestor';
187
+ }
188
+ if ( $page->ID === $page_id ) {
189
+ $retval[] = 'current_page_item';
190
+ } elseif ( $_bp_page && $page->ID === $_bp_page->post_parent ) {
191
+ $retval[] = 'current_page_parent';
192
+ }
193
+ }
194
+
195
+ $retval = array_unique( $retval );
196
+
197
+ return $retval;
198
+ }
199
+ add_filter( 'page_css_class', 'bp_core_menu_highlight_parent_page', 10, 2 );
200
+
201
+ /**
202
+ * Adds current page CSS classes to the parent BP page in a WP Nav Menu.
203
+ *
204
+ * When {@link wp_nav_menu()} is used, this function helps to highlight the
205
+ * current BP parent page during nav menu generation.
206
+ *
207
+ * @since BuddyPress (2.2.0)
208
+ *
209
+ * @param array $retval CSS classes for the current nav menu item in the menu
210
+ * @param WP_Post $item The properties for the current nav menu item
211
+ * @return array
212
+ */
213
+ function bp_core_menu_highlight_nav_menu_item( $retval, $item ) {
214
+ // If we're not on a BP page or if the current nav item is not a page, stop!
215
+ if ( ! is_buddypress() || 'page' !== $item->object ) {
216
+ return $retval;
217
+ }
218
+
219
+ // get the WP page
220
+ $page = get_post( $item->object_id );
221
+
222
+ // see if we should add our highlight CSS classes for the page
223
+ $retval = bp_core_menu_highlight_parent_page( $retval, $page );
224
+
225
+ return $retval;
226
+ }
227
+ add_filter( 'nav_menu_css_class', 'bp_core_menu_highlight_nav_menu_item', 10, 2 );
228
+
229
  /**
230
  * Set "From" name in outgoing email to the site name.
231
  *
462
  * And the super admin goes in pending accounts to resend it. In this case, as the
463
  * meta['password'] is not set, the activation url must be WordPress one
464
  */
465
+ } elseif ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
466
  $is_hashpass_in_meta = maybe_unserialize( $meta );
467
 
468
  if ( empty( $is_hashpass_in_meta['password'] ) ) {
510
  * @param string $seplocation Direction to display title.
511
  * @return string New page title.
512
  */
513
+ function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) {
514
  global $bp;
515
 
516
  // If this is not a BP page, just return the title produced by WP
517
+ if ( bp_is_blog_page() ) {
518
  return $title;
519
+ }
520
 
521
  // If this is a 404, let WordPress handle it
522
  if ( is_404() ) {
524
  }
525
 
526
  // If this is the front page of the site, return WP's title
527
+ if ( is_front_page() || is_home() ) {
528
  return $title;
529
+ }
530
 
531
  $title = '';
532
 
533
  // Displayed user
534
+ if ( bp_get_displayed_user_fullname() && ! is_404() ) {
535
+ // Get the component's ID to try and get its name
 
536
  $component_id = $component_name = bp_current_component();
537
 
538
+ // Use the component nav name
539
+ if ( ! empty( $bp->bp_nav[$component_id] ) ) {
540
+ // Remove counts that are added by the nav item
541
+ $span = strpos( $bp->bp_nav[ $component_id ]['name'], '<span' );
542
+ if ( false !== $span ) {
543
+ $component_name = substr( $bp->bp_nav[ $component_id ]['name'], 0, $span - 1 );
544
 
545
+ } else {
546
+ $component_name = $bp->bp_nav[ $component_id ]['name'];
547
+ }
548
+
549
+ // Fall back on the component ID
550
+ } elseif ( ! empty( $bp->{$component_id}->id ) ) {
551
+ $component_name = ucwords( $bp->{$component_id}->id );
552
  }
553
 
554
+ // Append action name if we're on a member component sub-page
555
+ if ( ! empty( $bp->bp_options_nav[ $component_id ] ) && ! empty( $bp->canonical_stack['action'] ) ) {
556
+ $component_subnav_name = wp_filter_object_list( $bp->bp_options_nav[ $component_id ], array( 'slug' => bp_current_action() ), 'and', 'name' );
557
+
558
+ if ( $component_subnav_name ) {
559
+ $component_subnav_name = array_shift( $component_subnav_name );
560
+ } else {
561
+ $component_subnav_name = '';
562
+ }
563
+
564
+ } else {
565
+ $component_subnav_name = '';
566
+ }
567
+
568
+ // If on the user profile's landing page, just use the fullname
569
+ if ( bp_is_current_component( $bp->default_component ) && bp_get_requested_url() === bp_displayed_user_domain() ) {
570
+ $title = bp_get_displayed_user_fullname();
571
+
572
+ // Use component name on member pages
573
+ } else {
574
+ // If we have a subnav name, add it separately for localization
575
+ if ( ! empty( $component_subnav_name ) ) {
576
+ // translators: construct the page title. 1 = user name, 2 = component name, 3 = separator, 4 = component subnav name
577
+ $title = strip_tags( sprintf( __( '%1$s %3$s %2$s %3$s %4$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep, $component_subnav_name ) );
578
+
579
+ } else {
580
+ // translators: construct the page title. 1 = user name, 2 = component name, 3 = separator
581
+ $title = strip_tags( sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep ) );
582
+ }
583
+ }
584
 
585
  // A single group
586
+ } elseif ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) && ! empty( $bp->bp_options_nav[ $bp->groups->current_group->slug ] ) ) {
587
+ $subnav = isset( $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] ) ? $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] : '';
588
+ // translators: 1 = group name, 2 = group nav section name, 3 = separator
589
+ $title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $subnav, $sep );
590
 
591
  // A single item from a component other than groups
592
  } elseif ( bp_is_single_item() ) {
593
+ // translators: 1 = component item name, 2 = component nav section name, 3 = separator
594
+ $title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'], $sep );
595
 
596
  // An index or directory
597
  } elseif ( bp_is_directory() ) {
 
598
  $current_component = bp_current_component();
599
 
600
  // No current component (when does this happen?)
646
 
647
  // We use information stored in the CSS class to determine what kind of
648
  // menu item this is, and how it should be treated
649
+ preg_match( '/\sbp-(.*)-nav/', implode( ' ', $menu_item->classes), $matches );
650
 
651
  // If this isn't a BP menu item, we can stop here
652
  if ( empty( $matches[1] ) ) {
725
  * @return string
726
  */
727
  function bp_filter_metaid_column_name( $q ) {
728
+ /*
729
+ * Replace quoted content with __QUOTE__ to avoid false positives.
730
+ * This regular expression will match nested quotes.
731
+ */
732
+ $quoted_regex = "/'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'/s";
733
+ preg_match_all( $quoted_regex, $q, $quoted_matches );
734
+ $q = preg_replace( $quoted_regex, '__QUOTE__', $q );
735
+
736
+ $q = str_replace( 'meta_id', 'id', $q );
737
+
738
+ // Put quoted content back into the string.
739
+ if ( ! empty( $quoted_matches[0] ) ) {
740
+ for ( $i = 0; $i < count( $quoted_matches[0] ); $i++ ) {
741
+ $quote_pos = strpos( $q, '__QUOTE__' );
742
+ $q = substr_replace( $q, $quoted_matches[0][ $i ], $quote_pos, 9 );
743
+ }
744
+ }
745
+
746
+ return $q;
747
  }
748
 
749
  /**
763
 
764
  return $edit_link;
765
  }
766
+
767
+ /**
768
+ * Should BuddyPress load the mentions scripts and related assets, including results to prime the
769
+ * mentions suggestions?
770
+ *
771
+ * @param bool $load_mentions True to load mentions assets, false otherwise.
772
+ * @param bool $mentions_enabled True if mentions are enabled.
773
+ * @return bool True if mentions scripts should be loaded.
774
+ * @since BuddyPress (2.2.0)
775
+ */
776
+ function bp_maybe_load_mentions_scripts_for_blog_content( $load_mentions, $mentions_enabled ) {
777
+ if ( ! $mentions_enabled ) {
778
+ return $load_mentions;
779
+ }
780
+
781
+ if ( $load_mentions || ( bp_is_blog_page() && is_singular() && comments_open() ) ) {
782
+ return true;
783
+ }
784
+
785
+ return $load_mentions;
786
+ }
787
+ add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bp_maybe_load_mentions_scripts_for_blog_content', 10, 2 );
bp-core/bp-core-functions.php CHANGED
@@ -93,39 +93,40 @@ function bp_core_get_table_prefix() {
93
  }
94
 
95
  /**
96
- * Sort an array of objects or arrays by alphabetically sorting by a specific key/property.
97
- *
98
- * For instance, if you have an array of WordPress post objects, you can sort
99
- * them by post_name as follows:
100
- * $sorted_posts = bp_alpha_sort_by_key( $posts, 'post_name' );
101
  *
102
  * The main purpose for this function is so that you can avoid having to create
103
  * your own awkward callback function for usort().
104
  *
105
- * @since BuddyPress (1.9.0)
106
  *
107
- * @param array $items The array to be sorted. Its constituent items can be
108
- * either associative arrays or objects.
109
- * @param string|int $key The array index or property name to sort by.
110
- * @return array $items The sorted array.
111
  */
112
- function bp_alpha_sort_by_key( $items, $key ) {
113
  usort( $items, create_function( '$a, $b', '
114
  $values = array( 0 => false, 1 => false, );
115
  $func_args = func_get_args();
116
  foreach ( $func_args as $indexi => $index ) {
117
  if ( isset( $index->' . $key . ' ) ) {
118
  $values[ $indexi ] = $index->' . $key . ';
119
- } else if ( isset( $index["' . $key . '"] ) ) {
120
  $values[ $indexi ] = $index["' . $key . '"];
121
  }
122
  }
123
 
124
- if ( $values[0] && $values[1] ) {
125
- $cmp = strcmp( $values[0], $values[1] );
 
 
 
 
 
126
  if ( 0 > $cmp ) {
127
  $retval = -1;
128
- } else if ( 0 < $cmp ) {
129
  $retval = 1;
130
  } else {
131
  $retval = 0;
@@ -139,6 +140,23 @@ function bp_alpha_sort_by_key( $items, $key ) {
139
  return $items;
140
  }
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  /**
143
  * Format numbers the BuddyPress way.
144
  *
@@ -323,7 +341,7 @@ function bp_use_wp_admin_bar() {
323
  // Default to true (to avoid loading deprecated BuddyBar code)
324
  $use_admin_bar = true;
325
 
326
- // Has the WP Toolbar constant been explicity opted into?
327
  if ( defined( 'BP_USE_WP_ADMIN_BAR' ) ) {
328
  $use_admin_bar = (bool) BP_USE_WP_ADMIN_BAR;
329
 
@@ -381,7 +399,16 @@ function bp_core_get_directory_page_ids() {
381
  if ( !empty( $page_ids ) && is_array( $page_ids ) ) {
382
  foreach( (array) $page_ids as $component_name => $page_id ) {
383
  if ( empty( $component_name ) || empty( $page_id ) ) {
384
- unset( $page_ids[$component_name] );
 
 
 
 
 
 
 
 
 
385
  }
386
  }
387
  }
@@ -566,6 +593,25 @@ function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
566
  }
567
  }
568
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  /**
570
  * Create a default component slug from a WP page root_slug.
571
  *
@@ -1281,7 +1327,7 @@ function bp_use_embed_in_activity() {
1281
  }
1282
 
1283
  /**
1284
- * Are oembeds allwoed in activity replies?
1285
  *
1286
  * @since BuddyPress (1.5.0)
1287
  *
@@ -1700,17 +1746,23 @@ function bp_is_get_request() {
1700
  * @return bool True on success, false on failure.
1701
  */
1702
  function bp_core_load_buddypress_textdomain() {
1703
- // Try to load via load_plugin_textdomain() first, for future
1704
- // wordpress.org translation downloads
1705
- if ( load_plugin_textdomain( 'buddypress', false, 'buddypress/bp-languages' ) ) {
1706
- return true;
1707
- }
1708
-
1709
- // Nothing found in bp-languages, so try to load from WP_LANG_DIR
1710
- $locale = apply_filters( 'buddypress_locale', get_locale() );
1711
- $mofile = WP_LANG_DIR . '/buddypress-' . $locale . '.mo';
 
 
 
 
 
1712
 
1713
- return load_textdomain( 'buddypress', $mofile );
 
1714
  }
1715
  add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
1716
 
@@ -1860,7 +1912,6 @@ function bp_nav_menu_get_loggedin_pages() {
1860
  $page_args = array();
1861
 
1862
  foreach ( $bp_menu_items as $bp_item ) {
1863
- $item_name = '';
1864
 
1865
  // Remove <span>number</span>
1866
  $item_name = preg_replace( '/([.0-9]+)/', '', $bp_item['name'] );
@@ -1999,7 +2050,7 @@ function bp_nav_menu_get_item_url( $slug ) {
1999
  * @since BuddyPress (2.1.0)
2000
  */
2001
  function bp_core_get_suggestions( $args ) {
2002
- $args = wp_parse_args( $args );
2003
 
2004
  if ( ! $args['type'] ) {
2005
  return new WP_Error( 'missing_parameter' );
@@ -2034,4 +2085,4 @@ function bp_core_get_suggestions( $args ) {
2034
  }
2035
 
2036
  return apply_filters( 'bp_core_get_suggestions', $retval, $args );
2037
- }
93
  }
94
 
95
  /**
96
+ * Sort an array of objects or arrays by a specific key/property.
 
 
 
 
97
  *
98
  * The main purpose for this function is so that you can avoid having to create
99
  * your own awkward callback function for usort().
100
  *
101
+ * @since BuddyPress (2.2.0)
102
  *
103
+ * @param array $items The items to be sorted. Its constituent items can be either associative arrays or objects.
104
+ * @param string|int $key The array index or property name to sort by.
105
+ * @param string $type Sort type. 'alpha' for alphabetical, 'num' for numeric. Default: 'alpha'.
106
+ * @return array $items The sorted array.
107
  */
108
+ function bp_sort_by_key( $items, $key, $type = 'alpha' ) {
109
  usort( $items, create_function( '$a, $b', '
110
  $values = array( 0 => false, 1 => false, );
111
  $func_args = func_get_args();
112
  foreach ( $func_args as $indexi => $index ) {
113
  if ( isset( $index->' . $key . ' ) ) {
114
  $values[ $indexi ] = $index->' . $key . ';
115
+ } elseif ( isset( $index["' . $key . '"] ) ) {
116
  $values[ $indexi ] = $index["' . $key . '"];
117
  }
118
  }
119
 
120
+ if ( isset( $values[0], $values[1] ) ) {
121
+ if ( "num" === "' . $type . '" ) {
122
+ $cmp = $values[0] - $values[1];
123
+ } else {
124
+ $cmp = strcmp( $values[0], $values[1] );
125
+ }
126
+
127
  if ( 0 > $cmp ) {
128
  $retval = -1;
129
+ } elseif ( 0 < $cmp ) {
130
  $retval = 1;
131
  } else {
132
  $retval = 0;
140
  return $items;
141
  }
142
 
143
+ /**
144
+ * Sort an array of objects or arrays by alphabetically sorting by a specific key/property.
145
+ *
146
+ * For instance, if you have an array of WordPress post objects, you can sort
147
+ * them by post_name as follows:
148
+ * $sorted_posts = bp_alpha_sort_by_key( $posts, 'post_name' );
149
+ *
150
+ * @since BuddyPress (1.9.0)
151
+ *
152
+ * @param array $items The items to be sorted. Its constituent items can be either associative arrays or objects.
153
+ * @param string|int $key The array index or property name to sort by.
154
+ * @return array $items The sorted array.
155
+ */
156
+ function bp_alpha_sort_by_key( $items, $key ) {
157
+ return bp_sort_by_key( $items, $key, 'alpha' );
158
+ }
159
+
160
  /**
161
  * Format numbers the BuddyPress way.
162
  *
341
  // Default to true (to avoid loading deprecated BuddyBar code)
342
  $use_admin_bar = true;
343
 
344
+ // Has the WP Toolbar constant been explicitly opted into?
345
  if ( defined( 'BP_USE_WP_ADMIN_BAR' ) ) {
346
  $use_admin_bar = (bool) BP_USE_WP_ADMIN_BAR;
347
 
399
  if ( !empty( $page_ids ) && is_array( $page_ids ) ) {
400
  foreach( (array) $page_ids as $component_name => $page_id ) {
401
  if ( empty( $component_name ) || empty( $page_id ) ) {
402
+ unset( $page_ids[ $component_name ] );
403
+ }
404
+
405
+ // 'register' and 'activate' do not have components, but should be whitelisted.
406
+ if ( bp_get_signup_allowed() && ( 'register' === $component_name || 'activate' === $component_name ) ) {
407
+ continue;
408
+ }
409
+
410
+ if ( ! bp_is_active( $component_name ) || 'trash' == get_post_status( $page_id ) ) {
411
+ unset( $page_ids[ $component_name ] );
412
  }
413
  }
414
  }
593
  }
594
  }
595
 
596
+ /**
597
+ * Remove the entry from bp_pages when the corresponding WP page is deleted.
598
+ *
599
+ * @since BuddyPress (2.2.0)
600
+ *
601
+ * @param int $post_id Post ID.
602
+ */
603
+ function bp_core_on_directory_page_delete( $post_id ) {
604
+ $page_ids = bp_core_get_directory_page_ids();
605
+ $component_name = array_search( $post_id, $page_ids );
606
+
607
+ if ( ! empty( $component_name ) ) {
608
+ unset( $page_ids[ $component_name ] );
609
+ }
610
+
611
+ bp_core_update_directory_page_ids( $page_ids );
612
+ }
613
+ add_action( 'delete_post', 'bp_core_on_directory_page_delete' );
614
+
615
  /**
616
  * Create a default component slug from a WP page root_slug.
617
  *
1327
  }
1328
 
1329
  /**
1330
+ * Are oembeds allowed in activity replies?
1331
  *
1332
  * @since BuddyPress (1.5.0)
1333
  *
1746
  * @return bool True on success, false on failure.
1747
  */
1748
  function bp_core_load_buddypress_textdomain() {
1749
+ $domain = 'buddypress';
1750
+ $mofile_custom = sprintf( '%s-%s.mo', $domain, apply_filters( 'buddypress_locale', get_locale() ) );
1751
+
1752
+ $locations = apply_filters( 'buddypress_locale_locations', array(
1753
+ trailingslashit( WP_LANG_DIR . '/' . $domain ),
1754
+ trailingslashit( WP_LANG_DIR ),
1755
+ ) );
1756
+
1757
+ // Try custom locations in WP_LANG_DIR
1758
+ foreach ( $locations as $location ) {
1759
+ if ( load_textdomain( 'buddypress', $location . $mofile_custom ) ) {
1760
+ return true;
1761
+ }
1762
+ }
1763
 
1764
+ // default to WP and glotpress
1765
+ return load_plugin_textdomain( $domain );
1766
  }
1767
  add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
1768
 
1912
  $page_args = array();
1913
 
1914
  foreach ( $bp_menu_items as $bp_item ) {
 
1915
 
1916
  // Remove <span>number</span>
1917
  $item_name = preg_replace( '/([.0-9]+)/', '', $bp_item['name'] );
2050
  * @since BuddyPress (2.1.0)
2051
  */
2052
  function bp_core_get_suggestions( $args ) {
2053
+ $args = bp_parse_args( $args, array(), 'get_suggestions' );
2054
 
2055
  if ( ! $args['type'] ) {
2056
  return new WP_Error( 'missing_parameter' );
2085
  }
2086
 
2087
  return apply_filters( 'bp_core_get_suggestions', $retval, $args );
2088
+ }
bp-core/bp-core-loader.php CHANGED
@@ -34,7 +34,7 @@ class BP_Core extends BP_Component {
34
  /**
35
  * Populate the global data needed before BuddyPress can continue.
36
  *
37
- * This involves figuring out the currently required, active, deactive,
38
  * and optional components.
39
  *
40
  * @since BuddyPress (1.5.0)
@@ -251,6 +251,21 @@ class BP_Core extends BP_Component {
251
  parent::setup_nav( $main_nav, $sub_nav );
252
  }
253
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
 
256
  /**
34
  /**
35
  * Populate the global data needed before BuddyPress can continue.
36
  *
37
+ * This involves figuring out the currently required, activated, deactivated,
38
  * and optional components.
39
  *
40
  * @since BuddyPress (1.5.0)
251
  parent::setup_nav( $main_nav, $sub_nav );
252
  }
253
  }
254
+
255
+ /**
256
+ * Setup cache groups
257
+ *
258
+ * @since BuddyPress (2.2.0)
259
+ */
260
+ public function setup_cache_groups() {
261
+
262
+ // Global groups
263
+ wp_cache_add_global_groups( array(
264
+ 'bp'
265
+ ) );
266
+
267
+ parent::setup_cache_groups();
268
+ }
269
  }
270
 
271
  /**
bp-core/bp-core-options.php CHANGED
@@ -435,7 +435,7 @@ function bp_core_get_root_options() {
435
  /** Active? *******************************************************************/
436
 
437
  /**
438
- * Is profile sycing disabled?
439
  *
440
  * @since BuddyPress (1.6.0)
441
  *
435
  /** Active? *******************************************************************/
436
 
437
  /**
438
+ * Is profile syncing disabled?
439
  *
440
  * @since BuddyPress (1.6.0)
441
  *
bp-core/bp-core-taxonomy.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * BuddyPress taxonomy functions.
5
+ *
6
+ * Most BuddyPress taxonomy functions are wrappers for their WordPress counterparts.
7
+ * Because BuddyPress can be activated in various ways in a network environment, we
8
+ * must switch to the root blog before using the WP functions.
9
+ *
10
+ * @since BuddyPress (2.2.0)
11
+ */
12
+
13
+ /**
14
+ * Register our default taxonomies.
15
+ *
16
+ * @since BuddyPress (2.2.0)
17
+ */
18
+ function bp_register_default_taxonomies() {
19
+ // Member Type.
20
+ register_taxonomy( 'bp_member_type', 'user', array(
21
+ 'public' => false,
22
+ ) );
23
+ }
24
+ add_action( 'bp_register_taxonomies', 'bp_register_default_taxonomies' );
25
+
26
+ /**
27
+ * Set taxonomy terms on a BuddyPress object.
28
+ *
29
+ * @since BuddyPress (2.2.0)
30
+ *
31
+ * @see wp_set_object_terms() for a full description of function and parameters.
32
+ *
33
+ * @param int $object_id Object ID.
34
+ * @param string|array $terms Term or terms to set.
35
+ * @param string $taxonomy Taxonomy name.
36
+ * @param bool $append Optional. True to append terms to existing terms. Default: false.
37
+ * @return array Array of term taxonomy IDs.
38
+ */
39
+ function bp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
40
+ if ( ! bp_is_root_blog() ) {
41
+ switch_to_blog( bp_get_root_blog_id() );
42
+ }
43
+
44
+ $retval = wp_set_object_terms( $object_id, $terms, $taxonomy, $append );
45
+
46
+ restore_current_blog();
47
+
48
+ return $retval;
49
+ }
50
+
51
+ /**
52
+ * Get taxonomy terms for a BuddyPress object.
53
+ *
54
+ * @since BuddyPress (2.2.0)
55
+ *
56
+ * @see wp_get_object_terms() for a full description of function and parameters.
57
+ *
58
+ * @param int|array $object_ids ID or IDs of objects.
59
+ * @param string|array $taxonomies Name or names of taxonomies to match.
60
+ * @param array $args See {@see wp_get_object_terms()}.
61
+ * @return array
62
+ */
63
+ function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
64
+ if ( ! bp_is_root_blog() ) {
65
+ switch_to_blog( bp_get_root_blog_id() );
66
+ }
67
+
68
+ $retval = wp_get_object_terms( $object_ids, $taxonomies, $args );
69
+
70
+ restore_current_blog();
71
+
72
+ return $retval;
73
+ }
bp-core/bp-core-template-loader.php CHANGED
@@ -442,6 +442,28 @@ function bp_load_theme_functions() {
442
  * @return array Array of possible root level wrapper template files.
443
  */
444
  function bp_get_theme_compat_templates() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  $templates = array(
446
  'plugin-buddypress.php',
447
  'buddypress.php',
@@ -451,5 +473,15 @@ function bp_get_theme_compat_templates() {
451
  'single.php',
452
  'index.php'
453
  );
 
 
 
 
 
 
 
 
 
 
454
  return bp_get_query_template( 'buddypress', $templates );
455
  }
442
  * @return array Array of possible root level wrapper template files.
443
  */
444
  function bp_get_theme_compat_templates() {
445
+ $page_id = 0;
446
+
447
+ // Get the WordPress Page ID for the current view.
448
+ foreach ( (array) buddypress()->pages as $component => $bp_page ) {
449
+
450
+ // Handles the majority of components.
451
+ if ( bp_is_current_component( $component ) ) {
452
+ $page_id = (int) $bp_page->id;
453
+ }
454
+
455
+ // Stop if not on a user page.
456
+ if ( ! bp_is_user() && ! empty( $page_id ) ) {
457
+ break;
458
+ }
459
+
460
+ // The Members component requires an explicit check due to overlapping components.
461
+ if ( bp_is_user() && 'members' === $component ) {
462
+ $page_id = (int) $bp_page->id;
463
+ break;
464
+ }
465
+ }
466
+
467
  $templates = array(
468
  'plugin-buddypress.php',
469
  'buddypress.php',
473
  'single.php',
474
  'index.php'
475
  );
476
+
477
+ // If the Page has a Page Template set, use that.
478
+ if ( $page_id ) {
479
+ $template_file = get_page_template_slug( $page_id );
480
+
481
+ if ( $template_file ) {
482
+ $templates = array( $template_file );
483
+ }
484
+ }
485
+
486
  return bp_get_query_template( 'buddypress', $templates );
487
  }
bp-core/bp-core-template.php CHANGED
@@ -26,12 +26,13 @@ if ( !defined( 'ABSPATH' ) ) exit;
26
  * @uses bp_get_user_nav() Renders the navigation for a profile of a currently
27
  * viewed user.
28
  */
29
- function bp_get_options_nav() {
30
  $bp = buddypress();
31
 
32
  // If we are looking at a member profile, then the we can use the current
33
  // component as an index. Otherwise we need to use the component's root_slug
34
  $component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() );
 
35
 
36
  if ( ! bp_is_single_item() ) {
37
  if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) {
@@ -40,10 +41,17 @@ function bp_get_options_nav() {
40
  $the_index = $component_index;
41
  }
42
  } else {
43
- if ( !isset( $bp->bp_options_nav[bp_current_item()] ) || count( $bp->bp_options_nav[bp_current_item()] ) < 1 ) {
 
 
 
 
 
 
 
44
  return false;
45
  } else {
46
- $the_index = bp_current_item();
47
  }
48
  }
49
 
@@ -54,7 +62,7 @@ function bp_get_options_nav() {
54
  }
55
 
56
  // If the current action or an action variable matches the nav item id, then add a highlight CSS class.
57
- if ( $subnav_item['slug'] == bp_current_action() ) {
58
  $selected = ' class="current selected"';
59
  } else {
60
  $selected = '';
@@ -64,7 +72,7 @@ function bp_get_options_nav() {
64
  $list_type = bp_is_group() ? 'groups' : 'personal';
65
 
66
  // echo out the final list item
67
- 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 );
68
  }
69
  }
70
 
@@ -483,6 +491,82 @@ function bp_custom_profile_sidebar_boxes() {
483
  do_action( 'bp_custom_profile_sidebar_boxes' );
484
  }
485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  /**
487
  * Create and output a button.
488
  *
@@ -1081,9 +1165,9 @@ function bp_loggedin_user_id() {
1081
  * @param string $component Name of the component being checked.
1082
  * @return bool Returns true if the component matches, or else false.
1083
  */
1084
- function bp_is_current_component( $component ) {
1085
- global $wp_query;
1086
 
 
1087
  $is_current_component = false;
1088
 
1089
  // Always return false if a null value is passed to the function
@@ -1098,6 +1182,7 @@ function bp_is_current_component( $component ) {
1098
 
1099
  $bp = buddypress();
1100
 
 
1101
  if ( ! empty( $bp->current_component ) ) {
1102
 
1103
  // First, check to see whether $component_name and the current
@@ -1138,21 +1223,6 @@ function bp_is_current_component( $component ) {
1138
  }
1139
  }
1140
  }
1141
-
1142
- // Page template fallback check if $bp->current_component is empty
1143
- } elseif ( !is_admin() && is_a( $wp_query, 'WP_Query' ) && is_page() ) {
1144
- global $wp_query;
1145
-
1146
- $page = $wp_query->get_queried_object();
1147
- if ( isset( $page->ID ) ) {
1148
- $custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
1149
- $page_template = $custom_fields[0];
1150
-
1151
- // Component name is in the page template name
1152
- if ( !empty( $page_template ) && strstr( strtolower( $page_template ), strtolower( $component ) ) ) {
1153
- $is_current_component = true;
1154
- }
1155
- }
1156
  }
1157
 
1158
  return apply_filters( 'bp_is_current_component', $is_current_component, $component );
@@ -1931,7 +2001,7 @@ function bp_is_group() {
1931
  if ( ! empty( $retval ) ) {
1932
  $retval = bp_is_groups_component() && groups_get_current_group();
1933
  }
1934
-
1935
  return (bool) $retval;
1936
  }
1937
 
@@ -2360,6 +2430,10 @@ function bp_the_body_class() {
2360
 
2361
  /** Groups ************************************************************/
2362
 
 
 
 
 
2363
  if ( bp_is_group_leave() ) {
2364
  $bp_classes[] = 'leave-group';
2365
  }
26
  * @uses bp_get_user_nav() Renders the navigation for a profile of a currently
27
  * viewed user.
28
  */
29
+ function bp_get_options_nav( $parent_slug = '' ) {
30
  $bp = buddypress();
31
 
32
  // If we are looking at a member profile, then the we can use the current
33
  // component as an index. Otherwise we need to use the component's root_slug
34
  $component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() );
35
+ $selected_item = bp_current_action();
36
 
37
  if ( ! bp_is_single_item() ) {
38
  if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) {
41
  $the_index = $component_index;
42
  }
43
  } else {
44
+ $current_item = bp_current_item();
45
+
46
+ if ( ! empty( $parent_slug ) ) {
47
+ $current_item = $parent_slug;
48
+ $selected_item = bp_action_variable( 0 );
49
+ }
50
+
51
+ if ( !isset( $bp->bp_options_nav[$current_item] ) || count( $bp->bp_options_nav[$current_item] ) < 1 ) {
52
  return false;
53
  } else {
54
+ $the_index = $current_item;
55
  }
56
  }
57
 
62
  }
63
 
64
  // If the current action or an action variable matches the nav item id, then add a highlight CSS class.
65
+ if ( $subnav_item['slug'] == $selected_item ) {
66
  $selected = ' class="current selected"';
67
  } else {
68
  $selected = '';
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
 
491
  do_action( 'bp_custom_profile_sidebar_boxes' );
492
  }
493
 
494
+ /**
495
+ * Output the attributes for a form field.
496
+ *
497
+ * @since BuddyPress (2.2.0)
498
+ *
499
+ * @param string $name The field name to output attributes for.
500
+ * @param array $attributes Array of existing attributes to add.
501
+ */
502
+ function bp_form_field_attributes( $name = '', $attributes = array() ) {
503
+ echo bp_get_form_field_attributes( $name, $attributes );
504
+ }
505
+ /**
506
+ * Get the attributes for a form field.
507
+ *
508
+ * Primarily to add better support for touchscreen devices, but plugin devs
509
+ * can use the 'bp_get_form_field_extra_attributes' filter for further
510
+ * manipulation.
511
+ *
512
+ * @since BuddyPress (2.2.0)
513
+ *
514
+ * @param string $name The field name to get attributes for.
515
+ * @param array $attributes Array of existing attributes to add.
516
+ * @return string
517
+ */
518
+ function bp_get_form_field_attributes( $name = '', $attributes = array() ) {
519
+ $retval = '';
520
+
521
+ if ( empty( $attributes ) ) {
522
+ $attributes = array();
523
+ }
524
+
525
+ $name = strtolower( $name );
526
+
527
+ switch ( $name ) {
528
+ case 'username' :
529
+ case 'blogname' :
530
+ $attributes['autocomplete'] = 'off';
531
+ $attributes['autocapitalize'] = 'none';
532
+ break;
533
+
534
+ case 'email' :
535
+ if ( wp_is_mobile() ) {
536
+ $attributes['autocapitalize'] = 'none';
537
+ }
538
+ break;
539
+
540
+ case 'password' :
541
+ $attributes['spellcheck'] = 'false';
542
+ $attributes['autocomplete'] = 'off';
543
+
544
+ if ( wp_is_mobile() ) {
545
+ $attributes['autocorrect'] = 'false';
546
+ $attributes['autocapitalize'] = 'none';
547
+ }
548
+ break;
549
+ }
550
+
551
+ /**
552
+ * Filter the attributes for a field before rendering output.
553
+ *
554
+ * @since BuddyPress (2.2.0)
555
+ *
556
+ * @param array $attributes The field attributes
557
+ * @param string $name The field name
558
+ */
559
+ $attributes = (array) apply_filters( 'bp_get_form_field_attributes', $attributes, $name );
560
+
561
+ $attributes = array_unique( $attributes );
562
+
563
+ foreach( $attributes as $attr => $value ) {
564
+ $retval .= sprintf( ' %s="%s"', sanitize_key( $attr ), esc_attr( $value ) );
565
+ }
566
+
567
+ return $retval;
568
+ }
569
+
570
  /**
571
  * Create and output a button.
572
  *
1165
  * @param string $component Name of the component being checked.
1166
  * @return bool Returns true if the component matches, or else false.
1167
  */
1168
+ function bp_is_current_component( $component = '' ) {
 
1169
 
1170
+ // Default is no match. We'll check a few places for matches
1171
  $is_current_component = false;
1172
 
1173
  // Always return false if a null value is passed to the function
1182
 
1183
  $bp = buddypress();
1184
 
1185
+ // Only check if BuddyPress found a current_component
1186
  if ( ! empty( $bp->current_component ) ) {
1187
 
1188
  // First, check to see whether $component_name and the current
1223
  }
1224
  }
1225
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1226
  }
1227
 
1228
  return apply_filters( 'bp_is_current_component', $is_current_component, $component );
2001
  if ( ! empty( $retval ) ) {
2002
  $retval = bp_is_groups_component() && groups_get_current_group();
2003
  }
2004
+
2005
  return (bool) $retval;
2006
  }
2007
 
2430
 
2431
  /** Groups ************************************************************/
2432
 
2433
+ if ( bp_is_group() ) {
2434
+ $bp_classes[] = 'group-' . groups_get_current_group()->slug;
2435
+ }
2436
+
2437
  if ( bp_is_group_leave() ) {
2438
  $bp_classes[] = 'leave-group';
2439
  }
bp-core/bp-core-theme-compatibility.php CHANGED
@@ -68,7 +68,7 @@ class BP_Theme_Compat {
68
  /**
69
  * Set up the BuddyPress-specific theme compat methods.
70
  *
71
- * Themes shoud use this method in their constructor.
72
  *
73
  * @since BuddyPress (1.7.0)
74
  */
@@ -155,7 +155,7 @@ function bp_setup_theme_compat( $theme = '' ) {
155
  * Get the ID of the theme package being used.
156
  *
157
  * This can be filtered or set manually. Tricky theme authors can override the
158
- * default and include their own BuddyPress compatability layers for their themes.
159
  *
160
  * @since BuddyPress (1.7.0)
161
  *
@@ -171,7 +171,7 @@ function bp_get_theme_compat_id() {
171
  * Get the name of the theme package being used.
172
  *
173
  * This can be filtered or set manually. Tricky theme authors can override the
174
- * default and include their own BuddyPress compatability layers for their themes.
175
  *
176
  * @since BuddyPress (1.7.0)
177
  *
@@ -187,7 +187,7 @@ function bp_get_theme_compat_name() {
187
  * Get the version of the theme package being used.
188
  *
189
  * This can be filtered or set manually. Tricky theme authors can override the
190
- * default and include their own BuddyPress compatability layers for their themes.
191
  *
192
  * @since BuddyPress (1.7.0)
193
  *
@@ -203,7 +203,7 @@ function bp_get_theme_compat_version() {
203
  * Get the absolute path of the theme package being used.
204
  *
205
  * or set manually. Tricky theme authors can override the default and include
206
- * their own BuddyPress compatability layers for their themes.
207
  *
208
  * @since BuddyPress (1.7.0)
209
  *
@@ -219,7 +219,7 @@ function bp_get_theme_compat_dir() {
219
  * Get the URL of the theme package being used.
220
  *
221
  * This can be filtered, or set manually. Tricky theme authors can override
222
- * the default and include their own BuddyPress compatability layers for their
223
  * themes.
224
  *
225
  * @since BuddyPress (1.7.0)
@@ -286,9 +286,9 @@ function bp_detect_theme_compat_with_current_theme() {
286
  if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
287
  $theme_compat = false;
288
 
289
- // Bruteforce check for a BP template
290
  // Examples are clones of bp-default
291
- } else if ( locate_template( 'members/members-loop.php', false, false ) ) {
292
  $theme_compat = false;
293
  }
294
  }
68
  /**
69
  * Set up the BuddyPress-specific theme compat methods.
70
  *
71
+ * Themes should use this method in their constructor.
72
  *
73
  * @since BuddyPress (1.7.0)
74
  */
155
  * Get the ID of the theme package being used.
156
  *
157
  * This can be filtered or set manually. Tricky theme authors can override the
158
+ * default and include their own BuddyPress compatibility layers for their themes.
159
  *
160
  * @since BuddyPress (1.7.0)
161
  *
171
  * Get the name of the theme package being used.
172
  *
173
  * This can be filtered or set manually. Tricky theme authors can override the
174
+ * default and include their own BuddyPress compatibility layers for their themes.
175
  *
176
  * @since BuddyPress (1.7.0)
177
  *
187
  * Get the version of the theme package being used.
188
  *
189
  * This can be filtered or set manually. Tricky theme authors can override the
190
+ * default and include their own BuddyPress compatibility layers for their themes.
191
  *
192
  * @since BuddyPress (1.7.0)
193
  *
203
  * Get the absolute path of the theme package being used.
204
  *
205
  * or set manually. Tricky theme authors can override the default and include
206
+ * their own BuddyPress compatibility layers for their themes.
207
  *
208
  * @since BuddyPress (1.7.0)
209
  *
219
  * Get the URL of the theme package being used.
220
  *
221
  * This can be filtered, or set manually. Tricky theme authors can override
222
+ * the default and include their own BuddyPress compatibility layers for their
223
  * themes.
224
  *
225
  * @since BuddyPress (1.7.0)
286
  if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
287
  $theme_compat = false;
288
 
289
+ // Brute-force check for a BP template
290
  // Examples are clones of bp-default
291
+ } elseif ( locate_template( 'members/members-loop.php', false, false ) ) {
292
  $theme_compat = false;
293
  }
294
  }
bp-core/bp-core-update.php CHANGED
@@ -241,6 +241,11 @@ function bp_version_updater() {
241
  if ( $raw_db_version < 8311 ) {
242
  bp_update_to_2_0_1();
243
  }
 
 
 
 
 
244
  }
245
 
246
  /** All done! *************************************************************/
@@ -389,6 +394,80 @@ function bp_update_to_2_0_1() {
389
  bp_core_maybe_install_signups();
390
  }
391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  /**
393
  * Redirect user to BP's What's New page on first page load after activation.
394
  *
241
  if ( $raw_db_version < 8311 ) {
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! *************************************************************/
394
  bp_core_maybe_install_signups();
395
  }
396
 
397
+ /**
398
+ * 2.2.0 update routine.
399
+ *
400
+ * - Add messages meta table
401
+ * - Update the component field of the 'new members' activity type
402
+ * - Clean up hidden friendship activities
403
+ *
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
+ }
410
+
411
+ if ( bp_is_active( 'activity' ) ) {
412
+ bp_migrate_new_member_activity_component();
413
+
414
+ if ( bp_is_active( 'friends' ) ) {
415
+ bp_cleanup_friendship_activities();
416
+ }
417
+ }
418
+ }
419
+
420
+ /**
421
+ * Updates the component field for new_members type.
422
+ *
423
+ * @since BuddyPress (2.2.0)
424
+ *
425
+ * @global $wpdb
426
+ * @uses buddypress()
427
+ *
428
+ */
429
+ function bp_migrate_new_member_activity_component() {
430
+ global $wpdb;
431
+ $bp = buddypress();
432
+
433
+ // Update the component for the new_member type
434
+ $wpdb->update(
435
+ // Activity table
436
+ $bp->members->table_name_last_activity,
437
+ array(
438
+ 'component' => $bp->members->id,
439
+ ),
440
+ array(
441
+ 'component' => 'xprofile',
442
+ 'type' => 'new_member',
443
+ ),
444
+ // Data sanitization format
445
+ array(
446
+ '%s',
447
+ ),
448
+ // WHERE sanitization format
449
+ array(
450
+ '%s',
451
+ '%s'
452
+ )
453
+ );
454
+ }
455
+
456
+ /**
457
+ * Remove all hidden friendship activities
458
+ *
459
+ * @since BuddyPress (2.2.0)
460
+ *
461
+ * @uses bp_activity_delete() to delete the corresponding friendship activities
462
+ */
463
+ function bp_cleanup_friendship_activities() {
464
+ bp_activity_delete( array(
465
+ 'component' => buddypress()->friends->id,
466
+ 'type' => 'friendship_created',
467
+ 'hide_sitewide' => true,
468
+ ) );
469
+ }
470
+
471
  /**
472
  * Redirect user to BP's What's New page on first page load after activation.
473
  *
bp-core/bp-core-widgets.php CHANGED
@@ -11,12 +11,11 @@ if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
  * Register bp-core widgets.
 
 
14
  */
15
  function bp_core_register_widgets() {
16
  add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Login_Widget");') );
17
- add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
18
- add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
19
- add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
20
  }
21
  add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
22
 
@@ -137,440 +136,3 @@ class BP_Core_Login_Widget extends WP_Widget {
137
  <?php
138
  }
139
  }
140
-
141
- /**
142
- * Members Widget.
143
- */
144
- class BP_Core_Members_Widget extends WP_Widget {
145
-
146
- /**
147
- * Constructor method.
148
- */
149
- function __construct() {
150
- $widget_ops = array(
151
- 'description' => __( 'A dynamic list of recently active, popular, and newest members', 'buddypress' ),
152
- 'classname' => 'widget_bp_core_members_widget buddypress widget',
153
- );
154
- parent::__construct( false, $name = _x( '(BuddyPress) Members', 'widget name', 'buddypress' ), $widget_ops );
155
-
156
- if ( is_active_widget( false, false, $this->id_base ) && !is_admin() && !is_network_admin() ) {
157
- wp_enqueue_script( 'bp-widget-members' );
158
- }
159
- }
160
-
161
- /**
162
- * Display the Members widget.
163
- *
164
- * @see WP_Widget::widget() for description of parameters.
165
- *
166
- * @param array $args Widget arguments.
167
- * @param array $instance Widget settings, as saved by the user.
168
- */
169
- function widget( $args, $instance ) {
170
-
171
- extract( $args );
172
-
173
- if ( !$instance['member_default'] )
174
- $instance['member_default'] = 'active';
175
-
176
- $title = apply_filters( 'widget_title', $instance['title'] );
177
-
178
- echo $before_widget;
179
-
180
- $title = $instance['link_title'] ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '">' . $title . '</a>' : $title;
181
-
182
- echo $before_title
183
- . $title
184
- . $after_title;
185
-
186
- $members_args = array(
187
- 'user_id' => 0,
188
- 'type' => $instance['member_default'],
189
- 'per_page' => $instance['max_members'],
190
- 'max' => $instance['max_members'],
191
- 'populate_extras' => true,
192
- 'search_terms' => false,
193
- );
194
-
195
- ?>
196
-
197
- <?php if ( bp_has_members( $members_args ) ) : ?>
198
- <div class="item-options" id="members-list-options">
199
- <a href="<?php bp_members_directory_permalink(); ?>" id="newest-members" <?php if ( $instance['member_default'] == 'newest' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ) ?></a>
200
- | <a href="<?php bp_members_directory_permalink(); ?>" id="recently-active-members" <?php if ( $instance['member_default'] == 'active' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ) ?></a>
201
-
202
- <?php if ( bp_is_active( 'friends' ) ) : ?>
203
-
204
- | <a href="<?php bp_members_directory_permalink(); ?>" id="popular-members" <?php if ( $instance['member_default'] == 'popular' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ) ?></a>
205
-
206
- <?php endif; ?>
207
- </div>
208
-
209
- <ul id="members-list" class="item-list">
210
- <?php while ( bp_members() ) : bp_the_member(); ?>
211
- <li class="vcard">
212
- <div class="item-avatar">
213
- <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
214
- </div>
215
-
216
- <div class="item">
217
- <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
218
- <div class="item-meta">
219
- <span class="activity">
220
- <?php
221
- if ( 'newest' == $instance['member_default'] )
222
- bp_member_registered();
223
- if ( 'active' == $instance['member_default'] )
224
- bp_member_last_active();
225
- if ( 'popular' == $instance['member_default'] )
226
- bp_member_total_friend_count();
227
- ?>
228
- </span>
229
- </div>
230
- </div>
231
- </li>
232
-
233
- <?php endwhile; ?>
234
- </ul>
235
- <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
236
- <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr( $instance['max_members'] ); ?>" />
237
-
238
- <?php else: ?>
239
-
240
- <div class="widget-error">
241
- <?php _e('No one has signed up yet!', 'buddypress') ?>
242
- </div>
243
-
244
- <?php endif; ?>
245
-
246
- <?php echo $after_widget; ?>
247
- <?php
248
- }
249
-
250
- /**
251
- * Update the Members widget options.
252
- *
253
- * @param array $new_instance The new instance options.
254
- * @param array $old_instance The old instance options.
255
- * @return array $instance The parsed options to be saved.
256
- */
257
- function update( $new_instance, $old_instance ) {
258
- $instance = $old_instance;
259
-
260
- $instance['title'] = strip_tags( $new_instance['title'] );
261
- $instance['max_members'] = strip_tags( $new_instance['max_members'] );
262
- $instance['member_default'] = strip_tags( $new_instance['member_default'] );
263
- $instance['link_title'] = (bool)$new_instance['link_title'];
264
-
265
- return $instance;
266
- }
267
-
268
- /**
269
- * Output the Members widget options form.
270
- *
271
- * @param $instance Settings for this widget.
272
- */
273
- function form( $instance ) {
274
- $defaults = array(
275
- 'title' => __( 'Members', 'buddypress' ),
276
- 'max_members' => 5,
277
- 'member_default' => 'active',
278
- 'link_title' => false
279
- );
280
- $instance = wp_parse_args( (array) $instance, $defaults );
281
-
282
- $title = strip_tags( $instance['title'] );
283
- $max_members = strip_tags( $instance['max_members'] );
284
- $member_default = strip_tags( $instance['member_default'] );
285
- $link_title = (bool)$instance['link_title'];
286
- ?>
287
-
288
- <p><label for="bp-core-widget-title"><?php _e('Title:', '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>
289
-
290
- <p><label for="<?php echo $this->get_field_name('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 Members directory', 'buddypress' ) ?></label></p>
291
-
292
- <p><label for="bp-core-widget-members-max"><?php _e('Max members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
293
-
294
- <p>
295
- <label for="bp-core-widget-groups-default"><?php _e('Default members to show:', 'buddypress'); ?>
296
- <select name="<?php echo $this->get_field_name( 'member_default' ) ?>">
297
- <option value="newest" <?php if ( $member_default == 'newest' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ) ?></option>
298
- <option value="active" <?php if ( $member_default == 'active' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ) ?></option>
299
- <option value="popular" <?php if ( $member_default == 'popular' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ) ?></option>
300
- </select>
301
- </label>
302
- </p>
303
-
304
- <?php
305
- }
306
- }
307
-
308
- /*** WHO'S ONLINE WIDGET *****************/
309
-
310
- class BP_Core_Whos_Online_Widget extends WP_Widget {
311
-
312
- /**
313
- * Constructor method.
314
- */
315
- function __construct() {
316
- $widget_ops = array(
317
- 'description' => __( 'Profile photos of online users', 'buddypress' ),
318
- 'classname' => 'widget_bp_core_whos_online_widget buddypress widget',
319
- );
320
- parent::__construct( false, $name = _x( "(BuddyPress) Who's Online", 'widget name', 'buddypress' ), $widget_ops );
321
- }
322
-
323
- /**
324
- * Display the Who's Online widget.
325
- *
326
- * @see WP_Widget::widget() for description of parameters.
327
- *
328
- * @param array $args Widget arguments.
329
- * @param array $instance Widget settings, as saved by the user.
330
- */
331
- function widget($args, $instance) {
332
-
333
- extract( $args );
334
-
335
- $title = apply_filters( 'widget_title', $instance['title'] );
336
-
337
- echo $before_widget;
338
- echo $before_title
339
- . $title
340
- . $after_title;
341
-
342
- $members_args = array(
343
- 'user_id' => 0,
344
- 'type' => 'online',
345
- 'per_page' => $instance['max_members'],
346
- 'max' => $instance['max_members'],
347
- 'populate_extras' => true,
348
- 'search_terms' => false,
349
- );
350
-
351
- ?>
352
-
353
- <?php if ( bp_has_members( $members_args ) ) : ?>
354
- <div class="avatar-block">
355
- <?php while ( bp_members() ) : bp_the_member(); ?>
356
- <div class="item-avatar">
357
- <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
358
- </div>
359
- <?php endwhile; ?>
360
- </div>
361
- <?php else: ?>
362
-
363
- <div class="widget-error">
364
- <?php _e( 'There are no users currently online', 'buddypress' ) ?>
365
- </div>
366
-
367
- <?php endif; ?>
368
-
369
- <?php echo $after_widget; ?>
370
- <?php
371
- }
372
-
373
- /**
374
- * Update the Who's Online widget options.
375
- *
376
- * @param array $new_instance The new instance options.
377
- * @param array $old_instance The old instance options.
378
- * @return array $instance The parsed options to be saved.
379
- */
380
- function update( $new_instance, $old_instance ) {
381
- $instance = $old_instance;
382
- $instance['title'] = strip_tags( $new_instance['title'] );
383
- $instance['max_members'] = strip_tags( $new_instance['max_members'] );
384
-
385
- return $instance;
386
- }
387
-
388
- /**
389
- * Output the Who's Online widget options form.
390
- *
391
- * @param $instance Settings for this widget.
392
- */
393
- function form( $instance ) {
394
- $defaults = array(
395
- 'title' => __( "Who's Online", 'buddypress' ),
396
- 'max_members' => 15
397
- );
398
- $instance = wp_parse_args( (array) $instance, $defaults );
399
-
400
- $title = strip_tags( $instance['title'] );
401
- $max_members = strip_tags( $instance['max_members'] );
402
- ?>
403
-
404
- <p><label for="bp-core-widget-title"><?php _e('Title:', '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>
405
-
406
- <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
407
- <?php
408
- }
409
- }
410
-
411
- /*** RECENTLY ACTIVE WIDGET *****************/
412
-
413
- class BP_Core_Recently_Active_Widget extends WP_Widget {
414
-
415
- /**
416
- * Constructor method.
417
- */
418
- function __construct() {
419
- $widget_ops = array(
420
- 'description' => __( 'Profile photos of recently active members', 'buddypress' ),
421
- 'classname' => 'widget_bp_core_recently_active_widget buddypress widget',
422
- );
423
- parent::__construct( false, $name = _x( '(BuddyPress) Recently Active Members', 'widget name', 'buddypress' ), $widget_ops );
424
- }
425
-
426
- /**
427
- * Display the Recently Active widget.
428
- *
429
- * @see WP_Widget::widget() for description of parameters.
430
- *
431
- * @param array $args Widget arguments.
432
- * @param array $instance Widget settings, as saved by the user.
433
- */
434
- function widget( $args, $instance ) {
435
-
436
- extract( $args );
437
-
438
- $title = apply_filters( 'widget_title', $instance['title'] );
439
-
440
- echo $before_widget;
441
- echo $before_title
442
- . $title
443
- . $after_title;
444
-
445
- $members_args = array(
446
- 'user_id' => 0,
447
- 'type' => 'active',
448
- 'per_page' => $instance['max_members'],
449
- 'max' => $instance['max_members'],
450
- 'populate_extras' => true,
451
- 'search_terms' => false,
452
- );
453
-
454
- ?>
455
-
456
- <?php if ( bp_has_members( $members_args ) ) : ?>
457
- <div class="avatar-block">
458
- <?php while ( bp_members() ) : bp_the_member(); ?>
459
- <div class="item-avatar">
460
- <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
461
- </div>
462
- <?php endwhile; ?>
463
- </div>
464
- <?php else: ?>
465
-
466
- <div class="widget-error">
467
- <?php _e( 'There are no recently active members', 'buddypress' ) ?>
468
- </div>
469
-
470
- <?php endif; ?>
471
-
472
- <?php echo $after_widget; ?>
473
- <?php
474
- }
475
-
476
- /**
477
- * Update the Recently Active widget options.
478
- *
479
- * @param array $new_instance The new instance options.
480
- * @param array $old_instance The old instance options.
481
- * @return array $instance The parsed options to be saved.
482
- */
483
- function update( $new_instance, $old_instance ) {
484
- $instance = $old_instance;
485
- $instance['title'] = strip_tags( $new_instance['title'] );
486
- $instance['max_members'] = strip_tags( $new_instance['max_members'] );
487
-
488
- return $instance;
489
- }
490
-
491
- /**
492
- * Output the Recently Active widget options form.
493
- *
494
- * @param $instance Settings for this widget.
495
- */
496
- function form( $instance ) {
497
- $defaults = array(
498
- 'title' => __( 'Recently Active Members', 'buddypress' ),
499
- 'max_members' => 15
500
- );
501
- $instance = wp_parse_args( (array) $instance, $defaults );
502
-
503
- $title = strip_tags( $instance['title'] );
504
- $max_members = strip_tags( $instance['max_members'] );
505
- ?>
506
-
507
- <p><label for="bp-core-widget-members-title"><?php _e('Title:', '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>
508
-
509
- <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
510
- <?php
511
- }
512
- }
513
-
514
- /**
515
- * AJAX request handler for Members widgets.
516
- */
517
- function bp_core_ajax_widget_members() {
518
-
519
- check_ajax_referer( 'bp_core_widget_members' );
520
-
521
- switch ( $_POST['filter'] ) {
522
- case 'newest-members':
523
- $type = 'newest';
524
- break;
525
-
526
- case 'recently-active-members':
527
- $type = 'active';
528
- break;
529
-
530
- case 'popular-members':
531
- if ( bp_is_active( 'friends' ) )
532
- $type = 'popular';
533
- else
534
- $type = 'active';
535
-
536
- break;
537
- }
538
-
539
- $members_args = array(
540
- 'user_id' => 0,
541
- 'type' => $type,
542
- 'per_page' => $_POST['max-members'],
543
- 'max' => $_POST['max-members'],
544
- 'populate_extras' => 1,
545
- 'search_terms' => false,
546
- );
547
-
548
- if ( bp_has_members( $members_args ) ) : ?>
549
- <?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. ?>
550
- <?php while ( bp_members() ) : bp_the_member(); ?>
551
- <li class="vcard">
552
- <div class="item-avatar">
553
- <a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
554
- </div>
555
-
556
- <div class="item">
557
- <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
558
- <?php if ( 'active' == $type ) : ?>
559
- <div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div>
560
- <?php elseif ( 'newest' == $type ) : ?>
561
- <div class="item-meta"><span class="activity"><?php bp_member_registered() ?></span></div>
562
- <?php elseif ( bp_is_active( 'friends' ) ) : ?>
563
- <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div>
564
- <?php endif; ?>
565
- </div>
566
- </li>
567
- <?php endwhile; ?>
568
-
569
- <?php else: ?>
570
- <?php echo "-1[[SPLIT]]<li>"; ?>
571
- <?php _e( 'There were no members found, please try another filter.', 'buddypress' ) ?>
572
- <?php echo "</li>"; ?>
573
- <?php endif;
574
- }
575
- add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' );
576
- add_action( 'wp_ajax_nopriv_widget_members', 'bp_core_ajax_widget_members' );
11
 
12
  /**
13
  * Register bp-core widgets.
14
+ *
15
+ * @since BuddyPress (1.0.0)
16
  */
17
  function bp_core_register_widgets() {
18
  add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Login_Widget");') );
 
 
 
19
  }
20
  add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
21
 
136
  <?php
137
  }
138
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-wpabstraction.php CHANGED
@@ -75,7 +75,7 @@ if ( !is_multisite() ) {
75
  /**
76
  * @see switch_to_blog()
77
  */
78
- function switch_to_blog() {
79
  return bp_get_root_blog_id();
80
  }
81
  }
@@ -93,7 +93,7 @@ if ( !is_multisite() ) {
93
  /**
94
  * @see get_blogs_of_user()
95
  */
96
- function get_blogs_of_user() {
97
  return false;
98
  }
99
  }
@@ -102,7 +102,7 @@ if ( !is_multisite() ) {
102
  /**
103
  * @see update_blog_status()
104
  */
105
- function update_blog_status() {
106
  return true;
107
  }
108
  }
75
  /**
76
  * @see switch_to_blog()
77
  */
78
+ function switch_to_blog( $new_blog, $deprecated = null ) {
79
  return bp_get_root_blog_id();
80
  }
81
  }
93
  /**
94
  * @see get_blogs_of_user()
95
  */
96
+ function get_blogs_of_user( $user_id, $all = false ) {
97
  return false;
98
  }
99
  }
102
  /**
103
  * @see update_blog_status()
104
  */
105
+ function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
106
  return true;
107
  }
108
  }
bp-core/css/admin-bar-rtl.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  #wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img,#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px -5px 0 10px;padding:0;background:#eee;float:none}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{right:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications,#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count{background:#21759B;color:#fff;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:700;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{background:#ddd;color:#333;margin:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert{background-color:#1fb3dd;color:#fff}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications>a{padding:0 .5em}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  #wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img,#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px -5px 0 10px;padding:0;background:#eee;float:none}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{right:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications,#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count{background:#21759B;color:#fff;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:700;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{background:#ddd;color:#333;margin:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert{background-color:#1fb3dd;color:#fff}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications>a{padding:0 .5em}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
bp-core/css/admin-bar.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  #wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img,#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 10px 0 -5px;padding:0;background:#eee;float:none}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{left:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications,#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count{background:#21759B;color:#fff;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:700;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{background:#ddd;color:#333;margin:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert{background-color:#1fb3dd;color:#fff}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications>a{padding:0 .5em}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  #wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img,#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 10px 0 -5px;padding:0;background:#eee;float:none}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{left:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications,#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count{background:#21759B;color:#fff;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:700;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{background:#ddd;color:#333;margin:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert{background-color:#1fb3dd;color:#fff}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications>a{padding:0 .5em}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
bp-core/css/buddybar-rtl.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  body:not(.wp-admin){padding-top:25px!important}#wp-admin-bar{position:fixed;top:0;right:0;height:25px;font-size:11px;width:100%;z-index:9999}#wp-admin-bar .padder{position:relative;padding:0;width:100%;margin:0 auto;background:url(../images/60pc_black.png);height:25px}body#bp-default #wp-admin-bar .padder{max-width:1250px}#wp-admin-bar *{z-index:999}#wp-admin-bar div#admin-bar-logo{position:absolute;top:5px;right:10px}#wp-admin-bar a img{border:none}#wp-admin-bar li{list-style:none;margin:0;padding:0;line-height:100%;text-align:right}#wp-admin-bar li a{padding:7px 15px;color:#eee;text-decoration:none;font-size:11px}#wp-admin-bar li.alt{border:none}#wp-admin-bar li.no-arrow a{padding-left:15px}#wp-admin-bar ul li ul li a span{display:none}#wp-admin-bar li.hover,#wp-admin-bar li:hover{position:static}#admin-bar-logo{float:right;font-weight:700;font-size:11px;padding:5px 8px;margin:0;text-decoration:none;color:#fff}body#bp-default #admin-bar-logo{padding:2px 8px}#wp-admin-bar ul{margin:0;list-style:none;line-height:1;cursor:pointer;height:auto;padding:0}#wp-admin-bar ul li{padding:0 0 0 11px;float:right;position:relative;background:url(../images/admin-menu-arrow.gif) 12% 53% no-repeat}#wp-admin-bar ul li.no-arrow{background:0 0;padding-left:0}#wp-admin-bar ul li ul li{background-image:none}#wp-admin-bar ul li.align-right{position:absolute;left:0}#wp-admin-bar ul li a{display:block}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li.sfhover,#wp-admin-bar ul.main-nav li:hover{background-color:#333}#wp-admin-bar ul li ul{position:absolute;width:185px;right:-999em;margin-right:0;background:#333;border:1px solid #222;-moz-box-shadow:0 4px 8px rgba(0,0,0,.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,.1);-moz-border-radius:3px;-webkit-border-radius:0 0 3px 3px;-moz-border-radius-topleft:0;-moz-border-radius-topright:0}#wp-admin-bar ul li>ul{border-top:none}#wp-admin-bar ul li ul a{color:#eee}#wp-admin-bar ul li ul li{float:right;width:174px;margin:0}#wp-admin-bar ul li ul li:hover a{color:#fff}#wp-admin-bar ul li div.admin-bar-clear{clear:both}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li ul li:hover{background-color:#222}#wp-admin-bar ul li ul ul{margin:-25px 184px 0 0;-moz-border-radius:3px;-webkit-border-radius:3px}#wp-admin-bar ul li ul li:hover ul li a{color:#eee}#wp-admin-bar ul li ul li ul li:hover a{color:#fff}#wp-admin-bar ul li ul li.sfhover ul,#wp-admin-bar ul li ul li:hover ul,#wp-admin-bar ul li.sfhover ul,#wp-admin-bar ul li:hover ul{right:auto}#wp-admin-bar ul li.align-right:hover ul{left:0}#wp-admin-bar li.sfhover ul li ul,#wp-admin-bar ul li:hover ul ul{right:-999em}#wp-admin-bar img.avatar{float:right;margin-left:8px}#wp-admin-bar span.activity{display:block;margin-right:34px;padding:0}#wp-admin-bar ul.author-list li a{height:17px}#wp-admin-bar ul li#bp-adminbar-notifications-menu a span{padding:0 6px;margin-right:2px;background:#fff;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  body:not(.wp-admin){padding-top:25px!important}#wp-admin-bar{position:fixed;top:0;right:0;height:25px;font-size:11px;width:100%;z-index:9999}#wp-admin-bar .padder{position:relative;padding:0;width:100%;margin:0 auto;background:url(../images/60pc_black.png);height:25px}body#bp-default #wp-admin-bar .padder{max-width:1250px}#wp-admin-bar *{z-index:999}#wp-admin-bar div#admin-bar-logo{position:absolute;top:5px;right:10px}#wp-admin-bar a img{border:none}#wp-admin-bar li{list-style:none;margin:0;padding:0;line-height:100%;text-align:right}#wp-admin-bar li a{padding:7px 15px;color:#eee;text-decoration:none;font-size:11px}#wp-admin-bar li.alt{border:none}#wp-admin-bar li.no-arrow a{padding-left:15px}#wp-admin-bar ul li ul li a span{display:none}#wp-admin-bar li.hover,#wp-admin-bar li:hover{position:static}#admin-bar-logo{float:right;font-weight:700;font-size:11px;padding:5px 8px;margin:0;text-decoration:none;color:#fff}body#bp-default #admin-bar-logo{padding:2px 8px}#wp-admin-bar ul{margin:0;list-style:none;line-height:1;cursor:pointer;height:auto;padding:0}#wp-admin-bar ul li{padding:0 0 0 11px;float:right;position:relative;background:url(../images/admin-menu-arrow.gif) 12% 53% no-repeat}#wp-admin-bar ul li.no-arrow{background:0 0;padding-left:0}#wp-admin-bar ul li ul li{background-image:none}#wp-admin-bar ul li.align-right{position:absolute;left:0}#wp-admin-bar ul li a{display:block}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li.sfhover,#wp-admin-bar ul.main-nav li:hover{background-color:#333}#wp-admin-bar ul li ul{position:absolute;width:185px;right:-999em;margin-right:0;background:#333;border:1px solid #222;-moz-box-shadow:0 4px 8px rgba(0,0,0,.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,.1);-moz-border-radius:3px;-webkit-border-radius:0 0 3px 3px;-moz-border-radius-topleft:0;-moz-border-radius-topright:0}#wp-admin-bar ul li>ul{border-top:none}#wp-admin-bar ul li ul a{color:#eee}#wp-admin-bar ul li ul li{float:right;width:174px;margin:0}#wp-admin-bar ul li ul li:hover a{color:#fff}#wp-admin-bar ul li div.admin-bar-clear{clear:both}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li ul li:hover{background-color:#222}#wp-admin-bar ul li ul ul{margin:-25px 184px 0 0;-moz-border-radius:3px;-webkit-border-radius:3px}#wp-admin-bar ul li ul li:hover ul li a{color:#eee}#wp-admin-bar ul li ul li ul li:hover a{color:#fff}#wp-admin-bar ul li ul li.sfhover ul,#wp-admin-bar ul li ul li:hover ul,#wp-admin-bar ul li.sfhover ul,#wp-admin-bar ul li:hover ul{right:auto}#wp-admin-bar ul li.align-right:hover ul{left:0}#wp-admin-bar li.sfhover ul li ul,#wp-admin-bar ul li:hover ul ul{right:-999em}#wp-admin-bar img.avatar{float:right;margin-left:8px}#wp-admin-bar span.activity{display:block;margin-right:34px;padding:0}#wp-admin-bar ul.author-list li a{height:17px}#wp-admin-bar ul li#bp-adminbar-notifications-menu a span{padding:0 6px;margin-right:2px;background:#fff;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
bp-core/css/buddybar.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  body:not(.wp-admin){padding-top:25px!important}#wp-admin-bar{position:fixed;top:0;left:0;height:25px;font-size:11px;width:100%;z-index:9999}#wp-admin-bar .padder{position:relative;padding:0;width:100%;margin:0 auto;background:url(../images/60pc_black.png);height:25px}body#bp-default #wp-admin-bar .padder{max-width:1250px}#wp-admin-bar *{z-index:999}#wp-admin-bar div#admin-bar-logo{position:absolute;top:5px;left:10px}#wp-admin-bar a img{border:none}#wp-admin-bar li{list-style:none;margin:0;padding:0;line-height:100%;text-align:left}#wp-admin-bar li a{padding:7px 15px;color:#eee;text-decoration:none;font-size:11px}#wp-admin-bar li.alt{border:none}#wp-admin-bar li.no-arrow a{padding-right:15px}#wp-admin-bar ul li ul li a span{display:none}#wp-admin-bar li.hover,#wp-admin-bar li:hover{position:static}#admin-bar-logo{float:left;font-weight:700;font-size:11px;padding:5px 8px;margin:0;text-decoration:none;color:#fff}body#bp-default #admin-bar-logo{padding:2px 8px}#wp-admin-bar ul{margin:0;list-style:none;line-height:1;cursor:pointer;height:auto;padding:0}#wp-admin-bar ul li{padding:0 11px 0 0;float:left;position:relative;background:url(../images/admin-menu-arrow.gif) 88% 53% no-repeat}#wp-admin-bar ul li.no-arrow{background:0 0;padding-right:0}#wp-admin-bar ul li ul li{background-image:none}#wp-admin-bar ul li.align-right{position:absolute;right:0}#wp-admin-bar ul li a{display:block}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li.sfhover,#wp-admin-bar ul.main-nav li:hover{background-color:#333}#wp-admin-bar ul li ul{position:absolute;width:185px;left:-999em;margin-left:0;background:#333;border:1px solid #222;-moz-box-shadow:0 4px 8px rgba(0,0,0,.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,.1);-moz-border-radius:3px;-webkit-border-radius:0 0 3px 3px;-moz-border-radius-topleft:0;-moz-border-radius-topright:0}#wp-admin-bar ul li>ul{border-top:none}#wp-admin-bar ul li ul a{color:#eee}#wp-admin-bar ul li ul li{float:left;width:174px;margin:0}#wp-admin-bar ul li ul li:hover a{color:#fff}#wp-admin-bar ul li div.admin-bar-clear{clear:both}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li ul li:hover{background-color:#222}#wp-admin-bar ul li ul ul{margin:-25px 0 0 184px;-moz-border-radius:3px;-webkit-border-radius:3px}#wp-admin-bar ul li ul li:hover ul li a{color:#eee}#wp-admin-bar ul li ul li ul li:hover a{color:#fff}#wp-admin-bar ul li ul li.sfhover ul,#wp-admin-bar ul li ul li:hover ul,#wp-admin-bar ul li.sfhover ul,#wp-admin-bar ul li:hover ul{left:auto}#wp-admin-bar ul li.align-right:hover ul{right:0}#wp-admin-bar li.sfhover ul li ul,#wp-admin-bar ul li:hover ul ul{left:-999em}#wp-admin-bar img.avatar{float:left;margin-right:8px}#wp-admin-bar span.activity{display:block;margin-left:34px;padding:0}#wp-admin-bar ul.author-list li a{height:17px}#wp-admin-bar ul li#bp-adminbar-notifications-menu a span{padding:0 6px;margin-left:2px;background:#fff;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  body:not(.wp-admin){padding-top:25px!important}#wp-admin-bar{position:fixed;top:0;left:0;height:25px;font-size:11px;width:100%;z-index:9999}#wp-admin-bar .padder{position:relative;padding:0;width:100%;margin:0 auto;background:url(../images/60pc_black.png);height:25px}body#bp-default #wp-admin-bar .padder{max-width:1250px}#wp-admin-bar *{z-index:999}#wp-admin-bar div#admin-bar-logo{position:absolute;top:5px;left:10px}#wp-admin-bar a img{border:none}#wp-admin-bar li{list-style:none;margin:0;padding:0;line-height:100%;text-align:left}#wp-admin-bar li a{padding:7px 15px;color:#eee;text-decoration:none;font-size:11px}#wp-admin-bar li.alt{border:none}#wp-admin-bar li.no-arrow a{padding-right:15px}#wp-admin-bar ul li ul li a span{display:none}#wp-admin-bar li.hover,#wp-admin-bar li:hover{position:static}#admin-bar-logo{float:left;font-weight:700;font-size:11px;padding:5px 8px;margin:0;text-decoration:none;color:#fff}body#bp-default #admin-bar-logo{padding:2px 8px}#wp-admin-bar ul{margin:0;list-style:none;line-height:1;cursor:pointer;height:auto;padding:0}#wp-admin-bar ul li{padding:0 11px 0 0;float:left;position:relative;background:url(../images/admin-menu-arrow.gif) 88% 53% no-repeat}#wp-admin-bar ul li.no-arrow{background:0 0;padding-right:0}#wp-admin-bar ul li ul li{background-image:none}#wp-admin-bar ul li.align-right{position:absolute;right:0}#wp-admin-bar ul li a{display:block}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li.sfhover,#wp-admin-bar ul.main-nav li:hover{background-color:#333}#wp-admin-bar ul li ul{position:absolute;width:185px;left:-999em;margin-left:0;background:#333;border:1px solid #222;-moz-box-shadow:0 4px 8px rgba(0,0,0,.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,.1);-moz-border-radius:3px;-webkit-border-radius:0 0 3px 3px;-moz-border-radius-topleft:0;-moz-border-radius-topright:0}#wp-admin-bar ul li>ul{border-top:none}#wp-admin-bar ul li ul a{color:#eee}#wp-admin-bar ul li ul li{float:left;width:174px;margin:0}#wp-admin-bar ul li ul li:hover a{color:#fff}#wp-admin-bar ul li div.admin-bar-clear{clear:both}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li ul li:hover{background-color:#222}#wp-admin-bar ul li ul ul{margin:-25px 0 0 184px;-moz-border-radius:3px;-webkit-border-radius:3px}#wp-admin-bar ul li ul li:hover ul li a{color:#eee}#wp-admin-bar ul li ul li ul li:hover a{color:#fff}#wp-admin-bar ul li ul li.sfhover ul,#wp-admin-bar ul li ul li:hover ul,#wp-admin-bar ul li.sfhover ul,#wp-admin-bar ul li:hover ul{left:auto}#wp-admin-bar ul li.align-right:hover ul{right:0}#wp-admin-bar li.sfhover ul li ul,#wp-admin-bar ul li:hover ul ul{left:-999em}#wp-admin-bar img.avatar{float:left;margin-right:8px}#wp-admin-bar span.activity{display:block;margin-left:34px;padding:0}#wp-admin-bar ul.author-list li a{height:17px}#wp-admin-bar ul li#bp-adminbar-notifications-menu a span{padding:0 6px;margin-left:2px;background:#fff;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
bp-core/deprecated/1.9.php CHANGED
@@ -212,7 +212,7 @@ function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $c
212
  /**
213
  * Delete all notifications for a user.
214
  *
215
- * Used when clearing out all notifications for a user, whene deleted or spammed
216
  *
217
  * @deprecated Deprecated since BuddyPress 1.9.0. Use
218
  * bp_notifications_delete_notifications_from_user() instead.
212
  /**
213
  * Delete all notifications for a user.
214
  *
215
+ * Used when clearing out all notifications for a user, when deleted or spammed
216
  *
217
  * @deprecated Deprecated since BuddyPress 1.9.0. Use
218
  * bp_notifications_delete_notifications_from_user() instead.
bp-core/deprecated/2.1.php CHANGED
@@ -170,7 +170,7 @@ function bp_admin_setting_callback_force_buddybar() {
170
 
171
 
172
  /**
173
- * Sanitization for _bp_force_buddyvar
174
  *
175
  * If upgraded to 1.6 and you chose to keep the BuddyBar, a checkbox asks if you want to switch to
176
  * the WP Toolbar. The option we store is 1 if the BuddyBar is forced on, so we use this function
@@ -625,7 +625,7 @@ function bp_blogs_get_subdomain_base() {
625
  }
626
 
627
  /**
628
- * Alledgedly output an avatar upload form, but it hasn't done that since 2009.
629
  *
630
  * @since BuddyPress (1.0.0)
631
  * @deprecated BuddyPress (2.1.0)
170
 
171
 
172
  /**
173
+ * Sanitization for _bp_force_buddybar
174
  *
175
  * If upgraded to 1.6 and you chose to keep the BuddyBar, a checkbox asks if you want to switch to
176
  * the WP Toolbar. The option we store is 1 if the BuddyBar is forced on, so we use this function
625
  }
626
 
627
  /**
628
+ * Allegedly output an avatar upload form, but it hasn't done that since 2009.
629
  *
630
  * @since BuddyPress (1.0.0)
631
  * @deprecated BuddyPress (2.1.0)
bp-core/deprecated/2.2.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Deprecated functions
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Core
7
+ * @deprecated 2.2.0
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ /**
14
+ * Detect a change in post status, and initiate an activity update if necessary.
15
+ *
16
+ * Posts get new activity updates when (a) they are being published, and (b)
17
+ * they have not already been published. This enables proper posting for
18
+ * regular posts as well as scheduled posts, while preventing post bumping.
19
+ *
20
+ * See #4090, #3746, #2546 for background.
21
+ *
22
+ * @since BuddyPress (2.0.0)
23
+ * @deprecated BuddyPress (2.2.0)
24
+ *
25
+ * @todo Support untrashing better
26
+ *
27
+ * @param string $new_status New status for the post.
28
+ * @param string $old_status Old status for the post.
29
+ * @param object $post Post data.
30
+ */
31
+ function bp_blogs_catch_transition_post_status( $new_status, $old_status, $post ) {
32
+ _deprecated_function( __FUNCTION__, '2.2', 'bp_activity_catch_transition_post_type_status()' );
33
+ bp_activity_catch_transition_post_type_status( $new_status, $old_status, $post );
34
+ }
35
+
36
+ /**
37
+ * Record a new blog post in the BuddyPress activity stream.
38
+ *
39
+ * @deprecated BuddyPress (2.2.0)
40
+ *
41
+ * @param int $post_id ID of the post being recorded.
42
+ * @param object $post The WP post object passed to the 'save_post' action.
43
+ * @param int $user_id Optional. The user to whom the activity item will be
44
+ * associated. Defaults to the post_author.
45
+ * @return bool|null Returns false on failure.
46
+ */
47
+ function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
48
+ _deprecated_function( __FUNCTION__, '2.2', 'bp_activity_post_type_publish()' );
49
+ bp_activity_post_type_publish( $post_id, $post, $user_id );
50
+ }
51
+
52
+ /**
53
+ * Updates a blog post's corresponding activity entry during a post edit.
54
+ *
55
+ * @since BuddyPress (2.0.0)
56
+ * @deprecated BuddyPress (2.2.0)
57
+ *
58
+ * @see bp_blogs_catch_transition_post_status()
59
+ *
60
+ * @param WP_Post $post
61
+ */
62
+ function bp_blogs_update_post( $post ) {
63
+ _deprecated_function( __FUNCTION__, '2.2', 'bp_activity_post_type_update()' );
64
+ bp_activity_post_type_update( $post );
65
+ }
66
+
67
+ /**
68
+ * Clear cache when a new blog is created.
69
+ *
70
+ * @since BuddyPress (1.0.0)
71
+ * @deprecated BuddyPress (2.2.0)
72
+ *
73
+ * @param BP_Blogs_Blog $recorded_blog_obj The recorded blog, passed by
74
+ * 'bp_blogs_new_blog'.
75
+ */
76
+ function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
77
+ _deprecated_function( __FUNCTION__, '2.2', 'bp_blogs_clear_blog_object_cache()' );
78
+ bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
79
+ }
80
+
81
+ /**
82
+ * Format 'new_member' activity actions.
83
+ *
84
+ * @since BuddyPress (2.0.0)
85
+ * @deprecated BuddyPress (2.2.0)
86
+ *
87
+ * @param string $action Static activity action.
88
+ * @param object $activity Activity object.
89
+ * @return string
90
+ */
91
+ function bp_xprofile_format_activity_action_new_member( $action, $activity ) {
92
+ _deprecated_function( __FUNCTION__, '2.2', 'bp_members_format_activity_action_new_member()' );
93
+
94
+ $action = apply_filters( 'bp_xprofile_format_activity_action_new_member', $action, $activity );
95
+ return bp_members_format_activity_action_new_member( $action, $activity );
96
+ }
97
+
98
+ /**
99
+ * Add 'bp' to global group of network wide cachable objects.
100
+ *
101
+ * @since BuddyPress (1.1)
102
+ * @deprecated BuddyPress (2.2.0)
103
+ */
104
+ function bp_core_add_global_group() {
105
+ _deprecated_function( __FUNCTION__, '2.2', 'This function has no replacement' );
106
+ }
bp-core/deprecated/css/autocomplete/jquery.autocompletefb-rtl.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  .ac_results{padding:0;overflow:hidden;z-index:99999;background:#fff;border:1px solid #ccc;-moz-border-radius-bottomleft:3px;-khtml-border-bottom-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px;-moz-border-radius-bottomright:3px;-khtml-border-bottom-left-radius:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px}.ac_results ul{width:100%;list-style:none;padding:0;margin:0}.ac_results li{margin:0;padding:5px 10px;cursor:pointer;display:block;font-size:1em;line-height:16px;overflow:hidden}.ac_results li img{margin-left:5px}.ac_odd{background-color:#f0f0f0}.ac_over{background-color:#888;color:#fff}ul.acfb-holder{margin:0;height:auto!important;height:1%;overflow:hidden;padding:0;list-style:none}ul.acfb-holder li{float:right;margin:0 0 4px 5px;list-style-type:none}ul.acfb-holder li.friend-tab{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;border:1px solid #ffe7c7;padding:2px 7px;background:#FFF9DF;font-size:1em}li.friend-tab img.avatar{border-width:2px!important;vertical-align:middle}li.friend-tab span.p{padding-right:5px;font-size:.8em;cursor:pointer}input#send-to-input{width:275px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  .ac_results{padding:0;overflow:hidden;z-index:99999;background:#fff;border:1px solid #ccc;-moz-border-radius-bottomleft:3px;-khtml-border-bottom-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px;-moz-border-radius-bottomright:3px;-khtml-border-bottom-left-radius:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px}.ac_results ul{width:100%;list-style:none;padding:0;margin:0}.ac_results li{margin:0;padding:5px 10px;cursor:pointer;display:block;font-size:1em;line-height:16px;overflow:hidden}.ac_results li img{margin-left:5px}.ac_odd{background-color:#f0f0f0}.ac_over{background-color:#888;color:#fff}ul.acfb-holder{margin:0;height:auto!important;height:1%;overflow:hidden;padding:0;list-style:none}ul.acfb-holder li{float:right;margin:0 0 4px 5px;list-style-type:none}ul.acfb-holder li.friend-tab{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;border:1px solid #ffe7c7;padding:2px 7px;background:#FFF9DF;font-size:1em}li.friend-tab img.avatar{border-width:2px!important;vertical-align:middle}li.friend-tab span.p{padding-right:5px;font-size:.8em;cursor:pointer}input#send-to-input{width:275px}
bp-core/deprecated/css/autocomplete/jquery.autocompletefb.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  .ac_results{padding:0;overflow:hidden;z-index:99999;background:#fff;border:1px solid #ccc;-moz-border-radius-bottomleft:3px;-khtml-border-bottom-left-radius:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-moz-border-radius-bottomright:3px;-khtml-border-bottom-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.ac_results ul{width:100%;list-style:none;padding:0;margin:0}.ac_results li{margin:0;padding:5px 10px;cursor:pointer;display:block;font-size:1em;line-height:16px;overflow:hidden}.ac_results li img{margin-right:5px}.ac_odd{background-color:#f0f0f0}.ac_over{background-color:#888;color:#fff}ul.acfb-holder{margin:0;height:auto!important;height:1%;overflow:hidden;padding:0;list-style:none}ul.acfb-holder li{float:left;margin:0 5px 4px 0;list-style-type:none}ul.acfb-holder li.friend-tab{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;border:1px solid #ffe7c7;padding:2px 7px;background:#FFF9DF;font-size:1em}li.friend-tab img.avatar{border-width:2px!important;vertical-align:middle}li.friend-tab span.p{padding-left:5px;font-size:.8em;cursor:pointer}input#send-to-input{width:275px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  .ac_results{padding:0;overflow:hidden;z-index:99999;background:#fff;border:1px solid #ccc;-moz-border-radius-bottomleft:3px;-khtml-border-bottom-left-radius:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-moz-border-radius-bottomright:3px;-khtml-border-bottom-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.ac_results ul{width:100%;list-style:none;padding:0;margin:0}.ac_results li{margin:0;padding:5px 10px;cursor:pointer;display:block;font-size:1em;line-height:16px;overflow:hidden}.ac_results li img{margin-right:5px}.ac_odd{background-color:#f0f0f0}.ac_over{background-color:#888;color:#fff}ul.acfb-holder{margin:0;height:auto!important;height:1%;overflow:hidden;padding:0;list-style:none}ul.acfb-holder li{float:left;margin:0 5px 4px 0;list-style-type:none}ul.acfb-holder li.friend-tab{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;border:1px solid #ffe7c7;padding:2px 7px;background:#FFF9DF;font-size:1em}li.friend-tab img.avatar{border-width:2px!important;vertical-align:middle}li.friend-tab span.p{padding-left:5px;font-size:.8em;cursor:pointer}input#send-to-input{width:275px}
bp-core/deprecated/js/autocomplete/jquery.autocomplete.js CHANGED
@@ -326,7 +326,7 @@ $.Autocompleter = function(input, options) {
326
  q: lastWord(term),
327
  limit: options.max,
328
  action: 'messages_autocomplete_results',
329
- 'cookie': encodeURIComponent(document.cookie)
330
  }, extraParams),
331
  success: function(data) {
332
  var parsed = options.parse && options.parse(data) || parse(data);
@@ -361,6 +361,29 @@ $.Autocompleter = function(input, options) {
361
  jQuery('#send-to-input').removeClass('loading');
362
  };
363
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  };
365
 
366
  $.Autocompleter.defaults = {
@@ -727,4 +750,4 @@ $.Autocompleter.Selection = function(field, start, end) {
727
  field.focus();
728
  };
729
 
730
- })(jQuery);
326
  q: lastWord(term),
327
  limit: options.max,
328
  action: 'messages_autocomplete_results',
329
+ 'cookie': getAutocompleteCookies()
330
  }, extraParams),
331
  success: function(data) {
332
  var parsed = options.parse && options.parse(data) || parse(data);
361
  jQuery('#send-to-input').removeClass('loading');
362
  };
363
 
364
+ /* Returns a querystring of BP cookies (cookies beginning with 'bp-') */
365
+ function getAutocompleteCookies() {
366
+ var allCookies = document.cookie.split(';'), // get all cookies and split into an array
367
+ bpCookies = {},
368
+ cookiePrefix = 'bp-',
369
+ i, cookie, delimiter, name, value;
370
+
371
+ // loop through cookies
372
+ for (i = 0; i < allCookies.length; i++) {
373
+ cookie = allCookies[i];
374
+ delimiter = cookie.indexOf('=');
375
+ name = jq.trim( unescape( cookie.slice(0, delimiter) ) );
376
+ value = unescape( cookie.slice(delimiter + 1) );
377
+
378
+ // if BP cookie, store it
379
+ if ( name.indexOf(cookiePrefix) === 0 ) {
380
+ bpCookies[name] = value;
381
+ }
382
+ }
383
+
384
+ // returns BP cookies as querystring
385
+ return encodeURIComponent( jq.param(bpCookies) );
386
+ }
387
  };
388
 
389
  $.Autocompleter.defaults = {
750
  field.focus();
751
  };
752
 
753
+ })(jQuery);
bp-core/deprecated/js/autocomplete/jquery.autocomplete.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- !function(a){a.fn.extend({autocomplete:function(b,c){var d="string"==typeof b;return c=a.extend({},a.Autocompleter.defaults,{url:d?b:null,data:d?null:b,delay:d?a.Autocompleter.defaults.delay:10,max:c&&!c.scroll?10:150},c),c.highlight=c.highlight||function(a){return a},this.each(function(){new a.Autocompleter(this,c)})},result:function(a){return this.bind("result",a)},search:function(a){return this.trigger("search",[a])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(a){return this.trigger("setOptions",[a])},unautocomplete:function(){return this.trigger("unautocomplete")}}),a.Autocompleter=function(b,c){function d(){var a=w.selected();if(!a)return!1;var b=a.result;if(s=b,c.multiple){var d=f(r.val());d.length>1&&(b=d.slice(0,d.length-1).join(c.multipleSeparator)+c.multipleSeparator+b),b+=c.multipleSeparator}return r.val(b),j(),r.trigger("result",[a.data,a.value]),!0}function e(a,b){if(p==q.DEL)return void w.hide();var d=r.val();(b||d!=s)&&(s=d,d=g(d),d.length>=c.minChars?(r.addClass(c.loadingClass),jQuery("#send-to-input").addClass("loading"),c.matchCase||(d=d.toLowerCase()),l(d,k,j)):(n(),w.hide()))}function f(b){if(!b)return[""];var d=b.split(a.trim(c.multipleSeparator)),e=[];return a.each(d,function(b,c){a.trim(c)&&(e[b]=a.trim(c))}),e}function g(a){if(!c.multiple)return a;var b=f(a);return b[b.length-1]}function h(d,e){c.autoFill&&g(r.val()).toLowerCase()==d.toLowerCase()&&8!=p&&(r.val(r.val()+e.substring(g(s).length)),a.Autocompleter.Selection(b,s.length,s.length+e.length))}function i(){clearTimeout(o),o=setTimeout(j,200)}function j(){w.hide(),clearTimeout(o),n(),c.mustMatch&&r.search(function(a){a||r.val("")})}function k(a,b){if(b&&b.length&&u){n(),w.display(b,a);var c=b[0].value.split(";");b.value=c[0],h(a,b.value),w.show()}else j()}function l(d,e,f){c.matchCase||(d=d.toLowerCase());var h=t.load(d);if(h&&h.length)e(d,h);else if("string"==typeof c.url&&c.url.length>0){var i={};a.each(c.extraParams,function(a,b){i[a]="function"==typeof b?b():b}),a.ajax({mode:"abort",port:"autocomplete"+b.name,dataType:c.dataType,url:c.url,data:a.extend({q:g(d),limit:c.max,action:"messages_autocomplete_results",cookie:encodeURIComponent(document.cookie)},i),success:function(a){var b=c.parse&&c.parse(a)||m(a);t.add(d,b),e(d,b)}})}else f(d)}function m(b){for(var d=[],e=b.split("\n"),f=0;f<e.length;f++){var g=a.trim(e[f]);g&&(g=g.split("|"),d[d.length]={data:g,value:g[0],result:c.formatResult&&c.formatResult(g,g[0])||g[0]})}return d}function n(){r.removeClass(c.loadingClass),jQuery("#send-to-input").removeClass("loading")}var o,p,q={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34},r=a(b).attr("autocomplete","off").addClass(c.inputClass),s="",t=a.Autocompleter.Cache(c),u=0,v={mouseDownOnSelect:!1},w=a.Autocompleter.Select(c,b,d,v);r.keydown(function(b){switch(p=b.keyCode,b.keyCode){case q.UP:b.preventDefault(),w.visible()?w.prev():e(0,!0);break;case q.DOWN:b.preventDefault(),w.visible()?w.next():e(0,!0);break;case q.PAGEUP:b.preventDefault(),w.visible()?w.pageUp():e(0,!0);break;case q.PAGEDOWN:b.preventDefault(),w.visible()?w.pageDown():e(0,!0);break;case c.multiple&&","==a.trim(c.multipleSeparator)&&q.COMMA:case q.TAB:case q.RETURN:d()&&(c.multiple||r.blur(),b.preventDefault(),r.focus());break;case q.ESC:w.hide();break;default:clearTimeout(o),o=setTimeout(e,c.delay)}}).keypress(function(){}).focus(function(){u++}).blur(function(){u=0,v.mouseDownOnSelect||i()}).click(function(){u++>1&&!w.visible()&&e(0,!0)}).bind("search",function(){function b(a,b){var d;if(b&&b.length)for(var e=0;e<b.length;e++)if(b[e].result.toLowerCase()==a.toLowerCase()){d=b[e];break}"function"==typeof c?c(d):r.trigger("result",d&&[d.data,d.value])}var c=arguments.length>1?arguments[1]:null;a.each(f(r.val()),function(a,c){l(c,b,b)})}).bind("flushCache",function(){t.flush()}).bind("setOptions",function(){a.extend(c,arguments[1]),"data"in arguments[1]&&t.populate()}).bind("unautocomplete",function(){w.unbind(),r.unbind()})},a.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:!1,matchSubset:!0,matchContains:!1,cacheLength:10,max:100,mustMatch:!1,extraParams:{},selectFirst:!0,formatItem:function(a){return a[0]},autoFill:!1,width:0,multiple:!1,multipleSeparator:", ",highlight:function(a,b){return a.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+b.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},scroll:!0,scrollHeight:250,attachTo:"body"},a.Autocompleter.Cache=function(b){function c(a,c){b.matchCase||(a=a.toLowerCase());var d=a.indexOf(c);return-1==d?!1:0==d||b.matchContains}function d(a,c){h>b.cacheLength&&f(),g[a]||h++,g[a]=c}function e(){if(!b.data)return!1;var c={},e=0;b.url||(b.cacheLength=1),c[""]=[];for(var f=0,g=b.data.length;g>f;f++){var h=b.data[f];h="string"==typeof h?[h]:h;var i=b.formatItem(h,f+1,b.data.length);if(i!==!1){var j=i.charAt(0).toLowerCase();c[j]||(c[j]=[]);var k={value:i,data:h,result:b.formatResult&&b.formatResult(h)||i};c[j].push(k),e++<b.max&&c[""].push(k)}}a.each(c,function(a,c){b.cacheLength++,d(a,c)})}function f(){g={},h=0}var g={},h=0;return setTimeout(e,25),{flush:f,add:d,populate:e,load:function(d){if(!b.cacheLength||!h)return null;if(!b.url&&b.matchContains){var e=[];for(var f in g)if(f.length>0){var i=g[f];a.each(i,function(a,b){c(b.value,d)&&e.push(b)})}return e}if(g[d])return g[d];if(b.matchSubset)for(var j=d.length-1;j>=b.minChars;j--){var i=g[d.substr(0,j)];if(i){var e=[];return a.each(i,function(a,b){c(b.value,d)&&(e[e.length]=b)}),e}}return null}}},a.Autocompleter.Select=function(b,c,d,e){function f(){s&&(n=a("<div/>").hide().addClass(b.resultsClass).css("position","absolute").appendTo(b.attachTo),o=a("<ul>").appendTo(n).mouseover(function(b){g(b).nodeName&&"LI"==g(b).nodeName.toUpperCase()&&(q=a("li",o).removeClass(p.ACTIVE).index(g(b)),a(g(b)).addClass(p.ACTIVE))}).click(function(b){return a(g(b)).addClass(p.ACTIVE),d(),c.focus(),!1}).mousedown(function(){e.mouseDownOnSelect=!0}).mouseup(function(){e.mouseDownOnSelect=!1}),b.width>0&&n.css("width",b.width),s=!1)}function g(a){for(var b=a.target;b&&"LI"!=b.tagName;)b=b.parentNode;return b?b:[]}function h(a){l.slice(q,q+1).removeClass(),i(a);var c=l.slice(q,q+1).addClass(p.ACTIVE);if(b.scroll){var d=0;l.slice(0,q).each(function(){d+=this.offsetHeight}),d+c[0].offsetHeight-o.scrollTop()>o[0].clientHeight?o.scrollTop(d+c[0].offsetHeight-o.innerHeight()):d<o.scrollTop()&&o.scrollTop(d)}}function i(a){q+=a,0>q?q=l.size()-1:q>=l.size()&&(q=0)}function j(a){return b.max&&b.max<a?b.max:a}function k(){o.empty();for(var c=j(m.length),d=0;c>d;d++)if(m[d]){var e=b.formatItem(m[d].data,d+1,c,m[d].value,r);if(e!==!1){var f=a("<li>").html(b.highlight(e,r)).addClass(d%2==0?"ac_event":"ac_odd").appendTo(o)[0];a.data(f,"ac_data",m[d])}}l=o.find("li"),b.selectFirst&&(l.slice(0,1).addClass(p.ACTIVE),q=0),o.bgiframe()}var l,m,n,o,p={ACTIVE:"ac_over"},q=-1,r="",s=!0;return{display:function(a,b){f(),m=a,r=b,k()},next:function(){h(1)},prev:function(){h(-1)},pageUp:function(){h(0!=q&&0>q-8?-q:-8)},pageDown:function(){h(q!=l.size()-1&&q+8>l.size()?l.size()-1-q:8)},hide:function(){n&&n.hide(),q=-1},visible:function(){return n&&n.is(":visible")},current:function(){return this.visible()&&(l.filter("."+p.ACTIVE)[0]||b.selectFirst&&l[0])},show:function(){var d=a(c).offset();if(n.css({width:"string"==typeof b.width||b.width>0?b.width:a(c).width(),top:d.top+c.offsetHeight,left:d.left}).show(),b.scroll&&(o.scrollTop(0),o.css({maxHeight:b.scrollHeight,overflow:"auto"}),a.browser.msie&&"undefined"==typeof document.body.style.maxHeight)){var e=0;l.each(function(){e+=this.offsetHeight});var f=e>b.scrollHeight;o.css("height",f?b.scrollHeight:e),f||l.width(o.width()-parseInt(l.css("padding-left"))-parseInt(l.css("padding-right")))}},selected:function(){var b=l&&l.filter("."+p.ACTIVE).removeClass(p.ACTIVE);return b&&b.length&&a.data(b[0],"ac_data")},unbind:function(){n&&n.remove()}}},a.Autocompleter.Selection=function(a,b,c){if(a.createTextRange){var d=a.createTextRange();d.collapse(!0),d.moveStart("character",b),d.moveEnd("character",c),d.select()}else a.setSelectionRange?a.setSelectionRange(b,c):a.selectionStart&&(a.selectionStart=b,a.selectionEnd=c);a.focus()}}(jQuery);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ !function(a){a.fn.extend({autocomplete:function(b,c){var d="string"==typeof b;return c=a.extend({},a.Autocompleter.defaults,{url:d?b:null,data:d?null:b,delay:d?a.Autocompleter.defaults.delay:10,max:c&&!c.scroll?10:150},c),c.highlight=c.highlight||function(a){return a},this.each(function(){new a.Autocompleter(this,c)})},result:function(a){return this.bind("result",a)},search:function(a){return this.trigger("search",[a])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(a){return this.trigger("setOptions",[a])},unautocomplete:function(){return this.trigger("unautocomplete")}}),a.Autocompleter=function(b,c){function d(){var a=x.selected();if(!a)return!1;var b=a.result;if(t=b,c.multiple){var d=f(s.val());d.length>1&&(b=d.slice(0,d.length-1).join(c.multipleSeparator)+c.multipleSeparator+b),b+=c.multipleSeparator}return s.val(b),j(),s.trigger("result",[a.data,a.value]),!0}function e(a,b){if(q==r.DEL)return void x.hide();var d=s.val();(b||d!=t)&&(t=d,d=g(d),d.length>=c.minChars?(s.addClass(c.loadingClass),jQuery("#send-to-input").addClass("loading"),c.matchCase||(d=d.toLowerCase()),l(d,k,j)):(n(),x.hide()))}function f(b){if(!b)return[""];var d=b.split(a.trim(c.multipleSeparator)),e=[];return a.each(d,function(b,c){a.trim(c)&&(e[b]=a.trim(c))}),e}function g(a){if(!c.multiple)return a;var b=f(a);return b[b.length-1]}function h(d,e){c.autoFill&&g(s.val()).toLowerCase()==d.toLowerCase()&&8!=q&&(s.val(s.val()+e.substring(g(t).length)),a.Autocompleter.Selection(b,t.length,t.length+e.length))}function i(){clearTimeout(p),p=setTimeout(j,200)}function j(){x.hide(),clearTimeout(p),n(),c.mustMatch&&s.search(function(a){a||s.val("")})}function k(a,b){if(b&&b.length&&v){n(),x.display(b,a);var c=b[0].value.split(";");b.value=c[0],h(a,b.value),x.show()}else j()}function l(d,e,f){c.matchCase||(d=d.toLowerCase());var h=u.load(d);if(h&&h.length)e(d,h);else if("string"==typeof c.url&&c.url.length>0){var i={};a.each(c.extraParams,function(a,b){i[a]="function"==typeof b?b():b}),a.ajax({mode:"abort",port:"autocomplete"+b.name,dataType:c.dataType,url:c.url,data:a.extend({q:g(d),limit:c.max,action:"messages_autocomplete_results",cookie:o()},i),success:function(a){var b=c.parse&&c.parse(a)||m(a);u.add(d,b),e(d,b)}})}else f(d)}function m(b){for(var d=[],e=b.split("\n"),f=0;f<e.length;f++){var g=a.trim(e[f]);g&&(g=g.split("|"),d[d.length]={data:g,value:g[0],result:c.formatResult&&c.formatResult(g,g[0])||g[0]})}return d}function n(){s.removeClass(c.loadingClass),jQuery("#send-to-input").removeClass("loading")}function o(){var a,b,c,d,e,f=document.cookie.split(";"),g={},h="bp-";for(a=0;a<f.length;a++)b=f[a],c=b.indexOf("="),d=jq.trim(unescape(b.slice(0,c))),e=unescape(b.slice(c+1)),0===d.indexOf(h)&&(g[d]=e);return encodeURIComponent(jq.param(g))}var p,q,r={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34},s=a(b).attr("autocomplete","off").addClass(c.inputClass),t="",u=a.Autocompleter.Cache(c),v=0,w={mouseDownOnSelect:!1},x=a.Autocompleter.Select(c,b,d,w);s.keydown(function(b){switch(q=b.keyCode,b.keyCode){case r.UP:b.preventDefault(),x.visible()?x.prev():e(0,!0);break;case r.DOWN:b.preventDefault(),x.visible()?x.next():e(0,!0);break;case r.PAGEUP:b.preventDefault(),x.visible()?x.pageUp():e(0,!0);break;case r.PAGEDOWN:b.preventDefault(),x.visible()?x.pageDown():e(0,!0);break;case c.multiple&&","==a.trim(c.multipleSeparator)&&r.COMMA:case r.TAB:case r.RETURN:d()&&(c.multiple||s.blur(),b.preventDefault(),s.focus());break;case r.ESC:x.hide();break;default:clearTimeout(p),p=setTimeout(e,c.delay)}}).keypress(function(){}).focus(function(){v++}).blur(function(){v=0,w.mouseDownOnSelect||i()}).click(function(){v++>1&&!x.visible()&&e(0,!0)}).bind("search",function(){function b(a,b){var d;if(b&&b.length)for(var e=0;e<b.length;e++)if(b[e].result.toLowerCase()==a.toLowerCase()){d=b[e];break}"function"==typeof c?c(d):s.trigger("result",d&&[d.data,d.value])}var c=arguments.length>1?arguments[1]:null;a.each(f(s.val()),function(a,c){l(c,b,b)})}).bind("flushCache",function(){u.flush()}).bind("setOptions",function(){a.extend(c,arguments[1]),"data"in arguments[1]&&u.populate()}).bind("unautocomplete",function(){x.unbind(),s.unbind()})},a.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:!1,matchSubset:!0,matchContains:!1,cacheLength:10,max:100,mustMatch:!1,extraParams:{},selectFirst:!0,formatItem:function(a){return a[0]},autoFill:!1,width:0,multiple:!1,multipleSeparator:", ",highlight:function(a,b){return a.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+b.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},scroll:!0,scrollHeight:250,attachTo:"body"},a.Autocompleter.Cache=function(b){function c(a,c){b.matchCase||(a=a.toLowerCase());var d=a.indexOf(c);return-1==d?!1:0==d||b.matchContains}function d(a,c){h>b.cacheLength&&f(),g[a]||h++,g[a]=c}function e(){if(!b.data)return!1;var c={},e=0;b.url||(b.cacheLength=1),c[""]=[];for(var f=0,g=b.data.length;g>f;f++){var h=b.data[f];h="string"==typeof h?[h]:h;var i=b.formatItem(h,f+1,b.data.length);if(i!==!1){var j=i.charAt(0).toLowerCase();c[j]||(c[j]=[]);var k={value:i,data:h,result:b.formatResult&&b.formatResult(h)||i};c[j].push(k),e++<b.max&&c[""].push(k)}}a.each(c,function(a,c){b.cacheLength++,d(a,c)})}function f(){g={},h=0}var g={},h=0;return setTimeout(e,25),{flush:f,add:d,populate:e,load:function(d){if(!b.cacheLength||!h)return null;if(!b.url&&b.matchContains){var e=[];for(var f in g)if(f.length>0){var i=g[f];a.each(i,function(a,b){c(b.value,d)&&e.push(b)})}return e}if(g[d])return g[d];if(b.matchSubset)for(var j=d.length-1;j>=b.minChars;j--){var i=g[d.substr(0,j)];if(i){var e=[];return a.each(i,function(a,b){c(b.value,d)&&(e[e.length]=b)}),e}}return null}}},a.Autocompleter.Select=function(b,c,d,e){function f(){s&&(n=a("<div/>").hide().addClass(b.resultsClass).css("position","absolute").appendTo(b.attachTo),o=a("<ul>").appendTo(n).mouseover(function(b){g(b).nodeName&&"LI"==g(b).nodeName.toUpperCase()&&(q=a("li",o).removeClass(p.ACTIVE).index(g(b)),a(g(b)).addClass(p.ACTIVE))}).click(function(b){return a(g(b)).addClass(p.ACTIVE),d(),c.focus(),!1}).mousedown(function(){e.mouseDownOnSelect=!0}).mouseup(function(){e.mouseDownOnSelect=!1}),b.width>0&&n.css("width",b.width),s=!1)}function g(a){for(var b=a.target;b&&"LI"!=b.tagName;)b=b.parentNode;return b?b:[]}function h(a){l.slice(q,q+1).removeClass(),i(a);var c=l.slice(q,q+1).addClass(p.ACTIVE);if(b.scroll){var d=0;l.slice(0,q).each(function(){d+=this.offsetHeight}),d+c[0].offsetHeight-o.scrollTop()>o[0].clientHeight?o.scrollTop(d+c[0].offsetHeight-o.innerHeight()):d<o.scrollTop()&&o.scrollTop(d)}}function i(a){q+=a,0>q?q=l.size()-1:q>=l.size()&&(q=0)}function j(a){return b.max&&b.max<a?b.max:a}function k(){o.empty();for(var c=j(m.length),d=0;c>d;d++)if(m[d]){var e=b.formatItem(m[d].data,d+1,c,m[d].value,r);if(e!==!1){var f=a("<li>").html(b.highlight(e,r)).addClass(d%2==0?"ac_event":"ac_odd").appendTo(o)[0];a.data(f,"ac_data",m[d])}}l=o.find("li"),b.selectFirst&&(l.slice(0,1).addClass(p.ACTIVE),q=0),o.bgiframe()}var l,m,n,o,p={ACTIVE:"ac_over"},q=-1,r="",s=!0;return{display:function(a,b){f(),m=a,r=b,k()},next:function(){h(1)},prev:function(){h(-1)},pageUp:function(){h(0!=q&&0>q-8?-q:-8)},pageDown:function(){h(q!=l.size()-1&&q+8>l.size()?l.size()-1-q:8)},hide:function(){n&&n.hide(),q=-1},visible:function(){return n&&n.is(":visible")},current:function(){return this.visible()&&(l.filter("."+p.ACTIVE)[0]||b.selectFirst&&l[0])},show:function(){var d=a(c).offset();if(n.css({width:"string"==typeof b.width||b.width>0?b.width:a(c).width(),top:d.top+c.offsetHeight,left:d.left}).show(),b.scroll&&(o.scrollTop(0),o.css({maxHeight:b.scrollHeight,overflow:"auto"}),a.browser.msie&&"undefined"==typeof document.body.style.maxHeight)){var e=0;l.each(function(){e+=this.offsetHeight});var f=e>b.scrollHeight;o.css("height",f?b.scrollHeight:e),f||l.width(o.width()-parseInt(l.css("padding-left"))-parseInt(l.css("padding-right")))}},selected:function(){var b=l&&l.filter("."+p.ACTIVE).removeClass(p.ACTIVE);return b&&b.length&&a.data(b[0],"ac_data")},unbind:function(){n&&n.remove()}}},a.Autocompleter.Selection=function(a,b,c){if(a.createTextRange){var d=a.createTextRange();d.collapse(!0),d.moveStart("character",b),d.moveEnd("character",c),d.select()}else a.setSelectionRange?a.setSelectionRange(b,c):a.selectionStart&&(a.selectionStart=b,a.selectionEnd=c);a.focus()}}(jQuery);
bp-core/deprecated/js/autocomplete/jquery.autocompletefb.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  jQuery.fn.autoCompletefb=function(a){var b=this,c={ul:b,urlLookup:[""],acOptions:{},foundClass:".friend-tab",inputClass:".send-to-input"};a&&jQuery.extend(c,a);var d={params:c,removeFind:function(a){return d.removeUsername(a),jQuery(a).unbind("click").parent().remove(),jQuery(c.inputClass,b).focus(),b.acfb},removeUsername:function(a){var b=a.parentNode.id.substr(a.parentNode.id.indexOf("-")+1);jQuery("#send-to-usernames").removeClass(b)}};return jQuery(c.foundClass+" img.p").click(function(){d.removeFind(this)}),jQuery(c.inputClass,b).autocomplete(c.urlLookup,c.acOptions),jQuery(c.inputClass,b).result(function(a,e,f){var f=c.foundClass.replace(/\./,""),e=String(e).split(" ("),g=e[1].substr(0,e[1].length-1);if(0===jQuery(c.inputClass).siblings("#un-"+g).length){var h="#link-"+g,i=jQuery(h).attr("href"),j='<li class="'+f+'" id="un-'+g+'"><span><a href="'+i+'">'+e[0]+'</a></span> <span class="p">X</span></li>',k=jQuery(c.inputClass,b).before(j);jQuery("#send-to-usernames").addClass(g),jQuery(".p",k[0].previousSibling).click(function(){d.removeFind(this)})}jQuery(c.inputClass,b).val("")}),jQuery(c.inputClass,b).focus(),d};
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  jQuery.fn.autoCompletefb=function(a){var b=this,c={ul:b,urlLookup:[""],acOptions:{},foundClass:".friend-tab",inputClass:".send-to-input"};a&&jQuery.extend(c,a);var d={params:c,removeFind:function(a){return d.removeUsername(a),jQuery(a).unbind("click").parent().remove(),jQuery(c.inputClass,b).focus(),b.acfb},removeUsername:function(a){var b=a.parentNode.id.substr(a.parentNode.id.indexOf("-")+1);jQuery("#send-to-usernames").removeClass(b)}};return jQuery(c.foundClass+" img.p").click(function(){d.removeFind(this)}),jQuery(c.inputClass,b).autocomplete(c.urlLookup,c.acOptions),jQuery(c.inputClass,b).result(function(a,e,f){var f=c.foundClass.replace(/\./,""),e=String(e).split(" ("),g=e[1].substr(0,e[1].length-1);if(0===jQuery(c.inputClass).siblings("#un-"+g).length){var h="#link-"+g,i=jQuery(h).attr("href"),j='<li class="'+f+'" id="un-'+g+'"><span><a href="'+i+'">'+e[0]+'</a></span> <span class="p">X</span></li>',k=jQuery(c.inputClass,b).before(j);jQuery("#send-to-usernames").addClass(g),jQuery(".p",k[0].previousSibling).click(function(){d.removeFind(this)})}jQuery(c.inputClass,b).val("")}),jQuery(c.inputClass,b).focus(),d};
bp-core/deprecated/js/autocomplete/jquery.bgiframe.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){function b(a){return a&&a.constructor===Number?a+"px":a}a.fn.bgiframe=a.browser.msie&&/msie 6\.0/i.test(navigator.userAgent)?function(c){c=a.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:!0,src:"javascript:false;"},c);var d='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+c.src+'"style="display:block;position:absolute;z-index:-1;'+(c.opacity!==!1?"filter:Alpha(Opacity='0');":"")+"top:"+("auto"==c.top?"expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')":b(c.top))+";left:"+("auto"==c.left?"expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')":b(c.left))+";width:"+("auto"==c.width?"expression(this.parentNode.offsetWidth+'px')":b(c.width))+";height:"+("auto"==c.height?"expression(this.parentNode.offsetHeight+'px')":b(c.height))+';"/>';return this.each(function(){0===a(this).children("iframe.bgiframe").length&&this.insertBefore(document.createElement(d),this.firstChild)})}:function(){return this},a.fn.bgIframe=a.fn.bgiframe}(jQuery);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){function b(a){return a&&a.constructor===Number?a+"px":a}a.fn.bgiframe=a.browser.msie&&/msie 6\.0/i.test(navigator.userAgent)?function(c){c=a.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:!0,src:"javascript:false;"},c);var d='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+c.src+'"style="display:block;position:absolute;z-index:-1;'+(c.opacity!==!1?"filter:Alpha(Opacity='0');":"")+"top:"+("auto"==c.top?"expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')":b(c.top))+";left:"+("auto"==c.left?"expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')":b(c.left))+";width:"+("auto"==c.width?"expression(this.parentNode.offsetWidth+'px')":b(c.width))+";height:"+("auto"==c.height?"expression(this.parentNode.offsetHeight+'px')":b(c.height))+';"/>';return this.each(function(){0===a(this).children("iframe.bgiframe").length&&this.insertBefore(document.createElement(d),this.firstChild)})}:function(){return this},a.fn.bgIframe=a.fn.bgiframe}(jQuery);
bp-core/deprecated/js/autocomplete/jquery.dimensions.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){a.dimensions={version:"@VERSION"},a.each(["Height","Width"],function(c,d){a.fn["inner"+d]=function(){if(this[0]){var a="Height"==d?"Top":"Left",c="Height"==d?"Bottom":"Right";return this[d.toLowerCase()]()+b(this,"padding"+a)+b(this,"padding"+c)}},a.fn["outer"+d]=function(c){if(this[0]){var e="Height"==d?"Top":"Left",f="Height"==d?"Bottom":"Right";return c=a.extend({margin:!1},c||{}),this[d.toLowerCase()]()+b(this,"border"+e+"Width")+b(this,"border"+f+"Width")+b(this,"padding"+e)+b(this,"padding"+f)+(c.margin?b(this,"margin"+e)+b(this,"margin"+f):0)}}}),a.each(["Left","Top"],function(b,c){a.fn["scroll"+c]=function(b){return this[0]?void 0!=b?this.each(function(){this==window||this==document?window.scrollTo("Left"==c?b:a(window).scrollLeft(),"Top"==c?b:a(window).scrollTop()):this["scroll"+c]=b}):this[0]==window||this[0]==document?self["Left"==c?"pageXOffset":"pageYOffset"]||a.boxModel&&document.documentElement["scroll"+c]||document.body["scroll"+c]:this[0]["scroll"+c]:void 0}}),a.fn.extend({position:function(){var a,c,d,e,f=this[0];return f&&(d=this.offsetParent(),a=this.offset(),c=d.offset(),a.top-=b(f,"marginTop"),a.left-=b(f,"marginLeft"),c.top+=b(d,"borderTopWidth"),c.left+=b(d,"borderLeftWidth"),e={top:a.top-c.top,left:a.left-c.left}),e},offsetParent:function(){for(var b=this[0].offsetParent;b&&!/^body|html$/i.test(b.tagName)&&"static"==a.css(b,"position");)b=b.offsetParent;return a(b)}});var b=function(b,c){return parseInt(a.css(b.jquery?b[0]:b,c))||0}}(jQuery);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){a.dimensions={version:"@VERSION"},a.each(["Height","Width"],function(c,d){a.fn["inner"+d]=function(){if(this[0]){var a="Height"==d?"Top":"Left",c="Height"==d?"Bottom":"Right";return this[d.toLowerCase()]()+b(this,"padding"+a)+b(this,"padding"+c)}},a.fn["outer"+d]=function(c){if(this[0]){var e="Height"==d?"Top":"Left",f="Height"==d?"Bottom":"Right";return c=a.extend({margin:!1},c||{}),this[d.toLowerCase()]()+b(this,"border"+e+"Width")+b(this,"border"+f+"Width")+b(this,"padding"+e)+b(this,"padding"+f)+(c.margin?b(this,"margin"+e)+b(this,"margin"+f):0)}}}),a.each(["Left","Top"],function(b,c){a.fn["scroll"+c]=function(b){return this[0]?void 0!=b?this.each(function(){this==window||this==document?window.scrollTo("Left"==c?b:a(window).scrollLeft(),"Top"==c?b:a(window).scrollTop()):this["scroll"+c]=b}):this[0]==window||this[0]==document?self["Left"==c?"pageXOffset":"pageYOffset"]||a.boxModel&&document.documentElement["scroll"+c]||document.body["scroll"+c]:this[0]["scroll"+c]:void 0}}),a.fn.extend({position:function(){var a,c,d,e,f=this[0];return f&&(d=this.offsetParent(),a=this.offset(),c=d.offset(),a.top-=b(f,"marginTop"),a.left-=b(f,"marginLeft"),c.top+=b(d,"borderTopWidth"),c.left+=b(d,"borderLeftWidth"),e={top:a.top-c.top,left:a.left-c.left}),e},offsetParent:function(){for(var b=this[0].offsetParent;b&&!/^body|html$/i.test(b.tagName)&&"static"==a.css(b,"position");)b=b.offsetParent;return a(b)}});var b=function(b,c){return parseInt(a.css(b.jquery?b[0]:b,c))||0}}(jQuery);
bp-core/deprecated/js/jquery-scroll-to.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(b){return a.isFunction(b)||"object"==typeof b?b:{top:b,left:b}}var c=a.scrollTo=function(b,c,d){return a(window).scrollTo(b,c,d)};return c.defaults={axis:"xy",duration:parseFloat(a.fn.jquery)>=1.3?0:1,limit:!0},c.window=function(){return a(window)._scrollable()},a.fn._scrollable=function(){return this.map(function(){var b=this,c=!b.nodeName||-1!==a.inArray(b.nodeName.toLowerCase(),["iframe","#document","html","body"]);if(!c)return b;var d=(b.contentWindow||b).document||b.ownerDocument||b;return/webkit/i.test(navigator.userAgent)||"BackCompat"===d.compatMode?d.body:d.documentElement})},a.fn.scrollTo=function(d,e,f){return"object"==typeof e&&(f=e,e=0),"function"==typeof f&&(f={onAfter:f}),"max"===d&&(d=9e9),f=a.extend({},c.defaults,f),e=e||f.duration,f.queue=f.queue&&f.axis.length>1,f.queue&&(e/=2),f.offset=b(f.offset),f.over=b(f.over),this._scrollable().each(function(){function g(a){j.animate(l,e,f.easing,a&&function(){a.call(this,k,f)})}if(null!==d){var h,i=this,j=a(i),k=d,l={},m=j.is("html,body");switch(typeof k){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(k)){k=b(k);break}if(k=m?a(k):a(k,this),!k.length)return;case"object":(k.is||k.style)&&(h=(k=a(k)).offset())}var n=a.isFunction(f.offset)&&f.offset(i,k)||f.offset;a.each(f.axis.split(""),function(a,b){var d="x"===b?"Left":"Top",e=d.toLowerCase(),o="scroll"+d,p=i[o],q=c.max(i,b);if(h)l[o]=h[e]+(m?0:p-j.offset()[e]),f.margin&&(l[o]-=parseInt(k.css("margin"+d))||0,l[o]-=parseInt(k.css("border"+d+"Width"))||0),l[o]+=n[e]||0,f.over[e]&&(l[o]+=k["x"===b?"width":"height"]()*f.over[e]);else{var r=k[e];l[o]=r.slice&&"%"===r.slice(-1)?parseFloat(r)/100*q:r}f.limit&&/^\d+$/.test(l[o])&&(l[o]=l[o]<=0?0:Math.min(l[o],q)),!a&&f.queue&&(p!==l[o]&&g(f.onAfterFirst),delete l[o])}),g(f.onAfter)}}).end()},c.max=function(b,c){var d="x"===c?"Width":"Height",e="scroll"+d;if(!a(b).is("html,body"))return b[e]-a(b)[d.toLowerCase()]();var f="client"+d,g=b.ownerDocument.documentElement,h=b.ownerDocument.body;return Math.max(g[e],h[e])-Math.min(g[f],h[f])},c});
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(b){return a.isFunction(b)||"object"==typeof b?b:{top:b,left:b}}var c=a.scrollTo=function(b,c,d){return a(window).scrollTo(b,c,d)};return c.defaults={axis:"xy",duration:parseFloat(a.fn.jquery)>=1.3?0:1,limit:!0},c.window=function(){return a(window)._scrollable()},a.fn._scrollable=function(){return this.map(function(){var b=this,c=!b.nodeName||-1!==a.inArray(b.nodeName.toLowerCase(),["iframe","#document","html","body"]);if(!c)return b;var d=(b.contentWindow||b).document||b.ownerDocument||b;return/webkit/i.test(navigator.userAgent)||"BackCompat"===d.compatMode?d.body:d.documentElement})},a.fn.scrollTo=function(d,e,f){return"object"==typeof e&&(f=e,e=0),"function"==typeof f&&(f={onAfter:f}),"max"===d&&(d=9e9),f=a.extend({},c.defaults,f),e=e||f.duration,f.queue=f.queue&&f.axis.length>1,f.queue&&(e/=2),f.offset=b(f.offset),f.over=b(f.over),this._scrollable().each(function(){function g(a){j.animate(l,e,f.easing,a&&function(){a.call(this,k,f)})}if(null!==d){var h,i=this,j=a(i),k=d,l={},m=j.is("html,body");switch(typeof k){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(k)){k=b(k);break}if(k=m?a(k):a(k,this),!k.length)return;case"object":(k.is||k.style)&&(h=(k=a(k)).offset())}var n=a.isFunction(f.offset)&&f.offset(i,k)||f.offset;a.each(f.axis.split(""),function(a,b){var d="x"===b?"Left":"Top",e=d.toLowerCase(),o="scroll"+d,p=i[o],q=c.max(i,b);if(h)l[o]=h[e]+(m?0:p-j.offset()[e]),f.margin&&(l[o]-=parseInt(k.css("margin"+d))||0,l[o]-=parseInt(k.css("border"+d+"Width"))||0),l[o]+=n[e]||0,f.over[e]&&(l[o]+=k["x"===b?"width":"height"]()*f.over[e]);else{var r=k[e];l[o]=r.slice&&"%"===r.slice(-1)?parseFloat(r)/100*q:r}f.limit&&/^\d+$/.test(l[o])&&(l[o]=l[o]<=0?0:Math.min(l[o],q)),!a&&f.queue&&(p!==l[o]&&g(f.onAfterFirst),delete l[o])}),g(f.onAfter)}}).end()},c.max=function(b,c){var d="x"===c?"Width":"Height",e="scroll"+d;if(!a(b).is("html,body"))return b[e]-a(b)[d.toLowerCase()]();var f="client"+d,g=b.ownerDocument.documentElement,h=b.ownerDocument.body;return Math.max(g[e],h[e])-Math.min(g[f],h[f])},c});
bp-core/js/confirm.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  jQuery(document).ready(function(){jQuery("a.confirm").click(function(){return confirm(BP_Confirm.are_you_sure)?!0:!1})});
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  jQuery(document).ready(function(){jQuery("a.confirm").click(function(){return confirm(BP_Confirm.are_you_sure)?!0:!1})});
bp-core/js/jquery-cookie.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
bp-core/js/jquery-query.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  function bp_get_querystring(a){var b=location.search.split(a+"=")[1];return b?decodeURIComponent(b.split("&")[0]):null}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  function bp_get_querystring(a){var b=location.search.split(a+"=")[1];return b?decodeURIComponent(b.split("&")[0]):null}
bp-core/js/jquery.atwho.js CHANGED
@@ -1,19 +1,25 @@
1
- /*! jquery.atwho - v0.5.0 - 2014-07-14
2
- * Copyright (c) 2014 chord.luo <chord.luo@gmail.com>;
3
- * homepage: http://ichord.github.com/At.js
4
  * Licensed MIT
5
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- (function() {
8
- (function(factory) {
9
- if (typeof define === 'function' && define.amd) {
10
- return define(['jquery'], factory);
11
- } else {
12
- return factory(window.jQuery);
13
- }
14
- })(function($) {
15
-
16
- var $CONTAINER, Api, App, Controller, DEFAULT_CALLBACKS, KEY_CODE, Model, View,
17
  __slice = [].slice;
18
 
19
  App = (function() {
@@ -22,20 +28,37 @@ App = (function() {
22
  this.controllers = {};
23
  this.alias_maps = {};
24
  this.$inputor = $(inputor);
25
- this.iframe = null;
26
  this.setIframe();
27
  this.listen();
28
  }
29
 
30
- App.prototype.setIframe = function(iframe) {
 
 
 
 
 
 
 
 
 
 
31
  if (iframe) {
32
  this.window = iframe.contentWindow;
33
  this.document = iframe.contentDocument || this.window.document;
34
- return this.iframe = iframe;
35
  } else {
36
  this.document = document;
37
  this.window = window;
38
- return this.iframe = null;
 
 
 
 
 
 
 
 
39
  }
40
  };
41
 
@@ -98,8 +121,7 @@ App = (function() {
98
  };
99
  })(this)).on('click.atwhoInner', (function(_this) {
100
  return function(e) {
101
- var _ref;
102
- return (_ref = _this.controller()) != null ? _ref.view.hide(e) : void 0;
103
  };
104
  })(this));
105
  };
@@ -112,7 +134,8 @@ App = (function() {
112
  c.destroy();
113
  delete this.controllers[_];
114
  }
115
- return this.$inputor.off('.atwhoInner');
 
116
  };
117
 
118
  App.prototype.dispatch = function() {
@@ -225,7 +248,9 @@ Controller = (function() {
225
  this.pos = 0;
226
  this.cur_rect = null;
227
  this.range = null;
228
- $CONTAINER.append(this.$el = $("<div id='atwho-ground-" + this.id + "'></div>"));
 
 
229
  this.model = new Model(this);
230
  this.view = new View(this);
231
  }
@@ -280,10 +305,14 @@ Controller = (function() {
280
  };
281
 
282
  Controller.prototype.content = function() {
 
283
  if (this.$inputor.is('textarea, input')) {
284
  return this.$inputor.val();
285
  } else {
286
- return this.$inputor.text();
 
 
 
287
  }
288
  };
289
 
@@ -313,14 +342,19 @@ Controller = (function() {
313
  };
314
 
315
  Controller.prototype.rect = function() {
316
- var c, scale_bottom;
317
  if (!(c = this.$inputor.caret('offset', this.pos - 1, {
318
  iframe: this.app.iframe
319
  }))) {
320
  return;
321
  }
322
- if (this.$inputor.attr('contentEditable') === 'true') {
323
- c = (this.cur_rect || (this.cur_rect = c)) || c;
 
 
 
 
 
324
  }
325
  scale_bottom = this.app.document.selection ? 0 : 2;
326
  return {
@@ -331,19 +365,20 @@ Controller = (function() {
331
  };
332
 
333
  Controller.prototype.reset_rect = function() {
334
- if (this.$inputor.attr('contentEditable') === 'true') {
335
  return this.cur_rect = null;
336
  }
337
  };
338
 
339
  Controller.prototype.mark_range = function() {
340
- if (this.$inputor.attr('contentEditable') === 'true') {
341
- if (this.app.window.getSelection) {
342
- this.range = this.app.window.getSelection().getRangeAt(0);
343
- }
344
- if (this.app.document.selection) {
345
- return this.ie8_range = this.app.document.selection.createRange();
346
- }
 
347
  }
348
  };
349
 
@@ -362,15 +397,15 @@ Controller = (function() {
362
  };
363
 
364
  Controller.prototype.insert = function(content, $li) {
365
- var $inputor, content_node, pos, range, sel, source, start_str, text, wrapped_content;
366
  $inputor = this.$inputor;
367
- wrapped_content = this.callbacks('inserting_wrapper').call(this, $inputor, content, this.get_opt("suffix"));
368
  if ($inputor.is('textarea, input')) {
369
  source = $inputor.val();
370
  start_str = source.slice(0, Math.max(this.query.head_pos - this.at.length, 0));
371
- text = "" + start_str + wrapped_content + (source.slice(this.query['end_pos'] || 0));
372
  $inputor.val(text);
373
- $inputor.caret('pos', start_str.length + wrapped_content.length, {
374
  iframe: this.app.iframe
375
  });
376
  } else if (range = this.range) {
@@ -378,16 +413,19 @@ Controller = (function() {
378
  range.setStart(range.endContainer, Math.max(pos, 0));
379
  range.setEnd(range.endContainer, range.endOffset);
380
  range.deleteContents();
381
- content_node = $(wrapped_content, this.app.document)[0];
382
- range.insertNode(content_node);
383
- range.setEndAfter(content_node);
384
- range.collapse(false);
 
 
 
385
  sel = this.app.window.getSelection();
386
  sel.removeAllRanges();
387
  sel.addRange(range);
388
  } else if (range = this.ie8_range) {
389
  range.moveStart('character', this.query.end_pos - this.query.head_pos - this.at.length);
390
- range.pasteHTML(wrapped_content);
391
  range.collapse(false);
392
  range.select();
393
  }
@@ -515,8 +553,10 @@ View = (function() {
515
  return $menu.on('mouseenter.atwho-view', 'li', function(e) {
516
  $menu.find('.cur').removeClass('cur');
517
  return $(e.currentTarget).addClass('cur');
518
- }).on('click', (function(_this) {
519
  return function(e) {
 
 
520
  _this.choose(e);
521
  return e.preventDefault();
522
  };
@@ -541,10 +581,14 @@ View = (function() {
541
  };
542
 
543
  View.prototype.reposition = function(rect) {
544
- var offset, _ref;
545
- if (rect.bottom + this.$el.height() - $(window).scrollTop() > $(window).height()) {
 
546
  rect.bottom = rect.top - this.$el.height();
547
  }
 
 
 
548
  offset = {
549
  left: rect.left,
550
  top: rect.bottom
@@ -563,7 +607,10 @@ View = (function() {
563
  if (!next.length) {
564
  next = this.$el.find('li:first');
565
  }
566
- return next.addClass('cur');
 
 
 
567
  };
568
 
569
  View.prototype.prev = function() {
@@ -573,7 +620,10 @@ View = (function() {
573
  if (!prev.length) {
574
  prev = this.$el.find('li:last');
575
  }
576
- return prev.addClass('cur');
 
 
 
577
  };
578
 
579
  View.prototype.show = function() {
@@ -585,6 +635,7 @@ View = (function() {
585
  this.context.mark_range();
586
  if (!this.visible()) {
587
  this.$el.show();
 
588
  this.context.trigger('shown');
589
  }
590
  if (rect = this.context.rect()) {
@@ -672,12 +723,14 @@ DEFAULT_CALLBACKS = {
672
  return _results;
673
  },
674
  matcher: function(flag, subtext, should_start_with_space) {
675
- var match, regexp;
676
  flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
677
  if (should_start_with_space) {
678
  flag = '(?:^|\\s)' + flag;
679
  }
680
- regexp = new RegExp(flag + '([A-Za-z0-9_\+\-]*)$|' + flag + '([^\\x00-\\xff]*)$', 'gi');
 
 
681
  match = regexp.exec(subtext);
682
  if (match) {
683
  return match[2] || match[1];
@@ -690,7 +743,7 @@ DEFAULT_CALLBACKS = {
690
  _results = [];
691
  for (_i = 0, _len = data.length; _i < _len; _i++) {
692
  item = data[_i];
693
- if (~item[search_key].toLowerCase().indexOf(query.toLowerCase())) {
694
  _results.push(item);
695
  }
696
  }
@@ -705,7 +758,7 @@ DEFAULT_CALLBACKS = {
705
  _results = [];
706
  for (_i = 0, _len = items.length; _i < _len; _i++) {
707
  item = items[_i];
708
- item.atwho_order = item[search_key].toLowerCase().indexOf(query.toLowerCase());
709
  if (item.atwho_order > -1) {
710
  _results.push(item);
711
  }
@@ -739,22 +792,22 @@ DEFAULT_CALLBACKS = {
739
  return value;
740
  },
741
  inserting_wrapper: function($inputor, content, suffix) {
742
- var new_suffix, wrapped_content;
743
- new_suffix = suffix === "" ? suffix : suffix || " ";
744
  if ($inputor.is('textarea, input')) {
745
- return '' + content + new_suffix;
746
  } else if ($inputor.attr('contentEditable') === 'true') {
747
- new_suffix = suffix === "" ? suffix : suffix || "&nbsp;";
748
  if (/firefox/i.test(navigator.userAgent)) {
749
- wrapped_content = "<span>" + content + new_suffix + "</span>";
750
  } else {
751
- suffix = "<span contenteditable='false'>" + new_suffix + "<span>";
752
  wrapped_content = "<span contenteditable='false'>" + content + suffix + "</span>";
753
  }
754
  if (this.app.document.selection) {
755
  wrapped_content = "<span contenteditable='true'>" + content + "</span>";
756
  }
757
- return wrapped_content;
758
  }
759
  }
760
  };
@@ -766,8 +819,8 @@ Api = {
766
  return c.model.load(data);
767
  }
768
  },
769
- setIframe: function(iframe) {
770
- this.setIframe(iframe);
771
  return null;
772
  },
773
  run: function() {
@@ -779,14 +832,11 @@ Api = {
779
  }
780
  };
781
 
782
- $CONTAINER = $("<div id='atwho-container'></div>");
783
-
784
  $.fn.atwho = function(method) {
785
  var result, _args;
786
  _args = arguments;
787
- $('body').append($CONTAINER);
788
  result = null;
789
- this.filter('textarea, input, [contenteditable=true]').each(function() {
790
  var $this, app;
791
  if (!(app = ($this = $(this)).data("atwho"))) {
792
  $this.data('atwho', (app = new App(this)));
@@ -820,5 +870,6 @@ $.fn.atwho["default"] = {
820
  delay: null
821
  };
822
 
823
- });
824
- }).call(this);
 
1
+ /*! jquery.atwho - v0.5.2 %>
2
+ * Copyright (c) 2014 chord.luo <chord.luo@gmail.com>;
3
+ * homepage: http://ichord.github.com/At.js
4
  * Licensed MIT
5
  */
6
+ (function (root, factory) {
7
+ if (typeof define === 'function' && define.amd) {
8
+ // AMD. Register as an anonymous module.
9
+ define(["jquery"], function ($) {
10
+ return (root.returnExportsGlobal = factory($));
11
+ });
12
+ } else if (typeof exports === 'object') {
13
+ // Node. Does not work with strict CommonJS, but
14
+ // only CommonJS-like enviroments that support module.exports,
15
+ // like Node.
16
+ module.exports = factory(require("jquery"));
17
+ } else {
18
+ factory(jQuery);
19
+ }
20
+ }(this, function ($) {
21
 
22
+ var Api, App, Controller, DEFAULT_CALLBACKS, KEY_CODE, Model, View,
 
 
 
 
 
 
 
 
 
23
  __slice = [].slice;
24
 
25
  App = (function() {
28
  this.controllers = {};
29
  this.alias_maps = {};
30
  this.$inputor = $(inputor);
 
31
  this.setIframe();
32
  this.listen();
33
  }
34
 
35
+ App.prototype.createContainer = function(doc) {
36
+ if ((this.$el = $("#atwho-container", doc)).length === 0) {
37
+ return $(doc.body).append(this.$el = $("<div id='atwho-container'></div>"));
38
+ }
39
+ };
40
+
41
+ App.prototype.setIframe = function(iframe, standalone) {
42
+ var _ref;
43
+ if (standalone == null) {
44
+ standalone = false;
45
+ }
46
  if (iframe) {
47
  this.window = iframe.contentWindow;
48
  this.document = iframe.contentDocument || this.window.document;
49
+ this.iframe = iframe;
50
  } else {
51
  this.document = document;
52
  this.window = window;
53
+ this.iframe = null;
54
+ }
55
+ if (this.iframeStandalone = standalone) {
56
+ if ((_ref = this.$el) != null) {
57
+ _ref.remove();
58
+ }
59
+ return this.createContainer(this.document);
60
+ } else {
61
+ return this.createContainer(document);
62
  }
63
  };
64
 
121
  };
122
  })(this)).on('click.atwhoInner', (function(_this) {
123
  return function(e) {
124
+ return _this.dispatch();
 
125
  };
126
  })(this));
127
  };
134
  c.destroy();
135
  delete this.controllers[_];
136
  }
137
+ this.$inputor.off('.atwhoInner');
138
+ return this.$el.remove();
139
  };
140
 
141
  App.prototype.dispatch = function() {
248
  this.pos = 0;
249
  this.cur_rect = null;
250
  this.range = null;
251
+ if ((this.$el = $("#atwho-ground-" + this.id, this.app.$el)).length === 0) {
252
+ this.app.$el.append(this.$el = $("<div id='atwho-ground-" + this.id + "'></div>"));
253
+ }
254
  this.model = new Model(this);
255
  this.view = new View(this);
256
  }
305
  };
306
 
307
  Controller.prototype.content = function() {
308
+ var range;
309
  if (this.$inputor.is('textarea, input')) {
310
  return this.$inputor.val();
311
  } else {
312
+ if (!(range = this.mark_range())) {
313
+ return;
314
+ }
315
+ return (range.startContainer.textContent || "").slice(0, range.startOffset);
316
  }
317
  };
318
 
342
  };
343
 
344
  Controller.prototype.rect = function() {
345
+ var c, iframe_offset, scale_bottom;
346
  if (!(c = this.$inputor.caret('offset', this.pos - 1, {
347
  iframe: this.app.iframe
348
  }))) {
349
  return;
350
  }
351
+ if (this.app.iframe && !this.app.iframeStandalone) {
352
+ iframe_offset = $(this.app.iframe).offset();
353
+ c.left += iframe_offset.left;
354
+ c.top += iframe_offset.top;
355
+ }
356
+ if (this.$inputor.is('[contentEditable]')) {
357
+ c = this.cur_rect || (this.cur_rect = c);
358
  }
359
  scale_bottom = this.app.document.selection ? 0 : 2;
360
  return {
365
  };
366
 
367
  Controller.prototype.reset_rect = function() {
368
+ if (this.$inputor.is('[contentEditable]')) {
369
  return this.cur_rect = null;
370
  }
371
  };
372
 
373
  Controller.prototype.mark_range = function() {
374
+ var sel;
375
+ if (!this.$inputor.is('[contentEditable]')) {
376
+ return;
377
+ }
378
+ if (this.app.window.getSelection && (sel = this.app.window.getSelection()).rangeCount > 0) {
379
+ return this.range = sel.getRangeAt(0);
380
+ } else if (this.app.document.selection) {
381
+ return this.ie8_range = this.app.document.selection.createRange();
382
  }
383
  };
384
 
397
  };
398
 
399
  Controller.prototype.insert = function(content, $li) {
400
+ var $inputor, node, pos, range, sel, source, start_str, text, wrapped_contents, _i, _len, _ref;
401
  $inputor = this.$inputor;
402
+ wrapped_contents = this.callbacks('inserting_wrapper').call(this, $inputor, content, this.get_opt("suffix"));
403
  if ($inputor.is('textarea, input')) {
404
  source = $inputor.val();
405
  start_str = source.slice(0, Math.max(this.query.head_pos - this.at.length, 0));
406
+ text = "" + start_str + wrapped_contents + (source.slice(this.query['end_pos'] || 0));
407
  $inputor.val(text);
408
+ $inputor.caret('pos', start_str.length + wrapped_contents.length, {
409
  iframe: this.app.iframe
410
  });
411
  } else if (range = this.range) {
413
  range.setStart(range.endContainer, Math.max(pos, 0));
414
  range.setEnd(range.endContainer, range.endOffset);
415
  range.deleteContents();
416
+ _ref = $(wrapped_contents, this.app.document);
417
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
418
+ node = _ref[_i];
419
+ range.insertNode(node);
420
+ range.setEndAfter(node);
421
+ range.collapse(false);
422
+ }
423
  sel = this.app.window.getSelection();
424
  sel.removeAllRanges();
425
  sel.addRange(range);
426
  } else if (range = this.ie8_range) {
427
  range.moveStart('character', this.query.end_pos - this.query.head_pos - this.at.length);
428
+ range.pasteHTML(wrapped_contents);
429
  range.collapse(false);
430
  range.select();
431
  }
553
  return $menu.on('mouseenter.atwho-view', 'li', function(e) {
554
  $menu.find('.cur').removeClass('cur');
555
  return $(e.currentTarget).addClass('cur');
556
+ }).on('click.atwho-view', 'li', (function(_this) {
557
  return function(e) {
558
+ $menu.find('.cur').removeClass('cur');
559
+ $(e.currentTarget).addClass('cur');
560
  _this.choose(e);
561
  return e.preventDefault();
562
  };
581
  };
582
 
583
  View.prototype.reposition = function(rect) {
584
+ var offset, overflowOffset, _ref, _window;
585
+ _window = this.context.app.iframeStandalone ? this.context.app.window : window;
586
+ if (rect.bottom + this.$el.height() - $(_window).scrollTop() > $(_window).height()) {
587
  rect.bottom = rect.top - this.$el.height();
588
  }
589
+ if (rect.left > (overflowOffset = $(_window).width() - this.$el.width() - 5)) {
590
+ rect.left = overflowOffset;
591
+ }
592
  offset = {
593
  left: rect.left,
594
  top: rect.bottom
607
  if (!next.length) {
608
  next = this.$el.find('li:first');
609
  }
610
+ next.addClass('cur');
611
+ return this.$el.animate({
612
+ scrollTop: Math.max(0, cur.innerHeight() * (next.index() + 2) - this.$el.height())
613
+ }, 150);
614
  };
615
 
616
  View.prototype.prev = function() {
620
  if (!prev.length) {
621
  prev = this.$el.find('li:last');
622
  }
623
+ prev.addClass('cur');
624
+ return this.$el.animate({
625
+ scrollTop: Math.max(0, cur.innerHeight() * (prev.index() + 2) - this.$el.height())
626
+ }, 150);
627
  };
628
 
629
  View.prototype.show = function() {
635
  this.context.mark_range();
636
  if (!this.visible()) {
637
  this.$el.show();
638
+ this.$el.scrollTop(0);
639
  this.context.trigger('shown');
640
  }
641
  if (rect = this.context.rect()) {
723
  return _results;
724
  },
725
  matcher: function(flag, subtext, should_start_with_space) {
726
+ var match, regexp, _a, _y;
727
  flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
728
  if (should_start_with_space) {
729
  flag = '(?:^|\\s)' + flag;
730
  }
731
+ _a = decodeURI("%C3%80");
732
+ _y = decodeURI("%C3%BF");
733
+ regexp = new RegExp("" + flag + "([A-Za-z" + _a + "-" + _y + "0-9_\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi');
734
  match = regexp.exec(subtext);
735
  if (match) {
736
  return match[2] || match[1];
743
  _results = [];
744
  for (_i = 0, _len = data.length; _i < _len; _i++) {
745
  item = data[_i];
746
+ if (~new String(item[search_key]).toLowerCase().indexOf(query.toLowerCase())) {
747
  _results.push(item);
748
  }
749
  }
758
  _results = [];
759
  for (_i = 0, _len = items.length; _i < _len; _i++) {
760
  item = items[_i];
761
+ item.atwho_order = new String(item[search_key]).toLowerCase().indexOf(query.toLowerCase());
762
  if (item.atwho_order > -1) {
763
  _results.push(item);
764
  }
792
  return value;
793
  },
794
  inserting_wrapper: function($inputor, content, suffix) {
795
+ var wrapped_content;
796
+ suffix = suffix === "" ? suffix : suffix || " ";
797
  if ($inputor.is('textarea, input')) {
798
+ return '' + content + suffix;
799
  } else if ($inputor.attr('contentEditable') === 'true') {
800
+ suffix = suffix === " " ? "&nbsp;" : suffix;
801
  if (/firefox/i.test(navigator.userAgent)) {
802
+ wrapped_content = "<span>" + content + suffix + "</span>";
803
  } else {
804
+ suffix = "<span contenteditable='false'>" + suffix + "</span>";
805
  wrapped_content = "<span contenteditable='false'>" + content + suffix + "</span>";
806
  }
807
  if (this.app.document.selection) {
808
  wrapped_content = "<span contenteditable='true'>" + content + "</span>";
809
  }
810
+ return wrapped_content + "<span></span>";
811
  }
812
  }
813
  };
819
  return c.model.load(data);
820
  }
821
  },
822
+ setIframe: function(iframe, standalone) {
823
+ this.setIframe(iframe, standalone);
824
  return null;
825
  },
826
  run: function() {
832
  }
833
  };
834
 
 
 
835
  $.fn.atwho = function(method) {
836
  var result, _args;
837
  _args = arguments;
 
838
  result = null;
839
+ this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function() {
840
  var $this, app;
841
  if (!(app = ($this = $(this)).data("atwho"))) {
842
  $this.data('atwho', (app = new App(this)));
870
  delay: null
871
  };
872
 
873
+
874
+
875
+ }));
bp-core/js/jquery.atwho.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- (function(){!function(a){return"function"==typeof define&&define.amd?define(["jquery"],a):a(window.jQuery)}(function(a){var b,c,d,e,f,g,h,i,j=[].slice;d=function(){function b(b){this.current_flag=null,this.controllers={},this.alias_maps={},this.$inputor=a(b),this.iframe=null,this.setIframe(),this.listen()}return b.prototype.setIframe=function(a){return a?(this.window=a.contentWindow,this.document=a.contentDocument||this.window.document,this.iframe=a):(this.document=document,this.window=window,this.iframe=null)},b.prototype.controller=function(a){var b,c,d,e;if(this.alias_maps[a])c=this.controllers[this.alias_maps[a]];else{e=this.controllers;for(d in e)if(b=e[d],d===a){c=b;break}}return c?c:this.controllers[this.current_flag]},b.prototype.set_context_for=function(a){return this.current_flag=a,this},b.prototype.reg=function(a,b){var c,d;return c=(d=this.controllers)[a]||(d[a]=new e(this,a)),b.alias&&(this.alias_maps[b.alias]=a),c.init(b),this},b.prototype.listen=function(){return this.$inputor.on("keyup.atwhoInner",function(a){return function(b){return a.on_keyup(b)}}(this)).on("keydown.atwhoInner",function(a){return function(b){return a.on_keydown(b)}}(this)).on("scroll.atwhoInner",function(a){return function(b){var c;return null!=(c=a.controller())?c.view.hide(b):void 0}}(this)).on("blur.atwhoInner",function(a){return function(b){var c;return(c=a.controller())?c.view.hide(b,c.get_opt("display_timeout")):void 0}}(this)).on("click.atwhoInner",function(a){return function(b){var c;return null!=(c=a.controller())?c.view.hide(b):void 0}}(this))},b.prototype.shutdown=function(){var a,b,c;c=this.controllers;for(b in c)a=c[b],a.destroy(),delete this.controllers[b];return this.$inputor.off(".atwhoInner")},b.prototype.dispatch=function(){return a.map(this.controllers,function(a){return function(b){var c;return(c=b.get_opt("delay"))?(clearTimeout(a.delayedCallback),a.delayedCallback=setTimeout(function(){return b.look_up()?a.set_context_for(b.at):void 0},c)):b.look_up()?a.set_context_for(b.at):void 0}}(this))},b.prototype.on_keyup=function(b){var c;switch(b.keyCode){case g.ESC:b.preventDefault(),null!=(c=this.controller())&&c.view.hide();break;case g.DOWN:case g.UP:case g.CTRL:a.noop();break;case g.P:case g.N:b.ctrlKey||this.dispatch();break;default:this.dispatch()}},b.prototype.on_keydown=function(b){var c,d;if(c=null!=(d=this.controller())?d.view:void 0,c&&c.visible())switch(b.keyCode){case g.ESC:b.preventDefault(),c.hide(b);break;case g.UP:b.preventDefault(),c.prev();break;case g.DOWN:b.preventDefault(),c.next();break;case g.P:if(!b.ctrlKey)return;b.preventDefault(),c.prev();break;case g.N:if(!b.ctrlKey)return;b.preventDefault(),c.next();break;case g.TAB:case g.ENTER:if(!c.visible())return;b.preventDefault(),c.choose(b);break;default:a.noop()}},b}(),e=function(){function c(c,d){this.app=c,this.at=d,this.$inputor=this.app.$inputor,this.id=this.$inputor[0].id||this.uid(),this.setting=null,this.query=null,this.pos=0,this.cur_rect=null,this.range=null,b.append(this.$el=a("<div id='atwho-ground-"+this.id+"'></div>")),this.model=new h(this),this.view=new i(this)}return c.prototype.uid=function(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()},c.prototype.init=function(b){return this.setting=a.extend({},this.setting||a.fn.atwho["default"],b),this.view.init(),this.model.reload(this.setting.data)},c.prototype.destroy=function(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()},c.prototype.call_default=function(){var b,c,d;d=arguments[0],b=2<=arguments.length?j.call(arguments,1):[];try{return f[d].apply(this,b)}catch(e){return c=e,a.error(""+c+" Or maybe At.js doesn't have function "+d)}},c.prototype.trigger=function(a,b){var c,d;return null==b&&(b=[]),b.push(this),c=this.get_opt("alias"),d=c?""+a+"-"+c+".atwho":""+a+".atwho",this.$inputor.trigger(d,b)},c.prototype.callbacks=function(a){return this.get_opt("callbacks")[a]||f[a]},c.prototype.get_opt=function(a){var b;try{return this.setting[a]}catch(c){return b=c,null}},c.prototype.content=function(){return this.$inputor.is("textarea, input")?this.$inputor.val():this.$inputor.text()},c.prototype.catch_query=function(){var a,b,c,d,e,f;return b=this.content(),a=this.$inputor.caret("pos",{iframe:this.app.iframe}),f=b.slice(0,a),d=this.callbacks("matcher").call(this,this.at,f,this.get_opt("start_with_space")),"string"==typeof d&&d.length<=this.get_opt("max_len",20)?(e=a-d.length,c=e+d.length,this.pos=e,d={text:d,head_pos:e,end_pos:c},this.trigger("matched",[this.at,d.text])):(d=null,this.view.hide()),this.query=d},c.prototype.rect=function(){var a,b;if(a=this.$inputor.caret("offset",this.pos-1,{iframe:this.app.iframe}))return"true"===this.$inputor.attr("contentEditable")&&(a=this.cur_rect||(this.cur_rect=a)||a),b=this.app.document.selection?0:2,{left:a.left,top:a.top,bottom:a.top+a.height+b}},c.prototype.reset_rect=function(){return"true"===this.$inputor.attr("contentEditable")?this.cur_rect=null:void 0},c.prototype.mark_range=function(){return"true"===this.$inputor.attr("contentEditable")&&(this.app.window.getSelection&&(this.range=this.app.window.getSelection().getRangeAt(0)),this.app.document.selection)?this.ie8_range=this.app.document.selection.createRange():void 0},c.prototype.insert_content_for=function(b){var c,d,e;return d=b.data("value"),e=this.get_opt("insert_tpl"),this.$inputor.is("textarea, input")||!e?d:(c=a.extend({},b.data("item-data"),{"atwho-data-value":d,"atwho-at":this.at}),this.callbacks("tpl_eval").call(this,e,c))},c.prototype.insert=function(b){var c,d,e,f,g,h,i,j,k;return c=this.$inputor,k=this.callbacks("inserting_wrapper").call(this,c,b,this.get_opt("suffix")),c.is("textarea, input")?(h=c.val(),i=h.slice(0,Math.max(this.query.head_pos-this.at.length,0)),j=""+i+k+h.slice(this.query.end_pos||0),c.val(j),c.caret("pos",i.length+k.length,{iframe:this.app.iframe})):(f=this.range)?(e=f.startOffset-(this.query.end_pos-this.query.head_pos)-this.at.length,f.setStart(f.endContainer,Math.max(e,0)),f.setEnd(f.endContainer,f.endOffset),f.deleteContents(),d=a(k,this.app.document)[0],f.insertNode(d),f.setEndAfter(d),f.collapse(!1),g=this.app.window.getSelection(),g.removeAllRanges(),g.addRange(f)):(f=this.ie8_range)&&(f.moveStart("character",this.query.end_pos-this.query.head_pos-this.at.length),f.pasteHTML(k),f.collapse(!1),f.select()),c.is(":focus")||c.focus(),c.change()},c.prototype.render_view=function(a){var b;return b=this.get_opt("search_key"),a=this.callbacks("sorter").call(this,this.query.text,a.slice(0,1001),b),this.view.render(a.slice(0,this.get_opt("limit")))},c.prototype.look_up=function(){var b,c;if(b=this.catch_query())return c=function(a){return a&&a.length>0?this.render_view(a):this.view.hide()},this.model.query(b.text,a.proxy(c,this)),b},c}(),h=function(){function b(a){this.context=a,this.at=this.context.at,this.storage=this.context.$inputor}return b.prototype.destroy=function(){return this.storage.data(this.at,null)},b.prototype.saved=function(){return this.fetch()>0},b.prototype.query=function(a,b){var c,d,e;return c=this.fetch(),d=this.context.get_opt("search_key"),c=this.context.callbacks("filter").call(this.context,a,c,d)||[],e=this.context.callbacks("remote_filter"),c.length>0||!e&&0===c.length?b(c):e.call(this.context,a,b)},b.prototype.fetch=function(){return this.storage.data(this.at)||[]},b.prototype.save=function(a){return this.storage.data(this.at,this.context.callbacks("before_save").call(this.context,a||[]))},b.prototype.load=function(a){return!this.saved()&&a?this._load(a):void 0},b.prototype.reload=function(a){return this._load(a)},b.prototype._load=function(b){return"string"==typeof b?a.ajax(b,{dataType:"json"}).done(function(a){return function(b){return a.save(b)}}(this)):this.save(b)},b}(),i=function(){function b(b){this.context=b,this.$el=a("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>"),this.timeout_id=null,this.context.$el.append(this.$el),this.bind_event()}return b.prototype.init=function(){var a;return a=this.context.get_opt("alias")||this.context.at.charCodeAt(0),this.$el.attr({id:"at-view-"+a})},b.prototype.destroy=function(){return this.$el.remove()},b.prototype.bind_event=function(){var b;return b=this.$el.find("ul"),b.on("mouseenter.atwho-view","li",function(c){return b.find(".cur").removeClass("cur"),a(c.currentTarget).addClass("cur")}).on("click",function(a){return function(b){return a.choose(b),b.preventDefault()}}(this))},b.prototype.visible=function(){return this.$el.is(":visible")},b.prototype.choose=function(a){var b,c;return(b=this.$el.find(".cur")).length&&(c=this.context.insert_content_for(b),this.context.insert(this.context.callbacks("before_insert").call(this.context,c,b),b),this.context.trigger("inserted",[b,a]),this.hide(a)),this.context.get_opt("hide_without_suffix")?this.stop_showing=!0:void 0},b.prototype.reposition=function(b){var c,d;return b.bottom+this.$el.height()-a(window).scrollTop()>a(window).height()&&(b.bottom=b.top-this.$el.height()),c={left:b.left,top:b.bottom},null!=(d=this.context.callbacks("before_reposition"))&&d.call(this.context,c),this.$el.offset(c),this.context.trigger("reposition",[c])},b.prototype.next=function(){var a,b;return a=this.$el.find(".cur").removeClass("cur"),b=a.next(),b.length||(b=this.$el.find("li:first")),b.addClass("cur")},b.prototype.prev=function(){var a,b;return a=this.$el.find(".cur").removeClass("cur"),b=a.prev(),b.length||(b=this.$el.find("li:last")),b.addClass("cur")},b.prototype.show=function(){var a;return this.stop_showing?void(this.stop_showing=!1):(this.context.mark_range(),this.visible()||(this.$el.show(),this.context.trigger("shown")),(a=this.context.rect())?this.reposition(a):void 0)},b.prototype.hide=function(a,b){var c;if(this.visible())return isNaN(b)?(this.context.reset_rect(),this.$el.hide(),this.context.trigger("hidden",[a])):(c=function(a){return function(){return a.hide()}}(this),clearTimeout(this.timeout_id),this.timeout_id=setTimeout(c,b))},b.prototype.render=function(b){var c,d,e,f,g,h,i;if(!(a.isArray(b)&&b.length>0))return void this.hide();for(this.$el.find("ul").empty(),d=this.$el.find("ul"),g=this.context.get_opt("tpl"),h=0,i=b.length;i>h;h++)e=b[h],e=a.extend({},e,{"atwho-at":this.context.at}),f=this.context.callbacks("tpl_eval").call(this.context,g,e),c=a(this.context.callbacks("highlighter").call(this.context,f,this.context.query.text)),c.data("item-data",e),d.append(c);return this.show(),this.context.get_opt("highlight_first")?d.find("li:first").addClass("cur"):void 0},b}(),g={DOWN:40,UP:38,ESC:27,TAB:9,ENTER:13,CTRL:17,P:80,N:78},f={before_save:function(b){var c,d,e,f;if(!a.isArray(b))return b;for(f=[],d=0,e=b.length;e>d;d++)c=b[d],f.push(a.isPlainObject(c)?c:{name:c});return f},matcher:function(a,b,c){var d,e;return a=a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),c&&(a="(?:^|\\s)"+a),e=new RegExp(a+"([A-Za-z0-9_+-]*)$|"+a+"([^\\x00-\\xff]*)$","gi"),d=e.exec(b),d?d[2]||d[1]:null},filter:function(a,b,c){var d,e,f,g;for(g=[],e=0,f=b.length;f>e;e++)d=b[e],~d[c].toLowerCase().indexOf(a.toLowerCase())&&g.push(d);return g},remote_filter:null,sorter:function(a,b,c){var d,e,f,g;if(!a)return b;for(g=[],e=0,f=b.length;f>e;e++)d=b[e],d.atwho_order=d[c].toLowerCase().indexOf(a.toLowerCase()),d.atwho_order>-1&&g.push(d);return g.sort(function(a,b){return a.atwho_order-b.atwho_order})},tpl_eval:function(a,b){var c;try{return a.replace(/\$\{([^\}]*)\}/g,function(a,c){return b[c]})}catch(d){return c=d,""}},highlighter:function(a,b){var c;return b?(c=new RegExp(">\\s*(\\w*?)("+b.replace("+","\\+")+")(\\w*)\\s*<","ig"),a.replace(c,function(a,b,c,d){return"> "+b+"<strong>"+c+"</strong>"+d+" <"})):a},before_insert:function(a){return a},inserting_wrapper:function(a,b,c){var d,e;return d=""===c?c:c||" ",a.is("textarea, input")?""+b+d:"true"===a.attr("contentEditable")?(d=""===c?c:c||"&nbsp;",/firefox/i.test(navigator.userAgent)?e="<span>"+b+d+"</span>":(c="<span contenteditable='false'>"+d+"<span>",e="<span contenteditable='false'>"+b+c+"</span>"),this.app.document.selection&&(e="<span contenteditable='true'>"+b+"</span>"),e):void 0}},c={load:function(a,b){var c;return(c=this.controller(a))?c.model.load(b):void 0},setIframe:function(a){return this.setIframe(a),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}},b=a("<div id='atwho-container'></div>"),a.fn.atwho=function(e){var f,g;return g=arguments,a("body").append(b),f=null,this.filter("textarea, input, [contenteditable=true]").each(function(){var b,h;return(h=(b=a(this)).data("atwho"))||b.data("atwho",h=new d(this)),"object"!=typeof e&&e?c[e]&&h?f=c[e].apply(h,Array.prototype.slice.call(g,1)):a.error("Method "+e+" does not exist on jQuery.caret"):h.reg(e.at,e)}),f||this},a.fn.atwho["default"]={at:void 0,alias:void 0,data:null,tpl:"<li data-value='${atwho-at}${name}'>${name}</li>",insert_tpl:"<span id='${id}'>${atwho-data-value}</span>",callbacks:f,search_key:"name",suffix:void 0,hide_without_suffix:!1,start_with_space:!0,highlight_first:!0,limit:5,max_len:20,display_timeout:300,delay:null}})}).call(this);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(c){return a.returnExportsGlobal=b(c)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){var b,c,d,e,f,g,h,i=[].slice;c=function(){function b(b){this.current_flag=null,this.controllers={},this.alias_maps={},this.$inputor=a(b),this.setIframe(),this.listen()}return b.prototype.createContainer=function(b){return 0===(this.$el=a("#atwho-container",b)).length?a(b.body).append(this.$el=a("<div id='atwho-container'></div>")):void 0},b.prototype.setIframe=function(a,b){var c;return null==b&&(b=!1),a?(this.window=a.contentWindow,this.document=a.contentDocument||this.window.document,this.iframe=a):(this.document=document,this.window=window,this.iframe=null),(this.iframeStandalone=b)?(null!=(c=this.$el)&&c.remove(),this.createContainer(this.document)):this.createContainer(document)},b.prototype.controller=function(a){var b,c,d,e;if(this.alias_maps[a])c=this.controllers[this.alias_maps[a]];else{e=this.controllers;for(d in e)if(b=e[d],d===a){c=b;break}}return c?c:this.controllers[this.current_flag]},b.prototype.set_context_for=function(a){return this.current_flag=a,this},b.prototype.reg=function(a,b){var c,e;return c=(e=this.controllers)[a]||(e[a]=new d(this,a)),b.alias&&(this.alias_maps[b.alias]=a),c.init(b),this},b.prototype.listen=function(){return this.$inputor.on("keyup.atwhoInner",function(a){return function(b){return a.on_keyup(b)}}(this)).on("keydown.atwhoInner",function(a){return function(b){return a.on_keydown(b)}}(this)).on("scroll.atwhoInner",function(a){return function(b){var c;return null!=(c=a.controller())?c.view.hide(b):void 0}}(this)).on("blur.atwhoInner",function(a){return function(b){var c;return(c=a.controller())?c.view.hide(b,c.get_opt("display_timeout")):void 0}}(this)).on("click.atwhoInner",function(a){return function(){return a.dispatch()}}(this))},b.prototype.shutdown=function(){var a,b,c;c=this.controllers;for(b in c)a=c[b],a.destroy(),delete this.controllers[b];return this.$inputor.off(".atwhoInner"),this.$el.remove()},b.prototype.dispatch=function(){return a.map(this.controllers,function(a){return function(b){var c;return(c=b.get_opt("delay"))?(clearTimeout(a.delayedCallback),a.delayedCallback=setTimeout(function(){return b.look_up()?a.set_context_for(b.at):void 0},c)):b.look_up()?a.set_context_for(b.at):void 0}}(this))},b.prototype.on_keyup=function(b){var c;switch(b.keyCode){case f.ESC:b.preventDefault(),null!=(c=this.controller())&&c.view.hide();break;case f.DOWN:case f.UP:case f.CTRL:a.noop();break;case f.P:case f.N:b.ctrlKey||this.dispatch();break;default:this.dispatch()}},b.prototype.on_keydown=function(b){var c,d;if(c=null!=(d=this.controller())?d.view:void 0,c&&c.visible())switch(b.keyCode){case f.ESC:b.preventDefault(),c.hide(b);break;case f.UP:b.preventDefault(),c.prev();break;case f.DOWN:b.preventDefault(),c.next();break;case f.P:if(!b.ctrlKey)return;b.preventDefault(),c.prev();break;case f.N:if(!b.ctrlKey)return;b.preventDefault(),c.next();break;case f.TAB:case f.ENTER:if(!c.visible())return;b.preventDefault(),c.choose(b);break;default:a.noop()}},b}(),d=function(){function b(b,c){this.app=b,this.at=c,this.$inputor=this.app.$inputor,this.id=this.$inputor[0].id||this.uid(),this.setting=null,this.query=null,this.pos=0,this.cur_rect=null,this.range=null,0===(this.$el=a("#atwho-ground-"+this.id,this.app.$el)).length&&this.app.$el.append(this.$el=a("<div id='atwho-ground-"+this.id+"'></div>")),this.model=new g(this),this.view=new h(this)}return b.prototype.uid=function(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()},b.prototype.init=function(b){return this.setting=a.extend({},this.setting||a.fn.atwho["default"],b),this.view.init(),this.model.reload(this.setting.data)},b.prototype.destroy=function(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()},b.prototype.call_default=function(){var b,c,d;d=arguments[0],b=2<=arguments.length?i.call(arguments,1):[];try{return e[d].apply(this,b)}catch(f){return c=f,a.error(""+c+" Or maybe At.js doesn't have function "+d)}},b.prototype.trigger=function(a,b){var c,d;return null==b&&(b=[]),b.push(this),c=this.get_opt("alias"),d=c?""+a+"-"+c+".atwho":""+a+".atwho",this.$inputor.trigger(d,b)},b.prototype.callbacks=function(a){return this.get_opt("callbacks")[a]||e[a]},b.prototype.get_opt=function(a){var b;try{return this.setting[a]}catch(c){return b=c,null}},b.prototype.content=function(){var a;if(this.$inputor.is("textarea, input"))return this.$inputor.val();if(a=this.mark_range())return(a.startContainer.textContent||"").slice(0,a.startOffset)},b.prototype.catch_query=function(){var a,b,c,d,e,f;return b=this.content(),a=this.$inputor.caret("pos",{iframe:this.app.iframe}),f=b.slice(0,a),d=this.callbacks("matcher").call(this,this.at,f,this.get_opt("start_with_space")),"string"==typeof d&&d.length<=this.get_opt("max_len",20)?(e=a-d.length,c=e+d.length,this.pos=e,d={text:d,head_pos:e,end_pos:c},this.trigger("matched",[this.at,d.text])):(d=null,this.view.hide()),this.query=d},b.prototype.rect=function(){var b,c,d;if(b=this.$inputor.caret("offset",this.pos-1,{iframe:this.app.iframe}))return this.app.iframe&&!this.app.iframeStandalone&&(c=a(this.app.iframe).offset(),b.left+=c.left,b.top+=c.top),this.$inputor.is("[contentEditable]")&&(b=this.cur_rect||(this.cur_rect=b)),d=this.app.document.selection?0:2,{left:b.left,top:b.top,bottom:b.top+b.height+d}},b.prototype.reset_rect=function(){return this.$inputor.is("[contentEditable]")?this.cur_rect=null:void 0},b.prototype.mark_range=function(){var a;if(this.$inputor.is("[contentEditable]"))return this.app.window.getSelection&&(a=this.app.window.getSelection()).rangeCount>0?this.range=a.getRangeAt(0):this.app.document.selection?this.ie8_range=this.app.document.selection.createRange():void 0},b.prototype.insert_content_for=function(b){var c,d,e;return d=b.data("value"),e=this.get_opt("insert_tpl"),this.$inputor.is("textarea, input")||!e?d:(c=a.extend({},b.data("item-data"),{"atwho-data-value":d,"atwho-at":this.at}),this.callbacks("tpl_eval").call(this,e,c))},b.prototype.insert=function(b){var c,d,e,f,g,h,i,j,k,l,m,n;if(c=this.$inputor,k=this.callbacks("inserting_wrapper").call(this,c,b,this.get_opt("suffix")),c.is("textarea, input"))h=c.val(),i=h.slice(0,Math.max(this.query.head_pos-this.at.length,0)),j=""+i+k+h.slice(this.query.end_pos||0),c.val(j),c.caret("pos",i.length+k.length,{iframe:this.app.iframe});else if(f=this.range){for(e=f.startOffset-(this.query.end_pos-this.query.head_pos)-this.at.length,f.setStart(f.endContainer,Math.max(e,0)),f.setEnd(f.endContainer,f.endOffset),f.deleteContents(),n=a(k,this.app.document),l=0,m=n.length;m>l;l++)d=n[l],f.insertNode(d),f.setEndAfter(d),f.collapse(!1);g=this.app.window.getSelection(),g.removeAllRanges(),g.addRange(f)}else(f=this.ie8_range)&&(f.moveStart("character",this.query.end_pos-this.query.head_pos-this.at.length),f.pasteHTML(k),f.collapse(!1),f.select());return c.is(":focus")||c.focus(),c.change()},b.prototype.render_view=function(a){var b;return b=this.get_opt("search_key"),a=this.callbacks("sorter").call(this,this.query.text,a.slice(0,1001),b),this.view.render(a.slice(0,this.get_opt("limit")))},b.prototype.look_up=function(){var b,c;if(b=this.catch_query())return c=function(a){return a&&a.length>0?this.render_view(a):this.view.hide()},this.model.query(b.text,a.proxy(c,this)),b},b}(),g=function(){function b(a){this.context=a,this.at=this.context.at,this.storage=this.context.$inputor}return b.prototype.destroy=function(){return this.storage.data(this.at,null)},b.prototype.saved=function(){return this.fetch()>0},b.prototype.query=function(a,b){var c,d,e;return c=this.fetch(),d=this.context.get_opt("search_key"),c=this.context.callbacks("filter").call(this.context,a,c,d)||[],e=this.context.callbacks("remote_filter"),c.length>0||!e&&0===c.length?b(c):e.call(this.context,a,b)},b.prototype.fetch=function(){return this.storage.data(this.at)||[]},b.prototype.save=function(a){return this.storage.data(this.at,this.context.callbacks("before_save").call(this.context,a||[]))},b.prototype.load=function(a){return!this.saved()&&a?this._load(a):void 0},b.prototype.reload=function(a){return this._load(a)},b.prototype._load=function(b){return"string"==typeof b?a.ajax(b,{dataType:"json"}).done(function(a){return function(b){return a.save(b)}}(this)):this.save(b)},b}(),h=function(){function b(b){this.context=b,this.$el=a("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>"),this.timeout_id=null,this.context.$el.append(this.$el),this.bind_event()}return b.prototype.init=function(){var a;return a=this.context.get_opt("alias")||this.context.at.charCodeAt(0),this.$el.attr({id:"at-view-"+a})},b.prototype.destroy=function(){return this.$el.remove()},b.prototype.bind_event=function(){var b;return b=this.$el.find("ul"),b.on("mouseenter.atwho-view","li",function(c){return b.find(".cur").removeClass("cur"),a(c.currentTarget).addClass("cur")}).on("click.atwho-view","li",function(c){return function(d){return b.find(".cur").removeClass("cur"),a(d.currentTarget).addClass("cur"),c.choose(d),d.preventDefault()}}(this))},b.prototype.visible=function(){return this.$el.is(":visible")},b.prototype.choose=function(a){var b,c;return(b=this.$el.find(".cur")).length&&(c=this.context.insert_content_for(b),this.context.insert(this.context.callbacks("before_insert").call(this.context,c,b),b),this.context.trigger("inserted",[b,a]),this.hide(a)),this.context.get_opt("hide_without_suffix")?this.stop_showing=!0:void 0},b.prototype.reposition=function(b){var c,d,e,f;return f=this.context.app.iframeStandalone?this.context.app.window:window,b.bottom+this.$el.height()-a(f).scrollTop()>a(f).height()&&(b.bottom=b.top-this.$el.height()),b.left>(d=a(f).width()-this.$el.width()-5)&&(b.left=d),c={left:b.left,top:b.bottom},null!=(e=this.context.callbacks("before_reposition"))&&e.call(this.context,c),this.$el.offset(c),this.context.trigger("reposition",[c])},b.prototype.next=function(){var a,b;return a=this.$el.find(".cur").removeClass("cur"),b=a.next(),b.length||(b=this.$el.find("li:first")),b.addClass("cur"),this.$el.animate({scrollTop:Math.max(0,a.innerHeight()*(b.index()+2)-this.$el.height())},150)},b.prototype.prev=function(){var a,b;return a=this.$el.find(".cur").removeClass("cur"),b=a.prev(),b.length||(b=this.$el.find("li:last")),b.addClass("cur"),this.$el.animate({scrollTop:Math.max(0,a.innerHeight()*(b.index()+2)-this.$el.height())},150)},b.prototype.show=function(){var a;return this.stop_showing?void(this.stop_showing=!1):(this.context.mark_range(),this.visible()||(this.$el.show(),this.$el.scrollTop(0),this.context.trigger("shown")),(a=this.context.rect())?this.reposition(a):void 0)},b.prototype.hide=function(a,b){var c;if(this.visible())return isNaN(b)?(this.context.reset_rect(),this.$el.hide(),this.context.trigger("hidden",[a])):(c=function(a){return function(){return a.hide()}}(this),clearTimeout(this.timeout_id),this.timeout_id=setTimeout(c,b))},b.prototype.render=function(b){var c,d,e,f,g,h,i;if(!(a.isArray(b)&&b.length>0))return void this.hide();for(this.$el.find("ul").empty(),d=this.$el.find("ul"),g=this.context.get_opt("tpl"),h=0,i=b.length;i>h;h++)e=b[h],e=a.extend({},e,{"atwho-at":this.context.at}),f=this.context.callbacks("tpl_eval").call(this.context,g,e),c=a(this.context.callbacks("highlighter").call(this.context,f,this.context.query.text)),c.data("item-data",e),d.append(c);return this.show(),this.context.get_opt("highlight_first")?d.find("li:first").addClass("cur"):void 0},b}(),f={DOWN:40,UP:38,ESC:27,TAB:9,ENTER:13,CTRL:17,P:80,N:78},e={before_save:function(b){var c,d,e,f;if(!a.isArray(b))return b;for(f=[],d=0,e=b.length;e>d;d++)c=b[d],f.push(a.isPlainObject(c)?c:{name:c});return f},matcher:function(a,b,c){var d,e,f,g;return a=a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),c&&(a="(?:^|\\s)"+a),f=decodeURI("%C3%80"),g=decodeURI("%C3%BF"),e=new RegExp(""+a+"([A-Za-z"+f+"-"+g+"0-9_+-]*)$|"+a+"([^\\x00-\\xff]*)$","gi"),d=e.exec(b),d?d[2]||d[1]:null},filter:function(a,b,c){var d,e,f,g;for(g=[],e=0,f=b.length;f>e;e++)d=b[e],~new String(d[c]).toLowerCase().indexOf(a.toLowerCase())&&g.push(d);return g},remote_filter:null,sorter:function(a,b,c){var d,e,f,g;if(!a)return b;for(g=[],e=0,f=b.length;f>e;e++)d=b[e],d.atwho_order=new String(d[c]).toLowerCase().indexOf(a.toLowerCase()),d.atwho_order>-1&&g.push(d);return g.sort(function(a,b){return a.atwho_order-b.atwho_order})},tpl_eval:function(a,b){var c;try{return a.replace(/\$\{([^\}]*)\}/g,function(a,c){return b[c]})}catch(d){return c=d,""}},highlighter:function(a,b){var c;return b?(c=new RegExp(">\\s*(\\w*?)("+b.replace("+","\\+")+")(\\w*)\\s*<","ig"),a.replace(c,function(a,b,c,d){return"> "+b+"<strong>"+c+"</strong>"+d+" <"})):a},before_insert:function(a){return a},inserting_wrapper:function(a,b,c){var d;return c=""===c?c:c||" ",a.is("textarea, input")?""+b+c:"true"===a.attr("contentEditable")?(c=" "===c?"&nbsp;":c,/firefox/i.test(navigator.userAgent)?d="<span>"+b+c+"</span>":(c="<span contenteditable='false'>"+c+"</span>",d="<span contenteditable='false'>"+b+c+"</span>"),this.app.document.selection&&(d="<span contenteditable='true'>"+b+"</span>"),d+"<span></span>"):void 0}},b={load:function(a,b){var c;return(c=this.controller(a))?c.model.load(b):void 0},setIframe:function(a,b){return this.setIframe(a,b),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}},a.fn.atwho=function(d){var e,f;return f=arguments,e=null,this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function(){var g,h;return(h=(g=a(this)).data("atwho"))||g.data("atwho",h=new c(this)),"object"!=typeof d&&d?b[d]&&h?e=b[d].apply(h,Array.prototype.slice.call(f,1)):a.error("Method "+d+" does not exist on jQuery.caret"):h.reg(d.at,d)}),e||this},a.fn.atwho["default"]={at:void 0,alias:void 0,data:null,tpl:"<li data-value='${atwho-at}${name}'>${name}</li>",insert_tpl:"<span id='${id}'>${atwho-data-value}</span>",callbacks:e,search_key:"name",suffix:void 0,hide_without_suffix:!1,start_with_space:!0,highlight_first:!0,limit:5,max_len:20,display_timeout:300,delay:null}});
bp-core/js/jquery.caret.js CHANGED
@@ -36,11 +36,16 @@
36
  };
37
 
38
  EditableCaret.prototype.getIEPosition = function() {
39
- return $.noop();
40
  };
41
 
42
  EditableCaret.prototype.getPosition = function() {
43
- return $.noop();
 
 
 
 
 
44
  };
45
 
46
  EditableCaret.prototype.getOldIEPos = function() {
@@ -79,25 +84,38 @@
79
  };
80
 
81
  EditableCaret.prototype.getOffset = function(pos) {
82
- var clonedRange, offset, range, rect;
83
  if (oWindow.getSelection && (range = this.range())) {
84
- if (range.endOffset - 1 < 0) {
85
- return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
- clonedRange = range.cloneRange();
88
- clonedRange.setStart(range.endContainer, range.endOffset - 1);
89
- clonedRange.setEnd(range.endContainer, range.endOffset);
90
- rect = clonedRange.getBoundingClientRect();
91
- offset = {
92
- height: rect.height,
93
- left: rect.left + rect.width,
94
- top: rect.top
95
- };
96
- clonedRange.detach();
97
  } else if (oDocument.selection) {
98
  offset = this.getOldIEOffset();
99
  }
100
- if (offset && !oFrame) {
101
  offset.top += $(oWindow).scrollTop();
102
  offset.left += $(oWindow).scrollLeft();
103
  }
@@ -206,7 +224,7 @@
206
  var $inputor, at_rect, end_range, format, html, mirror, start_range;
207
  $inputor = this.$inputor;
208
  format = function(value) {
209
- return value.replace(/</g, '&lt').replace(/>/g, '&gt').replace(/`/g, '&#96').replace(/"/g, '&quot').replace(/\r\n|\r|\n/g, "<br />");
210
  };
211
  if (pos === void 0) {
212
  pos = this.getPos();
@@ -307,13 +325,8 @@
307
  }
308
  },
309
  offset: function(pos) {
310
- var iOffset, offset;
311
  offset = this.getOffset(pos);
312
- if (oFrame) {
313
- iOffset = $(oFrame).offset();
314
- offset.top += iOffset.top;
315
- offset.left += iOffset.left;
316
- }
317
  return offset;
318
  }
319
  };
36
  };
37
 
38
  EditableCaret.prototype.getIEPosition = function() {
39
+ return this.getPosition();
40
  };
41
 
42
  EditableCaret.prototype.getPosition = function() {
43
+ var inputor_offset, offset;
44
+ offset = this.getOffset();
45
+ inputor_offset = this.$inputor.offset();
46
+ offset.left -= inputor_offset.left;
47
+ offset.top -= inputor_offset.top;
48
+ return offset;
49
  };
50
 
51
  EditableCaret.prototype.getOldIEPos = function() {
84
  };
85
 
86
  EditableCaret.prototype.getOffset = function(pos) {
87
+ var clonedRange, offset, range, rect, shadowCaret;
88
  if (oWindow.getSelection && (range = this.range())) {
89
+ if (range.endOffset - 1 > 0 && range.endContainer === !this.domInputor) {
90
+ clonedRange = range.cloneRange();
91
+ clonedRange.setStart(range.endContainer, range.endOffset - 1);
92
+ clonedRange.setEnd(range.endContainer, range.endOffset);
93
+ rect = clonedRange.getBoundingClientRect();
94
+ offset = {
95
+ height: rect.height,
96
+ left: rect.left + rect.width,
97
+ top: rect.top
98
+ };
99
+ clonedRange.detach();
100
+ }
101
+ if (!offset || (offset != null ? offset.height : void 0) === 0) {
102
+ clonedRange = range.cloneRange();
103
+ shadowCaret = $(oDocument.createTextNode("|"));
104
+ clonedRange.insertNode(shadowCaret[0]);
105
+ clonedRange.selectNode(shadowCaret[0]);
106
+ rect = clonedRange.getBoundingClientRect();
107
+ offset = {
108
+ height: rect.height,
109
+ left: rect.left,
110
+ top: rect.top
111
+ };
112
+ shadowCaret.remove();
113
+ clonedRange.detach();
114
  }
 
 
 
 
 
 
 
 
 
 
115
  } else if (oDocument.selection) {
116
  offset = this.getOldIEOffset();
117
  }
118
+ if (offset) {
119
  offset.top += $(oWindow).scrollTop();
120
  offset.left += $(oWindow).scrollLeft();
121
  }
224
  var $inputor, at_rect, end_range, format, html, mirror, start_range;
225
  $inputor = this.$inputor;
226
  format = function(value) {
227
+ return $('<div></div>').text(value).html().replace(/\r\n|\r|\n/g, "<br/>").replace(/\s/g, "&nbsp;");
228
  };
229
  if (pos === void 0) {
230
  pos = this.getPos();
325
  }
326
  },
327
  offset: function(pos) {
328
+ var offset;
329
  offset = this.getOffset(pos);
 
 
 
 
 
330
  return offset;
331
  }
332
  };
bp-core/js/jquery.caret.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- (function(){!function(a){return"function"==typeof define&&define.amd?define(["jquery"],a):a(window.jQuery)}(function(a){"use strict";var b,c,d,e,f,g,h,i,j,k,l;return k="caret",b=function(){function b(a){this.$inputor=a,this.domInputor=this.$inputor[0]}return b.prototype.setPos=function(){return this.domInputor},b.prototype.getIEPosition=function(){return a.noop()},b.prototype.getPosition=function(){return a.noop()},b.prototype.getOldIEPos=function(){var a,b;return b=h.selection.createRange(),a=h.body.createTextRange(),a.moveToElementText(this.domInputor),a.setEndPoint("EndToEnd",b),a.text.length},b.prototype.getPos=function(){var a,b,c;return(c=this.range())?(a=c.cloneRange(),a.selectNodeContents(this.domInputor),a.setEnd(c.endContainer,c.endOffset),b=a.toString().length,a.detach(),b):h.selection?this.getOldIEPos():void 0},b.prototype.getOldIEOffset=function(){var a,b;return a=h.selection.createRange().duplicate(),a.moveStart("character",-1),b=a.getBoundingClientRect(),{height:b.bottom-b.top,left:b.left,top:b.top}},b.prototype.getOffset=function(){var b,c,d,e;if(j.getSelection&&(d=this.range())){if(d.endOffset-1<0)return null;b=d.cloneRange(),b.setStart(d.endContainer,d.endOffset-1),b.setEnd(d.endContainer,d.endOffset),e=b.getBoundingClientRect(),c={height:e.height,left:e.left+e.width,top:e.top},b.detach()}else h.selection&&(c=this.getOldIEOffset());return c&&!i&&(c.top+=a(j).scrollTop(),c.left+=a(j).scrollLeft()),c},b.prototype.range=function(){var a;if(j.getSelection)return a=j.getSelection(),a.rangeCount>0?a.getRangeAt(0):null},b}(),c=function(){function b(a){this.$inputor=a,this.domInputor=this.$inputor[0]}return b.prototype.getIEPos=function(){var a,b,c,d,e,f,g;return b=this.domInputor,f=h.selection.createRange(),e=0,f&&f.parentElement()===b&&(d=b.value.replace(/\r\n/g,"\n"),c=d.length,g=b.createTextRange(),g.moveToBookmark(f.getBookmark()),a=b.createTextRange(),a.collapse(!1),e=g.compareEndPoints("StartToEnd",a)>-1?c:-g.moveStart("character",-c)),e},b.prototype.getPos=function(){return h.selection?this.getIEPos():this.domInputor.selectionStart},b.prototype.setPos=function(a){var b,c;return b=this.domInputor,h.selection?(c=b.createTextRange(),c.move("character",a),c.select()):b.setSelectionRange&&b.setSelectionRange(a,a),b},b.prototype.getIEOffset=function(a){var b,c,d,e;return c=this.domInputor.createTextRange(),a||(a=this.getPos()),c.move("character",a),d=c.boundingLeft,e=c.boundingTop,b=c.boundingHeight,{left:d,top:e,height:b}},b.prototype.getOffset=function(b){var c,d,e;return c=this.$inputor,h.selection?(d=this.getIEOffset(b),d.top+=a(j).scrollTop()+c.scrollTop(),d.left+=a(j).scrollLeft()+c.scrollLeft(),d):(d=c.offset(),e=this.getPosition(b),d={left:d.left+e.left-c.scrollLeft(),top:d.top+e.top-c.scrollTop(),height:e.height})},b.prototype.getPosition=function(a){var b,c,e,f,g,h,i;return b=this.$inputor,f=function(a){return a.replace(/</g,"&lt").replace(/>/g,"&gt").replace(/`/g,"&#96").replace(/"/g,"&quot").replace(/\r\n|\r|\n/g,"<br />")},void 0===a&&(a=this.getPos()),i=b.val().slice(0,a),e=b.val().slice(a),g="<span style='position: relative; display: inline;'>"+f(i)+"</span>",g+="<span id='caret' style='position: relative; display: inline;'>|</span>",g+="<span style='position: relative; display: inline;'>"+f(e)+"</span>",h=new d(b),c=h.create(g).rect()},b.prototype.getIEPosition=function(a){var b,c,d,e,f;return d=this.getIEOffset(a),c=this.$inputor.offset(),e=d.left-c.left,f=d.top-c.top,b=d.height,{left:e,top:f,height:b}},b}(),d=function(){function b(a){this.$inputor=a}return b.prototype.css_attr=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],b.prototype.mirrorCss=function(){var b,c=this;return b={position:"absolute",left:-9999,top:0,zIndex:-2e4},"TEXTAREA"===this.$inputor.prop("tagName")&&this.css_attr.push("width"),a.each(this.css_attr,function(a,d){return b[d]=c.$inputor.css(d)}),b},b.prototype.create=function(b){return this.$mirror=a("<div></div>"),this.$mirror.css(this.mirrorCss()),this.$mirror.html(b),this.$inputor.after(this.$mirror),this},b.prototype.rect=function(){var a,b,c;return a=this.$mirror.find("#caret"),b=a.position(),c={left:b.left,top:b.top,height:a.height()},this.$mirror.remove(),c},b}(),e={contentEditable:function(a){return!(!a[0].contentEditable||"true"!==a[0].contentEditable)}},g={pos:function(a){return a||0===a?this.setPos(a):this.getPos()},position:function(a){return h.selection?this.getIEPosition(a):this.getPosition(a)},offset:function(b){var c,d;return d=this.getOffset(b),i&&(c=a(i).offset(),d.top+=c.top,d.left+=c.left),d}},h=null,j=null,i=null,l=function(a){var b;return(b=null!=a?a.iframe:void 0)?(i=b,j=b.contentWindow,h=b.contentDocument||j.document):(i=void 0,j=window,h=document)},f=function(a){var b;h=a[0].ownerDocument,j=h.defaultView||h.parentWindow;try{return i=j.frameElement}catch(c){b=c}},a.fn.caret=function(d,f,h){var i;return g[d]?(a.isPlainObject(f)?(l(f),f=void 0):l(h),i=e.contentEditable(this)?new b(this):new c(this),g[d].apply(i,[f])):a.error("Method "+d+" does not exist on jQuery.caret")},a.fn.caret.EditableCaret=b,a.fn.caret.InputCaret=c,a.fn.caret.Utils=e,a.fn.caret.apis=g})}).call(this);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ (function(){!function(a){return"function"==typeof define&&define.amd?define(["jquery"],a):a(window.jQuery)}(function(a){"use strict";var b,c,d,e,f,g,h,i,j,k,l;return k="caret",b=function(){function b(a){this.$inputor=a,this.domInputor=this.$inputor[0]}return b.prototype.setPos=function(){return this.domInputor},b.prototype.getIEPosition=function(){return this.getPosition()},b.prototype.getPosition=function(){var a,b;return b=this.getOffset(),a=this.$inputor.offset(),b.left-=a.left,b.top-=a.top,b},b.prototype.getOldIEPos=function(){var a,b;return b=h.selection.createRange(),a=h.body.createTextRange(),a.moveToElementText(this.domInputor),a.setEndPoint("EndToEnd",b),a.text.length},b.prototype.getPos=function(){var a,b,c;return(c=this.range())?(a=c.cloneRange(),a.selectNodeContents(this.domInputor),a.setEnd(c.endContainer,c.endOffset),b=a.toString().length,a.detach(),b):h.selection?this.getOldIEPos():void 0},b.prototype.getOldIEOffset=function(){var a,b;return a=h.selection.createRange().duplicate(),a.moveStart("character",-1),b=a.getBoundingClientRect(),{height:b.bottom-b.top,left:b.left,top:b.top}},b.prototype.getOffset=function(){var b,c,d,e,f;return j.getSelection&&(d=this.range())?(d.endOffset-1>0&&d.endContainer===!this.domInputor&&(b=d.cloneRange(),b.setStart(d.endContainer,d.endOffset-1),b.setEnd(d.endContainer,d.endOffset),e=b.getBoundingClientRect(),c={height:e.height,left:e.left+e.width,top:e.top},b.detach()),c&&0!==(null!=c?c.height:void 0)||(b=d.cloneRange(),f=a(h.createTextNode("|")),b.insertNode(f[0]),b.selectNode(f[0]),e=b.getBoundingClientRect(),c={height:e.height,left:e.left,top:e.top},f.remove(),b.detach())):h.selection&&(c=this.getOldIEOffset()),c&&(c.top+=a(j).scrollTop(),c.left+=a(j).scrollLeft()),c},b.prototype.range=function(){var a;if(j.getSelection)return a=j.getSelection(),a.rangeCount>0?a.getRangeAt(0):null},b}(),c=function(){function b(a){this.$inputor=a,this.domInputor=this.$inputor[0]}return b.prototype.getIEPos=function(){var a,b,c,d,e,f,g;return b=this.domInputor,f=h.selection.createRange(),e=0,f&&f.parentElement()===b&&(d=b.value.replace(/\r\n/g,"\n"),c=d.length,g=b.createTextRange(),g.moveToBookmark(f.getBookmark()),a=b.createTextRange(),a.collapse(!1),e=g.compareEndPoints("StartToEnd",a)>-1?c:-g.moveStart("character",-c)),e},b.prototype.getPos=function(){return h.selection?this.getIEPos():this.domInputor.selectionStart},b.prototype.setPos=function(a){var b,c;return b=this.domInputor,h.selection?(c=b.createTextRange(),c.move("character",a),c.select()):b.setSelectionRange&&b.setSelectionRange(a,a),b},b.prototype.getIEOffset=function(a){var b,c,d,e;return c=this.domInputor.createTextRange(),a||(a=this.getPos()),c.move("character",a),d=c.boundingLeft,e=c.boundingTop,b=c.boundingHeight,{left:d,top:e,height:b}},b.prototype.getOffset=function(b){var c,d,e;return c=this.$inputor,h.selection?(d=this.getIEOffset(b),d.top+=a(j).scrollTop()+c.scrollTop(),d.left+=a(j).scrollLeft()+c.scrollLeft(),d):(d=c.offset(),e=this.getPosition(b),d={left:d.left+e.left-c.scrollLeft(),top:d.top+e.top-c.scrollTop(),height:e.height})},b.prototype.getPosition=function(b){var c,e,f,g,h,i,j;return c=this.$inputor,g=function(b){return a("<div></div>").text(b).html().replace(/\r\n|\r|\n/g,"<br/>").replace(/\s/g,"&nbsp;")},void 0===b&&(b=this.getPos()),j=c.val().slice(0,b),f=c.val().slice(b),h="<span style='position: relative; display: inline;'>"+g(j)+"</span>",h+="<span id='caret' style='position: relative; display: inline;'>|</span>",h+="<span style='position: relative; display: inline;'>"+g(f)+"</span>",i=new d(c),e=i.create(h).rect()},b.prototype.getIEPosition=function(a){var b,c,d,e,f;return d=this.getIEOffset(a),c=this.$inputor.offset(),e=d.left-c.left,f=d.top-c.top,b=d.height,{left:e,top:f,height:b}},b}(),d=function(){function b(a){this.$inputor=a}return b.prototype.css_attr=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],b.prototype.mirrorCss=function(){var b,c=this;return b={position:"absolute",left:-9999,top:0,zIndex:-2e4},"TEXTAREA"===this.$inputor.prop("tagName")&&this.css_attr.push("width"),a.each(this.css_attr,function(a,d){return b[d]=c.$inputor.css(d)}),b},b.prototype.create=function(b){return this.$mirror=a("<div></div>"),this.$mirror.css(this.mirrorCss()),this.$mirror.html(b),this.$inputor.after(this.$mirror),this},b.prototype.rect=function(){var a,b,c;return a=this.$mirror.find("#caret"),b=a.position(),c={left:b.left,top:b.top,height:a.height()},this.$mirror.remove(),c},b}(),e={contentEditable:function(a){return!(!a[0].contentEditable||"true"!==a[0].contentEditable)}},g={pos:function(a){return a||0===a?this.setPos(a):this.getPos()},position:function(a){return h.selection?this.getIEPosition(a):this.getPosition(a)},offset:function(a){var b;return b=this.getOffset(a)}},h=null,j=null,i=null,l=function(a){var b;return(b=null!=a?a.iframe:void 0)?(i=b,j=b.contentWindow,h=b.contentDocument||j.document):(i=void 0,j=window,h=document)},f=function(a){var b;h=a[0].ownerDocument,j=h.defaultView||h.parentWindow;try{return i=j.frameElement}catch(c){b=c}},a.fn.caret=function(d,f,h){var i;return g[d]?(a.isPlainObject(f)?(l(f),f=void 0):l(h),i=e.contentEditable(this)?new b(this):new c(this),g[d].apply(i,[f])):a.error("Method "+d+" does not exist on jQuery.caret")},a.fn.caret.EditableCaret=b,a.fn.caret.InputCaret=c,a.fn.caret.Utils=e,a.fn.caret.apis=g})}).call(this);
bp-core/js/widget-members.js CHANGED
@@ -17,7 +17,7 @@ jQuery(document).ready( function() {
17
  function(response)
18
  {
19
  jQuery(link).removeClass('loading');
20
- member_wiget_response(response);
21
  });
22
 
23
  return false;
@@ -25,7 +25,7 @@ jQuery(document).ready( function() {
25
  );
26
  });
27
 
28
- function member_wiget_response(response) {
29
  response = response.substr(0, response.length-1);
30
  response = response.split('[[SPLIT]]');
31
 
17
  function(response)
18
  {
19
  jQuery(link).removeClass('loading');
20
+ member_widget_response(response);
21
  });
22
 
23
  return false;
25
  );
26
  });
27
 
28
+ function member_widget_response(response) {
29
  response = response.substr(0, response.length-1);
30
  response = response.split('[[SPLIT]]');
31
 
bp-core/js/widget-members.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- function member_wiget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#members-list").fadeOut(200,function(){jQuery(".widget ul#members-list").html(a[1]),jQuery(".widget ul#members-list").fadeIn(200)}):jQuery(".widget ul#members-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#members-list").html(b),jQuery(".widget ul#members-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#members-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#members-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_members",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-members").val(),"max-members":jQuery("input#members_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),member_wiget_response(b)}),!1})});
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ function member_widget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#members-list").fadeOut(200,function(){jQuery(".widget ul#members-list").html(a[1]),jQuery(".widget ul#members-list").fadeIn(200)}):jQuery(".widget ul#members-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#members-list").html(b),jQuery(".widget ul#members-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#members-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#members-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_members",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-members").val(),"max-members":jQuery("input#members_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),member_widget_response(b)}),!1})});
bp-forums/bp-forums-bbpress-sa.php CHANGED
@@ -18,7 +18,7 @@ function bp_forums_load_bbpress() {
18
  global $wpdb, $wp_roles, $current_user, $wp_users_object;
19
  global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
20
  global $bb_roles, $wp_taxonomy_object, $bb_queries;
21
-
22
  // Return if we've already run this function.
23
  if ( is_object( $bbdb ) )
24
  return;
@@ -171,7 +171,7 @@ class BP_Forums_BB_Auth {
171
  * bbPress needs the DB class to be BPDB, but we want to use WPDB, so we can extend it and use this.
172
  *
173
  * The class is pluggable, so that plugins that swap out WPDB with a custom
174
- * database class (such as HyperDB and SharDB) can provide their own versions
175
  * of BPDB which extend the appropriate base class.
176
  */
177
  if ( ! class_exists( 'BPDB' ) ) :
@@ -196,7 +196,7 @@ if ( ! class_exists( 'BPDB' ) ) :
196
  /**
197
  * Determine if a database supports a particular feature.
198
  *
199
- * Overriden here to work around differences between bbPress's
200
  * and WordPress's implementations. In particular, when
201
  * BuddyPress tries to run bbPress' SQL installation script,
202
  * the collation check always failed. The capability is long
@@ -339,7 +339,7 @@ function bp_bb_dbDelta($queries, $execute = true) {
339
  if ( array_key_exists(strtolower($table), $cqueries) ) {
340
  // Clear the field and index arrays
341
  $cfields = $indices = array();
342
- // Get all of the field names in the query from between the parens
343
  preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2);
344
  $qryline = trim($match2[1]);
345
 
18
  global $wpdb, $wp_roles, $current_user, $wp_users_object;
19
  global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
20
  global $bb_roles, $wp_taxonomy_object, $bb_queries;
21
+
22
  // Return if we've already run this function.
23
  if ( is_object( $bbdb ) )
24
  return;
171
  * bbPress needs the DB class to be BPDB, but we want to use WPDB, so we can extend it and use this.
172
  *
173
  * The class is pluggable, so that plugins that swap out WPDB with a custom
174
+ * database class (such as HyperDB and ShareDB) can provide their own versions
175
  * of BPDB which extend the appropriate base class.
176
  */
177
  if ( ! class_exists( 'BPDB' ) ) :
196
  /**
197
  * Determine if a database supports a particular feature.
198
  *
199
+ * Overridden here to work around differences between bbPress's
200
  * and WordPress's implementations. In particular, when
201
  * BuddyPress tries to run bbPress' SQL installation script,
202
  * the collation check always failed. The capability is long
339
  if ( array_key_exists(strtolower($table), $cqueries) ) {
340
  // Clear the field and index arrays
341
  $cfields = $indices = array();
342
+ // Get all of the field names in the query from between the parents
343
  preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2);
344
  $qryline = trim($match2[1]);
345
 
bp-forums/bp-forums-functions.php CHANGED
@@ -129,7 +129,7 @@ function bp_forums_new_forum( $args = '' ) {
129
  * @type bool $forum_order Order.
130
  * @type int $forum_is_category Whether the forum is a category. Default: 0.
131
  * }
132
- * @return bool Ttrue on success, false on failure.
133
  */
134
  function bp_forums_update_forum( $args = '' ) {
135
  do_action( 'bbpress_init' );
@@ -308,7 +308,7 @@ function bp_forums_new_topic( $args = '' ) {
308
  'topic_start_time' => bp_core_current_time(),
309
  'topic_time' => bp_core_current_time(),
310
  'topic_open' => 1,
311
- 'topic_tags' => false, // accepts array or comma delim
312
  'forum_id' => 0 // accepts ids or slugs
313
  ) );
314
  extract( $r, EXTR_SKIP );
129
  * @type bool $forum_order Order.
130
  * @type int $forum_is_category Whether the forum is a category. Default: 0.
131
  * }
132
+ * @return bool True on success, false on failure.
133
  */
134
  function bp_forums_update_forum( $args = '' ) {
135
  do_action( 'bbpress_init' );
308
  'topic_start_time' => bp_core_current_time(),
309
  'topic_time' => bp_core_current_time(),
310
  'topic_open' => 1,
311
+ 'topic_tags' => false, // accepts array or comma delimited
312
  'forum_id' => 0 // accepts ids or slugs
313
  ) );
314
  extract( $r, EXTR_SKIP );
bp-forums/bp-forums-screens.php CHANGED
@@ -140,12 +140,12 @@ function bp_forums_screen_single_topic() {
140
  add_action( 'bp_screens', 'bp_forums_screen_single_topic' );
141
 
142
 
143
- /** Theme Compatability *******************************************************/
144
 
145
  /**
146
  * The main theme compat class for legacy BuddyPress forums.
147
  *
148
- * This class sets up the necessary theme compatability actions to safely output
149
  * old forum template parts to the_title and the_content areas of a theme.
150
  *
151
  * @since BuddyPress (1.7.0)
@@ -162,7 +162,7 @@ class BP_Forum_Legacy_Theme_Compat {
162
  }
163
 
164
  /**
165
- * Are we looking at something that needs old forum theme compatability?
166
  *
167
  * @since BuddyPress (1.7.0)
168
  */
140
  add_action( 'bp_screens', 'bp_forums_screen_single_topic' );
141
 
142
 
143
+ /** Theme Compatibility *******************************************************/
144
 
145
  /**
146
  * The main theme compat class for legacy BuddyPress forums.
147
  *
148
+ * This class sets up the necessary theme compatibility actions to safely output
149
  * old forum template parts to the_title and the_content areas of a theme.
150
  *
151
  * @since BuddyPress (1.7.0)
162
  }
163
 
164
  /**
165
+ * Are we looking at something that needs old forum theme compatibility?
166
  *
167
  * @since BuddyPress (1.7.0)
168
  */
bp-forums/bp-forums-template.php CHANGED
@@ -69,7 +69,7 @@ function bp_forums_directory_permalink() {
69
  * @since BuddyPress (1.5.0)
70
  *
71
  * @uses apply_filters()
72
- * @uses traisingslashit()
73
  * @uses bp_get_root_domain()
74
  * @uses bp_get_forums_root_slug()
75
  *
@@ -137,7 +137,7 @@ class BP_Forums_Template_Forum {
137
  * The page number being requested.
138
  *
139
  * @access public
140
- * @var public
141
  */
142
  var $pag_page;
143
 
@@ -145,7 +145,7 @@ class BP_Forums_Template_Forum {
145
  * The number of items being requested per page.
146
  *
147
  * @access public
148
- * @var public
149
  */
150
  var $pag_num;
151
 
@@ -199,7 +199,7 @@ class BP_Forums_Template_Forum {
199
  * @param int $user_id The ID of the user to whom topics should be
200
  * limited. Pass false to remove this filter.
201
  * @param int $page The number of the page being requested.
202
- * @param int $per_page The number of items being requested perpage.
203
  * @param string $no_stickies Requested sticky format.
204
  * @param string $search_terms Filter results by a string.
205
  * @param int $offset Optional. Offset results by a given numeric value.
@@ -295,7 +295,8 @@ class BP_Forums_Template_Forum {
295
  'current' => $this->pag_page,
296
  'prev_text' => _x( '&larr;', 'Forum topic pagination previous text', 'buddypress' ),
297
  'next_text' => _x( '&rarr;', 'Forum topic pagination next text', 'buddypress' ),
298
- 'mid_size' => 1
 
299
  ) );
300
  }
301
  }
@@ -567,7 +568,8 @@ function bp_has_forum_topics( $args = '' ) {
567
  'current' => $forum_template->pag_page,
568
  'prev_text' => _x( '&larr;', 'Forum topic pagination previous text', 'buddypress' ),
569
  'next_text' => _x( '&rarr;', 'Forum topic pagination next text', 'buddypress' ),
570
- 'mid_size' => 1
 
571
  ) );
572
 
573
  } else {
@@ -1273,7 +1275,7 @@ function bp_the_topic_admin_links( $args = '' ) {
1273
  * Return the admin links for the current topic in the loop.
1274
  *
1275
  * @param array $args {
1276
- * @type string $seperator The character to use when separating
1277
  * links. Default: '|'.
1278
  * }
1279
  * @return HTML string containing the admin links for the current topic.
@@ -1282,7 +1284,7 @@ function bp_the_topic_admin_links( $args = '' ) {
1282
  global $forum_template;
1283
 
1284
  $defaults = array(
1285
- 'seperator' => '|'
1286
  );
1287
 
1288
  $r = wp_parse_args( $args, $defaults );
@@ -1304,7 +1306,7 @@ function bp_the_topic_admin_links( $args = '' ) {
1304
  $links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete Topic', 'buddypress' ) . '</a>';
1305
  }
1306
 
1307
- return implode( ' ' . $seperator . ' ', (array) $links );
1308
  }
1309
 
1310
  /**
@@ -1735,7 +1737,8 @@ class BP_Forums_Template_Topic {
1735
  'current' => $this->pag_page,
1736
  'prev_text' => _x( '&larr;', 'Forum thread pagination previous text', 'buddypress' ),
1737
  'next_text' => _x( '&rarr;', 'Forum thread pagination next text', 'buddypress' ),
1738
- 'mid_size' => 1
 
1739
  ) );
1740
 
1741
  $this->pag->total_pages = ceil( (int) $this->total_post_count / (int) $this->pag_num );
69
  * @since BuddyPress (1.5.0)
70
  *
71
  * @uses apply_filters()
72
+ * @uses trailingslashit()
73
  * @uses bp_get_root_domain()
74
  * @uses bp_get_forums_root_slug()
75
  *
137
  * The page number being requested.
138
  *
139
  * @access public
140
+ * @var int
141
  */
142
  var $pag_page;
143
 
145
  * The number of items being requested per page.
146
  *
147
  * @access public
148
+ * @var int
149
  */
150
  var $pag_num;
151
 
199
  * @param int $user_id The ID of the user to whom topics should be
200
  * limited. Pass false to remove this filter.
201
  * @param int $page The number of the page being requested.
202
+ * @param int $per_page The number of items being requested per page.
203
  * @param string $no_stickies Requested sticky format.
204
  * @param string $search_terms Filter results by a string.
205
  * @param int $offset Optional. Offset results by a given numeric value.
295
  'current' => $this->pag_page,
296
  'prev_text' => _x( '&larr;', 'Forum topic pagination previous text', 'buddypress' ),
297
  'next_text' => _x( '&rarr;', 'Forum topic pagination next text', 'buddypress' ),
298
+ 'mid_size' => 1,
299
+ 'add_args' => array(),
300
  ) );
301
  }
302
  }
568
  'current' => $forum_template->pag_page,
569
  'prev_text' => _x( '&larr;', 'Forum topic pagination previous text', 'buddypress' ),
570
  'next_text' => _x( '&rarr;', 'Forum topic pagination next text', 'buddypress' ),
571
+ 'mid_size' => 1,
572
+ 'add_args' => array(),
573
  ) );
574
 
575
  } else {
1275
  * Return the admin links for the current topic in the loop.
1276
  *
1277
  * @param array $args {
1278
+ * @type string $separator The character to use when separating
1279
  * links. Default: '|'.
1280
  * }
1281
  * @return HTML string containing the admin links for the current topic.
1284
  global $forum_template;
1285
 
1286
  $defaults = array(
1287
+ 'separator' => '|'
1288
  );
1289
 
1290
  $r = wp_parse_args( $args, $defaults );
1306
  $links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete Topic', 'buddypress' ) . '</a>';
1307
  }
1308
 
1309
+ return implode( ' ' . $separator . ' ', (array) $links );
1310
  }
1311
 
1312
  /**
1737
  'current' => $this->pag_page,
1738
  'prev_text' => _x( '&larr;', 'Forum thread pagination previous text', 'buddypress' ),
1739
  'next_text' => _x( '&rarr;', 'Forum thread pagination next text', 'buddypress' ),
1740
+ 'mid_size' => 1,
1741
+ 'add_args' => array(),
1742
  ) );
1743
 
1744
  $this->pag->total_pages = ceil( (int) $this->total_post_count / (int) $this->pag_num );
bp-forums/deprecated/1.6.php CHANGED
@@ -140,7 +140,7 @@ function bp_forums_bbpress_install_wizard() {
140
  case 'existing':
141
  if ( isset( $_REQUEST['doinstall'] ) && ( 1 == (int) $_REQUEST['doinstall'] ) ) {
142
  if ( !bp_forums_configure_existing_install() ) {
143
- _e( 'The bb-config.php file was not found at that location, please try again.', 'buddypress' );
144
  } else {
145
  ?>
146
  <h3><?php _e( 'Forums were set up correctly using your existing bbPress install!', 'buddypress' ) ?></h3>
140
  case 'existing':
141
  if ( isset( $_REQUEST['doinstall'] ) && ( 1 == (int) $_REQUEST['doinstall'] ) ) {
142
  if ( !bp_forums_configure_existing_install() ) {
143
+ _e( 'The bb-config.php file was not found at that location. Please try again.', 'buddypress' );
144
  } else {
145
  ?>
146
  <h3><?php _e( 'Forums were set up correctly using your existing bbPress install!', 'buddypress' ) ?></h3>
bp-friends/bp-friends-actions.php CHANGED
@@ -40,7 +40,7 @@ function friends_action_add_friend() {
40
  bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
41
  }
42
 
43
- } else if ( 'is_friend' == $friendship_status ) {
44
  bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
45
  } else {
46
  bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );
@@ -78,7 +78,7 @@ function friends_action_remove_friend() {
78
  bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
79
  }
80
 
81
- } else if ( 'is_friends' == $friendship_status ) {
82
  bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
83
  } else {
84
  bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
40
  bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
41
  }
42
 
43
+ } elseif ( 'is_friend' == $friendship_status ) {
44
  bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
45
  } else {
46
  bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );
78
  bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
79
  }
80
 
81
+ } elseif ( 'is_friends' == $friendship_status ) {
82
  bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
83
  } else {
84
  bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
bp-friends/bp-friends-activity.php CHANGED
@@ -113,6 +113,11 @@ function friends_register_activity_actions() {
113
  // < BP 1.6 backpat
114
  bp_activity_set_action( $bp->friends->id, 'friends_register_activity_action', __( 'New friendship created', 'buddypress' ) );
115
 
 
 
 
 
 
116
  do_action( 'friends_register_activity_actions' );
117
  }
118
  add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
@@ -139,6 +144,14 @@ function bp_friends_format_activity_action_friendship_accepted( $action, $activi
139
  $action = apply_filters( 'friends_activity_friendsip_accepted_action', $action, $friendship );
140
  }
141
 
 
 
 
 
 
 
 
 
142
  return apply_filters( 'bp_friends_format_activity_action_friendship_accepted', $action, $activity );
143
  }
144
 
@@ -165,6 +178,14 @@ function bp_friends_format_activity_action_friendship_created( $action, $activit
165
  $action = apply_filters( 'friends_activity_friendsip_accepted_action', $action, $friendship );
166
  }
167
 
 
 
 
 
 
 
 
 
168
  return apply_filters( 'bp_friends_format_activity_action_friendship_created', $action, $activity );
169
  }
170
 
@@ -206,6 +227,109 @@ function bp_friends_prefetch_activity_object_data( $activities ) {
206
  }
207
  add_filter( 'bp_activity_prefetch_object_data', 'bp_friends_prefetch_activity_object_data' );
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  /**
210
  * Add activity stream items when one members accepts another members request
211
  * for virtual friendship.
@@ -218,16 +342,10 @@ add_filter( 'bp_activity_prefetch_object_data', 'bp_friends_prefetch_activity_ob
218
  * @param object $friendship Optional
219
  */
220
  function bp_friends_friendship_accepted_activity( $friendship_id, $initiator_user_id, $friend_user_id, $friendship = false ) {
221
-
222
- // Bail if Activity component is not active
223
  if ( ! bp_is_active( 'activity' ) ) {
224
  return;
225
  }
226
 
227
- // Get links to both members profiles
228
- $initiator_link = bp_core_get_userlink( $initiator_user_id );
229
- $friend_link = bp_core_get_userlink( $friend_user_id );
230
-
231
  // Record in activity streams for the initiator
232
  friends_record_activity( array(
233
  'user_id' => $initiator_user_id,
@@ -235,14 +353,5 @@ function bp_friends_friendship_accepted_activity( $friendship_id, $initiator_use
235
  'item_id' => $friendship_id,
236
  'secondary_item_id' => $friend_user_id
237
  ) );
238
-
239
- // Record in activity streams for the friend
240
- friends_record_activity( array(
241
- 'user_id' => $friend_user_id,
242
- 'type' => 'friendship_created',
243
- 'item_id' => $friendship_id,
244
- 'secondary_item_id' => $initiator_user_id,
245
- 'hide_sitewide' => true // We've already got the first entry site wide
246
- ) );
247
  }
248
  add_action( 'friends_friendship_accepted', 'bp_friends_friendship_accepted_activity', 10, 4 );
113
  // < BP 1.6 backpat
114
  bp_activity_set_action( $bp->friends->id, 'friends_register_activity_action', __( 'New friendship created', 'buddypress' ) );
115
 
116
+ /**
117
+ * Fires after all default bp-friends activity actions have been registered.
118
+ *
119
+ * @since BuddyPress (1.1.0)
120
+ */
121
  do_action( 'friends_register_activity_actions' );
122
  }
123
  add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
144
  $action = apply_filters( 'friends_activity_friendsip_accepted_action', $action, $friendship );
145
  }
146
 
147
+ /**
148
+ * Filters the 'friendship_accepted' activity action format.
149
+ *
150
+ * @since BuddyPress (2.0.0)
151
+ *
152
+ * @param string $action String text for the 'friendship_accepted' action.
153
+ * @param object $activity Activity data.
154
+ */
155
  return apply_filters( 'bp_friends_format_activity_action_friendship_accepted', $action, $activity );
156
  }
157
 
178
  $action = apply_filters( 'friends_activity_friendsip_accepted_action', $action, $friendship );
179
  }
180
 
181
+ /**
182
+ * Filters the 'friendship_created' activity action format.
183
+ *
184
+ * @since BuddyPress (2.0.0)
185
+ *
186
+ * @param string $action String text for the 'friendship_created' action.
187
+ * @param object $activity Activity data.
188
+ */
189
  return apply_filters( 'bp_friends_format_activity_action_friendship_created', $action, $activity );
190
  }
191
 
227
  }
228
  add_filter( 'bp_activity_prefetch_object_data', 'bp_friends_prefetch_activity_object_data' );
229
 
230
+ /**
231
+ * Set up activity arguments for use with the 'friends' scope.
232
+ *
233
+ * For details on the syntax, see {@link BP_Activity_Query}.
234
+ *
235
+ * @since BuddyPress (2.2.0)
236
+ *
237
+ * @param array $retval Empty array by default
238
+ * @param array $filter Current activity arguments
239
+ * @return array
240
+ */
241
+ function bp_friends_filter_activity_scope( $retval, $filter ) {
242
+ $friends = friends_get_friend_user_ids( $filter['user_id'] );
243
+
244
+ if ( empty( $friends ) ) {
245
+ return $retval;
246
+ }
247
+
248
+ $retval= array(
249
+ 'relation' => 'AND',
250
+ array(
251
+ 'column' => 'user_id',
252
+ 'compare' => 'IN',
253
+ 'value' => (array) $friends
254
+ ),
255
+ // we should only be able to view sitewide activity content for friends
256
+ array(
257
+ 'column' => 'hide_sitewide',
258
+ 'value' => 0
259
+ ),
260
+ );
261
+
262
+ // wipe out the user ID
263
+ $retval['override']['filter']['user_id'] = 0;
264
+
265
+ // make sure we aren't limiting items by 'hide_sitewide' since we're already
266
+ // limiting it above
267
+ $retval['override']['show_hidden'] = true;
268
+
269
+ return $retval;
270
+ }
271
+ add_filter( 'bp_activity_set_friends_scope_args', 'bp_friends_filter_activity_scope', 10, 2 );
272
+
273
+ /**
274
+ * Set up activity arguments for use with the 'just-me' scope.
275
+ *
276
+ * For details on the syntax, see {@link BP_Activity_Query}.
277
+ *
278
+ * @since BuddyPress (2.2.0)
279
+ *
280
+ * @param array $retval Empty array by default
281
+ * @param array $filter Current activity arguments
282
+ * @return array
283
+ */
284
+ function bp_friends_filter_activity_just_me_scope( $retval, $filter ) {
285
+ // Get the requested action
286
+ $action = $filter['filter']['action'];
287
+
288
+ // Make sure actions are listed in an array
289
+ if ( ! is_array( $action ) ) {
290
+ $action = explode( ',', $filter['filter']['action'] );
291
+ }
292
+
293
+ $action = array_flip( array_filter( $action ) );
294
+
295
+ /**
296
+ * If filtering activities for something other than the friendship_created action
297
+ * return without changing anything
298
+ */
299
+ if ( ! empty( $action ) && ! isset( $action['friendship_created'] ) ) {
300
+ return $retval;
301
+ }
302
+
303
+ /**
304
+ * Else make sure to get the friendship_created action, the user is involved in
305
+ * - user initiated the friendship
306
+ * - user has been requested a friendship
307
+ */
308
+ return array(
309
+ 'relation' => 'OR',
310
+ array(
311
+ 'column' => 'user_id',
312
+ 'value' => $filter['user_id']
313
+ ),
314
+ array(
315
+ 'relation' => 'AND',
316
+ array(
317
+ 'column' => 'component',
318
+ 'value' => 'friends',
319
+ ),
320
+ array(
321
+ 'column' => 'secondary_item_id',
322
+ 'value' => $filter['user_id'],
323
+ ),
324
+ ),
325
+ 'override' => array(
326
+ 'display_comments' => 'stream',
327
+ 'filter' => array( 'user_id' => 0 ),
328
+ ),
329
+ );
330
+ }
331
+ add_filter( 'bp_activity_set_just-me_scope_args', 'bp_friends_filter_activity_just_me_scope', 20, 2 );
332
+
333
  /**
334
  * Add activity stream items when one members accepts another members request
335
  * for virtual friendship.
342
  * @param object $friendship Optional
343
  */
344
  function bp_friends_friendship_accepted_activity( $friendship_id, $initiator_user_id, $friend_user_id, $friendship = false ) {
 
 
345
  if ( ! bp_is_active( 'activity' ) ) {
346
  return;
347
  }
348
 
 
 
 
 
349
  // Record in activity streams for the initiator
350
  friends_record_activity( array(
351
  'user_id' => $initiator_user_id,
353
  'item_id' => $friendship_id,
354
  'secondary_item_id' => $friend_user_id
355
  ) );
 
 
 
 
 
 
 
 
 
356
  }
357
  add_action( 'friends_friendship_accepted', 'bp_friends_friendship_accepted_activity', 10, 4 );
bp-friends/bp-friends-classes.php CHANGED
@@ -145,6 +145,13 @@ class BP_Friends_Friendship {
145
  $this->is_limited = apply_filters( 'friends_friendship_is_limited_before_save', $this->is_limited, $this->id );
146
  $this->date_created = apply_filters( 'friends_friendship_date_created_before_save', $this->date_created, $this->id );
147
 
 
 
 
 
 
 
 
148
  do_action_ref_array( 'friends_friendship_before_save', array( &$this ) );
149
 
150
  // Update
@@ -157,6 +164,13 @@ class BP_Friends_Friendship {
157
  $this->id = $wpdb->insert_id;
158
  }
159
 
 
 
 
 
 
 
 
160
  do_action( 'friends_friendship_after_save', array( &$this ) );
161
 
162
  return $result;
@@ -172,7 +186,7 @@ class BP_Friends_Friendship {
172
  /**
173
  * Get the IDs of a given user's friends.
174
  *
175
- * @param int $user_id ID of the user whose friends are being retreived.
176
  * @param bool $friend_requests_only Optional. Whether to fetch
177
  * unaccepted requests only. Default: false.
178
  * @param bool $assoc_arr Optional. True to receive an array of arrays
145
  $this->is_limited = apply_filters( 'friends_friendship_is_limited_before_save', $this->is_limited, $this->id );
146
  $this->date_created = apply_filters( 'friends_friendship_date_created_before_save', $this->date_created, $this->id );
147
 
148
+ /**
149
+ * Fires before processing and saving the current friendship request.
150
+ *
151
+ * @since BuddyPress (1.0.0)
152
+ *
153
+ * @param Object $value Current friendship request object.
154
+ */
155
  do_action_ref_array( 'friends_friendship_before_save', array( &$this ) );
156
 
157
  // Update
164
  $this->id = $wpdb->insert_id;
165
  }
166
 
167
+ /**
168
+ * Fires after processing and saving the current friendship request.
169
+ *
170
+ * @since BuddyPress (1.0.0)
171
+ *
172
+ * @param Object $value Current friendship request object.
173
+ */
174
  do_action( 'friends_friendship_after_save', array( &$this ) );
175
 
176
  return $result;
186
  /**
187
  * Get the IDs of a given user's friends.
188
  *
189
+ * @param int $user_id ID of the user whose friends are being retrieved.
190
  * @param bool $friend_requests_only Optional. Whether to fetch
191
  * unaccepted requests only. Default: false.
192
  * @param bool $assoc_arr Optional. True to receive an array of arrays
bp-friends/bp-friends-functions.php CHANGED
@@ -59,16 +59,28 @@ function friends_add_friend( $initiator_userid, $friend_userid, $force_accept =
59
 
60
  // Send notifications
61
  if ( empty( $force_accept ) ) {
62
- $action = 'friends_friendship_requested';
63
 
64
  // Update friend totals
65
  } else {
66
- $action = 'friends_friendship_accepted';
67
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id, 'add' );
68
  }
69
 
70
- // Call the above titled action and pass friendship data into it
71
- do_action( $action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship );
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  return true;
74
  }
@@ -87,18 +99,46 @@ function friends_remove_friend( $initiator_userid, $friend_userid ) {
87
  $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
88
  $friendship = new BP_Friends_Friendship( $friendship_id );
89
 
 
 
 
 
 
 
 
 
 
 
90
  do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid );
91
 
92
- // Remove the activity stream item for the user who canceled the friendship
93
- friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => bp_displayed_user_id() ) );
94
-
95
- // This hook is misleadingly named - the friendship is not yet deleted.
96
- // This is your last chance to do something while the friendship exists
 
 
 
 
 
 
 
 
 
 
97
  do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
98
 
99
  if ( $friendship->delete() ) {
100
  friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
101
 
 
 
 
 
 
 
 
 
102
  do_action( 'friends_friendship_post_delete', $initiator_userid, $friend_userid );
103
 
104
  return true;
@@ -117,7 +157,7 @@ function friends_remove_friend( $initiator_userid, $friend_userid ) {
117
  */
118
  function friends_accept_friendship( $friendship_id ) {
119
 
120
- // Get the friesdhip data
121
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
122
 
123
  // Accepting friendship
@@ -126,6 +166,16 @@ function friends_accept_friendship( $friendship_id ) {
126
  // Bump the friendship counts
127
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
128
 
 
 
 
 
 
 
 
 
 
 
129
  do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship );
130
 
131
  return true;
@@ -144,6 +194,15 @@ function friends_reject_friendship( $friendship_id ) {
144
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
145
 
146
  if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::reject( $friendship_id ) ) {
 
 
 
 
 
 
 
 
 
147
  do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
148
  return true;
149
  }
@@ -168,7 +227,14 @@ function friends_withdraw_friendship( $initiator_userid, $friend_userid ) {
168
  // @deprecated Since 1.9
169
  do_action_ref_array( 'friends_friendship_whithdrawn', array( $friendship_id, &$friendship ) );
170
 
171
- // @since 1.9
 
 
 
 
 
 
 
172
  do_action_ref_array( 'friends_friendship_withdrawn', array( $friendship_id, &$friendship ) );
173
 
174
  return true;
@@ -234,6 +300,13 @@ function friends_get_total_friend_count( $user_id = 0 ) {
234
  if ( empty( $count ) )
235
  $count = 0;
236
 
 
 
 
 
 
 
 
237
  return apply_filters( 'friends_get_total_friend_count', $count );
238
  }
239
 
@@ -269,7 +342,7 @@ function friends_get_friendship_id( $initiator_user_id, $friend_user_id ) {
269
  /**
270
  * Get the IDs of a given user's friends.
271
  *
272
- * @param int $user_id ID of the user whose friends are being retreived.
273
  * @param bool $friend_requests_only Optional. Whether to fetch unaccepted
274
  * requests only. Default: false.
275
  * @param bool $assoc_arr Optional. True to receive an array of arrays keyed as
@@ -315,7 +388,7 @@ function friends_get_friendship_request_user_ids( $user_id ) {
315
  *
316
  * @see BP_Core_User::get_users() for a description of return value.
317
  *
318
- * @param int $user_id ID of the user whose friends are being retreived.
319
  * @param int $per_page Optional. Number of results to return per page.
320
  * Default: 0 (no pagination; show all results).
321
  * @param int $page Optional. Number of the page of results to return.
@@ -325,6 +398,17 @@ function friends_get_friendship_request_user_ids( $user_id ) {
325
  * @return array See {@link BP_Core_User::get_users()}.
326
  */
327
  function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
 
 
 
 
 
 
 
 
 
 
 
328
  return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
329
  }
330
 
@@ -333,7 +417,7 @@ function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filte
333
  *
334
  * @see BP_Core_User::get_users() for a description of return value.
335
  *
336
- * @param int $user_id ID of the user whose friends are being retreived.
337
  * @param int $per_page Optional. Number of results to return per page.
338
  * Default: 0 (no pagination; show all results).
339
  * @param int $page Optional. Number of the page of results to return.
@@ -343,6 +427,17 @@ function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filte
343
  * @return array See {@link BP_Core_User::get_users()}.
344
  */
345
  function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
 
 
 
 
 
 
 
 
 
 
 
346
  return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
347
  }
348
 
@@ -351,7 +446,7 @@ function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter
351
  *
352
  * @see BP_Core_User::get_users() for a description of return value.
353
  *
354
- * @param int $user_id ID of the user whose friends are being retreived.
355
  * @param int $per_page Optional. Number of results to return per page.
356
  * Default: 0 (no pagination; show all results).
357
  * @param int $page Optional. Number of the page of results to return.
@@ -361,6 +456,17 @@ function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter
361
  * @return array See {@link BP_Core_User::get_users()}.
362
  */
363
  function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
 
 
 
 
 
 
 
 
 
 
 
364
  return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
365
  }
366
 
@@ -402,7 +508,13 @@ function friends_get_friends_invite_list( $user_id = 0, $group_id = 0 ) {
402
  // Assume no friends
403
  $friends = array();
404
 
405
- // Default args
 
 
 
 
 
 
406
  $args = apply_filters( 'bp_friends_pre_get_invite_list', array(
407
  'user_id' => $user_id,
408
  'type' => 'alphabetical',
@@ -449,7 +561,15 @@ function friends_get_friends_invite_list( $user_id = 0, $group_id = 0 ) {
449
  if ( empty( $friends ) )
450
  $friends = false;
451
 
452
- // Allow friends to be filtered
 
 
 
 
 
 
 
 
453
  return apply_filters( 'bp_friends_get_invite_list', $friends, $user_id, $group_id );
454
  }
455
 
@@ -554,6 +674,13 @@ function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $sta
554
  */
555
  function friends_remove_data( $user_id ) {
556
 
 
 
 
 
 
 
 
557
  do_action( 'friends_before_remove_data', $user_id );
558
 
559
  BP_Friends_Friendship::delete_all_for_user( $user_id );
@@ -561,6 +688,13 @@ function friends_remove_data( $user_id ) {
561
  // Remove usermeta
562
  bp_delete_user_meta( $user_id, 'total_friend_count' );
563
 
 
 
 
 
 
 
 
564
  do_action( 'friends_remove_data', $user_id );
565
  }
566
  add_action( 'wpmu_delete_user', 'friends_remove_data' );
@@ -579,6 +713,15 @@ function bp_friends_prime_mentions_results() {
579
  return;
580
  }
581
 
 
 
 
 
 
 
 
 
 
582
  $friends_query = array(
583
  'count_total' => '', // Prevents total count
584
  'populate_extras' => false,
@@ -594,7 +737,12 @@ function bp_friends_prime_mentions_results() {
594
  $result = new stdClass();
595
  $result->ID = $user->user_nicename;
596
  $result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) );
597
- $result->name = bp_core_get_user_displayname( $user->ID );
 
 
 
 
 
598
 
599
  $results[] = $result;
600
  }
@@ -603,4 +751,4 @@ function bp_friends_prime_mentions_results() {
603
  'friends' => $results,
604
  ) );
605
  }
606
- add_action( 'bp_activity_mentions_prime_results', 'bp_friends_prime_mentions_results' );
59
 
60
  // Send notifications
61
  if ( empty( $force_accept ) ) {
62
+ $action = 'requested';
63
 
64
  // Update friend totals
65
  } else {
66
+ $action = 'accepted';
67
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id, 'add' );
68
  }
69
 
70
+ /**
71
+ * Fires at the end of initiating a new friendship connection.
72
+ *
73
+ * This is a variable hook, depending on context.
74
+ * The two potential hooks are: friends_friendship_requested, friends_friendship_accepted.
75
+ *
76
+ * @since BuddyPress (1.0.0)
77
+ *
78
+ * @param int $id ID of the pending friendship connection.
79
+ * @param int $initiator_user_id ID of the friendship initiator.
80
+ * @param int $friend_user_id ID of the friend user.
81
+ * @param object $friendship BuddyPress Friendship Object.
82
+ */
83
+ do_action( 'friends_friendship_' . $action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship );
84
 
85
  return true;
86
  }
99
  $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
100
  $friendship = new BP_Friends_Friendship( $friendship_id );
101
 
102
+ /**
103
+ * Fires before the deletion of a friendship activity item
104
+ * for the user who canceled the friendship.
105
+ *
106
+ * @since BuddyPress (1.5.0)
107
+ *
108
+ * @param int $friendship_id ID of the friendship object, if any, between a pair of users.
109
+ * @param int $initiator_userid ID of the friendship initiator.
110
+ * @param int $friend_userid ID of the friend user.
111
+ */
112
  do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid );
113
 
114
+ // Remove the activity stream items about the friendship id
115
+ friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_created', 'user_id' => 0 ) );
116
+
117
+ /**
118
+ * Fires before the friendship connection is removed.
119
+ *
120
+ * This hook is misleadingly named - the friendship is not yet deleted.
121
+ * This is your last chance to do something while the friendship exists.
122
+ *
123
+ * @since BuddyPress (1.0.0)
124
+ *
125
+ * @param int $friendship_id ID of the friendship object, if any, between a pair of users.
126
+ * @param int $initiator_userid ID of the friendship initiator.
127
+ * @param int $friend_userid ID of the friend user.
128
+ */
129
  do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
130
 
131
  if ( $friendship->delete() ) {
132
  friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
133
 
134
+ /**
135
+ * Fires after the friendship connection is removed.
136
+ *
137
+ * @since BuddyPress (1.8.0)
138
+ *
139
+ * @param int $initiator_userid ID of the friendship initiator.
140
+ * @param int $friend_userid ID of the friend user.
141
+ */
142
  do_action( 'friends_friendship_post_delete', $initiator_userid, $friend_userid );
143
 
144
  return true;
157
  */
158
  function friends_accept_friendship( $friendship_id ) {
159
 
160
+ // Get the friendship data
161
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
162
 
163
  // Accepting friendship
166
  // Bump the friendship counts
167
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
168
 
169
+ /**
170
+ * Fires after a friendship is accepted.
171
+ *
172
+ * @since BuddyPress (1.0.0)
173
+ *
174
+ * @param int $id ID of the pending friendship object.
175
+ * @param int $initiator_user_id ID of the friendship initiator.
176
+ * @param int $friend_user_id ID of the user requested friendship with.
177
+ * @param object $friendship BuddyPress Friendship Object.
178
+ */
179
  do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship );
180
 
181
  return true;
194
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
195
 
196
  if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::reject( $friendship_id ) ) {
197
+
198
+ /**
199
+ * Fires after a friendship request is rejected.
200
+ *
201
+ * @since BuddyPress (1.0.0)
202
+ *
203
+ * @param int $friendship_id ID of the pending friendship.
204
+ * @param BP_Friends_Friendship $friendships Friendship object. Passed by reference.
205
+ */
206
  do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
207
  return true;
208
  }
227
  // @deprecated Since 1.9
228
  do_action_ref_array( 'friends_friendship_whithdrawn', array( $friendship_id, &$friendship ) );
229
 
230
+ /**
231
+ * Fires after a friendship request has been withdrawn.
232
+ *
233
+ * @since BuddyPress (1.9.0)
234
+ *
235
+ * @param int $friendship_id ID of the friendship.
236
+ * @param BP_Friends_Friendship $friendship Friendship object. Passed by reference.
237
+ */
238
  do_action_ref_array( 'friends_friendship_withdrawn', array( $friendship_id, &$friendship ) );
239
 
240
  return true;
300
  if ( empty( $count ) )
301
  $count = 0;
302
 
303
+ /**
304
+ * Filters the total friend count for a given user.
305
+ *
306
+ * @since BuddyPress (1.2.0)
307
+ *
308
+ * @param int $count Total friend count for a given user.
309
+ */
310
  return apply_filters( 'friends_get_total_friend_count', $count );
311
  }
312
 
342
  /**
343
  * Get the IDs of a given user's friends.
344
  *
345
+ * @param int $user_id ID of the user whose friends are being retrieved.
346
  * @param bool $friend_requests_only Optional. Whether to fetch unaccepted
347
  * requests only. Default: false.
348
  * @param bool $assoc_arr Optional. True to receive an array of arrays keyed as
388
  *
389
  * @see BP_Core_User::get_users() for a description of return value.
390
  *
391
+ * @param int $user_id ID of the user whose friends are being retrieved.
392
  * @param int $per_page Optional. Number of results to return per page.
393
  * Default: 0 (no pagination; show all results).
394
  * @param int $page Optional. Number of the page of results to return.
398
  * @return array See {@link BP_Core_User::get_users()}.
399
  */
400
  function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
401
+
402
+ /**
403
+ * Filters a user's most recently active friends.
404
+ *
405
+ * @since BuddyPress (1.2.0)
406
+ *
407
+ * @param array {
408
+ * @type int $total_users Total number of users matched by query params.
409
+ * @type array $paged_users The current page of users matched by query params.
410
+ * }
411
+ */
412
  return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
413
  }
414
 
417
  *
418
  * @see BP_Core_User::get_users() for a description of return value.
419
  *
420
+ * @param int $user_id ID of the user whose friends are being retrieved.
421
  * @param int $per_page Optional. Number of results to return per page.
422
  * Default: 0 (no pagination; show all results).
423
  * @param int $page Optional. Number of the page of results to return.
427
  * @return array See {@link BP_Core_User::get_users()}.
428
  */
429
  function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
430
+
431
+ /**
432
+ * Filters a user's friends listed in alphabetical order.
433
+ *
434
+ * @since BuddyPress (1.2.0)
435
+ *
436
+ * @return array {
437
+ * @type int $total_users Total number of users matched by query params.
438
+ * @type array $paged_users The current page of users matched by query params.
439
+ * }
440
+ */
441
  return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
442
  }
443
 
446
  *
447
  * @see BP_Core_User::get_users() for a description of return value.
448
  *
449
+ * @param int $user_id ID of the user whose friends are being retrieved.
450
  * @param int $per_page Optional. Number of results to return per page.
451
  * Default: 0 (no pagination; show all results).
452
  * @param int $page Optional. Number of the page of results to return.
456
  * @return array See {@link BP_Core_User::get_users()}.
457
  */
458
  function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
459
+
460
+ /**
461
+ * Filters a user's friends listed from newest to oldest.
462
+ *
463
+ * @since BuddyPress (1.2.0)
464
+ *
465
+ * @param array {
466
+ * @type int $total_users Total number of users matched by query params.
467
+ * @type array $paged_users The current page of users matched by query params.
468
+ * }
469
+ */
470
  return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
471
  }
472
 
508
  // Assume no friends
509
  $friends = array();
510
 
511
+ /**
512
+ * Filters default arguments for list of friends a user can invite into this group.
513
+ *
514
+ * @since BuddyPress (1.5.4)
515
+ *
516
+ * @param array $value Array of default parameters for invite list.
517
+ */
518
  $args = apply_filters( 'bp_friends_pre_get_invite_list', array(
519
  'user_id' => $user_id,
520
  'type' => 'alphabetical',
561
  if ( empty( $friends ) )
562
  $friends = false;
563
 
564
+ /**
565
+ * Filters the list of potential friends that can be invited to this group.
566
+ *
567
+ * @since BuddyPress (1.5.4)
568
+ *
569
+ * @param array|bool $friends Array friends available to invite or false for no friends.
570
+ * @param int $user_id ID of the user checked for who they can invite.
571
+ * @param int $group_id ID of the group being checked on.
572
+ */
573
  return apply_filters( 'bp_friends_get_invite_list', $friends, $user_id, $group_id );
574
  }
575
 
674
  */
675
  function friends_remove_data( $user_id ) {
676
 
677
+ /**
678
+ * Fires before deletion of friend-related data for a given user.
679
+ *
680
+ * @since BuddyPress (1.5.0)
681
+ *
682
+ * @param int $user_id ID for the user whose friend data is being removed.
683
+ */
684
  do_action( 'friends_before_remove_data', $user_id );
685
 
686
  BP_Friends_Friendship::delete_all_for_user( $user_id );
688
  // Remove usermeta
689
  bp_delete_user_meta( $user_id, 'total_friend_count' );
690
 
691
+ /**
692
+ * Fires after deletion of friend-related data for a given user.
693
+ *
694
+ * @since BuddyPress (1.0.0)
695
+ *
696
+ * @param int $user_id ID for the user whose friend data is being removed.
697
+ */
698
  do_action( 'friends_remove_data', $user_id );
699
  }
700
  add_action( 'wpmu_delete_user', 'friends_remove_data' );
713
  return;
714
  }
715
 
716
+ // Bail out if the site has a ton of users.
717
+ if ( is_multisite() && wp_is_large_network( 'users' ) ) {
718
+ return;
719
+ }
720
+
721
+ if ( friends_get_total_friend_count( get_current_user_id() ) > 150 ) {
722
+ return;
723
+ }
724
+
725
  $friends_query = array(
726
  'count_total' => '', // Prevents total count
727
  'populate_extras' => false,
737
  $result = new stdClass();
738
  $result->ID = $user->user_nicename;
739
  $result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) );
740
+
741
+ if ( ! empty( $user->display_name ) && ! bp_disable_profile_sync() ) {
742
+ $result->name = $user->display_name;
743
+ } else {
744
+ $result->name = bp_core_get_user_displayname( $user->ID );
745
+ }
746
 
747
  $results[] = $result;
748
  }
751
  'friends' => $results,
752
  ) );
753
  }
754
+ add_action( 'bp_activity_mentions_prime_results', 'bp_friends_prime_mentions_results' );
bp-friends/bp-friends-loader.php CHANGED
@@ -239,6 +239,21 @@ class BP_Friends_Component extends BP_Component {
239
 
240
  parent::setup_title();
241
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
243
 
244
  /**
239
 
240
  parent::setup_title();
241
  }
242
+
243
+ /**
244
+ * Setup cache groups
245
+ *
246
+ * @since BuddyPress (2.2.0)
247
+ */
248
+ public function setup_cache_groups() {
249
+
250
+ // Global groups
251
+ wp_cache_add_global_groups( array(
252
+ 'bp_friend_requests'
253
+ ) );
254
+
255
+ parent::setup_cache_groups();
256
+ }
257
  }
258
 
259
  /**
bp-friends/bp-friends-notifications.php CHANGED
@@ -56,13 +56,51 @@ To view %3$s\'s profile: %4$s
56
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
57
  }
58
 
59
- // Send the message
 
 
 
 
 
 
60
  $to = apply_filters( 'friends_notification_new_request_to', $to );
 
 
 
 
 
 
 
 
 
61
  $subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name );
 
 
 
 
 
 
 
 
 
 
 
 
62
  $message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link, $settings_link );
63
 
64
  wp_mail( $to, $subject, $message );
65
 
 
 
 
 
 
 
 
 
 
 
 
66
  do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id );
67
  }
68
  add_action( 'friends_friendship_requested', 'friends_notification_new_request', 10, 3 );
@@ -105,13 +143,50 @@ To view %2$s\'s profile: %3$s
105
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
106
  }
107
 
108
- // Send the message
 
 
 
 
 
 
109
  $to = apply_filters( 'friends_notification_accepted_request_to', $to );
 
 
 
 
 
 
 
 
 
110
  $subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name );
 
 
 
 
 
 
 
 
 
 
 
111
  $message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link );
112
 
113
  wp_mail( $to, $subject, $message );
114
 
 
 
 
 
 
 
 
 
 
 
 
115
  do_action( 'bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id );
116
  }
117
  add_action( 'friends_friendship_accepted', 'friends_notification_accepted_request', 10, 3 );
@@ -136,13 +211,16 @@ function friends_format_notifications( $action, $item_id, $secondary_item_id, $t
136
  case 'friendship_accepted':
137
  $link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends' );
138
 
 
 
 
139
  // Set up the string and the filter
140
  if ( (int) $total_items > 1 ) {
141
  $text = sprintf( __( '%d friends accepted your friendship requests', 'buddypress' ), (int) $total_items );
142
- $filter = 'bp_friends_multiple_friendship_accepted_notification';
143
  } else {
144
  $text = sprintf( __( '%s accepted your friendship request', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
145
- $filter = 'bp_friends_single_friendship_accepted_notification';
146
  }
147
 
148
  break;
@@ -150,13 +228,15 @@ function friends_format_notifications( $action, $item_id, $secondary_item_id, $t
150
  case 'friendship_request':
151
  $link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';
152
 
 
 
153
  // Set up the string and the filter
154
  if ( (int) $total_items > 1 ) {
155
  $text = sprintf( __( 'You have %d pending friendship requests', 'buddypress' ), (int) $total_items );
156
- $filter = 'bp_friends_multiple_friendship_request_notification';
157
  } else {
158
  $text = sprintf( __( 'You have a friendship request from %s', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
159
- $filter = 'bp_friends_single_friendship_request_notification';
160
  }
161
 
162
  break;
@@ -164,14 +244,46 @@ function friends_format_notifications( $action, $item_id, $secondary_item_id, $t
164
 
165
  // Return either an HTML link or an array, depending on the requested format
166
  if ( 'string' == $format ) {
167
- $return = apply_filters( $filter, '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $item_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  } else {
169
- $return = apply_filters( $filter, array(
 
170
  'link' => $link,
171
  'text' => $text
172
  ), (int) $total_items, $item_id );
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return );
176
 
177
  return $return;
@@ -217,7 +329,7 @@ add_action( 'friends_screen_my_friends', 'bp_friends_mark_friendship_accepted_no
217
  * @since BuddyPress (1.9.0)
218
  * @param int $friendship_id The unique ID of the friendship
219
  * @param int $initiator_user_id The friendship initiator user ID
220
- * @param int $friend_user_id The friendship request reciever user ID
221
  */
222
  function bp_friends_friendship_requested_notification( $friendship_id, $initiator_user_id, $friend_user_id ) {
223
  if ( bp_is_active( 'notifications' ) ) {
@@ -255,7 +367,7 @@ add_action( 'friends_friendship_rejected', 'bp_friends_mark_friendship_rejected_
255
  * @since BuddyPress (1.9.0)
256
  * @param int $friendship_id The unique ID of the friendship
257
  * @param int $initiator_user_id The friendship initiator user ID
258
- * @param int $friend_user_id The friendship request reciever user ID
259
  */
260
  function bp_friends_add_friendship_accepted_notification( $friendship_id, $initiator_user_id, $friend_user_id ) {
261
 
56
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
57
  }
58
 
59
+ /**
60
+ * Filters the email address for who is getting the friend request.
61
+ *
62
+ * @since BuddyPress (1.2.0)
63
+ *
64
+ * @param string $to Email address for who is getting the friend request.
65
+ */
66
  $to = apply_filters( 'friends_notification_new_request_to', $to );
67
+
68
+ /**
69
+ * Filters the subject for the friend request email.
70
+ *
71
+ * @since BuddyPress (1.2.0)
72
+ *
73
+ * @param string $subject Subject line to be used in friend request email.
74
+ * @param string $initiator_name Name of the person requesting friendship.
75
+ */
76
  $subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name );
77
+
78
+ /**
79
+ * Filters the message for the friend request email.
80
+ *
81
+ * @since BuddyPress (1.2.0)
82
+ *
83
+ * @param string $message Message to be used in friend request email.
84
+ * @param string $initiator_name Name of the person requesting friendship.
85
+ * @param string $initiator_link Profile link of person requesting friendship.
86
+ * @param string $all_requests_link User's friends request management link.
87
+ * @param string $settings_link Email recipient's settings management link.
88
+ */
89
  $message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link, $settings_link );
90
 
91
  wp_mail( $to, $subject, $message );
92
 
93
+ /**
94
+ * Fires after the new friend request email is sent.
95
+ *
96
+ * @since BuddyPress (1.5.0)
97
+ *
98
+ * @param int $friend_id ID of the request recipient.
99
+ * @param string $subject Text for the friend request subject field.
100
+ * @param string $message Text for the friend request message field.
101
+ * @param int $friendship_id ID of the friendship object.
102
+ * @param int $initiator_id ID of the friendship requester.
103
+ */
104
  do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id );
105
  }
106
  add_action( 'friends_friendship_requested', 'friends_notification_new_request', 10, 3 );
143
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
144
  }
145
 
146
+ /**
147
+ * Filters the email address for whose friend request got accepted.
148
+ *
149
+ * @since BuddyPress (1.2.0)
150
+ *
151
+ * @param string $to Email address for whose friend request got accepted.
152
+ */
153
  $to = apply_filters( 'friends_notification_accepted_request_to', $to );
154
+
155
+ /**
156
+ * Filters the subject for the friend request accepted email.
157
+ *
158
+ * @since BuddyPress (1.2.0)
159
+ *
160
+ * @param string $subject Subject line to be used in friend request accepted email.
161
+ * @param string $friend_name Name of the person who accepted the friendship request.
162
+ */
163
  $subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name );
164
+
165
+ /**
166
+ * Filters the message for the friend request accepted email.
167
+ *
168
+ * @since BuddyPress (1.2.0)
169
+ *
170
+ * @param string $message Message to be used in friend request email.
171
+ * @param string $friend_name Name of the person who accepted the friendship request.
172
+ * @param string $friend_link Profile link of person who accepted the friendship request.
173
+ * @param string $settings_link Email recipient's settings management link.
174
+ */
175
  $message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link );
176
 
177
  wp_mail( $to, $subject, $message );
178
 
179
+ /**
180
+ * Fires after the friend request accepted email is sent.
181
+ *
182
+ * @since BuddyPress (1.5.0)
183
+ *
184
+ * @param int $initiator_id ID of the friendship requester.
185
+ * @param string $subject Text for the friend request subject field.
186
+ * @param string $message Text for the friend request message field.
187
+ * @param int $friendship_id ID of the friendship object.
188
+ * @param int $friend_id ID of the request recipient.
189
+ */
190
  do_action( 'bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id );
191
  }
192
  add_action( 'friends_friendship_accepted', 'friends_notification_accepted_request', 10, 3 );
211
  case 'friendship_accepted':
212
  $link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends' );
213
 
214
+ // $action and $amount are used to generate dynamic filter names.
215
+ $action = 'accepted';
216
+
217
  // Set up the string and the filter
218
  if ( (int) $total_items > 1 ) {
219
  $text = sprintf( __( '%d friends accepted your friendship requests', 'buddypress' ), (int) $total_items );
220
+ $amount = 'multiple';
221
  } else {
222
  $text = sprintf( __( '%s accepted your friendship request', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
223
+ $amount = 'single';
224
  }
225
 
226
  break;
228
  case 'friendship_request':
229
  $link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';
230
 
231
+ $action = 'request';
232
+
233
  // Set up the string and the filter
234
  if ( (int) $total_items > 1 ) {
235
  $text = sprintf( __( 'You have %d pending friendship requests', 'buddypress' ), (int) $total_items );
236
+ $amount = 'multiple';
237
  } else {
238
  $text = sprintf( __( 'You have a friendship request from %s', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
239
+ $amount = 'single';
240
  }
241
 
242
  break;
244
 
245
  // Return either an HTML link or an array, depending on the requested format
246
  if ( 'string' == $format ) {
247
+
248
+ /**
249
+ * Filters the format of friendship notifications based on type and amount * of notifications pending.
250
+ *
251
+ * This is a variable filter that has four possible versions.
252
+ * The four possible versions are:
253
+ * - bp_friends_single_friendship_accepted_notification
254
+ * - bp_friends_multiple_friendship_accepted_notification
255
+ * - bp_friends_single_friendship_request_notification
256
+ * - bp_friends_multiple_friendship_request_notification
257
+ *
258
+ * @since BuddyPress (1.0.0)
259
+ *
260
+ * @param string|array $value Depending on format, an HTML link to new requests profile
261
+ * tab or array with link and text.
262
+ * @param int $total_items The total number of messaging-related notifications
263
+ * waiting for the user.
264
+ * @param int $item_id The primary item ID.
265
+ */
266
+ $return = apply_filters( 'bp_friends_' . $amount . '_friendship_' . $action . '_notification', '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $item_id );
267
  } else {
268
+ /** This filter is documented in bp-friends/bp-friends-notifications.php */
269
+ $return = apply_filters( 'bp_friends_' . $amount . '_friendship_' . $action . '_notification', array(
270
  'link' => $link,
271
  'text' => $text
272
  ), (int) $total_items, $item_id );
273
  }
274
 
275
+ /**
276
+ * Fires at the end of the bp-friends notification format callback.
277
+ *
278
+ * @since BuddyPress (1.0.0)
279
+ *
280
+ * @param string $action The kind of notification being rendered.
281
+ * @param int $item_id The primary item ID.
282
+ * @param int $secondary_item_id The secondary item ID.
283
+ * @param int $total_items The total number of messaging-related notifications
284
+ * waiting for the user.
285
+ * @param array|string $return Notification text string or array of link and text.
286
+ */
287
  do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return );
288
 
289
  return $return;
329
  * @since BuddyPress (1.9.0)
330
  * @param int $friendship_id The unique ID of the friendship
331
  * @param int $initiator_user_id The friendship initiator user ID
332
+ * @param int $friend_user_id The friendship request receiver user ID
333
  */
334
  function bp_friends_friendship_requested_notification( $friendship_id, $initiator_user_id, $friend_user_id ) {
335
  if ( bp_is_active( 'notifications' ) ) {
367
  * @since BuddyPress (1.9.0)
368
  * @param int $friendship_id The unique ID of the friendship
369
  * @param int $initiator_user_id The friendship initiator user ID
370
+ * @param int $friend_user_id The friendship request receiver user ID
371
  */
372
  function bp_friends_add_friendship_accepted_notification( $friendship_id, $initiator_user_id, $friend_user_id ) {
373
 
bp-friends/bp-friends-screens.php CHANGED
@@ -19,8 +19,20 @@ if ( !defined( 'ABSPATH' ) ) exit;
19
  */
20
  function friends_screen_my_friends() {
21
 
 
 
 
 
 
22
  do_action( 'friends_screen_my_friends' );
23
 
 
 
 
 
 
 
 
24
  bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
25
  }
26
 
@@ -62,8 +74,20 @@ function friends_screen_requests() {
62
  bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
63
  }
64
 
 
 
 
 
 
65
  do_action( 'friends_screen_requests' );
66
 
 
 
 
 
 
 
 
67
  bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
68
  }
69
 
@@ -102,7 +126,14 @@ function friends_screen_notification_settings() {
102
  <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php checked( $accept_requests, 'no', true ) ?>/></td>
103
  </tr>
104
 
105
- <?php do_action( 'friends_screen_notification_settings' ); ?>
 
 
 
 
 
 
 
106
 
107
  </tbody>
108
  </table>
19
  */
20
  function friends_screen_my_friends() {
21
 
22
+ /**
23
+ * Fires before the loading of template for the My Friends page.
24
+ *
25
+ * @since BuddyPress (1.0.0)
26
+ */
27
  do_action( 'friends_screen_my_friends' );
28
 
29
+ /**
30
+ * Filters the template used to display the My Friends page.
31
+ *
32
+ * @since BuddyPress (1.0.0)
33
+ *
34
+ * @param string $template Path to the my friends template to load.
35
+ */
36
  bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
37
  }
38
 
74
  bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
75
  }
76
 
77
+ /**
78
+ * Fires before the loading of template for the friends requests page.
79
+ *
80
+ * @since BuddyPress (1.0.0)
81
+ */
82
  do_action( 'friends_screen_requests' );
83
 
84
+ /**
85
+ * Filters the template used to display the My Friends page.
86
+ *
87
+ * @since BuddyPress (1.0.0)
88
+ *
89
+ * @param string $template Path to the friends request template to load.
90
+ */
91
  bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
92
  }
93
 
126
  <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php checked( $accept_requests, 'no', true ) ?>/></td>
127
  </tr>
128
 
129
+ <?php
130
+
131
+ /**
132
+ * Fires after the last table row on the friends notification screen.
133
+ *
134
+ * @since BuddyPress (1.0.0)
135
+ */
136
+ do_action( 'friends_screen_notification_settings' ); ?>
137
 
138
  </tbody>
139
  </table>
bp-friends/bp-friends-template.php CHANGED
@@ -26,6 +26,14 @@ function bp_friends_slug() {
26
  * @since BuddyPress (1.5.0)
27
  */
28
  function bp_get_friends_slug() {
 
 
 
 
 
 
 
 
29
  return apply_filters( 'bp_get_friends_slug', buddypress()->friends->slug );
30
  }
31
 
@@ -45,6 +53,14 @@ function bp_friends_root_slug() {
45
  * @since BuddyPress (1.5.0)
46
  */
47
  function bp_get_friends_root_slug() {
 
 
 
 
 
 
 
 
48
  return apply_filters( 'bp_get_friends_root_slug', buddypress()->friends->root_slug );
49
  }
50
 
@@ -212,10 +228,22 @@ function bp_member_total_friend_count() {
212
  function bp_get_member_total_friend_count() {
213
  global $members_template;
214
 
215
- if ( 1 == (int) $members_template->member->total_friend_count )
 
 
 
 
 
 
 
 
 
216
  return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
217
- else
 
 
218
  return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
 
219
  }
220
 
221
  /**
@@ -242,9 +270,16 @@ function bp_potential_friend_id( $user_id = 0 ) {
242
 
243
  if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) )
244
  $user_id = $friends_template->friendship->friend->id;
245
- else if ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) )
246
  $user_id = bp_displayed_user_id();
247
 
 
 
 
 
 
 
 
248
  return apply_filters( 'bp_get_potential_friend_id', (int) $user_id );
249
  }
250
 
@@ -268,6 +303,13 @@ function bp_is_friend( $user_id = 0 ) {
268
  if ( bp_loggedin_user_id() == $user_id )
269
  return false;
270
 
 
 
 
 
 
 
 
271
  return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id );
272
  }
273
 
@@ -370,7 +412,13 @@ function bp_add_friend_button( $potential_friend_id = 0, $friend_status = false
370
  break;
371
  }
372
 
373
- // Filter and return the HTML button
 
 
 
 
 
 
374
  return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) );
375
  }
376
 
@@ -422,6 +470,13 @@ function bp_get_friendship_requests( $user_id = 0 ) {
422
  $requests = 0;
423
  }
424
 
 
 
 
 
 
 
 
425
  return apply_filters( 'bp_get_friendship_requests', $requests );
426
  }
427
 
@@ -432,7 +487,7 @@ function bp_friend_friendship_id() {
432
  echo bp_get_friend_friendship_id();
433
  }
434
  /**
435
- * Return the ID of the frinedship between the logged-in user and the current user in the loop.
436
  *
437
  * @return int ID of the friendship.
438
  */
@@ -444,6 +499,13 @@ function bp_friend_friendship_id() {
444
  wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
445
  }
446
 
 
 
 
 
 
 
 
447
  return apply_filters( 'bp_get_friend_friendship_id', $friendship_id );
448
  }
449
 
@@ -466,6 +528,13 @@ function bp_friend_accept_request_link() {
466
  wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
467
  }
468
 
 
 
 
 
 
 
 
469
  return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) );
470
  }
471
 
@@ -488,6 +557,13 @@ function bp_friend_reject_request_link() {
488
  wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
489
  }
490
 
 
 
 
 
 
 
 
491
  return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) );
492
  }
493
 
@@ -506,6 +582,14 @@ function bp_total_friend_count( $user_id = 0 ) {
506
  * @return int Total friend count.
507
  */
508
  function bp_get_total_friend_count( $user_id = 0 ) {
 
 
 
 
 
 
 
 
509
  return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) );
510
  }
511
  add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' );
@@ -531,6 +615,13 @@ function bp_friend_total_requests_count( $user_id = 0 ) {
531
  if ( empty( $user_id ) )
532
  $user_id = bp_loggedin_user_id();
533
 
 
 
 
 
 
 
 
534
  return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ) );
535
  }
536
 
@@ -584,6 +675,13 @@ function bp_friends_get_profile_stats( $args = '' ) {
584
  }
585
  }
586
 
587
- // Filter and return
 
 
 
 
 
 
 
588
  return apply_filters( 'bp_friends_get_profile_stats', $r['output'], $r );
589
  }
26
  * @since BuddyPress (1.5.0)
27
  */
28
  function bp_get_friends_slug() {
29
+
30
+ /**
31
+ * Filters the friends component slug.
32
+ *
33
+ * @since BuddyPress (1.5.0)
34
+ *
35
+ * @param string $value Friends component slug.
36
+ */
37
  return apply_filters( 'bp_get_friends_slug', buddypress()->friends->slug );
38
  }
39
 
53
  * @since BuddyPress (1.5.0)
54
  */
55
  function bp_get_friends_root_slug() {
56
+
57
+ /**
58
+ * Filters the friends component root slug.
59
+ *
60
+ * @since BuddyPress (1.5.0)
61
+ *
62
+ * @param string $value Friends component root slug.
63
+ */
64
  return apply_filters( 'bp_get_friends_root_slug', buddypress()->friends->root_slug );
65
  }
66
 
228
  function bp_get_member_total_friend_count() {
229
  global $members_template;
230
 
231
+ if ( 1 == (int) $members_template->member->total_friend_count ) {
232
+
233
+ /**
234
+ * Filters text used to denote total friend count.
235
+ *
236
+ * @since BuddyPress (1.2.0)
237
+ *
238
+ * @param string $value String of the form "x friends".
239
+ * @param int $value Total friend count for current member in the loop.
240
+ */
241
  return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
242
+ } else {
243
+
244
+ /** This filter is documented in bp-friends/bp-friends-template.php */
245
  return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
246
+ }
247
  }
248
 
249
  /**
270
 
271
  if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) )
272
  $user_id = $friends_template->friendship->friend->id;
273
+ elseif ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) )
274
  $user_id = bp_displayed_user_id();
275
 
276
+ /**
277
+ * Filters the ID of current user in the friend request loop.
278
+ *
279
+ * @since BuddyPress (1.2.10)
280
+ *
281
+ * @param int $user_id ID of current user in the friend request loop.
282
+ */
283
  return apply_filters( 'bp_get_potential_friend_id', (int) $user_id );
284
  }
285
 
303
  if ( bp_loggedin_user_id() == $user_id )
304
  return false;
305
 
306
+ /**
307
+ * Filters the status of friendship between logged in user and given user.
308
+ *
309
+ * @since BuddyPress (1.2.10)
310
+ *
311
+ * @param string $value String status of friendship. Possible values are 'is_friend', 'not_friends', 'pending'.
312
+ */
313
  return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id );
314
  }
315
 
412
  break;
413
  }
414
 
415
+ /**
416
+ * Filters the HTML for the add friend button.
417
+ *
418
+ * @since BuddyPress (1.1.0)
419
+ *
420
+ * @param string $button HTML markup for add friend button.
421
+ */
422
  return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) );
423
  }
424
 
470
  $requests = 0;
471
  }
472
 
473
+ /**
474
+ * Filters the total pending friendship requests for a user.
475
+ *
476
+ * @since BuddyPress (1.2.0)
477
+ *
478
+ * @param array|int An array of user IDs if found, or a 0 if none are found.
479
+ */
480
  return apply_filters( 'bp_get_friendship_requests', $requests );
481
  }
482
 
487
  echo bp_get_friend_friendship_id();
488
  }
489
  /**
490
+ * Return the ID of the friendship between the logged-in user and the current user in the loop.
491
  *
492
  * @return int ID of the friendship.
493
  */
499
  wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
500
  }
501
 
502
+ /**
503
+ * Filters the ID of the friendship between the logged in user and the current user in the loop.
504
+ *
505
+ * @since BuddyPress (1.2.0)
506
+ *
507
+ * @param int $friendship_id ID of the friendship.
508
+ */
509
  return apply_filters( 'bp_get_friend_friendship_id', $friendship_id );
510
  }
511
 
528
  wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
529
  }
530
 
531
+ /**
532
+ * Filters the URL for accepting the current friendship request in the loop.
533
+ *
534
+ * @since BuddyPress (1.0.0)
535
+ *
536
+ * @param string $value Accept-friendship URL.
537
+ */
538
  return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) );
539
  }
540
 
557
  wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' );
558
  }
559
 
560
+ /**
561
+ * Filters the URL for rejecting the current friendship request in the loop.
562
+ *
563
+ * @since BuddyPress (1.0.0)
564
+ *
565
+ * @param string $value Reject-friendship URL.
566
+ */
567
  return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) );
568
  }
569
 
582
  * @return int Total friend count.
583
  */
584
  function bp_get_total_friend_count( $user_id = 0 ) {
585
+
586
+ /**
587
+ * Filters the total friend count for a given user.
588
+ *
589
+ * @since BuddyPress (1.2.0)
590
+ *
591
+ * @param int $value Total friend count.
592
+ */
593
  return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) );
594
  }
595
  add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' );
615
  if ( empty( $user_id ) )
616
  $user_id = bp_loggedin_user_id();
617
 
618
+ /**
619
+ * Filters the total friendship request count for a given user.
620
+ *
621
+ * @since BuddyPress (1.2.0)
622
+ *
623
+ * @param int $value Friendship request count.
624
+ */
625
  return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ) );
626
  }
627
 
675
  }
676
  }
677
 
678
+ /**
679
+ * Filters the number of friends in user's profile.
680
+ *
681
+ * @since BuddyPress (2.0.0)
682
+ *
683
+ * @param string $value Formatted string displaying total friends count.
684
+ * @param array $r Array of arguments for string formatting and output.
685
+ */
686
  return apply_filters( 'bp_friends_get_profile_stats', $r['output'], $r );
687
  }
bp-friends/bp-friends-widgets.php CHANGED
@@ -76,6 +76,13 @@ class BP_Core_Friends_Widget extends WP_Widget {
76
  $instance['friend_default'] = 'active';
77
  }
78
 
 
 
 
 
 
 
 
79
  $title = apply_filters( 'widget_title', $instance['title'] );
80
 
81
  echo $before_widget;
@@ -145,7 +152,7 @@ class BP_Core_Friends_Widget extends WP_Widget {
145
  * Process a widget save.
146
  *
147
  * @param array $new_instance The parameters saved by the user.
148
- * @param array $old_instance The paramaters as previously saved to the database.
149
  * @return array $instance The processed settings to save.
150
  */
151
  function update( $new_instance, $old_instance ) {
76
  $instance['friend_default'] = 'active';
77
  }
78
 
79
+ /**
80
+ * Filters the Friends widget title.
81
+ *
82
+ * @since BuddyPress (1.8.0)
83
+ *
84
+ * @param string $title The widget title.
85
+ */
86
  $title = apply_filters( 'widget_title', $instance['title'] );
87
 
88
  echo $before_widget;
152
  * Process a widget save.
153
  *
154
  * @param array $new_instance The parameters saved by the user.
155
+ * @param array $old_instance The parameters as previously saved to the database.
156
  * @return array $instance The processed settings to save.
157
  */
158
  function update( $new_instance, $old_instance ) {
bp-friends/js/widget-friends.js CHANGED
@@ -17,7 +17,7 @@ jQuery(document).ready( function() {
17
  function(response)
18
  {
19
  jQuery(link).removeClass('loading');
20
- friend_wiget_response(response);
21
  });
22
 
23
  return false;
@@ -25,7 +25,7 @@ jQuery(document).ready( function() {
25
  );
26
  });
27
 
28
- function friend_wiget_response(response) {
29
  response = response.substr(0, response.length-1);
30
  response = response.split('[[SPLIT]]');
31
 
17
  function(response)
18
  {
19
  jQuery(link).removeClass('loading');
20
+ friend_widget_response(response);
21
  });
22
 
23
  return false;
25
  );
26
  });
27
 
28
+ function friend_widget_response(response) {
29
  response = response.substr(0, response.length-1);
30
  response = response.split('[[SPLIT]]');
31
 
bp-friends/js/widget-friends.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- function friend_wiget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#friends-list").fadeOut(200,function(){jQuery(".widget ul#friends-list").html(a[1]),jQuery(".widget ul#friends-list").fadeIn(200)}):jQuery(".widget ul#friends-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#friends-list").html(b),jQuery(".widget ul#friends-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#friends-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#friends-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_friends",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-friends").val(),"max-friends":jQuery("input#friends_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),friend_wiget_response(b)}),!1})});
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ function friend_widget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#friends-list").fadeOut(200,function(){jQuery(".widget ul#friends-list").html(a[1]),jQuery(".widget ul#friends-list").fadeIn(200)}):jQuery(".widget ul#friends-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#friends-list").html(b),jQuery(".widget ul#friends-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#friends-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#friends-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_friends",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-friends").val(),"max-friends":jQuery("input#friends_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),friend_widget_response(b)}),!1})});
bp-groups/admin/css/admin-rtl.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  body.toplevel_page_bp-groups table.groups th#members,body.toplevel_page_bp-groups table.groups th#status{width:10%}body.toplevel_page_bp-groups table.groups th#last_active{width:15%}#bp-groups-form .avatar{float:right;margin-left:10px;margin-top:1px}#bp-groups-edit-form input{outline:0}#bp-groups-edit-form input#bp-groups-name{font-size:1.7em;width:100%;margin-bottom:6px}#bp-groups-edit-form input#bp-groups-new-members{width:100%;max-width:90%;border:0}#bp-groups-new-members-list{margin:0}#bp_group_settings legend{margin:10px 0;font-weight:700}#bp_group_settings ul{margin:0}.bp-groups-settings-section{margin-top:10px}#bp-groups-permalink-box{line-height:24px;color:#666}.bp-groups-member-type{position:relative}.bp-groups-member-type>h4{margin-bottom:.5em}ul.bp-group-delete-list{list-style-type:disc;margin:4px 26px}.bp-group-admin-pagination{position:absolute;text-align:left;width:100%}.bp-group-admin-pagination.table-top{top:0}.bp-group-admin-pagination.table-bottom{bottom:0}.bp-group-admin-pagination-viewing{color:#777;font-size:12px;font-style:italic}.bp-group-admin-pagination-links{white-space:nowrap;padding-right:15px}table.bp-group-members .uid-column{padding-right:20px;padding-left:20px}table.bp-group-members .uname-column{width:70%}table.bp-group-members .urole-column{padding-right:20px;padding-left:20px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  body.toplevel_page_bp-groups table.groups th#members,body.toplevel_page_bp-groups table.groups th#status{width:10%}body.toplevel_page_bp-groups table.groups th#last_active{width:15%}#bp-groups-form .avatar{float:right;margin-left:10px;margin-top:1px}#bp-groups-edit-form input{outline:0}#bp-groups-edit-form input#bp-groups-name{font-size:1.7em;width:100%;margin-bottom:6px}#bp-groups-edit-form input#bp-groups-new-members{width:100%;max-width:90%;border:0}#bp-groups-new-members-list{margin:0}#bp_group_settings legend{margin:10px 0;font-weight:700}#bp_group_settings ul{margin:0}.bp-groups-settings-section{margin-top:10px}#bp-groups-permalink-box{line-height:24px;color:#666}.bp-groups-member-type{position:relative}.bp-groups-member-type>h4{margin-bottom:.5em}ul.bp-group-delete-list{list-style-type:disc;margin:4px 26px}.bp-group-admin-pagination{position:absolute;text-align:left;width:100%}.bp-group-admin-pagination.table-top{top:0}.bp-group-admin-pagination.table-bottom{bottom:0}.bp-group-admin-pagination-viewing{color:#777;font-size:12px;font-style:italic}.bp-group-admin-pagination-links{white-space:nowrap;padding-right:15px}table.bp-group-members .uid-column{padding-right:20px;padding-left:20px}table.bp-group-members .uname-column{width:70%}table.bp-group-members .urole-column{padding-right:20px;padding-left:20px}
bp-groups/admin/css/admin.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  body.toplevel_page_bp-groups table.groups th#members,body.toplevel_page_bp-groups table.groups th#status{width:10%}body.toplevel_page_bp-groups table.groups th#last_active{width:15%}#bp-groups-form .avatar{float:left;margin-right:10px;margin-top:1px}#bp-groups-edit-form input{outline:0}#bp-groups-edit-form input#bp-groups-name{font-size:1.7em;width:100%;margin-bottom:6px}#bp-groups-edit-form input#bp-groups-new-members{width:100%;max-width:90%;border:0}#bp-groups-new-members-list{margin:0}#bp_group_settings legend{margin:10px 0;font-weight:700}#bp_group_settings ul{margin:0}.bp-groups-settings-section{margin-top:10px}#bp-groups-permalink-box{line-height:24px;color:#666}.bp-groups-member-type{position:relative}.bp-groups-member-type>h4{margin-bottom:.5em}ul.bp-group-delete-list{list-style-type:disc;margin:4px 26px}.bp-group-admin-pagination{position:absolute;text-align:right;width:100%}.bp-group-admin-pagination.table-top{top:0}.bp-group-admin-pagination.table-bottom{bottom:0}.bp-group-admin-pagination-viewing{color:#777;font-size:12px;font-style:italic}.bp-group-admin-pagination-links{white-space:nowrap;padding-left:15px}table.bp-group-members .uid-column{padding-left:20px;padding-right:20px}table.bp-group-members .uname-column{width:70%}table.bp-group-members .urole-column{padding-left:20px;padding-right:20px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  body.toplevel_page_bp-groups table.groups th#members,body.toplevel_page_bp-groups table.groups th#status{width:10%}body.toplevel_page_bp-groups table.groups th#last_active{width:15%}#bp-groups-form .avatar{float:left;margin-right:10px;margin-top:1px}#bp-groups-edit-form input{outline:0}#bp-groups-edit-form input#bp-groups-name{font-size:1.7em;width:100%;margin-bottom:6px}#bp-groups-edit-form input#bp-groups-new-members{width:100%;max-width:90%;border:0}#bp-groups-new-members-list{margin:0}#bp_group_settings legend{margin:10px 0;font-weight:700}#bp_group_settings ul{margin:0}.bp-groups-settings-section{margin-top:10px}#bp-groups-permalink-box{line-height:24px;color:#666}.bp-groups-member-type{position:relative}.bp-groups-member-type>h4{margin-bottom:.5em}ul.bp-group-delete-list{list-style-type:disc;margin:4px 26px}.bp-group-admin-pagination{position:absolute;text-align:right;width:100%}.bp-group-admin-pagination.table-top{top:0}.bp-group-admin-pagination.table-bottom{bottom:0}.bp-group-admin-pagination-viewing{color:#777;font-size:12px;font-style:italic}.bp-group-admin-pagination-links{white-space:nowrap;padding-left:15px}table.bp-group-members .uid-column{padding-left:20px;padding-right:20px}table.bp-group-members .uname-column{width:70%}table.bp-group-members .urole-column{padding-left:20px;padding-right:20px}
bp-groups/admin/js/admin.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){function b(b,c){a("#bp-groups-new-members-list").append('<li data-login="'+c.item.value+'"><a href="#" class="bp-groups-remove-new-member">x</a> '+c.item.label+"</li>")}var c="undefined"!=typeof group_id?"&group_id="+group_id:"";a(document).ready(function(){window.warn_on_leave=!1,a(".bp-suggest-user").autocomplete({source:ajaxurl+"?action=bp_group_admin_member_autocomplete"+c,delay:500,minLength:2,position:"undefined"!=typeof isRtl&&isRtl?{my:"right top",at:"right bottom",offset:"0, -1"}:{offset:"0, -1"},open:function(){a(this).addClass("open")},close:function(){a(this).removeClass("open"),a(this).val("")},select:function(a,c){b(a,c)}}),a("#bp-groups-new-members").prop("placeholder",BP_Group_Admin.add_member_placeholder),a("#bp_group_add_members").on("click",".bp-groups-remove-new-member",function(b){b.preventDefault(),a(b.target.parentNode).remove()}),a(document).on("change",'input#bp-groups-name, input#bp-groups-description, select.bp-groups-role, #bp-groups-settings-section-status input[type="radio"]',function(){window.warn_on_leave=!0}),a("input#save").on("click",function(){var b=[];a("#bp-groups-new-members-list li").each(function(){b.push(a(this).data("login"))}),b.length&&a("#bp-groups-new-members").val("").val(b.join(", ")),window.warn_on_leave=!1}),window.onbeforeunload=function(){return window.warn_on_leave?BP_Group_Admin.warn_on_leave:void 0}})}(jQuery);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){function b(b,c){a("#bp-groups-new-members-list").append('<li data-login="'+c.item.value+'"><a href="#" class="bp-groups-remove-new-member">x</a> '+c.item.label+"</li>")}var c="undefined"!=typeof group_id?"&group_id="+group_id:"";a(document).ready(function(){window.warn_on_leave=!1,a(".bp-suggest-user").autocomplete({source:ajaxurl+"?action=bp_group_admin_member_autocomplete"+c,delay:500,minLength:2,position:"undefined"!=typeof isRtl&&isRtl?{my:"right top",at:"right bottom",offset:"0, -1"}:{offset:"0, -1"},open:function(){a(this).addClass("open")},close:function(){a(this).removeClass("open"),a(this).val("")},select:function(a,c){b(a,c)}}),a("#bp-groups-new-members").prop("placeholder",BP_Group_Admin.add_member_placeholder),a("#bp_group_add_members").on("click",".bp-groups-remove-new-member",function(b){b.preventDefault(),a(b.target.parentNode).remove()}),a(document).on("change",'input#bp-groups-name, input#bp-groups-description, select.bp-groups-role, #bp-groups-settings-section-status input[type="radio"]',function(){window.warn_on_leave=!0}),a("input#save").on("click",function(){var b=[];a("#bp-groups-new-members-list li").each(function(){b.push(a(this).data("login"))}),b.length&&a("#bp-groups-new-members").val("").val(b.join(", ")),window.warn_on_leave=!1}),window.onbeforeunload=function(){return window.warn_on_leave?BP_Group_Admin.warn_on_leave:void 0}})}(jQuery);
bp-groups/bp-groups-actions.php CHANGED
@@ -34,7 +34,7 @@ function bp_groups_group_access_protection() {
34
  $user_has_access = true;
35
 
36
  // User doesn't have access, so set up redirect args
37
- } else if ( is_user_logged_in() ) {
38
  $no_access_args = array(
39
  'message' => __( 'You do not have access to this group.', 'buddypress' ),
40
  'root' => bp_get_group_permalink( $current_group ) . 'home/',
@@ -163,7 +163,7 @@ function groups_action_create_group() {
163
  $new_group_id = isset( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : 0;
164
 
165
  if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => bp_core_current_time(), 'status' => 'public' ) ) ) {
166
- bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
167
  bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/' );
168
  }
169
  }
@@ -183,11 +183,11 @@ function groups_action_create_group() {
183
 
184
  if ( 'private' == $_POST['group-status'] )
185
  $group_status = 'private';
186
- else if ( 'hidden' == $_POST['group-status'] )
187
  $group_status = 'hidden';
188
 
189
  if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) {
190
- bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
191
  bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/' );
192
  }
193
 
@@ -235,7 +235,10 @@ function groups_action_create_group() {
235
  unset( $bp->groups->current_create_step );
236
  unset( $bp->groups->completed_create_steps );
237
 
238
- // Once we compelete all steps, record the group creation in the activity stream.
 
 
 
239
  groups_record_activity( array(
240
  'type' => 'created_group',
241
  'item_id' => $bp->groups->new_group_id
34
  $user_has_access = true;
35
 
36
  // User doesn't have access, so set up redirect args
37
+ } elseif ( is_user_logged_in() ) {
38
  $no_access_args = array(
39
  'message' => __( 'You do not have access to this group.', 'buddypress' ),
40
  'root' => bp_get_group_permalink( $current_group ) . 'home/',
163
  $new_group_id = isset( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : 0;
164
 
165
  if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => bp_core_current_time(), 'status' => 'public' ) ) ) {
166
+ bp_core_add_message( __( 'There was an error saving group details. Please try again.', 'buddypress' ), 'error' );
167
  bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/' );
168
  }
169
  }
183
 
184
  if ( 'private' == $_POST['group-status'] )
185
  $group_status = 'private';
186
+ elseif ( 'hidden' == $_POST['group-status'] )
187
  $group_status = 'hidden';
188
 
189
  if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) {
190
+ bp_core_add_message( __( 'There was an error saving group details. Please try again.', 'buddypress' ), 'error' );
191
  bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/' );
192
  }
193
 
235
  unset( $bp->groups->current_create_step );
236
  unset( $bp->groups->completed_create_steps );
237
 
238
+ setcookie( 'bp_new_group_id', false, time() - 3600, COOKIEPATH );
239
+ setcookie( 'bp_completed_create_steps', false, time() - 3600, COOKIEPATH );
240
+
241
+ // Once we completed all steps, record the group creation in the activity stream.
242
  groups_record_activity( array(
243
  'type' => 'created_group',
244
  'item_id' => $bp->groups->new_group_id
bp-groups/bp-groups-activity.php CHANGED
@@ -43,6 +43,15 @@ function groups_register_activity_actions() {
43
  array( 'activity', 'group', 'member', 'member_groups' )
44
  );
45
 
 
 
 
 
 
 
 
 
 
46
  // These actions are for the legacy forums
47
  // Since the bbPress plugin also shares the same 'forums' identifier, we also
48
  // check for the legacy forums loader class to be extra cautious
@@ -127,6 +136,51 @@ function bp_groups_format_activity_action_joined_group( $action, $activity ) {
127
  return apply_filters( 'bp_groups_format_activity_action_joined_group', $action, $activity );
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  /**
131
  * Fetch data related to groups at the beginning of an activity loop.
132
  *
@@ -179,6 +233,42 @@ function bp_groups_prefetch_activity_object_data( $activities ) {
179
  }
180
  add_filter( 'bp_activity_prefetch_object_data', 'bp_groups_prefetch_activity_object_data' );
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  /**
183
  * Record an activity item related to the Groups component.
184
  *
@@ -289,6 +379,78 @@ function bp_groups_membership_accepted_add_activity( $user_id, $group_id ) {
289
  }
290
  add_action( 'groups_membership_accepted', 'bp_groups_membership_accepted_add_activity', 10, 2 );
291
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  /**
293
  * Delete all activity items related to a specific group.
294
  *
43
  array( 'activity', 'group', 'member', 'member_groups' )
44
  );
45
 
46
+ bp_activity_set_action(
47
+ $bp->groups->id,
48
+ 'group_details_updated',
49
+ __( 'Group details edited', 'buddypress' ),
50
+ 'bp_groups_format_activity_action_group_details_updated',
51
+ __( 'Group Updates', 'buddypress' ),
52
+ array( 'activity', 'group', 'member', 'member_groups' )
53
+ );
54
+
55
  // These actions are for the legacy forums
56
  // Since the bbPress plugin also shares the same 'forums' identifier, we also
57
  // check for the legacy forums loader class to be extra cautious
136
  return apply_filters( 'bp_groups_format_activity_action_joined_group', $action, $activity );
137
  }
138
 
139
+ /**
140
+ * Format 'group_details_updated' activity actions.
141
+ *
142
+ * @since BuddyPress (2.2.0)
143
+ *
144
+ * @param string $action Static activity action.
145
+ * @param object $activity Activity data object.
146
+ * @return string
147
+ */
148
+ function bp_groups_format_activity_action_group_details_updated( $action, $activity ) {
149
+ $user_link = bp_core_get_userlink( $activity->user_id );
150
+
151
+ $group = groups_get_group( array(
152
+ 'group_id' => $activity->item_id,
153
+ 'populate_extras' => false,
154
+ ) );
155
+ $group_link = '<a href="' . esc_url( bp_get_group_permalink( $group ) ) . '">' . esc_html( $group->name ) . '</a>';
156
+
157
+ /*
158
+ * Changed group details are stored in groupmeta, keyed by the activity
159
+ * timestamp. See {@link bp_groups_group_details_updated_add_activity()}.
160
+ */
161
+ $changed = groups_get_groupmeta( $activity->item_id, 'updated_details_' . $activity->date_recorded );
162
+
163
+ // No changed details were found, so use a generic message.
164
+ if ( empty( $changed ) ) {
165
+ $action = sprintf( __( '%1$s updated details for the group %2$s', 'buddypress' ), $user_link, $group_link );
166
+
167
+ // Name and description changed - to keep things short, don't describe changes in detail.
168
+ } elseif ( isset( $changed['name'] ) && isset( $changed['description'] ) ) {
169
+ $action = sprintf( __( '%1$s changed the name and description of the group %2$s', 'buddypress' ), $user_link, $group_link );
170
+
171
+ // Name only.
172
+ } elseif ( ! empty( $changed['name']['old'] ) && ! empty( $changed['name']['new'] ) ) {
173
+ $action = sprintf( __( '%1$s changed the name of the group %2$s from "%3$s" to "%4$s"', 'buddypress' ), $user_link, $group_link, esc_html( $changed['name']['old'] ), esc_html( $changed['name']['new'] ) );
174
+
175
+ // Description only.
176
+ } elseif ( ! empty( $changed['description']['old'] ) && ! empty( $changed['description']['new'] ) ) {
177
+ $action = sprintf( __( '%1$s changed the description of the group %2$s from "%3$s" to "%4$s"', 'buddypress' ), $user_link, $group_link, esc_html( $changed['description']['old'] ), esc_html( $changed['description']['new'] ) );
178
+
179
+ }
180
+
181
+ return apply_filters( 'bp_groups_format_activity_action_joined_group', $action, $activity );
182
+ }
183
+
184
  /**
185
  * Fetch data related to groups at the beginning of an activity loop.
186
  *
233
  }
234
  add_filter( 'bp_activity_prefetch_object_data', 'bp_groups_prefetch_activity_object_data' );
235
 
236
+ /**
237
+ * Set up activity arguments for use with the 'groups' scope.
238
+ *
239
+ * @since BuddyPress (2.2.0)
240
+ *
241
+ * @param array $retval Empty array by default
242
+ * @param array $filter Current activity arguments
243
+ * @return array
244
+ */
245
+ function bp_groups_filter_activity_scope( $retval, $filter ) {
246
+ $groups = groups_get_user_groups( $filter['user_id'] );
247
+
248
+ if ( empty( $groups['groups'] ) ) {
249
+ return $retval;
250
+ }
251
+
252
+ $retval= array(
253
+ 'relation' => 'AND',
254
+ array(
255
+ 'column' => 'component',
256
+ 'value' => buddypress()->groups->id
257
+ ),
258
+ array(
259
+ 'column' => 'item_id',
260
+ 'compare' => 'IN',
261
+ 'value' => (array) $groups['groups']
262
+ ),
263
+ );
264
+
265
+ // wipe out the user ID
266
+ $retval['override']['filter']['user_id'] = 0;
267
+
268
+ return $retval;
269
+ }
270
+ add_filter( 'bp_activity_set_groups_scope_args', 'bp_groups_filter_activity_scope', 10, 2 );
271
+
272
  /**
273
  * Record an activity item related to the Groups component.
274
  *
379
  }
380
  add_action( 'groups_membership_accepted', 'bp_groups_membership_accepted_add_activity', 10, 2 );
381
 
382
+ /**
383
+ * Add an activity item when a group's details are updated.
384
+ *
385
+ * @since BuddyPress (2.2.0)
386
+ *
387
+ * @param int $group_id ID of the group.
388
+ * @param BP_Groups_Group $old_group Group object before the details had been changed.
389
+ * @param bool $notify_members True if the admin has opted to notify group members, otherwise false.
390
+ * @return int|bool The ID of the activity on success. False on error.
391
+ */
392
+ function bp_groups_group_details_updated_add_activity( $group_id, $old_group, $notify_members ) {
393
+
394
+ // Bail if Activity is not active.
395
+ if ( ! bp_is_active( 'activity' ) ) {
396
+ return false;
397
+ }
398
+
399
+ if ( ! isset( $old_group->name ) || ! isset( $old_group->description ) ) {
400
+ return false;
401
+ }
402
+
403
+ // If the admin has opted not to notify members, don't post an activity item either
404
+ if ( empty( $notify_members ) ) {
405
+ return;
406
+ }
407
+
408
+ $group = groups_get_group( array(
409
+ 'group_id' => $group_id,
410
+ ) );
411
+
412
+ /*
413
+ * Store the changed data, which will be used to generate the activity
414
+ * action. Since we haven't yet created the activity item, we store the
415
+ * old group data in groupmeta, keyed by the timestamp that we'll put
416
+ * on the activity item.
417
+ */
418
+ $changed = array();
419
+
420
+ if ( $group->name !== $old_group->name ) {
421
+ $changed['name'] = array(
422
+ 'old' => $old_group->name,
423
+ 'new' => $group->name,
424
+ );
425
+ }
426
+
427
+ if ( $group->description !== $old_group->description ) {
428
+ $changed['description'] = array(
429
+ 'old' => $old_group->description,
430
+ 'new' => $group->description,
431
+ );
432
+ }
433
+
434
+ // If there are no changes, don't post an activity item.
435
+ if ( empty( $changed ) ) {
436
+ return;
437
+ }
438
+
439
+ $time = bp_core_current_time();
440
+ groups_update_groupmeta( $group_id, 'updated_details_' . $time, $changed );
441
+
442
+ // Record in activity streams.
443
+ return groups_record_activity( array(
444
+ 'type' => 'group_details_updated',
445
+ 'item_id' => $group_id,
446
+ 'user_id' => bp_loggedin_user_id(),
447
+ 'recorded_time' => $time,
448
+
449
+ ) );
450
+
451
+ }
452
+ add_action( 'groups_details_updated', 'bp_groups_group_details_updated_add_activity', 10, 3 );
453
+
454
  /**
455
  * Delete all activity items related to a specific group.
456
  *
bp-groups/bp-groups-admin.php CHANGED
@@ -102,7 +102,7 @@ function bp_groups_admin_load() {
102
 
103
  bp_core_redirect( $redirect_to );
104
 
105
- } else if ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) {
106
  // columns screen option
107
  add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) );
108
 
@@ -211,6 +211,15 @@ function bp_groups_admin_load() {
211
  // groups_edit_base_group_details()
212
  if ( !groups_edit_base_group_details( $group_id, $_POST['bp-groups-name'], $_POST['bp-groups-description'], 0 ) ) {
213
  $error = $group_id;
 
 
 
 
 
 
 
 
 
214
  }
215
 
216
  // Enable discussion forum
@@ -308,7 +317,7 @@ function bp_groups_admin_load() {
308
 
309
  if ( 'admin' == $existing_role || 'mod' == $existing_role ) {
310
  $result = groups_demote_member( $user_id, $group_id );
311
- } else if ( 'banned' == $existing_role ) {
312
  $result = groups_unban_member( $user_id, $group_id );
313
  }
314
 
@@ -406,7 +415,7 @@ function bp_groups_admin_screen_options( $value, $option, $new_value ) {
406
  }
407
 
408
  /**
409
- * Select the appropirate Groups admin screen, and output it.
410
  *
411
  * @since BuddyPress (1.7.0)
412
  */
@@ -419,7 +428,7 @@ function bp_groups_admin() {
419
  bp_groups_admin_edit();
420
 
421
  // Display the group deletion confirmation screen
422
- } else if ( 'delete' == $doaction && ! empty( $_GET['gid'] ) ) {
423
  bp_groups_admin_delete();
424
 
425
  // Otherwise, display the groups index screen
@@ -455,8 +464,25 @@ function bp_groups_admin_edit() {
455
  }
456
 
457
  if ( ! empty( $errors ) ) {
458
- $messages[] = __( 'An error occurred when trying to update your group details.', 'buddypress' );
459
- } else if ( ! empty( $updated ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  $messages[] = __( 'The group has been updated successfully.', 'buddypress' );
461
  }
462
 
@@ -1143,7 +1169,7 @@ class BP_Groups_List_Table extends WP_List_Table {
1143
  $this->group_counts[ $group_type ] = count( $group_ids );
1144
  }
1145
 
1146
- // If we're viewing a specific group, flatten all activites into a single array.
1147
  if ( $include_id ) {
1148
  $groups = array( (array) groups_get_group( 'group_id=' . $include_id ) );
1149
  } else {
@@ -1491,7 +1517,7 @@ class BP_Groups_List_Table extends WP_List_Table {
1491
  }
1492
 
1493
  /**
1494
- * Allow plugins to add their costum column.
1495
  *
1496
  * @since BuddyPress 2.0.0
1497
  *
102
 
103
  bp_core_redirect( $redirect_to );
104
 
105
+ } elseif ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) {
106
  // columns screen option
107
  add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) );
108
 
211
  // groups_edit_base_group_details()
212
  if ( !groups_edit_base_group_details( $group_id, $_POST['bp-groups-name'], $_POST['bp-groups-description'], 0 ) ) {
213
  $error = $group_id;
214
+
215
+ // using negative integers for different error messages... eek!
216
+ if ( empty( $_POST['bp-groups-name'] ) && empty( $_POST['bp-groups-description'] ) ) {
217
+ $error = -3;
218
+ } elseif ( empty( $_POST['bp-groups-name'] ) ) {
219
+ $error = -1;
220
+ } elseif ( empty( $_POST['bp-groups-description'] ) ) {
221
+ $error = -2;
222
+ }
223
  }
224
 
225
  // Enable discussion forum
317
 
318
  if ( 'admin' == $existing_role || 'mod' == $existing_role ) {
319
  $result = groups_demote_member( $user_id, $group_id );
320
+ } elseif ( 'banned' == $existing_role ) {
321
  $result = groups_unban_member( $user_id, $group_id );
322
  }
323
 
415
  }
416
 
417
  /**
418
+ * Select the appropriate Groups admin screen, and output it.
419
  *
420
  * @since BuddyPress (1.7.0)
421
  */
428
  bp_groups_admin_edit();
429
 
430
  // Display the group deletion confirmation screen
431
+ } elseif ( 'delete' == $doaction && ! empty( $_GET['gid'] ) ) {
432
  bp_groups_admin_delete();
433
 
434
  // Otherwise, display the groups index screen
464
  }
465
 
466
  if ( ! empty( $errors ) ) {
467
+ switch ( $errors ) {
468
+ case -1 :
469
+ $messages[] = __( 'Group name cannot be empty.', 'buddypress' );
470
+ break;
471
+
472
+ case -2 :
473
+ $messages[] = __( 'Group description cannot be empty.', 'buddypress' );
474
+ break;
475
+
476
+ case -3 :
477
+ $messages[] = __( 'Group name and description cannot be empty.', 'buddypress' );
478
+ break;
479
+
480
+ default :
481
+ $messages[] = __( 'An error occurred when trying to update your group details.', 'buddypress' );
482
+ break;
483
+ }
484
+
485
+ } elseif ( ! empty( $updated ) ) {
486
  $messages[] = __( 'The group has been updated successfully.', 'buddypress' );
487
  }
488
 
1169
  $this->group_counts[ $group_type ] = count( $group_ids );
1170
  }
1171
 
1172
+ // If we're viewing a specific group, flatten all activities into a single array.
1173
  if ( $include_id ) {
1174
  $groups = array( (array) groups_get_group( 'group_id=' . $include_id ) );
1175
  } else {
1517
  }
1518
 
1519
  /**
1520
+ * Allow plugins to add their custom column.
1521
  *
1522
  * @since BuddyPress 2.0.0
1523
  *
bp-groups/bp-groups-adminbar.php CHANGED
@@ -23,15 +23,18 @@ if ( !defined( 'ABSPATH' ) ) exit;
23
  * access to group admin options.
24
  */
25
  function bp_groups_group_admin_menu() {
26
- global $wp_admin_bar, $bp;
 
27
 
28
  // Only show if viewing a group
29
- if ( !bp_is_group() )
30
  return false;
 
31
 
32
  // Only show this menu to group admins and super admins
33
- if ( !bp_current_user_can( 'bp_moderate' ) && !bp_group_is_admin() )
34
  return false;
 
35
 
36
  // Unique ID for the 'Edit Group' menu
37
  $bp->group_admin_menu_id = 'group-admin';
@@ -43,67 +46,39 @@ function bp_groups_group_admin_menu() {
43
  'href' => bp_get_group_permalink( $bp->groups->current_group )
44
  ) );
45
 
46
- // Group Admin > Edit details
47
- $wp_admin_bar->add_menu( array(
48
- 'parent' => $bp->group_admin_menu_id,
49
- 'id' => 'edit-details',
50
- 'title' => __( 'Edit Details', 'buddypress' ),
51
- 'href' => bp_get_groups_action_link( 'admin/edit-details' )
52
- ) );
53
-
54
- // Group Admin > Group settings
55
- $wp_admin_bar->add_menu( array(
56
- 'parent' => $bp->group_admin_menu_id,
57
- 'id' => 'group-settings',
58
- 'title' => __( 'Edit Settings', 'buddypress' ),
59
- 'href' => bp_get_groups_action_link( 'admin/group-settings' )
60
- ) );
61
 
62
- // Group Admin > Group avatar
63
- if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) && $bp->avatar->show_avatars ) {
64
- $wp_admin_bar->add_menu( array(
65
- 'parent' => $bp->group_admin_menu_id,
66
- 'id' => 'group-avatar',
67
- 'title' => __( 'Edit Profile Photo', 'buddypress' ),
68
- 'href' => bp_get_groups_action_link( 'admin/group-avatar' )
69
- ) );
70
  }
71
 
72
- // Group Admin > Manage invitations
73
- if ( bp_is_active( 'friends' ) ) {
74
- $wp_admin_bar->add_menu( array(
75
- 'parent' => $bp->group_admin_menu_id,
76
- 'id' => 'manage-invitations',
77
- 'title' => __( 'Manage Invitations', 'buddypress' ),
78
- 'href' => bp_get_groups_action_link( 'send-invites' )
79
- ) );
80
- }
 
 
81
 
82
- // Group Admin > Manage members
83
- $wp_admin_bar->add_menu( array(
84
- 'parent' => $bp->group_admin_menu_id,
85
- 'id' => 'manage-members',
86
- 'title' => __( 'Manage Members', 'buddypress' ),
87
- 'href' => bp_get_groups_action_link( 'admin/manage-members' )
88
- ) );
89
 
90
- // Group Admin > Membership Requests
91
- if ( bp_get_group_status( $bp->groups->current_group ) == 'private' ) {
92
- $wp_admin_bar->add_menu( array(
93
- 'parent' => $bp->group_admin_menu_id,
94
- 'id' => 'membership-requests',
95
- 'title' => __( 'Membership Requests', 'buddypress' ),
96
- 'href' => bp_get_groups_action_link( 'admin/membership-requests' )
97
- ) );
98
  }
99
-
100
- // Delete Group
101
- $wp_admin_bar->add_menu( array(
102
- 'parent' => $bp->group_admin_menu_id,
103
- 'id' => 'delete-group',
104
- 'title' => __( 'Delete Group', 'buddypress' ),
105
- 'href' => bp_get_groups_action_link( 'admin/delete-group' )
106
- ) );
107
  }
108
  add_action( 'admin_bar_menu', 'bp_groups_group_admin_menu', 99 );
109
 
23
  * access to group admin options.
24
  */
25
  function bp_groups_group_admin_menu() {
26
+ global $wp_admin_bar;
27
+ $bp = buddypress();
28
 
29
  // Only show if viewing a group
30
+ if ( ! bp_is_group() || bp_is_group_create() ) {
31
  return false;
32
+ }
33
 
34
  // Only show this menu to group admins and super admins
35
+ if ( ! bp_current_user_can( 'bp_moderate' ) && ! bp_group_is_admin() ) {
36
  return false;
37
+ }
38
 
39
  // Unique ID for the 'Edit Group' menu
40
  $bp->group_admin_menu_id = 'group-admin';
46
  'href' => bp_get_group_permalink( $bp->groups->current_group )
47
  ) );
48
 
49
+ // Index of the Manage tabs parent slug
50
+ $nav_index = $bp->groups->current_group->slug . '_manage';
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ // Check if current group has Manage tabs
53
+ if ( empty( $bp->bp_options_nav[ $nav_index ] ) ) {
54
+ return;
 
 
 
 
 
55
  }
56
 
57
+ // Build the Group Admin menus
58
+ foreach ( $bp->bp_options_nav[ $nav_index ] as $menu ) {
59
+ /**
60
+ * Should we add the current manage link in the Group's "Edit" Admin Bar menu ?
61
+ *
62
+ * All core items will be added, plugins can use a new parameter in the BP Group Extension API
63
+ * to also add the link to the "edit screen" of their group component. To do so, set the
64
+ * the 'show_in_admin_bar' argument of your edit screen to true
65
+ */
66
+ if ( $menu['show_in_admin_bar'] ) {
67
+ $title = sprintf( _x( 'Edit Group %s', 'Group WP Admin Bar manage links', 'buddypress' ), $menu['name'] );
68
 
69
+ // Title is specific for delete
70
+ if ( 'delete-group' == $menu['slug'] ) {
71
+ $title = sprintf( _x( '%s Group', 'Group WP Admin Bar delete link', 'buddypress' ), $menu['name'] );
72
+ }
 
 
 
73
 
74
+ $wp_admin_bar->add_menu( array(
75
+ 'parent' => $bp->group_admin_menu_id,
76
+ 'id' => $menu['slug'],
77
+ 'title' => $title,
78
+ 'href' => bp_get_groups_action_link( 'admin/' . $menu['slug'] )
79
+ ) );
80
+ }
 
81
  }
 
 
 
 
 
 
 
 
82
  }
83
  add_action( 'admin_bar_menu', 'bp_groups_group_admin_menu', 99 );
84
 
bp-groups/bp-groups-classes.php CHANGED
@@ -781,7 +781,7 @@ class BP_Groups_Group {
781
  $paged_groups_sql = apply_filters( 'bp_groups_get_paged_groups_sql', join( ' ', (array) $sql ), $sql, $r );
782
  $paged_groups = $wpdb->get_results( $paged_groups_sql );
783
 
784
- $total_sql['select'] = "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name} g, {$bp->groups->table_name_members} gm1, {$bp->groups->table_name_groupmeta} gm2";
785
 
786
  if ( ! empty( $r['user_id'] ) ) {
787
  $total_sql['select'] .= ", {$bp->groups->table_name_members} m";
@@ -820,9 +820,8 @@ class BP_Groups_Group {
820
  $total_sql['where'][] = "g.id NOT IN ({$exclude})";
821
  }
822
 
823
- $total_sql['where'][] = "g.id = gm1.group_id";
824
- $total_sql['where'][] = "g.id = gm2.group_id";
825
- $total_sql['where'][] = "gm2.meta_key = 'last_activity'";
826
 
827
  $t_sql = $total_sql['select'];
828
 
@@ -895,12 +894,12 @@ class BP_Groups_Group {
895
  // @todo It may be better in the long run to refactor
896
  // the more general query syntax to accord better with
897
  // BP/WP convention
898
- preg_match_all( '/INNER JOIN (.*) ON/', $meta_sql['join'], $matches_a );
899
- preg_match_all( '/ON \((.*)\)/', $meta_sql['join'], $matches_b );
900
 
901
  if ( ! empty( $matches_a[1] ) && ! empty( $matches_b[1] ) ) {
902
  $sql_array['join'] = implode( ',', $matches_a[1] ) . ', ';
903
- $sql_array['where'] = $meta_sql['where'] . ' AND ' . implode ( ' AND ', $matches_b[1] );
904
  }
905
  }
906
 
@@ -1296,7 +1295,7 @@ class BP_Groups_Group {
1296
  $is_member = '1';
1297
 
1298
  // invite_sent means the user has been invited
1299
- } else if ( $user_status[ $gid ]->invite_sent ) {
1300
  $is_invited = '1';
1301
 
1302
  // User has sent request, but has not been confirmed
@@ -1612,7 +1611,7 @@ class BP_Group_Member_Query extends BP_User_Query {
1612
  $sql['where'][] = "inviter_id = 0";
1613
 
1614
  // The string 'any' matches any non-zero value (inviter_id != 0)
1615
- } else if ( 'any' === $inviter_id ) {
1616
  $sql['where'][] = "inviter_id != 0";
1617
 
1618
  // Assume that a list of inviter IDs has been passed
@@ -2874,7 +2873,7 @@ class BP_Group_Extension {
2874
  public $class_reflection = null;
2875
 
2876
  /**
2877
- * Parsed configuration paramaters for the extension.
2878
  *
2879
  * @since BuddyPress (1.8.0)
2880
  * @access public
@@ -3045,7 +3044,7 @@ class BP_Group_Extension {
3045
  */
3046
 
3047
  // The content of the group tab
3048
- public function display() {}
3049
 
3050
  // Content displayed in a widget sidebar, if applicable
3051
  public function widget_display() {}
@@ -3310,7 +3309,7 @@ class BP_Group_Extension {
3310
  * @since BuddyPress (2.1.0)
3311
  */
3312
  protected function setup_access_settings() {
3313
- // Bail if no gruop ID is available
3314
  if ( empty( $this->group_id ) ) {
3315
  return;
3316
  }
@@ -3370,7 +3369,7 @@ class BP_Group_Extension {
3370
  // constructor. So we always trust this value
3371
  $this->params['show_tab'] = 'noone';
3372
 
3373
- } else if ( isset( $this->params_raw['enable_nav_item'] ) || isset( $this->params_raw['visibility'] ) ) {
3374
  // If enable_nav_item or visibility is passed,
3375
  // we assume this is a legacy extension.
3376
  // Legacy behavior is that enable_nav_item=true +
@@ -3500,10 +3499,22 @@ class BP_Group_Extension {
3500
  * Hook the main display method, and loads the template file
3501
  */
3502
  public function _display_hook() {
3503
- add_action( 'bp_template_content', array( &$this, 'display' ) );
3504
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', $this->template_file ) );
3505
  }
3506
 
 
 
 
 
 
 
 
 
 
 
 
 
3507
  /**
3508
  * Determine whether the current user should see this nav tab.
3509
  *
@@ -3637,6 +3648,10 @@ class BP_Group_Extension {
3637
  * @since BuddyPress (1.8.0)
3638
  */
3639
  protected function setup_edit_hooks() {
 
 
 
 
3640
 
3641
  // Bail if not an edit screen
3642
  if ( ! $this->is_screen_enabled( 'edit' ) || ! bp_is_item_admin() ) {
@@ -3646,15 +3661,28 @@ class BP_Group_Extension {
3646
  $screen = $this->screens['edit'];
3647
 
3648
  $position = isset( $screen['position'] ) ? (int) $screen['position'] : 10;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3649
 
3650
- // Add the tab
3651
- // @todo BP should be using bp_core_new_subnav_item()
3652
- add_action( 'groups_admin_tabs', create_function( '$current, $group_slug',
3653
- '$selected = "";
3654
- if ( "' . esc_attr( $screen['slug'] ) . '" == $current )
3655
- $selected = " class=\"current\"";
3656
- echo "<li{$selected}><a href=\"' . trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/{$group_slug}/admin/' . esc_attr( $screen['slug'] ) ) . '\">' . esc_attr( $screen['name'] ) . '</a></li>";'
3657
- ), $position, 2 );
3658
 
3659
  // Catch the edit screen and forward it to the plugin template
3660
  if ( bp_is_groups_component() && bp_is_current_action( 'admin' ) && bp_is_action_variable( $screen['slug'], 0 ) ) {
781
  $paged_groups_sql = apply_filters( 'bp_groups_get_paged_groups_sql', join( ' ', (array) $sql ), $sql, $r );
782
  $paged_groups = $wpdb->get_results( $paged_groups_sql );
783
 
784
+ $total_sql['select'] = "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm";
785
 
786
  if ( ! empty( $r['user_id'] ) ) {
787
  $total_sql['select'] .= ", {$bp->groups->table_name_members} m";
820
  $total_sql['where'][] = "g.id NOT IN ({$exclude})";
821
  }
822
 
823
+ $total_sql['where'][] = "g.id = gm.group_id";
824
+ $total_sql['where'][] = "gm.meta_key = 'last_activity'";
 
825
 
826
  $t_sql = $total_sql['select'];
827
 
894
  // @todo It may be better in the long run to refactor
895
  // the more general query syntax to accord better with
896
  // BP/WP convention
897
+ preg_match_all( '/JOIN (.+?) ON/', $meta_sql['join'], $matches_a );
898
+ preg_match_all( '/ON \((.+?)\)/', $meta_sql['join'], $matches_b );
899
 
900
  if ( ! empty( $matches_a[1] ) && ! empty( $matches_b[1] ) ) {
901
  $sql_array['join'] = implode( ',', $matches_a[1] ) . ', ';
902
+ $sql_array['where'] = $meta_sql['where'] . ' AND ' . implode( ' AND ', $matches_b[1] );
903
  }
904
  }
905
 
1295
  $is_member = '1';
1296
 
1297
  // invite_sent means the user has been invited
1298
+ } elseif ( $user_status[ $gid ]->invite_sent ) {
1299
  $is_invited = '1';
1300
 
1301
  // User has sent request, but has not been confirmed
1611
  $sql['where'][] = "inviter_id = 0";
1612
 
1613
  // The string 'any' matches any non-zero value (inviter_id != 0)
1614
+ } elseif ( 'any' === $inviter_id ) {
1615
  $sql['where'][] = "inviter_id != 0";
1616
 
1617
  // Assume that a list of inviter IDs has been passed
2873
  public $class_reflection = null;
2874
 
2875
  /**
2876
+ * Parsed configuration parameters for the extension.
2877
  *
2878
  * @since BuddyPress (1.8.0)
2879
  * @access public
3044
  */
3045
 
3046
  // The content of the group tab
3047
+ public function display( $group_id = null ) {}
3048
 
3049
  // Content displayed in a widget sidebar, if applicable
3050
  public function widget_display() {}
3309
  * @since BuddyPress (2.1.0)
3310
  */
3311
  protected function setup_access_settings() {
3312
+ // Bail if no group ID is available
3313
  if ( empty( $this->group_id ) ) {
3314
  return;
3315
  }
3369
  // constructor. So we always trust this value
3370
  $this->params['show_tab'] = 'noone';
3371
 
3372
+ } elseif ( isset( $this->params_raw['enable_nav_item'] ) || isset( $this->params_raw['visibility'] ) ) {
3373
  // If enable_nav_item or visibility is passed,
3374
  // we assume this is a legacy extension.
3375
  // Legacy behavior is that enable_nav_item=true +
3499
  * Hook the main display method, and loads the template file
3500
  */
3501
  public function _display_hook() {
3502
+ add_action( 'bp_template_content', array( &$this, 'call_display' ) );
3503
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', $this->template_file ) );
3504
  }
3505
 
3506
+ /**
3507
+ * Call the display() method.
3508
+ *
3509
+ * We use this wrapper so that we can pass the group_id to the
3510
+ * display() callback.
3511
+ *
3512
+ * @since BuddyPress (2.1.1)
3513
+ */
3514
+ public function call_display() {
3515
+ $this->display( $this->group_id );
3516
+ }
3517
+
3518
  /**
3519
  * Determine whether the current user should see this nav tab.
3520
  *
3648
  * @since BuddyPress (1.8.0)
3649
  */
3650
  protected function setup_edit_hooks() {
3651
+ // Bail if not in a group
3652
+ if ( ! bp_is_group() ) {
3653
+ return;
3654
+ }
3655
 
3656
  // Bail if not an edit screen
3657
  if ( ! $this->is_screen_enabled( 'edit' ) || ! bp_is_item_admin() ) {
3661
  $screen = $this->screens['edit'];
3662
 
3663
  $position = isset( $screen['position'] ) ? (int) $screen['position'] : 10;
3664
+ $position += 40;
3665
+
3666
+ $current_group = groups_get_current_group();
3667
+ $admin_link = trailingslashit( bp_get_group_permalink( $current_group ) . 'admin' );
3668
+
3669
+ $subnav_args = array(
3670
+ 'name' => $screen['name'],
3671
+ 'slug' => $screen['slug'],
3672
+ 'parent_slug' => $current_group->slug . '_manage',
3673
+ 'parent_url' => trailingslashit( bp_get_group_permalink( $current_group ) . 'admin' ),
3674
+ 'user_has_access' => bp_is_item_admin(),
3675
+ 'position' => $position,
3676
+ 'screen_function' => 'groups_screen_group_admin',
3677
+ );
3678
+
3679
+ // Should we add a menu to the Group's WP Admin Bar
3680
+ if ( ! empty( $screen['show_in_admin_bar'] ) ) {
3681
+ $subnav_args['show_in_admin_bar'] = true;
3682
+ }
3683
 
3684
+ // Add the tab to the manage navigation
3685
+ bp_core_new_subnav_item( $subnav_args );
 
 
 
 
 
 
3686
 
3687
  // Catch the edit screen and forward it to the plugin template
3688
  if ( bp_is_groups_component() && bp_is_current_action( 'admin' ) && bp_is_action_variable( $screen['slug'], 0 ) ) {
bp-groups/bp-groups-filters.php CHANGED
@@ -233,3 +233,25 @@ function groups_filter_forums_root_page_sql( $sql ) {
233
  return apply_filters( 'groups_filter_bbpress_root_page_sql', 't.topic_id' );
234
  }
235
  add_filter( 'get_latest_topics_fields', 'groups_filter_forums_root_page_sql' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  return apply_filters( 'groups_filter_bbpress_root_page_sql', 't.topic_id' );
234
  }
235
  add_filter( 'get_latest_topics_fields', 'groups_filter_forums_root_page_sql' );
236
+
237
+ /**
238
+ * Should BuddyPress load the mentions scripts and related assets, including results to prime the
239
+ * mentions suggestions?
240
+ *
241
+ * @param bool $load_mentions True to load mentions assets, false otherwise.
242
+ * @param bool $mentions_enabled True if mentions are enabled.
243
+ * @return bool True if mentions scripts should be loaded.
244
+ * @since BuddyPress (2.2.0)
245
+ */
246
+ function bp_groups_maybe_load_mentions_scripts( $load_mentions, $mentions_enabled ) {
247
+ if ( ! $mentions_enabled ) {
248
+ return $load_mentions;
249
+ }
250
+
251
+ if ( $load_mentions || ( bp_is_group_activity() || bp_is_group_home() ) ) {
252
+ return true;
253
+ }
254
+
255
+ return $load_mentions;
256
+ }
257
+ add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bp_groups_maybe_load_mentions_scripts', 10, 2 );
bp-groups/bp-groups-functions.php CHANGED
@@ -120,12 +120,16 @@ function groups_create_group( $args = '' ) {
120
  }
121
 
122
  // Set creator ID
123
- if ( ! empty( $creator_id ) ) {
124
  $group->creator_id = (int) $creator_id;
125
- } else {
126
  $group->creator_id = bp_loggedin_user_id();
127
  }
128
 
 
 
 
 
129
  // Validate status
130
  if ( ! groups_is_valid_status( $status ) ) {
131
  return false;
@@ -186,7 +190,9 @@ function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $n
186
  if ( empty( $group_name ) || empty( $group_desc ) )
187
  return false;
188
 
189
- $group = groups_get_group( array( 'group_id' => $group_id ) );
 
 
190
  $group->name = $group_name;
191
  $group->description = $group_desc;
192
 
@@ -194,10 +200,19 @@ function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $n
194
  return false;
195
 
196
  if ( $notify_members ) {
197
- groups_notification_group_updated( $group->id );
198
  }
199
 
200
- do_action( 'groups_details_updated', $group->id );
 
 
 
 
 
 
 
 
 
201
 
202
  return true;
203
  }
@@ -394,7 +409,7 @@ function groups_join_group( $group_id, $user_id = 0 ) {
394
 
395
  // Check if the user has an outstanding request. If so, delete it.
396
  if ( groups_check_for_membership_request( $user_id, $group_id ) )
397
- groups_delete_membership_request( $user_id, $group_id );
398
 
399
  // User is already a member, just return true
400
  if ( groups_is_user_member( $user_id, $group_id ) )
@@ -629,7 +644,9 @@ function groups_get_groups( $args = '' ) {
629
  * @return int
630
  */
631
  function groups_get_total_group_count() {
632
- if ( !$count = wp_cache_get( 'bp_total_group_count', 'bp' ) ) {
 
 
633
  $count = BP_Groups_Group::get_total_group_count();
634
  wp_cache_set( 'bp_total_group_count', $count, 'bp' );
635
  }
@@ -669,7 +686,9 @@ function groups_total_groups_for_user( $user_id = 0 ) {
669
  if ( empty( $user_id ) )
670
  $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
671
 
672
- if ( !$count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' ) ) {
 
 
673
  $count = BP_Groups_Member::total_group_count( $user_id );
674
  wp_cache_set( 'bp_total_groups_for_user_' . $user_id, $count, 'bp' );
675
  }
@@ -902,7 +921,7 @@ function groups_invite_user( $args = '' ) {
902
  groups_accept_membership_request( $membership_id, $user_id, $group_id );
903
 
904
  // Otherwise, create a new invitation
905
- } else if ( ! groups_is_user_member( $user_id, $group_id ) && ! groups_check_user_has_invite( $user_id, $group_id, 'all' ) ) {
906
  $invite = new BP_Groups_Member;
907
  $invite->group_id = $group_id;
908
  $invite->user_id = $user_id;
@@ -957,7 +976,7 @@ function groups_accept_invite( $user_id, $group_id ) {
957
  }
958
 
959
  if ( groups_check_for_membership_request( $user_id, $group_id ) ) {
960
- groups_delete_membership_request( $user_id, $group_id );
961
  }
962
 
963
  return true;
@@ -1043,6 +1062,14 @@ function groups_send_invites( $user_id, $group_id ) {
1043
  do_action( 'groups_send_invites', $group_id, $invited_users );
1044
  }
1045
 
 
 
 
 
 
 
 
 
1046
  function groups_get_invites_for_group( $user_id, $group_id ) {
1047
  return BP_Groups_Group::get_invites( $user_id, $group_id );
1048
  }
@@ -1101,7 +1128,7 @@ function groups_promote_member( $user_id, $group_id, $status ) {
1101
  }
1102
 
1103
  /**
1104
- * Demone a user to 'member' status within a group.
1105
  *
1106
  * @param int $user_id ID of the user.
1107
  * @param int $group_id ID of the group.
120
  }
121
 
122
  // Set creator ID
123
+ if ( $creator_id ) {
124
  $group->creator_id = (int) $creator_id;
125
+ } elseif ( is_user_logged_in() ) {
126
  $group->creator_id = bp_loggedin_user_id();
127
  }
128
 
129
+ if ( ! $group->creator_id ) {
130
+ return false;
131
+ }
132
+
133
  // Validate status
134
  if ( ! groups_is_valid_status( $status ) ) {
135
  return false;
190
  if ( empty( $group_name ) || empty( $group_desc ) )
191
  return false;
192
 
193
+ $group = groups_get_group( array( 'group_id' => $group_id ) );
194
+ $old_group = clone $group;
195
+
196
  $group->name = $group_name;
197
  $group->description = $group_desc;
198
 
200
  return false;
201
 
202
  if ( $notify_members ) {
203
+ groups_notification_group_updated( $group->id, $old_group );
204
  }
205
 
206
+ /**
207
+ * Fired after a group's details are updated.
208
+ *
209
+ * @since BuddyPress (2.2.0)
210
+ *
211
+ * @param int $value ID of the group.
212
+ * @param BP_Groups_Group $old_group Group object, before being modified.
213
+ * @param bool $notify_members Whether to send an email notification to members about the change.
214
+ */
215
+ do_action( 'groups_details_updated', $group->id, $old_group, $notify_members );
216
 
217
  return true;
218
  }
409
 
410
  // Check if the user has an outstanding request. If so, delete it.
411
  if ( groups_check_for_membership_request( $user_id, $group_id ) )
412
+ groups_delete_membership_request( null, $user_id, $group_id );
413
 
414
  // User is already a member, just return true
415
  if ( groups_is_user_member( $user_id, $group_id ) )
644
  * @return int
645
  */
646
  function groups_get_total_group_count() {
647
+ $count = wp_cache_get( 'bp_total_group_count', 'bp' );
648
+
649
+ if ( false === $count ) {
650
  $count = BP_Groups_Group::get_total_group_count();
651
  wp_cache_set( 'bp_total_group_count', $count, 'bp' );
652
  }
686
  if ( empty( $user_id ) )
687
  $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
688
 
689
+ $count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' );
690
+
691
+ if ( false === $count ) {
692
  $count = BP_Groups_Member::total_group_count( $user_id );
693
  wp_cache_set( 'bp_total_groups_for_user_' . $user_id, $count, 'bp' );
694
  }
921
  groups_accept_membership_request( $membership_id, $user_id, $group_id );
922
 
923
  // Otherwise, create a new invitation
924
+ } elseif ( ! groups_is_user_member( $user_id, $group_id ) && ! groups_check_user_has_invite( $user_id, $group_id, 'all' ) ) {
925
  $invite = new BP_Groups_Member;
926
  $invite->group_id = $group_id;
927
  $invite->user_id = $user_id;
976
  }
977
 
978
  if ( groups_check_for_membership_request( $user_id, $group_id ) ) {
979
+ groups_delete_membership_request( null, $user_id, $group_id );
980
  }
981
 
982
  return true;
1062
  do_action( 'groups_send_invites', $group_id, $invited_users );
1063
  }
1064
 
1065
+ /**
1066
+ * Get IDs of users with outstanding invites to a given group from a specified user.
1067
+ *
1068
+ * @param int $user_id ID of the inviting user.
1069
+ * @param int $group_id ID of the group.
1070
+ * @return array IDs of users who have been invited to the group by the
1071
+ * user but have not yet accepted.
1072
+ */
1073
  function groups_get_invites_for_group( $user_id, $group_id ) {
1074
  return BP_Groups_Group::get_invites( $user_id, $group_id );
1075
  }
1128
  }
1129
 
1130
  /**
1131
+ * Demote a user to 'member' status within a group.
1132
  *
1133
  * @param int $user_id ID of the user.
1134
  * @param int $group_id ID of the group.
bp-groups/bp-groups-loader.php CHANGED
@@ -507,6 +507,57 @@ class BP_Groups_Component extends BP_Component {
507
  'item_css_id' => 'admin',
508
  'no_access_url' => $group_link,
509
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  }
511
 
512
  parent::setup_nav( $main_nav, $sub_nav );
@@ -597,7 +648,7 @@ class BP_Groups_Component extends BP_Component {
597
  if ( bp_is_my_profile() && !bp_is_single_item() ) {
598
  $bp->bp_options_title = _x( 'Memberships', 'My Groups page <title>', 'buddypress' );
599
 
600
- } else if ( !bp_is_my_profile() && !bp_is_single_item() ) {
601
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
602
  'item_id' => bp_displayed_user_id(),
603
  'type' => 'thumb',
@@ -607,7 +658,7 @@ class BP_Groups_Component extends BP_Component {
607
 
608
  // We are viewing a single group, so set up the
609
  // group navigation menu using the $this->current_group global.
610
- } else if ( bp_is_single_item() ) {
611
  $bp->bp_options_title = $this->current_group->name;
612
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
613
  'item_id' => $this->current_group->id,
@@ -625,6 +676,24 @@ class BP_Groups_Component extends BP_Component {
625
 
626
  parent::setup_title();
627
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  }
629
 
630
  /**
507
  'item_css_id' => 'admin',
508
  'no_access_url' => $group_link,
509
  );
510
+
511
+ $admin_link = trailingslashit( $group_link . 'admin' );
512
+
513
+ // Common params to all nav items
514
+ $default_params = array(
515
+ 'parent_url' => $admin_link,
516
+ 'parent_slug' => $this->current_group->slug . '_manage',
517
+ 'screen_function' => 'groups_screen_group_admin',
518
+ 'user_has_access' => bp_is_item_admin(),
519
+ 'show_in_admin_bar' => true,
520
+ );
521
+
522
+ $sub_nav[] = array_merge( array(
523
+ 'name' => __( 'Details', 'buddypress' ),
524
+ 'slug' => 'edit-details',
525
+ 'position' => 0,
526
+ ), $default_params );
527
+
528
+ $sub_nav[] = array_merge( array(
529
+ 'name' => __( 'Settings', 'buddypress' ),
530
+ 'slug' => 'group-settings',
531
+ 'position' => 10,
532
+ ), $default_params );
533
+
534
+ if ( ! (int) bp_get_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) {
535
+ $sub_nav[] = array_merge( array(
536
+ 'name' => __( 'Photo', 'buddypress' ),
537
+ 'slug' => 'group-avatar',
538
+ 'position' => 20,
539
+ ), $default_params );
540
+ }
541
+
542
+ $sub_nav[] = array_merge( array(
543
+ 'name' => __( 'Members', 'buddypress' ),
544
+ 'slug' => 'manage-members',
545
+ 'position' => 30,
546
+ ), $default_params );
547
+
548
+ if ( 'private' == $this->current_group->status ) {
549
+ $sub_nav[] = array_merge( array(
550
+ 'name' => __( 'Requests', 'buddypress' ),
551
+ 'slug' => 'membership-requests',
552
+ 'position' => 40,
553
+ ), $default_params );
554
+ }
555
+
556
+ $sub_nav[] = array_merge( array(
557
+ 'name' => __( 'Delete', 'buddypress' ),
558
+ 'slug' => 'delete-group',
559
+ 'position' => 1000,
560
+ ), $default_params );
561
  }
562
 
563
  parent::setup_nav( $main_nav, $sub_nav );
648
  if ( bp_is_my_profile() && !bp_is_single_item() ) {
649
  $bp->bp_options_title = _x( 'Memberships', 'My Groups page <title>', 'buddypress' );
650
 
651
+ } elseif ( !bp_is_my_profile() && !bp_is_single_item() ) {
652
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
653
  'item_id' => bp_displayed_user_id(),
654
  'type' => 'thumb',
658
 
659
  // We are viewing a single group, so set up the
660
  // group navigation menu using the $this->current_group global.
661
+ } elseif ( bp_is_single_item() ) {
662
  $bp->bp_options_title = $this->current_group->name;
663
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
664
  'item_id' => $this->current_group->id,
676
 
677
  parent::setup_title();
678
  }
679
+
680
+ /**
681
+ * Setup cache groups
682
+ *
683
+ * @since BuddyPress (2.2.0)
684
+ */
685
+ public function setup_cache_groups() {
686
+
687
+ // Global groups
688
+ wp_cache_add_global_groups( array(
689
+ 'bp_groups',
690
+ 'bp_group_admins',
691
+ 'bp_group_invite_count',
692
+ 'group_meta'
693
+ ) );
694
+
695
+ parent::setup_cache_groups();
696
+ }
697
  }
698
 
699
  /**
bp-groups/bp-groups-notifications.php CHANGED
@@ -21,10 +21,46 @@ if ( !defined( 'ABSPATH' ) ) exit;
21
  * @since BuddyPress (1.0.0)
22
  *
23
  * @param int $group_id ID of the group.
 
24
  */
25
- function groups_notification_group_updated( $group_id = 0 ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- $group = groups_get_group( array( 'group_id' => $group_id ) );
28
  $subject = bp_get_email_subject( array( 'text' => __( 'Group Details Updated', 'buddypress' ) ) );
29
  $user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
30
 
@@ -45,12 +81,12 @@ function groups_notification_group_updated( $group_id = 0 ) {
45
  $settings_link = bp_core_get_user_domain( $user_id ) . $settings_slug . '/notifications/';
46
 
47
  $message = sprintf( __(
48
- 'Group details for the group "%1$s" were updated:
49
 
50
- To view the group: %2$s
51
 
52
  ---------------------
53
- ', 'buddypress' ), $group->name, $group_link );
54
 
55
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
56
 
@@ -111,11 +147,32 @@ function groups_notification_new_membership_request( $requesting_user_id = 0, $a
111
  // Link to the group administrator email settings: %s in "disable notifications" part of the email
112
  $settings_link = bp_core_get_user_domain( $admin_id ) . $settings_slug . '/notifications/';
113
 
 
 
 
114
  // Set up and send the message
115
  $to = $ud->user_email;
116
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ) ) );
117
 
118
- $message = sprintf( __(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  '%1$s wants to join the group "%2$s".
120
 
121
  Because you are the administrator of this group, you must either accept or reject the membership request.
@@ -127,6 +184,7 @@ To view %4$s\'s profile: %5$s
127
 
128
  ---------------------
129
  ', 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_link );
 
130
 
131
  // Only show the disable notifications line if the settings component is enabled
132
  if ( bp_is_active( 'settings' ) ) {
@@ -393,19 +451,50 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
393
 
394
  $group = groups_get_group( array( 'group_id' => $group_id ) );
395
  $group_link = bp_get_group_permalink( $group );
 
396
 
397
  // Set up the string and the filter
398
  // Because different values are passed to the filters, we'll return the
399
  // values inline
400
  if ( (int) $total_items > 1 ) {
401
  $text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name );
402
- $filter = 'bp_groups_multiple_new_membership_requests_notification';
403
  $notification_link = $group_link . 'admin/membership-requests/?n=1';
404
 
405
  if ( 'string' == $format ) {
406
- return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . $text . '</a>', $group_link, $total_items, $group->name, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  } else {
408
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  'link' => $notification_link,
410
  'text' => $text
411
  ), $group_link, $total_items, $group->name, $text, $notification_link );
@@ -413,13 +502,42 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
413
  } else {
414
  $user_fullname = bp_core_get_user_displayname( $requesting_user_id );
415
  $text = sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname );
416
- $filter = 'bp_groups_single_new_membership_request_notification';
417
  $notification_link = $group_link . 'admin/membership-requests/?n=1';
418
 
419
  if ( 'string' == $format ) {
420
- return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . $text . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  } else {
422
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
  'link' => $notification_link,
424
  'text' => $text
425
  ), $group_link, $user_fullname, $group->name, $text, $notification_link );
@@ -433,16 +551,41 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
433
 
434
  $group = groups_get_group( array( 'group_id' => $group_id ) );
435
  $group_link = bp_get_group_permalink( $group );
 
436
 
437
  if ( (int) $total_items > 1 ) {
438
  $text = sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int) $total_items, $group->name );
439
- $filter = 'bp_groups_multiple_membership_request_accepted_notification';
440
  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
441
 
442
  if ( 'string' == $format ) {
443
- return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
 
444
  } else {
445
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
446
  'link' => $notification_link,
447
  'text' => $text
448
  ), $total_items, $group->name, $text, $notification_link );
@@ -453,8 +596,32 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
453
  $notification_link = $group_link . '?n=1';
454
 
455
  if ( 'string' == $format ) {
456
- return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
 
457
  } else {
 
 
 
 
 
 
 
 
 
 
 
 
458
  return apply_filters( $filter, array(
459
  'link' => $notification_link,
460
  'text' => $text
@@ -469,29 +636,77 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
469
 
470
  $group = groups_get_group( array( 'group_id' => $group_id ) );
471
  $group_link = bp_get_group_permalink( $group );
 
472
 
473
  if ( (int) $total_items > 1 ) {
474
  $text = sprintf( __( '%d rejected group membership requests', 'buddypress' ), (int) $total_items, $group->name );
475
- $filter = 'bp_groups_multiple_membership_request_rejected_notification';
476
  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
477
 
478
  if ( 'string' == $format ) {
479
- return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name );
 
 
 
 
 
 
 
 
 
 
 
 
480
  } else {
481
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
482
  'link' => $notification_link,
483
  'text' => $text
484
  ), $total_items, $group->name, $text, $notification_link );
485
  }
486
  } else {
487
  $text = sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name );
488
- $filter = 'bp_groups_single_membership_request_rejected_notification';
489
  $notification_link = $group_link . '?n=1';
490
 
491
  if ( 'string' == $format ) {
492
- return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
 
493
  } else {
494
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
495
  'link' => $notification_link,
496
  'text' => $text
497
  ), $group_link, $group->name, $text, $notification_link );
@@ -505,29 +720,75 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
505
 
506
  $group = groups_get_group( array( 'group_id' => $group_id ) );
507
  $group_link = bp_get_group_permalink( $group );
 
508
 
509
  if ( (int) $total_items > 1 ) {
510
  $text = sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int) $total_items );
511
- $filter = 'bp_groups_multiple_member_promoted_to_admin_notification';
512
  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
513
 
514
  if ( 'string' == $format ) {
515
- return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
516
  } else {
517
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
518
  'link' => $notification_link,
519
  'text' => $text
520
  ), $total_items, $text, $notification_link );
521
  }
522
  } else {
523
  $text = sprintf( __( 'You were promoted to an admin in the group "%s"', 'buddypress' ), $group->name );
524
- $filter = 'bp_groups_single_member_promoted_to_admin_notification';
525
  $notification_link = $group_link . '?n=1';
526
 
527
  if ( 'string' == $format ) {
528
- return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
 
529
  } else {
530
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
531
  'link' => $notification_link,
532
  'text' => $text
533
  ), $group_link, $group->name, $text, $notification_link );
@@ -541,29 +802,75 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
541
 
542
  $group = groups_get_group( array( 'group_id' => $group_id ) );
543
  $group_link = bp_get_group_permalink( $group );
 
544
 
545
  if ( (int) $total_items > 1 ) {
546
  $text = sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int) $total_items );
547
- $filter = 'bp_groups_multiple_member_promoted_to_mod_notification';
548
  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
549
 
550
  if ( 'string' == $format ) {
551
- return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
552
  } else {
553
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
554
  'link' => $notification_link,
555
  'text' => $text
556
  ), $total_items, $text, $notification_link );
557
  }
558
  } else {
559
  $text = sprintf( __( 'You were promoted to a mod in the group "%s"', 'buddypress' ), $group->name );
560
- $filter = 'bp_groups_single_member_promoted_to_mod_notification';
561
  $notification_link = $group_link . '?n=1';
562
 
563
  if ( 'string' == $format ) {
564
- return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
 
565
  } else {
566
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
567
  'link' => $notification_link,
568
  'text' => $text
569
  ), $group_link, $group->name, $text, $notification_link );
@@ -576,17 +883,40 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
576
  $group_id = $item_id;
577
  $group = groups_get_group( array( 'group_id' => $group_id ) );
578
  $group_link = bp_get_group_permalink( $group );
 
579
 
580
  $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/?n=1';
581
 
582
  if ( (int) $total_items > 1 ) {
583
  $text = sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int) $total_items );
584
- $filter = 'bp_groups_multiple_group_invite_notification';
585
 
586
  if ( 'string' == $format ) {
587
- return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Group Invites', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
588
  } else {
589
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
590
  'link' => $notification_link,
591
  'text' => $text
592
  ), $total_items, $text, $notification_link );
@@ -596,9 +926,33 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
596
  $filter = 'bp_groups_single_group_invite_notification';
597
 
598
  if ( 'string' == $format ) {
599
- return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
 
 
 
 
 
 
 
 
 
 
 
 
600
  } else {
601
- return apply_filters( $filter, array(
 
 
 
 
 
 
 
 
 
 
 
 
602
  'link' => $notification_link,
603
  'text' => $text
604
  ), $group_link, $group->name, $text, $notification_link );
21
  * @since BuddyPress (1.0.0)
22
  *
23
  * @param int $group_id ID of the group.
24
+ * @param BP_Groups_Group $old_group Group before new details were saved.
25
  */
26
+ function groups_notification_group_updated( $group_id = 0, $old_group = null ) {
27
+
28
+ $group = groups_get_group( array( 'group_id' => $group_id ) );
29
+
30
+ if ( $old_group instanceof BP_Groups_Group ) {
31
+ $changed = array();
32
+
33
+ if ( $group->name !== $old_group->name ) {
34
+ $changed[] = sprintf(
35
+ _x( '* Name changed from "%s" to "%s"', 'Group update email text', 'buddypress' ),
36
+ esc_html( $old_group->name ),
37
+ esc_html( $group->name )
38
+ );
39
+ }
40
+
41
+ if ( $group->description !== $old_group->description ) {
42
+ $changed[] = sprintf(
43
+ _x( '* Description changed from "%s" to "%s"', 'Group update email text', 'buddypress' ),
44
+ esc_html( $old_group->description ),
45
+ esc_html( $group->description )
46
+ );
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Filters the bullet points listing updated items in the email notification after a group is updated.
52
+ *
53
+ * @since BuddyPress (2.2.0)
54
+ *
55
+ * @param array $changed Array of bullet points.
56
+ */
57
+ $changed = apply_filters( 'groups_notification_group_update_updated_items', $changed );
58
+
59
+ $changed_text = '';
60
+ if ( ! empty( $changed ) ) {
61
+ $changed_text = "\n\n" . implode( "\n", $changed );
62
+ }
63
 
 
64
  $subject = bp_get_email_subject( array( 'text' => __( 'Group Details Updated', 'buddypress' ) ) );
65
  $user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
66
 
81
  $settings_link = bp_core_get_user_domain( $user_id ) . $settings_slug . '/notifications/';
82
 
83
  $message = sprintf( __(
84
+ 'Group details for the group "%1$s" were updated: %2$s
85
 
86
+ To view the group: %3$s
87
 
88
  ---------------------
89
+ ', 'buddypress' ), $group->name, $changed_text, $group_link );
90
 
91
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
92
 
147
  // Link to the group administrator email settings: %s in "disable notifications" part of the email
148
  $settings_link = bp_core_get_user_domain( $admin_id ) . $settings_slug . '/notifications/';
149
 
150
+ // Fetch the message, if there's one to fetch.
151
+ $membership = new BP_Groups_Member( false, false, $membership_id );
152
+
153
  // Set up and send the message
154
  $to = $ud->user_email;
155
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ) ) );
156
 
157
+ if ( ! empty( $membership->comments ) ) {
158
+ $message = sprintf( __(
159
+ '%1$s wants to join the group "%2$s".
160
+
161
+ Message from %1$s: "%3$s"
162
+
163
+ Because you are the administrator of this group, you must either accept or reject the membership request.
164
+
165
+ To view all pending membership requests for this group, please visit:
166
+ %4$s
167
+
168
+ To view %5$s\'s profile: %6$s
169
+
170
+ ---------------------
171
+ ', 'buddypress' ), $requesting_user_name, $group->name, esc_html( $membership->comments ), $group_requests, $requesting_user_name, $profile_link );
172
+
173
+ } else {
174
+
175
+ $message = sprintf( __(
176
  '%1$s wants to join the group "%2$s".
177
 
178
  Because you are the administrator of this group, you must either accept or reject the membership request.
184
 
185
  ---------------------
186
  ', 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_link );
187
+ }
188
 
189
  // Only show the disable notifications line if the settings component is enabled
190
  if ( bp_is_active( 'settings' ) ) {
451
 
452
  $group = groups_get_group( array( 'group_id' => $group_id ) );
453
  $group_link = bp_get_group_permalink( $group );
454
+ $amount = 'single';
455
 
456
  // Set up the string and the filter
457
  // Because different values are passed to the filters, we'll return the
458
  // values inline
459
  if ( (int) $total_items > 1 ) {
460
  $text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name );
461
+ $amount = 'multiple';
462
  $notification_link = $group_link . 'admin/membership-requests/?n=1';
463
 
464
  if ( 'string' == $format ) {
465
+ /**
466
+ * Filters groups multiple new membership request notification for string format.
467
+ *
468
+ * This is a dynamic filter that is dependent on item count and action.
469
+ * Complete filter - bp_groups_multiple_new_membership_requests_notification.
470
+ *
471
+ * @since BuddyPress (1.0.0)
472
+ *
473
+ * @param string $string HTML anchor tag for request.
474
+ * @param string $group_link The permalink for the group.
475
+ * @param int $total_items Total number of membership requests.
476
+ * @param string $group->name Name of the group.
477
+ * @param string $text Notification content.
478
+ * @param string $notification_link The permalink for notification.
479
+ */
480
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . 's_notification', '<a href="' . $notification_link . '" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . $text . '</a>', $group_link, $total_items, $group->name, $text, $notification_link );
481
  } else {
482
+ /**
483
+ * Filters groups multiple new membership request notification for any non-string format.
484
+ *
485
+ * This is a dynamic filter that is dependent on item count and action.
486
+ * Complete filter - bp_groups_multiple_new_membership_requests_notification.
487
+ *
488
+ * @since BuddyPress (1.0.0)
489
+ *
490
+ * @param array $array Array holding permalink and content for notification.
491
+ * @param string $group_link The permalink for the group.
492
+ * @param int $total_items Total number of membership requests.
493
+ * @param string $group->name Name of the group.
494
+ * @param string $text Notification content.
495
+ * @param string $notification_link The permalink for notification.
496
+ */
497
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . 's_notification', array(
498
  'link' => $notification_link,
499
  'text' => $text
500
  ), $group_link, $total_items, $group->name, $text, $notification_link );
502
  } else {
503
  $user_fullname = bp_core_get_user_displayname( $requesting_user_id );
504
  $text = sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname );
 
505
  $notification_link = $group_link . 'admin/membership-requests/?n=1';
506
 
507
  if ( 'string' == $format ) {
508
+ /**
509
+ * Filters groups single new membership request notification for string format.
510
+ *
511
+ * This is a dynamic filter that is dependent on item count and action.
512
+ * Complete filter - bp_groups_single_new_membership_request_notification.
513
+ *
514
+ * @since BuddyPress (1.0.0)
515
+ *
516
+ * @param string $string HTML anchor tag for request.
517
+ * @param string $group_link The permalink for the group.
518
+ * @param string $user_fullname Full name of requesting user.
519
+ * @param string $group->name Name of the group.
520
+ * @param string $text Notification content.
521
+ * @param string $notification_link The permalink for notification.
522
+ */
523
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . $text . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link );
524
  } else {
525
+ /**
526
+ * Filters groups single new membership request notification for any non-string format.
527
+ *
528
+ * This is a dynamic filter that is dependent on item count and action.
529
+ * Complete filter - bp_groups_single_new_membership_request_notification.
530
+ *
531
+ * @since BuddyPress (1.0.0)
532
+ *
533
+ * @param array $array Array holding permalink and content for notification.
534
+ * @param string $group_link The permalink for the group.
535
+ * @param string $user_fullname Full name of requesting user.
536
+ * @param string $group->name Name of the group.
537
+ * @param string $text Notification content.
538
+ * @param string $notification_link The permalink for notification.
539
+ */
540
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
541
  'link' => $notification_link,
542
  'text' => $text
543
  ), $group_link, $user_fullname, $group->name, $text, $notification_link );
551
 
552
  $group = groups_get_group( array( 'group_id' => $group_id ) );
553
  $group_link = bp_get_group_permalink( $group );
554
+ $amount = 'single';
555
 
556
  if ( (int) $total_items > 1 ) {
557
  $text = sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int) $total_items, $group->name );
558
+ $amount = 'multiple';
559
  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
560
 
561
  if ( 'string' == $format ) {
562
+ /**
563
+ * Filters multiple accepted group membership requests notification for string format.
564
+ * Complete filter - bp_groups_multiple_membership_request_accepted_notification.
565
+ *
566
+ * @since BuddyPress (1.0.0)
567
+ *
568
+ * @param string $string HTML anchor tag for notification.
569
+ * @param int $total_items Total number of accepted requests.
570
+ * @param string $group->name Name of the group.
571
+ * @param string $text Notification content.
572
+ * @param string $notification_link The permalink for notification.
573
+ */
574
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name, $text, $notification_link );
575
  } else {
576
+ /**
577
+ * Filters multiple accepted group membership requests notification for non-string format.
578
+ * Complete filter - bp_groups_multiple_membership_request_accepted_notification.
579
+ *
580
+ * @since BuddyPress (1.0.0)
581
+ *
582
+ * @param array $array Array holding permalink and content for notification
583
+ * @param int $total_items Total number of accepted requests.
584
+ * @param string $group->name Name of the group.
585
+ * @param string $text Notification content.
586
+ * @param string $notification_link The permalink for notification.
587
+ */
588
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
589
  'link' => $notification_link,
590
  'text' => $text
591
  ), $total_items, $group->name, $text, $notification_link );
596
  $notification_link = $group_link . '?n=1';
597
 
598
  if ( 'string' == $format ) {
599
+ /**
600
+ * Filters single accepted group membership request notification for string format.
601
+ * Complete filter - bp_groups_single_membership_request_accepted_notification.
602
+ *
603
+ * @since BuddyPress (1.0.0)
604
+ *
605
+ * @param string $string HTML anchor tag for notification.
606
+ * @param string $group_link The permalink for the group.
607
+ * @param string $group->name Name of the group.
608
+ * @param string $text Notification content.
609
+ * @param string $notification_link The permalink for notification.
610
+ */
611
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
612
  } else {
613
+ /**
614
+ * Filters single accepted group membership request notification for non-string format.
615
+ * Complete filter - bp_groups_single_membership_request_accepted_notification.
616
+ *
617
+ * @since BuddyPress (1.0.0)
618
+ *
619
+ * @param array $array Array holding permalink and content for notification.
620
+ * @param string $group_link The permalink for the group.
621
+ * @param string $group->name Name of the group.
622
+ * @param string $text Notification content.
623
+ * @param string $notification_link The permalink for notification.
624
+ */
625
  return apply_filters( $filter, array(
626
  'link' => $notification_link,
627
  'text' => $text
636
 
637
  $group = groups_get_group( array( 'group_id' => $group_id ) );
638
  $group_link = bp_get_group_permalink( $group );
639
+ $amount = 'single';
640
 
641
  if ( (int) $total_items > 1 ) {
642
  $text = sprintf( __( '%d rejected group membership requests', 'buddypress' ), (int) $total_items, $group->name );
643
+ $amount = 'multiple';
644
  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
645
 
646
  if ( 'string' == $format ) {
647
+ /**
648
+ * Filters multiple rejected group membership requests notification for string format.
649
+ * Complete filter - bp_groups_multiple_membership_request_rejected_notification.
650
+ *
651
+ * @since BuddyPress (1.0.0)
652
+ *
653
+ * @param string $string HTML anchor tag for notification.
654
+ * @param int $total_items Total number of rejected requests.
655
+ * @param string $group->name Name of the group.
656
+ * @param string $text Notification content.
657
+ * @param string $notification_link The permalink for notification.
658
+ */
659
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name );
660
  } else {
661
+ /**
662
+ * Filters multiple rejected group membership requests notification for non-string format.
663
+ * Complete filter - bp_groups_multiple_membership_request_rejected_notification.
664
+ *
665
+ * @since BuddyPress (1.0.0)
666
+ *
667
+ * @param array $array Array holding permalink and content for notification.
668
+ * @param int $total_items Total number of rejected requests.
669
+ * @param string $group->name Name of the group.
670
+ * @param string $text Notification content.
671
+ * @param string $notification_link The permalink for notification.
672
+ */
673
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
674
  'link' => $notification_link,
675
  'text' => $text
676
  ), $total_items, $group->name, $text, $notification_link );
677
  }
678
  } else {
679
  $text = sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name );
 
680
  $notification_link = $group_link . '?n=1';
681
 
682
  if ( 'string' == $format ) {
683
+ /**
684
+ * Filters single rejected group membership requests notification for string format.
685
+ * Complete filter - bp_groups_single_membership_request_rejected_notification.
686
+ *
687
+ * @since BuddyPress (1.0.0)
688
+ *
689
+ * @param string $string HTML anchor tag for notification.
690
+ * @param int $group_link The permalink for the group.
691
+ * @param string $group->name Name of the group.
692
+ * @param string $text Notification content.
693
+ * @param string $notification_link The permalink for notification.
694
+ */
695
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
696
  } else {
697
+ /**
698
+ * Filters single rejected group membership requests notification for non-string format.
699
+ * Complete filter - bp_groups_single_membership_request_rejected_notification.
700
+ *
701
+ * @since BuddyPress (1.0.0)
702
+ *
703
+ * @param array $array Array holding permalink and content for notification.
704
+ * @param int $group_link The permalink for the group.
705
+ * @param string $group->name Name of the group.
706
+ * @param string $text Notification content.
707
+ * @param string $notification_link The permalink for notification.
708
+ */
709
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
710
  'link' => $notification_link,
711
  'text' => $text
712
  ), $group_link, $group->name, $text, $notification_link );
720
 
721
  $group = groups_get_group( array( 'group_id' => $group_id ) );
722
  $group_link = bp_get_group_permalink( $group );
723
+ $amount = 'single';
724
 
725
  if ( (int) $total_items > 1 ) {
726
  $text = sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int) $total_items );
727
+ $amount = 'multiple';
728
  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
729
 
730
  if ( 'string' == $format ) {
731
+ /**
732
+ * Filters multiple promoted to group admin notification for string format.
733
+ * Complete filter - bp_groups_multiple_member_promoted_to_admin_notification.
734
+ *
735
+ * @since BuddyPress (1.0.0)
736
+ *
737
+ * @param string $string HTML anchor tag for notification.
738
+ * @param int $total_items Total number of rejected requests.
739
+ * @param string $text Notification content.
740
+ * @param string $notification_link The permalink for notification.
741
+ */
742
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
743
  } else {
744
+ /**
745
+ * Filters multiple promoted to group admin notification for non-string format.
746
+ * Complete filter - bp_groups_multiple_member_promoted_to_admin_notification.
747
+ *
748
+ * @since BuddyPress (1.0.0)
749
+ *
750
+ * @param array $array Array holding permalink and content for notification.
751
+ * @param int $total_items Total number of rejected requests.
752
+ * @param string $text Notification content.
753
+ * @param string $notification_link The permalink for notification.
754
+ */
755
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
756
  'link' => $notification_link,
757
  'text' => $text
758
  ), $total_items, $text, $notification_link );
759
  }
760
  } else {
761
  $text = sprintf( __( 'You were promoted to an admin in the group "%s"', 'buddypress' ), $group->name );
 
762
  $notification_link = $group_link . '?n=1';
763
 
764
  if ( 'string' == $format ) {
765
+ /**
766
+ * Filters single promoted to group admin notification for non-string format.
767
+ * Complete filter - bp_groups_single_member_promoted_to_admin_notification.
768
+ *
769
+ * @since BuddyPress (1.0.0)
770
+ *
771
+ * @param string $string HTML anchor tag for notification.
772
+ * @param int $group_link The permalink for the group.
773
+ * @param string $group->name Name of the group.
774
+ * @param string $text Notification content.
775
+ * @param string $notification_link The permalink for notification.
776
+ */
777
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
778
  } else {
779
+ /**
780
+ * Filters single promoted to group admin notification for non-string format.
781
+ * Complete filter - bp_groups_single_member_promoted_to_admin_notification.
782
+ *
783
+ * @since BuddyPress (1.0.0)
784
+ *
785
+ * @param array $array Array holding permalink and content for notification.
786
+ * @param int $group_link The permalink for the group.
787
+ * @param string $group->name Name of the group.
788
+ * @param string $text Notification content.
789
+ * @param string $notification_link The permalink for notification.
790
+ */
791
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
792
  'link' => $notification_link,
793
  'text' => $text
794
  ), $group_link, $group->name, $text, $notification_link );
802
 
803
  $group = groups_get_group( array( 'group_id' => $group_id ) );
804
  $group_link = bp_get_group_permalink( $group );
805
+ $amount = 'single';
806
 
807
  if ( (int) $total_items > 1 ) {
808
  $text = sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int) $total_items );
809
+ $amount = 'multiple';
810
  $notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
811
 
812
  if ( 'string' == $format ) {
813
+ /**
814
+ * Filters multiple promoted to group mod notification for string format.
815
+ * Complete filter - bp_groups_multiple_member_promoted_to_mod_notification.
816
+ *
817
+ * @since BuddyPress (1.0.0)
818
+ *
819
+ * @param string $string HTML anchor tag for notification.
820
+ * @param int $total_items Total number of rejected requests.
821
+ * @param string $text Notification content.
822
+ * @param string $notification_link The permalink for notification.
823
+ */
824
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
825
  } else {
826
+ /**
827
+ * Filters multiple promoted to group mod notification for non-string format.
828
+ * Complete filter - bp_groups_multiple_member_promoted_to_mod_notification.
829
+ *
830
+ * @since 1.0.0
831
+ *
832
+ * @param array $array Array holding permalink and content for notification.
833
+ * @param int $total_items Total number of rejected requests.
834
+ * @param string $text Notification content.
835
+ * @param string $notification_link The permalink for notification.
836
+ */
837
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
838
  'link' => $notification_link,
839
  'text' => $text
840
  ), $total_items, $text, $notification_link );
841
  }
842
  } else {
843
  $text = sprintf( __( 'You were promoted to a mod in the group "%s"', 'buddypress' ), $group->name );
 
844
  $notification_link = $group_link . '?n=1';
845
 
846
  if ( 'string' == $format ) {
847
+ /**
848
+ * Filters single promoted to group mod notification for string format.
849
+ * Complete filter - bp_groups_single_member_promoted_to_mod_notification.
850
+ *
851
+ * @since BuddyPress (1.0.0)
852
+ *
853
+ * @param string $string HTML anchor tag for notification.
854
+ * @param int $group_link The permalink for the group.
855
+ * @param string $group->name Name of the group.
856
+ * @param string $text Notification content.
857
+ * @param string $notification_link The permalink for notification.
858
+ */
859
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
860
  } else {
861
+ /**
862
+ * Filters single promoted to group admin notification for non-string format.
863
+ * Complete filter - bp_groups_single_member_promoted_to_mod_notification.
864
+ *
865
+ * @since BuddyPress (1.0.0)
866
+ *
867
+ * @param array $array Array holding permalink and content for notification.
868
+ * @param int $group_link The permalink for the group.
869
+ * @param string $group->name Name of the group.
870
+ * @param string $text Notification content.
871
+ * @param string $notification_link The permalink for notification.
872
+ */
873
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
874
  'link' => $notification_link,
875
  'text' => $text
876
  ), $group_link, $group->name, $text, $notification_link );
883
  $group_id = $item_id;
884
  $group = groups_get_group( array( 'group_id' => $group_id ) );
885
  $group_link = bp_get_group_permalink( $group );
886
+ $amount = 'single';
887
 
888
  $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/?n=1';
889
 
890
  if ( (int) $total_items > 1 ) {
891
  $text = sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int) $total_items );
892
+ $amount = 'multiple';
893
 
894
  if ( 'string' == $format ) {
895
+ /**
896
+ * Filters multiple group invitation notification for string format.
897
+ * Complete filter - bp_groups_multiple_group_invite_notification.
898
+ *
899
+ * @since BuddyPress (1.0.0)
900
+ *
901
+ * @param string $string HTML anchor tag for notification.
902
+ * @param int $total_items Total number of rejected requests.
903
+ * @param string $text Notification content.
904
+ * @param string $notification_link The permalink for notification.
905
+ */
906
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '" title="' . __( 'Group Invites', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
907
  } else {
908
+ /**
909
+ * Filters multiple group invitation notification for non-string format.
910
+ * Complete filter - bp_groups_multiple_group_invite_notification.
911
+ *
912
+ * @since BuddyPress (1.0.0)
913
+ *
914
+ * @param array $array Array holding permalink and content for notification.
915
+ * @param int $total_items Total number of rejected requests.
916
+ * @param string $text Notification content.
917
+ * @param string $notification_link The permalink for notification.
918
+ */
919
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
920
  'link' => $notification_link,
921
  'text' => $text
922
  ), $total_items, $text, $notification_link );
926
  $filter = 'bp_groups_single_group_invite_notification';
927
 
928
  if ( 'string' == $format ) {
929
+ /**
930
+ * Filters single group invitation notification for string format.
931
+ * Complete filter - bp_groups_single_group_invite_notification.
932
+ *
933
+ * @since BuddyPress (1.0.0)
934
+ *
935
+ * @param string $string HTML anchor tag for notification.
936
+ * @param int $group_link The permalink for the group.
937
+ * @param string $group->name Name of the group.
938
+ * @param string $text Notification content.
939
+ * @param string $notification_link The permalink for notification.
940
+ */
941
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
942
  } else {
943
+ /**
944
+ * Filters single group invitation notification for non-string format.
945
+ * Complete filter - bp_groups_single_group_invite_notification.
946
+ *
947
+ * @since BuddyPress (1.0.0)
948
+ *
949
+ * @param array $array Array holding permalink and content for notification.
950
+ * @param int $group_link The permalink for the group.
951
+ * @param string $group->name Name of the group.
952
+ * @param string $text Notification content.
953
+ * @param string $notification_link The permalink for notification.
954
+ */
955
+ return apply_filters( 'bp_groups_' . $amount . '_' . $action . '_notification', array(
956
  'link' => $notification_link,
957
  'text' => $text
958
  ), $group_link, $group->name, $text, $notification_link );
bp-groups/bp-groups-screens.php CHANGED
@@ -71,7 +71,7 @@ function groups_screen_group_invites() {
71
 
72
  bp_core_redirect( $redirect_to );
73
 
74
- } else if ( bp_is_action_variable( 'reject' ) && is_numeric( $group_id ) ) {
75
  // Check the nonce
76
  if ( !check_admin_referer( 'groups_reject_invite' ) )
77
  return false;
@@ -179,7 +179,7 @@ function groups_screen_group_forum() {
179
  }
180
 
181
  // Sticky a topic
182
- else if ( bp_is_action_variable( 'stick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
183
  // Check the nonce
184
  check_admin_referer( 'bp_forums_stick_topic' );
185
 
@@ -194,7 +194,7 @@ function groups_screen_group_forum() {
194
  }
195
 
196
  // Un-Sticky a topic
197
- else if ( bp_is_action_variable( 'unstick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
198
  // Check the nonce
199
  check_admin_referer( 'bp_forums_unstick_topic' );
200
 
@@ -209,7 +209,7 @@ function groups_screen_group_forum() {
209
  }
210
 
211
  // Close a topic
212
- else if ( bp_is_action_variable( 'close', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
213
  // Check the nonce
214
  check_admin_referer( 'bp_forums_close_topic' );
215
 
@@ -224,7 +224,7 @@ function groups_screen_group_forum() {
224
  }
225
 
226
  // Open a topic
227
- else if ( bp_is_action_variable( 'open', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
228
  // Check the nonce
229
  check_admin_referer( 'bp_forums_open_topic' );
230
 
@@ -239,7 +239,7 @@ function groups_screen_group_forum() {
239
  }
240
 
241
  // Delete a topic
242
- else if ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && !bp_action_variable( 3 ) ) {
243
  // Fetch the topic
244
  $topic = bp_forums_get_topic_details( $topic_id );
245
 
@@ -264,7 +264,7 @@ function groups_screen_group_forum() {
264
  }
265
 
266
  // Editing a topic
267
- else if ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && !bp_action_variable( 3 ) ) {
268
  // Fetch the topic
269
  $topic = bp_forums_get_topic_details( $topic_id );
270
 
@@ -292,7 +292,7 @@ function groups_screen_group_forum() {
292
  bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );
293
 
294
  // Delete a post
295
- } else if ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && $post_id = bp_action_variable( 4 ) ) {
296
  // Fetch the post
297
  $post = bp_forums_get_post( $post_id );
298
 
@@ -316,7 +316,7 @@ function groups_screen_group_forum() {
316
  bp_core_redirect( wp_get_referer() );
317
 
318
  // Editing a post
319
- } else if ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && $post_id = bp_action_variable( 4 ) ) {
320
 
321
  // Fetch the post
322
  $post = bp_forums_get_post( $post_id );
@@ -379,7 +379,7 @@ function groups_screen_group_forum() {
379
 
380
  if ( empty( $_POST['topic_title'] ) ) {
381
  $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );
382
- } else if ( empty( $_POST['topic_text'] ) ) {
383
  $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );
384
  }
385
 
@@ -492,10 +492,10 @@ function groups_remove_group_invite() {
492
  if ( ! bp_groups_user_can_send_invites( $group_id ) ) {
493
  $message = __( 'You are not allowed to send or remove invites', 'buddypress' );
494
  $error = 'error';
495
- } else if ( BP_Groups_Member::check_for_membership_request( $friend_id, $group_id ) ) {
496
  $message = __( 'The member requested to join the group', 'buddypress' );
497
  $error = 'error';
498
- } else if ( ! groups_uninvite_user( $friend_id, $group_id ) ) {
499
  $message = __( 'There was an error removing the invite', 'buddypress' );
500
  $error = 'error';
501
  }
@@ -524,7 +524,7 @@ function groups_screen_group_request_membership() {
524
  if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
525
  bp_core_add_message( __( 'Group invite accepted', 'buddypress' ) );
526
  else
527
- bp_core_add_message( __( 'There was an error accepting the group invitation; please try again.', 'buddypress' ), 'error' );
528
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
529
  }
530
 
@@ -536,7 +536,7 @@ function groups_screen_group_request_membership() {
536
  return false;
537
 
538
  if ( !groups_send_membership_request( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
539
- bp_core_add_message( __( 'There was an error sending your group membership request; please try again.', 'buddypress' ), 'error' );
540
  } else {
541
  bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
542
  }
@@ -596,7 +596,7 @@ function groups_screen_group_admin_edit_details() {
596
  $group_notify_members = isset( $_POST['group-notify-members'] ) ? (int) $_POST['group-notify-members'] : 0;
597
 
598
  if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $group_notify_members ) ) {
599
- bp_core_add_message( __( 'There was an error updating group details; please try again.', 'buddypress' ), 'error' );
600
  } else {
601
  bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
602
  }
@@ -643,7 +643,7 @@ function groups_screen_group_admin_settings() {
643
  return false;
644
 
645
  if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status, $invite_status ) ) {
646
- bp_core_add_message( __( 'There was an error updating group settings; please try again.', 'buddypress' ), 'error' );
647
  } else {
648
  bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) );
649
  }
@@ -682,7 +682,7 @@ function groups_screen_group_admin_avatar() {
682
  if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) ) {
683
  bp_core_add_message( __( 'The group profile photo was deleted successfully!', 'buddypress' ) );
684
  } else {
685
- bp_core_add_message( __( 'There was a problem deleting the group profile photo; please try again.', 'buddypress' ), 'error' );
686
  }
687
  }
688
 
@@ -761,7 +761,7 @@ function groups_screen_group_admin_manage_members() {
761
 
762
  // Promote a user.
763
  if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) )
764
- bp_core_add_message( __( 'There was an error when promoting that user, please try again', 'buddypress' ), 'error' );
765
  else
766
  bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
767
 
@@ -786,7 +786,7 @@ function groups_screen_group_admin_manage_members() {
786
 
787
  // Demote a user.
788
  elseif ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
789
- bp_core_add_message( __( 'There was an error when demoting that user; please try again', 'buddypress' ), 'error' );
790
  else
791
  bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
792
 
@@ -804,7 +804,7 @@ function groups_screen_group_admin_manage_members() {
804
 
805
  // Ban a user.
806
  if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) )
807
- bp_core_add_message( __( 'There was an error when banning that user; please try again', 'buddypress' ), 'error' );
808
  else
809
  bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
810
 
@@ -822,7 +822,7 @@ function groups_screen_group_admin_manage_members() {
822
 
823
  // Remove a ban for user.
824
  if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) )
825
- bp_core_add_message( __( 'There was an error when unbanning that user, please try again', 'buddypress' ), 'error' );
826
  else
827
  bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) );
828
 
@@ -840,7 +840,7 @@ function groups_screen_group_admin_manage_members() {
840
 
841
  // Remove a user.
842
  if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) )
843
- bp_core_add_message( __( 'There was an error removing that user from the group; please try again', 'buddypress' ), 'error' );
844
  else
845
  bp_core_add_message( __( 'User removed successfully', 'buddypress' ) );
846
 
@@ -882,7 +882,7 @@ function groups_screen_group_admin_requests() {
882
 
883
  // Accept the membership request
884
  if ( !groups_accept_membership_request( $membership_id ) )
885
- bp_core_add_message( __( 'There was an error accepting the membership request; please try again.', 'buddypress' ), 'error' );
886
  else
887
  bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) );
888
 
@@ -893,7 +893,7 @@ function groups_screen_group_admin_requests() {
893
 
894
  // Reject the membership request
895
  if ( !groups_reject_membership_request( $membership_id ) )
896
- bp_core_add_message( __( 'There was an error rejecting the membership request; please try again.', 'buddypress' ), 'error' );
897
  else
898
  bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
899
  }
@@ -930,7 +930,7 @@ function groups_screen_group_admin_delete_group() {
930
 
931
  // Group admin has deleted the group, now do it.
932
  if ( !groups_delete_group( $bp->groups->current_group->id ) ) {
933
- bp_core_add_message( __( 'There was an error deleting the group; please try again.', 'buddypress' ), 'error' );
934
  } else {
935
  bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
936
 
@@ -1010,12 +1010,12 @@ function groups_screen_notification_settings() {
1010
  }
1011
  add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
1012
 
1013
- /** Theme Compatability *******************************************************/
1014
 
1015
  /**
1016
  * The main theme compat class for BuddyPress Groups.
1017
  *
1018
- * This class sets up the necessary theme compatability actions to safely output
1019
  * group template parts to the_title and the_content areas of a theme.
1020
  *
1021
  * @since BuddyPress (1.7.0)
@@ -1032,7 +1032,7 @@ class BP_Groups_Theme_Compat {
1032
  }
1033
 
1034
  /**
1035
- * Are we looking at something that needs group theme compatability?
1036
  *
1037
  * @since BuddyPress (1.7.0)
1038
  */
@@ -1099,12 +1099,9 @@ class BP_Groups_Theme_Compat {
1099
  * @since BuddyPress (1.7.0)
1100
  */
1101
  public function directory_dummy_post() {
1102
-
1103
- $title = apply_filters( 'bp_groups_directory_header', bp_get_directory_title( 'groups' ) );
1104
-
1105
  bp_theme_compat_reset_post( array(
1106
  'ID' => 0,
1107
- 'post_title' => $title,
1108
  'post_author' => 0,
1109
  'post_date' => 0,
1110
  'post_content' => '',
@@ -1222,7 +1219,7 @@ class BP_Groups_Theme_Compat {
1222
  public function single_dummy_post() {
1223
  bp_theme_compat_reset_post( array(
1224
  'ID' => 0,
1225
- 'post_title' => '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . bp_get_current_group_name() . '</a>',
1226
  'post_author' => 0,
1227
  'post_date' => 0,
1228
  'post_content' => '',
71
 
72
  bp_core_redirect( $redirect_to );
73
 
74
+ } elseif ( bp_is_action_variable( 'reject' ) && is_numeric( $group_id ) ) {
75
  // Check the nonce
76
  if ( !check_admin_referer( 'groups_reject_invite' ) )
77
  return false;
179
  }
180
 
181
  // Sticky a topic
182
+ elseif ( bp_is_action_variable( 'stick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
183
  // Check the nonce
184
  check_admin_referer( 'bp_forums_stick_topic' );
185
 
194
  }
195
 
196
  // Un-Sticky a topic
197
+ elseif ( bp_is_action_variable( 'unstick', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
198
  // Check the nonce
199
  check_admin_referer( 'bp_forums_unstick_topic' );
200
 
209
  }
210
 
211
  // Close a topic
212
+ elseif ( bp_is_action_variable( 'close', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
213
  // Check the nonce
214
  check_admin_referer( 'bp_forums_close_topic' );
215
 
224
  }
225
 
226
  // Open a topic
227
+ elseif ( bp_is_action_variable( 'open', 2 ) && ( bp_is_item_admin() || bp_is_item_mod() ) ) {
228
  // Check the nonce
229
  check_admin_referer( 'bp_forums_open_topic' );
230
 
239
  }
240
 
241
  // Delete a topic
242
+ elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && !bp_action_variable( 3 ) ) {
243
  // Fetch the topic
244
  $topic = bp_forums_get_topic_details( $topic_id );
245
 
264
  }
265
 
266
  // Editing a topic
267
+ elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && !bp_action_variable( 3 ) ) {
268
  // Fetch the topic
269
  $topic = bp_forums_get_topic_details( $topic_id );
270
 
292
  bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );
293
 
294
  // Delete a post
295
+ } elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'delete', 2 ) && $post_id = bp_action_variable( 4 ) ) {
296
  // Fetch the post
297
  $post = bp_forums_get_post( $post_id );
298
 
316
  bp_core_redirect( wp_get_referer() );
317
 
318
  // Editing a post
319
+ } elseif ( empty( $user_is_banned ) && bp_is_action_variable( 'edit', 2 ) && $post_id = bp_action_variable( 4 ) ) {
320
 
321
  // Fetch the post
322
  $post = bp_forums_get_post( $post_id );
379
 
380
  if ( empty( $_POST['topic_title'] ) ) {
381
  $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );
382
+ } elseif ( empty( $_POST['topic_text'] ) ) {
383
  $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );
384
  }
385
 
492
  if ( ! bp_groups_user_can_send_invites( $group_id ) ) {
493
  $message = __( 'You are not allowed to send or remove invites', 'buddypress' );
494
  $error = 'error';
495
+ } elseif ( BP_Groups_Member::check_for_membership_request( $friend_id, $group_id ) ) {
496
  $message = __( 'The member requested to join the group', 'buddypress' );
497
  $error = 'error';
498
+ } elseif ( ! groups_uninvite_user( $friend_id, $group_id ) ) {
499
  $message = __( 'There was an error removing the invite', 'buddypress' );
500
  $error = 'error';
501
  }
524
  if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
525
  bp_core_add_message( __( 'Group invite accepted', 'buddypress' ) );
526
  else
527
+ bp_core_add_message( __( 'There was an error accepting the group invitation. Please try again.', 'buddypress' ), 'error' );
528
  bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
529
  }
530
 
536
  return false;
537
 
538
  if ( !groups_send_membership_request( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
539
+ bp_core_add_message( __( 'There was an error sending your group membership request. Please try again.', 'buddypress' ), 'error' );
540
  } else {
541
  bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
542
  }
596
  $group_notify_members = isset( $_POST['group-notify-members'] ) ? (int) $_POST['group-notify-members'] : 0;
597
 
598
  if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $group_notify_members ) ) {
599
+ bp_core_add_message( __( 'There was an error updating group details. Please try again.', 'buddypress' ), 'error' );
600
  } else {
601
  bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
602
  }
643
  return false;
644
 
645
  if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status, $invite_status ) ) {
646
+ bp_core_add_message( __( 'There was an error updating group settings. Please try again.', 'buddypress' ), 'error' );
647
  } else {
648
  bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) );
649
  }
682
  if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) ) {
683
  bp_core_add_message( __( 'The group profile photo was deleted successfully!', 'buddypress' ) );
684
  } else {
685
+ bp_core_add_message( __( 'There was a problem deleting the group profile photo. Please try again.', 'buddypress' ), 'error' );
686
  }
687
  }
688
 
761
 
762
  // Promote a user.
763
  if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) )
764
+ bp_core_add_message( __( 'There was an error when promoting that user. Please try again.', 'buddypress' ), 'error' );
765
  else
766
  bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
767
 
786
 
787
  // Demote a user.
788
  elseif ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
789
+ bp_core_add_message( __( 'There was an error when demoting that user. Please try again.', 'buddypress' ), 'error' );
790
  else
791
  bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
792
 
804
 
805
  // Ban a user.
806
  if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) )
807
+ bp_core_add_message( __( 'There was an error when banning that user. Please try again.', 'buddypress' ), 'error' );
808
  else
809
  bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
810
 
822
 
823
  // Remove a ban for user.
824
  if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) )
825
+ bp_core_add_message( __( 'There was an error when unbanning that user. Please try again.', 'buddypress' ), 'error' );
826
  else
827
  bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) );
828
 
840
 
841
  // Remove a user.
842
  if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) )
843
+ bp_core_add_message( __( 'There was an error removing that user from the group. Please try again.', 'buddypress' ), 'error' );
844
  else
845
  bp_core_add_message( __( 'User removed successfully', 'buddypress' ) );
846
 
882
 
883
  // Accept the membership request
884
  if ( !groups_accept_membership_request( $membership_id ) )
885
+ bp_core_add_message( __( 'There was an error accepting the membership request. Please try again.', 'buddypress' ), 'error' );
886
  else
887
  bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) );
888
 
893
 
894
  // Reject the membership request
895
  if ( !groups_reject_membership_request( $membership_id ) )
896
+ bp_core_add_message( __( 'There was an error rejecting the membership request. Please try again.', 'buddypress' ), 'error' );
897
  else
898
  bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
899
  }
930
 
931
  // Group admin has deleted the group, now do it.
932
  if ( !groups_delete_group( $bp->groups->current_group->id ) ) {
933
+ bp_core_add_message( __( 'There was an error deleting the group. Please try again.', 'buddypress' ), 'error' );
934
  } else {
935
  bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
936
 
1010
  }
1011
  add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
1012
 
1013
+ /** Theme Compatibility *******************************************************/
1014
 
1015
  /**
1016
  * The main theme compat class for BuddyPress Groups.
1017
  *
1018
+ * This class sets up the necessary theme compatibility actions to safely output
1019
  * group template parts to the_title and the_content areas of a theme.
1020
  *
1021
  * @since BuddyPress (1.7.0)
1032
  }
1033
 
1034
  /**
1035
+ * Are we looking at something that needs group theme compatibility?
1036
  *
1037
  * @since BuddyPress (1.7.0)
1038
  */
1099
  * @since BuddyPress (1.7.0)
1100
  */
1101
  public function directory_dummy_post() {
 
 
 
1102
  bp_theme_compat_reset_post( array(
1103
  'ID' => 0,
1104
+ 'post_title' => bp_get_directory_title( 'groups' ),
1105
  'post_author' => 0,
1106
  'post_date' => 0,
1107
  'post_content' => '',
1219
  public function single_dummy_post() {
1220
  bp_theme_compat_reset_post( array(
1221
  'ID' => 0,
1222
+ 'post_title' => bp_get_current_group_name(),
1223
  'post_author' => 0,
1224
  'post_date' => 0,
1225
  'post_content' => '',
bp-groups/bp-groups-template.php CHANGED
@@ -233,7 +233,7 @@ class BP_Groups_Template {
233
 
234
  if ( 'invites' == $type ) {
235
  $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page, $exclude );
236
- } else if ( 'single-group' == $type ) {
237
  $this->single_group = true;
238
 
239
  if ( groups_get_current_group() ) {
@@ -279,7 +279,7 @@ class BP_Groups_Template {
279
  $this->total_group_count = (int) $this->groups['total'];
280
  $this->group_count = (int) $this->groups['total'];
281
  $this->groups = $this->groups['groups'];
282
- } else if ( 'single-group' == $type ) {
283
  if ( empty( $group->id ) ) {
284
  $this->total_group_count = 0;
285
  $this->group_count = 0;
@@ -310,10 +310,7 @@ class BP_Groups_Template {
310
  // Build pagination links
311
  if ( (int) $this->total_group_count && (int) $this->pag_num ) {
312
  $pag_args = array(
313
- $page_arg => '%#%',
314
- 'num' => $this->pag_num,
315
- 'sortby' => $this->sort_by,
316
- 'order' => $this->order,
317
  );
318
 
319
  if ( defined( 'DOING_AJAX' ) && true === (bool) DOING_AJAX ) {
@@ -322,8 +319,14 @@ class BP_Groups_Template {
322
  $base = '';
323
  }
324
 
 
 
 
 
 
 
325
  if ( ! empty( $search_terms ) ) {
326
- $pag_args['s'] = $search_terms;
327
  }
328
 
329
  $this->pag_links = paginate_links( array(
@@ -333,7 +336,8 @@ class BP_Groups_Template {
333
  'current' => $this->pag_page,
334
  'prev_text' => _x( '&larr;', 'Group pagination previous text', 'buddypress' ),
335
  'next_text' => _x( '&rarr;', 'Group pagination next text', 'buddypress' ),
336
- 'mid_size' => 1
 
337
  ) );
338
  }
339
  }
@@ -423,35 +427,35 @@ class BP_Groups_Template {
423
  *
424
  * @param array $args {
425
  * Array of parameters. All items are optional.
426
- * @type string $type Optional. Shorthand for certain orderby/
427
  * order combinations. 'newest', 'active', 'popular',
428
  * 'alphabetical', 'random'. When present, will override
429
  * orderby and order params. Default: null.
430
- * @type string $orderby Optional. Property to sort by.
431
  * 'date_created', 'last_activity', 'total_member_count',
432
  * 'name', 'random'. Default: 'date_created'.
433
- * @type string $order Optional. Sort order. 'ASC' or 'DESC'.
434
  * Default: 'DESC'.
435
- * @type int $per_page Optional. Number of items to return per page
436
  * of results. Default: null (no limit).
437
- * @type int $page Optional. Page offset of results to return.
438
  * Default: null (no limit).
439
- * @type int $user_id Optional. If provided, results will be limited
440
  * to groups of which the specified user is a member. Default:
441
  * null.
442
- * @type string $search_terms Optional. If provided, only groups
443
  * whose names or descriptions match the search terms will be
444
  * returned. Default: false.
445
- * @type array $meta_query Optional. An array of meta_query
446
  * conditions. See {@link WP_Meta_Query::queries} for
447
  * description.
448
- * @type array|string Optional. Array or comma-separated list of
449
  * group IDs. Results will be limited to groups within the
450
  * list. Default: false.
451
  * @type bool $populate_extras Whether to fetch additional
452
  * information (such as member count) about groups. Default:
453
  * true.
454
- * @type array|string Optional. Array or comma-separated list of
455
  * group IDs. Results will exclude the listed groups.
456
  * Default: false.
457
  * @type bool $show_hidden Whether to include hidden groups in
@@ -706,9 +710,9 @@ function bp_group_type( $group = false ) {
706
 
707
  if ( 'public' == $group->status ) {
708
  $type = __( "Public Group", "buddypress" );
709
- } else if ( 'hidden' == $group->status ) {
710
  $type = __( "Hidden Group", "buddypress" );
711
- } else if ( 'private' == $group->status ) {
712
  $type = __( "Private Group", "buddypress" );
713
  } else {
714
  $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' );
@@ -1507,6 +1511,15 @@ function bp_group_search_form() {
1507
  echo apply_filters( 'bp_group_search_form', $search_form_html );
1508
  }
1509
 
 
 
 
 
 
 
 
 
 
1510
  function bp_group_show_no_groups_message() {
1511
  if ( !groups_total_groups_for_user( bp_displayed_user_id() ) )
1512
  return true;
@@ -1514,6 +1527,15 @@ function bp_group_show_no_groups_message() {
1514
  return false;
1515
  }
1516
 
 
 
 
 
 
 
 
 
 
1517
  function bp_group_is_activity_permalink() {
1518
 
1519
  if ( !bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action( bp_get_activity_slug() ) )
@@ -1522,18 +1544,34 @@ function bp_group_is_activity_permalink() {
1522
  return true;
1523
  }
1524
 
 
 
 
1525
  function bp_groups_pagination_links() {
1526
  echo bp_get_groups_pagination_links();
1527
  }
 
 
 
 
 
1528
  function bp_get_groups_pagination_links() {
1529
  global $groups_template;
1530
 
1531
  return apply_filters( 'bp_get_groups_pagination_links', $groups_template->pag_links );
1532
  }
1533
 
 
 
 
1534
  function bp_groups_pagination_count() {
1535
  echo bp_get_groups_pagination_count();
1536
  }
 
 
 
 
 
1537
  function bp_get_groups_pagination_count() {
1538
  global $groups_template;
1539
 
@@ -1542,18 +1580,37 @@ function bp_groups_pagination_count() {
1542
  $to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) );
1543
  $total = bp_core_number_format( $groups_template->total_group_count );
1544
 
1545
- return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing 1', 'Viewing %1$s - %2$s of %3$s groups', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
1546
  }
1547
 
 
 
 
 
 
 
 
 
1548
  function bp_groups_auto_join() {
1549
  global $bp;
1550
 
1551
  return apply_filters( 'bp_groups_auto_join', (bool)$bp->groups->auto_join );
1552
  }
1553
 
 
 
 
 
 
1554
  function bp_group_total_members( $group = false ) {
1555
  echo bp_get_group_total_members( $group );
1556
  }
 
 
 
 
 
 
1557
  function bp_get_group_total_members( $group = false ) {
1558
  global $groups_template;
1559
 
@@ -1563,21 +1620,46 @@ function bp_group_total_members( $group = false ) {
1563
  return apply_filters( 'bp_get_group_total_members', $group->total_member_count );
1564
  }
1565
 
 
 
 
 
 
1566
  function bp_group_member_count() {
1567
  echo bp_get_group_member_count();
1568
  }
 
 
 
 
 
 
1569
  function bp_get_group_member_count() {
1570
  global $groups_template;
1571
 
1572
- if ( 1 == (int) $groups_template->group->total_member_count )
1573
- return apply_filters( 'bp_get_group_member_count', sprintf( __( '%s member', 'buddypress' ), bp_core_number_format( $groups_template->group->total_member_count ) ) );
1574
- else
1575
- return apply_filters( 'bp_get_group_member_count', sprintf( __( '%s members', 'buddypress' ), bp_core_number_format( $groups_template->group->total_member_count ) ) );
 
 
 
 
 
1576
  }
1577
 
 
 
 
1578
  function bp_group_forum_permalink() {
1579
  echo bp_get_group_forum_permalink();
1580
  }
 
 
 
 
 
 
1581
  function bp_get_group_forum_permalink( $group = false ) {
1582
  global $groups_template;
1583
 
@@ -1587,9 +1669,25 @@ function bp_group_forum_permalink() {
1587
  return apply_filters( 'bp_get_group_forum_permalink', bp_get_group_permalink( $group ) . 'forum' );
1588
  }
1589
 
 
 
 
 
 
1590
  function bp_group_forum_topic_count( $args = '' ) {
1591
  echo bp_get_group_forum_topic_count( $args );
1592
  }
 
 
 
 
 
 
 
 
 
 
 
1593
  function bp_get_group_forum_topic_count( $args = '' ) {
1594
  global $groups_template;
1595
 
@@ -1621,9 +1719,25 @@ function bp_group_forum_topic_count( $args = '' ) {
1621
  return apply_filters( 'bp_get_group_forum_topic_count', $total_topics, (bool)$showtext );
1622
  }
1623
 
 
 
 
 
 
1624
  function bp_group_forum_post_count( $args = '' ) {
1625
  echo bp_get_group_forum_post_count( $args );
1626
  }
 
 
 
 
 
 
 
 
 
 
 
1627
  function bp_get_group_forum_post_count( $args = '' ) {
1628
  global $groups_template;
1629
 
@@ -1655,6 +1769,12 @@ function bp_group_forum_post_count( $args = '' ) {
1655
  return apply_filters( 'bp_get_group_forum_post_count', $total_posts, (bool)$showtext );
1656
  }
1657
 
 
 
 
 
 
 
1658
  function bp_group_is_forum_enabled( $group = false ) {
1659
  global $groups_template;
1660
 
@@ -1667,6 +1787,11 @@ function bp_group_is_forum_enabled( $group = false ) {
1667
  return false;
1668
  }
1669
 
 
 
 
 
 
1670
  function bp_group_show_forum_setting( $group = false ) {
1671
  global $groups_template;
1672
 
@@ -1677,6 +1802,12 @@ function bp_group_show_forum_setting( $group = false ) {
1677
  echo ' checked="checked"';
1678
  }
1679
 
 
 
 
 
 
 
1680
  function bp_group_show_status_setting( $setting, $group = false ) {
1681
  global $groups_template;
1682
 
@@ -1688,12 +1819,13 @@ function bp_group_show_status_setting( $setting, $group = false ) {
1688
  }
1689
 
1690
  /**
1691
- * Get the 'checked' value, if needed, for a given invite_status on the group create/admin screens
1692
  *
1693
  * @since BuddyPress (1.5.0)
1694
  *
1695
- * @param string $setting The setting you want to check against ('members', 'mods', or 'admins')
1696
- * @param BP_Groups_Group $group (optional) The group whose status you want to check
 
1697
  */
1698
  function bp_group_show_invite_status_setting( $setting, $group = false ) {
1699
  $group_id = isset( $group->id ) ? $group->id : false;
@@ -1705,19 +1837,23 @@ function bp_group_show_invite_status_setting( $setting, $group = false ) {
1705
  }
1706
 
1707
  /**
1708
- * Get the invite status of a group
1709
  *
1710
- * 'invite_status' became part of BuddyPress in BP 1.5. In order to provide backward compatibility,
1711
- * groups without a status set will default to 'members', ie all members in a group can send
1712
- * invitations. Filter 'bp_group_invite_status_fallback' to change this fallback behavior.
 
 
1713
  *
1714
  * This function can be used either in or out of the loop.
1715
  *
1716
  * @since BuddyPress (1.5.0)
1717
  *
1718
- * @param int $group_id (optional) The id of the group whose status you want to check
1719
- * @return mixed Returns false when no group can be found. Otherwise returns the group invite
1720
- * status, from among 'members', 'mods', and 'admins'
 
 
1721
  */
1722
  function bp_group_get_invite_status( $group_id = false ) {
1723
  global $bp, $groups_template;
@@ -1726,7 +1862,7 @@ function bp_group_get_invite_status( $group_id = false ) {
1726
  if ( isset( $bp->groups->current_group->id ) ) {
1727
  // Default to the current group first
1728
  $group_id = $bp->groups->current_group->id;
1729
- } else if ( isset( $groups_template->group->id ) ) {
1730
  // Then see if we're in the loop
1731
  $group_id = $groups_template->group->id;
1732
  } else {
@@ -1745,57 +1881,70 @@ function bp_group_get_invite_status( $group_id = false ) {
1745
  }
1746
 
1747
  /**
1748
- * Can the logged-in user send invitations in the specified group?
1749
  *
1750
  * @since BuddyPress (1.5.0)
 
1751
  *
1752
- * @param int $group_id (optional) The id of the group whose status you want to check
1753
- * @return bool $can_send_invites
 
1754
  */
1755
- function bp_groups_user_can_send_invites( $group_id = false ) {
1756
- global $bp;
1757
-
1758
  $can_send_invites = false;
1759
  $invite_status = false;
1760
 
1761
- if ( is_user_logged_in() ) {
1762
- if ( bp_current_user_can( 'bp_moderate' ) ) {
1763
- // Super admins can always send invitations
1764
- $can_send_invites = true;
1765
-
1766
- } else {
1767
- // If no $group_id is provided, default to the current group id
1768
- if ( !$group_id )
1769
- $group_id = isset( $bp->groups->current_group->id ) ? $bp->groups->current_group->id : 0;
1770
 
1771
- // If no group has been found, bail
1772
- if ( !$group_id )
1773
- return false;
 
1774
 
 
 
 
 
 
1775
  $invite_status = bp_group_get_invite_status( $group_id );
1776
- if ( !$invite_status )
1777
- return false;
1778
 
1779
  switch ( $invite_status ) {
1780
  case 'admins' :
1781
- if ( groups_is_user_admin( bp_loggedin_user_id(), $group_id ) )
1782
  $can_send_invites = true;
 
1783
  break;
1784
 
1785
  case 'mods' :
1786
- if ( groups_is_user_mod( bp_loggedin_user_id(), $group_id ) || groups_is_user_admin( bp_loggedin_user_id(), $group_id ) )
1787
  $can_send_invites = true;
 
1788
  break;
1789
 
1790
  case 'members' :
1791
- if ( groups_is_user_member( bp_loggedin_user_id(), $group_id ) )
1792
  $can_send_invites = true;
 
1793
  break;
1794
  }
1795
  }
1796
  }
1797
 
1798
- return apply_filters( 'bp_groups_user_can_send_invites', $can_send_invites, $group_id, $invite_status );
 
 
 
 
 
 
 
 
 
 
 
1799
  }
1800
 
1801
  /**
@@ -1875,6 +2024,13 @@ function bp_group_admin_memberlist( $admin_list = false, $group = false ) {
1875
  <?php endif;
1876
  }
1877
 
 
 
 
 
 
 
 
1878
  function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
1879
  global $groups_template;
1880
 
@@ -1937,6 +2093,12 @@ function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
1937
  <?php }
1938
  }
1939
 
 
 
 
 
 
 
1940
  function bp_group_has_moderators( $group = false ) {
1941
  global $groups_template;
1942
 
@@ -1946,9 +2108,24 @@ function bp_group_has_moderators( $group = false ) {
1946
  return apply_filters( 'bp_group_has_moderators', groups_get_group_mods( $group->id ) );
1947
  }
1948
 
 
 
 
 
 
1949
  function bp_group_member_promote_mod_link( $args = '' ) {
1950
  echo bp_get_group_member_promote_mod_link( $args );
1951
  }
 
 
 
 
 
 
 
 
 
 
1952
  function bp_get_group_member_promote_mod_link( $args = '' ) {
1953
  global $members_template, $groups_template;
1954
 
@@ -1963,9 +2140,24 @@ function bp_group_member_promote_mod_link( $args = '' ) {
1963
  return apply_filters( 'bp_get_group_member_promote_mod_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/promote/mod/' . $user_id, 'groups_promote_member' ) );
1964
  }
1965
 
 
 
 
 
 
1966
  function bp_group_member_promote_admin_link( $args = '' ) {
1967
  echo bp_get_group_member_promote_admin_link( $args );
1968
  }
 
 
 
 
 
 
 
 
 
 
1969
  function bp_get_group_member_promote_admin_link( $args = '' ) {
1970
  global $members_template, $groups_template;
1971
 
@@ -1980,6 +2172,12 @@ function bp_group_member_promote_admin_link( $args = '' ) {
1980
  return apply_filters( 'bp_get_group_member_promote_admin_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/promote/admin/' . $user_id, 'groups_promote_member' ) );
1981
  }
1982
 
 
 
 
 
 
 
1983
  function bp_group_member_demote_link( $user_id = 0 ) {
1984
  global $members_template;
1985
 
@@ -1988,6 +2186,14 @@ function bp_group_member_demote_link( $user_id = 0 ) {
1988
 
1989
  echo bp_get_group_member_demote_link( $user_id );
1990
  }
 
 
 
 
 
 
 
 
1991
  function bp_get_group_member_demote_link( $user_id = 0, $group = false ) {
1992
  global $members_template, $groups_template;
1993
 
@@ -2000,6 +2206,12 @@ function bp_group_member_demote_link( $user_id = 0 ) {
2000
  return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) );
2001
  }
2002
 
 
 
 
 
 
 
2003
  function bp_group_member_ban_link( $user_id = 0 ) {
2004
  global $members_template;
2005
 
@@ -2008,6 +2220,14 @@ function bp_group_member_ban_link( $user_id = 0 ) {
2008
 
2009
  echo bp_get_group_member_ban_link( $user_id );
2010
  }
 
 
 
 
 
 
 
 
2011
  function bp_get_group_member_ban_link( $user_id = 0, $group = false ) {
2012
  global $groups_template;
2013
 
@@ -2017,6 +2237,12 @@ function bp_group_member_ban_link( $user_id = 0 ) {
2017
  return apply_filters( 'bp_get_group_member_ban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/ban/' . $user_id, 'groups_ban_member' ) );
2018
  }
2019
 
 
 
 
 
 
 
2020
  function bp_group_member_unban_link( $user_id = 0 ) {
2021
  global $members_template;
2022
 
@@ -2025,6 +2251,14 @@ function bp_group_member_unban_link( $user_id = 0 ) {
2025
 
2026
  echo bp_get_group_member_unban_link( $user_id );
2027
  }
 
 
 
 
 
 
 
 
2028
  function bp_get_group_member_unban_link( $user_id = 0, $group = false ) {
2029
  global $members_template, $groups_template;
2030
 
@@ -2037,7 +2271,12 @@ function bp_group_member_unban_link( $user_id = 0 ) {
2037
  return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) );
2038
  }
2039
 
2040
-
 
 
 
 
 
2041
  function bp_group_member_remove_link( $user_id = 0 ) {
2042
  global $members_template;
2043
 
@@ -2046,6 +2285,14 @@ function bp_group_member_remove_link( $user_id = 0 ) {
2046
 
2047
  echo bp_get_group_member_remove_link( $user_id );
2048
  }
 
 
 
 
 
 
 
 
2049
  function bp_get_group_member_remove_link( $user_id = 0, $group = false ) {
2050
  global $groups_template;
2051
 
@@ -2055,6 +2302,12 @@ function bp_group_member_remove_link( $user_id = 0 ) {
2055
  return apply_filters( 'bp_get_group_member_remove_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/remove/' . $user_id, 'groups_remove_member' ) );
2056
  }
2057
 
 
 
 
 
 
 
2058
  function bp_group_admin_tabs( $group = false ) {
2059
  global $groups_template;
2060
 
@@ -2062,50 +2315,81 @@ function bp_group_admin_tabs( $group = false ) {
2062
  $group = ( $groups_template->group ) ? $groups_template->group : groups_get_current_group();
2063
  }
2064
 
2065
- $current_tab = bp_get_group_current_admin_tab();
2066
-
2067
- if ( bp_is_item_admin() ) : ?>
2068
-
2069
- <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/edit-details' ) ?>"><?php _e( 'Details', 'buddypress' ); ?></a></li>
2070
 
2071
- <?php endif; ?>
2072
-
2073
- <?php if ( ! bp_is_item_admin() )
2074
- return false; ?>
2075
-
2076
- <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-settings' ) ?>"><?php _e( 'Settings', 'buddypress' ); ?></a></li>
2077
 
2078
- <?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) : ?>
2079
 
2080
- <li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-avatar' ) ?>"><?php _e( 'Photo', 'buddypress' ); ?></a></li>
2081
 
2082
- <?php endif; ?>
 
2083
 
2084
- <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members' ) ?>"><?php _e( 'Members', 'buddypress' ); ?></a></li>
 
 
 
 
 
 
 
 
 
 
 
 
2085
 
2086
- <?php if ( $groups_template->group->status == 'private' ) : ?>
2087
 
2088
- <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/membership-requests' ) ?>"><?php _e( 'Requests', 'buddypress' ); ?></a></li>
2089
 
2090
- <?php endif; ?>
2091
 
2092
- <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
 
2093
 
2094
- <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/delete-group' ) ?>"><?php _e( 'Delete', 'buddypress' ); ?></a></li>
 
 
 
2095
 
2096
- <?php
2097
  }
2098
 
 
 
 
2099
  function bp_group_total_for_member() {
2100
  echo bp_get_group_total_for_member();
2101
  }
 
 
 
 
 
2102
  function bp_get_group_total_for_member() {
2103
  return apply_filters( 'bp_get_group_total_for_member', BP_Groups_Member::total_group_count() );
2104
  }
2105
 
 
 
 
 
 
2106
  function bp_group_form_action( $page ) {
2107
  echo bp_get_group_form_action( $page );
2108
  }
 
 
 
 
 
 
 
 
2109
  function bp_get_group_form_action( $page, $group = false ) {
2110
  global $groups_template;
2111
 
@@ -2115,9 +2399,22 @@ function bp_group_form_action( $page ) {
2115
  return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . $page );
2116
  }
2117
 
 
 
 
 
 
2118
  function bp_group_admin_form_action( $page = false ) {
2119
  echo bp_get_group_admin_form_action( $page );
2120
  }
 
 
 
 
 
 
 
 
2121
  function bp_get_group_admin_form_action( $page = false, $group = false ) {
2122
  global $groups_template;
2123
 
@@ -2130,6 +2427,13 @@ function bp_group_admin_form_action( $page = false ) {
2130
  return apply_filters( 'bp_group_admin_form_action', bp_get_group_permalink( $group ) . 'admin/' . $page );
2131
  }
2132
 
 
 
 
 
 
 
 
2133
  function bp_group_has_requested_membership( $group = false ) {
2134
  global $groups_template;
2135
 
@@ -2143,16 +2447,13 @@ function bp_group_has_requested_membership( $group = false ) {
2143
  }
2144
 
2145
  /**
2146
- * bp_group_is_member()
2147
  *
2148
- * Checks if current user is member of a group.
2149
  *
2150
- * @uses bp_current_user_can() Check if current user is super admin
2151
- * @uses apply_filters Creates bp_group_is_member filter and passes $is_member
2152
- * @usedby groups/activity.php, groups/single/forum/edit.php, groups/single/forum/topic.php to determine template part visibility
2153
- * @global object $groups_template Current Group (usually in template loop)
2154
- * @param object $group Group to check is_member
2155
- * @return bool If user is member of group or not
2156
  */
2157
  function bp_group_is_member( $group = false ) {
2158
  global $groups_template;
@@ -2170,7 +2471,7 @@ function bp_group_is_member( $group = false ) {
2170
  /**
2171
  * Check whether the current user has an outstanding invite to the current group in the loop.
2172
  *
2173
- * @param object $group Optional. Group data object. Defaults to the current
2174
  * group in the groups loop.
2175
  * @return bool True if the user has an outstanding invite, otherwise false.
2176
  */
@@ -2238,9 +2539,19 @@ function bp_group_is_user_banned( $group = false, $user_id = 0 ) {
2238
  return (bool) apply_filters( 'bp_group_is_user_banned', $retval );
2239
  }
2240
 
 
 
 
2241
  function bp_group_accept_invite_link() {
2242
  echo bp_get_group_accept_invite_link();
2243
  }
 
 
 
 
 
 
 
2244
  function bp_get_group_accept_invite_link( $group = false ) {
2245
  global $groups_template, $bp;
2246
 
@@ -2250,9 +2561,19 @@ function bp_group_accept_invite_link() {
2250
  return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/accept/' . $group->id ), 'groups_accept_invite' ) );
2251
  }
2252
 
 
 
 
2253
  function bp_group_reject_invite_link() {
2254
  echo bp_get_group_reject_invite_link();
2255
  }
 
 
 
 
 
 
 
2256
  function bp_get_group_reject_invite_link( $group = false ) {
2257
  global $groups_template, $bp;
2258
 
@@ -2262,9 +2583,19 @@ function bp_group_reject_invite_link() {
2262
  return apply_filters( 'bp_get_group_reject_invite_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/reject/' . $group->id ), 'groups_reject_invite' ) );
2263
  }
2264
 
 
 
 
2265
  function bp_group_leave_confirm_link() {
2266
  echo bp_get_group_leave_confirm_link();
2267
  }
 
 
 
 
 
 
 
2268
  function bp_get_group_leave_confirm_link( $group = false ) {
2269
  global $groups_template;
2270
 
@@ -2274,9 +2605,19 @@ function bp_group_leave_confirm_link() {
2274
  return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group/yes', 'groups_leave_group' ) );
2275
  }
2276
 
 
 
 
2277
  function bp_group_leave_reject_link() {
2278
  echo bp_get_group_leave_reject_link();
2279
  }
 
 
 
 
 
 
 
2280
  function bp_get_group_leave_reject_link( $group = false ) {
2281
  global $groups_template;
2282
 
@@ -2286,9 +2627,19 @@ function bp_group_leave_reject_link() {
2286
  return apply_filters( 'bp_get_group_leave_reject_link', bp_get_group_permalink( $group ) );
2287
  }
2288
 
 
 
 
2289
  function bp_group_send_invite_form_action() {
2290
  echo bp_get_group_send_invite_form_action();
2291
  }
 
 
 
 
 
 
 
2292
  function bp_get_group_send_invite_form_action( $group = false ) {
2293
  global $groups_template;
2294
 
@@ -2298,6 +2649,13 @@ function bp_group_send_invite_form_action() {
2298
  return apply_filters( 'bp_group_send_invite_form_action', bp_get_group_permalink( $group ) . 'send-invites/send' );
2299
  }
2300
 
 
 
 
 
 
 
 
2301
  function bp_has_friends_to_invite( $group = false ) {
2302
  global $groups_template;
2303
 
@@ -2314,12 +2672,12 @@ function bp_has_friends_to_invite( $group = false ) {
2314
  }
2315
 
2316
  /**
2317
- * Outputs a 'New Topic' button for a group.
2318
  *
2319
  * @since BuddyPress (1.2.7)
2320
  *
2321
- * @param BP_Groups_Group|bool $group The BP Groups_Group object if passed, boolean false if not passed.
2322
- * @uses bp_get_group_new_topic_button() Returns the 'New Topic' button
2323
  */
2324
  function bp_group_new_topic_button( $group = false ) {
2325
  echo bp_get_group_new_topic_button( $group );
@@ -2329,13 +2687,9 @@ function bp_group_new_topic_button( $group = false ) {
2329
  *
2330
  * @since BuddyPress (1.2.7)
2331
  *
2332
- * @param BP_Groups_Group|bool $group The BP Groups_Group object if passed, boolean false if not passed.
2333
- * @uses is_user_logged_in() Is there a user logged in?
2334
- * @uses bp_group_is_user_banned() Is the current user banned from the current group?
2335
- * @uses bp_is_group_forum() Are we on a group forum page?
2336
- * @uses bp_is_group_forum_topic() Are we on a group topic page?
2337
- * @uses bp_get_button() Renders a button
2338
- * @return string HTML code for the button
2339
  */
2340
  function bp_get_group_new_topic_button( $group = false ) {
2341
  global $groups_template;
@@ -2512,14 +2866,69 @@ function bp_group_create_button() {
2512
  'component' => 'groups',
2513
  'link_text' => __( 'Create a Group', 'buddypress' ),
2514
  'link_title' => __( 'Create a Group', 'buddypress' ),
2515
- 'link_class' => 'button group-create bp-title-button',
2516
  'link_href' => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_groups_root_slug() ) . trailingslashit( 'create' ),
2517
  'wrapper' => false,
 
2518
  );
2519
 
2520
  return bp_get_button( apply_filters( 'bp_get_group_create_button', $button_args ) );
2521
  }
2522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2523
  /**
2524
  * Prints a message if the group is not visible to the current user (it is a
2525
  * hidden or private group, and the user does not have access).
@@ -2538,7 +2947,7 @@ function bp_group_status_message( $group = null ) {
2538
  if ( ! bp_group_has_requested_membership() ) {
2539
  if ( is_user_logged_in() && bp_group_is_invited() ) {
2540
  $message = __( 'You must accept your pending invitation before you can access this private group.', 'buddypress' );
2541
- } else if ( is_user_logged_in() ) {
2542
  $message = __( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
2543
  } else {
2544
  $message = __( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
@@ -2700,13 +3109,14 @@ class BP_Groups_Group_Members_Template {
2700
  }
2701
 
2702
  $this->pag_links = paginate_links( array(
2703
- 'base' => add_query_arg( array( 'mlpage' => '%#%' ), $base_url ),
2704
- 'format' => '',
2705
- 'total' => !empty( $this->pag_num ) ? ceil( $this->total_member_count / $this->pag_num ) : $this->total_member_count,
2706
- 'current' => $this->pag_page,
2707
  'prev_text' => '&larr;',
2708
  'next_text' => '&rarr;',
2709
- 'mid_size' => 1
 
2710
  ));
2711
  }
2712
 
@@ -3731,13 +4141,14 @@ class BP_Groups_Membership_Requests_Template {
3731
  }
3732
 
3733
  $this->pag_links = paginate_links( array(
3734
- 'base' => add_query_arg( 'mrpage', '%#%' ),
3735
- 'format' => '',
3736
- 'total' => ceil( $this->total_request_count / $this->pag_num ),
3737
- 'current' => $this->pag_page,
3738
  'prev_text' => '&larr;',
3739
  'next_text' => '&rarr;',
3740
- 'mid_size' => 1
 
3741
  ) );
3742
  }
3743
 
@@ -3983,6 +4394,7 @@ class BP_Groups_Invite_Template {
3983
  'prev_text' => '&larr;',
3984
  'next_text' => '&rarr;',
3985
  'mid_size' => 1,
 
3986
  ) );
3987
  } else {
3988
  $this->pag_links = '';
@@ -4054,13 +4466,9 @@ class BP_Groups_Invite_Template {
4054
  $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count( $user_id );
4055
  }
4056
 
4057
- if ( bp_is_active( 'friends' ) ) {
4058
- $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count( $user_id );
4059
- }
4060
-
4061
  $this->invite->user->total_blogs = null;
4062
 
4063
- $this->invite->group_id = $group_id; // Globaled in bp_group_has_invites()
4064
 
4065
  if ( 0 == $this->current_invite ) // loop has just started
4066
  do_action('loop_start');
233
 
234
  if ( 'invites' == $type ) {
235
  $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page, $exclude );
236
+ } elseif ( 'single-group' == $type ) {
237
  $this->single_group = true;
238
 
239
  if ( groups_get_current_group() ) {
279
  $this->total_group_count = (int) $this->groups['total'];
280
  $this->group_count = (int) $this->groups['total'];
281
  $this->groups = $this->groups['groups'];
282
+ } elseif ( 'single-group' == $type ) {
283
  if ( empty( $group->id ) ) {
284
  $this->total_group_count = 0;
285
  $this->group_count = 0;
310
  // Build pagination links
311
  if ( (int) $this->total_group_count && (int) $this->pag_num ) {
312
  $pag_args = array(
313
+ $page_arg => '%#%'
 
 
 
314
  );
315
 
316
  if ( defined( 'DOING_AJAX' ) && true === (bool) DOING_AJAX ) {
319
  $base = '';
320
  }
321
 
322
+ $add_args = array(
323
+ 'num' => $this->pag_num,
324
+ 'sortby' => $this->sort_by,
325
+ 'order' => $this->order,
326
+ );
327
+
328
  if ( ! empty( $search_terms ) ) {
329
+ $add_args['s'] = urlencode( $search_terms );
330
  }
331
 
332
  $this->pag_links = paginate_links( array(
336
  'current' => $this->pag_page,
337
  'prev_text' => _x( '&larr;', 'Group pagination previous text', 'buddypress' ),
338
  'next_text' => _x( '&rarr;', 'Group pagination next text', 'buddypress' ),
339
+ 'mid_size' => 1,
340
+ 'add_args' => $add_args,
341
  ) );
342
  }
343
  }
427
  *
428
  * @param array $args {
429
  * Array of parameters. All items are optional.
430
+ * @type string $type Shorthand for certain orderby/
431
  * order combinations. 'newest', 'active', 'popular',
432
  * 'alphabetical', 'random'. When present, will override
433
  * orderby and order params. Default: null.
434
+ * @type string $orderby Property to sort by.
435
  * 'date_created', 'last_activity', 'total_member_count',
436
  * 'name', 'random'. Default: 'date_created'.
437
+ * @type string $order Sort order. 'ASC' or 'DESC'.
438
  * Default: 'DESC'.
439
+ * @type int $per_page Number of items to return per page
440
  * of results. Default: null (no limit).
441
+ * @type int $page Page offset of results to return.
442
  * Default: null (no limit).
443
+ * @type int $user_id If provided, results will be limited
444
  * to groups of which the specified user is a member. Default:
445
  * null.
446
+ * @type string $search_terms If provided, only groups
447
  * whose names or descriptions match the search terms will be
448
  * returned. Default: false.
449
+ * @type array $meta_query An array of meta_query
450
  * conditions. See {@link WP_Meta_Query::queries} for
451
  * description.
452
+ * @type array|string $include Array or comma-separated list of
453
  * group IDs. Results will be limited to groups within the
454
  * list. Default: false.
455
  * @type bool $populate_extras Whether to fetch additional
456
  * information (such as member count) about groups. Default:
457
  * true.
458
+ * @type array|string $exclude Array or comma-separated list of
459
  * group IDs. Results will exclude the listed groups.
460
  * Default: false.
461
  * @type bool $show_hidden Whether to include hidden groups in
710
 
711
  if ( 'public' == $group->status ) {
712
  $type = __( "Public Group", "buddypress" );
713
+ } elseif ( 'hidden' == $group->status ) {
714
  $type = __( "Hidden Group", "buddypress" );
715
+ } elseif ( 'private' == $group->status ) {
716
  $type = __( "Private Group", "buddypress" );
717
  } else {
718
  $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' );
1511
  echo apply_filters( 'bp_group_search_form', $search_form_html );
1512
  }
1513
 
1514
+ /**
1515
+ * Determine whether the displayed user has no groups.
1516
+ *
1517
+ * No longer used in BuddyPress.
1518
+ *
1519
+ * @todo Deprecate
1520
+ *
1521
+ * @return bool True if the displayed user has no groups, otherwise false.
1522
+ */
1523
  function bp_group_show_no_groups_message() {
1524
  if ( !groups_total_groups_for_user( bp_displayed_user_id() ) )
1525
  return true;
1527
  return false;
1528
  }
1529
 
1530
+ /**
1531
+ * Determine whether the current page is a group activity permalink.
1532
+ *
1533
+ * No longer used in BuddyPress.
1534
+ *
1535
+ * @todo Deprecate.
1536
+ *
1537
+ * @return bool True if this is a group activity permalink, otherwise false.
1538
+ */
1539
  function bp_group_is_activity_permalink() {
1540
 
1541
  if ( !bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action( bp_get_activity_slug() ) )
1544
  return true;
1545
  }
1546
 
1547
+ /**
1548
+ * Output the pagination HTML for a group loop.
1549
+ */
1550
  function bp_groups_pagination_links() {
1551
  echo bp_get_groups_pagination_links();
1552
  }
1553
+ /**
1554
+ * Get the pagination HTML for a group loop.
1555
+ *
1556
+ * @return string
1557
+ */
1558
  function bp_get_groups_pagination_links() {
1559
  global $groups_template;
1560
 
1561
  return apply_filters( 'bp_get_groups_pagination_links', $groups_template->pag_links );
1562
  }
1563
 
1564
+ /**
1565
+ * Output the "Viewing x-y of z groups" pagination message.
1566
+ */
1567
  function bp_groups_pagination_count() {
1568
  echo bp_get_groups_pagination_count();
1569
  }
1570
+ /**
1571
+ * Generate the "Viewing x-y of z groups" pagination message.
1572
+ *
1573
+ * @return string
1574
+ */
1575
  function bp_get_groups_pagination_count() {
1576
  global $groups_template;
1577
 
1580
  $to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) );
1581
  $total = bp_core_number_format( $groups_template->total_group_count );
1582
 
1583
+ return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing 1 group', 'Viewing %1$s - %2$s of %3$s groups', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
1584
  }
1585
 
1586
+ /**
1587
+ * Determine whether groups auto-join is enabled.
1588
+ *
1589
+ * "Auto-join" is the toggle that determines whether users are joined to a
1590
+ * public group automatically when creating content in that group.
1591
+ *
1592
+ * @return bool
1593
+ */
1594
  function bp_groups_auto_join() {
1595
  global $bp;
1596
 
1597
  return apply_filters( 'bp_groups_auto_join', (bool)$bp->groups->auto_join );
1598
  }
1599
 
1600
+ /**
1601
+ * Output the total member count for a group.
1602
+ *
1603
+ * @param object $group Optional. Group object. Default: current group in loop.
1604
+ */
1605
  function bp_group_total_members( $group = false ) {
1606
  echo bp_get_group_total_members( $group );
1607
  }
1608
+ /**
1609
+ * Get the total member count for a group.
1610
+ *
1611
+ * @param object $group Optional. Group object. Default: current group in loop.
1612
+ * @return int
1613
+ */
1614
  function bp_get_group_total_members( $group = false ) {
1615
  global $groups_template;
1616
 
1620
  return apply_filters( 'bp_get_group_total_members', $group->total_member_count );
1621
  }
1622
 
1623
+ /**
1624
+ * Output the "x members" count string for a group.
1625
+ *
1626
+ * @param object $group Optional. Group object. Default: current group in loop.
1627
+ */
1628
  function bp_group_member_count() {
1629
  echo bp_get_group_member_count();
1630
  }
1631
+ /**
1632
+ * Generate the "x members" count string for a group.
1633
+ *
1634
+ * @param object $group Optional. Group object. Default: current group in loop.
1635
+ * @return string
1636
+ */
1637
  function bp_get_group_member_count() {
1638
  global $groups_template;
1639
 
1640
+ if ( isset( $groups_template->group->total_member_count ) ) {
1641
+ $count = (int) $groups_template->group->total_member_count;
1642
+ } else {
1643
+ $count = 0;
1644
+ }
1645
+
1646
+ $count_string = sprintf( _n( '%s member', '%s members', $count, 'buddypress' ), bp_core_number_format( $count ) );
1647
+
1648
+ return apply_filters( 'bp_get_group_member_count', $count_string );
1649
  }
1650
 
1651
+ /**
1652
+ * Output the URL of the Forum page of the current group in the loop.
1653
+ */
1654
  function bp_group_forum_permalink() {
1655
  echo bp_get_group_forum_permalink();
1656
  }
1657
+ /**
1658
+ * Generate the URL of the Forum page of a group.
1659
+ *
1660
+ * @param object $group Optional. Group object. Default: current group in loop.
1661
+ * @return string
1662
+ */
1663
  function bp_get_group_forum_permalink( $group = false ) {
1664
  global $groups_template;
1665
 
1669
  return apply_filters( 'bp_get_group_forum_permalink', bp_get_group_permalink( $group ) . 'forum' );
1670
  }
1671
 
1672
+ /**
1673
+ * Output the topic count for a group forum.
1674
+ *
1675
+ * @param array $args See {@link bp_get_group_forum_topic_count()}.
1676
+ */
1677
  function bp_group_forum_topic_count( $args = '' ) {
1678
  echo bp_get_group_forum_topic_count( $args );
1679
  }
1680
+ /**
1681
+ * Generate the topic count string for a group forum.
1682
+ *
1683
+ * @param array $args {
1684
+ * Array of arguments.
1685
+ * @type bool $showtext Optional. If true, result will be formatted
1686
+ * as "x topics". If false, just a number will be returned.
1687
+ * Default: false.
1688
+ * }
1689
+ * @return string|int
1690
+ */
1691
  function bp_get_group_forum_topic_count( $args = '' ) {
1692
  global $groups_template;
1693
 
1719
  return apply_filters( 'bp_get_group_forum_topic_count', $total_topics, (bool)$showtext );
1720
  }
1721
 
1722
+ /**
1723
+ * Output the post count for a group forum.
1724
+ *
1725
+ * @param array $args See {@link bp_get_group_forum_post_count()}.
1726
+ */
1727
  function bp_group_forum_post_count( $args = '' ) {
1728
  echo bp_get_group_forum_post_count( $args );
1729
  }
1730
+ /**
1731
+ * Generate the post count string for a group forum.
1732
+ *
1733
+ * @param array $args {
1734
+ * Array of arguments.
1735
+ * @type bool $showtext Optional. If true, result will be formatted
1736
+ * as "x posts". If false, just a number will be returned.
1737
+ * Default: false.
1738
+ * }
1739
+ * @return string|int
1740
+ */
1741
  function bp_get_group_forum_post_count( $args = '' ) {
1742
  global $groups_template;
1743
 
1769
  return apply_filters( 'bp_get_group_forum_post_count', $total_posts, (bool)$showtext );
1770
  }
1771
 
1772
+ /**
1773
+ * Determine whether forums are enabled for a group.
1774
+ *
1775
+ * @param object $group Optional. Group object. Default: current group in loop.
1776
+ * @return bool
1777
+ */
1778
  function bp_group_is_forum_enabled( $group = false ) {
1779
  global $groups_template;
1780
 
1787
  return false;
1788
  }
1789
 
1790
+ /**
1791
+ * Output the 'checked' attribute for the group forums settings UI.
1792
+ *
1793
+ * @param object $group Optional. Group object. Default: current group in loop.
1794
+ */
1795
  function bp_group_show_forum_setting( $group = false ) {
1796
  global $groups_template;
1797
 
1802
  echo ' checked="checked"';
1803
  }
1804
 
1805
+ /**
1806
+ * Output the 'checked' attribute for a given status in the settings UI.
1807
+ *
1808
+ * @param string $setting Group status. 'public', 'private', 'hidden'.
1809
+ * @param object $group Optional. Group object. Default: current group in loop.
1810
+ */
1811
  function bp_group_show_status_setting( $setting, $group = false ) {
1812
  global $groups_template;
1813
 
1819
  }
1820
 
1821
  /**
1822
+ * Output the 'checked' value, if needed, for a given invite_status on the group create/admin screens
1823
  *
1824
  * @since BuddyPress (1.5.0)
1825
  *
1826
+ * @param string $setting The setting you want to check against ('members',
1827
+ * 'mods', or 'admins').
1828
+ * @param object $group Optional. Group object. Default: current group in loop.
1829
  */
1830
  function bp_group_show_invite_status_setting( $setting, $group = false ) {
1831
  $group_id = isset( $group->id ) ? $group->id : false;
1837
  }
1838
 
1839
  /**
1840
+ * Get the invite status of a group.
1841
  *
1842
+ * 'invite_status' became part of BuddyPress in BP 1.5. In order to provide
1843
+ * backward compatibility with earlier installations, groups without a status
1844
+ * set will default to 'members', ie all members in a group can send
1845
+ * invitations. Filter 'bp_group_invite_status_fallback' to change this
1846
+ * fallback behavior.
1847
  *
1848
  * This function can be used either in or out of the loop.
1849
  *
1850
  * @since BuddyPress (1.5.0)
1851
  *
1852
+ * @param int $group_id Optional. The ID of the group whose status you want to
1853
+ * check. Default: the displayed group, or the current group in the loop.
1854
+ * @return bool|string Returns false when no group can be found. Otherwise
1855
+ * returns the group invite status, from among 'members', 'mods', and
1856
+ * 'admins'.
1857
  */
1858
  function bp_group_get_invite_status( $group_id = false ) {
1859
  global $bp, $groups_template;
1862
  if ( isset( $bp->groups->current_group->id ) ) {
1863
  // Default to the current group first
1864
  $group_id = $bp->groups->current_group->id;
1865
+ } elseif ( isset( $groups_template->group->id ) ) {
1866
  // Then see if we're in the loop
1867
  $group_id = $groups_template->group->id;
1868
  } else {
1881
  }
1882
 
1883
  /**
1884
+ * Can a user send invitations in the specified group?
1885
  *
1886
  * @since BuddyPress (1.5.0)
1887
+ * @since BuddyPress (2.2.0) Added the $user_id parameter.
1888
  *
1889
+ * @param int $group_id The group ID to check.
1890
+ * @param int $user_id The user ID to check.
1891
+ * @return bool
1892
  */
1893
+ function bp_groups_user_can_send_invites( $group_id = 0, $user_id = 0 ) {
 
 
1894
  $can_send_invites = false;
1895
  $invite_status = false;
1896
 
1897
+ // If $user_id isn't specified, we check against the logged-in user.
1898
+ if ( ! $user_id ) {
1899
+ $user_id = bp_loggedin_user_id();
1900
+ }
 
 
 
 
 
1901
 
1902
+ // If $group_id isn't specified, use existing one if available.
1903
+ if ( ! $group_id ) {
1904
+ $group_id = bp_get_current_group_id();
1905
+ }
1906
 
1907
+ if ( $user_id ) {
1908
+ // Users with the 'bp_moderate' cap can always send invitations
1909
+ if ( user_can( $user_id, 'bp_moderate' ) ) {
1910
+ $can_send_invites = true;
1911
+ } else {
1912
  $invite_status = bp_group_get_invite_status( $group_id );
 
 
1913
 
1914
  switch ( $invite_status ) {
1915
  case 'admins' :
1916
+ if ( groups_is_user_admin( $user_id, $group_id ) ) {
1917
  $can_send_invites = true;
1918
+ }
1919
  break;
1920
 
1921
  case 'mods' :
1922
+ if ( groups_is_user_mod( $user_id, $group_id ) || groups_is_user_admin( $user_id, $group_id ) ) {
1923
  $can_send_invites = true;
1924
+ }
1925
  break;
1926
 
1927
  case 'members' :
1928
+ if ( groups_is_user_member( $user_id, $group_id ) ) {
1929
  $can_send_invites = true;
1930
+ }
1931
  break;
1932
  }
1933
  }
1934
  }
1935
 
1936
+ /**
1937
+ * Filters whether a user can send invites in a group.
1938
+ *
1939
+ * @since BuddyPress (1.5.0)
1940
+ * @since BuddyPress (2.2.0) Added the $user_id parameter.
1941
+ *
1942
+ * @param bool $can_send_invites Whether the user can send invites
1943
+ * @param int $group_id The group ID being checked
1944
+ * @param bool $invite_status The group's current invite status
1945
+ * @param int $user_id The user ID being checked
1946
+ */
1947
+ return apply_filters( 'bp_groups_user_can_send_invites', $can_send_invites, $group_id, $invite_status, $user_id );
1948
  }
1949
 
1950
  /**
2024
  <?php endif;
2025
  }
2026
 
2027
+ /**
2028
+ * Generate the HTML for a list of group moderators.
2029
+ *
2030
+ * No longer used.
2031
+ *
2032
+ * @todo Deprecate.
2033
+ */
2034
  function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
2035
  global $groups_template;
2036
 
2093
  <?php }
2094
  }
2095
 
2096
+ /**
2097
+ * Determine whether a group has moderators.
2098
+ *
2099
+ * @param object $group Optional. Group object. Default: current group in loop.
2100
+ * @return array Info about group admins (user_id + date_modified).
2101
+ */
2102
  function bp_group_has_moderators( $group = false ) {
2103
  global $groups_template;
2104
 
2108
  return apply_filters( 'bp_group_has_moderators', groups_get_group_mods( $group->id ) );
2109
  }
2110
 
2111
+ /**
2112
+ * Output a URL for promoting a user to moderator.
2113
+ *
2114
+ * @param array $args See {@link bp_get_group_member_promote_mod_link()}.
2115
+ */
2116
  function bp_group_member_promote_mod_link( $args = '' ) {
2117
  echo bp_get_group_member_promote_mod_link( $args );
2118
  }
2119
+ /**
2120
+ * Generate a URL for promoting a user to moderator.
2121
+ *
2122
+ * @param array $args {
2123
+ * @type int $user_id ID of the member to promote. Default:
2124
+ * current member in a group member loop.
2125
+ * @type object $group Group object. Default: current group.
2126
+ * }
2127
+ * @return string
2128
+ */
2129
  function bp_get_group_member_promote_mod_link( $args = '' ) {
2130
  global $members_template, $groups_template;
2131
 
2140
  return apply_filters( 'bp_get_group_member_promote_mod_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/promote/mod/' . $user_id, 'groups_promote_member' ) );
2141
  }
2142
 
2143
+ /**
2144
+ * Output a URL for promoting a user to admin.
2145
+ *
2146
+ * @param array $args See {@link bp_get_group_member_promote_admin_link()}.
2147
+ */
2148
  function bp_group_member_promote_admin_link( $args = '' ) {
2149
  echo bp_get_group_member_promote_admin_link( $args );
2150
  }
2151
+ /**
2152
+ * Generate a URL for promoting a user to admin.
2153
+ *
2154
+ * @param array $args {
2155
+ * @type int $user_id ID of the member to promote. Default:
2156
+ * current member in a group member loop.
2157
+ * @type object $group Group object. Default: current group.
2158
+ * }
2159
+ * @return string
2160
+ */
2161
  function bp_get_group_member_promote_admin_link( $args = '' ) {
2162
  global $members_template, $groups_template;
2163
 
2172
  return apply_filters( 'bp_get_group_member_promote_admin_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/promote/admin/' . $user_id, 'groups_promote_member' ) );
2173
  }
2174
 
2175
+ /**
2176
+ * Output a URL for demoting a user to member.
2177
+ *
2178
+ * @param int $user_id ID of the member to demote. Default: current member in
2179
+ * a member loop.
2180
+ */
2181
  function bp_group_member_demote_link( $user_id = 0 ) {
2182
  global $members_template;
2183
 
2186
 
2187
  echo bp_get_group_member_demote_link( $user_id );
2188
  }
2189
+ /**
2190
+ * Generate a URL for demoting a user to member.
2191
+ *
2192
+ * @param int $user_id ID of the member to demote. Default: current
2193
+ * member in a member loop.
2194
+ * @param object $group Optional. Group object. Default: current group.
2195
+ * @return string
2196
+ */
2197
  function bp_get_group_member_demote_link( $user_id = 0, $group = false ) {
2198
  global $members_template, $groups_template;
2199
 
2206
  return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) );
2207
  }
2208
 
2209
+ /**
2210
+ * Output a URL for banning a member from a group.
2211
+ *
2212
+ * @param int $user_id ID of the member to ban. Default: current member in
2213
+ * a member loop.
2214
+ */
2215
  function bp_group_member_ban_link( $user_id = 0 ) {
2216
  global $members_template;
2217
 
2220
 
2221
  echo bp_get_group_member_ban_link( $user_id );
2222
  }
2223
+ /**
2224
+ * Generate a URL for banning a member from a group.
2225
+ *
2226
+ * @param int $user_id ID of the member to ban. Default: current
2227
+ * member in a member loop.
2228
+ * @param object $group Optional. Group object. Default: current group.
2229
+ * @return string
2230
+ */
2231
  function bp_get_group_member_ban_link( $user_id = 0, $group = false ) {
2232
  global $groups_template;
2233
 
2237
  return apply_filters( 'bp_get_group_member_ban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/ban/' . $user_id, 'groups_ban_member' ) );
2238
  }
2239
 
2240
+ /**
2241
+ * Output a URL for unbanning a member from a group.
2242
+ *
2243
+ * @param int $user_id ID of the member to unban. Default: current member in
2244
+ * a member loop.
2245
+ */
2246
  function bp_group_member_unban_link( $user_id = 0 ) {
2247
  global $members_template;
2248
 
2251
 
2252
  echo bp_get_group_member_unban_link( $user_id );
2253
  }
2254
+ /**
2255
+ * Generate a URL for unbanning a member from a group.
2256
+ *
2257
+ * @param int $user_id ID of the member to unban. Default: current
2258
+ * member in a member loop.
2259
+ * @param object $group Optional. Group object. Default: current group.
2260
+ * @return string
2261
+ */
2262
  function bp_get_group_member_unban_link( $user_id = 0, $group = false ) {
2263
  global $members_template, $groups_template;
2264
 
2271
  return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) );
2272
  }
2273
 
2274
+ /**
2275
+ * Output a URL for removing a member from a group.
2276
+ *
2277
+ * @param int $user_id ID of the member to remove. Default: current member in
2278
+ * a member loop.
2279
+ */
2280
  function bp_group_member_remove_link( $user_id = 0 ) {
2281
  global $members_template;
2282
 
2285
 
2286
  echo bp_get_group_member_remove_link( $user_id );
2287
  }
2288
+ /**
2289
+ * Generate a URL for removing a member from a group.
2290
+ *
2291
+ * @param int $user_id ID of the member to remove. Default: current
2292
+ * member in a member loop.
2293
+ * @param object $group Optional. Group object. Default: current group.
2294
+ * @return string
2295
+ */
2296
  function bp_get_group_member_remove_link( $user_id = 0, $group = false ) {
2297
  global $groups_template;
2298
 
2302
  return apply_filters( 'bp_get_group_member_remove_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/remove/' . $user_id, 'groups_remove_member' ) );
2303
  }
2304
 
2305
+ /**
2306
+ * HTML admin subnav items for group pages.
2307
+ *
2308
+ * @param object $group Optional. Group object. Default: current group in
2309
+ * the loop.
2310
+ */
2311
  function bp_group_admin_tabs( $group = false ) {
2312
  global $groups_template;
2313
 
2315
  $group = ( $groups_template->group ) ? $groups_template->group : groups_get_current_group();
2316
  }
2317
 
2318
+ $css_id = 'manage-members';
 
 
 
 
2319
 
2320
+ if ( 'private' == $group->status ) {
2321
+ $css_id = 'membership-requests';
2322
+ }
 
 
 
2323
 
2324
+ add_filter( "bp_get_options_nav_{$css_id}", 'bp_group_admin_tabs_backcompat', 10, 3 );
2325
 
2326
+ bp_get_options_nav( $group->slug . '_manage' );
2327
 
2328
+ remove_filter( "bp_get_options_nav_{$css_id}", 'bp_group_admin_tabs_backcompat', 10, 3 );
2329
+ }
2330
 
2331
+ /**
2332
+ * BackCompat for plugins/themes directly hooking groups_admin_tabs
2333
+ * without using the Groups Extension API
2334
+ *
2335
+ * @param string $subnav_output subnav item output
2336
+ * @param string $subnav_item subnav item params
2337
+ * @param string $selected_item current selected tab
2338
+ * @return string HTML output
2339
+ */
2340
+ function bp_group_admin_tabs_backcompat( $subnav_output = '', $subnav_item = '', $selected_item = '' ) {
2341
+ if ( ! has_action( 'groups_admin_tabs' ) ) {
2342
+ return $subnav_output;
2343
+ }
2344
 
2345
+ $group = groups_get_current_group();
2346
 
2347
+ ob_start();
2348
 
2349
+ do_action( 'groups_admin_tabs', $selected_item, $group->slug );
2350
 
2351
+ $admin_tabs_backcompat = trim( ob_get_contents() );
2352
+ ob_end_clean();
2353
 
2354
+ if ( ! empty( $admin_tabs_backcompat ) ) {
2355
+ _doing_it_wrong( "do_action( 'groups_admin_tabs' )", __( 'This action should not be used directly. Please use the BuddyPress Group Extension API to generate Manage tabs.', 'buddypress' ), '2.2.0' );
2356
+ $subnav_output .= $admin_tabs_backcompat;
2357
+ }
2358
 
2359
+ return $subnav_output;
2360
  }
2361
 
2362
+ /**
2363
+ * Output the group count for the displayed user.
2364
+ */
2365
  function bp_group_total_for_member() {
2366
  echo bp_get_group_total_for_member();
2367
  }
2368
+ /**
2369
+ * Get the group count for the displayed user.
2370
+ *
2371
+ * @return string
2372
+ */
2373
  function bp_get_group_total_for_member() {
2374
  return apply_filters( 'bp_get_group_total_for_member', BP_Groups_Member::total_group_count() );
2375
  }
2376
 
2377
+ /**
2378
+ * Output the 'action' attribute for a group form.
2379
+ *
2380
+ * @param string $page Page slug.
2381
+ */
2382
  function bp_group_form_action( $page ) {
2383
  echo bp_get_group_form_action( $page );
2384
  }
2385
+ /**
2386
+ * Generate the 'action' attribute for a group form.
2387
+ *
2388
+ * @param string $page Page slug.
2389
+ * @param object $group Optional. Group object. Default: current group
2390
+ * in the loop.
2391
+ * @return string
2392
+ */
2393
  function bp_get_group_form_action( $page, $group = false ) {
2394
  global $groups_template;
2395
 
2399
  return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . $page );
2400
  }
2401
 
2402
+ /**
2403
+ * Output the 'action' attribute for a group admin form.
2404
+ *
2405
+ * @param string $page Optional. Page slug.
2406
+ */
2407
  function bp_group_admin_form_action( $page = false ) {
2408
  echo bp_get_group_admin_form_action( $page );
2409
  }
2410
+ /**
2411
+ * Generate the 'action' attribute for a group admin form.
2412
+ *
2413
+ * @param string $page Optional. Page slug.
2414
+ * @param object $group Optional. Group object. Default: current group
2415
+ * in the loop.
2416
+ * @return string
2417
+ */
2418
  function bp_get_group_admin_form_action( $page = false, $group = false ) {
2419
  global $groups_template;
2420
 
2427
  return apply_filters( 'bp_group_admin_form_action', bp_get_group_permalink( $group ) . 'admin/' . $page );
2428
  }
2429
 
2430
+ /**
2431
+ * Determine whether the logged-in user has requested membership to a group.
2432
+ *
2433
+ * @param object $group Optional. Group object. Default: current group in
2434
+ * the loop.
2435
+ * @return bool
2436
+ */
2437
  function bp_group_has_requested_membership( $group = false ) {
2438
  global $groups_template;
2439
 
2447
  }
2448
 
2449
  /**
2450
+ * Check if current user is member of a group.
2451
  *
2452
+ * @global object $groups_template
2453
  *
2454
+ * @param object $group Optional. Group to check is_member. Default: current
2455
+ * group in the loop.
2456
+ * @return bool If user is member of group or not.
 
 
 
2457
  */
2458
  function bp_group_is_member( $group = false ) {
2459
  global $groups_template;
2471
  /**
2472
  * Check whether the current user has an outstanding invite to the current group in the loop.
2473
  *
2474
+ * @param object $group Optional. Group data object. Default: the current
2475
  * group in the groups loop.
2476
  * @return bool True if the user has an outstanding invite, otherwise false.
2477
  */
2539
  return (bool) apply_filters( 'bp_group_is_user_banned', $retval );
2540
  }
2541
 
2542
+ /**
2543
+ * Output the URL for accepting an invitation to the current group in the loop.
2544
+ */
2545
  function bp_group_accept_invite_link() {
2546
  echo bp_get_group_accept_invite_link();
2547
  }
2548
+ /**
2549
+ * Generate the URL for accepting an invitation to a group.
2550
+ *
2551
+ * @param object $group Optional. Group object. Default: Current group
2552
+ * in the loop.
2553
+ * @return string
2554
+ */
2555
  function bp_get_group_accept_invite_link( $group = false ) {
2556
  global $groups_template, $bp;
2557
 
2561
  return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/accept/' . $group->id ), 'groups_accept_invite' ) );
2562
  }
2563
 
2564
+ /**
2565
+ * Output the URL for accepting an invitation to the current group in the loop.
2566
+ */
2567
  function bp_group_reject_invite_link() {
2568
  echo bp_get_group_reject_invite_link();
2569
  }
2570
+ /**
2571
+ * Generate the URL for rejecting an invitation to a group.
2572
+ *
2573
+ * @param object $group Optional. Group object. Default: Current group
2574
+ * in the loop.
2575
+ * @return string
2576
+ */
2577
  function bp_get_group_reject_invite_link( $group = false ) {
2578
  global $groups_template, $bp;
2579
 
2583
  return apply_filters( 'bp_get_group_reject_invite_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/reject/' . $group->id ), 'groups_reject_invite' ) );
2584
  }
2585
 
2586
+ /**
2587
+ * Output the URL for confirming a request to leave a group.
2588
+ */
2589
  function bp_group_leave_confirm_link() {
2590
  echo bp_get_group_leave_confirm_link();
2591
  }
2592
+ /**
2593
+ * Generate the URL for confirming a request to leave a group.
2594
+ *
2595
+ * @param object $group Optional. Group object. Default: Current group
2596
+ * in the loop.
2597
+ * @return string
2598
+ */
2599
  function bp_get_group_leave_confirm_link( $group = false ) {
2600
  global $groups_template;
2601
 
2605
  return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group/yes', 'groups_leave_group' ) );
2606
  }
2607
 
2608
+ /**
2609
+ * Output the URL for rejecting a request to leave a group.
2610
+ */
2611
  function bp_group_leave_reject_link() {
2612
  echo bp_get_group_leave_reject_link();
2613
  }
2614
+ /**
2615
+ * Generate the URL for rejecting a request to leave a group.
2616
+ *
2617
+ * @param object $group Optional. Group object. Default: Current group
2618
+ * in the loop.
2619
+ * @return string
2620
+ */
2621
  function bp_get_group_leave_reject_link( $group = false ) {
2622
  global $groups_template;
2623
 
2627
  return apply_filters( 'bp_get_group_leave_reject_link', bp_get_group_permalink( $group ) );
2628
  }
2629
 
2630
+ /**
2631
+ * Output the 'action' attribute for a group send invite form.
2632
+ */
2633
  function bp_group_send_invite_form_action() {
2634
  echo bp_get_group_send_invite_form_action();
2635
  }
2636
+ /**
2637
+ * Output the 'action' attribute for a group send invite form.
2638
+ *
2639
+ * @param object $page Optional. Group object. Default: current group
2640
+ * in the loop.
2641
+ * @return string
2642
+ */
2643
  function bp_get_group_send_invite_form_action( $group = false ) {
2644
  global $groups_template;
2645
 
2649
  return apply_filters( 'bp_group_send_invite_form_action', bp_get_group_permalink( $group ) . 'send-invites/send' );
2650
  }
2651
 
2652
+ /**
2653
+ * Determine whether the current user has friends to invite to a group.
2654
+ *
2655
+ * @param object $group Optional. Group object. Default: current group in
2656
+ * the loop.
2657
+ * @return bool
2658
+ */
2659
  function bp_has_friends_to_invite( $group = false ) {
2660
  global $groups_template;
2661
 
2672
  }
2673
 
2674
  /**
2675
+ * Output a 'New Topic' button for a group.
2676
  *
2677
  * @since BuddyPress (1.2.7)
2678
  *
2679
+ * @param BP_Groups_Group|bool $group The BP Groups_Group object if passed,
2680
+ * boolean false if not passed.
2681
  */
2682
  function bp_group_new_topic_button( $group = false ) {
2683
  echo bp_get_group_new_topic_button( $group );
2687
  *
2688
  * @since BuddyPress (1.2.7)
2689
  *
2690
+ * @param BP_Groups_Group|bool $group The BP Groups_Group object if
2691
+ * passed, boolean false if not passed.
2692
+ * @return string HTML code for the button.
 
 
 
 
2693
  */
2694
  function bp_get_group_new_topic_button( $group = false ) {
2695
  global $groups_template;
2866
  'component' => 'groups',
2867
  'link_text' => __( 'Create a Group', 'buddypress' ),
2868
  'link_title' => __( 'Create a Group', 'buddypress' ),
2869
+ 'link_class' => 'group-create no-ajax',
2870
  'link_href' => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_groups_root_slug() ) . trailingslashit( 'create' ),
2871
  'wrapper' => false,
2872
+ 'block_self' => false,
2873
  );
2874
 
2875
  return bp_get_button( apply_filters( 'bp_get_group_create_button', $button_args ) );
2876
  }
2877
 
2878
+ /**
2879
+ * Output the Create a Group nav item.
2880
+ *
2881
+ * @since BuddyPress (2.2.0)
2882
+ */
2883
+ function bp_group_create_nav_item() {
2884
+ echo bp_get_group_create_nav_item();
2885
+ }
2886
+
2887
+ /**
2888
+ * Get the Create a Group nav item.
2889
+ *
2890
+ * @since BuddyPress (2.2.0)
2891
+ *
2892
+ * @return string
2893
+ */
2894
+ function bp_get_group_create_nav_item() {
2895
+ // Get the create a group button
2896
+ $create_group_button = bp_get_group_create_button();
2897
+
2898
+ // Make sure the button is available
2899
+ if ( empty( $create_group_button ) ) {
2900
+ return;
2901
+ }
2902
+
2903
+ $output = '<li id="group-create-nav">' . $create_group_button . '</li>';
2904
+
2905
+ return apply_filters( 'bp_get_group_create_nav_item', $output );
2906
+ }
2907
+
2908
+ /**
2909
+ * Checks if a specific theme is still filtering the Groups directory title
2910
+ * if so, transform the title button into a Groups directory nav item.
2911
+ *
2912
+ * @since BuddyPress (2.2.0)
2913
+ *
2914
+ * @uses bp_group_create_nav_item() to output the create a Group nav item
2915
+ * @return string HTML Output
2916
+ */
2917
+ function bp_group_backcompat_create_nav_item() {
2918
+ // Bail if the Groups nav item is already used by bp-legacy
2919
+ if ( has_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 ) ) {
2920
+ return;
2921
+ }
2922
+
2923
+ // Bail if the theme is not filtering the Groups directory title
2924
+ if ( ! has_filter( 'bp_groups_directory_header' ) ) {
2925
+ return;
2926
+ }
2927
+
2928
+ bp_group_create_nav_item();
2929
+ }
2930
+ add_action( 'bp_groups_directory_group_filter', 'bp_group_backcompat_create_nav_item', 1000 );
2931
+
2932
  /**
2933
  * Prints a message if the group is not visible to the current user (it is a
2934
  * hidden or private group, and the user does not have access).
2947
  if ( ! bp_group_has_requested_membership() ) {
2948
  if ( is_user_logged_in() && bp_group_is_invited() ) {
2949
  $message = __( 'You must accept your pending invitation before you can access this private group.', 'buddypress' );
2950
+ } elseif ( is_user_logged_in() ) {
2951
  $message = __( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
2952
  } else {
2953
  $message = __( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
3109
  }
3110
 
3111
  $this->pag_links = paginate_links( array(
3112
+ 'base' => add_query_arg( array( 'mlpage' => '%#%' ), $base_url ),
3113
+ 'format' => '',
3114
+ 'total' => ! empty( $this->pag_num ) ? ceil( $this->total_member_count / $this->pag_num ) : $this->total_member_count,
3115
+ 'current' => $this->pag_page,
3116
  'prev_text' => '&larr;',
3117
  'next_text' => '&rarr;',
3118
+ 'mid_size' => 1,
3119
+ 'add_args' => array(),
3120
  ));
3121
  }
3122
 
4141
  }
4142
 
4143
  $this->pag_links = paginate_links( array(
4144
+ 'base' => add_query_arg( 'mrpage', '%#%' ),
4145
+ 'format' => '',
4146
+ 'total' => ceil( $this->total_request_count / $this->pag_num ),
4147
+ 'current' => $this->pag_page,
4148
  'prev_text' => '&larr;',
4149
  'next_text' => '&rarr;',
4150
+ 'mid_size' => 1,
4151
+ 'add_args' => array(),
4152
  ) );
4153
  }
4154
 
4394
  'prev_text' => '&larr;',
4395
  'next_text' => '&rarr;',
4396
  'mid_size' => 1,
4397
+ 'add_args' => array(),
4398
  ) );
4399
  } else {
4400
  $this->pag_links = '';
4466
  $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count( $user_id );
4467
  }
4468
 
 
 
 
 
4469
  $this->invite->user->total_blogs = null;
4470
 
4471
+ $this->invite->group_id = $group_id; // Global'ed in bp_group_has_invites()
4472
 
4473
  if ( 0 == $this->current_invite ) // loop has just started
4474
  do_action('loop_start');
bp-groups/bp-groups-widgets.php CHANGED
@@ -92,7 +92,7 @@ class BP_Groups_Widget extends WP_Widget {
92
  printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
93
  if ( 'active' == $instance['group_default'] )
94
  printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() );
95
- else if ( 'popular' == $instance['group_default'] )
96
  bp_group_member_count();
97
  ?>
98
  </span>
@@ -202,9 +202,9 @@ function groups_ajax_widget_groups_list() {
202
  <?php
203
  if ( 'newest-groups' == $_POST['filter'] ) {
204
  printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
205
- } else if ( 'recently-active-groups' == $_POST['filter'] ) {
206
  printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() );
207
- } else if ( 'popular-groups' == $_POST['filter'] ) {
208
  bp_group_member_count();
209
  }
210
  ?>
92
  printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
93
  if ( 'active' == $instance['group_default'] )
94
  printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() );
95
+ elseif ( 'popular' == $instance['group_default'] )
96
  bp_group_member_count();
97
  ?>
98
  </span>
202
  <?php
203
  if ( 'newest-groups' == $_POST['filter'] ) {
204
  printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
205
+ } elseif ( 'recently-active-groups' == $_POST['filter'] ) {
206
  printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() );
207
+ } elseif ( 'popular-groups' == $_POST['filter'] ) {
208
  bp_group_member_count();
209
  }
210
  ?>
bp-groups/js/widget-groups.js CHANGED
@@ -17,7 +17,7 @@ jQuery(document).ready( function() {
17
  function(response)
18
  {
19
  jQuery(link).removeClass('loading');
20
- groups_wiget_response(response);
21
  });
22
 
23
  return false;
@@ -25,7 +25,7 @@ jQuery(document).ready( function() {
25
  );
26
  });
27
 
28
- function groups_wiget_response(response) {
29
  response = response.substr(0, response.length-1);
30
  response = response.split('[[SPLIT]]');
31
 
17
  function(response)
18
  {
19
  jQuery(link).removeClass('loading');
20
+ groups_widget_response(response);
21
  });
22
 
23
  return false;
25
  );
26
  });
27
 
28
+ function groups_widget_response(response) {
29
  response = response.substr(0, response.length-1);
30
  response = response.split('[[SPLIT]]');
31
 
bp-groups/js/widget-groups.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- function groups_wiget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#groups-list").fadeOut(200,function(){jQuery(".widget ul#groups-list").html(a[1]),jQuery(".widget ul#groups-list").fadeIn(200)}):jQuery(".widget ul#groups-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#groups-list").html(b),jQuery(".widget ul#groups-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#groups-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#groups-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_groups_list",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-groups").val(),max_groups:jQuery("input#groups_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),groups_wiget_response(b)}),!1})});
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ function groups_widget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#groups-list").fadeOut(200,function(){jQuery(".widget ul#groups-list").html(a[1]),jQuery(".widget ul#groups-list").fadeIn(200)}):jQuery(".widget ul#groups-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#groups-list").html(b),jQuery(".widget ul#groups-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#groups-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#groups-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_groups_list",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-groups").val(),max_groups:jQuery("input#groups_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),groups_widget_response(b)}),!1})});
bp-loader.php CHANGED
@@ -11,17 +11,17 @@
11
  /**
12
  * Plugin Name: BuddyPress
13
  * Plugin URI: http://buddypress.org
14
- * Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
15
  * Author: The BuddyPress Community
16
  * Author URI: http://buddypress.org/community/members/
17
- * Version: 2.1.1
18
  * Text Domain: buddypress
19
  * Domain Path: /bp-languages/
20
  * License: GPLv2 or later (license.txt)
21
  */
22
 
23
  // Exit if accessed directly
24
- if ( !defined( 'ABSPATH' ) ) exit;
25
 
26
  /** Constants *****************************************************************/
27
 
@@ -178,14 +178,14 @@ class BuddyPress {
178
  public function __isset( $key ) { return isset( $this->data[$key] ); }
179
 
180
  /**
181
- * Magic method for getting BuddyPress varibles.
182
  *
183
  * @since BuddyPress (1.7.0)
184
  */
185
  public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
186
 
187
  /**
188
- * Magic method for setting BuddyPress varibles.
189
  *
190
  * @since BuddyPress (1.7.0)
191
  */
@@ -222,8 +222,9 @@ class BuddyPress {
222
 
223
  // Place your custom code (actions/filters) in a file called
224
  // '/plugins/bp-custom.php' and it will be loaded before anything else.
225
- if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
226
  require( WP_PLUGIN_DIR . '/bp-custom.php' );
 
227
 
228
  // Path and URL
229
  if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
@@ -282,8 +283,9 @@ class BuddyPress {
282
  // search requests are loaded
283
  //
284
  // @todo Make this better
285
- if ( !defined( 'BP_SEARCH_SLUG' ) )
286
  define( 'BP_SEARCH_SLUG', 'search' );
 
287
  }
288
 
289
  /**
@@ -300,8 +302,8 @@ class BuddyPress {
300
 
301
  /** Versions **********************************************************/
302
 
303
- $this->version = '2.1.1';
304
- $this->db_version = 8311;
305
 
306
  /** Loading ***********************************************************/
307
 
@@ -365,7 +367,7 @@ class BuddyPress {
365
  // Languages
366
  $this->lang_dir = $this->plugin_dir . 'bp-languages';
367
 
368
- // Templates (theme compatability)
369
  $this->themes_dir = $this->plugin_dir . 'bp-templates';
370
  $this->themes_url = $this->plugin_url . 'bp-templates';
371
 
@@ -395,10 +397,14 @@ class BuddyPress {
395
  private function legacy_constants() {
396
 
397
  // Define the BuddyPress version
398
- if ( !defined( 'BP_VERSION' ) ) define( 'BP_VERSION', $this->version );
 
 
399
 
400
  // Define the database version
401
- if ( !defined( 'BP_DB_VERSION' ) ) define( 'BP_DB_VERSION', $this->db_version );
 
 
402
  }
403
 
404
  /**
@@ -419,7 +425,7 @@ class BuddyPress {
419
 
420
  /** Update/Install ****************************************************/
421
 
422
- // Theme compatability
423
  require( $this->plugin_dir . 'bp-core/bp-core-template-loader.php' );
424
  require( $this->plugin_dir . 'bp-core/bp-core-theme-compatibility.php' );
425
 
@@ -432,6 +438,7 @@ class BuddyPress {
432
  require( $this->plugin_dir . 'bp-core/bp-core-update.php' );
433
  require( $this->plugin_dir . 'bp-core/bp-core-options.php' );
434
  require( $this->plugin_dir . 'bp-core/bp-core-classes.php' );
 
435
  require( $this->plugin_dir . 'bp-core/bp-core-filters.php' );
436
  require( $this->plugin_dir . 'bp-core/bp-core-avatars.php' );
437
  require( $this->plugin_dir . 'bp-core/bp-core-widgets.php' );
@@ -473,8 +480,9 @@ class BuddyPress {
473
  add_action( 'deactivate_' . $this->basename, 'bp_deactivation' );
474
 
475
  // If BuddyPress is being deactivated, do not add any actions
476
- if ( bp_is_deactivation( $this->basename ) )
477
  return;
 
478
 
479
  // Array of BuddyPress core actions
480
  $actions = array(
@@ -492,8 +500,11 @@ class BuddyPress {
492
  );
493
 
494
  // Add the actions
495
- foreach( $actions as $class_action )
496
- add_action( 'bp_' . $class_action, array( $this, $class_action ), 5 );
 
 
 
497
 
498
  // All BuddyPress actions are setup (includes bbp-core-hooks.php)
499
  do_action_ref_array( 'bp_after_setup_actions', array( &$this ) );
@@ -578,15 +589,16 @@ class BuddyPress {
578
  }
579
 
580
  /**
581
- * Set up the default BuddyPress theme compatability location.
582
  *
583
  * @since BuddyPress (1.7.0)
584
  */
585
  public function setup_theme() {
586
 
587
  // Bail if something already has this under control
588
- if ( ! empty( $this->theme_compat->theme ) )
589
  return;
 
590
 
591
  // Setup the theme package to use for compatibility
592
  bp_setup_theme_compat( bp_get_theme_package_id() );
11
  /**
12
  * Plugin Name: BuddyPress
13
  * Plugin URI: http://buddypress.org
14
+ * Description: BuddyPress helps you run any kind of social network on your WordPress, with member profiles, activity streams, user groups, messaging, and more.
15
  * Author: The BuddyPress Community
16
  * Author URI: http://buddypress.org/community/members/
17
+ * Version: 2.2-beta
18
  * Text Domain: buddypress
19
  * Domain Path: /bp-languages/
20
  * License: GPLv2 or later (license.txt)
21
  */
22
 
23
  // Exit if accessed directly
24
+ defined( 'ABSPATH' ) || exit;
25
 
26
  /** Constants *****************************************************************/
27
 
178
  public function __isset( $key ) { return isset( $this->data[$key] ); }
179
 
180
  /**
181
+ * Magic method for getting BuddyPress variables.
182
  *
183
  * @since BuddyPress (1.7.0)
184
  */
185
  public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
186
 
187
  /**
188
+ * Magic method for setting BuddyPress variables.
189
  *
190
  * @since BuddyPress (1.7.0)
191
  */
222
 
223
  // Place your custom code (actions/filters) in a file called
224
  // '/plugins/bp-custom.php' and it will be loaded before anything else.
225
+ if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) ) {
226
  require( WP_PLUGIN_DIR . '/bp-custom.php' );
227
+ }
228
 
229
  // Path and URL
230
  if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
283
  // search requests are loaded
284
  //
285
  // @todo Make this better
286
+ if ( ! defined( 'BP_SEARCH_SLUG' ) ) {
287
  define( 'BP_SEARCH_SLUG', 'search' );
288
+ }
289
  }
290
 
291
  /**
302
 
303
  /** Versions **********************************************************/
304
 
305
+ $this->version = '2.2-beta';
306
+ $this->db_version = 9181;
307
 
308
  /** Loading ***********************************************************/
309
 
367
  // Languages
368
  $this->lang_dir = $this->plugin_dir . 'bp-languages';
369
 
370
+ // Templates (theme compatibility)
371
  $this->themes_dir = $this->plugin_dir . 'bp-templates';
372
  $this->themes_url = $this->plugin_url . 'bp-templates';
373
 
397
  private function legacy_constants() {
398
 
399
  // Define the BuddyPress version
400
+ if ( ! defined( 'BP_VERSION' ) ) {
401
+ define( 'BP_VERSION', $this->version );
402
+ }
403
 
404
  // Define the database version
405
+ if ( ! defined( 'BP_DB_VERSION' ) ) {
406
+ define( 'BP_DB_VERSION', $this->db_version );
407
+ }
408
  }
409
 
410
  /**
425
 
426
  /** Update/Install ****************************************************/
427
 
428
+ // Theme compatibility
429
  require( $this->plugin_dir . 'bp-core/bp-core-template-loader.php' );
430
  require( $this->plugin_dir . 'bp-core/bp-core-theme-compatibility.php' );
431
 
438
  require( $this->plugin_dir . 'bp-core/bp-core-update.php' );
439
  require( $this->plugin_dir . 'bp-core/bp-core-options.php' );
440
  require( $this->plugin_dir . 'bp-core/bp-core-classes.php' );
441
+ require( $this->plugin_dir . 'bp-core/bp-core-taxonomy.php' );
442
  require( $this->plugin_dir . 'bp-core/bp-core-filters.php' );
443
  require( $this->plugin_dir . 'bp-core/bp-core-avatars.php' );
444
  require( $this->plugin_dir . 'bp-core/bp-core-widgets.php' );
480
  add_action( 'deactivate_' . $this->basename, 'bp_deactivation' );
481
 
482
  // If BuddyPress is being deactivated, do not add any actions
483
+ if ( bp_is_deactivation( $this->basename ) ) {
484
  return;
485
+ }
486
 
487
  // Array of BuddyPress core actions
488
  $actions = array(
500
  );
501
 
502
  // Add the actions
503
+ foreach( $actions as $class_action ) {
504
+ if ( method_exists( $this, $class_action ) ) {
505
+ add_action( 'bp_' . $class_action, array( $this, $class_action ), 5 );
506
+ }
507
+ }
508
 
509
  // All BuddyPress actions are setup (includes bbp-core-hooks.php)
510
  do_action_ref_array( 'bp_after_setup_actions', array( &$this ) );
589
  }
590
 
591
  /**
592
+ * Set up the default BuddyPress theme compatibility location.
593
  *
594
  * @since BuddyPress (1.7.0)
595
  */
596
  public function setup_theme() {
597
 
598
  // Bail if something already has this under control
599
+ if ( ! empty( $this->theme_compat->theme ) ) {
600
  return;
601
+ }
602
 
603
  // Setup the theme package to use for compatibility
604
  bp_setup_theme_compat( bp_get_theme_package_id() );
bp-members/admin/bp-members-classes.php CHANGED
@@ -120,6 +120,14 @@ class BP_Members_List_Table extends WP_Users_List_Table {
120
  * @since BuddyPress (2.0.0)
121
  */
122
  public function get_columns() {
 
 
 
 
 
 
 
 
123
  return apply_filters( 'bp_members_signup_columns', array(
124
  'cb' => '<input type="checkbox" />',
125
  'username' => __( 'Username', 'buddypress' ),
@@ -277,6 +285,14 @@ class BP_Members_List_Table extends WP_Users_List_Table {
277
  $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
278
  }
279
 
 
 
 
 
 
 
 
 
280
  $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
281
 
282
  echo $this->row_actions( $actions );
@@ -336,14 +352,23 @@ class BP_Members_List_Table extends WP_Users_List_Table {
336
  }
337
 
338
  /**
339
- * Allow plugins to add their costum column.
340
  *
341
- * @since BuddyPress 2.1.0
342
  *
343
  * @param object $signup_object The signup data object.
344
  * @param string the column name.
345
  */
346
  function column_default( $signup_object = null, $column_name = '' ) {
 
 
 
 
 
 
 
 
 
347
  return apply_filters( 'bp_members_signup_custom_column', '', $column_name, $signup_object );
348
  }
349
  }
@@ -448,6 +473,14 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
448
  * @since BuddyPress (2.0.0)
449
  */
450
  public function get_columns() {
 
 
 
 
 
 
 
 
451
  return apply_filters( 'bp_members_ms_signup_columns', array(
452
  'cb' => '<input type="checkbox" />',
453
  'username' => __( 'Username', 'buddypress' ),
@@ -600,6 +633,7 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
600
  $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
601
  }
602
 
 
603
  $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
604
 
605
  echo $this->row_actions( $actions );
@@ -673,7 +707,7 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
673
  }
674
 
675
  /**
676
- * Allow plugins to add their costum column.
677
  *
678
  * @since BuddyPress 2.1.0
679
  *
@@ -681,6 +715,15 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
681
  * @param string the column name.
682
  */
683
  function column_default( $signup_object = null, $column_name = '' ) {
 
 
 
 
 
 
 
 
 
684
  return apply_filters( 'bp_members_ms_signup_custom_column', '', $column_name, $signup_object );
685
  }
686
  }
120
  * @since BuddyPress (2.0.0)
121
  */
122
  public function get_columns() {
123
+
124
+ /**
125
+ * Filters the single site Members signup columns.
126
+ *
127
+ * @since BuddyPress (2.0.0)
128
+ *
129
+ * @param array $value Array of columns to display.
130
+ */
131
  return apply_filters( 'bp_members_signup_columns', array(
132
  'cb' => '<input type="checkbox" />',
133
  'username' => __( 'Username', 'buddypress' ),
285
  $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
286
  }
287
 
288
+ /**
289
+ * Filters the multisite row actions for each user in list.
290
+ *
291
+ * @since BuddyPress (2.0.0)
292
+ *
293
+ * @param array $actions Array of actions and corresponding links.
294
+ * @param object $signup_object The signup data object.
295
+ */
296
  $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
297
 
298
  echo $this->row_actions( $actions );
352
  }
353
 
354
  /**
355
+ * Allow plugins to add their custom column.
356
  *
357
+ * @since BuddyPress (2.1.0)
358
  *
359
  * @param object $signup_object The signup data object.
360
  * @param string the column name.
361
  */
362
  function column_default( $signup_object = null, $column_name = '' ) {
363
+
364
+ /**
365
+ * Filters the single site custom columns for plugins.
366
+ *
367
+ * @since BuddyPress (2.1.0)
368
+ *
369
+ * @param string $column_name The column name.
370
+ * @param object $signup_object The signup data object.
371
+ */
372
  return apply_filters( 'bp_members_signup_custom_column', '', $column_name, $signup_object );
373
  }
374
  }
473
  * @since BuddyPress (2.0.0)
474
  */
475
  public function get_columns() {
476
+
477
+ /**
478
+ * Filters the multisite Members signup columns.
479
+ *
480
+ * @since BuddyPress (2.0.0)
481
+ *
482
+ * @param array $value Array of columns to display.
483
+ */
484
  return apply_filters( 'bp_members_ms_signup_columns', array(
485
  'cb' => '<input type="checkbox" />',
486
  'username' => __( 'Username', 'buddypress' ),
633
  $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
634
  }
635
 
636
+ /** This filter is documented in bp-members/admin/bp-members-classes.php */
637
  $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
638
 
639
  echo $this->row_actions( $actions );
707
  }
708
 
709
  /**
710
+ * Allow plugins to add their custom column.
711
  *
712
  * @since BuddyPress 2.1.0
713
  *
715
  * @param string the column name.
716
  */
717
  function column_default( $signup_object = null, $column_name = '' ) {
718
+
719
+ /**
720
+ * Filters the multisite custom columns for plugins.
721
+ *
722
+ * @since BuddyPress (2.1.0)
723
+ *
724
+ * @param string $column_name The column name.
725
+ * @param object $signup_object The signup data object.
726
+ */
727
  return apply_filters( 'bp_members_ms_signup_custom_column', '', $column_name, $signup_object );
728
  }
729
  }
bp-members/admin/css/admin-rtl.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:5em}div#profile-page.wrap form#your-profile #profile-nav{position:absolute;top:-3.65em;width:97%}div#community-profile-page #profile-nav{margin-bottom:1em}#bp_members_admin_user_stats ul{margin-bottom:0}div#community-profile-page a.bp-xprofile-avatar-user-admin:before,div#community-profile-page li.bp-blogs-profile-stats:before,div#community-profile-page li.bp-friends-profile-stats:before,div#community-profile-page li.bp-groups-profile-stats:before,div#community-profile-page li.bp-members-profile-stats:before{font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 0 0 2px;top:0;right:-1px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#888}div#community-profile-page li.bp-members-profile-stats:before{content:"\f130"}div#community-profile-page li.bp-friends-profile-stats:before{content:"\f454"}div#community-profile-page li.bp-groups-profile-stats:before{content:"\f456"}div#community-profile-page li.bp-blogs-profile-stats:before{content:"\f120"}div#community-profile-page a.bp-xprofile-avatar-user-admin:before{content:"\f182"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img{max-width:100%;height:auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}#community-profile-page #submitdiv #publishing-action{float:none;width:100%}.bp-view-profile{float:right}.alt{background:0 0}.bp-profile-field{border-bottom:dotted 1px #ccc;font-size:14px;margin:15px 0;padding:10px}.bp-profile-field:last-child{border-bottom:0}.bp-profile-field p{font-size:14px}.bp-profile-field .datebox>label,.bp-profile-field .radio>label,.bp-profile-field>label{display:inline-block;font-weight:600;text-align:right;vertical-align:middle;width:200px}.field_type_checkbox .checkbox>label,.field_type_multiselectbox>label,.field_type_radio .radio>label,.field_type_textarea>label{vertical-align:top}.bp-profile-field .description{margin:10px 200px 10px 0;text-align:right}.clear-value{display:block;font-size:12px;margin-right:200px}.field_type_checkbox .checkbox>label+label{display:block;margin-right:200px;width:auto}.field_type_radio .radio div:not(.field-visibility-settings) label{display:block}.field_type_radio .radio div:not(.field-visibility-settings){display:inline-block}.field-visibility-settings-notoggle,.field-visibility-settings-toggle{margin:10px 200px 10px 0;text-align:right}.field-visibility-settings{display:none;margin-right:200px}.field-visibility-settings .button{margin-bottom:15px}#normal-sortables .field-visibility-settings legend{font-size:16px;margin-bottom:10px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:5em}div#profile-page.wrap form#your-profile #profile-nav{position:absolute;top:-3.65em;width:97%}div#community-profile-page #profile-nav{margin-bottom:1em}#bp_members_admin_user_stats ul{margin-bottom:0}div#community-profile-page a.bp-xprofile-avatar-user-admin:before,div#community-profile-page li.bp-blogs-profile-stats:before,div#community-profile-page li.bp-friends-profile-stats:before,div#community-profile-page li.bp-groups-profile-stats:before,div#community-profile-page li.bp-members-profile-stats:before{font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 0 0 2px;top:0;right:-1px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#888}div#community-profile-page li.bp-members-profile-stats:before{content:"\f130"}div#community-profile-page li.bp-friends-profile-stats:before{content:"\f454"}div#community-profile-page li.bp-groups-profile-stats:before{content:"\f456"}div#community-profile-page li.bp-blogs-profile-stats:before{content:"\f120"}div#community-profile-page a.bp-xprofile-avatar-user-admin:before{content:"\f182"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img{max-width:100%;height:auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}#community-profile-page #submitdiv #publishing-action{float:none;width:100%}.bp-view-profile{float:right}.alt{background:0 0}.bp-profile-field{border-bottom:dotted 1px #ccc;font-size:14px;margin:15px 0;padding:10px}.bp-profile-field:last-child{border-bottom:0}.bp-profile-field p{font-size:14px}.bp-profile-field .datebox>label,.bp-profile-field .radio>label,.bp-profile-field>label{display:inline-block;font-weight:600;text-align:right;vertical-align:middle;width:200px}.field_type_checkbox .checkbox>label,.field_type_multiselectbox>label,.field_type_radio .radio>label,.field_type_textarea>label{vertical-align:top}.bp-profile-field .description{margin:10px 200px 10px 0;text-align:right}.clear-value{display:block;font-size:12px;margin-right:200px}.field_type_checkbox .checkbox>label+label{display:block;margin-right:200px;width:auto}.field_type_radio .radio div:not(.field-visibility-settings) label{display:block}.field_type_radio .radio div:not(.field-visibility-settings){display:inline-block}.field-visibility-settings-notoggle,.field-visibility-settings-toggle{margin:10px 200px 10px 0;text-align:right}.field-visibility-settings{display:none;margin-right:200px}.field-visibility-settings .button{margin-bottom:15px}#normal-sortables .field-visibility-settings legend{font-size:16px;margin-bottom:10px}
bp-members/admin/css/admin.min.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:09 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:5em}div#profile-page.wrap form#your-profile #profile-nav{position:absolute;top:-3.65em;width:97%}div#community-profile-page #profile-nav{margin-bottom:1em}#bp_members_admin_user_stats ul{margin-bottom:0}div#community-profile-page a.bp-xprofile-avatar-user-admin:before,div#community-profile-page li.bp-blogs-profile-stats:before,div#community-profile-page li.bp-friends-profile-stats:before,div#community-profile-page li.bp-groups-profile-stats:before,div#community-profile-page li.bp-members-profile-stats:before{font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 2px 0 0;top:0;left:-1px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#888}div#community-profile-page li.bp-members-profile-stats:before{content:"\f130"}div#community-profile-page li.bp-friends-profile-stats:before{content:"\f454"}div#community-profile-page li.bp-groups-profile-stats:before{content:"\f456"}div#community-profile-page li.bp-blogs-profile-stats:before{content:"\f120"}div#community-profile-page a.bp-xprofile-avatar-user-admin:before{content:"\f182"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img{max-width:100%;height:auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}#community-profile-page #submitdiv #publishing-action{float:none;width:100%}.bp-view-profile{float:left}.alt{background:0 0}.bp-profile-field{border-bottom:dotted 1px #ccc;font-size:14px;margin:15px 0;padding:10px}.bp-profile-field:last-child{border-bottom:0}.bp-profile-field p{font-size:14px}.bp-profile-field .datebox>label,.bp-profile-field .radio>label,.bp-profile-field>label{display:inline-block;font-weight:600;text-align:left;vertical-align:middle;width:200px}.field_type_checkbox .checkbox>label,.field_type_multiselectbox>label,.field_type_radio .radio>label,.field_type_textarea>label{vertical-align:top}.bp-profile-field .description{margin:10px 0 10px 200px;text-align:left}.clear-value{display:block;font-size:12px;margin-left:200px}.field_type_checkbox .checkbox>label+label{display:block;margin-left:200px;width:auto}.field_type_radio .radio div:not(.field-visibility-settings) label{display:block}.field_type_radio .radio div:not(.field-visibility-settings){display:inline-block}.field-visibility-settings-notoggle,.field-visibility-settings-toggle{margin:10px 0 10px 200px;text-align:left}.field-visibility-settings{display:none;margin-left:200px}.field-visibility-settings .button{margin-bottom:15px}#normal-sortables .field-visibility-settings legend{font-size:16px;margin-bottom:10px}
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:37 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:5em}div#profile-page.wrap form#your-profile #profile-nav{position:absolute;top:-3.65em;width:97%}div#community-profile-page #profile-nav{margin-bottom:1em}#bp_members_admin_user_stats ul{margin-bottom:0}div#community-profile-page a.bp-xprofile-avatar-user-admin:before,div#community-profile-page li.bp-blogs-profile-stats:before,div#community-profile-page li.bp-friends-profile-stats:before,div#community-profile-page li.bp-groups-profile-stats:before,div#community-profile-page li.bp-members-profile-stats:before{font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 2px 0 0;top:0;left:-1px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#888}div#community-profile-page li.bp-members-profile-stats:before{content:"\f130"}div#community-profile-page li.bp-friends-profile-stats:before{content:"\f454"}div#community-profile-page li.bp-groups-profile-stats:before{content:"\f456"}div#community-profile-page li.bp-blogs-profile-stats:before{content:"\f120"}div#community-profile-page a.bp-xprofile-avatar-user-admin:before{content:"\f182"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img{max-width:100%;height:auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}#community-profile-page #submitdiv #publishing-action{float:none;width:100%}.bp-view-profile{float:left}.alt{background:0 0}.bp-profile-field{border-bottom:dotted 1px #ccc;font-size:14px;margin:15px 0;padding:10px}.bp-profile-field:last-child{border-bottom:0}.bp-profile-field p{font-size:14px}.bp-profile-field .datebox>label,.bp-profile-field .radio>label,.bp-profile-field>label{display:inline-block;font-weight:600;text-align:left;vertical-align:middle;width:200px}.field_type_checkbox .checkbox>label,.field_type_multiselectbox>label,.field_type_radio .radio>label,.field_type_textarea>label{vertical-align:top}.bp-profile-field .description{margin:10px 0 10px 200px;text-align:left}.clear-value{display:block;font-size:12px;margin-left:200px}.field_type_checkbox .checkbox>label+label{display:block;margin-left:200px;width:auto}.field_type_radio .radio div:not(.field-visibility-settings) label{display:block}.field_type_radio .radio div:not(.field-visibility-settings){display:inline-block}.field-visibility-settings-notoggle,.field-visibility-settings-toggle{margin:10px 0 10px 200px;text-align:left}.field-visibility-settings{display:none;margin-left:200px}.field-visibility-settings .button{margin-bottom:15px}#normal-sortables .field-visibility-settings legend{font-size:16px;margin-bottom:10px}
bp-members/admin/js/admin.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.1.0 - 2014-10-06 9:39:07 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  function clear(a){if(a=document.getElementById(a)){var b=a.getElementsByTagName("INPUT"),c=a.getElementsByTagName("OPTION"),d=0;if(b)for(d=0;d<b.length;d++)b[d].checked="";if(c)for(d=0;d<c.length;d++)c[d].selected=!1}}!function(a){a(".visibility-toggle-link").on("click",function(b){b.preventDefault(),a(this).parent().hide().siblings(".field-visibility-settings").show()}),a(".field-visibility-settings-close").on("click",function(b){b.preventDefault();var c=a(this).parent(),d=c.find("input:checked").parent().text();c.hide().siblings(".field-visibility-settings-toggle").children(".current-visibility-level").text(d).end().show()})}(jQuery);
1
+ /*! buddypress - v2.1.0 - 2015-01-09 11:28:36 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  function clear(a){if(a=document.getElementById(a)){var b=a.getElementsByTagName("INPUT"),c=a.getElementsByTagName("OPTION"),d=0;if(b)for(d=0;d<b.length;d++)b[d].checked="";if(c)for(d=0;d<c.length;d++)c[d].selected=!1}}!function(a){a(".visibility-toggle-link").on("click",function(b){b.preventDefault(),a(this).parent().hide().siblings(".field-visibility-settings").show()}),a(".field-visibility-settings-close").on("click",function(b){b.preventDefault();var c=a(this).parent(),d=c.find("input:checked").parent().text();c.hide().siblings(".field-visibility-settings-toggle").children(".current-visibility-level").text(d).end().show()})}(jQuery);
bp-members/bp-members-actions.php CHANGED
@@ -64,7 +64,7 @@ function bp_core_action_set_spammer_status( $user_id = 0 ) {
64
  bp_core_redirect( wp_get_referer() );
65
  }
66
  }
67
- // Unhooked in BuddyPress (1.6) - moved to settings
68
  //add_action( 'bp_actions', 'bp_core_action_set_spammer_status' );
69
 
70
  /**
@@ -100,13 +100,13 @@ function bp_core_action_delete_user() {
100
  bp_core_redirect( bp_loggedin_user_domain() );
101
  }
102
  }
103
- // Unhooked in BuddyPress (1.6) - moved to settings
104
  //add_action( 'bp_actions', 'bp_core_action_delete_user' );
105
 
106
  /**
107
  * Redirect to a random member page when visiting a ?random-member URL.
108
  *
109
- * @since BuddyPress (1.0)
110
  */
111
  function bp_core_get_random_member() {
112
  if ( ! isset( $_GET['random-member'] ) )
64
  bp_core_redirect( wp_get_referer() );
65
  }
66
  }
67
+ // Unhooked in BuddyPress (1.6.0) - moved to settings
68
  //add_action( 'bp_actions', 'bp_core_action_set_spammer_status' );
69
 
70
  /**
100
  bp_core_redirect( bp_loggedin_user_domain() );
101
  }
102
  }
103
+ // Unhooked in BuddyPress (1.6.0) - moved to settings
104
  //add_action( 'bp_actions', 'bp_core_action_delete_user' );
105
 
106
  /**
107
  * Redirect to a random member page when visiting a ?random-member URL.
108
  *
109
+ * @since BuddyPress (1.0.0)
110
  */
111
  function bp_core_get_random_member() {
112
  if ( ! isset( $_GET['random-member'] ) )
bp-members/bp-members-activity.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * BuddyPress Member Activity
5
+ *
6
+ * @package BuddyPress
7
+ * @subpackage MembersActivity
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ /**
14
+ * Register the 'new member' activity type
15
+ *
16
+ * @since BuddyPress (2.2.0)
17
+ *
18
+ * @uses bp_activity_set_action()
19
+ * @uses buddypress()
20
+ */
21
+ function bp_members_register_activity_actions() {
22
+
23
+ bp_activity_set_action(
24
+ buddypress()->members->id,
25
+ 'new_member',
26
+ __( 'New member registered', 'buddypress' ),
27
+ 'bp_members_format_activity_action_new_member',
28
+ __( 'New Members', 'buddypress' ),
29
+ array( 'activity' )
30
+ );
31
+
32
+ /**
33
+ * Fires after the default 'new member' activity types are registered.
34
+ *
35
+ * @since BuddyPress (2.2.0)
36
+ */
37
+ do_action( 'bp_members_register_activity_actions' );
38
+ }
39
+ add_action( 'bp_register_activity_actions', 'bp_members_register_activity_actions' );
40
+
41
+ /**
42
+ * Format 'new_member' activity actions.
43
+ *
44
+ * @since BuddyPress (2.2.0)
45
+ *
46
+ * @param string $action Static activity action.
47
+ * @param object $activity Activity object.
48
+ * @return string
49
+ */
50
+ function bp_members_format_activity_action_new_member( $action, $activity ) {
51
+ $userlink = bp_core_get_userlink( $activity->user_id );
52
+ $action = sprintf( __( '%s became a registered member', 'buddypress' ), $userlink );
53
+
54
+ // Legacy filter - pass $user_id instead of $activity
55
+ if ( has_filter( 'bp_core_activity_registered_member_action' ) ) {
56
+ $action = apply_filters( 'bp_core_activity_registered_member_action', $action, $activity->user_id );
57
+ }
58
+
59
+ /**
60
+ * Filters the formatted 'new member' activity actions.
61
+ *
62
+ * @since BuddyPress (2.2.0)
63
+ *
64
+ * @param string $action Static activity action.
65
+ * @param object $activity Activity object.
66
+ */
67
+ return apply_filters( 'bp_members_format_activity_action_new_member', $action, $activity );
68
+ }
69
+
70
+ /**
71
+ * Create a "became a registered user" activity item when a user activates his account.
72
+ *
73
+ * @param array $user Array of userdata passed to bp_core_activated_user hook.
74
+ */
75
+ function bp_core_new_user_activity( $user ) {
76
+ if ( empty( $user ) ) {
77
+ return false;
78
+ }
79
+
80
+ if ( is_array( $user ) ) {
81
+ $user_id = $user['user_id'];
82
+ } else {
83
+ $user_id = $user;
84
+ }
85
+
86
+ if ( empty( $user_id ) ) {
87
+ return false;
88
+ }
89
+
90
+ bp_activity_add( array(
91
+ 'user_id' => $user_id,
92
+ 'component' => buddypress()->members->id,
93
+ 'type' => 'new_member'
94
+ ) );
95
+ }
96
+ add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' );
bp-members/bp-members-admin.php CHANGED
@@ -105,7 +105,7 @@ class BP_Members_Admin {
105
  $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin CSS URL
106
 
107
  // Capability depends on config
108
- $this->capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options';
109
 
110
  // The Edit Profile Screen id
111
  $this->user_page = '';
@@ -144,7 +144,7 @@ class BP_Members_Admin {
144
 
145
  // When BuddyPress is not network activated, only Super Admin can moderate signups
146
  if ( ! empty( $this->subsite_activated ) ) {
147
- $this->capability = 'manage_network_options';
148
  }
149
  }
150
 
@@ -186,6 +186,9 @@ class BP_Members_Admin {
186
  // Add user row actions for single site
187
  add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 );
188
 
 
 
 
189
  /** Signups ***********************************************************/
190
 
191
  if ( is_admin() ) {
@@ -214,17 +217,11 @@ class BP_Members_Admin {
214
  * @return int
215
  */
216
  private function get_user_id() {
217
-
218
- // No user ID to start
219
- $user_id = 0;
220
 
221
  // We'll need a user ID when not on the user admin
222
  if ( ! empty( $_GET['user_id'] ) ) {
223
  $user_id = $_GET['user_id'];
224
-
225
- // Assume the current user ID
226
- } else {
227
- $user_id = get_current_user_id();
228
  }
229
 
230
  return intval( $user_id );
@@ -308,7 +305,7 @@ class BP_Members_Admin {
308
  case 'avatar':
309
  $notice = array(
310
  'class' => 'error',
311
- 'message' => __( 'There was a problem deleting that avatar, please try again.', 'buddypress' )
312
  );
313
  break;
314
  case 'ham' :
@@ -326,7 +323,7 @@ class BP_Members_Admin {
326
  case 1 :
327
  $notice = array(
328
  'class' => 'error',
329
- 'message' => __( 'An error occured while trying to update the profile.', 'buddypress' )
330
  );
331
  break;
332
  case 2:
@@ -338,7 +335,7 @@ class BP_Members_Admin {
338
  case 3:
339
  $notice = array(
340
  'class' => 'error',
341
- 'message' => __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' )
342
  );
343
  break;
344
  }
@@ -477,7 +474,7 @@ class BP_Members_Admin {
477
  $this->is_self_profile = true;
478
 
479
  // Is the user attempting to edit their own profile
480
- } else {
481
  $this->is_self_profile = (bool) ( $this->get_user_id() === $this->current_user_id );
482
  }
483
 
@@ -549,6 +546,14 @@ class BP_Members_Admin {
549
 
550
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
551
  $css = $this->css_url . "admin{$min}.css";
 
 
 
 
 
 
 
 
552
  $css = apply_filters( 'bp_members_admin_css', $css );
553
 
554
  wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() );
@@ -558,14 +563,29 @@ class BP_Members_Admin {
558
  wp_style_add_data( 'bp-members-css', 'suffix', $min );
559
  }
560
 
561
- // Only load javascript for BuddyPress profile
562
  if ( get_current_screen()->id == $this->user_page ) {
563
  $js = $this->js_url . "admin{$min}.js";
 
 
 
 
 
 
 
 
564
  $js = apply_filters( 'bp_members_admin_js', $js );
565
  wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true );
566
  }
567
 
568
- // Plugins may want to hook here to load some css/js
 
 
 
 
 
 
 
569
  do_action( 'bp_members_admin_enqueue_scripts', get_current_screen()->id, $this->screen_id );
570
  }
571
 
@@ -582,7 +602,7 @@ class BP_Members_Admin {
582
  return;
583
  }
584
 
585
- // Add the user ID to query agruments when not editing yourself
586
  if ( false === $this->is_self_profile ) {
587
  $query_args = array( 'user_id' => $user->ID );
588
  } else {
@@ -656,10 +676,23 @@ class BP_Members_Admin {
656
  }
657
  }
658
 
659
- // Call an action for plugins to hook in early
 
 
 
 
 
 
 
660
  do_action_ref_array( 'bp_members_admin_load', array( $doaction, $_REQUEST ) );
661
 
662
- // Allowed actions
 
 
 
 
 
 
663
  $allowed_actions = apply_filters( 'bp_members_admin_allowed_actions', array( 'update', 'delete_avatar', 'spam', 'ham' ) );
664
 
665
  // Prepare the display of the Community Profile screen
@@ -697,8 +730,15 @@ class BP_Members_Admin {
697
  $this->stats_metabox->priority = 'core';
698
 
699
  /**
700
- * xProfile Hooks to load the profile fields if component is active
701
- * Plugins should not use this hook, please use 'bp_members_admin_user_metaboxes' instead
 
 
 
 
 
 
 
702
  */
703
  do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) );
704
 
@@ -719,12 +759,31 @@ class BP_Members_Admin {
719
  sanitize_key( $this->stats_metabox->priority )
720
  );
721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
722
  /**
723
- * Custom metabox ?
724
- * Plugins can restrict metabox to "bp_moderate" admins checking
725
- * the first argument ($this->is_self_profile) is false in their hook
726
- * They can also restruct their metabox to self profile editing
727
- * by cheking it set to true.
 
 
 
 
 
 
728
  */
729
  do_action( 'bp_members_admin_user_metaboxes', $this->is_self_profile, $user_id );
730
 
@@ -749,6 +808,16 @@ class BP_Members_Admin {
749
  } else {
750
  $this->redirect = $redirect_to;
751
 
 
 
 
 
 
 
 
 
 
 
752
  do_action_ref_array( 'bp_members_admin_update_user', array( $doaction, $user_id, $_REQUEST, $this->redirect ) );
753
 
754
  bp_core_redirect( $this->redirect );
@@ -832,8 +901,6 @@ class BP_Members_Admin {
832
  <div id="poststuff">
833
 
834
  <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
835
- <div id="post-body-content">
836
- </div><!-- #post-body-content -->
837
 
838
  <div id="postbox-container-1" class="postbox-container">
839
  <?php do_meta_boxes( get_current_screen()->id, 'side', $user ); ?>
@@ -882,7 +949,7 @@ class BP_Members_Admin {
882
  return;
883
  }
884
 
885
- // Bail if user has not been activated yet (how didy ou get here?)
886
  if ( isset( $user->user_status ) && ( 2 == $user->user_status ) ) : ?>
887
 
888
  <p class="not-activated"><?php esc_html_e( 'User account has not yet been activated', 'buddypress' ); ?></p><br/>
@@ -991,6 +1058,15 @@ class BP_Members_Admin {
991
  <?php
992
  // Loading other stats only if user has activated their account
993
  if ( empty( $user->user_status ) ) {
 
 
 
 
 
 
 
 
 
994
  do_action( 'bp_members_admin_user_stats', array( 'user_id' => $user->ID ), $user );
995
  }
996
  ?>
@@ -999,6 +1075,72 @@ class BP_Members_Admin {
999
  <?php
1000
  }
1001
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1002
  /**
1003
  * Add a link to Profile in Users listing row actions.
1004
  *
@@ -1232,10 +1374,23 @@ class BP_Members_Admin {
1232
  $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] );
1233
  $doaction = bp_admin_list_table_current_bulk_action();
1234
 
1235
- // Call an action for plugins to hook in early
 
 
 
 
 
 
 
1236
  do_action( 'bp_signups_admin_load', $doaction, $_REQUEST );
1237
 
1238
- // Allowed actions
 
 
 
 
 
 
1239
  $allowed_actions = apply_filters( 'bp_signups_admin_allowed_actions', array( 'do_delete', 'do_activate', 'do_resend' ) );
1240
 
1241
  // Prepare the display of the Community Profile screen
@@ -1254,7 +1409,7 @@ class BP_Members_Admin {
1254
  'id' => 'bp-signups-overview',
1255
  'title' => __( 'Overview', 'buddypress' ),
1256
  'content' =>
1257
- '<p>' . __( 'This is the admininistration screen for pending accounts on your site.', 'buddypress' ) . '</p>' .
1258
  '<p>' . __( 'From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress' ) . '</p>' .
1259
  '<p>' . __( 'You can reorder the list of your pending accounts by clicking on the Username, Email or Registered column headers.', 'buddypress' ) . '</p>' .
1260
  '<p>' . __( 'Using the search form, you can find pending accounts more easily. The Username and Email fields will be included in the search.', 'buddypress' ) . '</p>'
@@ -1309,7 +1464,7 @@ class BP_Members_Admin {
1309
  bp_core_redirect( $redirect_to );
1310
 
1311
  // Handle activated accounts
1312
- } else if ( 'do_activate' == $doaction ) {
1313
 
1314
  // nonce check
1315
  check_admin_referer( 'signups_activate' );
@@ -1336,7 +1491,7 @@ class BP_Members_Admin {
1336
  bp_core_redirect( $redirect_to );
1337
 
1338
  // Handle sign-ups delete
1339
- } else if ( 'do_delete' == $doaction ) {
1340
 
1341
  // nonce check
1342
  check_admin_referer( 'signups_delete' );
@@ -1366,6 +1521,15 @@ class BP_Members_Admin {
1366
  } else {
1367
  $this->redirect = $redirect_to;
1368
 
 
 
 
 
 
 
 
 
 
1369
  do_action( 'bp_members_admin_update_signups', $doaction, $_REQUEST, $this->redirect );
1370
 
1371
  bp_core_redirect( $this->redirect );
@@ -1524,21 +1688,21 @@ class BP_Members_Admin {
1524
  case 'do_resend':
1525
  $notice = array(
1526
  'class' => 'error',
1527
- 'message' => esc_html__( 'There was a problem sending the activation emails, please try again.', 'buddypress' ),
1528
  );
1529
  break;
1530
 
1531
  case 'do_activate':
1532
  $notice = array(
1533
  'class' => 'error',
1534
- 'message' => esc_html__( 'There was a problem activating accounts, please try again.', 'buddypress' ),
1535
  );
1536
  break;
1537
 
1538
  case 'do_delete':
1539
  $notice = array(
1540
  'class' => 'error',
1541
- 'message' => esc_html__( 'There was a problem deleting sign-ups, please try again.', 'buddypress' ),
1542
  );
1543
  break;
1544
  }
@@ -1697,7 +1861,7 @@ class BP_Members_Admin {
1697
  * @param string $action Delete, activate, or resend activation link.
1698
  */
1699
  public function signups_admin_manage( $action = '' ) {
1700
- if ( ! is_super_admin() || empty( $action ) ) {
1701
  die( '-1' );
1702
  }
1703
 
@@ -1705,7 +1869,7 @@ class BP_Members_Admin {
1705
  $ids = false;
1706
  if ( ! empty( $_POST['allsignups'] ) ) {
1707
  $ids = wp_parse_id_list( $_POST['allsignups'] );
1708
- } else if ( ! empty( $_GET['signup_id'] ) ) {
1709
  $ids = absint( $_GET['signup_id'] );
1710
  }
1711
 
105
  $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin CSS URL
106
 
107
  // Capability depends on config
108
+ $this->capability = bp_core_do_network_admin() ? 'manage_network_users' : 'edit_users';
109
 
110
  // The Edit Profile Screen id
111
  $this->user_page = '';
144
 
145
  // When BuddyPress is not network activated, only Super Admin can moderate signups
146
  if ( ! empty( $this->subsite_activated ) ) {
147
+ $this->capability = 'manage_network_users';
148
  }
149
  }
150
 
186
  // Add user row actions for single site
187
  add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 );
188
 
189
+ // Process changes to member type.
190
+ add_action( 'bp_members_admin_load', array( $this, 'process_member_type_update' ) );
191
+
192
  /** Signups ***********************************************************/
193
 
194
  if ( is_admin() ) {
217
  * @return int
218
  */
219
  private function get_user_id() {
220
+ $user_id = get_current_user_id();
 
 
221
 
222
  // We'll need a user ID when not on the user admin
223
  if ( ! empty( $_GET['user_id'] ) ) {
224
  $user_id = $_GET['user_id'];
 
 
 
 
225
  }
226
 
227
  return intval( $user_id );
305
  case 'avatar':
306
  $notice = array(
307
  'class' => 'error',
308
+ 'message' => __( 'There was a problem deleting that avatar. Please try again.', 'buddypress' )
309
  );
310
  break;
311
  case 'ham' :
323
  case 1 :
324
  $notice = array(
325
  'class' => 'error',
326
+ 'message' => __( 'An error occurred while trying to update the profile.', 'buddypress' )
327
  );
328
  break;
329
  case 2:
335
  case 3:
336
  $notice = array(
337
  'class' => 'error',
338
+ 'message' => __( 'There was a problem updating some of your profile information. Please try again.', 'buddypress' )
339
  );
340
  break;
341
  }
474
  $this->is_self_profile = true;
475
 
476
  // Is the user attempting to edit their own profile
477
+ } elseif ( isset( $_GET['user_id' ] ) || ( isset( $_GET['page'] ) && ( 'bp-profile-edit' === $_GET['page'] ) ) ) {
478
  $this->is_self_profile = (bool) ( $this->get_user_id() === $this->current_user_id );
479
  }
480
 
546
 
547
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
548
  $css = $this->css_url . "admin{$min}.css";
549
+
550
+ /**
551
+ * Filters the CSS URL to enqueue in the Members admin area.
552
+ *
553
+ * @since BuddyPress (2.0.0)
554
+ *
555
+ * @param string $css URL to the CSS admin file to load.
556
+ */
557
  $css = apply_filters( 'bp_members_admin_css', $css );
558
 
559
  wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() );
563
  wp_style_add_data( 'bp-members-css', 'suffix', $min );
564
  }
565
 
566
+ // Only load JavaScript for BuddyPress profile
567
  if ( get_current_screen()->id == $this->user_page ) {
568
  $js = $this->js_url . "admin{$min}.js";
569
+
570
+ /**
571
+ * Filters the JS URL to enqueue in the Members admin area.
572
+ *
573
+ * @since BuddyPress (2.0.0)
574
+ *
575
+ * @param string $js URL to the JavaScript admin file to load.
576
+ */
577
  $js = apply_filters( 'bp_members_admin_js', $js );
578
  wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true );
579
  }
580
 
581
+ /**
582
+ * Fires after all of the members JavaScript and CSS is enqueued.
583
+ *
584
+ * @since BuddyPress (2.0.0)
585
+ *
586
+ * @param string $id ID of the current screen.
587
+ * @param array $screen_id Array of allowed screens to add scripts and styles to.
588
+ */
589
  do_action( 'bp_members_admin_enqueue_scripts', get_current_screen()->id, $this->screen_id );
590
  }
591
 
602
  return;
603
  }
604
 
605
+ // Add the user ID to query arguments when not editing yourself
606
  if ( false === $this->is_self_profile ) {
607
  $query_args = array( 'user_id' => $user->ID );
608
  } else {
676
  }
677
  }
678
 
679
+ /**
680
+ * Fires at the start of the signups admin load.
681
+ *
682
+ * @since BuddyPress (2.0.0)
683
+ *
684
+ * @param string $doaction Current bulk action being processed.
685
+ * @param array $_REQUEST Current $_REQUEST global.
686
+ */
687
  do_action_ref_array( 'bp_members_admin_load', array( $doaction, $_REQUEST ) );
688
 
689
+ /**
690
+ * Filters the allowed actions for use in the user admin page.
691
+ *
692
+ * @since BuddyPress (2.0.0)
693
+ *
694
+ * @param array $value Array of allowed actions to use.
695
+ */
696
  $allowed_actions = apply_filters( 'bp_members_admin_allowed_actions', array( 'update', 'delete_avatar', 'spam', 'ham' ) );
697
 
698
  // Prepare the display of the Community Profile screen
730
  $this->stats_metabox->priority = 'core';
731
 
732
  /**
733
+ * Fires before loading the profile fields if component is active.
734
+ *
735
+ * Plugins should not use this hook, please use 'bp_members_admin_user_metaboxes' instead.
736
+ *
737
+ * @since BuddyPress (2.0.0)
738
+ *
739
+ * @param int $user_id Current user ID for the screen.
740
+ * @param string $id Current screen ID.
741
+ * @param object $stats_metabox Object holding position data for use with the stats metabox.
742
  */
743
  do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) );
744
 
759
  sanitize_key( $this->stats_metabox->priority )
760
  );
761
 
762
+ // Member Type metabox. Only added if member types have been registered.
763
+ $member_types = bp_get_member_types();
764
+ if ( ! empty( $member_types ) ) {
765
+ add_meta_box(
766
+ 'bp_members_admin_member_type',
767
+ _x( 'Member Type', 'members user-admin edit screen', 'buddypress' ),
768
+ array( $this, 'user_admin_member_type_metabox' ),
769
+ get_current_screen()->id,
770
+ 'side',
771
+ 'core'
772
+ );
773
+ }
774
+
775
  /**
776
+ * Fires at the end of the Community Profile screen.
777
+ *
778
+ * Plugins can restrict metabox to "bp_moderate" admins by checking if
779
+ * the first argument ($this->is_self_profile) is false in their callback.
780
+ * They can also restrict their metabox to self profile editing
781
+ * by setting it to true.
782
+ *
783
+ * @since BuddyPress (2.0.0)
784
+ *
785
+ * @param bool $is_self_profile Whether or not it is the current user's profile.
786
+ * @param int $user_id Current user ID.
787
  */
788
  do_action( 'bp_members_admin_user_metaboxes', $this->is_self_profile, $user_id );
789
 
808
  } else {
809
  $this->redirect = $redirect_to;
810
 
811
+ /**
812
+ * Fires at end of user profile admin load if doaction does not match any available actions.
813
+ *
814
+ * @since BuddyPress (2.0.0)
815
+ *
816
+ * @param string $doaction Current bulk action being processed.
817
+ * @param int $user_id Current user ID.
818
+ * @param array $_REQUEST Current $_REQUEST global.
819
+ * @param string $redirect Determined redirect url to send user to.
820
+ */
821
  do_action_ref_array( 'bp_members_admin_update_user', array( $doaction, $user_id, $_REQUEST, $this->redirect ) );
822
 
823
  bp_core_redirect( $this->redirect );
901
  <div id="poststuff">
902
 
903
  <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
 
 
904
 
905
  <div id="postbox-container-1" class="postbox-container">
906
  <?php do_meta_boxes( get_current_screen()->id, 'side', $user ); ?>
949
  return;
950
  }
951
 
952
+ // Bail if user has not been activated yet (how did you get here?)
953
  if ( isset( $user->user_status ) && ( 2 == $user->user_status ) ) : ?>
954
 
955
  <p class="not-activated"><?php esc_html_e( 'User account has not yet been activated', 'buddypress' ); ?></p><br/>
1058
  <?php
1059
  // Loading other stats only if user has activated their account
1060
  if ( empty( $user->user_status ) ) {
1061
+
1062
+ /**
1063
+ * Fires in the user stats metabox if the user has activated their account.
1064
+ *
1065
+ * @since BuddyPress (2.0.0)
1066
+ *
1067
+ * @param array $value Array holding the user ID.
1068
+ * @param object $user Current displayed user object.
1069
+ */
1070
  do_action( 'bp_members_admin_user_stats', array( 'user_id' => $user->ID ), $user );
1071
  }
1072
  ?>
1075
  <?php
1076
  }
1077
 
1078
+ /**
1079
+ * Render the Member Type metabox.
1080
+ *
1081
+ * @since BuddyPress (2.2.0)
1082
+ * @access public
1083
+ *
1084
+ * @param WP_User $user The WP_User object to be edited.
1085
+ */
1086
+ public function user_admin_member_type_metabox( $user = null ) {
1087
+
1088
+ // Bail if no user ID.
1089
+ if ( empty( $user->ID ) ) {
1090
+ return;
1091
+ }
1092
+
1093
+ $types = bp_get_member_types( array(), 'objects' );
1094
+ $current_type = bp_get_member_type( $user->ID );
1095
+ ?>
1096
+
1097
+ <select name="bp-members-profile-member-type">
1098
+ <option value="" <?php selected( '', $current_type ); ?>><?php /* translators: no option picked in select box */ esc_attr_e( '----', 'buddypress' ) ?></option>
1099
+ <?php foreach ( $types as $type ) : ?>
1100
+ <option value="<?php echo esc_attr( $type->name ) ?>" <?php selected( $type->name, $current_type ) ?>><?php echo esc_html( $type->labels['singular_name'] ) ?></option>
1101
+ <?php endforeach; ?>
1102
+ </select>
1103
+
1104
+ <?php
1105
+
1106
+ wp_nonce_field( 'bp-member-type-change-' . $user->ID, 'bp-member-type-nonce' );
1107
+ }
1108
+
1109
+ /**
1110
+ * Process changes from the Member Type metabox.
1111
+ *
1112
+ * @since BuddyPress (2.2.0)
1113
+ * @access public
1114
+ */
1115
+ public function process_member_type_update() {
1116
+ if ( ! isset( $_POST['bp-member-type-nonce'] ) || ! isset( $_POST['bp-members-profile-member-type'] ) ) {
1117
+ return;
1118
+ }
1119
+
1120
+ $user_id = $this->get_user_id();
1121
+
1122
+ check_admin_referer( 'bp-member-type-change-' . $user_id, 'bp-member-type-nonce' );
1123
+
1124
+ // Permission check.
1125
+ if ( ! current_user_can( 'bp_moderate' ) && $user_id != bp_loggedin_user_id() ) {
1126
+ return;
1127
+ }
1128
+
1129
+ // Member type string must either reference a valid member type, or be empty.
1130
+ $member_type = stripslashes( $_POST['bp-members-profile-member-type'] );
1131
+ if ( ! empty( $member_type ) && ! bp_get_member_type_object( $member_type ) ) {
1132
+ return;
1133
+ }
1134
+
1135
+ /*
1136
+ * If an invalid member type is passed, someone's doing something
1137
+ * fishy with the POST request, so we can fail silently.
1138
+ */
1139
+ if ( bp_set_member_type( $user_id, $member_type ) ) {
1140
+ // @todo Success messages can't be posted because other stuff happens on the page load.
1141
+ }
1142
+ }
1143
+
1144
  /**
1145
  * Add a link to Profile in Users listing row actions.
1146
  *
1374
  $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] );
1375
  $doaction = bp_admin_list_table_current_bulk_action();
1376
 
1377
+ /**
1378
+ * Fires at the start of the signups admin load.
1379
+ *
1380
+ * @since BuddyPress (2.0.0)
1381
+ *
1382
+ * @param string $doaction Current bulk action being processed.
1383
+ * @param array $_REQUEST Current $_REQUEST global.
1384
+ */
1385
  do_action( 'bp_signups_admin_load', $doaction, $_REQUEST );
1386
 
1387
+ /**
1388
+ * Filters the allowed actions for use in the user signups admin page.
1389
+ *
1390
+ * @since BuddyPress (2.0.0)
1391
+ *
1392
+ * @param array $value Array of allowed actions to use.
1393
+ */
1394
  $allowed_actions = apply_filters( 'bp_signups_admin_allowed_actions', array( 'do_delete', 'do_activate', 'do_resend' ) );
1395
 
1396
  // Prepare the display of the Community Profile screen
1409
  'id' => 'bp-signups-overview',
1410
  'title' => __( 'Overview', 'buddypress' ),
1411
  'content' =>
1412
+ '<p>' . __( 'This is the administration screen for pending accounts on your site.', 'buddypress' ) . '</p>' .
1413
  '<p>' . __( 'From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress' ) . '</p>' .
1414
  '<p>' . __( 'You can reorder the list of your pending accounts by clicking on the Username, Email or Registered column headers.', 'buddypress' ) . '</p>' .
1415
  '<p>' . __( 'Using the search form, you can find pending accounts more easily. The Username and Email fields will be included in the search.', 'buddypress' ) . '</p>'
1464
  bp_core_redirect( $redirect_to );
1465
 
1466
  // Handle activated accounts
1467
+ } elseif ( 'do_activate' == $doaction ) {
1468
 
1469
  // nonce check
1470
  check_admin_referer( 'signups_activate' );
1491
  bp_core_redirect( $redirect_to );
1492
 
1493
  // Handle sign-ups delete
1494
+ } elseif ( 'do_delete' == $doaction ) {
1495
 
1496
  // nonce check
1497
  check_admin_referer( 'signups_delete' );
1521
  } else {
1522
  $this->redirect = $redirect_to;
1523
 
1524
+ /**
1525
+ * Fires at end of signups admin load if doaction does not match any actions.
1526
+ *
1527
+ * @since BuddyPress (2.0.0)
1528
+ *
1529
+ * @param string $doaction Current bulk action being processed.
1530
+ * @param array $_REQUEST Current $_REQUEST global.
1531
+ * @param string $redirect Determined redirect url to send user to.
1532
+ */
1533
  do_action( 'bp_members_admin_update_signups', $doaction, $_REQUEST, $this->redirect );
1534
 
1535
  bp_core_redirect( $this->redirect );
1688
  case 'do_resend':
1689
  $notice = array(
1690
  'class' => 'error',
1691
+ 'message' => esc_html__( 'There was a problem sending the activation emails. Please try again.', 'buddypress' ),
1692
  );
1693
  break;
1694
 
1695
  case 'do_activate':
1696
  $notice = array(
1697
  'class' => 'error',
1698
+ 'message' => esc_html__( 'There was a problem activating accounts. Please try again.', 'buddypress' ),
1699
  );
1700
  break;
1701
 
1702
  case 'do_delete':
1703
  $notice = array(
1704
  'class' => 'error',
1705
+ 'message' => esc_html__( 'There was a problem deleting sign-ups. Please try again.', 'buddypress' ),
1706
  );
1707
  break;
1708
  }
1861
  * @param string $action Delete, activate, or resend activation link.
1862
  */
1863
  public function signups_admin_manage( $action = '' ) {
1864
+ if ( ! current_user_can( $this->capability ) || empty( $action ) ) {
1865
  die( '-1' );
1866
  }
1867
 
1869
  $ids = false;
1870
  if ( ! empty( $_POST['allsignups'] ) ) {
1871
  $ids = wp_parse_id_list( $_POST['allsignups'] );
1872
+ } elseif ( ! empty( $_GET['signup_id'] ) ) {
1873
  $ids = absint( $_GET['signup_id'] );
1874
  }
1875
 
bp-members/bp-members-cache.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Caching functions specific to BuddyPress Members.
5
+ *
6
+ * @since BuddyPress (2.2.0)
7
+ */
8
+
9
+ /**
10
+ * Pre-fetch member type data when initializing a Members loop.
11
+ *
12
+ * @since BuddyPress (2.2.0)
13
+ *
14
+ * @param BP_User_Query $bp_user_query BP_User_Query object.
15
+ */
16
+ function bp_members_prefetch_member_type( BP_User_Query $bp_user_query ) {
17
+ $uncached_member_ids = bp_get_non_cached_ids( $bp_user_query->user_ids, 'bp_member_type' );
18
+
19
+ $member_types = bp_get_object_terms( $uncached_member_ids, 'bp_member_type', array(
20
+ 'fields' => 'all_with_object_id',
21
+ ) );
22
+
23
+ $cached_member_ids = array();
24
+ foreach ( $member_types as $member_type ) {
25
+ wp_cache_set( $member_type->object_id, $member_type->name, 'bp_member_type' );
26
+ $cached_member_ids[] = $member_type->object_id;
27
+ }
28
+
29
+ // Cache an empty value for users with no type.
30
+ foreach ( array_diff( $uncached_member_ids, $cached_member_ids ) as $no_type_id ) {
31
+ wp_cache_set( $no_type_id, '', 'bp_member_type' );
32
+ }
33
+ }
34
+ add_action( 'bp_user_query_populate_extras', 'bp_members_prefetch_member_type' );
35
+
36
+ /**
37
+ * Clear the member_type cache for a user.
38
+ *
39
+ * Called when the user is deleted or marked as spam.
40
+ *
41
+ * @since BuddyPres (2.2.0)
42
+ *
43
+ * @param int $user_id ID of the deleted user.
44
+ */
45
+ function bp_members_clear_member_type_cache( $user_id ) {
46
+ wp_cache_delete( $user_id, 'bp_member_type' );
47
+ }
48
+ add_action( 'wpmu_delete_user', 'bp_members_clear_member_type_cache' );
49
+ add_action( 'delete_user', 'bp_members_clear_member_type_cache' );
bp-members/bp-members-classes.php CHANGED
@@ -175,6 +175,16 @@ class BP_Signup {
175
  // Implode WHERE clauses
176
  $sql['where'] = 'WHERE ' . implode( ' AND ', $sql['where'] );
177
 
 
 
 
 
 
 
 
 
 
 
178
  $paged_signups = $wpdb->get_results( apply_filters( 'bp_members_signups_paged_query', join( ' ', $sql ), $sql, $args, $r ) );
179
 
180
  if ( empty( $paged_signups ) ) {
@@ -225,6 +235,17 @@ class BP_Signup {
225
 
226
  unset( $sql['limit'] );
227
  $sql['select'] = preg_replace( "/SELECT.*?FROM/", "SELECT COUNT(*) FROM", $sql['select'] );
 
 
 
 
 
 
 
 
 
 
 
228
  $total_signups = $wpdb->get_var( apply_filters( 'bp_members_signups_count_query', join( ' ', $sql ), $sql, $args, $r ) );
229
 
230
  return array( 'signups' => $paged_signups, 'total' => $total_signups );
@@ -270,6 +291,13 @@ class BP_Signup {
270
  $retval = false;
271
  }
272
 
 
 
 
 
 
 
 
273
  return apply_filters( 'bp_core_signups_add', $retval );
274
  }
275
 
@@ -294,8 +322,6 @@ class BP_Signup {
294
  public static function add_backcompat( $user_login = '', $user_password = '', $user_email = '', $usermeta = array() ) {
295
  global $wpdb;
296
 
297
- $errors = new WP_Error();
298
-
299
  $user_id = wp_insert_user( array(
300
  'user_login' => $user_login,
301
  'user_pass' => $user_password,
@@ -304,8 +330,7 @@ class BP_Signup {
304
  ) );
305
 
306
  if ( is_wp_error( $user_id ) || empty( $user_id ) ) {
307
- $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you. Please contact the <a href="mailto:%s">webmaster</a>.', 'buddypress' ), bp_get_option( 'admin_email' ) ) );
308
- return $errors;
309
  }
310
 
311
  // Update the user status to '2', ie "not activated"
@@ -338,6 +363,13 @@ class BP_Signup {
338
  }
339
  }
340
 
 
 
 
 
 
 
 
341
  return apply_filters( 'bp_core_signups_add_backcompat', $user_id );
342
  }
343
 
@@ -358,6 +390,13 @@ class BP_Signup {
358
 
359
  $user_status = $wpdb->get_var( $wpdb->prepare( "SELECT user_status FROM {$wpdb->users} WHERE ID = %d", $user_id ) );
360
 
 
 
 
 
 
 
 
361
  return apply_filters( 'bp_core_signups_check_user_status', intval( $user_status ) );
362
  }
363
 
@@ -397,6 +436,13 @@ class BP_Signup {
397
  )
398
  );
399
 
 
 
 
 
 
 
 
400
  return apply_filters( 'bp_core_signups_validate', $activated );
401
  }
402
 
@@ -413,6 +459,13 @@ class BP_Signup {
413
  $signups_table = buddypress()->members->table_name_signups;
414
  $count_signups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) AS total FROM {$signups_table} WHERE active = %d", 0 ) );
415
 
 
 
 
 
 
 
 
416
  return apply_filters( 'bp_core_signups_count', (int) $count_signups );
417
  }
418
 
@@ -463,6 +516,13 @@ class BP_Signup {
463
  )
464
  );
465
 
 
 
 
 
 
 
 
466
  return apply_filters( 'bp_core_signups_update', $r['signup_id'] );
467
  }
468
 
@@ -489,6 +549,13 @@ class BP_Signup {
489
 
490
  $result = array();
491
 
 
 
 
 
 
 
 
492
  do_action( 'bp_core_signup_before_resend', $signup_ids );
493
 
494
  foreach ( $signups as $signup ) {
@@ -510,7 +577,7 @@ class BP_Signup {
510
  // Status is not 2, so user's account has been activated
511
  $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
512
 
513
- // repare signups table
514
  self::validate( $signup->activation_key );
515
 
516
  continue;
@@ -528,8 +595,23 @@ class BP_Signup {
528
  ) );
529
  }
530
 
 
 
 
 
 
 
 
 
531
  do_action( 'bp_core_signup_after_resend', $signup_ids, $result );
532
 
 
 
 
 
 
 
 
533
  return apply_filters( 'bp_core_signup_resend', $result );
534
  }
535
 
@@ -556,6 +638,13 @@ class BP_Signup {
556
 
557
  $result = array();
558
 
 
 
 
 
 
 
 
559
  do_action( 'bp_core_signup_before_activate', $signup_ids );
560
 
561
  foreach ( $signups as $signup ) {
@@ -575,7 +664,7 @@ class BP_Signup {
575
  // Status is not 2, so user's account has been activated
576
  $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
577
 
578
- // repare signups table
579
  self::validate( $signup->activation_key );
580
 
581
  // we have a user id, account is not active, let's delete it
@@ -588,8 +677,23 @@ class BP_Signup {
588
  }
589
  }
590
 
 
 
 
 
 
 
 
 
591
  do_action( 'bp_core_signup_after_activate', $signup_ids, $result );
592
 
 
 
 
 
 
 
 
593
  return apply_filters( 'bp_core_signup_activate', $result );
594
  }
595
 
@@ -618,6 +722,13 @@ class BP_Signup {
618
 
619
  $result = array();
620
 
 
 
 
 
 
 
 
621
  do_action( 'bp_core_signup_before_delete', $signup_ids );
622
 
623
  foreach ( $signups as $signup ) {
@@ -630,7 +741,7 @@ class BP_Signup {
630
  // Status is not 2, so user's account has been activated
631
  $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
632
 
633
- // repare signups table
634
  self::validate( $signup->activation_key );
635
 
636
  // we have a user id, account is not active, let's delete it
@@ -653,8 +764,23 @@ class BP_Signup {
653
  }
654
  }
655
 
 
 
 
 
 
 
 
 
656
  do_action( 'bp_core_signup_after_delete', $signup_ids, $result );
657
 
 
 
 
 
 
 
 
658
  return apply_filters( 'bp_core_signup_delete', $result );
659
  }
660
  }
175
  // Implode WHERE clauses
176
  $sql['where'] = 'WHERE ' . implode( ' AND ', $sql['where'] );
177
 
178
+ /**
179
+ * Filters the Signups paged query.
180
+ *
181
+ * @since BuddyPress (2.0.0)
182
+ *
183
+ * @param string $value SQL statement.
184
+ * @param array $sql Array of SQL statement parts.
185
+ * @param array $args Array of original arguments for get() method.
186
+ * @param array $r Array of parsed arguments for get() method.
187
+ */
188
  $paged_signups = $wpdb->get_results( apply_filters( 'bp_members_signups_paged_query', join( ' ', $sql ), $sql, $args, $r ) );
189
 
190
  if ( empty( $paged_signups ) ) {
235
 
236
  unset( $sql['limit'] );
237
  $sql['select'] = preg_replace( "/SELECT.*?FROM/", "SELECT COUNT(*) FROM", $sql['select'] );
238
+
239
+ /**
240
+ * Filters the Signups count query.
241
+ *
242
+ * @since BuddyPress (2.0.0)
243
+ *
244
+ * @param string $value SQL statement.
245
+ * @param array $sql Array of SQL statement parts.
246
+ * @param array $args Array of original arguments for get() method.
247
+ * @param array $r Array of parsed arguments for get() method.
248
+ */
249
  $total_signups = $wpdb->get_var( apply_filters( 'bp_members_signups_count_query', join( ' ', $sql ), $sql, $args, $r ) );
250
 
251
  return array( 'signups' => $paged_signups, 'total' => $total_signups );
291
  $retval = false;
292
  }
293
 
294
+ /**
295
+ * Filters the result of a signup addition.
296
+ *
297
+ * @since BuddyPress (2.0.0)
298
+ *
299
+ * @param int|bool $retval Newly added user ID on success, false on failure.
300
+ */
301
  return apply_filters( 'bp_core_signups_add', $retval );
302
  }
303
 
322
  public static function add_backcompat( $user_login = '', $user_password = '', $user_email = '', $usermeta = array() ) {
323
  global $wpdb;
324
 
 
 
325
  $user_id = wp_insert_user( array(
326
  'user_login' => $user_login,
327
  'user_pass' => $user_password,
330
  ) );
331
 
332
  if ( is_wp_error( $user_id ) || empty( $user_id ) ) {
333
+ return $user_id;
 
334
  }
335
 
336
  // Update the user status to '2', ie "not activated"
363
  }
364
  }
365
 
366
+ /**
367
+ * Filters the user ID for the backcompat functionality.
368
+ *
369
+ * @since BuddyPress (2.0.0)
370
+ *
371
+ * @param int $user_id User ID being registered.
372
+ */
373
  return apply_filters( 'bp_core_signups_add_backcompat', $user_id );
374
  }
375
 
390
 
391
  $user_status = $wpdb->get_var( $wpdb->prepare( "SELECT user_status FROM {$wpdb->users} WHERE ID = %d", $user_id ) );
392
 
393
+ /**
394
+ * Filters the user status of a provided user ID.
395
+ *
396
+ * @since BuddyPress (2.0.0)
397
+ *
398
+ * @param int $value User status of the provided user ID.
399
+ */
400
  return apply_filters( 'bp_core_signups_check_user_status', intval( $user_status ) );
401
  }
402
 
436
  )
437
  );
438
 
439
+ /**
440
+ * Filters the status of the activated user.
441
+ *
442
+ * @since BuddyPress (2.0.0)
443
+ *
444
+ * @param bool $activated Whether or not the activation was successful.
445
+ */
446
  return apply_filters( 'bp_core_signups_validate', $activated );
447
  }
448
 
459
  $signups_table = buddypress()->members->table_name_signups;
460
  $count_signups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) AS total FROM {$signups_table} WHERE active = %d", 0 ) );
461
 
462
+ /**
463
+ * Filters the total inactive signups.
464
+ *
465
+ * @since BuddyPress (2.0.0)
466
+ *
467
+ * @param int $count_signups How many total signups there are.
468
+ */
469
  return apply_filters( 'bp_core_signups_count', (int) $count_signups );
470
  }
471
 
516
  )
517
  );
518
 
519
+ /**
520
+ * Filters the signup ID which received a meta update.
521
+ *
522
+ * @since BuddyPress (2.0.0)
523
+ *
524
+ * @param int $value The signup ID.
525
+ */
526
  return apply_filters( 'bp_core_signups_update', $r['signup_id'] );
527
  }
528
 
549
 
550
  $result = array();
551
 
552
+ /**
553
+ * Fires before activation emails are resent.
554
+ *
555
+ * @since BuddyPress (2.0.0)
556
+ *
557
+ * @param array $signup_ids Array of IDs to resend activation emails to.
558
+ */
559
  do_action( 'bp_core_signup_before_resend', $signup_ids );
560
 
561
  foreach ( $signups as $signup ) {
577
  // Status is not 2, so user's account has been activated
578
  $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
579
 
580
+ // repair signups table
581
  self::validate( $signup->activation_key );
582
 
583
  continue;
595
  ) );
596
  }
597
 
598
+ /**
599
+ * Fires after activation emails are resent.
600
+ *
601
+ * @since BuddyPress (2.0.0)
602
+ *
603
+ * @param array $signup_ids Array of IDs to resend activation emails to.
604
+ * @param array $result Updated metadata related to activation emails.
605
+ */
606
  do_action( 'bp_core_signup_after_resend', $signup_ids, $result );
607
 
608
+ /**
609
+ * Filters the result of the metadata for signup activation email resends.
610
+ *
611
+ * @since BuddyPress (2.0.0)
612
+ *
613
+ * @param array $result Updated metadata related to activation emails.
614
+ */
615
  return apply_filters( 'bp_core_signup_resend', $result );
616
  }
617
 
638
 
639
  $result = array();
640
 
641
+ /**
642
+ * Fires before activation of user accounts.
643
+ *
644
+ * @since BuddyPress (2.0.0)
645
+ *
646
+ * @param array $signup_ids Array of IDs to activate.
647
+ */
648
  do_action( 'bp_core_signup_before_activate', $signup_ids );
649
 
650
  foreach ( $signups as $signup ) {
664
  // Status is not 2, so user's account has been activated
665
  $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
666
 
667
+ // repair signups table
668
  self::validate( $signup->activation_key );
669
 
670
  // we have a user id, account is not active, let's delete it
677
  }
678
  }
679
 
680
+ /**
681
+ * Fires after activation of user accounts.
682
+ *
683
+ * @since BuddyPress (2.0.0)
684
+ *
685
+ * @param array $signup_ids Array of IDs activated activate.
686
+ * @param array $result Array of data for activated accounts.
687
+ */
688
  do_action( 'bp_core_signup_after_activate', $signup_ids, $result );
689
 
690
+ /**
691
+ * Filters the result of the metadata after user activation.
692
+ *
693
+ * @since BuddyPress (2.0.0)
694
+ *
695
+ * @param array $result Updated metadata related to user activation.
696
+ */
697
  return apply_filters( 'bp_core_signup_activate', $result );
698
  }
699
 
722
 
723
  $result = array();
724
 
725
+ /**
726
+ * Fires before deletion of pending accounts.
727
+ *
728
+ * @since BuddyPress (2.0.0)
729
+ *
730
+ * @param array $signup_ids Array of pending IDs to delete.
731
+ */
732
  do_action( 'bp_core_signup_before_delete', $signup_ids );
733
 
734
  foreach ( $signups as $signup ) {
741
  // Status is not 2, so user's account has been activated
742
  $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
743
 
744
+ // repair signups table
745
  self::validate( $signup->activation_key );
746
 
747
  // we have a user id, account is not active, let's delete it
764
  }
765
  }
766
 
767
+ /**
768
+ * Fires after deletion of pending accounts.
769
+ *
770
+ * @since BuddyPress (2.0.0)
771
+ *
772
+ * @param array $signup_ids Array of pending IDs to delete.
773
+ * @param array $result Array of data for deleted accounts.
774
+ */
775
  do_action( 'bp_core_signup_after_delete', $signup_ids, $result );
776
 
777
+ /**
778
+ * Filters the result of the metadata for deleted pending accounts.
779
+ *
780
+ * @since BuddyPress (2.0.0)
781
+ *
782
+ * @param array $result Updated metadata related to deleted pending accounts.
783
+ */
784
  return apply_filters( 'bp_core_signup_delete', $result );
785
  }
786
  }
bp-members/bp-members-filters.php CHANGED
@@ -111,6 +111,15 @@ function bp_members_edit_profile_url( $url, $user_id, $scheme = 'admin' ) {
111
  $profile_link = $url;
112
  }
113
 
 
 
 
 
 
 
 
 
 
114
  return apply_filters( 'bp_members_edit_profile_url', $profile_link, $url, $user_id, $scheme );
115
  }
116
  add_filter( 'edit_profile_url', 'bp_members_edit_profile_url', 10, 3 );
111
  $profile_link = $url;
112
  }
113
 
114
+ /**
115
+ * Filters the user profile URL to point to BuddyPress profile edit.
116
+ *
117
+ * @since BuddyPress (1.5.2)
118
+ *
119
+ * @param string $url WP profile edit URL.
120
+ * @param int $user_id ID of the user.
121
+ * @param string $scheme Scheme to use.
122
+ */
123
  return apply_filters( 'bp_members_edit_profile_url', $profile_link, $url, $user_id, $scheme );
124
  }
125
  add_filter( 'edit_profile_url', 'bp_members_edit_profile_url', 10, 3 );
bp-members/bp-members-functions.php CHANGED
@@ -78,19 +78,18 @@ add_action( 'bp_setup_globals', 'bp_core_define_slugs', 11 );
78
  * @param array $args {
79
  * Array of arguments. All are optional. See {@link BP_User_Query} for
80
  * a more complete description of arguments.
81
- * @type string $type Sort order. Default: 'active'.
82
- * @type int $user_id Limit results to friends of a user. Default: false.
83
- * @type mixed $exclude IDs to exclude from results. Default: false.
84
- * @type string $search_terms Limit to users matching search terms. Default: false.
85
- * @type string $meta_key Limit to users with a meta_key. Default: false.
86
- * @type string $meta_value Limit to users with a meta_value (with
87
- * meta_key). Default: false.
88
  * @type mixed $include Limit results by user IDs. Default: false.
89
- * @type int $per_page Results per page. Default: 20.
90
- * @type int $page Page of results. Default: 1.
91
- * @type bool $populate_extras Fetch optional extras. Default: true.
92
- * @type string|bool $count_total How to do total user count.
93
- * Default: 'count_query'.
94
  * }
95
  * @return array
96
  */
@@ -104,6 +103,7 @@ function bp_core_get_users( $args = '' ) {
104
  'search_terms' => false, // Limit to users that match these search terms
105
  'meta_key' => false, // Limit to users who have this piece of usermeta
106
  'meta_value' => false, // With meta_key, limit to users where usermeta matches this value
 
107
  'include' => false, // Pass comma separated list of user_ids to limit to only these users
108
  'per_page' => 20, // The number of results to return per page
109
  'page' => 1, // The page to return if limiting per page
@@ -139,6 +139,14 @@ function bp_core_get_users( $args = '' ) {
139
  );
140
  }
141
 
 
 
 
 
 
 
 
 
142
  return apply_filters( 'bp_core_get_users', $retval, $r );
143
  }
144
 
@@ -168,6 +176,16 @@ function bp_core_get_user_domain( $user_id = 0, $user_nicename = false, $user_lo
168
  // Use the 'bp_core_get_user_domain' filter instead.
169
  $domain = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login );
170
 
 
 
 
 
 
 
 
 
 
 
171
  return apply_filters( 'bp_core_get_user_domain', $domain, $user_id, $user_nicename, $user_login );
172
  }
173
 
@@ -186,6 +204,14 @@ function bp_core_get_core_userdata( $user_id = 0 ) {
186
  $userdata = BP_Core_User::get_core_userdata( $user_id );
187
  wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' );
188
  }
 
 
 
 
 
 
 
 
189
  return apply_filters( 'bp_core_get_core_userdata', $userdata );
190
  }
191
 
@@ -218,6 +244,14 @@ function bp_core_get_userid( $username = '' ) {
218
 
219
  $user = get_user_by( 'login', $username );
220
 
 
 
 
 
 
 
 
 
221
  return apply_filters( 'bp_core_get_userid', ! empty( $user->ID ) ? $user->ID : NULL, $username );
222
  }
223
 
@@ -236,6 +270,14 @@ function bp_core_get_userid_from_nicename( $user_nicename = '' ) {
236
 
237
  $user = get_user_by( 'slug', $user_nicename );
238
 
 
 
 
 
 
 
 
 
239
  return apply_filters( 'bp_core_get_userid_from_nicename', ! empty( $user->ID ) ? $user->ID : NULL, $user_nicename );
240
  }
241
 
@@ -310,6 +352,13 @@ function bp_core_get_username( $user_id = 0, $user_nicename = false, $user_login
310
  // wp_cache_delete( 'bp_user_username_' . $user_id );
311
  }
312
 
 
 
 
 
 
 
 
313
  return apply_filters( 'bp_core_get_username', $username );
314
  }
315
 
@@ -367,6 +416,13 @@ function bp_members_get_user_nicename( $user_id ) {
367
  wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' );
368
  }
369
 
 
 
 
 
 
 
 
370
  return apply_filters( 'bp_members_get_user_nicename', $user_nicename );
371
  }
372
 
@@ -394,6 +450,13 @@ function bp_core_get_user_email( $uid ) {
394
  wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
395
  }
396
 
 
 
 
 
 
 
 
397
  return apply_filters( 'bp_core_get_user_email', $email );
398
  }
399
 
@@ -431,6 +494,14 @@ function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false
431
  return $url;
432
  }
433
 
 
 
 
 
 
 
 
 
434
  return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>', $user_id );
435
  }
436
 
@@ -525,9 +596,6 @@ function bp_core_get_user_displaynames( $user_ids ) {
525
  * user not found.
526
  */
527
  function bp_core_get_user_displayname( $user_id_or_username ) {
528
-
529
- $fullname = '';
530
-
531
  if ( empty( $user_id_or_username ) ) {
532
  return false;
533
  }
@@ -550,6 +618,14 @@ function bp_core_get_user_displayname( $user_id_or_username ) {
550
  $fullname = $display_names[ $user_id ];
551
  }
552
 
 
 
 
 
 
 
 
 
553
  return apply_filters( 'bp_core_get_user_displayname', $fullname, $user_id );
554
  }
555
  add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 );
@@ -565,6 +641,14 @@ add_filter( 'bp_core_get_user_displayname', 'esc_html' );
565
  */
566
  function bp_core_get_userlink_by_email( $email ) {
567
  $user = get_user_by( 'email', $email );
 
 
 
 
 
 
 
 
568
  return apply_filters( 'bp_core_get_userlink_by_email', bp_core_get_userlink( $user->ID, false, false, true ) );
569
  }
570
 
@@ -582,6 +666,13 @@ function bp_core_get_userlink_by_username( $username ) {
582
  $user_id = bp_core_get_userid_from_nicename( $username );
583
  }
584
 
 
 
 
 
 
 
 
585
  return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
586
  }
587
 
@@ -597,12 +688,21 @@ function bp_core_get_userlink_by_username( $username ) {
597
  function bp_core_get_total_member_count() {
598
  global $wpdb;
599
 
600
- if ( !$count = wp_cache_get( 'bp_total_member_count', 'bp' ) ) {
 
 
601
  $status_sql = bp_core_get_status_sql();
602
  $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}" );
603
  wp_cache_set( 'bp_total_member_count', $count, 'bp' );
604
  }
605
 
 
 
 
 
 
 
 
606
  return apply_filters( 'bp_core_get_total_member_count', $count );
607
  }
608
 
@@ -631,6 +731,13 @@ function bp_core_get_active_member_count() {
631
  set_transient( 'bp_active_member_count', $count );
632
  }
633
 
 
 
 
 
 
 
 
634
  return apply_filters( 'bp_core_get_active_member_count', $count );
635
  }
636
 
@@ -710,8 +817,29 @@ function bp_core_process_spammer_status( $user_id, $status, $do_wp_cleanup = tru
710
 
711
  // Call multisite actions in single site mode for good measure
712
  if ( !is_multisite() ) {
713
- $wp_action = ( true === $is_spam ) ? 'make_spam_user' : 'make_ham_user';
714
- do_action( $wp_action, bp_displayed_user_id() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
  }
716
  }
717
 
@@ -721,10 +849,36 @@ function bp_core_process_spammer_status( $user_id, $status, $do_wp_cleanup = tru
721
  }
722
 
723
  // We need a special hook for is_spam so that components can delete data at spam time
724
- $bp_action = ( true === $is_spam ) ? 'bp_make_spam_user' : 'bp_make_ham_user';
725
- do_action( $bp_action, $user_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
726
 
727
- // Allow plugins to do neat things
 
 
 
 
 
 
 
728
  do_action( 'bp_core_process_spammer_status', $user_id, $is_spam );
729
 
730
  // Put things back how we found them
@@ -812,6 +966,13 @@ function bp_is_user_spammer( $user_id = 0 ) {
812
  }
813
  }
814
 
 
 
 
 
 
 
 
815
  return apply_filters( 'bp_is_user_spammer', (bool) $is_spammer );
816
  }
817
 
@@ -869,6 +1030,13 @@ function bp_is_user_deleted( $user_id = 0 ) {
869
  }
870
  }
871
 
 
 
 
 
 
 
 
872
  return apply_filters( 'bp_is_user_deleted', (bool) $is_deleted );
873
  }
874
 
@@ -973,7 +1141,7 @@ function bp_update_user_last_activity( $user_id = 0, $time = '' ) {
973
  // Remove our warning and re-add.
974
  remove_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 );
975
  remove_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 3 );
976
- update_user_meta( $user_id, 'last_activity', $time );
977
  add_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 );
978
  add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 3 );
979
 
@@ -1053,6 +1221,15 @@ function bp_get_user_last_activity( $user_id = 0 ) {
1053
  $activity = $last_activity[ $user_id ]['date_recorded'];
1054
  }
1055
 
 
 
 
 
 
 
 
 
 
1056
  return apply_filters( 'bp_get_user_last_activity', $activity, $user_id );
1057
  }
1058
 
@@ -1139,6 +1316,13 @@ function bp_core_delete_account( $user_id = 0 ) {
1139
  }
1140
  }
1141
 
 
 
 
 
 
 
 
1142
  do_action( 'bp_core_pre_delete_account', $user_id );
1143
 
1144
  // Specifically handle multi-site environment
@@ -1154,6 +1338,13 @@ function bp_core_delete_account( $user_id = 0 ) {
1154
  $retval = wp_delete_user( $user_id );
1155
  }
1156
 
 
 
 
 
 
 
 
1157
  do_action( 'bp_core_deleted_account', $user_id );
1158
 
1159
  return $retval;
@@ -1330,7 +1521,13 @@ function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) {
1330
  }
1331
  }
1332
 
1333
- // Add our slugs to the array and allow them to be filtered
 
 
 
 
 
 
1334
  $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) );
1335
 
1336
  // Merge the arrays together
@@ -1339,6 +1536,13 @@ function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) {
1339
  // Remove duplicates
1340
  $illegal_names = array_unique( (array) $merged_names );
1341
 
 
 
 
 
 
 
 
1342
  return apply_filters( 'bp_core_illegal_names', $illegal_names );
1343
  }
1344
  add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names', 10, 2 );
@@ -1450,7 +1654,13 @@ function bp_core_validate_user_signup( $user_name, $user_email ) {
1450
  } else {
1451
  $errors = new WP_Error();
1452
 
1453
- // Apply any user_login filters added by BP or other plugins before validating
 
 
 
 
 
 
1454
  $user_name = apply_filters( 'pre_user_login', $user_name );
1455
 
1456
  // User name can't be empty
@@ -1514,6 +1724,13 @@ function bp_core_validate_user_signup( $user_name, $user_email ) {
1514
  $result = apply_filters( 'wpmu_validate_user_signup', $result );
1515
  }
1516
 
 
 
 
 
 
 
 
1517
  return apply_filters( 'bp_core_validate_user_signup', $result );
1518
  }
1519
 
@@ -1531,6 +1748,13 @@ function bp_core_validate_blog_signup( $blog_url, $blog_title ) {
1531
  return false;
1532
  }
1533
 
 
 
 
 
 
 
 
1534
  return apply_filters( 'bp_core_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );
1535
  }
1536
 
@@ -1583,7 +1807,7 @@ function bp_core_signup_user( $user_login, $user_password, $user_email, $usermet
1583
  }
1584
 
1585
  $activation_key = wp_hash( $user_id );
1586
- update_user_meta( $user_id, 'activation_key', $activation_key );
1587
  }
1588
 
1589
  $args = array(
@@ -1595,6 +1819,18 @@ function bp_core_signup_user( $user_login, $user_password, $user_email, $usermet
1595
 
1596
  BP_Signup::add( $args );
1597
 
 
 
 
 
 
 
 
 
 
 
 
 
1598
  if ( apply_filters( 'bp_core_signup_send_activation_key', true, $user_id, $user_email, $activation_key, $usermeta ) ) {
1599
  bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key );
1600
  }
@@ -1602,6 +1838,18 @@ function bp_core_signup_user( $user_login, $user_password, $user_email, $usermet
1602
 
1603
  $bp->signup->username = $user_login;
1604
 
 
 
 
 
 
 
 
 
 
 
 
 
1605
  do_action( 'bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta );
1606
 
1607
  return $user_id;
@@ -1622,6 +1870,16 @@ function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name,
1622
  return false;
1623
  }
1624
 
 
 
 
 
 
 
 
 
 
 
1625
  return apply_filters( 'bp_core_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );
1626
  }
1627
 
@@ -1677,7 +1935,7 @@ function bp_core_activate_signup( $key ) {
1677
 
1678
  // If a user ID is found, this may be a legacy signup, or one
1679
  // created locally for backward compatibility. Process it.
1680
- } else if ( $key == wp_hash( $user_id ) ) {
1681
  // Change the user's status so they become active
1682
  if ( ! $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 0 WHERE ID = %d", $user_id ) ) ) {
1683
  return new WP_Error( 'invalid_key', __( 'Invalid activation key', 'buddypress' ) );
@@ -1723,6 +1981,16 @@ function bp_core_activate_signup( $key ) {
1723
  wp_new_user_notification( $user_id );
1724
 
1725
  if ( isset( $user_already_created ) ) {
 
 
 
 
 
 
 
 
 
 
1726
  do_action( 'bp_core_activated_user', $user_id, $key, $user );
1727
  return $user_id;
1728
  }
@@ -1758,6 +2026,15 @@ function bp_core_activate_signup( $key ) {
1758
  $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id ) );
1759
  }
1760
 
 
 
 
 
 
 
 
 
 
1761
  do_action( 'bp_core_activated_user', $user_id, $key, $user );
1762
 
1763
  return $user_id;
@@ -1844,34 +2121,6 @@ function bp_members_migrate_signups() {
1844
  }
1845
  }
1846
 
1847
- /**
1848
- * Create a "became a registered user" activity item when a user activates his account.
1849
- *
1850
- * @param array $user Array of userdata passed to bp_core_activated_user hook.
1851
- */
1852
- function bp_core_new_user_activity( $user ) {
1853
- if ( empty( $user ) || ! bp_is_active( 'activity' ) || ! bp_is_active( 'xprofile' ) ) {
1854
- return false;
1855
- }
1856
-
1857
- if ( is_array( $user ) ) {
1858
- $user_id = $user['user_id'];
1859
- } else {
1860
- $user_id = $user;
1861
- }
1862
-
1863
- if ( empty( $user_id ) ) {
1864
- return false;
1865
- }
1866
-
1867
- bp_activity_add( array(
1868
- 'user_id' => $user_id,
1869
- 'component' => 'xprofile',
1870
- 'type' => 'new_member'
1871
- ) );
1872
- }
1873
- add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' );
1874
-
1875
  /**
1876
  * Map a user's WP display name to the XProfile fullname field, if necessary.
1877
  *
@@ -1925,6 +2174,13 @@ function bp_core_signup_avatar_upload_dir() {
1925
  $newburl = $newurl;
1926
  $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
1927
 
 
 
 
 
 
 
 
1928
  return apply_filters( 'bp_core_signup_avatar_upload_dir', array(
1929
  'path' => $path,
1930
  'url' => $newurl,
@@ -1943,19 +2199,56 @@ function bp_core_signup_avatar_upload_dir() {
1943
  * @param string $key Activation key.
1944
  */
1945
  function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
1946
- $activate_url = bp_get_activation_page() ."?key=$key";
1947
  $activate_url = esc_url( $activate_url );
1948
 
1949
  $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 );
1950
  $subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
1951
 
1952
- // Send the message
 
 
 
 
 
 
 
1953
  $to = apply_filters( 'bp_core_signup_send_validation_email_to', $user_email, $user_id );
 
 
 
 
 
 
 
 
 
1954
  $subject = apply_filters( 'bp_core_signup_send_validation_email_subject', $subject, $user_id );
 
 
 
 
 
 
 
 
 
 
1955
  $message = apply_filters( 'bp_core_signup_send_validation_email_message', $message, $user_id, $activate_url );
1956
 
1957
  wp_mail( $to, $subject, $message );
1958
 
 
 
 
 
 
 
 
 
 
 
 
1959
  do_action( 'bp_core_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key );
1960
  }
1961
 
@@ -2100,7 +2393,7 @@ function bp_stop_live_spammer() {
2100
  $is_login = false;
2101
  if ( isset( $_GLOBALS['pagenow'] ) && false !== strpos( $GLOBALS['pagenow'], 'wp-login.php' ) ) {
2102
  $is_login = true;
2103
- } else if ( isset( $_SERVER['SCRIPT_NAME'] ) && false !== strpos( $_SERVER['SCRIPT_NAME'], 'wp-login.php' ) ) {
2104
  $is_login = true;
2105
  }
2106
 
@@ -2124,7 +2417,13 @@ function bp_stop_live_spammer() {
2124
  'reauth' => 1
2125
  );
2126
 
2127
- // setup login URL
 
 
 
 
 
 
2128
  $login_url = apply_filters( 'bp_live_spammer_redirect', add_query_arg( $args, wp_login_url() ) );
2129
 
2130
  // redirect user to login page
@@ -2148,3 +2447,219 @@ function bp_live_spammer_login_error() {
2148
  add_action( 'login_head', 'wp_shake_js', 12 );
2149
  }
2150
  add_action( 'login_form_bp-spam', 'bp_live_spammer_login_error' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  * @param array $args {
79
  * Array of arguments. All are optional. See {@link BP_User_Query} for
80
  * a more complete description of arguments.
81
+ * @type string $type Sort order. Default: 'active'.
82
+ * @type int $user_id Limit results to friends of a user. Default: false.
83
+ * @type mixed $exclude IDs to exclude from results. Default: false.
84
+ * @type string $search_terms Limit to users matching search terms. Default: false.
85
+ * @type string $meta_key Limit to users with a meta_key. Default: false.
86
+ * @type string $meta_value Limit to users with a meta_value (with meta_key). Default: false.
87
+ * @type array|string $member_type Array or comma-separated string of member types.
88
  * @type mixed $include Limit results by user IDs. Default: false.
89
+ * @type int $per_page Results per page. Default: 20.
90
+ * @type int $page Page of results. Default: 1.
91
+ * @type bool $populate_extras Fetch optional extras. Default: true.
92
+ * @type string|bool $count_total How to do total user count. Default: 'count_query'.
 
93
  * }
94
  * @return array
95
  */
103
  'search_terms' => false, // Limit to users that match these search terms
104
  'meta_key' => false, // Limit to users who have this piece of usermeta
105
  'meta_value' => false, // With meta_key, limit to users where usermeta matches this value
106
+ 'member_type' => '',
107
  'include' => false, // Pass comma separated list of user_ids to limit to only these users
108
  'per_page' => 20, // The number of results to return per page
109
  'page' => 1, // The page to return if limiting per page
139
  );
140
  }
141
 
142
+ /**
143
+ * Filters the results of the user query.
144
+ *
145
+ * @since BuddyPress (1.2.0)
146
+ *
147
+ * @param array $retval Array of users for the current query.
148
+ * @param array $r Array of parsed query arguments.
149
+ */
150
  return apply_filters( 'bp_core_get_users', $retval, $r );
151
  }
152
 
176
  // Use the 'bp_core_get_user_domain' filter instead.
177
  $domain = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login );
178
 
179
+ /**
180
+ * Filters the domain for the passed user.
181
+ *
182
+ * @since BuddyPress (1.0.1)
183
+ *
184
+ * @param string $domain Domain for the passed user.
185
+ * @param int $user_id ID of the passed user.
186
+ * @param string $user_nicename User nicename of the passed user.
187
+ * @param string $user_login User login of the passed user.
188
+ */
189
  return apply_filters( 'bp_core_get_user_domain', $domain, $user_id, $user_nicename, $user_login );
190
  }
191
 
204
  $userdata = BP_Core_User::get_core_userdata( $user_id );
205
  wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' );
206
  }
207
+
208
+ /**
209
+ * Filters the userdata for a passed user.
210
+ *
211
+ * @since BuddyPress (1.2.0)
212
+ *
213
+ * @param array $userdata Array of user data for a passed user.
214
+ */
215
  return apply_filters( 'bp_core_get_core_userdata', $userdata );
216
  }
217
 
244
 
245
  $user = get_user_by( 'login', $username );
246
 
247
+ /**
248
+ * Filters the ID of a user, based on user_login.
249
+ *
250
+ * @since BuddyPress (1.0.1)
251
+ *
252
+ * @param int|null $value ID of the user or null.
253
+ * @param string $username User login to check.
254
+ */
255
  return apply_filters( 'bp_core_get_userid', ! empty( $user->ID ) ? $user->ID : NULL, $username );
256
  }
257
 
270
 
271
  $user = get_user_by( 'slug', $user_nicename );
272
 
273
+ /**
274
+ * Filters the user ID based on user_nicename.
275
+ *
276
+ * @since BuddyPress (1.2.3)
277
+ *
278
+ * @param int|null $value ID of the user or null.
279
+ * @param string $user_nicename User nicename to check.
280
+ */
281
  return apply_filters( 'bp_core_get_userid_from_nicename', ! empty( $user->ID ) ? $user->ID : NULL, $user_nicename );
282
  }
283
 
352
  // wp_cache_delete( 'bp_user_username_' . $user_id );
353
  }
354
 
355
+ /**
356
+ * Filters the username based on originally provided user ID.
357
+ *
358
+ * @since BuddyPress (1.0.1)
359
+ *
360
+ * @param string $username Username determined by user ID.
361
+ */
362
  return apply_filters( 'bp_core_get_username', $username );
363
  }
364
 
416
  wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' );
417
  }
418
 
419
+ /**
420
+ * Filters the user_nicename based on originally provided user ID.
421
+ *
422
+ * @since BuddyPress (1.5.0)
423
+ *
424
+ * @param string $username User nice name determined by user ID.
425
+ */
426
  return apply_filters( 'bp_members_get_user_nicename', $user_nicename );
427
  }
428
 
450
  wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
451
  }
452
 
453
+ /**
454
+ * Filters the user email for user based on user ID.
455
+ *
456
+ * @since BuddyPress (1.0.1)
457
+ *
458
+ * @param string $email Email determined for the user.
459
+ */
460
  return apply_filters( 'bp_core_get_user_email', $email );
461
  }
462
 
494
  return $url;
495
  }
496
 
497
+ /**
498
+ * Filters the link text for the passed in user.
499
+ *
500
+ * @since BuddyPress (1.2.0)
501
+ *
502
+ * @param string $value Link text based on passed parameters.
503
+ * @param int $user_id ID of the user to check.
504
+ */
505
  return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>', $user_id );
506
  }
507
 
596
  * user not found.
597
  */
598
  function bp_core_get_user_displayname( $user_id_or_username ) {
 
 
 
599
  if ( empty( $user_id_or_username ) ) {
600
  return false;
601
  }
618
  $fullname = $display_names[ $user_id ];
619
  }
620
 
621
+ /**
622
+ * Filters the display name for the passed in user.
623
+ *
624
+ * @since BuddyPress (1.0.1)
625
+ *
626
+ * @param string $fullname Display name for the user.
627
+ * @param int $user_id ID of the user to check.
628
+ */
629
  return apply_filters( 'bp_core_get_user_displayname', $fullname, $user_id );
630
  }
631
  add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 );
641
  */
642
  function bp_core_get_userlink_by_email( $email ) {
643
  $user = get_user_by( 'email', $email );
644
+
645
+ /**
646
+ * Filters the user link for the user based on user email address.
647
+ *
648
+ * @since BuddyPress (1.0.1)
649
+ *
650
+ * @param string|bool $value URL for the user if found, otherwise false.
651
+ */
652
  return apply_filters( 'bp_core_get_userlink_by_email', bp_core_get_userlink( $user->ID, false, false, true ) );
653
  }
654
 
666
  $user_id = bp_core_get_userid_from_nicename( $username );
667
  }
668
 
669
+ /**
670
+ * Filters the user link for the user based on username.
671
+ *
672
+ * @since BuddyPress (1.0.1)
673
+ *
674
+ * @param string|bool $value URL for the user if found, otherwise false.
675
+ */
676
  return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
677
  }
678
 
688
  function bp_core_get_total_member_count() {
689
  global $wpdb;
690
 
691
+ $count = wp_cache_get( 'bp_total_member_count', 'bp' );
692
+
693
+ if ( false === $count ) {
694
  $status_sql = bp_core_get_status_sql();
695
  $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}" );
696
  wp_cache_set( 'bp_total_member_count', $count, 'bp' );
697
  }
698
 
699
+ /**
700
+ * Filters the total number of members for the installation.
701
+ *
702
+ * @since BuddyPress (1.2.0)
703
+ *
704
+ * @param int $count Total number of members.
705
+ */
706
  return apply_filters( 'bp_core_get_total_member_count', $count );
707
  }
708
 
731
  set_transient( 'bp_active_member_count', $count );
732
  }
733
 
734
+ /**
735
+ * Filters the total number of members for the installation limited to those with last_activity.
736
+ *
737
+ * @since BuddyPress (1.6.0)
738
+ *
739
+ * @param int $count Total number of active members.
740
+ */
741
  return apply_filters( 'bp_core_get_active_member_count', $count );
742
  }
743
 
817
 
818
  // Call multisite actions in single site mode for good measure
819
  if ( !is_multisite() ) {
820
+ if ( true === $is_spam ) {
821
+
822
+ /**
823
+ * Fires at end of processing spammer in Dashboard if not multisite and user is spam.
824
+ *
825
+ * @since BuddyPress (1.5.0)
826
+ *
827
+ * @param int $value Displayed user ID.
828
+ */
829
+ do_action( 'make_spam_user', bp_displayed_user_id() );
830
+ } else {
831
+
832
+ /**
833
+ * Fires at end of processing spammer in Dashboard if not multisite and user is not spam.
834
+ *
835
+ * @since BuddyPress (1.5.0)
836
+ *
837
+ * @param int $value Displayed user ID.
838
+ */
839
+ do_action( 'make_ham_user', bp_displayed_user_id() );
840
+ }
841
+
842
+
843
  }
844
  }
845
 
849
  }
850
 
851
  // We need a special hook for is_spam so that components can delete data at spam time
852
+ if ( true === $is_spam ) {
853
+
854
+ /**
855
+ * Fires at the end of the process spammer process if the user is spam.
856
+ *
857
+ * @since BuddyPress (1.5.0)
858
+ *
859
+ * @param int $value Displayed user ID.
860
+ */
861
+ do_action( 'bp_make_spam_user', $user_id );
862
+ } else {
863
+
864
+ /**
865
+ * Fires at the end of the process spammer process if the user is not spam.
866
+ *
867
+ * @since BuddyPress (1.5.0)
868
+ *
869
+ * @param int $value Displayed user ID.
870
+ */
871
+ do_action( 'bp_make_ham_user', $user_id );
872
+ }
873
 
874
+ /**
875
+ * Fires at the end of the process for hanlding spammer status.
876
+ *
877
+ * @since BuddyPress (1.5.5)
878
+ *
879
+ * @param int $user_id ID of the processed user.
880
+ * @param bool $is_spam The determined spam status of processed user.
881
+ */
882
  do_action( 'bp_core_process_spammer_status', $user_id, $is_spam );
883
 
884
  // Put things back how we found them
966
  }
967
  }
968
 
969
+ /**
970
+ * Filters whether a user is marked as a spammer.
971
+ *
972
+ * @since BuddyPress (1.6.0)
973
+ *
974
+ * @param bool $is_spammer Whether or not user is marked as spammer.
975
+ */
976
  return apply_filters( 'bp_is_user_spammer', (bool) $is_spammer );
977
  }
978
 
1030
  }
1031
  }
1032
 
1033
+ /**
1034
+ * Filters whether a user is marked as deleted.
1035
+ *
1036
+ * @since BuddyPress (1.6.0)
1037
+ *
1038
+ * @param bool $is_deleted Whether or not user is marked as deleted.
1039
+ */
1040
  return apply_filters( 'bp_is_user_deleted', (bool) $is_deleted );
1041
  }
1042
 
1141
  // Remove our warning and re-add.
1142
  remove_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 );
1143
  remove_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 3 );
1144
+ bp_update_user_meta( $user_id, 'last_activity', $time );
1145
  add_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 );
1146
  add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 3 );
1147
 
1221
  $activity = $last_activity[ $user_id ]['date_recorded'];
1222
  }
1223
 
1224
+ /**
1225
+ * Filters the last activity for a given user.
1226
+ *
1227
+ * @since BuddyPress (1.9.0)
1228
+ *
1229
+ * @param string $activity Time of last activity, in 'Y-m-d H:i:s' format or
1230
+ * an empty string if none found.
1231
+ * @param int $user_id ID of the user being checked.
1232
+ */
1233
  return apply_filters( 'bp_get_user_last_activity', $activity, $user_id );
1234
  }
1235
 
1316
  }
1317
  }
1318
 
1319
+ /**
1320
+ * Fires before the processing of an account deletion.
1321
+ *
1322
+ * @since BuddyPress (1.6.0)
1323
+ *
1324
+ * @param int $user_id ID of the user account being deleted.
1325
+ */
1326
  do_action( 'bp_core_pre_delete_account', $user_id );
1327
 
1328
  // Specifically handle multi-site environment
1338
  $retval = wp_delete_user( $user_id );
1339
  }
1340
 
1341
+ /**
1342
+ * Fires after the deletion of an account.
1343
+ *
1344
+ * @since BuddyPress (1.6.0)
1345
+ *
1346
+ * @param int $user_id ID of the user account that was deleted.
1347
+ */
1348
  do_action( 'bp_core_deleted_account', $user_id );
1349
 
1350
  return $retval;
1521
  }
1522
  }
1523
 
1524
+ /**
1525
+ * Filters the array of default illegal usernames.
1526
+ *
1527
+ * @since BuddyPress (1.2.2)
1528
+ *
1529
+ * @param array $value Merged and unique array of illegal usernames.
1530
+ */
1531
  $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) );
1532
 
1533
  // Merge the arrays together
1536
  // Remove duplicates
1537
  $illegal_names = array_unique( (array) $merged_names );
1538
 
1539
+ /**
1540
+ * Filters the array of default illegal names.
1541
+ *
1542
+ * @since BuddyPress (1.2.5)
1543
+ *
1544
+ * @param array $value Merged and unique array of illegal names.
1545
+ */
1546
  return apply_filters( 'bp_core_illegal_names', $illegal_names );
1547
  }
1548
  add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names', 10, 2 );
1654
  } else {
1655
  $errors = new WP_Error();
1656
 
1657
+ /**
1658
+ * Filters the username before being validated.
1659
+ *
1660
+ * @since BuddyPress (1.5.5)
1661
+ *
1662
+ * @param string $user_name Username to validate.
1663
+ */
1664
  $user_name = apply_filters( 'pre_user_login', $user_name );
1665
 
1666
  // User name can't be empty
1724
  $result = apply_filters( 'wpmu_validate_user_signup', $result );
1725
  }
1726
 
1727
+ /**
1728
+ * Filters the result of the user signup validation.
1729
+ *
1730
+ * @since BuddyPress (1.2.2)
1731
+ *
1732
+ * @param array $result Results of user validation including errors, if any.
1733
+ */
1734
  return apply_filters( 'bp_core_validate_user_signup', $result );
1735
  }
1736
 
1748
  return false;
1749
  }
1750
 
1751
+ /**
1752
+ * Filters the validated blog url and title provided at signup.
1753
+ *
1754
+ * @since BuddyPress (1.2.2)
1755
+ *
1756
+ * @param array $value Array with the new site data and error messages.
1757
+ */
1758
  return apply_filters( 'bp_core_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );
1759
  }
1760
 
1807
  }
1808
 
1809
  $activation_key = wp_hash( $user_id );
1810
+ bp_update_user_meta( $user_id, 'activation_key', $activation_key );
1811
  }
1812
 
1813
  $args = array(
1819
 
1820
  BP_Signup::add( $args );
1821
 
1822
+ /**
1823
+ * Filters if BuddyPress should send an activation key for a new signup.
1824
+ *
1825
+ * @since BuddyPress (1.2.3)
1826
+ *
1827
+ * @param bool $value Whether or not to send the activation key.
1828
+ * @param int $user_id User ID to send activation key to.
1829
+ * @param string $user_email User email to send activation key to.
1830
+ * @param string $activation_key Activation key to be sent.
1831
+ * @param array $usermeta Miscellaneous metadata about the user (blog-specific
1832
+ * signup data, xprofile data, etc).
1833
+ */
1834
  if ( apply_filters( 'bp_core_signup_send_activation_key', true, $user_id, $user_email, $activation_key, $usermeta ) ) {
1835
  bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key );
1836
  }
1838
 
1839
  $bp->signup->username = $user_login;
1840
 
1841
+ /**
1842
+ * Fires at the end of the process to sign up a user.
1843
+ *
1844
+ * @since BuddyPress (1.2.2)
1845
+ *
1846
+ * @param bool|WP_Error $user_id True on success, WP_Error on failure.
1847
+ * @param string $user_login Login name requested by the user.
1848
+ * @param string $user_password Password requested by the user.
1849
+ * @param string $user_email Email address requested by the user.
1850
+ * @param array $usermeta Miscellaneous metadata about the user (blog-specific
1851
+ * signup data, xprofile data, etc).
1852
+ */
1853
  do_action( 'bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta );
1854
 
1855
  return $user_id;
1870
  return false;
1871
  }
1872
 
1873
+ /**
1874
+ * Filters the result of wpmu_signup_blog()
1875
+ *
1876
+ * This filter provides no value and is retained for
1877
+ * backwards compatibility.
1878
+ *
1879
+ * @since BuddyPress (1.2.2)
1880
+ *
1881
+ * @param void $value
1882
+ */
1883
  return apply_filters( 'bp_core_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );
1884
  }
1885
 
1935
 
1936
  // If a user ID is found, this may be a legacy signup, or one
1937
  // created locally for backward compatibility. Process it.
1938
+ } elseif ( $key == wp_hash( $user_id ) ) {
1939
  // Change the user's status so they become active
1940
  if ( ! $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 0 WHERE ID = %d", $user_id ) ) ) {
1941
  return new WP_Error( 'invalid_key', __( 'Invalid activation key', 'buddypress' ) );
1981
  wp_new_user_notification( $user_id );
1982
 
1983
  if ( isset( $user_already_created ) ) {
1984
+
1985
+ /**
1986
+ * Fires if the user has already been created.
1987
+ *
1988
+ * @since BuddyPress (1.2.2)
1989
+ *
1990
+ * @param int $user_id ID of the user being checked.
1991
+ * @param string $key Activation key.
1992
+ * @param array $user Array of user data.
1993
+ */
1994
  do_action( 'bp_core_activated_user', $user_id, $key, $user );
1995
  return $user_id;
1996
  }
2026
  $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id ) );
2027
  }
2028
 
2029
+ /**
2030
+ * Fires at the end of the user activation process.
2031
+ *
2032
+ * @since BuddyPress (1.2.2)
2033
+ *
2034
+ * @param int $user_id ID of the user being checked.
2035
+ * @param string $key Activation key.
2036
+ * @param array $user Array of user data.
2037
+ */
2038
  do_action( 'bp_core_activated_user', $user_id, $key, $user );
2039
 
2040
  return $user_id;
2121
  }
2122
  }
2123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2124
  /**
2125
  * Map a user's WP display name to the XProfile fullname field, if necessary.
2126
  *
2174
  $newburl = $newurl;
2175
  $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
2176
 
2177
+ /**
2178
+ * Filters the avatar storage directory for use during registration.
2179
+ *
2180
+ * @since BuddyPress (1.1.1)
2181
+ *
2182
+ * @param array $value Array of path and URL values for created storage directory.
2183
+ */
2184
  return apply_filters( 'bp_core_signup_avatar_upload_dir', array(
2185
  'path' => $path,
2186
  'url' => $newurl,
2199
  * @param string $key Activation key.
2200
  */
2201
  function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
2202
+ $activate_url = trailingslashit( bp_get_activation_page() ) . "{$key}/";
2203
  $activate_url = esc_url( $activate_url );
2204
 
2205
  $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 );
2206
  $subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
2207
 
2208
+ /**
2209
+ * Filters the user email that the validation email will be sent to.
2210
+ *
2211
+ * @since BuddyPress (1.5.0)
2212
+ *
2213
+ * @param string $user_email User email the notification is being sent to.
2214
+ * @param int $user_id ID of the new user receiving email.
2215
+ */
2216
  $to = apply_filters( 'bp_core_signup_send_validation_email_to', $user_email, $user_id );
2217
+
2218
+ /**
2219
+ * Filters the validation email subject that will be sent to user.
2220
+ *
2221
+ * @since BuddyPress (1.5.0)
2222
+ *
2223
+ * @param string $subject Email validation subject text.
2224
+ * @param int $user_id ID of the new user receiving email.
2225
+ */
2226
  $subject = apply_filters( 'bp_core_signup_send_validation_email_subject', $subject, $user_id );
2227
+
2228
+ /**
2229
+ * Filters the validation email message that will be sent to user.
2230
+ *
2231
+ * @since BuddyPress (1.5.0)
2232
+ *
2233
+ * @param string $message Email validation message text.
2234
+ * @param int $user_id ID of the new user receiving email.
2235
+ * @param string $activate_url URL to use for activating account.
2236
+ */
2237
  $message = apply_filters( 'bp_core_signup_send_validation_email_message', $message, $user_id, $activate_url );
2238
 
2239
  wp_mail( $to, $subject, $message );
2240
 
2241
+ /**
2242
+ * Fires after the sending of activation email to a newly registered user.
2243
+ *
2244
+ * @since BuddyPress (1.5.0)
2245
+ *
2246
+ * @param string $subject Subject for the sent email.
2247
+ * @param string $message Message for the sent email.
2248
+ * @param int $user_id ID of the new user.
2249
+ * @param string $user_email Email address of the new user.
2250
+ * @param string $key Activation key.
2251
+ */
2252
  do_action( 'bp_core_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key );
2253
  }
2254
 
2393
  $is_login = false;
2394
  if ( isset( $_GLOBALS['pagenow'] ) && false !== strpos( $GLOBALS['pagenow'], 'wp-login.php' ) ) {
2395
  $is_login = true;
2396
+ } elseif ( isset( $_SERVER['SCRIPT_NAME'] ) && false !== strpos( $_SERVER['SCRIPT_NAME'], 'wp-login.php' ) ) {
2397
  $is_login = true;
2398
  }
2399
 
2417
  'reauth' => 1
2418
  );
2419
 
2420
+ /**
2421
+ * Filters the url used for redirection for a logged in user marked as spam.
2422
+ *
2423
+ * @since BuddyPress (1.8.0)
2424
+ *
2425
+ * @param string $value URL to redirect user to.
2426
+ */
2427
  $login_url = apply_filters( 'bp_live_spammer_redirect', add_query_arg( $args, wp_login_url() ) );
2428
 
2429
  // redirect user to login page
2447
  add_action( 'login_head', 'wp_shake_js', 12 );
2448
  }
2449
  add_action( 'login_form_bp-spam', 'bp_live_spammer_login_error' );
2450
+
2451
+ /** Member Types *************************************************************/
2452
+
2453
+ /**
2454
+ * Register a member type.
2455
+ *
2456
+ * @since BuddyPress (2.2.0)
2457
+ *
2458
+ * @param string $member_type Unique string identifier for the member type.
2459
+ * @param array $args {
2460
+ * Array of arguments describing the member type.
2461
+ *
2462
+ * @type array $labels {
2463
+ * Array of labels to use in various parts of the interface.
2464
+ *
2465
+ * @type string $name Default name. Should typically be plural.
2466
+ * @type string $singular_name Singular name.
2467
+ * }
2468
+ * }
2469
+ * @return object|WP_Error Member type object on success, WP_Error object on failure.
2470
+ */
2471
+ function bp_register_member_type( $member_type, $args = array() ) {
2472
+ $bp = buddypress();
2473
+
2474
+ if ( isset( $bp->members->types[ $member_type ] ) ) {
2475
+ return new WP_Error( 'bp_member_type_exists', __( 'Member type already exists.', 'buddypress' ), $member_type );
2476
+ }
2477
+
2478
+ $r = bp_parse_args( $args, array(
2479
+ 'labels' => array(),
2480
+ ), 'register_member_type' );
2481
+
2482
+ $type = (object) $r;
2483
+
2484
+ // Store the post type name as data in the object (not just as the array key).
2485
+ $type->name = $member_type;
2486
+
2487
+ // Make sure the relevant labels have been filled in.
2488
+ $default_name = isset( $r['labels']['name'] ) ? $r['labels']['name'] : ucfirst( $type->name );
2489
+ $r['labels'] = array_merge( array(
2490
+ 'name' => $default_name,
2491
+ 'singular_name' => $default_name,
2492
+ ), $r['labels'] );
2493
+
2494
+ $bp->members->types[ $member_type ] = $type;
2495
+
2496
+ /**
2497
+ * Fires after a member type is registered.
2498
+ *
2499
+ * @since BuddyPress (2.2.0)
2500
+ *
2501
+ * @param string $member_type Member type identifier.
2502
+ * @param object $type Member type object.
2503
+ */
2504
+ do_action( 'bp_registered_member_type', $member_type, $type );
2505
+
2506
+ return $type;
2507
+ }
2508
+
2509
+ /**
2510
+ * Retrieve a member type object by name.
2511
+ *
2512
+ * @since BuddyPress (2.2.0)
2513
+ *
2514
+ * @param string $post_type The name of the member type.
2515
+ * @return object A member type object.
2516
+ */
2517
+ function bp_get_member_type_object( $member_type ) {
2518
+ $types = bp_get_member_types( array(), 'objects' );
2519
+
2520
+ if ( empty( $types[ $member_type ] ) ) {
2521
+ return null;
2522
+ }
2523
+
2524
+ return $types[ $member_type ];
2525
+ }
2526
+
2527
+ /**
2528
+ * Get a list of all registered member type objects.
2529
+ *
2530
+ * @since BuddyPress (2.2.0)
2531
+ *
2532
+ * @see bp_register_member_type() for accepted arguments.
2533
+ *
2534
+ * @param array|string $args Optional. An array of key => value arguments to match against
2535
+ * the member type objects. Default empty array.
2536
+ * @param string $output Optional. The type of output to return. Accepts 'names'
2537
+ * or 'objects'. Default 'names'.
2538
+ * @param string $operator Optional. The logical operation to perform. 'or' means only one
2539
+ * element from the array needs to match; 'and' means all elements
2540
+ * must match. Accepts 'or' or 'and'. Default 'and'.
2541
+ * @return array A list of member type names or objects.
2542
+ */
2543
+ function bp_get_member_types( $args = array(), $output = 'names', $operator = 'and' ) {
2544
+ $types = buddypress()->members->types;
2545
+
2546
+ $field = 'names' == $output ? 'name' : false;
2547
+
2548
+ $types = wp_filter_object_list( $types, $args, $operator );
2549
+
2550
+ /**
2551
+ * Filters the array of member type objects.
2552
+ *
2553
+ * This filter is run before the $output filter has been applied, so that
2554
+ * filtering functions have access to the entire member type objects.
2555
+ *
2556
+ * @since BuddyPress (2.2.0)
2557
+ *
2558
+ * @param array $types Member type objects, keyed by name.
2559
+ * @param array $args Array of key=>value arguments for filtering.
2560
+ * @param string $operator 'or' to match any of $args, 'and' to require all.
2561
+ */
2562
+ $types = apply_filters( 'bp_get_member_types', $types, $args, $operator );
2563
+
2564
+ if ( 'names' === $output ) {
2565
+ $types = wp_list_pluck( $types, 'name' );
2566
+ }
2567
+
2568
+ return $types;
2569
+ }
2570
+
2571
+ /**
2572
+ * Set type for a member.
2573
+ *
2574
+ * @since BuddyPress (2.2.0)
2575
+ *
2576
+ * @param int $user_id ID of the user.
2577
+ * @param string $member_type Member type.
2578
+ * @param bool $append Optional. True to append this to existing types for user,
2579
+ * false to replace. Default: false.
2580
+ * @return See {@see bp_set_object_terms()}.
2581
+ */
2582
+ function bp_set_member_type( $user_id, $member_type, $append = false ) {
2583
+ // Pass an empty $member_type to remove a user's type.
2584
+ if ( ! empty( $member_type ) && ! bp_get_member_type_object( $member_type ) ) {
2585
+ return false;
2586
+ }
2587
+
2588
+ $retval = bp_set_object_terms( $user_id, $member_type, 'bp_member_type', $append );
2589
+
2590
+ // Bust the cache if the type has been updated.
2591
+ if ( ! is_wp_error( $retval ) ) {
2592
+ wp_cache_delete( $user_id, 'bp_member_type' );
2593
+
2594
+ /**
2595
+ * Fires just after a user's member type has been changed.
2596
+ *
2597
+ * @since BuddyPress (2.2.0)
2598
+ *
2599
+ * @param int $user_id ID of the user whose member type has been updated.
2600
+ * @param string $member_type Member type.
2601
+ * @param bool $append Whether the type is being appended to existing types.
2602
+ */
2603
+ do_action( 'bp_set_member_type', $user_id, $member_type, $append );
2604
+ }
2605
+
2606
+ return $retval;
2607
+ }
2608
+
2609
+ /**
2610
+ * Get type for a member.
2611
+ *
2612
+ * @since BuddyPress (2.2.0)
2613
+ *
2614
+ * @param int $user_id ID of the user.
2615
+ * @param bool $single Optional. Whether to return a single type string. If multiple types are found
2616
+ * for the user, the oldest one will be returned. Default: true.
2617
+ * @return string|array|bool On success, returns a single member type (if $single is true) or an array of member
2618
+ * types (if $single is false). Returns false on failure.
2619
+ */
2620
+ function bp_get_member_type( $user_id, $single = true ) {
2621
+ $types = wp_cache_get( $user_id, 'bp_member_type' );
2622
+
2623
+ if ( false === $types ) {
2624
+ $types = bp_get_object_terms( $user_id, 'bp_member_type' );
2625
+
2626
+ if ( ! is_wp_error( $types ) ) {
2627
+ $types = wp_list_pluck( $types, 'name' );
2628
+ wp_cache_set( $user_id, $types, 'bp_member_type' );
2629
+ }
2630
+ }
2631
+
2632
+ $type = false;
2633
+ if ( ! empty( $types ) ) {
2634
+ if ( $single ) {
2635
+ $type = array_pop( $types );
2636
+ } else {
2637
+ $type = $types;
2638
+ }
2639
+ }
2640
+
2641
+ /**
2642
+ * Filters a user's member type(s).
2643
+ *
2644
+ * @since BuddyPress (2.2.0)
2645
+ *
2646
+ * @param string $type Member type.
2647
+ * @param int $user_id ID of the user.
2648
+ * @param bool $single Whether to return a single type string, or an array.
2649
+ */
2650
+ return apply_filters( 'bp_get_member_type', $type, $user_id, $single );
2651
+ }
2652
+
2653
+ /**
2654
+ * Delete a user's member type when the user when the user is deleted.
2655
+ *
2656
+ * @since BuddyPress (2.2.0)
2657
+ *
2658
+ * @param int $user_id ID of the user.
2659
+ * @return See {@see bp_set_member_type()}.
2660
+ */
2661
+ function bp_remove_member_type_on_user_delete( $user_id ) {
2662
+ return bp_set_member_type( $user_id, '' );
2663
+ }
2664
+ add_action( 'wpmu_delete_user', 'bp_remove_member_type_on_user_delete' );
2665
+ add_action( 'delete_user', 'bp_remove_member_type_on_user_delete' );
bp-members/bp-members-loader.php CHANGED
@@ -11,6 +11,16 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  class BP_Members_Component extends BP_Component {
 
 
 
 
 
 
 
 
 
 
14
 
15
  /**
16
  * Start the members component creation process.
@@ -45,9 +55,15 @@ class BP_Members_Component extends BP_Component {
45
  'screens',
46
  'template',
47
  'adminbar',
48
- 'functions'
 
 
49
  );
50
 
 
 
 
 
51
  // Include these only if in admin
52
  if ( is_admin() ) {
53
  $includes[] = 'admin';
@@ -261,6 +277,21 @@ class BP_Members_Component extends BP_Component {
261
 
262
  parent::setup_title();
263
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  }
265
 
266
  /**
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  class BP_Members_Component extends BP_Component {
14
+ /**
15
+ * Member types.
16
+ *
17
+ * @see bp_register_member_type()
18
+ *
19
+ * @access public
20
+ * @since BuddyPress (2.2.0)
21
+ * @var array
22
+ */
23
+ public $types = array();
24
 
25
  /**
26
  * Start the members component creation process.
55
  'screens',
56
  'template',
57
  'adminbar',
58
+ 'functions',
59
+ 'widgets',
60
+ 'cache',
61
  );
62
 
63
+ if ( bp_is_active( 'activity' ) ) {
64
+ $includes[] = 'activity';
65
+ }
66
+
67
  // Include these only if in admin
68
  if ( is_admin() ) {
69
  $includes[] = 'admin';
277
 
278
  parent::setup_title();
279
  }
280
+
281
+ /**
282
+ * Setup cache groups
283
+ *
284
+ * @since BuddyPress (2.2.0)
285
+ */
286
+ public function setup_cache_groups() {
287
+
288
+ // Global groups
289
+ wp_cache_add_global_groups( array(
290
+ 'bp_member_type'
291
+ ) );
292
+
293
+ parent::setup_cache_groups();
294
+ }
295
  }
296
 
297
  /**
bp-members/bp-members-screens.php CHANGED
@@ -16,7 +16,21 @@ if ( !defined( 'ABSPATH' ) ) exit;
16
  * Handle the display of the profile page by loading the correct template file.
17
  */
18
  function bp_members_screen_display_profile() {
 
 
 
 
 
 
19
  do_action( 'bp_members_screen_display_profile' );
 
 
 
 
 
 
 
 
20
  bp_core_load_template( apply_filters( 'bp_members_screen_display_profile', 'members/single/home' ) );
21
  }
22
 
@@ -27,8 +41,20 @@ function bp_members_screen_index() {
27
  if ( bp_is_members_directory() ) {
28
  bp_update_is_directory( true, 'members' );
29
 
 
 
 
 
 
30
  do_action( 'bp_members_screen_index' );
31
 
 
 
 
 
 
 
 
32
  bp_core_load_template( apply_filters( 'bp_members_screen_index', 'members/index' ) );
33
  }
34
  }
@@ -53,6 +79,13 @@ function bp_core_screen_signup() {
53
  else
54
  $redirect_to = bp_get_root_domain();
55
 
 
 
 
 
 
 
 
56
  bp_core_redirect( apply_filters( 'bp_loggedin_register_page_redirect_to', $redirect_to ) );
57
 
58
  return;
@@ -66,6 +99,11 @@ function bp_core_screen_signup() {
66
  // If the signup page is submitted, validate and save
67
  } elseif ( isset( $_POST['signup_submit'] ) && bp_verify_nonce_request( 'bp_new_signup' ) ) {
68
 
 
 
 
 
 
69
  do_action( 'bp_signup_pre_validate' );
70
 
71
  // Check the base account details for problems
@@ -132,6 +170,11 @@ function bp_core_screen_signup() {
132
  }
133
  }
134
 
 
 
 
 
 
135
  do_action( 'bp_signup_validate' );
136
 
137
  // Add any errors to the action for the field in the template for display.
@@ -139,6 +182,14 @@ function bp_core_screen_signup() {
139
  foreach ( (array) $bp->signup->errors as $fieldname => $error_message ) {
140
  // addslashes() and stripslashes() to avoid create_function()
141
  // syntax errors when the $error_message contains quotes
 
 
 
 
 
 
 
 
142
  add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">" . stripslashes( \'' . addslashes( $error_message ) . '\' ) . "</div>" );' ) );
143
  }
144
  } else {
@@ -185,6 +236,13 @@ function bp_core_screen_signup() {
185
  if ( 'blog' == $active_signup || 'all' == $active_signup )
186
  $usermeta['public'] = ( isset( $_POST['signup_blog_privacy'] ) && 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
187
 
 
 
 
 
 
 
 
188
  $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
189
 
190
  // Finally, sign up the user and/or blog
@@ -201,12 +259,30 @@ function bp_core_screen_signup() {
201
  }
202
  }
203
 
 
 
 
 
 
204
  do_action( 'bp_complete_signup' );
205
  }
206
 
207
  }
208
 
 
 
 
 
 
209
  do_action( 'bp_core_screen_signup' );
 
 
 
 
 
 
 
 
210
  bp_core_load_template( apply_filters( 'bp_core_template_register', array( 'register', 'registration/register' ) ) );
211
  }
212
  add_action( 'bp_screens', 'bp_core_screen_signup' );
@@ -228,35 +304,64 @@ function bp_core_screen_activation() {
228
  $redirect_to = trailingslashit( bp_get_root_domain() );
229
  }
230
 
 
 
 
 
 
 
 
231
  bp_core_redirect( apply_filters( 'bp_loggedin_activate_page_redirect_to', $redirect_to ) );
232
 
233
  return;
234
  }
235
 
236
- // Check if an activation key has been passed
237
- if ( isset( $_GET['key'] ) ) {
 
 
 
 
 
 
 
 
238
 
239
- // Activate the signup
240
- $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $_GET['key'] ) );
 
 
 
 
 
 
 
241
 
242
  // If there were errors, add a message and redirect
243
- if ( !empty( $user->errors ) ) {
244
  bp_core_add_message( $user->get_error_message(), 'error' );
245
  bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
246
  }
247
 
248
- $hashed_key = wp_hash( $_GET['key'] );
249
 
250
- // Check if the avatar folder exists. If it does, move rename it, move
251
- // it and delete the signup avatar dir
252
- if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) )
253
  @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user );
 
254
 
255
  bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
256
-
257
  $bp->activation_complete = true;
258
  }
259
 
 
 
 
 
 
 
 
260
  bp_core_load_template( apply_filters( 'bp_core_template_activate', array( 'activate', 'registration/activate' ) ) );
261
  }
262
  add_action( 'bp_screens', 'bp_core_screen_activation' );
@@ -297,6 +402,11 @@ class BP_Members_Theme_Compat {
297
  if ( ! bp_current_action() && ! bp_current_item() ) {
298
  bp_update_is_directory( true, 'members' );
299
 
 
 
 
 
 
300
  do_action( 'bp_members_screen_index' );
301
 
302
  add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) );
@@ -310,6 +420,11 @@ class BP_Members_Theme_Compat {
310
  if ( bp_is_active( 'activity' ) && bp_is_single_activity() )
311
  return;
312
 
 
 
 
 
 
313
  do_action( 'bp_members_screen_display_profile' );
314
 
315
  add_filter( 'bp_get_buddypress_template', array( $this, 'single_template_hierarchy' ) );
@@ -329,12 +444,19 @@ class BP_Members_Theme_Compat {
329
  *
330
  * @since BuddyPress (1.8.0)
331
  *
332
- * @param string $templates The templates from bp_get_theme_compat_templates().
 
333
  * @return array $templates Array of custom templates to look for.
334
  */
335
  public function directory_template_hierarchy( $templates = array() ) {
336
 
337
- // Setup our templates based on priority
 
 
 
 
 
 
338
  $new_templates = apply_filters( 'bp_template_hierarchy_members_directory', array(
339
  'members/index-directory.php'
340
  ) );
@@ -392,7 +514,13 @@ class BP_Members_Theme_Compat {
392
  // Setup some variables we're going to reference in our custom templates
393
  $user_nicename = buddypress()->displayed_user->userdata->user_nicename;
394
 
395
- // Setup our templates based on priority
 
 
 
 
 
 
396
  $new_templates = apply_filters( 'bp_template_hierarchy_members_single_item', array(
397
  'members/single/index-id-' . sanitize_file_name( bp_displayed_user_id() ) . '.php',
398
  'members/single/index-nicename-' . sanitize_file_name( $user_nicename ) . '.php',
@@ -416,7 +544,7 @@ class BP_Members_Theme_Compat {
416
  public function single_dummy_post() {
417
  bp_theme_compat_reset_post( array(
418
  'ID' => 0,
419
- 'post_title' => '<a href="' . bp_get_displayed_user_link() . '">' . bp_get_displayed_user_fullname() . '</a>',
420
  'post_author' => 0,
421
  'post_date' => 0,
422
  'post_content' => '',
@@ -441,7 +569,7 @@ new BP_Members_Theme_Compat();
441
  /**
442
  * The main theme compat class for BuddyPress Registration.
443
  *
444
- * This class sets up the necessary theme compatability actions to safely output
445
  * registration template parts to the_title and the_content areas of a theme.
446
  *
447
  * @since BuddyPress (1.7.0)
@@ -494,7 +622,16 @@ class BP_Registration_Theme_Compat {
494
  public function template_hierarchy( $templates ) {
495
  $component = sanitize_file_name( bp_current_component() );
496
 
497
- // Setup our templates based on priority
 
 
 
 
 
 
 
 
 
498
  $new_templates = apply_filters( "bp_template_hierarchy_{$component}", array(
499
  "members/index-{$component}.php"
500
  ) );
16
  * Handle the display of the profile page by loading the correct template file.
17
  */
18
  function bp_members_screen_display_profile() {
19
+
20
+ /**
21
+ * Fires right before the loading of the Member profile screen template file.
22
+ *
23
+ * @since BuddyPress (1.5.0)
24
+ */
25
  do_action( 'bp_members_screen_display_profile' );
26
+
27
+ /**
28
+ * Filters the template to load for the Member profile page screen.
29
+ *
30
+ * @since BuddyPress (1.5.0)
31
+ *
32
+ * @param string $template Path to the Member template to load.
33
+ */
34
  bp_core_load_template( apply_filters( 'bp_members_screen_display_profile', 'members/single/home' ) );
35
  }
36
 
41
  if ( bp_is_members_directory() ) {
42
  bp_update_is_directory( true, 'members' );
43
 
44
+ /**
45
+ * Fires right before the loading of the Member directory index screen template file.
46
+ *
47
+ * @since BuddyPress (1.5.0)
48
+ */
49
  do_action( 'bp_members_screen_index' );
50
 
51
+ /**
52
+ * Filters the template to load for the Member directory page screen.
53
+ *
54
+ * @since BuddyPress (1.5.0)
55
+ *
56
+ * @param string $value Path to the member directory template to load.
57
+ */
58
  bp_core_load_template( apply_filters( 'bp_members_screen_index', 'members/index' ) );
59
  }
60
  }
79
  else
80
  $redirect_to = bp_get_root_domain();
81
 
82
+ /**
83
+ * Filters the URL to redirect logged in users to when visiting registration page.
84
+ *
85
+ * @since BuddyPress (1.5.1)
86
+ *
87
+ * @param string $redirect_to URL to redirect user to.
88
+ */
89
  bp_core_redirect( apply_filters( 'bp_loggedin_register_page_redirect_to', $redirect_to ) );
90
 
91
  return;
99
  // If the signup page is submitted, validate and save
100
  } elseif ( isset( $_POST['signup_submit'] ) && bp_verify_nonce_request( 'bp_new_signup' ) ) {
101
 
102
+ /**
103
+ * Fires before the validation of a new signup.
104
+ *
105
+ * @since BuddyPress (2.0.0)
106
+ */
107
  do_action( 'bp_signup_pre_validate' );
108
 
109
  // Check the base account details for problems
170
  }
171
  }
172
 
173
+ /**
174
+ * Fires after the validation of a new signup.
175
+ *
176
+ * @since BuddyPress (1.1.0)
177
+ */
178
  do_action( 'bp_signup_validate' );
179
 
180
  // Add any errors to the action for the field in the template for display.
182
  foreach ( (array) $bp->signup->errors as $fieldname => $error_message ) {
183
  // addslashes() and stripslashes() to avoid create_function()
184
  // syntax errors when the $error_message contains quotes
185
+
186
+ /**
187
+ * Filters the error message in the loop.
188
+ *
189
+ * @since BuddyPress (1.5.0)
190
+ *
191
+ * @param string $value Error message wrapped in html.
192
+ */
193
  add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">" . stripslashes( \'' . addslashes( $error_message ) . '\' ) . "</div>" );' ) );
194
  }
195
  } else {
236
  if ( 'blog' == $active_signup || 'all' == $active_signup )
237
  $usermeta['public'] = ( isset( $_POST['signup_blog_privacy'] ) && 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
238
 
239
+ /**
240
+ * Filters the user meta used for signup.
241
+ *
242
+ * @since BuddyPress (1.1.0)
243
+ *
244
+ * @param array $usermeta Array of user meta to add to signup.
245
+ */
246
  $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
247
 
248
  // Finally, sign up the user and/or blog
259
  }
260
  }
261
 
262
+ /**
263
+ * Fires after the completion of a new signup.
264
+ *
265
+ * @since BuddyPress (1.1.0)
266
+ */
267
  do_action( 'bp_complete_signup' );
268
  }
269
 
270
  }
271
 
272
+ /**
273
+ * Fires right before the loading of the Member registration screen template file.
274
+ *
275
+ * @since BuddyPress (1.5.0)
276
+ */
277
  do_action( 'bp_core_screen_signup' );
278
+
279
+ /**
280
+ * Filters the template to load for the Member registration page screen.
281
+ *
282
+ * @since BuddyPress (1.5.0)
283
+ *
284
+ * @param string $value Path to the Member registration template to load.
285
+ */
286
  bp_core_load_template( apply_filters( 'bp_core_template_register', array( 'register', 'registration/register' ) ) );
287
  }
288
  add_action( 'bp_screens', 'bp_core_screen_signup' );
304
  $redirect_to = trailingslashit( bp_get_root_domain() );
305
  }
306
 
307
+ /**
308
+ * Filters the URL to redirect logged in users to when visiting activation page.
309
+ *
310
+ * @since BuddyPress (1.9.0)
311
+ *
312
+ * @param string $redirect_to URL to redirect user to.
313
+ */
314
  bp_core_redirect( apply_filters( 'bp_loggedin_activate_page_redirect_to', $redirect_to ) );
315
 
316
  return;
317
  }
318
 
319
+ // grab the key (the old way)
320
+ $key = isset( $_GET['key'] ) ? $_GET['key'] : '';
321
+
322
+ // grab the key (the new way)
323
+ if ( empty( $key ) ) {
324
+ $key = bp_current_action();
325
+ }
326
+
327
+ // we've got a key; let's attempt to activate the signup
328
+ if ( ! empty( $key ) ) {
329
 
330
+ /**
331
+ * Filters the activation signup.
332
+ *
333
+ * @since BuddyPress (1.1.0)
334
+ *
335
+ * @param bool|int $value Value returned by activation.
336
+ * Integer on success, boolean on failure.
337
+ */
338
+ $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );
339
 
340
  // If there were errors, add a message and redirect
341
+ if ( ! empty( $user->errors ) ) {
342
  bp_core_add_message( $user->get_error_message(), 'error' );
343
  bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
344
  }
345
 
346
+ $hashed_key = wp_hash( $key );
347
 
348
+ // Check if the signup avatar folder exists. If it does, move the folder to
349
+ // the BP user avatars directory
350
+ if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) {
351
  @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user );
352
+ }
353
 
354
  bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
 
355
  $bp->activation_complete = true;
356
  }
357
 
358
+ /**
359
+ * Filters the template to load for the Member activation page screen.
360
+ *
361
+ * @since BuddyPress (1.1.1)
362
+ *
363
+ * @param string $value Path to the Member activation template to load.
364
+ */
365
  bp_core_load_template( apply_filters( 'bp_core_template_activate', array( 'activate', 'registration/activate' ) ) );
366
  }
367
  add_action( 'bp_screens', 'bp_core_screen_activation' );
402
  if ( ! bp_current_action() && ! bp_current_item() ) {
403
  bp_update_is_directory( true, 'members' );
404
 
405
+ /**
406
+ * Fires if looking at Members directory when needing theme compat.
407
+ *
408
+ * @since BuddyPress (1.5.0)
409
+ */
410
  do_action( 'bp_members_screen_index' );
411
 
412
  add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) );
420
  if ( bp_is_active( 'activity' ) && bp_is_single_activity() )
421
  return;
422
 
423
+ /**
424
+ * Fires if looking at Members user page when needing theme compat.
425
+ *
426
+ * @since BuddyPress (1.5.0)
427
+ */
428
  do_action( 'bp_members_screen_display_profile' );
429
 
430
  add_filter( 'bp_get_buddypress_template', array( $this, 'single_template_hierarchy' ) );
444
  *
445
  * @since BuddyPress (1.8.0)
446
  *
447
+ * @param array $templates The templates from bp_get_theme_compat_templates().
448
+ *
449
  * @return array $templates Array of custom templates to look for.
450
  */
451
  public function directory_template_hierarchy( $templates = array() ) {
452
 
453
+ /**
454
+ * Filters the template hierarchy for theme compat and members directory page.
455
+ *
456
+ * @since BuddyPress (1.8.0)
457
+ *
458
+ * @param array $value Array of template paths to add to hierarchy.
459
+ */
460
  $new_templates = apply_filters( 'bp_template_hierarchy_members_directory', array(
461
  'members/index-directory.php'
462
  ) );
514
  // Setup some variables we're going to reference in our custom templates
515
  $user_nicename = buddypress()->displayed_user->userdata->user_nicename;
516
 
517
+ /**
518
+ * Filters the template hierarchy for theme compat and member pages.
519
+ *
520
+ * @since BuddyPress (1.8.0)
521
+ *
522
+ * @param array $value Array of template paths to add to hierarchy.
523
+ */
524
  $new_templates = apply_filters( 'bp_template_hierarchy_members_single_item', array(
525
  'members/single/index-id-' . sanitize_file_name( bp_displayed_user_id() ) . '.php',
526
  'members/single/index-nicename-' . sanitize_file_name( $user_nicename ) . '.php',
544
  public function single_dummy_post() {
545
  bp_theme_compat_reset_post( array(
546
  'ID' => 0,
547
+ 'post_title' => bp_get_displayed_user_fullname(),
548
  'post_author' => 0,
549
  'post_date' => 0,
550
  'post_content' => '',
569
  /**
570
  * The main theme compat class for BuddyPress Registration.
571
  *
572
+ * This class sets up the necessary theme compatibility actions to safely output
573
  * registration template parts to the_title and the_content areas of a theme.
574
  *
575
  * @since BuddyPress (1.7.0)
622
  public function template_hierarchy( $templates ) {
623
  $component = sanitize_file_name( bp_current_component() );
624
 
625
+ /**
626
+ * Filters the template hierarchy for theme compat and registration/activation pages.
627
+ *
628
+ * This filter is a variable filter that depends on the current component
629
+ * being used.
630
+ *
631
+ * @since BuddyPress (1.8.0)
632
+ *
633
+ * @param array $value Array of template paths to add to hierarchy.
634
+ */
635
  $new_templates = apply_filters( "bp_template_hierarchy_{$component}", array(
636
  "members/index-{$component}.php"
637
  ) );
bp-members/bp-members-template.php CHANGED
@@ -30,6 +30,14 @@ function bp_members_slug() {
30
  * @return string
31
  */
32
  function bp_get_members_slug() {
 
 
 
 
 
 
 
 
33
  return apply_filters( 'bp_get_members_slug', buddypress()->members->slug );
34
  }
35
 
@@ -51,6 +59,14 @@ function bp_members_root_slug() {
51
  * @return string
52
  */
53
  function bp_get_members_root_slug() {
 
 
 
 
 
 
 
 
54
  return apply_filters( 'bp_get_members_root_slug', buddypress()->members->root_slug );
55
  }
56
 
@@ -72,6 +88,14 @@ function bp_members_directory_permalink() {
72
  * @return string
73
  */
74
  function bp_get_members_directory_permalink() {
 
 
 
 
 
 
 
 
75
  return apply_filters( 'bp_get_members_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
76
  }
77
 
@@ -103,6 +127,13 @@ function bp_signup_slug() {
103
  $slug = 'register';
104
  }
105
 
 
 
 
 
 
 
 
106
  return apply_filters( 'bp_get_signup_slug', $slug );
107
  }
108
 
@@ -134,6 +165,13 @@ function bp_activate_slug() {
134
  $slug = 'activate';
135
  }
136
 
 
 
 
 
 
 
 
137
  return apply_filters( 'bp_get_activate_slug', $slug );
138
  }
139
 
@@ -221,21 +259,22 @@ class BP_Core_Members_Template {
221
  *
222
  * @see BP_User_Query for an in-depth description of parameters.
223
  *
224
- * @param string $type Sort order.
225
- * @param int $page_number Page of results.
226
- * @param int $per_page Number of results per page.
227
- * @param int $max Max number of results to return.
228
- * @param int $user_id Limit to friends of a user.
229
- * @param string $search_terms Limit to users matching search terms.
230
- * @param array $include Limit results by these user IDs.
231
- * @param bool $populate_extras Fetch optional extras.
232
- * @param array $exclude Exclude these IDs from results.
233
- * @param array $meta_key Limit to users with a meta_key.
234
- * @param array $meta_value Limit to users with a meta_value (with meta_key).
235
- * @param array $page_arg Optional. The string used as a query
236
- * parameter in pagination links. Default: 'upage'.
237
- */
238
- function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage' ) {
 
239
 
240
  $this->pag_page = !empty( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : (int) $page_number;
241
  $this->pag_num = !empty( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : (int) $per_page;
@@ -244,7 +283,7 @@ class BP_Core_Members_Template {
244
  if ( !empty( $_REQUEST['letter'] ) )
245
  $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude );
246
  else
247
- $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude, 'meta_key' => $meta_key, 'meta_value' => $meta_value ) );
248
 
249
  if ( !$max || $max >= (int) $this->members['total'] )
250
  $this->total_member_count = (int) $this->members['total'];
@@ -274,8 +313,15 @@ class BP_Core_Members_Template {
274
  $base = '';
275
  }
276
 
 
 
 
 
 
 
 
277
  if ( ! empty( $search_terms ) ) {
278
- $pag_args['s'] = urlencode( $search_terms );
279
  }
280
 
281
  $this->pag_links = paginate_links( array(
@@ -285,7 +331,8 @@ class BP_Core_Members_Template {
285
  'current' => (int) $this->pag_page,
286
  'prev_text' => _x( '&larr;', 'Member pagination previous text', 'buddypress' ),
287
  'next_text' => _x( '&rarr;', 'Member pagination next text', 'buddypress' ),
288
- 'mid_size' => 1
 
289
  ) );
290
  }
291
  }
@@ -341,6 +388,12 @@ class BP_Core_Members_Template {
341
  if ( $this->current_member + 1 < $this->member_count ) {
342
  return true;
343
  } elseif ( $this->current_member + 1 == $this->member_count ) {
 
 
 
 
 
 
344
  do_action('member_loop_end');
345
  // Do some cleaning up after the loop
346
  $this->rewind_members();
@@ -365,8 +418,16 @@ class BP_Core_Members_Template {
365
  $this->member = $this->next_member();
366
 
367
  // loop has just started
368
- if ( 0 == $this->current_member )
 
 
 
 
 
 
369
  do_action( 'member_loop_start' );
 
 
370
  }
371
  }
372
 
@@ -398,30 +459,30 @@ function bp_rewind_members() {
398
  * Arguments can be passed as an associative array, or as a URL query
399
  * string (eg, 'user_id=4&per_page=3').
400
  *
401
- * @type int $type Sort order. 'active', 'random', 'newest', 'popular',
402
- * 'online', 'alphabetical'. Default: 'active'.
403
- * @type int|bool $page Page of results to display. Default: 1.
404
- * @type int|bool $per_page Number of results per page. Default: 20.
405
- * @type int|bool $max Maximum number of results to return.
406
- * Default: false (unlimited).
407
- * @type string $page_arg The string used as a query parameter in
408
- * pagination links. Default: 'bpage'.
409
- * @type array|int|string|bool $include Limit results by a list of user
410
- * IDs. Accepts an array, a single integer, a comma-separated list of
411
- * IDs, or false (to disable this limiting). Default: false.
412
- * 'active', 'alphabetical', 'newest', or 'random'.
413
- * @type array|int|string|bool $exclude Exclude users from results by ID.
414
- * Accepts an array, a single integer, a comma-separated list of
415
- * IDs, or false (to disable this limiting). Default: false.
416
- * @type int $user_id If provided, results are limited to the friends of
417
- * the specified user. When on a user's Friends page, defaults to
418
- * the ID of the displayed user. Otherwise defaults to 0.
419
- * @type string $search_terms Limit results by a search term. Default: null.
420
- * @type string $meta_key Limit results by the presence of a usermeta key.
421
  * Default: false.
422
- * @type mixed $meta_value When used with meta_key, limits results by the
423
  * a matching usermeta value. Default: false.
424
- * @type bool $populate_extras Whether to fetch optional data, such as
425
  * friend counts. Default: true.
426
  * }
427
  * @return bool Returns true when blogs are found, otherwise false.
@@ -450,6 +511,7 @@ function bp_has_members( $args = '' ) {
450
  'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users
451
 
452
  'user_id' => $user_id, // Pass a user_id to only show friends of this user
 
453
  'search_terms' => null, // Pass search_terms to filter users by their profile data
454
 
455
  'meta_key' => false, // Only return users with this usermeta
@@ -485,9 +547,18 @@ function bp_has_members( $args = '' ) {
485
  $r['exclude'],
486
  $r['meta_key'],
487
  $r['meta_value'],
488
- $r['page_arg']
 
489
  );
490
 
 
 
 
 
 
 
 
 
491
  return apply_filters( 'bp_has_members', $members_template->has_members(), $members_template );
492
  }
493
 
@@ -535,13 +606,20 @@ function bp_members_pagination_count() {
535
 
536
  if ( 'active' == $members_template->type )
537
  $pag = sprintf( _n( 'Viewing 1 active member', 'Viewing %1$s - %2$s of %3$s active members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
538
- else if ( 'popular' == $members_template->type )
539
  $pag = sprintf( _n( 'Viewing 1 member with friends', 'Viewing %1$s - %2$s of %3$s members with friends', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
540
- else if ( 'online' == $members_template->type )
541
  $pag = sprintf( _n( 'Viewing 1 online member', 'Viewing %1$s - %2$s of %3$s online members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
542
  else
543
  $pag = sprintf( _n( 'Viewing 1 member', 'Viewing %1$s - %2$s of %3$s members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
544
 
 
 
 
 
 
 
 
545
  return apply_filters( 'bp_members_pagination_count', $pag );
546
  }
547
 
@@ -559,6 +637,13 @@ function bp_members_pagination_links() {
559
  function bp_get_members_pagination_links() {
560
  global $members_template;
561
 
 
 
 
 
 
 
 
562
  return apply_filters( 'bp_get_members_pagination_links', $members_template->pag_links );
563
  }
564
 
@@ -578,6 +663,14 @@ function bp_member_user_id() {
578
  function bp_get_member_user_id() {
579
  global $members_template;
580
  $member_id = isset( $members_template->member->id ) ? (int) $members_template->member->id : false;
 
 
 
 
 
 
 
 
581
  return apply_filters( 'bp_get_member_user_id', $member_id );
582
  }
583
 
@@ -615,6 +708,13 @@ function bp_member_class() {
615
  $classes[] = 'is-online';
616
  }
617
 
 
 
 
 
 
 
 
618
  $classes = apply_filters( 'bp_get_member_class', $classes );
619
  $classes = array_merge( $classes, array() );
620
  $retval = 'class="' . join( ' ', $classes ) . '"';
@@ -635,6 +735,14 @@ function bp_member_user_nicename() {
635
  */
636
  function bp_get_member_user_nicename() {
637
  global $members_template;
 
 
 
 
 
 
 
 
638
  return apply_filters( 'bp_get_member_user_nicename', $members_template->member->user_nicename );
639
  }
640
 
@@ -651,6 +759,14 @@ function bp_member_user_login() {
651
  */
652
  function bp_get_member_user_login() {
653
  global $members_template;
 
 
 
 
 
 
 
 
654
  return apply_filters( 'bp_get_member_user_login', $members_template->member->user_login );
655
  }
656
 
@@ -667,6 +783,14 @@ function bp_member_user_email() {
667
  */
668
  function bp_get_member_user_email() {
669
  global $members_template;
 
 
 
 
 
 
 
 
670
  return apply_filters( 'bp_get_member_user_email', $members_template->member->user_email );
671
  }
672
 
@@ -677,6 +801,14 @@ function bp_member_user_email() {
677
  */
678
  function bp_member_is_loggedin_user() {
679
  global $members_template;
 
 
 
 
 
 
 
 
680
  return apply_filters( 'bp_member_is_loggedin_user', bp_loggedin_user_id() == $members_template->member->id ? true : false );
681
  }
682
 
@@ -688,6 +820,15 @@ function bp_member_is_loggedin_user() {
688
  * @param array $args See {@link bp_get_member_avatar()}.
689
  */
690
  function bp_member_avatar( $args = '' ) {
 
 
 
 
 
 
 
 
 
691
  echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
692
  }
693
  /**
@@ -727,6 +868,14 @@ function bp_member_avatar( $args = '' ) {
727
  $r = wp_parse_args( $args, $defaults );
728
  extract( $r, EXTR_SKIP );
729
 
 
 
 
 
 
 
 
 
730
  return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
731
  }
732
 
@@ -744,6 +893,13 @@ function bp_member_permalink() {
744
  function bp_get_member_permalink() {
745
  global $members_template;
746
 
 
 
 
 
 
 
 
747
  return apply_filters( 'bp_get_member_permalink', bp_core_get_user_domain( $members_template->member->id, $members_template->member->user_nicename, $members_template->member->user_login ) );
748
  }
749
 
@@ -761,6 +917,14 @@ function bp_member_permalink() {
761
  * Output display name of current member in the loop.
762
  */
763
  function bp_member_name() {
 
 
 
 
 
 
 
 
764
  echo apply_filters( 'bp_member_name', bp_get_member_name() );
765
  }
766
  /**
@@ -795,6 +959,13 @@ function bp_member_name() {
795
  }
796
  }
797
 
 
 
 
 
 
 
 
798
  return apply_filters( 'bp_get_member_name', $members_template->member->fullname );
799
  }
800
  add_filter( 'bp_get_member_name', 'wp_filter_kses' );
@@ -829,7 +1000,7 @@ function bp_member_last_active( $args = array() ) {
829
  'active_format' => true
830
  ) );
831
 
832
- // Backwards compatibilty for anyone forcing a 'true' active_format
833
  if ( true === $r['active_format'] ) {
834
  $r['active_format'] = __( 'active %s', 'buddypress' );
835
  }
@@ -847,7 +1018,14 @@ function bp_member_last_active( $args = array() ) {
847
  $last_activity = __( 'Never active', 'buddypress' );
848
  }
849
 
850
- // Filter and return
 
 
 
 
 
 
 
851
  return apply_filters( 'bp_member_last_active', $last_activity, $r );
852
  }
853
 
@@ -882,6 +1060,13 @@ function bp_member_latest_update( $args = '' ) {
882
  if ( !bp_is_active( 'activity' ) || empty( $members_template->member->latest_update ) || !$update = maybe_unserialize( $members_template->member->latest_update ) )
883
  return false;
884
 
 
 
 
 
 
 
 
885
  $update_content = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], $length ) ) ) );
886
 
887
  $update_content = sprintf( _x( '- &quot;%s&quot;', 'member latest update in member directory', 'buddypress' ), $update_content );
@@ -894,6 +1079,13 @@ function bp_member_latest_update( $args = '' ) {
894
  $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_permalink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>';
895
  }
896
 
 
 
 
 
 
 
 
897
  return apply_filters( 'bp_get_member_latest_update', $update_content );
898
  }
899
 
@@ -915,7 +1107,7 @@ function bp_member_profile_data( $args = '' ) {
915
  * to use outside of the loop.
916
  *
917
  * @param array $args {
918
- * Array of config paramaters.
919
  * @type string $field Name of the profile field.
920
  * @type int $user_id ID of the user whose data is being fetched.
921
  * Defaults to the current member in the loop, or if not
@@ -969,6 +1161,13 @@ function bp_member_profile_data( $args = '' ) {
969
  $data = xprofile_format_profile_field( $profile_data[ $r['field'] ]['field_type'], $profile_data[ $r['field'] ]['field_data'] );
970
  }
971
 
 
 
 
 
 
 
 
972
  return apply_filters( 'bp_get_member_profile_data', $data );
973
  }
974
 
@@ -986,8 +1185,15 @@ function bp_member_registered() {
986
  function bp_get_member_registered() {
987
  global $members_template;
988
 
989
- $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, _x( 'registered %s', 'Records the timestamp that the user registered into the activy stream', 'buddypress' ) ) );
990
 
 
 
 
 
 
 
 
991
  return apply_filters( 'bp_member_registered', $registered );
992
  }
993
 
@@ -1031,6 +1237,13 @@ function bp_directory_members_search_form() {
1031
  <input type="submit" id="members_search_submit" name="members_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
1032
  </form>';
1033
 
 
 
 
 
 
 
 
1034
  echo apply_filters( 'bp_directory_members_search_form', $search_form_html );
1035
  }
1036
 
@@ -1046,6 +1259,14 @@ function bp_total_site_member_count() {
1046
  * @return int
1047
  */
1048
  function bp_get_total_site_member_count() {
 
 
 
 
 
 
 
 
1049
  return apply_filters( 'bp_get_total_site_member_count', bp_core_number_format( bp_core_get_total_member_count() ) );
1050
  }
1051
 
@@ -1126,6 +1347,17 @@ function bp_get_displayed_user_nav() {
1126
  $link = trailingslashit( bp_displayed_user_domain() . $user_nav_item['link'] );
1127
  }
1128
 
 
 
 
 
 
 
 
 
 
 
 
1129
  echo apply_filters_ref_array( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], array( '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ) );
1130
  }
1131
  }
@@ -1171,6 +1403,13 @@ function bp_loggedin_user_avatar( $args = '' ) {
1171
  $r = wp_parse_args( $args, $defaults );
1172
  extract( $r, EXTR_SKIP );
1173
 
 
 
 
 
 
 
 
1174
  return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => bp_loggedin_user_id(), 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
1175
  }
1176
 
@@ -1213,6 +1452,13 @@ function bp_displayed_user_avatar( $args = '' ) {
1213
  $r = wp_parse_args( $args, $defaults );
1214
  extract( $r, EXTR_SKIP );
1215
 
 
 
 
 
 
 
 
1216
  return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => bp_displayed_user_id(), 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
1217
  }
1218
 
@@ -1236,6 +1482,13 @@ function bp_displayed_user_email() {
1236
  else
1237
  $retval = '';
1238
 
 
 
 
 
 
 
 
1239
  return apply_filters( 'bp_get_displayed_user_email', esc_attr( $retval ) );
1240
  }
1241
 
@@ -1247,6 +1500,14 @@ function bp_displayed_user_email() {
1247
  * @param int $user_id See {@link bp_get_last_activity()}.
1248
  */
1249
  function bp_last_activity( $user_id = 0 ) {
 
 
 
 
 
 
 
 
1250
  echo apply_filters( 'bp_last_activity', bp_get_last_activity( $user_id ) );
1251
  }
1252
  /**
@@ -1262,6 +1523,13 @@ function bp_last_activity( $user_id = 0 ) {
1262
 
1263
  $last_activity = bp_core_get_last_activity( bp_get_user_last_activity( $user_id ), __('active %s', 'buddypress') );
1264
 
 
 
 
 
 
 
 
1265
  return apply_filters( 'bp_get_last_activity', $last_activity );
1266
  }
1267
 
@@ -1293,6 +1561,14 @@ function bp_user_firstname() {
1293
 
1294
  $fullname = (array) explode( ' ', $name );
1295
 
 
 
 
 
 
 
 
 
1296
  return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
1297
  }
1298
 
@@ -1308,6 +1584,14 @@ function bp_loggedin_user_link() {
1308
  * @return string
1309
  */
1310
  function bp_get_loggedin_user_link() {
 
 
 
 
 
 
 
 
1311
  return apply_filters( 'bp_get_loggedin_user_link', bp_loggedin_user_domain() );
1312
  }
1313
 
@@ -1323,6 +1607,14 @@ function bp_displayed_user_link() {
1323
  * @return string
1324
  */
1325
  function bp_get_displayed_user_link() {
 
 
 
 
 
 
 
 
1326
  return apply_filters( 'bp_get_displayed_user_link', bp_displayed_user_domain() );
1327
  }
1328
 
@@ -1345,6 +1637,14 @@ function bp_current_user_id() { return bp_displayed_user_id(); }
1345
  */
1346
  function bp_displayed_user_domain() {
1347
  global $bp;
 
 
 
 
 
 
 
 
1348
  return apply_filters( 'bp_displayed_user_domain', isset( $bp->displayed_user->domain ) ? $bp->displayed_user->domain : '' );
1349
  }
1350
 
@@ -1355,6 +1655,14 @@ function bp_displayed_user_domain() {
1355
  */
1356
  function bp_loggedin_user_domain() {
1357
  global $bp;
 
 
 
 
 
 
 
 
1358
  return apply_filters( 'bp_loggedin_user_domain', isset( $bp->loggedin_user->domain ) ? $bp->loggedin_user->domain : '' );
1359
  }
1360
 
@@ -1371,6 +1679,14 @@ function bp_displayed_user_fullname() {
1371
  */
1372
  function bp_get_displayed_user_fullname() {
1373
  global $bp;
 
 
 
 
 
 
 
 
1374
  return apply_filters( 'bp_displayed_user_fullname', isset( $bp->displayed_user->fullname ) ? $bp->displayed_user->fullname : '' );
1375
  }
1376
 
@@ -1393,6 +1709,14 @@ function bp_loggedin_user_fullname() {
1393
  */
1394
  function bp_get_loggedin_user_fullname() {
1395
  global $bp;
 
 
 
 
 
 
 
 
1396
  return apply_filters( 'bp_get_loggedin_user_fullname', isset( $bp->loggedin_user->fullname ) ? $bp->loggedin_user->fullname : '' );
1397
  }
1398
 
@@ -1416,6 +1740,13 @@ function bp_displayed_user_username() {
1416
  $username = '';
1417
  }
1418
 
 
 
 
 
 
 
 
1419
  return apply_filters( 'bp_get_displayed_user_username', $username );
1420
  }
1421
 
@@ -1439,6 +1770,13 @@ function bp_loggedin_user_username() {
1439
  $username = '';
1440
  }
1441
 
 
 
 
 
 
 
 
1442
  return apply_filters( 'bp_get_loggedin_user_username', $username );
1443
  }
1444
 
@@ -1480,6 +1818,13 @@ function bp_signup_page() {
1480
  $page = bp_get_root_domain() . '/wp-signup.php';
1481
  }
1482
 
 
 
 
 
 
 
 
1483
  return apply_filters( 'bp_get_signup_page', $page );
1484
  }
1485
 
@@ -1502,7 +1847,7 @@ function bp_has_custom_activation_page() {
1502
  }
1503
 
1504
  /**
1505
- * Output the URL of the actvitation page.
1506
  */
1507
  function bp_activation_page() {
1508
  echo bp_get_activation_page();
@@ -1519,6 +1864,13 @@ function bp_activation_page() {
1519
  $page = trailingslashit( bp_get_root_domain() ) . 'wp-activate.php';
1520
  }
1521
 
 
 
 
 
 
 
 
1522
  return apply_filters( 'bp_get_activation_page', $page );
1523
  }
1524
 
@@ -1540,6 +1892,13 @@ function bp_signup_username_value() {
1540
  if ( isset( $_POST['signup_username'] ) )
1541
  $value = $_POST['signup_username'];
1542
 
 
 
 
 
 
 
 
1543
  return apply_filters( 'bp_get_signup_username_value', $value );
1544
  }
1545
 
@@ -1561,6 +1920,13 @@ function bp_signup_email_value() {
1561
  if ( isset( $_POST['signup_email'] ) )
1562
  $value = $_POST['signup_email'];
1563
 
 
 
 
 
 
 
 
1564
  return apply_filters( 'bp_get_signup_email_value', $value );
1565
  }
1566
 
@@ -1580,6 +1946,13 @@ function bp_signup_with_blog_value() {
1580
  if ( isset( $_POST['signup_with_blog'] ) )
1581
  $value = $_POST['signup_with_blog'];
1582
 
 
 
 
 
 
 
 
1583
  return apply_filters( 'bp_get_signup_with_blog_value', $value );
1584
  }
1585
 
@@ -1601,6 +1974,13 @@ function bp_signup_blog_url_value() {
1601
  if ( isset( $_POST['signup_blog_url'] ) )
1602
  $value = $_POST['signup_blog_url'];
1603
 
 
 
 
 
 
 
 
1604
  return apply_filters( 'bp_get_signup_blog_url_value', $value );
1605
  }
1606
 
@@ -1627,6 +2007,14 @@ function bp_signup_subdomain_base() {
1627
  // In case plugins are still using this filter
1628
  $subdomain_base = apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
1629
 
 
 
 
 
 
 
 
 
1630
  return apply_filters( 'bp_signup_subdomain_base', $subdomain_base );
1631
  }
1632
 
@@ -1648,6 +2036,13 @@ function bp_signup_blog_title_value() {
1648
  if ( isset( $_POST['signup_blog_title'] ) )
1649
  $value = $_POST['signup_blog_title'];
1650
 
 
 
 
 
 
 
 
1651
  return apply_filters( 'bp_get_signup_blog_title_value', $value );
1652
  }
1653
 
@@ -1669,6 +2064,13 @@ function bp_signup_blog_privacy_value() {
1669
  if ( isset( $_POST['signup_blog_privacy'] ) )
1670
  $value = $_POST['signup_blog_privacy'];
1671
 
 
 
 
 
 
 
 
1672
  return apply_filters( 'bp_get_signup_blog_privacy_value', $value );
1673
  }
1674
 
@@ -1698,7 +2100,14 @@ function bp_signup_avatar_dir_value() {
1698
  else
1699
  $signup_avatar_dir = false;
1700
 
1701
- return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
 
 
 
 
 
 
 
1702
  }
1703
 
1704
  /**
@@ -1773,17 +2182,31 @@ function bp_signup_avatar( $args = '' ) {
1773
  // Set default gravatar type
1774
  if ( empty( $bp->grav_default->user ) )
1775
  $default_grav = 'wavatar';
1776
- else if ( 'mystery' == $bp->grav_default->user )
1777
  $default_grav = $bp->plugin_url . 'bp-core/images/mystery-man.jpg';
1778
  else
1779
  $default_grav = $bp->grav_default->user;
1780
 
1781
- // Create
 
 
 
 
 
 
1782
  $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
1783
  $md5_lcase_email = md5( strtolower( bp_get_signup_email_value() ) );
1784
  $gravatar_img = '<img src="' . $gravatar_url . $md5_lcase_email . '?d=' . $default_grav . '&amp;s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
1785
  }
1786
 
 
 
 
 
 
 
 
 
1787
  return apply_filters( 'bp_get_signup_avatar', $gravatar_img, $args );
1788
  }
1789
 
@@ -1801,11 +2224,15 @@ function bp_signup_allowed() {
1801
  * @return bool
1802
  */
1803
  function bp_get_signup_allowed() {
1804
- global $bp;
1805
 
1806
  $signup_allowed = false;
1807
 
1808
  if ( is_multisite() ) {
 
 
 
 
1809
  if ( in_array( $bp->site_options['registration'], array( 'all', 'user' ) ) ) {
1810
  $signup_allowed = true;
1811
  }
@@ -1816,6 +2243,13 @@ function bp_signup_allowed() {
1816
  }
1817
  }
1818
 
 
 
 
 
 
 
 
1819
  return apply_filters( 'bp_get_signup_allowed', $signup_allowed );
1820
  }
1821
 
30
  * @return string
31
  */
32
  function bp_get_members_slug() {
33
+
34
+ /**
35
+ * Filters the Members component slug.
36
+ *
37
+ * @since BuddyPress (1.5.0)
38
+ *
39
+ * @param string $slug Members component slug.
40
+ */
41
  return apply_filters( 'bp_get_members_slug', buddypress()->members->slug );
42
  }
43
 
59
  * @return string
60
  */
61
  function bp_get_members_root_slug() {
62
+
63
+ /**
64
+ * Filters the Members component root slug.
65
+ *
66
+ * @since BuddyPress (1.5.0)
67
+ *
68
+ * @param string $slug Members component root slug.
69
+ */
70
  return apply_filters( 'bp_get_members_root_slug', buddypress()->members->root_slug );
71
  }
72
 
88
  * @return string
89
  */
90
  function bp_get_members_directory_permalink() {
91
+
92
+ /**
93
+ * Filters the member directory permalink.
94
+ *
95
+ * @since BuddyPress (1.5.0)
96
+ *
97
+ * @param string $value Members directory permalink.
98
+ */
99
  return apply_filters( 'bp_get_members_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
100
  }
101
 
127
  $slug = 'register';
128
  }
129
 
130
+ /**
131
+ * Filters the sign-up slug.
132
+ *
133
+ * @since BuddyPress (1.5.0)
134
+ *
135
+ * @param string $slug Sign-up slug.
136
+ */
137
  return apply_filters( 'bp_get_signup_slug', $slug );
138
  }
139
 
165
  $slug = 'activate';
166
  }
167
 
168
+ /**
169
+ * Filters the activation slug.
170
+ *
171
+ * @since BuddyPress (1.5.0)
172
+ *
173
+ * @param string $slug Activation slug.
174
+ */
175
  return apply_filters( 'bp_get_activate_slug', $slug );
176
  }
177
 
259
  *
260
  * @see BP_User_Query for an in-depth description of parameters.
261
  *
262
+ * @param string $type Sort order.
263
+ * @param int $page_number Page of results.
264
+ * @param int $per_page Number of results per page.
265
+ * @param int $max Max number of results to return.
266
+ * @param int $user_id Limit to friends of a user.
267
+ * @param string $search_terms Limit to users matching search terms.
268
+ * @param array $include Limit results by these user IDs.
269
+ * @param bool $populate_extras Fetch optional extras.
270
+ * @param array $exclude Exclude these IDs from results.
271
+ * @param array $meta_key Limit to users with a meta_key.
272
+ * @param array $meta_value Limit to users with a meta_value (with meta_key).
273
+ * @param array $page_arg Optional. The string used as a query parameter in pagination links.
274
+ * Default: 'upage'.
275
+ * @param array|string $member_type Array or comma-separated string of member types to limit results to.
276
+ */
277
+ function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage', $member_type = '' ) {
278
 
279
  $this->pag_page = !empty( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : (int) $page_number;
280
  $this->pag_num = !empty( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : (int) $per_page;
283
  if ( !empty( $_REQUEST['letter'] ) )
284
  $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude );
285
  else
286
+ $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude, 'meta_key' => $meta_key, 'meta_value' => $meta_value, 'member_type' => $member_type ) );
287
 
288
  if ( !$max || $max >= (int) $this->members['total'] )
289
  $this->total_member_count = (int) $this->members['total'];
313
  $base = '';
314
  }
315
 
316
+ /**
317
+ * Defaults to an empty array to make sure paginate_links()
318
+ * won't add the $page_arg to the links which would break
319
+ * pagination in case javascript is disabled.
320
+ */
321
+ $add_args = array();
322
+
323
  if ( ! empty( $search_terms ) ) {
324
+ $add_args['s'] = urlencode( $search_terms );
325
  }
326
 
327
  $this->pag_links = paginate_links( array(
331
  'current' => (int) $this->pag_page,
332
  'prev_text' => _x( '&larr;', 'Member pagination previous text', 'buddypress' ),
333
  'next_text' => _x( '&rarr;', 'Member pagination next text', 'buddypress' ),
334
+ 'mid_size' => 1,
335
+ 'add_args' => $add_args,
336
  ) );
337
  }
338
  }
388
  if ( $this->current_member + 1 < $this->member_count ) {
389
  return true;
390
  } elseif ( $this->current_member + 1 == $this->member_count ) {
391
+
392
+ /**
393
+ * Fires right before the rewinding of members listing.
394
+ *
395
+ * @since BuddyPress (1.5.0)
396
+ */
397
  do_action('member_loop_end');
398
  // Do some cleaning up after the loop
399
  $this->rewind_members();
418
  $this->member = $this->next_member();
419
 
420
  // loop has just started
421
+ if ( 0 == $this->current_member ) {
422
+
423
+ /**
424
+ * Fires if the current member is the first in the loop.
425
+ *
426
+ * @since BuddyPress (1.5.0)
427
+ */
428
  do_action( 'member_loop_start' );
429
+ }
430
+
431
  }
432
  }
433
 
459
  * Arguments can be passed as an associative array, or as a URL query
460
  * string (eg, 'user_id=4&per_page=3').
461
  *
462
+ * @type int $type Sort order. Accepts 'active', 'random', 'newest', 'popular',
463
+ * 'online', 'alphabetical'. Default: 'active'.
464
+ * @type int|bool $page Page of results to display. Default: 1.
465
+ * @type int|bool $per_page Number of results per page. Default: 20.
466
+ * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
467
+ * @type string $page_arg The string used as a query parameter in pagination links.
468
+ * Default: 'bpage'.
469
+ * @type array|int|string|bool $include Limit results by a list of user IDs. Accepts an array, a
470
+ * single integer, a comma-separated list of IDs, or false (to
471
+ * disable this limiting). Accepts 'active', 'alphabetical',
472
+ * 'newest', or 'random'. Default: false.
473
+ * @type array|int|string|bool $exclude Exclude users from results by ID. Accepts an array, a single
474
+ * integer, a comma-separated list of IDs, or false (to disable
475
+ * this limiting). Default: false.
476
+ * @type int $user_id If provided, results are limited to the friends of the specified
477
+ * user. When on a user's Friends page, defaults to the ID of the
478
+ * displayed user. Otherwise defaults to 0.
479
+ * @type string|array $member_type Array or comma-separated list of member types to limit results to.
480
+ * @type string $search_terms Limit results by a search term. Default: null.
481
+ * @type string $meta_key Limit results by the presence of a usermeta key.
482
  * Default: false.
483
+ * @type mixed $meta_value When used with meta_key, limits results by the
484
  * a matching usermeta value. Default: false.
485
+ * @type bool $populate_extras Whether to fetch optional data, such as
486
  * friend counts. Default: true.
487
  * }
488
  * @return bool Returns true when blogs are found, otherwise false.
511
  'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users
512
 
513
  'user_id' => $user_id, // Pass a user_id to only show friends of this user
514
+ 'member_type' => '',
515
  'search_terms' => null, // Pass search_terms to filter users by their profile data
516
 
517
  'meta_key' => false, // Only return users with this usermeta
547
  $r['exclude'],
548
  $r['meta_key'],
549
  $r['meta_value'],
550
+ $r['page_arg'],
551
+ $r['member_type']
552
  );
553
 
554
+ /**
555
+ * Filters whether or not BuddyPress has members to iterate over.
556
+ *
557
+ * @since BuddyPress (1.2.4)
558
+ *
559
+ * @param bool $value Whether or not there are members to iterate over.
560
+ * @param array $members_template Populated $members_template global.
561
+ */
562
  return apply_filters( 'bp_has_members', $members_template->has_members(), $members_template );
563
  }
564
 
606
 
607
  if ( 'active' == $members_template->type )
608
  $pag = sprintf( _n( 'Viewing 1 active member', 'Viewing %1$s - %2$s of %3$s active members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
609
+ elseif ( 'popular' == $members_template->type )
610
  $pag = sprintf( _n( 'Viewing 1 member with friends', 'Viewing %1$s - %2$s of %3$s members with friends', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
611
+ elseif ( 'online' == $members_template->type )
612
  $pag = sprintf( _n( 'Viewing 1 online member', 'Viewing %1$s - %2$s of %3$s online members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
613
  else
614
  $pag = sprintf( _n( 'Viewing 1 member', 'Viewing %1$s - %2$s of %3$s members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
615
 
616
+ /**
617
+ * Filters the members pagination count.
618
+ *
619
+ * @since BuddyPress (1.5.0)
620
+ *
621
+ * @param string $pag Pagination count string.
622
+ */
623
  return apply_filters( 'bp_members_pagination_count', $pag );
624
  }
625
 
637
  function bp_get_members_pagination_links() {
638
  global $members_template;
639
 
640
+ /**
641
+ * Filters the members pagination link.
642
+ *
643
+ * @since BuddyPress (1.2.0)
644
+ *
645
+ * @param string $pag_links HTML markup for pagination links.
646
+ */
647
  return apply_filters( 'bp_get_members_pagination_links', $members_template->pag_links );
648
  }
649
 
663
  function bp_get_member_user_id() {
664
  global $members_template;
665
  $member_id = isset( $members_template->member->id ) ? (int) $members_template->member->id : false;
666
+
667
+ /**
668
+ * Filters the ID of the current member in the loop.
669
+ *
670
+ * @since BuddyPress (1.2.0)
671
+ *
672
+ * @param int $member_id ID of the member being iterated over.
673
+ */
674
  return apply_filters( 'bp_get_member_user_id', $member_id );
675
  }
676
 
708
  $classes[] = 'is-online';
709
  }
710
 
711
+ /**
712
+ * Filters the determined classes to add to the HTML element.
713
+ *
714
+ * @since BuddyPress (1.7.0)
715
+ *
716
+ * @param string $classes Classes to be added to the HTML element.
717
+ */
718
  $classes = apply_filters( 'bp_get_member_class', $classes );
719
  $classes = array_merge( $classes, array() );
720
  $retval = 'class="' . join( ' ', $classes ) . '"';
735
  */
736
  function bp_get_member_user_nicename() {
737
  global $members_template;
738
+
739
+ /**
740
+ * Filters the nicename of the current member in the loop.
741
+ *
742
+ * @since BuddyPress (1.2.5)
743
+ *
744
+ * @param string $user_nicename Nicename for the current member.
745
+ */
746
  return apply_filters( 'bp_get_member_user_nicename', $members_template->member->user_nicename );
747
  }
748
 
759
  */
760
  function bp_get_member_user_login() {
761
  global $members_template;
762
+
763
+ /**
764
+ * Filters the login of the current member in the loop.
765
+ *
766
+ * @since BuddyPress (1.2.5)
767
+ *
768
+ * @param string $user_login Login for the current member.
769
+ */
770
  return apply_filters( 'bp_get_member_user_login', $members_template->member->user_login );
771
  }
772
 
783
  */
784
  function bp_get_member_user_email() {
785
  global $members_template;
786
+
787
+ /**
788
+ * Filters the email address of the current member in the loop.
789
+ *
790
+ * @since BuddyPress (1.2.5)
791
+ *
792
+ * @param string $user_email Email address for the current member.
793
+ */
794
  return apply_filters( 'bp_get_member_user_email', $members_template->member->user_email );
795
  }
796
 
801
  */
802
  function bp_member_is_loggedin_user() {
803
  global $members_template;
804
+
805
+ /**
806
+ * Filters whether the current member in the loop is the logged-in user.
807
+ *
808
+ * @since BuddyPress (1.2.5)
809
+ *
810
+ * @param bool $value Whether current member in the loop is logged in.
811
+ */
812
  return apply_filters( 'bp_member_is_loggedin_user', bp_loggedin_user_id() == $members_template->member->id ? true : false );
813
  }
814
 
820
  * @param array $args See {@link bp_get_member_avatar()}.
821
  */
822
  function bp_member_avatar( $args = '' ) {
823
+
824
+ /**
825
+ * Filters a members avatar.
826
+ *
827
+ * @since BuddyPress (1.2.0)
828
+ *
829
+ * @param string $value Formatted HTML <img> element,
830
+ * or raw avatar URL based on $html arg
831
+ */
832
  echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
833
  }
834
  /**
868
  $r = wp_parse_args( $args, $defaults );
869
  extract( $r, EXTR_SKIP );
870
 
871
+ /**
872
+ * Filters a members avatar.
873
+ *
874
+ * @since BuddyPress (1.2.0)
875
+ *
876
+ * @param string $value Formatted HTML <img> element,
877
+ * or raw avatar URL based on $html arg
878
+ */
879
  return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
880
  }
881
 
893
  function bp_get_member_permalink() {
894
  global $members_template;
895
 
896
+ /**
897
+ * Filters the permalink for the current member in the loop.
898
+ *
899
+ * @since BuddyPress (1.2.0)
900
+ *
901
+ * @param string $value Permalink for the current member in the loop.
902
+ */
903
  return apply_filters( 'bp_get_member_permalink', bp_core_get_user_domain( $members_template->member->id, $members_template->member->user_nicename, $members_template->member->user_login ) );
904
  }
905
 
917
  * Output display name of current member in the loop.
918
  */
919
  function bp_member_name() {
920
+
921
+ /**
922
+ * Filters the display name of current member in the loop.
923
+ *
924
+ * @since BuddyPress (1.2.0)
925
+ *
926
+ * @param string $value Display name for current member.
927
+ */
928
  echo apply_filters( 'bp_member_name', bp_get_member_name() );
929
  }
930
  /**
959
  }
960
  }
961
 
962
+ /**
963
+ * Filters the display name of current member in the loop.
964
+ *
965
+ * @since BuddyPress (1.2.0)
966
+ *
967
+ * @param string $fullname Display name for current member.
968
+ */
969
  return apply_filters( 'bp_get_member_name', $members_template->member->fullname );
970
  }
971
  add_filter( 'bp_get_member_name', 'wp_filter_kses' );
1000
  'active_format' => true
1001
  ) );
1002
 
1003
+ // Backwards compatibility for anyone forcing a 'true' active_format
1004
  if ( true === $r['active_format'] ) {
1005
  $r['active_format'] = __( 'active %s', 'buddypress' );
1006
  }
1018
  $last_activity = __( 'Never active', 'buddypress' );
1019
  }
1020
 
1021
+ /**
1022
+ * Filters the current members last active time.
1023
+ *
1024
+ * @since BuddyPress (1.2.0)
1025
+ *
1026
+ * @param string $last_activity Formatted time since last activity.
1027
+ * @param array $r Array of parsed arguments for query.
1028
+ */
1029
  return apply_filters( 'bp_member_last_active', $last_activity, $r );
1030
  }
1031
 
1060
  if ( !bp_is_active( 'activity' ) || empty( $members_template->member->latest_update ) || !$update = maybe_unserialize( $members_template->member->latest_update ) )
1061
  return false;
1062
 
1063
+ /**
1064
+ * Filters the excerpt of the latest update for current member in the loop.
1065
+ *
1066
+ * @since BuddyPress (1.2.5)
1067
+ *
1068
+ * @param string $value Excerpt of the latest update for current member in the loop.
1069
+ */
1070
  $update_content = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], $length ) ) ) );
1071
 
1072
  $update_content = sprintf( _x( '- &quot;%s&quot;', 'member latest update in member directory', 'buddypress' ), $update_content );
1079
  $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_permalink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>';
1080
  }
1081
 
1082
+ /**
1083
+ * Filters the latest update from the current member in the loop.
1084
+ *
1085
+ * @since BuddyPress (1.2.0)
1086
+ *
1087
+ * @param string $update_content Formatted latest update for current member.
1088
+ */
1089
  return apply_filters( 'bp_get_member_latest_update', $update_content );
1090
  }
1091
 
1107
  * to use outside of the loop.
1108
  *
1109
  * @param array $args {
1110
+ * Array of config parameters.
1111
  * @type string $field Name of the profile field.
1112
  * @type int $user_id ID of the user whose data is being fetched.
1113
  * Defaults to the current member in the loop, or if not
1161
  $data = xprofile_format_profile_field( $profile_data[ $r['field'] ]['field_type'], $profile_data[ $r['field'] ]['field_data'] );
1162
  }
1163
 
1164
+ /**
1165
+ * Filters resulting piece of member profile data.
1166
+ *
1167
+ * @since BuddyPress (1.2.0)
1168
+ *
1169
+ * @param string|bool $data Profile data if found, otherwise false.
1170
+ */
1171
  return apply_filters( 'bp_get_member_profile_data', $data );
1172
  }
1173
 
1185
  function bp_get_member_registered() {
1186
  global $members_template;
1187
 
1188
+ $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, _x( 'registered %s', 'Records the timestamp that the user registered into the activity stream', 'buddypress' ) ) );
1189
 
1190
+ /**
1191
+ * Filters the 'registered [x days ago]' string for the current member.
1192
+ *
1193
+ * @since BuddyPress (2.1.0)
1194
+ *
1195
+ * @param string $registered The 'registered [x days ago]' string.
1196
+ */
1197
  return apply_filters( 'bp_member_registered', $registered );
1198
  }
1199
 
1237
  <input type="submit" id="members_search_submit" name="members_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
1238
  </form>';
1239
 
1240
+ /**
1241
+ * Filters the Members component search form.
1242
+ *
1243
+ * @since BuddyPress (1.9.0)
1244
+ *
1245
+ * @param string $search_form_html HTML markup for the member search form.
1246
+ */
1247
  echo apply_filters( 'bp_directory_members_search_form', $search_form_html );
1248
  }
1249
 
1259
  * @return int
1260
  */
1261
  function bp_get_total_site_member_count() {
1262
+
1263
+ /**
1264
+ * Filters the total site member count.
1265
+ *
1266
+ * @since BuddyPress (1.2.0)
1267
+ *
1268
+ * @param int $value Number-formatted total site member count.
1269
+ */
1270
  return apply_filters( 'bp_get_total_site_member_count', bp_core_number_format( bp_core_get_total_member_count() ) );
1271
  }
1272
 
1347
  $link = trailingslashit( bp_displayed_user_domain() . $user_nav_item['link'] );
1348
  }
1349
 
1350
+ /**
1351
+ * Filters the navigation markup for the displayed user.
1352
+ *
1353
+ * This is a dynamic filter that is dependent on the navigation tab component being rendered.
1354
+ *
1355
+ * @since BuddyPress (1.1.0)
1356
+ *
1357
+ * @param string $value Markup for the tab list item including link.
1358
+ * @param array $user_nav_item Array holding parts used to construct tab list item.
1359
+ * Passed by reference.
1360
+ */
1361
  echo apply_filters_ref_array( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], array( '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ) );
1362
  }
1363
  }
1403
  $r = wp_parse_args( $args, $defaults );
1404
  extract( $r, EXTR_SKIP );
1405
 
1406
+ /**
1407
+ * Filters the logged in user's avatar.
1408
+ *
1409
+ * @since BuddyPress (1.1.0)
1410
+ *
1411
+ * @param string $value User avatar string.
1412
+ */
1413
  return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => bp_loggedin_user_id(), 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
1414
  }
1415
 
1452
  $r = wp_parse_args( $args, $defaults );
1453
  extract( $r, EXTR_SKIP );
1454
 
1455
+ /**
1456
+ * Filters the displayed user's avatar.
1457
+ *
1458
+ * @since BuddyPress (1.1.0)
1459
+ *
1460
+ * @param string $value User avatar string.
1461
+ */
1462
  return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => bp_displayed_user_id(), 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
1463
  }
1464
 
1482
  else
1483
  $retval = '';
1484
 
1485
+ /**
1486
+ * Filters the email address of the displayed user.
1487
+ *
1488
+ * @since BuddyPress (1.5.0)
1489
+ *
1490
+ * @param string $retval Email address for displayed user.
1491
+ */
1492
  return apply_filters( 'bp_get_displayed_user_email', esc_attr( $retval ) );
1493
  }
1494
 
1500
  * @param int $user_id See {@link bp_get_last_activity()}.
1501
  */
1502
  function bp_last_activity( $user_id = 0 ) {
1503
+
1504
+ /**
1505
+ * Filters the 'active [x days ago]' string for a user.
1506
+ *
1507
+ * @since BuddyPress (1.0.0)
1508
+ *
1509
+ * @param string $value Formatted 'active [x days ago]' string.
1510
+ */
1511
  echo apply_filters( 'bp_last_activity', bp_get_last_activity( $user_id ) );
1512
  }
1513
  /**
1523
 
1524
  $last_activity = bp_core_get_last_activity( bp_get_user_last_activity( $user_id ), __('active %s', 'buddypress') );
1525
 
1526
+ /**
1527
+ * Filters the 'active [x days ago]' string for a user.
1528
+ *
1529
+ * @since BuddyPress (1.5.0)
1530
+ *
1531
+ * @param string $value Formatted 'active [x days ago]' string.
1532
+ */
1533
  return apply_filters( 'bp_get_last_activity', $last_activity );
1534
  }
1535
 
1561
 
1562
  $fullname = (array) explode( ' ', $name );
1563
 
1564
+ /**
1565
+ * Filters the first name of a user.
1566
+ *
1567
+ * @since BuddyPress (1.2.0)
1568
+ *
1569
+ * @param string $value First name of user.
1570
+ * @param string $fullname Full name of user.
1571
+ */
1572
  return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
1573
  }
1574
 
1584
  * @return string
1585
  */
1586
  function bp_get_loggedin_user_link() {
1587
+
1588
+ /**
1589
+ * Filters the link for the logged-in user's profile.
1590
+ *
1591
+ * @since BuddyPress (1.2.4)
1592
+ *
1593
+ * @param string $value Link for the logged-in user's profile.
1594
+ */
1595
  return apply_filters( 'bp_get_loggedin_user_link', bp_loggedin_user_domain() );
1596
  }
1597
 
1607
  * @return string
1608
  */
1609
  function bp_get_displayed_user_link() {
1610
+
1611
+ /**
1612
+ * Filters the link for the displayed user's profile.
1613
+ *
1614
+ * @since BuddyPress (1.2.4)
1615
+ *
1616
+ * @param string $value Link for the displayed user's profile.
1617
+ */
1618
  return apply_filters( 'bp_get_displayed_user_link', bp_displayed_user_domain() );
1619
  }
1620
 
1637
  */
1638
  function bp_displayed_user_domain() {
1639
  global $bp;
1640
+
1641
+ /**
1642
+ * Filters the generated link for the displayed user's profile.
1643
+ *
1644
+ * @since BuddyPress (1.0.0)
1645
+ *
1646
+ * @param string $value Generated link for the displayed user's profile.
1647
+ */
1648
  return apply_filters( 'bp_displayed_user_domain', isset( $bp->displayed_user->domain ) ? $bp->displayed_user->domain : '' );
1649
  }
1650
 
1655
  */
1656
  function bp_loggedin_user_domain() {
1657
  global $bp;
1658
+
1659
+ /**
1660
+ * Filters the generated link for the logged-in user's profile.
1661
+ *
1662
+ * @since BuddyPress (1.0.0)
1663
+ *
1664
+ * @param string $value Generated link for the logged-in user's profile.
1665
+ */
1666
  return apply_filters( 'bp_loggedin_user_domain', isset( $bp->loggedin_user->domain ) ? $bp->loggedin_user->domain : '' );
1667
  }
1668
 
1679
  */
1680
  function bp_get_displayed_user_fullname() {
1681
  global $bp;
1682
+
1683
+ /**
1684
+ * Filters the displayed user's display name.
1685
+ *
1686
+ * @since BuddyPress (1.2.0)
1687
+ *
1688
+ * @param string $value Displayed user's display name.
1689
+ */
1690
  return apply_filters( 'bp_displayed_user_fullname', isset( $bp->displayed_user->fullname ) ? $bp->displayed_user->fullname : '' );
1691
  }
1692
 
1709
  */
1710
  function bp_get_loggedin_user_fullname() {
1711
  global $bp;
1712
+
1713
+ /**
1714
+ * Filters the logged-in user's display name.
1715
+ *
1716
+ * @since BuddyPress (1.0.0)
1717
+ *
1718
+ * @param string $value Logged-in user's display name.
1719
+ */
1720
  return apply_filters( 'bp_get_loggedin_user_fullname', isset( $bp->loggedin_user->fullname ) ? $bp->loggedin_user->fullname : '' );
1721
  }
1722
 
1740
  $username = '';
1741
  }
1742
 
1743
+ /**
1744
+ * Filters the username of the displayed user.
1745
+ *
1746
+ * @since BuddyPress (1.2.0)
1747
+ *
1748
+ * @param string $username Username of the displayed user.
1749
+ */
1750
  return apply_filters( 'bp_get_displayed_user_username', $username );
1751
  }
1752
 
1770
  $username = '';
1771
  }
1772
 
1773
+ /**
1774
+ * Filters the username of the logged-in user.
1775
+ *
1776
+ * @since BuddyPress (1.2.0)
1777
+ *
1778
+ * @param string $username Username of the logged-in user.
1779
+ */
1780
  return apply_filters( 'bp_get_loggedin_user_username', $username );
1781
  }
1782
 
1818
  $page = bp_get_root_domain() . '/wp-signup.php';
1819
  }
1820
 
1821
+ /**
1822
+ * Filters the URL to the signup page.
1823
+ *
1824
+ * @since BuddyPress (1.1.0)
1825
+ *
1826
+ * @param string $page URL to the signup page.
1827
+ */
1828
  return apply_filters( 'bp_get_signup_page', $page );
1829
  }
1830
 
1847
  }
1848
 
1849
  /**
1850
+ * Output the URL of the activation page.
1851
  */
1852
  function bp_activation_page() {
1853
  echo bp_get_activation_page();
1864
  $page = trailingslashit( bp_get_root_domain() ) . 'wp-activate.php';
1865
  }
1866
 
1867
+ /**
1868
+ * Filters the URL of the activation page.
1869
+ *
1870
+ * @since BuddyPress (1.2.0)
1871
+ *
1872
+ * @param string $page URL to the activation page.
1873
+ */
1874
  return apply_filters( 'bp_get_activation_page', $page );
1875
  }
1876
 
1892
  if ( isset( $_POST['signup_username'] ) )
1893
  $value = $_POST['signup_username'];
1894
 
1895
+ /**
1896
+ * Filters the username submitted during signup.
1897
+ *
1898
+ * @since BuddyPress (1.1.0)
1899
+ *
1900
+ * @param string $value Username submitted during signup.
1901
+ */
1902
  return apply_filters( 'bp_get_signup_username_value', $value );
1903
  }
1904
 
1920
  if ( isset( $_POST['signup_email'] ) )
1921
  $value = $_POST['signup_email'];
1922
 
1923
+ /**
1924
+ * Filters the email address submitted during signup.
1925
+ *
1926
+ * @since BuddyPress (1.1.0)
1927
+ *
1928
+ * @param string $value Email address submitted during signup.
1929
+ */
1930
  return apply_filters( 'bp_get_signup_email_value', $value );
1931
  }
1932
 
1946
  if ( isset( $_POST['signup_with_blog'] ) )
1947
  $value = $_POST['signup_with_blog'];
1948
 
1949
+ /**
1950
+ * Filters the 'signup_with_blog' value submitted during signup.
1951
+ *
1952
+ * @since BuddyPress (1.1.0)
1953
+ *
1954
+ * @param string $value 'signup_with_blog' value submitted during signup.
1955
+ */
1956
  return apply_filters( 'bp_get_signup_with_blog_value', $value );
1957
  }
1958
 
1974
  if ( isset( $_POST['signup_blog_url'] ) )
1975
  $value = $_POST['signup_blog_url'];
1976
 
1977
+ /**
1978
+ * Filters the 'signup_blog_url' value submitted during signup.
1979
+ *
1980
+ * @since BuddyPress (1.1.0)
1981
+ *
1982
+ * @param string $value 'signup_blog_url' value submitted during signup.
1983
+ */
1984
  return apply_filters( 'bp_get_signup_blog_url_value', $value );
1985
  }
1986
 
2007
  // In case plugins are still using this filter
2008
  $subdomain_base = apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
2009
 
2010
+ /**
2011
+ * Filters the base URL for subdomain installations of WordPress Multisite.
2012
+ *
2013
+ * @since BuddyPress (2.1.0)
2014
+ *
2015
+ * @param string $subdomain_base The base URL - eg, 'example.com' for
2016
+ * site_url() example.com or www.example.com.
2017
+ */
2018
  return apply_filters( 'bp_signup_subdomain_base', $subdomain_base );
2019
  }
2020
 
2036
  if ( isset( $_POST['signup_blog_title'] ) )
2037
  $value = $_POST['signup_blog_title'];
2038
 
2039
+ /**
2040
+ * Filters the 'signup_blog_title' value submitted during signup.
2041
+ *
2042
+ * @since BuddyPress (1.1.0)
2043
+ *
2044
+ * @param string $value 'signup_blog_title' value submitted during signup.
2045
+ */
2046
  return apply_filters( 'bp_get_signup_blog_title_value', $value );
2047
  }
2048
 
2064
  if ( isset( $_POST['signup_blog_privacy'] ) )
2065
  $value = $_POST['signup_blog_privacy'];
2066
 
2067
+ /**
2068
+ * Filters the 'signup_blog_privacy' value submitted during signup.
2069
+ *
2070
+ * @since BuddyPress (1.1.0)
2071
+ *
2072
+ * @param string $value 'signup_blog_privacy' value submitted during signup.
2073
+ */
2074
  return apply_filters( 'bp_get_signup_blog_privacy_value', $value );
2075
  }
2076
 
2100
  else
2101
  $signup_avatar_dir = false;
2102
 
2103
+ /**
2104
+ * Filters the avatar dir used during signup.
2105
+ *
2106
+ * @since BuddyPress (1.1.0)
2107
+ *
2108
+ * @param string|bool $signup_avatar_dir Avatar dir used during signup or false.
2109
+ */
2110
+ return apply_filters( 'bp_get_signup_avatar_dir_value', $signup_avatar_dir );
2111
  }
2112
 
2113
  /**
2182
  // Set default gravatar type
2183
  if ( empty( $bp->grav_default->user ) )
2184
  $default_grav = 'wavatar';
2185
+ elseif ( 'mystery' == $bp->grav_default->user )
2186
  $default_grav = $bp->plugin_url . 'bp-core/images/mystery-man.jpg';
2187
  else
2188
  $default_grav = $bp->grav_default->user;
2189
 
2190
+ /**
2191
+ * Filters the base Gravatar url used for signup avatars when no avatar dir found.
2192
+ *
2193
+ * @since BuddyPress (1.0.2)
2194
+ *
2195
+ * @param string $value Gravatar url to use.
2196
+ */
2197
  $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
2198
  $md5_lcase_email = md5( strtolower( bp_get_signup_email_value() ) );
2199
  $gravatar_img = '<img src="' . $gravatar_url . $md5_lcase_email . '?d=' . $default_grav . '&amp;s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
2200
  }
2201
 
2202
+ /**
2203
+ * Filters the user avatar during signup.
2204
+ *
2205
+ * @since BuddyPress (1.1.0)
2206
+ *
2207
+ * @param string $gravatar_img Avatar HTML image tag.
2208
+ * @param array $args Array of parsed args for avatar query.
2209
+ */
2210
  return apply_filters( 'bp_get_signup_avatar', $gravatar_img, $args );
2211
  }
2212
 
2224
  * @return bool
2225
  */
2226
  function bp_get_signup_allowed() {
2227
+ $bp = buddypress();
2228
 
2229
  $signup_allowed = false;
2230
 
2231
  if ( is_multisite() ) {
2232
+ if ( ! isset( $bp->site_options ) ) {
2233
+ $bp->site_options = bp_core_get_root_options();
2234
+ }
2235
+
2236
  if ( in_array( $bp->site_options['registration'], array( 'all', 'user' ) ) ) {
2237
  $signup_allowed = true;
2238
  }
2243
  }
2244
  }
2245
 
2246
+ /**
2247
+ * Filters whether or not new signups are allowed.
2248
+ *
2249
+ * @since BuddyPress (1.5.0)
2250
+ *
2251
+ * @param bool $signup_allowed Whether or not new signups are allowed.
2252
+ */
2253
  return apply_filters( 'bp_get_signup_allowed', $signup_allowed );
2254
  }
2255
 
bp-members/bp-members-widgets.php ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BuddyPress Members Widgets
4
+ *
5
+ * @package BuddyPress
6
+ */
7
+
8
+ // Exit if accessed directly
9
+ if ( !defined( 'ABSPATH' ) ) exit;
10
+
11
+ /**
12
+ * Register bp-members widgets.
13
+ *
14
+ * Previously, these widgets were registered in bp-core.
15
+ *
16
+ * @since BuddyPress (2.2.0)
17
+ */
18
+ function bp_members_register_widgets() {
19
+ add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
20
+ add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
21
+ add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
22
+ }
23
+ add_action( 'bp_register_widgets', 'bp_members_register_widgets' );
24
+
25
+ /**
26
+ * Members Widget.
27
+ *
28
+ * @since BuddyPress (1.0.3)
29
+ */
30
+ class BP_Core_Members_Widget extends WP_Widget {
31
+
32
+ /**
33
+ * Constructor method.
34
+ */
35
+ function __construct() {
36
+ $widget_ops = array(
37
+ 'description' => __( 'A dynamic list of recently active, popular, and newest members', 'buddypress' ),
38
+ 'classname' => 'widget_bp_core_members_widget buddypress widget',
39
+ );
40
+ parent::__construct( false, $name = _x( '(BuddyPress) Members', 'widget name', 'buddypress' ), $widget_ops );
41
+
42
+ if ( is_active_widget( false, false, $this->id_base ) && !is_admin() && !is_network_admin() ) {
43
+ wp_enqueue_script( 'bp-widget-members' );
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Display the Members widget.
49
+ *
50
+ * @see WP_Widget::widget() for description of parameters.
51
+ *
52
+ * @param array $args Widget arguments.
53
+ * @param array $instance Widget settings, as saved by the user.
54
+ */
55
+ function widget( $args, $instance ) {
56
+
57
+ extract( $args );
58
+
59
+ if ( !$instance['member_default'] )
60
+ $instance['member_default'] = 'active';
61
+
62
+ $title = apply_filters( 'widget_title', $instance['title'] );
63
+
64
+ echo $before_widget;
65
+
66
+ $title = $instance['link_title'] ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '">' . $title . '</a>' : $title;
67
+
68
+ echo $before_title
69
+ . $title
70
+ . $after_title;
71
+
72
+ $members_args = array(
73
+ 'user_id' => 0,
74
+ 'type' => $instance['member_default'],
75
+ 'per_page' => $instance['max_members'],
76
+ 'max' => $instance['max_members'],
77
+ 'populate_extras' => true,
78
+ 'search_terms' => false,
79
+ );
80
+
81
+ ?>
82
+
83
+ <?php if ( bp_has_members( $members_args ) ) : ?>
84
+ <div class="item-options" id="members-list-options">
85
+ <a href="<?php bp_members_directory_permalink(); ?>" id="newest-members" <?php if ( $instance['member_default'] == 'newest' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ) ?></a>
86
+ | <a href="<?php bp_members_directory_permalink(); ?>" id="recently-active-members" <?php if ( $instance['member_default'] == 'active' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ) ?></a>
87
+
88
+ <?php if ( bp_is_active( 'friends' ) ) : ?>
89
+
90
+ | <a href="<?php bp_members_directory_permalink(); ?>" id="popular-members" <?php if ( $instance['member_default'] == 'popular' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ) ?></a>
91
+
92
+ <?php endif; ?>
93
+ </div>
94
+
95
+ <ul id="members-list" class="item-list">
96
+ <?php while ( bp_members() ) : bp_the_member(); ?>
97
+ <li class="vcard">
98
+ <div class="item-avatar">
99
+ <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
100
+ </div>
101
+
102
+ <div class="item">
103
+ <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
104
+ <div class="item-meta">
105
+ <span class="activity">
106
+ <?php
107
+ if ( 'newest' == $instance['member_default'] )
108
+ bp_member_registered();
109
+ if ( 'active' == $instance['member_default'] )
110
+ bp_member_last_active();
111
+ if ( 'popular' == $instance['member_default'] )
112
+ bp_member_total_friend_count();
113
+ ?>
114
+ </span>
115
+ </div>
116
+ </div>
117
+ </li>
118
+
119
+ <?php endwhile; ?>
120
+ </ul>
121
+ <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
122
+ <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr( $instance['max_members'] ); ?>" />
123
+
124
+ <?php else: ?>
125
+
126
+ <div class="widget-error">
127
+ <?php _e('No one has signed up yet!', 'buddypress') ?>
128
+ </div>
129
+
130
+ <?php endif; ?>
131
+
132
+ <?php echo $after_widget; ?>
133
+ <?php
134
+ }
135
+
136
+ /**
137
+ * Update the Members widget options.
138
+ *
139
+ * @param array $new_instance The new instance options.
140
+ * @param array $old_instance The old instance options.
141
+ * @return array $instance The parsed options to be saved.
142
+ */
143
+ function update( $new_instance, $old_instance ) {
144
+ $instance = $old_instance;
145
+
146
+ $instance['title'] = strip_tags( $new_instance['title'] );
147
+ $instance['max_members'] = strip_tags( $new_instance['max_members'] );
148
+ $instance['member_default'] = strip_tags( $new_instance['member_default'] );
149
+ $instance['link_title'] = (bool)$new_instance['link_title'];
150
+
151
+ return $instance;
152
+ }
153
+
154
+ /**
155
+ * Output the Members widget options form.
156
+ *
157
+ * @param $instance Settings for this widget.
158
+ */
159
+ function form( $instance ) {
160
+ $defaults = array(
161
+ 'title' => __( 'Members', 'buddypress' ),
162
+ 'max_members' => 5,
163
+ 'member_default' => 'active',
164
+ 'link_title' => false
165
+ );
166
+ $instance = wp_parse_args( (array) $instance, $defaults );
167
+
168
+ $title = strip_tags( $instance['title'] );
169
+ $max_members = strip_tags( $instance['max_members'] );
170
+ $member_default = strip_tags( $instance['member_default'] );
171
+ $link_title = (bool)$instance['link_title'];
172
+ ?>
173
+
174
+ <p><label for="bp-core-widget-title"><?php _e('Title:', '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>
175
+
176
+ <p><label for="<?php echo $this->get_field_name('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 Members directory', 'buddypress' ) ?></label></p>
177
+
178
+ <p><label for="bp-core-widget-members-max"><?php _e('Max members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
179
+
180
+ <p>
181
+ <label for="bp-core-widget-groups-default"><?php _e('Default members to show:', 'buddypress'); ?>
182
+ <select name="<?php echo $this->get_field_name( 'member_default' ) ?>">
183
+ <option value="newest" <?php if ( $member_default == 'newest' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ) ?></option>
184
+ <option value="active" <?php if ( $member_default == 'active' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ) ?></option>
185
+ <option value="popular" <?php if ( $member_default == 'popular' ) : ?>selected="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ) ?></option>
186
+ </select>
187
+ </label>
188
+ </p>
189
+
190
+ <?php
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Who's Online Widget.
196
+ *
197
+ * @since BuddyPress (1.0.3)
198
+ */
199
+ class BP_Core_Whos_Online_Widget extends WP_Widget {
200
+
201
+ /**
202
+ * Constructor method.
203
+ */
204
+ function __construct() {
205
+ $widget_ops = array(
206
+ 'description' => __( 'Profile photos of online users', 'buddypress' ),
207
+ 'classname' => 'widget_bp_core_whos_online_widget buddypress widget',
208
+ );
209
+ parent::__construct( false, $name = _x( "(BuddyPress) Who's Online", 'widget name', 'buddypress' ), $widget_ops );
210
+ }
211
+
212
+ /**
213
+ * Display the Who's Online widget.
214
+ *
215
+ * @see WP_Widget::widget() for description of parameters.
216
+ *
217
+ * @param array $args Widget arguments.
218
+ * @param array $instance Widget settings, as saved by the user.
219
+ */
220
+ function widget($args, $instance) {
221
+
222
+ extract( $args );
223
+
224
+ $title = apply_filters( 'widget_title', $instance['title'] );
225
+
226
+ echo $before_widget;
227
+ echo $before_title
228
+ . $title
229
+ . $after_title;
230
+
231
+ $members_args = array(
232
+ 'user_id' => 0,
233
+ 'type' => 'online',
234
+ 'per_page' => $instance['max_members'],
235
+ 'max' => $instance['max_members'],
236
+ 'populate_extras' => true,
237
+ 'search_terms' => false,
238
+ );
239
+
240
+ ?>
241
+
242
+ <?php if ( bp_has_members( $members_args ) ) : ?>
243
+ <div class="avatar-block">
244
+ <?php while ( bp_members() ) : bp_the_member(); ?>
245
+ <div class="item-avatar">
246
+ <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
247
+ </div>
248
+ <?php endwhile; ?>
249
+ </div>
250
+ <?php else: ?>
251
+
252
+ <div class="widget-error">
253
+ <?php _e( 'There are no users currently online', 'buddypress' ) ?>
254
+ </div>
255
+
256
+ <?php endif; ?>
257
+
258
+ <?php echo $after_widget; ?>
259
+ <?php
260
+ }
261
+
262
+ /**
263
+ * Update the Who's Online widget options.
264
+ *
265
+ * @param array $new_instance The new instance options.
266
+ * @param array $old_instance The old instance options.
267
+ * @return array $instance The parsed options to be saved.
268
+ */
269
+ function update( $new_instance, $old_instance ) {
270
+ $instance = $old_instance;
271
+ $instance['title'] = strip_tags( $new_instance['title'] );
272
+ $instance['max_members'] = strip_tags( $new_instance['max_members'] );
273
+
274
+ return $instance;
275
+ }
276
+
277
+ /**
278
+ * Output the Who's Online widget options form.
279
+ *
280
+ * @param $instance Settings for this widget.
281
+ */
282
+ function form( $instance ) {
283
+ $defaults = array(
284
+ 'title' => __( "Who's Online", 'buddypress' ),
285
+ 'max_members' => 15
286
+ );
287
+ $instance = wp_parse_args( (array) $instance, $defaults );
288
+
289
+ $title = strip_tags( $instance['title'] );
290
+ $max_members = strip_tags( $instance['max_members'] );
291
+ ?>
292
+
293
+ <p><label for="bp-core-widget-title"><?php _e('Title:', '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>
294
+
295
+ <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
296
+ <?php
297
+ }
298
+ }
299
+
300
+ /**
301
+ * Recently Active Members Widget.
302
+ *
303
+ * @since BuddyPress (1.0.3)
304
+ */
305
+ class BP_Core_Recently_Active_Widget extends WP_Widget {
306
+
307
+ /**
308
+ * Constructor method.
309
+ */
310
+ function __construct() {
311
+ $widget_ops = array(
312
+ 'description' => __( 'Profile photos of recently active members', 'buddypress' ),
313
+ 'classname' => 'widget_bp_core_recently_active_widget buddypress widget',
314
+ );
315
+ parent::__construct( false, $name = _x( '(BuddyPress) Recently Active Members', 'widget name', 'buddypress' ), $widget_ops );
316
+ }
317
+
318
+ /**
319
+ * Display the Recently Active widget.
320
+ *
321
+ * @see WP_Widget::widget() for description of parameters.
322
+ *
323
+ * @param array $args Widget arguments.
324
+ * @param array $instance Widget settings, as saved by the user.
325
+ */
326
+ function widget( $args, $instance ) {
327
+
328
+ extract( $args );
329
+
330
+ $title = apply_filters( 'widget_title', $instance['title'] );
331
+
332
+ echo $before_widget;
333
+ echo $before_title
334
+ . $title
335
+ . $after_title;
336
+
337
+ $members_args = array(
338
+ 'user_id' => 0,
339
+ 'type' => 'active',
340
+ 'per_page' => $instance['max_members'],
341
+ 'max' => $instance['max_members'],
342
+ 'populate_extras' => true,
343
+ 'search_terms' => false,
344
+ );
345
+
346
+ ?>
347
+
348
+ <?php if ( bp_has_members( $members_args ) ) : ?>
349
+ <div class="avatar-block">
350
+ <?php while ( bp_members() ) : bp_the_member(); ?>
351
+ <div class="item-avatar">
352
+ <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
353
+ </div>
354
+ <?php endwhile; ?>
355
+ </div>
356
+ <?php else: ?>
357
+
358
+ <div class="widget-error">
359
+ <?php _e( 'There are no recently active members', 'buddypress' ) ?>
360
+ </div>
361
+
362
+ <?php endif; ?>
363
+
364
+ <?php echo $after_widget; ?>
365
+ <?php
366
+ }
367
+
368
+ /**
369
+ * Update the Recently Active widget options.
370
+ *
371
+ * @param array $new_instance The new instance options.
372
+ * @param array $old_instance The old instance options.
373
+ * @return array $instance The parsed options to be saved.
374
+ */
375
+ function update( $new_instance, $old_instance ) {
376
+ $instance = $old_instance;
377
+ $instance['title'] = strip_tags( $new_instance['title'] );
378
+ $instance['max_members'] = strip_tags( $new_instance['max_members'] );
379
+
380
+ return $instance;
381
+ }
382
+
383
+ /**
384
+ * Output the Recently Active widget options form.
385
+ *
386
+ * @param $instance Settings for this widget.
387
+ */
388
+ function form( $instance ) {
389
+ $defaults = array(
390
+ 'title' => __( 'Recently Active Members', 'buddypress' ),
391
+ 'max_members' => 15
392
+ );
393
+ $instance = wp_parse_args( (array) $instance, $defaults );
394
+
395
+ $title = strip_tags( $instance['title'] );
396
+ $max_members = strip_tags( $instance['max_members'] );
397
+ ?>
398
+
399
+ <p><label for="bp-core-widget-members-title"><?php _e('Title:', '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>
400
+
401
+ <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
402
+ <?php
403
+ }
404
+ }
405
+
406
+ /**
407
+ * AJAX request handler for Members widgets.
408
+ *
409
+ * @since BuddyPress (1.0.0)
410
+ */
411
+ function bp_core_ajax_widget_members() {
412
+
413
+ check_ajax_referer( 'bp_core_widget_members' );
414
+
415
+ switch ( $_POST['filter'] ) {
416
+ case 'newest-members':
417
+ $type = 'newest';
418
+ break;
419
+
420
+ case 'recently-active-members':
421
+ $type = 'active';
422
+ break;
423
+
424
+ case 'popular-members':
425
+ if ( bp_is_active( 'friends' ) )
426
+ $type = 'popular';
427
+ else
428
+ $type = 'active';
429
+
430
+ break;
431
+ }
432
+
433
+ $members_args = array(
434
+ 'user_id' => 0,
435
+ 'type' => $type,
436
+ 'per_page' => $_POST['max-members'],
437
+ 'max' => $_POST['max-members'],
438
+ 'populate_extras' => 1,
439
+ 'search_terms' => false,
440
+ );
441
+
442
+ if ( bp_has_members( $members_args ) ) : ?>
443
+ <?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. ?>
444
+ <?php while ( bp_members() ) : bp_the_member(); ?>
445
+ <li class="vcard">
446
+ <div class="item-avatar">
447
+ <a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
448
+ </div>
449
+
450
+ <div class="item">
451
+ <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
452
+ <?php if ( 'active' == $type ) : ?>
453
+ <div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div>
454
+ <?php elseif ( 'newest' == $type ) : ?>
455
+ <div class="item-meta"><span class="activity"><?php bp_member_registered() ?></span></div>
456
+ <?php elseif ( bp_is_active( 'friends' ) ) : ?>
457
+ <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div>
458
+ <?php endif; ?>
459
+ </div>
460
+ </li>
461
+ <?php endwhile; ?>
462
+
463
+ <?php else: ?>
464
+ <?php echo "-1[[SPLIT]]<li>"; ?>
465
+ <?php _e( 'There were no members found, please try another filter.', 'buddypress' ) ?>
466
+ <?php echo "</li>"; ?>
467
+ <?php endif;
468
+ }
469
+ add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' );
470
+ add_action( 'wp_ajax_nopriv_widget_members', 'bp_core_ajax_widget_members' );
bp-messages/bp-messages-actions.php CHANGED
@@ -47,7 +47,7 @@ function messages_action_conversation() {
47
  if ( ! empty( $new_reply ) ) {
48
  bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
49
  } else {
50
- bp_core_add_message( __( 'There was a problem sending your reply, please try again', 'buddypress' ), 'error' );
51
  }
52
 
53
  bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );
@@ -56,6 +56,11 @@ function messages_action_conversation() {
56
  // Mark message read
57
  messages_mark_thread_read( $thread_id );
58
 
 
 
 
 
 
59
  do_action( 'messages_action_conversation' );
60
  }
61
  add_action( 'bp_actions', 'messages_action_conversation' );
@@ -91,6 +96,155 @@ function messages_action_delete_message() {
91
  }
92
  add_action( 'bp_actions', 'messages_action_delete_message' );
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  /**
95
  * Process a request to bulk delete messages.
96
  *
47
  if ( ! empty( $new_reply ) ) {
48
  bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
49
  } else {
50
+ bp_core_add_message( __( 'There was a problem sending your reply. Please try again.', 'buddypress' ), 'error' );
51
  }
52
 
53
  bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );
56
  // Mark message read
57
  messages_mark_thread_read( $thread_id );
58
 
59
+ /**
60
+ * Fires after processing a view request for a single message thread.
61
+ *
62
+ * @since BuddyPress (1.7.0)
63
+ */
64
  do_action( 'messages_action_conversation' );
65
  }
66
  add_action( 'bp_actions', 'messages_action_conversation' );
96
  }
97
  add_action( 'bp_actions', 'messages_action_delete_message' );
98
 
99
+ /**
100
+ * Handle marking a single message thread as read.
101
+ *
102
+ * @since BuddyPress (2.2.0)
103
+ *
104
+ * @return bool|null Returns false on failure. Otherwise redirects back to the
105
+ * message box URL.
106
+ */
107
+ function bp_messages_action_mark_read() {
108
+
109
+ if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'read', 0 ) ) {
110
+ return false;
111
+ }
112
+
113
+ $action = ! empty( $_GET['action'] ) ? $_GET['action'] : '';
114
+ $nonce = ! empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';
115
+ $id = ! empty( $_GET['message_id'] ) ? intval( $_GET['message_id'] ) : '';
116
+
117
+ // Bail if no action or no ID.
118
+ if ( 'read' !== $action || empty( $id ) || empty( $nonce ) ) {
119
+ return false;
120
+ }
121
+
122
+ // Check the nonce.
123
+ if ( ! bp_verify_nonce_request( 'bp_message_thread_mark_read_' . $id ) ) {
124
+ return false;
125
+ }
126
+
127
+ // Check access to the message and mark as read.
128
+ if ( messages_check_thread_access( $id ) ) {
129
+ messages_mark_thread_read( $id );
130
+ bp_core_add_message( __( 'Message marked as read.', 'buddypress' ) );
131
+ } else {
132
+ bp_core_add_message( __( 'There was a problem marking that message.', 'buddypress' ), 'error' );
133
+ }
134
+
135
+ // Redirect back to the message box.
136
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
137
+ }
138
+ add_action( 'bp_actions', 'bp_messages_action_mark_read' );
139
+
140
+ /**
141
+ * Handle marking a single message thread as unread.
142
+ *
143
+ * @since BuddyPress (2.2.0)
144
+ *
145
+ * @return bool|null Returns false on failure. Otherwise redirects back to the
146
+ * message box URL.
147
+ */
148
+ function bp_messages_action_mark_unread() {
149
+
150
+ if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'unread', 0 ) ) {
151
+ return false;
152
+ }
153
+
154
+ $action = ! empty( $_GET['action'] ) ? $_GET['action'] : '';
155
+ $nonce = ! empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';
156
+ $id = ! empty( $_GET['message_id'] ) ? intval( $_GET['message_id'] ) : '';
157
+
158
+ // Bail if no action or no ID.
159
+ if ( 'unread' !== $action || empty( $id ) || empty( $nonce ) ) {
160
+ return false;
161
+ }
162
+
163
+ // Check the nonce.
164
+ if ( ! bp_verify_nonce_request( 'bp_message_thread_mark_unread_' . $id ) ) {
165
+ return false;
166
+ }
167
+
168
+ // Check access to the message and mark unread.
169
+ if ( messages_check_thread_access( $id ) ) {
170
+ messages_mark_thread_unread( $id );
171
+ bp_core_add_message( __( 'Message marked unread.', 'buddypress' ) );
172
+ } else {
173
+ bp_core_add_message( __( 'There was a problem marking that message.', 'buddypress' ), 'error' );
174
+ }
175
+
176
+ // Redirect back to the message box URL.
177
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
178
+ }
179
+ add_action( 'bp_actions', 'bp_messages_action_mark_unread' );
180
+
181
+ /**
182
+ * Handle bulk management (mark as read/unread, delete) of message threads.
183
+ *
184
+ * @since BuddyPress (2.2.0)
185
+ *
186
+ * @return bool Returns false on failure. Otherwise redirects back to the
187
+ * message box URL.
188
+ */
189
+ function bp_messages_action_bulk_manage() {
190
+
191
+ if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'bulk-manage', 0 ) ) {
192
+ return false;
193
+ }
194
+
195
+ $action = ! empty( $_POST['messages_bulk_action'] ) ? $_POST['messages_bulk_action'] : '';
196
+ $nonce = ! empty( $_POST['messages_bulk_nonce'] ) ? $_POST['messages_bulk_nonce'] : '';
197
+ $messages = ! empty( $_POST['message_ids'] ) ? $_POST['message_ids'] : '';
198
+
199
+ $messages = wp_parse_id_list( $messages );
200
+
201
+ // Bail if no action or no IDs.
202
+ if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $messages ) || empty( $nonce ) ) {
203
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' );
204
+ }
205
+
206
+ // Check the nonce.
207
+ if ( ! wp_verify_nonce( $nonce, 'messages_bulk_nonce' ) ) {
208
+ return false;
209
+ }
210
+
211
+ // Make sure the user has access to all notifications before managing them.
212
+ foreach ( $messages as $message ) {
213
+ if ( ! messages_check_thread_access( $message ) ) {
214
+ bp_core_add_message( __( 'There was a problem managing your messages.', 'buddypress' ), 'error' );
215
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' );
216
+ }
217
+ }
218
+
219
+ // Delete, mark as read or unread depending on the user 'action'.
220
+ switch ( $action ) {
221
+ case 'delete' :
222
+ foreach ( $messages as $message ) {
223
+ messages_delete_thread( $message );
224
+ }
225
+ bp_core_add_message( __( 'Messages deleted.', 'buddypress' ) );
226
+ break;
227
+
228
+ case 'read' :
229
+ foreach ( $messages as $message ) {
230
+ messages_mark_thread_read( $message );
231
+ }
232
+ bp_core_add_message( __( 'Messages marked as read', 'buddypress' ) );
233
+ break;
234
+
235
+ case 'unread' :
236
+ foreach ( $messages as $message ) {
237
+ messages_mark_thread_unread( $message );
238
+ }
239
+ bp_core_add_message( __( 'Messages marked as unread.', 'buddypress' ) );
240
+ break;
241
+ }
242
+
243
+ // Redirect back to message box.
244
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' );
245
+ }
246
+ add_action( 'bp_actions', 'bp_messages_action_bulk_manage' );
247
+
248
  /**
249
  * Process a request to bulk delete messages.
250
  *
bp-messages/bp-messages-cache.php CHANGED
@@ -12,6 +12,29 @@
12
  // Exit if accessed directly
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  // List actions to clear super cached pages on, if super cache is installed
16
  add_action( 'messages_delete_thread', 'bp_core_clear_cache' );
17
  add_action( 'messages_send_notice', 'bp_core_clear_cache' );
12
  // Exit if accessed directly
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
+ /**
16
+ * Slurp up metadata for a set of messages.
17
+ *
18
+ * It grabs all message meta associated with all of the messages passed in
19
+ * $message_ids and adds it to WP cache. This improves efficiency when using
20
+ * message meta within a loop context.
21
+ *
22
+ * @since BuddyPress (2.2.0)
23
+ *
24
+ * @param int|str|array $message_ids Accepts a single message_id, or a
25
+ * comma-separated list or array of message ids.
26
+ */
27
+ function bp_messages_update_meta_cache( $message_ids = false ) {
28
+ bp_update_meta_cache( array(
29
+ 'object_ids' => $message_ids,
30
+ 'object_type' => buddypress()->messages->id,
31
+ 'cache_group' => 'message_meta',
32
+ 'object_column' => 'message_id',
33
+ 'meta_table' => buddypress()->messages->table_name_meta,
34
+ 'cache_key_prefix' => 'bp_messages_meta'
35
+ ) );
36
+ }
37
+
38
  // List actions to clear super cached pages on, if super cache is installed
39
  add_action( 'messages_delete_thread', 'bp_core_clear_cache' );
40
  add_action( 'messages_send_notice', 'bp_core_clear_cache' );
bp-messages/bp-messages-classes.php CHANGED
@@ -109,12 +109,11 @@ class BP_Messages_Thread {
109
  *
110
  * @since BuddyPress (1.0.0)
111
  *
112
- * @param int $thread_id The message thread ID.
113
- * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'.
114
  */
115
- public function __construct( $thread_id = false, $order = 'ASC' ) {
116
  if ( $thread_id ) {
117
- $this->populate( $thread_id, $order );
118
  }
119
  }
120
 
@@ -127,14 +126,25 @@ class BP_Messages_Thread {
127
  *
128
  * @param int $thread_id The message thread ID.
129
  * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'.
 
 
 
 
 
 
130
  */
131
- public function populate( $thread_id, $order ) {
132
  global $wpdb, $bp;
133
 
134
  if( 'ASC' != $order && 'DESC' != $order ) {
135
- $order= 'ASC';
136
  }
137
 
 
 
 
 
 
138
  $this->messages_order = $order;
139
  $this->thread_id = $thread_id;
140
 
@@ -153,6 +163,20 @@ class BP_Messages_Thread {
153
  if ( isset( $this->recipients[bp_loggedin_user_id()] ) ) {
154
  $this->unread_count = $this->recipients[bp_loggedin_user_id()]->unread_count;
155
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
 
158
  /**
@@ -182,7 +206,7 @@ class BP_Messages_Thread {
182
  *
183
  * @since BuddyPress (1.0.0)
184
  *
185
- * @return object
186
  */
187
  public function get_recipients() {
188
  global $wpdb, $bp;
@@ -190,16 +214,28 @@ class BP_Messages_Thread {
190
  $recipients = array();
191
  $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
192
 
193
- foreach ( (array) $results as $recipient )
194
  $recipients[$recipient->user_id] = $recipient;
 
195
 
196
- return $recipients;
 
 
 
 
 
 
 
 
197
  }
198
 
199
  /** Static Functions ******************************************************/
200
 
201
  /**
202
- * Delete a message thread.
 
 
 
203
  *
204
  * @since BuddyPress (1.0.0)
205
  *
@@ -209,25 +245,71 @@ class BP_Messages_Thread {
209
  public static function delete( $thread_id ) {
210
  global $wpdb, $bp;
211
 
 
 
 
 
 
 
 
 
 
212
  // Mark messages as deleted
 
 
 
213
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_loggedin_user_id() ) );
214
 
215
- // Get the message id in order to pass to the action
216
- $message_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) );
217
 
218
  // Check to see if any more recipients remain for this message
219
- // if not, then delete the message from the database.
220
  $recipients = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND is_deleted = 0", $thread_id ) );
221
 
 
222
  if ( empty( $recipients ) ) {
 
 
 
 
 
 
 
 
 
 
 
223
  // Delete all the messages
224
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) );
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  // Delete all the recipients
227
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $thread_id ) );
228
  }
229
 
230
- do_action( 'messages_thread_deleted_thread', $message_id );
 
 
 
 
 
 
 
 
231
 
232
  return true;
233
  }
@@ -237,50 +319,109 @@ class BP_Messages_Thread {
237
  *
238
  * @since BuddyPress (1.0.0)
239
  *
240
- * @param int $user_id The user ID.
241
- * @param string $box The type of mailbox to get. Either 'inbox' or 'sentbox'.
242
- * Defaults to 'inbox'.
243
- * @param string $type The type of messages to get. Either 'all' or 'unread'
244
- * or 'read'. Defaults to 'all'.
245
- * @param int $limit The number of messages to get. Defaults to null.
246
- * @param int $page The page number to get. Defaults to null.
247
- * @param string $search_terms The search term to use. Defaults to ''.
 
 
 
 
248
  * @return array|bool Array on success. Boolean false on failure.
249
  */
250
- public static function get_current_threads_for_user( $user_id, $box = 'inbox', $type = 'all', $limit = null, $page = null, $search_terms = '' ) {
251
  global $wpdb, $bp;
252
 
253
- $user_id_sql = $pag_sql = $type_sql = $search_sql = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
- if ( $limit && $page ) {
256
- $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
258
 
259
- if ( $type == 'unread' ) {
260
  $type_sql = " AND r.unread_count != 0 ";
261
- } elseif ( $type == 'read' ) {
262
  $type_sql = " AND r.unread_count = 0 ";
263
  }
264
 
265
- if ( ! empty( $search_terms ) ) {
266
- $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
267
  $search_sql = $wpdb->prepare( "AND ( subject LIKE %s OR message LIKE %s )", $search_terms_like, $search_terms_like );
268
  }
269
 
270
- if ( 'sentbox' == $box ) {
271
- $user_id_sql = $wpdb->prepare( 'm.sender_id = %d', $user_id );
272
- $thread_ids = $wpdb->get_results( "SELECT m.thread_id, MAX(m.date_sent) AS date_sent FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND m.sender_id = r.user_id AND {$user_id_sql} AND r.is_deleted = 0 {$search_sql} GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}" );
273
- $total_threads = $wpdb->get_var( "SELECT COUNT( DISTINCT m.thread_id ) FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND m.sender_id = r.user_id AND {$user_id_sql} AND r.is_deleted = 0 {$search_sql} " );
274
- } else {
275
- $user_id_sql = $wpdb->prepare( 'r.user_id = %d', $user_id );
276
- $thread_ids = $wpdb->get_results( "SELECT m.thread_id, MAX(m.date_sent) AS date_sent FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND {$user_id_sql} AND r.sender_only = 0 {$type_sql} {$search_sql} GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}" );
277
- $total_threads = $wpdb->get_var( "SELECT COUNT( DISTINCT m.thread_id ) FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND {$user_id_sql} AND r.sender_only = 0 {$type_sql} {$search_sql}" );
 
 
 
 
 
 
 
 
 
278
  }
279
 
 
 
 
 
 
 
 
 
 
280
  if ( empty( $thread_ids ) ) {
281
  return false;
282
  }
283
 
 
 
 
 
 
284
  // Sort threads by date_sent
285
  foreach( (array) $thread_ids as $thread ) {
286
  $sorted_threads[$thread->thread_id] = strtotime( $thread->date_sent );
@@ -290,10 +431,55 @@ class BP_Messages_Thread {
290
 
291
  $threads = false;
292
  foreach ( (array) $sorted_threads as $thread_id => $date_sent ) {
293
- $threads[] = new BP_Messages_Thread( $thread_id );
 
 
294
  }
295
 
296
- return array( 'threads' => &$threads, 'total' => (int) $total_threads );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  }
298
 
299
  /**
@@ -349,7 +535,7 @@ class BP_Messages_Thread {
349
 
350
  if ( $type == 'unread' )
351
  $type_sql = " AND unread_count != 0 ";
352
- else if ( $type == 'read' )
353
  $type_sql = " AND unread_count = 0 ";
354
 
355
  return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(thread_id) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0{$exclude_sender} {$type_sql}", $user_id ) );
@@ -361,7 +547,7 @@ class BP_Messages_Thread {
361
  * @since BuddyPress (1.0.0)
362
  *
363
  * @param int $thread_id The message thread ID.
364
- * @param bool
365
  */
366
  public static function user_is_sender( $thread_id ) {
367
  global $wpdb, $bp;
@@ -416,7 +602,15 @@ class BP_Messages_Thread {
416
  wp_cache_set( $user_id, $unread_count, 'bp_messages_unread_count' );
417
  }
418
 
419
- return (int) $unread_count;
 
 
 
 
 
 
 
 
420
  }
421
 
422
  /**
@@ -468,7 +662,7 @@ class BP_Messages_Thread {
468
  *
469
  * @since BuddyPress (1.0.0)
470
  *
471
- * @param object $recipients Object containing the message recipients.
472
  * @return string
473
  */
474
  public static function get_recipient_links( $recipients ) {
@@ -630,6 +824,15 @@ class BP_Messages_Message {
630
  $this->message = apply_filters( 'messages_message_content_before_save', $this->message, $this->id );
631
  $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id );
632
 
 
 
 
 
 
 
 
 
 
633
  do_action_ref_array( 'messages_message_before_save', array( &$this ) );
634
 
635
  // Make sure we have at least one recipient before sending.
@@ -669,6 +872,13 @@ class BP_Messages_Message {
669
 
670
  messages_remove_callback_values();
671
 
 
 
 
 
 
 
 
672
  do_action_ref_array( 'messages_message_after_save', array( &$this ) );
673
 
674
  return $this->id;
@@ -790,6 +1000,7 @@ class BP_Messages_Notice {
790
  * Constructor.
791
  *
792
  * @since BuddyPress (1.0.0)
 
793
  */
794
  public function __construct( $id = null ) {
795
  if ( $id ) {
@@ -831,6 +1042,15 @@ class BP_Messages_Notice {
831
  $this->subject = apply_filters( 'messages_notice_subject_before_save', $this->subject, $this->id );
832
  $this->message = apply_filters( 'messages_notice_message_before_save', $this->message, $this->id );
833
 
 
 
 
 
 
 
 
 
 
834
  do_action_ref_array( 'messages_notice_before_save', array( &$this ) );
835
 
836
  if ( empty( $this->id ) ) {
@@ -852,6 +1072,13 @@ class BP_Messages_Notice {
852
 
853
  bp_update_user_last_activity( bp_loggedin_user_id(), bp_core_current_time() );
854
 
 
 
 
 
 
 
 
855
  do_action_ref_array( 'messages_notice_after_save', array( &$this ) );
856
 
857
  return true;
@@ -891,6 +1118,13 @@ class BP_Messages_Notice {
891
  public function delete() {
892
  global $wpdb, $bp;
893
 
 
 
 
 
 
 
 
894
  do_action( 'messages_notice_before_delete', $this );
895
 
896
  $sql = $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id );
@@ -911,7 +1145,7 @@ class BP_Messages_Notice {
911
  *
912
  * @since BuddyPress (1.0.0)
913
  *
914
- * @param array $data {
915
  * Array of parameters.
916
  * @type int $pag_num Number of notices per page. Defaults to 20.
917
  * @type int $pag_page The page number. Defaults to 1.
109
  *
110
  * @since BuddyPress (1.0.0)
111
  *
112
+ * @see BP_Messages_Thread::populate() for full description of parameters
 
113
  */
114
+ public function __construct( $thread_id = false, $order = 'ASC', $args = array() ) {
115
  if ( $thread_id ) {
116
+ $this->populate( $thread_id, $order, $args );
117
  }
118
  }
119
 
126
  *
127
  * @param int $thread_id The message thread ID.
128
  * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'.
129
+ * @param array $args {
130
+ * Array of arguments.
131
+ * @type bool $update_meta_cache Whether to pre-fetch metadata for
132
+ * queried message items. Default: true.
133
+ * }
134
+ * @return bool False on failure.
135
  */
136
+ public function populate( $thread_id = 0, $order = 'ASC', $args = array() ) {
137
  global $wpdb, $bp;
138
 
139
  if( 'ASC' != $order && 'DESC' != $order ) {
140
+ $order = 'ASC';
141
  }
142
 
143
+ // merge $args with our defaults
144
+ $r = wp_parse_args( $args, array(
145
+ 'update_meta_cache' => true
146
+ ) );
147
+
148
  $this->messages_order = $order;
149
  $this->thread_id = $thread_id;
150
 
163
  if ( isset( $this->recipients[bp_loggedin_user_id()] ) ) {
164
  $this->unread_count = $this->recipients[bp_loggedin_user_id()]->unread_count;
165
  }
166
+
167
+ // Grab all message meta
168
+ if ( true === (bool) $r['update_meta_cache'] ) {
169
+ bp_messages_update_meta_cache( wp_list_pluck( $this->messages, 'id' ) );
170
+ }
171
+
172
+ /**
173
+ * Fires after a BP_Messages_Thread object has been populated.
174
+ *
175
+ * @since BuddyPress (2.2.0)
176
+ *
177
+ * @param BP_Messages_Thread Message thread object.
178
+ */
179
+ do_action( 'bp_messages_thread_post_populate', $this );
180
  }
181
 
182
  /**
206
  *
207
  * @since BuddyPress (1.0.0)
208
  *
209
+ * @return array
210
  */
211
  public function get_recipients() {
212
  global $wpdb, $bp;
214
  $recipients = array();
215
  $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
216
 
217
+ foreach ( (array) $results as $recipient ) {
218
  $recipients[$recipient->user_id] = $recipient;
219
+ }
220
 
221
+ /**
222
+ * Filters the recipients of a message thread.
223
+ *
224
+ * @since BuddyPress (2.2.0)
225
+ *
226
+ * @param array $recipients Array of recipient objects.
227
+ * @param int $thread_id ID of the current thread.
228
+ */
229
+ return apply_filters( 'bp_messages_thread_get_recipients', $recipients, $this->thread_id );
230
  }
231
 
232
  /** Static Functions ******************************************************/
233
 
234
  /**
235
+ * Mark messages in a thread as deleted or delete all messages in a thread.
236
+ *
237
+ * Note: All messages in a thread are deleted once every recipient in a thread
238
+ * has marked the thread as deleted.
239
  *
240
  * @since BuddyPress (1.0.0)
241
  *
245
  public static function delete( $thread_id ) {
246
  global $wpdb, $bp;
247
 
248
+ /**
249
+ * Fires before a message thread is marked as deleted.
250
+ *
251
+ * @since BuddyPress (2.2.0)
252
+ *
253
+ * @param int $thread_id ID of the thread being deleted.
254
+ */
255
+ do_action( 'bp_messages_thread_before_mark_delete', $thread_id );
256
+
257
  // Mark messages as deleted
258
+ //
259
+ // @todo the reliance on bp_loggedin_user_id() sucks for plugins
260
+ // refactor this method to accept a $user_id parameter
261
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_loggedin_user_id() ) );
262
 
263
+ // Get the message ids in order to pass to the action
264
+ $message_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) );
265
 
266
  // Check to see if any more recipients remain for this message
 
267
  $recipients = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND is_deleted = 0", $thread_id ) );
268
 
269
+ // No more recipients so delete all messages associated with the thread
270
  if ( empty( $recipients ) ) {
271
+
272
+ /**
273
+ * Fires before an entire message thread is deleted.
274
+ *
275
+ * @since BuddyPress (2.2.0)
276
+ *
277
+ * @param int $thread_id ID of the thread being deleted.
278
+ * @param array $message_ids IDs of messages being deleted.
279
+ */
280
+ do_action( 'bp_messages_thread_before_delete', $thread_id, $message_ids );
281
+
282
  // Delete all the messages
283
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) );
284
 
285
+ // Do something for each message ID
286
+ foreach ( $message_ids as $message_id ) {
287
+ // Delete message meta
288
+ bp_messages_delete_meta( $message_id );
289
+
290
+ /**
291
+ * Fires after a message is deleted. This hook is poorly named.
292
+ *
293
+ * @since BuddyPress (1.0.0)
294
+ *
295
+ * @param int $message_id ID of the message
296
+ */
297
+ do_action( 'messages_thread_deleted_thread', $message_id );
298
+ }
299
+
300
  // Delete all the recipients
301
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $thread_id ) );
302
  }
303
 
304
+ /**
305
+ * Fires after a message thread is either marked as deleted or deleted
306
+ *
307
+ * @since BuddyPress (2.2.0)
308
+ *
309
+ * @param int $thread_id ID of the thread being deleted.
310
+ * @param array $message_ids IDs of messages being deleted.
311
+ */
312
+ do_action( 'bp_messages_thread_after_delete', $thread_id, $message_ids );
313
 
314
  return true;
315
  }
319
  *
320
  * @since BuddyPress (1.0.0)
321
  *
322
+ * @param array $args {
323
+ * Array of arguments.
324
+ * @type int $user_id The user ID.
325
+ * @type string $box The type of mailbox to get. Either 'inbox' or 'sentbox'.
326
+ * Defaults to 'inbox'.
327
+ * @type string $type The type of messages to get. Either 'all' or 'unread'
328
+ * or 'read'. Defaults to 'all'.
329
+ * @type int $limit The number of messages to get. Defaults to null.
330
+ * @type int $page The page number to get. Defaults to null.
331
+ * @type string $search_terms The search term to use. Defaults to ''.
332
+ * @type array $meta_query Meta query arguments. See WP_Meta_Query for more details.
333
+ * }
334
  * @return array|bool Array on success. Boolean false on failure.
335
  */
336
+ public static function get_current_threads_for_user( $args = array() ) {
337
  global $wpdb, $bp;
338
 
339
+ // Backward compatibility with old method of passing arguments
340
+ if ( ! is_array( $args ) || func_num_args() > 1 ) {
341
+ _deprecated_argument( __METHOD__, '2.2.0', 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__ ) );
342
+
343
+ $old_args_keys = array(
344
+ 0 => 'user_id',
345
+ 1 => 'box',
346
+ 2 => 'type',
347
+ 3 => 'limit',
348
+ 4 => 'page',
349
+ 5 => 'search_terms',
350
+ );
351
+
352
+ $func_args = func_get_args();
353
+ $args = bp_core_parse_args_array( $old_args_keys, $func_args );
354
+ }
355
 
356
+ $defaults = array(
357
+ 'user_id' => false,
358
+ 'box' => 'inbox',
359
+ 'type' => 'all',
360
+ 'limit' => null,
361
+ 'page' => null,
362
+ 'search_terms' => '',
363
+ 'meta_query' => array()
364
+ );
365
+ $r = wp_parse_args( $args, $defaults );
366
+
367
+ $pag_sql = $type_sql = $search_sql = $user_id_sql = $sender_sql = '';
368
+ $meta_query_sql = array(
369
+ 'join' => '',
370
+ 'where' => ''
371
+ );
372
+
373
+ if ( $r['limit'] && $r['page'] ) {
374
+ $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $r['page'] - 1 ) * $r['limit'] ), intval( $r['limit'] ) );
375
  }
376
 
377
+ if ( $r['type'] == 'unread' ) {
378
  $type_sql = " AND r.unread_count != 0 ";
379
+ } elseif ( $r['type'] == 'read' ) {
380
  $type_sql = " AND r.unread_count = 0 ";
381
  }
382
 
383
+ if ( ! empty( $r['search_terms'] ) ) {
384
+ $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
385
  $search_sql = $wpdb->prepare( "AND ( subject LIKE %s OR message LIKE %s )", $search_terms_like, $search_terms_like );
386
  }
387
 
388
+ if ( ! empty( $r['user_id'] ) ) {
389
+ if ( 'sentbox' == $r['box'] ) {
390
+ $user_id_sql = 'AND ' . $wpdb->prepare( 'm.sender_id = %d', $r['user_id'] );
391
+ $sender_sql = ' AND m.sender_id = r.user_id';
392
+ } else {
393
+ $user_id_sql = 'AND ' . $wpdb->prepare( 'r.user_id = %d', $r['user_id'] );
394
+ $sender_sql = ' AND r.sender_only = 0';
395
+ }
396
+ }
397
+
398
+ // Process meta query into SQL
399
+ $meta_query = self::get_meta_query_sql( $r['meta_query'] );
400
+ if ( ! empty( $meta_query['join'] ) ) {
401
+ $meta_query_sql['join'] = $meta_query['join'];
402
+ }
403
+ if ( ! empty( $meta_query['where'] ) ) {
404
+ $meta_query_sql['where'] = $meta_query['where'];
405
  }
406
 
407
+ // set up SQL array
408
+ $sql = array();
409
+ $sql['select'] = 'SELECT m.thread_id, MAX(m.date_sent) AS date_sent';
410
+ $sql['from'] = "FROM {$bp->messages->table_name_recipients} r INNER JOIN {$bp->messages->table_name_messages} m ON m.thread_id = r.thread_id {$meta_query_sql['join']}";
411
+ $sql['where'] = "WHERE r.is_deleted = 0 {$user_id_sql} {$sender_sql} {$type_sql} {$search_sql} {$meta_query_sql['where']}";
412
+ $sql['misc'] = "GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}";
413
+
414
+ // get thread IDs
415
+ $thread_ids = $wpdb->get_results( implode( ' ', $sql ) );
416
  if ( empty( $thread_ids ) ) {
417
  return false;
418
  }
419
 
420
+ // adjust $sql to work for thread total
421
+ $sql['select'] = 'SELECT COUNT( DISTINCT m.thread_id )';
422
+ unset( $sql['misc'] );
423
+ $total_threads = $wpdb->get_var( implode( ' ', $sql ) );
424
+
425
  // Sort threads by date_sent
426
  foreach( (array) $thread_ids as $thread ) {
427
  $sorted_threads[$thread->thread_id] = strtotime( $thread->date_sent );
431
 
432
  $threads = false;
433
  foreach ( (array) $sorted_threads as $thread_id => $date_sent ) {
434
+ $threads[] = new BP_Messages_Thread( $thread_id, 'ASC', array(
435
+ 'update_meta_cache' => false
436
+ ) );
437
  }
438
 
439
+ /**
440
+ * Filters the results of the query for a user's message threads.
441
+ *
442
+ * @since BuddyPress (2.2.0)
443
+ *
444
+ * @param array $value {
445
+ * @type array $threads Array of threads. Passed by reference.
446
+ * @type int $total_threads Number of threads found by the query.
447
+ * }
448
+ */
449
+ return apply_filters( 'bp_messages_thread_current_threads', array( 'threads' => &$threads, 'total' => (int) $total_threads ) );
450
+ }
451
+
452
+ /**
453
+ * Get the SQL for the 'meta_query' param in BP_Messages_Thread::get_current_threads_for_user().
454
+ *
455
+ * We use WP_Meta_Query to do the heavy lifting of parsing the meta_query array
456
+ * and creating the necessary SQL clauses.
457
+ *
458
+ * @since BuddyPress (2.2.0)
459
+ *
460
+ * @param array $meta_query An array of meta_query filters. See the
461
+ * documentation for WP_Meta_Query for details.
462
+ * @return array $sql_array 'join' and 'where' clauses.
463
+ */
464
+ public static function get_meta_query_sql( $meta_query = array() ) {
465
+ global $wpdb;
466
+
467
+ $sql_array = array(
468
+ 'join' => '',
469
+ 'where' => '',
470
+ );
471
+
472
+ if ( ! empty( $meta_query ) ) {
473
+ $meta_query = new WP_Meta_Query( $meta_query );
474
+
475
+ // WP_Meta_Query expects the table name at
476
+ // $wpdb->messagemeta
477
+ $wpdb->messagemeta = buddypress()->messages->table_name_meta;
478
+
479
+ return $meta_query->get_sql( 'message', 'm', 'id' );
480
+ }
481
+
482
+ return $sql_array;
483
  }
484
 
485
  /**
535
 
536
  if ( $type == 'unread' )
537
  $type_sql = " AND unread_count != 0 ";
538
+ elseif ( $type == 'read' )
539
  $type_sql = " AND unread_count = 0 ";
540
 
541
  return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(thread_id) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0{$exclude_sender} {$type_sql}", $user_id ) );
547
  * @since BuddyPress (1.0.0)
548
  *
549
  * @param int $thread_id The message thread ID.
550
+ * @return bool
551
  */
552
  public static function user_is_sender( $thread_id ) {
553
  global $wpdb, $bp;
602
  wp_cache_set( $user_id, $unread_count, 'bp_messages_unread_count' );
603
  }
604
 
605
+ /**
606
+ * Filters a user's unread message count.
607
+ *
608
+ * @since BuddyPress (2.2.0)
609
+ *
610
+ * @param int $unread_count Unread message count.
611
+ * @param int $user_id ID of the user.
612
+ */
613
+ return apply_filters( 'messages_thread_get_inbox_count', (int) $unread_count, $user_id );
614
  }
615
 
616
  /**
662
  *
663
  * @since BuddyPress (1.0.0)
664
  *
665
+ * @param array $recipients Array containing the message recipients (array of objects).
666
  * @return string
667
  */
668
  public static function get_recipient_links( $recipients ) {
824
  $this->message = apply_filters( 'messages_message_content_before_save', $this->message, $this->id );
825
  $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id );
826
 
827
+ /**
828
+ * Fires before the current message item gets saved.
829
+ *
830
+ * Please use this hook to filter the properties above. Each part will be passed in.
831
+ *
832
+ * @since BuddyPress (1.0.0)
833
+ *
834
+ * @param BP_Messages_Message Current instance of the message item being saved. Passed by reference.
835
+ */
836
  do_action_ref_array( 'messages_message_before_save', array( &$this ) );
837
 
838
  // Make sure we have at least one recipient before sending.
872
 
873
  messages_remove_callback_values();
874
 
875
+ /**
876
+ * Fires after the current message item has been saved.
877
+ *
878
+ * @since BuddyPress (1.0.0)
879
+ *
880
+ * @param BP_Messages_Message Current instance of the message item being saved. Passed by reference.
881
+ */
882
  do_action_ref_array( 'messages_message_after_save', array( &$this ) );
883
 
884
  return $this->id;
1000
  * Constructor.
1001
  *
1002
  * @since BuddyPress (1.0.0)
1003
+ * @param int $id Optional. The ID of the current notice.
1004
  */
1005
  public function __construct( $id = null ) {
1006
  if ( $id ) {
1042
  $this->subject = apply_filters( 'messages_notice_subject_before_save', $this->subject, $this->id );
1043
  $this->message = apply_filters( 'messages_notice_message_before_save', $this->message, $this->id );
1044
 
1045
+ /**
1046
+ * Fires before the current message notice item gets saved.
1047
+ *
1048
+ * Please use this hook to filter the properties above. Each part will be passed in.
1049
+ *
1050
+ * @since BuddyPress (1.0.0)
1051
+ *
1052
+ * @param BP_Messages_Notice Current instance of the message notice item being saved. Passed by reference.
1053
+ */
1054
  do_action_ref_array( 'messages_notice_before_save', array( &$this ) );
1055
 
1056
  if ( empty( $this->id ) ) {
1072
 
1073
  bp_update_user_last_activity( bp_loggedin_user_id(), bp_core_current_time() );
1074
 
1075
+ /**
1076
+ * Fires after the current message notice item has been saved.
1077
+ *
1078
+ * @since BuddyPress (1.0.0)
1079
+ *
1080
+ * @param BP_Messages_Notice Current instance of the message item being saved. Passed by reference.
1081
+ */
1082
  do_action_ref_array( 'messages_notice_after_save', array( &$this ) );
1083
 
1084
  return true;
1118
  public function delete() {
1119
  global $wpdb, $bp;
1120
 
1121
+ /**
1122
+ * Fires before the current message item has been deleted.
1123
+ *
1124
+ * @since BuddyPress (1.0.0)
1125
+ *
1126
+ * @param BP_Messages_Notice Current instance of the message notice item being deleted.
1127
+ */
1128
  do_action( 'messages_notice_before_delete', $this );
1129
 
1130
  $sql = $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id );
1145
  *
1146
  * @since BuddyPress (1.0.0)
1147
  *
1148
+ * @param array $args {
1149
  * Array of parameters.
1150
  * @type int $pag_num Number of notices per page. Defaults to 20.
1151
  * @type int $pag_page The page number. Defaults to 1.
bp-messages/bp-messages-functions.php CHANGED
@@ -155,7 +155,13 @@ function messages_new_message( $args = '' ) {
155
  return false;
156
  }
157
 
158
- // Allow additional actions when a message is sent successfully
 
 
 
 
 
 
159
  do_action_ref_array( 'messages_message_sent', array( &$message ) );
160
 
161
  // Return the thread ID
@@ -182,6 +188,14 @@ function messages_send_notice( $subject, $message ) {
182
  $notice->is_active = 1;
183
  $notice->save(); // send it.
184
 
 
 
 
 
 
 
 
 
185
  do_action_ref_array( 'messages_send_notice', array( $subject, $message ) );
186
 
187
  return true;
@@ -195,6 +209,14 @@ function messages_send_notice( $subject, $message ) {
195
  * @return bool True on success, false on failure.
196
  */
197
  function messages_delete_thread( $thread_ids ) {
 
 
 
 
 
 
 
 
198
  do_action( 'messages_before_delete_thread', $thread_ids );
199
 
200
  if ( is_array( $thread_ids ) ) {
@@ -209,6 +231,13 @@ function messages_delete_thread( $thread_ids ) {
209
  return false;
210
  }
211
 
 
 
 
 
 
 
 
212
  do_action( 'messages_delete_thread', $thread_ids );
213
 
214
  return true;
@@ -217,6 +246,7 @@ function messages_delete_thread( $thread_ids ) {
217
  return false;
218
  }
219
 
 
220
  do_action( 'messages_delete_thread', $thread_ids );
221
 
222
  return true;
@@ -335,3 +365,88 @@ function messages_get_message_sender( $message_id ) {
335
  function messages_is_valid_thread( $thread_id ) {
336
  return BP_Messages_Thread::is_valid( $thread_id );
337
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  return false;
156
  }
157
 
158
+ /**
159
+ * Fires after a message has been successfully sent.
160
+ *
161
+ * @since BuddyPress (1.1.0)
162
+ *
163
+ * @param BP_Messages_Message $message Message object. Passed by reference.
164
+ */
165
  do_action_ref_array( 'messages_message_sent', array( &$message ) );
166
 
167
  // Return the thread ID
188
  $notice->is_active = 1;
189
  $notice->save(); // send it.
190
 
191
+ /**
192
+ * Fires after a notice has been successfully sent.
193
+ *
194
+ * @since BuddyPress (1.0.0)
195
+ *
196
+ * @param string $subject Subject of the notice.
197
+ * @param string $message Content of the notice.
198
+ */
199
  do_action_ref_array( 'messages_send_notice', array( $subject, $message ) );
200
 
201
  return true;
209
  * @return bool True on success, false on failure.
210
  */
211
  function messages_delete_thread( $thread_ids ) {
212
+
213
+ /**
214
+ * Fires before specified thread IDs have been deleted.
215
+ *
216
+ * @since BuddyPress (1.5.0)
217
+ *
218
+ * @param int|array Thread ID or array of thread IDs that were deleted.
219
+ */
220
  do_action( 'messages_before_delete_thread', $thread_ids );
221
 
222
  if ( is_array( $thread_ids ) ) {
231
  return false;
232
  }
233
 
234
+ /**
235
+ * Fires after specified thread IDs have been deleted.
236
+ *
237
+ * @since BuddyPress (1.0.0)
238
+ *
239
+ * @param int|array Thread ID or array of thread IDs that were deleted.
240
+ */
241
  do_action( 'messages_delete_thread', $thread_ids );
242
 
243
  return true;
246
  return false;
247
  }
248
 
249
+ /** This action is documented in bp-messages/bp-messages-functions.php */
250
  do_action( 'messages_delete_thread', $thread_ids );
251
 
252
  return true;
365
  function messages_is_valid_thread( $thread_id ) {
366
  return BP_Messages_Thread::is_valid( $thread_id );
367
  }
368
+
369
+ /** Messages Meta *******************************************************/
370
+
371
+ /**
372
+ * Delete metadata for a message.
373
+ *
374
+ * If $meta_key is false, this will delete all meta for the message ID.
375
+ *
376
+ * @since BuddyPress (2.2.0)
377
+ *
378
+ * @see delete_metadata() for full documentation excluding $meta_type variable.
379
+ */
380
+ function bp_messages_delete_meta( $message_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
381
+ // Legacy - if no meta_key is passed, delete all for the item
382
+ if ( empty( $meta_key ) ) {
383
+ global $wpdb;
384
+
385
+ $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->messagemeta} WHERE message_id = %d", $message_id ) );
386
+
387
+ // With no meta_key, ignore $delete_all
388
+ $delete_all = false;
389
+ } else {
390
+ $keys = array( $meta_key );
391
+ }
392
+
393
+ // no keys, so stop now!
394
+ if ( empty( $keys ) ) {
395
+ return false;
396
+ }
397
+
398
+ add_filter( 'query', 'bp_filter_metaid_column_name' );
399
+
400
+ foreach ( $keys as $key ) {
401
+ $retval = delete_metadata( 'message', $message_id, $key, $meta_value, $delete_all );
402
+ }
403
+
404
+ remove_filter( 'query', 'bp_filter_metaid_column_name' );
405
+
406
+ return $retval;
407
+ }
408
+
409
+ /**
410
+ * Get a piece of message metadata.
411
+ *
412
+ * @since BuddyPress (2.2.0)
413
+ *
414
+ * @see get_metadata() for full documentation excluding $meta_type variable.
415
+ */
416
+ function bp_messages_get_meta( $message_id, $meta_key = '', $single = true ) {
417
+ add_filter( 'query', 'bp_filter_metaid_column_name' );
418
+ $retval = get_metadata( 'message', $message_id, $meta_key, $single );
419
+ remove_filter( 'query', 'bp_filter_metaid_column_name' );
420
+
421
+ return $retval;
422
+ }
423
+
424
+ /**
425
+ * Update a piece of message metadata.
426
+ *
427
+ * @since BuddyPress (2.2.0)
428
+ *
429
+ * @see update_metadata() for full documentation excluding $meta_type variable.
430
+ */
431
+ function bp_messages_update_meta( $message_id, $meta_key, $meta_value, $prev_value = '' ) {
432
+ add_filter( 'query', 'bp_filter_metaid_column_name' );
433
+ $retval = update_metadata( 'message', $message_id, $meta_key, $meta_value, $prev_value );
434
+ remove_filter( 'query', 'bp_filter_metaid_column_name' );
435
+
436
+ return $retval;
437
+ }
438
+
439
+ /**
440
+ * Add a piece of message metadata.
441
+ *
442
+ * @since BuddyPress (2.2.0)
443
+ *
444
+ * @see add_metadata() for full documentation excluding $meta_type variable.
445
+ */
446
+ function bp_message_add_meta( $message_id, $meta_key, $meta_value, $unique = false ) {
447
+ add_filter( 'query', 'bp_filter_metaid_column_name' );
448
+ $retval = add_metadata( 'message', $message_id, $meta_key, $meta_value, $unique );
449
+ remove_filter( 'query', 'bp_filter_metaid_column_name' );
450
+
451
+ return $retval;
452
+ }
bp-messages/bp-messages-loader.php CHANGED
@@ -22,7 +22,7 @@ class BP_Messages_Component extends BP_Component {
22
  * If this is true, the Message autocomplete will return friends only, unless
23
  * this is set to false, in which any matching users will be returned.
24
  *
25
- * @since BuddyPress (1.5)
26
  * @var bool
27
  */
28
  public $autocomplete_all;
@@ -90,22 +90,27 @@ class BP_Messages_Component extends BP_Component {
90
  $global_tables = array(
91
  'table_name_notices' => $bp->table_prefix . 'bp_messages_notices',
92
  'table_name_messages' => $bp->table_prefix . 'bp_messages_messages',
93
- 'table_name_recipients' => $bp->table_prefix . 'bp_messages_recipients'
 
 
 
 
 
 
94
  );
95
 
 
 
96
  // All globals for messaging component.
97
  // Note that global_tables is included in this array.
98
- $globals = array(
99
  'slug' => BP_MESSAGES_SLUG,
100
  'has_directory' => false,
101
  'notification_callback' => 'messages_format_notifications',
102
  'search_string' => __( 'Search Messages...', 'buddypress' ),
103
- 'global_tables' => $global_tables
104
- );
105
-
106
- $this->autocomplete_all = defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' );
107
-
108
- parent::setup_globals( $globals );
109
  }
110
 
111
  /**
@@ -287,6 +292,23 @@ class BP_Messages_Component extends BP_Component {
287
 
288
  parent::setup_title();
289
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  }
291
 
292
  /**
22
  * If this is true, the Message autocomplete will return friends only, unless
23
  * this is set to false, in which any matching users will be returned.
24
  *
25
+ * @since BuddyPress (1.5.0)
26
  * @var bool
27
  */
28
  public $autocomplete_all;
90
  $global_tables = array(
91
  'table_name_notices' => $bp->table_prefix . 'bp_messages_notices',
92
  'table_name_messages' => $bp->table_prefix . 'bp_messages_messages',
93
+ 'table_name_recipients' => $bp->table_prefix . 'bp_messages_recipients',
94
+ 'table_name_meta' => $bp->table_prefix . 'bp_messages_meta',
95
+ );
96
+
97
+ // Metadata tables for messaging component
98
+ $meta_tables = array(
99
+ 'message' => $bp->table_prefix . 'bp_messages_meta',
100
  );
101
 
102
+ $this->autocomplete_all = defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' );
103
+
104
  // All globals for messaging component.
105
  // Note that global_tables is included in this array.
106
+ parent::setup_globals( array(
107
  'slug' => BP_MESSAGES_SLUG,
108
  'has_directory' => false,
109
  'notification_callback' => 'messages_format_notifications',
110
  'search_string' => __( 'Search Messages...', 'buddypress' ),
111
+ 'global_tables' => $global_tables,
112
+ 'meta_tables' => $meta_tables
113
+ ) );
 
 
 
114
  }
115
 
116
  /**
292
 
293
  parent::setup_title();
294
  }
295
+
296
+ /**
297
+ * Setup cache groups
298
+ *
299
+ * @since BuddyPress (2.2.0)
300
+ */
301
+ public function setup_cache_groups() {
302
+
303
+ // Global groups
304
+ wp_cache_add_global_groups( array(
305
+ 'bp_messages',
306
+ 'bp_messages_unread_count',
307
+ 'message_meta'
308
+ ) );
309
+
310
+ parent::setup_cache_groups();
311
+ }
312
  }
313
 
314
  /**
bp-messages/bp-messages-notifications.php CHANGED
@@ -92,15 +92,56 @@ To view and read your messages please log in and visit: %4$s
92
  $email_content .= sprintf( __( 'To disable these notifications, please log in and go to: %s', 'buddypress' ), $settings_link );
93
  }
94
 
95
- // Send the message
 
 
 
 
 
 
 
96
  $email_to = apply_filters( 'messages_notification_new_message_to', $email_to, $ud );
 
 
 
 
 
 
 
 
 
 
97
  $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name, $ud );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  $email_content = apply_filters( 'messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link, $ud );
99
 
100
  wp_mail( $email_to, $email_subject, $email_content );
101
  }
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
104
  do_action( 'bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args );
105
  }
106
  add_action( 'messages_message_sent', 'messages_notification_new_message', 10 );
@@ -125,12 +166,15 @@ function messages_format_notifications( $action, $item_id, $secondary_item_id, $
125
  $total_items = (int) $total_items;
126
  $link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox' );
127
  $title = __( 'Inbox', 'buddypress' );
 
128
 
129
  if ( 'new_message' === $action ) {
130
  if ( $total_items > 1 ) {
 
131
  $text = sprintf( __( 'You have %d new messages', 'buddypress' ), $total_items );
132
- $filter = 'bp_messages_multiple_new_message_notification';
133
  } else {
 
 
134
  // get message thread ID
135
  $message = new BP_Messages_Message( $item_id );
136
  $thread_id = $message->thread_id;
@@ -143,7 +187,6 @@ function messages_format_notifications( $action, $item_id, $secondary_item_id, $
143
  } else {
144
  $text = sprintf( _n( 'You have %s new private message', 'You have %s new private messages', $total_items, 'buddypress' ), bp_core_number_format( $total_items ) );
145
  }
146
- $filter = 'bp_messages_single_new_message_notification';
147
  }
148
  }
149
 
@@ -153,14 +196,39 @@ function messages_format_notifications( $action, $item_id, $secondary_item_id, $
153
  } else {
154
  $retval = esc_html( $text );
155
  }
156
- $return = apply_filters( $filter, $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  } else {
158
- $return = apply_filters( $filter, array(
 
159
  'text' => $text,
160
  'link' => $link
161
  ), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
162
  }
163
 
 
 
 
 
 
 
 
 
 
 
164
  do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
165
 
166
  return $return;
92
  $email_content .= sprintf( __( 'To disable these notifications, please log in and go to: %s', 'buddypress' ), $settings_link );
93
  }
94
 
95
+ /**
96
+ * Filters the user email that the message notification will be sent to.
97
+ *
98
+ * @since BuddyPress (1.2.0)
99
+ *
100
+ * @param string $email_to User email the notification is being sent to.
101
+ * @param WP_User $ud WP_User object of who is receiving the message.
102
+ */
103
  $email_to = apply_filters( 'messages_notification_new_message_to', $email_to, $ud );
104
+
105
+ /**
106
+ * Filters the message notification subject that will be sent to user.
107
+ *
108
+ * @since BuddyPress (1.2.0)
109
+ *
110
+ * @param string $email_subject Email notification subject text.
111
+ * @param string $sender_name Name of the person who sent the message.
112
+ * @param WP_User $ud WP_User object of who is receiving the message.
113
+ */
114
  $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name, $ud );
115
+
116
+ /**
117
+ * Filters the message notification message that will be sent to user.
118
+ *
119
+ * @since BuddyPress (1.2.0)
120
+ *
121
+ * @param string $email_content Email notification message text.
122
+ * @param string $sender_name Name of the person who sent the message.
123
+ * @param string $subject Email notification subject text.
124
+ * @param string $content Content of the message.
125
+ * @param string $message_link URL permalink for the message.
126
+ * @param string $settings_link URL permalink for the user's notification settings area.
127
+ * @param WP_User $ud WP_User object of who is receiving the message.
128
+ */
129
  $email_content = apply_filters( 'messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link, $ud );
130
 
131
  wp_mail( $email_to, $email_subject, $email_content );
132
  }
133
  }
134
 
135
+ /**
136
+ * Fires after the sending of a new message email notification.
137
+ *
138
+ * @since BuddyPress (1.5.0)
139
+ *
140
+ * @param array $recipients User IDs of recipients.
141
+ * @param string $email_subject Email notification subject text.
142
+ * @param string $email_content Email notification message text.
143
+ * @param array $$args Array of originally provided arguments.
144
+ */
145
  do_action( 'bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args );
146
  }
147
  add_action( 'messages_message_sent', 'messages_notification_new_message', 10 );
166
  $total_items = (int) $total_items;
167
  $link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox' );
168
  $title = __( 'Inbox', 'buddypress' );
169
+ $amount = 'single';
170
 
171
  if ( 'new_message' === $action ) {
172
  if ( $total_items > 1 ) {
173
+ $amount = 'multiple';
174
  $text = sprintf( __( 'You have %d new messages', 'buddypress' ), $total_items );
 
175
  } else {
176
+ $amount = 'single';
177
+
178
  // get message thread ID
179
  $message = new BP_Messages_Message( $item_id );
180
  $thread_id = $message->thread_id;
187
  } else {
188
  $text = sprintf( _n( 'You have %s new private message', 'You have %s new private messages', $total_items, 'buddypress' ), bp_core_number_format( $total_items ) );
189
  }
 
190
  }
191
  }
192
 
196
  } else {
197
  $retval = esc_html( $text );
198
  }
199
+
200
+ /**
201
+ * Filters the new message notification text before the notification is created.
202
+ *
203
+ * This is a dynamic filter. Possible filter names are:
204
+ * - 'bp_messages_multiple_new_message_notification'
205
+ * - 'bp_messages_single_new_message_notification'
206
+ *
207
+ * @param string $retval Notification text.
208
+ * @param int $total_items Number of messages referred to by the notification.
209
+ * @param string $text The raw notification test (ie, not wrapped in a link).
210
+ * @param int $item_id ID of the associated item.
211
+ * @param int $secondary_item_id ID of the secondary associated item.
212
+ */
213
+ $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
214
  } else {
215
+ /** This filter is documented in bp-messages/bp-messages-notifications.php */
216
+ $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', array(
217
  'text' => $text,
218
  'link' => $link
219
  ), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
220
  }
221
 
222
+ /**
223
+ * Fires right before returning the formatted message notifications.
224
+ *
225
+ * @since BuddyPress (1.0.0)
226
+ *
227
+ * @param string $action The type of message notification.
228
+ * @param int $item_id The primary item ID.
229
+ * @param int $secondary_item_id The secondary item ID.
230
+ * @param int $total_items Total amount of items to format.
231
+ */
232
  do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
233
 
234
  return $return;
bp-messages/bp-messages-screens.php CHANGED
@@ -23,7 +23,20 @@ function messages_screen_inbox() {
23
  return;
24
  }
25
 
 
 
 
 
 
26
  do_action( 'messages_screen_inbox' );
 
 
 
 
 
 
 
 
27
  bp_core_load_template( apply_filters( 'messages_template_inbox', 'members/single/home' ) );
28
  }
29
 
@@ -36,7 +49,20 @@ function messages_screen_sentbox() {
36
  return;
37
  }
38
 
 
 
 
 
 
39
  do_action( 'messages_screen_sentbox' );
 
 
 
 
 
 
 
 
40
  bp_core_load_template( apply_filters( 'messages_template_sentbox', 'members/single/home' ) );
41
  }
42
 
@@ -61,7 +87,7 @@ function messages_screen_compose() {
61
 
62
  // Check we have what we need
63
  if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) {
64
- bp_core_add_message( __( 'There was an error sending that message, please try again', 'buddypress' ), 'error' );
65
  } else {
66
  // If this is a notice, send it
67
  if ( isset( $_POST['send-notice'] ) ) {
@@ -69,13 +95,21 @@ function messages_screen_compose() {
69
  bp_core_add_message( __( 'Notice sent successfully!', 'buddypress' ) );
70
  bp_core_redirect( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/' );
71
  } else {
72
- bp_core_add_message( __( 'There was an error sending that notice, please try again', 'buddypress' ), 'error' );
73
  }
74
  } else {
75
  // Filter recipients into the format we need - array( 'username/userid', 'username/userid' )
76
  $autocomplete_recipients = explode( ',', $_POST['send-to-input'] );
77
  $typed_recipients = explode( ' ', $_POST['send_to_usernames'] );
78
  $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients );
 
 
 
 
 
 
 
 
79
  $recipients = apply_filters( 'bp_messages_recipients', $recipients );
80
  $thread_id = messages_new_message( array(
81
  'recipients' => $recipients,
@@ -88,14 +122,26 @@ function messages_screen_compose() {
88
  bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) );
89
  bp_core_redirect( bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );
90
  } else {
91
- bp_core_add_message( __( 'There was an error sending that message, please try again', 'buddypress' ), 'error' );
92
  }
93
  }
94
  }
95
  }
96
 
 
 
 
 
 
97
  do_action( 'messages_screen_compose' );
98
 
 
 
 
 
 
 
 
99
  bp_core_load_template( apply_filters( 'messages_template_compose', 'members/single/home' ) );
100
  }
101
 
@@ -123,8 +169,20 @@ function messages_screen_conversation() {
123
  // Decrease the unread count in the nav before it's rendered
124
  $bp->bp_nav[$bp->messages->slug]['name'] = sprintf( __( 'Messages <span>%s</span>', 'buddypress' ), bp_get_total_unread_messages_count() );
125
 
 
 
 
 
 
126
  do_action( 'messages_screen_conversation' );
127
 
 
 
 
 
 
 
 
128
  bp_core_load_template( apply_filters( 'messages_template_view_message', 'members/single/home' ) );
129
  }
130
  add_action( 'bp_screens', 'messages_screen_conversation' );
@@ -152,13 +210,13 @@ function messages_screen_notices() {
152
  } else {
153
  bp_core_add_message( __('Notice deactivated.', 'buddypress') );
154
  }
155
- } else if ( bp_is_action_variable( 'activate', 0 ) ) {
156
  if ( !$notice->activate() ) {
157
  bp_core_add_message( __('There was a problem activating that notice.', 'buddypress'), 'error' );
158
  } else {
159
  bp_core_add_message( __('Notice activated.', 'buddypress') );
160
  }
161
- } else if ( bp_is_action_variable( 'delete' ) ) {
162
  if ( !$notice->delete() ) {
163
  bp_core_add_message( __('There was a problem deleting that notice.', 'buddypress'), 'buddypress' );
164
  } else {
@@ -173,8 +231,20 @@ function messages_screen_notices() {
173
  return;
174
  }
175
 
 
 
 
 
 
176
  do_action( 'messages_screen_notices' );
177
 
 
 
 
 
 
 
 
178
  bp_core_load_template( apply_filters( 'messages_template_notices', 'members/single/home' ) );
179
  }
180
 
@@ -209,7 +279,14 @@ function messages_screen_notification_settings() {
209
  <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php checked( $new_messages, 'no', true ) ?>/></td>
210
  </tr>
211
 
212
- <?php do_action( 'messages_screen_notification_settings' ) ?>
 
 
 
 
 
 
 
213
  </tbody>
214
  </table>
215
 
23
  return;
24
  }
25
 
26
+ /**
27
+ * Fires right before the loading of the Messages inbox screen template file.
28
+ *
29
+ * @since BuddyPress (1.0.0)
30
+ */
31
  do_action( 'messages_screen_inbox' );
32
+
33
+ /**
34
+ * Filters the template to load for the Messages inbox screen.
35
+ *
36
+ * @since BuddyPress (1.0.0)
37
+ *
38
+ * @param string $template Path to the messages template to load.
39
+ */
40
  bp_core_load_template( apply_filters( 'messages_template_inbox', 'members/single/home' ) );
41
  }
42
 
49
  return;
50
  }
51
 
52
+ /**
53
+ * Fires right before the loading of the Messages sentbox screen template file.
54
+ *
55
+ * @since BuddyPress (1.0.0)
56
+ */
57
  do_action( 'messages_screen_sentbox' );
58
+
59
+ /**
60
+ * Filters the template to load for the Messages sentbox screen.
61
+ *
62
+ * @since BuddyPress (1.0.0)
63
+ *
64
+ * @param string $template Path to the messages template to load.
65
+ */
66
  bp_core_load_template( apply_filters( 'messages_template_sentbox', 'members/single/home' ) );
67
  }
68
 
87
 
88
  // Check we have what we need
89
  if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) {
90
+ bp_core_add_message( __( 'There was an error sending that message. Please try again.', 'buddypress' ), 'error' );
91
  } else {
92
  // If this is a notice, send it
93
  if ( isset( $_POST['send-notice'] ) ) {
95
  bp_core_add_message( __( 'Notice sent successfully!', 'buddypress' ) );
96
  bp_core_redirect( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/' );
97
  } else {
98
+ bp_core_add_message( __( 'There was an error sending that notice. Please try again.', 'buddypress' ), 'error' );
99
  }
100
  } else {
101
  // Filter recipients into the format we need - array( 'username/userid', 'username/userid' )
102
  $autocomplete_recipients = explode( ',', $_POST['send-to-input'] );
103
  $typed_recipients = explode( ' ', $_POST['send_to_usernames'] );
104
  $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients );
105
+
106
+ /**
107
+ * Filters the array of recipients to receive the composed message.
108
+ *
109
+ * @since BuddyPress (1.2.10)
110
+ *
111
+ * @param array $recipients Array of recipients to receive message.
112
+ */
113
  $recipients = apply_filters( 'bp_messages_recipients', $recipients );
114
  $thread_id = messages_new_message( array(
115
  'recipients' => $recipients,
122
  bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) );
123
  bp_core_redirect( bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );
124
  } else {
125
+ bp_core_add_message( __( 'There was an error sending that message. Please try again.', 'buddypress' ), 'error' );
126
  }
127
  }
128
  }
129
  }
130
 
131
+ /**
132
+ * Fires right before the loading of the Messages compose screen template file.
133
+ *
134
+ * @since BuddyPress (1.0.0)
135
+ */
136
  do_action( 'messages_screen_compose' );
137
 
138
+ /**
139
+ * Filters the template to load for the Messages compose screen.
140
+ *
141
+ * @since BuddyPress (1.0.0)
142
+ *
143
+ * @param string $template Path to the messages template to load.
144
+ */
145
  bp_core_load_template( apply_filters( 'messages_template_compose', 'members/single/home' ) );
146
  }
147
 
169
  // Decrease the unread count in the nav before it's rendered
170
  $bp->bp_nav[$bp->messages->slug]['name'] = sprintf( __( 'Messages <span>%s</span>', 'buddypress' ), bp_get_total_unread_messages_count() );
171
 
172
+ /**
173
+ * Fires right before the loading of the Messages view screen template file.
174
+ *
175
+ * @since BuddyPress (1.7.0)
176
+ */
177
  do_action( 'messages_screen_conversation' );
178
 
179
+ /**
180
+ * Filters the template to load for the Messages view screen.
181
+ *
182
+ * @since BuddyPress (1.0.0)
183
+ *
184
+ * @param string $template Path to the messages template to load.
185
+ */
186
  bp_core_load_template( apply_filters( 'messages_template_view_message', 'members/single/home' ) );
187
  }
188
  add_action( 'bp_screens', 'messages_screen_conversation' );
210
  } else {
211
  bp_core_add_message( __('Notice deactivated.', 'buddypress') );
212
  }
213
+ } elseif ( bp_is_action_variable( 'activate', 0 ) ) {
214
  if ( !$notice->activate() ) {
215
  bp_core_add_message( __('There was a problem activating that notice.', 'buddypress'), 'error' );
216
  } else {
217
  bp_core_add_message( __('Notice activated.', 'buddypress') );
218
  }
219
+ } elseif ( bp_is_action_variable( 'delete' ) ) {
220
  if ( !$notice->delete() ) {
221
  bp_core_add_message( __('There was a problem deleting that notice.', 'buddypress'), 'buddypress' );
222
  } else {
231
  return;
232
  }
233
 
234
+ /**
235
+ * Fires right before the loading of the Messages notices screen template file.
236
+ *
237
+ * @since BuddyPress (1.0.0)
238
+ */
239
  do_action( 'messages_screen_notices' );
240
 
241
+ /**
242
+ * Filters the template to load for the Messages notices screen.
243
+ *
244
+ * @since BuddyPress (1.0.0)
245
+ *
246
+ * @param string $template Path to the messages template to load.
247
+ */
248
  bp_core_load_template( apply_filters( 'messages_template_notices', 'members/single/home' ) );
249
  }
250
 
279
  <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php checked( $new_messages, 'no', true ) ?>/></td>
280
  </tr>
281
 
282
+ <?php
283
+
284
+ /**
285
+ * Fires inside the closing </tbody> tag for messages screen notification settings.
286
+ *
287
+ * @since BuddyPress (1.0.0)
288
+ */
289
+ do_action( 'messages_screen_notification_settings' ); ?>
290
  </tbody>
291
  </table>
292
 
bp-messages/bp-messages-template.php CHANGED
@@ -114,26 +114,49 @@ class BP_Messages_Box_Template {
114
  /**
115
  * Constructor method.
116
  *
117
- * @param int $user_id ID of the user whose Messages box is being
118
- * viewed.
119
- * @param string $box Type of box being viewed ('notices', 'sentbox',
120
- * 'inbox').
121
- * @param int $per_page Number of thread to return per page of results.
122
- * @param int $max Max number of results to return.
123
- * @param string $type Type of results to return. 'unread', 'read',
124
- * or 'all'.
125
- * @param string $search_terms Search terms for limiting results.
126
- * @param string $page_arg Optional. URL argument for pagination
127
- * parameter. Default: 'mpage'.
128
- */
129
- public function __construct( $user_id, $box, $per_page, $max, $type, $search_terms, $page_arg = 'mpage' ) {
130
- $this->pag_page = isset( $_GET[$page_arg] ) ? intval( $_GET[$page_arg] ) : 1;
131
- $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
132
-
133
- $this->user_id = $user_id;
134
- $this->box = $box;
135
- $this->type = $type;
136
- $this->search_terms = $search_terms;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  if ( 'notices' == $this->box ) {
139
  $this->threads = BP_Messages_Notice::get_notices( array(
@@ -141,7 +164,15 @@ class BP_Messages_Box_Template {
141
  'pag_page' => $this->pag_page
142
  ) );
143
  } else {
144
- $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page, $this->search_terms );
 
 
 
 
 
 
 
 
145
 
146
  $this->threads = $threads['threads'];
147
  $this->total_thread_count = $threads['total'];
@@ -153,19 +184,19 @@ class BP_Messages_Box_Template {
153
  } else {
154
  $total_notice_count = BP_Messages_Notice::get_total_notice_count();
155
 
156
- if ( !$max || $max >= (int) $total_notice_count ) {
157
  if ( 'notices' == $this->box ) {
158
  $this->total_thread_count = (int) $total_notice_count;
159
  }
160
  } else {
161
- $this->total_thread_count = (int) $max;
162
  }
163
 
164
- if ( $max ) {
165
  if ( $max >= count( $this->threads ) ) {
166
  $this->thread_count = count( $this->threads );
167
  } else {
168
- $this->thread_count = (int) $max;
169
  }
170
  } else {
171
  $this->thread_count = count( $this->threads );
@@ -174,7 +205,7 @@ class BP_Messages_Box_Template {
174
 
175
  if ( (int) $this->total_thread_count && (int) $this->pag_num ) {
176
  $pag_args = array(
177
- $page_arg => '%#%',
178
  );
179
 
180
  if ( defined( 'DOING_AJAX' ) && true === (bool) DOING_AJAX ) {
@@ -183,8 +214,10 @@ class BP_Messages_Box_Template {
183
  $base = '';
184
  }
185
 
 
 
186
  if ( ! empty( $this->search_terms ) ) {
187
- $pag_args['s'] = $this->search_terms;
188
  }
189
 
190
  $this->pag_links = paginate_links( array(
@@ -194,7 +227,8 @@ class BP_Messages_Box_Template {
194
  'current' => $this->pag_page,
195
  'prev_text' => _x( '&larr;', 'Message pagination previous text', 'buddypress' ),
196
  'next_text' => _x( '&rarr;', 'Message pagination next text', 'buddypress' ),
197
- 'mid_size' => 1
 
198
  ) );
199
  }
200
  }
@@ -251,7 +285,13 @@ class BP_Messages_Box_Template {
251
  if ( $this->current_thread + 1 < $this->thread_count ) {
252
  return true;
253
  } elseif ( $this->current_thread + 1 == $this->thread_count ) {
254
- do_action('messages_box_loop_end');
 
 
 
 
 
 
255
  // Do some cleaning up after the loop
256
  $this->rewind_threads();
257
  }
@@ -307,6 +347,12 @@ class BP_Messages_Box_Template {
307
 
308
  // loop has just started
309
  if ( 0 == $this->current_thread ) {
 
 
 
 
 
 
310
  do_action( 'messages_box_loop_start' );
311
  }
312
  }
@@ -335,6 +381,8 @@ class BP_Messages_Box_Template {
335
  * the value of $_REQUEST['s'].
336
  * @type string $page_arg URL argument used for the pagination param.
337
  * Default: 'mpage'.
 
 
338
  * }
339
  * @return bool True if there are threads to display, otherwise false.
340
  */
@@ -359,6 +407,7 @@ function bp_has_message_threads( $args = '' ) {
359
  'type' => 'all',
360
  'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '',
361
  'page_arg' => 'mpage', // See https://buddypress.trac.wordpress.org/ticket/3679
 
362
  ), 'has_message_threads' );
363
 
364
  // If trying to access notices without capabilities, redirect to root domain
@@ -367,16 +416,17 @@ function bp_has_message_threads( $args = '' ) {
367
  }
368
 
369
  // Load the messages loop global up with messages
370
- $messages_template = new BP_Messages_Box_Template(
371
- $r['user_id'],
372
- $r['box'],
373
- $r['per_page'],
374
- $r['max'],
375
- $r['type'],
376
- $r['search_terms'],
377
- $r['page_arg']
378
- );
379
 
 
 
 
 
 
 
 
 
 
380
  return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), $messages_template, $r );
381
  }
382
 
@@ -414,6 +464,13 @@ function bp_message_thread_id() {
414
  function bp_get_message_thread_id() {
415
  global $messages_template;
416
 
 
 
 
 
 
 
 
417
  return apply_filters( 'bp_get_message_thread_id', $messages_template->thread->thread_id );
418
  }
419
 
@@ -431,6 +488,13 @@ function bp_message_thread_subject() {
431
  function bp_get_message_thread_subject() {
432
  global $messages_template;
433
 
 
 
 
 
 
 
 
434
  return apply_filters( 'bp_get_message_thread_subject', stripslashes_deep( $messages_template->thread->last_message_subject ) );
435
  }
436
 
@@ -448,6 +512,13 @@ function bp_message_thread_excerpt() {
448
  function bp_get_message_thread_excerpt() {
449
  global $messages_template;
450
 
 
 
 
 
 
 
 
451
  return apply_filters( 'bp_get_message_thread_excerpt', strip_tags( bp_create_excerpt( $messages_template->thread->last_message_content, 75 ) ) );
452
  }
453
 
@@ -480,6 +551,13 @@ function bp_message_thread_content() {
480
  function bp_get_message_thread_content() {
481
  global $messages_template;
482
 
 
 
 
 
 
 
 
483
  return apply_filters( 'bp_get_message_thread_content', $messages_template->thread->last_message_content );
484
  }
485
 
@@ -497,6 +575,13 @@ function bp_message_thread_from() {
497
  function bp_get_message_thread_from() {
498
  global $messages_template;
499
 
 
 
 
 
 
 
 
500
  return apply_filters( 'bp_get_message_thread_from', bp_core_get_userlink( $messages_template->thread->last_sender_id ) );
501
  }
502
 
@@ -513,6 +598,14 @@ function bp_message_thread_to() {
513
  */
514
  function bp_get_message_thread_to() {
515
  global $messages_template;
 
 
 
 
 
 
 
 
516
  return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients ) );
517
  }
518
 
@@ -541,6 +634,13 @@ function bp_message_thread_view_link( $thread_id = 0 ) {
541
  $thread_id = $messages_template->thread->thread_id;
542
  }
543
 
 
 
 
 
 
 
 
544
  return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ) );
545
  }
546
 
@@ -557,9 +657,112 @@ function bp_message_thread_delete_link() {
557
  */
558
  function bp_get_message_thread_delete_link() {
559
  global $messages_template;
 
 
 
 
 
 
 
 
 
560
  return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) );
561
  }
562
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563
  /**
564
  * Output the CSS class for the current thread.
565
  */
@@ -580,6 +783,13 @@ function bp_message_css_class() {
580
  $class .= 'alt';
581
  }
582
 
 
 
 
 
 
 
 
583
  return apply_filters( 'bp_get_message_css_class', trim( $class ) );
584
  }
585
 
@@ -595,6 +805,13 @@ function bp_message_thread_has_unread() {
595
  ? true
596
  : false;
597
 
 
 
 
 
 
 
 
598
  return apply_filters( 'bp_message_thread_has_unread', $retval );
599
  }
600
 
@@ -616,9 +833,90 @@ function bp_message_thread_unread_count() {
616
  ? (int) $messages_template->thread->unread_count
617
  : false;
618
 
 
 
 
 
 
 
 
619
  return apply_filters( 'bp_get_message_thread_unread_count', $count );
620
  }
621
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
622
  /**
623
  * Output the unformatted date of the last post in the current thread.
624
  */
@@ -633,6 +931,13 @@ function bp_message_thread_last_post_date_raw() {
633
  function bp_get_message_thread_last_post_date_raw() {
634
  global $messages_template;
635
 
 
 
 
 
 
 
 
636
  return apply_filters( 'bp_get_message_thread_last_message_date', $messages_template->thread->last_message_date );
637
  }
638
 
@@ -648,6 +953,14 @@ function bp_message_thread_last_post_date() {
648
  * @return string
649
  */
650
  function bp_get_message_thread_last_post_date() {
 
 
 
 
 
 
 
 
651
  return apply_filters( 'bp_get_message_thread_last_post_date', bp_format_time( strtotime( bp_get_message_thread_last_post_date_raw() ) ) );
652
  }
653
 
@@ -695,6 +1008,13 @@ function bp_message_thread_avatar( $args = '' ) {
695
  'alt' => $alt
696
  ) );
697
 
 
 
 
 
 
 
 
698
  return apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array(
699
  'item_id' => $messages_template->thread->last_sender_id,
700
  'type' => $r['type'],
@@ -718,6 +1038,14 @@ function bp_total_unread_messages_count() {
718
  * @return int
719
  */
720
  function bp_get_total_unread_messages_count() {
 
 
 
 
 
 
 
 
721
  return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count() );
722
  }
723
 
@@ -734,6 +1062,14 @@ function bp_messages_pagination() {
734
  */
735
  function bp_get_messages_pagination() {
736
  global $messages_template;
 
 
 
 
 
 
 
 
737
  return apply_filters( 'bp_get_messages_pagination', $messages_template->pag_links );
738
  }
739
 
@@ -764,7 +1100,8 @@ function bp_message_search_form() {
764
  $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>
765
 
766
  <form action="" method="get" id="search-message-form">
767
- <label><input type="text" name="s" id="messages_search" <?php if ( $search_value === $default_search_value ) : ?>placeholder="<?php echo esc_html( $search_value ); ?>"<?php endif; ?> <?php if ( $search_value !== $default_search_value ) : ?>value="<?php echo esc_html( $search_value ); ?>"<?php endif; ?> /></label>
 
768
  <input type="submit" id="messages_search_submit" name="messages_search_submit" value="<?php esc_attr_e( 'Search', 'buddypress' ) ?>" />
769
  </form>
770
 
@@ -783,6 +1120,14 @@ function bp_messages_form_action() {
783
  * @return string The form action
784
  */
785
  function bp_get_messages_form_action() {
 
 
 
 
 
 
 
 
786
  return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) );
787
  }
788
 
@@ -799,8 +1144,20 @@ function bp_messages_username_value() {
799
  */
800
  function bp_get_messages_username_value() {
801
  if ( isset( $_COOKIE['bp_messages_send_to'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
802
  return apply_filters( 'bp_get_messages_username_value', $_COOKIE['bp_messages_send_to'] );
803
- } else if ( isset( $_GET['r'] ) && !isset( $_COOKIE['bp_messages_send_to'] ) ) {
 
804
  return apply_filters( 'bp_get_messages_username_value', $_GET['r'] );
805
  }
806
  }
@@ -824,6 +1181,13 @@ function bp_messages_subject_value() {
824
  ? $_POST['subject']
825
  : '';
826
 
 
 
 
 
 
 
 
827
  return apply_filters( 'bp_get_messages_subject_value', $subject );
828
  }
829
 
@@ -847,6 +1211,13 @@ function bp_messages_content_value() {
847
  ? $_POST['content']
848
  : '';
849
 
 
 
 
 
 
 
 
850
  return apply_filters( 'bp_get_messages_content_value', $content );
851
  }
852
 
@@ -856,16 +1227,18 @@ function bp_messages_content_value() {
856
  function bp_messages_options() {
857
  ?>
858
 
859
- <?php _e( 'Select:', 'buddypress' ) ?>
 
 
860
 
861
  <select name="message-type-select" id="message-type-select">
862
- <option value=""></option>
863
  <option value="read"><?php _ex('Read', 'Message dropdown filter', 'buddypress') ?></option>
864
  <option value="unread"><?php _ex('Unread', 'Message dropdown filter', 'buddypress') ?></option>
865
  <option value="all"><?php _ex('All', 'Message dropdown filter', 'buddypress') ?></option>
866
  </select> &nbsp;
867
 
868
- <?php if ( ! bp_is_current_action( 'sentbox' ) && bp_is_current_action( 'notices' ) ) : ?>
869
 
870
  <a href="#" id="mark_as_read"><?php _ex('Mark as Read', 'Message management markup', 'buddypress') ?></a> &nbsp;
871
  <a href="#" id="mark_as_unread"><?php _ex('Mark as Unread', 'Message management markup', 'buddypress') ?></a> &nbsp;
@@ -877,6 +1250,24 @@ function bp_messages_options() {
877
  <?php
878
  }
879
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
880
  /**
881
  * Return whether or not the notice is currently active.
882
  *
@@ -889,6 +1280,13 @@ function bp_messages_is_active_notice() {
889
  ? true
890
  : false;
891
 
 
 
 
 
 
 
 
892
  return apply_filters( 'bp_messages_is_active_notice', $retval );
893
  }
894
 
@@ -936,6 +1334,14 @@ function bp_message_notice_id() {
936
  */
937
  function bp_get_message_notice_id() {
938
  global $messages_template;
 
 
 
 
 
 
 
 
939
  return apply_filters( 'bp_get_message_notice_id', $messages_template->thread->id );
940
  }
941
 
@@ -952,6 +1358,14 @@ function bp_message_notice_post_date() {
952
  */
953
  function bp_get_message_notice_post_date() {
954
  global $messages_template;
 
 
 
 
 
 
 
 
955
  return apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime( $messages_template->thread->date_sent ) ) );
956
  }
957
 
@@ -968,6 +1382,14 @@ function bp_message_notice_subject() {
968
  */
969
  function bp_get_message_notice_subject() {
970
  global $messages_template;
 
 
 
 
 
 
 
 
971
  return apply_filters( 'bp_get_message_notice_subject', $messages_template->thread->subject );
972
  }
973
 
@@ -984,6 +1406,14 @@ function bp_message_notice_text() {
984
  */
985
  function bp_get_message_notice_text() {
986
  global $messages_template;
 
 
 
 
 
 
 
 
987
  return apply_filters( 'bp_get_message_notice_text', $messages_template->thread->message );
988
  }
989
 
@@ -1001,6 +1431,14 @@ function bp_message_notice_delete_link() {
1001
  function bp_get_message_notice_delete_link() {
1002
  global $messages_template;
1003
 
 
 
 
 
 
 
 
 
1004
  return apply_filters( 'bp_get_message_notice_delete_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/delete/' . $messages_template->thread->id, 'messages_delete_thread' ) );
1005
  }
1006
 
@@ -1023,6 +1461,14 @@ function bp_message_activate_deactivate_link() {
1023
  } else {
1024
  $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' );
1025
  }
 
 
 
 
 
 
 
 
1026
  return apply_filters( 'bp_get_message_activate_deactivate_link', $link );
1027
  }
1028
 
@@ -1033,7 +1479,7 @@ function bp_message_activate_deactivate_text() {
1033
  echo bp_get_message_activate_deactivate_text();
1034
  }
1035
  /**
1036
- * Generate the text ('Deactivate' or 'Activate' for the notice action link.
1037
  *
1038
  * @return string
1039
  */
@@ -1045,6 +1491,14 @@ function bp_message_activate_deactivate_text() {
1045
  } else {
1046
  $text = __('Activate', 'buddypress');
1047
  }
 
 
 
 
 
 
 
 
1048
  return apply_filters( 'bp_message_activate_deactivate_text', $text );
1049
  }
1050
 
@@ -1066,6 +1520,14 @@ function bp_messages_slug() {
1066
  * @return string
1067
  */
1068
  function bp_get_messages_slug() {
 
 
 
 
 
 
 
 
1069
  return apply_filters( 'bp_get_messages_slug', buddypress()->messages->slug );
1070
  }
1071
 
@@ -1117,6 +1579,13 @@ function bp_send_private_message_link() {
1117
  return false;
1118
  }
1119
 
 
 
 
 
 
 
 
1120
  return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() ) ) );
1121
  }
1122
 
@@ -1148,6 +1617,14 @@ function bp_send_message_button() {
1148
  // Note: 'bp_get_send_message_button' is a legacy filter. Use
1149
  // 'bp_get_send_message_button_args' instead. See #4536
1150
  return apply_filters( 'bp_get_send_message_button',
 
 
 
 
 
 
 
 
1151
  bp_get_button( apply_filters( 'bp_get_send_message_button_args', array(
1152
  'id' => 'private_message',
1153
  'component' => 'messages',
@@ -1174,6 +1651,14 @@ function bp_message_loading_image_src() {
1174
  * @return string
1175
  */
1176
  function bp_get_message_loading_image_src() {
 
 
 
 
 
 
 
 
1177
  return apply_filters( 'bp_get_message_loading_image_src', buddypress()->messages->image_base . '/ajax-loader.gif' );
1178
  }
1179
 
@@ -1216,6 +1701,13 @@ function bp_message_get_recipient_usernames() {
1216
  function bp_get_message_get_recipient_usernames() {
1217
  $recipients = isset( $_GET['r'] ) ? stripslashes( $_GET['r'] ) : '';
1218
 
 
 
 
 
 
 
 
1219
  return apply_filters( 'bp_get_message_get_recipient_usernames', $recipients );
1220
  }
1221
 
@@ -1300,11 +1792,10 @@ class BP_Messages_Thread_Template {
1300
  /**
1301
  * Constructor method.
1302
  *
1303
- * @param int $thread_id ID of the message thread.
1304
- * @param string $order 'ASC' or 'DESC'.
1305
  */
1306
- public function __construct( $thread_id, $order ) {
1307
- $this->thread = new BP_Messages_Thread( $thread_id, $order );
1308
  $this->message_count = count( $this->thread->messages );
1309
 
1310
  $last_message_index = $this->message_count - 1;
@@ -1367,6 +1858,12 @@ class BP_Messages_Thread_Template {
1367
  if ( ( $this->current_message + 1 ) < $this->message_count ) {
1368
  return true;
1369
  } elseif ( ( $this->current_message + 1 ) === $this->message_count ) {
 
 
 
 
 
 
1370
  do_action( 'thread_loop_end' );
1371
  // Do some cleaning up after the loop
1372
  $this->rewind_messages();
@@ -1391,6 +1888,12 @@ class BP_Messages_Thread_Template {
1391
 
1392
  // loop has just started
1393
  if ( 0 === $this->current_message ) {
 
 
 
 
 
 
1394
  do_action( 'thread_loop_start' );
1395
  }
1396
  }
@@ -1405,6 +1908,8 @@ class BP_Messages_Thread_Template {
1405
  * Default: if viewing a thread, the thread ID will be parsed from
1406
  * the URL (bp_action_variable( 0 )).
1407
  * @type string $order 'ASC' or 'DESC'. Default: 'ASC'.
 
 
1408
  * }
1409
  * @return bool True if there are messages to display, otherwise false.
1410
  */
@@ -1412,15 +1917,20 @@ function bp_thread_has_messages( $args = '' ) {
1412
  global $thread_template;
1413
 
1414
  $r = bp_parse_args( $args, array(
1415
- 'thread_id' => false,
1416
- 'order' => 'ASC'
 
1417
  ), 'thread_has_messages' );
1418
 
1419
  if ( empty( $r['thread_id'] ) && bp_is_messages_component() && bp_is_current_action( 'view' ) ) {
1420
  $r['thread_id'] = (int) bp_action_variable( 0 );
1421
  }
1422
 
1423
- $thread_template = new BP_Messages_Thread_Template( $r['thread_id'], $r['order'] );
 
 
 
 
1424
 
1425
  return $thread_template->has_messages();
1426
  }
@@ -1477,6 +1987,13 @@ function bp_the_thread_id() {
1477
  function bp_get_the_thread_id() {
1478
  global $thread_template;
1479
 
 
 
 
 
 
 
 
1480
  return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id );
1481
  }
1482
 
@@ -1494,29 +2011,67 @@ function bp_the_thread_subject() {
1494
  function bp_get_the_thread_subject() {
1495
  global $thread_template;
1496
 
 
 
 
 
 
 
 
1497
  return apply_filters( 'bp_get_the_thread_subject', $thread_template->thread->last_message_subject );
1498
  }
1499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1500
  /**
1501
  * Output HTML links to recipients in the current thread.
 
 
1502
  */
1503
- function bp_the_thread_recipients() {
1504
- echo bp_get_the_thread_recipients();
1505
  }
1506
  /**
1507
  * Generate HTML links to the profiles of recipients in the current thread.
1508
  *
 
 
1509
  * @return string
1510
  */
1511
- function bp_get_the_thread_recipients() {
1512
  global $thread_template;
1513
 
1514
  $recipient_links = array();
1515
 
1516
- if ( count( $thread_template->thread->recipients ) >= 5 ) {
1517
- return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count( $thread_template->thread->recipients ) ) );
1518
- }
1519
-
1520
  foreach( (array) $thread_template->thread->recipients as $recipient ) {
1521
  if ( (int) $recipient->user_id !== bp_loggedin_user_id() ) {
1522
  $recipient_link = bp_core_get_userlink( $recipient->user_id );
@@ -1529,7 +2084,14 @@ function bp_the_thread_recipients() {
1529
  }
1530
  }
1531
 
1532
- return apply_filters( 'bp_get_the_thread_recipients', implode( ', ', $recipient_links ) );
 
 
 
 
 
 
 
1533
  }
1534
 
1535
  /**
@@ -1554,6 +2116,13 @@ function bp_the_thread_message_id() {
1554
  ? (int) $thread_template->message->id
1555
  : null;
1556
 
 
 
 
 
 
 
 
1557
  return apply_filters( 'bp_get_the_thread_message_id', $thread_message_id );
1558
  }
1559
 
@@ -1588,6 +2157,13 @@ function bp_the_thread_message_css_class() {
1588
  $classes[] = 'sent-by-me';
1589
  }
1590
 
 
 
 
 
 
 
 
1591
  $classes = apply_filters( 'bp_get_the_thread_message_css_class', $classes );
1592
 
1593
  return implode( ' ', $classes );
@@ -1613,6 +2189,13 @@ function bp_the_thread_message_alt_class() {
1613
  $class = 'odd';
1614
  }
1615
 
 
 
 
 
 
 
 
1616
  return apply_filters( 'bp_get_the_thread_message_alt_class', $class );
1617
  }
1618
 
@@ -1638,6 +2221,13 @@ function bp_the_thread_message_sender_id() {
1638
  ? $thread_template->message->sender_id
1639
  : 0;
1640
 
 
 
 
 
 
 
 
1641
  return (int) apply_filters( 'bp_get_the_thread_message_css_class', (int) $user_id );
1642
  }
1643
 
@@ -1671,6 +2261,13 @@ function bp_the_thread_message_sender_avatar( $args = '' ) {
1671
  'height' => false,
1672
  ) );
1673
 
 
 
 
 
 
 
 
1674
  return apply_filters( 'bp_get_the_thread_message_sender_avatar_thumb', bp_core_fetch_avatar( array(
1675
  'item_id' => $thread_template->message->sender_id,
1676
  'type' => $r['type'],
@@ -1694,6 +2291,13 @@ function bp_the_thread_message_sender_link() {
1694
  function bp_get_the_thread_message_sender_link() {
1695
  global $thread_template;
1696
 
 
 
 
 
 
 
 
1697
  return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) );
1698
  }
1699
 
@@ -1717,6 +2321,13 @@ function bp_the_thread_message_sender_name() {
1717
  $display_name = __( 'Deleted User', 'buddypress' );
1718
  }
1719
 
 
 
 
 
 
 
 
1720
  return apply_filters( 'bp_get_the_thread_message_sender_name', $display_name );
1721
  }
1722
 
@@ -1732,6 +2343,15 @@ function bp_the_thread_delete_link() {
1732
  * @return string URL
1733
  */
1734
  function bp_get_the_thread_delete_link() {
 
 
 
 
 
 
 
 
 
1735
  return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread' ) );
1736
  }
1737
 
@@ -1747,6 +2367,14 @@ function bp_the_thread_message_time_since() {
1747
  * @return string
1748
  */
1749
  function bp_get_the_thread_message_time_since() {
 
 
 
 
 
 
 
 
1750
  return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s', 'buddypress' ), bp_core_time_since( bp_get_the_thread_message_date_sent() ) ) );
1751
  }
1752
 
@@ -1769,6 +2397,13 @@ function bp_the_thread_message_date_sent() {
1769
  function bp_get_the_thread_message_date_sent() {
1770
  global $thread_template;
1771
 
 
 
 
 
 
 
 
1772
  return apply_filters( 'bp_get_the_thread_message_date_sent', strtotime( $thread_template->message->date_sent ) );
1773
  }
1774
 
@@ -1786,6 +2421,13 @@ function bp_the_thread_message_content() {
1786
  function bp_get_the_thread_message_content() {
1787
  global $thread_template;
1788
 
 
 
 
 
 
 
 
1789
  return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );
1790
  }
1791
 
@@ -1794,15 +2436,47 @@ function bp_the_thread_message_content() {
1794
  /**
1795
  * Enable oEmbed support for Messages.
1796
  *
1797
- * There's no caching as BP 1.5 does not have a Messages meta API.
1798
- *
1799
  * @since BuddyPress (1.5.0)
1800
  *
1801
  * @see BP_Embed
1802
- *
1803
- * @todo Add Messages meta?
1804
  */
1805
  function bp_messages_embed() {
1806
- add_filter( 'embed_post_id', 'bp_get_message_thread_id' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1807
  }
1808
- add_action( 'messages_box_loop_start', 'bp_messages_embed' );
114
  /**
115
  * Constructor method.
116
  *
117
+ * @param array $args {
118
+ * Array of arguments. See bp_has_message_threads() for full description.
119
+ * }
120
+ */
121
+ public function __construct( $args = array() ) {
122
+ global $wpdb, $bp;
123
+
124
+ // Backward compatibility with old method of passing arguments
125
+ if ( ! is_array( $args ) || func_num_args() > 1 ) {
126
+ _deprecated_argument( __METHOD__, '2.2.0', 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__ ) );
127
+
128
+ $old_args_keys = array(
129
+ 0 => 'user_id',
130
+ 1 => 'box',
131
+ 2 => 'per_page',
132
+ 3 => 'max',
133
+ 4 => 'type',
134
+ 5 => 'search_terms',
135
+ 6 => 'page_arg'
136
+ );
137
+
138
+ $func_args = func_get_args();
139
+ $args = bp_core_parse_args_array( $old_args_keys, $func_args );
140
+ }
141
+
142
+ $r = wp_parse_args( $args, array(
143
+ 'user_id' => bp_loggedin_user_id(),
144
+ 'box' => 'inbox',
145
+ 'per_page' => 10,
146
+ 'max' => false,
147
+ 'type' => 'all',
148
+ 'search_terms' => '',
149
+ 'page_arg' => 'mpage',
150
+ 'meta_query' => array(),
151
+ ) );
152
+
153
+ $this->pag_page = isset( $_GET[ $r['page_arg'] ] ) ? intval( $_GET[ $r['page_arg'] ] ) : 1;
154
+ $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $r['per_page'];
155
+
156
+ $this->user_id = $r['user_id'];
157
+ $this->box = $r['box'];
158
+ $this->type = $r['type'];
159
+ $this->search_terms = $r['search_terms'];
160
 
161
  if ( 'notices' == $this->box ) {
162
  $this->threads = BP_Messages_Notice::get_notices( array(
164
  'pag_page' => $this->pag_page
165
  ) );
166
  } else {
167
+ $threads = BP_Messages_Thread::get_current_threads_for_user( array(
168
+ 'user_id' => $this->user_id,
169
+ 'box' => $this->box,
170
+ 'type' => $this->type,
171
+ 'limit' => $this->pag_num,
172
+ 'page' => $this->pag_page,
173
+ 'search_terms' => $this->search_terms,
174
+ 'meta_query' => $r['meta_query'],
175
+ ) );
176
 
177
  $this->threads = $threads['threads'];
178
  $this->total_thread_count = $threads['total'];
184
  } else {
185
  $total_notice_count = BP_Messages_Notice::get_total_notice_count();
186
 
187
+ if ( ! $r['max'] || $r['max'] >= (int) $total_notice_count ) {
188
  if ( 'notices' == $this->box ) {
189
  $this->total_thread_count = (int) $total_notice_count;
190
  }
191
  } else {
192
+ $this->total_thread_count = (int) $r['max'];
193
  }
194
 
195
+ if ( $r['max'] ) {
196
  if ( $max >= count( $this->threads ) ) {
197
  $this->thread_count = count( $this->threads );
198
  } else {
199
+ $this->thread_count = (int) $r['max'];
200
  }
201
  } else {
202
  $this->thread_count = count( $this->threads );
205
 
206
  if ( (int) $this->total_thread_count && (int) $this->pag_num ) {
207
  $pag_args = array(
208
+ $r['page_arg'] => '%#%',
209
  );
210
 
211
  if ( defined( 'DOING_AJAX' ) && true === (bool) DOING_AJAX ) {
214
  $base = '';
215
  }
216
 
217
+ $add_args = array();
218
+
219
  if ( ! empty( $this->search_terms ) ) {
220
+ $add_args['s'] = $this->search_terms;
221
  }
222
 
223
  $this->pag_links = paginate_links( array(
227
  'current' => $this->pag_page,
228
  'prev_text' => _x( '&larr;', 'Message pagination previous text', 'buddypress' ),
229
  'next_text' => _x( '&rarr;', 'Message pagination next text', 'buddypress' ),
230
+ 'mid_size' => 1,
231
+ 'add_args' => $add_args,
232
  ) );
233
  }
234
  }
285
  if ( $this->current_thread + 1 < $this->thread_count ) {
286
  return true;
287
  } elseif ( $this->current_thread + 1 == $this->thread_count ) {
288
+
289
+ /**
290
+ * Fires when at the end of threads to iterate over.
291
+ *
292
+ * @since BuddyPress (1.5.0)
293
+ */
294
+ do_action( 'messages_box_loop_end' );
295
  // Do some cleaning up after the loop
296
  $this->rewind_threads();
297
  }
347
 
348
  // loop has just started
349
  if ( 0 == $this->current_thread ) {
350
+
351
+ /**
352
+ * Fires if at the start of the message thread loop.
353
+ *
354
+ * @since BuddyPress (1.5.0)
355
+ */
356
  do_action( 'messages_box_loop_start' );
357
  }
358
  }
381
  * the value of $_REQUEST['s'].
382
  * @type string $page_arg URL argument used for the pagination param.
383
  * Default: 'mpage'.
384
+ * @type array $meta_query Meta query arguments. Only applicable if $box is
385
+ * not 'notices'. See WP_Meta_Query more details.
386
  * }
387
  * @return bool True if there are threads to display, otherwise false.
388
  */
407
  'type' => 'all',
408
  'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '',
409
  'page_arg' => 'mpage', // See https://buddypress.trac.wordpress.org/ticket/3679
410
+ 'meta_query' => array()
411
  ), 'has_message_threads' );
412
 
413
  // If trying to access notices without capabilities, redirect to root domain
416
  }
417
 
418
  // Load the messages loop global up with messages
419
+ $messages_template = new BP_Messages_Box_Template( $r );
 
 
 
 
 
 
 
 
420
 
421
+ /**
422
+ * Filters if there are any message threads to display in inbox/sentbox/notices.
423
+ *
424
+ * @since BuddyPress (1.1.0)
425
+ *
426
+ * @param bool $value Whether or not the message has threads.
427
+ * @param BP_Messages_Box_Template $messages_template Current message box template object.
428
+ * @param array $r Array of parsed arguments passed into function.
429
+ */
430
  return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), $messages_template, $r );
431
  }
432
 
464
  function bp_get_message_thread_id() {
465
  global $messages_template;
466
 
467
+ /**
468
+ * Filters the ID of the current thread in the loop.
469
+ *
470
+ * @since BuddyPress (1.0.0)
471
+ *
472
+ * @param int $thread_id ID of the current thread in the loop.
473
+ */
474
  return apply_filters( 'bp_get_message_thread_id', $messages_template->thread->thread_id );
475
  }
476
 
488
  function bp_get_message_thread_subject() {
489
  global $messages_template;
490
 
491
+ /**
492
+ * Filters the subject of the current thread in the loop.
493
+ *
494
+ * @since BuddyPress (1.1.0)
495
+ *
496
+ * @param string $value Subject of the current thread in the loop.
497
+ */
498
  return apply_filters( 'bp_get_message_thread_subject', stripslashes_deep( $messages_template->thread->last_message_subject ) );
499
  }
500
 
512
  function bp_get_message_thread_excerpt() {
513
  global $messages_template;
514
 
515
+ /**
516
+ * Filters the excerpt of the current thread in the loop.
517
+ *
518
+ * @since BuddyPress (1.0.0)
519
+ *
520
+ * @param string $value Excerpt of the current thread in the loop.
521
+ */
522
  return apply_filters( 'bp_get_message_thread_excerpt', strip_tags( bp_create_excerpt( $messages_template->thread->last_message_content, 75 ) ) );
523
  }
524
 
551
  function bp_get_message_thread_content() {
552
  global $messages_template;
553
 
554
+ /**
555
+ * Filters the content of the last message in the thread.
556
+ *
557
+ * @since BuddyPress (2.0.0)
558
+ *
559
+ * @param string $last_message_content Content of the last message in the thread.
560
+ */
561
  return apply_filters( 'bp_get_message_thread_content', $messages_template->thread->last_message_content );
562
  }
563
 
575
  function bp_get_message_thread_from() {
576
  global $messages_template;
577
 
578
+ /**
579
+ * Filters the link to the page of the current thread's last author.
580
+ *
581
+ * @since BuddyPress (1.0.0)
582
+ *
583
+ * @param string $value Link to the page of the current thread's last author.
584
+ */
585
  return apply_filters( 'bp_get_message_thread_from', bp_core_get_userlink( $messages_template->thread->last_sender_id ) );
586
  }
587
 
598
  */
599
  function bp_get_message_thread_to() {
600
  global $messages_template;
601
+
602
+ /**
603
+ * Filters the HTML links to the pages of the current thread's recipients.
604
+ *
605
+ * @since BuddyPress (1.0.0)
606
+ *
607
+ * @param string $value HTML links to the pages of the current thread's recipients.
608
+ */
609
  return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients ) );
610
  }
611
 
634
  $thread_id = $messages_template->thread->thread_id;
635
  }
636
 
637
+ /**
638
+ * Filters the permalink of a particular thread.
639
+ *
640
+ * @since BuddyPress (1.0.0)
641
+ *
642
+ * @param string $value permalink of a particular thread.
643
+ */
644
  return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ) );
645
  }
646
 
657
  */
658
  function bp_get_message_thread_delete_link() {
659
  global $messages_template;
660
+
661
+ /**
662
+ * Filters the URL for deleting the current thread.
663
+ *
664
+ * @since BuddyPress (1.0.0)
665
+ *
666
+ * @param string $value URL for deleting the current thread.
667
+ * @param string $value Text indicating action being executed.
668
+ */
669
  return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) );
670
  }
671
 
672
+ /**
673
+ * Output the URL used for marking a single message thread as unread.
674
+ *
675
+ * Since this function directly outputs a URL, it is escaped.
676
+ *
677
+ * @since BuddyPress (2.2.0)
678
+ */
679
+ function bp_the_message_thread_mark_unread_url() {
680
+ echo esc_url( bp_get_the_message_thread_mark_unread_url() );
681
+ }
682
+ /**
683
+ * Return the URL used for marking a single message thread as unread.
684
+ *
685
+ * @since BuddyPress (2.2.0)
686
+ *
687
+ * @return string
688
+ */
689
+ function bp_get_the_message_thread_mark_unread_url() {
690
+
691
+ // Get the message ID.
692
+ $id = bp_get_message_thread_id();
693
+
694
+ // Get the args to add to the URL.
695
+ $args = array(
696
+ 'action' => 'unread',
697
+ 'message_id' => $id
698
+ );
699
+
700
+ // Base unread URL.
701
+ $url = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );
702
+
703
+ // Add the args to the URL.
704
+ $url = add_query_arg( $args, $url );
705
+
706
+ // Add the nonce.
707
+ $url = wp_nonce_url( $url, 'bp_message_thread_mark_unread_' . $id );
708
+
709
+ /**
710
+ * Filters the URL used for marking a single message thread as unread.
711
+ *
712
+ * @since BuddyPress (2.2.0)
713
+ *
714
+ * @param string $url URL used for marking a single message thread as unread.
715
+ */
716
+ return apply_filters( 'bp_get_the_message_thread_mark_unread_url', $url );
717
+ }
718
+
719
+ /**
720
+ * Output the URL used for marking a single message thread as read.
721
+ *
722
+ * Since this function directly outputs a URL, it is escaped.
723
+ *
724
+ * @since BuddyPress (2.2.0)
725
+ */
726
+ function bp_the_message_thread_mark_read_url() {
727
+ echo esc_url( bp_get_the_message_thread_mark_read_url() );
728
+ }
729
+ /**
730
+ * Return the URL used for marking a single message thread as read
731
+ *
732
+ * @since BuddyPress (2.2.0)
733
+ *
734
+ * @return string
735
+ */
736
+ function bp_get_the_message_thread_mark_read_url() {
737
+
738
+ // Get the message ID.
739
+ $id = bp_get_message_thread_id();
740
+
741
+ // Get the args to add to the URL.
742
+ $args = array(
743
+ 'action' => 'read',
744
+ 'message_id' => $id
745
+ );
746
+
747
+ // Base read URL.
748
+ $url = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );
749
+
750
+ // Add the args to the URL.
751
+ $url = add_query_arg( $args, $url );
752
+
753
+ // Add the nonce.
754
+ $url = wp_nonce_url( $url, 'bp_message_thread_mark_read_' . $id );
755
+
756
+ /**
757
+ * Filters the URL used for marking a single message thread as read.
758
+ *
759
+ * @since BuddyPress (2.2.0)
760
+ *
761
+ * @param string $url URL used for marking a single message thread as read.
762
+ */
763
+ return apply_filters( 'bp_get_the_message_thread_mark_read_url', $url );
764
+ }
765
+
766
  /**
767
  * Output the CSS class for the current thread.
768
  */
783
  $class .= 'alt';
784
  }
785
 
786
+ /**
787
+ * Filters the CSS class for the current thread.
788
+ *
789
+ * @since BuddyPress (1.2.10)
790
+ *
791
+ * @param string $class Class string to be added to the list of classes.
792
+ */
793
  return apply_filters( 'bp_get_message_css_class', trim( $class ) );
794
  }
795
 
805
  ? true
806
  : false;
807
 
808
+ /**
809
+ * Filters whether or not a message thread has unread items.
810
+ *
811
+ * @since BuddyPress (2.1.0)
812
+ *
813
+ * @param bool $retval Whether or not a message thread has unread items.
814
+ */
815
  return apply_filters( 'bp_message_thread_has_unread', $retval );
816
  }
817
 
833
  ? (int) $messages_template->thread->unread_count
834
  : false;
835
 
836
+ /**
837
+ * Filters the current thread's unread count.
838
+ *
839
+ * @since BuddyPress (1.0.0)
840
+ *
841
+ * @param int $count Current thread unread count.
842
+ */
843
  return apply_filters( 'bp_get_message_thread_unread_count', $count );
844
  }
845
 
846
+ /**
847
+ * Output a thread's total message count.
848
+ *
849
+ * @since BuddyPress (2.2.0)
850
+ *
851
+ * @param int $thread_id Optional. ID of the thread. Defaults to current thread ID.
852
+ */
853
+ function bp_message_thread_total_count( $thread_id = false ) {
854
+ echo bp_get_message_thread_total_count( $thread_id );
855
+ }
856
+ /**
857
+ * Get the current thread's total message count.
858
+ *
859
+ * @since BuddyPress (2.2.0)
860
+ *
861
+ * @param int $thread_id Optional. ID of the thread. Defaults to
862
+ * current thread ID.
863
+ * @return int
864
+ */
865
+ function bp_get_message_thread_total_count( $thread_id = false ) {
866
+ if ( false === $thread_id ) {
867
+ $thread_id = bp_get_message_thread_id();
868
+ }
869
+
870
+ $thread_template = new BP_Messages_Thread_Template( $thread_id, 'ASC', array(
871
+ 'update_meta_cache' => false
872
+ ) );
873
+
874
+ $count = 0;
875
+ if ( ! empty( $thread_template->message_count ) ) {
876
+ $count = intval( $thread_template->message_count );
877
+ }
878
+
879
+ /**
880
+ * Filters the current thread's total message count.
881
+ *
882
+ * @since BuddyPress (2.2.0)
883
+ *
884
+ * @param int $count Current thread total message count.
885
+ */
886
+ return apply_filters( 'bp_get_message_thread_total_count', $count );
887
+ }
888
+
889
+ /**
890
+ * Output markup for the current thread's total and unread count.
891
+ *
892
+ * @since Buddypress (2.2.0)
893
+ *
894
+ * @param int $thread_id Optional. ID of the thread. Default: current thread ID.
895
+ */
896
+ function bp_message_thread_total_and_unread_count( $thread_id = false ) {
897
+ echo bp_get_message_thread_total_and_unread_count( $thread_id );
898
+ }
899
+ /**
900
+ * Get markup for the current thread's total and unread count.
901
+ *
902
+ * @param int $thread_id Optional. ID of the thread. Default: current thread ID.
903
+ * @return string Markup displaying the total and unread count for the thread.
904
+ */
905
+ function bp_get_message_thread_total_and_unread_count( $thread_id = false ) {
906
+ if ( false === $thread_id ) {
907
+ $thread_id = bp_get_message_thread_id();
908
+ }
909
+
910
+ $total = bp_get_message_thread_total_count( $thread_id );
911
+ $unread = bp_get_message_thread_unread_count( $thread_id );
912
+
913
+ return sprintf(
914
+ '<span class="thread-count">(%1$s)</span> <span class="bp-screen-reader-text">%2$s</span>',
915
+ number_format_i18n( $total ),
916
+ sprintf( _n( '%d unread', '%d unread', $unread, 'buddypress' ), number_format_i18n( $unread ) )
917
+ );
918
+ }
919
+
920
  /**
921
  * Output the unformatted date of the last post in the current thread.
922
  */
931
  function bp_get_message_thread_last_post_date_raw() {
932
  global $messages_template;
933
 
934
+ /**
935
+ * Filters the unformatted date of the last post in the current thread.
936
+ *
937
+ * @since BuddyPress (2.1.0)
938
+ *
939
+ * @param string $last_message_date Unformatted date of the last post in the current thread.
940
+ */
941
  return apply_filters( 'bp_get_message_thread_last_message_date', $messages_template->thread->last_message_date );
942
  }
943
 
953
  * @return string
954
  */
955
  function bp_get_message_thread_last_post_date() {
956
+
957
+ /**
958
+ * Filters the nicely formatted date of the last post in the current thread.
959
+ *
960
+ * @since BuddyPress (2.1.0)
961
+ *
962
+ * @param string $value Formatted date of the last post in the current thread.
963
+ */
964
  return apply_filters( 'bp_get_message_thread_last_post_date', bp_format_time( strtotime( bp_get_message_thread_last_post_date_raw() ) ) );
965
  }
966
 
1008
  'alt' => $alt
1009
  ) );
1010
 
1011
+ /**
1012
+ * Filters the avatar for the last sender in the current message thread.
1013
+ *
1014
+ * @since BuddyPress (1.0.0)
1015
+ *
1016
+ * @param string $value User avatar string.
1017
+ */
1018
  return apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array(
1019
  'item_id' => $messages_template->thread->last_sender_id,
1020
  'type' => $r['type'],
1038
  * @return int
1039
  */
1040
  function bp_get_total_unread_messages_count() {
1041
+
1042
+ /**
1043
+ * Filters the unread messages count for the current inbox.
1044
+ *
1045
+ * @since BuddyPress (1.0.0)
1046
+ *
1047
+ * @param int $value Unread messages count for the current inbox.
1048
+ */
1049
  return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count() );
1050
  }
1051
 
1062
  */
1063
  function bp_get_messages_pagination() {
1064
  global $messages_template;
1065
+
1066
+ /**
1067
+ * Filters the pagination HTML for the current thread loop.
1068
+ *
1069
+ * @since BuddyPress (1.0.0)
1070
+ *
1071
+ * @param int $pag_links Pagination HTML for the current thread loop.
1072
+ */
1073
  return apply_filters( 'bp_get_messages_pagination', $messages_template->pag_links );
1074
  }
1075
 
1100
  $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>
1101
 
1102
  <form action="" method="get" id="search-message-form">
1103
+ <label for="messages_search" class="bp-screen-reader-text"><?php _e( 'Search Messages', 'buddypress' ); ?></label>
1104
+ <input type="text" name="s" id="messages_search" <?php if ( $search_value === $default_search_value ) : ?>placeholder="<?php echo esc_html( $search_value ); ?>"<?php endif; ?> <?php if ( $search_value !== $default_search_value ) : ?>value="<?php echo esc_html( $search_value ); ?>"<?php endif; ?> />
1105
  <input type="submit" id="messages_search_submit" name="messages_search_submit" value="<?php esc_attr_e( 'Search', 'buddypress' ) ?>" />
1106
  </form>
1107
 
1120
  * @return string The form action
1121
  */
1122
  function bp_get_messages_form_action() {
1123
+
1124
+ /**
1125
+ * Filters the form action for Messages HTML forms.
1126
+ *
1127
+ * @since BuddyPress (1.0.0)
1128
+ *
1129
+ * @param string The form action.
1130
+ */
1131
  return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) );
1132
  }
1133
 
1144
  */
1145
  function bp_get_messages_username_value() {
1146
  if ( isset( $_COOKIE['bp_messages_send_to'] ) ) {
1147
+
1148
+ /**
1149
+ * Filters the default username for the recipient box.
1150
+ *
1151
+ * Value passed into filter is dependent on if the 'bp_messages_send_to'
1152
+ * cookie or 'r' $_GET parameter is set.
1153
+ *
1154
+ * @since BuddyPress (1.0.0)
1155
+ *
1156
+ * @param string $value Default user name.
1157
+ */
1158
  return apply_filters( 'bp_get_messages_username_value', $_COOKIE['bp_messages_send_to'] );
1159
+ } elseif ( isset( $_GET['r'] ) && !isset( $_COOKIE['bp_messages_send_to'] ) ) {
1160
+ /** This filter is documented in bp-messages-template.php */
1161
  return apply_filters( 'bp_get_messages_username_value', $_GET['r'] );
1162
  }
1163
  }
1181
  ? $_POST['subject']
1182
  : '';
1183
 
1184
+ /**
1185
+ * Filters the default value for the subject field.
1186
+ *
1187
+ * @since BuddyPress (1.0.0)
1188
+ *
1189
+ * @param string $subject The default value for the subject field.
1190
+ */
1191
  return apply_filters( 'bp_get_messages_subject_value', $subject );
1192
  }
1193
 
1211
  ? $_POST['content']
1212
  : '';
1213
 
1214
+ /**
1215
+ * Filters the default value for the content field.
1216
+ *
1217
+ * @since BuddyPress (1.0.0)
1218
+ *
1219
+ * @param string $content The default value for the content field.
1220
+ */
1221
  return apply_filters( 'bp_get_messages_content_value', $content );
1222
  }
1223
 
1227
  function bp_messages_options() {
1228
  ?>
1229
 
1230
+ <label for="message-type-select" class="bp-screen-reader-text">
1231
+ <?php _e( 'Select:', 'buddypress' ) ?>
1232
+ </label>
1233
 
1234
  <select name="message-type-select" id="message-type-select">
1235
+ <option value=""><?php _e( 'Select', 'buddypress' ); ?></option>
1236
  <option value="read"><?php _ex('Read', 'Message dropdown filter', 'buddypress') ?></option>
1237
  <option value="unread"><?php _ex('Unread', 'Message dropdown filter', 'buddypress') ?></option>
1238
  <option value="all"><?php _ex('All', 'Message dropdown filter', 'buddypress') ?></option>
1239
  </select> &nbsp;
1240
 
1241
+ <?php if ( ! bp_is_current_action( 'sentbox' ) && ! bp_is_current_action( 'notices' ) ) : ?>
1242
 
1243
  <a href="#" id="mark_as_read"><?php _ex('Mark as Read', 'Message management markup', 'buddypress') ?></a> &nbsp;
1244
  <a href="#" id="mark_as_unread"><?php _ex('Mark as Unread', 'Message management markup', 'buddypress') ?></a> &nbsp;
1250
  <?php
1251
  }
1252
 
1253
+ /**
1254
+ * Output the dropdown for bulk management of messages.
1255
+ *
1256
+ * @since BuddyPress (2.2.0)
1257
+ */
1258
+ function bp_messages_bulk_management_dropdown() {
1259
+ ?>
1260
+ <label class="bp-screen-reader-text" for="messages-select"><?php _e( 'Select Bulk Action', 'buddypress' ); ?></label>
1261
+ <select name="messages_bulk_action" id="messages-select">
1262
+ <option value="" selected="selected"><?php _e( 'Bulk Actions', 'buddypress' ); ?></option>
1263
+ <option value="read"><?php _e( 'Mark read', 'buddypress' ); ?></option>
1264
+ <option value="unread"><?php _e( 'Mark unread', 'buddypress' ); ?></option>
1265
+ <option value="delete"><?php _e( 'Delete', 'buddypress' ); ?></option>
1266
+ </select>
1267
+ <input type="submit" id="messages-bulk-manage" class="button action" value="<?php esc_attr_e( 'Apply', 'buddypress' ); ?>">
1268
+ <?php
1269
+ }
1270
+
1271
  /**
1272
  * Return whether or not the notice is currently active.
1273
  *
1280
  ? true
1281
  : false;
1282
 
1283
+ /**
1284
+ * Filters whether or not the notice is currently active.
1285
+ *
1286
+ * @since BuddyPress (2.1.0)
1287
+ *
1288
+ * @param bool $retval Whether or not the notice is currently active.
1289
+ */
1290
  return apply_filters( 'bp_messages_is_active_notice', $retval );
1291
  }
1292
 
1334
  */
1335
  function bp_get_message_notice_id() {
1336
  global $messages_template;
1337
+
1338
+ /**
1339
+ * Filters the ID of the current notice in the loop.
1340
+ *
1341
+ * @since BuddyPress (1.5.0)
1342
+ *
1343
+ * @param int $id ID of the current notice in the loop.
1344
+ */
1345
  return apply_filters( 'bp_get_message_notice_id', $messages_template->thread->id );
1346
  }
1347
 
1358
  */
1359
  function bp_get_message_notice_post_date() {
1360
  global $messages_template;
1361
+
1362
+ /**
1363
+ * Filters the post date of the current notice in the loop.
1364
+ *
1365
+ * @since BuddyPress (1.0.0)
1366
+ *
1367
+ * @param string $value Formatted post date of the current notice in the loop.
1368
+ */
1369
  return apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime( $messages_template->thread->date_sent ) ) );
1370
  }
1371
 
1382
  */
1383
  function bp_get_message_notice_subject() {
1384
  global $messages_template;
1385
+
1386
+ /**
1387
+ * Filters the subject of the current notice in the loop.
1388
+ *
1389
+ * @since BuddyPress (1.0.0)
1390
+ *
1391
+ * @param string $subject Subject of the current notice in the loop.
1392
+ */
1393
  return apply_filters( 'bp_get_message_notice_subject', $messages_template->thread->subject );
1394
  }
1395
 
1406
  */
1407
  function bp_get_message_notice_text() {
1408
  global $messages_template;
1409
+
1410
+ /**
1411
+ * Filters the text of the current notice in the loop.
1412
+ *
1413
+ * @since BuddyPress (1.0.0)
1414
+ *
1415
+ * @param string $message Text for the current notice in the loop.
1416
+ */
1417
  return apply_filters( 'bp_get_message_notice_text', $messages_template->thread->message );
1418
  }
1419
 
1431
  function bp_get_message_notice_delete_link() {
1432
  global $messages_template;
1433
 
1434
+ /**
1435
+ * Filters the URL for deleting the current notice.
1436
+ *
1437
+ * @since BuddyPress (1.0.0)
1438
+ *
1439
+ * @param string $value URL for deleting the current notice.
1440
+ * @param string $value Text indicating action being executed.
1441
+ */
1442
  return apply_filters( 'bp_get_message_notice_delete_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/delete/' . $messages_template->thread->id, 'messages_delete_thread' ) );
1443
  }
1444
 
1461
  } else {
1462
  $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' );
1463
  }
1464
+
1465
+ /**
1466
+ * Filters the URL for deactivating the current notice.
1467
+ *
1468
+ * @since BuddyPress (1.0.0)
1469
+ *
1470
+ * @param string $link URL for deactivating the current notice.
1471
+ */
1472
  return apply_filters( 'bp_get_message_activate_deactivate_link', $link );
1473
  }
1474
 
1479
  echo bp_get_message_activate_deactivate_text();
1480
  }
1481
  /**
1482
+ * Generate the text ('Deactivate' or 'Activate') for the notice action link.
1483
  *
1484
  * @return string
1485
  */
1491
  } else {
1492
  $text = __('Activate', 'buddypress');
1493
  }
1494
+
1495
+ /**
1496
+ * Filters the "Deactivate" or "Activate" text for notice action links.
1497
+ *
1498
+ * @since BuddyPress (1.0.0)
1499
+ *
1500
+ * @param string $text Text used for notice action links.
1501
+ */
1502
  return apply_filters( 'bp_message_activate_deactivate_text', $text );
1503
  }
1504
 
1520
  * @return string
1521
  */
1522
  function bp_get_messages_slug() {
1523
+
1524
+ /**
1525
+ * Filters the messages component slug.
1526
+ *
1527
+ * @since BuddyPress (1.5.0)
1528
+ *
1529
+ * @param string $slug Messages component slug.
1530
+ */
1531
  return apply_filters( 'bp_get_messages_slug', buddypress()->messages->slug );
1532
  }
1533
 
1579
  return false;
1580
  }
1581
 
1582
+ /**
1583
+ * Filters the URL for the Private Message link in member profile headers.
1584
+ *
1585
+ * @since BuddyPress (1.2.10)
1586
+ *
1587
+ * @param string $value URL for the Private Message link in member profile headers.
1588
+ */
1589
  return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() ) ) );
1590
  }
1591
 
1617
  // Note: 'bp_get_send_message_button' is a legacy filter. Use
1618
  // 'bp_get_send_message_button_args' instead. See #4536
1619
  return apply_filters( 'bp_get_send_message_button',
1620
+
1621
+ /**
1622
+ * Filters the "Private Message" button for member profile headers.
1623
+ *
1624
+ * @since BuddyPress (1.8.0)
1625
+ *
1626
+ * @param array $value See {@link BP_Button}.
1627
+ */
1628
  bp_get_button( apply_filters( 'bp_get_send_message_button_args', array(
1629
  'id' => 'private_message',
1630
  'component' => 'messages',
1651
  * @return string
1652
  */
1653
  function bp_get_message_loading_image_src() {
1654
+
1655
+ /**
1656
+ * Filters the URL of the Messages AJAX loader gif.
1657
+ *
1658
+ * @since BuddyPress (1.0.0)
1659
+ *
1660
+ * @param string $value URL of the Messages AJAX loader gif.
1661
+ */
1662
  return apply_filters( 'bp_get_message_loading_image_src', buddypress()->messages->image_base . '/ajax-loader.gif' );
1663
  }
1664
 
1701
  function bp_get_message_get_recipient_usernames() {
1702
  $recipients = isset( $_GET['r'] ) ? stripslashes( $_GET['r'] ) : '';
1703
 
1704
+ /**
1705
+ * Filters the recipients usernames for prefilling the 'To' field on the Compose screen.
1706
+ *
1707
+ * @since BuddyPress (1.0.0)
1708
+ *
1709
+ * @param string $recipients Recipients usernames for 'To' field prefilling.
1710
+ */
1711
  return apply_filters( 'bp_get_message_get_recipient_usernames', $recipients );
1712
  }
1713
 
1792
  /**
1793
  * Constructor method.
1794
  *
1795
+ * @see BP_Messages_Thread::populate() for full parameter info
 
1796
  */
1797
+ public function __construct( $thread_id = 0, $order = 'ASC', $args = array() ) {
1798
+ $this->thread = new BP_Messages_Thread( $thread_id, $order, $args );
1799
  $this->message_count = count( $this->thread->messages );
1800
 
1801
  $last_message_index = $this->message_count - 1;
1858
  if ( ( $this->current_message + 1 ) < $this->message_count ) {
1859
  return true;
1860
  } elseif ( ( $this->current_message + 1 ) === $this->message_count ) {
1861
+
1862
+ /**
1863
+ * Fires when at the end of messages to iterate over.
1864
+ *
1865
+ * @since BuddyPress (1.1.0)
1866
+ */
1867
  do_action( 'thread_loop_end' );
1868
  // Do some cleaning up after the loop
1869
  $this->rewind_messages();
1888
 
1889
  // loop has just started
1890
  if ( 0 === $this->current_message ) {
1891
+
1892
+ /**
1893
+ * Fires if at the start of the message loop.
1894
+ *
1895
+ * @since BuddyPress (1.1.0)
1896
+ */
1897
  do_action( 'thread_loop_start' );
1898
  }
1899
  }
1908
  * Default: if viewing a thread, the thread ID will be parsed from
1909
  * the URL (bp_action_variable( 0 )).
1910
  * @type string $order 'ASC' or 'DESC'. Default: 'ASC'.
1911
+ * @type bool $update_meta_cache Whether to pre-fetch metadata for
1912
+ * queried message items. Default: true.
1913
  * }
1914
  * @return bool True if there are messages to display, otherwise false.
1915
  */
1917
  global $thread_template;
1918
 
1919
  $r = bp_parse_args( $args, array(
1920
+ 'thread_id' => false,
1921
+ 'order' => 'ASC',
1922
+ 'update_meta_cache' => true,
1923
  ), 'thread_has_messages' );
1924
 
1925
  if ( empty( $r['thread_id'] ) && bp_is_messages_component() && bp_is_current_action( 'view' ) ) {
1926
  $r['thread_id'] = (int) bp_action_variable( 0 );
1927
  }
1928
 
1929
+ // Set up extra args
1930
+ $extra_args = $r;
1931
+ unset( $extra_args['thread_id'], $extra_args['order'] );
1932
+
1933
+ $thread_template = new BP_Messages_Thread_Template( $r['thread_id'], $r['order'], $extra_args );
1934
 
1935
  return $thread_template->has_messages();
1936
  }
1987
  function bp_get_the_thread_id() {
1988
  global $thread_template;
1989
 
1990
+ /**
1991
+ * Filters the ID of the thread that the current loop belongs to.
1992
+ *
1993
+ * @since BuddyPress (1.1.0)
1994
+ *
1995
+ * @param int $thread_id ID of the thread.
1996
+ */
1997
  return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id );
1998
  }
1999
 
2011
  function bp_get_the_thread_subject() {
2012
  global $thread_template;
2013
 
2014
+ /**
2015
+ * Filters the subject of the thread currently being iterated over.
2016
+ *
2017
+ * @since BuddyPress (1.1.0)
2018
+ *
2019
+ * @return string $last_message_subject Subject of the thread currently being iterated over.
2020
+ */
2021
  return apply_filters( 'bp_get_the_thread_subject', $thread_template->thread->last_message_subject );
2022
  }
2023
 
2024
+ /**
2025
+ * Get a list of thread recipients or a "x recipients" string.
2026
+ *
2027
+ * In BuddyPress 2.2.0, this parts of this functionality were moved into the
2028
+ * members/single/messages/single.php template. This function is no longer used
2029
+ * by BuddyPress.
2030
+ *
2031
+ * @return string
2032
+ */
2033
+ function bp_get_the_thread_recipients(){
2034
+ if ( 5 <= bp_get_thread_recipients_count() ) {
2035
+ $recipients = sprintf( __( '%s recipients', 'buddypress' ), number_format_i18n( bp_get_thread_recipients_count() ) );
2036
+ } else {
2037
+ $recipients = bp_get_thread_recipients_list();
2038
+ }
2039
+
2040
+ return apply_filters( 'bp_get_the_thread_recipients', $recipients );
2041
+ }
2042
+
2043
+ /**
2044
+ * Get the number of recipients in the current thread.
2045
+ *
2046
+ * @since BuddyPress (2.2.0)
2047
+ *
2048
+ * @return int
2049
+ */
2050
+ function bp_get_thread_recipients_count() {
2051
+ global $thread_template;
2052
+ return count( $thread_template->thread->recipients );
2053
+ }
2054
+
2055
  /**
2056
  * Output HTML links to recipients in the current thread.
2057
+ *
2058
+ * @since BuddyPress (2.2.0)
2059
  */
2060
+ function bp_the_thread_recipients_list() {
2061
+ echo bp_get_thread_recipients_list();
2062
  }
2063
  /**
2064
  * Generate HTML links to the profiles of recipients in the current thread.
2065
  *
2066
+ * @since BuddyPress (2.2.0)
2067
+ *
2068
  * @return string
2069
  */
2070
+ function bp_get_thread_recipients_list() {
2071
  global $thread_template;
2072
 
2073
  $recipient_links = array();
2074
 
 
 
 
 
2075
  foreach( (array) $thread_template->thread->recipients as $recipient ) {
2076
  if ( (int) $recipient->user_id !== bp_loggedin_user_id() ) {
2077
  $recipient_link = bp_core_get_userlink( $recipient->user_id );
2084
  }
2085
  }
2086
 
2087
+ /**
2088
+ * Filters the HTML links to the profiles of recipients in the current thread.
2089
+ *
2090
+ * @since BuddyPress (2.2.0)
2091
+ *
2092
+ * @param string $value Comma-separated list of recipient HTML links for current thread.
2093
+ */
2094
+ return apply_filters( 'bp_get_the_thread_recipients_list', implode( ', ', $recipient_links ) );
2095
  }
2096
 
2097
  /**
2116
  ? (int) $thread_template->message->id
2117
  : null;
2118
 
2119
+ /**
2120
+ * Filters the ID of the current message in the thread.
2121
+ *
2122
+ * @since BuddyPress (1.9.0)
2123
+ *
2124
+ * @param int $thread_message_id ID of the current message in the thread.
2125
+ */
2126
  return apply_filters( 'bp_get_the_thread_message_id', $thread_message_id );
2127
  }
2128
 
2157
  $classes[] = 'sent-by-me';
2158
  }
2159
 
2160
+ /**
2161
+ * Filters the CSS classes for messages within a single thread.
2162
+ *
2163
+ * @since BuddyPress (2.1.0)
2164
+ *
2165
+ * @param array $classes Array of classes to add to the HTML class attribute.
2166
+ */
2167
  $classes = apply_filters( 'bp_get_the_thread_message_css_class', $classes );
2168
 
2169
  return implode( ' ', $classes );
2189
  $class = 'odd';
2190
  }
2191
 
2192
+ /**
2193
+ * Filters the CSS class used for message zebra striping.
2194
+ *
2195
+ * @since BuddyPress (1.1.0)
2196
+ *
2197
+ * @param string $class Class determined to be next for zebra striping effect.
2198
+ */
2199
  return apply_filters( 'bp_get_the_thread_message_alt_class', $class );
2200
  }
2201
 
2221
  ? $thread_template->message->sender_id
2222
  : 0;
2223
 
2224
+ /**
2225
+ * Filters the ID for message sender within a single thread.
2226
+ *
2227
+ * @since BuddyPress (2.1.0)
2228
+ *
2229
+ * @param int $user_id ID of the message sender.
2230
+ */
2231
  return (int) apply_filters( 'bp_get_the_thread_message_css_class', (int) $user_id );
2232
  }
2233
 
2261
  'height' => false,
2262
  ) );
2263
 
2264
+ /**
2265
+ * Filters the avatar for the current message sender.
2266
+ *
2267
+ * @since BuddyPress (1.1.0)
2268
+ *
2269
+ * @param string $value <img> tag containing the avatar value.
2270
+ */
2271
  return apply_filters( 'bp_get_the_thread_message_sender_avatar_thumb', bp_core_fetch_avatar( array(
2272
  'item_id' => $thread_template->message->sender_id,
2273
  'type' => $r['type'],
2291
  function bp_get_the_thread_message_sender_link() {
2292
  global $thread_template;
2293
 
2294
+ /**
2295
+ * Filters the link to the sender of the current message.
2296
+ *
2297
+ * @since BuddyPress (1.1.0)
2298
+ *
2299
+ * @param string $value Link to the sender of the current message.
2300
+ */
2301
  return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) );
2302
  }
2303
 
2321
  $display_name = __( 'Deleted User', 'buddypress' );
2322
  }
2323
 
2324
+ /**
2325
+ * Filters the display name of the sender of the current message.
2326
+ *
2327
+ * @since BuddyPress (1.1.0)
2328
+ *
2329
+ * @param string $display_name Display name of the sender of the current message.
2330
+ */
2331
  return apply_filters( 'bp_get_the_thread_message_sender_name', $display_name );
2332
  }
2333
 
2343
  * @return string URL
2344
  */
2345
  function bp_get_the_thread_delete_link() {
2346
+
2347
+ /**
2348
+ * Filters the URL for deleting the current thread.
2349
+ *
2350
+ * @since BuddyPress (1.0.0)
2351
+ *
2352
+ * @param string $value URL for deleting the current thread.
2353
+ * @param string $value Text indicating action being executed.
2354
+ */
2355
  return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread' ) );
2356
  }
2357
 
2367
  * @return string
2368
  */
2369
  function bp_get_the_thread_message_time_since() {
2370
+
2371
+ /**
2372
+ * Filters the 'Sent x hours ago' string for the current message.
2373
+ *
2374
+ * @since BuddyPress (1.1.0)
2375
+ *
2376
+ * @param string $value Default text of 'Sent x hours ago'.
2377
+ */
2378
  return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s', 'buddypress' ), bp_core_time_since( bp_get_the_thread_message_date_sent() ) ) );
2379
  }
2380
 
2397
  function bp_get_the_thread_message_date_sent() {
2398
  global $thread_template;
2399
 
2400
+ /**
2401
+ * Filters the date sent value for the current message as a timestamp.
2402
+ *
2403
+ * @since BuddyPress (2.1.0)
2404
+ *
2405
+ * @param string $value Timestamp of the date sent value for the current message.
2406
+ */
2407
  return apply_filters( 'bp_get_the_thread_message_date_sent', strtotime( $thread_template->message->date_sent ) );
2408
  }
2409
 
2421
  function bp_get_the_thread_message_content() {
2422
  global $thread_template;
2423
 
2424
+ /**
2425
+ * Filters the content of the current message in the loop.
2426
+ *
2427
+ * @since BuddyPress (1.1.0)
2428
+ *
2429
+ * @param string $message The content of the current message in the loop.
2430
+ */
2431
  return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );
2432
  }
2433
 
2436
  /**
2437
  * Enable oEmbed support for Messages.
2438
  *
 
 
2439
  * @since BuddyPress (1.5.0)
2440
  *
2441
  * @see BP_Embed
 
 
2442
  */
2443
  function bp_messages_embed() {
2444
+ add_filter( 'embed_post_id', 'bp_get_the_thread_message_id' );
2445
+ add_filter( 'bp_embed_get_cache', 'bp_embed_message_cache', 10, 3 );
2446
+ add_action( 'bp_embed_update_cache', 'bp_embed_message_save_cache', 10, 3 );
2447
+ }
2448
+ add_action( 'thread_loop_start', 'bp_messages_embed' );
2449
+
2450
+ /**
2451
+ * Fetch a private message item's cached embeds.
2452
+ *
2453
+ * Used during {@link BP_Embed::parse_oembed()} via {@link bp_messages_embed()}.
2454
+ *
2455
+ * @since BuddyPress (2.2.0)
2456
+ *
2457
+ * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
2458
+ * functions like this one to filter.
2459
+ * @param int $id The ID of the message item.
2460
+ * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
2461
+ * @return mixed The cached embeds for this message item.
2462
+ */
2463
+ function bp_embed_message_cache( $cache, $id, $cachekey ) {
2464
+ return bp_messages_get_meta( $id, $cachekey );
2465
+ }
2466
+
2467
+ /**
2468
+ * Set a private message item's embed cache.
2469
+ *
2470
+ * Used during {@link BP_Embed::parse_oembed()} via {@link bp_messages_embed()}.
2471
+ *
2472
+ * @since BuddyPress (2.2.0)
2473
+ *
2474
+ * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
2475
+ * functions like this one to filter.
2476
+ * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
2477
+ * @param int $id The ID of the message item.
2478
+ * @return bool True on success, false on failure.
2479
+ */
2480
+ function bp_embed_message_save_cache( $cache, $cachekey, $id ) {
2481
+ bp_messages_update_meta( $id, $cachekey, $cache );
2482
  }
 
bp-messages/bp-messages-widgets.php CHANGED
@@ -62,6 +62,14 @@ class BP_Messages_Sitewide_Notices_Widget extends WP_Widget {
62
  extract( $args );
63
 
64
  $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
 
 
 
 
 
 
 
 
65
  $title = apply_filters( 'widget_title', $title, $instance );
66
 
67
  echo $before_widget;
62
  extract( $args );
63
 
64
  $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
65
+
66
+ /**
67
+ * Filters the title of the Messages widget.
68
+ *
69
+ * @since BuddyPress (1.9.0)
70
+ *
71
+ * @param string $title The widget title.
72
+ */
73
  $title = apply_filters( 'widget_title', $title, $instance );
74
 
75
  echo $before_widget;
bp-notifications/bp-notifications-actions.php CHANGED
@@ -121,3 +121,64 @@ function bp_notifications_action_delete() {
121
  bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' );
122
  }
123
  add_action( 'bp_actions', 'bp_notifications_action_delete' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' );
122
  }
123
  add_action( 'bp_actions', 'bp_notifications_action_delete' );
124
+
125
+ /**
126
+ * Handles bulk management (mark as read/unread, delete) of notifications.
127
+ *
128
+ * @since BuddyPress (2.2)
129
+ *
130
+ * @return bool
131
+ */
132
+ function bp_notifications_action_bulk_manage() {
133
+
134
+ // Bail if not the read or unread screen.
135
+ if ( ! bp_is_notifications_component() || ! ( bp_is_current_action( 'read' ) || bp_is_current_action( 'unread' ) ) ) {
136
+ return false;
137
+ }
138
+
139
+ // Get the action
140
+ $action = !empty( $_POST['notification_bulk_action'] ) ? $_POST['notification_bulk_action'] : '';
141
+ $nonce = !empty( $_POST['notifications_bulk_nonce'] ) ? $_POST['notifications_bulk_nonce'] : '';
142
+ $notifications = !empty( $_POST['notifications'] ) ? $_POST['notifications'] : '';
143
+
144
+ // Bail if no action or no IDs.
145
+ if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $notifications ) || empty( $nonce ) ) {
146
+ return false;
147
+ }
148
+
149
+ // Check the nonce.
150
+ if ( ! wp_verify_nonce( $nonce, 'notifications_bulk_nonce' ) ) {
151
+ bp_core_add_message( __( 'There was a problem managing your notifications.', 'buddypress' ), 'error' );
152
+ return false;
153
+ }
154
+
155
+ $notifications = wp_parse_id_list( $notifications );
156
+
157
+ // Delete, mark as read or unread depending on the user 'action'.
158
+ switch ( $action ) {
159
+ case 'delete' :
160
+ foreach (