BuddyPress - Version 2.0.3

Version Description

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

Download this release

Release Info

Developer boonebgorges
Plugin Icon 128x128 BuddyPress
Version 2.0.3
Comparing to
See all releases

Code changes from version 2.1-beta1 to 2.0.3

Files changed (256) hide show
  1. bp-activity/admin/css/admin-rtl.css +0 -80
  2. bp-activity/admin/css/admin-rtl.min.css +0 -2
  3. bp-activity/admin/css/admin.css +1 -1
  4. bp-activity/admin/css/admin.min.css +1 -2
  5. bp-activity/admin/js/admin.js +8 -9
  6. bp-activity/admin/js/admin.min.js +1 -2
  7. bp-activity/bp-activity-actions.php +2 -27
  8. bp-activity/bp-activity-admin.php +19 -45
  9. bp-activity/bp-activity-classes.php +19 -99
  10. bp-activity/bp-activity-cssjs.php +0 -48
  11. bp-activity/bp-activity-filters.php +2 -9
  12. bp-activity/bp-activity-functions.php +279 -376
  13. bp-activity/bp-activity-loader.php +15 -16
  14. bp-activity/bp-activity-screens.php +2 -2
  15. bp-activity/bp-activity-template.php +147 -473
  16. bp-activity/css/mentions-rtl.css +0 -76
  17. bp-activity/css/mentions-rtl.min.css +0 -2
  18. bp-activity/css/mentions.css +0 -76
  19. bp-activity/css/mentions.min.css +0 -2
  20. bp-activity/js/mentions.js +0 -204
  21. bp-activity/js/mentions.min.js +0 -2
  22. bp-blogs/bp-blogs-activity.php +40 -114
  23. bp-blogs/bp-blogs-buddybar.php +78 -0
  24. bp-blogs/bp-blogs-classes.php +9 -13
  25. bp-blogs/bp-blogs-filters.php +0 -16
  26. bp-blogs/bp-blogs-functions.php +54 -231
  27. bp-blogs/bp-blogs-loader.php +13 -18
  28. bp-blogs/bp-blogs-screens.php +2 -2
  29. bp-blogs/bp-blogs-template.php +117 -142
  30. bp-core/admin/bp-core-functions.php +26 -42
  31. bp-core/admin/bp-core-schema.php +122 -211
  32. bp-core/admin/bp-core-settings.php +29 -0
  33. bp-core/admin/bp-core-tools.php +1 -42
  34. bp-core/admin/css/common-rtl.css +0 -432
  35. bp-core/admin/css/common-rtl.min.css +0 -2
  36. bp-core/admin/css/common.css +34 -33
  37. bp-core/admin/css/common.min.css +1 -2
  38. bp-core/admin/images/icons32.png +0 -0
  39. bp-core/admin/images/icons64.png +0 -0
  40. bp-core/admin/images/menu-2x.png +0 -0
  41. bp-core/admin/images/menu-wp.png +0 -0
  42. bp-core/admin/images/menu.png +0 -0
  43. bp-core/bp-core-actions.php +0 -1
  44. bp-core/bp-core-admin.php +111 -163
  45. bp-core/bp-core-adminbar.php +13 -26
  46. bp-core/bp-core-avatars.php +3 -16
  47. bp-core/bp-core-buddybar.php +221 -88
  48. bp-core/bp-core-caps.php +0 -27
  49. bp-core/bp-core-catchuri.php +19 -38
  50. bp-core/bp-core-classes.php +49 -335
  51. bp-core/bp-core-component.php +27 -38
  52. bp-core/bp-core-cssjs.php +17 -126
  53. bp-core/bp-core-dependency.php +0 -7
  54. bp-core/bp-core-filters.php +7 -40
  55. bp-core/bp-core-functions.php +65 -206
  56. bp-core/bp-core-loader.php +3 -3
  57. bp-core/bp-core-options.php +14 -23
  58. bp-core/bp-core-template-loader.php +8 -8
  59. bp-core/bp-core-template.php +480 -513
  60. bp-core/bp-core-update.php +9 -5
  61. bp-core/bp-core-widgets.php +5 -4
  62. bp-core/css/admin-bar-rtl.css +18 -49
  63. bp-core/css/admin-bar-rtl.min.css +1 -2
  64. bp-core/css/admin-bar.css +1 -1
  65. bp-core/css/admin-bar.min.css +1 -2
  66. bp-core/css/buddybar-rtl.css +15 -141
  67. bp-core/css/buddybar-rtl.min.css +1 -2
  68. bp-core/css/buddybar.css +4 -4
  69. bp-core/css/buddybar.min.css +1 -2
  70. bp-core/deprecated/2.1.php +0 -625
  71. bp-core/deprecated/css/autocomplete/jquery.autocompletefb-rtl.css +0 -80
  72. bp-core/deprecated/css/autocomplete/jquery.autocompletefb-rtl.min.css +0 -2
  73. bp-core/deprecated/css/autocomplete/jquery.autocompletefb.min.css +0 -2
  74. bp-core/deprecated/js/autocomplete/jquery.autocomplete.min.js +0 -2
  75. bp-core/deprecated/js/autocomplete/jquery.autocompletefb.min.js +0 -2
  76. bp-core/deprecated/js/autocomplete/jquery.bgiframe.min.js +0 -2
  77. bp-core/deprecated/js/autocomplete/jquery.dimensions.min.js +0 -2
  78. bp-core/deprecated/js/jquery-scroll-to.js +0 -208
  79. bp-core/deprecated/js/jquery-scroll-to.min.js +0 -2
  80. bp-core/images/60pc_black.png +0 -0
  81. bp-core/images/Jcrop.gif +0 -0
  82. bp-core/images/admin-menu-arrow.gif +0 -0
  83. bp-core/images/bp20/admin-xprofile.jpg +0 -0
  84. bp-core/images/bp20/load-newest.jpg +0 -0
  85. bp-core/images/bp20/performance.png +0 -0
  86. bp-core/images/bp20/tools-buddypress.jpg +0 -0
  87. bp-core/images/bp20/user-mark-spam.jpg +0 -0
  88. bp-core/images/bp20/users-pending.jpg +0 -0
  89. bp-core/images/mystery-man-50.jpg +0 -0
  90. bp-core/images/mystery-man.jpg +0 -0
  91. bp-core/js/confirm.js +3 -8
  92. bp-core/js/confirm.min.js +1 -2
  93. bp-core/js/jquery-cookie.js +0 -120
  94. bp-core/js/jquery-cookie.min.js +0 -2
  95. bp-core/js/jquery-query.js +0 -6
  96. bp-core/js/jquery-query.min.js +0 -2
  97. bp-core/js/jquery.atwho.js +0 -824
  98. bp-core/js/jquery.atwho.min.js +0 -2
  99. bp-core/js/jquery.atwho.txt +0 -22
  100. bp-core/js/jquery.caret.js +0 -366
  101. bp-core/js/jquery.caret.min.js +0 -2
  102. bp-core/js/jquery.caret.txt +0 -22
  103. bp-core/js/widget-members.js +11 -11
  104. bp-core/js/widget-members.min.js +1 -2
  105. bp-forums/bp-forums-screens.php +1 -1
  106. bp-forums/bp-forums-template.php +2 -2
  107. bp-friends/bp-friends-activity.php +2 -6
  108. bp-friends/bp-friends-classes.php +11 -17
  109. bp-friends/bp-friends-filters.php +1 -8
  110. bp-friends/bp-friends-functions.php +1 -54
  111. bp-friends/bp-friends-loader.php +9 -9
  112. bp-friends/bp-friends-screens.php +3 -3
  113. bp-friends/bp-friends-template.php +9 -4
  114. bp-friends/bp-friends-widgets.php +0 -7
  115. bp-friends/js/widget-friends.js +12 -12
  116. bp-friends/js/widget-friends.min.js +1 -2
  117. bp-groups/admin/css/admin-rtl.css +0 -86
  118. bp-groups/admin/css/admin-rtl.min.css +0 -2
  119. bp-groups/admin/css/admin.css +3 -33
  120. bp-groups/admin/css/admin.min.css +1 -2
  121. bp-groups/admin/js/admin.js +12 -24
  122. bp-groups/admin/js/admin.min.js +1 -2
  123. bp-groups/bp-groups-actions.php +5 -82
  124. bp-groups/bp-groups-activity.php +6 -26
  125. bp-groups/bp-groups-admin.php +104 -115
  126. bp-groups/bp-groups-adminbar.php +2 -2
  127. bp-groups/bp-groups-buddybar.php +67 -0
  128. bp-groups/bp-groups-cache.php +0 -29
  129. bp-groups/bp-groups-classes.php +57 -530
  130. bp-groups/bp-groups-filters.php +22 -48
  131. bp-groups/bp-groups-forums.php +147 -174
  132. bp-groups/bp-groups-functions.php +1 -1
  133. bp-groups/bp-groups-loader.php +99 -72
  134. bp-groups/bp-groups-notifications.php +68 -129
  135. bp-groups/bp-groups-screens.php +24 -24
  136. bp-groups/bp-groups-template.php +138 -415
  137. bp-groups/bp-groups-widgets.php +2 -11
  138. bp-groups/js/widget-groups.js +11 -11
  139. bp-groups/js/widget-groups.min.js +1 -2
  140. bp-languages/buddypress.pot +7212 -0
  141. bp-loader.php +34 -33
  142. bp-members/admin/bp-members-classes.php +56 -78
  143. bp-members/admin/css/admin-rtl.css +0 -160
  144. bp-members/admin/css/admin-rtl.min.css +0 -2
  145. bp-members/admin/css/admin.css +40 -21
  146. bp-members/admin/css/admin.min.css +1 -2
  147. bp-members/admin/js/admin.js +1 -3
  148. bp-members/admin/js/admin.min.js +1 -2
  149. bp-members/bp-members-actions.php +8 -9
  150. bp-members/bp-members-admin.php +255 -625
  151. bp-members/bp-members-adminbar.php +12 -11
  152. bp-members/bp-members-buddybar.php +116 -0
  153. bp-members/bp-members-classes.php +10 -9
  154. bp-members/bp-members-filters.php +12 -50
  155. bp-members/bp-members-functions.php +211 -380
  156. bp-members/bp-members-loader.php +75 -111
  157. bp-core/deprecated/1.9.php → bp-members/bp-members-notifications.php +43 -40
  158. bp-members/bp-members-screens.php +52 -48
  159. bp-members/bp-members-template.php +149 -716
  160. bp-messages/bp-messages-actions.php +10 -36
  161. bp-messages/bp-messages-cache.php +6 -5
  162. bp-messages/bp-messages-classes.php +10 -110
  163. bp-messages/bp-messages-cssjs.php +13 -19
  164. bp-messages/bp-messages-filters.php +1 -0
  165. bp-messages/bp-messages-functions.php +51 -172
  166. bp-messages/bp-messages-loader.php +8 -28
  167. bp-messages/bp-messages-notifications.php +25 -43
  168. bp-messages/bp-messages-screens.php +12 -42
  169. bp-messages/bp-messages-template.php +179 -914
  170. bp-messages/bp-messages-widgets.php +1 -1
  171. {bp-core/deprecated → bp-messages}/css/autocomplete/jquery.autocompletefb.css +5 -0
  172. bp-messages/css/autocomplete/jquery.autocompletefb.min.css +1 -0
  173. {bp-core/deprecated → bp-messages}/js/autocomplete/jquery.autocomplete.js +0 -0
  174. bp-messages/js/autocomplete/jquery.autocomplete.min.js +13 -0
  175. {bp-core/deprecated → bp-messages}/js/autocomplete/jquery.autocompletefb.js +0 -0
  176. bp-messages/js/autocomplete/jquery.autocompletefb.min.js +16 -0
  177. {bp-core/deprecated → bp-messages}/js/autocomplete/jquery.bgiframe.js +0 -0
  178. bp-messages/js/autocomplete/jquery.bgiframe.min.js +6 -0
  179. {bp-core/deprecated → bp-messages}/js/autocomplete/jquery.dimensions.js +0 -0
  180. bp-messages/js/autocomplete/jquery.dimensions.min.js +13 -0
  181. {bp-core/deprecated → bp-messages}/js/autocomplete/license.bgiframe.txt +0 -0
  182. bp-notifications/bp-notifications-buddybar.php +57 -0
  183. bp-notifications/bp-notifications-classes.php +2 -4
  184. bp-notifications/bp-notifications-functions.php +34 -39
  185. bp-notifications/bp-notifications-loader.php +11 -10
  186. bp-notifications/bp-notifications-template.php +80 -178
  187. bp-settings/bp-settings-actions.php +5 -112
  188. bp-settings/bp-settings-loader.php +1 -1
  189. bp-settings/bp-settings-template.php +0 -26
  190. bp-templates/bp-legacy/buddypress-functions.php +68 -48
  191. bp-templates/bp-legacy/buddypress/activity/activity-loop.php +9 -1
  192. bp-templates/bp-legacy/buddypress/activity/entry.php +3 -3
  193. bp-templates/bp-legacy/buddypress/activity/index.php +30 -2
  194. bp-templates/bp-legacy/buddypress/activity/post-form.php +4 -4
  195. bp-templates/bp-legacy/buddypress/groups/create.php +25 -28
  196. bp-templates/bp-legacy/buddypress/groups/single/activity.php +9 -3
  197. bp-templates/bp-legacy/buddypress/groups/single/admin.php +6 -6
  198. bp-templates/bp-legacy/buddypress/groups/single/home.php +32 -23
  199. bp-templates/bp-legacy/buddypress/members/register.php +6 -7
  200. bp-templates/bp-legacy/buddypress/members/single/activity.php +34 -3
  201. bp-templates/bp-legacy/buddypress/members/single/groups/invites.php +1 -1
  202. bp-templates/bp-legacy/buddypress/members/single/messages/single.php +1 -1
  203. bp-templates/bp-legacy/buddypress/members/single/profile/change-avatar.php +8 -8
  204. bp-templates/bp-legacy/buddypress/members/single/profile/edit.php +4 -6
  205. bp-templates/bp-legacy/buddypress/members/single/settings/general.php +2 -3
  206. bp-templates/bp-legacy/buddypress/members/single/settings/profile.php +1 -1
  207. bp-templates/bp-legacy/css/buddypress-rtl.css +29 -141
  208. bp-templates/bp-legacy/css/buddypress-rtl.min.css +0 -2
  209. bp-templates/bp-legacy/css/buddypress.css +4 -36
  210. bp-templates/bp-legacy/css/buddypress.min.css +0 -2
  211. bp-templates/bp-legacy/js/buddypress.js +410 -500
  212. bp-templates/bp-legacy/js/buddypress.min.js +0 -2
  213. bp-templates/bp-legacy/js/password-verify.js +0 -43
  214. bp-templates/bp-legacy/js/password-verify.min.js +0 -2
  215. bp-themes/bp-default/.jshintrc +0 -25
  216. bp-themes/bp-default/_inc/global.js +21 -16
  217. bp-themes/bp-default/_inc/images/45pc_black.png +0 -0
  218. bp-themes/bp-default/_inc/images/60pc_black.png +0 -0
  219. bp-themes/bp-default/_inc/images/activity_arrow.gif +0 -0
  220. bp-themes/bp-default/_inc/images/admin-menu-arrow.gif +0 -0
  221. bp-themes/bp-default/_inc/images/ajax-loader.gif +0 -0
  222. bp-themes/bp-default/_inc/images/background.gif +0 -0
  223. bp-themes/bp-default/_inc/images/closed.png +0 -0
  224. bp-themes/bp-default/_inc/images/default_header.jpg +0 -0
  225. bp-themes/bp-default/_inc/images/item_back.gif +0 -0
  226. bp-themes/bp-default/_inc/images/replyto_arrow.gif +0 -0
  227. bp-themes/bp-default/_inc/images/rss.png +0 -0
  228. bp-themes/bp-default/_inc/images/sidebar_back.gif +0 -0
  229. bp-themes/bp-default/_inc/images/white-grad.png +0 -0
  230. bp-themes/bp-default/activity/index.php +1 -1
  231. bp-themes/bp-default/functions.php +1 -20
  232. bp-themes/bp-default/groups/single/activity.php +1 -1
  233. bp-themes/bp-default/members/single/activity.php +1 -1
  234. bp-themes/bp-default/rtl.css +1 -1
  235. bp-themes/bp-default/screenshot.png +0 -0
  236. bp-themes/bp-default/style.css +1 -1
  237. bp-themes/index.php +5 -0
  238. bp-xprofile/admin/css/admin-rtl.css +0 -251
  239. bp-xprofile/admin/css/admin-rtl.min.css +0 -2
  240. bp-xprofile/admin/css/admin.css +69 -72
  241. bp-xprofile/admin/css/admin.min.css +1 -2
  242. bp-xprofile/admin/js/admin.js +77 -85
  243. bp-xprofile/admin/js/admin.min.js +1 -2
  244. bp-xprofile/bp-xprofile-actions.php +3 -14
  245. bp-xprofile/bp-xprofile-activity.php +79 -91
  246. bp-xprofile/bp-xprofile-admin.php +136 -183
  247. bp-xprofile/bp-xprofile-buddybar.php +4 -0
  248. bp-xprofile/bp-xprofile-classes.php +246 -602
  249. bp-xprofile/bp-xprofile-cssjs.php +0 -23
  250. bp-xprofile/bp-xprofile-filters.php +41 -102
  251. bp-xprofile/bp-xprofile-functions.php +114 -305
  252. bp-xprofile/bp-xprofile-loader.php +34 -60
  253. bp-xprofile/bp-xprofile-screens.php +9 -12
  254. bp-xprofile/bp-xprofile-template.php +10 -85
  255. buddypress.pot +2810 -2956
  256. readme.txt +16 -12
