BuddyPress - Version 1.5.7

Version Description

  • Security upgrade
Download this release

Release Info

Developer DJPaul
Plugin Icon 128x128 BuddyPress
Version 1.5.7
Comparing to
See all releases

Code changes from version 1.6-RC1 to 1.5.7

Files changed (243) hide show
  1. bp-activity/admin/css/admin.css +0 -1
  2. bp-activity/admin/css/admin.dev.css +0 -77
  3. bp-activity/admin/js/admin.dev.js +0 -167
  4. bp-activity/admin/js/admin.js +0 -1
  5. bp-activity/bp-activity-actions.php +38 -109
  6. bp-activity/bp-activity-admin.php +0 -1393
  7. bp-activity/bp-activity-akismet.php +0 -587
  8. bp-activity/bp-activity-cache.php +0 -39
  9. bp-activity/bp-activity-classes.php +45 -157
  10. bp-activity/bp-activity-filters.php +17 -89
  11. bp-activity/bp-activity-functions.php +155 -388
  12. bp-activity/bp-activity-loader.php +28 -51
  13. bp-activity/bp-activity-notifications.php +6 -15
  14. bp-activity/bp-activity-screens.php +30 -28
  15. bp-activity/bp-activity-template.php +288 -335
  16. bp-activity/feeds/bp-activity-favorites-feed.php +4 -5
  17. bp-activity/feeds/bp-activity-friends-feed.php +0 -1
  18. bp-activity/feeds/bp-activity-group-feed.php +1 -2
  19. bp-activity/feeds/bp-activity-mentions-feed.php +4 -6
  20. bp-activity/feeds/bp-activity-mygroups-feed.php +3 -5
  21. bp-activity/feeds/bp-activity-personal-feed.php +3 -4
  22. bp-activity/feeds/bp-activity-sitewide-feed.php +1 -2
  23. bp-blogs/bp-blogs-actions.php +4 -26
  24. bp-blogs/bp-blogs-activity.php +29 -64
  25. bp-blogs/bp-blogs-buddybar.php +8 -26
  26. bp-blogs/bp-blogs-cache.php +4 -25
  27. bp-blogs/bp-blogs-classes.php +26 -34
  28. bp-blogs/bp-blogs-filters.php +0 -26
  29. bp-blogs/bp-blogs-functions.php +55 -156
  30. bp-blogs/bp-blogs-loader.php +17 -36
  31. bp-blogs/bp-blogs-screens.php +1 -9
  32. bp-blogs/bp-blogs-template.php +48 -48
  33. bp-blogs/bp-blogs-widgets.php +12 -11
  34. bp-core/admin/bp-core-admin.php +637 -0
  35. bp-core/admin/bp-core-components.php +0 -300
  36. bp-core/admin/bp-core-functions.php +0 -399
  37. bp-core/admin/bp-core-schema.php +32 -116
  38. bp-core/admin/bp-core-settings.php +0 -368
  39. bp-core/admin/bp-core-slugs.php +0 -224
  40. bp-core/admin/bp-core-update.php +590 -287
  41. bp-core/admin/css/common.css +0 -1
  42. bp-core/admin/css/common.dev.css +0 -143
  43. bp-core/admin/css/wizard.css +0 -1
  44. bp-core/admin/images/icons32.png +0 -0
  45. bp-core/admin/images/menu-wp.png +0 -0
  46. bp-core/admin/images/menu.png +0 -0
  47. bp-core/bp-core-actions.php +0 -267
  48. bp-core/bp-core-admin.php +0 -511
  49. bp-core/bp-core-adminbar.php +225 -35
  50. bp-core/bp-core-avatars.php +121 -230
  51. bp-core/bp-core-buddybar.php +104 -169
  52. bp-core/bp-core-cache.php +3 -88
  53. bp-core/bp-core-caps.php +0 -426
  54. bp-core/bp-core-catchuri.php +90 -326
  55. bp-core/bp-core-classes.php +138 -172
  56. bp-core/bp-core-component.php +26 -57
  57. bp-core/bp-core-cssjs.php +36 -3
  58. bp-core/bp-core-filters.php +51 -72
  59. bp-core/bp-core-functions.php +555 -253
  60. bp-core/bp-core-hooks.php +114 -0
  61. bp-core/bp-core-loader.php +68 -81
  62. bp-core/bp-core-moderation.php +0 -268
  63. bp-core/bp-core-options.php +0 -524
  64. bp-core/bp-core-template.php +72 -106
  65. bp-core/bp-core-update.php +0 -197
  66. bp-core/bp-core-widgets.php +29 -23
  67. bp-core/bp-core-wpabstraction.php +6 -5
  68. bp-core/css/admin-bar-rtl.css +1 -1
  69. bp-core/css/admin-bar.css +1 -1
  70. bp-core/css/admin-bar.dev.css +29 -25
  71. bp-core/css/admin.css +1 -0
  72. bp-core/{admin/css/wizard.dev.css → css/admin.dev.css} +41 -56
  73. bp-core/css/buddybar-rtl.css +1 -1
  74. bp-core/css/buddybar.css +1 -1
  75. bp-core/css/buddybar.dev.css +4 -2
  76. bp-core/deprecated/1.5.php +5 -134
  77. bp-core/deprecated/1.6.php +0 -264
  78. bp-core/images/admin-bar-sprite-rtl.png +0 -0
  79. bp-core/images/admin-bar-sprite.png +0 -0
  80. bp-core/images/admin_menu_icon.png +0 -0
  81. bp-core/{admin/images → images}/completed.gif +0 -0
  82. bp-core/{admin/images → images}/find.png +0 -0
  83. bp-core/images/icons32.png +0 -0
  84. bp-core/{admin/images → images}/installed.gif +0 -0
  85. bp-core/images/logo-column-header.png +0 -0
  86. bp-core/images/logo.png +0 -0
  87. bp-core/{admin/js/wizard.dev.js → js/update.dev.js} +0 -0
  88. bp-core/{admin/js/wizard.js → js/update.js} +0 -0
  89. bp-forums/bp-forums-admin.php +25 -80
  90. bp-forums/bp-forums-bbpress-sa.php +9 -5
  91. bp-forums/bp-forums-filters.php +3 -3
  92. bp-forums/bp-forums-functions.php +29 -102
  93. bp-forums/bp-forums-loader.php +23 -25
  94. bp-forums/bp-forums-screens.php +2 -2
  95. bp-forums/bp-forums-template.php +59 -63
  96. bp-forums/deprecated/1.6.php +0 -203
  97. bp-friends/bp-friends-actions.php +1 -7
  98. bp-friends/bp-friends-activity.php +16 -26
  99. bp-friends/bp-friends-cache.php +4 -9
  100. bp-friends/bp-friends-classes.php +50 -53
  101. bp-friends/bp-friends-functions.php +23 -40
  102. bp-friends/bp-friends-loader.php +18 -25
  103. bp-friends/bp-friends-notifications.php +16 -20
  104. bp-friends/bp-friends-screens.php +9 -24
  105. bp-friends/bp-friends-template.php +95 -80
  106. bp-groups/bp-groups-actions.php +34 -41
  107. bp-groups/bp-groups-activity.php +39 -48
  108. bp-groups/bp-groups-adminbar.php +57 -27
  109. bp-groups/bp-groups-buddybar.php +4 -19
  110. bp-groups/bp-groups-cache.php +3 -58
  111. bp-groups/bp-groups-classes.php +154 -259
  112. bp-groups/bp-groups-filters.php +14 -27
  113. bp-groups/bp-groups-forums.php +42 -159
  114. bp-groups/bp-groups-functions.php +84 -125
  115. bp-groups/bp-groups-loader.php +55 -174
  116. bp-groups/bp-groups-notifications.php +16 -21
  117. bp-groups/bp-groups-screens.php +59 -73
  118. bp-groups/bp-groups-template.php +268 -307
  119. bp-groups/bp-groups-widgets.php +14 -30
  120. bp-languages/buddypress.pot +1445 -2017
  121. bp-loader.php +91 -438
  122. bp-members/bp-members-actions.php +19 -24
  123. bp-members/bp-members-adminbar.php +163 -60
  124. bp-members/bp-members-buddybar.php +20 -37
  125. bp-members/bp-members-filters.php +10 -5
  126. bp-members/bp-members-functions.php +102 -610
  127. bp-members/bp-members-loader.php +32 -51
  128. bp-members/bp-members-notifications.php +29 -151
  129. bp-members/bp-members-screens.php +1 -216
  130. bp-members/bp-members-signup.php +630 -0
  131. bp-members/bp-members-template.php +115 -126
  132. bp-messages/bp-messages-actions.php +10 -17
  133. bp-messages/bp-messages-cache.php +2 -8
  134. bp-messages/bp-messages-classes.php +52 -132
  135. bp-messages/bp-messages-cssjs.php +17 -29
  136. bp-messages/bp-messages-filters.php +39 -46
  137. bp-messages/bp-messages-functions.php +30 -27
  138. bp-messages/bp-messages-loader.php +25 -39
  139. bp-messages/bp-messages-notifications.php +33 -49
  140. bp-messages/bp-messages-screens.php +16 -15
  141. bp-messages/bp-messages-template.php +101 -167
  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 +40 -131
  148. bp-settings/bp-settings-functions.php +0 -9
  149. bp-settings/bp-settings-loader.php +25 -48
  150. bp-settings/bp-settings-screens.php +1 -80
  151. bp-settings/bp-settings-template.php +9 -10
  152. bp-themes/bp-default/404.php +3 -3
  153. bp-themes/bp-default/_inc/ajax.php +277 -456
  154. bp-themes/bp-default/_inc/css/default-rtl.css +14 -11
  155. bp-themes/bp-default/_inc/css/default.css +19 -83
  156. bp-themes/bp-default/_inc/css/responsive.css +0 -83
  157. bp-themes/bp-default/_inc/global.js +131 -306
  158. bp-themes/bp-default/_inc/images/rss.png +0 -0
  159. bp-themes/bp-default/activity/comment.php +2 -4
  160. bp-themes/bp-default/activity/entry.php +2 -2
  161. bp-themes/bp-default/activity/index.php +8 -6
  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 +4 -6
  166. bp-themes/bp-default/blogs/index.php +5 -3
  167. bp-themes/bp-default/comments.php +13 -13
  168. bp-themes/bp-default/footer.php +7 -8
  169. bp-themes/bp-default/forums/index.php +4 -4
  170. bp-themes/bp-default/functions.php +86 -80
  171. bp-themes/bp-default/groups/create.php +34 -31
  172. bp-themes/bp-default/groups/index.php +4 -2
  173. bp-themes/bp-default/groups/single/activity.php +14 -14
  174. bp-themes/bp-default/groups/single/admin.php +66 -68
  175. bp-themes/bp-default/groups/single/forum.php +14 -14
  176. bp-themes/bp-default/groups/single/forum/edit.php +25 -21
  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 +20 -15
  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 +3 -1
  187. bp-themes/bp-default/members/single/activity.php +10 -10
  188. bp-themes/bp-default/members/single/activity/permalink.php +3 -5
  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 +3 -1
  195. bp-themes/bp-default/members/single/member-header.php +1 -1
  196. bp-themes/bp-default/members/single/messages.php +0 -7
  197. bp-themes/bp-default/members/single/messages/compose.php +14 -14
  198. bp-themes/bp-default/members/single/messages/messages-loop.php +22 -23
  199. bp-themes/bp-default/members/single/messages/notices-loop.php +18 -23
  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 +7 -27
  203. bp-themes/bp-default/members/single/profile/profile-wp.php +5 -5
  204. bp-themes/bp-default/members/single/settings/capabilities.php +0 -81
  205. bp-themes/bp-default/members/single/settings/delete-account.php +9 -23
  206. bp-themes/bp-default/members/single/settings/general.php +5 -4
  207. bp-themes/bp-default/members/single/settings/notifications.php +5 -4
  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 +84 -106
  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 +37 -44
  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 +64 -46
  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 +107 -98
  227. bp-xprofile/admin/js/admin.js +1 -1
  228. bp-xprofile/bp-xprofile-actions.php +8 -12
  229. bp-xprofile/bp-xprofile-activity.php +24 -26
  230. bp-xprofile/bp-xprofile-admin.php +183 -176
  231. bp-xprofile/bp-xprofile-buddybar.php +0 -2
  232. bp-xprofile/bp-xprofile-cache.php +7 -10
  233. bp-xprofile/bp-xprofile-caps.php +0 -61
  234. bp-xprofile/bp-xprofile-classes.php +237 -402
  235. bp-xprofile/bp-xprofile-cssjs.php +15 -36
  236. bp-xprofile/bp-xprofile-filters.php +60 -62
  237. bp-xprofile/bp-xprofile-functions.php +44 -186
  238. bp-xprofile/bp-xprofile-loader.php +18 -61
  239. bp-xprofile/bp-xprofile-screens.php +13 -28
  240. bp-xprofile/bp-xprofile-template.php +69 -164
  241. humans.txt +1 -1
  242. license.txt +280 -280
  243. readme.txt +131 -104
