BuddyPress - Version 2.1.4

Version Description

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

Download this release

Release Info

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

Code changes from version 2.2.6 to 2.1.4

Files changed (211) hide show
  1. bp-activity/admin/js/admin.js +2 -4
  2. bp-activity/admin/js/admin.min.js +2 -2
  3. bp-activity/bp-activity-actions.php +17 -173
  4. bp-activity/bp-activity-admin.php +21 -147
  5. bp-activity/bp-activity-akismet.php +4 -57
  6. bp-activity/bp-activity-cache.php +1 -2
  7. bp-activity/bp-activity-classes.php +140 -769
  8. bp-activity/bp-activity-cssjs.php +2 -9
  9. bp-activity/bp-activity-filters.php +19 -248
  10. bp-activity/bp-activity-functions.php +48 -937
  11. bp-activity/bp-activity-loader.php +1 -20
  12. bp-activity/bp-activity-notifications.php +12 -170
  13. bp-activity/bp-activity-screens.php +29 -161
  14. bp-activity/bp-activity-template.php +374 -1014
  15. bp-activity/css/mentions-rtl.css +4 -17
  16. bp-activity/css/mentions-rtl.min.css +1 -1
  17. bp-activity/css/mentions.css +4 -17
  18. bp-activity/css/mentions.min.css +1 -1
  19. bp-activity/js/mentions.js +13 -70
  20. bp-activity/js/mentions.min.js +2 -2
  21. bp-blogs/bp-blogs-actions.php +1 -1
  22. bp-blogs/bp-blogs-activity.php +26 -120
  23. bp-blogs/bp-blogs-cache.php +16 -8
  24. bp-blogs/bp-blogs-classes.php +8 -53
  25. bp-blogs/bp-blogs-filters.php +3 -71
  26. bp-blogs/bp-blogs-functions.php +182 -174
  27. bp-blogs/bp-blogs-loader.php +2 -65
  28. bp-blogs/bp-blogs-screens.php +10 -43
  29. bp-blogs/bp-blogs-template.php +15 -344
  30. bp-blogs/bp-blogs-widgets.php +1 -10
  31. bp-core/admin/bp-core-actions.php +1 -1
  32. bp-core/admin/bp-core-components.php +6 -6
  33. bp-core/admin/bp-core-functions.php +56 -75
  34. bp-core/admin/bp-core-schema.php +10 -19
  35. bp-core/admin/bp-core-settings.php +2 -2
  36. bp-core/admin/bp-core-slugs.php +8 -2
  37. bp-core/admin/bp-core-tools.php +1 -1
  38. bp-core/admin/css/common-rtl.css +0 -20
  39. bp-core/admin/css/common-rtl.min.css +1 -1
  40. bp-core/admin/css/common.css +0 -20
  41. bp-core/admin/css/common.min.css +1 -1
  42. bp-core/admin/images/member-types.png +0 -0
  43. bp-core/admin/images/mentions.gif +0 -0
  44. bp-core/bp-core-actions.php +1 -3
  45. bp-core/bp-core-admin.php +166 -212
  46. bp-core/bp-core-adminbar.php +2 -2
  47. bp-core/bp-core-avatars.php +113 -165
  48. bp-core/bp-core-buddybar.php +21 -27
  49. bp-core/bp-core-cache.php +12 -2
  50. bp-core/bp-core-caps.php +3 -3
  51. bp-core/bp-core-catchuri.php +36 -14
  52. bp-core/bp-core-classes.php +56 -332
  53. bp-core/bp-core-component.php +2 -16
  54. bp-core/bp-core-cssjs.php +3 -3
  55. bp-core/bp-core-dependency.php +9 -37
  56. bp-core/bp-core-filters.php +46 -268
  57. bp-core/bp-core-functions.php +39 -138
  58. bp-core/bp-core-loader.php +2 -17
  59. bp-core/bp-core-moderation.php +62 -82
  60. bp-core/bp-core-options.php +2 -2
  61. bp-core/bp-core-taxonomy.php +0 -81
  62. bp-core/bp-core-template-loader.php +15 -24
  63. bp-core/bp-core-template.php +26 -98
  64. bp-core/bp-core-theme-compatibility.php +16 -20
  65. bp-core/bp-core-update.php +1 -80
  66. bp-core/bp-core-widgets.php +441 -3
  67. bp-core/bp-core-wpabstraction.php +4 -4
  68. bp-core/deprecated/1.5.php +2 -2
  69. bp-core/deprecated/1.6.php +1 -1
  70. bp-core/deprecated/1.7.php +1 -1
  71. bp-core/deprecated/1.9.php +2 -2
  72. bp-core/deprecated/2.0.php +1 -1
  73. bp-core/deprecated/2.1.php +2 -2
  74. bp-core/deprecated/2.2.php +0 -116
  75. bp-core/deprecated/js/autocomplete/jquery.autocomplete.js +2 -25
  76. bp-core/deprecated/js/autocomplete/jquery.autocomplete.min.js +2 -2
  77. bp-core/deprecated/js/autocomplete/jquery.autocompletefb.min.js +1 -1
  78. bp-core/deprecated/js/autocomplete/jquery.bgiframe.min.js +1 -1
  79. bp-core/deprecated/js/autocomplete/jquery.dimensions.min.js +1 -1
  80. bp-core/deprecated/js/jquery-scroll-to.min.js +1 -1
  81. bp-core/js/confirm.min.js +1 -1
  82. bp-core/js/jquery-cookie.min.js +1 -1
  83. bp-core/js/jquery-query.min.js +1 -1
  84. bp-core/js/jquery.atwho.js +66 -117
  85. bp-core/js/jquery.atwho.min.js +2 -2
  86. bp-core/js/jquery.caret.js +23 -36
  87. bp-core/js/jquery.caret.min.js +2 -2
  88. bp-core/js/widget-members.js +2 -2
  89. bp-core/js/widget-members.min.js +2 -2
  90. bp-forums/bp-forums-actions.php +1 -1
  91. bp-forums/bp-forums-bbpress-sa.php +5 -27
  92. bp-forums/bp-forums-bbpress.php +1 -1
  93. bp-forums/bp-forums-filters.php +1 -15
  94. bp-forums/bp-forums-functions.php +5 -116
  95. bp-forums/bp-forums-loader.php +1 -1
  96. bp-forums/bp-forums-screens.php +4 -84
  97. bp-forums/bp-forums-template.php +21 -582
  98. bp-forums/deprecated/1.6.php +2 -2
  99. bp-forums/deprecated/1.7.php +1 -1
  100. bp-friends/bp-friends-actions.php +3 -3
  101. bp-friends/bp-friends-activity.php +16 -152
  102. bp-friends/bp-friends-cache.php +1 -1
  103. bp-friends/bp-friends-classes.php +2 -16
  104. bp-friends/bp-friends-functions.php +20 -168
  105. bp-friends/bp-friends-loader.php +1 -16
  106. bp-friends/bp-friends-notifications.php +11 -123
  107. bp-friends/bp-friends-screens.php +2 -33
  108. bp-friends/bp-friends-template.php +7 -105
  109. bp-friends/bp-friends-widgets.php +1 -8
  110. bp-friends/js/widget-friends.js +2 -2
  111. bp-friends/js/widget-friends.min.js +2 -2
  112. bp-groups/admin/js/admin.min.js +1 -1
  113. bp-groups/bp-groups-actions.php +6 -9
  114. bp-groups/bp-groups-activity.php +1 -189
  115. bp-groups/bp-groups-admin.php +17 -51
  116. bp-groups/bp-groups-adminbar.php +59 -34
  117. bp-groups/bp-groups-cache.php +1 -1
  118. bp-groups/bp-groups-classes.php +30 -75
  119. bp-groups/bp-groups-filters.php +1 -23
  120. bp-groups/bp-groups-forums.php +1 -1
  121. bp-groups/bp-groups-functions.php +12 -39
  122. bp-groups/bp-groups-loader.php +3 -72
  123. bp-groups/bp-groups-notifications.php +40 -394
  124. bp-groups/bp-groups-screens.php +34 -31
  125. bp-groups/bp-groups-template.php +145 -562
  126. bp-groups/bp-groups-widgets.php +4 -4
  127. bp-groups/js/widget-groups.js +2 -2
  128. bp-groups/js/widget-groups.min.js +2 -2
  129. bp-loader.php +19 -32
  130. bp-members/admin/bp-members-classes.php +6 -49
  131. bp-members/admin/js/admin.min.js +1 -1
  132. bp-members/bp-members-actions.php +4 -4
  133. bp-members/bp-members-activity.php +0 -96
  134. bp-members/bp-members-admin.php +41 -205
  135. bp-members/bp-members-adminbar.php +1 -1
  136. bp-members/bp-members-cache.php +0 -59
  137. bp-members/bp-members-classes.php +7 -133
  138. bp-members/bp-members-filters.php +1 -10
  139. bp-members/bp-members-functions.php +74 -583
  140. bp-members/bp-members-loader.php +3 -35
  141. bp-members/bp-members-screens.php +30 -181
  142. bp-members/bp-members-template.php +59 -502
  143. bp-members/bp-members-widgets.php +0 -470
  144. bp-messages/bp-messages-actions.php +2 -156
  145. bp-messages/bp-messages-cache.php +1 -24
  146. bp-messages/bp-messages-classes.php +46 -280
  147. bp-messages/bp-messages-cssjs.php +1 -1
  148. bp-messages/bp-messages-filters.php +1 -1
  149. bp-messages/bp-messages-functions.php +2 -117
  150. bp-messages/bp-messages-loader.php +10 -32
  151. bp-messages/bp-messages-notifications.php +6 -74
  152. bp-messages/bp-messages-screens.php +7 -84
  153. bp-messages/bp-messages-template.php +73 -768
  154. bp-messages/bp-messages-widgets.php +0 -8
  155. bp-notifications/bp-notifications-actions.php +1 -62
  156. bp-notifications/bp-notifications-adminbar.php +1 -1
  157. bp-notifications/bp-notifications-cache.php +1 -1
  158. bp-notifications/bp-notifications-classes.php +2 -27
  159. bp-notifications/bp-notifications-functions.php +8 -45
  160. bp-notifications/bp-notifications-loader.php +2 -17
  161. bp-notifications/bp-notifications-screens.php +0 -26
  162. bp-notifications/bp-notifications-template.php +33 -256
  163. bp-settings/bp-settings-actions.php +13 -53
  164. bp-settings/bp-settings-functions.php +4 -4
  165. bp-settings/bp-settings-loader.php +10 -12
  166. bp-settings/bp-settings-screens.php +7 -33
  167. bp-settings/bp-settings-template.php +5 -21
  168. bp-templates/bp-legacy/buddypress-functions.php +87 -171
  169. bp-templates/bp-legacy/buddypress/activity/post-form.php +1 -3
  170. bp-templates/bp-legacy/buddypress/blogs/blogs-loop.php +1 -1
  171. bp-templates/bp-legacy/buddypress/groups/single/admin.php +2 -2
  172. bp-templates/bp-legacy/buddypress/groups/single/invites-loop.php +3 -4
  173. bp-templates/bp-legacy/buddypress/groups/single/members.php +1 -1
  174. bp-templates/bp-legacy/buddypress/groups/single/send-invites.php +3 -20
  175. bp-templates/bp-legacy/buddypress/members/register.php +5 -5
  176. bp-templates/bp-legacy/buddypress/members/single/blogs.php +2 -2
  177. bp-templates/bp-legacy/buddypress/members/single/groups.php +2 -2
  178. bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php +42 -70
  179. bp-templates/bp-legacy/buddypress/members/single/messages/single.php +3 -7
  180. bp-templates/bp-legacy/buddypress/members/single/notifications/notifications-loop.php +20 -30
  181. bp-templates/bp-legacy/buddypress/members/single/settings/general.php +4 -4
  182. bp-templates/bp-legacy/css/buddypress-rtl.css +20 -59
  183. bp-templates/bp-legacy/css/buddypress-rtl.min.css +1 -1
  184. bp-templates/bp-legacy/css/buddypress.css +20 -59
  185. bp-templates/bp-legacy/css/buddypress.min.css +1 -1
  186. bp-templates/bp-legacy/js/buddypress.js +112 -80
  187. bp-templates/bp-legacy/js/buddypress.min.js +2 -2
  188. bp-templates/bp-legacy/js/password-verify.min.js +1 -1
  189. bp-xprofile/admin/css/admin-rtl.css +0 -5
  190. bp-xprofile/admin/css/admin-rtl.min.css +1 -1
  191. bp-xprofile/admin/css/admin.css +0 -5
  192. bp-xprofile/admin/css/admin.min.css +1 -1
  193. bp-xprofile/admin/js/admin.js +3 -34
  194. bp-xprofile/admin/js/admin.min.js +2 -2
  195. bp-xprofile/bp-xprofile-actions.php +3 -13
  196. bp-xprofile/bp-xprofile-activity.php +36 -47
  197. bp-xprofile/bp-xprofile-admin.php +9 -118
  198. bp-xprofile/bp-xprofile-cache.php +11 -29
  199. bp-xprofile/bp-xprofile-caps.php +1 -11
  200. bp-xprofile/bp-xprofile-classes.php +47 -946
  201. bp-xprofile/bp-xprofile-cssjs.php +3 -3
  202. bp-xprofile/bp-xprofile-filters.php +6 -68
  203. bp-xprofile/bp-xprofile-functions.php +6 -80
  204. bp-xprofile/bp-xprofile-loader.php +11 -38
  205. bp-xprofile/bp-xprofile-screens.php +3 -75
  206. bp-xprofile/bp-xprofile-settings.php +3 -3
  207. bp-xprofile/bp-xprofile-template.php +8 -260
  208. buddypress.pot +1491 -1669
  209. composer.json +0 -33
  210. humans.txt +1 -11
  211. readme.txt +67 -126
