BuddyPress - Version 2.4.0-beta1

Version Description

= 2.4.0 = See: https://codex.buddypress.org/releases/version-2-4-0/

= 2.3.4 = See: https://codex.buddypress.org/releases/version-2-3-4/

= 2.3.3 = See: https://codex.buddypress.org/releases/version-2-3-3/

= 2.3.2 = See: https://codex.buddypress.org/releases/version-2-3-2/

= 2.3.1 = See: https://codex.buddypress.org/releases/version-2-3-1/

= 2.3.0 = See: https://codex.buddypress.org/releases/version-2-3-0/

= 2.2.3.1 = See: https://codex.buddypress.org/releases/version-2-2-3-1/

= 2.2.3 = See: https://codex.buddypress.org/releases/version-2-2-3/

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

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

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

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

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

= 2.0.3 = See: https://codex.buddypress.org/releases/version-2-0-3/

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

= 2.0.1 = See: https://codex.buddypress.org/releases/version-2-0-1/

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

= 1.9.2 = See: https://codex.buddypress.org/releases/version-1-9-2/

= 1.9.1 = See: https://codex.buddypress.org/releases/version-1-9-1/

= 1.9 = See: https://codex.buddypress.org/releases/version-1-9/

= 1.8.1 = See: https://codex.buddypress.org/releases/version-1-8-1/

= 1.8 = See: https://codex.buddypress.org/releases/version-1-8/

= 1.7.3 = See: https://codex.buddypress.org/releases/version-1-7-3/

= 1.7.2 = See: https://codex.buddypress.org/releases/version-1-7-2/

= 1.7.1 = See: https://codex.buddypress.org/releases/version-1-7-1/

= 1.7 = See: https://codex.buddypress.org/releases/version-1-7/

= 1.6.5 = See: https://codex.buddypress.org/releases/version-1-6-5/

= 1.6.4 = See: https://codex.buddypress.org/releases/version-1-6-4/

= 1.6.3 = See: https://codex.buddypress.org/releases/version-1-6-3/

= 1.6.2 = Compatibility with WordPress 3.5

= 1.6.1 = Fixes 4 bugs

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

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

= 1.2.9 = Compatibility with WordPress 3.2

= 1.2.8 = Compatibility with WordPress 3.1

= 1.2.7 = Fixes over 10 bugs.

Download this release

Release Info

Developer DJPaul
Plugin Icon 128x128 BuddyPress
Version 2.4.0-beta1
Comparing to
See all releases

Code changes from version 2.3.4 to 2.4.0-beta1

Files changed (68) hide show
  1. bp-activity/admin/js/admin.js +7 -7
  2. bp-activity/admin/js/admin.min.js +1 -1
  3. bp-activity/bp-activity-actions.php +82 -85
  4. bp-activity/bp-activity-admin.php +279 -231
  5. bp-activity/bp-activity-akismet.php +74 -78
  6. bp-activity/bp-activity-cache.php +8 -7
  7. bp-activity/bp-activity-classes.php +3 -3
  8. bp-activity/bp-activity-cssjs.php +5 -7
  9. bp-activity/bp-activity-filters.php +76 -89
  10. bp-activity/bp-activity-functions.php +274 -325
  11. bp-activity/bp-activity-loader.php +64 -62
  12. bp-activity/bp-activity-notifications.php +46 -50
  13. bp-activity/bp-activity-screens.php +57 -60
  14. bp-activity/bp-activity-template.php +437 -440
  15. bp-activity/classes/class-bp-activity-activity.php +214 -221
  16. bp-activity/classes/class-bp-activity-feed.php +61 -60
  17. bp-activity/classes/class-bp-activity-query.php +18 -30
  18. bp-activity/js/mentions.js +10 -10
  19. bp-activity/js/mentions.min.js +2 -2
  20. bp-blogs/bp-blogs-actions.php +1 -2
  21. bp-blogs/bp-blogs-activity.php +121 -85
  22. bp-blogs/bp-blogs-cache.php +6 -7
  23. bp-blogs/bp-blogs-classes.php +1 -2
  24. bp-blogs/bp-blogs-filters.php +12 -10
  25. bp-blogs/bp-blogs-functions.php +129 -102
  26. bp-blogs/bp-blogs-loader.php +51 -38
  27. bp-blogs/bp-blogs-screens.php +21 -22
  28. bp-blogs/bp-blogs-template.php +175 -162
  29. bp-blogs/bp-blogs-widgets.php +12 -8
  30. bp-blogs/classes/class-bp-blogs-blog.php +69 -58
  31. bp-core/admin/bp-core-admin-actions.php +23 -24
  32. bp-core/admin/bp-core-admin-components.php +17 -17
  33. bp-core/admin/bp-core-admin-functions.php +71 -59
  34. bp-core/admin/bp-core-admin-schema.php +25 -26
  35. bp-core/admin/bp-core-admin-settings.php +85 -57
  36. bp-core/admin/bp-core-admin-slugs.php +10 -12
  37. bp-core/admin/bp-core-admin-tools.php +26 -20
  38. bp-core/admin/css/common-rtl.css +3 -277
  39. bp-core/admin/css/common-rtl.min.css +1 -1
  40. bp-core/admin/css/common.css +3 -277
  41. bp-core/admin/css/common.min.css +1 -1
  42. bp-core/admin/images/icons32.png +0 -0
  43. bp-core/admin/images/icons64.png +0 -0
  44. bp-core/admin/images/menu-2x.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 +12 -13
  48. bp-core/bp-core-admin.php +46 -33
  49. bp-core/bp-core-adminbar.php +7 -8
  50. bp-core/bp-core-attachments.php +1003 -36
  51. bp-core/bp-core-avatars.php +273 -252
  52. bp-core/bp-core-buddybar.php +373 -139
  53. bp-core/bp-core-cache.php +29 -22
  54. bp-core/bp-core-caps.php +88 -54
  55. bp-core/bp-core-catchuri.php +69 -47
  56. bp-core/bp-core-classes.php +2 -1
  57. bp-core/bp-core-component.php +93 -77
  58. bp-core/bp-core-cssjs.php +134 -15
  59. bp-core/bp-core-dependency.php +68 -59
  60. bp-core/bp-core-filters.php +127 -61
  61. bp-core/bp-core-functions.php +213 -167
  62. bp-core/bp-core-loader.php +25 -70
  63. bp-core/bp-core-moderation.php +20 -17
  64. bp-core/bp-core-options.php +164 -88
  65. bp-core/bp-core-taxonomy.php +15 -7
  66. bp-core/bp-core-template-loader.php +64 -52
  67. bp-core/bp-core-template.php +280 -205
  68. bp-core/bp-core-theme-compatibility.php +148 -36
bp-activity/admin/js/admin.js CHANGED
@@ -4,14 +4,14 @@
4
  /**
5
  * Activity reply object for the activity index screen
6
  *
7
- * @since BuddyPress (1.6)
8
  */
9
  var activityReply = {
10
 
11
  /**
12
  * Attach event handler functions to the relevant elements.
13
  *
14
- * @since BuddyPress (1.6)
15
  */
16
  init : function() {
17
  $(document).on( 'click', '.row-actions a.reply', activityReply.open );
@@ -29,7 +29,7 @@ var activityReply = {
29
  /**
30
  * Reveals the entire row when "reply" is pressed.
31
  *
32
- * @since BuddyPress (1.6)
33
  */
34
  open : function() {
35
  // Hide the container row, and move it to the new location
@@ -46,7 +46,7 @@ var activityReply = {
46
  /**
47
  * Hide and reset the entire row when "cancel", or escape, are pressed.
48
  *
49
- * @since BuddyPress (1.6)
50
  */
51
  close : function() {
52
  // Hide the container row
@@ -66,7 +66,7 @@ var activityReply = {
66
  /**
67
  * Submits "form" via AJAX back to WordPress.
68
  *
69
- * @since BuddyPress (1.6)
70
  */
71
  send : function() {
72
  // Hide any existing error message, and show the loading spinner
@@ -100,7 +100,7 @@ var activityReply = {
100
  /**
101
  * send() error message handler
102
  *
103
- * @since BuddyPress (1.6)
104
  */
105
  error : function( r ) {
106
  var er = r.statusText;
@@ -118,7 +118,7 @@ var activityReply = {
118
  /**
119
  * send() success handler
120
  *
121
- * @since BuddyPress (1.6)
122
  */
123
  show : function ( xml ) {
124
  var bg, id, response;
4
  /**
5
  * Activity reply object for the activity index screen
6
  *
7
+ * @since 1.6.0
8
  */
9
  var activityReply = {
10
 
11
  /**
12
  * Attach event handler functions to the relevant elements.
13
  *
14
+ * @since 1.6.0
15
  */
16
  init : function() {
17
  $(document).on( 'click', '.row-actions a.reply', activityReply.open );
29
  /**
30
  * Reveals the entire row when "reply" is pressed.
31
  *
32
+ * @since 1.6.0
33
  */
34
  open : function() {
35
  // Hide the container row, and move it to the new location
46
  /**
47
  * Hide and reset the entire row when "cancel", or escape, are pressed.
48
  *
49
+ * @since 1.6.0
50
  */
51
  close : function() {
52
  // Hide the container row
66
  /**
67
  * Submits "form" via AJAX back to WordPress.
68
  *
69
+ * @since 1.6.0
70
  */
71
  send : function() {
72
  // Hide any existing error message, and show the loading spinner
100
  /**
101
  * send() error message handler
102
  *
103
+ * @since 1.6.0
104
  */
105
  error : function( r ) {
106
  var er = r.statusText;
118
  /**
119
  * send() success handler
120
  *
121
+ * @since 1.6.0
122
  */
123
  show : function ( xml ) {
124
  var bg, id, response;
bp-activity/admin/js/admin.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.3.4 - 2015-10-07 3:54:34 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
1
+ /*! buddypress - v2.4.0 - 2015-10-12 8:03:39 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
  !function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
bp-activity/bp-activity-actions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Action functions are exactly the same as screen functions, however they do
5
  * not have a template screen associated with them. Usually they will send the
@@ -9,13 +8,13 @@
9
  * @subpackage ActivityActions
10
  */
11
 
12
- // Exit if accessed directly
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  /**
16
  * Allow core components and dependent plugins to register activity actions.
17
  *
18
- * @since BuddyPress (1.2.0)
19
  *
20
  * @uses do_action() To call 'bp_register_activity_actions' hook.
21
  */
@@ -24,7 +23,7 @@ function bp_register_activity_actions() {
24
  /**
25
  * Fires on bp_init to allow core components and dependent plugins to register activity actions.
26
  *
27
- * @since BuddyPress (1.2.0)
28
  */
29
  do_action( 'bp_register_activity_actions' );
30
  }
@@ -33,7 +32,7 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
33
  /**
34
  * Catch and route requests for single activity item permalinks.
35
  *
36
- * @since BuddyPress (1.2.0)
37
  *
38
  * @uses bp_is_activity_component()
39
  * @uses bp_is_current_action()
@@ -51,15 +50,15 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
51
  */
52
  function bp_activity_action_permalink_router() {
53
 
54
- // Not viewing activity
55
  if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) )
56
  return false;
57
 
58
- // No activity to display
59
  if ( ! bp_action_variable( 0 ) || ! is_numeric( bp_action_variable( 0 ) ) )
60
  return false;
61
 
62
- // Get the activity details
63
  $activity = bp_activity_get_specific( array( 'activity_ids' => bp_action_variable( 0 ), 'show_hidden' => true ) );
64
 
65
  // 404 if activity does not exist
@@ -70,31 +69,31 @@ function bp_activity_action_permalink_router() {
70
  $activity = $activity['activities'][0];
71
  }
72
 
73
- // Do not redirect at default
74
  $redirect = false;
75
 
76
- // Redirect based on the type of activity
77
  if ( bp_is_active( 'groups' ) && $activity->component == buddypress()->groups->id ) {
78
 
79
- // Activity is a user update
80
  if ( ! empty( $activity->user_id ) ) {
81
  $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
82
 
83
- // Activity is something else
84
  } else {
85
 
86
- // Set redirect to group activity stream
87
  if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
88
  $redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
89
  }
90
  }
91
 
92
- // Set redirect to users' activity stream
93
  } elseif ( ! empty( $activity->user_id ) ) {
94
  $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
95
  }
96
 
97
- // If set, add the original query string back onto the redirect URL
98
  if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
99
  $query_frags = array();
100
  wp_parse_str( $_SERVER['QUERY_STRING'], $query_frags );
@@ -104,7 +103,7 @@ function bp_activity_action_permalink_router() {
104
  /**
105
  * Filter the intended redirect url before the redirect occurs for the single activity item.
106
  *
107
- * @since BuddyPress (1.2.2)
108
  *
109
  * @param array Array with url to redirect to and activity related to the redirect.
110
  */
@@ -112,7 +111,7 @@ function bp_activity_action_permalink_router() {
112
  bp_core_redirect( bp_get_root_domain() );
113
  }
114
 
115
- // Redirect to the actual activity permalink page
116
  bp_core_redirect( $redirect );
117
  }
118
  add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
@@ -120,9 +119,7 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
120
  /**
121
  * Delete specific activity item and redirect to previous page.
122
  *
123
- * @since BuddyPress (1.1.0)
124
- *
125
- * @param int $activity_id Activity id to be deleted. Defaults to 0.
126
  *
127
  * @uses bp_is_activity_component()
128
  * @uses bp_is_current_action()
@@ -135,42 +132,43 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
135
  * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
136
  * @uses bp_core_redirect()
137
  *
 
138
  * @return bool False on failure.
139
  */
140
  function bp_activity_action_delete_activity( $activity_id = 0 ) {
141
 
142
- // Not viewing activity or action is not delete
143
  if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
144
  return false;
145
 
146
  if ( empty( $activity_id ) && bp_action_variable( 0 ) )
147
  $activity_id = (int) bp_action_variable( 0 );
148
 
149
- // Not viewing a specific activity item
150
  if ( empty( $activity_id ) )
151
  return false;
152
 
153
- // Check the nonce
154
  check_admin_referer( 'bp_activity_delete_link' );
155
 
156
- // Load up the activity item
157
  $activity = new BP_Activity_Activity( $activity_id );
158
 
159
- // Check access
160
  if ( ! bp_activity_user_can_delete( $activity ) )
161
  return false;
162
 
163
  /**
164
  * Fires before the deletion so plugins can still fetch information about it.
165
  *
166
- * @since BuddyPress (1.5.0)
167
  *
168
  * @param int $activity_id The activity ID.
169
  * @param int $user_id The user associated with the activity.
170
  */
171
  do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
172
 
173
- // Delete the activity item and provide user feedback
174
  if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) )
175
  bp_core_add_message( __( 'Activity deleted successfully', 'buddypress' ) );
176
  else
@@ -179,14 +177,14 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
179
  /**
180
  * Fires after the deletion so plugins can act afterwards based on the activity.
181
  *
182
- * @since BuddyPress (1.1.0)
183
  *
184
  * @param int $activity_id The activity ID.
185
  * @param int $user_id The user associated with the activity.
186
  */
187
  do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
188
 
189
- // Check for the redirect query arg, otherwise let WP handle things
190
  if ( !empty( $_GET['redirect_to'] ) )
191
  bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
192
  else
@@ -197,23 +195,22 @@ add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
197
  /**
198
  * Mark specific activity item as spam and redirect to previous page.
199
  *
200
- * @since BuddyPress (1.6.0)
201
  *
202
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
203
- *
204
  * @return bool False on failure.
205
  */
206
  function bp_activity_action_spam_activity( $activity_id = 0 ) {
207
  $bp = buddypress();
208
 
209
- // Not viewing activity, or action is not spam, or Akismet isn't present
210
  if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
211
  return false;
212
 
213
  if ( empty( $activity_id ) && bp_action_variable( 0 ) )
214
  $activity_id = (int) bp_action_variable( 0 );
215
 
216
- // Not viewing a specific activity item
217
  if ( empty( $activity_id ) )
218
  return false;
219
 
@@ -221,42 +218,42 @@ function bp_activity_action_spam_activity( $activity_id = 0 ) {
221
  if ( !bp_activity_user_can_mark_spam() )
222
  return false;
223
 
224
- // Load up the activity item
225
  $activity = new BP_Activity_Activity( $activity_id );
226
  if ( empty( $activity->id ) )
227
  return false;
228
 
229
- // Check nonce
230
  check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
231
 
232
  /**
233
  * Fires before the marking activity as spam so plugins can modify things if they want to.
234
  *
235
- * @since BuddyPress (1.6.0)
236
  *
237
  * @param int $activity_id Activity ID to be marked as spam.
238
  * @param object $activity Activity object for the ID to be marked as spam.
239
  */
240
  do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
241
 
242
- // Mark as spam
243
  bp_activity_mark_as_spam( $activity );
244
  $activity->save();
245
 
246
- // Tell the user the spamming has been successful
247
  bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
248
 
249
  /**
250
  * Fires after the marking activity as spam so plugins can act afterwards based on the activity.
251
  *
252
- * @since BuddyPress (1.6.0)
253
  *
254
  * @param int $activity_id Activity ID that was marked as spam.
255
  * @param int $user_id User ID associated with activity.
256
  */
257
  do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
258
 
259
- // Check for the redirect query arg, otherwise let WP handle things
260
  if ( !empty( $_GET['redirect_to'] ) )
261
  bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
262
  else
@@ -267,7 +264,7 @@ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
267
  /**
268
  * Post user/group activity update.
269
  *
270
- * @since BuddyPress (1.2.0)
271
  *
272
  * @uses is_user_logged_in()
273
  * @uses bp_is_activity_component()
@@ -287,17 +284,17 @@ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
287
  */
288
  function bp_activity_action_post_update() {
289
 
290
- // Do not proceed if user is not logged in, not viewing activity, or not posting
291
  if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
292
  return false;
293
 
294
- // Check the nonce
295
  check_admin_referer( 'post_update', '_wpnonce_post_update' );
296
 
297
  /**
298
  * Filters the content provided in the activity input field.
299
  *
300
- * @since BuddyPress (1.2.0)
301
  *
302
  * @param string $value Activity message being posted.
303
  */
@@ -308,7 +305,7 @@ function bp_activity_action_post_update() {
308
  /**
309
  * Filters the item type that the activity update should be associated with.
310
  *
311
- * @since BuddyPress (1.2.0)
312
  *
313
  * @param string $value Item type to associate with.
314
  */
@@ -320,24 +317,24 @@ function bp_activity_action_post_update() {
320
  /**
321
  * Filters what component the activity is being to.
322
  *
323
- * @since BuddyPress (1.2.0)
324
  *
325
  * @param string $value Chosen component to post activity to.
326
  */
327
  $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
328
  }
329
 
330
- // No activity content so provide feedback and redirect
331
  if ( empty( $content ) ) {
332
  bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
333
  bp_core_redirect( wp_get_referer() );
334
  }
335
 
336
- // No existing item_id
337
  if ( empty( $item_id ) ) {
338
  $activity_id = bp_activity_post_update( array( 'content' => $content ) );
339
 
340
- // Post to groups object
341
  } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) {
342
  if ( (int) $item_id ) {
343
  $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
@@ -348,7 +345,7 @@ function bp_activity_action_post_update() {
348
  /**
349
  * Filters activity object for BuddyPress core and plugin authors before posting activity update.
350
  *
351
- * @since BuddyPress (1.2.0)
352
  *
353
  * @param string $object Activity item being associated to.
354
  * @param string $item_id Component ID being posted to.
@@ -357,13 +354,13 @@ function bp_activity_action_post_update() {
357
  $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
358
  }
359
 
360
- // Provide user feedback
361
  if ( !empty( $activity_id ) )
362
  bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
363
  else
364
  bp_core_add_message( __( 'There was an error when posting your update. Please try again.', 'buddypress' ), 'error' );
365
 
366
- // Redirect
367
  bp_core_redirect( wp_get_referer() );
368
  }
369
  add_action( 'bp_actions', 'bp_activity_action_post_update' );
@@ -371,7 +368,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
371
  /**
372
  * Post new activity comment.
373
  *
374
- * @since BuddyPress (1.2.0)
375
  *
376
  * @uses is_user_logged_in()
377
  * @uses bp_is_activity_component()
@@ -391,13 +388,13 @@ function bp_activity_action_post_comment() {
391
  if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'reply' ) )
392
  return false;
393
 
394
- // Check the nonce
395
  check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
396
 
397
  /**
398
  * Filters the activity ID a comment will be in reply to.
399
  *
400
- * @since BuddyPress (1.2.0)
401
  *
402
  * @param string $value ID of the activity being replied to.
403
  */
@@ -406,7 +403,7 @@ function bp_activity_action_post_comment() {
406
  /**
407
  * Filters the comment content for a comment reply.
408
  *
409
- * @since BuddyPress (1.2.0)
410
  *
411
  * @param string $value Comment content being posted.
412
  */
@@ -435,7 +432,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
435
  /**
436
  * Mark activity as favorite.
437
  *
438
- * @since BuddyPress (1.2.0)
439
  *
440
  * @uses is_user_logged_in()
441
  * @uses bp_is_activity_component()
@@ -454,7 +451,7 @@ function bp_activity_action_mark_favorite() {
454
  if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'favorite' ) )
455
  return false;
456
 
457
- // Check the nonce
458
  check_admin_referer( 'mark_favorite' );
459
 
460
  if ( bp_activity_add_user_favorite( bp_action_variable( 0 ) ) )
@@ -469,7 +466,7 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
469
  /**
470
  * Remove activity from favorites.
471
  *
472
- * @since BuddyPress (1.2.0)
473
  *
474
  * @uses is_user_logged_in()
475
  * @uses bp_is_activity_component()
@@ -488,7 +485,7 @@ function bp_activity_action_remove_favorite() {
488
  if ( ! is_user_logged_in() || ! bp_is_activity_component() || ! bp_is_current_action( 'unfavorite' ) )
489
  return false;
490
 
491
- // Check the nonce
492
  check_admin_referer( 'unmark_favorite' );
493
 
494
  if ( bp_activity_remove_user_favorite( bp_action_variable( 0 ) ) )
@@ -503,7 +500,7 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
503
  /**
504
  * Load the sitewide activity feed.
505
  *
506
- * @since BuddyPress (1.0.0)
507
  *
508
  * @uses bp_is_activity_component()
509
  * @uses bp_is_current_action()
@@ -518,7 +515,7 @@ function bp_activity_action_sitewide_feed() {
518
  if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
519
  return false;
520
 
521
- // setup the feed
522
  buddypress()->activity->feed = new BP_Activity_Feed( array(
523
  'id' => 'sitewide',
524
 
@@ -535,7 +532,7 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
535
  /**
536
  * Load a user's personal activity feed.
537
  *
538
- * @since BuddyPress (1.0.0)
539
  *
540
  * @uses bp_is_user_activity()
541
  * @uses bp_is_current_action()
@@ -548,7 +545,7 @@ function bp_activity_action_personal_feed() {
548
  return false;
549
  }
550
 
551
- // setup the feed
552
  buddypress()->activity->feed = new BP_Activity_Feed( array(
553
  'id' => 'personal',
554
 
@@ -565,7 +562,7 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
565
  /**
566
  * Load a user's friends' activity feed.
567
  *
568
- * @since BuddyPress (1.0.0)
569
  *
570
  * @uses bp_is_active()
571
  * @uses bp_is_user_activity()
@@ -581,7 +578,7 @@ function bp_activity_action_friends_feed() {
581
  return false;
582
  }
583
 
584
- // setup the feed
585
  buddypress()->activity->feed = new BP_Activity_Feed( array(
586
  'id' => 'friends',
587
 
@@ -598,7 +595,7 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
598
  /**
599
  * Load the activity feed for a user's groups.
600
  *
601
- * @since BuddyPress (1.2.0)
602
  *
603
  * @uses bp_is_active()
604
  * @uses bp_is_user_activity()
@@ -614,11 +611,11 @@ function bp_activity_action_my_groups_feed() {
614
  return false;
615
  }
616
 
617
- // get displayed user's group IDs
618
  $groups = groups_get_user_groups();
619
  $group_ids = implode( ',', $groups['groups'] );
620
 
621
- // setup the feed
622
  buddypress()->activity->feed = new BP_Activity_Feed( array(
623
  'id' => 'mygroups',
624
 
@@ -639,7 +636,7 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
639
  /**
640
  * Load a user's @mentions feed.
641
  *
642
- * @since BuddyPress (1.2.0)
643
  *
644
  * @uses bp_is_user_activity()
645
  * @uses bp_is_current_action()
@@ -657,7 +654,7 @@ function bp_activity_action_mentions_feed() {
657
  return false;
658
  }
659
 
660
- // setup the feed
661
  buddypress()->activity->feed = new BP_Activity_Feed( array(
662
  'id' => 'mentions',
663
 
@@ -676,7 +673,7 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
676
  /**
677
  * Load a user's favorites feed.
678
  *
679
- * @since BuddyPress (1.2.0)
680
  *
681
  * @uses bp_is_user_activity()
682
  * @uses bp_is_current_action()
@@ -690,11 +687,11 @@ function bp_activity_action_favorites_feed() {
690
  return false;
691
  }
692
 
693
- // get displayed user's favorite activity IDs
694
  $favs = bp_activity_get_user_favorites( bp_displayed_user_id() );
695
  $fav_ids = implode( ',', (array) $favs );
696
 
697
- // setup the feed
698
  buddypress()->activity->feed = new BP_Activity_Feed( array(
699
  'id' => 'favorites',
700
 
@@ -711,23 +708,23 @@ add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
711
  /**
712
  * Loads Akismet filtering for activity.
713
  *
714
- * @since BuddyPress (1.6.0)
715
- * @since BuddyPress (2.3.0) We only support Akismet 3+.
716
  */
717
  function bp_activity_setup_akismet() {
718
  $bp = buddypress();
719
 
720
- // Bail if Akismet is not active
721
  if ( ! defined( 'AKISMET_VERSION' ) ) {
722
  return;
723
  }
724
 
725
- // Bail if older version of Akismet
726
  if ( ! class_exists( 'Akismet' ) ) {
727
  return;
728
  }
729
 
730
- // Bail if no Akismet key is set
731
  if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) ) {
732
  return;
733
  }
@@ -735,7 +732,7 @@ function bp_activity_setup_akismet() {
735
  /**
736
  * Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
737
  *
738
- * @since BuddyPress (1.6.0)
739
  *
740
  * @param bool $value Return value of bp_is_akismet_active boolean function.
741
  */
@@ -743,14 +740,14 @@ function bp_activity_setup_akismet() {
743
  return;
744
  }
745
 
746
- // Instantiate Akismet for BuddyPress
747
  $bp->activity->akismet = new BP_Akismet();
748
  }
749
 
750
  /**
751
  * AJAX endpoint for Suggestions API lookups.
752
  *
753
- * @since BuddyPress (2.1.0)
754
  */
755
  function bp_ajax_get_suggestions() {
756
  if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) {
@@ -782,7 +779,7 @@ add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
782
  /**
783
  * Detect a change in post type status, and initiate an activity update if necessary.
784
  *
785
- * @since BuddyPress (2.2.0)
786
  *
787
  * @todo Support untrashing better.
788
  *
@@ -816,7 +813,7 @@ function bp_activity_catch_transition_post_type_status( $new_status, $old_status
816
  * This is a variable filter that is dependent on the post type
817
  * being untrashed.
818
  *
819
- * @since BuddyPress (2.2.0)
820
  *
821
  * @param WP_Post $post Post data.
822
  */
@@ -828,7 +825,7 @@ function bp_activity_catch_transition_post_type_status( $new_status, $old_status
828
 
829
  // Unpublishing a previously published post.
830
  } elseif ( 'publish' === $old_status ) {
831
- // Some form of pending status - only remove the activity entry
832
  bp_activity_post_type_unpublish( $post->ID, $post );
833
  }
834
  }
1
  <?php
 
2
  /**
3
  * Action functions are exactly the same as screen functions, however they do
4
  * not have a template screen associated with them. Usually they will send the
8
  * @subpackage ActivityActions
9
  */
10
 
11
+ // Exit if accessed directly.
12
  defined( 'ABSPATH' ) || exit;
13
 
14
  /**
15
  * Allow core components and dependent plugins to register activity actions.
16
  *
17
+ * @since 1.2.0
18
  *
19
  * @uses do_action() To call 'bp_register_activity_actions' hook.
20
  */
23
  /**
24
  * Fires on bp_init to allow core components and dependent plugins to register activity actions.
25
  *
26
+ * @since 1.2.0
27
  */
28
  do_action( 'bp_register_activity_actions' );
29
  }
32
  /**
33
  * Catch and route requests for single activity item permalinks.
34
  *
35
+ * @since 1.2.0
36
  *
37
  * @uses bp_is_activity_component()
38
  * @uses bp_is_current_action()
50
  */
51
  function bp_activity_action_permalink_router() {
52
 
53
+ // Not viewing activity.
54
  if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) )
55
  return false;
56
 
57
+ // No activity to display.
58
  if ( ! bp_action_variable( 0 ) || ! is_numeric( bp_action_variable( 0 ) ) )
59
  return false;
60
 
61
+ // Get the activity details.
62
  $activity = bp_activity_get_specific( array( 'activity_ids' => bp_action_variable( 0 ), 'show_hidden' => true ) );
63
 
64
  // 404 if activity does not exist
69
  $activity = $activity['activities'][0];
70
  }
71
 
72
+ // Do not redirect at default.
73
  $redirect = false;
74
 
75
+ // Redirect based on the type of activity.
76
  if ( bp_is_active( 'groups' ) && $activity->component == buddypress()->groups->id ) {
77
 
78
+ // Activity is a user update.
79
  if ( ! empty( $activity->user_id ) ) {
80
  $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
81
 
82
+ // Activity is something else.
83
  } else {
84
 
85
+ // Set redirect to group activity stream.
86
  if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
87
  $redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
88
  }
89
  }
90
 
91
+ // Set redirect to users' activity stream.
92
  } elseif ( ! empty( $activity->user_id ) ) {
93
  $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
94
  }
95
 
96
+ // If set, add the original query string back onto the redirect URL.
97
  if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
98
  $query_frags = array();
99
  wp_parse_str( $_SERVER['QUERY_STRING'], $query_frags );
103
  /**
104
  * Filter the intended redirect url before the redirect occurs for the single activity item.
105
  *
106
+ * @since 1.2.2
107
  *
108
  * @param array Array with url to redirect to and activity related to the redirect.
109
  */
111
  bp_core_redirect( bp_get_root_domain() );
112
  }
113
 
114
+ // Redirect to the actual activity permalink page.
115
  bp_core_redirect( $redirect );
116
  }
117
  add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
119
  /**
120
  * Delete specific activity item and redirect to previous page.
121
  *
122
+ * @since 1.1.0
 
 
123
  *
124
  * @uses bp_is_activity_component()
125
  * @uses bp_is_current_action()
132
  * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
133
  * @uses bp_core_redirect()
134
  *
135
+ * @param int $activity_id Activity id to be deleted. Defaults to 0.
136
  * @return bool False on failure.
137
  */
138
  function bp_activity_action_delete_activity( $activity_id = 0 ) {
139
 
140
+ // Not viewing activity or action is not delete.
141
  if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
142
  return false;
143
 
144
  if ( empty( $activity_id ) && bp_action_variable( 0 ) )
145
  $activity_id = (int) bp_action_variable( 0 );
146
 
147
+ // Not viewing a specific activity item.
148
  if ( empty( $activity_id ) )
149
  return false;
150
 
151
+ // Check the nonce.
152
  check_admin_referer( 'bp_activity_delete_link' );
153
 
154
+ // Load up the activity item.
155
  $activity = new BP_Activity_Activity( $activity_id );
156
 
157
+ // Check access.
158
  if ( ! bp_activity_user_can_delete( $activity ) )
159
  return false;
160
 
161
  /**
162
  * Fires before the deletion so plugins can still fetch information about it.
163
  *
164
+ * @since 1.5.0
165
  *
166
  * @param int $activity_id The activity ID.
167
  * @param int $user_id The user associated with the activity.
168
  */
169
  do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
170
 
171
+ // Delete the activity item and provide user feedback.
172
  if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) )
173
  bp_core_add_message( __( 'Activity deleted successfully', 'buddypress' ) );
174
  else
177
  /**
178
  * Fires after the deletion so plugins can act afterwards based on the activity.
179
  *
180
+ * @since 1.1.0
181
  *
182
  * @param int $activity_id The activity ID.
183
  * @param int $user_id The user associated with the activity.
184
  */
185
  do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
186
 
187
+ // Check for the redirect query arg, otherwise let WP handle things.
188
  if ( !empty( $_GET['redirect_to'] ) )
189
  bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
190
  else
195
  /**
196
  * Mark specific activity item as spam and redirect to previous page.
197
  *
198
+ * @since 1.6.0
199
  *
200
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
 
201
  * @return bool False on failure.
202
  */
203
  function bp_activity_action_spam_activity( $activity_id = 0 ) {
204
  $bp = buddypress();
205
 
206
+ // Not viewing activity, or action is not spam, or Akismet isn't present.
207
  if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
208
  return false;
209
 
210
  if ( empty( $activity_id ) && bp_action_variable( 0 ) )
211
  $activity_id = (int) bp_action_variable( 0 );
212
 
213
+ // Not viewing a specific activity item.
214
  if ( empty( $activity_id ) )
215
  return false;
216
 
218
  if ( !bp_activity_user_can_mark_spam() )
219
  return false;
220
 
221
+ // Load up the activity item.
222
  $activity = new BP_Activity_Activity( $activity_id );
223
  if ( empty( $activity->id ) )
224
  return false;
225
 
226
+ // Check nonce.
227
  check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
228
 
229
  /**
230
  * Fires before the marking activity as spam so plugins can modify things if they want to.
231
  *
232
+ * @since 1.6.0
233
  *
234
  * @param int $activity_id Activity ID to be marked as spam.
235
  * @param object $activity Activity object for the ID to be marked as spam.
236
  */
237
  do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
238
 
239
+ // Mark as spam.
240
  bp_activity_mark_as_spam( $activity );
241
  $activity->save();
242
 
243
+ // Tell the user the spamming has been successful.
244
  bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
245
 
246
  /**
247
  * Fires after the marking activity as spam so plugins can act afterwards based on the activity.
248
  *
249
+ * @since 1.6.0
250
  *
251
  * @param int $activity_id Activity ID that was marked as spam.
252
  * @param int $user_id User ID associated with activity.
253
  */
254
  do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
255
 
256
+ // Check for the redirect query arg, otherwise let WP handle things.
257
  if ( !empty( $_GET['redirect_to'] ) )
258
  bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
259
  else
264
  /**
265
  * Post user/group activity update.
266
  *
267
+ * @since 1.2.0
268
  *
269
  * @uses is_user_logged_in()
270
  * @uses bp_is_activity_component()
284
  */
285
  function bp_activity_action_post_update() {
286
 
287
+ // Do not proceed if user is not logged in, not viewing activity, or not posting.
288
  if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
289
  return false;
290
 
291
+ // Check the nonce.
292
  check_admin_referer( 'post_update', '_wpnonce_post_update' );
293
 
294
  /**
295
  * Filters the content provided in the activity input field.
296
  *
297
+ * @since 1.2.0
298
  *
299
  * @param string $value Activity message being posted.
300
  */
305
  /**
306
  * Filters the item type that the activity update should be associated with.
307
  *
308
+ * @since 1.2.0
309
  *
310
  * @param string $value Item type to associate with.
311
  */
317
  /**
318
  * Filters what component the activity is being to.
319
  *
320
+ * @since 1.2.0
321
  *
322
  * @param string $value Chosen component to post activity to.
323
  */
324
  $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
325
  }
326
 
327
+ // No activity content so provide feedback and redirect.
328
  if ( empty( $content ) ) {
329
  bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
330
  bp_core_redirect( wp_get_referer() );
331
  }
332
 
333
+ // No existing item_id.
334
  if ( empty( $item_id ) ) {
335
  $activity_id = bp_activity_post_update( array( 'content' => $content ) );
336
 
337
+ // Post to groups object.
338
  } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) {
339
  if ( (int) $item_id ) {
340
  $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
345
  /**
346
  * Filters activity object for BuddyPress core and plugin authors before posting activity update.
347
  *
348
+ * @since 1.2.0
349
  *
350
  * @param string $object Activity item being associated to.
351
  * @param string $item_id Component ID being posted to.
354
  $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
355
  }
356
 
357
+ // Provide user feedback.
358
  if ( !empty( $activity_id ) )
359
  bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
360
  else
361
  bp_core_add_message( __( 'There was an error when posting your update. Please try again.', 'buddypress' ), 'error' );
362
 
363
+ // Redirect.
364
  bp_core_redirect( wp_get_referer() );
365
  }
366
  add_action( 'bp_actions', 'bp_activity_action_post_update' );
368
  /**
369
  * Post new activity comment.
370
  *
371
+ * @since 1.2.0
372
  *
373
  * @uses is_user_logged_in()
374
  * @uses bp_is_activity_component()
388
  if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'reply' ) )
389
  return false;
390
 
391
+ // Check the nonce.
392
  check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
393
 
394
  /**
395
  * Filters the activity ID a comment will be in reply to.
396
  *
397
+ * @since 1.2.0
398
  *
399
  * @param string $value ID of the activity being replied to.
400
  */
403
  /**
404
  * Filters the comment content for a comment reply.
405
  *
406
+ * @since 1.2.0
407
  *
408
  * @param string $value Comment content being posted.
409
  */
432
  /**
433
  * Mark activity as favorite.
434
  *
435
+ * @since 1.2.0
436
  *
437
  * @uses is_user_logged_in()
438
  * @uses bp_is_activity_component()
451
  if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'favorite' ) )
452
  return false;
453
 
454
+ // Check the nonce.
455
  check_admin_referer( 'mark_favorite' );
456
 
457
  if ( bp_activity_add_user_favorite( bp_action_variable( 0 ) ) )
466
  /**
467
  * Remove activity from favorites.
468
  *
469
+ * @since 1.2.0
470
  *
471
  * @uses is_user_logged_in()
472
  * @uses bp_is_activity_component()
485
  if ( ! is_user_logged_in() || ! bp_is_activity_component() || ! bp_is_current_action( 'unfavorite' ) )
486
  return false;
487
 
488
+ // Check the nonce.
489
  check_admin_referer( 'unmark_favorite' );
490
 
491
  if ( bp_activity_remove_user_favorite( bp_action_variable( 0 ) ) )
500
  /**
501
  * Load the sitewide activity feed.
502
  *
503
+ * @since 1.0.0
504
  *
505
  * @uses bp_is_activity_component()
506
  * @uses bp_is_current_action()
515
  if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
516
  return false;
517
 
518
+ // Setup the feed.
519
  buddypress()->activity->feed = new BP_Activity_Feed( array(
520
  'id' => 'sitewide',
521
 
532
  /**
533
  * Load a user's personal activity feed.
534
  *
535
+ * @since 1.0.0
536
  *
537
  * @uses bp_is_user_activity()
538
  * @uses bp_is_current_action()
545
  return false;
546
  }
547
 
548
+ // Setup the feed.
549
  buddypress()->activity->feed = new BP_Activity_Feed( array(
550
  'id' => 'personal',
551
 
562
  /**
563
  * Load a user's friends' activity feed.
564
  *
565
+ * @since 1.0.0
566
  *
567
  * @uses bp_is_active()
568
  * @uses bp_is_user_activity()
578
  return false;
579
  }
580
 
581
+ // Setup the feed.
582
  buddypress()->activity->feed = new BP_Activity_Feed( array(
583
  'id' => 'friends',
584
 
595
  /**
596
  * Load the activity feed for a user's groups.
597
  *
598
+ * @since 1.2.0
599
  *
600
  * @uses bp_is_active()
601
  * @uses bp_is_user_activity()
611
  return false;
612
  }
613
 
614
+ // Get displayed user's group IDs.
615
  $groups = groups_get_user_groups();
616
  $group_ids = implode( ',', $groups['groups'] );
617
 
618
+ // Setup the feed.
619
  buddypress()->activity->feed = new BP_Activity_Feed( array(
620
  'id' => 'mygroups',
621
 
636
  /**
637
  * Load a user's @mentions feed.
638
  *
639
+ * @since 1.2.0
640
  *
641
  * @uses bp_is_user_activity()
642
  * @uses bp_is_current_action()
654
  return false;
655
  }
656
 
657
+ // Setup the feed.
658
  buddypress()->activity->feed = new BP_Activity_Feed( array(
659
  'id' => 'mentions',
660
 
673
  /**
674
  * Load a user's favorites feed.
675
  *
676
+ * @since 1.2.0
677
  *
678
  * @uses bp_is_user_activity()
679
  * @uses bp_is_current_action()
687
  return false;
688
  }
689
 
690
+ // Get displayed user's favorite activity IDs.
691
  $favs = bp_activity_get_user_favorites( bp_displayed_user_id() );
692
  $fav_ids = implode( ',', (array) $favs );
693
 
694
+ // Setup the feed.
695
  buddypress()->activity->feed = new BP_Activity_Feed( array(
696
  'id' => 'favorites',
697
 
708
  /**
709
  * Loads Akismet filtering for activity.
710
  *
711
+ * @since 1.6.0
712
+ * @since 2.3.0 We only support Akismet 3+.
713
  */
714
  function bp_activity_setup_akismet() {
715
  $bp = buddypress();
716
 
717
+ // Bail if Akismet is not active.
718
  if ( ! defined( 'AKISMET_VERSION' ) ) {
719
  return;
720
  }
721
 
722
+ // Bail if older version of Akismet.
723
  if ( ! class_exists( 'Akismet' ) ) {
724
  return;
725
  }
726
 
727
+ // Bail if no Akismet key is set.
728
  if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) ) {
729
  return;
730
  }
732
  /**
733
  * Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
734
  *
735
+ * @since 1.6.0
736
  *
737
  * @param bool $value Return value of bp_is_akismet_active boolean function.
738
  */
740
  return;
741
  }
742
 
743
+ // Instantiate Akismet for BuddyPress.
744
  $bp->activity->akismet = new BP_Akismet();
745
  }
746
 
747
  /**
748
  * AJAX endpoint for Suggestions API lookups.
749
  *
750
+ * @since 2.1.0
751
  */
752
  function bp_ajax_get_suggestions() {
753
  if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) {
779
  /**
780
  * Detect a change in post type status, and initiate an activity update if necessary.
781
  *
782
+ * @since 2.2.0
783
  *
784
  * @todo Support untrashing better.
785
  *
813
  * This is a variable filter that is dependent on the post type
814
  * being untrashed.
815
  *
816
+ * @since 2.2.0
817
  *
818
  * @param WP_Post $post Post data.
819
  */
825
 
826
  // Unpublishing a previously published post.
827
  } elseif ( 'publish' === $old_status ) {
828
+ // Some form of pending status - only remove the activity entry.
829
  bp_activity_post_type_unpublish( $post->ID, $post );
830
  }
831
  }
bp-activity/bp-activity-admin.php CHANGED
@@ -6,28 +6,28 @@
6
  * help text, on which this implementation is heavily based.
7
  *
8
  * @package BuddyPress
9
- * @since BuddyPress (1.6.0)
10
- * @subpackage Activity
11
  */
12
 
13
- // Exit if accessed directly
14
  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
  * Register the Activity component admin screen.
25
  *
26
- * @since BuddyPress (1.6)
27
  */
28
  function bp_activity_add_admin_menu() {
29
 
30
- // Add our screen
31
  $hook = add_menu_page(
32
  _x( 'Activity', 'Admin Dashbord SWA page title', 'buddypress' ),
33
  _x( 'Activity', 'Admin Dashbord SWA menu', 'buddypress' ),
@@ -49,10 +49,9 @@ add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
49
  * which all appear together in the middle of the Dashboard menu. This function
50
  * adds the Activity page to the array of these menu items.
51
  *
52
- * @since BuddyPress (1.7.0)
53
  *
54
  * @param array $custom_menus The list of top-level BP menu items.
55
- *
56
  * @return array $custom_menus List of top-level BP menu items, with Activity added.
57
  */
58
  function bp_activity_admin_menu_order( $custom_menus = array() ) {
@@ -67,10 +66,10 @@ add_filter( 'bp_admin_menu_order', 'bp_activity_admin_menu_order' );
67
  * Processes requests to add new activity comments, and echoes HTML for a new
68
  * table row.
69
  *
70
- * @since BuddyPress (1.6.0)
71
  */
72
  function bp_activity_admin_reply() {
73
- // Check nonce
74
  check_ajax_referer( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply' );
75
 
76
  $parent_id = ! empty( $_REQUEST['parent_id'] ) ? (int) $_REQUEST['parent_id'] : 0;
@@ -80,15 +79,15 @@ function bp_activity_admin_reply() {
80
  if ( empty( $parent_id ) )
81
  die( '-1' );
82
 
83
- // If $root_id not set (e.g. for root items), use $parent_id
84
  if ( empty( $root_id ) )
85
  $root_id = $parent_id;
86
 
87
- // Check that a reply has been entered
88
  if ( empty( $_REQUEST['content'] ) )
89
  die( __( 'ERROR: Please type a reply.', 'buddypress' ) );
90
 
91
- // Check parent activity exists
92
  $parent_activity = new BP_Activity_Activity( $parent_id );
93
  if ( empty( $parent_activity->component ) )
94
  die( __( 'ERROR: The item you are trying to reply to cannot be found, or it has been deleted.', 'buddypress' ) );
@@ -98,25 +97,25 @@ function bp_activity_admin_reply() {
98
  if ( ! current_user_can( 'bp_moderate' ) )
99
  die( '-1' );
100
 
101
- // Add new activity comment
102
  $new_activity_id = bp_activity_new_comment( array(
103
- 'activity_id' => $root_id, // ID of the root activity item
104
  'content' => $_REQUEST['content'],
105
- 'parent_id' => $parent_id, // ID of a parent comment
106
  ) );
107
 
108
- // Fetch the new activity item, as we need it to create table markup to return
109
  $new_activity = new BP_Activity_Activity( $new_activity_id );
110
 
111
- // This needs to be set for the BP_Activity_List_Table constructor to work
112
  set_current_screen( 'toplevel_page_bp-activity' );
113
 
114
- // Set up an output buffer
115
  ob_start();
116
  $list_table = new BP_Activity_List_Table();
117
  $list_table->single_row( (array) $new_activity );
118
 
119
- // Get table markup
120
  $response = array(
121
  'data' => ob_get_contents(),
122
  'id' => $new_activity_id,
@@ -125,7 +124,7 @@ function bp_activity_admin_reply() {
125
  );
126
  ob_end_clean();
127
 
128
- // Send response
129
  $r = new WP_Ajax_Response();
130
  $r->add( $response );
131
  $r->send();
@@ -137,19 +136,18 @@ add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
137
  /**
138
  * Handle save/update of screen options for the Activity component admin screen.
139
  *
140
- * @since BuddyPress (1.6.0)
141
  *
142
  * @param string $value Will always be false unless another plugin filters it first.
143
  * @param string $option Screen option name.
144
  * @param string $new_value Screen option form value.
145
- *
146
  * @return string Option value. False to abandon update.
147
  */
148
  function bp_activity_admin_screen_options( $value, $option, $new_value ) {
149
  if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option )
150
  return $value;
151
 
152
- // Per page
153
  $new_value = (int) $new_value;
154
  if ( $new_value < 1 || $new_value > 999 )
155
  return $value;
@@ -160,24 +158,23 @@ function bp_activity_admin_screen_options( $value, $option, $new_value ) {
160
  /**
161
  * Hide the advanced edit meta boxes by default, so we don't clutter the screen.
162
  *
163
- * @since BuddyPress (1.6.0)
164
  *
165
  * @param array $hidden Array of items to hide.
166
  * @param WP_Screen $screen Screen identifier.
167
- *
168
  * @return array Hidden Meta Boxes.
169
  */
170
  function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
171
  if ( empty( $screen->id ) || 'toplevel_page_bp-activity' != $screen->id && 'toplevel_page_bp-activity_network' != $screen->id )
172
  return $hidden;
173
 
174
- // Hide the primary link meta box by default
175
  $hidden = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) );
176
 
177
  /**
178
  * Filters default hidden metaboxes so plugins can alter list.
179
  *
180
- * @since BuddyPress (1.6.0)
181
  *
182
  * @param array $hidden Default metaboxes to hide.
183
  * @param WP_Screen $screen Screen identifier.
@@ -194,7 +191,7 @@ add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxe
194
  * - Enqueues scripts and styles.
195
  * - Catches POST and GET requests related to Activity.
196
  *
197
- * @since BuddyPress (1.6.0)
198
  *
199
  * @global object $bp BuddyPress global settings.
200
  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
@@ -204,7 +201,7 @@ function bp_activity_admin_load() {
204
 
205
  $bp = buddypress();
206
 
207
- // Decide whether to load the dev version of the CSS and JavaScript
208
  $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : 'min.';
209
 
210
  $doaction = bp_admin_list_table_current_bulk_action();
@@ -212,15 +209,15 @@ function bp_activity_admin_load() {
212
  /**
213
  * Fires at top of Activity admin page.
214
  *
215
- * @since BuddyPress (1.6.0)
216
  *
217
  * @param string $doaction Current $_GET action being performed in admin screen.
218
  */
219
  do_action( 'bp_activity_admin_load', $doaction );
220
 
221
- // Edit screen
222
  if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) {
223
- // columns screen option
224
  add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) );
225
 
226
  get_current_screen()->add_help_tab( array(
@@ -242,7 +239,7 @@ function bp_activity_admin_load() {
242
  '<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>'
243
  ) );
244
 
245
- // Help panel - sidebar links
246
  get_current_screen()->set_help_sidebar(
247
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
248
  '<p>' . __( '<a href="https://codex.buddypress.org/administrator-guide/activity-stream-management-panels/">Managing Activity</a>', 'buddypress' ) . '</p>' .
@@ -256,20 +253,27 @@ function bp_activity_admin_load() {
256
  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' );
257
  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' );
258
 
259
- // Enqueue JavaScript files
 
 
 
 
 
 
 
260
  wp_enqueue_script( 'postbox' );
261
  wp_enqueue_script( 'dashboard' );
262
  wp_enqueue_script( 'comment' );
263
 
264
- // Index screen
265
  } else {
266
- // Create the Activity screen list table
267
  $bp_activity_list_table = new BP_Activity_List_Table();
268
 
269
- // per_page screen option
270
  add_screen_option( 'per_page', array( 'label' => _x( 'Activity', 'Activity items per page (screen options)', 'buddypress' )) );
271
 
272
- // Help panel - overview text
273
  get_current_screen()->add_help_tab( array(
274
  'id' => 'bp-activity-overview',
275
  'title' => __( 'Overview', 'buddypress' ),
@@ -278,7 +282,7 @@ function bp_activity_admin_load() {
278
  '<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>'
279
  ) );
280
 
281
- // Help panel - moderation text
282
  get_current_screen()->add_help_tab( array(
283
  'id' => 'bp-activity-moderating',
284
  'title' => __( 'Moderating Activity', 'buddypress' ),
@@ -287,14 +291,14 @@ function bp_activity_admin_load() {
287
  '<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>'
288
  ) );
289
 
290
- // Help panel - sidebar links
291
  get_current_screen()->set_help_sidebar(
292
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
293
  '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
294
  );
295
  }
296
 
297
- // Enqueue CSS and JavaScript
298
  wp_enqueue_script( 'bp_activity_admin_js', $bp->plugin_url . "bp-activity/admin/js/admin.{$min}js", array( 'jquery', 'wp-ajax-response' ), bp_get_version(), true );
299
  wp_localize_script( 'bp_activity_admin_js', 'bp_activity_admin_vars', array(
300
  'page' => get_current_screen()->id
@@ -306,21 +310,27 @@ function bp_activity_admin_load() {
306
  wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min );
307
  }
308
 
 
 
 
 
 
 
309
 
310
- // Handle spam/un-spam/delete of activities
311
  if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
312
 
313
- // Build redirection URL
314
  $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() );
315
  $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to );
316
 
317
- // Get activity IDs
318
  $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
319
 
320
  /**
321
  * Filters list of IDs being spammed/un-spammed/deleted.
322
  *
323
- * @since BuddyPress (1.6.0)
324
  *
325
  * @param array $activity_ids Activity IDs to spam/un-spam/delete.
326
  */
@@ -328,32 +338,32 @@ function bp_activity_admin_load() {
328
 
329
  // Is this a bulk request?
330
  if ( 'bulk_' == substr( $doaction, 0, 5 ) && ! empty( $_REQUEST['aid'] ) ) {
331
- // Check this is a valid form submission
332
  check_admin_referer( 'bulk-activities' );
333
 
334
- // Trim 'bulk_' off the action name to avoid duplicating a ton of code
335
  $doaction = substr( $doaction, 5 );
336
 
337
  // This is a request to delete, spam, or un-spam, a single item.
338
  } elseif ( !empty( $_REQUEST['aid'] ) ) {
339
 
340
- // Check this is a valid form submission
341
  check_admin_referer( 'spam-activity_' . $activity_ids[0] );
342
  }
343
 
344
- // Initialise counters for how many of each type of item we perform an action on
345
  $deleted = $spammed = $unspammed = 0;
346
 
347
- // Store any errors that occurs when updating the database items
348
  $errors = array();
349
 
350
  // "We'd like to shoot the monster, could you move, please?"
351
  foreach ( $activity_ids as $activity_id ) {
352
  // @todo: Check the permissions on each
353
  //if ( ! current_user_can( 'bp_edit_activity', $activity_id ) )
354
- // continue;
355
 
356
- // Get the activity from the database
357
  $activity = new BP_Activity_Activity( $activity_id );
358
  if ( empty( $activity->component ) ) {
359
  $errors[] = $activity_id;
@@ -381,7 +391,7 @@ function bp_activity_admin_load() {
381
  bp_activity_mark_as_ham( $activity );
382
  $result = $activity->save();
383
 
384
- // Check for any error during activity save
385
  if ( ! $result )
386
  $errors[] = $activity->id;
387
  else
@@ -392,7 +402,7 @@ function bp_activity_admin_load() {
392
  bp_activity_mark_as_spam( $activity );
393
  $result = $activity->save();
394
 
395
- // Check for any error during activity save
396
  if ( ! $result )
397
  $errors[] = $activity->id;
398
  else
@@ -403,7 +413,7 @@ function bp_activity_admin_load() {
403
  break;
404
  }
405
 
406
- // Release memory
407
  unset( $activity );
408
  }
409
 
@@ -412,7 +422,7 @@ function bp_activity_admin_load() {
412
  *
413
  * Passes an activity array counts how many were spam, not spam, deleted, and IDs that were errors.
414
  *
415
- * @since BuddyPress (1.6.0)
416
  *
417
  * @param array $value Array holding spam, not spam, deleted counts, error IDs.
418
  * @param string $redirect_to URL to redirect to.
@@ -430,14 +440,14 @@ function bp_activity_admin_load() {
430
  if ( $deleted )
431
  $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
432
 
433
- // If an error occurred, pass back the activity ID that failed
434
  if ( ! empty( $errors ) )
435
  $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to );
436
 
437
  /**
438
  * Filters redirect URL after activity spamming/un-spamming/deletion occurs.
439
  *
440
- * @since BuddyPress (1.6.0)
441
  *
442
  * @param string $redirect_to URL to redirect to.
443
  */
@@ -445,73 +455,72 @@ function bp_activity_admin_load() {
445
  exit;
446
 
447
 
448
- // Save the edit
449
  } elseif ( $doaction && 'save' == $doaction ) {
450
- // Build redirection URL
451
  $redirect_to = remove_query_arg( array( 'action', 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
452
 
453
- // Get activity ID
454
  $activity_id = (int) $_REQUEST['aid'];
455
 
456
- // Check this is a valid form submission
457
  check_admin_referer( 'edit-activity_' . $activity_id );
458
 
459
- // Get the activity from the database
460
  $activity = new BP_Activity_Activity( $activity_id );
461
 
462
- // If the activity doesn't exist, just redirect back to the index
463
  if ( empty( $activity->component ) ) {
464
  wp_redirect( $redirect_to );
465
  exit;
466
  }
467
 
468
- // Check the form for the updated properties
469
-
470
- // Store any error that occurs when updating the database item
471
  $error = 0;
472
 
473
- // Activity spam status
474
  $prev_spam_status = $new_spam_status = false;
475
  if ( ! empty( $_POST['activity_status'] ) ) {
476
  $prev_spam_status = $activity->is_spam;
477
  $new_spam_status = ( 'spam' == $_POST['activity_status'] ) ? true : false;
478
  }
479
 
480
- // Activity action
481
  if ( isset( $_POST['bp-activities-action'] ) )
482
  $activity->action = $_POST['bp-activities-action'];
483
 
484
- // Activity content
485
  if ( isset( $_POST['bp-activities-content'] ) )
486
  $activity->content = $_POST['bp-activities-content'];
487
 
488
- // Activity primary link
489
  if ( ! empty( $_POST['bp-activities-link'] ) )
490
  $activity->primary_link = $_POST['bp-activities-link'];
491
 
492
- // Activity user ID
493
  if ( ! empty( $_POST['bp-activities-userid'] ) )
494
  $activity->user_id = (int) $_POST['bp-activities-userid'];
495
 
496
- // Activity item primary ID
497
  if ( isset( $_POST['bp-activities-primaryid'] ) )
498
  $activity->item_id = (int) $_POST['bp-activities-primaryid'];
499
 
500
- // Activity item secondary ID
501
  if ( isset( $_POST['bp-activities-secondaryid'] ) )
502
  $activity->secondary_item_id = (int) $_POST['bp-activities-secondaryid'];
503
 
504
- // Activity type
505
  if ( ! empty( $_POST['bp-activities-type'] ) ) {
506
  $actions = bp_activity_admin_get_activity_actions();
507
 
508
- // Check that the new type is a registered activity type
509
  if ( in_array( $_POST['bp-activities-type'], $actions ) ) {
510
  $activity->type = $_POST['bp-activities-type'];
511
  }
512
  }
513
 
514
- // Activity timestamp
515
  if ( ! empty( $_POST['aa'] ) && ! empty( $_POST['mm'] ) && ! empty( $_POST['jj'] ) && ! empty( $_POST['hh'] ) && ! empty( $_POST['mn'] ) && ! empty( $_POST['ss'] ) ) {
516
  $aa = $_POST['aa'];
517
  $mm = $_POST['mm'];
@@ -527,7 +536,7 @@ function bp_activity_admin_load() {
527
  $mn = ( $mn > 59 ) ? $mn -60 : $mn;
528
  $ss = ( $ss > 59 ) ? $ss -60 : $ss;
529
 
530
- // Reconstruct the date into a timestamp
531
  $gmt_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
532
 
533
  $activity->date_recorded = $gmt_date;
@@ -541,26 +550,26 @@ function bp_activity_admin_load() {
541
  bp_activity_mark_as_ham( $activity );
542
  }
543
 
544
- // Save
545
  $result = $activity->save();
546
 
547
- // Clear the activity stream first page cache, in case this activity's timestamp was changed
548
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
549
 
550
- // Check for any error during activity save
551
  if ( false === $result )
552
  $error = $activity->id;
553
 
554
  /**
555
  * Fires before redirect so plugins can do something first on save action.
556
  *
557
- * @since BuddyPress (1.6.0)
558
  *
559
  * @param array Array holding activity object and ID that holds error.
560
  */
561
  do_action_ref_array( 'bp_activity_admin_edit_after', array( &$activity, $error ) );
562
 
563
- // If an error occurred, pass back the activity ID that failed
564
  if ( $error )
565
  $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
566
  else
@@ -569,7 +578,7 @@ function bp_activity_admin_load() {
569
  /**
570
  * Filters URL to redirect to after saving.
571
  *
572
- * @since BuddyPress (1.6.0)
573
  *
574
  * @param string $redirect_to URL to redirect to.
575
  */
@@ -587,17 +596,17 @@ function bp_activity_admin_load() {
587
  /**
588
  * Output the Activity component admin screens.
589
  *
590
- * @since BuddyPress (1.6.0)
591
  */
592
  function bp_activity_admin() {
593
- // Decide whether to load the index or edit screen
594
  $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
595
 
596
- // Display the single activity edit screen
597
  if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) )
598
  bp_activity_admin_edit();
599
 
600
- // Otherwise, display the Activity index screen
601
  else
602
  bp_activity_admin_index();
603
  }
@@ -605,7 +614,7 @@ function bp_activity_admin() {
605
  /**
606
  * Display the single activity edit screen.
607
  *
608
- * @since BuddyPress (1.6.0)
609
  */
610
  function bp_activity_admin_edit() {
611
 
@@ -614,7 +623,7 @@ function bp_activity_admin_edit() {
614
  if ( ! is_super_admin() )
615
  die( '-1' );
616
 
617
- // Get the activity from the database
618
  $activity = bp_activity_get( array(
619
  'in' => ! empty( $_REQUEST['aid'] ) ? (int) $_REQUEST['aid'] : 0,
620
  'max' => 1,
@@ -626,28 +635,27 @@ function bp_activity_admin_edit() {
626
  if ( ! empty( $activity['activities'][0] ) ) {
627
  $activity = $activity['activities'][0];
628
 
629
- // Workaround to use WP's touch_time() without duplicating that function
630
  $GLOBALS['comment'] = new stdClass;
631
  $GLOBALS['comment']->comment_date = $activity->date_recorded;
632
  } else {
633
  $activity = '';
634
  }
635
 
636
- // Construct URL for form
637
  $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
638
  $form_url = add_query_arg( 'action', 'save', $form_url );
639
 
640
  /**
641
  * Fires before activity edit form is displays so plugins can modify the activity.
642
  *
643
- * @since BuddyPress (1.6.0)
644
  *
645
  * @param array $value Array holding single activity object that was passed by reference.
646
  */
647
  do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
648
 
649
  <div class="wrap">
650
- <?php screen_icon( 'buddypress-activity' ); ?>
651
  <h2><?php printf( __( 'Editing Activity (ID #%s)', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?></h2>
652
 
653
  <?php if ( ! empty( $activity ) ) : ?>
@@ -702,7 +710,7 @@ function bp_activity_admin_edit() {
702
  /**
703
  * Status metabox for the Activity admin edit screen.
704
  *
705
- * @since BuddyPress (1.6.0)
706
  *
707
  * @param object $item Activity item.
708
  */
@@ -728,7 +736,7 @@ function bp_activity_admin_edit_metabox_status( $item ) {
728
 
729
  <div class="misc-pub-section curtime misc-pub-section-last">
730
  <?php
731
- // translators: Publish box date format, see http://php.net/date
732
  $datef = __( 'M j, Y @ G:i', 'buddypress' );
733
  $date = date_i18n( $datef, strtotime( $item->date_recorded ) );
734
  ?>
@@ -745,7 +753,7 @@ function bp_activity_admin_edit_metabox_status( $item ) {
745
 
746
  <div id="major-publishing-actions">
747
  <div id="publishing-action">
748
- <?php submit_button( __( 'Update', 'buddypress' ), 'primary', 'save', false, array( 'tabindex' => '4' ) ); ?>
749
  </div>
750
  <div class="clear"></div>
751
  </div><!-- #major-publishing-actions -->
@@ -758,7 +766,7 @@ function bp_activity_admin_edit_metabox_status( $item ) {
758
  /**
759
  * Primary link metabox for the Activity admin edit screen.
760
  *
761
- * @since BuddyPress (1.6.0)
762
  *
763
  * @param object $item Activity item.
764
  */
@@ -766,8 +774,8 @@ function bp_activity_admin_edit_metabox_link( $item ) {
766
  ?>
767
 
768
  <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label>
769
- <input type="url" name="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" />
770
- <p><?php _e( 'Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
771
 
772
  <?php
773
  }
@@ -775,7 +783,7 @@ function bp_activity_admin_edit_metabox_link( $item ) {
775
  /**
776
  * User ID metabox for the Activity admin edit screen.
777
  *
778
- * @since BuddyPress (1.6.0)
779
  *
780
  * @param object $item Activity item.
781
  */
@@ -783,7 +791,7 @@ function bp_activity_admin_edit_metabox_userid( $item ) {
783
  ?>
784
 
785
  <label class="screen-reader-text" for="bp-activities-userid"><?php _e( 'Author ID', 'buddypress' ); ?></label>
786
- <input type="number" name="bp-activities-userid" value="<?php echo esc_attr( $item->user_id ); ?>" min="1" />
787
 
788
  <?php
789
  }
@@ -793,9 +801,9 @@ function bp_activity_admin_edit_metabox_userid( $item ) {
793
  *
794
  * Format is [activity_type] => Pretty name for activity type.
795
  *
796
- * @since BuddyPress (2.0.0)
797
  *
798
- * @return array
799
  */
800
  function bp_activity_admin_get_activity_actions() {
801
  $actions = array();
@@ -809,10 +817,10 @@ function bp_activity_admin_get_activity_actions() {
809
  }
810
  }
811
 
812
- // This was a mis-named activity type from before BP 1.6
813
  unset( $actions['friends_register_activity_action'] );
814
 
815
- // Sort array by the human-readable value
816
  natsort( $actions );
817
 
818
  return $actions;
@@ -821,7 +829,7 @@ function bp_activity_admin_get_activity_actions() {
821
  /**
822
  * Activity type metabox for the Activity admin edit screen.
823
  *
824
- * @since BuddyPress (1.6.0)
825
  *
826
  * @param object $item Activity item.
827
  */
@@ -839,15 +847,17 @@ function bp_activity_admin_edit_metabox_type( $item ) {
839
  $actions[ $action[$i]['key'] ] = $action[$i]['value'];
840
  }
841
 
842
- // This was a mis-named activity type from before BP 1.6
843
  unset( $actions['friends_register_activity_action'] );
844
 
845
- // Sort array by the human-readable value
846
  natsort( $actions );
847
 
848
- // If the activity type is not registered properly (eg, a plugin has
849
- // not called bp_activity_set_action()), add the raw type to the end
850
- // of the list
 
 
851
  if ( ! isset( $actions[ $selected ] ) ) {
852
  _doing_it_wrong( __FUNCTION__, sprintf( __( 'This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', 'buddypress' ), $selected ), '2.0.0' );
853
  $actions[ $selected ] = $selected;
@@ -867,7 +877,7 @@ function bp_activity_admin_edit_metabox_type( $item ) {
867
  /**
868
  * Primary item ID/Secondary item ID metabox for the Activity admin edit screen.
869
  *
870
- * @since BuddyPress (1.6.0)
871
  *
872
  * @param object $item Activity item.
873
  */
@@ -889,7 +899,7 @@ function bp_activity_admin_edit_metabox_itemids( $item ) {
889
  /**
890
  * Display the Activity admin index screen, which contains a list of all the activities.
891
  *
892
- * @since BuddyPress (1.6.0)
893
  *
894
  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
895
  * @global string $plugin_page The current plugin page.
@@ -899,7 +909,7 @@ function bp_activity_admin_index() {
899
 
900
  $messages = array();
901
 
902
- // If the user has just made a change to an activity item, build status messages
903
  if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) {
904
  $deleted = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
905
  $errors = ! empty( $_REQUEST['error'] ) ? $_REQUEST['error'] : '';
@@ -909,14 +919,14 @@ function bp_activity_admin_index() {
909
 
910
  $errors = array_map( 'absint', explode( ',', $errors ) );
911
 
912
- // Make sure we don't get any empty values in $errors
913
  for ( $i = 0, $errors_count = count( $errors ); $i < $errors_count; $i++ ) {
914
  if ( 0 === $errors[$i] ) {
915
  unset( $errors[$i] );
916
  }
917
  }
918
 
919
- // Reindex array
920
  $errors = array_values( $errors );
921
 
922
  if ( $deleted > 0 )
@@ -930,9 +940,9 @@ function bp_activity_admin_index() {
930
  $error_msg = __( 'Errors occurred when trying to update these activity items:', 'buddypress' );
931
  $error_msg .= '<ul class="activity-errors">';
932
 
933
- // Display each error as a list item
934
  foreach ( $errors as $error ) {
935
- // Translators: This is a bulleted list of item IDs
936
  $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>';
937
  }
938
 
@@ -951,20 +961,19 @@ function bp_activity_admin_index() {
951
  $messages[] = __( 'The activity item has been updated successfully.', 'buddypress' );
952
  }
953
 
954
- // Prepare the activity items for display
955
  $bp_activity_list_table->prepare_items();
956
 
957
  /**
958
  * Fires before edit form is displayed so plugins can modify the activity messages.
959
  *
960
- * @since BuddyPress (1.6.0)
961
  *
962
  * @param array $messages Array of messages to display at top of page.
963
  */
964
  do_action( 'bp_activity_admin_index', $messages ); ?>
965
 
966
  <div class="wrap">
967
- <?php screen_icon( 'buddypress-activity' ); ?>
968
  <h2>
969
  <?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
970
  <?php printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
@@ -977,12 +986,12 @@ function bp_activity_admin_index() {
977
  <?php endif; ?>
978
  </h2>
979
 
980
- <?php // If the user has just made a change to an activity item, display the status messages ?>
981
  <?php if ( !empty( $messages ) ) : ?>
982
  <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
983
  <?php endif; ?>
984
 
985
- <?php // Display each activity on its own row ?>
986
  <?php $bp_activity_list_table->views(); ?>
987
 
988
  <form id="bp-activities-form" action="" method="get">
@@ -991,7 +1000,7 @@ function bp_activity_admin_index() {
991
  <?php $bp_activity_list_table->display(); ?>
992
  </form>
993
 
994
- <?php // This markup is used for the reply form ?>
995
  <table style="display: none;">
996
  <tr id="bp-activities-container" style="display: none;">
997
  <td colspan="4">
@@ -1023,55 +1032,54 @@ function bp_activity_admin_index() {
1023
  /**
1024
  * List table class for the Activity component admin page.
1025
  *
1026
- * @since BuddyPress (1.6.0)
1027
  */
1028
  class BP_Activity_List_Table extends WP_List_Table {
1029
 
1030
  /**
1031
  * What type of view is being displayed?
1032
  *
1033
- * e.g. "all", "pending", "approved", "spam"...
1034
  *
1035
- * @since BuddyPress (1.6.0)
1036
- * @var string
1037
  */
1038
  public $view = 'all';
1039
 
1040
  /**
1041
  * How many activity items have been marked as spam.
1042
  *
1043
- * @since BuddyPress (1.6.0)
1044
- * @var int
1045
  */
1046
  public $spam_count = 0;
1047
 
1048
  /**
1049
  * Store activity-to-user-ID mappings for use in the In Response To column.
1050
  *
1051
- * @since BuddyPress (1.6.0)
1052
- * @var array
1053
  */
1054
  protected $activity_user_id = array();
1055
 
1056
  /**
1057
  * If users can comment on blog & forum activity items.
1058
  *
1059
- * @since BuddyPress (2.2.2)
1060
- *
1061
  * @link https://buddypress.trac.wordpress.org/ticket/6277
1062
  *
1063
- * @var bool
 
1064
  */
1065
  public $disable_blogforum_comments = false;
1066
 
1067
  /**
1068
  * Constructor.
1069
  *
1070
- * @since BuddyPress (1.6.0)
1071
  */
1072
  public function __construct() {
1073
 
1074
- // See if activity commenting is enabled for blog / forum activity items
1075
  $this->disable_blogforum_comments = bp_disable_blogforum_comments();
1076
 
1077
  // Define singular and plural labels, as well as whether we support AJAX.
@@ -1086,38 +1094,38 @@ class BP_Activity_List_Table extends WP_List_Table {
1086
  /**
1087
  * Handle filtering of data, sorting, pagination, and any other data manipulation prior to rendering.
1088
  *
1089
- * @since BuddyPress (1.6.0)
1090
  */
1091
  function prepare_items() {
1092
 
1093
- // Option defaults
1094
  $filter = array();
1095
  $include_id = false;
1096
  $search_terms = false;
1097
  $sort = 'DESC';
1098
  $spam = 'ham_only';
1099
 
1100
- // Set current page
1101
  $page = $this->get_pagenum();
1102
 
1103
- // Set per page from the screen options
1104
  $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
1105
 
1106
- // Check if we're on the "Spam" view
1107
  if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
1108
  $spam = 'spam_only';
1109
  $this->view = 'spam';
1110
  }
1111
 
1112
- // Sort order
1113
  if ( !empty( $_REQUEST['order'] ) && 'desc' != $_REQUEST['order'] )
1114
  $sort = 'ASC';
1115
 
1116
- // Order by
1117
  /*if ( !empty( $_REQUEST['orderby'] ) ) {
1118
  }*/
1119
 
1120
- // Filter
1121
  if ( !empty( $_REQUEST['activity_type'] ) )
1122
  $filter = array( 'action' => $_REQUEST['activity_type'] );
1123
 
@@ -1129,7 +1137,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1129
  if ( !empty( $_REQUEST['aid'] ) )
1130
  $include_id = (int) $_REQUEST['aid'];
1131
 
1132
- // Get the spam total (ignoring any search query or filter)
1133
  $spams = bp_activity_get( array(
1134
  'display_comments' => 'stream',
1135
  'show_hidden' => true,
@@ -1139,7 +1147,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1139
  $this->spam_count = $spams['total'];
1140
  unset( $spams );
1141
 
1142
- // Get the activities from the database
1143
  $activities = bp_activity_get( array(
1144
  'display_comments' => 'stream',
1145
  'filter' => $filter,
@@ -1148,7 +1156,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1148
  'per_page' => $per_page,
1149
  'search_terms' => $search_terms,
1150
  'show_hidden' => true,
1151
- //'sort' => $sort,
1152
  'spam' => $spam,
1153
  'count_total' => 'count_query',
1154
  ) );
@@ -1158,23 +1166,23 @@ class BP_Activity_List_Table extends WP_List_Table {
1158
  $activities['activities'] = BP_Activity_List_Table::flatten_activity_array( $activities['activities'] );
1159
  $activities['total'] = count( $activities['activities'] );
1160
 
1161
- // Sort the array by the activity object's date_recorded value
1162
  usort( $activities['activities'], create_function( '$a, $b', 'return $a->date_recorded > $b->date_recorded;' ) );
1163
  }
1164
 
1165
- // bp_activity_get returns an array of objects; cast these to arrays for WP_List_Table.
1166
  $new_activities = array();
1167
  foreach ( $activities['activities'] as $activity_item ) {
1168
  $new_activities[] = (array) $activity_item;
1169
 
1170
- // Build an array of activity-to-user ID mappings for better efficiency in the In Response To column
1171
  $this->activity_user_id[$activity_item->id] = $activity_item->user_id;
1172
  }
1173
 
1174
- // Set raw data to display
1175
  $this->items = $new_activities;
1176
 
1177
- // Store information needed for handling table pagination
1178
  $this->set_pagination_args( array(
1179
  'per_page' => $per_page,
1180
  'total_items' => $activities['total'],
@@ -1188,7 +1196,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1188
  /**
1189
  * Get an array of all the columns on the page.
1190
  *
1191
- * @since BuddyPress (1.6.0)
1192
  *
1193
  * @return array Column headers.
1194
  */
@@ -1203,10 +1211,21 @@ class BP_Activity_List_Table extends WP_List_Table {
1203
  return $this->_column_headers;
1204
  }
1205
 
 
 
 
 
 
 
 
 
 
 
 
1206
  /**
1207
  * Display a message on screen when no items are found (e.g. no search matches).
1208
  *
1209
- * @since BuddyPress (1.6.0)
1210
  */
1211
  function no_items() {
1212
  _e( 'No activities found.', 'buddypress' );
@@ -1215,8 +1234,8 @@ class BP_Activity_List_Table extends WP_List_Table {
1215
  /**
1216
  * Output the Activity data table.
1217
  *
1218
- * @since BuddyPress (1.6.0)
1219
- */
1220
  function display() {
1221
  $this->display_tablenav( 'top' ); ?>
1222
 
@@ -1245,7 +1264,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1245
  /**
1246
  * Generate content for a single row of the table.
1247
  *
1248
- * @since BuddyPress (1.6.0)
1249
  *
1250
  * @param object $item The current item.
1251
  */
@@ -1274,7 +1293,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1274
  /**
1275
  * Get the list of views available on this table (e.g. "all", "spam").
1276
  *
1277
- * @since BuddyPress (1.6.0)
1278
  */
1279
  function get_views() {
1280
  $url_base = add_query_arg( array( 'page' => 'bp-activity' ), bp_get_admin_url( 'admin.php' ) ); ?>
@@ -1288,7 +1307,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1288
  /**
1289
  * Fires inside listing of views so plugins can add their own.
1290
  *
1291
- * @since BuddyPress (1.6.0)
1292
  *
1293
  * @param string $url_base Current URL base for view.
1294
  * @param string $view Current view being displayed.
@@ -1301,7 +1320,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1301
  /**
1302
  * Get bulk actions.
1303
  *
1304
- * @since BuddyPress (1.6.0)
1305
  *
1306
  * @return array Key/value pairs for the bulk actions dropdown.
1307
  */
@@ -1314,7 +1333,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1314
  /**
1315
  * Filters the default bulk actions so plugins can add custom actions.
1316
  *
1317
- * @since BuddyPress (1.6.0)
1318
  *
1319
  * @param array $actions Default available actions for bulk operations.
1320
  */
@@ -1324,20 +1343,27 @@ class BP_Activity_List_Table extends WP_List_Table {
1324
  /**
1325
  * Get the table column titles.
1326
  *
1327
- * @since BuddyPress (1.6.0)
1328
  *
1329
  * @see WP_List_Table::single_row_columns()
1330
  *
1331
  * @return array The columns to appear in the Activity list table.
1332
  */
1333
  function get_columns() {
1334
- return array(
 
 
 
 
 
 
 
1335
  'cb' => '<input name type="checkbox" />',
1336
  'author' => _x('Author', 'Admin SWA column header', 'buddypress' ),
1337
  'comment' => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
1338
  'action' => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
1339
  'response' => _x( 'In Response To', 'Admin SWA column header', 'buddypress' ),
1340
- );
1341
  }
1342
 
1343
  /**
@@ -1345,7 +1371,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1345
  *
1346
  * Currently, returns an empty array (no columns are sortable).
1347
  *
1348
- * @since BuddyPress (1.6.0)
1349
  * @todo For this to work, BP_Activity_Activity::get() needs updating
1350
  * to support ordering by specific fields.
1351
  *
@@ -1362,13 +1388,13 @@ class BP_Activity_List_Table extends WP_List_Table {
1362
  /**
1363
  * Markup for the "filter" part of the form (i.e. which activity type to display).
1364
  *
1365
- * @since BuddyPress (1.6.0)
1366
  *
1367
  * @param string $which 'top' or 'bottom'.
1368
  */
1369
  function extra_tablenav( $which ) {
1370
 
1371
- // Bail on bottom table nav
1372
  if ( 'bottom' === $which ) {
1373
  return;
1374
  }
@@ -1376,11 +1402,12 @@ class BP_Activity_List_Table extends WP_List_Table {
1376
  // Is any filter currently selected?
1377
  $selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : '';
1378
 
1379
- // Get the actions
1380
  $activity_actions = bp_activity_get_actions(); ?>
1381
 
1382
  <div class="alignleft actions">
1383
- <select name="activity_type">
 
1384
  <option value="" <?php selected( ! $selected ); ?>><?php _e( 'View all actions', 'buddypress' ); ?></option>
1385
 
1386
  <?php foreach ( $activity_actions as $component => $actions ) : ?>
@@ -1391,7 +1418,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1391
 
1392
  <?php
1393
 
1394
- // Skip the incorrectly named pre-1.6 action
1395
  if ( 'friends_register_activity_action' !== $action_key ) : ?>
1396
 
1397
  <option value="<?php echo esc_attr( $action_key ); ?>" <?php selected( $action_key, $selected ); ?>><?php echo esc_html( $action_values[ 'value' ] ); ?></option>
@@ -1421,8 +1448,8 @@ class BP_Activity_List_Table extends WP_List_Table {
1421
  * @since 2.3.3
1422
  * @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0.
1423
  *
1424
- * @param array $actions The list of actions
1425
- * @param bool $always_visible Whether the actions should be always visible
1426
  * @return string
1427
  */
1428
  public function row_actions( $actions, $always_visible = false ) {
@@ -1446,7 +1473,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1446
  /**
1447
  * Checkbox column markup.
1448
  *
1449
- * @since BuddyPress (1.6.0)
1450
  *
1451
  * @see WP_List_Table::single_row_columns()
1452
  *
@@ -1459,7 +1486,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1459
  /**
1460
  * Author column markup.
1461
  *
1462
- * @since BuddyPress (1.6.0)
1463
  *
1464
  * @see WP_List_Table::single_row_columns()
1465
  *
@@ -1472,7 +1499,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1472
  /**
1473
  * Action column markup.
1474
  *
1475
- * @since BuddyPress (2.0.0)
1476
  *
1477
  * @see WP_List_Table::single_row_columns()
1478
  *
@@ -1493,20 +1520,20 @@ class BP_Activity_List_Table extends WP_List_Table {
1493
  *
1494
  * Called "comment" in the CSS so we can re-use some WP core CSS.
1495
  *
1496
- * @since BuddyPress (1.6.0)
1497
  *
1498
  * @see WP_List_Table::single_row_columns()
1499
  *
1500
  * @param array $item A singular item (one full row).
1501
  */
1502
  function column_comment( $item ) {
1503
- // Determine what type of item (row) we're dealing with
1504
  if ( $item['is_spam'] )
1505
  $item_status = 'spam';
1506
  else
1507
  $item_status = 'all';
1508
 
1509
- // Preorder items: Reply | Edit | Spam | Delete Permanently
1510
  $actions = array(
1511
  'reply' => '',
1512
  'edit' => '',
@@ -1514,7 +1541,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1514
  'delete' => '',
1515
  );
1516
 
1517
- // Build actions URLs
1518
  $base_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1519
  $spam_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'spam-activity_' . $item['id'] ) );
1520
 
@@ -1523,8 +1550,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1523
  $ham_url = $base_url . "&amp;action=ham&amp;$spam_nonce";
1524
  $spam_url = $base_url . "&amp;action=spam&amp;$spam_nonce";
1525
 
1526
- // Rollover actions
1527
-
1528
  // Reply - JavaScript only; implemented by AJAX.
1529
  if ( 'spam' != $item_status ) {
1530
  if ( $this->can_comment( $item ) ) {
@@ -1533,26 +1559,26 @@ class BP_Activity_List_Table extends WP_List_Table {
1533
  $actions['reply'] = sprintf( '<span class="form-input-tip" title="%s">%s</span>', __( 'Replies are disabled for this activity item', 'buddypress' ), __( 'Replies disabled', 'buddypress' ) );
1534
  }
1535
 
1536
- // Edit
1537
  $actions['edit'] = sprintf( '<a href="%s">%s</a>', $edit_url, __( 'Edit', 'buddypress' ) );
1538
  }
1539
 
1540
- // Spam/unspam
1541
  if ( 'spam' == $item_status )
1542
  $actions['unspam'] = sprintf( '<a href="%s">%s</a>', $ham_url, __( 'Not Spam', 'buddypress' ) );
1543
  else
1544
  $actions['spam'] = sprintf( '<a href="%s">%s</a>', $spam_url, __( 'Spam', 'buddypress' ) );
1545
 
1546
- // Delete
1547
  $actions['delete'] = sprintf( '<a href="%s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js( __( 'Are you sure?', 'buddypress' ) ) . "'); ", __( 'Delete Permanently', 'buddypress' ) );
1548
 
1549
- // Start timestamp
1550
  echo '<div class="submitted-on">';
1551
 
1552
  /**
1553
  * Filters available actions for plugins to alter.
1554
  *
1555
- * @since BuddyPress (1.6.0)
1556
  *
1557
  * @param array $actions Array of available actions user could use.
1558
  * @param array $item Current item being added to page.
@@ -1560,18 +1586,23 @@ class BP_Activity_List_Table extends WP_List_Table {
1560
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1561
 
1562
  /* translators: 2: activity admin ui date/time */
1563
- printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>', 'buddypress' ), bp_activity_get_permalink( $item['id'] ), get_date_from_gmt( $item['date_recorded'], get_option( 'date_format' ) ), get_date_from_gmt( $item['date_recorded'], get_option( 'time_format' ) ) );
 
 
 
 
 
1564
 
1565
- // End timestamp
1566
  echo '</div>';
1567
 
1568
- // Get activity content - if not set, use the action
1569
  if ( ! empty( $item['content'] ) ) {
1570
 
1571
  /**
1572
  * Filters current activity item content.
1573
  *
1574
- * @since BuddyPress (1.2.0)
1575
  *
1576
  * @param array $item Array index holding current activity item content.
1577
  */
@@ -1580,26 +1611,35 @@ class BP_Activity_List_Table extends WP_List_Table {
1580
  /**
1581
  * Filters current activity item action.
1582
  *
1583
- * @since BuddyPress (1.2.0)
1584
  *
1585
  * @var array $item Array index holding current activity item action.
1586
  */
1587
  $content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'] ) );
1588
  }
1589
 
1590
- echo $content . ' ' . $this->row_actions( $actions );
 
 
 
 
 
 
 
 
1591
  }
1592
 
1593
  /**
1594
  * "In response to" column markup.
1595
  *
1596
- * @since BuddyPress (1.6.0)
1597
  *
1598
  * @see WP_List_Table::single_row_columns()
1599
  *
1600
  * @param array $item A singular item (one full row).
1601
  */
1602
  function column_response( $item ) {
 
1603
  // Is $item is a root activity?
1604
  ?>
1605
 
@@ -1615,7 +1655,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1615
  /**
1616
  * Filters default list of default root activity types.
1617
  *
1618
- * @since BuddyPress (1.6.0)
1619
  *
1620
  * @param array $value Array of default activity types.
1621
  * @param array $item Current item being displayed.
@@ -1626,13 +1666,13 @@ class BP_Activity_List_Table extends WP_List_Table {
1626
  $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
1627
  $root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1628
 
1629
- // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
1630
  if ( $comment_count ) {
1631
  $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
1632
  printf( '<a href="%1$s" title="%2$s" class="post-com-count post-com-count-approved"><span class="comment-count comment-count-approved">%3$s</span></a>', esc_url( $root_activity_url ), esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
1633
  }
1634
 
1635
- // For non-root activities, display a link to the replied-to activity's author's profile
1636
  } else {
1637
  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 />';
1638
  echo $activity_permalink;
@@ -1644,16 +1684,38 @@ class BP_Activity_List_Table extends WP_List_Table {
1644
  <?php
1645
  }
1646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1647
  /**
1648
  * Get the user id associated with a given activity item.
1649
  *
1650
  * Wraps bp_activity_get_specific(), with some additional logic for
1651
  * avoiding duplicate queries.
1652
  *
1653
- * @since BuddyPress (1.6.0)
1654
  *
1655
  * @param int $activity_id Activity ID to retrieve User ID for.
1656
- *
1657
  * @return int User ID of the activity item in question.
1658
  */
1659
  protected function get_activity_user_id( $activity_id ) {
@@ -1661,24 +1723,24 @@ class BP_Activity_List_Table extends WP_List_Table {
1661
  if ( ! empty( $this->activity_user_id[$activity_id] ) ) {
1662
  return $this->activity_user_id[$activity_id];
1663
 
1664
- /**
1665
  * We don't have a mapping. This means the $activity_id is not on the current
1666
  * page of results, so fetch its details from the database.
1667
  */
1668
  } else {
1669
  $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'show_hidden' => true, 'spam' => 'all', ) );
1670
 
1671
- /**
1672
  * If, somehow, the referenced activity has been deleted, leaving its associated
1673
  * activities as orphans, use the logged in user's ID to avoid errors.
1674
  */
1675
  if ( empty( $activity['activities'] ) )
1676
  return bp_loggedin_user_id();
1677
 
1678
- // Store the new activity/user ID mapping for any later re-use
1679
  $this->activity_user_id[ $activity['activities'][0]->id ] = $activity['activities'][0]->user_id;
1680
 
1681
- // Return the user ID
1682
  return $activity['activities'][0]->user_id;
1683
  }
1684
  }
@@ -1691,11 +1753,10 @@ class BP_Activity_List_Table extends WP_List_Table {
1691
  * list table doesn't use a BuddyPress activity loop, which prevents those
1692
  * functions from working as intended.
1693
  *
1694
- * @since BuddyPress (2.0.0)
1695
  *
1696
  * @param array $item An array version of the BP_Activity_Activity object.
1697
- *
1698
- * @return bool
1699
  */
1700
  protected function can_comment( $item ) {
1701
  $can_comment = true;
@@ -1710,25 +1771,25 @@ class BP_Activity_List_Table extends WP_List_Table {
1710
  break;
1711
  }
1712
 
1713
- // activity comments supported
1714
  } else {
1715
- // activity comment
1716
  if ( 'activity_comment' == $item['type'] ) {
1717
- // blogs
1718
  if ( bp_is_active( 'blogs' ) ) {
1719
- // grab the parent activity entry
1720
  $parent_activity = new BP_Activity_Activity( $item['item_id'] );
1721
 
1722
- // fetch blog post comment depth and if the blog post's comments are open
1723
  bp_blogs_setup_activity_loop_globals( $parent_activity );
1724
 
1725
- // check if the activity item can be replied to
1726
  if ( false === bp_blogs_can_comment_reply( true, $item ) ) {
1727
  $can_comment = false;
1728
  }
1729
  }
1730
 
1731
- // blog post
1732
  } elseif ( 'new_blog_post' == $item['type'] ) {
1733
  if ( bp_is_active( 'blogs' ) ) {
1734
  bp_blogs_setup_activity_loop_globals( (object) $item );
@@ -1743,7 +1804,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1743
  /**
1744
  * Filters if an activity item can be commented on or not.
1745
  *
1746
- * @since BuddyPress (2.0.0)
1747
  *
1748
  * @param bool $can_comment Whether an activity item can be commented on or not.
1749
  */
@@ -1756,10 +1817,9 @@ class BP_Activity_List_Table extends WP_List_Table {
1756
  * In some cases, BuddyPress gives us a structured tree of activity
1757
  * items plus their comments. This method converts it to a flat array.
1758
  *
1759
- * @since BuddyPress (1.6.0)
1760
  *
1761
  * @param array $tree Source array.
1762
- *
1763
  * @return array Flattened array.
1764
  */
1765
  public static function flatten_activity_array( $tree ){
@@ -1776,16 +1836,4 @@ class BP_Activity_List_Table extends WP_List_Table {
1776
 
1777
  return $tree;
1778
  }
1779
-
1780
- /**
1781
- * Get name of default primary column
1782
- *
1783
- * @since BuddyPress (2.3.3)
1784
- * @access protected
1785
- *
1786
- * @return string
1787
- */
1788
- protected function get_default_primary_column_name() {
1789
- return 'author';
1790
- }
1791
  }
6
  * help text, on which this implementation is heavily based.
7
  *
8
  * @package BuddyPress
9
+ * @subpackage ActivityAdmin
10
+ * @since 1.6.0
11
  */
12
 
13
+ // Exit if accessed directly.
14
  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
  * Register the Activity component admin screen.
25
  *
26
+ * @since 1.6.0
27
  */
28
  function bp_activity_add_admin_menu() {
29
 
30
+ // Add our screen.
31
  $hook = add_menu_page(
32
  _x( 'Activity', 'Admin Dashbord SWA page title', 'buddypress' ),
33
  _x( 'Activity', 'Admin Dashbord SWA menu', 'buddypress' ),
49
  * which all appear together in the middle of the Dashboard menu. This function
50
  * adds the Activity page to the array of these menu items.
51
  *
52
+ * @since 1.7.0
53
  *
54
  * @param array $custom_menus The list of top-level BP menu items.
 
55
  * @return array $custom_menus List of top-level BP menu items, with Activity added.
56
  */
57
  function bp_activity_admin_menu_order( $custom_menus = array() ) {
66
  * Processes requests to add new activity comments, and echoes HTML for a new
67
  * table row.
68
  *
69
+ * @since 1.6.0
70
  */
71
  function bp_activity_admin_reply() {
72
+ // Check nonce.
73
  check_ajax_referer( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply' );
74
 
75
  $parent_id = ! empty( $_REQUEST['parent_id'] ) ? (int) $_REQUEST['parent_id'] : 0;
79
  if ( empty( $parent_id ) )
80
  die( '-1' );
81
 
82
+ // If $root_id not set (e.g. for root items), use $parent_id.
83
  if ( empty( $root_id ) )
84
  $root_id = $parent_id;
85
 
86
+ // Check that a reply has been entered.
87
  if ( empty( $_REQUEST['content'] ) )
88
  die( __( 'ERROR: Please type a reply.', 'buddypress' ) );
89
 
90
+ // Check parent activity exists.
91
  $parent_activity = new BP_Activity_Activity( $parent_id );
92
  if ( empty( $parent_activity->component ) )
93
  die( __( 'ERROR: The item you are trying to reply to cannot be found, or it has been deleted.', 'buddypress' ) );
97
  if ( ! current_user_can( 'bp_moderate' ) )
98
  die( '-1' );
99
 
100
+ // Add new activity comment.
101
  $new_activity_id = bp_activity_new_comment( array(
102
+ 'activity_id' => $root_id, // ID of the root activity item.
103
  'content' => $_REQUEST['content'],
104
+ 'parent_id' => $parent_id, // ID of a parent comment.
105
  ) );
106
 
107
+ // Fetch the new activity item, as we need it to create table markup to return.
108
  $new_activity = new BP_Activity_Activity( $new_activity_id );
109
 
110
+ // This needs to be set for the BP_Activity_List_Table constructor to work.
111
  set_current_screen( 'toplevel_page_bp-activity' );
112
 
113
+ // Set up an output buffer.
114
  ob_start();
115
  $list_table = new BP_Activity_List_Table();
116
  $list_table->single_row( (array) $new_activity );
117
 
118
+ // Get table markup.
119
  $response = array(
120
  'data' => ob_get_contents(),
121
  'id' => $new_activity_id,
124
  );
125
  ob_end_clean();
126
 
127
+ // Send response.
128
  $r = new WP_Ajax_Response();
129
  $r->add( $response );
130
  $r->send();
136
  /**
137
  * Handle save/update of screen options for the Activity component admin screen.
138
  *
139
+ * @since 1.6.0
140
  *
141
  * @param string $value Will always be false unless another plugin filters it first.
142
  * @param string $option Screen option name.
143
  * @param string $new_value Screen option form value.
 
144
  * @return string Option value. False to abandon update.
145
  */
146
  function bp_activity_admin_screen_options( $value, $option, $new_value ) {
147
  if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option )
148
  return $value;
149
 
150
+ // Per page.
151
  $new_value = (int) $new_value;
152
  if ( $new_value < 1 || $new_value > 999 )
153
  return $value;
158
  /**
159
  * Hide the advanced edit meta boxes by default, so we don't clutter the screen.
160
  *
161
+ * @since 1.6.0
162
  *
163
  * @param array $hidden Array of items to hide.
164
  * @param WP_Screen $screen Screen identifier.
 
165
  * @return array Hidden Meta Boxes.
166
  */
167
  function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
168
  if ( empty( $screen->id ) || 'toplevel_page_bp-activity' != $screen->id && 'toplevel_page_bp-activity_network' != $screen->id )
169
  return $hidden;
170
 
171
+ // Hide the primary link meta box by default.
172
  $hidden = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) );
173
 
174
  /**
175
  * Filters default hidden metaboxes so plugins can alter list.
176
  *
177
+ * @since 1.6.0
178
  *
179
  * @param array $hidden Default metaboxes to hide.
180
  * @param WP_Screen $screen Screen identifier.
191
  * - Enqueues scripts and styles.
192
  * - Catches POST and GET requests related to Activity.
193
  *
194
+ * @since 1.6.0
195
  *
196
  * @global object $bp BuddyPress global settings.
197
  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
201
 
202
  $bp = buddypress();
203
 
204
+ // Decide whether to load the dev version of the CSS and JavaScript.
205
  $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : 'min.';
206
 
207
  $doaction = bp_admin_list_table_current_bulk_action();
209
  /**
210
  * Fires at top of Activity admin page.
211
  *
212
+ * @since 1.6.0
213
  *
214
  * @param string $doaction Current $_GET action being performed in admin screen.
215
  */
216
  do_action( 'bp_activity_admin_load', $doaction );
217
 
218
+ // Edit screen.
219
  if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) {
220
+ // Columns screen option.
221
  add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) );
222
 
223
  get_current_screen()->add_help_tab( array(
239
  '<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>'
240
  ) );
241
 
242
+ // Help panel - sidebar links.
243
  get_current_screen()->set_help_sidebar(
244
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
245
  '<p>' . __( '<a href="https://codex.buddypress.org/administrator-guide/activity-stream-management-panels/">Managing Activity</a>', 'buddypress' ) . '</p>' .
253
  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' );
254
  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' );
255
 
256
+ /**
257
+ * Fires after the registration of all of the default activity meta boxes.
258
+ *
259
+ * @since 2.4.0
260
+ */
261
+ do_action( 'bp_activity_admin_meta_boxes' );
262
+
263
+ // Enqueue JavaScript files.
264
  wp_enqueue_script( 'postbox' );
265
  wp_enqueue_script( 'dashboard' );
266
  wp_enqueue_script( 'comment' );
267
 
268
+ // Index screen.
269
  } else {
270
+ // Create the Activity screen list table.
271
  $bp_activity_list_table = new BP_Activity_List_Table();
272
 
273
+ // The per_page screen option.
274
  add_screen_option( 'per_page', array( 'label' => _x( 'Activity', 'Activity items per page (screen options)', 'buddypress' )) );
275
 
276
+ // Help panel - overview text.
277
  get_current_screen()->add_help_tab( array(
278
  'id' => 'bp-activity-overview',
279
  'title' => __( 'Overview', 'buddypress' ),
282
  '<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>'
283
  ) );
284
 
285
+ // Help panel - moderation text.
286
  get_current_screen()->add_help_tab( array(
287
  'id' => 'bp-activity-moderating',
288
  'title' => __( 'Moderating Activity', 'buddypress' ),
291
  '<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>'
292
  ) );
293
 
294
+ // Help panel - sidebar links.
295
  get_current_screen()->set_help_sidebar(
296
  '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
297
  '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
298
  );
299
  }
300
 
301
+ // Enqueue CSS and JavaScript.
302
  wp_enqueue_script( 'bp_activity_admin_js', $bp->plugin_url . "bp-activity/admin/js/admin.{$min}js", array( 'jquery', 'wp-ajax-response' ), bp_get_version(), true );
303
  wp_localize_script( 'bp_activity_admin_js', 'bp_activity_admin_vars', array(
304
  'page' => get_current_screen()->id
310
  wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min );
311
  }
312
 
313
+ /**
314
+ * Fires after the activity js and style has been enqueued.
315
+ *
316
+ * @since 2.4.0
317
+ */
318
+ do_action( 'bp_activity_admin_enqueue_scripts' );
319
 
320
+ // Handle spam/un-spam/delete of activities.
321
  if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
322
 
323
+ // Build redirection URL.
324
  $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() );
325
  $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to );
326
 
327
+ // Get activity IDs.
328
  $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
329
 
330
  /**
331
  * Filters list of IDs being spammed/un-spammed/deleted.
332
  *
333
+ * @since 1.6.0
334
  *
335
  * @param array $activity_ids Activity IDs to spam/un-spam/delete.
336
  */
338
 
339
  // Is this a bulk request?
340
  if ( 'bulk_' == substr( $doaction, 0, 5 ) && ! empty( $_REQUEST['aid'] ) ) {
341
+ // Check this is a valid form submission.
342
  check_admin_referer( 'bulk-activities' );
343
 
344
+ // Trim 'bulk_' off the action name to avoid duplicating a ton of code.
345
  $doaction = substr( $doaction, 5 );
346
 
347
  // This is a request to delete, spam, or un-spam, a single item.
348
  } elseif ( !empty( $_REQUEST['aid'] ) ) {
349
 
350
+ // Check this is a valid form submission.
351
  check_admin_referer( 'spam-activity_' . $activity_ids[0] );
352
  }
353
 
354
+ // Initialise counters for how many of each type of item we perform an action on.
355
  $deleted = $spammed = $unspammed = 0;
356
 
357
+ // Store any errors that occurs when updating the database items.
358
  $errors = array();
359
 
360
  // "We'd like to shoot the monster, could you move, please?"
361
  foreach ( $activity_ids as $activity_id ) {
362
  // @todo: Check the permissions on each
363
  //if ( ! current_user_can( 'bp_edit_activity', $activity_id ) )
364
+ // continue;
365
 
366
+ // Get the activity from the database.
367
  $activity = new BP_Activity_Activity( $activity_id );
368
  if ( empty( $activity->component ) ) {
369
  $errors[] = $activity_id;
391
  bp_activity_mark_as_ham( $activity );
392
  $result = $activity->save();
393
 
394
+ // Check for any error during activity save.
395
  if ( ! $result )
396
  $errors[] = $activity->id;
397
  else
402
  bp_activity_mark_as_spam( $activity );
403
  $result = $activity->save();
404
 
405
+ // Check for any error during activity save.
406
  if ( ! $result )
407
  $errors[] = $activity->id;
408
  else
413
  break;
414
  }
415
 
416
+ // Release memory.
417
  unset( $activity );
418
  }
419
 
422
  *
423
  * Passes an activity array counts how many were spam, not spam, deleted, and IDs that were errors.
424
  *
425
+ * @since 1.6.0
426
  *
427
  * @param array $value Array holding spam, not spam, deleted counts, error IDs.
428
  * @param string $redirect_to URL to redirect to.
440
  if ( $deleted )
441
  $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
442
 
443
+ // If an error occurred, pass back the activity ID that failed.
444
  if ( ! empty( $errors ) )
445
  $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to );
446
 
447
  /**
448
  * Filters redirect URL after activity spamming/un-spamming/deletion occurs.
449
  *
450
+ * @since 1.6.0
451
  *
452
  * @param string $redirect_to URL to redirect to.
453
  */
455
  exit;
456
 
457
 
458
+ // Save the edit.
459
  } elseif ( $doaction && 'save' == $doaction ) {
460
+ // Build redirection URL.
461
  $redirect_to = remove_query_arg( array( 'action', 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
462
 
463
+ // Get activity ID.
464
  $activity_id = (int) $_REQUEST['aid'];
465
 
466
+ // Check this is a valid form submission.
467
  check_admin_referer( 'edit-activity_' . $activity_id );
468
 
469
+ // Get the activity from the database.
470
  $activity = new BP_Activity_Activity( $activity_id );
471
 
472
+ // If the activity doesn't exist, just redirect back to the index.
473
  if ( empty( $activity->component ) ) {
474
  wp_redirect( $redirect_to );
475
  exit;
476
  }
477
 
478
+ // Check the form for the updated properties.
479
+ // Store any error that occurs when updating the database item.
 
480
  $error = 0;
481
 
482
+ // Activity spam status.
483
  $prev_spam_status = $new_spam_status = false;
484
  if ( ! empty( $_POST['activity_status'] ) ) {
485
  $prev_spam_status = $activity->is_spam;
486
  $new_spam_status = ( 'spam' == $_POST['activity_status'] ) ? true : false;
487
  }
488
 
489
+ // Activity action.
490
  if ( isset( $_POST['bp-activities-action'] ) )
491
  $activity->action = $_POST['bp-activities-action'];
492
 
493
+ // Activity content.
494
  if ( isset( $_POST['bp-activities-content'] ) )
495
  $activity->content = $_POST['bp-activities-content'];
496
 
497
+ // Activity primary link.
498
  if ( ! empty( $_POST['bp-activities-link'] ) )
499
  $activity->primary_link = $_POST['bp-activities-link'];
500
 
501
+ // Activity user ID.
502
  if ( ! empty( $_POST['bp-activities-userid'] ) )
503
  $activity->user_id = (int) $_POST['bp-activities-userid'];
504
 
505
+ // Activity item primary ID.
506
  if ( isset( $_POST['bp-activities-primaryid'] ) )
507
  $activity->item_id = (int) $_POST['bp-activities-primaryid'];
508
 
509
+ // Activity item secondary ID.
510
  if ( isset( $_POST['bp-activities-secondaryid'] ) )
511
  $activity->secondary_item_id = (int) $_POST['bp-activities-secondaryid'];
512
 
513
+ // Activity type.
514
  if ( ! empty( $_POST['bp-activities-type'] ) ) {
515
  $actions = bp_activity_admin_get_activity_actions();
516
 
517
+ // Check that the new type is a registered activity type.
518
  if ( in_array( $_POST['bp-activities-type'], $actions ) ) {
519
  $activity->type = $_POST['bp-activities-type'];
520
  }
521
  }
522
 
523
+ // Activity timestamp.
524
  if ( ! empty( $_POST['aa'] ) && ! empty( $_POST['mm'] ) && ! empty( $_POST['jj'] ) && ! empty( $_POST['hh'] ) && ! empty( $_POST['mn'] ) && ! empty( $_POST['ss'] ) ) {
525
  $aa = $_POST['aa'];
526
  $mm = $_POST['mm'];
536
  $mn = ( $mn > 59 ) ? $mn -60 : $mn;
537
  $ss = ( $ss > 59 ) ? $ss -60 : $ss;
538
 
539
+ // Reconstruct the date into a timestamp.
540
  $gmt_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
541
 
542
  $activity->date_recorded = $gmt_date;
550
  bp_activity_mark_as_ham( $activity );
551
  }
552
 
553
+ // Save.
554
  $result = $activity->save();
555
 
556
+ // Clear the activity stream first page cache, in case this activity's timestamp was changed.
557
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
558
 
559
+ // Check for any error during activity save.
560
  if ( false === $result )
561
  $error = $activity->id;
562
 
563
  /**
564
  * Fires before redirect so plugins can do something first on save action.
565
  *
566
+ * @since 1.6.0
567
  *
568
  * @param array Array holding activity object and ID that holds error.
569
  */
570
  do_action_ref_array( 'bp_activity_admin_edit_after', array( &$activity, $error ) );
571
 
572
+ // If an error occurred, pass back the activity ID that failed.
573
  if ( $error )
574
  $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
575
  else
578
  /**
579
  * Filters URL to redirect to after saving.
580
  *
581
+ * @since 1.6.0
582
  *
583
  * @param string $redirect_to URL to redirect to.
584
  */
596
  /**
597
  * Output the Activity component admin screens.
598
  *
599
+ * @since 1.6.0
600
  */
601
  function bp_activity_admin() {
602
+ // Decide whether to load the index or edit screen.
603
  $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
604
 
605
+ // Display the single activity edit screen.
606
  if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) )
607
  bp_activity_admin_edit();
608
 
609
+ // Otherwise, display the Activity index screen.
610
  else
611
  bp_activity_admin_index();
612
  }
614
  /**
615
  * Display the single activity edit screen.
616
  *
617
+ * @since 1.6.0
618
  */
619
  function bp_activity_admin_edit() {
620
 
623
  if ( ! is_super_admin() )
624
  die( '-1' );
625
 
626
+ // Get the activity from the database.
627
  $activity = bp_activity_get( array(
628
  'in' => ! empty( $_REQUEST['aid'] ) ? (int) $_REQUEST['aid'] : 0,
629
  'max' => 1,
635
  if ( ! empty( $activity['activities'][0] ) ) {
636
  $activity = $activity['activities'][0];
637
 
638
+ // Workaround to use WP's touch_time() without duplicating that function.
639
  $GLOBALS['comment'] = new stdClass;
640
  $GLOBALS['comment']->comment_date = $activity->date_recorded;
641
  } else {
642
  $activity = '';
643
  }
644
 
645
+ // Construct URL for form.
646
  $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
647
  $form_url = add_query_arg( 'action', 'save', $form_url );
648
 
649
  /**
650
  * Fires before activity edit form is displays so plugins can modify the activity.
651
  *
652
+ * @since 1.6.0
653
  *
654
  * @param array $value Array holding single activity object that was passed by reference.
655
  */
656
  do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
657
 
658
  <div class="wrap">
 
659
  <h2><?php printf( __( 'Editing Activity (ID #%s)', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?></h2>
660
 
661
  <?php if ( ! empty( $activity ) ) : ?>
710
  /**
711
  * Status metabox for the Activity admin edit screen.
712
  *
713
+ * @since 1.6.0
714
  *
715
  * @param object $item Activity item.
716
  */
736
 
737
  <div class="misc-pub-section curtime misc-pub-section-last">
738
  <?php
739
+ // Translators: Publish box date format, see http://php.net/date.
740
  $datef = __( 'M j, Y @ G:i', 'buddypress' );
741
  $date = date_i18n( $datef, strtotime( $item->date_recorded ) );
742
  ?>
753
 
754
  <div id="major-publishing-actions">
755
  <div id="publishing-action">
756
+ <?php submit_button( __( 'Update', 'buddypress' ), 'primary', 'save', false ); ?>
757
  </div>
758
  <div class="clear"></div>
759
  </div><!-- #major-publishing-actions -->
766
  /**
767
  * Primary link metabox for the Activity admin edit screen.
768
  *
769
+ * @since 1.6.0
770
  *
771
  * @param object $item Activity item.
772
  */
774
  ?>
775
 
776
  <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label>
777
+ <input type="url" name="bp-activities-link" id="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" aria-describedby="bp-activities-link-description" />
778
+ <p id="bp-activities-link-description"><?php _e( 'Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
779
 
780
  <?php
781
  }
783
  /**
784
  * User ID metabox for the Activity admin edit screen.
785
  *
786
+ * @since 1.6.0
787
  *
788
  * @param object $item Activity item.
789
  */
791
  ?>
792
 
793
  <label class="screen-reader-text" for="bp-activities-userid"><?php _e( 'Author ID', 'buddypress' ); ?></label>
794
+ <input type="number" name="bp-activities-userid" id="bp-activities-userid" value="<?php echo esc_attr( $item->user_id ); ?>" min="1" />
795
 
796
  <?php
797
  }
801
  *
802
  * Format is [activity_type] => Pretty name for activity type.
803
  *
804
+ * @since 2.0.0
805
  *
806
+ * @return array $actions
807
  */
808
  function bp_activity_admin_get_activity_actions() {
809
  $actions = array();
817
  }
818
  }
819
 
820
+ // This was a mis-named activity type from before BP 1.6.
821
  unset( $actions['friends_register_activity_action'] );
822
 
823
+ // Sort array by the human-readable value.
824
  natsort( $actions );
825
 
826
  return $actions;
829
  /**
830
  * Activity type metabox for the Activity admin edit screen.
831
  *
832
+ * @since 1.6.0
833
  *
834
  * @param object $item Activity item.
835
  */
847
  $actions[ $action[$i]['key'] ] = $action[$i]['value'];
848
  }
849
 
850
+ // This was a mis-named activity type from before BP 1.6.
851
  unset( $actions['friends_register_activity_action'] );
852
 
853
+ // Sort array by the human-readable value.
854
  natsort( $actions );
855
 
856
+ /*
857
+ * If the activity type is not registered properly (eg, a plugin has
858
+ * not called bp_activity_set_action()), add the raw type to the end
859
+ * of the list.
860
+ */
861
  if ( ! isset( $actions[ $selected ] ) ) {
862
  _doing_it_wrong( __FUNCTION__, sprintf( __( 'This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', 'buddypress' ), $selected ), '2.0.0' );
863
  $actions[ $selected ] = $selected;
877
  /**
878
  * Primary item ID/Secondary item ID metabox for the Activity admin edit screen.
879
  *
880
+ * @since 1.6.0
881
  *
882
  * @param object $item Activity item.
883
  */
899
  /**
900
  * Display the Activity admin index screen, which contains a list of all the activities.
901
  *
902
+ * @since 1.6.0
903
  *
904
  * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
905
  * @global string $plugin_page The current plugin page.
909
 
910
  $messages = array();
911
 
912
+ // If the user has just made a change to an activity item, build status messages.
913
  if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) {
914
  $deleted = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
915
  $errors = ! empty( $_REQUEST['error'] ) ? $_REQUEST['error'] : '';
919
 
920
  $errors = array_map( 'absint', explode( ',', $errors ) );
921
 
922
+ // Make sure we don't get any empty values in $errors.
923
  for ( $i = 0, $errors_count = count( $errors ); $i < $errors_count; $i++ ) {
924
  if ( 0 === $errors[$i] ) {
925
  unset( $errors[$i] );
926
  }
927
  }
928
 
929
+ // Reindex array.
930
  $errors = array_values( $errors );
931
 
932
  if ( $deleted > 0 )
940
  $error_msg = __( 'Errors occurred when trying to update these activity items:', 'buddypress' );
941
  $error_msg .= '<ul class="activity-errors">';
942
 
943
+ // Display each error as a list item.
944
  foreach ( $errors as $error ) {
945
+ // Translators: This is a bulleted list of item IDs.
946
  $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>';
947
  }
948
 
961
  $messages[] = __( 'The activity item has been updated successfully.', 'buddypress' );
962
  }
963
 
964
+ // Prepare the activity items for display.
965
  $bp_activity_list_table->prepare_items();
966
 
967
  /**
968
  * Fires before edit form is displayed so plugins can modify the activity messages.
969
  *
970
+ * @since 1.6.0
971
  *
972
  * @param array $messages Array of messages to display at top of page.
973
  */
974
  do_action( 'bp_activity_admin_index', $messages ); ?>
975
 
976
  <div class="wrap">
 
977
  <h2>
978
  <?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
979
  <?php printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
986
  <?php endif; ?>
987
  </h2>
988
 
989
+ <?php // If the user has just made a change to an activity item, display the status messages. ?>
990
  <?php if ( !empty( $messages ) ) : ?>
991
  <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
992
  <?php endif; ?>
993
 
994
+ <?php // Display each activity on its own row. ?>
995
  <?php $bp_activity_list_table->views(); ?>
996
 
997
  <form id="bp-activities-form" action="" method="get">
1000
  <?php $bp_activity_list_table->display(); ?>
1001
  </form>
1002
 
1003
+ <?php // This markup is used for the reply form. ?>
1004
  <table style="display: none;">
1005
  <tr id="bp-activities-container" style="display: none;">
1006
  <td colspan="4">
1032
  /**
1033
  * List table class for the Activity component admin page.
1034
  *
1035
+ * @since 1.6.0
1036
  */
1037
  class BP_Activity_List_Table extends WP_List_Table {
1038
 
1039
  /**
1040
  * What type of view is being displayed?
1041
  *
1042
+ * E.g. "all", "pending", "approved", "spam"...
1043
  *
1044
+ * @since 1.6.0
1045
+ * @var string $view
1046
  */
1047
  public $view = 'all';
1048
 
1049
  /**
1050
  * How many activity items have been marked as spam.
1051
  *
1052
+ * @since 1.6.0
1053
+ * @var int $spam_count
1054
  */
1055
  public $spam_count = 0;
1056
 
1057
  /**
1058
  * Store activity-to-user-ID mappings for use in the In Response To column.
1059
  *
1060
+ * @since 1.6.0
1061
+ * @var array $activity_user_id
1062
  */
1063
  protected $activity_user_id = array();
1064
 
1065
  /**
1066
  * If users can comment on blog & forum activity items.
1067
  *
 
 
1068
  * @link https://buddypress.trac.wordpress.org/ticket/6277
1069
  *
1070
+ * @since 2.2.2
1071
+ * @var bool $disable_blogforum_comments
1072
  */
1073
  public $disable_blogforum_comments = false;
1074
 
1075
  /**
1076
  * Constructor.
1077
  *
1078
+ * @since 1.6.0
1079
  */
1080
  public function __construct() {
1081
 
1082
+ // See if activity commenting is enabled for blog / forum activity items.
1083
  $this->disable_blogforum_comments = bp_disable_blogforum_comments();
1084
 
1085
  // Define singular and plural labels, as well as whether we support AJAX.
1094
  /**
1095
  * Handle filtering of data, sorting, pagination, and any other data manipulation prior to rendering.
1096
  *
1097
+ * @since 1.6.0
1098
  */
1099
  function prepare_items() {
1100
 
1101
+ // Option defaults.
1102
  $filter = array();
1103
  $include_id = false;
1104
  $search_terms = false;
1105
  $sort = 'DESC';
1106
  $spam = 'ham_only';
1107
 
1108
+ // Set current page.
1109
  $page = $this->get_pagenum();
1110
 
1111
+ // Set per page from the screen options.
1112
  $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
1113
 
1114
+ // Check if we're on the "Spam" view.
1115
  if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
1116
  $spam = 'spam_only';
1117
  $this->view = 'spam';
1118
  }
1119
 
1120
+ // Sort order.
1121
  if ( !empty( $_REQUEST['order'] ) && 'desc' != $_REQUEST['order'] )
1122
  $sort = 'ASC';
1123
 
1124
+ // Order by.
1125
  /*if ( !empty( $_REQUEST['orderby'] ) ) {
1126
  }*/
1127
 
1128
+ // Filter.
1129
  if ( !empty( $_REQUEST['activity_type'] ) )
1130
  $filter = array( 'action' => $_REQUEST['activity_type'] );
1131
 
1137
  if ( !empty( $_REQUEST['aid'] ) )
1138
  $include_id = (int) $_REQUEST['aid'];
1139
 
1140
+ // Get the spam total (ignoring any search query or filter).
1141
  $spams = bp_activity_get( array(
1142
  'display_comments' => 'stream',
1143
  'show_hidden' => true,
1147
  $this->spam_count = $spams['total'];
1148
  unset( $spams );
1149
 
1150
+ // Get the activities from the database.
1151
  $activities = bp_activity_get( array(
1152
  'display_comments' => 'stream',
1153
  'filter' => $filter,
1156
  'per_page' => $per_page,
1157
  'search_terms' => $search_terms,
1158
  'show_hidden' => true,
1159
+ // 'sort' => $sort,
1160
  'spam' => $spam,
1161
  'count_total' => 'count_query',
1162
  ) );
1166
  $activities['activities'] = BP_Activity_List_Table::flatten_activity_array( $activities['activities'] );
1167
  $activities['total'] = count( $activities['activities'] );
1168
 
1169
+ // Sort the array by the activity object's date_recorded value.
1170
  usort( $activities['activities'], create_function( '$a, $b', 'return $a->date_recorded > $b->date_recorded;' ) );
1171
  }
1172
 
1173
+ // The bp_activity_get function returns an array of objects; cast these to arrays for WP_List_Table.
1174
  $new_activities = array();
1175
  foreach ( $activities['activities'] as $activity_item ) {
1176
  $new_activities[] = (array) $activity_item;
1177
 
1178
+ // Build an array of activity-to-user ID mappings for better efficiency in the In Response To column.
1179
  $this->activity_user_id[$activity_item->id] = $activity_item->user_id;
1180
  }
1181
 
1182
+ // Set raw data to display.
1183
  $this->items = $new_activities;
1184
 
1185
+ // Store information needed for handling table pagination.
1186
  $this->set_pagination_args( array(
1187
  'per_page' => $per_page,
1188
  'total_items' => $activities['total'],
1196
  /**
1197
  * Get an array of all the columns on the page.
1198
  *
1199
+ * @since 1.6.0
1200
  *
1201
  * @return array Column headers.
1202
  */
1211
  return $this->_column_headers;
1212
  }
1213
 
1214
+ /**
1215
+ * Get name of default primary column
1216
+ *
1217
+ * @since 2.3.3
1218
+ *
1219
+ * @return string
1220
+ */
1221
+ protected function get_default_primary_column_name() {
1222
+ return 'author';
1223
+ }
1224
+
1225
  /**
1226
  * Display a message on screen when no items are found (e.g. no search matches).
1227
  *
1228
+ * @since 1.6.0
1229
  */
1230
  function no_items() {
1231
  _e( 'No activities found.', 'buddypress' );
1234
  /**
1235
  * Output the Activity data table.
1236
  *
1237
+ * @since 1.6.0
1238
+ */
1239
  function display() {
1240
  $this->display_tablenav( 'top' ); ?>
1241
 
1264
  /**
1265
  * Generate content for a single row of the table.
1266
  *
1267
+ * @since 1.6.0
1268
  *
1269
  * @param object $item The current item.
1270
  */
1293
  /**
1294
  * Get the list of views available on this table (e.g. "all", "spam").
1295
  *
1296
+ * @since 1.6.0
1297
  */
1298
  function get_views() {
1299
  $url_base = add_query_arg( array( 'page' => 'bp-activity' ), bp_get_admin_url( 'admin.php' ) ); ?>
1307
  /**
1308
  * Fires inside listing of views so plugins can add their own.
1309
  *
1310
+ * @since 1.6.0
1311
  *
1312
  * @param string $url_base Current URL base for view.
1313
  * @param string $view Current view being displayed.
1320
  /**
1321
  * Get bulk actions.
1322
  *
1323
+ * @since 1.6.0
1324
  *
1325
  * @return array Key/value pairs for the bulk actions dropdown.
1326
  */
1333
  /**
1334
  * Filters the default bulk actions so plugins can add custom actions.
1335
  *
1336
+ * @since 1.6.0
1337
  *
1338
  * @param array $actions Default available actions for bulk operations.
1339
  */
1343
  /**
1344
  * Get the table column titles.
1345
  *
1346
+ * @since 1.6.0
1347
  *
1348
  * @see WP_List_Table::single_row_columns()
1349
  *
1350
  * @return array The columns to appear in the Activity list table.
1351
  */
1352
  function get_columns() {
1353
+ /**
1354
+ * Filters the titles for the columns for the activity list table.
1355
+ *
1356
+ * @since 2.4.0
1357
+ *
1358
+ * @param array $value Array of slugs and titles for the columns.
1359
+ */
1360
+ return apply_filters( 'bp_activity_list_table_get_columns', array(
1361
  'cb' => '<input name type="checkbox" />',
1362
  'author' => _x('Author', 'Admin SWA column header', 'buddypress' ),
1363
  'comment' => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
1364
  'action' => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
1365
  'response' => _x( 'In Response To', 'Admin SWA column header', 'buddypress' ),
1366
+ ) );
1367
  }
1368
 
1369
  /**
1371
  *
1372
  * Currently, returns an empty array (no columns are sortable).
1373
  *
1374
+ * @since 1.6.0
1375
  * @todo For this to work, BP_Activity_Activity::get() needs updating
1376
  * to support ordering by specific fields.
1377
  *
1388
  /**
1389
  * Markup for the "filter" part of the form (i.e. which activity type to display).
1390
  *
1391
+ * @since 1.6.0
1392
  *
1393
  * @param string $which 'top' or 'bottom'.
1394
  */
1395
  function extra_tablenav( $which ) {
1396
 
1397
+ // Bail on bottom table nav.
1398
  if ( 'bottom' === $which ) {
1399
  return;
1400
  }
1402
  // Is any filter currently selected?
1403
  $selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : '';
1404
 
1405
+ // Get the actions.
1406
  $activity_actions = bp_activity_get_actions(); ?>
1407
 
1408
  <div class="alignleft actions">
1409
+ <label for="activity-type" class="screen-reader-text"><?php _e( 'Filter by activity type', 'buddypress' ); ?></label>
1410
+ <select name="activity_type" id="activity-type">
1411
  <option value="" <?php selected( ! $selected ); ?>><?php _e( 'View all actions', 'buddypress' ); ?></option>
1412
 
1413
  <?php foreach ( $activity_actions as $component => $actions ) : ?>
1418
 
1419
  <?php
1420
 
1421
+ // Skip the incorrectly named pre-1.6 action.
1422
  if ( 'friends_register_activity_action' !== $action_key ) : ?>
1423
 
1424
  <option value="<?php echo esc_attr( $action_key ); ?>" <?php selected( $action_key, $selected ); ?>><?php echo esc_html( $action_values[ 'value' ] ); ?></option>
1448
  * @since 2.3.3
1449
  * @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0.
1450
  *
1451
+ * @param array $actions The list of actions.
1452
+ * @param bool $always_visible Whether the actions should be always visible.
1453
  * @return string
1454
  */
1455
  public function row_actions( $actions, $always_visible = false ) {
1473
  /**
1474
  * Checkbox column markup.
1475
  *
1476
+ * @since 1.6.0
1477
  *
1478
  * @see WP_List_Table::single_row_columns()
1479
  *
1486
  /**
1487
  * Author column markup.
1488
  *
1489
+ * @since 1.6.0
1490
  *
1491
  * @see WP_List_Table::single_row_columns()
1492
  *
1499
  /**
1500
  * Action column markup.
1501
  *
1502
+ * @since 2.0.0
1503
  *
1504
  * @see WP_List_Table::single_row_columns()
1505
  *
1520
  *
1521
  * Called "comment" in the CSS so we can re-use some WP core CSS.
1522
  *
1523
+ * @since 1.6.0
1524
  *
1525
  * @see WP_List_Table::single_row_columns()
1526
  *
1527
  * @param array $item A singular item (one full row).
1528
  */
1529
  function column_comment( $item ) {
1530
+ // Determine what type of item (row) we're dealing with.
1531
  if ( $item['is_spam'] )
1532
  $item_status = 'spam';
1533
  else
1534
  $item_status = 'all';
1535
 
1536
+ // Preorder items: Reply | Edit | Spam | Delete Permanently.
1537
  $actions = array(
1538
  'reply' => '',
1539
  'edit' => '',
1541
  'delete' => '',
1542
  );
1543
 
1544
+ // Build actions URLs.
1545
  $base_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1546
  $spam_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'spam-activity_' . $item['id'] ) );
1547
 
1550
  $ham_url = $base_url . "&amp;action=ham&amp;$spam_nonce";
1551
  $spam_url = $base_url . "&amp;action=spam&amp;$spam_nonce";
1552
 
1553
+ // Rollover actions.
 
1554
  // Reply - JavaScript only; implemented by AJAX.
1555
  if ( 'spam' != $item_status ) {
1556
  if ( $this->can_comment( $item ) ) {
1559
  $actions['reply'] = sprintf( '<span class="form-input-tip" title="%s">%s</span>', __( 'Replies are disabled for this activity item', 'buddypress' ), __( 'Replies disabled', 'buddypress' ) );
1560
  }
1561
 
1562
+ // Edit.
1563
  $actions['edit'] = sprintf( '<a href="%s">%s</a>', $edit_url, __( 'Edit', 'buddypress' ) );
1564
  }
1565
 
1566
+ // Spam/unspam.
1567
  if ( 'spam' == $item_status )
1568
  $actions['unspam'] = sprintf( '<a href="%s">%s</a>', $ham_url, __( 'Not Spam', 'buddypress' ) );
1569
  else
1570
  $actions['spam'] = sprintf( '<a href="%s">%s</a>', $spam_url, __( 'Spam', 'buddypress' ) );
1571
 
1572
+ // Delete.
1573
  $actions['delete'] = sprintf( '<a href="%s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js( __( 'Are you sure?', 'buddypress' ) ) . "'); ", __( 'Delete Permanently', 'buddypress' ) );
1574
 
1575
+ // Start timestamp.
1576
  echo '<div class="submitted-on">';
1577
 
1578
  /**
1579
  * Filters available actions for plugins to alter.
1580
  *
1581
+ * @since 1.6.0
1582
  *
1583
  * @param array $actions Array of available actions user could use.
1584
  * @param array $item Current item being added to page.
1586
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1587
 
1588
  /* translators: 2: activity admin ui date/time */
1589
+ printf(
1590
+ __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>', 'buddypress' ),
1591
+ bp_activity_get_permalink( $item['id'] ),
1592
+ date_i18n( bp_get_option( 'date_format' ), strtotime( $item['date_recorded'] ) ),
1593
+ get_date_from_gmt( $item['date_recorded'], bp_get_option( 'time_format' ) )
1594
+ );
1595
 
1596
+ // End timestamp.
1597
  echo '</div>';
1598
 
1599
+ // Get activity content - if not set, use the action.
1600
  if ( ! empty( $item['content'] ) ) {
1601
 
1602
  /**
1603
  * Filters current activity item content.
1604
  *
1605
+ * @since 1.2.0
1606
  *
1607
  * @param array $item Array index holding current activity item content.
1608
  */
1611
  /**
1612
  * Filters current activity item action.
1613
  *
1614
+ * @since 1.2.0
1615
  *
1616
  * @var array $item Array index holding current activity item action.
1617
  */
1618
  $content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'] ) );
1619
  }
1620
 
1621
+ /**
1622
+ * Filter here to add extra output to the activity content into the Administration.
1623
+ *
1624
+ * @since 2.4.0
1625
+ *
1626
+ * @param string $content The activity content.
1627
+ * @param array $item The activity object converted into an array.
1628
+ */
1629
+ echo apply_filters( 'bp_activity_admin_comment_content', $content, $item ) . ' ' . $this->row_actions( $actions );
1630
  }
1631
 
1632
  /**
1633
  * "In response to" column markup.
1634
  *
1635
+ * @since 1.6.0
1636
  *
1637
  * @see WP_List_Table::single_row_columns()
1638
  *
1639
  * @param array $item A singular item (one full row).
1640
  */
1641
  function column_response( $item ) {
1642
+
1643
  // Is $item is a root activity?
1644
  ?>
1645
 
1655
  /**
1656
  * Filters default list of default root activity types.
1657
  *
1658
+ * @since 1.6.0
1659
  *
1660
  * @param array $value Array of default activity types.
1661
  * @param array $item Current item being displayed.
1666
  $comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
1667
  $root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
1668
 
1669
+ // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble.
1670
  if ( $comment_count ) {
1671
  $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
1672
  printf( '<a href="%1$s" title="%2$s" class="post-com-count post-com-count-approved"><span class="comment-count comment-count-approved">%3$s</span></a>', esc_url( $root_activity_url ), esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
1673
  }
1674
 
1675
+ // For non-root activities, display a link to the replied-to activity's author's profile.
1676
  } else {
1677
  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 />';
1678
  echo $activity_permalink;
1684
  <?php
1685
  }
1686
 
1687
+ /**
1688
+ * Allow plugins to add their custom column.
1689
+ *
1690
+ * @since 2.4.0
1691
+ *
1692
+ * @param array $item Information about the current row.
1693
+ * @param string $column_name The column name.
1694
+ * @return string
1695
+ */
1696
+ public function column_default( $item = array(), $column_name = '' ) {
1697
+
1698
+ /**
1699
+ * Filters a string to allow plugins to add custom column content.
1700
+ *
1701
+ * @since 2.4.0
1702
+ *
1703
+ * @param string $value Empty string.
1704
+ * @param string $column_name Name of the column being rendered.
1705
+ * @param array $item The current activity item in the loop.
1706
+ */
1707
+ return apply_filters( 'bp_activity_admin_get_custom_column', '', $column_name, $item );
1708
+ }
1709
+
1710
  /**
1711
  * Get the user id associated with a given activity item.
1712
  *
1713
  * Wraps bp_activity_get_specific(), with some additional logic for
1714
  * avoiding duplicate queries.
1715
  *
1716
+ * @since 1.6.0
1717
  *
1718
  * @param int $activity_id Activity ID to retrieve User ID for.
 
1719
  * @return int User ID of the activity item in question.
1720
  */
1721
  protected function get_activity_user_id( $activity_id ) {
1723
  if ( ! empty( $this->activity_user_id[$activity_id] ) ) {
1724
  return $this->activity_user_id[$activity_id];
1725
 
1726
+ /*
1727
  * We don't have a mapping. This means the $activity_id is not on the current
1728
  * page of results, so fetch its details from the database.
1729
  */
1730
  } else {
1731
  $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'show_hidden' => true, 'spam' => 'all', ) );
1732
 
1733
+ /*
1734
  * If, somehow, the referenced activity has been deleted, leaving its associated
1735
  * activities as orphans, use the logged in user's ID to avoid errors.
1736
  */
1737
  if ( empty( $activity['activities'] ) )
1738
  return bp_loggedin_user_id();
1739
 
1740
+ // Store the new activity/user ID mapping for any later re-use.
1741
  $this->activity_user_id[ $activity['activities'][0]->id ] = $activity['activities'][0]->user_id;
1742
 
1743
+ // Return the user ID.
1744
  return $activity['activities'][0]->user_id;
1745
  }
1746
  }
1753
  * list table doesn't use a BuddyPress activity loop, which prevents those
1754
  * functions from working as intended.
1755
  *
1756
+ * @since 2.0.0
1757
  *
1758
  * @param array $item An array version of the BP_Activity_Activity object.
1759
+ * @return bool $can_comment
 
1760
  */
1761
  protected function can_comment( $item ) {
1762
  $can_comment = true;
1771
  break;
1772
  }
1773
 
1774
+ // Activity comments supported.
1775
  } else {
1776
+ // Activity comment.
1777
  if ( 'activity_comment' == $item['type'] ) {
1778
+ // Blogs.
1779
  if ( bp_is_active( 'blogs' ) ) {
1780
+ // Grab the parent activity entry.
1781
  $parent_activity = new BP_Activity_Activity( $item['item_id'] );
1782
 
1783
+ // Fetch blog post comment depth and if the blog post's comments are open.
1784
  bp_blogs_setup_activity_loop_globals( $parent_activity );
1785
 
1786
+ // Check if the activity item can be replied to.
1787
  if ( false === bp_blogs_can_comment_reply( true, $item ) ) {
1788
  $can_comment = false;
1789
  }
1790
  }
1791
 
1792
+ // Blog post.
1793
  } elseif ( 'new_blog_post' == $item['type'] ) {
1794
  if ( bp_is_active( 'blogs' ) ) {
1795
  bp_blogs_setup_activity_loop_globals( (object) $item );
1804
  /**
1805
  * Filters if an activity item can be commented on or not.
1806
  *
1807
+ * @since 2.0.0
1808
  *
1809
  * @param bool $can_comment Whether an activity item can be commented on or not.
1810
  */
1817
  * In some cases, BuddyPress gives us a structured tree of activity
1818
  * items plus their comments. This method converts it to a flat array.
1819
  *
1820
+ * @since 1.6.0
1821
  *
1822
  * @param array $tree Source array.
 
1823
  * @return array Flattened array.
1824
  */
1825
  public static function flatten_activity_array( $tree ){
1836
 
1837
  return $tree;
1838
  }
 
 
 
 
 
 
 
 
 
 
 
 
1839
  }
bp-activity/bp-activity-akismet.php CHANGED
@@ -3,33 +3,34 @@
3
  * Akismet support for BuddyPress' Activity Stream.
4
  *
5
  * @package BuddyPress
6
- * @since BuddyPress (1.6.0)
7
- * @subpackage Activity
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Akismet support for the Activity component.
15
  *
16
- * @since BuddyPress (1.6.0)
17
- * @since BuddyPress (2.3.0) We only support Akismet 3+.
18
  */
19
  class BP_Akismet {
 
20
  /**
21
  * The activity last marked as spam.
22
  *
23
- * @access protected
 
24
  * @var BP_Activity_Activity
25
- * @since BuddyPress (1.6.0)
26
  */
27
  protected $last_activity = null;
28
 
29
  /**
30
  * Constructor.
31
  *
32
- * @since BuddyPress (1.6.0)
33
  */
34
  public function __construct() {
35
  $this->setup_actions();
@@ -38,28 +39,28 @@ class BP_Akismet {
38
  /**
39
  * Hook Akismet into the activity stream.
40
  *
41
- * @since BuddyPress (1.6.0)
42
  */
43
  protected function setup_actions() {
44
- // Add nonces to activity stream lists
45
  add_action( 'bp_after_activity_post_form', array( $this, 'add_activity_stream_nonce' ) );
46
  add_action( 'bp_activity_entry_comments', array( $this, 'add_activity_stream_nonce' ) );
47
 
48
- // Add a "mark as spam" button to individual activity items
49
  add_action( 'bp_activity_entry_meta', array( $this, 'add_activity_spam_button' ) );
50
  add_action( 'bp_activity_comment_options', array( $this, 'add_activity_comment_spam_button' ) );
51
 
52
- // Check activity for spam
53
  add_action( 'bp_activity_before_save', array( $this, 'check_activity' ), 4, 1 );
54
 
55
- // Tidy up member's latest (activity) update
56
  add_action( 'bp_activity_posted_update', array( $this, 'check_member_activity_update' ), 1, 3 );
57
 
58
- // Hooks to extend Activity core spam/ham functions for Akismet
59
  add_action( 'bp_activity_mark_as_spam', array( $this, 'mark_as_spam' ), 10, 2 );
60
  add_action( 'bp_activity_mark_as_ham', array( $this, 'mark_as_ham' ), 10, 2 );
61
 
62
- // Hook into the Activity wp-admin screen
63
  add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'comment_row_action' ), 10, 2 );
64
  add_action( 'bp_activity_admin_load', array( $this, 'add_history_metabox' ) );
65
  }
@@ -70,11 +71,10 @@ class BP_Akismet {
70
  * This function lifted with love from the Akismet WordPress plugin's
71
  * akismet_comment_row_action() function. Thanks!
72
  *
73
- * @since BuddyPress (1.6.0)
74
  *
75
  * @param array $actions The hover links.
76
  * @param array $activity The activity for the current row being processed.
77
- *
78
  * @return array The hover links.
79
  */
80
  function comment_row_action( $actions, $activity ) {
@@ -83,7 +83,7 @@ class BP_Akismet {
83
  $desc = '';
84
 
85
  if ( !$user_result || $user_result == $akismet_result ) {
86
- // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
87
  if ( 'true' == $akismet_result && $activity['is_spam'] )
88
  $desc = __( 'Flagged as spam by Akismet', 'buddypress' );
89
 
@@ -99,7 +99,7 @@ class BP_Akismet {
99
  $desc = sprintf( __( 'Un-spammed by %s', 'buddypress' ), $who );
100
  }
101
 
102
- // add a History item to the hover links, just after Edit
103
  if ( $akismet_result ) {
104
  $b = array();
105
  foreach ( $actions as $k => $item ) {
@@ -117,7 +117,7 @@ class BP_Akismet {
117
  /**
118
  * Filters the list of actions for the current activity's row.
119
  *
120
- * @since BuddyPress (1.6.0)
121
  *
122
  * @param array $actions Array of available actions for the current activity item's row.
123
  */
@@ -131,7 +131,7 @@ class BP_Akismet {
131
  * the reply form of each activity item. The nonces are, in turn, used
132
  * by Akismet to help detect spam activity.
133
  *
134
- * @since BuddyPress (1.6.0)
135
  *
136
  * @see https://plugins.trac.wordpress.org/ticket/1232
137
  */
@@ -139,7 +139,7 @@ class BP_Akismet {
139
  $form_id = '_bp_as_nonce';
140
  $value = '_bp_as_nonce_' . bp_loggedin_user_id();
141
 
142
- // If we're in the activity stream loop, we can use the current item's ID to make the nonce unique
143
  if ( 'bp_activity_entry_comments' == current_filter() ) {
144
  $form_id .= '_' . bp_get_activity_id();
145
  $value .= '_' . bp_get_activity_id();
@@ -160,7 +160,7 @@ class BP_Akismet {
160
  * This can't be done in BP_Akismet::check_activity() due to the
161
  * default AJAX implementation; see bp_dtheme_post_update().
162
  *
163
- * @since BuddyPress (1.6.0)
164
  *
165
  * @see bp_dtheme_post_update()
166
  *
@@ -186,7 +186,7 @@ class BP_Akismet {
186
  *
187
  * This function is intended to be used inside the activity stream loop.
188
  *
189
- * @since BuddyPress (1.6.0)
190
  */
191
  public function add_activity_spam_button() {
192
  if ( !bp_activity_user_can_mark_spam() )
@@ -214,7 +214,7 @@ class BP_Akismet {
214
  *
215
  * This function is intended to be used inside the activity stream loop.
216
  *
217
- * @since BuddyPress (1.6.0)
218
  */
219
  public function add_activity_comment_spam_button() {
220
  if ( !bp_activity_user_can_mark_spam() )
@@ -241,18 +241,18 @@ class BP_Akismet {
241
  /**
242
  * Get a filterable list of activity types that Akismet should automatically check for spam.
243
  *
244
- * @since BuddyPress (1.6.0)
245
  *
246
  * @static
247
  *
248
- * @return array List of activity types.
249
  */
250
  public static function get_activity_types() {
251
 
252
  /**
253
  * Filters the list of activity types that Akismet should automatically check for spam.
254
  *
255
- * @since BuddyPress (1.6.0)
256
  *
257
  * @param array Array of default activity types for Akismet to check.
258
  */
@@ -262,7 +262,7 @@ class BP_Akismet {
262
  /**
263
  * Mark activity item as spam.
264
  *
265
- * @since BuddyPress (1.6.0)
266
  *
267
  * @param BP_Activity_Activity $activity Activity item being spammed.
268
  * @param string $source Either "by_a_person" (e.g. a person has
@@ -270,13 +270,13 @@ class BP_Akismet {
270
  * "by_akismet" (automatically spammed).
271
  */
272
  public function mark_as_spam( $activity, $source ) {
273
- // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
274
  $this->last_activity = $activity;
275
 
276
  /**
277
  * Fires after marking an activity item has been marked as spam.
278
  *
279
- * @since BuddyPress (1.6.0)
280
  *
281
  * @param BP_Activity_Activity $activity Activity object being marked as spam.
282
  * @param string $source Source of the whom marked as spam.
@@ -290,7 +290,7 @@ class BP_Akismet {
290
  /**
291
  * Mark activity item as ham.
292
  *
293
- * @since BuddyPress (1.6.0)
294
  *
295
  * @param BP_Activity_Activity $activity Activity item being hammed.
296
  * @param string $source Either "by_a_person" (e.g. a person has
@@ -305,7 +305,7 @@ class BP_Akismet {
305
  /**
306
  * Fires after marking an activity item has been marked as ham.
307
  *
308
- * @since BuddyPress (1.6.0)
309
  *
310
  * @param BP_Activity_Activity $activity Activity object being marked as ham.
311
  * @param string $source Source of the whom marked as ham.
@@ -319,14 +319,13 @@ class BP_Akismet {
319
  /**
320
  * Build a data package for the Akismet service to inspect.
321
  *
322
- * @since BuddyPress (1.6.0)
323
  *
324
  * @see http://akismet.com/development/api/#comment-check
325
  * @static
326
  *
327
  * @param BP_Activity_Activity $activity Activity item data.
328
- *
329
- * @return array
330
  */
331
  public static function build_akismet_data_package( $activity ) {
332
  $userdata = get_userdata( $activity->user_id );
@@ -359,7 +358,7 @@ class BP_Akismet {
359
  /**
360
  * Filters activity data before being sent to Akismet to inspect.
361
  *
362
- * @since BuddyPress (1.6.0)
363
  *
364
  * @param array $activity_data Array of activity data for Akismet to inspect.
365
  * @param BP_Activity_Activity $activity Activity item data.
@@ -370,7 +369,7 @@ class BP_Akismet {
370
  /**
371
  * Check if the activity item is spam or ham.
372
  *
373
- * @since BuddyPress (1.6.0)
374
  *
375
  * @see http://akismet.com/development/api/
376
  * @todo Spam counter?
@@ -383,27 +382,27 @@ class BP_Akismet {
383
  if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
384
  return;
385
 
386
- // Make sure last_activity is clear to avoid any confusion
387
  $this->last_activity = null;
388
 
389
- // Build data package for Akismet
390
  $activity_data = BP_Akismet::build_akismet_data_package( $activity );
391
 
392
- // Check with Akismet to see if this is spam
393
  $activity_data = $this->send_akismet_request( $activity_data, 'check', 'spam' );
394
 
395
- // Record this item
396
  $this->last_activity = $activity;
397
 
398
- // Store a copy of the data that was submitted to Akismet
399
  $this->last_activity->akismet_submission = $activity_data;
400
 
401
- // Spam
402
  if ( 'true' == $activity_data['bp_as_result'] ) {
403
  /**
404
  * Fires after an activity item has been proven to be spam, but before officially being marked as spam.
405
  *
406
- * @since BuddyPress (1.6.0)
407
  *
408
  * @param BP_Activity_Activity $activity The activity item proven to be spam.
409
  * @param array $activity_data Array of activity data for item including
@@ -411,18 +410,18 @@ class BP_Akismet {
411
  */
412
  do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
413
 
414
- // Mark as spam
415
  bp_activity_mark_as_spam( $activity, 'by_akismet' );
416
  }
417
 
418
- // Update activity meta after a spam check
419
  add_action( 'bp_activity_after_save', array( $this, 'update_activity_akismet_meta' ), 1, 1 );
420
  }
421
 
422
  /**
423
  * Update activity meta after a manual spam change (user-initiated).
424
  *
425
- * @since BuddyPress (1.6.0)
426
  *
427
  * @param BP_Activity_Activity $activity The activity to check.
428
  */
@@ -439,7 +438,7 @@ class BP_Akismet {
439
  /**
440
  * Update activity meta after a manual ham change (user-initiated).
441
  *
442
- * @since BuddyPress (1.6.0)
443
  *
444
  * @param BP_Activity_Activity $activity The activity to check.
445
  */
@@ -456,12 +455,12 @@ class BP_Akismet {
456
  /**
457
  * Update activity meta after an automatic spam check (not user-initiated).
458
  *
459
- * @since BuddyPress (1.6.0)
460
  *
461
  * @param BP_Activity_Activity $activity The activity to check.
462
  */
463
  public function update_activity_akismet_meta( $activity ) {
464
- // Check we're dealing with what was last updated by Akismet
465
  if ( empty( $this->last_activity ) || !empty( $this->last_activity ) && $activity->id != $this->last_activity->id )
466
  return;
467
 
@@ -469,12 +468,12 @@ class BP_Akismet {
469
  if ( !in_array( $this->last_activity->type, BP_Akismet::get_activity_types() ) )
470
  return;
471
 
472
- // Spam
473
  if ( 'true' == $this->last_activity->akismet_submission['bp_as_result'] ) {
474
  bp_activity_update_meta( $activity->id, '_bp_akismet_result', 'true' );
475
  $this->update_activity_history( $activity->id, __( 'Akismet caught this item as spam', 'buddypress' ), 'check-spam' );
476
 
477
- // Not spam
478
  } elseif ( 'false' == $this->last_activity->akismet_submission['bp_as_result'] ) {
479
  bp_activity_update_meta( $activity->id, '_bp_akismet_result', 'false' );
480
  $this->update_activity_history( $activity->id, __( 'Akismet cleared this item', 'buddypress' ), 'check-ham' );
@@ -485,7 +484,7 @@ class BP_Akismet {
485
  $this->update_activity_history( $activity->id, sprintf( __( 'Akismet was unable to check this item (response: %s), will automatically retry again later.', 'buddypress' ), $this->last_activity->akismet_submission['bp_as_result'] ), 'check-error' );
486
  }
487
 
488
- // Record the original data which was submitted to Akismet for checking
489
  bp_activity_update_meta( $activity->id, '_bp_akismet_submission', $this->last_activity->akismet_submission );
490
  }
491
 
@@ -494,12 +493,11 @@ class BP_Akismet {
494
  *
495
  * Props to WordPress core Akismet plugin for a lot of this.
496
  *
497
- * @since BuddyPress (1.6.0)
498
  *
499
  * @param array $activity_data Packet of information to submit to Akismet.
500
  * @param string $check "check" or "submit".
501
  * @param string $spam "spam" or "ham".
502
- *
503
  * @return array $activity_data Activity data, with Akismet data added.
504
  */
505
  public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
@@ -515,22 +513,22 @@ class BP_Akismet {
515
  if ( Akismet::is_test_mode() )
516
  $activity_data['is_test'] = 'true';
517
 
518
- // Loop through _POST args and rekey strings
519
  foreach ( $_POST as $key => $value )
520
  if ( is_string( $value ) && 'cookie' != $key )
521
  $activity_data['POST_' . $key] = $value;
522
 
523
- // Keys to ignore
524
  $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
525
 
526
- // Loop through _SERVER args and remove whitelisted keys
527
  foreach ( $_SERVER as $key => $value ) {
528
 
529
- // Key should not be ignored
530
  if ( !in_array( $key, $ignore ) && is_string( $value ) ) {
531
  $activity_data[$key] = $value;
532
 
533
- // Key should be ignored
534
  } else {
535
  $activity_data[$key] = '';
536
  }
@@ -544,18 +542,18 @@ class BP_Akismet {
544
  elseif ( 'submit' == $check )
545
  $path = 'submit-' . $spam;
546
 
547
- // Send to Akismet
548
  add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
549
  $response = Akismet::http_post( $query_string, $path );
550
  remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
551
 
552
- // Get the response
553
  if ( ! empty( $response[1] ) && ! is_wp_error( $response[1] ) )
554
  $activity_data['bp_as_result'] = $response[1];
555
  else
556
  $activity_data['bp_as_result'] = false;
557
 
558
- // Perform a daily tidy up
559
  if ( ! wp_next_scheduled( 'bp_activity_akismet_delete_old_metadata' ) )
560
  wp_schedule_event( time(), 'daily', 'bp_activity_akismet_delete_old_metadata' );
561
 
@@ -565,10 +563,9 @@ class BP_Akismet {
565
  /**
566
  * Filters user agent when sending to Akismet to add BuddyPress info.
567
  *
568
- * @since BuddyPress (1.6.0)
569
  *
570
  * @param string $user_agent User agent string, as generated by Akismet.
571
- *
572
  * @return string $user_agent Modified user agent string.
573
  */
574
  public function buddypress_ua( $user_agent ) {
@@ -579,23 +576,23 @@ class BP_Akismet {
579
  /**
580
  * Adds a "History" meta box to the activity edit screen.
581
  *
582
- * @since BuddyPress (1.6.0)
583
  *
584
  * @param string $screen_action The type of screen that has been requested.
585
  */
586
  function add_history_metabox( $screen_action ) {
587
- // Only proceed if we're on the edit screen
588
  if ( 'edit' != $screen_action )
589
  return;
590
 
591
- // Display meta box with a low priority (low position on screen by default)
592
  add_meta_box( 'bp_activity_history', __( 'Activity History', 'buddypress' ), array( $this, 'history_metabox' ), get_current_screen()->id, 'normal', 'low' );
593
  }
594
 
595
  /**
596
  * History meta box for the Activity admin edit screen.
597
  *
598
- * @since BuddyPress (1.6.0)
599
  *
600
  * @see https://buddypress.trac.wordpress.org/ticket/3907
601
  * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
@@ -616,7 +613,7 @@ class BP_Akismet {
616
  /**
617
  * Update an activity item's Akismet history.
618
  *
619
- * @since BuddyPress (1.6.0)
620
  *
621
  * @param int $activity_id Activity item ID.
622
  * @param string $message Human-readable description of what's changed.
@@ -630,17 +627,16 @@ class BP_Akismet {
630
  'user' => bp_loggedin_user_id(),
631
  );
632
 
633
- // Save the history data
634
  bp_activity_update_meta( $activity_id, '_bp_akismet_history', $event );
635
  }
636
 
637
  /**
638
  * Get an activity item's Akismet history.
639
  *
640
- * @since BuddyPress (1.6.0)
641
  *
642
  * @param int $activity_id Activity item ID.
643
- *
644
  * @return array The activity item's Akismet history.
645
  */
646
  public function get_activity_history( $activity_id = 0 ) {
@@ -648,7 +644,7 @@ class BP_Akismet {
648
  if ( $history === false )
649
  $history = array();
650
 
651
- // Sort it by the time recorded
652
  usort( $history, 'akismet_cmp_time' );
653
 
654
  return $history;
@@ -661,7 +657,7 @@ class BP_Akismet {
661
  * This is done as a clean-up mechanism, as _bp_akismet_submission meta can
662
  * grow to be quite large.
663
  *
664
- * @since BuddyPress (1.6.0)
665
  *
666
  * @global wpdb $wpdb WordPress database object.
667
  */
@@ -673,13 +669,13 @@ function bp_activity_akismet_delete_old_metadata() {
673
  /**
674
  * Filters the threshold for how many days old Akismet metadata needs to be before being automatically deleted.
675
  *
676
- * @since BuddyPress (1.6.0)
677
  *
678
  * @param integer 15 How many days old metadata needs to be.
679
  */
680
  $interval = apply_filters( 'bp_activity_akismet_delete_meta_interval', 15 );
681
 
682
- // Enforce a minimum of 1 day
683
  $interval = max( 1, absint( $interval ) );
684
 
685
  // _bp_akismet_submission meta values are large, so expire them after $interval days regardless of the activity status
3
  * Akismet support for BuddyPress' Activity Stream.
4
  *
5
  * @package BuddyPress
6
+ * @subpackage ActivityAkismet
7
+ * @since 1.6.0
8
  */
9
 
10
+ // Exit if accessed directly.
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Akismet support for the Activity component.
15
  *
16
+ * @since 1.6.0
17
+ * @since 2.3.0 We only support Akismet 3+.
18
  */
19
  class BP_Akismet {
20
+
21
  /**
22
  * The activity last marked as spam.
23
  *
24
+ * @since 1.6.0
25
+ *
26
  * @var BP_Activity_Activity
 
27
  */
28
  protected $last_activity = null;
29
 
30
  /**
31
  * Constructor.
32
  *
33
+ * @since 1.6.0
34
  */
35
  public function __construct() {
36
  $this->setup_actions();
39
  /**
40
  * Hook Akismet into the activity stream.
41
  *
42
+ * @since 1.6.0
43
  */
44
  protected function setup_actions() {
45
+ // Add nonces to activity stream lists.
46
  add_action( 'bp_after_activity_post_form', array( $this, 'add_activity_stream_nonce' ) );
47
  add_action( 'bp_activity_entry_comments', array( $this, 'add_activity_stream_nonce' ) );
48
 
49
+ // Add a "mark as spam" button to individual activity items.
50
  add_action( 'bp_activity_entry_meta', array( $this, 'add_activity_spam_button' ) );
51
  add_action( 'bp_activity_comment_options', array( $this, 'add_activity_comment_spam_button' ) );
52
 
53
+ // Check activity for spam.
54
  add_action( 'bp_activity_before_save', array( $this, 'check_activity' ), 4, 1 );
55
 
56
+ // Tidy up member's latest (activity) update.
57
  add_action( 'bp_activity_posted_update', array( $this, 'check_member_activity_update' ), 1, 3 );
58
 
59
+ // Hooks to extend Activity core spam/ham functions for Akismet.
60
  add_action( 'bp_activity_mark_as_spam', array( $this, 'mark_as_spam' ), 10, 2 );
61
  add_action( 'bp_activity_mark_as_ham', array( $this, 'mark_as_ham' ), 10, 2 );
62
 
63
+ // Hook into the Activity wp-admin screen.
64
  add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'comment_row_action' ), 10, 2 );
65
  add_action( 'bp_activity_admin_load', array( $this, 'add_history_metabox' ) );
66
  }
71
  * This function lifted with love from the Akismet WordPress plugin's
72
  * akismet_comment_row_action() function. Thanks!
73
  *
74
+ * @since 1.6.0
75
  *
76
  * @param array $actions The hover links.
77
  * @param array $activity The activity for the current row being processed.
 
78
  * @return array The hover links.
79
  */
80
  function comment_row_action( $actions, $activity ) {
83
  $desc = '';
84
 
85
  if ( !$user_result || $user_result == $akismet_result ) {
86
+ // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same.
87
  if ( 'true' == $akismet_result && $activity['is_spam'] )
88
  $desc = __( 'Flagged as spam by Akismet', 'buddypress' );
89
 
99
  $desc = sprintf( __( 'Un-spammed by %s', 'buddypress' ), $who );
100
  }
101
 
102
+ // Add a History item to the hover links, just after Edit.
103
  if ( $akismet_result ) {
104
  $b = array();
105
  foreach ( $actions as $k => $item ) {
117
  /**
118
  * Filters the list of actions for the current activity's row.
119
  *
120
+ * @since 1.6.0
121
  *
122
  * @param array $actions Array of available actions for the current activity item's row.
123
  */
131
  * the reply form of each activity item. The nonces are, in turn, used
132
  * by Akismet to help detect spam activity.
133
  *
134
+ * @since 1.6.0
135
  *
136
  * @see https://plugins.trac.wordpress.org/ticket/1232
137
  */
139
  $form_id = '_bp_as_nonce';
140
  $value = '_bp_as_nonce_' . bp_loggedin_user_id();
141
 
142
+ // If we're in the activity stream loop, we can use the current item's ID to make the nonce unique.
143
  if ( 'bp_activity_entry_comments' == current_filter() ) {
144
  $form_id .= '_' . bp_get_activity_id();
145
  $value .= '_' . bp_get_activity_id();
160
  * This can't be done in BP_Akismet::check_activity() due to the
161
  * default AJAX implementation; see bp_dtheme_post_update().
162
  *
163
+ * @since 1.6.0
164
  *
165
  * @see bp_dtheme_post_update()
166
  *
186
  *
187
  * This function is intended to be used inside the activity stream loop.
188
  *
189
+ * @since 1.6.0
190
  */
191
  public function add_activity_spam_button() {
192
  if ( !bp_activity_user_can_mark_spam() )
214
  *
215
  * This function is intended to be used inside the activity stream loop.
216
  *
217
+ * @since 1.6.0
218
  */
219
  public function add_activity_comment_spam_button() {
220
  if ( !bp_activity_user_can_mark_spam() )
241
  /**
242
  * Get a filterable list of activity types that Akismet should automatically check for spam.
243
  *
244
+ * @since 1.6.0
245
  *
246
  * @static
247
  *
248
+ * @return array $value List of activity types.
249
  */
250
  public static function get_activity_types() {
251
 
252
  /**
253
  * Filters the list of activity types that Akismet should automatically check for spam.
254
  *
255
+ * @since 1.6.0
256
  *
257
  * @param array Array of default activity types for Akismet to check.
258
  */
262
  /**
263
  * Mark activity item as spam.
264
  *
265
+ * @since 1.6.0
266
  *
267
  * @param BP_Activity_Activity $activity Activity item being spammed.
268
  * @param string $source Either "by_a_person" (e.g. a person has
270
  * "by_akismet" (automatically spammed).
271
  */
272
  public function mark_as_spam( $activity, $source ) {
273
+ // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update().
274
  $this->last_activity = $activity;
275
 
276
  /**
277
  * Fires after marking an activity item has been marked as spam.
278
  *
279
+ * @since 1.6.0
280
  *
281
  * @param BP_Activity_Activity $activity Activity object being marked as spam.
282
  * @param string $source Source of the whom marked as spam.
290
  /**
291
  * Mark activity item as ham.
292
  *
293
+ * @since 1.6.0
294
  *
295
  * @param BP_Activity_Activity $activity Activity item being hammed.
296
  * @param string $source Either "by_a_person" (e.g. a person has
305
  /**
306
  * Fires after marking an activity item has been marked as ham.
307
  *
308
+ * @since 1.6.0
309
  *
310
  * @param BP_Activity_Activity $activity Activity object being marked as ham.
311
  * @param string $source Source of the whom marked as ham.
319
  /**
320
  * Build a data package for the Akismet service to inspect.
321
  *
322
+ * @since 1.6.0
323
  *
324
  * @see http://akismet.com/development/api/#comment-check
325
  * @static
326
  *
327
  * @param BP_Activity_Activity $activity Activity item data.
328
+ * @return array $activity_data
 
329
  */
330
  public static function build_akismet_data_package( $activity ) {
331
  $userdata = get_userdata( $activity->user_id );
358
  /**
359
  * Filters activity data before being sent to Akismet to inspect.
360
  *
361
+ * @since 1.6.0
362
  *
363
  * @param array $activity_data Array of activity data for Akismet to inspect.
364
  * @param BP_Activity_Activity $activity Activity item data.
369
  /**
370
  * Check if the activity item is spam or ham.
371
  *
372
+ * @since 1.6.0
373
  *
374
  * @see http://akismet.com/development/api/
375
  * @todo Spam counter?
382
  if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
383
  return;
384
 
385
+ // Make sure last_activity is clear to avoid any confusion.
386
  $this->last_activity = null;
387
 
388
+ // Build data package for Akismet.
389
  $activity_data = BP_Akismet::build_akismet_data_package( $activity );
390
 
391
+ // Check with Akismet to see if this is spam.
392
  $activity_data = $this->send_akismet_request( $activity_data, 'check', 'spam' );
393
 
394
+ // Record this item.
395
  $this->last_activity = $activity;
396
 
397
+ // Store a copy of the data that was submitted to Akismet.
398
  $this->last_activity->akismet_submission = $activity_data;
399
 
400
+ // Spam.
401
  if ( 'true' == $activity_data['bp_as_result'] ) {
402
  /**
403
  * Fires after an activity item has been proven to be spam, but before officially being marked as spam.
404
  *
405
+ * @since 1.6.0
406
  *
407
  * @param BP_Activity_Activity $activity The activity item proven to be spam.
408
  * @param array $activity_data Array of activity data for item including
410
  */
411
  do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
412
 
413
+ // Mark as spam.
414
  bp_activity_mark_as_spam( $activity, 'by_akismet' );
415
  }
416
 
417
+ // Update activity meta after a spam check.
418
  add_action( 'bp_activity_after_save', array( $this, 'update_activity_akismet_meta' ), 1, 1 );
419
  }
420
 
421
  /**
422
  * Update activity meta after a manual spam change (user-initiated).
423
  *
424
+ * @since 1.6.0
425
  *
426
  * @param BP_Activity_Activity $activity The activity to check.
427
  */
438
  /**
439
  * Update activity meta after a manual ham change (user-initiated).
440
  *
441
+ * @since 1.6.0
442
  *
443
  * @param BP_Activity_Activity $activity The activity to check.
444
  */
455
  /**
456
  * Update activity meta after an automatic spam check (not user-initiated).
457
  *
458
+ * @since 1.6.0
459
  *
460
  * @param BP_Activity_Activity $activity The activity to check.
461
  */
462
  public function update_activity_akismet_meta( $activity ) {
463
+ // Check we're dealing with what was last updated by Akismet.
464
  if ( empty( $this->last_activity ) || !empty( $this->last_activity ) && $activity->id != $this->last_activity->id )
465
  return;
466
 
468
  if ( !in_array( $this->last_activity->type, BP_Akismet::get_activity_types() ) )
469
  return;
470
 
471
+ // Spam.
472
  if ( 'true' == $this->last_activity->akismet_submission['bp_as_result'] ) {
473
  bp_activity_update_meta( $activity->id, '_bp_akismet_result', 'true' );
474
  $this->update_activity_history( $activity->id, __( 'Akismet caught this item as spam', 'buddypress' ), 'check-spam' );
475
 
476
+ // Not spam.
477
  } elseif ( 'false' == $this->last_activity->akismet_submission['bp_as_result'] ) {
478
  bp_activity_update_meta( $activity->id, '_bp_akismet_result', 'false' );
479
  $this->update_activity_history( $activity->id, __( 'Akismet cleared this item', 'buddypress' ), 'check-ham' );
484
  $this->update_activity_history( $activity->id, sprintf( __( 'Akismet was unable to check this item (response: %s), will automatically retry again later.', 'buddypress' ), $this->last_activity->akismet_submission['bp_as_result'] ), 'check-error' );
485
  }
486
 
487
+ // Record the original data which was submitted to Akismet for checking.
488
  bp_activity_update_meta( $activity->id, '_bp_akismet_submission', $this->last_activity->akismet_submission );
489
  }
490
 
493
  *
494
  * Props to WordPress core Akismet plugin for a lot of this.
495
  *
496
+ * @since 1.6.0
497
  *
498
  * @param array $activity_data Packet of information to submit to Akismet.
499
  * @param string $check "check" or "submit".
500
  * @param string $spam "spam" or "ham".
 
501
  * @return array $activity_data Activity data, with Akismet data added.
502
  */
503
  public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
513
  if ( Akismet::is_test_mode() )
514
  $activity_data['is_test'] = 'true';
515
 
516
+ // Loop through _POST args and rekey strings.
517
  foreach ( $_POST as $key => $value )
518
  if ( is_string( $value ) && 'cookie' != $key )
519
  $activity_data['POST_' . $key] = $value;
520
 
521
+ // Keys to ignore.
522
  $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
523
 
524
+ // Loop through _SERVER args and remove whitelisted keys.
525
  foreach ( $_SERVER as $key => $value ) {
526
 
527
+ // Key should not be ignored.
528
  if ( !in_array( $key, $ignore ) && is_string( $value ) ) {
529
  $activity_data[$key] = $value;
530
 
531
+ // Key should be ignored.
532
  } else {
533
  $activity_data[$key] = '';
534
  }
542
  elseif ( 'submit' == $check )
543
  $path = 'submit-' . $spam;
544
 
545
+ // Send to Akismet.
546
  add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
547
  $response = Akismet::http_post( $query_string, $path );
548
  remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
549
 
550
+ // Get the response.
551
  if ( ! empty( $response[1] ) && ! is_wp_error( $response[1] ) )
552
  $activity_data['bp_as_result'] = $response[1];
553
  else
554
  $activity_data['bp_as_result'] = false;
555
 
556
+ // Perform a daily tidy up.
557
  if ( ! wp_next_scheduled( 'bp_activity_akismet_delete_old_metadata' ) )
558
  wp_schedule_event( time(), 'daily', 'bp_activity_akismet_delete_old_metadata' );
559
 
563
  /**
564
  * Filters user agent when sending to Akismet to add BuddyPress info.
565
  *
566
+ * @since 1.6.0
567
  *
568
  * @param string $user_agent User agent string, as generated by Akismet.
 
569
  * @return string $user_agent Modified user agent string.
570
  */
571
  public function buddypress_ua( $user_agent ) {
576
  /**
577
  * Adds a "History" meta box to the activity edit screen.
578
  *
579
+ * @since 1.6.0
580
  *
581
  * @param string $screen_action The type of screen that has been requested.
582
  */
583
  function add_history_metabox( $screen_action ) {
584
+ // Only proceed if we're on the edit screen.
585
  if ( 'edit' != $screen_action )
586
  return;
587
 
588
+ // Display meta box with a low priority (low position on screen by default).
589
  add_meta_box( 'bp_activity_history', __( 'Activity History', 'buddypress' ), array( $this, 'history_metabox' ), get_current_screen()->id, 'normal', 'low' );
590
  }
591
 
592
  /**
593
  * History meta box for the Activity admin edit screen.
594
  *
595
+ * @since 1.6.0
596
  *
597
  * @see https://buddypress.trac.wordpress.org/ticket/3907
598
  * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
613
  /**
614
  * Update an activity item's Akismet history.
615
  *
616
+ * @since 1.6.0
617
  *
618
  * @param int $activity_id Activity item ID.
619
  * @param string $message Human-readable description of what's changed.
627
  'user' => bp_loggedin_user_id(),
628
  );
629
 
630
+ // Save the history data.
631
  bp_activity_update_meta( $activity_id, '_bp_akismet_history', $event );
632
  }
633
 
634
  /**
635
  * Get an activity item's Akismet history.
636
  *
637
+ * @since 1.6.0
638
  *
639
  * @param int $activity_id Activity item ID.
 
640
  * @return array The activity item's Akismet history.
641
  */
642
  public function get_activity_history( $activity_id = 0 ) {
644
  if ( $history === false )
645
  $history = array();
646
 
647
+ // Sort it by the time recorded.
648
  usort( $history, 'akismet_cmp_time' );
649
 
650
  return $history;
657
  * This is done as a clean-up mechanism, as _bp_akismet_submission meta can
658
  * grow to be quite large.
659
  *
660
+ * @since 1.6.0
661
  *
662
  * @global wpdb $wpdb WordPress database object.
663
  */
669
  /**
670
  * Filters the threshold for how many days old Akismet metadata needs to be before being automatically deleted.
671
  *
672
+ * @since 1.6.0
673
  *
674
  * @param integer 15 How many days old metadata needs to be.
675
  */
676
  $interval = apply_filters( 'bp_activity_akismet_delete_meta_interval', 15 );
677
 
678
+ // Enforce a minimum of 1 day.
679
  $interval = max( 1, absint( $interval ) );
680
 
681
  // _bp_akismet_submission meta values are large, so expire them after $interval days regardless of the activity status
bp-activity/bp-activity-cache.php CHANGED
@@ -1,12 +1,13 @@
1
  <?php
2
-
3
  /**
4
  * Functions related to the BuddyPress Activity component and the WP Cache.
5
  *
6
- * @since BuddyPress (1.6.0)
 
 
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
@@ -17,7 +18,7 @@ defined( 'ABSPATH' ) || exit;
17
  * using querying activitymeta inline.
18
  *
19
  * @param int|string|array|bool $activity_ids Accepts a single activity ID, or a comma-
20
- * separated list or array of activity ids
21
  */
22
  function bp_activity_update_meta_cache( $activity_ids = false ) {
23
  $bp = buddypress();
@@ -37,9 +38,9 @@ function bp_activity_update_meta_cache( $activity_ids = false ) {
37
  /**
38
  * Clear a cached activity item when that item is updated.
39
  *
40
- * @since BuddyPress (2.0.0)
41
  *
42
- * @param BP_Activity_Activity $activity
43
  */
44
  function bp_activity_clear_cache_for_activity( $activity ) {
45
  wp_cache_delete( $activity->id, 'bp_activity' );
@@ -50,7 +51,7 @@ add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' );
50
  /**
51
  * Clear cached data for deleted activity items.
52
  *
53
- * @since BuddyPress (2.0.0)
54
  *
55
  * @param array $deleted_ids IDs of deleted activity items.
56
  */
1
  <?php
 
2
  /**
3
  * Functions related to the BuddyPress Activity component and the WP Cache.
4
  *
5
+ * @since 1.6.0
6
+ * @package BuddyPress
7
+ * @subpackage ActivityCache
8
  */
9
 
10
+ // Exit if accessed directly.
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
18
  * using querying activitymeta inline.
19
  *
20
  * @param int|string|array|bool $activity_ids Accepts a single activity ID, or a comma-
21
+ * separated list or array of activity ids.
22
  */
23
  function bp_activity_update_meta_cache( $activity_ids = false ) {
24
  $bp = buddypress();
38
  /**
39
  * Clear a cached activity item when that item is updated.
40
  *
41
+ * @since 2.0.0
42
  *
43
+ * @param BP_Activity_Activity $activity Activity object.
44
  */
45
  function bp_activity_clear_cache_for_activity( $activity ) {
46
  wp_cache_delete( $activity->id, 'bp_activity' );
51
  /**
52
  * Clear cached data for deleted activity items.
53
  *
54
+ * @since 2.0.0
55
  *
56
  * @param array $deleted_ids IDs of deleted activity items.
57
  */
bp-activity/bp-activity-classes.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * BuddyPress Activity Classes
4
  *
5
  * @package BuddyPress
6
- * @subpackage Activity
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  require dirname( __FILE__ ) . '/classes/class-bp-activity-activity.php';
1
  <?php
2
  /**
3
+ * BuddyPress Activity Classes.
4
  *
5
  * @package BuddyPress
6
+ * @subpackage ActivityClasses
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  require dirname( __FILE__ ) . '/classes/class-bp-activity-activity.php';
bp-activity/bp-activity-cssjs.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Activity component CSS/JS
5
  *
@@ -7,20 +6,20 @@
7
  * @subpackage ActivityScripts
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Enqueue @mentions JS.
15
  *
16
- * @since BuddyPress (2.1.0)
17
  */
18
  function bp_activity_mentions_script() {
19
  if ( ! bp_activity_maybe_load_mentions_scripts() ) {
20
  return;
21
  }
22
 
23
- // Special handling for New/Edit screens in wp-admin
24
  if ( is_admin() ) {
25
  if (
26
  ! get_current_screen() ||
@@ -50,7 +49,7 @@ function bp_activity_mentions_script() {
50
  * This is the hook where BP components can add their own prefetched results
51
  * friends to the page for quicker @mentions lookups.
52
  *
53
- * @since BuddyPress (2.1.0)
54
  */
55
  do_action( 'bp_activity_mentions_prime_results' );
56
  }
@@ -60,11 +59,10 @@ add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
60
  /**
61
  * Bind the mentions listener to a wp_editor instance when TinyMCE initializes.
62
  *
63
- * @since BuddyPress (2.3.3)
64
  *
65
  * @param array $settings An array with TinyMCE config.
66
  * @param string $editor_id Unique editor identifier, e.g. 'content'.
67
- *
68
  * @return array $mceInit An array with TinyMCE config.
69
  */
70
  function bp_add_mentions_on_tinymce_init( $settings, $editor_id ) {
1
  <?php
 
2
  /**
3
  * Activity component CSS/JS
4
  *
6
  * @subpackage ActivityScripts
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Enqueue @mentions JS.
14
  *
15
+ * @since 2.1.0
16
  */
17
  function bp_activity_mentions_script() {
18
  if ( ! bp_activity_maybe_load_mentions_scripts() ) {
19
  return;
20
  }
21
 
22
+ // Special handling for New/Edit screens in wp-admin.
23
  if ( is_admin() ) {
24
  if (
25
  ! get_current_screen() ||
49
  * This is the hook where BP components can add their own prefetched results
50
  * friends to the page for quicker @mentions lookups.
51
  *
52
+ * @since 2.1.0
53
  */
54
  do_action( 'bp_activity_mentions_prime_results' );
55
  }
59
  /**
60
  * Bind the mentions listener to a wp_editor instance when TinyMCE initializes.
61
  *
62
+ * @since 2.3.3
63
  *
64
  * @param array $settings An array with TinyMCE config.
65
  * @param string $editor_id Unique editor identifier, e.g. 'content'.
 
66
  * @return array $mceInit An array with TinyMCE config.
67
  */
68
  function bp_add_mentions_on_tinymce_init( $settings, $editor_id ) {
bp-activity/bp-activity-filters.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Filters related to the Activity component.
5
  *
@@ -7,12 +6,12 @@
7
  * @subpackage ActivityFilters
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /** Filters *******************************************************************/
14
 
15
- // Apply WordPress defined filters
16
  add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 );
17
  add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
18
  add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
@@ -78,7 +77,7 @@ add_filter( 'bp_get_activity_feed_item_description', 'stripslashes_deep', 5 );
78
 
79
  add_filter( 'bp_activity_primary_link_before_save', 'esc_url_raw' );
80
 
81
- // Apply BuddyPress-defined filters
82
  add_filter( 'bp_get_activity_content', 'bp_activity_make_nofollow_filter' );
83
  add_filter( 'bp_get_activity_content_body', 'bp_activity_make_nofollow_filter' );
84
  add_filter( 'bp_get_activity_parent_content', 'bp_activity_make_nofollow_filter' );
@@ -101,10 +100,10 @@ add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
101
 
102
  /** Actions *******************************************************************/
103
 
104
- // At-name filter
105
  add_action( 'bp_activity_before_save', 'bp_activity_at_name_filter_updates' );
106
 
107
- // Activity stream moderation
108
  add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 );
109
  add_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1 );
110
 
@@ -113,7 +112,7 @@ add_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1
113
  /**
114
  * Types of activity stream items to moderate.
115
  *
116
- * @since BuddyPress (1.6.0)
117
  *
118
  * @return array $types List of the activity types to moderate.
119
  */
@@ -126,7 +125,7 @@ function bp_activity_get_moderated_activity_types() {
126
  /**
127
  * Filters the default activity types that BuddyPress should moderate.
128
  *
129
- * @since BuddyPress (1.6.0)
130
  *
131
  * @param array $types Default activity types to moderate.
132
  */
@@ -136,18 +135,18 @@ function bp_activity_get_moderated_activity_types() {
136
  /**
137
  * Moderate the posted activity item, if it contains moderate keywords.
138
  *
139
- * @since BuddyPress (1.6.0)
140
  *
141
  * @param BP_Activity_Activity $activity The activity object to check.
142
  */
143
  function bp_activity_check_moderation_keys( $activity ) {
144
 
145
- // Only check specific types of activity updates
146
  if ( !in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
147
  return;
148
 
149
  // Unset the activity component so activity stream update fails
150
- // @todo This is temporary until some kind of moderation is built
151
  if ( !bp_core_check_for_moderation( $activity->user_id, '', $activity->content ) )
152
  $activity->component = false;
153
  }
@@ -155,17 +154,17 @@ function bp_activity_check_moderation_keys( $activity ) {
155
  /**
156
  * Mark the posted activity as spam, if it contains blacklist keywords.
157
  *
158
- * @since BuddyPress (1.6.0)
159
  *
160
  * @param BP_Activity_Activity $activity The activity object to check.
161
  */
162
  function bp_activity_check_blacklist_keys( $activity ) {
163
 
164
- // Only check specific types of activity updates
165
  if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
166
  return;
167
 
168
- // Mark as spam
169
  if ( ! bp_core_check_for_blacklist( $activity->user_id, '', $activity->content ) )
170
  bp_activity_mark_as_spam( $activity, 'by_blacklist' );
171
  }
@@ -173,13 +172,12 @@ function bp_activity_check_blacklist_keys( $activity ) {
173
  /**
174
  * Custom kses filtering for activity content.
175
  *
176
- * @since BuddyPress (1.1.0)
177
  *
178
  * @uses apply_filters() To call the 'bp_activity_allowed_tags' hook.
179
  * @uses wp_kses()
180
  *
181
  * @param string $content The activity content.
182
- *
183
  * @return string $content Filtered activity content.
184
  */
185
  function bp_activity_filter_kses( $content ) {
@@ -208,7 +206,7 @@ function bp_activity_filter_kses( $content ) {
208
  /**
209
  * Filters the allowed HTML tags for BuddyPress Activity content.
210
  *
211
- * @since BuddyPress (1.2.0)
212
  *
213
  * @param array $value Array of allowed HTML tags and attributes.
214
  */
@@ -219,11 +217,10 @@ function bp_activity_filter_kses( $content ) {
219
  /**
220
  * Find and link @-mentioned users in the contents of a given item.
221
  *
222
- * @since BuddyPress (1.2.0)
223
  *
224
  * @param string $content The contents of a given item.
225
  * @param int $activity_id The activity id. Deprecated.
226
- *
227
  * @return string $content Content filtered for mentions.
228
  */
229
  function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
@@ -233,7 +230,7 @@ function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
233
  return $content;
234
  }
235
 
236
- // Try to find mentions
237
  $usernames = bp_activity_find_mentions( $content );
238
 
239
  // No mentions? Stop now!
@@ -241,11 +238,11 @@ function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
241
  return $content;
242
 
243
  // We don't want to link @mentions that are inside of links, so we
244
- // temporarily remove them
245
  $replace_count = 0;
246
  $replacements = array();
247
  foreach ( $usernames as $username ) {
248
- // prevent @ name linking inside <a> tags
249
  preg_match_all( '/(<a.*?(?!<\/a>)@' . $username . '.*?<\/a>)/', $content, $content_matches );
250
  if ( ! empty( $content_matches[1] ) ) {
251
  foreach ( $content_matches[1] as $replacement ) {
@@ -256,19 +253,19 @@ function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
256
  }
257
  }
258
 
259
- // Linkify the mentions with the username
260
  foreach ( (array) $usernames as $user_id => $username ) {
261
  $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
262
  }
263
 
264
- // put everything back
265
  if ( ! empty( $replacements ) ) {
266
  foreach ( $replacements as $placeholder => $original ) {
267
  $content = str_replace( $placeholder, $original, $content );
268
  }
269
  }
270
 
271
- // Return the content
272
  return $content;
273
  }
274
 
@@ -278,11 +275,11 @@ function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
278
  * If mentions are found, replace @mention text with user links and add our
279
  * hook to send mention notifications after the activity item is saved.
280
  *
281
- * @since BuddyPress (1.5.0)
282
  *
283
  * @uses bp_activity_find_mentions()
284
  *
285
- * @param BP_Activity_Activity $activity
286
  */
287
  function bp_activity_at_name_filter_updates( $activity ) {
288
  // Are mentions disabled?
@@ -294,20 +291,20 @@ function bp_activity_at_name_filter_updates( $activity ) {
294
  if ( ! empty( $activity->is_spam ) )
295
  return;
296
 
297
- // Try to find mentions
298
  $usernames = bp_activity_find_mentions( $activity->content );
299
 
300
  // We have mentions!
301
  if ( ! empty( $usernames ) ) {
302
- // Replace @mention text with userlinks
303
  foreach( (array) $usernames as $user_id => $username ) {
304
  $activity->content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $activity->content );
305
  }
306
 
307
- // Add our hook to send @mention emails after the activity item is saved
308
  add_action( 'bp_activity_after_save', 'bp_activity_at_name_send_emails' );
309
 
310
- // temporary variable to avoid having to run bp_activity_find_mentions() again
311
  buddypress()->activity->mentioned_users = $usernames;
312
  }
313
  }
@@ -315,7 +312,7 @@ function bp_activity_at_name_filter_updates( $activity ) {
315
  /**
316
  * Sends emails and BP notifications for users @-mentioned in an activity item.
317
  *
318
- * @since BuddyPress (1.7.0)
319
  *
320
  * @uses bp_activity_at_message_notification()
321
  * @uses bp_activity_update_mention_count_for_user()
@@ -332,19 +329,19 @@ function bp_activity_at_name_send_emails( $activity ) {
332
  if ( empty( buddypress()->activity->mentioned_users ) )
333
  return;
334
 
335
- // Grab our temporary variable from bp_activity_at_name_filter_updates()
336
  $usernames = buddypress()->activity->mentioned_users;
337
 
338
- // Get rid of temporary variable
339
  unset( buddypress()->activity->mentioned_users );
340
 
341
- // Send @mentions and setup BP notifications
342
  foreach( (array) $usernames as $user_id => $username ) {
343
 
344
  /**
345
  * Filters BuddyPress' ability to send email notifications for @mentions.
346
  *
347
- * @since BuddyPress (1.6.0)
348
  *
349
  * @param bool $value Whether or not BuddyPress should send a notification to the mentioned users.
350
  * @param array $usernames Array of users potentially notified.
@@ -353,7 +350,7 @@ function bp_activity_at_name_send_emails( $activity ) {
353
  bp_activity_at_message_notification( $activity->id, $user_id );
354
  }
355
 
356
- // Updates mention count for the user
357
  bp_activity_update_mention_count_for_user( $user_id, $activity->id );
358
  }
359
  }
@@ -361,10 +358,9 @@ function bp_activity_at_name_send_emails( $activity ) {
361
  /**
362
  * Catch links in activity text so rel=nofollow can be added.
363
  *
364
- * @since BuddyPress (1.2.0)
365
  *
366
  * @param string $text Activity text.
367
- *
368
  * @return string $text Text with rel=nofollow added to any links.
369
  */
370
  function bp_activity_make_nofollow_filter( $text ) {
@@ -374,10 +370,9 @@ function bp_activity_make_nofollow_filter( $text ) {
374
  /**
375
  * Add rel=nofollow to a link.
376
  *
377
- * @since BuddyPress (1.2.0)
378
  *
379
  * @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
380
- *
381
  * @return string $text Link with rel=nofollow added.
382
  */
383
  function bp_activity_make_nofollow_filter_callback( $matches ) {
@@ -391,7 +386,7 @@ function bp_activity_make_nofollow_filter( $text ) {
391
  *
392
  * This method can only be used inside the Activity loop.
393
  *
394
- * @since BuddyPress (1.5.0)
395
  *
396
  * @uses bp_is_single_activity()
397
  * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook.
@@ -402,7 +397,6 @@ function bp_activity_make_nofollow_filter( $text ) {
402
  * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook.
403
  *
404
  * @param string $text The original activity entry text.
405
- *
406
  * @return string $excerpt The truncated text.
407
  */
408
  function bp_activity_truncate_entry( $text ) {
@@ -411,7 +405,7 @@ function bp_activity_truncate_entry( $text ) {
411
  /**
412
  * Provides a filter that lets you choose whether to skip this filter on a per-activity basis.
413
  *
414
- * @since BuddyPress (2.3.0)
415
  *
416
  * @param bool $value If true, text should be checked to see if it needs truncating.
417
  */
@@ -420,7 +414,7 @@ function bp_activity_truncate_entry( $text ) {
420
  isset( $activities_template->activity->type ) && ! in_array( $activities_template->activity->type, array( 'new_blog_post', ), true )
421
  );
422
 
423
- // The full text of the activity update should always show on the single activity screen
424
  if ( ! $maybe_truncate_text || bp_is_single_activity() ) {
425
  return $text;
426
  }
@@ -428,7 +422,7 @@ function bp_activity_truncate_entry( $text ) {
428
  /**
429
  * Filters the appended text for the activity excerpt.
430
  *
431
- * @since BuddyPress (1.5.0)
432
  *
433
  * @param string $value Internationalized "Read more" text.
434
  */
@@ -437,19 +431,20 @@ function bp_activity_truncate_entry( $text ) {
437
  /**
438
  * Filters the excerpt length for the activity excerpt.
439
  *
440
- * @since BuddyPress (1.5.0)
441
  *
442
  * @param int $value Number indicating how many words to trim the excerpt down to.
443
  */
444
  $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
445
 
446
- // Run the text through the excerpt function. If it's too short, the original text will be
447
- // returned.
448
  $excerpt = bp_create_excerpt( $text, $excerpt_length, array( 'ending' => __( '&hellip;', 'buddypress' ) ) );
449
 
450
- // If the text returned by bp_create_excerpt() is different from the original text (ie it's
451
- // been truncated), add the "Read More" link. Note that bp_create_excerpt() is stripping
452
- // shortcodes, so we have strip them from the $text before the comparison
 
 
453
  if ( $excerpt != strip_shortcodes( $text ) ) {
454
  $id = !empty( $activities_template->activity->current_comment->id ) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id();
455
 
@@ -459,7 +454,7 @@ function bp_activity_truncate_entry( $text ) {
459
  /**
460
  * Filters the composite activity excerpt entry.
461
  *
462
- * @since BuddyPress (1.5.0)
463
  *
464
  * @param string $excerpt Excerpt text and markup to be displayed.
465
  * @param string $text The original activity entry text.
@@ -471,12 +466,11 @@ function bp_activity_truncate_entry( $text ) {
471
  /**
472
  * Include extra JavaScript dependencies for activity component.
473
  *
474
- * @since BuddyPress (2.0.0)
475
  *
476
  * @uses bp_activity_do_heartbeat() to check if heartbeat is required.
477
  *
478
  * @param array $js_handles The original dependencies.
479
- *
480
  * @return array $js_handles The new dependencies.
481
  */
482
  function bp_activity_get_js_dependencies( $js_handles = array() ) {
@@ -494,10 +488,9 @@ add_filter( 'bp_core_get_js_dependencies', 'bp_activity_get_js_dependencies', 10
494
  * We use these classes to avoid pagination issues when items are loaded
495
  * dynamically into the activity stream.
496
  *
497
- * @since BuddyPress (2.0.0)
498
- *
499
- * @param string $classes
500
  *
 
501
  * @return string $classes
502
  */
503
  function bp_activity_newest_class( $classes = '' ) {
@@ -514,10 +507,9 @@ function bp_activity_newest_class( $classes = '' ) {
514
  /**
515
  * Check if Activity Heartbeat feature i on to add a timestamp class.
516
  *
517
- * @since BuddyPress (2.0.0)
518
- *
519
- * @param string $classes
520
  *
 
521
  * @return string $classes
522
  */
523
  function bp_activity_timestamp_class( $classes = '' ) {
@@ -541,13 +533,12 @@ add_filter( 'bp_get_activity_css_class', 'bp_activity_timestamp_class', 9, 1 );
541
  /**
542
  * Use WordPress Heartbeat API to check for latest activity update.
543
  *
544
- * @since BuddyPress (2.0.0)
545
  *
546
  * @uses bp_activity_get_last_updated() to get the recorded date of the last activity.
547
  *
548
- * @param array $response
549
- * @param array $data
550
- *
551
  * @return array $response
552
  */
553
  function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) {
@@ -556,7 +547,7 @@ function bp_activity_heartbeat_last_recorded( $response = array(), $data = array
556
  }
557
 
558
  // Use the querystring argument stored in the cookie (to preserve
559
- // filters), but force the offset to get only new items
560
  $activity_latest_args = bp_parse_args(
561
  bp_ajax_querystring( 'activity' ),
562
  array( 'since' => date( 'Y-m-d H:i:s', $data['bp_activity_last_recorded'] ) ),
@@ -570,7 +561,7 @@ function bp_activity_heartbeat_last_recorded( $response = array(), $data = array
570
  $newest_activities = array();
571
  $last_activity_recorded = 0;
572
 
573
- // Temporarily add a just-posted class for new activity items
574
  add_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
575
 
576
  ob_start();
@@ -591,7 +582,7 @@ function bp_activity_heartbeat_last_recorded( $response = array(), $data = array
591
  $newest_activities['last_recorded'] = $last_activity_recorded;
592
  ob_end_clean();
593
 
594
- // Remove the temporary filter
595
  remove_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
596
 
597
  if ( ! empty( $newest_activities['last_recorded'] ) ) {
@@ -606,10 +597,9 @@ add_filter( 'heartbeat_nopriv_received', 'bp_activity_heartbeat_last_recorded',
606
  /**
607
  * Set the strings for WP HeartBeat API where needed.
608
  *
609
- * @since BuddyPress (2.0.0)
610
  *
611
  * @param array $strings Localized strings.
612
- *
613
  * @return array $strings
614
  */
615
  function bp_activity_heartbeat_strings( $strings = array() ) {
@@ -623,7 +613,7 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
623
  /**
624
  * Filter that checks whether the global heartbeat settings already exist.
625
  *
626
- * @since BuddyPress (2.0.0)
627
  *
628
  * @param array $value Heartbeat settings array.
629
  */
@@ -636,7 +626,7 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
636
  /**
637
  * Filters the pulse frequency to be used for the BuddyPress Activity heartbeat.
638
  *
639
- * @since BuddyPress (2.0.0)
640
  *
641
  * @param int $value The frequency in seconds between pulses.
642
  */
@@ -668,16 +658,15 @@ add_filter( 'bp_core_get_js_strings', 'bp_activity_heartbeat_strings', 10, 1 );
668
  /**
669
  * Set up activity arguments for use with the 'just-me' scope.
670
  *
671
- * @since BuddyPress (2.2.0)
672
  *
673
  * @param array $retval Empty array by default.
674
  * @param array $filter Current activity arguments.
675
- *
676
- * @return array
677
  */
678
  function bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
679
 
680
- // Determine the user_id
681
  if ( ! empty( $filter['user_id'] ) ) {
682
  $user_id = $filter['user_id'];
683
  } else {
@@ -703,7 +692,7 @@ function bp_activity_filter_just_me_scope( $retval = array(), $filter = array()
703
  ),
704
  $show_hidden,
705
 
706
- // overrides
707
  'override' => array(
708
  'display_comments' => 'stream',
709
  'filter' => array( 'user_id' => 0 ),
@@ -718,16 +707,15 @@ add_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_sc
718
  /**
719
  * Set up activity arguments for use with the 'favorites' scope.
720
  *
721
- * @since BuddyPress (2.2.0)
722
  *
723
  * @param array $retval Empty array by default.
724
  * @param array $filter Current activity arguments.
725
- *
726
- * @return array
727
  */
728
  function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) {
729
 
730
- // Determine the user_id
731
  if ( ! empty( $filter['user_id'] ) ) {
732
  $user_id = $filter['user_id'];
733
  } else {
@@ -736,7 +724,7 @@ function bp_activity_filter_favorites_scope( $retval = array(), $filter = array(
736
  : bp_loggedin_user_id();
737
  }
738
 
739
- // Determine the favorites
740
  $favs = bp_activity_get_user_favorites( $user_id );
741
  if ( empty( $favs ) ) {
742
  $favs = array( 0 );
@@ -760,7 +748,7 @@ function bp_activity_filter_favorites_scope( $retval = array(), $filter = array(
760
  ),
761
  $show_hidden,
762
 
763
- // overrides
764
  'override' => array(
765
  'display_comments' => true,
766
  'filter' => array( 'user_id' => 0 ),
@@ -776,12 +764,11 @@ add_filter( 'bp_activity_set_favorites_scope_args', 'bp_activity_filter_favorite
776
  /**
777
  * Set up activity arguments for use with the 'favorites' scope.
778
  *
779
- * @since BuddyPress (2.2.0)
780
  *
781
  * @param array $retval Empty array by default.
782
  * @param array $filter Current activity arguments.
783
- *
784
- * @return array
785
  */
786
  function bp_activity_filter_mentions_scope( $retval = array(), $filter = array() ) {
787
 
@@ -790,7 +777,7 @@ function bp_activity_filter_mentions_scope( $retval = array(), $filter = array()
790
  return $retval;
791
  }
792
 
793
- // Determine the user_id
794
  if ( ! empty( $filter['user_id'] ) ) {
795
  $user_id = $filter['user_id'];
796
  } else {
@@ -819,10 +806,10 @@ function bp_activity_filter_mentions_scope( $retval = array(), $filter = array()
819
  ),
820
  $show_hidden,
821
 
822
- // overrides
823
  'override' => array(
824
 
825
- // clear search terms so 'mentions' scope works with other scopes
826
  'search_terms' => false,
827
 
828
  'display_comments' => 'stream',
1
  <?php
 
2
  /**
3
  * Filters related to the Activity component.
4
  *
6
  * @subpackage ActivityFilters
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /** Filters *******************************************************************/
13
 
14
+ // Apply WordPress defined filters.
15
  add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 );
16
  add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
17
  add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
77
 
78
  add_filter( 'bp_activity_primary_link_before_save', 'esc_url_raw' );
79
 
80
+ // Apply BuddyPress-defined filters.
81
  add_filter( 'bp_get_activity_content', 'bp_activity_make_nofollow_filter' );
82
  add_filter( 'bp_get_activity_content_body', 'bp_activity_make_nofollow_filter' );
83
  add_filter( 'bp_get_activity_parent_content', 'bp_activity_make_nofollow_filter' );
100
 
101
  /** Actions *******************************************************************/
102
 
103
+ // At-name filter.
104
  add_action( 'bp_activity_before_save', 'bp_activity_at_name_filter_updates' );
105
 
106
+ // Activity stream moderation.
107
  add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 );
108
  add_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1 );
109
 
112
  /**
113
  * Types of activity stream items to moderate.
114
  *
115
+ * @since 1.6.0
116
  *
117
  * @return array $types List of the activity types to moderate.
118
  */
125
  /**
126
  * Filters the default activity types that BuddyPress should moderate.
127
  *
128
+ * @since 1.6.0
129
  *
130
  * @param array $types Default activity types to moderate.
131
  */
135
  /**
136
  * Moderate the posted activity item, if it contains moderate keywords.
137
  *
138
+ * @since 1.6.0
139
  *
140
  * @param BP_Activity_Activity $activity The activity object to check.
141
  */
142
  function bp_activity_check_moderation_keys( $activity ) {
143
 
144
+ // Only check specific types of activity updates.
145
  if ( !in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
146
  return;
147
 
148
  // Unset the activity component so activity stream update fails
149
+ // @todo This is temporary until some kind of moderation is built.
150
  if ( !bp_core_check_for_moderation( $activity->user_id, '', $activity->content ) )
151
  $activity->component = false;
152
  }
154
  /**
155
  * Mark the posted activity as spam, if it contains blacklist keywords.
156
  *
157
+ * @since 1.6.0
158
  *
159
  * @param BP_Activity_Activity $activity The activity object to check.
160
  */
161
  function bp_activity_check_blacklist_keys( $activity ) {
162
 
163
+ // Only check specific types of activity updates.
164
  if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
165
  return;
166
 
167
+ // Mark as spam.
168
  if ( ! bp_core_check_for_blacklist( $activity->user_id, '', $activity->content ) )
169
  bp_activity_mark_as_spam( $activity, 'by_blacklist' );
170
  }
172
  /**
173
  * Custom kses filtering for activity content.
174
  *
175
+ * @since 1.1.0
176
  *
177
  * @uses apply_filters() To call the 'bp_activity_allowed_tags' hook.
178
  * @uses wp_kses()
179
  *
180
  * @param string $content The activity content.
 
181
  * @return string $content Filtered activity content.
182
  */
183
  function bp_activity_filter_kses( $content ) {
206
  /**
207
  * Filters the allowed HTML tags for BuddyPress Activity content.
208
  *
209
+ * @since 1.2.0
210
  *
211
  * @param array $value Array of allowed HTML tags and attributes.
212
  */
217
  /**
218
  * Find and link @-mentioned users in the contents of a given item.
219
  *
220
+ * @since 1.2.0
221
  *
222
  * @param string $content The contents of a given item.
223
  * @param int $activity_id The activity id. Deprecated.
 
224
  * @return string $content Content filtered for mentions.
225
  */
226
  function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
230
  return $content;
231
  }
232
 
233
+ // Try to find mentions.
234
  $usernames = bp_activity_find_mentions( $content );
235
 
236
  // No mentions? Stop now!
238
  return $content;
239
 
240
  // We don't want to link @mentions that are inside of links, so we
241
+ // temporarily remove them.
242
  $replace_count = 0;
243
  $replacements = array();
244
  foreach ( $usernames as $username ) {
245
+ // Prevent @ name linking inside <a> tags.
246
  preg_match_all( '/(<a.*?(?!<\/a>)@' . $username . '.*?<\/a>)/', $content, $content_matches );
247
  if ( ! empty( $content_matches[1] ) ) {
248
  foreach ( $content_matches[1] as $replacement ) {
253
  }
254
  }
255
 
256
+ // Linkify the mentions with the username.
257
  foreach ( (array) $usernames as $user_id => $username ) {
258
  $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
259
  }
260
 
261
+ // Put everything back.
262
  if ( ! empty( $replacements ) ) {
263
  foreach ( $replacements as $placeholder => $original ) {
264
  $content = str_replace( $placeholder, $original, $content );
265
  }
266
  }
267
 
268
+ // Return the content.
269
  return $content;
270
  }
271
 
275
  * If mentions are found, replace @mention text with user links and add our
276
  * hook to send mention notifications after the activity item is saved.
277
  *
278
+ * @since 1.5.0
279
  *
280
  * @uses bp_activity_find_mentions()
281
  *
282
+ * @param BP_Activity_Activity $activity Activity Object.
283
  */
284
  function bp_activity_at_name_filter_updates( $activity ) {
285
  // Are mentions disabled?
291
  if ( ! empty( $activity->is_spam ) )
292
  return;
293
 
294
+ // Try to find mentions.
295
  $usernames = bp_activity_find_mentions( $activity->content );
296
 
297
  // We have mentions!
298
  if ( ! empty( $usernames ) ) {
299
+ // Replace @mention text with userlinks.
300
  foreach( (array) $usernames as $user_id => $username ) {
301
  $activity->content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $activity->content );
302
  }
303
 
304
+ // Add our hook to send @mention emails after the activity item is saved.
305
  add_action( 'bp_activity_after_save', 'bp_activity_at_name_send_emails' );
306
 
307
+ // Temporary variable to avoid having to run bp_activity_find_mentions() again.
308
  buddypress()->activity->mentioned_users = $usernames;
309
  }
310
  }
312
  /**
313
  * Sends emails and BP notifications for users @-mentioned in an activity item.
314
  *
315
+ * @since 1.7.0
316
  *
317
  * @uses bp_activity_at_message_notification()
318
  * @uses bp_activity_update_mention_count_for_user()
329
  if ( empty( buddypress()->activity->mentioned_users ) )
330
  return;
331
 
332
+ // Grab our temporary variable from bp_activity_at_name_filter_updates().
333
  $usernames = buddypress()->activity->mentioned_users;
334
 
335
+ // Get rid of temporary variable.
336
  unset( buddypress()->activity->mentioned_users );
337
 
338
+ // Send @mentions and setup BP notifications.
339
  foreach( (array) $usernames as $user_id => $username ) {
340
 
341
  /**
342
  * Filters BuddyPress' ability to send email notifications for @mentions.
343
  *
344
+ * @since 1.6.0
345
  *
346
  * @param bool $value Whether or not BuddyPress should send a notification to the mentioned users.
347
  * @param array $usernames Array of users potentially notified.
350
  bp_activity_at_message_notification( $activity->id, $user_id );
351
  }
352
 
353
+ // Updates mention count for the user.
354
  bp_activity_update_mention_count_for_user( $user_id, $activity->id );
355
  }
356
  }
358
  /**
359
  * Catch links in activity text so rel=nofollow can be added.
360
  *
361
+ * @since 1.2.0
362
  *
363
  * @param string $text Activity text.
 
364
  * @return string $text Text with rel=nofollow added to any links.
365
  */
366
  function bp_activity_make_nofollow_filter( $text ) {
370
  /**
371
  * Add rel=nofollow to a link.
372
  *
373
+ * @since 1.2.0
374
  *
375
  * @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
 
376
  * @return string $text Link with rel=nofollow added.
377
  */
378
  function bp_activity_make_nofollow_filter_callback( $matches ) {
386
  *
387
  * This method can only be used inside the Activity loop.
388
  *
389
+ * @since 1.5.0
390
  *
391
  * @uses bp_is_single_activity()
392
  * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook.
397
  * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook.
398
  *
399
  * @param string $text The original activity entry text.
 
400
  * @return string $excerpt The truncated text.
401
  */
402
  function bp_activity_truncate_entry( $text ) {
405
  /**
406
  * Provides a filter that lets you choose whether to skip this filter on a per-activity basis.
407
  *
408
+ * @since 2.3.0
409
  *
410
  * @param bool $value If true, text should be checked to see if it needs truncating.
411
  */
414
  isset( $activities_template->activity->type ) && ! in_array( $activities_template->activity->type, array( 'new_blog_post', ), true )
415
  );
416
 
417
+ // The full text of the activity update should always show on the single activity screen.
418
  if ( ! $maybe_truncate_text || bp_is_single_activity() ) {
419
  return $text;
420
  }
422
  /**
423
  * Filters the appended text for the activity excerpt.
424
  *
425
+ * @since 1.5.0
426
  *
427
  * @param string $value Internationalized "Read more" text.
428
  */
431
  /**
432
  * Filters the excerpt length for the activity excerpt.
433
  *
434
+ * @since 1.5.0
435
  *
436
  * @param int $value Number indicating how many words to trim the excerpt down to.
437
  */
438
  $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
439
 
440
+ // Run the text through the excerpt function. If it's too short, the original text will be returned.
 
441
  $excerpt = bp_create_excerpt( $text, $excerpt_length, array( 'ending' => __( '&hellip;', 'buddypress' ) ) );
442
 
443
+ /*
444
+ * If the text returned by bp_create_excerpt() is different from the original text (ie it's
445
+ * been truncated), add the "Read More" link. Note that bp_create_excerpt() is stripping
446
+ * shortcodes, so we have strip them from the $text before the comparison.
447
+ */
448
  if ( $excerpt != strip_shortcodes( $text ) ) {
449
  $id = !empty( $activities_template->activity->current_comment->id ) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id();
450
 
454
  /**
455
  * Filters the composite activity excerpt entry.
456
  *
457
+ * @since 1.5.0
458
  *
459
  * @param string $excerpt Excerpt text and markup to be displayed.
460
  * @param string $text The original activity entry text.
466
  /**
467
  * Include extra JavaScript dependencies for activity component.
468
  *
469
+ * @since 2.0.0
470
  *
471
  * @uses bp_activity_do_heartbeat() to check if heartbeat is required.
472
  *
473
  * @param array $js_handles The original dependencies.
 
474
  * @return array $js_handles The new dependencies.
475
  */
476
  function bp_activity_get_js_dependencies( $js_handles = array() ) {
488
  * We use these classes to avoid pagination issues when items are loaded
489
  * dynamically into the activity stream.
490
  *
491
+ * @since 2.0.0
 
 
492
  *
493
+ * @param string $classes Array of classes for most recent activity item.
494
  * @return string $classes
495
  */
496
  function bp_activity_newest_class( $classes = '' ) {
507
  /**
508
  * Check if Activity Heartbeat feature i on to add a timestamp class.
509
  *
510
+ * @since 2.0.0
 
 
511
  *
512
+ * @param string $classes Array of classes for timestamp.
513
  * @return string $classes
514
  */
515
  function bp_activity_timestamp_class( $classes = '' ) {
533
  /**
534
  * Use WordPress Heartbeat API to check for latest activity update.
535
  *
536
+ * @since 2.0.0
537
  *
538
  * @uses bp_activity_get_last_updated() to get the recorded date of the last activity.
539
  *
540
+ * @param array $response Array containing Heartbeat API response.
541
+ * @param array $data Array containing data for Heartbeat API response.
 
542
  * @return array $response
543
  */
544
  function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) {
547
  }
548
 
549
  // Use the querystring argument stored in the cookie (to preserve
550
+ // filters), but force the offset to get only new items.
551
  $activity_latest_args = bp_parse_args(
552
  bp_ajax_querystring( 'activity' ),
553
  array( 'since' => date( 'Y-m-d H:i:s', $data['bp_activity_last_recorded'] ) ),
561
  $newest_activities = array();
562
  $last_activity_recorded = 0;
563
 
564
+ // Temporarily add a just-posted class for new activity items.
565
  add_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
566
 
567
  ob_start();
582
  $newest_activities['last_recorded'] = $last_activity_recorded;
583
  ob_end_clean();
584
 
585
+ // Remove the temporary filter.
586
  remove_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
587
 
588
  if ( ! empty( $newest_activities['last_recorded'] ) ) {
597
  /**
598
  * Set the strings for WP HeartBeat API where needed.
599
  *
600
+ * @since 2.0.0
601
  *
602
  * @param array $strings Localized strings.
 
603
  * @return array $strings
604
  */
605
  function bp_activity_heartbeat_strings( $strings = array() ) {
613
  /**
614
  * Filter that checks whether the global heartbeat settings already exist.
615
  *
616
+ * @since 2.0.0
617
  *
618
  * @param array $value Heartbeat settings array.
619
  */
626
  /**
627
  * Filters the pulse frequency to be used for the BuddyPress Activity heartbeat.
628
  *
629
+ * @since 2.0.0
630
  *
631
  * @param int $value The frequency in seconds between pulses.
632
  */
658
  /**
659
  * Set up activity arguments for use with the 'just-me' scope.
660
  *
661
+ * @since 2.2.0
662
  *
663
  * @param array $retval Empty array by default.
664
  * @param array $filter Current activity arguments.
665
+ * @return array $retval
 
666
  */
667
  function bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
668
 
669
+ // Determine the user_id.
670
  if ( ! empty( $filter['user_id'] ) ) {
671
  $user_id = $filter['user_id'];
672
  } else {
692
  ),
693
  $show_hidden,
694
 
695
+ // Overrides.
696
  'override' => array(
697
  'display_comments' => 'stream',
698
  'filter' => array( 'user_id' => 0 ),
707
  /**
708
  * Set up activity arguments for use with the 'favorites' scope.
709
  *
710
+ * @since 2.2.0
711
  *
712
  * @param array $retval Empty array by default.
713
  * @param array $filter Current activity arguments.
714
+ * @return array $retval
 
715
  */
716
  function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) {
717
 
718
+ // Determine the user_id.
719
  if ( ! empty( $filter['user_id'] ) ) {
720
  $user_id = $filter['user_id'];
721
  } else {
724
  : bp_loggedin_user_id();
725
  }
726
 
727
+ // Determine the favorites.
728
  $favs = bp_activity_get_user_favorites( $user_id );
729
  if ( empty( $favs ) ) {
730
  $favs = array( 0 );
748
  ),
749
  $show_hidden,
750
 
751
+ // Overrides.
752
  'override' => array(
753
  'display_comments' => true,
754
  'filter' => array( 'user_id' => 0 ),
764
  /**
765
  * Set up activity arguments for use with the 'favorites' scope.
766
  *
767
+ * @since 2.2.0
768
  *
769
  * @param array $retval Empty array by default.
770
  * @param array $filter Current activity arguments.
771
+ * @return array $retval
 
772
  */
773
  function bp_activity_filter_mentions_scope( $retval = array(), $filter = array() ) {
774
 
777
  return $retval;
778
  }
779
 
780
+ // Determine the user_id.
781
  if ( ! empty( $filter['user_id'] ) ) {
782
  $user_id = $filter['user_id'];
783
  } else {
806
  ),
807
  $show_hidden,
808
 
809
+ // Overrides.
810
  'override' => array(
811
 
812
+ // Clear search terms so 'mentions' scope works with other scopes.
813
  'search_terms' => false,
814
 
815
  'display_comments' => 'stream',
bp-activity/bp-activity-functions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Activity Functions.
5
  *
@@ -9,13 +8,13 @@
9
  * @subpackage ActivityFunctions
10
  */
11
 
12
- // Exit if accessed directly
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  /**
16
  * Check whether the $bp global lists an activity directory page.
17
  *
18
- * @since BuddyPress (1.5.0)
19
  *
20
  * @return bool True if activity directory page is found, otherwise false.
21
  */
@@ -38,7 +37,7 @@ function bp_activity_has_directory() {
38
  *
39
  * add_filter( 'bp_activity_do_mentions', '__return_false' );
40
  *
41
- * @since BuddyPress (1.8.0)
42
  *
43
  * @uses apply_filters() To call 'bp_activity_do_mentions' hook.
44
  *
@@ -49,7 +48,7 @@ function bp_activity_do_mentions() {
49
  /**
50
  * Filters whether or not mentions are enabled.
51
  *
52
- * @since BuddyPress (1.8.0)
53
  *
54
  * @param bool $enabled True to enable mentions, false to disable.
55
  */
@@ -60,7 +59,7 @@ function bp_activity_do_mentions() {
60
  * Should BuddyPress load the mentions scripts and related assets, including results to prime the
61
  * mentions suggestions?
62
  *
63
- * @since BuddyPress (2.1.0)
64
  *
65
  * @return bool True if mentions scripts should be loaded.
66
  */
@@ -71,7 +70,7 @@ function bp_activity_maybe_load_mentions_scripts() {
71
  /**
72
  * Filters whether or not BuddyPress should load mentions scripts and assets.
73
  *
74
- * @since BuddyPress (2.1.0)
75
  *
76
  * @param bool $load_mentions True to load mentions assets, false otherwise.
77
  * @param bool $mentions_enabled True if mentions are enabled.
@@ -82,11 +81,10 @@ function bp_activity_maybe_load_mentions_scripts() {
82
  /**
83
  * Locate usernames in an activity content string, as designated by an @ sign.
84
  *
85
- * @since BuddyPress (1.5.0)
86
  *
87
  * @param string $content The content of the activity, usually found in
88
  * $activity->content.
89
- *
90
  * @return array|bool Associative array with user ID as key and username as
91
  * value. Boolean false if no mentions found.
92
  */
@@ -95,21 +93,21 @@ function bp_activity_find_mentions( $content ) {
95
  $pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
96
  preg_match_all( $pattern, $content, $usernames );
97
 
98
- // Make sure there's only one instance of each username
99
  $usernames = array_unique( $usernames[1] );
100
 
101
- // Bail if no usernames
102
  if ( empty( $usernames ) ) {
103
  return false;
104
  }
105
 
106
  $mentioned_users = array();
107
 
108
- // We've found some mentions! Check to see if users exist
109
  foreach( (array) array_values( $usernames ) as $username ) {
110
  $user_id = bp_activity_get_userid_from_mentionname( $username );
111
 
112
- // user ID exists, so let's add it to our array
113
  if ( ! empty( $user_id ) ) {
114
  $mentioned_users[ $user_id ] = $username;
115
  }
@@ -125,7 +123,7 @@ function bp_activity_find_mentions( $content ) {
125
  /**
126
  * Reset a user's unread mentions list and count.
127
  *
128
- * @since BuddyPress (1.5.0)
129
  *
130
  * @uses bp_delete_user_meta()
131
  *
@@ -144,35 +142,34 @@ function bp_activity_clear_new_mentions( $user_id ) {
144
  *
145
  * Currently, only used in {@link bp_activity_delete()}.
146
  *
147
- * @since BuddyPress (1.5.0)
148
  *
149
  * @uses bp_activity_find_mentions()
150
  * @uses bp_activity_update_mention_count_for_user()
151
  *
152
  * @param int $activity_id The unique id for the activity item.
153
  * @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
154
- *
155
  * @return bool
156
  */
157
  function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
158
 
159
- // Bail if no activity ID passed
160
  if ( empty( $activity_id ) ) {
161
  return false;
162
  }
163
 
164
- // Get activity object
165
  $activity = new BP_Activity_Activity( (int) $activity_id );
166
 
167
- // Try to find mentions
168
  $usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
169
 
170
- // Still empty? Stop now
171
  if ( empty( $usernames ) ) {
172
  return false;
173
  }
174
 
175
- // Increment mention count foreach mentioned user
176
  foreach( (array) array_keys( $usernames ) as $user_id ) {
177
  bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
178
  }
@@ -184,7 +181,7 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
184
  * This function should be used when you've already parsed your activity item
185
  * for @mentions.
186
  *
187
- * @since BuddyPress (1.7.0)
188
  *
189
  * @uses bp_get_user_meta()
190
  * @uses bp_update_user_meta()
@@ -192,7 +189,6 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
192
  * @param int $user_id The user ID.
193
  * @param int $activity_id The unique ID for the activity item.
194
  * @param string $action 'delete' or 'add'. Default: 'add'.
195
- *
196
  * @return bool
197
  */
198
  function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
@@ -201,11 +197,11 @@ function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $act
201
  return false;
202
  }
203
 
204
- // Adjust the mention list and count for the member
205
  $new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true );
206
  $new_mentions = bp_get_user_meta( $user_id, 'bp_new_mentions', true );
207
 
208
- // Make sure new mentions is an array
209
  if ( empty( $new_mentions ) ) {
210
  $new_mentions = array();
211
  }
@@ -229,10 +225,10 @@ function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $act
229
  break;
230
  }
231
 
232
- // Get an updated mention count
233
  $new_mention_count = count( $new_mentions );
234
 
235
- // Resave the user_meta
236
  bp_update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count );
237
  bp_update_user_meta( $user_id, 'bp_new_mentions', $new_mentions );
238
 
@@ -242,11 +238,10 @@ function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $act
242
  /**
243
  * Determine a user's "mentionname", the name used for that user in @-mentions.
244
  *
245
- * @since BuddyPress (1.9.0)
246
  *
247
  * @param int|string $user_id ID of the user to get @-mention name for.
248
- *
249
- * @return string User name appropriate for @-mentions.
250
  */
251
  function bp_activity_get_user_mentionname( $user_id ) {
252
  $mentionname = '';
@@ -267,23 +262,24 @@ function bp_activity_get_user_mentionname( $user_id ) {
267
  /**
268
  * Get a user ID from a "mentionname", the name used for a user in @-mentions.
269
  *
270
- * @since BuddyPress (1.9.0)
271
  *
272
  * @param string $mentionname Username of user in @-mentions.
273
- *
274
  * @return int|bool ID of the user, if one is found. Otherwise false.
275
  */
276
  function bp_activity_get_userid_from_mentionname( $mentionname ) {
277
  $user_id = false;
278
 
279
- // In username compatibility mode, hyphens are ambiguous between
280
- // actual hyphens and converted spaces.
281
- //
282
- // @todo There is the potential for username clashes between 'foo bar'
283
- // and 'foo-bar' in compatibility mode. Come up with a system for
284
- // unique mentionnames.
 
 
285
  if ( bp_is_username_compatibility_mode() ) {
286
- // First, try the raw username
287
  $userdata = get_user_by( 'login', $mentionname );
288
 
289
  // Doing a direct query to use proper regex. Necessary to
@@ -297,7 +293,7 @@ function bp_activity_get_userid_from_mentionname( $mentionname ) {
297
  }
298
 
299
  // When username compatibility mode is disabled, the mentionname is
300
- // the same as the nicename
301
  } else {
302
  $user_id = bp_core_get_userid_from_nicename( $mentionname );
303
  }
@@ -322,7 +318,7 @@ function bp_activity_get_userid_from_mentionname( $mentionname ) {
322
  * panel, and dynamic action generation (which is essential for multilingual
323
  * sites, etc) will not work.
324
  *
325
- * @since BuddyPress (1.1.0)
326
  *
327
  * @param string $component_id The unique string ID of the component.
328
  * @param string $type The action type.
@@ -332,23 +328,22 @@ function bp_activity_get_userid_from_mentionname( $mentionname ) {
332
  * @param array $context Optional. Activity stream contexts where the filter should appear.
333
  * Values: 'activity', 'member', 'member_groups', 'group'.
334
  * @param int $position Optional. The position of the action when listed in dropdowns.
335
- *
336
  * @return bool False if any param is empty, otherwise true.
337
  */
338
  function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array(), $position = 0 ) {
339
  $bp = buddypress();
340
 
341
- // Return false if any of the above values are not set
342
  if ( empty( $component_id ) || empty( $type ) || empty( $description ) ) {
343
  return false;
344
  }
345
 
346
- // Set activity action
347
  if ( ! isset( $bp->activity->actions ) || ! is_object( $bp->activity->actions ) ) {
348
  $bp->activity->actions = new stdClass;
349
  }
350
 
351
- // Verify callback
352
  if ( ! is_callable( $format_callback ) ) {
353
  $format_callback = '';
354
  }
@@ -360,7 +355,7 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
360
  /**
361
  * Filters the action type being set for the current activity item.
362
  *
363
- * @since BuddyPress (1.1.0)
364
  *
365
  * @param array $array Array of arguments for action type being set.
366
  * @param string $component_id ID of the current component being set.
@@ -386,14 +381,13 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
386
  /**
387
  * Set tracking arguments for a given post type.
388
  *
389
- * @since BuddyPress (2.2.0)
390
  *
391
  * @global $wp_post_types
392
  *
393
  * @param string $post_type The name of the post type, as registered with WordPress. Eg 'post' or 'page'.
394
  * @param array $args {
395
  * An associative array of tracking parameters. All items are optional.
396
- *
397
  * @type string $bp_activity_admin_filter String to use in the Dashboard > Activity dropdown.
398
  * @type string $bp_activity_front_filter String to use in frontend dropdown.
399
  * @type string $bp_activity_new_post String format to use for generating the activity action. Should be a
@@ -415,7 +409,6 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
415
  * @type bool $activity_comment Whether to allow comments on the activity items. Defaults to true if
416
  * the post type does not natively support comments, otherwise false.
417
  * }
418
- *
419
  * @return bool
420
  */
421
  function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array() ) {
@@ -442,10 +435,9 @@ function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array
442
  /**
443
  * Get tracking arguments for a specific post type.
444
  *
445
- * @since BuddyPress (2.2.0)
446
  *
447
  * @param string $post_type Name of the post type.
448
- *
449
  * @return object The tracking arguments of the post type.
450
  */
451
  function bp_activity_get_post_type_tracking_args( $post_type ) {
@@ -499,7 +491,7 @@ function bp_activity_get_post_type_tracking_args( $post_type ) {
499
  /**
500
  * Filters tracking arguments for a specific post type.
501
  *
502
- * @since BuddyPress (2.2.0)
503
  *
504
  * @param object $post_type_activity The tracking arguments of the post type.
505
  * @param string $post_type Name of the post type.
@@ -510,12 +502,12 @@ function bp_activity_get_post_type_tracking_args( $post_type ) {
510
  /**
511
  * Get tracking arguments for all post types.
512
  *
513
- * @since BuddyPress (2.2.0)
514
  *
515
  * @return array List of post types with their tracking arguments.
516
  */
517
  function bp_activity_get_post_types_tracking_args() {
518
- // Fetch all public post types
519
  $post_types = get_post_types( array( 'public' => true ), 'names' );
520
 
521
  $post_types_tracking_args = array();
@@ -532,7 +524,7 @@ function bp_activity_get_post_types_tracking_args() {
532
  /**
533
  * Filters tracking arguments for all post types.
534
  *
535
- * @since BuddyPress (2.2.0)
536
  *
537
  * @param array $post_types_tracking_args Array of post types with
538
  * their tracking arguments.
@@ -543,7 +535,7 @@ function bp_activity_get_post_types_tracking_args() {
543
  /**
544
  * Get all components' activity actions, sorted by their position attribute.
545
  *
546
- * @since BuddyPress (2.2.0)
547
  *
548
  * @return object Actions ordered by their position.
549
  */
@@ -589,18 +581,17 @@ function bp_activity_get_actions() {
589
  /**
590
  * Retrieve the current action from a component and key.
591
  *
592
- * @since BuddyPress (1.1.0)
593
  *
594
  * @uses apply_filters() To call the 'bp_activity_get_action' hook.
595
  *
596
  * @param string $component_id The unique string ID of the component.
597
  * @param string $key The action key.
598
- *
599
  * @return string|bool Action value if found, otherwise false.
600
  */
601
  function bp_activity_get_action( $component_id, $key ) {
602
 
603
- // Return false if any of the above values are not set
604
  if ( empty( $component_id ) || empty( $key ) ) {
605
  return false;
606
  }
@@ -615,7 +606,7 @@ function bp_activity_get_action( $component_id, $key ) {
615
  /**
616
  * Filters the current action by component and key.
617
  *
618
- * @since BuddyPress (1.1.0)
619
  *
620
  * @param string|bool $retval The action key.
621
  * @param string $component_id The unique string ID of the component.
@@ -627,7 +618,7 @@ function bp_activity_get_action( $component_id, $key ) {
627
  /**
628
  * Fetch details of all registered activity types.
629
  *
630
- * @since BuddyPress (1.7.0)
631
  *
632
  * @return array array( type => description ), ...
633
  */
@@ -643,13 +634,13 @@ function bp_activity_get_types() {
643
  }
644
  }
645
 
646
- // This was a mis-named activity type from before BP 1.6
647
  unset( $actions['friends_register_activity_action'] );
648
 
649
  /**
650
  * Filters the available activity types.
651
  *
652
- * @since BuddyPress (1.7.0)
653
  *
654
  * @param array $actions Array of registered activity types.
655
  */
@@ -661,29 +652,28 @@ function bp_activity_get_types() {
661
  /**
662
  * Get a users favorite activity stream items.
663
  *
664
- * @since BuddyPress (1.2.0)
665
  *
666
  * @uses bp_get_user_meta()
667
  * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
668
  *
669
  * @param int $user_id ID of the user whose favorites are being queried.
670
- *
671
  * @return array IDs of the user's favorite activity items.
672
  */
673
  function bp_activity_get_user_favorites( $user_id = 0 ) {
674
 
675
- // Fallback to logged in user if no user_id is passed
676
  if ( empty( $user_id ) ) {
677
  $user_id = bp_displayed_user_id();
678
  }
679
 
680
- // Get favorites for user
681
  $favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
682
 
683
  /**
684
  * Filters the favorited activity items for a specified user.
685
  *
686
- * @since BuddyPress (1.2.0)
687
  *
688
  * @param array $favs Array of user's favorited activity items.
689
  */
@@ -693,7 +683,7 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
693
  /**
694
  * Add an activity stream item as a favorite for a user.
695
  *
696
- * @since BuddyPress (1.2.0)
697
  *
698
  * @uses is_user_logged_in()
699
  * @uses bp_get_user_meta()
@@ -705,17 +695,16 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
705
  *
706
  * @param int $activity_id ID of the activity item being favorited.
707
  * @param int $user_id ID of the user favoriting the activity item.
708
- *
709
  * @return bool True on success, false on failure.
710
  */
711
  function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
712
 
713
- // Favorite activity stream items are for logged in users only
714
  if ( ! is_user_logged_in() ) {
715
  return false;
716
  }
717
 
718
- // Fallback to logged in user if no user_id is passed
719
  if ( empty( $user_id ) ) {
720
  $user_id = bp_loggedin_user_id();
721
  }
@@ -725,44 +714,44 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
725
  $my_favs = array();
726
  }
727
 
728
- // Bail if the user has already favorited this activity item
729
  if ( in_array( $activity_id, $my_favs ) ) {
730
  return false;
731
  }
732
 
733
- // Add to user's favorites
734
  $my_favs[] = $activity_id;
735
 
736
- // Update the total number of users who have favorited this activity
737
  $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
738
  $fav_count = !empty( $fav_count ) ? (int) $fav_count + 1 : 1;
739
 
740
- // Update user meta
741
  bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs );
742
 
743
- // Update activity meta counts
744
  if ( bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ) ) {
745
 
746
  /**
747
  * Fires if bp_activity_update_meta() for favorite_count is successful and before returning a true value for success.
748
  *
749
- * @since BuddyPress (1.2.1)
750
  *
751
  * @param int $activity_id ID of the activity item being favorited.
752
  * @param int $user_id ID of the user doing the favoriting.
753
  */
754
  do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
755
 
756
- // Success
757
  return true;
758
 
759
- // Saving meta was unsuccessful for an unknown reason
760
  } else {
761
 
762
  /**
763
  * Fires if bp_activity_update_meta() for favorite_count is unsuccessful and before returning a false value for failure.
764
  *
765
- * @since BuddyPress (1.5.0)
766
  *
767
  * @param int $activity_id ID of the activity item being favorited.
768
  * @param int $user_id ID of the user doing the favoriting.
@@ -776,7 +765,7 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
776
  /**
777
  * Remove an activity stream item as a favorite for a user.
778
  *
779
- * @since BuddyPress (1.2.0)
780
  *
781
  * @uses is_user_logged_in()
782
  * @uses bp_get_user_meta()
@@ -787,17 +776,16 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
787
  *
788
  * @param int $activity_id ID of the activity item being unfavorited.
789
  * @param int $user_id ID of the user unfavoriting the activity item.
790
- *
791
  * @return bool True on success, false on failure.
792
  */
793
  function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
794
 
795
- // Favorite activity stream items are for logged in users only
796
  if ( ! is_user_logged_in() ) {
797
  return false;
798
  }
799
 
800
- // Fallback to logged in user if no user_id is passed
801
  if ( empty( $user_id ) ) {
802
  $user_id = bp_loggedin_user_id();
803
  }
@@ -805,49 +793,49 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
805
  $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
806
  $my_favs = array_flip( (array) $my_favs );
807
 
808
- // Bail if the user has not previously favorited the item
809
  if ( ! isset( $my_favs[ $activity_id ] ) ) {
810
  return false;
811
  }
812
 
813
- // Remove the fav from the user's favs
814
  unset( $my_favs[$activity_id] );
815
  $my_favs = array_unique( array_flip( $my_favs ) );
816
 
817
- // Update the total number of users who have favorited this activity
818
  $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
819
  if ( ! empty( $fav_count ) ) {
820
 
821
- // Deduct from total favorites
822
  if ( bp_activity_update_meta( $activity_id, 'favorite_count', (int) $fav_count - 1 ) ) {
823
 
824
- // Update users favorites
825
  if ( bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs ) ) {
826
 
827
  /**
828
  * Fires if bp_update_user_meta() is successful and before returning a true value for success.
829
  *
830
- * @since BuddyPress (1.2.1)
831
  *
832
  * @param int $activity_id ID of the activity item being unfavorited.
833
  * @param int $user_id ID of the user doing the unfavoriting.
834
  */
835
  do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
836
 
837
- // Success
838
  return true;
839
 
840
- // Error updating
841
  } else {
842
  return false;
843
  }
844
 
845
- // Error updating favorite count
846
  } else {
847
  return false;
848
  }
849
 
850
- // Error getting favorite count
851
  } else {
852
  return false;
853
  }
@@ -856,13 +844,12 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
856
  /**
857
  * Check whether an activity item exists with a given content string.
858
  *
859
- * @since BuddyPress (1.1.0)
860
  *
861
  * @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity}
862
  * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
863
  *
864
  * @param string $content The content to filter by.
865
- *
866
  * @return int|null The ID of the located activity item. Null if none is found.
867
  */
868
  function bp_activity_check_exists_by_content( $content ) {
@@ -870,7 +857,7 @@ function bp_activity_check_exists_by_content( $content ) {
870
  /**
871
  * Filters the results of the check for whether an activity item exists by specified content.
872
  *
873
- * @since BuddyPress (1.1.0)
874
  *
875
  * @param BP_Activity_Activity $content_exists ID of the activity if found, else null.
876
  */
@@ -880,7 +867,7 @@ function bp_activity_check_exists_by_content( $content ) {
880
  /**
881
  * Retrieve the last time activity was updated.
882
  *
883
- * @since BuddyPress (1.0.0)
884
  *
885
  * @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity}
886
  * @uses apply_filters() To call the 'bp_activity_get_last_updated' hook.
@@ -892,7 +879,7 @@ function bp_activity_get_last_updated() {
892
  /**
893
  * Filters the value for the last updated time for an activity item.
894
  *
895
- * @since BuddyPress (1.1.0)
896
  *
897
  * @param BP_Activity_Activity $last_updated Date last updated.
898
  */
@@ -902,17 +889,16 @@ function bp_activity_get_last_updated() {
902
  /**
903
  * Retrieve the number of favorite activity stream items a user has.
904
  *
905
- * @since BuddyPress (1.2.0)
906
  *
907
  * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
908
  *
909
  * @param int $user_id ID of the user whose favorite count is being requested.
910
- *
911
  * @return int Total favorite count for the user.
912
  */
913
  function bp_activity_total_favorites_for_user( $user_id = 0 ) {
914
 
915
- // Fallback on displayed user, and then logged in user
916
  if ( empty( $user_id ) ) {
917
  $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
918
  }
@@ -925,7 +911,7 @@ function bp_activity_total_favorites_for_user( $user_id = 0 ) {
925
  /**
926
  * Delete a meta entry from the DB for an activity stream item.
927
  *
928
- * @since BuddyPress (1.2.0)
929
  *
930
  * @global object $wpdb WordPress database access object.
931
  *
@@ -937,19 +923,18 @@ function bp_activity_total_favorites_for_user( $user_id = 0 ) {
937
  * deleted if the meta_value matches this parameter.
938
  * @param bool $delete_all Optional. If true, delete matching metadata entries
939
  * for all objects, ignoring the specified object_id. Otherwise,
940
- * only delete matching metadata entries for the specified
941
- * activity item. Default: false.
942
- *
943
  * @return bool True on success, false on failure.
944
  */
945
  function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
946
 
947
- // Legacy - if no meta_key is passed, delete all for the item
948
  if ( empty( $meta_key ) ) {
949
  $all_meta = bp_activity_get_meta( $activity_id );
950
  $keys = ! empty( $all_meta ) ? array_keys( $all_meta ) : array();
951
 
952
- // With no meta_key, ignore $delete_all
953
  $delete_all = false;
954
  } else {
955
  $keys = array( $meta_key );
@@ -969,7 +954,7 @@ function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = ''
969
  /**
970
  * Get metadata for a given activity item.
971
  *
972
- * @since BuddyPress (1.2.0)
973
  *
974
  * @uses apply_filters() To call the 'bp_activity_get_meta' hook.
975
  *
@@ -978,9 +963,8 @@ function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = ''
978
  * that meta key will be returned. Otherwise, all metadata for the
979
  * activity item will be fetched.
980
  * @param bool $single Optional. If true, return only the first value of the
981
- * specified meta_key. This parameter has no effect if meta_key is not
982
- * specified. Default: true.
983
- *
984
  * @return mixed The meta value(s) being requested.
985
  */
986
  function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true ) {
@@ -991,7 +975,7 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
991
  /**
992
  * Filters the metadata for a specified activity item.
993
  *
994
- * @since BuddyPress (1.5.0)
995
  *
996
  * @param mixed $retval The meta values for the activity item.
997
  * @param int $activity_id ID of the activity item.
@@ -1004,14 +988,13 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
1004
  /**
1005
  * Update a piece of activity meta.
1006
  *
1007
- * @since BuddyPress (1.2.0)
1008
  *
1009
  * @param int $activity_id ID of the activity item whose metadata is being updated.
1010
  * @param string $meta_key Key of the metadata being updated.
1011
  * @param mixed $meta_value Value to be set.
1012
  * @param mixed $prev_value Optional. If specified, only update existing metadata entries
1013
  * with the specified value. Otherwise, update all entries.
1014
- *
1015
  * @return bool|int Returns false on failure. On successful update of existing
1016
  * metadata, returns true. On successful creation of new metadata,
1017
  * returns the integer ID of the new metadata row.
@@ -1027,7 +1010,7 @@ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_va
1027
  /**
1028
  * Add a piece of activity metadata.
1029
  *
1030
- * @since BuddyPress (2.0.0)
1031
  *
1032
  * @param int $activity_id ID of the activity item.
1033
  * @param string $meta_key Metadata key.
@@ -1035,7 +1018,6 @@ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_va
1035
  * @param bool $unique Optional. Whether to enforce a single metadata value for the
1036
  * given key. If true, and the object already has a value for
1037
  * the key, no change will be made. Default: false.
1038
- *
1039
  * @return int|bool The meta ID on successful update, false on failure.
1040
  */
1041
  function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = false ) {
@@ -1051,7 +1033,7 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
1051
  /**
1052
  * Completely remove a user's activity data.
1053
  *
1054
- * @since BuddyPress (1.5.0)
1055
  *
1056
  * @uses is_user_logged_in()
1057
  * @uses bp_activity_delete()
@@ -1060,20 +1042,19 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
1060
  * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook.
1061
  *
1062
  * @param int $user_id ID of the user whose activity is being deleted.
1063
- *
1064
  * @return bool
1065
  */
1066
  function bp_activity_remove_all_user_data( $user_id = 0 ) {
1067
 
1068
- // Do not delete user data unless a logged in user says so
1069
  if ( empty( $user_id ) || ! is_user_logged_in() ) {
1070
  return false;
1071
  }
1072
 
1073
- // Clear the user's activity from the sitewide stream and clear their activity tables
1074
  bp_activity_delete( array( 'user_id' => $user_id ) );
1075
 
1076
- // Remove any usermeta
1077
  bp_delete_user_meta( $user_id, 'bp_latest_update' );
1078
  bp_delete_user_meta( $user_id, 'bp_favorite_activities' );
1079
 
@@ -1083,7 +1064,7 @@ function bp_activity_remove_all_user_data( $user_id = 0 ) {
1083
  /**
1084
  * Fires after the removal of all of a user's activity data.
1085
  *
1086
- * @since BuddyPress (1.5.0)
1087
  *
1088
  * @param int $user_id ID of the user being deleted.
1089
  */
@@ -1095,18 +1076,17 @@ add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
1095
  /**
1096
  * Mark all of the user's activity as spam.
1097
  *
1098
- * @since BuddyPress (1.6.0)
1099
  *
1100
  * @global object $wpdb WordPress database access object.
1101
  *
1102
  * @param int $user_id ID of the user whose activity is being spammed.
1103
- *
1104
  * @return bool
1105
  */
1106
  function bp_activity_spam_all_user_data( $user_id = 0 ) {
1107
  global $wpdb;
1108
 
1109
- // Do not delete user data unless a logged in user says so
1110
  if ( empty( $user_id ) || ! is_user_logged_in() ) {
1111
  return false;
1112
  }
@@ -1120,16 +1100,16 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
1120
 
1121
  $bp = buddypress();
1122
 
1123
- // Mark each as spam
1124
  foreach ( (array) $activities['activities'] as $activity ) {
1125
 
1126
- // Create an activity object
1127
  $activity_obj = new BP_Activity_Activity;
1128
  foreach ( $activity as $k => $v ) {
1129
  $activity_obj->$k = $v;
1130
  }
1131
 
1132
- // Mark as spam
1133
  bp_activity_mark_as_spam( $activity_obj );
1134
 
1135
  /*
@@ -1143,17 +1123,17 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
1143
  $bp->activity->akismet->update_activity_spam_meta( $activity_obj );
1144
  }
1145
 
1146
- // Tidy up
1147
  unset( $activity_obj );
1148
  }
1149
 
1150
- // Mark all of this user's activities as spam
1151
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id ) );
1152
 
1153
  /**
1154
  * Fires after all activity data from a user has been marked as spam.
1155
  *
1156
- * @since BuddyPress (1.6.0)
1157
  *
1158
  * @param int $user_id ID of the user whose activity is being marked as spam.
1159
  * @param array $activities Array of activity items being marked as spam.
@@ -1165,18 +1145,17 @@ add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
1165
  /**
1166
  * Mark all of the user's activity as ham (not spam).
1167
  *
1168
- * @since BuddyPress (1.6.0)
1169
  *
1170
  * @global object $wpdb WordPress database access object.
1171
  *
1172
  * @param int $user_id ID of the user whose activity is being hammed.
1173
- *
1174
  * @return bool
1175
  */
1176
  function bp_activity_ham_all_user_data( $user_id = 0 ) {
1177
  global $wpdb;
1178
 
1179
- // Do not delete user data unless a logged in user says so
1180
  if ( empty( $user_id ) || ! is_user_logged_in() ) {
1181
  return false;
1182
  }
@@ -1191,16 +1170,16 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
1191
 
1192
  $bp = buddypress();
1193
 
1194
- // Mark each as not spam
1195
  foreach ( (array) $activities['activities'] as $activity ) {
1196
 
1197
- // Create an activity object
1198
  $activity_obj = new BP_Activity_Activity;
1199
  foreach ( $activity as $k => $v ) {
1200
  $activity_obj->$k = $v;
1201
  }
1202
 
1203
- // Mark as not spam
1204
  bp_activity_mark_as_ham( $activity_obj );
1205
 
1206
  /*
@@ -1214,17 +1193,17 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
1214
  $bp->activity->akismet->update_activity_ham_meta( $activity_obj );
1215
  }
1216
 
1217
- // Tidy up
1218
  unset( $activity_obj );
1219
  }
1220
 
1221
- // Mark all of this user's activities as not spam
1222
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 0 WHERE user_id = %d", $user_id ) );
1223
 
1224
  /**
1225
  * Fires after all activity data from a user has been marked as ham.
1226
  *
1227
- * @since BuddyPress (1.6.0)
1228
  *
1229
  * @param int $user_id ID of the user whose activity is being marked as ham.
1230
  * @param array $activities Array of activity items being marked as ham.
@@ -1236,7 +1215,7 @@ add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
1236
  /**
1237
  * Register the activity stream actions for updates.
1238
  *
1239
- * @since BuddyPress (1.6.0)
1240
  */
1241
  function bp_activity_register_activity_actions() {
1242
  $bp = buddypress();
@@ -1263,7 +1242,7 @@ function bp_activity_register_activity_actions() {
1263
  *
1264
  * Allows plugin authors to add their own activity actions alongside the core actions.
1265
  *
1266
- * @since BuddyPress (1.6.0)
1267
  */
1268
  do_action( 'bp_activity_register_activity_actions' );
1269
 
@@ -1276,37 +1255,36 @@ add_action( 'bp_register_activity_actions', 'bp_activity_register_activity_actio
1276
  * Generate an activity action string for an activity item.
1277
  *
1278
  * @param object $activity Activity data object.
1279
- *
1280
  * @return string|bool Returns false if no callback is found, otherwise returns
1281
  * the formatted action string.
1282
  */
1283
  function bp_activity_generate_action_string( $activity ) {
1284
 
1285
- // Check for valid input
1286
  if ( empty( $activity->component ) || empty( $activity->type ) ) {
1287
  return false;
1288
  }
1289
 
1290
- // Check for registered format callback
1291
  $actions = bp_activity_get_actions();
1292
  if ( empty( $actions->{$activity->component}->{$activity->type}['format_callback'] ) ) {
1293
  return false;
1294
  }
1295
 
1296
- // We apply the format_callback as a filter
1297
  add_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
1298
 
1299
  /**
1300
  * Filters the string for the activity action being returned.
1301
  *
1302
- * @since BuddyPress (2.0.0)
1303
  *
1304
  * @param BP_Activity_Activity $action Action string being requested.
1305
  * @param BP_Activity_Activity $activity Activity item object.
1306
  */
1307
  $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
1308
 
1309
- // Remove the filter for future activity items
1310
  remove_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
1311
 
1312
  return $action;
@@ -1315,12 +1293,11 @@ function bp_activity_generate_action_string( $activity ) {
1315
  /**
1316
  * Format 'activity_update' activity actions.
1317
  *
1318
- * @since BuddyPress (2.0.0)
1319
  *
1320
  * @param string $action Static activity action.
1321
  * @param object $activity Activity data object.
1322
- *
1323
- * @return string
1324
  */
1325
  function bp_activity_format_activity_action_activity_update( $action, $activity ) {
1326
  $action = sprintf( __( '%s posted an update', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
@@ -1328,7 +1305,7 @@ function bp_activity_format_activity_action_activity_update( $action, $activity
1328
  /**
1329
  * Filters the formatted activity action update string.
1330
  *
1331
- * @since BuddyPress (1.2.0)
1332
  *
1333
  * @param string $action Activity action string value.
1334
  * @param BP_Activity_Activity $activity Activity item object.
@@ -1339,12 +1316,11 @@ function bp_activity_format_activity_action_activity_update( $action, $activity
1339
  /**
1340
  * Format 'activity_comment' activity actions.
1341
  *
1342
- * @since BuddyPress (2.0.0)
1343
  *
1344
  * @param string $action Static activity action.
1345
  * @param object $activity Activity data object.
1346
- *
1347
- * @return string
1348
  */
1349
  function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
1350
  $action = sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
@@ -1352,7 +1328,7 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
1352
  /**
1353
  * Filters the formatted activity action comment string.
1354
  *
1355
- * @since BuddyPress (1.2.0)
1356
  *
1357
  * @param string $action Activity action string value.
1358
  * @param BP_Activity_Activity $activity Activity item object.
@@ -1363,12 +1339,11 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
1363
  /**
1364
  * Format activity action strings for custom post types.
1365
  *
1366
- * @since BuddyPress (2.2.0)
1367
  *
1368
  * @param string $action Static activity action.
1369
  * @param object $activity Activity data object.
1370
- *
1371
- * @return string
1372
  */
1373
  function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) {
1374
  $bp = buddypress();
@@ -1410,7 +1385,7 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
1410
  /**
1411
  * Filters the formatted custom post type activity post action string.
1412
  *
1413
- * @since BuddyPress (2.2.0)
1414
  *
1415
  * @param string $action Activity action string value.
1416
  * @param BP_Activity_Activity $activity Activity item object.
@@ -1418,7 +1393,7 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
1418
  return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity );
1419
  }
1420
 
1421
- /******************************************************************************
1422
  * Business functions are where all the magic happens in BuddyPress. They will
1423
  * handle the actual saving or manipulation of information. Usually they will
1424
  * hand off to a database class for data access, then return
@@ -1428,13 +1403,14 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
1428
  /**
1429
  * Retrieve an activity or activities.
1430
  *
1431
- * bp_activity_get() shares all arguments with BP_Activity_Activity::get(). The
1432
- * following is a list of bp_activity_get() parameters that have different
1433
  * default values from BP_Activity_Activity::get() (value in parentheses is
1434
  * the default for the bp_activity_get()).
1435
  * - 'per_page' (false)
1436
  *
1437
- * @since BuddyPress (1.2.0)
 
1438
  *
1439
  * @see BP_Activity_Activity::get() For more information on accepted arguments
1440
  * and the format of the returned value.
@@ -1445,13 +1421,13 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
1445
  * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
1446
  *
1447
  * @param array|string $args See BP_Activity_Activity::get() for description.
1448
- *
1449
  * @return array $activity See BP_Activity_Activity::get() for description.
1450
  */
1451
  function bp_activity_get( $args = '' ) {
1452
 
1453
  $r = bp_parse_args( $args, array(
1454
  'max' => false, // Maximum number of results to return
 
1455
  'page' => 1, // page 1 without a per_page will result in no pagination.
1456
  'per_page' => false, // results per page
1457
  'sort' => 'DESC', // sort ASC or DESC
@@ -1462,8 +1438,9 @@ function bp_activity_get( $args = '' ) {
1462
  'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format
1463
  'filter_query' => false,
1464
  'show_hidden' => false, // Show activity items that are hidden site-wide?
1465
- 'exclude' => false, // Comma-separated list of activity IDs to exclude
1466
- 'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query
 
1467
  'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
1468
  'update_meta_cache' => true,
1469
  'count_total' => false,
@@ -1472,18 +1449,18 @@ function bp_activity_get( $args = '' ) {
1472
  /**
1473
  * Pass filters as an array -- all filter items can be multiple values comma separated:
1474
  * array(
1475
- * 'user_id' => false, // user_id to filter on
1476
- * 'object' => false, // object to filter on e.g. groups, profile, status, friends
1477
- * 'action' => false, // action to filter on e.g. activity_update, profile_updated
1478
- * 'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
1479
- * 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
1480
  * );
1481
  */
1482
  'filter' => array()
1483
  ) );
1484
 
1485
  // Attempt to return a cached copy of the first page of sitewide activity.
1486
- if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['scope'] )&& empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
1487
 
1488
  $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
1489
  if ( false === $activity ) {
@@ -1492,6 +1469,7 @@ function bp_activity_get( $args = '' ) {
1492
  'page' => $r['page'],
1493
  'per_page' => $r['per_page'],
1494
  'max' => $r['max'],
 
1495
  'sort' => $r['sort'],
1496
  'search_terms' => $r['search_terms'],
1497
  'meta_query' => $r['meta_query'],
@@ -1533,7 +1511,7 @@ function bp_activity_get( $args = '' ) {
1533
  /**
1534
  * Filters the requested activity item(s).
1535
  *
1536
- * @since BuddyPress (1.2.0)
1537
  *
1538
  * @param BP_Activity_Activity $activity Requested activity object.
1539
  * @param array $r Arguments used for the activity query.
@@ -1544,7 +1522,7 @@ function bp_activity_get( $args = '' ) {
1544
  /**
1545
  * Fetch specific activity items.
1546
  *
1547
- * @since BuddyPress (1.2.0)
1548
  *
1549
  * @see BP_Activity_Activity::get() For more information on accepted arguments.
1550
  * @uses wp_parse_args()
@@ -1555,7 +1533,7 @@ function bp_activity_get( $args = '' ) {
1555
  * All arguments and defaults are shared with BP_Activity_Activity::get(),
1556
  * except for the following:
1557
  * @type string|int|array Single activity ID, comma-separated list of IDs,
1558
- * or array of IDs.
1559
  * }
1560
  * @return array $activity See BP_Activity_Activity::get() for description.
1561
  */
@@ -1563,13 +1541,13 @@ function bp_activity_get_specific( $args = '' ) {
1563
 
1564
  $r = bp_parse_args( $args, array(
1565
  'activity_ids' => false, // A single activity_id or array of IDs.
1566
- 'display_comments' => false, // true or false to display threaded comments for these specific activity items
1567
- 'max' => false, // Maximum number of results to return
1568
- 'page' => 1, // page 1 without a per_page will result in no pagination.
1569
- 'per_page' => false, // results per page
1570
- 'show_hidden' => true, // When fetching specific items, show all
1571
- 'sort' => 'DESC', // sort ASC or DESC
1572
- 'spam' => 'ham_only', // Retrieve items marked as spam
1573
  'update_meta_cache' => true,
1574
  ) );
1575
 
@@ -1588,7 +1566,7 @@ function bp_activity_get_specific( $args = '' ) {
1588
  /**
1589
  * Filters the requested specific activity item.
1590
  *
1591
- * @since BuddyPress (1.2.0)
1592
  *
1593
  * @param BP_Activity_Activity $activity Requested activity object.
1594
  * @param array $args Original passed in arguments.
@@ -1600,7 +1578,7 @@ function bp_activity_get_specific( $args = '' ) {
1600
  /**
1601
  * Add an activity item.
1602
  *
1603
- * @since BuddyPress (1.1.0)
1604
  *
1605
  * @uses wp_parse_args()
1606
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
@@ -1647,18 +1625,18 @@ function bp_activity_add( $args = '' ) {
1647
  'id' => false, // Pass an existing activity ID to update an existing entry.
1648
  'action' => '', // The activity action - e.g. "Jon Doe posted an update"
1649
  'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
1650
- 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent
1651
- 'type' => false, // The activity type e.g. activity_update, profile_updated
1652
- 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
1653
  'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user.
1654
- 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
1655
- 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
1656
- 'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
1657
  'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
1658
  'is_spam' => false, // Is this activity item to be marked as spam?
1659
  ), 'activity_add' );
1660
 
1661
- // Make sure we are backwards compatible
1662
  if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
1663
  $r['component'] = $r['component_name'];
1664
  }
@@ -1667,7 +1645,7 @@ function bp_activity_add( $args = '' ) {
1667
  $r['type'] = $r['component_action'];
1668
  }
1669
 
1670
- // Setup activity to be added
1671
  $activity = new BP_Activity_Activity( $r['id'] );
1672
  $activity->user_id = $r['user_id'];
1673
  $activity->component = $r['component'];
@@ -1687,9 +1665,9 @@ function bp_activity_add( $args = '' ) {
1687
  return false;
1688
  }
1689
 
1690
- // If this is an activity comment, rebuild the tree
1691
  if ( 'activity_comment' === $activity->type ) {
1692
- // Also clear the comment cache for the parent activity ID
1693
  wp_cache_delete( $activity->item_id, 'bp_activity_comments' );
1694
 
1695
  BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
@@ -1700,7 +1678,7 @@ function bp_activity_add( $args = '' ) {
1700
  /**
1701
  * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID.
1702
  *
1703
- * @since BuddyPress (1.1.0)
1704
  *
1705
  * @param array $r Array of parsed arguments for the activity item being added.
1706
  */
@@ -1712,7 +1690,7 @@ function bp_activity_add( $args = '' ) {
1712
  /**
1713
  * Post an activity update.
1714
  *
1715
- * @since BuddyPress (1.2.0)
1716
  *
1717
  * @uses wp_parse_args()
1718
  * @uses bp_is_user_inactive()
@@ -1746,14 +1724,14 @@ function bp_activity_post_update( $args = '' ) {
1746
  return false;
1747
  }
1748
 
1749
- // Record this on the user's profile
1750
  $activity_content = $r['content'];
1751
  $primary_link = bp_core_get_userlink( $r['user_id'], false, true );
1752
 
1753
  /**
1754
  * Filters the new activity content for current activity item.
1755
  *
1756
- * @since BuddyPress (1.2.0)
1757
  *
1758
  * @param string $activity_content Activity content posted by user.
1759
  */
@@ -1762,13 +1740,13 @@ function bp_activity_post_update( $args = '' ) {
1762
  /**
1763
  * Filters the activity primary link for current activity item.
1764
  *
1765
- * @since BuddyPress (1.2.0)
1766
  *
1767
  * @param string $primary_link Link to the profile for the user who posted the activity.
1768
  */
1769
  $add_primary_link = apply_filters( 'bp_activity_new_update_primary_link', $primary_link );
1770
 
1771
- // Now write the values
1772
  $activity_id = bp_activity_add( array(
1773
  'user_id' => $r['user_id'],
1774
  'content' => $add_content,
@@ -1780,7 +1758,7 @@ function bp_activity_post_update( $args = '' ) {
1780
  /**
1781
  * Filters the latest update content for the activity item.
1782
  *
1783
- * @since BuddyPress (1.6.0)
1784
  *
1785
  * @param string $r Content of the activity update.
1786
  * @param string $activity_content Content of the activity update.
@@ -1796,7 +1774,7 @@ function bp_activity_post_update( $args = '' ) {
1796
  /**
1797
  * Fires at the end of an activity post update, before returning the updated activity item ID.
1798
  *
1799
- * @since BuddyPress (1.2.0)
1800
  *
1801
  * @param string $content Content of the activity post update.
1802
  * @param int $user_id ID of the user posting the activity update.
@@ -1810,12 +1788,11 @@ function bp_activity_post_update( $args = '' ) {
1810
  /**
1811
  * Create an activity item for a newly published post type post.
1812
  *
1813
- * @since BuddyPress (2.2.0)
1814
- *
1815
- * @param int $post_id ID of the new post.
1816
- * @param WP_Post $post Post object.
1817
- * @param int $user_id ID of the post author.
1818
  *
 
 
 
1819
  * @return int|bool The ID of the activity on success. False on error.
1820
  */
1821
  function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0 ) {
@@ -1860,7 +1837,7 @@ function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0
1860
  * This is a variable filter, dependent on the post type,
1861
  * that lets components or plugins bail early if needed.
1862
  *
1863
- * @since BuddyPress (2.2.0)
1864
  *
1865
  * @param bool $value Whether or not to continue.
1866
  * @param int $blog_id ID of the current site.
@@ -1934,7 +1911,7 @@ function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0
1934
  /**
1935
  * Fires after the publishing of an activity item for a newly published post type post.
1936
  *
1937
- * @since BuddyPress (2.2.0)
1938
  *
1939
  * @param int $activity_id ID of the newly published activity item.
1940
  * @param WP_Post $post Post object.
@@ -1948,11 +1925,10 @@ function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0
1948
  /**
1949
  * Update the activity item for a custom post type entry.
1950
  *
1951
- * @since BuddyPress (2.2.0)
1952
  *
1953
- * @param WP_Post $post Post item.
1954
- *
1955
- * @return bool True on success, false on failure.
1956
  */
1957
  function bp_activity_post_type_update( $post = null ) {
1958
 
@@ -2004,7 +1980,7 @@ function bp_activity_post_type_update( $post = null ) {
2004
  /**
2005
  * Fires after the updating of an activity item for a custom post type entry.
2006
  *
2007
- * @since BuddyPress (2.2.0)
2008
  *
2009
  * @param WP_Post $post Post object.
2010
  * @param BP_Activity_Activity $activity Activity object.
@@ -2017,12 +1993,11 @@ function bp_activity_post_type_update( $post = null ) {
2017
  /**
2018
  * Unpublish an activity for the custom post type.
2019
  *
2020
- * @since BuddyPress (2.2.0)
2021
  *
2022
  * @param int $post_id ID of the post being unpublished.
2023
  * @param WP_Post $post Post object.
2024
- *
2025
- * @return bool True on success, false on failure.
2026
  */
2027
  function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2028
 
@@ -2030,7 +2005,7 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2030
  return;
2031
  }
2032
 
2033
- // Get the post type tracking args
2034
  $activity_post_object = bp_activity_get_post_type_tracking_args( $post->post_type );
2035
 
2036
  if ( empty( $activity_post_object->action_id ) ) {
@@ -2054,7 +2029,7 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2054
  /**
2055
  * Fires after the unpublishing for the custom post type.
2056
  *
2057
- * @since BuddyPress (2.2.0)
2058
  *
2059
  * @param array $delete_activity_args Array of arguments for activity deletion.
2060
  * @param WP_Post $post Post object.
@@ -2068,7 +2043,7 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2068
  /**
2069
  * Add an activity comment.
2070
  *
2071
- * @since BuddyPress (1.2.0)
2072
  *
2073
  * @uses wp_parse_args()
2074
  * @uses bp_activity_add()
@@ -2103,11 +2078,11 @@ function bp_activity_new_comment( $args = '' ) {
2103
  'id' => false,
2104
  'content' => false,
2105
  'user_id' => bp_loggedin_user_id(),
2106
- 'activity_id' => false, // ID of the root activity item
2107
- 'parent_id' => false // ID of a parent comment (optional)
2108
  ) );
2109
 
2110
- // Bail if missing necessary data
2111
  if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
2112
  $errors->add( 'missing_data', $feedback );
2113
  $bp->activity->errors['new_comment'] = $errors;
@@ -2115,17 +2090,17 @@ function bp_activity_new_comment( $args = '' ) {
2115
  return false;
2116
  }
2117
 
2118
- // Maybe set current activity ID as the parent
2119
  if ( empty( $r['parent_id'] ) ) {
2120
  $r['parent_id'] = $r['activity_id'];
2121
  }
2122
 
2123
  $activity_id = $r['activity_id'];
2124
 
2125
- // Get the parent activity
2126
  $activity = new BP_Activity_Activity( $activity_id );
2127
 
2128
- // Bail if the parent activity does not exist
2129
  if ( empty( $activity->date_recorded ) ) {
2130
  $errors->add( 'missing_activity', __( 'Sorry, the item you are replying to no longer exists.', 'buddypress' ) );
2131
  $bp->activity->errors['new_comment'] = $errors;
@@ -2139,13 +2114,13 @@ function bp_activity_new_comment( $args = '' ) {
2139
  /**
2140
  * Filters the content of a new comment.
2141
  *
2142
- * @since BuddyPress (1.2.0)
2143
  *
2144
  * @param string $r Content for the newly posted comment.
2145
  */
2146
  $comment_content = apply_filters( 'bp_activity_comment_content', $r['content'] );
2147
 
2148
- // Insert the activity comment
2149
  $comment_id = bp_activity_add( array(
2150
  'id' => $r['id'],
2151
  'content' => $comment_content,
@@ -2157,10 +2132,10 @@ function bp_activity_new_comment( $args = '' ) {
2157
  'hide_sitewide' => $is_hidden
2158
  ) );
2159
 
2160
- // Comment caches are stored only with the top-level item
2161
  wp_cache_delete( $activity_id, 'bp_activity_comments' );
2162
 
2163
- // Walk the tree to clear caches for all parent items
2164
  $clear_id = $r['parent_id'];
2165
  while ( $clear_id != $activity_id ) {
2166
  $clear_object = new BP_Activity_Activity( $clear_id );
@@ -2172,7 +2147,7 @@ function bp_activity_new_comment( $args = '' ) {
2172
  /**
2173
  * Fires near the end of an activity comment posting, before the returning of the comment ID.
2174
  *
2175
- * @since BuddyPress (1.2.0)
2176
  *
2177
  * @param int $comment_id ID of the newly posted activity comment.
2178
  * @param array $r Array of parsed comment arguments.
@@ -2191,7 +2166,7 @@ function bp_activity_new_comment( $args = '' ) {
2191
  /**
2192
  * Fetch the activity_id for an existing activity entry in the DB.
2193
  *
2194
- * @since BuddyPress (1.2.0)
2195
  *
2196
  * @see BP_Activity_Activity::get() For more information on accepted arguments.
2197
  * @uses wp_parse_args()
@@ -2199,7 +2174,6 @@ function bp_activity_new_comment( $args = '' ) {
2199
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
2200
  *
2201
  * @param array|string $args See BP_Activity_Activity::get() for description.
2202
- *
2203
  * @return int $activity_id The ID of the activity item found.
2204
  */
2205
  function bp_activity_get_activity_id( $args = '' ) {
@@ -2218,7 +2192,7 @@ function bp_activity_get_activity_id( $args = '' ) {
2218
  /**
2219
  * Filters the activity ID being requested.
2220
  *
2221
- * @since BuddyPress (1.2.0)
2222
  *
2223
  * @param BP_Activity_Activity $value ID returned by BP_Activity_Activity get_id() method with provided arguments.
2224
  */
@@ -2247,7 +2221,7 @@ function bp_activity_get_activity_id( $args = '' ) {
2247
  *
2248
  * If you are deleting an activity comment please use bp_activity_delete_comment();
2249
  *
2250
- * @since BuddyPress (1.0.0)
2251
  *
2252
  * @see BP_Activity_Activity::get() For more information on accepted arguments.
2253
  * @uses wp_parse_args()
@@ -2265,12 +2239,11 @@ function bp_activity_get_activity_id( $args = '' ) {
2265
  * filters for item deletion, the argument format is
2266
  * the same as BP_Activity_Activity::get().
2267
  * See that method for a description.
2268
- *
2269
  * @return bool True on success, false on failure.
2270
  */
2271
  function bp_activity_delete( $args = '' ) {
2272
 
2273
- // Pass one or more the of following variables to delete by those variables
2274
  $args = bp_parse_args( $args, array(
2275
  'id' => false,
2276
  'action' => false,
@@ -2288,13 +2261,13 @@ function bp_activity_delete( $args = '' ) {
2288
  /**
2289
  * Fires before an activity item proceeds to be deleted.
2290
  *
2291
- * @since BuddyPress (1.5.0)
2292
  *
2293
  * @param array $args Array of arguments to be used with the activity deletion.
2294
  */
2295
  do_action( 'bp_before_activity_delete', $args );
2296
 
2297
- // Adjust the new mention count of any mentioned member
2298
  bp_activity_adjust_mention_count( $args['id'], 'delete' );
2299
 
2300
  $activity_ids_deleted = BP_Activity_Activity::delete( $args );
@@ -2302,7 +2275,7 @@ function bp_activity_delete( $args = '' ) {
2302
  return false;
2303
  }
2304
 
2305
- // Check if the user's latest update has been deleted
2306
  $user_id = empty( $args['user_id'] )
2307
  ? bp_loggedin_user_id()
2308
  : $args['user_id'];
@@ -2317,7 +2290,7 @@ function bp_activity_delete( $args = '' ) {
2317
  /**
2318
  * Fires after the activity item has been deleted.
2319
  *
2320
- * @since BuddyPress (1.0.0)
2321
  *
2322
  * @param array $args Array of arguments used with the activity deletion.
2323
  */
@@ -2326,7 +2299,7 @@ function bp_activity_delete( $args = '' ) {
2326
  /**
2327
  * Fires after the activity item has been deleted.
2328
  *
2329
- * @since BuddyPress (1.2.0)
2330
  *
2331
  * @param array $activity_ids_deleted Array of affected activity item IDs.
2332
  */
@@ -2342,15 +2315,14 @@ function bp_activity_delete( $args = '' ) {
2342
  *
2343
  * You should use bp_activity_delete() instead.
2344
  *
2345
- * @since BuddyPress (1.1.0)
2346
- * @deprecated BuddyPress (1.2.0)
2347
  *
2348
  * @uses wp_parse_args()
2349
  * @uses bp_activity_delete()
2350
  *
2351
  * @param array|string $args See BP_Activity_Activity::get for a
2352
  * description of accepted arguments.
2353
- *
2354
  * @return bool True on success, false on failure.
2355
  */
2356
  function bp_activity_delete_by_item_id( $args = '' ) {
@@ -2369,12 +2341,11 @@ function bp_activity_delete( $args = '' ) {
2369
  /**
2370
  * Delete an activity item by activity id.
2371
  *
2372
- * @since BuddyPress (1.1.0)
2373
  *
2374
  * @uses bp_activity_delete()
2375
  *
2376
  * @param int $activity_id ID of the activity item to be deleted.
2377
- *
2378
  * @return bool True on success, false on failure.
2379
  */
2380
  function bp_activity_delete_by_activity_id( $activity_id ) {
@@ -2386,8 +2357,8 @@ function bp_activity_delete( $args = '' ) {
2386
  *
2387
  * You should use bp_activity_delete() instead.
2388
  *
2389
- * @since BuddyPress (1.1.0)
2390
- * @deprecated BuddyPress (1.2.0)
2391
  *
2392
  * @uses bp_activity_delete()
2393
  *
@@ -2395,7 +2366,6 @@ function bp_activity_delete( $args = '' ) {
2395
  * @param string $content The activity id.
2396
  * @param string $component The activity component.
2397
  * @param string $type The activity type.
2398
- *
2399
  * @return bool True on success, false on failure.
2400
  */
2401
  function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
@@ -2412,14 +2382,13 @@ function bp_activity_delete( $args = '' ) {
2412
  *
2413
  * You should use bp_activity_delete() instead.
2414
  *
2415
- * @since BuddyPress (1.1.0)
2416
- * @deprecated BuddyPress (1.2.0)
2417
  *
2418
  * @uses bp_activity_delete()
2419
  *
2420
  * @param int $user_id The user id.
2421
  * @param string $component The activity component.
2422
- *
2423
  * @return bool True on success, false on failure.
2424
  */
2425
  function bp_activity_delete_for_user_by_component( $user_id, $component ) {
@@ -2432,7 +2401,7 @@ function bp_activity_delete( $args = '' ) {
2432
  /**
2433
  * Delete an activity comment.
2434
  *
2435
- * @since BuddyPress (1.2.0)
2436
  *
2437
  * @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook.
2438
  * @uses bp_activity_delete_children()
@@ -2447,7 +2416,6 @@ function bp_activity_delete( $args = '' ) {
2447
  * @param int $activity_id The ID of the "root" activity, ie the comment's
2448
  * oldest ancestor.
2449
  * @param int $comment_id The ID of the comment to be deleted.
2450
- *
2451
  * @return bool True on success, false on failure.
2452
  */
2453
  function bp_activity_delete_comment( $activity_id, $comment_id ) {
@@ -2458,7 +2426,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2458
  * You may want to hook into this filter if you want to override this function and
2459
  * handle the deletion of child comments differently. Make sure you return false.
2460
  *
2461
- * @since BuddyPress (1.2.0)
2462
  *
2463
  * @param bool $value Whether BuddyPress should continue or not.
2464
  * @param int $activity_id ID of the root activity item being deleted.
@@ -2471,21 +2439,21 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2471
  // Delete any children of this comment.
2472
  bp_activity_delete_children( $activity_id, $comment_id );
2473
 
2474
- // Delete the actual comment
2475
  if ( ! bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) {
2476
  return false;
2477
  }
2478
 
2479
- // Purge comment cache for the root activity update
2480
  wp_cache_delete( $activity_id, 'bp_activity_comments' );
2481
 
2482
- // Recalculate the comment tree
2483
  BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
2484
 
2485
  /**
2486
  * Fires at the end of the deletion of an activity comment, before returning success.
2487
  *
2488
- * @since BuddyPress (1.2.0)
2489
  *
2490
  * @param int $activity_id ID of the activity that has had a comment deleted from.
2491
  * @param int $comment_id ID of the comment that was deleted.
@@ -2498,7 +2466,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2498
  /**
2499
  * Delete an activity comment's children.
2500
  *
2501
- * @since BuddyPress (1.2.0)
2502
  *
2503
  * @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
2504
  * @uses bp_activity_delete_children()
@@ -2510,7 +2478,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2510
  */
2511
  function bp_activity_delete_children( $activity_id, $comment_id ) {
2512
 
2513
- // Get activity children to delete
2514
  $children = BP_Activity_Activity::get_child_comments( $comment_id );
2515
 
2516
  // Recursively delete all children of this comment.
@@ -2520,7 +2488,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2520
  }
2521
  }
2522
 
2523
- // Delete the comment itself
2524
  bp_activity_delete( array(
2525
  'secondary_item_id' => $comment_id,
2526
  'type' => 'activity_comment',
@@ -2536,7 +2504,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2536
  * be sure to pass the full $activity_obj parameter as well, if you already
2537
  * have it available.
2538
  *
2539
- * @since BuddyPress (1.2.0)
2540
  *
2541
  * @uses bp_get_root_domain()
2542
  * @uses bp_get_activity_root_slug()
@@ -2544,7 +2512,6 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
2544
  *
2545
  * @param int $activity_id The unique id of the activity object.
2546
  * @param object|bool $activity_obj Optional. The activity object.
2547
- *
2548
  * @return string $link Permalink for the activity item.
2549
  */
2550
  function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
@@ -2582,7 +2549,7 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
2582
  /**
2583
  * Filters the activity permalink for the specified activity item.
2584
  *
2585
- * @since BuddyPress (1.2.0)
2586
  *
2587
  * @param array $array Array holding activity permalink and activity item object.
2588
  */
@@ -2592,12 +2559,11 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
2592
  /**
2593
  * Hide a user's activity.
2594
  *
2595
- * @since BuddyPress (1.2.0)
2596
  *
2597
  * @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
2598
  *
2599
  * @param int $user_id The ID of the user whose activity is being hidden.
2600
- *
2601
  * @return bool True on success, false on failure.
2602
  */
2603
  function bp_activity_hide_user_activity( $user_id ) {
@@ -2616,7 +2582,7 @@ function bp_activity_hide_user_activity( $user_id ) {
2616
  *
2617
  * As of BuddyPress 2.3, this function is no longer in use.
2618
  *
2619
- * @since BuddyPress (1.2.0)
2620
  *
2621
  * @uses esc_attr()
2622
  * @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook.
@@ -2626,7 +2592,6 @@ function bp_activity_hide_user_activity( $user_id ) {
2626
  * to. If absent, the image will not be a link.
2627
  * @param array|bool $args Optional. The args passed to the activity
2628
  * creation function (eg bp_blogs_record_activity()).
2629
- *
2630
  * @return string $content The content with images stripped and replaced with a
2631
  * single thumb.
2632
  */
@@ -2634,15 +2599,15 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
2634
 
2635
  preg_match_all( '/<img[^>]*>/Ui', $content, $matches );
2636
 
2637
- // Remove <img> tags. Also remove caption shortcodes and caption text if present
2638
  $content = preg_replace('|(\[caption(.*?)\])?<img[^>]*>([^\[\[]*\[\/caption\])?|', '', $content );
2639
 
2640
  if ( !empty( $matches ) && !empty( $matches[0] ) ) {
2641
 
2642
- // Get the SRC value
2643
  preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src );
2644
 
2645
- // Get the width and height
2646
  preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
2647
  preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
2648
 
@@ -2678,7 +2643,7 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
2678
  /**
2679
  * Filters the activity content that had a thumbnail replace images.
2680
  *
2681
- * @since BuddyPress (1.2.0)
2682
  *
2683
  * @param string $content Activity content that had images replaced in.
2684
  * @param array $matches Array of all image tags found in the posted content.
@@ -2694,13 +2659,12 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
2694
  * Currently, it's only used for blog post items, but it will probably be used for all types of
2695
  * activity in the future.
2696
  *
2697
- * @since BuddyPress (2.3.0)
2698
  *
2699
  * @param string $content The content of the activity item.
2700
  * @param array $activity The data passed to bp_activity_add() or the values
2701
  * from an Activity obj.
2702
- *
2703
- * @return string
2704
  */
2705
  function bp_activity_create_summary( $content, $activity ) {
2706
  $args = array(
@@ -2717,7 +2681,7 @@ function bp_activity_create_summary( $content, $activity ) {
2717
  *
2718
  * Use this filter to change the media extractor used to extract media info for the activity item.
2719
  *
2720
- * @since BuddyPress (2.3.0)
2721
  *
2722
  * @param string $extractor Class name.
2723
  * @param string $content The content of the activity item.
@@ -2729,7 +2693,7 @@ function bp_activity_create_summary( $content, $activity ) {
2729
  /**
2730
  * Filter the arguments passed to the media extractor when creating an Activity summary.
2731
  *
2732
- * @since BuddyPress (2.3.0)
2733
  *
2734
  * @param array $args Array of bespoke data for the media extractor.
2735
  * @param string $content The content of the activity item.
@@ -2802,7 +2766,7 @@ function bp_activity_create_summary( $content, $activity ) {
2802
  /**
2803
  * Filter the results of the media extractor when creating an Activity summary.
2804
  *
2805
- * @since BuddyPress (2.3.0)
2806
  *
2807
  * @param array $extracted_media Extracted media item. See {@link BP_Media_Extractor::extract()} for format.
2808
  * @param string $content Content of the activity item.
@@ -2839,7 +2803,7 @@ function bp_activity_create_summary( $content, $activity ) {
2839
  /**
2840
  * Filters the newly-generated summary for the activity item.
2841
  *
2842
- * @since BuddyPress (2.3.0)
2843
  *
2844
  * @param string $summary Activity summary HTML.
2845
  * @param string $content Content of the activity item.
@@ -2852,7 +2816,7 @@ function bp_activity_create_summary( $content, $activity ) {
2852
  /**
2853
  * Fetch whether the current user is allowed to mark items as spam.
2854
  *
2855
- * @since BuddyPress (1.6.0)
2856
  *
2857
  * @return bool True if user is allowed to mark activity items as spam.
2858
  */
@@ -2861,7 +2825,7 @@ function bp_activity_user_can_mark_spam() {
2861
  /**
2862
  * Filters whether the current user should be able to mark items as spam.
2863
  *
2864
- * @since BuddyPress (1.6.0)
2865
  *
2866
  * @param bool $moderate Whether or not the current user has bp_moderate capability.
2867
  */
@@ -2871,7 +2835,7 @@ function bp_activity_user_can_mark_spam() {
2871
  /**
2872
  * Mark an activity item as spam.
2873
  *
2874
- * @since BuddyPress (1.6.0)
2875
  *
2876
  * @param BP_Activity_Activity $activity The activity item to be spammed.
2877
  * @param string $source Optional. Default is "by_a_person" (ie, a person has
@@ -2883,30 +2847,30 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
2883
 
2884
  $activity->is_spam = 1;
2885
 
2886
- // Clear the activity stream first page cache
2887
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
2888
 
2889
- // Clear the activity comment cache for this activity item
2890
  wp_cache_delete( $activity->id, 'bp_activity_comments' );
2891
 
2892
- // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity
2893
  if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
2894
  remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 4, 1 );
2895
 
2896
- // Build data package for Akismet
2897
  $activity_data = BP_Akismet::build_akismet_data_package( $activity );
2898
 
2899
- // Tell Akismet this is spam
2900
  $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'spam' );
2901
 
2902
- // Update meta
2903
  add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_spam_meta' ), 1, 1 );
2904
  }
2905
 
2906
  /**
2907
  * Fires at the end of the process to mark an activity item as spam.
2908
  *
2909
- * @since BuddyPress (1.6.0)
2910
  *
2911
  * @param BP_Activity_Activity $activity Activity item being marked as spam.
2912
  * @param string $source Source of determination of spam status. For example
@@ -2918,7 +2882,7 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
2918
  /**
2919
  * Mark an activity item as ham.
2920
  *
2921
- * @since BuddyPress (1.6.0)
2922
  *
2923
  * @param BP_Activity_Activity $activity The activity item to be hammed. Passed by reference.
2924
  * @param string $source Optional. Default is "by_a_person" (ie, a person has
@@ -2930,30 +2894,30 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
2930
 
2931
  $activity->is_spam = 0;
2932
 
2933
- // Clear the activity stream first page cache
2934
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
2935
 
2936
- // Clear the activity comment cache for this activity item
2937
  wp_cache_delete( $activity->id, 'bp_activity_comments' );
2938
 
2939
- // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity
2940
  if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
2941
  remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 4, 1 );
2942
 
2943
- // Build data package for Akismet
2944
  $activity_data = BP_Akismet::build_akismet_data_package( $activity );
2945
 
2946
- // Tell Akismet this is spam
2947
  $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'ham' );
2948
 
2949
- // Update meta
2950
  add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_ham_meta' ), 1, 1 );
2951
  }
2952
 
2953
  /**
2954
  * Fires at the end of the process to mark an activity item as ham.
2955
  *
2956
- * @since BuddyPress (1.6.0)
2957
  *
2958
  * @param BP_Activity_Activity $activity Activity item being marked as ham.
2959
  * @param string $source Source of determination of ham status. For example
@@ -2975,7 +2939,7 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
2975
  * This does not cover recursive activity comments, as they do not use a real loop.
2976
  * For that, see {@link bp_activity_comment_embed()}.
2977
  *
2978
- * @since BuddyPress (1.5.0)
2979
  *
2980
  * @see BP_Embed
2981
  * @see bp_embed_activity_cache()
@@ -3000,7 +2964,7 @@ add_action( 'activity_loop_start', 'bp_activity_embed' );
3000
  * necessary to grab each comment's embeds from the cache, or put them in
3001
  * the cache if they are not there yet.
3002
  *
3003
- * @since BuddyPress (1.5.0)
3004
  *
3005
  * @see BP_Embed
3006
  * @see bp_embed_activity_cache()
@@ -3020,7 +2984,7 @@ add_action( 'bp_before_activity_comment', 'bp_activity_comment_embed' );
3020
  /**
3021
  * When a user clicks on a "Read More" item, make sure embeds are correctly parsed and shown for the expanded content.
3022
  *
3023
- * @since BuddyPress (1.5.0)
3024
  *
3025
  * @see BP_Embed
3026
  * @uses add_filter() To attach create_function() to 'embed_post_id'.
@@ -3045,7 +3009,7 @@ add_action( 'bp_legacy_theme_get_single_activity_content', 'bp_dtheme_embed_read
3045
  * This filter must be removed so that the non-comment filters take over again
3046
  * once the comments are done being processed.
3047
  *
3048
- * @since BuddyPress (1.5.0)
3049
  *
3050
  * @see bp_activity_comment_embed()
3051
  * @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id'.
@@ -3060,7 +3024,7 @@ add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurs
3060
  *
3061
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
3062
  *
3063
- * @since BuddyPress (1.5.0)
3064
  *
3065
  * @see BP_Embed::parse_oembed()
3066
  * @uses bp_activity_get_meta()
@@ -3069,7 +3033,6 @@ add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurs
3069
  * functions like this one to filter.
3070
  * @param int $id The ID of the activity item.
3071
  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
3072
- *
3073
  * @return mixed The cached embeds for this activity item.
3074
  */
3075
  function bp_embed_activity_cache( $cache, $id, $cachekey ) {
@@ -3081,7 +3044,7 @@ function bp_embed_activity_cache( $cache, $id, $cachekey ) {
3081
  *
3082
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
3083
  *
3084
- * @since BuddyPress (1.5.0)
3085
  *
3086
  * @see BP_Embed::parse_oembed()
3087
  * @uses bp_activity_update_meta()
@@ -3090,8 +3053,6 @@ function bp_embed_activity_cache( $cache, $id, $cachekey ) {
3090
  * functions like this one to filter.
3091
  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
3092
  * @param int $id The ID of the activity item.
3093
- *
3094
- * @return bool True on success, false on failure.
3095
  */
3096
  function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
3097
  bp_activity_update_meta( $id, $cachekey, $cache );
@@ -3100,16 +3061,13 @@ function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
3100
  /**
3101
  * Should we use Heartbeat to refresh activities?
3102
  *
3103
- * @since BuddyPress (2.0.0)
3104
  *
3105
  * @uses bp_is_activity_heartbeat_active() to check if heartbeat setting is on.
3106
  * @uses bp_is_activity_directory() to check if the current page is the activity
3107
  * directory.
3108
- * @uses bp_is_active() to check if the group component is active.
3109
  * @uses bp_is_group_activity() to check if on a single group, the current page
3110
  * is the group activities.
3111
- * @uses bp_is_group_home() to check if the current page is a single group home
3112
- * page.
3113
  *
3114
  * @return bool True if activity heartbeat is enabled, otherwise false.
3115
  */
@@ -3120,18 +3078,9 @@ function bp_activity_do_heartbeat() {
3120
  return $retval;
3121
  }
3122
 
3123
- if ( bp_is_activity_directory() ) {
3124
  $retval = true;
3125
  }
3126
 
3127
- if ( bp_is_active( 'groups') ) {
3128
- // If no custom front, then activities are loaded in group's home
3129
- $has_custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );
3130
-
3131
- if ( bp_is_group_activity() || ( ! $has_custom_front && bp_is_group_home() ) ) {
3132
- $retval = true;
3133
- }
3134
- }
3135
-
3136
  return $retval;
3137
  }
1
  <?php
 
2
  /**
3
  * BuddyPress Activity Functions.
4
  *
8
  * @subpackage ActivityFunctions
9
  */
10
 
11
+ // Exit if accessed directly.
12
  defined( 'ABSPATH' ) || exit;
13
 
14
  /**
15
  * Check whether the $bp global lists an activity directory page.
16
  *
17
+ * @since 1.5.0
18
  *
19
  * @return bool True if activity directory page is found, otherwise false.
20
  */
37
  *
38
  * add_filter( 'bp_activity_do_mentions', '__return_false' );
39
  *
40
+ * @since 1.8.0
41
  *
42
  * @uses apply_filters() To call 'bp_activity_do_mentions' hook.
43
  *
48
  /**
49
  * Filters whether or not mentions are enabled.
50
  *
51
+ * @since 1.8.0
52
  *
53
  * @param bool $enabled True to enable mentions, false to disable.
54
  */
59
  * Should BuddyPress load the mentions scripts and related assets, including results to prime the
60
  * mentions suggestions?
61
  *
62
+ * @since 2.1.0
63
  *
64
  * @return bool True if mentions scripts should be loaded.
65
  */
70
  /**
71
  * Filters whether or not BuddyPress should load mentions scripts and assets.
72
  *
73
+ * @since 2.1.0
74
  *
75
  * @param bool $load_mentions True to load mentions assets, false otherwise.
76
  * @param bool $mentions_enabled True if mentions are enabled.
81
  /**
82
  * Locate usernames in an activity content string, as designated by an @ sign.
83
  *
84
+ * @since 1.5.0
85
  *
86
  * @param string $content The content of the activity, usually found in
87
  * $activity->content.
 
88
  * @return array|bool Associative array with user ID as key and username as
89
  * value. Boolean false if no mentions found.
90
  */
93
  $pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
94
  preg_match_all( $pattern, $content, $usernames );
95
 
96
+ // Make sure there's only one instance of each username.
97
  $usernames = array_unique( $usernames[1] );
98
 
99
+ // Bail if no usernames.
100
  if ( empty( $usernames ) ) {
101
  return false;
102
  }
103
 
104
  $mentioned_users = array();
105
 
106
+ // We've found some mentions! Check to see if users exist.
107
  foreach( (array) array_values( $usernames ) as $username ) {
108
  $user_id = bp_activity_get_userid_from_mentionname( $username );
109
 
110
+ // The user ID exists, so let's add it to our array.
111
  if ( ! empty( $user_id ) ) {
112
  $mentioned_users[ $user_id ] = $username;
113
  }
123
  /**
124
  * Reset a user's unread mentions list and count.
125
  *
126
+ * @since 1.5.0
127
  *
128
  * @uses bp_delete_user_meta()
129
  *
142
  *
143
  * Currently, only used in {@link bp_activity_delete()}.
144
  *
145
+ * @since 1.5.0
146
  *
147
  * @uses bp_activity_find_mentions()
148
  * @uses bp_activity_update_mention_count_for_user()
149
  *
150
  * @param int $activity_id The unique id for the activity item.
151
  * @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
 
152
  * @return bool
153
  */
154
  function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
155
 
156
+ // Bail if no activity ID passed.
157
  if ( empty( $activity_id ) ) {
158
  return false;
159
  }
160
 
161
+ // Get activity object.
162
  $activity = new BP_Activity_Activity( (int) $activity_id );
163
 
164
+ // Try to find mentions.
165
  $usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
166
 
167
+ // Still empty? Stop now.
168
  if ( empty( $usernames ) ) {
169
  return false;
170
  }
171
 
172
+ // Increment mention count foreach mentioned user.
173
  foreach( (array) array_keys( $usernames ) as $user_id ) {
174
  bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
175
  }
181
  * This function should be used when you've already parsed your activity item
182
  * for @mentions.
183
  *
184
+ * @since 1.7.0
185
  *
186
  * @uses bp_get_user_meta()
187
  * @uses bp_update_user_meta()
189
  * @param int $user_id The user ID.
190
  * @param int $activity_id The unique ID for the activity item.
191
  * @param string $action 'delete' or 'add'. Default: 'add'.
 
192
  * @return bool
193
  */
194
  function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
197
  return false;
198
  }
199
 
200
+ // Adjust the mention list and count for the member.
201
  $new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true );
202
  $new_mentions = bp_get_user_meta( $user_id, 'bp_new_mentions', true );
203
 
204
+ // Make sure new mentions is an array.
205
  if ( empty( $new_mentions ) ) {
206
  $new_mentions = array();
207
  }
225
  break;
226
  }
227
 
228
+ // Get an updated mention count.
229
  $new_mention_count = count( $new_mentions );
230
 
231
+ // Resave the user_meta.
232
  bp_update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count );
233
  bp_update_user_meta( $user_id, 'bp_new_mentions', $new_mentions );
234
 
238
  /**
239
  * Determine a user's "mentionname", the name used for that user in @-mentions.
240
  *
241
+ * @since 1.9.0
242
  *
243
  * @param int|string $user_id ID of the user to get @-mention name for.
244
+ * @return string $mentionname User name appropriate for @-mentions.
 
245
  */
246
  function bp_activity_get_user_mentionname( $user_id ) {
247
  $mentionname = '';
262
  /**
263
  * Get a user ID from a "mentionname", the name used for a user in @-mentions.
264
  *
265
+ * @since 1.9.0
266
  *
267
  * @param string $mentionname Username of user in @-mentions.
 
268
  * @return int|bool ID of the user, if one is found. Otherwise false.
269
  */
270
  function bp_activity_get_userid_from_mentionname( $mentionname ) {
271
  $user_id = false;
272
 
273
+ /*
274
+ * In username compatibility mode, hyphens are ambiguous between
275
+ * actual hyphens and converted spaces.
276
+ *
277
+ * @todo There is the potential for username clashes between 'foo bar'
278
+ * and 'foo-bar' in compatibility mode. Come up with a system for
279
+ * unique mentionnames.
280
+ */
281
  if ( bp_is_username_compatibility_mode() ) {
282
+ // First, try the raw username.
283
  $userdata = get_user_by( 'login', $mentionname );
284
 
285
  // Doing a direct query to use proper regex. Necessary to
293
  }
294
 
295
  // When username compatibility mode is disabled, the mentionname is
296
+ // the same as the nicename.
297
  } else {
298
  $user_id = bp_core_get_userid_from_nicename( $mentionname );
299
  }
318
  * panel, and dynamic action generation (which is essential for multilingual
319
  * sites, etc) will not work.
320
  *
321
+ * @since 1.1.0
322
  *
323
  * @param string $component_id The unique string ID of the component.
324
  * @param string $type The action type.
328
  * @param array $context Optional. Activity stream contexts where the filter should appear.
329
  * Values: 'activity', 'member', 'member_groups', 'group'.
330
  * @param int $position Optional. The position of the action when listed in dropdowns.
 
331
  * @return bool False if any param is empty, otherwise true.
332
  */
333
  function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array(), $position = 0 ) {
334
  $bp = buddypress();
335
 
336
+ // Return false if any of the above values are not set.
337
  if ( empty( $component_id ) || empty( $type ) || empty( $description ) ) {
338
  return false;
339
  }
340
 
341
+ // Set activity action.
342
  if ( ! isset( $bp->activity->actions ) || ! is_object( $bp->activity->actions ) ) {
343
  $bp->activity->actions = new stdClass;
344
  }
345
 
346
+ // Verify callback.
347
  if ( ! is_callable( $format_callback ) ) {
348
  $format_callback = '';
349
  }
355
  /**
356
  * Filters the action type being set for the current activity item.
357
  *
358
+ * @since 1.1.0
359
  *
360
  * @param array $array Array of arguments for action type being set.
361
  * @param string $component_id ID of the current component being set.
381
  /**
382
  * Set tracking arguments for a given post type.
383
  *
384
+ * @since 2.2.0
385
  *
386
  * @global $wp_post_types
387
  *
388
  * @param string $post_type The name of the post type, as registered with WordPress. Eg 'post' or 'page'.
389
  * @param array $args {
390
  * An associative array of tracking parameters. All items are optional.
 
391
  * @type string $bp_activity_admin_filter String to use in the Dashboard > Activity dropdown.
392
  * @type string $bp_activity_front_filter String to use in frontend dropdown.
393
  * @type string $bp_activity_new_post String format to use for generating the activity action. Should be a
409
  * @type bool $activity_comment Whether to allow comments on the activity items. Defaults to true if
410
  * the post type does not natively support comments, otherwise false.
411
  * }
 
412
  * @return bool
413
  */
414
  function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array() ) {
435
  /**
436
  * Get tracking arguments for a specific post type.
437
  *
438
+ * @since 2.2.0
439
  *
440
  * @param string $post_type Name of the post type.
 
441
  * @return object The tracking arguments of the post type.
442
  */
443
  function bp_activity_get_post_type_tracking_args( $post_type ) {
491
  /**
492
  * Filters tracking arguments for a specific post type.
493
  *
494
+ * @since 2.2.0
495
  *
496
  * @param object $post_type_activity The tracking arguments of the post type.
497
  * @param string $post_type Name of the post type.
502
  /**
503
  * Get tracking arguments for all post types.
504
  *
505
+ * @since 2.2.0
506
  *
507
  * @return array List of post types with their tracking arguments.
508
  */
509
  function bp_activity_get_post_types_tracking_args() {
510
+ // Fetch all public post types.
511
  $post_types = get_post_types( array( 'public' => true ), 'names' );
512
 
513
  $post_types_tracking_args = array();
524
  /**
525
  * Filters tracking arguments for all post types.
526
  *
527
+ * @since 2.2.0
528
  *
529
  * @param array $post_types_tracking_args Array of post types with
530
  * their tracking arguments.
535
  /**
536
  * Get all components' activity actions, sorted by their position attribute.
537
  *
538
+ * @since 2.2.0
539
  *
540
  * @return object Actions ordered by their position.
541
  */
581
  /**
582
  * Retrieve the current action from a component and key.
583
  *
584
+ * @since 1.1.0
585
  *
586
  * @uses apply_filters() To call the 'bp_activity_get_action' hook.
587
  *
588
  * @param string $component_id The unique string ID of the component.
589
  * @param string $key The action key.
 
590
  * @return string|bool Action value if found, otherwise false.
591
  */
592
  function bp_activity_get_action( $component_id, $key ) {
593
 
594
+ // Return false if any of the above values are not set.
595
  if ( empty( $component_id ) || empty( $key ) ) {
596
  return false;
597
  }
606
  /**
607
  * Filters the current action by component and key.
608
  *
609
+ * @since 1.1.0
610
  *
611
  * @param string|bool $retval The action key.
612
  * @param string $component_id The unique string ID of the component.
618
  /**
619
  * Fetch details of all registered activity types.
620
  *
621
+ * @since 1.7.0
622
  *
623
  * @return array array( type => description ), ...
624
  */
634
  }
635
  }
636
 
637
+ // This was a mis-named activity type from before BP 1.6.
638
  unset( $actions['friends_register_activity_action'] );
639
 
640
  /**
641
  * Filters the available activity types.
642
  *
643
+ * @since 1.7.0
644
  *
645
  * @param array $actions Array of registered activity types.
646
  */
652
  /**
653
  * Get a users favorite activity stream items.
654
  *
655
+ * @since 1.2.0
656
  *
657
  * @uses bp_get_user_meta()
658
  * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
659
  *
660
  * @param int $user_id ID of the user whose favorites are being queried.
 
661
  * @return array IDs of the user's favorite activity items.
662
  */
663
  function bp_activity_get_user_favorites( $user_id = 0 ) {
664
 
665
+ // Fallback to logged in user if no user_id is passed.
666
  if ( empty( $user_id ) ) {
667
  $user_id = bp_displayed_user_id();
668
  }
669
 
670
+ // Get favorites for user.
671
  $favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
672
 
673
  /**
674
  * Filters the favorited activity items for a specified user.
675
  *
676
+ * @since 1.2.0
677
  *
678
  * @param array $favs Array of user's favorited activity items.
679
  */
683
  /**
684
  * Add an activity stream item as a favorite for a user.
685
  *
686
+ * @since 1.2.0
687
  *
688
  * @uses is_user_logged_in()
689
  * @uses bp_get_user_meta()
695
  *
696
  * @param int $activity_id ID of the activity item being favorited.
697
  * @param int $user_id ID of the user favoriting the activity item.
 
698
  * @return bool True on success, false on failure.
699
  */
700
  function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
701
 
702
+ // Favorite activity stream items are for logged in users only.
703
  if ( ! is_user_logged_in() ) {
704
  return false;
705
  }
706
 
707
+ // Fallback to logged in user if no user_id is passed.
708
  if ( empty( $user_id ) ) {
709
  $user_id = bp_loggedin_user_id();
710
  }
714
  $my_favs = array();
715
  }
716
 
717
+ // Bail if the user has already favorited this activity item.
718
  if ( in_array( $activity_id, $my_favs ) ) {
719
  return false;
720
  }
721
 
722
+ // Add to user's favorites.
723
  $my_favs[] = $activity_id;
724
 
725
+ // Update the total number of users who have favorited this activity.
726
  $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
727
  $fav_count = !empty( $fav_count ) ? (int) $fav_count + 1 : 1;
728
 
729
+ // Update user meta.
730
  bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs );
731
 
732
+ // Update activity meta counts.
733
  if ( bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ) ) {
734
 
735
  /**
736
  * Fires if bp_activity_update_meta() for favorite_count is successful and before returning a true value for success.
737
  *
738
+ * @since 1.2.1
739
  *
740
  * @param int $activity_id ID of the activity item being favorited.
741
  * @param int $user_id ID of the user doing the favoriting.
742
  */
743
  do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
744
 
745
+ // Success.
746
  return true;
747
 
748
+ // Saving meta was unsuccessful for an unknown reason.
749
  } else {
750
 
751
  /**
752
  * Fires if bp_activity_update_meta() for favorite_count is unsuccessful and before returning a false value for failure.
753
  *
754
+ * @since 1.5.0
755
  *
756
  * @param int $activity_id ID of the activity item being favorited.
757
  * @param int $user_id ID of the user doing the favoriting.
765
  /**
766
  * Remove an activity stream item as a favorite for a user.
767
  *
768
+ * @since 1.2.0
769
  *
770
  * @uses is_user_logged_in()
771
  * @uses bp_get_user_meta()
776
  *
777
  * @param int $activity_id ID of the activity item being unfavorited.
778
  * @param int $user_id ID of the user unfavoriting the activity item.
 
779
  * @return bool True on success, false on failure.
780
  */
781
  function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
782
 
783
+ // Favorite activity stream items are for logged in users only.
784
  if ( ! is_user_logged_in() ) {
785
  return false;
786
  }
787
 
788
+ // Fallback to logged in user if no user_id is passed.
789
  if ( empty( $user_id ) ) {
790
  $user_id = bp_loggedin_user_id();
791
  }
793
  $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
794
  $my_favs = array_flip( (array) $my_favs );
795
 
796
+ // Bail if the user has not previously favorited the item.
797
  if ( ! isset( $my_favs[ $activity_id ] ) ) {
798
  return false;
799
  }
800
 
801
+ // Remove the fav from the user's favs.
802
  unset( $my_favs[$activity_id] );
803
  $my_favs = array_unique( array_flip( $my_favs ) );
804
 
805
+ // Update the total number of users who have favorited this activity.
806
  $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
807
  if ( ! empty( $fav_count ) ) {
808
 
809
+ // Deduct from total favorites.
810
  if ( bp_activity_update_meta( $activity_id, 'favorite_count', (int) $fav_count - 1 ) ) {
811
 
812
+ // Update users favorites.
813
  if ( bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs ) ) {
814
 
815
  /**
816
  * Fires if bp_update_user_meta() is successful and before returning a true value for success.
817
  *
818
+ * @since 1.2.1
819
  *
820
  * @param int $activity_id ID of the activity item being unfavorited.
821
  * @param int $user_id ID of the user doing the unfavoriting.
822
  */
823
  do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
824
 
825
+ // Success.
826
  return true;
827
 
828
+ // Error updating.
829
  } else {
830
  return false;
831
  }
832
 
833
+ // Error updating favorite count.
834
  } else {
835
  return false;
836
  }
837
 
838
+ // Error getting favorite count.
839
  } else {
840
  return false;
841
  }
844
  /**
845
  * Check whether an activity item exists with a given content string.
846
  *
847
+ * @since 1.1.0
848
  *
849
  * @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity}
850
  * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
851
  *
852
  * @param string $content The content to filter by.
 
853
  * @return int|null The ID of the located activity item. Null if none is found.
854
  */
855
  function bp_activity_check_exists_by_content( $content ) {
857
  /**
858
  * Filters the results of the check for whether an activity item exists by specified content.
859
  *
860
+ * @since 1.1.0
861
  *
862
  * @param BP_Activity_Activity $content_exists ID of the activity if found, else null.
863
  */
867
  /**
868
  * Retrieve the last time activity was updated.
869
  *
870
+ * @since 1.0.0
871
  *
872
  * @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity}
873
  * @uses apply_filters() To call the 'bp_activity_get_last_updated' hook.
879
  /**
880
  * Filters the value for the last updated time for an activity item.
881
  *
882
+ * @since 1.1.0
883
  *
884
  * @param BP_Activity_Activity $last_updated Date last updated.
885
  */
889
  /**
890
  * Retrieve the number of favorite activity stream items a user has.
891
  *
892
+ * @since 1.2.0
893
  *
894
  * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
895
  *
896
  * @param int $user_id ID of the user whose favorite count is being requested.
 
897
  * @return int Total favorite count for the user.
898
  */
899
  function bp_activity_total_favorites_for_user( $user_id = 0 ) {
900
 
901
+ // Fallback on displayed user, and then logged in user.
902
  if ( empty( $user_id ) ) {
903
  $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
904
  }
911
  /**
912
  * Delete a meta entry from the DB for an activity stream item.
913
  *
914
+ * @since 1.2.0
915
  *
916
  * @global object $wpdb WordPress database access object.
917
  *
923
  * deleted if the meta_value matches this parameter.
924
  * @param bool $delete_all Optional. If true, delete matching metadata entries
925
  * for all objects, ignoring the specified object_id. Otherwise,
926
+ * only delete matching metadata entries for the specified
927
+ * activity item. Default: false.
 
928
  * @return bool True on success, false on failure.
929
  */
930
  function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
931
 
932
+ // Legacy - if no meta_key is passed, delete all for the item.
933
  if ( empty( $meta_key ) ) {
934
  $all_meta = bp_activity_get_meta( $activity_id );
935
  $keys = ! empty( $all_meta ) ? array_keys( $all_meta ) : array();
936
 
937
+ // With no meta_key, ignore $delete_all.
938
  $delete_all = false;
939
  } else {
940
  $keys = array( $meta_key );
954
  /**
955
  * Get metadata for a given activity item.
956
  *
957
+ * @since 1.2.0
958
  *
959
  * @uses apply_filters() To call the 'bp_activity_get_meta' hook.
960
  *
963
  * that meta key will be returned. Otherwise, all metadata for the
964
  * activity item will be fetched.
965
  * @param bool $single Optional. If true, return only the first value of the
966
+ * specified meta_key. This parameter has no effect if meta_key is not
967
+ * specified. Default: true.
 
968
  * @return mixed The meta value(s) being requested.
969
  */
970
  function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true ) {
975
  /**
976
  * Filters the metadata for a specified activity item.
977
  *
978
+ * @since 1.5.0
979
  *
980
  * @param mixed $retval The meta values for the activity item.
981
  * @param int $activity_id ID of the activity item.
988
  /**
989
  * Update a piece of activity meta.
990
  *
991
+ * @since 1.2.0
992
  *
993
  * @param int $activity_id ID of the activity item whose metadata is being updated.
994
  * @param string $meta_key Key of the metadata being updated.
995
  * @param mixed $meta_value Value to be set.
996
  * @param mixed $prev_value Optional. If specified, only update existing metadata entries
997
  * with the specified value. Otherwise, update all entries.
 
998
  * @return bool|int Returns false on failure. On successful update of existing
999
  * metadata, returns true. On successful creation of new metadata,
1000
  * returns the integer ID of the new metadata row.
1010
  /**
1011
  * Add a piece of activity metadata.
1012
  *
1013
+ * @since 2.0.0
1014
  *
1015
  * @param int $activity_id ID of the activity item.
1016
  * @param string $meta_key Metadata key.
1018
  * @param bool $unique Optional. Whether to enforce a single metadata value for the
1019
  * given key. If true, and the object already has a value for
1020
  * the key, no change will be made. Default: false.
 
1021
  * @return int|bool The meta ID on successful update, false on failure.
1022
  */
1023
  function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = false ) {
1033
  /**
1034
  * Completely remove a user's activity data.
1035
  *
1036
+ * @since 1.5.0
1037
  *
1038
  * @uses is_user_logged_in()
1039
  * @uses bp_activity_delete()
1042
  * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook.
1043
  *
1044
  * @param int $user_id ID of the user whose activity is being deleted.
 
1045
  * @return bool
1046
  */
1047
  function bp_activity_remove_all_user_data( $user_id = 0 ) {
1048
 
1049
+ // Do not delete user data unless a logged in user says so.
1050
  if ( empty( $user_id ) || ! is_user_logged_in() ) {
1051
  return false;
1052
  }
1053
 
1054
+ // Clear the user's activity from the sitewide stream and clear their activity tables.
1055
  bp_activity_delete( array( 'user_id' => $user_id ) );
1056
 
1057
+ // Remove any usermeta.
1058
  bp_delete_user_meta( $user_id, 'bp_latest_update' );
1059
  bp_delete_user_meta( $user_id, 'bp_favorite_activities' );
1060
 
1064
  /**
1065
  * Fires after the removal of all of a user's activity data.
1066
  *
1067
+ * @since 1.5.0
1068
  *
1069
  * @param int $user_id ID of the user being deleted.
1070
  */
1076
  /**
1077
  * Mark all of the user's activity as spam.
1078
  *
1079
+ * @since 1.6.0
1080
  *
1081
  * @global object $wpdb WordPress database access object.
1082
  *
1083
  * @param int $user_id ID of the user whose activity is being spammed.
 
1084
  * @return bool
1085
  */
1086
  function bp_activity_spam_all_user_data( $user_id = 0 ) {
1087
  global $wpdb;
1088
 
1089
+ // Do not delete user data unless a logged in user says so.
1090
  if ( empty( $user_id ) || ! is_user_logged_in() ) {
1091
  return false;
1092
  }
1100
 
1101
  $bp = buddypress();
1102
 
1103
+ // Mark each as spam.
1104
  foreach ( (array) $activities['activities'] as $activity ) {
1105
 
1106
+ // Create an activity object.
1107
  $activity_obj = new BP_Activity_Activity;
1108
  foreach ( $activity as $k => $v ) {
1109
  $activity_obj->$k = $v;
1110
  }
1111
 
1112
+ // Mark as spam.
1113
  bp_activity_mark_as_spam( $activity_obj );
1114
 
1115
  /*
1123
  $bp->activity->akismet->update_activity_spam_meta( $activity_obj );
1124
  }
1125
 
1126
+ // Tidy up.
1127
  unset( $activity_obj );
1128
  }
1129
 
1130
+ // Mark all of this user's activities as spam.
1131
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id ) );
1132
 
1133
  /**
1134
  * Fires after all activity data from a user has been marked as spam.
1135
  *
1136
+ * @since 1.6.0
1137
  *
1138
  * @param int $user_id ID of the user whose activity is being marked as spam.
1139
  * @param array $activities Array of activity items being marked as spam.
1145
  /**
1146
  * Mark all of the user's activity as ham (not spam).
1147
  *
1148
+ * @since 1.6.0
1149
  *
1150
  * @global object $wpdb WordPress database access object.
1151
  *
1152
  * @param int $user_id ID of the user whose activity is being hammed.
 
1153
  * @return bool
1154
  */
1155
  function bp_activity_ham_all_user_data( $user_id = 0 ) {
1156
  global $wpdb;
1157
 
1158
+ // Do not delete user data unless a logged in user says so.
1159
  if ( empty( $user_id ) || ! is_user_logged_in() ) {
1160
  return false;
1161
  }
1170
 
1171
  $bp = buddypress();
1172
 
1173
+ // Mark each as not spam.
1174
  foreach ( (array) $activities['activities'] as $activity ) {
1175
 
1176
+ // Create an activity object.
1177
  $activity_obj = new BP_Activity_Activity;
1178
  foreach ( $activity as $k => $v ) {
1179
  $activity_obj->$k = $v;
1180
  }
1181
 
1182
+ // Mark as not spam.
1183
  bp_activity_mark_as_ham( $activity_obj );
1184
 
1185
  /*
1193
  $bp->activity->akismet->update_activity_ham_meta( $activity_obj );
1194
  }
1195
 
1196
+ // Tidy up.
1197
  unset( $activity_obj );
1198
  }
1199
 
1200
+ // Mark all of this user's activities as not spam.
1201
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 0 WHERE user_id = %d", $user_id ) );
1202
 
1203
  /**
1204
  * Fires after all activity data from a user has been marked as ham.
1205
  *
1206
+ * @since 1.6.0
1207
  *
1208
  * @param int $user_id ID of the user whose activity is being marked as ham.
1209
  * @param array $activities Array of activity items being marked as ham.
1215
  /**
1216
  * Register the activity stream actions for updates.
1217
  *
1218
+ * @since 1.6.0
1219
  */
1220
  function bp_activity_register_activity_actions() {
1221
  $bp = buddypress();
1242
  *
1243
  * Allows plugin authors to add their own activity actions alongside the core actions.
1244
  *
1245
+ * @since 1.6.0
1246
  */
1247
  do_action( 'bp_activity_register_activity_actions' );
1248
 
1255
  * Generate an activity action string for an activity item.
1256
  *
1257
  * @param object $activity Activity data object.
 
1258
  * @return string|bool Returns false if no callback is found, otherwise returns
1259
  * the formatted action string.
1260
  */
1261
  function bp_activity_generate_action_string( $activity ) {
1262
 
1263
+ // Check for valid input.
1264
  if ( empty( $activity->component ) || empty( $activity->type ) ) {
1265
  return false;
1266
  }
1267
 
1268
+ // Check for registered format callback.
1269
  $actions = bp_activity_get_actions();
1270
  if ( empty( $actions->{$activity->component}->{$activity->type}['format_callback'] ) ) {
1271
  return false;
1272
  }
1273
 
1274
+ // We apply the format_callback as a filter.
1275
  add_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
1276
 
1277
  /**
1278
  * Filters the string for the activity action being returned.
1279
  *
1280
+ * @since 2.0.0
1281
  *
1282
  * @param BP_Activity_Activity $action Action string being requested.
1283
  * @param BP_Activity_Activity $activity Activity item object.
1284
  */
1285
  $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
1286
 
1287
+ // Remove the filter for future activity items.
1288
  remove_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
1289
 
1290
  return $action;
1293
  /**
1294
  * Format 'activity_update' activity actions.
1295
  *
1296
+ * @since 2.0.0
1297
  *
1298
  * @param string $action Static activity action.
1299
  * @param object $activity Activity data object.
1300
+ * @return string $action
 
1301
  */
1302
  function bp_activity_format_activity_action_activity_update( $action, $activity ) {
1303
  $action = sprintf( __( '%s posted an update', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
1305
  /**
1306
  * Filters the formatted activity action update string.
1307
  *
1308
+ * @since 1.2.0
1309
  *
1310
  * @param string $action Activity action string value.
1311
  * @param BP_Activity_Activity $activity Activity item object.
1316
  /**
1317
  * Format 'activity_comment' activity actions.
1318
  *
1319
+ * @since 2.0.0
1320
  *
1321
  * @param string $action Static activity action.
1322
  * @param object $activity Activity data object.
1323
+ * @return string $action
 
1324
  */
1325
  function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
1326
  $action = sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
1328
  /**
1329
  * Filters the formatted activity action comment string.
1330
  *
1331
+ * @since 1.2.0
1332
  *
1333
  * @param string $action Activity action string value.
1334
  * @param BP_Activity_Activity $activity Activity item object.
1339
  /**
1340
  * Format activity action strings for custom post types.
1341
  *
1342
+ * @since 2.2.0
1343
  *
1344
  * @param string $action Static activity action.
1345
  * @param object $activity Activity data object.
1346
+ * @return string $action
 
1347
  */
1348
  function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) {
1349
  $bp = buddypress();
1385
  /**
1386
  * Filters the formatted custom post type activity post action string.
1387
  *
1388
+ * @since 2.2.0
1389
  *
1390
  * @param string $action Activity action string value.
1391
  * @param BP_Activity_Activity $activity Activity item object.
1393
  return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity );
1394
  }
1395
 
1396
+ /*
1397
  * Business functions are where all the magic happens in BuddyPress. They will
1398
  * handle the actual saving or manipulation of information. Usually they will
1399
  * hand off to a database class for data access, then return
1403
  /**
1404
  * Retrieve an activity or activities.
1405
  *
1406
+ * The bp_activity_get() function shares all arguments with BP_Activity_Activity::get().
1407
+ * The following is a list of bp_activity_get() parameters that have different
1408
  * default values from BP_Activity_Activity::get() (value in parentheses is
1409
  * the default for the bp_activity_get()).
1410
  * - 'per_page' (false)
1411
  *
1412
+ * @since 1.2.0
1413
+ * @since 2.4.0 Introduced the `$fields` parameter.
1414
  *
1415
  * @see BP_Activity_Activity::get() For more information on accepted arguments
1416
  * and the format of the returned value.
1421
  * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
1422
  *
1423
  * @param array|string $args See BP_Activity_Activity::get() for description.
 
1424
  * @return array $activity See BP_Activity_Activity::get() for description.
1425
  */
1426
  function bp_activity_get( $args = '' ) {
1427
 
1428
  $r = bp_parse_args( $args, array(
1429
  'max' => false, // Maximum number of results to return
1430
+ 'fields' => 'all',
1431
  'page' => 1, // page 1 without a per_page will result in no pagination.
1432
  'per_page' => false, // results per page
1433
  'sort' => 'DESC', // sort ASC or DESC
1438
  'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format
1439
  'filter_query' => false,
1440
  'show_hidden' => false, // Show activity items that are hidden site-wide?
1441
+ 'exclude' => false, // Comma-separated list of activity IDs to exclude.
1442
+ 'in' => false, // Comma-separated list or array of activity IDs to which you
1443
+ // want to limit the query.
1444
  'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
1445
  'update_meta_cache' => true,
1446
  'count_total' => false,
1449
  /**
1450
  * Pass filters as an array -- all filter items can be multiple values comma separated:
1451
  * array(
1452
+ * 'user_id' => false, // User ID to filter on.
1453
+ * 'object' => false, // Object to filter on e.g. groups, profile, status, friends.
1454
+ * 'action' => false, // Action to filter on e.g. activity_update, profile_updated.
1455
+ * 'primary_id' => false, // Object ID to filter on e.g. a group_id or forum_id or blog_id etc.
1456
+ * 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id.
1457
  * );
1458
  */
1459
  'filter' => array()
1460
  ) );
1461
 
1462
  // Attempt to return a cached copy of the first page of sitewide activity.
1463
+ if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && ( 'all' === $r['fields'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter_query'] ) && empty( $r['filter'] ) && empty( $r['scope'] )&& empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
1464
 
1465
  $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
1466
  if ( false === $activity ) {
1469
  'page' => $r['page'],
1470
  'per_page' => $r['per_page'],
1471
  'max' => $r['max'],
1472
+ 'fields' => $r['fields'],
1473
  'sort' => $r['sort'],
1474
  'search_terms' => $r['search_terms'],
1475
  'meta_query' => $r['meta_query'],
1511
  /**
1512
  * Filters the requested activity item(s).
1513
  *
1514
+ * @since 1.2.0
1515
  *
1516
  * @param BP_Activity_Activity $activity Requested activity object.
1517
  * @param array $r Arguments used for the activity query.
1522
  /**
1523
  * Fetch specific activity items.
1524
  *
1525
+ * @since 1.2.0
1526
  *
1527
  * @see BP_Activity_Activity::get() For more information on accepted arguments.
1528
  * @uses wp_parse_args()
1533
  * All arguments and defaults are shared with BP_Activity_Activity::get(),
1534
  * except for the following:
1535
  * @type string|int|array Single activity ID, comma-separated list of IDs,
1536
+ * or array of IDs.
1537
  * }
1538
  * @return array $activity See BP_Activity_Activity::get() for description.
1539
  */
1541
 
1542
  $r = bp_parse_args( $args, array(
1543
  'activity_ids' => false, // A single activity_id or array of IDs.
1544
+ 'display_comments' => false, // True or false to display threaded comments for these specific activity items.
1545
+ 'max' => false, // Maximum number of results to return.
1546
+ 'page' => 1, // Page 1 without a per_page will result in no pagination.
1547
+ 'per_page' => false, // Results per page.
1548
+ 'show_hidden' => true, // When fetching specific items, show all.
1549
+ 'sort' => 'DESC', // Sort ASC or DESC
1550
+ 'spam' => 'ham_only', // Retrieve items marked as spam.
1551
  'update_meta_cache' => true,
1552
  ) );
1553
 
1566
  /**
1567
  * Filters the requested specific activity item.
1568
  *
1569
+ * @since 1.2.0
1570
  *
1571
  * @param BP_Activity_Activity $activity Requested activity object.
1572
  * @param array $args Original passed in arguments.
1578
  /**
1579
  * Add an activity item.
1580
  *
1581
+ * @since 1.1.0
1582
  *
1583
  * @uses wp_parse_args()
1584
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
1625
  'id' => false, // Pass an existing activity ID to update an existing entry.
1626
  'action' => '', // The activity action - e.g. "Jon Doe posted an update"
1627
  'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
1628
+ 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent.
1629
+ 'type' => false, // The activity type e.g. activity_update, profile_updated.
1630
+ 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink).
1631
  'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user.
1632
+ 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id.
1633
+ 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id.
1634
+ 'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded.
1635
  'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
1636
  'is_spam' => false, // Is this activity item to be marked as spam?
1637
  ), 'activity_add' );
1638
 
1639
+ // Make sure we are backwards compatible.
1640
  if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
1641
  $r['component'] = $r['component_name'];
1642
  }
1645
  $r['type'] = $r['component_action'];
1646
  }
1647
 
1648
+ // Setup activity to be added.
1649
  $activity = new BP_Activity_Activity( $r['id'] );
1650
  $activity->user_id = $r['user_id'];
1651
  $activity->component = $r['component'];
1665
  return false;
1666
  }
1667
 
1668
+ // If this is an activity comment, rebuild the tree.
1669
  if ( 'activity_comment' === $activity->type ) {
1670
+ // Also clear the comment cache for the parent activity ID.
1671
  wp_cache_delete( $activity->item_id, 'bp_activity_comments' );
1672
 
1673
  BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
1678
  /**
1679
  * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID.
1680
  *
1681
+ * @since 1.1.0
1682
  *
1683
  * @param array $r Array of parsed arguments for the activity item being added.
1684
  */
1690
  /**
1691
  * Post an activity update.
1692
  *
1693
+ * @since 1.2.0
1694
  *
1695
  * @uses wp_parse_args()
1696
  * @uses bp_is_user_inactive()
1724
  return false;
1725
  }
1726
 
1727
+ // Record this on the user's profile.
1728
  $activity_content = $r['content'];
1729
  $primary_link = bp_core_get_userlink( $r['user_id'], false, true );
1730
 
1731
  /**
1732
  * Filters the new activity content for current activity item.
1733
  *
1734
+ * @since 1.2.0
1735
  *
1736
  * @param string $activity_content Activity content posted by user.
1737
  */
1740
  /**
1741
  * Filters the activity primary link for current activity item.
1742
  *
1743
+ * @since 1.2.0
1744
  *
1745
  * @param string $primary_link Link to the profile for the user who posted the activity.
1746
  */
1747
  $add_primary_link = apply_filters( 'bp_activity_new_update_primary_link', $primary_link );
1748
 
1749
+ // Now write the values.
1750
  $activity_id = bp_activity_add( array(
1751
  'user_id' => $r['user_id'],
1752
  'content' => $add_content,
1758
  /**
1759
  * Filters the latest update content for the activity item.
1760
  *
1761
+ * @since 1.6.0
1762
  *
1763
  * @param string $r Content of the activity update.
1764
  * @param string $activity_content Content of the activity update.
1774
  /**
1775
  * Fires at the end of an activity post update, before returning the updated activity item ID.
1776
  *
1777
+ * @since 1.2.0
1778
  *
1779
  * @param string $content Content of the activity post update.
1780
  * @param int $user_id ID of the user posting the activity update.
1788
  /**
1789
  * Create an activity item for a newly published post type post.
1790
  *
1791
+ * @since 2.2.0
 
 
 
 
1792
  *
1793
+ * @param int $post_id ID of the new post.
1794
+ * @param WP_Post $post Post object.
1795
+ * @param int $user_id ID of the post author.
1796
  * @return int|bool The ID of the activity on success. False on error.
1797
  */
1798
  function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0 ) {
1837
  * This is a variable filter, dependent on the post type,
1838
  * that lets components or plugins bail early if needed.
1839
  *
1840
+ * @since 2.2.0
1841
  *
1842
  * @param bool $value Whether or not to continue.
1843
  * @param int $blog_id ID of the current site.
1911
  /**
1912
  * Fires after the publishing of an activity item for a newly published post type post.
1913
  *
1914
+ * @since 2.2.0
1915
  *
1916
  * @param int $activity_id ID of the newly published activity item.
1917
  * @param WP_Post $post Post object.
1925
  /**
1926
  * Update the activity item for a custom post type entry.
1927
  *
1928
+ * @since 2.2.0
1929
  *
1930
+ * @param WP_Post $post Post item.
1931
+ * @return bool True on success, false on failure.
 
1932
  */
1933
  function bp_activity_post_type_update( $post = null ) {
1934
 
1980
  /**
1981
  * Fires after the updating of an activity item for a custom post type entry.
1982
  *
1983
+ * @since 2.2.0
1984
  *
1985
  * @param WP_Post $post Post object.
1986
  * @param BP_Activity_Activity $activity Activity object.
1993
  /**
1994
  * Unpublish an activity for the custom post type.
1995
  *
1996
+ * @since 2.2.0
1997
  *
1998
  * @param int $post_id ID of the post being unpublished.
1999
  * @param WP_Post $post Post object.
2000
+ * @return bool True on success, false on failure.
 
2001
  */
2002
  function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2003
 
2005
  return;
2006
  }
2007
 
2008
+ // Get the post type tracking args.
2009
  $activity_post_object = bp_activity_get_post_type_tracking_args( $post->post_type );
2010
 
2011
  if ( empty( $activity_post_object->action_id ) ) {
2029
  /**
2030
  * Fires after the unpublishing for the custom post type.
2031
  *
2032
+ * @since 2.2.0
2033
  *
2034
  * @param array $delete_activity_args Array of arguments for activity deletion.
2035
  * @param WP_Post $post Post object.
2043
  /**
2044
  * Add an activity comment.
2045
  *
2046
+ * @since 1.2.0
2047
  *
2048
  * @uses wp_parse_args()
2049
  * @uses bp_activity_add()
2078
  'id' => false,
2079
  'content' => false,
2080
  'user_id' => bp_loggedin_user_id(),
2081
+ 'activity_id' => false, // ID of the root activity item.
2082
+ 'parent_id' => false // ID of a parent comment (optional).
2083
  ) );
2084
 
2085
+ // Bail if missing necessary data.
2086
  if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
2087
  $errors->add( 'missing_data', $feedback );
2088
  $bp->activity->errors['new_comment'] = $errors;
2090
  return false;
2091
  }
2092
 
2093
+ // Maybe set current activity ID as the parent.
2094
  if ( empty( $r['parent_id'] ) ) {
2095
  $r['parent_id'] = $r['activity_id'];
2096
  }
2097
 
2098
  $activity_id = $r['activity_id'];
2099
 
2100
+ // Get the parent activity.
2101
  $activity = new BP_Activity_Activity( $activity_id );
2102
 
2103
+ // Bail if the parent activity does not exist.
2104
  if ( empty( $activity->date_recorded ) ) {
2105
  $errors->add( 'missing_activity', __( 'Sorry, the item you are replying to no longer exists.', 'buddypress' ) );
2106
  $bp->activity->errors['new_comment'] = $errors;
2114
  /**
2115
  * Filters the content of a new comment.
2116
  *
2117
+ * @since 1.2.0
2118
  *
2119
  * @param string $r Content for the newly posted comment.
2120
  */
2121
  $comment_content = apply_filters( 'bp_activity_comment_content', $r['content'] );
2122
 
2123
+ // Insert the activity comment.
2124
  $comment_id = bp_activity_add( array(
2125
  'id' => $r['id'],
2126
  'content' => $comment_content,
2132
  'hide_sitewide' => $is_hidden
2133
  ) );
2134
 
2135
+ // Comment caches are stored only with the top-level item.
2136
  wp_cache_delete( $activity_id, 'bp_activity_comments' );
2137
 
2138
+ // Walk the tree to clear caches for all parent items.
2139
  $clear_id = $r['parent_id'];
2140
  while ( $clear_id != $activity_id ) {
2141
  $clear_object = new BP_Activity_Activity( $clear_id );
2147
  /**
2148
  * Fires near the end of an activity comment posting, before the returning of the comment ID.
2149
  *
2150
+ * @since 1.2.0
2151
  *
2152
  * @param int $comment_id ID of the newly posted activity comment.
2153
  * @param array $r Array of parsed comment arguments.
2166
  /**
2167
  * Fetch the activity_id for an existing activity entry in the DB.
2168
  *
2169
+ * @since 1.2.0
2170
  *
2171
  * @see BP_Activity_Activity::get() For more information on accepted arguments.
2172
  * @uses wp_parse_args()
2174
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
2175
  *
2176
  * @param array|string $args See BP_Activity_Activity::get() for description.
 
2177
  * @return int $activity_id The ID of the activity item found.
2178
  */
2179
  function bp_activity_get_activity_id( $args = '' ) {
2192
  /**
2193
  * Filters the activity ID being requested.
2194
  *
2195
+ * @since 1.2.0
2196
  *
2197
  * @param BP_Activity_Activity $value ID returned by BP_Activity_Activity get_id() method with provided arguments.
2198
  */
2221
  *
2222
  * If you are deleting an activity comment please use bp_activity_delete_comment();
2223
  *
2224
+ * @since 1.0.0
2225
  *
2226
  * @see BP_Activity_Activity::get() For more information on accepted arguments.
2227
  * @uses wp_parse_args()
2239
  * filters for item deletion, the argument format is
2240
  * the same as BP_Activity_Activity::get().
2241
  * See that method for a description.
 
2242
  * @return bool True on success, false on failure.
2243
  */
2244
  function bp_activity_delete( $args = '' ) {
2245
 
2246
+ // Pass one or more the of following variables to delete by those variables.
2247
  $args = bp_parse_args( $args, array(
2248
  'id' => false,
2249
  'action' => false,
2261
  /**
2262
  * Fires before an activity item proceeds to be deleted.
2263
  *
2264
+ * @since 1.5.0
2265
  *
2266
  * @param array $args Array of arguments to be used with the activity deletion.
2267
  */
2268
  do_action( 'bp_before_activity_delete', $args );
2269
 
2270
+ // Adjust the new mention count of any mentioned member.
2271
  bp_activity_adjust_mention_count( $args['id'], 'delete' );
2272
 
2273
  $activity_ids_deleted = BP_Activity_Activity::delete( $args );
2275
  return false;
2276
  }
2277
 
2278
+ // Check if the user's latest update has been deleted.
2279
  $user_id = empty( $args['user_id'] )
2280
  ? bp_loggedin_user_id()
2281
  : $args['user_id'];
2290
  /**
2291
  * Fires after the activity item has been deleted.
2292
  *
2293
+ * @since 1.0.0
2294
  *
2295
  * @param array $args Array of arguments used with the activity deletion.
2296
  */
2299
  /**
2300
  * Fires after the activity item has been deleted.
2301
  *
2302
+ * @since 1.2.0
2303
  *
2304
  * @param array $activity_ids_deleted Array of affected activity item IDs.
2305
  */
2315
  *
2316
  * You should use bp_activity_delete() instead.
2317
  *
2318
+ * @since 1.1.0
2319
+ * @deprecated 1.2.0
2320
  *
2321
  * @uses wp_parse_args()
2322
  * @uses bp_activity_delete()
2323
  *
2324
  * @param array|string $args See BP_Activity_Activity::get for a
2325
  * description of accepted arguments.
 
2326
  * @return bool True on success, false on failure.
2327
  */
2328
  function bp_activity_delete_by_item_id( $args = '' ) {
2341
  /**
2342
  * Delete an activity item by activity id.
2343
  *
2344
+ * @since 1.1.0
2345
  *
2346
  * @uses bp_activity_delete()
2347
  *
2348
  * @param int $activity_id ID of the activity item to be deleted.
 
2349
  * @return bool True on success, false on failure.
2350
  */
2351
  function bp_activity_delete_by_activity_id( $activity_id ) {
2357
  *
2358
  * You should use bp_activity_delete() instead.
2359
  *
2360
+ * @since 1.1.0
2361
+ * @deprecated 1.2.0
2362
  *
2363
  * @uses bp_activity_delete()
2364
  *
2366
  * @param string $content The activity id.
2367
  * @param string $component The activity component.
2368
  * @param string $type The activity type.
 
2369
  * @return bool True on success, false on failure.
2370
  */
2371
  function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
2382
  *
2383
  * You should use bp_activity_delete() instead.
2384
  *
2385
+ * @since 1.1.0
2386
+ * @deprecated 1.2.0
2387
  *
2388
  * @uses bp_activity_delete()
2389
  *
2390
  * @param int $user_id The user id.
2391
  * @param string $component The activity component.
 
2392
  * @return bool True on success, false on failure.
2393
  */
2394
  function bp_activity_delete_for_user_by_component( $user_id, $component ) {
2401
  /**
2402
  * Delete an activity comment.
2403
  *
2404
+ * @since 1.2.0
2405
  *
2406
  * @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook.
2407
  * @uses bp_activity_delete_children()
2416
  * @param int $activity_id The ID of the "root" activity, ie the comment's
2417
  * oldest ancestor.
2418
  * @param int $comment_id The ID of the comment to be deleted.
 
2419
  * @return bool True on success, false on failure.
2420
  */
2421
  function bp_activity_delete_comment( $activity_id, $comment_id ) {
2426
  * You may want to hook into this filter if you want to override this function and
2427
  * handle the deletion of child comments differently. Make sure you return false.
2428
  *
2429
+ * @since 1.2.0
2430
  *
2431
  * @param bool $value Whether BuddyPress should continue or not.
2432
  * @param int $activity_id ID of the root activity item being deleted.
2439
  // Delete any children of this comment.
2440
  bp_activity_delete_children( $activity_id, $comment_id );
2441
 
2442
+ // Delete the actual comment.
2443
  if ( ! bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) {
2444
  return false;
2445
  }
2446
 
2447
+ // Purge comment cache for the root activity update.
2448
  wp_cache_delete( $activity_id, 'bp_activity_comments' );
2449
 
2450
+ // Recalculate the comment tree.
2451
  BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
2452
 
2453
  /**
2454
  * Fires at the end of the deletion of an activity comment, before returning success.
2455
  *
2456
+ * @since 1.2.0
2457
  *
2458
  * @param int $activity_id ID of the activity that has had a comment deleted from.
2459
  * @param int $comment_id ID of the comment that was deleted.
2466
  /**
2467
  * Delete an activity comment's children.
2468
  *
2469
+ * @since 1.2.0
2470
  *
2471
  * @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
2472
  * @uses bp_activity_delete_children()
2478
  */
2479
  function bp_activity_delete_children( $activity_id, $comment_id ) {
2480
 
2481
+ // Get activity children to delete.
2482
  $children = BP_Activity_Activity::get_child_comments( $comment_id );
2483
 
2484
  // Recursively delete all children of this comment.
2488
  }
2489
  }
2490
 
2491
+ // Delete the comment itself.
2492
  bp_activity_delete( array(
2493
  'secondary_item_id' => $comment_id,
2494
  'type' => 'activity_comment',
2504
  * be sure to pass the full $activity_obj parameter as well, if you already
2505
  * have it available.
2506
  *
2507
+ * @since 1.2.0
2508
  *
2509
  * @uses bp_get_root_domain()
2510
  * @uses bp_get_activity_root_slug()
2512
  *
2513
  * @param int $activity_id The unique id of the activity object.
2514
  * @param object|bool $activity_obj Optional. The activity object.
 
2515
  * @return string $link Permalink for the activity item.
2516
  */
2517
  function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
2549
  /**
2550
  * Filters the activity permalink for the specified activity item.
2551
  *
2552
+ * @since 1.2.0
2553
  *
2554
  * @param array $array Array holding activity permalink and activity item object.
2555
  */
2559
  /**
2560
  * Hide a user's activity.
2561
  *
2562
+ * @since 1.2.0
2563
  *
2564
  * @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
2565
  *
2566
  * @param int $user_id The ID of the user whose activity is being hidden.
 
2567
  * @return bool True on success, false on failure.
2568
  */
2569
  function bp_activity_hide_user_activity( $user_id ) {
2582
  *
2583
  * As of BuddyPress 2.3, this function is no longer in use.
2584
  *
2585
+ * @since 1.2.0
2586
  *
2587
  * @uses esc_attr()
2588
  * @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook.
2592
  * to. If absent, the image will not be a link.
2593
  * @param array|bool $args Optional. The args passed to the activity
2594
  * creation function (eg bp_blogs_record_activity()).
 
2595
  * @return string $content The content with images stripped and replaced with a
2596
  * single thumb.
2597
  */
2599
 
2600
  preg_match_all( '/<img[^>]*>/Ui', $content, $matches );
2601
 
2602
+ // Remove <img> tags. Also remove caption shortcodes and caption text if present.
2603
  $content = preg_replace('|(\[caption(.*?)\])?<img[^>]*>([^\[\[]*\[\/caption\])?|', '', $content );
2604
 
2605
  if ( !empty( $matches ) && !empty( $matches[0] ) ) {
2606
 
2607
+ // Get the SRC value.
2608
  preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src );
2609
 
2610
+ // Get the width and height.
2611
  preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
2612
  preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
2613
 
2643
  /**
2644
  * Filters the activity content that had a thumbnail replace images.
2645
  *
2646
+ * @since 1.2.0
2647
  *
2648
  * @param string $content Activity content that had images replaced in.
2649
  * @param array $matches Array of all image tags found in the posted content.
2659
  * Currently, it's only used for blog post items, but it will probably be used for all types of
2660
  * activity in the future.
2661
  *
2662
+ * @since 2.3.0
2663
  *
2664
  * @param string $content The content of the activity item.
2665
  * @param array $activity The data passed to bp_activity_add() or the values
2666
  * from an Activity obj.
2667
+ * @return string $summary
 
2668
  */
2669
  function bp_activity_create_summary( $content, $activity ) {
2670
  $args = array(
2681
  *
2682
  * Use this filter to change the media extractor used to extract media info for the activity item.
2683
  *
2684
+ * @since 2.3.0
2685
  *
2686
  * @param string $extractor Class name.
2687
  * @param string $content The content of the activity item.
2693
  /**
2694
  * Filter the arguments passed to the media extractor when creating an Activity summary.
2695
  *
2696
+ * @since 2.3.0
2697
  *
2698
  * @param array $args Array of bespoke data for the media extractor.
2699
  * @param string $content The content of the activity item.
2766
  /**
2767
  * Filter the results of the media extractor when creating an Activity summary.
2768
  *
2769
+ * @since 2.3.0
2770
  *
2771
  * @param array $extracted_media Extracted media item. See {@link BP_Media_Extractor::extract()} for format.
2772
  * @param string $content Content of the activity item.
2803
  /**
2804
  * Filters the newly-generated summary for the activity item.
2805
  *
2806
+ * @since 2.3.0
2807
  *
2808
  * @param string $summary Activity summary HTML.
2809
  * @param string $content Content of the activity item.
2816
  /**
2817
  * Fetch whether the current user is allowed to mark items as spam.
2818
  *
2819
+ * @since 1.6.0
2820
  *
2821
  * @return bool True if user is allowed to mark activity items as spam.
2822
  */
2825
  /**
2826
  * Filters whether the current user should be able to mark items as spam.
2827
  *
2828
+ * @since 1.6.0
2829
  *
2830
  * @param bool $moderate Whether or not the current user has bp_moderate capability.
2831
  */
2835
  /**
2836
  * Mark an activity item as spam.
2837
  *
2838
+ * @since 1.6.0
2839
  *
2840
  * @param BP_Activity_Activity $activity The activity item to be spammed.
2841
  * @param string $source Optional. Default is "by_a_person" (ie, a person has
2847
 
2848
  $activity->is_spam = 1;
2849
 
2850
+ // Clear the activity stream first page cache.
2851
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
2852
 
2853
+ // Clear the activity comment cache for this activity item.
2854
  wp_cache_delete( $activity->id, 'bp_activity_comments' );
2855
 
2856
+ // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity.
2857
  if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
2858
  remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 4, 1 );
2859
 
2860
+ // Build data package for Akismet.
2861
  $activity_data = BP_Akismet::build_akismet_data_package( $activity );
2862
 
2863
+ // Tell Akismet this is spam.
2864
  $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'spam' );
2865
 
2866
+ // Update meta.
2867
  add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_spam_meta' ), 1, 1 );
2868
  }
2869
 
2870
  /**
2871
  * Fires at the end of the process to mark an activity item as spam.
2872
  *
2873
+ * @since 1.6.0
2874
  *
2875
  * @param BP_Activity_Activity $activity Activity item being marked as spam.
2876
  * @param string $source Source of determination of spam status. For example
2882
  /**
2883
  * Mark an activity item as ham.
2884
  *
2885
+ * @since 1.6.0
2886
  *
2887
  * @param BP_Activity_Activity $activity The activity item to be hammed. Passed by reference.
2888
  * @param string $source Optional. Default is "by_a_person" (ie, a person has
2894
 
2895
  $activity->is_spam = 0;
2896
 
2897
+ // Clear the activity stream first page cache.
2898
  wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
2899
 
2900
+ // Clear the activity comment cache for this activity item.
2901
  wp_cache_delete( $activity->id, 'bp_activity_comments' );
2902
 
2903
+ // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity.
2904
  if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
2905
  remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 4, 1 );
2906
 
2907
+ // Build data package for Akismet.
2908
  $activity_data = BP_Akismet::build_akismet_data_package( $activity );
2909
 
2910
+ // Tell Akismet this is spam.
2911
  $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'ham' );
2912
 
2913
+ // Update meta.
2914
  add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_ham_meta' ), 1, 1 );
2915
  }
2916
 
2917
  /**
2918
  * Fires at the end of the process to mark an activity item as ham.
2919
  *
2920
+ * @since 1.6.0
2921
  *
2922
  * @param BP_Activity_Activity $activity Activity item being marked as ham.
2923
  * @param string $source Source of determination of ham status. For example
2939
  * This does not cover recursive activity comments, as they do not use a real loop.
2940
  * For that, see {@link bp_activity_comment_embed()}.
2941
  *
2942
+ * @since 1.5.0
2943
  *
2944
  * @see BP_Embed
2945
  * @see bp_embed_activity_cache()
2964
  * necessary to grab each comment's embeds from the cache, or put them in
2965
  * the cache if they are not there yet.
2966
  *
2967
+ * @since 1.5.0
2968
  *
2969
  * @see BP_Embed
2970
  * @see bp_embed_activity_cache()
2984
  /**
2985
  * When a user clicks on a "Read More" item, make sure embeds are correctly parsed and shown for the expanded content.
2986
  *
2987
+ * @since 1.5.0
2988
  *
2989
  * @see BP_Embed
2990
  * @uses add_filter() To attach create_function() to 'embed_post_id'.
3009
  * This filter must be removed so that the non-comment filters take over again
3010
  * once the comments are done being processed.
3011
  *
3012
+ * @since 1.5.0
3013
  *
3014
  * @see bp_activity_comment_embed()
3015
  * @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id'.
3024
  *
3025
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
3026
  *
3027
+ * @since 1.5.0
3028
  *
3029
  * @see BP_Embed::parse_oembed()
3030
  * @uses bp_activity_get_meta()
3033
  * functions like this one to filter.
3034
  * @param int $id The ID of the activity item.
3035
  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
 
3036
  * @return mixed The cached embeds for this activity item.
3037
  */
3038
  function bp_embed_activity_cache( $cache, $id, $cachekey ) {
3044
  *
3045
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
3046
  *
3047
+ * @since 1.5.0
3048
  *
3049
  * @see BP_Embed::parse_oembed()
3050
  * @uses bp_activity_update_meta()
3053
  * functions like this one to filter.
3054
  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
3055
  * @param int $id The ID of the activity item.
 
 
3056
  */
3057
  function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
3058
  bp_activity_update_meta( $id, $cachekey, $cache );
3061
  /**
3062
  * Should we use Heartbeat to refresh activities?
3063
  *
3064
+ * @since 2.0.0
3065
  *
3066
  * @uses bp_is_activity_heartbeat_active() to check if heartbeat setting is on.
3067
  * @uses bp_is_activity_directory() to check if the current page is the activity
3068
  * directory.
 
3069
  * @uses bp_is_group_activity() to check if on a single group, the current page
3070
  * is the group activities.
 
 
3071
  *
3072
  * @return bool True if activity heartbeat is enabled, otherwise false.
3073
  */
3078
  return $retval;
3079
  }
3080
 
3081
+ if ( bp_is_activity_directory() || bp_is_group_activity() ) {
3082
  $retval = true;
3083
  }
3084
 
 
 
 
 
 
 
 
 
 
3085
  return $retval;
3086
  }
bp-activity/bp-activity-loader.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Activity Streams Loader.
5
  *
@@ -9,20 +8,20 @@
9
  * @subpackage ActivityCore
10
  */
11
 
12
- // Exit if accessed directly
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  /**
16
  * Main Activity Class.
17
  *
18
- * @since BuddyPress (1.5.0)
19
  */
20
  class BP_Activity_Component extends BP_Component {
21
 
22
  /**
23
  * Start the activity component setup process.
24
  *
25
- * @since BuddyPress (1.5.0)
26
  */
27
  public function __construct() {
28
  parent::start(
@@ -30,7 +29,8 @@ class BP_Activity_Component extends BP_Component {
30
  __( 'Activity Streams', 'buddypress' ),
31
  buddypress()->plugin_dir,
32
  array(
33
- 'adminbar_myaccount_order' => 10
 
34
  )
35
  );
36
  }
@@ -38,14 +38,15 @@ class BP_Activity_Component extends BP_Component {
38
  /**
39
  * Include component files.
40
  *
41
- * @since BuddyPress (1.5.0)
42
  *
43
  * @see BP_Component::includes() for a description of arguments.
44
  *
45
  * @param array $includes See BP_Component::includes() for a description.
46
  */
47
  public function includes( $includes = array() ) {
48
- // Files to include
 
49
  $includes = array(
50
  'cssjs',
51
  'actions',
@@ -58,7 +59,7 @@ class BP_Activity_Component extends BP_Component {
58
  'cache'
59
  );
60
 
61
- // Load Akismet support if Akismet is configured
62
  $akismet_key = bp_get_option( 'wordpress_api_key' );
63
 
64
  /** This filter is documented in bp-activity/bp-activity-actions.php */
@@ -79,7 +80,7 @@ class BP_Activity_Component extends BP_Component {
79
  * The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
80
  * backwards compatibility.
81
  *
82
- * @since BuddyPress (1.5.0)
83
  *
84
  * @see BP_Component::setup_globals() for a description of arguments.
85
  *
@@ -88,17 +89,18 @@ class BP_Activity_Component extends BP_Component {
88
  public function setup_globals( $args = array() ) {
89
  $bp = buddypress();
90
 
91
- // Define a slug, if necessary
92
- if ( !defined( 'BP_ACTIVITY_SLUG' ) )
93
  define( 'BP_ACTIVITY_SLUG', $this->id );
 
94
 
95
- // Global tables for activity component
96
  $global_tables = array(
97
  'table_name' => $bp->table_prefix . 'bp_activity',
98
  'table_name_meta' => $bp->table_prefix . 'bp_activity_meta',
99
  );
100
 
101
- // Metadata tables for groups component
102
  $meta_tables = array(
103
  'activity' => $bp->table_prefix . 'bp_activity_meta',
104
  );
@@ -122,7 +124,7 @@ class BP_Activity_Component extends BP_Component {
122
  /**
123
  * Set up component navigation.
124
  *
125
- * @since BuddyPress (1.5.0)
126
  *
127
  * @see BP_Component::setup_nav() for a description of arguments.
128
  * @uses bp_is_active()
@@ -135,21 +137,12 @@ class BP_Activity_Component extends BP_Component {
135
  */
136
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
137
 
138
- // Add 'Activity' to the main navigation
139
- $main_nav = array(
140
- 'name' => _x( 'Activity', 'Profile activity screen nav', 'buddypress' ),
141
- 'slug' => $this->slug,
142
- 'position' => 10,
143
- 'screen_function' => 'bp_activity_screen_my_activity',
144
- 'default_subnav_slug' => 'just-me',
145
- 'item_css_id' => $this->id
146
- );
147
-
148
- // Stop if there is no user displayed or logged in
149
- if ( !is_user_logged_in() && !bp_displayed_user_id() )
150
  return;
 
151
 
152
- // Determine user to use
153
  if ( bp_displayed_user_domain() ) {
154
  $user_domain = bp_displayed_user_domain();
155
  } elseif ( bp_loggedin_user_domain() ) {
@@ -158,65 +151,75 @@ class BP_Activity_Component extends BP_Component {
158
  return;
159
  }
160
 
161
- // User link
162
- $activity_link = trailingslashit( $user_domain . $this->slug );
163
 
164
- // Add the subnav items to the activity nav item if we are using a theme that supports this
 
 
 
 
 
 
 
 
 
 
165
  $sub_nav[] = array(
166
  'name' => _x( 'Personal', 'Profile activity screen sub nav', 'buddypress' ),
167
  'slug' => 'just-me',
168
  'parent_url' => $activity_link,
169
- 'parent_slug' => $this->slug,
170
  'screen_function' => 'bp_activity_screen_my_activity',
171
  'position' => 10
172
  );
173
 
174
- // @ mentions
175
  if ( bp_activity_do_mentions() ) {
176
  $sub_nav[] = array(
177
  'name' => _x( 'Mentions', 'Profile activity screen sub nav', 'buddypress' ),
178
  'slug' => 'mentions',
179
  'parent_url' => $activity_link,
180
- 'parent_slug' => $this->slug,
181
  'screen_function' => 'bp_activity_screen_mentions',
182
  'position' => 20,
183
  'item_css_id' => 'activity-mentions'
184
  );
185
  }
186
 
187
- // Favorite activity items
188
  if ( bp_activity_can_favorite() ) {
189
  $sub_nav[] = array(
190
  'name' => _x( 'Favorites', 'Profile activity screen sub nav', 'buddypress' ),
191
  'slug' => 'favorites',
192
  'parent_url' => $activity_link,
193
- 'parent_slug' => $this->slug,
194
  'screen_function' => 'bp_activity_screen_favorites',
195
  'position' => 30,
196
  'item_css_id' => 'activity-favs'
197
  );
198
  }
199
 
200
- // Additional menu if friends is active
201
  if ( bp_is_active( 'friends' ) ) {
202
  $sub_nav[] = array(
203
  'name' => _x( 'Friends', 'Profile activity screen sub nav', 'buddypress' ),
204
  'slug' => bp_get_friends_slug(),
205
  'parent_url' => $activity_link,
206
- 'parent_slug' => $this->slug,
207
  'screen_function' => 'bp_activity_screen_friends',
208
  'position' => 40,
209
  'item_css_id' => 'activity-friends'
210
  ) ;
211
  }
212
 
213
- // Additional menu if groups is active
214
  if ( bp_is_active( 'groups' ) ) {
215
  $sub_nav[] = array(
216
  'name' => _x( 'Groups', 'Profile activity screen sub nav', 'buddypress' ),
217
  'slug' => bp_get_groups_slug(),
218
  'parent_url' => $activity_link,
219
- 'parent_slug' => $this->slug,
220
  'screen_function' => 'bp_activity_screen_groups',
221
  'position' => 50,
222
  'item_css_id' => 'activity-groups'
@@ -229,7 +232,7 @@ class BP_Activity_Component extends BP_Component {
229
  /**
230
  * Set up the component entries in the WordPress Admin Bar.
231
  *
232
- * @since BuddyPress (1.5.0)
233
  *
234
  * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
235
  * parameter array.
@@ -245,42 +248,40 @@ class BP_Activity_Component extends BP_Component {
245
  * description.
246
  */
247
  public function setup_admin_bar( $wp_admin_nav = array() ) {
248
- $bp = buddypress();
249
 
250
- // Menus for logged in user
251
  if ( is_user_logged_in() ) {
252
 
253
- // Setup the logged in user variables
254
- $user_domain = bp_loggedin_user_domain();
255
- $activity_link = trailingslashit( $user_domain . $this->slug );
256
 
257
- // Unread message count
258
  if ( bp_activity_do_mentions() ) {
259
  $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
260
  if ( !empty( $count ) ) {
261
- $title = sprintf( _x( 'Mentions <span class="count">%s</span>', 'Toolbar Mention logged in user', 'buddypress' ), number_format_i18n( $count ) );
262
  } else {
263
  $title = _x( 'Mentions', 'Toolbar Mention logged in user', 'buddypress' );
264
  }
265
  }
266
 
267
- // Add the "Activity" sub menu
268
  $wp_admin_nav[] = array(
269
- 'parent' => $bp->my_account_menu_id,
270
  'id' => 'my-account-' . $this->id,
271
  'title' => _x( 'Activity', 'My Account Activity sub nav', 'buddypress' ),
272
- 'href' => trailingslashit( $activity_link )
273
  );
274
 
275
- // Personal
276
  $wp_admin_nav[] = array(
277
  'parent' => 'my-account-' . $this->id,
278
  'id' => 'my-account-' . $this->id . '-personal',
279
  'title' => _x( 'Personal', 'My Account Activity sub nav', 'buddypress' ),
280
- 'href' => trailingslashit( $activity_link )
281
  );
282
 
283
- // Mentions
284
  if ( bp_activity_do_mentions() ) {
285
  $wp_admin_nav[] = array(
286
  'parent' => 'my-account-' . $this->id,
@@ -290,8 +291,7 @@ class BP_Activity_Component extends BP_Component {
290
  );
291
  }
292
 
293
- // Favorites
294
- // Favorite activity items
295
  if ( bp_activity_can_favorite() ) {
296
  $wp_admin_nav[] = array(
297
  'parent' => 'my-account-' . $this->id,
@@ -328,17 +328,18 @@ class BP_Activity_Component extends BP_Component {
328
  /**
329
  * Set up the title for pages and <title>.
330
  *
331
- * @since BuddyPress (1.5.0)
332
  *
333
  * @uses bp_is_activity_component()
334
  * @uses bp_is_my_profile()
335
  * @uses bp_core_fetch_avatar()
336
  */
337
  public function setup_title() {
338
- $bp = buddypress();
339
 
340
- // Adjust title based on view
341
  if ( bp_is_activity_component() ) {
 
 
342
  if ( bp_is_my_profile() ) {
343
  $bp->bp_options_title = _x( 'My Activity', 'Page and <title>', 'buddypress' );
344
  } else {
@@ -357,10 +358,11 @@ class BP_Activity_Component extends BP_Component {
357
  /**
358
  * Set up actions necessary for the component.
359
  *
360
- * @since BuddyPress (1.6.0)
361
  */
362
  public function setup_actions() {
363
- // Spam prevention
 
364
  add_action( 'bp_include', 'bp_activity_setup_akismet' );
365
 
366
  parent::setup_actions();
@@ -369,11 +371,11 @@ class BP_Activity_Component extends BP_Component {
369
  /**
370
  * Setup cache groups.
371
  *
372
- * @since BuddyPress (2.2.0)
373
  */
374
  public function setup_cache_groups() {
375
 
376
- // Global groups
377
  wp_cache_add_global_groups( array(
378
  'bp_activity',
379
  'bp_activity_comments',
1
  <?php
 
2
  /**
3
  * BuddyPress Activity Streams Loader.
4
  *
8
  * @subpackage ActivityCore
9
  */
10
 
11
+ // Exit if accessed directly.
12
  defined( 'ABSPATH' ) || exit;
13
 
14
  /**
15
  * Main Activity Class.
16
  *
17
+ * @since 1.5.0
18
  */
19
  class BP_Activity_Component extends BP_Component {
20
 
21
  /**
22
  * Start the activity component setup process.
23
  *
24
+ * @since 1.5.0
25
  */
26
  public function __construct() {
27
  parent::start(
29
  __( 'Activity Streams', 'buddypress' ),
30
  buddypress()->plugin_dir,
31
  array(
32
+ 'adminbar_myaccount_order' => 10,
33
+ 'search_query_arg' => 'activity_search',
34
  )
35
  );
36
  }
38
  /**
39
  * Include component files.
40
  *
41
+ * @since 1.5.0
42
  *
43
  * @see BP_Component::includes() for a description of arguments.
44
  *
45
  * @param array $includes See BP_Component::includes() for a description.
46
  */
47
  public function includes( $includes = array() ) {
48
+
49
+ // Files to include.
50
  $includes = array(
51
  'cssjs',
52
  'actions',
59
  'cache'
60
  );
61
 
62
+ // Load Akismet support if Akismet is configured.
63
  $akismet_key = bp_get_option( 'wordpress_api_key' );
64
 
65
  /** This filter is documented in bp-activity/bp-activity-actions.php */
80
  * The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
81
  * backwards compatibility.
82
  *
83
+ * @since 1.5.0
84
  *
85
  * @see BP_Component::setup_globals() for a description of arguments.
86
  *
89
  public function setup_globals( $args = array() ) {
90
  $bp = buddypress();
91
 
92
+ // Define a slug, if necessary.
93
+ if ( ! defined( 'BP_ACTIVITY_SLUG' ) ) {
94
  define( 'BP_ACTIVITY_SLUG', $this->id );
95
+ }
96
 
97
+ // Global tables for activity component.
98
  $global_tables = array(
99
  'table_name' => $bp->table_prefix . 'bp_activity',
100
  'table_name_meta' => $bp->table_prefix . 'bp_activity_meta',
101
  );
102
 
103
+ // Metadata tables for groups component.
104
  $meta_tables = array(
105
  'activity' => $bp->table_prefix . 'bp_activity_meta',
106
  );
124
  /**
125
  * Set up component navigation.
126
  *
127
+ * @since 1.5.0
128
  *
129
  * @see BP_Component::setup_nav() for a description of arguments.
130
  * @uses bp_is_active()
137
  */
138
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
139
 
140
+ // Stop if there is no user displayed or logged in.
141
+ if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) {
 
 
 
 
 
 
 
 
 
 
142
  return;
143
+ }
144
 
145
+ // Determine user to use.
146
  if ( bp_displayed_user_domain() ) {
147
  $user_domain = bp_displayed_user_domain();
148
  } elseif ( bp_loggedin_user_domain() ) {
151
  return;
152
  }
153
 
154
+ $slug = bp_get_activity_slug();
155
+ $activity_link = trailingslashit( $user_domain . $slug );
156
 
157
+ // Add 'Activity' to the main navigation.
158
+ $main_nav = array(
159
+ 'name' => _x( 'Activity', 'Profile activity screen nav', 'buddypress' ),
160
+ 'slug' => $slug,
161
+ 'position' => 10,
162
+ 'screen_function' => 'bp_activity_screen_my_activity',
163
+ 'default_subnav_slug' => 'just-me',
164
+ 'item_css_id' => $this->id
165
+ );
166
+
167
+ // Add the subnav items to the activity nav item if we are using a theme that supports this.
168
  $sub_nav[] = array(
169
  'name' => _x( 'Personal', 'Profile activity screen sub nav', 'buddypress' ),
170
  'slug' => 'just-me',
171
  'parent_url' => $activity_link,
172
+ 'parent_slug' => $slug,
173
  'screen_function' => 'bp_activity_screen_my_activity',
174
  'position' => 10
175
  );
176
 
177
+ // Check @mentions.
178
  if ( bp_activity_do_mentions() ) {
179
  $sub_nav[] = array(
180
  'name' => _x( 'Mentions', 'Profile activity screen sub nav', 'buddypress' ),
181
  'slug' => 'mentions',
182
  'parent_url' => $activity_link,
183
+ 'parent_slug' => $slug,
184
  'screen_function' => 'bp_activity_screen_mentions',
185
  'position' => 20,
186
  'item_css_id' => 'activity-mentions'
187
  );
188
  }
189
 
190
+ // Favorite activity items.
191
  if ( bp_activity_can_favorite() ) {
192
  $sub_nav[] = array(
193
  'name' => _x( 'Favorites', 'Profile activity screen sub nav', 'buddypress' ),
194
  'slug' => 'favorites',
195
  'parent_url' => $activity_link,
196
+ 'parent_slug' => $slug,
197
  'screen_function' => 'bp_activity_screen_favorites',
198
  'position' => 30,
199
  'item_css_id' => 'activity-favs'
200
  );
201
  }
202
 
203
+ // Additional menu if friends is active.
204
  if ( bp_is_active( 'friends' ) ) {
205
  $sub_nav[] = array(
206
  'name' => _x( 'Friends', 'Profile activity screen sub nav', 'buddypress' ),
207
  'slug' => bp_get_friends_slug(),
208
  'parent_url' => $activity_link,
209
+ 'parent_slug' => $slug,
210
  'screen_function' => 'bp_activity_screen_friends',
211
  'position' => 40,
212
  'item_css_id' => 'activity-friends'
213
  ) ;
214
  }
215
 
216
+ // Additional menu if groups is active.
217
  if ( bp_is_active( 'groups' ) ) {
218
  $sub_nav[] = array(
219
  'name' => _x( 'Groups', 'Profile activity screen sub nav', 'buddypress' ),
220
  'slug' => bp_get_groups_slug(),
221
  'parent_url' => $activity_link,
222
+ 'parent_slug' => $slug,
223
  'screen_function' => 'bp_activity_screen_groups',
224
  'position' => 50,
225
  'item_css_id' => 'activity-groups'
232
  /**
233
  * Set up the component entries in the WordPress Admin Bar.
234
  *
235
+ * @since 1.5.0
236
  *
237
  * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
238
  * parameter array.
248
  * description.
249
  */
250
  public function setup_admin_bar( $wp_admin_nav = array() ) {
 
251
 
252
+ // Menus for logged in user.
253
  if ( is_user_logged_in() ) {
254
 
255
+ // Setup the logged in user variables.
256
+ $activity_link = trailingslashit( bp_loggedin_user_domain() . bp_get_activity_slug() );
 
257
 
258
+ // Unread message count.
259
  if ( bp_activity_do_mentions() ) {
260
  $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
261
  if ( !empty( $count ) ) {
262
+ $title = sprintf( _x( 'Mentions <span class="count">%s</span>', 'Toolbar Mention logged in user', 'buddypress' ), bp_core_number_format( $count ) );
263
  } else {
264
  $title = _x( 'Mentions', 'Toolbar Mention logged in user', 'buddypress' );
265
  }
266
  }
267
 
268
+ // Add the "Activity" sub menu.
269
  $wp_admin_nav[] = array(
270
+ 'parent' => buddypress()->my_account_menu_id,
271
  'id' => 'my-account-' . $this->id,
272
  'title' => _x( 'Activity', 'My Account Activity sub nav', 'buddypress' ),
273
+ 'href' => $activity_link
274
  );
275
 
276
+ // Personal.
277
  $wp_admin_nav[] = array(
278
  'parent' => 'my-account-' . $this->id,
279
  'id' => 'my-account-' . $this->id . '-personal',
280
  'title' => _x( 'Personal', 'My Account Activity sub nav', 'buddypress' ),
281
+ 'href' => $activity_link
282
  );
283
 
284
+ // Mentions.
285
  if ( bp_activity_do_mentions() ) {
286
  $wp_admin_nav[] = array(
287
  'parent' => 'my-account-' . $this->id,
291
  );
292
  }
293
 
294
+ // Favorite activity items.
 
295
  if ( bp_activity_can_favorite() ) {
296
  $wp_admin_nav[] = array(
297
  'parent' => 'my-account-' . $this->id,
328
  /**
329
  * Set up the title for pages and <title>.
330
  *
331
+ * @since 1.5.0
332
  *
333
  * @uses bp_is_activity_component()
334
  * @uses bp_is_my_profile()
335
  * @uses bp_core_fetch_avatar()
336
  */
337
  public function setup_title() {
 
338
 
339
+ // Adjust title based on view.
340
  if ( bp_is_activity_component() ) {
341
+ $bp = buddypress();
342
+
343
  if ( bp_is_my_profile() ) {
344
  $bp->bp_options_title = _x( 'My Activity', 'Page and <title>', 'buddypress' );
345
  } else {
358
  /**
359
  * Set up actions necessary for the component.
360
  *
361
+ * @since 1.6.0
362
  */
363
  public function setup_actions() {
364
+
365
+ // Spam prevention.
366
  add_action( 'bp_include', 'bp_activity_setup_akismet' );
367
 
368
  parent::setup_actions();
371
  /**
372
  * Setup cache groups.
373
  *
374
+ * @since 2.2.0
375
  */
376
  public function setup_cache_groups() {
377
 
378
+ // Global groups.
379
  wp_cache_add_global_groups( array(
380
  'bp_activity',
381
  'bp_activity_comments',
bp-activity/bp-activity-notifications.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Activity Notifications.
5
  *
@@ -7,7 +6,7 @@
7
  * @subpackage ActivityNotifications
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /* Emails *********************************************************************/
@@ -15,7 +14,7 @@ defined( 'ABSPATH' ) || exit;
15
  /**
16
  * Send email and BP notifications when a user is mentioned in an update.
17
  *
18
- * @since BuddyPress (1.2.0)
19
  *
20
  * @uses bp_notifications_add_notification()
21
  * @uses bp_get_user_meta()
@@ -41,7 +40,7 @@ defined( 'ABSPATH' ) || exit;
41
  */
42
  function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
43
 
44
- // Don't leave multiple notifications for the same activity item
45
  $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' );
46
 
47
  foreach( $notifications as $notification ) {
@@ -56,7 +55,7 @@ function bp_activity_at_message_notification( $activity_id, $receiver_user_id )
56
  $message = '';
57
  $content = '';
58
 
59
- // Now email the user with the contents of the message (if they have enabled email notifications)
60
  if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
61
  $poster_name = bp_core_get_user_displayname( $activity->user_id );
62
 
@@ -67,7 +66,7 @@ function bp_activity_at_message_notification( $activity_id, $receiver_user_id )
67
  $poster_name = stripslashes( $poster_name );
68
  $content = bp_activity_filter_kses( strip_tags( stripslashes( $activity->content ) ) );
69
 
70
- // Set up and send the message
71
  $ud = bp_core_get_core_userdata( $receiver_user_id );
72
  $to = $ud->user_email;
73
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ) ) );
@@ -94,7 +93,7 @@ To view and respond to the message, log in and visit: %3$s
94
  ', 'buddypress' ), $poster_name, $content, $message_link );
95
  }
96
 
97
- // Only show the disable notifications line if the settings component is enabled
98
  if ( bp_is_active( 'settings' ) ) {
99
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
100
  }
@@ -102,7 +101,7 @@ To view and respond to the message, log in and visit: %3$s
102
  /**
103
  * Filters the user email that the @mention notification will be sent to.
104
  *
105
- * @since BuddyPress (1.2.0)
106
  *
107
  * @param string $to User email the notification is being sent to.
108
  */
@@ -111,7 +110,7 @@ To view and respond to the message, log in and visit: %3$s
111
  /**
112
  * Filters the @mention notification subject that will be sent to user.
113
  *
114
- * @since BuddyPress (1.2.0)
115
  *
116
  * @param string $subject Email notification subject text.
117
  * @param string $poster_name Name of the person who made the @mention.
@@ -121,7 +120,7 @@ To view and respond to the message, log in and visit: %3$s
121
  /**
122
  * Filters the @mention notification message that will be sent to user.
123
  *
124
- * @since BuddyPress (1.2.0)
125
  *
126
  * @param string $message Email notification message text.
127
  * @param string $poster_name Name of the person who made the @mention.
@@ -137,7 +136,7 @@ To view and respond to the message, log in and visit: %3$s
137
  /**
138
  * Fires after the sending of an @mention email notification.
139
  *
140
- * @since BuddyPress (1.5.0)
141
  *
142
  * @param BP_Activity_Activity $activity Activity Item object.
143
  * @param string $subject Email notification subject text.
@@ -151,7 +150,7 @@ To view and respond to the message, log in and visit: %3$s
151
  /**
152
  * Send email and BP notifications when an activity item receives a comment.
153
  *
154
- * @since BuddyPress (1.2.0)
155
  *
156
  * @uses bp_get_user_meta()
157
  * @uses bp_core_get_user_displayname()
@@ -175,13 +174,12 @@ To view and respond to the message, log in and visit: %3$s
175
  *
176
  * @param int $comment_id The comment id.
177
  * @param int $commenter_id The ID of the user who posted the comment.
178
- * @param array $params {@link bp_activity_new_comment()}
179
- *
180
  * @return bool
181
  */
182
  function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
183
 
184
- // Set some default parameters
185
  $activity_id = 0;
186
  $parent_id = 0;
187
 
@@ -198,7 +196,7 @@ function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id =
198
  $poster_name = stripslashes( $poster_name );
199
  $content = bp_activity_filter_kses( stripslashes($content) );
200
 
201
- // Set up and send the message
202
  $ud = bp_core_get_core_userdata( $original_activity->user_id );
203
  $to = $ud->user_email;
204
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name ) ) );
@@ -212,7 +210,7 @@ To view your original update and all comments, log in and visit: %3$s
212
  ---------------------
213
  ', 'buddypress' ), $poster_name, $content, $thread_link );
214
 
215
- // Only show the disable notifications line if the settings component is enabled
216
  if ( bp_is_active( 'settings' ) ) {
217
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
218
  }
@@ -220,7 +218,7 @@ To view your original update and all comments, log in and visit: %3$s
220
  /**
221
  * Filters the user email that the new comment notification will be sent to.
222
  *
223
- * @since BuddyPress (1.2.0)
224
  *
225
  * @param string $to User email the notification is being sent to.
226
  */
@@ -229,7 +227,7 @@ To view your original update and all comments, log in and visit: %3$s
229
  /**
230
  * Filters the new comment notification subject that will be sent to user.
231
  *
232
- * @since BuddyPress (1.2.0)
233
  *
234
  * @param string $subject Email notification subject text.
235
  * @param string $poster_name Name of the person who made the comment.
@@ -239,7 +237,7 @@ To view your original update and all comments, log in and visit: %3$s
239
  /**
240
  * Filters the new comment notification message that will be sent to user.
241
  *
242
- * @since BuddyPress (1.2.0)
243
  *
244
  * @param string $message Email notification message text.
245
  * @param string $poster_name Name of the person who made the comment.
@@ -254,7 +252,7 @@ To view your original update and all comments, log in and visit: %3$s
254
  /**
255
  * Fires after the sending of a reply to an update email notification.
256
  *
257
- * @since BuddyPress (1.5.0)
258
  *
259
  * @param int $user_id ID of the original activity item author.
260
  * @param string $subject Email notification subject text.
@@ -266,7 +264,7 @@ To view your original update and all comments, log in and visit: %3$s
266
  do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
267
  }
268
 
269
- /***
270
  * If this is a reply to another comment, send an email notification to the
271
  * author of the immediate parent comment.
272
  */
@@ -282,7 +280,7 @@ To view your original update and all comments, log in and visit: %3$s
282
  $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
283
  $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/';
284
 
285
- // Set up and send the message
286
  $ud = bp_core_get_core_userdata( $parent_comment->user_id );
287
  $to = $ud->user_email;
288
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name ) ) );
@@ -300,7 +298,7 @@ To view the original activity, your comment and all replies, log in and visit: %
300
  ---------------------
301
  ', 'buddypress' ), $poster_name, $content, $thread_link );
302
 
303
- // Only show the disable notifications line if the settings component is enabled
304
  if ( bp_is_active( 'settings' ) ) {
305
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
306
  }
@@ -308,7 +306,7 @@ To view the original activity, your comment and all replies, log in and visit: %
308
  /**
309
  * Filters the user email that the new comment reply notification will be sent to.
310
  *
311
- * @since BuddyPress (1.2.0)
312
  *
313
  * @param string $to User email the notification is being sent to.
314
  */
@@ -317,7 +315,7 @@ To view the original activity, your comment and all replies, log in and visit: %
317
  /**
318
  * Filters the new comment reply notification subject that will be sent to user.
319
  *
320
- * @since BuddyPress (1.2.0)
321
  *
322
  * @param string $subject Email notification subject text.
323
  * @param string $poster_name Name of the person who made the comment reply.
@@ -327,7 +325,7 @@ To view the original activity, your comment and all replies, log in and visit: %
327
  /**
328
  * Filters the new comment reply notification message that will be sent to user.
329
  *
330
- * @since BuddyPress (1.2.0)
331
  *
332
  * @param string $message Email notification message text.
333
  * @param string $poster_name Name of the person who made the comment reply.
@@ -342,7 +340,7 @@ To view the original activity, your comment and all replies, log in and visit: %
342
  /**
343
  * Fires after the sending of a reply to a reply email notification.
344
  *
345
- * @since BuddyPress (1.5.0)
346
  *
347
  * @param int $user_id ID of the parent activity item author.
348
  * @param string $subject Email notification subject text.
@@ -358,10 +356,10 @@ To view the original activity, your comment and all replies, log in and visit: %
358
  /**
359
  * Helper method to map action arguments to function parameters.
360
  *
361
- * @since BuddyPress (1.9.0)
362
  *
363
- * @param int $comment_id
364
- * @param array $params
365
  */
366
  function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
367
  bp_activity_new_comment_notification( $comment_id, $params['user_id'], $params );
@@ -373,7 +371,7 @@ add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_
373
  /**
374
  * Format notifications related to activity.
375
  *
376
- * @since BuddyPress (1.5.0)
377
  *
378
  * @uses bp_loggedin_user_domain()
379
  * @uses bp_get_activity_slug()
@@ -387,7 +385,6 @@ add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_
387
  * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
388
  * @param int $total_items The total number of notifications to format.
389
  * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
390
- *
391
  * @return string $return Formatted @mention notification.
392
  */
393
  function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
@@ -419,7 +416,7 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
419
  * need notified about. The two possible hooks are bp_activity_single_at_mentions_notification
420
  * or bp_activity_multiple_at_mentions_notification.
421
  *
422
- * @since BuddyPress (1.5.0)
423
  *
424
  * @param string $string HTML anchor tag for the mention.
425
  * @param string $at_mention_link The permalink for the mention.
@@ -437,7 +434,7 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
437
  * The two possible hooks are bp_activity_single_at_mentions_notification
438
  * or bp_activity_multiple_at_mentions_notification.
439
  *
440
- * @since BuddyPress (1.5.0)
441
  *
442
  * @param array $array Array holding the content and permalink for the mention notification.
443
  * @param string $at_mention_link The permalink for the mention.
@@ -454,7 +451,7 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
454
  /**
455
  * Fires right before returning the formatted activity notifications.
456
  *
457
- * @since BuddyPress (1.2.0)
458
  *
459
  * @param string $action The type of activity item.
460
  * @param int $item_id The activity ID.
@@ -474,13 +471,13 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
474
  * future when we separate emails from Notifications, this will need its own
475
  * 'bp_activity_at_name_send_emails' equivalent helper function.
476
  *
477
- * @since BuddyPress (1.9.0)
478
  *
479
- * @param object $activity
480
- * @param string $subject (not used)
481
- * @param string $message (not used)
482
- * @param string $content (not used)
483
- * @param int $receiver_user_id
484
  */
485
  function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
486
  if ( bp_is_active( 'notifications' ) ) {
@@ -500,7 +497,7 @@ add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notifi
500
  /**
501
  * Mark at-mention notifications as read when users visit their Mentions page.
502
  *
503
- * @since BuddyPress (1.5.0)
504
  *
505
  * @uses bp_notifications_mark_all_notifications_by_type()
506
  */
@@ -509,7 +506,7 @@ function bp_activity_remove_screen_notifications() {
509
  return;
510
  }
511
 
512
- // Only mark read if you're looking at your own mentions
513
  if ( ! bp_is_my_profile() ) {
514
  return;
515
  }
@@ -521,9 +518,9 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notificati
521
  /**
522
  * Mark at-mention notification as read when user visits the activity with the mention.
523
  *
524
- * @since BuddyPress (2.0.0)
525
  *
526
- * @param object BP_Activity_Activity
527
  */
528
  function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
529
  if ( ! bp_is_active( 'notifications' ) ) {
@@ -534,8 +531,7 @@ function bp_activity_remove_screen_notifications_single_activity_permalink( $act
534
  return;
535
  }
536
 
537
- // Mark as read any notifications for the current user related to this
538
- // activity item
539
  bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
540
  }
541
  add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
@@ -543,13 +539,13 @@ add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_
543
  /**
544
  * Delete at-mention notifications when the corresponding activity item is deleted.
545
  *
546
- * @since BuddyPress (2.0.0)
547
  *
548
  * @param array $activity_ids_deleted IDs of deleted activity items.
549
  */
550
  function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) {
551
  // Let's delete all without checking if content contains any mentions
552
- // to avoid a query to get the activity
553
  if ( bp_is_active( 'notifications' ) && ! empty( $activity_ids_deleted ) ) {
554
  foreach ( $activity_ids_deleted as $activity_id ) {
555
  bp_notifications_delete_all_notifications_by_type( $activity_id, buddypress()->activity->id );
1
  <?php
 
2
  /**
3
  * BuddyPress Activity Notifications.
4
  *
6
  * @subpackage ActivityNotifications
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /* Emails *********************************************************************/
14
  /**
15
  * Send email and BP notifications when a user is mentioned in an update.
16
  *
17
+ * @since 1.2.0
18
  *
19
  * @uses bp_notifications_add_notification()
20
  * @uses bp_get_user_meta()
40
  */
41
  function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
42
 
43
+ // Don't leave multiple notifications for the same activity item.
44
  $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' );
45
 
46
  foreach( $notifications as $notification ) {
55
  $message = '';
56
  $content = '';
57
 
58
+ // Now email the user with the contents of the message (if they have enabled email notifications).
59
  if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
60
  $poster_name = bp_core_get_user_displayname( $activity->user_id );
61
 
66
  $poster_name = stripslashes( $poster_name );
67
  $content = bp_activity_filter_kses( strip_tags( stripslashes( $activity->content ) ) );
68
 
69
+ // Set up and send the message.
70
  $ud = bp_core_get_core_userdata( $receiver_user_id );
71
  $to = $ud->user_email;
72
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ) ) );
93
  ', 'buddypress' ), $poster_name, $content, $message_link );
94
  }
95
 
96
+ // Only show the disable notifications line if the settings component is enabled.
97
  if ( bp_is_active( 'settings' ) ) {
98
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
99
  }
101
  /**
102
  * Filters the user email that the @mention notification will be sent to.
103
  *
104
+ * @since 1.2.0
105
  *
106
  * @param string $to User email the notification is being sent to.
107
  */
110
  /**
111
  * Filters the @mention notification subject that will be sent to user.
112
  *
113
+ * @since 1.2.0
114
  *
115
  * @param string $subject Email notification subject text.
116
  * @param string $poster_name Name of the person who made the @mention.
120
  /**
121
  * Filters the @mention notification message that will be sent to user.
122
  *
123
+ * @since 1.2.0
124
  *
125
  * @param string $message Email notification message text.
126
  * @param string $poster_name Name of the person who made the @mention.
136
  /**
137
  * Fires after the sending of an @mention email notification.
138
  *
139
+ * @since 1.5.0
140
  *
141
  * @param BP_Activity_Activity $activity Activity Item object.
142
  * @param string $subject Email notification subject text.
150
  /**
151
  * Send email and BP notifications when an activity item receives a comment.
152
  *
153
+ * @since 1.2.0
154
  *
155
  * @uses bp_get_user_meta()
156
  * @uses bp_core_get_user_displayname()
174
  *
175
  * @param int $comment_id The comment id.
176
  * @param int $commenter_id The ID of the user who posted the comment.
177
+ * @param array $params {@link bp_activity_new_comment()}.
 
178
  * @return bool
179
  */
180
  function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
181
 
182
+ // Set some default parameters.
183
  $activity_id = 0;
184
  $parent_id = 0;
185
 
196
  $poster_name = stripslashes( $poster_name );
197
  $content = bp_activity_filter_kses( stripslashes($content) );
198
 
199
+ // Set up and send the message.
200
  $ud = bp_core_get_core_userdata( $original_activity->user_id );
201
  $to = $ud->user_email;
202
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name ) ) );
210
  ---------------------
211
  ', 'buddypress' ), $poster_name, $content, $thread_link );
212
 
213
+ // Only show the disable notifications line if the settings component is enabled.
214
  if ( bp_is_active( 'settings' ) ) {
215
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
216
  }
218
  /**
219
  * Filters the user email that the new comment notification will be sent to.
220
  *
221
+ * @since 1.2.0
222
  *
223
  * @param string $to User email the notification is being sent to.
224
  */
227
  /**
228
  * Filters the new comment notification subject that will be sent to user.
229
  *
230
+ * @since 1.2.0
231
  *
232
  * @param string $subject Email notification subject text.
233
  * @param string $poster_name Name of the person who made the comment.
237
  /**
238
  * Filters the new comment notification message that will be sent to user.
239
  *
240
+ * @since 1.2.0
241
  *
242
  * @param string $message Email notification message text.
243
  * @param string $poster_name Name of the person who made the comment.
252
  /**
253
  * Fires after the sending of a reply to an update email notification.
254
  *
255
+ * @since 1.5.0
256
  *
257
  * @param int $user_id ID of the original activity item author.
258
  * @param string $subject Email notification subject text.
264
  do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
265
  }
266
 
267
+ /*
268
  * If this is a reply to another comment, send an email notification to the
269
  * author of the immediate parent comment.
270
  */
280
  $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
281
  $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/';
282
 
283
+ // Set up and send the message.
284
  $ud = bp_core_get_core_userdata( $parent_comment->user_id );
285
  $to = $ud->user_email;
286
  $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name ) ) );
298
  ---------------------
299
  ', 'buddypress' ), $poster_name, $content, $thread_link );
300
 
301
+ // Only show the disable notifications line if the settings component is enabled.
302
  if ( bp_is_active( 'settings' ) ) {
303
  $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
304
  }
306
  /**
307
  * Filters the user email that the new comment reply notification will be sent to.
308
  *
309
+ * @since 1.2.0
310
  *
311
  * @param string $to User email the notification is being sent to.
312
  */
315
  /**
316
  * Filters the new comment reply notification subject that will be sent to user.
317
  *
318
+ * @since 1.2.0
319
  *
320
  * @param string $subject Email notification subject text.
321
  * @param string $poster_name Name of the person who made the comment reply.
325
  /**
326
  * Filters the new comment reply notification message that will be sent to user.
327
  *
328
+ * @since 1.2.0
329
  *
330
  * @param string $message Email notification message text.
331
  * @param string $poster_name Name of the person who made the comment reply.
340
  /**
341
  * Fires after the sending of a reply to a reply email notification.
342
  *
343
+ * @since 1.5.0
344
  *
345
  * @param int $user_id ID of the parent activity item author.
346
  * @param string $subject Email notification subject text.
356
  /**
357
  * Helper method to map action arguments to function parameters.
358
  *
359
+ * @since 1.9.0
360
  *
361
+ * @param int $comment_id ID of the comment being notified about.
362
+ * @param array $params Parameters to use with notification.
363
  */
364
  function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
365
  bp_activity_new_comment_notification( $comment_id, $params['user_id'], $params );
371
  /**
372
  * Format notifications related to activity.
373
  *
374
+ * @since 1.5.0
375
  *
376
  * @uses bp_loggedin_user_domain()
377
  * @uses bp_get_activity_slug()
385
  * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
386
  * @param int $total_items The total number of notifications to format.
387
  * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
 
388
  * @return string $return Formatted @mention notification.
389
  */
390
  function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
416
  * need notified about. The two possible hooks are bp_activity_single_at_mentions_notification
417
  * or bp_activity_multiple_at_mentions_notification.
418
  *
419
+ * @since 1.5.0
420
  *
421
  * @param string $string HTML anchor tag for the mention.
422
  * @param string $at_mention_link The permalink for the mention.
434
  * The two possible hooks are bp_activity_single_at_mentions_notification
435
  * or bp_activity_multiple_at_mentions_notification.
436
  *
437
+ * @since 1.5.0
438
  *
439
  * @param array $array Array holding the content and permalink for the mention notification.
440
  * @param string $at_mention_link The permalink for the mention.
451
  /**
452
  * Fires right before returning the formatted activity notifications.
453
  *
454
+ * @since 1.2.0
455
  *
456
  * @param string $action The type of activity item.
457
  * @param int $item_id The activity ID.
471
  * future when we separate emails from Notifications, this will need its own
472
  * 'bp_activity_at_name_send_emails' equivalent helper function.
473
  *
474
+ * @since 1.9.0
475
  *
476
+ * @param object $activity Activity object.
477
+ * @param string $subject (not used) Notification subject.
478
+ * @param string $message (not used) Notification message.
479
+ * @param string $content (not used) Notification content.
480
+ * @param int $receiver_user_id ID of user receiving notification.
481
  */
482
  function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
483
  if ( bp_is_active( 'notifications' ) ) {
497
  /**
498
  * Mark at-mention notifications as read when users visit their Mentions page.
499
  *
500
+ * @since 1.5.0
501
  *
502
  * @uses bp_notifications_mark_all_notifications_by_type()
503
  */
506
  return;
507
  }
508
 
509
+ // Only mark read if you're looking at your own mentions.
510
  if ( ! bp_is_my_profile() ) {
511
  return;
512
  }
518
  /**
519
  * Mark at-mention notification as read when user visits the activity with the mention.
520
  *
521
+ * @since 2.0.0
522
  *
523
+ * @param BP_Activity_Activity $activity Activity object.
524
  */
525
  function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
526
  if ( ! bp_is_active( 'notifications' ) ) {
531
  return;
532
  }
533
 
534
+ // Mark as read any notifications for the current user related to this activity item.
 
535
  bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
536
  }
537
  add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
539
  /**
540
  * Delete at-mention notifications when the corresponding activity item is deleted.
541
  *
542
+ * @since 2.0.0
543
  *
544
  * @param array $activity_ids_deleted IDs of deleted activity items.
545
  */
546
  function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) {
547
  // Let's delete all without checking if content contains any mentions
548
+ // to avoid a query to get the activity.
549
  if ( bp_is_active( 'notifications' ) && ! empty( $activity_ids_deleted ) ) {
550
  foreach ( $activity_ids_deleted as $activity_id ) {
551
  bp_notifications_delete_all_notifications_by_type( $activity_id, buddypress()->activity->id );
bp-activity/bp-activity-screens.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Activity Screens.
5
  *
@@ -11,13 +10,13 @@
11
  * @subpackage ActivityScreens
12
  */
13
 
14
- // Exit if accessed directly
15
  defined( 'ABSPATH' ) || exit;
16
 
17
  /**
18
  * Load the Activity directory.
19
  *
20
- * @since BuddyPress (1.5.0)
21
  *
22
  * @uses bp_displayed_user_id()
23
  * @uses bp_is_activity_component()
@@ -34,14 +33,14 @@ function bp_activity_screen_index() {
34
  /**
35
  * Fires right before the loading of the Activity directory screen template file.
36
  *
37
- * @since BuddyPress (1.5.0)
38
  */
39
  do_action( 'bp_activity_screen_index' );
40
 
41
  /**
42
  * Filters the template to load for the Activity directory screen.
43
  *
44
- * @since BuddyPress (1.5.0)
45
  *
46
  * @param string $template Path to the activity template to load.
47
  */
@@ -53,7 +52,7 @@ add_action( 'bp_screens', 'bp_activity_screen_index' );
53
  /**
54
  * Load the 'My Activity' page.
55
  *
56
- * @since BuddyPress (1.0.0)
57
  *
58
  * @uses do_action() To call the 'bp_activity_screen_my_activity' hook.
59
  * @uses bp_core_load_template()
@@ -64,14 +63,14 @@ function bp_activity_screen_my_activity() {
64
  /**
65
  * Fires right before the loading of the "My Activity" screen template file.
66
  *
67
- * @since BuddyPress (1.0.0)
68
  */
69
  do_action( 'bp_activity_screen_my_activity' );
70
 
71
  /**
72
  * Filters the template to load for the "My Activity" screen.
73
  *
74
- * @since BuddyPress (1.0.0)
75
  *
76
  * @param string $template Path to the activity template to load.
77
  */
@@ -81,7 +80,7 @@ function bp_activity_screen_my_activity() {
81
  /**
82
  * Load the 'My Friends' activity page.
83
  *
84
- * @since BuddyPress (1.0.0)
85
  *
86
  * @uses bp_is_active()
87
  * @uses bp_update_is_item_admin()
@@ -99,14 +98,14 @@ function bp_activity_screen_friends() {
99
  /**
100
  * Fires right before the loading of the "My Friends" screen template file.
101
  *
102
- * @since BuddyPress (1.2.0)
103
  */
104
  do_action( 'bp_activity_screen_friends' );
105
 
106
  /**
107
  * Filters the template to load for the "My Friends" screen.
108
  *
109
- * @since BuddyPress (1.0.0)
110
  *
111
  * @param string $template Path to the activity template to load.
112
  */
@@ -116,7 +115,7 @@ function bp_activity_screen_friends() {
116
  /**
117
  * Load the 'My Groups' activity page.
118
  *
119
- * @since BuddyPress (1.2.0)
120
  *
121
  * @uses bp_is_active()
122
  * @uses bp_update_is_item_admin()
@@ -134,14 +133,14 @@ function bp_activity_screen_groups() {
134
  /**
135
  * Fires right before the loading of the "My Groups" screen template file.
136
  *
137
- * @since BuddyPress (1.2.0)
138
  */
139
  do_action( 'bp_activity_screen_groups' );
140
 
141
  /**
142
  * Filters the template to load for the "My Groups" screen.
143
  *
144
- * @since BuddyPress (1.2.0)
145
  *
146
  * @param string $template Path to the activity template to load.
147
  */
@@ -151,7 +150,7 @@ function bp_activity_screen_groups() {
151
  /**
152
  * Load the 'Favorites' activity page.
153
  *
154
- * @since BuddyPress (1.2.0)
155
  *
156
  * @uses bp_update_is_item_admin()
157
  * @uses bp_current_user_can()
@@ -165,14 +164,14 @@ function bp_activity_screen_favorites() {
165
  /**
166
  * Fires right before the loading of the "Favorites" screen template file.
167
  *
168
- * @since BuddyPress (1.2.0)
169
  */
170
  do_action( 'bp_activity_screen_favorites' );
171
 
172
  /**
173
  * Filters the template to load for the "Favorites" screen.
174
  *
175
- * @since BuddyPress (1.2.0)
176
  *
177
  * @param string $template Path to the activity template to load.
178
  */
@@ -182,7 +181,7 @@ function bp_activity_screen_favorites() {
182
  /**
183
  * Load the 'Mentions' activity page.
184
  *
185
- * @since BuddyPress (1.2.0)
186
  *
187
  * @uses bp_update_is_item_admin()
188
  * @uses bp_current_user_can()
@@ -196,14 +195,14 @@ function bp_activity_screen_mentions() {
196
  /**
197
  * Fires right before the loading of the "Mentions" screen template file.
198
  *
199
- * @since BuddyPress (1.2.0)
200
  */
201
  do_action( 'bp_activity_screen_mentions' );
202
 
203
  /**
204
  * Filters the template to load for the "Mentions" screen.
205
  *
206
- * @since BuddyPress (1.2.0)
207
  *
208
  * @param string $template Path to the activity template to load.
209
  */
@@ -213,7 +212,7 @@ function bp_activity_screen_mentions() {
213
  /**
214
  * Reset the logged-in user's new mentions data when he visits his mentions screen.
215
  *
216
- * @since BuddyPress (1.5.0)
217
  *
218
  * @uses bp_is_my_profile()
219
  * @uses bp_activity_clear_new_mentions()
@@ -228,7 +227,7 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
228
  /**
229
  * Load the page for a single activity item.
230
  *
231
- * @since BuddyPress (1.2.0)
232
  *
233
  * @uses bp_is_activity_component()
234
  * @uses bp_activity_get_specific()
@@ -253,14 +252,14 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
253
  function bp_activity_screen_single_activity_permalink() {
254
  $bp = buddypress();
255
 
256
- // No displayed user or not viewing activity component
257
  if ( !bp_is_activity_component() )
258
  return false;
259
 
260
  if ( ! bp_current_action() || !is_numeric( bp_current_action() ) )
261
  return false;
262
 
263
- // Get the activity details
264
  $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'show_hidden' => true, 'spam' => 'ham_only', ) );
265
 
266
  // 404 if activity does not exist
@@ -272,26 +271,26 @@ function bp_activity_screen_single_activity_permalink() {
272
  $activity = $activity['activities'][0];
273
  }
274
 
275
- // Default access is true
276
  $has_access = true;
277
 
278
- // If activity is from a group, do an extra cap check
279
  if ( isset( $bp->groups->id ) && $activity->component == $bp->groups->id ) {
280
 
281
- // Activity is from a group, but groups is currently disabled
282
  if ( !bp_is_active( 'groups') ) {
283
  bp_do_404();
284
  return;
285
  }
286
 
287
  // Check to see if the group is not public, if so, check the
288
- // user has access to see this activity
289
  if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
290
 
291
- // Group is not public
292
  if ( 'public' != $group->status ) {
293
 
294
- // User is not a member of group
295
  if ( !groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
296
  $has_access = false;
297
  }
@@ -302,7 +301,7 @@ function bp_activity_screen_single_activity_permalink() {
302
  /**
303
  * Filters the access permission for a single activity view.
304
  *
305
- * @since BuddyPress (1.2.0)
306
  *
307
  * @param array $access Array holding the current $has_access value and current activity item instance.
308
  */
@@ -311,20 +310,20 @@ function bp_activity_screen_single_activity_permalink() {
311
  /**
312
  * Fires before the loading of a single activity template file.
313
  *
314
- * @since BuddyPress (1.2.0)
315
  *
316
  * @param BP_Activity_Activity $activity Object representing the current activity item being displayed.
317
  * @param bool $has_access Whether or not the current user has access to view activity.
318
  */
319
  do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
320
 
321
- // Access is specifically disallowed
322
  if ( false === $has_access ) {
323
 
324
- // User feedback
325
  bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
326
 
327
- // Redirect based on logged in status
328
  if ( is_user_logged_in() ) {
329
  $url = bp_loggedin_user_domain();
330
 
@@ -341,7 +340,7 @@ function bp_activity_screen_single_activity_permalink() {
341
  /**
342
  * Filters the template to load for a single activity screen.
343
  *
344
- * @since BuddyPress (1.0.0)
345
  *
346
  * @param string $template Path to the activity template to load.
347
  */
@@ -352,7 +351,7 @@ add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
352
  /**
353
  * Add activity notifications settings to the notifications settings page.
354
  *
355
- * @since BuddyPress (1.2.0)
356
  *
357
  * @uses bp_get_user_meta()
358
  * @uses bp_core_get_username()
@@ -387,16 +386,16 @@ function bp_activity_screen_notification_settings() {
387
  <tr id="activity-notification-settings-mentions">
388
  <td>&nbsp;</td>
389
  <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) ) ?></td>
390
- <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td>
391
- <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td>
392
  </tr>
393
  <?php endif; ?>
394
 
395
  <tr id="activity-notification-settings-replies">
396
  <td>&nbsp;</td>
397
  <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
398
- <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php checked( $reply, 'yes', true ) ?>/></td>
399
- <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php checked( $reply, 'no', true ) ?>/></td>
400
  </tr>
401
 
402
  <?php
@@ -404,7 +403,7 @@ function bp_activity_screen_notification_settings() {
404
  /**
405
  * Fires inside the closing </tbody> tag for activity screen notification settings.
406
  *
407
- * @since BuddyPress (1.2.0)
408
  */
409
  do_action( 'bp_activity_screen_notification_settings' ) ?>
410
  </tbody>
@@ -422,14 +421,14 @@ add_action( 'bp_notification_settings', 'bp_activity_screen_notification_setting
422
  * This class sets up the necessary theme compatibility actions to safely output
423
  * activity template parts to the_title and the_content areas of a theme.
424
  *
425
- * @since BuddyPress (1.7.0)
426
  */
427
  class BP_Activity_Theme_Compat {
428
 
429
  /**
430
  * Set up the activity component theme compatibility.
431
  *
432
- * @since BuddyPress (1.7.0)
433
  */
434
  public function __construct() {
435
  add_action( 'bp_setup_theme_compat', array( $this, 'is_activity' ) );
@@ -438,15 +437,15 @@ class BP_Activity_Theme_Compat {
438
  /**
439
  * Set up the theme compatibility hooks, if we're looking at an activity page.
440
  *
441
- * @since BuddyPress (1.7.0)
442
  */
443
  public function is_activity() {
444
 
445
- // Bail if not looking at a group
446
  if ( ! bp_is_activity_component() )
447
  return;
448
 
449
- // Activity Directory
450
  if ( ! bp_displayed_user_id() && ! bp_current_action() ) {
451
  bp_update_is_directory( true, 'activity' );
452
 
@@ -457,7 +456,7 @@ class BP_Activity_Theme_Compat {
457
  add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
458
  add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) );
459
 
460
- // Single activity
461
  } elseif ( bp_is_single_activity() ) {
462
  add_filter( 'bp_get_buddypress_template', array( $this, 'single_template_hierarchy' ) );
463
  add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'single_dummy_post' ) );
@@ -472,10 +471,9 @@ class BP_Activity_Theme_Compat {
472
  *
473
  * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
474
  *
475
- * @since BuddyPress (1.8.0)
476
  *
477
  * @param string $templates The templates from bp_get_theme_compat_templates().
478
- *
479
  * @return array $templates Array of custom templates to look for.
480
  */
481
  public function directory_template_hierarchy( $templates ) {
@@ -483,7 +481,7 @@ class BP_Activity_Theme_Compat {
483
  /**
484
  * Filters the template hierarchy for the activity directory page.
485
  *
486
- * @since BuddyPress (1.8.0)
487
  *
488
  * @param array $index-directory Array holding template names to be merged into template list.
489
  */
@@ -492,7 +490,7 @@ class BP_Activity_Theme_Compat {
492
  ) );
493
 
494
  // Merge new templates with existing stack
495
- // @see bp_get_theme_compat_templates()
496
  $templates = array_merge( (array) $new_templates, $templates );
497
 
498
  return $templates;
@@ -501,7 +499,7 @@ class BP_Activity_Theme_Compat {
501
  /**
502
  * Update the global $post with directory data.
503
  *
504
- * @since BuddyPress (1.7.0)
505
  */
506
  public function directory_dummy_post() {
507
  bp_theme_compat_reset_post( array(
@@ -520,7 +518,7 @@ class BP_Activity_Theme_Compat {
520
  /**
521
  * Filter the_content with the groups index template part.
522
  *
523
- * @since BuddyPress (1.7.0)
524
  */
525
  public function directory_content() {
526
  return bp_buffer_template_part( 'activity/index', null, false );
@@ -533,10 +531,9 @@ class BP_Activity_Theme_Compat {
533
  *
534
  * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
535
  *
536
- * @since BuddyPress (1.8.0)
537
  *
538
  * @param string $templates The templates from bp_get_theme_compat_templates().
539
- *
540
  * @return array $templates Array of custom templates to look for.
541
  */
542
  public function single_template_hierarchy( $templates ) {
@@ -544,7 +541,7 @@ class BP_Activity_Theme_Compat {
544
  /**
545
  * Filters the template hierarchy for the activity permalink pages.
546
  *
547
- * @since BuddyPress (1.8.0)
548
  *
549
  * @param array $index Array holding template names to be merged into template list.
550
  */
@@ -553,7 +550,7 @@ class BP_Activity_Theme_Compat {
553
  ) );
554
 
555
  // Merge new templates with existing stack
556
- // @see bp_get_theme_compat_templates()
557
  $templates = array_merge( (array) $new_templates, $templates );
558
 
559
  return $templates;
@@ -562,7 +559,7 @@ class BP_Activity_Theme_Compat {
562
  /**
563
  * Update the global $post with the displayed user's data.
564
  *
565
- * @since BuddyPress (1.7.0)
566
  */
567
  public function single_dummy_post() {
568
  bp_theme_compat_reset_post( array(
@@ -581,7 +578,7 @@ class BP_Activity_Theme_Compat {
581
  /**
582
  * Filter the_content with the members' activity permalink template part.
583
  *
584
- * @since BuddyPress (1.7.0)
585
  */
586
  public function single_dummy_content() {
587
  return bp_buffer_template_part( 'activity/single/home', null, false );
1
  <?php
 
2
  /**
3
  * BuddyPress Activity Screens.
4
  *
10
  * @subpackage ActivityScreens
11
  */
12
 
13
+ // Exit if accessed directly.
14
  defined( 'ABSPATH' ) || exit;
15
 
16
  /**
17
  * Load the Activity directory.
18
  *
19
+ * @since 1.5.0
20
  *
21
  * @uses bp_displayed_user_id()
22
  * @uses bp_is_activity_component()
33
  /**
34
  * Fires right before the loading of the Activity directory screen template file.
35
  *
36
+ * @since 1.5.0
37
  */
38
  do_action( 'bp_activity_screen_index' );
39
 
40
  /**
41
  * Filters the template to load for the Activity directory screen.
42
  *
43
+ * @since 1.5.0
44
  *
45
  * @param string $template Path to the activity template to load.
46
  */
52
  /**
53
  * Load the 'My Activity' page.
54
  *
55
+ * @since 1.0.0
56
  *
57
  * @uses do_action() To call the 'bp_activity_screen_my_activity' hook.
58
  * @uses bp_core_load_template()
63
  /**
64
  * Fires right before the loading of the "My Activity" screen template file.
65
  *
66
+ * @since 1.0.0
67
  */
68
  do_action( 'bp_activity_screen_my_activity' );
69
 
70
  /**
71
  * Filters the template to load for the "My Activity" screen.
72
  *
73
+ * @since 1.0.0
74
  *
75
  * @param string $template Path to the activity template to load.
76
  */
80
  /**
81
  * Load the 'My Friends' activity page.
82
  *
83
+ * @since 1.0.0
84
  *
85
  * @uses bp_is_active()
86
  * @uses bp_update_is_item_admin()
98
  /**
99
  * Fires right before the loading of the "My Friends" screen template file.
100
  *
101
+ * @since 1.2.0
102
  */
103
  do_action( 'bp_activity_screen_friends' );
104
 
105
  /**
106
  * Filters the template to load for the "My Friends" screen.
107
  *
108
+ * @since 1.0.0
109
  *
110
  * @param string $template Path to the activity template to load.
111
  */
115
  /**
116
  * Load the 'My Groups' activity page.
117
  *
118
+ * @since 1.2.0
119
  *
120
  * @uses bp_is_active()
121
  * @uses bp_update_is_item_admin()
133
  /**
134
  * Fires right before the loading of the "My Groups" screen template file.
135
  *
136
+ * @since 1.2.0
137
  */
138
  do_action( 'bp_activity_screen_groups' );
139
 
140
  /**
141
  * Filters the template to load for the "My Groups" screen.
142
  *
143
+ * @since 1.2.0
144
  *
145
  * @param string $template Path to the activity template to load.
146
  */
150
  /**
151
  * Load the 'Favorites' activity page.
152
  *
153
+ * @since 1.2.0
154
  *
155
  * @uses bp_update_is_item_admin()
156
  * @uses bp_current_user_can()
164
  /**
165
  * Fires right before the loading of the "Favorites" screen template file.
166
  *
167
+ * @since 1.2.0
168
  */
169
  do_action( 'bp_activity_screen_favorites' );
170
 
171
  /**
172
  * Filters the template to load for the "Favorites" screen.
173
  *
174
+ * @since 1.2.0
175
  *
176
  * @param string $template Path to the activity template to load.
177
  */
181
  /**
182
  * Load the 'Mentions' activity page.
183
  *
184
+ * @since 1.2.0
185
  *
186
  * @uses bp_update_is_item_admin()
187
  * @uses bp_current_user_can()
195
  /**
196
  * Fires right before the loading of the "Mentions" screen template file.
197
  *
198
+ * @since 1.2.0
199
  */
200
  do_action( 'bp_activity_screen_mentions' );
201
 
202
  /**
203
  * Filters the template to load for the "Mentions" screen.
204
  *
205
+ * @since 1.2.0
206
  *
207
  * @param string $template Path to the activity template to load.
208
  */
212
  /**
213
  * Reset the logged-in user's new mentions data when he visits his mentions screen.
214
  *
215
+ * @since 1.5.0
216
  *
217
  * @uses bp_is_my_profile()
218
  * @uses bp_activity_clear_new_mentions()
227
  /**
228
  * Load the page for a single activity item.
229
  *
230
+ * @since 1.2.0
231
  *
232
  * @uses bp_is_activity_component()
233
  * @uses bp_activity_get_specific()
252
  function bp_activity_screen_single_activity_permalink() {
253
  $bp = buddypress();
254
 
255
+ // No displayed user or not viewing activity component.
256
  if ( !bp_is_activity_component() )
257
  return false;
258
 
259
  if ( ! bp_current_action() || !is_numeric( bp_current_action() ) )
260
  return false;
261
 
262
+ // Get the activity details.
263
  $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'show_hidden' => true, 'spam' => 'ham_only', ) );
264
 
265
  // 404 if activity does not exist
271
  $activity = $activity['activities'][0];
272
  }
273
 
274
+ // Default access is true.
275
  $has_access = true;
276
 
277
+ // If activity is from a group, do an extra cap check.
278
  if ( isset( $bp->groups->id ) && $activity->component == $bp->groups->id ) {
279
 
280
+ // Activity is from a group, but groups is currently disabled.
281
  if ( !bp_is_active( 'groups') ) {
282
  bp_do_404();
283
  return;
284
  }
285
 
286
  // Check to see if the group is not public, if so, check the
287
+ // user has access to see this activity.
288
  if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
289
 
290
+ // Group is not public.
291
  if ( 'public' != $group->status ) {
292
 
293
+ // User is not a member of group.
294
  if ( !groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
295
  $has_access = false;
296
  }
301
  /**
302
  * Filters the access permission for a single activity view.
303
  *
304
+ * @since 1.2.0
305
  *
306
  * @param array $access Array holding the current $has_access value and current activity item instance.
307
  */
310
  /**
311
  * Fires before the loading of a single activity template file.
312
  *
313
+ * @since 1.2.0
314
  *
315
  * @param BP_Activity_Activity $activity Object representing the current activity item being displayed.
316
  * @param bool $has_access Whether or not the current user has access to view activity.
317
  */
318
  do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
319
 
320
+ // Access is specifically disallowed.
321
  if ( false === $has_access ) {
322
 
323
+ // User feedback.
324
  bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
325
 
326
+ // Redirect based on logged in status.
327
  if ( is_user_logged_in() ) {
328
  $url = bp_loggedin_user_domain();
329
 
340
  /**
341
  * Filters the template to load for a single activity screen.
342
  *
343
+ * @since 1.0.0
344
  *
345
  * @param string $template Path to the activity template to load.
346
  */
351
  /**
352
  * Add activity notifications settings to the notifications settings page.
353
  *
354
+ * @since 1.2.0
355
  *
356
  * @uses bp_get_user_meta()
357
  * @uses bp_core_get_username()
386
  <tr id="activity-notification-settings-mentions">
387
  <td>&nbsp;</td>
388
  <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) ) ?></td>
389
+ <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-yes" value="yes" <?php checked( $mention, 'yes', true ) ?>/><label for="notification-activity-new-mention-yes" class="bp-screen-reader-text"><?php _e( 'Yes, send email', 'buddypress' ); ?></label></td>
390
+ <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-no" value="no" <?php checked( $mention, 'no', true ) ?>/><label for="notification-activity-new-mention-no" class="bp-screen-reader-text"><?php _e( 'No, do not send email', 'buddypress' ); ?></label></td>
391
  </tr>
392
  <?php endif; ?>
393
 
394
  <tr id="activity-notification-settings-replies">
395
  <td>&nbsp;</td>
396
  <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
397
+ <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-yes" value="yes" <?php checked( $reply, 'yes', true ) ?>/><label for="notification-activity-new-reply-yes" class="bp-screen-reader-text"><?php _e( 'Yes, send email', 'buddypress' ); ?></label></td>
398
+ <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-no" value="no" <?php checked( $reply, 'no', true ) ?>/><label for="notification-activity-new-reply-no" class="bp-screen-reader-text"><?php _e( 'No, do not send email', 'buddypress' ); ?></label></td>
399
  </tr>
400
 
401
  <?php
403
  /**
404
  * Fires inside the closing </tbody> tag for activity screen notification settings.
405
  *
406
+ * @since 1.2.0
407
  */
408
  do_action( 'bp_activity_screen_notification_settings' ) ?>
409
  </tbody>
421
  * This class sets up the necessary theme compatibility actions to safely output
422
  * activity template parts to the_title and the_content areas of a theme.
423
  *
424
+ * @since 1.7.0
425
  */
426
  class BP_Activity_Theme_Compat {
427
 
428
  /**
429
  * Set up the activity component theme compatibility.
430
  *
431
+ * @since 1.7.0
432
  */
433
  public function __construct() {
434
  add_action( 'bp_setup_theme_compat', array( $this, 'is_activity' ) );
437
  /**
438
  * Set up the theme compatibility hooks, if we're looking at an activity page.
439
  *
440
+ * @since 1.7.0
441
  */
442
  public function is_activity() {
443
 
444
+ // Bail if not looking at a group.
445
  if ( ! bp_is_activity_component() )
446
  return;
447
 
448
+ // Activity Directory.
449
  if ( ! bp_displayed_user_id() && ! bp_current_action() ) {
450
  bp_update_is_directory( true, 'activity' );
451
 
456
  add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
457
  add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) );
458
 
459
+ // Single activity.
460
  } elseif ( bp_is_single_activity() ) {
461
  add_filter( 'bp_get_buddypress_template', array( $this, 'single_template_hierarchy' ) );
462
  add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'single_dummy_post' ) );
471
  *
472
  * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
473
  *
474
+ * @since 1.8.0
475
  *
476
  * @param string $templates The templates from bp_get_theme_compat_templates().
 
477
  * @return array $templates Array of custom templates to look for.
478
  */
479
  public function directory_template_hierarchy( $templates ) {
481
  /**
482
  * Filters the template hierarchy for the activity directory page.
483
  *
484
+ * @since 1.8.0
485
  *
486
  * @param array $index-directory Array holding template names to be merged into template list.
487
  */
490
  ) );
491
 
492
  // Merge new templates with existing stack
493
+ // @see bp_get_theme_compat_templates().
494
  $templates = array_merge( (array) $new_templates, $templates );
495
 
496
  return $templates;
499
  /**
500
  * Update the global $post with directory data.
501
  *
502
+ * @since 1.7.0
503
  */
504
  public function directory_dummy_post() {
505
  bp_theme_compat_reset_post( array(
518
  /**
519
  * Filter the_content with the groups index template part.
520
  *
521
+ * @since 1.7.0
522
  */
523
  public function directory_content() {
524
  return bp_buffer_template_part( 'activity/index', null, false );
531
  *
532
  * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
533
  *
534
+ * @since 1.8.0
535
  *
536
  * @param string $templates The templates from bp_get_theme_compat_templates().
 
537
  * @return array $templates Array of custom templates to look for.
538
  */
539
  public function single_template_hierarchy( $templates ) {
541
  /**
542
  * Filters the template hierarchy for the activity permalink pages.
543
  *
544
+ * @since 1.8.0
545
  *
546
  * @param array $index Array holding template names to be merged into template list.
547
  */
550
  ) );
551
 
552
  // Merge new templates with existing stack
553
+ // @see bp_get_theme_compat_templates().
554
  $templates = array_merge( (array) $new_templates, $templates );
555
 
556
  return $templates;
559
  /**
560
  * Update the global $post with the displayed user's data.
561
  *
562
+ * @since 1.7.0
563
  */
564
  public function single_dummy_post() {
565
  bp_theme_compat_reset_post( array(
578
  /**
579
  * Filter the_content with the members' activity permalink template part.
580
  *
581
+ * @since 1.7.0
582
  */
583
  public function single_dummy_content() {
584
  return bp_buffer_template_part( 'activity/single/home', null, false );
bp-activity/bp-activity-template.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Activity Template Functions.
5
  *
@@ -7,13 +6,13 @@
7
  * @subpackage ActivityTemplate
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Output the activity component slug.
15
  *
16
- * @since BuddyPress (1.5.0)
17
  *
18
  * @uses bp_get_activity_slug()
19
  */
@@ -23,7 +22,7 @@ function bp_activity_slug() {
23
  /**
24
  * Return the activity component slug.
25
  *
26
- * @since BuddyPress (1.5.0)
27
  *
28
  * @uses apply_filters() To call the 'bp_get_activity_slug' hook.
29
  *
@@ -34,7 +33,7 @@ function bp_activity_slug() {
34
  /**
35
  * Filters the activity component slug.
36
  *
37
- * @since BuddyPress (1.5.0)
38
  *
39
  * @param string $slug Activity component slug.
40
  */
@@ -44,7 +43,7 @@ function bp_activity_slug() {
44
  /**
45
  * Output the activity component root slug.
46
  *
47
- * @since BuddyPress (1.5.0)
48
  *
49
  * @uses bp_get_activity_root_slug()
50
  */
@@ -54,7 +53,7 @@ function bp_activity_root_slug() {
54
  /**
55
  * Return the activity component root slug.
56
  *
57
- * @since BuddyPress (1.5.0)
58
  *
59
  * @uses apply_filters() To call the 'bp_get_activity_root_slug' hook.
60
  *
@@ -65,7 +64,7 @@ function bp_activity_root_slug() {
65
  /**
66
  * Filters the activity component root slug.
67
  *
68
- * @since BuddyPress (1.5.0)
69
  *
70
  * @param string $root_slug Activity component root slug.
71
  */
@@ -75,7 +74,7 @@ function bp_activity_root_slug() {
75
  /**
76
  * Output activity directory permalink.
77
  *
78
- * @since BuddyPress (1.5.0)
79
  *
80
  * @uses bp_get_activity_directory_permalink()
81
  */
@@ -85,7 +84,7 @@ function bp_activity_directory_permalink() {
85
  /**
86
  * Return activity directory permalink.
87
  *
88
- * @since BuddyPress (1.5.0)
89
  *
90
  * @uses trailingslashit()
91
  * @uses bp_get_root_domain()
@@ -99,7 +98,7 @@ function bp_activity_directory_permalink() {
99
  /**
100
  * Filters the activity directory permalink.
101
  *
102
- * @since BuddyPress (1.5.0)
103
  *
104
  * @param string $url Permalink url for the activity directory.
105
  */
@@ -111,14 +110,14 @@ function bp_activity_directory_permalink() {
111
  *
112
  * This is responsible for loading a group of activity items and displaying them.
113
  *
114
- * @since BuddyPress (1.0.0)
115
  */
116
  class BP_Activity_Template {
 
117
  /**
118
  * The loop iterator.
119
  *
120
- * @since BuddyPress (1.5.0)
121
- * @access public
122
  * @var int
123
  */
124
  public $current_activity = -1;
@@ -126,8 +125,7 @@ class BP_Activity_Template {
126
  /**
127
  * The activity count.
128
  *
129
- * @since BuddyPress (1.5.0)
130
- * @access public
131
  * @var int
132
  */
133
  public $activity_count;
@@ -135,8 +133,7 @@ class BP_Activity_Template {
135
  /**
136
  * The total activity count.
137
  *
138
- * @since BuddyPress (1.5.0)
139
- * @access public
140
  * @var int
141
  */
142
  public $total_activity_count;
@@ -144,8 +141,7 @@ class BP_Activity_Template {
144
  /**
145
  * Array of activities located by the query.
146
  *
147
- * @since BuddyPress (1.5.0)
148
- * @access public
149
  * @var array
150
  */
151
  public $activities;
@@ -153,8 +149,7 @@ class BP_Activity_Template {
153
  /**
154
  * The activity object currently being iterated on.
155
  *
156
- * @since BuddyPress (1.5.0)
157
- * @access public
158
  * @var object
159
  */
160
  public $activity;
@@ -162,8 +157,7 @@ class BP_Activity_Template {
162
  /**
163
  * A flag for whether the loop is currently being iterated.
164
  *
165
- * @since BuddyPress (1.5.0)
166
- * @access public
167
  * @var bool
168
  */
169
  public $in_the_loop;
@@ -171,7 +165,7 @@ class BP_Activity_Template {
171
  /**
172
  * URL parameter key for activity pagination. Default: 'acpage'.
173
  *
174
- * @since BuddyPress (2.1.0)
175
  * @var string
176
  */
177
  public $pag_arg;
@@ -179,8 +173,7 @@ class BP_Activity_Template {
179
  /**
180
  * The page number being requested.
181
  *
182
- * @since BuddyPress (1.5.0)
183
- * @access public
184
  * @var int
185
  */
186
  public $pag_page;
@@ -188,8 +181,7 @@ class BP_Activity_Template {
188
  /**
189
  * The number of items being requested per page.
190
  *
191
- * @since BuddyPress (1.5.0)
192
- * @access public
193
  * @var int
194
  */
195
  public $pag_num;
@@ -197,8 +189,7 @@ class BP_Activity_Template {
197
  /**
198
  * An HTML string containing pagination links.
199
  *
200
- * @since BuddyPress (1.5.0)
201
- * @access public
202
  * @var string
203
  */
204
  public $pag_links;
@@ -206,8 +197,7 @@ class BP_Activity_Template {
206
  /**
207
  * The displayed user's full name.
208
  *
209
- * @since BuddyPress (1.5.0)
210
- * @access public
211
  * @var string
212
  */
213
  public $full_name;
@@ -242,7 +232,7 @@ class BP_Activity_Template {
242
  public function __construct( $args ) {
243
  $bp = buddypress();
244
 
245
- // Backward compatibility with old method of passing arguments
246
  if ( !is_array( $args ) || func_num_args() > 1 ) {
247
  _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
248
 
@@ -271,6 +261,7 @@ class BP_Activity_Template {
271
  'per_page' => 20,
272
  'page_arg' => 'acpage',
273
  'max' => false,
 
274
  'count_total' => false,
275
  'sort' => false,
276
  'include' => false,
@@ -294,13 +285,13 @@ class BP_Activity_Template {
294
  $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] );
295
  $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
296
 
297
- // Check if blog/forum replies are disabled
298
  $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' );
299
 
300
- // Get an array of the logged in user's favorite activities
301
  $this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) );
302
 
303
- // Fetch specific activity items based on ID's
304
  if ( !empty( $include ) ) {
305
  $this->activities = bp_activity_get_specific( array(
306
  'activity_ids' => explode( ',', $include ),
@@ -315,7 +306,7 @@ class BP_Activity_Template {
315
  'update_meta_cache' => $update_meta_cache,
316
  ) );
317
 
318
- // Fetch all activity items
319
  } else {
320
  $this->activities = bp_activity_get( array(
321
  'display_comments' => $display_comments,
@@ -339,7 +330,7 @@ class BP_Activity_Template {
339
  }
340
 
341
  // The total_activity_count property will be set only if a
342
- // 'count_total' query has taken place
343
  if ( ! is_null( $this->activities['total'] ) ) {
344
  if ( ! $max || $max >= (int) $this->activities['total'] ) {
345
  $this->total_activity_count = (int) $this->activities['total'];
@@ -364,7 +355,7 @@ class BP_Activity_Template {
364
 
365
  $this->full_name = bp_get_displayed_user_fullname();
366
 
367
- // Fetch parent content for activity comments so we do not have to query in the loop
368
  foreach ( (array) $this->activities as $activity ) {
369
  if ( 'activity_comment' != $activity->type ) {
370
  continue;
@@ -456,11 +447,11 @@ class BP_Activity_Template {
456
  /**
457
  * Fires right before the rewinding of activity posts.
458
  *
459
- * @since BuddyPress (1.1.0)
460
  */
461
  do_action( 'activity_loop_end' );
462
 
463
- // Do some cleaning up after the loop
464
  $this->rewind_activities();
465
  }
466
 
@@ -487,13 +478,13 @@ class BP_Activity_Template {
487
  $this->activity = (object) $this->activity;
488
  }
489
 
490
- // loop has just started
491
  if ( $this->current_activity == 0 ) {
492
 
493
  /**
494
  * Fires if the current activity item is the first in the activity loop.
495
  *
496
- * @since BuddyPress (1.1.0)
497
  */
498
  do_action('activity_loop_start');
499
  }
@@ -507,7 +498,8 @@ class BP_Activity_Template {
507
  * $activities_template global, enabling the use of BuddyPress templates and
508
  * template functions to display a list of activity items.
509
  *
510
- * @since BuddyPress (1.0.0)
 
511
  *
512
  * @global object $activities_template {@link BP_Activity_Template}
513
  * @uses groups_is_user_member()
@@ -537,6 +529,8 @@ class BP_Activity_Template {
537
  * @type int|bool $per_page Number of results per page. Default: 20.
538
  * @type string $page_arg String used as a query parameter in pagination links. Default: 'acpage'.
539
  * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
 
 
540
  * @type string|bool $count_total If true, an additional DB query is run to count the total activity items
541
  * for the query. Default: false.
542
  * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
@@ -611,17 +605,19 @@ class BP_Activity_Template {
611
  function bp_has_activities( $args = '' ) {
612
  global $activities_template;
613
 
614
- // Get BuddyPress
615
  $bp = buddypress();
616
 
617
- /** Smart Defaults ********************************************************/
 
 
618
 
619
- // User filtering
620
  $user_id = bp_displayed_user_id()
621
  ? bp_displayed_user_id()
622
  : false;
623
 
624
- // Group filtering
625
  if ( bp_is_group() ) {
626
  $object = $bp->groups->id;
627
  $primary_id = bp_get_current_group_id();
@@ -632,75 +628,86 @@ function bp_has_activities( $args = '' ) {
632
  $show_hidden = false;
633
  }
634
 
635
- // The default scope should recognize custom slugs
636
  $scope = array_key_exists( bp_current_action(), (array) $bp->loaded_components )
637
  ? $bp->loaded_components[ bp_current_action() ]
638
  : bp_current_action();
639
 
640
- // Support for permalinks on single item pages: /groups/my-group/activity/124/
641
  $include = bp_is_current_action( bp_get_activity_slug() )
642
  ? bp_action_variable( 0 )
643
  : false;
644
 
645
- /** Parse Args ************************************************************/
 
 
 
 
 
 
 
 
646
 
647
  // Note: any params used for filtering can be a single value, or multiple
648
  // values comma separated.
649
  $r = bp_parse_args( $args, array(
650
- 'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
651
- 'include' => $include, // pass an activity_id or string of IDs comma-separated
652
- 'exclude' => false, // pass an activity_id or string of IDs comma-separated
653
- 'in' => false, // comma-separated list or array of activity IDs among which to search
654
- 'sort' => 'DESC', // sort DESC or ASC
655
- 'page' => 1, // which page to load
656
- 'per_page' => 20, // number of items per page
657
- 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679
658
- 'max' => false, // max number to return
 
659
  'count_total' => false,
660
  'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
661
- 'spam' => 'ham_only', // Hide spammed items
662
 
663
- // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
664
  'scope' => $scope,
665
 
666
  // Filtering
667
- 'user_id' => $user_id, // user_id to filter on
668
- 'object' => $object, // object to filter on e.g. groups, profile, status, friends
669
- 'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated
670
- 'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
671
- 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
672
- 'offset' => false, // return only items >= this ID
673
- 'since' => false, // return only items recorded since this Y-m-d H:i:s date
674
-
675
- 'meta_query' => false, // filter on activity meta. See WP_Meta_Query for format
676
- 'date_query' => false, // filter by date. See first parameter of WP_Date_Query for format
677
- 'filter_query' => false, // advanced filtering. See BP_Activity_Query for format
678
-
679
- // Searching
680
- 'search_terms' => false, // specify terms to search on
681
  'update_meta_cache' => true,
682
  ), 'has_activities' );
683
 
684
- /** Smart Overrides *******************************************************/
 
 
685
 
686
  // Translate various values for 'display_comments'
687
  // This allows disabling comments via ?display_comments=0
688
- // or =none or =false. Final true is a strict type check. See #5029
689
  if ( in_array( $r['display_comments'], array( 0, '0', 'none', 'false' ), true ) ) {
690
  $r['display_comments'] = false;
691
  }
692
 
693
- // Ignore pagination if an offset is passed
694
  if ( ! empty( $r['offset'] ) ) {
695
  $r['page'] = 0;
696
  }
697
 
698
- // Search terms
699
  if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) {
700
  $r['search_terms'] = $_REQUEST['s'];
701
  }
702
 
703
- // Do not exceed the maximum per page
704
  if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
705
  $r['per_page'] = $r['max'];
706
  }
@@ -712,7 +719,7 @@ function bp_has_activities( $args = '' ) {
712
  * To enable, put add_filter( 'bp_activity_enable_afilter_support', '__return_true' );
713
  * into bp-custom.php or your theme's functions.php.
714
  *
715
- * @since BuddyPress (1.6.0)
716
  *
717
  * @param bool $value True if BuddyPress should enable afilter support.
718
  */
@@ -740,14 +747,16 @@ function bp_has_activities( $args = '' ) {
740
  $r['spam'] = 'all';
741
  }
742
 
743
- /** Query *****************************************************************/
 
 
744
 
745
  $activities_template = new BP_Activity_Template( $r );
746
 
747
  /**
748
  * Filters whether or not there are activity items to display.
749
  *
750
- * @since BuddyPress (1.1.0)
751
  *
752
  * @param bool $value Whether or not there are activity items to display.
753
  * @param string $activities_template Current activities template being used.
@@ -759,7 +768,7 @@ function bp_has_activities( $args = '' ) {
759
  /**
760
  * Determine if there are still activities left in the loop.
761
  *
762
- * @since BuddyPress (1.0.0)
763
  *
764
  * @global object $activities_template {@link BP_Activity_Template}
765
  * @uses BP_Activity_Template::user_activities() {@link BP_Activity_Template::user_activities()}
@@ -774,7 +783,7 @@ function bp_activities() {
774
  /**
775
  * Get the current activity object in the loop.
776
  *
777
- * @since BuddyPress (1.0.0)
778
  *
779
  * @global object $activities_template {@link BP_Activity_Template}
780
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
@@ -789,7 +798,7 @@ function bp_the_activity() {
789
  /**
790
  * Output the URL for the Load More link.
791
  *
792
- * @since BuddyPress (2.1.0)
793
  */
794
  function bp_activity_load_more_link() {
795
  echo esc_url( bp_get_activity_load_more_link() );
@@ -797,7 +806,9 @@ function bp_activity_load_more_link() {
797
  /**
798
  * Get the URL for the Load More link.
799
  *
800
- * @since BuddyPress (2.1.0)
 
 
801
  */
802
  function bp_get_activity_load_more_link() {
803
  global $activities_template;
@@ -808,7 +819,7 @@ function bp_activity_load_more_link() {
808
  /**
809
  * Filters the Load More link URL.
810
  *
811
- * @since BuddyPress (2.1.0)
812
  *
813
  * @param string $link The "Load More" link URL with appropriate query args.
814
  * @param string $url The original URL.
@@ -820,7 +831,7 @@ function bp_activity_load_more_link() {
820
  /**
821
  * Output the activity pagination count.
822
  *
823
- * @since BuddyPress (1.0.0)
824
  *
825
  * @global object $activities_template {@link BP_Activity_Template}
826
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
@@ -832,7 +843,7 @@ function bp_activity_pagination_count() {
832
  /**
833
  * Return the activity pagination count.
834
  *
835
- * @since BuddyPress (1.2.0)
836
  *
837
  * @global object $activities_template {@link BP_Activity_Template}
838
  * @uses bp_core_number_format()
@@ -859,7 +870,7 @@ function bp_activity_pagination_count() {
859
  /**
860
  * Output the activity pagination links.
861
  *
862
- * @since BuddyPress (1.0.0)
863
  *
864
  * @uses bp_get_activity_pagination_links()
865
  */
@@ -870,7 +881,7 @@ function bp_activity_pagination_links() {
870
  /**
871
  * Return the activity pagination links.
872
  *
873
- * @since BuddyPress (1.0.0)
874
  *
875
  * @global object $activities_template {@link BP_Activity_Template}
876
  * @uses apply_filters() To call the 'bp_get_activity_pagination_links' hook.
@@ -883,7 +894,7 @@ function bp_activity_pagination_links() {
883
  /**
884
  * Filters the activity pagination link output.
885
  *
886
- * @since BuddyPress (1.0.0)
887
  *
888
  * @param string $pag_links Output for the activity pagination links.
889
  */
@@ -893,7 +904,7 @@ function bp_activity_pagination_links() {
893
  /**
894
  * Return true when there are more activity items to be shown than currently appear.
895
  *
896
- * @since BuddyPress (1.5.0)
897
  *
898
  * @global object $activities_template {@link BP_Activity_Template}
899
  * @uses apply_filters() To call the 'bp_activity_has_more_items' hook.
@@ -918,7 +929,7 @@ function bp_activity_has_more_items() {
918
  /**
919
  * Filters whether there are more activity items to display.
920
  *
921
- * @since BuddyPress (1.5.0)
922
  *
923
  * @param bool $has_more_items Whether or not there are more activity items to display.
924
  */
@@ -928,7 +939,7 @@ function bp_activity_has_more_items() {
928
  /**
929
  * Output the activity count.
930
  *
931
- * @since BuddyPress (1.2.0)
932
  *
933
  * @uses bp_get_activity_count()
934
  */
@@ -939,7 +950,7 @@ function bp_activity_count() {
939
  /**
940
  * Return the activity count.
941
  *
942
- * @since BuddyPress (1.2.0)
943
  *
944
  * @global object $activities_template {@link BP_Activity_Template}
945
  * @uses apply_filters() To call the 'bp_get_activity_count' hook.
@@ -952,7 +963,7 @@ function bp_activity_count() {
952
  /**
953
  * Filters the activity count for the activity template.
954
  *
955
- * @since BuddyPress (1.2.0)
956
  *
957
  * @param int $activity_count The count for total activity.
958
  */
@@ -962,7 +973,7 @@ function bp_activity_count() {
962
  /**
963
  * Output the number of activities per page.
964
  *
965
- * @since BuddyPress (1.2.0)
966
  *
967
  * @uses bp_get_activity_per_page()
968
  */
@@ -973,7 +984,7 @@ function bp_activity_per_page() {
973
  /**
974
  * Return the number of activities per page.
975
  *
976
- * @since BuddyPress (1.2.0)
977
  *
978
  * @global object $activities_template {@link BP_Activity_Template}
979
  * @uses apply_filters() To call the 'bp_get_activity_per_page' hook.
@@ -986,7 +997,7 @@ function bp_activity_per_page() {
986
  /**
987
  * Filters the activity posts per page value.
988
  *
989
- * @since BuddyPress (1.2.0)
990
  *
991
  * @param int $pag_num How many post should be displayed for pagination.
992
  */
@@ -996,7 +1007,7 @@ function bp_activity_per_page() {
996
  /**
997
  * Output the activities title.
998
  *
999
- * @since BuddyPress (1.0.0)
1000
  *
1001
  * @uses bp_get_activities_title()
1002
  * @todo Deprecate.
@@ -1008,7 +1019,7 @@ function bp_activities_title() {
1008
  /**
1009
  * Return the activities title.
1010
  *
1011
- * @since BuddyPress (1.0.0)
1012
  *
1013
  * @global string $bp_activity_title
1014
  * @uses apply_filters() To call the 'bp_get_activities_title' hook.
@@ -1022,7 +1033,7 @@ function bp_activities_title() {
1022
  /**
1023
  * Filters the activities title for the activity template.
1024
  *
1025
- * @since BuddyPress (1.0.0)
1026
  *
1027
  * @param string $bp_activity_title The title to be displayed.
1028
  */
@@ -1032,7 +1043,7 @@ function bp_activities_title() {
1032
  /**
1033
  * {@internal Missing Description}
1034
  *
1035
- * @since BuddyPress (1.0.0)
1036
  *
1037
  * @uses bp_get_activities_no_activity()
1038
  * @todo Deprecate.
@@ -1044,7 +1055,7 @@ function bp_activities_no_activity() {
1044
  /**
1045
  * {@internal Missing Description}
1046
  *
1047
- * @since BuddyPress (1.0.0)
1048
  *
1049
  * @global string $bp_activity_no_activity
1050
  * @uses apply_filters() To call the 'bp_get_activities_no_activity' hook.
@@ -1058,7 +1069,7 @@ function bp_activities_no_activity() {
1058
  /**
1059
  * Filters the text used when there is no activity to display.
1060
  *
1061
- * @since BuddyPress (1.0.0)
1062
  *
1063
  * @param string $bp_activity_no_activity Text to display for no activity.
1064
  */
@@ -1068,7 +1079,7 @@ function bp_activities_no_activity() {
1068
  /**
1069
  * Output the activity ID.
1070
  *
1071
- * @since BuddyPress (1.2.0)
1072
  *
1073
  * @uses bp_get_activity_id()
1074
  */
@@ -1079,7 +1090,7 @@ function bp_activity_id() {
1079
  /**
1080
  * Return the activity ID.
1081
  *
1082
- * @since BuddyPress (1.2.0)
1083
  *
1084
  * @global object $activities_template {@link BP_Activity_Template}
1085
  * @uses apply_filters() To call the 'bp_get_activity_id' hook.
@@ -1092,7 +1103,7 @@ function bp_activity_id() {
1092
  /**
1093
  * Filters the activity ID being displayed.
1094
  *
1095
- * @since BuddyPress (1.2.0)
1096
  *
1097
  * @param int $id The activity ID.
1098
  */
@@ -1102,7 +1113,7 @@ function bp_activity_id() {
1102
  /**
1103
  * Output the activity item ID.
1104
  *
1105
- * @since BuddyPress (1.2.0)
1106
  *
1107
  * @uses bp_get_activity_item_id()
1108
  */
@@ -1113,7 +1124,7 @@ function bp_activity_item_id() {
1113
  /**
1114
  * Return the activity item ID.
1115
  *
1116
- * @since BuddyPress (1.2.0)
1117
  *
1118
  * @global object $activities_template {@link BP_Activity_Template}
1119
  * @uses apply_filters() To call the 'bp_get_activity_item_id' hook.
@@ -1126,7 +1137,7 @@ function bp_activity_item_id() {
1126
  /**
1127
  * Filters the activity item ID being displayed.
1128
  *
1129
- * @since BuddyPress (1.2.0)
1130
  *
1131
  * @param int $item_id The activity item ID.
1132
  */
@@ -1136,7 +1147,7 @@ function bp_activity_item_id() {
1136
  /**
1137
  * Output the activity secondary item ID.
1138
  *
1139
- * @since BuddyPress (1.2.0)
1140
  *
1141
  * @uses bp_get_activity_secondary_item_id()
1142
  */
@@ -1147,7 +1158,7 @@ function bp_activity_secondary_item_id() {
1147
  /**
1148
  * Return the activity secondary item ID.
1149
  *
1150
- * @since BuddyPress (1.2.0)
1151
  *
1152
  * @global object $activities_template {@link BP_Activity_Template}
1153
  * @uses apply_filters() To call the 'bp_get_activity_secondary_item_id' hook.
@@ -1160,7 +1171,7 @@ function bp_activity_secondary_item_id() {
1160
  /**
1161
  * Filters the activity secondary item ID being displayed.
1162
  *
1163
- * @since BuddyPress (1.2.0)
1164
  *
1165
  * @param int $secondary_item_id The activity secondary item ID.
1166
  */
@@ -1170,7 +1181,7 @@ function bp_activity_secondary_item_id() {
1170
  /**
1171
  * Output the date the activity was recorded.
1172
  *
1173
- * @since BuddyPress (1.2.0)
1174
  *
1175
  * @uses bp_get_activity_date_recorded()
1176
  */
@@ -1181,7 +1192,7 @@ function bp_activity_date_recorded() {
1181
  /**
1182
  * Return the date the activity was recorded.
1183
  *
1184
- * @since BuddyPress (1.2.0)
1185
  *
1186
  * @global object $activities_template {@link BP_Activity_Template}
1187
  * @uses apply_filters() To call the 'bp_get_activity_date_recorded' hook.
@@ -1194,7 +1205,7 @@ function bp_activity_date_recorded() {
1194
  /**
1195
  * Filters the date the activity was recorded.
1196
  *
1197
- * @since BuddyPress (1.2.0)
1198
  *
1199
  * @param int $date_recorded The activity's date.
1200
  */
@@ -1204,7 +1215,7 @@ function bp_activity_date_recorded() {
1204
  /**
1205
  * Output the display name of the member who posted the activity.
1206
  *
1207
- * @since BuddyPress (2.1.0)
1208
  *
1209
  * @uses bp_get_activity_member_display_name()
1210
  */
@@ -1215,7 +1226,7 @@ function bp_activity_member_display_name() {
1215
  /**
1216
  * Return the display name of the member who posted the activity.
1217
  *
1218
- * @since BuddyPress (2.1.0)
1219
  *
1220
  * @global object $activities_template {@link BP_Activity_Template}
1221
  * @uses apply_filters() To call the 'bp_get_activity_member_display_name' hook.
@@ -1232,7 +1243,7 @@ function bp_activity_member_display_name() {
1232
  /**
1233
  * Filters the display name of the member who posted the activity.
1234
  *
1235
- * @since BuddyPress (2.1.0)
1236
  *
1237
  * @param int $retval Display name for the member who posted.
1238
  */
@@ -1242,7 +1253,7 @@ function bp_activity_member_display_name() {
1242
  /**
1243
  * Output the activity object name.
1244
  *
1245
- * @since BuddyPress (1.2.0)
1246
  *
1247
  * @uses bp_get_activity_object_name()
1248
  */
@@ -1253,7 +1264,7 @@ function bp_activity_object_name() {
1253
  /**
1254
  * Return the activity object name.
1255
  *
1256
- * @since BuddyPress (1.2.0)
1257
  *
1258
  * @global object $activities_template {@link BP_Activity_Template}
1259
  * @uses apply_filters() To call the 'bp_get_activity_object_name' hook.
@@ -1266,7 +1277,7 @@ function bp_activity_object_name() {
1266
  /**
1267
  * Filters the activity object name.
1268
  *
1269
- * @since BuddyPress (1.2.0)
1270
  *
1271
  * @param string $activity_component The activity object name.
1272
  */
@@ -1276,7 +1287,7 @@ function bp_activity_object_name() {
1276
  /**
1277
  * Output the activity type.
1278
  *
1279
- * @since BuddyPress (1.2.0)
1280
  *
1281
  * @uses bp_get_activity_type()
1282
  */
@@ -1287,7 +1298,7 @@ function bp_activity_type() {
1287
  /**
1288
  * Return the activity type.
1289
  *
1290
- * @since BuddyPress (1.2.0)
1291
  *
1292
  * @global object $activities_template {@link BP_Activity_Template}
1293
  * @uses apply_filters() To call the 'bp_get_activity_type' hook.
@@ -1300,7 +1311,7 @@ function bp_activity_type() {
1300
  /**
1301
  * Filters the activity type.
1302
  *
1303
- * @since BuddyPress (1.2.0)
1304
  *
1305
  * @param string $activity_type The activity type.
1306
  */
@@ -1312,11 +1323,11 @@ function bp_activity_type() {
1312
  *
1313
  * Just a wrapper for bp_activity_type().
1314
  *
1315
- * @since BuddyPress (1.2.0)
1316
- * @deprecated BuddyPress (1.5.0)
1317
  *
1318
  * @todo Properly deprecate in favor of bp_activity_type() and
1319
- * remove redundant echo
1320
  *
1321
  * @uses bp_activity_type()
1322
  */
@@ -1327,8 +1338,8 @@ function bp_activity_type() {
1327
  *
1328
  * Just a wrapper for bp_get_activity_type().
1329
  *
1330
- * @since BuddyPress (1.2.0)
1331
- * @deprecated BuddyPress (1.5.0)
1332
  *
1333
  * @todo Properly deprecate in favor of bp_get_activity_type().
1334
  *
@@ -1341,7 +1352,7 @@ function bp_activity_type() {
1341
  /**
1342
  * Output the activity user ID.
1343
  *
1344
- * @since BuddyPress (1.1.0)
1345
  *
1346
  * @uses bp_get_activity_user_id()
1347
  */
@@ -1352,7 +1363,7 @@ function bp_activity_user_id() {
1352
  /**
1353
  * Return the activity user ID.
1354
  *
1355
- * @since BuddyPress (1.1.0)
1356
  *
1357
  * @global object $activities_template {@link BP_Activity_Template}
1358
  * @uses apply_filters() To call the 'bp_get_activity_user_id' hook.
@@ -1365,7 +1376,7 @@ function bp_activity_user_id() {
1365
  /**
1366
  * Filters the activity user ID.
1367
  *
1368
- * @since BuddyPress (1.1.0)
1369
  *
1370
  * @param int $user_id The activity user ID.
1371
  */
@@ -1375,7 +1386,7 @@ function bp_activity_user_id() {
1375
  /**
1376
  * Output the activity user link.
1377
  *
1378
- * @since BuddyPress (1.2.0)
1379
  *
1380
  * @uses bp_get_activity_user_link()
1381
  */
@@ -1386,7 +1397,7 @@ function bp_activity_user_link() {
1386
  /**
1387
  * Return the activity user link.
1388
  *
1389
- * @since BuddyPress (1.2.0)
1390
  *
1391
  * @global object $activities_template {@link BP_Activity_Template}
1392
  * @uses bp_core_get_user_domain()
@@ -1406,7 +1417,7 @@ function bp_activity_user_link() {
1406
  /**
1407
  * Filters the activity user link.
1408
  *
1409
- * @since BuddyPress (1.2.0)
1410
  *
1411
  * @param string $link The activity user link.
1412
  */
@@ -1416,7 +1427,7 @@ function bp_activity_user_link() {
1416
  /**
1417
  * Output the avatar of the user that performed the action.
1418
  *
1419
- * @since BuddyPress (1.1.0)
1420
  *
1421
  * @see bp_get_activity_avatar() for description of arguments.
1422
  * @uses bp_get_activity_avatar()
@@ -1429,7 +1440,7 @@ function bp_activity_avatar( $args = '' ) {
1429
  /**
1430
  * Return the avatar of the user that performed the action.
1431
  *
1432
- * @since BuddyPress (1.1.0)
1433
  *
1434
  * @see bp_core_fetch_avatar() For a description of the arguments.
1435
  * @global object $activities_template {@link BP_Activity_Template}
@@ -1460,17 +1471,17 @@ function bp_activity_avatar( $args = '' ) {
1460
 
1461
  $bp = buddypress();
1462
 
1463
- // On activity permalink pages, default to the full-size avatar
1464
  $type_default = bp_is_single_activity() ? 'full' : 'thumb';
1465
 
1466
  // Within the activity comment loop, the current activity should be set
1467
  // to current_comment. Otherwise, just use activity.
1468
  $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity;
1469
 
1470
- // Activity user display name
1471
  $dn_default = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : '';
1472
 
1473
- // Prepend some descriptive text to alt
1474
  $alt_default = !empty( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default ) : __( 'Profile picture', 'buddypress' );
1475
 
1476
  $defaults = array(
@@ -1486,14 +1497,14 @@ function bp_activity_avatar( $args = '' ) {
1486
 
1487
  if ( !isset( $height ) && !isset( $width ) ) {
1488
 
1489
- // Backpat
1490
  if ( isset( $bp->avatar->full->height ) || isset( $bp->avatar->thumb->height ) ) {
1491
  $height = ( 'full' == $type ) ? $bp->avatar->full->height : $bp->avatar->thumb->height;
1492
  } else {
1493
  $height = 20;
1494
  }
1495
 
1496
- // Backpat
1497
  if ( isset( $bp->avatar->full->width ) || isset( $bp->avatar->thumb->width ) ) {
1498
  $width = ( 'full' == $type ) ? $bp->avatar->full->width : $bp->avatar->thumb->width;
1499
  } else {
@@ -1508,7 +1519,7 @@ function bp_activity_avatar( $args = '' ) {
1508
  * Possible hooks are bp_get_activity_avatar_object_blog,
1509
  * bp_get_activity_avatar_object_group, and bp_get_activity_avatar_object_user.
1510
  *
1511
- * @since BuddyPress (1.1.0)
1512
  *
1513
  * @param string $component Component being displayed.
1514
  */
@@ -1518,7 +1529,7 @@ function bp_activity_avatar( $args = '' ) {
1518
  /**
1519
  * Filters the activity avatar item ID.
1520
  *
1521
- * @since BuddyPress (1.2.10)
1522
  *
1523
  * @param int $item_id Item ID for the activity avatar.
1524
  */
@@ -1532,7 +1543,7 @@ function bp_activity_avatar( $args = '' ) {
1532
  /**
1533
  * Filters the value returned by bp_core_fetch_avatar.
1534
  *
1535
- * @since BuddyPress (1.1.3)
1536
  *
1537
  * @param array $value Array of arguments calculated for use with bp_core_fetch_avatar.
1538
  */
@@ -1551,7 +1562,7 @@ function bp_activity_avatar( $args = '' ) {
1551
  /**
1552
  * Output the avatar of the object that action was performed on.
1553
  *
1554
- * @since BuddyPress (1.2.0)
1555
  *
1556
  * @see bp_get_activity_secondary_avatar() for description of arguments.
1557
  * @uses bp_get_activity_secondary_avatar()
@@ -1565,7 +1576,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1565
  /**
1566
  * Return the avatar of the object that action was performed on.
1567
  *
1568
- * @since BuddyPress (1.2.0)
1569
  *
1570
  * @see bp_core_fetch_avatar() for description of arguments.
1571
  * @global object $activities_template {@link BP_Activity_Template}
@@ -1586,7 +1597,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1586
  * @type string|bool $email Default: email of the activity's user.
1587
  * @type int|bool $user_id Default: ID of the activity's user.
1588
  * }
1589
- * @return string The secondary avatar
1590
  */
1591
  function bp_get_activity_secondary_avatar( $args = '' ) {
1592
  global $activities_template;
@@ -1603,7 +1614,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1603
  ) );
1604
  extract( $r, EXTR_SKIP );
1605
 
1606
- // Set item_id and object (default to user)
1607
  switch ( $activities_template->activity->component ) {
1608
  case 'groups' :
1609
  if ( bp_disable_group_avatar_uploads() ) {
@@ -1615,7 +1626,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1615
  $link = '';
1616
  $name = '';
1617
 
1618
- // Only if groups is active
1619
  if ( bp_is_active( 'groups' ) ) {
1620
  $group = groups_get_group( array(
1621
  'group_id' => $item_id,
@@ -1675,7 +1686,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1675
  * bp_get_activity_secondary_avatar_object_blog, bp_get_activity_secondary_avatar_object_group,
1676
  * and bp_get_activity_secondary_avatar_object_user.
1677
  *
1678
- * @since BuddyPress (1.2.10)
1679
  *
1680
  * @param string $object Component being displayed.
1681
  */
@@ -1684,18 +1695,18 @@ function bp_activity_secondary_avatar( $args = '' ) {
1684
  /**
1685
  * Filters the activity secondary avatar item ID.
1686
  *
1687
- * @since BuddyPress (1.2.10)
1688
  *
1689
  * @param int $item_id ID for the secondary avatar item.
1690
  */
1691
  $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
1692
 
1693
- // If we have no item_id or object, there is no avatar to display
1694
  if ( empty( $item_id ) || empty( $object ) ) {
1695
  return false;
1696
  }
1697
 
1698
- // Get the avatar
1699
  $avatar = bp_core_fetch_avatar( array(
1700
  'item_id' => $item_id,
1701
  'object' => $object,
@@ -1712,7 +1723,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1712
  /**
1713
  * Filters the secondary avatar link for current activity.
1714
  *
1715
- * @since BuddyPress (1.7.0)
1716
  *
1717
  * @param string $link Link to wrap the avatar image in.
1718
  * @param string $component Activity component being acted on.
@@ -1722,7 +1733,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
1722
  /**
1723
  * Filters the determined avatar for the secondary activity item.
1724
  *
1725
- * @since BuddyPress (1.2.10)
1726
  *
1727
  * @param string $avatar Formatted HTML <img> element, or raw avatar URL.
1728
  */
@@ -1742,9 +1753,9 @@ function bp_activity_secondary_avatar( $args = '' ) {
1742
  /**
1743
  * Output the activity action.
1744
  *
1745
- * @since BuddyPress (1.2.0)
1746
  *
1747
- * @param array $args See bp_get_activity_action()
1748
  * @uses bp_get_activity_action()
1749
  */
1750
  function bp_activity_action( $args = array() ) {
@@ -1754,10 +1765,9 @@ function bp_activity_action( $args = array() ) {
1754
  /**
1755
  * Return the activity action.
1756
  *
1757
- * @since BuddyPress (1.2.0)
1758
  *
1759
  * @global object $activities_template {@link BP_Activity_Template}
1760
- * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
1761
  * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook.
1762
  * @uses bp_insert_activity_meta()
1763
  * @uses apply_filters_ref_array() To call the 'bp_get_activity_action' hook.
@@ -1778,7 +1788,7 @@ function bp_activity_action( $args = array() ) {
1778
  /**
1779
  * Filters the activity action before the action is inserted as meta.
1780
  *
1781
- * @since BuddyPress (1.2.10)
1782
  *
1783
  * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1784
  */
@@ -1788,7 +1798,7 @@ function bp_activity_action( $args = array() ) {
1788
  $r
1789
  ) );
1790
 
1791
- // Prepend the activity action meta (link, time since, etc...)
1792
  if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
1793
  $action = bp_insert_activity_meta( $action );
1794
  }
@@ -1796,7 +1806,7 @@ function bp_activity_action( $args = array() ) {
1796
  /**
1797
  * Filters the activity action after the action has been inserted as meta.
1798
  *
1799
- * @since BuddyPress (1.2.0)
1800
  *
1801
  * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1802
  */
@@ -1810,7 +1820,7 @@ function bp_activity_action( $args = array() ) {
1810
  /**
1811
  * Output the activity content body.
1812
  *
1813
- * @since BuddyPress (1.2.0)
1814
  *
1815
  * @uses bp_get_activity_content_body()
1816
  */
@@ -1821,7 +1831,7 @@ function bp_activity_content_body() {
1821
  /**
1822
  * Return the activity content body.
1823
  *
1824
- * @since BuddyPress (1.2.0)
1825
  *
1826
  * @global object $activities_template {@link BP_Activity_Template}
1827
  * @uses bp_insert_activity_meta()
@@ -1832,7 +1842,7 @@ function bp_activity_content_body() {
1832
  function bp_get_activity_content_body() {
1833
  global $activities_template;
1834
 
1835
- // Backwards compatibility if action is not being used
1836
  if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) {
1837
  $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
1838
  }
@@ -1840,7 +1850,7 @@ function bp_activity_content_body() {
1840
  /**
1841
  * Filters the activity content body.
1842
  *
1843
- * @since BuddyPress (1.2.0)
1844
  *
1845
  * @param array $value Array containing the current activity content body and the current activity.
1846
  */
@@ -1850,7 +1860,7 @@ function bp_activity_content_body() {
1850
  /**
1851
  * Does the activity have content?
1852
  *
1853
- * @since BuddyPress (1.2.0)
1854
  *
1855
  * @global object $activities_template {@link BP_Activity_Template}
1856
  *
@@ -1869,8 +1879,8 @@ function bp_activity_has_content() {
1869
  /**
1870
  * Output the activity content.
1871
  *
1872
- * @since BuddyPress (1.0.0)
1873
- * @deprecated BuddyPress (1.5.0)
1874
  *
1875
  * @todo properly deprecate this function.
1876
  *
@@ -1883,8 +1893,8 @@ function bp_activity_content() {
1883
  /**
1884
  * Return the activity content.
1885
  *
1886
- * @since BuddyPress (1.0.0)
1887
- * @deprecated BuddyPress (1.5.0)
1888
  *
1889
  * @todo properly deprecate this function.
1890
  *
@@ -1912,7 +1922,7 @@ function bp_activity_content() {
1912
  * This metadata includes the time since the item was posted (which will appear
1913
  * as a link to the item's permalink).
1914
  *
1915
- * @since BuddyPress (1.2.0)
1916
  *
1917
  * @global object $activities_template {@link BP_Activity_Template}
1918
  * @uses bp_core_time_since()
@@ -1924,22 +1934,21 @@ function bp_activity_content() {
1924
  * @uses apply_filters() To call the 'bp_insert_activity_meta' hook.
1925
  *
1926
  * @param string $content The activity content.
1927
- *
1928
  * @return string The activity content with the metadata string attached.
1929
  */
1930
  function bp_insert_activity_meta( $content = '' ) {
1931
  global $activities_template;
1932
 
1933
- // Strip any legacy time since placeholders from BP 1.0-1.1
1934
  $new_content = str_replace( '<span class="time-since">%s</span>', '', $content );
1935
 
1936
- // Get the time since this activity was recorded
1937
  $date_recorded = bp_core_time_since( $activities_template->activity->date_recorded );
1938
 
1939
  /**
1940
  * Filters the activity item time since markup.
1941
  *
1942
- * @since BuddyPress (1.2.0)
1943
  *
1944
  * @param array $value Array containing the time since markup and the current activity component.
1945
  */
@@ -1948,10 +1957,10 @@ function bp_insert_activity_meta( $content = '' ) {
1948
  &$activities_template->activity
1949
  ) );
1950
 
1951
- // Insert the permalink
1952
  if ( ! bp_is_single_activity() ) {
1953
 
1954
- // Setup variables for activity meta
1955
  $activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
1956
  $activity_meta = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>',
1957
  $new_content,
@@ -1963,9 +1972,10 @@ function bp_insert_activity_meta( $content = '' ) {
1963
  /**
1964
  * Filters the activity permalink to be added to the activity content.
1965
  *
1966
- * @since BuddyPress (1.2.0)
1967
  *
1968
- * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
 
1969
  */
1970
  $new_content = apply_filters_ref_array( 'bp_activity_permalink', array(
1971
  $activity_meta,
@@ -1978,7 +1988,7 @@ function bp_insert_activity_meta( $content = '' ) {
1978
  /**
1979
  * Filters the activity content after activity metadata has been attached.
1980
  *
1981
- * @since BuddyPress (1.2.0)
1982
  *
1983
  * @param string $content Activity content with the activity metadata added.
1984
  */
@@ -1988,35 +1998,34 @@ function bp_insert_activity_meta( $content = '' ) {
1988
  /**
1989
  * Determine if the current user can delete an activity item.
1990
  *
1991
- * @since BuddyPress (1.2.0)
1992
  *
1993
  * @global object $activities_template {@link BP_Activity_Template}
1994
  * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook.
1995
  *
1996
  * @param object|bool $activity Optional. Falls back on the current item in the loop.
1997
- *
1998
  * @return bool True if can delete, false otherwise.
1999
  */
2000
  function bp_activity_user_can_delete( $activity = false ) {
2001
  global $activities_template;
2002
 
2003
- // Try to use current activity if none was passed
2004
  if ( empty( $activity ) && ! empty( $activities_template->activity ) ) {
2005
  $activity = $activities_template->activity;
2006
  }
2007
 
2008
- // If current_comment is set, we'll use that in place of the main activity
2009
  if ( isset( $activity->current_comment ) ) {
2010
  $activity = $activity->current_comment;
2011
  }
2012
 
2013
- // Assume the user cannot delete the activity item
2014
  $can_delete = false;
2015
 
2016
- // Only logged in users can delete activity
2017
  if ( is_user_logged_in() ) {
2018
 
2019
- // Community moderators can always delete activity (at least for now)
2020
  if ( bp_current_user_can( 'bp_moderate' ) ) {
2021
  $can_delete = true;
2022
  }
@@ -2028,7 +2037,7 @@ function bp_activity_user_can_delete( $activity = false ) {
2028
  $can_delete = true;
2029
  }
2030
 
2031
- // Viewing a single item, and this user is an admin of that item
2032
  if ( bp_is_single_item() && bp_is_item_admin() ) {
2033
  $can_delete = true;
2034
  }
@@ -2037,7 +2046,7 @@ function bp_activity_user_can_delete( $activity = false ) {
2037
  /**
2038
  * Filters whether the current user can delete an activity item.
2039
  *
2040
- * @since BuddyPress (1.5.0)
2041
  *
2042
  * @param bool $can_delete Whether the user can delete the item.
2043
  * @param object $activity Current activity item object.
@@ -2048,7 +2057,7 @@ function bp_activity_user_can_delete( $activity = false ) {
2048
  /**
2049
  * Output the activity parent content.
2050
  *
2051
- * @since BuddyPress (1.2.0)
2052
  *
2053
  * @see bp_get_activity_parent_content() for a description of arguments.
2054
  * @uses bp_get_activity_parent_content()
@@ -2062,54 +2071,53 @@ function bp_activity_parent_content( $args = '' ) {
2062
  /**
2063
  * Return the activity content.
2064
  *
2065
- * @since BuddyPress (1.2.0)
2066
  *
2067
  * @global object $activities_template {@link BP_Activity_Template}
2068
  * @uses apply_filters() To call the 'bp_get_activity_parent_content' hook.
2069
  *
2070
  * @param string $args Unused. Left over from an earlier implementation.
2071
- *
2072
  * @return mixed False on failure, otherwise the activity parent content.
2073
  */
2074
  function bp_get_activity_parent_content( $args = '' ) {
2075
  global $activities_template;
2076
 
2077
- // Bail if no activity on no item ID
2078
  if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
2079
  return false;
2080
  }
2081
 
2082
- // Get the ID of the parent activity content
2083
  $parent_id = (int) $activities_template->activity->item_id;
2084
 
2085
- // Bail if no parent content
2086
  if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
2087
  return false;
2088
  }
2089
 
2090
- // Bail if no action
2091
  if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
2092
  return false;
2093
  }
2094
 
2095
- // Content always includes action
2096
  $content = $activities_template->activity_parents[ $parent_id ]->action;
2097
 
2098
- // Maybe append activity content, if it exists
2099
  if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
2100
  $content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
2101
  }
2102
 
2103
- // Remove the time since content for backwards compatibility
2104
  $content = str_replace( '<span class="time-since">%s</span>', '', $content );
2105
 
2106
- // Remove images
2107
  $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
2108
 
2109
  /**
2110
  * Filters the activity parent content.
2111
  *
2112
- * @since BuddyPress (1.2.0)
2113
  *
2114
  * @param string $content Content set to be displayed as parent content.
2115
  */
@@ -2119,7 +2127,7 @@ function bp_activity_parent_content( $args = '' ) {
2119
  /**
2120
  * Output the parent activity's user ID.
2121
  *
2122
- * @since BuddyPress (1.7.0)
2123
  */
2124
  function bp_activity_parent_user_id() {
2125
  echo bp_get_activity_parent_user_id();
@@ -2128,7 +2136,7 @@ function bp_activity_parent_user_id() {
2128
  /**
2129
  * Return the parent activity's user ID.
2130
  *
2131
- * @since BuddyPress (1.7.0)
2132
  *
2133
  * @global BP_Activity_Template $activities_template
2134
  *
@@ -2138,20 +2146,20 @@ function bp_activity_parent_user_id() {
2138
  function bp_get_activity_parent_user_id() {
2139
  global $activities_template;
2140
 
2141
- // Bail if no activity on no item ID
2142
  if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
2143
  return false;
2144
  }
2145
 
2146
- // Get the ID of the parent activity content
2147
  $parent_id = (int) $activities_template->activity->item_id;
2148
 
2149
- // Bail if no parent item
2150
  if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
2151
  return false;
2152
  }
2153
 
2154
- // Bail if no parent user ID
2155
  if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) {
2156
  return false;
2157
  }
@@ -2161,7 +2169,7 @@ function bp_activity_parent_user_id() {
2161
  /**
2162
  * Filters the activity parent item's user ID.
2163
  *
2164
- * @since BuddyPress (1.7.0)
2165
  *
2166
  * @param int $retval ID for the activity parent's user.
2167
  */
@@ -2171,7 +2179,7 @@ function bp_activity_parent_user_id() {
2171
  /**
2172
  * Output whether or not the current activity is in a current user's favorites.
2173
  *
2174
- * @since BuddyPress (1.2.0)
2175
  *
2176
  * @uses bp_get_activity_is_favorite()
2177
  */
@@ -2182,7 +2190,7 @@ function bp_activity_is_favorite() {
2182
  /**
2183
  * Return whether the current activity is in a current user's favorites.
2184
  *
2185
- * @since BuddyPress (1.2.0)
2186
  *
2187
  * @global object $activities_template {@link BP_Activity_Template}
2188
  * @uses apply_filters() To call the 'bp_get_activity_is_favorite' hook.
@@ -2195,7 +2203,7 @@ function bp_activity_is_favorite() {
2195
  /**
2196
  * Filters whether the current activity item is in the current user's favorites.
2197
  *
2198
- * @since BuddyPress (1.2.0)
2199
  *
2200
  * @param bool $value Whether or not the current activity item is in the current user's favorites.
2201
  */
@@ -2205,7 +2213,7 @@ function bp_activity_is_favorite() {
2205
  /**
2206
  * Output the comment markup for an activity item.
2207
  *
2208
- * @since BuddyPress (1.2.0)
2209
  *
2210
  * @todo deprecate $args param
2211
  *
@@ -2218,18 +2226,16 @@ function bp_activity_comments( $args = '' ) {
2218
  /**
2219
  * Get the comment markup for an activity item.
2220
  *
2221
- * @since BuddyPress (1.2.0)
2222
  *
2223
  * @todo deprecate $args param
2224
- *
2225
  * @todo Given that checks for children already happen in bp_activity_recurse_comments(),
2226
- * this function can probably be streamlined or removed.
2227
- *
2228
- * @param string $args Unused. Left over from an earlier implementation.
2229
  *
2230
  * @global object $activities_template {@link BP_Activity_Template}
2231
  * @uses bp_activity_recurse_comments()
2232
  *
 
2233
  * @return bool
2234
  */
2235
  function bp_activity_get_comments( $args = '' ) {
@@ -2248,13 +2254,12 @@ function bp_activity_comments( $args = '' ) {
2248
  * Note: The recursion itself used to happen entirely in this function. Now it is
2249
  * split between here and the comment.php template.
2250
  *
2251
- * @since BuddyPress (1.2.0)
2252
- *
2253
- * @param object $comment The activity object currently being recursed.
2254
  *
2255
  * @global object $activities_template {@link BP_Activity_Template}
2256
  * @uses locate_template()
2257
  *
 
2258
  * @return bool|string
2259
  */
2260
  function bp_activity_recurse_comments( $comment ) {
@@ -2271,14 +2276,14 @@ function bp_activity_comments( $args = '' ) {
2271
  /**
2272
  * Filters the opening tag for the template that lists activity comments.
2273
  *
2274
- * @since BuddyPress (1.6.0)
2275
  *
2276
  * @param string $value Opening tag for the HTML markup to use.
2277
  */
2278
  echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>' );
2279
  foreach ( (array) $comment->children as $comment_child ) {
2280
 
2281
- // Put the comment into the global so it's available to filters
2282
  $activities_template->activity->current_comment = $comment_child;
2283
 
2284
  $template = bp_locate_template( 'activity/comment.php', false, false );
@@ -2299,7 +2304,7 @@ function bp_activity_comments( $args = '' ) {
2299
  /**
2300
  * Filters the closing tag for the template that list activity comments.
2301
  *
2302
- * @since BuddyPress (1.6.0)
2303
  *
2304
  * @param string $value Closing tag for the HTML markup to use.
2305
  */
@@ -2309,7 +2314,7 @@ function bp_activity_comments( $args = '' ) {
2309
  /**
2310
  * Utility function that returns the comment currently being recursed.
2311
  *
2312
- * @since BuddyPress (1.5.0)
2313
  *
2314
  * @global object $activities_template {@link BP_Activity_Template}
2315
  * @uses apply_filters() To call the 'bp_activity_current_comment' hook.
@@ -2327,7 +2332,7 @@ function bp_activity_current_comment() {
2327
  /**
2328
  * Filters the current comment being recursed.
2329
  *
2330
- * @since BuddyPress (1.5.0)
2331
  *
2332
  * @param object|bool $current_comment The activity comment currently being displayed. False on failure.
2333
  */
@@ -2338,7 +2343,7 @@ function bp_activity_current_comment() {
2338
  /**
2339
  * Output the ID of the activity comment currently being displayed.
2340
  *
2341
- * @since BuddyPress (1.5.0)
2342
  *
2343
  * @uses bp_get_activity_comment_id()
2344
  */
@@ -2349,7 +2354,7 @@ function bp_activity_comment_id() {
2349
  /**
2350
  * Return the ID of the activity comment currently being displayed.
2351
  *
2352
- * @since BuddyPress (1.5.0)
2353
  *
2354
  * @global object $activities_template {@link BP_Activity_Template}
2355
  * @uses apply_filters() To call the 'bp_activity_comment_id' hook.
@@ -2365,7 +2370,7 @@ function bp_activity_comment_id() {
2365
  /**
2366
  * Filters the ID of the activity comment currently being displayed.
2367
  *
2368
- * @since BuddyPress (1.5.0)
2369
  *
2370
  * @param int|bool $comment_id ID for the comment currently being displayed.
2371
  */
@@ -2375,7 +2380,7 @@ function bp_activity_comment_id() {
2375
  /**
2376
  * Output the ID of the author of the activity comment currently being displayed.
2377
  *
2378
- * @since BuddyPress (1.5.0)
2379
  *
2380
  * @uses bp_get_activity_comment_user_id()
2381
  */
@@ -2386,7 +2391,7 @@ function bp_activity_comment_user_id() {
2386
  /**
2387
  * Return the ID of the author of the activity comment currently being displayed.
2388
  *
2389
- * @since BuddyPress (1.5.0)
2390
  *
2391
  * @global object $activities_template {@link BP_Activity_Template}
2392
  * @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
@@ -2402,7 +2407,7 @@ function bp_activity_comment_user_id() {
2402
  /**
2403
  * Filters the ID of the author of the activity comment currently being displayed.
2404
  *
2405
- * @since BuddyPress (1.5.0)
2406
  *
2407
  * @param int|bool $user_id ID for the author of the comment currently being displayed.
2408
  */
@@ -2412,7 +2417,7 @@ function bp_activity_comment_user_id() {
2412
  /**
2413
  * Output the author link for the activity comment currently being displayed.
2414
  *
2415
- * @since BuddyPress (1.5.0)
2416
  *
2417
  * @uses bp_get_activity_comment_user_link()
2418
  */
@@ -2423,7 +2428,7 @@ function bp_activity_comment_user_link() {
2423
  /**
2424
  * Return the author link for the activity comment currently being displayed.
2425
  *
2426
- * @since BuddyPress (1.5.0)
2427
  *
2428
  * @uses bp_core_get_user_domain()
2429
  * @uses bp_get_activity_comment_user_id()
@@ -2437,7 +2442,7 @@ function bp_activity_comment_user_link() {
2437
  /**
2438
  * Filters the author link for the activity comment currently being displayed.
2439
  *
2440
- * @since BuddyPress (1.5.0)
2441
  *
2442
  * @param string $user_link Link for the author of the activity comment currently being displayed.
2443
  */
@@ -2447,7 +2452,7 @@ function bp_activity_comment_user_link() {
2447
  /**
2448
  * Output the author name for the activity comment currently being displayed.
2449
  *
2450
- * @since BuddyPress (1.5.0)
2451
  *
2452
  * @uses bp_get_activity_comment_name()
2453
  */
@@ -2461,7 +2466,7 @@ function bp_activity_comment_name() {
2461
  * The use of the 'bp_acomment_name' filter is deprecated. Please use
2462
  * 'bp_activity_comment_name'.
2463
  *
2464
- * @since BuddyPress (1.5.0)
2465
  *
2466
  * @global object $activities_template {@link BP_Activity_Template}
2467
  * @uses apply_filters() To call the 'bp_acomment_name' hook.
@@ -2474,7 +2479,7 @@ function bp_activity_comment_name() {
2474
 
2475
  if ( isset( $activities_template->activity->current_comment->user_fullname ) ) {
2476
 
2477
- $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment ); // backward compatibility
2478
  } else {
2479
  $name = $activities_template->activity->current_comment->display_name;
2480
  }
@@ -2482,7 +2487,7 @@ function bp_activity_comment_name() {
2482
  /**
2483
  * Filters the name of the author for the activity comment.
2484
  *
2485
- * @since BuddyPress (1.5.0)
2486
  *
2487
  * @param string $name Name to be displayed with the activity comment.
2488
  */
@@ -2492,7 +2497,7 @@ function bp_activity_comment_name() {
2492
  /**
2493
  * Output the formatted date_recorded of the activity comment currently being displayed.
2494
  *
2495
- * @since BuddyPress (1.5.0)
2496
  *
2497
  * @uses bp_get_activity_comment_date_recorded()
2498
  */
@@ -2503,7 +2508,7 @@ function bp_activity_comment_date_recorded() {
2503
  /**
2504
  * Return the formatted date_recorded for the activity comment currently being displayed.
2505
  *
2506
- * @since BuddyPress (1.5.0)
2507
  *
2508
  * @uses bp_core_time_since()
2509
  * @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook.
@@ -2516,7 +2521,7 @@ function bp_activity_comment_date_recorded() {
2516
  /**
2517
  * Filters the recorded date of the activity comment currently being displayed.
2518
  *
2519
- * @since BuddyPress (1.5.0)
2520
  *
2521
  * @param string|bool Date for the activity comment currently being displayed.
2522
  */
@@ -2526,7 +2531,7 @@ function bp_activity_comment_date_recorded() {
2526
  /**
2527
  * Output the date_recorded of the activity comment currently being displayed.
2528
  *
2529
- * @since BuddyPress (2.3.0)
2530
  *
2531
  * @uses bp_get_activity_comment_date_recorded()
2532
  */
@@ -2537,7 +2542,7 @@ function bp_activity_comment_date_recorded_raw() {
2537
  /**
2538
  * Return the date_recorded for the activity comment currently being displayed.
2539
  *
2540
- * @since BuddyPress (2.3.0)
2541
  *
2542
  * @global object $activities_template {@link BP_Activity_Template}
2543
  * @uses bp_core_time_since()
@@ -2552,7 +2557,7 @@ function bp_activity_comment_date_recorded_raw() {
2552
  /**
2553
  * Filters the raw recorded date of the activity comment currently being displayed.
2554
  *
2555
- * @since BuddyPress (2.3.0)
2556
  *
2557
  * @param string|bool Raw date for the activity comment currently being displayed.
2558
  */
@@ -2562,7 +2567,7 @@ function bp_activity_comment_date_recorded_raw() {
2562
  /**
2563
  * Output the 'delete' URL for the activity comment currently being displayed.
2564
  *
2565
- * @since BuddyPress (1.5.0)
2566
  *
2567
  * @uses bp_get_activity_comment_delete_link()
2568
  */
@@ -2573,7 +2578,7 @@ function bp_activity_comment_delete_link() {
2573
  /**
2574
  * Gets the 'delete' URL for the activity comment currently being displayed.
2575
  *
2576
- * @since BuddyPress (1.5.0)
2577
  *
2578
  * @uses wp_nonce_url()
2579
  * @uses bp_get_root_domain()
@@ -2590,7 +2595,7 @@ function bp_activity_comment_delete_link() {
2590
  /**
2591
  * Filters the link used for deleting the activity comment currently being displayed.
2592
  *
2593
- * @since BuddyPress (1.5.0)
2594
  *
2595
  * @param string $link Link to use for deleting the currently displayed activity comment.
2596
  */
@@ -2600,7 +2605,7 @@ function bp_activity_comment_delete_link() {
2600
  /**
2601
  * Output the content of the activity comment currently being displayed.
2602
  *
2603
- * @since BuddyPress (1.5.0)
2604
  *
2605
  * @uses bp_get_activity_comment_content()
2606
  */
@@ -2616,7 +2621,7 @@ function bp_activity_comment_content() {
2616
  * 'bp_activity_comment_content' to modify the content of activity
2617
  * comments only.
2618
  *
2619
- * @since BuddyPress (1.5.0)
2620
  *
2621
  * @global object $activities_template {@link BP_Activity_Template}
2622
  * @uses apply_filters() To call the 'bp_get_activity_content' hook.
@@ -2633,7 +2638,7 @@ function bp_activity_comment_content() {
2633
  /**
2634
  * Filters the content of the current activity comment.
2635
  *
2636
- * @since BuddyPress (1.2.0)
2637
  *
2638
  * @param string $content The content of the current activity comment.
2639
  */
@@ -2643,7 +2648,7 @@ function bp_activity_comment_content() {
2643
  /**
2644
  * Output the activity comment count.
2645
  *
2646
- * @since BuddyPress (1.2.0)
2647
  *
2648
  * @uses bp_activity_get_comment_count()
2649
  */
@@ -2654,25 +2659,24 @@ function bp_activity_comment_count() {
2654
  /**
2655
  * Return the comment count of an activity item.
2656
  *
2657
- * @since BuddyPress (1.2.0)
2658
  *
2659
  * @global object $activities_template {@link BP_Activity_Template}
2660
  * @uses bp_activity_recurse_comment_count()
2661
  * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook.
2662
  *
2663
- * @param array $deprecated Deprecated.
2664
- *
2665
  * @return int $count The activity comment count.
2666
  */
2667
  function bp_activity_get_comment_count( $deprecated = null ) {
2668
  global $activities_template;
2669
 
2670
- // Deprecated notice about $args
2671
  if ( ! empty( $deprecated ) ) {
2672
  _deprecated_argument( __FUNCTION__, '1.2', sprintf( __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ), __FUNCTION__, __FILE__ ) );
2673
  }
2674
 
2675
- // Get the count using the purpose-built recursive function
2676
  $count = ! empty( $activities_template->activity->children )
2677
  ? bp_activity_recurse_comment_count( $activities_template->activity )
2678
  : 0;
@@ -2680,7 +2684,7 @@ function bp_activity_comment_count() {
2680
  /**
2681
  * Filters the activity comment count.
2682
  *
2683
- * @since BuddyPress (1.2.0)
2684
  *
2685
  * @param int $count The activity comment count.
2686
  */
@@ -2693,22 +2697,21 @@ function bp_activity_comment_count() {
2693
  * This function recursively adds the total number of comments each
2694
  * activity child has, and returns them.
2695
  *
2696
- * @since BuddyPress (1.2.0)
2697
  *
2698
  * @uses bp_activity_recurse_comment_count()
2699
  * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook.
2700
  *
2701
  * @param object $comment Activity comment object.
2702
  * @param int $count The current iteration count.
2703
- *
2704
  * @return int $count The activity comment count.
2705
  */
2706
  function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
2707
 
2708
- // Copy the count
2709
  $new_count = $count;
2710
 
2711
- // Loop through children and recursively count comments
2712
  if ( ! empty( $comment->children ) ) {
2713
  foreach ( (array) $comment->children as $comment ) {
2714
  $new_count++;
@@ -2719,7 +2722,7 @@ function bp_activity_comment_count() {
2719
  /**
2720
  * Filters the total number of comments for the current comment.
2721
  *
2722
- * @since BuddyPress (2.1.0)
2723
  *
2724
  * @param int $new_count New total count for the current comment.
2725
  * @param object $comment Activity comment object.
@@ -2731,7 +2734,7 @@ function bp_activity_comment_count() {
2731
  /**
2732
  * Output the depth of the current activity comment.
2733
  *
2734
- * @since BuddyPress (2.0.0)
2735
  */
2736
  function bp_activity_comment_depth() {
2737
  echo bp_activity_get_comment_depth();
@@ -2739,7 +2742,7 @@ function bp_activity_comment_depth() {
2739
  /**
2740
  * Return the current activity comment depth.
2741
  *
2742
- * @since BuddyPress (2.0.0)
2743
  *
2744
  * @return int $depth Depth for the current activity comment.
2745
  */
@@ -2749,7 +2752,7 @@ function bp_activity_comment_depth() {
2749
  /**
2750
  * Filters the comment depth of the current activity comment.
2751
  *
2752
- * @since BuddyPress (2.0.0)
2753
  *
2754
  * @param int $depth Depth for the current activity comment.
2755
  */
@@ -2759,7 +2762,7 @@ function bp_activity_comment_depth() {
2759
  /**
2760
  * Output the activity comment link.
2761
  *
2762
- * @since BuddyPress (1.2.0)
2763
  *
2764
  * @uses bp_get_activity_comment_link()
2765
  */
@@ -2770,7 +2773,7 @@ function bp_activity_comment_link() {
2770
  /**
2771
  * Return the activity comment link.
2772
  *
2773
- * @since BuddyPress (1.2.0)
2774
  *
2775
  * @global object $activities_template {@link BP_Activity_Template}
2776
  * @uses apply_filters() To call the 'bp_get_activity_comment_link' hook.
@@ -2783,7 +2786,7 @@ function bp_activity_comment_link() {
2783
  /**
2784
  * Filters the comment link for the current activity comment.
2785
  *
2786
- * @since BuddyPress (1.2.0)
2787
  *
2788
  * @param string $value Constructed URL parameters with activity IDs.
2789
  */
@@ -2793,7 +2796,7 @@ function bp_activity_comment_link() {
2793
  /**
2794
  * Output the activity comment form no JavaScript display CSS.
2795
  *
2796
- * @since BuddyPress (1.2.0)
2797
  *
2798
  * @uses bp_get_activity_comment_form_nojs_display()
2799
  */
@@ -2804,7 +2807,7 @@ function bp_activity_comment_form_nojs_display() {
2804
  /**
2805
  * Return the activity comment form no JavaScript display CSS.
2806
  *
2807
- * @since BuddyPress (1.2.0)
2808
  *
2809
  * @global object $activities_template {@link BP_Activity_Template}
2810
  *
@@ -2824,7 +2827,7 @@ function bp_activity_comment_form_nojs_display() {
2824
  /**
2825
  * Output the activity comment form action.
2826
  *
2827
- * @since BuddyPress (1.2.0)
2828
  *
2829
  * @uses bp_get_activity_comment_form_action()
2830
  */
@@ -2835,7 +2838,7 @@ function bp_activity_comment_form_action() {
2835
  /**
2836
  * Return the activity comment form action.
2837
  *
2838
- * @since BuddyPress (1.2.0)
2839
  *
2840
  * @uses home_url()
2841
  * @uses bp_get_activity_root_slug()
@@ -2848,7 +2851,7 @@ function bp_activity_comment_form_action() {
2848
  /**
2849
  * Filters the activity comment form action URL.
2850
  *
2851
- * @since BuddyPress (1.2.0)
2852
  *
2853
  * @param string $value URL to use in the comment form's action attribute.
2854
  */
@@ -2858,7 +2861,7 @@ function bp_activity_comment_form_action() {
2858
  /**
2859
  * Output the activity permalink ID.
2860
  *
2861
- * @since BuddyPress (1.2.0)
2862
  *
2863
  * @uses bp_get_activity_permalink_id()
2864
  */
@@ -2869,7 +2872,7 @@ function bp_activity_permalink_id() {
2869
  /**
2870
  * Return the activity permalink ID.
2871
  *
2872
- * @since BuddyPress (1.2.0)
2873
  *
2874
  * @uses apply_filters() To call the 'bp_get_activity_permalink_id' hook.
2875
  *
@@ -2880,7 +2883,7 @@ function bp_activity_permalink_id() {
2880
  /**
2881
  * Filters the activity action permalink ID.
2882
  *
2883
- * @since BuddyPress (1.2.0)
2884
  *
2885
  * @param string $value Current action for the activity item.
2886
  */
@@ -2890,7 +2893,7 @@ function bp_activity_permalink_id() {
2890
  /**
2891
  * Output the activity thread permalink.
2892
  *
2893
- * @since BuddyPress (1.2.0)
2894
  *
2895
  * @uses bp_get_activity_permalink_id()
2896
  */
@@ -2901,7 +2904,7 @@ function bp_activity_thread_permalink() {
2901
  /**
2902
  * Return the activity thread permalink.
2903
  *
2904
- * @since BuddyPress (1.2.0)
2905
  *
2906
  * @uses bp_activity_get_permalink()
2907
  * @uses apply_filters() To call the 'bp_get_activity_thread_permalink' hook.
@@ -2916,17 +2919,17 @@ function bp_activity_thread_permalink() {
2916
  /**
2917
  * Filters the activity thread permalink.
2918
  *
2919
- * @since BuddyPress (1.2.0)
2920
  *
2921
  * @param string $link The activity thread permalink.
2922
  */
2923
- return apply_filters( 'bp_get_activity_thread_permalink', $link );
2924
  }
2925
 
2926
  /**
2927
  * Output the activity comment permalink.
2928
  *
2929
- * @since BuddyPress (1.8.0)
2930
  *
2931
  * @uses bp_get_activity_permalink_id()
2932
  */
@@ -2936,7 +2939,7 @@ function bp_activity_comment_permalink() {
2936
  /**
2937
  * Return the activity comment permalink.
2938
  *
2939
- * @since BuddyPress (1.8.0)
2940
  *
2941
  * @uses bp_activity_get_permalink()
2942
  * @uses apply_filters() To call the 'bp_get_activity_comment_permalink' hook.
@@ -2946,23 +2949,23 @@ function bp_activity_comment_permalink() {
2946
  function bp_get_activity_comment_permalink() {
2947
  global $activities_template;
2948
 
2949
- // Check that comment exists
2950
  $comment_id = isset( $activities_template->activity->current_comment->id )
2951
  ? $activities_template->activity->current_comment->id
2952
  : 0;
2953
 
2954
- // Setup the comment link
2955
  $comment_link = ! empty( $comment_id )
2956
  ? '#acomment-' .$comment_id
2957
  : false;
2958
 
2959
- // Append comment ID to end of activity permalink
2960
  $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link;
2961
 
2962
  /**
2963
  * Filters the activity comment permalink.
2964
  *
2965
- * @since BuddyPress (1.8.0)
2966
  *
2967
  * @param string $link Activity comment permalink.
2968
  * @param int $comment_id ID for the current activity comment.
@@ -2973,7 +2976,7 @@ function bp_activity_comment_permalink() {
2973
  /**
2974
  * Output the activity favorite link.
2975
  *
2976
- * @since BuddyPress (1.2.0)
2977
  *
2978
  * @uses bp_get_activity_favorite_link()
2979
  */
@@ -2984,7 +2987,7 @@ function bp_activity_favorite_link() {
2984
  /**
2985
  * Return the activity favorite link.
2986
  *
2987
- * @since BuddyPress (1.2.0)
2988
  *
2989
  * @global object $activities_template {@link BP_Activity_Template}
2990
  * @uses wp_nonce_url()
@@ -3000,7 +3003,7 @@ function bp_activity_favorite_link() {
3000
  /**
3001
  * Filters the activity favorite link.
3002
  *
3003
- * @since BuddyPress (1.2.0)
3004
  *
3005
  * @param string $value Constructed link for favoriting the activity comment.
3006
  */
@@ -3010,7 +3013,7 @@ function bp_activity_favorite_link() {
3010
  /**
3011
  * Output the activity unfavorite link.
3012
  *
3013
- * @since BuddyPress (1.2.0)
3014
  *
3015
  * @uses bp_get_activity_unfavorite_link()
3016
  */
@@ -3021,7 +3024,7 @@ function bp_activity_unfavorite_link() {
3021
  /**
3022
  * Return the activity unfavorite link.
3023
  *
3024
- * @since BuddyPress (1.2.0)
3025
  *
3026
  * @global object $activities_template {@link BP_Activity_Template}
3027
  * @uses wp_nonce_url()
@@ -3037,7 +3040,7 @@ function bp_activity_unfavorite_link() {
3037
  /**
3038
  * Filters the activity unfavorite link.
3039
  *
3040
- * @since BuddyPress (1.2.0)
3041
  *
3042
  * @param string $value Constructed link for unfavoriting the activity comment.
3043
  */
@@ -3047,7 +3050,7 @@ function bp_activity_unfavorite_link() {
3047
  /**
3048
  * Output the activity CSS class.
3049
  *
3050
- * @since BuddyPress (1.0.0)
3051
  *
3052
  * @uses bp_get_activity_css_class()
3053
  */
@@ -3058,7 +3061,7 @@ function bp_activity_css_class() {
3058
  /**
3059
  * Return the current activity item's CSS class.
3060
  *
3061
- * @since BuddyPress (1.0.0)
3062
  *
3063
  * @global object $activities_template {@link BP_Activity_Template}
3064
  * @uses apply_filters() To call the 'bp_activity_mini_activity_types' hook.
@@ -3074,7 +3077,7 @@ function bp_activity_css_class() {
3074
  /**
3075
  * Filters the available mini activity actions available as CSS classes.
3076
  *
3077
- * @since BuddyPress (1.2.0)
3078
  *
3079
  * @param array $value Array of classes used to determine classes applied to HTML element.
3080
  */
@@ -3100,7 +3103,7 @@ function bp_activity_css_class() {
3100
  /**
3101
  * Filters the determined classes to add to the HTML element.
3102
  *
3103
- * @since BuddyPress (1.0.0)
3104
  *
3105
  * @param string $value Classes to be added to the HTML element.
3106
  */
@@ -3110,7 +3113,7 @@ function bp_activity_css_class() {
3110
  /**
3111
  * Output the activity delete link.
3112
  *
3113
- * @since BuddyPress (1.1.0)
3114
  *
3115
  * @uses bp_get_activity_delete_link()
3116
  */
@@ -3121,7 +3124,7 @@ function bp_activity_delete_link() {
3121
  /**
3122
  * Return the activity delete link.
3123
  *
3124
- * @since BuddyPress (1.1.0)
3125
  *
3126
  * @global object $activities_template {@link BP_Activity_Template}
3127
  * @uses bp_get_root_domain()
@@ -3140,7 +3143,7 @@ function bp_activity_delete_link() {
3140
  $url = bp_get_activity_delete_url();
3141
  $class = 'delete-activity';
3142
 
3143
- // Determine if we're on a single activity page, and customize accordingly
3144
  if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
3145
  $class = 'delete-activity-single';
3146
  }
@@ -3150,7 +3153,7 @@ function bp_activity_delete_link() {
3150
  /**
3151
  * Filters the activity delete link.
3152
  *
3153
- * @since BuddyPress (1.1.0)
3154
  *
3155
  * @param string $link Activity delete HTML link.
3156
  */
@@ -3160,7 +3163,7 @@ function bp_activity_delete_link() {
3160
  /**
3161
  * Output the URL to delete a single activity stream item.
3162
  *
3163
- * @since BuddyPress (2.1.0)
3164
  *
3165
  * @uses bp_get_activity_delete_link()
3166
  */
@@ -3170,7 +3173,7 @@ function bp_activity_delete_url() {
3170
  /**
3171
  * Return the URL to delete a single activity item.
3172
  *
3173
- * @since BuddyPress (2.1.0)
3174
  *
3175
  * @global object $activities_template {@link BP_Activity_Template}
3176
  * @uses bp_get_root_domain()
@@ -3190,7 +3193,7 @@ function bp_activity_delete_url() {
3190
 
3191
  $url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id );
3192
 
3193
- // Determine if we're on a single activity page, and customize accordingly
3194
  if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
3195
  $url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
3196
  }
@@ -3200,7 +3203,7 @@ function bp_activity_delete_url() {
3200
  /**
3201
  * Filters the activity delete URL.
3202
  *
3203
- * @since BuddyPress (2.1.0)
3204
  *
3205
  * @param string $url Activity delete URL.
3206
  */
@@ -3210,7 +3213,7 @@ function bp_activity_delete_url() {
3210
  /**
3211
  * Output the activity latest update link.
3212
  *
3213
- * @since BuddyPress (1.2.0)
3214
  *
3215
  * @see bp_get_activity_latest_update() for description of parameters.
3216
  * @uses bp_get_activity_latest_update()
@@ -3224,7 +3227,7 @@ function bp_activity_latest_update( $user_id = 0 ) {
3224
  /**
3225
  * Return the activity latest update link.
3226
  *
3227
- * @since BuddyPress (1.2.0)
3228
  *
3229
  * @uses bp_is_user_inactive()
3230
  * @uses bp_core_is_user_deleted()
@@ -3236,7 +3239,6 @@ function bp_activity_latest_update( $user_id = 0 ) {
3236
  * @uses apply_filters() To call the 'bp_get_activity_latest_update' hook.
3237
  *
3238
  * @param int $user_id If empty, will fall back on displayed user.
3239
- *
3240
  * @return string|bool $latest_update The activity latest update link.
3241
  * False on failure.
3242
  */
@@ -3257,7 +3259,7 @@ function bp_activity_latest_update( $user_id = 0 ) {
3257
  /**
3258
  * Filters the latest update excerpt.
3259
  *
3260
- * @since BuddyPress (1.2.10)
3261
  *
3262
  * @param string $value The excerpt for the latest update.
3263
  */
@@ -3273,7 +3275,7 @@ function bp_activity_latest_update( $user_id = 0 ) {
3273
  /**
3274
  * Filters the latest update excerpt with view link appended to the end.
3275
  *
3276
- * @since BuddyPress (1.2.0)
3277
  *
3278
  * @param string $latest_update The latest update with "view" link appended to it.
3279
  */
@@ -3283,7 +3285,7 @@ function bp_activity_latest_update( $user_id = 0 ) {
3283
  /**
3284
  * Output the activity filter links.
3285
  *
3286
- * @since BuddyPress (1.1.0)
3287
  *
3288
  * @see bp_get_activity_filter_links() for description of parameters.
3289
  * @uses bp_get_activity_filter_links()
@@ -3297,7 +3299,7 @@ function bp_activity_filter_links( $args = false ) {
3297
  /**
3298
  * Return the activity filter links.
3299
  *
3300
- * @since BuddyPress (1.1.0)
3301
  *
3302
  * @uses wp_parse_args()
3303
  * @uses BP_Activity_Activity::get_recorded_components() {@link BP_Activity_Activity}
@@ -3320,10 +3322,10 @@ function bp_activity_filter_links( $args = false ) {
3320
  'style' => 'list'
3321
  ) );
3322
 
3323
- // Define local variable
3324
  $component_links = array();
3325
 
3326
- // Fetch the names of components that have activity recorded in the DB
3327
  $components = BP_Activity_Activity::get_recorded_components();
3328
 
3329
  if ( empty( $components ) ) {
@@ -3332,7 +3334,7 @@ function bp_activity_filter_links( $args = false ) {
3332
 
3333
  foreach ( (array) $components as $component ) {
3334
 
3335
- // Skip the activity comment filter
3336
  if ( 'activity' == $component ) {
3337
  continue;
3338
  }
@@ -3369,7 +3371,7 @@ function bp_activity_filter_links( $args = false ) {
3369
  /**
3370
  * Filters the activity filter link URL for the current activity component.
3371
  *
3372
- * @since BuddyPress (1.1.0)
3373
  *
3374
  * @param string $link The URL for the current component.
3375
  * @param string $component The current component getting links constructed for.
@@ -3388,7 +3390,7 @@ function bp_activity_filter_links( $args = false ) {
3388
  /**
3389
  * Filters all of the constructed filter links.
3390
  *
3391
- * @since BuddyPress (1.1.0)
3392
  *
3393
  * @param string $value All of the links to be displayed to the user.
3394
  */
@@ -3398,7 +3400,7 @@ function bp_activity_filter_links( $args = false ) {
3398
  /**
3399
  * Determine if a comment can be made on an activity item.
3400
  *
3401
- * @since BuddyPress (1.2.0)
3402
  *
3403
  * @global object $activities_template {@link BP_Activity_Template}
3404
  * @uses bp_get_activity_action_name()
@@ -3410,10 +3412,10 @@ function bp_activity_can_comment() {
3410
  global $activities_template;
3411
  $bp = buddypress();
3412
 
3413
- // Assume activity can be commented on
3414
  $can_comment = true;
3415
 
3416
- // Determine ability to comment based on activity action name
3417
  $activity_action = bp_get_activity_action_name();
3418
 
3419
  $turn_off = 0;
@@ -3446,7 +3448,7 @@ function bp_activity_can_comment() {
3446
  /**
3447
  * Filters whether a comment can be made on an activity item.
3448
  *
3449
- * @since BuddyPress (1.5.0)
3450
  *
3451
  * @param bool $can_comment Status on if activity can be commented on.
3452
  * @param string $activity_action Current activity action being checked on.
@@ -3457,7 +3459,7 @@ function bp_activity_can_comment() {
3457
  /**
3458
  * Determine whether a comment can be made on an activity reply item.
3459
  *
3460
- * @since BuddyPress (1.5.0)
3461
  *
3462
  * @param bool|object $comment Activity comment.
3463
  * @return bool $can_comment True if comment can receive comments,
@@ -3465,26 +3467,26 @@ function bp_activity_can_comment() {
3465
  */
3466
  function bp_activity_can_comment_reply( $comment = false ) {
3467
 
3468
- // Assume activity can be commented on
3469
  $can_comment = true;
3470
 
3471
- // Check that comment exists
3472
  if ( empty( $comment ) ) {
3473
  $comment = bp_activity_current_comment();
3474
  }
3475
 
3476
  if ( ! empty( $comment ) ) {
3477
 
3478
- // Fall back on current comment in activity loop
3479
  $comment_depth = isset( $comment->depth )
3480
  ? intval( $comment->depth )
3481
  : bp_activity_get_comment_depth();
3482
 
3483
- // Threading is turned on, so check the depth
3484
  if ( get_option( 'thread_comments' ) ) {
3485
  $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
3486
 
3487
- // No threading for comment replies if no threading for comments
3488
  } else {
3489
  $can_comment = false;
3490
  }
@@ -3493,7 +3495,7 @@ function bp_activity_can_comment_reply( $comment = false ) {
3493
  /**
3494
  * Filters whether a comment can be made on an activity reply item.
3495
  *
3496
- * @since BuddyPress (1.5.0)
3497
  *
3498
  * @param bool $can_comment Status on if activity reply can be commented on.
3499
  * @param string $comment Current comment being checked on.
@@ -3506,7 +3508,7 @@ function bp_activity_can_comment_reply( $comment = false ) {
3506
  *
3507
  * Defaults to true, but can be modified by plugins.
3508
  *
3509
- * @since BuddyPress (1.5.0)
3510
  *
3511
  * @uses apply_filters() To call the 'bp_activity_can_favorite' hook.
3512
  *
@@ -3517,7 +3519,7 @@ function bp_activity_can_favorite() {
3517
  /**
3518
  * Filters whether or not users can favorite activity items.
3519
  *
3520
- * @since BuddyPress (1.5.0)
3521
  *
3522
  * @param bool $value Whether or not favoriting is enabled.
3523
  */
@@ -3527,7 +3529,7 @@ function bp_activity_can_favorite() {
3527
  /**
3528
  * Output the total favorite count for a specified user.
3529
  *
3530
- * @since BuddyPress (1.2.0)
3531
  *
3532
  * @see bp_get_total_favorite_count_for_user() for description of parameters.
3533
  * @uses bp_get_total_favorite_count_for_user()
@@ -3541,25 +3543,24 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
3541
  /**
3542
  * Return the total favorite count for a specified user.
3543
  *
3544
- * @since BuddyPress (1.2.0)
3545
  *
3546
  * @uses bp_activity_total_favorites_for_user()
3547
  * @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook.
3548
  *
3549
  * @param int $user_id ID of user being queried. Default: displayed user ID.
3550
- *
3551
  * @return int The total favorite count for the specified user.
3552
  */
3553
  function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
3554
  $retval = false;
3555
 
3556
  if ( bp_activity_can_favorite() ) {
3557
- // Default to displayed user if none is passed
3558
  $user_id = empty( $user_id )
3559
  ? bp_displayed_user_id()
3560
  : $user_id;
3561
 
3562
- // Get user meta if user ID exists
3563
  if ( ! empty( $user_id ) ) {
3564
  $retval = bp_activity_total_favorites_for_user( $user_id );
3565
  }
@@ -3568,7 +3569,7 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
3568
  /**
3569
  * Filters the total favorite count for a user.
3570
  *
3571
- * @since BuddyPress (1.2.0)
3572
  *
3573
  * @param int|bool $retval Total favorite count for a user. False on no favorites.
3574
  */
@@ -3579,7 +3580,7 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
3579
  /**
3580
  * Output the total mention count for a specified user.
3581
  *
3582
- * @since BuddyPress (1.2.0)
3583
  *
3584
  * @see bp_get_total_mention_count_for_user() for description of parameters.
3585
  * @uses bp_get_total_favorite_count_for_user()
@@ -3593,23 +3594,22 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
3593
  /**
3594
  * Return the total mention count for a specified user.
3595
  *
3596
- * @since BuddyPress (1.2.0)
3597
  *
3598
  * @uses bp_get_user_meta()
3599
  * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
3600
  *
3601
  * @param int $user_id ID of user being queried. Default: displayed user ID.
3602
- *
3603
  * @return int The total mention count for the specified user.
3604
  */
3605
  function bp_get_total_mention_count_for_user( $user_id = 0 ) {
3606
 
3607
- // Default to displayed user if none is passed
3608
  $user_id = empty( $user_id )
3609
  ? bp_displayed_user_id()
3610
  : $user_id;
3611
 
3612
- // Get user meta if user ID exists
3613
  $retval = ! empty( $user_id )
3614
  ? bp_get_user_meta( $user_id, 'bp_new_mention_count', true )
3615
  : false;
@@ -3617,7 +3617,7 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
3617
  /**
3618
  * Filters the total mention count for a user.
3619
  *
3620
- * @since BuddyPress (1.2.0)
3621
  *
3622
  * @param int|bool $retval Total mention count for a user. False on no mentions.
3623
  */
@@ -3627,7 +3627,7 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
3627
  /**
3628
  * Output the public message link for displayed user.
3629
  *
3630
- * @since BuddyPress (1.2.0)
3631
  *
3632
  * @uses bp_get_send_public_message_link()
3633
  */
@@ -3638,7 +3638,7 @@ function bp_send_public_message_link() {
3638
  /**
3639
  * Return the public message link for the displayed user.
3640
  *
3641
- * @since BuddyPress (1.2.0)
3642
  *
3643
  * @uses is_user_logged_in()
3644
  * @uses bp_is_my_profile()
@@ -3651,7 +3651,7 @@ function bp_send_public_message_link() {
3651
  */
3652
  function bp_get_send_public_message_link() {
3653
 
3654
- // No link if not logged in, not looking at someone else's profile
3655
  if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() ) {
3656
  $retval = '';
3657
  } else {
@@ -3663,7 +3663,7 @@ function bp_send_public_message_link() {
3663
  /**
3664
  * Filters the public message link for the displayed user.
3665
  *
3666
- * @since BuddyPress (1.2.0)
3667
  *
3668
  * @param string $retval The URL for the public message link.
3669
  */
@@ -3673,11 +3673,10 @@ function bp_send_public_message_link() {
3673
  /**
3674
  * Recurse through all activity comments and return the activity comment IDs.
3675
  *
3676
- * @since BuddyPress (2.0.0)
3677
  *
3678
  * @param array $activity Array of activities generated from {@link bp_activity_get()}.
3679
  * @param array $activity_ids Used for recursion purposes in this function.
3680
- *
3681
  * @return array
3682
  */
3683
  function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) {
@@ -3701,7 +3700,7 @@ function bp_activity_recurse_comments_activity_ids( $activity = array(), $activi
3701
  /**
3702
  * Output the mentioned user display name.
3703
  *
3704
- * @since BuddyPress (1.2.0)
3705
  *
3706
  * @see bp_get_mentioned_user_display_name() for description of parameters.
3707
  * @uses bp_get_mentioned_user_display_name()
@@ -3715,21 +3714,20 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3715
  /**
3716
  * Returns the mentioned user display name.
3717
  *
3718
- * @since BuddyPress (1.2.0)
3719
  *
3720
  * @uses bp_core_get_user_displayname()
3721
  * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
3722
  *
3723
- * @param int|string|bool User ID or username.
3724
- *
3725
  * @return string The mentioned user's display name.
3726
  */
3727
  function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
3728
 
3729
- // Get user display name
3730
  $name = bp_core_get_user_displayname( $user_id_or_username );
3731
 
3732
- // If user somehow has no name, return this really lame string
3733
  if ( empty( $name ) ) {
3734
  $name = __( 'a user', 'buddypress' );
3735
  }
@@ -3737,7 +3735,7 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3737
  /**
3738
  * Filters the mentioned user display name.
3739
  *
3740
- * @since BuddyPress (1.2.0)
3741
  *
3742
  * @param string $name Display name for the mentioned user.
3743
  * @param int|string $user_id_or_username User ID or username use for query.
@@ -3748,7 +3746,7 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3748
  /**
3749
  * Output button for sending a public message (an @-mention).
3750
  *
3751
- * @since BuddyPress (1.2.0)
3752
  *
3753
  * @see bp_get_send_public_message_button() for description of parameters.
3754
  * @uses bp_get_send_public_message_button()
@@ -3762,7 +3760,7 @@ function bp_send_public_message_button( $args = '' ) {
3762
  /**
3763
  * Return button for sending a public message (an @-mention).
3764
  *
3765
- * @since BuddyPress (1.2.0)
3766
  *
3767
  * @uses bp_get_send_public_message_link()
3768
  * @uses wp_parse_args()
@@ -3803,7 +3801,7 @@ function bp_send_public_message_button( $args = '' ) {
3803
  /**
3804
  * Filters the public message button HTML.
3805
  *
3806
- * @since BuddyPress (1.2.10)
3807
  *
3808
  * @param array $r Array of arguments for the public message button HTML.
3809
  */
@@ -3813,7 +3811,7 @@ function bp_send_public_message_button( $args = '' ) {
3813
  /**
3814
  * Output the activity post form action.
3815
  *
3816
- * @since BuddyPress (1.2.0)
3817
  *
3818
  * @uses bp_get_activity_post_form_action()
3819
  */
@@ -3824,7 +3822,7 @@ function bp_activity_post_form_action() {
3824
  /**
3825
  * Return the activity post form action.
3826
  *
3827
- * @since BuddyPress (1.2.0)
3828
  *
3829
  * @uses home_url()
3830
  * @uses bp_get_activity_root_slug()
@@ -3837,7 +3835,7 @@ function bp_activity_post_form_action() {
3837
  /**
3838
  * Filters the action url used for the activity post form.
3839
  *
3840
- * @since BuddyPress (1.2.0)
3841
  *
3842
  * @param string $value URL to be used for the activity post form.
3843
  */
@@ -3852,7 +3850,7 @@ function bp_activity_post_form_action() {
3852
  * Avatars are wrapped in <li> elements, but you've got to provide your own
3853
  * <ul> or <ol> wrapper markup.
3854
  *
3855
- * @since BuddyPress (1.7.0)
3856
  *
3857
  * @see bp_core_fetch_avatar() for a description of arguments.
3858
  *
@@ -3867,7 +3865,7 @@ function bp_activity_comments_user_avatars( $args = array() ) {
3867
  'width' => false,
3868
  ) );
3869
 
3870
- // Get the user IDs of everyone who has left a comment to the current activity item
3871
  $user_ids = bp_activity_get_comments_user_ids();
3872
  $output = array();
3873
  $retval = '';
@@ -3875,15 +3873,15 @@ function bp_activity_comments_user_avatars( $args = array() ) {
3875
  if ( ! empty( $user_ids ) ) {
3876
  foreach ( (array) $user_ids as $user_id ) {
3877
 
3878
- // Skip an empty user ID
3879
  if ( empty( $user_id ) ) {
3880
  continue;
3881
  }
3882
 
3883
- // Get profile link for this user
3884
  $profile_link = bp_core_get_user_domain( $user_id );
3885
 
3886
- // Get avatar for this user
3887
  $image_html = bp_core_fetch_avatar( array(
3888
  'item_id' => $user_id,
3889
  'height' => $r['height'],
@@ -3892,13 +3890,13 @@ function bp_activity_comments_user_avatars( $args = array() ) {
3892
  'width' => $r['width']
3893
  ) );
3894
 
3895
- // If user has link & avatar, add them to the output array
3896
  if ( ! empty( $profile_link ) && ! empty( $image_html ) ) {
3897
  $output[] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $profile_link ), $image_html );
3898
  }
3899
  }
3900
 
3901
- // If output array is not empty, wrap everything in some list items
3902
  if ( ! empty( $output ) ) {
3903
  $retval = '<li>' . implode( '</li><li>', $output ) . '</li>';
3904
  }
@@ -3907,7 +3905,7 @@ function bp_activity_comments_user_avatars( $args = array() ) {
3907
  /**
3908
  * Filters the list of linked avatars for users who have commented on the current activity item.
3909
  *
3910
- * @since BuddyPress (1.7.0)
3911
  *
3912
  * @param string $retval HTML markup for the list of avatars.
3913
  * @param array $r Array of arguments used for each avatar.
@@ -3919,7 +3917,7 @@ function bp_activity_comments_user_avatars( $args = array() ) {
3919
  /**
3920
  * Return the IDs of every user who's left a comment on the current activity item.
3921
  *
3922
- * @since BuddyPress (1.7.0)
3923
  *
3924
  * @return bool|array An array of IDs, or false if none are found.
3925
  */
@@ -3933,7 +3931,7 @@ function bp_activity_get_comments_user_ids() {
3933
  /**
3934
  * Filters the list of user IDs for the current activity item.
3935
  *
3936
- * @since BuddyPress (1.7.0)
3937
  *
3938
  * @param array $value Array of unique user IDs for the current activity item.
3939
  */
@@ -3943,18 +3941,17 @@ function bp_activity_get_comments_user_ids() {
3943
  /**
3944
  * Recurse through all activity comments and collect the IDs of the users who wrote them.
3945
  *
3946
- * @since BuddyPress (1.7.0)
3947
  *
3948
  * @param array $comments Array of {@link BP_Activity_Activity} items.
3949
- *
3950
  * @return array Array of user IDs.
3951
  */
3952
  function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
3953
 
3954
- // Default user ID's array
3955
  $user_ids = array();
3956
 
3957
- // Loop through comments and try to get user ID's
3958
  if ( ! empty( $comments ) ) {
3959
  foreach ( $comments as $comment ) {
3960
 
@@ -3964,10 +3961,10 @@ function bp_activity_get_comments_user_ids() {
3964
  continue;
3965
  }
3966
 
3967
- // Add user ID to array
3968
  $user_ids[] = $comment->user_id;
3969
 
3970
- // Check for commentception
3971
  if ( ! empty( $comment->children ) ) {
3972
  $user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) );
3973
  }
@@ -3977,7 +3974,7 @@ function bp_activity_get_comments_user_ids() {
3977
  /**
3978
  * Filters the list of user IDs for the current activity comment item.
3979
  *
3980
- * @since BuddyPress (2.1.0)
3981
  *
3982
  * @param array $user_ids Array of user IDs for the current activity comment item.
3983
  * @param array $comments Array of comments being checked for user IDs.
@@ -3988,7 +3985,7 @@ function bp_activity_get_comments_user_ids() {
3988
  /**
3989
  * Output the mentionname for the displayed user.
3990
  *
3991
- * @since BuddyPress (1.9.0)
3992
  */
3993
  function bp_displayed_user_mentionname() {
3994
  echo bp_get_displayed_user_mentionname();
@@ -3996,7 +3993,7 @@ function bp_displayed_user_mentionname() {
3996
  /**
3997
  * Get the mentionname for the displayed user.
3998
  *
3999
- * @since BuddyPress (1.9.0)
4000
  *
4001
  * @return string Mentionname for the displayed user, if available.
4002
  */
@@ -4005,7 +4002,7 @@ function bp_displayed_user_mentionname() {
4005
  /**
4006
  * Filters the mentionname for the displayed user.
4007
  *
4008
- * @since BuddyPress (1.9.0)
4009
  *
4010
  * @param string $value The mentionanme for the displayed user.
4011
  */
@@ -4015,7 +4012,7 @@ function bp_displayed_user_mentionname() {
4015
  /**
4016
  * Echo a list of all registered activity types for use in dropdowns or checkbox lists.
4017
  *
4018
- * @since BuddyPress (1.7.0)
4019
  *
4020
  * @param string $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
4021
  * @param array|string $args {
@@ -4036,14 +4033,14 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
4036
  $activities = bp_activity_get_types();
4037
  natsort( $activities );
4038
 
4039
- // Loop through the activity types and output markup
4040
  foreach ( $activities as $type => $description ) {
4041
 
4042
- // See if we need to preselect the current type
4043
  $checked = checked( true, in_array( $type, (array) $args['selected'] ), false );
4044
  $selected = selected( true, in_array( $type, (array) $args['selected'] ), false );
4045
 
4046
- // Switch output based on the element
4047
  switch ( $output ) {
4048
  case 'select' :
4049
  printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $type ), $selected, esc_html( $description ) );
@@ -4059,7 +4056,7 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
4059
  * This is a variable action hook. The actual hook to use will depend on the output type specified.
4060
  * Two default hooks are bp_activity_types_list_select and bp_activity_types_list_checkbox.
4061
  *
4062
- * @since BuddyPress (1.7.0)
4063
  *
4064
  * @param array $args Array of arguments passed into function.
4065
  * @param string $type Activity type being rendered in the output.
@@ -4068,7 +4065,7 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
4068
  do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
4069
  }
4070
 
4071
- // Backpat with BP-Default for dropdown boxes only
4072
  if ( 'select' === $output ) {
4073
  do_action( 'bp_activity_filter_options' );
4074
  }
@@ -4080,7 +4077,7 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
4080
  /**
4081
  * Output the sitewide activity feed link.
4082
  *
4083
- * @since BuddyPress (1.0.0)
4084
  *
4085
  * @uses bp_get_sitewide_activity_feed_link()
4086
  */
@@ -4091,7 +4088,7 @@ function bp_sitewide_activity_feed_link() {
4091
  /**
4092
  * Returns the sitewide activity feed link.
4093
  *
4094
- * @since BuddyPress (1.0.0)
4095
  *
4096
  * @uses home_url()
4097
  * @uses bp_get_activity_root_slug()
@@ -4104,7 +4101,7 @@ function bp_sitewide_activity_feed_link() {
4104
  /**
4105
  * Filters the sidewide activity feed link.
4106
  *
4107
- * @since BuddyPress (1.0.0)
4108
  *
4109
  * @param string $value The feed link for sitewide activity.
4110
  */
@@ -4114,7 +4111,7 @@ function bp_sitewide_activity_feed_link() {
4114
  /**
4115
  * Output the member activity feed link.
4116
  *
4117
- * @since BuddyPress (1.2.0)
4118
  *
4119
  * @uses bp_get_member_activity_feed_link()
4120
  */
@@ -4125,8 +4122,8 @@ function bp_member_activity_feed_link() {
4125
  /**
4126
  * Output the member activity feed link.
4127
  *
4128
- * @since BuddyPress (1.0.0)
4129
- * @deprecated BuddyPress (1.2.0)
4130
  *
4131
  * @todo properly deprecate in favor of bp_member_activity_feed_link().
4132
  *
@@ -4137,7 +4134,7 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
4137
  /**
4138
  * Return the member activity feed link.
4139
  *
4140
- * @since BuddyPress (1.2.0)
4141
  *
4142
  * @uses bp_is_profile_component()
4143
  * @uses bp_is_current_action()
@@ -4152,27 +4149,27 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
4152
  */
4153
  function bp_get_member_activity_feed_link() {
4154
 
4155
- // Single member activity feed link
4156
  if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
4157
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
4158
 
4159
- // Friend feed link
4160
  } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
4161
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
4162
 
4163
- // Group feed link
4164
  } elseif ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
4165
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
4166
 
4167
- // Favorites activity feed link
4168
  } elseif ( 'favorites' === bp_current_action() ) {
4169
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
4170
 
4171
- // Mentions activity feed link
4172
  } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
4173
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
4174
 
4175
- // No feed link
4176
  } else {
4177
  $link = '';
4178
  }
@@ -4180,7 +4177,7 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
4180
  /**
4181
  * Filters the member activity feed link.
4182
  *
4183
- * @since BuddyPress (1.0.0)
4184
  *
4185
  * @param string $link URL for the member activity feed.
4186
  */
@@ -4190,8 +4187,8 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
4190
  /**
4191
  * Return the member activity feed link.
4192
  *
4193
- * @since BuddyPress (1.0.0)
4194
- * @deprecated BuddyPress (1.2.0)
4195
  *
4196
  * @todo properly deprecate in favor of bp_get_member_activity_feed_link().
4197
  *
@@ -4207,7 +4204,7 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
4207
  /**
4208
  * Outputs the activity feed item guid.
4209
  *
4210
- * @since BuddyPress (1.0.0)
4211
  *
4212
  * @uses bp_activity_feed_item_guid()
4213
  */
@@ -4218,7 +4215,7 @@ function bp_activity_feed_item_guid() {
4218
  /**
4219
  * Returns the activity feed item guid.
4220
  *
4221
- * @since BuddyPress (1.2.0)
4222
  *
4223
  * @global object $activities_template {@link BP_Activity_Template}
4224
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_guid' hook.
@@ -4231,7 +4228,7 @@ function bp_activity_feed_item_guid() {
4231
  /**
4232
  * Filters the activity feed item guid.
4233
  *
4234
- * @since BuddyPress (1.1.3)
4235
  *
4236
  * @param string $value Calculated md5 value for the activity feed item.
4237
  */
@@ -4241,7 +4238,7 @@ function bp_activity_feed_item_guid() {
4241
  /**
4242
  * Output the activity feed item title.
4243
  *
4244
- * @since BuddyPress (1.0.0)
4245
  *
4246
  * @uses bp_get_activity_feed_item_title()
4247
  */
@@ -4252,7 +4249,7 @@ function bp_activity_feed_item_title() {
4252
  /**
4253
  * Return the activity feed item title.
4254
  *
4255
- * @since BuddyPress (1.0.0)
4256
  *
4257
  * @global object $activities_template {@link BP_Activity_Template}
4258
  * @uses ent2ncr()
@@ -4285,7 +4282,7 @@ function bp_activity_feed_item_title() {
4285
  /**
4286
  * Filters the activity feed item title.
4287
  *
4288
- * @since BuddyPress (1.0.0)
4289
  *
4290
  * @param string $title The title for the activity feed item.
4291
  */
@@ -4295,7 +4292,7 @@ function bp_activity_feed_item_title() {
4295
  /**
4296
  * Output the activity feed item link.
4297
  *
4298
- * @since BuddyPress (1.0.0)
4299
  *
4300
  * @uses bp_get_activity_feed_item_link()
4301
  */
@@ -4306,7 +4303,7 @@ function bp_activity_feed_item_link() {
4306
  /**
4307
  * Return the activity feed item link.
4308
  *
4309
- * @since BuddyPress (1.0.0)
4310
  *
4311
  * @global object $activities_template {@link BP_Activity_Template}
4312
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_link' hook.
@@ -4323,7 +4320,7 @@ function bp_activity_feed_item_link() {
4323
  /**
4324
  * Filters the activity feed item link.
4325
  *
4326
- * @since BuddyPress (1.0.0)
4327
  *
4328
  * @param string $retval The URL for the activity feed item.
4329
  */
@@ -4333,7 +4330,7 @@ function bp_activity_feed_item_link() {
4333
  /**
4334
  * Output the activity feed item date.
4335
  *
4336
- * @since BuddyPress (1.0.0)
4337
  *
4338
  * @uses bp_get_activity_feed_item_date()
4339
  */
@@ -4344,7 +4341,7 @@ function bp_activity_feed_item_date() {
4344
  /**
4345
  * Return the activity feed item date.
4346
  *
4347
- * @since BuddyPress (1.0.0)
4348
  *
4349
  * @global object $activities_template {@link BP_Activity_Template}
4350
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_date' hook.
@@ -4361,7 +4358,7 @@ function bp_activity_feed_item_date() {
4361
  /**
4362
  * Filters the activity feed item date.
4363
  *
4364
- * @since BuddyPress (1.0.0)
4365
  *
4366
  * @param string $retval The date for the activity feed item.
4367
  */
@@ -4371,7 +4368,7 @@ function bp_activity_feed_item_date() {
4371
  /**
4372
  * Output the activity feed item description.
4373
  *
4374
- * @since BuddyPress (1.0.0)
4375
  *
4376
  * @uses bp_get_activity_feed_item_description()
4377
  */
@@ -4382,7 +4379,7 @@ function bp_activity_feed_item_description() {
4382
  /**
4383
  * Return the activity feed item description.
4384
  *
4385
- * @since BuddyPress (1.0.0)
4386
  *
4387
  * @global object $activities_template {@link BP_Activity_Template}
4388
  * @uses ent2ncr()
@@ -4394,12 +4391,12 @@ function bp_activity_feed_item_description() {
4394
  function bp_get_activity_feed_item_description() {
4395
  global $activities_template;
4396
 
4397
- // Get the content, if exists
4398
  $content = ! empty( $activities_template->activity->content )
4399
  ? $activities_template->activity->content
4400
  : '';
4401
 
4402
- // Perform a few string conversions on the content, if it's not empty
4403
  if ( ! empty( $content ) ) {
4404
  $content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) );
4405
  }
@@ -4407,7 +4404,7 @@ function bp_activity_feed_item_description() {
4407
  /**
4408
  * Filters the activity feed item description.
4409
  *
4410
- * @since BuddyPress (1.0.0)
4411
  *
4412
  * @param string $content The description for the activity feed item.
4413
  */
@@ -4417,7 +4414,7 @@ function bp_activity_feed_item_description() {
4417
  /**
4418
  * Template tag so we can hook activity feed to <head>.
4419
  *
4420
- * @since BuddyPress (1.5.0)
4421
  *
4422
  * @uses bloginfo()
4423
  * @uses bp_sitewide_activity_feed_link()
@@ -4434,10 +4431,10 @@ add_action( 'bp_head', 'bp_activity_sitewide_feed' );
4434
  /**
4435
  * Display available filters depending on the scope.
4436
  *
4437
- * @since BuddyPress (2.1.0)
4438
  *
4439
  * @param string $context The current context. 'activity', 'member',
4440
- * 'member_groups', 'group'.
4441
  * @uses bp_get_activity_show_filters()
4442
  */
4443
  function bp_activity_show_filters( $context = '' ) {
@@ -4446,19 +4443,19 @@ function bp_activity_show_filters( $context = '' ) {
4446
  /**
4447
  * Get available filters depending on the scope.
4448
  *
4449
- * @since BuddyPress (2.1.0)
4450
  *
4451
  * @param string $context The current context. 'activity', 'member',
4452
- * 'member_groups', 'group'.
4453
  *
4454
  * @return string HTML for <option> values.
4455
  */
4456
  function bp_get_activity_show_filters( $context = '' ) {
4457
- // Set default context based on current page
4458
  if ( empty( $context ) ) {
4459
 
4460
  // On member pages, default to 'member', unless this
4461
- // is a user's Groups activity
4462
  if ( bp_is_user() ) {
4463
  if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
4464
  $context = 'member_groups';
@@ -4466,11 +4463,11 @@ function bp_activity_show_filters( $context = '' ) {
4466
  $context = 'member';
4467
  }
4468
 
4469
- // On individual group pages, default to 'group'
4470
  } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) {
4471
  $context = 'group';
4472
 
4473
- // 'activity' everywhere else
4474
  } else {
4475
  $context = 'activity';
4476
  }
@@ -4486,7 +4483,7 @@ function bp_activity_show_filters( $context = '' ) {
4486
  continue;
4487
  }
4488
 
4489
- // Friends activity collapses two filters into one
4490
  if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
4491
  $action['key'] = 'friendship_accepted,friendship_created';
4492
  }
@@ -4498,14 +4495,14 @@ function bp_activity_show_filters( $context = '' ) {
4498
  /**
4499
  * Filters the options available in the activity filter dropdown.
4500
  *
4501
- * @since BuddyPress (2.2.0)
4502
  *
4503
  * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
4504
  * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
4505
  */
4506
  $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
4507
 
4508
- // Build the options output
4509
  $output = '';
4510
 
4511
  if ( ! empty( $filters ) ) {
@@ -4517,7 +4514,7 @@ function bp_activity_show_filters( $context = '' ) {
4517
  /**
4518
  * Filters the HTML markup result for the activity filter dropdown.
4519
  *
4520
- * @since BuddyPress (2.1.0)
4521
  *
4522
  * @param string $output HTML output for the activity filter dropdown.
4523
  * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
1
  <?php
 
2
  /**
3
  * BuddyPress Activity Template Functions.
4
  *
6
  * @subpackage ActivityTemplate
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Output the activity component slug.
14
  *
15
+ * @since 1.5.0
16
  *
17
  * @uses bp_get_activity_slug()
18
  */
22
  /**
23
  * Return the activity component slug.
24
  *
25
+ * @since 1.5.0
26
  *
27
  * @uses apply_filters() To call the 'bp_get_activity_slug' hook.
28
  *
33
  /**
34
  * Filters the activity component slug.
35
  *
36
+ * @since 1.5.0
37
  *
38
  * @param string $slug Activity component slug.
39
  */
43
  /**
44
  * Output the activity component root slug.
45
  *
46
+ * @since 1.5.0
47
  *
48
  * @uses bp_get_activity_root_slug()
49
  */
53
  /**
54
  * Return the activity component root slug.
55
  *
56
+ * @since 1.5.0
57
  *
58
  * @uses apply_filters() To call the 'bp_get_activity_root_slug' hook.
59
  *
64
  /**
65
  * Filters the activity component root slug.
66
  *
67
+ * @since 1.5.0
68
  *
69
  * @param string $root_slug Activity component root slug.
70
  */
74
  /**
75
  * Output activity directory permalink.
76
  *
77
+ * @since 1.5.0
78
  *
79
  * @uses bp_get_activity_directory_permalink()
80
  */
84
  /**
85
  * Return activity directory permalink.
86
  *
87
+ * @since 1.5.0
88
  *
89
  * @uses trailingslashit()
90
  * @uses bp_get_root_domain()
98
  /**
99
  * Filters the activity directory permalink.
100
  *
101
+ * @since 1.5.0
102
  *
103
  * @param string $url Permalink url for the activity directory.
104
  */
110
  *
111
  * This is responsible for loading a group of activity items and displaying them.
112
  *
113
+ * @since 1.0.0
114
  */
115
  class BP_Activity_Template {
116
+
117
  /**
118
  * The loop iterator.
119
  *
120
+ * @since 1.5.0
 
121
  * @var int
122
  */
123
  public $current_activity = -1;
125
  /**
126
  * The activity count.
127
  *
128
+ * @since 1.5.0
 
129
  * @var int
130
  */
131
  public $activity_count;
133
  /**
134
  * The total activity count.
135
  *
136
+ * @since 1.5.0
 
137
  * @var int
138
  */
139
  public $total_activity_count;
141
  /**
142
  * Array of activities located by the query.
143
  *
144
+ * @since 1.5.0
 
145
  * @var array
146
  */
147
  public $activities;
149
  /**
150
  * The activity object currently being iterated on.
151
  *
152
+ * @since 1.5.0
 
153
  * @var object
154
  */
155
  public $activity;
157
  /**
158
  * A flag for whether the loop is currently being iterated.
159
  *
160
+ * @since 1.5.0
 
161
  * @var bool
162
  */
163
  public $in_the_loop;
165
  /**
166
  * URL parameter key for activity pagination. Default: 'acpage'.
167
  *
168
+ * @since 2.1.0
169
  * @var string
170
  */
171
  public $pag_arg;
173
  /**
174
  * The page number being requested.
175
  *
176
+ * @since 1.5.0
 
177
  * @var int
178
  */
179
  public $pag_page;
181
  /**
182
  * The number of items being requested per page.
183
  *
184
+ * @since 1.5.0
 
185
  * @var int
186
  */
187
  public $pag_num;
189
  /**
190
  * An HTML string containing pagination links.
191
  *
192
+ * @since 1.5.0
 
193
  * @var string
194
  */
195
  public $pag_links;
197
  /**
198
  * The displayed user's full name.
199
  *
200
+ * @since 1.5.0
 
201
  * @var string
202
  */
203
  public $full_name;
232
  public function __construct( $args ) {
233
  $bp = buddypress();
234
 
235
+ // Backward compatibility with old method of passing arguments.
236
  if ( !is_array( $args ) || func_num_args() > 1 ) {
237
  _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
238
 
261
  'per_page' => 20,
262
  'page_arg' => 'acpage',
263
  'max' => false,
264
+ 'fields' => 'all',
265
  'count_total' => false,
266
  'sort' => false,
267
  'include' => false,
285
  $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] );
286
  $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
287
 
288
+ // Check if blog/forum replies are disabled.
289
  $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' );
290
 
291
+ // Get an array of the logged in user's favorite activities.
292
  $this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) );
293
 
294
+ // Fetch specific activity items based on ID's.
295
  if ( !empty( $include ) ) {
296
  $this->activities = bp_activity_get_specific( array(
297
  'activity_ids' => explode( ',', $include ),
306
  'update_meta_cache' => $update_meta_cache,
307
  ) );
308
 
309
+ // Fetch all activity items.
310
  } else {
311
  $this->activities = bp_activity_get( array(
312
  'display_comments' => $display_comments,
330
  }
331
 
332
  // The total_activity_count property will be set only if a
333
+ // 'count_total' query has taken place.
334
  if ( ! is_null( $this->activities['total'] ) ) {
335
  if ( ! $max || $max >= (int) $this->activities['total'] ) {
336
  $this->total_activity_count = (int) $this->activities['total'];
355
 
356
  $this->full_name = bp_get_displayed_user_fullname();
357
 
358
+ // Fetch parent content for activity comments so we do not have to query in the loop.
359
  foreach ( (array) $this->activities as $activity ) {
360
  if ( 'activity_comment' != $activity->type ) {
361
  continue;
447
  /**
448
  * Fires right before the rewinding of activity posts.
449
  *
450
+ * @since 1.1.0
451
  */
452
  do_action( 'activity_loop_end' );
453
 
454
+ // Do some cleaning up after the loop.
455
  $this->rewind_activities();
456
  }
457
 
478
  $this->activity = (object) $this->activity;
479
  }
480
 
481
+ // Loop has just started.
482
  if ( $this->current_activity == 0 ) {
483
 
484
  /**
485
  * Fires if the current activity item is the first in the activity loop.
486
  *
487
+ * @since 1.1.0
488
  */
489
  do_action('activity_loop_start');
490
  }
498
  * $activities_template global, enabling the use of BuddyPress templates and
499
  * template functions to display a list of activity items.
500
  *
501
+ * @since 1.0.0
502
+ * @since 2.4.0 Introduced the `$fields` parameter.
503
  *
504
  * @global object $activities_template {@link BP_Activity_Template}
505
  * @uses groups_is_user_member()
529
  * @type int|bool $per_page Number of results per page. Default: 20.
530
  * @type string $page_arg String used as a query parameter in pagination links. Default: 'acpage'.
531
  * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
532
+ * @type string $fields Activity fields to retrieve. 'all' to fetch entire activity objects,
533
+ * 'ids' to get only the activity IDs. Default 'all'.
534
  * @type string|bool $count_total If true, an additional DB query is run to count the total activity items
535
  * for the query. Default: false.
536
  * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
605
  function bp_has_activities( $args = '' ) {
606
  global $activities_template;
607
 
608
+ // Get BuddyPress.
609
  $bp = buddypress();
610
 
611
+ /*
612
+ * Smart Defaults.
613
+ */
614
 
615
+ // User filtering.
616
  $user_id = bp_displayed_user_id()
617
  ? bp_displayed_user_id()
618
  : false;
619
 
620
+ // Group filtering.
621
  if ( bp_is_group() ) {
622
  $object = $bp->groups->id;
623
  $primary_id = bp_get_current_group_id();
628
  $show_hidden = false;
629
  }
630
 
631
+ // The default scope should recognize custom slugs.
632
  $scope = array_key_exists( bp_current_action(), (array) $bp->loaded_components )
633
  ? $bp->loaded_components[ bp_current_action() ]
634
  : bp_current_action();
635
 
636
+ // Support for permalinks on single item pages: /groups/my-group/activity/124/.
637
  $include = bp_is_current_action( bp_get_activity_slug() )
638
  ? bp_action_variable( 0 )
639
  : false;
640
 
641
+ $search_terms_default = false;
642
+ $search_query_arg = bp_core_get_component_search_query_arg( 'activity' );
643
+ if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) {
644
+ $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] );
645
+ }
646
+
647
+ /*
648
+ * Parse Args.
649
+ */
650
 
651
  // Note: any params used for filtering can be a single value, or multiple
652
  // values comma separated.
653
  $r = bp_parse_args( $args, array(
654
+ 'display_comments' => 'threaded', // False for none, stream/threaded - show comments in the stream or threaded under items.
655
+ 'include' => $include, // Pass an activity_id or string of IDs comma-separated.
656
+ 'exclude' => false, // Pass an activity_id or string of IDs comma-separated.
657
+ 'in' => false, // Comma-separated list or array of activity IDs among which to search.
658
+ 'sort' => 'DESC', // Sort DESC or ASC.
659
+ 'page' => 1, // Which page to load.
660
+ 'per_page' => 20, // Number of items per page.
661
+ 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679.
662
+ 'max' => false, // Max number to return.
663
+ 'fields' => 'all',
664
  'count_total' => false,
665
  'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
666
+ 'spam' => 'ham_only', // Hide spammed items.
667
 
668
+ // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions).
669
  'scope' => $scope,
670
 
671
  // Filtering
672
+ 'user_id' => $user_id, // user_id to filter on.
673
+ 'object' => $object, // Object to filter on e.g. groups, profile, status, friends.
674
+ 'action' => false, // Action to filter on e.g. activity_update, new_forum_post, profile_updated.
675
+ 'primary_id' => $primary_id, // Object ID to filter on e.g. a group_id or forum_id or blog_id etc.
676
+ 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id.
677
+ 'offset' => false, // Return only items >= this ID.
678
+ 'since' => false, // Return only items recorded since this Y-m-d H:i:s date.
679
+
680
+ 'meta_query' => false, // Filter on activity meta. See WP_Meta_Query for format.
681
+ 'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format.
682
+ 'filter_query' => false, // Advanced filtering. See BP_Activity_Query for format.
683
+
684
+ // Searching.
685
+ 'search_terms' => $search_terms_default,
686
  'update_meta_cache' => true,
687
  ), 'has_activities' );
688
 
689
+ /*
690
+ * Smart Overrides.
691
+ */
692
 
693
  // Translate various values for 'display_comments'
694
  // This allows disabling comments via ?display_comments=0
695
+ // or =none or =false. Final true is a strict type check. See #5029.
696
  if ( in_array( $r['display_comments'], array( 0, '0', 'none', 'false' ), true ) ) {
697
  $r['display_comments'] = false;
698
  }
699
 
700
+ // Ignore pagination if an offset is passed.
701
  if ( ! empty( $r['offset'] ) ) {
702
  $r['page'] = 0;
703
  }
704
 
705
+ // Search terms.
706
  if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) {
707
  $r['search_terms'] = $_REQUEST['s'];
708
  }
709
 
710
+ // Do not exceed the maximum per page.
711
  if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
712
  $r['per_page'] = $r['max'];
713
  }
719
  * To enable, put add_filter( 'bp_activity_enable_afilter_support', '__return_true' );
720
  * into bp-custom.php or your theme's functions.php.
721
  *
722
+ * @since 1.6.0
723
  *
724
  * @param bool $value True if BuddyPress should enable afilter support.
725
  */
747
  $r['spam'] = 'all';
748
  }
749
 
750
+ /*
751
+ * Query
752
+ */
753
 
754
  $activities_template = new BP_Activity_Template( $r );
755
 
756
  /**
757
  * Filters whether or not there are activity items to display.
758
  *
759
+ * @since 1.1.0
760
  *
761
  * @param bool $value Whether or not there are activity items to display.
762
  * @param string $activities_template Current activities template being used.
768
  /**
769
  * Determine if there are still activities left in the loop.
770
  *
771
+ * @since 1.0.0
772
  *
773
  * @global object $activities_template {@link BP_Activity_Template}
774
  * @uses BP_Activity_Template::user_activities() {@link BP_Activity_Template::user_activities()}
783
  /**
784
  * Get the current activity object in the loop.
785
  *
786
+ * @since 1.0.0
787
  *
788
  * @global object $activities_template {@link BP_Activity_Template}
789
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
798
  /**
799
  * Output the URL for the Load More link.
800
  *
801
+ * @since 2.1.0
802
  */
803
  function bp_activity_load_more_link() {
804
  echo esc_url( bp_get_activity_load_more_link() );
806
  /**
807
  * Get the URL for the Load More link.
808
  *
809
+ * @since 2.1.0
810
+ *
811
+ * @return string $link
812
  */
813
  function bp_get_activity_load_more_link() {
814
  global $activities_template;
819
  /**
820
  * Filters the Load More link URL.
821
  *
822
+ * @since 2.1.0
823
  *
824
  * @param string $link The "Load More" link URL with appropriate query args.
825
  * @param string $url The original URL.
831
  /**
832
  * Output the activity pagination count.
833
  *
834
+ * @since 1.0.0
835
  *
836
  * @global object $activities_template {@link BP_Activity_Template}
837
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
843
  /**
844
  * Return the activity pagination count.
845
  *
846
+ * @since 1.2.0
847
  *
848
  * @global object $activities_template {@link BP_Activity_Template}
849
  * @uses bp_core_number_format()
870
  /**
871
  * Output the activity pagination links.
872
  *
873
+ * @since 1.0.0
874
  *
875
  * @uses bp_get_activity_pagination_links()
876
  */
881
  /**
882
  * Return the activity pagination links.
883
  *
884
+ * @since 1.0.0
885
  *
886
  * @global object $activities_template {@link BP_Activity_Template}
887
  * @uses apply_filters() To call the 'bp_get_activity_pagination_links' hook.
894
  /**
895
  * Filters the activity pagination link output.
896
  *
897
+ * @since 1.0.0
898
  *
899
  * @param string $pag_links Output for the activity pagination links.
900
  */
904
  /**
905
  * Return true when there are more activity items to be shown than currently appear.
906
  *
907
+ * @since 1.5.0
908
  *
909
  * @global object $activities_template {@link BP_Activity_Template}
910
  * @uses apply_filters() To call the 'bp_activity_has_more_items' hook.
929
  /**
930
  * Filters whether there are more activity items to display.
931
  *
932
+ * @since 1.5.0
933
  *
934
  * @param bool $has_more_items Whether or not there are more activity items to display.
935
  */
939
  /**
940
  * Output the activity count.
941
  *
942
+ * @since 1.2.0
943
  *
944
  * @uses bp_get_activity_count()
945
  */
950
  /**
951
  * Return the activity count.
952
  *
953
+ * @since 1.2.0
954
  *
955
  * @global object $activities_template {@link BP_Activity_Template}
956
  * @uses apply_filters() To call the 'bp_get_activity_count' hook.
963
  /**
964
  * Filters the activity count for the activity template.
965
  *
966
+ * @since 1.2.0
967
  *
968
  * @param int $activity_count The count for total activity.
969
  */
973
  /**
974
  * Output the number of activities per page.
975
  *
976
+ * @since 1.2.0
977
  *
978
  * @uses bp_get_activity_per_page()
979
  */
984
  /**
985
  * Return the number of activities per page.
986
  *
987
+ * @since 1.2.0
988
  *
989
  * @global object $activities_template {@link BP_Activity_Template}
990
  * @uses apply_filters() To call the 'bp_get_activity_per_page' hook.
997
  /**
998
  * Filters the activity posts per page value.
999
  *
1000
+ * @since 1.2.0
1001
  *
1002
  * @param int $pag_num How many post should be displayed for pagination.
1003
  */
1007
  /**
1008
  * Output the activities title.
1009
  *
1010
+ * @since 1.0.0
1011
  *
1012
  * @uses bp_get_activities_title()
1013
  * @todo Deprecate.
1019
  /**
1020
  * Return the activities title.
1021
  *
1022
+ * @since 1.0.0
1023
  *
1024
  * @global string $bp_activity_title
1025
  * @uses apply_filters() To call the 'bp_get_activities_title' hook.
1033
  /**
1034
  * Filters the activities title for the activity template.
1035
  *
1036
+ * @since 1.0.0
1037
  *
1038
  * @param string $bp_activity_title The title to be displayed.
1039
  */
1043
  /**
1044
  * {@internal Missing Description}
1045
  *
1046
+ * @since 1.0.0
1047
  *
1048
  * @uses bp_get_activities_no_activity()
1049
  * @todo Deprecate.
1055
  /**
1056
  * {@internal Missing Description}
1057
  *
1058
+ * @since 1.0.0
1059
  *
1060
  * @global string $bp_activity_no_activity
1061
  * @uses apply_filters() To call the 'bp_get_activities_no_activity' hook.
1069
  /**
1070
  * Filters the text used when there is no activity to display.
1071
  *
1072
+ * @since 1.0.0
1073
  *
1074
  * @param string $bp_activity_no_activity Text to display for no activity.
1075
  */
1079
  /**
1080
  * Output the activity ID.
1081
  *
1082
+ * @since 1.2.0
1083
  *
1084
  * @uses bp_get_activity_id()
1085
  */
1090
  /**
1091
  * Return the activity ID.
1092
  *
1093
+ * @since 1.2.0
1094
  *
1095
  * @global object $activities_template {@link BP_Activity_Template}
1096
  * @uses apply_filters() To call the 'bp_get_activity_id' hook.
1103
  /**
1104
  * Filters the activity ID being displayed.
1105
  *
1106
+ * @since 1.2.0
1107
  *
1108
  * @param int $id The activity ID.
1109
  */
1113
  /**
1114
  * Output the activity item ID.
1115
  *
1116
+ * @since 1.2.0
1117
  *
1118
  * @uses bp_get_activity_item_id()
1119
  */
1124
  /**
1125
  * Return the activity item ID.
1126
  *
1127
+ * @since 1.2.0
1128
  *
1129
  * @global object $activities_template {@link BP_Activity_Template}
1130
  * @uses apply_filters() To call the 'bp_get_activity_item_id' hook.
1137
  /**
1138
  * Filters the activity item ID being displayed.
1139
  *
1140
+ * @since 1.2.0
1141
  *
1142
  * @param int $item_id The activity item ID.
1143
  */
1147
  /**
1148
  * Output the activity secondary item ID.
1149
  *
1150
+ * @since 1.2.0
1151
  *
1152
  * @uses bp_get_activity_secondary_item_id()
1153
  */
1158
  /**
1159
  * Return the activity secondary item ID.
1160
  *
1161
+ * @since 1.2.0
1162
  *
1163
  * @global object $activities_template {@link BP_Activity_Template}
1164
  * @uses apply_filters() To call the 'bp_get_activity_secondary_item_id' hook.
1171
  /**
1172
  * Filters the activity secondary item ID being displayed.
1173
  *
1174
+ * @since 1.2.0
1175
  *
1176
  * @param int $secondary_item_id The activity secondary item ID.
1177
  */
1181
  /**
1182
  * Output the date the activity was recorded.
1183
  *
1184
+ * @since 1.2.0
1185
  *
1186
  * @uses bp_get_activity_date_recorded()
1187
  */
1192
  /**
1193
  * Return the date the activity was recorded.
1194
  *
1195
+ * @since 1.2.0
1196
  *
1197
  * @global object $activities_template {@link BP_Activity_Template}
1198
  * @uses apply_filters() To call the 'bp_get_activity_date_recorded' hook.
1205
  /**
1206
  * Filters the date the activity was recorded.
1207
  *
1208
+ * @since 1.2.0
1209
  *
1210
  * @param int $date_recorded The activity's date.
1211
  */
1215
  /**
1216
  * Output the display name of the member who posted the activity.
1217
  *
1218
+ * @since 2.1.0
1219
  *
1220
  * @uses bp_get_activity_member_display_name()
1221
  */
1226
  /**
1227
  * Return the display name of the member who posted the activity.
1228
  *
1229
+ * @since 2.1.0
1230
  *
1231
  * @global object $activities_template {@link BP_Activity_Template}
1232
  * @uses apply_filters() To call the 'bp_get_activity_member_display_name' hook.
1243
  /**
1244
  * Filters the display name of the member who posted the activity.
1245
  *
1246
+ * @since 2.1.0
1247
  *
1248
  * @param int $retval Display name for the member who posted.
1249
  */
1253
  /**
1254
  * Output the activity object name.
1255
  *
1256
+ * @since 1.2.0
1257
  *
1258
  * @uses bp_get_activity_object_name()
1259
  */
1264
  /**
1265
  * Return the activity object name.
1266
  *
1267
+ * @since 1.2.0
1268
  *
1269
  * @global object $activities_template {@link BP_Activity_Template}
1270
  * @uses apply_filters() To call the 'bp_get_activity_object_name' hook.
1277
  /**
1278
  * Filters the activity object name.
1279
  *
1280
+ * @since 1.2.0
1281
  *
1282
  * @param string $activity_component The activity object name.
1283
  */
1287
  /**
1288
  * Output the activity type.
1289
  *
1290
+ * @since 1.2.0
1291
  *
1292
  * @uses bp_get_activity_type()
1293
  */
1298
  /**
1299
  * Return the activity type.
1300
  *
1301
+ * @since 1.2.0
1302
  *
1303
  * @global object $activities_template {@link BP_Activity_Template}
1304
  * @uses apply_filters() To call the 'bp_get_activity_type' hook.
1311
  /**
1312
  * Filters the activity type.
1313
  *
1314
+ * @since 1.2.0
1315
  *
1316
  * @param string $activity_type The activity type.
1317
  */
1323
  *
1324
  * Just a wrapper for bp_activity_type().
1325
  *
1326
+ * @since 1.2.0
1327
+ * @deprecated 1.5.0
1328
  *
1329
  * @todo Properly deprecate in favor of bp_activity_type() and
1330
+ * remove redundant echo
1331
  *
1332
  * @uses bp_activity_type()
1333
  */
1338
  *
1339
  * Just a wrapper for bp_get_activity_type().
1340
  *
1341
+ * @since 1.2.0
1342
+ * @deprecated 1.5.0
1343
  *
1344
  * @todo Properly deprecate in favor of bp_get_activity_type().
1345
  *
1352
  /**
1353
  * Output the activity user ID.
1354
  *
1355
+ * @since 1.1.0
1356
  *
1357
  * @uses bp_get_activity_user_id()
1358
  */
1363
  /**
1364
  * Return the activity user ID.
1365
  *
1366
+ * @since 1.1.0
1367
  *
1368
  * @global object $activities_template {@link BP_Activity_Template}
1369
  * @uses apply_filters() To call the 'bp_get_activity_user_id' hook.
1376
  /**
1377
  * Filters the activity user ID.
1378
  *
1379
+ * @since 1.1.0
1380
  *
1381
  * @param int $user_id The activity user ID.
1382
  */
1386
  /**
1387
  * Output the activity user link.
1388
  *
1389
+ * @since 1.2.0
1390
  *
1391
  * @uses bp_get_activity_user_link()
1392
  */
1397
  /**
1398
  * Return the activity user link.
1399
  *
1400
+ * @since 1.2.0
1401
  *
1402
  * @global object $activities_template {@link BP_Activity_Template}
1403
  * @uses bp_core_get_user_domain()
1417
  /**
1418
  * Filters the activity user link.
1419
  *
1420
+ * @since 1.2.0
1421
  *
1422
  * @param string $link The activity user link.
1423
  */
1427
  /**
1428
  * Output the avatar of the user that performed the action.
1429
  *
1430
+ * @since 1.1.0
1431
  *
1432
  * @see bp_get_activity_avatar() for description of arguments.
1433
  * @uses bp_get_activity_avatar()
1440
  /**
1441
  * Return the avatar of the user that performed the action.
1442
  *
1443
+ * @since 1.1.0
1444
  *
1445
  * @see bp_core_fetch_avatar() For a description of the arguments.
1446
  * @global object $activities_template {@link BP_Activity_Template}
1471
 
1472
  $bp = buddypress();
1473
 
1474
+ // On activity permalink pages, default to the full-size avatar.
1475
  $type_default = bp_is_single_activity() ? 'full' : 'thumb';
1476
 
1477
  // Within the activity comment loop, the current activity should be set
1478
  // to current_comment. Otherwise, just use activity.
1479
  $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity;
1480
 
1481
+ // Activity user display name.
1482
  $dn_default = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : '';
1483
 
1484
+ // Prepend some descriptive text to alt.
1485
  $alt_default = !empty( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default ) : __( 'Profile picture', 'buddypress' );
1486
 
1487
  $defaults = array(
1497
 
1498
  if ( !isset( $height ) && !isset( $width ) ) {
1499
 
1500
+ // Backpat.
1501
  if ( isset( $bp->avatar->full->height ) || isset( $bp->avatar->thumb->height ) ) {
1502
  $height = ( 'full' == $type ) ? $bp->avatar->full->height : $bp->avatar->thumb->height;
1503
  } else {
1504
  $height = 20;
1505
  }
1506
 
1507
+ // Backpat.
1508
  if ( isset( $bp->avatar->full->width ) || isset( $bp->avatar->thumb->width ) ) {
1509
  $width = ( 'full' == $type ) ? $bp->avatar->full->width : $bp->avatar->thumb->width;
1510
  } else {
1519
  * Possible hooks are bp_get_activity_avatar_object_blog,
1520
  * bp_get_activity_avatar_object_group, and bp_get_activity_avatar_object_user.
1521
  *
1522
+ * @since 1.1.0
1523
  *
1524
  * @param string $component Component being displayed.
1525
  */
1529
  /**
1530
  * Filters the activity avatar item ID.
1531
  *
1532
+ * @since 1.2.10
1533
  *
1534
  * @param int $item_id Item ID for the activity avatar.
1535
  */
1543
  /**
1544
  * Filters the value returned by bp_core_fetch_avatar.
1545
  *
1546
+ * @since 1.1.3
1547
  *
1548
  * @param array $value Array of arguments calculated for use with bp_core_fetch_avatar.
1549
  */
1562
  /**
1563
  * Output the avatar of the object that action was performed on.
1564
  *
1565
+ * @since 1.2.0
1566
  *
1567
  * @see bp_get_activity_secondary_avatar() for description of arguments.
1568
  * @uses bp_get_activity_secondary_avatar()
1576
  /**
1577
  * Return the avatar of the object that action was performed on.
1578
  *
1579
+ * @since 1.2.0
1580
  *
1581
  * @see bp_core_fetch_avatar() for description of arguments.
1582
  * @global object $activities_template {@link BP_Activity_Template}
1597
  * @type string|bool $email Default: email of the activity's user.
1598
  * @type int|bool $user_id Default: ID of the activity's user.
1599
  * }
1600
+ * @return string The secondary avatar.
1601
  */
1602
  function bp_get_activity_secondary_avatar( $args = '' ) {
1603
  global $activities_template;
1614
  ) );
1615
  extract( $r, EXTR_SKIP );
1616
 
1617
+ // Set item_id and object (default to user).
1618
  switch ( $activities_template->activity->component ) {
1619
  case 'groups' :
1620
  if ( bp_disable_group_avatar_uploads() ) {
1626
  $link = '';
1627
  $name = '';
1628
 
1629
+ // Only if groups is active.
1630
  if ( bp_is_active( 'groups' ) ) {
1631
  $group = groups_get_group( array(
1632
  'group_id' => $item_id,
1686
  * bp_get_activity_secondary_avatar_object_blog, bp_get_activity_secondary_avatar_object_group,
1687
  * and bp_get_activity_secondary_avatar_object_user.
1688
  *
1689
+ * @since 1.2.10
1690
  *
1691
  * @param string $object Component being displayed.
1692
  */
1695
  /**
1696
  * Filters the activity secondary avatar item ID.
1697
  *
1698
+ * @since 1.2.10
1699
  *
1700
  * @param int $item_id ID for the secondary avatar item.
1701
  */
1702
  $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
1703
 
1704
+ // If we have no item_id or object, there is no avatar to display.
1705
  if ( empty( $item_id ) || empty( $object ) ) {
1706
  return false;
1707
  }
1708
 
1709
+ // Get the avatar.
1710
  $avatar = bp_core_fetch_avatar( array(
1711
  'item_id' => $item_id,
1712
  'object' => $object,
1723
  /**
1724
  * Filters the secondary avatar link for current activity.
1725
  *
1726
+ * @since 1.7.0
1727
  *
1728
  * @param string $link Link to wrap the avatar image in.
1729
  * @param string $component Activity component being acted on.
1733
  /**
1734
  * Filters the determined avatar for the secondary activity item.
1735
  *
1736
+ * @since 1.2.10
1737
  *
1738
  * @param string $avatar Formatted HTML <img> element, or raw avatar URL.
1739
  */
1753
  /**
1754
  * Output the activity action.
1755
  *
1756
+ * @since 1.2.0
1757
  *
1758
+ * @param array $args See bp_get_activity_action().
1759
  * @uses bp_get_activity_action()
1760
  */
1761
  function bp_activity_action( $args = array() ) {
1765
  /**
1766
  * Return the activity action.
1767
  *
1768
+ * @since 1.2.0
1769
  *
1770
  * @global object $activities_template {@link BP_Activity_Template}
 
1771
  * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook.
1772
  * @uses bp_insert_activity_meta()
1773
  * @uses apply_filters_ref_array() To call the 'bp_get_activity_action' hook.
1788
  /**
1789
  * Filters the activity action before the action is inserted as meta.
1790
  *
1791
+ * @since 1.2.10
1792
  *
1793
  * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1794
  */
1798
  $r
1799
  ) );
1800
 
1801
+ // Prepend the activity action meta (link, time since, etc...).
1802
  if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
1803
  $action = bp_insert_activity_meta( $action );
1804
  }
1806
  /**
1807
  * Filters the activity action after the action has been inserted as meta.
1808
  *
1809
+ * @since 1.2.0
1810
  *
1811
  * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1812
  */
1820
  /**
1821
  * Output the activity content body.
1822
  *
1823
+ * @since 1.2.0
1824
  *
1825
  * @uses bp_get_activity_content_body()
1826
  */
1831
  /**
1832
  * Return the activity content body.
1833
  *
1834
+ * @since 1.2.0
1835
  *
1836
  * @global object $activities_template {@link BP_Activity_Template}
1837
  * @uses bp_insert_activity_meta()
1842
  function bp_get_activity_content_body() {
1843
  global $activities_template;
1844
 
1845
+ // Backwards compatibility if action is not being used.
1846
  if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) {
1847
  $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
1848
  }
1850
  /**
1851
  * Filters the activity content body.
1852
  *
1853
+ * @since 1.2.0
1854
  *
1855
  * @param array $value Array containing the current activity content body and the current activity.
1856
  */
1860
  /**
1861
  * Does the activity have content?
1862
  *
1863
+ * @since 1.2.0
1864
  *
1865
  * @global object $activities_template {@link BP_Activity_Template}
1866
  *
1879
  /**
1880
  * Output the activity content.
1881
  *
1882
+ * @since 1.0.0
1883
+ * @deprecated 1.5.0
1884
  *
1885
  * @todo properly deprecate this function.
1886
  *
1893
  /**
1894
  * Return the activity content.
1895
  *
1896
+ * @since 1.0.0
1897
+ * @deprecated 1.5.0
1898
  *
1899
  * @todo properly deprecate this function.
1900
  *
1922
  * This metadata includes the time since the item was posted (which will appear
1923
  * as a link to the item's permalink).
1924
  *
1925
+ * @since 1.2.0
1926
  *
1927
  * @global object $activities_template {@link BP_Activity_Template}
1928
  * @uses bp_core_time_since()
1934
  * @uses apply_filters() To call the 'bp_insert_activity_meta' hook.
1935
  *
1936
  * @param string $content The activity content.
 
1937
  * @return string The activity content with the metadata string attached.
1938
  */
1939
  function bp_insert_activity_meta( $content = '' ) {
1940
  global $activities_template;
1941
 
1942
+ // Strip any legacy time since placeholders from BP 1.0-1.1.
1943
  $new_content = str_replace( '<span class="time-since">%s</span>', '', $content );
1944
 
1945
+ // Get the time since this activity was recorded.
1946
  $date_recorded = bp_core_time_since( $activities_template->activity->date_recorded );
1947
 
1948
  /**
1949
  * Filters the activity item time since markup.
1950
  *
1951
+ * @since 1.2.0
1952
  *
1953
  * @param array $value Array containing the time since markup and the current activity component.
1954
  */
1957
  &$activities_template->activity
1958
  ) );
1959
 
1960
+ // Insert the permalink.
1961
  if ( ! bp_is_single_activity() ) {
1962
 
1963
+ // Setup variables for activity meta.
1964
  $activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
1965
  $activity_meta = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>',
1966
  $new_content,
1972
  /**
1973
  * Filters the activity permalink to be added to the activity content.
1974
  *
1975
+ * @since 1.2.0
1976
  *
1977
+ * @param array $value Array containing the html markup for the activity permalink, after being parsed by
1978
+ * sprintf and current activity component.
1979
  */
1980
  $new_content = apply_filters_ref_array( 'bp_activity_permalink', array(
1981
  $activity_meta,
1988
  /**
1989
  * Filters the activity content after activity metadata has been attached.
1990
  *
1991
+ * @since 1.2.0
1992
  *
1993
  * @param string $content Activity content with the activity metadata added.
1994
  */
1998
  /**
1999
  * Determine if the current user can delete an activity item.
2000
  *
2001
+ * @since 1.2.0
2002
  *
2003
  * @global object $activities_template {@link BP_Activity_Template}
2004
  * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook.
2005
  *
2006
  * @param object|bool $activity Optional. Falls back on the current item in the loop.
 
2007
  * @return bool True if can delete, false otherwise.
2008
  */
2009
  function bp_activity_user_can_delete( $activity = false ) {
2010
  global $activities_template;
2011
 
2012
+ // Try to use current activity if none was passed.
2013
  if ( empty( $activity ) && ! empty( $activities_template->activity ) ) {
2014
  $activity = $activities_template->activity;
2015
  }
2016
 
2017
+ // If current_comment is set, we'll use that in place of the main activity.
2018
  if ( isset( $activity->current_comment ) ) {
2019
  $activity = $activity->current_comment;
2020
  }
2021
 
2022
+ // Assume the user cannot delete the activity item.
2023
  $can_delete = false;
2024
 
2025
+ // Only logged in users can delete activity.
2026
  if ( is_user_logged_in() ) {
2027
 
2028
+ // Community moderators can always delete activity (at least for now).
2029
  if ( bp_current_user_can( 'bp_moderate' ) ) {
2030
  $can_delete = true;
2031
  }
2037
  $can_delete = true;
2038
  }
2039
 
2040
+ // Viewing a single item, and this user is an admin of that item.
2041
  if ( bp_is_single_item() && bp_is_item_admin() ) {
2042
  $can_delete = true;
2043
  }
2046
  /**
2047
  * Filters whether the current user can delete an activity item.
2048
  *
2049
+ * @since 1.5.0
2050
  *
2051
  * @param bool $can_delete Whether the user can delete the item.
2052
  * @param object $activity Current activity item object.
2057
  /**
2058
  * Output the activity parent content.
2059
  *
2060
+ * @since 1.2.0
2061
  *
2062
  * @see bp_get_activity_parent_content() for a description of arguments.
2063
  * @uses bp_get_activity_parent_content()
2071
  /**
2072
  * Return the activity content.
2073
  *
2074
+ * @since 1.2.0
2075
  *
2076
  * @global object $activities_template {@link BP_Activity_Template}
2077
  * @uses apply_filters() To call the 'bp_get_activity_parent_content' hook.
2078
  *
2079
  * @param string $args Unused. Left over from an earlier implementation.
 
2080
  * @return mixed False on failure, otherwise the activity parent content.
2081
  */
2082
  function bp_get_activity_parent_content( $args = '' ) {
2083
  global $activities_template;
2084
 
2085
+ // Bail if no activity on no item ID.
2086
  if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
2087
  return false;
2088
  }
2089
 
2090
+ // Get the ID of the parent activity content.
2091
  $parent_id = (int) $activities_template->activity->item_id;
2092
 
2093
+ // Bail if no parent content.
2094
  if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
2095
  return false;
2096
  }
2097
 
2098
+ // Bail if no action.
2099
  if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
2100
  return false;
2101
  }
2102
 
2103
+ // Content always includes action.
2104
  $content = $activities_template->activity_parents[ $parent_id ]->action;
2105
 
2106
+ // Maybe append activity content, if it exists.
2107
  if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
2108
  $content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
2109
  }
2110
 
2111
+ // Remove the time since content for backwards compatibility.
2112
  $content = str_replace( '<span class="time-since">%s</span>', '', $content );
2113
 
2114
+ // Remove images.
2115
  $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
2116
 
2117
  /**
2118
  * Filters the activity parent content.
2119
  *
2120
+ * @since 1.2.0
2121
  *
2122
  * @param string $content Content set to be displayed as parent content.
2123
  */
2127
  /**
2128
  * Output the parent activity's user ID.
2129
  *
2130
+ * @since 1.7.0
2131
  */
2132
  function bp_activity_parent_user_id() {
2133
  echo bp_get_activity_parent_user_id();
2136
  /**
2137
  * Return the parent activity's user ID.
2138
  *
2139
+ * @since 1.7.0
2140
  *
2141
  * @global BP_Activity_Template $activities_template
2142
  *
2146
  function bp_get_activity_parent_user_id() {
2147
  global $activities_template;
2148
 
2149
+ // Bail if no activity on no item ID.
2150
  if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
2151
  return false;
2152
  }
2153
 
2154
+ // Get the ID of the parent activity content.
2155
  $parent_id = (int) $activities_template->activity->item_id;
2156
 
2157
+ // Bail if no parent item.
2158
  if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
2159
  return false;
2160
  }
2161
 
2162
+ // Bail if no parent user ID.
2163
  if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) {
2164
  return false;
2165
  }
2169
  /**
2170
  * Filters the activity parent item's user ID.
2171
  *
2172
+ * @since 1.7.0
2173
  *
2174
  * @param int $retval ID for the activity parent's user.
2175
  */
2179
  /**
2180
  * Output whether or not the current activity is in a current user's favorites.
2181
  *
2182
+ * @since 1.2.0
2183
  *
2184
  * @uses bp_get_activity_is_favorite()
2185
  */
2190
  /**
2191
  * Return whether the current activity is in a current user's favorites.
2192
  *
2193
+ * @since 1.2.0
2194
  *
2195
  * @global object $activities_template {@link BP_Activity_Template}
2196
  * @uses apply_filters() To call the 'bp_get_activity_is_favorite' hook.
2203
  /**
2204
  * Filters whether the current activity item is in the current user's favorites.
2205
  *
2206
+ * @since 1.2.0
2207
  *
2208
  * @param bool $value Whether or not the current activity item is in the current user's favorites.
2209
  */
2213
  /**
2214
  * Output the comment markup for an activity item.
2215
  *
2216
+ * @since 1.2.0
2217
  *
2218
  * @todo deprecate $args param
2219
  *
2226
  /**
2227
  * Get the comment markup for an activity item.
2228
  *
2229
+ * @since 1.2.0
2230
  *
2231
  * @todo deprecate $args param
 
2232
  * @todo Given that checks for children already happen in bp_activity_recurse_comments(),
2233
+ * this function can probably be streamlined or removed.
 
 
2234
  *
2235
  * @global object $activities_template {@link BP_Activity_Template}
2236
  * @uses bp_activity_recurse_comments()
2237
  *
2238
+ * @param string $args Unused. Left over from an earlier implementation.
2239
  * @return bool
2240
  */
2241
  function bp_activity_get_comments( $args = '' ) {
2254
  * Note: The recursion itself used to happen entirely in this function. Now it is
2255
  * split between here and the comment.php template.
2256
  *
2257
+ * @since 1.2.0
 
 
2258
  *
2259
  * @global object $activities_template {@link BP_Activity_Template}
2260
  * @uses locate_template()
2261
  *
2262
+ * @param object $comment The activity object currently being recursed.
2263
  * @return bool|string
2264
  */
2265
  function bp_activity_recurse_comments( $comment ) {
2276
  /**
2277
  * Filters the opening tag for the template that lists activity comments.
2278
  *
2279
+ * @since 1.6.0
2280
  *
2281
  * @param string $value Opening tag for the HTML markup to use.
2282
  */
2283
  echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>' );
2284
  foreach ( (array) $comment->children as $comment_child ) {
2285
 
2286
+ // Put the comment into the global so it's available to filters.
2287
  $activities_template->activity->current_comment = $comment_child;
2288
 
2289
  $template = bp_locate_template( 'activity/comment.php', false, false );
2304
  /**
2305
  * Filters the closing tag for the template that list activity comments.
2306
  *
2307
+ * @since 1.6.0
2308
  *
2309
  * @param string $value Closing tag for the HTML markup to use.
2310
  */
2314
  /**
2315
  * Utility function that returns the comment currently being recursed.
2316
  *
2317
+ * @since 1.5.0
2318
  *
2319
  * @global object $activities_template {@link BP_Activity_Template}
2320
  * @uses apply_filters() To call the 'bp_activity_current_comment' hook.
2332
  /**
2333
  * Filters the current comment being recursed.
2334
  *
2335
+ * @since 1.5.0
2336
  *
2337
  * @param object|bool $current_comment The activity comment currently being displayed. False on failure.
2338
  */
2343
  /**
2344
  * Output the ID of the activity comment currently being displayed.
2345
  *
2346
+ * @since 1.5.0
2347
  *
2348
  * @uses bp_get_activity_comment_id()
2349
  */
2354
  /**
2355
  * Return the ID of the activity comment currently being displayed.
2356
  *
2357
+ * @since 1.5.0
2358
  *
2359
  * @global object $activities_template {@link BP_Activity_Template}
2360
  * @uses apply_filters() To call the 'bp_activity_comment_id' hook.
2370
  /**
2371
  * Filters the ID of the activity comment currently being displayed.
2372
  *
2373
+ * @since 1.5.0
2374
  *
2375
  * @param int|bool $comment_id ID for the comment currently being displayed.
2376
  */
2380
  /**
2381
  * Output the ID of the author of the activity comment currently being displayed.
2382
  *
2383
+ * @since 1.5.0
2384
  *
2385
  * @uses bp_get_activity_comment_user_id()
2386
  */
2391
  /**
2392
  * Return the ID of the author of the activity comment currently being displayed.
2393
  *
2394
+ * @since 1.5.0
2395
  *
2396
  * @global object $activities_template {@link BP_Activity_Template}
2397
  * @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
2407
  /**
2408
  * Filters the ID of the author of the activity comment currently being displayed.
2409
  *
2410
+ * @since 1.5.0
2411
  *
2412
  * @param int|bool $user_id ID for the author of the comment currently being displayed.
2413
  */
2417
  /**
2418
  * Output the author link for the activity comment currently being displayed.
2419
  *
2420
+ * @since 1.5.0
2421
  *
2422
  * @uses bp_get_activity_comment_user_link()
2423
  */
2428
  /**
2429
  * Return the author link for the activity comment currently being displayed.
2430
  *
2431
+ * @since 1.5.0
2432
  *
2433
  * @uses bp_core_get_user_domain()
2434
  * @uses bp_get_activity_comment_user_id()
2442
  /**
2443
  * Filters the author link for the activity comment currently being displayed.
2444
  *
2445
+ * @since 1.5.0
2446
  *
2447
  * @param string $user_link Link for the author of the activity comment currently being displayed.
2448
  */
2452
  /**
2453
  * Output the author name for the activity comment currently being displayed.
2454
  *
2455
+ * @since 1.5.0
2456
  *
2457
  * @uses bp_get_activity_comment_name()
2458
  */
2466
  * The use of the 'bp_acomment_name' filter is deprecated. Please use
2467
  * 'bp_activity_comment_name'.
2468
  *
2469
+ * @since 1.5.0
2470
  *
2471
  * @global object $activities_template {@link BP_Activity_Template}
2472
  * @uses apply_filters() To call the 'bp_acomment_name' hook.
2479
 
2480
  if ( isset( $activities_template->activity->current_comment->user_fullname ) ) {
2481
 
2482
+ $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment ); // Backward compatibility.
2483
  } else {
2484
  $name = $activities_template->activity->current_comment->display_name;
2485
  }
2487
  /**
2488
  * Filters the name of the author for the activity comment.
2489
  *
2490
+ * @since 1.5.0
2491
  *
2492
  * @param string $name Name to be displayed with the activity comment.
2493
  */
2497
  /**
2498
  * Output the formatted date_recorded of the activity comment currently being displayed.
2499
  *
2500
+ * @since 1.5.0
2501
  *
2502
  * @uses bp_get_activity_comment_date_recorded()
2503
  */
2508
  /**
2509
  * Return the formatted date_recorded for the activity comment currently being displayed.
2510
  *
2511
+ * @since 1.5.0
2512
  *
2513
  * @uses bp_core_time_since()
2514
  * @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook.
2521
  /**
2522
  * Filters the recorded date of the activity comment currently being displayed.
2523
  *
2524
+ * @since 1.5.0
2525
  *
2526
  * @param string|bool Date for the activity comment currently being displayed.
2527
  */
2531
  /**
2532
  * Output the date_recorded of the activity comment currently being displayed.
2533
  *
2534
+ * @since 2.3.0
2535
  *
2536
  * @uses bp_get_activity_comment_date_recorded()
2537
  */
2542
  /**
2543
  * Return the date_recorded for the activity comment currently being displayed.
2544
  *
2545
+ * @since 2.3.0
2546
  *
2547
  * @global object $activities_template {@link BP_Activity_Template}
2548
  * @uses bp_core_time_since()
2557
  /**
2558
  * Filters the raw recorded date of the activity comment currently being displayed.
2559
  *
2560
+ * @since 2.3.0
2561
  *
2562
  * @param string|bool Raw date for the activity comment currently being displayed.
2563
  */
2567
  /**
2568
  * Output the 'delete' URL for the activity comment currently being displayed.
2569
  *
2570
+ * @since 1.5.0
2571
  *
2572
  * @uses bp_get_activity_comment_delete_link()
2573
  */
2578
  /**
2579
  * Gets the 'delete' URL for the activity comment currently being displayed.
2580
  *
2581
+ * @since 1.5.0
2582
  *
2583
  * @uses wp_nonce_url()
2584
  * @uses bp_get_root_domain()
2595
  /**
2596
  * Filters the link used for deleting the activity comment currently being displayed.
2597
  *
2598
+ * @since 1.5.0
2599
  *
2600
  * @param string $link Link to use for deleting the currently displayed activity comment.
2601
  */
2605
  /**
2606
  * Output the content of the activity comment currently being displayed.
2607
  *
2608
+ * @since 1.5.0
2609
  *
2610
  * @uses bp_get_activity_comment_content()
2611
  */
2621
  * 'bp_activity_comment_content' to modify the content of activity
2622
  * comments only.
2623
  *
2624
+ * @since 1.5.0
2625
  *
2626
  * @global object $activities_template {@link BP_Activity_Template}
2627
  * @uses apply_filters() To call the 'bp_get_activity_content' hook.
2638
  /**
2639
  * Filters the content of the current activity comment.
2640
  *
2641
+ * @since 1.2.0
2642
  *
2643
  * @param string $content The content of the current activity comment.
2644
  */
2648
  /**
2649
  * Output the activity comment count.
2650
  *
2651
+ * @since 1.2.0
2652
  *
2653
  * @uses bp_activity_get_comment_count()
2654
  */
2659
  /**
2660
  * Return the comment count of an activity item.
2661
  *
2662
+ * @since 1.2.0
2663
  *
2664
  * @global object $activities_template {@link BP_Activity_Template}
2665
  * @uses bp_activity_recurse_comment_count()
2666
  * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook.
2667
  *
2668
+ * @param array|null $deprecated Deprecated.
 
2669
  * @return int $count The activity comment count.
2670
  */
2671
  function bp_activity_get_comment_count( $deprecated = null ) {
2672
  global $activities_template;
2673
 
2674
+ // Deprecated notice about $args.
2675
  if ( ! empty( $deprecated ) ) {
2676
  _deprecated_argument( __FUNCTION__, '1.2', sprintf( __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ), __FUNCTION__, __FILE__ ) );
2677
  }
2678
 
2679
+ // Get the count using the purpose-built recursive function.
2680
  $count = ! empty( $activities_template->activity->children )
2681
  ? bp_activity_recurse_comment_count( $activities_template->activity )
2682
  : 0;
2684
  /**
2685
  * Filters the activity comment count.
2686
  *
2687
+ * @since 1.2.0
2688
  *
2689
  * @param int $count The activity comment count.
2690
  */
2697
  * This function recursively adds the total number of comments each
2698
  * activity child has, and returns them.
2699
  *
2700
+ * @since 1.2.0
2701
  *
2702
  * @uses bp_activity_recurse_comment_count()
2703
  * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook.
2704
  *
2705
  * @param object $comment Activity comment object.
2706
  * @param int $count The current iteration count.
 
2707
  * @return int $count The activity comment count.
2708
  */
2709
  function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
2710
 
2711
+ // Copy the count.
2712
  $new_count = $count;
2713
 
2714
+ // Loop through children and recursively count comments.
2715
  if ( ! empty( $comment->children ) ) {
2716
  foreach ( (array) $comment->children as $comment ) {
2717
  $new_count++;
2722
  /**
2723
  * Filters the total number of comments for the current comment.
2724
  *
2725
+ * @since 2.1.0
2726
  *
2727
  * @param int $new_count New total count for the current comment.
2728
  * @param object $comment Activity comment object.
2734
  /**
2735
  * Output the depth of the current activity comment.
2736
  *
2737
+ * @since 2.0.0
2738
  */
2739
  function bp_activity_comment_depth() {
2740
  echo bp_activity_get_comment_depth();
2742
  /**
2743
  * Return the current activity comment depth.
2744
  *
2745
+ * @since 2.0.0
2746
  *
2747
  * @return int $depth Depth for the current activity comment.
2748
  */
2752
  /**
2753
  * Filters the comment depth of the current activity comment.
2754
  *
2755
+ * @since 2.0.0
2756
  *
2757
  * @param int $depth Depth for the current activity comment.
2758
  */
2762
  /**
2763
  * Output the activity comment link.
2764
  *
2765
+ * @since 1.2.0
2766
  *
2767
  * @uses bp_get_activity_comment_link()
2768
  */
2773
  /**
2774
  * Return the activity comment link.
2775
  *
2776
+ * @since 1.2.0
2777
  *
2778
  * @global object $activities_template {@link BP_Activity_Template}
2779
  * @uses apply_filters() To call the 'bp_get_activity_comment_link' hook.
2786
  /**
2787
  * Filters the comment link for the current activity comment.
2788
  *
2789
+ * @since 1.2.0
2790
  *
2791
  * @param string $value Constructed URL parameters with activity IDs.
2792
  */
2796
  /**
2797
  * Output the activity comment form no JavaScript display CSS.
2798
  *
2799
+ * @since 1.2.0
2800
  *
2801
  * @uses bp_get_activity_comment_form_nojs_display()
2802
  */
2807
  /**
2808
  * Return the activity comment form no JavaScript display CSS.
2809
  *
2810
+ * @since 1.2.0
2811
  *
2812
  * @global object $activities_template {@link BP_Activity_Template}
2813
  *
2827
  /**
2828
  * Output the activity comment form action.
2829
  *
2830
+ * @since 1.2.0
2831
  *
2832
  * @uses bp_get_activity_comment_form_action()
2833
  */
2838
  /**
2839
  * Return the activity comment form action.
2840
  *
2841
+ * @since 1.2.0
2842
  *
2843
  * @uses home_url()
2844
  * @uses bp_get_activity_root_slug()
2851
  /**
2852
  * Filters the activity comment form action URL.
2853
  *
2854
+ * @since 1.2.0
2855
  *
2856
  * @param string $value URL to use in the comment form's action attribute.
2857
  */
2861
  /**
2862
  * Output the activity permalink ID.
2863
  *
2864
+ * @since 1.2.0
2865
  *
2866
  * @uses bp_get_activity_permalink_id()
2867
  */
2872
  /**
2873
  * Return the activity permalink ID.
2874
  *
2875
+ * @since 1.2.0
2876
  *
2877
  * @uses apply_filters() To call the 'bp_get_activity_permalink_id' hook.
2878
  *
2883
  /**
2884
  * Filters the activity action permalink ID.
2885
  *
2886
+ * @since 1.2.0
2887
  *
2888
  * @param string $value Current action for the activity item.
2889
  */
2893
  /**
2894
  * Output the activity thread permalink.
2895
  *
2896
+ * @since 1.2.0
2897
  *
2898
  * @uses bp_get_activity_permalink_id()
2899
  */
2904
  /**
2905
  * Return the activity thread permalink.
2906
  *
2907
+ * @since 1.2.0
2908
  *
2909
  * @uses bp_activity_get_permalink()
2910
  * @uses apply_filters() To call the 'bp_get_activity_thread_permalink' hook.
2919
  /**
2920
  * Filters the activity thread permalink.
2921
  *
2922
+ * @since 1.2.0
2923
  *
2924
  * @param string $link The activity thread permalink.
2925
  */
2926
+ return apply_filters( 'bp_get_activity_thread_permalink', $link );
2927
  }
2928
 
2929
  /**
2930
  * Output the activity comment permalink.
2931
  *
2932
+ * @since 1.8.0
2933
  *
2934
  * @uses bp_get_activity_permalink_id()
2935
  */
2939
  /**
2940
  * Return the activity comment permalink.
2941
  *
2942
+ * @since 1.8.0
2943
  *
2944
  * @uses bp_activity_get_permalink()
2945
  * @uses apply_filters() To call the 'bp_get_activity_comment_permalink' hook.
2949
  function bp_get_activity_comment_permalink() {
2950
  global $activities_template;
2951
 
2952
+ // Check that comment exists.
2953
  $comment_id = isset( $activities_template->activity->current_comment->id )
2954
  ? $activities_template->activity->current_comment->id
2955
  : 0;
2956
 
2957
+ // Setup the comment link.
2958
  $comment_link = ! empty( $comment_id )
2959
  ? '#acomment-' .$comment_id
2960
  : false;
2961
 
2962
+ // Append comment ID to end of activity permalink.
2963
  $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link;
2964
 
2965
  /**
2966
  * Filters the activity comment permalink.
2967
  *
2968
+ * @since 1.8.0
2969
  *
2970
  * @param string $link Activity comment permalink.
2971
  * @param int $comment_id ID for the current activity comment.
2976
  /**
2977
  * Output the activity favorite link.
2978
  *
2979
+ * @since 1.2.0
2980
  *
2981
  * @uses bp_get_activity_favorite_link()
2982
  */
2987
  /**
2988
  * Return the activity favorite link.
2989
  *
2990
+ * @since 1.2.0
2991
  *
2992
  * @global object $activities_template {@link BP_Activity_Template}
2993
  * @uses wp_nonce_url()
3003
  /**
3004
  * Filters the activity favorite link.
3005
  *
3006
+ * @since 1.2.0
3007
  *
3008
  * @param string $value Constructed link for favoriting the activity comment.
3009
  */
3013
  /**
3014
  * Output the activity unfavorite link.
3015
  *
3016
+ * @since 1.2.0
3017
  *
3018
  * @uses bp_get_activity_unfavorite_link()
3019
  */
3024
  /**
3025
  * Return the activity unfavorite link.
3026
  *
3027
+ * @since 1.2.0
3028
  *
3029
  * @global object $activities_template {@link BP_Activity_Template}
3030
  * @uses wp_nonce_url()
3040
  /**
3041
  * Filters the activity unfavorite link.
3042
  *
3043
+ * @since 1.2.0
3044
  *
3045
  * @param string $value Constructed link for unfavoriting the activity comment.
3046
  */
3050
  /**
3051
  * Output the activity CSS class.
3052
  *
3053
+ * @since 1.0.0
3054
  *
3055
  * @uses bp_get_activity_css_class()
3056
  */
3061
  /**
3062
  * Return the current activity item's CSS class.
3063
  *
3064
+ * @since 1.0.0
3065
  *
3066
  * @global object $activities_template {@link BP_Activity_Template}
3067
  * @uses apply_filters() To call the 'bp_activity_mini_activity_types' hook.
3077
  /**
3078
  * Filters the available mini activity actions available as CSS classes.
3079
  *
3080
+ * @since 1.2.0
3081
  *
3082
  * @param array $value Array of classes used to determine classes applied to HTML element.
3083
  */
3103
  /**
3104
  * Filters the determined classes to add to the HTML element.
3105
  *
3106
+ * @since 1.0.0
3107
  *
3108
  * @param string $value Classes to be added to the HTML element.
3109
  */
3113
  /**
3114
  * Output the activity delete link.
3115
  *
3116
+ * @since 1.1.0
3117
  *
3118
  * @uses bp_get_activity_delete_link()
3119
  */
3124
  /**
3125
  * Return the activity delete link.
3126
  *
3127
+ * @since 1.1.0
3128
  *
3129
  * @global object $activities_template {@link BP_Activity_Template}
3130
  * @uses bp_get_root_domain()
3143
  $url = bp_get_activity_delete_url();
3144
  $class = 'delete-activity';
3145
 
3146
+ // Determine if we're on a single activity page, and customize accordingly.
3147
  if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
3148
  $class = 'delete-activity-single';
3149
  }
3153
  /**
3154
  * Filters the activity delete link.
3155
  *
3156
+ * @since 1.1.0
3157
  *
3158
  * @param string $link Activity delete HTML link.
3159
  */
3163
  /**
3164
  * Output the URL to delete a single activity stream item.
3165
  *
3166
+ * @since 2.1.0
3167
  *
3168
  * @uses bp_get_activity_delete_link()
3169
  */
3173
  /**
3174
  * Return the URL to delete a single activity item.
3175
  *
3176
+ * @since 2.1.0
3177
  *
3178
  * @global object $activities_template {@link BP_Activity_Template}
3179
  * @uses bp_get_root_domain()
3193
 
3194
  $url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id );
3195
 
3196
+ // Determine if we're on a single activity page, and customize accordingly.
3197
  if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
3198
  $url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
3199
  }
3203
  /**
3204
  * Filters the activity delete URL.
3205
  *
3206
+ * @since 2.1.0
3207
  *
3208
  * @param string $url Activity delete URL.
3209
  */
3213
  /**
3214
  * Output the activity latest update link.
3215
  *
3216
+ * @since 1.2.0
3217
  *
3218
  * @see bp_get_activity_latest_update() for description of parameters.
3219
  * @uses bp_get_activity_latest_update()
3227
  /**
3228
  * Return the activity latest update link.
3229
  *
3230
+ * @since 1.2.0
3231
  *
3232
  * @uses bp_is_user_inactive()
3233
  * @uses bp_core_is_user_deleted()
3239
  * @uses apply_filters() To call the 'bp_get_activity_latest_update' hook.
3240
  *
3241
  * @param int $user_id If empty, will fall back on displayed user.
 
3242
  * @return string|bool $latest_update The activity latest update link.
3243
  * False on failure.
3244
  */
3259
  /**
3260
  * Filters the latest update excerpt.
3261
  *
3262
+ * @since 1.2.10
3263
  *
3264
  * @param string $value The excerpt for the latest update.
3265
  */
3275
  /**
3276
  * Filters the latest update excerpt with view link appended to the end.
3277
  *
3278
+ * @since 1.2.0
3279
  *
3280
  * @param string $latest_update The latest update with "view" link appended to it.
3281
  */
3285
  /**
3286
  * Output the activity filter links.
3287
  *
3288
+ * @since 1.1.0
3289
  *
3290
  * @see bp_get_activity_filter_links() for description of parameters.
3291
  * @uses bp_get_activity_filter_links()
3299
  /**
3300
  * Return the activity filter links.
3301
  *
3302
+ * @since 1.1.0
3303
  *
3304
  * @uses wp_parse_args()
3305
  * @uses BP_Activity_Activity::get_recorded_components() {@link BP_Activity_Activity}
3322
  'style' => 'list'
3323
  ) );
3324
 
3325
+ // Define local variable.
3326
  $component_links = array();
3327
 
3328
+ // Fetch the names of components that have activity recorded in the DB.
3329
  $components = BP_Activity_Activity::get_recorded_components();
3330
 
3331
  if ( empty( $components ) ) {
3334
 
3335
  foreach ( (array) $components as $component ) {
3336
 
3337
+ // Skip the activity comment filter.
3338
  if ( 'activity' == $component ) {
3339
  continue;
3340
  }
3371
  /**
3372
  * Filters the activity filter link URL for the current activity component.
3373
  *
3374
+ * @since 1.1.0
3375
  *
3376
  * @param string $link The URL for the current component.
3377
  * @param string $component The current component getting links constructed for.
3390
  /**
3391
  * Filters all of the constructed filter links.
3392
  *
3393
+ * @since 1.1.0
3394
  *
3395
  * @param string $value All of the links to be displayed to the user.
3396
  */
3400
  /**
3401
  * Determine if a comment can be made on an activity item.
3402
  *
3403
+ * @since 1.2.0
3404
  *
3405
  * @global object $activities_template {@link BP_Activity_Template}
3406
  * @uses bp_get_activity_action_name()
3412
  global $activities_template;
3413
  $bp = buddypress();
3414
 
3415
+ // Assume activity can be commented on.
3416
  $can_comment = true;
3417
 
3418
+ // Determine ability to comment based on activity action name.
3419
  $activity_action = bp_get_activity_action_name();
3420
 
3421
  $turn_off = 0;
3448
  /**
3449
  * Filters whether a comment can be made on an activity item.
3450
  *
3451
+ * @since 1.5.0
3452
  *
3453
  * @param bool $can_comment Status on if activity can be commented on.
3454
  * @param string $activity_action Current activity action being checked on.
3459
  /**
3460
  * Determine whether a comment can be made on an activity reply item.
3461
  *
3462
+ * @since 1.5.0
3463
  *
3464
  * @param bool|object $comment Activity comment.
3465
  * @return bool $can_comment True if comment can receive comments,
3467
  */
3468
  function bp_activity_can_comment_reply( $comment = false ) {
3469
 
3470
+ // Assume activity can be commented on.
3471
  $can_comment = true;
3472
 
3473
+ // Check that comment exists.
3474
  if ( empty( $comment ) ) {
3475
  $comment = bp_activity_current_comment();
3476
  }
3477
 
3478
  if ( ! empty( $comment ) ) {
3479
 
3480
+ // Fall back on current comment in activity loop.
3481
  $comment_depth = isset( $comment->depth )
3482
  ? intval( $comment->depth )
3483
  : bp_activity_get_comment_depth();
3484
 
3485
+ // Threading is turned on, so check the depth.
3486
  if ( get_option( 'thread_comments' ) ) {
3487
  $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
3488
 
3489
+ // No threading for comment replies if no threading for comments.
3490
  } else {
3491
  $can_comment = false;
3492
  }
3495
  /**
3496
  * Filters whether a comment can be made on an activity reply item.
3497
  *
3498
+ * @since 1.5.0
3499
  *
3500
  * @param bool $can_comment Status on if activity reply can be commented on.
3501
  * @param string $comment Current comment being checked on.
3508
  *
3509
  * Defaults to true, but can be modified by plugins.
3510
  *
3511
+ * @since 1.5.0
3512
  *
3513
  * @uses apply_filters() To call the 'bp_activity_can_favorite' hook.
3514
  *
3519
  /**
3520
  * Filters whether or not users can favorite activity items.
3521
  *
3522
+ * @since 1.5.0
3523
  *
3524
  * @param bool $value Whether or not favoriting is enabled.
3525
  */
3529
  /**
3530
  * Output the total favorite count for a specified user.
3531
  *
3532
+ * @since 1.2.0
3533
  *
3534
  * @see bp_get_total_favorite_count_for_user() for description of parameters.
3535
  * @uses bp_get_total_favorite_count_for_user()
3543
  /**
3544
  * Return the total favorite count for a specified user.
3545
  *
3546
+ * @since 1.2.0
3547
  *
3548
  * @uses bp_activity_total_favorites_for_user()
3549
  * @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook.
3550
  *
3551
  * @param int $user_id ID of user being queried. Default: displayed user ID.
 
3552
  * @return int The total favorite count for the specified user.
3553
  */
3554
  function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
3555
  $retval = false;
3556
 
3557
  if ( bp_activity_can_favorite() ) {
3558
+ // Default to displayed user if none is passed.
3559
  $user_id = empty( $user_id )
3560
  ? bp_displayed_user_id()
3561
  : $user_id;
3562
 
3563
+ // Get user meta if user ID exists.
3564
  if ( ! empty( $user_id ) ) {
3565
  $retval = bp_activity_total_favorites_for_user( $user_id );
3566
  }
3569
  /**
3570
  * Filters the total favorite count for a user.
3571
  *
3572
+ * @since 1.2.0
3573
  *
3574
  * @param int|bool $retval Total favorite count for a user. False on no favorites.
3575
  */
3580
  /**
3581
  * Output the total mention count for a specified user.
3582
  *
3583
+ * @since 1.2.0
3584
  *
3585
  * @see bp_get_total_mention_count_for_user() for description of parameters.
3586
  * @uses bp_get_total_favorite_count_for_user()
3594
  /**
3595
  * Return the total mention count for a specified user.
3596
  *
3597
+ * @since 1.2.0
3598
  *
3599
  * @uses bp_get_user_meta()
3600
  * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
3601
  *
3602
  * @param int $user_id ID of user being queried. Default: displayed user ID.
 
3603
  * @return int The total mention count for the specified user.
3604
  */
3605
  function bp_get_total_mention_count_for_user( $user_id = 0 ) {
3606
 
3607
+ // Default to displayed user if none is passed.
3608
  $user_id = empty( $user_id )
3609
  ? bp_displayed_user_id()
3610
  : $user_id;
3611
 
3612
+ // Get user meta if user ID exists.
3613
  $retval = ! empty( $user_id )
3614
  ? bp_get_user_meta( $user_id, 'bp_new_mention_count', true )
3615
  : false;
3617
  /**
3618
  * Filters the total mention count for a user.
3619
  *
3620
+ * @since 1.2.0
3621
  *
3622
  * @param int|bool $retval Total mention count for a user. False on no mentions.
3623
  */
3627
  /**
3628
  * Output the public message link for displayed user.
3629
  *
3630
+ * @since 1.2.0
3631
  *
3632
  * @uses bp_get_send_public_message_link()
3633
  */
3638
  /**
3639
  * Return the public message link for the displayed user.
3640
  *
3641
+ * @since 1.2.0
3642
  *
3643
  * @uses is_user_logged_in()
3644
  * @uses bp_is_my_profile()
3651
  */
3652
  function bp_get_send_public_message_link() {
3653
 
3654
+ // No link if not logged in, not looking at someone else's profile.
3655
  if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() ) {
3656
  $retval = '';
3657
  } else {
3663
  /**
3664
  * Filters the public message link for the displayed user.
3665
  *
3666
+ * @since 1.2.0
3667
  *
3668
  * @param string $retval The URL for the public message link.
3669
  */
3673
  /**
3674
  * Recurse through all activity comments and return the activity comment IDs.
3675
  *
3676
+ * @since 2.0.0
3677
  *
3678
  * @param array $activity Array of activities generated from {@link bp_activity_get()}.
3679
  * @param array $activity_ids Used for recursion purposes in this function.
 
3680
  * @return array
3681
  */
3682
  function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) {
3700
  /**
3701
  * Output the mentioned user display name.
3702
  *
3703
+ * @since 1.2.0
3704
  *
3705
  * @see bp_get_mentioned_user_display_name() for description of parameters.
3706
  * @uses bp_get_mentioned_user_display_name()
3714
  /**
3715
  * Returns the mentioned user display name.
3716
  *
3717
+ * @since 1.2.0
3718
  *
3719
  * @uses bp_core_get_user_displayname()
3720
  * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
3721
  *
3722
+ * @param int|string|bool $user_id_or_username User ID or username.
 
3723
  * @return string The mentioned user's display name.
3724
  */
3725
  function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
3726
 
3727
+ // Get user display name.
3728
  $name = bp_core_get_user_displayname( $user_id_or_username );
3729
 
3730
+ // If user somehow has no name, return this really lame string.
3731
  if ( empty( $name ) ) {
3732
  $name = __( 'a user', 'buddypress' );
3733
  }
3735
  /**
3736
  * Filters the mentioned user display name.
3737
  *
3738
+ * @since 1.2.0
3739
  *
3740
  * @param string $name Display name for the mentioned user.
3741
  * @param int|string $user_id_or_username User ID or username use for query.
3746
  /**
3747
  * Output button for sending a public message (an @-mention).
3748
  *
3749
+ * @since 1.2.0
3750
  *
3751
  * @see bp_get_send_public_message_button() for description of parameters.
3752
  * @uses bp_get_send_public_message_button()
3760
  /**
3761
  * Return button for sending a public message (an @-mention).
3762
  *
3763
+ * @since 1.2.0
3764
  *
3765
  * @uses bp_get_send_public_message_link()
3766
  * @uses wp_parse_args()
3801
  /**
3802
  * Filters the public message button HTML.
3803
  *
3804
+ * @since 1.2.10
3805
  *
3806
  * @param array $r Array of arguments for the public message button HTML.
3807
  */
3811
  /**
3812
  * Output the activity post form action.
3813
  *
3814
+ * @since 1.2.0
3815
  *
3816
  * @uses bp_get_activity_post_form_action()
3817
  */
3822
  /**
3823
  * Return the activity post form action.
3824
  *
3825
+ * @since 1.2.0
3826
  *
3827
  * @uses home_url()
3828
  * @uses bp_get_activity_root_slug()
3835
  /**
3836
  * Filters the action url used for the activity post form.
3837
  *
3838
+ * @since 1.2.0
3839
  *
3840
  * @param string $value URL to be used for the activity post form.
3841
  */
3850
  * Avatars are wrapped in <li> elements, but you've got to provide your own
3851
  * <ul> or <ol> wrapper markup.
3852
  *
3853
+ * @since 1.7.0
3854
  *
3855
  * @see bp_core_fetch_avatar() for a description of arguments.
3856
  *
3865
  'width' => false,
3866
  ) );
3867
 
3868
+ // Get the user IDs of everyone who has left a comment to the current activity item.
3869
  $user_ids = bp_activity_get_comments_user_ids();
3870
  $output = array();
3871
  $retval = '';
3873
  if ( ! empty( $user_ids ) ) {
3874
  foreach ( (array) $user_ids as $user_id ) {
3875
 
3876
+ // Skip an empty user ID.
3877
  if ( empty( $user_id ) ) {
3878
  continue;
3879
  }
3880
 
3881
+ // Get profile link for this user.
3882
  $profile_link = bp_core_get_user_domain( $user_id );
3883
 
3884
+ // Get avatar for this user.
3885
  $image_html = bp_core_fetch_avatar( array(
3886
  'item_id' => $user_id,
3887
  'height' => $r['height'],
3890
  'width' => $r['width']
3891
  ) );
3892
 
3893
+ // If user has link & avatar, add them to the output array.
3894
  if ( ! empty( $profile_link ) && ! empty( $image_html ) ) {
3895
  $output[] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $profile_link ), $image_html );
3896
  }
3897
  }
3898
 
3899
+ // If output array is not empty, wrap everything in some list items.
3900
  if ( ! empty( $output ) ) {
3901
  $retval = '<li>' . implode( '</li><li>', $output ) . '</li>';
3902
  }
3905
  /**
3906
  * Filters the list of linked avatars for users who have commented on the current activity item.
3907
  *
3908
+ * @since 1.7.0
3909
  *
3910
  * @param string $retval HTML markup for the list of avatars.
3911
  * @param array $r Array of arguments used for each avatar.
3917
  /**
3918
  * Return the IDs of every user who's left a comment on the current activity item.
3919
  *
3920
+ * @since 1.7.0
3921
  *
3922
  * @return bool|array An array of IDs, or false if none are found.
3923
  */
3931
  /**
3932
  * Filters the list of user IDs for the current activity item.
3933
  *
3934
+ * @since 1.7.0
3935
  *
3936
  * @param array $value Array of unique user IDs for the current activity item.
3937
  */
3941
  /**
3942
  * Recurse through all activity comments and collect the IDs of the users who wrote them.
3943
  *
3944
+ * @since 1.7.0
3945
  *
3946
  * @param array $comments Array of {@link BP_Activity_Activity} items.
 
3947
  * @return array Array of user IDs.
3948
  */
3949
  function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
3950
 
3951
+ // Default user ID's array.
3952
  $user_ids = array();
3953
 
3954
+ // Loop through comments and try to get user ID's.
3955
  if ( ! empty( $comments ) ) {
3956
  foreach ( $comments as $comment ) {
3957
 
3961
  continue;
3962
  }
3963
 
3964
+ // Add user ID to array.
3965
  $user_ids[] = $comment->user_id;
3966
 
3967
+ // Check for commentception.
3968
  if ( ! empty( $comment->children ) ) {
3969
  $user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) );
3970
  }
3974
  /**
3975
  * Filters the list of user IDs for the current activity comment item.
3976
  *
3977
+ * @since 2.1.0
3978
  *
3979
  * @param array $user_ids Array of user IDs for the current activity comment item.
3980
  * @param array $comments Array of comments being checked for user IDs.
3985
  /**
3986
  * Output the mentionname for the displayed user.
3987
  *
3988
+ * @since 1.9.0
3989
  */
3990
  function bp_displayed_user_mentionname() {
3991
  echo bp_get_displayed_user_mentionname();
3993
  /**
3994
  * Get the mentionname for the displayed user.
3995
  *
3996
+ * @since 1.9.0
3997
  *
3998
  * @return string Mentionname for the displayed user, if available.
3999
  */
4002
  /**
4003
  * Filters the mentionname for the displayed user.
4004
  *
4005
+ * @since 1.9.0
4006
  *
4007
  * @param string $value The mentionanme for the displayed user.
4008
  */
4012
  /**
4013
  * Echo a list of all registered activity types for use in dropdowns or checkbox lists.
4014
  *
4015
+ * @since 1.7.0
4016
  *
4017
  * @param string $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
4018
  * @param array|string $args {
4033
  $activities = bp_activity_get_types();
4034
  natsort( $activities );
4035
 
4036
+ // Loop through the activity types and output markup.
4037
  foreach ( $activities as $type => $description ) {
4038
 
4039
+ // See if we need to preselect the current type.
4040
  $checked = checked( true, in_array( $type, (array) $args['selected'] ), false );
4041
  $selected = selected( true, in_array( $type, (array) $args['selected'] ), false );
4042
 
4043
+ // Switch output based on the element.
4044
  switch ( $output ) {
4045
  case 'select' :
4046
  printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $type ), $selected, esc_html( $description ) );
4056
  * This is a variable action hook. The actual hook to use will depend on the output type specified.
4057
  * Two default hooks are bp_activity_types_list_select and bp_activity_types_list_checkbox.
4058
  *
4059
+ * @since 1.7.0
4060
  *
4061
  * @param array $args Array of arguments passed into function.
4062
  * @param string $type Activity type being rendered in the output.
4065
  do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
4066
  }
4067
 
4068
+ // Backpat with BP-Default for dropdown boxes only.
4069
  if ( 'select' === $output ) {
4070
  do_action( 'bp_activity_filter_options' );
4071
  }
4077
  /**
4078
  * Output the sitewide activity feed link.
4079
  *
4080
+ * @since 1.0.0
4081
  *
4082
  * @uses bp_get_sitewide_activity_feed_link()
4083
  */
4088
  /**
4089
  * Returns the sitewide activity feed link.
4090
  *
4091
+ * @since 1.0.0
4092
  *
4093
  * @uses home_url()
4094
  * @uses bp_get_activity_root_slug()
4101
  /**
4102
  * Filters the sidewide activity feed link.
4103
  *
4104
+ * @since 1.0.0
4105
  *
4106
  * @param string $value The feed link for sitewide activity.
4107
  */
4111
  /**
4112
  * Output the member activity feed link.
4113
  *
4114
+ * @since 1.2.0
4115
  *
4116
  * @uses bp_get_member_activity_feed_link()
4117
  */
4122
  /**
4123
  * Output the member activity feed link.
4124
  *
4125
+ * @since 1.0.0
4126
+ * @deprecated 1.2.0
4127
  *
4128
  * @todo properly deprecate in favor of bp_member_activity_feed_link().
4129
  *
4134
  /**
4135
  * Return the member activity feed link.
4136
  *
4137
+ * @since 1.2.0
4138
  *
4139
  * @uses bp_is_profile_component()
4140
  * @uses bp_is_current_action()
4149
  */
4150
  function bp_get_member_activity_feed_link() {
4151
 
4152
+ // Single member activity feed link.
4153
  if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
4154
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
4155
 
4156
+ // Friend feed link.
4157
  } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
4158
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
4159
 
4160
+ // Group feed link.
4161
  } elseif ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
4162
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
4163
 
4164
+ // Favorites activity feed link.
4165
  } elseif ( 'favorites' === bp_current_action() ) {
4166
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
4167
 
4168
+ // Mentions activity feed link.
4169
  } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
4170
  $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
4171
 
4172
+ // No feed link.
4173
  } else {
4174
  $link = '';
4175
  }
4177
  /**
4178
  * Filters the member activity feed link.
4179
  *
4180
+ * @since 1.0.0
4181
  *
4182
  * @param string $link URL for the member activity feed.
4183
  */
4187
  /**
4188
  * Return the member activity feed link.
4189
  *
4190
+ * @since 1.0.0
4191
+ * @deprecated 1.2.0
4192
  *
4193
  * @todo properly deprecate in favor of bp_get_member_activity_feed_link().
4194
  *
4204
  /**
4205
  * Outputs the activity feed item guid.
4206
  *
4207
+ * @since 1.0.0
4208
  *
4209
  * @uses bp_activity_feed_item_guid()
4210
  */
4215
  /**
4216
  * Returns the activity feed item guid.
4217
  *
4218
+ * @since 1.2.0
4219
  *
4220
  * @global object $activities_template {@link BP_Activity_Template}
4221
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_guid' hook.
4228
  /**
4229
  * Filters the activity feed item guid.
4230
  *
4231
+ * @since 1.1.3
4232
  *
4233
  * @param string $value Calculated md5 value for the activity feed item.
4234
  */
4238
  /**
4239
  * Output the activity feed item title.
4240
  *
4241
+ * @since 1.0.0
4242
  *
4243
  * @uses bp_get_activity_feed_item_title()
4244
  */
4249
  /**
4250
  * Return the activity feed item title.
4251
  *
4252
+ * @since 1.0.0
4253
  *
4254
  * @global object $activities_template {@link BP_Activity_Template}
4255
  * @uses ent2ncr()
4282
  /**
4283
  * Filters the activity feed item title.
4284
  *
4285
+ * @since 1.0.0
4286
  *
4287
  * @param string $title The title for the activity feed item.
4288
  */
4292
  /**
4293
  * Output the activity feed item link.
4294
  *
4295
+ * @since 1.0.0
4296
  *
4297
  * @uses bp_get_activity_feed_item_link()
4298
  */
4303
  /**
4304
  * Return the activity feed item link.
4305
  *
4306
+ * @since 1.0.0
4307
  *
4308
  * @global object $activities_template {@link BP_Activity_Template}
4309
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_link' hook.
4320
  /**
4321
  * Filters the activity feed item link.
4322
  *
4323
+ * @since 1.0.0
4324
  *
4325
  * @param string $retval The URL for the activity feed item.
4326
  */
4330
  /**
4331
  * Output the activity feed item date.
4332
  *
4333
+ * @since 1.0.0
4334
  *
4335
  * @uses bp_get_activity_feed_item_date()
4336
  */
4341
  /**
4342
  * Return the activity feed item date.
4343
  *
4344
+ * @since 1.0.0
4345
  *
4346
  * @global object $activities_template {@link BP_Activity_Template}
4347
  * @uses apply_filters() To call the 'bp_get_activity_feed_item_date' hook.
4358
  /**
4359
  * Filters the activity feed item date.
4360
  *
4361
+ * @since 1.0.0
4362
  *
4363
  * @param string $retval The date for the activity feed item.
4364
  */
4368
  /**
4369
  * Output the activity feed item description.
4370
  *
4371
+ * @since 1.0.0
4372
  *
4373
  * @uses bp_get_activity_feed_item_description()
4374
  */
4379
  /**
4380
  * Return the activity feed item description.
4381
  *
4382
+ * @since 1.0.0
4383
  *
4384
  * @global object $activities_template {@link BP_Activity_Template}
4385
  * @uses ent2ncr()
4391
  function bp_get_activity_feed_item_description() {
4392
  global $activities_template;
4393
 
4394
+ // Get the content, if exists.
4395
  $content = ! empty( $activities_template->activity->content )
4396
  ? $activities_template->activity->content
4397
  : '';
4398
 
4399
+ // Perform a few string conversions on the content, if it's not empty.
4400
  if ( ! empty( $content ) ) {
4401
  $content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) );
4402
  }
4404
  /**
4405
  * Filters the activity feed item description.
4406
  *
4407
+ * @since 1.0.0
4408
  *
4409
  * @param string $content The description for the activity feed item.
4410
  */
4414
  /**
4415
  * Template tag so we can hook activity feed to <head>.
4416
  *
4417
+ * @since 1.5.0
4418
  *
4419
  * @uses bloginfo()
4420
  * @uses bp_sitewide_activity_feed_link()
4431
  /**
4432
  * Display available filters depending on the scope.
4433
  *
4434
+ * @since 2.1.0
4435
  *
4436
  * @param string $context The current context. 'activity', 'member',
4437
+ * 'member_groups', 'group'.
4438
  * @uses bp_get_activity_show_filters()
4439
  */
4440
  function bp_activity_show_filters( $context = '' ) {
4443
  /**
4444
  * Get available filters depending on the scope.
4445
  *
4446
+ * @since 2.1.0
4447
  *
4448
  * @param string $context The current context. 'activity', 'member',
4449
+ * 'member_groups', 'group'.
4450
  *
4451
  * @return string HTML for <option> values.
4452
  */
4453
  function bp_get_activity_show_filters( $context = '' ) {
4454
+ // Set default context based on current page.
4455
  if ( empty( $context ) ) {
4456
 
4457
  // On member pages, default to 'member', unless this
4458
+ // is a user's Groups activity.
4459
  if ( bp_is_user() ) {
4460
  if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
4461
  $context = 'member_groups';
4463
  $context = 'member';
4464
  }
4465
 
4466
+ // On individual group pages, default to 'group'.
4467
  } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) {
4468
  $context = 'group';
4469
 
4470
+ // 'activity' everywhere else.
4471
  } else {
4472
  $context = 'activity';
4473
  }
4483
  continue;
4484
  }
4485
 
4486
+ // Friends activity collapses two filters into one.
4487
  if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
4488
  $action['key'] = 'friendship_accepted,friendship_created';
4489
  }
4495
  /**
4496
  * Filters the options available in the activity filter dropdown.
4497
  *
4498
+ * @since 2.2.0
4499
  *
4500
  * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
4501
  * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
4502
  */
4503
  $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
4504
 
4505
+ // Build the options output.
4506
  $output = '';
4507
 
4508
  if ( ! empty( $filters ) ) {
4514
  /**
4515
  * Filters the HTML markup result for the activity filter dropdown.
4516
  *
4517
+ * @since 2.1.0
4518
  *
4519
  * @param string $output HTML output for the activity filter dropdown.
4520
  * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
bp-activity/classes/class-bp-activity-activity.php CHANGED
@@ -6,7 +6,7 @@
6
  * @subpackage Activity
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
@@ -15,7 +15,7 @@ defined( 'ABSPATH' ) || exit;
15
  * Instance methods are available for creating/editing an activity,
16
  * static methods for querying activities.
17
  *
18
- * @since BuddyPress (1.0.0)
19
  */
20
  class BP_Activity_Activity {
21
 
@@ -163,17 +163,17 @@ class BP_Activity_Activity {
163
  $this->is_spam = $row->is_spam;
164
  }
165
 
166
- // Generate dynamic 'action' when possible
167
  $action = bp_activity_generate_action_string( $this );
168
  if ( false !== $action ) {
169
  $this->action = $action;
170
 
171
  // If no callback is available, use the literal string from
172
- // the database row
173
  } elseif ( ! empty( $row->action ) ) {
174
  $this->action = $row->action;
175
 
176
- // Provide a fallback to avoid PHP notices
177
  } else {
178
  $this->action = '';
179
  }
@@ -209,7 +209,7 @@ class BP_Activity_Activity {
209
  *
210
  * Please use this hook to filter the properties above. Each part will be passed in.
211
  *
212
- * @since BuddyPress (1.0.0)
213
  *
214
  * @param BP_Activity_Activity $this Current instance of the activity item being saved. Passed by reference.
215
  */
@@ -234,7 +234,7 @@ class BP_Activity_Activity {
234
  return false;
235
  }
236
 
237
- // If this is a new activity item, set the $id property
238
  if ( empty( $this->id ) ) {
239
  $this->id = $wpdb->insert_id;
240
 
@@ -246,7 +246,7 @@ class BP_Activity_Activity {
246
  /**
247
  * Fires after an activity item has been saved to the database.
248
  *
249
- * @since BuddyPress (1.0.0)
250
  *
251
  * @param BP_Activity_Activity $this Current instance of activity item being saved. Passed by reference.
252
  */
@@ -260,6 +260,9 @@ class BP_Activity_Activity {
260
  /**
261
  * Get activity items, as specified by parameters.
262
  *
 
 
 
263
  * @see BP_Activity_Activity::get_filter_sql() for a description of the
264
  * 'filter' parameter.
265
  * @see WP_Meta_Query::queries for a description of the 'meta_query'
@@ -267,11 +270,12 @@ class BP_Activity_Activity {
267
  *
268
  * @param array $args {
269
  * An array of arguments. All items are optional.
270
- *
271
  * @type int $page Which page of results to fetch. Using page=1 without per_page will result
272
  * in no pagination. Default: 1.
273
  * @type int|bool $per_page Number of results per page. Default: 25.
274
  * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
 
 
275
  * @type string $sort ASC or DESC. Default: 'DESC'.
276
  * @type array $exclude Array of activity IDs to exclude. Default: false.
277
  * @type array $in Array of ids to limit query by (IN). Default: false.
@@ -290,13 +294,13 @@ class BP_Activity_Activity {
290
  * for the query. Default: false.
291
  * }
292
  * @return array The array returned has two keys:
293
- * - 'total' is the count of located activities
294
- * - 'activities' is an array of the located activities
295
  */
296
  public static function get( $args = array() ) {
297
  global $wpdb;
298
 
299
- // Backward compatibility with old method of passing arguments
300
  if ( !is_array( $args ) || func_num_args() > 1 ) {
301
  _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
302
 
@@ -320,53 +324,54 @@ class BP_Activity_Activity {
320
 
321
  $bp = buddypress();
322
  $r = wp_parse_args( $args, array(
323
- 'page' => 1, // The current page
324
- 'per_page' => 25, // Activity items per page
325
- 'max' => false, // Max number of items to return
326
- 'sort' => 'DESC', // ASC or DESC
327
- 'exclude' => false, // Array of ids to exclude
328
- 'in' => false, // Array of ids to limit query by (IN)
329
- 'meta_query' => false, // Filter by activitymeta
330
- 'date_query' => false, // Filter by date
331
- 'filter_query' => false, // Advanced filtering - see BP_Activity_Query
332
- 'filter' => false, // See self::get_filter_sql()
333
- 'scope' => false, // Preset activity arguments
334
- 'search_terms' => false, // Terms to search by
335
- 'display_comments' => false, // Whether to include activity comments
336
- 'show_hidden' => false, // Show items marked hide_sitewide
337
- 'spam' => 'ham_only', // Spam status
338
- 'update_meta_cache' => true,
339
- 'count_total' => false,
 
340
  ) );
341
 
342
- // Select conditions
343
  $select_sql = "SELECT DISTINCT a.id";
344
 
345
  $from_sql = " FROM {$bp->activity->table_name} a";
346
 
347
  $join_sql = '';
348
 
349
- // Where conditions
350
  $where_conditions = array();
351
 
352
- // Excluded types
353
  $excluded_types = array();
354
 
355
- // Scope takes precedence
356
  if ( ! empty( $r['scope'] ) ) {
357
  $scope_query = self::get_scope_query_sql( $r['scope'], $r );
358
 
359
- // Add our SQL conditions if matches were found
360
  if ( ! empty( $scope_query['sql'] ) ) {
361
  $where_conditions['scope_query_sql'] = $scope_query['sql'];
362
  }
363
 
364
- // override some arguments if needed
365
  if ( ! empty( $scope_query['override'] ) ) {
366
  $r = self::array_replace_recursive( $r, $scope_query['override'] );
367
  }
368
 
369
- // Advanced filtering
370
  } elseif ( ! empty( $r['filter_query'] ) ) {
371
  $filter_query = new BP_Activity_Query( $r['filter_query'] );
372
  $sql = $filter_query->get_sql();
@@ -375,25 +380,25 @@ class BP_Activity_Activity {
375
  }
376
  }
377
 
378
- // Regular filtering
379
  if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
380
  $where_conditions['filter_sql'] = $filter_sql;
381
  }
382
 
383
- // Spam
384
  if ( 'ham_only' == $r['spam'] ) {
385
  $where_conditions['spam_sql'] = 'a.is_spam = 0';
386
  } elseif ( 'spam_only' == $r['spam'] ) {
387
  $where_conditions['spam_sql'] = 'a.is_spam = 1';
388
  }
389
 
390
- // Searching
391
  if ( $r['search_terms'] ) {
392
  $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
393
  $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
394
  }
395
 
396
- // Sorting
397
  $sort = $r['sort'];
398
  if ( $sort != 'ASC' && $sort != 'DESC' ) {
399
  $sort = 'DESC';
@@ -404,19 +409,19 @@ class BP_Activity_Activity {
404
  $where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
405
  }
406
 
407
- // Exclude specified items
408
  if ( ! empty( $r['exclude'] ) ) {
409
  $exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
410
  $where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
411
  }
412
 
413
- // The specific ids to which you want to limit the query
414
  if ( ! empty( $r['in'] ) ) {
415
  $in = implode( ',', wp_parse_id_list( $r['in'] ) );
416
  $where_conditions['in'] = "a.id IN ({$in})";
417
  }
418
 
419
- // Process meta_query into SQL
420
  $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
421
 
422
  if ( ! empty( $meta_query_sql['join'] ) ) {
@@ -427,7 +432,7 @@ class BP_Activity_Activity {
427
  $where_conditions[] = $meta_query_sql['where'];
428
  }
429
 
430
- // Process date_query into SQL
431
  $date_query_sql = self::get_date_query_sql( $r['date_query'] );
432
 
433
  if ( ! empty( $date_query_sql ) ) {
@@ -442,12 +447,12 @@ class BP_Activity_Activity {
442
  }
443
 
444
  // Exclude 'last_activity' items unless the 'action' filter has
445
- // been explicitly set
446
  if ( empty( $r['filter']['object'] ) ) {
447
  $excluded_types[] = 'last_activity';
448
  }
449
 
450
- // Build the excluded type sql part
451
  if ( ! empty( $excluded_types ) ) {
452
  $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
453
  $where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
@@ -456,7 +461,7 @@ class BP_Activity_Activity {
456
  /**
457
  * Filters the MySQL WHERE conditions for the Activity items get method.
458
  *
459
- * @since BuddyPress (1.9.0)
460
  *
461
  * @param array $where_conditions Current conditions for MySQL WHERE statement.
462
  * @param array $r Parsed arguments passed into method.
@@ -466,13 +471,13 @@ class BP_Activity_Activity {
466
  */
467
  $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
468
 
469
- // Join the where conditions together
470
  $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
471
 
472
  /**
473
  * Filters the preferred order of indexes for activity item.
474
  *
475
- * @since BuddyPress (1.6.0)
476
  *
477
  * @param array Array of indexes in preferred order.
478
  */
@@ -481,7 +486,7 @@ class BP_Activity_Activity {
481
  foreach( $indexes as $key => $index ) {
482
  if ( false !== strpos( $where_sql, $index ) ) {
483
  $the_index = $index;
484
- break; // Take the first one we find
485
  }
486
  }
487
 
@@ -491,7 +496,7 @@ class BP_Activity_Activity {
491
  $index_hint_sql = '';
492
  }
493
 
494
- // Sanitize page and per_page parameters
495
  $page = absint( $r['page'] );
496
  $per_page = absint( $r['per_page'] );
497
 
@@ -506,7 +511,7 @@ class BP_Activity_Activity {
506
  *
507
  * It is not recommended to use the legacy structure, but allowed to if needed.
508
  *
509
- * @since BuddyPress (2.0.0)
510
  *
511
  * @param bool $value Whether to use legacy structure or not.
512
  * @param BP_Activity_Activity $value Current method being called.
@@ -514,14 +519,14 @@ class BP_Activity_Activity {
514
  */
515
  if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
516
 
517
- // Legacy queries joined against the user table
518
  $select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
519
  $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
520
 
521
  if ( ! empty( $page ) && ! empty( $per_page ) ) {
522
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
523
 
524
- /** this filter is documented in bp-activity/bp-activity-classes.php */
525
  $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
526
  } else {
527
  $pag_sql = '';
@@ -529,7 +534,7 @@ class BP_Activity_Activity {
529
  /**
530
  * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
531
  *
532
- * @since BuddyPress (1.5.0)
533
  *
534
  * @param string $value Concatenated MySQL statement pieces to be query results with for legacy query.
535
  * @param string $select_sql Final SELECT MySQL statement portion for legacy query.
@@ -541,19 +546,19 @@ class BP_Activity_Activity {
541
  }
542
 
543
  } else {
544
- // Query first for activity IDs
545
  $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
546
 
547
  if ( ! empty( $per_page ) && ! empty( $page ) ) {
548
  // We query for $per_page + 1 items in order to
549
- // populate the has_more_items flag
550
  $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
551
  }
552
 
553
  /**
554
  * Filters the paged activities MySQL statement.
555
  *
556
- * @since BuddyPress (2.0.0)
557
  *
558
  * @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
559
  * @param array $r Array of arguments passed into method.
@@ -565,46 +570,52 @@ class BP_Activity_Activity {
565
  $retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
566
 
567
  // If we've fetched more than the $per_page value, we
568
- // can discard the extra now
569
  if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
570
  array_pop( $activity_ids );
571
  }
572
 
573
- $activities = self::get_activity_data( $activity_ids );
 
 
 
 
574
  }
575
 
576
- // Get the fullnames of users so we don't have to query in the loop
577
- $activities = self::append_user_fullnames( $activities );
 
578
 
579
- // Get activity meta
580
- $activity_ids = array();
581
- foreach ( (array) $activities as $activity ) {
582
- $activity_ids[] = $activity->id;
583
- }
584
 
585
- if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
586
- bp_activity_update_meta_cache( $activity_ids );
587
- }
588
 
589
- if ( $activities && $r['display_comments'] ) {
590
- $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
591
- }
592
 
593
- // Pre-fetch data associated with activity users and other objects
594
- BP_Activity_Activity::prefetch_object_data( $activities );
595
 
596
- // Generate action strings
597
- $activities = BP_Activity_Activity::generate_action_strings( $activities );
 
598
 
599
  $retval['activities'] = $activities;
600
 
601
- // If $max is set, only return up to the max results
602
  if ( ! empty( $r['count_total'] ) ) {
603
 
604
  /**
605
  * Filters the total activities MySQL statement.
606
  *
607
- * @since BuddyPress (1.5.0)
608
  *
609
  * @param string $value MySQL statement used to query for total activities.
610
  * @param string $where_sql MySQL WHERE statement portion.
@@ -628,53 +639,52 @@ class BP_Activity_Activity {
628
  /**
629
  * Convert activity IDs to activity objects, as expected in template loop.
630
  *
631
- * @since BuddyPress (2.0.0)
632
  *
633
  * @param array $activity_ids Array of activity IDs.
634
- *
635
  * @return array
636
  */
637
  protected static function get_activity_data( $activity_ids = array() ) {
638
  global $wpdb;
639
 
640
- // Bail if no activity ID's passed
641
  if ( empty( $activity_ids ) ) {
642
  return array();
643
  }
644
 
645
- // Get BuddyPress
646
  $bp = buddypress();
647
 
648
  $activities = array();
649
  $uncached_ids = bp_get_non_cached_ids( $activity_ids, 'bp_activity' );
650
 
651
- // Prime caches as necessary
652
  if ( ! empty( $uncached_ids ) ) {
653
- // Format the activity ID's for use in the query below
654
  $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
655
 
656
- // Fetch data from activity table, preserving order
657
  $queried_adata = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$uncached_ids_sql})");
658
 
659
  // Put that data into the placeholders created earlier,
660
- // and add it to the cache
661
  foreach ( (array) $queried_adata as $adata ) {
662
  wp_cache_set( $adata->id, $adata, 'bp_activity' );
663
  }
664
  }
665
 
666
- // Now fetch data from the cache
667
  foreach ( $activity_ids as $activity_id ) {
668
  $activities[] = wp_cache_get( $activity_id, 'bp_activity' );
669
  }
670
 
671
- // Then fetch user data
672
  $user_query = new BP_User_Query( array(
673
  'user_ids' => wp_list_pluck( $activities, 'user_id' ),
674
  'populate_extras' => false,
675
  ) );
676
 
677
- // Associated located user data with activity items
678
  foreach ( $activities as $a_index => $a_item ) {
679
  $a_user_id = intval( $a_item->user_id );
680
  $a_user = isset( $user_query->results[ $a_user_id ] ) ? $user_query->results[ $a_user_id ] : '';
@@ -693,10 +703,9 @@ class BP_Activity_Activity {
693
  /**
694
  * Append xProfile fullnames to an activity array.
695
  *
696
- * @since BuddyPress (2.0.0)
697
  *
698
  * @param array $activities Activities array.
699
- *
700
  * @return array
701
  */
702
  protected static function append_user_fullnames( $activities ) {
@@ -734,10 +743,9 @@ class BP_Activity_Activity {
734
  * components, such as bp-friends and bp-groups, to hook in and prime
735
  * their own caches at the beginning of an activity loop.
736
  *
737
- * @since BuddyPress (2.0.0)
738
  *
739
  * @param array $activities Array of activities.
740
- *
741
  * @return array $activities Array of activities.
742
  */
743
  protected static function prefetch_object_data( $activities ) {
@@ -745,7 +753,7 @@ class BP_Activity_Activity {
745
  /**
746
  * Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
747
  *
748
- * @since BuddyPress (2.0.0)
749
  *
750
  * @param array $activities Array of activities.
751
  */
@@ -760,10 +768,9 @@ class BP_Activity_Activity {
760
  * registered), the static 'action' value pulled from the database will
761
  * be left in place.
762
  *
763
- * @since BuddyPress (2.0.0)
764
  *
765
  * @param array $activities Array of activities.
766
- *
767
  * @return array
768
  */
769
  protected static function generate_action_strings( $activities ) {
@@ -788,11 +795,10 @@ class BP_Activity_Activity {
788
  * WP_Query, we have to alter the return value (stripping the leading
789
  * AND keyword from the 'where' clause).
790
  *
791
- * @since BuddyPress (1.8.0)
792
  *
793
  * @param array $meta_query An array of meta_query filters. See the
794
  * documentation for WP_Meta_Query for details.
795
- *
796
  * @return array $sql_array 'join' and 'where' clauses.
797
  */
798
  public static function get_meta_query_sql( $meta_query = array() ) {
@@ -807,12 +813,12 @@ class BP_Activity_Activity {
807
  $activity_meta_query = new WP_Meta_Query( $meta_query );
808
 
809
  // WP_Meta_Query expects the table name at
810
- // $wpdb->activitymeta
811
  $wpdb->activitymeta = buddypress()->activity->table_name_meta;
812
 
813
  $meta_sql = $activity_meta_query->get_sql( 'activity', 'a', 'id' );
814
 
815
- // Strip the leading AND - BP handles it in get()
816
  $sql_array['where'] = preg_replace( '/^\sAND/', '', $meta_sql['where'] );
817
  $sql_array['join'] = $meta_sql['join'];
818
  }
@@ -829,18 +835,17 @@ class BP_Activity_Activity {
829
  * WP_Query, we have to alter the return value (stripping the leading AND
830
  * keyword from the query).
831
  *
832
- * @since BuddyPress (2.1.0)
833
  *
834
  * @param array $date_query An array of date_query parameters. See the
835
  * documentation for the first parameter of WP_Date_Query.
836
- *
837
  * @return string
838
  */
839
  public static function get_date_query_sql( $date_query = array() ) {
840
  $sql = '';
841
 
842
- // Date query
843
- if ( ! empty( $date_query ) && is_array( $date_query ) && class_exists( 'BP_Date_Query' ) ) {
844
  $date_query = new BP_Date_Query( $date_query, 'date_recorded' );
845
  $sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
846
  }
@@ -856,41 +861,40 @@ class BP_Activity_Activity {
856
  *
857
  * Can handle multiple scopes.
858
  *
859
- * @since BuddyPress (2.2.0)
860
  *
861
  * @param mixed $scope The activity scope. Accepts string or array of scopes.
862
  * @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),
863
  * but merged with defaults.
864
- *
865
  * @return array 'sql' WHERE SQL string and 'override' activity args.
866
  */
867
  public static function get_scope_query_sql( $scope = false, $r = array() ) {
868
 
869
- // Define arrays for future use
870
  $query_args = array();
871
  $override = array();
872
  $retval = array();
873
 
874
- // Check for array of scopes
875
  if ( is_array( $scope ) ) {
876
  $scopes = $scope;
877
 
878
- // Explode a comma separated string of scopes
879
  } elseif ( is_string( $scope ) ) {
880
  $scopes = explode( ',', $scope );
881
  }
882
 
883
- // Bail if no scope passed
884
  if ( empty( $scopes ) ) {
885
  return false;
886
  }
887
 
888
- // Helper to easily grab the 'user_id'
889
  if ( ! empty( $r['filter']['user_id'] ) ) {
890
  $r['user_id'] = $r['filter']['user_id'];
891
  }
892
 
893
- // parse each scope; yes! we handle multiples!
894
  foreach ( $scopes as $scope ) {
895
  $scope_args = array();
896
 
@@ -905,11 +909,10 @@ class BP_Activity_Activity {
905
  * - bp_groups_filter_activity_scope() - used for 'groups' scope
906
  * - bp_friends_filter_activity_scope() - used for 'friends' scope
907
  *
908
- * @since BuddyPress (2.2.0)
909
  *
910
  * @param array {
911
  * Activity query clauses.
912
- *
913
  * @type array {
914
  * Activity arguments for your custom scope.
915
  * See {@link BP_Activity_Query::_construct()} for more details.
@@ -921,14 +924,14 @@ class BP_Activity_Activity {
921
  $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r );
922
 
923
  if ( ! empty( $scope_args ) ) {
924
- // merge override properties from other scopes
925
  // this might be a problem...
926
  if ( ! empty( $scope_args['override'] ) ) {
927
  $override = array_merge( $override, $scope_args['override'] );
928
  unset( $scope_args['override'] );
929
  }
930
 
931
- // save scope args
932
  if ( ! empty( $scope_args ) ) {
933
  $query_args[] = $scope_args;
934
  }
@@ -936,7 +939,7 @@ class BP_Activity_Activity {
936
  }
937
 
938
  if ( ! empty( $query_args ) ) {
939
- // set relation to OR
940
  $query_args['relation'] = 'OR';
941
 
942
  $query = new BP_Activity_Query( $query_args );
@@ -958,7 +961,7 @@ class BP_Activity_Activity {
958
  *
959
  * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
960
  *
961
- * @since BuddyPress (1.2.0)
962
  *
963
  * @deprecated 1.5
964
  * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
@@ -969,7 +972,6 @@ class BP_Activity_Activity {
969
  * @param int $per_page Specifies how many results per page. Used in pagination. (Optional; default is 25).
970
  * @param string $sort MySQL column sort; ASC or DESC. (Optional; default is DESC).
971
  * @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false).
972
- *
973
  * @return array
974
  */
975
  public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
@@ -980,6 +982,8 @@ class BP_Activity_Activity {
980
  /**
981
  * Get the first activity ID that matches a set of criteria.
982
  *
 
 
983
  * @param int $user_id User ID to filter by.
984
  * @param string $component Component to filter by.
985
  * @param string $type Activity type to filter by.
@@ -988,9 +992,6 @@ class BP_Activity_Activity {
988
  * @param string $action Action to filter by.
989
  * @param string $content Content to filter by.
990
  * @param string $date_recorded Date to filter by.
991
- *
992
- * @todo Should parameters be optional?
993
- *
994
  * @return int|bool Activity ID on success, false if none is found.
995
  */
996
  public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
@@ -1046,7 +1047,7 @@ class BP_Activity_Activity {
1046
  * To delete a specific activity item, pass an 'id' parameter.
1047
  * Otherwise use the filters.
1048
  *
1049
- * @since BuddyPress (1.2.0)
1050
  *
1051
  * @param array $args {
1052
  * @int $id Optional. The ID of a specific item to delete.
@@ -1061,7 +1062,6 @@ class BP_Activity_Activity {
1061
  * @string $date_recorded Optional. The date to filter by.
1062
  * @int $hide_sitewide Optional. Default: false.
1063
  * }
1064
- *
1065
  * @return array|bool An array of deleted activity IDs on success, false on failure.
1066
  */
1067
  public static function delete( $args = array() ) {
@@ -1082,89 +1082,89 @@ class BP_Activity_Activity {
1082
  'hide_sitewide' => false
1083
  ) );
1084
 
1085
- // Setup empty array from where query arguments
1086
  $where_args = array();
1087
 
1088
- // ID
1089
  if ( ! empty( $r['id'] ) ) {
1090
  $where_args[] = $wpdb->prepare( "id = %d", $r['id'] );
1091
  }
1092
 
1093
- // User ID
1094
  if ( ! empty( $r['user_id'] ) ) {
1095
  $where_args[] = $wpdb->prepare( "user_id = %d", $r['user_id'] );
1096
  }
1097
 
1098
- // Action
1099
  if ( ! empty( $r['action'] ) ) {
1100
  $where_args[] = $wpdb->prepare( "action = %s", $r['action'] );
1101
  }
1102
 
1103
- // Content
1104
  if ( ! empty( $r['content'] ) ) {
1105
  $where_args[] = $wpdb->prepare( "content = %s", $r['content'] );
1106
  }
1107
 
1108
- // Component
1109
  if ( ! empty( $r['component'] ) ) {
1110
  $where_args[] = $wpdb->prepare( "component = %s", $r['component'] );
1111
  }
1112
 
1113
- // Type
1114
  if ( ! empty( $r['type'] ) ) {
1115
  $where_args[] = $wpdb->prepare( "type = %s", $r['type'] );
1116
  }
1117
 
1118
- // Primary Link
1119
  if ( ! empty( $r['primary_link'] ) ) {
1120
  $where_args[] = $wpdb->prepare( "primary_link = %s", $r['primary_link'] );
1121
  }
1122
 
1123
- // Item ID
1124
  if ( ! empty( $r['item_id'] ) ) {
1125
  $where_args[] = $wpdb->prepare( "item_id = %d", $r['item_id'] );
1126
  }
1127
 
1128
- // Secondary item ID
1129
  if ( ! empty( $r['secondary_item_id'] ) ) {
1130
  $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $r['secondary_item_id'] );
1131
  }
1132
 
1133
- // Date Recorded
1134
  if ( ! empty( $r['date_recorded'] ) ) {
1135
  $where_args[] = $wpdb->prepare( "date_recorded = %s", $r['date_recorded'] );
1136
  }
1137
 
1138
- // Hidden sitewide
1139
  if ( ! empty( $r['hide_sitewide'] ) ) {
1140
  $where_args[] = $wpdb->prepare( "hide_sitewide = %d", $r['hide_sitewide'] );
1141
  }
1142
 
1143
- // Bail if no where arguments
1144
  if ( empty( $where_args ) ) {
1145
  return false;
1146
  }
1147
 
1148
- // Join the where arguments for querying
1149
  $where_sql = 'WHERE ' . join( ' AND ', $where_args );
1150
 
1151
- // Fetch all activities being deleted so we can perform more actions
1152
  $activities = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} {$where_sql}" );
1153
 
1154
  /**
1155
  * Action to allow intercepting activity items to be deleted.
1156
  *
1157
- * @since BuddyPress (2.3.0)
1158
  *
1159
  * @param array $activities Array of activities.
1160
  * @param array $r Array of parsed arguments.
1161
  */
1162
  do_action_ref_array( 'bp_activity_before_delete', array( $activities, $r ) );
1163
 
1164
- // Attempt to delete activities from the database
1165
  $deleted = $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" );
1166
 
1167
- // Bail if nothing was deleted
1168
  if ( empty( $deleted ) ) {
1169
  return false;
1170
  }
@@ -1172,41 +1172,41 @@ class BP_Activity_Activity {
1172
  /**
1173
  * Action to allow intercepting activity items just deleted.
1174
  *
1175
- * @since BuddyPress (2.3.0)
1176
  *
1177
  * @param array $activities Array of activities.
1178
  * @param array $r Array of parsed arguments.
1179
  */
1180
  do_action_ref_array( 'bp_activity_after_delete', array( $activities, $r ) );
1181
 
1182
- // Pluck the activity IDs out of the $activities array
1183
  $activity_ids = wp_parse_id_list( wp_list_pluck( $activities, 'id' ) );
1184
 
1185
- // Handle accompanying activity comments and meta deletion
1186
  if ( ! empty( $activity_ids ) ) {
1187
 
1188
- // Delete all activity meta entries for activity items
1189
  BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
1190
 
1191
- // Setup empty array for comments
1192
  $comment_ids = array();
1193
 
1194
- // Loop through activity ids and attempt to delete comments
1195
  foreach ( $activity_ids as $activity_id ) {
1196
 
1197
- // Attempt to delete comments
1198
  $comments = BP_Activity_Activity::delete( array(
1199
  'type' => 'activity_comment',
1200
  'item_id' => $activity_id
1201
  ) );
1202
 
1203
- // Merge IDs together
1204
  if ( ! empty( $comments ) ) {
1205
  $comment_ids = array_merge( $comment_ids, $comments );
1206
  }
1207
  }
1208
 
1209
- // Merge activity IDs with any deleted comment IDs
1210
  if ( ! empty( $comment_ids ) ) {
1211
  $activity_ids = array_unique( array_merge( $activity_ids, $comment_ids ) );
1212
  }
@@ -1221,11 +1221,11 @@ class BP_Activity_Activity {
1221
  * This method is no longer used by BuddyPress, and it is recommended not to
1222
  * use it going forward, and use BP_Activity_Activity::delete() instead.
1223
  *
1224
- * @since BuddyPress (1.2.0)
1225
- * @deprecated BuddyPress (2.3.0)
1226
  *
1227
  * @param array $activity_ids Activity IDs whose comments should be deleted.
1228
- * @param bool $delete_meta Should we delete the activity meta items for these comments?
1229
  *
1230
  * @return bool True on success.
1231
  */
@@ -1238,7 +1238,7 @@ class BP_Activity_Activity {
1238
  $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
1239
 
1240
  if ( $delete_meta ) {
1241
- // Fetch the activity comment IDs for our deleted activity items
1242
  $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
1243
 
1244
  if ( ! empty( $activity_comment_ids ) ) {
@@ -1252,10 +1252,9 @@ class BP_Activity_Activity {
1252
  /**
1253
  * Delete the meta entries associated with a set of activity items.
1254
  *
1255
- * @since BuddyPress (1.2.0)
1256
  *
1257
  * @param array $activity_ids Activity IDs whose meta should be deleted.
1258
- *
1259
  * @return bool True on success.
1260
  */
1261
  public static function delete_activity_meta_entries( $activity_ids = array() ) {
@@ -1271,13 +1270,12 @@ class BP_Activity_Activity {
1271
  /**
1272
  * Append activity comments to their associated activity items.
1273
  *
1274
- * @since BuddyPress (1.2.0)
1275
  *
1276
  * @global wpdb $wpdb WordPress database object.
1277
  *
1278
  * @param array $activities Activities to fetch comments for.
1279
  * @param string $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
1280
- *
1281
  * @return array The updated activities with nested comments.
1282
  */
1283
  public static function append_comments( $activities, $spam = 'ham_only' ) {
@@ -1289,7 +1287,7 @@ class BP_Activity_Activity {
1289
  $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );
1290
  }
1291
 
1292
- // Merge the comments with the activity items
1293
  foreach ( (array) $activities as $key => $activity ) {
1294
  if ( isset( $activity_comments[$activity->id] ) ) {
1295
  $activities[$key]->children = $activity_comments[$activity->id];
@@ -1302,7 +1300,7 @@ class BP_Activity_Activity {
1302
  /**
1303
  * Get activity comments that are associated with a specific activity ID.
1304
  *
1305
- * @since BuddyPress (1.2.0)
1306
  *
1307
  * @global wpdb $wpdb WordPress database object.
1308
  *
@@ -1311,7 +1309,6 @@ class BP_Activity_Activity {
1311
  * @param int $right Right-most node boundary.
1312
  * @param string $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
1313
  * @param int $top_level_parent_id Optional. The id of the root-level parent activity item.
1314
- *
1315
  * @return array The updated activities with nested comments.
1316
  */
1317
  public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
@@ -1324,27 +1321,27 @@ class BP_Activity_Activity {
1324
  $comments = wp_cache_get( $activity_id, 'bp_activity_comments' );
1325
 
1326
  // We store the string 'none' to cache the fact that the
1327
- // activity item has no comments
1328
  if ( 'none' === $comments ) {
1329
  $comments = false;
1330
 
1331
- // A true cache miss
1332
  } elseif ( empty( $comments ) ) {
1333
 
1334
  $bp = buddypress();
1335
 
1336
- // Select the user's fullname with the query
1337
  if ( bp_is_active( 'xprofile' ) ) {
1338
  $fullname_select = ", pd.value as user_fullname";
1339
  $fullname_from = ", {$bp->profile->table_name_data} pd ";
1340
  $fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1";
1341
 
1342
- // Prevent debug errors
1343
  } else {
1344
  $fullname_select = $fullname_from = $fullname_where = '';
1345
  }
1346
 
1347
- // Don't retrieve activity comments marked as spam
1348
  if ( 'ham_only' == $spam ) {
1349
  $spam_sql = 'AND a.is_spam = 0';
1350
  } elseif ( 'spam_only' == $spam ) {
@@ -1353,13 +1350,13 @@ class BP_Activity_Activity {
1353
  $spam_sql = '';
1354
  }
1355
 
1356
- // Legacy query - not recommended
1357
  $func_args = func_get_args();
1358
 
1359
  /**
1360
  * Filters if BuddyPress should use the legacy activity query.
1361
  *
1362
- * @since BuddyPress (2.0.0)
1363
  *
1364
  * @param bool $value Whether or not to use the legacy query.
1365
  * @param BP_Activity_Activity $value Magic method referring to currently called method.
@@ -1370,7 +1367,7 @@ class BP_Activity_Activity {
1370
  /**
1371
  * Filters the MySQL prepared statement for the legacy activity query.
1372
  *
1373
- * @since BuddyPress (1.5.0)
1374
  *
1375
  * @param string $value Prepared statement for the activity query.
1376
  * @param int $activity_id Activity ID to fetch comments for.
@@ -1394,41 +1391,46 @@ class BP_Activity_Activity {
1394
 
1395
  $ref = array();
1396
 
1397
- // Loop descendants and build an assoc array
1398
  foreach ( (array) $descendants as $d ) {
1399
  $d->children = array();
1400
 
1401
- // If we have a reference on the parent
1402
  if ( isset( $ref[ $d->secondary_item_id ] ) ) {
1403
  $ref[ $d->secondary_item_id ]->children[ $d->id ] = $d;
1404
  $ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ];
1405
 
1406
- // If we don't have a reference on the parent, put in the root level
1407
  } else {
1408
  $comments[ $d->id ] = $d;
1409
  $ref[ $d->id ] =& $comments[ $d->id ];
1410
  }
1411
  }
1412
 
1413
- // Calculate depth for each item
1414
  foreach ( $ref as &$r ) {
1415
  $depth = 1;
1416
  $parent_id = $r->secondary_item_id;
 
1417
  while ( $parent_id !== $r->item_id ) {
1418
  $depth++;
1419
 
1420
- // When display_comments=stream, the
1421
- // parent comment may not be part of
1422
- // the returned results, so we manually
1423
- // fetch it
1424
  if ( empty( $ref[ $parent_id ] ) ) {
1425
  $direct_parent = new BP_Activity_Activity( $parent_id );
1426
  if ( isset( $direct_parent->secondary_item_id ) ) {
1427
- $parent_id = $direct_parent->secondary_item_id;
 
 
 
 
 
 
 
 
1428
  } else {
1429
- // Something went wrong
1430
- // Short-circuit the
1431
- // depth calculation
1432
  $parent_id = $r->item_id;
1433
  }
1434
  } else {
@@ -1457,7 +1459,7 @@ class BP_Activity_Activity {
1457
  /**
1458
  * Rebuild nested comment tree under an activity or activity comment.
1459
  *
1460
- * @since BuddyPress (1.2.0)
1461
  *
1462
  * @global wpdb $wpdb WordPress database object.
1463
  *
@@ -1470,39 +1472,38 @@ class BP_Activity_Activity {
1470
 
1471
  $bp = buddypress();
1472
 
1473
- // The right value of this node is the left value + 1
1474
  $right = intval( $left + 1 );
1475
 
1476
- // Get all descendants of this node
1477
  $comments = BP_Activity_Activity::get_child_comments( $parent_id );
1478
  $descendants = wp_list_pluck( $comments, 'id' );
1479
 
1480
- // Loop the descendants and recalculate the left and right values
1481
  foreach ( (array) $descendants as $descendant_id ) {
1482
  $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );
1483
  }
1484
 
1485
  // We've got the left value, and now that we've processed the children
1486
- // of this node we also know the right value
1487
  if ( 1 === $left ) {
1488
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
1489
  } else {
1490
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id ) );
1491
  }
1492
 
1493
- // Return the right value of this node + 1
1494
  return intval( $right + 1 );
1495
  }
1496
 
1497
  /**
1498
  * Get child comments of an activity or activity comment.
1499
  *
1500
- * @since BuddyPress (1.2.0)
1501
  *
1502
  * @global wpdb $wpdb WordPress database object.
1503
  *
1504
  * @param int $parent_id ID of an activity or activity comment.
1505
- *
1506
  * @return object Numerically indexed array of child comments.
1507
  */
1508
  public static function get_child_comments( $parent_id ) {
@@ -1517,11 +1518,10 @@ class BP_Activity_Activity {
1517
  * Get a list of components that have recorded activity associated with them.
1518
  *
1519
  * @param bool $skip_last_activity If true, components will not be
1520
- * included if the only activity type associated with them is
1521
- * 'last_activity'. (Since 2.0.0, 'last_activity' is stored in
1522
- * the activity table, but these items are not full-fledged
1523
- * activity items.) Default: true.
1524
- *
1525
  * @return array List of component names.
1526
  */
1527
  public static function get_recorded_components( $skip_last_activity = true ) {
@@ -1542,7 +1542,6 @@ class BP_Activity_Activity {
1542
  * Get sitewide activity items for use in an RSS feed.
1543
  *
1544
  * @param int $limit Optional. Number of items to fetch. Default: 35.
1545
- *
1546
  * @return array $activity_feed List of activity items, with RSS data added.
1547
  */
1548
  public static function get_sitewide_items_for_feed( $limit = 35 ) {
@@ -1563,35 +1562,34 @@ class BP_Activity_Activity {
1563
  /**
1564
  * Create SQL IN clause for filter queries.
1565
  *
1566
- * @since BuddyPress (1.5.0)
1567
  *
1568
  * @see BP_Activity_Activity::get_filter_sql()
1569
  *
1570
  * @param string $field The database field.
1571
  * @param array|bool $items The values for the IN clause, or false when none are found.
1572
- *
1573
- * @return string|bool.
1574
  */
1575
  public static function get_in_operator_sql( $field, $items ) {
1576
  global $wpdb;
1577
 
1578
- // split items at the comma
1579
  if ( ! is_array( $items ) ) {
1580
  $items = explode( ',', $items );
1581
  }
1582
 
1583
- // array of prepared integers or quoted strings
1584
  $items_prepared = array();
1585
 
1586
- // clean up and format each item
1587
  foreach ( $items as $item ) {
1588
- // clean up the string
1589
  $item = trim( $item );
1590
- // pass everything through prepare for security and to safely quote strings
1591
  $items_prepared[] = ( is_numeric( $item ) ) ? $wpdb->prepare( '%d', $item ) : $wpdb->prepare( '%s', $item );
1592
  }
1593
 
1594
- // build IN operator sql syntax
1595
  if ( count( $items_prepared ) )
1596
  return sprintf( '%s IN ( %s )', trim( $field ), implode( ',', $items_prepared ) );
1597
  else
@@ -1601,7 +1599,7 @@ class BP_Activity_Activity {
1601
  /**
1602
  * Create filter SQL clauses.
1603
  *
1604
- * @since BuddyPress (1.5.0)
1605
  *
1606
  * @param array $filter_array {
1607
  * Fields and values to filter by.
@@ -1621,7 +1619,6 @@ class BP_Activity_Activity {
1621
  * date_recorded value greater than a
1622
  * given MySQL-formatted date.
1623
  * }
1624
- *
1625
  * @return string The filter clause, for use in a SQL query.
1626
  */
1627
  public static function get_filter_sql( $filter_array ) {
@@ -1664,8 +1661,8 @@ class BP_Activity_Activity {
1664
  }
1665
 
1666
  if ( ! empty( $filter_array['since'] ) ) {
1667
- // Validate that this is a proper Y-m-d H:i:s date
1668
- // Trick: parse to UNIX date then translate back
1669
  $translated_date = date( 'Y-m-d H:i:s', strtotime( $filter_array['since'] ) );
1670
  if ( $translated_date === $filter_array['since'] ) {
1671
  $filter_sql[] = "a.date_recorded > '{$translated_date}'";
@@ -1681,7 +1678,7 @@ class BP_Activity_Activity {
1681
  /**
1682
  * Get the date/time of last recorded activity.
1683
  *
1684
- * @since BuddyPress (1.2.0)
1685
  *
1686
  * @return string ISO timestamp.
1687
  */
@@ -1696,21 +1693,20 @@ class BP_Activity_Activity {
1696
  /**
1697
  * Get favorite count for a given user.
1698
  *
1699
- * @since BuddyPress (1.2.0)
1700
  *
1701
  * @param int $user_id The ID of the user whose favorites you're counting.
1702
- *
1703
  * @return int $value A count of the user's favorites.
1704
  */
1705
  public static function total_favorite_count( $user_id ) {
1706
 
1707
- // Get activities from user meta
1708
  $favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
1709
  if ( ! empty( $favorite_activity_entries ) ) {
1710
  return count( maybe_unserialize( $favorite_activity_entries ) );
1711
  }
1712
 
1713
- // No favorites
1714
  return 0;
1715
  }
1716
 
@@ -1718,7 +1714,6 @@ class BP_Activity_Activity {
1718
  * Check whether an activity item exists with a given string content.
1719
  *
1720
  * @param string $content The content to filter by.
1721
- *
1722
  * @return int|bool The ID of the first matching item if found, otherwise false.
1723
  */
1724
  public static function check_exists_by_content( $content ) {
@@ -1733,7 +1728,6 @@ class BP_Activity_Activity {
1733
  * Hide all activity for a given user.
1734
  *
1735
  * @param int $user_id The ID of the user whose activity you want to mark hidden.
1736
- *
1737
  * @return mixed
1738
  */
1739
  public static function hide_all_for_user( $user_id ) {
@@ -1747,7 +1741,7 @@ class BP_Activity_Activity {
1747
  /**
1748
  * PHP-agnostic version of {@link array_replace_recursive()}.
1749
  *
1750
- * array_replace_recursive() is a PHP 5.3 function. BuddyPress (and
1751
  * WordPress) currently supports down to PHP 5.2, so this method is a workaround
1752
  * for PHP 5.2.
1753
  *
@@ -1756,13 +1750,12 @@ class BP_Activity_Activity {
1756
  *
1757
  * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
1758
  *
1759
- * @since BuddyPress (2.2.0)
1760
  *
1761
  * @see http://php.net/manual/en/function.array-replace-recursive.php#109390
1762
  *
1763
  * @param array $base Array with keys needing to be replaced.
1764
  * @param array $replacements Array with the replaced keys.
1765
- *
1766
  * @return array
1767
  */
1768
  protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
@@ -1771,7 +1764,7 @@ class BP_Activity_Activity {
1771
  }
1772
 
1773
  // PHP 5.2-compatible version
1774
- // http://php.net/manual/en/function.array-replace-recursive.php#109390
1775
  foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
1776
  $bref_stack = array( &$base );
1777
  $head_stack = array( $replacements );
6
  * @subpackage Activity
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
15
  * Instance methods are available for creating/editing an activity,
16
  * static methods for querying activities.
17
  *
18
+ * @since 1.0.0
19
  */
20
  class BP_Activity_Activity {
21
 
163
  $this->is_spam = $row->is_spam;
164
  }
165
 
166
+ // Generate dynamic 'action' when possible.
167
  $action = bp_activity_generate_action_string( $this );
168
  if ( false !== $action ) {
169
  $this->action = $action;
170
 
171
  // If no callback is available, use the literal string from
172
+ // the database row.
173
  } elseif ( ! empty( $row->action ) ) {
174
  $this->action = $row->action;
175
 
176
+ // Provide a fallback to avoid PHP notices.
177
  } else {
178
  $this->action = '';
179
  }
209
  *
210
  * Please use this hook to filter the properties above. Each part will be passed in.
211
  *
212
+ * @since 1.0.0
213
  *
214
  * @param BP_Activity_Activity $this Current instance of the activity item being saved. Passed by reference.
215
  */
234
  return false;
235
  }
236
 
237
+ // If this is a new activity item, set the $id property.
238
  if ( empty( $this->id ) ) {
239
  $this->id = $wpdb->insert_id;
240
 
246
  /**
247
  * Fires after an activity item has been saved to the database.
248
  *
249
+ * @since 1.0.0
250
  *
251
  * @param BP_Activity_Activity $this Current instance of activity item being saved. Passed by reference.
252
  */
260
  /**
261
  * Get activity items, as specified by parameters.
262
  *
263
+ * @since 1.0.0
264
+ * @since 2.4.0 Introduced the `$fields` parameter.
265
+ *
266
  * @see BP_Activity_Activity::get_filter_sql() for a description of the
267
  * 'filter' parameter.
268
  * @see WP_Meta_Query::queries for a description of the 'meta_query'
270
  *
271
  * @param array $args {
272
  * An array of arguments. All items are optional.
 
273
  * @type int $page Which page of results to fetch. Using page=1 without per_page will result
274
  * in no pagination. Default: 1.
275
  * @type int|bool $per_page Number of results per page. Default: 25.
276
  * @type int|bool $max Maximum number of results to return. Default: false (unlimited).
277
+ * @type string $fields Activity fields to return. Pass 'ids' to get only the activity IDs.
278
+ * 'all' returns full activity objects.
279
  * @type string $sort ASC or DESC. Default: 'DESC'.
280
  * @type array $exclude Array of activity IDs to exclude. Default: false.
281
  * @type array $in Array of ids to limit query by (IN). Default: false.
294
  * for the query. Default: false.
295
  * }
296
  * @return array The array returned has two keys:
297
+ * - 'total' is the count of located activities
298
+ * - 'activities' is an array of the located activities
299
  */
300
  public static function get( $args = array() ) {
301
  global $wpdb;
302
 
303
+ // Backward compatibility with old method of passing arguments.
304
  if ( !is_array( $args ) || func_num_args() > 1 ) {
305
  _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
306
 
324
 
325
  $bp = buddypress();
326
  $r = wp_parse_args( $args, array(
327
+ 'page' => 1, // The current page.
328
+ 'per_page' => 25, // Activity items per page.
329
+ 'max' => false, // Max number of items to return.
330
+ 'fields' => 'all', // Fields to include.
331
+ 'sort' => 'DESC', // ASC or DESC.
332
+ 'exclude' => false, // Array of ids to exclude.
333
+ 'in' => false, // Array of ids to limit query by (IN).
334
+ 'meta_query' => false, // Filter by activitymeta.
335
+ 'date_query' => false, // Filter by date.
336
+ 'filter_query' => false, // Advanced filtering - see BP_Activity_Query.
337
+ 'filter' => false, // See self::get_filter_sql().
338
+ 'scope' => false, // Preset activity arguments.
339
+ 'search_terms' => false, // Terms to search by.
340
+ 'display_comments' => false, // Whether to include activity comments.
341
+ 'show_hidden' => false, // Show items marked hide_sitewide.
342
+ 'spam' => 'ham_only', // Spam status.
343
+ 'update_meta_cache' => true, // Whether or not to update meta cache.
344
+ 'count_total' => false, // Whether or not to use count_total.
345
  ) );
346
 
347
+ // Select conditions.
348
  $select_sql = "SELECT DISTINCT a.id";
349
 
350
  $from_sql = " FROM {$bp->activity->table_name} a";
351
 
352
  $join_sql = '';
353
 
354
+ // Where conditions.
355
  $where_conditions = array();
356
 
357
+ // Excluded types.
358
  $excluded_types = array();
359
 
360
+ // Scope takes precedence.
361
  if ( ! empty( $r['scope'] ) ) {
362
  $scope_query = self::get_scope_query_sql( $r['scope'], $r );
363
 
364
+ // Add our SQL conditions if matches were found.
365
  if ( ! empty( $scope_query['sql'] ) ) {
366
  $where_conditions['scope_query_sql'] = $scope_query['sql'];
367
  }
368
 
369
+ // Override some arguments if needed.
370
  if ( ! empty( $scope_query['override'] ) ) {
371
  $r = self::array_replace_recursive( $r, $scope_query['override'] );
372
  }
373
 
374
+ // Advanced filtering.
375
  } elseif ( ! empty( $r['filter_query'] ) ) {
376
  $filter_query = new BP_Activity_Query( $r['filter_query'] );
377
  $sql = $filter_query->get_sql();
380
  }
381
  }
382
 
383
+ // Regular filtering.
384
  if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
385
  $where_conditions['filter_sql'] = $filter_sql;
386
  }
387
 
388
+ // Spam.
389
  if ( 'ham_only' == $r['spam'] ) {
390
  $where_conditions['spam_sql'] = 'a.is_spam = 0';
391
  } elseif ( 'spam_only' == $r['spam'] ) {
392
  $where_conditions['spam_sql'] = 'a.is_spam = 1';
393
  }
394
 
395
+ // Searching.
396
  if ( $r['search_terms'] ) {
397
  $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
398
  $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
399
  }
400
 
401
+ // Sorting.
402
  $sort = $r['sort'];
403
  if ( $sort != 'ASC' && $sort != 'DESC' ) {
404
  $sort = 'DESC';
409
  $where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
410
  }
411
 
412
+ // Exclude specified items.
413
  if ( ! empty( $r['exclude'] ) ) {
414
  $exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
415
  $where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
416
  }
417
 
418
+ // The specific ids to which you want to limit the query.
419
  if ( ! empty( $r['in'] ) ) {
420
  $in = implode( ',', wp_parse_id_list( $r['in'] ) );
421
  $where_conditions['in'] = "a.id IN ({$in})";
422
  }
423
 
424
+ // Process meta_query into SQL.
425
  $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
426
 
427
  if ( ! empty( $meta_query_sql['join'] ) ) {
432
  $where_conditions[] = $meta_query_sql['where'];
433
  }
434
 
435
+ // Process date_query into SQL.
436
  $date_query_sql = self::get_date_query_sql( $r['date_query'] );
437
 
438
  if ( ! empty( $date_query_sql ) ) {
447
  }
448
 
449
  // Exclude 'last_activity' items unless the 'action' filter has
450
+ // been explicitly set.
451
  if ( empty( $r['filter']['object'] ) ) {
452
  $excluded_types[] = 'last_activity';
453
  }
454
 
455
+ // Build the excluded type sql part.
456
  if ( ! empty( $excluded_types ) ) {
457
  $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
458
  $where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
461
  /**
462
  * Filters the MySQL WHERE conditions for the Activity items get method.
463
  *
464
+ * @since 1.9.0
465
  *
466
  * @param array $where_conditions Current conditions for MySQL WHERE statement.
467
  * @param array $r Parsed arguments passed into method.
471
  */
472
  $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
473
 
474
+ // Join the where conditions together.
475
  $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
476
 
477
  /**
478
  * Filters the preferred order of indexes for activity item.
479
  *
480
+ * @since 1.6.0
481
  *
482
  * @param array Array of indexes in preferred order.
483
  */
486
  foreach( $indexes as $key => $index ) {
487
  if ( false !== strpos( $where_sql, $index ) ) {
488
  $the_index = $index;
489
+ break; // Take the first one we find.
490
  }
491
  }
492
 
496
  $index_hint_sql = '';
497
  }
498
 
499
+ // Sanitize page and per_page parameters.
500
  $page = absint( $r['page'] );
501
  $per_page = absint( $r['per_page'] );
502
 
511
  *
512
  * It is not recommended to use the legacy structure, but allowed to if needed.
513
  *
514
+ * @since 2.0.0
515
  *
516
  * @param bool $value Whether to use legacy structure or not.
517
  * @param BP_Activity_Activity $value Current method being called.
519
  */
520
  if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
521
 
522
+ // Legacy queries joined against the user table.
523
  $select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
524
  $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
525
 
526
  if ( ! empty( $page ) && ! empty( $per_page ) ) {
527
  $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
528
 
529
+ /** This filter is documented in bp-activity/bp-activity-classes.php */
530
  $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
531
  } else {
532
  $pag_sql = '';
534
  /**
535
  * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
536
  *
537
+ * @since 1.5.0
538
  *
539
  * @param string $value Concatenated MySQL statement pieces to be query results with for legacy query.
540
  * @param string $select_sql Final SELECT MySQL statement portion for legacy query.
546
  }
547
 
548
  } else {
549
+ // Query first for activity IDs.
550
  $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
551
 
552
  if ( ! empty( $per_page ) && ! empty( $page ) ) {
553
  // We query for $per_page + 1 items in order to
554
+ // populate the has_more_items flag.
555
  $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
556
  }
557
 
558
  /**
559
  * Filters the paged activities MySQL statement.
560
  *
561
+ * @since 2.0.0
562
  *
563
  * @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
564
  * @param array $r Array of arguments passed into method.
570
  $retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
571
 
572
  // If we've fetched more than the $per_page value, we
573
+ // can discard the extra now.
574
  if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
575
  array_pop( $activity_ids );
576
  }
577
 
578
+ if ( 'ids' === $r['fields'] ) {
579
+ $activities = array_map( 'intval', $activity_ids );
580
+ } else {
581
+ $activities = self::get_activity_data( $activity_ids );
582
+ }
583
  }
584
 
585
+ if ( 'ids' !== $r['fields'] ) {
586
+ // Get the fullnames of users so we don't have to query in the loop.
587
+ $activities = self::append_user_fullnames( $activities );
588
 
589
+ // Get activity meta.
590
+ $activity_ids = array();
591
+ foreach ( (array) $activities as $activity ) {
592
+ $activity_ids[] = $activity->id;
593
+ }
594
 
595
+ if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
596
+ bp_activity_update_meta_cache( $activity_ids );
597
+ }
598
 
599
+ if ( $activities && $r['display_comments'] ) {
600
+ $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
601
+ }
602
 
603
+ // Pre-fetch data associated with activity users and other objects.
604
+ BP_Activity_Activity::prefetch_object_data( $activities );
605
 
606
+ // Generate action strings.
607
+ $activities = BP_Activity_Activity::generate_action_strings( $activities );
608
+ }
609
 
610
  $retval['activities'] = $activities;
611
 
612
+ // If $max is set, only return up to the max results.
613
  if ( ! empty( $r['count_total'] ) ) {
614
 
615
  /**
616
  * Filters the total activities MySQL statement.
617
  *
618
+ * @since 1.5.0
619
  *
620
  * @param string $value MySQL statement used to query for total activities.
621
  * @param string $where_sql MySQL WHERE statement portion.
639
  /**
640
  * Convert activity IDs to activity objects, as expected in template loop.
641
  *
642
+ * @since 2.0.0
643
  *
644
  * @param array $activity_ids Array of activity IDs.
 
645
  * @return array
646
  */
647
  protected static function get_activity_data( $activity_ids = array() ) {
648
  global $wpdb;
649
 
650
+ // Bail if no activity ID's passed.
651
  if ( empty( $activity_ids ) ) {
652
  return array();
653
  }
654
 
655
+ // Get BuddyPress.
656
  $bp = buddypress();
657
 
658
  $activities = array();
659
  $uncached_ids = bp_get_non_cached_ids( $activity_ids, 'bp_activity' );
660
 
661
+ // Prime caches as necessary.
662
  if ( ! empty( $uncached_ids ) ) {
663
+ // Format the activity ID's for use in the query below.
664
  $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
665
 
666
+ // Fetch data from activity table, preserving order.
667
  $queried_adata = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$uncached_ids_sql})");
668
 
669
  // Put that data into the placeholders created earlier,
670
+ // and add it to the cache.
671
  foreach ( (array) $queried_adata as $adata ) {
672
  wp_cache_set( $adata->id, $adata, 'bp_activity' );
673
  }
674
  }
675
 
676
+ // Now fetch data from the cache.
677
  foreach ( $activity_ids as $activity_id ) {
678
  $activities[] = wp_cache_get( $activity_id, 'bp_activity' );
679
  }
680
 
681
+ // Then fetch user data.
682
  $user_query = new BP_User_Query( array(
683
  'user_ids' => wp_list_pluck( $activities, 'user_id' ),
684
  'populate_extras' => false,
685
  ) );
686
 
687
+ // Associated located user data with activity items.
688
  foreach ( $activities as $a_index => $a_item ) {
689
  $a_user_id = intval( $a_item->user_id );
690
  $a_user = isset( $user_query->results[ $a_user_id ] ) ? $user_query->results[ $a_user_id ] : '';
703
  /**
704
  * Append xProfile fullnames to an activity array.
705
  *
706
+ * @since 2.0.0
707
  *
708
  * @param array $activities Activities array.
 
709
  * @return array
710
  */
711
  protected static function append_user_fullnames( $activities ) {
743
  * components, such as bp-friends and bp-groups, to hook in and prime
744
  * their own caches at the beginning of an activity loop.
745
  *
746
+ * @since 2.0.0
747
  *
748
  * @param array $activities Array of activities.
 
749
  * @return array $activities Array of activities.
750
  */
751
  protected static function prefetch_object_data( $activities ) {
753
  /**
754
  * Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
755
  *
756
+ * @since 2.0.0
757
  *
758
  * @param array $activities Array of activities.
759
  */
768
  * registered), the static 'action' value pulled from the database will
769
  * be left in place.
770
  *
771
+ * @since 2.0.0
772
  *
773
  * @param array $activities Array of activities.
 
774
  * @return array
775
  */
776
  protected static function generate_action_strings( $activities ) {
795
  * WP_Query, we have to alter the return value (stripping the leading
796
  * AND keyword from the 'where' clause).
797
  *
798
+ * @since 1.8.0
799
  *
800
  * @param array $meta_query An array of meta_query filters. See the
801
  * documentation for WP_Meta_Query for details.
 
802
  * @return array $sql_array 'join' and 'where' clauses.
803
  */
804
  public static function get_meta_query_sql( $meta_query = array() ) {
813
  $activity_meta_query = new WP_Meta_Query( $meta_query );
814
 
815
  // WP_Meta_Query expects the table name at
816
+ // $wpdb->activitymeta.
817
  $wpdb->activitymeta = buddypress()->activity->table_name_meta;
818
 
819
  $meta_sql = $activity_meta_query->get_sql( 'activity', 'a', 'id' );
820
 
821
+ // Strip the leading AND - BP handles it in get().
822
  $sql_array['where'] = preg_replace( '/^\sAND/', '', $meta_sql['where'] );
823
  $sql_array['join'] = $meta_sql['join'];
824
  }
835
  * WP_Query, we have to alter the return value (stripping the leading AND
836
  * keyword from the query).
837
  *
838
+ * @since 2.1.0
839
  *
840
  * @param array $date_query An array of date_query parameters. See the
841
  * documentation for the first parameter of WP_Date_Query.
 
842
  * @return string
843
  */
844
  public static function get_date_query_sql( $date_query = array() ) {
845
  $sql = '';
846
 
847
+ // Date query.
848
+ if ( ! empty( $date_query ) && is_array( $date_query ) ) {
849
  $date_query = new BP_Date_Query( $date_query, 'date_recorded' );
850
  $sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
851
  }
861
  *
862
  * Can handle multiple scopes.
863
  *
864
+ * @since 2.2.0
865
  *
866
  * @param mixed $scope The activity scope. Accepts string or array of scopes.
867
  * @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),
868
  * but merged with defaults.
 
869
  * @return array 'sql' WHERE SQL string and 'override' activity args.
870
  */
871
  public static function get_scope_query_sql( $scope = false, $r = array() ) {
872
 
873
+ // Define arrays for future use.
874
  $query_args = array();
875
  $override = array();
876
  $retval = array();
877
 
878
+ // Check for array of scopes.
879
  if ( is_array( $scope ) ) {
880
  $scopes = $scope;
881
 
882
+ // Explode a comma separated string of scopes.
883
  } elseif ( is_string( $scope ) ) {
884
  $scopes = explode( ',', $scope );
885
  }
886
 
887
+ // Bail if no scope passed.
888
  if ( empty( $scopes ) ) {
889
  return false;
890
  }
891
 
892
+ // Helper to easily grab the 'user_id'.
893
  if ( ! empty( $r['filter']['user_id'] ) ) {
894
  $r['user_id'] = $r['filter']['user_id'];
895
  }
896
 
897
+ // Parse each scope; yes! we handle multiples!
898
  foreach ( $scopes as $scope ) {
899
  $scope_args = array();
900
 
909
  * - bp_groups_filter_activity_scope() - used for 'groups' scope
910
  * - bp_friends_filter_activity_scope() - used for 'friends' scope
911
  *
912
+ * @since 2.2.0
913
  *
914
  * @param array {
915
  * Activity query clauses.
 
916
  * @type array {
917
  * Activity arguments for your custom scope.
918
  * See {@link BP_Activity_Query::_construct()} for more details.
924
  $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r );
925
 
926
  if ( ! empty( $scope_args ) ) {
927
+ // Merge override properties from other scopes
928
  // this might be a problem...
929
  if ( ! empty( $scope_args['override'] ) ) {
930
  $override = array_merge( $override, $scope_args['override'] );
931
  unset( $scope_args['override'] );
932
  }
933
 
934
+ // Save scope args.
935
  if ( ! empty( $scope_args ) ) {
936
  $query_args[] = $scope_args;
937
  }
939
  }
940
 
941
  if ( ! empty( $query_args ) ) {
942
+ // Set relation to OR.
943
  $query_args['relation'] = 'OR';
944
 
945
  $query = new BP_Activity_Query( $query_args );
961
  *
962
  * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
963
  *
964
+ * @since 1.2.0
965
  *
966
  * @deprecated 1.5
967
  * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
972
  * @param int $per_page Specifies how many results per page. Used in pagination. (Optional; default is 25).
973
  * @param string $sort MySQL column sort; ASC or DESC. (Optional; default is DESC).
974
  * @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false).
 
975
  * @return array
976
  */
977
  public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
982
  /**
983
  * Get the first activity ID that matches a set of criteria.
984
  *
985
+ * @todo Should parameters be optional?
986
+ *
987
  * @param int $user_id User ID to filter by.
988
  * @param string $component Component to filter by.
989
  * @param string $type Activity type to filter by.
992
  * @param string $action Action to filter by.
993
  * @param string $content Content to filter by.
994
  * @param string $date_recorded Date to filter by.
 
 
 
995
  * @return int|bool Activity ID on success, false if none is found.
996
  */
997
  public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
1047
  * To delete a specific activity item, pass an 'id' parameter.
1048
  * Otherwise use the filters.
1049
  *
1050
+ * @since 1.2.0
1051
  *
1052
  * @param array $args {
1053
  * @int $id Optional. The ID of a specific item to delete.
1062
  * @string $date_recorded Optional. The date to filter by.
1063
  * @int $hide_sitewide Optional. Default: false.
1064
  * }
 
1065
  * @return array|bool An array of deleted activity IDs on success, false on failure.
1066
  */
1067
  public static function delete( $args = array() ) {
1082
  'hide_sitewide' => false
1083
  ) );
1084
 
1085
+ // Setup empty array from where query arguments.
1086
  $where_args = array();
1087
 
1088
+ // ID.
1089
  if ( ! empty( $r['id'] ) ) {
1090
  $where_args[] = $wpdb->prepare( "id = %d", $r['id'] );
1091
  }
1092
 
1093
+ // User ID.
1094
  if ( ! empty( $r['user_id'] ) ) {
1095
  $where_args[] = $wpdb->prepare( "user_id = %d", $r['user_id'] );
1096
  }
1097
 
1098
+ // Action.
1099
  if ( ! empty( $r['action'] ) ) {
1100
  $where_args[] = $wpdb->prepare( "action = %s", $r['action'] );
1101
  }
1102
 
1103
+ // Content.
1104
  if ( ! empty( $r['content'] ) ) {
1105
  $where_args[] = $wpdb->prepare( "content = %s", $r['content'] );
1106
  }
1107
 
1108
+ // Component.
1109
  if ( ! empty( $r['component'] ) ) {
1110
  $where_args[] = $wpdb->prepare( "component = %s", $r['component'] );
1111
  }
1112
 
1113
+ // Type.
1114
  if ( ! empty( $r['type'] ) ) {
1115
  $where_args[] = $wpdb->prepare( "type = %s", $r['type'] );
1116
  }
1117
 
1118
+ // Primary Link.
1119
  if ( ! empty( $r['primary_link'] ) ) {
1120
  $where_args[] = $wpdb->prepare( "primary_link = %s", $r['primary_link'] );
1121
  }
1122
 
1123
+ // Item ID.
1124
  if ( ! empty( $r['item_id'] ) ) {
1125
  $where_args[] = $wpdb->prepare( "item_id = %d", $r['item_id'] );
1126
  }
1127
 
1128
+ // Secondary item ID.
1129
  if ( ! empty( $r['secondary_item_id'] ) ) {
1130
  $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $r['secondary_item_id'] );
1131
  }
1132
 
1133
+ // Date Recorded.
1134
  if ( ! empty( $r['date_recorded'] ) ) {
1135
  $where_args[] = $wpdb->prepare( "date_recorded = %s", $r['date_recorded'] );
1136
  }
1137
 
1138
+ // Hidden sitewide.
1139
  if ( ! empty( $r['hide_sitewide'] ) ) {
1140
  $where_args[] = $wpdb->prepare( "hide_sitewide = %d", $r['hide_sitewide'] );
1141
  }
1142
 
1143
+ // Bail if no where arguments.
1144
  if ( empty( $where_args ) ) {
1145
  return false;
1146
  }
1147
 
1148
+ // Join the where arguments for querying.
1149
  $where_sql = 'WHERE ' . join( ' AND ', $where_args );
1150
 
1151
+ // Fetch all activities being deleted so we can perform more actions.
1152
  $activities = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} {$where_sql}" );
1153
 
1154
  /**
1155
  * Action to allow intercepting activity items to be deleted.
1156
  *
1157
+ * @since 2.3.0
1158
  *
1159
  * @param array $activities Array of activities.
1160
  * @param array $r Array of parsed arguments.
1161
  */
1162
  do_action_ref_array( 'bp_activity_before_delete', array( $activities, $r ) );
1163
 
1164
+ // Attempt to delete activities from the database.
1165
  $deleted = $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" );
1166
 
1167
+ // Bail if nothing was deleted.
1168
  if ( empty( $deleted ) ) {
1169
  return false;
1170
  }
1172
  /**
1173
  * Action to allow intercepting activity items just deleted.
1174
  *
1175
+ * @since 2.3.0
1176
  *
1177
  * @param array $activities Array of activities.
1178
  * @param array $r Array of parsed arguments.
1179
  */
1180
  do_action_ref_array( 'bp_activity_after_delete', array( $activities, $r ) );
1181
 
1182
+ // Pluck the activity IDs out of the $activities array.
1183
  $activity_ids = wp_parse_id_list( wp_list_pluck( $activities, 'id' ) );
1184
 
1185
+ // Handle accompanying activity comments and meta deletion.
1186
  if ( ! empty( $activity_ids ) ) {
1187
 
1188
+ // Delete all activity meta entries for activity items.
1189
  BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
1190
 
1191
+ // Setup empty array for comments.
1192
  $comment_ids = array();
1193
 
1194
+ // Loop through activity ids and attempt to delete comments.
1195
  foreach ( $activity_ids as $activity_id ) {
1196
 
1197
+ // Attempt to delete comments.
1198
  $comments = BP_Activity_Activity::delete( array(
1199
  'type' => 'activity_comment',
1200
  'item_id' => $activity_id
1201
  ) );
1202
 
1203
+ // Merge IDs together.
1204
  if ( ! empty( $comments ) ) {
1205
  $comment_ids = array_merge( $comment_ids, $comments );
1206
  }
1207
  }
1208
 
1209
+ // Merge activity IDs with any deleted comment IDs.
1210
  if ( ! empty( $comment_ids ) ) {
1211
  $activity_ids = array_unique( array_merge( $activity_ids, $comment_ids ) );
1212
  }
1221
  * This method is no longer used by BuddyPress, and it is recommended not to
1222
  * use it going forward, and use BP_Activity_Activity::delete() instead.
1223
  *
1224
+ * @since 1.2.0
1225
+ * @deprecated 2.3.0
1226
  *
1227
  * @param array $activity_ids Activity IDs whose comments should be deleted.
1228
+ * @param bool $delete_meta Should we delete the activity meta items for these comments.
1229
  *
1230
  * @return bool True on success.
1231
  */
1238
  $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
1239
 
1240
  if ( $delete_meta ) {
1241
+ // Fetch the activity comment IDs for our deleted activity items.
1242
  $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
1243
 
1244
  if ( ! empty( $activity_comment_ids ) ) {
1252
  /**
1253
  * Delete the meta entries associated with a set of activity items.
1254
  *
1255
+ * @since 1.2.0
1256
  *
1257
  * @param array $activity_ids Activity IDs whose meta should be deleted.
 
1258
  * @return bool True on success.
1259
  */
1260
  public static function delete_activity_meta_entries( $activity_ids = array() ) {
1270
  /**
1271
  * Append activity comments to their associated activity items.
1272
  *
1273
+ * @since 1.2.0
1274
  *
1275
  * @global wpdb $wpdb WordPress database object.
1276
  *
1277
  * @param array $activities Activities to fetch comments for.
1278
  * @param string $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
 
1279
  * @return array The updated activities with nested comments.
1280
  */
1281
  public static function append_comments( $activities, $spam = 'ham_only' ) {
1287
  $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );
1288
  }
1289
 
1290
+ // Merge the comments with the activity items.
1291
  foreach ( (array) $activities as $key => $activity ) {
1292
  if ( isset( $activity_comments[$activity->id] ) ) {
1293
  $activities[$key]->children = $activity_comments[$activity->id];
1300
  /**
1301
  * Get activity comments that are associated with a specific activity ID.
1302
  *
1303
+ * @since 1.2.0
1304
  *
1305
  * @global wpdb $wpdb WordPress database object.
1306
  *
1309
  * @param int $right Right-most node boundary.
1310
  * @param string $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
1311
  * @param int $top_level_parent_id Optional. The id of the root-level parent activity item.
 
1312
  * @return array The updated activities with nested comments.
1313
  */
1314
  public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
1321
  $comments = wp_cache_get( $activity_id, 'bp_activity_comments' );
1322
 
1323
  // We store the string 'none' to cache the fact that the
1324
+ // activity item has no comments.
1325
  if ( 'none' === $comments ) {
1326
  $comments = false;
1327
 
1328
+ // A true cache miss.
1329
  } elseif ( empty( $comments ) ) {
1330
 
1331
  $bp = buddypress();
1332
 
1333
+ // Select the user's fullname with the query.
1334
  if ( bp_is_active( 'xprofile' ) ) {
1335
  $fullname_select = ", pd.value as user_fullname";
1336
  $fullname_from = ", {$bp->profile->table_name_data} pd ";
1337
  $fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1";
1338
 
1339
+ // Prevent debug errors.
1340
  } else {
1341
  $fullname_select = $fullname_from = $fullname_where = '';
1342
  }
1343
 
1344
+ // Don't retrieve activity comments marked as spam.
1345
  if ( 'ham_only' == $spam ) {
1346
  $spam_sql = 'AND a.is_spam = 0';
1347
  } elseif ( 'spam_only' == $spam ) {
1350
  $spam_sql = '';
1351
  }
1352
 
1353
+ // Legacy query - not recommended.
1354
  $func_args = func_get_args();
1355
 
1356
  /**
1357
  * Filters if BuddyPress should use the legacy activity query.
1358
  *
1359
+ * @since 2.0.0
1360
  *
1361
  * @param bool $value Whether or not to use the legacy query.
1362
  * @param BP_Activity_Activity $value Magic method referring to currently called method.
1367
  /**
1368
  * Filters the MySQL prepared statement for the legacy activity query.
1369
  *
1370
+ * @since 1.5.0
1371
  *
1372
  * @param string $value Prepared statement for the activity query.
1373
  * @param int $activity_id Activity ID to fetch comments for.
1391
 
1392
  $ref = array();
1393
 
1394
+ // Loop descendants and build an assoc array.
1395
  foreach ( (array) $descendants as $d ) {
1396
  $d->children = array();
1397
 
1398
+ // If we have a reference on the parent.
1399
  if ( isset( $ref[ $d->secondary_item_id ] ) ) {
1400
  $ref[ $d->secondary_item_id ]->children[ $d->id ] = $d;
1401
  $ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ];
1402
 
1403
+ // If we don't have a reference on the parent, put in the root level.
1404
  } else {
1405
  $comments[ $d->id ] = $d;
1406
  $ref[ $d->id ] =& $comments[ $d->id ];
1407
  }
1408
  }
1409
 
1410
+ // Calculate depth for each item.
1411
  foreach ( $ref as &$r ) {
1412
  $depth = 1;
1413
  $parent_id = $r->secondary_item_id;
1414
+
1415
  while ( $parent_id !== $r->item_id ) {
1416
  $depth++;
1417
 
1418
+ // When display_comments=stream, the parent comment may not be part of the
1419
+ // returned results, so we manually fetch it.
 
 
1420
  if ( empty( $ref[ $parent_id ] ) ) {
1421
  $direct_parent = new BP_Activity_Activity( $parent_id );
1422
  if ( isset( $direct_parent->secondary_item_id ) ) {
1423
+ // If the direct parent is not an activity update, that means we've reached
1424
+ // the parent activity item (eg. new_blog_post).
1425
+ if ( 'activity_update' !== $direct_parent->type ) {
1426
+ $parent_id = $r->item_id;
1427
+
1428
+ } else {
1429
+ $parent_id = $direct_parent->secondary_item_id;
1430
+ }
1431
+
1432
  } else {
1433
+ // Something went wrong. Short-circuit the depth calculation.
 
 
1434
  $parent_id = $r->item_id;
1435
  }
1436
  } else {
1459
  /**
1460
  * Rebuild nested comment tree under an activity or activity comment.
1461
  *
1462
+ * @since 1.2.0
1463
  *
1464
  * @global wpdb $wpdb WordPress database object.
1465
  *
1472
 
1473
  $bp = buddypress();
1474
 
1475
+ // The right value of this node is the left value + 1.
1476
  $right = intval( $left + 1 );
1477
 
1478
+ // Get all descendants of this node.
1479
  $comments = BP_Activity_Activity::get_child_comments( $parent_id );
1480
  $descendants = wp_list_pluck( $comments, 'id' );
1481
 
1482
+ // Loop the descendants and recalculate the left and right values.
1483
  foreach ( (array) $descendants as $descendant_id ) {
1484
  $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );
1485
  }
1486
 
1487
  // We've got the left value, and now that we've processed the children
1488
+ // of this node we also know the right value.
1489
  if ( 1 === $left ) {
1490
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
1491
  } else {
1492
  $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id ) );
1493
  }
1494
 
1495
+ // Return the right value of this node + 1.
1496
  return intval( $right + 1 );
1497
  }
1498
 
1499
  /**
1500
  * Get child comments of an activity or activity comment.
1501
  *
1502
+ * @since 1.2.0
1503
  *
1504
  * @global wpdb $wpdb WordPress database object.
1505
  *
1506
  * @param int $parent_id ID of an activity or activity comment.
 
1507
  * @return object Numerically indexed array of child comments.
1508
  */
1509
  public static function get_child_comments( $parent_id ) {
1518
  * Get a list of components that have recorded activity associated with them.
1519
  *
1520
  * @param bool $skip_last_activity If true, components will not be
1521
+ * included if the only activity type associated with them is
1522
+ * 'last_activity'. (Since 2.0.0, 'last_activity' is stored in
1523
+ * the activity table, but these items are not full-fledged
1524
+ * activity items.) Default: true.
 
1525
  * @return array List of component names.
1526
  */
1527
  public static function get_recorded_components( $skip_last_activity = true ) {
1542
  * Get sitewide activity items for use in an RSS feed.
1543
  *
1544
  * @param int $limit Optional. Number of items to fetch. Default: 35.
 
1545
  * @return array $activity_feed List of activity items, with RSS data added.
1546
  */
1547
  public static function get_sitewide_items_for_feed( $limit = 35 ) {
1562
  /**
1563
  * Create SQL IN clause for filter queries.
1564
  *
1565
+ * @since 1.5.0
1566
  *
1567
  * @see BP_Activity_Activity::get_filter_sql()
1568
  *
1569
  * @param string $field The database field.
1570
  * @param array|bool $items The values for the IN clause, or false when none are found.
1571
+ * @return string|bool
 
1572
  */
1573
  public static function get_in_operator_sql( $field, $items ) {
1574
  global $wpdb;
1575
 
1576
+ // Split items at the comma.
1577
  if ( ! is_array( $items ) ) {
1578
  $items = explode( ',', $items );
1579
  }
1580
 
1581
+ // Array of prepared integers or quoted strings.
1582
  $items_prepared = array();
1583
 
1584
+ // Clean up and format each item.
1585
  foreach ( $items as $item ) {
1586
+ // Clean up the string.
1587
  $item = trim( $item );
1588
+ // Pass everything through prepare for security and to safely quote strings.
1589
  $items_prepared[] = ( is_numeric( $item ) ) ? $wpdb->prepare( '%d', $item ) : $wpdb->prepare( '%s', $item );
1590
  }
1591
 
1592
+ // Build IN operator sql syntax.
1593
  if ( count( $items_prepared ) )
1594
  return sprintf( '%s IN ( %s )', trim( $field ), implode( ',', $items_prepared ) );
1595
  else
1599
  /**
1600
  * Create filter SQL clauses.
1601
  *
1602
+ * @since 1.5.0
1603
  *
1604
  * @param array $filter_array {
1605
  * Fields and values to filter by.
1619
  * date_recorded value greater than a
1620
  * given MySQL-formatted date.
1621
  * }
 
1622
  * @return string The filter clause, for use in a SQL query.
1623
  */
1624
  public static function get_filter_sql( $filter_array ) {
1661
  }
1662
 
1663
  if ( ! empty( $filter_array['since'] ) ) {
1664
+ // Validate that this is a proper Y-m-d H:i:s date.
1665
+ // Trick: parse to UNIX date then translate back.
1666
  $translated_date = date( 'Y-m-d H:i:s', strtotime( $filter_array['since'] ) );
1667
  if ( $translated_date === $filter_array['since'] ) {
1668
  $filter_sql[] = "a.date_recorded > '{$translated_date}'";
1678
  /**
1679
  * Get the date/time of last recorded activity.
1680
  *
1681
+ * @since 1.2.0
1682
  *
1683
  * @return string ISO timestamp.
1684
  */
1693
  /**
1694
  * Get favorite count for a given user.
1695
  *
1696
+ * @since 1.2.0
1697
  *
1698
  * @param int $user_id The ID of the user whose favorites you're counting.
 
1699
  * @return int $value A count of the user's favorites.
1700
  */
1701
  public static function total_favorite_count( $user_id ) {
1702
 
1703
+ // Get activities from user meta.
1704
  $favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
1705
  if ( ! empty( $favorite_activity_entries ) ) {
1706
  return count( maybe_unserialize( $favorite_activity_entries ) );
1707
  }
1708
 
1709
+ // No favorites.
1710
  return 0;
1711
  }
1712
 
1714
  * Check whether an activity item exists with a given string content.
1715
  *
1716
  * @param string $content The content to filter by.
 
1717
  * @return int|bool The ID of the first matching item if found, otherwise false.
1718
  */
1719
  public static function check_exists_by_content( $content ) {
1728
  * Hide all activity for a given user.
1729
  *
1730
  * @param int $user_id The ID of the user whose activity you want to mark hidden.
 
1731
  * @return mixed
1732
  */
1733
  public static function hide_all_for_user( $user_id ) {
1741
  /**
1742
  * PHP-agnostic version of {@link array_replace_recursive()}.
1743
  *
1744
+ * The array_replace_recursive() function is a PHP 5.3 function. BuddyPress (and
1745
  * WordPress) currently supports down to PHP 5.2, so this method is a workaround
1746
  * for PHP 5.2.
1747
  *
1750
  *
1751
  * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
1752
  *
1753
+ * @since 2.2.0
1754
  *
1755
  * @see http://php.net/manual/en/function.array-replace-recursive.php#109390
1756
  *
1757
  * @param array $base Array with keys needing to be replaced.
1758
  * @param array $replacements Array with the replaced keys.
 
1759
  * @return array
1760
  */
1761
  protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
1764
  }
1765
 
1766
  // PHP 5.2-compatible version
1767
+ // http://php.net/manual/en/function.array-replace-recursive.php#109390.
1768
  foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
1769
  $bref_stack = array( &$base );
1770
  $head_stack = array( $replacements );
bp-activity/classes/class-bp-activity-feed.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * BuddyPress Activity Classes
4
  *
5
  * @package BuddyPress
6
- * @subpackage Activity
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
@@ -15,10 +15,12 @@ defined( 'ABSPATH' ) || exit;
15
  * You should only construct a new feed when you've validated that you're on
16
  * the appropriate screen.
17
  *
 
 
18
  * See {@link bp_activity_action_sitewide_feed()} as an example.
19
  *
20
  * @param array $args {
21
- * @type string $id Required. Internal id for the feed; should be alphanumeric only.
22
  * @type string $title Optional. RSS feed title.
23
  * @type string $link Optional. Relevant link for the RSS feed.
24
  * @type string $description Optional. RSS feed description.
@@ -30,7 +32,6 @@ defined( 'ABSPATH' ) || exit;
30
  * @type string $max Optional. Number of feed items to display.
31
  * @type array $activity_args Optional. Arguments passed to {@link bp_has_activities()}
32
  * }
33
- * @since BuddyPress (1.8.0)
34
  */
35
  class BP_Activity_Feed {
36
 
@@ -48,7 +49,7 @@ class BP_Activity_Feed {
48
  /**
49
  * Magic method for checking the existence of a certain data variable.
50
  *
51
- * @param string $key
52
  *
53
  * @return bool Whether or not data variable exists.
54
  */
@@ -57,12 +58,22 @@ class BP_Activity_Feed {
57
  /**
58
  * Magic method for getting a certain data variable.
59
  *
60
- * @param string $key
61
  *
62
  * @return mixed Data in variable if available or null.
63
  */
64
  public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
65
 
 
 
 
 
 
 
 
 
 
 
66
  /**
67
  * Constructor.
68
  *
@@ -73,68 +84,68 @@ class BP_Activity_Feed {
73
  /**
74
  * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
75
  *
76
- * @since BuddyPress (1.8.0)
77
  *
78
  * @param bool true Default true aka feeds are enabled.
79
  */
80
  if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
81
  global $wp_query;
82
 
83
- // set feed flag to false
84
  $wp_query->is_feed = false;
85
 
86
  return false;
87
  }
88
 
89
- // Setup data
90
  $this->data = wp_parse_args( $args, array(
91
- // Internal identifier for the RSS feed - should be alphanumeric only
92
  'id' => '',
93
 
94
- // RSS title - should be plain-text
95
  'title' => '',
96
 
97
- // relevant link for the RSS feed
98
  'link' => '',
99
 
100
- // RSS description - should be plain-text
101
  'description' => '',
102
 
103
  // Time-to-live - number of minutes to cache the data before an aggregator
104
  // requests it again. This is only acknowledged if the RSS client supports it
105
  //
106
- // See: http://www.rssboard.org/rss-profile#element-channel-ttl
107
- // http://www.kbcafe.com/rss/rssfeedstate.html#ttl
108
  'ttl' => '30',
109
 
110
  // Syndication module - similar to ttl, but not really supported by RSS
111
  // clients
112
  //
113
- // See: http://web.resource.org/rss/1.0/modules/syndication/#description
114
- // http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule
115
  'update_period' => 'hourly',
116
  'update_frequency' => 2,
117
 
118
- // Number of items to display
119
  'max' => 50,
120
 
121
- // Activity arguments passed to bp_has_activities()
122
  'activity_args' => array()
123
  ) );
124
 
125
  /**
126
  * Fires before the feed is setup so plugins can modify.
127
  *
128
- * @since BuddyPress (1.8.0)
129
  *
130
  * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
131
  */
132
  do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
133
 
134
- // Setup class properties
135
  $this->setup_properties();
136
 
137
- // Check if id is valid
138
  if ( empty( $this->id ) ) {
139
  _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
140
  return false;
@@ -143,19 +154,19 @@ class BP_Activity_Feed {
143
  /**
144
  * Fires after the feed is setup so plugins can modify.
145
  *
146
- * @since BuddyPress (1.8.0)
147
  *
148
  * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
149
  */
150
  do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
151
 
152
- // Setup feed hooks
153
  $this->setup_hooks();
154
 
155
- // Output the feed
156
  $this->output();
157
 
158
- // Kill the rest of the output
159
  die();
160
  }
161
 
@@ -163,8 +174,6 @@ class BP_Activity_Feed {
163
 
164
  /**
165
  * Setup and validate the class properties.
166
- *
167
- * @access protected
168
  */
169
  protected function setup_properties() {
170
  $this->id = sanitize_title( $this->id );
@@ -188,8 +197,6 @@ class BP_Activity_Feed {
188
  *
189
  * Currently, these hooks are used to maintain backwards compatibility with
190
  * the RSS feeds previous to BP 1.8.
191
- *
192
- * @access protected
193
  */
194
  protected function setup_hooks() {
195
  add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
@@ -209,7 +216,7 @@ class BP_Activity_Feed {
209
  *
210
  * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
211
  *
212
- * @since BuddyPress (1.0.0)
213
  */
214
  do_action( 'bp_activity_' . $this->id . '_feed' );
215
  }
@@ -224,7 +231,7 @@ class BP_Activity_Feed {
224
  *
225
  * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
226
  *
227
- * @since BuddyPress (1.0.0)
228
  */
229
  do_action( 'bp_activity_' . $this->id . '_feed_head' );
230
  }
@@ -235,7 +242,7 @@ class BP_Activity_Feed {
235
  public function backpat_item_elements() {
236
  switch ( $this->id ) {
237
 
238
- // sitewide and friends feeds use the 'personal' hook
239
  case 'sitewide' :
240
  case 'friends' :
241
  $id = 'personal';
@@ -253,7 +260,7 @@ class BP_Activity_Feed {
253
  *
254
  * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
255
  *
256
- * @since BuddyPress (1.0.0)
257
  */
258
  do_action( 'bp_activity_' . $id . '_feed_item' );
259
  }
@@ -262,15 +269,13 @@ class BP_Activity_Feed {
262
 
263
  /**
264
  * Output the feed's item content.
265
- *
266
- * @access protected
267
  */
268
  protected function feed_content() {
269
  bp_activity_content_body();
270
 
271
  switch ( $this->id ) {
272
 
273
- // also output parent activity item if we're on a specific feed
274
  case 'favorites' :
275
  case 'friends' :
276
  case 'mentions' :
@@ -292,13 +297,11 @@ class BP_Activity_Feed {
292
  *
293
  * Most of this class method is derived from {@link WP::send_headers()}.
294
  *
295
- * @since BuddyPress (1.9.0)
296
- *
297
- * @access protected
298
  */
299
  protected function http_headers() {
300
- // set up some additional headers if not on a directory page
301
- // this is done b/c BP uses pseudo-pages
302
  if ( ! bp_is_directory() ) {
303
  global $wp_query;
304
 
@@ -306,46 +309,46 @@ class BP_Activity_Feed {
306
  status_header( 200 );
307
  }
308
 
309
- // Set content-type
310
  @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
311
  send_nosniff_header();
312
 
313
- // Cache-related variables
314
  $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
315
  $modified_timestamp = strtotime( $last_modified );
316
  $etag = md5( $last_modified );
317
 
318
- // Set cache-related headers
319
  @header( 'Last-Modified: ' . $last_modified );
320
  @header( 'Pragma: no-cache' );
321
  @header( 'ETag: ' . '"' . $etag . '"' );
322
 
323
- // First commit of BuddyPress! (Easter egg)
324
  @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT');
325
 
326
- // Get ETag from supported user agents
327
  if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
328
  $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
329
 
330
- // Remove quotes from ETag
331
  $client_etag = trim( $client_etag, '"' );
332
 
333
- // Strip suffixes from ETag if they exist (eg. "-gzip")
334
  $etag_suffix_pos = strpos( $client_etag, '-' );
335
  if ( ! empty( $etag_suffix_pos ) ) {
336
  $client_etag = substr( $client_etag, 0, $etag_suffix_pos );
337
  }
338
 
339
- // No ETag found
340
  } else {
341
  $client_etag = false;
342
  }
343
 
344
- // Get client last modified timestamp from supported user agents
345
  $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
346
  $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
347
 
348
- // Set 304 status if feed hasn't been updated since last fetch
349
  if ( ( $client_last_modified && $client_etag ) ?
350
  ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) :
351
  ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) {
@@ -354,11 +357,11 @@ class BP_Activity_Feed {
354
  $status = false;
355
  }
356
 
357
- // If feed hasn't changed as reported by the user agent, set 304 status header
358
  if ( ! empty( $status ) ) {
359
  status_header( $status );
360
 
361
- // cached response, so stop now!
362
  if ( $status == 304 ) {
363
  exit();
364
  }
@@ -369,8 +372,6 @@ class BP_Activity_Feed {
369
 
370
  /**
371
  * Output the RSS feed.
372
- *
373
- * @access protected
374
  */
375
  protected function output() {
376
  $this->http_headers();
@@ -387,7 +388,7 @@ class BP_Activity_Feed {
387
  /**
388
  * Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
389
  *
390
- * @since BuddyPress (1.8.0)
391
  */
392
  do_action( 'bp_activity_feed_rss_attributes' ); ?>
393
  >
@@ -408,7 +409,7 @@ class BP_Activity_Feed {
408
  /**
409
  * Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
410
  *
411
- * @since BuddyPress (1.8.0)
412
  */
413
  do_action( 'bp_activity_feed_channel_elements' ); ?>
414
 
@@ -433,7 +434,7 @@ class BP_Activity_Feed {
433
  /**
434
  * Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
435
  *
436
- * @since BuddyPress (1.8.0)
437
  */
438
  do_action( 'bp_activity_feed_item_elements' ); ?>
439
  </item>
1
  <?php
2
  /**
3
+ * BuddyPress Activity Classes.
4
  *
5
  * @package BuddyPress
6
+ * @subpackage ActivityFeeds
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
15
  * You should only construct a new feed when you've validated that you're on
16
  * the appropriate screen.
17
  *
18
+ * @since 1.8.0
19
+ *
20
  * See {@link bp_activity_action_sitewide_feed()} as an example.
21
  *
22
  * @param array $args {
23
+ * @type string $id Required. Internal id for the feed; should be alphanumeric only.
24
  * @type string $title Optional. RSS feed title.
25
  * @type string $link Optional. Relevant link for the RSS feed.
26
  * @type string $description Optional. RSS feed description.
32
  * @type string $max Optional. Number of feed items to display.
33
  * @type array $activity_args Optional. Arguments passed to {@link bp_has_activities()}
34
  * }
 
35
  */
36
  class BP_Activity_Feed {
37
 
49
  /**
50
  * Magic method for checking the existence of a certain data variable.
51
  *
52
+ * @param string $key Property to check.
53
  *
54
  * @return bool Whether or not data variable exists.
55
  */
58
  /**
59
  * Magic method for getting a certain data variable.
60
  *
61
+ * @param string $key Property to get.
62
  *
63
  * @return mixed Data in variable if available or null.
64
  */
65
  public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
66
 
67
+ /**
68
+ * Magic method for setting a certain data variable.
69
+ *
70
+ * @since 2.4.0
71
+ *
72
+ * @param string $key The property to set.
73
+ * @param mixed $value The value to set.
74
+ */
75
+ public function __set( $key, $value ) { $this->data[$key] = $value; }
76
+
77
  /**
78
  * Constructor.
79
  *
84
  /**
85
  * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
86
  *
87
+ * @since 1.8.0
88
  *
89
  * @param bool true Default true aka feeds are enabled.
90
  */
91
  if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
92
  global $wp_query;
93
 
94
+ // Set feed flag to false.
95
  $wp_query->is_feed = false;
96
 
97
  return false;
98
  }
99
 
100
+ // Setup data.
101
  $this->data = wp_parse_args( $args, array(
102
+ // Internal identifier for the RSS feed - should be alphanumeric only.
103
  'id' => '',
104
 
105
+ // RSS title - should be plain-text.
106
  'title' => '',
107
 
108
+ // Relevant link for the RSS feed.
109
  'link' => '',
110
 
111
+ // RSS description - should be plain-text.
112
  'description' => '',
113
 
114
  // Time-to-live - number of minutes to cache the data before an aggregator
115
  // requests it again. This is only acknowledged if the RSS client supports it
116
  //
117
+ // See: http://www.rssboard.org/rss-profile#element-channel-ttl.
118
+ // See: http://www.kbcafe.com/rss/rssfeedstate.html#ttl.
119
  'ttl' => '30',
120
 
121
  // Syndication module - similar to ttl, but not really supported by RSS
122
  // clients
123
  //
124
+ // See: http://web.resource.org/rss/1.0/modules/syndication/#description.
125
+ // See: http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule.
126
  'update_period' => 'hourly',
127
  'update_frequency' => 2,
128
 
129
+ // Number of items to display.
130
  'max' => 50,
131
 
132
+ // Activity arguments passed to bp_has_activities().
133
  'activity_args' => array()
134
  ) );
135
 
136
  /**
137
  * Fires before the feed is setup so plugins can modify.
138
  *
139
+ * @since 1.8.0
140
  *
141
  * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
142
  */
143
  do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
144
 
145
+ // Setup class properties.
146
  $this->setup_properties();
147
 
148
+ // Check if id is valid.
149
  if ( empty( $this->id ) ) {
150
  _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
151
  return false;
154
  /**
155
  * Fires after the feed is setup so plugins can modify.
156
  *
157
+ * @since 1.8.0
158
  *
159
  * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
160
  */
161
  do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
162
 
163
+ // Setup feed hooks.
164
  $this->setup_hooks();
165
 
166
+ // Output the feed.
167
  $this->output();
168
 
169
+ // Kill the rest of the output.
170
  die();
171
  }
172
 
174
 
175
  /**
176
  * Setup and validate the class properties.
 
 
177
  */
178
  protected function setup_properties() {
179
  $this->id = sanitize_title( $this->id );
197
  *
198
  * Currently, these hooks are used to maintain backwards compatibility with
199
  * the RSS feeds previous to BP 1.8.
 
 
200
  */
201
  protected function setup_hooks() {
202
  add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
216
  *
217
  * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
218
  *
219
+ * @since 1.0.0
220
  */
221
  do_action( 'bp_activity_' . $this->id . '_feed' );
222
  }
231
  *
232
  * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
233
  *
234
+ * @since 1.0.0
235
  */
236
  do_action( 'bp_activity_' . $this->id . '_feed_head' );
237
  }
242
  public function backpat_item_elements() {
243
  switch ( $this->id ) {
244
 
245
+ // Sitewide and friends feeds use the 'personal' hook.
246
  case 'sitewide' :
247
  case 'friends' :
248
  $id = 'personal';
260
  *
261
  * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
262
  *
263
+ * @since 1.0.0
264
  */
265
  do_action( 'bp_activity_' . $id . '_feed_item' );
266
  }
269
 
270
  /**
271
  * Output the feed's item content.
 
 
272
  */
273
  protected function feed_content() {
274
  bp_activity_content_body();
275
 
276
  switch ( $this->id ) {
277
 
278
+ // Also output parent activity item if we're on a specific feed.
279
  case 'favorites' :
280
  case 'friends' :
281
  case 'mentions' :
297
  *
298
  * Most of this class method is derived from {@link WP::send_headers()}.
299
  *
300
+ * @since 1.9.0
 
 
301
  */
302
  protected function http_headers() {
303
+ // Set up some additional headers if not on a directory page
304
+ // this is done b/c BP uses pseudo-pages.
305
  if ( ! bp_is_directory() ) {
306
  global $wp_query;
307
 
309
  status_header( 200 );
310
  }
311
 
312
+ // Set content-type.
313
  @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
314
  send_nosniff_header();
315
 
316
+ // Cache-related variables.
317
  $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
318
  $modified_timestamp = strtotime( $last_modified );
319
  $etag = md5( $last_modified );
320
 
321
+ // Set cache-related headers.
322
  @header( 'Last-Modified: ' . $last_modified );
323
  @header( 'Pragma: no-cache' );
324
  @header( 'ETag: ' . '"' . $etag . '"' );
325
 
326
+ // First commit of BuddyPress! (Easter egg).
327
  @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT');
328
 
329
+ // Get ETag from supported user agents.
330
  if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
331
  $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
332
 
333
+ // Remove quotes from ETag.
334
  $client_etag = trim( $client_etag, '"' );
335
 
336
+ // Strip suffixes from ETag if they exist (eg. "-gzip").
337
  $etag_suffix_pos = strpos( $client_etag, '-' );
338
  if ( ! empty( $etag_suffix_pos ) ) {
339
  $client_etag = substr( $client_etag, 0, $etag_suffix_pos );
340
  }
341
 
342
+ // No ETag found.
343
  } else {
344
  $client_etag = false;
345
  }
346
 
347
+ // Get client last modified timestamp from supported user agents.
348
  $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
349
  $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
350
 
351
+ // Set 304 status if feed hasn't been updated since last fetch.
352
  if ( ( $client_last_modified && $client_etag ) ?
353
  ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) :
354
  ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) {
357
  $status = false;
358
  }
359
 
360
+ // If feed hasn't changed as reported by the user agent, set 304 status header.
361
  if ( ! empty( $status ) ) {
362
  status_header( $status );
363
 
364
+ // Cached response, so stop now!
365
  if ( $status == 304 ) {
366
  exit();
367
  }
372
 
373
  /**
374
  * Output the RSS feed.
 
 
375
  */
376
  protected function output() {
377
  $this->http_headers();
388
  /**
389
  * Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
390
  *
391
+ * @since 1.8.0
392
  */
393
  do_action( 'bp_activity_feed_rss_attributes' ); ?>
394
  >
409
  /**
410
  * Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
411
  *
412
+ * @since 1.8.0
413
  */
414
  do_action( 'bp_activity_feed_channel_elements' ); ?>
415
 
434
  /**
435
  * Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
436
  *
437
+ * @since 1.8.0
438
  */
439
  do_action( 'bp_activity_feed_item_elements' ); ?>
440
  </item>
bp-activity/classes/class-bp-activity-query.php CHANGED
@@ -3,10 +3,10 @@
3
  * BuddyPress Activity Classes
4
  *
5
  * @package BuddyPress
6
- * @subpackage Activity
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
@@ -15,7 +15,7 @@ defined( 'ABSPATH' ) || exit;
15
  * This is notably used in {@link BP_Activity_Activity::get()} with the
16
  * 'filter_query' parameter.
17
  *
18
- * @since BuddyPress (2.2.0)
19
  */
20
  class BP_Activity_Query extends BP_Recursive_Query {
21
  /**
@@ -23,8 +23,7 @@ class BP_Activity_Query extends BP_Recursive_Query {
23
  *
24
  * See {@see BP_Activity_Query::__construct()} for information on query arguments.
25
  *
26
- * @since BuddyPress (2.2.0)
27
- * @access public
28
  * @var array
29
  */
30
  public $queries = array();
@@ -32,8 +31,7 @@ class BP_Activity_Query extends BP_Recursive_Query {
32
  /**
33
  * Table alias.
34
  *
35
- * @since BuddyPress (2.2.0)
36
- * @access public
37
  * @var string
38
  */
39
  public $table_alias = '';
@@ -43,8 +41,7 @@ class BP_Activity_Query extends BP_Recursive_Query {
43
  *
44
  * See the 'wp_bp_activity' DB table schema.
45
  *
46
- * @since BuddyPress (2.2.0)
47
- * @access public
48
  * @var array
49
  */
50
  public $db_columns = array(
@@ -55,11 +52,10 @@ class BP_Activity_Query extends BP_Recursive_Query {
55
  /**
56
  * Constructor.
57
  *
58
- * @since BuddyPress (2.2.0)
59
  *
60
  * @param array $query {
61
  * Array of query clauses.
62
- *
63
  * @type array {
64
  * @type string $column Required. The column to query against. Basically, any DB column in the main
65
  * 'wp_bp_activity' table.
@@ -86,12 +82,10 @@ class BP_Activity_Query extends BP_Recursive_Query {
86
  /**
87
  * Generates WHERE SQL clause to be appended to a main query.
88
  *
89
- * @since BuddyPress (2.2.0)
90
- * @access public
91
  *
92
  * @param string $alias An existing table alias that is compatible with the current query clause.
93
  * Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
94
- *
95
  * @return string SQL fragment to append to the main WHERE clause.
96
  */
97
  public function get_sql( $alias = 'a' ) {
@@ -101,22 +95,20 @@ class BP_Activity_Query extends BP_Recursive_Query {
101
 
102
  $sql = $this->get_sql_clauses();
103
 
104
- // we only need the 'where' clause
105
  //
106
- // also trim trailing "AND" clause from parent BP_Recursive_Query class
107
- // since it's not necessary for our needs
108
  return preg_replace( '/^\sAND/', '', $sql['where'] );
109
  }
110
 
111
  /**
112
  * Generate WHERE clauses for a first-order clause.
113
  *
114
- * @since BuddyPress (2.2.0)
115
- * @access protected
116
  *
117
  * @param array $clause Array of arguments belonging to the clause.
118
  * @param array $parent_query Parent query to which the clause belongs.
119
- *
120
  * @return array {
121
  * @type array $where Array of subclauses for the WHERE statement.
122
  * @type array $join Empty array. Not used.
@@ -142,7 +134,7 @@ class BP_Activity_Query extends BP_Recursive_Query {
142
  $clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
143
  }
144
 
145
- // default 'compare' to '=' if no valid operator is found
146
  if ( ! in_array( $clause['compare'], array(
147
  '=', '!=', '>', '>=', '<', '<=',
148
  'LIKE', 'NOT LIKE',
@@ -160,7 +152,7 @@ class BP_Activity_Query extends BP_Recursive_Query {
160
  // Next, Build the WHERE clause.
161
  $where = '';
162
 
163
- // value.
164
  if ( isset( $clause['value'] ) ) {
165
  if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
166
  if ( ! is_array( $value ) ) {
@@ -168,13 +160,13 @@ class BP_Activity_Query extends BP_Recursive_Query {
168
  }
169
  }
170
 
171
- // tinyint
172
  if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
173
  $sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
174
 
175
  } else {
176
  switch ( $compare ) {
177
- // IN uses different syntax
178
  case 'IN' :
179
  case 'NOT IN' :
180
  $in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value );
@@ -224,11 +216,9 @@ class BP_Activity_Query extends BP_Recursive_Query {
224
  /**
225
  * Determine whether a clause is first-order.
226
  *
227
- * @since BuddyPress (2.2.0)
228
- * @access protected
229
  *
230
  * @param array $query Clause to check.
231
- *
232
  * @return bool
233
  */
234
  protected function is_first_order_clause( $query ) {
@@ -241,11 +231,9 @@ class BP_Activity_Query extends BP_Recursive_Query {
241
  * Column names are checked against a whitelist of known tables.
242
  * See {@link BP_Activity_Query::db_tables}.
243
  *
244
- * @since BuddyPress (2.2.0)
245
- * @access public
246
  *
247
  * @param string $column The user-supplied column name.
248
- *
249
  * @return string A validated column name value.
250
  */
251
  public function validate_column( $column = '' ) {
3
  * BuddyPress Activity Classes
4
  *
5
  * @package BuddyPress
6
+ * @subpackage ActivityQuery
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
15
  * This is notably used in {@link BP_Activity_Activity::get()} with the
16
  * 'filter_query' parameter.
17
  *
18
+ * @since 2.2.0
19
  */
20
  class BP_Activity_Query extends BP_Recursive_Query {
21
  /**
23
  *
24
  * See {@see BP_Activity_Query::__construct()} for information on query arguments.
25
  *
26
+ * @since 2.2.0
 
27
  * @var array
28
  */
29
  public $queries = array();
31
  /**
32
  * Table alias.
33
  *
34
+ * @since 2.2.0
 
35
  * @var string
36
  */
37
  public $table_alias = '';
41
  *
42
  * See the 'wp_bp_activity' DB table schema.
43
  *
44
+ * @since 2.2.0
 
45
  * @var array
46
  */
47
  public $db_columns = array(
52
  /**
53
  * Constructor.
54
  *
55
+ * @since 2.2.0
56
  *
57
  * @param array $query {
58
  * Array of query clauses.
 
59
  * @type array {
60
  * @type string $column Required. The column to query against. Basically, any DB column in the main
61
  * 'wp_bp_activity' table.
82
  /**
83
  * Generates WHERE SQL clause to be appended to a main query.
84
  *
85
+ * @since 2.2.0
 
86
  *
87
  * @param string $alias An existing table alias that is compatible with the current query clause.
88
  * Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
 
89
  * @return string SQL fragment to append to the main WHERE clause.
90
  */
91
  public function get_sql( $alias = 'a' ) {
95
 
96
  $sql = $this->get_sql_clauses();
97
 
98
+ // We only need the 'where' clause.
99
  //
100
+ // Also trim trailing "AND" clause from parent BP_Recursive_Query class
101
+ // since it's not necessary for our needs.
102
  return preg_replace( '/^\sAND/', '', $sql['where'] );
103
  }
104
 
105
  /**
106
  * Generate WHERE clauses for a first-order clause.
107
  *
108
+ * @since 2.2.0
 
109
  *
110
  * @param array $clause Array of arguments belonging to the clause.
111
  * @param array $parent_query Parent query to which the clause belongs.
 
112
  * @return array {
113
  * @type array $where Array of subclauses for the WHERE statement.
114
  * @type array $join Empty array. Not used.
134
  $clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
135
  }
136
 
137
+ // Default 'compare' to '=' if no valid operator is found.
138
  if ( ! in_array( $clause['compare'], array(
139
  '=', '!=', '>', '>=', '<', '<=',
140
  'LIKE', 'NOT LIKE',
152
  // Next, Build the WHERE clause.
153
  $where = '';
154
 
155
+ // Value.
156
  if ( isset( $clause['value'] ) ) {
157
  if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
158
  if ( ! is_array( $value ) ) {
160
  }
161
  }
162
 
163
+ // Tinyint.
164
  if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
165
  $sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
166
 
167
  } else {
168
  switch ( $compare ) {
169
+ // IN uses different syntax.
170
  case 'IN' :
171
  case 'NOT IN' :
172
  $in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value );
216
  /**
217
  * Determine whether a clause is first-order.
218
  *
219
+ * @since 2.2.0
 
220
  *
221
  * @param array $query Clause to check.
 
222
  * @return bool
223
  */
224
  protected function is_first_order_clause( $query ) {
231
  * Column names are checked against a whitelist of known tables.
232
  * See {@link BP_Activity_Query::db_tables}.
233
  *
234
+ * @since 2.2.0
 
235
  *
236
  * @param string $column The user-supplied column name.
 
237
  * @return string A validated column name value.
238
  */
239
  public function validate_column( $column = '' ) {
bp-activity/js/mentions.js CHANGED
@@ -17,7 +17,7 @@ window.bp = window.bp || {};
17
  * Adds BuddyPress @mentions to form inputs.
18
  *
19
  * @param {array|object} options If array, becomes the suggestions' data source. If object, passed as config to $.atwho().
20
- * @since BuddyPress (2.1.0)
21
  */
22
  $.fn.bp_mentions = function( options ) {
23
  if ( $.isArray( options ) ) {
@@ -44,7 +44,7 @@ window.bp = window.bp || {};
44
  * @param {array} data
45
  * @param {string} search_key
46
  * @return {array}
47
- * @since BuddyPress (2.1.0)
48
  */
49
  filter: function( query, data, search_key ) {
50
  var item, _i, _len, _results = [],
@@ -67,7 +67,7 @@ window.bp = window.bp || {};
67
  * @param {unknown} li
68
  * @param {string} query
69
  * @return {string}
70
- * @since BuddyPress (2.1.0)
71
  */
72
  highlighter: function( li, query ) {
73
  if ( ! query ) {
@@ -84,7 +84,7 @@ window.bp = window.bp || {};
84
  * Reposition the suggestion list dynamically.
85
  *
86
  * @param {unknown} offset
87
- * @since BuddyPress (2.1.0)
88
  */
89
  before_reposition: function( offset ) {
90
  // get the iframe, if any, already applied with atwho
@@ -141,7 +141,7 @@ window.bp = window.bp || {};
141
  * @param {string) content The content that will be inserted.
142
  * @param {string) suffix Applied to the end of the content string.
143
  * @return {string}
144
- * @since BuddyPress (2.1.0)
145
  */
146
  inserting_wrapper: function( $inputor, content, suffix ) {
147
  return '' + content + suffix;
@@ -159,7 +159,7 @@ window.bp = window.bp || {};
159
  *
160
  * @param {string} query Partial @mention to search for.
161
  * @param {function} render_view Render page callback function.
162
- * @since BuddyPress (2.1.0)
163
  */
164
  remote_filter: function( query, render_view ) {
165
  var self = $( this ),
@@ -186,7 +186,7 @@ window.bp = window.bp || {};
186
  * Success callback for the @suggestions lookup.
187
  *
188
  * @param {object} response Details of users matching the query.
189
- * @since BuddyPress (2.1.0)
190
  */
191
  .done(function( response ) {
192
  if ( ! response.success ) {
@@ -200,7 +200,7 @@ window.bp = window.bp || {};
200
  *
201
  * @param {array} suggestion A suggestion's original data.
202
  * @return {array} A suggestion's new data.
203
- * @since BuddyPress (2.1.0)
204
  */
205
  function( suggestion ) {
206
  suggestion.search = suggestion.search || suggestion.ID + ' ' + suggestion.name;
@@ -221,7 +221,7 @@ window.bp = window.bp || {};
221
  *
222
  * @param {array} suggestion A suggestion's original data.
223
  * @return {array} A suggestion's new data.
224
- * @since BuddyPress (2.1.0)
225
  */
226
  function( suggestion ) {
227
  suggestion.search = suggestion.search || suggestion.ID + ' ' + suggestion.name;
@@ -252,4 +252,4 @@ window.bp = window.bp || {};
252
  .bp_mentions( bp.mentions.users );
253
  }
254
  };
255
- })( bp, jQuery );
17
  * Adds BuddyPress @mentions to form inputs.
18
  *
19
  * @param {array|object} options If array, becomes the suggestions' data source. If object, passed as config to $.atwho().
20
+ * @since 2.1.0
21
  */
22
  $.fn.bp_mentions = function( options ) {
23
  if ( $.isArray( options ) ) {
44
  * @param {array} data
45
  * @param {string} search_key
46
  * @return {array}
47
+ * @since 2.1.0
48
  */
49
  filter: function( query, data, search_key ) {
50
  var item, _i, _len, _results = [],
67
  * @param {unknown} li
68
  * @param {string} query
69
  * @return {string}
70
+ * @since 2.1.0
71
  */
72
  highlighter: function( li, query ) {
73
  if ( ! query ) {
84
  * Reposition the suggestion list dynamically.
85
  *
86
  * @param {unknown} offset
87
+ * @since 2.1.0
88
  */
89
  before_reposition: function( offset ) {
90
  // get the iframe, if any, already applied with atwho
141
  * @param {string) content The content that will be inserted.
142
  * @param {string) suffix Applied to the end of the content string.
143
  * @return {string}
144
+ * @since 2.1.0
145
  */
146
  inserting_wrapper: function( $inputor, content, suffix ) {
147
  return '' + content + suffix;
159
  *
160
  * @param {string} query Partial @mention to search for.
161
  * @param {function} render_view Render page callback function.
162
+ * @since 2.1.0
163
  */
164
  remote_filter: function( query, render_view ) {
165
  var self = $( this ),
186
  * Success callback for the @suggestions lookup.
187
  *
188
  * @param {object} response Details of users matching the query.
189
+ * @since 2.1.0
190
  */
191
  .done(function( response ) {
192
  if ( ! response.success ) {
200
  *
201
  * @param {array} suggestion A suggestion's original data.
202
  * @return {array} A suggestion's new data.
203
+ * @since 2.1.0
204
  */
205
  function( suggestion ) {
206
  suggestion.search = suggestion.search || suggestion.ID + ' ' + suggestion.name;
221
  *
222
  * @param {array} suggestion A suggestion's original data.
223
  * @return {array} A suggestion's new data.
224
+ * @since 2.1.0
225
  */
226
  function( suggestion ) {
227
  suggestion.search = suggestion.search || suggestion.ID + ' ' + suggestion.name;
252
  .bp_mentions( bp.mentions.users );
253
  }
254
  };
255
+ })( bp, jQuery );
bp-activity/js/mentions.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! buddypress - v2.3.4 - 2015-10-07 3:54:34 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
- window.bp=window.bp||{},function(a,b){var c,d=[];a.mentions=a.mentions||{},a.mentions.users=window.bp.mentions.users||[],"object"==typeof window.BP_Suggestions&&(a.mentions.users=window.BP_Suggestions.friends||a.mentions.users),b.fn.bp_mentions=function(a){b.isArray(a)&&(a={data:a});var e={delay:200,hide_without_suffix:!0,insert_tpl:"</>${atwho-data-value}</>",limit:10,start_with_space:!1,suffix:"",callbacks:{filter:function(a,b,c){var d,e,f,g=[],h=new RegExp("^"+a+"| "+a,"ig");for(e=0,f=b.length;f>e;e++)d=b[e],d[c].toLowerCase().match(h)&&g.push(d);return g},highlighter:function(a,b){if(!b)return a;var c=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+b.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return a.replace(c,function(a,b,c,d){return">"+b+"<strong>"+c+"</strong>"+d+"<"})},before_reposition:function(a){var c,d,e,f,g=b("#atwho-ground-"+this.id+" .atwho-view"),h=b("body"),i=this.$inputor.data("atwho");"undefined"!==i&&"undefined"!==i.iframe&&null!==i.iframe?(c=this.$inputor.caret("offset",{iframe:i.iframe}),e=b(i.iframe).offset(),"undefined"!==e&&(c.left+=e.left,c.top+=e.top)):c=this.$inputor.caret("offset"),c.left>h.width()/2?(g.addClass("right"),f=c.left-a.left-this.view.$el.width()):(g.removeClass("right"),f=c.left-a.left+1),h.width()<=400&&b(document).scrollTop(c.top-6),d=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10),(!d||5>d)&&(d=19),a.top=c.top+d,a.left+=f},inserting_wrapper:function(a,b,c){return""+b+c}}},f={callbacks:{remote_filter:function(a,e){var f=b(this),g={};return c=d[a],"object"==typeof c?void e(c):(f.xhr&&f.xhr.abort(),g={action:"bp_get_suggestions",term:a,type:"members"},b.isNumeric(this.$inputor.data("suggestions-group-id"))&&(g["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),void(f.xhr=b.getJSON(ajaxurl,g).done(function(c){if(c.success){var f=b.map(c.data,function(a){return a.search=a.search||a.ID+" "+a.name,a});d[a]=f,e(f)}})))}},data:b.map(a.data,function(a){return a.search=a.search||a.ID+" "+a.name,a}),at:"@",search_key:"search",tpl:'<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'},g=b.extend(!0,{},e,f,a);return b.fn.atwho.call(this,g)},b(document).ready(function(){b(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(a.mentions.users)}),a.mentions.tinyMCEinit=function(){"undefined"!=typeof window.tinyMCE&&null!==window.tinyMCE.activeEditor&&"undefined"!=typeof window.tinyMCE.activeEditor&&b(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",b("#content_ifr")[0]).bp_mentions(a.mentions.users)}}(bp,jQuery);
1
+ /*! buddypress - v2.4.0 - 2015-10-12 8:03:39 PM UTC - https://wordpress.org/plugins/buddypress/ */
2
+ window.bp=window.bp||{},function(a,b,c){var d,e=[];a.mentions=a.mentions||{},a.mentions.users=window.bp.mentions.users||[],"object"==typeof window.BP_Suggestions&&(a.mentions.users=window.BP_Suggestions.friends||a.mentions.users),b.fn.bp_mentions=function(a){b.isArray(a)&&(a={data:a});var c={delay:200,hide_without_suffix:!0,insert_tpl:"</>${atwho-data-value}</>",limit:10,start_with_space:!1,suffix:"",callbacks:{filter:function(a,b,c){var d,e,f,g=[],h=new RegExp("^"+a+"| "+a,"ig");for(e=0,f=b.length;f>e;e++)d=b[e],d[c].toLowerCase().match(h)&&g.push(d);return g},highlighter:function(a,b){if(!b)return a;var c=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+b.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return a.replace(c,function(a,b,c,d){return">"+b+"<strong>"+c+"</strong>"+d+"<"})},before_reposition:function(a){var c,d,e,f,g=b("#atwho-ground-"+this.id+" .atwho-view"),h=b("body"),i=this.$inputor.data("atwho");"undefined"!==i&&"undefined"!==i.iframe&&null!==i.iframe?(c=this.$inputor.caret("offset",{iframe:i.iframe}),e=b(i.iframe).offset(),"undefined"!==e&&(c.left+=e.left,c.top+=e.top)):c=this.$inputor.caret("offset"),c.left>h.width()/2?(g.addClass("right"),f=c.left-a.left-this.view.$el.width()):(g.removeClass("right"),f=c.left-a.left+1),h.width()<=400&&b(document).scrollTop(c.top-6),d=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10),(!d||5>d)&&(d=19),a.top=c.top+d,a.left+=f},inserting_wrapper:function(a,b,c){return""+b+c}}},f={callbacks:{remote_filter:function(a,c){var f=b(this),g={};return d=e[a],"object"==typeof d?void c(d):(f.xhr&&f.xhr.abort(),g={action:"bp_get_suggestions",term:a,type:"members"},b.isNumeric(this.$inputor.data("suggestions-group-id"))&&(g["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),void(f.xhr=b.getJSON(ajaxurl,g).done(function(d){if(d.success){var f=b.map(d.data,function(a){return a.search=a.search||a.ID+" "+a.name,a});e[a]=f,c(f)}})))}},data:b.map(a.data,function(a){return a.search=a.search||a.ID+" "+a.name,a}),at:"@",search_key:"search",tpl:'<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'},g=b.extend(!0,{},c,f,a);return b.fn.atwho.call(this,g)},b(document).ready(function(){b(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(a.mentions.users)}),a.mentions.tinyMCEinit=function(){"undefined"!=typeof window.tinyMCE&&null!==window.tinyMCE.activeEditor&&"undefined"!=typeof window.tinyMCE.activeEditor&&b(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",b("#content_ifr")[0]).bp_mentions(a.mentions.users)}}(bp,jQuery);
bp-blogs/bp-blogs-actions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Blogs Actions.
5
  *
@@ -13,7 +12,7 @@ defined( 'ABSPATH' ) || exit;
13
  /**
14
  * Redirect to a random blog in the multisite network.
15
  *
16
- * @since BuddyPress (1.0.0)
17
  */
18
  function bp_blogs_redirect_to_random_blog() {
19
 
1
  <?php
 
2
  /**
3
  * BuddyPress Blogs Actions.
4
  *
12
  /**
13
  * Redirect to a random blog in the multisite network.
14
  *
15
+ * @since 1.0.0
16
  */
17
  function bp_blogs_redirect_to_random_blog() {
18
 
bp-blogs/bp-blogs-activity.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Blogs Activity.
5
  *
@@ -7,13 +6,13 @@
7
  * @subpackage BlogsActivity
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Register activity actions for the blogs component.
15
  *
16
- * @since BuddyPress (1.0.0)
17
  *
18
  * @return bool|null Returns false if activity component is not active.
19
  */
@@ -53,7 +52,7 @@ function bp_blogs_register_activity_actions() {
53
  /**
54
  * Fires after the registry of the default blog component activity actions.
55
  *
56
- * @since BuddyPress (1.1.0)
57
  */
58
  do_action( 'bp_blogs_register_activity_actions' );
59
  }
@@ -62,10 +61,12 @@ add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions'
62
  /**
63
  * Format 'new_blog' activity actions.
64
  *
65
- * @since BuddyPress (2.0.0)
 
 
 
66
  *
67
- * @param string $action Static activity action.
68
- * @param obj $activity Activity data object.
69
  */
70
  function bp_blogs_format_activity_action_new_blog( $action, $activity ) {
71
  $blog_url = bp_blogs_get_blogmeta( $activity->item_id, 'url' );
@@ -88,10 +89,10 @@ function bp_blogs_format_activity_action_new_blog( $action, $activity ) {
88
  /**
89
  * Filters the new blog activity action for the new blog.
90
  *
91
- * @since BuddyPress (2.0.0)
92
  *
93
  * @param string $action Constructed activity action.
94
- * @param obj $activity Activity data object.
95
  */
96
  return apply_filters( 'bp_blogs_format_activity_action_new_blog', $action, $activity );
97
  }
@@ -99,10 +100,12 @@ function bp_blogs_format_activity_action_new_blog( $action, $activity ) {
99
  /**
100
  * Format 'new_blog_post' activity actions.
101
  *
102
- * @since BuddyPress (2.0.0)
103
  *
104
- * @param string $action Static activity action.
105
- * @param obj $activity Activity data object.
 
 
106
  */
107
  function bp_blogs_format_activity_action_new_blog_post( $action, $activity ) {
108
  $blog_url = bp_blogs_get_blogmeta( $activity->item_id, 'url' );
@@ -198,10 +201,10 @@ function bp_blogs_format_activity_action_new_blog_post( $action, $activity ) {
198
  /**
199
  * Filters the new blog post action for the new blog.
200
  *
201
- * @since BuddyPress (2.0.0)
202
  *
203
  * @param string $action Constructed activity action.
204
- * @param obj $activity Activity data object.
205
  */
206
  return apply_filters( 'bp_blogs_format_activity_action_new_blog_post', $action, $activity );
207
  }
@@ -209,10 +212,12 @@ function bp_blogs_format_activity_action_new_blog_post( $action, $activity ) {
209
  /**
210
  * Format 'new_blog_comment' activity actions.
211
  *
212
- * @since BuddyPress (2.0.0)
 
 
 
213
  *
214
- * @param string $action Static activity action.
215
- * @param obj $activity Activity data object.
216
  */
217
  function bp_blogs_format_activity_action_new_blog_comment( $action, $activity ) {
218
  $blog_url = bp_blogs_get_blogmeta( $activity->item_id, 'url' );
@@ -273,10 +278,10 @@ function bp_blogs_format_activity_action_new_blog_comment( $action, $activity )
273
  /**
274
  * Filters the new blog comment action for the new blog.
275
  *
276
- * @since BuddyPress (2.0.0)
277
  *
278
  * @param string $action Constructed activity action.
279
- * @param obj $activity Activity data object.
280
  */
281
  return apply_filters( 'bp_blogs_format_activity_action_new_blog_comment', $action, $activity );
282
  }
@@ -286,9 +291,10 @@ function bp_blogs_format_activity_action_new_blog_comment( $action, $activity )
286
  *
287
  * This reduces database overhead during the activity loop.
288
  *
289
- * @since BuddyPress (2.0.0)
290
  *
291
  * @param array $activities Array of activity items.
 
292
  * @return array
293
  */
294
  function bp_blogs_prefetch_activity_object_data( $activities ) {
@@ -317,11 +323,11 @@ add_filter( 'bp_activity_prefetch_object_data', 'bp_blogs_prefetch_activity_obje
317
  /**
318
  * Record blog-related activity to the activity stream.
319
  *
320
- * @since BuddyPress (1.0.0)
321
  *
322
  * @see bp_activity_add() for description of parameters.
323
  *
324
- * @param array $args {
325
  * See {@link bp_activity_add()} for complete description of arguments.
326
  * The arguments listed here have different default values from
327
  * bp_activity_add().
@@ -358,7 +364,7 @@ function bp_blogs_record_activity( $args = '' ) {
358
  /**
359
  * Filters the action associated with activity for activity stream.
360
  *
361
- * @since BuddyPress (1.2.0)
362
  *
363
  * @param string $value Action for the activity stream.
364
  */
@@ -370,7 +376,7 @@ function bp_blogs_record_activity( $args = '' ) {
370
  /**
371
  * Filters the content associated with activity for activity stream.
372
  *
373
- * @since BuddyPress (1.2.0)
374
  *
375
  * @param string $value Generated summary from content for the activity stream.
376
  * @param string $value Content for the activity stream.
@@ -394,11 +400,11 @@ function bp_blogs_record_activity( $args = '' ) {
394
  /**
395
  * Delete a blog-related activity stream item.
396
  *
397
- * @since BuddyPress (1.0.0)
398
  *
399
  * @see bp_activity_delete() for description of parameters.
400
  *
401
- * @param array $args {
402
  * See {@link bp_activity_delete()} for complete description of arguments.
403
  * The arguments listed here have different default values from
404
  * bp_activity_add().
@@ -435,9 +441,10 @@ function bp_blogs_delete_activity( $args = '' ) {
435
  * to blogmeta and checks the values in blogmeta instead. This is to prevent
436
  * multiple {@link switch_to_blog()} calls in the activity stream.
437
  *
438
- * @since BuddyPress (2.0.0)
439
  *
440
  * @param object $activity The BP_Activity_Activity object
 
441
  * @return bool
442
  */
443
  function bp_blogs_comments_open( $activity ) {
@@ -520,11 +527,11 @@ function bp_blogs_comments_open( $activity ) {
520
  *
521
  * For blog post -> activity comment, see {@link bp_blogs_record_comment()}.
522
  *
523
- * @since BuddyPress (2.0.0)
524
  *
525
- * @param int $comment_id The activity ID for the posted activity comment.
526
- * @param array $params Parameters for the activity comment.
527
- * @param object Parameters of the parent activity item (in this case, the blog post).
528
  */
529
  function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_activity ) {
530
  // if parent activity isn't a blog post, stop now!
@@ -597,8 +604,18 @@ function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_
597
  // doesn't change on the frontend until the next page refresh.
598
  $resave_activity = new BP_Activity_Activity( $comment_id );
599
  $resave_activity->primary_link = get_comment_link( $post_comment_id );
 
 
 
 
 
 
 
600
  $resave_activity->save();
601
 
 
 
 
602
  // multisite again!
603
  restore_current_blog();
604
 
@@ -608,7 +625,7 @@ function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_
608
  /**
609
  * Fires after activity comments have been synced and posted as blog comments.
610
  *
611
- * @since BuddyPress (2.0.0)
612
  *
613
  * @param int $comment_id The activity ID for the posted activity comment.
614
  * @param array $args Array of args used for the comment syncing.
@@ -626,11 +643,13 @@ add_action( 'bp_activity_comment_posted', 'bp_blogs_sync_add_from_activity_comme
626
  * of the 'bp_activity_delete_comment' action because we need to fetch the
627
  * activity comment children before they are deleted.
628
  *
629
- * @since BuddyPress (2.0.0)
630
  *
631
  * @param bool $retval
632
- * @param int $parent_activity_id The parent activity ID for the activity comment.
633
- * @param int $activity_id The activity ID for the pending deleted activity comment.
 
 
634
  */
635
  function bp_blogs_sync_delete_from_activity_comment( $retval, $parent_activity_id, $activity_id ) {
636
  // check if parent activity is a blog post
@@ -672,7 +691,7 @@ add_filter( 'bp_activity_delete_comment_pre', 'bp_blogs_sync_delete_from_activit
672
  /**
673
  * Updates the blog comment when the associated activity comment is edited.
674
  *
675
- * @since BuddyPress (2.0.0)
676
  *
677
  * @param BP_Activity_Activity $activity The activity object.
678
  */
@@ -729,11 +748,11 @@ add_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comm
729
  * Since these activity entries are deleted, we need to remove the deleted
730
  * activity comment IDs from each comment's meta when a post is trashed.
731
  *
732
- * @since BuddyPress (2.0.0)
733
  *
734
- * @param int $post_id The post ID
735
  * @param array $comments Array of comment statuses. The key is comment ID, the
736
- * value is the $comment->comment_approved value.
737
  */
738
  function bp_blogs_remove_activity_meta_for_trashed_comments( $post_id = 0, $comments = array() ) {
739
  if ( ! empty( $comments ) ) {
@@ -760,57 +779,69 @@ add_action( 'trashed_post_comments', 'bp_blogs_remove_activity_meta_for_trashed_
760
  * multiple query condition clauses, connected by an OR, in the bp_has_activities()
761
  * API.
762
  *
763
- * @since BuddyPress (2.1.0)
764
  *
765
  * @param array $args Arguments passed from bp_parse_args() in bp_has_activities().
 
766
  * @return array $args
767
  */
768
  function bp_blogs_new_blog_comment_query_backpat( $args ) {
 
 
 
769
  // Bail if this is not a 'new_blog_comment' query
770
  if ( 'new_blog_comment' !== $args['action'] ) {
771
  return $args;
772
  }
773
 
774
- // display_comments=stream is required to show new-style
775
- // 'activity_comment' items inline
776
- $args['display_comments'] = 'stream';
777
 
778
- // For the remaining clauses, we filter the SQL query directly
779
- add_filter( 'bp_activity_paged_activities_sql', '_bp_blogs_new_blog_comment_query_backpat_filter' );
780
- add_filter( 'bp_activity_total_activities_sql', '_bp_blogs_new_blog_comment_query_backpat_filter' );
781
 
782
- // Return the original arguments
783
- return $args;
784
- }
785
- add_filter( 'bp_after_has_activities_parse_args', 'bp_blogs_new_blog_comment_query_backpat' );
 
 
 
 
 
 
 
 
 
 
 
786
 
787
- /**
788
- * Filter activity SQL to include new- and old-style 'new_blog_comment' activity items.
789
- *
790
- * @since BuddyPress (2.1.0)
791
- *
792
- * @access private
793
- * @see bp_blogs_new_blog_comment_query_backpat()
794
- *
795
- * @param string $query SQL query as assembled in BP_Activity_Activity::get().
796
- * @return string $query Modified SQL query.
797
- */
798
- function _bp_blogs_new_blog_comment_query_backpat_filter( $query ) {
799
- $bp = buddypress();
800
 
801
- // The query passed to the filter is for old-style 'new_blog_comment'
802
- // items. We include new-style 'activity_comment' items by running a
803
- // subquery inside of a large OR clause.
804
- $activity_comment_subquery = "SELECT a.id FROM {$bp->activity->table_name} a INNER JOIN {$bp->activity->table_name_meta} am ON (a.id = am.activity_id) WHERE am.meta_key = 'bp_blogs_post_comment_id' AND a.type = 'activity_comment'";
805
 
806
- // WHERE ( [original WHERE clauses] OR a.id IN (activity_comment subquery) )
807
- $query = preg_replace( '|WHERE (.*?) ORDER|', 'WHERE ( ( $1 ) OR ( a.id IN ( ' . $activity_comment_subquery . ' ) ) ) ORDER', $query );
808
 
809
- // Don't run this on future queries
810
- remove_filter( current_filter(), '_bp_blogs_new_blog_comment_query_backpat_filter' );
811
 
812
- return $query;
 
813
  }
 
814
 
815
  /**
816
  * Utility function to set up some variables for use in the activity loop.
@@ -820,12 +851,12 @@ function _bp_blogs_new_blog_comment_query_backpat_filter( $query ) {
820
  *
821
  * This is to prevent having to requery these items later on.
822
  *
823
- * @since BuddyPress (2.0.0)
824
  *
825
  * @see bp_blogs_disable_activity_commenting()
826
  * @see bp_blogs_setup_comment_loop_globals_on_ajax()
827
  *
828
- * @param object $activity The BP_Activity_Activity object
829
  */
830
  function bp_blogs_setup_activity_loop_globals( $activity ) {
831
  if ( ! is_object( $activity ) ) {
@@ -872,7 +903,7 @@ function bp_blogs_setup_activity_loop_globals( $activity ) {
872
  /**
873
  * Set up some globals used in the activity comment loop when AJAX is used.
874
  *
875
- * @since BuddyPress (2.0.0)
876
  *
877
  * @see bp_blogs_setup_activity_loop_globals()
878
  */
@@ -904,9 +935,10 @@ add_action( 'bp_before_activity_comment', 'bp_blogs_setup_comment_loop_globals_o
904
  * based on a certain age
905
  * - the activity entry is a 'new_blog_comment' type
906
  *
907
- * @since BuddyPress (2.0.0)
908
  *
909
  * @param bool $retval Is activity commenting enabled for this activity entry?
 
910
  * @return bool
911
  */
912
  function bp_blogs_disable_activity_commenting( $retval ) {
@@ -955,10 +987,11 @@ add_filter( 'bp_activity_can_comment', 'bp_blogs_disable_activity_commenting' );
955
  * This check uses a locally-cached value set in {@link bp_blogs_disable_activity_commenting()}
956
  * via {@link bp_blogs_setup_activity_loop_globals()}.
957
  *
958
- * @since BuddyPress (2.0.0)
 
 
 
959
  *
960
- * @param bool $retval Are replies allowed for this activity reply?
961
- * @param object $comment The activity comment object
962
  * @return bool
963
  */
964
  function bp_blogs_can_comment_reply( $retval, $comment ) {
@@ -993,9 +1026,10 @@ add_filter( 'bp_activity_can_comment_reply', 'bp_blogs_can_comment_reply', 10, 2
993
  * This is only done if activity commenting is allowed and whether the parent
994
  * activity item is a 'new_blog_post' entry.
995
  *
996
- * @since BuddyPress (2.0.0)
 
 
997
  *
998
- * @param string $retval The activity comment permalink
999
  * @return string
1000
  */
1001
  function bp_blogs_activity_comment_permalink( $retval = '' ) {
@@ -1020,10 +1054,11 @@ add_filter( 'bp_get_activity_comment_permalink', 'bp_blogs_activity_comment_perm
1020
  *
1021
  * This is only done if the activity comment is associated with a blog comment.
1022
  *
1023
- * @since BuddyPress (2.0.1)
1024
  *
1025
- * @param string $retval The activity permalink
1026
  * @param BP_Activity_Activity $activity
 
1027
  * @return string
1028
  */
1029
  function bp_blogs_activity_comment_single_permalink( $retval, $activity ) {
@@ -1046,10 +1081,11 @@ add_filter( 'bp_activity_get_permalink', 'bp_blogs_activity_comment_single_perma
1046
  *
1047
  * This is only done if the activity comment is associated with a blog comment.
1048
  *
1049
- * @since BuddyPress (2.0.1)
1050
  *
1051
- * @param string $retval The activity action
1052
  * @param BP_Activity_Activity $activity
 
1053
  * @return string
1054
  */
1055
  function bp_blogs_activity_comment_single_action( $retval, $activity ) {
1
  <?php
 
2
  /**
3
  * BuddyPress Blogs Activity.
4
  *
6
  * @subpackage BlogsActivity
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Register activity actions for the blogs component.
14
  *
15
+ * @since 1.0.0
16
  *
17
  * @return bool|null Returns false if activity component is not active.
18
  */
52
  /**
53
  * Fires after the registry of the default blog component activity actions.
54
  *
55
+ * @since 1.1.0
56
  */
57
  do_action( 'bp_blogs_register_activity_actions' );
58
  }
61
  /**
62
  * Format 'new_blog' activity actions.
63
  *
64
+ * @since 2.0.0
65
+ *
66
+ * @param string $action Static activity action.
67
+ * @param object $activity Activity data object.
68
  *
69
+ * @return string
 
70
  */
71
  function bp_blogs_format_activity_action_new_blog( $action, $activity ) {
72
  $blog_url = bp_blogs_get_blogmeta( $activity->item_id, 'url' );
89
  /**
90
  * Filters the new blog activity action for the new blog.
91
  *
92
+ * @since 2.0.0
93
  *
94
  * @param string $action Constructed activity action.
95
+ * @param object $activity Activity data object.
96
  */
97
  return apply_filters( 'bp_blogs_format_activity_action_new_blog', $action, $activity );
98
  }
100
  /**
101
  * Format 'new_blog_post' activity actions.
102
  *
103
+ * @since 2.0.0
104
  *
105
+ * @param string $action Static activity action.
106
+ * @param object $activity Activity data object.
107
+ *
108
+ * @return string Constructed activity action.
109
  */
110
  function bp_blogs_format_activity_action_new_blog_post( $action, $activity ) {
111
  $blog_url = bp_blogs_get_blogmeta( $activity->item_id, 'url' );
201
  /**
202
  * Filters the new blog post action for the new blog.
203
  *
204
+ * @since 2.0.0
205
  *
206
  * @param string $action Constructed activity action.
207
+ * @param object $activity Activity data object.
208
  */
209
  return apply_filters( 'bp_blogs_format_activity_action_new_blog_post', $action, $activity );
210
  }
212
  /**
213
  * Format 'new_blog_comment' activity actions.
214
  *
215
+ * @since 2.0.0
216
+ *
217
+ * @param string $action Static activity action.
218
+ * @param object $activity Activity data object.
219
  *
220
+ * @return string Constructed activity action.
 
221
  */
222
  function bp_blogs_format_activity_action_new_blog_comment( $action, $activity ) {
223
  $blog_url = bp_blogs_get_blogmeta( $activity->item_id, 'url' );
278
  /**
279
  * Filters the new blog comment action for the new blog.
280
  *
281
+ * @since 2.0.0
282
  *
283
  * @param string $action Constructed activity action.
284
+ * @param object $activity Activity data object.
285
  */
286
  return apply_filters( 'bp_blogs_format_activity_action_new_blog_comment', $action, $activity );
287
  }
291
  *
292
  * This reduces database overhead during the activity loop.
293
  *
294
+ * @since 2.0.0
295
  *
296
  * @param array $activities Array of activity items.
297
+ *
298
  * @return array
299
  */
300
  function bp_blogs_prefetch_activity_object_data( $activities ) {
323
  /**
324
  * Record blog-related activity to the activity stream.
325
  *
326
+ * @since 1.0.0
327
  *
328
  * @see bp_activity_add() for description of parameters.
329
  *
330
+ * @param array|string $args {
331
  * See {@link bp_activity_add()} for complete description of arguments.
332
  * The arguments listed here have different default values from
333
  * bp_activity_add().
364
  /**
365
  * Filters the action associated with activity for activity stream.
366
  *
367
+ * @since 1.2.0
368
  *
369
  * @param string $value Action for the activity stream.
370
  */
376
  /**
377
  * Filters the content associated with activity for activity stream.
378
  *
379
+ * @since 1.2.0
380
  *
381
  * @param string $value Generated summary from content for the activity stream.
382
  * @param string $value Content for the activity stream.
400
  /**
401
  * Delete a blog-related activity stream item.
402
  *
403
+ * @since 1.0.0
404
  *
405
  * @see bp_activity_delete() for description of parameters.
406
  *
407
+ * @param array|string $args {
408
  * See {@link bp_activity_delete()} for complete description of arguments.
409
  * The arguments listed here have different default values from
410
  * bp_activity_add().
441
  * to blogmeta and checks the values in blogmeta instead. This is to prevent
442
  * multiple {@link switch_to_blog()} calls in the activity stream.
443
  *
444
+ * @since 2.0.0
445
  *
446
  * @param object $activity The BP_Activity_Activity object
447
+ *
448
  * @return bool
449
  */
450
  function bp_blogs_comments_open( $activity ) {
527
  *
528
  * For blog post -> activity comment, see {@link bp_blogs_record_comment()}.
529
  *
530
+ * @since 2.0.0
531
  *
532
+ * @param int $comment_id The activity ID for the posted activity comment.
533
+ * @param array $params Parameters for the activity comment.
534
+ * @param object $parent_activity Parameters of the parent activity item (in this case, the blog post).
535
  */
536
  function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_activity ) {
537
  // if parent activity isn't a blog post, stop now!
604
  // doesn't change on the frontend until the next page refresh.
605
  $resave_activity = new BP_Activity_Activity( $comment_id );
606
  $resave_activity->primary_link = get_comment_link( $post_comment_id );
607
+
608
+ /**
609
+ * Now that the activity id exists and the post comment was created, we don't need to update
610
+ * the content of the comment as there are no chances it has evolved.
611
+ */
612
+ remove_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 );
613
+
614
  $resave_activity->save();
615
 
616
+ // add the edit activity comment hook back
617
+ add_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 );
618
+
619
  // multisite again!
620
  restore_current_blog();
621
 
625
  /**
626
  * Fires after activity comments have been synced and posted as blog comments.
627
  *
628
+ * @since 2.0.0
629
  *
630
  * @param int $comment_id The activity ID for the posted activity comment.
631
  * @param array $args Array of args used for the comment syncing.
643
  * of the 'bp_activity_delete_comment' action because we need to fetch the
644
  * activity comment children before they are deleted.
645
  *
646
+ * @since 2.0.0
647
  *
648
  * @param bool $retval
649
+ * @param int $parent_activity_id The parent activity ID for the activity comment.
650
+ * @param int $activity_id The activity ID for the pending deleted activity comment.
651
+ *
652
+ * @return bool
653
  */
654
  function bp_blogs_sync_delete_from_activity_comment( $retval, $parent_activity_id, $activity_id ) {
655
  // check if parent activity is a blog post
691
  /**
692
  * Updates the blog comment when the associated activity comment is edited.
693
  *
694
+ * @since 2.0.0
695
  *
696
  * @param BP_Activity_Activity $activity The activity object.
697
  */
748
  * Since these activity entries are deleted, we need to remove the deleted
749
  * activity comment IDs from each comment's meta when a post is trashed.
750
  *
751
+ * @since 2.0.0
752
  *
753
+ * @param int $post_id The post ID.
754
  * @param array $comments Array of comment statuses. The key is comment ID, the
755
+ * value is the $comment->comment_approved value.
756
  */
757
  function bp_blogs_remove_activity_meta_for_trashed_comments( $post_id = 0, $comments = array() ) {
758
  if ( ! empty( $comments ) ) {
779
  * multiple query condition clauses, connected by an OR, in the bp_has_activities()
780
  * API.
781
  *
782
+ * @since 2.1.0
783
  *
784
  * @param array $args Arguments passed from bp_parse_args() in bp_has_activities().
785
+ *
786
  * @return array $args
787
  */
788
  function bp_blogs_new_blog_comment_query_backpat( $args ) {
789
+ global $wpdb;
790
+ $bp = buddypress();
791
+
792
  // Bail if this is not a 'new_blog_comment' query
793
  if ( 'new_blog_comment' !== $args['action'] ) {
794
  return $args;
795
  }
796
 
797
+ // Comment synced ?
798
+ $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT activity_id FROM {$bp->activity->table_name_meta} WHERE meta_key = %s", 'bp_blogs_post_comment_id' ) );
 
799
 
800
+ if ( empty( $activity_ids ) ) {
801
+ return $args;
802
+ }
803
 
804
+ // Init the filter query
805
+ $filter_query = array();
806
+
807
+ if ( 'null' === $args['scope'] ) {
808
+ $args['scope'] = '';
809
+ } elseif ( 'just-me' === $args['scope'] ) {
810
+ $filter_query = array(
811
+ 'relation' => 'AND',
812
+ array(
813
+ 'column' => 'user_id',
814
+ 'value' => bp_displayed_user_id(),
815
+ ),
816
+ );
817
+ $args['scope'] = '';
818
+ }
819
 
820
+ $filter_query[] = array(
821
+ 'relation' => 'OR',
822
+ array(
823
+ 'column' => 'type',
824
+ 'value' => $args['action'],
825
+ ),
826
+ array(
827
+ 'column' => 'id',
828
+ 'value' => $activity_ids,
829
+ 'compare' => 'IN'
830
+ ),
831
+ );
 
832
 
833
+ $args['filter_query'] = $filter_query;
 
 
 
834
 
835
+ // Make sure to have comment in stream mode && avoid duplicate content
836
+ $args['display_comments'] = 'stream';
837
 
838
+ // Finally reset the action
839
+ $args['action'] = '';
840
 
841
+ // Return the original arguments
842
+ return $args;
843
  }
844
+ add_filter( 'bp_after_has_activities_parse_args', 'bp_blogs_new_blog_comment_query_backpat' );
845
 
846
  /**
847
  * Utility function to set up some variables for use in the activity loop.
851
  *
852
  * This is to prevent having to requery these items later on.
853
  *
854
+ * @since 2.0.0
855
  *
856
  * @see bp_blogs_disable_activity_commenting()
857
  * @see bp_blogs_setup_comment_loop_globals_on_ajax()
858
  *
859
+ * @param object $activity The BP_Activity_Activity object.
860
  */
861
  function bp_blogs_setup_activity_loop_globals( $activity ) {
862
  if ( ! is_object( $activity ) ) {
903
  /**
904
  * Set up some globals used in the activity comment loop when AJAX is used.
905
  *
906
+ * @since 2.0.0
907
  *
908
  * @see bp_blogs_setup_activity_loop_globals()
909
  */
935
  * based on a certain age
936
  * - the activity entry is a 'new_blog_comment' type
937
  *
938
+ * @since 2.0.0
939
  *
940
  * @param bool $retval Is activity commenting enabled for this activity entry?
941
+ *
942
  * @return bool
943
  */
944
  function bp_blogs_disable_activity_commenting( $retval ) {
987
  * This check uses a locally-cached value set in {@link bp_blogs_disable_activity_commenting()}
988
  * via {@link bp_blogs_setup_activity_loop_globals()}.
989
  *
990
+ * @since 2.0.0
991
+ *
992
+ * @param bool $retval Are replies allowed for this activity reply?
993
+ * @param object|array $comment The activity comment object.
994
  *
 
 
995
  * @return bool
996
  */
997
  function bp_blogs_can_comment_reply( $retval, $comment ) {
1026
  * This is only done if activity commenting is allowed and whether the parent
1027
  * activity item is a 'new_blog_post' entry.
1028
  *
1029
+ * @since 2.0.0
1030
+ *
1031
+ * @param string $retval The activity comment permalink.
1032
  *
 
1033
  * @return string
1034
  */
1035
  function bp_blogs_activity_comment_permalink( $retval = '' ) {
1054
  *
1055
  * This is only done if the activity comment is associated with a blog comment.
1056
  *
1057
+ * @since 2.0.1
1058
  *
1059
+ * @param string $retval The activity permalink.
1060
  * @param BP_Activity_Activity $activity
1061
+ *
1062
  * @return string
1063
  */
1064
  function bp_blogs_activity_comment_single_permalink( $retval, $activity ) {
1081
  *
1082
  * This is only done if the activity comment is associated with a blog comment.
1083
  *
1084
+ * @since 2.0.1
1085
  *
1086
+ * @param string $retval The activity action.
1087
  * @param BP_Activity_Activity $activity
1088
+ *
1089
  * @return string
1090
  */
1091
  function bp_blogs_activity_comment_single_action( $retval, $activity ) {
bp-blogs/bp-blogs-cache.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Blogs Caching.
5
  *
@@ -10,7 +9,7 @@
10
  * @subpackage BlogsCache
11
  */
12
 
13
- // Exit if accessed directly
14
  defined( 'ABSPATH' ) || exit;
15
 
16
  /**
@@ -20,8 +19,8 @@ defined( 'ABSPATH' ) || exit;
20
  * in $blog_ids and adds it to the WP cache. This improves efficiency when
21
  * using querying blogmeta inline.
22
  *
23
- * @param int|str|array $blog_ids Accepts a single blog ID, or a comma-
24
- * separated list or array of blog IDs.
25
  */
26
  function bp_blogs_update_meta_cache( $blog_ids = false ) {
27
  $cache_args = array(
@@ -37,7 +36,7 @@ function bp_blogs_update_meta_cache( $blog_ids = false ) {
37
  /**
38
  * Clear the blog object cache.
39
  *
40
- * @since BuddyPress (1.0.0)
41
  *
42
  * @param int $blog_id ID of the current blog.
43
  * @param int $user_id ID of the user whose blog cache should be cleared.
@@ -51,12 +50,12 @@ function bp_blogs_clear_blog_object_cache( $blog_id = 0, $user_id = 0 ) {
51
  wp_cache_delete( 'bp_total_blogs', 'bp' );
52
  }
53
 
54
- // List actions to clear object caches on
55
  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
56
  add_action( 'wpmu_new_blog', 'bp_blogs_clear_blog_object_cache', 10, 2 );
57
  add_action( 'bp_blogs_remove_blog', 'bp_blogs_clear_blog_object_cache' );
58
 
59
- // List actions to clear super cached pages on, if super cache is installed
60
  add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
61
  add_action( 'bp_blogs_remove_comment', 'bp_core_clear_cache' );
62
  add_action( 'bp_blogs_remove_post', 'bp_core_clear_cache' );
1
  <?php
 
2
  /**
3
  * BuddyPress Blogs Caching.
4
  *
9
  * @subpackage BlogsCache
10
  */
11
 
12
+ // Exit if accessed directly.
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  /**
19
  * in $blog_ids and adds it to the WP cache. This improves efficiency when
20
  * using querying blogmeta inline.
21
  *
22
+ * @param int|string|array|bool $blog_ids Accepts a single blog ID, or a comma-
23
+ * separated list or array of blog IDs.
24
  */
25
  function bp_blogs_update_meta_cache( $blog_ids = false ) {
26
  $cache_args = array(
36
  /**
37
  * Clear the blog object cache.
38
  *
39
+ * @since 1.0.0
40
  *
41
  * @param int $blog_id ID of the current blog.
42
  * @param int $user_id ID of the user whose blog cache should be cleared.
50
  wp_cache_delete( 'bp_total_blogs', 'bp' );
51
  }
52
 
53
+ // List actions to clear object caches on.
54
  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
55
  add_action( 'wpmu_new_blog', 'bp_blogs_clear_blog_object_cache', 10, 2 );
56
  add_action( 'bp_blogs_remove_blog', 'bp_blogs_clear_blog_object_cache' );
57
 
58
+ // List actions to clear super cached pages on, if super cache is installed.
59
  add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
60
  add_action( 'bp_blogs_remove_comment', 'bp_core_clear_cache' );
61
  add_action( 'bp_blogs_remove_post', 'bp_core_clear_cache' );
bp-blogs/bp-blogs-classes.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Blogs Classes.
5
  *
@@ -7,7 +6,7 @@
7
  * @subpackage BlogsClasses
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  require dirname( __FILE__ ) . '/classes/class-bp-blogs-blog.php';
1
  <?php
 
2
  /**
3
  * BuddyPress Blogs Classes.
4
  *
6
  * @subpackage BlogsClasses
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  require dirname( __FILE__ ) . '/classes/class-bp-blogs-blog.php';
bp-blogs/bp-blogs-filters.php CHANGED
@@ -1,11 +1,10 @@
1
  <?php
2
-
3
  /**
4
  * Filters related to the Blogs component.
5
  *
6
  * @package BuddyPress
7
- * @subpackage Blogs
8
- * @since BuddyPress (1.6.0)
9
  */
10
 
11
  /** Display Filters **********************************************************/
@@ -24,12 +23,13 @@ add_filter( 'bp_blog_latest_post_content', 'prepend_attachment' );
24
  /**
25
  * Ensure that the 'Create a new site' link at wp-admin/my-sites.php points to the BP blog signup.
26
  *
27
- * @since BuddyPress (1.6.0)
28
  *
29
  * @uses apply_filters() Filter 'bp_blogs_creation_location' to alter the
30
  * returned value.
31
  *
32
  * @param string $url The original URL (points to wp-signup.php by default).
 
33
  * @return string The new URL.
34
  */
35
  function bp_blogs_creation_location( $url ) {
@@ -37,7 +37,7 @@ function bp_blogs_creation_location( $url ) {
37
  /**
38
  * Filters the 'Create a new site' link URL.
39
  *
40
- * @since BuddyPress (1.6.0)
41
  *
42
  * @param string $value URL for the 'Create a new site' signup page.
43
  */
@@ -48,11 +48,12 @@ add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
48
  /**
49
  * Only select comments by ID instead of all fields when using get_comments().
50
  *
51
- * @since BuddyPress (2.1.0)
52
  *
53
  * @see bp_blogs_update_post_activity_meta()
54
  *
55
- * @param array Current SQL clauses in array format
 
56
  * @return array
57
  */
58
  function bp_blogs_comments_clauses_select_by_id( $retval ) {
@@ -66,12 +67,13 @@ function bp_blogs_comments_clauses_select_by_id( $retval ) {
66
  *
67
  * Abstracted from the deprecated `bp_blogs_record_post()`.
68
  *
69
- * @since BuddyPress (2.2.0)
70
  *
71
  * @param bool $return Whether the post should be published.
72
  * @param int $blog_id ID of the blog.
73
  * @param int $post_id ID of the post.
74
  * @param int $user_id ID of the post author.
 
75
  * @return bool True to authorize the post to be published, otherwise false.
76
  */
77
  function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0, $user_id = 0 ) {
@@ -98,7 +100,7 @@ function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0,
98
  /**
99
  * Filters whether or not BuddyPress should block sitewide tags activity.
100
  *
101
- * @since BuddyPress (2.2.0)
102
  *
103
  * @param bool $value Current status of the sitewide tags activity.
104
  */
@@ -109,7 +111,7 @@ function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0,
109
  /**
110
  * Filters whether or not the current blog is public.
111
  *
112
- * @since BuddyPress (2.2.0)
113
  *
114
  * @param int $value Value from the blog_public option for the current blog.
115
  */
1
  <?php
 
2
  /**
3
  * Filters related to the Blogs component.
4
  *
5
  * @package BuddyPress
6
+ * @subpackage BlogFilters
7
+ * @since 1.6.0
8
  */
9
 
10
  /** Display Filters **********************************************************/
23
  /**
24
  * Ensure that the 'Create a new site' link at wp-admin/my-sites.php points to the BP blog signup.
25
  *
26
+ * @since 1.6.0
27
  *
28
  * @uses apply_filters() Filter 'bp_blogs_creation_location' to alter the
29
  * returned value.
30
  *
31
  * @param string $url The original URL (points to wp-signup.php by default).
32
+ *
33
  * @return string The new URL.
34
  */
35
  function bp_blogs_creation_location( $url ) {
37
  /**
38
  * Filters the 'Create a new site' link URL.
39
  *
40
+ * @since 1.6.0
41
  *
42
  * @param string $value URL for the 'Create a new site' signup page.
43
  */
48
  /**
49
  * Only select comments by ID instead of all fields when using get_comments().
50
  *
51
+ * @since 2.1.0
52
  *
53
  * @see bp_blogs_update_post_activity_meta()
54
  *
55
+ * @param array $retval Current SQL clauses in array format.
56
+ *
57
  * @return array
58
  */
59
  function bp_blogs_comments_clauses_select_by_id( $retval ) {
67
  *
68
  * Abstracted from the deprecated `bp_blogs_record_post()`.
69
  *
70
+ * @since 2.2.0
71
  *
72
  * @param bool $return Whether the post should be published.
73
  * @param int $blog_id ID of the blog.
74
  * @param int $post_id ID of the post.
75
  * @param int $user_id ID of the post author.
76
+ *
77
  * @return bool True to authorize the post to be published, otherwise false.
78
  */
79
  function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0, $user_id = 0 ) {
100
  /**
101
  * Filters whether or not BuddyPress should block sitewide tags activity.
102
  *
103
+ * @since 2.2.0
104
  *
105
  * @param bool $value Current status of the sitewide tags activity.
106
  */
111
  /**
112
  * Filters whether or not the current blog is public.
113
  *
114
+ * @since 2.2.0
115
  *
116
  * @param int $value Value from the blog_public option for the current blog.
117
  */
bp-blogs/bp-blogs-functions.php CHANGED
@@ -12,7 +12,7 @@ defined( 'ABSPATH' ) || exit;
12
  /**
13
  * Check whether the $bp global lists an activity directory page.
14
  *
15
- * @since BuddyPress (1.5.0)
16
  *
17
  * @return bool True if set, false if empty.
18
  */
@@ -23,20 +23,20 @@ function bp_blogs_has_directory() {
23
  }
24
 
25
  /**
26
- * Retrieve a set of blogs
27
  *
28
  * @see BP_Blogs_Blog::get() for a description of arguments and return value.
29
  *
30
- * @param array $args {
31
  * Arguments are listed here with their default values. For more
32
  * information about the arguments, see {@link BP_Blogs_Blog::get()}.
33
- * @type string $type Default: 'active'.
34
- * @type int|bool $user_id Default: false.
35
- * @type array $include_blog_ids Default: false.
36
- * @type string|bool $search_terms Default: false.
37
- * @type int $per_page Default: 20.
38
- * @type int $page Default: 1.
39
- * @type bool $update_meta_cache Whether to pre-fetch blogmeta. Default: true.
40
  * }
41
  * @return array See {@link BP_Blogs_Blog::get()}.
42
  */
@@ -71,11 +71,13 @@ function bp_blogs_get_blogs( $args = '' ) {
71
  /**
72
  * Populate the BP blogs table with existing blogs.
73
  *
74
- * @since BuddyPress (1.0.0)
75
  *
76
- * @global object $wpdb WordPress database object
77
  * @uses get_users()
78
  * @uses bp_blogs_record_blog()
 
 
79
  */
80
  function bp_blogs_record_existing_blogs() {
81
  global $wpdb;
@@ -144,6 +146,13 @@ function bp_blogs_record_existing_blogs() {
144
  }
145
  }
146
 
 
 
 
 
 
 
 
147
  // No errors
148
  return true;
149
  }
@@ -154,12 +163,13 @@ function bp_blogs_record_existing_blogs() {
154
  * If $user_id is provided, you can restrict site from being recordable
155
  * only to particular users.
156
  *
157
- * @since BuddyPress (1.7.0)
158
  *
159
  * @uses apply_filters()
160
  *
161
  * @param int $blog_id ID of the blog being checked.
162
  * @param int $user_id Optional. ID of the user for whom access is being checked.
 
163
  * @return bool True if blog is recordable, otherwise false.
164
  */
165
  function bp_blogs_is_blog_recordable( $blog_id, $user_id = 0 ) {
@@ -185,13 +195,14 @@ function bp_blogs_is_blog_recordable( $blog_id, $user_id = 0 ) {
185
  * If $user_id is provided, the developer can restrict site from
186
  * being trackable only to particular users.
187
  *
188
- * @since BuddyPress (1.7.0)
189
  *
190
  * @uses bp_blogs_is_blog_recordable
191
  * @uses apply_filters()
192
  *
193
  * @param int $blog_id ID of the blog being checked.
194
  * @param int $user_id Optional. ID of the user for whom access is being checked.
 
195
  * @return bool True if blog is trackable, otherwise false.
196
  */
197
  function bp_blogs_is_blog_trackable( $blog_id, $user_id = 0 ) {
@@ -214,14 +225,15 @@ function bp_blogs_is_blog_trackable( $blog_id, $user_id = 0 ) {
214
  /**
215
  * Make BuddyPress aware of a new site so that it can track its activity.
216
  *
217
- * @since BuddyPress (1.0.0)
218
  *
219
  * @uses BP_Blogs_Blog
220
  *
221
- * @param int $blog_id ID of the blog being recorded.
222
- * @param int $user_id ID of the user for whom the blog is being recorded.
223
  * @param bool $no_activity Optional. Whether to skip recording an activity
224
- * item about this blog creation. Default: false.
 
225
  * @return bool|null Returns false on failure.
226
  */
227
  function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
@@ -284,7 +296,7 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
284
  /**
285
  * Fires after BuddyPress has been made aware of a new site for activity tracking.
286
  *
287
- * @since BuddyPress (1.0.0)
288
  *
289
  * @param BP_Blogs_Blog $recorded_blog Current blog being recorded. Passed by reference.
290
  * @param bool $is_private Whether or not the current blog being recorded is private.
@@ -300,7 +312,7 @@ add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
300
  * @global object $wpdb DB Layer.
301
  *
302
  * @param string $oldvalue Value before save. Passed by do_action() but
303
- * unused here.
304
  * @param string $newvalue Value to change meta to.
305
  */
306
  function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
@@ -311,12 +323,12 @@ function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
311
  add_action( 'update_option_blogname', 'bp_blogs_update_option_blogname', 10, 2 );
312
 
313
  /**
314
- * Update blog description in BuddyPress blogmeta table
315
  *
316
  * @global object $wpdb DB Layer.
317
  *
318
  * @param string $oldvalue Value before save. Passed by do_action() but
319
- * unused here.
320
  * @param string $newvalue Value to change meta to.
321
  */
322
  function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) {
@@ -329,12 +341,12 @@ add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescrip
329
  /**
330
  * Update "Close comments for old posts" option in BuddyPress blogmeta table.
331
  *
332
- * @since BuddyPress (2.0.0)
333
  *
334
  * @global object $wpdb DB Layer.
335
  *
336
  * @param string $oldvalue Value before save. Passed by do_action() but
337
- * unused here.
338
  * @param string $newvalue Value to change meta to.
339
  */
340
  function bp_blogs_update_option_close_comments_for_old_posts( $oldvalue, $newvalue ) {
@@ -347,12 +359,12 @@ add_action( 'update_option_close_comments_for_old_posts', 'bp_blogs_update_optio
347
  /**
348
  * Update "Close comments after days old" option in BuddyPress blogmeta table.
349
  *
350
- * @since BuddyPress (2.0.0)
351
  *
352
  * @global object $wpdb DB Layer.
353
  *
354
  * @param string $oldvalue Value before save. Passed by do_action() but
355
- * unused here.
356
  * @param string $newvalue Value to change meta to.
357
  */
358
  function bp_blogs_update_option_close_comments_days_old( $oldvalue, $newvalue ) {
@@ -365,12 +377,12 @@ add_action( 'update_option_close_comments_days_old', 'bp_blogs_update_option_clo
365
  /**
366
  * When toggling threaded comments, update thread depth in blogmeta table.
367
  *
368
- * @since BuddyPress (2.0.0)
369
  *
370
  * @global object $wpdb DB Layer.
371
  *
372
  * @param string $oldvalue Value before save. Passed by do_action() but
373
- * unused here.
374
  * @param string $newvalue Value to change meta to.
375
  */
376
  function bp_blogs_update_option_thread_comments( $oldvalue, $newvalue ) {
@@ -389,12 +401,12 @@ add_action( 'update_option_thread_comments', 'bp_blogs_update_option_thread_comm
389
  /**
390
  * When updating comment depth, update thread depth in blogmeta table.
391
  *
392
- * @since BuddyPress (2.0.0)
393
  *
394
  * @global object $wpdb DB Layer.
395
  *
396
  * @param string $oldvalue Value before save. Passed by do_action() but
397
- * unused here.
398
  * @param string $newvalue Value to change meta to.
399
  */
400
  function bp_blogs_update_option_thread_comments_depth( $oldvalue, $newvalue ) {
@@ -414,9 +426,9 @@ add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_threa
414
  * Hooked to 'refresh_blog_details', which is notably used when editing a site
415
  * under "Network Admin > Sites".
416
  *
417
- * @since BuddyPress (2.3.0)
418
  *
419
- * @param int $site_id The site ID
420
  */
421
  function bp_blogs_delete_url_blogmeta( $site_id = 0 ) {
422
  bp_blogs_delete_blogmeta( (int) $site_id, 'url' );
@@ -426,10 +438,11 @@ add_action( 'refresh_blog_details', 'bp_blogs_delete_url_blogmeta' );
426
  /**
427
  * Record activity metadata about a published blog post.
428
  *
429
- * @since BuddyPress (2.2.0)
430
  *
431
- * @param int $activity_id ID of the activity item.
432
- * @param WP_Post $post Post object.
 
433
  */
434
  function bp_blogs_publish_post_activity_meta( $activity_id, $post, $args ) {
435
  if ( empty( $activity_id ) || 'post' != $post->post_type ) {
@@ -452,7 +465,7 @@ function bp_blogs_publish_post_activity_meta( $activity_id, $post, $args ) {
452
  /**
453
  * Fires after BuddyPress has recorded metadata about a published blog post.
454
  *
455
- * @since BuddyPress (1.0.0)
456
  *
457
  * @param int $ID ID of the blog post being recorded.
458
  * @param WP_Post $post WP_Post object for the current blog post.
@@ -465,7 +478,7 @@ add_action( 'bp_activity_post_type_published', 'bp_blogs_publish_post_activity_m
465
  /**
466
  * Updates a blog post's activity meta entry during a post edit.
467
  *
468
- * @since BuddyPress (2.2.0)
469
  *
470
  * @param WP_Post $post Post object.
471
  * @param BP_Activity_Activity $activity Activity object.
@@ -548,9 +561,10 @@ add_action( 'bp_activity_post_type_updated', 'bp_blogs_update_post_activity_meta
548
  *
549
  * Only posts the item if blog is public and post is not password-protected.
550
  *
551
- * @param int $comment_id ID of the comment being recorded.
552
  * @param bool|string $is_approved Optional. The $is_approved value passed to
553
- * the 'comment_post' action. Default: true.
 
554
  * @return bool|object Returns false on failure, the comment object on success.
555
  */
556
  function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
@@ -729,9 +743,9 @@ add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );
729
  * default, though as of 2.1.0 you can filter 'bp_blogs_get_allowed_roles' to
730
  * modify this behavior.
731
  *
732
- * @param int $user_id The ID of the user
733
- * @param string|bool $role User's WordPress role for this blog ID
734
- * @param int $blog_id Blog ID user is being added to
735
  *
736
  * @return bool|null False on failure.
737
  */
@@ -788,7 +802,7 @@ add_action( 'user_register', 'bp_blogs_add_user_to_blog' );
788
  * This added and was made filterable in BuddyPress 2.1.0 to make it easier
789
  * to extend the functionality of the Blogs component.
790
  *
791
- * @since BuddyPress (2.1.0)
792
  *
793
  * @return string
794
  */
@@ -814,15 +828,14 @@ function bp_blogs_remove_user_from_blog( $user_id, $blog_id = 0 ) {
814
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_user_from_blog', 10, 2 );
815
 
816
  /**
817
- * Rehook WP's maybe_add_existing_user_to_blog with a later priority
818
  *
819
  * WordPress catches add-user-to-blog requests at init:10. In some cases, this
820
  * can precede BP's Blogs component. This function bumps the priority of the
821
  * core function, so that we can be sure that the Blogs component is loaded
822
  * first. See https://buddypress.trac.wordpress.org/ticket/3916.
823
  *
824
- * @since BuddyPress (1.6.0)
825
- * @access private
826
  */
827
  function bp_blogs_maybe_add_user_to_blog() {
828
  if ( ! is_multisite() )
@@ -846,7 +859,7 @@ function bp_blogs_remove_blog( $blog_id ) {
846
  * Fires before a "blog created" item is removed from blogs
847
  * tracker and activity stream.
848
  *
849
- * @since BuddyPress (1.5.0)
850
  *
851
  * @param int $blog_id ID of the blog having its item removed.
852
  */
@@ -865,7 +878,7 @@ function bp_blogs_remove_blog( $blog_id ) {
865
  * Fires after a "blog created" item has been removed from blogs
866
  * tracker and activity stream.
867
  *
868
- * @since BuddyPress (1.0.0)
869
  *
870
  * @param int $blog_id ID of the blog who had its item removed.
871
  */
@@ -887,7 +900,7 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
887
  /**
888
  * Fires before a blog is removed from the tracker for a specific user.
889
  *
890
- * @since BuddyPress (1.5.0)
891
  *
892
  * @param int $blog_id ID of the blog being removed.
893
  * @param int $user_id ID of the user having the blog removed for.
@@ -906,7 +919,7 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
906
  /**
907
  * Fires after a blog has been removed from the tracker for a specific user.
908
  *
909
- * @since BuddyPress (1.0.0)
910
  *
911
  * @param int $blog_id ID of the blog that was removed.
912
  * @param int $user_id ID of the user having the blog removed for.
@@ -921,7 +934,9 @@ add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
921
  * @param int $post_id ID of the post to be removed.
922
  * @param int $blog_id Optional. Defaults to current blog ID.
923
  * @param int $user_id Optional. Defaults to the logged-in user ID. This param
924
- * is currently unused in the function (but is passed to hooks).
 
 
925
  */
926
  function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
927
  global $wpdb;
@@ -940,7 +955,7 @@ function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
940
  /**
941
  * Fires before removal of a blog post activity item from the activity stream.
942
  *
943
- * @since BuddyPress (1.5.0)
944
  *
945
  * @param int $blog_id ID of the blog associated with the post that was removed.
946
  * @param int $post_id ID of the post that was removed.
@@ -959,7 +974,7 @@ function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
959
  /**
960
  * Fires after removal of a blog post activity item from the activity stream.
961
  *
962
- * @since BuddyPress (1.0.0)
963
  *
964
  * @param int $blog_id ID of the blog associated with the post that was removed.
965
  * @param int $post_id ID of the post that was removed.
@@ -1001,6 +1016,7 @@ function bp_blogs_remove_comment( $comment_id ) {
1001
  $activity = bp_activity_get( array(
1002
  'in' => $activity_id,
1003
  'display_comments' => 'stream',
 
1004
  ) );
1005
 
1006
  // get all activity comment IDs for the pending deleted item
@@ -1027,7 +1043,7 @@ function bp_blogs_remove_comment( $comment_id ) {
1027
  /**
1028
  * Fires after a blog comment activity item was removed from activity stream.
1029
  *
1030
- * @since BuddyPress (1.0.0)
1031
  *
1032
  * @param int $blogid Item ID for the blog associated with the removed comment.
1033
  * @param int $comment_id ID of the comment being removed.
@@ -1040,15 +1056,15 @@ add_action( 'delete_comment', 'bp_blogs_remove_comment' );
1040
  /**
1041
  * Removes blog comments that are associated with activity comments.
1042
  *
1043
- * @since BuddyPress (2.0.0)
1044
  *
1045
  * @see bp_blogs_remove_comment()
1046
  * @see bp_blogs_sync_delete_from_activity_comment()
1047
  *
1048
  * @param array $activity_ids The activity IDs to check association with blog
1049
- * comments.
1050
- * @param bool $force_delete Whether to force delete the comments. If false,
1051
- * comments are trashed instead.
1052
  */
1053
  function bp_blogs_remove_associated_blog_comments( $activity_ids = array(), $force_delete = true ) {
1054
  // query args
@@ -1081,11 +1097,11 @@ function bp_blogs_remove_associated_blog_comments( $activity_ids = array(), $for
1081
  /**
1082
  * When a blog comment status transition occurs, update the relevant activity's status.
1083
  *
1084
- * @since BuddyPress (1.6.0)
1085
  *
1086
  * @param string $new_status New comment status.
1087
  * @param string $old_status Previous comment status.
1088
- * @param object $comment Comment data.
1089
  */
1090
  function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
1091
 
@@ -1179,10 +1195,11 @@ function bp_blogs_total_blogs() {
1179
  /**
1180
  * Get the total number of blogs being tracked by BP for a specific user.
1181
  *
1182
- * @since BuddyPress (1.2.0)
1183
  *
1184
  * @param int $user_id ID of the user being queried. Default: on a user page,
1185
- * the displayed user. Otherwise, the logged-in user.
 
1186
  * @return int $count Total blog count for the user.
1187
  */
1188
  function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
@@ -1215,7 +1232,7 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
1215
  * Fires before all data related to a given blog is removed from blogs tracker
1216
  * and activity stream.
1217
  *
1218
- * @since BuddyPress (1.5.0)
1219
  *
1220
  * @param int $blog_id ID of the blog whose data is being removed.
1221
  */
@@ -1235,7 +1252,7 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
1235
  * Fires after all data related to a given blog has been removed from blogs tracker
1236
  * and activity stream.
1237
  *
1238
- * @since BuddyPress (1.0.0)
1239
  *
1240
  * @param int $blog_id ID of the blog whose data is being removed.
1241
  */
@@ -1249,8 +1266,9 @@ add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
1249
  * @see BP_Blogs_Blog::get_blogs_for_user() for a description of parameters
1250
  * and return values.
1251
  *
1252
- * @param int $user_id See {@BP_Blogs_Blog::get_blogs_for_user()}.
1253
  * @param bool $show_hidden See {@BP_Blogs_Blog::get_blogs_for_user()}.
 
1254
  * @return array See {@BP_Blogs_Blog::get_blogs_for_user()}.
1255
  */
1256
  function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) {
@@ -1263,7 +1281,8 @@ function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) {
1263
  * @see BP_Blogs_Blog::get_all() for a description of parameters and return values.
1264
  *
1265
  * @param int $limit See {@BP_Blogs_Blog::get_all()}.
1266
- * @param int $page See {@BP_Blogs_Blog::get_all()}.
 
1267
  * @return array See {@BP_Blogs_Blog::get_all()}.
1268
  */
1269
  function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
@@ -1276,7 +1295,8 @@ function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
1276
  * @see BP_Blogs_Blog::get() for a description of parameters and return values.
1277
  *
1278
  * @param int $limit See {@BP_Blogs_Blog::get()}.
1279
- * @param int $page See {@BP_Blogs_Blog::get()}.
 
1280
  * @return array See {@BP_Blogs_Blog::get()}.
1281
  */
1282
  function bp_blogs_get_random_blogs( $limit = null, $page = null ) {
@@ -1289,6 +1309,7 @@ function bp_blogs_get_random_blogs( $limit = null, $page = null ) {
1289
  * @see BP_Blogs_Blog::is_hidden() for a description of parameters and return values.
1290
  *
1291
  * @param int $blog_id See {@BP_Blogs_Blog::is_hidden()}.
 
1292
  * @return bool See {@BP_Blogs_Blog::is_hidden()}.
1293
  */
1294
  function bp_blogs_is_blog_hidden( $blog_id ) {
@@ -1309,15 +1330,17 @@ function bp_blogs_is_blog_hidden( $blog_id ) {
1309
  *
1310
  * @global object $wpdb WordPress database access object.
1311
  *
1312
- * @param int $blog_id ID of the blog whose metadata is being deleted.
1313
- * @param string $meta_key Optional. The key of the metadata being deleted. If
1314
- * omitted, all BP metadata associated with the blog will be deleted.
1315
- * @param string $meta_value Optional. If present, the metadata will only be
1316
- * deleted if the meta_value matches this parameter.
1317
- * @param bool $delete_all Optional. If true, delete matching metadata entries
1318
- * for all objects, ignoring the specified blog_id. Otherwise, only
1319
- * delete matching metadata entries for the specified blog.
1320
- * Default: false.
 
 
1321
  * @return bool True on success, false on failure.
1322
  */
1323
  function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
@@ -1346,17 +1369,18 @@ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = fa
1346
  /**
1347
  * Get metadata for a given blog.
1348
  *
1349
- * @since BuddyPress (1.2.0)
1350
  *
1351
  * @global object $wpdb WordPress database access object.
1352
  *
1353
- * @param int $blog_id ID of the blog whose metadata is being requested.
1354
  * @param string $meta_key Optional. If present, only the metadata matching
1355
- * that meta key will be returned. Otherwise, all metadata for the
1356
- * blog will be fetched.
1357
- * @param bool $single Optional. If true, return only the first value of the
1358
- * specified meta_key. This parameter has no effect if meta_key is not
1359
- * specified. Default: true.
 
1360
  * @return mixed The meta value(s) being requested.
1361
  */
1362
  function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) {
@@ -1372,15 +1396,16 @@ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) {
1372
  *
1373
  * @global object $wpdb WordPress database access object.
1374
  *
1375
- * @param int $blog_id ID of the blog whose metadata is being updated.
1376
- * @param string $meta_key Key of the metadata being updated.
1377
- * @param mixed $meta_value Value to be set.
1378
- * @param mixed $prev_value Optional. If specified, only update existing
1379
- * metadata entries with the specified value. Otherwise, update all
1380
- * entries.
 
1381
  * @return bool|int Returns false on failure. On successful update of existing
1382
- * metadata, returns true. On successful creation of new metadata,
1383
- * returns the integer ID of the new metadata row.
1384
  */
1385
  function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value = '' ) {
1386
  add_filter( 'query', 'bp_filter_metaid_column_name' );
@@ -1393,14 +1418,15 @@ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value
1393
  /**
1394
  * Add a piece of blog metadata.
1395
  *
1396
- * @since BuddyPress (2.0.0)
 
 
 
 
 
 
 
1397
  *
1398
- * @param int $blog_id ID of the blog.
1399
- * @param string $meta_key Metadata key.
1400
- * @param mixed $meta_value Metadata value.
1401
- * @param bool $unique Optional. Whether to enforce a single metadata value
1402
- * for the given key. If true, and the object already has a value for
1403
- * the key, no change will be made. Default: false.
1404
  * @return int|bool The meta ID on successful update, false on failure.
1405
  */
1406
  function bp_blogs_add_blogmeta( $blog_id, $meta_key, $meta_value, $unique = false ) {
@@ -1414,6 +1440,7 @@ function bp_blogs_add_blogmeta( $blog_id, $meta_key, $meta_value, $unique = fals
1414
  * Remove all blog associations for a given user.
1415
  *
1416
  * @param int $user_id ID whose blog data should be removed.
 
1417
  * @return bool|null Returns false on failure.
1418
  */
1419
  function bp_blogs_remove_data( $user_id ) {
@@ -1423,7 +1450,7 @@ function bp_blogs_remove_data( $user_id ) {
1423
  /**
1424
  * Fires before all blog associations are removed for a given user.
1425
  *
1426
- * @since BuddyPress (1.5.0)
1427
  *
1428
  * @param int $user_id ID of the user whose blog associations are being removed.
1429
  */
@@ -1435,7 +1462,7 @@ function bp_blogs_remove_data( $user_id ) {
1435
  /**
1436
  * Fires after all blog associations are removed for a given user.
1437
  *
1438
- * @since BuddyPress (1.0.0)
1439
  *
1440
  * @param int $user_id ID of the user whose blog associations were removed.
1441
  */
@@ -1446,9 +1473,9 @@ add_action( 'delete_user', 'bp_blogs_remove_data' );
1446
  add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
1447
 
1448
  /**
1449
- * Restore all blog associations for a given user
1450
  *
1451
- * @since BuddyPress (2.2.0)
1452
  *
1453
  * @param int $user_id ID whose blog data should be restored.
1454
  */
12
  /**
13
  * Check whether the $bp global lists an activity directory page.
14
  *
15
+ * @since 1.5.0
16
  *
17
  * @return bool True if set, false if empty.
18
  */
23
  }
24
 
25
  /**
26
+ * Retrieve a set of blogs.
27
  *
28
  * @see BP_Blogs_Blog::get() for a description of arguments and return value.
29
  *
30
+ * @param array|string $args {
31
  * Arguments are listed here with their default values. For more
32
  * information about the arguments, see {@link BP_Blogs_Blog::get()}.
33
+ * @type string $type Default: 'active'.
34
+ * @type int|bool $user_id Default: false.
35
+ * @type array $include_blog_ids Default: false.
36
+ * @type string|bool $search_terms Default: false.
37
+ * @type int $per_page Default: 20.
38
+ * @type int $page Default: 1.
39
+ * @type bool $update_meta_cache Whether to pre-fetch blogmeta. Default: true.
40
  * }
41
  * @return array See {@link BP_Blogs_Blog::get()}.
42
  */
71
  /**
72
  * Populate the BP blogs table with existing blogs.
73
  *
74
+ * @since 1.0.0
75
  *
76
+ * @global object $wpdb WordPress database object.
77
  * @uses get_users()
78
  * @uses bp_blogs_record_blog()
79
+ *
80
+ * @return bool
81
  */
82
  function bp_blogs_record_existing_blogs() {
83
  global $wpdb;
146
  }
147
  }
148
 
149
+ /**
150
+ * Fires after the BP blogs tables have been populated with existing blogs.
151
+ *
152
+ * @since 2.4.0
153
+ */
154
+ do_action( 'bp_blogs_recorded_existing_blogs' );
155
+
156
  // No errors
157
  return true;
158
  }
163
  * If $user_id is provided, you can restrict site from being recordable
164
  * only to particular users.
165
  *
166
+ * @since 1.7.0
167
  *
168
  * @uses apply_filters()
169
  *
170
  * @param int $blog_id ID of the blog being checked.
171
  * @param int $user_id Optional. ID of the user for whom access is being checked.
172
+ *
173
  * @return bool True if blog is recordable, otherwise false.
174
  */
175
  function bp_blogs_is_blog_recordable( $blog_id, $user_id = 0 ) {
195
  * If $user_id is provided, the developer can restrict site from
196
  * being trackable only to particular users.
197
  *
198
+ * @since 1.7.0
199
  *
200
  * @uses bp_blogs_is_blog_recordable
201
  * @uses apply_filters()
202
  *
203
  * @param int $blog_id ID of the blog being checked.
204
  * @param int $user_id Optional. ID of the user for whom access is being checked.
205
+ *
206
  * @return bool True if blog is trackable, otherwise false.
207
  */
208
  function bp_blogs_is_blog_trackable( $blog_id, $user_id = 0 ) {
225
  /**
226
  * Make BuddyPress aware of a new site so that it can track its activity.
227
  *
228
+ * @since 1.0.0
229
  *
230
  * @uses BP_Blogs_Blog
231
  *
232
+ * @param int $blog_id ID of the blog being recorded.
233
+ * @param int $user_id ID of the user for whom the blog is being recorded.
234
  * @param bool $no_activity Optional. Whether to skip recording an activity
235
+ * item about this blog creation. Default: false.
236
+ *
237
  * @return bool|null Returns false on failure.
238
  */
239
  function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
296
  /**
297
  * Fires after BuddyPress has been made aware of a new site for activity tracking.
298
  *
299
+ * @since 1.0.0
300
  *
301
  * @param BP_Blogs_Blog $recorded_blog Current blog being recorded. Passed by reference.
302
  * @param bool $is_private Whether or not the current blog being recorded is private.
312
  * @global object $wpdb DB Layer.
313
  *
314
  * @param string $oldvalue Value before save. Passed by do_action() but
315
+ * unused here.
316
  * @param string $newvalue Value to change meta to.
317
  */
318
  function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
323
  add_action( 'update_option_blogname', 'bp_blogs_update_option_blogname', 10, 2 );
324
 
325
  /**
326
+ * Update blog description in BuddyPress blogmeta table.
327
  *
328
  * @global object $wpdb DB Layer.
329
  *
330
  * @param string $oldvalue Value before save. Passed by do_action() but
331
+ * unused here.
332
  * @param string $newvalue Value to change meta to.
333
  */
334
  function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) {
341
  /**
342
  * Update "Close comments for old posts" option in BuddyPress blogmeta table.
343
  *
344
+ * @since 2.0.0
345
  *
346
  * @global object $wpdb DB Layer.
347
  *
348
  * @param string $oldvalue Value before save. Passed by do_action() but
349
+ * unused here.
350
  * @param string $newvalue Value to change meta to.
351
  */
352
  function bp_blogs_update_option_close_comments_for_old_posts( $oldvalue, $newvalue ) {
359
  /**
360
  * Update "Close comments after days old" option in BuddyPress blogmeta table.
361
  *
362
+ * @since 2.0.0
363
  *
364
  * @global object $wpdb DB Layer.
365
  *
366
  * @param string $oldvalue Value before save. Passed by do_action() but
367
+ * unused here.
368
  * @param string $newvalue Value to change meta to.
369
  */
370
  function bp_blogs_update_option_close_comments_days_old( $oldvalue, $newvalue ) {
377
  /**
378
  * When toggling threaded comments, update thread depth in blogmeta table.
379
  *
380
+ * @since 2.0.0
381
  *
382
  * @global object $wpdb DB Layer.
383
  *
384
  * @param string $oldvalue Value before save. Passed by do_action() but
385
+ * unused here.
386
  * @param string $newvalue Value to change meta to.
387
  */
388
  function bp_blogs_update_option_thread_comments( $oldvalue, $newvalue ) {
401
  /**
402
  * When updating comment depth, update thread depth in blogmeta table.
403
  *
404
+ * @since 2.0.0
405
  *
406
  * @global object $wpdb DB Layer.
407
  *
408
  * @param string $oldvalue Value before save. Passed by do_action() but
409
+ * unused here.
410
  * @param string $newvalue Value to change meta to.
411
  */
412
  function bp_blogs_update_option_thread_comments_depth( $oldvalue, $newvalue ) {
426
  * Hooked to 'refresh_blog_details', which is notably used when editing a site
427
  * under "Network Admin > Sites".
428
  *
429
+ * @since 2.3.0
430
  *
431
+ * @param int $site_id The site ID.
432
  */
433
  function bp_blogs_delete_url_blogmeta( $site_id = 0 ) {
434
  bp_blogs_delete_blogmeta( (int) $site_id, 'url' );
438
  /**
439
  * Record activity metadata about a published blog post.
440
  *
441
+ * @since 2.2.0
442
  *
443
+ * @param int $activity_id ID of the activity item.
444
+ * @param WP_Post $post Post object.
445
+ * @param array $args Array of arguments.
446
  */
447
  function bp_blogs_publish_post_activity_meta( $activity_id, $post, $args ) {
448
  if ( empty( $activity_id ) || 'post' != $post->post_type ) {
465
  /**
466
  * Fires after BuddyPress has recorded metadata about a published blog post.
467
  *
468
+ * @since 1.0.0
469
  *
470
  * @param int $ID ID of the blog post being recorded.
471
  * @param WP_Post $post WP_Post object for the current blog post.
478
  /**
479
  * Updates a blog post's activity meta entry during a post edit.
480
  *
481
+ * @since 2.2.0
482
  *
483
  * @param WP_Post $post Post object.
484
  * @param BP_Activity_Activity $activity Activity object.
561
  *
562
  * Only posts the item if blog is public and post is not password-protected.
563
  *
564
+ * @param int $comment_id ID of the comment being recorded.
565
  * @param bool|string $is_approved Optional. The $is_approved value passed to
566
+ * the 'comment_post' action. Default: true.
567
+ *
568
  * @return bool|object Returns false on failure, the comment object on success.
569
  */
570
  function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
743
  * default, though as of 2.1.0 you can filter 'bp_blogs_get_allowed_roles' to
744
  * modify this behavior.
745
  *
746
+ * @param int $user_id The ID of the user.
747
+ * @param string|bool $role User's WordPress role for this blog ID.
748
+ * @param int $blog_id Blog ID user is being added to.
749
  *
750
  * @return bool|null False on failure.
751
  */
802
  * This added and was made filterable in BuddyPress 2.1.0 to make it easier
803
  * to extend the functionality of the Blogs component.
804
  *
805
+ * @since 2.1.0
806
  *
807
  * @return string
808
  */
828
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_user_from_blog', 10, 2 );
829
 
830
  /**
831
+ * Rehook WP's maybe_add_existing_user_to_blog with a later priority.
832
  *
833
  * WordPress catches add-user-to-blog requests at init:10. In some cases, this
834
  * can precede BP's Blogs component. This function bumps the priority of the
835
  * core function, so that we can be sure that the Blogs component is loaded
836
  * first. See https://buddypress.trac.wordpress.org/ticket/3916.
837
  *
838
+ * @since 1.6.0
 
839
  */
840
  function bp_blogs_maybe_add_user_to_blog() {
841
  if ( ! is_multisite() )
859
  * Fires before a "blog created" item is removed from blogs
860
  * tracker and activity stream.
861
  *
862
+ * @since 1.5.0
863
  *
864
  * @param int $blog_id ID of the blog having its item removed.
865
  */
878
  * Fires after a "blog created" item has been removed from blogs
879
  * tracker and activity stream.
880
  *
881
+ * @since 1.0.0
882
  *
883
  * @param int $blog_id ID of the blog who had its item removed.
884
  */
900
  /**
901
  * Fires before a blog is removed from the tracker for a specific user.
902
  *
903
+ * @since 1.5.0
904
  *
905
  * @param int $blog_id ID of the blog being removed.
906
  * @param int $user_id ID of the user having the blog removed for.
919
  /**
920
  * Fires after a blog has been removed from the tracker for a specific user.
921
  *
922
+ * @since 1.0.0
923
  *
924
  * @param int $blog_id ID of the blog that was removed.
925
  * @param int $user_id ID of the user having the blog removed for.
934
  * @param int $post_id ID of the post to be removed.
935
  * @param int $blog_id Optional. Defaults to current blog ID.
936
  * @param int $user_id Optional. Defaults to the logged-in user ID. This param
937
+ * is currently unused in the function (but is passed to hooks).
938
+ *
939
+ * @return bool
940
  */
941
  function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
942
  global $wpdb;
955
  /**
956
  * Fires before removal of a blog post activity item from the activity stream.
957
  *
958
+ * @since 1.5.0
959
  *
960
  * @param int $blog_id ID of the blog associated with the post that was removed.
961
  * @param int $post_id ID of the post that was removed.
974
  /**
975
  * Fires after removal of a blog post activity item from the activity stream.
976
  *
977
+ * @since 1.0.0
978
  *
979
  * @param int $blog_id ID of the blog associated with the post that was removed.
980
  * @param int $post_id ID of the post that was removed.
1016
  $activity = bp_activity_get( array(
1017
  'in' => $activity_id,
1018
  'display_comments' => 'stream',
1019
+ 'spam' => 'all',
1020
  ) );
1021
 
1022
  // get all activity comment IDs for the pending deleted item
1043
  /**
1044
  * Fires after a blog comment activity item was removed from activity stream.
1045
  *
1046
+ * @since 1.0.0
1047
  *
1048
  * @param int $blogid Item ID for the blog associated with the removed comment.
1049
  * @param int $comment_id ID of the comment being removed.
1056
  /**
1057
  * Removes blog comments that are associated with activity comments.
1058
  *
1059
+ * @since 2.0.0
1060
  *
1061
  * @see bp_blogs_remove_comment()
1062
  * @see bp_blogs_sync_delete_from_activity_comment()
1063
  *
1064
  * @param array $activity_ids The activity IDs to check association with blog
1065
+ * comments.
1066
+ * @param bool $force_delete Whether to force delete the comments. If false,
1067
+ * comments are trashed instead.
1068
  */
1069
  function bp_blogs_remove_associated_blog_comments( $activity_ids = array(), $force_delete = true ) {
1070
  // query args
1097
  /**
1098
  * When a blog comment status transition occurs, update the relevant activity's status.
1099
  *
1100
+ * @since 1.6.0
1101
  *
1102
  * @param string $new_status New comment status.
1103
  * @param string $old_status Previous comment status.
1104
+ * @param object $comment Comment data.
1105
  */
1106
  function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
1107
 
1195
  /**
1196
  * Get the total number of blogs being tracked by BP for a specific user.
1197
  *
1198
+ * @since 1.2.0
1199
  *
1200
  * @param int $user_id ID of the user being queried. Default: on a user page,
1201
+ * the displayed user. Otherwise, the logged-in user.
1202
+ *
1203
  * @return int $count Total blog count for the user.
1204
  */
1205
  function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
1232
  * Fires before all data related to a given blog is removed from blogs tracker
1233
  * and activity stream.
1234
  *
1235
+ * @since 1.5.0
1236
  *
1237
  * @param int $blog_id ID of the blog whose data is being removed.
1238
  */
1252
  * Fires after all data related to a given blog has been removed from blogs tracker
1253
  * and activity stream.
1254
  *
1255
+ * @since 1.0.0
1256
  *
1257
  * @param int $blog_id ID of the blog whose data is being removed.
1258
  */
1266
  * @see BP_Blogs_Blog::get_blogs_for_user() for a description of parameters
1267
  * and return values.
1268
  *
1269
+ * @param int $user_id See {@BP_Blogs_Blog::get_blogs_for_user()}.
1270
  * @param bool $show_hidden See {@BP_Blogs_Blog::get_blogs_for_user()}.
1271
+ *
1272
  * @return array See {@BP_Blogs_Blog::get_blogs_for_user()}.
1273
  */
1274
  function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) {
1281
  * @see BP_Blogs_Blog::get_all() for a description of parameters and return values.
1282
  *
1283
  * @param int $limit See {@BP_Blogs_Blog::get_all()}.
1284
+ * @param int $page See {@BP_Blogs_Blog::get_all()}.
1285
+ *
1286
  * @return array See {@BP_Blogs_Blog::get_all()}.
1287
  */
1288
  function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
1295
  * @see BP_Blogs_Blog::get() for a description of parameters and return values.
1296
  *
1297
  * @param int $limit See {@BP_Blogs_Blog::get()}.
1298
+ * @param int $page See {@BP_Blogs_Blog::get()}.
1299
+ *
1300
  * @return array See {@BP_Blogs_Blog::get()}.
1301
  */
1302
  function bp_blogs_get_random_blogs( $limit = null, $page = null ) {
1309
  * @see BP_Blogs_Blog::is_hidden() for a description of parameters and return values.
1310
  *
1311
  * @param int $blog_id See {@BP_Blogs_Blog::is_hidden()}.
1312
+ *
1313
  * @return bool See {@BP_Blogs_Blog::is_hidden()}.
1314
  */
1315
  function bp_blogs_is_blog_hidden( $blog_id ) {
1330
  *
1331
  * @global object $wpdb WordPress database access object.
1332
  *
1333
+ * @param int $blog_id ID of the blog whose metadata is being deleted.
1334
+ * @param string|bool $meta_key Optional. The key of the metadata being deleted. If
1335
+ * omitted, all BP metadata associated with the blog will
1336
+ * be deleted.
1337
+ * @param string|bool $meta_value Optional. If present, the metadata will only be
1338
+ * deleted if the meta_value matches this parameter.
1339
+ * @param bool $delete_all Optional. If true, delete matching metadata entries for
1340
+ * all objects, ignoring the specified blog_id. Otherwise, only
1341
+ * delete matching metadata entries for the specified blog.
1342
+ * Default: false.
1343
+ *
1344
  * @return bool True on success, false on failure.
1345
  */
1346
  function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
1369
  /**
1370
  * Get metadata for a given blog.
1371
  *
1372
+ * @since 1.2.0
1373
  *
1374
  * @global object $wpdb WordPress database access object.
1375
  *
1376
+ * @param int $blog_id ID of the blog whose metadata is being requested.
1377
  * @param string $meta_key Optional. If present, only the metadata matching
1378
+ * that meta key will be returned. Otherwise, all
1379
+ * metadata for the blog will be fetched.
1380
+ * @param bool $single Optional. If true, return only the first value of the
1381
+ * specified meta_key. This parameter has no effect if
1382
+ * meta_key is not specified. Default: true.
1383
+ *
1384
  * @return mixed The meta value(s) being requested.
1385
  */
1386
  function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) {
1396
  *
1397
  * @global object $wpdb WordPress database access object.
1398
  *
1399
+ * @param int $blog_id ID of the blog whose metadata is being updated.
1400
+ * @param string $meta_key Key of the metadata being updated.
1401
+ * @param mixed $meta_value Value to be set.
1402
+ * @param mixed $prev_value Optional. If specified, only update existing
1403
+ * metadata entries with the specified value.
1404
+ * Otherwise, update all entries.
1405
+ *
1406
  * @return bool|int Returns false on failure. On successful update of existing
1407
+ * metadata, returns true. On successful creation of new metadata,
1408
+ * returns the integer ID of the new metadata row.
1409
  */
1410
  function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value = '' ) {
1411
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1418
  /**
1419
  * Add a piece of blog metadata.
1420
  *
1421
+ * @since 2.0.0
1422
+ *
1423
+ * @param int $blog_id ID of the blog.
1424
+ * @param string $meta_key Metadata key.
1425
+ * @param mixed $meta_value Metadata value.
1426
+ * @param bool $unique Optional. Whether to enforce a single metadata value
1427
+ * for the given key. If true, and the object already has a value for
1428
+ * the key, no change will be made. Default: false.
1429
  *
 
 
 
 
 
 
1430
  * @return int|bool The meta ID on successful update, false on failure.
1431
  */
1432
  function bp_blogs_add_blogmeta( $blog_id, $meta_key, $meta_value, $unique = false ) {
1440
  * Remove all blog associations for a given user.
1441
  *
1442
  * @param int $user_id ID whose blog data should be removed.
1443
+ *
1444
  * @return bool|null Returns false on failure.
1445
  */
1446
  function bp_blogs_remove_data( $user_id ) {
1450
  /**
1451
  * Fires before all blog associations are removed for a given user.
1452
  *
1453
+ * @since 1.5.0
1454
  *
1455
  * @param int $user_id ID of the user whose blog associations are being removed.
1456
  */
1462
  /**
1463
  * Fires after all blog associations are removed for a given user.
1464
  *
1465
+ * @since 1.0.0
1466
  *
1467
  * @param int $user_id ID of the user whose blog associations were removed.
1468
  */
1473
  add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
1474
 
1475
  /**
1476
+ * Restore all blog associations for a given user.
1477
  *
1478
+ * @since 2.2.0
1479
  *
1480
  * @param int $user_id ID whose blog data should be restored.
1481
  */
bp-blogs/bp-blogs-loader.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Blogs Loader
5
  *
@@ -8,7 +7,7 @@
8
  * information from those blogs to make querying blogs in bulk more performant.
9
  *
10
  * @package BuddyPress
11
- * @subpackage Blogs Core
12
  */
13
 
14
  // Exit if accessed directly
@@ -19,7 +18,7 @@ class BP_Blogs_Component extends BP_Component {
19
  /**
20
  * Start the blogs component creation process.
21
  *
22
- * @since BuddyPress (1.5.0)
23
  */
24
  public function __construct() {
25
  parent::start(
@@ -27,7 +26,8 @@ class BP_Blogs_Component extends BP_Component {
27
  __( 'Site Directory', 'buddypress' ),
28
  buddypress()->plugin_dir,
29
  array(
30
- 'adminbar_myaccount_order' => 30
 
31
  )
32
  );
33
  }
@@ -38,7 +38,7 @@ class BP_Blogs_Component extends BP_Component {
38
  * The BP_BLOGS_SLUG constant is deprecated, and only used here for
39
  * backwards compatibility.
40
  *
41
- * @since BuddyPress (1.5.0)
42
  *
43
  * @see BP_Component::setup_globals() for description of parameters.
44
  *
@@ -78,17 +78,21 @@ class BP_Blogs_Component extends BP_Component {
78
  parent::setup_globals( $args );
79
 
80
  /*
81
- * Set up the post post type to track.
82
  *
83
  * In case the config is not multisite, the blog_public option is ignored.
 
 
 
 
84
  */
85
  if ( 0 !== apply_filters( 'bp_is_blog_public', (int) get_option( 'blog_public' ) ) || ! is_multisite() ) {
86
 
87
  /**
88
  * Filters the post types to track for the Blogs component.
89
  *
90
- * @since BuddyPress (1.5.0)
91
- * @deprecated BuddyPress (2.3.0)
92
  *
93
  * @param array $value Array of post types to track.
94
  */
@@ -138,12 +142,11 @@ class BP_Blogs_Component extends BP_Component {
138
  * @see BP_Component::setup_nav() for a description of arguments.
139
  *
140
  * @param array $main_nav Optional. See BP_Component::setup_nav() for
141
- * description.
142
- * @param array $sub_nav Optional. See BP_Component::setup_nav() for
143
- * description.
144
  */
145
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
146
- $bp = buddypress();
147
 
148
  /**
149
  * Blog/post/comment menus should not appear on single WordPress setups.
@@ -154,35 +157,36 @@ class BP_Blogs_Component extends BP_Component {
154
  return false;
155
  }
156
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  // Add 'Sites' to the main navigation
158
  $count = (int) bp_get_total_blog_count_for_user();
159
  $class = ( 0 === $count ) ? 'no-count' : 'count';
160
- $nav_text = sprintf( __( 'Sites <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) );
161
  $main_nav = array(
162
  'name' => $nav_text,
163
- 'slug' => $this->slug,
164
  'position' => 30,
165
  'screen_function' => 'bp_blogs_screen_my_blogs',
166
  'default_subnav_slug' => 'my-sites',
167
  'item_css_id' => $this->id
168
  );
169
 
170
- // Determine user to use
171
- if ( bp_displayed_user_domain() ) {
172
- $user_domain = bp_displayed_user_domain();
173
- } elseif ( bp_loggedin_user_domain() ) {
174
- $user_domain = bp_loggedin_user_domain();
175
- } else {
176
- return;
177
- }
178
-
179
- $parent_url = trailingslashit( $user_domain . bp_get_blogs_slug() );
180
-
181
  $sub_nav[] = array(
182
  'name' => __( 'My Sites', 'buddypress' ),
183
  'slug' => 'my-sites',
184
  'parent_url' => $parent_url,
185
- 'parent_slug' => $bp->blogs->slug,
186
  'screen_function' => 'bp_blogs_screen_my_blogs',
187
  'position' => 10
188
  );
@@ -194,15 +198,16 @@ class BP_Blogs_Component extends BP_Component {
194
  /**
195
  * Set up bp-blogs integration with the WordPress admin bar.
196
  *
197
- * @since BuddyPress (1.5.0)
198
  *
199
  * @see BP_Component::setup_admin_bar() for a description of arguments.
200
  *
201
  * @param array $wp_admin_nav See BP_Component::setup_admin_bar()
202
- * for description.
 
 
203
  */
204
  public function setup_admin_bar( $wp_admin_nav = array() ) {
205
- $bp = buddypress();
206
 
207
  /**
208
  * Site/post/comment menus should not appear on single WordPress setups.
@@ -216,14 +221,15 @@ class BP_Blogs_Component extends BP_Component {
216
  // Menus for logged in user
217
  if ( is_user_logged_in() ) {
218
 
219
- $blogs_link = trailingslashit( bp_loggedin_user_domain() . $this->slug );
 
220
 
221
  // Add the "Sites" sub menu
222
  $wp_admin_nav[] = array(
223
- 'parent' => $bp->my_account_menu_id,
224
  'id' => 'my-account-' . $this->id,
225
  'title' => __( 'Sites', 'buddypress' ),
226
- 'href' => trailingslashit( $blogs_link )
227
  );
228
 
229
  // My Sites
@@ -231,7 +237,7 @@ class BP_Blogs_Component extends BP_Component {
231
  'parent' => 'my-account-' . $this->id,
232
  'id' => 'my-account-' . $this->id . '-my-sites',
233
  'title' => __( 'My Sites', 'buddypress' ),
234
- 'href' => trailingslashit( $blogs_link )
235
  );
236
 
237
  // Create a Site
@@ -252,10 +258,11 @@ class BP_Blogs_Component extends BP_Component {
252
  * Set up the title for pages and <title>
253
  */
254
  public function setup_title() {
255
- $bp = buddypress();
256
 
257
  // Set up the component options navigation for Site
258
  if ( bp_is_blogs_component() ) {
 
 
259
  if ( bp_is_my_profile() ) {
260
  if ( bp_is_active( 'xprofile' ) ) {
261
  $bp->bp_options_title = __( 'My Sites', 'buddypress' );
@@ -279,7 +286,7 @@ class BP_Blogs_Component extends BP_Component {
279
  /**
280
  * Setup cache groups
281
  *
282
- * @since BuddyPress (2.2.0)
283
  */
284
  public function setup_cache_groups() {
285
 
@@ -294,16 +301,22 @@ class BP_Blogs_Component extends BP_Component {
294
  /**
295
  * Set up the tracking arguments for the 'post' post type.
296
  *
297
- * @since BuddyPress (2.2.0)
298
  *
299
  * @see bp_activity_get_post_type_tracking_args() for information on parameters.
 
 
 
 
 
300
  */
301
  public function post_tracking_args( $params = null, $post_type = 0 ) {
 
302
  /**
303
  * Filters the post types to track for the Blogs component.
304
  *
305
- * @since BuddyPress (1.5.0)
306
- * @deprecated BuddyPress (2.3.0)
307
  *
308
  * Make sure plugins still using 'bp_blogs_record_post_post_types'
309
  * to track their post types will generate new_blog_post activities
1
  <?php
 
2
  /**
3
  * BuddyPress Blogs Loader
4
  *
7
  * information from those blogs to make querying blogs in bulk more performant.
8
  *
9
  * @package BuddyPress
10
+ * @subpackage BlogsCore
11
  */
12
 
13
  // Exit if accessed directly
18
  /**
19
  * Start the blogs component creation process.
20
  *
21
+ * @since 1.5.0
22
  */
23
  public function __construct() {
24
  parent::start(
26
  __( 'Site Directory', 'buddypress' ),
27
  buddypress()->plugin_dir,
28
  array(
29
+ 'adminbar_myaccount_order' => 30,
30
+ 'search_query_arg' => 'sites_search',
31
  )
32
  );
33
  }
38
  * The BP_BLOGS_SLUG constant is deprecated, and only used here for
39
  * backwards compatibility.
40
  *
41
+ * @since 1.5.0
42
  *
43
  * @see BP_Component::setup_globals() for description of parameters.
44
  *
78
  parent::setup_globals( $args );
79
 
80
  /*
81
+ * Filters if a blog is public.
82
  *
83
  * In case the config is not multisite, the blog_public option is ignored.
84
+ *
85
+ * @since 2.3.0
86
+ *
87
+ * @oaram int $value Whether or not the blog is public.
88
  */
89
  if ( 0 !== apply_filters( 'bp_is_blog_public', (int) get_option( 'blog_public' ) ) || ! is_multisite() ) {
90
 
91
  /**
92
  * Filters the post types to track for the Blogs component.
93
  *
94
+ * @since 1.5.0
95
+ * @deprecated 2.3.0
96
  *
97
  * @param array $value Array of post types to track.
98
  */
142
  * @see BP_Component::setup_nav() for a description of arguments.
143
  *
144
  * @param array $main_nav Optional. See BP_Component::setup_nav() for
145
+ * description.
146
+ * @param array $sub_nav Optional. See BP_Component::setup_nav() for
147
+ * description.
148
  */
149
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
 
150
 
151
  /**
152
  * Blog/post/comment menus should not appear on single WordPress setups.
157
  return false;
158
  }
159
 
160
+ // Determine user to use
161
+ if ( bp_displayed_user_domain() ) {
162
+ $user_domain = bp_displayed_user_domain();
163
+ } elseif ( bp_loggedin_user_domain() ) {
164
+ $user_domain = bp_loggedin_user_domain();
165
+ } else {
166
+ return;
167
+ }
168
+
169
+ $slug = bp_get_blogs_slug();
170
+ $parent_url = trailingslashit( $user_domain . $slug );
171
+
172
  // Add 'Sites' to the main navigation
173
  $count = (int) bp_get_total_blog_count_for_user();
174
  $class = ( 0 === $count ) ? 'no-count' : 'count';
175
+ $nav_text = sprintf( __( 'Sites <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), bp_core_number_format( $count ) );
176
  $main_nav = array(
177
  'name' => $nav_text,
178
+ 'slug' => $slug,
179
  'position' => 30,
180
  'screen_function' => 'bp_blogs_screen_my_blogs',
181
  'default_subnav_slug' => 'my-sites',
182
  'item_css_id' => $this->id
183
  );
184
 
 
 
 
 
 
 
 
 
 
 
 
185
  $sub_nav[] = array(
186
  'name' => __( 'My Sites', 'buddypress' ),
187
  'slug' => 'my-sites',
188
  'parent_url' => $parent_url,
189
+ 'parent_slug' => $slug,
190
  'screen_function' => 'bp_blogs_screen_my_blogs',
191
  'position' => 10
192
  );
198
  /**
199
  * Set up bp-blogs integration with the WordPress admin bar.
200
  *
201
+ * @since 1.5.0
202
  *
203
  * @see BP_Component::setup_admin_bar() for a description of arguments.
204
  *
205
  * @param array $wp_admin_nav See BP_Component::setup_admin_bar()
206
+ * for description.
207
+ *
208
+ * @return bool
209
  */
210
  public function setup_admin_bar( $wp_admin_nav = array() ) {
 
211
 
212
  /**
213
  * Site/post/comment menus should not appear on single WordPress setups.
221
  // Menus for logged in user
222
  if ( is_user_logged_in() ) {
223
 
224
+ // Setup the logged in user variables
225
+ $blogs_link = trailingslashit( bp_loggedin_user_domain() . bp_get_blogs_slug() );
226
 
227
  // Add the "Sites" sub menu
228
  $wp_admin_nav[] = array(
229
+ 'parent' => buddypress()->my_account_menu_id,
230
  'id' => 'my-account-' . $this->id,
231
  'title' => __( 'Sites', 'buddypress' ),
232
+ 'href' => $blogs_link
233
  );
234
 
235
  // My Sites
237
  'parent' => 'my-account-' . $this->id,
238
  'id' => 'my-account-' . $this->id . '-my-sites',
239
  'title' => __( 'My Sites', 'buddypress' ),
240
+ 'href' => $blogs_link
241
  );
242
 
243
  // Create a Site
258
  * Set up the title for pages and <title>
259
  */
260
  public function setup_title() {
 
261
 
262
  // Set up the component options navigation for Site
263
  if ( bp_is_blogs_component() ) {
264
+ $bp = buddypress();
265
+
266
  if ( bp_is_my_profile() ) {
267
  if ( bp_is_active( 'xprofile' ) ) {
268
  $bp->bp_options_title = __( 'My Sites', 'buddypress' );
286
  /**
287
  * Setup cache groups
288
  *
289
+ * @since 2.2.0
290
  */
291
  public function setup_cache_groups() {
292
 
301
  /**
302
  * Set up the tracking arguments for the 'post' post type.
303
  *
304
+ * @since 2.2.0
305
  *
306
  * @see bp_activity_get_post_type_tracking_args() for information on parameters.
307
+ *
308
+ * @param object|null $params
309
+ * @param string|int $post_type
310
+ *
311
+ * @return object
312
  */
313
  public function post_tracking_args( $params = null, $post_type = 0 ) {
314
+
315
  /**
316
  * Filters the post types to track for the Blogs component.
317
  *
318
+ * @since 1.5.0
319
+ * @deprecated 2.3.0
320
  *
321
  * Make sure plugins still using 'bp_blogs_record_post_post_types'
322
  * to track their post types will generate new_blog_post activities
bp-blogs/bp-blogs-screens.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
-
3
  /**
4
- * BuddyPress Blogs Screens
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsScreens
@@ -20,7 +19,7 @@ function bp_blogs_screen_my_blogs() {
20
  /**
21
  * Fires right before the loading of the My Blogs screen template file.
22
  *
23
- * @since BuddyPress (1.0.0)
24
  */
25
  do_action( 'bp_blogs_screen_my_blogs' );
26
 
@@ -41,7 +40,7 @@ function bp_blogs_screen_create_a_blog() {
41
  /**
42
  * Fires right before the loading of the Create A Blog screen template file.
43
  *
44
- * @since BuddyPress (1.0.0)
45
  */
46
  do_action( 'bp_blogs_screen_create_a_blog' );
47
 
@@ -59,7 +58,7 @@ function bp_blogs_screen_index() {
59
  /**
60
  * Fires right before the loading of the top-level Blogs screen template file.
61
  *
62
- * @since BuddyPress (1.0.0)
63
  */
64
  do_action( 'bp_blogs_screen_index' );
65
 
@@ -71,19 +70,19 @@ add_action( 'bp_screens', 'bp_blogs_screen_index', 2 );
71
  /** Theme Compatibility *******************************************************/
72
 
73
  /**
74
- * The main theme compat class for BuddyPress Blogs
75
  *
76
  * This class sets up the necessary theme compatibility actions to safely output
77
  * group template parts to the_title and the_content areas of a theme.
78
  *
79
- * @since BuddyPress (1.7.0)
80
  */
81
  class BP_Blogs_Theme_Compat {
82
 
83
  /**
84
  * Set up theme compatibility for the Blogs component.
85
  *
86
- * @since BuddyPress (1.7.0)
87
  */
88
  public function __construct() {
89
  add_action( 'bp_setup_theme_compat', array( $this, 'is_blogs' ) );
@@ -92,7 +91,7 @@ class BP_Blogs_Theme_Compat {
92
  /**
93
  * Are we looking at something that needs Blogs theme compatibility?
94
  *
95
- * @since BuddyPress (1.7.0)
96
  */
97
  public function is_blogs() {
98
 
@@ -112,7 +111,7 @@ class BP_Blogs_Theme_Compat {
112
  * Fires if in the blog directory and BuddyPress needs Blog theme compatibility,
113
  * before the actions and filters are added.
114
  *
115
- * @since BuddyPress (1.5.0)
116
  */
117
  do_action( 'bp_blogs_screen_index' );
118
 
@@ -136,10 +135,10 @@ class BP_Blogs_Theme_Compat {
136
  * This is to mirror how WordPress has
137
  * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
138
  *
139
- * @since BuddyPress (1.8.0)
 
 
140
  *
141
- * @param string $templates The templates from
142
- * bp_get_theme_compat_templates().
143
  * @return array $templates Array of custom templates to look for.
144
  */
145
  public function directory_template_hierarchy( $templates ) {
@@ -147,7 +146,7 @@ class BP_Blogs_Theme_Compat {
147
  /**
148
  * Filters the custom templates used for theme compat with the blog directory page.
149
  *
150
- * @since BuddyPress (1.8.0)
151
  *
152
  * @param array $value Array of template paths to add to template list to look for.
153
  */
@@ -165,7 +164,7 @@ class BP_Blogs_Theme_Compat {
165
  /**
166
  * Update the global $post with directory data.
167
  *
168
- * @since BuddyPress (1.7.0)
169
  */
170
  public function directory_dummy_post() {
171
 
@@ -185,7 +184,7 @@ class BP_Blogs_Theme_Compat {
185
  /**
186
  * Filter the_content with the groups index template part.
187
  *
188
- * @since BuddyPress (1.7.0)
189
  */
190
  public function directory_content() {
191
  return bp_buffer_template_part( 'blogs/index', null, false );
@@ -199,10 +198,10 @@ class BP_Blogs_Theme_Compat {
199
  * This is to mirror how WordPress has
200
  * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
201
  *
202
- * @since BuddyPress (1.8.0)
 
 
203
  *
204
- * @param string $templates The templates from
205
- * bp_get_theme_compat_templates().
206
  * @return array $templates Array of custom templates to look for.
207
  */
208
  public function create_template_hierarchy( $templates ) {
@@ -210,7 +209,7 @@ class BP_Blogs_Theme_Compat {
210
  /**
211
  * Filters the custom templates used for theme compat with the blog create page.
212
  *
213
- * @since BuddyPress (1.8.0)
214
  *
215
  * @param array $value Array of template paths to add to template list to look for.
216
  */
@@ -228,7 +227,7 @@ class BP_Blogs_Theme_Compat {
228
  /**
229
  * Update the global $post with create screen data.
230
  *
231
- * @since BuddyPress (1.7.0)
232
  */
233
  public function create_dummy_post() {
234
 
@@ -255,7 +254,7 @@ class BP_Blogs_Theme_Compat {
255
  /**
256
  * Filter the_content with the create screen template part.
257
  *
258
- * @since BuddyPress (1.7.0)
259
  */
260
  public function create_content() {
261
  return bp_buffer_template_part( 'blogs/create', null, false );
1
  <?php
 
2
  /**
3
+ * BuddyPress Blogs Screens.
4
  *
5
  * @package BuddyPress
6
  * @subpackage BlogsScreens
19
  /**
20
  * Fires right before the loading of the My Blogs screen template file.
21
  *
22
+ * @since 1.0.0
23
  */
24
  do_action( 'bp_blogs_screen_my_blogs' );
25
 
40
  /**
41
  * Fires right before the loading of the Create A Blog screen template file.
42
  *
43
+ * @since 1.0.0
44
  */
45
  do_action( 'bp_blogs_screen_create_a_blog' );
46
 
58
  /**
59
  * Fires right before the loading of the top-level Blogs screen template file.
60
  *
61
+ * @since 1.0.0
62
  */
63
  do_action( 'bp_blogs_screen_index' );
64
 
70
  /** Theme Compatibility *******************************************************/
71
 
72
  /**
73
+ * The main theme compat class for BuddyPress Blogs.
74
  *
75
  * This class sets up the necessary theme compatibility actions to safely output
76
  * group template parts to the_title and the_content areas of a theme.
77
  *
78
+ * @since 1.7.0
79
  */
80
  class BP_Blogs_Theme_Compat {
81
 
82
  /**
83
  * Set up theme compatibility for the Blogs component.
84
  *
85
+ * @since 1.7.0
86
  */
87
  public function __construct() {
88
  add_action( 'bp_setup_theme_compat', array( $this, 'is_blogs' ) );
91
  /**
92
  * Are we looking at something that needs Blogs theme compatibility?
93
  *
94
+ * @since 1.7.0
95
  */
96
  public function is_blogs() {
97
 
111
  * Fires if in the blog directory and BuddyPress needs Blog theme compatibility,
112
  * before the actions and filters are added.
113
  *
114
+ * @since 1.5.0
115
  */
116
  do_action( 'bp_blogs_screen_index' );
117
 
135
  * This is to mirror how WordPress has
136
  * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
137
  *
138
+ * @since 1.8.0
139
+ *
140
+ * @param string $templates The templates from bp_get_theme_compat_templates().
141
  *
 
 
142
  * @return array $templates Array of custom templates to look for.
143
  */
144
  public function directory_template_hierarchy( $templates ) {
146
  /**
147
  * Filters the custom templates used for theme compat with the blog directory page.
148
  *
149
+ * @since 1.8.0
150
  *
151
  * @param array $value Array of template paths to add to template list to look for.
152
  */
164
  /**
165
  * Update the global $post with directory data.
166
  *
167
+ * @since 1.7.0
168
  */
169
  public function directory_dummy_post() {
170
 
184
  /**
185
  * Filter the_content with the groups index template part.
186
  *
187
+ * @since 1.7.0
188
  */
189
  public function directory_content() {
190
  return bp_buffer_template_part( 'blogs/index', null, false );
198
  * This is to mirror how WordPress has
199
  * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
200
  *
201
+ * @since 1.8.0
202
+ *
203
+ * @param string $templates The templates from bp_get_theme_compat_templates().
204
  *
 
 
205
  * @return array $templates Array of custom templates to look for.
206
  */
207
  public function create_template_hierarchy( $templates ) {
209
  /**
210
  * Filters the custom templates used for theme compat with the blog create page.
211
  *
212
+ * @since 1.8.0
213
  *
214
  * @param array $value Array of template paths to add to template list to look for.
215
  */
227
  /**
228
  * Update the global $post with create screen data.
229
  *
230
+ * @since 1.7.0
231
  */
232
  public function create_dummy_post() {
233
 
254
  /**
255
  * Filter the_content with the create screen template part.
256
  *
257
+ * @since 1.7.0
258
  */
259
  public function create_content() {
260
  return bp_buffer_template_part( 'blogs/create', null, false );
bp-blogs/bp-blogs-template.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Blogs Template Tags.
5
  *
@@ -7,13 +6,13 @@
7
  * @subpackage BlogsTemplate
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Output the blogs component slug.
15
  *
16
- * @since BuddyPress (1.5.0)
17
  *
18
  * @uses bp_get_blogs_slug()
19
  */
@@ -23,7 +22,7 @@ function bp_blogs_slug() {
23
  /**
24
  * Return the blogs component slug.
25
  *
26
- * @since BuddyPress (1.5.0)
27
  *
28
  * @return string The 'blogs' slug.
29
  */
@@ -32,7 +31,7 @@ function bp_blogs_slug() {
32
  /**
33
  * Filters the blogs component slug.
34
  *
35
- * @since BuddyPress (1.5.0)
36
  *
37
  * @param string $slug Slug for the blogs component.
38
  */
@@ -42,7 +41,7 @@ function bp_blogs_slug() {
42
  /**
43
  * Output the blogs component root slug.
44
  *
45
- * @since BuddyPress (1.5.0)
46
  *
47
  * @uses bp_get_blogs_root_slug()
48
  */
@@ -52,7 +51,7 @@ function bp_blogs_root_slug() {
52
  /**
53
  * Return the blogs component root slug.
54
  *
55
- * @since BuddyPress (1.5.0)
56
  *
57
  * @return string The 'blogs' root slug.
58
  */
@@ -61,7 +60,7 @@ function bp_blogs_root_slug() {
61
  /**
62
  * Filters the blogs component root slug.
63
  *
64
- * @since BuddyPress (1.5.0)
65
  *
66
  * @param string $root_slug Root slug for the blogs component.
67
  */
@@ -71,7 +70,7 @@ function bp_blogs_root_slug() {
71
  /**
72
  * Output blog directory permalink.
73
  *
74
- * @since BuddyPress (1.5.0)
75
  *
76
  * @uses bp_get_blogs_directory_permalink()
77
  */
@@ -81,12 +80,13 @@ function bp_blogs_directory_permalink() {
81
  /**
82
  * Return blog directory permalink.
83
  *
84
- * @since BuddyPress (1.5.0)
85
  *
86
  * @uses apply_filters()
87
  * @uses trailingslashit()
88
  * @uses bp_get_root_domain()
89
  * @uses bp_get_blogs_root_slug()
 
90
  * @return string The URL of the Blogs directory.
91
  */
92
  function bp_get_blogs_directory_permalink() {
@@ -94,7 +94,7 @@ function bp_blogs_directory_permalink() {
94
  /**
95
  * Filters the blog directory permalink.
96
  *
97
- * @since BuddyPress (1.5.0)
98
  *
99
  * @param string $value Permalink URL for the blog directory.
100
  */
@@ -111,7 +111,6 @@ class BP_Blogs_Template {
111
  /**
112
  * The loop iterator.
113
  *
114
- * @access public
115
  * @var int
116
  */
117
  public $current_blog = -1;
@@ -119,7 +118,6 @@ class BP_Blogs_Template {
119
  /**
120
  * The number of blogs returned by the paged query.
121
  *
122
- * @access public
123
  * @var int
124
  */
125
  public $blog_count = 0;
@@ -127,7 +125,6 @@ class BP_Blogs_Template {
127
  /**
128
  * Array of blogs located by the query..
129
  *
130
- * @access public
131
  * @var array
132
  */
133
  public $blogs = array();
@@ -135,7 +132,6 @@ class BP_Blogs_Template {
135
  /**
136
  * The blog object currently being iterated on.
137
  *
138
- * @access public
139
  * @var object
140
  */
141
  public $blog;
@@ -143,7 +139,6 @@ class BP_Blogs_Template {
143
  /**
144
  * A flag for whether the loop is currently being iterated.
145
  *
146
- * @access public
147
  * @var bool
148
  */
149
  public $in_the_loop = false;
@@ -151,23 +146,20 @@ class BP_Blogs_Template {
151
  /**
152
  * The page number being requested.
153
  *
154
- * @access public
155
- * @var public
156
  */
157
  public $pag_page = 1;
158
 
159
  /**
160
  * The number of items being requested per page.
161
  *
162
- * @access public
163
- * @var public
164
  */
165
  public $pag_num = 20;
166
 
167
  /**
168
  * An HTML string containing pagination links.
169
  *
170
- * @access public
171
  * @var string
172
  */
173
  public $pag_links = '';
@@ -175,7 +167,6 @@ class BP_Blogs_Template {
175
  /**
176
  * The total number of blogs matching the query parameters.
177
  *
178
- * @access public
179
  * @var int
180
  */
181
  public $total_blog_count = 0;
@@ -185,17 +176,17 @@ class BP_Blogs_Template {
185
  *
186
  * @see BP_Blogs_Blog::get() for a description of parameters.
187
  *
188
- * @param string $type See {@link BP_Blogs_Blog::get()}.
189
- * @param string $page See {@link BP_Blogs_Blog::get()}.
190
- * @param string $per_page See {@link BP_Blogs_Blog::get()}.
191
- * @param string $max See {@link BP_Blogs_Blog::get()}.
192
- * @param string $user_id See {@link BP_Blogs_Blog::get()}.
193
- * @param string $search_terms See {@link BP_Blogs_Blog::get()}.
194
- * @param string $page_arg The string used as a query parameter in
195
- * pagination links. Default: 'bpage'.
196
- * @param bool $update_meta_cache Whether to pre-fetch metadata for
197
- * queried blogs.
198
- * @param array $include_blog_ids Array of blog IDs to include.
199
  */
200
  public function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) {
201
 
@@ -307,7 +298,7 @@ class BP_Blogs_Template {
307
  /**
308
  * Fires right before the rewinding of blogs listing after all are shown.
309
  *
310
- * @since BuddyPress (1.5.0)
311
  */
312
  do_action( 'blog_loop_end' );
313
  // Do some cleaning up after the loop
@@ -338,7 +329,7 @@ class BP_Blogs_Template {
338
  /**
339
  * Fires if on the first blog in the loop.
340
  *
341
- * @since BuddyPress (1.5.0)
342
  */
343
  do_action( 'blog_loop_start' );
344
  }
@@ -363,7 +354,7 @@ function bp_rewind_blogs() {
363
  *
364
  * @global object $blogs_template {@link BP_Blogs_Template}
365
  *
366
- * @param array $args {
367
  * Arguments for limiting the contents of the blogs loop. Most arguments
368
  * are in the same format as {@link BP_Blogs_Blog::get()}. However, because
369
  * the format of the arguments accepted here differs in a number of ways,
@@ -373,32 +364,36 @@ function bp_rewind_blogs() {
373
  * Arguments can be passed as an associative array, or as a URL query
374
  * string (eg, 'user_id=4&per_page=3').
375
  *
376
- * @type int $page Which page of results to fetch. Using page=1 without
377
- * per_page will result in no pagination. Default: 1.
378
- * @type int|bool $per_page Number of results per page. Default: 20.
379
- * @type string $page_arg The string used as a query parameter in
380
- * pagination links. Default: 'bpage'.
381
- * @type int|bool $max Maximum number of results to return.
382
- * Default: false (unlimited).
383
- * @type string $type The order in which results should be fetched.
384
- * 'active', 'alphabetical', 'newest', or 'random'.
385
- * @type array $include_blog_ids Array of blog IDs to limit results to.
386
- * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
387
- * @type string $search_terms Limit results by a search term. Default: the
388
- * value of $_REQUEST['s'], if present.
389
- * @type int $user_id The ID of the user whose blogs should be retrieved.
390
- * When viewing a user profile page, 'user_id' defaults to the ID of
391
- * the displayed user. Otherwise the default is false.
392
  * }
393
  * @return bool Returns true when blogs are found, otherwise false.
394
  */
395
  function bp_has_blogs( $args = '' ) {
396
  global $blogs_template;
397
 
398
- // Check for and use search terms
399
- $search_terms = ! empty( $_REQUEST['s'] )
400
- ? $_REQUEST['s']
401
- : false;
 
 
 
 
402
 
403
  // Parse arguments
404
  $r = bp_parse_args( $args, array(
@@ -409,7 +404,7 @@ function bp_has_blogs( $args = '' ) {
409
  'max' => false,
410
  'user_id' => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of
411
  'include_blog_ids' => false,
412
- 'search_terms' => $search_terms, // Pass search terms to filter on the blog title or description.
413
  'update_meta_cache' => true
414
  ), 'has_blogs' );
415
 
@@ -424,7 +419,7 @@ function bp_has_blogs( $args = '' ) {
424
  /**
425
  * Filters whether or not there are blogs to list.
426
  *
427
- * @since BuddyPress (1.1.0)
428
  *
429
  * @param bool $value Whether or not there are blogs to list.
430
  * @param BP_Blogs_Template $blogs_template Current blogs template object.
@@ -500,7 +495,7 @@ function bp_blogs_pagination_links() {
500
  /**
501
  * Filters the blogs pagination links.
502
  *
503
- * @since BuddyPress (1.0.0)
504
  *
505
  * @param string $pag_links HTML pagination links.
506
  */
@@ -512,7 +507,7 @@ function bp_blogs_pagination_links() {
512
  *
513
  * @see bp_get_blog_avatar() for description of arguments.
514
  *
515
- * @param array $args See {@link bp_get_blog_avatar()}.
516
  */
517
  function bp_blog_avatar( $args = '' ) {
518
  echo bp_get_blog_avatar( $args );
@@ -523,21 +518,23 @@ function bp_blog_avatar( $args = '' ) {
523
  * At the moment, blog avatars are simply the user avatars of the blog
524
  * admin. Filter 'bp_get_blog_avatar_' . $blog_id to customize.
525
  *
 
 
526
  * @see bp_core_fetch_avatar() For a description of arguments and
527
  * return values.
528
  *
529
- * @param array $args {
530
  * Arguments are listed here with an explanation of their defaults.
531
  * For more information about the arguments, see
532
  * {@link bp_core_fetch_avatar()}.
533
- * @type string $alt Default: 'Profile picture of site author
534
- * [user name]'.
535
- * @type string $class Default: 'avatar'.
536
- * @type string $type Default: 'full'.
537
- * @type int|bool $width Default: false.
538
- * @type int|bool $height Default: false.
539
- * @type bool $id Currently unused.
540
- * @type bool $no_grav Default: true.
541
  * }
542
  * @return string User avatar string.
543
  */
@@ -550,21 +547,24 @@ function bp_blog_avatar( $args = '' ) {
550
  return false;
551
  }
552
 
 
 
553
  // Parse the arguments
554
  $r = bp_parse_args( $args, array(
555
  'type' => 'full',
556
  'width' => false,
557
  'height' => false,
558
  'class' => 'avatar',
 
559
  'id' => false,
560
- 'alt' => sprintf( __( 'Profile picture of site author %s', 'buddypress' ), bp_core_get_user_displayname( $blogs_template->blog->admin_user_id ) ),
561
  'no_grav' => true,
562
  ) );
563
 
564
  // Fetch the avatar
565
  $avatar = bp_core_fetch_avatar( array(
566
  'item_id' => $blogs_template->blog->admin_user_id,
567
- 'title' => $blogs_template->blog->admin_user_email,
568
  //'avatar_dir' => 'blog-avatars',
569
  //'object' => 'blog',
570
  'type' => $r['type'],
@@ -588,7 +588,7 @@ function bp_blog_avatar( $args = '' ) {
588
  /**
589
  * Filters a blog's avatar.
590
  *
591
- * @since BuddyPress (1.5.0)
592
  *
593
  * @param string $avatar Formatted HTML <img> element, or raw avatar
594
  * URL based on $html arg.
@@ -617,7 +617,7 @@ function bp_blog_permalink() {
617
  /**
618
  * Filters the blog permalink.
619
  *
620
- * @since BuddyPress (1.0.0)
621
  *
622
  * @param string $permalink Permalink URL for the blog.
623
  */
@@ -641,7 +641,7 @@ function bp_blog_name() {
641
  /**
642
  * Filters the name of the current blog in the loop.
643
  *
644
- * @since BuddyPress (1.2.0)
645
  *
646
  * @param string $name Name of the current blog in the loop.
647
  */
@@ -651,7 +651,7 @@ function bp_blog_name() {
651
  /**
652
  * Output the ID of the current blog in the loop.
653
  *
654
- * @since BuddyPress (1.7.0)
655
  */
656
  function bp_blog_id() {
657
  echo bp_get_blog_id();
@@ -659,7 +659,7 @@ function bp_blog_id() {
659
  /**
660
  * Return the ID of the current blog in the loop.
661
  *
662
- * @since BuddyPress (1.7.0)
663
  *
664
  * @return int ID of the current blog in the loop.
665
  */
@@ -669,7 +669,7 @@ function bp_blog_id() {
669
  /**
670
  * Filters the ID of the current blog in the loop.
671
  *
672
- * @since BuddyPress (1.7.0)
673
  *
674
  * @param int $blog_id ID of the current blog in the loop.
675
  */
@@ -684,7 +684,7 @@ function bp_blog_description() {
684
  /**
685
  * Filters the description of the current blog in the loop.
686
  *
687
- * @since BuddyPress (1.2.0)
688
  *
689
  * @param string $value Description of the current blog in the loop.
690
  */
@@ -701,7 +701,7 @@ function bp_blog_description() {
701
  /**
702
  * Filters the description of the current blog in the loop.
703
  *
704
- * @since BuddyPress (1.0.0)
705
  *
706
  * @param string $value Description of the current blog in the loop.
707
  */
@@ -711,7 +711,7 @@ function bp_blog_description() {
711
  /**
712
  * Output the row class of the current blog in the loop.
713
  *
714
- * @since BuddyPress (1.7.0)
715
  *
716
  * @param array $classes Array of custom classes
717
  */
@@ -721,7 +721,7 @@ function bp_blog_class( $classes = array() ) {
721
  /**
722
  * Return the row class of the current blog in the loop.
723
  *
724
- * @since BuddyPress (1.7.0)
725
  *
726
  * @global BP_Blogs_Template $blogs_template
727
  * @param array $classes Array of custom classes
@@ -744,7 +744,7 @@ function bp_blog_class( $classes = array() ) {
744
  /**
745
  * Filters the row class of the current blog in the loop.
746
  *
747
- * @since BuddyPress (1.7.0)
748
  *
749
  * @param array $classes Array of classes to be applied to row.
750
  */
@@ -768,8 +768,9 @@ function bp_blog_last_active( $args = array() ) {
768
  *
769
  * @param array $args {
770
  * Array of optional arguments.
771
- * @type bool $active_format If true, formatted "Active 5 minutes
772
- * ago". If false, formatted "5 minutes ago". Default: true.
 
773
  * }
774
  * @return string Last active date.
775
  */
@@ -823,9 +824,9 @@ function bp_blog_latest_post( $args = array() ) {
823
  *
824
  * @param array $args {
825
  * Array of optional arguments.
826
- * @type bool $latest_format If true, formatted "Latest post:
827
- * [link to post]". If false, formatted "[link to post]".
828
- * Default: true.
829
  * }
830
  * @return string $retval String of the form 'Latest Post: [link to post]'.
831
  */
@@ -844,7 +845,7 @@ function bp_blog_latest_post( $args = array() ) {
844
  /**
845
  * Filters the title text of the latest post for the current blog in loop.
846
  *
847
- * @since BuddyPress (1.0.0)
848
  *
849
  * @param string $retval Title of the latest post.
850
  */
@@ -859,7 +860,7 @@ function bp_blog_latest_post( $args = array() ) {
859
  /**
860
  * Filters the HTML markup result for the latest blog post in loop.
861
  *
862
- * @since BuddyPress (1.2.0)
863
  *
864
  * @param string $retval HTML markup for the latest post.
865
  */
@@ -869,7 +870,7 @@ function bp_blog_latest_post( $args = array() ) {
869
  /**
870
  * Output the title of the latest post on the current blog in the loop.
871
  *
872
- * @since BuddyPress (1.7.0)
873
  *
874
  * @see bp_get_blog_latest_post_title()
875
  */
@@ -879,7 +880,7 @@ function bp_blog_latest_post_title() {
879
  /**
880
  * Return the title of the latest post on the current blog in the loop.
881
  *
882
- * @since BuddyPress (1.7.0)
883
  *
884
  * @global BP_Blogs_Template
885
  *
@@ -896,7 +897,7 @@ function bp_blog_latest_post_title() {
896
  /**
897
  * Filters the title text of the latest post on the current blog in the loop.
898
  *
899
- * @since BuddyPress (1.7.0)
900
  *
901
  * @param string $retval Title text for the latest post.
902
  */
@@ -906,7 +907,7 @@ function bp_blog_latest_post_title() {
906
  /**
907
  * Output the permalink of the latest post on the current blog in the loop.
908
  *
909
- * @since BuddyPress (1.7.0)
910
  *
911
  * @see bp_get_blog_latest_post_title()
912
  */
@@ -916,7 +917,7 @@ function bp_blog_latest_post_permalink() {
916
  /**
917
  * Return the permalink of the latest post on the current blog in the loop.
918
  *
919
- * @since BuddyPress (1.7.0)
920
  *
921
  * @global BP_Blogs_Template
922
  *
@@ -933,7 +934,7 @@ function bp_blog_latest_post_permalink() {
933
  /**
934
  * Filters the permalink of the latest post on the current blog in the loop.
935
  *
936
- * @since BuddyPress (1.7.0)
937
  *
938
  * @param string $retval Permalink URL of the latest post.
939
  */
@@ -943,7 +944,7 @@ function bp_blog_latest_post_permalink() {
943
  /**
944
  * Output the content of the latest post on the current blog in the loop.
945
  *
946
- * @since BuddyPress (1.7.0)
947
  *
948
  * @uses bp_get_blog_latest_post_content()
949
  */
@@ -953,7 +954,7 @@ function bp_blog_latest_post_content() {
953
  /**
954
  * Return the content of the latest post on the current blog in the loop.
955
  *
956
- * @since BuddyPress (1.7.0)
957
  *
958
  * @global BP_Blogs_Template
959
  *
@@ -970,7 +971,7 @@ function bp_blog_latest_post_content() {
970
  /**
971
  * Filters the content of the latest post on the current blog in the loop.
972
  *
973
- * @since BuddyPress (1.7.0)
974
  *
975
  * @param string $retval Content of the latest post on the current blog in the loop.
976
  */
@@ -980,7 +981,7 @@ function bp_blog_latest_post_content() {
980
  /**
981
  * Output the featured image of the latest post on the current blog in the loop.
982
  *
983
- * @since BuddyPress (1.7.0)
984
  *
985
  * @see bp_get_blog_latest_post_content() For description of parameters.
986
  *
@@ -992,12 +993,13 @@ function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
992
  /**
993
  * Return the featured image of the latest post on the current blog in the loop.
994
  *
995
- * @since BuddyPress (1.7.0)
996
  *
997
  * @global BP_Blogs_Template
998
  *
999
  * @param string $size Image version to return. 'thumbnail', 'medium',
1000
- * 'large', or 'post-thumbnail'. Default: 'thumbnail'.
 
1001
  * @return string URL of the image.
1002
  */
1003
  function bp_get_blog_latest_post_featured_image( $size = 'thumbnail' ) {
@@ -1011,7 +1013,7 @@ function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
1011
  /**
1012
  * Filters the featured image of the latest post on the current blog in the loop.
1013
  *
1014
- * @since BuddyPress (1.7.0)
1015
  *
1016
  * @param string $retval The featured image of the latest post on the current blog in the loop.
1017
  */
@@ -1021,12 +1023,13 @@ function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
1021
  /**
1022
  * Does the latest blog post have a featured image?
1023
  *
1024
- * @since BuddyPress (1.7.0)
 
 
 
1025
  *
1026
- * @param string $size Image version to return. 'thumbnail', 'medium', 'large',
1027
- * or 'post-thumbnail'. Default: 'thumbnail'.
1028
  * @return bool True if the latest blog post from the current blog has a
1029
- * featured image of the given size.
1030
  */
1031
  function bp_blog_latest_post_has_featured_image( $thumbnail = 'thumbnail' ) {
1032
  $image = bp_get_blog_latest_post_featured_image( $thumbnail );
@@ -1034,7 +1037,7 @@ function bp_blog_latest_post_has_featured_image( $thumbnail = 'thumbnail' ) {
1034
  /**
1035
  * Filters whether or not the latest blog post has a featured image.
1036
  *
1037
- * @since BuddyPress (1.7.0)
1038
  *
1039
  * @param bool $value Whether or not the latest blog post has a featured image.
1040
  * @param string $thumbnail Image version to return.
@@ -1077,7 +1080,7 @@ function bp_total_blog_count() {
1077
  /**
1078
  * Filters the total number of blogs on the site.
1079
  *
1080
- * @since BuddyPress (1.2.0)
1081
  *
1082
  * @param int $value Total number of blogs on the site.
1083
  */
@@ -1097,6 +1100,7 @@ function bp_total_blog_count_for_user( $user_id = 0 ) {
1097
  * Return the total number of blogs for a given user.
1098
  *
1099
  * @param int $user_id ID of the user.
 
1100
  * @return int Total number of blogs for the user.
1101
  */
1102
  function bp_get_total_blog_count_for_user( $user_id = 0 ) {
@@ -1104,7 +1108,7 @@ function bp_total_blog_count_for_user( $user_id = 0 ) {
1104
  /**
1105
  * Filters the total number of blogs for a given user.
1106
  *
1107
- * @since BuddyPress (1.2.0)
1108
  *
1109
  * @param int $value Total number of blogs for a given user.
1110
  */
@@ -1133,7 +1137,7 @@ function bp_blog_signup_enabled() {
1133
  /**
1134
  * Filters whether or not blog creation is enabled.
1135
  *
1136
- * @since BuddyPress (1.0.0)
1137
  *
1138
  * @param string $active_signup Value of the registration site option creation status.
1139
  */
@@ -1148,10 +1152,10 @@ function bp_blog_signup_enabled() {
1148
  /**
1149
  * Output the wrapper markup for the blog signup form.
1150
  *
1151
- * @param string $blogname Optional. The default blog name (path or domain).
1152
- * @param string $blog_title Optional. The default blog title.
1153
- * @param string|WP_Error Optional. The WP_Error object returned by a previous
1154
- * submission attempt.
1155
  */
1156
  function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') {
1157
  global $current_user;
@@ -1166,7 +1170,7 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
1166
  /**
1167
  * Filters the default values for Blog name, title, and any current errors.
1168
  *
1169
- * @since BuddyPress (1.0.0)
1170
  *
1171
  * @param array $value {
1172
  * string $blogname Default blog name provided.
@@ -1195,7 +1199,7 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
1195
  /**
1196
  * Fires after the default hidden fields in blog signup form markup.
1197
  *
1198
- * @since BuddyPress (1.0.0)
1199
  */
1200
  do_action( 'signup_hidden_fields' ); ?>
1201
 
@@ -1213,10 +1217,10 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
1213
  /**
1214
  * Output the input fields for the blog creation form.
1215
  *
1216
- * @param string $blogname Optional. The default blog name (path or domain).
1217
- * @param string $blog_title Optional. The default blog title.
1218
- * @param string|WP_Error Optional. The WP_Error object returned by a previous
1219
- * submission attempt.
1220
  */
1221
  function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
1222
  global $current_site;
@@ -1282,7 +1286,7 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
1282
  /**
1283
  * Fires at the end of all of the default input fields for blog creation form.
1284
  *
1285
- * @since BuddyPress (1.0.0)
1286
  *
1287
  * @param WP_Error $errors WP_Error object if any present.
1288
  */
@@ -1323,11 +1327,11 @@ function bp_blogs_validate_blog_signup() {
1323
  /**
1324
  * Filters the default values for Blog meta.
1325
  *
1326
- * @since BuddyPress (1.0.0)
1327
  *
1328
  * @param array $meta {
1329
- * string $value Default blog language ID.
1330
- * string $public Default public status.
1331
  * }
1332
  */
1333
  $meta = apply_filters( 'add_signup_meta', $meta );
@@ -1359,12 +1363,12 @@ function bp_blogs_validate_blog_form() {
1359
  /**
1360
  * Display a message after successful blog registration.
1361
  *
1362
- * @param string $domain The new blog's domain.
1363
- * @param string $path The new blog's path.
1364
- * @param string $blog_title The new blog's title.
1365
- * @param string $user_name The user name of the user who created the blog. Unused.
1366
- * @param string $user_email The email of the user who created the blog. Unused.
1367
- * @param string|array $meta Meta values associated with the new blog. Unused.
1368
  */
1369
  function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = '' ) {
1370
  $protocol = is_ssl() ? 'https://' : 'http://';
@@ -1380,7 +1384,7 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
1380
  /**
1381
  * Fires after the default successful blog registration message markup.
1382
  *
1383
- * @since BuddyPress (1.0.0)
1384
  */
1385
  do_action('signup_finished');
1386
  }
@@ -1401,7 +1405,7 @@ function bp_create_blog_link() {
1401
  /**
1402
  * Filters "Create a Site" links for users viewing their own profiles.
1403
  *
1404
- * @since BuddyPress (1.0.0)
1405
  *
1406
  * @param string $value HTML link for creating a site.
1407
  */
@@ -1431,7 +1435,7 @@ function bp_blogs_blog_tabs() {
1431
  /**
1432
  * Fires after the markup for the navigation tabs for a user Blogs page.
1433
  *
1434
- * @since BuddyPress (1.0.0)
1435
  */
1436
  do_action( 'bp_blogs_blog_tabs' );
1437
  }
@@ -1440,18 +1444,24 @@ function bp_blogs_blog_tabs() {
1440
  * Output the blog directory search form.
1441
  */
1442
  function bp_directory_blogs_search_form() {
1443
- $default_search_value = bp_get_search_default_text();
1444
- $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
 
 
 
 
 
 
1445
 
1446
  $search_form_html = '<form action="" method="get" id="search-blogs-form">
1447
- <label><input type="text" name="s" id="blogs_search" placeholder="'. esc_attr( $search_value ) .'" /></label>
1448
  <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
1449
  </form>';
1450
 
1451
  /**
1452
  * Filters the output for the blog directory search form.
1453
  *
1454
- * @since BuddyPress (1.9.0)
1455
  *
1456
  * @param string $search_form_html HTML markup for blog directory search form.
1457
  */
@@ -1461,7 +1471,7 @@ function bp_directory_blogs_search_form() {
1461
  /**
1462
  * Output the Create a Site button.
1463
  *
1464
- * @since BuddyPress (2.0.0)
1465
  */
1466
  function bp_blog_create_button() {
1467
  echo bp_get_blog_create_button();
@@ -1469,7 +1479,7 @@ function bp_blog_create_button() {
1469
  /**
1470
  * Get the Create a Site button.
1471
  *
1472
- * @since BuddyPress (2.0.0)
1473
  *
1474
  * @return string
1475
  */
@@ -1496,7 +1506,7 @@ function bp_blog_create_button() {
1496
  /**
1497
  * Filters the Create a Site button.
1498
  *
1499
- * @since BuddyPress (2.0.0)
1500
  *
1501
  * @param array $button_args Array of arguments to be used for the Create a Site button.
1502
  */
@@ -1506,7 +1516,7 @@ function bp_blog_create_button() {
1506
  /**
1507
  * Output the Create a Site nav item.
1508
  *
1509
- * @since BuddyPress (2.2.0)
1510
  */
1511
  function bp_blog_create_nav_item() {
1512
  echo bp_get_blog_create_nav_item();
@@ -1515,7 +1525,7 @@ function bp_blog_create_nav_item() {
1515
  /**
1516
  * Get the Create a Site nav item.
1517
  *
1518
- * @since BuddyPress (2.2.0)
1519
  *
1520
  * @return string
1521
  */
@@ -1537,9 +1547,10 @@ function bp_blog_create_nav_item() {
1537
  * Checks if a specific theme is still filtering the Blogs directory title
1538
  * if so, transform the title button into a Blogs directory nav item.
1539
  *
1540
- * @since BuddyPress (2.2.0)
 
 
1541
  *
1542
- * @uses bp_blog_create_nav_item() to output the Create a Site nav item
1543
  * @return string HTML Output
1544
  */
1545
  function bp_blog_backcompat_create_nav_item() {
@@ -1562,7 +1573,7 @@ add_action( 'bp_blogs_directory_blog_types', 'bp_blog_backcompat_create_nav_item
1562
  *
1563
  * @see bp_get_blogs_visit_blog_button() for description of arguments.
1564
  *
1565
- * @param array $args See {@link bp_get_blogs_visit_blog_button()}.
1566
  */
1567
  function bp_blogs_visit_blog_button( $args = '' ) {
1568
  echo bp_get_blogs_visit_blog_button( $args );
@@ -1573,18 +1584,18 @@ function bp_blogs_visit_blog_button( $args = '' ) {
1573
  * @see BP_Button for a complete description of arguments and return
1574
  * value.
1575
  *
1576
- * @param array $args {
1577
  * Arguments are listed below, with their default values. For a
1578
  * complete description of arguments, see {@link BP_Button}.
1579
- * @type string $id Default: 'visit_blog'.
1580
- * @type string $component Default: 'blogs'.
1581
- * @type bool $must_be_logged_in Default: false.
1582
- * @type bool $block_self Default: false.
1583
- * @type string $wrapper_class Default: 'blog-button visit'.
1584
- * @type string $link_href Permalink of the current blog in the loop.
1585
- * @type string $link_class Default: 'blog-button visit'.
1586
- * @type string $link_text Default: 'Visit Site'.
1587
- * @type string $link_title Default: 'Visit Site'.
1588
  * }
1589
  * @return string The HTML for the Visit button.
1590
  */
@@ -1606,7 +1617,7 @@ function bp_blogs_visit_blog_button( $args = '' ) {
1606
  /**
1607
  * Filters the button for visiting a blog in a loop.
1608
  *
1609
- * @since BuddyPress (1.2.10)
1610
  *
1611
  * @param array $button Array of arguments to be used for the button to visit a blog.
1612
  */
@@ -1618,10 +1629,11 @@ function bp_blogs_visit_blog_button( $args = '' ) {
1618
  /**
1619
  * Display the number of blogs in user's profile.
1620
  *
1621
- * @since BuddyPress (2.0.0)
1622
  *
1623
- * @param array $args before|after|user_id
1624
- * @uses bp_blogs_admin_get_profile_stats() to get the stats
 
1625
  */
1626
  function bp_blogs_profile_stats( $args = '' ) {
1627
  echo bp_blogs_get_profile_stats( $args );
@@ -1631,9 +1643,10 @@ add_action( 'bp_members_admin_user_stats', 'bp_blogs_profile_stats', 9, 1 );
1631
  /**
1632
  * Return the number of blogs in user's profile.
1633
  *
1634
- * @since BuddyPress (2.0.0)
 
 
1635
  *
1636
- * @param array $args before|after|user_id
1637
  * @return string HTML for stats output.
1638
  */
1639
  function bp_blogs_get_profile_stats( $args = '' ) {
@@ -1666,7 +1679,7 @@ function bp_blogs_get_profile_stats( $args = '' ) {
1666
  /**
1667
  * Filters the number of blogs in user's profile.
1668
  *
1669
- * @since BuddyPress (2.0.0)
1670
  *
1671
  * @param string $value Output determined for the profile stats.
1672
  * @param array $r Array of arguments used for default output if none provided.
1
  <?php
 
2
  /**
3
  * BuddyPress Blogs Template Tags.
4
  *
6
  * @subpackage BlogsTemplate
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Output the blogs component slug.
14
  *
15
+ * @since 1.5.0
16
  *
17
  * @uses bp_get_blogs_slug()
18
  */
22
  /**
23
  * Return the blogs component slug.
24
  *
25
+ * @since 1.5.0
26
  *
27
  * @return string The 'blogs' slug.
28
  */
31
  /**
32
  * Filters the blogs component slug.
33
  *
34
+ * @since 1.5.0
35
  *
36
  * @param string $slug Slug for the blogs component.
37
  */
41
  /**
42
  * Output the blogs component root slug.
43
  *
44
+ * @since 1.5.0
45
  *
46
  * @uses bp_get_blogs_root_slug()
47
  */
51
  /**
52
  * Return the blogs component root slug.
53
  *
54
+ * @since 1.5.0
55
  *
56
  * @return string The 'blogs' root slug.
57
  */
60
  /**
61
  * Filters the blogs component root slug.
62
  *
63
+ * @since 1.5.0
64
  *
65
  * @param string $root_slug Root slug for the blogs component.
66
  */
70
  /**
71
  * Output blog directory permalink.
72
  *
73
+ * @since 1.5.0
74
  *
75
  * @uses bp_get_blogs_directory_permalink()
76
  */
80
  /**
81
  * Return blog directory permalink.
82
  *
83
+ * @since 1.5.0
84
  *
85
  * @uses apply_filters()
86
  * @uses trailingslashit()
87
  * @uses bp_get_root_domain()
88
  * @uses bp_get_blogs_root_slug()
89
+ *
90
  * @return string The URL of the Blogs directory.
91
  */
92
  function bp_get_blogs_directory_permalink() {
94
  /**
95
  * Filters the blog directory permalink.
96
  *
97
+ * @since 1.5.0
98
  *
99
  * @param string $value Permalink URL for the blog directory.
100
  */
111
  /**
112
  * The loop iterator.
113
  *
 
114
  * @var int
115
  */
116
  public $current_blog = -1;
118
  /**
119
  * The number of blogs returned by the paged query.
120
  *
 
121
  * @var int
122
  */
123
  public $blog_count = 0;
125
  /**
126
  * Array of blogs located by the query..
127
  *
 
128
  * @var array
129
  */
130
  public $blogs = array();
132
  /**
133
  * The blog object currently being iterated on.
134
  *
 
135
  * @var object
136
  */
137
  public $blog;
139
  /**
140
  * A flag for whether the loop is currently being iterated.
141
  *
 
142
  * @var bool
143
  */
144
  public $in_the_loop = false;
146
  /**
147
  * The page number being requested.
148
  *
149
+ * @var int
 
150
  */
151
  public $pag_page = 1;
152
 
153
  /**
154
  * The number of items being requested per page.
155
  *
156
+ * @var int
 
157
  */
158
  public $pag_num = 20;
159
 
160
  /**
161
  * An HTML string containing pagination links.
162
  *
 
163
  * @var string
164
  */
165
  public $pag_links = '';
167
  /**
168
  * The total number of blogs matching the query parameters.
169
  *
 
170
  * @var int
171
  */
172
  public $total_blog_count = 0;
176
  *
177
  * @see BP_Blogs_Blog::get() for a description of parameters.
178
  *
179
+ * @param string $type See {@link BP_Blogs_Blog::get()}.
180
+ * @param string $page See {@link BP_Blogs_Blog::get()}.
181
+ * @param string $per_page See {@link BP_Blogs_Blog::get()}.
182
+ * @param string $max See {@link BP_Blogs_Blog::get()}.
183
+ * @param string $user_id See {@link BP_Blogs_Blog::get()}.
184
+ * @param string $search_terms See {@link BP_Blogs_Blog::get()}.
185
+ * @param string $page_arg The string used as a query parameter in
186
+ * pagination links. Default: 'bpage'.
187
+ * @param bool $update_meta_cache Whether to pre-fetch metadata for
188
+ * queried blogs.
189
+ * @param array|bool $include_blog_ids Array of blog IDs to include.
190
  */
191
  public function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) {
192
 
298
  /**
299
  * Fires right before the rewinding of blogs listing after all are shown.
300
  *
301
+ * @since 1.5.0
302
  */
303
  do_action( 'blog_loop_end' );
304
  // Do some cleaning up after the loop
329
  /**
330
  * Fires if on the first blog in the loop.
331
  *
332
+ * @since 1.5.0
333
  */
334
  do_action( 'blog_loop_start' );
335
  }
354
  *
355
  * @global object $blogs_template {@link BP_Blogs_Template}
356
  *
357
+ * @param array|string $args {
358
  * Arguments for limiting the contents of the blogs loop. Most arguments
359
  * are in the same format as {@link BP_Blogs_Blog::get()}. However, because
360
  * the format of the arguments accepted here differs in a number of ways,
364
  * Arguments can be passed as an associative array, or as a URL query
365
  * string (eg, 'user_id=4&per_page=3').
366
  *
367
+ * @type int $page Which page of results to fetch. Using page=1 without
368
+ * per_page will result in no pagination. Default: 1.
369
+ * @type int|bool $per_page Number of results per page. Default: 20.
370
+ * @type string $page_arg The string used as a query parameter in
371
+ * pagination links. Default: 'bpage'.
372
+ * @type int|bool $max Maximum number of results to return.
373
+ * Default: false (unlimited).
374
+ * @type string $type The order in which results should be fetched.
375
+ * 'active', 'alphabetical', 'newest', or 'random'.
376
+ * @type array $include_blog_ids Array of blog IDs to limit results to.
377
+ * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
378
+ * @type string $search_terms Limit results by a search term. Default: the value of `$_REQUEST['s']` or
379
+ * `$_REQUEST['sites_search']`, if present.
380
+ * @type int $user_id The ID of the user whose blogs should be retrieved.
381
+ * When viewing a user profile page, 'user_id' defaults to the
382
+ * ID of the displayed user. Otherwise the default is false.
383
  * }
384
  * @return bool Returns true when blogs are found, otherwise false.
385
  */
386
  function bp_has_blogs( $args = '' ) {
387
  global $blogs_template;
388
 
389
+ // Check for and use search terms.
390
+ $search_terms_default = false;
391
+ $search_query_arg = bp_core_get_component_search_query_arg( 'blogs' );
392
+ if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) {
393
+ $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] );
394
+ } elseif ( ! empty( $_REQUEST['s'] ) ) {
395
+ $search_terms_default = stripslashes( $_REQUEST['s'] );
396
+ }
397
 
398
  // Parse arguments
399
  $r = bp_parse_args( $args, array(
404
  'max' => false,
405
  'user_id' => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of
406
  'include_blog_ids' => false,
407
+ 'search_terms' => $search_terms_default,
408
  'update_meta_cache' => true
409
  ), 'has_blogs' );
410
 
419
  /**
420
  * Filters whether or not there are blogs to list.
421
  *
422
+ * @since 1.1.0
423
  *
424
  * @param bool $value Whether or not there are blogs to list.
425
  * @param BP_Blogs_Template $blogs_template Current blogs template object.
495
  /**
496
  * Filters the blogs pagination links.
497
  *
498
+ * @since 1.0.0
499
  *
500
  * @param string $pag_links HTML pagination links.
501
  */
507
  *
508
  * @see bp_get_blog_avatar() for description of arguments.
509
  *
510
+ * @param array|string $args See {@link bp_get_blog_avatar()}.
511
  */
512
  function bp_blog_avatar( $args = '' ) {
513
  echo bp_get_blog_avatar( $args );
518
  * At the moment, blog avatars are simply the user avatars of the blog
519
  * admin. Filter 'bp_get_blog_avatar_' . $blog_id to customize.
520
  *
521
+ * @since 2.4.0 Introduced `$title` argument.
522
+ *
523
  * @see bp_core_fetch_avatar() For a description of arguments and
524
  * return values.
525
  *
526
+ * @param array|string $args {
527
  * Arguments are listed here with an explanation of their defaults.
528
  * For more information about the arguments, see
529
  * {@link bp_core_fetch_avatar()}.
530
+ * @type string $alt Default: 'Profile picture of site author [user name]'.
531
+ * @type string $class Default: 'avatar'.
532
+ * @type string $title Default: 'Profile picture of site author [user name]'.
533
+ * @type string $type Default: 'full'.
534
+ * @type int|bool $width Default: false.
535
+ * @type int|bool $height Default: false.
536
+ * @type bool $id Currently unused.
537
+ * @type bool $no_grav Default: true.
538
  * }
539
  * @return string User avatar string.
540
  */
547
  return false;
548
  }
549
 
550
+ $author_displayname = bp_core_get_user_displayname( $blogs_template->blog->admin_user_id );
551
+
552
  // Parse the arguments
553
  $r = bp_parse_args( $args, array(
554
  'type' => 'full',
555
  'width' => false,
556
  'height' => false,
557
  'class' => 'avatar',
558
+ 'title' => sprintf( __( 'Profile picture of site author %s', 'buddypress' ), esc_attr( $author_displayname ) ),
559
  'id' => false,
560
+ 'alt' => sprintf( __( 'Profile picture of site author %s', 'buddypress' ), esc_attr( $author_displayname ) ),
561
  'no_grav' => true,
562
  ) );
563
 
564
  // Fetch the avatar
565
  $avatar = bp_core_fetch_avatar( array(
566
  'item_id' => $blogs_template->blog->admin_user_id,
567
+ 'title' => $r['title'],
568
  //'avatar_dir' => 'blog-avatars',
569
  //'object' => 'blog',
570
  'type' => $r['type'],
588
  /**
589
  * Filters a blog's avatar.
590
  *
591
+ * @since 1.5.0
592
  *
593
  * @param string $avatar Formatted HTML <img> element, or raw avatar
594
  * URL based on $html arg.
617
  /**
618
  * Filters the blog permalink.
619
  *
620
+ * @since 1.0.0
621
  *
622
  * @param string $permalink Permalink URL for the blog.
623
  */
641
  /**
642
  * Filters the name of the current blog in the loop.
643
  *
644
+ * @since 1.2.0
645
  *
646
  * @param string $name Name of the current blog in the loop.
647
  */
651
  /**
652
  * Output the ID of the current blog in the loop.
653
  *
654
+ * @since 1.7.0
655
  */
656
  function bp_blog_id() {
657
  echo bp_get_blog_id();
659
  /**
660
  * Return the ID of the current blog in the loop.
661
  *
662
+ * @since 1.7.0
663
  *
664
  * @return int ID of the current blog in the loop.
665
  */
669
  /**
670
  * Filters the ID of the current blog in the loop.
671
  *
672
+ * @since 1.7.0
673
  *
674
  * @param int $blog_id ID of the current blog in the loop.
675
  */
684
  /**
685
  * Filters the description of the current blog in the loop.
686
  *
687
+ * @since 1.2.0
688
  *
689
  * @param string $value Description of the current blog in the loop.
690
  */
701
  /**
702
  * Filters the description of the current blog in the loop.
703
  *
704
+ * @since 1.0.0
705
  *
706
  * @param string $value Description of the current blog in the loop.
707
  */
711
  /**
712
  * Output the row class of the current blog in the loop.
713
  *
714
+ * @since 1.7.0
715
  *
716
  * @param array $classes Array of custom classes
717
  */
721
  /**
722
  * Return the row class of the current blog in the loop.
723
  *
724
+ * @since 1.7.0
725
  *
726
  * @global BP_Blogs_Template $blogs_template
727
  * @param array $classes Array of custom classes
744
  /**
745
  * Filters the row class of the current blog in the loop.
746
  *
747
+ * @since 1.7.0
748
  *
749
  * @param array $classes Array of classes to be applied to row.
750
  */
768
  *
769
  * @param array $args {
770
  * Array of optional arguments.
771
+ * @type bool $active_format If true, formatted "Active 5 minutes ago".
772
+ * If false, formatted "5 minutes ago".
773
+ * Default: true.
774
  * }
775
  * @return string Last active date.
776
  */
824
  *
825
  * @param array $args {
826
  * Array of optional arguments.
827
+ * @type bool $latest_format If true, formatted "Latest post: [link to post]".
828
+ * If false, formatted "[link to post]".
829
+ * Default: true.
830
  * }
831
  * @return string $retval String of the form 'Latest Post: [link to post]'.
832
  */
845
  /**
846
  * Filters the title text of the latest post for the current blog in loop.
847
  *
848
+ * @since 1.0.0
849
  *
850
  * @param string $retval Title of the latest post.
851
  */
860
  /**
861
  * Filters the HTML markup result for the latest blog post in loop.
862
  *
863
+ * @since 1.2.0
864
  *
865
  * @param string $retval HTML markup for the latest post.
866
  */
870
  /**
871
  * Output the title of the latest post on the current blog in the loop.
872
  *
873
+ * @since 1.7.0
874
  *
875
  * @see bp_get_blog_latest_post_title()
876
  */
880
  /**
881
  * Return the title of the latest post on the current blog in the loop.
882
  *
883
+ * @since 1.7.0
884
  *
885
  * @global BP_Blogs_Template
886
  *
897
  /**
898
  * Filters the title text of the latest post on the current blog in the loop.
899
  *
900
+ * @since 1.7.0
901
  *
902
  * @param string $retval Title text for the latest post.
903
  */
907
  /**
908
  * Output the permalink of the latest post on the current blog in the loop.
909
  *
910
+ * @since 1.7.0
911
  *
912
  * @see bp_get_blog_latest_post_title()
913
  */
917
  /**
918
  * Return the permalink of the latest post on the current blog in the loop.
919
  *
920
+ * @since 1.7.0
921
  *
922
  * @global BP_Blogs_Template
923
  *
934
  /**
935
  * Filters the permalink of the latest post on the current blog in the loop.
936
  *
937
+ * @since 1.7.0
938
  *
939
  * @param string $retval Permalink URL of the latest post.
940
  */
944
  /**
945
  * Output the content of the latest post on the current blog in the loop.
946
  *
947
+ * @since 1.7.0
948
  *
949
  * @uses bp_get_blog_latest_post_content()
950
  */
954
  /**
955
  * Return the content of the latest post on the current blog in the loop.
956
  *
957
+ * @since 1.7.0
958
  *
959
  * @global BP_Blogs_Template
960
  *
971
  /**
972
  * Filters the content of the latest post on the current blog in the loop.
973
  *
974
+ * @since 1.7.0
975
  *
976
  * @param string $retval Content of the latest post on the current blog in the loop.
977
  */
981
  /**
982
  * Output the featured image of the latest post on the current blog in the loop.
983
  *
984
+ * @since 1.7.0
985
  *
986
  * @see bp_get_blog_latest_post_content() For description of parameters.
987
  *
993
  /**
994
  * Return the featured image of the latest post on the current blog in the loop.
995
  *
996
+ * @since 1.7.0
997
  *
998
  * @global BP_Blogs_Template
999
  *
1000
  * @param string $size Image version to return. 'thumbnail', 'medium',
1001
+ * 'large', or 'post-thumbnail'. Default: 'thumbnail'.
1002
+ *
1003
  * @return string URL of the image.
1004
  */
1005
  function bp_get_blog_latest_post_featured_image( $size = 'thumbnail' ) {
1013
  /**
1014
  * Filters the featured image of the latest post on the current blog in the loop.
1015
  *
1016
+ * @since 1.7.0
1017
  *
1018
  * @param string $retval The featured image of the latest post on the current blog in the loop.
1019
  */
1023
  /**
1024
  * Does the latest blog post have a featured image?
1025
  *
1026
+ * @since 1.7.0
1027
+ *
1028
+ * @param string $thumbnail Image version to return. 'thumbnail', 'medium', 'large',
1029
+ * or 'post-thumbnail'. Default: 'thumbnail'.
1030
  *
 
 
1031
  * @return bool True if the latest blog post from the current blog has a
1032
+ * featured image of the given size.
1033
  */
1034
  function bp_blog_latest_post_has_featured_image( $thumbnail = 'thumbnail' ) {
1035
  $image = bp_get_blog_latest_post_featured_image( $thumbnail );
1037
  /**
1038
  * Filters whether or not the latest blog post has a featured image.
1039
  *
1040
+ * @since 1.7.0
1041
  *
1042
  * @param bool $value Whether or not the latest blog post has a featured image.
1043
  * @param string $thumbnail Image version to return.
1080
  /**
1081
  * Filters the total number of blogs on the site.
1082
  *
1083
+ * @since 1.2.0
1084
  *
1085
  * @param int $value Total number of blogs on the site.
1086
  */
1100
  * Return the total number of blogs for a given user.
1101
  *
1102
  * @param int $user_id ID of the user.
1103
+ *
1104
  * @return int Total number of blogs for the user.
1105
  */
1106
  function bp_get_total_blog_count_for_user( $user_id = 0 ) {
1108
  /**
1109
  * Filters the total number of blogs for a given user.
1110
  *
1111
+ * @since 1.2.0
1112
  *
1113
  * @param int $value Total number of blogs for a given user.
1114
  */
1137
  /**
1138
  * Filters whether or not blog creation is enabled.
1139
  *
1140
+ * @since 1.0.0
1141
  *
1142
  * @param string $active_signup Value of the registration site option creation status.
1143
  */
1152
  /**
1153
  * Output the wrapper markup for the blog signup form.
1154
  *
1155
+ * @param string $blogname Optional. The default blog name (path or domain).
1156
+ * @param string $blog_title Optional. The default blog title.
1157
+ * @param string|WP_Error $errors Optional. The WP_Error object returned by a previous
1158
+ * submission attempt.
1159
  */
1160
  function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') {
1161
  global $current_user;
1170
  /**
1171
  * Filters the default values for Blog name, title, and any current errors.
1172
  *
1173
+ * @since 1.0.0
1174
  *
1175
  * @param array $value {
1176
  * string $blogname Default blog name provided.
1199
  /**
1200
  * Fires after the default hidden fields in blog signup form markup.
1201
  *
1202
+ * @since 1.0.0
1203
  */
1204
  do_action( 'signup_hidden_fields' ); ?>
1205
 
1217
  /**
1218
  * Output the input fields for the blog creation form.
1219
  *
1220
+ * @param string $blogname Optional. The default blog name (path or domain).
1221
+ * @param string $blog_title Optional. The default blog title.
1222
+ * @param string|WP_Error $errors Optional. The WP_Error object returned by a previous
1223
+ * submission attempt.
1224
  */
1225
  function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
1226
  global $current_site;
1286
  /**
1287
  * Fires at the end of all of the default input fields for blog creation form.
1288
  *
1289
+ * @since 1.0.0
1290
  *
1291
  * @param WP_Error $errors WP_Error object if any present.
1292
  */
1327
  /**
1328
  * Filters the default values for Blog meta.
1329
  *
1330
+ * @since 1.0.0
1331
  *
1332
  * @param array $meta {
1333
+ * string $value Default blog language ID.
1334
+ * string $public Default public status.
1335
  * }
1336
  */
1337
  $meta = apply_filters( 'add_signup_meta', $meta );
1363
  /**
1364
  * Display a message after successful blog registration.
1365
  *
1366
+ * @param string $domain The new blog's domain.
1367
+ * @param string $path The new blog's path.
1368
+ * @param string $blog_title The new blog's title.
1369
+ * @param string $user_name The user name of the user who created the blog. Unused.
1370
+ * @param string $user_email The email of the user who created the blog. Unused.
1371
+ * @param string|array $meta Meta values associated with the new blog. Unused.
1372
  */
1373
  function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = '' ) {
1374
  $protocol = is_ssl() ? 'https://' : 'http://';
1384
  /**
1385
  * Fires after the default successful blog registration message markup.
1386
  *
1387
+ * @since 1.0.0
1388
  */
1389
  do_action('signup_finished');
1390
  }
1405
  /**
1406
  * Filters "Create a Site" links for users viewing their own profiles.
1407
  *
1408
+ * @since 1.0.0
1409
  *
1410
  * @param string $value HTML link for creating a site.
1411
  */
1435
  /**
1436
  * Fires after the markup for the navigation tabs for a user Blogs page.
1437
  *
1438
+ * @since 1.0.0
1439
  */
1440
  do_action( 'bp_blogs_blog_tabs' );
1441
  }
1444
  * Output the blog directory search form.
1445
  */
1446
  function bp_directory_blogs_search_form() {
1447
+
1448
+ $query_arg = bp_core_get_component_search_query_arg( 'blogs' );
1449
+
1450
+ if ( ! empty( $_REQUEST[ $query_arg ] ) ) {
1451
+ $search_value = stripslashes( $_REQUEST[ $query_arg ] );
1452
+ } else {
1453
+ $search_value = bp_get_search_default_text( 'blogs' );
1454
+ }
1455
 
1456
  $search_form_html = '<form action="" method="get" id="search-blogs-form">
1457
+ <label for="blogs_search"><input type="text" name="' . esc_attr( $query_arg ) . '" id="blogs_search" placeholder="'. esc_attr( $search_value ) .'" /></label>
1458
  <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
1459
  </form>';
1460
 
1461
  /**
1462
  * Filters the output for the blog directory search form.
1463
  *
1464
+ * @since 1.9.0
1465
  *
1466
  * @param string $search_form_html HTML markup for blog directory search form.
1467
  */
1471
  /**
1472
  * Output the Create a Site button.
1473
  *
1474
+ * @since 2.0.0
1475
  */
1476
  function bp_blog_create_button() {
1477
  echo bp_get_blog_create_button();
1479
  /**
1480
  * Get the Create a Site button.
1481
  *
1482
+ * @since 2.0.0
1483
  *
1484
  * @return string
1485
  */
1506
  /**
1507
  * Filters the Create a Site button.
1508
  *
1509
+ * @since 2.0.0
1510
  *
1511
  * @param array $button_args Array of arguments to be used for the Create a Site button.
1512
  */
1516
  /**
1517
  * Output the Create a Site nav item.
1518
  *
1519
+ * @since 2.2.0
1520
  */
1521
  function bp_blog_create_nav_item() {
1522
  echo bp_get_blog_create_nav_item();
1525
  /**
1526
  * Get the Create a Site nav item.
1527
  *
1528
+ * @since 2.2.0
1529
  *
1530
  * @return string
1531
  */
1547
  * Checks if a specific theme is still filtering the Blogs directory title
1548
  * if so, transform the title button into a Blogs directory nav item.
1549
  *
1550
+ * @since 2.2.0
1551
+ *
1552
+ * @uses bp_blog_create_nav_item() to output the Create a Site nav item.
1553
  *
 
1554
  * @return string HTML Output
1555
  */
1556
  function bp_blog_backcompat_create_nav_item() {
1573
  *
1574
  * @see bp_get_blogs_visit_blog_button() for description of arguments.
1575
  *
1576
+ * @param array|string $args See {@link bp_get_blogs_visit_blog_button()}.
1577
  */
1578
  function bp_blogs_visit_blog_button( $args = '' ) {
1579
  echo bp_get_blogs_visit_blog_button( $args );
1584
  * @see BP_Button for a complete description of arguments and return
1585
  * value.
1586
  *
1587
+ * @param array|string $args {
1588
  * Arguments are listed below, with their default values. For a
1589
  * complete description of arguments, see {@link BP_Button}.
1590
+ * @type string $id Default: 'visit_blog'.
1591
+ * @type string $component Default: 'blogs'.
1592
+ * @type bool $must_be_logged_in Default: false.
1593
+ * @type bool $block_self Default: false.
1594
+ * @type string $wrapper_class Default: 'blog-button visit'.
1595
+ * @type string $link_href Permalink of the current blog in the loop.
1596
+ * @type string $link_class Default: 'blog-button visit'.
1597
+ * @type string $link_text Default: 'Visit Site'.
1598
+ * @type string $link_title Default: 'Visit Site'.
1599
  * }
1600
  * @return string The HTML for the Visit button.
1601
  */
1617
  /**
1618
  * Filters the button for visiting a blog in a loop.
1619
  *
1620
+ * @since 1.2.10
1621
  *
1622
  * @param array $button Array of arguments to be used for the button to visit a blog.
1623
  */
1629
  /**
1630
  * Display the number of blogs in user's profile.
1631
  *
1632
+ * @since 2.0.0
1633
  *
1634
+ * @uses bp_blogs_admin_get_profile_stats() to get the stats.
1635
+ *
1636
+ * @param array|string $args before|after|user_id
1637
  */
1638
  function bp_blogs_profile_stats( $args = '' ) {
1639
  echo bp_blogs_get_profile_stats( $args );
1643
  /**
1644
  * Return the number of blogs in user's profile.
1645
  *
1646
+ * @since 2.0.0
1647
+ *
1648
+ * @param array|string $args before|after|user_id
1649
  *
 
1650
  * @return string HTML for stats output.
1651
  */
1652
  function bp_blogs_get_profile_stats( $args = '' ) {
1679
  /**
1680
  * Filters the number of blogs in user's profile.
1681
  *
1682
+ * @since 2.0.0
1683
  *
1684
  * @param string $value Output determined for the profile stats.
1685
  * @param array $r Array of arguments used for default output if none provided.
bp-blogs/bp-blogs-widgets.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
-
3
  /**
4
- * BuddyPress Blogs Widgets
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsWidgets
@@ -23,7 +22,7 @@ function bp_blogs_register_widgets() {
23
  add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
24
 
25
  /**
26
- * The Recent Networkwide Posts widget
27
  */
28
  class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
29
 
@@ -43,7 +42,7 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
43
  *
44
  * @see WP_Widget::widget() for description of parameters.
45
  *
46
- * @param array $args Widget arguments.
47
  * @param array $instance Widget settings, as saved by the user.
48
  */
49
  public function widget( $args, $instance ) {
@@ -59,8 +58,8 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
59
  /**
60
  * Filters the Blogs Recent Posts widget title.
61
  *
62
- * @since BuddyPress (2.2.0)
63
- * @since BuddyPress (2.3.0) Added 'instance' and 'id_base' to arguments passed to filter.
64
  *
65
  * @param string $title The widget title.
66
  * @param array $instance The settings for the particular instance of the widget.
@@ -75,6 +74,8 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
75
  $instance['max_posts'] = 10;
76
  }
77
 
 
 
78
  // Override some of the contextually set parameters for bp_has_activities()
79
  $args = array(
80
  'action' => 'new_blog_post',
@@ -117,7 +118,7 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
117
 
118
  <?php endif; ?>
119
 
120
- <?php echo $args['after_widget']; ?>
121
  <?php
122
  }
123
 
@@ -126,6 +127,7 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
126
  *
127
  * @param array $new_instance The new instance options.
128
  * @param array $old_instance The old instance options.
 
129
  * @return array $instance The parsed options to be saved.
130
  */
131
  public function update( $new_instance, $old_instance ) {
@@ -140,7 +142,9 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
140
  /**
141
  * Output the networkwide posts widget options form.
142
  *
143
- * @param $instance Settings for this widget.
 
 
144
  */
145
  public function form( $instance ) {
146
  $instance = wp_parse_args( (array) $instance, array(
1
  <?php
 
2
  /**
3
+ * BuddyPress Blogs Widgets.
4
  *
5
  * @package BuddyPress
6
  * @subpackage BlogsWidgets
22
  add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
23
 
24
  /**
25
+ * The Recent Networkwide Posts widget.
26
  */
27
  class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
28
 
42
  *
43
  * @see WP_Widget::widget() for description of parameters.
44
  *
45
+ * @param array $args Widget arguments.
46
  * @param array $instance Widget settings, as saved by the user.
47
  */
48
  public function widget( $args, $instance ) {
58
  /**
59
  * Filters the Blogs Recent Posts widget title.
60
  *
61
+ * @since 2.2.0
62
+ * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
63
  *
64
  * @param string $title The widget title.
65
  * @param array $instance The settings for the particular instance of the widget.
74
  $instance['max_posts'] = 10;
75
  }
76
 
77
+ $after_widget = $args['after_widget'];
78
+
79
  // Override some of the contextually set parameters for bp_has_activities()
80
  $args = array(
81
  'action' => 'new_blog_post',
118
 
119
  <?php endif; ?>
120
 
121
+ <?php echo $after_widget; ?>
122
  <?php
123
  }
124
 
127
  *
128
  * @param array $new_instance The new instance options.
129
  * @param array $old_instance The old instance options.
130
+ *
131
  * @return array $instance The parsed options to be saved.
132
  */
133
  public function update( $new_instance, $old_instance ) {
142
  /**
143
  * Output the networkwide posts widget options form.
144
  *
145
+ * @param array $instance Settings for this widget.
146
+ *
147
+ * @return string
148
  */
149
  public function form( $instance ) {
150
  $instance = wp_parse_args( (array) $instance, array(
bp-blogs/classes/class-bp-blogs-blog.php CHANGED
@@ -15,7 +15,7 @@ defined( 'ABSPATH' ) || exit;
15
  * A BP_Blogs_Object represents a link between a specific WordPress blog on a
16
  * network and a specific user on that blog.
17
  *
18
- * @since BuddyPress (1.0.0)
19
  */
20
  class BP_Blogs_Blog {
21
  public $id;
@@ -64,9 +64,9 @@ class BP_Blogs_Blog {
64
  *
65
  * Please use this hook to filter the properties above. Each part will be passed in.
66
  *
67
- * @since BuddyPress (1.0.0)
68
  *
69
- * @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
70
  */
71
  do_action_ref_array( 'bp_blogs_blog_before_save', array( &$this ) );
72
 
@@ -96,9 +96,9 @@ class BP_Blogs_Blog {
96
  *
97
  * Please use this hook to filter the properties above. Each part will be passed in.
98
  *
99
- * @since BuddyPress (1.0.0)
100
  *
101
- * @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
102
  */
103
  do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) );
104
 
@@ -111,8 +111,8 @@ class BP_Blogs_Blog {
111
  /**
112
  * Check whether an association between this user and this blog exists.
113
  *
114
- * @return int The number of associations between the user and blog
115
- * saved in the blog component tables.
116
  */
117
  public function exists() {
118
  global $wpdb;
@@ -127,22 +127,23 @@ class BP_Blogs_Blog {
127
  /**
128
  * Retrieve a set of blog-user associations.
129
  *
130
- * @param string $type The order in which results should be returned.
131
- * 'active', 'alphabetical', 'newest', or 'random'.
132
- * @param int|bool $limit Optional. The maximum records to return.
133
- * Default: false.
134
- * @param int|bool $page Optional. The page of records to return.
135
- * Default: false (unlimited results).
136
- * @param int $user_id Optional. ID of the user whose blogs are being
137
- * retrieved. Default: 0.
138
- * @param string|bool $search_terms Optional. Search by text stored in
139
- * blogmeta (such as the blog name). Default: false.
140
- * @param bool $update_meta_cache Whether to pre-fetch metadata for
141
- * blogs. Default: true.
142
- * @param array $include_blog_ids Array of blog IDs to include.
 
143
  * @return array Multidimensional results array, structured as follows:
144
- * 'blogs' - Array of located blog objects
145
- * 'total' - A count of the total blogs matching the filter params
146
  */
147
  public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true, $include_blog_ids = false ) {
148
  global $wpdb;
@@ -241,7 +242,7 @@ class BP_Blogs_Blog {
241
  global $wpdb;
242
 
243
  bp_blogs_delete_blogmeta( $blog_id );
244
-
245
  $bp = buddypress();
246
 
247
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
@@ -251,8 +252,9 @@ class BP_Blogs_Blog {
251
  * Delete the record of a given blog for a specific user.
252
  *
253
  * @param int $blog_id The blog being removed.
254
- * @param int $user_id Optional. The ID of the user from whom the blog
255
- * is being removed. If absent, defaults to the logged-in user ID.
 
256
  * @return int|bool Number of rows deleted on success, false on failure.
257
  */
258
  public static function delete_blog_for_user( $blog_id, $user_id = null ) {
@@ -269,9 +271,9 @@ class BP_Blogs_Blog {
269
  /**
270
  * Delete all of a user's blog associations in the BP tables.
271
  *
272
- * @param int $user_id Optional. The ID of the user whose blog
273
- * associations are being deleted. If absent, defaults to
274
- * logged-in user ID.
275
  * @return int|bool Number of rows deleted on success, false on failure.
276
  */
277
  public static function delete_blogs_for_user( $user_id = null ) {
@@ -293,14 +295,14 @@ class BP_Blogs_Blog {
293
  * blogs that have been recorded by BuddyPress, while the WP function
294
  * does a true query of a user's blog capabilities.
295
  *
296
- * @param int $user_id Optional. ID of the user whose blogs are being
297
- * queried. Defaults to logged-in user.
298
- * @param bool $show_hidden Optional. Whether to include blogs that are
299
- * not marked public. Defaults to true when viewing one's own
300
- * profile.
301
  * @return array Multidimensional results array, structured as follows:
302
- * 'blogs' - Array of located blog objects
303
- * 'total' - A count of the total blogs for the user.
304
  */
305
  public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
306
  global $wpdb;
@@ -336,7 +338,8 @@ class BP_Blogs_Blog {
336
  * This method always includes hidden blogs.
337
  *
338
  * @param int $user_id Optional. ID of the user whose blogs are being
339
- * queried. Defaults to logged-in user.
 
340
  * @return int The number of blogs associated with the user.
341
  */
342
  public static function get_blog_ids_for_user( $user_id = 0 ) {
@@ -354,8 +357,9 @@ class BP_Blogs_Blog {
354
  * Check whether a blog has been recorded by BuddyPress.
355
  *
356
  * @param int $blog_id ID of the blog being queried.
 
357
  * @return int|null The ID of the first located entry in the BP table
358
- * on success, otherwise null.
359
  */
360
  public static function is_recorded( $blog_id ) {
361
  global $wpdb;
@@ -373,7 +377,8 @@ class BP_Blogs_Blog {
373
  * cap.
374
  *
375
  * @param int $user_id Optional. ID of the user whose blogs are being
376
- * queried. Defaults to logged-in user.
 
377
  * @return int Blog count for the user.
378
  */
379
  public static function total_blog_count_for_user( $user_id = null ) {
@@ -399,13 +404,14 @@ class BP_Blogs_Blog {
399
  * blogmeta table.
400
  *
401
  * @param string $filter The search term.
402
- * @param int $limit Optional. The maximum number of items to return.
403
- * Default: null (no limit).
404
- * @param int $page Optional. The page of results to return. Default:
405
- * null (no limit).
 
406
  * @return array Multidimensional results array, structured as follows:
407
- * 'blogs' - Array of located blog objects
408
- * 'total' - A count of the total blogs matching the query.
409
  */
410
  public static function search_blogs( $filter, $limit = null, $page = null ) {
411
  global $wpdb;
@@ -437,12 +443,13 @@ class BP_Blogs_Blog {
437
  * 'bp_moderate' cap.
438
  *
439
  * @param int $limit Optional. The maximum number of items to return.
440
- * Default: null (no limit).
441
- * @param int $page Optional. The page of results to return. Default:
442
- * null (no limit).
 
443
  * @return array Multidimensional results array, structured as follows:
444
- * 'blogs' - Array of located blog objects
445
- * 'total' - A count of the total blogs.
446
  */
447
  public static function get_all( $limit = null, $page = null ) {
448
  global $wpdb;
@@ -465,13 +472,14 @@ class BP_Blogs_Blog {
465
  * 'bp_moderate' cap.
466
  *
467
  * @param string $letter. The letter you're looking for.
468
- * @param int $limit Optional. The maximum number of items to return.
469
- * Default: null (no limit).
470
- * @param int $page Optional. The page of results to return. Default:
471
- * null (no limit).
 
472
  * @return array Multidimensional results array, structured as follows:
473
- * 'blogs' - Array of located blog objects.
474
- * 'total' - A count of the total blogs matching the query.
475
  */
476
  public static function get_by_letter( $letter, $limit = null, $page = null ) {
477
  global $wpdb;
@@ -504,9 +512,10 @@ class BP_Blogs_Blog {
504
  * - The latest post for each blog, include Featured Image data
505
  * - The blog description
506
  *
507
- * @param array $paged_blogs Array of results from the original query.
508
- * @param array $blog_ids Array of IDs returned from the original query.
509
- * @param string|bool $type Not currently used. Default: false.
 
510
  * @return array $paged_blogs The located blogs array, with the extras added.
511
  */
512
  public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
@@ -571,6 +580,7 @@ class BP_Blogs_Blog {
571
  * Checks the 'public' column in the wp_blogs table.
572
  *
573
  * @param int $blog_id The ID of the blog being checked.
 
574
  * @return bool True if hidden (public = 0), false otherwise.
575
  */
576
  public static function is_hidden( $blog_id ) {
@@ -588,6 +598,7 @@ class BP_Blogs_Blog {
588
  *
589
  * @param int $user_id ID of user.
590
  * @param int $blog_id ID of blog.
 
591
  * @return int|bool ID of user-blog link, or false if not found.
592
  */
593
  public static function get_user_blog( $user_id, $blog_id ) {
15
  * A BP_Blogs_Object represents a link between a specific WordPress blog on a
16
  * network and a specific user on that blog.
17
  *
18
+ * @since 1.0.0
19
  */
20
  class BP_Blogs_Blog {
21
  public $id;
64
  *
65
  * Please use this hook to filter the properties above. Each part will be passed in.
66
  *
67
+ * @since 1.0.0
68
  *
69
+ * @param BP_Blogs_Blog $this Current instance of the blog item being saved. Passed by reference.
70
  */
71
  do_action_ref_array( 'bp_blogs_blog_before_save', array( &$this ) );
72
 
96
  *
97
  * Please use this hook to filter the properties above. Each part will be passed in.
98
  *
99
+ * @since 1.0.0
100
  *
101
+ * @param BP_Blogs_Blog $this Current instance of the blog item being saved. Passed by reference.
102
  */
103
  do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) );
104
 
111
  /**
112
  * Check whether an association between this user and this blog exists.
113
  *
114
+ * @return int $value The number of associations between the user and blog
115
+ * saved in the blog component tables.
116
  */
117
  public function exists() {
118
  global $wpdb;
127
  /**
128
  * Retrieve a set of blog-user associations.
129
  *
130
+ * @param string $type The order in which results should be returned.
131
+ * 'active', 'alphabetical', 'newest', or 'random'.
132
+ * @param int|bool $limit Optional. The maximum records to return.
133
+ * Default: false.
134
+ * @param int|bool $page Optional. The page of records to return.
135
+ * Default: false (unlimited results).
136
+ * @param int $user_id Optional. ID of the user whose blogs are being
137
+ * retrieved. Default: 0.
138
+ * @param string|bool $search_terms Optional. Search by text stored in
139
+ * blogmeta (such as the blog name). Default: false.
140
+ * @param bool $update_meta_cache Whether to pre-fetch metadata for
141
+ * blogs. Default: true.
142
+ * @param array|bool $include_blog_ids Array of blog IDs to include.
143
+ *
144
  * @return array Multidimensional results array, structured as follows:
145
+ * 'blogs' - Array of located blog objects
146
+ * 'total' - A count of the total blogs matching the filter params
147
  */
148
  public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true, $include_blog_ids = false ) {
149
  global $wpdb;
242
  global $wpdb;
243
 
244
  bp_blogs_delete_blogmeta( $blog_id );
245
+
246
  $bp = buddypress();
247
 
248
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
252
  * Delete the record of a given blog for a specific user.
253
  *
254
  * @param int $blog_id The blog being removed.
255
+ * @param int $user_id Optional. The ID of the user from whom the blog is
256
+ * being removed. If absent, defaults to the logged-in user ID.
257
+ *
258
  * @return int|bool Number of rows deleted on success, false on failure.
259
  */
260
  public static function delete_blog_for_user( $blog_id, $user_id = null ) {
271
  /**
272
  * Delete all of a user's blog associations in the BP tables.
273
  *
274
+ * @param int $user_id Optional. The ID of the user whose blog associations
275
+ * are being deleted. If absent, defaults to logged-in user ID.
276
+ *
277
  * @return int|bool Number of rows deleted on success, false on failure.
278
  */
279
  public static function delete_blogs_for_user( $user_id = null ) {
295
  * blogs that have been recorded by BuddyPress, while the WP function
296
  * does a true query of a user's blog capabilities.
297
  *
298
+ * @param int $user_id Optional. ID of the user whose blogs are being
299
+ * queried. Defaults to logged-in user.
300
+ * @param bool $show_hidden Optional. Whether to include blogs that are not marked
301
+ * public. Defaults to true when viewing one's own profile.
302
+ *
303
  * @return array Multidimensional results array, structured as follows:
304
+ * 'blogs' - Array of located blog objects.
305
+ * 'total' - A count of the total blogs for the user.
306
  */
307
  public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
308
  global $wpdb;
338
  * This method always includes hidden blogs.
339
  *
340
  * @param int $user_id Optional. ID of the user whose blogs are being
341
+ * queried. Defaults to logged-in user.
342
+ *
343
  * @return int The number of blogs associated with the user.
344
  */
345
  public static function get_blog_ids_for_user( $user_id = 0 ) {
357
  * Check whether a blog has been recorded by BuddyPress.
358
  *
359
  * @param int $blog_id ID of the blog being queried.
360
+ *
361
  * @return int|null The ID of the first located entry in the BP table
362
+ * on success, otherwise null.
363
  */
364
  public static function is_recorded( $blog_id ) {
365
  global $wpdb;
377
  * cap.
378
  *
379
  * @param int $user_id Optional. ID of the user whose blogs are being
380
+ * queried. Defaults to logged-in user.
381
+ *
382
  * @return int Blog count for the user.
383
  */
384
  public static function total_blog_count_for_user( $user_id = null ) {
404
  * blogmeta table.
405
  *
406
  * @param string $filter The search term.
407
+ * @param int $limit Optional. The maximum number of items to return.
408
+ * Default: null (no limit).
409
+ * @param int $page Optional. The page of results to return. Default:
410
+ * null (no limit).
411
+ *
412
  * @return array Multidimensional results array, structured as follows:
413
+ * 'blogs' - Array of located blog objects.
414
+ * 'total' - A count of the total blogs matching the query.
415
  */
416
  public static function search_blogs( $filter, $limit = null, $page = null ) {
417
  global $wpdb;
443
  * 'bp_moderate' cap.
444
  *
445
  * @param int $limit Optional. The maximum number of items to return.
446
+ * Default: null (no limit).
447
+ * @param int $page Optional. The page of results to return. Default:
448
+ * null (no limit).
449
+ *
450
  * @return array Multidimensional results array, structured as follows:
451
+ * 'blogs' - Array of located blog objects.
452
+ * 'total' - A count of the total blogs.
453
  */
454
  public static function get_all( $limit = null, $page = null ) {
455
  global $wpdb;
472
  * 'bp_moderate' cap.
473
  *
474
  * @param string $letter. The letter you're looking for.
475
+ * @param int $limit Optional. The maximum number of items to return.
476
+ * Default: null (no limit).
477
+ * @param int $page Optional. The page of results to return. Default:
478
+ * null (no limit).
479
+ *
480
  * @return array Multidimensional results array, structured as follows:
481
+ * 'blogs' - Array of located blog objects.
482
+ * 'total' - A count of the total blogs matching the query.
483
  */
484
  public static function get_by_letter( $letter, $limit = null, $page = null ) {
485
  global $wpdb;
512
  * - The latest post for each blog, include Featured Image data
513
  * - The blog description
514
  *
515
+ * @param array $paged_blogs Array of results from the original query.
516
+ * @param array $blog_ids Array of IDs returned from the original query.
517
+ * @param string|bool $type Not currently used. Default: false.
518
+ *
519
  * @return array $paged_blogs The located blogs array, with the extras added.
520
  */
521
  public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
580
  * Checks the 'public' column in the wp_blogs table.
581
  *
582
  * @param int $blog_id The ID of the blog being checked.
583
+ *
584
  * @return bool True if hidden (public = 0), false otherwise.
585
  */
586
  public static function is_hidden( $blog_id ) {
598
  *
599
  * @param int $user_id ID of user.
600
  * @param int $blog_id ID of blog.
601
+ *
602
  * @return int|bool ID of user-blog link, or false if not found.
603
  */
604
  public static function get_user_blog( $user_id, $blog_id ) {
bp-core/admin/bp-core-admin-actions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Admin Actions.
5
  *
@@ -18,7 +17,7 @@
18
  * @see bp-core-filters.php
19
  */
20
 
21
- // Exit if accessed directly
22
  defined( 'ABSPATH' ) || exit;
23
 
24
  /**
@@ -62,14 +61,14 @@ add_action( 'bp_admin_menu', 'bp_admin_separator' );
62
  * When a new site is created in a multisite installation, run the activation
63
  * routine on that site.
64
  *
65
- * @since BuddyPress (1.7.0)
66
  *
67
- * @param int $blog_id
68
- * @param int $user_id
69
  * @param string $domain
70
  * @param string $path
71
- * @param int $site_id
72
- * @param array $meta
73
  */
74
  function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
75
 
@@ -83,7 +82,7 @@ function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
83
  /**
84
  * Fires the activation routine for a new site created in a multisite installation.
85
  *
86
- * @since BuddyPress (1.7.0)
87
  *
88
  * @param int $blog_id ID of the blog being installed to.
89
  * @param int $user_id ID of the user the install is for.
@@ -103,7 +102,7 @@ function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
103
  /**
104
  * Piggy back admin_init action.
105
  *
106
- * @since BuddyPress (1.7.0)
107
  * @uses do_action() Calls 'bp_admin_init'.
108
  */
109
  function bp_admin_init() {
@@ -111,7 +110,7 @@ function bp_admin_init() {
111
  /**
112
  * Fires inside the bp_admin_init function.
113
  *
114
- * @since BuddyPress (1.6.0)
115
  */
116
  do_action( 'bp_admin_init' );
117
  }
@@ -119,7 +118,7 @@ function bp_admin_init() {
119
  /**
120
  * Piggy back admin_menu action.
121
  *
122
- * @since BuddyPress (1.7.0)
123
  * @uses do_action() Calls 'bp_admin_menu'.
124
  */
125
  function bp_admin_menu() {
@@ -127,7 +126,7 @@ function bp_admin_menu() {
127
  /**
128
  * Fires inside the bp_admin_menu function.
129
  *
130
- * @since BuddyPress (1.7.0)
131
  */
132
  do_action( 'bp_admin_menu' );
133
  }
@@ -135,7 +134,7 @@ function bp_admin_menu() {
135
  /**
136
  * Piggy back admin_head action.
137
  *
138
- * @since BuddyPress (1.7.0)
139
  * @uses do_action() Calls 'bp_admin_head'.
140
  */
141
  function bp_admin_head() {
@@ -143,7 +142,7 @@ function bp_admin_head() {
143
  /**
144
  * Fires inside the bp_admin_head function.
145
  *
146
- * @since BuddyPress (1.6.0)
147
  */
148
  do_action( 'bp_admin_head' );
149
  }
@@ -151,7 +150,7 @@ function bp_admin_head() {
151
  /**
152
  * Piggy back admin_notices action.
153
  *
154
- * @since BuddyPress (1.7.0)
155
  * @uses do_action() Calls 'bp_admin_notices'.
156
  */
157
  function bp_admin_notices() {
@@ -159,7 +158,7 @@ function bp_admin_notices() {
159
  /**
160
  * Fires inside the bp_admin_notices function.
161
  *
162
- * @since BuddyPress (1.5.0)
163
  */
164
  do_action( 'bp_admin_notices' );
165
  }
@@ -167,7 +166,7 @@ function bp_admin_notices() {
167
  /**
168
  * Piggy back admin_enqueue_scripts action.
169
  *
170
- * @since BuddyPress (1.7.0)
171
  *
172
  * @uses do_action() Calls 'bp_admin_enqueue_scripts''.
173
  *
@@ -179,7 +178,7 @@ function bp_admin_enqueue_scripts( $hook_suffix = '' ) {
179
  /**
180
  * Fires inside the bp_admin_enqueue_scripts function.
181
  *
182
- * @since BuddyPress (1.7.0)
183
  *
184
  * @param string $hook_suffix The current admin page, passed to admin_enqueue_scripts.
185
  */
@@ -189,7 +188,7 @@ function bp_admin_enqueue_scripts( $hook_suffix = '' ) {
189
  /**
190
  * Dedicated action to register BuddyPress importers.
191
  *
192
- * @since BuddyPress (1.7.0)
193
  * @uses do_action() Calls 'bp_admin_notices'.
194
  */
195
  function bp_register_importers() {
@@ -199,7 +198,7 @@ function bp_register_importers() {
199
  *
200
  * Used to register a BuddyPress importer.
201
  *
202
- * @since BuddyPress (1.7.0)
203
  */
204
  do_action( 'bp_register_importers' );
205
  }
@@ -207,7 +206,7 @@ function bp_register_importers() {
207
  /**
208
  * Dedicated action to register admin styles.
209
  *
210
- * @since BuddyPress (1.7.0)
211
  * @uses do_action() Calls 'bp_admin_notices'.
212
  */
213
  function bp_register_admin_style() {
@@ -215,7 +214,7 @@ function bp_register_admin_style() {
215
  /**
216
  * Fires inside the bp_register_admin_style function.
217
  *
218
- * @since BuddyPress (1.7.0)
219
  */
220
  do_action( 'bp_register_admin_style' );
221
  }
@@ -223,7 +222,7 @@ function bp_register_admin_style() {
223
  /**
224
  * Dedicated action to register admin settings.
225
  *
226
- * @since BuddyPress (1.7.0)
227
  * @uses do_action() Calls 'bp_register_admin_settings'.
228
  */
229
  function bp_register_admin_settings() {
@@ -231,7 +230,7 @@ function bp_register_admin_settings() {
231
  /**
232
  * Fires inside the bp_register_admin_settings function.
233
  *
234
- * @since BuddyPress (1.6.0)
235
  */
236
  do_action( 'bp_register_admin_settings' );
237
  }
1
  <?php
 
2
  /**
3
  * BuddyPress Admin Actions.
4
  *
17
  * @see bp-core-filters.php
18
  */
19
 
20
+ // Exit if accessed directly.
21
  defined( 'ABSPATH' ) || exit;
22
 
23
  /**
61
  * When a new site is created in a multisite installation, run the activation
62
  * routine on that site.
63
  *
64
+ * @since 1.7.0
65
  *
66
+ * @param int $blog_id
67
+ * @param int $user_id
68
  * @param string $domain
69
  * @param string $path
70
+ * @param int $site_id
71
+ * @param array $meta
72
  */
73
  function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
74
 
82
  /**
83
  * Fires the activation routine for a new site created in a multisite installation.
84
  *
85
+ * @since 1.7.0
86
  *
87
  * @param int $blog_id ID of the blog being installed to.
88
  * @param int $user_id ID of the user the install is for.
102
  /**
103
  * Piggy back admin_init action.
104
  *
105
+ * @since 1.7.0
106
  * @uses do_action() Calls 'bp_admin_init'.
107
  */
108
  function bp_admin_init() {
110
  /**
111
  * Fires inside the bp_admin_init function.
112
  *
113
+ * @since 1.6.0
114
  */
115
  do_action( 'bp_admin_init' );
116
  }
118
  /**
119
  * Piggy back admin_menu action.
120
  *
121
+ * @since 1.7.0
122
  * @uses do_action() Calls 'bp_admin_menu'.
123
  */
124
  function bp_admin_menu() {
126
  /**
127
  * Fires inside the bp_admin_menu function.
128
  *
129
+ * @since 1.7.0
130
  */
131
  do_action( 'bp_admin_menu' );
132
  }
134
  /**
135
  * Piggy back admin_head action.
136
  *
137
+ * @since 1.7.0
138
  * @uses do_action() Calls 'bp_admin_head'.
139
  */
140
  function bp_admin_head() {
142
  /**
143
  * Fires inside the bp_admin_head function.
144
  *
145
+ * @since 1.6.0
146
  */
147
  do_action( 'bp_admin_head' );
148
  }
150
  /**
151
  * Piggy back admin_notices action.
152
  *
153
+ * @since 1.7.0
154
  * @uses do_action() Calls 'bp_admin_notices'.
155
  */
156
  function bp_admin_notices() {
158
  /**
159
  * Fires inside the bp_admin_notices function.
160
  *
161
+ * @since 1.5.0
162
  */
163
  do_action( 'bp_admin_notices' );
164
  }
166
  /**
167
  * Piggy back admin_enqueue_scripts action.
168
  *
169
+ * @since 1.7.0
170
  *
171
  * @uses do_action() Calls 'bp_admin_enqueue_scripts''.
172
  *
178
  /**
179
  * Fires inside the bp_admin_enqueue_scripts function.
180
  *
181
+ * @since 1.7.0
182
  *
183
  * @param string $hook_suffix The current admin page, passed to admin_enqueue_scripts.
184
  */
188
  /**
189
  * Dedicated action to register BuddyPress importers.
190
  *
191
+ * @since 1.7.0
192
  * @uses do_action() Calls 'bp_admin_notices'.
193
  */
194
  function bp_register_importers() {
198
  *
199
  * Used to register a BuddyPress importer.
200
  *
201
+ * @since 1.7.0
202
  */
203
  do_action( 'bp_register_importers' );
204
  }
206
  /**
207
  * Dedicated action to register admin styles.
208
  *
209
+ * @since 1.7.0
210
  * @uses do_action() Calls 'bp_admin_notices'.
211
  */
212
  function bp_register_admin_style() {
214
  /**
215
  * Fires inside the bp_register_admin_style function.
216
  *
217
+ * @since 1.7.0
218
  */
219
  do_action( 'bp_register_admin_style' );
220
  }
222
  /**
223
  * Dedicated action to register admin settings.
224
  *
225
+ * @since 1.7.0
226
  * @uses do_action() Calls 'bp_register_admin_settings'.
227
  */
228
  function bp_register_admin_settings() {
230
  /**
231
  * Fires inside the bp_register_admin_settings function.
232
  *
233
+ * @since 1.6.0
234
  */
235
  do_action( 'bp_register_admin_settings' );
236
  }
bp-core/admin/bp-core-admin-components.php CHANGED
@@ -1,27 +1,25 @@
1
  <?php
2
-
3
  /**
4
- * BuddyPress Admin Component Functions
5
  *
6
  * @package BuddyPress
7
  * @subpackage CoreAdministration
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Renders the Component Setup admin panel.
15
  *
16
  * @package BuddyPress
17
- * @since BuddyPress (1.6.0)
18
  * @uses bp_core_admin_component_options()
19
  */
20
  function bp_core_admin_components_settings() {
21
  ?>
22
 
23
  <div class="wrap">
24
- <?php screen_icon( 'buddypress'); ?>
25
 
26
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Components', 'buddypress' ) ); ?></h2>
27
  <form action="" method="post" id="bp-admin-component-form">
@@ -44,7 +42,7 @@ function bp_core_admin_components_settings() {
44
  * Creates reusable markup for component setup on the Components and Pages dashboard panel.
45
  *
46
  * @package BuddyPress
47
- * @since BuddyPress (1.6.0)
48
  * @todo Use settings API
49
  */
50
  function bp_core_admin_components_options() {
@@ -55,7 +53,7 @@ function bp_core_admin_components_options() {
55
  /**
56
  * Filters the array of available components.
57
  *
58
- * @since BuddyPress (1.5.0)
59
  *
60
  * @param mixed $value Active components.
61
  */
@@ -235,9 +233,9 @@ function bp_core_admin_components_options() {
235
  }
236
 
237
  /**
238
- * Handle saving the Component settings
239
  *
240
- * @since BuddyPress (1.6.0)
241
  * @todo Use settings API when it supports saving network settings
242
  */
243
  function bp_core_admin_components_settings_handler() {
@@ -277,7 +275,7 @@ function bp_core_admin_components_settings_handler() {
277
  add_action( 'bp_admin_init', 'bp_core_admin_components_settings_handler' );
278
 
279
  /**
280
- * Calculates the components that should be active after save, based on submitted settings
281
  *
282
  * The way that active components must be set after saving your settings must
283
  * be calculated differently depending on which of the Components subtabs you
@@ -296,10 +294,11 @@ add_action( 'bp_admin_init', 'bp_core_admin_components_settings_handler' );
296
  * is not present, before merging the submitted components with the active
297
  * ones.
298
  *
299
- * @since BuddyPress (1.7.0)
 
 
 
300
  *
301
- * @param array This is the array of component settings coming from the POST
302
- * global. You should stripslashes_deep() before passing to this function
303
  * @return array The calculated list of component settings
304
  */
305
  function bp_core_admin_get_active_components_from_submitted_settings( $submitted ) {
@@ -336,14 +335,15 @@ function bp_core_admin_get_active_components_from_submitted_settings( $submitted
336
  }
337
 
338
  /**
339
- * Return a list of component information, optionally filtered by type
340
  *
341
  * We use this information both to build the markup for the admin screens, as
342
  * well as to do some processing on settings data submitted from those screens.
343
  *
344
- * @since BuddyPress (1.7.0)
 
 
345
  *
346
- * @param string $type 'all', 'optional', 'retired', 'required'
347
  * @return array An array of requested component data
348
  */
349
  function bp_core_admin_get_components( $type = 'all' ) {
@@ -434,7 +434,7 @@ function bp_core_admin_get_components( $type = 'all' ) {
434
  /**
435
  * Filters the list of component information.
436
  *
437
- * @since BuddyPress (2.0.0)
438
  *
439
  * @param array $components Array of component information.
440
  * @param string $type Type of component list requested.
1
  <?php
 
2
  /**
3
+ * BuddyPress Admin Component Functions.
4
  *
5
  * @package BuddyPress
6
  * @subpackage CoreAdministration
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Renders the Component Setup admin panel.
14
  *
15
  * @package BuddyPress
16
+ * @since 1.6.0
17
  * @uses bp_core_admin_component_options()
18
  */
19
  function bp_core_admin_components_settings() {
20
  ?>
21
 
22
  <div class="wrap">
 
23
 
24
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Components', 'buddypress' ) ); ?></h2>
25
  <form action="" method="post" id="bp-admin-component-form">
42
  * Creates reusable markup for component setup on the Components and Pages dashboard panel.
43
  *
44
  * @package BuddyPress
45
+ * @since 1.6.0
46
  * @todo Use settings API
47
  */
48
  function bp_core_admin_components_options() {
53
  /**
54
  * Filters the array of available components.
55
  *
56
+ * @since 1.5.0
57
  *
58
  * @param mixed $value Active components.
59
  */
233
  }
234
 
235
  /**
236
+ * Handle saving the Component settings.
237
  *
238
+ * @since 1.6.0
239
  * @todo Use settings API when it supports saving network settings
240
  */
241
  function bp_core_admin_components_settings_handler() {
275
  add_action( 'bp_admin_init', 'bp_core_admin_components_settings_handler' );
276
 
277
  /**
278
+ * Calculates the components that should be active after save, based on submitted settings.
279
  *
280
  * The way that active components must be set after saving your settings must
281
  * be calculated differently depending on which of the Components subtabs you
294
  * is not present, before merging the submitted components with the active
295
  * ones.
296
  *
297
+ * @since 1.7.0
298
+ *
299
+ * @param array $submitted This is the array of component settings coming from the POST
300
+ * global. You should stripslashes_deep() before passing to this function.
301
  *
 
 
302
  * @return array The calculated list of component settings
303
  */
304
  function bp_core_admin_get_active_components_from_submitted_settings( $submitted ) {
335
  }
336
 
337
  /**
338
+ * Return a list of component information, optionally filtered by type.
339
  *
340
  * We use this information both to build the markup for the admin screens, as
341
  * well as to do some processing on settings data submitted from those screens.
342
  *
343
+ * @since 1.7.0
344
+ *
345
+ * @param string $type 'all', 'optional', 'retired', 'required'.
346
  *
 
347
  * @return array An array of requested component data
348
  */
349
  function bp_core_admin_get_components( $type = 'all' ) {
434
  /**
435
  * Filters the list of component information.
436
  *
437
+ * @since 2.0.0
438
  *
439
  * @param array $components Array of component information.
440
  * @param string $type Type of component list requested.
bp-core/admin/bp-core-admin-functions.php CHANGED
@@ -1,13 +1,12 @@
1
  <?php
2
-
3
  /**
4
- * BuddyPress Common Admin Functions
5
  *
6
  * @package BuddyPress
7
  * @subpackage CoreAdministration
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /** Menu **********************************************************************/
@@ -32,7 +31,7 @@ function bp_core_admin_menu_init() {
32
  * @global array $_parent_pages
33
  * @global array $_registered_pages
34
  * @global array $submenu
35
- * @since BuddyPress (1.6.0)
36
  */
37
  function bp_core_admin_backpat_menu() {
38
  global $_parent_pages, $_registered_pages, $submenu;
@@ -71,7 +70,7 @@ add_action( bp_core_admin_hook(), 'bp_core_admin_backpat_menu', 999 );
71
  *
72
  * @global string $plugin_page
73
  * @global array $submenu
74
- * @since BuddyPress (1.6.0)
75
  */
76
  function bp_core_modify_admin_menu_highlight() {
77
  global $plugin_page, $submenu_file;
@@ -93,7 +92,7 @@ function bp_core_modify_admin_menu_highlight() {
93
  * will never appear.
94
  *
95
  * @see bp_core_admin_backpat_menu()
96
- * @since BuddyPress (1.6.0)
97
  * @todo Add convenience links into the markup once new positions are finalised.
98
  */
99
  function bp_core_admin_backpat_page() {
@@ -101,7 +100,6 @@ function bp_core_admin_backpat_page() {
101
  $settings_url = add_query_arg( 'page', 'bp-components', $url ); ?>
102
 
103
  <div class="wrap">
104
- <?php screen_icon( 'buddypress' ); ?>
105
  <h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
106
 
107
  <p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
@@ -114,14 +112,14 @@ function bp_core_admin_backpat_page() {
114
  /** Notices *******************************************************************/
115
 
116
  /**
117
- * Print admin messages to admin_notices or network_admin_notices
118
  *
119
  * BuddyPress combines all its messages into a single notice, to avoid a preponderance of yellow
120
  * boxes.
121
  *
122
- * @since BuddyPress (1.5.0)
123
  *
124
- * @uses bp_current_user_can() to check current user permissions before showing the notices
125
  * @uses bp_is_root_blog()
126
  */
127
  function bp_core_print_admin_notices() {
@@ -158,16 +156,16 @@ add_action( 'admin_notices', 'bp_core_print_admin_notices' );
158
  add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
159
 
160
  /**
161
- * Add an admin notice to the BP queue
162
  *
163
  * Messages added with this function are displayed in BuddyPress's general purpose admin notices
164
  * box. It is recommended that you hook this function to admin_init, so that your messages are
165
  * loaded in time.
166
  *
167
- * @since BuddyPress (1.5.0)
168
  *
169
  * @param string $notice The notice you are adding to the queue.
170
- * @param string $type The notice type; optional. Usually either "updated" or "error".
171
  */
172
  function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) {
173
 
@@ -189,17 +187,17 @@ function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) {
189
  }
190
 
191
  /**
192
- * Verify that some BP prerequisites are set up properly, and notify the admin if not
193
  *
194
  * On every Dashboard page, this function checks the following:
195
- * - that pretty permalinks are enabled
196
- * - that every BP component that needs a WP page for a directory has one
197
- * - that no WP page has multiple BP components associated with it
198
  * The administrator will be shown a notice for each check that fails.
199
  *
200
  * @global WPDB $wpdb WordPress DB object
201
  * @global WP_Rewrite $wp_rewrite
202
- * @since BuddyPress (1.2.0)
203
  */
204
  function bp_core_activation_notice() {
205
  global $wp_rewrite, $wpdb;
@@ -327,18 +325,18 @@ function bp_core_activation_notice() {
327
  }
328
 
329
  /**
330
- * Redirect user to BuddyPress's What's New page on activation
331
  *
332
- * @since BuddyPress (1.7.0)
333
  *
334
- * @internal Used internally to redirect BuddyPress to the about page on activation
335
  *
336
- * @uses get_transient() To see if transient to redirect exists
337
- * @uses delete_transient() To delete the transient if it exists
338
- * @uses is_network_admin() To bail if being network activated
339
- * @uses wp_safe_redirect() To redirect
340
- * @uses add_query_arg() To help build the URL to redirect to
341
- * @uses admin_url() To get the admin URL to index.php
342
  */
343
  function bp_do_activation_redirect() {
344
 
@@ -368,9 +366,10 @@ function bp_do_activation_redirect() {
368
  /** UI/Styling ****************************************************************/
369
 
370
  /**
371
- * Output the tabs in the admin area
 
 
372
  *
373
- * @since BuddyPress (1.5.0)
374
  * @param string $active_tab Name of the tab that is active. Optional.
375
  */
376
  function bp_core_admin_tabs( $active_tab = '' ) {
@@ -381,7 +380,7 @@ function bp_core_admin_tabs( $active_tab = '' ) {
381
  /**
382
  * Filters the admin tabs to be displayed.
383
  *
384
- * @since BuddyPress (1.9.0)
385
  *
386
  * @param array $value Array of tabs to output to the admin area.
387
  */
@@ -399,7 +398,7 @@ function bp_core_admin_tabs( $active_tab = '' ) {
399
  /**
400
  * Fires after the output of tabs for the admin area.
401
  *
402
- * @since BuddyPress (1.5.0)
403
  */
404
  do_action( 'bp_admin_tabs' );
405
  }
@@ -407,8 +406,11 @@ function bp_core_admin_tabs( $active_tab = '' ) {
407
  /**
408
  * Get the data for the tabs in the admin area.
409
  *
410
- * @since BuddyPress (2.2.0)
 
411
  * @param string $active_tab Name of the tab that is active. Optional.
 
 
412
  */
413
  function bp_core_get_admin_tabs( $active_tab = '' ) {
414
  $tabs = array(
@@ -442,7 +444,7 @@ function bp_core_get_admin_tabs( $active_tab = '' ) {
442
  /**
443
  * Filters the tab data used in our wp-admin screens.
444
  *
445
- * @since BuddyPress (2.2.0)
446
  *
447
  * @param array $tabs Tab data.
448
  */
@@ -452,10 +454,12 @@ function bp_core_get_admin_tabs( $active_tab = '' ) {
452
  /** Help **********************************************************************/
453
 
454
  /**
455
- * adds contextual help to BuddyPress admin pages
456
  *
457
- * @since BuddyPress (1.7.0)
458
  * @todo Make this part of the BP_Component class and split into each component
 
 
459
  */
460
  function bp_core_add_contextual_help( $screen = '' ) {
461
 
@@ -542,9 +546,13 @@ function bp_core_add_contextual_help( $screen = '' ) {
542
  add_action( 'contextual_help', 'bp_core_add_contextual_help' );
543
 
544
  /**
545
- * renders contextual help content to contextual help tabs
 
 
546
  *
547
- * @since BuddyPress (1.7.0)
 
 
548
  */
549
  function bp_core_add_contextual_help_content( $tab = '' ) {
550
 
@@ -581,11 +589,11 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
581
  /** Separator *****************************************************************/
582
 
583
  /**
584
- * Add a separator to the WordPress admin menus
585
  *
586
- * @since BuddyPress (1.7.0)
587
  *
588
- * @uses bp_current_user_can() To check users capability on root blog
589
  */
590
  function bp_admin_separator() {
591
 
@@ -616,12 +624,13 @@ function bp_admin_separator() {
616
  }
617
 
618
  /**
619
- * Tell WordPress we have a custom menu order
 
 
 
620
  *
621
- * @since BuddyPress (1.7.0)
622
  *
623
- * @param bool $menu_order Menu order
624
- * @uses bp_current_user_can() To check users capability on root blog
625
  * @return bool Always true
626
  */
627
  function bp_admin_custom_menu_order( $menu_order = false ) {
@@ -635,12 +644,13 @@ function bp_admin_custom_menu_order( $menu_order = false ) {
635
  }
636
 
637
  /**
638
- * Move our custom separator above our custom post types
639
  *
640
- * @since BuddyPress (1.7.0)
 
 
 
641
  *
642
- * @param array $menu_order Menu Order
643
- * @uses bp_current_user_can() To check users capability on root blog
644
  * @return array Modified menu order
645
  */
646
  function bp_admin_menu_order( $menu_order = array() ) {
@@ -659,7 +669,7 @@ function bp_admin_menu_order( $menu_order = array() ) {
659
  /**
660
  * Filters the custom admin menus.
661
  *
662
- * @since BuddyPress (1.7.0)
663
  *
664
  * @param array $value Empty array.
665
  */
@@ -702,13 +712,14 @@ function bp_admin_menu_order( $menu_order = array() ) {
702
  /** Utility *****************************************************************/
703
 
704
  /**
705
- * When using a WP_List_Table, get the currently selected bulk action
706
  *
707
  * WP_List_Tables have bulk actions at the top and at the bottom of the tables,
708
  * and the inputs have different keys in the $_REQUEST array. This function
709
  * reconciles the two values and returns a single action being performed.
710
  *
711
- * @since BuddyPress (1.7.0)
 
712
  * @return string
713
  */
714
  function bp_admin_list_table_current_bulk_action() {
@@ -726,9 +737,9 @@ function bp_admin_list_table_current_bulk_action() {
726
  /** Menus *********************************************************************/
727
 
728
  /**
729
- * Register meta box and associated JS for BuddyPress WP Nav Menu .
730
  *
731
- * @since BuddyPress (1.9.0)
732
  */
733
  function bp_admin_wp_nav_menu_meta_box() {
734
  if ( ! bp_is_root_blog() ) {
@@ -743,7 +754,7 @@ function bp_admin_wp_nav_menu_meta_box() {
743
  /**
744
  * Build and populate the BuddyPress accordion on Appearance > Menus.
745
  *
746
- * @since BuddyPress (1.9.0)
747
  *
748
  * @global $nav_menu_selected_id
749
  */
@@ -809,7 +820,7 @@ function bp_admin_do_wp_nav_menu_meta_box() {
809
  *
810
  * Note: These restrictions are only enforced if JavaScript is enabled.
811
  *
812
- * @since BuddyPress (1.9.0)
813
  */
814
  function bp_admin_wp_nav_menu_restrict_items() {
815
  ?>
@@ -830,10 +841,11 @@ function bp_admin_wp_nav_menu_restrict_items() {
830
  /**
831
  * Add "Mark as Spam/Ham" button to user row actions.
832
  *
833
- * @since BuddyPress (2.0.0)
834
  *
835
- * @param array $actions User row action links.
836
  * @param object $user_object Current user information.
 
837
  * @return array $actions User row action links.
838
  */
839
  function bp_core_admin_user_row_actions( $actions, $user_object ) {
@@ -875,7 +887,7 @@ function bp_core_admin_user_row_actions( $actions, $user_object ) {
875
  /**
876
  * Catch requests to mark individual users as spam/ham from users.php.
877
  *
878
- * @since BuddyPress (2.0.0)
879
  */
880
  function bp_core_admin_user_manage_spammers() {
881
 
@@ -930,7 +942,7 @@ function bp_core_admin_user_manage_spammers() {
930
  /**
931
  * Inline script that adds the 'site-spammed' class to spammed users.
932
  *
933
- * @since BuddyPress (2.0.0)
934
  */
935
  function bp_core_admin_user_spammed_js() {
936
  ?>
1
  <?php
 
2
  /**
3
+ * BuddyPress Common Admin Functions.
4
  *
5
  * @package BuddyPress
6
  * @subpackage CoreAdministration
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /** Menu **********************************************************************/
31
  * @global array $_parent_pages
32
  * @global array $_registered_pages
33
  * @global array $submenu
34
+ * @since 1.6.0
35
  */
36
  function bp_core_admin_backpat_menu() {
37
  global $_parent_pages, $_registered_pages, $submenu;
70
  *
71
  * @global string $plugin_page
72
  * @global array $submenu
73
+ * @since 1.6.0
74
  */
75
  function bp_core_modify_admin_menu_highlight() {
76
  global $plugin_page, $submenu_file;
92
  * will never appear.
93
  *
94
  * @see bp_core_admin_backpat_menu()
95
+ * @since 1.6.0
96
  * @todo Add convenience links into the markup once new positions are finalised.
97
  */
98
  function bp_core_admin_backpat_page() {
100
  $settings_url = add_query_arg( 'page', 'bp-components', $url ); ?>
101
 
102
  <div class="wrap">
 
103
  <h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
104
 
105
  <p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
112
  /** Notices *******************************************************************/
113
 
114
  /**
115
+ * Print admin messages to admin_notices or network_admin_notices.
116
  *
117
  * BuddyPress combines all its messages into a single notice, to avoid a preponderance of yellow
118
  * boxes.
119
  *
120
+ * @since 1.5.0
121
  *
122
+ * @uses bp_current_user_can() to check current user permissions before showing the notices.
123
  * @uses bp_is_root_blog()
124
  */
125
  function bp_core_print_admin_notices() {
156
  add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
157
 
158
  /**
159
+ * Add an admin notice to the BP queue.
160
  *
161
  * Messages added with this function are displayed in BuddyPress's general purpose admin notices
162
  * box. It is recommended that you hook this function to admin_init, so that your messages are
163
  * loaded in time.
164
  *
165
+ * @since 1.5.0
166
  *
167
  * @param string $notice The notice you are adding to the queue.
168
+ * @param string $type The notice type; optional. Usually either "updated" or "error".
169
  */
170
  function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) {
171
 
187
  }
188
 
189
  /**
190
+ * Verify that some BP prerequisites are set up properly, and notify the admin if not.
191
  *
192
  * On every Dashboard page, this function checks the following:
193
+ * - that pretty permalinks are enabled.
194
+ * - that every BP component that needs a WP page for a directory has one.
195
+ * - that no WP page has multiple BP components associated with it.
196
  * The administrator will be shown a notice for each check that fails.
197
  *
198
  * @global WPDB $wpdb WordPress DB object
199
  * @global WP_Rewrite $wp_rewrite
200
+ * @since 1.2.0
201
  */
202
  function bp_core_activation_notice() {
203
  global $wp_rewrite, $wpdb;
325
  }
326
 
327
  /**
328
+ * Redirect user to BuddyPress's What's New page on activation.
329
  *
330
+ * @since 1.7.0
331
  *
332
+ * @internal Used internally to redirect BuddyPress to the about page on activation.
333
  *
334
+ * @uses get_transient() To see if transient to redirect exists.
335
+ * @uses delete_transient() To delete the transient if it exists.
336
+ * @uses is_network_admin() To bail if being network activated.
337
+ * @uses wp_safe_redirect() To redirect.
338
+ * @uses add_query_arg() To help build the URL to redirect to.
339
+ * @uses admin_url() To get the admin URL to index.php.
340
  */
341
  function bp_do_activation_redirect() {
342
 
366
  /** UI/Styling ****************************************************************/
367
 
368
  /**
369
+ * Output the tabs in the admin area.
370
+ *
371
+ * @since 1.5.0
372
  *
 
373
  * @param string $active_tab Name of the tab that is active. Optional.
374
  */
375
  function bp_core_admin_tabs( $active_tab = '' ) {
380
  /**
381
  * Filters the admin tabs to be displayed.
382
  *
383
+ * @since 1.9.0
384
  *
385
  * @param array $value Array of tabs to output to the admin area.
386
  */
398
  /**
399
  * Fires after the output of tabs for the admin area.
400
  *
401
+ * @since 1.5.0
402
  */
403
  do_action( 'bp_admin_tabs' );
404
  }
406
  /**
407
  * Get the data for the tabs in the admin area.
408
  *
409
+ * @since 2.2.0
410
+ *
411
  * @param string $active_tab Name of the tab that is active. Optional.
412
+ *
413
+ * @return string
414
  */
415
  function bp_core_get_admin_tabs( $active_tab = '' ) {
416
  $tabs = array(
444
  /**
445
  * Filters the tab data used in our wp-admin screens.
446
  *
447
+ * @since 2.2.0
448
  *
449
  * @param array $tabs Tab data.
450
  */
454
  /** Help **********************************************************************/
455
 
456
  /**
457
+ * adds contextual help to BuddyPress admin pages.
458
  *
459
+ * @since 1.7.0
460
  * @todo Make this part of the BP_Component class and split into each component
461
+ *
462
+ * @param string $screen
463
  */
464
  function bp_core_add_contextual_help( $screen = '' ) {
465
 
546
  add_action( 'contextual_help', 'bp_core_add_contextual_help' );
547
 
548
  /**
549
+ * renders contextual help content to contextual help tabs.
550
+ *
551
+ * @since 1.7.0
552
  *
553
+ * @param string $tab
554
+ *
555
+ * @return string
556
  */
557
  function bp_core_add_contextual_help_content( $tab = '' ) {
558
 
589
  /** Separator *****************************************************************/
590
 
591
  /**
592
+ * Add a separator to the WordPress admin menus.
593
  *
594
+ * @since 1.7.0
595
  *
596
+ * @uses bp_current_user_can() To check users capability on root blog.
597
  */
598
  function bp_admin_separator() {
599
 
624
  }
625
 
626
  /**
627
+ * Tell WordPress we have a custom menu order.
628
+ *
629
+ * @since 1.7.0
630
+ * @uses bp_current_user_can() To check users capability on root blog.
631
  *
632
+ * @param bool $menu_order Menu order.
633
  *
 
 
634
  * @return bool Always true
635
  */
636
  function bp_admin_custom_menu_order( $menu_order = false ) {
644
  }
645
 
646
  /**
647
+ * Move our custom separator above our custom post types.
648
  *
649
+ * @since 1.7.0
650
+ * @uses bp_current_user_can() To check users capability on root blog.
651
+ *
652
+ * @param array $menu_order Menu Order.
653
  *
 
 
654
  * @return array Modified menu order
655
  */
656
  function bp_admin_menu_order( $menu_order = array() ) {
669
  /**
670
  * Filters the custom admin menus.
671
  *
672
+ * @since 1.7.0
673
  *
674
  * @param array $value Empty array.
675
  */
712
  /** Utility *****************************************************************/
713
 
714
  /**
715
+ * When using a WP_List_Table, get the currently selected bulk action.
716
  *
717
  * WP_List_Tables have bulk actions at the top and at the bottom of the tables,
718
  * and the inputs have different keys in the $_REQUEST array. This function
719
  * reconciles the two values and returns a single action being performed.
720
  *
721
+ * @since 1.7.0
722
+ *
723
  * @return string
724
  */
725
  function bp_admin_list_table_current_bulk_action() {
737
  /** Menus *********************************************************************/
738
 
739
  /**
740
+ * Register meta box and associated JS for BuddyPress WP Nav Menu.
741
  *
742
+ * @since 1.9.0
743
  */
744
  function bp_admin_wp_nav_menu_meta_box() {
745
  if ( ! bp_is_root_blog() ) {
754
  /**
755
  * Build and populate the BuddyPress accordion on Appearance > Menus.
756
  *
757
+ * @since 1.9.0
758
  *
759
  * @global $nav_menu_selected_id
760
  */
820
  *
821
  * Note: These restrictions are only enforced if JavaScript is enabled.
822
  *
823
+ * @since 1.9.0
824
  */
825
  function bp_admin_wp_nav_menu_restrict_items() {
826
  ?>
841
  /**
842
  * Add "Mark as Spam/Ham" button to user row actions.
843
  *
844
+ * @since 2.0.0
845
  *
846
+ * @param array $actions User row action links.
847
  * @param object $user_object Current user information.
848
+ *
849
  * @return array $actions User row action links.
850
  */
851
  function bp_core_admin_user_row_actions( $actions, $user_object ) {
887
  /**
888
  * Catch requests to mark individual users as spam/ham from users.php.
889
  *
890
+ * @since 2.0.0
891
  */
892
  function bp_core_admin_user_manage_spammers() {
893
 
942
  /**
943
  * Inline script that adds the 'site-spammed' class to spammed users.
944
  *
945
+ * @since 2.0.0
946
  */
947
  function bp_core_admin_user_spammed_js() {
948
  ?>
bp-core/admin/bp-core-admin-schema.php CHANGED
@@ -1,22 +1,21 @@
1
  <?php
2
-
3
  /**
4
- * BuddyPress DB schema
5
  *
6
  * @package BuddyPress
7
  * @subpackage CoreAdministration
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
- * Get the DB schema to use for BuddyPress components
15
  *
16
- * @since BuddyPress (1.1.0)
17
  *
18
  * @global $wpdb $wpdb
19
- * @return string The default database character-set, if set
20
  */
21
  function bp_core_set_charset() {
22
  global $wpdb;
@@ -27,14 +26,14 @@ function bp_core_set_charset() {
27
  }
28
 
29
  /**
30
- * Main installer
31
  *
32
  * Can be passed an optional array of components to explicitly run installation
33
  * routines on, typically the first time a component is activated in Settings.
34
  *
35
- * @since BuddyPress (1.0.0)
36
  *
37
- * @param array $active_components Components to install
38
  */
39
  function bp_core_install( $active_components = false ) {
40
 
@@ -85,9 +84,9 @@ function bp_core_install( $active_components = false ) {
85
  }
86
 
87
  /**
88
- * Install database tables for the Notifications component
89
  *
90
- * @since BuddyPress (1.0.0)
91
  *
92
  * @uses bp_core_set_charset()
93
  * @uses bp_core_get_table_prefix()
@@ -129,9 +128,9 @@ function bp_core_install_notifications() {
129
  }
130
 
131
  /**
132
- * Install database tables for the Activity component
133
  *
134
- * @since BuddyPress (1.0.0)
135
  *
136
  * @uses bp_core_set_charset()
137
  * @uses bp_core_get_table_prefix()
@@ -182,9 +181,9 @@ function bp_core_install_activity_streams() {
182
  }
183
 
184
  /**
185
- * Install database tables for the Notifications component
186
  *
187
- * @since BuddyPress (1.0.0)
188
  *
189
  * @uses bp_core_set_charset()
190
  * @uses bp_core_get_table_prefix()
@@ -210,9 +209,9 @@ function bp_core_install_friends() {
210
  }
211
 
212
  /**
213
- * Install database tables for the Groups component
214
  *
215
- * @since BuddyPress (1.0.0)
216
  *
217
  * @uses bp_core_set_charset()
218
  * @uses bp_core_get_table_prefix()
@@ -270,9 +269,9 @@ function bp_core_install_groups() {
270
  }
271
 
272
  /**
273
- * Install database tables for the Messages component
274
  *
275
- * @since BuddyPress (1.0.0)
276
  *
277
  * @uses bp_core_set_charset()
278
  * @uses bp_core_get_table_prefix()
@@ -330,9 +329,9 @@ function bp_core_install_private_messaging() {
330
  }
331
 
332
  /**
333
- * Install database tables for the Profiles component
334
  *
335
- * @since BuddyPress (1.0.0)
336
  *
337
  * @uses bp_core_set_charset()
338
  * @uses bp_core_get_table_prefix()
@@ -420,9 +419,9 @@ function bp_core_install_extended_profiles() {
420
  }
421
 
422
  /**
423
- * Install database tables for the Sites component
424
  *
425
- * @since BuddyPress (1.0.0)
426
  *
427
  * @uses bp_core_set_charset()
428
  * @uses bp_core_get_table_prefix()
@@ -458,7 +457,7 @@ function bp_core_install_blog_tracking() {
458
  /**
459
  * Install the signups table.
460
  *
461
- * @since BuddyPress (2.0.0)
462
  *
463
  * @global $wpdb
464
  * @uses wp_get_db_schema() to get WordPress ms_global schema
@@ -500,9 +499,9 @@ function bp_core_install_signups() {
500
  *
501
  * This is necessary because WordPress's `pre_schema_upgrade()` function wraps
502
  * table ALTER's in multisite checks, and other plugins may have installed their
503
- * own sign-ups table; Eg: Gravity Forms User Registration Add On
504
  *
505
- * @since BuddyPress (2.0.1)
506
  *
507
  * @see pre_schema_upgrade()
508
  * @link https://core.trac.wordpress.org/ticket/27855 WordPress Trac Ticket
1
  <?php
 
2
  /**
3
+ * BuddyPress DB schema.
4
  *
5
  * @package BuddyPress
6
  * @subpackage CoreAdministration
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
+ * Get the DB schema to use for BuddyPress components.
14
  *
15
+ * @since 1.1.0
16
  *
17
  * @global $wpdb $wpdb
18
+ * @return string The default database character-set, if set.
19
  */
20
  function bp_core_set_charset() {
21
  global $wpdb;
26
  }
27
 
28
  /**
29
+ * Main installer.
30
  *
31
  * Can be passed an optional array of components to explicitly run installation
32
  * routines on, typically the first time a component is activated in Settings.
33
  *
34
+ * @since 1.0.0
35
  *
36
+ * @param array|bool $active_components Components to install.
37
  */
38
  function bp_core_install( $active_components = false ) {
39
 
84
  }
85
 
86
  /**
87
+ * Install database tables for the Notifications component.
88
  *
89
+ * @since 1.0.0
90
  *
91
  * @uses bp_core_set_charset()
92
  * @uses bp_core_get_table_prefix()
128
  }
129
 
130
  /**
131
+ * Install database tables for the Activity component.
132
  *
133
+ * @since 1.0.0
134
  *
135
  * @uses bp_core_set_charset()
136
  * @uses bp_core_get_table_prefix()
181
  }
182
 
183
  /**
184
+ * Install database tables for the Notifications component.
185
  *
186
+ * @since 1.0.0
187
  *
188
  * @uses bp_core_set_charset()
189
  * @uses bp_core_get_table_prefix()
209
  }
210
 
211
  /**
212
+ * Install database tables for the Groups component.
213
  *
214
+ * @since 1.0.0
215
  *
216
  * @uses bp_core_set_charset()
217
  * @uses bp_core_get_table_prefix()
269
  }
270
 
271
  /**
272
+ * Install database tables for the Messages component.
273
  *
274
+ * @since 1.0.0
275
  *
276
  * @uses bp_core_set_charset()
277
  * @uses bp_core_get_table_prefix()
329
  }
330
 
331
  /**
332
+ * Install database tables for the Profiles component.
333
  *
334
+ * @since 1.0.0
335
  *
336
  * @uses bp_core_set_charset()
337
  * @uses bp_core_get_table_prefix()
419
  }
420
 
421
  /**
422
+ * Install database tables for the Sites component.
423
  *
424
+ * @since 1.0.0
425
  *
426
  * @uses bp_core_set_charset()
427
  * @uses bp_core_get_table_prefix()
457
  /**
458
  * Install the signups table.
459
  *
460
+ * @since 2.0.0
461
  *
462
  * @global $wpdb
463
  * @uses wp_get_db_schema() to get WordPress ms_global schema
499
  *
500
  * This is necessary because WordPress's `pre_schema_upgrade()` function wraps
501
  * table ALTER's in multisite checks, and other plugins may have installed their
502
+ * own sign-ups table; Eg: Gravity Forms User Registration Add On.
503
  *
504
+ * @since 2.0.1
505
  *
506
  * @see pre_schema_upgrade()
507
  * @link https://core.trac.wordpress.org/ticket/27855 WordPress Trac Ticket
bp-core/admin/bp-core-admin-settings.php CHANGED
@@ -1,28 +1,27 @@
1
  <?php
2
-
3
  /**
4
- * BuddyPress Admin Settings
5
  *
6
  * @package BuddyPress
7
  * @subpackage CoreAdministration
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
- * Main settings section description for the settings page
15
  *
16
- * @since BuddyPress (1.6.0)
17
  */
18
  function bp_admin_setting_callback_main_section() { }
19
 
20
  /**
21
- * Admin bar for logged out users setting field
22
  *
23
- * @since BuddyPress (1.6.0)
24
  *
25
- * @uses bp_form_option() To output the option value
26
  */
27
  function bp_admin_setting_callback_admin_bar() {
28
  ?>
@@ -34,11 +33,11 @@ function bp_admin_setting_callback_admin_bar() {
34
  }
35
 
36
  /**
37
- * Allow members to delete their accounts setting field
38
  *
39
- * @since BuddyPress (1.6.0)
40
  *
41
- * @uses checked() To display the checked attribute
42
  */
43
  function bp_admin_setting_callback_account_deletion() {
44
  ?>
@@ -52,18 +51,18 @@ function bp_admin_setting_callback_account_deletion() {
52
  /** Activity *******************************************************************/
53
 
54
  /**
55
- * Groups settings section description for the settings page
56
  *
57
- * @since BuddyPress (1.6.0)
58
  */
59
  function bp_admin_setting_callback_activity_section() { }
60
 
61
  /**
62
- * Allow Akismet setting field
63
  *
64
- * @since BuddyPress (1.6.0)
65
  *
66
- * @uses checked() To display the checked attribute
67
  */
68
  function bp_admin_setting_callback_activity_akismet() {
69
  ?>
@@ -75,9 +74,9 @@ function bp_admin_setting_callback_activity_akismet() {
75
  }
76
 
77
  /**
78
- * Allow activity comments on blog posts and forum posts
79
  *
80
- * @since BuddyPress (1.6.0)
81
  */
82
  function bp_admin_setting_callback_blogforum_comments() {
83
  ?>
@@ -91,7 +90,7 @@ function bp_admin_setting_callback_blogforum_comments() {
91
  /**
92
  * Allow Heartbeat to refresh activity stream.
93
  *
94
- * @since BuddyPress (2.0.0)
95
  */
96
  function bp_admin_setting_callback_heartbeat() {
97
  ?>
@@ -103,13 +102,17 @@ function bp_admin_setting_callback_heartbeat() {
103
  }
104
 
105
  /**
106
- * Sanitization for bp-disable-blogforum-comments setting
107
  *
108
  * In the UI, a checkbox asks whether you'd like to *enable* blog/forum activity comments. For
109
  * legacy reasons, the option that we store is 1 if these comments are *disabled*. So we use this
110
  * function to flip the boolean before saving the intval.
111
  *
112
- * @since BuddyPress (1.6.0)
 
 
 
 
113
  */
114
  function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
115
  return $value ? 0 : 1;
@@ -118,18 +121,18 @@ function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
118
  /** XProfile ******************************************************************/
119
 
120
  /**
121
- * Profile settings section description for the settings page
122
  *
123
- * @since BuddyPress (1.6.0)
124
  */
125
  function bp_admin_setting_callback_xprofile_section() { }
126
 
127
  /**
128
- * Enable BP->WP profile syncing field
129
  *
130
- * @since BuddyPress (1.6.0)
131
  *
132
- * @uses bp_form_option() To output the option value
133
  */
134
  function bp_admin_setting_callback_profile_sync() {
135
  ?>
@@ -141,11 +144,11 @@ function bp_admin_setting_callback_profile_sync() {
141
  }
142
 
143
  /**
144
- * Allow members to upload avatars field
145
  *
146
- * @since BuddyPress (1.6.0)
147
  *
148
- * @uses checked() To display the checked attribute
149
  */
150
  function bp_admin_setting_callback_avatar_uploads() {
151
  ?>
@@ -156,21 +159,33 @@ function bp_admin_setting_callback_avatar_uploads() {
156
  <?php
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  /** Groups Section ************************************************************/
160
 
161
  /**
162
- * Groups settings section description for the settings page
163
  *
164
- * @since BuddyPress (1.6.0)
165
  */
166
  function bp_admin_setting_callback_groups_section() { }
167
 
168
  /**
169
- * Allow all users to create groups field
170
  *
171
- * @since BuddyPress (1.6.0)
172
  *
173
- * @uses checked() To display the checked attribute
174
  */
175
  function bp_admin_setting_callback_group_creation() {
176
  ?>
@@ -185,7 +200,7 @@ function bp_admin_setting_callback_group_creation() {
185
  /**
186
  * 'Enable group avatars' field markup.
187
  *
188
- * @since BuddyPress (2.3.0)
189
  */
190
  function bp_admin_setting_callback_group_avatar_uploads() {
191
  ?>
@@ -194,22 +209,34 @@ function bp_admin_setting_callback_group_avatar_uploads() {
194
  <?php
195
  }
196
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  /** Forums Section ************************************************************/
198
 
199
  /**
200
- * Forums settings section description for the settings page
201
  *
202
- * @since BuddyPress (1.6.0)
203
  */
204
  function bp_admin_setting_callback_bbpress_section() { }
205
 
206
  /**
207
- * bb-config.php location field
208
  *
209
- * @since BuddyPress (1.6.0)
210
- * @uses checked() To display the checked attribute
211
- * @uses bp_get_option() To get the config location
212
- * @uses bp_form_option() To get the sanitized form option
213
  */
214
  function bp_admin_setting_callback_bbpress_configuration() {
215
 
@@ -235,11 +262,10 @@ function bp_admin_setting_callback_bbpress_configuration() {
235
  /**
236
  * The main settings page
237
  *
238
- * @since BuddyPress (1.6.0)
239
  *
240
- * @uses screen_icon() To display the screen icon
241
- * @uses settings_fields() To output the hidden fields for the form
242
- * @uses do_settings_sections() To output the settings sections
243
  */
244
  function bp_core_admin_settings() {
245
 
@@ -250,8 +276,6 @@ function bp_core_admin_settings() {
250
 
251
  <div class="wrap">
252
 
253
- <?php screen_icon( 'buddypress' ); ?>
254
-
255
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Settings', 'buddypress' ) ); ?></h2>
256
 
257
  <form action="<?php echo esc_url( $form_action ) ?>" method="post">
@@ -270,9 +294,9 @@ function bp_core_admin_settings() {
270
  }
271
 
272
  /**
273
- * Save our settings
274
  *
275
- * @since BuddyPress (1.6.0)
276
  */
277
  function bp_core_admin_settings_save() {
278
  global $wp_settings_fields;
@@ -296,7 +320,9 @@ function bp_core_admin_settings_save() {
296
  $legacy_options = array(
297
  'bp-disable-account-deletion',
298
  'bp-disable-avatar-uploads',
 
299
  'bp-disable-group-avatar-uploads',
 
300
  'bp_disable_blogforum_comments',
301
  'bp-disable-profile-sync',
302
  'bp_restrict_group_creation',
@@ -317,15 +343,15 @@ function bp_core_admin_settings_save() {
317
  add_action( 'bp_admin_init', 'bp_core_admin_settings_save', 100 );
318
 
319
  /**
320
- * Output settings API option
321
  *
322
- * @since BuddyPress (1.6.0)
323
  *
324
  * @uses bp_get_bp_form_option()
325
  *
326
  * @param string $option
327
  * @param string $default
328
- * @param bool $slug
329
  */
330
  function bp_form_option( $option, $default = '' , $slug = false ) {
331
  echo bp_get_form_option( $option, $default, $slug );
@@ -333,7 +359,7 @@ function bp_form_option( $option, $default = '' , $slug = false ) {
333
  /**
334
  * Return settings API option
335
  *
336
- * @since BuddyPress (1.6.0)
337
  *
338
  * @uses bp_get_option()
339
  * @uses esc_attr()
@@ -341,7 +367,9 @@ function bp_form_option( $option, $default = '' , $slug = false ) {
341
  *
342
  * @param string $option
343
  * @param string $default
344
- * @param bool $slug
 
 
345
  */
346
  function bp_get_form_option( $option, $default = '', $slug = false ) {
347
 
@@ -354,7 +382,7 @@ function bp_form_option( $option, $default = '' , $slug = false ) {
354
  /**
355
  * Filters the slug value in the form field.
356
  *
357
- * @since BuddyPress (1.6.0)
358
  *
359
  * @param string $value Value being returned for the requested option.
360
  */
@@ -370,7 +398,7 @@ function bp_form_option( $option, $default = '' , $slug = false ) {
370
  /**
371
  * Filters the settings API option.
372
  *
373
- * @since BuddyPress (1.6.0)
374
  *
375
  * @param string $value Value being returned for the requested option.
376
  * @param string $option Option whose value is being requested.
1
  <?php
 
2
  /**
3
+ * BuddyPress Admin Settings.
4
  *
5
  * @package BuddyPress
6
  * @subpackage CoreAdministration
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
+ * Main settings section description for the settings page.
14
  *
15
+ * @since 1.6.0
16
  */
17
  function bp_admin_setting_callback_main_section() { }
18
 
19
  /**
20
+ * Admin bar for logged out users setting field.
21
  *
22
+ * @since 1.6.0
23
  *
24
+ * @uses bp_form_option() To output the option value.
25
  */
26
  function bp_admin_setting_callback_admin_bar() {
27
  ?>
33
  }
34
 
35
  /**
36
+ * Allow members to delete their accounts setting field.
37
  *
38
+ * @since 1.6.0
39
  *
40
+ * @uses checked() To display the checked attribute.
41
  */
42
  function bp_admin_setting_callback_account_deletion() {
43
  ?>
51
  /** Activity *******************************************************************/
52
 
53
  /**
54
+ * Groups settings section description for the settings page.
55
  *
56
+ * @since 1.6.0
57
  */
58
  function bp_admin_setting_callback_activity_section() { }
59
 
60
  /**
61
+ * Allow Akismet setting field.
62
  *
63
+ * @since 1.6.0
64
  *
65
+ * @uses checked() To display the checked attribute.
66
  */
67
  function bp_admin_setting_callback_activity_akismet() {
68
  ?>
74
  }
75
 
76
  /**
77
+ * Allow activity comments on blog posts and forum posts.
78
  *
79
+ * @since 1.6.0
80
  */
81
  function bp_admin_setting_callback_blogforum_comments() {
82
  ?>
90
  /**
91
  * Allow Heartbeat to refresh activity stream.
92
  *
93
+ * @since 2.0.0
94
  */
95
  function bp_admin_setting_callback_heartbeat() {
96
  ?>
102
  }
103
 
104
  /**
105
+ * Sanitization for bp-disable-blogforum-comments setting.
106
  *
107
  * In the UI, a checkbox asks whether you'd like to *enable* blog/forum activity comments. For
108
  * legacy reasons, the option that we store is 1 if these comments are *disabled*. So we use this
109
  * function to flip the boolean before saving the intval.
110
  *
111
+ * @since 1.6.0
112
+ *
113
+ * @param bool $value
114
+ *
115
+ * @return bool
116
  */
117
  function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
118
  return $value ? 0 : 1;
121
  /** XProfile ******************************************************************/
122
 
123
  /**
124
+ * Profile settings section description for the settings page.
125
  *
126
+ * @since 1.6.0
127
  */
128
  function bp_admin_setting_callback_xprofile_section() { }
129
 
130
  /**
131
+ * Enable BP->WP profile syncing field.
132
  *
133
+ * @since 1.6.0
134
  *
135
+ * @uses bp_form_option() To output the option value.
136
  */
137
  function bp_admin_setting_callback_profile_sync() {
138
  ?>
144
  }
145
 
146
  /**
147
+ * Allow members to upload avatars field.
148
  *
149
+ * @since 1.6.0
150
  *
151
+ * @uses checked() To display the checked attribute.
152
  */
153
  function bp_admin_setting_callback_avatar_uploads() {
154
  ?>
159
  <?php
160
  }
161
 
162
+ /**
163
+ * Allow members to upload cover images field.
164
+ *
165
+ * @since 2.4.0
166
+ */
167
+ function bp_admin_setting_callback_cover_image_uploads() {
168
+ ?>
169
+ <input id="bp-disable-cover-image-uploads" name="bp-disable-cover-image-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_cover_image_uploads() ); ?> />
170
+ <label for="bp-disable-cover-image-uploads"><?php _e( 'Allow registered members to upload cover images', 'buddypress' ); ?></label>
171
+ <?php
172
+ }
173
+
174
  /** Groups Section ************************************************************/
175
 
176
  /**
177
+ * Groups settings section description for the settings page.
178
  *
179
+ * @since 1.6.0
180
  */
181
  function bp_admin_setting_callback_groups_section() { }
182
 
183
  /**
184
+ * Allow all users to create groups field.
185
  *
186
+ * @since 1.6.0
187
  *
188
+ * @uses checked() To display the checked attribute.
189
  */
190
  function bp_admin_setting_callback_group_creation() {
191
  ?>
200
  /**
201
  * 'Enable group avatars' field markup.
202
  *
203
+ * @since 2.3.0
204
  */
205
  function bp_admin_setting_callback_group_avatar_uploads() {
206
  ?>
209
  <?php
210
  }
211
 
212
+ /**
213
+ * 'Enable group cover images' field markup.
214
+ *
215
+ * @since 2.4.0
216
+ */
217
+ function bp_admin_setting_callback_group_cover_image_uploads() {
218
+ ?>
219
+ <input id="bp-disable-group-cover-image-uploads" name="bp-disable-group-cover-image-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_cover_image_uploads() ); ?> />
220
+ <label for="bp-disable-group-cover-image-uploads"><?php _e( 'Allow customizable cover images for groups', 'buddypress' ); ?></label>
221
+ <?php
222
+ }
223
+
224
  /** Forums Section ************************************************************/
225
 
226
  /**
227
+ * Forums settings section description for the settings page.
228
  *
229
+ * @since 1.6.0
230
  */
231
  function bp_admin_setting_callback_bbpress_section() { }
232
 
233
  /**
234
+ * bb-config.php location field.
235
  *
236
+ * @since 1.6.0
237
+ * @uses checked() To display the checked attribute.
238
+ * @uses bp_get_option() To get the config location.
239
+ * @uses bp_form_option() To get the sanitized form option.
240
  */
241
  function bp_admin_setting_callback_bbpress_configuration() {
242
 
262
  /**
263
  * The main settings page
264
  *
265
+ * @since 1.6.0
266
  *
267
+ * @uses settings_fields() To output the hidden fields for the form.
268
+ * @uses do_settings_sections() To output the settings sections.
 
269
  */
270
  function bp_core_admin_settings() {
271
 
276
 
277
  <div class="wrap">
278
 
 
 
279
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Settings', 'buddypress' ) ); ?></h2>
280
 
281
  <form action="<?php echo esc_url( $form_action ) ?>" method="post">
294
  }
295
 
296
  /**
297
+ * Save our settings.
298
  *
299
+ * @since 1.6.0
300
  */
301
  function bp_core_admin_settings_save() {
302
  global $wp_settings_fields;
320
  $legacy_options = array(
321
  'bp-disable-account-deletion',
322
  'bp-disable-avatar-uploads',
323
+ 'bp-disable-cover-image-uploads',
324
  'bp-disable-group-avatar-uploads',
325
+ 'bp-disable-group-cover-image-uploads',
326
  'bp_disable_blogforum_comments',
327
  'bp-disable-profile-sync',
328
  'bp_restrict_group_creation',
343
  add_action( 'bp_admin_init', 'bp_core_admin_settings_save', 100 );
344
 
345
  /**
346
+ * Output settings API option.
347
  *
348
+ * @since 1.6.0
349
  *
350
  * @uses bp_get_bp_form_option()
351
  *
352
  * @param string $option
353
  * @param string $default
354
+ * @param bool $slug
355
  */
356
  function bp_form_option( $option, $default = '' , $slug = false ) {
357
  echo bp_get_form_option( $option, $default, $slug );
359
  /**
360
  * Return settings API option
361
  *
362
+ * @since 1.6.0
363
  *
364
  * @uses bp_get_option()
365
  * @uses esc_attr()
367
  *
368
  * @param string $option
369
  * @param string $default
370
+ * @param bool $slug
371
+ *
372
+ * @return string
373
  */
374
  function bp_get_form_option( $option, $default = '', $slug = false ) {
375
 
382
  /**
383
  * Filters the slug value in the form field.
384
  *
385
+ * @since 1.6.0
386
  *
387
  * @param string $value Value being returned for the requested option.
388
  */
398
  /**
399
  * Filters the settings API option.
400
  *
401
+ * @since 1.6.0
402
  *
403
  * @param string $value Value being returned for the requested option.
404
  * @param string $option Option whose value is being requested.
bp-core/admin/bp-core-admin-slugs.php CHANGED
@@ -1,19 +1,18 @@
1
  <?php
2
-
3
  /**
4
- * BuddyPress Admin Slug Functions
5
  *
6
  * @package BuddyPress
7
  * @subpackage CoreAdministration
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Renders the page mapping admin panel.
15
  *
16
- * @since BuddyPress (1.6.0)
17
  * @todo Use settings API
18
  * @uses bp_core_admin_component_options()
19
  */
@@ -21,7 +20,6 @@ function bp_core_admin_slugs_settings() {
21
  ?>
22
 
23
  <div class="wrap">
24
- <?php screen_icon( 'buddypress'); ?>
25
 
26
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Pages', 'buddypress' ) ); ?></h2>
27
  <form action="" method="post" id="bp-admin-page-form">
@@ -44,7 +42,7 @@ function bp_core_admin_slugs_settings() {
44
  * Creates reusable markup for page setup on the Components and Pages dashboard panel.
45
  *
46
  * @package BuddyPress
47
- * @since BuddyPress (1.6.0)
48
  * @todo Use settings API
49
  */
50
  function bp_core_admin_slugs_options() {
@@ -75,7 +73,7 @@ function bp_core_admin_slugs_options() {
75
  /**
76
  * Filters the loaded components needing directory page association to a WordPress page.
77
  *
78
- * @since BuddyPress (1.5.0)
79
  *
80
  * @param array $directory_pages Array of available components to set associations for.
81
  */
@@ -129,7 +127,7 @@ function bp_core_admin_slugs_options() {
129
  *
130
  * Allows plugins to add their own directory associations.
131
  *
132
- * @since BuddyPress (1.5.0)
133
  */
134
  do_action( 'bp_active_external_directories' ); ?>
135
 
@@ -151,7 +149,7 @@ function bp_core_admin_slugs_options() {
151
  /**
152
  * Filters the default static pages for BuddyPress setup.
153
  *
154
- * @since BuddyPress (1.6.0)
155
  *
156
  * @param array $static_pages Array of static default static pages.
157
  */
@@ -202,7 +200,7 @@ function bp_core_admin_slugs_options() {
202
  /**
203
  * Fires after the display of default static pages for BuddyPress setup.
204
  *
205
- * @since BuddyPress (1.5.0)
206
  */
207
  do_action( 'bp_active_external_pages' ); ?>
208
 
@@ -214,9 +212,9 @@ function bp_core_admin_slugs_options() {
214
  }
215
 
216
  /**
217
- * Handle saving of the BuddyPress slugs
218
  *
219
- * @since BuddyPress (1.6.0)
220
  * @todo Use settings API
221
  */
222
  function bp_core_admin_slugs_setup_handler() {
1
  <?php
 
2
  /**
3
+ * BuddyPress Admin Slug Functions.
4
  *
5
  * @package BuddyPress
6
  * @subpackage CoreAdministration
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Renders the page mapping admin panel.
14
  *
15
+ * @since 1.6.0
16
  * @todo Use settings API
17
  * @uses bp_core_admin_component_options()
18
  */
20
  ?>
21
 
22
  <div class="wrap">
 
23
 
24
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Pages', 'buddypress' ) ); ?></h2>
25
  <form action="" method="post" id="bp-admin-page-form">
42
  * Creates reusable markup for page setup on the Components and Pages dashboard panel.
43
  *
44
  * @package BuddyPress
45
+ * @since 1.6.0
46
  * @todo Use settings API
47
  */
48
  function bp_core_admin_slugs_options() {
73
  /**
74
  * Filters the loaded components needing directory page association to a WordPress page.
75
  *
76
+ * @since 1.5.0
77
  *
78
  * @param array $directory_pages Array of available components to set associations for.
79
  */
127
  *
128
  * Allows plugins to add their own directory associations.
129
  *
130
+ * @since 1.5.0
131
  */
132
  do_action( 'bp_active_external_directories' ); ?>
133
 
149
  /**
150
  * Filters the default static pages for BuddyPress setup.
151
  *
152
+ * @since 1.6.0
153
  *
154
  * @param array $static_pages Array of static default static pages.
155
  */
200
  /**
201
  * Fires after the display of default static pages for BuddyPress setup.
202
  *
203
+ * @since 1.5.0
204
  */
205
  do_action( 'bp_active_external_pages' ); ?>
206
 
212
  }
213
 
214
  /**
215
+ * Handle saving of the BuddyPress slugs.
216
  *
217
+ * @since 1.6.0
218
  * @todo Use settings API
219
  */
220
  function bp_core_admin_slugs_setup_handler() {
bp-core/admin/bp-core-admin-tools.php CHANGED
@@ -1,20 +1,24 @@
1
  <?php
2
-
3
  /**
4
- * BuddyPress Tools panel
 
 
5
  *
6
- * @since BuddyPress (2.0.0)
 
7
  */
8
 
 
 
 
9
  /**
10
  * Render the BuddyPress Tools page.
11
  *
12
- * @since BuddyPress (2.0.0)
13
  */
14
  function bp_core_admin_tools() {
15
  ?>
16
  <div class="wrap">
17
- <?php screen_icon( 'buddypress'); ?>
18
 
19
  <h2><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h2>
20
 
@@ -35,7 +39,7 @@ function bp_core_admin_tools() {
35
 
36
  <?php foreach ( bp_admin_repair_list() as $item ) : ?>
37
 
38
- <label><input type="checkbox" class="checkbox" name="<?php echo esc_attr( $item[0] ) . '" id="' . esc_attr( str_replace( '_', '-', $item[0] ) ); ?>" value="1" /> <?php echo esc_html( $item[1] ); ?></label><br />
39
 
40
  <?php endforeach; ?>
41
 
@@ -57,7 +61,7 @@ function bp_core_admin_tools() {
57
  /**
58
  * Handle the processing and feedback of the admin tools page.
59
  *
60
- * @since BuddyPress (2.0.0)
61
  */
62
  function bp_admin_repair_handler() {
63
  if ( ! bp_is_post_request() ) {
@@ -147,7 +151,7 @@ function bp_admin_repair_list() {
147
  /**
148
  * Filters the array of the repair list.
149
  *
150
- * @since BuddyPress (2.0.0)
151
  *
152
  * @param array $repair_list Array of values for the Repair list options.
153
  */
@@ -157,7 +161,7 @@ function bp_admin_repair_list() {
157
  /**
158
  * Recalculate friend counts for each user.
159
  *
160
- * @since BuddyPress (2.0.0)
161
  *
162
  * @return array
163
  */
@@ -215,7 +219,7 @@ function bp_admin_repair_friend_count() {
215
  /**
216
  * Recalculate group counts for each user.
217
  *
218
- * @since BuddyPress (2.0.0)
219
  *
220
  * @return array
221
  */
@@ -260,9 +264,9 @@ function bp_admin_repair_group_count() {
260
  }
261
 
262
  /**
263
- * Recalculate user-to-blog relationships and useful blog meta data
264
  *
265
- * @since BuddyPress (2.1.0)
266
  *
267
  * @return array
268
  */
@@ -294,7 +298,7 @@ function bp_admin_repair_blog_records() {
294
  /**
295
  * Recalculate the total number of active site members.
296
  *
297
- * @since BuddyPress (2.0.0)
298
  */
299
  function bp_admin_repair_count_members() {
300
  $statement = __( 'Counting the number of active members on the site&hellip; %s', 'buddypress' );
@@ -308,7 +312,7 @@ function bp_admin_repair_count_members() {
308
  *
309
  * Re-runs the migration from usermeta introduced in BP 2.0.
310
  *
311
- * @since BuddyPress (2.0.0)
312
  */
313
  function bp_admin_repair_last_activity() {
314
  $statement = __( 'Determining last activity dates for each user&hellip; %s', 'buddypress' );
@@ -319,10 +323,12 @@ function bp_admin_repair_last_activity() {
319
  /**
320
  * Assemble admin notices relating success/failure of repair processes.
321
  *
322
- * @since BuddyPress (2.0.0)
 
 
 
323
  *
324
- * @param string $message Feedback message.
325
- * @param unknown $class Unused.
326
  */
327
  function bp_admin_tools_feedback( $message, $class = false ) {
328
  if ( is_string( $message ) ) {
@@ -364,7 +370,7 @@ function bp_admin_tools_feedback( $message, $class = false ) {
364
  * We register this page on Network Admin as a top-level home for our
365
  * BuddyPress tools. This displays the default content.
366
  *
367
- * @since BuddyPress (2.0.0)
368
  */
369
  function bp_core_admin_available_tools_page() {
370
  ?>
@@ -376,7 +382,7 @@ function bp_core_admin_available_tools_page() {
376
  /**
377
  * Fires inside the markup used to display the Available Tools page.
378
  *
379
- * @since BuddyPress (2.0.0)
380
  */
381
  do_action( 'bp_network_tool_box' ); ?>
382
 
@@ -387,7 +393,7 @@ function bp_core_admin_available_tools_page() {
387
  /**
388
  * Render an introduction of BuddyPress tools on Available Tools page.
389
  *
390
- * @since BuddyPress (2.0.0)
391
  */
392
  function bp_core_admin_available_tools_intro() {
393
  $query_arg = array(
1
  <?php
 
2
  /**
3
+ * BuddyPress Tools panel.
4
+ *
5
+ * @since 2.0.0
6
  *
7
+ * @package BuddyPress
8
+ * @subpackage Core
9
  */
10
 
11
+ // Exit if accessed directly.
12
+ defined( 'ABSPATH' ) || exit;
13
+
14
  /**
15
  * Render the BuddyPress Tools page.
16
  *
17
+ * @since 2.0.0
18
  */
19
  function bp_core_admin_tools() {
20
  ?>
21
  <div class="wrap">
 
22
 
23
  <h2><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h2>
24
 
39
 
40
  <?php foreach ( bp_admin_repair_list() as $item ) : ?>
41
 
42
+ <label for="<?php echo esc_attr( str_replace( '_', '-', $item[0] ) ); ?>"><input type="checkbox" class="checkbox" name="<?php echo esc_attr( $item[0] ) . '" id="' . esc_attr( str_replace( '_', '-', $item[0] ) ); ?>" value="1" /> <?php echo esc_html( $item[1] ); ?></label><br />
43
 
44
  <?php endforeach; ?>
45
 
61
  /**
62
  * Handle the processing and feedback of the admin tools page.
63
  *
64
+ * @since 2.0.0
65
  */
66
  function bp_admin_repair_handler() {
67
  if ( ! bp_is_post_request() ) {
151
  /**
152
  * Filters the array of the repair list.
153
  *
154
+ * @since 2.0.0
155
  *
156
  * @param array $repair_list Array of values for the Repair list options.
157
  */
161
  /**
162
  * Recalculate friend counts for each user.
163
  *
164
+ * @since 2.0.0
165
  *
166
  * @return array
167
  */
219
  /**
220
  * Recalculate group counts for each user.
221
  *
222
+ * @since 2.0.0
223
  *
224
  * @return array
225
  */
264
  }
265
 
266
  /**
267
+ * Recalculate user-to-blog relationships and useful blog meta data.
268
  *
269
+ * @since 2.1.0
270
  *
271
  * @return array
272
  */
298
  /**
299
  * Recalculate the total number of active site members.
300
  *
301
+ * @since 2.0.0
302
  */
303
  function bp_admin_repair_count_members() {
304
  $statement = __( 'Counting the number of active members on the site&hellip; %s', 'buddypress' );
312
  *
313
  * Re-runs the migration from usermeta introduced in BP 2.0.
314
  *
315
+ * @since 2.0.0
316
  */
317
  function bp_admin_repair_last_activity() {
318
  $statement = __( 'Determining last activity dates for each user&hellip; %s', 'buddypress' );
323
  /**
324
  * Assemble admin notices relating success/failure of repair processes.
325
  *
326
+ * @since 2.0.0
327
+ *
328
+ * @param string $message Feedback message.
329
+ * @param string|bool $class Unused.
330
  *
331
+ * @return bool
 
332
  */
333
  function bp_admin_tools_feedback( $message, $class = false ) {
334
  if ( is_string( $message ) ) {
370
  * We register this page on Network Admin as a top-level home for our
371
  * BuddyPress tools. This displays the default content.
372
  *
373
+ * @since 2.0.0
374
  */
375
  function bp_core_admin_available_tools_page() {
376
  ?>
382
  /**
383
  * Fires inside the markup used to display the Available Tools page.
384
  *
385
+ * @since 2.0.0
386
  */
387
  do_action( 'bp_network_tool_box' ); ?>
388
 
393
  /**
394
  * Render an introduction of BuddyPress tools on Available Tools page.
395
  *
396
+ * @since 2.0.0
397
  */
398
  function bp_core_admin_available_tools_intro() {
399
  $query_arg = array(
bp-core/admin/css/common-rtl.css CHANGED
@@ -1,7 +1,7 @@
1
  /**
2
  * CSS that is always loaded when in wp-admin
3
  *
4
- * @since BuddyPress (1.6)
5
  */
6
 
7
  /* Welcome Screen
@@ -37,7 +37,7 @@ body.index_page_bp-about span.dashicons {
37
  margin-left: 0;
38
  }
39
 
40
- .about-wrap .feature-list.finer-points h4,
41
  .about-wrap .feature-list.finer-points p {
42
  margin-right: 115px;
43
  }
@@ -60,7 +60,7 @@ body.index_page_bp-about span.dashicons {
60
  margin: 30px 0 0;
61
  text-align: center;
62
  }
63
- .about-wrap .feature-list.finer-points h4,
64
  .about-wrap .feature-list.finer-points p {
65
  margin-right: 90px;
66
  }
@@ -97,93 +97,6 @@ body.users_page_bp-signups td.count_sent {
97
  text-align: center;
98
  }
99
 
100
- /* Icon 32's
101
- ------------------------------------------------------------------------------*/
102
-
103
- body.branch-3-6 div#icon-buddypress,
104
- body.branch-3-7 div#icon-buddypress {
105
- background: url('../images/icons32.png') no-repeat -370px -6px;
106
- }
107
-
108
- body.branch-3-6 div#icon-buddypress-activity,
109
- body.branch-3-7 div#icon-buddypress-activity {
110
- background: url('../images/icons32.png') no-repeat -10px -6px;
111
- }
112
-
113
- body.branch-3-6 div#icon-buddypress-groups,
114
- body.branch-3-7 div#icon-buddypress-groups {
115
- background: url('../images/icons32.png') no-repeat -250px -6px;
116
- }
117
-
118
- /* Menu Icons
119
- ------------------------------------------------------------------------------*/
120
-
121
- /* Backpat */
122
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
123
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
124
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
125
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
126
- background-image: url('../images/menu.png') !important;
127
- background-position: -178px -34px;
128
- }
129
-
130
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,
131
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,
132
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,
133
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,
134
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,
135
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,
136
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,
137
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image {
138
- background-position: -178px -2px;
139
- }
140
-
141
- /* Activity */
142
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
143
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
144
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
145
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image {
146
- background-image: url('../images/menu.png');
147
- background-position: 0 -34px;
148
- }
149
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,
150
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,
151
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,
152
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,
153
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,
154
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,
155
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,
156
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,
157
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,
158
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,
159
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,
160
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image {
161
- background-position: 0 -2px;
162
- }
163
-
164
- /* Groups */
165
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
166
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,
167
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
168
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image {
169
- background-image: url('../images/menu.png');
170
- background-position: -61px -34px;
171
- }
172
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,
173
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,
174
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,
175
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,
176
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,
177
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,
178
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,
179
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,
180
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,
181
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,
182
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,
183
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image {
184
- background-position: -61px -2px;
185
- }
186
-
187
  /* Tools */
188
  #adminmenu .toplevel_page_network-tools div.wp-menu-image:before {
189
  content: "";
@@ -234,22 +147,6 @@ body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-s
234
  content: "\f448";
235
  }
236
 
237
- /* Dashicons overrides for backward compatibility */
238
- body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,
239
- body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,
240
- body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,
241
- body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,
242
- body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,
243
- body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
244
- body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,
245
- body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,
246
- body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,
247
- body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,
248
- body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,
249
- body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
250
- content: "";
251
- }
252
-
253
  /* Settings - Dashicons (WP 3.8+) */
254
  .settings_page_bp-components td.plugin-title span {
255
  float: right;
@@ -299,143 +196,6 @@ body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
299
  content: "\f454";
300
  }
301
 
302
- /* Settings - Legacy (< WP 3.8) */
303
- body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,
304
- body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,
305
- body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,
306
- body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,
307
- body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,
308
- body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,
309
- body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,
310
- body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,
311
- body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,
312
- body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,
313
- body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,
314
- body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before,
315
- body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,
316
- body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,
317
- body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,
318
- body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,
319
- body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,
320
- body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before {
321
- content: "";
322
- }
323
-
324
- body.branch-3-6.settings_page_bp-components td.plugin-title span,
325
- body.branch-3-7.settings_page_bp-components td.plugin-title span {
326
- background-image: url('../images/menu.png');
327
- background-position: -4px -40px;
328
- background-repeat: no-repeat;
329
- }
330
-
331
- body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,
332
- body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span {
333
- background-position-y: -7px;
334
- }
335
-
336
- body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,
337
- body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span {
338
- background-position: -4px -40px;
339
- }
340
-
341
- body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,
342
- body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span {
343
- background-position: -4px -7px;
344
- }
345
-
346
- body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,
347
- body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span {
348
- background-image: url('../images/menu-wp.png');
349
- background-position: -305px -40px;
350
- }
351
-
352
- body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,
353
- body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span {
354
- background-position: -305px -7px;
355
- }
356
-
357
- body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,
358
- body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span {
359
- background-image: url('../images/menu-wp.png');
360
- background-position: -334px -40px;
361
- }
362
-
363
- body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,
364
- body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span {
365
- background-position: -334px -7px;
366
- }
367
-
368
- body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,
369
- body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span {
370
- background-position: -66px -40px;
371
- }
372
-
373
- body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,
374
- body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span {
375
- background-position: -66px -7px;
376
- }
377
-
378
- body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,
379
- body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span {
380
- background-position: -154px -40px;
381
- }
382
-
383
- body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,
384
- body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span {
385
- background-position: -154px -7px;
386
- }
387
-
388
- body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,
389
- body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span {
390
- background-image: url('../images/menu-wp.png');
391
- background-position: -36px -40px;
392
- }
393
-
394
- body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,
395
- body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span {
396
- background-position: -36px -7px;
397
- }
398
-
399
- body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,
400
- body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span {
401
- background-position: -125px -40px;
402
- }
403
-
404
- body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,
405
- body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span {
406
- background-position: -125px -7px;
407
- }
408
-
409
- body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,
410
- body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span {
411
- background-position: -95px -40px;
412
- }
413
-
414
- body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,
415
- body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span {
416
- background-position: -95px -7px;
417
- }
418
-
419
- body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,
420
- body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span {
421
- background-position: -184px -40px;
422
- }
423
-
424
- body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,
425
- body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span {
426
- background-position: -184px -7px;
427
- }
428
-
429
- body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,
430
- body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span {
431
- background-position: -36px -40px;
432
- }
433
-
434
- body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,
435
- body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span {
436
- background-position: -36px -7px;
437
- }
438
-
439
  #bp-admin-component-form .widefat th {
440
  display: table-cell;
441
  vertical-align: top;
@@ -467,39 +227,5 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
467
  margin: 10px auto;
468
  top: auto;
469
  left: auto;
470
- }
471
- }
472
-
473
- /* HiDPI
474
- ------------------------------------------------------------------------------*/
475
-
476
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
477
-
478
- /* Icon 32 */
479
- body.branch-3-6 div#icon-buddypress,
480
- body.branch-3-6 div#icon-buddypress-activity,
481
- body.branch-3-6 div#icon-buddypress-groups,
482
- body.branch-3-7 div#icon-buddypress,
483
- body.branch-3-7 div#icon-buddypress-activity,
484
- body.branch-3-7 div#icon-buddypress-groups {
485
- background-image: url('../images/icons64.png');
486
- background-size: 419px 45px;
487
- }
488
-
489
- /* Backpat */
490
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
491
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
492
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
493
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
494
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
495
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,
496
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
497
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
498
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
499
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
500
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
501
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image {
502
- background-image: url('../images/menu-2x.png') !important;
503
- background-size: 209px 64px;
504
  }
505
  }
1
  /**
2
  * CSS that is always loaded when in wp-admin
3
  *
4
+ * @since 1.6.0
5
  */
6
 
7
  /* Welcome Screen
37
  margin-left: 0;
38
  }
39
 
40
+ .about-wrap .feature-list.finer-points h4,
41
  .about-wrap .feature-list.finer-points p {
42
  margin-right: 115px;
43
  }
60
  margin: 30px 0 0;
61
  text-align: center;
62
  }
63
+ .about-wrap .feature-list.finer-points h4,
64
  .about-wrap .feature-list.finer-points p {
65
  margin-right: 90px;
66
  }
97
  text-align: center;
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  /* Tools */
101
  #adminmenu .toplevel_page_network-tools div.wp-menu-image:before {
102
  content: "";
147
  content: "\f448";
148
  }
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  /* Settings - Dashicons (WP 3.8+) */
151
  .settings_page_bp-components td.plugin-title span {
152
  float: right;
196
  content: "\f454";
197
  }
198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  #bp-admin-component-form .widefat th {
200
  display: table-cell;
201
  vertical-align: top;
227
  margin: 10px auto;
228
  top: auto;
229
  left: auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
  }
bp-core/admin/css/common-rtl.min.css CHANGED
@@ -1 +1 @@
1
- body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:right;clear:right;margin:15px 0 0 15px;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}.about-wrap .two-col>div{position:relative;width:47.6%;margin-left:4.799999999%;float:right}.about-wrap [class$=col] .last-feature{margin-left:0}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-right:115px}@media screen and (max-width:782px){.about-wrap .two-col>div{width:100%;margin:30px 0 0;padding:0 0 30px;border-bottom:1px solid rgba(0,0,0,.1)}body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{font-size:55px;line-height:70px;height:70px;width:70px}.about-wrap .feature-list h2{margin:30px 0 0;text-align:center}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-right:90px}}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:right;width:18px;height:18px;margin-left:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;left:0}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;left:auto}}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
1
+ body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:right;clear:right;margin:15px 0 0 15px;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}.about-wrap .two-col>div{position:relative;width:47.6%;margin-left:4.799999999%;float:right}.about-wrap [class$=col] .last-feature{margin-left:0}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-right:115px}@media screen and (max-width:782px){.about-wrap .two-col>div{width:100%;margin:30px 0 0;padding:0 0 30px;border-bottom:1px solid rgba(0,0,0,.1)}body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{font-size:55px;line-height:70px;height:70px;width:70px}.about-wrap .feature-list h2{margin:30px 0 0;text-align:center}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-right:90px}}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}.settings_page_bp-components td.plugin-title span{float:right;width:18px;height:18px;margin-left:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;left:0}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;left:auto}}
bp-core/admin/css/common.css CHANGED
@@ -1,7 +1,7 @@
1
  /**
2
  * CSS that is always loaded when in wp-admin
3
  *
4
- * @since BuddyPress (1.6)
5
  */
6
 
7
  /* Welcome Screen
@@ -37,7 +37,7 @@ body.index_page_bp-about span.dashicons {
37
  margin-right: 0;
38
  }
39
 
40
- .about-wrap .feature-list.finer-points h4,
41
  .about-wrap .feature-list.finer-points p {
42
  margin-left: 115px;
43
  }
@@ -60,7 +60,7 @@ body.index_page_bp-about span.dashicons {
60
  margin: 30px 0 0;
61
  text-align: center;
62
  }
63
- .about-wrap .feature-list.finer-points h4,
64
  .about-wrap .feature-list.finer-points p {
65
  margin-left: 90px;
66
  }
@@ -97,93 +97,6 @@ body.users_page_bp-signups td.count_sent {
97
  text-align: center;
98
  }
99
 
100
- /* Icon 32's
101
- ------------------------------------------------------------------------------*/
102
-
103
- body.branch-3-6 div#icon-buddypress,
104
- body.branch-3-7 div#icon-buddypress {
105
- background: url('../images/icons32.png') no-repeat -370px -6px;
106
- }
107
-
108
- body.branch-3-6 div#icon-buddypress-activity,
109
- body.branch-3-7 div#icon-buddypress-activity {
110
- background: url('../images/icons32.png') no-repeat -10px -6px;
111
- }
112
-
113
- body.branch-3-6 div#icon-buddypress-groups,
114
- body.branch-3-7 div#icon-buddypress-groups {
115
- background: url('../images/icons32.png') no-repeat -250px -6px;
116
- }
117
-
118
- /* Menu Icons
119
- ------------------------------------------------------------------------------*/
120
-
121
- /* Backpat */
122
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
123
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
124
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
125
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
126
- background-image: url('../images/menu.png') !important;
127
- background-position: -178px -34px;
128
- }
129
-
130
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,
131
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,
132
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,
133
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,
134
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,
135
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,
136
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,
137
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image {
138
- background-position: -178px -2px;
139
- }
140
-
141
- /* Activity */
142
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
143
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
144
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
145
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image {
146
- background-image: url('../images/menu.png');
147
- background-position: 0 -34px;
148
- }
149
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,
150
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,
151
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,
152
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,
153
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,
154
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,
155
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,
156
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,
157
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,
158
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,
159
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,
160
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image {
161
- background-position: 0 -2px;
162
- }
163
-
164
- /* Groups */
165
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
166
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,
167
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
168
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image {
169
- background-image: url('../images/menu.png');
170
- background-position: -61px -34px;
171
- }
172
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,
173
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,
174
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,
175
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,
176
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,
177
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,
178
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,
179
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,
180
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,
181
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,
182
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,
183
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image {
184
- background-position: -61px -2px;
185
- }
186
-
187
  /* Tools */
188
  #adminmenu .toplevel_page_network-tools div.wp-menu-image:before {
189
  content: "";
@@ -234,22 +147,6 @@ body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-s
234
  content: "\f448";
235
  }
236
 
237
- /* Dashicons overrides for backward compatibility */
238
- body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,
239
- body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,
240
- body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,
241
- body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,
242
- body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,
243
- body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
244
- body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,
245
- body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,
246
- body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,
247
- body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,
248
- body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,
249
- body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
250
- content: "";
251
- }
252
-
253
  /* Settings - Dashicons (WP 3.8+) */
254
  .settings_page_bp-components td.plugin-title span {
255
  float: left;
@@ -299,143 +196,6 @@ body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
299
  content: "\f454";
300
  }
301
 
302
- /* Settings - Legacy (< WP 3.8) */
303
- body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,
304
- body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,
305
- body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,
306
- body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,
307
- body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,
308
- body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,
309
- body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,
310
- body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,
311
- body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,
312
- body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,
313
- body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,
314
- body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before,
315
- body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,
316
- body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,
317
- body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,
318
- body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,
319
- body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,
320
- body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before {
321
- content: "";
322
- }
323
-
324
- body.branch-3-6.settings_page_bp-components td.plugin-title span,
325
- body.branch-3-7.settings_page_bp-components td.plugin-title span {
326
- background-image: url('../images/menu.png');
327
- background-position: -4px -40px;
328
- background-repeat: no-repeat;
329
- }
330
-
331
- body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,
332
- body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span {
333
- background-position-y: -7px;
334
- }
335
-
336
- body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,
337
- body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span {
338
- background-position: -4px -40px;
339
- }
340
-
341
- body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,
342
- body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span {
343
- background-position: -4px -7px;
344
- }
345
-
346
- body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,
347
- body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span {
348
- background-image: url('../images/menu-wp.png');
349
- background-position: -305px -40px;
350
- }
351
-
352
- body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,
353
- body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span {
354
- background-position: -305px -7px;
355
- }
356
-
357
- body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,
358
- body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span {
359
- background-image: url('../images/menu-wp.png');
360
- background-position: -334px -40px;
361
- }
362
-
363
- body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,
364
- body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span {
365
- background-position: -334px -7px;
366
- }
367
-
368
- body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,
369
- body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span {
370
- background-position: -66px -40px;
371
- }
372
-
373
- body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,
374
- body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span {
375
- background-position: -66px -7px;
376
- }
377
-
378
- body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,
379
- body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span {
380
- background-position: -154px -40px;
381
- }
382
-
383
- body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,
384
- body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span {
385
- background-position: -154px -7px;
386
- }
387
-
388
- body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,
389
- body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span {
390
- background-image: url('../images/menu-wp.png');
391
- background-position: -36px -40px;
392
- }
393
-
394
- body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,
395
- body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span {
396
- background-position: -36px -7px;
397
- }
398
-
399
- body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,
400
- body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span {
401
- background-position: -125px -40px;
402
- }
403
-
404
- body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,
405
- body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span {
406
- background-position: -125px -7px;
407
- }
408
-
409
- body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,
410
- body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span {
411
- background-position: -95px -40px;
412
- }
413
-
414
- body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,
415
- body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span {
416
- background-position: -95px -7px;
417
- }
418
-
419
- body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,
420
- body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span {
421
- background-position: -184px -40px;
422
- }
423
-
424
- body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,
425
- body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span {
426
- background-position: -184px -7px;
427
- }
428
-
429
- body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,
430
- body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span {
431
- background-position: -36px -40px;
432
- }
433
-
434
- body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,
435
- body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span {
436
- background-position: -36px -7px;
437
- }
438
-
439
  #bp-admin-component-form .widefat th {
440
  display: table-cell;
441
  vertical-align: top;
@@ -467,39 +227,5 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
467
  margin: 10px auto;
468
  top: auto;
469
  right: auto;
470
- }
471
- }
472
-
473
- /* HiDPI
474
- ------------------------------------------------------------------------------*/
475
-
476
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
477
-
478
- /* Icon 32 */
479
- body.branch-3-6 div#icon-buddypress,
480
- body.branch-3-6 div#icon-buddypress-activity,
481
- body.branch-3-6 div#icon-buddypress-groups,
482
- body.branch-3-7 div#icon-buddypress,
483
- body.branch-3-7 div#icon-buddypress-activity,
484
- body.branch-3-7 div#icon-buddypress-groups {
485
- background-image: url('../images/icons64.png');
486
- background-size: 419px 45px;
487
- }
488
-
489
- /* Backpat */
490
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
491
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
492
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
493
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
494
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
495
- body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,
496
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
497
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
498
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
499
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
500
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
501
- body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image {
502
- background-image: url('../images/menu-2x.png') !important;
503
- background-size: 209px 64px;
504
  }
505
  }
1
  /**
2
  * CSS that is always loaded when in wp-admin
3
  *
4
+ * @since 1.6.0
5
  */
6
 
7
  /* Welcome Screen
37
  margin-right: 0;
38
  }
39
 
40
+ .about-wrap .feature-list.finer-points h4,
41
  .about-wrap .feature-list.finer-points p {
42
  margin-left: 115px;
43
  }
60
  margin: 30px 0 0;
61
  text-align: center;
62
  }
63
+ .about-wrap .feature-list.finer-points h4,
64
  .about-wrap .feature-list.finer-points p {
65
  margin-left: 90px;
66
  }
97
  text-align: center;
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  /* Tools */
101
  #adminmenu .toplevel_page_network-tools div.wp-menu-image:before {
102
  content: "";
147
  content: "\f448";
148
  }
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  /* Settings - Dashicons (WP 3.8+) */
151
  .settings_page_bp-components td.plugin-title span {
152
  float: left;
196
  content: "\f454";
197
  }
198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  #bp-admin-component-form .widefat th {
200
  display: table-cell;
201
  vertical-align: top;
227
  margin: 10px auto;
228
  top: auto;
229
  right: auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
  }
bp-core/admin/css/common.min.css CHANGED
@@ -1 +1 @@
1
- body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:left;clear:left;margin:15px 15px 0 0;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}.about-wrap .two-col>div{position:relative;width:47.6%;margin-right:4.799999999%;float:left}.about-wrap [class$=col] .last-feature{margin-right:0}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-left:115px}@media screen and (max-width:782px){.about-wrap .two-col>div{width:100%;margin:30px 0 0;padding:0 0 30px;border-bottom:1px solid rgba(0,0,0,.1)}body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{font-size:55px;line-height:70px;height:70px;width:70px}.about-wrap .feature-list h2{margin:30px 0 0;text-align:center}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-left:90px}}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:left;width:18px;height:18px;margin-right:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;right:0}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;right:auto}}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
1
+ body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:left;clear:left;margin:15px 15px 0 0;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}.about-wrap .two-col>div{position:relative;width:47.6%;margin-right:4.799999999%;float:left}.about-wrap [class$=col] .last-feature{margin-right:0}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-left:115px}@media screen and (max-width:782px){.about-wrap .two-col>div{width:100%;margin:30px 0 0;padding:0 0 30px;border-bottom:1px solid rgba(0,0,0,.1)}body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{font-size:55px;line-height:70px;height:70px;width:70px}.about-wrap .feature-list h2{margin:30px 0 0;text-align:center}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-left:90px}}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}.settings_page_bp-components td.plugin-title span{float:left;width:18px;height:18px;margin-right:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;right:0}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;right:auto}}
bp-core/admin/images/icons32.png DELETED
Binary file
bp-core/admin/images/icons64.png DELETED
Binary file
bp-core/admin/images/menu-2x.png DELETED
Binary file
bp-core/admin/images/menu-wp.png DELETED
Binary file
bp-core/admin/images/menu.png DELETED
Binary file
bp-core/bp-core-actions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Filters & Actions.
5
  *
@@ -9,10 +8,9 @@
9
  * This file contains the actions and filters that are used through-out BuddyPress.
10
  * They are consolidated here to make searching for them easier, and to help
11
  * developers understand at a glance the order in which things occur.
12
- *
13
  */
14
 
15
- // Exit if accessed directly
16
  defined( 'ABSPATH' ) || exit;
17
 
18
  /**
@@ -33,19 +31,19 @@ defined( 'ABSPATH' ) || exit;
33
  */
34
  add_action( 'plugins_loaded', 'bp_loaded', 10 );
35
  add_action( 'init', 'bp_init', 10 );
36
- add_action( 'parse_query', 'bp_parse_query', 2 ); // Early for overrides
37
  add_action( 'wp', 'bp_ready', 10 );
38
  add_action( 'set_current_user', 'bp_setup_current_user', 10 );
39
  add_action( 'setup_theme', 'bp_setup_theme', 10 );
40
- add_action( 'after_setup_theme', 'bp_after_setup_theme', 100 ); // After WP themes
41
  add_action( 'wp_enqueue_scripts', 'bp_enqueue_scripts', 10 );
42
- add_action( 'admin_bar_menu', 'bp_setup_admin_bar', 20 ); // After WP core
43
  add_action( 'template_redirect', 'bp_template_redirect', 10 );
44
  add_action( 'widgets_init', 'bp_widgets_init', 10 );
45
  add_action( 'generate_rewrite_rules', 'bp_generate_rewrite_rules', 10 );
46
 
47
  /**
48
- * bp_loaded - Attached to 'plugins_loaded' above
49
  *
50
  * Attach various loader actions to the bp_loaded action.
51
  * The load order helps to execute code at the correct time.
@@ -60,7 +58,7 @@ add_action( 'bp_loaded', 'bp_register_theme_packages', 12 );
60
  add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
61
 
62
  /**
63
- * bp_init - Attached to 'init' above
64
  *
65
  * Attach various initialization actions to the bp_init action.
66
  * The load order helps to execute code at the correct time.
@@ -78,7 +76,7 @@ add_action( 'bp_init', 'bp_add_rewrite_rules', 30 );
78
  add_action( 'bp_init', 'bp_add_permastructs', 40 );
79
 
80
  /**
81
- * bp_template_redirect - Attached to 'template_redirect' above
82
  *
83
  * Attach various template actions to the bp_template_redirect action.
84
  * The load order helps to execute code at the correct time.
@@ -95,14 +93,15 @@ add_action( 'bp_template_redirect', 'bp_post_request', 10 );
95
  add_action( 'bp_template_redirect', 'bp_get_request', 10 );
96
 
97
  /**
98
- * Add the BuddyPress functions file
99
  */
100
- add_action( 'bp_after_setup_theme', 'bp_load_theme_functions', 1 );
 
101
 
102
- // Load the admin
103
  if ( is_admin() ) {
104
  add_action( 'bp_loaded', 'bp_admin' );
105
  }
106
 
107
- // Activation redirect
108
  add_action( 'bp_activation', 'bp_add_activation_redirect' );
1
  <?php
 
2
  /**
3
  * BuddyPress Filters & Actions.
4
  *
8
  * This file contains the actions and filters that are used through-out BuddyPress.
9
  * They are consolidated here to make searching for them easier, and to help
10
  * developers understand at a glance the order in which things occur.
 
11
  */
12
 
13
+ // Exit if accessed directly.
14
  defined( 'ABSPATH' ) || exit;
15
 
16
  /**
31
  */
32
  add_action( 'plugins_loaded', 'bp_loaded', 10 );
33
  add_action( 'init', 'bp_init', 10 );
34
+ add_action( 'parse_query', 'bp_parse_query', 2 ); // Early for overrides.
35
  add_action( 'wp', 'bp_ready', 10 );
36
  add_action( 'set_current_user', 'bp_setup_current_user', 10 );
37
  add_action( 'setup_theme', 'bp_setup_theme', 10 );
38
+ add_action( 'after_setup_theme', 'bp_after_setup_theme', 100 ); // After WP themes.
39
  add_action( 'wp_enqueue_scripts', 'bp_enqueue_scripts', 10 );
40
+ add_action( 'admin_bar_menu', 'bp_setup_admin_bar', 20 ); // After WP core.
41
  add_action( 'template_redirect', 'bp_template_redirect', 10 );
42
  add_action( 'widgets_init', 'bp_widgets_init', 10 );
43
  add_action( 'generate_rewrite_rules', 'bp_generate_rewrite_rules', 10 );
44
 
45
  /**
46
+ * bp_loaded - Attached to 'plugins_loaded' above.
47
  *
48
  * Attach various loader actions to the bp_loaded action.
49
  * The load order helps to execute code at the correct time.
58
  add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
59
 
60
  /**
61
+ * bp_init - Attached to 'init' above.
62
  *
63
  * Attach various initialization actions to the bp_init action.
64
  * The load order helps to execute code at the correct time.
76
  add_action( 'bp_init', 'bp_add_permastructs', 40 );
77
 
78
  /**
79
+ * bp_template_redirect - Attached to 'template_redirect' above.
80
  *
81
  * Attach various template actions to the bp_template_redirect action.
82
  * The load order helps to execute code at the correct time.
93
  add_action( 'bp_template_redirect', 'bp_get_request', 10 );
94
 
95
  /**
96
+ * Add the BuddyPress functions file and the Theme Compat Default features.
97
  */
98
+ add_action( 'bp_after_setup_theme', 'bp_load_theme_functions', 1 );
99
+ add_action( 'bp_after_setup_theme', 'bp_register_theme_compat_default_features', 10 );
100
 
101
+ // Load the admin.
102
  if ( is_admin() ) {
103
  add_action( 'bp_loaded', 'bp_admin' );
104
  }
105
 
106
+ // Activation redirect.
107
  add_action( 'bp_activation', 'bp_add_activation_redirect' );
bp-core/bp-core-admin.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Main BuddyPress Admin Class.
5
  *
@@ -7,10 +6,11 @@
7
  * @subpackage CoreAdministration
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  if ( !class_exists( 'BP_Admin' ) ) :
 
14
  /**
15
  * Load BuddyPress plugin admin area.
16
  *
@@ -18,7 +18,7 @@ if ( !class_exists( 'BP_Admin' ) ) :
18
  * @subpackage CoreAdministration
19
  * @todo Break this apart into each applicable Component
20
  *
21
- * @since BuddyPress (1.6.0)
22
  */
23
  class BP_Admin {
24
 
@@ -75,7 +75,7 @@ class BP_Admin {
75
  /**
76
  * The main BuddyPress admin loader.
77
  *
78
- * @since BuddyPress (1.6.0)
79
  *
80
  * @uses BP_Admin::setup_globals() Setup the globals needed.
81
  * @uses BP_Admin::includes() Include the required files.
@@ -90,8 +90,7 @@ class BP_Admin {
90
  /**
91
  * Set admin-related globals.
92
  *
93
- * @access private
94
- * @since BuddyPress (1.6.0)
95
  */
96
  private function setup_globals() {
97
  $bp = buddypress();
@@ -113,8 +112,7 @@ class BP_Admin {
113
  /**
114
  * Include required files.
115
  *
116
- * @since BuddyPress (1.6.0)
117
- * @access private
118
  */
119
  private function includes() {
120
  require( $this->admin_dir . 'bp-core-admin-actions.php' );
@@ -128,8 +126,7 @@ class BP_Admin {
128
  /**
129
  * Set up the admin hooks, actions, and filters.
130
  *
131
- * @access private
132
- * @since BuddyPress (1.6.0)
133
  *
134
  * @uses add_action() To add various actions.
135
  * @uses add_filter() To add various filters.
@@ -179,7 +176,7 @@ class BP_Admin {
179
  /**
180
  * Add the navigational menu elements.
181
  *
182
- * @since BuddyPress (1.6.0)
183
  *
184
  * @uses add_management_page() To add the Recount page in Tools section.
185
  * @uses add_options_page() To add the Forums settings page in Settings
@@ -304,7 +301,7 @@ class BP_Admin {
304
  /**
305
  * Register the settings.
306
  *
307
- * @since BuddyPress (1.6.0)
308
  *
309
  * @uses add_settings_section() To add our own settings section.
310
  * @uses add_settings_field() To add various settings fields.
@@ -319,17 +316,17 @@ class BP_Admin {
319
 
320
  // Hide toolbar for logged out users setting
321
  add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
322
- register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
323
 
324
  // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade
325
  if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) {
326
  add_settings_field( '_bp_force_buddybar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_force_buddybar', 'buddypress', 'bp_main' );
327
- register_setting( 'buddypress', '_bp_force_buddybar', 'bp_admin_sanitize_callback_force_buddybar' );
328
  }
329
 
330
  // Allow account deletion
331
  add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
332
- register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
333
 
334
  /** XProfile Section **************************************************/
335
 
@@ -338,9 +335,16 @@ class BP_Admin {
338
  // Add the main section
339
  add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
340
 
 
341
  add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' );
342
  register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
343
 
 
 
 
 
 
 
344
  // Profile sync setting
345
  add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
346
  register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
@@ -360,6 +364,12 @@ class BP_Admin {
360
  // Allow group avatars.
361
  add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' );
362
  register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' );
 
 
 
 
 
 
363
  }
364
 
365
  /** Forums ************************************************************/
@@ -400,7 +410,7 @@ class BP_Admin {
400
  /**
401
  * Add a link to BuddyPress About page to the admin bar.
402
  *
403
- * @since BuddyPress (1.9.0)
404
  *
405
  * @param WP_Admin_Bar $wp_admin_bar As passed to 'admin_bar_menu'.
406
  */
@@ -418,10 +428,11 @@ class BP_Admin {
418
  /**
419
  * Add Settings link to plugins area.
420
  *
421
- * @since BuddyPress (1.6.0)
 
 
 
422
  *
423
- * @param array $links Links array in which we would prepend our link.
424
- * @param string $file Current plugin basename.
425
  * @return array Processed links.
426
  */
427
  public function modify_plugin_action_links( $links, $file ) {
@@ -441,7 +452,7 @@ class BP_Admin {
441
  /**
442
  * Add some general styling to the admin area.
443
  *
444
- * @since BuddyPress (1.6.0)
445
  */
446
  public function admin_head() {
447
 
@@ -460,7 +471,7 @@ class BP_Admin {
460
  /**
461
  * Add some general styling to the admin area.
462
  *
463
- * @since BuddyPress (1.6.0)
464
  */
465
  public function enqueue_scripts() {
466
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -470,7 +481,7 @@ class BP_Admin {
470
  /**
471
  * Filters the BuddyPress Core Admin CSS file path.
472
  *
473
- * @since BuddyPress (1.6.0)
474
  *
475
  * @param string $file File path for the admin CSS.
476
  */
@@ -488,7 +499,7 @@ class BP_Admin {
488
  /**
489
  * Output the about screen.
490
  *
491
- * @since BuddyPress (1.7.0)
492
  */
493
  public function about_screen() {
494
  ?>
@@ -626,7 +637,7 @@ class BP_Admin {
626
  * Hardcoding this in here is pretty janky. It's fine for now, but we'll
627
  * want to leverage api.wordpress.org eventually.
628
  *
629
- * @since BuddyPress (1.7.0)
630
  */
631
  public function credits_screen() {
632
  ?>
@@ -774,9 +785,9 @@ class BP_Admin {
774
  }
775
 
776
  /**
777
- * Output welcome text and badge for What's New and Credits pages
778
  *
779
- * @since BuddyPress (2.2.0)
780
  */
781
  public static function welcome_text() {
782
 
@@ -798,9 +809,9 @@ class BP_Admin {
798
  }
799
 
800
  /**
801
- * Output tab navigation for `What's New` and `Credits` pages
802
  *
803
- * @since BuddyPress (2.2.0)
804
  * @param string $tab
805
  */
806
  public static function tab_navigation( $tab = 'whats_new' ) {
@@ -820,11 +831,12 @@ class BP_Admin {
820
  /** Helpers ***************************************************************/
821
 
822
  /**
823
- * Return true/false based on whether a query argument is set
824
  *
825
  * @see bp_do_activation_redirect()
826
  *
827
- * @since BuddyPress (2.2.0)
 
828
  * @return bool
829
  */
830
  public static function is_new_install() {
@@ -832,9 +844,10 @@ class BP_Admin {
832
  }
833
 
834
  /**
835
- * Return a user-friendly version-number string, for use in translations
 
 
836
  *
837
- * @since BuddyPress (2.2.0)
838
  * @return string
839
  */
840
  public static function display_version() {
@@ -866,7 +879,7 @@ endif; // class_exists check
866
  /**
867
  * Setup BuddyPress Admin.
868
  *
869
- * @since BuddyPress (1.6.0)
870
  *
871
  * @uses BP_Admin
872
  */
1
  <?php
 
2
  /**
3
  * Main BuddyPress Admin Class.
4
  *
6
  * @subpackage CoreAdministration
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  if ( !class_exists( 'BP_Admin' ) ) :
13
+
14
  /**
15
  * Load BuddyPress plugin admin area.
16
  *
18
  * @subpackage CoreAdministration
19
  * @todo Break this apart into each applicable Component
20
  *
21
+ * @since 1.6.0
22
  */
23
  class BP_Admin {
24
 
75
  /**
76
  * The main BuddyPress admin loader.
77
  *
78
+ * @since 1.6.0
79
  *
80
  * @uses BP_Admin::setup_globals() Setup the globals needed.
81
  * @uses BP_Admin::includes() Include the required files.
90
  /**
91
  * Set admin-related globals.
92
  *
93
+ * @since 1.6.0
 
94
  */
95
  private function setup_globals() {
96
  $bp = buddypress();
112
  /**
113
  * Include required files.
114
  *
115
+ * @since 1.6.0
 
116
  */
117
  private function includes() {
118
  require( $this->admin_dir . 'bp-core-admin-actions.php' );
126
  /**
127
  * Set up the admin hooks, actions, and filters.
128
  *
129
+ * @since 1.6.0
 
130
  *
131
  * @uses add_action() To add various actions.
132
  * @uses add_filter() To add various filters.
176
  /**
177
  * Add the navigational menu elements.
178
  *
179
+ * @since 1.6.0
180
  *
181
  * @uses add_management_page() To add the Recount page in Tools section.
182
  * @uses add_options_page() To add the Forums settings page in Settings
301
  /**
302
  * Register the settings.
303
  *
304
+ * @since 1.6.0
305
  *
306
  * @uses add_settings_section() To add our own settings section.
307
  * @uses add_settings_field() To add various settings fields.
316
 
317
  // Hide toolbar for logged out users setting
318
  add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
319
+ register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
320
 
321
  // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade
322
  if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) {
323
  add_settings_field( '_bp_force_buddybar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_force_buddybar', 'buddypress', 'bp_main' );
324
+ register_setting( 'buddypress', '_bp_force_buddybar', 'bp_admin_sanitize_callback_force_buddybar' );
325
  }
326
 
327
  // Allow account deletion
328
  add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
329
+ register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
330
 
331
  /** XProfile Section **************************************************/
332
 
335
  // Add the main section
336
  add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
337
 
338
+ // Avatars
339
  add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' );
340
  register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
341
 
342
+ // Cover images
343
+ if ( bp_is_active( 'xprofile', 'cover_image' ) ) {
344
+ add_settings_field( 'bp-disable-cover-image-uploads', __( 'Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_cover_image_uploads', 'buddypress', 'bp_xprofile' );
345
+ register_setting( 'buddypress', 'bp-disable-cover-image-uploads', 'intval' );
346
+ }
347
+
348
  // Profile sync setting
349
  add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
350
  register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
364
  // Allow group avatars.
365
  add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' );
366
  register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' );
367
+
368
+ // Allow group cover images.
369
+ if ( bp_is_active( 'groups', 'cover_image' ) ) {
370
+ add_settings_field( 'bp-disable-group-cover-image-uploads', __( 'Group Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_cover_image_uploads', 'buddypress', 'bp_groups' );
371
+ register_setting( 'buddypress', 'bp-disable-group-cover-image-uploads', 'intval' );
372
+ }
373
  }
374
 
375
  /** Forums ************************************************************/
410
  /**
411
  * Add a link to BuddyPress About page to the admin bar.
412
  *
413
+ * @since 1.9.0
414
  *
415
  * @param WP_Admin_Bar $wp_admin_bar As passed to 'admin_bar_menu'.
416
  */
428
  /**
429
  * Add Settings link to plugins area.
430
  *
431
+ * @since 1.6.0
432
+ *
433
+ * @param array $links Links array in which we would prepend our link.
434
+ * @param string $file Current plugin basename.
435
  *
 
 
436
  * @return array Processed links.
437
  */
438
  public function modify_plugin_action_links( $links, $file ) {
452
  /**
453
  * Add some general styling to the admin area.
454
  *
455
+ * @since 1.6.0
456
  */
457
  public function admin_head() {
458
 
471
  /**
472
  * Add some general styling to the admin area.
473
  *
474
+ * @since 1.6.0
475
  */
476
  public function enqueue_scripts() {
477
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
481
  /**
482
  * Filters the BuddyPress Core Admin CSS file path.
483
  *
484
+ * @since 1.6.0
485
  *
486
  * @param string $file File path for the admin CSS.
487
  */
499
  /**
500
  * Output the about screen.
501
  *
502
+ * @since 1.7.0
503
  */
504
  public function about_screen() {
505
  ?>
637
  * Hardcoding this in here is pretty janky. It's fine for now, but we'll
638
  * want to leverage api.wordpress.org eventually.
639
  *
640
+ * @since 1.7.0
641
  */
642
  public function credits_screen() {
643
  ?>
785
  }
786
 
787
  /**
788
+ * Output welcome text and badge for What's New and Credits pages.
789
  *
790
+ * @since 2.2.0
791
  */
792
  public static function welcome_text() {
793
 
809
  }
810
 
811
  /**
812
+ * Output tab navigation for `What's New` and `Credits` pages.
813
  *
814
+ * @since 2.2.0
815
  * @param string $tab
816
  */
817
  public static function tab_navigation( $tab = 'whats_new' ) {
831
  /** Helpers ***************************************************************/
832
 
833
  /**
834
+ * Return true/false based on whether a query argument is set.
835
  *
836
  * @see bp_do_activation_redirect()
837
  *
838
+ * @since 2.2.0
839
+ *
840
  * @return bool
841
  */
842
  public static function is_new_install() {
844
  }
845
 
846
  /**
847
+ * Return a user-friendly version-number string, for use in translations.
848
+ *
849
+ * @since 2.2.0
850
  *
 
851
  * @return string
852
  */
853
  public static function display_version() {
879
  /**
880
  * Setup BuddyPress Admin.
881
  *
882
+ * @since 1.6.0
883
  *
884
  * @uses BP_Admin
885
  */
bp-core/bp-core-adminbar.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Core Toolbar.
5
  *
@@ -9,13 +8,13 @@
9
  * @subpackage Core
10
  */
11
 
12
- // Exit if accessed directly
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  /**
16
  * Add the secondary BuddyPress area to the my-account menu.
17
  *
18
- * @since BuddyPress (1.6.0)
19
  *
20
  * @global WP_Admin_Bar $wp_admin_bar
21
  */
@@ -52,7 +51,7 @@ add_action( 'admin_bar_menu', 'bp_admin_bar_my_account_root', 100 );
52
  /**
53
  * Handle the Toolbar/BuddyBar business.
54
  *
55
- * @since BuddyPress (1.2.0)
56
  *
57
  * @global string $wp_version
58
  * @uses bp_get_option()
@@ -102,7 +101,7 @@ add_action( 'init', 'bp_core_load_admin_bar', 9 );
102
  * previously unhooking this function can continue to do so. It's hooked to
103
  * the `bp_init` action in `bp-core-actions.php`.
104
  *
105
- * @since BuddyPress (1.5.0)
106
  */
107
  function bp_core_load_admin_bar_css() {
108
  add_action( 'bp_enqueue_scripts', 'bp_core_enqueue_admin_bar_css', 1 );
@@ -110,9 +109,9 @@ function bp_core_load_admin_bar_css() {
110
  }
111
 
112
  /**
113
- * Enqueue supplemental WordPress Toolbar styling
114
  *
115
- * @since BuddyPress (2.1.0)
116
  *
117
  * @see bp_core_register_common_styles()
118
  * @see bp_core_load_admin_bar_css()
@@ -127,4 +126,4 @@ function bp_core_enqueue_admin_bar_css() {
127
 
128
  // Enqueue the additional adminbar css
129
  wp_enqueue_style( 'bp-admin-bar' );
130
- }
1
  <?php
 
2
  /**
3
  * BuddyPress Core Toolbar.
4
  *
8
  * @subpackage Core
9
  */
10
 
11
+ // Exit if accessed directly.
12
  defined( 'ABSPATH' ) || exit;
13
 
14
  /**
15
  * Add the secondary BuddyPress area to the my-account menu.
16
  *
17
+ * @since 1.6.0
18
  *
19
  * @global WP_Admin_Bar $wp_admin_bar
20
  */
51
  /**
52
  * Handle the Toolbar/BuddyBar business.
53
  *
54
+ * @since 1.2.0
55
  *
56
  * @global string $wp_version
57
  * @uses bp_get_option()
101
  * previously unhooking this function can continue to do so. It's hooked to
102
  * the `bp_init` action in `bp-core-actions.php`.
103
  *
104
+ * @since 1.5.0
105
  */
106
  function bp_core_load_admin_bar_css() {
107
  add_action( 'bp_enqueue_scripts', 'bp_core_enqueue_admin_bar_css', 1 );
109
  }
110
 
111
  /**
112
+ * Enqueue supplemental WordPress Toolbar styling.
113
  *
114
+ * @since 2.1.0
115
  *
116
  * @see bp_core_register_common_styles()
117
  * @see bp_core_load_admin_bar_css()
126
 
127
  // Enqueue the additional adminbar css
128
  wp_enqueue_style( 'bp-admin-bar' );
129
+ }
bp-core/bp-core-attachments.php CHANGED
@@ -6,7 +6,7 @@
6
  * @subpackage Attachments
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
@@ -16,20 +16,465 @@ defined( 'ABSPATH' ) || exit;
16
  * script requires it. So we need to make sure the current WordPress
17
  * match with our needs.
18
  *
19
- * @since BuddyPress (2.3.0)
20
  *
21
- * @return bool True if WordPress is 3.9+, false otherwise
22
  */
23
  function bp_attachments_is_wp_version_supported() {
24
  return (bool) version_compare( bp_get_major_wp_version(), '3.9', '>=' );
25
  }
26
 
27
  /**
28
- * Get the BuddyPress Plupload settings
29
  *
30
- * @since BuddyPress (2.3.0)
31
  *
32
- * @return array list of BuddyPress Plupload settings
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  */
34
  function bp_attachments_get_plupload_default_settings() {
35
 
@@ -83,11 +528,11 @@ function bp_attachments_get_plupload_default_settings() {
83
  }
84
 
85
  /**
86
- * Builds localization strings for the BuddyPress Uploader scripts
87
  *
88
- * @since BuddyPress (2.3.0)
89
  *
90
- * @return array Plupload default localization strings
91
  */
92
  function bp_attachments_get_plupload_l10n() {
93
  // Localization strings
@@ -119,14 +564,16 @@ function bp_attachments_get_plupload_l10n() {
119
  }
120
 
121
  /**
122
- * Enqueues the script needed for the Uploader UI
123
  *
124
  * @see BP_Attachment::script_data() && BP_Attachment_Avatar::script_data() for examples showing how
125
- * to set specific script data
 
 
126
  *
127
- * @since BuddyPress (2.3.0)
128
  *
129
- * @param string $class name of the class extending BP_Attachment (eg: BP_Attachment_Avatar)
130
  */
131
  function bp_attachments_enqueue_scripts( $class = '' ) {
132
  // Enqueue me just once per page, please.
@@ -239,22 +686,52 @@ function bp_attachments_enqueue_scripts( $class = '' ) {
239
  }
240
 
241
  /**
242
- * Use this filter to add a navigation to a custom tool to set the object's avatar
243
  *
244
- * @since BuddyPress (2.3.0)
245
  *
246
  * @param array $avatar_nav An associative array of available nav items where each item is an array organized this way:
247
  * $avatar_nav[ $nav_item_id ] {
248
- * @type string $nav_item_id the nav item id in lower case without special characters or space
249
- * @type string $caption the name of the item nav that will be displayed in the nav
250
- * @type int $order An integer to specify the priority of the item nav, choose one
251
- * between 1 and 99 to be after the uploader nav item and before the delete nav item
252
- * @type int $hide if set to 1 the item nav will be hidden
253
- * (only used for the delete nav item)
254
  * }
255
  * @param string $object the object the avatar belongs to (eg: user or group)
256
  */
257
  $settings['nav'] = bp_sort_by_key( apply_filters( 'bp_attachments_avatar_nav', $avatar_nav, $object ), 'order', 'num' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
 
260
  // Set Plupload settings
@@ -297,23 +774,25 @@ function bp_attachments_enqueue_scripts( $class = '' ) {
297
  * Fires at the conclusion of bp_attachments_enqueue_scripts()
298
  * to avoid the scripts to be loaded more than once.
299
  *
300
- * @since BuddyPress 2.3.0
301
  */
302
  do_action( 'bp_attachments_enqueue_scripts' );
303
  }
304
 
305
  /**
306
- * Check the current user's capability to edit an avatar for a given object
307
  *
308
- * @since BuddyPress (2.3.0)
309
  *
310
- * @param string $capability the capability to check
311
- * @param array $args an array containing the item_id and the object to check
 
 
312
  */
313
  function bp_attachments_current_user_can( $capability, $args = array() ) {
314
  $can = false;
315
 
316
- if ( 'edit_avatar' === $capability ) {
317
  /**
318
  * Needed avatar arguments are set.
319
  */
@@ -348,11 +827,11 @@ function bp_attachments_current_user_can( $capability, $args = array() ) {
348
  /**
349
  * Send a JSON response back to an Ajax upload request.
350
  *
351
- * @since BuddyPress (2.3.0)
352
  *
353
- * @param bool true for a success, false otherwise
354
- * @param bool true if the Plupload runtime used is html4, false otherwise.
355
- * @param mixed $data Data to encode as JSON, then print and die.
356
  */
357
  function bp_attachments_json_response( $success, $is_html4 = false, $data = null ) {
358
  $response = array( 'success' => $success );
@@ -380,23 +859,25 @@ function bp_attachments_json_response( $success, $is_html4 = false, $data = null
380
  /**
381
  * Get an Attachment template part.
382
  *
383
- * @since BuddyPress (2.3.0)
 
 
384
  *
385
- * @param string Template part slug. eg 'uploader' for 'uploader.php'.
386
  */
387
  function bp_attachments_get_template_part( $slug ) {
388
  $attachment_template_part = 'assets/_attachments/' . $slug;
389
 
390
- // Load the attachment template in WP Administratin screens
391
  if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
392
  $attachment_admin_template_part = buddypress()->themes_dir . '/bp-legacy/buddypress/' . $attachment_template_part . '.php';
393
 
394
- // Check the template part exists
395
  if ( ! file_exists( $attachment_admin_template_part ) ) {
396
  return false;
397
  }
398
 
399
- // load the template part
400
  require( $attachment_admin_template_part );
401
 
402
  // Load the attachment template in WP_USE_THEMES env.
@@ -404,3 +885,489 @@ function bp_attachments_get_template_part( $slug ) {
404
  bp_get_template_part( $attachment_template_part );
405
  }
406
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  * @subpackage Attachments
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
16
  * script requires it. So we need to make sure the current WordPress
17
  * match with our needs.
18
  *
19
+ * @since 2.3.0
20
  *
21
+ * @return bool True if WordPress is 3.9+, false otherwise.
22
  */
23
  function bp_attachments_is_wp_version_supported() {
24
  return (bool) version_compare( bp_get_major_wp_version(), '3.9', '>=' );
25
  }
26
 
27
  /**
28
+ * Get the Attachments Uploads dir data
29
  *
30
+ * @since 2.4.0
31
  *
32
+ * @param string $data The data to get. Possible values are: 'dir', 'basedir' & 'baseurl'
33
+ * Leave empty to get all datas.
34
+ * @return string|array The needed Upload dir data.
35
+ */
36
+ function bp_attachments_uploads_dir_get( $data = '' ) {
37
+ $attachments_dir = 'buddypress';
38
+ $retval = '';
39
+
40
+ if ( 'dir' === $data ) {
41
+ $retval = $attachments_dir;
42
+ } else {
43
+ $upload_data = bp_upload_dir();
44
+
45
+ // Build the Upload data array for BuddyPress attachments
46
+ foreach ( $upload_data as $key => $value ) {
47
+ if ( 'basedir' === $key || 'baseurl' === $key ) {
48
+ $upload_data[ $key ] = trailingslashit( $value ) . $attachments_dir;
49
+ } else {
50
+ unset( $upload_data[ $key ] );
51
+ }
52
+ }
53
+
54
+ // Add the dir to the array
55
+ $upload_data['dir'] = $attachments_dir;
56
+
57
+ if ( empty( $data ) ) {
58
+ $retval = $upload_data;
59
+ } elseif ( isset( $upload_data[ $data ] ) ) {
60
+ $retval = $upload_data[ $data ];
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Filter here to edit the Attachments upload dir data.
66
+ *
67
+ * @since 2.4.0
68
+ *
69
+ * @param string|array $retval The needed Upload dir data or the full array of data
70
+ * @param string $data The data requested
71
+ */
72
+ return apply_filters( 'bp_attachments_uploads_dir_get', $retval, $data );
73
+ }
74
+
75
+ /**
76
+ * Get the max upload file size for any attachment
77
+ *
78
+ * @since 2.4.0
79
+ *
80
+ * @param string $type A string to inform about the type of attachment
81
+ * we wish to get the max upload file size for
82
+ * @return int max upload file size for any attachment
83
+ */
84
+ function bp_attachments_get_max_upload_file_size( $type = '' ) {
85
+ $fileupload_maxk = bp_core_get_root_option( 'fileupload_maxk' );
86
+
87
+ if ( '' === $fileupload_maxk ) {
88
+ $fileupload_maxk = 5120000; // 5mb;
89
+ } else {
90
+ $fileupload_maxk = $fileupload_maxk * 1024;
91
+ }
92
+
93
+ /**
94
+ * Filter here to edit the max upload file size.
95
+ *
96
+ * @since 2.4.0
97
+ *
98
+ * @param int $fileupload_maxk Max upload file size for any attachment
99
+ * @param string $type The attachment type (eg: 'avatar' or 'cover_image')
100
+ */
101
+ return apply_filters( 'bp_attachments_get_max_upload_file_size', $fileupload_maxk, $type );
102
+ }
103
+
104
+ /**
105
+ * Get allowed types for any attachment
106
+ *
107
+ * @since 2.4.0
108
+ *
109
+ * @param string $type The extension types to get.
110
+ * Default: 'avatar'
111
+ * @return array The list of allowed extensions for attachments
112
+ */
113
+ function bp_attachments_get_allowed_types( $type = 'avatar' ) {
114
+ // Defaults to BuddyPress supported image extensions
115
+ $exts = array( 'jpeg', 'gif', 'png' );
116
+
117
+ /**
118
+ * It's not a BuddyPress feature, get the allowed extensions
119
+ * matching the $type requested
120
+ */
121
+ if ( 'avatar' !== $type && 'cover_image' !== $type ) {
122
+ // Reset the default exts
123
+ $exts = array();
124
+
125
+ switch ( $type ) {
126
+ case 'video' :
127
+ $exts = wp_get_video_extensions();
128
+ break;
129
+
130
+ case 'audio' :
131
+ $exts = wp_get_video_extensions();
132
+ break;
133
+
134
+ default:
135
+ $allowed_mimes = get_allowed_mime_types();
136
+
137
+ /**
138
+ * Search for allowed mimes matching the type
139
+ *
140
+ * eg: using 'application/vnd.oasis' as the $type
141
+ * parameter will get all OpenOffice extensions supported
142
+ * by WordPress and allowed for the current user.
143
+ */
144
+ if ( '' !== $type ) {
145
+ $allowed_mimes = preg_grep( '/' . addcslashes( $type, '/.+-' ) . '/', $allowed_mimes );
146
+ }
147
+
148
+ $allowed_types = array_keys( $allowed_mimes );
149
+
150
+ // Loop to explode keys using '|'
151
+ foreach ( $allowed_types as $allowed_type ) {
152
+ $t = explode( '|', $allowed_type );
153
+ $exts = array_merge( $exts, (array) $t );
154
+ }
155
+ break;
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Filter here to edit the allowed extensions by attachment type.
161
+ *
162
+ * @since 2.4.0
163
+ *
164
+ * @param array $exts List of allowed extensions
165
+ * @param string $type The requested file type
166
+ */
167
+ return apply_filters( 'bp_attachments_get_allowed_types', $exts, $type );
168
+ }
169
+
170
+ /**
171
+ * Get allowed attachment mime types.
172
+ *
173
+ * @since 2.4.0
174
+ *
175
+ * @param string $type The extension types to get (Optional).
176
+ * @param array $allowed_types List of allowed extensions
177
+ * @return array List of allowed mime types
178
+ */
179
+ function bp_attachments_get_allowed_mimes( $type = '', $allowed_types = array() ) {
180
+ if ( empty( $allowed_types ) ) {
181
+ $allowed_types = bp_attachments_get_allowed_types( $type );
182
+ }
183
+
184
+ $validate_mimes = wp_match_mime_types( join( ',', $allowed_types ), wp_get_mime_types() );
185
+ $allowed_mimes = array_map( 'implode', $validate_mimes );
186
+
187
+ /**
188
+ * Include jpg type if jpeg is set
189
+ */
190
+ if ( isset( $allowed_mimes['jpeg'] ) && ! isset( $allowed_mimes['jpg'] ) ) {
191
+ $allowed_mimes['jpg'] = $allowed_mimes['jpeg'];
192
+ }
193
+
194
+ return $allowed_mimes;
195
+ }
196
+
197
+ /**
198
+ * Check the uploaded attachment type is allowed
199
+ *
200
+ * @since 2.4.0
201
+ *
202
+ * @param string $file Full path to the file.
203
+ * @param string $filename The name of the file (may differ from $file due to $file being
204
+ * in a tmp directory).
205
+ * @param array $allowed_mimes The attachment allowed mimes (Required)
206
+ * @return bool True if the attachment type is allowed. False otherwise
207
+ */
208
+ function bp_attachments_check_filetype( $file, $filename, $allowed_mimes ) {
209
+ $filetype = wp_check_filetype_and_ext( $file, $filename, $allowed_mimes );
210
+
211
+ if ( ! empty( $filetype['ext'] ) && ! empty( $filetype['type'] ) ) {
212
+ return true;
213
+ }
214
+
215
+ return false;
216
+ }
217
+
218
+ /**
219
+ * Use the absolute path to an image to set an attachment type for a given item.
220
+ *
221
+ * @since 2.4.0
222
+ *
223
+ * @param string $type The attachment type to create (avatar or cover_image). Default: avatar.
224
+ * @param array $args {
225
+ * @type int $item_id The ID of the object (Required). Default: 0.
226
+ * @type string $object The object type (eg: group, user, blog) (Required). Default: 'user'.
227
+ * @type string $component The component for the object (eg: groups, xprofile, blogs). Default: ''.
228
+ * @type string $image The absolute path to the image (Required). Default: ''.
229
+ * @type int $crop_w Crop width. Default: 0.
230
+ * @type int $crop_h Crop height. Default: 0.
231
+ * @type int $crop_x The horizontal starting point of the crop. Default: 0.
232
+ * @type int $crop_y The vertical starting point of the crop. Default: 0.
233
+ * }
234
+ * @return bool True on success, false otherwise.
235
+ */
236
+ function bp_attachments_create_item_type( $type = 'avatar', $args = array() ) {
237
+ if ( empty( $type ) || ( $type !== 'avatar' && $type !== 'cover_image' ) ) {
238
+ return false;
239
+ }
240
+
241
+ $r = bp_parse_args( $args, array(
242
+ 'item_id' => 0,
243
+ 'object' => 'user',
244
+ 'component' => '',
245
+ 'image' => '',
246
+ 'crop_w' => 0,
247
+ 'crop_h' => 0,
248
+ 'crop_x' => 0,
249
+ 'crop_y' => 0
250
+ ), 'create_item_' . $type );
251
+
252
+ if ( empty( $r['item_id'] ) || empty( $r['object'] ) || ! file_exists( $r['image'] ) || ! @getimagesize( $r['image'] ) ) {
253
+ return false;
254
+ }
255
+
256
+ // Make sure the file path is safe
257
+ if ( 0 !== validate_file( $r['image'] ) ) {
258
+ return false;
259
+ }
260
+
261
+ // Set the component if not already done
262
+ if ( empty( $r['component'] ) ) {
263
+ if ( 'user' === $r['object'] ) {
264
+ $r['component'] = 'xprofile';
265
+ } else {
266
+ $r['component'] = $r['object'] . 's';
267
+ }
268
+ }
269
+
270
+ // Get allowed mimes for the Attachment type and check the image one is.
271
+ $allowed_mimes = bp_attachments_get_allowed_mimes( $type );
272
+ $is_allowed = wp_check_filetype( $r['image'], $allowed_mimes );
273
+
274
+ // It's not an image.
275
+ if ( ! $is_allowed['ext'] ) {
276
+ return false;
277
+ }
278
+
279
+ // Init the Attachment data
280
+ $attachment_data = array();
281
+
282
+ if ( 'avatar' === $type ) {
283
+ // Set crop width for the avatar if not given
284
+ if ( empty( $r['crop_w'] ) ) {
285
+ $r['crop_w'] = bp_core_avatar_full_width();
286
+ }
287
+
288
+ // Set crop height for the avatar if not given
289
+ if ( empty( $r['crop_h'] ) ) {
290
+ $r['crop_h'] = bp_core_avatar_full_height();
291
+ }
292
+
293
+ if ( is_callable( $r['component'] . '_avatar_upload_dir' ) ) {
294
+ $dir_args = array( $r['item_id'] );
295
+
296
+ // In case of xprofile, we need an extra argument
297
+ if ( 'xprofile' === $r['component'] ) {
298
+ $dir_args = array( false, $r['item_id'] );
299
+ }
300
+
301
+ $attachment_data = call_user_func_array( $r['component'] . '_avatar_upload_dir', $dir_args );
302
+ }
303
+ } elseif ( 'cover_image' === $type ) {
304
+ $attachment_data = bp_attachments_uploads_dir_get();
305
+
306
+ // Default to members for xProfile
307
+ $object_subdir = 'members';
308
+
309
+ if ( 'xprofile' !== $r['component'] ) {
310
+ $object_subdir = sanitize_key( $r['component'] );
311
+ }
312
+
313
+ // Set Subdir
314
+ $attachment_data['subdir'] = $object_subdir . '/' . $r['item_id'] . '/cover-image';
315
+
316
+ // Set Path
317
+ $attachment_data['path'] = trailingslashit( $attachment_data['basedir'] ) . $attachment_data['subdir'];
318
+ }
319
+
320
+ if ( ! isset( $attachment_data['path'] ) || ! isset( $attachment_data['subdir'] ) ) {
321
+ return false;
322
+ }
323
+
324
+ // It's not a regular upload, we may need to create some folders
325
+ if ( ! is_dir( $attachment_data['path'] ) ) {
326
+ if ( ! wp_mkdir_p( $attachment_data['path'] ) ) {
327
+ return false;
328
+ }
329
+ }
330
+
331
+ // Set the image name and path
332
+ $image_file_name = wp_unique_filename( $attachment_data['path'], basename( $r['image'] ) );
333
+ $image_file_path = $attachment_data['path'] . '/' . $image_file_name;
334
+
335
+ // Copy the image file into the avatar dir
336
+ if ( ! copy( $r['image'], $image_file_path ) ) {
337
+ return false;
338
+ }
339
+
340
+ // Init the response
341
+ $created = false;
342
+
343
+ // It's an avatar, we need to crop it.
344
+ if ( 'avatar' === $type ) {
345
+ $created = bp_core_avatar_handle_crop( array(
346
+ 'object' => $r['object'],
347
+ 'avatar_dir' => trim( dirname( $attachment_data['subdir'] ), '/' ),
348
+ 'item_id' => (int) $r['item_id'],
349
+ 'original_file' => trailingslashit( $attachment_data['subdir'] ) . $image_file_name,
350
+ 'crop_w' => $r['crop_w'],
351
+ 'crop_h' => $r['crop_h'],
352
+ 'crop_x' => $r['crop_x'],
353
+ 'crop_y' => $r['crop_y']
354
+ ) );
355
+
356
+ // It's a cover image we need to fit it to feature's dimensions
357
+ } elseif ( 'cover_image' === $type ) {
358
+ $cover_image = bp_attachments_cover_image_generate_file( array(
359
+ 'file' => $image_file_path,
360
+ 'component' => $r['component'],
361
+ 'cover_image_dir' => $attachment_data['path']
362
+ ) );
363
+
364
+ $created = ! empty( $cover_image['cover_file'] );
365
+ }
366
+
367
+ // Remove copied file if it fails
368
+ if ( ! $created ) {
369
+ @unlink( $image_file_path );
370
+ }
371
+
372
+ // Return the response
373
+ return $created;
374
+ }
375
+
376
+ /**
377
+ * Get the url or the path for a type of attachment
378
+ *
379
+ * @since 2.4.0
380
+ *
381
+ * @param string $data whether to get the url or the path
382
+ * @param array $args {
383
+ * @type string $object_dir The object dir (eg: members/groups). Defaults to members.
384
+ * @type int $item_id The object id (eg: a user or a group id). Defaults to current user.
385
+ * @type string $type The type of the attachment which is also the subdir where files are saved.
386
+ * Defaults to 'cover-image'
387
+ * @type string $file The name of the file.
388
+ * }
389
+ * @return string|bool the url or the path to the attachment, false otherwise
390
+ */
391
+ function bp_attachments_get_attachment( $data = 'url', $args = array() ) {
392
+ // Default value
393
+ $attachment_data = false;
394
+
395
+ $r = bp_parse_args( $args, array(
396
+ 'object_dir' => 'members',
397
+ 'item_id' => bp_loggedin_user_id(),
398
+ 'type' => 'cover-image',
399
+ 'file' => '',
400
+ ), 'attachments_get_attachment_src' );
401
+
402
+ // Get BuddyPress Attachments Uploads Dir datas
403
+ $bp_attachments_uploads_dir = bp_attachments_uploads_dir_get();
404
+
405
+ $type_subdir = $r['object_dir'] . '/' . $r['item_id'] . '/' . $r['type'];
406
+ $type_dir = trailingslashit( $bp_attachments_uploads_dir['basedir'] ) . $type_subdir;
407
+
408
+ if ( ! is_dir( $type_dir ) ) {
409
+ return $attachment_data;
410
+ }
411
+
412
+ if ( ! empty( $r['file'] ) ) {
413
+ if ( ! file_exists( trailingslashit( $type_dir ) . $r['file'] ) ) {
414
+ return $attachment_data;
415
+ }
416
+
417
+ if ( 'url' === $data ) {
418
+ $attachment_data = trailingslashit( $bp_attachments_uploads_dir['baseurl'] ) . $type_subdir . '/' . $r['file'];
419
+ } else {
420
+ $attachment_data = trailingslashit( $type_dir ) . $r['file'];
421
+ }
422
+
423
+ } else {
424
+ $file = false;
425
+
426
+ // Open the directory and get the first file
427
+ if ( $att_dir = opendir( $type_dir ) ) {
428
+
429
+ while ( false !== ( $attachment_file = readdir( $att_dir ) ) ) {
430
+ // Look for the first file having the type in its name
431
+ if ( false !== strpos( $attachment_file, $r['type'] ) && empty( $file ) ) {
432
+ $file = $attachment_file;
433
+ break;
434
+ }
435
+ }
436
+ }
437
+
438
+ if ( empty( $file ) ) {
439
+ return $attachment_data;
440
+ }
441
+
442
+ if ( 'url' === $data ) {
443
+ $attachment_data = trailingslashit( $bp_attachments_uploads_dir['baseurl'] ) . $type_subdir . '/' . $file;
444
+ } else {
445
+ $attachment_data = trailingslashit( $type_dir ) . $file;
446
+ }
447
+ }
448
+
449
+ return $attachment_data;
450
+ }
451
+
452
+ /**
453
+ * Delete an attachment for the given arguments
454
+ *
455
+ * @since 2.4.0
456
+ *
457
+ * @param array $args
458
+ * @see bp_attachments_get_attachment() For more information on accepted arguments.
459
+ * @return bool True if the attachment was deleted, false otherwise
460
+ */
461
+ function bp_attachments_delete_file( $args = array() ) {
462
+ $attachment_path = bp_attachments_get_attachment( 'path', $args );
463
+
464
+ if ( empty( $attachment_path ) ) {
465
+ return false;
466
+ }
467
+
468
+ @unlink( $attachment_path );
469
+ return true;
470
+ }
471
+
472
+ /**
473
+ * Get the BuddyPress Plupload settings.
474
+ *
475
+ * @since 2.3.0
476
+ *
477
+ * @return array list of BuddyPress Plupload settings.
478
  */
479
  function bp_attachments_get_plupload_default_settings() {
480
 
528
  }
529
 
530
  /**
531
+ * Builds localization strings for the BuddyPress Uploader scripts.
532
  *
533
+ * @since 2.3.0
534
  *
535
+ * @return array Plupload default localization strings.
536
  */
537
  function bp_attachments_get_plupload_l10n() {
538
  // Localization strings
564
  }
565
 
566
  /**
567
+ * Enqueues the script needed for the Uploader UI.
568
  *
569
  * @see BP_Attachment::script_data() && BP_Attachment_Avatar::script_data() for examples showing how
570
+ * to set specific script data.
571
+ *
572
+ * @since 2.3.0
573
  *
574
+ * @param string $class name of the class extending BP_Attachment (eg: BP_Attachment_Avatar).
575
  *
576
+ * @return null|WP_Error
577
  */
578
  function bp_attachments_enqueue_scripts( $class = '' ) {
579
  // Enqueue me just once per page, please.
686
  }
687
 
688
  /**
689
+ * Use this filter to add a navigation to a custom tool to set the object's avatar.
690
  *
691
+ * @since 2.3.0
692
  *
693
  * @param array $avatar_nav An associative array of available nav items where each item is an array organized this way:
694
  * $avatar_nav[ $nav_item_id ] {
695
+ * @type string $nav_item_id The nav item id in lower case without special characters or space.
696
+ * @type string $caption The name of the item nav that will be displayed in the nav.
697
+ * @type int $order An integer to specify the priority of the item nav, choose one.
698
+ * between 1 and 99 to be after the uploader nav item and before the delete nav item.
699
+ * @type int $hide If set to 1 the item nav will be hidden
700
+ * (only used for the delete nav item).
701
  * }
702
  * @param string $object the object the avatar belongs to (eg: user or group)
703
  */
704
  $settings['nav'] = bp_sort_by_key( apply_filters( 'bp_attachments_avatar_nav', $avatar_nav, $object ), 'order', 'num' );
705
+
706
+ // Specific to BuddyPress cover images
707
+ } elseif ( 'bp_cover_image_upload' === $defaults['multipart_params']['action'] ) {
708
+
709
+ // Cover images only need 1 file and 1 only!
710
+ $defaults['multi_selection'] = false;
711
+
712
+ // Default cover component is xprofile
713
+ $cover_component = 'xprofile';
714
+
715
+ // Get the object we're editing the cover image of
716
+ $object = $defaults['multipart_params']['bp_params']['object'];
717
+
718
+ // Set the cover component according to the object
719
+ if ( 'group' === $object ) {
720
+ $cover_component = 'groups';
721
+ } elseif ( 'user' !== $object ) {
722
+ $cover_component = apply_filters( 'bp_attachments_cover_image_ui_component', $cover_component );
723
+ }
724
+ // Get cover image advised dimensions
725
+ $cover_dimensions = bp_attachments_get_cover_image_dimensions( $cover_component );
726
+
727
+ // Set warning messages
728
+ $strings['cover_image_warnings'] = apply_filters( 'bp_attachments_cover_image_ui_warnings', array(
729
+ 'dimensions' => sprintf(
730
+ __( 'For better results, make sure to upload an image that is larger than %1$spx wide, and %2$spx tall.', 'buddypress' ),
731
+ (int) $cover_dimensions['width'],
732
+ (int) $cover_dimensions['height']
733
+ ),
734
+ ) );
735
  }
736
 
737
  // Set Plupload settings
774
  * Fires at the conclusion of bp_attachments_enqueue_scripts()
775
  * to avoid the scripts to be loaded more than once.
776
  *
777
+ * @since 2.3.0
778
  */
779
  do_action( 'bp_attachments_enqueue_scripts' );
780
  }
781
 
782
  /**
783
+ * Check the current user's capability to edit an avatar for a given object.
784
  *
785
+ * @since 2.3.0
786
  *
787
+ * @param string $capability The capability to check.
788
+ * @param array $args An array containing the item_id and the object to check.
789
+ *
790
+ * @return bool
791
  */
792
  function bp_attachments_current_user_can( $capability, $args = array() ) {
793
  $can = false;
794
 
795
+ if ( 'edit_avatar' === $capability || 'edit_cover_image' === $capability ) {
796
  /**
797
  * Needed avatar arguments are set.
798
  */
827
  /**
828
  * Send a JSON response back to an Ajax upload request.
829
  *
830
+ * @since 2.3.0
831
  *
832
+ * @param bool $success True for a success, false otherwise.
833
+ * @param bool $is_html4 True if the Plupload runtime used is html4, false otherwise.
834
+ * @param mixed $data Data to encode as JSON, then print and die.
835
  */
836
  function bp_attachments_json_response( $success, $is_html4 = false, $data = null ) {
837
  $response = array( 'success' => $success );
859
  /**
860
  * Get an Attachment template part.
861
  *
862
+ * @since 2.3.0
863
+ *
864
+ * @param string $slug Template part slug. eg 'uploader' for 'uploader.php'.
865
  *
866
+ * @return bool
867
  */
868
  function bp_attachments_get_template_part( $slug ) {
869
  $attachment_template_part = 'assets/_attachments/' . $slug;
870
 
871
+ // Load the attachment template in WP Administration screens.
872
  if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
873
  $attachment_admin_template_part = buddypress()->themes_dir . '/bp-legacy/buddypress/' . $attachment_template_part . '.php';
874
 
875
+ // Check whether the template part exists.
876
  if ( ! file_exists( $attachment_admin_template_part ) ) {
877
  return false;
878
  }
879
 
880
+ // Load the template part.
881
  require( $attachment_admin_template_part );
882
 
883
  // Load the attachment template in WP_USE_THEMES env.
885
  bp_get_template_part( $attachment_template_part );
886
  }
887
  }
888
+
889
+ /** Cover Image ***************************************************************/
890
+
891
+ /**
892
+ * Get the cover image settings
893
+ *
894
+ * @since 2.4.0
895
+ *
896
+ * @param string $component the component to get the settings for ("xprofile" for user or "groups")
897
+ * @return array the cover image settings
898
+ */
899
+ function bp_attachments_get_cover_image_settings( $component = 'xprofile' ) {
900
+ // Default parameters
901
+ $args = array();
902
+
903
+ // First look in BP Theme Compat
904
+ $cover_image = bp_get_theme_compat_feature( 'cover_image' );
905
+
906
+ if ( ! empty( $cover_image ) ) {
907
+ $args = (array) $cover_image;
908
+ }
909
+
910
+ /**
911
+ * Then let people override/set the feature using this dynamic filter
912
+ *
913
+ * eg: for the user's profile cover image use :
914
+ * add_filter( 'bp_before_xprofile_cover_image_settings_parse_args', 'your_filter', 10, 1 );
915
+ *
916
+ * @since 2.4.0
917
+ *
918
+ * @param array $settings the cover image settings
919
+ */
920
+ $settings = bp_parse_args( $args, array(
921
+ 'components' => array(),
922
+ 'width' => 1300,
923
+ 'height' => 225,
924
+ 'callback' => '',
925
+ 'theme_handle' => '',
926
+ 'default_cover' => '',
927
+ ), $component . '_cover_image_settings' );
928
+
929
+ if ( empty( $settings['components'] ) || empty( $settings['callback'] ) || empty( $settings['theme_handle'] ) ) {
930
+ return false;
931
+ }
932
+
933
+ // Current component is not supported
934
+ if ( ! in_array( $component, $settings['components'] ) ) {
935
+ return false;
936
+ }
937
+
938
+ // Finally return the settings
939
+ return $settings;
940
+ }
941
+
942
+ /**
943
+ * Get cover image Width and Height
944
+ *
945
+ * @since 2.4.0
946
+ *
947
+ * @param string $component the BuddyPress component concerned ("xprofile" for user or "groups")
948
+ * @return array an associative array containing the advised width and height for the cover image
949
+ */
950
+ function bp_attachments_get_cover_image_dimensions( $component = 'xprofile' ) {
951
+ // Let's prevent notices when setting the warning strings
952
+ $default = array( 'width' => 0, 'height' => 0 );
953
+
954
+ $settings = bp_attachments_get_cover_image_settings( $component );
955
+
956
+ if ( empty( $settings ) ) {
957
+ return false;
958
+ }
959
+
960
+ // Get width and height
961
+ $wh = array_intersect_key( $settings, $default );
962
+
963
+ /**
964
+ * Filter here to edit the cover image dimensions if needed.
965
+ *
966
+ * @since 2.4.0
967
+ *
968
+ * @param array $wh an associative array containing the width and height values
969
+ * @param array $settings an associative array containing all the feature settings
970
+ * @param string $compnent the requested component
971
+ */
972
+ return apply_filters( 'bp_attachments_get_cover_image_dimensions', $wh, $settings, $component );
973
+ }
974
+
975
+ /**
976
+ * Are we on a page to edit a cover image ?
977
+ *
978
+ * @since 2.4.0
979
+ *
980
+ * @return bool True if on a page to edit a cover image, false otherwise
981
+ */
982
+ function bp_attachments_cover_image_is_edit() {
983
+ $retval = false;
984
+
985
+ $current_component = bp_current_component();
986
+ if ( 'profile' === $current_component ) {
987
+ $current_component = 'xprofile';
988
+ }
989
+
990
+ if ( ! bp_is_active( $current_component, 'cover_image' ) ) {
991
+ return $retval;
992
+ }
993
+
994
+ if ( bp_is_user_change_cover_image() ) {
995
+ $retval = ! bp_disable_cover_image_uploads();
996
+ }
997
+
998
+ if ( ( bp_is_group_admin_page() && 'group-cover-image' == bp_get_group_current_admin_tab() )
999
+ || ( bp_is_group_create() && bp_is_group_creation_step( 'group-cover-image' ) ) ) {
1000
+ $retval = ! bp_disable_group_cover_image_uploads();
1001
+ }
1002
+
1003
+ return apply_filters( 'bp_attachments_cover_image_is_edit', $retval, $current_component );
1004
+ }
1005
+
1006
+ /**
1007
+ * Does the user has a cover image ?
1008
+ *
1009
+ * @since 2.4.0
1010
+ *
1011
+ * @param int $user_id
1012
+ * @return bool True if the user has a cover image, false otherwise
1013
+ */
1014
+ function bp_attachments_get_user_has_cover_image( $user_id = 0 ) {
1015
+ if ( empty( $user_id ) ) {
1016
+ $user_id = bp_displayed_user_id();
1017
+ }
1018
+
1019
+ $cover_src = bp_attachments_get_attachment( 'url', array(
1020
+ 'item_id' => $user_id,
1021
+ ) );
1022
+
1023
+ return (bool) apply_filters( 'bp_attachments_get_user_has_cover_image', $cover_src, $user_id );
1024
+ }
1025
+
1026
+ /**
1027
+ * Does the group has a cover image ?
1028
+ *
1029
+ * @since 2.4.0
1030
+ *
1031
+ * @param int $group_id
1032
+ * @return bool True if the group has a cover image, false otherwise
1033
+ */
1034
+ function bp_attachments_get_group_has_cover_image( $group_id = 0 ) {
1035
+ if ( empty( $group_id ) ) {
1036
+ $group_id = bp_get_current_group_id();
1037
+ }
1038
+
1039
+ $cover_src = bp_attachments_get_attachment( 'url', array(
1040
+ 'object_dir' => 'groups',
1041
+ 'item_id' => $group_id,
1042
+ ) );
1043
+
1044
+ return (bool) apply_filters( 'bp_attachments_get_user_has_cover_image', $cover_src, $group_id );
1045
+ }
1046
+
1047
+ /**
1048
+ * Generate the cover image file.
1049
+ *
1050
+ * @since 2.4.0
1051
+ *
1052
+ * @param array $args {
1053
+ * @type string $file The absolute path to the image. Required.
1054
+ * @type string $component The component for the object (eg: groups, xprofile). Required.
1055
+ * @type string $cover_image_dir The Cover image dir to write the image into. Required.
1056
+ * }
1057
+ * @param BP_Attachment_Cover_Image $cover_image_class The class to use to fit the cover image.
1058
+ * @return bool|array An array containing cover image data on success, false otherwise.
1059
+ */
1060
+ function bp_attachments_cover_image_generate_file( $args = array(), $cover_image_class = null ) {
1061
+ // Bail if an argument is missing
1062
+ if ( empty( $args['file'] ) || empty( $args['component'] ) || empty( $args['cover_image_dir'] ) ) {
1063
+ return false;
1064
+ }
1065
+
1066
+ // Get advised dimensions for the cover image
1067
+ $dimensions = bp_attachments_get_cover_image_dimensions( $args['component'] );
1068
+
1069
+ // No dimensions or the file does not match with the cover image dir, stop!
1070
+ if ( false === $dimensions || $args['file'] !== $args['cover_image_dir'] . '/' . wp_basename( $args['file'] ) ) {
1071
+ return false;
1072
+ }
1073
+
1074
+ if ( ! is_a( $cover_image_class, 'BP_Attachment_Cover_Image' ) ) {
1075
+ $cover_image_class = new BP_Attachment_Cover_Image();
1076
+ }
1077
+
1078
+ // Make sure the file is inside the Cover Image Upload path.
1079
+ if ( false === strpos( $args['file'], $cover_image_class->upload_path ) ) {
1080
+ return false;
1081
+ }
1082
+
1083
+ // Resize the image so that it fit with the cover image dimensions
1084
+ $cover_image = $cover_image_class->fit( $args['file'], $dimensions );
1085
+ $is_too_small = false;
1086
+
1087
+ // Image is too small in width and height
1088
+ if ( empty( $cover_image ) ) {
1089
+ $cover_file = $cover_image_class->generate_filename( $args['file'] );
1090
+ @rename( $args['file'], $cover_file );
1091
+
1092
+ // It's too small!
1093
+ $is_too_small = true;
1094
+ } elseif ( ! empty( $cover_image['path'] ) ) {
1095
+ $cover_file = $cover_image['path'];
1096
+
1097
+ // Image is too small in width or height
1098
+ if ( $cover_image['width'] < $dimensions['width'] || $cover_image['height'] < $dimensions['height'] ) {
1099
+ $is_too_small = true;
1100
+ }
1101
+ }
1102
+
1103
+ // We were not able to generate the cover image file.
1104
+ if ( empty( $cover_file ) ) {
1105
+ return false;
1106
+ }
1107
+
1108
+ // Do some clean up with old cover image, now a new one is set.
1109
+ $cover_basename = wp_basename( $cover_file );
1110
+
1111
+ if ( $att_dir = opendir( $args['cover_image_dir'] ) ) {
1112
+ while ( false !== ( $attachment_file = readdir( $att_dir ) ) ) {
1113
+ // skip directories and the new cover image
1114
+ if ( 2 < strlen( $attachment_file ) && 0 !== strpos( $attachment_file, '.' ) && $cover_basename !== $attachment_file ) {
1115
+ @unlink( $args['cover_image_dir'] . '/' . $attachment_file );
1116
+ }
1117
+ }
1118
+ }
1119
+
1120
+ // Finally return needed data.
1121
+ return array(
1122
+ 'cover_file' => $cover_file,
1123
+ 'cover_basename' => $cover_basename,
1124
+ 'is_too_small' => $is_too_small
1125
+ );
1126
+ }
1127
+
1128
+ /**
1129
+ * Ajax Upload and set a cover image
1130
+ *
1131
+ * @since 2.4.0
1132
+ *
1133
+ * @return string|null A json object containing success data if the upload succeeded
1134
+ * error message otherwise.
1135
+ */
1136
+ function bp_attachments_cover_image_ajax_upload() {
1137
+ // Bail if not a POST action
1138
+ if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
1139
+ wp_die();
1140
+ }
1141
+
1142
+ /**
1143
+ * Sending the json response will be different if
1144
+ * the current Plupload runtime is html4
1145
+ */
1146
+ $is_html4 = false;
1147
+ if ( ! empty( $_POST['html4' ] ) ) {
1148
+ $is_html4 = true;
1149
+ }
1150
+
1151
+ // Check the nonce
1152
+ check_admin_referer( 'bp-uploader' );
1153
+
1154
+ // Init the BuddyPress parameters
1155
+ $bp_params = array();
1156
+
1157
+ // We need it to carry on
1158
+ if ( ! empty( $_POST['bp_params'] ) ) {
1159
+ $bp_params = bp_parse_args( $_POST['bp_params'], array(
1160
+ 'object' => 'user',
1161
+ 'item_id' => bp_loggedin_user_id(),
1162
+ ), 'attachments_cover_image_ajax_upload' );
1163
+ } else {
1164
+ bp_attachments_json_response( false, $is_html4 );
1165
+ }
1166
+
1167
+ // We need the object to set the uploads dir filter
1168
+ if ( empty( $bp_params['object'] ) ) {
1169
+ bp_attachments_json_response( false, $is_html4 );
1170
+ }
1171
+
1172
+ // Capability check
1173
+ if ( ! bp_attachments_current_user_can( 'edit_cover_image', $bp_params ) ) {
1174
+ bp_attachments_json_response( false, $is_html4 );
1175
+ }
1176
+
1177
+ $bp = buddypress();
1178
+ $needs_reset = array();
1179
+
1180
+ // Member's cover image
1181
+ if ( 'user' === $bp_params['object'] ) {
1182
+ $object_data = array( 'dir' => 'members', 'component' => 'xprofile' );
1183
+
1184
+ if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
1185
+ $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
1186
+ $bp->displayed_user->id = $bp_params['item_id'];
1187
+ }
1188
+
1189
+ // Group's cover image
1190
+ } elseif ( 'group' === $bp_params['object'] ) {
1191
+ $object_data = array( 'dir' => 'groups', 'component' => 'groups' );
1192
+
1193
+ if ( ! bp_get_current_group_id() && ! empty( $bp_params['item_id'] ) ) {
1194
+ $needs_reset = array( 'component' => 'groups', 'key' => 'current_group', 'value' => $bp->groups->current_group );
1195
+ $bp->groups->current_group = groups_get_group( array(
1196
+ 'group_id' => $bp_params['item_id'],
1197
+ 'populate_extras' => false,
1198
+ ) );
1199
+ }
1200
+
1201
+ // Other object's cover image
1202
+ } else {
1203
+ $object_data = apply_filters( 'bp_attachments_cover_image_object_dir', array(), $bp_params['object'] );
1204
+ }
1205
+
1206
+ // Stop here in case of a missing parameter for the object
1207
+ if ( empty( $object_data['dir'] ) || empty( $object_data['component'] ) ) {
1208
+ bp_attachments_json_response( false, $is_html4 );
1209
+ }
1210
+
1211
+ $cover_image_attachment = new BP_Attachment_Cover_Image();
1212
+ $uploaded = $cover_image_attachment->upload( $_FILES );
1213
+
1214
+ // Reset objects
1215
+ if ( ! empty( $needs_reset ) ) {
1216
+ if ( ! empty( $needs_reset['component'] ) ) {
1217
+ $bp->{$needs_reset['component']}->{$needs_reset['key']} = $needs_reset['value'];
1218
+ } else {
1219
+ $bp->{$needs_reset['key']} = $needs_reset['value'];
1220
+ }
1221
+ }
1222
+
1223
+ if ( ! empty( $uploaded['error'] ) ) {
1224
+ // Upload error response
1225
+ bp_attachments_json_response( false, $is_html4, array(
1226
+ 'type' => 'upload_error',
1227
+ 'message' => sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $uploaded['error'] ),
1228
+ ) );
1229
+ }
1230
+
1231
+ // Default error message
1232
+ $error_message = __( 'There was a problem uploading the cover image.', 'buddypress' );
1233
+
1234
+ // Get BuddyPress Attachments Uploads Dir datas
1235
+ $bp_attachments_uploads_dir = bp_attachments_uploads_dir_get();
1236
+
1237
+ $cover_subdir = $object_data['dir'] . '/' . $bp_params['item_id'] . '/cover-image';
1238
+ $cover_dir = trailingslashit( $bp_attachments_uploads_dir['basedir'] ) . $cover_subdir;
1239
+
1240
+ if ( ! is_dir( $cover_dir ) ) {
1241
+ // Upload error response
1242
+ bp_attachments_json_response( false, $is_html4, array(
1243
+ 'type' => 'upload_error',
1244
+ 'message' => $error_message,
1245
+ ) );
1246
+ }
1247
+
1248
+ /**
1249
+ * Generate the cover image so that it fit to feature's dimensions
1250
+ *
1251
+ * Unlike the Avatar, Uploading and generating the cover image is happening during
1252
+ * the same Ajax request, as we already instantiated the BP_Attachment_Cover_Image
1253
+ * class, let's use it.
1254
+ */
1255
+ $cover = bp_attachments_cover_image_generate_file( array(
1256
+ 'file' => $uploaded['file'],
1257
+ 'component' => $object_data['component'],
1258
+ 'cover_image_dir' => $cover_dir
1259
+ ), $cover_image_attachment );
1260
+
1261
+ if ( ! $cover ) {
1262
+ // Upload error response
1263
+ bp_attachments_json_response( false, $is_html4, array(
1264
+ 'type' => 'upload_error',
1265
+ 'message' => $error_message,
1266
+ ) );
1267
+ }
1268
+
1269
+ // Build the url to the file
1270
+ $cover_url = trailingslashit( $bp_attachments_uploads_dir['baseurl'] ) . $cover_subdir . '/' . $cover['cover_basename'];
1271
+
1272
+ // Init Feedback code, 1 is success
1273
+ $feedback_code = 1;
1274
+
1275
+ // 0 is the size warning
1276
+ if ( $cover['is_too_small'] ) {
1277
+ $feedback_code = 0;
1278
+ }
1279
+
1280
+ // Set the name of the file
1281
+ $name = $_FILES['file']['name'];
1282
+ $name_parts = pathinfo( $name );
1283
+ $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
1284
+
1285
+ /**
1286
+ * Fires if the new cover image was successfully uploaded.
1287
+ *
1288
+ * The dynamic portion of the hook will be xprofile in case of a user's
1289
+ * cover image, groups in case of a group's cover image. For instance:
1290
+ * Use add_action( 'xprofile_cover_image_uploaded' ) to run your specific
1291
+ * code once the user has set his cover image.
1292
+ *
1293
+ * @since 2.4.0
1294
+ *
1295
+ * @param int $item_id Inform about the item id the cover image was set for.
1296
+ */
1297
+ do_action( $object_data['component'] . '_cover_image_uploaded', (int) $bp_params['item_id'] );
1298
+
1299
+ // Finally return the cover image url to the UI
1300
+ bp_attachments_json_response( true, $is_html4, array(
1301
+ 'name' => $name,
1302
+ 'url' => $cover_url,
1303
+ 'feedback_code' => $feedback_code,
1304
+ ) );
1305
+ }
1306
+ add_action( 'wp_ajax_bp_cover_image_upload', 'bp_attachments_cover_image_ajax_upload' );
1307
+
1308
+ /**
1309
+ * Ajax delete a cover image for a given object and item id.
1310
+ *
1311
+ * @since 2.4.0
1312
+ *
1313
+ * @return string|null A json object containing success data if the cover image was deleted
1314
+ * error message otherwise.
1315
+ */
1316
+ function bp_attachments_cover_image_ajax_delete() {
1317
+ // Bail if not a POST action.
1318
+ if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
1319
+ wp_send_json_error();
1320
+ }
1321
+
1322
+ $cover_image_data = $_POST;
1323
+
1324
+ if ( empty( $cover_image_data['object'] ) || empty( $cover_image_data['item_id'] ) ) {
1325
+ wp_send_json_error();
1326
+ }
1327
+
1328
+ // Check the nonce
1329
+ check_admin_referer( 'bp_delete_cover_image', 'nonce' );
1330
+
1331
+ // Capability check
1332
+ if ( ! bp_attachments_current_user_can( 'edit_cover_image', $cover_image_data ) ) {
1333
+ wp_send_json_error();
1334
+ }
1335
+
1336
+ // Set object for the user's case
1337
+ if ( 'user' === $cover_image_data['object'] ) {
1338
+ $component = 'xprofile';
1339
+ $dir = 'members';
1340
+
1341
+ // Set it for any other cases
1342
+ } else {
1343
+ $component = $cover_image_data['object'] . 's';
1344
+ $dir = $component;
1345
+ }
1346
+
1347
+ // Handle delete
1348
+ if ( bp_attachments_delete_file( array( 'item_id' => $cover_image_data['item_id'], 'object_dir' => $dir, 'type' => 'cover-image' ) ) ) {
1349
+
1350
+ // Defaults no cover image
1351
+ $response = array(
1352
+ 'reset_url' => '',
1353
+ 'feedback_code' => 3 ,
1354
+ );
1355
+
1356
+ // Get cover image settings in case there's a default header
1357
+ $cover_params = bp_attachments_get_cover_image_settings( $component );
1358
+
1359
+ // Check if there's a default cover
1360
+ if ( ! empty( $cover_params['default_cover'] ) ) {
1361
+ $response['reset_url'] = $cover_params['default_cover'];
1362
+ }
1363
+
1364
+ // Finally send the reset url
1365
+ wp_send_json_success( $response );
1366
+
1367
+ } else {
1368
+ wp_send_json_error( array(
1369
+ 'feedback_code' => 2,
1370
+ ) );
1371
+ }
1372
+ }
1373
+ add_action( 'wp_ajax_bp_cover_image_delete', 'bp_attachments_cover_image_ajax_delete' );
bp-core/bp-core-avatars.php CHANGED
@@ -1,13 +1,15 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Avatars.
 
 
 
5
  */
6
 
7
- // Exit if accessed directly
8
  defined( 'ABSPATH' ) || exit;
9
 
10
- /***
11
  * Set up the constants we need for avatar support.
12
  */
13
  function bp_core_set_avatar_constants() {
@@ -30,13 +32,7 @@ function bp_core_set_avatar_constants() {
30
  define( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 450 );
31
 
32
  if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) {
33
-
34
- $fileupload_maxk = bp_core_get_root_option( 'fileupload_maxk' );
35
- if ( '' === $fileupload_maxk ) {
36
- define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); // 5mb
37
- } else {
38
- define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $fileupload_maxk * 1024 );
39
- }
40
  }
41
 
42
  if ( ! defined( 'BP_SHOW_AVATARS' ) ) {
@@ -48,7 +44,7 @@ add_action( 'bp_init', 'bp_core_set_avatar_constants', 3 );
48
  /**
49
  * Set up global variables related to avatars.
50
  *
51
- * @since BuddyPress (1.5.0)
52
  */
53
  function bp_core_set_avatar_globals() {
54
  $bp = buddypress();
@@ -90,7 +86,7 @@ function bp_core_set_avatar_globals() {
90
  /**
91
  * Fires at the end of the core avatar globals setup.
92
  *
93
- * @since BuddyPress (1.5.0)
94
  */
95
  do_action( 'bp_core_set_avatar_globals' );
96
  }
@@ -107,76 +103,77 @@ add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
107
  * locally:
108
  * add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
109
  *
110
- * @param array $args {
111
  * An array of arguments. All arguments are technically optional; some
112
  * will, if not provided, be auto-detected by bp_core_fetch_avatar(). This
113
  * auto-detection is described more below, when discussing specific
114
  * arguments.
115
  *
116
- * @type int|bool $item_id The numeric ID of the item for which you're
117
- * requesting an avatar (eg, a user ID). If no 'item_id' is present,
118
- * the function attempts to infer an ID from the 'object' + the
119
- * current context: if 'object' is 'user' and the current page is a
120
- * user page, 'item_id' will default to the displayed user ID; if
121
- * 'group' and on a group page, to the current group ID; if 'blog',
122
- * to the current blog's ID. If no 'item_id' can be determined in
123
- * this way, the function returns false. Default: false.
124
- * @type string $object The kind of object for which you're getting an
125
- * avatar. BuddyPress natively supports three options: 'user',
126
- * 'group', 'blog'; a plugin may register more. Default: 'user'.
127
- * @type string $type When a new avatar is uploaded to BP, 'thumb' and
128
- * 'full' versions are saved. This parameter specifies whether you'd
129
- * like the 'full' or smaller 'thumb' avatar. Default: 'thumb'.
130
  * @type string|bool $avatar_dir The name of the subdirectory where the
131
- * requested avatar should be found. If no value is passed,
132
- * 'avatar_dir' is inferred from 'object': 'user' becomes 'avatars',
133
- * 'group' becomes 'group-avatars', 'blog' becomes 'blog-avatars'.
134
- * Remember that this string denotes a subdirectory of BP's main
135
- * avatar directory (usually based on {@link wp_upload_dir()}); it's a
136
- * string like 'group-avatars' rather than the full directory path.
137
- * Generally, it'll only be necessary to override the default value if
138
- * storing avatars in a non-default location. Defaults to false
139
- * (auto-detected).
140
- * @type int|bool $width Requested avatar width. The unit is px. This value
141
- * is used to build the 'width' attribute for the <img> element. If
142
- * no value is passed, BP uses the global avatar width for this
143
- * avatar type. Default: false (auto-detected).
144
- * @type int|bool $height Requested avatar height. The unit is px. This
145
- * value is used to build the 'height' attribute for the <img>
146
- * element. If no value is passed, BP uses the global avatar height
147
- * for this avatar type. Default: false (auto-detected).
148
- * @type string $class The CSS class for the <img> element. Note that BP
149
- * uses the 'avatar' class fairly extensively in its default styling,
150
- * so if you plan to pass a custom value, consider appending it to
151
- * 'avatar' (eg 'avatar foo') rather than replacing it altogether.
152
- * Default: 'avatar'.
153
- * @type string|bool $css_id The CSS id for the <img> element.
154
- * Default: false.
155
- * @type string $title The title attribute for the <img> element.
156
- * Default: false.
157
- * @type string $alt The alt attribute for the <img> element. In BP, this
158
- * value is generally passed by the wrapper functions, where the data
159
- * necessary for concatenating the string is at hand; see
160
- * {@link bp_get_activity_avatar()} for an example. Default: ''.
161
- * @type string|bool $email An email to use in Gravatar queries. Unless
162
- * otherwise configured, BP uses Gravatar as a fallback for avatars
163
- * that are not provided locally. Gravatar's API requires using a hash
164
- * of the user's email address; this argument provides it. If not
165
- * provided, the function will infer it: for users, by getting the
166
- * user's email from the database, for groups/blogs, by concatenating
167
- * "{$item_id}-{$object}@{bp_get_root_domain()}". The user query adds
168
- * overhead, so it's recommended that wrapper functions provide a
169
- * value for 'email' when querying user IDs. Default: false.
170
- * @type bool $no_grav Whether to disable the default Gravatar fallback.
171
- * By default, BP will fall back on Gravatar when it cannot find a
172
- * local avatar. In some cases, this may be undesirable, in which
173
- * case 'no_grav' should be set to true. To disable Gravatar
174
- * fallbacks globally, see the 'bp_core_fetch_avatar_no_grav' filter.
175
- * Default: false.
176
- * @type bool $html Whether to return an <img> HTML element, vs a raw URL
177
- * to an avatar. If false, <img>-specific arguments (like 'css_id')
178
- * will be ignored. Default: true.
179
  * }
 
180
  * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg.
181
  */
182
  function bp_core_fetch_avatar( $args = '' ) {
@@ -234,7 +231,7 @@ function bp_core_fetch_avatar( $args = '' ) {
234
  /**
235
  * Filters the ID of the item being requested.
236
  *
237
- * @since BuddyPress (1.1.0)
238
  *
239
  * @param string $value ID of avatar item being requested.
240
  * @param string $value Avatar type being requested.
@@ -275,7 +272,7 @@ function bp_core_fetch_avatar( $args = '' ) {
275
  /**
276
  * Filters the avatar directory to use.
277
  *
278
- * @since BuddyPress (1.1.0)
279
  *
280
  * @param string $value Name of the subdirectory where the requested avatar should be found.
281
  * @param string $value Avatar type being requested.
@@ -311,7 +308,7 @@ function bp_core_fetch_avatar( $args = '' ) {
311
  /**
312
  * Filters the alt attribute value to be applied to avatar.
313
  *
314
- * @since BuddyPress (1.5.0)
315
  *
316
  * @param string $value alt to be applied to avatar.
317
  * @param string $value ID of avatar item being requested.
@@ -324,19 +321,19 @@ function bp_core_fetch_avatar( $args = '' ) {
324
 
325
  /** Sanity Checks *********************************************************/
326
 
327
- // Get a fallback for the 'alt' parameter, create html output
328
  if ( empty( $params['alt'] ) ) {
329
  $params['alt'] = __( 'Profile Photo', 'buddypress' );
330
  }
331
  $html_alt = ' alt="' . esc_attr( $params['alt'] ) . '"';
332
 
333
- // Filter image title and create html string
334
  $html_title = '';
335
 
336
  /**
337
  * Filters the title attribute value to be applied to avatar.
338
  *
339
- * @since BuddyPress (1.5.0)
340
  *
341
  * @param string $value Title to be applied to avatar.
342
  * @param string $value ID of avatar item being requested.
@@ -349,13 +346,13 @@ function bp_core_fetch_avatar( $args = '' ) {
349
  $html_title = ' title="' . esc_attr( $params['title'] ) . '"';
350
  }
351
 
352
- // Set CSS ID and create html string
353
  $html_css_id = '';
354
 
355
  /**
356
  * Filters the ID attribute to be applied to avatar.
357
  *
358
- * @since BuddyPress (2.2.0)
359
  *
360
  * @param string $value ID to be applied to avatar.
361
  * @param string $value ID of avatar item being requested.
@@ -391,7 +388,7 @@ function bp_core_fetch_avatar( $args = '' ) {
391
  /**
392
  * Filters the classes to be applied to the avatar.
393
  *
394
- * @since BuddyPress (1.6.0)
395
  *
396
  * @param array|string $value Class(es) to be applied to the avatar.
397
  * @param string $value ID of the avatar item being requested.
@@ -428,7 +425,7 @@ function bp_core_fetch_avatar( $args = '' ) {
428
  /**
429
  * Filters the avatar folder directory URL.
430
  *
431
- * @since BuddyPress (1.1.0)
432
  *
433
  * @param string $value Path to the avatar folder URL.
434
  * @param int $value ID of the avatar item being requested.
@@ -440,7 +437,7 @@ function bp_core_fetch_avatar( $args = '' ) {
440
  /**
441
  * Filters the avatar folder directory path.
442
  *
443
- * @since BuddyPress (1.1.0)
444
  *
445
  * @param string $value Path to the avatar folder directory.
446
  * @param int $value ID of the avatar item being requested.
@@ -515,7 +512,7 @@ function bp_core_fetch_avatar( $args = '' ) {
515
  /**
516
  * Filters an avatar URL wrapped in an <img> element.
517
  *
518
- * @since BuddyPress (1.1.0)
519
  *
520
  * @param string $value Full <img> element for an avatar.
521
  * @param array $params Array of parameters for the request.
@@ -535,7 +532,7 @@ function bp_core_fetch_avatar( $args = '' ) {
535
  /**
536
  * Filters a locally uploaded avatar URL.
537
  *
538
- * @since BuddyPress (1.2.5)
539
  *
540
  * @param string $avatar_url URL for a locally uploaded avatar.
541
  * @param array $params Array of parameters for the request.
@@ -548,7 +545,7 @@ function bp_core_fetch_avatar( $args = '' ) {
548
  /**
549
  * Filters whether or not to skip Gravatar check.
550
  *
551
- * @since BuddyPress (1.5.0)
552
  *
553
  * @param bool $value Whether or not to skip Gravatar.
554
  * @param array $params Array of parameters for the avatar request.
@@ -561,9 +558,9 @@ function bp_core_fetch_avatar( $args = '' ) {
561
  } elseif ( 'mystery' == $bp->grav_default->{$params['object']} ) {
562
 
563
  /**
564
- * Filters the Mysteryman avatar src value.
565
  *
566
- * @since BuddyPress (1.2.0)
567
  *
568
  * @param string $value Avatar value.
569
  * @param string $value Width to display avatar at.
@@ -587,7 +584,7 @@ function bp_core_fetch_avatar( $args = '' ) {
587
  /**
588
  * Filters the Gravatar email to use.
589
  *
590
- * @since BuddyPress (1.1.0)
591
  *
592
  * @param string $value Email to use in Gravatar request.
593
  * @param string $value ID of the item being requested.
@@ -598,7 +595,7 @@ function bp_core_fetch_avatar( $args = '' ) {
598
  /**
599
  * Filters the Gravatar URL path.
600
  *
601
- * @since BuddyPress (1.0.2)
602
  *
603
  * @param string $value Gravatar URL path.
604
  */
@@ -618,7 +615,7 @@ function bp_core_fetch_avatar( $args = '' ) {
618
  *
619
  * This is a variable filter dependent on the avatar type being requested.
620
  *
621
- * @since BuddyPress (1.5.0)
622
  *
623
  * @param string $value Default avatar for non-gravatar requests.
624
  * @param array $params Array of parameters for the avatar request.
@@ -640,15 +637,16 @@ function bp_core_fetch_avatar( $args = '' ) {
640
  /**
641
  * Delete an existing avatar.
642
  *
643
- * @param array $args {
644
  * Array of function parameters.
645
- * @type bool|int $item_id ID of the item whose avatar you're deleting.
646
- * Defaults to the current item of type $object.
647
- * @type string $object Object type of the item whose avatar you're
648
- * deleting. 'user', 'group', 'blog', or custom. Default: 'user'.
 
649
  * @type bool|string $avatar_dir Subdirectory where avatar is located.
650
- * Default: false, which falls back on the default location
651
- * corresponding to the $object.
652
  * }
653
  * @return bool True on success, false on failure.
654
  */
@@ -710,7 +708,7 @@ function bp_core_delete_existing_avatar( $args = '' ) {
710
  /**
711
  * Fires after deleting an existing avatar.
712
  *
713
- * @since BuddyPress (1.1.0)
714
  *
715
  * @param array $args Array of arguments used for avatar deletion.
716
  */
@@ -720,15 +718,15 @@ function bp_core_delete_existing_avatar( $args = '' ) {
720
  }
721
 
722
  /**
723
- * Ajax delete an avatar for a given object and item id
724
  *
725
- * @since BuddyPress (2.3.0)
726
  *
727
- * @return string a json object containing success data if the avatar was deleted
728
- * error message otherwise
729
  */
730
  function bp_avatar_ajax_delete() {
731
- // Bail if not a POST action
732
  if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
733
  wp_send_json_error();
734
  }
@@ -798,7 +796,7 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
798
  *
799
  * If you want to override this function, make sure you return false.
800
  *
801
- * @since BuddyPress (1.2.4)
802
  *
803
  * @param bool $value Whether or not to crop.
804
  * @param array $file Appropriate entry from $_FILES superglobal.
@@ -808,22 +806,30 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
808
  return true;
809
  }
810
 
811
- // Setup some variables
812
  $bp = buddypress();
813
  $upload_path = bp_core_avatar_upload_path();
814
 
815
- // Upload the file
816
  $avatar_attachment = new BP_Attachment_Avatar();
817
  $bp->avatar_admin->original = $avatar_attachment->upload( $file, $upload_dir_filter );
818
 
819
- // In case of an error, stop the process and display a feedback to the user
820
  if ( ! empty( $bp->avatar_admin->original['error'] ) ) {
821
  bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
822
  return false;
823
  }
824
 
825
- // Maybe resize
826
- $bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'] );
 
 
 
 
 
 
 
 
827
  $bp->avatar_admin->image = new stdClass();
828
 
829
  // We only want to handle one image after resize.
@@ -836,30 +842,30 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
836
  @unlink( $bp->avatar_admin->original['file'] );
837
  }
838
 
839
- // Check for WP_Error on what should be an image
840
  if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
841
  bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
842
  return false;
843
  }
844
 
845
- // If the uploaded image is smaller than the "full" dimensions, throw a warning
846
  if ( $avatar_attachment->is_too_small( $bp->avatar_admin->image->file ) ) {
847
  bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %d x %d pixels.', 'buddypress' ), bp_core_avatar_full_width(), bp_core_avatar_full_height() ), 'error' );
848
  }
849
 
850
- // Set the url value for the image
851
  $bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
852
 
853
  return true;
854
  }
855
 
856
  /**
857
- * Ajax upload an avatar
858
  *
859
- * @since BuddyPress (2.3.0)
860
  *
861
- * @return string a json object containing success data if the upload succeeded
862
- * error message otherwise
863
  */
864
  function bp_avatar_ajax_upload() {
865
  // Bail if not a POST action
@@ -922,11 +928,11 @@ function bp_avatar_ajax_upload() {
922
  }
923
  } else {
924
  /**
925
- * Filter here to deal with other components
926
  *
927
- * @since BuddyPress (2.3.0)
928
  *
929
- * @var array $bp_params the BuddyPress Ajax parameters
930
  */
931
  $bp_params = apply_filters( 'bp_core_avatar_ajax_upload_params', $bp_params );
932
  }
@@ -935,6 +941,14 @@ function bp_avatar_ajax_upload() {
935
  $bp->avatar_admin = new stdClass();
936
  }
937
 
 
 
 
 
 
 
 
 
938
  // Upload the avatar
939
  $avatar = bp_core_avatar_handle_upload( $_FILES, $bp_params['upload_dir_filter'] );
940
 
@@ -999,14 +1013,15 @@ function bp_avatar_ajax_upload() {
999
  add_action( 'wp_ajax_bp_avatar_upload', 'bp_avatar_ajax_upload' );
1000
 
1001
  /**
1002
- * Handle avatar webcam capture.
1003
- *
1004
- * @since BuddyPress (2.3.0)
1005
- *
1006
- * @param string $data base64 encoded image.
1007
- * @param int $item_id.
1008
- * @return bool True on success, false on failure.
1009
- */
 
1010
  function bp_avatar_handle_capture( $data = '', $item_id = 0 ) {
1011
  if ( empty( $data ) || empty( $item_id ) ) {
1012
  return false;
@@ -1014,16 +1029,26 @@ function bp_avatar_handle_capture( $data = '', $item_id = 0 ) {
1014
 
1015
  $avatar_dir = bp_core_avatar_upload_path() . '/avatars';
1016
 
1017
- // It's not a regular upload, we may need to create this folder
1018
  if ( ! file_exists( $avatar_dir ) ) {
1019
  if ( ! wp_mkdir_p( $avatar_dir ) ) {
1020
  return false;
1021
  }
1022
  }
1023
 
 
 
 
 
 
 
 
 
 
 
1024
  $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', $avatar_dir . '/' . $item_id, $item_id, 'user', 'avatars' );
1025
 
1026
- // It's not a regular upload, we may need to create this folder
1027
  if( ! is_dir( $avatar_folder_dir ) ) {
1028
  if ( ! wp_mkdir_p( $avatar_folder_dir ) ) {
1029
  return false;
@@ -1057,22 +1082,24 @@ function bp_avatar_handle_capture( $data = '', $item_id = 0 ) {
1057
  * crop_x - The horizontal starting point of the crop
1058
  * crop_y - The vertical starting point of the crop
1059
  *
1060
- * @param array $args {
1061
  * Array of function parameters.
1062
- * @type string $object Object type of the item whose avatar you're
1063
- * handling. 'user', 'group', 'blog', or custom. Default: 'user'.
1064
- * @type string $avatar_dir Subdirectory where avatar should be stored.
1065
- * Default: 'avatars'.
1066
- * @type bool|int $item_id ID of the item that the avatar belongs to.
1067
- * @type bool|string $original_file Absolute path to the original avatar
1068
- * file.
1069
- * @type int $crop_w Crop width. Default: the global 'full' avatar width,
1070
- * as retrieved by bp_core_avatar_full_width().
1071
- * @type int $crop_h Crop height. Default: the global 'full' avatar height,
1072
- * as retrieved by bp_core_avatar_full_height().
1073
- * @type int $crop_x The horizontal starting point of the crop. Default: 0.
1074
- * @type int $crop_y The vertical starting point of the crop. Default: 0.
 
1075
  * }
 
1076
  * @return bool True on success, false on failure.
1077
  */
1078
  function bp_core_avatar_handle_crop( $args = '' ) {
@@ -1093,10 +1120,10 @@ function bp_core_avatar_handle_crop( $args = '' ) {
1093
  *
1094
  * If you want to override this function, make sure you return false.
1095
  *
1096
- * @since BuddyPress (1.2.4)
1097
  *
1098
  * @param bool $value Whether or not to crop.
1099
- * @param array $r Array of parsed arguments for function
1100
  */
1101
  if ( ! apply_filters( 'bp_core_pre_avatar_handle_crop', true, $r ) ) {
1102
  return true;
@@ -1115,12 +1142,12 @@ function bp_core_avatar_handle_crop( $args = '' ) {
1115
  }
1116
 
1117
  /**
1118
- * Ajax set an avatar for a given object and item id
1119
  *
1120
- * @since BuddyPress (2.3.0)
1121
  *
1122
- * @return string a json object containing success data if the crop/capture succeeded
1123
- * error message otherwise
1124
  */
1125
  function bp_avatar_ajax_set() {
1126
  // Bail if not a POST action
@@ -1256,11 +1283,12 @@ add_action( 'wp_ajax_bp_avatar_set', 'bp_avatar_ajax_set' );
1256
  *
1257
  * Filters 'get_avatar'.
1258
  *
1259
- * @param string $avatar The avatar path passed to 'get_avatar'.
1260
- * @param int|string|object $user A user ID, email address, or comment object.
1261
- * @param int $size Size of the avatar image ('thumb' or 'full').
1262
- * @param string $default URL to a default image to use if no avatar is available.
1263
- * @param string $alt Alternate text to use in image tag. Default: ''.
 
1264
  * @return string BP avatar path, if found; else the original avatar path.
1265
  */
1266
  function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = '' ) {
@@ -1322,6 +1350,7 @@ add_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );
1322
  * Is the current avatar upload error-free?
1323
  *
1324
  * @param array $file The $_FILES array.
 
1325
  * @return bool True if no errors are found. False if there are errors.
1326
  */
1327
  function bp_core_check_avatar_upload( $file ) {
@@ -1335,6 +1364,7 @@ function bp_core_check_avatar_upload( $file ) {
1335
  * Is the file size of the current avatar upload permitted?
1336
  *
1337
  * @param array $file The $_FILES array.
 
1338
  * @return bool True if the avatar is under the size limit, otherwise false.
1339
  */
1340
  function bp_core_check_avatar_size( $file ) {
@@ -1345,19 +1375,19 @@ function bp_core_check_avatar_size( $file ) {
1345
  }
1346
 
1347
  /**
1348
- * Get allowed avatar types
1349
  *
1350
- * @since BuddyPress (2.3.0)
1351
  */
1352
  function bp_core_get_allowed_avatar_types() {
1353
- $allowed_types = array( 'jpeg', 'gif', 'png' );
1354
 
1355
  /**
1356
- * Use this filter to restrict image types
1357
  *
1358
- * @since BuddyPress (2.3.0)
1359
  *
1360
- * @param array list of image types
1361
  */
1362
  $avatar_types = (array) apply_filters( 'bp_core_get_allowed_avatar_types', $allowed_types );
1363
 
@@ -1371,24 +1401,14 @@ function bp_core_get_allowed_avatar_types() {
1371
  }
1372
 
1373
  /**
1374
- * Get allowed avatar mime types
1375
  *
1376
- * @since BuddyPress (2.3.0)
1377
  */
1378
  function bp_core_get_allowed_avatar_mimes() {
1379
  $allowed_types = bp_core_get_allowed_avatar_types();
1380
- $validate_mimes = wp_match_mime_types( join( ',', $allowed_types ), wp_get_mime_types() );
1381
- $allowed_mimes = array_map( 'implode', $validate_mimes );
1382
 
1383
- /**
1384
- * Include jpg type if needed so that bp_core_check_avatar_type()
1385
- * will check for jpeg and jpg extensions.
1386
- */
1387
- if ( isset( $allowed_mimes['jpeg'] ) ) {
1388
- $allowed_mimes['jpg'] = $allowed_mimes['jpeg'];
1389
- }
1390
-
1391
- return $allowed_mimes;
1392
  }
1393
 
1394
  /**
@@ -1397,25 +1417,21 @@ function bp_core_get_allowed_avatar_mimes() {
1397
  * Permitted file types are JPG, GIF and PNG.
1398
  *
1399
  * @param array $file The $_FILES array.
 
1400
  * @return bool True if the file extension is permitted, otherwise false.
1401
  */
1402
  function bp_core_check_avatar_type( $file ) {
1403
- $avatar_filetype = wp_check_filetype_and_ext( $file['file']['tmp_name'], $file['file']['name'], bp_core_get_allowed_avatar_mimes() );
1404
-
1405
- if ( ! empty( $avatar_filetype['ext'] ) && ! empty( $avatar_filetype['type'] ) ) {
1406
- return true;
1407
- }
1408
-
1409
- return false;
1410
  }
1411
 
1412
  /**
1413
  * Fetch data from the BP root blog's upload directory.
1414
  *
1415
- * @since BuddyPress (1.8.0)
 
 
 
1416
  *
1417
- * @param string $type The variable we want to return from the $bp->avatars
1418
- * object. Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
1419
  * @return string The avatar upload directory path.
1420
  */
1421
  function bp_core_get_upload_dir( $type = 'upload_path' ) {
@@ -1440,30 +1456,30 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) {
1440
  break;
1441
  }
1442
 
1443
- // See if the value has already been calculated and stashed in the $bp global
1444
  if ( isset( $bp->avatar->$type ) ) {
1445
  $retval = $bp->avatar->$type;
1446
  } else {
1447
- // If this value has been set in a constant, just use that
1448
  if ( defined( $constant ) ) {
1449
  $retval = constant( $constant );
1450
  } else {
1451
 
1452
- // Use cached upload dir data if available
1453
  if ( ! empty( $bp->avatar->upload_dir ) ) {
1454
  $upload_dir = $bp->avatar->upload_dir;
1455
 
1456
- // No cache, so query for it
1457
  } else {
1458
 
1459
- // Get upload directory information from current site
1460
  $upload_dir = bp_upload_dir();
1461
 
1462
- // Stash upload directory data for later use
1463
  $bp->avatar->upload_dir = $upload_dir;
1464
  }
1465
 
1466
- // Directory does not exist and cannot be created
1467
  if ( ! empty( $upload_dir['error'] ) ) {
1468
  $retval = '';
1469
 
@@ -1479,7 +1495,7 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) {
1479
 
1480
  }
1481
 
1482
- // Stash in $bp for later use
1483
  $bp->avatar->$type = $retval;
1484
  }
1485
 
@@ -1489,7 +1505,7 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) {
1489
  /**
1490
  * Get the absolute upload path for the WP installation.
1491
  *
1492
- * @uses bp_core_get_upload_dir() To get upload directory info
1493
  *
1494
  * @return string Absolute path to WP upload directory.
1495
  */
@@ -1498,7 +1514,7 @@ function bp_core_avatar_upload_path() {
1498
  /**
1499
  * Filters the absolute upload path for the WP installation.
1500
  *
1501
- * @since BuddyPress (1.2.0)
1502
  *
1503
  * @param string $value Absolute upload path for the WP installation.
1504
  */
@@ -1517,7 +1533,7 @@ function bp_core_avatar_url() {
1517
  /**
1518
  * Filters the raw base URL for root site upload location.
1519
  *
1520
- * @since BuddyPress (1.2.0)
1521
  *
1522
  * @param string $value Raw base URL for the root site upload location.
1523
  */
@@ -1527,9 +1543,10 @@ function bp_core_avatar_url() {
1527
  /**
1528
  * Check if a given user ID has an uploaded avatar.
1529
  *
1530
- * @since BuddyPress (1.0.0)
1531
  *
1532
  * @param int $user_id ID of the user whose avatar is being checked.
 
1533
  * @return bool True if the user has uploaded a local avatar. Otherwise false.
1534
  */
1535
  function bp_get_user_has_avatar( $user_id = 0 ) {
@@ -1544,7 +1561,7 @@ function bp_get_user_has_avatar( $user_id = 0 ) {
1544
  /**
1545
  * Filters whether or not a user has an uploaded avatar.
1546
  *
1547
- * @since BuddyPress (1.6.0)
1548
  *
1549
  * @param bool $retval Whether or not a user has an uploaded avatar.
1550
  * @param int $user_id ID of the user being checked.
@@ -1555,13 +1572,14 @@ function bp_get_user_has_avatar( $user_id = 0 ) {
1555
  /**
1556
  * Utility function for fetching an avatar dimension setting.
1557
  *
1558
- * @since BuddyPress (1.5.0)
1559
  *
1560
- * @param string $type Dimension type you're fetching dimensions for. 'thumb'
1561
- * or 'full'. Default: 'thumb'.
1562
  * @param string $h_or_w Which dimension is being fetched. 'height' or 'width'.
1563
- * Default: 'height'.
1564
- * @return int $dim The dimension.
 
1565
  */
1566
  function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
1567
  $bp = buddypress();
@@ -1570,11 +1588,11 @@ function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
1570
  /**
1571
  * Filters the avatar dimension setting.
1572
  *
1573
- * @since BuddyPress (1.5.0)
1574
  *
1575
- * @param int $dim Dimension setting for the type.
1576
- * @param string $type The type of avatar whose dimensions are requested. Default 'thumb'.
1577
- * @param string $h_or_w The dimension parameter being requested. Default 'height'.
1578
  */
1579
  return apply_filters( 'bp_core_avatar_dimension', $dim, $type, $h_or_w );
1580
  }
@@ -1582,7 +1600,7 @@ function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
1582
  /**
1583
  * Get the 'thumb' avatar width setting.
1584
  *
1585
- * @since BuddyPress (1.5.0)
1586
  *
1587
  * @return int The 'thumb' width.
1588
  */
@@ -1591,7 +1609,7 @@ function bp_core_avatar_thumb_width() {
1591
  /**
1592
  * Filters the 'thumb' avatar width setting.
1593
  *
1594
- * @since BuddyPress (1.5.0)
1595
  *
1596
  * @param int $value Value for the 'thumb' avatar width setting.
1597
  */
@@ -1601,7 +1619,7 @@ function bp_core_avatar_thumb_width() {
1601
  /**
1602
  * Get the 'thumb' avatar height setting.
1603
  *
1604
- * @since BuddyPress (1.5.0)
1605
  *
1606
  * @return int The 'thumb' height.
1607
  */
@@ -1610,7 +1628,7 @@ function bp_core_avatar_thumb_height() {
1610
  /**
1611
  * Filters the 'thumb' avatar height setting.
1612
  *
1613
- * @since BuddyPress (1.5.0)
1614
  *
1615
  * @param int $value Value for the 'thumb' avatar height setting.
1616
  */
@@ -1618,9 +1636,9 @@ function bp_core_avatar_thumb_height() {
1618
  }
1619
 
1620
  /**
1621
- * Get the 'full' avatar width setting
1622
  *
1623
- * @since BuddyPress (1.5.0)
1624
  *
1625
  * @return int The 'full' width.
1626
  */
@@ -1629,7 +1647,7 @@ function bp_core_avatar_full_width() {
1629
  /**
1630
  * Filters the 'full' avatar width setting.
1631
  *
1632
- * @since BuddyPress (1.5.0)
1633
  *
1634
  * @param int $value Value for the 'full' avatar width setting.
1635
  */
@@ -1639,7 +1657,7 @@ function bp_core_avatar_full_width() {
1639
  /**
1640
  * Get the 'full' avatar height setting.
1641
  *
1642
- * @since BuddyPress (1.5.0)
1643
  *
1644
  * @return int The 'full' height.
1645
  */
@@ -1648,7 +1666,7 @@ function bp_core_avatar_full_height() {
1648
  /**
1649
  * Filters the 'full' avatar height setting.
1650
  *
1651
- * @since BuddyPress (1.5.0)
1652
  *
1653
  * @param int $value Value for the 'full' avatar height setting.
1654
  */
@@ -1658,7 +1676,7 @@ function bp_core_avatar_full_height() {
1658
  /**
1659
  * Get the max width for original avatar uploads.
1660
  *
1661
- * @since BuddyPress (1.5.0)
1662
  *
1663
  * @return int The max width for original avatar uploads.
1664
  */
@@ -1667,7 +1685,7 @@ function bp_core_avatar_original_max_width() {
1667
  /**
1668
  * Filters the max width for original avatar uploads.
1669
  *
1670
- * @since BuddyPress (1.5.0)
1671
  *
1672
  * @param int $value Value for the max width.
1673
  */
@@ -1677,7 +1695,7 @@ function bp_core_avatar_original_max_width() {
1677
  /**
1678
  * Get the max filesize for original avatar uploads.
1679
  *
1680
- * @since BuddyPress (1.5.0)
1681
  *
1682
  * @return int The max filesize for original avatar uploads.
1683
  */
@@ -1686,7 +1704,7 @@ function bp_core_avatar_original_max_filesize() {
1686
  /**
1687
  * Filters the max filesize for original avatar uploads.
1688
  *
1689
- * @since BuddyPress (1.5.0)
1690
  *
1691
  * @param int $value Value for the max filesize.
1692
  */
@@ -1696,11 +1714,12 @@ function bp_core_avatar_original_max_filesize() {
1696
  /**
1697
  * Get the URL of the 'full' default avatar.
1698
  *
1699
- * @since BuddyPress (1.5.0)
 
 
 
 
1700
  *
1701
- * @param string $type 'local' if the fallback should be the locally-hosted
1702
- * version of the mystery-man, 'gravatar' if the fallback should be
1703
- * Gravatar's version. Default: 'gravatar'.
1704
  * @return string The URL of the default avatar.
1705
  */
1706
  function bp_core_avatar_default( $type = 'gravatar' ) {
@@ -1712,7 +1731,7 @@ function bp_core_avatar_default( $type = 'gravatar' ) {
1712
  } elseif ( 'local' === $type ) {
1713
  $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man.jpg';
1714
 
1715
- // Use Gravatar's mystery man as fallback
1716
  } else {
1717
  $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_full_width();
1718
  }
@@ -1720,7 +1739,7 @@ function bp_core_avatar_default( $type = 'gravatar' ) {
1720
  /**
1721
  * Filters the URL of the 'full' default avatar.
1722
  *
1723
- * @since BuddyPress (1.5.0)
1724
  *
1725
  * @param string $avatar URL of the default avatar.
1726
  */
@@ -1730,14 +1749,15 @@ function bp_core_avatar_default( $type = 'gravatar' ) {
1730
  /**
1731
  * Get the URL of the 'thumb' default avatar.
1732
  *
1733
- * Uses Gravatar's mystery-man avatar, unless BP_AVATAR_DEFAULT_THUMB has been
1734
  * defined.
1735
  *
1736
- * @since BuddyPress (1.5.0)
 
 
 
 
1737
  *
1738
- * @param string $type 'local' if the fallback should be the locally-hosted
1739
- * version of the mystery-man, 'gravatar' if the fallback should be
1740
- * Gravatar's version. Default: 'gravatar'.
1741
  * @return string The URL of the default avatar thumb.
1742
  */
1743
  function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
@@ -1749,7 +1769,7 @@ function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
1749
  } elseif ( 'local' === $type ) {
1750
  $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man-50.jpg';
1751
 
1752
- // Use Gravatar's mystery man as fallback
1753
  } else {
1754
  $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_thumb_width();
1755
  }
@@ -1757,7 +1777,7 @@ function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
1757
  /**
1758
  * Filters the URL of the 'thumb' default avatar.
1759
  *
1760
- * @since BuddyPress (1.5.0)
1761
  *
1762
  * @param string $avatar URL of the default avatar.
1763
  */
@@ -1765,15 +1785,16 @@ function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
1765
  }
1766
 
1767
  /**
1768
- * Reset the week parameter of the WordPress main query if needed
1769
  *
1770
  * When cropping an avatar, a $_POST['w'] var is sent, setting the 'week'
1771
  * parameter of the WordPress main query to this posted var. To avoid
1772
- * notices, we need to make sure this 'week' query var is reset to 0
 
 
1773
  *
1774
- * @since BuddyPress (2.2.0)
1775
  *
1776
- * @param WP_Query $posts_query the main query object
1777
  * @uses bp_is_group_create()
1778
  * @uses bp_is_group_admin_page()
1779
  * @uses bp_is_group_admin_screen() to check for a group admin screen
@@ -1808,11 +1829,11 @@ function bp_core_avatar_reset_query( $posts_query = null ) {
1808
  add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );
1809
 
1810
  /**
1811
- * Checks whether Avatar UI should be loaded
1812
  *
1813
- * @since BuddyPress (2.3.0)
1814
  *
1815
- * @return bool True if Avatar UI should load, false otherwise
1816
  */
1817
  function bp_avatar_is_front_edit() {
1818
  $retval = false;
@@ -1842,17 +1863,17 @@ function bp_avatar_is_front_edit() {
1842
  * - Load the avatar UI for a component that is !groups or !user (return true regarding your conditions)
1843
  * - Completely disable the avatar UI introduced in 2.3 (eg: __return_false())
1844
  *
1845
- * @since BuddyPress (2.3.0)
1846
  *
1847
- * @var bool whether to load the Avatar UI
1848
  */
1849
  return apply_filters( 'bp_avatar_is_front_edit', $retval );
1850
  }
1851
 
1852
  /**
1853
- * Checks whether the Webcam Avatar UI part should be loaded
1854
  *
1855
- * @since BuddyPress (2.3.0)
1856
  *
1857
  * @global $is_safari
1858
  * @global $is_IE
@@ -1882,17 +1903,17 @@ function bp_avatar_use_webcam() {
1882
  * Use this filter if you need to disable the webcam capture feature
1883
  * by returning false.
1884
  *
1885
- * @since BuddyPress (2.3.0)
1886
  *
1887
- * @var bool whether to load Webcam Avatar UI part
1888
  */
1889
  return apply_filters( 'bp_avatar_use_webcam', true );
1890
  }
1891
 
1892
  /**
1893
- * Template function to load the Avatar UI javascript templates
1894
  *
1895
- * @since BuddyPress (2.3.0)
1896
  */
1897
  function bp_avatar_get_templates() {
1898
  if ( ! bp_avatar_is_front_edit() ) {
@@ -1903,12 +1924,12 @@ function bp_avatar_get_templates() {
1903
  }
1904
 
1905
  /**
1906
- * Trick to check if the theme's BuddyPress templates are up to date
1907
  *
1908
  * If the "avatar templates" are not including the new template tag, this will
1909
  * help users to get the avatar UI.
1910
  *
1911
- * @since BuddyPress (2.3.0)
1912
  */
1913
  function bp_avatar_template_check() {
1914
  if ( ! bp_avatar_is_front_edit() ) {
1
  <?php
 
2
  /**
3
  * BuddyPress Avatars.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Core
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
+ /**
13
  * Set up the constants we need for avatar support.
14
  */
15
  function bp_core_set_avatar_constants() {
32
  define( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 450 );
33
 
34
  if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) {
35
+ define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', bp_attachments_get_max_upload_file_size( 'avatar' ) );
 
 
 
 
 
 
36
  }
37
 
38
  if ( ! defined( 'BP_SHOW_AVATARS' ) ) {
44
  /**
45
  * Set up global variables related to avatars.
46
  *
47
+ * @since 1.5.0
48
  */
49
  function bp_core_set_avatar_globals() {
50
  $bp = buddypress();
86
  /**
87
  * Fires at the end of the core avatar globals setup.
88
  *
89
+ * @since 1.5.0
90
  */
91
  do_action( 'bp_core_set_avatar_globals' );
92
  }
103
  * locally:
104
  * add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
105
  *
106
+ * @param array|string $args {
107
  * An array of arguments. All arguments are technically optional; some
108
  * will, if not provided, be auto-detected by bp_core_fetch_avatar(). This
109
  * auto-detection is described more below, when discussing specific
110
  * arguments.
111
  *
112
+ * @type int|bool $item_id The numeric ID of the item for which you're requesting
113
+ * an avatar (eg, a user ID). If no 'item_id' is present,
114
+ * the function attempts to infer an ID from the 'object' + the
115
+ * current context: if 'object' is 'user' and the current page is a
116
+ * user page, 'item_id' will default to the displayed user ID; if
117
+ * 'group' and on a group page, to the current group ID; if 'blog',
118
+ * to the current blog's ID. If no 'item_id' can be determined in
119
+ * this way, the function returns false. Default: false.
120
+ * @type string $object The kind of object for which you're getting an
121
+ * avatar. BuddyPress natively supports three options: 'user',
122
+ * 'group', 'blog'; a plugin may register more. Default: 'user'.
123
+ * @type string $type When a new avatar is uploaded to BP, 'thumb' and
124
+ * 'full' versions are saved. This parameter specifies whether you'd
125
+ * like the 'full' or smaller 'thumb' avatar. Default: 'thumb'.
126
  * @type string|bool $avatar_dir The name of the subdirectory where the
127
+ * requested avatar should be found. If no value is passed,
128
+ * 'avatar_dir' is inferred from 'object': 'user' becomes 'avatars',
129
+ * 'group' becomes 'group-avatars', 'blog' becomes 'blog-avatars'.
130
+ * Remember that this string denotes a subdirectory of BP's main
131
+ * avatar directory (usually based on {@link wp_upload_dir()}); it's a
132
+ * string like 'group-avatars' rather than the full directory path.
133
+ * Generally, it'll only be necessary to override the default value if
134
+ * storing avatars in a non-default location. Defaults to false
135
+ * (auto-detected).
136
+ * @type int|bool $width Requested avatar width. The unit is px. This value
137
+ * is used to build the 'width' attribute for the <img> element. If
138
+ * no value is passed, BP uses the global avatar width for this
139
+ * avatar type. Default: false (auto-detected).
140
+ * @type int|bool $height Requested avatar height. The unit is px. This
141
+ * value is used to build the 'height' attribute for the <img>
142
+ * element. If no value is passed, BP uses the global avatar height
143
+ * for this avatar type. Default: false (auto-detected).
144
+ * @type string $class The CSS class for the <img> element. Note that BP
145
+ * uses the 'avatar' class fairly extensively in its default styling,
146
+ * so if you plan to pass a custom value, consider appending it to
147
+ * 'avatar' (eg 'avatar foo') rather than replacing it altogether.
148
+ * Default: 'avatar'.
149
+ * @type string|bool $css_id The CSS id for the <img> element.
150
+ * Default: false.
151
+ * @type string $title The title attribute for the <img> element.
152
+ * Default: false.
153
+ * @type string $alt The alt attribute for the <img> element. In BP, this
154
+ * value is generally passed by the wrapper functions, where the data
155
+ * necessary for concatenating the string is at hand; see
156
+ * {@link bp_get_activity_avatar()} for an example. Default: ''.
157
+ * @type string|bool $email An email to use in Gravatar queries. Unless
158
+ * otherwise configured, BP uses Gravatar as a fallback for avatars
159
+ * that are not provided locally. Gravatar's API requires using a hash
160
+ * of the user's email address; this argument provides it. If not
161
+ * provided, the function will infer it: for users, by getting the
162
+ * user's email from the database, for groups/blogs, by concatenating
163
+ * "{$item_id}-{$object}@{bp_get_root_domain()}". The user query adds
164
+ * overhead, so it's recommended that wrapper functions provide a
165
+ * value for 'email' when querying user IDs. Default: false.
166
+ * @type bool $no_grav Whether to disable the default Gravatar fallback.
167
+ * By default, BP will fall back on Gravatar when it cannot find a
168
+ * local avatar. In some cases, this may be undesirable, in which
169
+ * case 'no_grav' should be set to true. To disable Gravatar
170
+ * fallbacks globally, see the 'bp_core_fetch_avatar_no_grav' filter.
171
+ * Default: false.
172
+ * @type bool $html Whether to return an <img> HTML element, vs a raw URL
173
+ * to an avatar. If false, <img>-specific arguments (like 'css_id')
174
+ * will be ignored. Default: true.
175
  * }
176
+ *
177
  * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg.
178
  */
179
  function bp_core_fetch_avatar( $args = '' ) {
231
  /**
232
  * Filters the ID of the item being requested.
233
  *
234
+ * @since 1.1.0
235
  *
236
  * @param string $value ID of avatar item being requested.
237
  * @param string $value Avatar type being requested.
272
  /**
273
  * Filters the avatar directory to use.
274
  *
275
+ * @since 1.1.0
276
  *
277
  * @param string $value Name of the subdirectory where the requested avatar should be found.
278
  * @param string $value Avatar type being requested.
308
  /**
309
  * Filters the alt attribute value to be applied to avatar.
310
  *
311
+ * @since 1.5.0
312
  *
313
  * @param string $value alt to be applied to avatar.
314
  * @param string $value ID of avatar item being requested.
321
 
322
  /** Sanity Checks *********************************************************/
323
 
324
+ // Get a fallback for the 'alt' parameter, create html output.
325
  if ( empty( $params['alt'] ) ) {
326
  $params['alt'] = __( 'Profile Photo', 'buddypress' );
327
  }
328
  $html_alt = ' alt="' . esc_attr( $params['alt'] ) . '"';
329
 
330
+ // Filter image title and create html string.
331
  $html_title = '';
332
 
333
  /**
334
  * Filters the title attribute value to be applied to avatar.
335
  *
336
+ * @since 1.5.0
337
  *
338
  * @param string $value Title to be applied to avatar.
339
  * @param string $value ID of avatar item being requested.
346
  $html_title = ' title="' . esc_attr( $params['title'] ) . '"';
347
  }
348
 
349
+ // Set CSS ID and create html string.
350
  $html_css_id = '';
351
 
352
  /**
353
  * Filters the ID attribute to be applied to avatar.
354
  *
355
+ * @since 2.2.0
356
  *
357
  * @param string $value ID to be applied to avatar.
358
  * @param string $value ID of avatar item being requested.
388
  /**
389
  * Filters the classes to be applied to the avatar.
390
  *
391
+ * @since 1.6.0
392
  *
393
  * @param array|string $value Class(es) to be applied to the avatar.
394
  * @param string $value ID of the avatar item being requested.
425
  /**
426
  * Filters the avatar folder directory URL.
427
  *
428
+ * @since 1.1.0
429
  *
430
  * @param string $value Path to the avatar folder URL.
431
  * @param int $value ID of the avatar item being requested.
437
  /**
438
  * Filters the avatar folder directory path.
439
  *
440
+ * @since 1.1.0
441
  *
442
  * @param string $value Path to the avatar folder directory.
443
  * @param int $value ID of the avatar item being requested.
512
  /**
513
  * Filters an avatar URL wrapped in an <img> element.
514
  *
515
+ * @since 1.1.0
516
  *
517
  * @param string $value Full <img> element for an avatar.
518
  * @param array $params Array of parameters for the request.
532
  /**
533
  * Filters a locally uploaded avatar URL.
534
  *
535
+ * @since 1.2.5
536
  *
537
  * @param string $avatar_url URL for a locally uploaded avatar.
538
  * @param array $params Array of parameters for the request.
545
  /**
546
  * Filters whether or not to skip Gravatar check.
547
  *
548
+ * @since 1.5.0
549
  *
550
  * @param bool $value Whether or not to skip Gravatar.
551
  * @param array $params Array of parameters for the avatar request.
558
  } elseif ( 'mystery' == $bp->grav_default->{$params['object']} ) {
559
 
560
  /**
561
+ * Filters the Mystery person avatar src value.
562
  *
563
+ * @since 1.2.0
564
  *
565
  * @param string $value Avatar value.
566
  * @param string $value Width to display avatar at.
584
  /**
585
  * Filters the Gravatar email to use.
586
  *
587
+ * @since 1.1.0
588
  *
589
  * @param string $value Email to use in Gravatar request.
590
  * @param string $value ID of the item being requested.
595
  /**
596
  * Filters the Gravatar URL path.
597
  *
598
+ * @since 1.0.2
599
  *
600
  * @param string $value Gravatar URL path.
601
  */
615
  *
616
  * This is a variable filter dependent on the avatar type being requested.
617
  *
618
+ * @since 1.5.0
619
  *
620
  * @param string $value Default avatar for non-gravatar requests.
621
  * @param array $params Array of parameters for the avatar request.
637
  /**
638
  * Delete an existing avatar.
639
  *
640
+ * @param array|string $args {
641
  * Array of function parameters.
642
+ * @type bool|int $item_id ID of the item whose avatar you're deleting.
643
+ * Defaults to the current item of type $object.
644
+ * @type string $object Object type of the item whose avatar you're
645
+ * deleting. 'user', 'group', 'blog', or custom.
646
+ * Default: 'user'.
647
  * @type bool|string $avatar_dir Subdirectory where avatar is located.
648
+ * Default: false, which falls back on the default location
649
+ * corresponding to the $object.
650
  * }
651
  * @return bool True on success, false on failure.
652
  */
708
  /**
709
  * Fires after deleting an existing avatar.
710
  *
711
+ * @since 1.1.0
712
  *
713
  * @param array $args Array of arguments used for avatar deletion.
714
  */
718
  }
719
 
720
  /**
721
+ * Ajax delete an avatar for a given object and item id.
722
  *
723
+ * @since 2.3.0
724
  *
725
+ * @return string|null A json object containing success data if the avatar was deleted
726
+ * error message otherwise.
727
  */
728
  function bp_avatar_ajax_delete() {
729
+ // Bail if not a POST action.
730
  if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
731
  wp_send_json_error();
732
  }
796
  *
797
  * If you want to override this function, make sure you return false.
798
  *
799
+ * @since 1.2.4
800
  *
801
  * @param bool $value Whether or not to crop.
802
  * @param array $file Appropriate entry from $_FILES superglobal.
806
  return true;
807
  }
808
 
809
+ // Setup some variables.
810
  $bp = buddypress();
811
  $upload_path = bp_core_avatar_upload_path();
812
 
813
+ // Upload the file.
814
  $avatar_attachment = new BP_Attachment_Avatar();
815
  $bp->avatar_admin->original = $avatar_attachment->upload( $file, $upload_dir_filter );
816
 
817
+ // In case of an error, stop the process and display a feedback to the user.
818
  if ( ! empty( $bp->avatar_admin->original['error'] ) ) {
819
  bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
820
  return false;
821
  }
822
 
823
+ // The Avatar UI available width
824
+ $ui_available_width = 0;
825
+
826
+ // Try to set the ui_available_width using the avatar_admin global
827
+ if ( isset( $bp->avatar_admin->ui_available_width ) ) {
828
+ $ui_available_width = $bp->avatar_admin->ui_available_width;
829
+ }
830
+
831
+ // Maybe resize.
832
+ $bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'], $ui_available_width );
833
  $bp->avatar_admin->image = new stdClass();
834
 
835
  // We only want to handle one image after resize.
842
  @unlink( $bp->avatar_admin->original['file'] );
843
  }
844
 
845
+ // Check for WP_Error on what should be an image.
846
  if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
847
  bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
848
  return false;
849
  }
850
 
851
+ // If the uploaded image is smaller than the "full" dimensions, throw a warning.
852
  if ( $avatar_attachment->is_too_small( $bp->avatar_admin->image->file ) ) {
853
  bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %d x %d pixels.', 'buddypress' ), bp_core_avatar_full_width(), bp_core_avatar_full_height() ), 'error' );
854
  }
855
 
856
+ // Set the url value for the image.
857
  $bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
858
 
859
  return true;
860
  }
861
 
862
  /**
863
+ * Ajax upload an avatar.
864
  *
865
+ * @since 2.3.0
866
  *
867
+ * @return string|null A json object containing success data if the upload succeeded
868
+ * error message otherwise.
869
  */
870
  function bp_avatar_ajax_upload() {
871
  // Bail if not a POST action
928
  }
929
  } else {
930
  /**
931
+ * Filter here to deal with other components.
932
  *
933
+ * @since 2.3.0
934
  *
935
+ * @var array $bp_params the BuddyPress Ajax parameters.
936
  */
937
  $bp_params = apply_filters( 'bp_core_avatar_ajax_upload_params', $bp_params );
938
  }
941
  $bp->avatar_admin = new stdClass();
942
  }
943
 
944
+ /**
945
+ * The BuddyPress upload parameters is including the Avatar UI Available width,
946
+ * add it to the avatar_admin global for a later use.
947
+ */
948
+ if ( isset( $bp_params['ui_available_width'] ) ) {
949
+ $bp->avatar_admin->ui_available_width = (int) $bp_params['ui_available_width'];
950
+ }
951
+
952
  // Upload the avatar
953
  $avatar = bp_core_avatar_handle_upload( $_FILES, $bp_params['upload_dir_filter'] );
954
 
1013
  add_action( 'wp_ajax_bp_avatar_upload', 'bp_avatar_ajax_upload' );
1014
 
1015
  /**
1016
+ * Handle avatar webcam capture.
1017
+ *
1018
+ * @since 2.3.0
1019
+ *
1020
+ * @param string $data Base64 encoded image.
1021
+ * @param int $item_id Item to associate.
1022
+ *
1023
+ * @return bool True on success, false on failure.
1024
+ */
1025
  function bp_avatar_handle_capture( $data = '', $item_id = 0 ) {
1026
  if ( empty( $data ) || empty( $item_id ) ) {
1027
  return false;
1029
 
1030
  $avatar_dir = bp_core_avatar_upload_path() . '/avatars';
1031
 
1032
+ // It's not a regular upload, we may need to create this folder.
1033
  if ( ! file_exists( $avatar_dir ) ) {
1034
  if ( ! wp_mkdir_p( $avatar_dir ) ) {
1035
  return false;
1036
  }
1037
  }
1038
 
1039
+ /**
1040
+ * Filters the Avatar folder directory.
1041
+ *
1042
+ * @since 2.3.0
1043
+ *
1044
+ * @param string $avatar_dir Directory for storing avatars.
1045
+ * @param int $item_id ID of the item being acted on.
1046
+ * @param string $value Avatar type.
1047
+ * @param string $value Avatars word.
1048
+ */
1049
  $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', $avatar_dir . '/' . $item_id, $item_id, 'user', 'avatars' );
1050
 
1051
+ // It's not a regular upload, we may need to create this folder.
1052
  if( ! is_dir( $avatar_folder_dir ) ) {
1053
  if ( ! wp_mkdir_p( $avatar_folder_dir ) ) {
1054
  return false;
1082
  * crop_x - The horizontal starting point of the crop
1083
  * crop_y - The vertical starting point of the crop
1084
  *
1085
+ * @param array|string $args {
1086
  * Array of function parameters.
1087
+ *
1088
+ * @type string $object Object type of the item whose avatar you're
1089
+ * handling. 'user', 'group', 'blog', or custom.
1090
+ * Default: 'user'.
1091
+ * @type string $avatar_dir Subdirectory where avatar should be stored.
1092
+ * Default: 'avatars'.
1093
+ * @type bool|int $item_id ID of the item that the avatar belongs to.
1094
+ * @type bool|string $original_file Absolute path to the original avatar file.
1095
+ * @type int $crop_w Crop width. Default: the global 'full' avatar width,
1096
+ * as retrieved by bp_core_avatar_full_width().
1097
+ * @type int $crop_h Crop height. Default: the global 'full' avatar height,
1098
+ * as retrieved by bp_core_avatar_full_height().
1099
+ * @type int $crop_x The horizontal starting point of the crop. Default: 0.
1100
+ * @type int $crop_y The vertical starting point of the crop. Default: 0.
1101
  * }
1102
+ *
1103
  * @return bool True on success, false on failure.
1104
  */
1105
  function bp_core_avatar_handle_crop( $args = '' ) {
1120
  *
1121
  * If you want to override this function, make sure you return false.
1122
  *
1123
+ * @since 1.2.4
1124
  *
1125
  * @param bool $value Whether or not to crop.
1126
+ * @param array $r Array of parsed arguments for function.
1127
  */
1128
  if ( ! apply_filters( 'bp_core_pre_avatar_handle_crop', true, $r ) ) {
1129
  return true;
1142
  }
1143
 
1144
  /**
1145
+ * Ajax set an avatar for a given object and item id.
1146
  *
1147
+ * @since 2.3.0
1148
  *
1149
+ * @return string|null A json object containing success data if the crop/capture succeeded
1150
+ * error message otherwise.
1151
  */
1152
  function bp_avatar_ajax_set() {
1153
  // Bail if not a POST action
1283
  *
1284
  * Filters 'get_avatar'.
1285
  *
1286
+ * @param string $avatar The avatar path passed to 'get_avatar'.
1287
+ * @param int|string|object $user A user ID, email address, or comment object.
1288
+ * @param int $size Size of the avatar image ('thumb' or 'full').
1289
+ * @param string $default URL to a default image to use if no avatar is available.
1290
+ * @param string $alt Alternate text to use in image tag. Default: ''.
1291
+ *
1292
  * @return string BP avatar path, if found; else the original avatar path.
1293
  */
1294
  function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = '' ) {
1350
  * Is the current avatar upload error-free?
1351
  *
1352
  * @param array $file The $_FILES array.
1353
+ *
1354
  * @return bool True if no errors are found. False if there are errors.
1355
  */
1356
  function bp_core_check_avatar_upload( $file ) {
1364
  * Is the file size of the current avatar upload permitted?
1365
  *
1366
  * @param array $file The $_FILES array.
1367
+ *
1368
  * @return bool True if the avatar is under the size limit, otherwise false.
1369
  */
1370
  function bp_core_check_avatar_size( $file ) {
1375
  }
1376
 
1377
  /**
1378
+ * Get allowed avatar types.
1379
  *
1380
+ * @since 2.3.0
1381
  */
1382
  function bp_core_get_allowed_avatar_types() {
1383
+ $allowed_types = bp_attachments_get_allowed_types( 'avatar' );
1384
 
1385
  /**
1386
+ * Filters the list of allowed image types.
1387
  *
1388
+ * @since 2.3.0
1389
  *
1390
+ * @param array $allowed_types List of image types.
1391
  */
1392
  $avatar_types = (array) apply_filters( 'bp_core_get_allowed_avatar_types', $allowed_types );
1393
 
1401
  }
1402
 
1403
  /**
1404
+ * Get allowed avatar mime types.
1405
  *
1406
+ * @since 2.3.0
1407
  */
1408
  function bp_core_get_allowed_avatar_mimes() {
1409
  $allowed_types = bp_core_get_allowed_avatar_types();
 
 
1410
 
1411
+ return bp_attachments_get_allowed_mimes( 'avatar', $allowed_types );
 
 
 
 
 
 
 
 
1412
  }
1413
 
1414
  /**
1417
  * Permitted file types are JPG, GIF and PNG.
1418
  *
1419
  * @param array $file The $_FILES array.
1420
+ *
1421
  * @return bool True if the file extension is permitted, otherwise false.
1422
  */
1423
  function bp_core_check_avatar_type( $file ) {
1424
+ return bp_attachments_check_filetype( $file['file']['tmp_name'], $file['file']['name'], bp_core_get_allowed_avatar_mimes() );
 
 
 
 
 
 
1425
  }
1426
 
1427
  /**
1428
  * Fetch data from the BP root blog's upload directory.
1429
  *
1430
+ * @since 1.8.0
1431
+ *
1432
+ * @param string $type The variable we want to return from the $bp->avatars object.
1433
+ * Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
1434
  *
 
 
1435
  * @return string The avatar upload directory path.
1436
  */
1437
  function bp_core_get_upload_dir( $type = 'upload_path' ) {
1456
  break;
1457
  }
1458
 
1459
+ // See if the value has already been calculated and stashed in the $bp global.
1460
  if ( isset( $bp->avatar->$type ) ) {
1461
  $retval = $bp->avatar->$type;
1462
  } else {
1463
+ // If this value has been set in a constant, just use that.
1464
  if ( defined( $constant ) ) {
1465
  $retval = constant( $constant );
1466
  } else {
1467
 
1468
+ // Use cached upload dir data if available.
1469
  if ( ! empty( $bp->avatar->upload_dir ) ) {
1470
  $upload_dir = $bp->avatar->upload_dir;
1471
 
1472
+ // No cache, so query for it.
1473
  } else {
1474
 
1475
+ // Get upload directory information from current site.
1476
  $upload_dir = bp_upload_dir();
1477
 
1478
+ // Stash upload directory data for later use.
1479
  $bp->avatar->upload_dir = $upload_dir;
1480
  }
1481
 
1482
+ // Directory does not exist and cannot be created.
1483
  if ( ! empty( $upload_dir['error'] ) ) {
1484
  $retval = '';
1485
 
1495
 
1496
  }
1497
 
1498
+ // Stash in $bp for later use.
1499
  $bp->avatar->$type = $retval;
1500
  }
1501
 
1505
  /**
1506
  * Get the absolute upload path for the WP installation.
1507
  *
1508
+ * @uses bp_core_get_upload_dir() To get upload directory info.
1509
  *
1510
  * @return string Absolute path to WP upload directory.
1511
  */
1514
  /**
1515
  * Filters the absolute upload path for the WP installation.
1516
  *
1517
+ * @since 1.2.0
1518
  *
1519
  * @param string $value Absolute upload path for the WP installation.
1520
  */
1533
  /**
1534
  * Filters the raw base URL for root site upload location.
1535
  *
1536
+ * @since 1.2.0
1537
  *
1538
  * @param string $value Raw base URL for the root site upload location.
1539
  */
1543
  /**
1544
  * Check if a given user ID has an uploaded avatar.
1545
  *
1546
+ * @since 1.0.0
1547
  *
1548
  * @param int $user_id ID of the user whose avatar is being checked.
1549
+ *
1550
  * @return bool True if the user has uploaded a local avatar. Otherwise false.
1551
  */
1552
  function bp_get_user_has_avatar( $user_id = 0 ) {
1561
  /**
1562
  * Filters whether or not a user has an uploaded avatar.
1563
  *
1564
+ * @since 1.6.0
1565
  *
1566
  * @param bool $retval Whether or not a user has an uploaded avatar.
1567
  * @param int $user_id ID of the user being checked.
1572
  /**
1573
  * Utility function for fetching an avatar dimension setting.
1574
  *
1575
+ * @since 1.5.0
1576
  *
1577
+ * @param string $type Dimension type you're fetching dimensions for. 'thumb'
1578
+ * or 'full'. Default: 'thumb'.
1579
  * @param string $h_or_w Which dimension is being fetched. 'height' or 'width'.
1580
+ * Default: 'height'.
1581
+ *
1582
+ * @return int|bool $dim The dimension.
1583
  */
1584
  function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
1585
  $bp = buddypress();
1588
  /**
1589
  * Filters the avatar dimension setting.
1590
  *
1591
+ * @since 1.5.0
1592
  *
1593
+ * @param int|bool $dim Dimension setting for the type.
1594
+ * @param string $type The type of avatar whose dimensions are requested. Default 'thumb'.
1595
+ * @param string $h_or_w The dimension parameter being requested. Default 'height'.
1596
  */
1597
  return apply_filters( 'bp_core_avatar_dimension', $dim, $type, $h_or_w );
1598
  }
1600
  /**
1601
  * Get the 'thumb' avatar width setting.
1602
  *
1603
+ * @since 1.5.0
1604
  *
1605
  * @return int The 'thumb' width.
1606
  */
1609
  /**
1610
  * Filters the 'thumb' avatar width setting.
1611
  *
1612
+ * @since 1.5.0
1613
  *
1614
  * @param int $value Value for the 'thumb' avatar width setting.
1615
  */
1619
  /**
1620
  * Get the 'thumb' avatar height setting.
1621
  *
1622
+ * @since 1.5.0
1623
  *
1624
  * @return int The 'thumb' height.
1625
  */
1628
  /**
1629
  * Filters the 'thumb' avatar height setting.
1630
  *
1631
+ * @since 1.5.0
1632
  *
1633
  * @param int $value Value for the 'thumb' avatar height setting.
1634
  */
1636
  }
1637
 
1638
  /**
1639
+ * Get the 'full' avatar width setting.
1640
  *
1641
+ * @since 1.5.0
1642
  *
1643
  * @return int The 'full' width.
1644
  */
1647
  /**
1648
  * Filters the 'full' avatar width setting.
1649
  *
1650
+ * @since 1.5.0
1651
  *
1652
  * @param int $value Value for the 'full' avatar width setting.
1653
  */
1657
  /**
1658
  * Get the 'full' avatar height setting.
1659
  *
1660
+ * @since 1.5.0
1661
  *
1662
  * @return int The 'full' height.
1663
  */
1666
  /**
1667
  * Filters the 'full' avatar height setting.
1668
  *
1669
+ * @since 1.5.0
1670
  *
1671
  * @param int $value Value for the 'full' avatar height setting.
1672
  */
1676
  /**
1677
  * Get the max width for original avatar uploads.
1678
  *
1679
+ * @since 1.5.0
1680
  *
1681
  * @return int The max width for original avatar uploads.
1682
  */
1685
  /**
1686
  * Filters the max width for original avatar uploads.
1687
  *
1688
+ * @since 1.5.0
1689
  *
1690
  * @param int $value Value for the max width.
1691
  */
1695
  /**
1696
  * Get the max filesize for original avatar uploads.
1697
  *
1698
+ * @since 1.5.0
1699
  *
1700
  * @return int The max filesize for original avatar uploads.
1701
  */
1704
  /**
1705
  * Filters the max filesize for original avatar uploads.
1706
  *
1707
+ * @since 1.5.0
1708
  *
1709
  * @param int $value Value for the max filesize.
1710
  */
1714
  /**
1715
  * Get the URL of the 'full' default avatar.
1716
  *
1717
+ * @since 1.5.0
1718
+ *
1719
+ * @param string $type 'local' if the fallback should be the locally-hosted version
1720
+ * of the mystery-person, 'gravatar' if the fallback should be
1721
+ * Gravatar's version. Default: 'gravatar'.
1722
  *
 
 
 
1723
  * @return string The URL of the default avatar.
1724
  */
1725
  function bp_core_avatar_default( $type = 'gravatar' ) {
1731
  } elseif ( 'local' === $type ) {
1732
  $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man.jpg';
1733
 
1734
+ // Use Gravatar's mystery person as fallback
1735
  } else {
1736
  $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_full_width();
1737
  }
1739
  /**
1740
  * Filters the URL of the 'full' default avatar.
1741
  *
1742
+ * @since 1.5.0
1743
  *
1744
  * @param string $avatar URL of the default avatar.
1745
  */
1749
  /**
1750
  * Get the URL of the 'thumb' default avatar.
1751
  *
1752
+ * Uses Gravatar's mystery-person avatar, unless BP_AVATAR_DEFAULT_THUMB has been
1753
  * defined.
1754
  *
1755
+ * @since 1.5.0
1756
+ *
1757
+ * @param string $type 'local' if the fallback should be the locally-hosted version
1758
+ * of the mystery-person, 'gravatar' if the fallback should be
1759
+ * Gravatar's version. Default: 'gravatar'.
1760
  *
 
 
 
1761
  * @return string The URL of the default avatar thumb.
1762
  */
1763
  function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
1769
  } elseif ( 'local' === $type ) {
1770
  $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man-50.jpg';
1771
 
1772
+ // Use Gravatar's mystery person as fallback
1773
  } else {
1774
  $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_thumb_width();
1775
  }
1777
  /**
1778
  * Filters the URL of the 'thumb' default avatar.
1779
  *
1780
+ * @since 1.5.0
1781
  *
1782
  * @param string $avatar URL of the default avatar.
1783
  */
1785
  }
1786
 
1787
  /**
1788
+ * Reset the week parameter of the WordPress main query if needed.
1789
  *
1790
  * When cropping an avatar, a $_POST['w'] var is sent, setting the 'week'
1791
  * parameter of the WordPress main query to this posted var. To avoid
1792
+ * notices, we need to make sure this 'week' query var is reset to 0.
1793
+ *
1794
+ * @since 2.2.0
1795
  *
1796
+ * @param WP_Query|null $posts_query the main query object.
1797
  *
 
1798
  * @uses bp_is_group_create()
1799
  * @uses bp_is_group_admin_page()
1800
  * @uses bp_is_group_admin_screen() to check for a group admin screen
1829
  add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );
1830
 
1831
  /**
1832
+ * Checks whether Avatar UI should be loaded.
1833
  *
1834
+ * @since 2.3.0
1835
  *
1836
+ * @return bool True if Avatar UI should load, false otherwise.
1837
  */
1838
  function bp_avatar_is_front_edit() {
1839
  $retval = false;
1863
  * - Load the avatar UI for a component that is !groups or !user (return true regarding your conditions)
1864
  * - Completely disable the avatar UI introduced in 2.3 (eg: __return_false())
1865
  *
1866
+ * @since 2.3.0
1867
  *
1868
+ * @param bool whether to load the Avatar UI.
1869
  */
1870
  return apply_filters( 'bp_avatar_is_front_edit', $retval );
1871
  }
1872
 
1873
  /**
1874
+ * Checks whether the Webcam Avatar UI part should be loaded.
1875
  *
1876
+ * @since 2.3.0
1877
  *
1878
  * @global $is_safari
1879
  * @global $is_IE
1903
  * Use this filter if you need to disable the webcam capture feature
1904
  * by returning false.
1905
  *
1906
+ * @since 2.3.0
1907
  *
1908
+ * @param bool whether to load Webcam Avatar UI part.
1909
  */
1910
  return apply_filters( 'bp_avatar_use_webcam', true );
1911
  }
1912
 
1913
  /**
1914
+ * Template function to load the Avatar UI javascript templates.
1915
  *
1916
+ * @since 2.3.0
1917
  */
1918
  function bp_avatar_get_templates() {
1919
  if ( ! bp_avatar_is_front_edit() ) {
1924
  }
1925
 
1926
  /**
1927
+ * Trick to check if the theme's BuddyPress templates are up to date.
1928
  *
1929
  * If the "avatar templates" are not including the new template tag, this will
1930
  * help users to get the avatar UI.
1931
  *
1932
+ * @since 2.3.0
1933
  */
1934
  function bp_avatar_template_check() {
1935
  if ( ! bp_avatar_is_front_edit() ) {
bp-core/bp-core-buddybar.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Core BuddyPress Navigational Functions.
5
  *
@@ -8,34 +7,95 @@
8
  * @todo Deprecate BuddyBar functions.
9
  */
10
 
11
- // Exit if accessed directly
12
  defined( 'ABSPATH' ) || exit;
13
 
14
  /**
15
  * Add an item to the main BuddyPress navigation array.
16
  *
17
- * @param array $args {
18
  * Array describing the new nav item.
19
- * @type string $name Display name for the nav item.
20
- * @type string $slug Unique URL slug for the nav item.
21
- * @type bool|string $item_css_id Optional. 'id' attribute for the nav
22
- * item. Default: the value of $slug.
23
- * @type bool $show_for_displayed_user Optional. Whether the nav item
24
- * should be visible when viewing a member profile other than your
25
- * own. Default: true.
26
- * @type bool $site_admin_only Optional. Whether the nav item should be
27
- * visible only to site admins (those with the 'bp_moderate' cap).
28
- * Default: false.
29
- * @type int $position Optional. Numerical index specifying where the item
30
- * should appear in the nav array. Default: 99.
31
- * @type callable $screen_function The callback function that will run
32
- * when the nav item is clicked.
33
- * @type bool|string $default_subnav_slug Optional. The slug of the default
34
- * subnav item to select when the nav item is clicked.
35
  * }
36
  * @return bool|null Returns false on failure.
37
  */
38
  function bp_core_new_nav_item( $args = '' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  $bp = buddypress();
40
 
41
  $defaults = array(
@@ -50,98 +110,173 @@ function bp_core_new_nav_item( $args = '' ) {
50
  );
51
 
52
  $r = wp_parse_args( $args, $defaults );
53
- extract( $r, EXTR_SKIP );
54
 
55
- // If we don't have the required info we need, don't create this subnav item
56
- if ( empty( $name ) || empty( $slug ) )
57
  return false;
 
58
 
59
- // If this is for site admins only and the user is not one, don't create the subnav item
60
- if ( !empty( $site_admin_only ) && !bp_current_user_can( 'bp_moderate' ) )
61
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
- if ( empty( $item_css_id ) )
64
- $item_css_id = $slug;
65
-
66
- $bp->bp_nav[$slug] = array(
67
- 'name' => $name,
68
- 'slug' => $slug,
69
- 'link' => trailingslashit( bp_loggedin_user_domain() . $slug ),
70
- 'css_id' => $item_css_id,
71
- 'show_for_displayed_user' => $show_for_displayed_user,
72
- 'position' => $position,
73
- 'screen_function' => &$screen_function,
74
- 'default_subnav_slug' => $default_subnav_slug
75
  );
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  /**
78
  * If this nav item is hidden for the displayed user, and
79
  * the logged in user is not the displayed user
80
- * looking at their own profile, don't create the nav item.
81
  */
82
- if ( empty( $show_for_displayed_user ) && !bp_user_has_access() )
83
  return false;
 
84
 
85
  /**
86
  * If the nav item is visible, we are not viewing a user, and this is a root
87
  * component, don't attach the default subnav function so we can display a
88
  * directory or something else.
89
  */
90
- if ( ( -1 != $position ) && bp_is_root_component( $slug ) && !bp_displayed_user_id() )
91
  return;
 
92
 
93
  // Look for current component
94
- if ( bp_is_current_component( $slug ) || bp_is_current_item( $slug ) ) {
95
 
96
  // The requested URL has explicitly included the default subnav
97
  // (eg: http://example.com/members/membername/activity/just-me/)
98
  // The canonical version will not contain this subnav slug.
99
- if ( !empty( $default_subnav_slug ) && bp_is_current_action( $default_subnav_slug ) && !bp_action_variable( 0 ) ) {
100
  unset( $bp->canonical_stack['action'] );
101
  } elseif ( ! bp_current_action() ) {
102
 
103
  // Add our screen hook if screen function is callable
104
- if ( is_callable( $screen_function ) ) {
105
- add_action( 'bp_screens', $screen_function, 3 );
106
  }
107
 
108
- if ( !empty( $default_subnav_slug ) ) {
109
 
110
  /**
111
  * Filters the default component subnav item.
112
  *
113
- * @since BuddyPress (1.5.0)
114
  *
115
- * @param string $default_subnav_slug The slug of the default subnav item
116
- * to select when clicked.
117
- * @param array $r Parsed arguments for the nav item.
118
  */
119
- $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
120
  }
121
  }
122
  }
123
 
124
  /**
125
- * Fires after adding an item to the main BuddyPress navigation array.
 
126
  *
127
- * @since BuddyPress (1.5.0)
128
  *
129
  * @param array $r Parsed arguments for the nav item.
130
  * @param array $args Originally passed in arguments for the nav item.
131
  * @param array $defaults Default arguments for a nav item.
132
  */
133
- do_action( 'bp_core_new_nav_item', $r, $args, $defaults );
134
  }
135
 
136
  /**
137
  * Modify the default subnav item that loads when a top level nav item is clicked.
138
  *
139
- * @param array $args {
140
- * @type string $parent_slug The slug of the nav item whose default is
141
- * being changed.
142
- * @type callable $screen_function The new default callback function that
143
- * will run when the nav item is clicked.
144
- * @type string $subnav_slug The slug of the new default subnav item.
145
  * }
146
  */
147
  function bp_core_new_nav_default( $args = '' ) {
@@ -154,43 +289,42 @@ function bp_core_new_nav_default( $args = '' ) {
154
  );
155
 
156
  $r = wp_parse_args( $args, $defaults );
157
- extract( $r, EXTR_SKIP );
158
 
159
- if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) {
160
  // Remove our screen hook if screen function is callable
161
  if ( is_callable( $function ) ) {
162
  remove_action( 'bp_screens', $function, 3 );
163
  }
164
  }
165
 
166
- $bp->bp_nav[$parent_slug]['screen_function'] = &$screen_function;
167
 
168
- if ( bp_is_current_component( $parent_slug ) ) {
169
 
170
  // The only way to tell whether to set the subnav is to peek at the unfiltered_uri
171
  // Find the component
172
- $component_uri_key = array_search( $parent_slug, $bp->unfiltered_uri );
173
 
174
  if ( false !== $component_uri_key ) {
175
- if ( !empty( $bp->unfiltered_uri[$component_uri_key + 1] ) ) {
176
  $unfiltered_action = $bp->unfiltered_uri[$component_uri_key + 1];
177
  }
178
  }
179
 
180
  // No subnav item has been requested in the URL, so set a new nav default
181
  if ( empty( $unfiltered_action ) ) {
182
- if ( !bp_is_current_action( $subnav_slug ) ) {
183
- if ( is_callable( $screen_function ) ) {
184
- add_action( 'bp_screens', $screen_function, 3 );
185
  }
186
 
187
- $bp->current_action = $subnav_slug;
188
  unset( $bp->canonical_stack['action'] );
189
  }
190
 
191
  // The URL is explicitly requesting the new subnav item, but should be
192
  // directed to the canonical URL
193
- } elseif ( $unfiltered_action == $subnav_slug ) {
194
  unset( $bp->canonical_stack['action'] );
195
 
196
  // In all other cases (including the case where the original subnav item
@@ -215,19 +349,20 @@ function bp_core_new_nav_default( $args = '' ) {
215
  function bp_core_sort_nav_items() {
216
  $bp = buddypress();
217
 
218
- if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
219
  return false;
 
220
 
221
  $temp = array();
222
 
223
  foreach ( (array) $bp->bp_nav as $slug => $nav_item ) {
224
- if ( empty( $temp[$nav_item['position']]) ) {
225
  $temp[$nav_item['position']] = $nav_item;
226
  } else {
227
  // increase numbers here to fit new items in.
228
  do {
229
  $nav_item['position']++;
230
- } while ( !empty( $temp[$nav_item['position']] ) );
231
 
232
  $temp[$nav_item['position']] = $nav_item;
233
  }
@@ -242,35 +377,80 @@ add_action( 'admin_head', 'bp_core_sort_nav_items' );
242
  /**
243
  * Add a subnav item to the BuddyPress navigation.
244
  *
245
- * @param array $args {
246
  * Array describing the new subnav item.
247
- * @type string $name Display name for the subnav item.
248
- * @type string $slug Unique URL slug for the subnav item.
249
- * @type string $parent_slug Slug of the top-level nav item under which the
250
- * new subnav item should be added.
251
- * @type string $parent_url URL of the parent nav item.
252
- * @type bool|string $item_css_id Optional. 'id' attribute for the nav
253
- * item. Default: the value of $slug.
254
- * @type bool $user_has_access Optional. True if the logged-in user has
255
- * access to the subnav item, otherwise false. Can be set dynamically
256
- * when registering the subnav; eg, use bp_is_my_profile() to restrict
257
- * access to profile owners only. Default: true.
258
- * @type bool $site_admin_only Optional. Whether the nav item should be
259
- * visible only to site admins (those with the 'bp_moderate' cap).
260
- * Default: false.
261
- * @type int $position Optional. Numerical index specifying where the item
262
- * should appear in the subnav array. Default: 90.
263
- * @type callable $screen_function The callback function that will run
264
- * when the nav item is clicked.
265
- * @type string $link Optional. The URL that the subnav item should point
266
- * to. Defaults to a value generated from the $parent_url + $slug.
267
- * @type bool $show_in_admin_bar Optional. Whether the nav item should be
268
- * added into the group's "Edit" Admin Bar menu for group admins.
269
- * Default: false.
270
  * }
271
  * @return bool|null Returns false on failure.
272
  */
273
  function bp_core_new_subnav_item( $args = '' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  $bp = buddypress();
275
 
276
  $r = wp_parse_args( $args, array(
@@ -288,48 +468,90 @@ function bp_core_new_subnav_item( $args = '' ) {
288
  'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu
289
  ) );
290
 
291
- extract( $r, EXTR_SKIP );
292
-
293
  // If we don't have the required info we need, don't create this subnav item
294
- if ( empty( $name ) || empty( $slug ) || empty( $parent_slug ) || empty( $parent_url ) || empty( $screen_function ) )
295
  return false;
296
 
297
  // Link was not forced, so create one
298
- if ( empty( $link ) ) {
299
- $link = trailingslashit( $parent_url . $slug );
300
 
301
  // If this sub item is the default for its parent, skip the slug
302
- if ( ! empty( $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) && $slug == $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) {
303
- $link = trailingslashit( $parent_url );
304
  }
305
  }
306
 
307
  // If this is for site admins only and the user is not one, don't create the subnav item
308
- if ( !empty( $site_admin_only ) && !bp_current_user_can( 'bp_moderate' ) )
309
  return false;
 
310
 
311
- if ( empty( $item_css_id ) )
312
- $item_css_id = $slug;
 
313
 
314
  $subnav_item = array(
315
- 'name' => $name,
316
- 'link' => $link,
317
- 'slug' => $slug,
318
- 'css_id' => $item_css_id,
319
- 'position' => $position,
320
- 'user_has_access' => $user_has_access,
321
- 'no_access_url' => $no_access_url,
322
- 'screen_function' => &$screen_function,
323
  'show_in_admin_bar' => (bool) $r['show_in_admin_bar'],
324
  );
325
 
326
- $bp->bp_options_nav[$parent_slug][$slug] = $subnav_item;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
 
328
  /**
329
- * The last step is to hook the screen function for the added subnav item. But this only
330
- * needs to be done if this subnav item is the current view, and the user has access to the
331
- * subnav item. We figure out whether we're currently viewing this subnav by checking the
332
- * following two conditions:
333
  * (1) Either:
334
  * (a) the parent slug matches the current_component, or
335
  * (b) the parent slug matches the current_item
@@ -343,13 +565,19 @@ function bp_core_new_subnav_item( $args = '' ) {
343
  */
344
 
345
  // If we *don't* meet condition (1), return
346
- if ( ! bp_is_current_component( $parent_slug ) && ! bp_is_current_item( $parent_slug ) )
347
  return;
 
348
 
349
  // If we *do* meet condition (2), then the added subnav item is currently being requested
350
- if ( ( bp_current_action() && bp_is_current_action( $slug ) ) || ( bp_is_user() && ! bp_current_action() && ( $screen_function == $bp->bp_nav[$parent_slug]['screen_function'] ) ) ) {
351
 
352
- $hooked = bp_core_maybe_hook_new_subnav_screen_function( $subnav_item );
 
 
 
 
 
353
 
354
  // If redirect args have been returned, perform the redirect now
355
  if ( ! empty( $hooked['status'] ) && 'failure' === $hooked['status'] && isset( $hooked['redirect_args'] ) ) {
@@ -361,10 +589,10 @@ function bp_core_new_subnav_item( $args = '' ) {
361
  /**
362
  * For a given subnav item, either hook the screen function or generate redirect arguments, as necessary.
363
  *
364
- * @since BuddyPress (2.1.0)
 
 
365
  *
366
- * @param array $subnav_item The subnav array added to bp_options_nav in
367
- * bp_core_new_subnav_item().
368
  * @return array
369
  */
370
  function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) {
@@ -372,8 +600,14 @@ function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) {
372
  'status' => '',
373
  );
374
 
 
 
 
 
 
 
375
  // User has access, so let's try to hook the display callback
376
- if ( ! empty( $subnav_item['user_has_access'] ) ) {
377
 
378
  // Screen function is invalid
379
  if ( ! is_callable( $subnav_item['screen_function'] ) ) {
@@ -487,12 +721,12 @@ add_action( 'admin_head', 'bp_core_sort_subnav_items' );
487
  /**
488
  * Check whether a given nav item has subnav items.
489
  *
490
- * @since BuddyPress (1.5.0)
 
 
 
491
  *
492
- * @param string $nav_item The slug of the top-level nav item whose subnav
493
- * items you're checking. Default: the current component slug.
494
- * @return bool $has_subnav True if the nav item is found and has subnav
495
- * items; false otherwise.
496
  */
497
  function bp_nav_item_has_subnav( $nav_item = '' ) {
498
  $bp = buddypress();
@@ -505,11 +739,10 @@ function bp_nav_item_has_subnav( $nav_item = '' ) {
505
  /**
506
  * Filters whether or not a given nav item has subnav items.
507
  *
508
- * @since BuddyPress (1.5.0)
509
  *
510
  * @param bool $has_subnav Whether or not there is any subnav items.
511
- * @param string $nav_item The slug of the top-level nav item whose subnav
512
- * items you're checking.
513
  */
514
  return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item );
515
  }
@@ -518,7 +751,8 @@ function bp_nav_item_has_subnav( $nav_item = '' ) {
518
  * Remove a nav item from the navigation array.
519
  *
520
  * @param int $parent_id The slug of the parent navigation item.
521
- * @param bool Returns false on failure, ie if the nav item can't be found.
 
522
  */
523
  function bp_core_remove_nav_item( $parent_id ) {
524
  $bp = buddypress();
@@ -547,7 +781,7 @@ function bp_core_remove_nav_item( $parent_id ) {
547
  * Remove a subnav item from the navigation array.
548
  *
549
  * @param string $parent_id The slug of the parent navigation item.
550
- * @param string $slug The slug of the subnav item to be removed.
551
  */
552
  function bp_core_remove_subnav_item( $parent_id, $slug ) {
553
  $bp = buddypress();
@@ -586,13 +820,13 @@ function bp_core_reset_subnav_items( $parent_slug ) {
586
  *
587
  * This is a direct copy of WP's private _get_admin_bar_pref()
588
  *
589
- * @since BuddyPress (1.5.0)
590
  *
591
  * @uses get_user_option()
592
  *
593
  * @param string $context Context of this preference check. 'admin' or 'front'.
594
- * @param int $user Optional. ID of the user to check. Default: 0 (which falls
595
- * back to the logged-in user's ID).
596
  * @return bool True if the toolbar should be showing for this user.
597
  */
598
  function bp_get_admin_bar_pref( $context, $user = 0 ) {
1
  <?php
 
2
  /**
3
  * Core BuddyPress Navigational Functions.
4
  *
7
  * @todo Deprecate BuddyBar functions.
8
  */
9
 
10
+ // Exit if accessed directly.
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Add an item to the main BuddyPress navigation array.
15
  *
16
+ * @param array|string $args {
17
  * Array describing the new nav item.
18
+ * @type string $name Display name for the nav item.
19
+ * @type string $slug Unique URL slug for the nav item.
20
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
21
+ * @type bool $show_for_displayed_user Optional. Whether the nav item should be visible when viewing a
22
+ * member profile other than your own. Default: true.
23
+ * @type bool $site_admin_only Optional. Whether the nav item should be visible only to site admins
24
+ * (those with the 'bp_moderate' cap). Default: false.
25
+ * @type int $position Optional. Numerical index specifying where the item should appear in
26
+ * the nav array. Default: 99.
27
+ * @type callable $screen_function The callback function that will run when the nav item is clicked.
28
+ * @type bool|string $default_subnav_slug Optional. The slug of the default subnav item to select when the nav
29
+ * item is clicked.
 
 
 
 
30
  * }
31
  * @return bool|null Returns false on failure.
32
  */
33
  function bp_core_new_nav_item( $args = '' ) {
34
+
35
+ $defaults = array(
36
+ 'name' => false, // Display name for the nav item
37
+ 'slug' => false, // URL slug for the nav item
38
+ 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
39
+ 'show_for_displayed_user' => true, // When viewing another user does this nav item show up?
40
+ 'site_admin_only' => false, // Can only site admins see this nav item?
41
+ 'position' => 99, // Index of where this nav item should be positioned
42
+ 'screen_function' => false, // The name of the function to run when clicked
43
+ 'default_subnav_slug' => false // The slug of the default subnav item to select when clicked
44
+ );
45
+
46
+ $r = wp_parse_args( $args, $defaults );
47
+
48
+ // First, add the nav item link to the bp_nav array.
49
+ $created = bp_core_create_nav_link( $r );
50
+
51
+ // To mimic the existing behavior, if bp_core_create_nav_link()
52
+ // returns false, we make an early exit and don't attempt to register
53
+ // the screen function.
54
+ if ( false === $created ) {
55
+ return false;
56
+ }
57
+
58
+ // Then, hook the screen function for the added nav item.
59
+ bp_core_register_nav_screen_function( $r );
60
+
61
+ /**
62
+ * Fires after adding an item to the main BuddyPress navigation array.
63
+ * Note that, when possible, the more specific action hooks
64
+ * `bp_core_create_nav_link` or `bp_core_register_nav_screen_function`
65
+ * should be used.
66
+ *
67
+ * @since 1.5.0
68
+ *
69
+ * @param array $r Parsed arguments for the nav item.
70
+ * @param array $args Originally passed in arguments for the nav item.
71
+ * @param array $defaults Default arguments for a nav item.
72
+ */
73
+ do_action( 'bp_core_new_nav_item', $r, $args, $defaults );
74
+ }
75
+
76
+ /**
77
+ * Add a link to the main BuddyPress navigation array.
78
+ *
79
+ * @since 2.4.0
80
+ *
81
+ * @param array|string $args {
82
+ * Array describing the new nav item.
83
+ * @type string $name Display name for the nav item.
84
+ * @type string $slug Unique URL slug for the nav item.
85
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
86
+ * @type bool $show_for_displayed_user Optional. Whether the nav item should be visible when viewing a
87
+ * member profile other than your own. Default: true.
88
+ * @type bool $site_admin_only Optional. Whether the nav item should be visible only to site admins
89
+ * (those with the 'bp_moderate' cap). Default: false.
90
+ * @type int $position Optional. Numerical index specifying where the item should appear in
91
+ * the nav array. Default: 99.
92
+ * @type callable $screen_function The callback function that will run when the nav item is clicked.
93
+ * @type bool|string $default_subnav_slug Optional. The slug of the default subnav item to select when the nav
94
+ * item is clicked.
95
+ * }
96
+ * @return bool|null Returns false on failure.
97
+ */
98
+ function bp_core_create_nav_link( $args = '' ) {
99
  $bp = buddypress();
100
 
101
  $defaults = array(
110
  );
111
 
112
  $r = wp_parse_args( $args, $defaults );
 
113
 
114
+ // If we don't have the required info we need, don't create this nav item.
115
+ if ( empty( $r['name'] ) || empty( $r['slug'] ) ) {
116
  return false;
117
+ }
118
 
119
+ // If this is for site admins only and the user is not one, don't create the nav item.
120
+ if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
121
  return false;
122
+ }
123
+
124
+ /**
125
+ * If this nav item is hidden for the displayed user, and
126
+ * the logged in user is not the displayed user
127
+ * looking at their own profile, don't create the nav item.
128
+ */
129
+ if ( empty( $r['show_for_displayed_user'] ) && ! bp_user_has_access() ) {
130
+ return false;
131
+ }
132
+
133
+ if ( empty( $r['item_css_id'] ) ) {
134
+ $r['item_css_id'] = $r['slug'];
135
+ }
136
+
137
+ $bp->bp_nav[$r['slug']] = array(
138
+ 'name' => $r['name'],
139
+ 'slug' => $r['slug'],
140
+ 'link' => trailingslashit( bp_loggedin_user_domain() . $r['slug'] ),
141
+ 'css_id' => $r['item_css_id'],
142
+ 'show_for_displayed_user' => $r['show_for_displayed_user'],
143
+ 'position' => $r['position'],
144
+ 'screen_function' => &$r['screen_function'],
145
+ 'default_subnav_slug' => $r['default_subnav_slug']
146
+ );
147
+
148
+ /**
149
+ * Fires after a link is added to the main BuddyPress navigation array.
150
+ *
151
+ * @since 2.4.0
152
+ *
153
+ * @param array $r Parsed arguments for the nav item.
154
+ * @param array $args Originally passed in arguments for the nav item.
155
+ * @param array $defaults Default arguments for a nav item.
156
+ */
157
+ do_action( 'bp_core_create_nav_link', $r, $args, $defaults );
158
+ }
159
+
160
+ /**
161
+ * Register a screen function for an item in the main nav array.
162
+ *
163
+ * @since 2.4.0
164
+ *
165
+ * @param array|string $args {
166
+ * Array describing the new nav item.
167
+ * @type string $name Display name for the nav item.
168
+ * @type string $slug Unique URL slug for the nav item.
169
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
170
+ * @type bool $show_for_displayed_user Optional. Whether the nav item should be visible when viewing a
171
+ * member profile other than your own. Default: true.
172
+ * @type bool $site_admin_only Optional. Whether the nav item should be visible only to site admins
173
+ * (those with the 'bp_moderate' cap). Default: false.
174
+ * @type int $position Optional. Numerical index specifying where the item should appear in
175
+ * the nav array. Default: 99.
176
+ * @type callable $screen_function The callback function that will run when the nav item is clicked.
177
+ * @type bool|string $default_subnav_slug Optional. The slug of the default subnav item to select when the nav
178
+ * item is clicked.
179
+ * }
180
+ * @return bool|null Returns false on failure.
181
+ */
182
+ function bp_core_register_nav_screen_function( $args = '' ) {
183
+ $bp = buddypress();
184
 
185
+ $defaults = array(
186
+ 'name' => false, // Display name for the nav item
187
+ 'slug' => false, // URL slug for the nav item
188
+ 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
189
+ 'show_for_displayed_user' => true, // When viewing another user does this nav item show up?
190
+ 'site_admin_only' => false, // Can only site admins see this nav item?
191
+ 'position' => 99, // Index of where this nav item should be positioned
192
+ 'screen_function' => false, // The name of the function to run when clicked
193
+ 'default_subnav_slug' => false // The slug of the default subnav item to select when clicked
 
 
 
194
  );
195
 
196
+ $r = wp_parse_args( $args, $defaults );
197
+
198
+ // If we don't have the required info we need, don't register this screen function.
199
+ if ( empty( $r['slug'] ) ) {
200
+ return false;
201
+ }
202
+
203
+ /**
204
+ * If this is for site admins only and the user is not one,
205
+ * don't register this screen function.
206
+ */
207
+ if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
208
+ return false;
209
+ }
210
+
211
  /**
212
  * If this nav item is hidden for the displayed user, and
213
  * the logged in user is not the displayed user
214
+ * looking at their own profile, don't don't register this screen function.
215
  */
216
+ if ( empty( $r['show_for_displayed_user'] ) && ! bp_user_has_access() ) {
217
  return false;
218
+ }
219
 
220
  /**
221
  * If the nav item is visible, we are not viewing a user, and this is a root
222
  * component, don't attach the default subnav function so we can display a
223
  * directory or something else.
224
  */
225
+ if ( ( -1 != $r['position'] ) && bp_is_root_component( $r['slug'] ) && ! bp_displayed_user_id() ) {
226
  return;
227
+ }
228
 
229
  // Look for current component
230
+ if ( bp_is_current_component( $r['slug'] ) || bp_is_current_item( $r['slug'] ) ) {
231
 
232
  // The requested URL has explicitly included the default subnav
233
  // (eg: http://example.com/members/membername/activity/just-me/)
234
  // The canonical version will not contain this subnav slug.
235
+ if ( ! empty( $r['default_subnav_slug'] ) && bp_is_current_action( $r['default_subnav_slug'] ) && ! bp_action_variable( 0 ) ) {
236
  unset( $bp->canonical_stack['action'] );
237
  } elseif ( ! bp_current_action() ) {
238
 
239
  // Add our screen hook if screen function is callable
240
+ if ( is_callable( $r['screen_function'] ) ) {
241
+ add_action( 'bp_screens', $r['screen_function'], 3 );
242
  }
243
 
244
+ if ( ! empty( $r['default_subnav_slug'] ) ) {
245
 
246
  /**
247
  * Filters the default component subnav item.
248
  *
249
+ * @since 1.5.0
250
  *
251
+ * @param string $value The slug of the default subnav item
252
+ * to select when clicked.
253
+ * @param array $r Parsed arguments for the nav item.
254
  */
255
+ $bp->current_action = apply_filters( 'bp_default_component_subnav', $r['default_subnav_slug'], $r );
256
  }
257
  }
258
  }
259
 
260
  /**
261
+ * Fires after the screen function for an item in the BuddyPress main
262
+ * navigation is registered.
263
  *
264
+ * @since 2.4.0
265
  *
266
  * @param array $r Parsed arguments for the nav item.
267
  * @param array $args Originally passed in arguments for the nav item.
268
  * @param array $defaults Default arguments for a nav item.
269
  */
270
+ do_action( 'bp_core_register_nav_screen_function', $r, $args, $defaults );
271
  }
272
 
273
  /**
274
  * Modify the default subnav item that loads when a top level nav item is clicked.
275
  *
276
+ * @param array|string $args {
277
+ * @type string $parent_slug The slug of the nav item whose default is being changed.
278
+ * @type callable $screen_function The new default callback function that will run when the nav item is clicked.
279
+ * @type string $subnav_slug The slug of the new default subnav item.
 
 
280
  * }
281
  */
282
  function bp_core_new_nav_default( $args = '' ) {
289
  );
290
 
291
  $r = wp_parse_args( $args, $defaults );
 
292
 
293
+ if ( $function = $bp->bp_nav[$r['parent_slug']]['screen_function'] ) {
294
  // Remove our screen hook if screen function is callable
295
  if ( is_callable( $function ) ) {
296
  remove_action( 'bp_screens', $function, 3 );
297
  }
298
  }
299
 
300
+ $bp->bp_nav[$r['parent_slug']]['screen_function'] = &$r['screen_function'];
301
 
302
+ if ( bp_is_current_component( $r['parent_slug'] ) ) {
303
 
304
  // The only way to tell whether to set the subnav is to peek at the unfiltered_uri
305
  // Find the component
306
+ $component_uri_key = array_search( $r['parent_slug'], $bp->unfiltered_uri );
307
 
308
  if ( false !== $component_uri_key ) {
309
+ if ( ! empty( $bp->unfiltered_uri[$component_uri_key + 1] ) ) {
310
  $unfiltered_action = $bp->unfiltered_uri[$component_uri_key + 1];
311
  }
312
  }
313
 
314
  // No subnav item has been requested in the URL, so set a new nav default
315
  if ( empty( $unfiltered_action ) ) {
316
+ if ( ! bp_is_current_action( $r['subnav_slug'] ) ) {
317
+ if ( is_callable( $r['screen_function'] ) ) {
318
+ add_action( 'bp_screens', $r['screen_function'], 3 );
319
  }
320
 
321
+ $bp->current_action = $r['subnav_slug'];
322
  unset( $bp->canonical_stack['action'] );
323
  }
324
 
325
  // The URL is explicitly requesting the new subnav item, but should be
326
  // directed to the canonical URL
327
+ } elseif ( $unfiltered_action == $r['subnav_slug'] ) {
328
  unset( $bp->canonical_stack['action'] );
329
 
330
  // In all other cases (including the case where the original subnav item
349
  function bp_core_sort_nav_items() {
350
  $bp = buddypress();
351
 
352
+ if ( empty( $bp->bp_nav ) || ! is_array( $bp->bp_nav ) ) {
353
  return false;
354
+ }
355
 
356
  $temp = array();
357
 
358
  foreach ( (array) $bp->bp_nav as $slug => $nav_item ) {
359
+ if ( empty( $temp[$nav_item['position']] ) ) {
360
  $temp[$nav_item['position']] = $nav_item;
361
  } else {
362
  // increase numbers here to fit new items in.
363
  do {
364
  $nav_item['position']++;
365
+ } while ( ! empty( $temp[$nav_item['position']] ) );
366
 
367
  $temp[$nav_item['position']] = $nav_item;
368
  }
377
  /**
378
  * Add a subnav item to the BuddyPress navigation.
379
  *
380
+ * @param array|string $args {
381
  * Array describing the new subnav item.
382
+ * @type string $name Display name for the subnav item.
383
+ * @type string $slug Unique URL slug for the subnav item.
384
+ * @type string $parent_slug Slug of the top-level nav item under which the new subnav item should
385
+ * be added.
386
+ * @type string $parent_url URL of the parent nav item.
387
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
388
+ * @type bool $user_has_access Optional. True if the logged-in user has access to the subnav item,
389
+ * otherwise false. Can be set dynamically when registering the subnav;
390
+ * eg, use `bp_is_my_profile()` to restrict access to profile owners only.
391
+ * Default: true.
392
+ * @type bool $site_admin_only Optional. Whether the nav item should be visible only to site admins
393
+ * (those with the 'bp_moderate' cap). Default: false.
394
+ * @type int $position Optional. Numerical index specifying where the item should appear in the
395
+ * subnav array. Default: 90.
396
+ * @type callable $screen_function The callback function that will run when the nav item is clicked.
397
+ * @type string $link Optional. The URL that the subnav item should point to. Defaults to a value
398
+ * generated from the `$parent_url` + `$slug`.
399
+ * @type bool $show_in_admin_bar Optional. Whether the nav item should be added into the group's "Edit"
400
+ * Admin Bar menu for group admins. Default: false.
 
 
 
 
401
  * }
402
  * @return bool|null Returns false on failure.
403
  */
404
  function bp_core_new_subnav_item( $args = '' ) {
405
+
406
+ // First, add the subnav item link to the bp_options_nav array.
407
+ $created = bp_core_create_subnav_link( $args );
408
+
409
+ // To mimic the existing behavior, if bp_core_create_subnav_link()
410
+ // returns false, we make an early exit and don't attempt to register
411
+ // the screen function.
412
+ if ( false === $created ) {
413
+ return false;
414
+ }
415
+
416
+ // Then, hook the screen function for the added subnav item.
417
+ bp_core_register_subnav_screen_function( $args );
418
+
419
+ }
420
+
421
+ /**
422
+ * Add a subnav link to the BuddyPress navigation.
423
+ *
424
+ * @param array|string $args {
425
+ * Array describing the new subnav item.
426
+ * @type string $name Display name for the subnav item.
427
+ * @type string $slug Unique URL slug for the subnav item.
428
+ * @type string $parent_slug Slug of the top-level nav item under which the
429
+ * new subnav item should be added.
430
+ * @type string $parent_url URL of the parent nav item.
431
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav
432
+ * item. Default: the value of $slug.
433
+ * @type bool $user_has_access Optional. True if the logged-in user has access to the
434
+ * subnav item, otherwise false. Can be set dynamically
435
+ * when registering the subnav; eg, use bp_is_my_profile()
436
+ * to restrict access to profile owners only. Default: true.
437
+ * @type bool $site_admin_only Optional. Whether the nav item should be visible only
438
+ * to site admins (those with the 'bp_moderate' cap).
439
+ * Default: false.
440
+ * @type int $position Optional. Numerical index specifying where the item
441
+ * should appear in the subnav array. Default: 90.
442
+ * @type callable $screen_function The callback function that will run
443
+ * when the nav item is clicked.
444
+ * @type string $link Optional. The URL that the subnav item should point
445
+ * to. Defaults to a value generated from the $parent_url + $slug.
446
+ * @type bool $show_in_admin_bar Optional. Whether the nav item should be added into
447
+ * the group's "Edit" Admin Bar menu for group admins.
448
+ * Default: false.
449
+ * }
450
+ *
451
+ * @return bool|null Returns false on failure.
452
+ */
453
+ function bp_core_create_subnav_link( $args = '' ) {
454
  $bp = buddypress();
455
 
456
  $r = wp_parse_args( $args, array(
468
  'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu
469
  ) );
470
 
 
 
471
  // If we don't have the required info we need, don't create this subnav item
472
+ if ( empty( $r['name'] ) || empty( $r['slug'] ) || empty( $r['parent_slug'] ) || empty( $r['parent_url'] ) || empty( $r['screen_function'] ) )
473
  return false;
474
 
475
  // Link was not forced, so create one
476
+ if ( empty( $r['link'] ) ) {
477
+ $r['link'] = trailingslashit( $r['parent_url'] . $r['slug'] );
478
 
479
  // If this sub item is the default for its parent, skip the slug
480
+ if ( ! empty( $bp->bp_nav[$r['parent_slug']]['default_subnav_slug'] ) && $r['slug'] == $bp->bp_nav[$r['parent_slug']]['default_subnav_slug'] ) {
481
+ $r['link'] = trailingslashit( $r['parent_url'] );
482
  }
483
  }
484
 
485
  // If this is for site admins only and the user is not one, don't create the subnav item
486
+ if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
487
  return false;
488
+ }
489
 
490
+ if ( empty( $r['item_css_id'] ) ) {
491
+ $r['item_css_id'] = $r['slug'];
492
+ }
493
 
494
  $subnav_item = array(
495
+ 'name' => $r['name'],
496
+ 'link' => $r['link'],
497
+ 'slug' => $r['slug'],
498
+ 'css_id' => $r['item_css_id'],
499
+ 'position' => $r['position'],
500
+ 'user_has_access' => $r['user_has_access'],
501
+ 'no_access_url' => $r['no_access_url'],
502
+ 'screen_function' => &$r['screen_function'],
503
  'show_in_admin_bar' => (bool) $r['show_in_admin_bar'],
504
  );
505
 
506
+ $bp->bp_options_nav[$r['parent_slug']][$r['slug']] = $subnav_item;
507
+ }
508
+
509
+ /**
510
+ * Register a screen function, whether or not a related subnav link exists.
511
+ *
512
+ * @param array|string $args {
513
+ * Array describing the new subnav item.
514
+ * @type string $slug Unique URL slug for the subnav item.
515
+ * @type string $parent_slug Slug of the top-level nav item under which the
516
+ * new subnav item should be added.
517
+ * @type string $parent_url URL of the parent nav item.
518
+ * @type bool $user_has_access Optional. True if the logged-in user has access to the
519
+ * subnav item, otherwise false. Can be set dynamically
520
+ * when registering the subnav; eg, use bp_is_my_profile()
521
+ * to restrict access to profile owners only. Default: true.
522
+ * @type bool $site_admin_only Optional. Whether the nav item should be visible
523
+ * only to site admins (those with the 'bp_moderate' cap).
524
+ * Default: false.
525
+ * @type int $position Optional. Numerical index specifying where the item
526
+ * should appear in the subnav array. Default: 90.
527
+ * @type callable $screen_function The callback function that will run
528
+ * when the nav item is clicked.
529
+ * @type string $link Optional. The URL that the subnav item should point to.
530
+ * Defaults to a value generated from the $parent_url + $slug.
531
+ * @type bool $show_in_admin_bar Optional. Whether the nav item should be added into
532
+ * the group's "Edit" Admin Bar menu for group admins.
533
+ * Default: false.
534
+ * }
535
+ *
536
+ * @return bool|null Returns false on failure.
537
+ */
538
+ function bp_core_register_subnav_screen_function( $args = '' ) {
539
+ $bp = buddypress();
540
+
541
+ $r = wp_parse_args( $args, array(
542
+ 'slug' => false, // URL slug for the screen
543
+ 'parent_slug' => false, // URL slug of the parent screen
544
+ 'user_has_access' => true, // Can the user visit this screen?
545
+ 'no_access_url' => '',
546
+ 'site_admin_only' => false, // Can only site admins visit this screen?
547
+ 'screen_function' => false, // The name of the function to run when clicked
548
+ ) );
549
 
550
  /**
551
+ * Hook the screen function for the added subnav item. But this only needs to
552
+ * be done if this subnav item is the current view, and the user has access to the
553
+ * subnav item. We figure out whether we're currently viewing this subnav by
554
+ * checking the following two conditions:
555
  * (1) Either:
556
  * (a) the parent slug matches the current_component, or
557
  * (b) the parent slug matches the current_item
565
  */
566
 
567
  // If we *don't* meet condition (1), return
568
+ if ( ! bp_is_current_component( $r['parent_slug'] ) && ! bp_is_current_item( $r['parent_slug'] ) ) {
569
  return;
570
+ }
571
 
572
  // If we *do* meet condition (2), then the added subnav item is currently being requested
573
+ if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ( $r['screen_function'] == $bp->bp_nav[$r['parent_slug']]['screen_function'] ) ) ) {
574
 
575
+ // If this is for site admins only and the user is not one, don't create the subnav item
576
+ if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
577
+ return false;
578
+ }
579
+
580
+ $hooked = bp_core_maybe_hook_new_subnav_screen_function( $r );
581
 
582
  // If redirect args have been returned, perform the redirect now
583
  if ( ! empty( $hooked['status'] ) && 'failure' === $hooked['status'] && isset( $hooked['redirect_args'] ) ) {
589
  /**
590
  * For a given subnav item, either hook the screen function or generate redirect arguments, as necessary.
591
  *
592
+ * @since 2.1.0
593
+ *
594
+ * @param array $subnav_item The subnav array added to bp_options_nav in `bp_core_new_subnav_item()`.
595
  *
 
 
596
  * @return array
597
  */
598
  function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) {
600
  'status' => '',
601
  );
602
 
603
+ // Is this accessible by site admins only?
604
+ $site_admin_restricted = false;
605
+ if ( ! empty( $subnav_item['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
606
+ $site_admin_restricted = true;
607
+ }
608
+
609
  // User has access, so let's try to hook the display callback
610
+ if ( ! empty( $subnav_item['user_has_access'] ) && ! $site_admin_restricted ) {
611
 
612
  // Screen function is invalid
613
  if ( ! is_callable( $subnav_item['screen_function'] ) ) {
721
  /**
722
  * Check whether a given nav item has subnav items.
723
  *
724
+ * @since 1.5.0
725
+ *
726
+ * @param string $nav_item The slug of the top-level nav item whose subnav items you're checking.
727
+ * Default: the current component slug.
728
  *
729
+ * @return bool $has_subnav True if the nav item is found and has subnav items; false otherwise.
 
 
 
730
  */
731
  function bp_nav_item_has_subnav( $nav_item = '' ) {
732
  $bp = buddypress();
739
  /**
740
  * Filters whether or not a given nav item has subnav items.
741
  *
742
+ * @since 1.5.0
743
  *
744
  * @param bool $has_subnav Whether or not there is any subnav items.
745
+ * @param string $nav_item The slug of the top-level nav item whose subnav items you're checking.
 
746
  */
747
  return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item );
748
  }
751
  * Remove a nav item from the navigation array.
752
  *
753
  * @param int $parent_id The slug of the parent navigation item.
754
+ *
755
+ * @return bool Returns false on failure, ie if the nav item can't be found.
756
  */
757
  function bp_core_remove_nav_item( $parent_id ) {
758
  $bp = buddypress();
781
  * Remove a subnav item from the navigation array.
782
  *
783
  * @param string $parent_id The slug of the parent navigation item.
784
+ * @param string $slug The slug of the subnav item to be removed.
785
  */
786
  function bp_core_remove_subnav_item( $parent_id, $slug ) {
787
  $bp = buddypress();
820
  *
821
  * This is a direct copy of WP's private _get_admin_bar_pref()
822
  *
823
+ * @since 1.5.0
824
  *
825
  * @uses get_user_option()
826
  *
827
  * @param string $context Context of this preference check. 'admin' or 'front'.
828
+ * @param int $user Optional. ID of the user to check. Default: 0 (which falls back to the logged-in user's ID).
829
+ *
830
  * @return bool True if the toolbar should be showing for this user.
831
  */
832
  function bp_get_admin_bar_pref( $context, $user = 0 ) {
bp-core/bp-core-cache.php CHANGED
@@ -2,11 +2,13 @@
2
  /**
3
  * BuddyPress Core Caching Functions.
4
  *
 
 
5
  * Caching functions handle the clearing of cached objects and pages on specific
6
  * actions throughout BuddyPress.
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
@@ -16,6 +18,8 @@ defined( 'ABSPATH' ) || exit;
16
  *
17
  * When wp-super-cache is installed this function will clear cached pages
18
  * so that success/error messages are not cached, or time sensitive content.
 
 
19
  */
20
  function bp_core_clear_cache() {
21
  global $cache_path;
@@ -25,7 +29,7 @@ function bp_core_clear_cache() {
25
  /**
26
  * Fires before the pruning of WP Super Cache.
27
  *
28
- * @since BuddyPress (1.0.0)
29
  */
30
  do_action( 'bp_core_clear_cache' );
31
  return prune_super_cache( $cache_path, true );
@@ -34,6 +38,8 @@ function bp_core_clear_cache() {
34
 
35
  /**
36
  * Clear all cached objects for a user, or those that a user is part of.
 
 
37
  */
38
  function bp_core_clear_user_object_cache( $user_id ) {
39
  wp_cache_delete( 'bp_user_' . $user_id, 'bp' );
@@ -55,16 +61,16 @@ add_action( 'deleted_user', 'bp_core_clear_member_count_caches
55
  /**
56
  * Clear the directory_pages cache when one of the pages is updated.
57
  *
58
- * @since BuddyPress (2.0.0)
59
  *
60
- * @param int $post_id
61
  */
62
  function bp_core_clear_directory_pages_cache_page_edit( $post_id ) {
63
  if ( ! bp_is_root_blog() ) {
64
  return;
65
  }
66
 
67
- // Bail if BP is not defined here
68
  if ( ! buddypress() ) {
69
  return;
70
  }
@@ -82,7 +88,7 @@ add_action( 'save_post', 'bp_core_clear_directory_pages_cache_page_edit' );
82
  /**
83
  * Clear the directory_pages cache when the bp-pages option is updated.
84
  *
85
- * @since BuddyPress (2.0.0)
86
  *
87
  * @param string $option Option name.
88
  */
@@ -96,7 +102,7 @@ add_action( 'update_option', 'bp_core_clear_directory_pages_cache_settings_edit'
96
  /**
97
  * Clear the root_blog_options cache when any of its options are updated.
98
  *
99
- * @since BuddyPress (2.0.0)
100
  *
101
  * @param string $option Option name.
102
  */
@@ -123,10 +129,11 @@ add_action( 'add_site_option', 'bp_core_clear_root_options_cache' );
123
  /**
124
  * Determine which items from a list do not have cached values.
125
  *
126
- * @since BuddyPress (2.0.0)
127
  *
128
- * @param array $item_ids ID list.
129
  * @param string $cache_group The cache group to check against.
 
130
  * @return array
131
  */
132
  function bp_get_non_cached_ids( $item_ids, $cache_group ) {
@@ -151,22 +158,23 @@ function bp_get_non_cached_ids( $item_ids, $cache_group ) {
151
  * object can lead to dramatic performance improvements when using metadata
152
  * in the context of template loops.
153
  *
154
- * @since BuddyPress (1.6.0)
155
  *
156
- * @global $wpdb WordPress database object for queries..
157
  *
158
  * @param array $args {
159
  * Array of arguments.
160
- * @type array|string $object_ids List of object IDs to fetch metadata for.
161
- * Accepts an array or a comma-separated list of numeric IDs.
162
- * @type string $object_type The type of object, eg 'groups' or 'activity'.
163
- * @type string $meta_table The name of the metadata table being queried.
164
- * @type string $object_column Optional. The name of the database column
165
- * where IDs (those provided by $object_ids) are found. Eg, 'group_id'
166
- * for the groups metadata tables. Default: $object_type . '_id'.
167
- * @type string $cache_key_prefix Optional. The prefix to use when creating
168
- * cache key names. Default: the value of $meta_table.
169
  * }
 
170
  * @return array|bool Metadata cache for the specified objects, or false on failure.
171
  */
172
  function bp_update_meta_cache( $args = array() ) {
@@ -178,8 +186,7 @@ function bp_update_meta_cache( $args = array() ) {
178
  'cache_group' => '', // Cache group
179
  'meta_table' => '', // Name of the table containing the metadata
180
  'object_column' => '', // DB column for the object ids (group_id, etc)
181
- 'cache_key_prefix' => '' // Prefix to use when creating cache key names. Eg
182
- // 'bp_groups_groupmeta'
183
  );
184
  $r = wp_parse_args( $args, $defaults );
185
  extract( $r );
2
  /**
3
  * BuddyPress Core Caching Functions.
4
  *
5
+ * @package BuddyPress
6
+ *
7
  * Caching functions handle the clearing of cached objects and pages on specific
8
  * actions throughout BuddyPress.
9
  */
10
 
11
+ // Exit if accessed directly.
12
  defined( 'ABSPATH' ) || exit;
13
 
14
  /**
18
  *
19
  * When wp-super-cache is installed this function will clear cached pages
20
  * so that success/error messages are not cached, or time sensitive content.
21
+ *
22
+ * @return int
23
  */
24
  function bp_core_clear_cache() {
25
  global $cache_path;
29
  /**
30
  * Fires before the pruning of WP Super Cache.
31
  *
32
+ * @since 1.0.0
33
  */
34
  do_action( 'bp_core_clear_cache' );
35
  return prune_super_cache( $cache_path, true );
38
 
39
  /**
40
  * Clear all cached objects for a user, or those that a user is part of.
41
+ *
42
+ * @param string $user_id User ID to delete cache for.
43
  */
44
  function bp_core_clear_user_object_cache( $user_id ) {
45
  wp_cache_delete( 'bp_user_' . $user_id, 'bp' );
61
  /**
62
  * Clear the directory_pages cache when one of the pages is updated.
63
  *
64
+ * @since 2.0.0
65
  *
66
+ * @param int $post_id ID of the page that was saved.
67
  */
68
  function bp_core_clear_directory_pages_cache_page_edit( $post_id ) {
69
  if ( ! bp_is_root_blog() ) {
70
  return;
71
  }
72
 
73
+ // Bail if BP is not defined here.
74
  if ( ! buddypress() ) {
75
  return;
76
  }
88
  /**
89
  * Clear the directory_pages cache when the bp-pages option is updated.
90
  *
91
+ * @since 2.0.0
92
  *
93
  * @param string $option Option name.
94
  */
102
  /**
103
  * Clear the root_blog_options cache when any of its options are updated.
104
  *
105
+ * @since 2.0.0
106
  *
107
  * @param string $option Option name.
108
  */
129
  /**
130
  * Determine which items from a list do not have cached values.
131
  *
132
+ * @since 2.0.0
133
  *
134
+ * @param array $item_ids ID list.
135
  * @param string $cache_group The cache group to check against.
136
+ *
137
  * @return array
138
  */
139
  function bp_get_non_cached_ids( $item_ids, $cache_group ) {
158
  * object can lead to dramatic performance improvements when using metadata
159
  * in the context of template loops.
160
  *
161
+ * @since 1.6.0
162
  *
163
+ * @global object $wpdb WordPress database object for queries..
164
  *
165
  * @param array $args {
166
  * Array of arguments.
167
+ * @type array|string $object_ids List of object IDs to fetch metadata for.
168
+ * Accepts an array or a comma-separated list of numeric IDs.
169
+ * @type string $object_type The type of object, eg 'groups' or 'activity'.
170
+ * @type string $meta_table The name of the metadata table being queried.
171
+ * @type string $object_column Optional. The name of the database column where IDs
172
+ * (those provided by $object_ids) are found. Eg, 'group_id'
173
+ * for the groups metadata tables. Default: $object_type . '_id'.
174
+ * @type string $cache_key_prefix Optional. The prefix to use when creating
175
+ * cache key names. Default: the value of $meta_table.
176
  * }
177
+ *
178
  * @return array|bool Metadata cache for the specified objects, or false on failure.
179
  */
180
  function bp_update_meta_cache( $args = array() ) {
186
  'cache_group' => '', // Cache group
187
  'meta_table' => '', // Name of the table containing the metadata
188
  'object_column' => '', // DB column for the object ids (group_id, etc)
189
+ 'cache_key_prefix' => '' // Prefix to use when creating cache key names. Eg 'bp_groups_groupmeta'
 
190
  );
191
  $r = wp_parse_args( $args, $defaults );
192
  extract( $r );
bp-core/bp-core-caps.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Capabilities.
5
  *
@@ -7,18 +6,18 @@
7
  * @subpackage Capabilities
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
- * Return an array of roles from the currently loaded blog
15
  *
16
  * WordPress roles are dynamically flipped when calls to switch_to_blog() and
17
  * restore_current_blog() are made, so we use and trust WordPress core to have
18
  * loaded the correct results for us here. As enhancements are made to
19
  * WordPress's RBAC, so should our capability functions here.
20
  *
21
- * @since BuddyPress (2.1.0)
22
  *
23
  * @return array
24
  */
@@ -33,7 +32,7 @@ function bp_get_current_blog_roles() {
33
  /**
34
  * Filters the list of editable roles.
35
  *
36
- * @since BuddyPress (2.1.0)
37
  *
38
  * @param array $roles List of roles.
39
  */
@@ -42,7 +41,7 @@ function bp_get_current_blog_roles() {
42
  /**
43
  * Filters the array of roles from the currently loaded blog.
44
  *
45
- * @since BuddyPress (2.1.0)
46
  *
47
  * @param array $roles Available roles.
48
  * @param WP_Roles $wp_roles Object of WordPress roles.
@@ -55,7 +54,7 @@ function bp_get_current_blog_roles() {
55
  *
56
  * This is called on plugin activation.
57
  *
58
- * @since BuddyPress (1.6.0)
59
  *
60
  * @uses get_role() To get the administrator, default and moderator roles.
61
  * @uses WP_Role::add_cap() To add various capabilities.
@@ -65,8 +64,9 @@ function bp_add_caps() {
65
  global $wp_roles;
66
 
67
  // Load roles if not set
68
- if ( ! isset( $wp_roles ) )
69
  $wp_roles = new WP_Roles();
 
70
 
71
  // Loop through available roles and add them
72
  foreach( $wp_roles->role_objects as $role ) {
@@ -80,7 +80,7 @@ function bp_add_caps() {
80
  *
81
  * This is called on plugin activation.
82
  *
83
- * @since BuddyPress (1.6.0)
84
  */
85
  do_action( 'bp_add_caps' );
86
  }
@@ -90,7 +90,7 @@ function bp_add_caps() {
90
  *
91
  * This is called on plugin deactivation.
92
  *
93
- * @since BuddyPress (1.6.0)
94
  *
95
  * @uses get_role() To get the administrator and default roles.
96
  * @uses WP_Role::remove_cap() To remove various capabilities.
@@ -100,8 +100,9 @@ function bp_remove_caps() {
100
  global $wp_roles;
101
 
102
  // Load roles if not set
103
- if ( ! isset( $wp_roles ) )
104
  $wp_roles = new WP_Roles();
 
105
 
106
  // Loop through available roles and remove them
107
  foreach( $wp_roles->role_objects as $role ) {
@@ -115,7 +116,7 @@ function bp_remove_caps() {
115
  *
116
  * This is called on plugin deactivation.
117
  *
118
- * @since BuddyPress (1.6.0)
119
  */
120
  do_action( 'bp_remove_caps' );
121
  }
@@ -123,17 +124,18 @@ function bp_remove_caps() {
123
  /**
124
  * Map community caps to built in WordPress caps.
125
  *
126
- * @since BuddyPress (1.6.0)
127
  *
128
  * @see WP_User::has_cap() for description of the arguments passed to the
129
  * 'map_meta_cap' filter.
130
  * @uses apply_filters() Calls 'bp_map_meta_caps' with caps, cap, user ID and
131
  * args.
132
  *
133
- * @param array $caps See {@link WP_User::has_cap()}.
134
- * @param string $cap See {@link WP_User::has_cap()}.
135
- * @param int $user_id See {@link WP_User::has_cap()}.
136
- * @param mixed $args See {@link WP_User::has_cap()}.
 
137
  * @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}.
138
  */
139
  function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
@@ -141,7 +143,7 @@ function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
141
  /**
142
  * Filters the community caps mapping to be built in WordPress caps.
143
  *
144
- * @since BuddyPress (1.6.0)
145
  *
146
  * @param array $caps Returns the user's actual capabilities.
147
  * @param string $cap Capability name.
@@ -154,7 +156,7 @@ function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
154
  /**
155
  * Return community capabilities.
156
  *
157
- * @since BuddyPress (1.6.0)
158
  *
159
  * @uses apply_filters() Calls 'bp_get_community_caps' with the capabilities.
160
  *
@@ -168,7 +170,7 @@ function bp_get_community_caps() {
168
  /**
169
  * Filters community capabilities.
170
  *
171
- * @since BuddyPress (1.6.0)
172
  *
173
  * @param array $caps Array of capabilities to add. Empty by default.
174
  */
@@ -178,11 +180,12 @@ function bp_get_community_caps() {
178
  /**
179
  * Return an array of capabilities based on the role that is being requested.
180
  *
181
- * @since BuddyPress (1.6.0)
182
  *
183
  * @uses apply_filters() Allow return value to be filtered.
184
  *
185
  * @param string $role The role for which you're loading caps.
 
186
  * @return array Capabilities for $role.
187
  */
188
  function bp_get_caps_for_role( $role = '' ) {
@@ -199,11 +202,12 @@ function bp_get_caps_for_role( $role = '' ) {
199
 
200
  break;
201
 
202
- case 'editor' :
203
- case 'author' :
204
- case 'contributor' :
205
- case 'subscriber' :
206
- default :
 
207
  $caps = array();
208
  break;
209
  }
@@ -211,7 +215,7 @@ function bp_get_caps_for_role( $role = '' ) {
211
  /**
212
  * Filters the array of capabilities based on the role that is being requested.
213
  *
214
- * @since BuddyPress (1.6.0)
215
  *
216
  * @param array $caps Array of capabilities to return.
217
  * @param string $role The role currently being loaded.
@@ -225,7 +229,7 @@ function bp_get_caps_for_role( $role = '' ) {
225
  * Give a user the default role when creating content on a site they do not
226
  * already have a role or capability on.
227
  *
228
- * @since BuddyPress (1.6.0)
229
  *
230
  * @global BuddyPress $bp Global BuddyPress settings object.
231
  *
@@ -239,16 +243,19 @@ function bp_get_caps_for_role( $role = '' ) {
239
  function bp_set_current_user_default_role() {
240
 
241
  // Bail if not multisite or not root blog
242
- if ( ! is_multisite() || ! bp_is_root_blog() )
243
  return;
 
244
 
245
  // Bail if user is not logged in or already a member
246
- if ( ! is_user_logged_in() || is_user_member_of_blog() )
247
  return;
 
248
 
249
  // Bail if user is not active
250
- if ( bp_is_user_inactive() )
251
  return;
 
252
 
253
  // Set the current users default role
254
  buddypress()->current_user->set_role( bp_get_option( 'default_role', 'subscriber' ) );
@@ -257,32 +264,53 @@ function bp_set_current_user_default_role() {
257
  /**
258
  * Check whether the current user has a given capability.
259
  *
260
- * Can be passed blog ID, or will use the root blog by default.
 
261
  *
262
- * @since BuddyPress (1.6.0)
 
 
 
 
 
263
  *
264
- * @param string $capability Capability or role name.
265
- * @param int $blog_id Optional. Blog ID. Defaults to the BP root blog.
266
- * @return bool True if the user has the cap for the given blog.
267
  */
268
- function bp_current_user_can( $capability, $blog_id = 0 ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
269
 
270
  // Use root blog if no ID passed
271
- if ( empty( $blog_id ) )
272
  $blog_id = bp_get_root_blog_id();
 
273
 
274
- $retval = current_user_can_for_blog( $blog_id, $capability );
 
275
 
276
  /**
277
  * Filters whether or not the current user has a given capability.
278
  *
279
- * @since BuddyPress (1.6.0)
 
280
  *
281
  * @param bool $retval Whether or not the current user has the capability.
282
  * @param string $capability The capability being checked for.
283
  * @param int $blog_id Blog ID. Defaults to the BP root blog.
 
284
  */
285
- return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id );
286
  }
287
 
288
  /**
@@ -299,32 +327,38 @@ function bp_current_user_can( $capability, $blog_id = 0 ) {
299
  * installation. See {@link WP_User::has_cap()}.
300
  *
301
  * This implementation of 'bp_moderate' is temporary, until BuddyPress properly
302
- * matches caps to roles and stores them in the database. Plugin authors: Do
303
- * not use this function.
 
304
  *
305
  * @access private
306
- * @since BuddyPress (1.6.0)
307
  *
308
  * @see WP_User::has_cap()
309
  *
310
- * @param array $allcaps The caps that WP associates with the given role.
311
- * @param array $caps The caps being tested for in WP_User::has_cap().
312
- * @param array $args Miscellaneous arguments passed to the user_has_cap filter.
 
 
313
  * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
314
  */
315
  function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
316
 
317
  // Bail if not checking the 'bp_moderate' cap
318
- if ( 'bp_moderate' !== $cap )
319
  return $caps;
 
320
 
321
  // Bail if BuddyPress is not network activated
322
- if ( bp_is_network_activated() )
323
  return $caps;
 
324
 
325
  // Never trust inactive users
326
- if ( bp_is_user_inactive( $user_id ) )
327
  return $caps;
 
328
 
329
  // Only users that can 'manage_options' on this site can 'bp_moderate'
330
  return array( 'manage_options' );
@@ -338,7 +372,7 @@ add_filter( 'map_meta_cap', '_bp_enforce_bp_moderate_cap_for_admins', 10, 4 );
338
  *
339
  * This is called on plugin activation.
340
  *
341
- * @since BuddyPress (1.6.0)
342
  * @deprecated 1.7.0
343
  */
344
  function bp_add_roles() {
@@ -350,7 +384,7 @@ function bp_add_roles() {
350
  *
351
  * This is called on plugin deactivation.
352
  *
353
- * @since BuddyPress (1.6.0)
354
  * @deprecated 1.7.0
355
  */
356
  function bp_remove_roles() {
@@ -364,7 +398,7 @@ function bp_remove_roles() {
364
  * This is primarily for multisite compatibility when users without roles on
365
  * sites that have global communities enabled.
366
  *
367
- * @since BuddyPress (1.6)
368
  * @deprecated 1.7.0
369
  */
370
  function bp_get_participant_role() {
@@ -374,7 +408,7 @@ function bp_get_participant_role() {
374
  /**
375
  * The moderator role for BuddyPress users.
376
  *
377
- * @since BuddyPress (1.6.0)
378
  * @deprecated 1.7.0
379
  */
380
  function bp_get_moderator_role() {
1
  <?php
 
2
  /**
3
  * BuddyPress Capabilities.
4
  *
6
  * @subpackage Capabilities
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
+ * Return an array of roles from the currently loaded blog.
14
  *
15
  * WordPress roles are dynamically flipped when calls to switch_to_blog() and
16
  * restore_current_blog() are made, so we use and trust WordPress core to have
17
  * loaded the correct results for us here. As enhancements are made to
18
  * WordPress's RBAC, so should our capability functions here.
19
  *
20
+ * @since 2.1.0
21
  *
22
  * @return array
23
  */
32
  /**
33
  * Filters the list of editable roles.
34
  *
35
+ * @since 2.1.0
36
  *
37
  * @param array $roles List of roles.
38
  */
41
  /**
42
  * Filters the array of roles from the currently loaded blog.
43
  *
44
+ * @since 2.1.0
45
  *
46
  * @param array $roles Available roles.
47
  * @param WP_Roles $wp_roles Object of WordPress roles.
54
  *
55
  * This is called on plugin activation.
56
  *
57
+ * @since 1.6.0
58
  *
59
  * @uses get_role() To get the administrator, default and moderator roles.
60
  * @uses WP_Role::add_cap() To add various capabilities.
64
  global $wp_roles;
65
 
66
  // Load roles if not set
67
+ if ( ! isset( $wp_roles ) ) {
68
  $wp_roles = new WP_Roles();
69
+ }
70
 
71
  // Loop through available roles and add them
72
  foreach( $wp_roles->role_objects as $role ) {
80
  *
81
  * This is called on plugin activation.
82
  *
83
+ * @since 1.6.0
84
  */
85
  do_action( 'bp_add_caps' );
86
  }
90
  *
91
  * This is called on plugin deactivation.
92
  *
93
+ * @since 1.6.0
94
  *
95
  * @uses get_role() To get the administrator and default roles.
96
  * @uses WP_Role::remove_cap() To remove various capabilities.
100
  global $wp_roles;
101
 
102
  // Load roles if not set
103
+ if ( ! isset( $wp_roles ) ) {
104
  $wp_roles = new WP_Roles();
105
+ }
106
 
107
  // Loop through available roles and remove them
108
  foreach( $wp_roles->role_objects as $role ) {
116
  *
117
  * This is called on plugin deactivation.
118
  *
119
+ * @since 1.6.0
120
  */
121
  do_action( 'bp_remove_caps' );
122
  }
124
  /**
125
  * Map community caps to built in WordPress caps.
126
  *
127
+ * @since 1.6.0
128
  *
129
  * @see WP_User::has_cap() for description of the arguments passed to the
130
  * 'map_meta_cap' filter.
131
  * @uses apply_filters() Calls 'bp_map_meta_caps' with caps, cap, user ID and
132
  * args.
133
  *
134
+ * @param array $caps See {@link WP_User::has_cap()}.
135
+ * @param string $cap See {@link WP_User::has_cap()}.
136
+ * @param int $user_id See {@link WP_User::has_cap()}.
137
+ * @param mixed $args See {@link WP_User::has_cap()}.
138
+ *
139
  * @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}.
140
  */
141
  function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
143
  /**
144
  * Filters the community caps mapping to be built in WordPress caps.
145
  *
146
+ * @since 1.6.0
147
  *
148
  * @param array $caps Returns the user's actual capabilities.
149
  * @param string $cap Capability name.
156
  /**
157
  * Return community capabilities.
158
  *
159
+ * @since 1.6.0
160
  *
161
  * @uses apply_filters() Calls 'bp_get_community_caps' with the capabilities.
162
  *
170
  /**
171
  * Filters community capabilities.
172
  *
173
+ * @since 1.6.0
174
  *
175
  * @param array $caps Array of capabilities to add. Empty by default.
176
  */
180
  /**
181
  * Return an array of capabilities based on the role that is being requested.
182
  *
183
+ * @since 1.6.0
184
  *
185
  * @uses apply_filters() Allow return value to be filtered.
186
  *
187
  * @param string $role The role for which you're loading caps.
188
+ *
189
  * @return array Capabilities for $role.
190
  */
191
  function bp_get_caps_for_role( $role = '' ) {
202
 
203
  break;
204
 
205
+ // All other default WordPress blog roles
206
+ case 'editor' :
207
+ case 'author' :
208
+ case 'contributor' :
209
+ case 'subscriber' :
210
+ default :
211
  $caps = array();
212
  break;
213
  }
215
  /**
216
  * Filters the array of capabilities based on the role that is being requested.
217
  *
218
+ * @since 1.6.0
219
  *
220
  * @param array $caps Array of capabilities to return.
221
  * @param string $role The role currently being loaded.
229
  * Give a user the default role when creating content on a site they do not
230
  * already have a role or capability on.
231
  *
232
+ * @since 1.6.0
233
  *
234
  * @global BuddyPress $bp Global BuddyPress settings object.
235
  *
243
  function bp_set_current_user_default_role() {
244
 
245
  // Bail if not multisite or not root blog
246
+ if ( ! is_multisite() || ! bp_is_root_blog() ) {
247
  return;
248
+ }
249
 
250
  // Bail if user is not logged in or already a member
251
+ if ( ! is_user_logged_in() || is_user_member_of_blog() ) {
252
  return;
253
+ }
254
 
255
  // Bail if user is not active
256
+ if ( bp_is_user_inactive() ) {
257
  return;
258
+ }
259
 
260
  // Set the current users default role
261
  buddypress()->current_user->set_role( bp_get_option( 'default_role', 'subscriber' ) );
264
  /**
265
  * Check whether the current user has a given capability.
266
  *
267
+ * @since 1.6.0
268
+ * @since 2.4.0 Second argument modified to accept an array, rather than `$blog_id`.
269
  *
270
+ * @param string $capability Capability or role name.
271
+ * @param array|int $args {
272
+ * Array of extra arguments applicable to the capability check.
273
+ * @type int $blog_id Optional. Blog ID. Defaults to the BP root blog.
274
+ * @type mixed $a,... Optional. Extra arguments applicable to the capability check.
275
+ * }
276
  *
277
+ * @return bool True if the user has the cap for the given parameters.
 
 
278
  */
279
+ function bp_current_user_can( $capability, $args = array() ) {
280
+ $blog_id = 0;
281
+
282
+ // Backward compatibility for older $blog_id parameter.
283
+ if ( is_int( $args ) ) {
284
+ $blog_id = $args;
285
+ $args = array();
286
+
287
+ // New format for second parameter.
288
+ } elseif ( is_array( $args ) && isset( $args['blog_id'] ) ) {
289
+ // Get the blog ID if set, but don't pass along to `current_user_can_for_blog()`.
290
+ $blog_id = (int) $args['blog_id'];
291
+ unset( $args['blog_id'] );
292
+ }
293
 
294
  // Use root blog if no ID passed
295
+ if ( empty( $blog_id ) ) {
296
  $blog_id = bp_get_root_blog_id();
297
+ }
298
 
299
+ $args = array( $blog_id, $capability, $args );
300
+ $retval = call_user_func_array( 'current_user_can_for_blog', $args );
301
 
302
  /**
303
  * Filters whether or not the current user has a given capability.
304
  *
305
+ * @since 1.6.0
306
+ * @since 2.4.0 Pass `$args` variable.
307
  *
308
  * @param bool $retval Whether or not the current user has the capability.
309
  * @param string $capability The capability being checked for.
310
  * @param int $blog_id Blog ID. Defaults to the BP root blog.
311
+ * @param array $args Array of extra arguments passed.
312
  */
313
+ return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id, $args );
314
  }
315
 
316
  /**
327
  * installation. See {@link WP_User::has_cap()}.
328
  *
329
  * This implementation of 'bp_moderate' is temporary, until BuddyPress properly
330
+ * matches caps to roles and stores them in the database.
331
+ *
332
+ * Plugin authors: Please do not use this function; thank you. :)
333
  *
334
  * @access private
335
+ * @since 1.6.0
336
  *
337
  * @see WP_User::has_cap()
338
  *
339
+ * @param array $caps The caps that WP associates with the given role.
340
+ * @param string $cap The caps being tested for in WP_User::has_cap().
341
+ * @param int $user_id ID of the user being checked against.
342
+ * @param array $args Miscellaneous arguments passed to the user_has_cap filter.
343
+ *
344
  * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
345
  */
346
  function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
347
 
348
  // Bail if not checking the 'bp_moderate' cap
349
+ if ( 'bp_moderate' !== $cap ) {
350
  return $caps;
351
+ }
352
 
353
  // Bail if BuddyPress is not network activated
354
+ if ( bp_is_network_activated() ) {
355
  return $caps;
356
+ }
357
 
358
  // Never trust inactive users
359
+ if ( bp_is_user_inactive( $user_id ) ) {
360
  return $caps;
361
+ }
362
 
363
  // Only users that can 'manage_options' on this site can 'bp_moderate'
364
  return array( 'manage_options' );
372
  *
373
  * This is called on plugin activation.
374
  *
375
+ * @since 1.6.0
376
  * @deprecated 1.7.0
377
  */
378
  function bp_add_roles() {
384
  *
385
  * This is called on plugin deactivation.
386
  *
387
+ * @since 1.6.0
388
  * @deprecated 1.7.0
389
  */
390
  function bp_remove_roles() {
398
  * This is primarily for multisite compatibility when users without roles on
399
  * sites that have global communities enabled.
400
  *
401
+ * @since 1.6.0
402
  * @deprecated 1.7.0
403
  */
404
  function bp_get_participant_role() {
408
  /**
409
  * The moderator role for BuddyPress users.
410
  *
411
+ * @since 1.6.0
412
  * @deprecated 1.7.0
413
  */
414
  function bp_get_moderator_role() {
bp-core/bp-core-catchuri.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress URI catcher.
5
  *
@@ -10,7 +9,7 @@
10
  * @subpackage Core
11
  */
12
 
13
- // Exit if accessed directly
14
  defined( 'ABSPATH' ) || exit;
15
 
16
  /**
@@ -30,7 +29,7 @@ defined( 'ABSPATH' ) || exit;
30
  * - $bp->current_action: string 'edit'
31
  * - $bp->action_variables: array ['group', 5]
32
  *
33
- * @since BuddyPress (1.0.0)
34
  */
35
  function bp_core_set_uri_globals() {
36
  global $current_blog, $wp_rewrite;
@@ -58,7 +57,7 @@ function bp_core_set_uri_globals() {
58
  /**
59
  * Filters the BuddyPress global URI path.
60
  *
61
- * @since BuddyPress (1.0.0)
62
  *
63
  * @param string $path Path to set.
64
  */
@@ -241,8 +240,11 @@ function bp_core_set_uri_globals() {
241
 
242
  // Rejig the offset
243
  if ( !empty( $slug ) && ( 1 < count( $slug ) ) ) {
244
- array_pop( $slug );
245
- $uri_offset = count( $slug );
 
 
 
246
  }
247
 
248
  // Global the unfiltered offset to use in bp_core_load_template().
@@ -265,9 +267,14 @@ function bp_core_set_uri_globals() {
265
 
266
  // Are we viewing a specific user?
267
  if ( $after_member_slug ) {
 
 
 
 
268
  // Switch the displayed_user based on compatibility mode
269
- if ( bp_is_username_compatibility_mode() ) {
270
  $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $after_member_slug ) );
 
271
  } else {
272
  $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( $after_member_slug );
273
  }
@@ -322,8 +329,22 @@ function bp_core_set_uri_globals() {
322
  }
323
  }
324
 
325
- // Set the current action
326
- $bp->current_action = isset( $bp_uri[$uri_offset + 1] ) ? $bp_uri[$uri_offset + 1] : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
 
328
  // Slice the rest of the $bp_uri array and reset offset
329
  $bp_uri = array_slice( $bp_uri, $uri_offset + 2 );
@@ -339,7 +360,7 @@ function bp_core_set_uri_globals() {
339
  /**
340
  * Are root profiles enabled and allowed?
341
  *
342
- * @since BuddyPress (1.6.0)
343
  *
344
  * @return bool True if yes, false if no.
345
  */
@@ -353,7 +374,7 @@ function bp_core_enable_root_profiles() {
353
  /**
354
  * Filters whether or not root profiles are enabled and allowed.
355
  *
356
- * @since BuddyPress (1.6.0)
357
  *
358
  * @param bool $retval Whether or not root profiles are available.
359
  */
@@ -369,6 +390,7 @@ function bp_core_enable_root_profiles() {
369
  * wp-content/themes/[activated_theme]/members/index.php
370
  *
371
  * @param array $templates Array of templates to attempt to load.
 
372
  * @return bool|null Returns false on failure.
373
  */
374
  function bp_core_load_template( $templates ) {
@@ -405,7 +427,7 @@ function bp_core_load_template( $templates ) {
405
  *
406
  * Allows plugins to alter where the template files are located.
407
  *
408
- * @since BuddyPress (1.1.0)
409
  *
410
  * @param string $template Located template path.
411
  * @param array $filtered_templates Array of templates to attempt to load.
@@ -421,7 +443,7 @@ function bp_core_load_template( $templates ) {
421
  /**
422
  * Fires before the loading of a located template file.
423
  *
424
- * @since BuddyPress (1.6.0)
425
  *
426
  * @param string $located_template Template found to be loaded.
427
  */
@@ -430,7 +452,7 @@ function bp_core_load_template( $templates ) {
430
  /**
431
  * Filters the selected template right before loading.
432
  *
433
- * @since BuddyPress (1.1.0)
434
  *
435
  * @param string $located_template Template found to be loaded.
436
  */
@@ -439,7 +461,7 @@ function bp_core_load_template( $templates ) {
439
  /**
440
  * Fires after the loading of a located template file.
441
  *
442
- * @since BuddyPress (1.6.0)
443
  *
444
  * @param string $located_template Template found that was loaded.
445
  */
@@ -464,7 +486,7 @@ function bp_core_load_template( $templates ) {
464
  /**
465
  * Fires if there are no found templates to load and theme compat is needed.
466
  *
467
- * @since BuddyPress (1.7.0)
468
  */
469
  do_action( 'bp_setup_theme_compat' );
470
  }
@@ -479,7 +501,7 @@ function bp_core_catch_profile_uri() {
479
  /**
480
  * Filters the path to redirect users to if XProfile is not enabled.
481
  *
482
- * @since BuddyPress (1.0.0)
483
  *
484
  * @param string $value Path to redirect users to.
485
  */
@@ -490,7 +512,7 @@ function bp_core_catch_profile_uri() {
490
  /**
491
  * Catch unauthorized access to certain BuddyPress pages and redirect accordingly.
492
  *
493
- * @since BuddyPress (1.5.0)
494
  */
495
  function bp_core_catch_no_access() {
496
  global $wp_query;
@@ -515,19 +537,18 @@ add_action( 'bp_template_redirect', 'bp_core_catch_no_access', 1 );
515
  *
516
  * If authenticated, redirects user back to requested content by default.
517
  *
518
- * @since BuddyPress (1.5.0)
519
- *
520
- * @param array $args {
521
- * @type int $mode Specifies the destination of the redirect. 1 will
522
- * direct to the root domain (home page), which assumes you have a
523
- * log-in form there; 2 directs to wp-login.php. Default: 2.
524
- * @type string $redirect The URL the user will be redirected to after
525
- * successfully logging in. Default: the URL originally requested.
526
- * @type string $root The root URL of the site, used in case of error or
527
- * mode 1 redirects. Default: the value of {@link bp_get_root_domain()}.
528
- * @type string $message An error message to display to the user on the
529
- * log-in page. Default: "You must log in to access the page you
530
- * requested."
531
  * }
532
  */
533
  function bp_core_no_access( $args = '' ) {
@@ -549,7 +570,7 @@ function bp_core_no_access( $args = '' ) {
549
  /**
550
  * Filters the arguments used for user redirecting when visiting access controlled areas.
551
  *
552
- * @since BuddyPress (1.6.0)
553
  *
554
  * @param array $r Array of parsed arguments for redirect determination.
555
  */
@@ -603,9 +624,9 @@ function bp_core_no_access( $args = '' ) {
603
  *
604
  * Hooks into the "bpnoaccess" action defined in bp_core_no_access().
605
  *
606
- * @since BuddyPress (1.5.0)
607
  *
608
- * @global $error Error message to pass to wp-login.php
609
  */
610
  function bp_core_no_access_wp_login_error() {
611
  global $error;
@@ -613,7 +634,7 @@ function bp_core_no_access_wp_login_error() {
613
  /**
614
  * Filters the error message for wp-login.php when needing to log in before accessing.
615
  *
616
- * @since BuddyPress (1.5.0)
617
  *
618
  * @param string $value Error message to display.
619
  * @param string $value URL to redirect user to after successful login.
@@ -634,7 +655,7 @@ add_action( 'login_form_bpnoaccess', 'bp_core_no_access_wp_login_error' );
634
  * URL - eg, example.com/groups/mygroup/ instead of
635
  * example.com/groups/mygroup/home/.
636
  *
637
- * @since BuddyPress (1.6.0)
638
  *
639
  * @see BP_Members_Component::setup_globals() where
640
  * $bp->canonical_stack['base_url'] and ['component'] may be set.
@@ -647,7 +668,7 @@ function bp_redirect_canonical() {
647
  /**
648
  * Filters whether or not to do canonical redirects on BuddyPress URLs.
649
  *
650
- * @since BuddyPress (1.6.0)
651
  *
652
  * @param bool $value Whether or not to do canonical redirects. Default true.
653
  */
@@ -696,7 +717,7 @@ function bp_redirect_canonical() {
696
  /**
697
  * Output rel=canonical header tag for BuddyPress content.
698
  *
699
- * @since BuddyPress (1.6.0)
700
  */
701
  function bp_rel_canonical() {
702
  $canonical_url = bp_get_canonical_url();
@@ -708,15 +729,16 @@ function bp_rel_canonical() {
708
  /**
709
  * Get the canonical URL of the current page.
710
  *
711
- * @since BuddyPress (1.6.0)
712
  *
713
  * @uses apply_filters() Filter bp_get_canonical_url to modify return value.
714
  *
715
  * @param array $args {
716
  * Optional array of arguments.
717
  * @type bool $include_query_args Whether to include current URL arguments
718
- * in the canonical URL returned from the function.
719
  * }
 
720
  * @return string Canonical URL for the current page.
721
  */
722
  function bp_get_canonical_url( $args = array() ) {
@@ -755,7 +777,7 @@ function bp_get_canonical_url( $args = array() ) {
755
  /**
756
  * Filters the logged in register page redirect URL.
757
  *
758
- * @since BuddyPress (1.5.1)
759
  *
760
  * @param string $value URL to redirect logged in members to.
761
  */
@@ -803,7 +825,7 @@ function bp_get_canonical_url( $args = array() ) {
803
  /**
804
  * Filters the canonical url of the current page.
805
  *
806
- * @since BuddyPress (1.6.0)
807
  *
808
  * @param string $canonical_url Canonical URL of the current page.
809
  * @param array $args Array of arguments to help determine canonical URL.
@@ -814,7 +836,7 @@ function bp_get_canonical_url( $args = array() ) {
814
  /**
815
  * Return the URL as requested on the current page load by the user agent.
816
  *
817
- * @since BuddyPress (1.6.0)
818
  *
819
  * @return string Requested URL string.
820
  */
@@ -829,7 +851,7 @@ function bp_get_requested_url() {
829
  /**
830
  * Filters the URL as requested on the current page load by the user agent.
831
  *
832
- * @since BuddyPress (1.7.0)
833
  *
834
  * @param string $value Requested URL string.
835
  */
@@ -845,7 +867,7 @@ function bp_get_requested_url() {
845
  * This function should be considered temporary, and may be removed without
846
  * notice in future versions of BuddyPress.
847
  *
848
- * @since BuddyPress (1.6.0)
849
  *
850
  * @uses bp_is_blog_page()
851
  */
@@ -877,7 +899,7 @@ add_action( 'bp_init', '_bp_maybe_remove_redirect_canonical' );
877
  * This function will be removed in a later version of BuddyPress. Plugins
878
  * (and plugin authors!) should ignore it.
879
  *
880
- * @since BuddyPress (1.6.1)
881
  *
882
  * @link https://buddypress.trac.wordpress.org/ticket/4329
883
  * @link https://buddypress.trac.wordpress.org/ticket/4415
@@ -896,7 +918,7 @@ add_action( 'template_redirect', '_bp_rehook_maybe_redirect_404', 1 );
896
  * This function should be considered temporary, and may be removed without
897
  * notice in future versions of BuddyPress.
898
  *
899
- * @since BuddyPress (1.6.0)
900
  */
901
  function _bp_maybe_remove_rel_canonical() {
902
  if ( ! bp_is_blog_page() && ! is_404() ) {
1
  <?php
 
2
  /**
3
  * BuddyPress URI catcher.
4
  *
9
  * @subpackage Core
10
  */
11
 
12
+ // Exit if accessed directly.
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  /**
29
  * - $bp->current_action: string 'edit'
30
  * - $bp->action_variables: array ['group', 5]
31
  *
32
+ * @since 1.0.0
33
  */
34
  function bp_core_set_uri_globals() {
35
  global $current_blog, $wp_rewrite;
57
  /**
58
  * Filters the BuddyPress global URI path.
59
  *
60
+ * @since 1.0.0
61
  *
62
  * @param string $path Path to set.
63
  */
240
 
241
  // Rejig the offset
242
  if ( !empty( $slug ) && ( 1 < count( $slug ) ) ) {
243
+ // Only offset if not on a root profile. Fixes issue when Members page is nested.
244
+ if ( false === $root_profile ) {
245
+ array_pop( $slug );
246
+ $uri_offset = count( $slug );
247
+ }
248
  }
249
 
250
  // Global the unfiltered offset to use in bp_core_load_template().
267
 
268
  // Are we viewing a specific user?
269
  if ( $after_member_slug ) {
270
+ // If root profile, we've already queried for the user
271
+ if ( $root_profile instanceof WP_User ) {
272
+ $bp->displayed_user->id = $root_profile->ID;
273
+
274
  // Switch the displayed_user based on compatibility mode
275
+ } elseif ( bp_is_username_compatibility_mode() ) {
276
  $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $after_member_slug ) );
277
+
278
  } else {
279
  $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( $after_member_slug );
280
  }
329
  }
330
  }
331
 
332
+ // Determine the current action.
333
+ $current_action = isset( $bp_uri[ $uri_offset + 1 ] ) ? $bp_uri[ $uri_offset + 1 ] : '';
334
+
335
+ /*
336
+ * If a BuddyPress directory is set to the WP front page, URLs like example.com/members/?s=foo
337
+ * shouldn't interfere with blog searches.
338
+ */
339
+ if ( empty( $current_action) && ! empty( $_GET['s'] ) && 'page' == get_option( 'show_on_front' ) && ! empty( $match->id ) ) {
340
+ $page_on_front = (int) get_option( 'page_on_front' );
341
+ if ( (int) $match->id === $page_on_front ) {
342
+ $bp->current_component = '';
343
+ return false;
344
+ }
345
+ }
346
+
347
+ $bp->current_action = $current_action;
348
 
349
  // Slice the rest of the $bp_uri array and reset offset
350
  $bp_uri = array_slice( $bp_uri, $uri_offset + 2 );
360
  /**
361
  * Are root profiles enabled and allowed?
362
  *
363
+ * @since 1.6.0
364
  *
365
  * @return bool True if yes, false if no.
366
  */
374
  /**
375
  * Filters whether or not root profiles are enabled and allowed.
376
  *
377
+ * @since 1.6.0
378
  *
379
  * @param bool $retval Whether or not root profiles are available.
380
  */
390
  * wp-content/themes/[activated_theme]/members/index.php
391
  *
392
  * @param array $templates Array of templates to attempt to load.
393
+ *
394
  * @return bool|null Returns false on failure.
395
  */
396
  function bp_core_load_template( $templates ) {
427
  *
428
  * Allows plugins to alter where the template files are located.
429
  *
430
+ * @since 1.1.0
431
  *
432
  * @param string $template Located template path.
433
  * @param array $filtered_templates Array of templates to attempt to load.
443
  /**
444
  * Fires before the loading of a located template file.
445
  *
446
+ * @since 1.6.0
447
  *
448
  * @param string $located_template Template found to be loaded.
449
  */
452
  /**
453
  * Filters the selected template right before loading.
454
  *
455
+ * @since 1.1.0
456
  *
457
  * @param string $located_template Template found to be loaded.
458
  */
461
  /**
462
  * Fires after the loading of a located template file.
463
  *
464
+ * @since 1.6.0
465
  *
466
  * @param string $located_template Template found that was loaded.
467
  */
486
  /**
487
  * Fires if there are no found templates to load and theme compat is needed.
488
  *
489
+ * @since 1.7.0
490
  */
491
  do_action( 'bp_setup_theme_compat' );
492
  }
501
  /**
502
  * Filters the path to redirect users to if XProfile is not enabled.
503
  *
504
+ * @since 1.0.0
505
  *
506
  * @param string $value Path to redirect users to.
507
  */
512
  /**
513
  * Catch unauthorized access to certain BuddyPress pages and redirect accordingly.
514
  *
515
+ * @since 1.5.0
516
  */
517
  function bp_core_catch_no_access() {
518
  global $wp_query;
537
  *
538
  * If authenticated, redirects user back to requested content by default.
539
  *
540
+ * @since 1.5.0
541
+ *
542
+ * @param array|string $args {
543
+ * @type int $mode Specifies the destination of the redirect. 1 will
544
+ * direct to the root domain (home page), which assumes you have a
545
+ * log-in form there; 2 directs to wp-login.php. Default: 2.
546
+ * @type string $redirect The URL the user will be redirected to after successfully
547
+ * logging in. Default: the URL originally requested.
548
+ * @type string $root The root URL of the site, used in case of error or mode 1 redirects.
549
+ * Default: the value of {@link bp_get_root_domain()}.
550
+ * @type string $message An error message to display to the user on the log-in page.
551
+ * Default: "You must log in to access the page you requested."
 
552
  * }
553
  */
554
  function bp_core_no_access( $args = '' ) {
570
  /**
571
  * Filters the arguments used for user redirecting when visiting access controlled areas.
572
  *
573
+ * @since 1.6.0
574
  *
575
  * @param array $r Array of parsed arguments for redirect determination.
576
  */
624
  *
625
  * Hooks into the "bpnoaccess" action defined in bp_core_no_access().
626
  *
627
+ * @since 1.5.0
628
  *
629
+ * @global string $error Error message to pass to wp-login.php.
630
  */
631
  function bp_core_no_access_wp_login_error() {
632
  global $error;
634
  /**
635
  * Filters the error message for wp-login.php when needing to log in before accessing.
636
  *
637
+ * @since 1.5.0
638
  *
639
  * @param string $value Error message to display.
640
  * @param string $value URL to redirect user to after successful login.
655
  * URL - eg, example.com/groups/mygroup/ instead of
656
  * example.com/groups/mygroup/home/.
657
  *
658
+ * @since 1.6.0
659
  *
660
  * @see BP_Members_Component::setup_globals() where
661
  * $bp->canonical_stack['base_url'] and ['component'] may be set.
668
  /**
669
  * Filters whether or not to do canonical redirects on BuddyPress URLs.
670
  *
671
+ * @since 1.6.0
672
  *
673
  * @param bool $value Whether or not to do canonical redirects. Default true.
674
  */
717
  /**
718
  * Output rel=canonical header tag for BuddyPress content.
719
  *
720
+ * @since 1.6.0
721
  */
722
  function bp_rel_canonical() {
723
  $canonical_url = bp_get_canonical_url();
729
  /**
730
  * Get the canonical URL of the current page.
731
  *
732
+ * @since 1.6.0
733
  *
734
  * @uses apply_filters() Filter bp_get_canonical_url to modify return value.
735
  *
736
  * @param array $args {
737
  * Optional array of arguments.
738
  * @type bool $include_query_args Whether to include current URL arguments
739
+ * in the canonical URL returned from the function.
740
  * }
741
+ *
742
  * @return string Canonical URL for the current page.
743
  */
744
  function bp_get_canonical_url( $args = array() ) {
777
  /**
778
  * Filters the logged in register page redirect URL.
779
  *
780
+ * @since 1.5.1
781
  *
782
  * @param string $value URL to redirect logged in members to.
783
  */
825
  /**
826
  * Filters the canonical url of the current page.
827
  *
828
+ * @since 1.6.0
829
  *
830
  * @param string $canonical_url Canonical URL of the current page.
831
  * @param array $args Array of arguments to help determine canonical URL.
836
  /**
837
  * Return the URL as requested on the current page load by the user agent.
838
  *
839
+ * @since 1.6.0
840
  *
841
  * @return string Requested URL string.
842
  */
851
  /**
852
  * Filters the URL as requested on the current page load by the user agent.
853
  *
854
+ * @since 1.7.0
855
  *
856
  * @param string $value Requested URL string.
857
  */
867
  * This function should be considered temporary, and may be removed without
868
  * notice in future versions of BuddyPress.
869
  *
870
+ * @since 1.6.0
871
  *
872
  * @uses bp_is_blog_page()
873
  */
899
  * This function will be removed in a later version of BuddyPress. Plugins
900
  * (and plugin authors!) should ignore it.
901
  *
902
+ * @since 1.6.1
903
  *
904
  * @link https://buddypress.trac.wordpress.org/ticket/4329
905
  * @link https://buddypress.trac.wordpress.org/ticket/4415
918
  * This function should be considered temporary, and may be removed without
919
  * notice in future versions of BuddyPress.
920
  *
921
+ * @since 1.6.0
922
  */
923
  function _bp_maybe_remove_rel_canonical() {
924
  if ( ! bp_is_blog_page() && ! is_404() ) {
bp-core/bp-core-classes.php CHANGED
@@ -6,7 +6,7 @@
6
  * @subpackage Core
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  require dirname( __FILE__ ) . '/classes/class-bp-user-query.php';
@@ -23,3 +23,4 @@ require dirname( __FILE__ ) . '/classes/class-bp-recursive-query.php';
23
  require dirname( __FILE__ ) . '/classes/class-bp-media-extractor.php';
24
  require dirname( __FILE__ ) . '/classes/class-bp-attachment.php';
25
  require dirname( __FILE__ ) . '/classes/class-bp-attachment-avatar.php';
 
6
  * @subpackage Core
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  require dirname( __FILE__ ) . '/classes/class-bp-user-query.php';
23
  require dirname( __FILE__ ) . '/classes/class-bp-media-extractor.php';
24
  require dirname( __FILE__ ) . '/classes/class-bp-attachment.php';
25
  require dirname( __FILE__ ) . '/classes/class-bp-attachment-avatar.php';
26
+ require dirname( __FILE__ ) . '/classes/class-bp-attachment-cover-image.php';
bp-core/bp-core-component.php CHANGED
@@ -6,10 +6,11 @@
6
  * @subpackage Core
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  if ( !class_exists( 'BP_Component' ) ) :
 
13
  /**
14
  * BuddyPress Component Class.
15
  *
@@ -21,7 +22,7 @@ if ( !class_exists( 'BP_Component' ) ) :
21
  * @package BuddyPress
22
  * @subpackage Component
23
  *
24
- * @since BuddyPress (1.5.0)
25
  */
26
  class BP_Component {
27
 
@@ -94,7 +95,7 @@ class BP_Component {
94
  /**
95
  * Placeholder text for component directory search box.
96
  *
97
- * @since BuddyPress (1.5.0)
98
  * @var string $search_string
99
  */
100
  public $search_string = '';
@@ -102,37 +103,46 @@ class BP_Component {
102
  /**
103
  * Root slug for the component.
104
  *
105
- * @since BuddyPress (1.5.0)
106
  * @var string $root_slug
107
  */
108
  public $root_slug = '';
109
 
110
  /**
111
- * Metadata tables for the component (if applicable)
112
  *
113
- * @since BuddyPress (2.0.0)
114
  *
115
  * @var array
116
  */
117
  public $meta_tables = array();
118
 
119
  /**
120
- * Global tables for the component (if applicable)
121
  *
122
- * @since BuddyPress (2.0.0)
123
  *
124
  * @var array
125
  */
126
  public $global_tables = array();
127
 
 
 
 
 
 
 
 
 
128
  /** Methods ***************************************************************/
129
 
130
  /**
131
  * Component loader.
132
  *
133
- * @since BuddyPress (1.5.0)
134
- * @since BuddyPress (1.9.0) Added $params as a parameter.
135
- * @since BuddyPress (2.3.0) Added $params['features'] as a configurable value.
 
136
  *
137
  * @param string $id Unique ID. Letters, numbers, and underscores only.
138
  * @param string $name Unique name. This should be a translatable name, eg.
@@ -140,11 +150,12 @@ class BP_Component {
140
  * @param string $path The file path for the component's files. Used by {@link BP_Component::includes()}.
141
  * @param array $params {
142
  * Additional parameters used by the component.
143
- * @type int $adminbar_myaccount_order Set the position for our menu under the WP Toolbar's "My Account menu"
144
- * @type array $features An array of feature names. This is used to load additional files from your
145
- * component directory and for feature active checks. eg. array( 'awesome' )
146
- * would look for a file called "bp-{$this->id}-awesome.php" and you could use
147
- * bp_is_active( $this->id, 'awesome' ) to determine if the feature is active.
 
148
  * }
149
  */
150
  public function start( $id = '', $name = '', $path = '', $params = array() ) {
@@ -170,6 +181,10 @@ class BP_Component {
170
  $this->features = array_map( 'sanitize_title', (array) $params['features'] );
171
  }
172
 
 
 
 
 
173
  // Set defaults if not passed
174
  } else {
175
  // new component menus are added before the settings menu if not set
@@ -183,7 +198,7 @@ class BP_Component {
183
  /**
184
  * Set up component global variables.
185
  *
186
- * @since BuddyPress (1.5)
187
  *
188
  * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_id'.
189
  * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_slug'.
@@ -226,7 +241,7 @@ class BP_Component {
226
  /**
227
  * Filters the slug to be used for the permalink URI chunk after root.
228
  *
229
- * @since BuddyPress (1.5.0)
230
  *
231
  * @param string $value Slug to use in permalink URI chunk.
232
  */
@@ -235,7 +250,7 @@ class BP_Component {
235
  /**
236
  * Filters the slug used for root directory.
237
  *
238
- * @since BuddyPress (1.5.0)
239
  *
240
  * @param string $value Root directory slug.
241
  */
@@ -244,7 +259,7 @@ class BP_Component {
244
  /**
245
  * Filters the component's top-level directory if available.
246
  *
247
- * @since BuddyPress (1.5.0)
248
  *
249
  * @param bool $value Whether or not there is a top-level directory.
250
  */
@@ -253,7 +268,7 @@ class BP_Component {
253
  /**
254
  * Filters the component's directory title.
255
  *
256
- * @since BuddyPress (2.0.0)
257
  *
258
  * @param string $value Title to use for the directory.
259
  */
@@ -262,7 +277,7 @@ class BP_Component {
262
  /**
263
  * Filters the placeholder text for search inputs for component.
264
  *
265
- * @since BuddyPress (1.5.0)
266
  *
267
  * @param string $value Name to use in search input placeholders.
268
  */
@@ -271,7 +286,7 @@ class BP_Component {
271
  /**
272
  * Filters the callable function that formats the component's notifications.
273
  *
274
- * @since BuddyPress (1.5.0)
275
  *
276
  * @param string $value Function callback.
277
  */
@@ -297,7 +312,7 @@ class BP_Component {
297
  *
298
  * This is a dynamic hook that is based on the component string ID.
299
  *
300
- * @since BuddyPress (1.5.0)
301
  */
302
  do_action( 'bp_' . $this->id . '_setup_globals' );
303
  }
@@ -325,12 +340,12 @@ class BP_Component {
325
  * - ./bp-my_component/actions
326
  * - ./bp-my_component/bp-my_component-actions.php
327
  *
328
- * @since BuddyPress (1.5.0)
329
  *
330
  * @uses do_action() Calls 'bp_{@link bp_Component::name}includes'.
331
  *
332
  * @param array $includes An array of file names, or file name chunks,
333
- * to be parsed and then included.
334
  */
335
  public function includes( $includes = array() ) {
336
 
@@ -368,7 +383,7 @@ class BP_Component {
368
  *
369
  * This is a dynamic hook that is based on the component string ID.
370
  *
371
- * @since BuddyPress (1.5.0)
372
  */
373
  do_action( 'bp_' . $this->id . '_includes' );
374
  }
@@ -376,7 +391,7 @@ class BP_Component {
376
  /**
377
  * Set up the actions.
378
  *
379
- * @since BuddyPress (1.5.0)
380
  *
381
  * @uses add_action() To add various actions.
382
  * @uses do_action() Calls 'bp_{@link BP_Component::name}setup_actions'.
@@ -434,7 +449,7 @@ class BP_Component {
434
  *
435
  * This is a dynamic hook that is based on the component string ID.
436
  *
437
- * @since BuddyPress (1.5.0)
438
  */
439
  do_action( 'bp_' . $this->id . '_setup_actions' );
440
  }
@@ -442,7 +457,7 @@ class BP_Component {
442
  /**
443
  * Set up the canonical URL stack for this component.
444
  *
445
- * @since BuddyPress (2.1.0)
446
  */
447
  public function setup_canonical_stack() {}
448
 
@@ -454,11 +469,11 @@ class BP_Component {
454
  * @see bp_core_new_subnav_item() For a description of how each item
455
  * in the $sub_nav parameter array should be formatted.
456
  *
457
- * @param array $main_nav Optional. Passed directly to
458
- * bp_core_new_nav_item(). See that function for a description.
459
- * @param array $sub_nav Optional. Multidimensional array, each item in
460
- * which is passed to bp_core_new_subnav_item(). See that
461
- * function for a description.
462
  */
463
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
464
 
@@ -479,7 +494,7 @@ class BP_Component {
479
  *
480
  * This is a dynamic hook that is based on the component string ID.
481
  *
482
- * @since BuddyPress (1.5.0)
483
  */
484
  do_action( 'bp_' . $this->id . '_setup_nav' );
485
  }
@@ -489,12 +504,12 @@ class BP_Component {
489
  *
490
  * @see WP_Admin_Bar::add_menu() for a description of the syntax
491
  * required by each item in the $wp_admin_nav parameter array.
492
- * @global obj $wp_admin_bar
493
  *
494
- * @param array $wp_admin_nav An array of nav item arguments. Each item
495
- * in this parameter array is passed to {@link WP_Admin_Bar::add_menu()}.
496
- * See that method for a description of the required syntax for
497
- * each item.
498
  */
499
  public function setup_admin_bar( $wp_admin_nav = array() ) {
500
 
@@ -513,7 +528,7 @@ class BP_Component {
513
  *
514
  * This is a dynamic hook that is based on the component string ID.
515
  *
516
- * @since BuddyPress (1.9.0)
517
  *
518
  * @param array $wp_admin_nav Array of navigation items to add.
519
  */
@@ -539,7 +554,7 @@ class BP_Component {
539
  *
540
  * This is a dynamic hook that is based on the component string ID.
541
  *
542
- * @since BuddyPress (1.5.0)
543
  */
544
  do_action( 'bp_' . $this->id . '_setup_admin_bar' );
545
  }
@@ -547,7 +562,7 @@ class BP_Component {
547
  /**
548
  * Set up the component title.
549
  *
550
- * @since BuddyPress (1.5.0)
551
  *
552
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_setup_title'.
553
  */
@@ -558,7 +573,7 @@ class BP_Component {
558
  *
559
  * This is a dynamic hook that is based on the component string ID.
560
  *
561
- * @since BuddyPress (1.5.0)
562
  */
563
  do_action( 'bp_' . $this->id . '_setup_title' );
564
  }
@@ -566,7 +581,7 @@ class BP_Component {
566
  /**
567
  * Setup component-specific cache groups.
568
  *
569
- * @since BuddyPress (2.2.0)
570
  *
571
  * @uses do_action() Calls 'bp_setup_{@link bp_Component::name}_cache_groups'.
572
  */
@@ -577,7 +592,7 @@ class BP_Component {
577
  *
578
  * This is a dynamic hook that is based on the component string ID.
579
  *
580
- * @since BuddyPress (2.2.0)
581
  */
582
  do_action( 'bp_' . $this->id . '_setup_cache_groups' );
583
  }
@@ -585,9 +600,9 @@ class BP_Component {
585
  /**
586
  * Register global tables for the component, so that it may use WordPress's database API.
587
  *
588
- * @since BuddyPress (2.0.0)
589
  *
590
- * @param array $tables
591
  */
592
  public function register_global_tables( $tables = array() ) {
593
 
@@ -598,7 +613,7 @@ class BP_Component {
598
  * It allows for component-specific filtering of table names. To filter
599
  * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
600
  *
601
- * @since BuddyPress (1.6.0)
602
  */
603
  $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
604
 
@@ -617,7 +632,7 @@ class BP_Component {
617
  *
618
  * This is a dynamic hook that is based on the component string ID.
619
  *
620
- * @since BuddyPress (2.0.0)
621
  */
622
  do_action( 'bp_' . $this->id . '_register_global_tables' );
623
  }
@@ -628,9 +643,9 @@ class BP_Component {
628
  * Metadata tables are registered in the $wpdb global, for
629
  * compatibility with the WordPress metadata API.
630
  *
631
- * @since BuddyPress (2.0.0)
632
  *
633
- * @param array $tables
634
  */
635
  public function register_meta_tables( $tables = array() ) {
636
  global $wpdb;
@@ -642,7 +657,7 @@ class BP_Component {
642
  * It allows for component-specific filtering of table names. To filter
643
  * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
644
  *
645
- * @since BuddyPress (2.0.0)
646
  */
647
  $tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables );
648
 
@@ -664,7 +679,7 @@ class BP_Component {
664
  *
665
  * This is a dynamic hook that is based on the component string ID.
666
  *
667
- * @since BuddyPress (2.0.0)
668
  */
669
  do_action( 'bp_' . $this->id . '_register_meta_tables' );
670
  }
@@ -672,7 +687,7 @@ class BP_Component {
672
  /**
673
  * Set up the component post types.
674
  *
675
- * @since BuddyPress (1.5.0)
676
  *
677
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_post_types'.
678
  */
@@ -683,7 +698,7 @@ class BP_Component {
683
  *
684
  * This is a dynamic hook that is based on the component string ID.
685
  *
686
- * @since BuddyPress (1.5.0)
687
  */
688
  do_action( 'bp_' . $this->id . '_register_post_types' );
689
  }
@@ -691,7 +706,7 @@ class BP_Component {
691
  /**
692
  * Register component-specific taxonomies.
693
  *
694
- * @since BuddyPress (1.5.0)
695
  *
696
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_taxonomies'.
697
  */
@@ -702,7 +717,7 @@ class BP_Component {
702
  *
703
  * This is a dynamic hook that is based on the component string ID.
704
  *
705
- * @since BuddyPress (1.5.0)
706
  */
707
  do_action( 'bp_' . $this->id . '_register_taxonomies' );
708
  }
@@ -710,7 +725,7 @@ class BP_Component {
710
  /**
711
  * Add any additional rewrite tags.
712
  *
713
- * @since BuddyPress (1.5.0)
714
  *
715
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_tags'.
716
  */
@@ -721,7 +736,7 @@ class BP_Component {
721
  *
722
  * This is a dynamic hook that is based on the component string ID.
723
  *
724
- * @since BuddyPress (1.5.0)
725
  */
726
  do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
727
  }
@@ -729,7 +744,7 @@ class BP_Component {
729
  /**
730
  * Add any additional rewrite rules.
731
  *
732
- * @since BuddyPress (1.9.0)
733
  *
734
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_rules'.
735
  */
@@ -740,17 +755,17 @@ class BP_Component {
740
  *
741
  * This is a dynamic hook that is based on the component string ID.
742
  *
743
- * @since BuddyPress (1.9.0)
744
  */
745
  do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
746
  }
747
 
748
  /**
749
- * Add any permalink structures
750
  *
751
- * @since BuddyPress (1.9)
752
  *
753
- * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_permastruct'
754
  */
755
  public function add_permastructs() {
756
 
@@ -759,18 +774,19 @@ class BP_Component {
759
  *
760
  * This is a dynamic hook that is based on the component string ID.
761
  *
762
- * @since BuddyPress (1.9.0)
763
  */
764
  do_action( 'bp_' . $this->id . '_add_permastructs' );
765
  }
766
 
767
  /**
768
- * Allow components to parse the main query
 
 
769
  *
770
- * @since BuddyPress (1.9)
771
  *
772
- * @uses do_action() Calls 'bp_{@link bp_Component::name}_parse_query'
773
- * @param object The main WP_Query
774
  */
775
  public function parse_query( $query ) {
776
 
@@ -779,7 +795,7 @@ class BP_Component {
779
  *
780
  * This is a dynamic hook that is based on the component string ID.
781
  *
782
- * @since BuddyPress (1.9.0)
783
  *
784
  * @param object $query Main WP_Query object. Passed by reference.
785
  */
@@ -787,11 +803,11 @@ class BP_Component {
787
  }
788
 
789
  /**
790
- * Generate any additional rewrite rules
791
  *
792
- * @since BuddyPress (1.5)
793
  *
794
- * @uses do_action() Calls 'bp_{@link bp_Component::name}_generate_rewrite_rules'
795
  */
796
  public function generate_rewrite_rules() {
797
 
@@ -800,9 +816,9 @@ class BP_Component {
800
  *
801
  * This is a dynamic hook that is based on the component string ID.
802
  *
803
- * @since BuddyPress (1.5.0)
804
  */
805
  do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
806
  }
807
  }
808
- endif; // BP_Component
6
  * @subpackage Core
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  if ( !class_exists( 'BP_Component' ) ) :
13
+
14
  /**
15
  * BuddyPress Component Class.
16
  *
22
  * @package BuddyPress
23
  * @subpackage Component
24
  *
25
+ * @since 1.5.0
26
  */
27
  class BP_Component {
28
 
95
  /**
96
  * Placeholder text for component directory search box.
97
  *
98
+ * @since 1.5.0
99
  * @var string $search_string
100
  */
101
  public $search_string = '';
103
  /**
104
  * Root slug for the component.
105
  *
106
+ * @since 1.5.0
107
  * @var string $root_slug
108
  */
109
  public $root_slug = '';
110
 
111
  /**
112
+ * Metadata tables for the component (if applicable).
113
  *
114
+ * @since 2.0.0
115
  *
116
  * @var array
117
  */
118
  public $meta_tables = array();
119
 
120
  /**
121
+ * Global tables for the component (if applicable).
122
  *
123
+ * @since 2.0.0
124
  *
125
  * @var array
126
  */
127
  public $global_tables = array();
128
 
129
+ /**
130
+ * Query argument for component search URLs.
131
+ *
132
+ * @since 2.4.0
133
+ * @var string
134
+ */
135
+ public $search_query_arg = 's';
136
+
137
  /** Methods ***************************************************************/
138
 
139
  /**
140
  * Component loader.
141
  *
142
+ * @since 1.5.0
143
+ * @since 1.9.0 Added $params as a parameter.
144
+ * @since 2.3.0 Added $params['features'] as a configurable value.
145
+ * @since 2.4.0 Added $params['search_query_arg'] as a configurable value.
146
  *
147
  * @param string $id Unique ID. Letters, numbers, and underscores only.
148
  * @param string $name Unique name. This should be a translatable name, eg.
150
  * @param string $path The file path for the component's files. Used by {@link BP_Component::includes()}.
151
  * @param array $params {
152
  * Additional parameters used by the component.
153
+ * @type int $adminbar_myaccount_order Set the position for our menu under the WP Toolbar's "My Account menu".
154
+ * @type array $features An array of feature names. This is used to load additional files from your
155
+ * component directory and for feature active checks. eg. array( 'awesome' )
156
+ * would look for a file called "bp-{$this->id}-awesome.php" and you could use
157
+ * bp_is_active( $this->id, 'awesome' ) to determine if the feature is active.
158
+ * @type string $search_query_arg String to be used as the query argument in component search URLs.
159
  * }
160
  */
161
  public function start( $id = '', $name = '', $path = '', $params = array() ) {
181
  $this->features = array_map( 'sanitize_title', (array) $params['features'] );
182
  }
183
 
184
+ if ( ! empty( $params['search_query_arg'] ) ) {
185
+ $this->search_query_arg = sanitize_title( $params['search_query_arg'] );
186
+ }
187
+
188
  // Set defaults if not passed
189
  } else {
190
  // new component menus are added before the settings menu if not set
198
  /**
199
  * Set up component global variables.
200
  *
201
+ * @since 1.5.0
202
  *
203
  * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_id'.
204
  * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_slug'.
241
  /**
242
  * Filters the slug to be used for the permalink URI chunk after root.
243
  *
244
+ * @since 1.5.0
245
  *
246
  * @param string $value Slug to use in permalink URI chunk.
247
  */
250
  /**
251
  * Filters the slug used for root directory.
252
  *
253
+ * @since 1.5.0
254
  *
255
  * @param string $value Root directory slug.
256
  */
259
  /**
260
  * Filters the component's top-level directory if available.
261
  *
262
+ * @since 1.5.0
263
  *
264
  * @param bool $value Whether or not there is a top-level directory.
265
  */
268
  /**
269
  * Filters the component's directory title.
270
  *
271
+ * @since 2.0.0
272
  *
273
  * @param string $value Title to use for the directory.
274
  */
277
  /**
278
  * Filters the placeholder text for search inputs for component.
279
  *
280
+ * @since 1.5.0
281
  *
282
  * @param string $value Name to use in search input placeholders.
283
  */
286
  /**
287
  * Filters the callable function that formats the component's notifications.
288
  *
289
+ * @since 1.5.0
290
  *
291
  * @param string $value Function callback.
292
  */
312
  *
313
  * This is a dynamic hook that is based on the component string ID.
314
  *
315
+ * @since 1.5.0
316
  */
317
  do_action( 'bp_' . $this->id . '_setup_globals' );
318
  }
340
  * - ./bp-my_component/actions
341
  * - ./bp-my_component/bp-my_component-actions.php
342
  *
343
+ * @since 1.5.0
344
  *
345
  * @uses do_action() Calls 'bp_{@link bp_Component::name}includes'.
346
  *
347
  * @param array $includes An array of file names, or file name chunks,
348
+ * to be parsed and then included.
349
  */
350
  public function includes( $includes = array() ) {
351
 
383
  *
384
  * This is a dynamic hook that is based on the component string ID.
385
  *
386
+ * @since 1.5.0
387
  */
388
  do_action( 'bp_' . $this->id . '_includes' );
389
  }
391
  /**
392
  * Set up the actions.
393
  *
394
+ * @since 1.5.0
395
  *
396
  * @uses add_action() To add various actions.
397
  * @uses do_action() Calls 'bp_{@link BP_Component::name}setup_actions'.
449
  *
450
  * This is a dynamic hook that is based on the component string ID.
451
  *
452
+ * @since 1.5.0
453
  */
454
  do_action( 'bp_' . $this->id . '_setup_actions' );
455
  }
457
  /**
458
  * Set up the canonical URL stack for this component.
459
  *
460
+ * @since 2.1.0
461
  */
462
  public function setup_canonical_stack() {}
463
 
469
  * @see bp_core_new_subnav_item() For a description of how each item
470
  * in the $sub_nav parameter array should be formatted.
471
  *
472
+ * @param array $main_nav Optional. Passed directly to bp_core_new_nav_item().
473
+ * See that function for a description.
474
+ * @param array $sub_nav Optional. Multidimensional array, each item in
475
+ * which is passed to bp_core_new_subnav_item(). See that
476
+ * function for a description.
477
  */
478
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
479
 
494
  *
495
  * This is a dynamic hook that is based on the component string ID.
496
  *
497
+ * @since 1.5.0
498
  */
499
  do_action( 'bp_' . $this->id . '_setup_nav' );
500
  }
504
  *
505
  * @see WP_Admin_Bar::add_menu() for a description of the syntax
506
  * required by each item in the $wp_admin_nav parameter array.
507
+ * @global object $wp_admin_bar
508
  *
509
+ * @param array $wp_admin_nav An array of nav item arguments. Each item in this parameter
510
+ * array is passed to {@link WP_Admin_Bar::add_menu()}.
511
+ * See that method for a description of the required syntax for
512
+ * each item.
513
  */
514
  public function setup_admin_bar( $wp_admin_nav = array() ) {
515
 
528
  *
529
  * This is a dynamic hook that is based on the component string ID.
530
  *
531
+ * @since 1.9.0
532
  *
533
  * @param array $wp_admin_nav Array of navigation items to add.
534
  */
554
  *
555
  * This is a dynamic hook that is based on the component string ID.
556
  *
557
+ * @since 1.5.0
558
  */
559
  do_action( 'bp_' . $this->id . '_setup_admin_bar' );
560
  }
562
  /**
563
  * Set up the component title.
564
  *
565
+ * @since 1.5.0
566
  *
567
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_setup_title'.
568
  */
573
  *
574
  * This is a dynamic hook that is based on the component string ID.
575
  *
576
+ * @since 1.5.0
577
  */
578
  do_action( 'bp_' . $this->id . '_setup_title' );
579
  }
581
  /**
582
  * Setup component-specific cache groups.
583
  *
584
+ * @since 2.2.0
585
  *
586
  * @uses do_action() Calls 'bp_setup_{@link bp_Component::name}_cache_groups'.
587
  */
592
  *
593
  * This is a dynamic hook that is based on the component string ID.
594
  *
595
+ * @since 2.2.0
596
  */
597
  do_action( 'bp_' . $this->id . '_setup_cache_groups' );
598
  }
600
  /**
601
  * Register global tables for the component, so that it may use WordPress's database API.
602
  *
603
+ * @since 2.0.0
604
  *
605
+ * @param array $tables Table names to register.
606
  */
607
  public function register_global_tables( $tables = array() ) {
608
 
613
  * It allows for component-specific filtering of table names. To filter
614
  * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
615
  *
616
+ * @since 1.6.0
617
  */
618
  $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
619
 
632
  *
633
  * This is a dynamic hook that is based on the component string ID.
634
  *
635
+ * @since 2.0.0
636
  */
637
  do_action( 'bp_' . $this->id . '_register_global_tables' );
638
  }
643
  * Metadata tables are registered in the $wpdb global, for
644
  * compatibility with the WordPress metadata API.
645
  *
646
+ * @since 2.0.0
647
  *
648
+ * @param array $tables Table names to register.
649
  */
650
  public function register_meta_tables( $tables = array() ) {
651
  global $wpdb;
657
  * It allows for component-specific filtering of table names. To filter
658
  * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
659
  *
660
+ * @since 2.0.0
661
  */
662
  $tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables );
663
 
679
  *
680
  * This is a dynamic hook that is based on the component string ID.
681
  *
682
+ * @since 2.0.0
683
  */
684
  do_action( 'bp_' . $this->id . '_register_meta_tables' );
685
  }
687
  /**
688
  * Set up the component post types.
689
  *
690
+ * @since 1.5.0
691
  *
692
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_post_types'.
693
  */
698
  *
699
  * This is a dynamic hook that is based on the component string ID.
700
  *
701
+ * @since 1.5.0
702
  */
703
  do_action( 'bp_' . $this->id . '_register_post_types' );
704
  }
706
  /**
707
  * Register component-specific taxonomies.
708
  *
709
+ * @since 1.5.0
710
  *
711
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_taxonomies'.
712
  */
717
  *
718
  * This is a dynamic hook that is based on the component string ID.
719
  *
720
+ * @since 1.5.0
721
  */
722
  do_action( 'bp_' . $this->id . '_register_taxonomies' );
723
  }
725
  /**
726
  * Add any additional rewrite tags.
727
  *
728
+ * @since 1.5.0
729
  *
730
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_tags'.
731
  */
736
  *
737
  * This is a dynamic hook that is based on the component string ID.
738
  *
739
+ * @since 1.5.0
740
  */
741
  do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
742
  }
744
  /**
745
  * Add any additional rewrite rules.
746
  *
747
+ * @since 1.9.0
748
  *
749
  * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_rules'.
750
  */
755
  *
756
  * This is a dynamic hook that is based on the component string ID.
757
  *
758
+ * @since 1.9.0
759
  */
760
  do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
761
  }
762
 
763
  /**
764
+ * Add any permalink structures.
765
  *
766
+ * @since 1.9.0
767
  *
768
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_permastruct'.
769
  */
770
  public function add_permastructs() {
771
 
774
  *
775
  * This is a dynamic hook that is based on the component string ID.
776
  *
777
+ * @since 1.9.0
778
  */
779
  do_action( 'bp_' . $this->id . '_add_permastructs' );
780
  }
781
 
782
  /**
783
+ * Allow components to parse the main query.
784
+ *
785
+ * @since 1.9.0
786
  *
787
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_parse_query'.
788
  *
789
+ * @param object $query The main WP_Query.
 
790
  */
791
  public function parse_query( $query ) {
792
 
795
  *
796
  * This is a dynamic hook that is based on the component string ID.
797
  *
798
+ * @since 1.9.0
799
  *
800
  * @param object $query Main WP_Query object. Passed by reference.
801
  */
803
  }
804
 
805
  /**
806
+ * Generate any additional rewrite rules.
807
  *
808
+ * @since 1.5.0
809
  *
810
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_generate_rewrite_rules'.
811
  */
812
  public function generate_rewrite_rules() {
813
 
816
  *
817
  * This is a dynamic hook that is based on the component string ID.
818
  *
819
+ * @since 1.5.0
820
  */
821
  do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
822
  }
823
  }
824
+ endif; // BP_Component.
bp-core/bp-core-cssjs.php CHANGED
@@ -6,13 +6,13 @@
6
  * @subpackage Core
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Register scripts commonly used by BuddyPress.
14
  *
15
- * @since BuddyPress (2.1.0)
16
  */
17
  function bp_core_register_common_scripts() {
18
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -21,7 +21,7 @@ function bp_core_register_common_scripts() {
21
  /**
22
  * Filters the BuddyPress Core javascript files to register.
23
  *
24
- * @since BuddyPress (2.1.0)
25
  *
26
  * @param array $value Array of javascript file information to register.
27
  */
@@ -43,6 +43,9 @@ function bp_core_register_common_scripts() {
43
  'bp-avatar' => array( 'file' => "{$url}avatar{$min}.js", 'dependencies' => array( 'jcrop' ), 'footer' => true ),
44
  'bp-webcam' => array( 'file' => "{$url}webcam{$min}.js", 'dependencies' => array( 'bp-avatar' ), 'footer' => true ),
45
 
 
 
 
46
  ) );
47
 
48
  $version = bp_get_version();
@@ -56,7 +59,7 @@ add_action( 'bp_admin_enqueue_scripts', 'bp_core_register_common_scripts', 1 );
56
  /**
57
  * Register styles commonly used by BuddyPress.
58
  *
59
- * @since BuddyPress (2.1.0)
60
  */
61
  function bp_core_register_common_styles() {
62
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -65,7 +68,7 @@ function bp_core_register_common_styles() {
65
  /**
66
  * Filters the URL for the Admin Bar stylesheet.
67
  *
68
- * @since BuddyPress (1.1.0)
69
  *
70
  * @param string $value URL for the Admin Bar stylesheet.
71
  */
@@ -74,7 +77,7 @@ function bp_core_register_common_styles() {
74
  /**
75
  * Filters the BuddyPress Core stylesheet files to register.
76
  *
77
- * @since BuddyPress (2.1.0)
78
  *
79
  * @param array $value Array of stylesheet file information to register.
80
  */
@@ -120,9 +123,9 @@ add_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' );
120
  add_action( 'bp_admin_enqueue_scripts', 'bp_core_confirmation_js' );
121
 
122
  /**
123
- * Enqueues the css and js required by the Avatar UI
124
  *
125
- * @since BuddyPress (2.3.0)
126
  */
127
  function bp_core_avatar_scripts() {
128
  if ( ! bp_avatar_is_front_edit() ) {
@@ -139,6 +142,21 @@ function bp_core_avatar_scripts() {
139
  }
140
  add_action( 'bp_enqueue_scripts', 'bp_core_avatar_scripts' );
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  /**
143
  * Enqueues jCrop library and hooks BP's custom cropper JS.
144
  */
@@ -157,7 +175,7 @@ function bp_core_add_cropper_inline_js() {
157
  /**
158
  * Filters the return value of getimagesize to determine if an image was uploaded.
159
  *
160
- * @since BuddyPress (1.1.0)
161
  *
162
  * @param array $value Array of data found by getimagesize.
163
  */
@@ -277,7 +295,7 @@ function bp_core_add_cropper_inline_css() {
277
  /**
278
  * Define the 'ajaxurl' JS variable, used by themes as an AJAX endpoint.
279
  *
280
- * @since BuddyPress (1.1.0)
281
  */
282
  function bp_core_add_ajax_url_js() {
283
  ?>
@@ -294,7 +312,7 @@ add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
294
  * Designed to be sensitive to FORCE_SSL_ADMIN and non-standard multisite
295
  * configurations.
296
  *
297
- * @since BuddyPress (1.7.0)
298
  *
299
  * @return string AJAX endpoint URL.
300
  */
@@ -303,7 +321,7 @@ function bp_core_ajax_url() {
303
  /**
304
  * Filters the proper value for BuddyPress' ajaxurl.
305
  *
306
- * @since BuddyPress (1.7.0)
307
  *
308
  * @param string $value Proper ajaxurl value for BuddyPress.
309
  */
@@ -313,9 +331,9 @@ function bp_core_ajax_url() {
313
  /**
314
  * Get the JavaScript dependencies for buddypress.js.
315
  *
316
- * @since BuddyPress (2.0.0)
317
  *
318
- * @uses apply_filters() to allow other component to load extra dependencies
319
  *
320
  * @return array The JavaScript dependencies.
321
  */
@@ -324,7 +342,7 @@ function bp_core_get_js_dependencies() {
324
  /**
325
  * Filters the javascript dependencies for buddypress.js.
326
  *
327
- * @since BuddyPress (2.0.0)
328
  *
329
  * @param array $value Array of javascript dependencies for buddypress.js.
330
  */
@@ -337,3 +355,104 @@ function bp_core_get_js_dependencies() {
337
  'bp-jquery-scroll-to'
338
  ) );
339
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  * @subpackage Core
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Register scripts commonly used by BuddyPress.
14
  *
15
+ * @since 2.1.0
16
  */
17
  function bp_core_register_common_scripts() {
18
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
21
  /**
22
  * Filters the BuddyPress Core javascript files to register.
23
  *
24
+ * @since 2.1.0
25
  *
26
  * @param array $value Array of javascript file information to register.
27
  */
43
  'bp-avatar' => array( 'file' => "{$url}avatar{$min}.js", 'dependencies' => array( 'jcrop' ), 'footer' => true ),
44
  'bp-webcam' => array( 'file' => "{$url}webcam{$min}.js", 'dependencies' => array( 'bp-avatar' ), 'footer' => true ),
45
 
46
+ // 2.4
47
+ 'bp-cover-image' => array( 'file' => "{$url}cover-image{$min}.js", 'dependencies' => array(), 'footer' => true ),
48
+
49
  ) );
50
 
51
  $version = bp_get_version();
59
  /**
60
  * Register styles commonly used by BuddyPress.
61
  *
62
+ * @since 2.1.0
63
  */
64
  function bp_core_register_common_styles() {
65
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
68
  /**
69
  * Filters the URL for the Admin Bar stylesheet.
70
  *
71
+ * @since 1.1.0
72
  *
73
  * @param string $value URL for the Admin Bar stylesheet.
74
  */
77
  /**
78
  * Filters the BuddyPress Core stylesheet files to register.
79
  *
80
+ * @since 2.1.0
81
  *
82
  * @param array $value Array of stylesheet file information to register.
83
  */
123
  add_action( 'bp_admin_enqueue_scripts', 'bp_core_confirmation_js' );
124
 
125
  /**
126
+ * Enqueues the css and js required by the Avatar UI.
127
  *
128
+ * @since 2.3.0
129
  */
130
  function bp_core_avatar_scripts() {
131
  if ( ! bp_avatar_is_front_edit() ) {
142
  }
143
  add_action( 'bp_enqueue_scripts', 'bp_core_avatar_scripts' );
144
 
145
+ /**
146
+ * Enqueues the css and js required by the Cover Image UI.
147
+ *
148
+ * @since 2.4.0
149
+ */
150
+ function bp_core_cover_image_scripts() {
151
+ if ( ! bp_attachments_cover_image_is_edit() ) {
152
+ return false;
153
+ }
154
+
155
+ // Enqueue the Attachments scripts for the Cover Image UI
156
+ bp_attachments_enqueue_scripts( 'BP_Attachment_Cover_Image' );
157
+ }
158
+ add_action( 'bp_enqueue_scripts', 'bp_core_cover_image_scripts' );
159
+
160
  /**
161
  * Enqueues jCrop library and hooks BP's custom cropper JS.
162
  */
175
  /**
176
  * Filters the return value of getimagesize to determine if an image was uploaded.
177
  *
178
+ * @since 1.1.0
179
  *
180
  * @param array $value Array of data found by getimagesize.
181
  */
295
  /**
296
  * Define the 'ajaxurl' JS variable, used by themes as an AJAX endpoint.
297
  *
298
+ * @since 1.1.0
299
  */
300
  function bp_core_add_ajax_url_js() {
301
  ?>
312
  * Designed to be sensitive to FORCE_SSL_ADMIN and non-standard multisite
313
  * configurations.
314
  *
315
+ * @since 1.7.0
316
  *
317
  * @return string AJAX endpoint URL.
318
  */
321
  /**
322
  * Filters the proper value for BuddyPress' ajaxurl.
323
  *
324
+ * @since 1.7.0
325
  *
326
  * @param string $value Proper ajaxurl value for BuddyPress.
327
  */
331
  /**
332
  * Get the JavaScript dependencies for buddypress.js.
333
  *
334
+ * @since 2.0.0
335
  *
336
+ * @uses apply_filters() to allow other component to load extra dependencies.
337
  *
338
  * @return array The JavaScript dependencies.
339
  */
342
  /**
343
  * Filters the javascript dependencies for buddypress.js.
344
  *
345
+ * @since 2.0.0
346
  *
347
  * @param array $value Array of javascript dependencies for buddypress.js.
348
  */
355
  'bp-jquery-scroll-to'
356
  ) );
357
  }
358
+
359
+ /**
360
+ * Add inline css to display the component's single item cover image
361
+ *
362
+ * @since 2.4.0
363
+ *
364
+ * @param bool $return true to get the inline css
365
+ * @return string|array the inline css or an associative array containing
366
+ * the css rules and the style handle
367
+ */
368
+ function bp_add_cover_image_inline_css( $return = false ) {
369
+ $bp = buddypress();
370
+
371
+ // Find the component of the current item
372
+ if ( bp_is_user() ) {
373
+
374
+ // User is not allowed to upload cover images
375
+ // no need to carry on
376
+ if ( bp_disable_cover_image_uploads() ) {
377
+ return;
378
+ }
379
+
380
+ $cover_image_object = array(
381
+ 'component' => 'xprofile',
382
+ 'object' => $bp->displayed_user
383
+ );
384
+ } elseif ( bp_is_group() ) {
385
+
386
+ // Users are not allowed to upload cover images for their groups
387
+ // no need to carry on
388
+ if ( bp_disable_group_cover_image_uploads() ) {
389
+ return;
390
+ }
391
+
392
+ $cover_image_object = array(
393
+ 'component' =>'groups',
394
+ 'object' => $bp->groups->current_group
395
+ );
396
+ } else {
397
+ $cover_image_object = apply_filters( 'bp_current_cover_image_object_inline_css', array() );
398
+ }
399
+
400
+ // Bail if no component were found.
401
+ if ( empty( $cover_image_object['component'] ) || empty( $cover_image_object['object'] ) || ! bp_is_active( $cover_image_object['component'], 'cover_image' ) ) {
402
+ return;
403
+ }
404
+
405
+ // Get the settings of the cover image feature for the current component
406
+ $params = bp_attachments_get_cover_image_settings( $cover_image_object['component'] );
407
+
408
+ // Bail if no params.
409
+ if ( empty( $params ) ) {
410
+ return;
411
+ }
412
+
413
+ // Try to call the callback
414
+ if ( is_callable( $params['callback'] ) ) {
415
+
416
+ $object_dir = $cover_image_object['component'];
417
+
418
+ if ( 'xprofile' === $object_dir ) {
419
+ $object_dir = 'members';
420
+ }
421
+
422
+ $cover_image = bp_attachments_get_attachment( 'url', array(
423
+ 'object_dir' => $object_dir,
424
+ 'item_id' => $cover_image_object['object']->id,
425
+ ) );
426
+
427
+ if ( empty( $cover_image ) ) {
428
+ if ( ! empty( $params['default_cover'] ) ) {
429
+ $cover_image = $params['default_cover'];
430
+ }
431
+ }
432
+
433
+ $inline_css = call_user_func_array( $params['callback'], array( array(
434
+ 'cover_image' => esc_url( $cover_image ),
435
+ 'component' => sanitize_key( $cover_image_object['component'] ),
436
+ 'object_id' => (int) $cover_image_object['object']->id,
437
+ 'width' => (int) $params['width'],
438
+ 'height' => (int) $params['height'],
439
+ ) ) );
440
+
441
+ // Finally add the inline css to the handle
442
+ if ( ! empty( $inline_css ) ) {
443
+
444
+ // Used to get the css when Ajax setting the cover image
445
+ if ( true === $return ) {
446
+ return array(
447
+ 'css_rules' => '<style type="text/css">' . "\n" . $inline_css . "\n" . '</style>',
448
+ 'handle' => $params['theme_handle'],
449
+ );
450
+ }
451
+
452
+ wp_add_inline_style( $params['theme_handle'], $inline_css );
453
+ } else {
454
+ return false;
455
+ }
456
+ }
457
+ }
458
+ add_action( 'bp_enqueue_scripts', 'bp_add_cover_image_inline_css', 11 );
bp-core/bp-core-dependency.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Plugin Dependency Action Hooks.
5
  *
@@ -15,6 +14,9 @@
15
  * manually called and/or piggy-backed on top of other hooks if needed.
16
  *
17
  * @todo use anonymous functions when PHP minimum requirement allows (5.3)
 
 
 
18
  */
19
 
20
  /**
@@ -25,7 +27,7 @@ function bp_include() {
25
  /**
26
  * Fires inside the 'bp_include' function, where plugins should include files.
27
  *
28
- * @since BuddyPress (1.2.5)
29
  */
30
  do_action( 'bp_include' );
31
  }
@@ -38,7 +40,7 @@ function bp_setup_components() {
38
  /**
39
  * Fires inside the 'bp_setup_components' function, where plugins should initialize components.
40
  *
41
- * @since BuddyPress (1.6.0)
42
  */
43
  do_action( 'bp_setup_components' );
44
  }
@@ -51,7 +53,7 @@ function bp_setup_canonical_stack() {
51
  /**
52
  * Fires inside the 'bp_setup_canonical_stack' function, where plugins should set up their canonical URL.
53
  *
54
- * @since BuddyPress (2.1.0)
55
  */
56
  do_action( 'bp_setup_canonical_stack' );
57
  }
@@ -59,14 +61,14 @@ function bp_setup_canonical_stack() {
59
  /**
60
  * Fire the 'bp_register_taxonomies' action, where plugins should register taxonomies.
61
  *
62
- * @since BuddyPress (2.2.0)
63
  */
64
  function bp_register_taxonomies() {
65
 
66
  /**
67
  * Fires inside the 'bp_register_taxonomies' function, where plugins should register taxonomies.
68
  *
69
- * @since BuddyPress (2.2.0)
70
  */
71
  do_action( 'bp_register_taxonomies' );
72
  }
@@ -79,7 +81,7 @@ function bp_setup_globals() {
79
  /**
80
  * Fires inside the 'bp_setup_globals' function, where plugins should initialize global settings.
81
  *
82
- * @since BuddyPress (1.2.0)
83
  */
84
  do_action( 'bp_setup_globals' );
85
  }
@@ -92,7 +94,7 @@ function bp_setup_nav() {
92
  /**
93
  * Fires inside the 'bp_setup_nav' function, where plugins should register their navigation items.
94
  *
95
- * @since BuddyPress (1.2.0)
96
  */
97
  do_action( 'bp_setup_nav' );
98
  }
@@ -108,7 +110,7 @@ function bp_setup_admin_bar() {
108
  *
109
  * This hook will only fire if bp_use_wp_admin_bar() returns true.
110
  *
111
- * @since BuddyPress (1.5.0)
112
  */
113
  do_action( 'bp_setup_admin_bar' );
114
  }
@@ -122,7 +124,7 @@ function bp_setup_title() {
122
  /**
123
  * Fires inside the 'bp_setup_title' function, where plugins should modify the page title.
124
  *
125
- * @since BuddyPress (1.5.0)
126
  */
127
  do_action( 'bp_setup_title' );
128
  }
@@ -135,7 +137,7 @@ function bp_setup_widgets() {
135
  /**
136
  * Fires inside the 'bp_register_widgets' function, where plugins should register widgets.
137
  *
138
- * @since BuddyPress (1.2.0)
139
  */
140
  do_action( 'bp_register_widgets' );
141
  }
@@ -143,14 +145,14 @@ function bp_setup_widgets() {
143
  /**
144
  * Fire the 'bp_register_member_types' action, where plugins should register member types.
145
  *
146
- * @since BuddyPress (2.3.0)
147
  */
148
  function bp_register_member_types() {
149
 
150
  /**
151
  * Fires inside bp_register_member_types(), so plugins can register member types.
152
  *
153
- * @since BuddyPress (2.3.0)
154
  */
155
  do_action( 'bp_register_member_types' );
156
  }
@@ -158,14 +160,14 @@ function bp_register_member_types() {
158
  /**
159
  * Fire the 'bp_setup_cache_groups' action, where cache groups are registered.
160
  *
161
- * @since BuddyPress (2.2.0)
162
  */
163
  function bp_setup_cache_groups() {
164
 
165
  /**
166
  * Fires inside the 'bp_setup_cache_groups' function, where cache groups are registered.
167
  *
168
- * @since BuddyPress (2.2.0)
169
  */
170
  do_action( 'bp_setup_cache_groups' );
171
  }
@@ -192,7 +194,7 @@ function bp_setup_current_user() {
192
  /**
193
  * Fires to set up the current user setup process.
194
  *
195
- * @since BuddyPress (1.7.0)
196
  */
197
  do_action( 'bp_setup_current_user' );
198
  }
@@ -205,7 +207,7 @@ function bp_init() {
205
  /**
206
  * Fires inside the 'bp_init' function, BuddyPress' main initialization hook.
207
  *
208
- * @since BuddyPress (1.2.0)
209
  */
210
  do_action( 'bp_init' );
211
  }
@@ -220,7 +222,7 @@ function bp_loaded() {
220
  /**
221
  * Fires inside the 'bp_loaded' function, which fires after BP's core plugin files have been loaded.
222
  *
223
- * @since BuddyPress (1.2.5)
224
  */
225
  do_action( 'bp_loaded' );
226
  }
@@ -235,7 +237,7 @@ function bp_ready() {
235
  /**
236
  * Fires inside the 'bp_ready' function, which runs after BP is set up and the page is about to render.
237
  *
238
- * @since BuddyPress (1.6.0)
239
  */
240
  do_action( 'bp_ready' );
241
  }
@@ -251,7 +253,7 @@ function bp_actions() {
251
  /**
252
  * Fires inside the 'bp_actions' function, which runs just before rendering.
253
  *
254
- * @since BuddyPress (1.5.0)
255
  */
256
  do_action( 'bp_actions' );
257
  }
@@ -269,7 +271,7 @@ function bp_screens() {
269
  *
270
  * Runs just after 'bp_actions'. Use this hook to attach your template loaders.
271
  *
272
- * @since BuddyPress (1.5.0)
273
  */
274
  do_action( 'bp_screens' );
275
  }
@@ -286,7 +288,7 @@ function bp_widgets_init() {
286
  *
287
  * Hooked to 'widgets_init'.
288
  *
289
- * @since BuddyPress (1.6.0)
290
  */
291
  do_action ( 'bp_widgets_init' );
292
  }
@@ -309,7 +311,7 @@ function bp_head() {
309
  * template. The main purpose of this hook in BuddyPress is to redirect users
310
  * who do not have the proper permission to access certain content.
311
  *
312
- * @since BuddyPress (1.6.0)
313
  *
314
  * @uses do_action()
315
  */
@@ -318,7 +320,7 @@ function bp_template_redirect() {
318
  /**
319
  * Fires inside the 'bp_template_redirect' function.
320
  *
321
- * @since BuddyPress (1.6.0)
322
  */
323
  do_action( 'bp_template_redirect' );
324
  }
@@ -330,7 +332,7 @@ function bp_template_redirect() {
330
  *
331
  * The main action used registering theme directories.
332
  *
333
- * @since BuddyPress (1.5.0)
334
  *
335
  * @uses do_action()
336
  */
@@ -341,7 +343,7 @@ function bp_register_theme_directory() {
341
  *
342
  * The main action used registering theme directories.
343
  *
344
- * @since BuddyPress (1.7.0)
345
  */
346
  do_action( 'bp_register_theme_directory' );
347
  }
@@ -351,7 +353,7 @@ function bp_register_theme_directory() {
351
  *
352
  * The main action used registering theme packages.
353
  *
354
- * @since BuddyPress (1.7.0)
355
  *
356
  * @uses do_action()
357
  */
@@ -360,7 +362,7 @@ function bp_register_theme_packages() {
360
  /**
361
  * Fires inside the 'bp_register_theme_packages' function.
362
  *
363
- * @since BuddyPress (1.7.0)
364
  */
365
  do_action( 'bp_register_theme_packages' );
366
  }
@@ -368,7 +370,7 @@ function bp_register_theme_packages() {
368
  /**
369
  * Fire the 'bp_enqueue_scripts' action, where BP enqueues its CSS and JS.
370
  *
371
- * @since BuddyPress (1.6.0)
372
  *
373
  * @uses do_action() Calls 'bp_enqueue_scripts'.
374
  */
@@ -377,7 +379,7 @@ function bp_enqueue_scripts() {
377
  /**
378
  * Fires inside the 'bp_enqueue_scripts' function, where BP enqueues its CSS and JS.
379
  *
380
- * @since BuddyPress (1.6.0)
381
  */
382
  do_action ( 'bp_enqueue_scripts' );
383
  }
@@ -385,7 +387,7 @@ function bp_enqueue_scripts() {
385
  /**
386
  * Fire the 'bp_add_rewrite_tag' action, where BP adds its custom rewrite tags.
387
  *
388
- * @since BuddyPress (1.8.0)
389
  *
390
  * @uses do_action() Calls 'bp_add_rewrite_tags'.
391
  */
@@ -394,7 +396,7 @@ function bp_add_rewrite_tags() {
394
  /**
395
  * Fires inside the 'bp_add_rewrite_tags' function, where BP adds its custom rewrite tags.
396
  *
397
- * @since BuddyPress (1.8.0)
398
  */
399
  do_action( 'bp_add_rewrite_tags' );
400
  }
@@ -402,7 +404,7 @@ function bp_add_rewrite_tags() {
402
  /**
403
  * Fire the 'bp_add_rewrite_rules' action, where BP adds its custom rewrite rules.
404
  *
405
- * @since BuddyPress (1.9.0)
406
  *
407
  * @uses do_action() Calls 'bp_add_rewrite_rules'.
408
  */
@@ -411,7 +413,7 @@ function bp_add_rewrite_rules() {
411
  /**
412
  * Fires inside the 'bp_add_rewrite_rules' function, where BP adds its custom rewrite rules.
413
  *
414
- * @since BuddyPress (1.9.0)
415
  */
416
  do_action( 'bp_add_rewrite_rules' );
417
  }
@@ -419,7 +421,7 @@ function bp_add_rewrite_rules() {
419
  /**
420
  * Fire the 'bp_add_permastructs' action, where BP adds its BP-specific permalink structure.
421
  *
422
- * @since BuddyPress (1.9.0)
423
  *
424
  * @uses do_action() Calls 'bp_add_permastructs'.
425
  */
@@ -428,7 +430,7 @@ function bp_add_permastructs() {
428
  /**
429
  * Fires inside the 'bp_add_permastructs' function, where BP adds its BP-specific permalink structure.
430
  *
431
- * @since BuddyPress (1.9.0)
432
  */
433
  do_action( 'bp_add_permastructs' );
434
  }
@@ -439,7 +441,7 @@ function bp_add_permastructs() {
439
  * The main purpose of 'bp_setup_theme' is give themes a place to load their
440
  * BuddyPress-specific functionality.
441
  *
442
- * @since BuddyPress (1.6.0)
443
  *
444
  * @uses do_action() Calls 'bp_setup_theme'.
445
  */
@@ -448,7 +450,7 @@ function bp_setup_theme() {
448
  /**
449
  * Fires inside the 'bp_setup_theme' function.
450
  *
451
- * @since BuddyPress (1.6.0)
452
  */
453
  do_action ( 'bp_setup_theme' );
454
  }
@@ -463,7 +465,7 @@ function bp_setup_theme() {
463
  * time for other themes to load their features, such as BuddyPress support,
464
  * before our theme compatibility layer kicks in.
465
  *
466
- * @since BuddyPress (1.6.0)
467
  *
468
  * @uses do_action() Calls 'bp_after_setup_theme'.
469
  */
@@ -472,7 +474,7 @@ function bp_after_setup_theme() {
472
  /**
473
  * Fires inside the 'bp_after_setup_theme' function.
474
  *
475
- * @since BuddyPress (1.7.0)
476
  */
477
  do_action ( 'bp_after_setup_theme' );
478
  }
@@ -482,11 +484,12 @@ function bp_after_setup_theme() {
482
  /**
483
  * Fire the 'bp_request' filter, a piggy-back of WP's 'request'.
484
  *
485
- * @since BuddyPress (1.7.0)
486
  *
487
  * @see WP::parse_request() for a description of parameters.
488
  *
489
  * @param array $query_vars See {@link WP::parse_request()}.
 
490
  * @return array $query_vars See {@link WP::parse_request()}.
491
  */
492
  function bp_request( $query_vars = array() ) {
@@ -494,7 +497,7 @@ function bp_request( $query_vars = array() ) {
494
  /**
495
  * Filters the query_vars for the current request.
496
  *
497
- * @since BuddyPress (1.7.0)
498
  *
499
  * @param array $query_vars Array of query variables.
500
  */
@@ -504,10 +507,11 @@ function bp_request( $query_vars = array() ) {
504
  /**
505
  * Fire the 'bp_login_redirect' filter, a piggy-back of WP's 'login_redirect'.
506
  *
507
- * @since BuddyPress (1.7.0)
508
  *
509
- * @param string $redirect_to See 'login_redirect'.
510
  * @param string $redirect_to_raw See 'login_redirect'.
 
511
  * @param bool $user See 'login_redirect'.
512
  *
513
  * @return string
@@ -517,7 +521,7 @@ function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = fa
517
  /**
518
  * Filters the URL to redirect to after login.
519
  *
520
- * @since BuddyPress (1.7.0)
521
  *
522
  * @param string $redirect_to The redirect destination URL.
523
  * @param string $redirect_to_raw The requested redirect destination URL passed as a parameter.
@@ -531,11 +535,12 @@ function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = fa
531
  *
532
  * Hooked to 'template_include'.
533
  *
534
- * @since BuddyPress (1.6.0)
535
  *
536
  * @uses apply_filters()
537
  *
538
  * @param string $template See 'template_include'.
 
539
  * @return string Template file to use.
540
  */
541
  function bp_template_include( $template = '' ) {
@@ -543,7 +548,7 @@ function bp_template_include( $template = '' ) {
543
  /**
544
  * Filters the template to use with template_include.
545
  *
546
- * @since BuddyPress (1.6.0)
547
  *
548
  * @param string $template The path of the template to include.
549
  */
@@ -553,7 +558,7 @@ function bp_template_include( $template = '' ) {
553
  /**
554
  * Fire the 'bp_generate_rewrite_rules' action, where BP generates its rewrite rules.
555
  *
556
- * @since BuddyPress (1.7.0)
557
  *
558
  * @uses do_action() Calls 'bp_generate_rewrite_rules' with {@link WP_Rewrite}.
559
  *
@@ -564,7 +569,7 @@ function bp_generate_rewrite_rules( $wp_rewrite ) {
564
  /**
565
  * Fires inside the 'bp_generate_rewrite_rules' function.
566
  *
567
- * @since BuddyPress (1.7.0)
568
  *
569
  * @param WP_Rewrite $wp_rewrite WP_Rewrite object. Passed by reference.
570
  */
@@ -576,16 +581,20 @@ function bp_generate_rewrite_rules( $wp_rewrite ) {
576
  *
577
  * Filter the allowed themes list for BuddyPress-specific themes.
578
  *
579
- * @since BuddyPress (1.7.0)
580
  *
581
  * @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list.
 
 
 
 
582
  */
583
  function bp_allowed_themes( $themes ) {
584
 
585
  /**
586
  * Filters the allowed themes list for BuddyPress-specific themes.
587
  *
588
- * @since BuddyPress (1.7.0)
589
  *
590
  * @param string $template The path of the template to include.
591
  */
@@ -595,9 +604,9 @@ function bp_allowed_themes( $themes ) {
595
  /** Requests ******************************************************************/
596
 
597
  /**
598
- * The main action used for handling theme-side POST requests
599
  *
600
- * @since BuddyPress (1.9.0)
601
  * @uses do_action()
602
  */
603
  function bp_post_request() {
@@ -621,7 +630,7 @@ function bp_post_request() {
621
  * This dynamic action is probably the one you want to use. It narrows down
622
  * the scope of the 'action' without needing to check it in your function.
623
  *
624
- * @since BuddyPress (1.9.0)
625
  */
626
  do_action( 'bp_post_request_' . $action );
627
 
@@ -630,7 +639,7 @@ function bp_post_request() {
630
  *
631
  * Use this static action if you don't mind checking the 'action' yourself.
632
  *
633
- * @since BuddyPress (1.9.0)
634
  *
635
  * @param string $action The action being run.
636
  */
@@ -638,9 +647,9 @@ function bp_post_request() {
638
  }
639
 
640
  /**
641
- * The main action used for handling theme-side GET requests
642
  *
643
- * @since BuddyPress (1.9.0)
644
  * @uses do_action()
645
  */
646
  function bp_get_request() {
@@ -664,7 +673,7 @@ function bp_get_request() {
664
  * This dynamic action is probably the one you want to use. It narrows down
665
  * the scope of the 'action' without needing to check it in your function.
666
  *
667
- * @since BuddyPress (1.9.0)
668
  */
669
  do_action( 'bp_get_request_' . $action );
670
 
@@ -673,7 +682,7 @@ function bp_get_request() {
673
  *
674
  * Use this static action if you don't mind checking the 'action' yourself.
675
  *
676
- * @since BuddyPress (1.9.0)
677
  *
678
  * @param string $action The action being run.
679
  */
1
  <?php
 
2
  /**
3
  * Plugin Dependency Action Hooks.
4
  *
14
  * manually called and/or piggy-backed on top of other hooks if needed.
15
  *
16
  * @todo use anonymous functions when PHP minimum requirement allows (5.3)
17
+ *
18
+ * @package BuddyPress
19
+ * @subpackage Core
20
  */
21
 
22
  /**
27
  /**
28
  * Fires inside the 'bp_include' function, where plugins should include files.
29
  *
30
+ * @since 1.2.5
31
  */
32
  do_action( 'bp_include' );
33
  }
40
  /**
41
  * Fires inside the 'bp_setup_components' function, where plugins should initialize components.
42
  *
43
+ * @since 1.6.0
44
  */
45
  do_action( 'bp_setup_components' );
46
  }
53
  /**
54
  * Fires inside the 'bp_setup_canonical_stack' function, where plugins should set up their canonical URL.
55
  *
56
+ * @since 2.1.0
57
  */
58
  do_action( 'bp_setup_canonical_stack' );
59
  }
61
  /**
62
  * Fire the 'bp_register_taxonomies' action, where plugins should register taxonomies.
63
  *
64
+ * @since 2.2.0
65
  */
66
  function bp_register_taxonomies() {
67
 
68
  /**
69
  * Fires inside the 'bp_register_taxonomies' function, where plugins should register taxonomies.
70
  *
71
+ * @since 2.2.0
72
  */
73
  do_action( 'bp_register_taxonomies' );
74
  }
81
  /**
82
  * Fires inside the 'bp_setup_globals' function, where plugins should initialize global settings.
83
  *
84
+ * @since 1.2.0
85
  */
86
  do_action( 'bp_setup_globals' );
87
  }
94
  /**
95
  * Fires inside the 'bp_setup_nav' function, where plugins should register their navigation items.
96
  *
97
+ * @since 1.2.0
98
  */
99
  do_action( 'bp_setup_nav' );
100
  }
110
  *
111
  * This hook will only fire if bp_use_wp_admin_bar() returns true.
112
  *
113
+ * @since 1.5.0
114
  */
115
  do_action( 'bp_setup_admin_bar' );
116
  }
124
  /**
125
  * Fires inside the 'bp_setup_title' function, where plugins should modify the page title.
126
  *
127
+ * @since 1.5.0
128
  */
129
  do_action( 'bp_setup_title' );
130
  }
137
  /**
138
  * Fires inside the 'bp_register_widgets' function, where plugins should register widgets.
139
  *
140
+ * @since 1.2.0
141
  */
142
  do_action( 'bp_register_widgets' );
143
  }
145
  /**
146
  * Fire the 'bp_register_member_types' action, where plugins should register member types.
147
  *
148
+ * @since 2.3.0
149
  */
150
  function bp_register_member_types() {
151
 
152
  /**
153
  * Fires inside bp_register_member_types(), so plugins can register member types.
154
  *
155
+ * @since 2.3.0
156
  */
157
  do_action( 'bp_register_member_types' );
158
  }
160
  /**
161
  * Fire the 'bp_setup_cache_groups' action, where cache groups are registered.
162
  *
163
+ * @since 2.2.0
164
  */
165
  function bp_setup_cache_groups() {
166
 
167
  /**
168
  * Fires inside the 'bp_setup_cache_groups' function, where cache groups are registered.
169
  *
170
+ * @since 2.2.0
171
  */
172
  do_action( 'bp_setup_cache_groups' );
173
  }
194
  /**
195
  * Fires to set up the current user setup process.
196
  *
197
+ * @since 1.7.0
198
  */
199
  do_action( 'bp_setup_current_user' );
200
  }
207
  /**
208
  * Fires inside the 'bp_init' function, BuddyPress' main initialization hook.
209
  *
210
+ * @since 1.2.0
211
  */
212
  do_action( 'bp_init' );
213
  }
222
  /**
223
  * Fires inside the 'bp_loaded' function, which fires after BP's core plugin files have been loaded.
224
  *
225
+ * @since 1.2.5
226
  */
227
  do_action( 'bp_loaded' );
228
  }
237
  /**
238
  * Fires inside the 'bp_ready' function, which runs after BP is set up and the page is about to render.
239
  *
240
+ * @since 1.6.0
241
  */
242
  do_action( 'bp_ready' );
243
  }
253
  /**
254
  * Fires inside the 'bp_actions' function, which runs just before rendering.
255
  *
256
+ * @since 1.5.0
257
  */
258
  do_action( 'bp_actions' );
259
  }
271
  *
272
  * Runs just after 'bp_actions'. Use this hook to attach your template loaders.
273
  *
274
+ * @since 1.5.0
275
  */
276
  do_action( 'bp_screens' );
277
  }
288
  *
289
  * Hooked to 'widgets_init'.
290
  *
291
+ * @since 1.6.0
292
  */
293
  do_action ( 'bp_widgets_init' );
294
  }
311
  * template. The main purpose of this hook in BuddyPress is to redirect users
312
  * who do not have the proper permission to access certain content.
313
  *
314
+ * @since 1.6.0
315
  *
316
  * @uses do_action()
317
  */
320
  /**
321
  * Fires inside the 'bp_template_redirect' function.
322
  *
323
+ * @since 1.6.0
324
  */
325
  do_action( 'bp_template_redirect' );
326
  }
332
  *
333
  * The main action used registering theme directories.
334
  *
335
+ * @since 1.5.0
336
  *
337
  * @uses do_action()
338
  */
343
  *
344
  * The main action used registering theme directories.
345
  *
346
+ * @since 1.7.0
347
  */
348
  do_action( 'bp_register_theme_directory' );
349
  }
353
  *
354
  * The main action used registering theme packages.
355
  *
356
+ * @since 1.7.0
357
  *
358
  * @uses do_action()
359
  */
362
  /**
363
  * Fires inside the 'bp_register_theme_packages' function.
364
  *
365
+ * @since 1.7.0
366
  */
367
  do_action( 'bp_register_theme_packages' );
368
  }
370
  /**
371
  * Fire the 'bp_enqueue_scripts' action, where BP enqueues its CSS and JS.
372
  *
373
+ * @since 1.6.0
374
  *
375
  * @uses do_action() Calls 'bp_enqueue_scripts'.
376
  */
379
  /**
380
  * Fires inside the 'bp_enqueue_scripts' function, where BP enqueues its CSS and JS.
381
  *
382
+ * @since 1.6.0
383
  */
384
  do_action ( 'bp_enqueue_scripts' );
385
  }
387
  /**
388
  * Fire the 'bp_add_rewrite_tag' action, where BP adds its custom rewrite tags.
389
  *
390
+ * @since 1.8.0
391
  *
392
  * @uses do_action() Calls 'bp_add_rewrite_tags'.
393
  */
396
  /**
397
  * Fires inside the 'bp_add_rewrite_tags' function, where BP adds its custom rewrite tags.
398
  *
399
+ * @since 1.8.0
400
  */
401
  do_action( 'bp_add_rewrite_tags' );
402
  }
404
  /**
405
  * Fire the 'bp_add_rewrite_rules' action, where BP adds its custom rewrite rules.
406
  *
407
+ * @since 1.9.0
408
  *
409
  * @uses do_action() Calls 'bp_add_rewrite_rules'.
410
  */
413
  /**
414
  * Fires inside the 'bp_add_rewrite_rules' function, where BP adds its custom rewrite rules.
415
  *
416
+ * @since 1.9.0
417
  */
418
  do_action( 'bp_add_rewrite_rules' );
419
  }
421
  /**
422
  * Fire the 'bp_add_permastructs' action, where BP adds its BP-specific permalink structure.
423
  *
424
+ * @since 1.9.0
425
  *
426
  * @uses do_action() Calls 'bp_add_permastructs'.
427
  */
430
  /**
431
  * Fires inside the 'bp_add_permastructs' function, where BP adds its BP-specific permalink structure.
432
  *
433
+ * @since 1.9.0
434
  */
435
  do_action( 'bp_add_permastructs' );
436
  }
441
  * The main purpose of 'bp_setup_theme' is give themes a place to load their
442
  * BuddyPress-specific functionality.
443
  *
444
+ * @since 1.6.0
445
  *
446
  * @uses do_action() Calls 'bp_setup_theme'.
447
  */
450
  /**
451
  * Fires inside the 'bp_setup_theme' function.
452
  *
453
+ * @since 1.6.0
454
  */
455
  do_action ( 'bp_setup_theme' );
456
  }
465
  * time for other themes to load their features, such as BuddyPress support,
466
  * before our theme compatibility layer kicks in.
467
  *
468
+ * @since 1.6.0
469
  *
470
  * @uses do_action() Calls 'bp_after_setup_theme'.
471
  */
474
  /**
475
  * Fires inside the 'bp_after_setup_theme' function.
476
  *
477
+ * @since 1.7.0
478
  */
479
  do_action ( 'bp_after_setup_theme' );
480
  }
484
  /**
485
  * Fire the 'bp_request' filter, a piggy-back of WP's 'request'.
486
  *
487
+ * @since 1.7.0
488
  *
489
  * @see WP::parse_request() for a description of parameters.
490
  *
491
  * @param array $query_vars See {@link WP::parse_request()}.
492
+ *
493
  * @return array $query_vars See {@link WP::parse_request()}.
494
  */
495
  function bp_request( $query_vars = array() ) {
497
  /**
498
  * Filters the query_vars for the current request.
499
  *
500
+ * @since 1.7.0
501
  *
502
  * @param array $query_vars Array of query variables.
503
  */
507
  /**
508
  * Fire the 'bp_login_redirect' filter, a piggy-back of WP's 'login_redirect'.
509
  *
510
+ * @since 1.7.0
511
  *
512
+ * @param string $redirect_to See 'login_redirect'.
513
  * @param string $redirect_to_raw See 'login_redirect'.
514
+ *
515
  * @param bool $user See 'login_redirect'.
516
  *
517
  * @return string
521
  /**
522
  * Filters the URL to redirect to after login.
523
  *
524
+ * @since 1.7.0
525
  *
526
  * @param string $redirect_to The redirect destination URL.
527
  * @param string $redirect_to_raw The requested redirect destination URL passed as a parameter.
535
  *
536
  * Hooked to 'template_include'.
537
  *
538
+ * @since 1.6.0
539
  *
540
  * @uses apply_filters()
541
  *
542
  * @param string $template See 'template_include'.
543
+ *
544
  * @return string Template file to use.
545
  */
546
  function bp_template_include( $template = '' ) {
548
  /**
549
  * Filters the template to use with template_include.
550
  *
551
+ * @since 1.6.0
552
  *
553
  * @param string $template The path of the template to include.
554
  */
558
  /**
559
  * Fire the 'bp_generate_rewrite_rules' action, where BP generates its rewrite rules.
560
  *
561
+ * @since 1.7.0
562
  *
563
  * @uses do_action() Calls 'bp_generate_rewrite_rules' with {@link WP_Rewrite}.
564
  *
569
  /**
570
  * Fires inside the 'bp_generate_rewrite_rules' function.
571
  *
572
+ * @since 1.7.0
573
  *
574
  * @param WP_Rewrite $wp_rewrite WP_Rewrite object. Passed by reference.
575
  */
581
  *
582
  * Filter the allowed themes list for BuddyPress-specific themes.
583
  *
584
+ * @since 1.7.0
585
  *
586
  * @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list.
587
+ *
588
+ * @param array $themes
589
+ *
590
+ * @return array
591
  */
592
  function bp_allowed_themes( $themes ) {
593
 
594
  /**
595
  * Filters the allowed themes list for BuddyPress-specific themes.
596
  *
597
+ * @since 1.7.0
598
  *
599
  * @param string $template The path of the template to include.
600
  */
604
  /** Requests ******************************************************************/
605
 
606
  /**
607
+ * The main action used for handling theme-side POST requests.
608
  *
609
+ * @since 1.9.0
610
  * @uses do_action()
611
  */
612
  function bp_post_request() {
630
  * This dynamic action is probably the one you want to use. It narrows down
631
  * the scope of the 'action' without needing to check it in your function.
632
  *
633
+ * @since 1.9.0
634
  */
635
  do_action( 'bp_post_request_' . $action );
636
 
639
  *
640
  * Use this static action if you don't mind checking the 'action' yourself.
641
  *
642
+ * @since 1.9.0
643
  *
644
  * @param string $action The action being run.
645
  */
647
  }
648
 
649
  /**
650
+ * The main action used for handling theme-side GET requests.
651
  *
652
+ * @since 1.9.0
653
  * @uses do_action()
654
  */
655
  function bp_get_request() {
673
  * This dynamic action is probably the one you want to use. It narrows down
674
  * the scope of the 'action' without needing to check it in your function.
675
  *
676
+ * @since 1.9.0
677
  */
678
  do_action( 'bp_get_request_' . $action );
679
 
682
  *
683
  * Use this static action if you don't mind checking the 'action' yourself.
684
  *
685
+ * @since 1.9.0
686
  *
687
  * @param string $action The action being run.
688
  */
bp-core/bp-core-filters.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Filters.
5
  *
@@ -20,7 +19,7 @@
20
  * @see bp-core-actions.php
21
  */
22
 
23
- // Exit if accessed directly
24
  defined( 'ABSPATH' ) || exit;
25
 
26
  /**
@@ -74,7 +73,8 @@ add_filter( 'comments_open', 'bp_comments_open', 10, 2 );
74
  * @uses bp_is_active() checks if a BuddyPress component is active.
75
  *
76
  * @param array $pages List of excluded page IDs, as passed to the
77
- * 'wp_list_pages_excludes' filter.
 
78
  * @return array The exclude list, with BP's pages added.
79
  */
80
  function bp_core_exclude_pages( $pages = array() ) {
@@ -97,7 +97,7 @@ function bp_core_exclude_pages( $pages = array() ) {
97
  /**
98
  * Filters specific pages that shouldn't show up on page listings.
99
  *
100
- * @since BuddyPress (1.5.0)
101
  *
102
  * @param array $pages Array of pages to exclude.
103
  */
@@ -108,13 +108,14 @@ add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
108
  /**
109
  * Prevent specific pages (eg 'Activate') from showing in the Pages meta box of the Menu Administration screen.
110
  *
111
- * @since BuddyPress (2.0.0)
112
  *
113
  * @uses bp_is_root_blog() checks if current blog is root blog.
114
  * @uses buddypress() gets BuddyPress main instance
115
  *
116
- * @param object $object The post type object used in the meta box
117
- * @return object The $object, with a query argument to remove register and activate pages id.
 
118
  */
119
  function bp_core_exclude_pages_from_nav_menu_admin( $object = null ) {
120
 
@@ -154,10 +155,11 @@ add_filter( 'nav_menu_meta_box_object', 'bp_core_exclude_pages_from_nav_menu_adm
154
  * current BP component against the current page in the WP menu to see if we
155
  * should highlight the WP page.
156
  *
157
- * @since BuddyPress (2.2.0)
 
 
 
158
  *
159
- * @param array $retval CSS classes for the current menu page in the menu
160
- * @param WP_Post $page The page properties for the current menu item
161
  * @return array
162
  */
163
  function bp_core_menu_highlight_parent_page( $retval, $page ) {
@@ -211,10 +213,11 @@ add_filter( 'page_css_class', 'bp_core_menu_highlight_parent_page', 10, 2 );
211
  * When {@link wp_nav_menu()} is used, this function helps to highlight the
212
  * current BP parent page during nav menu generation.
213
  *
214
- * @since BuddyPress (2.2.0)
 
 
 
215
  *
216
- * @param array $retval CSS classes for the current nav menu item in the menu
217
- * @param WP_Post $item The properties for the current nav menu item
218
  * @return array
219
  */
220
  function bp_core_menu_highlight_nav_menu_item( $retval, $item ) {
@@ -245,7 +248,7 @@ function bp_core_email_from_name_filter() {
245
  /**
246
  * Filters the "From" name in outgoing email to the site name.
247
  *
248
- * @since BuddyPress (1.2.0)
249
  *
250
  * @param string $value Value to set the "From" name to.
251
  */
@@ -257,7 +260,8 @@ add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
257
  * Filter the blog post comments array and insert BuddyPress URLs for users.
258
  *
259
  * @param array $comments The array of comments supplied to the comments template.
260
- * @param int $post->ID The post ID.
 
261
  * @return array $comments The modified comment array.
262
  */
263
  function bp_core_filter_comments( $comments, $post_id ) {
@@ -296,11 +300,11 @@ add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
296
  * @uses apply_filters() Filter 'bp_core_login_redirect' to modify where users
297
  * are redirected to on login.
298
  *
299
- * @param string $redirect_to The URL to be redirected to, sanitized
300
- * in wp-login.php.
301
- * @param string $redirect_to_raw The unsanitized redirect_to URL ($_REQUEST['redirect_to'])
302
- * @param WP_User $user The WP_User object corresponding to a successfully
303
- * logged-in user. Otherwise a WP_Error object.
304
  * @return string The redirect URL.
305
  */
306
  function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
@@ -320,9 +324,9 @@ function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
320
  *
321
  * Allows plugins to have finer grained control of redirect upon login.
322
  *
323
- * @since BuddyPress (1.6.0)
324
  *
325
- * @param bool $value Whether or not to redirect.
326
  * @param string $redirect_to Sanitized URL to be redirected to.
327
  * @param string $redirect_to_raw Unsanitized URL to be redirected to.
328
  * @param WP_User $user The WP_User object corresponding to a
@@ -347,7 +351,7 @@ function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
347
  /**
348
  * Filters the URL to redirect users to upon successful login.
349
  *
350
- * @since BuddyPress (1.9.0)
351
  *
352
  * @param string $value URL to redirect to.
353
  */
@@ -365,8 +369,9 @@ add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
365
  * This filter will not fire when a user is registered by the site admin.
366
  *
367
  * @param string $welcome_email Complete email passed through WordPress.
 
368
  * @return string Filtered $welcome_email with the password replaced
369
- * by '[User Set]'.
370
  */
371
  function bp_core_filter_user_welcome_email( $welcome_email ) {
372
 
@@ -399,9 +404,10 @@ add_filter( 'update_welcome_user_email', 'bp_core_filter_user_welcome_email' );
399
  * This filter will not fire when a user is registered by the site admin.
400
  *
401
  * @param string $welcome_email Complete email passed through WordPress.
402
- * @param int $blog_id ID of the blog user is joining.
403
- * @param int $user_id ID of the user joining.
404
- * @param string $password Password of user.
 
405
  * @return string Filtered $welcome_email with $password replaced by '[User Set]'.
406
  */
407
  function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
@@ -428,14 +434,15 @@ add_filter( 'update_welcome_email', 'bp_core_filter_blog_welcome_email', 10, 4 )
428
  *
429
  * @see wpmu_signup_blog_notification() for a description of parameters.
430
  *
431
- * @param string $domain The new blog domain.
432
- * @param string $path The new blog path.
433
- * @param string $title The site title.
434
- * @param string $user The user's login name.
435
  * @param string $user_email The user's email address.
436
- * @param string $key The activation key created in wpmu_signup_blog()
437
- * @param array $meta By default, contains the requested privacy setting and
438
- * lang_id.
 
439
  * @return bool True on success, false on failure.
440
  */
441
  function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
@@ -451,7 +458,7 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
451
  /**
452
  * Filters the email that the notification is going to upon successful registration with blog.
453
  *
454
- * @since BuddyPress (1.2.0)
455
  *
456
  * @param string $user_email The user's email address.
457
  * @param string $domain The new blog domain.
@@ -467,7 +474,7 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
467
  /**
468
  * Filters the subject that the notification uses upon successful registration with blog.
469
  *
470
- * @since BuddyPress (1.2.0)
471
  *
472
  * @param string $subject The subject to use.
473
  * @param string $domain The new blog domain.
@@ -483,7 +490,7 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
483
  /**
484
  * Filters the message that the notification uses upon successful registration with blog.
485
  *
486
- * @since BuddyPress (1.2.0)
487
  *
488
  * @param string $message The message to use.
489
  * @param string $domain The new blog domain.
@@ -505,12 +512,12 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
505
  /**
506
  * Fires after the sending of the notification to new users for successful registration with blog.
507
  *
508
- * @since BuddyPress (1.5.0)
509
  *
510
  * @param string $admin_email Admin Email address for the site.
511
  * @param string $subject Subject used in the notification email.
512
  * @param string $message Message used in the notification email.
513
- * @param string domain The new blog domain.
514
  * @param string $path The new blog path.
515
  * @param string $title The site title.
516
  * @param string $user The user's login name.
@@ -530,11 +537,12 @@ add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_not
530
  *
531
  * @see wpmu_signup_user_notification() for a full description of params.
532
  *
533
- * @param string $user The user's login name.
534
  * @param string $user_email The user's email address.
535
- * @param string $key The activation key created in wpmu_signup_user()
536
- * @param array $meta By default, an empty array.
537
- * @return bool True on success, false on failure.
 
538
  */
539
  function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
540
 
@@ -575,7 +583,7 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
575
  /**
576
  * Filters the email that the notification is going to upon successful registration without blog.
577
  *
578
- * @since BuddyPress (1.2.0)
579
  *
580
  * @param string $user_email The user's email address.
581
  * @param string $user The user's login name.
@@ -588,7 +596,7 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
588
  /**
589
  * Filters the subject that the notification uses upon successful registration without blog.
590
  *
591
- * @since BuddyPress (1.2.0)
592
  *
593
  * @param string $subject The subject to use.
594
  * @param string $user The user's login name.
@@ -601,7 +609,7 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
601
  /**
602
  * Filters the message that the notification uses upon successful registration without blog.
603
  *
604
- * @since BuddyPress (1.2.0)
605
  *
606
  * @param string $message The message to use.
607
  * @param string $user The user's login name.
@@ -620,7 +628,7 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
620
  /**
621
  * Fires after the sending of the notification to new users for successful registration without blog.
622
  *
623
- * @since BuddyPress (1.5.0)
624
  *
625
  * @param string $admin_email Admin Email address for the site.
626
  * @param string $subject Subject used in the notification email.
@@ -640,7 +648,7 @@ add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_not
640
  /**
641
  * Filter the page title for BuddyPress pages.
642
  *
643
- * @since BuddyPress (1.5.0)
644
  *
645
  * @see wp_title()
646
  * @global object $bp BuddyPress global settings.
@@ -803,7 +811,7 @@ function bp_modify_page_title( $title = '', $sep = '&raquo;', $seplocation = 'ri
803
  /**
804
  * Filters the page title for BuddyPress pages.
805
  *
806
- * @since BuddyPress (1.5.0)
807
  *
808
  * @param string $new_title The BuddyPress page title.
809
  * @param string $title The original WordPress page title.
@@ -824,6 +832,7 @@ add_filter( 'bp_modify_page_title', 'esc_html' );
824
  * less than 4.0, and should be removed at a later date.
825
  *
826
  * @param string $title_part
 
827
  * @return string
828
  */
829
  function _bp_strip_spans_from_title( $title_part = '' ) {
@@ -838,10 +847,11 @@ function _bp_strip_spans_from_title( $title_part = '' ) {
838
  /**
839
  * Add BuddyPress-specific items to the wp_nav_menu.
840
  *
841
- * @since BuddyPress (1.9.0)
842
  *
843
  * @param WP_Post $menu_item The menu item.
844
- * @return obj The modified WP_Post object.
 
845
  */
846
  function bp_setup_nav_menu_item( $menu_item ) {
847
  if ( is_admin() ) {
@@ -927,7 +937,7 @@ add_filter( 'wp_setup_nav_menu_item', 'bp_setup_nav_menu_item', 10, 1 );
927
  /**
928
  * Populate BuddyPress user nav items for the customizer
929
  *
930
- * @since BuddyPress (2.3.3)
931
  *
932
  * @param array $items The array of menu items
933
  * @param string $type The requested type
@@ -964,9 +974,10 @@ add_filter( 'customize_nav_menu_available_items', 'bp_customizer_nav_menus_get_i
964
  /**
965
  * Set BuddyPress item navs for the customizer
966
  *
967
- * @since BuddyPress (2.3.3)
968
  *
969
- * @param array $item_types an associative array structured for the customizer
 
970
  */
971
  function bp_customizer_nav_menus_set_item_types( $item_types = array() ) {
972
  $item_types = array_merge( $item_types, array(
@@ -995,11 +1006,12 @@ add_filter( 'customize_nav_menu_available_item_types', 'bp_customizer_nav_menus_
995
  * usable for BuddyPress, we use this just-in-time filter on 'query' to swap
996
  * 'meta_id' with 'id.
997
  *
998
- * @since BuddyPress (2.0.0)
999
  *
1000
  * @access private Do not use.
1001
  *
1002
  * @param string $q SQL query.
 
1003
  * @return string
1004
  */
1005
  function bp_filter_metaid_column_name( $q ) {
@@ -1025,14 +1037,15 @@ function bp_filter_metaid_column_name( $q ) {
1025
  }
1026
 
1027
  /**
1028
- * Filter the edit post link to avoid its display in BuddyPress pages
1029
  *
1030
- * @since BuddyPress (2.1.0)
1031
  *
1032
  * @param string $edit_link The edit link.
1033
  * @param int $post_id Post ID.
1034
- * @return mixed Will be a boolean (false) if $post_id is 0. Will be a string (the unchanged edit link)
1035
- * otherwise
 
1036
  */
1037
  function bp_core_filter_edit_post_link( $edit_link = '', $post_id = 0 ) {
1038
  if ( 0 === $post_id ) {
@@ -1046,10 +1059,12 @@ function bp_core_filter_edit_post_link( $edit_link = '', $post_id = 0 ) {
1046
  * Should BuddyPress load the mentions scripts and related assets, including results to prime the
1047
  * mentions suggestions?
1048
  *
1049
- * @param bool $load_mentions True to load mentions assets, false otherwise.
 
 
1050
  * @param bool $mentions_enabled True if mentions are enabled.
 
1051
  * @return bool True if mentions scripts should be loaded.
1052
- * @since BuddyPress (2.2.0)
1053
  */
1054
  function bp_maybe_load_mentions_scripts_for_blog_content( $load_mentions, $mentions_enabled ) {
1055
  if ( ! $mentions_enabled ) {
@@ -1063,3 +1078,54 @@ function bp_maybe_load_mentions_scripts_for_blog_content( $load_mentions, $menti
1063
  return $load_mentions;
1064
  }
1065
  add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bp_maybe_load_mentions_scripts_for_blog_content', 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
 
2
  /**
3
  * BuddyPress Filters.
4
  *
19
  * @see bp-core-actions.php
20
  */
21
 
22
+ // Exit if accessed directly.
23
  defined( 'ABSPATH' ) || exit;
24
 
25
  /**
73
  * @uses bp_is_active() checks if a BuddyPress component is active.
74
  *
75
  * @param array $pages List of excluded page IDs, as passed to the
76
+ * 'wp_list_pages_excludes' filter.
77
+ *
78
  * @return array The exclude list, with BP's pages added.
79
  */
80
  function bp_core_exclude_pages( $pages = array() ) {
97
  /**
98
  * Filters specific pages that shouldn't show up on page listings.
99
  *
100
+ * @since 1.5.0
101
  *
102
  * @param array $pages Array of pages to exclude.
103
  */
108
  /**
109
  * Prevent specific pages (eg 'Activate') from showing in the Pages meta box of the Menu Administration screen.
110
  *
111
+ * @since 2.0.0
112
  *
113
  * @uses bp_is_root_blog() checks if current blog is root blog.
114
  * @uses buddypress() gets BuddyPress main instance
115
  *
116
+ * @param object|null $object The post type object used in the meta box.
117
+ *
118
+ * @return object|null The $object, with a query argument to remove register and activate pages id.
119
  */
120
  function bp_core_exclude_pages_from_nav_menu_admin( $object = null ) {
121
 
155
  * current BP component against the current page in the WP menu to see if we
156
  * should highlight the WP page.
157
  *
158
+ * @since 2.2.0
159
+ *
160
+ * @param array $retval CSS classes for the current menu page in the menu.
161
+ * @param WP_Post $page The page properties for the current menu item.
162
  *
 
 
163
  * @return array
164
  */
165
  function bp_core_menu_highlight_parent_page( $retval, $page ) {
213
  * When {@link wp_nav_menu()} is used, this function helps to highlight the
214
  * current BP parent page during nav menu generation.
215
  *
216
+ * @since 2.2.0
217
+ *
218
+ * @param array $retval CSS classes for the current nav menu item in the menu.
219
+ * @param WP_Post $item The properties for the current nav menu item.
220
  *
 
 
221
  * @return array
222
  */
223
  function bp_core_menu_highlight_nav_menu_item( $retval, $item ) {
248
  /**
249
  * Filters the "From" name in outgoing email to the site name.
250
  *
251
+ * @since 1.2.0
252
  *
253
  * @param string $value Value to set the "From" name to.
254
  */
260
  * Filter the blog post comments array and insert BuddyPress URLs for users.
261
  *
262
  * @param array $comments The array of comments supplied to the comments template.
263
+ * @param int $post_id The post ID.
264
+ *
265
  * @return array $comments The modified comment array.
266
  */
267
  function bp_core_filter_comments( $comments, $post_id ) {
300
  * @uses apply_filters() Filter 'bp_core_login_redirect' to modify where users
301
  * are redirected to on login.
302
  *
303
+ * @param string $redirect_to The URL to be redirected to, sanitized in wp-login.php.
304
+ * @param string $redirect_to_raw The unsanitized redirect_to URL ($_REQUEST['redirect_to']).
305
+ * @param WP_User $user The WP_User object corresponding to a successfully
306
+ * logged-in user. Otherwise a WP_Error object.
307
+ *
308
  * @return string The redirect URL.
309
  */
310
  function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
324
  *
325
  * Allows plugins to have finer grained control of redirect upon login.
326
  *
327
+ * @since 1.6.0
328
  *
329
+ * @param bool $value Whether or not to redirect.
330
  * @param string $redirect_to Sanitized URL to be redirected to.
331
  * @param string $redirect_to_raw Unsanitized URL to be redirected to.
332
  * @param WP_User $user The WP_User object corresponding to a
351
  /**
352
  * Filters the URL to redirect users to upon successful login.
353
  *
354
+ * @since 1.9.0
355
  *
356
  * @param string $value URL to redirect to.
357
  */
369
  * This filter will not fire when a user is registered by the site admin.
370
  *
371
  * @param string $welcome_email Complete email passed through WordPress.
372
+ *
373
  * @return string Filtered $welcome_email with the password replaced
374
+ * by '[User Set]'.
375
  */
376
  function bp_core_filter_user_welcome_email( $welcome_email ) {
377
 
404
  * This filter will not fire when a user is registered by the site admin.
405
  *
406
  * @param string $welcome_email Complete email passed through WordPress.
407
+ * @param int $blog_id ID of the blog user is joining.
408
+ * @param int $user_id ID of the user joining.
409
+ * @param string $password Password of user.
410
+ *
411
  * @return string Filtered $welcome_email with $password replaced by '[User Set]'.
412
  */
413
  function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
434
  *
435
  * @see wpmu_signup_blog_notification() for a description of parameters.
436
  *
437
+ * @param string $domain The new blog domain.
438
+ * @param string $path The new blog path.
439
+ * @param string $title The site title.
440
+ * @param string $user The user's login name.
441
  * @param string $user_email The user's email address.
442
+ * @param string $key The activation key created in wpmu_signup_blog()
443
+ * @param array $meta By default, contains the requested privacy setting and
444
+ * lang_id.
445
+ *
446
  * @return bool True on success, false on failure.
447
  */
448
  function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
458
  /**
459
  * Filters the email that the notification is going to upon successful registration with blog.
460
  *
461
+ * @since 1.2.0
462
  *
463
  * @param string $user_email The user's email address.
464
  * @param string $domain The new blog domain.
474
  /**
475
  * Filters the subject that the notification uses upon successful registration with blog.
476
  *
477
+ * @since 1.2.0
478
  *
479
  * @param string $subject The subject to use.
480
  * @param string $domain The new blog domain.
490
  /**
491
  * Filters the message that the notification uses upon successful registration with blog.
492
  *
493
+ * @since 1.2.0
494
  *
495
  * @param string $message The message to use.
496
  * @param string $domain The new blog domain.
512
  /**
513
  * Fires after the sending of the notification to new users for successful registration with blog.
514
  *
515
+ * @since 1.5.0
516
  *
517
  * @param string $admin_email Admin Email address for the site.
518
  * @param string $subject Subject used in the notification email.
519
  * @param string $message Message used in the notification email.
520
+ * @param string $domain The new blog domain.
521
  * @param string $path The new blog path.
522
  * @param string $title The site title.
523
  * @param string $user The user's login name.
537
  *
538
  * @see wpmu_signup_user_notification() for a full description of params.
539
  *
540
+ * @param string $user The user's login name.
541
  * @param string $user_email The user's email address.
542
+ * @param string $key The activation key created in wpmu_signup_user()
543
+ * @param array $meta By default, an empty array.
544
+ *
545
+ * @return bool|string True on success, false on failure.
546
  */
547
  function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
548
 
583
  /**
584
  * Filters the email that the notification is going to upon successful registration without blog.
585
  *
586
+ * @since 1.2.0
587
  *
588
  * @param string $user_email The user's email address.
589
  * @param string $user The user's login name.
596
  /**
597
  * Filters the subject that the notification uses upon successful registration without blog.
598
  *
599
+ * @since 1.2.0
600
  *
601
  * @param string $subject The subject to use.
602
  * @param string $user The user's login name.
609
  /**
610
  * Filters the message that the notification uses upon successful registration without blog.
611
  *
612
+ * @since 1.2.0
613
  *
614
  * @param string $message The message to use.
615
  * @param string $user The user's login name.
628
  /**
629
  * Fires after the sending of the notification to new users for successful registration without blog.
630
  *
631
+ * @since 1.5.0
632
  *
633
  * @param string $admin_email Admin Email address for the site.
634
  * @param string $subject Subject used in the notification email.
648
  /**
649
  * Filter the page title for BuddyPress pages.
650
  *
651
+ * @since 1.5.0
652
  *
653
  * @see wp_title()
654
  * @global object $bp BuddyPress global settings.
811
  /**
812
  * Filters the page title for BuddyPress pages.
813
  *
814
+ * @since 1.5.0
815
  *
816
  * @param string $new_title The BuddyPress page title.
817
  * @param string $title The original WordPress page title.
832
  * less than 4.0, and should be removed at a later date.
833
  *
834
  * @param string $title_part
835
+ *
836
  * @return string
837
  */
838
  function _bp_strip_spans_from_title( $title_part = '' ) {
847
  /**
848
  * Add BuddyPress-specific items to the wp_nav_menu.
849
  *
850
+ * @since 1.9.0
851
  *
852
  * @param WP_Post $menu_item The menu item.
853
+ *
854
+ * @return WP_Post The modified WP_Post object.
855
  */
856
  function bp_setup_nav_menu_item( $menu_item ) {
857
  if ( is_admin() ) {
937
  /**
938
  * Populate BuddyPress user nav items for the customizer
939
  *
940
+ * @since 2.3.3
941
  *
942
  * @param array $items The array of menu items
943
  * @param string $type The requested type
974
  /**
975
  * Set BuddyPress item navs for the customizer
976
  *
977
+ * @since 2.3.3
978
  *
979
+ * @param array $item_types An associative array structured for the customizer.
980
+ * @return array $item_types An associative array structured for the customizer.
981
  */
982
  function bp_customizer_nav_menus_set_item_types( $item_types = array() ) {
983
  $item_types = array_merge( $item_types, array(
1006
  * usable for BuddyPress, we use this just-in-time filter on 'query' to swap
1007
  * 'meta_id' with 'id.
1008
  *
1009
+ * @since 2.0.0
1010
  *
1011
  * @access private Do not use.
1012
  *
1013
  * @param string $q SQL query.
1014
+ *
1015
  * @return string
1016
  */
1017
  function bp_filter_metaid_column_name( $q ) {
1037
  }
1038
 
1039
  /**
1040
+ * Filter the edit post link to avoid its display in BuddyPress pages.
1041
  *
1042
+ * @since 2.1.0
1043
  *
1044
  * @param string $edit_link The edit link.
1045
  * @param int $post_id Post ID.
1046
+ *
1047
+ * @return bool|string Will be a boolean (false) if $post_id is 0. Will be a string (the unchanged edit link)
1048
+ * otherwise
1049
  */
1050
  function bp_core_filter_edit_post_link( $edit_link = '', $post_id = 0 ) {
1051
  if ( 0 === $post_id ) {
1059
  * Should BuddyPress load the mentions scripts and related assets, including results to prime the
1060
  * mentions suggestions?
1061
  *
1062
+ * @since 2.2.0
1063
+ *
1064
+ * @param bool $load_mentions True to load mentions assets, false otherwise.
1065
  * @param bool $mentions_enabled True if mentions are enabled.
1066
+ *
1067
  * @return bool True if mentions scripts should be loaded.
 
1068
  */
1069
  function bp_maybe_load_mentions_scripts_for_blog_content( $load_mentions, $mentions_enabled ) {
1070
  if ( ! $mentions_enabled ) {
1078
  return $load_mentions;
1079
  }
1080
  add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bp_maybe_load_mentions_scripts_for_blog_content', 10, 2 );
1081
+
1082
+ /**
1083
+ * Injects specific BuddyPress CSS classes into a widget sidebar.
1084
+ *
1085
+ * Helps to standardize styling of BuddyPress widgets within a theme that
1086
+ * does not use dynamic CSS classes in their widget sidebar's 'before_widget'
1087
+ * call.
1088
+ *
1089
+ * @since 2.4.0
1090
+ * @access private
1091
+ *
1092
+ * @global array $wp_registered_widgets Current registered widgets.
1093
+ * @param array $params Current sidebar params.
1094
+ * @return array
1095
+ */
1096
+ function _bp_core_inject_bp_widget_css_class( $params ) {
1097
+ global $wp_registered_widgets;
1098
+
1099
+ $widget_id = $params[0]['widget_id'];
1100
+
1101
+ // If the current widget isn't a BuddyPress one, stop!
1102
+ // We determine if a widget is a BuddyPress widget, if the widget class
1103
+ // begins with 'bp_'.
1104
+ if ( 0 !== strpos( $wp_registered_widgets[ $widget_id ]['callback'][0]->id_base, 'bp_' ) ) {
1105
+ return $params;
1106
+ }
1107
+
1108
+ // Dynamically add our widget CSS classes for BP widgets if not already there.
1109
+ $classes = array();
1110
+
1111
+ // Try to find 'widget' CSS class.
1112
+ if ( false === strpos( $params[0]['before_widget'], 'widget ' ) ) {
1113
+ $classes[] = 'widget';
1114
+ }
1115
+
1116
+ // Try to find 'buddypress' CSS class.
1117
+ if ( false === strpos( $params[0]['before_widget'], ' buddypress' ) ) {
1118
+ $classes[] = 'buddypress';
1119
+ }
1120
+
1121
+ // Stop if widget already has our CSS classes.
1122
+ if ( empty( $classes ) ) {
1123
+ return $params;
1124
+ }
1125
+
1126
+ // CSS injection time!
1127
+ $params[0]['before_widget'] = str_replace( 'class="', 'class="' . implode( ' ', $classes ) . ' ', $params[0]['before_widget'] );
1128
+
1129
+ return $params;
1130
+ }
1131
+ add_filter( 'dynamic_sidebar_params', '_bp_core_inject_bp_widget_css_class' );
bp-core/bp-core-functions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Common Functions.
5
  *
@@ -7,7 +6,7 @@
7
  * @subpackage Functions
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /** Versions ******************************************************************/
@@ -15,7 +14,7 @@ defined( 'ABSPATH' ) || exit;
15
  /**
16
  * Output the BuddyPress version.
17
  *
18
- * @since BuddyPress (1.6.0)
19
  *
20
  * @uses bp_get_version() To get the BuddyPress version.
21
  */
@@ -25,7 +24,7 @@ function bp_version() {
25
  /**
26
  * Return the BuddyPress version.
27
  *
28
- * @since BuddyPress (1.6.0)
29
  *
30
  * @return string The BuddyPress version.
31
  */
@@ -36,7 +35,7 @@ function bp_version() {
36
  /**
37
  * Output the BuddyPress database version.
38
  *
39
- * @since BuddyPress (1.6.0)
40
  *
41
  * @uses bp_get_db_version() To get the BuddyPress database version.
42
  */
@@ -46,7 +45,7 @@ function bp_db_version() {
46
  /**
47
  * Return the BuddyPress database version.
48
  *
49
- * @since BuddyPress (1.6.0)
50
  * @return string The BuddyPress database version.
51
  */
52
  function bp_get_db_version() {
@@ -56,7 +55,7 @@ function bp_db_version() {
56
  /**
57
  * Output the BuddyPress database version.
58
  *
59
- * @since BuddyPress (1.6.0)
60
  *
61
  * @uses bp_get_db_version_raw() To get the current database BuddyPress version.
62
  */
@@ -64,9 +63,9 @@ function bp_db_version_raw() {
64
  echo bp_get_db_version_raw();
65
  }
66
  /**
67
- * Return the BuddyPress database version
68
  *
69
- * @since BuddyPress (1.6)
70
  *
71
  * @return string The BuddyPress version direct from the database.
72
  */
@@ -94,7 +93,7 @@ function bp_core_get_table_prefix() {
94
  *
95
  * Intended primarily for use in multinetwork installations.
96
  *
97
- * @since BuddyPress (1.2.6)
98
  *
99
  * @param string $base_prefix Base prefix to use.
100
  */
@@ -107,7 +106,7 @@ function bp_core_get_table_prefix() {
107
  * The main purpose for this function is so that you can avoid having to create
108
  * your own awkward callback function for usort().
109
  *
110
- * @since BuddyPress (2.2.0)
111
  *
112
  * @param array $items The items to be sorted. Its constituent items can be either associative arrays or objects.
113
  * @param string|int $key The array index or property name to sort by.
@@ -156,7 +155,7 @@ function bp_sort_by_key( $items, $key, $type = 'alpha' ) {
156
  * them by post_name as follows:
157
  * $sorted_posts = bp_alpha_sort_by_key( $posts, 'post_name' );
158
  *
159
- * @since BuddyPress (1.9.0)
160
  *
161
  * @param array $items The items to be sorted. Its constituent items can be either associative arrays or objects.
162
  * @param string|int $key The array index or property name to sort by.
@@ -169,8 +168,9 @@ function bp_alpha_sort_by_key( $items, $key ) {
169
  /**
170
  * Format numbers the BuddyPress way.
171
  *
172
- * @param int $number The number to be formatted.
173
  * @param bool $decimals Whether to use decimals. See {@link number_format_i18n()}.
 
174
  * @return string The formatted number.
175
  */
176
  function bp_core_number_format( $number = 0, $decimals = false ) {
@@ -183,7 +183,7 @@ function bp_core_number_format( $number = 0, $decimals = false ) {
183
  /**
184
  * Filters the BuddyPress formatted number.
185
  *
186
- * @since BuddyPress (1.2.4)
187
  *
188
  * @param string $value BuddyPress formatted value.
189
  * @param int $number The number to be formatted.
@@ -222,9 +222,11 @@ function bp_core_number_format( $number = 0, $decimals = false ) {
222
  *
223
  * For the second argument, $func_args, you should just pass the value of func_get_args().
224
  *
225
- * @since BuddyPress (1.6)
 
226
  * @param array $old_args_keys Old argument indexs, keyed to their positions.
227
- * @param array $func_args The parameters passed to the originating function.
 
228
  * @return array $new_args The parsed arguments.
229
  */
230
  function bp_core_parse_args_array( $old_args_keys, $func_args ) {
@@ -248,11 +250,12 @@ function bp_core_parse_args_array( $old_args_keys, $func_args ) {
248
  * the optional $filter_key parameter. If no $filter_key is passed, no filters
249
  * are applied.
250
  *
251
- * @since BuddyPress (r7704)
 
 
 
 
252
  *
253
- * @param string|array $args Value to merge with $defaults
254
- * @param array $defaults Array that serves as the defaults.
255
- * @param string $filter_key String to key the filters from
256
  * @return array Merged user defined values with defaults.
257
  */
258
  function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
@@ -274,7 +277,7 @@ function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
274
  *
275
  * This is a dynamic filter dependent on the specified key.
276
  *
277
- * @since BuddyPress (2.0.0)
278
  *
279
  * @param array $r Array of arguments to use.
280
  */
@@ -294,7 +297,7 @@ function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
294
  *
295
  * This is a dynamic filter dependent on the specified key.
296
  *
297
- * @since BuddyPress (2.0.0)
298
  *
299
  * @param array $r Array of parsed arguments.
300
  */
@@ -310,11 +313,12 @@ function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
310
  * original value submitted via a query argument, likely to a template class
311
  * responsible for limiting the resultset of a template loop.
312
  *
313
- * @since BuddyPress (2.2.0)
 
 
 
314
  *
315
- * @param string $page_arg The $_REQUEST argument to look for
316
- * @param int $page The original page value to fall back to
317
- * @return int A sanitized integer value, good for pagination
318
  */
319
  function bp_sanitize_pagination_arg( $page_arg = '', $page = 1 ) {
320
 
@@ -340,9 +344,10 @@ function bp_sanitize_pagination_arg( $page_arg = '', $page = 1 ) {
340
  * Strings like 'DESC', 'desc', ' desc' will be interpreted into 'DESC'.
341
  * Everything else becomes 'ASC'.
342
  *
343
- * @since BuddyPress (1.8.0)
344
  *
345
  * @param string $order The 'order' string, as passed to the SQL constructor.
 
346
  * @return string The sanitized value 'DESC' or 'ASC'.
347
  */
348
  function bp_esc_sql_order( $order = '' ) {
@@ -358,13 +363,14 @@ function bp_esc_sql_order( $order = '' ) {
358
  * maintain compatibility with versions of WP before 4.0, we duplicate the
359
  * logic of the replacement, wpdb::esc_like().
360
  *
361
- * @since BuddyPress (2.1.0)
362
  *
363
  * @see wpdb::esc_like() for more details on proper use.
364
  *
365
  * @param string $text The raw text to be escaped.
 
366
  * @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
367
- * wpdb::prepare() before use.
368
  */
369
  function bp_esc_like( $text ) {
370
  global $wpdb;
@@ -379,20 +385,20 @@ function bp_esc_like( $text ) {
379
  /**
380
  * Are we running username compatibility mode?
381
  *
382
- * @since BuddyPress (1.5.0)
383
  *
384
  * @uses apply_filters() Filter 'bp_is_username_compatibility_mode' to alter.
385
  * @todo Move to members component?
386
  *
387
  * @return bool False when compatibility mode is disabled, true when enabled.
388
- * Default: false.
389
  */
390
  function bp_is_username_compatibility_mode() {
391
 
392
  /**
393
  * Filters whether or not to use username compatibility mode.
394
  *
395
- * @since BuddyPress (1.5.0)
396
  *
397
  * @param bool $value Whether or not username compatibility mode should be used.
398
  */
@@ -405,7 +411,7 @@ function bp_is_username_compatibility_mode() {
405
  * The WP Toolbar, introduced in WP 3.1, is fully supported in BuddyPress as
406
  * of BP 1.5. For BP 1.6, the WP Toolbar is the default.
407
  *
408
- * @since BuddyPress (1.5.0)
409
  *
410
  * @uses apply_filters() Filter 'bp_use_wp_admin_bar' to alter.
411
  *
@@ -428,7 +434,7 @@ function bp_use_wp_admin_bar() {
428
  /**
429
  * Filters whether or not to use the admin bar.
430
  *
431
- * @since BuddyPress (1.5.0)
432
  *
433
  * @param bool $use_admin_bar Whether or not to use the admin bar.
434
  */
@@ -440,7 +446,7 @@ function bp_use_wp_admin_bar() {
440
  /**
441
  * Returns an array of core component IDs.
442
  *
443
- * @since BuddyPress (2.1.0)
444
  *
445
  * @return array
446
  */
@@ -469,11 +475,12 @@ function bp_core_get_packaged_component_ids() {
469
  /**
470
  * Fetch a list of BP directory pages from the appropriate meta table.
471
  *
472
- * @since BuddyPress (1.5.0)
473
  *
474
  * @param string $status 'active' to return only pages associated with active components, 'all' to return all saved
475
  * pages. When running save routines, use 'all' to avoid removing data related to inactive
476
  * components. Default: 'active'.
 
477
  * @return array|string An array of page IDs, keyed by component names, or an
478
  * empty string if the list is not found.
479
  */
@@ -508,7 +515,7 @@ function bp_core_get_directory_page_ids( $status = 'active' ) {
508
  /**
509
  * Filters the list of BP directory pages from the appropriate meta table.
510
  *
511
- * @since BuddyPress (1.5.0)
512
  *
513
  * @param array $page_ids Array of directory pages.
514
  */
@@ -522,10 +529,10 @@ function bp_core_get_directory_page_ids( $status = 'active' ) {
522
  * in an array keyed by blog_id. This allows you to change your
523
  * bp_get_root_blog_id() and go through the setup process again.
524
  *
525
- * @since BuddyPress (1.5.0)
526
  *
527
  * @param array $blog_page_ids The IDs of the WP pages corresponding to BP
528
- * component directories.
529
  */
530
  function bp_core_update_directory_page_ids( $blog_page_ids ) {
531
  bp_update_option( 'bp-pages', $blog_page_ids );
@@ -534,7 +541,7 @@ function bp_core_update_directory_page_ids( $blog_page_ids ) {
534
  /**
535
  * Get names and slugs for BuddyPress component directory pages.
536
  *
537
- * @since BuddyPress (1.5.0).
538
  *
539
  * @return object Page names, IDs, and slugs.
540
  */
@@ -592,7 +599,7 @@ function bp_core_get_directory_pages() {
592
  /**
593
  * Filters the names and slugs for BuddyPress component directory pages.
594
  *
595
- * @since BuddyPress (1.5.0)
596
  *
597
  * @param object $pages Object holding page names and slugs.
598
  */
@@ -605,12 +612,12 @@ function bp_core_get_directory_pages() {
605
  * Directory pages are those WordPress pages used by BP components to display
606
  * content (eg, the 'groups' page created by BP).
607
  *
608
- * @since BuddyPress (1.7.0)
609
  *
610
- * @param array $components Components to create pages for.
611
- * @param string $existing 'delete' if you want to delete existing page
612
- * mappings and replace with new ones. Otherwise existing page mappings
613
- * are kept, and the gaps filled in with new pages. Default: 'keep'.
614
  */
615
  function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
616
 
@@ -705,7 +712,7 @@ function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
705
  * Bails early on multisite installations when not viewing the root site.
706
  * @link https://buddypress.trac.wordpress.org/ticket/6226
707
  *
708
- * @since BuddyPress (2.2.0)
709
  *
710
  * @param int $post_id Post ID.
711
  */
@@ -745,9 +752,10 @@ add_action( 'delete_post', 'bp_core_on_directory_page_delete' );
745
  * in general, or define a specific component slug constant (e.g.
746
  * BP_MEMBERS_SLUG) to override specific component slugs.
747
  *
748
- * @since BuddyPress (1.5.0)
749
  *
750
  * @param string $root_slug The root slug, which comes from $bp->pages->[component]->slug.
 
751
  * @return string The short slug for use in the middle of URLs.
752
  */
753
  function bp_core_component_slug_from_root_slug( $root_slug ) {
@@ -757,7 +765,7 @@ function bp_core_component_slug_from_root_slug( $root_slug ) {
757
  /**
758
  * Filters the default component slug from a WP page root_slug.
759
  *
760
- * @since BuddyPress (1.5.0)
761
  *
762
  * @param string $slug Short slug for use in the middle of URLs.
763
  * @param string $root_slug The root slug which comes from $bp->pages-[component]->slug.
@@ -845,10 +853,35 @@ function bp_core_add_illegal_names() {
845
  update_site_option( 'illegal_names', get_site_option( 'illegal_names' ), array() );
846
  }
847
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
848
  /**
849
  * Determine whether BuddyPress should register the bp-themes directory.
850
  *
851
- * @since BuddyPress (1.9.0)
852
  *
853
  * @return bool True if bp-themes should be registered, false otherwise.
854
  */
@@ -875,7 +908,7 @@ function bp_do_register_theme_directory() {
875
  /**
876
  * Filters whether BuddyPress should register the bp-themes directory.
877
  *
878
- * @since BuddyPress (1.9.0)
879
  *
880
  * @param bool $register If bp-themes should be registered.
881
  */
@@ -900,7 +933,7 @@ function bp_core_get_root_domain() {
900
  /**
901
  * Filters the domain for the root blog.
902
  *
903
- * @since BuddyPress (1.0.1)
904
  *
905
  * @param string $domain The domain URL for the blog.
906
  */
@@ -913,8 +946,8 @@ function bp_core_get_root_domain() {
913
  * @uses wp_safe_redirect()
914
  *
915
  * @param string $location The redirect URL.
916
- * @param int $status Optional. The numeric code to give in the redirect
917
- * headers. Default: 302.
918
  */
919
  function bp_core_redirect( $location = '', $status = 302 ) {
920
 
@@ -940,7 +973,7 @@ function bp_core_redirect( $location = '', $status = 302 ) {
940
  * a webroot-relative path. For example, 'http://example.com/foo/' will be
941
  * reduced to '/foo/'.
942
  *
943
- * @since BuddyPress (2.3.0)
944
  *
945
  * @return bool|string Returns false on error, a URL path on success.
946
  */
@@ -991,7 +1024,7 @@ function bp_core_get_site_path() {
991
  /**
992
  * Filters the path of the current site.
993
  *
994
- * @since BuddyPress (1.2.0)
995
  *
996
  * @param string $site_path URL to the current site.
997
  */
@@ -1003,11 +1036,12 @@ function bp_core_get_site_path() {
1003
  /**
1004
  * Get the current GMT time to save into the DB.
1005
  *
1006
- * @since BuddyPress (1.2.6)
1007
  *
1008
- * @param bool $gmt True to use GMT (rather than local) time. Default: true.
1009
  * @param string $type See the 'type' parameter in {@link current_time()}.
1010
- Default: 'mysql'.
 
1011
  * @return string Current time in 'Y-m-d h:i:s' format.
1012
  */
1013
  function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
@@ -1015,7 +1049,7 @@ function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
1015
  /**
1016
  * Filters the current GMT time to save into the DB.
1017
  *
1018
- * @since BuddyPress (1.2.6)
1019
  *
1020
  * @param string $value Current GMT time.
1021
  */
@@ -1041,10 +1075,11 @@ function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
1041
  * @uses apply_filters() Filter 'bp_core_time_since' to modify BP's calculations.
1042
  *
1043
  * @param int|string $older_date The earlier time from which you're calculating
1044
- * the time elapsed. Enter either as an integer Unix timestamp, or as a
1045
- * date string of the format 'Y-m-d h:i:s'.
1046
- * @param int $newer_date Optional. Unix timestamp of date to compare older
1047
- * date to. Default: false (current time).
 
1048
  * @return string String representing the time since the older date, eg
1049
  * "2 hours and 50 minutes".
1050
  */
@@ -1053,7 +1088,7 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1053
  /**
1054
  * Filters whether or not to bypass BuddyPress' time_since calculations.
1055
  *
1056
- * @since BuddyPress (1.7.0)
1057
  *
1058
  * @param bool $value Whether or not to bypass.
1059
  * @param string $older_date Earlier time from which we're calculating time elapsed.
@@ -1067,7 +1102,7 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1067
  /**
1068
  * Filters the value to use if the time since is unknown.
1069
  *
1070
- * @since BuddyPress (1.5.0)
1071
  *
1072
  * @param string $value String representing the time since the older date.
1073
  */
@@ -1076,7 +1111,7 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1076
  /**
1077
  * Filters the value to use if the time since is right now.
1078
  *
1079
- * @since BuddyPress (1.5.0)
1080
  *
1081
  * @param string $value String representing the time since the older date.
1082
  */
@@ -1085,7 +1120,7 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1085
  /**
1086
  * Filters the value to use if the time since is some time ago.
1087
  *
1088
- * @since BuddyPress (1.5.0)
1089
  *
1090
  * @param string $value String representing the time since the older date.
1091
  */
@@ -1222,7 +1257,7 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1222
  /**
1223
  * Filters the English-language representation of the time elapsed since a given date.
1224
  *
1225
- * @since BuddyPress (1.7.0)
1226
  *
1227
  * @param string $output Final 'time since' string.
1228
  * @param string $older_date Earlier time from which we're calculating time elapsed.
@@ -1237,8 +1272,8 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1237
  * Add a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
1238
  *
1239
  * @param string $message Feedback message to be displayed.
1240
- * @param string $type Message type. 'updated', 'success', 'error', 'warning'.
1241
- * Default: 'success'.
1242
  */
1243
  function bp_core_add_message( $message, $type = '' ) {
1244
 
@@ -1316,7 +1351,7 @@ function bp_core_render_message() {
1316
  /**
1317
  * Filters the 'template_notices' feedback message content.
1318
  *
1319
- * @since BuddyPress (1.5.5)
1320
  *
1321
  * @param string $template_message Feedback message content.
1322
  * @param string $type The type of message being displayed.
@@ -1335,7 +1370,7 @@ function bp_core_render_message() {
1335
  /**
1336
  * Fires after the display of any template_notices feedback messages.
1337
  *
1338
- * @since BuddyPress (1.1.0)
1339
  */
1340
  do_action( 'bp_core_render_message' );
1341
 
@@ -1391,7 +1426,7 @@ function bp_core_record_activity() {
1391
  *
1392
  * Use this action to detect the very first activity for a given member.
1393
  *
1394
- * @since BuddyPress (1.6.0)
1395
  *
1396
  * @param int $user_id ID of the user whose activity is recorded.
1397
  */
@@ -1412,7 +1447,8 @@ add_action( 'wp_head', 'bp_core_record_activity' );
1412
  * representation of the time elapsed.
1413
  *
1414
  * @param int|string $last_activity_date The date of last activity.
1415
- * @param string $string A sprintf()-able statement of the form 'active %s'
 
1416
  * @return string $last_active A string of the form '3 years ago'.
1417
  */
1418
  function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
@@ -1430,7 +1466,7 @@ function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1430
  /**
1431
  * Filters last activity string based on time since date given.
1432
  *
1433
- * @since BuddyPress (1.2.0)
1434
  *
1435
  * @param string $last_active Last activity string based on time since date given.
1436
  * @param string $last_activity_date The date of last activity.
@@ -1457,11 +1493,12 @@ function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1457
  * $friend_count = get_user_meta( $user_id, bp_get_user_meta_key( 'total_friend_count' ), true );
1458
  * If using the WP functions, do not not hardcode your meta keys.
1459
  *
1460
- * @since BuddyPress (1.5.0)
1461
  *
1462
  * @uses apply_filters() Filter 'bp_get_user_meta_key' to modify keys individually.
1463
  *
1464
- * @param string $key The usermeta meta_key.
 
1465
  * @return string $key The usermeta meta_key.
1466
  */
1467
  function bp_get_user_meta_key( $key = false ) {
@@ -1469,7 +1506,7 @@ function bp_get_user_meta_key( $key = false ) {
1469
  /**
1470
  * Filters the meta_key for a given piece of user metadata.
1471
  *
1472
- * @since BuddyPress (1.5.0)
1473
  *
1474
  * @param string $key The usermeta meta key.
1475
  */
@@ -1483,14 +1520,15 @@ function bp_get_user_meta_key( $key = false ) {
1483
  * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1484
  * BP setups.
1485
  *
1486
- * @since BuddyPress (1.5.0)
1487
  *
1488
  * @see get_user_meta() For complete details about parameters and return values.
1489
  * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1490
  *
1491
- * @param int $user_id The ID of the user whose meta you're fetching.
1492
- * @param string $key The meta key to retrieve.
1493
- * @param bool $single Whether to return a single value.
 
1494
  * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
1495
  * is true.
1496
  */
@@ -1505,15 +1543,16 @@ function bp_get_user_meta( $user_id, $key, $single = false ) {
1505
  * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1506
  * BP setups.
1507
  *
1508
- * @since BuddyPress (1.5.0)
1509
  *
1510
  * @see update_user_meta() For complete details about parameters and return values.
1511
  * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1512
  *
1513
- * @param int $user_id The ID of the user whose meta you're setting.
1514
- * @param string $key The meta key to set.
1515
- * @param mixed $value Metadata value.
1516
- * @param mixed $prev_value Optional. Previous value to check before removing.
 
1517
  * @return bool False on failure, true on success.
1518
  */
1519
  function bp_update_user_meta( $user_id, $key, $value, $prev_value = '' ) {
@@ -1527,14 +1566,15 @@ function bp_update_user_meta( $user_id, $key, $value, $prev_value = '' ) {
1527
  * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1528
  * BP setups.
1529
  *
1530
- * @since BuddyPress (1.5.0)
1531
  *
1532
  * @see delete_user_meta() For complete details about parameters and return values.
1533
  * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1534
  *
1535
- * @param int $user_id The ID of the user whose meta you're deleting.
1536
- * @param string $key The meta key to delete.
1537
- * @param mixed $value Optional. Metadata value.
 
1538
  * @return bool False for failure. True for success.
1539
  */
1540
  function bp_delete_user_meta( $user_id, $key, $value = '' ) {
@@ -1546,7 +1586,7 @@ function bp_delete_user_meta( $user_id, $key, $value = '' ) {
1546
  /**
1547
  * Initializes {@link BP_Embed} after everything is loaded.
1548
  *
1549
- * @since BuddyPress (1.5.0)
1550
  */
1551
  function bp_embed_init() {
1552
 
@@ -1562,17 +1602,17 @@ add_action( 'bp_init', 'bp_embed_init', 9 );
1562
  /**
1563
  * Are oembeds allowed in activity items?
1564
  *
1565
- * @since BuddyPress (1.5.0)
1566
  *
1567
  * @return bool False when activity embed support is disabled; true when
1568
- * enabled. Default: true.
1569
  */
1570
  function bp_use_embed_in_activity() {
1571
 
1572
  /**
1573
  * Filters whether or not oEmbeds are allowed in activity items.
1574
  *
1575
- * @since BuddyPress (1.5.0)
1576
  *
1577
  * @param bool $value Whether or not oEmbeds are allowed.
1578
  */
@@ -1582,17 +1622,17 @@ function bp_use_embed_in_activity() {
1582
  /**
1583
  * Are oembeds allowed in activity replies?
1584
  *
1585
- * @since BuddyPress (1.5.0)
1586
  *
1587
  * @return bool False when activity replies embed support is disabled; true
1588
- * when enabled. Default: true.
1589
  */
1590
  function bp_use_embed_in_activity_replies() {
1591
 
1592
  /**
1593
  * Filters whether or not oEmbeds are allowed in activity replies.
1594
  *
1595
- * @since BuddyPress (1.5.0)
1596
  *
1597
  * @param bool $value Whether or not oEmbeds are allowed.
1598
  */
@@ -1602,17 +1642,17 @@ function bp_use_embed_in_activity_replies() {
1602
  /**
1603
  * Are oembeds allowed in forum posts?
1604
  *
1605
- * @since BuddyPress (1.5.0)
1606
  *
1607
  * @return bool False when forum post embed support is disabled; true when
1608
- * enabled. Default: true.
1609
  */
1610
  function bp_use_embed_in_forum_posts() {
1611
 
1612
  /**
1613
  * Filters whether or not oEmbeds are allowed in forum posts.
1614
  *
1615
- * @since BuddyPress (1.5.0)
1616
  *
1617
  * @param bool $value Whether or not oEmbeds are allowed.
1618
  */
@@ -1622,17 +1662,17 @@ function bp_use_embed_in_forum_posts() {
1622
  /**
1623
  * Are oembeds allowed in private messages?
1624
  *
1625
- * @since BuddyPress (1.5.0)
1626
  *
1627
  * @return bool False when private message embed support is disabled; true when
1628
- * enabled. Default: true.
1629
  */
1630
  function bp_use_embed_in_private_messages() {
1631
 
1632
  /**
1633
  * Filters whether or not oEmbeds are allowed in private messages.
1634
  *
1635
- * @since BuddyPress (1.5.0)
1636
  *
1637
  * @param bool $value Whether or not oEmbeds are allowed.
1638
  */
@@ -1644,11 +1684,11 @@ function bp_use_embed_in_private_messages() {
1644
  /**
1645
  * Output the correct admin URL based on BuddyPress and WordPress configuration.
1646
  *
1647
- * @since BuddyPress (1.5.0)
1648
  *
1649
  * @see bp_get_admin_url() For description of parameters.
1650
  *
1651
- * @param string $path See {@link bp_get_admin_url()}.
1652
  * @param string $scheme See {@link bp_get_admin_url()}.
1653
  */
1654
  function bp_admin_url( $path = '', $scheme = 'admin' ) {
@@ -1657,17 +1697,18 @@ function bp_admin_url( $path = '', $scheme = 'admin' ) {
1657
  /**
1658
  * Return the correct admin URL based on BuddyPress and WordPress configuration.
1659
  *
1660
- * @since BuddyPress (1.5.0)
1661
  *
1662
  * @uses bp_core_do_network_admin()
1663
  * @uses network_admin_url()
1664
  * @uses admin_url()
1665
  *
1666
- * @param string $path Optional. The sub-path under /wp-admin to be
1667
- * appended to the admin URL.
1668
  * @param string $scheme The scheme to use. Default is 'admin', which
1669
- * obeys {@link force_ssl_admin()} and {@link is_ssl()}. 'http'
1670
- * or 'https' can be passed to force those schemes.
 
1671
  * @return string Admin url link with optional path appended.
1672
  */
1673
  function bp_get_admin_url( $path = '', $scheme = 'admin' ) {
@@ -1691,13 +1732,13 @@ function bp_admin_url( $path = '', $scheme = 'admin' ) {
1691
  * configurations, we need to check a few things to be confident about where
1692
  * to hook into certain areas of WordPress's admin.
1693
  *
1694
- * @since BuddyPress (1.5.0)
1695
  *
1696
  * @uses bp_is_network_activated()
1697
  * @uses bp_is_multiblog_mode()
1698
  *
1699
  * @return bool True if the BP admin screen should appear in the Network Admin,
1700
- * otherwise false.
1701
  */
1702
  function bp_core_do_network_admin() {
1703
 
@@ -1711,7 +1752,7 @@ function bp_core_do_network_admin() {
1711
  /**
1712
  * Filters whether or not BuddyPress should appear in network admin.
1713
  *
1714
- * @since BuddyPress (1.5.0)
1715
  *
1716
  * @param bool $retval Whether or not BuddyPress should be in the network admin.
1717
  */
@@ -1736,7 +1777,7 @@ function bp_core_admin_hook() {
1736
  /**
1737
  * Filters the action name that BuddyPress nav setup callbacks should be hooked to.
1738
  *
1739
- * @since BuddyPress (1.5.0)
1740
  *
1741
  * @param string $hook Action name to be attached to.
1742
  */
@@ -1748,9 +1789,10 @@ function bp_core_admin_hook() {
1748
  /**
1749
  * Is this the root blog?
1750
  *
1751
- * @since BuddyPress (1.5.0)
1752
  *
1753
  * @param int $blog_id Optional. Default: the ID of the current blog.
 
1754
  * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
1755
  */
1756
  function bp_is_root_blog( $blog_id = 0 ) {
@@ -1759,19 +1801,19 @@ function bp_is_root_blog( $blog_id = 0 ) {
1759
  $is_root_blog = false;
1760
 
1761
  // Use current blog if no ID is passed
1762
- if ( empty( $blog_id ) ) {
1763
  $blog_id = get_current_blog_id();
1764
  }
1765
 
1766
  // Compare to root blog ID
1767
- if ( $blog_id == bp_get_root_blog_id() ) {
1768
  $is_root_blog = true;
1769
  }
1770
 
1771
  /**
1772
  * Filters whether or not we're on the root blog.
1773
  *
1774
- * @since BuddyPress (1.5.0)
1775
  *
1776
  * @param bool $is_root_blog Whether or not we're on the root blog.
1777
  */
@@ -1785,7 +1827,7 @@ function bp_is_root_blog( $blog_id = 0 ) {
1785
  * appears (where member profile URLs resolve, where a given theme is loaded,
1786
  * etc.).
1787
  *
1788
- * @since BuddyPress (1.5.0)
1789
  *
1790
  * @return int The root site ID.
1791
  */
@@ -1794,7 +1836,7 @@ function bp_get_root_blog_id() {
1794
  /**
1795
  * Filters the ID for the root blog.
1796
  *
1797
- * @since BuddyPress (1.5.0)
1798
  *
1799
  * @param int $root_blog_id ID for the root blog.
1800
  */
@@ -1824,12 +1866,12 @@ function bp_get_root_blog_id() {
1824
  * a very small use-case with large architectural shortcomings, so do not go
1825
  * down this road unless you specifically need to.
1826
  *
1827
- * @since BuddyPress (1.5.0)
1828
  *
1829
  * @uses apply_filters() Filter 'bp_is_multiblog_mode' to alter.
1830
  *
1831
  * @return bool False when multiblog mode is disabled; true when enabled.
1832
- * Default: false.
1833
  */
1834
  function bp_is_multiblog_mode() {
1835
 
@@ -1851,7 +1893,7 @@ function bp_is_multiblog_mode() {
1851
  /**
1852
  * Filters whether or not we're running in multiblog mode.
1853
  *
1854
- * @since BuddyPress (1.5.0)
1855
  *
1856
  * @param bool $retval Whether or not we're running multiblog mode.
1857
  */
@@ -1866,7 +1908,7 @@ function bp_is_multiblog_mode() {
1866
  * with an mu-plugin or some other method, you'll want to filter
1867
  * 'bp_is_network_activated' and override the auto-determined value.
1868
  *
1869
- * @since BuddyPress (1.7.0)
1870
  *
1871
  * @return bool True if BuddyPress is network activated.
1872
  */
@@ -1887,7 +1929,7 @@ function bp_is_network_activated() {
1887
  /**
1888
  * Filters whether or not we're active at the network level.
1889
  *
1890
- * @since BuddyPress (1.7.0)
1891
  *
1892
  * @param bool $retval Whether or not we're network activated.
1893
  */
@@ -1899,9 +1941,9 @@ function bp_is_network_activated() {
1899
  /**
1900
  * Set the "is_directory" global.
1901
  *
1902
- * @param bool $is_directory Optional. Default: false.
1903
- * @param string $component Optional. Component name. Default: the current
1904
- * component.
1905
  */
1906
  function bp_update_is_directory( $is_directory = false, $component = '' ) {
1907
 
@@ -1912,7 +1954,7 @@ function bp_update_is_directory( $is_directory = false, $component = '' ) {
1912
  /**
1913
  * Filters the "is_directory" global value.
1914
  *
1915
- * @since BuddyPress (1.5.0)
1916
  *
1917
  * @param bool $is_directory Whether or not we're "is_directory".
1918
  * @param string $component Component name. Default: the current component.
@@ -1923,9 +1965,9 @@ function bp_update_is_directory( $is_directory = false, $component = '' ) {
1923
  /**
1924
  * Set the "is_item_admin" global.
1925
  *
1926
- * @param bool $is_item_admin Optional. Default: false.
1927
- * @param string $component Optional. Component name. Default: the current
1928
- * component.
1929
  */
1930
  function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
1931
 
@@ -1936,7 +1978,7 @@ function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
1936
  /**
1937
  * Filters the "is_item_admin" global value.
1938
  *
1939
- * @since BuddyPress (1.5.0)
1940
  *
1941
  * @param bool $is_item_admin Whether or not we're "is_item_admin".
1942
  * @param string $component Component name. Default: the current component.
@@ -1947,9 +1989,9 @@ function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
1947
  /**
1948
  * Set the "is_item_mod" global.
1949
  *
1950
- * @param bool $is_item_mod Optional. Default: false.
1951
- * @param string $component Optional. Component name. Default: the current
1952
- * component.
1953
  */
1954
  function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1955
 
@@ -1960,7 +2002,7 @@ function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1960
  /**
1961
  * Filters the "is_item_mod" global value.
1962
  *
1963
- * @since BuddyPress (1.5.0)
1964
  *
1965
  * @param bool $is_item_mod Whether or not we're "is_item_mod".
1966
  * @param string $component Component name. Default: the current component.
@@ -1971,12 +2013,12 @@ function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1971
  /**
1972
  * Trigger a 404.
1973
  *
1974
- * @since BuddyPress (1.5.0)
1975
  *
1976
  * @global WP_Query $wp_query WordPress query object.
1977
  *
1978
- * @param string $redirect If 'remove_canonical_direct', remove WordPress'
1979
- * "helpful" redirect_canonical action. Default: 'remove_canonical_redirect'.
1980
  */
1981
  function bp_do_404( $redirect = 'remove_canonical_direct' ) {
1982
  global $wp_query;
@@ -1984,7 +2026,7 @@ function bp_do_404( $redirect = 'remove_canonical_direct' ) {
1984
  /**
1985
  * Fires inside the triggering of a 404.
1986
  *
1987
- * @since BuddyPress (1.5.0)
1988
  *
1989
  * @param string $redirect Redirect type used to determine if redirect_canonical
1990
  * function should be be removed.
@@ -2007,12 +2049,13 @@ function bp_do_404( $redirect = 'remove_canonical_direct' ) {
2007
  *
2008
  * To avoid security exploits within the theme.
2009
  *
2010
- * @since BuddyPress (1.6.0)
2011
  *
2012
  * @uses do_action() Calls 'bp_verify_nonce_request' on $action.
2013
  *
2014
- * @param string $action Action nonce.
2015
- * @param string $query_arg where to look for nonce in $_REQUEST.
 
2016
  * @return bool True if the nonce is verified, otherwise false.
2017
  */
2018
  function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
@@ -2021,9 +2064,9 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
2021
 
2022
  // Parse home_url() into pieces to remove query-strings, strange characters,
2023
  // and other funny things that plugins might to do to it.
2024
- $parsed_home = parse_url( home_url( '/', ( is_ssl() ? 'https://' : 'http://' ) ) );
2025
 
2026
- // Maybe include the port, if it's included
2027
  if ( isset( $parsed_home['port'] ) ) {
2028
  $parsed_host = $parsed_home['host'] . ':' . $parsed_home['port'];
2029
  } else {
@@ -2036,7 +2079,7 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
2036
  /** Requested URL *********************************************************/
2037
 
2038
  // Maybe include the port, if it's included in home_url()
2039
- if ( isset( $parsed_home['port'] ) ) {
2040
  $request_host = $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'];
2041
  } else {
2042
  $request_host = $_SERVER['HTTP_HOST'];
@@ -2053,7 +2096,7 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
2053
  *
2054
  * Useful for configurations like reverse proxying.
2055
  *
2056
- * @since BuddyPress (1.9.0)
2057
  *
2058
  * @param string $requested_url The requested URL.
2059
  */
@@ -2070,7 +2113,7 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
2070
  /**
2071
  * Fires at the end of the nonce verification check.
2072
  *
2073
- * @since BuddyPress (1.6.0)
2074
  *
2075
  * @param string $action Action nonce.
2076
  * @param bool $result Boolean result of nonce verification.
@@ -2083,9 +2126,9 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
2083
  /** Requests ******************************************************************/
2084
 
2085
  /**
2086
- * Return true|false if this is a POST request
2087
  *
2088
- * @since BuddyPress (1.9.0)
2089
  * @return bool
2090
  */
2091
  function bp_is_post_request() {
@@ -2093,9 +2136,9 @@ function bp_is_post_request() {
2093
  }
2094
 
2095
  /**
2096
- * Return true|false if this is a GET request
2097
  *
2098
- * @since BuddyPress (1.9.0)
2099
  * @return bool
2100
  */
2101
  function bp_is_get_request() {
@@ -2118,7 +2161,7 @@ function bp_core_load_buddypress_textdomain() {
2118
  /**
2119
  * Filters the locale to be loaded for the language files.
2120
  *
2121
- * @since BuddyPress (1.0.2)
2122
  *
2123
  * @param string $value Current locale for the install.
2124
  */
@@ -2127,7 +2170,7 @@ function bp_core_load_buddypress_textdomain() {
2127
  /**
2128
  * Filters the locations to load language files from.
2129
  *
2130
- * @since BuddyPress (2.2.0)
2131
  *
2132
  * @param array $value Array of directories to check for language files in.
2133
  */
@@ -2213,7 +2256,7 @@ function bp_core_action_search_site( $slug = '' ) {
2213
  /**
2214
  * Filters the constructed url for use with site searching.
2215
  *
2216
- * @since BuddyPress (1.0.0)
2217
  *
2218
  * @param string $value URL for use with site searching.
2219
  * @param array $search_terms Array of search terms.
@@ -2242,7 +2285,7 @@ add_action( 'wp_footer', 'bp_core_print_generation_time' );
2242
  * function, we remove these links when on a BuddyPress page. This also
2243
  * prevents additional, unnecessary queries from running.
2244
  *
2245
- * @since BuddyPress (2.1.0)
2246
  */
2247
  function bp_remove_adjacent_posts_rel_link() {
2248
  if ( ! is_buddypress() ) {
@@ -2269,7 +2312,7 @@ add_action( 'bp_init', 'bp_remove_adjacent_posts_rel_link' );
2269
  * example, "My Profile" will always point to the URL of the profile of the
2270
  * logged-in user.
2271
  *
2272
- * @since BuddyPress (1.9.0)
2273
  *
2274
  * @return mixed A URL or an array of dummy pages.
2275
  */
@@ -2339,7 +2382,7 @@ function bp_nav_menu_get_loggedin_pages() {
2339
  * nor tax terms, so we fake a post-like object so as to be compatible with the
2340
  * menu.
2341
  *
2342
- * @since BuddyPress (1.9.0)
2343
  *
2344
  * @return mixed A URL or an array of dummy pages.
2345
  */
@@ -2410,10 +2453,11 @@ function bp_nav_menu_get_loggedout_pages() {
2410
  * based on the identity of the current user. This function lets you fetch the
2411
  * proper URL for a given nav item slug (such as 'login' or 'messages').
2412
  *
2413
- * @since BuddyPress (1.9.0)
2414
  *
2415
  * @param string $slug The slug of the nav item: login, register, or one of the
2416
- * slugs from buddypress()->bp_nav.
 
2417
  * @return string $nav_item_url The URL generated for the current user.
2418
  */
2419
  function bp_nav_menu_get_item_url( $slug ) {
@@ -2435,9 +2479,11 @@ function bp_nav_menu_get_item_url( $slug ) {
2435
  * This is used to power BuddyPress' at-mentions suggestions, but it is flexible enough to be used
2436
  * for similar kinds of future requirements, or those implemented by third-party developers.
2437
  *
 
 
2438
  * @param array $args
 
2439
  * @return array|WP_Error Array of results. If there were any problems, returns a WP_Error object.
2440
- * @since BuddyPress (2.1.0)
2441
  */
2442
  function bp_core_get_suggestions( $args ) {
2443
  $args = bp_parse_args( $args, array(), 'get_suggestions' );
@@ -2463,7 +2509,7 @@ function bp_core_get_suggestions( $args ) {
2463
  * Use this hook to tell BP the name of your class
2464
  * if you've built a custom suggestions service.
2465
  *
2466
- * @since BuddyPress (2.1.0)
2467
  *
2468
  * @param string $value Custom class to use. Default: none.
2469
  * @param array $args Array of arguments for sugggestions.
@@ -2488,7 +2534,7 @@ function bp_core_get_suggestions( $args ) {
2488
  /**
2489
  * Filters the available type of at-mentions.
2490
  *
2491
- * @since BuddyPress (2.1.0)
2492
  *
2493
  * @param array|WP_Error $retval Array of results or WP_Error object.
2494
  * @param array $args Array of arguments for suggestions.
@@ -2505,7 +2551,7 @@ function bp_core_get_suggestions( $args ) {
2505
  * This function ensures that we only need to use {@link switch_to_blog()}
2506
  * once to get what we need.
2507
  *
2508
- * @since BuddyPress (2.3.0)
2509
  *
2510
  * @uses is_multisite()
2511
  * @uses bp_is_root_blog()
1
  <?php
 
2
  /**
3
  * BuddyPress Common Functions.
4
  *
6
  * @subpackage Functions
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /** Versions ******************************************************************/
14
  /**
15
  * Output the BuddyPress version.
16
  *
17
+ * @since 1.6.0
18
  *
19
  * @uses bp_get_version() To get the BuddyPress version.
20
  */
24
  /**
25
  * Return the BuddyPress version.
26
  *
27
+ * @since 1.6.0
28
  *
29
  * @return string The BuddyPress version.
30
  */
35
  /**
36
  * Output the BuddyPress database version.
37
  *
38
+ * @since 1.6.0
39
  *
40
  * @uses bp_get_db_version() To get the BuddyPress database version.
41
  */
45
  /**
46
  * Return the BuddyPress database version.
47
  *
48
+ * @since 1.6.0
49
  * @return string The BuddyPress database version.
50
  */
51
  function bp_get_db_version() {
55
  /**
56
  * Output the BuddyPress database version.
57
  *
58
+ * @since 1.6.0
59
  *
60
  * @uses bp_get_db_version_raw() To get the current database BuddyPress version.
61
  */
63
  echo bp_get_db_version_raw();
64
  }
65
  /**
66
+ * Return the BuddyPress database version.
67
  *
68
+ * @since 1.6.0
69
  *
70
  * @return string The BuddyPress version direct from the database.
71
  */
93
  *
94
  * Intended primarily for use in multinetwork installations.
95
  *
96
+ * @since 1.2.6
97
  *
98
  * @param string $base_prefix Base prefix to use.
99
  */
106
  * The main purpose for this function is so that you can avoid having to create
107
  * your own awkward callback function for usort().
108
  *
109
+ * @since 2.2.0
110
  *
111
  * @param array $items The items to be sorted. Its constituent items can be either associative arrays or objects.
112
  * @param string|int $key The array index or property name to sort by.
155
  * them by post_name as follows:
156
  * $sorted_posts = bp_alpha_sort_by_key( $posts, 'post_name' );
157
  *
158
+ * @since 1.9.0
159
  *
160
  * @param array $items The items to be sorted. Its constituent items can be either associative arrays or objects.
161
  * @param string|int $key The array index or property name to sort by.
168
  /**
169
  * Format numbers the BuddyPress way.
170
  *
171
+ * @param int $number The number to be formatted.
172
  * @param bool $decimals Whether to use decimals. See {@link number_format_i18n()}.
173
+ *
174
  * @return string The formatted number.
175
  */
176
  function bp_core_number_format( $number = 0, $decimals = false ) {
183
  /**
184
  * Filters the BuddyPress formatted number.
185
  *
186
+ * @since 1.2.4
187
  *
188
  * @param string $value BuddyPress formatted value.
189
  * @param int $number The number to be formatted.
222
  *
223
  * For the second argument, $func_args, you should just pass the value of func_get_args().
224
  *
225
+ * @since 1.6.0
226
+ *
227
  * @param array $old_args_keys Old argument indexs, keyed to their positions.
228
+ * @param array $func_args The parameters passed to the originating function.
229
+ *
230
  * @return array $new_args The parsed arguments.
231
  */
232
  function bp_core_parse_args_array( $old_args_keys, $func_args ) {
250
  * the optional $filter_key parameter. If no $filter_key is passed, no filters
251
  * are applied.
252
  *
253
+ * @since r7704
254
+ *
255
+ * @param string|array $args Value to merge with $defaults.
256
+ * @param array $defaults Array that serves as the defaults.
257
+ * @param string $filter_key String to key the filters from.
258
  *
 
 
 
259
  * @return array Merged user defined values with defaults.
260
  */
261
  function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
277
  *
278
  * This is a dynamic filter dependent on the specified key.
279
  *
280
+ * @since 2.0.0
281
  *
282
  * @param array $r Array of arguments to use.
283
  */
297
  *
298
  * This is a dynamic filter dependent on the specified key.
299
  *
300
+ * @since 2.0.0
301
  *
302
  * @param array $r Array of parsed arguments.
303
  */
313
  * original value submitted via a query argument, likely to a template class
314
  * responsible for limiting the resultset of a template loop.
315
  *
316
+ * @since 2.2.0
317
+ *
318
+ * @param string $page_arg The $_REQUEST argument to look for.
319
+ * @param int $page The original page value to fall back to.
320
  *
321
+ * @return int A sanitized integer value, good for pagination.
 
 
322
  */
323
  function bp_sanitize_pagination_arg( $page_arg = '', $page = 1 ) {
324
 
344
  * Strings like 'DESC', 'desc', ' desc' will be interpreted into 'DESC'.
345
  * Everything else becomes 'ASC'.
346
  *
347
+ * @since 1.8.0
348
  *
349
  * @param string $order The 'order' string, as passed to the SQL constructor.
350
+ *
351
  * @return string The sanitized value 'DESC' or 'ASC'.
352
  */
353
  function bp_esc_sql_order( $order = '' ) {
363
  * maintain compatibility with versions of WP before 4.0, we duplicate the
364
  * logic of the replacement, wpdb::esc_like().
365
  *
366
+ * @since 2.1.0
367
  *
368
  * @see wpdb::esc_like() for more details on proper use.
369
  *
370
  * @param string $text The raw text to be escaped.
371
+ *
372
  * @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
373
+ * wpdb::prepare() before use.
374
  */
375
  function bp_esc_like( $text ) {
376
  global $wpdb;
385
  /**
386
  * Are we running username compatibility mode?
387
  *
388
+ * @since 1.5.0
389
  *
390
  * @uses apply_filters() Filter 'bp_is_username_compatibility_mode' to alter.
391
  * @todo Move to members component?
392
  *
393
  * @return bool False when compatibility mode is disabled, true when enabled.
394
+ * Default: false.
395
  */
396
  function bp_is_username_compatibility_mode() {
397
 
398
  /**
399
  * Filters whether or not to use username compatibility mode.
400
  *
401
+ * @since 1.5.0
402
  *
403
  * @param bool $value Whether or not username compatibility mode should be used.
404
  */
411
  * The WP Toolbar, introduced in WP 3.1, is fully supported in BuddyPress as
412
  * of BP 1.5. For BP 1.6, the WP Toolbar is the default.
413
  *
414
+ * @since 1.5.0
415
  *
416
  * @uses apply_filters() Filter 'bp_use_wp_admin_bar' to alter.
417
  *
434
  /**
435
  * Filters whether or not to use the admin bar.
436
  *
437
+ * @since 1.5.0
438
  *
439
  * @param bool $use_admin_bar Whether or not to use the admin bar.
440
  */
446
  /**
447
  * Returns an array of core component IDs.
448
  *
449
+ * @since 2.1.0
450
  *
451
  * @return array
452
  */
475
  /**
476
  * Fetch a list of BP directory pages from the appropriate meta table.
477
  *
478
+ * @since 1.5.0
479
  *
480
  * @param string $status 'active' to return only pages associated with active components, 'all' to return all saved
481
  * pages. When running save routines, use 'all' to avoid removing data related to inactive
482
  * components. Default: 'active'.
483
+ *
484
  * @return array|string An array of page IDs, keyed by component names, or an
485
  * empty string if the list is not found.
486
  */
515
  /**
516
  * Filters the list of BP directory pages from the appropriate meta table.
517
  *
518
+ * @since 1.5.0
519
  *
520
  * @param array $page_ids Array of directory pages.
521
  */
529
  * in an array keyed by blog_id. This allows you to change your
530
  * bp_get_root_blog_id() and go through the setup process again.
531
  *
532
+ * @since 1.5.0
533
  *
534
  * @param array $blog_page_ids The IDs of the WP pages corresponding to BP
535
+ * component directories.
536
  */
537
  function bp_core_update_directory_page_ids( $blog_page_ids ) {
538
  bp_update_option( 'bp-pages', $blog_page_ids );
541
  /**
542
  * Get names and slugs for BuddyPress component directory pages.
543
  *
544
+ * @since 1.5.0
545
  *
546
  * @return object Page names, IDs, and slugs.
547
  */
599
  /**
600
  * Filters the names and slugs for BuddyPress component directory pages.
601
  *
602
+ * @since 1.5.0
603
  *
604
  * @param object $pages Object holding page names and slugs.
605
  */
612
  * Directory pages are those WordPress pages used by BP components to display
613
  * content (eg, the 'groups' page created by BP).
614
  *
615
+ * @since 1.7.0
616
  *
617
+ * @param array $components Components to create pages for.
618
+ * @param string $existing 'delete' if you want to delete existing page mappings
619
+ * and replace with new ones. Otherwise existing page mappings
620
+ * are kept, and the gaps filled in with new pages. Default: 'keep'.
621
  */
622
  function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
623
 
712
  * Bails early on multisite installations when not viewing the root site.
713
  * @link https://buddypress.trac.wordpress.org/ticket/6226
714
  *
715
+ * @since 2.2.0
716
  *
717
  * @param int $post_id Post ID.
718
  */
752
  * in general, or define a specific component slug constant (e.g.
753
  * BP_MEMBERS_SLUG) to override specific component slugs.
754
  *
755
+ * @since 1.5.0
756
  *
757
  * @param string $root_slug The root slug, which comes from $bp->pages->[component]->slug.
758
+ *
759
  * @return string The short slug for use in the middle of URLs.
760
  */
761
  function bp_core_component_slug_from_root_slug( $root_slug ) {
765
  /**
766
  * Filters the default component slug from a WP page root_slug.
767
  *
768
+ * @since 1.5.0
769
  *
770
  * @param string $slug Short slug for use in the middle of URLs.
771
  * @param string $root_slug The root slug which comes from $bp->pages-[component]->slug.
853
  update_site_option( 'illegal_names', get_site_option( 'illegal_names' ), array() );
854
  }
855
 
856
+ /**
857
+ * Get the 'search' query argument for a given component.
858
+ *
859
+ * @since 2.4.0
860
+ *
861
+ * @param string $component Component name.
862
+ * @return string|bool Query argument on success. False on failure.
863
+ */
864
+ function bp_core_get_component_search_query_arg( $component ) {
865
+ $query_arg = false;
866
+ if ( isset( buddypress()->{$component}->search_query_arg ) ) {
867
+ $query_arg = sanitize_title( buddypress()->{$component}->search_query_arg );
868
+ }
869
+
870
+ /**
871
+ * Filters the query arg for a component search string.
872
+ *
873
+ * @since 2.4.0
874
+ *
875
+ * @param string $query_arg Query argument.
876
+ * @param string $component Component name.
877
+ */
878
+ return apply_filters( 'bp_core_get_component_search_query_arg', $query_arg, $component );
879
+ }
880
+
881
  /**
882
  * Determine whether BuddyPress should register the bp-themes directory.
883
  *
884
+ * @since 1.9.0
885
  *
886
  * @return bool True if bp-themes should be registered, false otherwise.
887
  */
908
  /**
909
  * Filters whether BuddyPress should register the bp-themes directory.
910
  *
911
+ * @since 1.9.0
912
  *
913
  * @param bool $register If bp-themes should be registered.
914
  */
933
  /**
934
  * Filters the domain for the root blog.
935
  *
936
+ * @since 1.0.1
937
  *
938
  * @param string $domain The domain URL for the blog.
939
  */
946
  * @uses wp_safe_redirect()
947
  *
948
  * @param string $location The redirect URL.
949
+ * @param int $status Optional. The numeric code to give in the redirect
950
+ * headers. Default: 302.
951
  */
952
  function bp_core_redirect( $location = '', $status = 302 ) {
953
 
973
  * a webroot-relative path. For example, 'http://example.com/foo/' will be
974
  * reduced to '/foo/'.
975
  *
976
+ * @since 2.3.0
977
  *
978
  * @return bool|string Returns false on error, a URL path on success.
979
  */
1024
  /**
1025
  * Filters the path of the current site.
1026
  *
1027
+ * @since 1.2.0
1028
  *
1029
  * @param string $site_path URL to the current site.
1030
  */
1036
  /**
1037
  * Get the current GMT time to save into the DB.
1038
  *
1039
+ * @since 1.2.6
1040
  *
1041
+ * @param bool $gmt True to use GMT (rather than local) time. Default: true.
1042
  * @param string $type See the 'type' parameter in {@link current_time()}.
1043
+ * Default: 'mysql'.
1044
+ *
1045
  * @return string Current time in 'Y-m-d h:i:s' format.
1046
  */
1047
  function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
1049
  /**
1050
  * Filters the current GMT time to save into the DB.
1051
  *
1052
+ * @since 1.2.6
1053
  *
1054
  * @param string $value Current GMT time.
1055
  */
1075
  * @uses apply_filters() Filter 'bp_core_time_since' to modify BP's calculations.
1076
  *
1077
  * @param int|string $older_date The earlier time from which you're calculating
1078
+ * the time elapsed. Enter either as an integer Unix timestamp,
1079
+ * or as a date string of the format 'Y-m-d h:i:s'.
1080
+ * @param int|bool $newer_date Optional. Unix timestamp of date to compare older
1081
+ * date to. Default: false (current time).
1082
+ *
1083
  * @return string String representing the time since the older date, eg
1084
  * "2 hours and 50 minutes".
1085
  */
1088
  /**
1089
  * Filters whether or not to bypass BuddyPress' time_since calculations.
1090
  *
1091
+ * @since 1.7.0
1092
  *
1093
  * @param bool $value Whether or not to bypass.
1094
  * @param string $older_date Earlier time from which we're calculating time elapsed.
1102
  /**
1103
  * Filters the value to use if the time since is unknown.
1104
  *
1105
+ * @since 1.5.0
1106
  *
1107
  * @param string $value String representing the time since the older date.
1108
  */
1111
  /**
1112
  * Filters the value to use if the time since is right now.
1113
  *
1114
+ * @since 1.5.0
1115
  *
1116
  * @param string $value String representing the time since the older date.
1117
  */
1120
  /**
1121
  * Filters the value to use if the time since is some time ago.
1122
  *
1123
+ * @since 1.5.0
1124
  *
1125
  * @param string $value String representing the time since the older date.
1126
  */
1257
  /**
1258
  * Filters the English-language representation of the time elapsed since a given date.
1259
  *
1260
+ * @since 1.7.0
1261
  *
1262
  * @param string $output Final 'time since' string.
1263
  * @param string $older_date Earlier time from which we're calculating time elapsed.
1272
  * Add a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
1273
  *
1274
  * @param string $message Feedback message to be displayed.
1275
+ * @param string $type Message type. 'updated', 'success', 'error', 'warning'.
1276
+ * Default: 'success'.
1277
  */
1278
  function bp_core_add_message( $message, $type = '' ) {
1279
 
1351
  /**
1352
  * Filters the 'template_notices' feedback message content.
1353
  *
1354
+ * @since 1.5.5
1355
  *
1356
  * @param string $template_message Feedback message content.
1357
  * @param string $type The type of message being displayed.
1370
  /**
1371
  * Fires after the display of any template_notices feedback messages.
1372
  *
1373
+ * @since 1.1.0
1374
  */
1375
  do_action( 'bp_core_render_message' );
1376
 
1426
  *
1427
  * Use this action to detect the very first activity for a given member.
1428
  *
1429
+ * @since 1.6.0
1430
  *
1431
  * @param int $user_id ID of the user whose activity is recorded.
1432
  */
1447
  * representation of the time elapsed.
1448
  *
1449
  * @param int|string $last_activity_date The date of last activity.
1450
+ * @param string $string A sprintf()-able statement of the form 'active %s'.
1451
+ *
1452
  * @return string $last_active A string of the form '3 years ago'.
1453
  */
1454
  function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1466
  /**
1467
  * Filters last activity string based on time since date given.
1468
  *
1469
+ * @since 1.2.0
1470
  *
1471
  * @param string $last_active Last activity string based on time since date given.
1472
  * @param string $last_activity_date The date of last activity.
1493
  * $friend_count = get_user_meta( $user_id, bp_get_user_meta_key( 'total_friend_count' ), true );
1494
  * If using the WP functions, do not not hardcode your meta keys.
1495
  *
1496
+ * @since 1.5.0
1497
  *
1498
  * @uses apply_filters() Filter 'bp_get_user_meta_key' to modify keys individually.
1499
  *
1500
+ * @param string|bool $key The usermeta meta_key.
1501
+ *
1502
  * @return string $key The usermeta meta_key.
1503
  */
1504
  function bp_get_user_meta_key( $key = false ) {
1506
  /**
1507
  * Filters the meta_key for a given piece of user metadata.
1508
  *
1509
+ * @since 1.5.0
1510
  *
1511
  * @param string $key The usermeta meta key.
1512
  */
1520
  * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1521
  * BP setups.
1522
  *
1523
+ * @since 1.5.0
1524
  *
1525
  * @see get_user_meta() For complete details about parameters and return values.
1526
  * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1527
  *
1528
+ * @param int $user_id The ID of the user whose meta you're fetching.
1529
+ * @param string $key The meta key to retrieve.
1530
+ * @param bool $single Whether to return a single value.
1531
+ *
1532
  * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
1533
  * is true.
1534
  */
1543
  * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1544
  * BP setups.
1545
  *
1546
+ * @since 1.5.0
1547
  *
1548
  * @see update_user_meta() For complete details about parameters and return values.
1549
  * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1550
  *
1551
+ * @param int $user_id The ID of the user whose meta you're setting.
1552
+ * @param string $key The meta key to set.
1553
+ * @param mixed $value Metadata value.
1554
+ * @param mixed $prev_value Optional. Previous value to check before removing.
1555
+ *
1556
  * @return bool False on failure, true on success.
1557
  */
1558
  function bp_update_user_meta( $user_id, $key, $value, $prev_value = '' ) {
1566
  * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1567
  * BP setups.
1568
  *
1569
+ * @since 1.5.0
1570
  *
1571
  * @see delete_user_meta() For complete details about parameters and return values.
1572
  * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1573
  *
1574
+ * @param int $user_id The ID of the user whose meta you're deleting.
1575
+ * @param string $key The meta key to delete.
1576
+ * @param mixed $value Optional. Metadata value.
1577
+ *
1578
  * @return bool False for failure. True for success.
1579
  */
1580
  function bp_delete_user_meta( $user_id, $key, $value = '' ) {
1586
  /**
1587
  * Initializes {@link BP_Embed} after everything is loaded.
1588
  *
1589
+ * @since 1.5.0
1590
  */
1591
  function bp_embed_init() {
1592
 
1602
  /**
1603
  * Are oembeds allowed in activity items?
1604
  *
1605
+ * @since 1.5.0
1606
  *
1607
  * @return bool False when activity embed support is disabled; true when
1608
+ * enabled. Default: true.
1609
  */
1610
  function bp_use_embed_in_activity() {
1611
 
1612
  /**
1613
  * Filters whether or not oEmbeds are allowed in activity items.
1614
  *
1615
+ * @since 1.5.0
1616
  *
1617
  * @param bool $value Whether or not oEmbeds are allowed.
1618
  */
1622
  /**
1623
  * Are oembeds allowed in activity replies?
1624
  *
1625
+ * @since 1.5.0
1626
  *
1627
  * @return bool False when activity replies embed support is disabled; true
1628
+ * when enabled. Default: true.
1629
  */
1630
  function bp_use_embed_in_activity_replies() {
1631
 
1632
  /**
1633
  * Filters whether or not oEmbeds are allowed in activity replies.
1634
  *
1635
+ * @since 1.5.0
1636
  *
1637
  * @param bool $value Whether or not oEmbeds are allowed.
1638
  */
1642
  /**
1643
  * Are oembeds allowed in forum posts?
1644
  *
1645
+ * @since 1.5.0
1646
  *
1647
  * @return bool False when forum post embed support is disabled; true when
1648
+ * enabled. Default: true.
1649
  */
1650
  function bp_use_embed_in_forum_posts() {
1651
 
1652
  /**
1653
  * Filters whether or not oEmbeds are allowed in forum posts.
1654
  *
1655
+ * @since 1.5.0
1656
  *
1657
  * @param bool $value Whether or not oEmbeds are allowed.
1658
  */
1662
  /**
1663
  * Are oembeds allowed in private messages?
1664
  *
1665
+ * @since 1.5.0
1666
  *
1667
  * @return bool False when private message embed support is disabled; true when
1668
+ * enabled. Default: true.
1669
  */
1670
  function bp_use_embed_in_private_messages() {
1671
 
1672
  /**
1673
  * Filters whether or not oEmbeds are allowed in private messages.
1674
  *
1675
+ * @since 1.5.0
1676
  *
1677
  * @param bool $value Whether or not oEmbeds are allowed.
1678
  */
1684
  /**
1685
  * Output the correct admin URL based on BuddyPress and WordPress configuration.
1686
  *
1687
+ * @since 1.5.0
1688
  *
1689
  * @see bp_get_admin_url() For description of parameters.
1690
  *
1691
+ * @param string $path See {@link bp_get_admin_url()}.
1692
  * @param string $scheme See {@link bp_get_admin_url()}.
1693
  */
1694
  function bp_admin_url( $path = '', $scheme = 'admin' ) {
1697
  /**
1698
  * Return the correct admin URL based on BuddyPress and WordPress configuration.
1699
  *
1700
+ * @since 1.5.0
1701
  *
1702
  * @uses bp_core_do_network_admin()
1703
  * @uses network_admin_url()
1704
  * @uses admin_url()
1705
  *
1706
+ * @param string $path Optional. The sub-path under /wp-admin to be
1707
+ * appended to the admin URL.
1708
  * @param string $scheme The scheme to use. Default is 'admin', which
1709
+ * obeys {@link force_ssl_admin()} and {@link is_ssl()}. 'http'
1710
+ * or 'https' can be passed to force those schemes.
1711
+ *
1712
  * @return string Admin url link with optional path appended.
1713
  */
1714
  function bp_get_admin_url( $path = '', $scheme = 'admin' ) {
1732
  * configurations, we need to check a few things to be confident about where
1733
  * to hook into certain areas of WordPress's admin.
1734
  *
1735
+ * @since 1.5.0
1736
  *
1737
  * @uses bp_is_network_activated()
1738
  * @uses bp_is_multiblog_mode()
1739
  *
1740
  * @return bool True if the BP admin screen should appear in the Network Admin,
1741
+ * otherwise false.
1742
  */
1743
  function bp_core_do_network_admin() {
1744
 
1752
  /**
1753
  * Filters whether or not BuddyPress should appear in network admin.
1754
  *
1755
+ * @since 1.5.0
1756
  *
1757
  * @param bool $retval Whether or not BuddyPress should be in the network admin.
1758
  */
1777
  /**
1778
  * Filters the action name that BuddyPress nav setup callbacks should be hooked to.
1779
  *
1780
+ * @since 1.5.0
1781
  *
1782
  * @param string $hook Action name to be attached to.
1783
  */
1789
  /**
1790
  * Is this the root blog?
1791
  *
1792
+ * @since 1.5.0
1793
  *
1794
  * @param int $blog_id Optional. Default: the ID of the current blog.
1795
+ *
1796
  * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
1797
  */
1798
  function bp_is_root_blog( $blog_id = 0 ) {
1801
  $is_root_blog = false;
1802
 
1803
  // Use current blog if no ID is passed
1804
+ if ( empty( $blog_id ) || ! is_int( $blog_id ) ) {
1805
  $blog_id = get_current_blog_id();
1806
  }
1807
 
1808
  // Compare to root blog ID
1809
+ if ( bp_get_root_blog_id() === $blog_id ) {
1810
  $is_root_blog = true;
1811
  }
1812
 
1813
  /**
1814
  * Filters whether or not we're on the root blog.
1815
  *
1816
+ * @since 1.5.0
1817
  *
1818
  * @param bool $is_root_blog Whether or not we're on the root blog.
1819
  */
1827
  * appears (where member profile URLs resolve, where a given theme is loaded,
1828
  * etc.).
1829
  *
1830
+ * @since 1.5.0
1831
  *
1832
  * @return int The root site ID.
1833
  */
1836
  /**
1837
  * Filters the ID for the root blog.
1838
  *
1839
+ * @since 1.5.0
1840
  *
1841
  * @param int $root_blog_id ID for the root blog.
1842
  */
1866
  * a very small use-case with large architectural shortcomings, so do not go
1867
  * down this road unless you specifically need to.
1868
  *
1869
+ * @since 1.5.0
1870
  *
1871
  * @uses apply_filters() Filter 'bp_is_multiblog_mode' to alter.
1872
  *
1873
  * @return bool False when multiblog mode is disabled; true when enabled.
1874
+ * Default: false.
1875
  */
1876
  function bp_is_multiblog_mode() {
1877
 
1893
  /**
1894
  * Filters whether or not we're running in multiblog mode.
1895
  *
1896
+ * @since 1.5.0
1897
  *
1898
  * @param bool $retval Whether or not we're running multiblog mode.
1899
  */
1908
  * with an mu-plugin or some other method, you'll want to filter
1909
  * 'bp_is_network_activated' and override the auto-determined value.
1910
  *
1911
+ * @since 1.7.0
1912
  *
1913
  * @return bool True if BuddyPress is network activated.
1914
  */
1929
  /**
1930
  * Filters whether or not we're active at the network level.
1931
  *
1932
+ * @since 1.7.0
1933
  *
1934
  * @param bool $retval Whether or not we're network activated.
1935
  */
1941
  /**
1942
  * Set the "is_directory" global.
1943
  *
1944
+ * @param bool $is_directory Optional. Default: false.
1945
+ * @param string $component Optional. Component name. Default: the current
1946
+ * component.
1947
  */
1948
  function bp_update_is_directory( $is_directory = false, $component = '' ) {
1949
 
1954
  /**
1955
  * Filters the "is_directory" global value.
1956
  *
1957
+ * @since 1.5.0
1958
  *
1959
  * @param bool $is_directory Whether or not we're "is_directory".
1960
  * @param string $component Component name. Default: the current component.
1965
  /**
1966
  * Set the "is_item_admin" global.
1967
  *
1968
+ * @param bool $is_item_admin Optional. Default: false.
1969
+ * @param string $component Optional. Component name. Default: the current
1970
+ * component.
1971
  */
1972
  function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
1973
 
1978
  /**
1979
  * Filters the "is_item_admin" global value.
1980
  *
1981
+ * @since 1.5.0
1982
  *
1983
  * @param bool $is_item_admin Whether or not we're "is_item_admin".
1984
  * @param string $component Component name. Default: the current component.
1989
  /**
1990
  * Set the "is_item_mod" global.
1991
  *
1992
+ * @param bool $is_item_mod Optional. Default: false.
1993
+ * @param string $component Optional. Component name. Default: the current
1994
+ * component.
1995
  */
1996
  function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1997
 
2002
  /**
2003
  * Filters the "is_item_mod" global value.
2004
  *
2005
+ * @since 1.5.0
2006
  *
2007
  * @param bool $is_item_mod Whether or not we're "is_item_mod".
2008
  * @param string $component Component name. Default: the current component.
2013
  /**
2014
  * Trigger a 404.
2015
  *
2016
+ * @since 1.5.0
2017
  *
2018
  * @global WP_Query $wp_query WordPress query object.
2019
  *
2020
+ * @param string $redirect If 'remove_canonical_direct', remove WordPress' "helpful"
2021
+ * redirect_canonical action. Default: 'remove_canonical_redirect'.
2022
  */
2023
  function bp_do_404( $redirect = 'remove_canonical_direct' ) {
2024
  global $wp_query;
2026
  /**
2027
  * Fires inside the triggering of a 404.
2028
  *
2029
+ * @since 1.5.0
2030
  *
2031
  * @param string $redirect Redirect type used to determine if redirect_canonical
2032
  * function should be be removed.
2049
  *
2050
  * To avoid security exploits within the theme.
2051
  *
2052
+ * @since 1.6.0
2053
  *
2054
  * @uses do_action() Calls 'bp_verify_nonce_request' on $action.
2055
  *
2056
+ * @param string $action Action nonce.
2057
+ * @param string $query_arg Where to look for nonce in $_REQUEST.
2058
+ *
2059
  * @return bool True if the nonce is verified, otherwise false.
2060
  */
2061
  function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
2064
 
2065
  // Parse home_url() into pieces to remove query-strings, strange characters,
2066
  // and other funny things that plugins might to do to it.
2067
+ $parsed_home = parse_url( home_url( '/', ( is_ssl() ? 'https' : 'http' ) ) );
2068
 
2069
+ // Maybe include the port, if it's included in home_url()
2070
  if ( isset( $parsed_home['port'] ) ) {
2071
  $parsed_host = $parsed_home['host'] . ':' . $parsed_home['port'];
2072
  } else {
2079
  /** Requested URL *********************************************************/
2080
 
2081
  // Maybe include the port, if it's included in home_url()
2082
+ if ( isset( $parsed_home['port'] ) && false === strpos( $_SERVER['HTTP_HOST'], ':' ) ) {
2083
  $request_host = $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'];
2084
  } else {
2085
  $request_host = $_SERVER['HTTP_HOST'];
2096
  *
2097
  * Useful for configurations like reverse proxying.
2098
  *
2099
+ * @since 1.9.0
2100
  *
2101
  * @param string $requested_url The requested URL.
2102
  */
2113
  /**
2114
  * Fires at the end of the nonce verification check.
2115
  *
2116
+ * @since 1.6.0
2117
  *
2118
  * @param string $action Action nonce.
2119
  * @param bool $result Boolean result of nonce verification.
2126
  /** Requests ******************************************************************/
2127
 
2128
  /**
2129
+ * Return true|false if this is a POST request.
2130
  *
2131
+ * @since 1.9.0
2132
  * @return bool
2133
  */
2134
  function bp_is_post_request() {
2136
  }
2137
 
2138
  /**
2139
+ * Return true|false if this is a GET request.
2140
  *
2141
+ * @since 1.9.0
2142
  * @return bool
2143
  */
2144
  function bp_is_get_request() {
2161
  /**
2162
  * Filters the locale to be loaded for the language files.
2163
  *
2164
+ * @since 1.0.2
2165
  *
2166
  * @param string $value Current locale for the install.
2167
  */
2170
  /**
2171
  * Filters the locations to load language files from.
2172
  *
2173
+ * @since 2.2.0
2174
  *
2175
  * @param array $value Array of directories to check for language files in.
2176
  */
2256
  /**
2257
  * Filters the constructed url for use with site searching.
2258
  *
2259
+ * @since 1.0.0
2260
  *
2261
  * @param string $value URL for use with site searching.
2262
  * @param array $search_terms Array of search terms.
2285
  * function, we remove these links when on a BuddyPress page. This also
2286
  * prevents additional, unnecessary queries from running.
2287
  *
2288
+ * @since 2.1.0
2289
  */
2290
  function bp_remove_adjacent_posts_rel_link() {
2291
  if ( ! is_buddypress() ) {
2312
  * example, "My Profile" will always point to the URL of the profile of the
2313
  * logged-in user.
2314
  *
2315
+ * @since 1.9.0
2316
  *
2317
  * @return mixed A URL or an array of dummy pages.
2318
  */
2382
  * nor tax terms, so we fake a post-like object so as to be compatible with the
2383
  * menu.
2384
  *
2385
+ * @since 1.9.0
2386
  *
2387
  * @return mixed A URL or an array of dummy pages.
2388
  */
2453
  * based on the identity of the current user. This function lets you fetch the
2454
  * proper URL for a given nav item slug (such as 'login' or 'messages').
2455
  *
2456
+ * @since 1.9.0
2457
  *
2458
  * @param string $slug The slug of the nav item: login, register, or one of the
2459
+ * slugs from buddypress()->bp_nav.
2460
+ *
2461
  * @return string $nav_item_url The URL generated for the current user.
2462
  */
2463
  function bp_nav_menu_get_item_url( $slug ) {
2479
  * This is used to power BuddyPress' at-mentions suggestions, but it is flexible enough to be used
2480
  * for similar kinds of future requirements, or those implemented by third-party developers.
2481
  *
2482
+ * @since 2.1.0
2483
+ *
2484
  * @param array $args
2485
+ *
2486
  * @return array|WP_Error Array of results. If there were any problems, returns a WP_Error object.
 
2487
  */
2488
  function bp_core_get_suggestions( $args ) {
2489
  $args = bp_parse_args( $args, array(), 'get_suggestions' );
2509
  * Use this hook to tell BP the name of your class
2510
  * if you've built a custom suggestions service.
2511
  *
2512
+ * @since 2.1.0
2513
  *
2514
  * @param string $value Custom class to use. Default: none.
2515
  * @param array $args Array of arguments for sugggestions.
2534
  /**
2535
  * Filters the available type of at-mentions.
2536
  *
2537
+ * @since 2.1.0
2538
  *
2539
  * @param array|WP_Error $retval Array of results or WP_Error object.
2540
  * @param array $args Array of arguments for suggestions.
2551
  * This function ensures that we only need to use {@link switch_to_blog()}
2552
  * once to get what we need.
2553
  *
2554
+ * @since 2.3.0
2555
  *
2556
  * @uses is_multisite()
2557
  * @uses bp_is_root_blog()
bp-core/bp-core-loader.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Core Loader.
5
  *
@@ -9,7 +8,7 @@
9
  * @subpackage Core
10
  */
11
 
12
- // Exit if accessed directly
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  class BP_Core extends BP_Component {
@@ -17,7 +16,7 @@ class BP_Core extends BP_Component {
17
  /**
18
  * Start the members component creation process.
19
  *
20
- * @since BuddyPress (1.5.0)
21
  *
22
  * @uses BP_Core::bootstrap()
23
  */
@@ -37,7 +36,7 @@ class BP_Core extends BP_Component {
37
  * This involves figuring out the currently required, activated, deactivated,
38
  * and optional components.
39
  *
40
- * @since BuddyPress (1.5.0)
41
  */
42
  private function bootstrap() {
43
  $bp = buddypress();
@@ -47,7 +46,7 @@ class BP_Core extends BP_Component {
47
  *
48
  * Allows plugins to run code ahead of the other components.
49
  *
50
- * @since BuddyPress (1.2.0)
51
  */
52
  do_action( 'bp_core_loaded' );
53
 
@@ -56,7 +55,7 @@ class BP_Core extends BP_Component {
56
  /**
57
  * Filters the included and optional components.
58
  *
59
- * @since BuddyPress (1.5.0)
60
  *
61
  * @param array $value Array of included and optional components.
62
  */
@@ -65,7 +64,7 @@ class BP_Core extends BP_Component {
65
  /**
66
  * Filters the required components.
67
  *
68
- * @since BuddyPress (1.5.0)
69
  *
70
  * @param array $value Array of required components.
71
  */
@@ -80,7 +79,7 @@ class BP_Core extends BP_Component {
80
  /**
81
  * Filters the deactivated components.
82
  *
83
- * @since BuddyPress (1.0.0)
84
  *
85
  * @param array $value Array of deactivated components.
86
  */
@@ -136,7 +135,7 @@ class BP_Core extends BP_Component {
136
  /**
137
  * Fires after the loading of individual components.
138
  *
139
- * @since BuddyPress (2.0.0)
140
  */
141
  do_action( 'bp_core_components_included' );
142
  }
@@ -150,8 +149,9 @@ class BP_Core extends BP_Component {
150
  */
151
  public function includes( $includes = array() ) {
152
 
153
- if ( !is_admin() )
154
  return;
 
155
 
156
  $includes = array(
157
  'admin'
@@ -166,7 +166,7 @@ class BP_Core extends BP_Component {
166
  * Sets up a majority of the BuddyPress globals that require a minimal
167
  * amount of processing, meaning they cannot be set in the BuddyPress class.
168
  *
169
- * @since BuddyPress (1.5.0)
170
  *
171
  * @see BP_Component::setup_globals() for description of parameters.
172
  *
@@ -178,20 +178,24 @@ class BP_Core extends BP_Component {
178
  /** Database **********************************************************/
179
 
180
  // Get the base database prefix
181
- if ( empty( $bp->table_prefix ) )
182
  $bp->table_prefix = bp_core_get_table_prefix();
 
183
 
184
  // The domain for the root of the site where the main blog resides
185
- if ( empty( $bp->root_domain ) )
186
  $bp->root_domain = bp_core_get_root_domain();
 
187
 
188
  // Fetches all of the core BuddyPress settings in one fell swoop
189
- if ( empty( $bp->site_options ) )
190
  $bp->site_options = bp_core_get_root_options();
 
191
 
192
  // The names of the core WordPress pages used to display BuddyPress content
193
- if ( empty( $bp->pages ) )
194
  $bp->pages = bp_core_get_directory_pages();
 
195
 
196
  /** Basic current user data *******************************************/
197
 
@@ -210,7 +214,7 @@ class BP_Core extends BP_Component {
210
  /**
211
  * Filters the default user Gravatar.
212
  *
213
- * @since BuddyPress (1.1.0)
214
  *
215
  * @param string $value Default user Gravatar.
216
  */
@@ -219,7 +223,7 @@ class BP_Core extends BP_Component {
219
  /**
220
  * Filters the default group Gravatar.
221
  *
222
- * @since BuddyPress (1.1.0)
223
  *
224
  * @param string $value Default group Gravatar.
225
  */
@@ -228,7 +232,7 @@ class BP_Core extends BP_Component {
228
  /**
229
  * Filters the default blog Gravatar.
230
  *
231
- * @since BuddyPress (1.1.0)
232
  *
233
  * @param string $value Default blog Gravatar.
234
  */
@@ -254,64 +258,15 @@ class BP_Core extends BP_Component {
254
  /**
255
  * Fires at the end of the setup of bp-core globals setting.
256
  *
257
- * @since BuddyPress (1.1.0)
258
  */
259
  do_action( 'bp_core_setup_globals' );
260
  }
261
 
262
- /**
263
- * Set up component navigation.
264
- *
265
- * @since BuddyPress (1.5.0)
266
- *
267
- * @see BP_Component::setup_nav() for a description of arguments.
268
- *
269
- * @param array $main_nav Optional. See BP_Component::setup_nav() for
270
- * description.
271
- * @param array $sub_nav Optional. See BP_Component::setup_nav() for
272
- * description.
273
- */
274
- public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
275
- $bp = buddypress();
276
-
277
- // If xprofile component is disabled, revert to WordPress profile
278
- if ( !bp_is_active( 'xprofile' ) ) {
279
-
280
- // Fallback values if xprofile is disabled
281
- if ( ! isset( $bp->core->profile ) ) {
282
- $bp->core->profile = new stdClass;
283
- }
284
- $bp->core->profile->slug = 'profile';
285
- $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug;
286
-
287
- // Add 'Profile' to the main navigation
288
- $main_nav = array(
289
- 'name' => _x( 'Profile', 'Main navigation', 'buddypress' ),
290
- 'slug' => $bp->core->profile->slug,
291
- 'position' => 20,
292
- 'screen_function' => 'bp_core_catch_profile_uri',
293
- 'default_subnav_slug' => 'public'
294
- );
295
-
296
- $profile_link = trailingslashit( bp_loggedin_user_domain() . '/' . $bp->core->profile->slug );
297
-
298
- // Add the subnav items to the profile
299
- $sub_nav[] = array(
300
- 'name' => _x( 'View', 'Profile sub nav', 'buddypress' ),
301
- 'slug' => 'public',
302
- 'parent_url' => $profile_link,
303
- 'parent_slug' => $bp->core->profile->slug,
304
- 'screen_function' => 'bp_core_catch_profile_uri'
305
- );
306
-
307
- parent::setup_nav( $main_nav, $sub_nav );
308
- }
309
- }
310
-
311
  /**
312
  * Setup cache groups
313
  *
314
- * @since BuddyPress (2.2.0)
315
  */
316
  public function setup_cache_groups() {
317
 
@@ -327,7 +282,7 @@ class BP_Core extends BP_Component {
327
  /**
328
  * Set up the BuddyPress Core component.
329
  *
330
- * @since BuddyPress (1.6.0)
331
  *
332
  * @global BuddyPress $bp BuddyPress global settings object.
333
  */
1
  <?php
 
2
  /**
3
  * BuddyPress Core Loader.
4
  *
8
  * @subpackage Core
9
  */
10
 
11
+ // Exit if accessed directly.
12
  defined( 'ABSPATH' ) || exit;
13
 
14
  class BP_Core extends BP_Component {
16
  /**
17
  * Start the members component creation process.
18
  *
19
+ * @since 1.5.0
20
  *
21
  * @uses BP_Core::bootstrap()
22
  */
36
  * This involves figuring out the currently required, activated, deactivated,
37
  * and optional components.
38
  *
39
+ * @since 1.5.0
40
  */
41
  private function bootstrap() {
42
  $bp = buddypress();
46
  *
47
  * Allows plugins to run code ahead of the other components.
48
  *
49
+ * @since 1.2.0
50
  */
51
  do_action( 'bp_core_loaded' );
52
 
55
  /**
56
  * Filters the included and optional components.
57
  *
58
+ * @since 1.5.0
59
  *
60
  * @param array $value Array of included and optional components.
61
  */
64
  /**
65
  * Filters the required components.
66
  *
67
+ * @since 1.5.0
68
  *
69
  * @param array $value Array of required components.
70
  */
79
  /**
80
  * Filters the deactivated components.
81
  *
82
+ * @since 1.0.0
83
  *
84
  * @param array $value Array of deactivated components.
85
  */
135
  /**
136
  * Fires after the loading of individual components.
137
  *
138
+ * @since 2.0.0
139
  */
140
  do_action( 'bp_core_components_included' );
141
  }
149
  */
150
  public function includes( $includes = array() ) {
151
 
152
+ if ( ! is_admin() ) {
153
  return;
154
+ }
155
 
156
  $includes = array(
157
  'admin'
166
  * Sets up a majority of the BuddyPress globals that require a minimal
167
  * amount of processing, meaning they cannot be set in the BuddyPress class.
168
  *
169
+ * @since 1.5.0
170
  *
171
  * @see BP_Component::setup_globals() for description of parameters.
172
  *
178
  /** Database **********************************************************/
179
 
180
  // Get the base database prefix
181
+ if ( empty( $bp->table_prefix ) ) {
182
  $bp->table_prefix = bp_core_get_table_prefix();
183
+ }
184
 
185
  // The domain for the root of the site where the main blog resides
186
+ if ( empty( $bp->root_domain ) ) {
187
  $bp->root_domain = bp_core_get_root_domain();
188
+ }
189
 
190
  // Fetches all of the core BuddyPress settings in one fell swoop
191
+ if ( empty( $bp->site_options ) ) {
192
  $bp->site_options = bp_core_get_root_options();
193
+ }
194
 
195
  // The names of the core WordPress pages used to display BuddyPress content
196
+ if ( empty( $bp->pages ) ) {
197
  $bp->pages = bp_core_get_directory_pages();
198
+ }
199
 
200
  /** Basic current user data *******************************************/
201
 
214
  /**
215
  * Filters the default user Gravatar.
216
  *
217
+ * @since 1.1.0
218
  *
219
  * @param string $value Default user Gravatar.
220
  */
223
  /**
224
  * Filters the default group Gravatar.
225
  *
226
+ * @since 1.1.0
227
  *
228
  * @param string $value Default group Gravatar.
229
  */
232
  /**
233
  * Filters the default blog Gravatar.
234
  *
235
+ * @since 1.1.0
236
  *
237
  * @param string $value Default blog Gravatar.
238
  */
258
  /**
259
  * Fires at the end of the setup of bp-core globals setting.
260
  *
261
+ * @since 1.1.0
262
  */
263
  do_action( 'bp_core_setup_globals' );
264
  }
265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  /**
267
  * Setup cache groups
268
  *
269
+ * @since 2.2.0
270
  */
271
  public function setup_cache_groups() {
272
 
282
  /**
283
  * Set up the BuddyPress Core component.
284
  *
285
+ * @since 1.6.0
286
  *
287
  * @global BuddyPress $bp BuddyPress global settings object.
288
  */
bp-core/bp-core-moderation.php CHANGED
@@ -4,10 +4,10 @@
4
  *
5
  * @package BuddyPress
6
  * @subpackage Core
7
- * @since BuddyPress (1.6.0)
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /** Moderation ****************************************************************/
@@ -18,7 +18,7 @@ defined( 'ABSPATH' ) || exit;
18
  * Check to make sure that a user is not making too many posts in a short amount
19
  * of time.
20
  *
21
- * @since BuddyPress (1.6.0)
22
  *
23
  * @uses current_user_can() To check if the current user can throttle.
24
  * @uses bp_get_option() To get the throttle time.
@@ -26,6 +26,7 @@ defined( 'ABSPATH' ) || exit;
26
  * @uses get_user_meta() To get the last posted meta of the user.
27
  *
28
  * @param int $user_id User id to check for flood.
 
29
  * @return bool True if there is no flooding, false if there is.
30
  */
31
  function bp_core_check_for_flood( $user_id = 0 ) {
@@ -51,15 +52,16 @@ function bp_core_check_for_flood( $user_id = 0 ) {
51
  /**
52
  * Check for moderation keys and too many links.
53
  *
54
- * @since BuddyPress (1.6.0)
55
  *
56
  * @uses bp_current_author_ip() To get current user IP address.
57
  * @uses bp_current_author_ua() To get current user agent.
58
  * @uses bp_current_user_can() Allow super admins to bypass blacklist.
59
  *
60
- * @param int $user_id Topic or reply author ID.
61
- * @param string $title The title of the content.
62
  * @param string $content The content being posted.
 
63
  * @return bool True if test is passed, false if fail.
64
  */
65
  function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {
@@ -67,7 +69,7 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = ''
67
  /**
68
  * Filters whether or not to bypass checking for moderation keys and too many links.
69
  *
70
- * @since BuddyPress (2.2.0)
71
  *
72
  * @param bool $value Whether or not to bypass checking. Default false.
73
  * @param int $user_id Topic of reply author ID.
@@ -124,7 +126,7 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = ''
124
  /**
125
  * Filters the maximum amount of links allowed to include the user's URL.
126
  *
127
- * @since BuddyPress (1.6.0)
128
  *
129
  * @param string $num_links How many links found.
130
  * @param string $value User's url.
@@ -185,15 +187,16 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = ''
185
  /**
186
  * Check for blocked keys.
187
  *
188
- * @since BuddyPress (1.6.0)
189
  *
190
  * @uses bp_current_author_ip() To get current user IP address.
191
  * @uses bp_current_author_ua() To get current user agent.
192
  * @uses bp_current_user_can() Allow super admins to bypass blacklist.
193
  *
194
- * @param int $user_id Topic or reply author ID.
195
- * @param string $title The title of the content.
196
  * @param string $content The content being posted.
 
197
  * @return bool True if test is passed, false if fail.
198
  */
199
  function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {
@@ -201,7 +204,7 @@ function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' )
201
  /**
202
  * Filters whether or not to bypass checking for blocked keys.
203
  *
204
- * @since BuddyPress (2.2.0)
205
  *
206
  * @param bool $value Whether or not to bypass checking. Default false.
207
  * @param int $user_id Topic of reply author ID.
@@ -292,7 +295,7 @@ function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' )
292
  /**
293
  * Get the current user's IP address.
294
  *
295
- * @since BuddyPress (1.6.0)
296
  *
297
  * @return string IP address.
298
  */
@@ -302,7 +305,7 @@ function bp_core_current_user_ip() {
302
  /**
303
  * Filters the current user's IP address.
304
  *
305
- * @since BuddyPress (1.6.0)
306
  *
307
  * @param string $retval Current user's IP Address.
308
  */
@@ -312,7 +315,7 @@ function bp_core_current_user_ip() {
312
  /**
313
  * Get the current user's user-agent.
314
  *
315
- * @since BuddyPress (1.6.0)
316
  *
317
  * @return string User agent string.
318
  */
@@ -328,9 +331,9 @@ function bp_core_current_user_ua() {
328
  /**
329
  * Filters the current user's user-agent.
330
  *
331
- * @since BuddyPress (1.6.0)
332
  *
333
- * @param string $retval Current user's user-agent
334
  */
335
  return apply_filters( 'bp_core_current_user_ua', $retval );
336
  }
4
  *
5
  * @package BuddyPress
6
  * @subpackage Core
7
+ * @since 1.6.0
8
  */
9
 
10
+ // Exit if accessed directly.
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /** Moderation ****************************************************************/
18
  * Check to make sure that a user is not making too many posts in a short amount
19
  * of time.
20
  *
21
+ * @since 1.6.0
22
  *
23
  * @uses current_user_can() To check if the current user can throttle.
24
  * @uses bp_get_option() To get the throttle time.
26
  * @uses get_user_meta() To get the last posted meta of the user.
27
  *
28
  * @param int $user_id User id to check for flood.
29
+ *
30
  * @return bool True if there is no flooding, false if there is.
31
  */
32
  function bp_core_check_for_flood( $user_id = 0 ) {
52
  /**
53
  * Check for moderation keys and too many links.
54
  *
55
+ * @since 1.6.0
56
  *
57
  * @uses bp_current_author_ip() To get current user IP address.
58
  * @uses bp_current_author_ua() To get current user agent.
59
  * @uses bp_current_user_can() Allow super admins to bypass blacklist.
60
  *
61
+ * @param int $user_id Topic or reply author ID.
62
+ * @param string $title The title of the content.
63
  * @param string $content The content being posted.
64
+ *
65
  * @return bool True if test is passed, false if fail.
66
  */
67
  function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {
69
  /**
70
  * Filters whether or not to bypass checking for moderation keys and too many links.
71
  *
72
+ * @since 2.2.0
73
  *
74
  * @param bool $value Whether or not to bypass checking. Default false.
75
  * @param int $user_id Topic of reply author ID.
126
  /**
127
  * Filters the maximum amount of links allowed to include the user's URL.
128
  *
129
+ * @since 1.6.0
130
  *
131
  * @param string $num_links How many links found.
132
  * @param string $value User's url.
187
  /**
188
  * Check for blocked keys.
189
  *
190
+ * @since 1.6.0
191
  *
192
  * @uses bp_current_author_ip() To get current user IP address.
193
  * @uses bp_current_author_ua() To get current user agent.
194
  * @uses bp_current_user_can() Allow super admins to bypass blacklist.
195
  *
196
+ * @param int $user_id Topic or reply author ID.
197
+ * @param string $title The title of the content.
198
  * @param string $content The content being posted.
199
+ *
200
  * @return bool True if test is passed, false if fail.
201
  */
202
  function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {
204
  /**
205
  * Filters whether or not to bypass checking for blocked keys.
206
  *
207
+ * @since 2.2.0
208
  *
209
  * @param bool $value Whether or not to bypass checking. Default false.
210
  * @param int $user_id Topic of reply author ID.
295
  /**
296
  * Get the current user's IP address.
297
  *
298
+ * @since 1.6.0
299
  *
300
  * @return string IP address.
301
  */
305
  /**
306
  * Filters the current user's IP address.
307
  *
308
+ * @since 1.6.0
309
  *
310
  * @param string $retval Current user's IP Address.
311
  */
315
  /**
316
  * Get the current user's user-agent.
317
  *
318
+ * @since 1.6.0
319
  *
320
  * @return string User agent string.
321
  */
331
  /**
332
  * Filters the current user's user-agent.
333
  *
334
+ * @since 1.6.0
335
  *
336
+ * @param string $retval Current user's user-agent.
337
  */
338
  return apply_filters( 'bp_core_current_user_ua', $retval );
339
  }
bp-core/bp-core-options.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Options.
5
  *
@@ -7,13 +6,13 @@
7
  * @subpackage Options
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * Get the default site options and their values.
15
  *
16
- * @since BuddyPress (1.6.0)
17
  *
18
  * @return array Filtered option names and values.
19
  */
@@ -24,75 +23,81 @@ function bp_get_default_options() {
24
 
25
  /** Components ********************************************************/
26
 
27
- 'bp-deactivated-components' => array(),
28
 
29
  /** bbPress ***********************************************************/
30
 
31
  // Legacy bbPress config location
32
- 'bb-config-location' => ABSPATH . 'bb-config.php',
33
 
34
  /** XProfile **********************************************************/
35
 
36
  // Base profile groups name
37
- 'bp-xprofile-base-group-name' => 'Base',
38
 
39
  // Base fullname field name
40
- 'bp-xprofile-fullname-field-name' => 'Name',
41
 
42
  /** Blogs *************************************************************/
43
 
44
  // Used to decide if blogs need indexing
45
- 'bp-blogs-first-install' => false,
46
 
47
  /** Settings **********************************************************/
48
 
49
  // Disable the WP to BP profile sync
50
- 'bp-disable-profile-sync' => false,
51
 
52
  // Hide the Toolbar for logged out users
53
- 'hide-loggedout-adminbar' => false,
54
 
55
  // Avatar uploads
56
- 'bp-disable-avatar-uploads' => false,
 
 
 
57
 
58
  // Group Profile Photos
59
- 'bp-disable-group-avatar-uploads' => false,
 
 
 
60
 
61
  // Allow users to delete their own accounts
62
- 'bp-disable-account-deletion' => false,
63
 
64
  // Allow comments on blog and forum activity items
65
- 'bp-disable-blogforum-comments' => true,
66
 
67
  // The ID for the current theme package.
68
- '_bp_theme_package_id' => 'legacy',
69
 
70
  /** Groups ************************************************************/
71
 
72
  // @todo Move this into the groups component
73
 
74
  // Restrict group creation to super admins
75
- 'bp_restrict_group_creation' => false,
76
 
77
  /** Akismet ***********************************************************/
78
 
79
  // Users from all sites can post
80
- '_bp_enable_akismet' => true,
81
 
82
  /** Activity HeartBeat ************************************************/
83
 
84
  // HeartBeat is on to refresh activities
85
- '_bp_enable_heartbeat_refresh' => true,
86
 
87
  /** BuddyBar **********************************************************/
88
 
89
  // Force the BuddyBar
90
- '_bp_force_buddybar' => false,
91
 
92
  /** Legacy theme *********************************************/
93
 
94
  // Whether to register the bp-default themes directory
95
- '_bp_retain_bp_default' => false,
96
 
97
  /** Widgets **************************************************/
98
  'widget_bp_core_login_widget' => false,
@@ -106,7 +111,7 @@ function bp_get_default_options() {
106
  /**
107
  * Filters the default options to be set upon activation.
108
  *
109
- * @since BuddyPress (1.6.0)
110
  *
111
  * @param array $options Array of default options to set.
112
  */
@@ -119,7 +124,7 @@ function bp_get_default_options() {
119
  * Only called once when BuddyPress is activated.
120
  * Non-destructive, so existing settings will not be overridden.
121
  *
122
- * @since BuddyPress (1.6.0)
123
  *
124
  * @uses bp_get_default_options() To get default options.
125
  * @uses add_option() Adds default options.
@@ -140,7 +145,7 @@ function bp_add_options() {
140
  *
141
  * Allows previously activated plugins to append their own options.
142
  *
143
- * @since BuddyPress (1.6.0)
144
  */
145
  do_action( 'bp_add_options' );
146
  }
@@ -153,7 +158,7 @@ function bp_add_options() {
153
  *
154
  * Currently unused.
155
  *
156
- * @since BuddyPress (1.6.0)
157
  *
158
  * @uses bp_get_default_options() To get default options.
159
  * @uses delete_option() Removes default options.
@@ -174,7 +179,7 @@ function bp_delete_options() {
174
  *
175
  * Allows previously activated plugins to append their own options.
176
  *
177
- * @since BuddyPress (1.6.0)
178
  */
179
  do_action( 'bp_delete_options' );
180
  }
@@ -184,7 +189,7 @@ function bp_delete_options() {
184
  *
185
  * Currently unused.
186
  *
187
- * @since BuddyPress (1.6.0)
188
  *
189
  * @uses bp_get_default_options() To get default options.
190
  * @uses add_filter() To add filters to 'pre_option_{$key}'.
@@ -205,7 +210,7 @@ function bp_setup_option_filters() {
205
  *
206
  * Allows previously activated plugins to append their own options.
207
  *
208
- * @since BuddyPress (1.6.0)
209
  */
210
  do_action( 'bp_setup_option_filters' );
211
  }
@@ -215,10 +220,11 @@ function bp_setup_option_filters() {
215
  *
216
  * Currently unused.
217
  *
218
- * @since BuddyPress (1.6.0)
 
 
219
  *
220
- * @param bool $value Optional. Default value false
221
- * @return mixed false if not overloaded, mixed if set
222
  */
223
  function bp_pre_get_option( $value = false ) {
224
  $bp = buddypress();
@@ -246,13 +252,14 @@ function bp_pre_get_option( $value = false ) {
246
  *
247
  * The 'bp_get_option' filter is primarily for backward-compatibility.
248
  *
249
- * @since BuddyPress (1.2.0)
250
  *
251
  * @uses bp_get_root_blog_id()
252
  *
253
  * @param string $option_name The option to be retrieved.
254
- * @param string $default Optional. Default value to be returned if the option
255
- * isn't set. See {@link get_blog_option()}.
 
256
  * @return mixed The value for the option.
257
  */
258
  function bp_get_option( $option_name, $default = '' ) {
@@ -261,7 +268,7 @@ function bp_get_option( $option_name, $default = '' ) {
261
  /**
262
  * Filters the option value for the requested option.
263
  *
264
- * @since BuddyPress (1.2.0)
265
  *
266
  * @param mixed $value The value for the option.
267
  */
@@ -274,10 +281,11 @@ function bp_get_option( $option_name, $default = '' ) {
274
  * This is a wrapper for {@link add_blog_option()}, which in turn stores
275
  * settings data on the appropriate blog, given your current setup.
276
  *
277
- * @since BuddyPress (2.0.0)
278
  *
279
  * @param string $option_name The option key to be set.
280
- * @param mixed $value The value to be set.
 
281
  * @return bool True on success, false on failure.
282
  */
283
  function bp_add_option( $option_name, $value ) {
@@ -291,12 +299,13 @@ function bp_add_option( $option_name, $value ) {
291
  * settings data (such as bp-pages) on the appropriate blog, given your current
292
  * setup.
293
  *
294
- * @since BuddyPress (1.5.0)
295
  *
296
  * @uses bp_get_root_blog_id()
297
  *
298
  * @param string $option_name The option key to be set.
299
- * @param string $value The value to be set.
 
300
  * @return bool True on success, false on failure.
301
  */
302
  function bp_update_option( $option_name, $value ) {
@@ -310,11 +319,12 @@ function bp_update_option( $option_name, $value ) {
310
  * settings data (such as bp-pages) on the appropriate blog, given your current
311
  * setup.
312
  *
313
- * @since BuddyPress (1.5.0)
314
  *
315
  * @uses bp_get_root_blog_id()
316
  *
317
  * @param string $option_name The option key to be deleted.
 
318
  * @return bool True on success, false on failure.
319
  */
320
  function bp_delete_option( $option_name ) {
@@ -330,6 +340,10 @@ function bp_delete_option( $option_name ) {
330
  * This function is no longer used.
331
  *
332
  * @deprecated 1.6.0
 
 
 
 
333
  */
334
  function bp_core_activate_site_options( $keys = array() ) {
335
 
@@ -394,7 +408,7 @@ function bp_core_get_root_options() {
394
  /**
395
  * Filters multisite options retrieved from sitemeta.
396
  *
397
- * @since BuddyPress (1.5.0)
398
  *
399
  * @param array $value Array of multisite options from sitemeta table.
400
  */
@@ -477,7 +491,7 @@ function bp_core_get_root_options() {
477
  /**
478
  * Filters the global BP options.
479
  *
480
- * @since BuddyPress (1.5.0)
481
  *
482
  * @param array $root_blog_options_meta Array of global BP options.
483
  */
@@ -491,9 +505,10 @@ function bp_core_get_root_options() {
491
  * time during a pageload and stored in `buddypress()->site_options` to prevent future lookups.
492
  * See {@see bp_core_get_root_options()}.
493
  *
494
- * @since BuddyPress (2.3.0)
495
  *
496
  * @param string $option Name of the option key.
 
497
  * @return mixed Value, if found.
498
  */
499
  function bp_core_get_root_option( $option ) {
@@ -516,12 +531,13 @@ function bp_core_get_root_option( $option ) {
516
  /**
517
  * Is profile syncing disabled?
518
  *
519
- * @since BuddyPress (1.6.0)
520
  *
521
  * @uses bp_get_option() To get the profile sync option.
522
  *
523
  * @param bool $default Optional. Fallback value if not found in the database.
524
- * Default: true.
 
525
  * @return bool True if profile sync is enabled, otherwise false.
526
  */
527
  function bp_disable_profile_sync( $default = false ) {
@@ -529,7 +545,7 @@ function bp_disable_profile_sync( $default = false ) {
529
  /**
530
  * Filters whether or not profile syncing is disabled.
531
  *
532
- * @since BuddyPress (1.6.0)
533
  *
534
  * @param bool $value Whether or not syncing is disabled.
535
  */
@@ -539,21 +555,22 @@ function bp_disable_profile_sync( $default = false ) {
539
  /**
540
  * Is the Toolbar hidden for logged out users?
541
  *
542
- * @since BuddyPress (1.6.0)
543
  *
544
  * @uses bp_get_option() To get the logged out Toolbar option.
545
  *
546
  * @param bool $default Optional. Fallback value if not found in the database.
547
- * Default: true.
 
548
  * @return bool True if the admin bar should be hidden for logged-out users,
549
- * otherwise false.
550
  */
551
  function bp_hide_loggedout_adminbar( $default = true ) {
552
 
553
  /**
554
  * Filters whether or not the toolbar is hidden for logged out users.
555
  *
556
- * @since BuddyPress (1.6.0)
557
  *
558
  * @param bool $value Whether or not the toolbar is hidden.
559
  */
@@ -563,12 +580,13 @@ function bp_hide_loggedout_adminbar( $default = true ) {
563
  /**
564
  * Are members able to upload their own avatars?
565
  *
566
- * @since BuddyPress (1.6.0)
567
  *
568
  * @uses bp_get_option() To get the avatar uploads option.
569
  *
570
  * @param bool $default Optional. Fallback value if not found in the database.
571
- * Default: true.
 
572
  * @return bool True if avatar uploads are disabled, otherwise false.
573
  */
574
  function bp_disable_avatar_uploads( $default = true ) {
@@ -576,23 +594,48 @@ function bp_disable_avatar_uploads( $default = true ) {
576
  /**
577
  * Filters whether or not members are able to upload their own avatars.
578
  *
579
- * @since BuddyPress (1.6.0)
580
  *
581
  * @param bool $value Whether or not members are able to upload their own avatars.
582
  */
583
  return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
584
  }
585
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
586
  /**
587
  * Are group avatars disabled?
588
  *
589
  * For backward compatibility, this option falls back on the value of 'bp-disable-avatar-uploads' when no value is
590
  * found in the database.
591
  *
592
- * @since BuddyPress (2.3.0)
 
 
 
593
  *
594
- * @param bool $default Optional. Fallback value if not found in the database.
595
- * Defaults to the value of `bp_disable_avatar_uploads()`.
596
  * @return bool True if group avatar uploads are disabled, otherwise false.
597
  */
598
  function bp_disable_group_avatar_uploads( $default = null ) {
@@ -609,7 +652,7 @@ function bp_disable_group_avatar_uploads( $default = null ) {
609
  /**
610
  * Filters whether or not members are able to upload group avatars.
611
  *
612
- * @since BuddyPress (2.3.0)
613
  *
614
  * @param bool $disabled Whether or not members are able to upload their groups avatars.
615
  * @param bool $default Default value passed to the function.
@@ -617,24 +660,49 @@ function bp_disable_group_avatar_uploads( $default = null ) {
617
  return (bool) apply_filters( 'bp_disable_group_avatar_uploads', $disabled, $default );
618
  }
619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
620
  /**
621
  * Are members able to delete their own accounts?
622
  *
623
- * @since BuddyPress (1.6.0)
624
  *
625
  * @uses bp_get_option() To get the account deletion option.
626
  *
627
  * @param bool $default Optional. Fallback value if not found in the database.
628
- * Default: true.
 
629
  * @return bool True if users are able to delete their own accounts, otherwise
630
- * false.
631
  */
632
  function bp_disable_account_deletion( $default = false ) {
633
 
634
  /**
635
  * Filters whether or not members are able to delete their own accounts.
636
  *
637
- * @since BuddyPress (1.6.0)
638
  *
639
  * @param bool $value Whether or not members are able to delete their own accounts.
640
  */
@@ -644,22 +712,23 @@ function bp_disable_account_deletion( $default = false ) {
644
  /**
645
  * Are blog and forum activity stream comments disabled?
646
  *
647
- * @since BuddyPress (1.6.0)
648
  *
649
  * @todo split and move into blog and forum components.
650
  * @uses bp_get_option() To get the blog/forum comments option.
651
  *
652
  * @param bool $default Optional. Fallback value if not found in the database.
653
- * Default: false.
 
654
  * @return bool True if activity comments are disabled for blog and forum
655
- * items, otherwise false.
656
  */
657
  function bp_disable_blogforum_comments( $default = false ) {
658
 
659
  /**
660
  * Filters whether or not blog and forum activity stream comments are disabled.
661
  *
662
- * @since BuddyPress (1.6.0)
663
  *
664
  * @param bool $value Whether or not blog and forum activity stream comments are disabled.
665
  */
@@ -669,13 +738,14 @@ function bp_disable_blogforum_comments( $default = false ) {
669
  /**
670
  * Is group creation turned off?
671
  *
672
- * @since BuddyPress (1.6.0)
673
  *
674
  * @todo Move into groups component.
675
  * @uses bp_get_option() To get the group creation.
676
  *
677
  * @param bool $default Optional. Fallback value if not found in the database.
678
- * Default: true.
 
679
  * @return bool True if group creation is restricted, otherwise false.
680
  */
681
  function bp_restrict_group_creation( $default = true ) {
@@ -683,7 +753,7 @@ function bp_restrict_group_creation( $default = true ) {
683
  /**
684
  * Filters whether or not group creation is turned off.
685
  *
686
- * @since BuddyPress (1.6.0)
687
  *
688
  * @param bool $value Whether or not group creation is turned off.
689
  */
@@ -693,12 +763,13 @@ function bp_restrict_group_creation( $default = true ) {
693
  /**
694
  * Should the old BuddyBar be forced in place of the WP admin bar?
695
  *
696
- * @since BuddyPress (1.6.0)
697
  *
698
  * @uses bp_get_option() To get the BuddyBar option.
699
  *
700
  * @param bool $default Optional. Fallback value if not found in the database.
701
- * Default: true.
 
702
  * @return bool True if the BuddyBar should be forced on, otherwise false.
703
  */
704
  function bp_force_buddybar( $default = true ) {
@@ -706,7 +777,7 @@ function bp_force_buddybar( $default = true ) {
706
  /**
707
  * Filters whether or not BuddyBar should be forced in place of WP Admin Bar.
708
  *
709
- * @since BuddyPress (1.6.0)
710
  *
711
  * @param bool $value Whether or not BuddyBar should be forced in place of WP Admin Bar.
712
  */
@@ -716,9 +787,9 @@ function bp_force_buddybar( $default = true ) {
716
  /**
717
  * Output the group forums root parent forum id.
718
  *
719
- * @since BuddyPress (1.6.0)
720
  *
721
- * @param bool $default Optional. Default: '0'.
722
  */
723
  function bp_group_forums_root_id( $default = '0' ) {
724
  echo bp_get_group_forums_root_id( $default );
@@ -726,11 +797,12 @@ function bp_group_forums_root_id( $default = '0' ) {
726
  /**
727
  * Return the group forums root parent forum id.
728
  *
729
- * @since BuddyPress (1.6.0)
730
  *
731
  * @uses bp_get_option() To get the root forum ID from the database.
732
  *
733
- * @param bool $default Optional. Default: '0'.
 
734
  * @return int The ID of the group forums root forum.
735
  */
736
  function bp_get_group_forums_root_id( $default = '0' ) {
@@ -738,7 +810,7 @@ function bp_group_forums_root_id( $default = '0' ) {
738
  /**
739
  * Filters the group forums root parent forum id.
740
  *
741
- * @since BuddyPress (1.6.0)
742
  *
743
  * @param int $value The group forums root parent forum id.
744
  */
@@ -748,12 +820,13 @@ function bp_group_forums_root_id( $default = '0' ) {
748
  /**
749
  * Check whether BuddyPress Group Forums are enabled.
750
  *
751
- * @since BuddyPress (1.6.0)
752
  *
753
  * @uses bp_get_option() To get the group forums option.
754
  *
755
  * @param bool $default Optional. Fallback value if not found in the database.
756
- * Default: true.
 
757
  * @return bool True if group forums are active, otherwise false.
758
  */
759
  function bp_is_group_forums_active( $default = true ) {
@@ -761,7 +834,7 @@ function bp_is_group_forums_active( $default = true ) {
761
  /**
762
  * Filters whether or not BuddyPress Group Forums are enabled.
763
  *
764
- * @since BuddyPress (1.6.0)
765
  *
766
  * @param bool $value Whether or not BuddyPress Group Forums are enabled.
767
  */
@@ -771,12 +844,13 @@ function bp_is_group_forums_active( $default = true ) {
771
  /**
772
  * Check whether Akismet is enabled.
773
  *
774
- * @since BuddyPress (1.6.0)
775
  *
776
  * @uses bp_get_option() To get the Akismet option.
777
  *
778
  * @param bool $default Optional. Fallback value if not found in the database.
779
- * Default: true.
 
780
  * @return bool True if Akismet is enabled, otherwise false.
781
  */
782
  function bp_is_akismet_active( $default = true ) {
@@ -784,7 +858,7 @@ function bp_is_akismet_active( $default = true ) {
784
  /**
785
  * Filters whether or not Akismet is enabled.
786
  *
787
- * @since BuddyPress (1.6.0)
788
  *
789
  * @param bool $value Whether or not Akismet is enabled.
790
  */
@@ -794,12 +868,13 @@ function bp_is_akismet_active( $default = true ) {
794
  /**
795
  * Check whether Activity Heartbeat refresh is enabled.
796
  *
797
- * @since BuddyPress (2.0.0)
798
  *
799
  * @uses bp_get_option() To get the Heartbeat option.
800
  *
801
  * @param bool $default Optional. Fallback value if not found in the database.
802
- * Default: true.
 
803
  * @return bool True if Heartbeat refresh is enabled, otherwise false.
804
  */
805
  function bp_is_activity_heartbeat_active( $default = true ) {
@@ -807,7 +882,7 @@ function bp_is_activity_heartbeat_active( $default = true ) {
807
  /**
808
  * Filters whether or not Activity Heartbeat refresh is enabled.
809
  *
810
- * @since BuddyPress (2.0.0)
811
  *
812
  * @param bool $value Whether or not Activity Heartbeat refresh is enabled.
813
  */
@@ -817,12 +892,13 @@ function bp_is_activity_heartbeat_active( $default = true ) {
817
  /**
818
  * Get the current theme package ID.
819
  *
820
- * @since BuddyPress (1.7.0)
821
  *
822
  * @uses get_option() To get the theme package option.
823
  *
824
- * @param bool $default Optional. Fallback value if not found in the database.
825
- * Default: 'legacy'.
 
826
  * @return string ID of the theme package.
827
  */
828
  function bp_get_theme_package_id( $default = 'legacy' ) {
@@ -830,7 +906,7 @@ function bp_get_theme_package_id( $default = 'legacy' ) {
830
  /**
831
  * Filters the current theme package ID.
832
  *
833
- * @since BuddyPress (1.7.0)
834
  *
835
  * @param string $value The current theme package ID.
836
  */
1
  <?php
 
2
  /**
3
  * BuddyPress Options.
4
  *
6
  * @subpackage Options
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
13
  * Get the default site options and their values.
14
  *
15
+ * @since 1.6.0
16
  *
17
  * @return array Filtered option names and values.
18
  */
23
 
24
  /** Components ********************************************************/
25
 
26
+ 'bp-deactivated-components' => array(),
27
 
28
  /** bbPress ***********************************************************/
29
 
30
  // Legacy bbPress config location
31
+ 'bb-config-location' => ABSPATH . 'bb-config.php',
32
 
33
  /** XProfile **********************************************************/
34
 
35
  // Base profile groups name
36
+ 'bp-xprofile-base-group-name' => 'Base',
37
 
38
  // Base fullname field name
39
+ 'bp-xprofile-fullname-field-name' => 'Name',
40
 
41
  /** Blogs *************************************************************/
42
 
43
  // Used to decide if blogs need indexing
44
+ 'bp-blogs-first-install' => false,
45
 
46
  /** Settings **********************************************************/
47
 
48
  // Disable the WP to BP profile sync
49
+ 'bp-disable-profile-sync' => false,
50
 
51
  // Hide the Toolbar for logged out users
52
+ 'hide-loggedout-adminbar' => false,
53
 
54
  // Avatar uploads
55
+ 'bp-disable-avatar-uploads' => false,
56
+
57
+ // Cover image uploads
58
+ 'bp-disable-cover-image-uploads' => false,
59
 
60
  // Group Profile Photos
61
+ 'bp-disable-group-avatar-uploads' => false,
62
+
63
+ // Group Cover image uploads
64
+ 'bp-disable-group-cover-image-uploads' => false,
65
 
66
  // Allow users to delete their own accounts
67
+ 'bp-disable-account-deletion' => false,
68
 
69
  // Allow comments on blog and forum activity items
70
+ 'bp-disable-blogforum-comments' => true,
71
 
72
  // The ID for the current theme package.
73
+ '_bp_theme_package_id' => 'legacy',
74
 
75
  /** Groups ************************************************************/
76
 
77
  // @todo Move this into the groups component
78
 
79
  // Restrict group creation to super admins
80
+ 'bp_restrict_group_creation' => false,
81
 
82
  /** Akismet ***********************************************************/
83
 
84
  // Users from all sites can post
85
+ '_bp_enable_akismet' => true,
86
 
87
  /** Activity HeartBeat ************************************************/
88
 
89
  // HeartBeat is on to refresh activities
90
+ '_bp_enable_heartbeat_refresh' => true,
91
 
92
  /** BuddyBar **********************************************************/
93
 
94
  // Force the BuddyBar
95
+ '_bp_force_buddybar' => false,
96
 
97
  /** Legacy theme *********************************************/
98
 
99
  // Whether to register the bp-default themes directory
100
+ '_bp_retain_bp_default' => false,
101
 
102
  /** Widgets **************************************************/
103
  'widget_bp_core_login_widget' => false,
111
  /**
112
  * Filters the default options to be set upon activation.
113
  *
114
+ * @since 1.6.0
115
  *
116
  * @param array $options Array of default options to set.
117
  */
124
  * Only called once when BuddyPress is activated.
125
  * Non-destructive, so existing settings will not be overridden.
126
  *
127
+ * @since 1.6.0
128
  *
129
  * @uses bp_get_default_options() To get default options.
130
  * @uses add_option() Adds default options.
145
  *
146
  * Allows previously activated plugins to append their own options.
147
  *
148
+ * @since 1.6.0
149
  */
150
  do_action( 'bp_add_options' );
151
  }
158
  *
159
  * Currently unused.
160
  *
161
+ * @since 1.6.0
162
  *
163
  * @uses bp_get_default_options() To get default options.
164
  * @uses delete_option() Removes default options.
179
  *
180
  * Allows previously activated plugins to append their own options.
181
  *
182
+ * @since 1.6.0
183
  */
184
  do_action( 'bp_delete_options' );
185
  }
189
  *
190
  * Currently unused.
191
  *
192
+ * @since 1.6.0
193
  *
194
  * @uses bp_get_default_options() To get default options.
195
  * @uses add_filter() To add filters to 'pre_option_{$key}'.
210
  *
211
  * Allows previously activated plugins to append their own options.
212
  *
213
+ * @since 1.6.0
214
  */
215
  do_action( 'bp_setup_option_filters' );
216
  }
220
  *
221
  * Currently unused.
222
  *
223
+ * @since 1.6.0
224
+ *
225
+ * @param bool $value Optional. Default value false.
226
  *
227
+ * @return mixed False if not overloaded, mixed if set.
 
228
  */
229
  function bp_pre_get_option( $value = false ) {
230
  $bp = buddypress();
252
  *
253
  * The 'bp_get_option' filter is primarily for backward-compatibility.
254
  *
255
+ * @since 1.2.0
256
  *
257
  * @uses bp_get_root_blog_id()
258
  *
259
  * @param string $option_name The option to be retrieved.
260
+ * @param string $default Optional. Default value to be returned if the option
261
+ * isn't set. See {@link get_blog_option()}.
262
+ *
263
  * @return mixed The value for the option.
264
  */
265
  function bp_get_option( $option_name, $default = '' ) {
268
  /**
269
  * Filters the option value for the requested option.
270
  *
271
+ * @since 1.2.0
272
  *
273
  * @param mixed $value The value for the option.
274
  */
281
  * This is a wrapper for {@link add_blog_option()}, which in turn stores
282
  * settings data on the appropriate blog, given your current setup.
283
  *
284
+ * @since 2.0.0
285
  *
286
  * @param string $option_name The option key to be set.
287
+ * @param mixed $value The value to be set.
288
+ *
289
  * @return bool True on success, false on failure.
290
  */
291
  function bp_add_option( $option_name, $value ) {
299
  * settings data (such as bp-pages) on the appropriate blog, given your current
300
  * setup.
301
  *
302
+ * @since 1.5.0
303
  *
304
  * @uses bp_get_root_blog_id()
305
  *
306
  * @param string $option_name The option key to be set.
307
+ * @param string $value The value to be set.
308
+ *
309
  * @return bool True on success, false on failure.
310
  */
311
  function bp_update_option( $option_name, $value ) {
319
  * settings data (such as bp-pages) on the appropriate blog, given your current
320
  * setup.
321
  *
322
+ * @since 1.5.0
323
  *
324
  * @uses bp_get_root_blog_id()
325
  *
326
  * @param string $option_name The option key to be deleted.
327
+ *
328
  * @return bool True on success, false on failure.
329
  */
330
  function bp_delete_option( $option_name ) {
340
  * This function is no longer used.
341
  *
342
  * @deprecated 1.6.0
343
+ *
344
+ * @param array $keys
345
+ *
346
+ * @return bool
347
  */
348
  function bp_core_activate_site_options( $keys = array() ) {
349
 
408
  /**
409
  * Filters multisite options retrieved from sitemeta.
410
  *
411
+ * @since 1.5.0
412
  *
413
  * @param array $value Array of multisite options from sitemeta table.
414
  */
491
  /**
492
  * Filters the global BP options.
493
  *
494
+ * @since 1.5.0
495
  *
496
  * @param array $root_blog_options_meta Array of global BP options.
497
  */
505
  * time during a pageload and stored in `buddypress()->site_options` to prevent future lookups.
506
  * See {@see bp_core_get_root_options()}.
507
  *
508
+ * @since 2.3.0
509
  *
510
  * @param string $option Name of the option key.
511
+ *
512
  * @return mixed Value, if found.
513
  */
514
  function bp_core_get_root_option( $option ) {
531
  /**
532
  * Is profile syncing disabled?
533
  *
534
+ * @since 1.6.0
535
  *
536
  * @uses bp_get_option() To get the profile sync option.
537
  *
538
  * @param bool $default Optional. Fallback value if not found in the database.
539
+ * Default: true.
540
+ *
541
  * @return bool True if profile sync is enabled, otherwise false.
542
  */
543
  function bp_disable_profile_sync( $default = false ) {
545
  /**
546
  * Filters whether or not profile syncing is disabled.
547
  *
548
+ * @since 1.6.0
549
  *
550
  * @param bool $value Whether or not syncing is disabled.
551
  */
555
  /**
556
  * Is the Toolbar hidden for logged out users?
557
  *
558
+ * @since 1.6.0
559
  *
560
  * @uses bp_get_option() To get the logged out Toolbar option.
561
  *
562
  * @param bool $default Optional. Fallback value if not found in the database.
563
+ * Default: true.
564
+ *
565
  * @return bool True if the admin bar should be hidden for logged-out users,
566
+ * otherwise false.
567
  */
568
  function bp_hide_loggedout_adminbar( $default = true ) {
569
 
570
  /**
571
  * Filters whether or not the toolbar is hidden for logged out users.
572
  *
573
+ * @since 1.6.0
574
  *
575
  * @param bool $value Whether or not the toolbar is hidden.
576
  */
580
  /**
581
  * Are members able to upload their own avatars?
582
  *
583
+ * @since 1.6.0
584
  *
585
  * @uses bp_get_option() To get the avatar uploads option.
586
  *
587
  * @param bool $default Optional. Fallback value if not found in the database.
588
+ * Default: true.
589
+ *
590
  * @return bool True if avatar uploads are disabled, otherwise false.
591
  */
592
  function bp_disable_avatar_uploads( $default = true ) {
594
  /**
595
  * Filters whether or not members are able to upload their own avatars.
596
  *
597
+ * @since 1.6.0
598
  *
599
  * @param bool $value Whether or not members are able to upload their own avatars.
600
  */
601
  return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
602
  }
603
 
604
+ /**
605
+ * Are members able to upload their own cover images?
606
+ *
607
+ * @since 2.4.0
608
+ *
609
+ * @uses bp_get_option() To get the cover image uploads option.
610
+ *
611
+ * @param bool $default Optional. Fallback value if not found in the database.
612
+ * Default: false.
613
+ *
614
+ * @return bool True if cover image uploads are disabled, otherwise false.
615
+ */
616
+ function bp_disable_cover_image_uploads( $default = false ) {
617
+
618
+ /**
619
+ * Filters whether or not members are able to upload their own cover images.
620
+ *
621
+ * @since 2.4.0
622
+ *
623
+ * @param bool $value Whether or not members are able to upload their own cover images.
624
+ */
625
+ return (bool) apply_filters( 'bp_disable_cover_image_uploads', (bool) bp_get_option( 'bp-disable-cover-image-uploads', $default ) );
626
+ }
627
+
628
  /**
629
  * Are group avatars disabled?
630
  *
631
  * For backward compatibility, this option falls back on the value of 'bp-disable-avatar-uploads' when no value is
632
  * found in the database.
633
  *
634
+ * @since 2.3.0
635
+ *
636
+ * @param bool|null $default Optional. Fallback value if not found in the database.
637
+ * Defaults to the value of `bp_disable_avatar_uploads()`.
638
  *
 
 
639
  * @return bool True if group avatar uploads are disabled, otherwise false.
640
  */
641
  function bp_disable_group_avatar_uploads( $default = null ) {
652
  /**
653
  * Filters whether or not members are able to upload group avatars.
654
  *
655
+ * @since 2.3.0
656
  *
657
  * @param bool $disabled Whether or not members are able to upload their groups avatars.
658
  * @param bool $default Default value passed to the function.
660
  return (bool) apply_filters( 'bp_disable_group_avatar_uploads', $disabled, $default );
661
  }
662
 
663
+ /**
664
+ * Are group cover images disabled?
665
+ *
666
+ * @since 2.4.0
667
+ *
668
+ * @uses bp_get_option() To get the group cover image uploads option.
669
+ *
670
+ * @param bool $default Optional. Fallback value if not found in the database.
671
+ * Default: false.
672
+ *
673
+ * @return bool True if group cover image uploads are disabled, otherwise false.
674
+ */
675
+ function bp_disable_group_cover_image_uploads( $default = false ) {
676
+
677
+ /**
678
+ * Filters whether or not members are able to upload group cover images.
679
+ *
680
+ * @since 2.4.0
681
+ *
682
+ * @param bool $value Whether or not members are able to upload thier groups cover images.
683
+ */
684
+ return (bool) apply_filters( 'bp_disable_group_cover_image_uploads', (bool) bp_get_option( 'bp-disable-group-cover-image-uploads', $default ) );
685
+ }
686
+
687
  /**
688
  * Are members able to delete their own accounts?
689
  *
690
+ * @since 1.6.0
691
  *
692
  * @uses bp_get_option() To get the account deletion option.
693
  *
694
  * @param bool $default Optional. Fallback value if not found in the database.
695
+ * Default: true.
696
+ *
697
  * @return bool True if users are able to delete their own accounts, otherwise
698
+ * false.
699
  */
700
  function bp_disable_account_deletion( $default = false ) {
701
 
702
  /**
703
  * Filters whether or not members are able to delete their own accounts.
704
  *
705
+ * @since 1.6.0
706
  *
707
  * @param bool $value Whether or not members are able to delete their own accounts.
708
  */
712
  /**
713
  * Are blog and forum activity stream comments disabled?
714
  *
715
+ * @since 1.6.0
716
  *
717
  * @todo split and move into blog and forum components.
718
  * @uses bp_get_option() To get the blog/forum comments option.
719
  *
720
  * @param bool $default Optional. Fallback value if not found in the database.
721
+ * Default: false.
722
+ *
723
  * @return bool True if activity comments are disabled for blog and forum
724
+ * items, otherwise false.
725
  */
726
  function bp_disable_blogforum_comments( $default = false ) {
727
 
728
  /**
729
  * Filters whether or not blog and forum activity stream comments are disabled.
730
  *
731
+ * @since 1.6.0
732
  *
733
  * @param bool $value Whether or not blog and forum activity stream comments are disabled.
734
  */
738
  /**
739
  * Is group creation turned off?
740
  *
741
+ * @since 1.6.0
742
  *
743
  * @todo Move into groups component.
744
  * @uses bp_get_option() To get the group creation.
745
  *
746
  * @param bool $default Optional. Fallback value if not found in the database.
747
+ * Default: true.
748
+ *
749
  * @return bool True if group creation is restricted, otherwise false.
750
  */
751
  function bp_restrict_group_creation( $default = true ) {
753
  /**
754
  * Filters whether or not group creation is turned off.
755
  *
756
+ * @since 1.6.0
757
  *
758
  * @param bool $value Whether or not group creation is turned off.
759
  */
763
  /**
764
  * Should the old BuddyBar be forced in place of the WP admin bar?
765
  *
766
+ * @since 1.6.0
767
  *
768
  * @uses bp_get_option() To get the BuddyBar option.
769
  *
770
  * @param bool $default Optional. Fallback value if not found in the database.
771
+ * Default: true.
772
+ *
773
  * @return bool True if the BuddyBar should be forced on, otherwise false.
774
  */
775
  function bp_force_buddybar( $default = true ) {
777
  /**
778
  * Filters whether or not BuddyBar should be forced in place of WP Admin Bar.
779
  *
780
+ * @since 1.6.0
781
  *
782
  * @param bool $value Whether or not BuddyBar should be forced in place of WP Admin Bar.
783
  */
787
  /**
788
  * Output the group forums root parent forum id.
789
  *
790
+ * @since 1.6.0
791
  *
792
+ * @param bool|string $default Optional. Default: '0'.
793
  */
794
  function bp_group_forums_root_id( $default = '0' ) {
795
  echo bp_get_group_forums_root_id( $default );
797
  /**
798
  * Return the group forums root parent forum id.
799
  *
800
+ * @since 1.6.0
801
  *
802
  * @uses bp_get_option() To get the root forum ID from the database.
803
  *
804
+ * @param bool|string $default Optional. Default: '0'.
805
+ *
806
  * @return int The ID of the group forums root forum.
807
  */
808
  function bp_get_group_forums_root_id( $default = '0' ) {
810
  /**
811
  * Filters the group forums root parent forum id.
812
  *
813
+ * @since 1.6.0
814
  *
815
  * @param int $value The group forums root parent forum id.
816
  */
820
  /**
821
  * Check whether BuddyPress Group Forums are enabled.
822
  *
823
+ * @since 1.6.0
824
  *
825
  * @uses bp_get_option() To get the group forums option.
826
  *
827
  * @param bool $default Optional. Fallback value if not found in the database.
828
+ * Default: true.
829
+ *
830
  * @return bool True if group forums are active, otherwise false.
831
  */
832
  function bp_is_group_forums_active( $default = true ) {
834
  /**
835
  * Filters whether or not BuddyPress Group Forums are enabled.
836
  *
837
+ * @since 1.6.0
838
  *
839
  * @param bool $value Whether or not BuddyPress Group Forums are enabled.
840
  */
844
  /**
845
  * Check whether Akismet is enabled.
846
  *
847
+ * @since 1.6.0
848
  *
849
  * @uses bp_get_option() To get the Akismet option.
850
  *
851
  * @param bool $default Optional. Fallback value if not found in the database.
852
+ * Default: true.
853
+ *
854
  * @return bool True if Akismet is enabled, otherwise false.
855
  */
856
  function bp_is_akismet_active( $default = true ) {
858
  /**
859
  * Filters whether or not Akismet is enabled.
860
  *
861
+ * @since 1.6.0
862
  *
863
  * @param bool $value Whether or not Akismet is enabled.
864
  */
868
  /**
869
  * Check whether Activity Heartbeat refresh is enabled.
870
  *
871
+ * @since 2.0.0
872
  *
873
  * @uses bp_get_option() To get the Heartbeat option.
874
  *
875
  * @param bool $default Optional. Fallback value if not found in the database.
876
+ * Default: true.
877
+ *
878
  * @return bool True if Heartbeat refresh is enabled, otherwise false.
879
  */
880
  function bp_is_activity_heartbeat_active( $default = true ) {
882
  /**
883
  * Filters whether or not Activity Heartbeat refresh is enabled.
884
  *
885
+ * @since 2.0.0
886
  *
887
  * @param bool $value Whether or not Activity Heartbeat refresh is enabled.
888
  */
892
  /**
893
  * Get the current theme package ID.
894
  *
895
+ * @since 1.7.0
896
  *
897
  * @uses get_option() To get the theme package option.
898
  *
899
+ * @param string $default Optional. Fallback value if not found in the database.
900
+ * Default: 'legacy'.
901
+ *
902
  * @return string ID of the theme package.
903
  */
904
  function bp_get_theme_package_id( $default = 'legacy' ) {
906
  /**
907
  * Filters the current theme package ID.
908
  *
909
+ * @since 1.7.0
910
  *
911
  * @param string $value The current theme package ID.
912
  */
bp-core/bp-core-taxonomy.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress taxonomy functions.
5
  *
@@ -7,13 +6,19 @@
7
  * Because BuddyPress can be activated in various ways in a network environment, we
8
  * must switch to the root blog before using the WP functions.
9
  *
10
- * @since BuddyPress (2.2.0)
 
 
 
11
  */
12
 
 
 
 
13
  /**
14
  * Register our default taxonomies.
15
  *
16
- * @since BuddyPress (2.2.0)
17
  */
18
  function bp_register_default_taxonomies() {
19
  // Member Type.
@@ -26,7 +31,7 @@ add_action( 'bp_register_taxonomies', 'bp_register_default_taxonomies' );
26
  /**
27
  * Set taxonomy terms on a BuddyPress object.
28
  *
29
- * @since BuddyPress (2.2.0)
30
  *
31
  * @see wp_set_object_terms() for a full description of function and parameters.
32
  *
@@ -34,6 +39,7 @@ add_action( 'bp_register_taxonomies', 'bp_register_default_taxonomies' );
34
  * @param string|array $terms Term or terms to set.
35
  * @param string $taxonomy Taxonomy name.
36
  * @param bool $append Optional. True to append terms to existing terms. Default: false.
 
37
  * @return array Array of term taxonomy IDs.
38
  */
39
  function bp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
@@ -55,13 +61,14 @@ function bp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
55
  /**
56
  * Get taxonomy terms for a BuddyPress object.
57
  *
58
- * @since BuddyPress (2.2.0)
59
  *
60
  * @see wp_get_object_terms() for a full description of function and parameters.
61
  *
62
  * @param int|array $object_ids ID or IDs of objects.
63
  * @param string|array $taxonomies Name or names of taxonomies to match.
64
  * @param array $args See {@see wp_get_object_terms()}.
 
65
  * @return array
66
  */
67
  function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
@@ -83,13 +90,14 @@ function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
83
  /**
84
  * Remove taxonomy terms on a BuddyPress object.
85
  *
86
- * @since BuddyPress (2.3.0)
87
  *
88
  * @see wp_remove_object_terms() for a full description of function and parameters.
89
  *
90
  * @param int $object_id Object ID.
91
  * @param string|array $terms Term or terms to remove.
92
  * @param string $taxonomy Taxonomy name.
 
93
  * @return bool|WP_Error True on success, false or WP_Error on failure.
94
  */
95
  function bp_remove_object_terms( $object_id, $terms, $taxonomy ) {
@@ -106,4 +114,4 @@ function bp_remove_object_terms( $object_id, $terms, $taxonomy ) {
106
  }
107
 
108
  return $retval;
109
- }
1
  <?php
 
2
  /**
3
  * BuddyPress taxonomy functions.
4
  *
6
  * Because BuddyPress can be activated in various ways in a network environment, we
7
  * must switch to the root blog before using the WP functions.
8
  *
9
+ * @since 2.2.0
10
+ *
11
+ * @package BuddyPress
12
+ * @subpackage Core
13
  */
14
 
15
+ // Exit if accessed directly.
16
+ defined( 'ABSPATH' ) || exit;
17
+
18
  /**
19
  * Register our default taxonomies.
20
  *
21
+ * @since 2.2.0
22
  */
23
  function bp_register_default_taxonomies() {
24
  // Member Type.
31
  /**
32
  * Set taxonomy terms on a BuddyPress object.
33
  *
34
+ * @since 2.2.0
35
  *
36
  * @see wp_set_object_terms() for a full description of function and parameters.
37
  *
39
  * @param string|array $terms Term or terms to set.
40
  * @param string $taxonomy Taxonomy name.
41
  * @param bool $append Optional. True to append terms to existing terms. Default: false.
42
+ *
43
  * @return array Array of term taxonomy IDs.
44
  */
45
  function bp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
61
  /**
62
  * Get taxonomy terms for a BuddyPress object.
63
  *
64
+ * @since 2.2.0
65
  *
66
  * @see wp_get_object_terms() for a full description of function and parameters.
67
  *
68
  * @param int|array $object_ids ID or IDs of objects.
69
  * @param string|array $taxonomies Name or names of taxonomies to match.
70
  * @param array $args See {@see wp_get_object_terms()}.
71
+ *
72
  * @return array
73
  */
74
  function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
90
  /**
91
  * Remove taxonomy terms on a BuddyPress object.
92
  *
93
+ * @since 2.3.0
94
  *
95
  * @see wp_remove_object_terms() for a full description of function and parameters.
96
  *
97
  * @param int $object_id Object ID.
98
  * @param string|array $terms Term or terms to remove.
99
  * @param string $taxonomy Taxonomy name.
100
+ *
101
  * @return bool|WP_Error True on success, false or WP_Error on failure.
102
  */
103
  function bp_remove_object_terms( $object_id, $terms, $taxonomy ) {
114
  }
115
 
116
  return $retval;
117
+ }
bp-core/bp-core-template-loader.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Template Functions.
5
  *
@@ -11,33 +10,33 @@
11
  * @subpackage TemplateFunctions
12
  */
13
 
14
- // Exit if accessed directly
15
  defined( 'ABSPATH' ) || exit;
16
 
17
  /**
18
  * Get a BuddyPress template part for display in a theme.
19
  *
20
- * @since BuddyPress (1.7.0)
21
  *
22
  * @uses bp_locate_template()
23
  * @uses load_template()
24
  * @uses get_template_part()
25
  *
26
- * @param string $slug Template part slug. Used to generate filenames, eg
27
- * 'friends' for 'friends.php'.
28
  * @param string $name Optional. Template part name. Used to generate
29
- * secondary filenames, eg 'personal' for 'activity-personal.php'.
 
30
  * @return string Path to located template. See {@link bp_locate_template()}.
31
  */
32
  function bp_get_template_part( $slug, $name = null ) {
33
 
34
- // Execute code for this part
35
  /**
36
  * Fires at the start of bp_get_template_part().
37
  *
38
  * This is a variable hook that is dependent on the slug passed in.
39
  *
40
- * @since BuddyPress (1.7.0)
41
  *
42
  * @param string $slug Template part slug requested.
43
  * @param string $name Template part name requested.
@@ -51,11 +50,10 @@ function bp_get_template_part( $slug, $name = null ) {
51
  }
52
  $templates[] = $slug . '.php';
53
 
54
- // Allow template parts to be filtered
55
  /**
56
  * Filters the template parts to be loaded.
57
  *
58
- * @since BuddyPress (1.7.0)
59
  *
60
  * @param array $templates Array of templates located.
61
  * @param string $slug Template part slug requested.
@@ -74,13 +72,14 @@ function bp_get_template_part( $slug, $name = null ) {
74
  * inherit from a parent theme can just overload one file. If the template is
75
  * not found in either of those, it looks in the theme-compat folder last.
76
  *
77
- * @since BuddyPress (1.7.0)
78
  *
79
  * @param string|array $template_names Template file(s) to search for, in order.
80
- * @param bool $load Optional. If true, the template file will be loaded when
81
- * found. If false, the path will be returned. Default: false.
82
- * @param bool $require_once Optional. Whether to require_once or require. Has
83
- * no effect if $load is false. Default: true.
 
84
  * @return string The template filename if one is located.
85
  */
86
  function bp_locate_template( $template_names, $load = false, $require_once = true ) {
@@ -142,11 +141,12 @@ function bp_locate_template( $template_names, $load = false, $require_once = tru
142
  * relationship, to allow for custom template locations. Used in conjunction
143
  * with bp_locate_template(), this allows for easy template overrides.
144
  *
145
- * @since BuddyPress (1.7.0)
146
  *
147
  * @param string $location_callback Callback function that returns the stack location.
148
- * @param int $priority Optional. The priority parameter as passed to
149
- * add_filter(). Default: 10.
 
150
  * @return bool See {@link add_filter()}.
151
  */
152
  function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
@@ -163,13 +163,14 @@ function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
163
  /**
164
  * Deregister a previously registered template stack location.
165
  *
166
- * @since BuddyPress (1.7.0)
167
  *
168
  * @see bp_register_template_stack()
169
  *
170
  * @param string $location_callback Callback function that returns the stack location.
171
- * @param int $priority Optional. The priority parameter passed to
172
- * {@link bp_register_template_stack()}. Default: 10.
 
173
  * @return bool See {@link remove_filter()}.
174
  */
175
  function bp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
@@ -191,12 +192,13 @@ function bp_deregister_template_stack( $location_callback = '', $priority = 10 )
191
  *
192
  * @see bp_register_template_stack()
193
  *
194
- * @since BuddyPress (1.7.0)
 
 
 
 
 
195
  *
196
- * @global array $wp_filter Stores all of the filters.
197
- * @global array $merged_filters Merges the filter hooks using this function..
198
- * @global array $wp_current_filter stores the list of current filters with
199
- * the current one last.
200
  * @return array The filtered value after all hooked functions are applied to it.
201
  */
202
  function bp_get_template_stack() {
@@ -237,7 +239,7 @@ function bp_get_template_stack() {
237
  /**
238
  * Filters the "template stack" list of registered directories where templates can be found.
239
  *
240
- * @since BuddyPress (1.7.0)
241
  *
242
  * @param array $stack Array of registered directories for template locations.
243
  */
@@ -247,14 +249,15 @@ function bp_get_template_stack() {
247
  /**
248
  * Put a template part into an output buffer, and return it.
249
  *
250
- * @since BuddyPress (1.7.0)
251
  *
252
  * @see bp_get_template_part() for a description of $slug and $name params.
253
  *
254
  * @param string $slug See {@link bp_get_template_part()}.
255
  * @param string $name See {@link bp_get_template_part()}.
256
- * @param bool $echo If true, template content will be echoed. If false,
257
- * returned. Default: true.
 
258
  * @return string|null If $echo, returns the template content.
259
  */
260
  function bp_buffer_template_part( $slug, $name = null, $echo = true ) {
@@ -287,14 +290,15 @@ function bp_buffer_template_part( $slug, $name = null, $echo = true ) {
287
  * the use of {@link bp_locate_template()}. Allows for more generic template
288
  * locations without the use of the other get_*_template() functions.
289
  *
290
- * @since BuddyPress (1.7.0)
291
  *
292
  * @uses bp_set_theme_compat_templates()
293
  * @uses bp_locate_template()
294
  * @uses bp_set_theme_compat_template()
295
  *
296
- * @param string $type Filename without extension.
297
- * @param array $templates An optional list of template candidates.
 
298
  * @return string Full path to file.
299
  */
300
  function bp_get_query_template( $type, $templates = array() ) {
@@ -310,7 +314,7 @@ function bp_get_query_template( $type, $templates = array() ) {
310
  * This is a variable filter based on the type passed into
311
  * bp_get_query_template.
312
  *
313
- * @since BuddyPress (1.7.0)
314
  *
315
  * @param array $templates Array of template files already prepared.
316
  */
@@ -328,7 +332,7 @@ function bp_get_query_template( $type, $templates = array() ) {
328
  * This is a variable filter based on the type passed into
329
  * bp_get_query_template.
330
  *
331
- * @since BuddyPress (1.7.0)
332
  *
333
  * @param string $template Path to the most appropriate found template file.
334
  */
@@ -336,11 +340,13 @@ function bp_get_query_template( $type, $templates = array() ) {
336
  }
337
 
338
  /**
339
- * Get the possible subdirectories to check for templates in
 
 
340
  *
341
- * @since BuddyPress (1.7.0)
342
- * @param array $templates Templates we are looking for
343
- * @return array Possible subfolders to look in
344
  */
345
  function bp_get_template_locations( $templates = array() ) {
346
  $locations = array(
@@ -352,7 +358,7 @@ function bp_get_template_locations( $templates = array() ) {
352
  /**
353
  * Filters the possible subdirectories to check for templates in.
354
  *
355
- * @since BuddyPress (1.7.0)
356
  *
357
  * @param array $locations Array of subfolders to look in.
358
  * @param array $templates Array of templates we are looking for.
@@ -363,9 +369,10 @@ function bp_get_template_locations( $templates = array() ) {
363
  /**
364
  * Add template locations to template files being searched for.
365
  *
366
- * @since BuddyPress (1.7.0)
367
  *
368
  * @param array $stacks Array of template locations.
 
369
  * @return array() Array of all template locations registered so far.
370
  */
371
  function bp_add_template_stack_locations( $stacks = array() ) {
@@ -384,7 +391,7 @@ function bp_add_template_stack_locations( $stacks = array() ) {
384
  /**
385
  * Filters the template locations to template files being searched for.
386
  *
387
- * @since BuddyPress (1.7.0)
388
  *
389
  * @param array $value Array of all template locations registered so far.
390
  * @param array $stacks Array of template locations.
@@ -395,7 +402,7 @@ function bp_add_template_stack_locations( $stacks = array() ) {
395
  /**
396
  * Add checks for BuddyPress conditions to 'parse_query' action.
397
  *
398
- * @since BuddyPress (1.7.0)
399
  *
400
  * @param WP_Query $posts_query
401
  */
@@ -421,7 +428,7 @@ function bp_parse_query( $posts_query ) {
421
  *
422
  * Allow BuddyPress components to parse the main query.
423
  *
424
- * @since BuddyPress (1.7.0)
425
  *
426
  * @param WP_Query $posts_query WP_Query instance. Passed by reference.
427
  */
@@ -433,14 +440,15 @@ function bp_parse_query( $posts_query ) {
433
  *
434
  * Listens to the 'template_include' filter and waits for any BuddyPress specific
435
  * template condition to be met. If one is met and the template file exists,
436
- * it will be used; otherwise
437
  *
438
  * Note that the _edit() checks are ahead of their counterparts, to prevent them
439
  * from being stomped on accident.
440
  *
441
- * @since BuddyPress (1.7.0)
442
  *
443
  * @param string $template
 
444
  * @return string The path to the template file that is being used.
445
  */
446
  function bp_template_include_theme_supports( $template = '' ) {
@@ -448,7 +456,7 @@ function bp_template_include_theme_supports( $template = '' ) {
448
  /**
449
  * Filters whether or not to override the template being loaded in parent/child themes.
450
  *
451
- * @since BuddyPress (1.7.0)
452
  *
453
  * @param bool $value Whether or not there is a file override. Default false.
454
  * @param string $template The path to the template file that is being used.
@@ -464,7 +472,7 @@ function bp_template_include_theme_supports( $template = '' ) {
464
  /**
465
  * Filters the final template being loaded in parent/child themes.
466
  *
467
- * @since BuddyPress (1.7.0)
468
  *
469
  * @param string $template The path to the template file that is being used.
470
  */
@@ -474,9 +482,10 @@ function bp_template_include_theme_supports( $template = '' ) {
474
  /**
475
  * Set the included template.
476
  *
477
- * @since BuddyPress (1.8.0)
478
  *
479
  * @param mixed $template Default: false.
 
480
  * @return mixed False if empty. Template name if template included.
481
  */
482
  function bp_set_template_included( $template = false ) {
@@ -488,7 +497,8 @@ function bp_set_template_included( $template = false ) {
488
  /**
489
  * Is a BuddyPress template being included?
490
  *
491
- * @since BuddyPress (1.8.0)
 
492
  * @return bool True if yes, false if no.
493
  */
494
  function bp_is_template_included() {
@@ -498,7 +508,7 @@ function bp_is_template_included() {
498
  /**
499
  * Attempt to load a custom BP functions file, similar to each themes functions.php file.
500
  *
501
- * @since BuddyPress (1.7.0)
502
  *
503
  * @global string $pagenow
504
  * @uses bp_locate_template()
@@ -533,7 +543,8 @@ function bp_load_theme_functions() {
533
  /**
534
  * Get the templates to use as the endpoint for BuddyPress template parts.
535
  *
536
- * @since BuddyPress (1.7.0)
 
537
  *
538
  * @return array Array of possible root level wrapper template files.
539
  */
@@ -545,6 +556,7 @@ function bp_get_theme_compat_templates() {
545
  'generic.php',
546
  'page.php',
547
  'single.php',
 
548
  'index.php'
549
  ) );
550
  }
1
  <?php
 
2
  /**
3
  * BuddyPress Template Functions.
4
  *
10
  * @subpackage TemplateFunctions
11
  */
12
 
13
+ // Exit if accessed directly.
14
  defined( 'ABSPATH' ) || exit;
15
 
16
  /**
17
  * Get a BuddyPress template part for display in a theme.
18
  *
19
+ * @since 1.7.0
20
  *
21
  * @uses bp_locate_template()
22
  * @uses load_template()
23
  * @uses get_template_part()
24
  *
25
+ * @param string $slug Template part slug. Used to generate filenames,
26
+ * eg 'friends' for 'friends.php'.
27
  * @param string $name Optional. Template part name. Used to generate
28
+ * secondary filenames, eg 'personal' for 'activity-personal.php'.
29
+ *
30
  * @return string Path to located template. See {@link bp_locate_template()}.
31
  */
32
  function bp_get_template_part( $slug, $name = null ) {
33
 
 
34
  /**
35
  * Fires at the start of bp_get_template_part().
36
  *
37
  * This is a variable hook that is dependent on the slug passed in.
38
  *
39
+ * @since 1.7.0
40
  *
41
  * @param string $slug Template part slug requested.
42
  * @param string $name Template part name requested.
50
  }
51
  $templates[] = $slug . '.php';
52
 
 
53
  /**
54
  * Filters the template parts to be loaded.
55
  *
56
+ * @since 1.7.0
57
  *
58
  * @param array $templates Array of templates located.
59
  * @param string $slug Template part slug requested.
72
  * inherit from a parent theme can just overload one file. If the template is
73
  * not found in either of those, it looks in the theme-compat folder last.
74
  *
75
+ * @since 1.7.0
76
  *
77
  * @param string|array $template_names Template file(s) to search for, in order.
78
+ * @param bool $load Optional. If true, the template file will be loaded when
79
+ * found. If false, the path will be returned. Default: false.
80
+ * @param bool $require_once Optional. Whether to require_once or require. Has
81
+ * no effect if $load is false. Default: true.
82
+ *
83
  * @return string The template filename if one is located.
84
  */
85
  function bp_locate_template( $template_names, $load = false, $require_once = true ) {
141
  * relationship, to allow for custom template locations. Used in conjunction
142
  * with bp_locate_template(), this allows for easy template overrides.
143
  *
144
+ * @since 1.7.0
145
  *
146
  * @param string $location_callback Callback function that returns the stack location.
147
+ * @param int $priority Optional. The priority parameter as passed to
148
+ * add_filter(). Default: 10.
149
+ *
150
  * @return bool See {@link add_filter()}.
151
  */
152
  function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
163
  /**
164
  * Deregister a previously registered template stack location.
165
  *
166
+ * @since 1.7.0
167
  *
168
  * @see bp_register_template_stack()
169
  *
170
  * @param string $location_callback Callback function that returns the stack location.
171
+ * @param int $priority Optional. The priority parameter passed to
172
+ * {@link bp_register_template_stack()}. Default: 10.
173
+ *
174
  * @return bool See {@link remove_filter()}.
175
  */
176
  function bp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
192
  *
193
  * @see bp_register_template_stack()
194
  *
195
+ * @since 1.7.0
196
+ *
197
+ * @global array $wp_filter Stores all of the filters.
198
+ * @global array $merged_filters Merges the filter hooks using this function.
199
+ * @global array $wp_current_filter Stores the list of current filters with
200
+ * the current one last.
201
  *
 
 
 
 
202
  * @return array The filtered value after all hooked functions are applied to it.
203
  */
204
  function bp_get_template_stack() {
239
  /**
240
  * Filters the "template stack" list of registered directories where templates can be found.
241
  *
242
+ * @since 1.7.0
243
  *
244
  * @param array $stack Array of registered directories for template locations.
245
  */
249
  /**
250
  * Put a template part into an output buffer, and return it.
251
  *
252
+ * @since 1.7.0
253
  *
254
  * @see bp_get_template_part() for a description of $slug and $name params.
255
  *
256
  * @param string $slug See {@link bp_get_template_part()}.
257
  * @param string $name See {@link bp_get_template_part()}.
258
+ * @param bool $echo If true, template content will be echoed. If false,
259
+ * returned. Default: true.
260
+ *
261
  * @return string|null If $echo, returns the template content.
262
  */
263
  function bp_buffer_template_part( $slug, $name = null, $echo = true ) {
290
  * the use of {@link bp_locate_template()}. Allows for more generic template
291
  * locations without the use of the other get_*_template() functions.
292
  *
293
+ * @since 1.7.0
294
  *
295
  * @uses bp_set_theme_compat_templates()
296
  * @uses bp_locate_template()
297
  * @uses bp_set_theme_compat_template()
298
  *
299
+ * @param string $type Filename without extension.
300
+ * @param array $templates An optional list of template candidates.
301
+ *
302
  * @return string Full path to file.
303
  */
304
  function bp_get_query_template( $type, $templates = array() ) {
314
  * This is a variable filter based on the type passed into
315
  * bp_get_query_template.
316
  *
317
+ * @since 1.7.0
318
  *
319
  * @param array $templates Array of template files already prepared.
320
  */
332
  * This is a variable filter based on the type passed into
333
  * bp_get_query_template.
334
  *
335
+ * @since 1.7.0
336
  *
337
  * @param string $template Path to the most appropriate found template file.
338
  */
340
  }
341
 
342
  /**
343
+ * Get the possible subdirectories to check for templates in.
344
+ *
345
+ * @since 1.7.0
346
  *
347
+ * @param array $templates Templates we are looking for.
348
+ *
349
+ * @return array Possible subfolders to look in.
350
  */
351
  function bp_get_template_locations( $templates = array() ) {
352
  $locations = array(
358
  /**
359
  * Filters the possible subdirectories to check for templates in.
360
  *
361
+ * @since 1.7.0
362
  *
363
  * @param array $locations Array of subfolders to look in.
364
  * @param array $templates Array of templates we are looking for.
369
  /**
370
  * Add template locations to template files being searched for.
371
  *
372
+ * @since 1.7.0
373
  *
374
  * @param array $stacks Array of template locations.
375
+ *
376
  * @return array() Array of all template locations registered so far.
377
  */
378
  function bp_add_template_stack_locations( $stacks = array() ) {
391
  /**
392
  * Filters the template locations to template files being searched for.
393
  *
394
+ * @since 1.7.0
395
  *
396
  * @param array $value Array of all template locations registered so far.
397
  * @param array $stacks Array of template locations.
402
  /**
403
  * Add checks for BuddyPress conditions to 'parse_query' action.
404
  *
405
+ * @since 1.7.0
406
  *
407
  * @param WP_Query $posts_query
408
  */
428
  *
429
  * Allow BuddyPress components to parse the main query.
430
  *
431
+ * @since 1.7.0
432
  *
433
  * @param WP_Query $posts_query WP_Query instance. Passed by reference.
434
  */
440
  *
441
  * Listens to the 'template_include' filter and waits for any BuddyPress specific
442
  * template condition to be met. If one is met and the template file exists,
443
+ * it will be used; otherwise.
444
  *
445
  * Note that the _edit() checks are ahead of their counterparts, to prevent them
446
  * from being stomped on accident.
447
  *
448
+ * @since 1.7.0
449
  *
450
  * @param string $template
451
+ *
452
  * @return string The path to the template file that is being used.
453
  */
454
  function bp_template_include_theme_supports( $template = '' ) {
456
  /**
457
  * Filters whether or not to override the template being loaded in parent/child themes.
458
  *
459
+ * @since 1.7.0
460
  *
461
  * @param bool $value Whether or not there is a file override. Default false.
462
  * @param string $template The path to the template file that is being used.
472
  /**
473
  * Filters the final template being loaded in parent/child themes.
474
  *
475
+ * @since 1.7.0
476
  *
477
  * @param string $template The path to the template file that is being used.
478
  */
482
  /**
483
  * Set the included template.
484
  *
485
+ * @since 1.8.0
486
  *
487
  * @param mixed $template Default: false.
488
+ *
489
  * @return mixed False if empty. Template name if template included.
490
  */
491
  function bp_set_template_included( $template = false ) {
497
  /**
498
  * Is a BuddyPress template being included?
499
  *
500
+ * @since 1.8.0
501
+ *
502
  * @return bool True if yes, false if no.
503
  */
504
  function bp_is_template_included() {
508
  /**
509
  * Attempt to load a custom BP functions file, similar to each themes functions.php file.
510
  *
511
+ * @since 1.7.0
512
  *
513
  * @global string $pagenow
514
  * @uses bp_locate_template()
543
  /**
544
  * Get the templates to use as the endpoint for BuddyPress template parts.
545
  *
546
+ * @since 1.7.0
547
+ * @since 2.4.0 Added singular.php to stack
548
  *
549
  * @return array Array of possible root level wrapper template files.
550
  */
556
  'generic.php',
557
  'page.php',
558
  'single.php',
559
+ 'singular.php',
560
  'index.php'
561
  ) );
562
  }
bp-core/bp-core-template.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Core component template tag functions
4
  *
5
  * @package BuddyPress
6
  * @subpackage TemplateFunctions
7
  */
8
 
9
- // Exit if accessed directly
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
@@ -25,6 +25,10 @@ defined( 'ABSPATH' ) || exit;
25
  *
26
  * @uses bp_get_user_nav() Renders the navigation for a profile of a currently
27
  * viewed user.
 
 
 
 
28
  */
29
  function bp_get_options_nav( $parent_slug = '' ) {
30
  $bp = buddypress();
@@ -76,7 +80,7 @@ function bp_get_options_nav( $parent_slug = '' ) {
76
  *
77
  * This is a dynamic filter that is dependent on the provided css_id value.
78
  *
79
- * @since BuddyPress (1.1.0)
80
  *
81
  * @param string $value HTML list item for the submenu item.
82
  * @param array $subnav_item Submenu array item being displayed.
@@ -108,7 +112,9 @@ function bp_get_options_title() {
108
  * Used for the <title> element and the page header on the component directory
109
  * page.
110
  *
111
- * @since BuddyPress (2.0.0)
 
 
112
  *
113
  * @return string
114
  */
@@ -127,7 +133,7 @@ function bp_get_directory_title( $component = '' ) {
127
  /**
128
  * Filters the directory title for a component.
129
  *
130
- * @since BuddyPress (2.0.0)
131
  *
132
  * @param string $title Text to be used in <title> tag.
133
  * @param string $component Current componet being displayed.
@@ -145,7 +151,7 @@ function bp_get_directory_title( $component = '' ) {
145
  *
146
  * Not currently used in BuddyPress.
147
  *
148
- * @return bool Returns true if an options avatar has been set, otherwise false.
149
  */
150
  function bp_has_options_avatar() {
151
  return (bool) buddypress()->bp_options_avatar;
@@ -221,7 +227,7 @@ function bp_avatar_admin_step() {
221
  /**
222
  * Filters the current avatar upload step.
223
  *
224
- * @since BuddyPress (1.1.0)
225
  *
226
  * @param string $step The current avatar upload step.
227
  */
@@ -248,7 +254,7 @@ function bp_avatar_to_crop() {
248
  /**
249
  * Filters the URL of the avatar to crop.
250
  *
251
- * @since BuddyPress (1.1.0)
252
  *
253
  * @param string $url URL for the avatar.
254
  */
@@ -275,7 +281,7 @@ function bp_avatar_to_crop_src() {
275
  /**
276
  * Filters the relative file path to the avatar to crop.
277
  *
278
- * @since BuddyPress (1.1.0)
279
  *
280
  * @param string $src Relative file path for the avatar.
281
  */
@@ -304,14 +310,14 @@ function bp_site_name() {
304
  /**
305
  * Returns the name of the BP site. Used in RSS headers.
306
  *
307
- * @since BuddyPress (1.6.0)
308
  */
309
  function bp_get_site_name() {
310
 
311
  /**
312
  * Filters the name of the BP site. Used in RSS headers.
313
  *
314
- * @since BuddyPress (1.0.0)
315
  *
316
  * @param string $value Current BP site name.
317
  */
@@ -319,7 +325,7 @@ function bp_site_name() {
319
  }
320
 
321
  /**
322
- * Format a date based on a UNIX timestamp
323
  *
324
  * This function can be used to turn a UNIX timestamp into a properly formatted
325
  * (and possibly localized) string, userful for ouputting the date & time an
@@ -332,18 +338,18 @@ function bp_site_name() {
332
  * hardly used and adds an additional layer of complexity to calculating dates
333
  * and times together with timezone offsets and i18n.
334
  *
335
- * @since BuddyPress (1.1.0)
336
  *
337
- * @param int $time The UNIX timestamp to be formatted.
338
- * @param bool $exclude_time Optional. True to return only the month + day, false
339
- * to return month, day, and time. Default: false.
340
- * @param bool $gmt Optional. True to display in local time, false to
341
- * leave in GMT. Default: true.
342
  *
343
- * @return mixed A string representation of $time, in the format
344
- * "March 18, 2014 at 2:00 pm" (or whatever your
345
- * 'date_format' and 'time_format' settings are
346
- * on your root blog). False on failure.
347
  */
348
  function bp_format_time( $time = '', $exclude_time = false, $gmt = true ) {
349
 
@@ -392,7 +398,7 @@ function bp_format_time( $time = '', $exclude_time = false, $gmt = true ) {
392
  /**
393
  * Filters the date based on a UNIX timestamp.
394
  *
395
- * @since BuddyPress (1.0.0)
396
  *
397
  * @param string $formatted_date Formatted date from the timestamp.
398
  */
@@ -408,14 +414,15 @@ function bp_format_time( $time = '', $exclude_time = false, $gmt = true ) {
408
  * of the phrase, and bp_word_or_name() will detect which is appropriate, and
409
  * do the necessary argument swapping for dynamic phrases.
410
  *
411
- * @param string $youtext The "you" version of the phrase (eg "Your Friends").
412
  * @param string $nametext The other-user version of the phrase. Should be in
413
- * a format appropriate for sprintf() - use %s in place of the displayed
414
- * user's name (eg "%'s Friends").
415
  * @param bool $capitalize Optional. Force into title case. Default: true.
416
- * @param bool $echo Optional. True to echo the results, false to return them.
417
- * Default: true.
418
- * @return string|null If ! $echo, returns the appropriate string.
 
419
  */
420
  function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
421
 
@@ -429,7 +436,7 @@ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true
429
  /**
430
  * Filters the text used based on context of own profile or someone else's profile.
431
  *
432
- * @since BuddyPress (1.0.0)
433
  *
434
  * @param string $youtext Context-determined string to display.
435
  */
@@ -479,7 +486,7 @@ function bp_search_form_action() {
479
  /**
480
  * Filters the "action" attribute for search forms.
481
  *
482
- * @since BuddyPress (1.0.0)
483
  *
484
  * @param string $value Search form action url.
485
  */
@@ -489,7 +496,7 @@ function bp_search_form_action() {
489
  /**
490
  * Generate the basic search form as used in BP-Default's header.
491
  *
492
- * @since BuddyPress (1.0.0)
493
  *
494
  * @return string HTML <select> element.
495
  */
@@ -522,7 +529,7 @@ function bp_search_form_type_select() {
522
  /**
523
  * Filters all of the component options available for search scope.
524
  *
525
- * @since BuddyPress (1.5.0)
526
  *
527
  * @param array $options Array of options to add to select field.
528
  */
@@ -536,7 +543,7 @@ function bp_search_form_type_select() {
536
  /**
537
  * Filters the complete <select> input used for search scope.
538
  *
539
- * @since BuddyPress (1.0.0)
540
  *
541
  * @param string $selection_box <select> input for selecting search scope.
542
  */
@@ -546,7 +553,7 @@ function bp_search_form_type_select() {
546
  /**
547
  * Output the default text for the search box for a given component.
548
  *
549
- * @since BuddyPress (1.5.0)
550
  *
551
  * @see bp_get_search_default_text()
552
  *
@@ -558,9 +565,10 @@ function bp_search_default_text( $component = '' ) {
558
  /**
559
  * Return the default text for the search box for a given component.
560
  *
561
- * @since BuddyPress (1.5.0)
562
  *
563
  * @param string $component Component name. Default: current component.
 
564
  * @return string Placeholder text for search field.
565
  */
566
  function bp_get_search_default_text( $component = '' ) {
@@ -592,7 +600,7 @@ function bp_search_default_text( $component = '' ) {
592
  /**
593
  * Filters the default text for the search box for a given component.
594
  *
595
- * @since BuddyPress (1.5.0)
596
  *
597
  * @param string $default_text Default text for search box.
598
  * @param string $component Current component displayed.
@@ -625,7 +633,7 @@ function bp_custom_profile_sidebar_boxes() {
625
  /**
626
  * Output the attributes for a form field.
627
  *
628
- * @since BuddyPress (2.2.0)
629
  *
630
  * @param string $name The field name to output attributes for.
631
  * @param array $attributes Array of existing attributes to add.
@@ -640,7 +648,7 @@ function bp_form_field_attributes( $name = '', $attributes = array() ) {
640
  * can use the 'bp_get_form_field_extra_attributes' filter for further
641
  * manipulation.
642
  *
643
- * @since BuddyPress (2.2.0)
644
  *
645
  * @param string $name The field name to get attributes for.
646
  * @param array $attributes Array of existing attributes to add.
@@ -682,10 +690,10 @@ function bp_form_field_attributes( $name = '', $attributes = array() ) {
682
  /**
683
  * Filter the attributes for a field before rendering output.
684
  *
685
- * @since BuddyPress (2.2.0)
686
  *
687
- * @param array $attributes The field attributes
688
- * @param string $name The field name
689
  */
690
  $attributes = (array) apply_filters( 'bp_get_form_field_attributes', $attributes, $name );
691
 
@@ -701,7 +709,7 @@ function bp_form_field_attributes( $name = '', $attributes = array() ) {
701
  *
702
  * @see bp_get_button()
703
  *
704
- * @param array $args See {@link BP_Button}.
705
  */
706
  function bp_button( $args = '' ) {
707
  echo bp_get_button( $args );
@@ -711,7 +719,7 @@ function bp_button( $args = '' ) {
711
  *
712
  * @see BP_Button for a description of arguments and return value.
713
  *
714
- * @param array $args See {@link BP_Button}.
715
  * @return string HTML markup for the button.
716
  */
717
  function bp_get_button( $args = '' ) {
@@ -720,7 +728,7 @@ function bp_button( $args = '' ) {
720
  /**
721
  * Filters the requested button output.
722
  *
723
- * @since BuddyPress (1.2.6)
724
  *
725
  * @param string $contents Button context to be used.
726
  * @param array $args Array of args for the button.
@@ -740,24 +748,24 @@ function bp_button( $args = '' ) {
740
  *
741
  * ### Options:
742
  *
743
- * - `ending` Will be used as Ending and appended to the trimmed string
744
- * - `exact` If false, $text will not be cut mid-word
745
- * - `html` If true, HTML tags would be handled correctly
746
- * - `filter_shortcodes` If true, shortcodes will be stripped before truncating
747
  *
748
- * @param string $text String to truncate.
749
- * @param int $length Optional. Length of returned string, including ellipsis.
750
- * Default: 225.
751
  * @param array $options {
752
  * An array of HTML attributes and options. Each item is optional.
753
- * @type string $ending The string used after truncation.
754
- * Default: ' [&hellip;]'.
755
- * @type bool $exact If true, $text will be trimmed to exactly $length.
756
- * If false, $text will not be cut mid-word. Default: false.
757
- * @type bool $html If true, don't include HTML tags when calculating
758
- * excerpt length. Default: true.
759
- * @type bool $filter_shortcodes If true, shortcodes will be stripped.
760
- * Default: true.
761
  * }
762
  * @return string Trimmed string.
763
  */
@@ -779,7 +787,7 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
779
  /**
780
  * Filters the excerpt length to trim text to.
781
  *
782
- * @since BuddyPress (1.5.0)
783
  *
784
  * @param int $length Length of returned string, including ellipsis.
785
  */
@@ -788,7 +796,7 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
788
  /**
789
  * Filters the excerpt appended text value.
790
  *
791
- * @since BuddyPress (1.5.0)
792
  *
793
  * @param string $value Text to append to the end of the excerpt.
794
  */
@@ -941,7 +949,7 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
941
  /**
942
  * Filters the final generated excerpt.
943
  *
944
- * @since BuddyPress (1.1.0)
945
  *
946
  * @param string $truncate Generated excerpt.
947
  * @param string $original_text Original text provided.
@@ -978,7 +986,7 @@ function bp_total_member_count() {
978
  /**
979
  * Filters the total member count in your BP instance.
980
  *
981
- * @since BuddyPress (1.2.0)
982
  *
983
  * @param int $value Member count.
984
  */
@@ -1020,7 +1028,7 @@ function bp_blog_signup_allowed() {
1020
  * Check whether an activation has just been completed.
1021
  *
1022
  * @return bool True if the activation_complete global flag has been set,
1023
- * otherwise false.
1024
  */
1025
  function bp_account_was_activated() {
1026
  $bp = buddypress();
@@ -1045,7 +1053,7 @@ function bp_registration_needs_activation() {
1045
  /**
1046
  * Filters whether registrations require activation on this installation.
1047
  *
1048
- * @since BuddyPress (1.2.0)
1049
  *
1050
  * @param bool $value Whether registrations require activation. Default true.
1051
  */
@@ -1058,20 +1066,20 @@ function bp_registration_needs_activation() {
1058
  * The blogname option is escaped with esc_html on the way into the database in
1059
  * sanitize_option, we want to reverse this for the plain text arena of emails.
1060
  *
1061
- * @since BuddyPress (1.7.0)
1062
  *
1063
  * @see https://buddypress.trac.wordpress.org/ticket/4401
1064
  *
1065
  * @param array $args {
1066
  * Array of optional parameters.
1067
- * @type string $before String to appear before the site name in the
1068
- * email subject. Default: '['.
1069
- * @type string $after String to appear after the site name in the
1070
- * email subject. Default: ']'.
1071
  * @type string $default The default site name, to be used when none is
1072
- * found in the database. Default: 'Community'.
1073
- * @type string $text Text to append to the site name (ie, the main text of
1074
- * the email subject).
1075
  * }
1076
  * @return string Sanitized email subject.
1077
  */
@@ -1089,7 +1097,7 @@ function bp_get_email_subject( $args = array() ) {
1089
  /**
1090
  * Filters a client friendly version of the root blog name.
1091
  *
1092
- * @since BuddyPress (1.7.0)
1093
  *
1094
  * @param string $subject Client friendy version of the root blog name.
1095
  * @param array $r Array of arguments for the email subject.
@@ -1107,7 +1115,8 @@ function bp_get_email_subject( $args = array() ) {
1107
  * errors if someone copies the templates from the default theme into another
1108
  * WordPress theme without coping the functions from functions.php.
1109
  *
1110
- * @param string $object
 
1111
  * @return string The AJAX querystring.
1112
  */
1113
  function bp_ajax_querystring( $object = false ) {
@@ -1122,7 +1131,7 @@ function bp_ajax_querystring( $object = false ) {
1122
  *
1123
  * Allows templates to pass parameters into the template loops via AJAX.
1124
  *
1125
- * @since BuddyPress (1.2.0)
1126
  *
1127
  * @param string $ajax_querystring Current query string.
1128
  * @param string $object Current template component.
@@ -1146,7 +1155,7 @@ function bp_current_component() {
1146
  /**
1147
  * Filters the name of the current component.
1148
  *
1149
- * @since BuddyPress (1.0.0)
1150
  *
1151
  * @param string|bool $current_component Current component if available or false.
1152
  */
@@ -1167,7 +1176,7 @@ function bp_current_action() {
1167
  /**
1168
  * Filters the name of the current action.
1169
  *
1170
- * @since BuddyPress (1.0.0)
1171
  *
1172
  * @param string $current_action Current action.
1173
  */
@@ -1177,7 +1186,7 @@ function bp_current_action() {
1177
  /**
1178
  * Return the name of the current item.
1179
  *
1180
- * @return unknown
1181
  */
1182
  function bp_current_item() {
1183
  $bp = buddypress();
@@ -1188,7 +1197,7 @@ function bp_current_item() {
1188
  /**
1189
  * Filters the name of the current item.
1190
  *
1191
- * @since BuddyPress (1.1.0)
1192
  *
1193
  * @param string|bool $current_item Current item if available or false.
1194
  */
@@ -1199,7 +1208,7 @@ function bp_current_item() {
1199
  * Return the value of $bp->action_variables.
1200
  *
1201
  * @return array|bool $action_variables The action variables array, or false
1202
- * if the array is empty.
1203
  */
1204
  function bp_action_variables() {
1205
  $bp = buddypress();
@@ -1210,7 +1219,7 @@ function bp_action_variables() {
1210
  /**
1211
  * Filters the value of $bp->action_variables.
1212
  *
1213
- * @since BuddyPress (1.0.0)
1214
  *
1215
  * @param array|bool $action_variables Available action variables.
1216
  */
@@ -1220,11 +1229,12 @@ function bp_action_variables() {
1220
  /**
1221
  * Return the value of a given action variable.
1222
  *
1223
- * @since BuddyPress (1.5.0)
1224
  *
1225
  * @param int $position The key of the action_variables array that you want.
 
1226
  * @return string|bool $action_variable The value of that position in the
1227
- * array, or false if not found.
1228
  */
1229
  function bp_action_variable( $position = 0 ) {
1230
  $action_variables = bp_action_variables();
@@ -1235,7 +1245,7 @@ function bp_action_variable( $position = 0 ) {
1235
  /**
1236
  * Filters the value of a given action variable.
1237
  *
1238
- * @since BuddyPress (1.5.0)
1239
  *
1240
  * @param string|bool $action_variable Requested action variable based on position.
1241
  * @param int $position The key of the action variable requested.
@@ -1267,7 +1277,7 @@ function bp_root_domain() {
1267
  /**
1268
  * Filters the "root domain", the URL of the BP root blog.
1269
  *
1270
- * @since BuddyPress (1.2.4)
1271
  *
1272
  * @param string $domain URL of the BP root blog.
1273
  */
@@ -1277,7 +1287,7 @@ function bp_root_domain() {
1277
  /**
1278
  * Output the root slug for a given component.
1279
  *
1280
- * @since BuddyPress (1.5.0)
1281
  *
1282
  * @param string $component The component name.
1283
  */
@@ -1297,11 +1307,11 @@ function bp_root_slug( $component = '' ) {
1297
  * In order to maintain backward compatibility, the following procedure
1298
  * is used:
1299
  * 1) Use the short slug to get the canonical component name from the
1300
- * active component array
1301
  * 2) Use the component name to get the root slug out of the
1302
- * appropriate part of the $bp global
1303
  * 3) If nothing turns up, it probably means that $component is itself
1304
- * a root slug
1305
  *
1306
  * Example: If your groups directory is at /community/companies, this
1307
  * function first uses the short slug 'companies' (ie the current
@@ -1309,9 +1319,10 @@ function bp_root_slug( $component = '' ) {
1309
  * $bp->active_components. Then it uses 'groups' to get the root slug,
1310
  * from $bp->groups->root_slug.
1311
  *
1312
- * @since BuddyPress (1.5.0)
1313
  *
1314
  * @param string $component Optional. Defaults to the current component.
 
1315
  * @return string $root_slug The root slug.
1316
  */
1317
  function bp_get_root_slug( $component = '' ) {
@@ -1346,7 +1357,7 @@ function bp_root_slug( $component = '' ) {
1346
  /**
1347
  * Filters the root slug for given component.
1348
  *
1349
- * @since BuddyPress (1.5.0)
1350
  *
1351
  * @param string $root_slug Root slug for given component.
1352
  * @param string $component Current component.
@@ -1357,9 +1368,10 @@ function bp_root_slug( $component = '' ) {
1357
  /**
1358
  * Return the component name based on a root slug.
1359
  *
1360
- * @since BuddyPress (1.5.0)
1361
  *
1362
  * @param string $root_slug Needle to our active component haystack.
 
1363
  * @return mixed False if none found, component name if found.
1364
  */
1365
  function bp_get_name_from_root_slug( $root_slug = '' ) {
@@ -1386,14 +1398,12 @@ function bp_get_name_from_root_slug( $root_slug = '' ) {
1386
  }
1387
 
1388
  function bp_user_has_access() {
1389
- $has_access = ( bp_current_user_can( 'bp_moderate' ) || bp_is_my_profile() )
1390
- ? true
1391
- : false;
1392
 
1393
  /**
1394
  * Filters whether or not a user has access.
1395
  *
1396
- * @since BuddyPress (1.2.4)
1397
  *
1398
  * @param bool $has_access Whether or not user has access.
1399
  */
@@ -1403,7 +1413,7 @@ function bp_user_has_access() {
1403
  /**
1404
  * Output the search slug.
1405
  *
1406
- * @since BuddyPress (1.5.0)
1407
  *
1408
  * @uses bp_get_search_slug()
1409
  */
@@ -1413,7 +1423,7 @@ function bp_search_slug() {
1413
  /**
1414
  * Return the search slug.
1415
  *
1416
- * @since BuddyPress (1.5.0)
1417
  *
1418
  * @return string The search slug. Default: 'search'.
1419
  */
@@ -1422,9 +1432,9 @@ function bp_search_slug() {
1422
  /**
1423
  * Filters the search slug.
1424
  *
1425
- * @since BuddyPress (1.5.0)
1426
  *
1427
- * @param string BP_SEARCH_SLUG The search slug. Default "search".
1428
  */
1429
  return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
1430
  }
@@ -1434,7 +1444,7 @@ function bp_search_slug() {
1434
  *
1435
  * @uses apply_filters() Filter 'bp_displayed_user_id' to change this value.
1436
  *
1437
- * @return int ID of the currently displayed user.
1438
  */
1439
  function bp_displayed_user_id() {
1440
  $bp = buddypress();
@@ -1445,7 +1455,7 @@ function bp_displayed_user_id() {
1445
  /**
1446
  * Filters the ID of the currently displayed user.
1447
  *
1448
- * @since BuddyPress (1.0.0)
1449
  *
1450
  * @param int $id ID of the currently displayed user.
1451
  */
@@ -1468,7 +1478,7 @@ function bp_loggedin_user_id() {
1468
  /**
1469
  * Filters the ID of the currently logged-in user.
1470
  *
1471
- * @since BuddyPress (1.0.0)
1472
  *
1473
  * @param int $id ID of the currently logged-in user.
1474
  */
@@ -1482,13 +1492,14 @@ function bp_loggedin_user_id() {
1482
  *
1483
  * This function is designed to be generous, accepting several different kinds
1484
  * of value for the $component parameter. It checks $component_name against:
1485
- * - the component's root_slug, which matches the page slug in $bp->pages
1486
- * - the component's regular slug
1487
- * - the component's id, or 'canonical' name
1488
  *
1489
- * @since BuddyPress (1.5.0)
1490
  *
1491
  * @param string $component Name of the component being checked.
 
1492
  * @return bool Returns true if the component matches, or else false.
1493
  */
1494
  function bp_is_current_component( $component = '' ) {
@@ -1554,7 +1565,7 @@ function bp_is_current_component( $component = '' ) {
1554
  /**
1555
  * Filters whether the current page belongs to the specified component.
1556
  *
1557
- * @since BuddyPress (1.5.0)
1558
  *
1559
  * @param bool $is_current_component Whether or not the current page belongs to specified component.
1560
  * @param string $component Name of the component being checked.
@@ -1574,9 +1585,10 @@ function bp_is_current_component( $component = '' ) {
1574
  * http://example.com/groups/my-group/members
1575
  * the current_action is 'members'.
1576
  *
1577
- * @since BuddyPress (1.5.0)
1578
  *
1579
  * @param string $action The action being tested against.
 
1580
  * @return bool True if the current action matches $action.
1581
  */
1582
  function bp_is_current_action( $action = '' ) {
@@ -1595,12 +1607,13 @@ function bp_is_current_action( $action = '' ) {
1595
  * http://example.com/groups/my-group/admin/group-settings
1596
  * $action_variables[0] is 'group-settings'.
1597
  *
1598
- * @since BuddyPress (1.5.0)
 
 
 
 
 
1599
  *
1600
- * @param string $action_variable The action_variable being tested against.
1601
- * @param int $position Optional. The array key you're testing against. If you
1602
- * don't provide a $position, the function will return true if the
1603
- * $action_variable is found *anywhere* in the action variables array.
1604
  * @return bool True if $action_variable matches at the $position provided.
1605
  */
1606
  function bp_is_action_variable( $action_variable = '', $position = false ) {
@@ -1623,7 +1636,7 @@ function bp_is_action_variable( $action_variable = '', $position = false ) {
1623
  /**
1624
  * Filters whether the current page matches a given action_variable.
1625
  *
1626
- * @since BuddyPress (1.5.0)
1627
  *
1628
  * @param bool $is_action_variable Whether the current page matches a given action_variable.
1629
  * @param string $action_variable The action_variable being tested against.
@@ -1636,6 +1649,7 @@ function bp_is_action_variable( $action_variable = '', $position = false ) {
1636
  * Check against the current_item.
1637
  *
1638
  * @param string $item The item being checked.
 
1639
  * @return bool True if $item is the current item.
1640
  */
1641
  function bp_is_current_item( $item = '' ) {
@@ -1644,7 +1658,7 @@ function bp_is_current_item( $item = '' ) {
1644
  /**
1645
  * Filters whether or not an item is the current item.
1646
  *
1647
- * @since BuddyPress (2.1.0)
1648
  *
1649
  * @param bool $retval Whether or not an item is the current item.
1650
  * @param string $item The item being checked.
@@ -1668,7 +1682,7 @@ function bp_is_single_item() {
1668
  /**
1669
  * Filters whether or not an item is the a single item. (group, user, etc)
1670
  *
1671
- * @since BuddyPress (2.1.0)
1672
  *
1673
  * @param bool $retval Whether or not an item is a single item.
1674
  */
@@ -1679,7 +1693,7 @@ function bp_is_single_item() {
1679
  * Is the logged-in user an admin for the current item?
1680
  *
1681
  * @return bool True if the current user is an admin for the current item,
1682
- * otherwise false.
1683
  */
1684
  function bp_is_item_admin() {
1685
  $bp = buddypress();
@@ -1692,7 +1706,7 @@ function bp_is_item_admin() {
1692
  /**
1693
  * Filters whether or not the logged-in user is an admin for the current item.
1694
  *
1695
- * @since BuddyPress (2.1.0)
1696
  *
1697
  * @param bool $retval Whether or not the logged-in user is an admin.
1698
  */
@@ -1703,7 +1717,7 @@ function bp_is_item_admin() {
1703
  * Is the logged-in user a mod for the current item?
1704
  *
1705
  * @return bool True if the current user is a mod for the current item,
1706
- * otherwise false.
1707
  */
1708
  function bp_is_item_mod() {
1709
  $bp = buddypress();
@@ -1716,7 +1730,7 @@ function bp_is_item_mod() {
1716
  /**
1717
  * Filters whether or not the logged-in user is a mod for the current item.
1718
  *
1719
- * @since BuddyPress (2.1.0)
1720
  *
1721
  * @param bool $retval Whether or not the logged-in user is a mod.
1722
  */
@@ -1726,8 +1740,7 @@ function bp_is_item_mod() {
1726
  /**
1727
  * Is this a component directory page?
1728
  *
1729
- * @return bool True if the current page is a component directory, otherwise
1730
- * false.
1731
  */
1732
  function bp_is_directory() {
1733
  $bp = buddypress();
@@ -1740,7 +1753,7 @@ function bp_is_directory() {
1740
  /**
1741
  * Filters whether or not user is on a component directory page.
1742
  *
1743
- * @since BuddyPress (2.1.0)
1744
  *
1745
  * @param bool $retval Whether or not user is on a component directory page.
1746
  */
@@ -1756,6 +1769,8 @@ function bp_is_directory() {
1756
  * This function is on the chopping block. It's currently only used by a few
1757
  * already deprecated functions.
1758
  *
 
 
1759
  * @return bool True if root component, else false.
1760
  */
1761
  function bp_is_root_component( $component_name = '' ) {
@@ -1780,7 +1795,7 @@ function bp_is_root_component( $component_name = '' ) {
1780
  /**
1781
  * Filters whether or not a component's URL should be in the root, not under a member page.
1782
  *
1783
- * @since BuddyPress (2.1.0)
1784
  *
1785
  * @param bool $retval Whether or not URL should be in the root.
1786
  */
@@ -1792,12 +1807,13 @@ function bp_is_root_component( $component_name = '' ) {
1792
  *
1793
  * Corresponds to the setting in wp-admin's Settings > Reading screen.
1794
  *
1795
- * @since BuddyPress (1.5.0)
1796
  *
1797
- * @global $current_blog WordPress global for the current blog.
1798
  *
1799
  * @param string $component Optional. Name of the component to check for.
1800
  * Default: current component.
 
1801
  * @return bool True if the specified component is set to be the site's front
1802
  * page, otherwise false.
1803
  */
@@ -1827,7 +1843,7 @@ function bp_is_component_front_page( $component = '' ) {
1827
  /**
1828
  * Filters whether or not the specified BuddyPress component directory is set to be the front page.
1829
  *
1830
- * @since BuddyPress (1.5.0)
1831
  *
1832
  * @param bool $value Whether or not the specified component directory is set as front page.
1833
  * @param string $component Current component being checked.
@@ -1857,7 +1873,7 @@ function bp_is_blog_page() {
1857
  /**
1858
  * Filters whether or not current page is a blog page or not.
1859
  *
1860
- * @since BuddyPress (1.5.0)
1861
  *
1862
  * @param bool $is_blog_page Whether or not current page is a blog page.
1863
  */
@@ -1874,7 +1890,7 @@ function bp_is_blog_page() {
1874
  * The one exception is single user home tabs, where $bp->current_component
1875
  * is unset. Thus the addition of the bp_is_user() check.
1876
  *
1877
- * @since BuddyPress (1.7.0)
1878
  *
1879
  * @return bool True if it's a BuddyPress page, false otherwise.
1880
  */
@@ -1884,7 +1900,7 @@ function is_buddypress() {
1884
  /**
1885
  * Filters whether or not this is a BuddyPress component.
1886
  *
1887
- * @since BuddyPress (1.7.0)
1888
  *
1889
  * @param bool $retval Whether or not this is a BuddyPress component.
1890
  */
@@ -1896,11 +1912,12 @@ function is_buddypress() {
1896
  /**
1897
  * Check whether a given component (or feature of a component) is active.
1898
  *
1899
- * @since BuddyPress (1.2.0) See r2539.
1900
- * @since BuddyPress (2.3.0) Added $feature as a parameter.
1901
  *
1902
  * @param string $component The component name.
1903
  * @param string $feature The feature name.
 
1904
  * @return bool
1905
  */
1906
  function bp_is_active( $component = '', $feature = '' ) {
@@ -1917,6 +1934,11 @@ function bp_is_active( $component = '', $feature = '' ) {
1917
 
1918
  // Is feature active?
1919
  if ( ! empty( $feature ) ) {
 
 
 
 
 
1920
  if ( empty( buddypress()->$component->features ) || false === in_array( $feature, buddypress()->$component->features, true ) ) {
1921
  $retval = false;
1922
  }
@@ -1924,7 +1946,10 @@ function bp_is_active( $component = '', $feature = '' ) {
1924
  /**
1925
  * Filters whether or not a given feature for a component is active.
1926
  *
1927
- * @since BuddyPress (2.3.0)
 
 
 
1928
  *
1929
  * @param bool $retval
1930
  */
@@ -1935,7 +1960,7 @@ function bp_is_active( $component = '', $feature = '' ) {
1935
  /**
1936
  * Filters whether or not a given component has been activated by the admin.
1937
  *
1938
- * @since BuddyPress (2.1.0)
1939
  *
1940
  * @param bool $retval Whether or not a given component has been activated by the admin.
1941
  * @param string $component Current component being checked.
@@ -2018,7 +2043,7 @@ function bp_is_forums_component() {
2018
  /**
2019
  * Check whether the current page is part of the Notifications component.
2020
  *
2021
- * @since BuddyPress (1.9.0)
2022
  *
2023
  * @return bool True if the current page is part of the Notifications component.
2024
  */
@@ -2045,7 +2070,7 @@ function bp_is_settings_component() {
2045
  * BuddyPress core, it will return true.
2046
  *
2047
  * @return bool True if the current component is active and is one of BP's
2048
- * packaged components.
2049
  */
2050
  function bp_is_current_component_core() {
2051
  $retval = false;
@@ -2063,9 +2088,9 @@ function bp_is_current_component_core() {
2063
  /** Activity ******************************************************************/
2064
 
2065
  /**
2066
- * Is the current page the activity directory ?
2067
  *
2068
- * @since BuddyPress (2.0.0)
2069
  *
2070
  * @return True if the current page is the activity directory.
2071
  */
@@ -2089,9 +2114,9 @@ function bp_is_single_activity() {
2089
  /** User **********************************************************************/
2090
 
2091
  /**
2092
- * Is the current page the members directory ?
2093
  *
2094
- * @since BuddyPress (2.0.0)
2095
  *
2096
  * @return True if the current page is the members directory.
2097
  */
@@ -2121,7 +2146,7 @@ function bp_is_my_profile() {
2121
  /**
2122
  * Filters whether or not current page is part of the profile for the logged-in user.
2123
  *
2124
- * @since BuddyPress (1.2.4)
2125
  *
2126
  * @param bool $my_profile Whether or not current page is part of the profile for the logged-in user.
2127
  */
@@ -2226,6 +2251,19 @@ function bp_is_user_change_avatar() {
2226
  return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) );
2227
  }
2228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2229
  /**
2230
  * Is this a user's forums page?
2231
  *
@@ -2251,7 +2289,7 @@ function bp_is_user_forums() {
2251
  *
2252
  * Eg http://example.com/members/joe/forums/topics/.
2253
  *
2254
- * @since BuddyPress (1.5.0)
2255
  *
2256
  * @return bool True if the current page is a user's Topics Started page.
2257
  */
@@ -2264,7 +2302,7 @@ function bp_is_user_forums_started() {
2264
  *
2265
  * Eg http://example.com/members/joe/forums/replies/.
2266
  *
2267
- * @since BuddyPress (1.5.0)
2268
  *
2269
  * @return bool True if the current page is a user's Replied To forums page.
2270
  */
@@ -2343,7 +2381,7 @@ function bp_is_user_friend_requests() {
2343
  *
2344
  * Eg http://example.com/members/joe/notifications/ (or a subpage thereof).
2345
  *
2346
- * @since BuddyPress (1.9.0)
2347
  *
2348
  * @return bool True if the current page is a user's Notifications page.
2349
  */
@@ -2367,7 +2405,7 @@ function bp_is_user_settings() {
2367
  *
2368
  * Eg http://example.com/members/joe/settings/general/.
2369
  *
2370
- * @since BuddyPress (1.5.0)
2371
  *
2372
  * @return bool True if the current page is a user's General Settings page.
2373
  */
@@ -2380,7 +2418,7 @@ function bp_is_user_settings_general() {
2380
  *
2381
  * Eg http://example.com/members/joe/settings/notifications/.
2382
  *
2383
- * @since BuddyPress (1.5.0)
2384
  *
2385
  * @return bool True if the current page is a user's Notification Settings page.
2386
  */
@@ -2393,7 +2431,7 @@ function bp_is_user_settings_notifications() {
2393
  *
2394
  * Eg http://example.com/members/joe/settings/delete-account/.
2395
  *
2396
- * @since BuddyPress (1.5.0)
2397
  *
2398
  * @return bool True if the current page is a user's Delete Account page.
2399
  */
@@ -2406,7 +2444,7 @@ function bp_is_user_settings_account_delete() {
2406
  *
2407
  * Eg http://example.com/members/joe/settings/profile/.
2408
  *
2409
- * @since BuddyPress (2.0.0)
2410
  *
2411
  * @return bool True if the current page is a user's Profile Settings page.
2412
  */
@@ -2419,7 +2457,7 @@ function bp_is_user_settings_profile() {
2419
  /**
2420
  * Is the current page the groups directory ?
2421
  *
2422
- * @since BuddyPress (2.0.0)
2423
  *
2424
  * @return True if the current page is the groups directory.
2425
  */
@@ -2514,7 +2552,17 @@ function bp_is_group_forum() {
2514
  * @return True if the current page is a group's activity page.
2515
  */
2516
  function bp_is_group_activity() {
2517
- return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) );
 
 
 
 
 
 
 
 
 
 
2518
  }
2519
 
2520
  /**
@@ -2547,7 +2595,17 @@ function bp_is_group_forum_topic_edit() {
2547
  * @return bool True if the current page is part of a group's Members page.
2548
  */
2549
  function bp_is_group_members() {
2550
- return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) );
 
 
 
 
 
 
 
 
 
 
2551
  }
2552
 
2553
  /**
@@ -2594,6 +2652,18 @@ function bp_is_group_single() {
2594
  return (bool) ( bp_is_groups_component() && bp_is_single_item() );
2595
  }
2596
 
 
 
 
 
 
 
 
 
 
 
 
 
2597
  /**
2598
  * Is the current page the Create a Blog page?
2599
  *
@@ -2608,7 +2678,7 @@ function bp_is_create_blog() {
2608
  /**
2609
  * Is the current page the blogs directory ?
2610
  *
2611
- * @since BuddyPress (2.0.0)
2612
  *
2613
  * @return True if the current page is the blogs directory.
2614
  */
@@ -2693,6 +2763,9 @@ function bp_is_messages_conversation() {
2693
  /**
2694
  * Not currently used by BuddyPress.
2695
  *
 
 
 
2696
  * @return bool
2697
  */
2698
  function bp_is_single( $component, $callback ) {
@@ -2725,16 +2798,20 @@ function bp_is_register_page() {
2725
 
2726
  /**
2727
  * Customize the body class, according to the currently displayed BP content.
2728
- *
2729
- * Uses the above is_() functions to output a body class for each scenario.
2730
- *
2731
- * @param array $wp_classes The body classes coming from WP.
2732
- * @param array $custom_classes Classes that were passed to get_body_class().
2733
- * @return array $classes The BP-adjusted body classes.
2734
  */
2735
  function bp_the_body_class() {
2736
  echo bp_get_the_body_class();
2737
  }
 
 
 
 
 
 
 
 
 
 
2738
  function bp_get_the_body_class( $wp_classes = array(), $custom_classes = false ) {
2739
 
2740
  $bp_classes = array();
@@ -2949,7 +3026,7 @@ function bp_the_body_class() {
2949
  /**
2950
  * Filters the BuddyPress classes to be added to body_class()
2951
  *
2952
- * @since BuddyPress (1.1.0)
2953
  *
2954
  * @param array $classes Array of body classes to add.
2955
  * @param array $bp_classes Array of BuddyPress-based classes.
@@ -2965,9 +3042,10 @@ function bp_the_body_class() {
2965
  *
2966
  * Hooked to the 'post_class' filter.
2967
  *
2968
- * @since BuddyPress (2.1.0)
2969
  *
2970
  * @param array $wp_classes The post classes coming from WordPress.
 
2971
  * @return array
2972
  */
2973
  function bp_get_the_post_class( $wp_classes = array() ) {
@@ -3009,13 +3087,6 @@ function bp_get_the_post_class( $wp_classes = array() ) {
3009
  $bp_classes[] = "type-{$bp_class}";
3010
  }
3011
 
3012
- // removes the 'page' and 'type-page' post classes
3013
- // we need to remove these classes since they did not exist before we switched
3014
- // theme compat to use the 'page' post type
3015
- $page_key = array_search( 'page', $wp_classes );
3016
- $page_type_key = array_search( 'type-page', $wp_classes );
3017
- unset( $wp_classes[$page_key], $wp_classes[$page_type_key] );
3018
-
3019
  // okay let's merge!
3020
  return array_unique( array_merge( $bp_classes, $wp_classes ) );
3021
  }
@@ -3028,12 +3099,14 @@ add_filter( 'post_class', 'bp_get_the_post_class' );
3028
  * a later release. Do not use.
3029
  *
3030
  * @access private
3031
- * @since BuddyPress (1.7.0)
3032
  *
3033
  * @param array $a First item.
3034
  * @param array $b Second item.
 
3035
  * @return int Returns an integer less than, equal to, or greater than zero if
3036
- * the first argument is considered to be respectively less than, equal to, or greater than the second.
 
3037
  */
3038
  function _bp_nav_menu_sort( $a, $b ) {
3039
  if ( $a['position'] == $b['position'] ) {
@@ -3048,7 +3121,7 @@ function _bp_nav_menu_sort( $a, $b ) {
3048
  /**
3049
  * Get the items registered in the primary and secondary BuddyPress navigation menus.
3050
  *
3051
- * @since BuddyPress (1.7.0)
3052
  *
3053
  * @return array A multidimensional array of all navigation items.
3054
  */
@@ -3127,7 +3200,7 @@ function bp_get_nav_menu_items() {
3127
  /**
3128
  * Filters the items registered in the primary and secondary BuddyPress navigation menus.
3129
  *
3130
- * @since BuddyPress (1.7.0)
3131
  *
3132
  * @param array $menus Array of items registered in the primary and secondary BuddyPress navigation.
3133
  */
@@ -3137,38 +3210,40 @@ function bp_get_nav_menu_items() {
3137
  /**
3138
  * Display a navigation menu.
3139
  *
3140
- * @since BuddyPress (1.7.0)
3141
  *
3142
  * @param string|array $args {
3143
  * An array of optional arguments.
3144
- * @type string $after Text after the link text. Default: ''.
3145
- * @type string $before Text before the link text. Default: ''.
3146
- * @type string $container The name of the element to wrap the navigation
3147
- * with. 'div' or 'nav'. Default: 'div'.
 
3148
  * @type string $container_class The class that is applied to the container.
3149
- * Default: 'menu-bp-container'.
3150
- * @type string $container_id The ID that is applied to the container.
3151
- * Default: ''.
3152
- * @type int depth How many levels of the hierarchy are to be included. 0
3153
- * means all. Default: 0.
3154
- * @type bool $echo True to echo the menu, false to return it.
3155
- * Default: true.
3156
- * @type bool $fallback_cb If the menu doesn't exist, should a callback
3157
- * function be fired? Default: false (no fallback).
3158
- * @type string $items_wrap How the list items should be wrapped. Should be
3159
- * in the form of a printf()-friendly string, using numbered
3160
- * placeholders. Default: '<ul id="%1$s" class="%2$s">%3$s</ul>'.
3161
- * @type string $link_after Text after the link. Default: ''.
3162
- * @type string $link_before Text before the link. Default: ''.
3163
- * @type string $menu_class CSS class to use for the <ul> element which
3164
- * forms the menu. Default: 'menu'.
3165
- * @type string $menu_id The ID that is applied to the <ul> element which
3166
- * forms the menu. Default: 'menu-bp', incremented.
3167
- * @type string $walker Allows a custom walker class to be specified.
3168
- * Default: 'BP_Walker_Nav_Menu'.
3169
  * }
 
3170
  * @return string|null If $echo is false, returns a string containing the nav
3171
- * menu markup.
3172
  */
3173
  function bp_nav_menu( $args = array() ) {
3174
  static $menu_id_slugs = array();
@@ -3194,7 +3269,7 @@ function bp_nav_menu( $args = array() ) {
3194
  /**
3195
  * Filters the parsed bp_nav_menu arguments.
3196
  *
3197
- * @since BuddyPress (1.7.0)
3198
  *
3199
  * @param array $args Array of parsed arguments.
3200
  */
@@ -3219,7 +3294,7 @@ function bp_nav_menu( $args = array() ) {
3219
  /**
3220
  * Filters the allowed tags for the wp_nav_menu_container.
3221
  *
3222
- * @since BuddyPress (1.7.0)
3223
  *
3224
  * @param array $value Array of allowed tags. Default 'div' and 'nav'.
3225
  */
@@ -3237,7 +3312,7 @@ function bp_nav_menu( $args = array() ) {
3237
  /**
3238
  * Filters the BuddyPress menu objects.
3239
  *
3240
- * @since BuddyPress (1.7.0)
3241
  *
3242
  * @param array $value Array of nav menu objects.
3243
  * @param array $args Array of arguments for the menu.
@@ -3269,7 +3344,7 @@ function bp_nav_menu( $args = array() ) {
3269
  *
3270
  * Allow plugins to hook into the menu to add their own <li>'s
3271
  *
3272
- * @since BuddyPress (1.7.0)
3273
  *
3274
  * @param array $items Array of nav menu items.
3275
  * @param array $args Array of arguments for the menu.
@@ -3289,7 +3364,7 @@ function bp_nav_menu( $args = array() ) {
3289
  /**
3290
  * Filters the final BuddyPress menu output.
3291
  *
3292
- * @since BuddyPress (1.7.0)
3293
  *
3294
  * @param string $nav_menu Final nav menu output.
3295
  * @param array $args Array of arguments for the menu.
1
  <?php
2
  /**
3
+ * Core component template tag functions.
4
  *
5
  * @package BuddyPress
6
  * @subpackage TemplateFunctions
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /**
25
  *
26
  * @uses bp_get_user_nav() Renders the navigation for a profile of a currently
27
  * viewed user.
28
+ *
29
+ * @param string $parent_slug
30
+ *
31
+ * @return string
32
  */
33
  function bp_get_options_nav( $parent_slug = '' ) {
34
  $bp = buddypress();
80
  *
81
  * This is a dynamic filter that is dependent on the provided css_id value.
82
  *
83
+ * @since 1.1.0
84
  *
85
  * @param string $value HTML list item for the submenu item.
86
  * @param array $subnav_item Submenu array item being displayed.
112
  * Used for the <title> element and the page header on the component directory
113
  * page.
114
  *
115
+ * @since 2.0.0
116
+ *
117
+ * @param string $component
118
  *
119
  * @return string
120
  */
133
  /**
134
  * Filters the directory title for a component.
135
  *
136
+ * @since 2.0.0
137
  *
138
  * @param string $title Text to be used in <title> tag.
139
  * @param string $component Current componet being displayed.
151
  *
152
  * Not currently used in BuddyPress.
153
  *
154
+ * @return bool $value Returns true if an options avatar has been set, otherwise false.
155
  */
156
  function bp_has_options_avatar() {
157
  return (bool) buddypress()->bp_options_avatar;
227
  /**
228
  * Filters the current avatar upload step.
229
  *
230
+ * @since 1.1.0
231
  *
232
  * @param string $step The current avatar upload step.
233
  */
254
  /**
255
  * Filters the URL of the avatar to crop.
256
  *
257
+ * @since 1.1.0
258
  *
259
  * @param string $url URL for the avatar.
260
  */
281
  /**
282
  * Filters the relative file path to the avatar to crop.
283
  *
284
+ * @since 1.1.0
285
  *
286
  * @param string $src Relative file path for the avatar.
287
  */
310
  /**
311
  * Returns the name of the BP site. Used in RSS headers.
312
  *
313
+ * @since 1.6.0
314
  */
315
  function bp_get_site_name() {
316
 
317
  /**
318
  * Filters the name of the BP site. Used in RSS headers.
319
  *
320
+ * @since 1.0.0
321
  *
322
  * @param string $value Current BP site name.
323
  */
325
  }
326
 
327
  /**
328
+ * Format a date based on a UNIX timestamp.
329
  *
330
  * This function can be used to turn a UNIX timestamp into a properly formatted
331
  * (and possibly localized) string, userful for ouputting the date & time an
338
  * hardly used and adds an additional layer of complexity to calculating dates
339
  * and times together with timezone offsets and i18n.
340
  *
341
+ * @since 1.1.0
342
  *
343
+ * @param int|string $time The UNIX timestamp to be formatted.
344
+ * @param bool $exclude_time Optional. True to return only the month + day, false
345
+ * to return month, day, and time. Default: false.
346
+ * @param bool $gmt Optional. True to display in local time, false to
347
+ * leave in GMT. Default: true.
348
  *
349
+ * @return mixed A string representation of $time, in the format
350
+ * "March 18, 2014 at 2:00 pm" (or whatever your
351
+ * 'date_format' and 'time_format' settings are
352
+ * on your root blog). False on failure.
353
  */
354
  function bp_format_time( $time = '', $exclude_time = false, $gmt = true ) {
355
 
398
  /**
399
  * Filters the date based on a UNIX timestamp.
400
  *
401
+ * @since 1.0.0
402
  *
403
  * @param string $formatted_date Formatted date from the timestamp.
404
  */
414
  * of the phrase, and bp_word_or_name() will detect which is appropriate, and
415
  * do the necessary argument swapping for dynamic phrases.
416
  *
417
+ * @param string $youtext The "you" version of the phrase (eg "Your Friends").
418
  * @param string $nametext The other-user version of the phrase. Should be in
419
+ * a format appropriate for sprintf() - use %s in place of the displayed
420
+ * user's name (eg "%'s Friends").
421
  * @param bool $capitalize Optional. Force into title case. Default: true.
422
+ * @param bool $echo Optional. True to echo the results, false to return them.
423
+ * Default: true.
424
+ *
425
+ * @return string|null $nametext If ! $echo, returns the appropriate string.
426
  */
427
  function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
428
 
436
  /**
437
  * Filters the text used based on context of own profile or someone else's profile.
438
  *
439
+ * @since 1.0.0
440
  *
441
  * @param string $youtext Context-determined string to display.
442
  */
486
  /**
487
  * Filters the "action" attribute for search forms.
488
  *
489
+ * @since 1.0.0
490
  *
491
  * @param string $value Search form action url.
492
  */
496
  /**
497
  * Generate the basic search form as used in BP-Default's header.
498
  *
499
+ * @since 1.0.0
500
  *
501
  * @return string HTML <select> element.
502
  */
529
  /**
530
  * Filters all of the component options available for search scope.
531
  *
532
+ * @since 1.5.0
533
  *
534
  * @param array $options Array of options to add to select field.
535
  */
543
  /**
544
  * Filters the complete <select> input used for search scope.
545
  *
546
+ * @since 1.0.0
547
  *
548
  * @param string $selection_box <select> input for selecting search scope.
549
  */
553
  /**
554
  * Output the default text for the search box for a given component.
555
  *
556
+ * @since 1.5.0
557
  *
558
  * @see bp_get_search_default_text()
559
  *
565
  /**
566
  * Return the default text for the search box for a given component.
567
  *
568
+ * @since 1.5.0
569
  *
570
  * @param string $component Component name. Default: current component.
571
+ *
572
  * @return string Placeholder text for search field.
573
  */
574
  function bp_get_search_default_text( $component = '' ) {
600
  /**
601
  * Filters the default text for the search box for a given component.
602
  *
603
+ * @since 1.5.0
604
  *
605
  * @param string $default_text Default text for search box.
606
  * @param string $component Current component displayed.
633
  /**
634
  * Output the attributes for a form field.
635
  *
636
+ * @since 2.2.0
637
  *
638
  * @param string $name The field name to output attributes for.
639
  * @param array $attributes Array of existing attributes to add.
648
  * can use the 'bp_get_form_field_extra_attributes' filter for further
649
  * manipulation.
650
  *
651
+ * @since 2.2.0
652
  *
653
  * @param string $name The field name to get attributes for.
654
  * @param array $attributes Array of existing attributes to add.
690
  /**
691
  * Filter the attributes for a field before rendering output.
692
  *
693
+ * @since 2.2.0
694
  *
695
+ * @param array $attributes The field attributes.
696
+ * @param string $name The field name.
697
  */
698
  $attributes = (array) apply_filters( 'bp_get_form_field_attributes', $attributes, $name );
699
 
709
  *
710
  * @see bp_get_button()
711
  *
712
+ * @param array|string $args See {@link BP_Button}.
713
  */
714
  function bp_button( $args = '' ) {
715
  echo bp_get_button( $args );
719
  *
720
  * @see BP_Button for a description of arguments and return value.
721
  *
722
+ * @param array|string $args See {@link BP_Button}.
723
  * @return string HTML markup for the button.
724
  */
725
  function bp_get_button( $args = '' ) {
728
  /**
729
  * Filters the requested button output.
730
  *
731
+ * @since 1.2.6
732
  *
733
  * @param string $contents Button context to be used.
734
  * @param array $args Array of args for the button.
748
  *
749
  * ### Options:
750
  *
751
+ * - `ending` Will be used as Ending and appended to the trimmed string.
752
+ * - `exact` If false, $text will not be cut mid-word.
753
+ * - `html` If true, HTML tags would be handled correctly.
754
+ * - `filter_shortcodes` If true, shortcodes will be stripped before truncating.
755
  *
756
+ * @param string $text String to truncate.
757
+ * @param int $length Optional. Length of returned string, including ellipsis.
758
+ * Default: 225.
759
  * @param array $options {
760
  * An array of HTML attributes and options. Each item is optional.
761
+ * @type string $ending The string used after truncation.
762
+ * Default: ' [&hellip;]'.
763
+ * @type bool $exact If true, $text will be trimmed to exactly $length.
764
+ * If false, $text will not be cut mid-word. Default: false.
765
+ * @type bool $html If true, don't include HTML tags when calculating
766
+ * excerpt length. Default: true.
767
+ * @type bool $filter_shortcodes If true, shortcodes will be stripped.
768
+ * Default: true.
769
  * }
770
  * @return string Trimmed string.
771
  */
787
  /**
788
  * Filters the excerpt length to trim text to.
789
  *
790
+ * @since 1.5.0
791
  *
792
  * @param int $length Length of returned string, including ellipsis.
793
  */
796
  /**
797
  * Filters the excerpt appended text value.
798
  *
799
+ * @since 1.5.0
800
  *
801
  * @param string $value Text to append to the end of the excerpt.
802
  */
949
  /**
950
  * Filters the final generated excerpt.
951
  *
952
+ * @since 1.1.0
953
  *
954
  * @param string $truncate Generated excerpt.
955
  * @param string $original_text Original text provided.
986
  /**
987
  * Filters the total member count in your BP instance.
988
  *
989
+ * @since 1.2.0
990
  *
991
  * @param int $value Member count.
992
  */
1028
  * Check whether an activation has just been completed.
1029
  *
1030
  * @return bool True if the activation_complete global flag has been set,
1031
+ * otherwise false.
1032
  */
1033
  function bp_account_was_activated() {
1034
  $bp = buddypress();
1053
  /**
1054
  * Filters whether registrations require activation on this installation.
1055
  *
1056
+ * @since 1.2.0
1057
  *
1058
  * @param bool $value Whether registrations require activation. Default true.
1059
  */
1066
  * The blogname option is escaped with esc_html on the way into the database in
1067
  * sanitize_option, we want to reverse this for the plain text arena of emails.
1068
  *
1069
+ * @since 1.7.0
1070
  *
1071
  * @see https://buddypress.trac.wordpress.org/ticket/4401
1072
  *
1073
  * @param array $args {
1074
  * Array of optional parameters.
1075
+ * @type string $before String to appear before the site name in the
1076
+ * email subject. Default: '['.
1077
+ * @type string $after String to appear after the site name in the
1078
+ * email subject. Default: ']'.
1079
  * @type string $default The default site name, to be used when none is
1080
+ * found in the database. Default: 'Community'.
1081
+ * @type string $text Text to append to the site name (ie, the main text of
1082
+ * the email subject).
1083
  * }
1084
  * @return string Sanitized email subject.
1085
  */
1097
  /**
1098
  * Filters a client friendly version of the root blog name.
1099
  *
1100
+ * @since 1.7.0
1101
  *
1102
  * @param string $subject Client friendy version of the root blog name.
1103
  * @param array $r Array of arguments for the email subject.
1115
  * errors if someone copies the templates from the default theme into another
1116
  * WordPress theme without coping the functions from functions.php.
1117
  *
1118
+ * @param string|bool $object
1119
+ *
1120
  * @return string The AJAX querystring.
1121
  */
1122
  function bp_ajax_querystring( $object = false ) {
1131
  *
1132
  * Allows templates to pass parameters into the template loops via AJAX.
1133
  *
1134
+ * @since 1.2.0
1135
  *
1136
  * @param string $ajax_querystring Current query string.
1137
  * @param string $object Current template component.
1155
  /**
1156
  * Filters the name of the current component.
1157
  *
1158
+ * @since 1.0.0
1159
  *
1160
  * @param string|bool $current_component Current component if available or false.
1161
  */
1176
  /**
1177
  * Filters the name of the current action.
1178
  *
1179
+ * @since 1.0.0
1180
  *
1181
  * @param string $current_action Current action.
1182
  */
1186
  /**
1187
  * Return the name of the current item.
1188
  *
1189
+ * @return string|bool
1190
  */
1191
  function bp_current_item() {
1192
  $bp = buddypress();
1197
  /**
1198
  * Filters the name of the current item.
1199
  *
1200
+ * @since 1.1.0
1201
  *
1202
  * @param string|bool $current_item Current item if available or false.
1203
  */
1208
  * Return the value of $bp->action_variables.
1209
  *
1210
  * @return array|bool $action_variables The action variables array, or false
1211
+ * if the array is empty.
1212
  */
1213
  function bp_action_variables() {
1214
  $bp = buddypress();
1219
  /**
1220
  * Filters the value of $bp->action_variables.
1221
  *
1222
+ * @since 1.0.0
1223
  *
1224
  * @param array|bool $action_variables Available action variables.
1225
  */
1229
  /**
1230
  * Return the value of a given action variable.
1231
  *
1232
+ * @since 1.5.0
1233
  *
1234
  * @param int $position The key of the action_variables array that you want.
1235
+ *
1236
  * @return string|bool $action_variable The value of that position in the
1237
+ * array, or false if not found.
1238
  */
1239
  function bp_action_variable( $position = 0 ) {
1240
  $action_variables = bp_action_variables();
1245
  /**
1246
  * Filters the value of a given action variable.
1247
  *
1248
+ * @since 1.5.0
1249
  *
1250
  * @param string|bool $action_variable Requested action variable based on position.
1251
  * @param int $position The key of the action variable requested.
1277
  /**
1278
  * Filters the "root domain", the URL of the BP root blog.
1279
  *
1280
+ * @since 1.2.4
1281
  *
1282
  * @param string $domain URL of the BP root blog.
1283
  */
1287
  /**
1288
  * Output the root slug for a given component.
1289
  *
1290
+ * @since 1.5.0
1291
  *
1292
  * @param string $component The component name.
1293
  */
1307
  * In order to maintain backward compatibility, the following procedure
1308
  * is used:
1309
  * 1) Use the short slug to get the canonical component name from the
1310
+ * active component array.
1311
  * 2) Use the component name to get the root slug out of the
1312
+ * appropriate part of the $bp global.
1313
  * 3) If nothing turns up, it probably means that $component is itself
1314
+ * a root slug.
1315
  *
1316
  * Example: If your groups directory is at /community/companies, this
1317
  * function first uses the short slug 'companies' (ie the current
1319
  * $bp->active_components. Then it uses 'groups' to get the root slug,
1320
  * from $bp->groups->root_slug.
1321
  *
1322
+ * @since 1.5.0
1323
  *
1324
  * @param string $component Optional. Defaults to the current component.
1325
+ *
1326
  * @return string $root_slug The root slug.
1327
  */
1328
  function bp_get_root_slug( $component = '' ) {
1357
  /**
1358
  * Filters the root slug for given component.
1359
  *
1360
+ * @since 1.5.0
1361
  *
1362
  * @param string $root_slug Root slug for given component.
1363
  * @param string $component Current component.
1368
  /**
1369
  * Return the component name based on a root slug.
1370
  *
1371
+ * @since 1.5.0
1372
  *
1373
  * @param string $root_slug Needle to our active component haystack.
1374
+ *
1375
  * @return mixed False if none found, component name if found.
1376
  */
1377
  function bp_get_name_from_root_slug( $root_slug = '' ) {
1398
  }
1399
 
1400
  function bp_user_has_access() {
1401
+ $has_access = bp_current_user_can( 'bp_moderate' ) || bp_is_my_profile();
 
 
1402
 
1403
  /**
1404
  * Filters whether or not a user has access.
1405
  *
1406
+ * @since 1.2.4
1407
  *
1408
  * @param bool $has_access Whether or not user has access.
1409
  */
1413
  /**
1414
  * Output the search slug.
1415
  *
1416
+ * @since 1.5.0
1417
  *
1418
  * @uses bp_get_search_slug()
1419
  */
1423
  /**
1424
  * Return the search slug.
1425
  *
1426
+ * @since 1.5.0
1427
  *
1428
  * @return string The search slug. Default: 'search'.
1429
  */
1432
  /**
1433
  * Filters the search slug.
1434
  *
1435
+ * @since 1.5.0
1436
  *
1437
+ * @const string BP_SEARCH_SLUG The search slug. Default "search".
1438
  */
1439
  return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
1440
  }
1444
  *
1445
  * @uses apply_filters() Filter 'bp_displayed_user_id' to change this value.
1446
  *
1447
+ * @return int $id ID of the currently displayed user.
1448
  */
1449
  function bp_displayed_user_id() {
1450
  $bp = buddypress();
1455
  /**
1456
  * Filters the ID of the currently displayed user.
1457
  *
1458
+ * @since 1.0.0
1459
  *
1460
  * @param int $id ID of the currently displayed user.
1461
  */
1478
  /**
1479
  * Filters the ID of the currently logged-in user.
1480
  *
1481
+ * @since 1.0.0
1482
  *
1483
  * @param int $id ID of the currently logged-in user.
1484
  */
1492
  *
1493
  * This function is designed to be generous, accepting several different kinds
1494
  * of value for the $component parameter. It checks $component_name against:
1495
+ * - the component's root_slug, which matches the page slug in $bp->pages.
1496
+ * - the component's regular slug.
1497
+ * - the component's id, or 'canonical' name.
1498
  *
1499
+ * @since 1.5.0
1500
  *
1501
  * @param string $component Name of the component being checked.
1502
+ *
1503
  * @return bool Returns true if the component matches, or else false.
1504
  */
1505
  function bp_is_current_component( $component = '' ) {
1565
  /**
1566
  * Filters whether the current page belongs to the specified component.
1567
  *
1568
+ * @since 1.5.0
1569
  *
1570
  * @param bool $is_current_component Whether or not the current page belongs to specified component.
1571
  * @param string $component Name of the component being checked.
1585
  * http://example.com/groups/my-group/members
1586
  * the current_action is 'members'.
1587
  *
1588
+ * @since 1.5.0
1589
  *
1590
  * @param string $action The action being tested against.
1591
+ *
1592
  * @return bool True if the current action matches $action.
1593
  */
1594
  function bp_is_current_action( $action = '' ) {
1607
  * http://example.com/groups/my-group/admin/group-settings
1608
  * $action_variables[0] is 'group-settings'.
1609
  *
1610
+ * @since 1.5.0
1611
+ *
1612
+ * @param string $action_variable The action_variable being tested against.
1613
+ * @param int|bool $position Optional. The array key you're testing against. If you
1614
+ * don't provide a $position, the function will return true if the
1615
+ * $action_variable is found *anywhere* in the action variables array.
1616
  *
 
 
 
 
1617
  * @return bool True if $action_variable matches at the $position provided.
1618
  */
1619
  function bp_is_action_variable( $action_variable = '', $position = false ) {
1636
  /**
1637
  * Filters whether the current page matches a given action_variable.
1638
  *
1639
+ * @since 1.5.0
1640
  *
1641
  * @param bool $is_action_variable Whether the current page matches a given action_variable.
1642
  * @param string $action_variable The action_variable being tested against.
1649
  * Check against the current_item.
1650
  *
1651
  * @param string $item The item being checked.
1652
+ *
1653
  * @return bool True if $item is the current item.
1654
  */
1655
  function bp_is_current_item( $item = '' ) {
1658
  /**
1659
  * Filters whether or not an item is the current item.
1660
  *
1661
+ * @since 2.1.0
1662
  *
1663
  * @param bool $retval Whether or not an item is the current item.
1664
  * @param string $item The item being checked.
1682
  /**
1683
  * Filters whether or not an item is the a single item. (group, user, etc)
1684
  *
1685
+ * @since 2.1.0
1686
  *
1687
  * @param bool $retval Whether or not an item is a single item.
1688
  */
1693
  * Is the logged-in user an admin for the current item?
1694
  *
1695
  * @return bool True if the current user is an admin for the current item,
1696
+ * otherwise false.
1697
  */
1698
  function bp_is_item_admin() {
1699
  $bp = buddypress();
1706
  /**
1707
  * Filters whether or not the logged-in user is an admin for the current item.
1708
  *
1709
+ * @since 2.1.0
1710
  *
1711
  * @param bool $retval Whether or not the logged-in user is an admin.
1712
  */
1717
  * Is the logged-in user a mod for the current item?
1718
  *
1719
  * @return bool True if the current user is a mod for the current item,
1720
+ * otherwise false.
1721
  */
1722
  function bp_is_item_mod() {
1723
  $bp = buddypress();
1730
  /**
1731
  * Filters whether or not the logged-in user is a mod for the current item.
1732
  *
1733
+ * @since 2.1.0
1734
  *
1735
  * @param bool $retval Whether or not the logged-in user is a mod.
1736
  */
1740
  /**
1741
  * Is this a component directory page?
1742
  *
1743
+ * @return bool True if the current page is a component directory, otherwise false.
 
1744
  */
1745
  function bp_is_directory() {
1746
  $bp = buddypress();
1753
  /**
1754
  * Filters whether or not user is on a component directory page.
1755
  *
1756
+ * @since 2.1.0
1757
  *
1758
  * @param bool $retval Whether or not user is on a component directory page.
1759
  */
1769
  * This function is on the chopping block. It's currently only used by a few
1770
  * already deprecated functions.
1771
  *
1772
+ * @param string $component_name
1773
+ *
1774
  * @return bool True if root component, else false.
1775
  */
1776
  function bp_is_root_component( $component_name = '' ) {
1795
  /**
1796
  * Filters whether or not a component's URL should be in the root, not under a member page.
1797
  *
1798
+ * @since 2.1.0
1799
  *
1800
  * @param bool $retval Whether or not URL should be in the root.
1801
  */
1807
  *
1808
  * Corresponds to the setting in wp-admin's Settings > Reading screen.
1809
  *
1810
+ * @since 1.5.0
1811
  *
1812
+ * @global int $current_blog WordPress global for the current blog.
1813
  *
1814
  * @param string $component Optional. Name of the component to check for.
1815
  * Default: current component.
1816
+ *
1817
  * @return bool True if the specified component is set to be the site's front
1818
  * page, otherwise false.
1819
  */
1843
  /**
1844
  * Filters whether or not the specified BuddyPress component directory is set to be the front page.
1845
  *
1846
+ * @since 1.5.0
1847
  *
1848
  * @param bool $value Whether or not the specified component directory is set as front page.
1849
  * @param string $component Current component being checked.
1873
  /**
1874
  * Filters whether or not current page is a blog page or not.
1875
  *
1876
+ * @since 1.5.0
1877
  *
1878
  * @param bool $is_blog_page Whether or not current page is a blog page.
1879
  */
1890
  * The one exception is single user home tabs, where $bp->current_component
1891
  * is unset. Thus the addition of the bp_is_user() check.
1892
  *
1893
+ * @since 1.7.0
1894
  *
1895
  * @return bool True if it's a BuddyPress page, false otherwise.
1896
  */
1900
  /**
1901
  * Filters whether or not this is a BuddyPress component.
1902
  *
1903
+ * @since 1.7.0
1904
  *
1905
  * @param bool $retval Whether or not this is a BuddyPress component.
1906
  */
1912
  /**
1913
  * Check whether a given component (or feature of a component) is active.
1914
  *
1915
+ * @since 1.2.0 See r2539.
1916
+ * @since 2.3.0 Added $feature as a parameter.
1917
  *
1918
  * @param string $component The component name.
1919
  * @param string $feature The feature name.
1920
+ *
1921
  * @return bool
1922
  */
1923
  function bp_is_active( $component = '', $feature = '' ) {
1934
 
1935
  // Is feature active?
1936
  if ( ! empty( $feature ) ) {
1937
+ // The xProfile component is specific
1938
+ if ( 'xprofile' === $component ) {
1939
+ $component = 'profile';
1940
+ }
1941
+
1942
  if ( empty( buddypress()->$component->features ) || false === in_array( $feature, buddypress()->$component->features, true ) ) {
1943
  $retval = false;
1944
  }
1946
  /**
1947
  * Filters whether or not a given feature for a component is active.
1948
  *
1949
+ * This is a variable filter that is based on the component and feature
1950
+ * that you are checking of active status of.
1951
+ *
1952
+ * @since 2.3.0
1953
  *
1954
  * @param bool $retval
1955
  */
1960
  /**
1961
  * Filters whether or not a given component has been activated by the admin.
1962
  *
1963
+ * @since 2.1.0
1964
  *
1965
  * @param bool $retval Whether or not a given component has been activated by the admin.
1966
  * @param string $component Current component being checked.
2043
  /**
2044
  * Check whether the current page is part of the Notifications component.
2045
  *
2046
+ * @since 1.9.0
2047
  *
2048
  * @return bool True if the current page is part of the Notifications component.
2049
  */
2070
  * BuddyPress core, it will return true.
2071
  *
2072
  * @return bool True if the current component is active and is one of BP's
2073
+ * packaged components.
2074
  */
2075
  function bp_is_current_component_core() {
2076
  $retval = false;
2088
  /** Activity ******************************************************************/
2089
 
2090
  /**
2091
+ * Is the current page the activity directory?
2092
  *
2093
+ * @since 2.0.0
2094
  *
2095
  * @return True if the current page is the activity directory.
2096
  */
2114
  /** User **********************************************************************/
2115
 
2116
  /**
2117
+ * Is the current page the members directory?
2118
  *
2119
+ * @since 2.0.0
2120
  *
2121
  * @return True if the current page is the members directory.
2122
  */
2146
  /**
2147
  * Filters whether or not current page is part of the profile for the logged-in user.
2148
  *
2149
+ * @since 1.2.4
2150
  *
2151
  * @param bool $my_profile Whether or not current page is part of the profile for the logged-in user.
2152
  */
2251
  return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) );
2252
  }
2253
 
2254
+ /**
2255
+ * Is the current page the a user's change cover image profile page?
2256
+ *
2257
+ * Eg http://example.com/members/joe/profile/change-cover-image/ (or a subpage thereof).
2258
+ *
2259
+ * @since 2.4.0
2260
+ *
2261
+ * @return True if the current page is a user's profile edit cover image page.
2262
+ */
2263
+ function bp_is_user_change_cover_image() {
2264
+ return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-cover-image' ) );
2265
+ }
2266
+
2267
  /**
2268
  * Is this a user's forums page?
2269
  *
2289
  *
2290
  * Eg http://example.com/members/joe/forums/topics/.
2291
  *
2292
+ * @since 1.5.0
2293
  *
2294
  * @return bool True if the current page is a user's Topics Started page.
2295
  */
2302
  *
2303
  * Eg http://example.com/members/joe/forums/replies/.
2304
  *
2305
+ * @since 1.5.0
2306
  *
2307
  * @return bool True if the current page is a user's Replied To forums page.
2308
  */
2381
  *
2382
  * Eg http://example.com/members/joe/notifications/ (or a subpage thereof).
2383
  *
2384
+ * @since 1.9.0
2385
  *
2386
  * @return bool True if the current page is a user's Notifications page.
2387
  */
2405
  *
2406
  * Eg http://example.com/members/joe/settings/general/.
2407
  *
2408
+ * @since 1.5.0
2409
  *
2410
  * @return bool True if the current page is a user's General Settings page.
2411
  */
2418
  *
2419
  * Eg http://example.com/members/joe/settings/notifications/.
2420
  *
2421
+ * @since 1.5.0
2422
  *
2423
  * @return bool True if the current page is a user's Notification Settings page.
2424
  */
2431
  *
2432
  * Eg http://example.com/members/joe/settings/delete-account/.
2433
  *
2434
+ * @since 1.5.0
2435
  *
2436
  * @return bool True if the current page is a user's Delete Account page.
2437
  */
2444
  *
2445
  * Eg http://example.com/members/joe/settings/profile/.
2446
  *
2447
+ * @since 2.0.0
2448
  *
2449
  * @return bool True if the current page is a user's Profile Settings page.
2450
  */
2457
  /**
2458
  * Is the current page the groups directory ?
2459
  *
2460
+ * @since 2.0.0
2461
  *
2462
  * @return True if the current page is the groups directory.
2463
  */
2552
  * @return True if the current page is a group's activity page.
2553
  */
2554
  function bp_is_group_activity() {
2555
+ $retval = false;
2556
+
2557
+ if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) {
2558
+ $retval = true;
2559
+ }
2560
+
2561
+ if ( bp_is_group_home() && bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
2562
+ $retval = true;
2563
+ }
2564
+
2565
+ return $retval;
2566
  }
2567
 
2568
  /**
2595
  * @return bool True if the current page is part of a group's Members page.
2596
  */
2597
  function bp_is_group_members() {
2598
+ $retval = false;
2599
+
2600
+ if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) {
2601
+ $retval = true;
2602
+ }
2603
+
2604
+ if ( bp_is_group_home() && ! bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
2605
+ $retval = true;
2606
+ }
2607
+
2608
+ return $retval;
2609
  }
2610
 
2611
  /**
2652
  return (bool) ( bp_is_groups_component() && bp_is_single_item() );
2653
  }
2654
 
2655
+ /**
2656
+ * Is the current group page a custom front?
2657
+ *
2658
+ * @since 2.4.0
2659
+ *
2660
+ * @return bool True if the current group page is a custom front.
2661
+ */
2662
+ function bp_is_group_custom_front() {
2663
+ $bp = buddypress();
2664
+ return (bool) bp_is_group_home() && ! empty( $bp->groups->current_group->front_template );
2665
+ }
2666
+
2667
  /**
2668
  * Is the current page the Create a Blog page?
2669
  *
2678
  /**
2679
  * Is the current page the blogs directory ?
2680
  *
2681
+ * @since 2.0.0
2682
  *
2683
  * @return True if the current page is the blogs directory.
2684
  */
2763
  /**
2764
  * Not currently used by BuddyPress.
2765
  *
2766
+ * @param string $component Current component to check for.
2767
+ * @param string $callback Callback to invoke.
2768
+ *
2769
  * @return bool
2770
  */
2771
  function bp_is_single( $component, $callback ) {
2798
 
2799
  /**
2800
  * Customize the body class, according to the currently displayed BP content.
 
 
 
 
 
 
2801
  */
2802
  function bp_the_body_class() {
2803
  echo bp_get_the_body_class();
2804
  }
2805
+ /**
2806
+ * Customize the body class, according to the currently displayed BP content.
2807
+ *
2808
+ * Uses the above is_() functions to output a body class for each scenario.
2809
+ *
2810
+ * @param array $wp_classes The body classes coming from WP.
2811
+ * @param array|bool $custom_classes Classes that were passed to get_body_class().
2812
+ *
2813
+ * @return array $classes The BP-adjusted body classes.
2814
+ */
2815
  function bp_get_the_body_class( $wp_classes = array(), $custom_classes = false ) {
2816
 
2817
  $bp_classes = array();
3026
  /**
3027
  * Filters the BuddyPress classes to be added to body_class()
3028
  *
3029
+ * @since 1.1.0
3030
  *
3031
  * @param array $classes Array of body classes to add.
3032
  * @param array $bp_classes Array of BuddyPress-based classes.
3042
  *
3043
  * Hooked to the 'post_class' filter.
3044
  *
3045
+ * @since 2.1.0
3046
  *
3047
  * @param array $wp_classes The post classes coming from WordPress.
3048
+ *
3049
  * @return array
3050
  */
3051
  function bp_get_the_post_class( $wp_classes = array() ) {
3087
  $bp_classes[] = "type-{$bp_class}";
3088
  }
3089
 
 
 
 
 
 
 
 
3090
  // okay let's merge!
3091
  return array_unique( array_merge( $bp_classes, $wp_classes ) );
3092
  }
3099
  * a later release. Do not use.
3100
  *
3101
  * @access private
3102
+ * @since 1.7.0
3103
  *
3104
  * @param array $a First item.
3105
  * @param array $b Second item.
3106
+ *
3107
  * @return int Returns an integer less than, equal to, or greater than zero if
3108
+ * the first argument is considered to be respectively less than,
3109
+ * equal to, or greater than the second.
3110
  */
3111
  function _bp_nav_menu_sort( $a, $b ) {
3112
  if ( $a['position'] == $b['position'] ) {
3121
  /**
3122
  * Get the items registered in the primary and secondary BuddyPress navigation menus.
3123
  *
3124
+ * @since 1.7.0
3125
  *
3126
  * @return array A multidimensional array of all navigation items.
3127
  */
3200
  /**
3201
  * Filters the items registered in the primary and secondary BuddyPress navigation menus.
3202
  *
3203
+ * @since 1.7.0
3204
  *
3205
  * @param array $menus Array of items registered in the primary and secondary BuddyPress navigation.
3206
  */
3210
  /**
3211
  * Display a navigation menu.
3212
  *
3213
+ * @since 1.7.0
3214
  *
3215
  * @param string|array $args {
3216
  * An array of optional arguments.
3217
+ *
3218
+ * @type string $after Text after the link text. Default: ''.
3219
+ * @type string $before Text before the link text. Default: ''.
3220
+ * @type string $container The name of the element to wrap the navigation
3221
+ * with. 'div' or 'nav'. Default: 'div'.
3222
  * @type string $container_class The class that is applied to the container.
3223
+ * Default: 'menu-bp-container'.
3224
+ * @type string $container_id The ID that is applied to the container.
3225
+ * Default: ''.
3226
+ * @type int $depth How many levels of the hierarchy are to be included.
3227
+ * 0 means all. Default: 0.
3228
+ * @type bool $echo True to echo the menu, false to return it.
3229
+ * Default: true.
3230
+ * @type bool $fallback_cb If the menu doesn't exist, should a callback
3231
+ * function be fired? Default: false (no fallback).
3232
+ * @type string $items_wrap How the list items should be wrapped. Should be
3233
+ * in the form of a printf()-friendly string, using numbered
3234
+ * placeholders. Default: '<ul id="%1$s" class="%2$s">%3$s</ul>'.
3235
+ * @type string $link_after Text after the link. Default: ''.
3236
+ * @type string $link_before Text before the link. Default: ''.
3237
+ * @type string $menu_class CSS class to use for the <ul> element which
3238
+ * forms the menu. Default: 'menu'.
3239
+ * @type string $menu_id The ID that is applied to the <ul> element which
3240
+ * forms the menu. Default: 'menu-bp', incremented.
3241
+ * @type string $walker Allows a custom walker class to be specified.
3242
+ * Default: 'BP_Walker_Nav_Menu'.
3243
  * }
3244
+ *
3245
  * @return string|null If $echo is false, returns a string containing the nav
3246
+ * menu markup.
3247
  */
3248
  function bp_nav_menu( $args = array() ) {
3249
  static $menu_id_slugs = array();
3269
  /**
3270
  * Filters the parsed bp_nav_menu arguments.
3271
  *
3272
+ * @since 1.7.0
3273
  *
3274
  * @param array $args Array of parsed arguments.
3275
  */
3294
  /**
3295
  * Filters the allowed tags for the wp_nav_menu_container.
3296
  *
3297
+ * @since 1.7.0
3298
  *
3299
  * @param array $value Array of allowed tags. Default 'div' and 'nav'.
3300
  */
3312
  /**
3313
  * Filters the BuddyPress menu objects.
3314
  *
3315
+ * @since 1.7.0
3316
  *
3317
  * @param array $value Array of nav menu objects.
3318
  * @param array $args Array of arguments for the menu.
3344
  *
3345
  * Allow plugins to hook into the menu to add their own <li>'s
3346
  *
3347
+ * @since 1.7.0
3348
  *
3349
  * @param array $items Array of nav menu items.
3350
  * @param array $args Array of arguments for the menu.
3364
  /**
3365
  * Filters the final BuddyPress menu output.
3366
  *
3367
+ * @since 1.7.0
3368
  *
3369
  * @param string $nav_menu Final nav menu output.
3370
  * @param array $args Array of arguments for the menu.
bp-core/bp-core-theme-compatibility.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * BuddyPress Core Theme Compatibility.
5
  *
@@ -7,7 +6,7 @@
7
  * @subpackage ThemeCompatibility
8
  */
9
 
10
- // Exit if accessed directly
11
  defined( 'ABSPATH' ) || exit;
12
 
13
  /** Theme Compat **************************************************************/
@@ -31,20 +30,20 @@ defined( 'ABSPATH' ) || exit;
31
  * for future Theme Packs to use. {@link BP_Legacy} is a good example of
32
  * extending this class.
33
  *
34
- * @since BuddyPress (1.7.0)
35
  *
36
  * @todo We should probably do something similar to BP_Component::start().
37
  * @todo If this is only intended to be extended, it should be abstract.
38
  *
39
  * @param array $properties {
40
  * An array of properties describing the theme compat package.
41
- * @type string $id ID of the package. Must be unique.
42
- * @type string $name Name of the theme. This should match the name given
43
- * in style.css.
44
  * @type string $version Theme version. Used for busting script and style
45
- * browser caches.
46
- * @type string $dir Filesystem path of the theme.
47
- * @type string $url Base URL of the theme.
48
  * }
49
  */
50
  class BP_Theme_Compat {
@@ -59,7 +58,9 @@ class BP_Theme_Compat {
59
  /**
60
  * Pass the $properties to the object on creation.
61
  *
62
- * @since BuddyPress (1.7.0)
 
 
63
  */
64
  public function __construct( Array $properties = array() ) {
65
  $this->_data = $properties;
@@ -70,7 +71,7 @@ class BP_Theme_Compat {
70
  *
71
  * Themes should use this method in their constructor.
72
  *
73
- * @since BuddyPress (1.7.0)
74
  */
75
  protected function start() {
76
  // Sanity check
@@ -89,7 +90,7 @@ class BP_Theme_Compat {
89
  * Meant to be overridden in your class. See
90
  * {@link BP_Legacy::setup_globals()} for an example.
91
  *
92
- * @since BuddyPress (1.7.0)
93
  */
94
  protected function setup_globals() {}
95
 
@@ -99,17 +100,18 @@ class BP_Theme_Compat {
99
  * Meant to be overridden in your class. See
100
  * {@link BP_Legacy::setup_actions()} for an example.
101
  *
102
- * @since BuddyPress (1.7.0)
103
  */
104
  protected function setup_actions() {}
105
 
106
  /**
107
  * Set a theme's property.
108
  *
109
- * @since BuddyPress (1.7.0)
110
  *
111
  * @param string $property Property name.
112
- * @param mixed $value Property value.
 
113
  * @return bool True on success, false on failure.
114
  */
115
  public function __set( $property, $value ) {
@@ -119,11 +121,12 @@ class BP_Theme_Compat {
119
  /**
120
  * Get a theme's property.
121
  *
122
- * @since BuddyPress (1.7.0)
123
  *
124
  * @param string $property Property name.
 
125
  * @return mixed The value of the property if it exists, otherwise an
126
- * empty string.
127
  */
128
  public function __get( $property ) {
129
  return array_key_exists( $property, $this->_data ) ? $this->_data[$property] : '';
@@ -135,7 +138,7 @@ class BP_Theme_Compat {
135
  /**
136
  * Set up the default theme compat theme.
137
  *
138
- * @since BuddyPress (1.7.0)
139
  *
140
  * @param string $theme Optional. The unique ID identifier of a theme package.
141
  */
@@ -157,7 +160,7 @@ function bp_setup_theme_compat( $theme = '' ) {
157
  * This can be filtered or set manually. Tricky theme authors can override the
158
  * default and include their own BuddyPress compatibility layers for their themes.
159
  *
160
- * @since BuddyPress (1.7.0)
161
  *
162
  * @uses apply_filters()
163
  *
@@ -168,7 +171,7 @@ function bp_get_theme_compat_id() {
168
  /**
169
  * Filters the ID of the theme package being used.
170
  *
171
- * @since BuddyPress (1.7.0)
172
  *
173
  * @param string $id ID of the theme package in use.
174
  */
@@ -181,7 +184,7 @@ function bp_get_theme_compat_id() {
181
  * This can be filtered or set manually. Tricky theme authors can override the
182
  * default and include their own BuddyPress compatibility layers for their themes.
183
  *
184
- * @since BuddyPress (1.7.0)
185
  *
186
  * @uses apply_filters()
187
  *
@@ -192,7 +195,7 @@ function bp_get_theme_compat_name() {
192
  /**
193
  * Filters the name of the theme package being used.
194
  *
195
- * @since BuddyPress (1.7.0)
196
  *
197
  * @param string $name Name of the theme package in use.
198
  */
@@ -205,7 +208,7 @@ function bp_get_theme_compat_name() {
205
  * This can be filtered or set manually. Tricky theme authors can override the
206
  * default and include their own BuddyPress compatibility layers for their themes.
207
  *
208
- * @since BuddyPress (1.7.0)
209
  *
210
  * @uses apply_filters()
211
  *
@@ -216,7 +219,7 @@ function bp_get_theme_compat_version() {
216
  /**
217
  * Filters the version of the theme package being used.
218
  *
219
- * @since BuddyPress (1.7.0)
220
  *
221
  * @param string $version The version string of the theme package in use.
222
  */
@@ -229,7 +232,7 @@ function bp_get_theme_compat_version() {
229
  * or set manually. Tricky theme authors can override the default and include
230
  * their own BuddyPress compatibility layers for their themes.
231
  *
232
- * @since BuddyPress (1.7.0)
233
  *
234
  * @uses apply_filters()
235
  *
@@ -240,7 +243,7 @@ function bp_get_theme_compat_dir() {
240
  /**
241
  * Filters the absolute path of the theme package being used.
242
  *
243
- * @since BuddyPress (1.7.0)
244
  *
245
  * @param string $dir The absolute path of the theme package in use.
246
  */
@@ -254,7 +257,7 @@ function bp_get_theme_compat_dir() {
254
  * the default and include their own BuddyPress compatibility layers for their
255
  * themes.
256
  *
257
- * @since BuddyPress (1.7.0)
258
  *
259
  * @uses apply_filters()
260
  *
@@ -265,7 +268,7 @@ function bp_get_theme_compat_url() {
265
  /**
266
  * Filters the URL of the theme package being used.
267
  *
268
- * @since BuddyPress (1.7.0)
269
  *
270
  * @param string $url URL of the theme package in use.
271
  */
@@ -278,7 +281,7 @@ function bp_get_theme_compat_url() {
278
  * If the current theme's need for theme compat hasn't yet been detected, we
279
  * do so using bp_detect_theme_compat_with_current_theme().
280
  *
281
- * @since BuddyPress (1.9.0)
282
  *
283
  * @uses bp_detect_theme_compat_with_current_theme()
284
  *
@@ -292,7 +295,7 @@ function bp_use_theme_compat_with_current_theme() {
292
  /**
293
  * Filters whether or not to use theme compat for the active theme.
294
  *
295
- * @since BuddyPress (1.9.0)
296
  *
297
  * @param bool $use_with_current_theme True if the current theme needs theme compatibility.
298
  */
@@ -311,7 +314,7 @@ function bp_use_theme_compat_with_current_theme() {
311
  * this category will have the members-loop.php template, and so use its
312
  * presence as an indicator that theme compatibility is not required
313
  *
314
- * @since BuddyPress (1.9.0)
315
  *
316
  * @return bool True if the current theme needs theme compatibility.
317
  */
@@ -349,7 +352,7 @@ function bp_detect_theme_compat_with_current_theme() {
349
  /**
350
  * Is the current page using theme compatibility?
351
  *
352
- * @since BuddyPress (1.7.0)
353
  *
354
  * @return bool True if the current page uses theme compatibility.
355
  */
@@ -366,9 +369,10 @@ function bp_is_theme_compat_active() {
366
  /**
367
  * Set the flag that tells whether the current page is using theme compatibility.
368
  *
369
- * @since BuddyPress (1.7.0)
370
  *
371
  * @param bool $set True to set the flag to true, false to set it to false.
 
372
  * @return bool Returns the value of $set.
373
  */
374
  function bp_set_theme_compat_active( $set = true ) {
@@ -383,9 +387,10 @@ function bp_set_theme_compat_active( $set = true ) {
383
  * Stash possible template files for the current query. Useful if plugins want
384
  * to override them, or see what files are being scanned for inclusion.
385
  *
386
- * @since BuddyPress (1.7.0)
387
  *
388
  * @param array $templates The template stack.
 
389
  * @return array The template stack (value of $templates).
390
  */
391
  function bp_set_theme_compat_templates( $templates = array() ) {
@@ -400,9 +405,10 @@ function bp_set_theme_compat_templates( $templates = array() ) {
400
  * Stash the template file for the current query. Useful if plugins want
401
  * to override it, or see what file is being included.
402
  *
403
- * @since BuddyPress (1.7.0)
404
  *
405
  * @param string $template The template currently in use.
 
406
  * @return string The template currently in use (value of $template).
407
  */
408
  function bp_set_theme_compat_template( $template = '' ) {
@@ -417,9 +423,10 @@ function bp_set_theme_compat_template( $template = '' ) {
417
  * Stash the original template file for the current query. Useful for checking
418
  * if BuddyPress was able to find a more appropriate template.
419
  *
420
- * @since BuddyPress (1.7.0)
421
  *
422
  * @param string $template The template originally selected by WP.
 
423
  * @return string The template originally selected by WP (value of $template).
424
  */
425
  function bp_set_theme_compat_original_template( $template = '' ) {
@@ -428,14 +435,175 @@ function bp_set_theme_compat_original_template( $template = '' ) {
428
  return buddypress()->theme_compat->original_template;
429
  }
430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
 
2
  /**
3
  * BuddyPress Core Theme Compatibility.
4
  *
6
  * @subpackage ThemeCompatibility
7
  */
8
 
9
+ // Exit if accessed directly.
10
  defined( 'ABSPATH' ) || exit;
11
 
12
  /** Theme Compat **************************************************************/
30
  * for future Theme Packs to use. {@link BP_Legacy} is a good example of
31
  * extending this class.
32
  *
33
+ * @since 1.7.0
34
  *
35
  * @todo We should probably do something similar to BP_Component::start().
36
  * @todo If this is only intended to be extended, it should be abstract.
37
  *
38
  * @param array $properties {
39
  * An array of properties describing the theme compat package.
40
+ * @type string $id ID of the package. Must be unique.
41
+ * @type string $name Name of the theme. This should match the name given
42
+ * in style.css.
43
  * @type string $version Theme version. Used for busting script and style
44
+ * browser caches.
45
+ * @type string $dir Filesystem path of the theme.
46
+ * @type string $url Base URL of the theme.
47
  * }
48
  */
49
  class BP_Theme_Compat {
58
  /**
59
  * Pass the $properties to the object on creation.
60
  *
61
+ * @since 1.7.0
62
+ *
63
+ * @param array $properties Array of properties for BP_Theme_Compat.
64
  */
65
  public function __construct( Array $properties = array() ) {
66
  $this->_data = $properties;
71
  *
72
  * Themes should use this method in their constructor.
73
  *
74
+ * @since 1.7.0
75
  */
76
  protected function start() {
77
  // Sanity check
90
  * Meant to be overridden in your class. See
91
  * {@link BP_Legacy::setup_globals()} for an example.
92
  *
93
+ * @since 1.7.0
94
  */
95
  protected function setup_globals() {}
96
 
100
  * Meant to be overridden in your class. See
101
  * {@link BP_Legacy::setup_actions()} for an example.
102
  *
103
+ * @since 1.7.0
104
  */
105
  protected function setup_actions() {}
106
 
107
  /**
108
  * Set a theme's property.
109
  *
110
+ * @since 1.7.0
111
  *
112
  * @param string $property Property name.
113
+ * @param mixed $value Property value.
114
+ *
115
  * @return bool True on success, false on failure.
116
  */
117
  public function __set( $property, $value ) {
121
  /**
122
  * Get a theme's property.
123
  *
124
+ * @since 1.7.0
125
  *
126
  * @param string $property Property name.
127
+ *
128
  * @return mixed The value of the property if it exists, otherwise an
129
+ * empty string.
130
  */
131
  public function __get( $property ) {
132
  return array_key_exists( $property, $this->_data ) ? $this->_data[$property] : '';
138
  /**
139
  * Set up the default theme compat theme.
140
  *
141
+ * @since 1.7.0
142
  *
143
  * @param string $theme Optional. The unique ID identifier of a theme package.
144
  */
160
  * This can be filtered or set manually. Tricky theme authors can override the
161
  * default and include their own BuddyPress compatibility layers for their themes.
162
  *
163
+ * @since 1.7.0
164
  *
165
  * @uses apply_filters()
166
  *
171
  /**
172
  * Filters the ID of the theme package being used.
173
  *
174
+ * @since 1.7.0
175
  *
176
  * @param string $id ID of the theme package in use.
177
  */
184
  * This can be filtered or set manually. Tricky theme authors can override the
185
  * default and include their own BuddyPress compatibility layers for their themes.
186
  *
187
+ * @since 1.7.0
188
  *
189
  * @uses apply_filters()
190
  *
195
  /**
196
  * Filters the name of the theme package being used.
197
  *
198
+ * @since 1.7.0
199
  *
200
  * @param string $name Name of the theme package in use.
201
  */
208
  * This can be filtered or set manually. Tricky theme authors can override the
209
  * default and include their own BuddyPress compatibility layers for their themes.
210
  *
211
+ * @since 1.7.0
212
  *
213
  * @uses apply_filters()
214
  *
219
  /**
220
  * Filters the version of the theme package being used.
221
  *
222
+ * @since 1.7.0
223
  *
224
  * @param string $version The version string of the theme package in use.
225
  */
232
  * or set manually. Tricky theme authors can override the default and include
233
  * their own BuddyPress compatibility layers for their themes.
234
  *
235
+ * @since 1.7.0
236
  *
237
  * @uses apply_filters()
238
  *
243
  /**
244
  * Filters the absolute path of the theme package being used.
245
  *
246
+ * @since 1.7.0
247
  *
248
  * @param string $dir The absolute path of the theme package in use.
249
  */
257
  * the default and include their own BuddyPress compatibility layers for their
258
  * themes.
259
  *
260
+ * @since 1.7.0
261
  *
262
  * @uses apply_filters()
263
  *
268
  /**
269
  * Filters the URL of the theme package being used.
270
  *
271
+ * @since 1.7.0
272
  *
273
  * @param string $url URL of the theme package in use.
274
  */
281
  * If the current theme's need for theme compat hasn't yet been detected, we
282
  * do so using bp_detect_theme_compat_with_current_theme().
283
  *
284
+ * @since 1.9.0
285
  *
286
  * @uses bp_detect_theme_compat_with_current_theme()
287
  *
295
  /**
296
  * Filters whether or not to use theme compat for the active theme.
297
  *
298
+ * @since 1.9.0
299
  *
300
  * @param bool $use_with_current_theme True if the current theme needs theme compatibility.
301
  */
314
  * this category will have the members-loop.php template, and so use its
315
  * presence as an indicator that theme compatibility is not required
316
  *
317
+ * @since 1.9.0
318
  *
319
  * @return bool True if the current theme needs theme compatibility.
320
  */
352
  /**
353
  * Is the current page using theme compatibility?
354
  *
355
+ * @since 1.7.0
356
  *
357
  * @return bool True if the current page uses theme compatibility.
358
  */
369
  /**
370
  * Set the flag that tells whether the current page is using theme compatibility.
371
  *
372
+ * @since 1.7.0
373
  *
374
  * @param bool $set True to set the flag to true, false to set it to false.
375
+ *
376
  * @return bool Returns the value of $set.
377
  */
378
  function bp_set_theme_compat_active( $set = true ) {
387
  * Stash possible template files for the current query. Useful if plugins want
388
  * to override them, or see what files are being scanned for inclusion.
389
  *
390
+ * @since 1.7.0
391
  *
392
  * @param array $templates The template stack.
393
+ *
394
  * @return array The template stack (value of $templates).
395
  */
396
  function bp_set_theme_compat_templates( $templates = array() ) {
405
  * Stash the template file for the current query. Useful if plugins want
406
  * to override it, or see what file is being included.
407
  *
408
+ * @since 1.7.0
409
  *
410
  * @param string $template The template currently in use.
411
+ *
412
  * @return string The template currently in use (value of $template).
413
  */
414
  function bp_set_theme_compat_template( $template = '' ) {
423
  * Stash the original template file for the current query. Useful for checking
424
  * if BuddyPress was able to find a more appropriate template.
425
  *
426
+ * @since 1.7.0
427
  *
428
  * @param string $template The template originally selected by WP.
429
+ *
430
  * @return string The template originally selected by WP (value of $template).
431
  */
432
  function bp_set_theme_compat_original_template( $template = '' ) {
435
  return buddypress()->theme_compat->original_template;
436
  }
437
 
438
+ /**
439
+ * Set a theme compat feature
440
+ *
441
+ * @since 2.4.0
442
+ *
443
+ * @param string $theme_id the theme id (eg: legacy)
444
+ * @param array $feature an associative array (eg: array( name => 'feature_name', 'settings' => array() ))
445
+ */
446
+ function bp_set_theme_compat_feature( $theme_id, $feature = array() ) {
447
+ if ( empty( $theme_id ) || empty( $feature['name'] ) ) {
448
+ return;
449
+ }
450
+
451
+ // Get BuddyPress instance
452
+ $bp = buddypress();
453
+
454
+ // Get current theme compat theme
455
+ $theme_compat_theme = $bp->theme_compat->theme;
456
+
457
+ // Bail if the Theme Compat theme is not in use
458
+ if ( $theme_id !== bp_get_theme_compat_id() ) {
459
+ return;
460
+ }
461
+
462
+ $features = $theme_compat_theme->__get( 'features' );
463
+ if ( empty( $features ) ) {
464
+ $features = array();
465
+ }
466
+
467
+ // Bail if the feature is already registered or no settings were provided
468
+ if ( isset( $features[ $feature['name'] ] ) || empty( $feature['settings'] ) ) {
469
+ return;
470
+ }
471
+
472
+ // Add the feature
473
+ $features[ $feature['name'] ] = (object) $feature['settings'];
474
+
475
+ // The feature is attached to components
476
+ if ( isset( $features[ $feature['name'] ]->components ) ) {
477
+ // Set the feature for each concerned component
478
+ foreach ( (array) $features[ $feature['name'] ]->components as $component ) {
479
+ // The xProfile component is specific
480
+ if ( 'xprofile' === $component ) {
481
+ $component = 'profile';
482
+ }
483
+
484
+ if ( isset( $bp->{$component} ) ) {
485
+ if ( isset( $bp->{$component}->features ) ) {
486
+ $bp->{$component}->features[] = $feature['name'];
487
+ } else {
488
+ $bp->{$component}->features = array( $feature['name'] );
489
+ }
490
+ }
491
+ }
492
+ }
493
+
494
+ // Finally update the theme compat features
495
+ $theme_compat_theme->__set( 'features', $features );
496
+ }
497
+
498
+ /**
499
+ * Get a theme compat feature
500
+ *
501
+ * @since 2.4.0
502
+ *
503
+ * @param string $feature the feature (eg: cover_image)
504
+ * @return object the feature settings.
505
+ */
506
+ function bp_get_theme_compat_feature( $feature = '' ) {
507
+ // Get current theme compat theme
508
+ $theme_compat_theme = buddypress()->theme_compat->theme;
509
+
510
+ // Get features
511
+ $features = $theme_compat_theme->__get( 'features' );
512
+
513
+ if ( ! isset( $features[ $feature ] ) ) {
514
+ return false;
515
+ }
516
+
517
+ return $features[ $feature ];
518
+ }
519
+
520
+ /**
521
+ * Setup the theme's features
522
+ *
523
+ * Note: BP Legacy's buddypress-functions.php is not loaded in WP Administration
524
+ * as it's loaded using bp_locate_template(). That's why this function is here.
525
+ *
526
+ * @since 2.4.0
527
+ *
528
+ * @global $content_width the content width of the theme
529
+ */
530
+ function bp_register_theme_compat_default_features() {
531
+ global $content_width;
532
+
533
+ // If the current theme doesn't need theme compat, bail at this point.
534
+ if ( ! bp_use_theme_compat_with_current_theme() ) {
535
+ return;
536
+ }
537
+
538
+ // Make sure BP Legacy is the Theme Compat in use.
539
+ if ( 'legacy' !== bp_get_theme_compat_id() ) {
540
+ return;
541
+ }
542
+