BuddyPress - Version 2.7.0-beta1

Version Description

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

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

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

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

Download this release

Release Info

Developer mercime
Plugin Icon 128x128 BuddyPress
Version 2.7.0-beta1
Comparing to
See all releases

Code changes from version 2.6.2 to 2.7.0-beta1

Files changed (281) hide show
  1. bp-activity/bp-activity-actions.php +1 -40
  2. bp-activity/bp-activity-akismet.php +23 -0
  3. bp-activity/bp-activity-cache.php +21 -0
  4. bp-activity/bp-activity-filters.php +15 -11
  5. bp-activity/bp-activity-functions.php +226 -49
  6. bp-activity/bp-activity-loader.php +1 -1
  7. bp-activity/bp-activity-notifications.php +23 -225
  8. bp-activity/bp-activity-screens.php +1 -1
  9. bp-activity/bp-activity-template.php +11 -11
  10. bp-activity/classes/class-bp-activity-activity.php +24 -2
  11. bp-activity/classes/class-bp-activity-component.php +11 -16
  12. bp-activity/classes/class-bp-activity-list-table.php +20 -2
  13. bp-activity/js/mentions.min.js +1 -1
  14. bp-blogs/bp-blogs-activity.php +1 -1
  15. bp-blogs/bp-blogs-filters.php +14 -0
  16. bp-blogs/bp-blogs-functions.php +20 -0
  17. bp-blogs/bp-blogs-loader.php +2 -0
  18. bp-blogs/bp-blogs-template.php +94 -18
  19. bp-blogs/classes/class-bp-blogs-blog.php +33 -10
  20. bp-blogs/classes/class-bp-blogs-component.php +6 -1
  21. bp-core/admin/bp-core-admin-components.php +1 -0
  22. bp-core/admin/bp-core-admin-functions.php +22 -0
  23. bp-core/admin/bp-core-admin-schema.php +13 -26
  24. bp-core/admin/bp-core-admin-slugs.php +11 -3
  25. bp-core/admin/bp-core-admin-tools.php +20 -29
  26. bp-core/admin/css/common-rtl.css +45 -0
  27. bp-core/admin/css/common-rtl.min.css +1 -1
  28. bp-core/admin/css/common.css +45 -0
  29. bp-core/admin/css/common.min.css +1 -1
  30. bp-core/admin/images/activity-embeds.png +0 -0
  31. bp-core/bp-core-actions.php +11 -4
  32. bp-core/bp-core-admin.php +27 -19
  33. bp-core/bp-core-attachments.php +8 -6
  34. bp-core/bp-core-avatars.php +21 -30
  35. bp-core/bp-core-buddybar.php +11 -11
  36. bp-core/bp-core-cache.php +107 -0
  37. bp-core/bp-core-caps.php +65 -20
  38. bp-core/bp-core-catchuri.php +71 -20
  39. bp-core/bp-core-classes.php +1 -0
  40. bp-core/bp-core-cssjs.php +104 -14
  41. bp-core/bp-core-customizer-email.php +3 -5
  42. bp-core/bp-core-dependency.php +0 -12
  43. bp-core/bp-core-filters.php +53 -43
  44. bp-core/bp-core-functions.php +405 -52
  45. bp-core/bp-core-loader.php +1 -3
  46. bp-core/bp-core-options.php +19 -59
  47. bp-core/bp-core-taxonomy.php +113 -5
  48. bp-core/bp-core-template-loader.php +5 -1
  49. bp-core/bp-core-template.php +73 -8
  50. bp-core/bp-core-theme-compatibility.php +11 -9
  51. bp-core/bp-core-update.php +109 -24
  52. bp-core/bp-core-wpabstraction.php +0 -7
  53. bp-core/classes/class-bp-admin.php +6 -6
  54. bp-core/classes/class-bp-attachment-avatar.php +1 -4
  55. bp-core/classes/class-bp-attachment-cover-image.php +291 -291
  56. bp-core/classes/class-bp-attachment.php +12 -12
  57. bp-core/classes/class-bp-button.php +232 -77
  58. bp-core/classes/class-bp-core-html-element.php +127 -0
  59. bp-core/classes/class-bp-core-nav.php +15 -15
  60. bp-core/classes/class-bp-core-oembed-extension.php +21 -15
  61. bp-core/classes/class-bp-core-user.php +17 -0
  62. bp-core/classes/class-bp-theme-compat.php +1 -1
  63. bp-core/classes/class-bp-user-query.php +11 -4
  64. bp-core/css/avatar-rtl.css +1 -1
  65. bp-core/css/avatar-rtl.min.css +1 -1
  66. bp-core/css/avatar.css +1 -1
  67. bp-core/css/avatar.min.css +1 -1
  68. bp-core/deprecated/2.7.php +26 -0
  69. bp-core/js/bp-plupload.min.js +1 -1
  70. bp-core/js/confirm.min.js +1 -1
  71. bp-core/js/cover-image.js +277 -277
  72. bp-core/js/jquery.atwho.min.js +0 -1
  73. bp-core/js/{jquery-cookie.js → vendor/jquery-cookie.js} +0 -0
  74. bp-core/js/{jquery-cookie.min.js → vendor/jquery-cookie.min.js} +1 -1
  75. bp-core/js/{jquery-scroll-to.js → vendor/jquery-scroll-to.js} +0 -0
  76. bp-core/js/{jquery-scroll-to.min.js → vendor/jquery-scroll-to.min.js} +1 -1
  77. bp-core/js/{jquery.atwho.js → vendor/jquery.atwho.js} +0 -0
  78. bp-core/js/vendor/jquery.atwho.min.js +1 -0
  79. bp-core/js/{jquery.atwho.txt → vendor/jquery.atwho.txt} +0 -0
  80. bp-core/js/{jquery.caret.js → vendor/jquery.caret.js} +0 -0
  81. bp-core/js/{jquery.caret.min.js → vendor/jquery.caret.min.js} +1 -1
  82. bp-core/js/{jquery.caret.txt → vendor/jquery.caret.txt} +0 -0
  83. bp-core/js/vendor/livestamp.js +129 -0
  84. bp-core/js/vendor/livestamp.min.js +1 -0
  85. bp-core/js/vendor/moment.js +4040 -0
  86. bp-core/js/vendor/moment.min.js +2 -0
  87. bp-forums/bp-forums-bbpress-sa.php +8 -11
  88. bp-forums/bp-forums-template.php +9 -14
  89. bp-friends/bp-friends-actions.php +2 -2
  90. bp-friends/bp-friends-cache.php +41 -0
  91. bp-friends/bp-friends-filters.php +7 -34
  92. bp-friends/bp-friends-functions.php +75 -0
  93. bp-friends/bp-friends-loader.php +1 -1
  94. bp-friends/bp-friends-notifications.php +15 -96
  95. bp-friends/bp-friends-template.php +0 -4
  96. bp-friends/bp-friends-widgets.php +2 -2
  97. bp-friends/classes/class-bp-core-friends-widget.php +7 -10
  98. bp-friends/classes/class-bp-friends-component.php +8 -2
  99. bp-friends/classes/class-bp-friends-friendship.php +296 -49
  100. bp-groups/admin/css/admin-rtl.css +17 -7
  101. bp-groups/admin/css/admin-rtl.min.css +1 -1
  102. bp-groups/admin/css/admin.css +17 -7
  103. bp-groups/admin/css/admin.min.css +1 -1
  104. bp-groups/admin/js/admin.min.js +1 -1
  105. bp-groups/bp-groups-actions.php +33 -2
  106. bp-groups/bp-groups-activity.php +5 -14
  107. bp-groups/bp-groups-admin.php +107 -13
  108. bp-groups/bp-groups-cache.php +73 -3
  109. bp-groups/bp-groups-filters.php +1 -1
  110. bp-groups/bp-groups-forums.php +1 -1
  111. bp-groups/bp-groups-functions.php +150 -68
  112. bp-groups/bp-groups-loader.php +1 -1
  113. bp-groups/bp-groups-notifications.php +53 -11
  114. bp-groups/bp-groups-screens.php +43 -1
  115. bp-groups/bp-groups-template.php +338 -79
  116. bp-groups/bp-groups-widgets.php +7 -11
  117. bp-groups/classes/class-bp-group-extension.php +4 -10
  118. bp-groups/classes/class-bp-groups-component.php +16 -16
  119. bp-groups/classes/class-bp-groups-group-members-template.php +5 -3
  120. bp-groups/classes/class-bp-groups-group.php +361 -178
  121. bp-groups/classes/class-bp-groups-invite-template.php +4 -2
  122. bp-groups/classes/class-bp-groups-list-table.php +132 -3
  123. bp-groups/classes/class-bp-groups-member-suggestions.php +1 -6
  124. bp-groups/classes/class-bp-groups-member.php +90 -27
  125. bp-groups/classes/class-bp-groups-template.php +5 -6
  126. bp-groups/classes/class-bp-groups-theme-compat.php +8 -4
  127. bp-groups/classes/class-bp-groups-widget.php +1 -1
  128. bp-loader.php +9 -7
  129. bp-members/bp-members-cache.php +13 -1
  130. bp-members/bp-members-functions.php +40 -5
  131. bp-members/bp-members-screens.php +2 -2
  132. bp-members/bp-members-template.php +60 -34
  133. bp-members/classes/class-bp-core-members-widget.php +9 -13
  134. bp-members/classes/class-bp-core-recently-active-widget.php +1 -3
  135. bp-members/classes/class-bp-core-whos-online-widget.php +1 -4
  136. bp-members/classes/class-bp-members-admin.php +277 -0
  137. bp-members/classes/class-bp-members-component.php +5 -1
  138. bp-messages/bp-messages-functions.php +106 -8
  139. bp-messages/bp-messages-loader.php +3 -1
  140. bp-messages/bp-messages-notifications.php +21 -104
  141. bp-messages/bp-messages-template.php +0 -1
  142. bp-messages/classes/class-bp-messages-component.php +3 -1
  143. bp-messages/classes/class-bp-messages-message.php +12 -6
  144. bp-messages/classes/class-bp-messages-notice.php +8 -2
  145. bp-messages/classes/class-bp-messages-thread.php +30 -7
  146. bp-messages/js/autocomplete/jquery.autocomplete.min.js +1 -1
  147. bp-messages/js/autocomplete/jquery.dimensions.min.js +1 -1
  148. bp-notifications/bp-notifications-loader.php +1 -1
  149. bp-notifications/classes/class-bp-notifications-notification.php +26 -20
  150. bp-settings/bp-settings-actions.php +1 -1
  151. bp-settings/bp-settings-loader.php +1 -1
  152. bp-templates/bp-legacy/buddypress-functions.php +44 -12
  153. bp-templates/bp-legacy/buddypress/activity/comment.php +2 -2
  154. bp-templates/bp-legacy/buddypress/activity/entry.php +2 -2
  155. bp-templates/bp-legacy/buddypress/activity/index.php +8 -8
  156. bp-templates/bp-legacy/buddypress/assets/_attachments/avatars/index.php +2 -2
  157. bp-templates/bp-legacy/buddypress/assets/_attachments/cover-images/index.php +36 -36
  158. bp-templates/bp-legacy/buddypress/blogs/index.php +16 -5
  159. bp-templates/bp-legacy/buddypress/common/search/dir-search-form.php +16 -0
  160. bp-templates/bp-legacy/buddypress/forums/index.php +13 -5
  161. bp-templates/bp-legacy/buddypress/groups/create.php +70 -29
  162. bp-templates/bp-legacy/buddypress/groups/groups-loop.php +5 -1
  163. bp-templates/bp-legacy/buddypress/groups/index.php +16 -5
  164. bp-templates/bp-legacy/buddypress/groups/single/activity.php +2 -2
  165. bp-templates/bp-legacy/buddypress/groups/single/admin.php +19 -456
  166. bp-templates/bp-legacy/buddypress/groups/single/admin/delete-group.php +41 -0
  167. bp-templates/bp-legacy/buddypress/groups/single/admin/edit-details.php +53 -0
  168. bp-templates/bp-legacy/buddypress/groups/single/admin/group-avatar.php +67 -0
  169. bp-templates/bp-legacy/buddypress/groups/single/admin/group-cover-image.php +33 -0
  170. bp-templates/bp-legacy/buddypress/groups/single/admin/group-settings.php +124 -0
  171. bp-templates/bp-legacy/buddypress/groups/single/admin/manage-members.php +332 -0
  172. bp-templates/bp-legacy/buddypress/groups/single/admin/membership-requests.php +35 -0
  173. bp-templates/bp-legacy/buddypress/groups/single/cover-image-header.php +124 -123
  174. bp-templates/bp-legacy/buddypress/groups/single/forum.php +1 -1
  175. bp-templates/bp-legacy/buddypress/groups/single/forum/edit.php +1 -1
  176. bp-templates/bp-legacy/buddypress/groups/single/forum/topic.php +1 -1
  177. bp-templates/bp-legacy/buddypress/groups/single/group-header.php +5 -3
  178. bp-templates/bp-legacy/buddypress/groups/single/home.php +1 -1
  179. bp-templates/bp-legacy/buddypress/groups/single/invites-loop.php +1 -1
  180. bp-templates/bp-legacy/buddypress/groups/single/members.php +1 -1
  181. bp-templates/bp-legacy/buddypress/groups/single/request-membership.php +2 -0
  182. bp-templates/bp-legacy/buddypress/groups/single/requests-loop.php +2 -2
  183. bp-templates/bp-legacy/buddypress/groups/single/send-invites.php +3 -1
  184. bp-templates/bp-legacy/buddypress/members/index.php +17 -7
  185. bp-templates/bp-legacy/buddypress/members/members-loop.php +1 -1
  186. bp-templates/bp-legacy/buddypress/members/register.php +3 -3
  187. bp-templates/bp-legacy/buddypress/members/single/activity.php +2 -2
  188. bp-templates/bp-legacy/buddypress/members/single/blogs.php +1 -1
  189. bp-templates/bp-legacy/buddypress/members/single/cover-image-header.php +103 -103
  190. bp-templates/bp-legacy/buddypress/members/single/forums.php +1 -1
  191. bp-templates/bp-legacy/buddypress/members/single/friends.php +7 -1
  192. bp-templates/bp-legacy/buddypress/members/single/friends/requests.php +2 -0
  193. bp-templates/bp-legacy/buddypress/members/single/groups.php +7 -1
  194. bp-templates/bp-legacy/buddypress/members/single/groups/invites.php +2 -0
  195. bp-templates/bp-legacy/buddypress/members/single/home.php +1 -1
  196. bp-templates/bp-legacy/buddypress/members/single/member-header.php +1 -1
  197. bp-templates/bp-legacy/buddypress/members/single/messages.php +9 -1
  198. bp-templates/bp-legacy/buddypress/members/single/messages/compose.php +2 -0
  199. bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php +2 -0
  200. bp-templates/bp-legacy/buddypress/members/single/messages/single.php +1 -1
  201. bp-templates/bp-legacy/buddypress/members/single/notifications.php +1 -1
  202. bp-templates/bp-legacy/buddypress/members/single/notifications/read.php +2 -0
  203. bp-templates/bp-legacy/buddypress/members/single/notifications/unread.php +2 -0
  204. bp-templates/bp-legacy/buddypress/members/single/plugins.php +1 -1
  205. bp-templates/bp-legacy/buddypress/members/single/profile.php +1 -1
  206. bp-templates/bp-legacy/buddypress/members/single/profile/change-avatar.php +2 -2
  207. bp-templates/bp-legacy/buddypress/members/single/profile/change-cover-image.php +33 -33
  208. bp-templates/bp-legacy/buddypress/members/single/profile/edit.php +1 -1
  209. bp-templates/bp-legacy/buddypress/members/single/profile/profile-loop.php +1 -1
  210. bp-templates/bp-legacy/buddypress/members/single/profile/profile-wp.php +1 -1
  211. bp-templates/bp-legacy/buddypress/members/single/settings.php +1 -1
  212. bp-templates/bp-legacy/buddypress/members/single/settings/general.php +2 -0
  213. bp-templates/bp-legacy/buddypress/members/single/settings/notifications.php +2 -0
  214. bp-templates/bp-legacy/buddypress/members/single/settings/profile.php +2 -0
  215. bp-templates/bp-legacy/css/buddypress-rtl.css +19 -8
  216. bp-templates/bp-legacy/css/buddypress-rtl.min.css +1 -1
  217. bp-templates/bp-legacy/css/buddypress.css +19 -8
  218. bp-templates/bp-legacy/css/buddypress.min.css +1 -1
  219. bp-templates/bp-legacy/css/twentyeleven-rtl.css +189 -189
  220. bp-templates/bp-legacy/css/twentyeleven-rtl.min.css +1 -1
  221. bp-templates/bp-legacy/css/twentyeleven.css +189 -189
  222. bp-templates/bp-legacy/css/twentyeleven.min.css +1 -1
  223. bp-templates/bp-legacy/css/twentyeleven.scss +2577 -2577
  224. bp-templates/bp-legacy/css/twentyfifteen-rtl.css +15 -5
  225. bp-templates/bp-legacy/css/twentyfifteen-rtl.min.css +1 -1
  226. bp-templates/bp-legacy/css/twentyfifteen.css +15 -5
  227. bp-templates/bp-legacy/css/twentyfifteen.min.css +1 -1
  228. bp-templates/bp-legacy/css/twentyfifteen.scss +18 -5
  229. bp-templates/bp-legacy/css/twentyfourteen-rtl.css +28 -7
  230. bp-templates/bp-legacy/css/twentyfourteen-rtl.min.css +1 -1
  231. bp-templates/bp-legacy/css/twentyfourteen.css +28 -7
  232. bp-templates/bp-legacy/css/twentyfourteen.min.css +1 -1
  233. bp-templates/bp-legacy/css/twentyfourteen.scss +32 -8
  234. bp-templates/bp-legacy/css/twentysixteen-rtl.css +214 -192
  235. bp-templates/bp-legacy/css/twentysixteen-rtl.min.css +1 -1
  236. bp-templates/bp-legacy/css/twentysixteen.css +214 -192
  237. bp-templates/bp-legacy/css/twentysixteen.min.css +1 -1
  238. bp-templates/bp-legacy/css/twentysixteen.scss +2435 -2415
  239. bp-templates/bp-legacy/css/twentyten-rtl.css +189 -189
  240. bp-templates/bp-legacy/css/twentyten-rtl.min.css +1 -1
  241. bp-templates/bp-legacy/css/twentyten.css +189 -189
  242. bp-templates/bp-legacy/css/twentyten.min.css +1 -1
  243. bp-templates/bp-legacy/css/twentyten.scss +2478 -2478
  244. bp-templates/bp-legacy/css/twentythirteen-rtl.css +209 -200
  245. bp-templates/bp-legacy/css/twentythirteen-rtl.min.css +1 -1
  246. bp-templates/bp-legacy/css/twentythirteen.css +209 -200
  247. bp-templates/bp-legacy/css/twentythirteen.min.css +1 -1
  248. bp-templates/bp-legacy/css/twentythirteen.scss +2427 -2418
  249. bp-templates/bp-legacy/css/twentytwelve-rtl.css +198 -194
  250. bp-templates/bp-legacy/css/twentytwelve-rtl.min.css +1 -1
  251. bp-templates/bp-legacy/css/twentytwelve.css +198 -194
  252. bp-templates/bp-legacy/css/twentytwelve.min.css +1 -1
  253. bp-templates/bp-legacy/css/twentytwelve.scss +2517 -2514
  254. bp-templates/bp-legacy/js/buddypress.js +8 -2
  255. bp-templates/bp-legacy/js/buddypress.min.js +1 -1
  256. bp-templates/bp-legacy/js/password-verify.min.js +1 -1
  257. bp-xprofile/admin/css/admin-rtl.css +76 -0
  258. bp-xprofile/admin/css/admin-rtl.min.css +1 -1
  259. bp-xprofile/admin/css/admin.css +76 -0
  260. bp-xprofile/admin/css/admin.min.css +1 -1
  261. bp-xprofile/admin/js/admin.js +44 -3
  262. bp-xprofile/admin/js/admin.min.js +1 -1
  263. bp-xprofile/bp-xprofile-activity.php +1 -1
  264. bp-xprofile/bp-xprofile-admin.php +8 -3
  265. bp-xprofile/bp-xprofile-caps.php +2 -2
  266. bp-xprofile/bp-xprofile-cssjs.php +3 -3
  267. bp-xprofile/bp-xprofile-functions.php +1 -1
  268. bp-xprofile/bp-xprofile-loader.php +1 -1
  269. bp-xprofile/bp-xprofile-template.php +2 -3
  270. bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php +294 -6
  271. bp-xprofile/classes/class-bp-xprofile-field-type-placeholder.php +2 -0
  272. bp-xprofile/classes/class-bp-xprofile-field-type-url.php +4 -4
  273. bp-xprofile/classes/class-bp-xprofile-field-type.php +38 -1
  274. bp-xprofile/classes/class-bp-xprofile-field.php +44 -24
  275. bp-xprofile/classes/class-bp-xprofile-group.php +11 -1
  276. bp-xprofile/classes/class-bp-xprofile-profiledata.php +30 -6
  277. bp-xprofile/classes/class-bp-xprofile-query.php +1 -1
  278. bp-xprofile/classes/class-bp-xprofile-user-admin.php +2 -2
  279. buddypress.pot +1801 -1397
  280. composer.json +6 -5
  281. readme.txt +196 -196
