BuddyPress - Version 2.5.5

Version Description

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

Download this release

Release Info

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

Code changes from version 2.6.4 to 2.5.5

Files changed (280) hide show
  1. bp-activity/admin/js/admin.min.js +1 -0
  2. bp-activity/bp-activity-actions.php +102 -0
  3. bp-activity/bp-activity-admin.php +10 -40
  4. bp-activity/bp-activity-adminbar.php +0 -47
  5. bp-activity/bp-activity-akismet.php +1 -3
  6. bp-activity/bp-activity-classes.php +0 -5
  7. bp-activity/bp-activity-embeds.php +0 -352
  8. bp-activity/bp-activity-filters.php +31 -39
  9. bp-activity/bp-activity-functions.php +161 -110
  10. bp-activity/bp-activity-loader.php +1 -3
  11. bp-activity/bp-activity-notifications.php +92 -241
  12. bp-activity/bp-activity-screens.php +63 -25
  13. bp-activity/bp-activity-template.php +278 -30
  14. bp-activity/classes/class-bp-activity-activity.php +8 -72
  15. bp-activity/classes/class-bp-activity-component.php +16 -16
  16. bp-activity/classes/class-bp-activity-list-table.php +7 -17
  17. bp-activity/classes/class-bp-activity-oembed-extension.php +0 -329
  18. bp-activity/css/mentions-rtl.css +3 -2
  19. bp-activity/css/mentions-rtl.min.css +1 -1
  20. bp-activity/css/mentions.css +3 -3
  21. bp-activity/css/mentions.min.css +1 -1
  22. bp-activity/js/mentions.js +1 -1
  23. bp-activity/js/mentions.min.js +2 -1
  24. bp-blogs/bp-blogs-activity.php +1 -135
  25. bp-blogs/bp-blogs-filters.php +1 -0
  26. bp-blogs/bp-blogs-functions.php +161 -130
  27. bp-blogs/bp-blogs-loader.php +1 -3
  28. bp-blogs/bp-blogs-screens.php +1 -3
  29. bp-blogs/bp-blogs-template.php +22 -34
  30. bp-blogs/bp-blogs-widgets.php +1 -3
  31. bp-blogs/classes/class-bp-blogs-component.php +2 -13
  32. bp-blogs/classes/class-bp-blogs-recent-posts-widget.php +2 -3
  33. bp-core/admin/bp-core-admin-actions.php +9 -0
  34. bp-core/admin/bp-core-admin-components.php +94 -27
  35. bp-core/admin/bp-core-admin-functions.php +18 -26
  36. bp-core/admin/bp-core-admin-schema.php +22 -0
  37. bp-core/admin/bp-core-admin-settings.php +16 -0
  38. bp-core/admin/bp-core-admin-slugs.php +1 -0
  39. bp-core/admin/bp-core-admin-tools.php +1 -25
  40. bp-core/admin/css/common-rtl.css +78 -202
  41. bp-core/admin/css/common-rtl.min.css +1 -1
  42. bp-core/admin/css/common.css +78 -202
  43. bp-core/admin/css/common.min.css +1 -1
  44. bp-core/admin/images/activity-embeds.png +0 -0
  45. bp-core/admin/images/autolink-feature.png +0 -0
  46. bp-core/admin/images/bp-emails-feature.png +0 -0
  47. bp-core/admin/images/default-themes.png +0 -0
  48. bp-core/admin/images/emoji-feature.png +0 -0
  49. bp-core/admin/images/group-type-pop.png +0 -0
  50. bp-core/admin/images/new-nav-api.png +0 -0
  51. bp-core/admin/images/post-type.png +0 -0
  52. bp-core/admin/images/twentytwelve.png +0 -0
  53. bp-core/admin/images/user-frontpage.png +0 -0
  54. bp-core/admin/js/customizer-controls.min.js +1 -0
  55. bp-core/admin/js/customizer-receiver-emails.min.js +1 -0
  56. bp-core/bp-core-actions.php +0 -2
  57. bp-core/bp-core-admin.php +2 -3
  58. bp-core/bp-core-adminbar.php +11 -0
  59. bp-core/bp-core-attachments.php +1 -1
  60. bp-core/bp-core-avatars.php +28 -58
  61. bp-core/bp-core-buddybar.php +158 -226
  62. bp-core/bp-core-caps.php +17 -0
  63. bp-core/bp-core-catchuri.php +7 -71
  64. bp-core/bp-core-classes.php +0 -8
  65. bp-core/bp-core-component.php +1 -3
  66. bp-core/bp-core-cssjs.php +2 -0
  67. bp-core/bp-core-customizer-email.php +4 -6
  68. bp-core/bp-core-dependency.php +29 -50
  69. bp-core/bp-core-filters.php +6 -0
  70. bp-core/bp-core-functions.php +64 -164
  71. bp-core/bp-core-loader.php +1 -4
  72. bp-core/bp-core-moderation.php +27 -28
  73. bp-core/bp-core-options.php +40 -0
  74. bp-core/bp-core-taxonomy.php +17 -55
  75. bp-core/bp-core-template-loader.php +15 -59
  76. bp-core/bp-core-template.php +106 -144
  77. bp-core/bp-core-theme-compatibility.php +31 -7
  78. bp-core/bp-core-update.php +18 -0
  79. bp-core/bp-core-widgets.php +1 -3
  80. bp-core/classes/class-bp-admin.php +61 -143
  81. bp-core/classes/class-bp-attachment-avatar.php +17 -0
  82. bp-core/classes/class-bp-attachment.php +14 -0
  83. bp-core/classes/class-bp-component.php +16 -2
  84. bp-core/classes/class-bp-core-bp-nav-backcompat.php +0 -270
  85. bp-core/classes/class-bp-core-bp-options-nav-backcompat.php +0 -138
  86. bp-core/classes/class-bp-core-login-widget.php +2 -3
  87. bp-core/classes/class-bp-core-nav-item.php +0 -34
  88. bp-core/classes/class-bp-core-nav.php +0 -402
  89. bp-core/classes/class-bp-core-oembed-extension.php +0 -616
  90. bp-core/classes/class-bp-core-user.php +13 -1
  91. bp-core/classes/class-bp-core.php +1 -6
  92. bp-core/classes/class-bp-email-recipient.php +13 -36
  93. bp-core/classes/class-bp-embed.php +9 -0
  94. bp-core/classes/class-bp-user-query.php +6 -7
  95. bp-core/classes/class-bp-walker-category-checklist.php +1 -1
  96. bp-core/css/avatar-rtl.css +1 -1
  97. bp-core/css/avatar-rtl.min.css +1 -1
  98. bp-core/css/avatar.css +1 -1
  99. bp-core/css/avatar.min.css +1 -1
  100. bp-core/css/buddybar-rtl.css +3 -3
  101. bp-core/css/buddybar-rtl.min.css +1 -1
  102. bp-core/deprecated/1.2.php +2 -0
  103. bp-core/deprecated/1.7.php +1 -0
  104. bp-core/deprecated/2.6.php +0 -50
  105. bp-core/images/mystery-group-50.png +0 -0
  106. bp-core/images/mystery-group.png +0 -0
  107. bp-core/js/avatar.min.js +1 -0
  108. bp-core/js/bp-plupload.min.js +1 -0
  109. bp-core/js/confirm.min.js +1 -0
  110. bp-core/js/cover-image.min.js +1 -0
  111. bp-core/js/jquery-cookie.min.js +1 -0
  112. bp-core/js/jquery-query.min.js +1 -0
  113. bp-core/js/jquery-scroll-to.min.js +1 -0
  114. bp-core/js/jquery.atwho.min.js +1 -0
  115. bp-core/js/jquery.caret.min.js +1 -0
  116. bp-core/js/webcam.min.js +1 -0
  117. bp-core/js/widget-members.js +1 -12
  118. bp-core/js/widget-members.min.js +2 -1
  119. bp-forums/bp-forums-bbpress-sa.php +0 -35
  120. bp-forums/bp-forums-filters.php +0 -12
  121. bp-forums/bp-forums-functions.php +0 -50
  122. bp-forums/bp-forums-loader.php +0 -11
  123. bp-forums/bp-forums-screens.php +0 -12
  124. bp-forums/bp-forums-template.php +9 -306
  125. bp-forums/deprecated/1.6.php +6 -12
  126. bp-friends/bp-friends-activity.php +1 -1
  127. bp-friends/bp-friends-loader.php +1 -3
  128. bp-friends/bp-friends-notifications.php +3 -1
  129. bp-friends/bp-friends-screens.php +4 -16
  130. bp-friends/bp-friends-template.php +14 -20
  131. bp-friends/bp-friends-widgets.php +1 -3
  132. bp-friends/classes/class-bp-core-friends-widget.php +5 -16
  133. bp-friends/classes/class-bp-friends-component.php +6 -28
  134. bp-friends/classes/class-bp-friends-friendship.php +9 -13
  135. bp-friends/js/widget-friends.js +1 -12
  136. bp-friends/js/widget-friends.min.js +2 -1
  137. bp-groups/admin/js/admin.min.js +1 -0
  138. bp-groups/bp-groups-actions.php +6 -21
  139. bp-groups/bp-groups-activity.php +1 -2
  140. bp-groups/bp-groups-admin.php +10 -113
  141. bp-groups/bp-groups-adminbar.php +9 -9
  142. bp-groups/bp-groups-cache.php +0 -41
  143. bp-groups/bp-groups-filters.php +1 -28
  144. bp-groups/bp-groups-functions.php +48 -592
  145. bp-groups/bp-groups-loader.php +1 -3
  146. bp-groups/bp-groups-screens.php +11 -54
  147. bp-groups/bp-groups-template.php +118 -116
  148. bp-groups/bp-groups-widgets.php +1 -3
  149. bp-groups/classes/class-bp-group-extension.php +3 -3
  150. bp-groups/classes/class-bp-groups-component.php +10 -63
  151. bp-groups/classes/class-bp-groups-group.php +107 -148
  152. bp-groups/classes/class-bp-groups-list-table.php +6 -13
  153. bp-groups/classes/class-bp-groups-member.php +0 -45
  154. bp-groups/classes/class-bp-groups-template.php +29 -35
  155. bp-groups/classes/class-bp-groups-widget.php +5 -15
  156. bp-groups/js/widget-groups.js +1 -12
  157. bp-groups/js/widget-groups.min.js +2 -1
  158. bp-loader.php +21 -140
  159. bp-members/admin/css/admin-rtl.css +8 -98
  160. bp-members/admin/css/admin-rtl.min.css +1 -1
  161. bp-members/admin/css/admin.css +8 -98
  162. bp-members/admin/css/admin.min.css +1 -1
  163. bp-members/admin/js/admin.min.js +1 -0
  164. bp-members/bp-members-actions.php +0 -4
  165. bp-members/bp-members-activity.php +2 -2
  166. bp-members/bp-members-admin.php +1 -3
  167. bp-members/bp-members-adminbar.php +2 -2
  168. bp-members/bp-members-cache.php +1 -1
  169. bp-members/bp-members-filters.php +1 -1
  170. bp-members/bp-members-functions.php +18 -109
  171. bp-members/bp-members-loader.php +1 -5
  172. bp-members/bp-members-screens.php +4 -14
  173. bp-members/bp-members-template.php +38 -332
  174. bp-members/bp-members-widgets.php +3 -5
  175. bp-members/classes/class-bp-core-members-template.php +0 -25
  176. bp-members/classes/class-bp-core-members-widget.php +7 -22
  177. bp-members/classes/class-bp-core-recently-active-widget.php +3 -11
  178. bp-members/classes/class-bp-core-whos-online-widget.php +3 -11
  179. bp-members/classes/class-bp-members-admin.php +8 -23
  180. bp-members/classes/class-bp-members-component.php +28 -116
  181. bp-members/classes/class-bp-members-list-table.php +9 -12
  182. bp-members/classes/class-bp-members-ms-list-table.php +8 -11
  183. bp-members/classes/class-bp-signup.php +0 -10
  184. bp-messages/bp-messages-functions.php +6 -6
  185. bp-messages/bp-messages-loader.php +1 -3
  186. bp-messages/bp-messages-notifications.php +21 -64
  187. bp-messages/bp-messages-screens.php +3 -12
  188. bp-messages/bp-messages-template.php +19 -30
  189. bp-messages/bp-messages-widgets.php +1 -3
  190. bp-messages/classes/class-bp-messages-component.php +4 -23
  191. bp-messages/classes/class-bp-messages-sitewide-notices-widget.php +2 -3
  192. bp-messages/css/autocomplete/jquery.autocompletefb-rtl.css +2 -2
  193. bp-messages/css/autocomplete/jquery.autocompletefb-rtl.min.css +1 -1
  194. bp-messages/js/autocomplete/jquery.autocomplete.js +1 -2
  195. bp-messages/js/autocomplete/jquery.autocomplete.min.js +2 -1
  196. bp-messages/js/autocomplete/jquery.autocompletefb.js +1 -1
  197. bp-messages/js/autocomplete/jquery.autocompletefb.min.js +2 -1
  198. bp-messages/js/autocomplete/jquery.bgiframe.min.js +1 -0
  199. bp-messages/js/autocomplete/jquery.dimensions.min.js +1 -0
  200. bp-notifications/bp-notifications-functions.php +14 -33
  201. bp-notifications/bp-notifications-loader.php +1 -3
  202. bp-notifications/bp-notifications-template.php +102 -204
  203. bp-notifications/classes/class-bp-notifications-component.php +4 -29
  204. bp-notifications/classes/class-bp-notifications-notification.php +1 -12
  205. bp-settings/bp-settings-actions.php +1 -1
  206. bp-settings/bp-settings-loader.php +1 -3
  207. bp-settings/bp-settings-template.php +7 -8
  208. bp-templates/bp-legacy/buddypress-functions.php +62 -35
  209. bp-templates/bp-legacy/buddypress/activity/entry.php +1 -4
  210. bp-templates/bp-legacy/buddypress/activity/post-form.php +2 -8
  211. bp-templates/bp-legacy/buddypress/assets/_attachments/uploader.php +1 -4
  212. bp-templates/bp-legacy/buddypress/assets/embeds/activity.php +0 -11
  213. bp-templates/bp-legacy/buddypress/assets/embeds/footer.php +0 -9
  214. bp-templates/bp-legacy/buddypress/assets/embeds/header-activity.php +0 -26
  215. bp-templates/bp-legacy/buddypress/assets/embeds/header.php +0 -18
  216. bp-templates/bp-legacy/buddypress/groups/create.php +1 -4
  217. bp-templates/bp-legacy/buddypress/groups/single/admin.php +1 -20
  218. bp-templates/bp-legacy/buddypress/groups/single/cover-image-header.php +2 -2
  219. bp-templates/bp-legacy/buddypress/groups/single/forum/edit.php +1 -4
  220. bp-templates/bp-legacy/buddypress/groups/single/forum/topic.php +1 -4
  221. bp-templates/bp-legacy/buddypress/groups/single/group-header.php +1 -1
  222. bp-templates/bp-legacy/buddypress/groups/single/requests-loop.php +13 -22
  223. bp-templates/bp-legacy/buddypress/members/single/home.php +1 -4
  224. bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php +3 -12
  225. bp-templates/bp-legacy/buddypress/members/single/messages/single.php +2 -5
  226. bp-templates/bp-legacy/buddypress/members/single/notifications/notifications-loop.php +2 -8
  227. bp-templates/bp-legacy/buddypress/members/single/profile/change-avatar.php +1 -4
  228. bp-templates/bp-legacy/buddypress/members/single/settings/general.php +1 -4
  229. bp-templates/bp-legacy/css/buddypress-rtl.css +3 -14
  230. bp-templates/bp-legacy/css/buddypress-rtl.min.css +1 -1
  231. bp-templates/bp-legacy/css/buddypress.css +3 -14
  232. bp-templates/bp-legacy/css/buddypress.min.css +1 -1
  233. bp-templates/bp-legacy/css/embeds-activity-rtl.css +0 -152
  234. bp-templates/bp-legacy/css/embeds-activity-rtl.min.css +0 -1
  235. bp-templates/bp-legacy/css/embeds-activity.css +0 -152
  236. bp-templates/bp-legacy/css/embeds-activity.min.css +0 -1
  237. bp-templates/bp-legacy/css/twentyeleven-rtl.css +0 -2025
  238. bp-templates/bp-legacy/css/twentyeleven-rtl.min.css +0 -1
  239. bp-templates/bp-legacy/css/twentyeleven.css +0 -2025
  240. bp-templates/bp-legacy/css/twentyeleven.min.css +0 -1
  241. bp-templates/bp-legacy/css/twentyeleven.scss +0 -2577
  242. bp-templates/bp-legacy/css/twentysixteen.scss +2 -0
  243. bp-templates/bp-legacy/css/twentyten-rtl.css +0 -1976
  244. bp-templates/bp-legacy/css/twentyten-rtl.min.css +0 -1
  245. bp-templates/bp-legacy/css/twentyten.css +0 -1976
  246. bp-templates/bp-legacy/css/twentyten.min.css +0 -1
  247. bp-templates/bp-legacy/css/twentyten.scss +0 -2478
  248. bp-templates/bp-legacy/js/buddypress.js +16 -32
  249. bp-templates/bp-legacy/js/buddypress.min.js +3 -2
  250. bp-templates/bp-legacy/js/password-verify.min.js +1 -0
  251. bp-themes/bp-default/groups/single/home.php +0 -3
  252. bp-xprofile/admin/js/admin.min.js +1 -0
  253. bp-xprofile/bp-xprofile-actions.php +2 -2
  254. bp-xprofile/bp-xprofile-activity.php +5 -0
  255. bp-xprofile/bp-xprofile-admin.php +10 -19
  256. bp-xprofile/bp-xprofile-caps.php +3 -0
  257. bp-xprofile/bp-xprofile-filters.php +9 -8
  258. bp-xprofile/bp-xprofile-functions.php +11 -54
  259. bp-xprofile/bp-xprofile-loader.php +1 -5
  260. bp-xprofile/bp-xprofile-screens.php +7 -6
  261. bp-xprofile/bp-xprofile-settings.php +2 -0
  262. bp-xprofile/bp-xprofile-template.php +22 -161
  263. bp-xprofile/classes/class-bp-xprofile-component.php +2 -16
  264. bp-xprofile/classes/class-bp-xprofile-data-template.php +0 -21
  265. bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php +6 -9
  266. bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php +46 -68
  267. bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php +1 -4
  268. bp-xprofile/classes/class-bp-xprofile-field-type-number.php +1 -4
  269. bp-xprofile/classes/class-bp-xprofile-field-type-radiobutton.php +8 -11
  270. bp-xprofile/classes/class-bp-xprofile-field-type-selectbox.php +1 -4
  271. bp-xprofile/classes/class-bp-xprofile-field-type-textbox.php +1 -4
  272. bp-xprofile/classes/class-bp-xprofile-field-type-url.php +1 -4
  273. bp-xprofile/classes/class-bp-xprofile-field-type.php +1 -4
  274. bp-xprofile/classes/class-bp-xprofile-field.php +12 -18
  275. bp-xprofile/classes/class-bp-xprofile-group.php +8 -26
  276. bp-xprofile/classes/class-bp-xprofile-meta-query.php +4 -1
  277. bp-xprofile/classes/class-bp-xprofile-profiledata.php +6 -47
  278. bp-xprofile/classes/class-bp-xprofile-user-admin.php +17 -39
  279. buddypress.pot +1875 -2117
  280. readme.txt +161 -32
