BuddyPress - Version 1.6-RC2

Version Description

= 1.5 = See: http://codex.buddypress.org/releases/version-1-5/

= 1.2.9 = Compatibility with WordPress 3.2

= 1.2.8 = Compatibility with WordPress 3.1

= 1.2.7 = Fixes over 10 bugs.

Download this release

Release Info

Developer DJPaul
Plugin Icon 128x128 BuddyPress
Version 1.6-RC2
Comparing to
See all releases

Code changes from version 1.5.7 to 1.6-RC2

Files changed (243) hide show
  1. bp-activity/admin/css/admin.css +1 -0
  2. bp-activity/admin/css/admin.dev.css +77 -0
  3. bp-activity/admin/js/admin.dev.js +167 -0
  4. bp-activity/admin/js/admin.js +1 -0
  5. bp-activity/bp-activity-actions.php +109 -38
  6. bp-activity/bp-activity-admin.php +1393 -0
  7. bp-activity/bp-activity-akismet.php +587 -0
  8. bp-activity/bp-activity-cache.php +39 -0
  9. bp-activity/bp-activity-classes.php +157 -45
  10. bp-activity/bp-activity-filters.php +89 -17
  11. bp-activity/bp-activity-functions.php +388 -155
  12. bp-activity/bp-activity-loader.php +51 -28
  13. bp-activity/bp-activity-notifications.php +15 -6
  14. bp-activity/bp-activity-screens.php +28 -30
  15. bp-activity/bp-activity-template.php +335 -288
  16. bp-activity/feeds/bp-activity-favorites-feed.php +5 -4
  17. bp-activity/feeds/bp-activity-friends-feed.php +1 -0
  18. bp-activity/feeds/bp-activity-group-feed.php +2 -1
  19. bp-activity/feeds/bp-activity-mentions-feed.php +6 -4
  20. bp-activity/feeds/bp-activity-mygroups-feed.php +5 -3
  21. bp-activity/feeds/bp-activity-personal-feed.php +4 -3
  22. bp-activity/feeds/bp-activity-sitewide-feed.php +2 -1
  23. bp-blogs/bp-blogs-actions.php +26 -4
  24. bp-blogs/bp-blogs-activity.php +64 -29
  25. bp-blogs/bp-blogs-buddybar.php +26 -8
  26. bp-blogs/bp-blogs-cache.php +25 -4
  27. bp-blogs/bp-blogs-classes.php +34 -26
  28. bp-blogs/bp-blogs-filters.php +26 -0
  29. bp-blogs/bp-blogs-functions.php +156 -55
  30. bp-blogs/bp-blogs-loader.php +36 -17
  31. bp-blogs/bp-blogs-screens.php +9 -1
  32. bp-blogs/bp-blogs-template.php +48 -48
  33. bp-blogs/bp-blogs-widgets.php +11 -12
  34. bp-core/admin/bp-core-admin.php +0 -637
  35. bp-core/admin/bp-core-components.php +300 -0
  36. bp-core/admin/bp-core-functions.php +399 -0
  37. bp-core/admin/bp-core-schema.php +116 -32
  38. bp-core/admin/bp-core-settings.php +368 -0
  39. bp-core/admin/bp-core-slugs.php +224 -0
  40. bp-core/admin/bp-core-update.php +287 -590
  41. bp-core/admin/css/common.css +1 -0
  42. bp-core/admin/css/common.dev.css +143 -0
  43. bp-core/admin/css/wizard.css +1 -0
  44. bp-core/{css/admin.dev.css → admin/css/wizard.dev.css} +56 -41
  45. bp-core/{images → admin/images}/completed.gif +0 -0
  46. bp-core/{images → admin/images}/find.png +0 -0
  47. bp-core/admin/images/icons32.png +0 -0
  48. bp-core/{images → admin/images}/installed.gif +0 -0
  49. bp-core/admin/images/menu-wp.png +0 -0
  50. bp-core/admin/images/menu.png +0 -0
  51. bp-core/{js/update.dev.js → admin/js/wizard.dev.js} +0 -0
  52. bp-core/{js/update.js → admin/js/wizard.js} +0 -0
  53. bp-core/bp-core-actions.php +267 -0
  54. bp-core/bp-core-admin.php +511 -0
  55. bp-core/bp-core-adminbar.php +35 -225
  56. bp-core/bp-core-avatars.php +230 -121
  57. bp-core/bp-core-buddybar.php +169 -104
  58. bp-core/bp-core-cache.php +88 -3
  59. bp-core/bp-core-caps.php +426 -0
  60. bp-core/bp-core-catchuri.php +326 -90
  61. bp-core/bp-core-classes.php +172 -138
  62. bp-core/bp-core-component.php +57 -26
  63. bp-core/bp-core-cssjs.php +3 -36
  64. bp-core/bp-core-filters.php +72 -51
  65. bp-core/bp-core-functions.php +288 -555
  66. bp-core/bp-core-hooks.php +0 -114
  67. bp-core/bp-core-loader.php +81 -68
  68. bp-core/bp-core-moderation.php +268 -0
  69. bp-core/bp-core-options.php +524 -0
  70. bp-core/bp-core-template.php +110 -72
  71. bp-core/bp-core-update.php +197 -0
  72. bp-core/bp-core-widgets.php +23 -29
  73. bp-core/bp-core-wpabstraction.php +5 -6
  74. bp-core/css/admin-bar-rtl.css +1 -1
  75. bp-core/css/admin-bar.css +1 -1
  76. bp-core/css/admin-bar.dev.css +25 -29
  77. bp-core/css/admin.css +0 -1
  78. bp-core/css/buddybar-rtl.css +1 -1
  79. bp-core/css/buddybar.css +1 -1
  80. bp-core/css/buddybar.dev.css +2 -4
  81. bp-core/deprecated/1.5.php +134 -5
  82. bp-core/deprecated/1.6.php +264 -0
  83. bp-core/images/admin-bar-sprite-rtl.png +0 -0
  84. bp-core/images/admin-bar-sprite.png +0 -0
  85. bp-core/images/admin_menu_icon.png +0 -0
  86. bp-core/images/icons32.png +0 -0
  87. bp-core/images/logo-column-header.png +0 -0
  88. bp-core/images/logo.png +0 -0
  89. bp-forums/bp-forums-admin.php +84 -26
  90. bp-forums/bp-forums-bbpress-sa.php +5 -9
  91. bp-forums/bp-forums-filters.php +3 -3
  92. bp-forums/bp-forums-functions.php +102 -29
  93. bp-forums/bp-forums-loader.php +25 -23
  94. bp-forums/bp-forums-screens.php +2 -2
  95. bp-forums/bp-forums-template.php +63 -59
  96. bp-forums/deprecated/1.6.php +203 -0
  97. bp-friends/bp-friends-actions.php +7 -1
  98. bp-friends/bp-friends-activity.php +26 -16
  99. bp-friends/bp-friends-cache.php +9 -4
  100. bp-friends/bp-friends-classes.php +53 -50
  101. bp-friends/bp-friends-functions.php +40 -23
  102. bp-friends/bp-friends-loader.php +25 -18
  103. bp-friends/bp-friends-notifications.php +20 -16
  104. bp-friends/bp-friends-screens.php +24 -9
  105. bp-friends/bp-friends-template.php +80 -95
  106. bp-groups/bp-groups-actions.php +41 -34
  107. bp-groups/bp-groups-activity.php +48 -39
  108. bp-groups/bp-groups-adminbar.php +27 -57
  109. bp-groups/bp-groups-buddybar.php +19 -4
  110. bp-groups/bp-groups-cache.php +58 -3
  111. bp-groups/bp-groups-classes.php +259 -154
  112. bp-groups/bp-groups-filters.php +27 -14
  113. bp-groups/bp-groups-forums.php +159 -42
  114. bp-groups/bp-groups-functions.php +125 -84
  115. bp-groups/bp-groups-loader.php +174 -55
  116. bp-groups/bp-groups-notifications.php +21 -16
  117. bp-groups/bp-groups-screens.php +73 -59
  118. bp-groups/bp-groups-template.php +307 -268
  119. bp-groups/bp-groups-widgets.php +30 -14
  120. bp-languages/buddypress.pot +2017 -1445
  121. bp-loader.php +444 -91
  122. bp-members/bp-members-actions.php +24 -19
  123. bp-members/bp-members-adminbar.php +60 -163
  124. bp-members/bp-members-buddybar.php +37 -20
  125. bp-members/bp-members-filters.php +5 -4
  126. bp-members/bp-members-functions.php +609 -101
  127. bp-members/bp-members-loader.php +51 -32
  128. bp-members/bp-members-notifications.php +151 -29
  129. bp-members/bp-members-screens.php +212 -1
  130. bp-members/bp-members-signup.php +0 -630
  131. bp-members/bp-members-template.php +126 -115
  132. bp-messages/bp-messages-actions.php +17 -10
  133. bp-messages/bp-messages-cache.php +8 -2
  134. bp-messages/bp-messages-classes.php +132 -52
  135. bp-messages/bp-messages-cssjs.php +29 -17
  136. bp-messages/bp-messages-filters.php +46 -39
  137. bp-messages/bp-messages-functions.php +27 -30
  138. bp-messages/bp-messages-loader.php +39 -25
  139. bp-messages/bp-messages-notifications.php +49 -33
  140. bp-messages/bp-messages-screens.php +15 -16
  141. bp-messages/bp-messages-template.php +167 -101
  142. bp-messages/css/autocomplete/jquery.autocompletefb.css +1 -1
  143. bp-messages/js/autocomplete/jquery.autocomplete.js +1 -1
  144. bp-messages/js/autocomplete/jquery.autocompletefb.js +1 -1
  145. bp-messages/js/autocomplete/jquery.bgiframe.js +1 -1
  146. bp-messages/js/autocomplete/jquery.dimensions.js +1 -1
  147. bp-settings/bp-settings-actions.php +131 -40
  148. bp-settings/bp-settings-functions.php +9 -0
  149. bp-settings/bp-settings-loader.php +48 -25
  150. bp-settings/bp-settings-screens.php +80 -1
  151. bp-settings/bp-settings-template.php +10 -9
  152. bp-themes/bp-default/404.php +3 -3
  153. bp-themes/bp-default/_inc/ajax.php +456 -277
  154. bp-themes/bp-default/_inc/css/default-rtl.css +11 -14
  155. bp-themes/bp-default/_inc/css/default.css +83 -19
  156. bp-themes/bp-default/_inc/css/responsive.css +83 -0
  157. bp-themes/bp-default/_inc/global.js +306 -131
  158. bp-themes/bp-default/_inc/images/rss.png +0 -0
  159. bp-themes/bp-default/activity/comment.php +4 -2
  160. bp-themes/bp-default/activity/entry.php +2 -2
  161. bp-themes/bp-default/activity/index.php +6 -8
  162. bp-themes/bp-default/activity/post-form.php +1 -1
  163. bp-themes/bp-default/archive.php +9 -9
  164. bp-themes/bp-default/attachment.php +5 -5
  165. bp-themes/bp-default/blogs/create.php +6 -4
  166. bp-themes/bp-default/blogs/index.php +3 -5
  167. bp-themes/bp-default/comments.php +13 -13
  168. bp-themes/bp-default/footer.php +8 -7
  169. bp-themes/bp-default/forums/index.php +4 -4
  170. bp-themes/bp-default/functions.php +80 -86
  171. bp-themes/bp-default/groups/create.php +31 -34
  172. bp-themes/bp-default/groups/index.php +2 -4
  173. bp-themes/bp-default/groups/single/activity.php +14 -14
  174. bp-themes/bp-default/groups/single/admin.php +68 -66
  175. bp-themes/bp-default/groups/single/forum.php +14 -14
  176. bp-themes/bp-default/groups/single/forum/edit.php +21 -25
  177. bp-themes/bp-default/groups/single/forum/topic.php +91 -91
  178. bp-themes/bp-default/groups/single/group-header.php +1 -1
  179. bp-themes/bp-default/groups/single/home.php +1 -1
  180. bp-themes/bp-default/groups/single/plugins.php +11 -11
  181. bp-themes/bp-default/groups/single/request-membership.php +6 -6
  182. bp-themes/bp-default/groups/single/send-invites.php +17 -17
  183. bp-themes/bp-default/header.php +15 -20
  184. bp-themes/bp-default/index.php +13 -13
  185. bp-themes/bp-default/links.php +4 -4
  186. bp-themes/bp-default/members/index.php +1 -3
  187. bp-themes/bp-default/members/single/activity.php +10 -10
  188. bp-themes/bp-default/members/single/activity/permalink.php +5 -3
  189. bp-themes/bp-default/members/single/forums.php +1 -1
  190. bp-themes/bp-default/members/single/friends.php +6 -6
  191. bp-themes/bp-default/members/single/friends/requests.php +12 -12
  192. bp-themes/bp-default/members/single/groups.php +1 -1
  193. bp-themes/bp-default/members/single/groups/invites.php +10 -10
  194. bp-themes/bp-default/members/single/home.php +1 -3
  195. bp-themes/bp-default/members/single/member-header.php +1 -1
  196. bp-themes/bp-default/members/single/messages.php +7 -0
  197. bp-themes/bp-default/members/single/messages/compose.php +14 -14
  198. bp-themes/bp-default/members/single/messages/messages-loop.php +23 -22
  199. bp-themes/bp-default/members/single/messages/notices-loop.php +23 -18
  200. bp-themes/bp-default/members/single/messages/single.php +25 -25
  201. bp-themes/bp-default/members/single/profile/change-avatar.php +16 -16
  202. bp-themes/bp-default/members/single/profile/edit.php +27 -7
  203. bp-themes/bp-default/members/single/profile/profile-wp.php +5 -5
  204. bp-themes/bp-default/members/single/settings/capabilities.php +81 -0
  205. bp-themes/bp-default/members/single/settings/delete-account.php +23 -9
  206. bp-themes/bp-default/members/single/settings/general.php +4 -5
  207. bp-themes/bp-default/members/single/settings/notifications.php +4 -5
  208. bp-themes/bp-default/onecolumn-page.php +4 -4
  209. bp-themes/bp-default/page.php +4 -4
  210. bp-themes/bp-default/registration/activate.php +13 -13
  211. bp-themes/bp-default/registration/register.php +106 -84
  212. bp-themes/bp-default/rtl.css +2 -2
  213. bp-themes/bp-default/search.php +13 -13
  214. bp-themes/bp-default/searchform.php +5 -5
  215. bp-themes/bp-default/sidebar-footer.php +44 -37
  216. bp-themes/bp-default/sidebar.php +20 -20
  217. bp-themes/bp-default/single.php +6 -6
  218. bp-themes/bp-default/style.css +2 -2
  219. bp-xprofile/admin/css/admin.css +1 -1
  220. bp-xprofile/admin/css/admin.dev.css +46 -64
  221. bp-xprofile/admin/images/cross.gif +0 -0
  222. bp-xprofile/admin/images/move-x.gif +0 -0
  223. bp-xprofile/admin/images/move.gif +0 -0
  224. bp-xprofile/admin/images/move.png +0 -0
  225. bp-xprofile/admin/images/plus.gif +0 -0
  226. bp-xprofile/admin/js/admin.dev.js +98 -107
  227. bp-xprofile/admin/js/admin.js +1 -1
  228. bp-xprofile/bp-xprofile-actions.php +12 -8
  229. bp-xprofile/bp-xprofile-activity.php +26 -24
  230. bp-xprofile/bp-xprofile-admin.php +176 -183
  231. bp-xprofile/bp-xprofile-buddybar.php +2 -0
  232. bp-xprofile/bp-xprofile-cache.php +10 -7
  233. bp-xprofile/bp-xprofile-caps.php +61 -0
  234. bp-xprofile/bp-xprofile-classes.php +402 -237
  235. bp-xprofile/bp-xprofile-cssjs.php +36 -15
  236. bp-xprofile/bp-xprofile-filters.php +60 -51
  237. bp-xprofile/bp-xprofile-functions.php +186 -44
  238. bp-xprofile/bp-xprofile-loader.php +61 -18
  239. bp-xprofile/bp-xprofile-screens.php +28 -13
  240. bp-xprofile/bp-xprofile-template.php +164 -69
  241. humans.txt +1 -1
  242. license.txt +280 -280
  243. readme.txt +104 -131