bp-activity/bp-activity-actions.php CHANGED
@@ -71,7 +71,7 @@ function bp_activity_action_permalink_router() {
71
} else {
72
73
// Set redirect to group activity stream.
74
- if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
75
$redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
76
}
77
}
@@ -604,45 +604,6 @@ function bp_activity_action_favorites_feed() {
604
}
605
add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
606
607
- /**
608
- * Loads Akismet filtering for activity.
609
- *
610
- * @since 1.6.0
611
- * @since 2.3.0 We only support Akismet 3+.
612
- */
613
- function bp_activity_setup_akismet() {
614
- $bp = buddypress();
615
-
616
- // Bail if Akismet is not active.
617
- if ( ! defined( 'AKISMET_VERSION' ) ) {
618
- return;
619
- }
620
-
621
- // Bail if older version of Akismet.
622
- if ( ! class_exists( 'Akismet' ) ) {
623
- return;
624
- }
625
-
626
- // Bail if no Akismet key is set.
627
- if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) ) {
628
- return;
629
- }
630
-
631
- /**
632
- * Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
633
- *
634
- * @since 1.6.0
635
- *
636
- * @param bool $value Return value of bp_is_akismet_active boolean function.
637
- */
638
- if ( ! apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
639
- return;
640
- }
641
-
642
- // Instantiate Akismet for BuddyPress.
643
- $bp->activity->akismet = new BP_Akismet();
644
- }
645
-
646
/**
647
* AJAX endpoint for Suggestions API lookups.
648
*
71
} else {
72
73
// Set redirect to group activity stream.
74
+ if ( $group = groups_get_group( $activity->item_id ) ) {
75
$redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
76
}
77
}
604
}
605
add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
606
607
/**
608
* AJAX endpoint for Suggestions API lookups.
609
*
bp-activity/bp-activity-akismet.php CHANGED
@@ -14,6 +14,29 @@ if ( ! buddypress()->do_autoload ) {
14
require dirname( __FILE__ ) . '/classes/class-bp-akismet.php';
15
}
16
17
/**
18
* Delete old spam activity meta data.
19
*
14
require dirname( __FILE__ ) . '/classes/class-bp-akismet.php';
15
}
16
17
+ /**
18
+ * Loads Akismet filtering for activity.
19
+ *
20
+ * @since 1.6.0
21
+ * @since 2.3.0 We only support Akismet 3+.
22
+ */
23
+ function bp_activity_setup_akismet() {
24
+ /**
25
+ * Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
26
+ *
27
+ * @since 1.6.0
28
+ *
29
+ * @param bool $value Return value of bp_is_akismet_active boolean function.
30
+ */
31
+ if ( ! apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
32
+ return;
33
+ }
34
+
35
+ // Instantiate Akismet for BuddyPress.
36
+ buddypress()->activity->akismet = new BP_Akismet();
37
+ }
38
+ add_action( 'bp_activity_setup_globals', 'bp_activity_setup_akismet' );
39
+
40
/**
41
* Delete old spam activity meta data.
42
*
bp-activity/bp-activity-cache.php CHANGED
@@ -63,3 +63,24 @@ function bp_activity_clear_cache_for_deleted_activity( $deleted_ids ) {
63
}
64
}
65
add_action( 'bp_activity_deleted_activities', 'bp_activity_clear_cache_for_deleted_activity' );
63
}
64
}
65
add_action( 'bp_activity_deleted_activities', 'bp_activity_clear_cache_for_deleted_activity' );
66
+
67
+ /**
68
+ * Reset cache incrementor for the Activity component.
69
+ *
70
+ * Called whenever an activity item is created, updated, or deleted, this
71
+ * function effectively invalidates all cached results of activity queries.
72
+ *
73
+ * @since 2.7.0
74
+ *
75
+ * @return bool True on success, false on failure.
76
+ */
77
+ function bp_activity_reset_cache_incrementor() {
78
+ $without_last_activity = bp_core_reset_incrementor( 'bp_activity' );
79
+ $with_last_activity = bp_core_reset_incrementor( 'bp_activity_with_last_activity' );
80
+ return $without_last_activity && $with_last_activity;
81
+ }
82
+ add_action( 'bp_activity_delete', 'bp_activity_reset_cache_incrementor' );
83
+ add_action( 'bp_activity_add', 'bp_activity_reset_cache_incrementor' );
84
+ add_action( 'added_activity_meta', 'bp_activity_reset_cache_incrementor' );
85
+ add_action( 'updated_activity_meta', 'bp_activity_reset_cache_incrementor' );
86
+ add_action( 'deleted_activity_meta', 'bp_activity_reset_cache_incrementor' );
bp-activity/bp-activity-filters.php CHANGED
@@ -207,13 +207,15 @@ function bp_activity_filter_kses( $content ) {
207
global $allowedtags;
208
209
$activity_allowedtags = $allowedtags;
210
- $activity_allowedtags['a']['class'] = array();
211
- $activity_allowedtags['a']['id'] = array();
212
- $activity_allowedtags['a']['rel'] = array();
213
- $activity_allowedtags['a']['title'] = array();
214
- $activity_allowedtags['b'] = array();
215
- $activity_allowedtags['code'] = array();
216
- $activity_allowedtags['i'] = array();
217
$activity_allowedtags['img'] = array();
218
$activity_allowedtags['img']['src'] = array();
219
$activity_allowedtags['img']['alt'] = array();
@@ -222,8 +224,10 @@ function bp_activity_filter_kses( $content ) {
222
$activity_allowedtags['img']['class'] = array();
223
$activity_allowedtags['img']['id'] = array();
224
$activity_allowedtags['img']['title'] = array();
225
- $activity_allowedtags['span'] = array();
226
- $activity_allowedtags['span']['class'] = array();
227
228
229
/**
@@ -278,7 +282,7 @@ function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
278
279
// Linkify the mentions with the username.
280
foreach ( (array) $usernames as $user_id => $username ) {
281
- $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
282
}
283
284
// Put everything back.
@@ -319,7 +323,7 @@ function bp_activity_at_name_filter_updates( $activity ) {
319
if ( ! empty( $usernames ) ) {
320
// Replace @mention text with userlinks.
321
foreach( (array) $usernames as $user_id => $username ) {
322
- $activity->content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $activity->content );
323
}
324
325
// Add our hook to send @mention emails after the activity item is saved.
207
global $allowedtags;
208
209
$activity_allowedtags = $allowedtags;
210
+ $activity_allowedtags['a']['class'] = array();
211
+ $activity_allowedtags['a']['id'] = array();
212
+ $activity_allowedtags['a']['rel'] = array();
213
+ $activity_allowedtags['a']['title'] = array();
214
+
215
+ $activity_allowedtags['b'] = array();
216
+ $activity_allowedtags['code'] = array();
217
+ $activity_allowedtags['i'] = array();
218
+
219
$activity_allowedtags['img'] = array();
220
$activity_allowedtags['img']['src'] = array();
221
$activity_allowedtags['img']['alt'] = array();
224
$activity_allowedtags['img']['class'] = array();
225
$activity_allowedtags['img']['id'] = array();
226
$activity_allowedtags['img']['title'] = array();
227
+
228
+ $activity_allowedtags['span'] = array();
229
+ $activity_allowedtags['span']['class'] = array();
230
+ $activity_allowedtags['span']['data-livestamp'] = array();
231
232
233
/**
282
283
// Linkify the mentions with the username.
284
foreach ( (array) $usernames as $user_id => $username ) {
285
+ $content = preg_replace( '/(@' . $username . '\b)/', "<a class='bp-suggestions-mention' href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
286
}
287
288
// Put everything back.
323
if ( ! empty( $usernames ) ) {
324
// Replace @mention text with userlinks.
325
foreach( (array) $usernames as $user_id => $username ) {
326
+ $activity->content = preg_replace( '/(@' . $username . '\b)/', "<a class='bp-suggestions-mention' href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $activity->content );
327
}
328
329
// Add our hook to send @mention emails after the activity item is saved.
bp-activity/bp-activity-functions.php CHANGED
@@ -1663,56 +1663,28 @@ function bp_activity_get( $args = '' ) {
1663
* );
1664
*/
1665
'filter' => array()
1666
- ) );
1667
-
1668
- // Attempt to return a cached copy of the first page of sitewide activity.
1669
- if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && ( 'all' === $r['fields'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['scope'] )&& empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
1670
-
1671
- $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
1672
- if ( false === $activity ) {
1673
-
1674
- $activity = BP_Activity_Activity::get( array(
1675
- 'page' => $r['page'],
1676
- 'per_page' => $r['per_page'],
1677
- 'max' => $r['max'],
1678
- 'fields' => $r['fields'],
1679
- 'sort' => $r['sort'],
1680
- 'search_terms' => $r['search_terms'],
1681
- 'meta_query' => $r['meta_query'],
1682
- 'date_query' => $r['date_query'],
1683
- 'filter_query' => $r['filter_query'],
1684
- 'filter' => $r['filter'],
1685
- 'scope' => $r['scope'],
1686
- 'display_comments' => $r['display_comments'],
1687
- 'show_hidden' => $r['show_hidden'],
1688
- 'spam' => $r['spam'],
1689
- 'update_meta_cache' => $r['update_meta_cache'],
1690
- 'count_total' => $r['count_total'],
1691
- ) );
1692
-
1693
- wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
1694
- }
1695
1696
- } else {
1697
- $activity = BP_Activity_Activity::get( array(
1698
- 'page' => $r['page'],
1699
- 'per_page' => $r['per_page'],
1700
- 'max' => $r['max'],
1701
- 'sort' => $r['sort'],
1702
- 'search_terms' => $r['search_terms'],
1703
- 'meta_query' => $r['meta_query'],
1704
- 'date_query' => $r['date_query'],
1705
- 'filter_query' => $r['filter_query'],
1706
- 'filter' => $r['filter'],
1707
- 'scope' => $r['scope'],
1708
- 'display_comments' => $r['display_comments'],
1709
- 'show_hidden' => $r['show_hidden'],
1710
- 'exclude' => $r['exclude'],
1711
- 'in' => $r['in'],
1712
- 'spam' => $r['spam'],
1713
- 'count_total' => $r['count_total'],
1714
- ) );
1715
- }
1716
1717
/**
1718
* Filters the requested activity item(s).
@@ -3417,6 +3389,211 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
3417
do_action( 'bp_activity_mark_as_ham', $activity, $source );
3418
}
3419
3420
3421
/** Embeds *******************************************************************/
3422
1663
* );
1664
*/
1665
'filter' => array()
1666
+ ), 'activity_get' );
1667
1668
+ $activity = BP_Activity_Activity::get( array(
1669
+ 'page' => $r['page'],
1670
+ 'per_page' => $r['per_page'],
1671
+ 'max' => $r['max'],
1672
+ 'sort' => $r['sort'],
1673
+ 'search_terms' => $r['search_terms'],
1674
+ 'meta_query' => $r['meta_query'],
1675
+ 'date_query' => $r['date_query'],
1676
+ 'filter_query' => $r['filter_query'],
1677
+ 'filter' => $r['filter'],
1678
+ 'scope' => $r['scope'],
1679
+ 'display_comments' => $r['display_comments'],
1680
+ 'show_hidden' => $r['show_hidden'],
1681
+ 'exclude' => $r['exclude'],
1682
+ 'in' => $r['in'],
1683
+ 'spam' => $r['spam'],
1684
+ 'update_meta_cache' => $r['update_meta_cache'],
1685
+ 'count_total' => $r['count_total'],
1686
+ 'fields' => $r['fields'],
1687
+ ) );
1688
1689
/**
1690
* Filters the requested activity item(s).
3389
do_action( 'bp_activity_mark_as_ham', $activity, $source );
3390
}
3391
3392
+ /* Emails *********************************************************************/
3393
+
3394
+ /**
3395
+ * Send email and BP notifications when a user is mentioned in an update.
3396
+ *
3397
+ * @since 1.2.0
3398
+ *
3399
+ * @param int $activity_id The ID of the activity update.
3400
+ * @param int $receiver_user_id The ID of the user who is receiving the update.
3401
+ */
3402
+ function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
3403
+ $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' );
3404
+
3405
+ // Don't leave multiple notifications for the same activity item.
3406
+ foreach( $notifications as $notification ) {
3407
+ if ( $activity_id == $notification->item_id ) {
3408
+ return;
3409
+ }
3410
+ }
3411
+
3412
+ $activity = new BP_Activity_Activity( $activity_id );
3413
+ $email_type = 'activity-at-message';
3414
+ $group_name = '';
3415
+ $message_link = bp_activity_get_permalink( $activity_id );
3416
+ $poster_name = bp_core_get_user_displayname( $activity->user_id );
3417
+
3418
+ remove_filter( 'bp_get_activity_content_body', 'convert_smilies' );
3419
+ remove_filter( 'bp_get_activity_content_body', 'wpautop' );
3420
+ remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
3421
+
3422
+ /** This filter is documented in bp-activity/bp-activity-template.php */
3423
+ $content = apply_filters( 'bp_get_activity_content_body', $activity->content );
3424
+
3425
+ add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
3426
+ add_filter( 'bp_get_activity_content_body', 'wpautop' );
3427
+ add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
3428
+
3429
+ // Now email the user with the contents of the message (if they have enabled email notifications).
3430
+ if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
3431
+ if ( bp_is_active( 'groups' ) && bp_is_group() ) {
3432
+ $email_type = 'groups-at-message';
3433
+ $group_name = bp_get_current_group_name();
3434
+ }
3435
+
3436
+ $unsubscribe_args = array(
3437
+ 'user_id' => $receiver_user_id,
3438
+ 'notification_type' => $email_type,
3439
+ );
3440
+
3441
+ $args = array(
3442
+ 'tokens' => array(
3443
+ 'activity' => $activity,
3444
+ 'usermessage' => wp_strip_all_tags( $content ),
3445
+ 'group.name' => $group_name,
3446
+ 'mentioned.url' => $message_link,
3447
+ 'poster.name' => $poster_name,
3448
+ 'receiver-user.id' => $receiver_user_id,
3449
+ 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
3450
+ ),
3451
+ );
3452
+
3453
+ bp_send_email( $email_type, $receiver_user_id, $args );
3454
+ }
3455
+
3456
+ /**
3457
+ * Fires after the sending of an @mention email notification.
3458
+ *
3459
+ * @since 1.5.0
3460
+ * @since 2.5.0 $subject, $message, $content arguments unset and deprecated.
3461
+ *
3462
+ * @param BP_Activity_Activity $activity Activity Item object.
3463
+ * @param string $deprecated Removed in 2.5; now an empty string.
3464
+ * @param string $deprecated Removed in 2.5; now an empty string.
3465
+ * @param string $deprecated Removed in 2.5; now an empty string.
3466
+ * @param int $receiver_user_id The ID of the user who is receiving the update.
3467
+ */
3468
+ do_action( 'bp_activity_sent_mention_email', $activity, '', '', '', $receiver_user_id );
3469
+ }
3470
+
3471
+ /**
3472
+ * Send email and BP notifications when an activity item receives a comment.
3473
+ *
3474
+ * @since 1.2.0
3475
+ * @since 2.5.0 Updated to use new email APIs.
3476
+ *
3477
+ * @param int $comment_id The comment id.
3478
+ * @param int $commenter_id The ID of the user who posted the comment.
3479
+ * @param array $params {@link bp_activity_new_comment()}.
3480
+ */
3481
+ function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
3482
+ $original_activity = new BP_Activity_Activity( $params['activity_id'] );
3483
+ $poster_name = bp_core_get_user_displayname( $commenter_id );
3484
+ $thread_link = bp_activity_get_permalink( $params['activity_id'] );
3485
+
3486
+ remove_filter( 'bp_get_activity_content_body', 'convert_smilies' );
3487
+ remove_filter( 'bp_get_activity_content_body', 'wpautop' );
3488
+ remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
3489
+
3490
+ /** This filter is documented in bp-activity/bp-activity-template.php */
3491
+ $content = apply_filters( 'bp_get_activity_content_body', $params['content'] );
3492
+
3493
+ add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
3494
+ add_filter( 'bp_get_activity_content_body', 'wpautop' );
3495
+ add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
3496
+
3497
+ if ( $original_activity->user_id != $commenter_id ) {
3498
+
3499
+ // Send an email if the user hasn't opted-out.
3500
+ if ( 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) {
3501
+
3502
+ $unsubscribe_args = array(
3503
+ 'user_id' => $original_activity->user_id,
3504
+ 'notification_type' => 'activity-comment',
3505
+ );
3506
+
3507
+ $args = array(
3508
+ 'tokens' => array(
3509
+ 'comment.id' => $comment_id,
3510
+ 'commenter.id' => $commenter_id,
3511
+ 'usermessage' => wp_strip_all_tags( $content ),
3512
+ 'original_activity.user_id' => $original_activity->user_id,
3513
+ 'poster.name' => $poster_name,
3514
+ 'thread.url' => esc_url( $thread_link ),
3515
+ 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
3516
+ ),
3517
+ );
3518
+
3519
+ bp_send_email( 'activity-comment', $original_activity->user_id, $args );
3520
+ }
3521
+
3522
+ /**
3523
+ * Fires at the point that notifications should be sent for activity comments.
3524
+ *
3525
+ * @since 2.6.0
3526
+ *
3527
+ * @param BP_Activity_Activity $original_activity The original activity.
3528
+ * @param int $comment_id ID for the newly received comment.
3529
+ * @param int $commenter_id ID of the user who made the comment.
3530
+ * @param array $params Arguments used with the original activity comment.
3531
+ */
3532
+ do_action( 'bp_activity_sent_reply_to_update_notification', $original_activity, $comment_id, $commenter_id, $params );
3533
+ }
3534
+
3535
+
3536
+ /*
3537
+ * If this is a reply to another comment, send an email notification to the
3538
+ * author of the immediate parent comment.
3539
+ */
3540
+ if ( empty( $params['parent_id'] ) || ( $params['activity_id'] == $params['parent_id'] ) ) {
3541
+ return;
3542
+ }
3543
+
3544
+ $parent_comment = new BP_Activity_Activity( $params['parent_id'] );
3545
+
3546
+ if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id ) {
3547
+
3548
+ // Send an email if the user hasn't opted-out.
3549
+ if ( 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
3550
+
3551
+ $unsubscribe_args = array(
3552
+ 'user_id' => $parent_comment->user_id,
3553
+ 'notification_type' => 'activity-comment-author',
3554
+ );
3555
+
3556
+ $args = array(
3557
+ 'tokens' => array(
3558
+ 'comment.id' => $comment_id,
3559
+ 'commenter.id' => $commenter_id,
3560
+ 'usermessage' => wp_strip_all_tags( $content ),
3561
+ 'parent-comment-user.id' => $parent_comment->user_id,
3562
+ 'poster.name' => $poster_name,
3563
+ 'thread.url' => esc_url( $thread_link ),
3564
+ 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
3565
+ ),
3566
+ );
3567
+
3568
+ bp_send_email( 'activity-comment-author', $parent_comment->user_id, $args );
3569
+ }
3570
+
3571
+ /**
3572
+ * Fires at the point that notifications should be sent for comments on activity replies.
3573
+ *
3574
+ * @since 2.6.0
3575
+ *
3576
+ * @param BP_Activity_Activity $parent_comment The parent activity.
3577
+ * @param int $comment_id ID for the newly received comment.
3578
+ * @param int $commenter_id ID of the user who made the comment.
3579
+ * @param array $params Arguments used with the original activity comment.
3580
+ */
3581
+ do_action( 'bp_activity_sent_reply_to_reply_notification', $parent_comment, $comment_id, $commenter_id, $params );
3582
+ }
3583
+ }
3584
+
3585
+ /**
3586
+ * Helper method to map action arguments to function parameters.
3587
+ *
3588
+ * @since 1.9.0
3589
+ *
3590
+ * @param int $comment_id ID of the comment being notified about.
3591
+ * @param array $params Parameters to use with notification.
3592
+ */
3593
+ function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
3594
+ bp_activity_new_comment_notification( $comment_id, $params['user_id'], $params );
3595
+ }
3596
+ add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_helper', 10, 2 );
3597
3598
/** Embeds *******************************************************************/
3599
bp-activity/bp-activity-loader.php CHANGED
@@ -17,7 +17,7 @@ if ( ! buddypress()->do_autoload ) {
17
}
18
19
/**
20
- * Bootstrap the Activity component.
21
*
22
* @since 1.6.0
23
*/
17
}
18
19
/**
20
+ * Set up the bp-activity component.
21
*
22
* @since 1.6.0
23
*/
bp-activity/bp-activity-notifications.php CHANGED
@@ -10,194 +10,6 @@
10
// Exit if accessed directly.
11
defined( 'ABSPATH' ) || exit;
12
13
- /* Emails *********************************************************************/
14
-
15
- /**
16
- * Send email and BP notifications when a user is mentioned in an update.
17
- *
18
- * @since 1.2.0
19
- *
20
- * @param int $activity_id The ID of the activity update.
21
- * @param int $receiver_user_id The ID of the user who is receiving the update.
22
- */
23
- function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
24
- $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' );
25
-
26
- // Don't leave multiple notifications for the same activity item.
27
- foreach( $notifications as $notification ) {
28
- if ( $activity_id == $notification->item_id ) {
29
- return;
30
- }
31
- }
32
-
33
- $activity = new BP_Activity_Activity( $activity_id );
34
- $email_type = 'activity-at-message';
35
- $group_name = '';
36
- $message_link = bp_activity_get_permalink( $activity_id );
37
- $poster_name = bp_core_get_user_displayname( $activity->user_id );
38
-
39
- remove_filter( 'bp_get_activity_content_body', 'convert_smilies' );
40
- remove_filter( 'bp_get_activity_content_body', 'wpautop' );
41
- remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
42
-
43
- /** This filter is documented in bp-activity/bp-activity-template.php */
44
- $content = apply_filters( 'bp_get_activity_content_body', $activity->content );
45
-
46
- add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
47
- add_filter( 'bp_get_activity_content_body', 'wpautop' );
48
- add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
49
-
50
- // Now email the user with the contents of the message (if they have enabled email notifications).
51
- if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
52
- if ( bp_is_active( 'groups' ) && bp_is_group() ) {
53
- $email_type = 'groups-at-message';
54
- $group_name = bp_get_current_group_name();
55
- }
56
-
57
- $args = array(
58
- 'tokens' => array(
59
- 'activity' => $activity,
60
- 'usermessage' => wp_strip_all_tags( $content ),
61
- 'group.name' => $group_name,
62
- 'mentioned.url' => $message_link,
63
- 'poster.name' => $poster_name,
64
- 'receiver-user.id' => $receiver_user_id,
65
- ),
66
- );
67
-
68
- bp_send_email( $email_type, $receiver_user_id, $args );
69
- }
70
-
71
- /**
72
- * Fires after the sending of an @mention email notification.
73
- *
74
- * @since 1.5.0
75
- * @since 2.5.0 $subject, $message, $content arguments unset and deprecated.
76
- *
77
- * @param BP_Activity_Activity $activity Activity Item object.
78
- * @param string $deprecated Removed in 2.5; now an empty string.
79
- * @param string $deprecated Removed in 2.5; now an empty string.
80
- * @param string $deprecated Removed in 2.5; now an empty string.
81
- * @param int $receiver_user_id The ID of the user who is receiving the update.
82
- */
83
- do_action( 'bp_activity_sent_mention_email', $activity, '', '', '', $receiver_user_id );
84
- }
85
-
86
- /**
87
- * Send email and BP notifications when an activity item receives a comment.
88
- *
89
- * @since 1.2.0
90
- * @since 2.5.0 Updated to use new email APIs.
91
- *
92
- * @param int $comment_id The comment id.
93
- * @param int $commenter_id The ID of the user who posted the comment.
94
- * @param array $params {@link bp_activity_new_comment()}.
95
- */
96
- function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
97
- $original_activity = new BP_Activity_Activity( $params['activity_id'] );
98
- $poster_name = bp_core_get_user_displayname( $commenter_id );
99
- $thread_link = bp_activity_get_permalink( $params['activity_id'] );
100
-
101
- remove_filter( 'bp_get_activity_content_body', 'convert_smilies' );
102
- remove_filter( 'bp_get_activity_content_body', 'wpautop' );
103
- remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
104
-
105
- /** This filter is documented in bp-activity/bp-activity-template.php */
106
- $content = apply_filters( 'bp_get_activity_content_body', $params['content'] );
107
-
108
- add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
109
- add_filter( 'bp_get_activity_content_body', 'wpautop' );
110
- add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
111
-
112
- if ( $original_activity->user_id != $commenter_id ) {
113
-
114
- // Send an email if the user hasn't opted-out.
115
- if ( 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) {
116
- $args = array(
117
- 'tokens' => array(
118
- 'comment.id' => $comment_id,
119
- 'commenter.id' => $commenter_id,
120
- 'usermessage' => wp_strip_all_tags( $content ),
121
- 'original_activity.user_id' => $original_activity->user_id,
122
- 'poster.name' => $poster_name,
123
- 'thread.url' => esc_url( $thread_link ),
124
- ),
125
- );
126
-
127
- bp_send_email( 'activity-comment', $original_activity->user_id, $args );
128
- }
129
-
130
- /**
131
- * Fires at the point that notifications should be sent for activity comments.
132
- *
133
- * @since 2.6.0
134
- *
135
- * @param BP_Activity_Activity $original_activity The original activity.
136
- * @param int $comment_id ID for the newly received comment.
137
- * @param int $commenter_id ID of the user who made the comment.
138
- * @param array $params Arguments used with the original activity comment.
139
- */
140
- do_action( 'bp_activity_sent_reply_to_update_notification', $original_activity, $comment_id, $commenter_id, $params );
141
- }
142
-
143
-
144
- /*
145
- * If this is a reply to another comment, send an email notification to the
146
- * author of the immediate parent comment.
147
- */
148
- if ( empty( $params['parent_id'] ) || ( $params['activity_id'] == $params['parent_id'] ) ) {
149
- return;
150
- }
151
-
152
- $parent_comment = new BP_Activity_Activity( $params['parent_id'] );
153
-
154
- if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id ) {
155
-
156
- // Send an email if the user hasn't opted-out.
157
- if ( 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
158
- $args = array(
159
- 'tokens' => array(
160
- 'comment.id' => $comment_id,
161
- 'commenter.id' => $commenter_id,
162
- 'usermessage' => wp_strip_all_tags( $content ),
163
- 'parent-comment-user.id' => $parent_comment->user_id,
164
- 'poster.name' => $poster_name,
165
- 'thread.url' => esc_url( $thread_link ),
166
- ),
167
- );
168
-
169
- bp_send_email( 'activity-comment-author', $parent_comment->user_id, $args );
170
- }
171
-
172
- /**
173
- * Fires at the point that notifications should be sent for comments on activity replies.
174
- *
175
- * @since 2.6.0
176
- *
177
- * @param BP_Activity_Activity $parent_comment The parent activity.
178
- * @param int $comment_id ID for the newly received comment.
179
- * @param int $commenter_id ID of the user who made the comment.
180
- * @param array $params Arguments used with the original activity comment.
181
- */
182
- do_action( 'bp_activity_sent_reply_to_reply_notification', $parent_comment, $comment_id, $commenter_id, $params );
183
- }
184
- }
185
-
186
- /**
187
- * Helper method to map action arguments to function parameters.
188
- *
189
- * @since 1.9.0
190
- *
191
- * @param int $comment_id ID of the comment being notified about.
192
- * @param array $params Parameters to use with notification.
193
- */
194
- function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
195
- bp_activity_new_comment_notification( $comment_id, $params['user_id'], $params );
196
- }
197
- add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_helper', 10, 2 );
198
-
199
- /** Notifications *************************************************************/
200
-
201
/**
202
* Format notifications related to activity.
203
*
@@ -339,8 +151,7 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
339
* @param int $receiver_user_id ID of user receiving notification.
340
*/
341
function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
342
- if ( bp_is_active( 'notifications' ) ) {
343
- bp_notifications_add_notification( array(
344
'user_id' => $receiver_user_id,
345
'item_id' => $activity->id,
346
'secondary_item_id' => $activity->user_id,
@@ -348,8 +159,7 @@ function bp_activity_at_mention_add_notification( $activity, $subject, $message,
348
'component_action' => 'new_at_mention',
349
'date_notified' => bp_core_current_time(),
350
'is_new' => 1,
351
- ) );
352
- }
353
}
354
add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notification', 10, 5 );
355
@@ -363,17 +173,15 @@ add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notifi
363
* @param int $commenter_id ID of the user who made the comment.
364
*/
365
function bp_activity_update_reply_add_notification( $activity, $comment_id, $commenter_id ) {
366
- if ( bp_is_active( 'notifications' ) ) {
367
- bp_notifications_add_notification( array(
368
- 'user_id' => $activity->user_id,
369
- 'item_id' => $comment_id,
370
- 'secondary_item_id' => $commenter_id,
371
- 'component_name' => buddypress()->activity->id,
372
- 'component_action' => 'update_reply',
373
- 'date_notified' => bp_core_current_time(),
374
- 'is_new' => 1,
375
- ) );
376
- }
377
}
378
add_action( 'bp_activity_sent_reply_to_update_notification', 'bp_activity_update_reply_add_notification', 10, 3 );
379
@@ -387,17 +195,15 @@ add_action( 'bp_activity_sent_reply_to_update_notification', 'bp_activity_update
387
* @param int $commenter_id ID of the user who made the comment.
388
*/
389
function bp_activity_comment_reply_add_notification( $activity_comment, $comment_id, $commenter_id ) {
390
- if ( bp_is_active( 'notifications' ) ) {
391
- bp_notifications_add_notification( array(
392
- 'user_id' => $activity_comment->user_id,
393
- 'item_id' => $comment_id,
394
- 'secondary_item_id' => $commenter_id,
395
- 'component_name' => buddypress()->activity->id,
396
- 'component_action' => 'comment_reply',
397
- 'date_notified' => bp_core_current_time(),
398
- 'is_new' => 1,
399
- ) );
400
- }
401
}
402
add_action( 'bp_activity_sent_reply_to_reply_notification', 'bp_activity_comment_reply_add_notification', 10, 3 );
403
@@ -410,10 +216,6 @@ add_action( 'bp_activity_sent_reply_to_reply_notification', 'bp_activity_comment
410
* @param int $user_id The id of the user whose notifications are marked as read.
411
*/
412
function bp_activity_remove_screen_notifications( $user_id = 0 ) {
413
- if ( ! bp_is_active( 'notifications' ) ) {
414
- return;
415
- }
416
-
417
// Only mark read if the current user is looking at his own mentions.
418
if ( empty( $user_id ) || (int) $user_id !== (int) bp_loggedin_user_id() ) {
419
return;
@@ -431,10 +233,6 @@ add_action( 'bp_activity_clear_new_mentions', 'bp_activity_remove_screen_notific
431
* @param BP_Activity_Activity $activity Activity object.
432
*/
433
function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
434
- if ( ! bp_is_active( 'notifications' ) ) {
435
- return;
436
- }
437
-
438
if ( ! is_user_logged_in() ) {
439
return;
440
}
@@ -453,7 +251,7 @@ add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_
453
* @since 2.6.0
454
*/
455
function bp_activity_remove_screen_notifications_for_non_mentions() {
456
- if ( false === bp_is_active( 'notifications' ) || false === is_singular() || false === is_user_logged_in() || empty( $_GET['nid'] ) ) {
457
return;
458
}
459
@@ -480,7 +278,7 @@ add_action( 'bp_screens', 'bp_activity_remove_screen_notifications_for_non_menti
480
function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) {
481
// Let's delete all without checking if content contains any mentions
482
// to avoid a query to get the activity.
483
- if ( bp_is_active( 'notifications' ) && ! empty( $activity_ids_deleted ) ) {
484
foreach ( $activity_ids_deleted as $activity_id ) {
485
bp_notifications_delete_all_notifications_by_type( $activity_id, buddypress()->activity->id );
486
}
@@ -502,7 +300,7 @@ add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_not
502
*/
503
function bp_activity_add_notification_for_synced_blog_comment( $activity_id, $post_type_comment, $activity_args, $activity_post_object ) {
504
// If activity comments are disabled for WP posts, stop now!
505
- if ( bp_disable_blogforum_comments() || empty( $activity_id ) || false === bp_is_active( 'notifications' ) ) {
506
return;
507
}
508
10
// Exit if accessed directly.
11
defined( 'ABSPATH' ) || exit;
12
13
/**
14
* Format notifications related to activity.
15
*
151
* @param int $receiver_user_id ID of user receiving notification.
152
*/
153
function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
154
+ bp_notifications_add_notification( array(
155
'user_id' => $receiver_user_id,
156
'item_id' => $activity->id,
157
'secondary_item_id' => $activity->user_id,
159
'component_action' => 'new_at_mention',
160
'date_notified' => bp_core_current_time(),
161
'is_new' => 1,
162
+ ) );
163
}
164
add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notification', 10, 5 );
165
173
* @param int $commenter_id ID of the user who made the comment.
174
*/
175
function bp_activity_update_reply_add_notification( $activity, $comment_id, $commenter_id ) {
176
+ bp_notifications_add_notification( array(
177
+ 'user_id' => $activity->user_id,
178
+ 'item_id' => $comment_id,
179
+ 'secondary_item_id' => $commenter_id,
180
+ 'component_name' => buddypress()->activity->id,
181
+ 'component_action' => 'update_reply',
182
+ 'date_notified' => bp_core_current_time(),
183
+ 'is_new' => 1,
184
+ ) );
185
}
186
add_action( 'bp_activity_sent_reply_to_update_notification', 'bp_activity_update_reply_add_notification', 10, 3 );
187
195
* @param int $commenter_id ID of the user who made the comment.
196
*/
197
function bp_activity_comment_reply_add_notification( $activity_comment, $comment_id, $commenter_id ) {
198
+ bp_notifications_add_notification( array(
199
+ 'user_id' => $activity_comment->user_id,
200
+ 'item_id' => $comment_id,
201
+ 'secondary_item_id' => $commenter_id,
202
+ 'component_name' => buddypress()->activity->id,
203
+ 'component_action' => 'comment_reply',
204
+ 'date_notified' => bp_core_current_time(),
205
+ 'is_new' => 1,
206
+ ) );
207
}
208
add_action( 'bp_activity_sent_reply_to_reply_notification', 'bp_activity_comment_reply_add_notification', 10, 3 );
209
216
* @param int $user_id The id of the user whose notifications are marked as read.
217
*/
218
function bp_activity_remove_screen_notifications( $user_id = 0 ) {
219
// Only mark read if the current user is looking at his own mentions.
220
if ( empty( $user_id ) || (int) $user_id !== (int) bp_loggedin_user_id() ) {
221
return;
233
* @param BP_Activity_Activity $activity Activity object.
234
*/
235
function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
236
if ( ! is_user_logged_in() ) {
237
return;
238
}
251
* @since 2.6.0
252
*/
253
function bp_activity_remove_screen_notifications_for_non_mentions() {
254
+ if ( false === is_singular() || false === is_user_logged_in() || empty( $_GET['nid'] ) ) {
255
return;
256
}
257
278
function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) {
279
// Let's delete all without checking if content contains any mentions
280
// to avoid a query to get the activity.
281
+ if ( ! empty( $activity_ids_deleted ) ) {
282
foreach ( $activity_ids_deleted as $activity_id ) {
283
bp_notifications_delete_all_notifications_by_type( $activity_id, buddypress()->activity->id );
284
}
300
*/
301
function bp_activity_add_notification_for_synced_blog_comment( $activity_id, $post_type_comment, $activity_args, $activity_post_object ) {
302
// If activity comments are disabled for WP posts, stop now!
303
+ if ( bp_disable_blogforum_comments() || empty( $activity_id ) ) {
304
return;
305
}
306
bp-activity/bp-activity-screens.php CHANGED
@@ -236,7 +236,7 @@ function bp_activity_screen_single_activity_permalink() {
236
237
// Check to see if the group is not public, if so, check the
238
// user has access to see this activity.
239
- if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
240
241
// Group is not public.
242
if ( 'public' != $group->status ) {
236
237
// Check to see if the group is not public, if so, check the
238
// user has access to see this activity.
239
+ if ( $group = groups_get_group( $activity->item_id ) ) {
240
241
// Group is not public.
242
if ( 'public' != $group->status ) {
bp-activity/bp-activity-template.php CHANGED
@@ -1177,11 +1177,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1177
1178
// Only if groups is active.
1179
if ( bp_is_active( 'groups' ) ) {
1180
- $group = groups_get_group( array(
1181
- 'group_id' => $item_id,
1182
- 'populate_extras' => false,
1183
- 'update_meta_cache' => false,
1184
- ) );
1185
$link = bp_get_group_permalink( $group );
1186
$name = $group->name;
1187
}
@@ -1476,6 +1472,13 @@ function bp_insert_activity_meta( $content = '' ) {
1476
// Get the time since this activity was recorded.
1477
$date_recorded = bp_core_time_since( $activities_template->activity->date_recorded );
1478
1479
/**
1480
* Filters the activity item time since markup.
1481
*
@@ -1484,7 +1487,7 @@ function bp_insert_activity_meta( $content = '' ) {
1484
* @param array $value Array containing the time since markup and the current activity component.
1485
*/
1486
$time_since = apply_filters_ref_array( 'bp_activity_time_since', array(
1487
- '<span class="time-since">' . $date_recorded . '</span>',
1488
&$activities_template->activity
1489
) );
1490
@@ -1533,7 +1536,7 @@ function bp_insert_activity_meta( $content = '' ) {
1533
*
1534
* @global object $activities_template {@link BP_Activity_Template}
1535
*
1536
- * @param object|bool $activity Optional. Falls back on the current item in the loop.
1537
* @return bool True if can delete, false otherwise.
1538
*/
1539
function bp_activity_user_can_delete( $activity = false ) {
@@ -2090,7 +2093,7 @@ function bp_activity_comment_delete_link() {
2090
* activity comment.
2091
*/
2092
function bp_get_activity_comment_delete_link() {
2093
- $link = wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
2094
2095
/**
2096
* Filters the link used for deleting the activity comment currently being displayed.
@@ -3162,8 +3165,6 @@ function bp_send_public_message_button( $args = '' ) {
3162
* @type string $wrapper_id Default: 'post-mention'.
3163
* @type string $link_href Default: the public message link for
3164
* the current member in the loop.
3165
- * @type string $link_title Default: 'Send a public message on your
3166
- * activity stream.'.
3167
* @type string $link_text Default: 'Public Message'.
3168
* @type string $link_class Default: 'activity-button mention'.
3169
* }
@@ -3178,7 +3179,6 @@ function bp_send_public_message_button( $args = '' ) {
3178
'block_self' => true,
3179
'wrapper_id' => 'post-mention',
3180
'link_href' => bp_get_send_public_message_link(),
3181
- 'link_title' => __( 'Send a public message on your activity stream.', 'buddypress' ),
3182
'link_text' => __( 'Public Message', 'buddypress' ),
3183
'link_class' => 'activity-button mention'
3184
) );
1177
1178
// Only if groups is active.
1179
if ( bp_is_active( 'groups' ) ) {
1180
+ $group = groups_get_group( $item_id );
1181
$link = bp_get_group_permalink( $group );
1182
$name = $group->name;
1183
}
1472
// Get the time since this activity was recorded.
1473
$date_recorded = bp_core_time_since( $activities_template->activity->date_recorded );
1474
1475
+ // Set up 'time-since' <span>.
1476
+ $time_since = sprintf(
1477
+ '<span class="time-since" data-livestamp="%1$s">%2$s</span>',
1478
+ bp_core_get_iso8601_date( $activities_template->activity->date_recorded ),
1479
+ $date_recorded
1480
+ );
1481
+
1482
/**
1483
* Filters the activity item time since markup.
1484
*
1487
* @param array $value Array containing the time since markup and the current activity component.
1488
*/
1489
$time_since = apply_filters_ref_array( 'bp_activity_time_since', array(
1490
+ $time_since,
1491
&$activities_template->activity
1492
) );
1493
1536
*
1537
* @global object $activities_template {@link BP_Activity_Template}
1538
*
1539
+ * @param BP_Activity_Activity $activity Optional. Falls back on the current item in the loop.
1540
* @return bool True if can delete, false otherwise.
1541
*/
1542
function bp_activity_user_can_delete( $activity = false ) {
2093
* activity comment.
2094
*/
2095
function bp_get_activity_comment_delete_link() {
2096
+ $link = wp_nonce_url( bp_get_activity_directory_permalink() . 'delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
2097
2098
/**
2099
* Filters the link used for deleting the activity comment currently being displayed.
3165
* @type string $wrapper_id Default: 'post-mention'.
3166
* @type string $link_href Default: the public message link for
3167
* the current member in the loop.
3168
* @type string $link_text Default: 'Public Message'.
3169
* @type string $link_class Default: 'activity-button mention'.
3170
* }
3179
'block_self' => true,
3180
'wrapper_id' => 'post-mention',
3181
'link_href' => bp_get_send_public_message_link(),
3182
'link_text' => __( 'Public Message', 'buddypress' ),
3183
'link_class' => 'activity-button mention'
3184
) );
bp-activity/classes/class-bp-activity-activity.php CHANGED
@@ -645,7 +645,23 @@ class BP_Activity_Activity {
645
*/
646
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
647
648
- $activity_ids = $wpdb->get_col( $activity_ids_sql );
649
650
$retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
651
@@ -702,7 +718,13 @@ class BP_Activity_Activity {
702
* @param string $sort Sort direction for query.
703
*/
704
$total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
705
- $total_activities = $wpdb->get_var( $total_activities_sql );
706
707
if ( !empty( $r['max'] ) ) {
708
if ( (int) $total_activities > (int) $r['max'] ) {
645
*/
646
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
647
648
+ /*
649
+ * Queries that include 'last_activity' are cached separately,
650
+ * since they are generally much less long-lived.
651
+ */
652
+ if ( preg_match( '/a\.type NOT IN \([^\)]*\'last_activity\'[^\)]*\)/', $activity_ids_sql ) ) {
653
+ $cache_group = 'bp_activity';
654
+ } else {
655
+ $cache_group = 'bp_activity_with_last_activity';
656
+ }
657
+
658
+ $cached = bp_core_get_incremented_cache( $activity_ids_sql, $cache_group );
659
+ if ( false === $cached ) {
660
+ $activity_ids = $wpdb->get_col( $activity_ids_sql );
661
+ bp_core_set_incremented_cache( $activity_ids_sql, $cache_group, $activity_ids );
662
+ } else {
663
+ $activity_ids = $cached;
664
+ }
665
666
$retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
667
718
* @param string $sort Sort direction for query.
719
*/
720
$total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
721
+ $cached = bp_core_get_incremented_cache( $total_activities_sql, $cache_group );
722
+ if ( false === $cached ) {
723
+ $total_activities = $wpdb->get_var( $total_activities_sql );
724
+ bp_core_set_incremented_cache( $total_activities_sql, $cache_group, $total_activities );
725
+ } else {
726
+ $total_activities = $cached;
727
+ }
728
729
if ( !empty( $r['max'] ) ) {
730
if ( (int) $total_activities > (int) $r['max'] ) {
bp-activity/classes/class-bp-activity-component.php CHANGED
@@ -57,10 +57,14 @@ class BP_Activity_Component extends BP_Component {
57
'adminbar',
58
'template',
59
'functions',
60
- 'notifications',
61
'cache'
62
);
63
64
if ( ! buddypress()->do_autoload ) {
65
$includes[] = 'classes';
66
}
@@ -68,7 +72,7 @@ class BP_Activity_Component extends BP_Component {
68
// Load Akismet support if Akismet is configured.
69
$akismet_key = bp_get_option( 'wordpress_api_key' );
70
71
- /** This filter is documented in bp-activity/bp-activity-actions.php */
72
if ( defined( 'AKISMET_VERSION' ) && class_exists( 'Akismet' ) && ( ! empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
73
$includes[] = 'akismet';
74
}
@@ -116,13 +120,17 @@ class BP_Activity_Component extends BP_Component {
116
'activity' => $bp->table_prefix . 'bp_activity_meta',
117
);
118
119
// All globals for activity component.
120
// Note that global_tables is included in this array.
121
$args = array(
122
'slug' => BP_ACTIVITY_SLUG,
123
'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
124
'has_directory' => true,
125
- 'directory_title' => _x( 'Site-Wide Activity', 'component directory title', 'buddypress' ),
126
'notification_callback' => 'bp_activity_format_notifications',
127
'search_string' => __( 'Search Activity...', 'buddypress' ),
128
'global_tables' => $global_tables,
@@ -361,19 +369,6 @@ class BP_Activity_Component extends BP_Component {
361
parent::setup_title();
362
}
363
364
- /**
365
- * Set up actions necessary for the component.
366
- *
367
- * @since 1.6.0
368
- */
369
- public function setup_actions() {
370
-
371
- // Spam prevention.
372
- add_action( 'bp_include', 'bp_activity_setup_akismet' );
373
-
374
- parent::setup_actions();
375
- }
376
-
377
/**
378
* Setup cache groups.
379
*
57
'adminbar',
58
'template',
59
'functions',
60
'cache'
61
);
62
63
+ // Notifications support.
64
+ if ( bp_is_active( 'notifications' ) ) {
65
+ $includes[] = 'notifications';
66
+ }
67
+
68
if ( ! buddypress()->do_autoload ) {
69
$includes[] = 'classes';
70
}
72
// Load Akismet support if Akismet is configured.
73
$akismet_key = bp_get_option( 'wordpress_api_key' );
74
75
+ /** This filter is documented in bp-activity/bp-activity-akismet.php */
76
if ( defined( 'AKISMET_VERSION' ) && class_exists( 'Akismet' ) && ( ! empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
77
$includes[] = 'akismet';
78
}
120
'activity' => $bp->table_prefix . 'bp_activity_meta',
121
);
122
123
+ // Fetch the default directory title.
124
+ $default_directory_titles = bp_core_get_directory_page_default_titles();
125
+ $default_directory_title = $default_directory_titles[$this->id];
126
+
127
// All globals for activity component.
128
// Note that global_tables is included in this array.
129
$args = array(
130
'slug' => BP_ACTIVITY_SLUG,
131
'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
132
'has_directory' => true,
133
+ 'directory_title' => isset( $bp->pages->activity->title ) ? $bp->pages->activity->title : $default_directory_title,
134
'notification_callback' => 'bp_activity_format_notifications',
135
'search_string' => __( 'Search Activity...', 'buddypress' ),
136
'global_tables' => $global_tables,
369
parent::setup_title();
370
}
371
372
/**
373
* Setup cache groups.
374
*
bp-activity/classes/class-bp-activity-list-table.php CHANGED
@@ -428,8 +428,26 @@ class BP_Activity_List_Table extends WP_List_Table {
428
<option value="" <?php selected( ! $selected ); ?>><?php _e( 'View all actions', 'buddypress' ); ?></option>
429
430
<?php foreach ( $activity_actions as $component => $actions ) : ?>
431
-
432
- <optgroup label="<?php echo ucfirst( $component ); ?>">
433
434
<?php foreach ( $actions as $action_key => $action_values ) : ?>
435
428
<option value="" <?php selected( ! $selected ); ?>><?php _e( 'View all actions', 'buddypress' ); ?></option>
429
430
<?php foreach ( $activity_actions as $component => $actions ) : ?>
431
+ <?php
432
+ // Older avatar activity items use 'profile' for component. See r4273.
433
+ if ( $component === 'profile' ) {
434
+ $component = 'xprofile';
435
+ }
436
+
437
+ if ( bp_is_active( $component ) ) {
438
+ if ( $component === 'xprofile' ) {
439
+ $component_name = buddypress()->profile->name;
440
+ } else {
441
+ $component_name = buddypress()->$component->name;
442
+ }
443
+
444
+ } else {
445
+ // Prevent warnings by other plugins if a component is disabled but the activity type has been registered.
446
+ $component_name = ucfirst( $component );
447
+ }
448
+ ?>
449
+
450
+ <optgroup label="<?php echo esc_html( $component_name ); ?>">
451
452
<?php foreach ( $actions as $action_key => $action_values ) : ?>
453
bp-activity/js/mentions.min.js CHANGED
@@ -1 +1 @@
1
- window.bp=window.bp||{},function(a,b,c){var d,e=[];a.mentions=a.mentions||{},a.mentions.users=window.bp.mentions.users||[],"object"==typeof window.BP_Suggestions&&(a.mentions.users=window.BP_Suggestions.friends||a.mentions.users),b.fn.bp_mentions=function(a){b.isArray(a)&&(a={data:a});var c={delay:200,hide_without_suffix:!0,insert_tpl:"</>${atwho-data-value}</>",limit:10,start_with_space:!1,suffix:"",callbacks:{filter:function(a,b,c){var d,e,f,g=[],h=new RegExp("^"+a+"| "+a,"ig");for(e=0,f=b.length;f>e;e++)d=b[e],d[c].toLowerCase().match(h)&&g.push(d);return g},highlighter:function(a,b){if(!b)return a;var c=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+b.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return a.replace(c,function(a,b,c,d){return">"+b+"<strong>"+c+"</strong>"+d+"<"})},before_reposition:function(a){var c,d,e,f,g=b("#atwho-ground-"+this.id+" .atwho-view"),h=b("body"),i=this.$inputor.data("atwho");"undefined"!==i&&"undefined"!==i.iframe&&null!==i.iframe?(c=this.$inputor.caret("offset",{iframe:i.iframe}),e=b(i.iframe).offset(),"undefined"!==e&&(c.left+=e.left,c.top+=e.top)):c=this.$inputor.caret("offset"),c.left>h.width()/2?(g.addClass("right"),f=c.left-a.left-this.view.$el.width()):(g.removeClass("right"),f=c.left-a.left+1),h.width()<=400&&b(document).scrollTop(c.top-6),d=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10),(!d||5>d)&&(d=19),a.top=c.top+d,a.left+=f},inserting_wrapper:function(a,b,c){return""+b+c}}},f={callbacks:{remote_filter:function(a,c){var f=b(this),g={};return d=e[a],"object"==typeof d?void c(d):(f.xhr&&f.xhr.abort(),g={action:"bp_get_suggestions",term:a,type:"members"},b.isNumeric(this.$inputor.data("suggestions-group-id"))&&(g["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),void(f.xhr=b.getJSON(ajaxurl,g).done(function(d){if(d.success){var f=b.map(d.data,function(a){return a.search=a.search||a.ID+" "+a.name,a});e[a]=f,c(f)}})))}},data:b.map(a.data,function(a){return a.search=a.search||a.ID+" "+a.name,a}),at:"@",search_key:"search",tpl:'<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'},g=b.extend(!0,{},c,f,a);return b.fn.atwho.call(this,g)},b(document).ready(function(){b(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(a.mentions.users)}),a.mentions.tinyMCEinit=function(){"undefined"!=typeof window.tinyMCE&&null!==window.tinyMCE.activeEditor&&"undefined"!=typeof window.tinyMCE.activeEditor&&b(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",b(".wp-editor-wrap iframe")[0]).bp_mentions(a.mentions.users)}}(bp,jQuery);
1
+ window.bp=window.bp||{},function(a,b,c){var d,e=[];a.mentions=a.mentions||{},a.mentions.users=window.bp.mentions.users||[],"object"==typeof window.BP_Suggestions&&(a.mentions.users=window.BP_Suggestions.friends||a.mentions.users),b.fn.bp_mentions=function(a){b.isArray(a)&&(a={data:a});var c={delay:200,hide_without_suffix:!0,insert_tpl:"</>${atwho-data-value}</>",limit:10,start_with_space:!1,suffix:"",callbacks:{filter:function(a,b,c){var d,e,f,g=[],h=new RegExp("^"+a+"| "+a,"ig");for(e=0,f=b.length;e<f;e++)d=b[e],d[c].toLowerCase().match(h)&&g.push(d);return g},highlighter:function(a,b){if(!b)return a;var c=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+b.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return a.replace(c,function(a,b,c,d){return">"+b+"<strong>"+c+"</strong>"+d+"<"})},before_reposition:function(a){var c,d,e,f,g=b("#atwho-ground-"+this.id+" .atwho-view"),h=b("body"),i=this.$inputor.data("atwho");"undefined"!==i&&"undefined"!==i.iframe&&null!==i.iframe?(c=this.$inputor.caret("offset",{iframe:i.iframe}),e=b(i.iframe).offset(),"undefined"!==e&&(c.left+=e.left,c.top+=e.top)):c=this.$inputor.caret("offset"),c.left>h.width()/2?(g.addClass("right"),f=c.left-a.left-this.view.$el.width()):(g.removeClass("right"),f=c.left-a.left+1),h.width()<=400&&b(document).scrollTop(c.top-6),d=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10),(!d||d<5)&&(d=19),a.top=c.top+d,a.left+=f},inserting_wrapper:function(a,b,c){return""+b+c}}},f={callbacks:{remote_filter:function(a,c){var f=b(this),g={};return d=e[a],"object"==typeof d?void c(d):(f.xhr&&f.xhr.abort(),g={action:"bp_get_suggestions",term:a,type:"members"},b.isNumeric(this.$inputor.data("suggestions-group-id"))&&(g["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),void(f.xhr=b.getJSON(ajaxurl,g).done(function(d){if(d.success){var f=b.map(d.data,function(a){return a.search=a.search||a.ID+" "+a.name,a});e[a]=f,c(f)}})))}},data:b.map(a.data,function(a){return a.search=a.search||a.ID+" "+a.name,a}),at:"@",search_key:"search",tpl:'<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'},g=b.extend(!0,{},c,f,a);return b.fn.atwho.call(this,g)},b(document).ready(function(){b(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(a.mentions.users)}),a.mentions.tinyMCEinit=function(){"undefined"!=typeof window.tinyMCE&&null!==window.tinyMCE.activeEditor&&"undefined"!=typeof window.tinyMCE.activeEditor&&b(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",b(".wp-editor-wrap iframe")[0]).bp_mentions(a.mentions.users)}}(bp,jQuery);
bp-blogs/bp-blogs-activity.php CHANGED
@@ -1291,7 +1291,7 @@ function bp_blogs_can_comment_reply( $retval, $comment ) {
1291
1292
// Check comment depth and disable if depth is too large.
1293
if ( isset( buddypress()->blogs->thread_depth[$comment->item_id] ) ){
1294
- if ( $comment->mptt_left > buddypress()->blogs->thread_depth[$comment->item_id] ) {
1295
$retval = false;
1296
}
1297
}
1291
1292
// Check comment depth and disable if depth is too large.
1293
if ( isset( buddypress()->blogs->thread_depth[$comment->item_id] ) ){
1294
+ if ( bp_activity_get_comment_depth() > buddypress()->blogs->thread_depth[$comment->item_id] ) {
1295
$retval = false;
1296
}
1297
}
bp-blogs/bp-blogs-filters.php CHANGED
@@ -121,3 +121,17 @@ function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0,
121
}
122
add_filter( 'bp_activity_post_pre_publish', 'bp_blogs_post_pre_publish', 10, 4 );
123
add_filter( 'bp_activity_post_pre_comment', 'bp_blogs_post_pre_publish', 10, 4 );
121
}
122
add_filter( 'bp_activity_post_pre_publish', 'bp_blogs_post_pre_publish', 10, 4 );
123
add_filter( 'bp_activity_post_pre_comment', 'bp_blogs_post_pre_publish', 10, 4 );
124
+
125
+ /**
126
+ * Registers our custom thumb size with WP's Site Icon feature.
127
+ *
128
+ * @since 2.7.0
129
+ *
130
+ * @param array $sizes Current array of custom site icon sizes.
131
+ * @return array
132
+ */
133
+ function bp_blogs_register_custom_site_icon_size( $sizes ) {
134
+ $sizes[] = bp_core_avatar_thumb_width();
135
+ return $sizes;
136
+ }
137
+ add_filter( 'site_icon_image_sizes', 'bp_blogs_register_custom_site_icon_size' );
bp-blogs/bp-blogs-functions.php CHANGED
@@ -475,6 +475,26 @@ function bp_blogs_update_option_thread_comments_depth( $oldvalue, $newvalue ) {
475
}
476
add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
477
478
/**
479
* Deletes the 'url' blogmeta for a site.
480
*
475
}
476
add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
477
478
+ /**
479
+ * Syncs site icon URLs to blogmeta.
480
+ *
481
+ * @since 2.7.0
482
+ *
483
+ * @param int|string $old_value Old value
484
+ * @param int|string $new_value New value
485
+ */
486
+ function bp_blogs_update_option_site_icon( $old_value, $new_value ) {
487
+ if ( 0 === $new_value ) {
488
+ bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_thumb', 0 );
489
+ bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_full', 0 );
490
+ } else {
491
+ // Save site icon URL as blogmeta.
492
+ bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_thumb', get_site_icon_url( bp_core_avatar_thumb_width() ) );
493
+ bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_full', get_site_icon_url( bp_core_avatar_full_width() ) );
494
+ }
495
+ }
496
+ add_action( 'update_option_site_icon', 'bp_blogs_update_option_site_icon', 10, 2 );
497
+
498
/**
499
* Deletes the 'url' blogmeta for a site.
500
*
bp-blogs/bp-blogs-loader.php CHANGED
@@ -20,6 +20,8 @@ if ( ! buddypress()->do_autoload ) {
20
21
/**
22
* Set up the bp-blogs component.
23
*/
24
function bp_setup_blogs() {
25
buddypress()->blogs = new BP_Blogs_Component();
20
21
/**
22
* Set up the bp-blogs component.
23
+ *
24
+ * @since 1.5.0
25
*/
26
function bp_setup_blogs() {
27
buddypress()->blogs = new BP_Blogs_Component();
bp-blogs/bp-blogs-template.php CHANGED
@@ -220,9 +220,20 @@ function bp_the_blog() {
220
/**
221
* Output the blogs pagination count.
222
*
223
- * @global object $blogs_template {@link BP_Blogs_Template}
224
*/
225
function bp_blogs_pagination_count() {
226
global $blogs_template;
227
228
$start_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1;
@@ -236,7 +247,17 @@ function bp_blogs_pagination_count() {
236
$message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s site', 'Viewing %1$s - %2$s of %3$s sites', $blogs_template->total_blog_count, 'buddypress' ), $from_num, $to_num, $total );
237
}
238
239
- echo $message;
240
}
241
242
/**
@@ -324,19 +345,77 @@ function bp_blog_avatar( $args = '' ) {
324
'no_grav' => true,
325
) );
326
327
- // Fetch the avatar.
328
- $avatar = bp_core_fetch_avatar( array(
329
- 'item_id' => $blogs_template->blog->admin_user_id,
330
- 'title' => $r['title'],
331
- // 'avatar_dir' => 'blog-avatars',
332
- // 'object' => 'blog',
333
- 'type' => $r['type'],
334
- 'alt' => $r['alt'],
335
- 'css_id' => $r['id'],
336
- 'class' => $r['class'],
337
- 'width' => $r['width'],
338
- 'height' => $r['height']
339
- ) );
340
341
/**
342
* In future BuddyPress versions you will be able to set the avatar for a blog.
@@ -1280,7 +1359,6 @@ function bp_blog_create_button() {
1280
'id' => 'create_blog',
1281
'component' => 'blogs',
1282
'link_text' => __( 'Create a Site', 'buddypress' ),
1283
- 'link_title' => __( 'Create a Site', 'buddypress' ),
1284
'link_class' => 'blog-create no-ajax',
1285
'link_href' => trailingslashit( bp_get_blogs_directory_permalink() . 'create' ),
1286
'wrapper' => false,
@@ -1377,7 +1455,6 @@ function bp_blogs_visit_blog_button( $args = '' ) {
1377
* @type string $link_href Permalink of the current blog in the loop.
1378
* @type string $link_class Default: 'blog-button visit'.
1379
* @type string $link_text Default: 'Visit Site'.
1380
- * @type string $link_title Default: 'Visit Site'.
1381
* }
1382
* @return string The HTML for the Visit button.
1383
*/
@@ -1391,7 +1468,6 @@ function bp_blogs_visit_blog_button( $args = '' ) {
1391
'link_href' => bp_get_blog_permalink(),
1392
'link_class' => 'blog-button visit',
1393
'link_text' => __( 'Visit Site', 'buddypress' ),
1394
- 'link_title' => __( 'Visit Site', 'buddypress' ),
1395
);
1396
1397
$button = wp_parse_args( $args, $defaults );
220
/**
221
* Output the blogs pagination count.
222
*
223
+ * @since 1.0.0
224
*/
225
function bp_blogs_pagination_count() {
226
+ echo bp_get_blogs_pagination_count();
227
+ }
228
+
229
+ /**
230
+ * Get the blogs pagination count.
231
+ *
232
+ * @since 2.7.0
233
+ *
234
+ * @global object $blogs_template {@link BP_Blogs_Template}
235
+ */
236
+ function bp_get_blogs_pagination_count() {
237
global $blogs_template;
238
239
$start_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1;
247
$message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s site', 'Viewing %1$s - %2$s of %3$s sites', $blogs_template->total_blog_count, 'buddypress' ), $from_num, $to_num, $total );
248
}
249
250
+ /**
251
+ * Filters the "Viewing x-y of z blogs" pagination message.
252
+ *
253
+ * @since 2.7.0
254
+ *
255
+ * @param string $message "Viewing x-y of z blogs" text.
256
+ * @param string $from_num Total amount for the low value in the range.
257
+ * @param string $to_num Total amount for the high value in the range.
258
+ * @param string $total Total amount of blogs found.
259
+ */
260
+ return apply_filters( 'bp_get_blogs_pagination_count', $message, $from_num, $to_num, $total );
261
}
262
263
/**
345
'no_grav' => true,
346
) );
347
348
+ // Use site icon if available.
349
+ $avatar = '';
350
+ if ( bp_is_active( 'blogs', 'site-icon' ) && function_exists( 'has_site_icon' ) ) {
351
+ $site_icon = bp_blogs_get_blogmeta( bp_get_blog_id(), "site_icon_url_{$r['type']}" );
352
+
353
+ // Never attempted to fetch site icon before; do it now!
354
+ if ( '' === $site_icon ) {
355
+ switch_to_blog( bp_get_blog_id() );
356
+
357
+ // Fetch the other size first.
358
+ if ( 'full' === $r['type'] ) {
359
+ $size = bp_core_avatar_thumb_width();
360
+ $save_size = 'thumb';
361
+ } else {
362
+ $size = bp_core_avatar_full_width();
363
+ $save_size = 'full';
364
+ }
365
+
366
+ $site_icon = get_site_icon_url( $size );
367
+ // Empty site icons get saved as integer 0.
368
+ if ( empty( $site_icon ) ) {
369
+ $site_icon = 0;
370
+ }
371
+
372
+ // Sync site icon for other size to blogmeta.
373
+ bp_blogs_update_blogmeta( bp_get_blog_id(), "site_icon_url_{$save_size}", $site_icon );
374
+
375
+ // Now, fetch the size we want.
376
+ if ( 0 !== $site_icon ) {
377
+ $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
378
+ $site_icon = get_site_icon_url( $size );
379
+ }
380
+
381
+ // Sync site icon to blogmeta.
382
+ bp_blogs_update_blogmeta( bp_get_blog_id(), "site_icon_url_{$r['type']}", $site_icon );
383
+
384
+ restore_current_blog();
385
+ }
386
+
387
+ // We have a site icon.
388
+ if ( ! is_numeric( $site_icon ) ) {
389
+ if ( empty( $r['width'] ) && ! isset( $size ) ) {
390
+ $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
391
+ } else {
392
+ $size = (int) $r['width'];
393
+ }
394
+
395
+ $avatar = sprintf( '<img src="%1$s" class="%2$s" width="%3$s" height="%3$s" alt="%4$s" title="%4$s" />',
396
+ esc_url( $site_icon ),
397
+ esc_attr( "{$r['class']} avatar-{$size}" ),
398
+ esc_attr( $size ),
399
+ sprintf( esc_attr__( 'Site icon for %s', 'buddypress' ), bp_get_blog_name() )
400
+ );
401
+ }
402
+ }
403
+
404
+ // Fallback to user ID avatar.
405
+ if ( '' === $avatar ) {
406
+ $avatar = bp_core_fetch_avatar( array(
407
+ 'item_id' => $blogs_template->blog->admin_user_id,
408
+ 'title' => $r['title'],
409
+ // 'avatar_dir' => 'blog-avatars',
410
+ // 'object' => 'blog',
411
+ 'type' => $r['type'],
412
+ 'alt' => $r['alt'],
413
+ 'css_id' => $r['id'],
414
+ 'class' => $r['class'],
415
+ 'width' => $r['width'],
416
+ 'height' => $r['height']
417
+ ) );
418
+ }
419
420
/**
421
* In future BuddyPress versions you will be able to set the avatar for a blog.
1359
'id' => 'create_blog',
1360
'component' => 'blogs',
1361
'link_text' => __( 'Create a Site', 'buddypress' ),
1362
'link_class' => 'blog-create no-ajax',
1363
'link_href' => trailingslashit( bp_get_blogs_directory_permalink() . 'create' ),
1364
'wrapper' => false,
1455
* @type string $link_href Permalink of the current blog in the loop.
1456
* @type string $link_class Default: 'blog-button visit'.
1457
* @type string $link_text Default: 'Visit Site'.
1458
* }
1459
* @return string The HTML for the Visit button.
1460
*/
1468
'link_href' => bp_get_blog_permalink(),
1469
'link_class' => 'blog-button visit',
1470
'link_text' => __( 'Visit Site', 'buddypress' ),
1471
);
1472
1473
$button = wp_parse_args( $args, $defaults );
bp-blogs/classes/class-bp-blogs-blog.php CHANGED
@@ -48,7 +48,7 @@ class BP_Blogs_Blog {
48
*/
49
public function __construct( $id = null ) {
50
if ( !empty( $id ) ) {
51
- $this->id = $id;
52
$this->populate();
53
}
54
}
@@ -63,8 +63,8 @@ class BP_Blogs_Blog {
63
64
$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
65
66
- $this->user_id = $blog->user_id;
67
- $this->blog_id = $blog->blog_id;
68
}
69
70
/**
@@ -243,6 +243,12 @@ class BP_Blogs_Blog {
243
244
$paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type );
245
246
if ( $update_meta_cache ) {
247
bp_blogs_update_meta_cache( $blog_ids );
248
}
@@ -338,8 +344,8 @@ class BP_Blogs_Blog {
338
$user_blogs = array();
339
foreach ( (array) $blogs as $blog ) {
340
$user_blogs[$blog->blog_id] = new stdClass;
341
- $user_blogs[$blog->blog_id]->id = $blog->id;
342
- $user_blogs[$blog->blog_id]->blog_id = $blog->blog_id;
343
$user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
344
$user_blogs[$blog->blog_id]->name = $blog->name;
345
}
@@ -364,7 +370,7 @@ class BP_Blogs_Blog {
364
if ( !$user_id )
365
$user_id = bp_displayed_user_id();
366
367
- return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
368
}
369
370
/**
@@ -379,7 +385,9 @@ class BP_Blogs_Blog {
379
380
$bp = buddypress();
381
382
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
383
}
384
385
/**
@@ -444,7 +452,12 @@ class BP_Blogs_Blog {
444
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
445
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
446
447
- return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
448
}
449
450
/**
@@ -472,7 +485,12 @@ class BP_Blogs_Blog {
472
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" );
473
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" );
474
475
- return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
476
}
477
478
/**
@@ -509,7 +527,12 @@ class BP_Blogs_Blog {
509
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" );
510
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" );
511
512
- return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
513
}
514
515
/**
48
*/
49
public function __construct( $id = null ) {
50
if ( !empty( $id ) ) {
51
+ $this->id = (int) $id;
52
$this->populate();
53
}
54
}
63
64
$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
65
66
+ $this->user_id = (int) $blog->user_id;
67
+ $this->blog_id = (int) $blog->blog_id;
68
}
69
70
/**
243
244
$paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type );
245
246
+ // Integer casting.
247
+ foreach ( (array) $paged_blogs as $key => $data ) {
248
+ $paged_blogs[ $key ]->blog_id = (int) $paged_blogs[ $key ]->blog_id;
249
+ $paged_blogs[ $key ]->admin_user_id = (int) $paged_blogs[ $key ]->admin_user_id;
250
+ }
251
+
252
if ( $update_meta_cache ) {
253
bp_blogs_update_meta_cache( $blog_ids );
254
}
344
$user_blogs = array();
345
foreach ( (array) $blogs as $blog ) {
346
$user_blogs[$blog->blog_id] = new stdClass;
347
+ $user_blogs[$blog->blog_id]->id = (int) $blog->id;
348
+ $user_blogs[$blog->blog_id]->blog_id = (int) $blog->blog_id;
349
$user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
350
$user_blogs[$blog->blog_id]->name = $blog->name;
351
}
370
if ( !$user_id )
371
$user_id = bp_displayed_user_id();
372
373
+ return array_map( 'intval', $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) ) );
374
}
375
376
/**
385
386
$bp = buddypress();
387
388
+ $query = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
389
+
390
+ return is_numeric( $query ) ? (int) $query : $query;
391
}
392
393
/**
452
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
453
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
454
455
+ // Integer casting.
456
+ foreach ( (array) $paged_blogs as $key => $data ) {
457
+ $paged_blogs[ $key ]->blog_id = (int) $paged_blogs[ $key ]->blog_id;
458
+ }
459
+
460
+ return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs );
461
}
462
463
/**
485
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" );
486
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" );
487
488
+ // Integer casting.
489
+ foreach ( (array) $paged_blogs as $key => $data ) {
490
+ $paged_blogs[ $key ]->blog_id = (int) $paged_blogs[ $key ]->blog_id;
491
+ }
492
+
493
+ return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs );
494
}
495
496
/**
527
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" );
528
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" );
529
530
+ // Integer casting.
531
+ foreach ( (array) $paged_blogs as $key => $data ) {
532
+ $paged_blogs[ $key ]->blog_id = (int) $paged_blogs[ $key ]->blog_id;
533
+ }
534
+
535
+ return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs );
536
}
537
538
/**
bp-blogs/classes/class-bp-blogs-component.php CHANGED
@@ -32,6 +32,7 @@ class BP_Blogs_Component extends BP_Component {
32
array(
33
'adminbar_myaccount_order' => 30,
34
'search_query_arg' => 'sites_search',
35
)
36
);
37
}
@@ -65,12 +66,16 @@ class BP_Blogs_Component extends BP_Component {
65
'blog' => $bp->table_prefix . 'bp_user_blogs_blogmeta',
66
);
67
68
// All globals for blogs component.
69
$args = array(
70
'slug' => BP_BLOGS_SLUG,
71
'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
72
'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site.
73
- 'directory_title' => _x( 'Sites', 'component directory title', 'buddypress' ),
74
'notification_callback' => 'bp_blogs_format_notifications',
75
'search_string' => __( 'Search sites...', 'buddypress' ),
76
'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
32
array(
33
'adminbar_myaccount_order' => 30,
34
'search_query_arg' => 'sites_search',
35
+ 'features' => array( 'site-icon' )
36
)
37
);
38
}
66
'blog' => $bp->table_prefix . 'bp_user_blogs_blogmeta',
67
);
68
69
+ // Fetch the default directory title.
70
+ $default_directory_titles = bp_core_get_directory_page_default_titles();
71
+ $default_directory_title = $default_directory_titles[$this->id];
72
+
73
// All globals for blogs component.
74
$args = array(
75
'slug' => BP_BLOGS_SLUG,
76
'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
77
'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site.
78
+ 'directory_title' => isset( $bp->pages->blogs->title ) ? $bp->pages->blogs->title : $default_directory_title,
79
'notification_callback' => 'bp_blogs_format_notifications',
80
'search_string' => __( 'Search sites...', 'buddypress' ),
81
'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
bp-core/admin/bp-core-admin-components.php CHANGED
@@ -276,6 +276,7 @@ function bp_core_admin_components_settings_handler() {
276
$bp = buddypress();
277
278
// Save settings and upgrade schema.
279
require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
280
281
$submitted = stripslashes_deep( $_POST['bp_components'] );
276
$bp = buddypress();
277
278
// Save settings and upgrade schema.
279
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
280
require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
281
282
$submitted = stripslashes_deep( $_POST['bp_components'] );
bp-core/admin/bp-core-admin-functions.php CHANGED
@@ -804,7 +804,29 @@ function bp_admin_do_wp_nav_menu_meta_box() {
804
</ul>
805
</div>
806
807
<p class="button-controls">
808
<span class="add-to-menu">
809
<input type="submit"<?php if ( function_exists( 'wp_nav_menu_disabled_check' ) ) : wp_nav_menu_disabled_check( $nav_menu_selected_id ); endif; ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'buddypress' ); ?>" name="add-custom-menu-item" id="submit-buddypress-menu" />
810
<span class="spinner"></span>
804
</ul>
805
</div>
806
807
+ <?php
808
+ $removed_args = array(
809
+ 'action',
810
+ 'customlink-tab',
811
+ 'edit-menu-item',
812
+ 'menu-item',
813
+ 'page-tab',
814
+ '_wpnonce',
815
+ );
816
+ ?>
817
+
818
<p class="button-controls">
819
+ <span class="list-controls">
820
+ <a href="<?php
821
+ echo esc_url( add_query_arg(
822
+ array(
823
+ $post_type_name . '-tab' => 'all',
824
+ 'selectall' => 1,
825
+ ),
826
+ remove_query_arg( $removed_args )
827
+ ) );
828
+ ?>#buddypress-menu" class="select-all"><?php _e( 'Select All', 'buddypress' ); ?></a>
829
+ </span>
830
<span class="add-to-menu">
831
<input type="submit"<?php if ( function_exists( 'wp_nav_menu_disabled_check' ) ) : wp_nav_menu_disabled_check( $nav_menu_selected_id ); endif; ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'buddypress' ); ?>" name="add-custom-menu-item" id="submit-buddypress-menu" />
832
<span class="spinner"></span>
bp-core/admin/bp-core-admin-schema.php CHANGED
@@ -10,23 +10,6 @@
10
// Exit if accessed directly.
11
defined( 'ABSPATH' ) || exit;
12
13
- /**
14
- * Get the DB schema to use for BuddyPress components.
15
- *
16
- * @since 1.1.0
17
- *
18
- * @global $wpdb $wpdb
19
- *
20
- * @return string The default database character-set, if set.
21
- */
22
- function bp_core_set_charset() {
23
- global $wpdb;
24
-
25
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
26
-
27
- return !empty( $wpdb->charset ) ? "DEFAULT CHARACTER SET {$wpdb->charset}" : '';
28
- }
29
-
30
/**
31
* Main installer.
32
*
@@ -93,7 +76,7 @@ function bp_core_install( $active_components = false ) {
93
*/
94
function bp_core_install_notifications() {
95
$sql = array();
96
- $charset_collate = bp_core_set_charset();
97
$bp_prefix = bp_core_get_table_prefix();
98
99
$sql[] = "CREATE TABLE {$bp_prefix}bp_notifications (
@@ -134,7 +117,7 @@ function bp_core_install_notifications() {
134
*/
135
function bp_core_install_activity_streams() {
136
$sql = array();
137
- $charset_collate = bp_core_set_charset();
138
$bp_prefix = bp_core_get_table_prefix();
139
140
$sql[] = "CREATE TABLE {$bp_prefix}bp_activity (
@@ -184,7 +167,7 @@ function bp_core_install_activity_streams() {
184
*/
185
function bp_core_install_friends() {
186
$sql = array();
187
- $charset_collate = bp_core_set_charset();
188
$bp_prefix = bp_core_get_table_prefix();
189
190
$sql[] = "CREATE TABLE {$bp_prefix}bp_friends (
@@ -209,7 +192,7 @@ function bp_core_install_friends() {
209
*/
210
function bp_core_install_groups() {
211
$sql = array();
212
- $charset_collate = bp_core_set_charset();
213
$bp_prefix = bp_core_get_table_prefix();
214
215
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups (
@@ -219,10 +202,12 @@ function bp_core_install_groups() {
219
slug varchar(200) NOT NULL,
220
description longtext NOT NULL,
221
status varchar(10) NOT NULL DEFAULT 'public',
222
enable_forum tinyint(1) NOT NULL DEFAULT '1',
223
date_created datetime NOT NULL,
224
KEY creator_id (creator_id),
225
- KEY status (status)
226
) {$charset_collate};";
227
228
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups_members (
@@ -266,7 +251,7 @@ function bp_core_install_groups() {
266
*/
267
function bp_core_install_private_messaging() {
268
$sql = array();
269
- $charset_collate = bp_core_set_charset();
270
$bp_prefix = bp_core_get_table_prefix();
271
272
$sql[] = "CREATE TABLE {$bp_prefix}bp_messages_messages (
@@ -325,7 +310,7 @@ function bp_core_install_extended_profiles() {
325
global $wpdb;
326
327
$sql = array();
328
- $charset_collate = bp_core_set_charset();
329
$bp_prefix = bp_core_get_table_prefix();
330
331
// These values should only be updated if they are not already present.
@@ -410,7 +395,7 @@ function bp_core_install_extended_profiles() {
410
*/
411
function bp_core_install_blog_tracking() {
412
$sql = array();
413
- $charset_collate = bp_core_set_charset();
414
$bp_prefix = bp_core_get_table_prefix();
415
416
$sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs (
@@ -517,7 +502,7 @@ function bp_core_install_emails() {
517
);
518
519
$emails = bp_email_get_schema();
520
- $descriptions = bp_email_get_type_schema();
521
522
// Add these emails to the database.
523
foreach ( $emails as $id => $email ) {
@@ -535,6 +520,8 @@ function bp_core_install_emails() {
535
}
536
}
537
538
/**
539
* Fires after BuddyPress adds the posts for its emails.
540
*
10
// Exit if accessed directly.
11
defined( 'ABSPATH' ) || exit;
12
13
/**
14
* Main installer.
15
*
76
*/
77
function bp_core_install_notifications() {
78
$sql = array();
79
+ $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
80
$bp_prefix = bp_core_get_table_prefix();
81
82
$sql[] = "CREATE TABLE {$bp_prefix}bp_notifications (
117
*/
118
function bp_core_install_activity_streams() {
119
$sql = array();
120
+ $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
121
$bp_prefix = bp_core_get_table_prefix();
122
123
$sql[] = "CREATE TABLE {$bp_prefix}bp_activity (
167
*/
168
function bp_core_install_friends() {
169
$sql = array();
170
+ $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
171
$bp_prefix = bp_core_get_table_prefix();
172
173
$sql[] = "CREATE TABLE {$bp_prefix}bp_friends (
192
*/
193
function bp_core_install_groups() {
194
$sql = array();
195
+ $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
196
$bp_prefix = bp_core_get_table_prefix();
197
198
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups (
202
slug varchar(200) NOT NULL,
203
description longtext NOT NULL,
204
status varchar(10) NOT NULL DEFAULT 'public',
205
+ parent_id bigint(20) NOT NULL DEFAULT 0,
206
enable_forum tinyint(1) NOT NULL DEFAULT '1',
207
date_created datetime NOT NULL,
208
KEY creator_id (creator_id),
209
+ KEY status (status),
210
+ KEY parent_id (parent_id)
211
) {$charset_collate};";
212
213
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups_members (
251
*/
252
function bp_core_install_private_messaging() {
253
$sql = array();
254
+ $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
255
$bp_p