bp-activity/admin/js/admin.min.js CHANGED
@@ -1 +1,2 @@
1
!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.5.3 - 2016-05-24 5:17:45 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
!function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
bp-activity/bp-activity-actions.php CHANGED
@@ -17,6 +17,7 @@ defined( 'ABSPATH' ) || exit;
17
*
18
* @since 1.2.0
19
*
20
*/
21
function bp_register_activity_actions() {
22
@@ -34,6 +35,18 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
34
*
35
* @since 1.2.0
36
*
37
* @return bool False on failure.
38
*/
39
function bp_activity_action_permalink_router() {
@@ -109,6 +122,17 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
109
*
110
* @since 1.1.0
111
*
112
* @param int $activity_id Activity id to be deleted. Defaults to 0.
113
* @return bool False on failure.
114
*/
@@ -243,6 +267,20 @@ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
243
*
244
* @since 1.2.0
245
*
246
* @return bool False on failure.
247
*/
248
function bp_activity_action_post_update() {
@@ -333,6 +371,17 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
333
*
334
* @since 1.2.0
335
*
336
* @return bool False on failure.
337
*/
338
function bp_activity_action_post_comment() {
@@ -386,6 +435,16 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
386
*
387
* @since 1.2.0
388
*
389
* @return bool False on failure.
390
*/
391
function bp_activity_action_mark_favorite() {
@@ -410,6 +469,16 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
410
*
411
* @since 1.2.0
412
*
413
* @return bool False on failure.
414
*/
415
function bp_activity_action_remove_favorite() {
@@ -434,6 +503,11 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
434
*
435
* @since 1.0.0
436
*
437
* @return bool False on failure.
438
*/
439
function bp_activity_action_sitewide_feed() {
@@ -461,6 +535,10 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
461
*
462
* @since 1.0.0
463
*
464
* @return bool False on failure.
465
*/
466
function bp_activity_action_personal_feed() {
@@ -487,6 +565,13 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
487
*
488
* @since 1.0.0
489
*
490
* @return bool False on failure.
491
*/
492
function bp_activity_action_friends_feed() {
@@ -513,6 +598,13 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
513
*
514
* @since 1.2.0
515
*
516
* @return bool False on failure.
517
*/
518
function bp_activity_action_my_groups_feed() {
@@ -547,6 +639,11 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
547
*
548
* @since 1.2.0
549
*
550
* @return bool False on failure.
551
*/
552
function bp_activity_action_mentions_feed() {
@@ -579,6 +676,11 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
579
*
580
* @since 1.2.0
581
*
582
* @return bool False on failure.
583
*/
584
function bp_activity_action_favorites_feed() {
17
*
18
* @since 1.2.0
19
*
20
+ * @uses do_action() To call 'bp_register_activity_actions' hook.
21
*/
22
function bp_register_activity_actions() {
23
35
*
36
* @since 1.2.0
37
*
38
+ * @uses bp_is_activity_component()
39
+ * @uses bp_is_current_action()
40
+ * @uses bp_action_variable()
41
+ * @uses bp_activity_get_specific()
42
+ * @uses bp_is_active()
43
+ * @uses bp_core_get_user_domain()
44
+ * @uses groups_get_group()
45
+ * @uses bp_get_group_permalink()
46
+ * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook.
47
+ * @uses bp_core_redirect()
48
+ * @uses bp_get_root_domain()
49
+ *
50
* @return bool False on failure.
51
*/
52
function bp_activity_action_permalink_router() {
122
*
123
* @since 1.1.0
124
*
125
+ * @uses bp_is_activity_component()
126
+ * @uses bp_is_current_action()
127
+ * @uses bp_action_variable()
128
+ * @uses check_admin_referer()
129
+ * @uses bp_activity_user_can_delete()
130
+ * @uses do_action() Calls 'bp_activity_before_action_delete_activity' hook to allow actions to be taken before the activity is deleted.
131
+ * @uses bp_activity_delete()
132
+ * @uses bp_core_add_message()
133
+ * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
134
+ * @uses bp_core_redirect()
135
+ *
136
* @param int $activity_id Activity id to be deleted. Defaults to 0.
137
* @return bool False on failure.
138
*/
267
*
268
* @since 1.2.0
269
*
270
+ * @uses is_user_logged_in()
271
+ * @uses bp_is_activity_component()
272
+ * @uses bp_is_current_action()
273
+ * @uses check_admin_referer()
274
+ * @uses apply_filters() To call 'bp_activity_post_update_content' hook.
275
+ * @uses apply_filters() To call 'bp_activity_post_update_object' hook.
276
+ * @uses apply_filters() To call 'bp_activity_post_update_item_id' hook.
277
+ * @uses bp_core_add_message()
278
+ * @uses bp_core_redirect()
279
+ * @uses bp_activity_post_update()
280
+ * @uses groups_post_update()
281
+ * @uses bp_core_redirect()
282
+ * @uses apply_filters() To call 'bp_activity_custom_update' hook.
283
+ *
284
* @return bool False on failure.
285
*/
286
function bp_activity_action_post_update() {
371
*
372
* @since 1.2.0
373
*
374
+ * @uses is_user_logged_in()
375
+ * @uses bp_is_activity_component()
376
+ * @uses bp_is_current_action()
377
+ * @uses check_admin_referer()
378
+ * @uses apply_filters() To call 'bp_activity_post_comment_activity_id' hook.
379
+ * @uses apply_filters() To call 'bp_activity_post_comment_content' hook.
380
+ * @uses bp_core_add_message()
381
+ * @uses bp_core_redirect()
382
+ * @uses bp_activity_new_comment()
383
+ * @uses wp_get_referer()
384
+ *
385
* @return bool False on failure.
386
*/
387
function bp_activity_action_post_comment() {
435
*
436
* @since 1.2.0
437
*
438
+ * @uses is_user_logged_in()
439
+ * @uses bp_is_activity_component()
440
+ * @uses bp_is_current_action()
441
+ * @uses check_admin_referer()
442
+ * @uses bp_activity_add_user_favorite()
443
+ * @uses bp_action_variable()
444
+ * @uses bp_core_add_message()
445
+ * @uses bp_core_redirect()
446
+ * @uses wp_get_referer()
447
+ *
448
* @return bool False on failure.
449
*/
450
function bp_activity_action_mark_favorite() {
469
*
470
* @since 1.2.0
471
*
472
+ * @uses is_user_logged_in()
473
+ * @uses bp_is_activity_component()
474
+ * @uses bp_is_current_action()
475
+ * @uses check_admin_referer()
476
+ * @uses bp_activity_remove_user_favorite()
477
+ * @uses bp_action_variable()
478
+ * @uses bp_core_add_message()
479
+ * @uses bp_core_redirect()
480
+ * @uses wp_get_referer()
481
+ *
482
* @return bool False on failure.
483
*/
484
function bp_activity_action_remove_favorite() {
503
*
504
* @since 1.0.0
505
*
506
+ * @uses bp_is_activity_component()
507
+ * @uses bp_is_current_action()
508
+ * @uses bp_is_user()
509
+ * @uses status_header()
510
+ *
511
* @return bool False on failure.
512
*/
513
function bp_activity_action_sitewide_feed() {
535
*
536
* @since 1.0.0
537
*
538
+ * @uses bp_is_user_activity()
539
+ * @uses bp_is_current_action()
540
+ * @uses status_header()
541
+ *
542
* @return bool False on failure.
543
*/
544
function bp_activity_action_personal_feed() {
565
*
566
* @since 1.0.0
567
*
568
+ * @uses bp_is_active()
569
+ * @uses bp_is_user_activity()
570
+ * @uses bp_is_current_action()
571
+ * @uses bp_get_friends_slug()
572
+ * @uses bp_is_action_variable()
573
+ * @uses status_header()
574
+ *
575
* @return bool False on failure.
576
*/
577
function bp_activity_action_friends_feed() {
598
*
599
* @since 1.2.0
600
*
601
+ * @uses bp_is_active()
602
+ * @uses bp_is_user_activity()
603
+ * @uses bp_is_current_action()
604
+ * @uses bp_get_groups_slug()
605
+ * @uses bp_is_action_variable()
606
+ * @uses status_header()
607
+ *
608
* @return bool False on failure.
609
*/
610
function bp_activity_action_my_groups_feed() {
639
*
640
* @since 1.2.0
641
*
642
+ * @uses bp_is_user_activity()
643
+ * @uses bp_is_current_action()
644
+ * @uses bp_is_action_variable()
645
+ * @uses status_header()
646
+ *
647
* @return bool False on failure.
648
*/
649
function bp_activity_action_mentions_feed() {
676
*
677
* @since 1.2.0
678
*
679
+ * @uses bp_is_user_activity()
680
+ * @uses bp_is_current_action()
681
+ * @uses bp_is_action_variable()
682
+ * @uses status_header()
683
+ *
684
* @return bool False on failure.
685
*/
686
function bp_activity_action_favorites_feed() {
bp-activity/bp-activity-admin.php CHANGED
@@ -16,9 +16,7 @@ defined( 'ABSPATH' ) || exit;
16
// Include WP's list table class.
17
if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
18
19
- if ( ! buddypress()->do_autoload ) {
20
- require dirname( __FILE__ ) . '/classes/class-bp-activity-list-table.php';
21
- }
22
23
// Per_page screen option. Has to be hooked in extremely early.
24
if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['page'] )
@@ -301,7 +299,6 @@ function bp_activity_admin_load() {
301
// Add accessible hidden heading and text for Activity screen pagination.
302
if ( bp_get_major_wp_version() >= 4.4 ) {
303
get_current_screen()->set_screen_reader_content( array(
304
- /* translators: accessibility text */
305
'heading_pagination' => __( 'Activity list navigation', 'buddypress' ),
306
) );
307
}
@@ -579,9 +576,9 @@ function bp_activity_admin_load() {
579
580
// If an error occurred, pass back the activity ID that failed.
581
if ( $error )
582
- $redirect_to = add_query_arg( 'error', $error, $redirect_to );
583
else
584
- $redirect_to = add_query_arg( 'updated', $activity->id, $redirect_to );
585
586
/**
587
* Filters URL to redirect to after saving.
@@ -677,10 +674,6 @@ function bp_activity_admin_edit() {
677
<div id="bp_activity_action" class="postbox">
678
<h2><?php _e( 'Action', 'buddypress' ); ?></h2>
679
<div class="inside">
680
- <label for="bp-activities-action" class="screen-reader-text"><?php
681
- /* translators: accessibility text */
682
- _e( 'Edit activity action', 'buddypress' );
683
- ?></label>
684
<?php wp_editor( stripslashes( $activity->action ), 'bp-activities-action', array( 'media_buttons' => false, 'textarea_rows' => 7, 'teeny' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?>
685
</div>
686
</div>
@@ -688,10 +681,6 @@ function bp_activity_admin_edit() {
688
<div id="bp_activity_content" class="postbox">
689
<h2><?php _e( 'Content', 'buddypress' ); ?></h2>
690
<div class="inside">
691
- <label for="bp-activities-content" class="screen-reader-text"><?php
692
- /* translators: accessibility text */
693
- _e( 'Edit activity content', 'buddypress' );
694
- ?></label>
695
<?php wp_editor( stripslashes( $activity->content ), 'bp-activities-content', array( 'media_buttons' => false, 'teeny' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?>
696
</div>
697
</div>
@@ -715,16 +704,10 @@ function bp_activity_admin_edit() {
715
</form>
716
717
<?php else : ?>
718
-
719
- <p><?php
720
- printf(
721
- '%1$s <a href="%2$s">%3$s</a>',
722
- __( 'No activity found with this ID.', 'buddypress' ),
723
- esc_url( bp_get_admin_url( 'admin.php?page=bp-activity' ) ),
724
- __( 'Go back and try again.', 'buddypress' )
725
- );
726
- ?></p>
727
-
728
<?php endif; ?>
729
730
</div><!-- .wrap -->
@@ -798,10 +781,7 @@ function bp_activity_admin_edit_metabox_status( $item ) {
798
function bp_activity_admin_edit_metabox_link( $item ) {
799
?>
800
801
- <label class="screen-reader-text" for="bp-activities-link"><?php
802
- /* translators: accessibility text */
803
- _e( 'Link', 'buddypress' );
804
- ?></label>
805
<input type="url" name="bp-activities-link" id="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" aria-describedby="bp-activities-link-description" />
806
<p id="bp-activities-link-description"><?php _e( 'Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
807
@@ -818,10 +798,7 @@ function bp_activity_admin_edit_metabox_link( $item ) {
818
function bp_activity_admin_edit_metabox_userid( $item ) {
819
?>
820
821
- <label class="screen-reader-text" for="bp-activities-userid"><?php
822
- /* translators: accessibility text */
823
- _e( 'Author ID', 'buddypress' );
824
- ?></label>
825
<input type="number" name="bp-activities-userid" id="bp-activities-userid" value="<?php echo esc_attr( $item->user_id ); ?>" min="1" />
826
827
<?php
@@ -896,10 +873,7 @@ function bp_activity_admin_edit_metabox_type( $item ) {
896
897
?>
898
899
- <label for="bp-activities-type" class="screen-reader-text"><?php
900
- /* translators: accessibility text */
901
- esc_html_e( 'Select activity type', 'buddypress' );
902
- ?></label>
903
<select name="bp-activities-type" id="bp-activities-type">
904
<?php foreach ( $actions as $k => $v ) : ?>
905
<option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option>
@@ -1042,10 +1016,6 @@ function bp_activity_admin_index() {
1042
<form method="get" action="">
1043
1044
<h3 id="bp-replyhead"><?php _e( 'Reply to Activity', 'buddypress' ); ?></h3>
1045
- <label for="bp-activities" class="screen-reader-text"><?php
1046
- /* translators: accessibility text */
1047
- _e( 'Reply', 'buddypress' );
1048
- ?></label>
1049
<?php wp_editor( '', 'bp-activities', array( 'dfw' => false, 'media_buttons' => false, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ), 'tinymce' => false, ) ); ?>
1050
1051
<p id="bp-replysubmit" class="submit">
16
// Include WP's list table class.
17
if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
18
19
+ require dirname( __FILE__ ) . '/classes/class-bp-activity-list-table.php';
20
21
// Per_page screen option. Has to be hooked in extremely early.
22
if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['page'] )
299
// Add accessible hidden heading and text for Activity screen pagination.
300
if ( bp_get_major_wp_version() >= 4.4 ) {
301
get_current_screen()->set_screen_reader_content( array(
302
'heading_pagination' => __( 'Activity list navigation', 'buddypress' ),
303
) );
304
}
576
577
// If an error occurred, pass back the activity ID that failed.
578
if ( $error )
579
+ $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
580
else
581
+ $redirect_to = add_query_arg( 'updated', (int) $activity->id, $redirect_to );
582
583
/**
584
* Filters URL to redirect to after saving.
674
<div id="bp_activity_action" class="postbox">
675
<h2><?php _e( 'Action', 'buddypress' ); ?></h2>
676
<div class="inside">
677
<?php wp_editor( stripslashes( $activity->action ), 'bp-activities-action', array( 'media_buttons' => false, 'textarea_rows' => 7, 'teeny' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?>
678
</div>
679
</div>
681
<div id="bp_activity_content" class="postbox">
682
<h2><?php _e( 'Content', 'buddypress' ); ?></h2>
683
<div class="inside">
684
<?php wp_editor( stripslashes( $activity->content ), 'bp-activities-content', array( 'media_buttons' => false, 'teeny' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?>
685
</div>
686
</div>
704
</form>
705
706
<?php else : ?>
707
+ <p>
708
+ <?php _e( 'No activity found with this ID.', 'buddypress' ); ?>
709
+ <a href="<?php echo esc_url( bp_get_admin_url( 'admin.php?page=bp-activity' ) ); ?>"><?php _e( 'Go back and try again.', 'buddypress' ); ?></a>
710
+ </p>
711
<?php endif; ?>
712
713
</div><!-- .wrap -->
781
function bp_activity_admin_edit_metabox_link( $item ) {
782
?>
783
784
+ <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label>
785
<input type="url" name="bp-activities-link" id="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" aria-describedby="bp-activities-link-description" />
786
<p id="bp-activities-link-description"><?php _e( 'Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
787
798
function bp_activity_admin_edit_metabox_userid( $item ) {
799
?>
800
801
+ <label class="screen-reader-text" for="bp-activities-userid"><?php _e( 'Author ID', 'buddypress' ); ?></label>
802
<input type="number" name="bp-activities-userid" id="bp-activities-userid" value="<?php echo esc_attr( $item->user_id ); ?>" min="1" />
803
804
<?php
873
874
?>
875
876
+ <label for="bp-activities-type" class="screen-reader-text"><?php esc_html_e( 'Select activity type', 'buddypress' ); ?></label>
877
<select name="bp-activities-type" id="bp-activities-type">
878
<?php foreach ( $actions as $k => $v ) : ?>
879
<option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option>
1016
<form method="get" action="">
1017
1018
<h3 id="bp-replyhead"><?php _e( 'Reply to Activity', 'buddypress' ); ?></h3>
1019
<?php wp_editor( '', 'bp-activities', array( 'dfw' => false, 'media_buttons' => false, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ), 'tinymce' => false, ) ); ?>
1020
1021
<p id="bp-replysubmit" class="submit">
bp-activity/bp-activity-adminbar.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Activity Toolbar.
4
- *
5
- * Handles the activity functions related to the WordPress Toolbar.
6
- *
7
- * @package BuddyPress
8
- * @subpackage Activity
9
- */
10
-
11
- // Exit if accessed directly.
12
- defined( 'ABSPATH' ) || exit;
13
-
14
- /**
15
- * Add the Activity top-level menu link when viewing single activity item.
16
- *
17
- * @since 2.6.0
18
- *
19
- * @return null Null if user does not have access to editing functionality.
20
- */
21
- function bp_activity_admin_menu() {
22
- global $wp_admin_bar;
23
-
24
- // Only show if viewing a single activity item.
25
- if ( ! bp_is_single_activity() ) {
26
- return;
27
- }
28
-
29
- // Only show this menu to super admins
30
- if ( ! bp_current_user_can( 'bp_moderate' ) ) {
31
- return;
32
- }
33
-
34
- $activity_edit_link = add_query_arg( array(
35
- 'page' => 'bp-activity',
36
- 'aid' => bp_current_action(),
37
- 'action' => 'edit'
38
- ), bp_get_admin_url( 'admin.php' ) );
39
-
40
- // Add the top-level Edit Activity button.
41
- $wp_admin_bar->add_menu( array(
42
- 'id' => 'activity-admin',
43
- 'title' => __( 'Edit Activity', 'buddypress' ),
44
- 'href' => esc_url( $activity_edit_link ),
45
- ) );
46
- }
47
- add_action( 'admin_bar_menu', 'bp_activity_admin_menu', 99 );
bp-activity/bp-activity-akismet.php CHANGED
@@ -10,9 +10,7 @@
10
// Exit if accessed directly.
11
defined( 'ABSPATH' ) || exit;
12
13
- if ( ! buddypress()->do_autoload ) {
14
- require dirname( __FILE__ ) . '/classes/class-bp-akismet.php';
15
- }
16
17
/**
18
* Delete old spam activity meta data.
10
// Exit if accessed directly.
11
defined( 'ABSPATH' ) || exit;
12
13
+ require dirname( __FILE__ ) . '/classes/class-bp-akismet.php';
14
15
/**
16
* Delete old spam activity meta data.
bp-activity/bp-activity-classes.php CHANGED
@@ -13,8 +13,3 @@ defined( 'ABSPATH' ) || exit;
13
require dirname( __FILE__ ) . '/classes/class-bp-activity-activity.php';
14
require dirname( __FILE__ ) . '/classes/class-bp-activity-feed.php';
15
require dirname( __FILE__ ) . '/classes/class-bp-activity-query.php';
16
-
17
- // Embeds - only applicable for WP 4.5+
18
- if ( version_compare( $GLOBALS['wp_version'], '4.5', '>=' ) && bp_is_active( 'activity', 'embeds' ) ) {
19
- require dirname( __FILE__ ) . '/classes/class-bp-activity-oembed-extension.php';
20
- }
13
require dirname( __FILE__ ) . '/classes/class-bp-activity-activity.php';
14
require dirname( __FILE__ ) . '/classes/class-bp-activity-feed.php';
15
require dirname( __FILE__ ) . '/classes/class-bp-activity-query.php';
bp-activity/bp-activity-embeds.php DELETED
@@ -1,352 +0,0 @@
1
- <?php
2
- /**
3
- * Functions related to embedding single activity items externally.
4
- *
5
- * Relies on WordPress 4.5.
6
- *
7
- * @since 2.6.0
8
- *
9
- * @package BuddyPress
10
- * @subpackage ActivityEmbeds
11
- */
12
-
13
- // Exit if accessed directly.
14
- defined( 'ABSPATH' ) || exit;
15
-
16
- /**
17
- * Loads our activity oEmbed component.
18
- *
19
- * @since 2.6.0
20
- */
21
- function bp_activity_setup_oembed() {
22
- if ( version_compare( $GLOBALS['wp_version'], '4.5', '>=' ) && bp_is_active( 'activity', 'embeds' ) ) {
23
- buddypress()->activity->oembed = new BP_Activity_oEmbed_Extension;
24
- }
25
- }
26
- add_action( 'bp_loaded', 'bp_activity_setup_oembed' );
27
-
28
- /**
29
- * Catch links in embed excerpt so top.location.href can be added.
30
- *
31
- * Due to <iframe sandbox="allow-top-navigation">, links in embeds can only be
32
- * clicked if invoked with top.location.href via JS.
33
- *
34
- * @since 2.6.0
35
- *
36
- * @param string $text Embed excerpt
37
- * @return string
38
- */
39
- function bp_activity_embed_excerpt_onclick_location_filter( $text ) {
40
- return preg_replace_callback( '/<a\s+[^>]*href=\"([^\"]*)\"/iU', 'bp_activity_embed_excerpt_onclick_location_filter_callback', $text );
41
- }
42
- /**
43
- * Add onclick="top.location.href" to a link.
44
- *
45
- * @since 2.6.0
46
- *
47
- * @param array $matches Items matched by bp_activity_embed_excerpt_onclick_location_filter().
48
- * @return string
49
- */
50
- function bp_activity_embed_excerpt_onclick_location_filter_callback( $matches ) {
51
- return sprintf( '<a href="%1$s" onclick="top.location.href=\'%1$s\'"', $matches[1] );
52
- }
53
-
54
- /**
55
- * Add inline styles for BP activity embeds.
56
- *
57
- * @since 2.6.0
58
- */
59
- function bp_activity_embed_add_inline_styles() {
60
- if ( false === bp_is_single_activity() ) {
61
- return;
62
- }
63
-
64
- $min = bp_core_get_minified_asset_suffix();
65
-
66
- if ( is_rtl() ) {
67
- $css = bp_locate_template_asset( "css/embeds-activity-rtl{$min}.css" );
68
- } else {
69
- $css = bp_locate_template_asset( "css/embeds-activity{$min}.css" );
70
- }
71
-
72
- // Bail if file wasn't found.
73
- if ( false === $css ) {
74
- return;
75
- }
76
-
77
- // Grab contents of CSS file and do some rudimentary CSS protection.
78
- $css = file_get_contents( $css['file'] );
79
- $css = wp_kses( $css, array( "\'", '\"' ) );
80
-
81
- printf( '<style type="text/css">%s</style>', $css );
82
- }
83
- add_action( 'embed_head', 'bp_activity_embed_add_inline_styles', 20 );
84
-
85
- /**
86
- * Query for the activity item on the activity embed template.
87
- *
88
- * Basically a wrapper for {@link bp_has_activities()}, but allows us to
89
- * use the activity loop without requerying for it again.
90
- *
91
- * @since 2.6.0
92
- *
93
- * @param int $activity_id The activity ID.
94
- * @return bool
95
- */
96
- function bp_activity_embed_has_activity( $activity_id = 0 ) {
97
- global $activities_template;
98
-
99
- if ( empty( $activity_id ) ) {
100
- return false;
101
- }
102
-
103
- if ( ! empty( $activities_template->activities ) ) {
104
- $activity = (array) $activities_template->activities;
105
- $activity = reset( $activity );
106
-
107
- // No need to requery if we already got the embed activity
108
- if ( (int) $activity_id === $activity->id ) {
109
- return $activities_template->has_activities();
110
- }
111
- }
112
-
113
- return bp_has_activities( array(
114
- 'display_comments' => 'threaded',
115
- 'show_hidden' => true,
116
- 'include' => (int) $activity_id,
117
- ) );
118
- }
119
-
120
- /**
121
- * Outputs excerpt for an activity embed item.
122
- *
123
- * @since 2.6.0
124
- */
125
- function bp_activity_embed_excerpt( $content = '' ) {
126
- echo bp_activity_get_embed_excerpt( $content = '' );
127
- }
128
-
129
- /**
130
- * Generates excerpt for an activity embed item.
131
- *
132
- * @since 2.6.0
133
- *
134
- * @param string $content The content to generate an excerpt for.
135
- * @return string
136
- */
137
- function bp_activity_get_embed_excerpt( $content = '' ) {
138
- if ( empty( $content ) && ! empty( $GLOBALS['activities_template']->in_the_loop ) ) {
139
- $content = $GLOBALS['activities_template']->activity->content;
140
- }
141
-
142
- /*
143
- * bp_activity_truncate_entry() includes the 'Read More' link, which is why
144
- * we're using this instead of bp_create_excerpt().
145
- */
146
- $content = html_entity_decode( $content );
147
- $content = bp_activity_truncate_entry( $content, array(
148
- 'html' => false,
149
- 'filter_shortcodes' => true,
150
- 'strip_tags' => true,
151
- 'force_truncate' => true
152
- ) );
153
-
154
- /**
155
- * Filter the activity embed excerpt.
156
- *
157
- * @since 2.6.0
158
- *
159
- * @var string $content Embed Excerpt.
160
- * @var string $unmodified_content Unmodified activity content.
161
- */
162
- return apply_filters( 'bp_activity_get_embed_excerpt', $content, $GLOBALS['activities_template']->activity->content );
163
- }
164
-
165
- /**
166
- * Outputs the first embedded item in the activity oEmbed template.
167
- *
168
- * @since 2.6.0
169
- */
170
- function bp_activity_embed_media() {
171
- // Bail if oEmbed request explicitly hides media.
172
- if ( isset( $_GET['hide_media'] ) && true == wp_validate_boolean( $_GET['hide_media'] ) ) {
173
- /**
174
- * Do something after media is rendered for an activity oEmbed item.
175
- *
176
- * @since 2.6.0
177
- */
178
- do_action( 'bp_activity_embed_after_media' );
179
-
180
- return;
181
- }
182
-
183
- /**
184
- * Should we display media in the oEmbed template?
185
- *
186
- * @since 2.6.0
187
- *
188
- * @param bool $retval Defaults to true.
189
- */
190
- $allow_media = apply_filters( 'bp_activity_embed_display_media', true );
191
-
192
- // Find oEmbeds from only WP registered providers.
193
- bp_remove_all_filters( 'oembed_providers' );
194
- $media = bp_core_extract_media_from_content( $GLOBALS['activities_template']->activity->content, 'embeds' );
195
- bp_restore_all_filters( 'oembed_providers' );
196
-
197
- // oEmbeds have precedence over inline video / audio.
198
- if ( isset( $media['embeds'] ) && true === $allow_media ) {
199
- // Autoembed first URL.
200
- $oembed_defaults = wp_embed_defaults();
201
- $oembed_args = array(
202
- 'width' => $oembed_defaults['width'],
203
- 'height' => $oembed_defaults['height'],
204
- 'discover' => true
205
- );
206
- $url = $media['embeds'][0]['url'];
207
- $cachekey = '_oembed_response_' . md5( $url . serialize( $oembed_args ) );
208
-
209
- // Try to fetch oEmbed response from meta.
210
- $oembed = bp_activity_get_meta( bp_get_activity_id(), $cachekey );
211
-
212
- // No cache, so fetch full oEmbed response now!
213
- if ( '' === $oembed ) {
214
- $o = _wp_oembed_get_object();
215
- $oembed = $o->fetch( $o->get_provider( $url, $oembed_args ), $url, $oembed_args );
216
-
217
- // Cache oEmbed response.
218
- bp_activity_update_meta( bp_get_activity_id(), $cachekey, $oembed );
219
- }
220
-
221
- $content = '';
222
-
223
- /**
224
- * Filters the default embed display max width.
225
- *
226
- * This is used if the oEmbed response does not return a thumbnail width.
227
- *
228
- * @since 2.6.0
229
- *
230
- * @param int $width.
231
- */
232
- $width = (int) apply_filters( 'bp_activity_embed_display_media_width', 550 );
233
-
234
- // Set thumbnail.
235
- if ( 'photo' === $oembed->type ) {
236
- $thumbnail = $oembed->url;
237
- } elseif ( isset( $oembed->thumbnail_url ) ) {
238
- $thumbnail = $oembed->thumbnail_url;
239
-
240
- /* Non-oEmbed standard attributes */
241
- // Mixcloud
242
- } elseif ( isset( $oembed->image ) ) {
243
- $thumbnail = $oembed->image;
244
- // ReverbNation
245
- } elseif ( isset( $oembed->{'thumbnail-url'} ) ) {
246
- $thumbnail = $oembed->{'thumbnail-url'};
247
- }
248
-
249
- // Display thumb and related oEmbed meta.
250
- if ( true === isset ( $thumbnail ) ) {
251
- $play_icon = $caption = '';
252
-
253
- // Add play icon for non-photos.
254
- if ( 'photo' !== $oembed->type ) {
255
- /**
256
- * ion-play icon from Ionicons.
257
- *
258
- * @link http://ionicons.com/
259
- * @license MIT
260
- */
261
- $play_icon = <<<EOD
262
- <svg id="Layer_1" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M405.2,232.9L126.8,67.2c-3.4-2-6.9-3.2-10.9-3.2c-10.9,0-19.8,9-19.8,20H96v344h0.1c0,11,8.9,20,19.8,20 c4.1,0,7.5-1.4,11.2-3.4l278.1-165.5c6.6-5.5,10.8-13.8,10.8-23.1C416,246.7,411.8,238.5,405.2,232.9z"/></svg>
263
- EOD;
264
-
265
- $play_icon = sprintf( '<a rel="nofollow" class="play-btn" href="%1$s" onclick="top.location.href=\'%1$s\'">%2$s</a>', esc_url( $url ), $play_icon );
266
- }
267
-
268
- // Thumb width
269
- $thumb_width = isset( $oembed->thumbnail_width ) && 'photo' !== $oembed->type && (int) $oembed->thumbnail_width < 550 ? (int) $oembed->thumbnail_width : $width;
270
-
271
- $float_width = 350;
272
-
273
- // Set up thumb.
274
- $content = sprintf( '<div class="thumb" style="max-width:%1$spx">%2$s<a href="%3$s" rel="nofollow" onclick="top.location.href=\'%3$s\'"><img src="%4$s" /></a></div>', $thumb_width, $play_icon, esc_url( $url ), esc_url( $thumbnail ) );
275
-
276
- // Show title.
277
- if ( isset( $oembed->title ) ) {
278
- $caption .= sprintf( '<p class="caption-title"><strong>%s</strong></p>', apply_filters( 'single_post_title', $oembed->title ) );
279
- }
280
-
281
- // Show description (non-oEmbed standard)
282
- if ( isset( $oembed->description ) ) {
283
- $caption .= sprintf( '<div class="caption-description">%s</div>', apply_filters( 'bp_activity_get_embed_excerpt', $oembed->description ) );
284
- }
285
-
286
- // Show author info.
287
- if ( isset( $oembed->provider_name ) && isset( $oembed->author_name ) ) {
288
- /* translators: By [oEmbed author] on [oEmbed provider]. eg. By BuddyPress on YouTube. */
289
- $anchor_text = sprintf( __( 'By %1$s on %2$s', 'buddypress' ), $oembed->author_name, $oembed->provider_name );
290
-
291
- } elseif ( isset( $oembed->provider_name ) ) {
292
- $anchor_text = sprintf( __( 'View on %s', 'buddypress' ), $oembed->provider_name );
293
- }
294
-
295
- if ( true === isset( $anchor_text ) ) {
296
- $caption .= sprintf( '<a rel="nofollow" href="%1$s" onclick="top.location.href=\'%1$s\'">%2$s</a>', esc_url( $url ), apply_filters( 'the_title', $anchor_text ) );
297
- }
298
-
299
- // Set up caption.
300
- if ( '' !== $caption ) {
301
- $css_class = isset( $oembed->provider_name ) ? sprintf( ' provider-%s', sanitize_html_class( strtolower( $oembed->provider_name ) ) ) : '';
302
- $caption = sprintf( '<div class="caption%1$s" style="width:%2$s">%3$s</div>',
303
- $css_class,
304
- $thumb_width > $float_width ? 100 . '%' : round( ( $width - (int) $thumb_width ) / $width * 100 ) . '%',
305
- $caption
306
- );
307
-
308
- $content .= $caption;
309
- }
310
- }
311
-
312
- // Print rich content.
313
- if ( '' !== $content ) {
314
- printf( '<div class="bp-activity-embed-display-media %s" style="max-width:%spx">%s</div>',
315
- $thumb_width < $float_width ? 'two-col' : 'one-col',
316
- $thumb_width < $float_width ? $width : $thumb_width,
317
- $content
318
- );
319
- }
320
-
321
- // Video / audio.
322
- } elseif ( true === $allow_media ) {
323
- // Call BP_Embed if it hasn't already loaded.
324
- bp_embed_init();
325
-
326
- // Run shortcode and embed routine.
327
- $content = buddypress()->embed->run_shortcode( $GLOBALS['activities_template']->activity->content );
328
- $content = buddypress()->embed->autoembed( $content );
329
-
330
- // Try to find inline video / audio.
331
- $media = bp_core_extract_media_from_content( $content, 96 );
332
-
333
- // Video takes precedence. HTML5-only.
334
- if ( isset( $media['videos'] ) && 'shortcodes' === $media['videos'][0]['source'] ) {
335
- printf( '<video controls preload="metadata"><source src="%1$s"><p>%2$s</p></video>',
336
- esc_url( $media['videos'][0]['url'] ),
337
- esc_html__( 'Your browser does not support HTML5 video', 'buddypress' )
338
- );
339
-
340
- // No video? Try audio. HTML5-only.
341
- } elseif ( isset( $media['audio'] ) && 'shortcodes' === $media['audio'][0]['source'] ) {
342
- printf( '<audio controls preload="metadata"><source src="%1$s"><p>%2$s</p></audio>',
343
- esc_url( $media['audio'][0]['url'] ),
344
- esc_html__( 'Your browser does not support HTML5 audio', 'buddypress' )
345
- );
346
- }
347
-
348
- }
349
-
350
- /** This hook is documented in /bp-activity/bp-activity-embeds.php */
351
- do_action( 'bp_activity_embed_after_media' );
352
- }
bp-activity/bp-activity-filters.php CHANGED
@@ -43,7 +43,6 @@ add_filter( 'bp_get_activity_content', 'wptexturize' );
43
add_filter( 'bp_get_activity_parent_content', 'wptexturize' );
44
add_filter( 'bp_get_activity_latest_update', 'wptexturize' );
45
add_filter( 'bp_get_activity_latest_update_excerpt', 'wptexturize' );
46
- add_filter( 'bp_activity_get_embed_excerpt', 'wptexturize' );
47
48
add_filter( 'bp_get_activity_action', 'convert_smilies' );
49
add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
@@ -51,7 +50,6 @@ add_filter( 'bp_get_activity_content', 'convert_smilies' );
51
add_filter( 'bp_get_activity_parent_content', 'convert_smilies' );
52
add_filter( 'bp_get_activity_latest_update', 'convert_smilies' );
53
add_filter( 'bp_get_activity_latest_update_excerpt', 'convert_smilies' );
54
- add_filter( 'bp_activity_get_embed_excerpt', 'convert_smilies' );
55
56
add_filter( 'bp_get_activity_action', 'convert_chars' );
57
add_filter( 'bp_get_activity_content_body', 'convert_chars' );
@@ -59,13 +57,11 @@ add_filter( 'bp_get_activity_content', 'convert_chars' );
59
add_filter( 'bp_get_activity_parent_content', 'convert_chars' );
60
add_filter( 'bp_get_activity_latest_update', 'convert_chars' );
61
add_filter( 'bp_get_activity_latest_update_excerpt', 'convert_chars' );
62
- add_filter( 'bp_activity_get_embed_excerpt', 'convert_chars' );
63
64
add_filter( 'bp_get_activity_action', 'wpautop' );
65
add_filter( 'bp_get_activity_content_body', 'wpautop' );
66
add_filter( 'bp_get_activity_content', 'wpautop' );
67
add_filter( 'bp_get_activity_feed_item_description', 'wpautop' );
68
- add_filter( 'bp_activity_get_embed_excerpt', 'wpautop' );
69
70
add_filter( 'bp_get_activity_action', 'make_clickable', 9 );
71
add_filter( 'bp_get_activity_content_body', 'make_clickable', 9 );
@@ -74,7 +70,6 @@ add_filter( 'bp_get_activity_parent_content', 'make_clickable', 9 );
74
add_filter( 'bp_get_activity_latest_update', 'make_clickable', 9 );
75
add_filter( 'bp_get_activity_latest_update_excerpt', 'make_clickable', 9 );
76
add_filter( 'bp_get_activity_feed_item_description', 'make_clickable', 9 );
77
- add_filter( 'bp_activity_get_embed_excerpt', 'make_clickable', 9 );
78
79
add_filter( 'bp_acomment_name', 'stripslashes_deep', 5 );
80
add_filter( 'bp_get_activity_action', 'stripslashes_deep', 5 );
@@ -99,7 +94,6 @@ add_filter( 'pre_comment_content', 'bp_activity_at_name_filter
99
add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
100
add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
101
add_filter( 'the_content', 'bp_activity_at_name_filter' );
102
- add_filter( 'bp_activity_get_embed_excerpt', 'bp_activity_at_name_filter' );
103
104
add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' );
105
@@ -109,8 +103,6 @@ add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 );
109
add_filter( 'bp_get_total_favorite_count_for_user', 'bp_core_number_format' );
110
add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
111
112
- add_filter( 'bp_activity_get_embed_excerpt', 'bp_activity_embed_excerpt_onclick_location_filter', 9 );
113
-
114
/* Actions *******************************************************************/
115
116
// At-name filter.
@@ -155,19 +147,13 @@ function bp_activity_get_moderated_activity_types() {
155
function bp_activity_check_moderation_keys( $activity ) {
156
157
// Only check specific types of activity updates.
158
- if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) ) {
159
return;
160
- }
161
162
- // Send back the error so activity update fails.
163
// @todo This is temporary until some kind of moderation is built.
164
- $moderate = bp_core_check_for_moderation( $activity->user_id, '', $activity->content, 'wp_error' );
165
- if ( is_wp_error( $moderate ) ) {
166
- $activity->errors = $moderate;
167
-
168
- // Backpat.
169
$activity->component = false;
170
- }
171
}
172
173
/**
@@ -180,19 +166,12 @@ function bp_activity_check_moderation_keys( $activity ) {
180
function bp_activity_check_blacklist_keys( $activity ) {
181
182
// Only check specific types of activity updates.
183
- if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) ) {
184
return;
185
- }
186
-
187
- // Send back the error so activity update fails.
188
- // @todo This is temporary until some kind of trash status is built.
189
- $blacklist = bp_core_check_for_blacklist( $activity->user_id, '', $activity->content, 'wp_error' );
190
- if ( is_wp_error( $blacklist ) ) {
191
- $activity->errors = $blacklist;
192
193
- // Backpat.
194
- $activity->component = false;
195
- }
196
}
197
198
/**
@@ -200,6 +179,9 @@ function bp_activity_check_blacklist_keys( $activity ) {
200
*
201
* @since 1.1.0
202
*
203
* @param string $content The activity content.
204
* @return string $content Filtered activity content.
205
*/
@@ -300,6 +282,8 @@ function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
300
*
301
* @since 1.5.0
302
*
303
* @param BP_Activity_Activity $activity Activity Object.
304
*/
305
function bp_activity_at_name_filter_updates( $activity ) {
@@ -335,6 +319,9 @@ function bp_activity_at_name_filter_updates( $activity ) {
335
*
336
* @since 1.7.0
337
*
338
* @param BP_Activity_Activity $activity The BP_Activity_Activity object.
339
*/
340
function bp_activity_at_name_send_emails( $activity ) {
@@ -408,16 +395,19 @@ function bp_activity_make_nofollow_filter( $text ) {
408
* This method can only be used inside the Activity loop.
409
*
410
* @since 1.5.0
411
- * @since 2.6.0 Added $args parameter.
412
*
413
* @param string $text The original activity entry text.
414
- * @param array $args {
415
- * Optional parameters. See $options argument of {@link bp_create_excerpt()}
416
- * for all available parameters.
417
- * }
418
* @return string $excerpt The truncated text.
419
*/
420
- function bp_activity_truncate_entry( $text, $args = array() ) {
421
global $activities_template;
422
423
/**
@@ -433,7 +423,7 @@ function bp_activity_truncate_entry( $text, $args = array() ) {
433
);
434
435
// The full text of the activity update should always show on the single activity screen.
436
- if ( empty( $args['force_truncate'] ) && ( ! $maybe_truncate_text || bp_is_single_activity() ) ) {
437
return $text;
438
}
439
@@ -455,17 +445,15 @@ function bp_activity_truncate_entry( $text, $args = array() ) {
455
*/
456
$excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
457
458
- $args = wp_parse_args( $args, array( 'ending' => __( '&hellip;', 'buddypress' ) ) );
459
-
460
// Run the text through the excerpt function. If it's too short, the original text will be returned.
461
- $excerpt = bp_create_excerpt( $text, $excerpt_length, $args );
462
463
/*
464
* If the text returned by bp_create_excerpt() is different from the original text (ie it's
465
* been truncated), add the "Read More" link. Note that bp_create_excerpt() is stripping
466
* shortcodes, so we have strip them from the $text before the comparison.
467
*/
468
- if ( strlen( $excerpt ) < strlen( strip_shortcodes( $text ) ) ) {
469
$id = !empty( $activities_template->activity->current_comment->id ) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id();
470
471
$excerpt = sprintf( '%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text );
@@ -488,6 +476,8 @@ function bp_activity_truncate_entry( $text, $args = array() ) {
488
*
489
* @since 2.0.0
490
*
491
* @param array $js_handles The original dependencies.
492
* @return array $js_handles The new dependencies.
493
*/
@@ -553,6 +543,8 @@ add_filter( 'bp_get_activity_css_class', 'bp_activity_timestamp_class', 9, 1 );
553
*
554
* @since 2.0.0
555
*
556
* @param array $response Array containing Heartbeat API response.
557
* @param array $data Array containing data for Heartbeat API response.
558
* @return array $response
43
add_filter( 'bp_get_activity_parent_content', 'wptexturize' );
44
add_filter( 'bp_get_activity_latest_update', 'wptexturize' );
45
add_filter( 'bp_get_activity_latest_update_excerpt', 'wptexturize' );
46
47
add_filter( 'bp_get_activity_action', 'convert_smilies' );
48
add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
50
add_filter( 'bp_get_activity_parent_content', 'convert_smilies' );
51
add_filter( 'bp_get_activity_latest_update', 'convert_smilies' );
52
add_filter( 'bp_get_activity_latest_update_excerpt', 'convert_smilies' );
53
54
add_filter( 'bp_get_activity_action', 'convert_chars' );
55
add_filter( 'bp_get_activity_content_body', 'convert_chars' );
57
add_filter( 'bp_get_activity_parent_content', 'convert_chars' );
58
add_filter( 'bp_get_activity_latest_update', 'convert_chars' );
59
add_filter( 'bp_get_activity_latest_update_excerpt', 'convert_chars' );
60
61
add_filter( 'bp_get_activity_action', 'wpautop' );
62
add_filter( 'bp_get_activity_content_body', 'wpautop' );
63
add_filter( 'bp_get_activity_content', 'wpautop' );
64
add_filter( 'bp_get_activity_feed_item_description', 'wpautop' );
65
66
add_filter( 'bp_get_activity_action', 'make_clickable', 9 );
67
add_filter( 'bp_get_activity_content_body', 'make_clickable', 9 );
70
add_filter( 'bp_get_activity_latest_update', 'make_clickable', 9 );
71
add_filter( 'bp_get_activity_latest_update_excerpt', 'make_clickable', 9 );
72
add_filter( 'bp_get_activity_feed_item_description', 'make_clickable', 9 );
73
74
add_filter( 'bp_acomment_name', 'stripslashes_deep', 5 );
75
add_filter( 'bp_get_activity_action', 'stripslashes_deep', 5 );
94
add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
95
add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
96
add_filter( 'the_content', 'bp_activity_at_name_filter' );
97
98
add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' );
99
103
add_filter( 'bp_get_total_favorite_count_for_user', 'bp_core_number_format' );
104
add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
105
106
/* Actions *******************************************************************/
107
108
// At-name filter.
147
function bp_activity_check_moderation_keys( $activity ) {
148
149
// Only check specific types of activity updates.
150
+ if ( !in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
151
return;
152
153
+ // Unset the activity component so activity stream update fails
154
// @todo This is temporary until some kind of moderation is built.
155
+ if ( !bp_core_check_for_moderation( $activity->user_id, '', $activity->content ) )
156
$activity->component = false;
157
}
158
159
/**
166
function bp_activity_check_blacklist_keys( $activity ) {
167
168
// Only check specific types of activity updates.
169
+ if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
170
return;
171
172
+ // Mark as spam.
173
+ if ( ! bp_core_check_for_blacklist( $activity->user_id, '', $activity->content ) )
174
+ bp_activity_mark_as_spam( $activity, 'by_blacklist' );
175
}
176
177
/**
179
*
180
* @since 1.1.0
181
*
182
+ * @uses apply_filters() To call the 'bp_activity_allowed_tags' hook.
183
+ * @uses wp_kses()
184
+ *
185
* @param string $content The activity content.
186
* @return string $content Filtered activity content.
187
*/
282
*
283
* @since 1.5.0
284
*
285
+ * @uses bp_activity_find_mentions()
286
+ *
287
* @param BP_Activity_Activity $activity Activity Object.
288
*/
289
function bp_activity_at_name_filter_updates( $activity ) {
319
*
320
* @since 1.7.0
321
*
322
+ * @uses bp_activity_at_message_notification()
323
+ * @uses bp_activity_update_mention_count_for_user()
324
+ *
325
* @param BP_Activity_Activity $activity The BP_Activity_Activity object.
326
*/
327
function bp_activity_at_name_send_emails( $activity ) {
395
* This method can only be used inside the Activity loop.
396
*
397
* @since 1.5.0
398
+ *
399
+ * @uses bp_is_single_activity()
400
+ * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook.
401
+ * @uses apply_filters() To call the 'bp_activity_excerpt_length' hook.
402
+ * @uses bp_create_excerpt()
403
+ * @uses bp_get_activity_id()
404
+ * @uses bp_get_activity_thread_permalink()
405
+ * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook.
406
*
407
* @param string $text The original activity entry text.
408
* @return string $excerpt The truncated text.
409
*/
410
+ function bp_activity_truncate_entry( $text ) {
411
global $activities_template;
412
413
/**
423
);
424
425
// The full text of the activity update should always show on the single activity screen.
426
+ if ( ! $maybe_truncate_text || bp_is_single_activity() ) {
427
return $text;
428
}
429
445
*/
446
$excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
447
448
// Run the text through the excerpt function. If it's too short, the original text will be returned.
449
+ $excerpt = bp_create_excerpt( $text, $excerpt_length, array( 'ending' => __( '&hellip;', 'buddypress' ) ) );
450
451
/*
452
* If the text returned by bp_create_excerpt() is different from the original text (ie it's
453
* been truncated), add the "Read More" link. Note that bp_create_excerpt() is stripping
454
* shortcodes, so we have strip them from the $text before the comparison.
455
*/
456
+ if ( $excerpt != strip_shortcodes( $text ) ) {
457
$id = !empty( $activities_template->activity->current_comment->id ) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id();
458
459
$excerpt = sprintf( '%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text );
476
*
477
* @since 2.0.0
478
*
479
+ * @uses bp_activity_do_heartbeat() to check if heartbeat is required.
480
+ *
481
* @param array $js_handles The original dependencies.
482
* @return array $js_handles The new dependencies.
483
*/
543
*
544
* @since 2.0.0
545
*
546
+ * @uses bp_activity_get_last_updated() to get the recorded date of the last activity.
547
+ *
548
* @param array $response Array containing Heartbeat API response.
549
* @param array $data Array containing data for Heartbeat API response.
550
* @return array $response
bp-activity/bp-activity-functions.php CHANGED
@@ -40,6 +40,8 @@ function bp_activity_has_directory() {
40
*
41
* @since 1.8.0
42
*
43
* @return bool $retval True to enable mentions, false to disable.
44
*/
45
function bp_activity_do_mentions() {
@@ -131,6 +133,8 @@ function bp_activity_find_mentions( $content ) {
131
*
132
* @since 1.5.0
133
*
134
* @param int $user_id The id of the user whose unread mentions are being reset.
135
*/
136
function bp_activity_clear_new_mentions( $user_id ) {
@@ -157,6 +161,9 @@ function bp_activity_clear_new_mentions( $user_id ) {
157
*
158
* @since 1.5.0
159
*
160
* @param int $activity_id The unique id for the activity item.
161
* @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
162
* @return bool
@@ -169,7 +176,7 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
169
}
170
171
// Get activity object.
172
- $activity = new BP_Activity_Activity( $activity_id );
173
174
// Try to find mentions.
175
$usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
@@ -193,6 +200,9 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
193
*
194
* @since 1.7.0
195
*
196
* @param int $user_id The user ID.
197
* @param int $activity_id The unique ID for the activity item.
198
* @param string $action 'delete' or 'add'. Default: 'add'.
@@ -777,6 +787,8 @@ function bp_activity_get_actions() {
777
*
778
* @since 1.1.0
779
*
780
* @param string $component_id The unique string ID of the component.
781
* @param string $key The action key.
782
* @return string|bool Action value if found, otherwise false.
@@ -846,6 +858,9 @@ function bp_activity_get_types() {
846
*
847
* @since 1.2.0
848
*
849
* @param int $user_id ID of the user whose favorites are being queried.
850
* @return array IDs of the user's favorite activity items.
851
*/
@@ -874,6 +889,14 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
874
*
875
* @since 1.2.0
876
*
877
* @param int $activity_id ID of the activity item being favorited.
878
* @param int $user_id ID of the user favoriting the activity item.
879
* @return bool True on success, false on failure.
@@ -948,6 +971,13 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
948
*
949
* @since 1.2.0
950
*
951
* @param int $activity_id ID of the activity item being unfavorited.
952
* @param int $user_id ID of the user unfavoriting the activity item.
953
* @return bool True on success, false on failure.
@@ -1020,6 +1050,9 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
1020
*
1021
* @since 1.1.0
1022
*
1023
* @param string $content The content to filter by.
1024
* @return int|null The ID of the located activity item. Null if none is found.
1025
*/
@@ -1030,7 +1063,7 @@ function bp_activity_check_exists_by_content( $content ) {
1030
*
1031
* @since 1.1.0
1032
*
1033
- * @param BP_Activity_Activity $value ID of the activity if found, else null.
1034
*/
1035
return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
1036
}
@@ -1040,6 +1073,9 @@ function bp_activity_check_exists_by_content( $content ) {
1040
*
1041
* @since 1.0.0
1042
*
1043
* @return string Date last updated.
1044
*/
1045
function bp_activity_get_last_updated() {
@@ -1059,6 +1095,8 @@ function bp_activity_get_last_updated() {
1059
*
1060
* @since 1.2.0
1061
*
1062
* @param int $user_id ID of the user whose favorite count is being requested.
1063
* @return int Total favorite count for the user.
1064
*/
@@ -1122,6 +1160,8 @@ function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = ''
1122
*
1123
* @since 1.2.0
1124
*
1125
* @param int $activity_id ID of the activity item whose metadata is being requested.
1126
* @param string $meta_key Optional. If present, only the metadata matching
1127
* that meta key will be returned. Otherwise, all metadata for the
@@ -1199,6 +1239,12 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
1199
*
1200
* @since 1.5.0
1201
*
1202
* @param int $user_id ID of the user whose activity is being deleted.
1203
* @return bool
1204
*/
@@ -1625,6 +1671,11 @@ function bp_activity_format_activity_action_custom_post_type_comment( $action, $
1625
*
1626
* @see BP_Activity_Activity::get() For more information on accepted arguments
1627
* and the format of the returned value.
1628
*
1629
* @param array|string $args See BP_Activity_Activity::get() for description.
1630
* @return array $activity See BP_Activity_Activity::get() for description.
@@ -1731,6 +1782,9 @@ function bp_activity_get( $args = '' ) {
1731
* @since 1.2.0
1732
*
1733
* @see BP_Activity_Activity::get() For more information on accepted arguments.
1734
*
1735
* @param array|string $args {
1736
* All arguments and defaults are shared with BP_Activity_Activity::get(),
@@ -1782,7 +1836,12 @@ function bp_activity_get_specific( $args = '' ) {
1782
* Add an activity item.
1783
*
1784
* @since 1.1.0
1785
- * @since 2.6.0 Added 'error_type' parameter to $args.
1786
*
1787
* @param array|string $args {
1788
* An array of arguments.
@@ -1814,7 +1873,6 @@ function bp_activity_get_specific( $args = '' ) {
1814
* @type bool $hide_sitewide Should the item be hidden on sitewide streams?
1815
* Default: false.
1816
* @type bool $is_spam Should the item be marked as spam? Default: false.
1817
- * @type string $error_type Optional. Error type. Either 'bool' or 'wp_error'. Default: 'bool'.
1818
* }
1819
* @return int|bool The ID of the activity on success. False on error.
1820
*/
@@ -1833,7 +1891,6 @@ function bp_activity_add( $args = '' ) {
1833
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded.
1834
'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
1835
'is_spam' => false, // Is this activity item to be marked as spam?
1836
- 'error_type' => 'bool'
1837
), 'activity_add' );
1838
1839
// Make sure we are backwards compatible.
@@ -1857,16 +1914,11 @@ function bp_activity_add( $args = '' ) {
1857
$activity->date_recorded = $r['recorded_time'];
1858
$activity->hide_sitewide = $r['hide_sitewide'];
1859
$activity->is_spam = $r['is_spam'];
1860
- $activity->error_type = $r['error_type'];
1861
$activity->action = ! empty( $r['action'] )
1862
- ? $r['action']
1863
- : bp_activity_generate_action_string( $activity );
1864
1865
- $save = $activity->save();
1866
-
1867
- if ( 'wp_error' === $r['error_type'] && is_wp_error( $save ) ) {
1868
- return $save;
1869
- } elseif ('bool' === $r['error_type'] && false === $save ) {
1870
return false;
1871
}
1872
@@ -1897,6 +1949,17 @@ function bp_activity_add( $args = '' ) {
1897
*
1898
* @since 1.2.0
1899
*
1900
* @param array|string $args {
1901
* @type string $content The content of the activity update.
1902
* @type int $user_id Optional. Defaults to the logged-in user.
@@ -1906,9 +1969,8 @@ function bp_activity_add( $args = '' ) {
1906
function bp_activity_post_update( $args = '' ) {
1907
1908
$r = wp_parse_args( $args, array(
1909
- 'content' => false,
1910
- 'user_id' => bp_loggedin_user_id(),
1911
- 'error_type' => 'bool',
1912
) );
1913
1914
if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) ) {
@@ -1948,14 +2010,8 @@ function bp_activity_post_update( $args = '' ) {
1948
'primary_link' => $add_primary_link,
1949
'component' => buddypress()->activity->id,
1950
'type' => 'activity_update',
1951
- 'error_type' => $r['error_type']
1952
) );
1953
1954
- // Bail on failure.
1955
- if ( false === $activity_id || is_wp_error( $activity_id ) ) {
1956
- return $activity_id;
1957
- }
1958
-
1959
/**
1960
* Filters the latest update content for the activity item.
1961
*
@@ -2248,9 +2304,10 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2248
*
2249
* @since 2.5.0
2250
*
2251
- * @param int $comment_id ID of the comment.
2252
- * @param bool $is_approved Whether the comment is approved or not.
2253
- * @param object|null $activity_post_object The post type tracking args object.
2254
* @return int|bool The ID of the activity on success. False on error.
2255
*/
2256
function bp_activity_post_type_comment( $comment_id = 0, $is_approved = true, $activity_post_object = null ) {
@@ -2440,8 +2497,9 @@ add_action( 'edit_comment', 'bp_activity_post_type_comment', 10 );
2440
*
2441
* @since 2.5.0
2442
*
2443
- * @param int $comment_id ID of the comment.
2444
- * @param object|null $activity_post_object The post type tracking args object.
2445
* @return bool True on success. False on error.
2446
*/
2447
function bp_activity_post_type_remove_comment( $comment_id = 0, $activity_post_object = null ) {
@@ -2506,10 +2564,15 @@ add_action( 'delete_comment', 'bp_activity_post_type_remove_comment', 10, 1 );
2506
* @since 1.2.0
2507
* @since 2.5.0 Add a new possible parameter $skip_notification for the array of arguments.
2508
* Add the $primary_link parameter for the array of arguments.
2509
- * @since 2.6.0 Added 'error_type' parameter to $args.
2510
*
2511
* @param array|string $args {
2512
- * An array of arguments.
2513
* @type int $id Optional. Pass an ID to update an existing comment.
2514
* @type string $content The content of the comment.
2515
* @type int $user_id Optional. The ID of the user making the comment.
@@ -2523,12 +2586,17 @@ add_action( 'delete_comment', 'bp_activity_post_type_remove_comment', 10, 1 );
2523
* Defaults to an empty string.
2524
* @type bool $skip_notification Optional. false to send a comment notification, false otherwise.
2525
* Defaults to false.
2526
- * @type string $error_type Optional. Error type. Either 'bool' or 'wp_error'. Default: 'bool'.
2527
* }
2528
* @return int|bool The ID of the comment on success, otherwise false.
2529
*/
2530
function bp_activity_new_comment( $args = '' ) {
2531
- $bp = buddypress();
2532
2533
$r = wp_parse_args( $args, array(
2534
'id' => false,
@@ -2538,31 +2606,14 @@ function bp_activity_new_comment( $args = '' ) {
2538
'parent_id' => false, // ID of a parent comment (optional).
2539
'primary_link' => '',
2540
'skip_notification' => false,
2541
- 'error_type' => 'bool'
2542
) );
2543
2544
- // Error type is boolean; need to initialize some variables for backpat.
2545
- if ( 'bool' === $r['error_type'] ) {
2546
- if ( empty( $bp->activity->errors ) ) {
2547
- $bp->activity->errors = array();
2548
- }
2549
- }
2550
-
2551
- // Default error message.
2552
- $feedback = __( 'There was an error posting your reply. Please try again.', 'buddypress' );
2553
-
2554
// Bail if missing necessary data.
2555
if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
2556
- $error = new WP_Error( 'missing_data', $feedback );
2557
-
2558
- if ( 'wp_error' === $r['error_type'] ) {
2559
- return $error;
2560
2561
- // Backpat.
2562
- } else {
2563
- $bp->activity->errors['new_comment'] = $error;
2564
- return false;
2565
- }
2566
}
2567
2568
// Maybe set current activity ID as the parent.
@@ -2577,21 +2628,14 @@ function bp_activity_new_comment( $args = '' ) {
2577
2578
// Bail if the parent activity does not exist.
2579
if ( empty( $activity->date_recorded ) ) {
2580
- $error = new WP_Error( 'missing_activity', __( 'The item you were replying to no longer exists.', 'buddypress' ) );
2581
-
2582
- if ( 'wp_error' === $r['error_type'] ) {
2583
- return $error;
2584
-
2585
- // Backpat.
2586
- } else {
2587
- $bp->activity->errors['new_comment'] = $error;
2588
- return false;
2589
- }
2590
2591
}
2592
2593
// Check to see if the parent activity is hidden, and if so, hide this comment publicly.
2594
- $is_hidden = $activity->hide_sitewide ? 1 : 0;
2595
2596
/**
2597
* Filters the content of a new comment.
@@ -2612,15 +2656,9 @@ function bp_activity_new_comment( $args = '' ) {
2612
'user_id' => $r['user_id'],
2613
'item_id' => $activity_id,
2614
'secondary_item_id' => $r['parent_id'],
2615
- 'hide_sitewide' => $is_hidden,
2616
- 'error_type' => $r['error_type']
2617
) );
2618
2619
- // Bail on failure.
2620
- if ( false === $comment_id || is_wp_error( $comment_id ) ) {
2621
- return $comment_id;
2622
- }
2623
-
2624
// Comment caches are stored only with the top-level item.
2625
wp_cache_delete( $activity_id, 'bp_activity_comments' );
2626
@@ -2660,15 +2698,8 @@ function bp_activity_new_comment( $args = '' ) {
2660
}
2661
2662
if ( empty( $comment_id ) ) {
2663
- $error = new WP_Error( 'comment_failed', $feedback );
2664
-
2665
- if ( 'wp_error' === $r['error_type'] ) {
2666
- return $error;
2667
-
2668
- // Backpat.
2669
- } else {
2670
- $bp->activity->errors['new_comment'] = $error;
2671
- }
2672
}
2673
2674
return $comment_id;
@@ -2680,6 +2711,9 @@ function bp_activity_new_comment( $args = '' ) {
2680
* @since 1.2.0
2681
*
2682
* @see BP_Activity_Activity::get() For more information on accepted arguments.
2683
*
2684
* @param array|string $args See BP_Activity_Activity::get() for description.
2685
* @return int $activity_id The ID of the activity item found.
@@ -2735,6 +2769,15 @@ function bp_activity_get_activity_id( $args = '' ) {
2735
* @since 1.0.0
2736
*
2737
* @see BP_Activity_Activity::get() For more information on accepted arguments.
2738
*
2739
* @param array|string $args To delete specific activity items, use
2740
* $args = array( 'id' => $ids ); Otherwise, to use
@@ -2820,6 +2863,8 @@ function bp_activity_delete( $args = '' ) {
2820
* @since 1.1.0
2821
* @deprecated 1.2.0
2822
*
2823
*
2824
* @param array|string $args See BP_Activity_Activity::get for a
2825
* description of accepted arguments.
@@ -2843,6 +2888,7 @@ function bp_activity_delete( $args = '' ) {
2843
*
2844
* @since 1.1.0
2845
*
2846
*
2847
* @param int $activity_id ID of the activity item to be deleted.
2848
* @return bool True on success, false on failure.
@@ -2859,6 +2905,7 @@ function bp_activity_delete( $args = '' ) {
2859
* @since 1.1.0
2860
* @deprecated 1.2.0
2861
*
2862
*
2863
* @param int $user_id The user id.
2864
* @param string $content The activity id.
@@ -2883,6 +2930,7 @@ function bp_activity_delete( $args = '' ) {
2883
* @since 1.1.0
2884
* @deprecated 1.2.0
2885
*
2886
*
2887
* @param int $user_id The user id.
2888
* @param string $component The activity component.
@@ -2900,6 +2948,11 @@ function bp_activity_delete( $args = '' ) {
2900
*
2901
* @since 1.2.0
2902
*
2903
* @todo Why is an activity id required? We could look this up.
2904
* @todo Why do we encourage users to call this function directly? We could just
2905
* as easily examine the activity type in bp_activity_delete() and then
@@ -2965,6 +3018,9 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2965
*
2966
* @since 1.2.0
2967
*
2968
*
2969
* @param int $activity_id The ID of the "root" activity, ie the
2970
* comment's oldest ancestor.
@@ -3000,6 +3056,10 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
3000
*
3001
* @since 1.2.0
3002
*
3003
* @param int $activity_id The unique id of the activity object.
3004
* @param object|bool $activity_obj Optional. The activity object.
3005
* @return string $link Permalink for the activity item.
@@ -3030,7 +3090,7 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
3030
$link = $activity_obj->primary_link;
3031
} else {
3032
if ( 'activity_comment' == $activity_obj->type ) {
3033
- $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/#acomment-' . $activity_obj->id;
3034
} else {
3035
$link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/';
3036
}
@@ -3051,6 +3111,8 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
3051
*
3052
* @since 1.2.0
3053
*
3054
* @param int $user_id The ID of the user whose activity is being hidden.
3055
* @return bool True on success, false on failure.
3056
*/
@@ -3072,6 +3134,9 @@ function bp_activity_hide_user_activity( $user_id ) {
3072
*
3073
* @since 1.2.0
3074
*
3075
* @param string $content The content of the activity item.
3076
* @param string|bool $link Optional. The unescaped URL that the image should link
3077
* to. If absent, the image will not be a link.
@@ -3274,12 +3339,8 @@ function bp_activity_create_summary( $content, $activity ) {
3274
}
3275
3276
// Generate a text excerpt for this activity item (and remove any oEmbeds URLs).
3277
- $summary = bp_create_excerpt( html_entity_decode( $content ), 225, array(
3278
- 'html' => false,
3279
- 'filter_shortcodes' => true,
3280
- 'strip_tags' => true,
3281
- 'remove_links' => true
3282
- ) );
3283
3284
if ( $use_media_type === 'embeds' ) {
3285
$summary .= PHP_EOL . PHP_EOL . $extracted_media['url'];
@@ -3326,8 +3387,6 @@ function bp_activity_user_can_mark_spam() {
3326
*
3327
* @since 1.6.0
3328
*
3329
- * @todo We should probably save $source to activity meta.
3330
- *
3331
* @param BP_Activity_Activity $activity The activity item to be spammed.
3332
* @param string $source Optional. Default is "by_a_person" (ie, a person has
3333
* manually marked the activity as spam). BP core also
@@ -3436,31 +3495,17 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
3436
* @see bp_embed_activity_cache()
3437
* @see bp_embed_activity_save_cache()
3438
*
3439
*/
3440
function bp_activity_embed() {
3441
add_filter( 'embed_post_id', 'bp_get_activity_id' );
3442
- add_filter( 'oembed_dataparse', 'bp_activity_oembed_dataparse', 10, 2 );
3443
add_filter( 'bp_embed_get_cache', 'bp_embed_activity_cache', 10, 3 );
3444
add_action( 'bp_embed_update_cache', 'bp_embed_activity_save_cache', 10, 3 );
3445
}
3446
add_action( 'activity_loop_start', 'bp_activity_embed' );
3447
3448
- /**
3449
- * Cache full oEmbed response from oEmbed.
3450
- *
3451
- * @since 2.6.0
3452
- *
3453
- * @param string $retval Current oEmbed result.
3454
- * @param object $data Full oEmbed response.
3455
- * @param string $url URL used for the oEmbed request.
3456
- * @return string
3457
- */
3458
- function bp_activity_oembed_dataparse( $retval, $data ) {
3459
- buddypress()->activity->oembed_response = $data;
3460
-
3461
- return $retval;
3462
- }
3463
-
3464
/**
3465
* Set up activity oEmbed cache while recursing through activity comments.
3466
*
@@ -3475,6 +3520,9 @@ function bp_activity_oembed_dataparse( $retval, $data ) {
3475
* @see bp_embed_activity_cache()
3476
* @see bp_embed_activity_save_cache()
3477
*
3478
*/
3479
function bp_activity_comment_embed() {
3480
add_filter( 'embed_post_id', 'bp_get_activity_comment_id' );
@@ -3489,6 +3537,9 @@ add_action( 'bp_before_activity_comment', 'bp_activity_comment_embed' );
3489
* @since 1.5.0
3490
*
3491
* @see BP_Embed
3492
*
3493
* @param object $activity The activity that is being expanded.
3494
*/
@@ -3511,6 +3562,7 @@ add_action( 'bp_legacy_theme_get_single_activity_content', 'bp_dtheme_embed_read
3511
* @since 1.5.0
3512
*
3513
* @see bp_activity_comment_embed()
3514
*/
3515
function bp_activity_comment_embed_after_recurse() {
3516
remove_filter( 'embed_post_id', 'bp_get_activity_comment_id' );
@@ -3525,6 +3577,7 @@ add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurs
3525
* @since 1.5.0
3526
*
3527
* @see BP_Embed::parse_oembed()
3528
*
3529
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
3530
* functions like this one to filter.
@@ -3544,6 +3597,7 @@ function bp_embed_activity_cache( $cache, $id, $cachekey ) {
3544
* @since 1.5.0
3545
*
3546
* @see BP_Embed::parse_oembed()
3547
*
3548
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
3549
* functions like this one to filter.
@@ -3552,12 +3606,6 @@ function bp_embed_activity_cache( $cache, $id, $cachekey ) {
3552
*/
3553
function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
3554
bp_activity_update_meta( $id, $cachekey, $cache );
3555
-
3556
- // Cache full oEmbed response.
3557
- if ( true === isset( buddypress()->activity->oembed_response ) ) {
3558
- $cachekey = str_replace( '_oembed', '_oembed_response', $cachekey );
3559
- bp_activity_update_meta( $id, $cachekey, buddypress()->activity->oembed_response );
3560
- }
3561
}
3562
3563
/**
@@ -3565,7 +3613,10 @@ function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
3565
*
3566
* @since 2.0.0
3567
*
3568
* directory.
3569
* is the group activities.
3570
*
3571
* @return bool True if activity heartbeat is enabled, otherwise false.
40
*
41
* @since 1.8.0
42
*
43
+ * @uses apply_filters() To call 'bp_activity_do_mentions' hook.
44
+ *
45
* @return bool $retval True to enable mentions, false to disable.
46
*/
47
function bp_activity_do_mentions() {
133
*
134
* @since 1.5.0
135
*
136
+ * @uses bp_delete_user_meta()
137
+ *
138
* @param int $user_id The id of the user whose unread mentions are being reset.
139
*/
140
function bp_activity_clear_new_mentions( $user_id ) {
161
*
162
* @since 1.5.0
163
*
164
+ * @uses bp_activity_find_mentions()
165
+ * @uses bp_activity_update_mention_count_for_user()
166
+ *
167
* @param int $activity_id The unique id for the activity item.
168
* @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
169
* @return bool
176
}
177
178
// Get activity object.
179
+ $activity = new BP_Activity_Activity( (int) $activity_id );
180
181
// Try to find mentions.
182
$usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
200
*
201
* @since 1.7.0
202
*
203
+ * @uses bp_get_user_meta()
204
+ * @uses bp_update_user_meta()
205
+ *
206
* @param int $user_id The user ID.
207
* @param int $activity_id The unique ID for the activity item.
208
* @param string $action 'delete' or 'add'. Default: 'add'.
787
*
788
* @since 1.1.0
789
*
790
+ * @uses apply_filters() To call the 'bp_activity_get_action' hook.
791
+ *
792
* @param string $component_id The unique string ID of the component.
793
* @param string $key The action key.
794
* @return string|bool Action value if found, otherwise false.
858
*
859
* @since 1.2.0
860
*
861
+ * @uses bp_get_user_meta()
862
+ * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
863
+ *
864
* @param int $user_id ID of the user whose favorites are being queried.
865
* @return array IDs of the user's favorite activity items.
866
*/
889
*
890
* @since 1.2.0
891
*
892
+ * @uses is_user_logged_in()
893
+ * @uses bp_get_user_meta()
894
+ * @uses bp_activity_get_meta()
895
+ * @uses bp_update_user_meta()
896
+ * @uses bp_activity_update_meta()
897
+ * @uses do_action() To call the 'bp_activity_add_user_favorite' hook.
898
+ * @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook.
899
+ *
900
* @param int $activity_id ID of the activity item being favorited.
901
* @param int $user_id ID of the user favoriting the activity item.
902
* @return bool True on success, false on failure.
971
*
972
* @since 1.2.0
973
*
974
+ * @uses is_user_logged_in()
975
+ * @uses bp_get_user_meta()
976
+ * @uses bp_activity_get_meta()
977
+ * @uses bp_activity_update_meta()
978
+ * @uses bp_update_user_meta()
979
+ * @uses do_action() To call the 'bp_activity_remove_user_favorite' hook.
980
+ *
981
* @param int $activity_id ID of the activity item being unfavorited.
982
* @param int $user_id ID of the user unfavoriting the activity item.
983
* @return bool True on success, false on failure.
1050
*
1051
* @since 1.1.0
1052
*
1053
+ * @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity}
1054
+ * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
1055
+ *
1056
* @param string $content The content to filter by.
1057
* @return int|null The ID of the located activity item. Null if none is found.
1058
*/
1063
*
1064
* @since 1.1.0
1065
*
1066
+ * @param BP_Activity_Activity $content_exists ID of the activity if found, else null.
1067
*/
1068
return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
1069
}
1073
*
1074
* @since 1.0.0
1075
*
1076
+ * @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity}
1077
+ * @uses apply_filters() To call the 'bp_activity_get_last_updated' hook.
1078
+ *
1079
* @return string Date last updated.
1080
*/
1081
function bp_activity_get_last_updated() {
1095
*
1096
* @since 1.2.0
1097
*
1098
+ * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
1099
+ *
1100
* @param int $user_id ID of the user whose favorite count is being requested.
1101
* @return int Total favorite count for the user.
1102
*/
1160
*
1161
* @since 1.2.0
1162
*
1163
+ * @uses apply_filters() To call the 'bp_activity_get_meta' hook.
1164
+ *
1165
* @param int $activity_id ID of the activity item whose metadata is being requested.
1166
* @param string $meta_key Optional. If present, only the metadata matching
1167
* that meta key will be returned. Otherwise, all metadata for the
1239
*
1240
* @since 1.5.0
1241
*
1242
+ * @uses is_user_logged_in()
1243
+ * @uses bp_activity_delete()
1244
+ * @uses bp_delete_user_meta()
1245
+ * @uses do_action() To call the 'bp_activity_remove_data' hook.
1246
+ * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook.
1247
+ *
1248
* @param int $user_id ID of the user whose activity is being deleted.
1249
* @return bool
1250
*/
1671
*
1672
* @see BP_Activity_Activity::get() For more information on accepted arguments
1673
* and the format of the returned value.
1674
+ * @uses wp_parse_args()
1675
+ * @uses wp_cache_get()
1676
+ * @uses wp_cache_set()
1677
+ * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
1678
+ * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
1679
*
1680
* @param array|string $args See BP_Activity_Activity::get() for description.
1681
* @return array $activity See BP_Activity_Activity::get() for description.
1782
* @since 1.2.0
1783
*
1784
* @see BP_Activity_Activity::get() For more information on accepted arguments.
1785
+ * @uses wp_parse_args()
1786
+ * @uses apply_filters() To call the 'bp_activity_get_specific' hook.
1787
+ * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
1788
*
1789
* @param array|string $args {
1790
* All arguments and defaults are shared with BP_Activity_Activity::get(),
1836
* Add an activity item.
1837
*
1838
* @since 1.1.0
1839
+ *
1840
+ * @uses wp_parse_args()
1841
+ * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
1842
+ * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
1843
+ * @uses wp_cache_delete()
1844
+ * @uses do_action() To call the 'bp_activity_add' hook.
1845
*
1846
* @param array|string $args {
1847
* An array of arguments.
1873
* @type bool $hide_sitewide Should the item be hidden on sitewide streams?
1874
* Default: false.
1875
* @type bool $is_spam Should the item be marked as spam? Default: false.
1876
* }
1877
* @return int|bool The ID of the activity on success. False on error.
1878
*/
1891
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded.
1892
'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
1893
'is_spam' => false, // Is this activity item to be marked as spam?
1894
), 'activity_add' );
1895
1896
// Make sure we are backwards compatible.
1914
$activity->date_recorded = $r['recorded_time'];
1915
$activity->hide_sitewide = $r['hide_sitewide'];
1916
$activity->is_spam = $r['is_spam'];
1917
$activity->action = ! empty( $r['action'] )
1918
+ ? $r['action']
1919
+ : bp_activity_generate_action_string( $activity );
1920
1921
+ if ( ! $activity->save() ) {
1922
return false;
1923
}
1924
1949
*
1950
* @since 1.2.0
1951
*
1952
+ * @uses wp_parse_args()
1953
+ * @uses bp_is_user_inactive()
1954
+ * @uses bp_core_get_userlink()
1955
+ * @uses bp_activity_add()
1956
+ * @uses apply_filters() To call the 'bp_activity_new_update_action' hook.
1957
+ * @uses apply_filters() To call the 'bp_activity_new_update_content' hook.
1958
+ * @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook.
1959
+ * @uses bp_update_user_meta()
1960
+ * @uses wp_filter_kses()
1961
+ * @uses do_action() To call the 'bp_activity_posted_update' hook.
1962
+ *
1963
* @param array|string $args {
1964
* @type string $content The content of the activity update.
1965
* @type int $user_id Optional. Defaults to the logged-in user.
1969
function bp_activity_post_update( $args = '' ) {
1970
1971
$r = wp_parse_args( $args, array(
1972
+ 'content' => false,
1973
+ 'user_id' => bp_loggedin_user_id()
1974
) );
1975
1976
if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) ) {
2010
'primary_link' => $add_primary_link,
2011
'component' => buddypress()->activity->id,
2012
'type' => 'activity_update',
2013
) );
2014
2015
/**
2016
* Filters the latest update content for the activity item.
2017
*
2304
*
2305
* @since 2.5.0
2306
*
2307
+ * @param int $comment_id ID of the comment.
2308
+ * @param bool $is_approved Whether the comment is approved or not.
2309
+ * @param object $activity_post_object the post type tracking args object.
2310
+ *
2311
* @return int|bool The ID of the activity on success. False on error.
2312
*/
2313
function bp_activity_post_type_comment( $comment_id = 0, $is_approved = true, $activity_post_object = null ) {
2497
*
2498
* @since 2.5.0
2499
*
2500
+ * @param int $comment_id ID of the comment.
2501
+ * @param object $activity_post_object The post type tracking args object.
2502
+ *
2503
* @return bool True on success. False on error.
2504
*/
2505
function bp_activity_post_type_remove_comment( $comment_id = 0, $activity_post_object = null ) {
2564
* @since 1.2.0
2565
* @since 2.5.0 Add a new possible parameter $skip_notification for the array of arguments.
2566
* Add the $primary_link parameter for the array of arguments.
2567
+ *
2568
+ * @uses wp_parse_args()
2569
+ * @uses bp_activity_add()
2570
+ * @uses apply_filters() To call the 'bp_activity_comment_action' hook.
2571
+ * @uses apply_filters() To call the 'bp_activity_comment_content' hook.
2572
+ * @uses wp_cache_delete()
2573
+ * @uses do_action() To call the 'bp_activity_comment_posted' hook.
2574
*
2575
* @param array|string $args {
2576
* @type int $id Optional. Pass an ID to update an existing comment.
2577
* @type string $content The content of the comment.
2578
* @type int $user_id Optional. The ID of the user making the comment.
2586
* Defaults to an empty string.
2587
* @type bool $skip_notification Optional. false to send a comment notification, false otherwise.
2588
* Defaults to false.
2589
* }
2590
* @return int|bool The ID of the comment on success, otherwise false.
2591
*/
2592
function bp_activity_new_comment( $args = '' ) {
2593
+ $bp = buddypress();
2594
+ $errors = new WP_Error();
2595
+ $feedback = __( 'There was an error posting your reply. Please try again.', 'buddypress' );
2596
+
2597
+ if ( empty( $bp->activity->errors ) ) {
2598
+ $bp->activity->errors = array();
2599
+ }
2600
2601
$r = wp_parse_args( $args, array(
2602
'id' => false,
2606
'parent_id' => false, // ID of a parent comment (optional).
2607
'primary_link' => '',
2608
'skip_notification' => false,
2609
) );
2610
2611
// Bail if missing necessary data.
2612
if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
2613
+ $errors->add( 'missing_data', $feedback );
2614
+ $bp->activity->errors['new_comment'] = $errors;
2615
2616
+ return false;
2617
}
2618
2619
// Maybe set current activity ID as the parent.
2628
2629
// Bail if the parent activity does not exist.
2630
if ( empty( $activity->date_recorded ) ) {
2631
+ $errors->add( 'missing_activity', __( 'Sorry, the item you are replying to no longer exists.', 'buddypress' ) );
2632
+ $bp->activity->errors['new_comment'] = $errors;
2633
2634
+ return false;
2635
}
2636
2637