bp-activity/admin/css/admin.css DELETED
@@ -1 +0,0 @@
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 DELETED
@@ -1,77 +0,0 @@
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 DELETED
@@ -1,167 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
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 BuddyPress (1.2)
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 BuddyPress (1.2)
31
*
32
* @global object $bp BuddyPress global settings
33
* @uses bp_is_activity_component()
@@ -88,14 +88,7 @@ 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
- // 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,10 +103,11 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
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,6 +122,7 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
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,65 +164,12 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
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,6 +187,7 @@ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
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,7 +213,7 @@ function bp_activity_action_post_update() {
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,8 +236,9 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
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,8 +253,9 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
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,8 +287,9 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
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,8 +303,9 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
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,8 +323,9 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
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,8 +339,9 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
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,7 +359,7 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
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,8 +387,9 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
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,7 +398,7 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
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,8 +414,9 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
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,7 +428,7 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
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,8 +444,9 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
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,7 +458,7 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
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,8 +474,9 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
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,7 +486,7 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
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,8 +502,9 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
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,7 +514,7 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
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,29 +527,4 @@ function bp_activity_action_favorites_feed() {
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
?>
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
/**
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
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
/**
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
* @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
}
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
* @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
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
/**
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
* @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
/**
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
* @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
/**
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
* @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
/**
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
/**
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
* @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
/**
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
* @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
/**
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
* @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
/**
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
* @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
/**
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
* @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
}
528
add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
529
530
?>
bp-activity/bp-activity-admin.php DELETED
@@ -1,1393 +0,0 @@
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
- <?php screen_icon( 'buddypress-activity' ); ?>
831
- <h2>
832
- <?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
833
- <?php printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
834
- <?php else : ?>
835
- <?php _e( 'Activity', 'buddypress' ); ?>
836
- <?php endif; ?>
837
-
838
- <?php if ( !empty( $_REQUEST['s'] ) ) : ?>
839
- <span class="subtitle"><?php printf( __( 'Search results for &#8220;%s&#8221;', 'buddypress' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ); ?></span>
840
- <?php endif; ?>
841
- </h2>
842
-
843
- <?php // If the user has just made a change to an activity item, display the status messages ?>
844
- <?php if ( !empty( $messages ) ) : ?>
845
- <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
846
- <?php endif; ?>
847
-
848
- <?php // Display each activity on its own row ?>
849
- <?php $bp_activity_list_table->views(); ?>
850
-
851
- <form id="bp-activities-form" action="" method="get">
852
- <?php $bp_activity_list_table->search_box( __( 'Search all Activity', 'buddypress' ), 'bp-activity' ); ?>
853
- <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" />
854
- <?php $bp_activity_list_table->display(); ?>
855
- </form>
856
-
857
- <?php // This markup is used for the reply form ?>
858
- <table style="display: none;">
859
- <tr id="bp-activities-container" style="display: none;">
860
- <td colspan="4">
861
- <form method="get" action="">
862
-
863
- <h5 id="bp-replyhead"><?php _e( 'Reply to Activity', 'buddypress' ); ?></h5>
864
- <?php wp_editor( '', 'bp-activities', array( 'dfw' => false, 'media_buttons' => false, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ), 'tinymce' => false, ) ); ?>
865
-
866
- <p id="bp-replysubmit" class="submit">
867
- <a href="#" class="cancel button-secondary alignleft"><?php _e( 'Cancel', 'buddypress' ); ?></a>
868
- <a href="#" class="save button-primary alignright"><?php _e( 'Reply', 'buddypress' ); ?></a>
869
-
870
- <img class="waiting" style="display:none;" src="<?php echo esc_url( network_admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
871
- <span class="error" style="display:none;"></span>
872
- <br class="clear" />
873
- </p>
874
-
875
- <?php wp_nonce_field( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply', false ); ?>
876
-
877
- </form>
878
- </td>
879
- </tr>
880
- </table>
881
- </div>
882
-
883
- <?php
884
- }
885
-
886
- /**
887
- * List table class for the Activity component admin page.
888
- *
889
- * @since 1.6
890
- */
891
- class BP_Activity_List_Table extends WP_List_Table {
892
- /**
893
- * What type of view is being displayed? e.g. "All", "Pending", "Approved", "Spam"...
894
- *
895
- * @since 1.6
896
- */
897
- public $view = 'all';
898
-
899
- /**
900
- * How many activity items have been marked as spam.
901
- *
902
- * @since 1.6
903
- */
904
- public $spam_count = 0;
905
-
906
- /**
907
- * Store activity-to-user-ID mappings for use in the In Response To column.
908
- *
909
- * @since 1.6
910
- */
911
- protected $activity_user_id = array();
912
-
913
- /**
914
- * Constructor
915
- *
916
- * @since 1.6
917
- */
918
- public function __construct() {
919
-
920
- // Define singular and plural labels, as well as whether we support AJAX.
921
- parent::__construct( array(
922
- 'ajax' => false,
923
- 'plural' => 'activities',
924
- 'singular' => 'activity',
925
- ) );
926
- }
927
-
928
- /**
929
- * Handle filtering of data, sorting, pagination, and any other data-manipulation required prior to rendering.
930
- *
931
- * @since 1.6
932
- */
933
- function prepare_items() {
934
- $screen = get_current_screen();
935
-
936
- // Option defaults
937
- $filter = array();
938
- $include_id = false;
939
- $search_terms = false;
940
- $sort = 'DESC';
941
- $spam = 'ham_only';
942
-
943
- // Set current page
944
- $page = $this->get_pagenum();
945
-
946
- // Set per page from the screen options
947
- $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$screen->id}_per_page" ) );
948
-
949
- // Check if we're on the "Spam" view
950
- if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
951
- $spam = 'spam_only';
952
- $this->view = 'spam';
953
- }
954
-
955
- // Sort order
956
- if ( !empty( $_REQUEST['order'] ) && 'desc' != $_REQUEST['order'] )
957
- $sort = 'ASC';
958
-
959
- // Order by
960
- /*if ( !empty( $_REQUEST['orderby'] ) ) {
961
- }*/
962
-
963
- // Filter
964
- if ( !empty( $_REQUEST['activity_type'] ) )
965
- $filter = array( 'action' => $_REQUEST['activity_type'] );
966
-
967
- // Are we doing a search?
968
- if ( !empty( $_REQUEST['s'] ) )
969
- $search_terms = $_REQUEST['s'];
970
-
971
- // Check if user has clicked on a specific activity (if so, fetch only that, and any related, activity).
972
- if ( !empty( $_REQUEST['aid'] ) )
973
- $include_id = (int) $_REQUEST['aid'];
974
-
975
- // Get the spam total (ignoring any search query or filter)
976
- $spams = bp_activity_get( array(
977
- 'display_comments' => 'stream',
978
- 'show_hidden' => true,
979
- 'spam' => 'spam_only',
980
- ) );
981
- $this->spam_count = $spams['total'];
982
- unset( $spams );
983
-
984
- // Get the activities from the database
985
- $activities = bp_activity_get( array(
986
- 'display_comments' => 'stream',
987
- 'filter' => $filter,
988
- 'in' => $include_id,
989
- 'page' => $page,
990
- 'per_page' => $per_page,
991
- 'search_terms' => $search_terms,
992
- 'show_hidden' => true,
993
- //'sort' => $sort,
994
- 'spam' => $spam,
995
- ) );
996
-
997
- // If we're viewing a specific activity, flatten all activites into a single array.
998
- if ( $include_id ) {
999
- $activities['activities'] = BP_Activity_List_Table::flatten_activity_array( $activities['activities'] );
1000
- $activities['total'] = count( $activities['activities'] );
1001
-
1002
- // Sort the array by the activity object's date_recorded value
1003
- usort( $activities['activities'], create_function( '$a, $b', 'return $a->date_recorded > $b->date_recorded;' ) );
1004
- }
1005
-
1006
- // bp_activity_get returns an array of objects; cast these to arrays for WP_List_Table.
1007
- $new_activities = array();
1008
- foreach ( $activities['activities'] as $activity_item ) {
1009
- $new_activities[] = (array) $activity_item;
1010
-
1011
- // Build an array of activity-to-user ID mappings for better efficency in the In Response To column
1012
- $this->activity_user_id[$activity_item->id] = $activity_item->user_id;
1013
- }
1014
-
1015
- // Set raw data to display
1016
- $this->items = $new_activities;
1017
-
1018
- // Store information needed for handling table pagination
1019
- $this->set_pagination_args( array(
1020
- 'per_page' => $per_page,
1021
- 'total_items' => $activities['total'],
1022
- 'total_pages' => ceil( $activities['total'] / $per_page )
1023
- ) );
1024
-
1025
- // Don't truncate activity items; bp_activity_truncate_entry() needs to be used inside a BP_Activity_Template loop.
1026
- remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
1027
- }
1028
-
1029
- /**
1030
- * Get an array of all the columns on the page
1031
- *
1032
- * @return array
1033
- * @since 1.6
1034
- */
1035
- function get_column_info() {
1036
- $this->_column_headers = array(
1037
- $this->get_columns(),
1038
- array(),
1039
- $this->get_sortable_columns(),
1040
- );
1041
-
1042
- return $this->_column_headers;
1043
- }
1044
-
1045
- /**
1046
- * Displays a message on screen when no items are found (e.g. no search matches)
1047
- *
1048
- * @since 1.6
1049
- */
1050
- function no_items() {
1051
- _e( 'No activities found.', 'buddypress' );
1052
- }
1053
-
1054
- /**
1055
- * Outputs the Activity data table
1056
- *
1057
- * @since 1.6
1058
- */
1059
- function display() {
1060
- extract( $this->_args );
1061
-
1062
- $this->display_tablenav( 'top' );
1063
- ?>
1064
-
1065
- <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
1066
- <thead>
1067
- <tr>
1068
- <?php $this->print_column_headers(); ?>
1069
- </tr>
1070
- </thead>
1071
-
1072
- <tfoot>
1073
- <tr>
1074
- <?php $this->print_column_headers( false ); ?>
1075
- </tr>
1076
- </tfoot>
1077
-
1078
- <tbody id="the-comment-list">
1079
- <?php $this->display_rows_or_placeholder(); ?>
1080
- </tbody>
1081
- </table>
1082
- <?php
1083
-
1084
- $this->display_tablenav( 'bottom' );
1085
- }
1086
-
1087
- /**
1088
- * Generates content for a single row of the table
1089
- *
1090
- * @param object $item The current item
1091
- * @since 1.6
1092
- */
1093
- function single_row( $item ) {
1094
- static $row_class = '';
1095
- $row_class = ( $row_class == '' ? ' class="alternate"' : '' );
1096
-
1097
- echo '<tr' . $row_class . ' id="activity-' . esc_attr( $item['id'] ) . '" data-parent_id="' . esc_attr( $item['id'] ) . '" data-root_id="' . esc_attr( $item['item_id'] ) . '">';
1098
- echo $this->single_row_columns( $item );
1099
- echo '</tr>';
1100
- }
1101
-
1102
- /**
1103
- * Get the list of views available on this table (e.g. "all", "spam").
1104
- *
1105
- * @since 1.6
1106
- */
1107
- function get_views() {
1108
- $redirect_to = remove_query_arg( array( 'activity_status', 'aid', 'deleted', 'error', 'spammed', 'unspammed', 'updated', ), $_SERVER['REQUEST_URI'] );
1109
- ?>
1110
- <ul class="subsubsub">
1111
- <li class="all"><a href="<?php echo esc_attr( esc_url( $redirect_to ) ); ?>" class="<?php if ( 'spam' != $this->view ) echo 'current'; ?>"><?php _e( 'All', 'buddypress' ); ?></a> |</li>
1112
- <li class="spam"><a href="<?php echo esc_attr( esc_url( add_query_arg( 'activity_status', 'spam', $redirect_to ) ) ); ?>" class="<?php if ( 'spam' == $this->view ) echo 'current'; ?>"><?php printf( __( 'Spam <span class="count">(%s)</span>', 'buddypress' ), number_format_i18n( $this->spam_count ) ); ?></a></li>
1113
-
1114
- <?php do_action( 'bp_activity_list_table_get_views', $redirect_to, $this->view ); ?>
1115
- </ul>
1116
- <?php
1117
- }
1118
-
1119
- /**
1120
- * Get bulk actions
1121
- *
1122
- * @return array Key/value pairs for the bulk actions dropdown
1123
- * @since 1.6
1124
- */
1125
- function get_bulk_actions() {
1126
- $actions = array();
1127
- $actions['bulk_spam'] = __( 'Mark as Spam', 'buddypress' );
1128
- $actions['bulk_ham'] = __( 'Not Spam', 'buddypress' );
1129
- $actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
1130
-
1131
- return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
1132
- }
1133
-
1134
- /**
1135
- * Get the table column titles.
1136
- *
1137
- * @see WP_List_Table::single_row_columns()
1138
- * @return array
1139
- * @since 1.6
1140
- */
1141
- function get_columns() {
1142
- return array(
1143
- 'cb' => '<input name type="checkbox" />',
1144
- 'author' => __( 'Author', 'buddypress' ),
1145
- 'comment' => __( 'Activity', 'buddypress' ),
1146
- 'response' => __( 'In Response To', 'buddypress' ),
1147
- );
1148
- }
1149
-
1150
- /**
1151
- * Get the column names for sortable columns
1152
- *
1153
- * @return array
1154
- * @since 1.6
1155
- * @todo For this to work, BP_Activity_Activity::get() needs updating to supporting ordering by specific fields
1156
- */
1157
- function get_sortable_columns() {
1158
- return array();
1159
-
1160
- /*return array(
1161
- 'author' => array( 'activity_author', false ), // Intentionally not using "=>"
1162
- );*/
1163
- }
1164
-
1165
- /**
1166
- * Markup for the "filter" part of the form (i.e. which activity type to display)
1167
- *
1168
- * @global object $bp BuddyPress global settings
1169
- * @param string $which 'top' or 'bottom'
1170
- * @since 1.6
1171
- */
1172
- function extra_tablenav( $which ) {
1173
- global $bp;
1174
-
1175
- if ( 'bottom' == $which )
1176
- return;
1177
-
1178
- $actions = array();
1179
- $selected = !empty( $_REQUEST['activity_type'] ) ? $_REQUEST['activity_type'] : '';
1180
-
1181
- // Walk through the registered actions, and build an array of actions/values.
1182
- foreach ( $bp->activity->actions as $action ) {
1183
- $action = array_values( (array) $action );
1184
-
1185
- for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
1186
- $actions[ $action[$i]['key'] ] = $action[$i]['value'];
1187
- }
1188
-
1189
- // This was a mis-named activity type from before BP 1.6
1190
- unset( $actions['friends_register_activity_action'] );
1191
-
1192
- // This type has not been used since BP 1.0.3. It will be re-instated in a future version.
1193
- unset( $actions['updated_profile'] );
1194
-
1195
- // Sort array by the human-readable value
1196
- natsort( $actions );
1197
- ?>
1198
-
1199
- <div class="alignleft actions">
1200
- <select name="activity_type">
1201
- <option value="" <?php selected( !$selected ); ?>><?php _e( 'Show all activity types', 'buddypress' ); ?></option>
1202
-
1203
- <?php foreach ( $actions as $k => $v ) : ?>
1204
- <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option>
1205
- <?php endforeach; ?>
1206
- </select>
1207
-
1208
- <?php submit_button( __( 'Filter', 'buddypress' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); ?>
1209
- </div>
1210
-
1211
- <?php
1212
- }
1213
-
1214
- /**
1215
- * Checkbox column
1216
- *
1217
- * @param array $item A singular item (one full row)
1218
- * @see WP_List_Table::single_row_columns()
1219
- * @since 1.6
1220
- */
1221
- function column_cb( $item ) {
1222
- printf( '<input type="checkbox" name="aid[]" value="%d" />', (int) $item['id'] );
1223
- }
1224
-
1225
- /**
1226
- * Author column
1227
- *
1228
- * @param array $item A singular item (one full row)
1229
- * @see WP_List_Table::single_row_columns()
1230
- * @since 1.6
1231
- */
1232
- function column_author( $item ) {
1233
- echo '<strong>' . get_avatar( $item['user_id'], '32' ) . ' ' . bp_core_get_userlink( $item['user_id'] ) . '</strong>';
1234
- }
1235
-
1236
- /**
1237
- * Content column, and "quick admin" rollover actions.
1238
- *
1239
- * Called "comment" in the CSS so we can re-use some WP core CSS.
1240
- *
1241
- * @param array $item A singular item (one full row)
1242
- * @see WP_List_Table::single_row_columns()
1243
- * @since 1.6
1244
- */
1245
- function column_comment( $item ) {
1246
- // Determine what type of item (row) we're dealing with
1247
- if ( $item['is_spam'] )
1248
- $item_status = 'spam';
1249
- else
1250
- $item_status = 'all';
1251
-
1252
- // Preorder items: Reply | Edit | Spam | Delete Permanently
1253
- $actions = array(
1254
- 'reply' => '',
1255
- 'edit' => '',
1256
- 'spam' => '', 'unspam' => '',
1257
- 'delete' => '',
1258
- );
1259
-
1260
- // Build actions URLs
1261
- $base_url = network_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1262
- $spam_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'spam-activity_' . $item['id'] ) );
1263
-
1264
- $delete_url = $base_url . "&amp;action=delete&amp;$spam_nonce";
1265
- $edit_url = $base_url . '&amp;action=edit';
1266
- $ham_url = $base_url . "&amp;action=ham&amp;$spam_nonce";
1267
- $spam_url = $base_url . "&amp;action=spam&amp;$spam_nonce";
1268
-
1269
- // Rollover actions
1270
-
1271
- // Reply - javascript only; implemented by AJAX.
1272
- if ( 'spam' != $item_status ) {
1273
- $actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', __( 'Reply', 'buddypress' ) );
1274
-
1275
- // Edit
1276
- $actions['edit'] = sprintf( '<a href="%s">%s</a>', $edit_url, __( 'Edit', 'buddypress' ) );
1277
- }
1278
-
1279
- // Spam/unspam
1280
- if ( 'spam' == $item_status )
1281
- $actions['unspam'] = sprintf( '<a href="%s">%s</a>', $ham_url, __( 'Not Spam', 'buddypress' ) );
1282
- else
1283
- $actions['spam'] = sprintf( '<a href="%s">%s</a>', $spam_url, __( 'Spam', 'buddypress' ) );
1284
-
1285
- // Delete
1286
- $actions['delete'] = sprintf( '<a href="%s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js( __( 'Are you sure?', 'buddypress' ) ) . "'); ", __( 'Delete Permanently', 'buddypress' ) );
1287
-
1288
- // Start timestamp
1289
- echo '<div class="submitted-on">';
1290
-
1291
- // Other plugins can filter which actions are shown
1292
- $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1293
-
1294
- /* translators: 2: activity admin ui date/time */
1295
- printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>', 'buddypress' ), bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $item['id'] . '/', date_i18n( get_option( 'date_format' ), strtotime( $item['date_recorded'] ) ), date_i18n( get_option( 'time_format' ), strtotime( $item['date_recorded'] ) ) );
1296
-
1297
- // End timestamp
1298
- echo '</div>';
1299
-
1300
- // Get activity content - if not set, use the action
1301
- if ( ! empty( $item['content'] ) )
1302
- $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'] ) );
1303
- else
1304
- $content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'] ) );
1305
-
1306
- echo $content . ' ' . $this->row_actions( $actions );
1307
- }
1308
-
1309
- /**
1310
- * "In response to" column
1311
- *
1312
- * @param array $item A singular item (one full row)
1313
- * @see WP_List_Table::single_row_columns()
1314
- * @since 1.6
1315
- */
1316
- function column_response( $item ) {
1317
- // Is $item is a root activity?
1318
- if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) ) {
1319
- $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
1320
- $root_activity_url = network_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1321
-
1322
- // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
1323
- if ( $comment_count ) {
1324
- $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
1325
- printf( '<a href="%1$s" title="%2$s" class="post-com-count"><span class="comment-count">%3$s</span></a>', esc_attr( $root_activity_url ), esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
1326
- }
1327
-
1328
- // For non-root activities, display a link to the replied-to activity's author's profile
1329
- } else {
1330
- echo '<strong>' . get_avatar( $this->get_activity_user_id( $item['item_id'] ), '32' ) . ' ' . bp_core_get_userlink( $this->get_activity_user_id( $item['item_id'] ) ) . '</strong><br />';
1331
- }
1332
-
1333
- // Activity permalink
1334
- if ( ! $item['is_spam'] )
1335
- printf( __( '<a href="%1$s">View Activity</a>', 'buddypress' ), bp_activity_get_permalink( $item['id'], (object) $item ) );
1336
- }
1337
-
1338
- /**
1339
- * A wrapper function for the BP_Activity_List_Table to get the specified activity's user ID.
1340
- *
1341
- * @param int $activity_id Activity ID to retrieve User ID for
1342
- * @since 1.6
1343
- */
1344
- protected function get_activity_user_id( $activity_id ) {
1345
- // If there is an existing activity/user ID mapping, just return the user ID.
1346
- if ( ! empty( $this->activity_user_id[$activity_id] ) ) {
1347
- return $this->activity_user_id[$activity_id];
1348
-
1349
- /**
1350
- * We don't have a mapping. This means the $activity_id is not on the current
1351
- * page of results, so fetch its details from the database.
1352
- */
1353
- } else {
1354
- $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'show_hidden' => true, 'spam' => 'all', ) );
1355
-
1356
- /**
1357
- * If, somehow, the referenced activity has been deleted, leaving its associated
1358
- * activites as orphans, use the logged in user's ID to avoid errors.
1359
- */
1360
- if ( empty( $activity['activities'] ) )
1361
- return bp_loggedin_user_id();
1362
-
1363
- // Store the new activity/user ID mapping for any later re-use
1364
- $this->activity_user_id[ $activity['activities'][0]->id ] = $activity['activities'][0]->user_id;
1365
-
1366
- // Return the user ID
1367
- return $activity['activities'][0]->user_id;
1368
- }
1369
- }
1370
-
1371
- /**
1372
- * Helper function to flatten all activites returned from bp_activity_get() into a single array.
1373
- *
1374
- * @param array $tree Source array
1375
- * @return array Flattened array
1376
- * @since 1.6
1377
- */
1378
- public static function flatten_activity_array( $tree ){
1379
- foreach ( (array) $tree as $node ) {
1380
- if ( isset( $node->children ) ) {
1381
-
1382
- foreach ( BP_Activity_List_Table::flatten_activity_array( $node->children ) as $child ) {
1383
- $tree[] = $child;
1384
- }
1385
-
1386
- unset( $node->children );
1387
- }
1388
- }
1389
-
1390
- return $tree;
1391
- }
1392
- }
1393
- ?>