bp-activity/admin/js/admin.js CHANGED
@@ -165,11 +165,9 @@ $(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
- if ( typeof postboxes !== 'undefined' ) {
171
- postboxes.add_postbox_toggles( bp_activity_admin_vars.page );
172
- }
173
});
174
175
})(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
+ postboxes.add_postbox_toggles( bp_activity_admin_vars.page );
171
});
172
173
})(jQuery);
bp-activity/admin/js/admin.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.2.4 - 2015-11-11 5:04:26 AM UTC - https://wordpress.org/plugins/buddypress/ */
2
- !function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
1
+ /*! buddypress - v2.1.2 - 2015-11-11 4:43:05 AM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ !function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
bp-activity/bp-activity-actions.php CHANGED
@@ -10,22 +10,16 @@
10
*/
11
12
// Exit if accessed directly
13
- defined( 'ABSPATH' ) || exit;
14
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,7 +85,7 @@ function bp_activity_action_permalink_router() {
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,13 +96,7 @@ function bp_activity_action_permalink_router() {
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,14 +149,7 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
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,14 +158,6 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
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,31 +203,16 @@ function bp_activity_action_spam_activity( $activity_id = 0 ) {
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,36 +253,14 @@ function bp_activity_action_post_update() {
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,22 +275,13 @@ function bp_activity_action_post_update() {
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,7 +289,7 @@ function bp_activity_action_post_update() {
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,22 +322,7 @@ function bp_activity_action_post_comment() {
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,7 +339,7 @@ function bp_activity_action_post_comment() {
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,7 +373,7 @@ function bp_activity_action_mark_favorite() {
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,7 +407,7 @@ function bp_activity_action_remove_favorite() {
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,13 +640,7 @@ function bp_activity_setup_akismet() {
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,17 +659,10 @@ function bp_ajax_get_suggestions() {
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,58 +672,3 @@ function bp_ajax_get_suggestions() {
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
-
808
- /**
809
- * Fires if untrashing post in a post type.
810
- *
811
- * This is a variable filter that is dependent on the post type
812
- * being untrashed.
813
- *
814
- * @since BuddyPress (2.2.0)
815
- *
816
- * @param WP_Post $post Post data.
817
- */
818
- do_action( 'bp_activity_post_type_untrash_' . $post->post_type, $post );
819
- } else {
820
- // Record the post.
821
- bp_activity_post_type_publish( $post->ID, $post );
822
- }
823
-
824
- // Unpublishing a previously published post.
825
- } elseif ( 'publish' === $old_status ) {
826
- // Some form of pending status - only remove the activity entry
827
- bp_activity_post_type_unpublish( $post->ID, $post );
828
- }
829
- }
830
- add_action( 'transition_post_status', 'bp_activity_catch_transition_post_type_status', 10, 3 );
10
*/
11
12
// Exit if accessed directly
13
+ if ( !defined( 'ABSPATH' ) ) exit;
14
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
}
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
$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
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
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
// 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
// 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
$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
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
// 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
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
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
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
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
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
wp_send_json_success( $results );
673
}
674
add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
bp-activity/bp-activity-admin.php CHANGED
@@ -11,7 +11,7 @@
11
*/
12
13
// Exit if accessed directly
14
- defined( 'ABSPATH' ) || exit;
15
16
// Include WP's list table class
17
if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
@@ -171,14 +171,6 @@ 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
- /**
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,13 +198,7 @@ function bp_activity_admin_load() {
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,13 +300,7 @@ function bp_activity_admin_load() {
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,17 +384,7 @@ function bp_activity_admin_load() {
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,13 +401,7 @@ function bp_activity_admin_load() {
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,13 +512,7 @@ function bp_activity_admin_load() {
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,13 +521,7 @@ function bp_activity_admin_load() {
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,13 +586,7 @@ function bp_activity_admin_edit() {
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">
@@ -649,7 +595,7 @@ function bp_activity_admin_edit() {
649
650
<?php if ( ! empty( $activity ) ) : ?>
651
652
- <form action="<?php echo esc_url( $form_url ); ?>" id="bp-activities-edit-form" method="post">
653
<div id="poststuff">
654
655
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
@@ -798,7 +744,7 @@ function bp_activity_admin_get_activity_actions() {
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,7 +777,7 @@ function bp_activity_admin_edit_metabox_type( $item ) {
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,19 +894,13 @@ function bp_activity_admin_index() {
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">
@@ -1053,17 +993,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1053
*/
1054
protected $activity_user_id = array();
1055
1056
- /**
1057
- * If users can comment on blog & forum activity items
1058
- *
1059
- * @since BuddyPress (2.2.2)
1060
- *
1061
- * @link https://buddypress.trac.wordpress.org/ticket/6277
1062
- *
1063
- * @var bool
1064
- */
1065
- public $disable_blogforum_comments = false;
1066
-
1067
/**
1068
* Constructor.
1069
*
@@ -1153,7 +1082,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1153
'count_total' => 'count_query',
1154
) );
1155
1156
- // If we're viewing a specific activity, flatten all activities into a single array.
1157
if ( $include_id ) {
1158
$activities['activities'] = BP_Activity_List_Table::flatten_activity_array( $activities['activities'] );
1159
$activities['total'] = count( $activities['activities'] );
@@ -1167,7 +1096,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1167
foreach ( $activities['activities'] as $activity_item ) {
1168
$new_activities[] = (array) $activity_item;
1169
1170
- // Build an array of activity-to-user ID mappings for better efficiency in the In Response To column
1171
$this->activity_user_id[$activity_item->id] = $activity_item->user_id;
1172
}
1173
@@ -1279,20 +1208,10 @@ class BP_Activity_List_Table extends WP_List_Table {
1279
$url_base = bp_get_admin_url( 'admin.php?page=bp-activity' ); ?>
1280
1281
<ul class="subsubsub">
1282
- <li class="all"><a href="<?php echo esc_url( $url_base ); ?>" class="<?php if ( 'spam' != $this->view ) echo 'current'; ?>"><?php _e( 'All', 'buddypress' ); ?></a> |</li>
1283
- <li class="spam"><a href="<?php echo esc_url( add_query_arg( 'activity_status', 'spam', $url_base ) ); ?>" class="<?php if ( 'spam' == $this->view ) echo 'current'; ?>"><?php printf( __( 'Spam <span class="count">(%s)</span>', 'buddypress' ), number_format_i18n( $this->spam_count ) ); ?></a></li>
1284
-
1285
- <?php
1286
1287
- /**
1288
- * Fires inside listing of views so plugins can add their own.
1289
- *
1290
- * @since BuddyPress (1.6.0)
1291
- *
1292
- * @param string $url_base Current URL base for view.
1293
- * @param string $view Current view being displayed.
1294
- */
1295
- do_action( 'bp_activity_list_table_get_views', $url_base, $this->view ); ?>
1296
</ul>
1297
<?php
1298
}
@@ -1310,13 +1229,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1310
$actions['bulk_ham'] = __( 'Not Spam', 'buddypress' );
1311
$actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
1312
1313
- /**
1314
- * Filters the default bulk actions so plugins can add custom actions.
1315
- *
1316
- * @since BuddyPress (1.6.0)
1317
- *
1318
- * @param array $actions Default available actions for bulk operations.
1319
- */
1320
return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
1321
}
1322
@@ -1376,7 +1288,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1376
$selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : '';
1377
1378
// Get the actions
1379
- $activity_actions = bp_activity_get_actions(); ?>
1380
1381
<div class="alignleft actions">
1382
<select name="activity_type">
@@ -1517,14 +1429,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1517
// Start timestamp
1518
echo '<div class="submitted-on">';
1519
1520
- /**
1521
- * Filters available actions for plugins to alter.
1522
- *
1523
- * @since BuddyPress (1.6.0)
1524
- *
1525
- * @param array $actions Array of available actions user could use.
1526
- * @param array $item Current item being added to page.
1527
- */
1528
$actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1529
1530
/* translators: 2: activity admin ui date/time */
@@ -1535,23 +1440,8 @@ class BP_Activity_List_Table extends WP_List_Table {
1535
1536
// Get activity content - if not set, use the action
1537
if ( ! empty( $item['content'] ) ) {
1538
-
1539
- /**
1540
- * Filters current activity item content.
1541
- *
1542
- * @since BuddyPress (1.2.0)
1543
- *
1544
- * @param array $item Array index holding current activity item content.
1545
- */
1546
$content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'] ) );
1547
} else {
1548
- /**
1549
- * Filters current activity item action.
1550
- *
1551
- * @since BuddyPress (1.2.0)
1552
- *
1553
- * @var array $item Array index holding current activity item action.
1554
- */
1555
$content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'] ) );
1556
}
1557
@@ -1569,15 +1459,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1569
*/
1570
function column_response( $item ) {
1571
// Is $item is a root activity?
1572
-
1573
- /**
1574
- * Filters default list of default root activity types.
1575
- *
1576
- * @since BuddyPress (1.6.0)
1577
- *
1578
- * @param array Array of default activity types.
1579
- * @param array $item Current item being displayed.
1580
- */
1581
if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) ) {
1582
$comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
1583
$root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
@@ -1623,7 +1504,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1623
1624
/**
1625
* If, somehow, the referenced activity has been deleted, leaving its associated
1626
- * activities as orphans, use the logged in user's ID to avoid errors.
1627
*/
1628
if ( empty( $activity['activities'] ) )
1629
return bp_loggedin_user_id();
@@ -1692,13 +1573,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1692
}
1693
}
1694
1695
- /**
1696
- * Filters if an activity item can be commented on or not.
1697
- *
1698
- * @since BuddyPress (2.0.0)
1699
- *
1700
- * @param bool $can_comment Whether an activity item can be commented on or not.
1701
- */
1702
return apply_filters( 'bp_activity_list_table_can_comment', $can_comment );
1703
}
1704
11
*/
12
13
// Exit if accessed directly
14
+ if ( !defined( 'ABSPATH' ) ) exit;
15
16
// Include WP's list table class
17
if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
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
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
// 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
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
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
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
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
$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">
595
596
<?php if ( ! empty( $activity ) ) : ?>
597
598
+ <form action="<?php echo esc_attr( $form_url ); ?>" id="bp-activities-edit-form" method="post">
599
<div id="poststuff">
600
601
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
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
$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
$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">
993
*/
994
protected $activity_user_id = array();
995
996
/**
997
* Constructor.
998
*
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
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
1208
$url_base = bp_get_admin_url( 'admin.php?page=bp-activity' ); ?>
1209
1210
<ul class="subsubsub">
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
$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
$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
// 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
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
*/
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
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
}
1574
}
1575
1576
return apply_filters( 'bp_activity_list_table_can_comment', $can_comment );
1577
}
1578
bp-activity/bp-activity-akismet.php CHANGED
@@ -8,7 +8,7 @@
8
*/
9
10
// Exit if accessed directly
11
- defined( 'ABSPATH' ) || exit;
12
13
/**
14
* Akismet support for the Activity component.
@@ -112,13 +112,6 @@ 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
- /**
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,14 +239,6 @@ class BP_Akismet {
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,14 +254,6 @@ class BP_Akismet {
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,14 +270,6 @@ class BP_Akismet {
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,14 +311,6 @@ class BP_Akismet {
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,14 +347,7 @@ class BP_Akismet {
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,7 +431,7 @@ class BP_Akismet {
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,7 +450,7 @@ class BP_Akismet {
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,13 +614,6 @@ class BP_Akismet {
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
8
*/
9
10
// Exit if accessed directly
11
+ if ( !defined( 'ABSPATH' ) ) exit;
12
13
/**
14
* Akismet support for the Activity component.
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
* @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
// 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
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
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
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
/**
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
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
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
bp-activity/bp-activity-cache.php CHANGED
@@ -7,7 +7,7 @@
7
*/
8
9
// Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
12
/**
13
* Slurp up activitymeta for a specified set of activity items.
@@ -43,7 +43,6 @@ function bp_activity_update_meta_cache( $activity_ids = false ) {
43
*/
44
function bp_activity_clear_cache_for_activity( $activity ) {
45
wp_cache_delete( $activity->id, 'bp_activity' );
46
- wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
47
}
48
add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' );
49
7
*/
8
9
// Exit if accessed directly
10
+ if ( !defined( 'ABSPATH' ) ) exit;
11
12
/**
13
* Slurp up activitymeta for a specified set of activity items.
43
*/
44
function bp_activity_clear_cache_for_activity( $activity ) {
45
wp_cache_delete( $activity->id, 'bp_activity' );
46
}
47
add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' );
48
bp-activity/bp-activity-classes.php CHANGED
@@ -7,7 +7,7 @@
7
*/
8
9
// Exit if accessed directly
10
- defined( 'ABSPATH' ) || exit;
11
12
/**
13
* Database interaction class for the BuddyPress activity component.
@@ -135,12 +135,11 @@ class BP_Activity_Activity {
135
* Populate the object with data about the specific activity item.
136
*/
137
public function populate() {
138
- global $wpdb;
139
140
$row = wp_cache_get( $this->id, 'bp_activity' );
141
142
if ( false === $row ) {
143
- $bp = buddypress();
144
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
145
146
wp_cache_set( $this->id, $row, 'bp_activity' );
@@ -170,7 +169,7 @@ class BP_Activity_Activity {
170
171
// If no callback is available, use the literal string from
172
// the database row
173
- } elseif ( ! empty( $row->action ) ) {
174
$this->action = $row->action;
175
176
// Provide a fallback to avoid PHP notices
@@ -185,9 +184,7 @@ class BP_Activity_Activity {
185
* @return bool True on success.
186
*/
187
public function save() {
188
- global $wpdb;
189
-
190
- $bp = buddypress();
191
192
$this->id = apply_filters_ref_array( 'bp_activity_id_before_save', array( $this->id, &$this ) );
193
$this->item_id = apply_filters_ref_array( 'bp_activity_item_id_before_save', array( $this->item_id, &$this ) );
@@ -204,52 +201,32 @@ class BP_Activity_Activity {
204
$this->mptt_right = apply_filters_ref_array( 'bp_activity_mptt_right_before_save', array( $this->mptt_right, &$this ) );
205
$this->is_spam = apply_filters_ref_array( 'bp_activity_is_spam_before_save', array( $this->is_spam, &$this ) );
206
207
- /**
208
- * Fires before the current activity item gets saved.
209
- *
210
- * Please use this hook to filter the properties above. Each part will be passed in.
211
- *
212
- * @since BuddyPress (1.0.0)
213
- *
214
- * @param BP_Activity_Activity Current instance of the activity item being saved.
215
- */
216
do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
217
218
- if ( empty( $this->component ) || empty( $this->type ) ) {
219
return false;
220
- }
221
222
- if ( empty( $this->primary_link ) ) {
223
$this->primary_link = bp_loggedin_user_domain();
224
- }
225
226
// If we have an existing ID, update the activity item, otherwise insert it.
227
- if ( ! empty( $this->id ) ) {
228
$q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %d, secondary_item_id = %d, hide_sitewide = %d, is_spam = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam, $this->id );
229
- } else {
230
$q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam );
231
- }
232
233
- if ( false === $wpdb->query( $q ) ) {
234
return false;
235
- }
236
237
// If this is a new activity item, set the $id property
238
- if ( empty( $this->id ) ) {
239
$this->id = $wpdb->insert_id;
240
241
// If an existing activity item, prevent any changes to the content generating new @mention notifications.
242
- } else {
243
add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
244
- }
245
246
- /**
247
- * Fires after an activity item has been saved to the database.
248
- *
249
- * @since BuddyPress (1.0.0)
250
- *
251
- * @param BP_Activity_Activity Reference to current instance of activity being saved.
252
- */
253
do_action_ref_array( 'bp_activity_after_save', array( &$this ) );
254
255
return true;
@@ -267,34 +244,42 @@ class BP_Activity_Activity {
267
*
268
* @param array $args {
269
* An array of arguments. All items are optional.
270
- *
271
- * @type int $page Which page of results to fetch. Using page=1 without per_page will result
272
- * in no pagination. Default: 1.
273
- * @type int|bool $per_page Number of results per page. Default: 25.
274
- * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
275
- * @type string $sort ASC or DESC. Default: 'DESC'.
276
- * @type array $exclude Array of activity IDs to exclude. Default: false.
277
- * @type array $in Array of ids to limit query by (IN). Default: false.
278
- * @type array $meta_query Array of meta_query conditions. See WP_Meta_Query::queries.
279
- * @type array $date_query Array of date_query conditions. See first parameter of
280
- * WP_Date_Query::__construct().
281
- * @type array $filter_query Array of advanced query conditions. See BP_Activity_Query::__construct().
282
- * @type string|array $scope Pre-determined set of activity arguments.
283
- * @type array $filter See BP_Activity_Activity::get_filter_sql().
284
- * @type string $search_terms Limit results by a search term. Default: false.
285
- * @type bool $display_comments Whether to include activity comments. Default: false.
286
- * @type bool $show_hidden Whether to show items marked hide_sitewide. Default: false.
287
- * @type string $spam Spam status. Default: 'ham_only'.
288
- * @type bool $update_meta_cache Whether to pre-fetch metadata for queried activity items. Default: true.
289
- * @type string|bool $count_total If true, an additional DB query is run to count the total activity items
290
- * for the query. Default: false.
291
* }
292
* @return array The array returned has two keys:
293
* - 'total' is the count of located activities
294
* - 'activities' is an array of the located activities
295
*/
296
public static function get( $args = array() ) {
297
- global $wpdb;
298
299
// Backward compatibility with old method of passing arguments
300
if ( !is_array( $args ) || func_num_args() > 1 ) {
@@ -318,8 +303,7 @@ class BP_Activity_Activity {
318
$args = bp_core_parse_args_array( $old_args_keys, $func_args );
319
}
320
321
- $bp = buddypress();
322
- $r = wp_parse_args( $args, array(
323
'page' => 1, // The current page
324
'per_page' => 25, // Activity items per page
325
'max' => false, // Max number of items to return
@@ -328,16 +312,16 @@ class BP_Activity_Activity {
328
'in' => false, // Array of ids to limit query by (IN)
329
'meta_query' => false, // Filter by activitymeta
330
'date_query' => false, // Filter by date
331
- 'filter_query' => false, // Advanced filtering - see BP_Activity_Query
332
'filter' => false, // See self::get_filter_sql()
333
- 'scope' => false, // Preset activity arguments
334
'search_terms' => false, // Terms to search by
335
'display_comments' => false, // Whether to include activity comments
336
'show_hidden' => false, // Show items marked hide_sitewide
337
'spam' => 'ham_only', // Spam status
338
'update_meta_cache' => true,
339
'count_total' => false,
340
- ) );
341
342
// Select conditions
343
$select_sql = "SELECT DISTINCT a.id";
@@ -352,72 +336,44 @@ class BP_Activity_Activity {
352
// Excluded types
353
$excluded_types = array();
354
355
- // Scope takes precedence
356
- if ( ! empty( $r['scope'] ) ) {
357
- $scope_query = self::get_scope_query_sql( $r['scope'], $r );
358
-
359
- // Add our SQL conditions if matches were found
360
- if ( ! empty( $scope_query['sql'] ) ) {
361
- $where_conditions['scope_query_sql'] = $scope_query['sql'];
362
- }
363
-
364
- // override some arguments if needed
365
- if ( ! empty( $scope_query['override'] ) ) {
366
- $r = self::array_replace_recursive( $r, $scope_query['override'] );
367
- }
368
-
369
- // Advanced filtering
370
- } elseif ( ! empty( $r['filter_query'] ) ) {
371
- $filter_query = new BP_Activity_Query( $r['filter_query'] );
372
- $sql = $filter_query->get_sql();
373
- if ( ! empty( $sql ) ) {
374
- $where_conditions['filter_query_sql'] = $sql;
375
- }
376
- }
377
-
378
- // Regular filtering
379
- if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
380
- $where_conditions['filter_sql'] = $filter_sql;
381
- }
382
-
383
// Spam
384
- if ( 'ham_only' == $r['spam'] ) {
385
$where_conditions['spam_sql'] = 'a.is_spam = 0';
386
- } elseif ( 'spam_only' == $r['spam'] ) {
387
$where_conditions['spam_sql'] = 'a.is_spam = 1';
388
- }
389
390
// Searching
391
- if ( $r['search_terms'] ) {
392
- $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
393
$where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
394
}
395
396
// Sorting
397
- $sort = $r['sort'];
398
- if ( $sort != 'ASC' && $sort != 'DESC' ) {
399
$sort = 'DESC';
400
- }
401
402
// Hide Hidden Items?
403
- if ( ! $r['show_hidden'] ) {
404
$where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
405
- }
406
407
// Exclude specified items
408
- if ( ! empty( $r['exclude'] ) ) {
409
- $exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
410
$where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
411
}
412
413
// The specific ids to which you want to limit the query
414
- if ( ! empty( $r['in'] ) ) {
415
- $in = implode( ',', wp_parse_id_list( $r['in'] ) );
416
$where_conditions['in'] = "a.id IN ({$in})";
417
}
418
419
// Process meta_query into SQL
420
- $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
421
422
if ( ! empty( $meta_query_sql['join'] ) ) {
423
$join_sql .= $meta_query_sql['join'];
@@ -428,7 +384,7 @@ class BP_Activity_Activity {
428
}
429
430
// Process date_query into SQL
431
- $date_query_sql = self::get_date_query_sql( $r['date_query'] );
432
433
if ( ! empty( $date_query_sql ) ) {
434
$where_conditions['date'] = $date_query_sql;
@@ -437,45 +393,34 @@ class BP_Activity_Activity {
437
// Alter the query based on whether we want to show activity item
438
// comments in the stream like normal comments or threaded below
439
// the activity.
440
- if ( false === $r['display_comments'] || 'threaded' === $r['display_comments'] ) {
441
$excluded_types[] = 'activity_comment';
442
}
443
444
// Exclude 'last_activity' items unless the 'action' filter has
445
// been explicitly set
446
- if ( empty( $r['filter']['object'] ) ) {
447
$excluded_types[] = 'last_activity';
448
}
449
450
// Build the excluded type sql part
451
if ( ! empty( $excluded_types ) ) {
452
$not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
453
$where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
454
}
455
456
- /**
457
- * Filters the MySQL WHERE conditions for the Activity items get method.
458
- *
459
- * @since BuddyPress (1.9.0)
460
- *
461
- * @param array $where_conditions Current conditions for MySQL WHERE statement.
462
- * @param array $r Parsed arguments passed into method.
463
- * @param string $select_sql Current SELECT MySQL statement at point of execution.
464
- * @param string $from_sql Current FROM MySQL statement at point of execution.
465
- * @param string $join_sql Current INNER JOIN MySQL statement at point of execution.
466
- */
467
$where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
468
469
// Join the where conditions together
470
$where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
471
472
- /**
473
- * Filters the preferred order of indexes for activity item.
474
- *
475
- * @since BuddyPress (1.6.0)
476
- *
477
- * @param array Array of indexes in preferred order.
478
- */
479
$indexes = apply_filters( 'bp_activity_preferred_index_order', array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ) );
480
481
foreach( $indexes as $key => $index ) {
@@ -492,8 +437,8 @@ class BP_Activity_Activity {
492
}
493
494
// Sanitize page and per_page parameters
495
- $page = absint( $r['page'] );
496
- $per_page = absint( $r['per_page'] );
497
498
$retval = array(
499
'activities' => null,
@@ -501,17 +446,7 @@ class BP_Activity_Activity {
501
'has_more_items' => null,
502
);
503
504
- /**
505
- * Filters if BuddyPress should use legacy query structure over current structure for version 2.0+.
506
- *
507
- * It is not recommended to use the legacy structure, but allowed to if needed.
508
- *
509
- * @since BuddyPress (2.0.0)
510
- *
511
- * @param bool Whether to use legacy structure or not.
512
- * @param BP_Activity_Activity Current method being called.
513
- * @param array $r Parsed arguments passed into method.
514
- */
515
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
516
517
// Legacy queries joined against the user table
@@ -520,27 +455,13 @@ class BP_Activity_Activity {
520
521
if ( ! empty( $page ) && ! empty( $per_page ) ) {
522
$pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
523
-
524
- /** this filter is documented in bp-activity/bp-activity-classes.php */
525
$activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
526
} else {
527
- $pag_sql = '';
528
-
529
- /**
530
- * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
531
- *
532
- * @since BuddyPress (1.5.0)
533
- *
534
- * @param string Concatenated MySQL statement pieces to be query results with for legacy query.
535
- * @param string $select_sql Final SELECT MySQL statement portion for legacy query.
536
- * @param string $from_sql Final FROM MySQL statement portion for legacy query.
537
- * @param string $where_sql Final WHERE MySQL statement portion for legacy query.
538
- * @param string $sort Final sort direction for legacy query.
539
- */
540
- $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
541
}
542
543
} else {
544
// Query first for activity IDs
545
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
546
@@ -550,14 +471,6 @@ class BP_Activity_Activity {
550
$activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
551
}
552
553
- /**
554
- * Filters the paged activities MySQL statement.
555
- *
556
- * @since BuddyPress (2.0.0)
557
- *
558
- * @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
559
- * @param array $r Array of arguments passed into method.
560
- */
561
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
562
563
$activity_ids = $wpdb->get_col( $activity_ids_sql );
@@ -582,13 +495,12 @@ class BP_Activity_Activity {
582
$activity_ids[] = $activity->id;
583
}
584
585
- if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
586
bp_activity_update_meta_cache( $activity_ids );
587
}
588
589
- if ( $activities && $r['display_comments'] ) {
590
- $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
591
- }
592
593
// Pre-fetch data associated with activity users and other objects
594
BP_Activity_Activity::prefetch_object_data( $activities );
@@ -601,22 +513,12 @@ class BP_Activity_Activity {
601
// If $max is set, only return up to the max results
602
if ( ! empty( $r['count_total'] ) ) {
603
604
- /**
605
- * Filters the total activities MySQL statement.
606
- *
607
- * @since BuddyPress (1.5.0)
608
- *
609
- * @param string MySQL statement used to query for total activities.
610
- * @param string $where_sql MySQL WHERE statement portion.
611
- * @param string $sort sort direction for query.
612
- */
613
$total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
614
$total_activities = $wpdb->get_var( $total_activities_sql );
615
616
- if ( !empty( $r['max'] ) ) {
617
- if ( (int) $total_activities > (int) $r['max'] ) {
618
- $total_activities = $r['max'];
619
- }
620
}
621
622
$retval['total'] = $total_activities;
@@ -737,14 +639,6 @@ class BP_Activity_Activity {
737
* @param array $activities Array of activities.
738
*/
739
protected static function prefetch_object_data( $activities ) {
740
-
741
- /**
742
- * Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
743
- *
744
- * @since BuddyPress (2.0.0)
745
- *
746
- * @param array $activities Array of activities.
747
- */
748
return apply_filters( 'bp_activity_prefetch_object_data', $activities );
749
}
750
@@ -841,110 +735,6 @@ class BP_Activity_Activity {
841
return $sql;
842
}
843
844
- /**
845
- * Get the SQL for the 'scope' param in BP_Activity_Activity::get().
846
- *
847
- * A scope is a predetermined set of activity arguments. This method is used
848
- * to grab these activity arguments and override any existing args if needed.
849
- *
850
- * Can handle multiple scopes.
851
- *
852
- * @since BuddyPress (2.2.0)
853
- *
854
- * @param mixed $scope The activity scope. Accepts string or array of scopes
855
- * @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),
856
- * but merged with defaults.
857
- * @return array 'sql' WHERE SQL string and 'override' activity args
858
- */
859
- public static function get_scope_query_sql( $scope = false, $r = array() ) {
860
-
861
- // Define arrays for future use
862
- $query_args = array();
863
- $override = array();
864
- $retval = array();
865
-
866
- // Check for array of scopes
867
- if ( is_array( $scope ) ) {
868
- $scopes = $scope;
869
-
870
- // Explode a comma separated string of scopes
871
- } elseif ( is_string( $scope ) ) {
872
- $scopes = explode( ',', $scope );
873
- }
874
-
875
- // Bail if no scope passed
876
- if ( empty( $scopes ) ) {
877
- return false;
878
- }
879
-
880
- // Helper to easily grab the 'user_id'
881
- if ( ! empty( $r['filter']['user_id'] ) ) {
882
- $r['user_id'] = $r['filter']['user_id'];
883
- }
884
-
885
- // parse each scope; yes! we handle multiples!
886
- foreach ( $scopes as $scope ) {
887
- $scope_args = array();
888
-
889
- /**
890
- * Plugins can hook here to set their activity arguments for custom scopes.
891
- *
892
- * This is a dynamic filter based on the activity scope. eg:
893
- * - 'bp_activity_set_groups_scope_args'
894
- * - 'bp_activity_set_friends_scope_args'
895
- *
896
- * To see how this filter is used, plugin devs should check out:
897
- * - bp_groups_filter_activity_scope() - used for 'groups' scope
898
- * - bp_friends_filter_activity_scope() - used for 'friends' scope
899
- *
900
- * @since BuddyPress (2.2.0)
901
- *
902
- * @param array {
903
- * Activity query clauses.
904
- *
905
- * @type array {
906
- * Activity arguments for your custom scope.
907
- * See {@link BP_Activity_Query::_construct()} for more details.
908
- * }
909
- * @type array $override Optional. Override existing activity arguments passed by $r.
910
- * }
911
- * @param array $r Current activity arguments passed in BP_Activity_Activity::get()
912
- */
913
- $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r );
914
-
915
- if ( ! empty( $scope_args ) ) {
916
- // merge override properties from other scopes
917
- // this might be a problem...
918
- if ( ! empty( $scope_args['override'] ) ) {
919
- $override = array_merge( $override, $scope_args['override'] );
920
- unset( $scope_args['override'] );
921
- }
922
-
923
- // save scope args
924
- if ( ! empty( $scope_args ) ) {
925
- $query_args[] = $scope_args;
926
- }
927
- }
928
- }
929
-
930
- if ( ! empty( $query_args ) ) {
931
- // set relation to OR
932
- $query_args['relation'] = 'OR';
933
-
934
- $query = new BP_Activity_Query( $query_args );
935
- $sql = $query->get_sql();
936
- if ( ! empty( $sql ) ) {
937
- $retval['sql'] = $sql;
938
- }
939
- }
940
-
941
- if ( ! empty( $override ) ) {
942
- $retval['override'] = $override;
943
- }
944
-
945
- return $retval;
946
- }
947
-
948
/**
949
* In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
950
*
@@ -971,64 +761,51 @@ class BP_Activity_Activity {
971
/**
972
* Get the first activity ID that matches a set of criteria.
973
*
974
- * @param int $user_id User ID to filter by
975
- * @param string $component Component to filter by
976
- * @param string $type Activity type to filter by
977
- * @param int $item_id Associated item to filter by
978
- * @param int $secondary_item_id Secondary associated item to filter by
979
- * @param string $action Action to filter by
980
- * @param string $content Content to filter by
981
- * @param string $date_recorded Date to filter by
982
- *
983
- * @todo Should parameters be optional?
984
- *
985
* @return int|bool Activity ID on success, false if none is found.
986
*/
987
public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
988
- global $wpdb;
989
-
990
- $bp = buddypress();
991
992
$where_args = false;
993
994
- if ( ! empty( $user_id ) ) {
995
$where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
996
- }
997
998
- if ( ! empty( $component ) ) {
999
$where_args[] = $wpdb->prepare( "component = %s", $component );
1000
- }
1001
1002
- if ( ! empty( $type ) ) {
1003
$where_args[] = $wpdb->prepare( "type = %s", $type );
1004
- }
1005
1006
- if ( ! empty( $item_id ) ) {
1007
$where_args[] = $wpdb->prepare( "item_id = %d", $item_id );
1008
- }
1009
1010
- if ( ! empty( $secondary_item_id ) ) {
1011
$where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id );
1012
- }
1013
1014
- if ( ! empty( $action ) ) {
1015
$where_args[] = $wpdb->prepare( "action = %s", $action );
1016
- }
1017
1018
- if ( ! empty( $content ) ) {
1019
$where_args[] = $wpdb->prepare( "content = %s", $content );
1020
- }
1021
1022
- if ( ! empty( $date_recorded ) ) {
1023
$where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
1024
- }
1025
1026
- if ( ! empty( $where_args ) ) {
1027
$where_sql = 'WHERE ' . join( ' AND ', $where_args );
1028
- return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
1029
- }
1030
1031
- return false;
1032
}
1033
1034
/**
@@ -1055,9 +832,7 @@ class BP_Activity_Activity {
1055
* @return array|bool An array of deleted activity IDs on success, false on failure.
1056
*/
1057
public static function delete( $args = array() ) {
1058
- global $wpdb;
1059
-
1060
- $bp = buddypress();
1061
1062
$defaults = array(
1063
'id' => false,
@@ -1158,11 +933,10 @@ class BP_Activity_Activity {
1158
* @return bool True on success.
1159
*/
1160
public static function delete_activity_item_comments( $activity_ids = array(), $delete_meta = true ) {
1161
- global $wpdb;
1162
1163
- $bp = buddypress();
1164
1165
- $delete_meta = (bool) $delete_meta;
1166
$activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
1167
1168
if ( $delete_meta ) {
@@ -1230,6 +1004,7 @@ class BP_Activity_Activity {
1230
*
1231
* @since BuddyPress (1.2)
1232
*
1233
* @global wpdb $wpdb WordPress database object.
1234
*
1235
* @param int $activity_id Activity ID to fetch comments for.
@@ -1240,7 +1015,7 @@ class BP_Activity_Activity {
1240
* @return array The updated activities with nested comments.
1241
*/
1242
public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
1243
- global $wpdb;
1244
1245
if ( empty( $top_level_parent_id ) ) {
1246
$top_level_parent_id = $activity_id;
@@ -1254,9 +1029,7 @@ class BP_Activity_Activity {
1254
$comments = false;
1255
1256
// A true cache miss
1257
- } elseif ( empty( $comments ) ) {
1258
-
1259
- $bp = buddypress();
1260
1261
// Select the user's fullname with the query
1262
if ( bp_is_active( 'xprofile' ) ) {
@@ -1280,29 +1053,7 @@ class BP_Activity_Activity {
1280
1281
// Legacy query - not recommended
1282
$func_args = func_get_args();
1283
-
1284
- /**
1285
- * Filters if BuddyPress should use the legacy activity query.
1286
- *
1287
- * @since BuddyPress (2.0.0)
1288
- *
1289
- * @param bool Whether or not to use the legacy query.
1290
- * @param BP_Activity_Activity Magic method referring to currently called method.
1291
- * @param array $func_args Array of the method's argument list.
1292
- */
1293
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $func_args ) ) {
1294
-
1295
- /**
1296
- * Filters the MySQL prepared statement for the legacy activity query.
1297
- *
1298
- * @since BuddyPress (1.5.0)
1299
- *
1300
- * @param string Prepared statement for the activity query.
1301
- * @param int $activity_id Activity ID to fetch comments for.
1302
- * @param int $left Left-most node boundary.
1303
- * @param int $right Right-most node boundary.
1304
- * @param string $spam_sql SQL Statement portion to differentiate between ham or spam.
1305
- */
1306
$sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d AND a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right ), $activity_id, $left, $right, $spam_sql );
1307
1308
$descendants = $wpdb->get_results( $sql );
@@ -1384,39 +1135,35 @@ class BP_Activity_Activity {
1384
*
1385
* @since BuddyPress (1.2)
1386
*
1387
- * @global wpdb $wpdb WordPress database object
1388
*
1389
- * @param int $parent_id ID of an activity or activity comment
1390
- * @param int $left Node boundary start for activity or activity comment
1391
- * @return int Right Node boundary of activity or activity comment
1392
*/
1393
public static function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
1394
- global $wpdb;
1395
-
1396
- $bp = buddypress();
1397
1398
// The right value of this node is the left value + 1
1399
- $right = intval( $left + 1 );
1400
1401
// Get all descendants of this node
1402
- $comments = BP_Activity_Activity::get_child_comments( $parent_id );
1403
- $descendants = wp_list_pluck( $comments, 'id' );
1404
1405
// Loop the descendants and recalculate the left and right values
1406
- foreach ( (array) $descendants as $descendant_id ) {
1407
- $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );
1408
- }
1409
1410
// We've got the left value, and now that we've processed the children
1411
// of this node we also know the right value
1412
- if ( 1 === $left ) {
1413
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
1414
- } else {
1415
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id ) );
1416
- }
1417
1418
// Return the right value of this node + 1
1419
- return intval( $right + 1 );
1420
}
1421
1422
/**
@@ -1424,15 +1171,14 @@ class BP_Activity_Activity {
1424
*
1425
* @since BuddyPress (1.2)
1426
*
1427
* @global wpdb $wpdb WordPress database object.
1428
*
1429
- * @param int $parent_id ID of an activity or activity comment.
1430
* @return object Numerically indexed array of child comments.
1431
*/
1432
public static function get_child_comments( $parent_id ) {
1433
- global $wpdb;
1434
-
1435
- $bp = buddypress();
1436
1437
return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
1438
}
@@ -1448,11 +1194,9 @@ class BP_Activity_Activity {
1448
* @return array List of component names.
1449
*/
1450
public static function get_recorded_components( $skip_last_activity = true ) {
1451
- global $wpdb;
1452
-
1453
- $bp = buddypress();
1454
1455
- if ( true === $skip_last_activity ) {
1456
$components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} WHERE action != '' AND action != 'last_activity' ORDER BY component ASC" );
1457
} else {
1458
$components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
@@ -1604,9 +1348,7 @@ class BP_Activity_Activity {
1604
* @return string ISO timestamp.
1605
*/
1606
public static function get_last_updated() {
1607
- global $wpdb;
1608
-
1609
- $bp = buddypress();
1610
1611
return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
1612
}
@@ -1620,15 +1362,10 @@ class BP_Activity_Activity {
1620
* @return int A count of the user's favorites.
1621
*/
1622
public static function total_favorite_count( $user_id ) {
1623
1624
- // Get activities from user meta
1625
- $favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
1626
- if ( ! empty( $favorite_activity_entries ) ) {
1627
- return count( maybe_unserialize( $favorite_activity_entries ) );
1628
- }
1629
-
1630
- // No favorites
1631
- return 0;
1632
}
1633
1634
/**
@@ -1638,9 +1375,7 @@ class BP_Activity_Activity {
1638
* @return int|bool The ID of the first matching item if found, otherwise false.
1639
*/
1640
public static function check_exists_by_content( $content ) {
1641
- global $wpdb;
1642
-
1643
- $bp = buddypress();
1644
1645
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
1646
}
@@ -1652,309 +1387,10 @@ class BP_Activity_Activity {
1652
* @param int
1653
*/
1654
public static function hide_all_for_user( $user_id ) {
1655
- global $wpdb;
1656
-
1657
- $bp = buddypress();
1658
1659
return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
1660
}
1661
-
1662
- /**
1663
- * PHP-agnostic version of {@link array_replace_recursive()}.
1664
- *
1665
- * array_replace_recursive() is a PHP 5.3 function. BuddyPress (and
1666
- * WordPress) currently supports down to PHP 5.2, so this method is a workaround
1667
- * for PHP 5.2.
1668
- *
1669
- * Note: array_replace_recursive() supports infinite arguments, but for our use-
1670
- * case, we only need to support two arguments.
1671
- *
1672
- * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
1673
- *
1674
- * @since BuddyPress (2.2.0)
1675
- *
1676
- * @see http://php.net/manual/en/function.array-replace-recursive.php#109390
1677
- *
1678
- * @param array $base Array with keys needing to be replaced
1679
- * @param array $replacements Array with the replaced keys
1680
- * @return array
1681
- */
1682
- protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
1683
- if ( function_exists( 'array_replace_recursive' ) ) {
1684
- return array_replace_recursive( $base, $replacements );
1685
- }
1686
-
1687
- // PHP 5.2-compatible version
1688
- // http://php.net/manual/en/function.array-replace-recursive.php#109390
1689
- foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
1690
- $bref_stack = array( &$base );
1691
- $head_stack = array( $replacements );
1692
-
1693
- do {
1694
- end( $bref_stack );
1695
-
1696
- $bref = &$bref_stack[ key( $bref_stack ) ];
1697
- $head = array_pop( $head_stack );
1698
-
1699
- unset( $bref_stack[ key($bref_stack) ] );
1700
-
1701
- foreach ( array_keys( $head ) as $key ) {
1702
- if ( isset( $key, $bref ) && is_array( $bref[$key] ) && is_array( $head[$key] ) ) {
1703
- $bref_stack[] = &$bref[ $key ];
1704
- $head_stack[] = $head[ $key ];
1705
- } else {
1706
- $bref[ $key ] = $head[ $key ];
1707
- }
1708
- }
1709
- } while( count( $head_stack ) );
1710
- }
1711
-
1712
- return $base;
1713
- }
1714
- }
1715
-
1716
- /**
1717
- * Class for generating the WHERE SQL clause for advanced activity fetching.
1718
- *
1719
- * This is notably used in {@link BP_Activity_Activity::get()} with the
1720
- * 'filter_query' parameter.
1721
- *
1722
- * @since BuddyPress (2.2.0)
1723
- */
1724
- class BP_Activity_Query extends BP_Recursive_Query {
1725
- /**
1726
- * Array of activity queries.
1727
- *
1728
- * See {@see BP_Activity_Query::__construct()} for information on query arguments.
1729
- *
1730
- * @since BuddyPress (2.2.0)
1731
- * @access public
1732
- * @var array
1733
- */
1734
- public $queries = array();
1735
-
1736
- /**
1737
- * Table alias.
1738
- *
1739
- * @since BuddyPress (2.2.0)
1740
- * @access public
1741
- * @var string
1742
- */
1743
- public $table_alias = '';
1744
-
1745
- /**
1746
- * Supported DB columns.
1747
- *
1748
- * See the 'wp_bp_activity' DB table schema.
1749
- *
1750
- * @since BuddyPress (2.2.0)
1751
- * @access public
1752
- * @var array
1753
- */
1754
- public $db_columns = array(
1755
- 'id', 'user_id', 'component', 'type', 'action', 'content',
1756
- 'item_id', 'secondary_item_id', 'hide_sitewide', 'is_spam',
1757
- );
1758
-
1759
- /**
1760
- * Constructor.
1761
- *
1762
- * @since BuddyPress (2.2.0)
1763
- *
1764
- * @param array $query {
1765
- * Array of query clauses.
1766
- *
1767
- * @type array {
1768
- * @type string $column Required. The column to query against. Basically, any DB column in the main
1769
- * 'wp_bp_activity' table.
1770
- * @type string $value Required. Value to filter by.
1771
- * @type string $compare Optional. The comparison operator. Default '='.
1772
- * Accepts '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'LIKE',
1773
- * 'NOT LIKE', BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', 'RLIKE'
1774
- * @type string $relation Optional. The boolean relationship between the activity queries.
1775
- * Accepts 'OR', 'AND'. Default 'AND'.
1776
- * @type array {
1777
- * Optional. Another fully-formed activity query. See parameters above.
1778
- * }
1779
- * }
1780
- * }
1781
- */
1782
- public function __construct( $query = array() ) {
1783
- if ( ! is_array( $query ) ) {
1784
- return;
1785
- }
1786
-
1787
- $this->queries = $this->sanitize_query( $query );
1788
- }
1789
-
1790
- /**
1791
- * Generates WHERE SQL clause to be appended to a main query.
1792
- *
1793
- * @since BuddyPress (2.2.0)
1794
- * @access public
1795
- *
1796
- * @param string $alias An existing table alias that is compatible with the current query clause.
1797
- * Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
1798
- * @return string SQL fragment to append to the main WHERE clause.
1799
- */
1800
- public function get_sql( $alias = 'a' ) {
1801
- if ( ! empty( $alias ) ) {
1802
- $this->table_alias = sanitize_title( $alias );
1803
- }
1804
-
1805
- $sql = $this->get_sql_clauses();
1806
-
1807
- // we only need the 'where' clause
1808
- //
1809
- // also trim trailing "AND" clause from parent BP_Recursive_Query class
1810
- // since it's not necessary for our needs
1811
- return preg_replace( '/^\sAND/', '', $sql['where'] );
1812
- }
1813
-
1814
- /**
1815
- * Generate WHERE clauses for a first-order clause.
1816
- *
1817
- * @since BuddyPress (2.2.0)
1818
- * @access protected
1819
- *
1820
- * @param array $clause Array of arguments belonging to the clause.
1821
- * @param array $parent_query Parent query to which the clause belongs.
1822
- * @return array {
1823
- * @type array $where Array of subclauses for the WHERE statement.
1824
- * @type array $join Empty array. Not used.
1825
- * }
1826
- */
1827
- protected function get_sql_for_clause( $clause, $parent_query ) {
1828
- global $wpdb;
1829
-
1830
- $sql_chunks = array(
1831
- 'where' => array(),
1832
- 'join' => array(),
1833
- );
1834
-
1835
- $column = isset( $clause['column'] ) ? $this->validate_column( $clause['column'] ) : '';
1836
- $value = isset( $clause['value'] ) ? $clause['value'] : '';
1837
- if ( empty( $column ) || ! isset( $clause['value'] ) ) {
1838
- return $sql_chunks;
1839
- }
1840
-
1841
- if ( isset( $clause['compare'] ) ) {
1842
- $clause['compare'] = strtoupper( $clause['compare'] );
1843
- } else {
1844
- $clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
1845
- }
1846
-
1847
- // default 'compare' to '=' if no valid operator is found
1848
- if ( ! in_array( $clause['compare'], array(
1849
- '=', '!=', '>', '>=', '<', '<=',
1850
- 'LIKE', 'NOT LIKE',
1851
- 'IN', 'NOT IN',
1852
- 'BETWEEN', 'NOT BETWEEN',
1853
- 'REGEXP', 'NOT REGEXP', 'RLIKE'
1854
- ) ) ) {
1855
- $clause['compare'] = '=';
1856
- }
1857
-
1858
- $compare = $clause['compare'];
1859
-
1860
- $alias = ! empty( $this->table_alias ) ? "{$this->table_alias}." : '';
1861
-
1862
- // Next, Build the WHERE clause.
1863
- $where = '';
1864
-
1865
- // value.
1866
- if ( isset( $clause['value'] ) ) {
1867
- if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
1868
- if ( ! is_array( $value ) ) {
1869
- $value = preg_split( '/[,\s]+/', $value );
1870
- }
1871
- }
1872
-
1873
- // tinyint
1874
- if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
1875
- $sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
1876
-
1877
- } else {
1878
- switch ( $compare ) {
1879
- // IN uses different syntax
1880
- case 'IN' :
1881
- case 'NOT IN' :
1882
- $in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value );
1883
-
1884
- // 'NOT IN' operator is as easy as a string replace!
1885
- if ( 'NOT IN' === $compare ) {
1886
- $in_sql = str_replace( 'IN', 'NOT IN', $in_sql );
1887
- }
1888
-
1889
- $sql_chunks['where'][] = $in_sql;
1890
- break;
1891
-
1892
- case 'BETWEEN' :
1893
- case 'NOT BETWEEN' :
1894
- $value = array_slice( $value, 0, 2 );
1895
- $where = $wpdb->prepare( '%s AND %s', $value );
1896
- break;
1897
-
1898
- case 'LIKE' :
1899
- case 'NOT LIKE' :
1900
- $value = '%' . bp_esc_like( $value ) . '%';
1901
- $where = $wpdb->prepare( '%s', $value );
1902
- break;
1903
-
1904
- default :
1905
- $where = $wpdb->prepare( '%s', $value );
1906
- break;
1907
-
1908
- }
1909
- }
1910
-
1911
- if ( $where ) {
1912
- $sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}";
1913
- }
1914
- }
1915
-
1916
- /*
1917
- * Multiple WHERE clauses should be joined in parentheses.
1918
- */
1919
- if ( 1 < count( $sql_chunks['where'] ) ) {
1920
- $sql_chunks['where'] = array( '( ' . implode( ' AND ', $sql_chunks['where'] ) . ' )' );
1921
- }
1922
-
1923
- return $sql_chunks;
1924
- }
1925
-
1926
- /**
1927
- * Determine whether a clause is first-order.
1928
- *
1929
- * @since BuddyPress (2.2.0)
1930
- * @access protected
1931
- *
1932
- * @param array $query Clause to check.
1933
- * @return bool
1934
- */
1935
- protected function is_first_order_clause( $query ) {
1936
- return isset( $query['column'] ) || isset( $query['value'] );
1937
- }
1938
-
1939
- /**
1940
- * Validates a column name parameter.
1941
- *
1942
- * Column names are checked against a whitelist of known tables.
1943
- * See {@link BP_Activity_Query::db_tables}.
1944
- *
1945
- * @since BuddyPress (2.2.0)
1946
- * @access public
1947
- *
1948
- * @param string $column The user-supplied column name.
1949
- * @return string A validated column name value.
1950
- */
1951
- public function validate_column( $column = '' ) {
1952
- if ( in_array( $column, $this->db_columns ) ) {
1953
- return $column;
1954
- } else {
1955
- return '';
1956
- }
1957
- }
1958
}
1959
1960
/**
@@ -2013,14 +1449,7 @@ class BP_Activity_Feed {
2013
* @param array $args Optional
2014
*/
2015
public function __construct( $args = array() ) {
2016
-
2017
- /**
2018
- * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
2019
- *
2020
- * @since BuddyPress (1.8.0)
2021
- *
2022
- * @param bool true Default true aka feeds are enabled.
2023
- */
2024
if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
2025
global $wp_query;
2026
@@ -2066,13 +1495,7 @@ class BP_Activity_Feed {
2066
'activity_args' => array()
2067
) );
2068
2069
- /**
2070
- * Fires before the feed is setup so plugins can modify.
2071
- *
2072
- * @since BuddyPress (1.8.0)
2073
- *
2074
- * @param BP_Activity_Feed Reference to current instance of activity feed.
2075
- */
2076
do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
2077
2078
// Setup class properties
@@ -2084,13 +1507,7 @@ class BP_Activity_Feed {
2084
return false;
2085
}
2086
2087
- /**
2088
- * Fires after the feed is setup so plugins can modify.
2089
- *
2090
- * @since BuddyPress (1.8.0)
2091
- *
2092
- * @param BP_Activity_Feed Reference to current instance of activity feed.
2093
- */
2094
do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
2095
2096
// Setup feed hooks
@@ -2147,14 +1564,6 @@ class BP_Activity_Feed {
2147
* Fire a hook to ensure backward compatibility for RSS attributes.
2148
*/
2149
public function backpat_rss_attributes() {
2150
-
2151
- /**
2152
- * Fires inside backpat_rss_attributes method for backwards compatibility related to RSS attributes.
2153
- *
2154
- * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2155
- *
2156
- * @since BuddyPress (1.0.0)
2157
- */
2158
do_action( 'bp_activity_' . $this->id . '_feed' );
2159
}
2160
@@ -2162,14 +1571,6 @@ class BP_Activity_Feed {
2162
* Fire a hook to ensure backward compatibility for channel elements.
2163
*/
2164
public function backpat_channel_elements() {
2165
-
2166
- /**
2167
- * Fires inside backpat_channel_elements method for backwards compatibility related to RSS channel elements.
2168
- *
2169
- * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2170
- *
2171
- * @since BuddyPress (1.0.0)
2172
- */
2173
do_action( 'bp_activity_' . $this->id . '_feed_head' );
2174
}
2175
@@ -2192,13 +1593,6 @@ class BP_Activity_Feed {
2192
break;
2193
}
2194
2195
- /**
2196
- * Fires inside backpat_item_elements method for backwards compatibility related to RSS item elements.
2197
- *
2198
- * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
2199
- *
2200
- * @since BuddyPress (1.0.0)
2201
- */
2202
do_action( 'bp_activity_' . $id . '_feed_item' );
2203
}
2204
@@ -2252,7 +1646,6 @@ class BP_Activity_Feed {
2252
2253
// Set content-type
2254
@header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
2255
- send_nosniff_header();
2256
2257
// Cache-related variables
2258
$last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
@@ -2275,8 +1668,7 @@ class BP_Activity_Feed {
2275
$client_etag = trim( $client_etag, '"' );
2276
2277
// Strip suffixes from ETag if they exist (eg. "-gzip")
2278
- $etag_suffix_pos = strpos( $client_etag, '-' );
2279
- if ( ! empty( $etag_suffix_pos ) ) {
2280
$client_etag = substr( $client_etag, 0, $etag_suffix_pos );
2281
}
2282
@@ -2326,14 +1718,7 @@ class BP_Activity_Feed {
2326
xmlns:atom="http://www.w3.org/2005/Atom"
2327
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
2328
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
2329
- <?php
2330
-
2331
- /**
2332
- * Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
2333
- *
2334
- * @since BuddyPress (1.8.0)
2335
- */
2336
- do_action( 'bp_activity_feed_rss_attributes' ); ?>
2337
>
2338
2339
<channel>
@@ -2347,14 +1732,7 @@ class BP_Activity_Feed {
2347
<ttl><?php echo $this->ttl; ?></ttl>
2348
<sy:updatePeriod><?php echo $this->update_period; ?></sy:updatePeriod>
2349
<sy:updateFrequency><?php echo $this->update_frequency; ?></sy:updateFrequency>
2350
- <?php
2351
-
2352
- /**
2353
- * Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
2354
- *
2355
- * @since BuddyPress (1.8.0)
2356
- */
2357
- do_action( 'bp_activity_feed_channel_elements' ); ?>
2358
2359
<?php if ( bp_has_activities( $this->activity_args ) ) : ?>
2360
<?php while ( bp_activities() ) : bp_the_activity(); ?>
@@ -2372,14 +1750,7 @@ class BP_Activity_Feed {
2372
<slash:comments><?php bp_activity_comment_count(); ?></slash:comments>
2373
<?php endif; ?>
2374
2375
- <?php
2376
-
2377
- /**
2378
- * Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
2379
- *
2380
- * @since BuddyPress (1.8.0)
2381
- */
2382
- do_action( 'bp_activity_feed_item_elements' ); ?>
2383
</item>
2384
<?php endwhile; ?>
2385
7
*/
8
9
// Exit if accessed directly
10
+ if ( !defined( 'ABSPATH' ) ) exit;
11
12
/**
13
* Database interaction class for the BuddyPress activity component.
135