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 (195) 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 +61 -0
  143. bp-notifications/bp-notifications-classes.php +1 -1
  144. bp-notifications/bp-notifications-functions.php +3 -3
  145. bp-notifications/bp-notifications-loader.php +15 -0
  146. bp-notifications/bp-notifications-template.php +27 -3
  147. bp-settings/bp-settings-actions.php +51 -11
  148. bp-settings/bp-settings-loader.php +11 -9
  149. bp-settings/bp-settings-screens.php +32 -6
  150. bp-settings/bp-settings-template.php +20 -4
  151. bp-templates/bp-legacy/buddypress-functions.php +76 -25
  152. bp-templates/bp-legacy/buddypress/activity/post-form.php +6 -1
  153. bp-templates/bp-legacy/buddypress/blogs/blogs-loop.php +1 -1
  154. bp-templates/bp-legacy/buddypress/groups/single/admin.php +2 -2
  155. bp-templates/bp-legacy/buddypress/groups/single/members.php +1 -1
  156. bp-templates/bp-legacy/buddypress/members/register.php +5 -5
  157. bp-templates/bp-legacy/buddypress/members/single/blogs.php +2 -2
  158. bp-templates/bp-legacy/buddypress/members/single/groups.php +2 -2
  159. bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php +70 -42
  160. bp-templates/bp-legacy/buddypress/members/single/messages/single.php +7 -3
  161. bp-templates/bp-legacy/buddypress/members/single/notifications/notifications-loop.php +30 -20
  162. bp-templates/bp-legacy/buddypress/members/single/settings/general.php +4 -4
  163. bp-templates/bp-legacy/css/buddypress-rtl.css +55 -21
  164. bp-templates/bp-legacy/css/buddypress-rtl.min.css +2 -2
  165. bp-templates/bp-legacy/css/buddypress.css +54 -20
  166. bp-templates/bp-legacy/css/buddypress.min.css +2 -2
  167. bp-templates/bp-legacy/js/buddypress.js +78 -12
  168. bp-templates/bp-legacy/js/buddypress.min.js +3 -2
  169. bp-templates/bp-legacy/js/password-verify.min.js +1 -1
  170. bp-themes/bp-default/_inc/global.js +22 -23
  171. bp-themes/bp-default/groups/single/admin.php +1 -1
  172. bp-themes/bp-default/groups/single/forum/topic.php +1 -1
  173. bp-xprofile/admin/css/admin-rtl.css +5 -0
  174. bp-xprofile/admin/css/admin-rtl.min.css +2 -2
  175. bp-xprofile/admin/css/admin.css +5 -0
  176. bp-xprofile/admin/css/admin.min.css +2 -2
  177. bp-xprofile/admin/js/admin.js +34 -3
  178. bp-xprofile/admin/js/admin.min.js +2 -2
  179. bp-xprofile/bp-xprofile-actions.php +12 -2
  180. bp-xprofile/bp-xprofile-activity.php +46 -35
  181. bp-xprofile/bp-xprofile-admin.php +123 -14
  182. bp-xprofile/bp-xprofile-cache.php +28 -10
  183. bp-xprofile/bp-xprofile-caps.php +11 -1
  184. bp-xprofile/bp-xprofile-classes.php +955 -46
  185. bp-xprofile/bp-xprofile-cssjs.php +2 -2
  186. bp-xprofile/bp-xprofile-filters.php +67 -5
  187. bp-xprofile/bp-xprofile-functions.php +79 -5
  188. bp-xprofile/bp-xprofile-loader.php +37 -10
  189. bp-xprofile/bp-xprofile-screens.php +74 -2
  190. bp-xprofile/bp-xprofile-settings.php +3 -3
  191. bp-xprofile/bp-xprofile-template.php +259 -7
  192. buddypress.pot +1549 -1363
  193. composer.json +33 -0
  194. humans.txt +11 -1
  195. readme.txt +4 -10
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 ) {