bp-activity/admin/css/admin.css ADDED
@@ -0,0 +1 @@
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}
bp-activity/admin/css/admin.dev.css ADDED
@@ -0,0 +1,77 @@
1
+ .akismet-status {
2
+ float: right;
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: right;
42
+ padding: 4px 10px 0;
43
+ vertical-align: top;
44
+ }
45
+ #bp-activities-form .column-response img {
46
+ float: left;
47
+ margin-right: 10px;
48
+ margin-top: 1px;
49
+ }
50
+ .activity-errors {
51
+ list-style-type: disc;
52
+ margin-left: 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
+ }
bp-activity/admin/js/admin.dev.js ADDED
@@ -0,0 +1,167 @@
1
+ (function( $ ) {
2
+
3
+ /**
4
+ * Activity reply object for the activity index screen
5
+ *
6
+ * @since 1.6
7
+ */
8
+ var activityReply = {
9
+
10
+ /**
11
+ * Attach event handler functions to the relevant elements.
12
+ *
13
+ * @since 1.6
14
+ */
15
+ init : function() {
16
+ $(document).on( 'click', '.row-actions a.reply', activityReply.open );
17
+ $(document).on( 'click', '#bp-activities-container a.cancel', activityReply.close );
18
+ $(document).on( 'click', '#bp-activities-container a.save', activityReply.send );
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
+ });
26
+ },
27
+
28
+ /**
29
+ * Reveals the entire row when "reply" is pressed.
30
+ *
31
+ * @since 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 );
37
+
38
+ // Fade the whole row in, and set focus on the text area.
39
+ box.fadeIn( '300' );
40
+ $( '#bp-activities' ).focus();
41
+
42
+ return false;
43
+ },
44
+
45
+ /**
46
+ * Hide and reset the entire row when "cancel", or escape, are pressed.
47
+ *
48
+ * @since 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();
56
+
57
+ // Remove any error message and disable the spinner
58
+ $( '#bp-replysubmit .error' ).html( '' ).hide();
59
+ $( '#bp-replysubmit .waiting' ).hide();
60
+ });
61
+
62
+ return false;
63
+ },
64
+
65
+ /**
66
+ * Submits "form" via AJAX back to WordPress.
67
+ *
68
+ * @since 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();
74
+
75
+ // Grab the nonce
76
+ var reply = {};
77
+ reply['_ajax_nonce-bp-activity-admin-reply'] = $( '#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]' ).val();
78
+
79
+ // Get the rest of the data
80
+ reply.action = 'bp-activity-admin-reply';
81
+ reply.content = $( '#bp-activities' ).val();
82
+ reply.parent_id = $( '#bp-activities-container' ).prev().data( 'parent_id' );
83
+ reply.root_id = $( '#bp-activities-container' ).prev().data( 'root_id' );
84
+
85
+ // Make the AJAX call
86
+ $.ajax({
87
+ data : reply,
88
+ type : 'POST',
89
+ url : ajaxurl,
90
+
91
+ // Callbacks
92
+ error : function( r ) { activityReply.error( r ); },
93
+ success : function( r ) { activityReply.show( r ); }
94
+ });
95
+
96
+ return false;
97
+ },
98
+
99
+ /**
100
+ * send() error message handler
101
+ *
102
+ * @since 1.6
103
+ */
104
+ error : function( r ) {
105
+ var er = r.statusText;
106
+ $('#bp-replysubmit .waiting').hide();
107
+
108
+ if ( r.responseText ) {
109
+ er = r.responseText.replace( /<.[^<>]*?>/g, '' );
110
+ }
111
+
112
+ if ( er ) {
113
+ $('#bp-replysubmit .error').html( er ).show();
114
+ }
115
+ },
116
+
117
+ /**
118
+ * send() success handler
119
+ *
120
+ * @since 1.6
121
+ */
122
+ show : function ( xml ) {
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
+ }
130
+
131
+ response = wpAjax.parseAjaxResponse( xml );
132
+ if ( response.errors ) {
133
+ activityReply.error( { 'responseText': wpAjax.broken } );
134
+ return false;
135
+ }
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();
143
+
144
+ // Remove any error message and disable the spinner
145
+ $( '#bp-replysubmit .error' ).html( '' ).hide();
146
+ $( '#bp-replysubmit .waiting' ).hide();
147
+
148
+ // Insert new activity item
149
+ $( '#bp-activities-container' ).before( response.data );
150
+
151
+ // Get background colour and animate the flash
152
+ id = $( '#activity-' + response.id );
153
+ bg = id.closest( '.widefat' ).css( 'backgroundColor' );
154
+ id.animate( { 'backgroundColor': '#CEB' }, 300 ).animate( { 'backgroundColor': bg }, 300 );
155
+ });
156
+ }
157
+ };
158
+
159
+ $(document).ready( function () {
160
+ // Create the Activity reply object after domready event
161
+ activityReply.init();
162
+
163
+ // On the edit screen, unload the close/open toggle js for the action & content metaboxes
164
+ $( '#bp_activity_action h3, #bp_activity_content h3' ).unbind( 'click' );
165
+ });
166
+
167
+ })(jQuery);
bp-activity/admin/js/admin.js ADDED
@@ -0,0 +1 @@
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")})})(jQuery);
bp-activity/bp-activity-actions.php CHANGED
@@ -15,7 +15,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
15
/**
16
* Allow core components and dependent plugins to register activity actions
17
*
18
- * @since 1.2.0
19
*
20
* @uses do_action() To call 'bp_register_activity_actions' hook.
21
*/
@@ -27,7 +27,7 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
27
/**
28
* Allow core components and dependent plugins to register activity actions
29
*
30
- * @since 1.2.0
31
*
32
* @global object $bp BuddyPress global settings
33
* @uses bp_is_activity_component()
@@ -88,7 +88,14 @@ function bp_activity_action_permalink_router() {
88
89
// Set redirect to users' activity stream
90
} else {
91
- $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id;
92
}
93
94
// Allow redirect to be filtered
@@ -103,11 +110,10 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
103
/**
104
* Delete specific activity item and redirect to previous page.
105
*
106
- * @since 1.1.0
107
*
108
* @param int $activity_id Activity id to be deleted. Defaults to 0.
109
*
110
- * @global object $bp BuddyPress global settings
111
* @uses bp_is_activity_component()
112
* @uses bp_is_current_action()
113
* @uses bp_action_variable()
@@ -122,7 +128,6 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
122
* @return bool False on failure
123
*/
124
function bp_activity_action_delete_activity( $activity_id = 0 ) {
125
- global $bp;
126
127
// Not viewing activity or action is not delete
128
if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
@@ -164,12 +169,65 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
164
}
165
add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
166
167
/**
168
* Post user/group activity update.
169
*
170
- * @since 1.2.0
171
*
172
- * @global object $bp BuddyPress global settings
173
* @uses is_user_logged_in()
174
* @uses bp_is_activity_component()
175
* @uses bp_is_current_action()
@@ -187,7 +245,6 @@ add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
187
* @return bool False on failure
188
*/
189
function bp_activity_action_post_update() {
190
- global $bp;
191
192
// Do not proceed if user is not logged in, not viewing activity, or not posting
193
if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
@@ -213,7 +270,7 @@ function bp_activity_action_post_update() {
213
214
// Post to groups object
215
} else if ( 'groups' == $object && bp_is_active( 'groups' ) ) {
216
- if ( (int)$item_id ) {
217
$activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
218
}
219
@@ -236,9 +293,8 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
236
/**
237
* Post new activity comment.
238
*
239
- * @since 1.2.0
240
*
241
- * @global object $bp BuddyPress global settings
242
* @uses is_user_logged_in()
243
* @uses bp_is_activity_component()
244
* @uses bp_is_current_action()
@@ -253,9 +309,8 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
253
* @return bool False on failure
254
*/
255
function bp_activity_action_post_comment() {
256
- global $bp;
257
258
- if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'reply' ) )
259
return false;
260
261
// Check the nonce
@@ -287,9 +342,8 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
287
/**
288
* Mark activity as favorite.
289
*
290
- * @since 1.2.0
291
*
292
- * @global object $bp BuddyPress global settings
293
* @uses is_user_logged_in()
294
* @uses bp_is_activity_component()
295
* @uses bp_is_current_action()
@@ -303,9 +357,8 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
303
* @return bool False on failure
304
*/
305
function bp_activity_action_mark_favorite() {
306
- global $bp;
307
308
- if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'favorite' ) )
309
return false;
310
311
// Check the nonce
@@ -323,9 +376,8 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
323
/**
324
* Remove activity from favorites.
325
*
326
- * @since 1.2.0
327
*
328
- * @global object $bp BuddyPress global settings
329
* @uses is_user_logged_in()
330
* @uses bp_is_activity_component()
331
* @uses bp_is_current_action()
@@ -339,9 +391,8 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
339
* @return bool False on failure
340
*/
341
function bp_activity_action_remove_favorite() {
342
- global $bp;
343
344
- if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'unfavorite' ) )
345
return false;
346
347
// Check the nonce
@@ -359,7 +410,7 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
359
/**
360
* Load the sitewide feed.
361
*
362
- * @since 1.0.0
363
*
364
* @global object $bp BuddyPress global settings
365
* @global object $wp_query
@@ -387,9 +438,8 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
387
/**
388
* Load a user's personal feed.
389
*
390
- * @since 1.0.0
391
*
392
- * @global object $bp BuddyPress global settings
393
* @global object $wp_query
394
* @uses bp_is_user_activity()
395
* @uses bp_is_current_action()
@@ -398,7 +448,7 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
398
* @return bool False on failure
399
*/
400
function bp_activity_action_personal_feed() {
401
- global $bp, $wp_query;
402
403
if ( !bp_is_user_activity() || !bp_is_current_action( 'feed' ) )
404
return false;
@@ -414,9 +464,8 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
414
/**
415
* Load a user's friends feed.
416
*
417
- * @since 1.0.0
418
*
419
- * @global object $bp BuddyPress global settings
420
* @global object $wp_query
421
* @uses bp_is_active()
422
* @uses bp_is_user_activity()
@@ -428,7 +477,7 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
428
* @return bool False on failure
429
*/
430
function bp_activity_action_friends_feed() {
431
- global $bp, $wp_query;
432
433
if ( !bp_is_active( 'friends' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_friends_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
434
return false;
@@ -444,9 +493,8 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
444
/**
445
* Load a user's my groups feed.
446
*
447
- * @since 1.2.0
448
*
449
- * @global object $bp BuddyPress global settings
450
* @global object $wp_query
451
* @uses bp_is_active()
452
* @uses bp_is_user_activity()
@@ -458,7 +506,7 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
458
* @return bool False on failure
459
*/
460
function bp_activity_action_my_groups_feed() {
461
- global $bp, $wp_query;
462
463
if ( !bp_is_active( 'groups' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_groups_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
464
return false;
@@ -474,9 +522,8 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
474
/**
475
* Load a user's @mentions feed.
476
*
477
- * @since 1.2.0
478
*
479
- * @global object $bp BuddyPress global settings
480
* @global object $wp_query
481
* @uses bp_is_user_activity()
482
* @uses bp_is_current_action()
@@ -486,7 +533,7 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
486
* @return bool False on failure
487
*/
488
function bp_activity_action_mentions_feed() {
489
- global $bp, $wp_query;
490
491
if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
492
return false;
@@ -502,9 +549,8 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
502
/**
503
* Load a user's favorites feed.
504
*
505
- * @since 1.2.0
506
*
507
- * @global object $bp BuddyPress global settings
508
* @global object $wp_query
509
* @uses bp_is_user_activity()
510
* @uses bp_is_current_action()
@@ -514,7 +560,7 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
514
* @return bool False on failure
515
*/
516
function bp_activity_action_favorites_feed() {
517
- global $bp, $wp_query;
518
519
if ( !bp_is_user_activity() || !bp_is_current_action( 'favorites' ) || !bp_is_action_variable( 'feed', 0 ) )
520
return false;
@@ -527,4 +573,29 @@ function bp_activity_action_favorites_feed() {
527
}
528
add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
529
530
?>
15
/**
16
* Allow core components and dependent plugins to register activity actions
17
*
18
+ * @since BuddyPress (1.2)
19
*
20
* @uses do_action() To call 'bp_register_activity_actions' hook.
21
*/
27
/**
28
* Allow core components and dependent plugins to register activity actions
29
*
30
+ * @since BuddyPress (1.2)
31
*
32
* @global object $bp BuddyPress global settings
33
* @uses bp_is_activity_component()
88
89
// Set redirect to users' activity stream
90
} else {
91
+ $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
92
+ }
93
+
94
+ // If set, add the original query string back onto the redirect URL
95
+ if ( !empty( $_SERVER['QUERY_STRING'] ) ) {
96
+ $query_frags = array();
97
+ wp_parse_str( $_SERVER['QUERY_STRING'], $query_frags );
98
+ $redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect );
99
}
100
101
// Allow redirect to be filtered
110
/**
111
* Delete specific activity item and redirect to previous page.
112
*
113
+ * @since BuddyPress (1.1)
114
*
115
* @param int $activity_id Activity id to be deleted. Defaults to 0.
116
*
117
* @uses bp_is_activity_component()
118
* @uses bp_is_current_action()
119
* @uses bp_action_variable()
128
* @return bool False on failure
129
*/
130
function bp_activity_action_delete_activity( $activity_id = 0 ) {
131
132
// Not viewing activity or action is not delete
133
if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
169
}
170
add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
171
172
+ /**
173
+ * Mark specific activity item as spam and redirect to previous page
174
+ *
175
+ * @global object $bp BuddyPress global settings
176
+ * @param int $activity_id Activity id to be deleted. Defaults to 0.
177
+ * @return bool False on failure
178
+ * @since 1.6
179
+ */
180
+ function bp_activity_action_spam_activity( $activity_id = 0 ) {
181
+ global $bp;
182
+
183
+ // Not viewing activity, or action is not spam, or Akismet isn't present
184
+ if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
185
+ return false;
186
+
187
+ if ( empty( $activity_id ) && bp_action_variable( 0 ) )
188
+ $activity_id = (int) bp_action_variable( 0 );
189
+
190
+ // Not viewing a specific activity item
191
+ if ( empty( $activity_id ) )
192
+ return false;
193
+
194
+ // Is the current user allowed to spam items?
195
+ if ( !bp_activity_user_can_mark_spam() )
196
+ return false;
197
+
198
+ // Load up the activity item
199
+ $activity = new BP_Activity_Activity( $activity_id );
200
+ if ( empty( $activity->id ) )
201
+ return false;
202
+
203
+ // Check nonce
204
+ check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
205
+
206
+ // Call an action before the spamming so plugins can modify things if they want to
207
+ do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
208
+
209
+ // Mark as spam
210
+ bp_activity_mark_as_spam( $activity );
211
+ $activity->save();
212
+
213
+ // Tell the user the spamming has been succesful
214
+ bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
215
+
216
+ do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
217
+
218
+ // Check for the redirect query arg, otherwise let WP handle things
219
+ if ( !empty( $_GET['redirect_to'] ) )
220
+ bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
221
+ else
222
+ bp_core_redirect( wp_get_referer() );
223
+ }
224
+ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
225
+
226
/**
227
* Post user/group activity update.
228
*
229
+ * @since BuddyPress (1.2)
230
*
231
* @uses is_user_logged_in()
232
* @uses bp_is_activity_component()
233
* @uses bp_is_current_action()
245
* @return bool False on failure
246
*/
247
function bp_activity_action_post_update() {
248
249
// Do not proceed if user is not logged in, not viewing activity, or not posting
250
if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
270
271
// Post to groups object
272
} else if ( 'groups' == $object && bp_is_active( 'groups' ) ) {
273
+ if ( (int) $item_id ) {
274
$activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
275
}
276
293
/**
294
* Post new activity comment.
295
*
296
+ * @since BuddyPress (1.2)
297
*
298
* @uses is_user_logged_in()
299
* @uses bp_is_activity_component()
300
* @uses bp_is_current_action()
309
* @return bool False on failure
310
*/
311
function bp_activity_action_post_comment() {
312
313
+ if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'reply' ) )
314
return false;
315
316
// Check the nonce
342
/**
343
* Mark activity as favorite.
344
*
345
+ * @since BuddyPress (1.2)
346
*
347
* @uses is_user_logged_in()
348
* @uses bp_is_activity_component()
349
* @uses bp_is_current_action()
357
* @return bool False on failure
358
*/
359
function bp_activity_action_mark_favorite() {
360
361
+ if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'favorite' ) )
362
return false;
363
364
// Check the nonce
376
/**
377
* Remove activity from favorites.
378
*
379
+ * @since BuddyPress (1.2)
380
*
381
* @uses is_user_logged_in()
382
* @uses bp_is_activity_component()
383
* @uses bp_is_current_action()
391
* @return bool False on failure
392
*/
393
function bp_activity_action_remove_favorite() {
394
395
+ if ( ! is_user_logged_in() || ! bp_is_activity_component() || ! bp_is_current_action( 'unfavorite' ) )
396
return false;
397
398
// Check the nonce
410
/**
411
* Load the sitewide feed.
412
*
413
+ * @since BuddyPress (1.0)
414
*
415
* @global object $bp BuddyPress global settings
416
* @global object $wp_query
438
/**
439
* Load a user's personal feed.
440
*
441
+ * @since BuddyPress (1.0)
442
*
443
* @global object $wp_query
444
* @uses bp_is_user_activity()
445
* @uses bp_is_current_action()
448
* @return bool False on failure
449
*/
450
function bp_activity_action_personal_feed() {
451
+ global $wp_query;
452
453
if ( !bp_is_user_activity() || !bp_is_current_action( 'feed' ) )
454
return false;
464
/**
465
* Load a user's friends feed.
466
*
467
+ * @since BuddyPress (1.0)
468
*
469
* @global object $wp_query
470
* @uses bp_is_active()
471
* @uses bp_is_user_activity()
477
* @return bool False on failure
478
*/
479
function bp_activity_action_friends_feed() {
480
+ global $wp_query;
481
482
if ( !bp_is_active( 'friends' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_friends_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
483
return false;
493
/**
494
* Load a user's my groups feed.
495
*
496
+ * @since BuddyPress (1.2)
497
*
498
* @global object $wp_query
499
* @uses bp_is_active()
500
* @uses bp_is_user_activity()
506
* @return bool False on failure
507
*/
508
function bp_activity_action_my_groups_feed() {
509
+ global $wp_query;
510
511
if ( !bp_is_active( 'groups' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_groups_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
512
return false;
522
/**
523
* Load a user's @mentions feed.
524
*
525
+ * @since BuddyPress (1.2)
526
*
527
* @global object $wp_query
528
* @uses bp_is_user_activity()
529
* @uses bp_is_current_action()
533
* @return bool False on failure
534
*/
535
function bp_activity_action_mentions_feed() {
536
+ global $wp_query;
537
538
if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
539
return false;
549
/**
550
* Load a user's favorites feed.
551
*
552
+ * @since BuddyPress (1.2)
553
*
554
* @global object $wp_query
555
* @uses bp_is_user_activity()
556
* @uses bp_is_current_action()
560
* @return bool False on failure
561
*/
562
function bp_activity_action_favorites_feed() {
563
+ global $wp_query;
564
565
if ( !bp_is_user_activity() || !bp_is_current_action( 'favorites' ) || !bp_is_action_variable( 'feed', 0 ) )
566
return false;
573
}
574
add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
575
576
+ /**
577
+ * Loads Akismet
578
+ *
579
+ * @global object $bp BuddyPress global settings
580
+ * @since 1.6
581
+ */
582
+ function bp_activity_setup_akismet() {
583
+ global $bp;
584
+
585
+ // Bail if Akismet is not active
586
+ if ( ! defined( 'AKISMET_VERSION' ) )
587
+ return;
588
+
589
+ // Bail if no Akismet key is set
590
+ if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) )
591
+ return;
592
+
593
+ // Bail if BuddyPress Activity Akismet support has been disabled by another plugin
594
+ if ( ! apply_filters( 'bp_activity_use_akismet', true ) )
595
+ return;
596
+
597
+ // Instantiate Akismet for BuddyPress
598
+ $bp->activity->akismet = new BP_Akismet();
599
+ }
600
+
601
?>
bp-activity/bp-activity-admin.php ADDED
@@ -0,0 +1,1393 @@
1
+ <?php
2
+ /**
3
+ * BuddyPress Activity component admin screen
4
+ *
5
+ * Props to WordPress core for the Comments admin screen, and its contextual help text,
6
+ * on which this implementation is heavily based.
7
+ *
8
+ * @package BuddyPress
9
+ * @since 1.6
10
+ * @subpackage Activity
11
+ */
12
+
13
+ // Exit if accessed directly
14
+ if ( !defined( 'ABSPATH' ) ) exit;
15
+
16
+ // Include WP's list table class
17
+ if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
18
+
19
+ // per_page screen option. Has to be hooked in extremely early.
20
+ if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['page'] )
21
+ add_filter( 'set-screen-option', 'bp_activity_admin_screen_options', 10, 3 );
22
+
23
+ /**
24
+ * Registers the Activity component admin screen
25
+ *
26
+ * @since 1.6
27
+ */
28
+ function bp_activity_add_admin_menu() {
29
+
30
+ if ( ! bp_current_user_can( 'bp_moderate' ) )
31
+ return;
32
+
33
+ // Add our screen
34
+ $hook = add_menu_page( __( 'Activity', 'buddypress' ), __( 'Activity', 'buddypress' ), 'manage_options', 'bp-activity', 'bp_activity_admin' );
35
+
36
+ // Hook into early actions to load custom CSS and our init handler.
37
+ add_action( "load-$hook", 'bp_activity_admin_load' );
38
+ }
39
+ add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
40
+
41
+ /**
42
+ * AJAX receiver for Activity replies via the admin screen. Adds a new activity
43
+ * comment, and returns HTML for a new table row.
44
+ *
45
+ * @since 1.6
46
+ */
47
+ function bp_activity_admin_reply() {
48
+ // Check nonce
49
+ check_ajax_referer( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply' );
50
+
51
+ $parent_id = ! empty( $_REQUEST['parent_id'] ) ? (int) $_REQUEST['parent_id'] : 0;
52
+ $root_id = ! empty( $_REQUEST['root_id'] ) ? (int) $_REQUEST['root_id'] : 0;
53
+
54
+ // $parent_id is required
55
+ if ( empty( $parent_id ) )
56
+ die( '-1' );
57
+
58
+ // If $root_id not set (e.g. for root items), use $parent_id
59
+ if ( empty( $root_id ) )
60
+ $root_id = $parent_id;
61
+
62
+ // Check that a reply has been entered
63
+ if ( empty( $_REQUEST['content'] ) )
64
+ die( __( 'ERROR: Please type a reply.', 'buddypress' ) );
65
+
66
+ // Check parent activity exists
67
+ $parent_activity = new BP_Activity_Activity( $parent_id );
68
+ if ( empty( $parent_activity->component ) )
69
+ die( __( 'ERROR: The item you are trying to reply to cannot be found, or it has been deleted.', 'buddypress' ) );
70
+
71
+ // @todo: Check if user is allowed to create new activity items
72
+ // if ( ! current_user_can( 'bp_new_activity' ) )
73
+ if ( ! is_super_admin() )
74
+ die( '-1' );
75
+
76
+ // Add new activity comment
77
+ $new_activity_id = bp_activity_new_comment( array(
78
+ 'activity_id' => $root_id, // ID of the root activity item
79
+ 'content' => $_REQUEST['content'],
80
+ 'parent_id' => $parent_id, // ID of a parent comment
81
+ ) );
82
+
83
+ // Fetch the new activity item, as we need it to create table markup to return
84
+ $new_activity = new BP_Activity_Activity( $new_activity_id );
85
+
86
+ // This needs to be set for the BP_Activity_List_Table constructor to work
87
+ set_current_screen( 'toplevel_page_bp-activity' );
88
+
89
+ // Set up an output buffer
90
+ ob_start();
91
+ $list_table = new BP_Activity_List_Table();
92
+ $list_table->single_row( (array) $new_activity );
93
+
94
+ // Get table markup
95
+ $response = array(
96
+ 'data' => ob_get_contents(),
97
+ 'id' => $new_activity_id,
98
+ 'position' => -1,
99
+ 'what' => 'bp_activity',
100
+ );
101
+ ob_end_clean();
102
+
103
+ // Send response
104
+ $r = new WP_Ajax_Response();
105
+ $r->add( $response );
106
+ $r->send();
107
+
108
+ exit();
109
+ }
110
+ add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
111
+
112
+ /**
113
+ * Handle save/update of screen options for the Activity component admin screen
114
+ *
115
+ * @param string $value Will always be false unless another plugin filters it first.
116
+ * @param string $option Screen option name
117
+ * @param string $new_value Screen option form value
118
+ * @return string Option value. False to abandon update.
119
+ * @since 1.6
120
+ */
121
+ function bp_activity_admin_screen_options( $value, $option, $new_value ) {
122
+ if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option )
123
+ return $value;
124
+
125
+ // Per page
126
+ $new_value = (int) $new_value;
127
+ if ( $new_value < 1 || $new_value > 999 )
128
+ return $value;
129
+
130
+ return $new_value;
131
+ }
132
+
133
+ /**
134
+ * Hide the advanced edit meta boxes by default, so we don't clutter the scren.
135
+ *
136
+ * @param WP_Screen $screen Screen identifier
137
+ * @return array Hidden Meta Boxes
138
+ * @since 1.0
139
+ */
140
+ function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
141
+ if ( empty( $screen->id ) || 'toplevel_page_bp-activity' != $screen->id && 'toplevel_page_bp-activity_network' != $screen->id )
142
+ return $hidden;
143
+
144
+ // Hide the primary link meta box by default
145
+ $hidden = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) );
146
+
147
+ return apply_filters( 'bp_hide_meta_boxes', array_unique( $hidden ), $screen );
148
+ }
149
+ add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
150
+
151
+ /**
152
+ * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page.
153
+ *
154
+ * @global object $bp BuddyPress global settings
155
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
156
+ * @since 1.6
157
+ */
158
+ function bp_activity_admin_load() {
159
+ global $bp, $bp_activity_list_table;
160
+
161
+ // Decide whether to load the dev version of the CSS and JavaScript
162
+ $dev = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'dev.' : '';
163
+
164
+ // Decide whether to load the index or edit screen
165
+ $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
166
+
167
+ // Call an action for plugins to hook in early
168
+ do_action( 'bp_activity_admin_load', $doaction );
169
+
170
+ // Edit screen
171
+ if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) {
172
+ // columns screen option
173
+ add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) );
174
+
175
+ get_current_screen()->add_help_tab( array(
176
+ 'id' => 'bp-activity-edit-overview',
177
+ 'title' => __( 'Overview', 'buddypress' ),
178
+ 'content' =>
179
+ '<p>' . __( 'You edit activities made on your site similar to the way you edit a comment. This is useful if you need to change which page the activity links to, or when you notice that the author has made a typographical error.', 'buddypress' ) . '</p>' .
180
+ '<p>' . __( 'The two big editing areas for the activity title and content are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Primary Item/Secondary Item, Link, Type, Author ID) or to choose a 1- or 2-column layout for this screen.', 'buddypress' ) . '</p>' .
181
+ '<p>' . __( 'You can also moderate the activity from this screen using the Status box, where you can also change the timestamp of the activity.', 'buddypress' ) . '</p>'
182
+ ) );
183
+
184
+ get_current_screen()->add_help_tab( array(
185
+ 'id' => 'bp-activity-edit-advanced',
186
+ 'title' => __( 'Item, Link, Type', 'buddypress' ),
187
+ 'content' =>
188
+ '<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>' .
189
+ '<p>' . __( '<strong>Link</strong> - Activity generated by blog 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>' .
190
+ '<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>' .
191
+ '<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>'
192
+ ) );
193
+
194
+ // Help panel - sidebar links
195
+ get_current_screen()->set_help_sidebar(
196
+ '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
197
+ '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-activity/">Managing Activity</a>', 'buddypress' ) . '</p>' .
198
+ '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
199
+ );
200
+
201
+ // Register metaboxes for the edit screen.
202
+ add_meta_box( 'submitdiv', _x( 'Status', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_status', get_current_screen()->id, 'side', 'core' );
203
+ add_meta_box( 'bp_activity_itemids', _x( 'Primary Item/Secondary Item', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_itemids', get_current_screen()->id, 'normal', 'core' );
204
+ add_meta_box( 'bp_activity_link', _x( 'Link', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_link', get_current_screen()->id, 'normal', 'core' );
205
+ add_meta_box( 'bp_activity_type', _x( 'Type', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_type', get_current_screen()->id, 'normal', 'core' );
206
+ add_meta_box( 'bp_activity_userid', _x( 'Author ID', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_userid', get_current_screen()->id, 'normal', 'core' );
207
+
208
+ // Enqueue javascripts
209
+ wp_enqueue_script( 'postbox' );
210
+ wp_enqueue_script( 'dashboard' );
211
+ wp_enqueue_script( 'comment' );
212
+
213
+ // Index screen
214
+ } else {
215
+ // Create the Activity screen list table
216
+ $bp_activity_list_table = new BP_Activity_List_Table();
217
+
218
+ // per_page screen option
219
+ add_screen_option( 'per_page', array( 'label' => _x( 'Activity', 'Activity items per page (screen options)', 'buddypress' )) );
220
+
221
+ // Help panel - overview text
222
+ get_current_screen()->add_help_tab( array(
223
+ 'id' => 'bp-activity-overview',
224
+ 'title' => __( 'Overview', 'buddypress' ),
225
+ 'content' =>
226
+ '<p>' . __( 'You can manage activities made on your site similar to the way you manage comments and other content. This screen is customizable in the same ways as other management screens, and you can act on activities using the on-hover action links or the Bulk Actions.', 'buddypress' ) . '</p>' .
227
+ '<p>' . __( 'There are many different types of activities. Some are generated automatically by BuddyPress and other plugins, and some are entered directly by a user in the form of status update. To help manage the different activity types, use the filter dropdown box to switch between them.', 'buddypress' ) . '</p>'
228
+ ) );
229
+
230
+ // Help panel - moderation text
231
+ get_current_screen()->add_help_tab( array(
232
+ 'id' => 'bp-activity-moderating',
233
+ 'title' => __( 'Moderating Activity', 'buddypress' ),
234
+ 'content' =>
235
+ '<p>' . __( 'In the <strong>Activity</strong> column, above each activity it says &#8220;Submitted on,&#8221; followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity.', 'buddypress' ) . '</p>' .
236
+ '<p>' . __( "In the <strong>In Response To</strong> column, if the activity was in reply to another activity, it shows that activity's author's picture and name, and a link to that activity on your live site. If there is a small bubble, the number in it shows how many other activities are related to this one; these are usually comments. Clicking the bubble will filter the activity screen to show only related activity items.", 'buddypress' ) . '</p>'
237
+ ) );
238
+
239
+ // Help panel - sidebar links
240
+ get_current_screen()->set_help_sidebar(
241
+ '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
242
+ '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
243
+ );
244
+ }
245
+
246
+ // Enqueue CSS and JavaScript
247
+ wp_enqueue_script( 'bp_activity_admin_js', BP_PLUGIN_URL . "bp-activity/admin/js/admin.{$dev}js", array( 'jquery', 'wp-ajax-response' ), bp_get_version(), true );
248
+ wp_enqueue_style( 'bp_activity_admin_css', BP_PLUGIN_URL . "bp-activity/admin/css/admin.{$dev}css", array(), bp_get_version() );
249
+
250
+ // Handle spam/un-spam/delete of activities
251
+ if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
252
+
253
+ // Build redirection URL
254
+ $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() );
255
+ $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to );
256
+
257
+ // Get activity IDs
258
+ $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
259
+
260
+ // Call a filter for plugins to modify the requested activities to load
261
+ $activity_ids = apply_filters( 'bp_activity_admin_action_activity_ids', $activity_ids );
262
+
263
+ // Is this a bulk request?
264
+ if ( 'bulk_' == substr( $doaction, 0, 5 ) && ! empty( $_REQUEST['aid'] ) ) {
265
+ // Check this is a valid form submission
266
+ check_admin_referer( 'bulk-activities' );
267
+
268
+ // Trim 'bulk_' off the action name to avoid duplicating a ton of code
269
+ $doaction = substr( $doaction, 5 );
270
+
271
+ // This is a request to delete, spam, or un-spam, a single item.
272
+ } elseif ( !empty( $_REQUEST['aid'] ) ) {
273
+
274
+ // Check this is a valid form submission
275
+ check_admin_referer( 'spam-activity_' . $activity_ids[0] );
276
+ }
277
+
278
+ // Initialise counters for how many of each type of item we perform an action on
279
+ $deleted = $spammed = $unspammed = 0;
280
+
281
+ // Store any errors that occurs when updating the database items
282
+ $errors = array();
283
+
284
+ // "We'd like to shoot the monster, could you move, please?"
285
+ foreach ( $activity_ids as $activity_id ) {
286
+ // @todo: Check the permissions on each
287
+ //if ( ! current_user_can( 'bp_edit_activity', $activity_id ) )
288
+ // continue;
289
+
290
+ // Get the activity from the database
291
+ $activity = new BP_Activity_Activity( $activity_id );
292
+ if ( empty( $activity->component ) ) {
293
+ $errors[] = $activity_id;
294
+ continue;
295
+ }
296
+
297
+ switch ( $doaction ) {
298
+ case 'delete' :
299
+ if ( 'activity_comment' == $activity->type )
300
+ bp_activity_delete_comment( $activity->item_id, $activity->id );
301
+ else
302
+ bp_activity_delete( array( 'id' => $activity->id ) );
303
+
304
+ $deleted++;
305
+ break;
306
+
307
+ case 'ham' :
308
+ /**
309
+ * Remove moderation and blacklist checks in case we want to ham an activity
310
+ * which contains one of these listed keys.
311
+ */
312
+ remove_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 );
313
+ remove_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1 );
314
+
315
+ bp_activity_mark_as_ham( $activity );
316
+ $result = $activity->save();
317
+
318
+ // Check for any error during activity save
319
+ if ( ! $result )
320
+ $errors[] = $activity->id;
321
+ else
322
+ $unspammed++;
323
+ break;
324
+
325
+ case 'spam' :
326
+ bp_activity_mark_as_spam( $activity );
327
+ $result = $activity->save();
328
+
329
+ // Check for any error during activity save
330
+ if ( ! $result )
331
+ $errors[] = $activity->id;
332
+ else
333
+ $spammed++;
334
+ break;
335
+
336
+ default:
337
+ break;
338
+ }
339
+
340
+ // Release memory
341
+ unset( $activity );
342
+ }
343
+
344
+ // Call actions for plugins to do something before we redirect
345
+ do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids );
346
+
347
+ // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
348
+ if ( $spammed )
349
+ $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to );
350
+
351
+ if ( $unspammed )
352
+ $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to );
353
+
354
+ if ( $deleted )
355
+ $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
356
+
357
+ // If an error occurred, pass back the activity ID that failed
358
+ if ( ! empty( $errors ) )
359
+ $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to );
360
+
361
+ // Redirect
362
+ wp_redirect( apply_filters( 'bp_activity_admin_action_redirect', $redirect_to ) );
363
+ exit;
364
+
365
+
366
+ // Save the edit
367
+ } elseif ( $doaction && 'save' == $doaction ) {
368
+ // Build redirection URL
369
+ $redirect_to = remove_query_arg( array( 'action', 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
370
+
371
+ // Get activity ID
372
+ $activity_id = (int) $_REQUEST['aid'];
373
+
374
+ // Check this is a valid form submission
375
+ check_admin_referer( 'edit-activity_' . $activity_id );
376
+
377
+ // Get the activity from the database
378
+ $activity = new BP_Activity_Activity( $activity_id );
379
+
380
+ // If the activity doesn't exist, just redirect back to the index
381
+ if ( empty( $activity->component ) ) {
382
+ wp_redirect( $redirect_to );
383
+ exit;
384
+ }
385
+
386
+ // Check the form for the updated properties
387
+
388
+ // Store any error that occurs when updating the database item
389
+ $error = 0;
390
+
391
+ // Activity spam status
392
+ $prev_spam_status = $new_spam_status = false;
393
+ if ( ! empty( $_POST['activity_status'] ) ) {
394
+ $prev_spam_status = $activity->is_spam;
395
+ $new_spam_status = ( 'spam' == $_POST['activity_status'] ) ? true : false;
396
+ }
397
+
398
+ // Activity action
399
+ if ( isset( $_POST['bp-activities-action'] ) )
400
+ $activity->action = $_POST['bp-activities-action'];
401
+
402
+ // Activity content
403
+ if ( isset( $_POST['bp-activities-content'] ) )
404
+ $activity->content = $_POST['bp-activities-content'];
405
+
406
+ // Activity primary link
407
+ if ( ! empty( $_POST['bp-activities-link'] ) )
408
+ $activity->primary_link = $_POST['bp-activities-link'];
409
+
410
+ // Activity user ID
411
+ if ( ! empty( $_POST['bp-activities-userid'] ) )
412
+ $activity->user_id = (int) $_POST['bp-activities-userid'];
413
+
414
+ // Activity item primary ID
415
+ if ( isset( $_POST['bp-activities-primaryid'] ) )
416
+ $activity->item_id = (int) $_POST['bp-activities-primaryid'];
417
+
418
+ // Activity item secondary ID
419
+ if ( isset( $_POST['bp-activities-secondaryid'] ) )
420
+ $activity->secondary_item_id = (int) $_POST['bp-activities-secondaryid'];
421
+
422
+ // Activity type
423
+ if ( ! empty( $_POST['bp-activities-type'] ) ) {
424
+ $actions = array();
425
+
426
+ // Walk through the registered actions, and build an array of actions/values.
427
+ foreach ( $bp->activity->actions as $action ) {
428
+ $action = array_values( (array) $action );
429
+
430
+ for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
431
+ $actions[] = $action[$i]['key'];
432
+ }
433
+
434
+ // This was a mis-named activity type from before BP 1.6
435
+ unset( $actions['friends_register_activity_action'] );
436
+
437
+ // Check that the new type is a registered activity type
438
+ if ( in_array( $_POST['bp-activities-type'], $actions ) )
439
+ $activity->type = $_POST['bp-activities-type'];
440
+ }
441
+
442
+ // Activity timestamp
443
+ if ( ! empty( $_POST['aa'] ) && ! empty( $_POST['mm'] ) && ! empty( $_POST['jj'] ) && ! empty( $_POST['hh'] ) && ! empty( $_POST['mn'] ) && ! empty( $_POST['ss'] ) ) {
444
+ $aa = $_POST['aa'];
445
+ $mm = $_POST['mm'];
446
+ $jj = $_POST['jj'];
447
+ $hh = $_POST['hh'];
448
+ $mn = $_POST['mn'];
449
+ $ss = $_POST['ss'];
450
+ $aa = ( $aa <= 0 ) ? date( 'Y' ) : $aa;
451
+ $mm = ( $mm <= 0 ) ? date( 'n' ) : $mm;
452
+ $jj = ( $jj > 31 ) ? 31 : $jj;
453
+ $jj = ( $jj <= 0 ) ? date( 'j' ) : $jj;
454
+ $hh = ( $hh > 23 ) ? $hh -24 : $hh;
455
+ $mn = ( $mn > 59 ) ? $mn -60 : $mn;
456
+ $ss = ( $ss > 59 ) ? $ss -60 : $ss;
457
+
458
+ // Reconstruct the date into a timestamp
459
+ $gmt_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
460
+
461
+ $activity->date_recorded = $gmt_date;
462
+ }
463
+
464
+ // Has the spam status has changed?
465
+ if ( $new_spam_status != $prev_spam_status ) {
466
+ if ( $new_spam_status )
467
+ bp_activity_mark_as_spam( $activity );
468
+ else
469
+ bp_activity_mark_as_ham( $activity );
470
+ }
471
+
472
+ // Save
473
+ $result = $activity->save();
474
+
475
+ // Clear the activity stream first page cache, in case this activity's timestamp was changed
476
+ wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
477
+
478
+ // Check for any error during activity save
479
+ if ( false === $result )
480
+ $error = $activity->id;
481
+
482
+ // Call actions for plugins to do something before we redirect
483
+ do_action_ref_array( 'bp_activity_admin_edit_after', array( &$activity, $error ) );
484
+
485
+ // If an error occurred, pass back the activity ID that failed
486
+ if ( $error )
487
+ $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
488
+ else
489
+ $redirect_to = add_query_arg( 'updated', (int) $activity->id, $redirect_to );
490
+
491
+ // Redirect
492
+ wp_redirect( apply_filters( 'bp_activity_admin_edit_redirect', $redirect_to ) );
493
+ exit;
494
+
495
+
496
+ // If a referrer and a nonce is supplied, but no action, redirect back.
497
+ } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
498
+ wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
499
+ exit;
500
+ }
501
+ }
502
+
503
+ /**
504
+ * Outputs the Activity component admin screens
505
+ *
506
+ * @since 1.6
507
+ */
508
+ function bp_activity_admin() {
509
+ // Decide whether to load the index or edit screen
510
+ $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
511
+
512
+ // Display the single activity edit screen
513
+ if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) )
514
+ bp_activity_admin_edit();
515
+
516
+ // Otherwise, display the Activity index screen
517
+ else
518
+ bp_activity_admin_index();
519
+ }
520
+
521
+ /**
522
+ * Display the single activity edit screen
523
+ *
524
+ * @global int $screen_layout_columns Number of columns shown on this admin page
525
+ * @since 1.6
526
+ */
527
+ function bp_activity_admin_edit() {
528
+ global $screen_layout_columns;
529
+
530
+ // @todo: Check if user is allowed to edit activity items
531
+ // if ( ! current_user_can( 'bp_edit_activity' ) )
532
+ if ( ! is_super_admin() )
533
+ die( '-1' );
534
+
535
+ // Get the activity from the database
536
+ $activity = bp_activity_get( array(
537
+ 'in' => ! empty( $_REQUEST['aid'] ) ? (int) $_REQUEST['aid'] : 0,
538
+ 'max' => 1,
539
+ 'show_hidden' => true,
540
+ 'spam' => 'all',
541
+ 'display_comments' => 0
542
+ ) );
543
+
544
+ if ( ! empty( $activity['activities'][0] ) ) {
545
+ $activity = $activity['activities'][0];
546
+
547
+ // Workaround to use WP's touch_time() without duplicating that function
548
+ $GLOBALS['comment'] = new stdClass;
549
+ $GLOBALS['comment']->comment_date = $activity->date_recorded;
550
+ } else {
551
+ $activity = '';
552
+ }
553
+
554
+ // Construct URL for form
555
+ $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
556
+ $form_url = add_query_arg( 'action', 'save', $form_url );
557
+
558
+ // Call an action for plugins to modify the activity before we display the edit form
559
+ do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) );
560
+ ?>
561
+
562
+ <div class="wrap">
563
+ <?php screen_icon( 'buddypress-activity' ); ?>
564
+ <h2><?php printf( __( 'Editing Activity (ID #%s)', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?></h2>
565
+
566
+ <?php if ( ! empty( $activity ) ) : ?>
567
+
568
+ <form action="<?php echo esc_attr( $form_url ); ?>" id="bp-activities-edit-form" method="post">
569
+ <div id="poststuff">
570
+
571
+ <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
572
+ <div id="post-body-content">
573
+ <div id="postdiv" class="postarea">
574
+ <div id="bp_activity_action" class="postbox">
575
+ <h3><?php _e( 'Action', 'buddypress' ); ?></h3>
576
+ <div class="inside">
577
+ <?php wp_editor( stripslashes( $activity->action ), 'bp-activities-action', array( 'media_buttons' => false, 'textarea_rows' => 7, 'teeny' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?>
578
+ </div>
579
+ </div>
580
+
581
+ <div id="bp_activity_content" class="postbox">
582
+ <h3><?php _e( 'Content', 'buddypress' ); ?></h3>
583
+ <div class="inside">
584
+ <?php wp_editor( stripslashes( $activity->content ), 'bp-activities-content', array( 'media_buttons' => false, 'teeny' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?>
585
+ </div>
586
+ </div>
587
+ </div>
588
+ </div><!-- #post-body-content -->
589
+
590
+ <div id="postbox-container-1" class="postbox-container">
591
+ <?php do_meta_boxes( get_current_screen()->id, 'side', $activity ); ?>
592
+ </div>
593
+
594
+ <div id="postbox-container-2" class="postbox-container">
595
+ <?php do_meta_boxes( get_current_screen()->id, 'normal', $activity ); ?>
596
+ <?php do_meta_boxes( get_current_screen()->id, 'advanced', $activity ); ?>
597
+ </div>
598
+ </div><!-- #post-body -->
599
+
600
+ </div><!-- #poststuff -->
601
+ <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
602
+ <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
603
+ <?php wp_nonce_field( 'edit-activity_' . $activity->id ); ?>
604
+ </form>
605
+
606
+ <?php else : ?>
607
+ <p><?php printf( __( 'No activity found with this ID. <a href="%s">Go back and try again</a>.', 'buddypress' ), network_admin_url( 'admin.php?page=bp-activity' ) ); ?></p>
608
+ <?php endif; ?>
609
+
610
+ </div><!-- .wrap -->
611
+
612
+ <?php
613
+ }
614
+
615
+ /**
616
+ * Status metabox for the Activity admin edit screen
617
+ *
618
+ * @param object $item Activity item
619
+ * @since 1.6
620
+ */
621
+ function bp_activity_admin_edit_metabox_status( $item ) {
622
+ ?>
623
+
624
+ <div class="submitbox" id="submitcomment">
625
+
626
+ <div id="minor-publishing">
627
+ <div id="minor-publishing-actions">
628
+ <div id="preview-action">
629
+ <a class="button preview" href="<?php echo esc_attr( bp_activity_get_permalink( $item->id, $item ) ); ?>" target="_blank"><?php _e( 'View Activity', 'buddypress' ); ?></a>
630
+ </div>
631
+
632
+ <div class="clear"></div>
633
+ </div><!-- #minor-publishing-actions -->
634
+
635
+ <div id="misc-publishing-actions">
636
+ <div class="misc-pub-section" id="comment-status-radio">
637
+ <label class="approved"><input type="radio" name="activity_status" value="ham" <?php checked( $item->is_spam, 0 ); ?>><?php _e( 'Approved', 'buddypress' ); ?></label><br />
638
+ <label class="spam"><input type="radio" name="activity_status" value="spam" <?php checked( $item->is_spam, 1 ); ?>><?php _e( 'Spam', 'buddypress' ); ?></label>
639
+ </div>
640
+
641
+ <div class="misc-pub-section curtime misc-pub-section-last">
642
+ <?php
643
+ // translators: Publish box date format, see http://php.net/date
644
+ $datef = __( 'M j, Y @ G:i', 'buddypress' );
645
+ $date = date_i18n( $datef, strtotime( $item->date_recorded ) );
646
+ ?>
647
+ <span id="timestamp"><?php printf( __( 'Submitted on: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></span>&nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e( 'Edit', 'buddypress' ); ?></a>
648
+
649
+ <div id='timestampdiv' class='hide-if-js'>
650
+ <?php touch_time( 1, 0, 5 ); ?>
651
+ </div><!-- #timestampdiv -->
652
+ </div>
653
+ </div> <!-- #misc-publishing-actions -->
654
+
655
+ <div class="clear"></div>
656
+ </div><!-- #minor-publishing -->
657
+
658
+ <div id="major-publishing-actions">
659
+ <div id="publishing-action">
660
+ <?php submit_button( __( 'Update', 'buddypress' ), 'primary', 'save', false, array( 'tabindex' => '4' ) ); ?>
661
+ </div>
662
+ <div class="clear"></div>
663
+ </div><!-- #major-publishing-actions -->
664
+
665
+ </div><!-- #submitcomment -->
666
+
667
+ <?php
668
+ }
669
+
670
+ /**
671
+ * Primary link metabox for the Activity admin edit screen
672
+ *
673
+ * @param object $item Activity item
674
+ * @since 1.6
675
+ */
676
+ function bp_activity_admin_edit_metabox_link( $item ) {
677
+ ?>
678
+
679
+ <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label>
680
+ <input type="url" name="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" />
681
+ <p><?php _e( 'Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
682
+
683
+ <?php
684
+ }
685
+
686
+ /**
687
+ * User ID metabox for the Activity admin edit screen
688
+ *
689
+ * @param object $item Activity item
690
+ * @since 1.6
691
+ */
692
+ function bp_activity_admin_edit_metabox_userid( $item ) {
693
+ ?>
694
+
695
+ <label class="screen-reader-text" for="bp-activities-userid"><?php _e( 'Author ID', 'buddypress' ); ?></label>
696
+ <input type="number" name="bp-activities-userid" value="<?php echo esc_attr( $item->user_id ); ?>" min="1" />
697
+
698
+ <?php
699
+ }
700
+
701
+ /**
702
+ * Activity type metabox for the Activity admin edit screen
703
+ *
704
+ * @global object $bp BuddyPress global settings
705
+ * @param object $item Activity item
706
+ * @since 1.6
707
+ */
708
+ function bp_activity_admin_edit_metabox_type( $item ) {
709
+ global $bp;
710
+
711
+ $actions = array();
712
+ $selected = $item->type;
713
+
714
+ // Walk through the registered actions, and build an array of actions/values.
715
+ foreach ( $bp->activity->actions as $action ) {
716
+ $action = array_values( (array) $action );
717
+
718
+ for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
719
+ $actions[ $action[$i]['key'] ] = $action[$i]['value'];
720
+ }
721
+
722
+ // This was a mis-named activity type from before BP 1.6
723
+ unset( $actions['friends_register_activity_action'] );
724
+
725
+ // Sort array by the human-readable value
726
+ natsort( $actions );
727
+ ?>
728
+
729
+ <select name="bp-activities-type">
730
+ <?php foreach ( $actions as $k => $v ) : ?>
731
+ <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option>
732
+ <?php endforeach; ?>
733
+ </select>
734
+
735
+ <?php
736
+ }
737
+
738
+ /**
739
+ * Primary item ID/Secondary item ID metabox for the Activity admin edit screen
740
+ *
741
+ * @param object $item Activity item
742
+ * @since 1.6
743
+ */
744
+ function bp_activity_admin_edit_metabox_itemids( $item ) {
745
+ ?>
746
+
747
+ <label for="bp-activities-primaryid"><?php _e( 'Primary Item ID', 'buddypress' ); ?></label>
748
+ <input type="number" name="bp-activities-primaryid" id="bp-activities-primaryid" value="<?php echo esc_attr( $item->item_id ); ?>" min="0" />
749
+ <br />
750
+
751
+ <label for="bp-activities-secondaryid"><?php _e( 'Secondary Item ID', 'buddypress' ); ?></label>
752
+ <input type="number" name="bp-activities-secondaryid" id="bp-activities-secondaryid" value="<?php echo esc_attr( $item->secondary_item_id ); ?>" min="0" />
753
+
754
+ <p><?php _e( 'These identify the object that created this activity. For example, the fields could reference a pair of site and comment IDs.', 'buddypress' ); ?></p>
755
+
756
+ <?php
757
+ }
758
+
759
+ /**
760
+ * Display the Activity admin index screen, which contains a list of all the activities.
761
+ *
762
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
763
+ * @global string $plugin_page
764
+ * @since 1.6
765
+ */
766
+ function bp_activity_admin_index() {
767
+ global $bp_activity_list_table, $plugin_page;
768
+
769
+ $messages = array();
770
+
771
+ // If the user has just made a change to an activity item, build status messages
772
+ if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) {
773
+ $deleted = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
774
+ $errors = ! empty( $_REQUEST['error'] ) ? $_REQUEST['error'] : '';
775
+ $spammed = ! empty( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0;
776
+ $unspammed = ! empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
777
+ $updated = ! empty( $_REQUEST['updated'] ) ? (int) $_REQUEST['updated'] : 0;
778
+
779
+ $errors = array_map( 'absint', explode( ',', $errors ) );
780
+
781
+ // Make sure we don't get any empty values in $errors
782
+ for ( $i = 0, $errors_count = count( $errors ); $i < $errors_count; $i++ ) {
783
+ if ( 0 === $errors[$i] )
784
+ unset( $errors[$i] );
785
+ }
786
+
787
+ // Reindex array
788
+ $errors = array_values( $errors );
789
+
790
+ if ( $deleted > 0 )
791
+ $messages[] = sprintf( _n( '%s activity has been permanently deleted.', '%s activity items have been permanently deleted.', $deleted, 'buddypress' ), number_format_i18n( $deleted ) );
792
+
793
+ if ( ! empty( $errors ) ) {
794
+ if ( 1 == count( $errors ) ) {
795
+ $messages[] = sprintf( __( 'An error occurred when trying to update activity ID #%s.', 'buddypress' ), number_format_i18n( $errors[0] ) );
796
+
797
+ } else {
798
+ $error_msg = __( 'Errors occurred when trying to update these activity items:', 'buddypress' );
799
+ $error_msg .= '<ul class="activity-errors">';
800
+
801
+ // Display each error as a list item
802
+ foreach ( $errors as $error ) {
803
+ // Translators: This is a bulleted list of item IDs
804
+ $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>';
805
+ }
806
+
807
+ $error_msg .= '</ul>';
808
+ $messages[] = $error_msg;
809
+ }
810
+ }
811
+
812
+ if ( $spammed > 0 )
813
+ $messages[] = sprintf( _n( '%s activity has been successfully spammed.', '%s activity items have been successfully spammed.', $spammed, 'buddypress' ), number_format_i18n( $spammed ) );
814
+
815
+ if ( $unspammed > 0 )
816
+ $messages[] = sprintf( _n( '%s activity has been successfully unspammed.', '%s activity items have been successfully unspammed.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) );
817
+
818
+ if ( $updated > 0 )
819
+ $messages[] = __( 'The activity has been updated succesfully.', 'buddypress' );
820
+ }
821
+
822
+ // Prepare the activity items for display
823
+ $bp_activity_list_table->prepare_items();
824
+
825
+ // Call an action for plugins to modify the activity before we display the edit form
826
+ do_action( 'bp_activity_admin_index', $messages );
827
+ ?>
828
+
829
+ <div class="wrap">
830
+