bp-activity/admin/css/admin-rtl.css DELETED
@@ -1,80 +0,0 @@
1
- .akismet-status {
2
- float: left;
3
- }
4
- .akismet-status a {
5
- color: #AAA;
6
- font-style: italic;
7
- }
8
- .akismet-history {
9
- margin: 13px;
10
- }
11
- .akismet-history div {
12
- margin-bottom: 13px;
13
- }
14
- .akismet-history span {
15
- color: #999;
16
- }
17
-
18
- #wp-bp-activities-wrap {
19
- padding: 5px 0;
20
- }
21
- #bp-activities {
22
- height: 120px;
23
- }
24
- #bp-replyhead {
25
- font-size: 1em;
26
- line-height: 1.4em;
27
- margin: 0;
28
- }
29
- #bp-replysubmit {
30
- margin: 0;
31
- padding: 0 0 3px;
32
- text-align: center;
33
- }
34
- #bp-replysubmit .error {
35
- color: red;
36
- line-height: 21px;
37
- text-align: center;
38
- vertical-align: center;
39
- }
40
- #bp-replysubmit img.waiting {
41
- float: left;
42
- padding: 4px 10px 0;
43
- vertical-align: top;
44
- }
45
- #bp-activities-form .column-response img {
46
- float: right;
47
- margin-left: 10px;
48
- margin-top: 1px;
49
- }
50
- .activity-errors {
51
- list-style-type: disc;
52
- margin-right: 2em;
53
- }
54
-
55
- #bp_activity_action div.inside,
56
- #bp_activity_content div.inside {
57
- line-height: 0;
58
- }
59
- #bp_activity_action h3,
60
- #bp_activity_content h3 {
61
- cursor: auto;
62
- }
63
- #bp_activity_action td.mceIframeContainer,
64
- #bp_activity_content td.mceIframeContainer {
65
- background-color: white;
66
- }
67
- #post-body #bp-activities-action_resize,
68
- #post-body #bp-activities-content_resize {
69
- position: inherit;
70
- margin-top: -2px;
71
- }
72
- #bp_activity_link input {
73
- width: 99%;
74
- }
75
- #bp-activities-primaryid {
76
- margin-bottom: 1em;
77
- }
78
- .column-action {
79
- width: 12%;
80
- }
bp-activity/admin/css/admin-rtl.min.css DELETED
@@ -1,2 +0,0 @@
1
- /*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- .akismet-status{float:left}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:left;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:right;margin-left:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-right:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}
bp-activity/admin/css/admin.css CHANGED
@@ -77,4 +77,4 @@
77
}
78
.column-action {
79
width: 12%;
80
- }
77
}
78
.column-action {
79
width: 12%;
80
+ }
bp-activity/admin/css/admin.min.css CHANGED
@@ -1,2 +1 @@
1
- /*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- .akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}
1
+ .akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:white}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}
bp-activity/admin/js/admin.js CHANGED
@@ -1,4 +1,3 @@
1
- /* global bp_activity_admin_vars, postboxes, wpAjax */
2
(function( $ ) {
3
4
/**
@@ -20,7 +19,7 @@ var activityReply = {
20
21
// Close textarea on escape
22
$(document).on( 'keyup', '#bp-activities:visible', function( e ) {
23
- if ( 27 === e.which ) {
24
activityReply.close();
25
}
26
});
@@ -31,7 +30,7 @@ var activityReply = {
31
*
32
* @since BuddyPress (1.6)
33
*/
34
- open : function() {
35
// Hide the container row, and move it to the new location
36
var box = $( '#bp-activities-container' ).hide();
37
$( this ).parents( 'tr' ).after( box );
@@ -48,9 +47,9 @@ var activityReply = {
48
*
49
* @since BuddyPress (1.6)
50
*/
51
- close : function() {
52
// Hide the container row
53
- $('#bp-activities-container').fadeOut( '200', function () {
54
55
// Empty and unfocus the text area
56
$( '#bp-activities' ).val( '' ).blur();
@@ -68,7 +67,7 @@ var activityReply = {
68
*
69
* @since BuddyPress (1.6)
70
*/
71
- send : function() {
72
// Hide any existing error message, and show the loading spinner
73
$( '#bp-replysubmit .error' ).hide();
74
$( '#bp-replysubmit .waiting' ).show();
@@ -124,7 +123,7 @@ var activityReply = {
124
var bg, id, response;
125
126
// Handle any errors in the response
127
- if ( typeof( xml ) === 'string' ) {
128
activityReply.error( { 'responseText': xml } );
129
return false;
130
}
@@ -137,7 +136,7 @@ var activityReply = {
137
response = response.responses[0];
138
139
// Close and reset the reply row, and add the new Activity item into the list.
140
- $('#bp-activities-container').fadeOut( '200', function () {
141
142
// Empty and unfocus the text area
143
$( '#bp-activities' ).val( '' ).blur();
@@ -170,4 +169,4 @@ $(document).ready( function () {
170
postboxes.add_postbox_toggles( bp_activity_admin_vars.page );
171
});
172
173
- })(jQuery);
1
(function( $ ) {
2
3
/**
19
20
// Close textarea on escape
21
$(document).on( 'keyup', '#bp-activities:visible', function( e ) {
22
+ if ( 27 == e.which ) {
23
activityReply.close();
24
}
25
});
30
*
31
* @since BuddyPress (1.6)
32
*/
33
+ open : function( e ) {
34
// Hide the container row, and move it to the new location
35
var box = $( '#bp-activities-container' ).hide();
36
$( this ).parents( 'tr' ).after( box );
47
*
48
* @since BuddyPress (1.6)
49
*/
50
+ close : function( e ) {
51
// Hide the container row
52
+ $('#bp-activities-container').fadeOut( '200', function () {
53
54
// Empty and unfocus the text area
55
$( '#bp-activities' ).val( '' ).blur();
67
*
68
* @since BuddyPress (1.6)
69
*/
70
+ send : function( e ) {
71
// Hide any existing error message, and show the loading spinner
72
$( '#bp-replysubmit .error' ).hide();
73
$( '#bp-replysubmit .waiting' ).show();
123
var bg, id, response;
124
125
// Handle any errors in the response
126
+ if ( typeof( xml ) == 'string' ) {
127
activityReply.error( { 'responseText': xml } );
128
return false;
129
}
136
response = response.responses[0];
137
138
// Close and reset the reply row, and add the new Activity item into the list.
139
+ $('#bp-activities-container').fadeOut( '200', function () {
140
141
// Empty and unfocus the text area
142
$( '#bp-activities' ).val( '' ).blur();
169
postboxes.add_postbox_toggles( bp_activity_admin_vars.page );
170
});
171
172
+ })(jQuery);
bp-activity/admin/js/admin.min.js CHANGED
@@ -1,2 +1 @@
1
- /*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- !function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
1
+ (function(b){var a={init:function(){b(document).on("click",".row-actions a.reply",a.open);b(document).on("click","#bp-activities-container a.cancel",a.close);b(document).on("click","#bp-activities-container a.save",a.send);b(document).on("keyup","#bp-activities:visible",function(c){if(27==c.which){a.close()}})},open:function(d){var c=b("#bp-activities-container").hide();b(this).parents("tr").after(c);c.fadeIn("300");b("#bp-activities").focus();return false},close:function(c){b("#bp-activities-container").fadeOut("200",function(){b("#bp-activities").val("").blur();b("#bp-replysubmit .error").html("").hide();b("#bp-replysubmit .waiting").hide()});return false},send:function(d){b("#bp-replysubmit .error").hide();b("#bp-replysubmit .waiting").show();var c={};c["_ajax_nonce-bp-activity-admin-reply"]=b('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val();c.action="bp-activity-admin-reply";c.content=b("#bp-activities").val();c.parent_id=b("#bp-activities-container").prev().data("parent_id");c.root_id=b("#bp-activities-container").prev().data("root_id");b.ajax({data:c,type:"POST",url:ajaxurl,error:function(e){a.error(e)},success:function(e){a.show(e)}});return false},error:function(c){var d=c.statusText;b("#bp-replysubmit .waiting").hide();if(c.responseText){d=c.responseText.replace(/<.[^<>]*?>/g,"")}if(d){b("#bp-replysubmit .error").html(d).show()}},show:function(d){var e,f,c;if(typeof(d)=="string"){a.error({responseText:d});return false}c=wpAjax.parseAjaxResponse(d);if(c.errors){a.error({responseText:wpAjax.broken});return false}c=c.responses[0];b("#bp-activities-container").fadeOut("200",function(){b("#bp-activities").val("").blur();b("#bp-replysubmit .error").html("").hide();b("#bp-replysubmit .waiting").hide();b("#bp-activities-container").before(c.data);f=b("#activity-"+c.id);e=f.closest(".widefat").css("backgroundColor");f.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:e},300)})}};b(document).ready(function(){a.init();b("#bp_activity_action h3, #bp_activity_content h3").unbind("click");postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})})(jQuery);
bp-activity/bp-activity-actions.php CHANGED
@@ -437,7 +437,7 @@ function bp_activity_action_sitewide_feed() {
437
'id' => 'sitewide',
438
439
/* translators: Sitewide activity RSS title - "[Site Name] | Site Wide Activity" */
440
- 'title' => sprintf( __( '%s | Site-Wide Activity', 'buddypress' ), bp_get_site_name() ),
441
442
'link' => bp_get_activity_directory_permalink(),
443
'description' => __( 'Activity feed for the entire site.', 'buddypress' ),
@@ -540,7 +540,7 @@ function bp_activity_action_my_groups_feed() {
540
'title' => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
541
542
'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() ),
543
- 'description' => sprintf( __( "Public group activity feed of which %s is a member.", 'buddypress' ), bp_get_displayed_user_fullname() ),
544
'activity_args' => array(
545
'object' => buddypress()->groups->id,
546
'primary_id' => $group_ids,
@@ -647,28 +647,3 @@ function bp_activity_setup_akismet() {
647
// Instantiate Akismet for BuddyPress
648
$bp->activity->akismet = new BP_Akismet();
649
}
650
-
651
- /**
652
- * AJAX endpoint for Suggestions API lookups.
653
- *
654
- * @since BuddyPress (2.1.0)
655
- */
656
- function bp_ajax_get_suggestions() {
657
- if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) {
658
- wp_send_json_error( 'missing_parameter' );
659
- exit;
660
- }
661
-
662
- $results = bp_core_get_suggestions( array(
663
- 'term' => sanitize_text_field( $_GET['term'] ),
664
- 'type' => sanitize_text_field( $_GET['type'] ),
665
- ) );
666
-
667
- if ( is_wp_error( $results ) ) {
668
- wp_send_json_error( $results->get_error_message() );
669
- exit;
670
- }
671
-
672
- wp_send_json_success( $results );
673
- }
674
- add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
437
'id' => 'sitewide',
438
439
/* translators: Sitewide activity RSS title - "[Site Name] | Site Wide Activity" */
440
+ 'title' => sprintf( __( '%s | Site Wide Activity', 'buddypress' ), bp_get_site_name() ),
441
442
'link' => bp_get_activity_directory_permalink(),
443
'description' => __( 'Activity feed for the entire site.', 'buddypress' ),
540
'title' => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
541
542
'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() ),
543
+ 'description' => sprintf( __( "Public group activity feed of which %s is a member of.", 'buddypress' ), bp_get_displayed_user_fullname() ),
544
'activity_args' => array(
545
'object' => buddypress()->groups->id,
546
'primary_id' => $group_ids,
647
// Instantiate Akismet for BuddyPress
648
$bp->activity->akismet = new BP_Akismet();
649
}
bp-activity/bp-activity-admin.php CHANGED
@@ -29,8 +29,8 @@ function bp_activity_add_admin_menu() {
29
30
// Add our screen
31
$hook = add_menu_page(
32
- _x( 'Activity', 'Admin Dashbord SWA page title', 'buddypress' ),
33
- _x( 'Activity', 'Admin Dashbord SWA menu', 'buddypress' ),
34
'bp_moderate',
35
'bp-activity',
36
'bp_activity_admin',
@@ -220,7 +220,7 @@ function bp_activity_admin_load() {
220
'title' => __( 'Item, Link, Type', 'buddypress' ),
221
'content' =>
222
'<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' .
223
- '<p>' . __( '<strong>Link</strong> - Used by some types of activity (e.g blog posts and comments, and forum topics and replies) to store a link back to the original content.', 'buddypress' ) . '</p>' .
224
'<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' .
225
'<p>' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '</p>'
226
) );
@@ -284,12 +284,6 @@ function bp_activity_admin_load() {
284
) );
285
wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin.{$min}css", array(), bp_get_version() );
286
287
- wp_style_add_data( 'bp_activity_admin_css', 'rtl', true );
288
- if ( $min ) {
289
- wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min );
290
- }
291
-
292
-
293
// Handle spam/un-spam/delete of activities
294
if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
295
@@ -909,7 +903,7 @@ function bp_activity_admin_index() {
909
<?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
910
<?php printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
911
<?php else : ?>
912
- <?php _ex( 'Activity', 'Admin SWA page', 'buddypress' ); ?>
913
<?php endif; ?>
914
915
<?php if ( !empty( $_REQUEST['s'] ) ) : ?>
@@ -1063,7 +1057,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1063
'display_comments' => 'stream',
1064
'show_hidden' => true,
1065
'spam' => 'spam_only',
1066
- 'count_total' => 'count_query',
1067
) );
1068
$this->spam_count = $spams['total'];
1069
unset( $spams );
@@ -1079,7 +1072,6 @@ class BP_Activity_List_Table extends WP_List_Table {
1079
'show_hidden' => true,
1080
//'sort' => $sort,
1081
'spam' => $spam,
1082
- 'count_total' => 'count_query',
1083
) );
1084
1085
// If we're viewing a specific activity, flatten all activites into a single array.
@@ -1146,6 +1138,8 @@ class BP_Activity_List_Table extends WP_List_Table {
1146
* @since BuddyPress (1.6.0)
1147
*/
1148
function display() {
1149
$this->display_tablenav( 'top' ); ?>
1150
1151
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
@@ -1244,10 +1238,10 @@ class BP_Activity_List_Table extends WP_List_Table {
1244
function get_columns() {
1245
return array(
1246
'cb' => '<input name type="checkbox" />',
1247
- 'author' => _x('Author', 'Admin SWA column header', 'buddypress' ),
1248
- 'comment' => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
1249
- 'action' => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
1250
- 'response' => _x( 'In Response To', 'Admin SWA column header', 'buddypress' ),
1251
);
1252
}
1253
@@ -1278,43 +1272,23 @@ class BP_Activity_List_Table extends WP_List_Table {
1278
* @param string $which 'top' or 'bottom'.
1279
*/
1280
function extra_tablenav( $which ) {
1281
-
1282
- // Bail on bottom table nav
1283
- if ( 'bottom' === $which ) {
1284
return;
1285
- }
1286
1287
- // Is any filter currently selected?
1288
- $selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : '';
1289
1290
- // Get the actions
1291
- $activity_actions = buddypress()->activity->actions; ?>
1292
1293
<div class="alignleft actions">
1294
<select name="activity_type">
1295
- <option value="" <?php selected( ! $selected ); ?>><?php _e( 'View all actions', 'buddypress' ); ?></option>
1296
-
1297
- <?php foreach ( $activity_actions as $component => $actions ) : ?>
1298
-
1299
- <optgroup label="<?php echo ucfirst( $component ); ?>">
1300
-
1301
- <?php foreach ( $actions as $action_key => $action_values ) : ?>
1302
-
1303
- <?php
1304
-
1305
- // Skip the incorrectly named pre-1.6 action
1306
- if ( 'friends_register_activity_action' !== $action_key ) : ?>
1307
-
1308
- <option value="<?php echo esc_attr( $action_key ); ?>" <?php selected( $action_key, $selected ); ?>><?php echo esc_html( $action_values[ 'value' ] ); ?></option>
1309
-
1310
- <?php endif; ?>
1311
-
1312
- <?php endforeach; ?>
1313
-
1314
- </optgroup>
1315
1316
<?php endforeach; ?>
1317
-
1318
</select>
1319
1320
<?php submit_button( __( 'Filter', 'buddypress' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); ?>
29
30
// Add our screen
31
$hook = add_menu_page(
32
+ __( 'Activity', 'buddypress' ),
33
+ __( 'Activity', 'buddypress' ),
34
'bp_moderate',
35
'bp-activity',
36
'bp_activity_admin',
220
'title' => __( 'Item, Link, Type', 'buddypress' ),
221
'content' =>
222
'<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' .
223
+ '<p>' . __( '<strong>Link</strong> - Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set.', 'buddypress' ) . '</p>' .
224
'<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' .
225
'<p>' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '</p>'
226
) );
284
) );
285
wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin.{$min}css", array(), bp_get_version() );
286
287
// Handle spam/un-spam/delete of activities
288
if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
289
903
<?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
904
<?php printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
905
<?php else : ?>
906
+ <?php _e( 'Activity', 'buddypress' ); ?>
907
<?php endif; ?>
908
909
<?php if ( !empty( $_REQUEST['s'] ) ) : ?>
1057
'display_comments' => 'stream',
1058
'show_hidden' => true,
1059
'spam' => 'spam_only',
1060
) );
1061
$this->spam_count = $spams['total'];
1062
unset( $spams );
1072
'show_hidden' => true,
1073
//'sort' => $sort,
1074
'spam' => $spam,
1075
) );
1076
1077
// If we're viewing a specific activity, flatten all activites into a single array.
1138
* @since BuddyPress (1.6.0)
1139
*/
1140
function display() {
1141
+ extract( $this->_args );
1142
+
1143
$this->display_tablenav( 'top' ); ?>
1144
1145
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
1238
function get_columns() {
1239
return array(
1240
'cb' => '<input name type="checkbox" />',
1241
+ 'author' => __( 'Author', 'buddypress' ),
1242
+ 'comment' => __( 'Activity', 'buddypress' ),
1243
+ 'action' => __( 'Action', 'buddypress' ),
1244
+ 'response' => __( 'In Response To', 'buddypress' ),
1245
);
1246
}
1247
1272
* @param string $which 'top' or 'bottom'.
1273
*/
1274
function extra_tablenav( $which ) {
1275
+ if ( 'bottom' == $which )
1276
return;
1277
1278
+ $selected = !empty( $_REQUEST['activity_type'] ) ? $_REQUEST['activity_type'] : '';
1279
1280
+ // Get all types of activities, and sort alphabetically.
1281
+ $actions = bp_activity_get_types();
1282
+ natsort( $actions );
1283
+ ?>
1284
1285
<div class="alignleft actions">
1286
<select name="activity_type">
1287
+ <option value="" <?php selected( !$selected ); ?>><?php _e( 'Show all activity types', 'buddypress' ); ?></option>
1288
1289
+ <?php foreach ( $actions as $k => $v ) : ?>
1290
+ <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option>
1291
<?php endforeach; ?>
1292
</select>
1293
1294
<?php submit_button( __( 'Filter', 'buddypress' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); ?>
bp-activity/bp-activity-classes.php CHANGED
@@ -146,10 +146,10 @@ class BP_Activity_Activity {
146
}
147
148
if ( ! empty( $row ) ) {
149
- $this->id = (int) $row->id;
150
- $this->item_id = (int) $row->item_id;
151
- $this->secondary_item_id = (int) $row->secondary_item_id;
152
- $this->user_id = (int) $row->user_id;
153
$this->primary_link = $row->primary_link;
154
$this->component = $row->component;
155
$this->type = $row->type;
@@ -157,8 +157,8 @@ class BP_Activity_Activity {
157
$this->content = $row->content;
158
$this->date_recorded = $row->date_recorded;
159
$this->hide_sitewide = $row->hide_sitewide;
160
- $this->mptt_left = (int) $row->mptt_left;
161
- $this->mptt_right = (int) $row->mptt_right;
162
$this->is_spam = $row->is_spam;
163
}
164
@@ -257,9 +257,6 @@ class BP_Activity_Activity {
257
* Default: false.
258
* @type array $meta_query An array of meta_query conditions.
259
* See WP_Meta_Query::queries for description.
260
- * @type array $date_query An array of date_query conditions.
261
- * See first parameter of WP_Date_Query::__construct()
262
- * for description.
263
* @type array $filter See BP_Activity_Activity::get_filter_sql().
264
* @type string $search_terms Limit results by a search term.
265
* Default: false.
@@ -270,9 +267,6 @@ class BP_Activity_Activity {
270
* @type string $spam Spam status. Default: 'ham_only'.
271
* @type bool $update_meta_cache Whether to pre-fetch metadata for
272
* queried activity items. Default: true.
273
- * @type string|bool $count_total If true, an additional DB query
274
- * is run to count the total activity items for the query.
275
- * Default: false.
276
* }
277
* @return array The array returned has two keys:
278
* - 'total' is the count of located activities
@@ -311,14 +305,12 @@ class BP_Activity_Activity {
311
'exclude' => false, // Array of ids to exclude
312
'in' => false, // Array of ids to limit query by (IN)
313
'meta_query' => false, // Filter by activitymeta
314
- 'date_query' => false, // Filter by date
315
'filter' => false, // See self::get_filter_sql()
316
'search_terms' => false, // Terms to search by
317
'display_comments' => false, // Whether to include activity comments
318
'show_hidden' => false, // Show items marked hide_sitewide
319
'spam' => 'ham_only', // Spam status
320
'update_meta_cache' => true,
321
- 'count_total' => false,
322
);
323
$r = wp_parse_args( $args, $defaults );
324
extract( $r );
@@ -333,9 +325,6 @@ class BP_Activity_Activity {
333
// Where conditions
334
$where_conditions = array();
335
336
- // Excluded types
337
- $excluded_types = array();
338
-
339
// Spam
340
if ( 'ham_only' == $spam )
341
$where_conditions['spam_sql'] = 'a.is_spam = 0';
@@ -344,8 +333,8 @@ class BP_Activity_Activity {
344
345
// Searching
346
if ( $search_terms ) {
347
- $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
348
- $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
349
}
350
351
// Filtering
@@ -383,35 +372,17 @@ class BP_Activity_Activity {
383
$where_conditions[] = $meta_query_sql['where'];
384
}
385
386
- // Process date_query into SQL
387
- $date_query_sql = self::get_date_query_sql( $date_query );
388
-
389
- if ( ! empty( $date_query_sql ) ) {
390
- $where_conditions['date'] = $date_query_sql;
391
- }
392
-
393
// Alter the query based on whether we want to show activity item
394
// comments in the stream like normal comments or threaded below
395
// the activity.
396
if ( false === $display_comments || 'threaded' === $display_comments ) {
397
- $excluded_types[] = 'activity_comment';
398
}
399
400
// Exclude 'last_activity' items unless the 'action' filter has
401
// been explicitly set
402
if ( empty( $filter['object'] ) ) {
403
- $excluded_types[] = 'last_activity';
404
- }
405
-
406
- // Exclude 'new_member' items if xprofile component is not active
407
- if ( ! bp_is_active( 'xprofile' ) ) {
408
- $excluded_types[] = 'new_member';
409
- }
410
-
411
- // Build the excluded type sql part
412
- if ( ! empty( $excluded_types ) ) {
413
- $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
414
- $where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
415
}
416
417
// Filter the where conditions
@@ -440,12 +411,6 @@ class BP_Activity_Activity {
440
$page = absint( $page );
441
$per_page = absint( $per_page );
442
443
- $retval = array(
444
- 'activities' => null,
445
- 'total' => null,
446
- 'has_more_items' => null,
447
- );
448
-
449
// Filter and return true to use the legacy query structure (not recommended)
450
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
451
@@ -466,26 +431,18 @@ class BP_Activity_Activity {
466
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
467
468
if ( ! empty( $per_page ) && ! empty( $page ) ) {
469
- // We query for $per_page + 1 items in order to
470
- // populate the has_more_items flag
471
- $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
472
}
473
474
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
475
476
$activity_ids = $wpdb->get_col( $activity_ids_sql );
477
-
478
- $retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
479
-
480
- // If we've fetched more than the $per_page value, we
481
- // can discard the extra now
482
- if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
483
- array_pop( $activity_ids );
484
- }
485
-
486
- $activities = self::get_activity_data( $activity_ids );
487
}
488
489
// Get the fullnames of users so we don't have to query in the loop
490
$activities = self::append_user_fullnames( $activities );
491
@@ -508,23 +465,13 @@ class BP_Activity_Activity {
508
// Generate action strings
509
$activities = BP_Activity_Activity::generate_action_strings( $activities );
510
511
- $retval['activities'] = $activities;
512
-
513
// If $max is set, only return up to the max results
514
- if ( ! empty( $r['count_total'] ) ) {
515
-
516
- $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
517
- $total_activities = $wpdb->get_var( $total_activities_sql );
518
-
519
- if ( !empty( $max ) ) {
520
- if ( (int) $total_activities > (int) $max )
521
- $total_activities = $max;
522
- }
523
-
524
- $retval['total'] = $total_activities;
525
}
526
527
- return $retval;
528
}
529
530
/**
@@ -709,33 +656,6 @@ class BP_Activity_Activity {
709
return $sql_array;
710
}
711
712
- /**
713
- * Get the SQL for the 'date_query' param in BP_Activity_Activity::get().
714
- *
715
- * We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
716
- * of parsing the date_query array and creating the necessary SQL clauses.
717
- * However, since BP_Activity_Activity::get() builds its SQL differently than
718
- * WP_Query, we have to alter the return value (stripping the leading AND
719
- * keyword from the query).
720
- *
721
- * @since BuddyPress (2.1.0)
722
- *
723
- * @param array $date_query An array of date_query parameters. See the
724
- * documentation for the first parameter of WP_Date_Query.
725
- * @return string
726
- */
727
- public static function get_date_query_sql( $date_query = array() ) {
728
- $sql = '';
729
-
730
- // Date query
731
- if ( ! empty( $date_query ) && is_array( $date_query ) && class_exists( 'BP_Date_Query' ) ) {
732
- $date_query = new BP_Date_Query( $date_query, 'date_recorded' );
733
- $sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
734
- }
735
-
736
- return $sql;
737
- }
738
-
739
/**
740
* In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
741
*
146
}
147
148
if ( ! empty( $row ) ) {
149
+ $this->id = $row->id;
150
+ $this->item_id = $row->item_id;
151
+ $this->secondary_item_id = $row->secondary_item_id;
152
+ $this->user_id = $row->user_id;
153
$this->primary_link = $row->primary_link;
154
$this->component = $row->component;
155
$this->type = $row->type;
157
$this->content = $row->content;
158
$this->date_recorded = $row->date_recorded;
159
$this->hide_sitewide = $row->hide_sitewide;
160
+ $this->mptt_left = $row->mptt_left;
161
+ $this->mptt_right = $row->mptt_right;
162
$this->is_spam = $row->is_spam;
163
}
164
257
* Default: false.
258
* @type array $meta_query An array of meta_query conditions.
259
* See WP_Meta_Query::queries for description.
260
* @type array $filter See BP_Activity_Activity::get_filter_sql().
261
* @type string $search_terms Limit results by a search term.
262
* Default: false.
267
* @type string $spam Spam status. Default: 'ham_only'.
268
* @type bool $update_meta_cache Whether to pre-fetch metadata for
269
* queried activity items. Default: true.
270
* }
271
* @return array The array returned has two keys:
272
* - 'total' is the count of located activities
305
'exclude' => false, // Array of ids to exclude
306
'in' => false, // Array of ids to limit query by (IN)
307
'meta_query' => false, // Filter by activitymeta
308
'filter' => false, // See self::get_filter_sql()
309
'search_terms' => false, // Terms to search by
310
'display_comments' => false, // Whether to include activity comments
311
'show_hidden' => false, // Show items marked hide_sitewide
312
'spam' => 'ham_only', // Spam status
313
'update_meta_cache' => true,
314
);
315
$r = wp_parse_args( $args, $defaults );
316
extract( $r );
325
// Where conditions
326
$where_conditions = array();
327
328
// Spam
329
if ( 'ham_only' == $spam )
330
$where_conditions['spam_sql'] = 'a.is_spam = 0';
333
334
// Searching
335
if ( $search_terms ) {
336
+ $search_terms = esc_sql( $search_terms );
337
+ $where_conditions['search_sql'] = "a.content LIKE '%%" . esc_sql( like_escape( $search_terms ) ) . "%%'";
338
}
339
340
// Filtering
372
$where_conditions[] = $meta_query_sql['where'];
373
}
374
375
// Alter the query based on whether we want to show activity item
376
// comments in the stream like normal comments or threaded below
377
// the activity.
378
if ( false === $display_comments || 'threaded' === $display_comments ) {
379
+ $where_conditions[] = "a.type != 'activity_comment'";
380
}
381
382
// Exclude 'last_activity' items unless the 'action' filter has
383
// been explicitly set
384
if ( empty( $filter['object'] ) ) {
385
+ $where_conditions[] = "a.type != 'last_activity'";
386
}
387
388
// Filter the where conditions
411
$page = absint( $page );
412
$per_page = absint( $per_page );
413
414
// Filter and return true to use the legacy query structure (not recommended)
415
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
416
431
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
432
433
if ( ! empty( $per_page ) && ! empty( $page ) ) {
434
+ $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
435
}
436
437
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
438
439
$activity_ids = $wpdb->get_col( $activity_ids_sql );
440
+ $activities = self::get_activity_data( $activity_ids );
441
}
442
443
+ $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 );
444
+ $total_activities = $wpdb->get_var( $total_activities_sql );
445
+
446
// Get the fullnames of users so we don't have to query in the loop
447
$activities = self::append_user_fullnames( $activities );
448
465
// Generate action strings
466
$activities = BP_Activity_Activity::generate_action_strings( $activities );
467
468
// If $max is set, only return up to the max results
469
+ if ( !empty( $max ) ) {
470
+ if ( (int) $total_activities > (int) $max )
471
+ $total_activities = $max;
472
}
473
474
+ return array( 'activities' => $activities, 'total' => (int) $total_activities );
475
}
476
477
/**
656
return $sql_array;
657
}
658
659
/**
660
* In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
661
*
bp-activity/bp-activity-cssjs.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Activity component CSS/JS
5
- *
6
- * @package BuddyPress
7
- * @subpackage ActivityScripts
8
- */
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) ) exit;
12
-
13
- /**
14
- * Enqueue @mentions JS.
15
- *
16
- * @since BuddyPress (2.1)
17
- */
18
- function bp_activity_mentions_script() {
19
- if ( ! bp_activity_maybe_load_mentions_scripts() ) {
20
- return;
21
- }
22
-
23
- // Special handling for New/Edit screens in wp-admin
24
- if ( is_admin() ) {
25
- if (
26
- ! get_current_screen() ||
27
- ! in_array( get_current_screen()->base, array( 'page', 'post' ) ) ||
28
- ! post_type_supports( get_current_screen()->post_type, 'editor' ) ) {
29
- return;
30
- }
31
- }
32
-
33
-
34
- $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
35
-
36
- wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
37
- wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() );
38
-
39
- wp_style_add_data( 'bp-mentions-css', 'rtl', true );
40
- if ( $min ) {
41
- wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
42
- }
43
-
44
- // Print a list of the current user's friends to the page for quicker @mentions lookups.
45
- do_action( 'bp_activity_mentions_prime_results' );
46
- }
47
- add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' );
48
- add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
bp-activity/bp-activity-filters.php CHANGED
@@ -22,7 +22,7 @@ add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_filter_kses',
22
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_filter_kses', 1 );
23
add_filter( 'bp_activity_content_before_save', 'bp_activity_filter_kses', 1 );
24
add_filter( 'bp_activity_action_before_save', 'bp_activity_filter_kses', 1 );
25
- add_filter( 'bp_activity_latest_update_content', 'bp_activity_filter_kses', 1 );
26
27
add_filter( 'bp_get_activity_action', 'force_balance_tags' );
28
add_filter( 'bp_get_activity_content_body', 'force_balance_tags' );
@@ -96,9 +96,6 @@ add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' );
96
add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
97
add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 );
98
99
- add_filter( 'bp_get_total_favorite_count_for_user', 'bp_core_number_format' );
100
- add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
101
-
102
/** Actions *******************************************************************/
103
104
// At-name filter
@@ -459,7 +456,7 @@ function bp_activity_timestamp_class( $classes = '' ) {
459
if ( empty( $activity_date ) ) {
460
return $classes;
461
}
462
-
463
$classes .= ' date-recorded-' . strtotime( $activity_date );
464
465
return $classes;
@@ -492,10 +489,6 @@ function bp_activity_heartbeat_last_recorded( $response = array(), $data = array
492
'activity_latest_args'
493
);
494
495
- if ( ! empty( $data['bp_activity_last_recorded_search_terms'] ) && empty( $activity_latest_args['search_terms'] ) ) {
496
- $activity_latest_args['search_terms'] = addslashes( $data['bp_activity_last_recorded_search_terms'] );
497
- }
498
-
499
$newest_activities = array();
500
$last_activity_recorded = 0;
501
22
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_filter_kses', 1 );
23
add_filter( 'bp_activity_content_before_save', 'bp_activity_filter_kses', 1 );
24
add_filter( 'bp_activity_action_before_save', 'bp_activity_filter_kses', 1 );
25
+ add_filter( 'bp_activity_latest_update_content', 'wp_filter_kses', 1 );
26
27
add_filter( 'bp_get_activity_action', 'force_balance_tags' );
28
add_filter( 'bp_get_activity_content_body', 'force_balance_tags' );
96
add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
97
add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 );
98
99
/** Actions *******************************************************************/
100
101
// At-name filter
456
if ( empty( $activity_date ) ) {
457
return $classes;
458
}
459
+
460
$classes .= ' date-recorded-' . strtotime( $activity_date );
461
462
return $classes;
489
'activity_latest_args'
490
);
491
492
$newest_activities = array();
493
$last_activity_recorded = 0;
494
bp-activity/bp-activity-functions.php CHANGED
@@ -15,12 +15,16 @@ if ( !defined( 'ABSPATH' ) ) exit;
15
/**
16
* Check whether the $bp global lists an activity directory page.
17
*
18
- * @since BuddyPress (1.5.0)
19
*
20
* @return bool True if activity directory page is found, otherwise false.
21
*/
22
function bp_activity_has_directory() {
23
- return (bool) !empty( buddypress()->pages->activity->id );
24
}
25
26
/**
@@ -38,7 +42,7 @@ function bp_activity_has_directory() {
38
*
39
* add_filter( 'bp_activity_do_mentions', '__return_false' );
40
*
41
- * @since BuddyPress (1.8.0)
42
*
43
* @uses apply_filters() To call 'bp_activity_do_mentions' hook.
44
*
@@ -48,60 +52,36 @@ function bp_activity_do_mentions() {
48
return (bool) apply_filters( 'bp_activity_do_mentions', true );
49
}
50
51
- /**
52
- * Should BuddyPress load the mentions scripts and related assets, including results to prime the
53
- * mentions suggestions?
54
- *
55
- * @return bool True if mentions scripts should be loaded.
56
- * @since BuddyPress (2.1.0)
57
- */
58
- function bp_activity_maybe_load_mentions_scripts() {
59
- $retval =
60
- bp_activity_do_mentions() &&
61
- bp_is_user_active() &&
62
- ( bp_is_activity_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin() );
63
-
64
- return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $retval );
65
- }
66
-
67
/**
68
* Locate usernames in an activity content string, as designated by an @ sign.
69
*
70
- * @since BuddyPress (1.5.0)
71
*
72
- * @param string $content The content of the activity, usually found in
73
- * $activity->content.
74
- * @return array|bool Associative array with user ID as key and username as
75
- * value. Boolean false if no mentions found.
76
*/
77
function bp_activity_find_mentions( $content ) {
78
-
79
$pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
80
preg_match_all( $pattern, $content, $usernames );
81
82
// Make sure there's only one instance of each username
83
- $usernames = array_unique( $usernames[1] );
84
-
85
- // Bail if no usernames
86
- if ( empty( $usernames ) ) {
87
return false;
88
- }
89
90
$mentioned_users = array();
91
92
// We've found some mentions! Check to see if users exist
93
- foreach( (array) array_values( $usernames ) as $username ) {
94
$user_id = bp_activity_get_userid_from_mentionname( $username );
95
96
// user ID exists, so let's add it to our array
97
if ( ! empty( $user_id ) ) {
98
- $mentioned_users[ $user_id ] = $username;
99
}
100
}
101
102
- if ( empty( $mentioned_users ) ) {
103
return false;
104
- }
105
106
return $mentioned_users;
107
}
@@ -109,7 +89,7 @@ function bp_activity_find_mentions( $content ) {
109
/**
110
* Reset a user's unread mentions list and count.
111
*
112
- * @since BuddyPress (1.5.0)
113
*
114
* @uses bp_delete_user_meta()
115
*
@@ -117,7 +97,7 @@ function bp_activity_find_mentions( $content ) {
117
*/
118
function bp_activity_clear_new_mentions( $user_id ) {
119
bp_delete_user_meta( $user_id, 'bp_new_mention_count' );
120
- bp_delete_user_meta( $user_id, 'bp_new_mentions' );
121
}
122
123
/**
@@ -128,7 +108,7 @@ function bp_activity_clear_new_mentions( $user_id ) {
128
*
129
* Currently, only used in {@link bp_activity_delete()}.
130
*
131
- * @since BuddyPress (1.5.0)
132
*
133
* @uses bp_activity_find_mentions()
134
* @uses bp_activity_update_mention_count_for_user()
@@ -137,25 +117,21 @@ function bp_activity_clear_new_mentions( $user_id ) {
137
* @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
138
*/
139
function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
140
-
141
- // Bail if no activity ID passed
142
- if ( empty( $activity_id ) ) {
143
return false;
144
- }
145
146
// Get activity object
147
- $activity = new BP_Activity_Activity( (int) $activity_id );
148
149
// Try to find mentions
150
$usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
151
152
// Still empty? Stop now
153
- if ( empty( $usernames ) ) {
154
return false;
155
- }
156
157
// Increment mention count foreach mentioned user
158
- foreach( (array) array_keys( $usernames ) as $user_id ) {
159
bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
160
}
161
}
@@ -166,7 +142,7 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
166
* This function should be used when you've already parsed your activity item
167
* for @mentions.
168
*
169
- * @since BuddyPress (1.7.0)
170
*
171
* @uses bp_get_user_meta()
172
* @uses bp_update_user_meta()
@@ -177,19 +153,13 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
177
* @return bool
178
*/
179
function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
180
-
181
- if ( empty( $user_id ) || empty( $activity_id ) ) {
182
return false;
183
- }
184
185
// Adjust the mention list and count for the member
186
$new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true );
187
- $new_mentions = bp_get_user_meta( $user_id, 'bp_new_mentions', true );
188
-
189
- // Make sure new mentions is an array
190
- if ( empty( $new_mentions ) ) {
191
$new_mentions = array();
192
- }
193
194
switch ( $action ) {
195
case 'delete' :
@@ -305,13 +275,9 @@ function bp_activity_get_userid_from_mentionname( $mentionname ) {
305
* @param string $type The action type.
306
* @param string $description The action description.
307
* @param callable $format_callback Callback for formatting the action string.
308
- * @param string $label String to describe this action in the activity stream
309
- * filter dropdown.
310
- * @param array $context Activity stream contexts where the filter should appear.
311
- * 'activity', 'member', 'member_groups', 'group'
312
* @return bool False if any param is empty, otherwise true.
313
*/
314
- function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array() ) {
315
$bp = buddypress();
316
317
// Return false if any of the above values are not set
@@ -337,9 +303,7 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
337
'key' => $type,
338
'value' => $description,
339
'format_callback' => $format_callback,
340
- 'label' => $label,
341
- 'context' => $context,
342
- ), $component_id, $type, $description, $format_callback, $label, $context );
343
344
return true;
345
}
@@ -347,8 +311,9 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
347
/**
348
* Retreive the current action from a component and key.
349
*
350
- * @since BuddyPress (1.1.0)
351
*
352
* @uses apply_filters() To call the 'bp_activity_get_action' hook.
353
*
354
* @param string $component_id The unique string ID of the component.
@@ -356,24 +321,19 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
356
* @return string|bool Action value if found, otherwise false.
357
*/
358
function bp_activity_get_action( $component_id, $key ) {
359
360
// Return false if any of the above values are not set
361
- if ( empty( $component_id ) || empty( $key ) ) {
362
return false;
363
- }
364
-
365
- $bp = buddypress();
366
- $retval = isset( $bp->activity->actions->{$component_id}->{$key} )
367
- ? $bp->activity->actions->{$component_id}->{$key}
368
- : false;
369
370
- return apply_filters( 'bp_activity_get_action', $retval, $component_id, $key );
371
}
372
373
/**
374
* Fetch details of all registered activity types.
375
*
376
- * @since BuddyPress (1.7.0)
377
*
378
* @return array array( type => description ), ...
379
*/
@@ -384,9 +344,8 @@ function bp_activity_get_types() {
384
foreach ( buddypress()->activity->actions as $action ) {
385
$action = array_values( (array) $action );
386
387
- for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
388
$actions[ $action[$i]['key'] ] = $action[$i]['value'];
389
- }
390
}
391
392
// This was a mis-named activity type from before BP 1.6
@@ -400,7 +359,7 @@ function bp_activity_get_types() {
400
/**
401
* Get a users favorite activity stream items.
402
*
403
- * @since BuddyPress (1.2.0)
404
*
405
* @uses bp_get_user_meta()
406
* @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
@@ -411,9 +370,8 @@ function bp_activity_get_types() {
411
function bp_activity_get_user_favorites( $user_id = 0 ) {
412
413
// Fallback to logged in user if no user_id is passed
414
- if ( empty( $user_id ) ) {
415
$user_id = bp_displayed_user_id();
416
- }
417
418
// Get favorites for user
419
$favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
@@ -424,7 +382,7 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
424
/**
425
* Add an activity stream item as a favorite for a user.
426
*
427
- * @since BuddyPress (1.2.0)
428
*
429
* @uses is_user_logged_in()
430
* @uses bp_get_user_meta()
@@ -441,14 +399,12 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
441
function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
442
443
// Favorite activity stream items are for logged in users only
444
- if ( ! is_user_logged_in() ) {
445
return false;
446
- }
447
448
// Fallback to logged in user if no user_id is passed
449
- if ( empty( $user_id ) ) {
450
$user_id = bp_loggedin_user_id();
451
- }
452
453
$my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
454
if ( empty( $my_favs ) || ! is_array( $my_favs ) ) {
@@ -491,7 +447,7 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
491
/**
492
* Remove an activity stream item as a favorite for a user.
493
*
494
- * @since BuddyPress (1.2.0)
495
*
496
* @uses is_user_logged_in()
497
* @uses bp_get_user_meta()
@@ -507,14 +463,12 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
507
function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
508
509
// Favorite activity stream items are for logged in users only
510
- if ( ! is_user_logged_in() ) {
511
return false;
512
- }
513
514
// Fallback to logged in user if no user_id is passed
515
- if ( empty( $user_id ) ) {
516
$user_id = bp_loggedin_user_id();
517
- }
518
519
$my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
520
$my_favs = array_flip( (array) $my_favs );
@@ -529,8 +483,7 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
529
$my_favs = array_unique( array_flip( $my_favs ) );
530
531
// Update the total number of users who have favorited this activity
532
- $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
533
- if ( ! empty( $fav_count ) ) {
534
535
// Deduct from total favorites
536
if ( bp_activity_update_meta( $activity_id, 'favorite_count', (int) $fav_count - 1 ) ) {
@@ -563,7 +516,7 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
563
/**
564
* Check whether an activity item exists with a given content string.
565
*
566
- * @since BuddyPress (1.1.0)
567
*
568
* @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity}
569
* @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
@@ -578,7 +531,7 @@ function bp_activity_check_exists_by_content( $content ) {
578
/**
579
* Retrieve the last time activity was updated.
580
*
581
- * @since BuddyPress (1.0.0)
582
*
583
* @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity}
584
* @uses apply_filters() To call the 'bp_activity_get_last_updated' hook.
@@ -592,7 +545,7 @@ function bp_activity_get_last_updated() {
592
/**
593
* Retrieve the number of favorite activity stream items a user has.
594
*
595
- * @since BuddyPress (1.2.0)
596
*
597
* @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
598
*
@@ -602,9 +555,8 @@ function bp_activity_get_last_updated() {
602
function bp_activity_total_favorites_for_user( $user_id = 0 ) {
603
604
// Fallback on displayed user, and then logged in user
605
- if ( empty( $user_id ) ) {
606
$user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
607
- }
608
609
return BP_Activity_Activity::total_favorite_count( $user_id );
610
}
@@ -632,6 +584,7 @@ function bp_activity_total_favorites_for_user( $user_id = 0 ) {
632
* @return bool True on success, false on failure.
633
*/
634
function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
635
636
// Legacy - if no meta_key is passed, delete all for the item
637
if ( empty( $meta_key ) ) {
@@ -658,7 +611,7 @@ function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = ''
658
/**
659
* Get metadata for a given activity item.
660
*
661
- * @since BuddyPress (1.2.0)
662
*
663
* @uses apply_filters() To call the 'bp_activity_get_meta' hook.
664
*
@@ -683,7 +636,7 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
683
/**
684
* Update a piece of activity meta.
685
*
686
- * @since BuddyPress (1.2.0)
687
*
688
* @param int $activity_id ID of the activity item whose metadata is being
689
* updated.
@@ -712,7 +665,7 @@ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_va
712
* @param int $activity_id ID of the activity item.
713
* @param string $meta_key Metadata key.
714
* @param mixed $meta_value Metadata value.
715
- * @param bool $unique Optional. Whether to enforce a single metadata value
716
* for the given key. If true, and the object already has a value for
717
* the key, no change will be made. Default: false.
718
* @return int|bool The meta ID on successful update, false on failure.
@@ -730,7 +683,7 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
730
/**
731
* Completely remove a user's activity data.
732
*
733
- * @since BuddyPress (1.5.0)
734
*
735
* @uses is_user_logged_in()
736
* @uses bp_activity_delete()
@@ -743,15 +696,14 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
743
function bp_activity_remove_all_user_data( $user_id = 0 ) {
744
745
// Do not delete user data unless a logged in user says so
746
- if ( empty( $user_id ) || ! is_user_logged_in() ) {
747
return false;
748
- }
749
750
// Clear the user's activity from the sitewide stream and clear their activity tables
751
bp_activity_delete( array( 'user_id' => $user_id ) );
752
753
// Remove any usermeta
754
- bp_delete_user_meta( $user_id, 'bp_latest_update' );
755
bp_delete_user_meta( $user_id, 'bp_favorite_activities' );
756
757
// Execute additional code
@@ -766,7 +718,7 @@ add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
766
/**
767
* Mark all of the user's activity as spam.
768
*
769
- * @since BuddyPress (1.6.0)
770
*
771
* @global object $wpdb WordPress database access object.
772
* @global object $bp BuddyPress global settings.
@@ -774,30 +726,22 @@ add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
774
* @param int $user_id ID of the user whose activity is being spammed.
775
*/
776
function bp_activity_spam_all_user_data( $user_id = 0 ) {
777
- global $wpdb;
778
779
// Do not delete user data unless a logged in user says so
780
- if ( empty( $user_id ) || ! is_user_logged_in() ) {
781
return false;
782
- }
783
784
// Get all the user's activities.
785
- $activities = bp_activity_get( array(
786
- 'display_comments' => 'stream',
787
- 'filter' => array( 'user_id' => $user_id ),
788
- 'show_hidden' => true
789
- ) );
790
-
791
- $bp = buddypress();
792
793
// Mark each as spam
794
foreach ( (array) $activities['activities'] as $activity ) {
795
796
// Create an activity object
797
$activity_obj = new BP_Activity_Activity;
798
- foreach ( $activity as $k => $v ) {
799
$activity_obj->$k = $v;
800
- }
801
802
// Mark as spam
803
bp_activity_mark_as_spam( $activity_obj );
@@ -809,9 +753,8 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
809
* as we're going to be updating all the activity statuses directly, for efficency,
810
* we need to update manually.
811
*/
812
- if ( ! empty( $bp->activity->akismet ) ) {
813
$bp->activity->akismet->update_activity_spam_meta( $activity_obj );
814
- }
815
816
// Tidy up
817
unset( $activity_obj );
@@ -828,7 +771,7 @@ add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
828
/**
829
* Mark all of the user's activity as ham (not spam).
830
*
831
- * @since BuddyPress (1.6.0)
832
*
833
* @global object $wpdb WordPress database access object.
834
* @global object $bp BuddyPress global settings.
@@ -836,31 +779,22 @@ add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
836
* @param int $user_id ID of the user whose activity is being hammed.
837
*/
838
function bp_activity_ham_all_user_data( $user_id = 0 ) {
839
- global $wpdb;
840
841
// Do not delete user data unless a logged in user says so
842
- if ( empty( $user_id ) || ! is_user_logged_in() ) {
843
return false;
844
- }
845
846
// Get all the user's activities.
847
- $activities = bp_activity_get( array(
848
- 'display_comments' => 'stream',
849
- 'filter' => array( 'user_id' => $user_id ),
850
- 'show_hidden' => true,
851
- 'spam' => 'all'
852
- ) );
853
-
854
- $bp = buddypress();
855
856
// Mark each as not spam
857
foreach ( (array) $activities['activities'] as $activity ) {
858
859
// Create an activity object
860
$activity_obj = new BP_Activity_Activity;
861
- foreach ( $activity as $k => $v ) {
862
$activity_obj->$k = $v;
863
- }
864
865
// Mark as not spam
866
bp_activity_mark_as_ham( $activity_obj );
@@ -872,9 +806,8 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
872
* as we're going to be updating all the activity statuses directly, for efficency,
873
* we need to update manually.
874
*/
875
- if ( ! empty( $bp->activity->akismet ) ) {
876
$bp->activity->akismet->update_activity_ham_meta( $activity_obj );
877
- }
878
879
// Tidy up
880
unset( $activity_obj );
@@ -891,26 +824,25 @@ add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
891
/**
892
* Register the activity stream actions for updates
893
*
894
- * @since BuddyPress (1.6.0)
895
*/
896
function bp_activity_register_activity_actions() {
897
- $bp = buddypress();
898
899
bp_activity_set_action(
900
$bp->activity->id,
901
'activity_update',
902
__( 'Posted a status update', 'buddypress' ),
903
- 'bp_activity_format_activity_action_activity_update',
904
- __( 'Updates', 'buddypress' ),
905
- array( 'activity', 'group', 'member', 'member_groups' )
906
);
907
908
bp_activity_set_action(
909
$bp->activity->id,
910
'activity_comment',
911
__( 'Replied to a status update', 'buddypress' ),
912
- 'bp_activity_format_activity_action_activity_comment',
913
- __( 'Activity Comments', 'buddypress' )
914
);
915
916
do_action( 'bp_activity_register_activity_actions' );
@@ -928,7 +860,6 @@ add_action( 'bp_register_activity_actions', 'bp_activity_register_activity_actio
928
* the formatted action string.
929
*/
930
function bp_activity_generate_action_string( $activity ) {
931
-
932
// Check for valid input
933
if ( empty( $activity->component ) || empty( $activity->type ) ) {
934
return false;
@@ -995,7 +926,7 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
995
* the default for the bp_activity_get()).
996
* - 'per_page' (false)
997
*
998
- * @since BuddyPress (1.2.0)
999
*
1000
* @see BP_Activity_Activity::get() For more information on accepted arguments
1001
* and the format of the returned value.
@@ -1009,8 +940,7 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
1009
* @return array $activity See BP_Activity_Activity::get() for description.
1010
*/
1011
function bp_activity_get( $args = '' ) {
1012
-
1013
- $r = bp_parse_args( $args, array(
1014
'max' => false, // Maximum number of results to return
1015
'page' => 1, // page 1 without a per_page will result in no pagination.
1016
'per_page' => false, // results per page
@@ -1019,13 +949,11 @@ function bp_activity_get( $args = '' ) {
1019
1020
'search_terms' => false, // Pass search terms as a string
1021
'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format
1022
- 'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format
1023
'show_hidden' => false, // Show activity items that are hidden site-wide?
1024
'exclude' => false, // Comma-separated list of activity IDs to exclude
1025
'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query
1026
'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
1027
'update_meta_cache' => true,
1028
- 'count_total' => false,
1029
1030
/**
1031
* Pass filters as an array -- all filter items can be multiple values comma separated:
@@ -1038,50 +966,46 @@ function bp_activity_get( $args = '' ) {
1038
* );
1039
*/
1040
'filter' => array()
1041
- ) );
1042
1043
// Attempt to return a cached copy of the first page of sitewide activity.
1044
- if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
1045
-
1046
- $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
1047
- if ( false === $activity ) {
1048
-
1049
- $activity = BP_Activity_Activity::get( array(
1050
- 'page' => $r['page'],
1051
- 'per_page' => $r['per_page'],
1052
- 'max' => $r['max'],
1053
- 'sort' => $r['sort'],
1054
- 'search_terms' => $r['search_terms'],
1055
- 'meta_query' => $r['meta_query'],
1056
- 'date_query' => $r['date_query'],
1057
- 'filter' => $r['filter'],
1058
- 'display_comments' => $r['display_comments'],
1059
- 'show_hidden' => $r['show_hidden'],
1060
- 'spam' => $r['spam'],
1061
- 'update_meta_cache' => $r['update_meta_cache'],
1062
- 'count_total' => $r['count_total'],
1063
- ) );
1064
-
1065
wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
1066
}
1067
1068
} else {
1069
- $activity = BP_Activity_Activity::get( array(
1070
- 'page' => $r['page'],
1071
- 'per_page' => $r['per_page'],
1072
- 'max' => $r['max'],
1073
- 'sort' => $r['sort'],
1074
- 'search_terms' => $r['search_terms'],
1075
- 'meta_query' => $r['meta_query'],
1076
- 'date_query' => $r['date_query'],
1077
- 'filter' => $r['filter'],
1078
- 'display_comments' => $r['display_comments'],
1079
- 'show_hidden' => $r['show_hidden'],
1080
- 'exclude' => $r['exclude'],
1081
- 'in' => $r['in'],
1082
- 'spam' => $r['spam'],
1083
- 'count_total' => $r['count_total'],
1084
- ) );
1085
}
1086
1087
return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
@@ -1090,7 +1014,7 @@ function bp_activity_get( $args = '' ) {
1090
/**
1091
* Fetch specific activity items.
1092
*
1093
- * @since BuddyPress (1.2.0)
1094
*
1095
* @see BP_Activity_Activity::get() For more information on accepted arguments
1096
* @uses wp_parse_args()
@@ -1106,38 +1030,38 @@ function bp_activity_get( $args = '' ) {
1106
* @return array $activity See BP_Activity_Activity::get() for description.
1107
*/
1108
function bp_activity_get_specific( $args = '' ) {
1109
-
1110
- $r = bp_parse_args( $args, array(
1111
- 'activity_ids' => false, // A single activity_id or array of IDs.
1112
- 'display_comments' => false, // true or false to display threaded comments for these specific activity items
1113
- 'max' => false, // Maximum number of results to return
1114
- 'page' => 1, // page 1 without a per_page will result in no pagination.
1115
- 'per_page' => false, // results per page
1116
- 'show_hidden' => true, // When fetching specific items, show all
1117
- 'sort' => 'DESC', // sort ASC or DESC
1118
- 'spam' => 'ham_only', // Retrieve items marked as spam
1119
'update_meta_cache' => true,
1120
- ) );
1121
1122
$get_args = array(
1123
- 'display_comments' => $r['display_comments'],
1124
- 'in' => $r['activity_ids'],
1125
- 'max' => $r['max'],
1126
- 'page' => $r['page'],
1127
- 'per_page' => $r['per_page'],
1128
- 'show_hidden' => $r['show_hidden'],
1129
- 'sort' => $r['sort'],
1130
- 'spam' => $r['spam'],
1131
- 'update_meta_cache' => $r['update_meta_cache'],
1132
);
1133
-
1134
return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
1135
}
1136
1137
/**
1138
* Add an activity item.
1139
*
1140
- * @since BuddyPress (1.1.0)
1141
*
1142
* @uses wp_parse_args()
1143
* @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
@@ -1180,57 +1104,56 @@ function bp_activity_get_specific( $args = '' ) {
1180
*/
1181
function bp_activity_add( $args = '' ) {
1182
1183
- $r = bp_parse_args( $args, array(
1184
- 'id' => false, // Pass an existing activity ID to update an existing entry.
1185
- 'action' => '', // The activity action - e.g. "Jon Doe posted an update"
1186
- 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
1187
- 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent
1188
- 'type' => false, // The activity type e.g. activity_update, profile_updated
1189
- 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
1190
- 'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user.
1191
- 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
1192
- 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
1193
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
1194
- 'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
1195
- 'is_spam' => false, // Is this activity item to be marked as spam?
1196
- ) );
1197
1198
// Make sure we are backwards compatible
1199
- if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
1200
- $r['component'] = $r['component_name'];
1201
- }
1202
1203
- if ( empty( $r['type'] ) && !empty( $r['component_action'] ) ) {
1204
- $r['type'] = $r['component_action'];
1205
- }
1206
1207
// Setup activity to be added
1208
- $activity = new BP_Activity_Activity( $r['id'] );
1209
- $activity->user_id = $r['user_id'];
1210
- $activity->component = $r['component'];
1211
- $activity->type = $r['type'];
1212
- $activity->content = $r['content'];
1213
- $activity->primary_link = $r['primary_link'];
1214
- $activity->item_id = $r['item_id'];
1215
- $activity->secondary_item_id = $r['secondary_item_id'];
1216
- $activity->date_recorded = $r['recorded_time'];
1217
- $activity->hide_sitewide = $r['hide_sitewide'];
1218
- $activity->is_spam = $r['is_spam'];
1219
- $activity->action = ! empty( $r['action'] )
1220
- ? $r['action']
1221
- : bp_activity_generate_action_string( $activity );
1222
-
1223
- if ( ! $activity->save() ) {
1224
return false;
1225
- }
1226
1227
// If this is an activity comment, rebuild the tree
1228
- if ( 'activity_comment' === $activity->type ) {
1229
BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
1230
- }
1231
1232
wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
1233
- do_action( 'bp_activity_add', $r );
1234
1235
return $activity->id;
1236
}
@@ -1238,8 +1161,9 @@ function bp_activity_add( $args = '' ) {
1238
/**
1239
* Post an activity update.
1240
*
1241
- * @since BuddyPress (1.2.0)
1242
*
1243
* @uses wp_parse_args()
1244
* @uses bp_is_user_inactive()
1245
* @uses bp_core_get_userlink()
@@ -1258,42 +1182,41 @@ function bp_activity_add( $args = '' ) {
1258
* @return int $activity_id The activity id
1259
*/
1260
function bp_activity_post_update( $args = '' ) {
1261
1262
- $r = wp_parse_args( $args, array(
1263
'content' => false,
1264
'user_id' => bp_loggedin_user_id()
1265
- ) );
1266
1267
- if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) ) {
1268
return false;
1269
- }
1270
1271
- if ( bp_is_user_inactive( $r['user_id'] ) ) {
1272
return false;
1273
- }
1274
1275
// Record this on the user's profile
1276
- $activity_content = $r['content'];
1277
- $primary_link = bp_core_get_userlink( $r['user_id'], false, true );
1278
1279
// Now write the values
1280
$activity_id = bp_activity_add( array(
1281
- 'user_id' => $r['user_id'],
1282
'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
1283
'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
1284
- 'component' => buddypress()->activity->id,
1285
'type' => 'activity_update',
1286
) );
1287
1288
- $activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content );
1289
1290
// Add this update to the "latest update" usermeta so it can be fetched anywhere.
1291
- bp_update_user_meta( bp_loggedin_user_id(), 'bp_latest_update', array(
1292
- 'id' => $activity_id,
1293
- 'content' => $activity_content
1294
- ) );
1295
1296
- do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
1297
1298
return $activity_id;
1299
}
@@ -1301,7 +1224,7 @@ function bp_activity_post_update( $args = '' ) {
1301
/**
1302
* Add an activity comment.
1303
*
1304
- * @since BuddyPress (1.2.0)
1305
*
1306
* @global object $bp BuddyPress global settings.
1307
* @uses wp_parse_args()
@@ -1316,18 +1239,18 @@ function bp_activity_post_update( $args = '' ) {
1316
* @type int $id Optional. Pass an ID to update an existing comment.
1317
* @type string $content The content of the comment.
1318
* @type int $user_id Optional. The ID of the user making the comment.
1319
- * Defaults to the ID of the logged-in user.
1320
* @type int $activity_id The ID of the "root" activity item, ie the oldest
1321
- * ancestor of the comment.
1322
* @type int $parent_id Optional. The ID of the parent activity item, ie the
1323
- * item to which the comment is an immediate reply. If not provided,
1324
- * this value defaults to the $activity_id.
1325
* }
1326
* @return int|bool The ID of the comment on success, otherwise false.
1327
*/
1328
function bp_activity_new_comment( $args = '' ) {
1329
1330
- $r = wp_parse_args( $args, array(
1331
'id' => false,
1332
'content' => false,
1333
'user_id' => bp_loggedin_user_id(),
@@ -1335,31 +1258,31 @@ function bp_activity_new_comment( $args = '' ) {
1335
'parent_id' => false // ID of a parent comment (optional)
1336
) );
1337
1338
// Bail if missing necessary data
1339
- if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
1340
return false;
1341
}
1342
1343
// Maybe set current activity ID as the parent
1344
- if ( empty( $r['parent_id'] ) ) {
1345
- $r['parent_id'] = $r['activity_id'];
1346
}
1347
1348
- $activity_id = $r['activity_id'];
1349
-
1350
// Check to see if the parent activity is hidden, and if so, hide this comment publically.
1351
$activity = new BP_Activity_Activity( $activity_id );
1352
$is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
1353
1354
// Insert the activity comment
1355
$comment_id = bp_activity_add( array(
1356
- 'id' => $r['id'],
1357
- 'content' => apply_filters( 'bp_activity_comment_content', $r['content'] ),
1358
'component' => buddypress()->activity->id,
1359
'type' => 'activity_comment',
1360
- 'user_id' => $r['user_id'],
1361
'item_id' => $activity_id,
1362
- 'secondary_item_id' => $r['parent_id'],
1363
'hide_sitewide' => $is_hidden
1364
) );
1365
@@ -1367,7 +1290,7 @@ function bp_activity_new_comment( $args = '' ) {
1367
wp_cache_delete( $activity_id, 'bp_activity_comments' );
1368
1369
// Walk the tree to clear caches for all parent items
1370
- $clear_id = $r['parent_id'];
1371
while ( $clear_id != $activity_id ) {
1372
$clear_object = new BP_Activity_Activity( $clear_id );
1373
wp_cache_delete( $clear_id, 'bp_activity' );
@@ -1375,7 +1298,7 @@ function bp_activity_new_comment( $args = '' ) {
1375
}
1376
wp_cache_delete( $activity_id, 'bp_activity' );
1377
1378
- do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity );
1379
1380
return $comment_id;
1381
}
@@ -1383,7 +1306,7 @@ function bp_activity_new_comment( $args = '' ) {
1383
/**
1384
* Fetch the activity_id for an existing activity entry in the DB.
1385
*
1386
- * @since BuddyPress (1.2.0)
1387
*
1388
* @see BP_Activity_Activity::get() For more information on accepted arguments.
1389
* @uses wp_parse_args()
@@ -1394,8 +1317,7 @@ function bp_activity_new_comment( $args = '' ) {
1394
* @return int $activity_id The ID of the activity item found.
1395
*/
1396
function bp_activity_get_activity_id( $args = '' ) {
1397
-
1398
- $r = bp_parse_args( $args, array(
1399
'user_id' => false,
1400
'component' => false,
1401
'type' => false,
@@ -1404,18 +1326,12 @@ function bp_activity_get_activity_id( $args = '' ) {
1404
'action' => false,
1405
'content' => false,
1406
'date_recorded' => false,
1407
- ) );
1408
1409
- return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
1410
- $r['user_id'],
1411
- $r['component'],
1412
- $r['type'],
1413
- $r['item_id'],
1414
- $r['secondary_item_id'],
1415
- $r['action'],
1416
- $r['content'],
1417
- $r['date_recorded']
1418
- ) );
1419
}
1420
1421
/**
@@ -1431,7 +1347,7 @@ function bp_activity_get_activity_id( $args = '' ) {
1431
*
1432
* If you are deleting an activity comment please use bp_activity_delete_comment();
1433
*
1434
- * @since BuddyPress (1.0.0)
1435
*
1436
* @see BP_Activity_Activity::get() For more information on accepted arguments.
1437
* @uses wp_parse_args()
@@ -1453,7 +1369,7 @@ function bp_activity_get_activity_id( $args = '' ) {
1453
function bp_activity_delete( $args = '' ) {
1454
1455
// Pass one or more the of following variables to delete by those variables
1456
- $args = bp_parse_args( $args, array(
1457
'id' => false,
1458
'action' => false,
1459
'content' => false,
@@ -1465,22 +1381,23 @@ function bp_activity_delete( $args = '' ) {
1465
'secondary_item_id' => false,
1466
'date_recorded' => false,
1467
'hide_sitewide' => false
1468
- ) );
1469
1470
do_action( 'bp_before_activity_delete', $args );
1471
1472
// Adjust the new mention count of any mentioned member
1473
bp_activity_adjust_mention_count( $args['id'], 'delete' );
1474
1475
- $activity_ids_deleted = BP_Activity_Activity::delete( $args );
1476
- if ( empty( $activity_ids_deleted ) ) {
1477
return false;
1478
- }
1479
1480
// Check if the user's latest update has been deleted
1481
- $user_id = empty( $args['user_id'] )
1482
- ? bp_loggedin_user_id()
1483
- : $args['user_id'];
1484
1485
$latest_update = bp_get_user_meta( $user_id, 'bp_latest_update', true );
1486
if ( !empty( $latest_update ) ) {
@@ -1502,7 +1419,7 @@ function bp_activity_delete( $args = '' ) {
1502
*
1503
* You should use bp_activity_delete() instead.
1504
*
1505
- * @since BuddyPress (1.1.0)
1506
* @deprecated BuddyPress (1.2)
1507
*
1508
* @uses wp_parse_args()
@@ -1515,21 +1432,23 @@ function bp_activity_delete( $args = '' ) {
1515
*/
1516
function bp_activity_delete_by_item_id( $args = '' ) {
1517
1518
- $r = bp_parse_args( $args, array(
1519
'item_id' => false,
1520
'component' => false,
1521
'type' => false,
1522
'user_id' => false,
1523
'secondary_item_id' => false
1524
- ) );
1525
1526
- return bp_activity_delete( $r );
1527
}
1528
1529
/**
1530
* Delete an activity item by activity id.
1531
*
1532
- * @since BuddyPress (1.1.0)
1533
*
1534
* @uses bp_activity_delete()
1535
*
@@ -1545,7 +1464,7 @@ function bp_activity_delete( $args = '' ) {
1545
*
1546
* You should use bp_activity_delete() instead.
1547
*
1548
- * @since BuddyPress (1.1.0)
1549
* @deprecated BuddyPress (1.2)
1550
*
1551
* @uses bp_activity_delete()
@@ -1557,12 +1476,7 @@ function bp_activity_delete( $args = '' ) {
1557
* @return bool True on success, false on failure.
1558
*/
1559
function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
1560
- return bp_activity_delete( array(
1561
- 'user_id' => $user_id,
1562
- 'content' => $content,
1563
- 'component' => $component,
1564
- 'type' => $type
1565
- ) );
1566
}
1567
1568
/**
@@ -1570,7 +1484,7 @@ function bp_activity_delete( $args = '' ) {
1570
*
1571
* You should use bp_activity_delete() instead.
1572
*
1573
- * @since BuddyPress (1.1.0)
1574
* @deprecated BuddyPress (1.2)
1575
*
1576
* @uses bp_activity_delete()
@@ -1580,16 +1494,13 @@ function bp_activity_delete( $args = '' ) {
1580
* @return bool True on success, false on failure.
1581
*/
1582
function bp_activity_delete_for_user_by_component( $user_id, $component ) {
1583
- return bp_activity_delete( array(
1584
- 'user_id' => $user_id,
1585
- 'component' => $component
1586
- ) );
1587
}
1588
1589
/**
1590
* Delete an activity comment.
1591
*
1592
- * @since BuddyPress (1.2.0)
1593
*
1594
* @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook.
1595
* @uses bp_activity_delete_children()
@@ -1611,17 +1522,15 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1611
* You may want to hook into this filter if you want to override this function and
1612
* handle the deletion of child comments differently. Make sure you return false.
1613
*/
1614
- if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
1615
return false;
1616
- }
1617
1618
// Delete any children of this comment.
1619
bp_activity_delete_children( $activity_id, $comment_id );
1620
1621
// Delete the actual comment
1622
- if ( ! bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) {
1623
return false;
1624
- }
1625
1626
// Recalculate the comment tree
1627
BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
@@ -1634,34 +1543,24 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1634
/**
1635
* Delete an activity comment's children.
1636
*
1637
- * @since BuddyPress (1.2.0)
1638
*
1639
* @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
1640
* @uses bp_activity_delete_children()
1641
* @uses bp_activity_delete()
1642
*
1643
* @param int $activity_id The ID of the "root" activity, ie the
1644
- * comment's oldest ancestor.
1645
* @param int $comment_id The ID of the comment to be deleted.
1646
*/
1647
- function bp_activity_delete_children( $activity_id, $comment_id ) {
1648
-
1649
- // Get activity children to delete
1650
- $children = BP_Activity_Activity::get_child_comments( $comment_id );
1651
-
1652
// Recursively delete all children of this comment.
1653
- if ( ! empty( $children ) ) {
1654
foreach( (array) $children as $child ) {
1655
bp_activity_delete_children( $activity_id, $child->id );
1656
}
1657
}
1658
-
1659
- // Delete the comment itself
1660
- bp_activity_delete( array(
1661
- 'secondary_item_id' => $comment_id,
1662
- 'type' => 'activity_comment',
1663
- 'item_id' => $activity_id
1664
- ) );
1665
}
1666
1667
/**
@@ -1672,7 +1571,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1672
* be sure to pass the full $activity_obj parameter as well, if you already
1673
* have it available.
1674
*
1675
- * @since BuddyPress (1.2.0)
1676
*
1677
* @uses bp_get_root_domain()
1678
* @uses bp_get_activity_root_slug()
@@ -1684,9 +1583,8 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1684
*/
1685
function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
1686
1687
- if ( empty( $activity_obj ) ) {
1688
$activity_obj = new BP_Activity_Activity( $activity_id );
1689
- }
1690
1691
if ( isset( $activity_obj->current_comment ) ) {
1692
$activity_obj = $activity_obj->current_comment;
@@ -1708,7 +1606,7 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
1708
/**
1709
* Hide a user's activity.
1710
*
1711
- * @since BuddyPress (1.2.0)
1712
*
1713
* @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
1714
*
@@ -1729,18 +1627,18 @@ function bp_activity_hide_user_activity( $user_id ) {
1729
* through the content, grabs the first image and converts it to a thumbnail,
1730
* and removes the rest of the images from the string.
1731
*
1732
- * @since BuddyPress (1.2.0)
1733
*
1734
* @uses esc_attr()
1735
* @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook
1736
*
1737
* @param string $content The content of the activity item.
1738
* @param string $link Optional. The unescaped URL that the image should link
1739
- * to. If absent, the image will not be a link.
1740
- * @param array $args Optional. The args passed to the activity
1741
- * creation function (eg bp_blogs_record_activity()).
1742
* @return string $content The content with images stripped and replaced with a
1743
- * single thumb.
1744
*/
1745
function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
1746
@@ -1750,18 +1648,17 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
1750
$content = preg_replace('|(\[caption(.*?)\])?<img[^>]*>([^\[\[]*\[\/caption\])?|', '', $content );
1751
1752
if ( !empty( $matches ) && !empty( $matches[0] ) ) {
1753
-
1754
// Get the SRC value
1755
- preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src );
1756
1757
// Get the width and height
1758
preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
1759
preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
1760
1761
if ( !empty( $src ) ) {
1762
- $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
1763
$height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
1764
- $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
1765
1766
if ( empty( $width ) || empty( $height ) ) {
1767
$width = 100;
@@ -1787,7 +1684,7 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
1787
/**
1788
* Fetch whether the current user is allowed to mark items as spam.
1789
*
1790
- * @since BuddyPress (1.6.0)
1791
*
1792
* @return bool True if user is allowed to mark activity items as spam.
1793
*/
@@ -1798,15 +1695,17 @@ function bp_activity_user_can_mark_spam() {
1798
/**
1799
* Mark an activity item as spam.
1800
*
1801
- * @since BuddyPress (1.6.0)
1802
*
1803
* @param BP_Activity_Activity $activity The activity item to be spammed.
1804
* @param string $source Optional. Default is "by_a_person" (ie, a person has
1805
- * manually marked the activity as spam). BP core also accepts
1806
- * 'by_akismet'.
1807
*/
1808
function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
1809
- $bp = buddypress();
1810
1811
$activity->is_spam = 1;
1812
@@ -1836,15 +1735,17 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
1836
/**
1837
* Mark an activity item as ham.
1838
*
1839
- * @since BuddyPress (1.6.0)
1840
*
1841
* @param BP_Activity_Activity $activity The activity item to be hammed.
1842
* @param string $source Optional. Default is "by_a_person" (ie, a person has
1843
- * manually marked the activity as spam). BP core also accepts
1844
- * 'by_akismet'.
1845
*/
1846
function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
1847
- $bp = buddypress();
1848
1849
$activity->is_spam = 0;
1850
@@ -1884,7 +1785,7 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
1884
* This does not cover recursive activity comments, as they do not use a real loop.
1885
* For that, see {@link bp_activity_comment_embed()}.
1886
*
1887
- * @since BuddyPress (1.5.0)
1888
*
1889
* @see BP_Embed
1890
* @see bp_embed_activity_cache()
@@ -1908,7 +1809,7 @@ add_action( 'activity_loop_start', 'bp_activity_embed' );
1908
* necessary to grab each comment's embeds from the cache, or put them in
1909
* the cache if they are not there yet.
1910
*
1911
- * @since BuddyPress (1.5.0)
1912
*
1913
* @see BP_Embed
1914
* @see bp_embed_activity_cache()
@@ -1927,9 +1828,10 @@ add_action( 'bp_before_activity_comment', 'bp_activity_comment_embed' );
1927
/**
1928
* When a user clicks on a "Read More" item, make sure embeds are correctly parsed and shown for the expanded content.
1929
*
1930
- * @since BuddyPress (1.5.0)
1931
*
1932
* @see BP_Embed
1933
* @uses add_filter() To attach create_function() to 'embed_post_id'.
1934
* @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
1935
* @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
@@ -1937,14 +1839,15 @@ add_action( 'bp_before_activity_comment', 'bp_activity_comment_embed' );
1937
* @param object $activity The activity that is being expanded.
1938
*/
1939
function bp_dtheme_embed_read_more( $activity ) {
1940
- buddypress()->activity->read_more_id = $activity->id;
1941
1942
- add_filter( 'embed_post_id', create_function( '', 'return buddypress()->activity->read_more_id;' ) );
1943
- add_filter( 'bp_embed_get_cache', 'bp_embed_activity_cache', 10, 3 );
1944
- add_action( 'bp_embed_update_cache', 'bp_embed_activity_save_cache', 10, 3 );
1945
}
1946
- add_action( 'bp_dtheme_get_single_activity_content', 'bp_dtheme_embed_read_more' );
1947
- add_action( 'bp_legacy_theme_get_single_activity_content', 'bp_dtheme_embed_read_more' );
1948
1949
/**
1950
* Clean up 'embed_post_id' filter after comment recursion.
@@ -1952,7 +1855,7 @@ add_action( 'bp_legacy_theme_get_single_activity_content', 'bp_dtheme_embed_read
1952
* This filter must be removed so that the non-comment filters take over again
1953
* once the comments are done being processed.
1954
*
1955
- * @since BuddyPress (1.5.0)
1956
*
1957
* @see bp_activity_comment_embed()
1958
* @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id'.
@@ -1967,13 +1870,13 @@ add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurs
1967
*
1968
* Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
1969
*
1970
- * @since BuddyPress (1.5.0)
1971
*
1972
* @see BP_Embed::parse_oembed()
1973
* @uses bp_activity_get_meta()
1974
*
1975
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
1976
- * functions like this one to filter.
1977
* @param int $id The ID of the activity item.
1978
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
1979
* @return mixed The cached embeds for this activity item.
@@ -1987,15 +1890,15 @@ function bp_embed_activity_cache( $cache, $id, $cachekey ) {
1987
*
1988
* Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
1989
*
1990
- * @since BuddyPress (1.5.0)
1991
*
1992
* @see BP_Embed::parse_oembed()
1993
* @uses bp_activity_update_meta()
1994
*
1995
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
1996
- * functions like this one to filter.
1997
- * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
1998
* @param int $id The ID of the activity item.
1999
* @return bool True on success, false on failure.
2000
*/
2001
function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
15
/**
16
* Check whether the $bp global lists an activity directory page.
17
*
18
+ * @since BuddyPress (1.5)
19
+ *
20
+ * @global object $bp BuddyPress global settings
21
*
22
* @return bool True if activity directory page is found, otherwise false.
23
*/
24
function bp_activity_has_directory() {
25
+ global $bp;
26
+
27
+ return (bool) !empty( $bp->pages->activity->id );
28
}
29
30
/**
42
*
43
* add_filter( 'bp_activity_do_mentions', '__return_false' );
44
*
45
+ * @since BuddyPress (1.8)
46
*
47
* @uses apply_filters() To call 'bp_activity_do_mentions' hook.
48
*
52
return (bool) apply_filters( 'bp_activity_do_mentions', true );
53
}
54
55
/**
56
* Locate usernames in an activity content string, as designated by an @ sign.
57
*
58
+ * @since BuddyPress (1.5)
59
*
60
+ * @param string $content The content of the activity, usually found in $activity->content.
61
+ * @return array|bool Associative array with user ID as key and username as value. Boolean false if no mentions found.
62
*/
63
function bp_activity_find_mentions( $content ) {
64
$pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
65
preg_match_all( $pattern, $content, $usernames );
66
67
// Make sure there's only one instance of each username
68
+ if ( !$usernames = array_unique( $usernames[1] ) )
69
return false;
70
71
$mentioned_users = array();
72
73
// We've found some mentions! Check to see if users exist
74
+ foreach( (array) $usernames as $key => $username ) {
75
$user_id = bp_activity_get_userid_from_mentionname( $username );
76
77
// user ID exists, so let's add it to our array
78
if ( ! empty( $user_id ) ) {
79
+ $mentioned_users[$user_id] = $username;
80
}
81
}
82
83
+ if ( empty( $mentioned_users ) )
84
return false;
85
86
return $mentioned_users;
87
}
89
/**
90
* Reset a user's unread mentions list and count.
91
*
92
+ * @since BuddyPress (1.5)
93
*
94
* @uses bp_delete_user_meta()
95
*
97
*/
98
function bp_activity_clear_new_mentions( $user_id ) {
99
bp_delete_user_meta( $user_id, 'bp_new_mention_count' );
100
+ bp_delete_user_meta( $user_id, 'bp_new_mentions' );
101
}
102
103
/**
108
*
109
* Currently, only used in {@link bp_activity_delete()}.
110
*
111
+ * @since BuddyPress (1.5)
112
*
113
* @uses bp_activity_find_mentions()
114
* @uses bp_activity_update_mention_count_for_user()
117
* @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
118
*/
119
function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
120
+ if ( empty( $activity_id ) )
121
return false;
122
123
// Get activity object
124
+ $activity = new BP_Activity_Activity( (int) $activity_id );
125
126
// Try to find mentions
127
$usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
128
129
// Still empty? Stop now
130
+ if ( empty( $usernames ) )
131
return false;
132
133
// Increment mention count foreach mentioned user
134
+ foreach( (array) $usernames as $user_id => $username ) {
135
bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
136
}
137
}
142
* This function should be used when you've already parsed your activity item
143
* for @mentions.
144
*
145
+ * @since BuddyPress (1.7)
146
*
147
* @uses bp_get_user_meta()
148
* @uses bp_update_user_meta()
153
* @return bool
154
*/
155
function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
156
+ if ( empty( $user_id ) || empty( $activity_id ) )
157
return false;
158
159
// Adjust the mention list and count for the member
160
$new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true );
161
+ if ( !$new_mentions = bp_get_user_meta( $user_id, 'bp_new_mentions', true ) )
162
$new_mentions = array();
163
164
switch ( $action ) {
165
case 'delete' :
275
* @param string $type The action type.
276
* @param string $description The action description.
277
* @param callable $format_callback Callback for formatting the action string.
278
* @return bool False if any param is empty, otherwise true.
279
*/
280
+ function bp_activity_set_action( $component_id, $type, $description, $format_callback = false ) {
281
$bp = buddypress();
282
283
// Return false if any of the above values are not set
303
'key' => $type,
304
'value' => $description,
305
'format_callback' => $format_callback,
306
+ ), $component_id, $type, $description, $format_callback );
307
308
return true;
309
}
311
/**
312
* Retreive the current action from a component and key.
313
*
314
+ * @since BuddyPress (1.1)
315
*
316
+ * @global object $bp BuddyPress global settings.
317
* @uses apply_filters() To call the 'bp_activity_get_action' hook.
318
*
319
* @param string $component_id The unique string ID of the component.
321
* @return string|bool Action value if found, otherwise false.
322
*/
323
function bp_activity_get_action( $component_id, $key ) {
324
+ global $bp;
325
326
// Return false if any of the above values are not set
327
+ if ( empty( $component_id ) || empty( $key ) )
328
return false;
329
330
+ return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
331