BuddyPress - Version 1.9-beta1

Version Description

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

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

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

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

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

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

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

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

= 1.6.3 = See: http://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: http://codex.buddypress.org/releases/version-1-6/

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

= 1.2.9 = Compatibility with WordPress 3.2

= 1.2.8 = Compatibility with WordPress 3.1

= 1.2.7 = Fixes over 10 bugs.

Download this release

Release Info

Developer boonebgorges
Plugin Icon 128x128 BuddyPress
Version 1.9-beta1
Comparing to
See all releases

Code changes from version 1.8.1 to 1.9-beta1

Files changed (81) hide show
  1. bp-activity/bp-activity-actions.php +35 -33
  2. bp-activity/bp-activity-admin.php +173 -114
  3. bp-activity/bp-activity-akismet.php +100 -56
  4. bp-activity/bp-activity-cache.php +10 -9
  5. bp-activity/bp-activity-classes.php +454 -62
  6. bp-activity/bp-activity-filters.php +35 -35
  7. bp-activity/bp-activity-functions.php +402 -261
  8. bp-activity/bp-activity-loader.php +45 -30
  9. bp-activity/bp-activity-notifications.php +13 -13
  10. bp-activity/bp-activity-screens.php +35 -35
  11. bp-activity/bp-activity-template.php +621 -354
  12. bp-blogs/bp-blogs-actions.php +3 -5
  13. bp-blogs/bp-blogs-activity.php +33 -20
  14. bp-blogs/bp-blogs-buddybar.php +7 -8
  15. bp-blogs/bp-blogs-cache.php +11 -12
  16. bp-blogs/bp-blogs-classes.php +197 -28
  17. bp-blogs/bp-blogs-filters.php +9 -7
  18. bp-blogs/bp-blogs-functions.php +272 -45
  19. bp-blogs/bp-blogs-loader.php +48 -33
  20. bp-blogs/bp-blogs-screens.php +41 -28
  21. bp-blogs/bp-blogs-template.php +435 -89
  22. bp-blogs/bp-blogs-widgets.php +26 -1
  23. bp-core/admin/bp-core-actions.php +11 -8
  24. bp-core/admin/bp-core-components.php +14 -2
  25. bp-core/admin/bp-core-functions.php +144 -21
  26. bp-core/admin/bp-core-schema.php +9 -2
  27. bp-core/bp-core-actions.php +11 -5
  28. bp-core/bp-core-admin.php +79 -46
  29. bp-core/bp-core-adminbar.php +16 -15
  30. bp-core/bp-core-avatars.php +202 -99
  31. bp-core/bp-core-buddybar.php +123 -44
  32. bp-core/bp-core-cache.php +31 -14
  33. bp-core/bp-core-caps.php +78 -71
  34. bp-core/bp-core-catchuri.php +102 -64
  35. bp-core/bp-core-classes.php +441 -236
  36. bp-core/bp-core-component.php +197 -65
  37. bp-core/bp-core-cssjs.php +19 -20
  38. bp-core/bp-core-dependency.php +171 -62
  39. bp-core/bp-core-filters.php +181 -80
  40. bp-core/bp-core-functions.php +602 -231
  41. bp-core/bp-core-loader.php +38 -27
  42. bp-core/bp-core-moderation.php +42 -34
  43. bp-core/bp-core-options.php +132 -105
  44. bp-core/bp-core-template-loader.php +86 -57
  45. bp-core/bp-core-template.php +826 -224
  46. bp-core/bp-core-theme-compatibility.php +264 -154
  47. bp-core/bp-core-update.php +104 -43
  48. bp-core/bp-core-widgets.php +205 -5
  49. bp-core/bp-core-wpabstraction.php +61 -23
  50. bp-core/deprecated/1.2.php +6 -0
  51. bp-forums/bp-forums-actions.php +7 -0
  52. bp-forums/bp-forums-bbpress-sa.php +83 -12
  53. bp-forums/bp-forums-filters.php +67 -37
  54. bp-forums/bp-forums-functions.php +299 -49
  55. bp-forums/bp-forums-loader.php +43 -13
  56. bp-forums/bp-forums-screens.php +33 -13
  57. bp-forums/bp-forums-template.php +1029 -74
  58. bp-friends/bp-friends-actions.php +9 -3
  59. bp-friends/bp-friends-activity.php +44 -8
  60. bp-friends/bp-friends-cache.php +13 -5
  61. bp-friends/bp-friends-classes.php +291 -46
  62. bp-friends/bp-friends-filters.php +8 -6
  63. bp-friends/bp-friends-functions.php +232 -7
  64. bp-friends/bp-friends-loader.php +52 -31
  65. bp-friends/bp-friends-notifications.php +20 -0
  66. bp-friends/bp-friends-screens.php +16 -7
  67. bp-friends/bp-friends-template.php +148 -38
  68. bp-friends/bp-friends-widgets.php +251 -0
  69. bp-friends/js/widget-friends.js +49 -0
  70. bp-friends/js/widget-friends.min.js +1 -0
  71. bp-groups/bp-groups-actions.php +47 -22
  72. bp-groups/bp-groups-activity.php +29 -0
  73. bp-groups/bp-groups-admin.php +168 -107
  74. bp-groups/bp-groups-adminbar.php +6 -7
  75. bp-groups/bp-groups-classes.php +135 -93
  76. bp-groups/bp-groups-functions.php +20 -13
  77. bp-groups/bp-groups-loader.php +25 -31
  78. bp-groups/bp-groups-screens.php +37 -16
  79. bp-groups/bp-groups-template.php +63 -35
  80. bp-groups/bp-groups-widgets.php +11 -6
  81. bp-languages/buddypress.pot +621 -523
bp-activity/bp-activity-actions.php CHANGED
@@ -13,7 +13,7 @@
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
- * Allow core components and dependent plugins to register activity actions
17
  *
18
  * @since BuddyPress (1.2)
19
  *
@@ -25,7 +25,7 @@ function bp_register_activity_actions() {
25
  add_action( 'bp_init', 'bp_register_activity_actions', 8 );
26
 
27
  /**
28
- * Allow core components and dependent plugins to register activity actions
29
  *
30
  * @since BuddyPress (1.2)
31
  *
@@ -38,11 +38,11 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
38
  * @uses bp_core_get_user_domain()
39
  * @uses groups_get_group()
40
  * @uses bp_get_group_permalink()
41
- * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook
42
  * @uses bp_core_redirect()
43
  * @uses bp_get_root_domain()
44
  *
45
- * @return bool False on failure
46
  */
47
  function bp_activity_action_permalink_router() {
48
 
@@ -124,7 +124,7 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
124
  * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
125
  * @uses bp_core_redirect()
126
  *
127
- * @return bool False on failure
128
  */
129
  function bp_activity_action_delete_activity( $activity_id = 0 ) {
130
 
@@ -169,12 +169,13 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
169
  add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
170
 
171
  /**
172
- * Mark specific activity item as spam and redirect to previous page
 
 
173
  *
174
  * @global object $bp BuddyPress global settings
175
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
176
- * @return bool False on failure
177
- * @since BuddyPress (1.6)
178
  */
179
  function bp_activity_action_spam_activity( $activity_id = 0 ) {
180
  global $bp;
@@ -241,7 +242,7 @@ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
241
  * @uses bp_core_redirect()
242
  * @uses apply_filters() To call 'bp_activity_custom_update' hook.
243
  *
244
- * @return bool False on failure
245
  */
246
  function bp_activity_action_post_update() {
247
 
@@ -253,9 +254,15 @@ function bp_activity_action_post_update() {
253
  check_admin_referer( 'post_update', '_wpnonce_post_update' );
254
 
255
  // Get activity info
256
- $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
257
- $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
258
- $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
 
 
 
 
 
 
259
 
260
  // No activity content so provide feedback and redirect
261
  if ( empty( $content ) ) {
@@ -305,7 +312,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
305
  * @uses bp_activity_new_comment()
306
  * @uses wp_get_referer()
307
  *
308
- * @return bool False on failure
309
  */
310
  function bp_activity_action_post_comment() {
311
 
@@ -353,7 +360,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
353
  * @uses bp_core_redirect()
354
  * @uses wp_get_referer()
355
  *
356
- * @return bool False on failure
357
  */
358
  function bp_activity_action_mark_favorite() {
359
 
@@ -387,7 +394,7 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
387
  * @uses bp_core_redirect()
388
  * @uses wp_get_referer()
389
  *
390
- * @return bool False on failure
391
  */
392
  function bp_activity_action_remove_favorite() {
393
 
@@ -407,18 +414,17 @@ function bp_activity_action_remove_favorite() {
407
  add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
408
 
409
  /**
410
- * Load the sitewide feed.
411
  *
412
  * @since BuddyPress (1.0)
413
  *
414
  * @global object $bp BuddyPress global settings
415
- * @global object $wp_query
416
  * @uses bp_is_activity_component()
417
  * @uses bp_is_current_action()
418
  * @uses bp_is_user()
419
  * @uses status_header()
420
  *
421
- * @return bool False on failure
422
  */
423
  function bp_activity_action_sitewide_feed() {
424
  global $bp;
@@ -441,16 +447,15 @@ function bp_activity_action_sitewide_feed() {
441
  add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
442
 
443
  /**
444
- * Load a user's personal feed.
445
  *
446
  * @since BuddyPress (1.0)
447
  *
448
- * @global object $wp_query
449
  * @uses bp_is_user_activity()
450
  * @uses bp_is_current_action()
451
  * @uses status_header()
452
  *
453
- * @return bool False on failure
454
  */
455
  function bp_activity_action_personal_feed() {
456
  if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) {
@@ -472,11 +477,10 @@ function bp_activity_action_personal_feed() {
472
  add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
473
 
474
  /**
475
- * Load a user's friends feed.
476
  *
477
  * @since BuddyPress (1.0)
478
  *
479
- * @global object $wp_query
480
  * @uses bp_is_active()
481
  * @uses bp_is_user_activity()
482
  * @uses bp_is_current_action()
@@ -484,7 +488,7 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
484
  * @uses bp_is_action_variable()
485
  * @uses status_header()
486
  *
487
- * @return bool False on failure
488
  */
489
  function bp_activity_action_friends_feed() {
490
  if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
@@ -506,11 +510,10 @@ function bp_activity_action_friends_feed() {
506
  add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
507
 
508
  /**
509
- * Load a user's my groups feed.
510
  *
511
  * @since BuddyPress (1.2)
512
  *
513
- * @global object $wp_query
514
  * @uses bp_is_active()
515
  * @uses bp_is_user_activity()
516
  * @uses bp_is_current_action()
@@ -518,7 +521,7 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
518
  * @uses bp_is_action_variable()
519
  * @uses status_header()
520
  *
521
- * @return bool False on failure
522
  */
523
  function bp_activity_action_my_groups_feed() {
524
  if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
@@ -552,13 +555,12 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
552
  *
553
  * @since BuddyPress (1.2)
554
  *
555
- * @global object $wp_query
556
  * @uses bp_is_user_activity()
557
  * @uses bp_is_current_action()
558
  * @uses bp_is_action_variable()
559
  * @uses status_header()
560
  *
561
- * @return bool False on failure
562
  */
563
  function bp_activity_action_mentions_feed() {
564
  if ( ! bp_activity_do_mentions() ) {
@@ -590,13 +592,12 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
590
  *
591
  * @since BuddyPress (1.2)
592
  *
593
- * @global object $wp_query
594
  * @uses bp_is_user_activity()
595
  * @uses bp_is_current_action()
596
  * @uses bp_is_action_variable()
597
  * @uses status_header()
598
  *
599
- * @return bool False on failure
600
  */
601
  function bp_activity_action_favorites_feed() {
602
  if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
@@ -622,10 +623,11 @@ function bp_activity_action_favorites_feed() {
622
  add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
623
 
624
  /**
625
- * Loads Akismet
626
  *
627
- * @global object $bp BuddyPress global settings
628
  * @since BuddyPress (1.6)
 
 
629
  */
630
  function bp_activity_setup_akismet() {
631
  global $bp;
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
+ * Allow core components and dependent plugins to register activity actions.
17
  *
18
  * @since BuddyPress (1.2)
19
  *
25
  add_action( 'bp_init', 'bp_register_activity_actions', 8 );
26
 
27
  /**
28
+ * Catch and route requests for single activity item permalinks.
29
  *
30
  * @since BuddyPress (1.2)
31
  *
38
  * @uses bp_core_get_user_domain()
39
  * @uses groups_get_group()
40
  * @uses bp_get_group_permalink()
41
+ * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook.
42
  * @uses bp_core_redirect()
43
  * @uses bp_get_root_domain()
44
  *
45
+ * @return bool False on failure.
46
  */
47
  function bp_activity_action_permalink_router() {
48
 
124
  * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
125
  * @uses bp_core_redirect()
126
  *
127
+ * @return bool False on failure.
128
  */
129
  function bp_activity_action_delete_activity( $activity_id = 0 ) {
130
 
169
  add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
170
 
171
  /**
172
+ * Mark specific activity item as spam and redirect to previous page.
173
+ *
174
+ * @since BuddyPress (1.6)
175
  *
176
  * @global object $bp BuddyPress global settings
177
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
178
+ * @return bool False on failure.
 
179
  */
180
  function bp_activity_action_spam_activity( $activity_id = 0 ) {
181
  global $bp;
242
  * @uses bp_core_redirect()
243
  * @uses apply_filters() To call 'bp_activity_custom_update' hook.
244
  *
245
+ * @return bool False on failure.
246
  */
247
  function bp_activity_action_post_update() {
248
 
254
  check_admin_referer( 'post_update', '_wpnonce_post_update' );
255
 
256
  // Get activity info
257
+ $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
258
+
259
+ if ( ! empty( $_POST['whats-new-post-object'] ) ) {
260
+ $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
261
+ }
262
+
263
+ if ( ! empty( $_POST['whats-new-post-in'] ) ) {
264
+ $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
265
+ }
266
 
267
  // No activity content so provide feedback and redirect
268
  if ( empty( $content ) ) {
312
  * @uses bp_activity_new_comment()
313
  * @uses wp_get_referer()
314
  *
315
+ * @return bool False on failure.
316
  */
317
  function bp_activity_action_post_comment() {
318
 
360
  * @uses bp_core_redirect()
361
  * @uses wp_get_referer()
362
  *
363
+ * @return bool False on failure.
364
  */
365
  function bp_activity_action_mark_favorite() {
366
 
394
  * @uses bp_core_redirect()
395
  * @uses wp_get_referer()
396
  *
397
+ * @return bool False on failure.
398
  */
399
  function bp_activity_action_remove_favorite() {
400
 
414
  add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
415
 
416
  /**
417
+ * Load the sitewide activity feed.
418
  *
419
  * @since BuddyPress (1.0)
420
  *
421
  * @global object $bp BuddyPress global settings
 
422
  * @uses bp_is_activity_component()
423
  * @uses bp_is_current_action()
424
  * @uses bp_is_user()
425
  * @uses status_header()
426
  *
427
+ * @return bool False on failure.
428
  */
429
  function bp_activity_action_sitewide_feed() {
430
  global $bp;
447
  add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
448
 
449
  /**
450
+ * Load a user's personal activity feed.
451
  *
452
  * @since BuddyPress (1.0)
453
  *
 
454
  * @uses bp_is_user_activity()
455
  * @uses bp_is_current_action()
456
  * @uses status_header()
457
  *
458
+ * @return bool False on failure.
459
  */
460
  function bp_activity_action_personal_feed() {
461
  if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) {
477
  add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
478
 
479
  /**
480
+ * Load a user's friends' activity feed.
481
  *
482
  * @since BuddyPress (1.0)
483
  *
 
484
  * @uses bp_is_active()
485
  * @uses bp_is_user_activity()
486
  * @uses bp_is_current_action()
488
  * @uses bp_is_action_variable()
489
  * @uses status_header()
490
  *
491
+ * @return bool False on failure.
492
  */
493
  function bp_activity_action_friends_feed() {
494
  if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
510
  add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
511
 
512
  /**
513
+ * Load the activity feed for a user's groups.
514
  *
515
  * @since BuddyPress (1.2)
516
  *
 
517
  * @uses bp_is_active()
518
  * @uses bp_is_user_activity()
519
  * @uses bp_is_current_action()
521
  * @uses bp_is_action_variable()
522
  * @uses status_header()
523
  *
524
+ * @return bool False on failure.
525
  */
526
  function bp_activity_action_my_groups_feed() {
527
  if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
555
  *
556
  * @since BuddyPress (1.2)
557
  *
 
558
  * @uses bp_is_user_activity()
559
  * @uses bp_is_current_action()
560
  * @uses bp_is_action_variable()
561
  * @uses status_header()
562
  *
563
+ * @return bool False on failure.
564
  */
565
  function bp_activity_action_mentions_feed() {
566
  if ( ! bp_activity_do_mentions() ) {
592
  *
593
  * @since BuddyPress (1.2)
594
  *
 
595
  * @uses bp_is_user_activity()
596
  * @uses bp_is_current_action()
597
  * @uses bp_is_action_variable()
598
  * @uses status_header()
599
  *
600
+ * @return bool False on failure.
601
  */
602
  function bp_activity_action_favorites_feed() {
603
  if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
623
  add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
624
 
625
  /**
626
+ * Loads Akismet filtering for activity.
627
  *
 
628
  * @since BuddyPress (1.6)
629
+ *
630
+ * @global object $bp BuddyPress global settings
631
  */
632
  function bp_activity_setup_akismet() {
633
  global $bp;
bp-activity/bp-activity-admin.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * BuddyPress Activity component admin screen
4
  *
5
- * Props to WordPress core for the Comments admin screen, and its contextual help text,
6
- * on which this implementation is heavily based.
7
  *
8
  * @package BuddyPress
9
- * @since BuddyPress (1.6)
10
  * @subpackage Activity
11
  */
12
 
@@ -21,20 +21,17 @@ if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['p
21
  add_filter( 'set-screen-option', 'bp_activity_admin_screen_options', 10, 3 );
22
 
23
  /**
24
- * Registers the Activity component admin screen
25
  *
26
  * @since BuddyPress (1.6)
27
  */
28
  function bp_activity_add_admin_menu() {
29
 
30
- if ( ! bp_current_user_can( 'bp_moderate' ) )
31
- return;
32
-
33
  // Add our screen
34
  $hook = add_menu_page(
35
  __( 'Activity', 'buddypress' ),
36
  __( 'Activity', 'buddypress' ),
37
- 'manage_options',
38
  'bp-activity',
39
  'bp_activity_admin',
40
  'div'
@@ -46,12 +43,16 @@ function bp_activity_add_admin_menu() {
46
  add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
47
 
48
  /**
49
- * Add activity component to custom menus array
50
  *
51
- * @since BuddyPress (1.7)
 
 
52
  *
53
- * @param array $custom_menus
54
- * @return array
 
 
55
  */
56
  function bp_activity_admin_menu_order( $custom_menus = array() ) {
57
  array_push( $custom_menus, 'bp-activity' );
@@ -60,10 +61,12 @@ function bp_activity_admin_menu_order( $custom_menus = array() ) {
60
  add_filter( 'bp_admin_menu_order', 'bp_activity_admin_menu_order' );
61
 
62
  /**
63
- * AJAX receiver for Activity replies via the admin screen. Adds a new activity
64
- * comment, and returns HTML for a new table row.
65
  *
66
- * @since BuddyPress (1.6)
 
 
 
67
  */
68
  function bp_activity_admin_reply() {
69
  // Check nonce
@@ -91,7 +94,7 @@ function bp_activity_admin_reply() {
91
 
92
  // @todo: Check if user is allowed to create new activity items
93
  // if ( ! current_user_can( 'bp_new_activity' ) )
94
- if ( ! is_super_admin() )
95
  die( '-1' );
96
 
97
  // Add new activity comment
@@ -131,13 +134,15 @@ function bp_activity_admin_reply() {
131
  add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
132
 
133
  /**
134
- * Handle save/update of screen options for the Activity component admin screen
 
 
135
  *
136
- * @param string $value Will always be false unless another plugin filters it first.
137
- * @param string $option Screen option name
138
- * @param string $new_value Screen option form value
 
139
  * @return string Option value. False to abandon update.
140
- * @since BuddyPress (1.6)
141
  */
142
  function bp_activity_admin_screen_options( $value, $option, $new_value ) {
143
  if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option )
@@ -152,11 +157,12 @@ function bp_activity_admin_screen_options( $value, $option, $new_value ) {
152
  }
153
 
154
  /**
155
- * Hide the advanced edit meta boxes by default, so we don't clutter the scren.
 
 
156
  *
157
- * @param WP_Screen $screen Screen identifier
158
- * @return array Hidden Meta Boxes
159
- * @since BuddyPress (1.0)
160
  */
161
  function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
162
  if ( empty( $screen->id ) || 'toplevel_page_bp-activity' != $screen->id && 'toplevel_page_bp-activity_network' != $screen->id )
@@ -170,11 +176,17 @@ function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
170
  add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
171
 
172
  /**
173
- * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page.
174
  *
175
- * @global object $bp BuddyPress global settings
176
- * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
177
- * @since BuddyPress (1.6)
 
 
 
 
 
 
178
  */
179
  function bp_activity_admin_load() {
180
  global $bp, $bp_activity_list_table;
@@ -206,7 +218,7 @@ function bp_activity_admin_load() {
206
  'title' => __( 'Item, Link, Type', 'buddypress' ),
207
  'content' =>
208
  '<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' .
209
- '<p>' . __( '<strong>Link</strong> - Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set.', 'buddypress' ) . '</p>' .
210
  '<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' .
211
  '<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>'
212
  ) );
@@ -521,9 +533,9 @@ function bp_activity_admin_load() {
521
  }
522
 
523
  /**
524
- * Outputs the Activity component admin screens
525
  *
526
- * @since BuddyPress (1.6)
527
  */
528
  function bp_activity_admin() {
529
  // Decide whether to load the index or edit screen
@@ -539,10 +551,9 @@ function bp_activity_admin() {
539
  }
540
 
541
  /**
542
- * Display the single activity edit screen
543
  *
544
- * @global int $screen_layout_columns Number of columns shown on this admin page
545
- * @since BuddyPress (1.6)
546
  */
547
  function bp_activity_admin_edit() {
548
 
@@ -631,10 +642,11 @@ function bp_activity_admin_edit() {
631
  }
632
 
633
  /**
634
- * Status metabox for the Activity admin edit screen
635
  *
636
- * @param object $item Activity item
637
- * @since BuddyPress (1.6)
 
638
  */
639
  function bp_activity_admin_edit_metabox_status( $item ) {
640
  ?>
@@ -686,26 +698,28 @@ function bp_activity_admin_edit_metabox_status( $item ) {
686
  }
687
 
688
  /**
689
- * Primary link metabox for the Activity admin edit screen
690
  *
691
- * @param object $item Activity item
692
- * @since BuddyPress (1.6)
 
693
  */
694
  function bp_activity_admin_edit_metabox_link( $item ) {
695
  ?>
696
 
697
  <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label>
698
  <input type="url" name="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" />
699
- <p><?php _e( 'Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
700
 
701
  <?php
702
  }
703
 
704
  /**
705
- * User ID metabox for the Activity admin edit screen
706
  *
707
- * @param object $item Activity item
708
- * @since BuddyPress (1.6)
 
709
  */
710
  function bp_activity_admin_edit_metabox_userid( $item ) {
711
  ?>
@@ -719,9 +733,11 @@ function bp_activity_admin_edit_metabox_userid( $item ) {
719
  /**
720
  * Activity type metabox for the Activity admin edit screen
721
  *
722
- * @global object $bp BuddyPress global settings
723
- * @param object $item Activity item
724
- * @since BuddyPress (1.6)
 
 
725
  */
726
  function bp_activity_admin_edit_metabox_type( $item ) {
727
  global $bp;
@@ -753,10 +769,11 @@ function bp_activity_admin_edit_metabox_type( $item ) {
753
  }
754
 
755
  /**
756
- * Primary item ID/Secondary item ID metabox for the Activity admin edit screen
757
  *
758
- * @param object $item Activity item
759
- * @since BuddyPress (1.6)
 
760
  */
761
  function bp_activity_admin_edit_metabox_itemids( $item ) {
762
  ?>
@@ -776,9 +793,11 @@ function bp_activity_admin_edit_metabox_itemids( $item ) {
776
  /**
777
  * Display the Activity admin index screen, which contains a list of all the activities.
778
  *
779
- * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
780
- * @global string $plugin_page
781
- * @since BuddyPress (1.6)
 
 
782
  */
783
  function bp_activity_admin_index() {
784
  global $bp_activity_list_table, $plugin_page;
@@ -908,30 +927,35 @@ function bp_activity_admin_index() {
908
  class BP_Activity_List_Table extends WP_List_Table {
909
 
910
  /**
911
- * What type of view is being displayed? e.g. "All", "Pending", "Approved", "Spam"...
912
  *
913
- * @since BuddyPress (1.6)
914
- */
 
 
 
915
  public $view = 'all';
916
 
917
  /**
918
  * How many activity items have been marked as spam.
919
  *
920
- * @since BuddyPress (1.6)
 
921
  */
922
  public $spam_count = 0;
923
 
924
  /**
925
  * Store activity-to-user-ID mappings for use in the In Response To column.
926
  *
927
- * @since BuddyPress (1.6)
 
928
  */
929
  protected $activity_user_id = array();
930
 
931
  /**
932
- * Constructor
933
  *
934
- * @since BuddyPress (1.6)
935
  */
936
  public function __construct() {
937
 
@@ -940,16 +964,16 @@ class BP_Activity_List_Table extends WP_List_Table {
940
  'ajax' => false,
941
  'plural' => 'activities',
942
  'singular' => 'activity',
 
943
  ) );
944
  }
945
 
946
  /**
947
- * Handle filtering of data, sorting, pagination, and any other data-manipulation required prior to rendering.
948
  *
949
- * @since BuddyPress (1.6)
950
  */
951
  function prepare_items() {
952
- $screen = get_current_screen();
953
 
954
  // Option defaults
955
  $filter = array();
@@ -962,7 +986,7 @@ class BP_Activity_List_Table extends WP_List_Table {
962
  $page = $this->get_pagenum();
963
 
964
  // Set per page from the screen options
965
- $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$screen->id}_per_page" ) );
966
 
967
  // Check if we're on the "Spam" view
968
  if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
@@ -1045,10 +1069,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1045
  }
1046
 
1047
  /**
1048
- * Get an array of all the columns on the page
1049
  *
1050
- * @return array
1051
- * @since BuddyPress (1.6)
 
1052
  */
1053
  function get_column_info() {
1054
  $this->_column_headers = array(
@@ -1061,18 +1086,18 @@ class BP_Activity_List_Table extends WP_List_Table {
1061
  }
1062
 
1063
  /**
1064
- * Displays a message on screen when no items are found (e.g. no search matches)
1065
  *
1066
- * @since BuddyPress (1.6)
1067
  */
1068
  function no_items() {
1069
  _e( 'No activities found.', 'buddypress' );
1070
  }
1071
 
1072
  /**
1073
- * Outputs the Activity data table
1074
  *
1075
- * @since BuddyPress (1.6)
1076
  */
1077
  function display() {
1078
  extract( $this->_args );
@@ -1102,29 +1127,38 @@ class BP_Activity_List_Table extends WP_List_Table {
1102
  }
1103
 
1104
  /**
1105
- * Generates content for a single row of the table
 
 
1106
  *
1107
- * @param object $item The current item
1108
- * @since BuddyPress (1.6)
1109
  */
1110
  function single_row( $item ) {
1111
- static $row_class = '';
 
 
 
 
 
 
1112
 
1113
- if ( empty( $row_class ) ) {
1114
- $row_class = ' class="alternate"';
1115
  } else {
1116
- $row_class = '';
1117
  }
1118
 
1119
- echo '<tr' . $row_class . ' id="activity-' . esc_attr( $item['id'] ) . '" data-parent_id="' . esc_attr( $item['id'] ) . '" data-root_id="' . esc_attr( $item['item_id'] ) . '">';
1120
  echo $this->single_row_columns( $item );
1121
  echo '</tr>';
 
 
1122
  }
1123
 
1124
  /**
1125
  * Get the list of views available on this table (e.g. "all", "spam").
1126
  *
1127
- * @since BuddyPress (1.6)
1128
  */
1129
  function get_views() {
1130
  $url_base = bp_get_admin_url( 'admin.php?page=bp-activity' ); ?>
@@ -1138,11 +1172,12 @@ class BP_Activity_List_Table extends WP_List_Table {
1138
  <?php
1139
  }
1140
 
1141
- /**
1142
- * Get bulk actions
 
 
1143
  *
1144
- * @return array Key/value pairs for the bulk actions dropdown
1145
- * @since BuddyPress (1.6)
1146
  */
1147
  function get_bulk_actions() {
1148
  $actions = array();
@@ -1156,9 +1191,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1156
  /**
1157
  * Get the table column titles.
1158
  *
 
 
1159
  * @see WP_List_Table::single_row_columns()
1160
- * @return array
1161
- * @since BuddyPress (1.6)
1162
  */
1163
  function get_columns() {
1164
  return array(
@@ -1170,11 +1207,15 @@ class BP_Activity_List_Table extends WP_List_Table {
1170
  }
1171
 
1172
  /**
1173
- * Get the column names for sortable columns
 
 
1174
  *
1175
- * @return array
1176
- * @since BuddyPress (1.6)
1177
- * @todo For this to work, BP_Activity_Activity::get() needs updating to supporting ordering by specific fields
 
 
1178
  */
1179
  function get_sortable_columns() {
1180
  return array();
@@ -1185,10 +1226,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1185
  }
1186
 
1187
  /**
1188
- * Markup for the "filter" part of the form (i.e. which activity type to display)
 
 
1189
  *
1190
- * @param string $which 'top' or 'bottom'
1191
- * @since BuddyPress (1.6)
1192
  */
1193
  function extra_tablenav( $which ) {
1194
  if ( 'bottom' == $which )
@@ -1217,22 +1259,26 @@ class BP_Activity_List_Table extends WP_List_Table {
1217
  }
1218
 
1219
  /**
1220
- * Checkbox column
 
 
1221
  *
1222
- * @param array $item A singular item (one full row)
1223
  * @see WP_List_Table::single_row_columns()
1224
- * @since BuddyPress (1.6)
 
1225
  */
1226
  function column_cb( $item ) {
1227
  printf( '<label class="screen-reader-text" for="aid-%1$d">' . __( 'Select activity item %1$d', 'buddypress' ) . '</label><input type="checkbox" name="aid[]" value="%1$d" id="aid-%1$d" />', $item['id'] );
1228
  }
1229
 
1230
  /**
1231
- * Author column
 
 
1232
  *
1233
- * @param array $item A singular item (one full row)
1234
  * @see WP_List_Table::single_row_columns()
1235
- * @since BuddyPress (1.6)
 
1236
  */
1237
  function column_author( $item ) {
1238
  echo '<strong>' . get_avatar( $item['user_id'], '32' ) . ' ' . bp_core_get_userlink( $item['user_id'] ) . '</strong>';
@@ -1243,9 +1289,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1243
  *
1244
  * Called "comment" in the CSS so we can re-use some WP core CSS.
1245
  *
1246
- * @param array $item A singular item (one full row)
 
1247
  * @see WP_List_Table::single_row_columns()
1248
- * @since BuddyPress (1.6)
 
1249
  */
1250
  function column_comment( $item ) {
1251
  // Determine what type of item (row) we're dealing with
@@ -1297,7 +1345,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1297
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1298
 
1299
  /* translators: 2: activity admin ui date/time */
1300
- printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>', 'buddypress' ), bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $item['id'] . '/', get_date_from_gmt( $item['date_recorded'], get_option( 'date_format' ) ), get_date_from_gmt( $item['date_recorded'], get_option( 'time_format' ) ) );
1301
 
1302
  // End timestamp
1303
  echo '</div>';
@@ -1313,11 +1361,13 @@ class BP_Activity_List_Table extends WP_List_Table {
1313
  }
1314
 
1315
  /**
1316
- * "In response to" column
 
 
1317
  *
1318
- * @param array $item A singular item (one full row)
1319
  * @see WP_List_Table::single_row_columns()
1320
- * @since BuddyPress (1.6)
 
1321
  */
1322
  function column_response( $item ) {
1323
  // Is $item is a root activity?
@@ -1342,10 +1392,15 @@ class BP_Activity_List_Table extends WP_List_Table {
1342
  }
1343
 
1344
  /**
1345
- * A wrapper function for the BP_Activity_List_Table to get the specified activity's user ID.
 
 
 
1346
  *
1347
- * @param int $activity_id Activity ID to retrieve User ID for
1348
- * @since BuddyPress (1.6)
 
 
1349
  */
1350
  protected function get_activity_user_id( $activity_id ) {
1351
  // If there is an existing activity/user ID mapping, just return the user ID.
@@ -1375,11 +1430,15 @@ class BP_Activity_List_Table extends WP_List_Table {
1375
  }
1376
 
1377
  /**
1378
- * Helper function to flatten all activites returned from bp_activity_get() into a single array.
 
 
 
 
 
1379
  *
1380
- * @param array $tree Source array
1381
- * @return array Flattened array
1382
- * @since BuddyPress (1.6)
1383
  */
1384
  public static function flatten_activity_array( $tree ){
1385
  foreach ( (array) $tree as $node ) {
1
  <?php
2
  /**
3
+ * BuddyPress Activity component admin screen.
4
  *
5
+ * Props to WordPress core for the Comments admin screen, and its contextual
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
 
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
  __( 'Activity', 'buddypress' ),
33
  __( 'Activity', 'buddypress' ),
34
+ 'bp_moderate',
35
  'bp-activity',
36
  'bp_activity_admin',
37
  'div'
43
  add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
44
 
45
  /**
46
+ * Add activity component to custom menus array.
47
  *
48
+ * Several BuddyPress components have top-level menu items in the Dashboard,
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
+ * @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() ) {
58
  array_push( $custom_menus, 'bp-activity' );
61
  add_filter( 'bp_admin_menu_order', 'bp_activity_admin_menu_order' );
62
 
63
  /**
64
+ * AJAX receiver for Activity replies via the admin screen.
 
65
  *
66
+ * Processes requests to add new activity comments, and echoes HTML for a new
67
+ * table row.
68
+ *
69
+ * @since BuddyPress (1.6.0)
70
  */
71
  function bp_activity_admin_reply() {
72
  // Check nonce
94
 
95
  // @todo: Check if user is allowed to create new activity items
96
  // if ( ! current_user_can( 'bp_new_activity' ) )
97
+ if ( ! current_user_can( 'bp_moderate' ) )
98
  die( '-1' );
99
 
100
  // Add new activity comment
134
  add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
135
 
136
  /**
137
+ * Handle save/update of screen options for the Activity component admin screen.
138
+ *
139
+ * @since BuddyPress (1.6.0)
140
  *
141
+ * @param string $value Will always be false unless another plugin filters it
142
+ * first.
143
+ * @param string $option Screen option name.
144
+ * @param string $new_value Screen option form value.
145
  * @return string Option value. False to abandon update.
 
146
  */
147
  function bp_activity_admin_screen_options( $value, $option, $new_value ) {
148
  if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option )
157
  }
158
 
159
  /**
160
+ * Hide the advanced edit meta boxes by default, so we don't clutter the screen.
161
+ *
162
+ * @since BuddyPress (1.6.0)
163
  *
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 )
176
  add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
177
 
178
  /**
179
+ * Set up the Activity admin page.
180
  *
181
+ * Does the following:
182
+ * - Register contextual help and screen options for this admin page.
183
+ * - Enqueues scripts and styles
184
+ * - Catches POST and GET requests related to Activity
185
+ *
186
+ * @since BuddyPress (1.6.0)
187
+ *
188
+ * @global object $bp BuddyPress global settings.
189
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
190
  */
191
  function bp_activity_admin_load() {
192
  global $bp, $bp_activity_list_table;
218
  'title' => __( 'Item, Link, Type', 'buddypress' ),
219
  'content' =>
220
  '<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' .
221
+ '<p>' . __( '<strong>Link</strong> - Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set.', 'buddypress' ) . '</p>' .
222
  '<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' .
223
  '<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>'
224
  ) );
533
  }
534
 
535
  /**
536
+ * Output the Activity component admin screens.
537
  *
538
+ * @since BuddyPress (1.6.0)
539
  */
540
  function bp_activity_admin() {
541
  // Decide whether to load the index or edit screen
551
  }
552
 
553
  /**
554
+ * Display the single activity edit screen.
555
  *
556
+ * @since BuddyPress (1.6.0)
 
557
  */
558
  function bp_activity_admin_edit() {
559
 
642
  }
643
 
644
  /**
645
+ * Status metabox for the Activity admin edit screen.
646
  *
647
+ * @since BuddyPress (1.6.0)
648
+ *
649
+ * @param object $item Activity item.
650
  */
651
  function bp_activity_admin_edit_metabox_status( $item ) {
652
  ?>
698
  }
699
 
700
  /**
701
+ * Primary link metabox for the Activity admin edit screen.
702
  *
703
+ * @since BuddyPress (1.6.0)
704
+ *
705
+ * @param object $item Activity item.
706
  */
707
  function bp_activity_admin_edit_metabox_link( $item ) {
708
  ?>
709
 
710
  <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label>
711
  <input type="url" name="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" />
712
+ <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>
713
 
714
  <?php
715
  }
716
 
717
  /**
718
+ * User ID metabox for the Activity admin edit screen.
719
  *
720
+ * @since BuddyPress (1.6.0)
721
+ *
722
+ * @param object $item Activity item.
723
  */
724
  function bp_activity_admin_edit_metabox_userid( $item ) {
725
  ?>
733
  /**
734
  * Activity type metabox for the Activity admin edit screen
735
  *
736
+ * @since BuddyPress (1.6.0)
737
+ *
738
+ * @global object $bp BuddyPress global settings.
739
+ *
740
+ * @param object $item Activity item.
741
  */
742
  function bp_activity_admin_edit_metabox_type( $item ) {
743
  global $bp;
769
  }
770
 
771
  /**
772
+ * Primary item ID/Secondary item ID metabox for the Activity admin edit screen.
773
  *
774
+ * @since BuddyPress (1.6.0)
775
+ *
776
+ * @param object $item Activity item.
777
  */
778
  function bp_activity_admin_edit_metabox_itemids( $item ) {
779
  ?>
793
  /**
794
  * Display the Activity admin index screen, which contains a list of all the activities.
795
  *
796
+ * @since BuddyPress (1.6.0)
797
+ *
798
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list
799
+ * table.
800
+ * @global string $plugin_page The current plugin page.
801
  */
802
  function bp_activity_admin_index() {
803
  global $bp_activity_list_table, $plugin_page;
927
  class BP_Activity_List_Table extends WP_List_Table {
928
 
929
  /**
930
+ * What type of view is being displayed?
931
  *
932
+ * e.g. "all", "pending", "approved", "spam"...
933
+ *
934
+ * @since BuddyPress (1.6.0)
935
+ * @var string
936
+ */
937
  public $view = 'all';
938
 
939
  /**
940
  * How many activity items have been marked as spam.
941
  *
942
+ * @since BuddyPress (1.6.0)
943
+ * @var int
944
  */
945
  public $spam_count = 0;
946
 
947
  /**
948
  * Store activity-to-user-ID mappings for use in the In Response To column.
949
  *
950
+ * @since BuddyPress (1.6.0)
951
+ * @var array
952
  */
953
  protected $activity_user_id = array();
954
 
955
  /**
956
+ * Constructor.
957
  *
958
+ * @since BuddyPress (1.6.0)
959
  */
960
  public function __construct() {
961
 
964
  'ajax' => false,
965
  'plural' => 'activities',
966
  'singular' => 'activity',
967
+ 'screen' => get_current_screen(),
968
  ) );
969
  }
970
 
971
  /**
972
+ * Handle filtering of data, sorting, pagination, and any other data manipulation prior to rendering.
973
  *
974
+ * @since BuddyPress (1.6.0)
975
  */
976
  function prepare_items() {
 
977
 
978
  // Option defaults
979
  $filter = array();
986
  $page = $this->get_pagenum();
987
 
988
  // Set per page from the screen options
989
+ $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
990
 
991
  // Check if we're on the "Spam" view
992
  if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
1069
  }
1070
 
1071
  /**
1072
+ * Get an array of all the columns on the page.
1073
  *
1074
+ * @since BuddyPress (1.6.0)
1075
+ *
1076
+ * @return array Column headers.
1077
  */
1078
  function get_column_info() {
1079
  $this->_column_headers = array(
1086
  }
1087
 
1088
  /**
1089
+ * Display a message on screen when no items are found (e.g. no search matches).
1090
  *
1091
+ * @since BuddyPress (1.6.0)
1092
  */
1093
  function no_items() {
1094
  _e( 'No activities found.', 'buddypress' );
1095
  }
1096
 
1097
  /**
1098
+ * Output the Activity data table.
1099
  *
1100
+ * @since BuddyPress (1.6.0)
1101
  */
1102
  function display() {
1103
  extract( $this->_args );
1127
  }
1128
 
1129
  /**
1130
+ * Generate content for a single row of the table.
1131
+ *
1132
+ * @since BuddyPress (1.6.0)
1133
  *
1134
+ * @param object $item The current item.
 
1135
  */
1136
  function single_row( $item ) {
1137
+ static $even = false;
1138
+
1139
+ if ( $even ) {
1140
+ $row_class = ' class="even"';
1141
+ } else {
1142
+ $row_class = ' class="alternate odd"';
1143
+ }
1144
 
1145
+ if ( 'activity_comment' === $item['type'] ) {
1146
+ $root_id = $item['item_id'];
1147
  } else {
1148
+ $root_id = $item['id'];
1149
  }
1150
 
1151
+ echo '<tr' . $row_class . ' id="activity-' . esc_attr( $item['id'] ) . '" data-parent_id="' . esc_attr( $item['id'] ) . '" data-root_id="' . esc_attr( $root_id ) . '">';
1152
  echo $this->single_row_columns( $item );
1153
  echo '</tr>';
1154
+
1155
+ $even = ! $even;
1156
  }
1157
 
1158
  /**
1159
  * Get the list of views available on this table (e.g. "all", "spam").
1160
  *
1161
+ * @since BuddyPress (1.6.0)
1162
  */
1163
  function get_views() {
1164
  $url_base = bp_get_admin_url( 'admin.php?page=bp-activity' ); ?>
1172
  <?php
1173
  }
1174
 
1175
+ /**
1176
+ * Get bulk actions.
1177
+ *
1178
+ * @since BuddyPress (1.6.0)
1179
  *
1180
+ * @return array Key/value pairs for the bulk actions dropdown.
 
1181
  */
1182
  function get_bulk_actions() {
1183
  $actions = array();
1191
  /**
1192
  * Get the table column titles.
1193
  *
1194
+ * @since BuddyPress (1.6.0)
1195
+ *
1196
  * @see WP_List_Table::single_row_columns()
1197
+ *
1198
+ * @return array The columns to appear in the Activity list table.
1199
  */
1200
  function get_columns() {
1201
  return array(
1207
  }
1208
 
1209
  /**
1210
+ * Get the column names for sortable columns.
1211
+ *
1212
+ * Currently, returns an empty array (no columns are sortable).
1213
  *
1214
+ * @since BuddyPress (1.6.0)
1215
+ * @todo For this to work, BP_Activity_Activity::get() needs updating
1216
+ * to support ordering by specific fields.
1217
+ *
1218
+ * @return array The columns that can be sorted on the Activity screen.
1219
  */
1220
  function get_sortable_columns() {
1221
  return array();
1226
  }
1227
 
1228
  /**
1229
+ * Markup for the "filter" part of the form (i.e. which activity type to display).
1230
+ *
1231
+ * @since BuddyPress (1.6.0)
1232
  *
1233
+ * @param string $which 'top' or 'bottom'.
 
1234
  */
1235
  function extra_tablenav( $which ) {
1236
  if ( 'bottom' == $which )
1259
  }
1260
 
1261
  /**
1262
+ * Checkbox column markup.
1263
+ *
1264
+ * @since BuddyPress (1.6.0)
1265
  *
 
1266
  * @see WP_List_Table::single_row_columns()
1267
+ *
1268
+ * @param array $item A singular item (one full row).
1269
  */
1270
  function column_cb( $item ) {
1271
  printf( '<label class="screen-reader-text" for="aid-%1$d">' . __( 'Select activity item %1$d', 'buddypress' ) . '</label><input type="checkbox" name="aid[]" value="%1$d" id="aid-%1$d" />', $item['id'] );
1272
  }
1273
 
1274
  /**
1275
+ * Author column markup.
1276
+ *
1277
+ * @since BuddyPress (1.6.0)
1278
  *
 
1279
  * @see WP_List_Table::single_row_columns()
1280
+ *
1281
+ * @param array $item A singular item (one full row).
1282
  */
1283
  function column_author( $item ) {
1284
  echo '<strong>' . get_avatar( $item['user_id'], '32' ) . ' ' . bp_core_get_userlink( $item['user_id'] ) . '</strong>';
1289
  *
1290
  * Called "comment" in the CSS so we can re-use some WP core CSS.
1291
  *
1292
+ * @since BuddyPress (1.6.0)
1293
+ *
1294
  * @see WP_List_Table::single_row_columns()
1295
+ *
1296
+ * @param array $item A singular item (one full row).
1297
  */
1298
  function column_comment( $item ) {
1299
  // Determine what type of item (row) we're dealing with
1345
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1346
 
1347
  /* translators: 2: activity admin ui date/time */
1348
+ 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' ) ) );
1349
 
1350
  // End timestamp
1351
  echo '</div>';
1361
  }
1362
 
1363
  /**
1364
+ * "In response to" column markup.
1365
+ *
1366
+ * @since BuddyPress (1.6.0)
1367
  *
 
1368
  * @see WP_List_Table::single_row_columns()
1369
+ *
1370
+ * @param array $item A singular item (one full row).
1371
  */
1372
  function column_response( $item ) {
1373
  // Is $item is a root activity?
1392
  }
1393
 
1394
  /**
1395
+ * Get the user id associated with a given activity item.
1396
+ *
1397
+ * Wraps bp_activity_get_specific(), with some additional logic for
1398
+ * avoiding duplicate queries.
1399
  *
1400
+ * @since BuddyPress (1.6.0)
1401
+ *
1402
+ * @param int $activity_id Activity ID to retrieve User ID for.
1403
+ * @return int User ID of the activity item in question.
1404
  */
1405
  protected function get_activity_user_id( $activity_id ) {
1406
  // If there is an existing activity/user ID mapping, just return the user ID.
1430
  }
1431
 
1432
  /**
1433
+ * Flatten the activity array.
1434
+ *
1435
+ * In some cases, BuddyPress gives us a structured tree of activity
1436
+ * items plus their comments. This method converts it to a flat array.
1437
+ *
1438
+ * @since BuddyPress (1.6.0)
1439
  *
1440
+ * @param array $tree Source array.
1441
+ * @return array Flattened array.
 
1442
  */
1443
  public static function flatten_activity_array( $tree ){
1444
  foreach ( (array) $tree as $node ) {
bp-activity/bp-activity-akismet.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Akismet support for BuddyPress' Activity Stream
4
  *
5
  * @package BuddyPress
6
  * @since BuddyPress (1.6)
@@ -10,9 +10,14 @@
10
  // Exit if accessed directly
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
 
 
 
 
 
13
  class BP_Akismet {
14
  /**
15
- * The activity last marked as spam
16
  *
17
  * @access protected
18
  * @var BP_Activity_Activity
@@ -21,7 +26,7 @@ class BP_Akismet {
21
  protected $last_activity = null;
22
 
23
  /**
24
- * Constructor
25
  *
26
  * @since BuddyPress (1.6)
27
  */
@@ -30,7 +35,7 @@ class BP_Akismet {
30
  }
31
 
32
  /**
33
- * Hook Akismet into the activity stream
34
  *
35
  * @since BuddyPress (1.6)
36
  */
@@ -64,10 +69,11 @@ class BP_Akismet {
64
  * This function lifted with love from the Akismet WordPress plugin's
65
  * akismet_comment_row_action() function. Thanks!
66
  *
67
- * @param array $actions The hover links
68
- * @param array $activity The activity for the current row being processed
69
- * @return array The hover links
70
  * @since BuddyPress (1.6)
 
 
 
 
71
  */
72
  function comment_row_action( $actions, $activity ) {
73
  $akismet_result = bp_activity_get_meta( $activity['id'], '_bp_akismet_result' );
@@ -110,11 +116,15 @@ class BP_Akismet {
110
  }
111
 
112
  /**
113
- * Adds a nonce to the member profile status form, and to the reply form of each activity stream item.
114
- * This is used by Akismet to help detect spam activity.
 
 
 
115
  *
116
- * @see http://plugins.trac.wordpress.org/ticket/1232
117
  * @since BuddyPress (1.6)
 
 
118
  */
119
  public function add_activity_stream_nonce() {
120
  $form_id = '_bp_as_nonce';
@@ -130,15 +140,24 @@ class BP_Akismet {
130
  }
131
 
132
  /**
133
- * Check the member's latest (activity) update to see if it's the item that was (just) marked as spam.
134
  *
135
- * This can't be done in BP_Akismet::check_activity() due to BP-Default's AJAX implementation; see bp_dtheme_post_update().
 
 
 
 
 
 
 
136
  *
137
- * @param string $content Activity update text
138
- * @param int $user_id User ID
139
- * @param int $activity_id Activity ID
140
- * @see bp_dtheme_post_update()
141
  * @since BuddyPress (1.6)
 
 
 
 
 
 
142
  */
143
  public function check_member_activity_update( $content, $user_id, $activity_id ) {
144
  // By default, only handle activity updates and activity comments.
@@ -211,22 +230,25 @@ class BP_Akismet {
211
  }
212
 
213
  /**
214
- * Get a list of filterable types of activity item that we want Akismet to automatically check for spam.
215
  *
216
- * @return array List of activity types
217
  * @since BuddyPress (1.6)
 
218
  * @static
 
 
219
  */
220
  public static function get_activity_types() {
221
  return apply_filters( 'bp_akismet_get_activity_types', array( 'activity_comment', 'activity_update' ) );
222
  }
223
 
224
  /**
225
- * Mark activity item as spam
 
 
226
  *
227
  * @param BP_Activity_Activity $activity
228
  * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed).
229
- * @since BuddyPress (1.6)
230
  */
231
  public function mark_as_spam( $activity, $source ) {
232
  // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
@@ -236,11 +258,12 @@ class BP_Akismet {
236
  }
237
 
238
  /**
239
- * Mark activity item as ham
 
 
240
  *
241
  * @param BP_Activity_Activity $activity
242
  * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed).
243
- * @since BuddyPress (1.6)
244
  */
245
  public function mark_as_ham( $activity, $source ) {
246
  // If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
@@ -251,12 +274,14 @@ class BP_Akismet {
251
  }
252
 
253
  /**
254
- * Build a data package for the Akismet service to inspect
255
  *
256
- * @param BP_Activity_Activity $activity
257
- * @see http://akismet.com/development/api/#comment-check
258
  * @since BuddyPress (1.6)
 
 
259
  * @static
 
 
260
  */
261
  public static function build_akismet_data_package( $activity ) {
262
  $userdata = get_userdata( $activity->user_id );
@@ -290,13 +315,15 @@ class BP_Akismet {
290
  }
291
 
292
  /**
293
- * Check if the activity item is spam or ham
294
  *
295
- * @param BP_Activity_Activity $activity The activity item to check
296
- * @see http://akismet.com/development/api/
297
  * @since BuddyPress (1.6)
 
 
298
  * @todo Spam counter?
299
  * @todo Auto-delete old spam?
 
 
300
  */
301
  public function check_activity( $activity ) {
302
  // By default, only handle activity updates and activity comments.
@@ -332,10 +359,11 @@ class BP_Akismet {
332
  }
333
 
334
  /**
335
- * Update activity meta after a manual spam change (user initiated)
336
  *
337
- * @param BP_Activity_Activity $activity The activity to check
338
  * @since BuddyPress (1.6)
 
 
339
  */
340
  public function update_activity_spam_meta( $activity ) {
341
  // By default, only handle activity updates and activity comments.
@@ -348,10 +376,11 @@ class BP_Akismet {
348
  }
349
 
350
  /**
351
- * Update activity meta after a manual ham change (user initiated)
352
  *
353
- * @param BP_Activity_Activity $activity The activity to check
354
  * @since BuddyPress (1.6)
 
 
355
  */
356
  public function update_activity_ham_meta( $activity ) {
357
  // By default, only handle activity updates and activity comments.
@@ -364,10 +393,11 @@ class BP_Akismet {
364
  }
365
 
366
  /**
367
- * Update activity meta after an automatic spam check (not user initiated)
368
  *
369
- * @param BP_Activity_Activity $activity The activity to check
370
  * @since BuddyPress (1.6)
 
 
371
  */
372
  public function update_activity_akismet_meta( $activity ) {
373
  // Check we're dealing with what was last updated by Akismet
@@ -399,16 +429,19 @@ class BP_Akismet {
399
  }
400
 
401
  /**
402
- * Contact Akismet to check if this is spam or ham
 
 
403
  *
404
- * Props to WordPress core Akismet plugin for alot of this
405
  *
406
  * @global string $akismet_api_host
407
  * @global string $akismet_api_port
408
- * @param array $activity_data Packet of information to submit to Akismet
409
- * @param string $check "check" or "submit"
410
- * @param string $spam "spam" or "ham"
411
- * @since BuddyPress (1.6)
 
412
  */
413
  public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
414
  global $akismet_api_host, $akismet_api_port;
@@ -477,10 +510,12 @@ class BP_Akismet {
477
  }
478
 
479
  /**
480
- * Filters user agent when sending to Akismet.
481
  *
482
- * @param string $user_agent
483
  * @since BuddyPress (1.6)
 
 
 
484
  */
485
  public function buddypress_ua( $user_agent ) {
486
  $user_agent = 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' );
@@ -490,8 +525,9 @@ class BP_Akismet {
490
  /**
491
  * Adds a "History" meta box to the activity edit screen.
492
  *
493
- * @param string $screen_action The type of screen that has been requested
494
  * @since BuddyPress (1.6)
 
 
495
  */
496
  function add_history_metabox( $screen_action ) {
497
  // Only proceed if we're on the edit screen
@@ -503,12 +539,14 @@ class BP_Akismet {
503
  }
504
 
505
  /**
506
- * History meta box for the Activity admin edit screen
507
  *
508
- * @param object $item Activity item
509
  * @since BuddyPress (1.6)
510
- * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
511
  * @see http://buddypress.trac.wordpress.org/ticket/3907
 
 
 
512
  */
513
  function history_metabox( $item ) {
514
  $history = BP_Akismet::get_activity_history( $item->id );
@@ -522,12 +560,13 @@ class BP_Akismet {
522
  }
523
 
524
  /**
525
- * Update an activity item's Akismet history
526
  *
527
- * @param int $activity_id Activity item ID
528
- * @param string $message Human-readable description of what's changed
529
- * @param string $event The type of check we were carrying out
530
  * @since BuddyPress (1.6)
 
 
 
 
531
  */
532
  public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
533
  $event = array(
@@ -542,11 +581,12 @@ class BP_Akismet {
542
  }
543
 
544
  /**
545
- * Get an activity item's Akismet history
546
  *
547
- * @param int $activity_id Activity item ID
548
- * @return array The activity item's Akismet history
549
  * @since BuddyPress (1.6)
 
 
 
550
  */
551
  public function get_activity_history( $activity_id = 0 ) {
552
  $history = bp_activity_get_meta( $activity_id, '_bp_akismet_history' );
@@ -561,11 +601,15 @@ class BP_Akismet {
561
  }
562
 
563
  /**
564
- * Deletes old spam activity meta data, as _bp_akismet_submission meta can be large.
 
 
 
565
  *
566
- * @global object $bp BuddyPress global settings
567
- * @global wpdb $wpdb WordPress database object
568
  * @since BuddyPress (1.6)
 
 
 
569
  */
570
  function bp_activity_akismet_delete_old_metadata() {
571
  global $bp, $wpdb;
1
  <?php
2
  /**
3
+ * Akismet support for BuddyPress' Activity Stream.
4
  *
5
  * @package BuddyPress
6
  * @since BuddyPress (1.6)
10
  // Exit if accessed directly
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
+ /**
14
+ * Akismet support for the Activity component.
15
+ *
16
+ * @since BuddyPress (1.6)
17
+ */
18
  class BP_Akismet {
19
  /**
20
+ * The activity last marked as spam.
21
  *
22
  * @access protected
23
  * @var BP_Activity_Activity
26
  protected $last_activity = null;
27
 
28
  /**
29
+ * Constructor.
30
  *
31
  * @since BuddyPress (1.6)
32
  */
35
  }
36
 
37
  /**
38
+ * Hook Akismet into the activity stream.
39
  *
40
  * @since BuddyPress (1.6)
41
  */
69
  * This function lifted with love from the Akismet WordPress plugin's
70
  * akismet_comment_row_action() function. Thanks!
71
  *
 
 
 
72
  * @since BuddyPress (1.6)
73
+ *
74
+ * @param array $actions The hover links.
75
+ * @param array $activity The activity for the current row being processed.
76
+ * @return array The hover links.
77
  */
78
  function comment_row_action( $actions, $activity ) {
79
  $akismet_result = bp_activity_get_meta( $activity['id'], '_bp_akismet_result' );
116
  }
117
 
118
  /**
119
+ * Generate nonces for activity forms.
120
+ *
121
+ * These nonces appear in the member profile status form, as well as in
122
+ * the reply form of each activity item. The nonces are, in turn, used
123
+ * by Akismet to help detect spam activity.
124
  *
 
125
  * @since BuddyPress (1.6)
126
+ *
127
+ * @see http://plugins.trac.wordpress.org/ticket/1232
128
  */
129
  public function add_activity_stream_nonce() {
130
  $form_id = '_bp_as_nonce';
140
  }
141
 
142
  /**
143
+ * Clean up the bp_latest_update usermeta in case of spamming.
144
  *
145
+ * Run just after an update is posted, this method check to see whether
146
+ * the newly created update has been marked as spam by Akismet. If so,
147
+ * the cached update is cleared from the user's 'bp_latest_update'
148
+ * usermeta, ensuring that it won't appear in the member header and
149
+ * elsewhere in the theme.
150
+ *
151
+ * This can't be done in BP_Akismet::check_activity() due to the
152
+ * default AJAX implementation; see bp_dtheme_post_update().
153
  *
 
 
 
 
154
  * @since BuddyPress (1.6)
155
+ *
156
+ * @see bp_dtheme_post_update()
157
+ *
158
+ * @param string $content Activity update text.
159
+ * @param int $user_id User ID.
160
+ * @param int $activity_id Activity ID.
161
  */
162
  public function check_member_activity_update( $content, $user_id, $activity_id ) {
163
  // By default, only handle activity updates and activity comments.
230
  }
231
 
232
  /**
233
+ * Get a filterable list of activity types that Akismet should automatically check for spam.
234
  *
 
235
  * @since BuddyPress (1.6)
236
+ *
237
  * @static
238
+ *
239
+ * @return array List of activity types.
240
  */
241
  public static function get_activity_types() {
242
  return apply_filters( 'bp_akismet_get_activity_types', array( 'activity_comment', 'activity_update' ) );
243
  }
244
 
245
  /**
246
+ * Mark activity item as spam.
247
+ *
248
+ * @since BuddyPress (1.6)
249
  *
250
  * @param BP_Activity_Activity $activity
251
  * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed).
 
252
  */
253
  public function mark_as_spam( $activity, $source ) {
254
  // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
258
  }
259
 
260
  /**
261
+ * Mark activity item as ham.
262
+ *
263
+ * @since BuddyPress (1.6)
264
  *
265
  * @param BP_Activity_Activity $activity
266
  * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed).
 
267
  */
268
  public function mark_as_ham( $activity, $source ) {
269
  // If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
274
  }
275
 
276
  /**
277
+ * Build a data package for the Akismet service to inspect.
278
  *
 
 
279
  * @since BuddyPress (1.6)
280
+ *
281
+ * @see http://akismet.com/development/api/#comment-check
282
  * @static
283
+ *
284
+ * @param BP_Activity_Activity $activity Activity item data.
285
  */
286
  public static function build_akismet_data_package( $activity ) {
287
  $userdata = get_userdata( $activity->user_id );
315
  }
316
 
317
  /**
318
+ * Check if the activity item is spam or ham.
319
  *
 
 
320
  * @since BuddyPress (1.6)
321
+ *
322
+ * @see http://akismet.com/development/api/
323
  * @todo Spam counter?
324
  * @todo Auto-delete old spam?
325
+ *
326
+ * @param BP_Activity_Activity $activity The activity item to check.
327
  */
328
  public function check_activity( $activity ) {
329
  // By default, only handle activity updates and activity comments.
359
  }
360
 
361
  /**
362
+ * Update activity meta after a manual spam change (user-initiated).
363
  *
 
364
  * @since BuddyPress (1.6)
365
+ *
366
+ * @param BP_Activity_Activity $activity The activity to check.
367
  */
368
  public function update_activity_spam_meta( $activity ) {
369
  // By default, only handle activity updates and activity comments.
376
  }
377
 
378
  /**
379
+ * Update activity meta after a manual ham change (user-initiated).
380
  *
 
381
  * @since BuddyPress (1.6)
382
+ *
383
+ * @param BP_Activity_Activity $activity The activity to check.
384
  */
385
  public function update_activity_ham_meta( $activity ) {
386
  // By default, only handle activity updates and activity comments.
393
  }
394
 
395
  /**
396
+ * Update activity meta after an automatic spam check (not user-initiated).
397
  *
 
398
  * @since BuddyPress (1.6)
399
+ *
400
+ * @param BP_Activity_Activity $activity The activity to check.
401
  */
402
  public function update_activity_akismet_meta( $activity ) {
403
  // Check we're dealing with what was last updated by Akismet
429
  }
430
 
431
  /**
432
+ * Contact Akismet to check if this is spam or ham.
433
+ *
434
+ * Props to WordPress core Akismet plugin for alot of this.
435
  *
436
+ * @since BuddyPress (1.6)
437
  *
438
  * @global string $akismet_api_host
439
  * @global string $akismet_api_port
440
+ *
441
+ * @param array $activity_data Packet of information to submit to Akismet.
442
+ * @param string $check "check" or "submit".
443
+ * @param string $spam "spam" or "ham".
444
+ * @return array $activity_data Activity data, with Akismet data added.
445
  */
446
  public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
447
  global $akismet_api_host, $akismet_api_port;
510
  }
511
 
512
  /**
513
+ * Filters user agent when sending to Akismet to add BuddyPress info.
514
  *
 
515
  * @since BuddyPress (1.6)
516
+ *
517
+ * @param string $user_agent User agent string, as generated by Akismet.
518
+ * @return string $user_agent Modified user agent string.
519
  */
520
  public function buddypress_ua( $user_agent ) {
521
  $user_agent = 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' );
525
  /**
526
  * Adds a "History" meta box to the activity edit screen.
527
  *
 
528
  * @since BuddyPress (1.6)
529
+ *
530
+ * @param string $screen_action The type of screen that has been requested.
531
  */
532
  function add_history_metabox( $screen_action ) {
533
  // Only proceed if we're on the edit screen
539
  }
540
 
541
  /**
542
+ * History meta box for the Activity admin edit screen.
543
  *
 
544
  * @since BuddyPress (1.6)
545
+ *
546
  * @see http://buddypress.trac.wordpress.org/ticket/3907
547
+ * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
548
+ *
549
+ * @param object $item Activity item.
550
  */
551
  function history_metabox( $item ) {
552
  $history = BP_Akismet::get_activity_history( $item->id );
560
  }
561
 
562
  /**
563
+ * Update an activity item's Akismet history.
564
  *
 
 
 
565
  * @since BuddyPress (1.6)
566
+ *
567
+ * @param int $activity_id Activity item ID.
568
+ * @param string $message Human-readable description of what's changed.
569
+ * @param string $event The type of check we were carrying out.
570
  */
571
  public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
572
  $event = array(
581
  }
582
 
583
  /**
584
+ * Get an activity item's Akismet history.
585
  *
 
 
586
  * @since BuddyPress (1.6)
587
+ *
588
+ * @param int $activity_id Activity item ID.
589
+ * @return array The activity item's Akismet history.
590
  */
591
  public function get_activity_history( $activity_id = 0 ) {
592
  $history = bp_activity_get_meta( $activity_id, '_bp_akismet_history' );
601
  }
602
 
603
  /**
604
+ * Delete old spam activity meta data
605
+ *
606
+ * This is done as a clean-up mechanism, as _bp_akismet_submission meta can
607
+ * grow to be quite large.
608
  *
 
 
609
  * @since BuddyPress (1.6)
610
+ *
611
+ * @global object $bp BuddyPress global settings.
612
+ * @global wpdb $wpdb WordPress database object.
613
  */
614
  function bp_activity_akismet_delete_old_metadata() {
615
  global $bp, $wpdb;
bp-activity/bp-activity-cache.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * Functions related to the BuddyPress Activity component and the WP Cache
5
  *
6
  * @since BuddyPress (1.6)
7
  */
@@ -10,17 +10,18 @@
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
- * Slurps up activitymeta
14
  *
15
- * This function is called in two places in the BP_Groups_Group class:
16
- * - in the populate() method, when single group objects are populated
17
  * - in the get() method, when multiple groups are queried
18
  *
19
- * It grabs all groupmeta associated with all of the groups passed in $group_ids and adds it to
20
- * the WP cache. This improves efficiency when using groupmeta inline
 
21
  *
22
- * @param int|str|array $group_ids Accepts a single group_id, or a comma-separated list or array of
23
- * group ids
24
  */
25
  function bp_activity_update_meta_cache( $activity_ids = false ) {
26
  global $bp;
@@ -37,7 +38,7 @@ function bp_activity_update_meta_cache( $activity_ids = false ) {
37
  }
38
 
39
  /**
40
- * Clear the cache for all metadata of a given activity
41
  *
42
  * @param int $activity_id
43
  */
1
  <?php
2
 
3
  /**
4
+ * Functions related to the BuddyPress Activity component and the WP Cache.
5
  *
6
  * @since BuddyPress (1.6)
7
  */
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
+ * Slurp up activitymeta for a specified set of activity items.
14
  *
15
+ * This function is called in two places in the BP_Activity_Activity class:
16
+ * - in the populate() method, when single activity objects are populated
17
  * - in the get() method, when multiple groups are queried
18
  *
19
+ * It grabs all activitymeta associated with all of the activity items passed
20
+ * in $activity_ids and adds it to the WP cache. This improves efficiency when
21
+ * using querying activitymeta inline.
22
  *
23
+ * @param int|str|array $activity_ids Accepts a single activity ID, or a comma-
24
+ * separated list or array of activity ids
25
  */
26
  function bp_activity_update_meta_cache( $activity_ids = false ) {
27
  global $bp;
38
  }
39
 
40
  /**
41
+ * Clear the cache for all metadata of a given activity.
42
  *
43
  * @param int $activity_id
44
  */
bp-activity/bp-activity-classes.php CHANGED
@@ -9,30 +9,132 @@
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
 
 
 
 
 
 
 
 
12
  class BP_Activity_Activity {
 
 
 
 
 
 
 
 
13
  var $id;
 
 
 
 
 
 
14
  var $item_id;
 
 
 
 
 
 
15
  var $secondary_item_id;
 
 
 
 
 
 
16
  var $user_id;
 
 
 
 
 
 
17
  var $primary_link;
 
 
 
 
 
 
18
  var $component;
 
 
 
 
 
 
19
  var $type;
 
 
 
 
 
 
20
  var $action;
 
 
 
 
 
 
21
  var $content;
 
 
 
 
 
 
22
  var $date_recorded;
 
 
 
 
 
 
23
  var $hide_sitewide = false;
 
 
 
 
 
 
24
  var $mptt_left;
 
 
 
 
 
 
25
  var $mptt_right;
 
 
 
 
 
 
26
  var $is_spam;
27
 
28
- function __construct( $id = false ) {
 
 
 
 
 
29
  if ( !empty( $id ) ) {
30
  $this->id = $id;
31
  $this->populate();
32
  }
33
  }
34
 
35
- function populate() {
 
 
 
36
  global $wpdb, $bp;
37
 
38
  if ( $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) ) ) {
@@ -55,8 +157,13 @@ class BP_Activity_Activity {
55
  }
56
  }
57
 
58
- function save() {
59
- global $wpdb, $bp, $current_user;
 
 
 
 
 
60
 
61
  $this->id = apply_filters_ref_array( 'bp_activity_id_before_save', array( $this->id, &$this ) );
62
  $this->item_id = apply_filters_ref_array( 'bp_activity_item_id_before_save', array( $this->item_id, &$this ) );
@@ -104,15 +211,45 @@ class BP_Activity_Activity {
104
  return true;
105
  }
106
 
107
- // Static Functions
108
 
109
  /**
110
  * Get activity items, as specified by parameters
111
  *
112
- * @param array $args See $defaults for explanation of arguments
113
- * @return array
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  */
115
- function get( $args = array() ) {
116
  global $wpdb, $bp;
117
 
118
  // Backward compatibility with old method of passing arguments
@@ -295,7 +432,7 @@ class BP_Activity_Activity {
295
  }
296
 
297
  /**
298
- * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get()
299
  *
300
  * We use WP_Meta_Query to do the heavy lifting of parsing the
301
  * meta_query array and creating the necessary SQL clauses. However,
@@ -307,7 +444,7 @@ class BP_Activity_Activity {
307
  *
308
  * @param array $meta_query An array of meta_query filters. See the
309
  * documentation for WP_Meta_Query for details.
310
- * @return array $sql_array 'join' and 'where' clauses
311
  */
312
  public static function get_meta_query_sql( $meta_query = array() ) {
313
  global $wpdb;
@@ -336,10 +473,14 @@ class BP_Activity_Activity {
336
 
337
  /**
338
  * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
 
339
  * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
340
  *
 
 
341
  * @deprecated 1.5
342
  * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
 
343
  * @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve
344
  * @param int $max Maximum number of results to return. (Optional; default is no maximum)
345
  * @param int $page The set of results that the user is viewing. Used in pagination. (Optional; default is 1)
@@ -347,14 +488,26 @@ class BP_Activity_Activity {
347
  * @param string MySQL column sort; ASC or DESC. (Optional; default is DESC)
348
  * @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false)
349
  * @return array
350
- * @since BuddyPress (1.2)
351
  */
352
- function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
353
  _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
354
  return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
355
  }
356
 
357
- function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  global $bp, $wpdb;
359
 
360
  $where_args = false;
@@ -391,7 +544,30 @@ class BP_Activity_Activity {
391
  return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
392
  }
393
 
394
- function delete( $args ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
  global $wpdb, $bp;
396
 
397
  $defaults = array(
@@ -453,28 +629,73 @@ class BP_Activity_Activity {
453
  // Fetch the activity IDs so we can delete any comments for this activity item
454
  $activity_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
455
 
456
- if ( !$wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) )
457
  return false;
 
458
 
 
459
  if ( $activity_ids ) {
460
- BP_Activity_Activity::delete_activity_item_comments( $activity_ids );
461
- BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
 
 
 
 
 
 
 
 
462
 
463
- return $activity_ids;
 
 
 
 
 
464
  }
465
 
466
  return $activity_ids;
467
  }
468
 
469
- function delete_activity_item_comments( $activity_ids = array() ) {
 
 
 
 
 
 
 
 
 
 
 
470
  global $bp, $wpdb;
471
 
 
 
472
  $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
473
 
 
 
 
 
 
 
 
 
 
474
  return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
475
  }
476
 
477
- function delete_activity_meta_entries( $activity_ids = array() ) {
 
 
 
 
 
 
 
 
478
  global $bp, $wpdb;
479
 
480
  $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
@@ -487,17 +708,17 @@ class BP_Activity_Activity {
487
  }
488
 
489
  /**
490
- * Append activity comments to their associated activity items
491
  *
492
- * @global wpdb $wpdb WordPress database object
493
- * @param array $activities
494
- * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'.
495
- * @return array The updated activities with nested comments
496
  * @since BuddyPress (1.2)
 
 
 
 
 
 
497
  */
498
- function append_comments( $activities, $spam = 'ham_only' ) {
499
- global $wpdb;
500
-
501
  $activity_comments = array();
502
 
503
  // Now fetch the activity comments and parse them into the correct position in the activities array.
@@ -515,19 +736,21 @@ class BP_Activity_Activity {
515
  }
516
 
517
  /**
518
- * Get activity comments that are associated with a specific activity ID
519
  *
520
- * @global BuddyPress $bp The one true BuddyPress instance
521
- * @global wpdb $wpdb WordPress database object
522
- * @param int $activity_id Activity ID to fetch comments for
523
- * @param int $left Left-most node boundary
524
- * @param into $right Right-most node boundary
525
- * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'.
526
- * @param int $top_level_parent_id The id of the root-level parent activity item
527
- * @return array The updated activities with nested comments
528
  * @since BuddyPress (1.2)
 
 
 
 
 
 
 
 
 
 
529
  */
530
- function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
531
  global $wpdb, $bp;
532
 
533
  if ( empty( $top_level_parent_id ) ) {
@@ -584,7 +807,19 @@ class BP_Activity_Activity {
584
  return $comments;
585
  }
586
 
587
- function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
 
 
 
 
 
 
 
 
 
 
 
 
588
  global $wpdb, $bp;
589
 
590
  // The right value of this node is the left value + 1
@@ -608,40 +843,65 @@ class BP_Activity_Activity {
608
  return $right + 1;
609
  }
610
 
611
- function get_child_comments( $parent_id ) {
 
 
 
 
 
 
 
 
 
 
 
612
  global $bp, $wpdb;
613
 
614
  return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
615
  }
616
 
617
  /**
618
- * Fetch a list of all components that have activity items recorded
619
  *
620
- * @return array
621
  */
622
- function get_recorded_components() {
623
  global $wpdb, $bp;
624
  return $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
625
  }
626
 
627
- function get_sitewide_items_for_feed( $limit = 35 ) {
628
- global $bp;
629
-
 
 
 
 
630
  $activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
631
  $activity_feed = array();
632
 
633
  for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
634
- $title = explode( '<span', $activities[$i]['content'] );
635
- $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
636
- $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
637
- $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
638
- $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
639
  }
640
 
641
  return $activity_feed;
642
  }
643
 
644
- function get_in_operator_sql( $field, $items ) {
 
 
 
 
 
 
 
 
 
 
645
  global $wpdb;
646
 
647
  // split items at the comma
@@ -665,7 +925,27 @@ class BP_Activity_Activity {
665
  return false;
666
  }
667
 
668
- function get_filter_sql( $filter_array ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
 
670
  $filter_sql = array();
671
 
@@ -705,26 +985,53 @@ class BP_Activity_Activity {
705
  return join( ' AND ', $filter_sql );
706
  }
707
 
708
- function get_last_updated() {
 
 
 
 
 
 
 
709
  global $bp, $wpdb;
710
 
711
  return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
712
  }
713
 
714
- function total_favorite_count( $user_id ) {
 
 
 
 
 
 
 
 
715
  if ( !$favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ) )
716
  return 0;
717
 
718
  return count( maybe_unserialize( $favorite_activity_entries ) );
719
  }
720
 
721
- function check_exists_by_content( $content ) {
 
 
 
 
 
 
722
  global $wpdb, $bp;
723
 
724
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
725
  }
726
 
727
- function hide_all_for_user( $user_id ) {
 
 
 
 
 
 
728
  global $wpdb, $bp;
729
 
730
  return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
@@ -862,6 +1169,8 @@ class BP_Activity_Feed {
862
 
863
  /**
864
  * Setup and validate the class properties.
 
 
865
  */
866
  protected function setup_properties() {
867
  $this->id = sanitize_title( $this->id );
@@ -874,6 +1183,7 @@ class BP_Activity_Feed {
874
 
875
  $this->activity_args = wp_parse_args( $this->activity_args, array(
876
  'max' => $this->max,
 
877
  'display_comments' => 'stream'
878
  ) );
879
 
@@ -884,6 +1194,8 @@ class BP_Activity_Feed {
884
  *
885
  * Currently, these hooks are used to maintain backwards compatibility with
886
  * the RSS feeds previous to BP 1.8.
 
 
887
  */
888
  protected function setup_hooks() {
889
  add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
@@ -893,14 +1205,23 @@ class BP_Activity_Feed {
893
 
894
  /** BACKPAT HOOKS ********************************************************/
895
 
 
 
 
896
  public function backpat_rss_attributes() {
897
  do_action( 'bp_activity_' . $this->id . '_feed' );
898
  }
899
 
 
 
 
900
  public function backpat_channel_elements() {
901
  do_action( 'bp_activity_' . $this->id . '_feed_head' );
902
  }
903
 
 
 
 
904
  public function backpat_item_elements() {
905
  switch ( $this->id ) {
906
 
@@ -924,6 +1245,8 @@ class BP_Activity_Feed {
924
 
925
  /**
926
  * Output the feed's item content.
 
 
927
  */
928
  protected function feed_content() {
929
  bp_activity_content_body();
@@ -947,12 +1270,16 @@ class BP_Activity_Feed {
947
  }
948
  }
949
 
950
- /** OUTPUT ***************************************************************/
951
-
952
  /**
953
- * Output the RSS feed.
 
 
 
 
 
 
954
  */
955
- protected function output() {
956
  // set up some additional headers if not on a directory page
957
  // this is done b/c BP uses pseudo-pages
958
  if ( ! bp_is_directory() ) {
@@ -962,7 +1289,72 @@ class BP_Activity_Feed {
962
  status_header( 200 );
963
  }
964
 
965
- header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
966
  echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>';
967
  ?>
968
 
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
+ /**
13
+ * Database interaction class for the BuddyPress activity component.
14
+ *
15
+ * Instance methods are available for creating/editing an activity,
16
+ * static methods for querying activities.
17
+ *
18
+ * @since BuddyPress (1.0)
19
+ */
20
  class BP_Activity_Activity {
21
+
22
+ /** Properties ************************************************************/
23
+
24
+ /**
25
+ * ID of the activity item.
26
+ *
27
+ * @var int
28
+ */
29
  var $id;
30
+
31
+ /**
32
+ * ID of the associated item.
33
+ *
34
+ * @var int
35
+ */
36
  var $item_id;
37
+
38
+ /**
39
+ * ID of the associated secondary item.
40
+ *
41
+ * @var int
42
+ */
43
  var $secondary_item_id;
44
+
45
+ /**
46
+ * ID of user associated with the activity item.
47
+ *
48
+ * @var int
49
+ */
50
  var $user_id;
51
+
52
+ /**
53
+ * The primary URL for the activity in RSS feeds.
54
+ *
55
+ * @var string
56
+ */
57
  var $primary_link;
58
+
59
+ /**
60
+ * BuddyPress component the activity item relates to.
61
+ *
62
+ * @var string
63
+ */
64
  var $component;
65
+
66
+ /**
67
+ * Activity type, eg 'new_blog_post'.
68
+ *
69
+ * @var string
70
+ */
71
  var $type;
72
+
73
+ /**
74
+ * Description of the activity, eg 'Alex updated his profile.'
75
+ *
76
+ * @var string
77
+ */
78
  var $action;
79
+
80
+ /**
81
+ * The content of the activity item.
82
+ *
83
+ * @var string
84
+ */
85
  var $content;
86
+
87
+ /**
88
+ * The date the activity item was recorded, in 'Y-m-d h:i:s' format.
89
+ *
90
+ * @var string
91
+ */
92
  var $date_recorded;
93
+
94
+ /**
95
+ * Whether the item should be hidden in sitewide streams.
96
+ *
97
+ * @var int
98
+ */
99
  var $hide_sitewide = false;
100
+
101
+ /**
102
+ * Node boundary start for activity or activity comment.
103
+ *
104
+ * @var int
105
+ */
106
  var $mptt_left;
107
+
108
+ /**
109
+ * Node boundary end for activity or activity comment.
110
+ *
111
+ * @var int
112
+ */
113
  var $mptt_right;
114
+
115
+ /**
116
+ * Whether this item is marked as spam.
117
+ *
118
+ * @var int
119
+ */
120
  var $is_spam;
121
 
122
+ /**
123
+ * Constructor method.
124
+ *
125
+ * @param int $id Optional. The ID of a specific activity item.
126
+ */
127
+ public function __construct( $id = false ) {
128
  if ( !empty( $id ) ) {
129
  $this->id = $id;
130
  $this->populate();
131
  }
132
  }
133
 
134
+ /**
135
+ * Populate the object with data about the specific activity item.
136
+ */
137
+ public function populate() {
138
  global $wpdb, $bp;
139
 
140
  if ( $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) ) ) {
157
  }
158
  }
159
 
160
+ /**
161
+ * Save the activity item to the database.
162
+ *
163
+ * @return bool True on success.
164
+ */
165
+ public function save() {
166
+ global $wpdb, $bp;
167
 
168
  $this->id = apply_filters_ref_array( 'bp_activity_id_before_save', array( $this->id, &$this ) );
169
  $this->item_id = apply_filters_ref_array( 'bp_activity_item_id_before_save', array( $this->item_id, &$this ) );
211
  return true;
212
  }
213
 
214
+ /** Static Methods ***************************************************/
215
 
216
  /**
217
  * Get activity items, as specified by parameters
218
  *
219
+ * @see BP_Activity_Activity::get_filter_sql() for a description of the
220
+ * 'filter' parameter.
221
+ * @see WP_Meta_Query::queries for a description of the 'meta_query'
222
+ * parameter format.
223
+ *
224
+ * @param array $args {
225
+ * An array of arguments. All items are optional.
226
+ * @type int $page Which page of results to fetch. Using page=1
227
+ * without per_page will result in no pagination.
228
+ * Default: 1.
229
+ * @type int|bool $per_page Number of results per page. Default: 25.
230
+ * @type int|bool $max Maximum number of results to return.
231
+ * Default: false (unlimited).
232
+ * @type string $sort ASC or DESC. Default: 'DESC'.
233
+ * @type array $exclude Array of activity IDs to exclude.
234
+ * Default: false.
235
+ * @type array $in Array of ids to limit query by (IN).
236
+ * Default: false.
237
+ * @type array $meta_query An array of meta_query conditions.
238
+ * See WP_Meta_Query::queries for description.
239
+ * @type array $filter See BP_Activity_Activity::get_filter_sql().
240
+ * @type string $search_terms Limit results by a search term.
241
+ * Default: false.
242
+ * @type bool $display_comments Whether to include activity comments.
243
+ * Default: false.
244
+ * @type bool $show_hidden Whether to show items marked hide_sitewide.
245
+ * Default: false.
246
+ * @type string $spam Spam status. Default: 'ham_only'.
247
+ * }
248
+ * @return array The array returned has two keys:
249
+ * - 'total' is the count of located activities
250
+ * - 'activities' is an array of the located activities
251
  */
252
+ public static function get( $args = array() ) {
253
  global $wpdb, $bp;
254
 
255
  // Backward compatibility with old method of passing arguments
432
  }
433
 
434
  /**
435
+ * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get().
436
  *
437
  * We use WP_Meta_Query to do the heavy lifting of parsing the
438
  * meta_query array and creating the necessary SQL clauses. However,
444
  *
445
  * @param array $meta_query An array of meta_query filters. See the
446
  * documentation for WP_Meta_Query for details.
447
+ * @return array $sql_array 'join' and 'where' clauses.
448
  */
449
  public static function get_meta_query_sql( $meta_query = array() ) {
450
  global $wpdb;
473
 
474
  /**
475
  * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
476
+ *
477
  * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
478
  *
479
+ * @since BuddyPress (1.2)
480
+ *
481
  * @deprecated 1.5
482
  * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
483
+ *
484
  * @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve
485
  * @param int $max Maximum number of results to return. (Optional; default is no maximum)
486
  * @param int $page The set of results that the user is viewing. Used in pagination. (Optional; default is 1)
488
  * @param string MySQL column sort; ASC or DESC. (Optional; default is DESC)
489
  * @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false)
490
  * @return array
 
491
  */
492
+ public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
493
  _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
494
  return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
495
  }
496
 
497
+ /**
498
+ * Get the first activity ID that matches a set of criteria.
499
+ *
500
+ * @param int $user_id The user ID to filter by.
501
+ * @param string $component The component to filter by.
502
+ * @param string $type The activity type to filter by.
503
+ * @param int $item_id The associated item to filter by.
504
+ * @param int $secondary_item_id The secondary associated item to filter by.
505
+ * @param string $action The action to filter by.
506
+ * @param string $content The content to filter by.
507
+ * @param string $date_recorded The date to filter by.
508
+ * @return int|bool Activity ID on success, false if none is found.
509
+ */
510
+ public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
511
  global $bp, $wpdb;
512
 
513
  $where_args = false;
544
  return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
545
  }
546
 
547
+ /**
548
+ * Delete activity items from the database.
549
+ *
550
+ * To delete a specific activity item, pass an 'id' parameter.
551
+ * Otherwise use the filters.
552
+ *
553
+ * @since BuddyPress (1.2)
554
+ *
555
+ * @param array $args {
556
+ * @int $id Optional. The ID of a specific item to delete.
557
+ * @string $action Optional. The action to filter by.
558
+ * @string $content Optional. The content to filter by.
559
+ * @string $component Optional. The component name to filter by.
560
+ * @string $type Optional. The activity type to filter by.
561
+ * @string $primary_link Optional. The primary URL to filter by.
562
+ * @int $user_id Optional. The user ID to filter by.
563
+ * @int $item_id Optional. The associated item ID to filter by.
564
+ * @int $secondary_item_id Optional. The secondary associated item ID to filter by.
565
+ * @string $date_recorded Optional. The date to filter by.
566
+ * @int $hide_sitewide Optional. Default: false.
567
+ * }
568
+ * @return array|bool An array of deleted activity IDs on success, false on failure.
569
+ */
570
+ public static function delete( $args = array() ) {
571
  global $wpdb, $bp;
572
 
573
  $defaults = array(
629
  // Fetch the activity IDs so we can delete any comments for this activity item
630
  $activity_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
631
 
632
+ if ( ! $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) ) {
633
  return false;
634
+ }
635
 
636
+ // Handle accompanying activity comments and meta deletion
637
  if ( $activity_ids ) {
638
+ $activity_ids_comma = implode( ',', wp_parse_id_list( $activity_ids ) );
639
+ $activity_comments_where_sql = "WHERE type = 'activity_comment' AND item_id IN ({$activity_ids_comma})";
640
+
641
+ // Fetch the activity comment IDs for our deleted activity items
642
+ $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$activity_comments_where_sql}" );
643
+
644
+ // We have activity comments!
645
+ if ( ! empty( $activity_comment_ids ) ) {
646
+ // Delete activity comments
647
+ $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$activity_comments_where_sql}" );
648
 
649
+ // Merge activity IDs with activity comment IDs
650
+ $activity_ids = array_merge( $activity_ids, $activity_comment_ids );
651
+ }
652
+
653
+ // Delete all activity meta entries for activity items and activity comments
654
+ BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
655
  }
656
 
657
  return $activity_ids;
658
  }
659
 
660
+ /**
661
+ * Delete the comments associated with a set of activity items.
662
+ *
663
+ * @since BuddyPress (1.2)
664
+ *
665
+ * @todo Mark as deprecated? Method is no longer used internally.
666
+ *
667
+ * @param array $activity_ids Activity IDs whose comments should be deleted.
668
+ * @param bool $delete_meta Should we delete the activity meta items for these comments?
669
+ * @return bool True on success.
670
+ */
671
+ public static function delete_activity_item_comments( $activity_ids = array(), $delete_meta = true ) {
672
  global $bp, $wpdb;
673
 
674
+ $delete_meta = (bool) $delete_meta;
675
+
676
  $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
677
 
678
+ if ( $delete_meta ) {
679
+ // Fetch the activity comment IDs for our deleted activity items
680
+ $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
681
+
682
+ if ( ! empty( $activity_comment_ids ) ) {
683
+ self::delete_activity_meta_entries( $activity_comment_ids );
684
+ }
685
+ }
686
+
687
  return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
688
  }
689
 
690
+ /**
691
+ * Delete the meta entries associated with a set of activity items.
692
+ *
693
+ * @since BuddyPress (1.2)
694
+ *
695
+ * @param array $activity_ids Activity IDs whose meta should be deleted.
696
+ * @return bool True on success.
697
+ */
698
+ public static function delete_activity_meta_entries( $activity_ids = array() ) {
699
  global $bp, $wpdb;
700
 
701
  $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
708
  }
709
 
710
  /**
711
+ * Append activity comments to their associated activity items.
712
  *
 
 
 
 
713
  * @since BuddyPress (1.2)
714
+ *
715
+ * @global wpdb $wpdb WordPress database object
716
+ *
717
+ * @param array $activities Activities to fetch comments for.
718
+ * @param bool $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
719
+ * @return array The updated activities with nested comments.
720
  */
721
+ public static function append_comments( $activities, $spam = 'ham_only' ) {
 
 
722
  $activity_comments = array();
723
 
724
  // Now fetch the activity comments and parse them into the correct position in the activities array.
736
  }
737
 
738
  /**
739
+ * Get activity comments that are associated with a specific activity ID.
740
  *
 
 
 
 
 
 
 
 
741
  * @since BuddyPress (1.2)
742
+ *
743
+ * @global BuddyPress $bp The one true BuddyPress instance.
744
+ * @global wpdb $wpdb WordPress database object.
745
+ *
746
+ * @param int $activity_id Activity ID to fetch comments for.
747
+ * @param int $left Left-most node boundary.
748
+ * @param into $right Right-most node boundary.
749
+ * @param bool $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
750
+ * @param int $top_level_parent_id Optional. The id of the root-level parent activity item.
751
+ * @return array The updated activities with nested comments.
752
  */
753
+ public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
754
  global $wpdb, $bp;
755
 
756
  if ( empty( $top_level_parent_id ) ) {
807
  return $comments;
808
  }
809
 
810
+ /**
811
+ * Rebuild nested comment tree under an activity or activity comment.
812
+ *
813
+ * @since BuddyPress (1.2)
814
+ *
815
+ * @global BuddyPress $bp The one true BuddyPress instance.
816
+ * @global wpdb $wpdb WordPress database object.
817
+ *
818
+ * @param int $parent_id ID of an activty or activity comment.
819
+ * @param int $left Node boundary start for activity or activity comment.
820
+ * @return int Right node boundary of activity or activity comment.
821
+ */
822
+ public static function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
823
  global $wpdb, $bp;
824
 
825
  // The right value of this node is the left value + 1
843
  return $right + 1;
844
  }
845
 
846
+ /**
847
+ * Get child comments of an activity or activity comment.
848
+ *
849
+ * @since BuddyPress (1.2)
850
+ *
851
+ * @global BuddyPress $bp The one true BuddyPress instance.
852
+ * @global wpdb $wpdb WordPress database object.
853
+ *
854
+ * @param int $parent_id ID of an activty or activity comment.
855
+ * @return object Numerically indexed array of child comments.
856
+ */
857
+ public static function get_child_comments( $parent_id ) {
858
  global $bp, $wpdb;
859
 
860
  return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
861
  }
862
 
863
  /**
864
+ * Get a list of components that have recorded activity associated with them
865
  *
866
+ * @return array List of component names.
867
  */
868
+ public static function get_recorded_components() {
869
  global $wpdb, $bp;
870
  return $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
871
  }
872
 
873
+ /**
874
+ * Get sitewide activity items for use in an RSS feed.
875
+ *
876
+ * @param int $limit Optional. Number of items to fetch. Default: 35.
877
+ * @return array $activity_feed List of activity items, with RSS data added.
878
+ */
879
+ public static function get_sitewide_items_for_feed( $limit = 35 ) {
880
  $activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
881
  $activity_feed = array();
882
 
883
  for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
884
+ $title = explode( '<span', $activities[$i]['content'] );
885
+ $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
886
+ $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
887
+ $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
888
+ $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
889
  }
890
 
891
  return $activity_feed;
892
  }
893
 
894
+ /**
895
+ * Create SQL IN clause for filter queries.
896
+ *
897
+ * @since BuddyPress (1.5)
898
+ *
899
+ * @see BP_Activity_Activity::get_filter_sql()
900
+ *
901
+ * @param string $field The database field.
902
+ * @param array|bool $items The values for the IN clause, or false when none are found.
903
+ */
904
+ public static function get_in_operator_sql( $field, $items ) {
905
  global $wpdb;
906
 
907
  // split items at the comma
925
  return false;
926
  }
927
 
928
+ /**
929
+ * Create filter SQL clauses.
930
+ *
931
+ * @since BuddyPress (1.5)
932
+ *
933
+ * @param array $filter_array Fields and values to filter by. Should be
934
+ * in the format:
935
+ * $filter_array = array(
936
+ * 'filter1' => $value,
937
+ * 'filter2' => $value,
938
+ * )
939
+ * Possible filters are as follows. Each can be either a single
940
+ * string, a comma-separated list, or an array of values.
941
+ * - 'user_id' User ID(s)
942
+ * - 'object' Corresponds to the 'component' column in the database.
943
+ * - 'action' Corresponds to the 'type' column in the database.
944
+ * - 'primary_id' Corresponds to the 'item_id' column in the database.
945
+ * - 'secondary_id' Corresponds to the 'secondary_item_id' column in the database.
946
+ * @return string The filter clause, for use in a SQL query.
947
+ */
948
+ public static function get_filter_sql( $filter_array ) {
949
 
950
  $filter_sql = array();
951
 
985
  return join( ' AND ', $filter_sql );
986
  }
987
 
988
+ /**
989
+ * Get the date/time of last recorded activity.
990
+ *
991
+ * @since BuddyPress (1.2)
992
+ *
993
+ * @return string ISO timestamp.
994
+ */
995
+ public static function get_last_updated() {
996
  global $bp, $wpdb;
997
 
998
  return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
999
  }
1000
 
1001
+ /**
1002
+ * Get favorite count for a given user.
1003
+ *
1004
+ * @since BuddyPress (1.2)
1005
+ *
1006
+ * @param int The ID of the user whose favorites you're counting.
1007
+ * @return int A count of the user's favorites.
1008
+ */
1009
+ public static function total_favorite_count( $user_id ) {
1010
  if ( !$favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ) )
1011
  return 0;
1012
 
1013
  return count( maybe_unserialize( $favorite_activity_entries ) );
1014
  }
1015
 
1016
+ /**
1017
+ * Check whether an activity item exists with a given string content.
1018
+ *
1019
+ * @param string $content The content to filter by.
1020
+ * @return int|bool The ID of the first matching item if found, otherwise false.
1021
+ */
1022
+ public static function check_exists_by_content( $content ) {
1023
  global $wpdb, $bp;
1024
 
1025
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
1026
  }
1027
 
1028
+ /**
1029
+ * Hide all activity for a given user.
1030
+ *
1031
+ * @param int $user_id The ID of the user whose activity you want to mark hidden.
1032
+ * @param int
1033
+ */
1034
+ public static function hide_all_for_user( $user_id ) {
1035
  global $wpdb, $bp;
1036
 
1037
  return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
1169
 
1170
  /**
1171
  * Setup and validate the class properties.
1172
+ *
1173
+ * @access protected
1174
  */
1175
  protected function setup_properties() {
1176
  $this->id = sanitize_title( $this->id );
1183
 
1184
  $this->activity_args = wp_parse_args( $this->activity_args, array(
1185
  'max' => $this->max,
1186
+ 'per_page' => $this->max,
1187
  'display_comments' => 'stream'
1188
  ) );
1189
 
1194
  *
1195
  * Currently, these hooks are used to maintain backwards compatibility with
1196
  * the RSS feeds previous to BP 1.8.
1197
+ *
1198
+ * @access protected
1199
  */
1200
  protected function setup_hooks() {
1201
  add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
1205
 
1206
  /** BACKPAT HOOKS ********************************************************/
1207
 
1208
+ /**
1209
+ * Fire a hook to ensure backward compatibility for RSS attributes.
1210
+ */
1211
  public function backpat_rss_attributes() {
1212
  do_action( 'bp_activity_' . $this->id . '_feed' );
1213
  }
1214
 
1215
+ /**
1216
+ * Fire a hook to ensure backward compatibility for channel elements.
1217
+ */
1218
  public function backpat_channel_elements() {
1219
  do_action( 'bp_activity_' . $this->id . '_feed_head' );
1220
  }
1221
 
1222
+ /**
1223
+ * Fire a hook to ensure backward compatibility for item elements.
1224
+ */
1225
  public function backpat_item_elements() {
1226
  switch ( $this->id ) {
1227
 
1245
 
1246
  /**
1247
  * Output the feed's item content.
1248
+ *
1249
+ * @access protected
1250
  */
1251
  protected function feed_content() {
1252
  bp_activity_content_body();
1270
  }
1271
  }
1272
 
 
 
1273
  /**
1274
+ * Sets various HTTP headers related to Content-Type and browser caching.
1275
+ *
1276
+ * Most of this class method is derived from {@link WP::send_headers()}.
1277
+ *
1278
+ * @since BuddyPress (1.9.0)
1279
+ *
1280
+ * @access protected
1281
  */
1282
+ protected function http_headers() {
1283
  // set up some additional headers if not on a directory page
1284
  // this is done b/c BP uses pseudo-pages
1285
  if ( ! bp_is_directory() ) {
1289
  status_header( 200 );
1290
  }
1291
 
1292
+ // Set content-type
1293
+ @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
1294
+
1295
+ // Cache-related variables
1296
+ $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
1297
+ $modified_timestamp = strtotime( $last_modified );
1298
+ $etag = md5( $last_modified );
1299
+
1300
+ // Set cache-related headers
1301
+ @header( 'Last-Modified: ' . $last_modified );
1302
+ @header( 'Pragma: no-cache' );
1303
+ @header( 'ETag: ' . '"' . $etag . '"' );
1304
+
1305
+ // First commit of BuddyPress! (Easter egg)
1306
+ @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT');
1307
+
1308
+ // Get ETag from supported user agents
1309
+ if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
1310
+ $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
1311
+
1312
+ // Remove quotes from ETag
1313
+ $client_etag = trim( $client_etag, '"' );
1314
+
1315
+ // Strip suffixes from ETag if they exist (eg. "-gzip")
1316
+ if ( $etag_suffix_pos = strpos( $client_etag, '-' ) ) {
1317
+ $client_etag = substr( $client_etag, 0, $etag_suffix_pos );
1318
+ }
1319
+
1320
+ // No ETag found
1321
+ } else {
1322
+ $client_etag = false;
1323
+ }
1324
+
1325
+ // Get client last modified timestamp from supported user agents
1326
+ $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
1327
+ $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
1328
+
1329
+ // Set 304 status if feed hasn't been updated since last fetch
1330
+ if ( ( $client_last_modified && $client_etag ) ?
1331
+ ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) :
1332
+ ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) {
1333
+ $status = 304;
1334
+ } else {
1335
+ $status = false;
1336
+ }
1337
+
1338
+ // If feed hasn't changed as reported by the user agent, set 304 status header
1339
+ if ( ! empty( $status ) ) {
1340
+ status_header( $status );
1341
+
1342
+ // cached response, so stop now!
1343
+ if ( $status == 304 ) {
1344
+ exit();
1345
+ }
1346
+ }
1347
+ }
1348
+
1349
+ /** OUTPUT ***************************************************************/
1350
+
1351
+ /**
1352
+ * Output the RSS feed.
1353
+ *
1354
+ * @access protected
1355
+ */
1356
+ protected function output() {
1357
+ $this->http_headers();
1358
  echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>';
1359
  ?>
1360
 
bp-activity/bp-activity-filters.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * The Activity filters
5
  *
6
  * @package BuddyPress
7
  * @subpackage ActivityFilters
@@ -78,7 +78,7 @@ add_filter( 'bp_get_activity_feed_item_description', 'stripslashes_deep' );
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' );
@@ -108,9 +108,11 @@ add_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1
108
  /** Functions *****************************************************************/
109
 
110
  /**
111
- * Types of activity stream items to check against
112
  *
113
  * @since BuddyPress (1.6)
 
 
114
  */
115
  function bp_activity_get_moderated_activity_types() {
116
  $types = array(
@@ -121,10 +123,11 @@ function bp_activity_get_moderated_activity_types() {
121
  }
122
 
123
  /**
124
- * Check activity stream for moderation keys
125
  *
126
  * @since BuddyPress (1.6)
127
- * @param BP_Activity_Activity $activity
 
128
  */
129
  function bp_activity_check_moderation_keys( $activity ) {
130
 
@@ -139,10 +142,11 @@ function bp_activity_check_moderation_keys( $activity ) {
139
  }
140
 
141
  /**
142
- * Check activity stream for blacklisted keys
143
  *
144
  * @since BuddyPress (1.6)
145
- * @param BP_Activity_Activity $activity
 
146
  */
147
  function bp_activity_check_blacklist_keys( $activity ) {
148
 
@@ -156,16 +160,15 @@ function bp_activity_check_blacklist_keys( $activity ) {
156
  }
157
 
158
  /**
159
- * Custom kses filtering for activity content
160
  *
161
  * @since BuddyPress (1.1)
162
  *
163
- * @param string $content The activity content
164
- *
165
  * @uses apply_filters() To call the 'bp_activity_allowed_tags' hook.
166
  * @uses wp_kses()
167
  *
168
- * @return string $content Filtered activity content
 
169
  */
170
  function bp_activity_filter_kses( $content ) {
171
  global $allowedtags;
@@ -196,13 +199,12 @@ function bp_activity_filter_kses( $content ) {
196
  *
197
  * @since BuddyPress (1.2)
198
  *
199
- * @param string $content The contents of a given item.
200
- * @param int $activity_id The activity id. Deprecated.
201
- *
202
  * @uses bp_activity_find_mentions()
203
  * @uses bp_core_get_user_domain()
204
  *
205
- * @return string $content Content filtered for mentions
 
 
206
  */
207
  function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
208
 
@@ -228,16 +230,16 @@ function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
228
  }
229
 
230
  /**
231
- * Catch mentions in activity items before they are saved into the database.
232
  *
233
  * If mentions are found, replace @mention text with user links and add our
234
- * hook to send mentions after the activity item is saved.
235
  *
236
  * @since BuddyPress (1.5)
237
  *
238
- * @param BP_Activity_Activity $activity
239
- *
240
  * @uses bp_activity_find_mentions()
 
 
241
  */
242
  function bp_activity_at_name_filter_updates( $activity ) {
243
  // Are mentions disabled?
@@ -268,15 +270,14 @@ function bp_activity_at_name_filter_updates( $activity ) {
268
  }
269
 
270
  /**
271
- * Sends emails and BP notifications for @-mentioned users in the contents of
272
- * an activity item.
273
  *
274
  * @since BuddyPress (1.7)
275
  *
276
- * @param BP_Activity_Activity $activity The BP_Activity_Activity object
277
- *
278
  * @uses bp_activity_at_message_notification()
279
  * @uses bp_activity_update_mention_count_for_user()
 
 
280
  */
281
  function bp_activity_at_name_send_emails( $activity ) {
282
  // Are mentions disabled?
@@ -307,25 +308,25 @@ function bp_activity_at_name_send_emails( $activity ) {
307
  }
308
 
309
  /**
310
- * Catches links in activity text so rel=nofollow can be added
311
  *
312
  * @since BuddyPress (1.2)
313
  *
314
- * @param string $text Activity text
315
- *
316
- * @return string $text Text with rel=nofollow added to any links
317
  */
318
  function bp_activity_make_nofollow_filter( $text ) {
319
  return preg_replace_callback( '|<a (.+?)>|i', 'bp_activity_make_nofollow_filter_callback', $text );
320
  }
321
 
322
  /**
323
- * Adds rel=nofollow to a link
324
  *
325
  * @since BuddyPress (1.2)
326
  *
327
  * @param array $matches
328
  *
 
329
  * @return string $text Link with rel=nofollow added
330
  */
331
  function bp_activity_make_nofollow_filter_callback( $matches ) {
@@ -335,21 +336,20 @@ function bp_activity_make_nofollow_filter( $text ) {
335
  }
336
 
337
  /**
338
- * Truncates long activity entries when viewed in activity streams
339
  *
340
  * @since BuddyPress (1.5)
341
  *
342
- * @param string $text The original activity entry text
343
- *
344
  * @uses bp_is_single_activity()
345
- * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook
346
- * @uses apply_filters() To call the 'bp_activity_excerpt_length' hook
347
  * @uses bp_create_excerpt()
348
  * @uses bp_get_activity_id()
349
  * @uses bp_get_activity_thread_permalink()
350
- * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook
351
  *
352
- * @return string $excerpt The truncated text
 
353
  */
354
  function bp_activity_truncate_entry( $text ) {
355
  global $activities_template;
1
  <?php
2
 
3
  /**
4
+ * Filters related to the Activity component.
5
  *
6
  * @package BuddyPress
7
  * @subpackage ActivityFilters
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' );
108
  /** Functions *****************************************************************/
109
 
110
  /**
111
+ * Types of activity stream items to moderate.
112
  *
113
  * @since BuddyPress (1.6)
114
+ *
115
+ * @return array $types List of the activity types to moderate.
116
  */
117
  function bp_activity_get_moderated_activity_types() {
118
  $types = array(
123
  }
124
 
125
  /**
126
+ * Moderate the posted activity item, if it contains moderate keywords.
127
  *
128
  * @since BuddyPress (1.6)
129
+ *
130
+ * @param BP_Activity_Activity $activity The activity object to check.
131
  */
132
  function bp_activity_check_moderation_keys( $activity ) {
133
 
142
  }
143
 
144
  /**
145
+ * Mark the posted activity as spam, if it contains blacklist keywords.
146
  *
147
  * @since BuddyPress (1.6)
148
+ *
149
+ * @param BP_Activity_Activity $activity The activity object to check.
150
  */
151
  function bp_activity_check_blacklist_keys( $activity ) {
152
 
160
  }
161
 
162
  /**
163
+ * Custom kses filtering for activity content.
164
  *
165
  * @since BuddyPress (1.1)
166
  *
 
 
167
  * @uses apply_filters() To call the 'bp_activity_allowed_tags' hook.
168
  * @uses wp_kses()
169
  *
170
+ * @param string $content The activity content.
171
+ * @return string $content Filtered activity content.
172
  */
173
  function bp_activity_filter_kses( $content ) {
174
  global $allowedtags;
199
  *
200
  * @since BuddyPress (1.2)
201
  *
 
 
 
202
  * @uses bp_activity_find_mentions()
203
  * @uses bp_core_get_user_domain()
204
  *
205
+ * @param string $content The contents of a given item.
206
+ * @param int $activity_id The activity id. Deprecated.
207
+ * @return string $content Content filtered for mentions.
208
  */
209
  function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
210
 
230
  }
231
 
232
  /**
233
+ * Catch mentions in an activity item before it is saved into the database.
234
  *
235
  * If mentions are found, replace @mention text with user links and add our
236
+ * hook to send mention notifications after the activity item is saved.
237
  *
238
  * @since BuddyPress (1.5)
239
  *
 
 
240
  * @uses bp_activity_find_mentions()
241
+ *
242
+ * @param BP_Activity_Activity $activity
243
  */
244
  function bp_activity_at_name_filter_updates( $activity ) {
245
  // Are mentions disabled?
270
  }
271
 
272
  /**
273
+ * Sends emails and BP notifications for users @-mentioned in an activity item.
 
274
  *
275
  * @since BuddyPress (1.7)
276
  *
 
 
277
  * @uses bp_activity_at_message_notification()
278
  * @uses bp_activity_update_mention_count_for_user()
279
+ *
280
+ * @param BP_Activity_Activity $activity The BP_Activity_Activity object
281
  */
282
  function bp_activity_at_name_send_emails( $activity ) {
283
  // Are mentions disabled?
308
  }
309
 
310
  /**
311
+ * Catch links in activity text so rel=nofollow can be added.
312
  *
313
  * @since BuddyPress (1.2)
314
  *
315
+ * @param string $text Activity text.
316
+ * @return string $text Text with rel=nofollow added to any links.
 
317
  */
318
  function bp_activity_make_nofollow_filter( $text ) {
319
  return preg_replace_callback( '|<a (.+?)>|i', 'bp_activity_make_nofollow_filter_callback', $text );
320
  }
321
 
322
  /**
323
+ * Add rel=nofollow to a link.
324
  *
325
  * @since BuddyPress (1.2)
326
  *
327
  * @param array $matches
328
  *
329
+ * @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
330
  * @return string $text Link with rel=nofollow added
331
  */
332
  function bp_activity_make_nofollow_filter_callback( $matches ) {
336
  }
337
 
338
  /**
339
+ * Truncate long activity entries when viewed in activity streams.
340
  *
341
  * @since BuddyPress (1.5)
342
  *
 
 
343
  * @uses bp_is_single_activity()
344
+ * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook.
345
+ * @uses apply_filters() To call the 'bp_activity_excerpt_length' hook.
346
  * @uses bp_create_excerpt()
347
  * @uses bp_get_activity_id()
348
  * @uses bp_get_activity_thread_permalink()
349
+ * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook.
350
  *
351
+ * @param string $text The original activity entry text.
352
+ * @return string $excerpt The truncated text.
353
  */
354
  function bp_activity_truncate_entry( $text ) {
355
  global $activities_template;
bp-activity/bp-activity-functions.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Activity Functions
5
  *
6
- * Functions for the Activity Streams component
7
  *
8
  * @package BuddyPress
9
  * @subpackage ActivityFunctions
@@ -13,13 +13,13 @@
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
- * Checks $bp pages global and looks for directory page
17
  *
18
  * @since BuddyPress (1.5)
19
  *
20
  * @global object $bp BuddyPress global settings
21
  *
22
- * @return bool True if set, False if empty
23
  */
24
  function bp_activity_has_directory() {
25
  global $bp;
@@ -45,6 +45,7 @@ function bp_activity_has_directory() {
45
  * @since BuddyPress (1.8)
46
  *
47
  * @uses apply_filters() To call 'bp_activity_do_mentions' hook.
 
48
  * @return bool $retval True to enable mentions, false to disable.
49
  */
50
  function bp_activity_do_mentions() {
@@ -52,13 +53,12 @@ function bp_activity_do_mentions() {
52
  }
53
 
54
  /**
55
- * Searches through the content of an activity item to locate usernames,
56
- * designated by an @ sign.
57
  *
58
  * @since BuddyPress (1.5)
59
  *
60
  * @param string $content The content of the activity, usually found in $activity->content.
61
- * @return mixed Associative array with user ID as key and username as value. Boolean false if no mentions found.
62
  */
63
  function bp_activity_find_mentions( $content ) {
64
  $pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
@@ -72,11 +72,7 @@ function bp_activity_find_mentions( $content ) {
72
 
73
  // We've found some mentions! Check to see if users exist
74
  foreach( (array) $usernames as $key => $username ) {
75
- if ( bp_is_username_compatibility_mode() ) {
76
- $user_id = username_exists( $username );
77
- } else {
78
- $user_id = bp_core_get_userid_from_nicename( $username );
79
- }
80
 
81
  // user ID exists, so let's add it to our array
82
  if ( ! empty( $user_id ) ) {
@@ -91,12 +87,13 @@ function bp_activity_find_mentions( $content ) {
91
  }
92
 
93
  /**
94
- * Resets a user's unread mentions list and count
95
  *
96
  * @since BuddyPress (1.5)
97
  *
98
- * @param int $user_id The id of the user whose unread mentions are being reset
99
  * @uses bp_delete_user_meta()
 
 
100
  */
101
  function bp_activity_clear_new_mentions( $user_id ) {
102
  bp_delete_user_meta( $user_id, 'bp_new_mention_count' );
@@ -113,11 +110,11 @@ function bp_activity_clear_new_mentions( $user_id ) {
113
  *
114
  * @since BuddyPress (1.5)
115
  *
116
- * @param int $activity_id The unique id for the activity item
117
- * @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
118
- *
119
  * @uses bp_activity_find_mentions()
120
  * @uses bp_activity_update_mention_count_for_user()
 
 
 
121
  */
122
  function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
123
  if ( empty( $activity_id ) )
@@ -140,19 +137,19 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
140
  }
141
 
142
  /**
143
- * Updates the mention count for the user in question.
144
  *
145
  * This function should be used when you've already parsed your activity item
146
  * for @mentions.
147
  *
148
  * @since BuddyPress (1.7)
149
  *
150
- * @param int $user_id The user ID
151
- * @param int $activity_id The unique id for the activity item
152
- * @param string $action Can be 'delete' or 'add'. Defaults to 'add'
153
- *
154
  * @uses bp_get_user_meta()
155
  * @uses bp_update_user_meta()
 
 
 
 
156
  * @return bool
157
  */
158
  function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
@@ -194,24 +191,23 @@ function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $act
194
  }
195
 
196
  /**
197
- * Formats notifications related to activity
198
  *
199
  * @since BuddyPress (1.5)
200
  *
201
- * @param string $action The type of activity item. Just 'new_at_mention' for now
202
- * @param int $item_id The activity id
203
- * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's id
204
- * @param int $total_items The total number of notifications to format
205
- * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise
206
- *
207
  * @uses bp_loggedin_user_domain()
208
  * @uses bp_get_activity_slug()
209
  * @uses bp_core_get_user_displayname()
210
- * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook
211
- * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook
212
- * @uses do_action() To call 'activity_format_notifications' hook
213
- *
214
- * @return string $return Formatted @mention notification
 
 
 
 
 
215
  */
216
  function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
217
 
@@ -247,21 +243,83 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
247
  return $return;
248
  }
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  /** Actions ******************************************************************/
251
 
252
  /**
253
- * Sets the current action for a given activity stream location
254
  *
255
  * @since BuddyPress (1.1)
256
  *
257
- * @param string $component_id
258
- * @param string $key
259
- * @param string $value
260
- *
261
  * @global object $bp BuddyPress global settings
262
  * @uses apply_filters() To call the 'bp_activity_set_action' hook
263
  *
264
- * @return bool False if any param is empty, otherwise true
 
 
 
265
  */
266
  function bp_activity_set_action( $component_id, $key, $value ) {
267
  global $bp;
@@ -288,17 +346,16 @@ function bp_activity_set_action( $component_id, $key, $value ) {
288
  }
289
 
290
  /**
291
- * Retreives the current action from a component and key
292
  *
293
  * @since BuddyPress (1.1)
294
  *
295
- * @param string $component_id
296
- * @param string $key
297
- *
298
- * @global object $bp BuddyPress global settings
299
- * @uses apply_filters() To call the 'bp_activity_get_action' hook
300
  *
301
- * @return mixed False on error, action on success
 
 
302
  */
303
  function bp_activity_get_action( $component_id, $key ) {
304
  global $bp;
@@ -311,10 +368,11 @@ function bp_activity_get_action( $component_id, $key ) {
311
  }
312
 
313
  /**
314
- * Fetch details of all registered activity types
315
  *
316
- * @return array array( type => description ), ...
317
  * @since BuddyPress (1.7)
 
 
318
  */
319
  function bp_activity_get_types() {
320
  $actions = array();
@@ -339,16 +397,15 @@ function bp_activity_get_types() {
339
  /** Favorites ****************************************************************/
340
 
341
  /**
342
- * Get a users favorite activity stream items
343
  *
344
  * @since BuddyPress (1.2)
345
  *
346
- * @param int $user_id
347
- *
348
  * @uses bp_get_user_meta()
349
- * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook
350
  *
351
- * @return array Array of users favorite activity stream ID's
 
352
  */
353
  function bp_activity_get_user_favorites( $user_id = 0 ) {
354
 
@@ -363,22 +420,21 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
363
  }
364
 
365
  /**
366
- * Add an activity stream item as a favorite for a user
367
  *
368
  * @since BuddyPress (1.2)
369
  *
370
- * @param int $activity_id
371
- * @param int $user_id
372
- *
373
  * @uses is_user_logged_in()
374
  * @uses bp_get_user_meta()
375
  * @uses bp_activity_get_meta()
376
  * @uses bp_update_user_meta()
377
  * @uses bp_activity_update_meta()
378
- * @uses do_action() To call the 'bp_activity_add_user_favorite' hook
379
- * @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook
380
  *
381
- * @return bool True on success, false on failure
 
 
382
  */
383
  function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
384
 
@@ -420,21 +476,20 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
420
  }
421
 
422
  /**
423
- * Remove an activity stream item as a favorite for a user
424
  *
425
  * @since BuddyPress (1.2)
426
  *
427
- * @param int $activity_id
428
- * @param int $user_id
429
- *
430
  * @uses is_user_logged_in()
431
  * @uses bp_get_user_meta()
432
  * @uses bp_activity_get_meta()
433
  * @uses bp_activity_update_meta()
434
  * @uses bp_update_user_meta()
435
- * @uses do_action() To call the 'bp_activity_remove_user_favorite' hook
436
  *
437
- * @return bool True on success, false on failure
 
 
438
  */
439
  function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
440
 
@@ -484,45 +539,43 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
484
  }
485
 
486
  /**
487
- * Check if activity exists by scanning content
488
  *
489
  * @since BuddyPress (1.1)
490
  *
491
- * @param string $content
492
- *
493
  * @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity}
494
- * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook
495
  *
496
- * @return bool
 
497
  */
498
  function bp_activity_check_exists_by_content( $content ) {
499
  return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
500
  }
501
 
502
  /**
503
- * Retrieve the last time activity was updated
504
  *
505
  * @since BuddyPress (1.0)
506
  *
507
  * @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity}
508
- * @uses apply_filters() To call the 'bp_activity_get_last_updated' hook
509
  *
510
- * @return string Date last updated
511
  */
512
  function bp_activity_get_last_updated() {
513
  return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
514
  }
515
 
516
  /**
517
- * Retrieve the number of favorite activity stream items a user has
518
  *
519
  * @since BuddyPress (1.2)
520
  *
521
- * @param int $user_id
522
- *
523
  * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
524
  *
525
- * @return int Total favorite count
 
526
  */
527
  function bp_activity_total_favorites_for_user( $user_id = 0 ) {
528
 
@@ -536,20 +589,22 @@ function bp_activity_total_favorites_for_user( $user_id = 0 ) {
536
  /** Meta *********************************************************************/
537
 
538
  /**
539
- * Delete a meta entry from the DB for an activity stream item
540
  *
541
  * @since BuddyPress (1.2)
542
  *
543
- * @param int $activity_id
544
- * @param string $meta_key
545
- * @param string $meta_value
546
- *
547
- * @global object $wpdb
548
- * @global object $bp BuddyPress global settings
549
  * @uses wp_cache_delete()
550
  * @uses is_wp_error()
551
  *
552
- * @return bool True on success, false on failure
 
 
 
 
 
 
553
  */
554
  function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '' ) {
555
  global $wpdb, $bp;
@@ -592,20 +647,21 @@ function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = ''
592
  }
593
 
594
  /**
595
- * Get activity meta
596
  *
597
  * @since BuddyPress (1.2)
598
  *
599
- * @param int $activity_id
600
- * @param string $meta_key
601
- *
602
- * @global object $wpdb
603
- * @global object $bp BuddyPress global settings
604
  * @uses wp_cache_get()
605
  * @uses wp_cache_set()
606
- * @uses apply_filters() To call the 'bp_activity_get_meta' hook
607
  *
608
- * @return bool
 
 
 
 
609
  */
610
  function bp_activity_get_meta( $activity_id = 0, $meta_key = '' ) {
611
  global $wpdb, $bp;
@@ -657,21 +713,20 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '' ) {
657
  }
658
 
659
  /**
660
- * Update activity meta
661
  *
662
  * @since BuddyPress (1.2)
663
  *
664
- * @param int $activity_id
665
- * @param string $meta_key
666
- * @param string $meta_value
667
- *
668
- * @global object $wpdb
669
- * @global object $bp BuddyPress global settings
670
  * @uses maybe_serialize()
671
  * @uses bp_activity_delete_meta()
672
  * @uses wp_cache_set()
673
  *
674
- * @return bool True on success, false on failure
 
 
 
675
  */
676
  function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
677
  global $wpdb, $bp;
@@ -684,14 +739,15 @@ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
684
  $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
685
 
686
  // Sanitize value
687
- if ( is_string( $meta_value ) )
688
- $meta_value = stripslashes( esc_sql( $meta_value ) );
 
689
 
690
  // Maybe, just maybe... serialize
691
  $meta_value = maybe_serialize( $meta_value );
692
 
693
- // If value is empty, delete the meta key
694
- if ( empty( $meta_value ) )
695
  return bp_activity_delete_meta( $activity_id, $meta_key );
696
 
697
  // See if meta key exists for activity_id
@@ -719,17 +775,17 @@ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
719
  /** Clean up *****************************************************************/
720
 
721
  /**
722
- * Completely remove a user's activity data
723
  *
724
  * @since BuddyPress (1.5)
725
  *
726
- * @param int $user_id
727
- *
728
  * @uses is_user_logged_in()
729
  * @uses bp_activity_delete()
730
  * @uses bp_delete_user_meta()
731
- * @uses do_action() To call the 'bp_activity_remove_data' hook
732
- * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook
 
 
733
  */
734
  function bp_activity_remove_all_user_data( $user_id = 0 ) {
735
 
@@ -754,12 +810,14 @@ add_action( 'wpmu_delete_user', 'bp_activity_remove_all_user_data' );
754
  add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
755
 
756
  /**
757
- * Mark all of the user's activity as spam
758
  *
759
- * @global object $wpdb
760
- * @global object $bp BuddyPress global settings
761
- * @param int $user_id
762
  * @since BuddyPress (1.6)
 
 
 
 
 
763
  */
764
  function bp_activity_spam_all_user_data( $user_id = 0 ) {
765
  global $bp, $wpdb;
@@ -805,12 +863,14 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
805
  add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
806
 
807
  /**
808
- * Mark all of the user's activity as ham (not spam)
809
  *
810
- * @global object $wpdb
811
- * @global object $bp BuddyPress global settings
812
- * @param int $user_id
813
  * @since BuddyPress (1.6)
 
 
 
 
 
814
  */
815
  function bp_activity_ham_all_user_data( $user_id = 0 ) {
816
  global $bp, $wpdb;
@@ -858,8 +918,9 @@ add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
858
  /**
859
  * Register the activity stream actions for updates
860
  *
861
- * @global object $bp BuddyPress global settings
862
  * @since BuddyPress (1.6)
 
 
863
  */
864
  function bp_activity_register_activity_actions() {
865
  global $bp;
@@ -882,19 +943,26 @@ add_action( 'bp_register_activity_actions', 'bp_activity_register_activity_actio
882
  */
883
 
884
  /**
885
- * Retrieve an activity or activities
886
  *
887
- * @since BuddyPress (1.2)
 
 
 
 
888
  *
889
- * @param array $args
890
  *
 
 
891
  * @uses wp_parse_args()
892
  * @uses wp_cache_get()
893
  * @uses wp_cache_set()
894
  * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
895
- * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook
896
  *
897
- * @return object $activity The activity/activities object
 
898
  */
899
  function bp_activity_get( $args = '' ) {
900
  $defaults = array(
@@ -967,17 +1035,22 @@ function bp_activity_get( $args = '' ) {
967
  }
968
 
969
  /**
970
- * Fetch specific activity items
971
  *
972
  * @since BuddyPress (1.2)
973
  *
974
- * @param array $args See docs for $defaults for details
975
- *
976
  * @uses wp_parse_args()
977
  * @uses apply_filters() To call the 'bp_activity_get_specific' hook
978
  * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
979
  *
980
- * @return array The array returned by BP_Activity_Activity::get()
 
 
 
 
 
 
981
  */
982
  function bp_activity_get_specific( $args = '' ) {
983
  $defaults = array(
@@ -1007,19 +1080,42 @@ function bp_activity_get_specific( $args = '' ) {
1007
  }
1008
 
1009
  /**
1010
- * Add an activity item
1011
  *
1012
  * @since BuddyPress (1.1)
1013
  *
1014
- * @param array $args See docs for $defaults for details
1015
- *
1016
  * @uses wp_parse_args()
1017
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
1018
  * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
1019
  * @uses wp_cache_delete()
1020
  * @uses do_action() To call the 'bp_activity_add' hook
1021
  *
1022
- * @return int The activity id
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1023
  */
1024
  function bp_activity_add( $args = '' ) {
1025
 
@@ -1078,24 +1174,26 @@ function bp_activity_add( $args = '' ) {
1078
  }
1079
 
1080
  /**
1081
- * Post an activity update
1082
  *
1083
  * @since BuddyPress (1.2)
1084
  *
1085
- * @param array $args See docs for $defaults for details
1086
- *
1087
- * @global object $bp BuddyPress global settings
1088
  * @uses wp_parse_args()
1089
  * @uses bp_is_user_inactive()
1090
  * @uses bp_core_get_userlink()
1091
  * @uses bp_activity_add()
1092
- * @uses apply_filters() To call the 'bp_activity_new_update_action' hook
1093
- * @uses apply_filters() To call the 'bp_activity_new_update_content' hook
1094
- * @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook
1095
  * @uses bp_update_user_meta()
1096
  * @uses wp_filter_kses()
1097
- * @uses do_action() To call the 'bp_activity_posted_update' hook
1098
  *
 
 
 
 
1099
  * @return int $activity_id The activity id
1100
  */
1101
  function bp_activity_post_update( $args = '' ) {
@@ -1141,22 +1239,31 @@ function bp_activity_post_update( $args = '' ) {
1141
  }
1142
 
1143
  /**
1144
- * Add an activity comment
1145
  *
1146
  * @since BuddyPress (1.2)
1147
  *
1148
- * @param array $args See docs for $defaults for details
1149
- *
1150
- * @global object $bp BuddyPress global settings
1151
  * @uses wp_parse_args()
1152
  * @uses bp_activity_add()
1153
- * @uses apply_filters() To call the 'bp_activity_comment_action' hook
1154
- * @uses apply_filters() To call the 'bp_activity_comment_content' hook
1155
  * @uses bp_activity_new_comment_notification()
1156
  * @uses wp_cache_delete()
1157
- * @uses do_action() To call the 'bp_activity_comment_posted' hook
1158
- *
1159
- * @return int $comment_id The comment id
 
 
 
 
 
 
 
 
 
 
 
1160
  */
1161
  function bp_activity_new_comment( $args = '' ) {
1162
  global $bp;
@@ -1201,7 +1308,7 @@ function bp_activity_new_comment( $args = '' ) {
1201
  // Clear the comment cache for this activity
1202
  wp_cache_delete( 'bp_activity_comments_' . $parent_id );
1203
 
1204
- do_action( 'bp_activity_comment_posted', $comment_id, $params );
1205
 
1206
  return $comment_id;
1207
  }
@@ -1211,13 +1318,13 @@ function bp_activity_new_comment( $args = '' ) {
1211
  *
1212
  * @since BuddyPress (1.2)
1213
  *
1214
- * @param array $args See docs for $defaults for details
1215
- *
1216
  * @uses wp_parse_args()
1217
- * @uses apply_filters() To call the 'bp_activity_get_activity_id' hook
1218
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
1219
  *
1220
- * @return int $activity_id The activity id
 
1221
  */
1222
  function bp_activity_get_activity_id( $args = '' ) {
1223
  $defaults = array(
@@ -1238,7 +1345,7 @@ function bp_activity_get_activity_id( $args = '' ) {
1238
  }
1239
 
1240
  /**
1241
- * Deleting Activity
1242
  *
1243
  * If you're looking to hook into one action that provides the ID(s) of
1244
  * the activity/activities deleted, then use:
@@ -1252,19 +1359,22 @@ function bp_activity_get_activity_id( $args = '' ) {
1252
  *
1253
  * @since BuddyPress (1.0)
1254
  *
1255
- * @param array $args See docs for $defaults for details
1256
- *
1257
  * @uses wp_parse_args()
1258
  * @uses bp_activity_adjust_mention_count()
1259
  * @uses BP_Activity_Activity::delete() {@link BP_Activity_Activity}
1260
- * @uses do_action() To call the 'bp_before_activity_delete' hook
1261
  * @uses bp_get_user_meta()
1262
  * @uses bp_delete_user_meta()
1263
- * @uses do_action() To call the 'bp_activity_delete' hook
1264
- * @uses do_action() To call the 'bp_activity_deleted_activities' hook
1265
  * @uses wp_cache_delete()
1266
  *
1267
- * @return bool True on success, false on failure
 
 
 
 
1268
  */
1269
  function bp_activity_delete( $args = '' ) {
1270
 
@@ -1315,19 +1425,20 @@ function bp_activity_delete( $args = '' ) {
1315
  }
1316
 
1317
  /**
1318
- * Delete an activity item by activity id
1319
  *
1320
- * You should use bp_activity_delete() instead
1321
  *
1322
  * @since BuddyPress (1.1)
1323
  * @deprecated BuddyPress (1.2)
1324
  *
1325
- * @param array $args See docs for $defaults for details
1326
- *
1327
  * @uses wp_parse_args()
1328
  * @uses bp_activity_delete()
1329
  *
1330
- * @return bool True on success, false on failure
 
 
 
1331
  */
1332
  function bp_activity_delete_by_item_id( $args = '' ) {
1333
 
@@ -1345,77 +1456,75 @@ function bp_activity_delete( $args = '' ) {
1345
  }
1346
 
1347
  /**
1348
- * Delete an activity item by activity id
1349
- *
1350
- * You should use bp_activity_delete() instead
1351
  *
1352
  * @since BuddyPress (1.1)
1353
- * @deprecated BuddyPress (1.2)
1354
- *
1355
- * @param int $activity_id The activity id
1356
  *
1357
  * @uses bp_activity_delete()
1358
  *
1359
- * @return bool True on success, false on failure
 
1360
  */
1361
  function bp_activity_delete_by_activity_id( $activity_id ) {
1362
  return bp_activity_delete( array( 'id' => $activity_id ) );
1363
  }
1364
 
1365
  /**
1366
- * Delete an activity item by it's content
1367
  *
1368
- * You should use bp_activity_delete() instead
1369
  *
1370
  * @since BuddyPress (1.1)
1371
  * @deprecated BuddyPress (1.2)
1372
  *
1373
- * @param int $user_id The user id
1374
- * @param string $content The activity id
1375
- * @param string $component The activity component
1376
- * @param string $type The activity type
1377
- *
1378
  * @uses bp_activity_delete()
1379
  *
1380
- * @return bool True on success, false on failure
 
 
 
 
1381
  */
1382
  function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
1383
  return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) );
1384
  }
1385
 
1386
  /**
1387
- * Delete a user's activity for a component
1388
  *
1389
- * You should use bp_activity_delete() instead
1390
  *
1391
  * @since BuddyPress (1.1)
1392
  * @deprecated BuddyPress (1.2)
1393
  *
1394
- * @param int $user_id The user id
1395
- * @param string $component The activity component
1396
- *
1397
  * @uses bp_activity_delete()
1398
  *
1399
- * @return bool True on success, false on failure
 
 
1400
  */
1401
  function bp_activity_delete_for_user_by_component( $user_id, $component ) {
1402
  return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) );
1403
  }
1404
 
1405
  /**
1406
- * Delete an activity comment
1407
  *
1408
  * @since BuddyPress (1.2)
1409
  *
1410
- * @param int $activity_id The activity id
1411
- * @param int $comment_id The activity comment id
1412
- *
1413
- * @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook
1414
  * @uses bp_activity_delete_children()
1415
  * @uses bp_activity_delete()
1416
  * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
1417
- * @uses do_action() To call the 'bp_activity_delete_comment' hook
1418
- *
 
 
 
 
 
 
 
1419
  * @return bool True on success, false on failure
1420
  */
1421
  function bp_activity_delete_comment( $activity_id, $comment_id ) {
@@ -1442,16 +1551,17 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1442
  }
1443
 
1444
  /**
1445
- * Delete an activity comment's children
1446
  *
1447
  * @since BuddyPress (1.2)
1448
  *
1449
- * @param int $activity_id The activity id
1450
- * @param int $comment_id The activity comment id
1451
- *
1452
  * @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
1453
  * @uses bp_activity_delete_children()
1454
  * @uses bp_activity_delete()
 
 
 
 
1455
  */
1456
  function bp_activity_delete_children( $activity_id, $comment_id) {
1457
  // Recursively delete all children of this comment.
@@ -1464,22 +1574,22 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
1464
  }
1465
 
1466
  /**
1467
- * Get the permalink for a single activity item
1468
  *
1469
- * When only the $activity_id param is passed, BP has to instantiate a new BP_Activity_Activity
1470
- * object. To save yourself some processing overhead, be sure to pass the full $activity_obj param
1471
- * as well, if you already have it available.
 
1472
  *
1473
  * @since BuddyPress (1.2)
1474
  *
1475
- * @param int $activity_id The unique id of the activity object
1476
- * @param object $activity_obj (optional) The activity object
1477
- *
1478
  * @uses bp_get_root_domain()
1479
  * @uses bp_get_activity_root_slug()
1480
- * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook
1481
  *
1482
- * @return string $link Permalink for the activity item
 
 
1483
  */
1484
  function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
1485
 
@@ -1504,34 +1614,41 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
1504
  }
1505
 
1506
  /**
1507
- * Hide a user's activity
1508
  *
1509
  * @since BuddyPress (1.2)
1510
  *
1511
- * @param int $user_id The user id
1512
- *
1513
  * @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
1514
  *
1515
- * @return bool True on success, false on failure
 
1516
  */
1517
  function bp_activity_hide_user_activity( $user_id ) {
1518
  return BP_Activity_Activity::hide_all_for_user( $user_id );
1519
  }
1520
 
1521
  /**
1522
- * Take content, remove all images and replace them with one thumbnail image.
1523
  *
1524
- * @since BuddyPress (1.2)
 
 
 
 
 
1525
  *
1526
- * @param string $content The content to work with
1527
- * @param string $link Optional. The URL that the image should link to
1528
- * @param array $activity_args Optional. The args passed to the activity
1529
- * creation function (eg bp_blogs_record_activity())
1530
  *
1531
  * @uses esc_attr()
1532
  * @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook
1533
  *
1534
- * @return string $content The content with images stripped and replaced with a single thumb.
 
 
 
 
 
 
1535
  */
1536
  function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
1537
 
@@ -1561,11 +1678,10 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
1561
  $ratio = (int) $width / (int) $height;
1562
  $new_height = (int) $height >= 100 ? 100 : $height;
1563
  $new_width = $new_height * $ratio;
1564
-
1565
- $image = '<img src="' . esc_attr( $src ) . '" width="' . $new_width . '" height="' . $new_height . '" alt="' . __( 'Thumbnail', 'buddypress' ) . '" class="align-left thumbnail" />';
1566
 
1567
  if ( !empty( $link ) ) {
1568
- $image = '<a href="' . $link . '">' . $image . '</a>';
1569
  }
1570
 
1571
  $content = $image . $content;
@@ -1576,23 +1692,27 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
1576
  }
1577
 
1578
  /**
1579
- * Convenience function to control whether the current user is allowed to mark activity items as spam
1580
  *
1581
- * @return bool True if user is allowed to mark activity items as spam
1582
  * @since BuddyPress (1.6)
1583
- * @static
 
1584
  */
1585
  function bp_activity_user_can_mark_spam() {
1586
  return apply_filters( 'bp_activity_user_can_mark_spam', bp_current_user_can( 'bp_moderate' ) );
1587
  }
1588
 
1589
  /**
1590
- * Mark activity item as spam
1591
  *
1592
- * @global object $bp BuddyPress global settings
1593
- * @param BP_Activity_Activity $activity
1594
- * @param string $source Optional; default is "by_a_person" (e.g. a person has manually marked the activity as spam).
1595
  * @since BuddyPress (1.6)
 
 
 
 
 
 
 
1596
  */
1597
  function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
1598
  global $bp;
@@ -1623,12 +1743,16 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
1623
  }
1624
 
1625
  /**
1626
- * Mark activity item as ham
1627
  *
1628
- * @global object $bp BuddyPress global settings
1629
- * @param BP_Activity_Activity $activity
1630
- * @param string $source Optional; default is "by_a_person" (e.g. a person has manually marked the activity as spam).
1631
  * @since BuddyPress (1.6)
 
 
 
 
 
 
 
1632
  */
1633
  function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
1634
  global $bp;
@@ -1662,8 +1786,11 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
1662
  /** Embeds *******************************************************************/
1663
 
1664
  /**
1665
- * Grabs the activity update ID and attempts to retrieve the oEmbed cache (if it exists)
1666
- * during the activity loop. If no cache and link is embeddable, cache it.
 
 
 
1667
  *
1668
  * This does not cover recursive activity comments, as they do not use a real loop.
1669
  * For that, see {@link bp_activity_comment_embed()}.
@@ -1673,10 +1800,9 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
1673
  * @see BP_Embed
1674
  * @see bp_embed_activity_cache()
1675
  * @see bp_embed_activity_save_cache()
1676
- *
1677
- * @uses add_filter() To attach 'bp_get_activity_id' to 'embed_post_id'
1678
- * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'
1679
- * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'
1680
  */
1681
  function bp_activity_embed() {
1682
  add_filter( 'embed_post_id', 'bp_get_activity_id' );
@@ -1686,19 +1812,21 @@ function bp_activity_embed() {
1686
  add_action( 'activity_loop_start', 'bp_activity_embed' );
1687
 
1688
  /**
1689
- * Grabs the activity comment ID and attempts to retrieve the oEmbed cache (if it exists)
1690
- * when BP is recursing through activity comments {@link bp_activity_recurse_comments()}.
1691
- * If no cache and link is embeddable, cache it.
 
 
 
1692
  *
1693
  * @since BuddyPress (1.5)
1694
  *
1695
  * @see BP_Embed
1696
  * @see bp_embed_activity_cache()
1697
  * @see bp_embed_activity_save_cache()
1698
- *
1699
- * @uses add_filter() To attach 'bp_get_activity_comment_id' to 'embed_post_id'
1700
- * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'
1701
- * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'
1702
  */
1703
  function bp_activity_comment_embed() {
1704
  add_filter( 'embed_post_id', 'bp_get_activity_comment_id' );
@@ -1713,13 +1841,12 @@ add_action( 'bp_before_activity_comment', 'bp_activity_comment_embed' );
1713
  * @since BuddyPress (1.5)
1714
  *
1715
  * @see BP_Embed
1716
- *
1717
- * @param object $activity The activity that is being expanded
1718
- *
1719
  * @global object $bp BuddyPress global settings
1720
- * @uses add_filter() To attach create_function() to 'embed_post_id'
1721
- * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'
1722
- * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'
 
 
1723
  */
1724
  function bp_dtheme_embed_read_more( $activity ) {
1725
  global $bp;
@@ -1733,15 +1860,15 @@ function bp_dtheme_embed_read_more( $activity ) {
1733
  add_action( 'bp_dtheme_get_single_activity_content', 'bp_dtheme_embed_read_more' );
1734
 
1735
  /**
1736
- * Removes the 'embed_post_id' filter after {@link bp_activity_recurse_comments()}
1737
- * is rendered to avoid conflict with the 'embed_post_id' filter in
1738
- * {@link bp_activity_embed()} or any other component embeds.
 
1739
  *
1740
  * @since BuddyPress (1.5)
1741
  *
1742
  * @see bp_activity_comment_embed()
1743
- *
1744
- * @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id'
1745
  */
1746
  function bp_activity_comment_embed_after_recurse() {
1747
  remove_filter( 'embed_post_id', 'bp_get_activity_comment_id' );
@@ -1749,26 +1876,40 @@ function bp_activity_comment_embed_after_recurse() {
1749
  add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurse' );
1750
 
1751
  /**
1752
- * Wrapper function for {@link bp_activity_get_meta()}.
 
1753
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
1754
  *
1755
  * @since BuddyPress (1.5)
1756
  *
 
1757
  * @uses bp_activity_get_meta()
1758
  *
1759
- * @return mixed The activity meta
 
 
 
 
1760
  */
1761
  function bp_embed_activity_cache( $cache, $id, $cachekey ) {
1762
  return bp_activity_get_meta( $id, $cachekey );
1763
  }
1764
 
1765
  /**
1766
- * Wrapper function for {@link bp_activity_update_meta()}.
 
1767
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
1768
  *
1769
  * @since BuddyPress (1.5)
1770
  *
 
1771
  * @uses bp_activity_update_meta()
 
 
 
 
 
 
1772
  */
1773
  function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
1774
  bp_activity_update_meta( $id, $cachekey, $cache );
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Activity Functions.
5
  *
6
+ * Functions for the Activity Streams component.
7
  *
8
  * @package BuddyPress
9
  * @subpackage ActivityFunctions
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
+ * Check whether the $bp global lists an activity directory page.
17
  *
18
  * @since BuddyPress (1.5)
19
  *
20
  * @global object $bp BuddyPress global settings
21
  *
22
+ * @return bool True if activity directory page is found, otherwise false.
23
  */
24
  function bp_activity_has_directory() {
25
  global $bp;
45
  * @since BuddyPress (1.8)
46
  *
47
  * @uses apply_filters() To call 'bp_activity_do_mentions' hook.
48
+ *
49
  * @return bool $retval True to enable mentions, false to disable.
50
  */
51
  function bp_activity_do_mentions() {
53
  }
54
 
55
  /**
56
+ * Locate usernames in an activity content string, as designated by an @ sign.
 
57
  *
58
  * @since BuddyPress (1.5)
59
  *
60
  * @param string $content The content of the activity, usually found in $activity->content.
61
+ * @return array|bool Associative array with user ID as key and username as value. Boolean false if no mentions found.
62
  */
63
  function bp_activity_find_mentions( $content ) {
64
  $pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
72
 
73
  // We've found some mentions! Check to see if users exist
74
  foreach( (array) $usernames as $key => $username ) {
75
+ $user_id = bp_activity_get_userid_from_mentionname( $username );
 
 
 
 
76
 
77
  // user ID exists, so let's add it to our array
78
  if ( ! empty( $user_id ) ) {
87
  }
88
 
89
  /**
90
+ * Reset a user's unread mentions list and count.
91
  *
92
  * @since BuddyPress (1.5)
93
  *
 
94
  * @uses bp_delete_user_meta()
95
+ *
96
+ * @param int $user_id The id of the user whose unread mentions are being reset.
97
  */
98
  function bp_activity_clear_new_mentions( $user_id ) {
99
  bp_delete_user_meta( $user_id, 'bp_new_mention_count' );
110
  *
111
  * @since BuddyPress (1.5)
112
  *
 
 
 
113
  * @uses bp_activity_find_mentions()
114
  * @uses bp_activity_update_mention_count_for_user()
115
+ *
116
+ * @param int $activity_id The unique id for the activity item.
117
+ * @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
118
  */
119
  function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
120
  if ( empty( $activity_id ) )
137
  }
138
 
139
  /**
140
+ * Update the mention count for a given user.
141
  *
142
  * This function should be used when you've already parsed your activity item
143
  * for @mentions.
144
  *
145
  * @since BuddyPress (1.7)
146
  *
 
 
 
 
147
  * @uses bp_get_user_meta()
148
  * @uses bp_update_user_meta()
149
+ *
150
+ * @param int $user_id The user ID.
151
+ * @param int $activity_id The unique ID for the activity item.
152
+ * @param string $action 'delete' or 'add'. Default: 'add'.
153
  * @return bool
154
  */
155
  function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
191
  }
192
 
193
  /**
194
+ * Format notifications related to activity.
195
  *
196
  * @since BuddyPress (1.5)
197
  *
 
 
 
 
 
 
198
  * @uses bp_loggedin_user_domain()
199
  * @uses bp_get_activity_slug()
200
  * @uses bp_core_get_user_displayname()
201
+ * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook.
202
+ * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
203
+ * @uses do_action() To call 'activity_format_notifications' hook.
204
+ *
205
+ * @param string $action The type of activity item. Just 'new_at_mention' for now.
206
+ * @param int $item_id The activity ID.
207
+ * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
208
+ * @param int $total_items The total number of notifications to format.
209
+ * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
210
+ * @return string $return Formatted @mention notification.
211
  */
212
  function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
213
 
243
  return $return;
244
  }
245
 
246
+ /**
247
+ * Determine a user's "mentionname", the name used for that user in @-mentions.
248
+ *
249
+ * @since BuddyPress (1.9.0)
250
+ *
251
+ * @return string User name appropriate for @-mentions.
252
+ */
253
+ function bp_activity_get_user_mentionname( $user_id ) {
254
+ $mentionname = '';
255
+
256
+ $userdata = bp_core_get_core_userdata( $user_id );
257
+
258
+ if ( $userdata ) {
259
+ if ( bp_is_username_compatibility_mode() ) {
260
+ $mentionname = str_replace( ' ', '-', $userdata->user_login );
261
+ } else {
262
+ $mentionname = $userdata->user_nicename;
263
+ }
264
+ }
265
+
266
+ return $mentionname;
267
+ }
268
+
269
+ /**
270
+ * Get a user ID from a "mentionname", the name used for a user in @-mentions.
271
+ *
272
+ * @since BuddyPress (1.9.0)
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
290
+ // account for hyphens + spaces in the same user_login.
291
+ if ( empty( $userdata ) || ! is_a( $userdata, 'WP_User' ) ) {
292
+ global $wpdb;
293
+ $regex = esc_sql( str_replace( '-', '[ \-]', $mentionname ) );
294
+ $user_id = $wpdb->get_var( "SELECT ID FROM {$wpdb->users} WHERE user_login REGEXP '{$regex}'" );
295
+ } else {
296
+ $user_id = $userdata->ID;
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
+ }
304
+
305
+
306
+ return $user_id;
307
+ }
308
+
309
  /** Actions ******************************************************************/
310
 
311
  /**
312
+ * Set the current action for a given activity stream location.
313
  *
314
  * @since BuddyPress (1.1)
315
  *
 
 
 
 
316
  * @global object $bp BuddyPress global settings
317
  * @uses apply_filters() To call the 'bp_activity_set_action' hook
318
  *
319
+ * @param string $component_id The unique string ID of the component.
320
+ * @param string $key The action key.
321
+ * @param string $value The action value.
322
+ * @return bool False if any param is empty, otherwise true.
323
  */
324
  function bp_activity_set_action( $component_id, $key, $value ) {
325
  global $bp;
346
  }
347
 
348
  /**
349
+ * Retreive the current action from a component and key.
350
  *
351
  * @since BuddyPress (1.1)
352
  *
353
+ * @global object $bp BuddyPress global settings.
354
+ * @uses apply_filters() To call the 'bp_activity_get_action' hook.
 
 
 
355
  *
356
+ * @param string $component_id The unique string ID of the component.
357
+ * @param string $key The action key.
358
+ * @return string|bool Action value if found, otherwise false.
359
  */
360
  function bp_activity_get_action( $component_id, $key ) {
361
  global $bp;
368
  }
369
 
370
  /**
371
+ * Fetch details of all registered activity types.
372
  *
 
373
  * @since BuddyPress (1.7)
374
+ *
375
+ * @return array array( type => description ), ...
376
  */
377
  function bp_activity_get_types() {
378
  $actions = array();
397
  /** Favorites ****************************************************************/
398
 
399
  /**
400
+ * Get a users favorite activity stream items.
401
  *
402
  * @since BuddyPress (1.2)
403
  *
 
 
404
  * @uses bp_get_user_meta()
405
+ * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
406
  *
407
+ * @param int $user_id ID of the user whose favorites are being queried.
408
+ * @return array IDs of the user's favorite activity items.
409
  */
410
  function bp_activity_get_user_favorites( $user_id = 0 ) {
411
 
420
  }
421
 
422
  /**
423
+ * Add an activity stream item as a favorite for a user.
424
  *
425
  * @since BuddyPress (1.2)
426
  *
 
 
 
427
  * @uses is_user_logged_in()
428
  * @uses bp_get_user_meta()
429
  * @uses bp_activity_get_meta()
430
  * @uses bp_update_user_meta()
431
  * @uses bp_activity_update_meta()
432
+ * @uses do_action() To call the 'bp_activity_add_user_favorite' hook.
433
+ * @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook.
434
  *
435
+ * @param int $activity_id ID of the activity item being favorited.
436
+ * @param int $user_id ID of the user favoriting the activity item.
437
+ * @return bool True on success, false on failure.
438
  */
439
  function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
440
 
476
  }
477
 
478
  /**
479
+ * Remove an activity stream item as a favorite for a user.
480
  *
481
  * @since BuddyPress (1.2)
482
  *
 
 
 
483
  * @uses is_user_logged_in()
484
  * @uses bp_get_user_meta()
485
  * @uses bp_activity_get_meta()
486
  * @uses bp_activity_update_meta()
487
  * @uses bp_update_user_meta()
488
+ * @uses do_action() To call the 'bp_activity_remove_user_favorite' hook.
489
  *
490
+ * @param int $activity_id ID of the activity item being unfavorited.
491
+ * @param int $user_id ID of the user unfavoriting the activity item.
492
+ * @return bool True on success, false on failure.
493
  */
494
  function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
495
 
539
  }
540
 
541
  /**
542
+ * Check whether an activity item exists with a given content string.
543
  *
544
  * @since BuddyPress (1.1)
545
  *
 
 
546
  * @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity}
547
+ * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
548
  *
549
+ * @param string $content The content to filter by.
550
+ * @return int|null The ID of the located activity item. Null if none is found.
551
  */
552
  function bp_activity_check_exists_by_content( $content ) {
553
  return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
554
  }
555
 
556
  /**
557
+ * Retrieve the last time activity was updated.
558
  *
559
  * @since BuddyPress (1.0)
560
  *
561
  * @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity}
562
+ * @uses apply_filters() To call the 'bp_activity_get_last_updated' hook.
563
  *
564
+ * @return string Date last updated.
565
  */
566
  function bp_activity_get_last_updated() {
567
  return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
568
  }
569
 
570
  /**
571
+ * Retrieve the number of favorite activity stream items a user has.
572
  *
573
  * @since BuddyPress (1.2)
574
  *
 
 
575
  * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
576
  *
577
+ * @param int $user_id ID of the user whose favorite count is being requested.
578
+ * @return int Total favorite count for the user.
579
  */
580
  function bp_activity_total_favorites_for_user( $user_id = 0 ) {
581
 
589
  /** Meta *********************************************************************/
590
 
591
  /**
592
+ * Delete a meta entry from the DB for an activity stream item.
593
  *
594
  * @since BuddyPress (1.2)
595
  *
596
+ * @global object $wpdb WordPress database access object.
597
+ * @global object $bp BuddyPress global settings.
 
 
 
 
598
  * @uses wp_cache_delete()
599
  * @uses is_wp_error()
600
  *
601
+ * @param int $activity_id ID of the activity item whose metadata is being deleted.
602
+ * @param string $meta_key Optional. The key of the metadata being deleted. If
603
+ * omitted, all metadata associated with the activity
604
+ * item will be deleted.
605
+ * @param string $meta_value Optional. If present, the metadata will only be
606
+ * deleted if the meta_value matches this parameter.
607
+ * @return bool True on success, false on failure.
608
  */
609
  function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '' ) {
610
  global $wpdb, $bp;
647
  }
648
 
649
  /**
650
+ * Get metadata for a given activity item.
651
  *
652
  * @since BuddyPress (1.2)
653
  *
654
+ * @global object $wpdb WordPress database access object.
655
+ * @global object $bp BuddyPress global settings.
 
 
 
656
  * @uses wp_cache_get()
657
  * @uses wp_cache_set()
658
+ * @uses apply_filters() To call the 'bp_activity_get_meta' hook.
659
  *
660
+ * @param int $activity_id ID of the activity item whose metadata is being requseted.
661
+ * @param string $meta_key Optional. If present, only the metadata matching
662
+ * that meta key will be returned. Otherwise, all
663
+ * metadata for the activity item will be fetched.
664
+ * @return mixed The meta value(s) being requested.
665
  */
666
  function bp_activity_get_meta( $activity_id = 0, $meta_key = '' ) {
667
  global $wpdb, $bp;
713
  }
714
 
715
  /**
716
+ * Update a piece of activity meta.
717
  *
718
  * @since BuddyPress (1.2)
719
  *
720
+ * @global object $wpdb WordPress database access object.
721
+ * @global object $bp BuddyPress global settings.
 
 
 
 
722
  * @uses maybe_serialize()
723
  * @uses bp_activity_delete_meta()
724
  * @uses wp_cache_set()
725
  *
726
+ * @param int $activity_id ID of the activity item whose metadata is being updated.
727
+ * @param string $meta_key Key of the metadata being updated.
728
+ * @param mixed $meta_value Value to be set.
729
+ * @return bool True on success, false on failure.
730
  */
731
  function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
732
  global $wpdb, $bp;
739
  $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
740
 
741
  // Sanitize value
742
+ if ( is_string( $meta_value ) ) {
743
+ $meta_value = stripslashes( $meta_value );
744
+ }
745
 
746
  // Maybe, just maybe... serialize
747
  $meta_value = maybe_serialize( $meta_value );
748
 
749
+ // If value is false, delete the meta key
750
+ if ( false === $meta_value )
751
  return bp_activity_delete_meta( $activity_id, $meta_key );
752
 
753
  // See if meta key exists for activity_id
775
  /** Clean up *****************************************************************/
776
 
777
  /**
778
+ * Completely remove a user's activity data.
779
  *
780
  * @since BuddyPress (1.5)
781
  *
 
 
782
  * @uses is_user_logged_in()
783
  * @uses bp_activity_delete()
784
  * @uses bp_delete_user_meta()
785
+ * @uses do_action() To call the 'bp_activity_remove_data' hook.
786
+ * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook.
787
+ *
788
+ * @param int $user_id ID of the user whose activity is being deleted.
789
  */
790
  function bp_activity_remove_all_user_data( $user_id = 0 ) {
791
 
810
  add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
811
 
812
  /**
813
+ * Mark all of the user's activity as spam.
814
  *
 
 
 
815
  * @since BuddyPress (1.6)
816
+ *
817
+ * @global object $wpdb WordPress database access object.
818
+ * @global object $bp BuddyPress global settings.
819
+ *
820
+ * @param int $user_id ID of the user whose activity is being spammed.
821
  */
822
  function bp_activity_spam_all_user_data( $user_id = 0 ) {
823
  global $bp, $wpdb;
863
  add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
864
 
865
  /**
866
+ * Mark all of the user's activity as ham (not spam).
867
  *
 
 
 
868
  * @since BuddyPress (1.6)
869
+ *
870
+ * @global object $wpdb WordPress database access object.
871
+ * @global object $bp BuddyPress global settings.
872
+ *
873
+ * @param int $user_id ID of the user whose activity is being hammed.
874
  */
875
  function bp_activity_ham_all_user_data( $user_id = 0 ) {
876
  global $bp, $wpdb;
918
  /**
919
  * Register the activity stream actions for updates
920
  *
 
921
  * @since BuddyPress (1.6)
922
+ *
923
+ * @global object $bp BuddyPress global settings.
924
  */
925
  function bp_activity_register_activity_actions() {
926
  global $bp;
943
  */
944
 
945
  /**
946
+ * Retrieve an activity or activities.
947
  *
948
+ * bp_activity_get() shares all arguments with BP_Activity_Activity::get(). The
949
+ * following is a list of bp_activity_get() parameters that have different
950
+ * default values from BP_Activity_Activity::get() (value in parentheses is
951
+ * the default for the bp_activity_get()).
952
+ * - 'per_page' (false)
953
  *
954
+ * @since BuddyPress (1.2)
955
  *
956
+ * @see BP_Activity_Activity::get() For more information on accepted arguments
957
+ * and the format of the returned value.
958
  * @uses wp_parse_args()
959
  * @uses wp_cache_get()
960
  * @uses wp_cache_set()
961
  * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
962
+ * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
963
  *
964
+ * @param array $args See BP_Activity_Activity::get() for description.
965
+ * @return array $activity See BP_Activity_Activity::get() for description.
966
  */
967
  function bp_activity_get( $args = '' ) {
968
  $defaults = array(
1035
  }
1036
 
1037
  /**
1038
+ * Fetch specific activity items.
1039
  *
1040
  * @since BuddyPress (1.2)
1041
  *
1042
+ * @see BP_Activity_Activity::get() For more information on accepted arguments
 
1043
  * @uses wp_parse_args()
1044
  * @uses apply_filters() To call the 'bp_activity_get_specific' hook
1045
  * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
1046
  *
1047
+ * @param array $args {
1048
+ * All arguments and defaults are shared with BP_Activity_Activity::get(),
1049
+ * except for the following:
1050
+ * @type string|int|array Single activity ID, comma-separated list of IDs,
1051
+ * or array of IDs.
1052
+ * }
1053
+ * @return array $activity See BP_Activity_Activity::get() for description.
1054
  */
1055
  function bp_activity_get_specific( $args = '' ) {
1056
  $defaults = array(
1080
  }
1081
 
1082
  /**
1083
+ * Add an activity item.
1084
  *
1085
  * @since BuddyPress (1.1)
1086
  *
 
 
1087
  * @uses wp_parse_args()
1088
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
1089
  * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
1090
  * @uses wp_cache_delete()
1091
  * @uses do_action() To call the 'bp_activity_add' hook
1092
  *
1093
+ * @param array $args {
1094
+ * An array of arguments.
1095
+ * @type int|bool $id Pass an activity ID to update an existing item, or
1096
+ * false to create a new item. Default: false.
1097
+ * @type string $action Optional. The activity action/description, typically
1098
+ * something like "Joe posted an update".
1099
+ * @type string $content Optional. The content of the activity item.
1100
+ * @type string $component The unique name of the component associated with
1101
+ * the activity item - 'groups', 'profile', etc.
1102
+ * @type string $type The specific activity type, used for directory
1103
+ * filtering. 'new_blog_post', 'activity_update', etc.
1104
+ * @type string $primary_link Optional. The URL for this item, as used in
1105
+ * RSS feeds. Defaults to the URL for this activity item's permalink page.
1106
+ * @type int|bool $user_id Optional. The ID of the user associated with the
1107
+ * activity item. May be set to false or 0 if the item is not related
1108
+ * to any user. Default: the ID of the currently logged-in user.
1109
+ * @type int $item_id Optional. The ID of the associated item.
1110
+ * @type int $secondary_item_id Optional. The ID of a secondary associated
1111
+ * item.
1112
+ * @type string $date_recorded Optional. The GMT time, in Y-m-d h:i:s format,
1113
+ * when the item was recorded. Defaults to the current time.
1114
+ * @type bool $hide_sitewide Should the item be hidden on sitewide streams?
1115
+ * Default: false.
1116
+ * @type bool $is_spam Should the item be marked as spam? Default: false.
1117
+ * }
1118
+ * @return int|bool The ID of the activity on success. False on error.
1119
  */
1120
  function bp_activity_add( $args = '' ) {
1121
 
1174
  }
1175
 
1176
  /**
1177
+ * Post an activity update.
1178
  *
1179
  * @since BuddyPress (1.2)
1180
  *
1181
+ * @global object $bp BuddyPress global settings.
 
 
1182
  * @uses wp_parse_args()
1183
  * @uses bp_is_user_inactive()
1184
  * @uses bp_core_get_userlink()
1185
  * @uses bp_activity_add()
1186
+ * @uses apply_filters() To call the 'bp_activity_new_update_action' hook.
1187
+ * @uses apply_filters() To call the 'bp_activity_new_update_content' hook.
1188
+ * @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook.
1189
  * @uses bp_update_user_meta()
1190
  * @uses wp_filter_kses()
1191
+ * @uses do_action() To call the 'bp_activity_posted_update' hook.
1192
  *
1193
+ * @param array $args {
1194
+ * @type string $content The content of the activity update.
1195
+ * @type int $user_id Optional. Defaults to the logged-in user.
1196
+ * }
1197
  * @return int $activity_id The activity id
1198
  */
1199
  function bp_activity_post_update( $args = '' ) {
1239
  }
1240
 
1241
  /**
1242
+ * Add an activity comment.
1243
  *
1244
  * @since BuddyPress (1.2)
1245
  *
1246
+ * @global object $bp BuddyPress global settings.
 
 
1247
  * @uses wp_parse_args()
1248
  * @uses bp_activity_add()
1249
+ * @uses apply_filters() To call the 'bp_activity_comment_action' hook.
1250
+ * @uses apply_filters() To call the 'bp_activity_comment_content' hook.
1251
  * @uses bp_activity_new_comment_notification()
1252
  * @uses wp_cache_delete()
1253
+ * @uses do_action() To call the 'bp_activity_comment_posted' hook.
1254
+ *
1255
+ * @param array $args {
1256
+ * @type int $id Optional. Pass an ID to update an existing comment.
1257
+ * @type string $content The content of the comment.
1258
+ * @type int $user_id Optional. The ID of the user making the comment.
1259
+ * Defaults to the ID of the logged-in user.
1260
+ * @type int $activity_id The ID of the "root" activity item, ie the oldest
1261
+ * ancestor of the comment.
1262
+ * @type int $parent_id Optional. The ID of the parent activity item, ie the
1263
+ * item to which the comment is an immediate reply. If
1264
+ * not provided, this value defaults to the $activity_id.
1265
+ * }
1266
+ * @return int|bool The ID of the comment on success, otherwise false.
1267
  */
1268
  function bp_activity_new_comment( $args = '' ) {
1269
  global $bp;
1308
  // Clear the comment cache for this activity
1309
  wp_cache_delete( 'bp_activity_comments_' . $parent_id );
1310
 
1311
+ do_action( 'bp_activity_comment_posted', $comment_id, $params, $activity );
1312
 
1313
  return $comment_id;
1314
  }
1318
  *
1319
  * @since BuddyPress (1.2)
1320
  *
1321
+ * @see BP_Activity_Activity::get() For more information on accepted arguments.
 
1322
  * @uses wp_parse_args()
1323
+ * @uses apply_filters() To call the 'bp_activity_get_activity_id' hook.
1324
  * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
1325
  *
1326
+ * @param array $args See BP_Activity_Activity::get() for description.
1327
+ * @return int $activity_id The ID of the activity item found.
1328
  */
1329
  function bp_activity_get_activity_id( $args = '' ) {
1330
  $defaults = array(
1345
  }
1346
 
1347
  /**
1348
+ * Delete activity item(s).
1349
  *
1350
  * If you're looking to hook into one action that provides the ID(s) of
1351
  * the activity/activities deleted, then use:
1359
  *
1360
  * @since BuddyPress (1.0)
1361
  *
1362
+ * @see BP_Activity_Activity::get() For more information on accepted arguments.
 
1363
  * @uses wp_parse_args()
1364
  * @uses bp_activity_adjust_mention_count()
1365
  * @uses BP_Activity_Activity::delete() {@link BP_Activity_Activity}
1366
+ * @uses do_action() To call the 'bp_before_activity_delete' hook.
1367
  * @uses bp_get_user_meta()
1368
  * @uses bp_delete_user_meta()
1369
+ * @uses do_action() To call the 'bp_activity_delete' hook.
1370
+ * @uses do_action() To call the 'bp_activity_deleted_activities' hook.
1371
  * @uses wp_cache_delete()
1372
  *
1373
+ * @param array $args To delete specific activity items, use
1374
+ * $args = array( 'id' => $ids );
1375
+ * Otherwise, to use filters for item deletion, the argument format is
1376
+ * the same as BP_Activity_Activity::get(). See that method for a description.
1377
+ * @return bool True on success, false on failure.
1378
  */
1379
  function bp_activity_delete( $args = '' ) {
1380
 
1425
  }
1426
 
1427
  /**
1428
+ * Delete an activity item by activity id.
1429
  *
1430
+ * You should use bp_activity_delete() instead.
1431
  *
1432
  * @since BuddyPress (1.1)
1433
  * @deprecated BuddyPress (1.2)
1434
  *
 
 
1435
  * @uses wp_parse_args()
1436
  * @uses bp_activity_delete()
1437
  *
1438
+ * @param array $args See BP_Activity_Activity::get for a description
1439
+ * of accepted arguments.
1440
+ *
1441
+ * @return bool True on success, false on failure.
1442
  */
1443
  function bp_activity_delete_by_item_id( $args = '' ) {
1444
 
1456
  }
1457
 
1458
  /**
1459
+ * Delete an activity item by activity id.
 
 
1460
  *
1461
  * @since BuddyPress (1.1)
 
 
 
1462
  *
1463
  * @uses bp_activity_delete()
1464
  *
1465
+ * @param int ID of the activity item to be deleted.
1466
+ * @return bool True on success, false on failure.
1467
  */
1468
  function bp_activity_delete_by_activity_id( $activity_id ) {
1469
  return bp_activity_delete( array( 'id' => $activity_id ) );
1470
  }
1471
 
1472
  /**
1473
+ * Delete an activity item by its content.
1474
  *
1475
+ * You should use bp_activity_delete() instead.
1476
  *
1477
  * @since BuddyPress (1.1)
1478
  * @deprecated BuddyPress (1.2)
1479
  *
 
 
 
 
 
1480
  * @uses bp_activity_delete()
1481
  *
1482
+ * @param int $user_id The user id.
1483
+ * @param string $content The activity id.
1484
+ * @param string $component The activity component.
1485
+ * @param string $type The activity type.
1486
+ * @return bool True on success, false on failure.
1487
  */
1488
  function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
1489
  return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) );
1490
  }
1491
 
1492
  /**
1493
+ * Delete a user's activity for a component.
1494
  *
1495
+ * You should use bp_activity_delete() instead.
1496
  *
1497
  * @since BuddyPress (1.1)
1498
  * @deprecated BuddyPress (1.2)
1499
  *
 
 
 
1500
  * @uses bp_activity_delete()
1501
  *
1502
+ * @param int $user_id The user id.
1503
+ * @param string $component The activity component.
1504
+ * @return bool True on success, false on failure.
1505
  */
1506
  function bp_activity_delete_for_user_by_component( $user_id, $component ) {
1507
  return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) );
1508
  }
1509
 
1510
  /**
1511
+ * Delete an activity comment.
1512
  *
1513
  * @since BuddyPress (1.2)
1514
  *
1515
+ * @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook.
 
 
 
1516
  * @uses bp_activity_delete_children()
1517
  * @uses bp_activity_delete()
1518
  * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
1519
+ * @uses do_action() To call the 'bp_activity_delete_comment' hook.
1520
+ * @todo Why is an activity id required? We could look this up.
1521
+ * @todo Why do we encourage users to call this function directly? We could just
1522
+ * as easily examine the activity type in bp_activity_delete() and then
1523
+ * call this function with the proper arguments if necessary.
1524
+ *
1525
+ * @param int $activity_id The ID of the "root" activity, ie the comment's
1526
+ * oldest ancestor.
1527
+ * @param int $comment_id The ID of the comment to be deleted.
1528
  * @return bool True on success, false on failure
1529
  */
1530
  function bp_activity_delete_comment( $activity_id, $comment_id ) {
1551
  }
1552
 
1553
  /**
1554
+ * Delete an activity comment's children.
1555
  *
1556
  * @since BuddyPress (1.2)
1557
  *
 
 
 
1558
  * @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
1559
  * @uses bp_activity_delete_children()
1560
  * @uses bp_activity_delete()
1561
+ *
1562
+ * @param int $activity_id The ID of the "root" activity, ie the
1563
+ * comment's oldest ancestor.
1564
+ * @param int $comment_id The ID of the comment to be deleted.
1565
  */
1566
  function bp_activity_delete_children( $activity_id, $comment_id) {
1567
  // Recursively delete all children of this comment.
1574
  }
1575
 
1576
  /**
1577
+ * Get the permalink for a single activity item.
1578
  *
1579
+ * When only the $activity_id param is passed, BP has to instantiate a new
1580
+ * BP_Activity_Activity object. To save yourself some processing overhead,
1581
+ * be sure to pass the full $activity_obj parameter as well, if you already
1582
+ * have it available.
1583
  *
1584
  * @since BuddyPress (1.2)
1585
  *
 
 
 
1586
  * @uses bp_get_root_domain()
1587
  * @uses bp_get_activity_root_slug()
1588
+ * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook.
1589
  *
1590
+ * @param int $activity_id The unique id of the activity object.
1591
+ * @param object $activity_obj Optional. The activity object.
1592
+ * @return string $link Permalink for the activity item.
1593
  */
1594
  function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
1595
 
1614
  }
1615
 
1616
  /**
1617
+ * Hide a user's activity.
1618
  *
1619
  * @since BuddyPress (1.2)
1620
  *
 
 
1621
  * @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
1622
  *
1623
+ * @param int $user_id The ID of the user whose activity is being hidden.
1624
+ * @return bool True on success, false on failure.
1625
  */
1626
  function bp_activity_hide_user_activity( $user_id ) {
1627
  return BP_Activity_Activity::hide_all_for_user( $user_id );
1628
  }
1629
 
1630
  /**
1631
+ * Take content, remove images, and replace them with a single thumbnail image.
1632
  *
1633
+ * The format of items in the activity stream is such that we do not want to
1634
+ * allow an arbitrary number of arbitrarily large images to be rendered.
1635
+ * However, the activity stream is built to elegantly display a single
1636
+ * thumbnail corresponding to the activity comment. This function looks
1637
+ * through the content, grabs the first image and converts it to a thumbnail,
1638
+ * and removes the rest of the images from the string.
1639
  *
1640
+ * @since BuddyPress (1.2)
 
 
 
1641
  *
1642
  * @uses esc_attr()
1643
  * @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook
1644
  *
1645
+ * @param string $content The content of the activity item.
1646
+ * @param string $link Optional. The unescaped URL that the image should link
1647
+ * to. If absent, the image will not be a link.
1648
+ * @param array $activity_args Optional. The args passed to the activity
1649
+ * creation function (eg bp_blogs_record_activity()).
1650
+ * @return string $content The content with images stripped and replaced with a
1651
+ * single thumb.
1652
  */
1653
  function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
1654
 
1678
  $ratio = (int) $width / (int) $height;
1679
  $new_height = (int) $height >= 100 ? 100 : $height;
1680
  $new_width = $new_height * $ratio;
1681
+ $image = '<img src="' . esc_url( $src ) . '" width="' . absint( $new_width ) . '" height="' . absint( $new_height ) . '" alt="' . __( 'Thumbnail', 'buddypress' ) . '" class="align-left thumbnail" />';
 
1682
 
1683
  if ( !empty( $link ) ) {
1684
+ $image = '<a href="' . esc_url( $link ) . '">' . $image . '</a>';
1685
  }
1686
 
1687
  $content = $image . $content;
1692
  }
1693
 
1694
  /**
1695
+ * Fetch whether the current user is allowed to mark items as spam.
1696
  *
 
1697
  * @since BuddyPress (1.6)
1698
+ *
1699
+ * @return bool True if user is allowed to mark activity items as spam.
1700
  */
1701
  function bp_activity_user_can_mark_spam() {
1702
  return apply_filters( 'bp_activity_user_can_mark_spam', bp_current_user_can( 'bp_moderate' ) );
1703
  }
1704
 
1705
  /**
1706
+ * Mark an activity item as spam.
1707
  *
 
 
 
1708
  * @since BuddyPress (1.6)
1709
+ *
1710
+ * @global object $bp BuddyPress global settings.
1711
+ *
1712
+ * @param BP_Activity_Activity $activity The activity item to be spammed.
1713
+ * @param string $source Optional. Default is "by_a_person" (ie, a person has
1714
+ * manually marked the activity as spam). BP core also
1715
+ * accepts 'by_akismet'.
1716
  */
1717
  function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
1718
  global $bp;
1743
  }
1744
 
1745
  /**
1746
+ * Mark an activity item as ham.
1747
  *
 
 
 
1748
  * @since BuddyPress (1.6)
1749
+ *
1750
+ * @global object $bp BuddyPress global settings.
1751
+ *
1752
+ * @param BP_Activity_Activity $activity The activity item to be hammed.
1753
+ * @param string $source Optional. Default is "by_a_person" (ie, a person has
1754
+ * manually marked the activity as spam). BP core also
1755
+ * accepts 'by_akismet'.
1756
  */
1757
  function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
1758
  global $bp;
1786
  /** Embeds *******************************************************************/
1787
 
1788
  /**
1789
+ * Set up activity oEmbed cache during the activity loop.
1790
+ *
1791
+ * During an activity loop, this function sets up the hooks necessary to grab
1792
+ * each item's embeds from the cache, or put them in the cache if they are
1793
+ * not there yet.
1794
  *
1795
  * This does not cover recursive activity comments, as they do not use a real loop.
1796
  * For that, see {@link bp_activity_comment_embed()}.
1800
  * @see BP_Embed
1801
  * @see bp_embed_activity_cache()
1802
  * @see bp_embed_activity_save_cache()
1803
+ * @uses add_filter() To attach 'bp_get_activity_id' to 'embed_post_id'.
1804
+ * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
1805
+ * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
 
1806
  */
1807
  function bp_activity_embed() {
1808
  add_filter( 'embed_post_id', 'bp_get_activity_id' );
1812
  add_action( 'activity_loop_start', 'bp_activity_embed' );
1813
 
1814
  /**
1815
+ * Set up activity oEmbed cache while recursing through activity comments.
1816
+ *
1817
+ * While crawling through an activity comment tree
1818
+ * ({@link bp_activity_recurse_comments}), this function sets up the hooks
1819
+ * necessary to grab each comment's embeds from the cache, or put them in
1820
+ * the cache if they are not there yet.
1821
  *
1822
  * @since BuddyPress (1.5)
1823
  *
1824
  * @see BP_Embed
1825
  * @see bp_embed_activity_cache()
1826
  * @see bp_embed_activity_save_cache()
1827
+ * @uses add_filter() To attach 'bp_get_activity_comment_id' to 'embed_post_id'.
1828
+ * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
1829
+ * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
 
1830
  */
1831
  function bp_activity_comment_embed() {
1832
  add_filter( 'embed_post_id', 'bp_get_activity_comment_id' );
1841
  * @since BuddyPress (1.5)
1842
  *
1843
  * @see BP_Embed
 
 
 
1844
  * @global object $bp BuddyPress global settings
1845
+ * @uses add_filter() To attach create_function() to 'embed_post_id'.
1846
+ * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
1847
+ * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
1848
+ *
1849
+ * @param object $activity The activity that is being expanded.
1850
  */
1851
  function bp_dtheme_embed_read_more( $activity ) {
1852
  global $bp;
1860
  add_action( 'bp_dtheme_get_single_activity_content', 'bp_dtheme_embed_read_more' );
1861
 
1862
  /**
1863
+ * Clean up 'embed_post_id' filter after comment recursion.
1864
+ *
1865
+ * This filter must be removed so that the non-comment filters take over again
1866
+ * once the comments are done being processed.
1867
  *
1868
  * @since BuddyPress (1.5)
1869
  *
1870
  * @see bp_activity_comment_embed()
1871
+ * @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id'.
 
1872
  */
1873
  function bp_activity_comment_embed_after_recurse() {
1874
  remove_filter( 'embed_post_id', 'bp_get_activity_comment_id' );
1876
  add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurse' );
1877
 
1878
  /**
1879
+ * Fetch an activity item's cached embeds.
1880
+ *
1881
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
1882
  *
1883
  * @since BuddyPress (1.5)
1884
  *
1885
+ * @see BP_Embed::parse_oembed()
1886
  * @uses bp_activity_get_meta()
1887
  *
1888
+ * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
1889
+ * functions like this one to filter.
1890
+ * @param int $id The ID of the activity item.
1891
+ * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
1892
+ * @return mixed The cached embeds for this activity item.
1893
  */
1894
  function bp_embed_activity_cache( $cache, $id, $cachekey ) {
1895
  return bp_activity_get_meta( $id, $cachekey );
1896
  }
1897
 
1898
  /**
1899
+ * Set an activity item's embed cache.
1900
+ *
1901
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
1902
  *
1903
  * @since BuddyPress (1.5)
1904
  *
1905
+ * @see BP_Embed::parse_oembed()
1906
  * @uses bp_activity_update_meta()
1907
+ *
1908
+ * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
1909
+ * functions like this one to filter.
1910
+ * @param int $id The ID of the activity item.
1911
+ * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
1912
+ * @return bool True on success, false on failure.
1913
  */
1914
  function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
1915
  bp_activity_update_meta( $id, $cachekey, $cache );
bp-activity/bp-activity-loader.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Activity Streams Loader
5
  *
6
- * An activity stream component, for users, groups, and blog tracking.
7
  *
8
  * @package BuddyPress
9
  * @subpackage ActivityCore
@@ -13,14 +13,14 @@
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
- * Main Activity Class
17
  *
18
  * @since BuddyPress (1.5)
19
  */
20
  class BP_Activity_Component extends BP_Component {
21
 
22
  /**
23
- * Start the activity component creation process
24
  *
25
  * @since BuddyPress (1.5)
26
  */
@@ -28,14 +28,21 @@ class BP_Activity_Component extends BP_Component {
28
  parent::start(
29
  'activity',
30
  __( 'Activity Streams', 'buddypress' ),
31
- BP_PLUGIN_DIR
 
 
 
32
  );
33
  }
34
 
35
  /**
36
- * Include files
37
  *
38
  * @since BuddyPress (1.5)
 
 
 
 
39
  */
40
  public function includes( $includes = array() ) {
41
  // Files to include
@@ -52,27 +59,31 @@ class BP_Activity_Component extends BP_Component {
52
 
53
  // Load Akismet support if Akismet is configured
54
  $akismet_key = bp_get_option( 'wordpress_api_key' );
55
- if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) )
56
  $includes[] = 'akismet';
 
57
 
58
- if ( is_admin() )
59
  $includes[] = 'admin';
 
60
 
61
  parent::includes( $includes );
62
  }
63
 
64
  /**
65
- * Setup globals
66
  *
67
  * The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
68
  * backwards compatibility.
69
  *
70
  * @since BuddyPress (1.5)
71
  *
72
- * @global object $bp BuddyPress global settings
 
 
73
  */
74
  public function setup_globals( $args = array() ) {
75
- global $bp;
76
 
77
  // Define a slug, if necessary
78
  if ( !defined( 'BP_ACTIVITY_SLUG' ) )
@@ -86,7 +97,7 @@ class BP_Activity_Component extends BP_Component {
86
 
87
  // All globals for activity component.
88
  // Note that global_tables is included in this array.
89
- $globals = array(
90
  'slug' => BP_ACTIVITY_SLUG,
91
  'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
92
  'has_directory' => true,
@@ -95,24 +106,27 @@ class BP_Activity_Component extends BP_Component {
95
  'notification_callback' => 'bp_activity_format_notifications',
96
  );
97
 
98
- parent::setup_globals( $globals );
99
  }
100
 
101
  /**
102
- * Setup BuddyBar navigation
103
  *
104
  * @since BuddyPress (1.5)
105
  *
106
- * @global object $bp BuddyPress global settings
107
  * @uses bp_is_active()
108
  * @uses is_user_logged_in()
109
  * @uses bp_get_friends_slug()
110
  * @uses bp_get_groups_slug()
 
 
 
 
 
111
  */
112
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
113
 
114
- $sub_nav = array();
115
-
116
  // Add 'Activity' to the main navigation
117
  $main_nav = array(
118
  'name' => __( 'Activity', 'buddypress' ),
@@ -203,11 +217,12 @@ class BP_Activity_Component extends BP_Component {
203
  }
204
 
205
  /**
206
- * Set up the Toolbar
207
  *
208
  * @since BuddyPress (1.5)
209
  *
210
- * @global object $bp BuddyPress global settings
 
211
  * @uses is_user_logged_in()
212
  * @uses trailingslashit()
213
  * @uses bp_get_total_mention_count_for_user()
@@ -215,12 +230,12 @@ class BP_Activity_Component extends BP_Component {
215
  * @uses bp_is_active()
216
  * @uses bp_get_friends_slug()
217
  * @uses bp_get_groups_slug()
 
 
 
218
  */
219
  public function setup_admin_bar( $wp_admin_nav = array() ) {
220
- global $bp;
221
-
222
- // Prevent debug notices
223
- $wp_admin_nav = array();
224
 
225
  // Menus for logged in user
226
  if ( is_user_logged_in() ) {
@@ -298,17 +313,16 @@ class BP_Activity_Component extends BP_Component {
298
  }
299
 
300
  /**
301
- * Sets up the title for pages and <title>
302
  *
303
  * @since BuddyPress (1.5)
304
  *
305
- * @global object $bp BuddyPress global settings
306
  * @uses bp_is_activity_component()
307
  * @uses bp_is_my_profile()
308
  * @uses bp_core_fetch_avatar()
309
  */
310
  function setup_title() {
311
- global $bp;
312
 
313
  // Adjust title based on view
314
  if ( bp_is_activity_component() ) {
@@ -328,7 +342,7 @@ class BP_Activity_Component extends BP_Component {
328
  }
329
 
330
  /**
331
- * Setup the actions
332
  *
333
  * @since BuddyPress (1.6)
334
  */
@@ -340,9 +354,10 @@ class BP_Activity_Component extends BP_Component {
340
  }
341
  }
342
 
 
 
 
343
  function bp_setup_activity() {
344
- global $bp;
345
-
346
- $bp->activity = new BP_Activity_Component();
347
  }
348
  add_action( 'bp_setup_components', 'bp_setup_activity', 6 );
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Activity Streams Loader.
5
  *
6
+ * An activity stream component, for users, groups, and site tracking.
7
  *
8
  * @package BuddyPress
9
  * @subpackage ActivityCore
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
+ * Main Activity Class.
17
  *
18
  * @since BuddyPress (1.5)
19
  */
20
  class BP_Activity_Component extends BP_Component {
21
 
22
  /**
23
+ * Start the activity component setup process.
24
  *
25
  * @since BuddyPress (1.5)
26
  */
28
  parent::start(
29
  'activity',
30
  __( 'Activity Streams', 'buddypress' ),
31
+ BP_PLUGIN_DIR,
32
+ array(
33
+ 'adminbar_myaccount_order' => 10
34
+ )
35
  );
36
  }
37
 
38
  /**
39
+ * Include component files.
40
  *
41
  * @since BuddyPress (1.5)
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
59
 
60
  // Load Akismet support if Akismet is configured
61
  $akismet_key = bp_get_option( 'wordpress_api_key' );
62
+ if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
63
  $includes[] = 'akismet';
64
+ }
65
 
66
+ if ( is_admin() ) {
67
  $includes[] = 'admin';
68
+ }
69
 
70
  parent::includes( $includes );
71
  }
72
 
73
  /**
74
+ * Set up component global variables.
75
  *
76
  * The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
77
  * backwards compatibility.
78
  *
79
  * @since BuddyPress (1.5)
80
  *
81
+ * @see BP_Component::setup_globals() for a description of arguments.
82
+ *
83
+ * @param array $args See BP_Component::setup_globals() for a description.
84
  */
85
  public function setup_globals( $args = array() ) {
86
+ $bp = buddypress();
87
 
88
  // Define a slug, if necessary
89
  if ( !defined( 'BP_ACTIVITY_SLUG' ) )
97
 
98
  // All globals for activity component.
99
  // Note that global_tables is included in this array.
100
+ $args = array(
101
  'slug' => BP_ACTIVITY_SLUG,
102
  'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
103
  'has_directory' => true,
106
  'notification_callback' => 'bp_activity_format_notifications',
107
  );
108
 
109
+ parent::setup_globals( $args );
110
  }
111
 
112
  /**
113
+ * Set up component navigation.
114
  *
115
  * @since BuddyPress (1.5)
116
  *
117
+ * @see BP_Component::setup_nav() for a description of arguments.
118
  * @uses bp_is_active()
119
  * @uses is_user_logged_in()
120
  * @uses bp_get_friends_slug()
121
  * @uses bp_get_groups_slug()
122
+ *
123
+ * @param array $main_nav Optional. See BP_Component::setup_nav() for
124
+ * description.
125
+ * @param array $sub_nav Optional. See BP_Component::setup_nav() for
126
+ * description.
127
  */
128
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
129
 
 
 
130
  // Add 'Activity' to the main navigation
131
  $main_nav = array(
132
  'name' => __( 'Activity', 'buddypress' ),
217
  }
218
 
219
  /**
220
+ * Set up the component entries in the WordPress Admin Bar.
221
  *
222
  * @since BuddyPress (1.5)
223
  *
224
+ * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
225
+ * parameter array.
226
  * @uses is_user_logged_in()
227
  * @uses trailingslashit()
228
  * @uses bp_get_total_mention_count_for_user()
230
  * @uses bp_is_active()
231
  * @uses bp_get_friends_slug()
232
  * @uses bp_get_groups_slug()
233
+ *
234
+ * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
235
+ * description.
236
  */
237
  public function setup_admin_bar( $wp_admin_nav = array() ) {
238
+ $bp = buddypress();
 
 
 
239
 
240
  // Menus for logged in user
241
  if ( is_user_logged_in() ) {
313
  }
314
 
315
  /**
316
+ * Set up the title for pages and <title>.
317
  *
318
  * @since BuddyPress (1.5)
319
  *
 
320
  * @uses bp_is_activity_component()
321
  * @uses bp_is_my_profile()
322
  * @uses bp_core_fetch_avatar()
323
  */
324
  function setup_title() {
325
+ $bp = buddypress();
326
 
327
  // Adjust title based on view
328
  if ( bp_is_activity_component() ) {
342
  }
343
 
344
  /**
345
+ * Set up actions necessary for the component.
346
  *
347
  * @since BuddyPress (1.6)
348
  */
354
  }
355
  }
356
 
357
+ /**
358
+ * Bootstrap the Activity component.
359
+ */
360
  function bp_setup_activity() {
361
+ buddypress()->activity = new BP_Activity_Component();
 
 
362
  }
363
  add_action( 'bp_setup_components', 'bp_setup_activity', 6 );
bp-activity/bp-activity-notifications.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Activity Notifications
5
  *
6
  * @package BuddyPress
7
  * @subpackage ActivityNotifications
@@ -11,13 +11,10 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Sends an email notification and a BP notification when someone mentions you in an update
15
  *
16
  * @since BuddyPress (1.2)
17
  *
18
- * @param int $activity_id The id of the activity update
19
- * @param int $receiver_user_id The unique user_id of the user who is receiving the update
20
- *
21
  * @uses bp_core_add_notification()
22
  * @uses bp_get_user_meta()
23
  * @uses bp_core_get_user_displayname()
@@ -31,11 +28,14 @@ if ( !defined( 'ABSPATH' ) ) exit;
31
  * @uses bp_is_active()
32
  * @uses bp_is_group()
33
  * @uses bp_get_current_group_name()
34
- * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook
35
- * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook
36
- * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook
37
  * @uses wp_mail()
38
  * @uses do_action() To call the 'bp_activity_sent_mention_email' hook
 
 
 
39
  */
40
  function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
41
 
@@ -112,14 +112,10 @@ To view and respond to the message, log in and visit: %3$s
112
  }
113
 
114
  /**
115
- * Sends an email notification and a BP notification when someone mentions you in an update
116
  *
117
  * @since BuddyPress (1.2)
118
  *
119
- * @param int $comment_id The comment id
120
- * @param int $commenter_id The unique user_id of the user who posted the comment
121
- * @param array $params {@link bp_activity_new_comment()}
122
- *
123
  * @uses bp_get_user_meta()
124
  * @uses bp_core_get_user_displayname()
125
  * @uses bp_activity_get_permalink()
@@ -139,6 +135,10 @@ To view and respond to the message, log in and visit: %3$s
139
  * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook
140
  * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook
141
  * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook
 
 
 
 
142
  */
143
  function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) {
144
 
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Activity Notifications.
5
  *
6
  * @package BuddyPress
7
  * @subpackage ActivityNotifications
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
+ * Send email and BP notifications when a user is mentioned in an update.
15
  *
16
  * @since BuddyPress (1.2)
17
  *
 
 
 
18
  * @uses bp_core_add_notification()
19
  * @uses bp_get_user_meta()
20
  * @uses bp_core_get_user_displayname()
28
  * @uses bp_is_active()
29
  * @uses bp_is_group()
30
  * @uses bp_get_current_group_name()
31
+ * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook.
32
+ * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook.
33
+ * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook.
34
  * @uses wp_mail()
35
  * @uses do_action() To call the 'bp_activity_sent_mention_email' hook
36
+ *
37
+ * @param int $activity_id The ID of the activity update.
38
+ * @param int $receiver_user_id The ID of the user who is receiving the update.
39
  */
40
  function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
41
 
112
  }
113
 
114
  /**
115
+ * Send email and BP notifications when an activity item receives a comment.
116
  *
117
  * @since BuddyPress (1.2)
118
  *
 
 
 
 
119
  * @uses bp_get_user_meta()
120
  * @uses bp_core_get_user_displayname()
121
  * @uses bp_activity_get_permalink()
135
  * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook
136
  * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook
137
  * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook
138
+ *
139
+ * @param int $comment_id The comment id.
140
+ * @param int $commenter_id The ID of the user who posted the comment.
141
+ * @param array $params {@link bp_activity_new_comment()}
142
  */
143
  function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) {
144
 
bp-activity/bp-activity-screens.php CHANGED
@@ -1,7 +1,11 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Activity Screens
 
 
 
 
5
  *
6
  * @package BuddyPress
7
  * @subpackage ActivityScreens
@@ -11,7 +15,7 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Activity screen index
15
  *
16
  * @since BuddyPress (1.5)
17
  *
@@ -19,9 +23,9 @@ if ( !defined( 'ABSPATH' ) ) exit;
19
  * @uses bp_is_activity_component()
20
  * @uses bp_current_action()
21
  * @uses bp_update_is_directory()
22
- * @uses do_action() To call the 'bp_activity_screen_index' hook
23
  * @uses bp_core_load_template()
24
- * @uses apply_filters() To call the 'bp_activity_screen_index' hook
25
  */
26
  function bp_activity_screen_index() {
27
  if ( !bp_displayed_user_id() && bp_is_activity_component() && !bp_current_action() ) {
@@ -35,13 +39,13 @@ function bp_activity_screen_index() {
35
  add_action( 'bp_screens', 'bp_activity_screen_index' );
36
 
37
  /**
38
- * Activity screen 'my activity' index
39
  *
40
  * @since BuddyPress (1.0)
41
  *
42
- * @uses do_action() To call the 'bp_activity_screen_my_activity' hook
43
  * @uses bp_core_load_template()
44
- * @uses apply_filters() To call the 'bp_activity_template_my_activity' hook
45
  */
46
  function bp_activity_screen_my_activity() {
47
  do_action( 'bp_activity_screen_my_activity' );
@@ -49,16 +53,16 @@ function bp_activity_screen_my_activity() {
49
  }
50
 
51
  /**
52
- * Activity screen 'friends' index
53
  *
54
  * @since BuddyPress (1.0)
55
  *
56
  * @uses bp_is_active()
57
  * @uses bp_update_is_item_admin()
58
  * @uses bp_current_user_can()
59
- * @uses do_action() To call the 'bp_activity_screen_friends' hook
60
  * @uses bp_core_load_template()
61
- * @uses apply_filters() To call the 'bp_activity_template_friends_activity' hook
62
  */
63
  function bp_activity_screen_friends() {
64
  if ( !bp_is_active( 'friends' ) )
@@ -70,7 +74,7 @@ function bp_activity_screen_friends() {
70
  }
71
 
72
  /**
73
- * Activity screen 'groups' index
74
  *
75
  * @since BuddyPress (1.2)
76
  *
@@ -91,7 +95,7 @@ function bp_activity_screen_groups() {
91
  }
92
 
93
  /**
94
- * Activity screen 'favorites' index
95
  *
96
  * @since BuddyPress (1.2)
97
  *
@@ -108,7 +112,7 @@ function bp_activity_screen_favorites() {
108
  }
109
 
110
  /**
111
- * Activity screen 'mentions' index
112
  *
113
  * @since BuddyPress (1.2)
114
  *
@@ -125,25 +129,21 @@ function bp_activity_screen_mentions() {
125
  }
126
 
127
  /**
128
- * Removes activity notifications from the notification menu when a user clicks on them and
129
- * is taken to a specific screen.
130
  *
131
  * @since BuddyPress (1.5)
132
  *
133
- * @global object $bp BuddyPress global settings
134
- * @uses bp_core_delete_notifications_by_type()
135
  */
136
  function bp_activity_remove_screen_notifications() {
137
- global $bp;
138
-
139
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->activity->id, 'new_at_mention' );
140
  }
141
  add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' );
142
  add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' );
143
  add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );
144
 
145
  /**
146
- * Reset the logged-in user's new mentions data when he visits his mentions screen
147
  *
148
  * @since BuddyPress (1.5)
149
  *
@@ -158,7 +158,7 @@ function bp_activity_reset_my_new_mentions() {
158
  add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' );
159
 
160
  /**
161
- * Reset the logged-in user's new mentions data when he visits his mentions screen
162
  *
163
  * @since BuddyPress (1.2)
164
  *
@@ -255,13 +255,13 @@ function bp_activity_screen_single_activity_permalink() {
255
  add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
256
 
257
  /**
258
- * Add activity notifications settings to the notifications settings page
259
  *
260
  * @since BuddyPress (1.2)
261
  *
262
  * @uses bp_get_user_meta()
263
  * @uses bp_core_get_username()
264
- * @uses do_action() To call the 'bp_activity_screen_notification_settings' hook
265
  */
266
  function bp_activity_screen_notification_settings() {
267
 
@@ -315,7 +315,7 @@ add_action( 'bp_notification_settings', 'bp_activity_screen_notification_setting
315
  /** Theme Compatability *******************************************************/
316
 
317
  /**
318
- * The main theme compat class for BuddyPress Activity
319
  *
320
  * This class sets up the necessary theme compatability actions to safely output
321
  * activity template parts to the_title and the_content areas of a theme.
@@ -325,7 +325,7 @@ add_action( 'bp_notification_settings', 'bp_activity_screen_notification_setting
325
  class BP_Activity_Theme_Compat {
326
 
327
  /**
328
- * Setup the activity component theme compatibility
329
  *
330
  * @since BuddyPress (1.7)
331
  */
@@ -334,7 +334,7 @@ class BP_Activity_Theme_Compat {
334
  }
335
 
336
  /**
337
- * Are we looking at something that needs activity theme compatability?
338
  *
339
  * @since BuddyPress (1.7)
340
  */
@@ -371,7 +371,7 @@ class BP_Activity_Theme_Compat {
371
  *
372
  * @since BuddyPress (1.8)
373
  *
374
- * @param string $templates The templates from bp_get_theme_compat_templates()
375
  * @return array $templates Array of custom templates to look for.
376
  */
377
  public function directory_template_hierarchy( $templates ) {
@@ -388,7 +388,7 @@ class BP_Activity_Theme_Compat {
388
  }
389
 
390
  /**
391
- * Update the global $post with directory data
392
  *
393
  * @since BuddyPress (1.7)
394
  */
@@ -407,12 +407,12 @@ class BP_Activity_Theme_Compat {
407
  }
408
 
409
  /**
410
- * Filter the_content with the groups index template part
411
  *
412
  * @since BuddyPress (1.7)
413
  */
414
  public function directory_content() {
415
- bp_buffer_template_part( 'activity/index' );
416
  }
417
 
418
  /** Single ****************************************************************/
@@ -424,7 +424,7 @@ class BP_Activity_Theme_Compat {
424
  *
425
  * @since BuddyPress (1.8)
426
  *
427
- * @param string $templates The templates from bp_get_theme_compat_templates()
428
  * @return array $templates Array of custom templates to look for.
429
  */
430
  public function single_template_hierarchy( $templates ) {
@@ -441,7 +441,7 @@ class BP_Activity_Theme_Compat {
441
  }
442
 
443
  /**
444
- * Update the global $post with the displayed user's data
445
  *
446
  * @since BuddyPress (1.7)
447
  */
@@ -460,12 +460,12 @@ class BP_Activity_Theme_Compat {
460
  }
461
 
462
  /**
463
- * Filter the_content with the members' activity permalink template part
464
  *
465
  * @since BuddyPress (1.7)
466
  */
467
  public function single_dummy_content() {
468
- bp_buffer_template_part( 'activity/single/home' );
469
  }
470
  }
471
  new BP_Activity_Theme_Compat();
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Activity Screens.
5
+ *
6
+ * The functions in this file detect, with each page load, whether an Activity
7
+ * component page is being requested. If so, it parses any necessary data from
8
+ * the URL, and tells BuddyPress to load the appropriate template.
9
  *
10
  * @package BuddyPress
11
  * @subpackage ActivityScreens
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
17
  /**
18
+ * Load the Activity directory.
19
  *
20
  * @since BuddyPress (1.5)
21
  *
23
  * @uses bp_is_activity_component()
24
  * @uses bp_current_action()
25
  * @uses bp_update_is_directory()
26
+ * @uses do_action() To call the 'bp_activity_screen_index' hook.
27
  * @uses bp_core_load_template()
28
+ * @uses apply_filters() To call the 'bp_activity_screen_index' hook.
29
  */
30
  function bp_activity_screen_index() {
31
  if ( !bp_displayed_user_id() && bp_is_activity_component() && !bp_current_action() ) {
39
  add_action( 'bp_screens', 'bp_activity_screen_index' );
40
 
41
  /**
42
+ * Load the 'My Activity' page.
43
  *
44
  * @since BuddyPress (1.0)
45
  *
46
+ * @uses do_action() To call the 'bp_activity_screen_my_activity' hook.
47
  * @uses bp_core_load_template()
48
+ * @uses apply_filters() To call the 'bp_activity_template_my_activity' hook.
49
  */
50
  function bp_activity_screen_my_activity() {
51
  do_action( 'bp_activity_screen_my_activity' );
53
  }
54
 
55
  /**
56
+ * Load the 'My Friends' activity page.
57
  *
58
  * @since BuddyPress (1.0)
59
  *
60
  * @uses bp_is_active()
61
  * @uses bp_update_is_item_admin()
62
  * @uses bp_current_user_can()
63
+ * @uses do_action() To call the 'bp_activity_screen_friends' hook.
64
  * @uses bp_core_load_template()
65
+ * @uses apply_filters() To call the 'bp_activity_template_friends_activity' hook.
66
  */
67
  function bp_activity_screen_friends() {
68
  if ( !bp_is_active( 'friends' ) )
74
  }
75
 
76
  /**
77
+ * Load the 'My Groups' activity page.
78
  *
79
  * @since BuddyPress (1.2)
80
  *
95
  }
96
 
97
  /**
98
+ * Load the 'Favorites' activity page.
99
  *
100
  * @since BuddyPress (1.2)
101
  *
112
  }
113
 
114
  /**
115
+ * Load the 'Mentions' activity page.
116
  *
117
  * @since BuddyPress (1.2)
118
  *
129
  }
130
 
131
  /**
132
+ * Remove activity notifications when a user clicks on them.
 
133
  *
134
  * @since BuddyPress (1.5)
135
  *
136
+ * @uses bp_core_mark_all_notifications_by_type()
 
137
  */
138
  function bp_activity_remove_screen_notifications() {
139
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' );
 
 
140
  }
141
  add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' );
142
  add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' );
143
  add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );
144
 
145
  /**
146
+ * Reset the logged-in user's new mentions data when he visits his mentions screen.
147
  *
148
  * @since BuddyPress (1.5)
149
  *
158
  add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' );
159
 
160
  /**
161
+ * Load the page for a single activity item.
162
  *
163
  * @since BuddyPress (1.2)
164
  *
255
  add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
256
 
257
  /**
258
+ * Add activity notifications settings to the notifications settings page.
259
  *
260
  * @since BuddyPress (1.2)
261
  *
262
  * @uses bp_get_user_meta()
263
  * @uses bp_core_get_username()
264
+ * @uses do_action() To call the 'bp_activity_screen_notification_settings' hook.
265
  */
266
  function bp_activity_screen_notification_settings() {
267
 
315
  /** Theme Compatability *******************************************************/
316
 
317
  /**
318
+ * The main theme compat class for BuddyPress Activity.
319
  *
320
  * This class sets up the necessary theme compatability actions to safely output
321
  * activity template parts to the_title and the_content areas of a theme.
325
  class BP_Activity_Theme_Compat {
326
 
327
  /**
328
+ * Set up the activity component theme compatibility.
329
  *
330
  * @since BuddyPress (1.7)
331
  */
334
  }
335
 
336
  /**
337
+ * Set up the theme compatibility hooks, if we're looking at an activity page.
338
  *
339
  * @since BuddyPress (1.7)
340
  */
371
  *
372
  * @since BuddyPress (1.8)
373
  *
374
+ * @param string $templates The templates from bp_get_theme_compat_templates().
375
  * @return array $templates Array of custom templates to look for.
376
  */
377
  public function directory_template_hierarchy( $templates ) {
388
  }
389
 
390
  /**
391
+ * Update the global $post with directory data.
392
  *
393
  * @since BuddyPress (1.7)
394
  */
407
  }
408
 
409
  /**
410
+ * Filter the_content with the groups index template part.
411
  *
412
  * @since BuddyPress (1.7)
413
  */
414
  public function directory_content() {
415
+ return bp_buffer_template_part( 'activity/index', null, false );
416
  }
417
 
418
  /** Single ****************************************************************/
424
  *
425
  * @since BuddyPress (1.8)
426
  *
427
+ * @param string $templates The templates from bp_get_theme_compat_templates().
428
  * @return array $templates Array of custom templates to look for.
429
  */
430
  public function single_template_hierarchy( $templates ) {
441
  }
442
 
443
  /**
444
+ * Update the global $post with the displayed user's data.
445
  *
446
  * @since BuddyPress (1.7)
447
  */
460
  }
461
 
462
  /**
463
+ * Filter the_content with the members' activity permalink template part.
464
  *
465
  * @since BuddyPress (1.7)
466
  */
467
  public function single_dummy_content() {
468
+ return bp_buffer_template_part( 'activity/single/home', null, false );
469
  }
470
  }
471
  new BP_Activity_Theme_Compat();
bp-activity/bp-activity-template.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Activity Template Functions
5
  *
6
  * @package BuddyPress
7
  * @subpackage ActivityTemplate
@@ -11,7 +11,7 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Output the activity component slug
15
  *
16
  * @since BuddyPress (1.5)
17
  *
@@ -21,12 +21,14 @@ function bp_activity_slug() {
21
  echo bp_get_activity_slug();
22
  }
23
  /**
24
- * Return the activity component slug
25
  *
26
  * @since BuddyPress (1.5)
27
  *
28
- * @global object $bp BuddyPress global settings
29
- * @uses apply_filters() To call the 'bp_get_activity_slug' hook
 
 
30
  */
31
  function bp_get_activity_slug() {
32
  global $bp;
@@ -34,7 +36,7 @@ function bp_activity_slug() {
34
  }
35
 
36
  /**
37
- * Output the activity component root slug
38
  *
39
  * @since BuddyPress (1.5)
40
  *
@@ -44,12 +46,14 @@ function bp_activity_root_slug() {
44
  echo bp_get_activity_root_slug();
45
  }
46
  /**
47
- * Return the activity component root slug
48
  *
49
  * @since BuddyPress (1.5)
50
  *
51
- * @global object $bp BuddyPress global settings
52
- * @uses apply_filters() To call the 'bp_get_activity_root_slug' hook
 
 
53
  */
54
  function bp_get_activity_root_slug() {
55
  global $bp;
@@ -57,7 +61,7 @@ function bp_activity_root_slug() {
57
  }
58
 
59
  /**
60
- * Output member directory permalink
61
  *
62
  * @since BuddyPress (1.5)
63
  *
@@ -67,25 +71,25 @@ function bp_activity_directory_permalink() {
67
  echo bp_get_activity_directory_permalink();
68
  }
69
  /**
70
- * Return member directory permalink
71
  *
72
  * @since BuddyPress (1.5)
73
  *
74
  * @uses traisingslashit()
75
  * @uses bp_get_root_domain()
76
  * @uses bp_get_activity_root_slug()
77
- * @uses apply_filters() To call the 'bp_get_activity_directory_permalink' hook
78
  *
79
- * @return string Activity directory permalink
80
  */
81
  function bp_get_activity_directory_permalink() {
82
  return apply_filters( 'bp_get_activity_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() ) );
83
  }
84
 
85
  /**
86
- * The main activity template loop
87
  *
88
- * This is responsible for loading a group of activity items and displaying them
89
  *
90
  * @since BuddyPress (1.0)
91
  */
@@ -105,12 +109,31 @@ class BP_Activity_Template {
105
  var $full_name;
106
 
107
  /**
108
- * Constructor method
109
- *
110
- * See definition of $defaults below, as well as $defaults in bp_has_activities(), for
111
- * description of $args array
112
- *
113
- * @param array $args
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  */
115
  function __construct( $args ) {
116
  global $bp;
@@ -225,6 +248,13 @@ class BP_Activity_Template {
225
  }
226
  }
227
 
 
 
 
 
 
 
 
228
  function has_activities() {
229
  if ( $this->activity_count )
230
  return true;
@@ -232,6 +262,11 @@ class BP_Activity_Template {
232
  return false;
233
  }
234
 
 
 
 
 
 
235
  function next_activity() {
236
  $this->current_activity++;
237
  $this->activity = $this->activities[$this->current_activity];
@@ -239,6 +274,9 @@ class BP_Activity_Template {
239
  return $this->activity;
240
  }
241
 
 
 
 
242
  function rewind_activities() {
243
  $this->current_activity = -1;
244
  if ( $this->activity_count > 0 ) {
@@ -246,6 +284,18 @@ class BP_Activity_Template {
246
  }
247
  }
248
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  function user_activities() {
250
  if ( $this->current_activity + 1 < $this->activity_count ) {
251
  return true;
@@ -259,6 +309,15 @@ class BP_Activity_Template {
259
  return false;
260
  }
261
 
 
 
 
 
 
 
 
 
 
262
  function the_activity() {
263
 
264
  $this->in_the_loop = true;
@@ -273,16 +332,16 @@ class BP_Activity_Template {
273
  }
274
 
275
  /**
276
- * Initializes the activity loop.
277
  *
278
- * Based on the $args passed, bp_has_activities() populates the $activities_template global.
 
 
279
  *
280
  * @since BuddyPress (1.0)
281
  *
282
- * @param array $args Arguments for limiting the contents of the activity loop. Can be passed as an associative array or as a URL argument string
283
- *
284
  * @global object $activities_template {@link BP_Activity_Template}
285
- * @global object $bp BuddyPress global settings
286
  * @uses groups_is_user_member()
287
  * @uses bp_current_action()
288
  * @uses bp_is_current_action()
@@ -293,9 +352,108 @@ class BP_Activity_Template {
293
  * @uses friends_get_friend_user_ids()
294
  * @uses groups_get_user_groups()
295
  * @uses bp_activity_get_user_favorites()
296
- * @uses apply_filters() To call the 'bp_has_activities' hook
297
- *
298
- * @return bool Returns true when activities are found
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  */
300
  function bp_has_activities( $args = '' ) {
301
  global $activities_template, $bp;
@@ -371,6 +529,13 @@ function bp_has_activities( $args = '' ) {
371
  $r = wp_parse_args( $args, $defaults );
372
  extract( $r );
373
 
 
 
 
 
 
 
 
374
  if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) )
375
  $search_terms = $_REQUEST['s'];
376
 
@@ -425,7 +590,7 @@ function bp_has_activities( $args = '' ) {
425
  }
426
 
427
  // Start search at @ symbol and stop search at closing tag delimiter.
428
- $search_terms = '@' . bp_core_get_username( $user_id ) . '<';
429
  $display_comments = 'stream';
430
  $user_id = 0;
431
  break;
@@ -474,14 +639,14 @@ function bp_has_activities( $args = '' ) {
474
  }
475
 
476
  /**
477
- * Determines if there are still activities left in the loop.
478
  *
479
  * @since BuddyPress (1.0)
480
  *
481
  * @global object $activities_template {@link BP_Activity_Template}
482
  * @uses BP_Activity_Template::user_activities() {@link BP_Activity_Template::user_activities()}
483
  *
484
- * @return bool Returns true when activities are found
485
  */
486
  function bp_activities() {
487
  global $activities_template;
@@ -489,14 +654,14 @@ function bp_activities() {
489
  }
490
 
491
  /**
492
- * Gets the current activity object in the loop
493
  *
494
  * @since BuddyPress (1.0)
495
  *
496
  * @global object $activities_template {@link BP_Activity_Template}
497
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
498
  *
499
- * @return object The current activity within the loop
500
  */
501
  function bp_the_activity() {
502
  global $activities_template;
@@ -504,7 +669,7 @@ function bp_the_activity() {
504
  }
505
 
506
  /**
507
- * Outputs the activity pagination count
508
  *
509
  * @since BuddyPress (1.0)
510
  *
@@ -516,14 +681,14 @@ function bp_activity_pagination_count() {
516
  }
517
 
518
  /**
519
- * Returns the activity pagination count
520
  *
521
  * @since BuddyPress (1.2)
522
  *
523
  * @global object $activities_template {@link BP_Activity_Template}
524
  * @uses bp_core_number_format()
525
  *
526
- * @return string The pagination text
527
  */
528
  function bp_get_activity_pagination_count() {
529
  global $activities_template;
@@ -533,11 +698,11 @@ function bp_activity_pagination_count() {
533
  $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
534
  $total = bp_core_number_format( $activities_template->total_activity_count );
535
 
536
- return sprintf( __( 'Viewing item %1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total );
537
  }
538
 
539
  /**
540
- * Outputs the activity pagination links
541
  *
542
  * @since BuddyPress (1.0)
543
  *
@@ -548,14 +713,14 @@ function bp_activity_pagination_links() {
548
  }
549
 
550
  /**
551
- * Outputs the activity pagination links
552
  *
553
  * @since BuddyPress (1.0)
554
  *
555
  * @global object $activities_template {@link BP_Activity_Template}
556
- * @uses apply_filters() To call the 'bp_get_activity_pagination_links' hook
557
  *
558
- * @return string The pagination links
559
  */
560
  function bp_get_activity_pagination_links() {
561
  global $activities_template;
@@ -564,14 +729,14 @@ function bp_activity_pagination_links() {
564
  }
565
 
566
  /**
567
- * Returns true when there are more activity items to be shown than currently appear
568
  *
569
  * @since BuddyPress (1.5)
570
  *
571
  * @global object $activities_template {@link BP_Activity_Template}
572
- * @uses apply_filters() To call the 'bp_activity_has_more_items' hook
573
  *
574
- * @return bool $has_more_items True if more items, false if not
575
  */
576
  function bp_activity_has_more_items() {
577
  global $activities_template;
@@ -583,7 +748,7 @@ function bp_activity_has_more_items() {
583
  }
584
 
585
  /**
586
- * Outputs the activity count
587
  *
588
  * @since BuddyPress (1.2)
589
  *
@@ -594,14 +759,14 @@ function bp_activity_count() {
594
  }
595
 
596
  /**
597
- * Returns the activity count
598
  *
599
  * @since BuddyPress (1.2)
600
  *
601
  * @global object $activities_template {@link BP_Activity_Template}
602
- * @uses apply_filters() To call the 'bp_get_activity_count' hook
603
  *
604
- * @return int The activity count
605
  */
606
  function bp_get_activity_count() {
607
  global $activities_template;
@@ -610,7 +775,7 @@ function bp_activity_count() {
610
  }
611
 
612
  /**
613
- * Outputs the number of activities per page
614
  *
615
  * @since BuddyPress (1.2)
616
  *
@@ -621,14 +786,14 @@ function bp_activity_per_page() {
621
  }
622
 
623
  /**
624
- * Returns the number of activities per page
625
  *
626
  * @since BuddyPress (1.2)
627
  *
628
  * @global object $activities_template {@link BP_Activity_Template}
629
- * @uses apply_filters() To call the 'bp_get_activity_per_page' hook
630
  *
631
- * @return int The activities per page
632
  */
633
  function bp_get_activity_per_page() {
634
  global $activities_template;
@@ -637,25 +802,27 @@ function bp_activity_per_page() {
637
  }
638
 
639
  /**
640
- * Outputs the activities title
641
  *
642
  * @since BuddyPress (1.0)
643
  *
644
  * @uses bp_get_activities_title()
 
645
  */
646
  function bp_activities_title() {
647
  echo bp_get_activities_title();
648
  }
649
 
650
  /**
651
- * Returns the activities title
652
  *
653
  * @since BuddyPress (1.0)
654
  *
655
  * @global string $bp_activity_title
656
- * @uses apply_filters() To call the 'bp_get_activities_title' hook
 
657
  *
658
- * @return int The activities title
659
  */
660
  function bp_get_activities_title() {
661
  global $bp_activity_title;
@@ -669,6 +836,7 @@ function bp_activities_title() {
669
  * @since BuddyPress (1.0)
670
  *
671
  * @uses bp_get_activities_no_activity()
 
672
  */
673
  function bp_activities_no_activity() {
674
  echo bp_get_activities_no_activity();
@@ -681,6 +849,7 @@ function bp_activities_no_activity() {
681
  *
682
  * @global string $bp_activity_no_activity
683
  * @uses apply_filters() To call the 'bp_get_activities_no_activity' hook
 
684
  *
685
  * @return string
686
  */
@@ -691,7 +860,7 @@ function bp_activities_no_activity() {
691
  }
692
 
693
  /**
694
- * Outputs the activity id
695
  *
696
  * @since BuddyPress (1.2)
697
  *
@@ -702,14 +871,14 @@ function bp_activity_id() {
702
  }
703
 
704
  /**
705
- * Returns the activity id
706
  *
707
  * @since BuddyPress (1.2)
708
  *
709
  * @global object $activities_template {@link BP_Activity_Template}
710
- * @uses apply_filters() To call the 'bp_get_activity_id' hook
711
  *
712
- * @return int The activity id
713
  */
714
  function bp_get_activity_id() {
715
  global $activities_template;
@@ -717,7 +886,7 @@ function bp_activity_id() {
717
  }
718
 
719
  /**
720
- * Outputs the activity item id
721
  *
722
  * @since BuddyPress (1.2)
723
  *
@@ -728,14 +897,14 @@ function bp_activity_item_id() {
728
  }
729
 
730
  /**
731
- * Returns the activity item id
732
  *
733
  * @since BuddyPress (1.2)
734
  *
735
  * @global object $activities_template {@link BP_Activity_Template}
736
- * @uses apply_filters() To call the 'bp_get_activity_item_id' hook
737
  *
738
- * @return int The activity item id
739
  */
740
  function bp_get_activity_item_id() {
741
  global $activities_template;
@@ -743,7 +912,7 @@ function bp_activity_item_id() {
743
  }
744
 
745
  /**
746
- * Outputs the activity secondary item id
747
  *
748
  * @since BuddyPress (1.2)
749
  *
@@ -754,14 +923,14 @@ function bp_activity_secondary_item_id() {
754
  }
755
 
756
  /**
757
- * Returns the activity secondary item id
758
  *
759
  * @since BuddyPress (1.2)
760
  *
761
  * @global object $activities_template {@link BP_Activity_Template}
762
- * @uses apply_filters() To call the 'bp_get_activity_secondary_item_id' hook
763
  *
764
- * @return int The activity secondary item id
765
  */
766
  function bp_get_activity_secondary_item_id() {
767
  global $activities_template;
@@ -769,7 +938,7 @@ function bp_activity_secondary_item_id() {
769
  }
770
 
771
  /**
772
- * Outputs the date the activity was recorded
773
  *
774
  * @since BuddyPress (1.2)
775
  *
@@ -780,14 +949,14 @@ function bp_activity_date_recorded() {
780
  }
781
 
782
  /**
783
- * Returns the date the activity was recorded
784
  *
785
  * @since BuddyPress (1.2)
786
  *
787
  * @global object $activities_template {@link BP_Activity_Template}
788
- * @uses apply_filters() To call the 'bp_get_activity_date_recorded' hook
789
  *
790
- * @return string The date the activity was recorded
791
  */
792
  function bp_get_activity_date_recorded() {
793
  global $activities_template;
@@ -795,7 +964,7 @@ function bp_activity_date_recorded() {
795
  }
796
 
797
  /**
798
- * Outputs the activity object name
799
  *
800
  * @since BuddyPress (1.2)
801
  *
@@ -806,14 +975,14 @@ function bp_activity_object_name() {
806
  }
807
 
808
  /**
809
- * Returns the activity object name
810
  *
811
  * @since BuddyPress (1.2)
812
  *
813
  * @global object $activities_template {@link BP_Activity_Template}
814
- * @uses apply_filters() To call the 'bp_get_activity_object_name' hook
815
  *
816
- * @return string The activity object name
817
  */
818
  function bp_get_activity_object_name() {
819
  global $activities_template;
@@ -821,7 +990,7 @@ function bp_activity_object_name() {
821
  }
822
 
823
  /**
824
- * Outputs the activity type
825
  *
826
  * @since BuddyPress (1.2)
827
  *
@@ -832,14 +1001,14 @@ function bp_activity_type() {
832
  }
833
 
834
  /**
835
- * Returns the activity type
836
  *
837
  * @since BuddyPress (1.2)
838
  *
839
  * @global object $activities_template {@link BP_Activity_Template}
840
- * @uses apply_filters() To call the 'bp_get_activity_type' hook
841
  *
842
- * @return string The activity type
843
  */
844
  function bp_get_activity_type() {
845
  global $activities_template;
@@ -847,9 +1016,9 @@ function bp_activity_type() {
847
  }
848
 
849
  /**
850
- * Outputs the activity action name
851
  *
852
- * Just a wrapper for bp_activity_type()
853
  *
854
  * @since BuddyPress (1.2)
855
  * @deprecated BuddyPress (1.5)
@@ -862,23 +1031,23 @@ function bp_activity_type() {
862
  function bp_activity_action_name() { echo bp_activity_type(); }
863
 
864
  /**
865
- * Returns the activity type
866
  *
867
- * Just a wrapper for bp_get_activity_type()
868
  *
869
  * @since BuddyPress (1.2)
870
  * @deprecated BuddyPress (1.5)
871
  *
872
- * @todo Properly deprecate in favor of bp_get_activity_type()
873
  *
874
  * @uses bp_get_activity_type()
875
  *
876
- * @return string The activity type
877
  */
878
  function bp_get_activity_action_name() { return bp_get_activity_type(); }
879
 
880
  /**
881
- * Outputs the activity user id
882
  *
883
  * @since BuddyPress (1.1)
884
  *
@@ -889,14 +1058,14 @@ function bp_activity_user_id() {
889
  }
890
 
891
  /**
892
- * Returns the activity user id
893
  *
894
  * @since BuddyPress (1.1)
895
  *
896
  * @global object $activities_template {@link BP_Activity_Template}
897
- * @uses apply_filters() To call the 'bp_get_activity_user_id' hook
898
  *
899
- * @return int The activity user id
900
  */
901
  function bp_get_activity_user_id() {
902
  global $activities_template;
@@ -904,7 +1073,7 @@ function bp_activity_user_id() {
904
  }
905
 
906
  /**
907
- * Outputs the activity user link
908
  *
909
  * @since BuddyPress (1.2)
910
  *
@@ -915,15 +1084,15 @@ function bp_activity_user_link() {
915
  }
916
 
917
  /**
918
- * Returns the activity user link
919
  *
920
  * @since BuddyPress (1.2)
921
  *
922
  * @global object $activities_template {@link BP_Activity_Template}
923
  * @uses bp_core_get_user_domain()
924
- * @uses apply_filters() To call the 'bp_get_activity_user_link' hook
925
  *
926
- * @return string $link The activity user link
927
  */
928
  function bp_get_activity_user_link() {
929
  global $activities_template;
@@ -937,24 +1106,24 @@ function bp_activity_user_link() {
937
  }
938
 
939
  /**
940
- * Output the avatar of the user that performed the action
941
  *
942
  * @since BuddyPress (1.1)
943
  *
944
- * @param array $args
945
- *
946
  * @uses bp_get_activity_avatar()
 
 
947
  */
948
  function bp_activity_avatar( $args = '' ) {
949
  echo bp_get_activity_avatar( $args );
950
  }
951
  /**
952
- * Return the avatar of the user that performed the action
953
  *
954
  * @since BuddyPress (1.1)
955
  *
956
- * @param array $args optional
957
- *
958
  * @global object $activities_template {@link BP_Activity_Template}
959
  * @global object $bp BuddyPress global settings
960
  * @uses bp_is_single_activity()
@@ -964,7 +1133,20 @@ function bp_activity_avatar( $args = '' ) {
964
  * @uses bp_core_fetch_avatar()
965
  * @uses apply_filters() To call the 'bp_get_activity_avatar' hook
966
  *
967
- * @return string User avatar
 
 
 
 
 
 
 
 
 
 
 
 
 
968
  */
969
  function bp_get_activity_avatar( $args = '' ) {
970
  global $activities_template;
@@ -1034,13 +1216,14 @@ function bp_activity_avatar( $args = '' ) {
1034
  }
1035
 
1036
  /**
1037
- * Output the avatar of the object that action was performed on
1038
  *
1039
  * @since BuddyPress (1.2)
1040
  *
1041
- * @param array $args optional
1042
- *
1043
  * @uses bp_get_activity_secondary_avatar()
 
 
1044
  */
1045
  function bp_activity_secondary_avatar( $args = '' ) {
1046
  echo bp_get_activity_secondary_avatar( $args );
@@ -1051,16 +1234,25 @@ function bp_activity_secondary_avatar( $args = '' ) {
1051
  *
1052
  * @since BuddyPress (1.2)
1053
  *
1054
- * @param array $args optional
1055
- *
1056
  * @global object $activities_template {@link BP_Activity_Template}
1057
  * @uses wp_parse_args()
1058
  * @uses get_blog_option()
1059
- * @uses apply_filters() To call the 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component hook
1060
- * @uses apply_filters() To call the 'bp_get_activity_secondary_avatar_item_id' hook
1061
  * @uses bp_core_fetch_avatar()
1062
- * @uses apply_filters() To call the 'bp_get_activity_secondary_avatar' hook
1063
- *
 
 
 
 
 
 
 
 
 
 
1064
  * @return string The secondary avatar
1065
  */
1066
  function bp_get_activity_secondary_avatar( $args = '' ) {
@@ -1191,9 +1383,12 @@ function bp_activity_action( $args = array() ) {
1191
  * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
1192
  * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook
1193
  * @uses bp_insert_activity_meta()
1194
- * @uses apply_filters_ref_array() To call the 'bp_get_activity_action' hook
1195
  *
1196
- * @return string The activity action
 
 
 
1197
  */
1198
  function bp_get_activity_action( $args = array() ) {
1199
  global $activities_template;
@@ -1232,9 +1427,9 @@ function bp_activity_content_body() {
1232
  *
1233
  * @global object $activities_template {@link BP_Activity_Template}
1234
  * @uses bp_insert_activity_meta()
1235
- * @uses apply_filters_ref_array() To call the 'bp_get_activity_content_body' hook
1236
  *
1237
- * @return string The activity content body
1238
  */
1239
  function bp_get_activity_content_body() {
1240
  global $activities_template;
@@ -1253,7 +1448,7 @@ function bp_activity_content_body() {
1253
  *
1254
  * @global object $activities_template {@link BP_Activity_Template}
1255
  *
1256
- * @return bool True if activity has content, false otherwise
1257
  */
1258
  function bp_activity_has_content() {
1259
  global $activities_template;
@@ -1265,12 +1460,12 @@ function bp_activity_has_content() {
1265
  }
1266
 
1267
  /**
1268
- * Output the activity content
1269
  *
1270
  * @since BuddyPress (1.0)
1271
  * @deprecated BuddyPress (1.5)
1272
  *
1273
- * @todo properly deprecate this function
1274
  *
1275
  * @uses bp_get_activity_content()
1276
  */
@@ -1279,18 +1474,18 @@ function bp_activity_content() {
1279
  }
1280
 
1281
  /**
1282
- * Return the activity content
1283
  *
1284
  * @since BuddyPress (1.0)
1285
  * @deprecated BuddyPress (1.5)
1286
  *
1287
- * @todo properly deprecate this function
1288
  *
1289
  * @uses bp_get_activity_action()
1290
  * @uses bp_get_activity_content_body()
1291
- * @uses apply_filters() To call the 'bp_get_activity_content' hook
1292
  *
1293
- * @return string The activity content
1294
  */
1295
  function bp_get_activity_content() {
1296
  /**
@@ -1305,22 +1500,24 @@ function bp_activity_content() {
1305
  }
1306
 
1307
  /**
1308
- * Insert activity meta
1309
  *
1310
- * @since BuddyPress (1.2)
 
1311
  *
1312
- * @param string $content
1313
  *
1314
  * @global object $activities_template {@link BP_Activity_Template}
1315
  * @uses bp_core_time_since()
1316
- * @uses apply_filters_ref_array() To call the 'bp_activity_time_since' hook
1317
  * @uses bp_is_single_activity()
1318
  * @uses bp_activity_get_permalink()
1319
  * @uses esc_attr__()
1320
- * @uses apply_filters_ref_array() To call the 'bp_activity_permalink' hook
1321
- * @uses apply_filters() To call the 'bp_insert_activity_meta' hook
1322
  *
1323
- * @return string The activity content
 
1324
  */
1325
  function bp_insert_activity_meta( $content ) {
1326
  global $activities_template;
@@ -1341,16 +1538,15 @@ function bp_insert_activity_meta( $content ) {
1341
  }
1342
 
1343
  /**
1344
- * Determine if the current user can delete an activity item
1345
  *
1346
  * @since BuddyPress (1.2)
1347
  *
1348
- * @param object $activity Optional
1349
- *
1350
  * @global object $activities_template {@link BP_Activity_Template}
1351
  * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
1352
  *
1353
- * @return bool True if can delete, false otherwise
 
1354
  */
1355
  function bp_activity_user_can_delete( $activity = false ) {
1356
  global $activities_template;
@@ -1372,33 +1568,36 @@ function bp_activity_user_can_delete( $activity = false ) {
1372
  if ( bp_is_item_admin() && bp_is_single_item() )
1373
  $can_delete = true;
1374
 
1375
- return apply_filters( 'bp_activity_user_can_delete', $can_delete );
1376
  }
1377
 
1378
  /**
1379
- * Output the activity parent content
1380
  *
1381
  * @since BuddyPress (1.2)
1382
  *
1383
- * @param array $args Optional
1384
- *
1385
  * @uses bp_get_activity_parent_content()
 
 
1386
  */
1387
  function bp_activity_parent_content( $args = '' ) {
1388
  echo bp_get_activity_parent_content($args);
1389
  }
1390
 
1391
  /**
1392
- * Return the activity content
1393
  *
1394
  * @since BuddyPress (1.2)
1395
  *
1396
- * @param array $args Optional
1397
- *
1398
  * @global object $activities_template {@link BP_Activity_Template}
1399
  * @uses wp_parse_args()
1400
- * @uses apply_filters() To call the 'bp_get_activity_parent_content' hook
1401
  *
 
 
 
 
1402
  * @return mixed False on failure, otherwise the activity parent content
1403
  */
1404
  function bp_get_activity_parent_content( $args = '' ) {
@@ -1440,7 +1639,7 @@ function bp_activity_parent_content( $args = '' ) {
1440
  }
1441
 
1442
  /**
1443
- * Output the parent activity's user ID
1444
  *
1445
  * @since BuddyPress (1.7)
1446
  */
@@ -1449,11 +1648,14 @@ function bp_activity_parent_user_id() {
1449
  }
1450
 
1451
  /**
1452
- * Return the parent activity's user ID
1453
  *
1454
- * @global BP_Activity_Template $activities_template
1455
- * @return bool|int False if parent activity can't be found, otherwise returns the parent activity's user ID
1456
  * @since BuddyPress (1.7)
 
 
 
 
 
1457
  */
1458
  function bp_get_activity_parent_user_id() {
1459
  global $activities_template;
@@ -1480,7 +1682,7 @@ function bp_activity_parent_user_id() {
1480
  }
1481
 
1482
  /**
1483
- * Output whether or not the current activity is in a current user's favorites
1484
  *
1485
  * @since BuddyPress (1.2)
1486
  *
@@ -1491,14 +1693,14 @@ function bp_activity_is_favorite() {
1491
  }
1492
 
1493
  /**
1494
- * Return whether or not the current activity is in a current user's favorites
1495
  *
1496
  * @since BuddyPress (1.2)
1497
  *
1498
  * @global object $activities_template {@link BP_Activity_Template}
1499
- * @uses apply_filters() To call the 'bp_get_activity_is_favorite' hook
1500
  *
1501
- * @return bool True if user favorite, false otherwise
1502
  */
1503
  function bp_get_activity_is_favorite() {
1504
  global $activities_template;
@@ -1507,7 +1709,7 @@ function bp_activity_is_favorite() {
1507
  }
1508
 
1509
  /**
1510
- * Echoes the comment markup for an activity item
1511
  *
1512
  * @since BuddyPress (1.2)
1513
  *
@@ -1520,7 +1722,7 @@ function bp_activity_comments( $args = '' ) {
1520
  }
1521
 
1522
  /**
1523
- * Gets the comment markup for an activity item
1524
  *
1525
  * @since BuddyPress (1.2)
1526
  *
@@ -1590,14 +1792,15 @@ function bp_activity_comments( $args = '' ) {
1590
  }
1591
 
1592
  /**
1593
- * Utility function that returns the comment currently being recursed
1594
  *
1595
  * @since BuddyPress (1.5)
1596
  *
1597
  * @global object $activities_template {@link BP_Activity_Template}
1598
- * @uses apply_filters() To call the 'bp_activity_current_comment' hook
1599
  *
1600
- * @return object|bool $current_comment The activity comment currently being displayed. False on failure
 
1601
  */
1602
  function bp_activity_current_comment() {
1603
  global $activities_template;
@@ -1609,7 +1812,7 @@ function bp_activity_current_comment() {
1609
 
1610
 
1611
  /**
1612
- * Echoes the id of the activity comment currently being displayed
1613
  *
1614
  * @since BuddyPress (1.5)
1615
  *
@@ -1620,14 +1823,15 @@ function bp_activity_comment_id() {
1620
  }
1621
 
1622
  /**
1623
- * Gets the id of the activity comment currently being displayed
1624
  *
1625
  * @since BuddyPress (1.5)
1626
  *
1627
  * @global object $activities_template {@link BP_Activity_Template}
1628
- * @uses apply_filters() To call the 'bp_activity_comment_id' hook
1629
  *
1630
- * @return int $comment_id The id of the activity comment currently being displayed
 
1631
  */
1632
  function bp_get_activity_comment_id() {
1633
  global $activities_template;
@@ -1638,7 +1842,7 @@ function bp_activity_comment_id() {
1638
  }
1639
 
1640
  /**
1641
- * Echoes the user_id of the author of the activity comment currently being displayed
1642
  *
1643
  * @since BuddyPress (1.5)
1644
  *
@@ -1649,14 +1853,15 @@ function bp_activity_comment_user_id() {
1649
  }
1650
 
1651
  /**
1652
- * Gets the user_id of the author of the activity comment currently being displayed
1653
  *
1654
  * @since BuddyPress (1.5)
1655
  *
1656
  * @global object $activities_template {@link BP_Activity_Template}
1657
- * @uses apply_filters() To call the 'bp_activity_comment_user_id' hook
1658
  *
1659
- * @return int|bool $user_id The user_id of the author of the displayed activity comment. False on failure
 
1660
  */
1661
  function bp_get_activity_comment_user_id() {
1662
  global $activities_template;
@@ -1667,7 +1872,7 @@ function bp_activity_comment_user_id() {
1667
  }
1668
 
1669
  /**
1670
- * Echoes the author link for the activity comment currently being displayed
1671
  *
1672
  * @since BuddyPress (1.5)
1673
  *
@@ -1678,7 +1883,7 @@ function bp_activity_comment_user_link() {
1678
  }
1679
 
1680
  /**
1681
- * Gets the author link for the activity comment currently being displayed
1682
  *
1683
  * @since BuddyPress (1.5)
1684
  *
@@ -1686,7 +1891,7 @@ function bp_activity_comment_user_link() {
1686
  * @uses bp_get_activity_comment_user_id()
1687
  * @uses apply_filters() To call the 'bp_activity_comment_user_link' hook
1688
  *
1689
- * @return string $user_link The URL of the activity comment author's profile
1690
  */
1691
  function bp_get_activity_comment_user_link() {
1692
  $user_link = bp_core_get_user_domain( bp_get_activity_comment_user_id() );
@@ -1695,7 +1900,7 @@ function bp_activity_comment_user_link() {
1695
  }
1696
 
1697
  /**
1698
- * Echoes the author name for the activity comment currently being displayed
1699
  *
1700
  * @since BuddyPress (1.5)
1701
  *
@@ -1706,17 +1911,18 @@ function bp_activity_comment_name() {
1706
  }
1707
 
1708
  /**
1709
- * Gets the author name for the activity comment currently being displayed
1710
  *
1711
- * The use of the bp_acomment_name filter is deprecated. Please use bp_activity_comment_name
 
1712
  *
1713
  * @since BuddyPress (1.5)
1714
  *
1715
  * @global object $activities_template {@link BP_Activity_Template}
1716
- * @uses apply_filters() To call the 'bp_acomment_name' hook
1717
- * @uses apply_filters() To call the 'bp_activity_comment_name' hook
1718
  *
1719
- * @return string $name The full name of the activity comment author
1720
  */
1721
  function bp_get_activity_comment_name() {
1722
  global $activities_template;
@@ -1730,7 +1936,7 @@ function bp_activity_comment_name() {
1730
  }
1731
 
1732
  /**
1733
- * Echoes the date_recorded of the activity comment currently being displayed
1734
  *
1735
  * @since BuddyPress (1.5)
1736
  *
@@ -1741,7 +1947,7 @@ function bp_activity_comment_date_recorded() {
1741
  }
1742
 
1743
  /**
1744
- * Gets the date_recorded for the activity comment currently being displayed
1745
  *
1746
  * @since BuddyPress (1.5)
1747
  *
@@ -1749,7 +1955,8 @@ function bp_activity_comment_date_recorded() {
1749
  * @uses bp_core_time_since()
1750
  * @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook
1751
  *
1752
- * @return string|bool $date_recorded Time since the activity was recorded, of the form "%s ago". False on failure
 
1753
  */
1754
  function bp_get_activity_comment_date_recorded() {
1755
  global $activities_template;
@@ -1763,7 +1970,7 @@ function bp_activity_comment_date_recorded() {
1763
  }
1764
 
1765
  /**
1766
- * Echoes the 'delete' URL for the activity comment currently being displayed
1767
  *
1768
  * @since BuddyPress (1.5)
1769
  *
@@ -1782,9 +1989,10 @@ function bp_activity_comment_delete_link() {
1782
  * @uses bp_get_root_domain()
1783
  * @uses bp_get_activity_slug()
1784
  * @uses bp_get_activity_comment_id()
1785
- * @uses apply_filters() To call the 'bp_activity_comment_delete_link' hook
1786
  *
1787
- * @return string $link The nonced URL for deleting the current activity comment
 
1788
  */
1789
  function bp_get_activity_comment_delete_link() {
1790
  $link = wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
@@ -1793,7 +2001,7 @@ function bp_activity_comment_delete_link() {
1793
  }
1794
 
1795
  /**
1796
- * Echoes the content of the activity comment currently being displayed
1797
  *
1798
  * @since BuddyPress (1.5)
1799
  *
@@ -1804,19 +2012,20 @@ function bp_activity_comment_content() {
1804
  }
1805
 
1806
  /**
1807
- * Gets the content of the activity comment currently being displayed
1808
  *
1809
- * The content is run through two filters. bp_get_activity_content will apply all filters
1810
- * applied to activity items in general. Use bp_activity_comment_content to modify the
1811
- * content of activity comments only.
 
1812
  *
1813
  * @since BuddyPress (1.5)
1814
  *
1815
  * @global object $activities_template {@link BP_Activity_Template}
1816
- * @uses apply_filters() To call the 'bp_get_activity_content' hook
1817
- * @uses apply_filters() To call the 'bp_activity_comment_content' hook
1818
  *
1819
- * @return string $content The content of the current activity comment
1820
  */
1821
  function bp_get_activity_comment_content() {
1822
  global $activities_template;
@@ -1827,7 +2036,7 @@ function bp_activity_comment_content() {
1827
  }
1828
 
1829
  /**
1830
- * Echoes the activity comment count
1831
  *
1832
  * @since BuddyPress (1.2)
1833
  *
@@ -1838,21 +2047,22 @@ function bp_activity_comment_count() {
1838
  }
1839
 
1840
  /**
1841
- * Gets the content of the activity comment currently being displayed
1842
  *
1843
- * The content is run through two filters. bp_get_activity_content will apply all filters
1844
- * applied to activity items in general. Use bp_activity_comment_content to modify the
1845
- * content of activity comments only.
 
1846
  *
1847
  * @since BuddyPress (1.2)
1848
  *
1849
- * @todo deprecate $args
1850
- *
1851
  * @global object $activities_template {@link BP_Activity_Template}
1852
  * @uses bp_activity_recurse_comment_count()
1853
- * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook
 
1854
  *
1855
- * @return int $count The activity comment count. Defaults to zero
 
1856
  */
1857
  function bp_activity_get_comment_count( $args = '' ) {
1858
  global $activities_template;
@@ -1866,21 +2076,21 @@ function bp_activity_comment_count() {
1866
  }
1867
 
1868
  /**
1869
- * Gets the content of the activity comment currently being displayed
1870
  *
1871
- * The content is run through two filters. bp_get_activity_content will apply all filters
1872
- * applied to activity items in general. Use bp_activity_comment_content to modify the
1873
- * content of activity comments only.
 
1874
  *
1875
  * @since BuddyPress (1.2)
1876
  *
1877
- * @todo investigate why bp_activity_recurse_comment_count() is used while being declared
1878
- *
1879
- * @param object $comment Activity comments object
1880
- *
1881
  * @uses bp_activity_recurse_comment_count()
1882
  * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook
 
1883
  *
 
 
1884
  * @return int $count The activity comment count.
1885
  */
1886
  function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
@@ -1897,7 +2107,7 @@ function bp_activity_comment_count() {
1897
  }
1898
 
1899
  /**
1900
- * Echoes the activity comment link
1901
  *
1902
  * @since BuddyPress (1.2)
1903
  *
@@ -1908,14 +2118,14 @@ function bp_activity_comment_link() {
1908
  }
1909
 
1910
  /**
1911
- * Gets the activity comment link
1912
  *
1913
  * @since BuddyPress (1.2)
1914
  *
1915
  * @global object $activities_template {@link BP_Activity_Template}
1916
- * @uses apply_filters() To call the 'bp_get_activity_comment_link' hook
1917
  *
1918
- * @return string The activity comment link
1919
  */
1920
  function bp_get_activity_comment_link() {
1921
  global $activities_template;
@@ -1923,7 +2133,7 @@ function bp_activity_comment_link() {
1923
  }
1924
 
1925
  /**
1926
- * Echoes the activity comment form no javascript display CSS
1927
  *
1928
  * @since BuddyPress (1.2)
1929
  *
@@ -1934,13 +2144,14 @@ function bp_activity_comment_form_nojs_display() {
1934
  }
1935
 
1936
  /**
1937
- * Gets the activity comment form no javascript display CSS
1938
  *
1939
  * @since BuddyPress (1.2)
1940
  *
1941
  * @global object $activities_template {@link BP_Activity_Template}
1942
  *
1943
- * @return string|bool The activity comment form no javascript display CSS. False on failure
 
1944
  */
1945
  function bp_get_activity_comment_form_nojs_display() {
1946
  global $activities_template;
@@ -1951,7 +2162,7 @@ function bp_activity_comment_form_nojs_display() {
1951
  }
1952
 
1953
  /**
1954
- * Echoes the activity comment form action
1955
  *
1956
  * @since BuddyPress (1.2)
1957
  *
@@ -1962,22 +2173,22 @@ function bp_activity_comment_form_action() {
1962
  }
1963
 
1964
  /**
1965
- * Gets the activity comment form action
1966
  *
1967
  * @since BuddyPress (1.2)
1968
  *
1969
  * @uses home_url()
1970
  * @uses bp_get_activity_root_slug()
1971
- * @uses apply_filters() To call the 'bp_get_activity_comment_form_action' hook
1972
  *
1973
- * @return string The activity comment form action
1974
  */
1975
  function bp_get_activity_comment_form_action() {
1976
  return apply_filters( 'bp_get_activity_comment_form_action', home_url( bp_get_activity_root_slug() . '/reply/' ) );
1977
  }
1978
 
1979
  /**
1980
- * Echoes the activity permalink id
1981
  *
1982
  * @since BuddyPress (1.2)
1983
  *
@@ -1988,20 +2199,20 @@ function bp_activity_permalink_id() {
1988
  }
1989
 
1990
  /**
1991
- * Gets the activity permalink id
1992
  *
1993
  * @since BuddyPress (1.2)
1994
  *
1995
- * @uses apply_filters() To call the 'bp_get_activity_permalink_id' hook
1996
  *
1997
- * @return string The activity permalink id
1998
  */
1999
  function bp_get_activity_permalink_id() {
2000
  return apply_filters( 'bp_get_activity_permalink_id', bp_current_action() );
2001
  }
2002
 
2003
  /**
2004
- * Echoes the activity thread permalink
2005
  *
2006
  * @since BuddyPress (1.2)
2007
  *
@@ -2012,14 +2223,14 @@ function bp_activity_thread_permalink() {
2012
  }
2013
 
2014
  /**
2015
- * Gets the activity thread permalink
2016
  *
2017
  * @since BuddyPress (1.2)
2018
  *
2019
  * @uses bp_activity_get_permalink()
2020
- * @uses apply_filters() To call the 'bp_get_activity_thread_permalink' hook
2021
  *
2022
- * @return string $link The activity thread permalink
2023
  */
2024
  function bp_get_activity_thread_permalink() {
2025
  global $activities_template;
@@ -2030,7 +2241,7 @@ function bp_activity_thread_permalink() {
2030
  }
2031
 
2032
  /**
2033
- * Echoes the activity comment permalink
2034
  *
2035
  * @since BuddyPress (1.8)
2036
  *
@@ -2040,14 +2251,14 @@ function bp_activity_comment_permalink() {
2040
  echo bp_get_activity_comment_permalink();
2041
  }
2042
  /**
2043
- * Gets the activity comment permalink
2044
  *
2045
  * @since BuddyPress (1.8)
2046
  *
2047
  * @uses bp_activity_get_permalink()
2048
- * @uses apply_filters() To call the 'bp_get_activity_comment_permalink' hook
2049
  *
2050
- * @return string $link The activity comment permalink
2051
  */
2052
  function bp_get_activity_comment_permalink() {
2053
  global $activities_template;
@@ -2058,7 +2269,7 @@ function bp_activity_comment_permalink() {
2058
  }
2059
 
2060
  /**
2061
- * Echoes the activity favorite link
2062
  *
2063
  * @since BuddyPress (1.2)
2064
  *
@@ -2069,7 +2280,7 @@ function bp_activity_favorite_link() {
2069
  }
2070
 
2071
  /**
2072
- * Gets the activity favorite link
2073
  *
2074
  * @since BuddyPress (1.2)
2075
  *
@@ -2079,7 +2290,7 @@ function bp_activity_favorite_link() {
2079
  * @uses bp_get_activity_root_slug()
2080
  * @uses apply_filters() To call the 'bp_get_activity_favorite_link' hook
2081
  *
2082
- * @return string The activity favorite link
2083
  */
2084
  function bp_get_activity_favorite_link() {
2085
  global $activities_template;
@@ -2087,7 +2298,7 @@ function bp_activity_favorite_link() {
2087
  }
2088
 
2089
  /**
2090
- * Echoes the activity unfavorite link
2091
  *
2092
  * @since BuddyPress (1.2)
2093
  *
@@ -2098,7 +2309,7 @@ function bp_activity_unfavorite_link() {
2098
  }
2099
 
2100
  /**
2101
- * Gets the activity unfavorite link
2102
  *
2103
  * @since BuddyPress (1.2)
2104
  *
@@ -2106,9 +2317,9 @@ function bp_activity_unfavorite_link() {
2106
  * @uses wp_nonce_url()
2107
  * @uses home_url()
2108
  * @uses bp_get_activity_root_slug()
2109
- * @uses apply_filters() To call the 'bp_get_activity_unfavorite_link' hook
2110
  *
2111
- * @return string The activity unfavorite link
2112
  */
2113
  function bp_get_activity_unfavorite_link() {
2114
  global $activities_template;
@@ -2116,7 +2327,7 @@ function bp_activity_unfavorite_link() {
2116
  }
2117
 
2118
  /**
2119
- * Echoes the activity CSS class
2120
  *
2121
  * @since BuddyPress (1.0)
2122
  *
@@ -2127,17 +2338,17 @@ function bp_activity_css_class() {
2127
  }
2128
 
2129
  /**
2130
- * Gets the activity CSS class
2131
  *
2132
  * @since BuddyPress (1.0)
2133
  *
2134
  * @global object $activities_template {@link BP_Activity_Template}
2135
- * @uses apply_filters() To call the 'bp_activity_mini_activity_types' hook
2136
  * @uses bp_activity_get_comment_count()
2137
  * @uses bp_activity_can_comment()
2138
- * @uses apply_filters() To call the 'bp_get_activity_css_class' hook
2139
  *
2140
- * @return string The activity css class
2141
  */
2142
  function bp_get_activity_css_class() {
2143
  global $activities_template;
@@ -2163,7 +2374,7 @@ function bp_activity_css_class() {
2163
  }
2164
 
2165
  /**
2166
- * Display the activity delete link.
2167
  *
2168
  * @since BuddyPress (1.1)
2169
  *
@@ -2186,9 +2397,10 @@ function bp_activity_delete_link() {
2186
  * @uses add_query_arg()
2187
  * @uses wp_get_referer()
2188
  * @uses wp_nonce_url()
2189
- * @uses apply_filters() To call the 'bp_get_activity_delete_link' hook
2190
  *
2191
- * @return string $link Activity delete link. Contains $redirect_to arg if on single activity page.
 
2192
  */
2193
  function bp_get_activity_delete_link() {
2194
  global $activities_template;
@@ -2207,13 +2419,14 @@ function bp_activity_delete_link() {
2207
  }
2208
 
2209
  /**
2210
- * Display the activity latest update link.
2211
  *
2212
  * @since BuddyPress (1.2)
2213
  *
2214
- * @param int $user_id Defaults to 0
2215
- *
2216
  * @uses bp_get_activity_latest_update()
 
 
2217
  */
2218
  function bp_activity_latest_update( $user_id = 0 ) {
2219
  echo bp_get_activity_latest_update( $user_id );
@@ -2224,8 +2437,6 @@ function bp_activity_latest_update( $user_id = 0 ) {
2224
  *
2225
  * @since BuddyPress (1.2)
2226
  *
2227
- * @param int $user_id Defaults to 0
2228
- *
2229
  * @uses bp_is_user_inactive()
2230
  * @uses bp_core_is_user_deleted()
2231
  * @uses bp_get_user_meta()
@@ -2235,7 +2446,9 @@ function bp_activity_latest_update( $user_id = 0 ) {
2235
  * @uses bp_get_activity_root_slug()
2236
  * @uses apply_filters() To call the 'bp_get_activity_latest_update' hook
2237
  *
2238
- * @return string|bool $latest_update The activity latest update link. False on failure
 
 
2239
  */
2240
  function bp_get_activity_latest_update( $user_id = 0 ) {
2241
 
@@ -2255,13 +2468,14 @@ function bp_activity_latest_update( $user_id = 0 ) {
2255
  }
2256
 
2257
  /**
2258
- * Display the activity filter links.
2259
  *
2260
  * @since BuddyPress (1.1)
2261
  *
2262
- * @param array $args Defaults to false
2263
- *
2264
  * @uses bp_get_activity_filter_links()
 
 
2265
  */
2266
  function bp_activity_filter_links( $args = false ) {
2267
  echo bp_get_activity_filter_links( $args );
@@ -2272,17 +2486,20 @@ function bp_activity_filter_links( $args = false ) {
2272
  *
2273
  * @since BuddyPress (1.1)
2274
  *
2275
- * @param array $args Defaults to false
2276
- *
2277
  * @uses wp_parse_args()
2278
  * @uses BP_Activity_Activity::get_recorded_components() {@link BP_Activity_Activity}
2279
  * @uses esc_attr()
2280
  * @uses add_query_arg()
2281
  * @uses remove_query_arg()
2282
- * @uses apply_filters() To call the 'bp_get_activity_filter_link_href' hook
2283
- * @uses apply_filters() To call the 'bp_get_activity_filter_links' hook
2284
  *
2285
- * @return string|bool $component_links The activity filter links. False on failure
 
 
 
 
 
2286
  */
2287
  function bp_get_activity_filter_links( $args = false ) {
2288
 
@@ -2349,15 +2566,15 @@ function bp_activity_filter_links( $args = false ) {
2349
  }
2350
 
2351
  /**
2352
- * Determine if a comment can be made on an activity item
2353
  *
2354
  * @since BuddyPress (1.2)
2355
  *
2356
  * @global object $activities_template {@link BP_Activity_Template}
2357
  * @uses bp_get_activity_action_name()
2358
- * @uses apply_filters() To call the 'bp_activity_can_comment' hook
2359
  *
2360
- * @return bool $can_comment Defaults to true
2361
  */
2362
  function bp_activity_can_comment() {
2363
  global $activities_template;
@@ -2376,15 +2593,16 @@ function bp_activity_can_comment() {
2376
  }
2377
 
2378
  /**
2379
- * Determine if a comment can be made on an activity reply item
2380
  *
2381
- * @since BuddyPress (1.5)
2382
  *
2383
- * @param object $comment Activity comment
2384
  *
2385
  * @uses apply_filters() To call the 'bp_activity_can_comment_reply' hook
2386
  *
2387
- * @return bool $can_comment Defaults to true
 
2388
  */
2389
  function bp_activity_can_comment_reply( $comment ) {
2390
  $can_comment = true;
@@ -2393,13 +2611,15 @@ function bp_activity_can_comment_reply( $comment ) {
2393
  }
2394
 
2395
  /**
2396
- * Determine if an favorites are allowed
 
 
2397
  *
2398
  * @since BuddyPress (1.5)
2399
  *
2400
- * @uses apply_filters() To call the 'bp_activity_can_favorite' hook
2401
  *
2402
- * @return bool $can_favorite Defaults to true
2403
  */
2404
  function bp_activity_can_favorite() {
2405
  $can_favorite = true;
@@ -2408,29 +2628,29 @@ function bp_activity_can_favorite() {
2408
  }
2409
 
2410
  /**
2411
- * Echoes the total favorite count for a specified user
2412
  *
2413
  * @since BuddyPress (1.2)
2414
  *
2415
- * @param int $user_id Defaults to 0
2416
- *
2417
  * @uses bp_get_total_favorite_count_for_user()
 
 
2418
  */
2419
  function bp_total_favorite_count_for_user( $user_id = 0 ) {
2420
  echo bp_get_total_favorite_count_for_user( $user_id );
2421
  }
2422
 
2423
  /**
2424
- * Returns the total favorite count for a specified user
2425
  *
2426
  * @since BuddyPress (1.2)
2427
  *
2428
- * @param int $user_id Defaults to 0
2429
- *
2430
  * @uses bp_activity_total_favorites_for_user()
2431
  * @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook
2432
  *
2433
- * @return int The total favorite count for a specified user
 
2434
  */
2435
  function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
2436
  if ( ! $user_id ) {
@@ -2439,29 +2659,32 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
2439
 
2440
  return apply_filters( 'bp_get_total_favorite_count_for_user', bp_activity_total_favorites_for_user( $user_id ) );
2441
  }
 
2442
 
2443
  /**
2444
- * Echoes the total mention count for a specified user
2445
  *
2446
  * @since BuddyPress (1.2)
2447
  *
2448
- * @param int $user_id Defaults to 0
2449
- *
2450
  * @uses bp_get_total_favorite_count_for_user()
 
 
2451
  */
2452
  function bp_total_mention_count_for_user( $user_id = 0 ) {
2453
  echo bp_get_total_mention_count_for_user( $user_id );
2454
  }
2455
 
2456
  /**
2457
- * Returns the total mention count for a specified user
2458
  *
2459
  * @since BuddyPress (1.2)
2460
  *
2461
- * @param int $user_id Defaults to 0
2462
  * @uses bp_get_user_meta()
2463
- * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook
2464
- * @return int The total mention count for a specified user
 
 
2465
  */
2466
  function bp_get_total_mention_count_for_user( $user_id = 0 ) {
2467
  if ( ! $user_id ) {
@@ -2470,9 +2693,10 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
2470
 
2471
  return apply_filters( 'bp_get_total_mention_count_for_user', bp_get_user_meta( $user_id, 'bp_new_mention_count', true ) );
2472
  }
 
2473
 
2474
  /**
2475
- * Echoes the public message link for displayed user
2476
  *
2477
  * @since BuddyPress (1.2)
2478
  *
@@ -2483,38 +2707,37 @@ function bp_send_public_message_link() {
2483
  }
2484
 
2485
  /**
2486
- * Returns the public message link for displayed user
2487
  *
2488
  * @since BuddyPress (1.2)
2489
  *
2490
- * @global object $bp BuddyPress global settings
2491
- * @uses bp_is_my_profile()
2492
  * @uses is_user_logged_in()
 
 
2493
  * @uses wp_nonce_url()
2494
- * @uses bp_loggedin_user_domain()
2495
- * @uses bp_get_activity_slug()
2496
- * @uses bp_core_get_username()
2497
  * @uses apply_filters() To call the 'bp_get_send_public_message_link' hook
2498
  *
2499
- * @return string The public message link for displayed user
2500
  */
2501
  function bp_get_send_public_message_link() {
2502
- global $bp;
2503
 
2504
- if ( bp_is_my_profile() || !is_user_logged_in() )
2505
  return false;
2506
 
2507
- return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( bp_get_activity_directory_permalink() . '?r=' . bp_core_get_username( bp_displayed_user_id(), bp_get_displayed_user_username(), $bp->displayed_user->userdata->user_login ) ) );
2508
  }
2509
 
 
2510
  /**
2511
- * Echoes the mentioned user display name
2512
  *
2513
  * @since BuddyPress (1.2)
2514
  *
2515
- * @param int|string User id or username
2516
- *
2517
  * @uses bp_get_mentioned_user_display_name()
 
 
2518
  */
2519
  function bp_mentioned_user_display_name( $user_id_or_username ) {
2520
  echo bp_get_mentioned_user_display_name( $user_id_or_username );
@@ -2525,12 +2748,11 @@ function bp_mentioned_user_display_name( $user_id_or_username ) {
2525
  *
2526
  * @since BuddyPress (1.2)
2527
  *
2528
- * @param int|string User id or username
2529
- *
2530
  * @uses bp_core_get_user_displayname()
2531
- * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook
2532
  *
2533
- * @return string The mentioned user display name
 
2534
  */
2535
  function bp_get_mentioned_user_display_name( $user_id_or_username ) {
2536
  if ( !$name = bp_core_get_user_displayname( $user_id_or_username ) )
@@ -2540,31 +2762,45 @@ function bp_mentioned_user_display_name( $user_id_or_username ) {
2540
  }
2541
 
2542
  /**
2543
- * Output button for sending a public message
2544
  *
2545
  * @since BuddyPress (1.2)
2546
  *
2547
- * @param array $args Optional
2548
- *
2549
  * @uses bp_get_send_public_message_button()
 
 
2550
  */
2551
  function bp_send_public_message_button( $args = '' ) {
2552
  echo bp_get_send_public_message_button( $args );
2553
  }
2554
 
2555
  /**
2556
- * Return button for sending a public message
2557
  *
2558
  * @since BuddyPress (1.2)
2559
  *
2560
- * @param array $args Optional
2561
- *
2562
  * @uses bp_get_send_public_message_link()
2563
  * @uses wp_parse_args()
2564
  * @uses bp_get_button()
2565
- * @uses apply_filters() To call the 'bp_get_send_public_message_button' hook
2566
- *
2567
- * @return string The button for sending a public message
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2568
  */
2569
  function bp_get_send_public_message_button( $args = '' ) {
2570
  $defaults = array(
@@ -2586,7 +2822,7 @@ function bp_send_public_message_button( $args = '' ) {
2586
  }
2587
 
2588
  /**
2589
- * Outputs the activity post form action
2590
  *
2591
  * @since BuddyPress (1.2)
2592
  *
@@ -2597,27 +2833,33 @@ function bp_activity_post_form_action() {
2597
  }
2598
 
2599
  /**
2600
- * Returns the activity post form action
2601
  *
2602
  * @since BuddyPress (1.2)
2603
  *
2604
  * @uses home_url()
2605
  * @uses bp_get_activity_root_slug()
2606
- * @uses apply_filters() To call the 'bp_get_activity_post_form_action' hook
2607
  *
2608
- * @return string The activity post form action
2609
  */
2610
  function bp_get_activity_post_form_action() {
2611
  return apply_filters( 'bp_get_activity_post_form_action', home_url( bp_get_activity_root_slug() . '/post/' ) );
2612
  }
2613
 
2614
  /**
2615
- * Looks at all the activity comments on the current activity item, and prints the comments' authors's avatar wrapped in <LI> tags.
2616
  *
2617
  * Use this function to easily output activity comment authors' avatars.
2618
  *
2619
- * @param array $args See {@link bp_core_fetch_avatar} for accepted values
 
 
2620
  * @since BuddyPress (1.7)
 
 
 
 
2621
  */
2622
  function bp_activity_comments_user_avatars( $args = array() ) {
2623
  $defaults = array(
@@ -2645,10 +2887,11 @@ function bp_activity_comments_user_avatars( $args = array() ) {
2645
  }
2646
 
2647
  /**
2648
- * Returns the user IDs of everyone who's written an activity comment on the current activity item.
2649
  *
2650
- * @return bool|array Returns false if there is no current activity items
2651
  * @since BuddyPress (1.7)
 
 
2652
  */
2653
  function bp_activity_get_comments_user_ids() {
2654
  if ( empty( $GLOBALS['activities_template']->activity ) || empty( $GLOBALS['activities_template']->activity->children ) )
@@ -2661,9 +2904,10 @@ function bp_activity_get_comments_user_ids() {
2661
  /**
2662
  * Recurse through all activity comments and collect the IDs of the users who wrote them.
2663
  *
2664
- * @param array $comments Array of {@link BP_Activity_Activity} items
2665
- * @return array Array of user IDs
2666
  * @since BuddyPress (1.7)
 
 
 
2667
  */
2668
  function bp_activity_recurse_comments_user_ids( array $comments ) {
2669
  $user_ids = array();
@@ -2683,15 +2927,38 @@ function bp_activity_get_comments_user_ids() {
2683
  return $user_ids;
2684
  }
2685
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2686
 
2687
  /**
2688
- * Renders a list of all the registered activity types for use in a <select> element, or as <input type="checkbox">.
2689
  *
2690
- * @param string $output Optional. Either 'select' or 'checkbox'. Defaults to select.
2691
- * @param string|array $args Optional extra arguments:
2692
- * checkbox_name - Used when type=checkbox. Sets the item's name property.
2693
- * selected - Array of strings of activity types to mark as selected/checked.
2694
  * @since BuddyPress (1.7)
 
 
 
 
 
 
 
 
 
2695
  */
2696
  function bp_activity_types_list( $output = 'select', $args = '' ) {
2697
  $defaults = array(
@@ -2729,7 +2996,7 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
2729
  /* RSS Feed Template Tags ****************************************************/
2730
 
2731
  /**
2732
- * Outputs the sitewide activity feed link
2733
  *
2734
  * @since BuddyPress (1.0)
2735
  *
@@ -2740,22 +3007,22 @@ function bp_sitewide_activity_feed_link() {
2740
  }
2741
 
2742
  /**
2743
- * Returns the sitewide activity feed link
2744
  *
2745
  * @since BuddyPress (1.0)
2746
  *
2747
  * @uses home_url()
2748
  * @uses bp_get_activity_root_slug()
2749
- * @uses apply_filters() To call the 'bp_get_sitewide_activity_feed_link' hook
2750
  *
2751
- * @return string The sitewide activity feed link
2752
  */
2753
  function bp_get_sitewide_activity_feed_link() {
2754
  return apply_filters( 'bp_get_sitewide_activity_feed_link', bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/feed/' );
2755
  }
2756
 
2757
  /**
2758
- * Outputs the member activity feed link
2759
  *
2760
  * @since BuddyPress (1.2)
2761
  *
@@ -2766,19 +3033,19 @@ function bp_member_activity_feed_link() {
2766
  }
2767
 
2768
  /**
2769
- * Outputs the member activity feed link
2770
  *
2771
  * @since BuddyPress (1.0)
2772
  * @deprecated BuddyPress (1.2)
2773
  *
2774
- * @todo properly deprecated in favor of bp_member_activity_feed_link()
2775
  *
2776
  * @uses bp_get_member_activity_feed_link()
2777
  */
2778
  function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link(); }
2779
 
2780
  /**
2781
- * Returns the member activity feed link
2782
  *
2783
  * @since BuddyPress (1.2)
2784
  *
@@ -2789,9 +3056,9 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
2789
  * @uses bp_is_active()
2790
  * @uses bp_get_friends_slug()
2791
  * @uses bp_get_groups_slug()
2792
- * @uses apply_filters() To call the 'bp_get_activities_member_rss_link' hook
2793
  *
2794
- * @return string $link The member activity feed link
2795
  */
2796
  function bp_get_member_activity_feed_link() {
2797
 
@@ -2812,16 +3079,16 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
2812
  }
2813
 
2814
  /**
2815
- * Returns the member activity feed link
2816
  *
2817
  * @since BuddyPress (1.0)
2818
  * @deprecated BuddyPress (1.2)
2819
  *
2820
- * @todo properly deprecated in favor of bp_get_member_activity_feed_link()
2821
  *
2822
  * @uses bp_get_member_activity_feed_link()
2823
  *
2824
- * @return string The member activity feed link
2825
  */
2826
  function bp_get_activities_member_rss_link() { return bp_get_member_activity_feed_link(); }
2827
 
@@ -2829,7 +3096,7 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
2829
  /** Template tags for RSS feed output ****************************************/
2830
 
2831
  /**
2832
- * Outputs the activity feed item guid
2833
  *
2834
  * @since BuddyPress (1.0)
2835
  *
@@ -2840,14 +3107,14 @@ function bp_activity_feed_item_guid() {
2840
  }
2841
 
2842
  /**
2843
- * Returns the activity feed item guid
2844
  *
2845
  * @since BuddyPress (1.2)
2846
  *
2847
  * @global object $activities_template {@link BP_Activity_Template}
2848
- * @uses apply_filters() To call the 'bp_get_activity_feed_item_guid' hook
2849
  *
2850
- * @return string The activity feed item guid
2851
  */
2852
  function bp_get_activity_feed_item_guid() {
2853
  global $activities_template;
@@ -2856,7 +3123,7 @@ function bp_activity_feed_item_guid() {
2856
  }
2857
 
2858
  /**
2859
- * Outputs the activity feed item title
2860
  *
2861
  * @since BuddyPress (1.0)
2862
  *
@@ -2867,7 +3134,7 @@ function bp_activity_feed_item_title() {
2867
  }
2868
 
2869
  /**
2870
- * Returns the activity feed item title
2871
  *
2872
  * @since BuddyPress (1.0)
2873
  *
@@ -2875,9 +3142,9 @@ function bp_activity_feed_item_title() {
2875
  * @uses ent2ncr()
2876
  * @uses convert_chars()
2877
  * @uses bp_create_excerpt()
2878
- * @uses apply_filters() To call the 'bp_get_activity_feed_item_title' hook
2879
  *
2880
- * @return string $title The activity feed item title
2881
  */
2882
  function bp_get_activity_feed_item_title() {
2883
  global $activities_template;
@@ -2900,7 +3167,7 @@ function bp_activity_feed_item_title() {
2900
  }
2901
 
2902
  /**
2903
- * Outputs the activity feed item link
2904
  *
2905
  * @since BuddyPress (1.0)
2906
  *
@@ -2911,14 +3178,14 @@ function bp_activity_feed_item_link() {
2911
  }
2912
 
2913
  /**
2914
- * Returns the activity feed item link
2915
  *
2916
  * @since BuddyPress (1.0)
2917
  *
2918
  * @global object $activities_template {@link BP_Activity_Template}
2919
- * @uses apply_filters() To call the 'bp_get_activity_feed_item_link' hook
2920
  *
2921
- * @return string The activity feed item link
2922
  */
2923
  function bp_get_activity_feed_item_link() {
2924
  global $activities_template;
@@ -2927,7 +3194,7 @@ function bp_activity_feed_item_link() {
2927
  }
2928
 
2929
  /**
2930
- * Outputs the activity feed item date
2931
  *
2932
  * @since BuddyPress (1.0)
2933
  *
@@ -2938,14 +3205,14 @@ function bp_activity_feed_item_date() {
2938
  }
2939
 
2940
  /**
2941
- * Returns the activity feed item date
2942
  *
2943
  * @since BuddyPress (1.0)
2944
  *
2945
  * @global object $activities_template {@link BP_Activity_Template}
2946
- * @uses apply_filters() To call the 'bp_get_activity_feed_item_date' hook
2947
  *
2948
- * @return string The activity feed item date
2949
  */
2950
  function bp_get_activity_feed_item_date() {
2951
  global $activities_template;
@@ -2954,7 +3221,7 @@ function bp_activity_feed_item_date() {
2954
  }
2955
 
2956
  /**
2957
- * Outputs the activity feed item description
2958
  *
2959
  * @since BuddyPress (1.0)
2960
  *
@@ -2965,16 +3232,16 @@ function bp_activity_feed_item_description() {
2965
  }
2966
 
2967
  /**
2968
- * Returns the activity feed item description
2969
  *
2970
  * @since BuddyPress (1.0)
2971
  *
2972
  * @global object $activities_template {@link BP_Activity_Template}
2973
  * @uses ent2ncr()
2974
  * @uses convert_chars()
2975
- * @uses apply_filters() To call the 'bp_get_activity_feed_item_description' hook
2976
  *
2977
- * @return string The activity feed item description
2978
  */
2979
  function bp_get_activity_feed_item_description() {
2980
  global $activities_template;
@@ -2987,7 +3254,7 @@ function bp_activity_feed_item_description() {
2987
  }
2988
 
2989
  /**
2990
- * Template tag so we can hook activity feed to <head>
2991
  *
2992
  * @since BuddyPress (1.5)
2993
  *
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Activity Template Functions.
5
  *
6
  * @package BuddyPress
7
  * @subpackage ActivityTemplate
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
+ * Output the activity component slug.
15
  *
16
  * @since BuddyPress (1.5)
17
  *
21
  echo bp_get_activity_slug();
22
  }
23
  /**
24
+ * Return the activity component slug.
25
  *
26
  * @since BuddyPress (1.5)
27
  *
28
+ * @global object $bp BuddyPress global settings.
29
+ * @uses apply_filters() To call the 'bp_get_activity_slug' hook.
30
+ *
31
+ * @return string The activity component slug.
32
  */
33
  function bp_get_activity_slug() {
34
  global $bp;
36
  }
37
 
38
  /**
39
+ * Output the activity component root slug.
40
  *
41
  * @since BuddyPress (1.5)
42
  *
46
  echo bp_get_activity_root_slug();
47
  }
48
  /**
49
+ * Return the activity component root slug.
50
  *
51
  * @since BuddyPress (1.5)
52
  *
53
+ * @global object $bp BuddyPress global settings.
54
+ * @uses apply_filters() To call the 'bp_get_activity_root_slug' hook.
55
+ *
56
+ * @return string The activity component root slug.
57
  */
58
  function bp_get_activity_root_slug() {
59
  global $bp;
61
  }
62
 
63
  /**
64
+ * Output activity directory permalink.
65
  *
66
  * @since BuddyPress (1.5)
67
  *
71
  echo bp_get_activity_directory_permalink();
72
  }
73
  /**
74
+ * Return activity directory permalink
75
  *
76
  * @since BuddyPress (1.5)
77
  *
78
  * @uses traisingslashit()
79
  * @uses bp_get_root_domain()
80
  * @uses bp_get_activity_root_slug()
81
+ * @uses apply_filters() To call the 'bp_get_activity_directory_permalink' hook.
82
  *
83
+ * @return string Activity directory permalink.
84
  */
85
  function bp_get_activity_directory_permalink() {
86
  return apply_filters( 'bp_get_activity_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() ) );
87
  }
88
 
89
  /**
90
+ * The main activity template loop class.
91
  *
92
+ * This is responsible for loading a group of activity items and displaying them.
93
  *
94
  * @since BuddyPress (1.0)
95
  */
109
  var $full_name;
110
 
111
  /**
112
+ * Constructor method.
113
+ *
114
+ * The arguments passed to this class constructor are of the same
115
+ * format as {@link BP_Activity_Activity::get()}.
116
+ *
117
+ * @see BP_Activity_Activity::get() for a description of the argument
118
+ * structure, as well as default values.
119
+ *
120
+ * @param array $args {
121
+ * Array of arguments. Supports all arguments from
122
+ * BP_Activity_Activity::get(), as well as 'page_arg' and
123
+ * 'include'. Default values for 'per_page' and 'display_comments'
124
+ * differ from the originating function, and are described below.
125
+ * @type string $page_arg The string used as a query parameter in
126
+ * pagination links. Default: 'acpage'.
127
+ * @type array|bool $include Pass an array of activity IDs to
128
+ * retrieve only those items, or false to noop the 'include'
129
+ * parameter. 'include' differs from 'in' in that 'in' forms
130
+ * an IN clause that works in conjunction with other filters
131
+ * passed to the function, while 'include' is interpreted as
132
+ * an exact list of items to retrieve, which skips all other
133
+ * filter-related parameters. Default: false.
134
+ * @type int|bool $per_page Default: 20.
135
+ * @type string|bool $display_comments Default: 'threaded'.
136
+ * }
137
  */
138
  function __construct( $args ) {
139
  global $bp;
248
  }
249
  }
250
 
251
+ /**
252
+ * Whether there are activity items available in the loop.
253
+ *
254
+ * @see bp_has_activities()
255
+ *
256
+ * @return bool True if there are items in the loop, otherwise false.
257
+ */
258
  function has_activities() {
259
  if ( $this->activity_count )
260
  return true;
262
  return false;
263
  }
264
 
265
+ /**
266
+ * Set up the next activity item and iterate index.
267
+ *
268
+ * @return object The next activity item to iterate over.
269
+ */
270
  function next_activity() {
271
  $this->current_activity++;
272
  $this->activity = $this->activities[$this->current_activity];
274
  return $this->activity;
275
  }
276
 
277
+ /**
278
+ * Rewind the posts and reset post index.
279
+ */
280
  function rewind_activities() {
281
  $this->current_activity = -1;
282
  if ( $this->activity_count > 0 ) {
284
  }
285
  }
286
 
287
+ /**
288
+ * Whether there are activity items left in the loop to iterate over.
289
+ *
290
+ * This method is used by {@link bp_activities()} as part of the while loop
291
+ * that controls iteration inside the activities loop, eg:
292
+ * while ( bp_activities() ) { ...
293
+ *
294
+ * @see bp_activities()
295
+ *
296
+ * @return bool True if there are more activity items to show,
297
+ * otherwise false.
298
+ */
299
  function user_activities() {
300
  if ( $this->current_activity + 1 < $this->activity_count ) {
301
  return true;
309
  return false;
310
  }
311
 
312
+ /**
313
+ * Set up the current activity item inside the loop.
314
+ *
315
+ * Used by {@link bp_the_activity()} to set up the current activity item
316
+ * data while looping, so that template tags used during that iteration
317
+ * make reference to the current activity item.
318
+ *
319
+ * @see bp_the_activity()
320
+ */
321
  function the_activity() {
322
 
323
  $this->in_the_loop = true;
332
  }
333
 
334
  /**
335
+ * Initialize the activity loop.
336
  *
337
+ * Based on the $args passed, bp_has_activities() populates the
338
+ * $activities_template global, enabling the use of BuddyPress templates and
339
+ * template functions to display a list of activity items.
340
  *
341
  * @since BuddyPress (1.0)
342
  *
 
 
343
  * @global object $activities_template {@link BP_Activity_Template}
344
+ * @global object $bp BuddyPress global settings.
345
  * @uses groups_is_user_member()
346
  * @uses bp_current_action()
347
  * @uses bp_is_current_action()
352
  * @uses friends_get_friend_user_ids()
353
  * @uses groups_get_user_groups()
354
  * @uses bp_activity_get_user_favorites()
355
+ * @uses apply_filters() To call the 'bp_has_activities' hook.
356
+ *
357
+ * @param array $args {
358
+ * Arguments for limiting the contents of the activity loop. Most
359
+ * arguments are in the same format as {@link BP_Activity_Activity::get()}.
360
+ * However, because the format of the arguments accepted here differs in
361
+ * a number of ways, and because bp_has_activities() determines some
362
+ * default arguments in a dynamic fashion, we list all accepted arguments
363
+ * here as well.
364
+ *
365
+ * Arguments can be passed as an associative array, or as a URL query
366
+ * string (eg, 'user_id=4&display_comments=threaded').
367
+ *
368
+ * @type int $page Which page of results to fetch. Using page=1 without
369
+ * per_page will result in no pagination. Default: 1.
370
+ * @type int|bool $per_page Number of results per page. Default: 20.
371
+ * @type string $page_arg The string used as a query parameter in
372
+ * pagination links. Default: 'acpage'.
373
+ * @type int|bool $max Maximum number of results to return.
374
+ * Default: false (unlimited).
375
+ * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
376
+ * @type array|bool $exclude Array of activity IDs to exclude. Default: false.
377
+ * @type array|bool $in Array of IDs to limit query by (IN). 'in' is
378
+ * intended to be used in conjunction with other filter parameters.
379
+ * Default: false.
380
+ * @type array|bool $include Array of exact activity IDs to query.
381
+ * Providing an 'include' array will override all other filters
382
+ * passed in the argument array. When viewing a the permalink page
383
+ * for a single activity item, this value defaults to the ID of that
384
+ * item. Otherwise the default is false.
385
+ * @type array $meta_query Limit by activitymeta by passing an array of
386
+ * meta_query conditions. See {@link WP_Meta_Query::queries} for a
387
+ * description of the syntax.
388
+ * @type string $search_terms Limit results by a search term. Default: false.
389
+ * @type string|bool $scope Use one of BuddyPress's pre-built filters. In
390
+ * each case, the term 'current user' refers to the displayed user
391
+ * when looking at a user profile, and otherwise to the logged-in user.
392
+ * - 'just-me' retrieves items belonging only to the logged-in user;
393
+ * this is equivalent to passing a 'user_id' argument
394
+ * - 'friends' retrieves items belonging to the friends of the
395
+ * current user
396
+ * - 'groups' retrieves items associated with the groups to which
397
+ * the current user belongs
398
+ * - 'favorites' retrieves the current user's favorited activity
399
+ * items
400
+ * - 'mentions' retrieves activity items where the current user has
401
+ * received an @-mention
402
+ * The default value of 'scope' is set to one of the above if that
403
+ * value appears in the appropriate place in the URL; eg, 'scope' will
404
+ * be 'groups' when visiting http://example.com/members/joe/activity/groups/.
405
+ * Otherwise defaults to false.
406
+ * @type int|array|bool $user_id The ID(s) of user(s) whose activity should
407
+ * be fetched. Pass a single ID or an array of IDs. When viewing a
408
+ * user profile page (but not that user's activity subpages, ie My
409
+ * Friends, My Groups, etc), 'user_id' defaults to the ID of the
410
+ * displayed user. Otherwise the default is false.
411
+ * @type string|array|bool $object Filters by the `component` column in the
412
+ * database, which is generally the component ID in the case of
413
+ * BuddyPress components, or the plugin slug in the case of plugins.
414
+ * For example, 'groups' will limit results to those that are
415
+ * associated with the BP Groups component. Accepts a single
416
+ * component string, or an array of multiple components. Defaults to
417
+ * 'groups' when viewing the page of a single group, the My Groups
418
+ * activity filter, or the Activity > Groups filter of a user profile.
419
+ * Otherwise defaults to false.
420
+ * @type string|array|bool $action Filters by the `type` column in the
421
+ * database, which is a string categorizing the activity item (eg,
422
+ * 'new_blog_post', 'created_group'). Accepts a single type string,
423
+ * or an array of multiple types. Defaults to false.
424
+ * @type int|array|bool $primary_id Filters by the `item_id` column in the
425
+ * database. The meaning of 'primary_id' differs between components/
426
+ * types; for example, in the case of 'created_group', 'primary_id'
427
+ * is the ID of the group. Accepts a single ID, or an array of
428
+ * multiple IDs. When viewing a single group, defaults to the current
429
+ * group ID. When viewing a user's Groups stream page, defaults to
430
+ * the IDs of the user's groups. Otherwise defaults to false.
431
+ * @type int|array|bool $secondary_id Filters by the `secondary_item_id`
432
+ * column in the database. The meaning of 'secondary_id' differs
433
+ * between components/types. Accepts a single ID, or an array of
434
+ * multiple IDs. Defaults to false.
435
+ * @type string|bool $display_comments How to handle activity comments.
436
+ * Possible values:
437
+ * - 'threaded' - comments appear in a threaded tree, under their
438
+ * parent items
439
+ * - 'stream' - the activity stream is presented in a flat manner,
440
+ * with comments sorted in chronological order alongside other
441
+ * activity items
442
+ * - false - don't fetch activity comments at all
443
+ * Default: 'threaded'.
444
+ * @type bool $show_hidden Whether to show items marked hide_sitewide.
445
+ * Defaults to false, except in the following cases:
446
+ * - User is viewing his own activity stream
447
+ * - User is viewing the activity stream of a non-public group of
448
+ * which he is a member
449
+ * @type bool $show_hidden Normally defaults to false, except when:
450
+ * - a user is viewing his own activity stream
451
+ * - a user is viewing the activity stream of a non-public group of
452
+ * which he is a member
453
+ * @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false
454
+ * to show all activity regardless of spam status. Default: 'ham_only'.
455
+ * }
456
+ * @return bool Returns true when activities are found, otherwise false.
457
  */
458
  function bp_has_activities( $args = '' ) {
459
  global $activities_template, $bp;
529
  $r = wp_parse_args( $args, $defaults );
530
  extract( $r );
531
 
532
+ // Translate various values for 'display_comments'
533
+ // This allows disabling comments via ?display_comments=0
534
+ // or =none or =false. Final true is a strict type check. See #5029
535
+ if ( in_array( $display_comments, array( 0, '0', 'none', 'false' ), true ) ) {
536
+ $display_comments = false;
537
+ }
538
+
539
  if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) )
540
  $search_terms = $_REQUEST['s'];
541
 
590
  }
591
 
592
  // Start search at @ symbol and stop search at closing tag delimiter.
593
+ $search_terms = '@' . bp_activity_get_user_mentionname( $user_id ) . '<';
594
  $display_comments = 'stream';
595
  $user_id = 0;
596
  break;
639
  }
640
 
641
  /**
642
+ * Determine if there are still activities left in the loop.
643
  *
644
  * @since BuddyPress (1.0)
645
  *
646
  * @global object $activities_template {@link BP_Activity_Template}
647
  * @uses BP_Activity_Template::user_activities() {@link BP_Activity_Template::user_activities()}
648
  *
649
+ * @return bool Returns true when activities are found.
650
  */
651
  function bp_activities() {
652
  global $activities_template;
654
  }
655
 
656
  /**
657
+ * Get the current activity object in the loop.
658
  *
659
  * @since BuddyPress (1.0)
660
  *
661
  * @global object $activities_template {@link BP_Activity_Template}
662
  * @uses BP_Activity_Template::the_activity() {@link BP_Activity_Template::the_activity()}
663
  *
664
+ * @return object The current activity within the loop.
665
  */
666
  function bp_the_activity() {
667
  global $activities_template;
669
  }
670
 
671
  /**
672
+ * Output the activity pagination count.
673
  *
674
  * @since BuddyPress (1.0)
675
  *
681
  }
682
 
683
  /**
684
+ * Return the activity pagination count.
685
  *
686
  * @since BuddyPress (1.2)
687
  *
688
  * @global object $activities_template {@link BP_Activity_Template}
689
  * @uses bp_core_number_format()
690
  *
691
+ * @return string The pagination text.
692
  */
693
  function bp_get_activity_pagination_count() {
694
  global $activities_template;
698
  $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
699
  $total = bp_core_number_format( $activities_template->total_activity_count );
700
 
701
+ return sprintf( _n( 'Viewing item %1$s to %2$s (of %3$s item)', 'Viewing item %1$s to %2$s (of %3$s items)', $total, 'buddypress' ), $from_num, $to_num, $total );
702
  }
703
 
704
  /**
705
+ * Output the activity pagination links.
706
  *
707
  * @since BuddyPress (1.0)
708
  *
713
  }
714
 
715
  /**
716
+ * Return the activity pagination links.
717
  *
718
  * @since BuddyPress (1.0)
719
  *
720
  * @global object $activities_template {@link BP_Activity_Template}
721
+ * @uses apply_filters() To call the 'bp_get_activity_pagination_links' hook.
722
  *
723
+ * @return string The pagination links.
724
  */
725
  function bp_get_activity_pagination_links() {
726
  global $activities_template;
729
  }
730
 
731
  /**
732
+ * Return true when there are more activity items to be shown than currently appear.
733
  *
734
  * @since BuddyPress (1.5)
735
  *
736
  * @global object $activities_template {@link BP_Activity_Template}
737
+ * @uses apply_filters() To call the 'bp_activity_has_more_items' hook.
738
  *
739
+ * @return bool $has_more_items True if more items, false if not.
740
  */
741
  function bp_activity_has_more_items() {
742
  global $activities_template;
748
  }
749
 
750
  /**
751
+ * Output the activity count.
752
  *
753
  * @since BuddyPress (1.2)
754
  *
759
  }
760
 
761
  /**
762
+ * Return the activity count.
763
  *
764
  * @since BuddyPress (1.2)
765
  *
766
  * @global object $activities_template {@link BP_Activity_Template}
767
+ * @uses apply_filters() To call the 'bp_get_activity_count' hook.
768
  *
769
+ * @return int The activity count.
770
  */
771
  function bp_get_activity_count() {
772
  global $activities_template;
775
  }
776
 
777
  /**
778
+ * Output the number of activities per page.
779
  *
780
  * @since BuddyPress (1.2)
781
  *
786
  }
787
 
788
  /**
789
+ * Return the number of activities per page.
790
  *
791
  * @since BuddyPress (1.2)
792
  *
793
  * @global object $activities_template {@link BP_Activity_Template}
794
+ * @uses apply_filters() To call the 'bp_get_activity_per_page' hook.
795
  *
796
+ * @return int The activities per page.
797
  */
798
  function bp_get_activity_per_page() {
799
  global $activities_template;
802
  }
803
 
804
  /**
805
+ * Output the activities title.
806
  *
807
  * @since BuddyPress (1.0)
808
  *
809
  * @uses bp_get_activities_title()
810
+ * @todo Deprecate.
811
  */
812
  function bp_activities_title() {
813
  echo bp_get_activities_title();
814
  }
815
 
816
  /**
817
+ * Return the activities title.
818
  *
819
  * @since BuddyPress (1.0)
820
  *
821
  * @global string $bp_activity_title
822
+ * @uses apply_filters() To call the 'bp_get_activities_title' hook.
823
+ * @todo Deprecate.
824
  *
825
+ * @return int The activities title.
826
  */
827
  function bp_get_activities_title() {
828
  global $bp_activity_title;
836
  * @since BuddyPress (1.0)
837
  *
838
  * @uses bp_get_activities_no_activity()
839
+ * @todo Deprecate.
840
  */
841
  function bp_activities_no_activity() {
842
  echo bp_get_activities_no_activity();
849
  *
850
  * @global string $bp_activity_no_activity
851
  * @uses apply_filters() To call the 'bp_get_activities_no_activity' hook
852
+ * @todo Deprecate.
853
  *
854
  * @return string
855
  */
860
  }
861
 
862
  /**
863
+ * Output the activity ID.
864
  *
865
  * @since BuddyPress (1.2)
866
  *
871
  }
872
 
873
  /**
874
+ * Return the activity ID.
875
  *
876
  * @since BuddyPress (1.2)
877
  *
878
  * @global object $activities_template {@link BP_Activity_Template}
879
+ * @uses apply_filters() To call the 'bp_get_activity_id' hook.
880
  *
881
+ * @return int The activity ID.
882
  */
883
  function bp_get_activity_id() {
884
  global $activities_template;
886
  }
887
 
888
  /**
889
+ * Output the activity item ID.
890
  *
891
  * @since BuddyPress (1.2)
892
  *
897
  }
898
 
899
  /**
900
+ * Return the activity item ID.
901
  *
902
  * @since BuddyPress (1.2)
903
  *
904
  * @global object $activities_template {@link BP_Activity_Template}
905
+ * @uses apply_filters() To call the 'bp_get_activity_item_id' hook.
906
  *
907
+ * @return int The activity item ID.
908
  */
909
  function bp_get_activity_item_id() {
910
  global $activities_template;
912
  }
913
 
914
  /**
915
+ * Output the activity secondary item ID.
916
  *
917
  * @since BuddyPress (1.2)
918
  *
923
  }
924
 
925
  /**
926
+ * Return the activity secondary item ID.
927
  *
928
  * @since BuddyPress (1.2)
929
  *
930
  * @global object $activities_template {@link BP_Activity_Template}
931
+ * @uses apply_filters() To call the 'bp_get_activity_secondary_item_id' hook.
932
  *
933
+ * @return int The activity secondary item ID.
934
  */
935
  function bp_get_activity_secondary_item_id() {
936
  global $activities_template;
938
  }
939
 
940
  /**
941
+ * Output the date the activity was recorded.
942
  *
943
  * @since BuddyPress (1.2)
944
  *
949
  }
950
 
951
  /**
952
+ * Return the date the activity was recorded.
953
  *
954
  * @since BuddyPress (1.2)
955
  *
956
  * @global object $activities_template {@link BP_Activity_Template}
957
+ * @uses apply_filters() To call the 'bp_get_activity_date_recorded' hook.
958
  *
959
+ * @return string The date the activity was recorded.
960
  */
961
  function bp_get_activity_date_recorded() {
962
  global $activities_template;
964
  }
965
 
966
  /**
967
+ * Output the activity object name.
968
  *
969
  * @since BuddyPress (1.2)
970
  *
975
  }
976
 
977
  /**
978
+ * Return the activity object name.
979
  *
980
  * @since BuddyPress (1.2)
981
  *
982
  * @global object $activities_template {@link BP_Activity_Template}
983
+ * @uses apply_filters() To call the 'bp_get_activity_object_name' hook.
984
  *
985
+ * @return string The activity object name.
986
  */
987
  function bp_get_activity_object_name() {
988
  global $activities_template;
990
  }
991
 
992
  /**
993
+ * Output the activity type.
994
  *
995
  * @since BuddyPress (1.2)
996
  *
1001
  }
1002
 
1003
  /**
1004
+ * Return the activity type.
1005
  *
1006
  * @since BuddyPress (1.2)
1007
  *
1008
  * @global object $activities_template {@link BP_Activity_Template}
1009
+ * @uses apply_filters() To call the 'bp_get_activity_type' hook.
1010
  *
1011
+ * @return string The activity type.
1012
  */
1013
  function bp_get_activity_type() {
1014
  global $activities_template;
1016
  }
1017
 
1018
  /**
1019
+ * Output the activity action name.
1020
  *
1021
+ * Just a wrapper for bp_activity_type().
1022
  *
1023
  * @since BuddyPress (1.2)
1024
  * @deprecated BuddyPress (1.5)
1031
  function bp_activity_action_name() { echo bp_activity_type(); }
1032
 
1033
  /**
1034
+ * Return the activity type.
1035
  *
1036
+ * Just a wrapper for bp_get_activity_type().
1037
  *
1038
  * @since BuddyPress (1.2)
1039
  * @deprecated BuddyPress (1.5)
1040
  *
1041
+ * @todo Properly deprecate in favor of bp_get_activity_type().
1042
  *
1043
  * @uses bp_get_activity_type()
1044
  *
1045
+ * @return string The activity type.
1046
  */
1047
  function bp_get_activity_action_name() { return bp_get_activity_type(); }
1048
 
1049
  /**
1050
+ * Output the activity user ID.
1051
  *
1052
  * @since BuddyPress (1.1)
1053
  *
1058
  }
1059
 
1060
  /**
1061
+ * Return the activity user ID.
1062
  *
1063
  * @since BuddyPress (1.1)
1064
  *
1065
  * @global object $activities_template {@link BP_Activity_Template}
1066
+ * @uses apply_filters() To call the 'bp_get_activity_user_id' hook.
1067
  *
1068
+ * @return int The activity user ID.
1069
  */
1070
  function bp_get_activity_user_id() {
1071
  global $activities_template;
1073
  }
1074
 
1075
  /**
1076
+ * Output the activity user link.
1077
  *
1078
  * @since BuddyPress (1.2)
1079
  *
1084
  }
1085
 
1086
  /**
1087
+ * Return the activity user link.
1088
  *
1089
  * @since BuddyPress (1.2)
1090
  *
1091
  * @global object $activities_template {@link BP_Activity_Template}
1092
  * @uses bp_core_get_user_domain()
1093
+ * @uses apply_filters() To call the 'bp_get_activity_user_link' hook.
1094
  *
1095
+ * @return string $link The activity user link.
1096
  */
1097
  function bp_get_activity_user_link() {
1098
  global $activities_template;
1106
  }
1107
 
1108
  /**
1109
+ * Output the avatar of the user that performed the action.
1110
  *
1111
  * @since BuddyPress (1.1)
1112
  *
1113
+ * @see bp_get_activity_avatar() for description of arguments.
 
1114
  * @uses bp_get_activity_avatar()
1115
+ *
1116
+ * @param array $args See {@link bp_get_activity_avatar()} for description.
1117
  */
1118
  function bp_activity_avatar( $args = '' ) {
1119
  echo bp_get_activity_avatar( $args );
1120
  }
1121
  /**
1122
+ * Return the avatar of the user that performed the action.
1123
  *
1124
  * @since BuddyPress (1.1)
1125
  *
1126
+ * @see bp_core_fetch_avatar() For a description of the arguments.
 
1127
  * @global object $activities_template {@link BP_Activity_Template}
1128
  * @global object $bp BuddyPress global settings
1129
  * @uses bp_is_single_activity()
1133
  * @uses bp_core_fetch_avatar()
1134
  * @uses apply_filters() To call the 'bp_get_activity_avatar' hook
1135
  *
1136
+ * @param array $args {
1137
+ * Arguments are listed here with an explanation of their defaults.
1138
+ * For more information about the arguments, see
1139
+ * {@link bp_core_fetch_avatar()}.
1140
+ * @type string $alt Default: 'Profile picture of [user name]' if
1141
+ * activity user name is available, otherwise 'Profile picture'.
1142
+ * @type string $class Default: 'avatar'.
1143
+ * @type string|bool $email Default: Email of the activity's
1144
+ * associated user, if available. Otherwise false.
1145
+ * @type string $type Default: 'full' when viewing a single activity
1146
+ * permalink page, otherwise 'thumb'.
1147
+ * @type int|bool $user_id Default: ID of the activity's user.
1148
+ * }
1149
+ * @return string User avatar string.
1150
  */
1151
  function bp_get_activity_avatar( $args = '' ) {
1152
  global $activities_template;
1216
  }
1217
 
1218
  /**
1219
+ * Output the avatar of the object that action was performed on.
1220
  *
1221
  * @since BuddyPress (1.2)
1222
  *
1223
+ * @see bp_get_activity_secondary_avatar() for description of arguments.
 
1224
  * @uses bp_get_activity_secondary_avatar()
1225
+ *
1226
+ * @param array $args See {@link bp_get_activity_secondary_avatar} for description.
1227
  */
1228
  function bp_activity_secondary_avatar( $args = '' ) {
1229
  echo bp_get_activity_secondary_avatar( $args );
1234
  *
1235
  * @since BuddyPress (1.2)
1236
  *
1237
+ * @see bp_core_fetch_avatar() for description of arguments.
 
1238
  * @global object $activities_template {@link BP_Activity_Template}
1239
  * @uses wp_parse_args()
1240
  * @uses get_blog_option()
1241
+ * @uses apply_filters() To call the 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component hook.
1242
+ * @uses apply_filters() To call the 'bp_get_activity_secondary_avatar_item_id' hook.
1243
  * @uses bp_core_fetch_avatar()
1244
+ * @uses apply_filters() To call the 'bp_get_activity_secondary_avatar' hook.
1245
+ *
1246
+ * @param array $args {
1247
+ * For a complete description of arguments, see {@link bp_core_fetch_avatar()}.
1248
+ * @type string $alt Default value varies based on current activity
1249
+ * item component.
1250
+ * @type string $type Default: 'full' when viewing a single activity
1251
+ * permalink page, otherwise 'thumb'.
1252
+ * @type string $class Default: 'avatar'.
1253
+ * @type string|bool $email Default: email of the activity's user.
1254
+ * @type int|bool $user_id Default: ID of the activity's user.
1255
+ * }
1256
  * @return string The secondary avatar
1257
  */
1258
  function bp_get_activity_secondary_avatar( $args = '' ) {
1383
  * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
1384
  * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook
1385
  * @uses bp_insert_activity_meta()
1386
+ * @uses apply_filters_ref_array() To call the 'bp_get_activity_action' hook.
1387
  *
1388
+ * @param array $args {
1389
+ * @type bool $no_timestamp Whether to exclude the timestamp.
1390
+ * }
1391
+ * @return string The activity action.
1392
  */
1393
  function bp_get_activity_action( $args = array() ) {
1394
  global $activities_template;
1427
  *
1428
  * @global object $activities_template {@link BP_Activity_Template}
1429
  * @uses bp_insert_activity_meta()
1430
+ * @uses apply_filters_ref_array() To call the 'bp_get_activity_content_body' hook.
1431
  *
1432
+ * @return string The activity content body.
1433
  */
1434
  function bp_get_activity_content_body() {
1435
  global $activities_template;
1448
  *
1449
  * @global object $activities_template {@link BP_Activity_Template}
1450
  *
1451
+ * @return bool True if activity has content, false otherwise.
1452
  */
1453
  function bp_activity_has_content() {
1454
  global $activities_template;
1460
  }
1461
 
1462
  /**
1463
+ * Output the activity content.
1464
  *
1465
  * @since BuddyPress (1.0)
1466
  * @deprecated BuddyPress (1.5)
1467
  *
1468
+ * @todo properly deprecate this function.
1469
  *
1470
  * @uses bp_get_activity_content()
1471
  */
1474
  }
1475
 
1476
  /**
1477
+ * Return the activity content.
1478
  *
1479
  * @since BuddyPress (1.0)
1480
  * @deprecated BuddyPress (1.5)
1481
  *
1482
+ * @todo properly deprecate this function.
1483
  *
1484
  * @uses bp_get_activity_action()
1485
  * @uses bp_get_activity_content_body()
1486
+ * @uses apply_filters() To call the 'bp_get_activity_content' hook.
1487
  *
1488
+ * @return string The activity content.
1489
  */
1490
  function bp_get_activity_content() {
1491
  /**
1500
  }
1501
 
1502
  /**
1503
+ * Attach metadata about an activity item to the activity content.
1504
  *
1505
+ * This metadata includes the time since the item was posted (which will appear
1506
+ * as a link to the item's permalink).
1507
  *
1508
+ * @since BuddyPress (1.2)
1509
  *
1510
  * @global object $activities_template {@link BP_Activity_Template}
1511
  * @uses bp_core_time_since()
1512
+ * @uses apply_filters_ref_array() To call the 'bp_activity_time_since' hook.
1513
  * @uses bp_is_single_activity()
1514
  * @uses bp_activity_get_permalink()
1515
  * @uses esc_attr__()
1516
+ * @uses apply_filters_ref_array() To call the 'bp_activity_permalink' hook.
1517
+ * @uses apply_filters() To call the 'bp_insert_activity_meta' hook.
1518
  *
1519
+ * @param string $content The activity content.
1520
+ * @return string The activity content with the metadata string attached.
1521
  */
1522
  function bp_insert_activity_meta( $content ) {
1523
  global $activities_template;
1538
  }
1539
 
1540
  /**
1541
+ * Determine if the current user can delete an activity item.
1542
  *
1543
  * @since BuddyPress (1.2)
1544
  *
 
 
1545
  * @global object $activities_template {@link BP_Activity_Template}
1546
  * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
1547
  *
1548
+ * @param object $activity Optional. Falls back on the current item in the loop.
1549
+ * @return bool True if can delete, false otherwise.
1550
  */
1551
  function bp_activity_user_can_delete( $activity = false ) {
1552
  global $activities_template;
1568
  if ( bp_is_item_admin() && bp_is_single_item() )
1569
  $can_delete = true;
1570
 
1571
+ return apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
1572
  }
1573
 
1574
  /**
1575
+ * Output the activity parent content.
1576
  *
1577
  * @since BuddyPress (1.2)
1578
  *
1579
+ * @see bp_get_activity_parent_content() for a description of arguments.
 
1580
  * @uses bp_get_activity_parent_content()
1581
+ *
1582
+ * @param array $args See {@link bp_get_activity_parent_content} for description.
1583
  */
1584
  function bp_activity_parent_content( $args = '' ) {
1585
  echo bp_get_activity_parent_content($args);
1586
  }
1587
 
1588
  /**
1589
+ * Return the activity content.
1590
  *
1591
  * @since BuddyPress (1.2)
1592
  *
 
 
1593
  * @global object $activities_template {@link BP_Activity_Template}
1594
  * @uses wp_parse_args()
1595
+ * @uses apply_filters() To call the 'bp_get_activity_parent_content' hook.
1596
  *
1597
+ * @param array $args {
1598
+ * Array of optional arguments.
1599
+ * @deprecated bool $hide_user No longer used.
1600
+ * }
1601
  * @return mixed False on failure, otherwise the activity parent content
1602
  */
1603
  function bp_get_activity_parent_content( $args = '' ) {
1639
  }
1640
 
1641
  /**
1642
+ * Output the parent activity's user ID.
1643
  *
1644
  * @since BuddyPress (1.7)
1645
  */
1648
  }
1649
 
1650
  /**
1651
+ * Return the parent activity's user ID.
1652
  *
 
 
1653
  * @since BuddyPress (1.7)
1654
+ *
1655
+ * @global BP_Activity_Template $activities_template
1656
+ *
1657
+ * @return bool|int False if parent activity can't be found, otherwise
1658
+ * the parent activity's user ID.
1659
  */
1660
  function bp_get_activity_parent_user_id() {
1661
  global $activities_template;
1682
  }
1683
 
1684
  /**
1685
+ * Output whether or not the current activity is in a current user's favorites.
1686
  *
1687
  * @since BuddyPress (1.2)
1688
  *
1693
  }
1694
 
1695
  /**
1696
+ * Return whether the current activity is in a current user's favorites.
1697
  *
1698
  * @since BuddyPress (1.2)
1699
  *
1700
  * @global object $activities_template {@link BP_Activity_Template}
1701
+ * @uses apply_filters() To call the 'bp_get_activity_is_favorite' hook.
1702
  *
1703
+ * @return bool True if user favorite, false otherwise.
1704
  */
1705
  function bp_get_activity_is_favorite() {
1706
  global $activities_template;
1709
  }
1710
 
1711
  /**
1712
+ * Output the comment markup for an activity item.
1713
  *
1714
  * @since BuddyPress (1.2)
1715
  *
1722
  }
1723
 
1724
  /**
1725
+ * Get the comment markup for an activity item.
1726
  *
1727
  * @since BuddyPress (1.2)
1728
  *
1792
  }
1793
 
1794
  /**
1795
+ * Utility function that returns the comment currently being recursed.
1796
  *
1797
  * @since BuddyPress (1.5)
1798
  *
1799
  * @global object $activities_template {@link BP_Activity_Template}
1800
+ * @uses apply_filters() To call the 'bp_activity_current_comment' hook.
1801
  *
1802
+ * @return object|bool $current_comment The activity comment currently being
1803
+ * displayed. False on failure.
1804
  */
1805
  function bp_activity_current_comment() {
1806
  global $activities_template;
1812
 
1813
 
1814
  /**
1815
+ * Output the ID of the activity comment currently being displayed.
1816
  *
1817
  * @since BuddyPress (1.5)
1818
  *
1823
  }
1824
 
1825
  /**
1826
+ * Return the ID of the activity comment currently being displayed.
1827
  *
1828
  * @since BuddyPress (1.5)
1829
  *
1830
  * @global object $activities_template {@link BP_Activity_Template}
1831
+ * @uses apply_filters() To call the 'bp_activity_comment_id' hook.
1832
  *
1833
+ * @return int|bool $comment_id The ID of the activity comment
1834
+ * currently being displayed, false if none is found.
1835
  */
1836
  function bp_get_activity_comment_id() {
1837
  global $activities_template;
1842
  }
1843
 
1844
  /**
1845
+ * Output the ID of the author of the activity comment currently being displayed.
1846
  *
1847
  * @since BuddyPress (1.5)
1848
  *
1853
  }
1854
 
1855
  /**
1856
+ * Return the ID of the author of the activity comment currently being displayed.
1857
  *
1858
  * @since BuddyPress (1.5)
1859
  *
1860
  * @global object $activities_template {@link BP_Activity_Template}
1861
+ * @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
1862
  *
1863
+ * @return int|bool $user_id The user_id of the author of the displayed
1864
+ * activity comment. False on failure.
1865
  */
1866
  function bp_get_activity_comment_user_id() {
1867
  global $activities_template;
1872
  }
1873
 
1874
  /**
1875
+ * Output the author link for the activity comment currently being displayed.
1876
  *
1877
  * @since BuddyPress (1.5)
1878
  *
1883
  }
1884
 
1885
  /**
1886
+ * Return the author link for the activity comment currently being displayed.
1887
  *
1888
  * @since BuddyPress (1.5)
1889
  *
1891
  * @uses bp_get_activity_comment_user_id()
1892
  * @uses apply_filters() To call the 'bp_activity_comment_user_link' hook
1893
  *
1894
+ * @return string $user_link The URL of the activity comment author's profile.
1895
  */
1896
  function bp_get_activity_comment_user_link() {
1897
  $user_link = bp_core_get_user_domain( bp_get_activity_comment_user_id() );
1900
  }
1901
 
1902
  /**
1903
+ * Output the author name for the activity comment currently being displayed.
1904
  *
1905
  * @since BuddyPress (1.5)
1906
  *
1911
  }
1912
 
1913
  /**
1914
+ * Return the author name for the activity comment currently being displayed.
1915
  *
1916
+ * The use of the 'bp_acomment_name' filter is deprecated. Please use
1917
+ * 'bp_activity_comment_name'.
1918
  *
1919
  * @since BuddyPress (1.5)
1920
  *
1921
  * @global object $activities_template {@link BP_Activity_Template}
1922
+ * @uses apply_filters() To call the 'bp_acomment_name' hook.
1923
+ * @uses apply_filters() To call the 'bp_activity_comment_name' hook.
1924
  *
1925
+ * @return string $name The full name of the activity comment author.
1926
  */
1927
  function bp_get_activity_comment_name() {
1928
  global $activities_template;
1936
  }
1937
 
1938
  /**
1939
+ * Output the date_recorded of the activity comment currently being displayed.
1940
  *
1941
  * @since BuddyPress (1.5)
1942
  *
1947
  }
1948
 
1949
  /**
1950
+ * Return the date_recorded for the activity comment currently being displayed.
1951
  *
1952
  * @since BuddyPress (1.5)
1953
  *
1955
  * @uses bp_core_time_since()
1956
  * @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook
1957
  *
1958
+ * @return string|bool $date_recorded Time since the activity was recorded,
1959
+ * in the form "%s ago". False on failure.
1960
  */
1961
  function bp_get_activity_comment_date_recorded() {
1962
  global $activities_template;
1970
  }
1971
 
1972
  /**
1973
+ * Output the 'delete' URL for the activity comment currently being displayed.
1974
  *
1975
  * @since BuddyPress (1.5)
1976
  *
1989
  * @uses bp_get_root_domain()
1990
  * @uses bp_get_activity_slug()
1991
  * @uses bp_get_activity_comment_id()
1992
+ * @uses apply_filters() To call the 'bp_activity_comment_delete_link' hook.
1993
  *
1994
+ * @return string $link The nonced URL for deleting the current
1995
+ * activity comment.
1996
  */
1997
  function bp_get_activity_comment_delete_link() {
1998
  $link = wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
2001
  }
2002
 
2003
  /**
2004
+ * Output the content of the activity comment currently being displayed.
2005
  *
2006
  * @since BuddyPress (1.5)
2007
  *
2012
  }
2013
 
2014
  /**
2015
+ * Return the content of the activity comment currently being displayed.
2016
  *
2017
+ * The content is run through two filters. 'bp_get_activity_content'
2018
+ * will apply all filters applied to activity items in general. Use
2019
+ * 'bp_activity_comment_content' to modify the content of activity
2020
+ * comments only.
2021
  *
2022
  * @since BuddyPress (1.5)
2023
  *
2024
  * @global object $activities_template {@link BP_Activity_Template}
2025
+ * @uses apply_filters() To call the 'bp_get_activity_content' hook.
2026
+ * @uses apply_filters() To call the 'bp_activity_comment_content' hook.
2027
  *
2028
+ * @return string $content The content of the current activity comment.
2029
  */
2030
  function bp_get_activity_comment_content() {
2031
  global $activities_template;
2036
  }
2037
 
2038
  /**
2039
+ * Output the activity comment count.
2040
  *
2041
  * @since BuddyPress (1.2)
2042
  *
2047
  }
2048
 
2049
  /**
2050
+ * Return the content of the activity comment currently being displayed.
2051
  *
2052
+ * The content is run through two filters. 'bp_get_activity_content'
2053
+ * will apply all filters applied to activity items in general. Use
2054
+ * 'bp_activity_comment_content' to modify the content of activity
2055
+ * comments only.
2056
  *
2057
  * @since BuddyPress (1.2)
2058
  *
 
 
2059
  * @global object $activities_template {@link BP_Activity_Template}
2060
  * @uses bp_activity_recurse_comment_count()
2061
+ * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook.
2062
+ * @todo deprecate $args
2063
  *
2064
+ * @param array $args Deprecated.
2065
+ * @return int $count The activity comment count.
2066
  */
2067
  function bp_activity_get_comment_count( $args = '' ) {
2068
  global $activities_template;
2076
  }
2077
 
2078
  /**
2079
+ * Return the content of the activity comment currently being displayed.
2080
  *
2081
+ * The content is run through two filters. 'bp_get_activity_content'
2082
+ * will apply all filters applied to activity items in general.
2083
+ * Use bp_activity_comment_content to modify the content of
2084
+ * activity comments only.
2085
  *
2086
  * @since BuddyPress (1.2)
2087
  *
 
 
 
 
2088
  * @uses bp_activity_recurse_comment_count()
2089
  * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook
2090
+ * @todo investigate why bp_activity_recurse_comment_count() is used while being declared
2091
  *
2092
+ * @param object $comment Activity comment object.
2093
+ * @param int $count The current iteration count.
2094
  * @return int $count The activity comment count.
2095
  */
2096
  function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
2107
  }
2108
 
2109
  /**
2110
+ * Output the activity comment link.
2111
  *
2112
  * @since BuddyPress (1.2)
2113
  *
2118
  }
2119
 
2120
  /**
2121
+ * Return the activity comment link.
2122
  *
2123
  * @since BuddyPress (1.2)
2124
  *
2125
  * @global object $activities_template {@link BP_Activity_Template}
2126
+ * @uses apply_filters() To call the 'bp_get_activity_comment_link' hook.
2127
  *
2128
+ * @return string The activity comment link.
2129
  */
2130
  function bp_get_activity_comment_link() {
2131
  global $activities_template;
2133
  }
2134
 
2135
  /**
2136
+ * Output the activity comment form no javascript display CSS.
2137
  *
2138
  * @since BuddyPress (1.2)
2139
  *
2144
  }
2145
 
2146
  /**
2147
+ * Return the activity comment form no javascript display CSS.
2148
  *
2149
  * @since BuddyPress (1.2)
2150
  *
2151
  * @global object $activities_template {@link BP_Activity_Template}
2152
  *
2153
+ * @return string|bool The activity comment form no javascript
2154
+ * display CSS. False on failure
2155
  */
2156
  function bp_get_activity_comment_form_nojs_display() {
2157
  global $activities_template;
2162
  }
2163
 
2164
  /**
2165
+ * Output the activity comment form action.
2166
  *
2167
  * @since BuddyPress (1.2)
2168
  *
2173
  }
2174
 
2175
  /**
2176
+ * Return the activity comment form action.
2177
  *
2178
  * @since BuddyPress (1.2)
2179
  *
2180
  * @uses home_url()
2181
  * @uses bp_get_activity_root_slug()
2182
+ * @uses apply_filters() To call the 'bp_get_activity_comment_form_action' hook.
2183
  *
2184
+ * @return string The activity comment form action.
2185
  */
2186
  function bp_get_activity_comment_form_action() {
2187
  return apply_filters( 'bp_get_activity_comment_form_action', home_url( bp_get_activity_root_slug() . '/reply/' ) );
2188
  }
2189
 
2190
  /**
2191
+ * Output the activity permalink ID.
2192
  *
2193
  * @since BuddyPress (1.2)
2194
  *
2199
  }
2200
 
2201
  /**
2202
+ * Return the activity permalink ID.
2203
  *
2204
  * @since BuddyPress (1.2)
2205
  *
2206
+ * @uses apply_filters() To call the 'bp_get_activity_permalink_id' hook.
2207
  *
2208
+ * @return string The activity permalink ID.
2209
  */
2210
  function bp_get_activity_permalink_id() {
2211
  return apply_filters( 'bp_get_activity_permalink_id', bp_current_action() );
2212
  }
2213
 
2214
  /**
2215
+ * Output the activity thread permalink.
2216
  *
2217
  * @since BuddyPress (1.2)
2218
  *
2223
  }
2224
 
2225
  /**
2226
+ * Return the activity thread permalink.
2227
  *
2228
  * @since BuddyPress (1.2)
2229
  *
2230
  * @uses bp_activity_get_permalink()
2231
+ * @uses apply_filters() To call the 'bp_get_activity_thread_permalink' hook.
2232
  *
2233
+ * @return string $link The activity thread permalink.
2234
  */
2235
  function bp_get_activity_thread_permalink() {
2236
  global $activities_template;
2241
  }
2242
 
2243
  /**
2244
+ * Output the activity comment permalink.
2245
  *
2246
  * @since BuddyPress (1.8)
2247
  *
2251
  echo bp_get_activity_comment_permalink();
2252
  }
2253
  /**
2254
+ * Return the activity comment permalink.
2255
  *
2256
  * @since BuddyPress (1.8)
2257
  *
2258
  * @uses bp_activity_get_permalink()
2259
+ * @uses apply_filters() To call the 'bp_get_activity_comment_permalink' hook.
2260
  *
2261
+ * @return string $link The activity comment permalink.
2262
  */
2263
  function bp_get_activity_comment_permalink() {
2264
  global $activities_template;
2269
  }
2270
 
2271
  /**
2272
+ * Output the activity favorite link.
2273
  *
2274
  * @since BuddyPress (1.2)
2275
  *
2280
  }
2281
 
2282
  /**
2283
+ * Return the activity favorite link.
2284
  *
2285
  * @since BuddyPress (1.2)
2286
  *
2290
  * @uses bp_get_activity_root_slug()
2291
  * @uses apply_filters() To call the 'bp_get_activity_favorite_link' hook
2292
  *
2293
+ * @return string The activity favorite link.
2294
  */
2295
  function bp_get_activity_favorite_link() {
2296
  global $activities_template;
2298
  }
2299
 
2300
  /**
2301
+ * Output the activity unfavorite link.
2302
  *
2303
  * @since BuddyPress (1.2)
2304
  *
2309
  }
2310
 
2311
  /**
2312
+ * Return the activity unfavorite link.
2313
  *
2314
  * @since BuddyPress (1.2)
2315
  *
2317
  * @uses wp_nonce_url()
2318
  * @uses home_url()
2319
  * @uses bp_get_activity_root_slug()
2320
+ * @uses apply_filters() To call the 'bp_get_activity_unfavorite_link' hook.
2321
  *
2322
+ * @return string The activity unfavorite link.
2323
  */
2324
  function bp_get_activity_unfavorite_link() {
2325
  global $activities_template;
2327
  }
2328
 
2329
  /**
2330
+ * Output the activity CSS class.
2331
  *
2332
  * @since BuddyPress (1.0)
2333
  *
2338
  }
2339
 
2340
  /**
2341
+ * Return the current activity item's CSS class.
2342
  *
2343
  * @since BuddyPress (1.0)
2344
  *
2345
  * @global object $activities_template {@link BP_Activity_Template}
2346
+ * @uses apply_filters() To call the 'bp_activity_mini_activity_types' hook.
2347
  * @uses bp_activity_get_comment_count()
2348
  * @uses bp_activity_can_comment()
2349
+ * @uses apply_filters() To call the 'bp_get_activity_css_class' hook.
2350
  *
2351
+ * @return string The activity item's CSS class.
2352
  */
2353
  function bp_get_activity_css_class() {
2354
  global $activities_template;
2374
  }
2375
 
2376
  /**
2377
+ * Output the activity delete link.
2378
  *
2379
  * @since BuddyPress (1.1)
2380
  *
2397
  * @uses add_query_arg()
2398
  * @uses wp_get_referer()
2399
  * @uses wp_nonce_url()
2400
+ * @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
2401
  *
2402
+ * @return string $link Activity delete link. Contains $redirect_to arg
2403
+ * if on single activity page.
2404
  */
2405
  function bp_get_activity_delete_link() {
2406
  global $activities_template;
2419
  }
2420
 
2421
  /**
2422
+ * Output the activity latest update link.
2423
  *
2424
  * @since BuddyPress (1.2)
2425
  *
2426
+ * @see bp_get_activity_latest_update() for description of parameters.
 
2427
  * @uses bp_get_activity_latest_update()
2428
+ *
2429
+ * @param int $user_id See {@link bp_get_activity_latest_update()} for description.
2430
  */
2431
  function bp_activity_latest_update( $user_id = 0 ) {
2432
  echo bp_get_activity_latest_update( $user_id );
2437
  *
2438
  * @since BuddyPress (1.2)
2439
  *
 
 
2440
  * @uses bp_is_user_inactive()
2441
  * @uses bp_core_is_user_deleted()
2442
  * @uses bp_get_user_meta()
2446
  * @uses bp_get_activity_root_slug()
2447
  * @uses apply_filters() To call the 'bp_get_activity_latest_update' hook
2448
  *
2449
+ * @param int $user_id If empty, will fall back on displayed user.
2450
+ * @return string|bool $latest_update The activity latest update link.
2451
+ * False on failure
2452
  */
2453
  function bp_get_activity_latest_update( $user_id = 0 ) {
2454
 
2468
  }
2469
 
2470
  /**
2471
+ * Output the activity filter links.
2472
  *
2473
  * @since BuddyPress (1.1)
2474
  *
2475
+ * @see bp_get_activity_filter_links() for description of parameters.
 
2476
  * @uses bp_get_activity_filter_links()
2477
+ *
2478
+ * @param array $args See {@link bp_get_activity_filter_links()} for description.
2479
  */
2480
  function bp_activity_filter_links( $args = false ) {
2481
  echo bp_get_activity_filter_links( $args );
2486
  *
2487
  * @since BuddyPress (1.1)
2488
  *
 
 
2489
  * @uses wp_parse_args()
2490
  * @uses BP_Activity_Activity::get_recorded_components() {@link BP_Activity_Activity}
2491
  * @uses esc_attr()
2492
  * @uses add_query_arg()
2493
  * @uses remove_query_arg()
2494
+ * @uses apply_filters() To call the 'bp_get_activity_filter_link_href' hook.
2495
+ * @uses apply_filters() To call the 'bp_get_activity_filter_links' hook.
2496
  *
2497
+ * @param array $args {
2498
+ * @type string $style The type of markup to use for the links.
2499
+ * 'list', 'paragraph', or 'span'. Default: 'list'.
2500
+ * }
2501
+ * @return string|bool $component_links The activity filter links.
2502
+ * False on failure.
2503
  */
2504
  function bp_get_activity_filter_links( $args = false ) {
2505
 
2566
  }
2567
 
2568
  /**
2569
+ * Determine if a comment can be made on an activity item.
2570
  *
2571
  * @since BuddyPress (1.2)
2572
  *
2573
  * @global object $activities_template {@link BP_Activity_Template}
2574
  * @uses bp_get_activity_action_name()
2575
+ * @uses apply_filters() To call the 'bp_activity_can_comment' hook.
2576
  *
2577
+ * @return bool $can_comment True if item can receive comments.
2578
  */
2579
  function bp_activity_can_comment() {
2580
  global $activities_template;
2593
  }
2594
 
2595
  /**
2596
+ * Determine if a comment can be made on an activity reply item.
2597
  *
2598
+ * Defaults to true, but can be modified by plugins.
2599
  *
2600
+ * @since BuddyPress (1.5)
2601
  *
2602
  * @uses apply_filters() To call the 'bp_activity_can_comment_reply' hook
2603
  *
2604
+ * @param object $comment Activity comment.
2605
+ * @return bool $can_comment True if comment can receive comments.
2606
  */
2607
  function bp_activity_can_comment_reply( $comment ) {
2608
  $can_comment = true;
2611
  }
2612
 
2613
  /**
2614
+ * Determine if an favorites are allowed.
2615
+ *
2616
+ * Defaults to true, but can be modified by plugins.
2617
  *
2618
  * @since BuddyPress (1.5)
2619
  *
2620
+ * @uses apply_filters() To call the 'bp_activity_can_favorite' hook.
2621
  *
2622
+ * @return bool $can_favorite True if comment can receive comments.
2623
  */
2624
  function bp_activity_can_favorite() {
2625
  $can_favorite = true;
2628
  }
2629
 
2630
  /**
2631
+ * Output the total favorite count for a specified user.
2632
  *
2633
  * @since BuddyPress (1.2)
2634
  *
2635
+ * @see bp_get_total_favorite_count_for_user() for description of parameters.
 
2636
  * @uses bp_get_total_favorite_count_for_user()
2637
+ *
2638
+ * @param int $user_id See {@link bp_get_total_favorite_count_for_user()}.
2639
  */
2640
  function bp_total_favorite_count_for_user( $user_id = 0 ) {
2641
  echo bp_get_total_favorite_count_for_user( $user_id );
2642
  }
2643
 
2644
  /**
2645
+ * Return the total favorite count for a specified user.
2646
  *
2647
  * @since BuddyPress (1.2)
2648
  *
 
 
2649
  * @uses bp_activity_total_favorites_for_user()
2650
  * @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook
2651
  *
2652
+ * @param int $user_id ID of user being queried. Default: displayed user ID.
2653
+ * @return int The total favorite count for the specified user.
2654
  */
2655
  function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
2656
  if ( ! $user_id ) {
2659
 
2660
  return apply_filters( 'bp_get_total_favorite_count_for_user', bp_activity_total_favorites_for_user( $user_id ) );
2661
  }
2662
+ add_filter( 'bp_get_total_favorite_count_for_user', 'bp_core_number_format' );
2663
 
2664
  /**
2665
+ * Output the total mention count for a specified user.
2666
  *
2667
  * @since BuddyPress (1.2)
2668
  *
2669
+ * @see bp_get_total_mention_count_for_user() for description of parameters.
 
2670
  * @uses bp_get_total_favorite_count_for_user()
2671
+ *
2672
+ * @param int $user_id See {@link bp_get_total_mention_count_for_user()}.
2673
  */
2674
  function bp_total_mention_count_for_user( $user_id = 0 ) {
2675
  echo bp_get_total_mention_count_for_user( $user_id );
2676
  }
2677
 
2678
  /**
2679
+ * Return the total mention count for a specified user.
2680
  *
2681
  * @since BuddyPress (1.2)
2682
  *
 
2683
  * @uses bp_get_user_meta()
2684
+ * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
2685
+ *
2686
+ * @param int $user_id ID of user being queried. Default: displayed user ID.
2687
+ * @return int The total mention count for the specified user.
2688
  */
2689
  function bp_get_total_mention_count_for_user( $user_id = 0 ) {
2690
  if ( ! $user_id ) {
2693
 
2694
  return apply_filters( 'bp_get_total_mention_count_for_user', bp_get_user_meta( $user_id, 'bp_new_mention_count', true ) );
2695
  }
2696
+ add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
2697
 
2698
  /**
2699
+ * Output the public message link for displayed user.
2700
  *
2701
  * @since BuddyPress (1.2)
2702
  *
2707
  }
2708
 
2709
  /**
2710
+ * Return the public message link for the displayed user.
2711
  *
2712
  * @since BuddyPress (1.2)
2713
  *
 
 
2714
  * @uses is_user_logged_in()
2715
+ * @uses bp_is_my_profile()
2716
+ * @uses bp_is_user()
2717
  * @uses wp_nonce_url()
2718
+ * @uses bp_get_activity_directory_permalink()
 
 
2719
  * @uses apply_filters() To call the 'bp_get_send_public_message_link' hook
2720
  *
2721
+ * @return string The public message link for the displayed user.
2722
  */
2723
  function bp_get_send_public_message_link() {
 
2724
 
2725
+ if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() )
2726
  return false;
2727
 
2728
+ return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( bp_get_activity_directory_permalink() . '?r=' . bp_get_displayed_user_mentionname() ) );
2729
  }
2730
 
2731
+
2732
  /**
2733
+ * Output the mentioned user display name.
2734
  *
2735
  * @since BuddyPress (1.2)
2736
  *
2737
+ * @see bp_get_mentioned_user_display_name() for description of parameters.
 
2738
  * @uses bp_get_mentioned_user_display_name()
2739
+ *
2740
+ * @param int|string $user_id_or_username See {@link bp_get_mentioned_user_display_name()}.
2741
  */
2742
  function bp_mentioned_user_display_name( $user_id_or_username ) {
2743
  echo bp_get_mentioned_user_display_name( $user_id_or_username );
2748
  *
2749
  * @since BuddyPress (1.2)
2750
  *
 
 
2751
  * @uses bp_core_get_user_displayname()
2752
+ * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
2753
  *
2754
+ * @param int|string User ID or username.
2755
+ * @return string The mentioned user's display name.
2756
  */
2757
  function bp_get_mentioned_user_display_name( $user_id_or_username ) {
2758
  if ( !$name = bp_core_get_user_displayname( $user_id_or_username ) )
2762
  }
2763
 
2764
  /**
2765
+ * Output button for sending a public message (an @-mention).
2766
  *
2767
  * @since BuddyPress (1.2)
2768
  *
2769
+ * @see bp_get_send_public_message_button() for description of parameters.
 
2770
  * @uses bp_get_send_public_message_button()
2771
+ *
2772
+ * @param array $args See {@link bp_get_send_public_message_button()}.
2773
  */
2774
  function bp_send_public_message_button( $args = '' ) {
2775
  echo bp_get_send_public_message_button( $args );
2776
  }
2777
 
2778
  /**
2779
+ * Return button for sending a public message (an @-mention).
2780
  *
2781
  * @since BuddyPress (1.2)
2782
  *
 
 
2783
  * @uses bp_get_send_public_message_link()
2784
  * @uses wp_parse_args()
2785
  * @uses bp_get_button()
2786
+ * @uses apply_filters() To call the 'bp_get_send_public_message_button' hook.
2787
+ *
2788
+ * @param array $args {
2789
+ * All arguments are optional. See {@link BP_Button} for complete
2790
+ * descriptions.
2791
+ * @type string $id Default: 'public_message'.
2792
+ * @type string $component Default: 'activity'.
2793
+ * @type bool $must_be_logged_in Default: true.
2794
+ * @type bool $block_self Default: true.
2795
+ * @type string $wrapper_id Default: 'post-mention'.
2796
+ * @type string $link_href Default: the public message link for
2797
+ * the current member in the loop.
2798
+ * @type string $link_title Default: 'Send a public message on your
2799
+ * activity stream.'.
2800
+ * @type string $link_text Default: 'Public Message'.
2801
+ * @type string $link_class Default: 'activity-button mention'.
2802
+ * }
2803
+ * @return string The button for sending a public message.
2804
  */
2805
  function bp_get_send_public_message_button( $args = '' ) {
2806
  $defaults = array(
2822
  }
2823
 
2824
  /**
2825
+ * Output the activity post form action.
2826
  *
2827
  * @since BuddyPress (1.2)
2828
  *
2833
  }
2834
 
2835
  /**
2836
+ * Return the activity post form action.
2837
  *
2838
  * @since BuddyPress (1.2)
2839
  *
2840
  * @uses home_url()
2841
  * @uses bp_get_activity_root_slug()
2842
+ * @uses apply_filters() To call the 'bp_get_activity_post_form_action' hook.
2843
  *
2844
+ * @return string The activity post form action.
2845
  */
2846
  function bp_get_activity_post_form_action() {
2847
  return apply_filters( 'bp_get_activity_post_form_action', home_url( bp_get_activity_root_slug() . '/post/' ) );
2848
  }
2849
 
2850
  /**
2851
+ * Echo a list of linked avatars of users who have commented on the current activity item.
2852
  *
2853
  * Use this function to easily output activity comment authors' avatars.
2854
  *
2855
+ * Avatars are wrapped in <li> elements, but you've got to provide your own
2856
+ * <ul> or <ol> wrapper markup.
2857
+ *
2858
  * @since BuddyPress (1.7)
2859
+ *
2860
+ * @see bp_core_fetch_avatar() for a description of arguments.
2861
+ *
2862
+ * @param array $args See {@link bp_core_fetch_avatar()}.
2863
  */
2864
  function bp_activity_comments_user_avatars( $args = array() ) {
2865
  $defaults = array(
2887
  }
2888
 
2889
  /**
2890
+ * Return the IDs of every user who's left a comment on the current activity item.
2891
  *
 
2892
  * @since BuddyPress (1.7)
2893
+ *
2894
+ * @return bool|array An array of IDs, or false if none are found.
2895
  */
2896
  function bp_activity_get_comments_user_ids() {
2897
  if ( empty( $GLOBALS['activities_template']->activity ) || empty( $GLOBALS['activities_template']->activity->children ) )
2904
  /**
2905
  * Recurse through all activity comments and collect the IDs of the users who wrote them.
2906
  *
 
 
2907
  * @since BuddyPress (1.7)
2908
+ *
2909
+ * @param array $comments Array of {@link BP_Activity_Activity} items.
2910
+ * @return array Array of user IDs.
2911
  */
2912
  function bp_activity_recurse_comments_user_ids( array $comments ) {
2913
  $user_ids = array();
2927
  return $user_ids;
2928
  }
2929
 
2930
+ /**
2931
+ * Output the mentionname for the displayed user.
2932
+ *
2933
+ * @since BuddyPress (1.9.0)
2934
+ */
2935
+ function bp_displayed_user_mentionname() {
2936
+ echo bp_get_displayed_user_mentionname();
2937
+ }
2938
+ /**
2939
+ * Get the mentionname for the displayed user.
2940
+ *
2941
+ * @since BuddyPress (1.9.0)
2942
+ *
2943
+ * @return string Mentionname for the displayed user, if available.
2944
+ */
2945
+ function bp_get_displayed_user_mentionname() {
2946
+ return apply_filters( 'bp_get_displayed_user_mentionname', bp_activity_get_user_mentionname( bp_displayed_user_id() ) );
2947
+ }
2948
 
2949
  /**
2950
+ * Echo a list of all registered activity types for use in dropdowns or checkbox lists.
2951
  *
 
 
 
 
2952
  * @since BuddyPress (1.7)
2953
+ *
2954
+ * @param string $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
2955
+ * @param array $args {
2956
+ * Optional extra arguments.
2957
+ * @type string $checkbox_name When returning checkboxes, sets the 'name'
2958
+ * attribute.
2959
+ * @type array|string $selected A list of types that should be checked/
2960
+ * selected.
2961
+ * }
2962
  */
2963
  function bp_activity_types_list( $output = 'select', $args = '' ) {
2964
  $defaults = array(
2996
  /* RSS Feed Template Tags ****************************************************/
2997
 
2998
  /**
2999
+ * Output the sitewide activity feed link.
3000
  *
3001
  * @since BuddyPress (1.0)
3002
  *
3007
  }
3008
 
3009
  /**
3010
+ * Returns the sitewide activity feed link.
3011
  *
3012
  * @since BuddyPress (1.0)
3013
  *
3014
  * @uses home_url()
3015
  * @uses bp_get_activity_root_slug()
3016
+ * @uses apply_filters() To call the 'bp_get_sitewide_activity_feed_link' hook.
3017
  *
3018
+ * @return string The sitewide activity feed link.
3019
  */
3020
  function bp_get_sitewide_activity_feed_link() {
3021
  return apply_filters( 'bp_get_sitewide_activity_feed_link', bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/feed/' );
3022
  }
3023
 
3024
  /**
3025
+ * Output the member activity feed link.
3026
  *
3027
  * @since BuddyPress (1.2)
3028
  *
3033
  }
3034
 
3035
  /**
3036
+ * Output the member activity feed link.
3037
  *
3038
  * @since BuddyPress (1.0)
3039
  * @deprecated BuddyPress (1.2)
3040
  *
3041
+ * @todo properly deprecate in favor of bp_member_activity_feed_link().
3042
  *
3043
  * @uses bp_get_member_activity_feed_link()
3044
  */
3045
  function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link(); }
3046
 
3047
  /**
3048
+ * Return the member activity feed link.
3049
  *
3050
  * @since BuddyPress (1.2)
3051
  *
3056
  * @uses bp_is_active()
3057
  * @uses bp_get_friends_slug()
3058
  * @uses bp_get_groups_slug()
3059
+ * @uses apply_filters() To call the 'bp_get_activities_member_rss_link' hook.
3060
  *
3061
+ * @return string $link The member activity feed link.
3062
  */
3063
  function bp_get_member_activity_feed_link() {
3064
 
3079
  }
3080
 
3081
  /**
3082
+ * Return the member activity feed link.
3083
  *
3084
  * @since BuddyPress (1.0)
3085
  * @deprecated BuddyPress (1.2)
3086
  *
3087
+ * @todo properly deprecate in favor of bp_get_member_activity_feed_link().
3088
  *
3089
  * @uses bp_get_member_activity_feed_link()
3090
  *
3091
+ * @return string The member activity feed link.
3092
  */
3093
  function bp_get_activities_member_rss_link() { return bp_get_member_activity_feed_link(); }
3094
 
3096
  /** Template tags for RSS feed output ****************************************/
3097
 
3098
  /**
3099
+ * Outputs the activity feed item guid.
3100
  *
3101
  * @since BuddyPress (1.0)
3102
  *
3107
  }
3108
 
3109
  /**
3110
+ * Returns the activity feed item guid.
3111
  *
3112
  * @since BuddyPress (1.2)
3113
  *
3114
  * @global object $activities_template {@link BP_Activity_Template}
3115
+ * @uses apply_filters() To call the 'bp_get_activity_feed_item_guid' hook.
3116
  *
3117
+ * @return string The activity feed item guid.
3118
  */
3119
  function bp_get_activity_feed_item_guid() {
3120
  global $activities_template;
3123
  }
3124
 
3125
  /**
3126
+ * Output the activity feed item title.
3127
  *
3128
  * @since BuddyPress (1.0)
3129
  *
3134
  }
3135
 
3136
  /**
3137
+ * Return the activity feed item title.
3138
  *
3139
  * @since BuddyPress (1.0)
3140
  *
3142
  * @uses ent2ncr()
3143
  * @uses convert_chars()
3144
  * @uses bp_create_excerpt()
3145
+ * @uses apply_filters() To call the 'bp_get_activity_feed_item_title' hook.
3146
  *
3147
+ * @return string $title The activity feed item title.
3148
  */
3149
  function bp_get_activity_feed_item_title() {
3150
  global $activities_template;
3167
  }
3168
 
3169
  /**
3170
+ * Output the activity feed item link
3171
  *
3172
  * @since BuddyPress (1.0)
3173
  *
3178
  }
3179
 
3180
  /**
3181
+ * Return the activity feed item link
3182
  *
3183
  * @since BuddyPress (1.0)
3184
  *
3185
  * @global object $activities_template {@link BP_Activity_Template}
3186
+ * @uses apply_filters() To call the 'bp_get_activity_feed_item_link' hook.
3187
  *
3188
+ * @return string The activity feed item link.
3189
  */
3190
  function bp_get_activity_feed_item_link() {
3191
  global $activities_template;
3194
  }
3195
 
3196
  /**
3197
+ * Output the activity feed item date.
3198
  *
3199
  * @since BuddyPress (1.0)
3200
  *
3205
  }
3206
 
3207
  /**
3208
+ * Return the activity feed item date.
3209
  *
3210
  * @since BuddyPress (1.0)
3211
  *
3212
  * @global object $activities_template {@link BP_Activity_Template}
3213
+ * @uses apply_filters() To call the 'bp_get_activity_feed_item_date' hook.
3214
  *
3215
+ * @return string The activity feed item date.
3216
  */
3217
  function bp_get_activity_feed_item_date() {
3218
  global $activities_template;
3221
  }
3222
 
3223
  /**
3224
+ * Output the activity feed item description.
3225
  *
3226
  * @since BuddyPress (1.0)
3227
  *
3232
  }
3233
 
3234
  /**
3235
+ * Return the activity feed item description.
3236
  *
3237
  * @since BuddyPress (1.0)
3238
  *
3239
  * @global object $activities_template {@link BP_Activity_Template}
3240
  * @uses ent2ncr()
3241
  * @uses convert_chars()
3242
+ * @uses apply_filters() To call the 'bp_get_activity_feed_item_description' hook.
3243
  *
3244
+ * @return string The activity feed item description.
3245
  */
3246
  function bp_get_activity_feed_item_description() {
3247
  global $activities_template;
3254
  }
3255
 
3256
  /**
3257
+ * Template tag so we can hook activity feed to <head>.
3258
  *
3259
  * @since BuddyPress (1.5)
3260
  *
bp-blogs/bp-blogs-actions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Blogs Actions
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsActions
@@ -11,11 +11,9 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Redirect to a random blog in the multisite network
15
  *
16
- * @since BuddyPress (1.0)
17
- * @package BuddyPress
18
- * @subpackage BlogsActions
19
  */
20
  function bp_blogs_redirect_to_random_blog() {
21
 
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Blogs Actions.
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsActions
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
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
 
bp-blogs/bp-blogs-activity.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Blogs Activity
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsActivity
@@ -11,13 +11,13 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Register activity actions for the blogs component
15
  *
16
- * @since BuddyPress (1.0)
17
- * @package BuddyPress
18
- * @subpackage BlogsActivity
19
- * @global type $bp
20
- * @return boolean
21
  */
22
  function bp_blogs_register_activity_actions() {
23
  global $bp;
@@ -39,14 +39,20 @@ function bp_blogs_register_activity_actions() {
39
  add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions' );
40
 
41
  /**
42
- * Record the activity to the actvity stream
43
  *
44
- * @since BuddyPress (1.0)
45
- * @package BuddyPress
46
- * @subpackage BlogsActivity
47
- * @global BuddyPress $bp
48
- * @param array $args
49
- * @return boolean
 
 
 
 
 
 
50
  */
51
  function bp_blogs_record_activity( $args = '' ) {
52
  global $bp;
@@ -94,13 +100,20 @@ function bp_blogs_record_activity( $args = '' ) {
94
  }
95
 
96
  /**
97
- * Delete a blogs activity stream item
98
  *
99
- * @since BuddyPress (1.0)
100
- * @package BuddyPress
101
- * @subpackage BlogsActivity
102
- * @global BuddyPress $bp
103
- * @param array $args
 
 
 
 
 
 
 
104
  */
105
  function bp_blogs_delete_activity( $args = true ) {
106
  global $bp;
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Blogs Activity.
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsActivity
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
+ * Register activity actions for the blogs component.
15
  *
16
+ * @since BuddyPress (1.0.0)
17
+ *
18
+ * @global object $bp The BuddyPress global settings object.
19
+ *
20
+ * @return bool|null Returns false if activity component is not active.
21
  */
22
  function bp_blogs_register_activity_actions() {
23
  global $bp;
39
  add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions' );
40
 
41
  /**
42
+ * Record blog-related activity to the activity stream.
43
  *
44
+ * @since BuddyPress (1.0.0)
45
+ *
46
+ * @see bp_activity_add() for description of parameters.
47
+ * @global object $bp The BuddyPress global settings object.
48
+ *
49
+ * @param array $args {
50
+ * See {@link bp_activity_add()} for complete description of arguments.
51
+ * The arguments listed here have different default values from
52
+ * bp_activity_add().
53
+ * @type string $component Default: 'blogs'.
54
+ * }
55
+ * @return int|bool On success, returns the activity ID. False on failure.
56
  */
57
  function bp_blogs_record_activity( $args = '' ) {
58
  global $bp;
100
  }
101
 
102
  /**
103
+ * Delete a blog-related activity stream item.
104
  *
105
+ * @since BuddyPress (1.0.0)
106
+ *
107
+ * @see bp_activity_delete() for description of parameters.
108
+ * @global object $bp The BuddyPress global settings object.
109
+ *
110
+ * @param array $args {
111
+ * See {@link bp_activity_delete()} for complete description of arguments.
112
+ * The arguments listed here have different default values from
113
+ * bp_activity_add().
114
+ * @type string $component Default: 'blogs'.
115
+ * }
116
+ * @return bool True on success, false on failure.
117
  */
118
  function bp_blogs_delete_activity( $args = true ) {
119
  global $bp;
bp-blogs/bp-blogs-buddybar.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Blogs Activity
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsBuddyBar
@@ -11,15 +11,14 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Add a Sites menu to the BuddyBar
15
  *
16
- * @since BuddyPress (1.0)
17
- * @package BuddyPress
18
- * @subpackage BlogsBuddyBar
19
- * @global BuddyPress $bp
20
- * @return boolean
21
  */
22
-
23
  function bp_adminbar_blogs_menu() {
24
  global $bp;
25
 
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Blogs BuddyBar functions.
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsBuddyBar
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
+ * Add a Sites menu to the BuddyBar.
15
  *
16
+ * @since BuddyPress (1.0.0)
17
+ *
18
+ * @global object $bp The BuddyPress global settings object.
19
+ *
20
+ * @return bool|null Returns false on failure. Otherwise echoes the menu item.
21
  */
 
22
  function bp_adminbar_blogs_menu() {
23
  global $bp;
24
 
bp-blogs/bp-blogs-cache.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Blogs Caching
5
  *
6
  * Caching functions handle the clearing of cached objects and pages on specific
7
  * actions throughout BuddyPress.
@@ -14,13 +14,12 @@
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
  /**
17
- * Clear the blog object cache
18
  *
19
- * @since BuddyPress (1.0)
20
- * @package BuddyPress
21
- * @subpackage BlogsCache
22
- * @param int $blog_id
23
- * @param int $user_id
24
  */
25
  function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
26
  wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
@@ -28,12 +27,12 @@ function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
28
  }
29
 
30
  /**
31
- * Clear cache when a new blog is created
32
  *
33
- * @since BuddyPress (1.0)
34
- * @package BuddyPress
35
- * @subpackage BlogsCache
36
- * @param BP_Blogs_Blog $recorded_blog_obj
37
  */
38
  function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
39
  bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Blogs Caching.
5
  *
6
  * Caching functions handle the clearing of cached objects and pages on specific
7
  * actions throughout BuddyPress.
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
  /**
17
+ * Clear the blog object cache.
18
  *
19
+ * @since BuddyPress (1.0.0)
20
+ *
21
+ * @param int $blog_id ID of the current blog.
22
+ * @param int $user_id ID of the user whose blog cache should be cleared.
 
23
  */
24
  function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
25
  wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
27
  }
28
 
29
  /**
30
+ * Clear cache when a new blog is created.
31
  *
32
+ * @since BuddyPress (1.0.0)
33
+ *
34
+ * @param BP_Blogs_Blog $recorded_blog_obj The recorded blog, passed by
35
+ * 'bp_blogs_new_blog'.
36
  */
37
  function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
38
  bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
bp-blogs/bp-blogs-classes.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Blogs Classes
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsClasses
@@ -11,25 +11,34 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * The main BuddyPress blog class
15
  *
16
- * @since BuddyPress (1.0)
17
- * @package BuddyPress
18
- * @subpackage BlogsClasses
 
19
  */
20
  class BP_Blogs_Blog {
21
- var $id;
22
- var $user_id;
23
- var $blog_id;
24
-
25
- function __construct( $id = null ) {
 
 
 
 
 
26
  if ( !empty( $id ) ) {
27
  $this->id = $id;
28
  $this->populate();
29
  }
30
  }
31
 
32
- function populate() {
 
 
 
33
  global $wpdb, $bp;
34
 
35
  $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
@@ -38,7 +47,12 @@ class BP_Blogs_Blog {
38
  $this->blog_id = $blog->blog_id;
39
  }
40
 
41
- function save() {
 
 
 
 
 
42
  global $wpdb, $bp;
43
 
44
  $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
@@ -73,15 +87,38 @@ class BP_Blogs_Blog {
73
  return $wpdb->insert_id;
74
  }
75
 
76
- function exists() {
 
 
 
 
 
 
77
  global $bp, $wpdb;
78
 
79
  return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
80
  }
81
 
82
- /* Static Functions */
83
-
84
- function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  global $bp, $wpdb;
86
 
87
  if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) )
@@ -127,14 +164,28 @@ class BP_Blogs_Blog {
127
  return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
128
  }
129
 
130
- function delete_blog_for_all( $blog_id ) {
 
 
 
 
 
 
131
  global $wpdb, $bp;
132
 
133
  bp_blogs_delete_blogmeta( $blog_id );
134
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
135
  }
136
 
137
- function delete_blog_for_user( $blog_id, $user_id = null ) {
 
 
 
 
 
 
 
 
138
  global $wpdb, $bp;
139
 
140
  if ( !$user_id )
@@ -143,7 +194,15 @@ class BP_Blogs_Blog {
143
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
144
  }
145
 
146
- function delete_blogs_for_user( $user_id = null ) {
 
 
 
 
 
 
 
 
147
  global $wpdb, $bp;
148
 
149
  if ( !$user_id )
@@ -152,7 +211,24 @@ class BP_Blogs_Blog {
152
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
153
  }
154
 
155
- function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  global $bp, $wpdb;
157
 
158
  if ( !$user_id )
@@ -178,7 +254,16 @@ class BP_Blogs_Blog {
178
  return array( 'blogs' => $user_blogs, 'count' => $total_blog_count );
179
  }
180
 
181
- function get_blog_ids_for_user( $user_id = 0 ) {
 
 
 
 
 
 
 
 
 
182
  global $bp, $wpdb;
183
 
184
  if ( !$user_id )
@@ -187,13 +272,31 @@ class BP_Blogs_Blog {
187
  return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
188
  }
189
 
190
- function is_recorded( $blog_id ) {
 
 
 
 
 
 
 
191
  global $bp, $wpdb;
192
 
193
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
194
  }
195
 
196
- function total_blog_count_for_user( $user_id = null ) {
 
 
 
 
 
 
 
 
 
 
 
197
  global $bp, $wpdb;
198
 
199
  if ( !$user_id )
@@ -207,7 +310,22 @@ class BP_Blogs_Blog {
207
  }
208
  }
209
 
210
- function search_blogs( $filter, $limit = null, $page = null ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  global $wpdb, $bp;
212
 
213
  $filter = esc_sql( like_escape( $filter ) );
@@ -226,7 +344,21 @@ class BP_Blogs_Blog {
226
  return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
227
  }
228
 
229
- function get_all( $limit = null, $page = null ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  global $bp, $wpdb;
231
 
232
  $hidden_sql = !bp_current_user_can( 'bp_moderate' ) ? "AND wb.public = 1" : '';
@@ -238,7 +370,22 @@ class BP_Blogs_Blog {
238
  return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
239
  }
240
 
241
- function get_by_letter( $letter, $limit = null, $page = null ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  global $bp, $wpdb;
243
 
244
  $letter = esc_sql( like_escape( $letter ) );
@@ -256,7 +403,21 @@ class BP_Blogs_Blog {
256
  return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
257
  }
258
 
259
- function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  global $bp, $wpdb;
261
 
262
  if ( empty( $blog_ids ) )
@@ -310,7 +471,15 @@ class BP_Blogs_Blog {
310
  return $paged_blogs;
311
  }
312
 
313
- function is_hidden( $blog_id ) {
 
 
 
 
 
 
 
 
314
  global $wpdb;
315
 
316
  if ( !(int) $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) )
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Blogs Classes.
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsClasses
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
+ * The main BuddyPress blog class.
15
  *
16
+ * A BP_Blogs_Object represents a link between a specific WordPress blog on a
17
+ * network and a specific user on that blog.
18
+ *
19
+ * @since BuddyPress (1.0.0)
20
  */
21
  class BP_Blogs_Blog {
22
+ public $id;
23
+ public $user_id;
24
+ public $blog_id;
25
+
26
+ /**
27
+ * Constructor method.
28
+ *
29
+ * @param int $id Optional. The ID of the blog.
30
+ */
31
+ public function __construct( $id = null ) {
32
  if ( !empty( $id ) ) {
33
  $this->id = $id;
34
  $this->populate();
35
  }
36
  }
37
 
38
+ /**
39
+ * Populate the object with data about the specific activity item.
40
+ */
41
+ public function populate() {
42
  global $wpdb, $bp;
43
 
44
  $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
47
  $this->blog_id = $blog->blog_id;
48
  }
49
 
50
+ /**
51
+ * Save the BP blog data to the database.
52
+ *
53
+ * @return bool True on success, false on failure.
54
+ */
55
+ public function save() {
56
  global $wpdb, $bp;
57
 
58
  $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
87
  return $wpdb->insert_id;
88
  }
89
 
90
+ /**
91
+ * Check whether an association between this user and this blog exists.
92
+ *
93
+ * @return int The number of associations between the user and blog
94
+ * saved in the blog component tables.
95
+ */
96
+ public function exists() {
97
  global $bp, $wpdb;
98
 
99
  return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
100
  }
101
 
102
+ /** Static Methods ***************************************************/
103
+
104
+ /**
105
+ * Retrieve a set of blog-user associations.
106
+ *
107
+ * @param string $type The order in which results should be returned.
108
+ * 'active', 'alphabetical', 'newest', or 'random'.
109
+ * @param int|bool $limit Optional. The maximum records to return.
110
+ * Default: false.
111
+ * @param int|bool $page Optional. The page of records to return.
112
+ * Default: false (unlimited results).
113
+ * @param int $user_id Optional. ID of the user whose blogs are being
114
+ * retrieved. Default: 0.
115
+ * @param string|bool $search_terms Optional. Search by text stored in
116
+ * blogmeta (such as the blog name). Default: false.
117
+ * @return array Multidimensional results array, structured as follows:
118
+ * 'blogs' - Array of located blog objects
119
+ * 'total' - A count of the total blogs matching the filter params
120
+ */
121
+ public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false ) {
122
  global $bp, $wpdb;
123
 
124
  if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) )
164
  return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
165
  }
166
 
167
+ /**
168
+ * Delete the record of a given blog for all users.
169
+ *
170
+ * @param int $blog_id The blog being removed from all users.
171
+ * @return int|bool Number of rows deleted on success, false on failure.
172
+ */
173
+ public static function delete_blog_for_all( $blog_id ) {
174
  global $wpdb, $bp;
175
 
176
  bp_blogs_delete_blogmeta( $blog_id );
177
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
178
  }
179
 
180
+ /**
181
+ * Delete the record of a given blog for a specific user.
182
+ *
183
+ * @param int $blog_id The blog being removed.
184
+ * @param int $user_id Optional. The ID of the user from whom the blog
185
+ * is being removed. If absent, defaults to the logged-in user ID.
186
+ * @return int|bool Number of rows deleted on success, false on failure.
187
+ */
188
+ public static function delete_blog_for_user( $blog_id, $user_id = null ) {
189
  global $wpdb, $bp;
190
 
191
  if ( !$user_id )
194
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
195
  }
196
 
197
+ /**
198
+ * Delete all of a user's blog associations in the BP tables.
199
+ *
200
+ * @param int $user_id Optional. The ID of the user whose blog
201
+ * associations are being deleted. If absent, defaults to
202
+ * logged-in user ID.
203
+ * @return int|bool Number of rows deleted on success, false on failure.
204
+ */
205
+ public static function delete_blogs_for_user( $user_id = null ) {
206
  global $wpdb, $bp;
207
 
208
  if ( !$user_id )
211
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
212
  }
213
 
214
+ /**
215
+ * Get all of a user's blogs, as tracked by BuddyPress.
216
+ *
217
+ * Note that this is different from the WordPress function
218
+ * {@link get_blogs_of_user()}; the current method returns only those
219
+ * blogs that have been recorded by BuddyPress, while the WP function
220
+ * does a true query of a user's blog capabilities.
221
+ *
222
+ * @param int $user_id Optional. ID of the user whose blogs are being
223
+ * queried. Defaults to logged-in user.
224
+ * @param bool $show_hidden Optional. Whether to include blogs that are
225
+ * not marked public. Defaults to true when viewing one's own
226
+ * profile.
227
+ * @return array Multidimensional results array, structured as follows:
228
+ * 'blogs' - Array of located blog objects
229
+ * 'total' - A count of the total blogs for the user.
230
+ */
231
+ public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
232
  global $bp, $wpdb;
233
 
234
  if ( !$user_id )
254
  return array( 'blogs' => $user_blogs, 'count' => $total_blog_count );
255
  }
256
 
257
+ /**
258
+ * Get IDs of all of a user's blogs, as tracked by BuddyPress.
259
+ *
260
+ * This method always includes hidden blogs.
261
+ *
262
+ * @param int $user_id Optional. ID of the user whose blogs are being
263
+ * queried. Defaults to logged-in user.
264
+ * @return int The number of blogs associated with the user.
265
+ */
266
+ public static function get_blog_ids_for_user( $user_id = 0 ) {
267
  global $bp, $wpdb;
268
 
269
  if ( !$user_id )
272
  return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
273
  }
274
 
275
+ /**
276
+ * Check whether a blog has been recorded by BuddyPress.
277
+ *
278
+ * @param int $blog_id ID of the blog being queried.
279
+ * @return int|null The ID of the first located entry in the BP table
280
+ * on success, otherwise null.
281
+ */
282
+ public static function is_recorded( $blog_id ) {
283
  global $bp, $wpdb;
284
 
285
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
286
  }
287
 
288
+ /**
289
+ * Return a count of associated blogs for a given user.
290
+ *
291
+ * Includes hidden blogs when the logged-in user is the same as the
292
+ * $user_id parameter, or when the logged-in user has the bp_moderate
293
+ * cap.
294
+ *
295
+ * @param int $user_id Optional. ID of the user whose blogs are being
296
+ * queried. Defaults to logged-in user.
297
+ * @return int Blog count for the user.
298
+ */
299
+ public static function total_blog_count_for_user( $user_id = null ) {
300
  global $bp, $wpdb;
301
 
302
  if ( !$user_id )
310
  }
311
  }
312
 
313
+ /**
314
+ * Return a list of blogs matching a search term.
315
+ *
316
+ * Matches against blog names and descriptions, as stored in the BP
317
+ * blogmeta table.
318
+ *
319
+ * @param string $filter The search term.
320
+ * @param int $limit Optional. The maximum number of items to return.
321
+ * Default: null (no limit).
322
+ * @param int $page Optional. The page of results to return. Default:
323
+ * null (no limit).
324
+ * @return array Multidimensional results array, structured as follows:
325
+ * 'blogs' - Array of located blog objects
326
+ * 'total' - A count of the total blogs matching the query.
327
+ */
328
+ public static function search_blogs( $filter, $limit = null, $page = null ) {
329
  global $wpdb, $bp;
330
 
331
  $filter = esc_sql( like_escape( $filter ) );
344
  return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
345
  }
346
 
347
+ /**
348
+ * Retrieve a list of all blogs.
349
+ *
350
+ * Query will include hidden blogs if the logged-in user has the
351
+ * 'bp_moderate' cap.
352
+ *
353
+ * @param int $limit Optional. The maximum number of items to return.
354
+ * Default: null (no limit).
355
+ * @param int $page Optional. The page of results to return. Default:
356
+ * null (no limit).
357
+ * @return array Multidimensional results array, structured as follows:
358
+ * 'blogs' - Array of located blog objects
359
+ * 'total' - A count of the total blogs.
360
+ */
361
+ public static function get_all( $limit = null, $page = null ) {
362
  global $bp, $wpdb;
363
 
364
  $hidden_sql = !bp_current_user_can( 'bp_moderate' ) ? "AND wb.public = 1" : '';
370
  return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
371
  }
372
 
373
+ /**
374
+ * Retrieve a list of blogs whose names start with a given letter.
375
+ *
376
+ * Query will include hidden blogs if the logged-in user has the
377
+ * 'bp_moderate' cap.
378
+ *
379
+ * @param string $letter. The letter you're looking for.
380
+ * @param int $limit Optional. The maximum number of items to return.
381
+ * Default: null (no limit).
382
+ * @param int $page Optional. The page of results to return. Default:
383
+ * null (no limit).
384
+ * @return array Multidimensional results array, structured as follows:
385
+ * 'blogs' - Array of located blog objects.
386
+ * 'total' - A count of the total blogs matching the query.
387
+ */
388
+ public static function get_by_letter( $letter, $limit = null, $page = null ) {
389
  global $bp, $wpdb;
390
 
391
  $letter = esc_sql( like_escape( $letter ) );
403
  return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
404
  }
405
 
406
+ /**
407
+ * Fetch blog data not caught in the main query and append it to results array.
408
+ *
409
+ * Gets the following information, which is either unavailable at the
410
+ * time of the original query, or is more efficient to look up in one
411
+ * fell swoop:
412
+ * - The latest post for each blog, include Featured Image data
413
+ * - The blog description
414
+ *
415
+ * @param array $paged_blogs Array of results from the original query.
416
+ * @param array $blog_ids Array of IDs returned from the original query.
417
+ * @param string|bool $type Not currently used. Default: false.
418
+ * @return array $paged_blogs The located blogs array, with the extras added.
419
+ */
420
+ public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
421
  global $bp, $wpdb;
422
 
423
  if ( empty( $blog_ids ) )
471
  return $paged_blogs;
472
  }
473
 
474
+ /**
475
+ * Check whether a given blog is hidden.
476
+ *
477
+ * Checks the 'public' column in the wp_blogs table.
478
+ *
479
+ * @param int $blog_id The ID of the blog being checked.
480
+ * @return bool True if hidden (public = 0), false otherwise.
481
+ */
482
+ public static function is_hidden( $blog_id ) {
483
  global $wpdb;
484
 
485
  if ( !(int) $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) )
bp-blogs/bp-blogs-filters.php CHANGED
@@ -5,10 +5,10 @@
5
  *
6
  * @package BuddyPress
7
  * @subpackage Blogs
8
- * @since BuddyPress (1.6)
9
  */
10
 
11
- // Display filters
12
 
13
  add_filter( 'bp_get_blog_latest_post_title', 'wptexturize' );
14
  add_filter( 'bp_get_blog_latest_post_title', 'convert_chars' );
@@ -22,13 +22,15 @@ add_filter( 'bp_blog_latest_post_content', 'shortcode_unautop' );
22
  add_filter( 'bp_blog_latest_post_content', 'prepend_attachment' );
23
 
24
  /**
25
- * Ensures 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)
28
- * @uses apply_filters() Filter bp_blogs_creation_location to alter the returned value
29
  *
30
- * @param string $url The original URL (points to wp-signup.php by default)
31
- * @return string The new URL
 
 
 
32
  */
33
  function bp_blogs_creation_location( $url ) {
34
  return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create', $url ) );
5
  *
6
  * @package BuddyPress
7
  * @subpackage Blogs
8
+ * @since BuddyPress (1.6.0)
9
  */
10
 
11
+ /** Display Filters **********************************************************/
12
 
13
  add_filter( 'bp_get_blog_latest_post_title', 'wptexturize' );
14
  add_filter( 'bp_get_blog_latest_post_title', 'convert_chars' );
22
  add_filter( 'bp_blog_latest_post_content', 'prepend_attachment' );
23
 
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 ) {
36
  return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create', $url ) );
bp-blogs/bp-blogs-functions.php CHANGED
@@ -1,14 +1,22 @@
1
  <?php
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( !defined( 'ABSPATH' ) ) exit;
4
 
5
  /**
6
- * Checks $bp pages global and looks for directory page
7
  *
8
- * @since BuddyPress (1.5)
9
  *
10
- * @global BuddyPress $bp The one true BuddyPress instance
11
- * @return bool True if set, False if empty
 
12
  */
13
  function bp_blogs_has_directory() {
14
  global $bp;
@@ -16,6 +24,22 @@ function bp_blogs_has_directory() {
16
  return (bool) !empty( $bp->pages->blogs->id );
17
  }
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  function bp_blogs_get_blogs( $args = '' ) {
20
 
21
  $defaults = array(
@@ -33,9 +57,7 @@ function bp_blogs_get_blogs( $args = '' ) {
33
  }
34
 
35
  /**
36
- * Populates the BP blogs table with existing blogs.
37
- *
38
- * @package BuddyPress Blogs
39
  *
40
  * @global object $bp BuddyPress global settings
41
  * @global object $wpdb WordPress database object
@@ -72,16 +94,18 @@ function bp_blogs_record_existing_blogs() {
72
  }
73
 
74
  /**
75
- * Makes BuddyPress aware of sites that shouldn't be recorded to activity streams.
76
  *
77
  * If $user_id is provided, you can restrict site from being recordable
78
  * only to particular users.
79
  *
80
- * @since BuddyPress (1.7)
81
- * @param int $blog_id
82
- * @param int|null $user_id
83
  * @uses apply_filters()
84
- * @return bool True if blog is recordable, false elsewhere
 
 
 
85
  */
86
  function bp_blogs_is_blog_recordable( $blog_id, $user_id = 0 ) {
87
 
@@ -101,16 +125,19 @@ function bp_blogs_is_blog_recordable( $blog_id, $user_id = 0 ) {
101
  }
102
 
103
  /**
104
- * Makes BuddyPress aware of sites that activities shouldn't be trackable.
 
105
  * If $user_id is provided, the developer can restrict site from
106
  * being trackable only to particular users.
107
  *
108
- * @since BuddyPress (1.7)
109
- * @param int $blog_id
110
- * @param int|null $user_id
111
  * @uses bp_blogs_is_blog_recordable
112
  * @uses apply_filters()
113
- * @return bool True if blog is trackable, false elsewhere
 
 
 
114
  */
115
  function bp_blogs_is_blog_trackable( $blog_id, $user_id = 0 ) {
116
 
@@ -130,13 +157,17 @@ function bp_blogs_is_blog_trackable( $blog_id, $user_id = 0 ) {
130
  }
131
 
132
  /**
133
- * Makes BuddyPress aware of a new site so that it can track its activity.
 
 
134
  *
135
- * @since BuddyPress (1.0)
136
- * @param int $blog_id
137
- * @param int $user_id
138
- * @param bool $no_activity Optional; defaults to false
139
  * @uses BP_Blogs_Blog
 
 
 
 
 
 
140
  */
141
  function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
142
 
@@ -184,11 +215,13 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
184
  add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
185
 
186
  /**
187
- * Updates blogname in BuddyPress blogmeta table
188
  *
189
- * @global object $wpdb DB Layer
190
- * @param string $oldvalue Value before save (not used)
191
- * @param string $newvalue Value to change meta to
 
 
192
  */
193
  function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
194
  global $wpdb;
@@ -198,11 +231,13 @@ function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
198
  add_action( 'update_option_blogname', 'bp_blogs_update_option_blogname', 10, 2 );
199
 
200
  /**
201
- * Updates blogdescription in BuddyPress blogmeta table
 
 
202
  *
203
- * @global object $wpdb DB Layer
204
- * @param string $oldvalue Value before save (not used)
205
- * @param string $newvalue Value to change meta to
206
  */
207
  function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) {
208
  global $wpdb;
@@ -211,6 +246,46 @@ function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) {
211
  }
212
  add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 );
213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
215
  global $bp, $wpdb;
216
 
@@ -246,7 +321,11 @@ function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
246
  if ( $is_blog_public || !is_multisite() ) {
247
 
248
  // Record this in activity streams
249
- $post_permalink = get_permalink( $post_id );
 
 
 
 
250
 
251
  if ( is_multisite() )
252
  $activity_action = sprintf( __( '%1$s wrote a new post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' );
@@ -278,7 +357,7 @@ function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
278
  'type' => 'new_blog_post',
279
  'item_id' => $blog_id,
280
  'secondary_item_id' => $post_id,
281
- 'recorded_time' => $post->post_modified_gmt
282
  ));
283
  }
284
 
@@ -290,15 +369,16 @@ function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
290
 
291
  do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id );
292
  }
293
- add_action( 'save_post', 'bp_blogs_record_post', 10, 2 );
294
 
295
  /**
296
- * Record blog comment activity. Checks if blog is public and post is not
297
- * password protected.
 
298
  *
299
- * @param int $comment_id
300
- * @param mixed $is_approved
301
- * @return mixed
 
302
  */
303
  function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
304
  // Get the users comment
@@ -353,7 +433,7 @@ function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
353
 
354
  // Get activity related links
355
  $post_permalink = get_permalink( $recorded_comment->comment_post_ID );
356
- $comment_link = htmlspecialchars( get_comment_link( $recorded_comment->comment_ID ) );
357
 
358
  // Prepare to record in activity streams
359
  if ( is_multisite() )
@@ -384,6 +464,22 @@ function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
384
  add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
385
  add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );
386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  function bp_blogs_add_user_to_blog( $user_id, $role = false, $blog_id = 0 ) {
388
  global $wpdb;
389
 
@@ -409,6 +505,12 @@ add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
409
  add_action( 'profile_update', 'bp_blogs_add_user_to_blog' );
410
  add_action( 'user_register', 'bp_blogs_add_user_to_blog' );
411
 
 
 
 
 
 
 
412
  function bp_blogs_remove_user_from_blog( $user_id, $blog_id = 0 ) {
413
  global $wpdb;
414
 
@@ -420,13 +522,15 @@ function bp_blogs_remove_user_from_blog( $user_id, $blog_id = 0 ) {
420
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_user_from_blog', 10, 2 );
421
 
422
  /**
423
- * Rehooks WP's maybe_add_existing_user_to_blog with a later priority
424
  *
425
- * WordPress catches add-user-to-blog requests at init:10. In some cases, this can precede BP's
426
- * Blogs component. This function bumps the priority of the core function, so that we can be sure
427
- * that the Blogs component is loaded first. See http://buddypress.trac.wordpress.org/ticket/3916
 
428
  *
429
  * @since BuddyPress (1.6)
 
430
  */
431
  function bp_blogs_maybe_add_user_to_blog() {
432
  if ( ! is_multisite() )
@@ -437,6 +541,11 @@ function bp_blogs_maybe_add_user_to_blog() {
437
  }
438
  add_action( 'init', 'bp_blogs_maybe_add_user_to_blog', 1 );
439
 
 
 
 
 
 
440
  function bp_blogs_remove_blog( $blog_id ) {
441
  global $bp;
442
 
@@ -452,6 +561,12 @@ function bp_blogs_remove_blog( $blog_id ) {
452
  }
453
  add_action( 'delete_blog', 'bp_blogs_remove_blog' );
454
 
 
 
 
 
 
 
455
  function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
456
  global $bp;
457
 
@@ -473,6 +588,14 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
473
  }
474
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
475
 
 
 
 
 
 
 
 
 
476
  function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
477
  global $wpdb, $bp;
478
 
@@ -496,6 +619,11 @@ function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
496
  }
497
  add_action( 'delete_post', 'bp_blogs_remove_post' );
498
 
 
 
 
 
 
499
  function bp_blogs_remove_comment( $comment_id ) {
500
  global $wpdb;
501
 
@@ -509,11 +637,13 @@ add_action( 'delete_comment', 'bp_blogs_remove_comment' );
509
  /**
510
  * When a blog comment status transition occurs, update the relevant activity's status.
511
  *
512
- * @global object $bp BuddyPress global settings
 
 
 
513
  * @param string $new_status New comment status.
514
  * @param string $old_status Previous comment status.
515
  * @param object $comment Comment data.
516
- * @since BuddyPress (1.6)
517
  */
518
  function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
519
  global $bp;
@@ -578,6 +708,11 @@ function bp_blogs_transition_activity_status( $new_status, $old_status, $comment
578
  }
579
  add_action( 'transition_comment_status', 'bp_blogs_transition_activity_status', 10, 3 );
580
 
 
 
 
 
 
581
  function bp_blogs_total_blogs() {
582
  if ( !$count = wp_cache_get( 'bp_total_blogs', 'bp' ) ) {
583
  $blogs = BP_Blogs_Blog::get_all();
@@ -587,6 +722,13 @@ function bp_blogs_total_blogs() {
587
  return $count;
588
  }
589
 
 
 
 
 
 
 
 
590
  function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
591
 
592
  if ( empty( $user_id ) )
@@ -600,6 +742,11 @@ function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
600
  return $count;
601
  }
602
 
 
 
 
 
 
603
  function bp_blogs_remove_data_for_blog( $blog_id ) {
604
  global $bp;
605
 
@@ -615,18 +762,54 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
615
  }
616
  add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
617
 
 
 
 
 
 
 
 
 
 
 
618
  function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) {
619
  return BP_Blogs_Blog::get_blogs_for_user( $user_id, $show_hidden );
620
  }
621
 
 
 
 
 
 
 
 
 
 
622
  function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
623
  return BP_Blogs_Blog::get_all( $limit, $page );
624
  }
625
 
 
 
 
 
 
 
 
 
 
626
  function bp_blogs_get_random_blogs( $limit = null, $page = null ) {
627
  return BP_Blogs_Blog::get( 'random', $limit, $page );
628
  }
629
 
 
 
 
 
 
 
 
 
630
  function bp_blogs_is_blog_hidden( $blog_id ) {
631
  return BP_Blogs_Blog::is_hidden( $blog_id );
632
  }
@@ -640,6 +823,19 @@ function bp_blogs_is_blog_hidden( $blog_id ) {
640
  * stored and synced here.
641
  */
642
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
644
  global $wpdb, $bp;
645
 
@@ -665,6 +861,20 @@ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = fa
665
  return true;
666
  }
667
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
668
  function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
669
  global $wpdb, $bp;
670
 
@@ -699,6 +909,17 @@ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
699
  return $metas;
700
  }
701
 
 
 
 
 
 
 
 
 
 
 
 
702
  function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
703
  global $wpdb, $bp;
704
 
@@ -729,6 +950,12 @@ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
729
  return true;
730
  }
731
 
 
 
 
 
 
 
732
  function bp_blogs_remove_data( $user_id ) {
733
  if ( !is_multisite() )
734
  return false;
1
  <?php
2
+ /**
3
+ * Blogs component functions.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage BlogsFunctions
7
+ */
8
+
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
+ * Check whether the $bp global lists an activity directory page.
14
  *
15
+ * @since BuddyPress (1.5.0)
16
  *
17
+ * @global BuddyPress $bp The one true BuddyPress instance.
18
+ *
19
+ * @return bool True if set, false if empty.
20
  */
21
  function bp_blogs_has_directory() {
22
  global $bp;
24
  return (bool) !empty( $bp->pages->blogs->id );
25
  }
26
 
27
+ /**
28
+ * Retrieve a set of blogs
29
+ *
30
+ * @see BP_Blogs_Blog::get() for a description of arguments and return value.
31
+ *
32
+ * @param array $args {
33
+ * Arguments are listed here with their default values. For more
34
+ * information about the arguments, see {@link BP_Blogs_Blog::get()}.
35
+ * @type string $type Default: 'active'.
36
+ * @type int|bool $user_id Default: false.
37
+ * @type string|bool $search_terms Default: false.
38
+ * @type int $per_page Default: 20.
39
+ * @type int $page Default: 1.
40
+ * }
41
+ * @return array See {@link BP_Blogs_Blog::get()}.
42
+ */
43
  function bp_blogs_get_blogs( $args = '' ) {
44
 
45
  $defaults = array(
57
  }
58
 
59
  /**
60
+ * Populate the BP blogs table with existing blogs.
 
 
61
  *
62
  * @global object $bp BuddyPress global settings
63
  * @global object $wpdb WordPress database object
94
  }
95
 
96
  /**
97
+ * Check whether a given blog should be recorded in activity streams.
98
  *
99
  * If $user_id is provided, you can restrict site from being recordable
100
  * only to particular users.
101
  *
102
+ * @since BuddyPress (1.7.0)
103
+ *
 
104
  * @uses apply_filters()
105
+ *
106
+ * @param int $blog_id ID of the blog being checked.
107
+ * @param int $user_id Optional. ID of the user for whom access is being checked.
108
+ * @return bool True if blog is recordable, otherwise false.
109
  */
110
  function bp_blogs_is_blog_recordable( $blog_id, $user_id = 0 ) {
111
 
125
  }
126
 
127
  /**
128
+ * Check whether a given blog should be tracked by the Blogs component.
129
+ *
130
  * If $user_id is provided, the developer can restrict site from
131
  * being trackable only to particular users.
132
  *
133
+ * @since BuddyPress (1.7.0)
134
+ *
 
135
  * @uses bp_blogs_is_blog_recordable
136
  * @uses apply_filters()
137
+ *
138
+ * @param int $blog_id ID of the blog being checked.
139
+ * @param int $user_id Optional. ID of the user for whom access is being checked.
140
+ * @return bool True if blog is trackable, otherwise false.
141
  */
142
  function bp_blogs_is_blog_trackable( $blog_id, $user_id = 0 ) {
143
 
157
  }
158
 
159
  /**
160
+ * Make BuddyPress aware of a new site so that it can track its activity.
161
+ *
162
+ * @since BuddyPress (1.0.0)
163
  *
 
 
 
 
164
  * @uses BP_Blogs_Blog
165
+ *
166
+ * @param int $blog_id ID of the blog being recorded.
167
+ * @param int $user_id ID of the user for whom the blog is being recorded.
168
+ * @param bool $no_activity Optional. Whether to skip recording an activity
169
+ * item about this blog creation. Default: false.
170
+ * @return bool|null Returns false on failure.
171
  */
172
  function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
173
 
215
  add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
216
 
217
  /**
218
+ * Update blog name in BuddyPress blogmeta table.
219
  *
220
+ * @global object $wpdb DB Layer.
221
+ *
222
+ * @param string $oldvalue Value before save. Passed by do_action() but
223
+ * unused here.
224
+ * @param string $newvalue Value to change meta to.
225
  */
226
  function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
227
  global $wpdb;
231
  add_action( 'update_option_blogname', 'bp_blogs_update_option_blogname', 10, 2 );
232
 
233
  /**
234
+ * Update blog description in BuddyPress blogmeta table
235
+ *
236
+ * @global object $wpdb DB Layer.
237
  *
238
+ * @param string $oldvalue Value before save. Passed by do_action() but
239
+ * unused here.
240
+ * @param string $newvalue Value to change meta to.
241
  */
242
  function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) {
243
  global $wpdb;
246
  }
247
  add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 );
248
 
249
+ /**
250
+ * Detect a change in post status, and initiate an activity update if necessary.
251
+ *
252
+ * Posts get new activity updates when (a) they are being published, and (b)
253
+ * they have not already been published. This enables proper posting for
254
+ * regular posts as well as scheduled posts, while preventing post bumping.
255
+ *
256
+ * See #4090, #3746, #2546 for background.
257
+ *
258
+ * @since BuddyPress (1.9.0)
259
+ *
260
+ * @param string $new_status New status for the post.
261
+ * @param string $old_status Old status for the post.
262
+ * @param object $post Post data.
263
+ */
264
+ function bp_blogs_catch_published_post( $new_status, $old_status, $post ) {
265
+
266
+ // Only record published posts
267
+ if ( 'publish' !== $new_status ) {
268
+ return;
269
+ }
270
+
271
+ // Don't record edits (publish -> publish)
272
+ if ( 'publish' === $old_status ) {
273
+ return;
274
+ }
275
+
276
+ return bp_blogs_record_post( $post->ID, $post );
277
+ }
278
+ add_action( 'transition_post_status', 'bp_blogs_catch_published_post', 10, 3 );
279
+
280
+ /**
281
+ * Record a new blog post in the BuddyPress activity stream.
282
+ *
283
+ * @param int $post_id ID of the post being recorded.
284
+ * @param object $post The WP post object passed to the 'save_post' action.
285
+ * @param int $user_id Optional. The user to whom the activity item will be
286
+ * associated. Defaults to the post_author.
287
+ * @return bool|null Returns false on failure.
288
+ */
289
  function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
290
  global $bp, $wpdb;
291
 
321
  if ( $is_blog_public || !is_multisite() ) {
322
 
323
  // Record this in activity streams
324
+ $post_permalink = add_query_arg(
325
+ 'p',
326
+ $post_id,
327
+ trailingslashit( get_home_url( $blog_id ) )
328
+ );
329
 
330
  if ( is_multisite() )
331
  $activity_action = sprintf( __( '%1$s wrote a new post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' );
357
  'type' => 'new_blog_post',
358
  'item_id' => $blog_id,
359
  'secondary_item_id' => $post_id,
360
+ 'recorded_time' => $post->post_date_gmt,
361
  ));
362
  }
363
 
369
 
370
  do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id );
371
  }
 
372
 
373
  /**
374
+ * Record a new blog comment in the BuddyPress activity stream.
375
+ *
376
+ * Only posts the item if blog is public and post is not password-protected.
377
  *
378
+ * @param int $comment_id ID of the comment being recorded.
379
+ * @param bool|string $is_approved Optional. The $is_approved value passed to
380
+ * the 'comment_post' action. Default: true.
381
+ * @return bool|object Returns false on failure, the comment object on success.
382
  */
383
  function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
384
  // Get the users comment
433
 
434
  // Get activity related links
435
  $post_permalink = get_permalink( $recorded_comment->comment_post_ID );
436
+ $comment_link = get_comment_link( $recorded_comment->comment_ID );
437
 
438
  // Prepare to record in activity streams
439
  if ( is_multisite() )
464
  add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
465
  add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );
466
 
467
+ /**
468
+ * Record a user's association with a blog.
469
+ *
470
+ * This function is hooked to several WordPress actions where blog roles are
471
+ * set/changed ('add_user_to_blog', 'profile_update', 'user_register'). It
472
+ * parses the changes, and records them as necessary in the BP blog tracker.
473
+ *
474
+ * BuddyPress does not track blogs for Subscribers.
475
+ *
476
+ * @param int $user_id The ID of the user.
477
+ * @param string|bool $role The WP role being assigned to the user
478
+ * ('subscriber', 'contributor', 'author', 'editor', 'administrator', or
479
+ * a custom role). Defaults to false.
480
+ * @param int $blog_id Default: the current blog ID.
481
+ * @return bool|null False on failure.
482
+ */
483
  function bp_blogs_add_user_to_blog( $user_id, $role = false, $blog_id = 0 ) {
484
  global $wpdb;
485
 
505
  add_action( 'profile_update', 'bp_blogs_add_user_to_blog' );
506
  add_action( 'user_register', 'bp_blogs_add_user_to_blog' );
507
 
508
+ /**
509
+ * Remove a blog-user pair from BP's blog tracker.
510
+ *
511
+ * @param int $user_id ID of the user whose blog is being removed.
512
+ * @param int $blog_id Optional. ID of the blog being removed. Default: current blog ID.
513
+ */
514
  function bp_blogs_remove_user_from_blog( $user_id, $blog_id = 0 ) {
515
  global $wpdb;
516
 
522
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_user_from_blog', 10, 2 );
523
 
524
  /**
525
+ * Rehook WP's maybe_add_existing_user_to_blog with a later priority
526
  *
527
+ * WordPress catches add-user-to-blog requests at init:10. In some cases, this
528
+ * can precede BP's Blogs component. This function bumps the priority of the
529
+ * core function, so that we can be sure that the Blogs component is loaded
530
+ * first. See http://buddypress.trac.wordpress.org/ticket/3916.
531
  *
532
  * @since BuddyPress (1.6)
533
+ * @access private
534
  */
535
  function bp_blogs_maybe_add_user_to_blog() {
536
  if ( ! is_multisite() )
541
  }
542
  add_action( 'init', 'bp_blogs_maybe_add_user_to_blog', 1 );
543
 
544
+ /**
545
+ * Remove the "blog created" item from the BP blogs tracker and activity stream.
546
+ *
547
+ * @param int $blog_id ID of the blog being removed.
548
+ */
549
  function bp_blogs_remove_blog( $blog_id ) {
550
  global $bp;
551
 
561
  }
562
  add_action( 'delete_blog', 'bp_blogs_remove_blog' );
563
 
564
+ /**
565
+ * Remove a blog from the tracker for a specific user.
566
+ *
567
+ * @param int $user_id ID of the user for whom the blog is being removed.
568
+ * @param int $blog_id ID of the blog being removed.
569
+ */
570
  function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
571
  global $bp;
572
 
588
  }
589
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
590
 
591
+ /**
592
+ * Remove a blog post activity item from the activity stream.
593
+ *
594
+ * @param int $post_id ID of the post to be removed.
595
+ * @param int $blog_id Optional. Defaults to current blog ID.
596
+ * @param int $user_id Optional. Defaults to the logged-in user ID. This param
597
+ * is currently unused in the function (but is passed to hooks).
598
+ */
599
  function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
600
  global $wpdb, $bp;
601
 
619
  }
620
  add_action( 'delete_post', 'bp_blogs_remove_post' );
621
 
622
+ /**
623
+ * Remove a blog comment activity item from the activity stream.
624
+ *
625
+ * @param int $comment_id ID of the comment to be removed.
626
+ */
627
  function bp_blogs_remove_comment( $comment_id ) {
628
  global $wpdb;
629
 
637
  /**
638
  * When a blog comment status transition occurs, update the relevant activity's status.
639
  *
640
+ * @since BuddyPress (1.6.0)
641
+ *
642
+ * @global object $bp BuddyPress global settings.
643
+ *
644
  * @param string $new_status New comment status.
645
  * @param string $old_status Previous comment status.
646
  * @param object $comment Comment data.
 
647
  */
648
  function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
649
  global $bp;
708
  }
709
  add_action( 'transition_comment_status', 'bp_blogs_transition_activity_status', 10, 3 );
710
 
711
+ /**
712
+ * Get the total number of blogs being tracked by BuddyPress.
713
+ *
714
+ * @return int $count Total blog count.
715
+ */
716
  function bp_blogs_total_blogs() {
717
  if ( !$count = wp_cache_get( 'bp_total_blogs', 'bp' ) ) {
718
  $blogs = BP_Blogs_Blog::get_all();
722
  return $count;
723
  }
724
 
725
+ /**
726
+ * Get the total number of blogs being tracked by BP for a specific user.
727
+ *
728
+ * @param int $user_id ID of the user being queried. Default: on a user page,
729
+ * the displayed user. Otherwise, the logged-in user.
730
+ * @return int $count Total blog count for the user.
731
+ */
732
  function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
733
 
734
  if ( empty( $user_id ) )
742
  return $count;
743
  }
744
 
745
+ /**
746
+ * Remove the all data related to a given blog from the BP blogs tracker and activity stream.
747
+ *
748
+ * @param int $blog_id The ID of the blog to expunge.
749
+ */
750
  function bp_blogs_remove_data_for_blog( $blog_id ) {
751
  global $bp;
752
 
762
  }
763
  add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
764
 
765
+ /**
766
+ * Get all of a user's blogs, as tracked by BuddyPress.
767
+ *
768
+ * @see BP_Blogs_Blog::get_blogs_for_user() for a description of parameters
769
+ * and return values.
770
+ *
771
+ * @param int $user_id See {@BP_Blogs_Blog::get_blogs_for_user()}.
772
+ * @param bool $show_hidden See {@BP_Blogs_Blog::get_blogs_for_user()}.
773
+ * @return array See {@BP_Blogs_Blog::get_blogs_for_user()}.
774
+ */
775
  function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) {
776
  return BP_Blogs_Blog::get_blogs_for_user( $user_id, $show_hidden );
777
  }
778
 
779
+ /**
780
+ * Retrieve a list of all blogs.
781
+ *
782
+ * @see BP_Blogs_Blog::get_all() for a description of parameters and return values.
783
+ *
784
+ * @param int $limit See {@BP_Blogs_Blog::get_all()}.
785
+ * @param int $page See {@BP_Blogs_Blog::get_all()}.
786
+ * @return array See {@BP_Blogs_Blog::get_all()}.
787
+ */
788
  function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
789
  return BP_Blogs_Blog::get_all( $limit, $page );
790
  }
791
 
792
+ /**
793
+ * Retrieve a random list of blogs.
794
+ *
795
+ * @see BP_Blogs_Blog::get() for a description of parameters and return values.
796
+ *
797
+ * @param int $limit See {@BP_Blogs_Blog::get()}.
798
+ * @param int $page See {@BP_Blogs_Blog::get()}.
799
+ * @return array See {@BP_Blogs_Blog::get()}.
800
+ */
801
  function bp_blogs_get_random_blogs( $limit = null, $page = null ) {
802
  return BP_Blogs_Blog::get( 'random', $limit, $page );
803
  }
804
 
805
+ /**
806
+ * Check whether a given blog is hidden.
807
+ *
808
+ * @see BP_Blogs_Blog::is_hidden() for a description of parameters and return values.
809
+ *
810
+ * @param int $blog_id See {@BP_Blogs_Blog::is_hidden()}.
811
+ * @return bool See {@BP_Blogs_Blog::is_hidden()}.
812
+ */
813
  function bp_blogs_is_blog_hidden( $blog_id ) {
814
  return BP_Blogs_Blog::is_hidden( $blog_id );
815
  }
823
  * stored and synced here.
824
  */
825
 
826
+ /**
827
+ * Delete a metadta from the DB for a blog.
828
+ *
829
+ * @global object $wpdb WordPress database access object.
830
+ * @global object $bp BuddyPress global settings.
831
+ *
832
+ * @param int $blog_id ID of the blog whose metadata is being deleted.
833
+ * @param string $meta_key Optional. The key of the metadata being deleted. If
834
+ * omitted, all BP metadata associated with the blog will be deleted.
835
+ * @param string $meta_value Optional. If present, the metadata will only be
836
+ * deleted if the meta_value matches this parameter.
837
+ * @return bool True on success, false on failure.
838
+ */
839
  function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
840
  global $wpdb, $bp;
841
 
861
  return true;
862
  }
863
 
864
+ /**
865
+ * Get metadata for a given blog.
866
+ *
867
+ * @since BuddyPress (1.2.0)
868
+ *
869
+ * @global object $wpdb WordPress database access object.
870
+ * @global object $bp BuddyPress global settings.
871
+ *
872
+ * @param int $blog_id ID of the blog whose metadata is being requested.
873
+ * @param string $meta_key Optional. If present, only the metadata matching
874
+ * that meta key will be returned. Otherwise, all metadata for the
875
+ * blog will be fetched.
876
+ * @return mixed The meta value(s) being requested.
877
+ */
878
  function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
879
  global $wpdb, $bp;
880
 
909
  return $metas;
910
  }
911
 
912
+ /**
913
+ * Update a piece of blog meta.
914
+ *
915
+ * @global object $wpdb WordPress database access object.
916
+ * @global object $bp BuddyPress global settings.
917
+ *
918
+ * @param int $blog_id ID of the blog whose metadata is being updated.
919
+ * @param string $meta_key Key of the metadata being updated.
920
+ * @param mixed $meta_value Value to be set.
921
+ * @return bool True on success, false on failure.
922
+ */
923
  function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
924
  global $wpdb, $bp;
925
 
950
  return true;
951
  }
952
 
953
+ /**
954
+ * Remove all blog associations for a given user.
955
+ *
956
+ * @param int $user_id ID whose blog data should be removed.
957
+ * @return bool|null Returns false on failure.
958
+ */
959
  function bp_blogs_remove_data( $user_id ) {
960
  if ( !is_multisite() )
961
  return false;
bp-blogs/bp-blogs-loader.php CHANGED
@@ -15,29 +15,35 @@ if ( !defined( 'ABSPATH' ) ) exit;
15
  class BP_Blogs_Component extends BP_Component {
16
 
17
  /**
18
- * Start the blogs component creation process
19
  *
20
- * @since BuddyPress (1.5)
21
  */
22
  function __construct() {
23
  parent::start(
24
  'blogs',
25
  __( 'Site Tracking', 'buddypress' ),
26
- BP_PLUGIN_DIR
 
 
 
27
  );
28
  }
29
 
30
  /**
31
- * Setup globals
32
  *
33
  * The BP_BLOGS_SLUG constant is deprecated, and only used here for
34
  * backwards compatibility.
35
  *
36
- * @since BuddyPress (1.5)
37
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
38
  */
39
  public function setup_globals( $args = array() ) {
40
- global $bp;
41
 
42
  if ( !defined( 'BP_BLOGS_SLUG' ) )
43
  define ( 'BP_BLOGS_SLUG', $this->id );
@@ -50,7 +56,7 @@ class BP_Blogs_Component extends BP_Component {
50
 
51
  // All globals for messaging component.
52
  // Note that global_tables is included in this array.
53
- $globals = array(
54
  'slug' => BP_BLOGS_SLUG,
55
  'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
56
  'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site
@@ -61,11 +67,15 @@ class BP_Blogs_Component extends BP_Component {
61
  );
62
 
63
  // Setup the globals
64
- parent::setup_globals( $globals );
65
  }
66
 
67
  /**
68
- * Include files
 
 
 
 
69
  */
70
  public function includes( $includes = array() ) {
71
  // Files to include
@@ -89,12 +99,17 @@ class BP_Blogs_Component extends BP_Component {
89
  }
90
 
91
  /**
92
- * Setup BuddyBar navigation
93
  *
94
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
 
 
95
  */
96
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
97
- global $bp;
98
 
99
  /**
100
  * Blog/post/comment menus should not appear on single WordPress setups.
@@ -104,8 +119,6 @@ class BP_Blogs_Component extends BP_Component {
104
  if ( !is_multisite() )
105
  return false;
106
 
107
- $sub_nav = array();
108
-
109
  // Add 'Sites' to the main navigation
110
  $main_nav = array(
111
  'name' => sprintf( __( 'Sites <span>%d</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ),
@@ -141,30 +154,32 @@ class BP_Blogs_Component extends BP_Component {
141
  }
142
 
143
  /**
144
- * Set up the Toolbar
 
 
145
  *
146
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
147
  */
148
  public function setup_admin_bar( $wp_admin_nav = array() ) {
149
- global $bp;
150
 
151
  /**
152
- * Blog/post/comment menus should not appear on single WordPress setups.
153
  * Although comments and posts made by users will still show on their
154
  * activity stream.
155
  */
156
  if ( !is_multisite() )
157
  return false;
158
 
159
- // Prevent debug notices
160
- $wp_admin_nav = array();
161
-
162
  // Menus for logged in user
163
  if ( is_user_logged_in() ) {
164
 
165
  $blogs_link = trailingslashit( bp_loggedin_user_domain() . $this->slug );
166
 
167
- // Add the "Blogs" sub menu
168
  $wp_admin_nav[] = array(
169
  'parent' => $bp->my_account_menu_id,
170
  'id' => 'my-account-' . $this->id,
@@ -172,7 +187,7 @@ class BP_Blogs_Component extends BP_Component {
172
  'href' => trailingslashit( $blogs_link )
173
  );
174
 
175
- // My Blogs
176
  $wp_admin_nav[] = array(
177
  'parent' => 'my-account-' . $this->id,
178
  'id' => 'my-account-' . $this->id . '-my-sites',
@@ -180,12 +195,12 @@ class BP_Blogs_Component extends BP_Component {
180
  'href' => trailingslashit( $blogs_link )
181
  );
182
 
183
- // Create a Blog
184
  if ( bp_blog_signup_enabled() ) {
185
  $wp_admin_nav[] = array(
186
  'parent' => 'my-account-' . $this->id,
187
  'id' => 'my-account-' . $this->id . '-create',
188
- 'title' => __( 'Create a Blog', 'buddypress' ),
189
  'href' => trailingslashit( bp_get_blogs_directory_permalink() . 'create' )
190
  );
191
  }
@@ -195,14 +210,12 @@ class BP_Blogs_Component extends BP_Component {
195
  }
196
 
197
  /**
198
- * Sets up the title for pages and <title>
199
- *
200
- * @global BuddyPress $bp The one true BuddyPress instance
201
  */
202
  function setup_title() {
203
- global $bp;
204
 
205
- // Set up the component options navigation for Blog
206
  if ( bp_is_blogs_component() ) {
207
  if ( bp_is_my_profile() ) {
208
  if ( bp_is_active( 'xprofile' ) ) {
@@ -225,8 +238,10 @@ class BP_Blogs_Component extends BP_Component {
225
  }
226
  }
227
 
 
 
 
228
  function bp_setup_blogs() {
229
- global $bp;
230
- $bp->blogs = new BP_Blogs_Component();
231
  }
232
  add_action( 'bp_setup_components', 'bp_setup_blogs', 6 );
15
  class BP_Blogs_Component extends BP_Component {
16
 
17
  /**
18
+ * Start the blogs component creation process.
19
  *
20
+ * @since BuddyPress (1.5.0)
21
  */
22
  function __construct() {
23
  parent::start(
24
  'blogs',
25
  __( 'Site Tracking', 'buddypress' ),
26
+ BP_PLUGIN_DIR,
27
+ array(
28
+ 'adminbar_myaccount_order' => 30
29
+ )
30
  );
31
  }
32
 
33
  /**
34
+ * Set up global settings for the blogs component.
35
  *
36
  * The BP_BLOGS_SLUG constant is deprecated, and only used here for
37
  * backwards compatibility.
38
  *
39
+ * @since BuddyPress (1.5.0)
40
+ *
41
+ * @see BP_Component::setup_globals() for description of parameters.
42
+ *
43
+ * @param array $args See {@link BP_Component::setup_globals()}.
44
  */
45
  public function setup_globals( $args = array() ) {
46
+ $bp = buddypress();
47
 
48
  if ( !defined( 'BP_BLOGS_SLUG' ) )
49
  define ( 'BP_BLOGS_SLUG', $this->id );
56
 
57
  // All globals for messaging component.
58
  // Note that global_tables is included in this array.
59
+ $args = array(
60
  'slug' => BP_BLOGS_SLUG,
61
  'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
62
  'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site
67
  );
68
 
69
  // Setup the globals
70
+ parent::setup_globals( $args );
71
  }
72
 
73
  /**
74
+ * Include bp-blogs files.
75
+ *
76
+ * @see BP_Component::includes() for description of parameters.
77
+ *
78
+ * @param array $includes See {@link BP_Component::includes()}.
79
  */
80
  public function includes( $includes = array() ) {
81
  // Files to include
99
  }
100
 
101
  /**
102
+ * Set up component navigation for bp-blogs.
103
  *
104
+ * @see BP_Component::setup_nav() for a description of arguments.
105
+ *
106
+ * @param array $main_nav Optional. See BP_Component::setup_nav() for
107
+ * description.
108
+ * @param array $sub_nav Optional. See BP_Component::setup_nav() for
109
+ * description.
110
  */
111
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
112
+ $bp = buddypress();
113
 
114
  /**
115
  * Blog/post/comment menus should not appear on single WordPress setups.
119
  if ( !is_multisite() )
120
  return false;
121
 
 
 
122
  // Add 'Sites' to the main navigation
123
  $main_nav = array(
124
  'name' => sprintf( __( 'Sites <span>%d</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ),
154
  }
155
 
156
  /**
157
+ * Set up bp-blogs integration with the WordPress admin bar.
158
+ *
159
+ * @since BuddyPress (1.5.0)
160
  *
161
+ * @see BP_Component::setup_admin_bar() for a description of arguments.
162
+ *
163
+ * @param array $wp_admin_nav See BP_Component::setup_admin_bar()
164
+ * for description.
165
  */
166
  public function setup_admin_bar( $wp_admin_nav = array() ) {
167
+ $bp = buddypress();
168
 
169
  /**
170
+ * Site/post/comment menus should not appear on single WordPress setups.
171
  * Although comments and posts made by users will still show on their
172
  * activity stream.
173
  */
174
  if ( !is_multisite() )
175
  return false;
176
 
 
 
 
177
  // Menus for logged in user
178
  if ( is_user_logged_in() ) {
179
 
180
  $blogs_link = trailingslashit( bp_loggedin_user_domain() . $this->slug );
181
 
182
+ // Add the "Sites" sub menu
183
  $wp_admin_nav[] = array(
184
  'parent' => $bp->my_account_menu_id,
185
  'id' => 'my-account-' . $this->id,
187
  'href' => trailingslashit( $blogs_link )
188
  );
189
 
190
+ // My Sites
191
  $wp_admin_nav[] = array(
192
  'parent' => 'my-account-' . $this->id,
193
  'id' => 'my-account-' . $this->id . '-my-sites',
195
  'href' => trailingslashit( $blogs_link )
196
  );
197
 
198
+ // Create a Site
199
  if ( bp_blog_signup_enabled() ) {
200
  $wp_admin_nav[] = array(
201
  'parent' => 'my-account-' . $this->id,
202
  'id' => 'my-account-' . $this->id . '-create',
203
+ 'title' => __( 'Create a Site', 'buddypress' ),
204
  'href' => trailingslashit( bp_get_blogs_directory_permalink() . 'create' )
205
  );
206
  }
210
  }
211
 
212
  /**
213
+ * Set up the title for pages and <title>
 
 
214
  */
215
  function setup_title() {
216
+ $bp = buddypress();
217
 
218
+ // Set up the component options navigation for Site
219
  if ( bp_is_blogs_component() ) {
220
  if ( bp_is_my_profile() ) {
221
  if ( bp_is_active( 'xprofile' ) ) {
238
  }
239
  }
240
 
241
+ /**
242
+ * Set up the bp-blogs component.
243
+ */
244
  function bp_setup_blogs() {
245
+ buddypress()->blogs = new BP_Blogs_Component();
 
246
  }
247
  add_action( 'bp_setup_components', 'bp_setup_blogs', 6 );
bp-blogs/bp-blogs-screens.php CHANGED
@@ -10,6 +10,9 @@
10
  // Exit if accessed directly
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
 
 
 
13
  function bp_blogs_screen_my_blogs() {
14
  if ( !is_multisite() )
15
  return false;
@@ -19,6 +22,9 @@ function bp_blogs_screen_my_blogs() {
19
  bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
20
  }
21
 
 
 
 
22
  function bp_blogs_screen_create_a_blog() {
23
 
24
  if ( !is_multisite() || !bp_is_blogs_component() || !bp_is_current_action( 'create' ) )
@@ -33,6 +39,9 @@ function bp_blogs_screen_create_a_blog() {
33
  }
34
  add_action( 'bp_screens', 'bp_blogs_screen_create_a_blog', 3 );
35
 
 
 
 
36
  function bp_blogs_screen_index() {
37
  if ( is_multisite() && bp_is_blogs_component() && !bp_current_action() ) {
38
  bp_update_is_directory( true, 'blogs' );
@@ -47,28 +56,28 @@ add_action( 'bp_screens', 'bp_blogs_screen_index', 2 );
47
  /** Theme Compatability *******************************************************/
48
 
49
  /**
50
- * The main theme compat class for BuddyPress Activity
51
  *
52
  * This class sets up the necessary theme compatability actions to safely output
53
  * group template parts to the_title and the_content areas of a theme.
54
  *
55
- * @since BuddyPress (1.7)
56
  */
57
  class BP_Blogs_Theme_Compat {
58
 
59
  /**
60
- * Setup the groups component theme compatibility
61
  *
62
- * @since BuddyPress (1.7)
63
  */
64
  public function __construct() {
65
  add_action( 'bp_setup_theme_compat', array( $this, 'is_blogs' ) );
66
  }
67
 
68
  /**
69
- * Are we looking at something that needs group theme compatability?
70
  *
71
- * @since BuddyPress (1.7)
72
  */
73
  public function is_blogs() {
74
 
@@ -94,7 +103,7 @@ class BP_Blogs_Theme_Compat {
94
  } elseif ( is_user_logged_in() && bp_blog_signup_enabled() ) {
95
  add_filter( 'bp_get_buddypress_template', array( $this, 'create_template_hierarchy' ) );
96
  add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'create_dummy_post' ) );
97
- add_filter( 'bp_replace_the_content', array( $this, 'create_content' ) );
98
  }
99
  }
100
 
@@ -103,11 +112,13 @@ class BP_Blogs_Theme_Compat {
103
  /**
104
  * Add template hierarchy to theme compat for the blog directory page.
105
  *
106
- * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
 
107
  *
108
- * @since BuddyPress (1.8)
109
  *
110
- * @param string $templates The templates from bp_get_theme_compat_templates()
 
111
  * @return array $templates Array of custom templates to look for.
112
  */
113
  public function directory_template_hierarchy( $templates ) {
@@ -124,17 +135,17 @@ class BP_Blogs_Theme_Compat {
124
  }
125
 
126
  /**
127
- * Update the global $post with directory data
128
  *
129
- * @since BuddyPress (1.7)
130
  */
131
  public function directory_dummy_post() {
132
 
133
  // Title based on ability to create blogs
134
  if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
135
- $title = __( 'Blogs', 'buddypress' ) . '&nbsp;<a class="button" href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create' ) . '">' . __( 'Create a Blog', 'buddypress' ) . '</a>';
136
  } else {
137
- $title = __( 'Blogs', 'buddypress' );
138
  }
139
 
140
  bp_theme_compat_reset_post( array(
@@ -151,24 +162,26 @@ class BP_Blogs_Theme_Compat {
151
  }
152
 
153
  /**
154
- * Filter the_content with the groups index template part
155
  *
156
- * @since BuddyPress (1.7)
157
  */
158
  public function directory_content() {
159
- bp_buffer_template_part( 'blogs/index' );
160
  }
161
-
162
  /** Create ****************************************************************/
163
 
164
  /**
165
  * Add custom template hierarchy to theme compat for the blog create page.
166
  *
167
- * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
 
168
  *
169
- * @since BuddyPress (1.8)
170
  *
171
- * @param string $templates The templates from bp_get_theme_compat_templates()
 
172
  * @return array $templates Array of custom templates to look for.
173
  */
174
  public function create_template_hierarchy( $templates ) {
@@ -185,17 +198,17 @@ class BP_Blogs_Theme_Compat {
185
  }
186
 
187
  /**
188
- * Update the global $post with create screen data
189
  *
190
- * @since BuddyPress (1.7)
191
  */
192
  public function create_dummy_post() {
193
 
194
  // Title based on ability to create blogs
195
  if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
196
- $title = '<a class="button bp-title-button" href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) . '">' . __( 'Blogs', 'buddypress' ) . '</a>&nbsp;' . __( 'Create a Blog', 'buddypress' );
197
  } else {
198
- $title = __( 'Blogs', 'buddypress' );
199
  }
200
 
201
  bp_theme_compat_reset_post( array(
@@ -212,12 +225,12 @@ class BP_Blogs_Theme_Compat {
212
  }
213
 
214
  /**
215
- * Filter the_content with the create screen template part
216
  *
217
- * @since BuddyPress (1.7)
218
  */
219
  public function create_content() {
220
- bp_buffer_template_part( 'blogs/create' );
221
  }
222
  }
223
  new BP_Blogs_Theme_Compat();
10
  // Exit if accessed directly
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
+ /**
14
+ * Load the "My Blogs" screen.
15
+ */
16
  function bp_blogs_screen_my_blogs() {
17
  if ( !is_multisite() )
18
  return false;
22
  bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
23
  }
24
 
25
+ /**
26
+ * Load the "Create a Blog" screen.
27
+ */
28
  function bp_blogs_screen_create_a_blog() {
29
 
30
  if ( !is_multisite() || !bp_is_blogs_component() || !bp_is_current_action( 'create' ) )
39
  }
40
  add_action( 'bp_screens', 'bp_blogs_screen_create_a_blog', 3 );
41
 
42
+ /**
43
+ * Load the top-level Blogs directory.
44
+ */
45
  function bp_blogs_screen_index() {
46
  if ( is_multisite() && bp_is_blogs_component() && !bp_current_action() ) {
47
  bp_update_is_directory( true, 'blogs' );
56
  /** Theme Compatability *******************************************************/
57
 
58
  /**
59
+ * The main theme compat class for BuddyPress Blogs
60
  *
61
  * This class sets up the necessary theme compatability actions to safely output
62
  * group template parts to the_title and the_content areas of a theme.
63
  *
64
+ * @since BuddyPress (1.7.0)
65
  */
66
  class BP_Blogs_Theme_Compat {
67
 
68
  /**
69
+ * Set up theme compatibility for the Blogs component.
70
  *
71
+ * @since BuddyPress (1.7.0)
72
  */
73
  public function __construct() {
74
  add_action( 'bp_setup_theme_compat', array( $this, 'is_blogs' ) );
75
  }
76
 
77
  /**
78
+ * Are we looking at something that needs Blogs theme compatability?
79
  *
80
+ * @since BuddyPress (1.7.0)
81
  */
82
  public function is_blogs() {
83
 
103
  } elseif ( is_user_logged_in() && bp_blog_signup_enabled() ) {
104
  add_filter( 'bp_get_buddypress_template', array( $this, 'create_template_hierarchy' ) );
105
  add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'create_dummy_post' ) );
106
+ add_filter( 'bp_replace_the_content', array( $this, 'create_content' ) );
107
  }
108
  }
109
 
112
  /**
113
  * Add template hierarchy to theme compat for the blog directory page.
114
  *
115
+ * This is to mirror how WordPress has
116
+ * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
117
  *
118
+ * @since BuddyPress (1.8.0)
119
  *
120
+ * @param string $templates The templates from
121
+ * bp_get_theme_compat_templates().
122
  * @return array $templates Array of custom templates to look for.
123
  */
124
  public function directory_template_hierarchy( $templates ) {
135
  }
136
 
137
  /**
138
+ * Update the global $post with directory data.
139
  *
140
+ * @since BuddyPress (1.7.0)
141
  */
142
  public function directory_dummy_post() {
143
 
144
  // Title based on ability to create blogs
145
  if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
146
+ $title = __( 'Sites', 'buddypress' ) . '&nbsp;<a class="button" href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create' ) . '">' . __( 'Create a Sites', 'buddypress' ) . '</a>';
147
  } else {
148
+ $title = __( 'Sites', 'buddypress' );
149
  }
150
 
151
  bp_theme_compat_reset_post( array(
162
  }
163
 
164
  /**
165
+ * Filter the_content with the groups index template part.
166
  *
167
+ * @since BuddyPress (1.7.0)
168
  */
169
  public function directory_content() {
170
+ return bp_buffer_template_part( 'blogs/index', null, false );
171
  }
172
+
173
  /** Create ****************************************************************/
174
 
175
  /**
176
  * Add custom template hierarchy to theme compat for the blog create page.
177
  *
178
+ * This is to mirror how WordPress has
179
+ * {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
180
  *
181
+ * @since BuddyPress (1.8.0)
182
  *
183
+ * @param string $templates The templates from
184
+ * bp_get_theme_compat_templates().
185
  * @return array $templates Array of custom templates to look for.
186
  */
187
  public function create_template_hierarchy( $templates ) {
198
  }
199
 
200
  /**
201
+ * Update the global $post with create screen data.
202
  *
203
+ * @since BuddyPress (1.7.0)
204
  */
205
  public function create_dummy_post() {
206
 
207
  // Title based on ability to create blogs
208
  if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
209
+ $title = '<a class="button bp-title-button" href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) . '">' . __( 'Sites', 'buddypress' ) . '</a>&nbsp;' . __( 'Create a Site', 'buddypress' );
210
  } else {
211
+ $title = __( 'Sites', 'buddypress' );
212
  }
213
 
214
  bp_theme_compat_reset_post( array(
225
  }
226
 
227
  /**
228
+ * Filter the_content with the create screen template part.
229
  *
230
+ * @since BuddyPress (1.7.0)
231
  */
232
  public function create_content() {
233
+ return bp_buffer_template_part( 'blogs/create', null, false );
234
  }
235
  }
236
  new BP_Blogs_Theme_Compat();
bp-blogs/bp-blogs-template.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Blogs Template Tags
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsTemplate
@@ -11,11 +11,9 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Output the blogs component slug
15
  *
16
- * @package BuddyPress
17
- * @subpackage BlogsTemplate
18
- * @since BuddyPress (1.5)
19
  *
20
  * @uses bp_get_blogs_slug()
21
  */
@@ -23,22 +21,20 @@ function bp_blogs_slug() {
23
  echo bp_get_blogs_slug();
24
  }
25
  /**
26
- * Return the blogs component slug
 
 
27
  *
28
- * @package BuddyPress
29
- * @subpackage BlogsTemplate
30
- * @since BuddyPress (1.5)
31
  */
32
  function bp_get_blogs_slug() {
33
  return apply_filters( 'bp_get_blogs_slug', buddypress()->blogs->slug );
34
  }
35
 
36
  /**
37
- * Output the blogs component root slug
38
  *
39
- * @package BuddyPress
40
- * @subpackage BlogsTemplate
41
- * @since BuddyPress (1.5)
42
  *
43
  * @uses bp_get_blogs_root_slug()
44
  */
@@ -46,60 +42,134 @@ function bp_blogs_root_slug() {
46
  echo bp_get_blogs_root_slug();
47
  }
48
  /**
49
- * Return the blogs component root slug
 
 
50
  *
51
- * @package BuddyPress
52
- * @subpackage BlogsTemplate
53
- * @since BuddyPress (1.5)
54
  */
55
  function bp_get_blogs_root_slug() {
56
  return apply_filters( 'bp_get_blogs_root_slug', buddypress()->blogs->root_slug );
57
  }
58
 
59
  /**
60
- * Output blog directory permalink
 
 
61
  *
62
- * @package BuddyPress
63
- * @subpackage BlogsTemplate
64
- * @since BuddyPress (1.5)
65
  * @uses bp_get_blogs_directory_permalink()
66
  */
67
  function bp_blogs_directory_permalink() {
68
  echo bp_get_blogs_directory_permalink();
69
  }
70
  /**
71
- * Return blog directory permalink
 
 
72
  *
73
- * @package BuddyPress
74
- * @subpackage BlogsTemplate
75
- * @since BuddyPress (1.5)
76
  * @uses apply_filters()
77
- * @uses traisingslashit()
78
  * @uses bp_get_root_domain()
79
  * @uses bp_get_blogs_root_slug()
80
- * @return string
81
  */
82
  function bp_get_blogs_directory_permalink() {
83
  return apply_filters( 'bp_get_blogs_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) );
84
  }
85
 
86
- /**********************************************************************
87
- * Blog listing template class.
 
 
88
  */
89
-
90
  class BP_Blogs_Template {
 
 
 
 
 
 
 
91
  var $current_blog = -1;
 
 
 
 
 
 
 
92
  var $blog_count;
 
 
 
 
 
 
 
93
  var $blogs;
 
 
 
 
 
 
 
94
  var $blog;
95
 
 
 
 
 
 
 
96
  var $in_the_loop;
97
 
 
 
 
 
 
 
98
  var $pag_page;
 
 
 
 
 
 
 
99
  var $pag_num;
 
 
 
 
 
 
 
100
  var $pag_links;
 
 
 
 
 
 
 
101
  var $total_blog_count;
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage' ) {
104
 
105
  $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page;
@@ -140,6 +210,13 @@ class BP_Blogs_Template {
140
  }
141
  }
142
 
 
 
 
 
 
 
 
143
  function has_blogs() {
144
  if ( $this->blog_count )
145
  return true;
@@ -147,6 +224,11 @@ class BP_Blogs_Template {
147
  return false;
148
  }
149
 
 
 
 
 
 
150
  function next_blog() {
151
  $this->current_blog++;
152
  $this->blog = $this->blogs[$this->current_blog];
@@ -154,6 +236,9 @@ class BP_Blogs_Template {
154
  return $this->blog;
155
  }
156
 
 
 
 
157
  function rewind_blogs() {
158
  $this->current_blog = -1;
159
  if ( $this->blog_count > 0 ) {
@@ -161,6 +246,17 @@ class BP_Blogs_Template {
161
  }
162
  }
163
 
 
 
 
 
 
 
 
 
 
 
 
164
  function blogs() {
165
  if ( $this->current_blog + 1 < $this->blog_count ) {
166
  return true;
@@ -174,6 +270,15 @@ class BP_Blogs_Template {
174
  return false;
175
  }
176
 
 
 
 
 
 
 
 
 
 
177
  function the_blog() {
178
 
179
  $this->in_the_loop = true;
@@ -184,12 +289,51 @@ class BP_Blogs_Template {
184
  }
185
  }
186
 
 
 
 
187
  function bp_rewind_blogs() {
188
  global $blogs_template;
189
 
190
  $blogs_template->rewind_blogs();
191
  }
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  function bp_has_blogs( $args = '' ) {
194
  global $blogs_template;
195
 
@@ -238,18 +382,37 @@ function bp_has_blogs( $args = '' ) {
238
  return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template );
239
  }
240
 
 
 
 
 
 
 
 
241
  function bp_blogs() {
242
  global $blogs_template;
243
 
244
  return $blogs_template->blogs();
245
  }
246
 
 
 
 
 
 
 
 
247
  function bp_the_blog() {
248
  global $blogs_template;
249
 
250
  return $blogs_template->the_blog();
251
  }
252
 
 
 
 
 
 
253
  function bp_blogs_pagination_count() {
254
  global $blogs_template;
255
 
@@ -258,21 +421,62 @@ function bp_blogs_pagination_count() {
258
  $to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) );
259
  $total = bp_core_number_format( $blogs_template->total_blog_count );
260
 
261
- echo sprintf( __( 'Viewing site %1$s to %2$s (of %3$s sites)', 'buddypress' ), $from_num, $to_num, $total );
262
  }
263
 
 
 
 
264
  function bp_blogs_pagination_links() {
265
  echo bp_get_blogs_pagination_links();
266
  }
 
 
 
 
 
 
 
267
  function bp_get_blogs_pagination_links() {
268
  global $blogs_template;
269
 
270
  return apply_filters( 'bp_get_blogs_pagination_links', $blogs_template->pag_links );
271
  }
272
 
 
 
 
 
 
 
 
273
  function bp_blog_avatar( $args = '' ) {
274
  echo bp_get_blog_avatar( $args );
275
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  function bp_get_blog_avatar( $args = '' ) {
277
  global $blogs_template;
278
 
@@ -321,9 +525,17 @@ function bp_blog_permalink() {
321
  return apply_filters( 'bp_get_blog_permalink', $permalink );
322
  }
323
 
 
 
 
324
  function bp_blog_name() {
325
  echo bp_get_blog_name();
326
  }
 
 
 
 
 
327
  function bp_get_blog_name() {
328
  global $blogs_template;
329
 
@@ -331,18 +543,19 @@ function bp_blog_name() {
331
  }
332
 
333
  /**
334
- * Outputs the blog ID
335
  *
336
- * @since BuddyPress (1.7)
337
  */
338
  function bp_blog_id() {
339
  echo bp_get_blog_id();
340
  }
341
  /**
342
- * Returns the blog ID
343
  *
344
- * @return int
345
- * @since BuddyPress (1.7)
 
346
  */
347
  function bp_get_blog_id() {
348
  global $blogs_template;
@@ -350,30 +563,39 @@ function bp_blog_id() {
350
  return apply_filters( 'bp_get_blog_id', $blogs_template->blog->blog_id );
351
  }
352
 
 
 
 
353
  function bp_blog_description() {
354
  echo apply_filters( 'bp_blog_description', bp_get_blog_description() );
355
  }
 
 
 
 
 
356
  function bp_get_blog_description() {
357
  global $blogs_template;
358
 
359
  return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description );
360
  }
361
 
362
-
363
  /**
364
- * Output the row class of a site
365
  *
366
- * @since BuddyPress (1.7)
367
  */
368
  function bp_blog_class() {
369
  echo bp_get_blog_class();
370
  }
371
  /**
372
- * Return the row class of a site
 
 
373
  *
374
  * @global BP_Blogs_Template $blogs_template
375
- * @return string Row class of the site
376
- * @since BuddyPress (1.7)
377
  */
378
  function bp_get_blog_class() {
379
  global $blogs_template;
@@ -394,18 +616,34 @@ function bp_blog_class() {
394
  return $retval;
395
  }
396
 
 
 
 
397
  function bp_blog_last_active() {
398
  echo bp_get_blog_last_active();
399
  }
 
 
 
 
 
400
  function bp_get_blog_last_active() {
401
  global $blogs_template;
402
 
403
  return apply_filters( 'bp_blog_last_active', bp_core_get_last_activity( $blogs_template->blog->last_activity, __( 'active %s', 'buddypress' ) ) );
404
  }
405
 
 
 
 
406
  function bp_blog_latest_post() {
407
  echo bp_get_blog_latest_post();
408
  }
 
 
 
 
 
409
  function bp_get_blog_latest_post() {
410
  global $blogs_template;
411
 
@@ -418,9 +656,9 @@ function bp_blog_latest_post() {
418
  }
419
 
420
  /**
421
- * Prints this site's latest article's title
422
  *
423
- * @since BuddyPress (1.7)
424
  *
425
  * @see bp_get_blog_latest_post_title()
426
  */
@@ -428,12 +666,13 @@ function bp_blog_latest_post_title() {
428
  echo bp_get_blog_latest_post_title();
429
  }
430
  /**
431
- * Returns this site's latest article's title
432
  *
433
- * @since BuddyPress (1.7)
434
  *
435
  * @global BP_Blogs_Template
436
- * @return string
 
437
  */
438
  function bp_get_blog_latest_post_title() {
439
  global $blogs_template;
@@ -447,20 +686,23 @@ function bp_blog_latest_post_title() {
447
  }
448
 
449
  /**
450
- * Prints this site's latest article's permalink
 
 
451
  *
452
  * @see bp_get_blog_latest_post_title()
453
- * @since BuddyPress (1.7)
454
  */
455
  function bp_blog_latest_post_permalink() {
456
  echo bp_get_blog_latest_post_permalink();
457
  }
458
  /**
459
- * Returns this site's latest article's permalink
 
 
460
  *
461
  * @global BP_Blogs_Template
462
- * @return string
463
- * @since BuddyPress (1.7)
464
  */
465
  function bp_get_blog_latest_post_permalink() {
466
  global $blogs_template;
@@ -474,9 +716,9 @@ function bp_blog_latest_post_permalink() {
474
  }
475
 
476
  /**
477
- * Prints this site's latest article's content
478
  *
479
- * @since BuddyPress (1.7)
480
  *
481
  * @uses bp_get_blog_latest_post_content()
482
  */
@@ -484,12 +726,13 @@ function bp_blog_latest_post_content() {
484
  echo bp_get_blog_latest_post_content();
485
  }
486
  /**
487
- * Returns this site's latest article's content
488
  *
489
- * @since BuddyPress (1.7)
490
  *
491
  * @global BP_Blogs_Template
492
- * @return string
 
493
  */
494
  function bp_get_blog_latest_post_content() {
495
  global $blogs_template;
@@ -503,24 +746,27 @@ function bp_blog_latest_post_content() {
503
  }
504
 
505
  /**
506
- * Prints this site's latest article's featured image
 
 
507
  *
508
- * @since BuddyPress (1.7)
509
  *
510
- * @param string $size Image version to return. Either "thumbnail", "medium", "large", "post-thumbnail".
511
- * @see bp_get_blog_latest_post_content()
512
  */
513
  function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
514
  echo bp_get_blog_latest_post_featured_image( $size );
515
  }
516
  /**
517
- * Returns this site's latest article's featured image
518
  *
519
- * @since BuddyPress (1.7)
520
  *
521
  * @global BP_Blogs_Template
522
- * @param string $size Image version to return. Either "thumbnail", "medium", "large", "post-thumbnail".
523
- * @return string
 
 
524
  */
525
  function bp_get_blog_latest_post_featured_image( $size = 'thumbnail' ) {
526
  global $blogs_template;
@@ -536,9 +782,12 @@ function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
536
  /**
537
  * Does the latest blog post have a featured image?
538
  *
539
- * @param string $size Image version to check for. Either "thumbnail", "medium", "large", "post-thumbnail".
540
- * @return bool
541
- * @since BuddyPress (1.7)
 
 
 
542
  */
543
  function bp_blog_latest_post_has_featured_image( $thumbnail = 'thumbnail' ) {
544
  $image = bp_get_blog_latest_post_featured_image( $thumbnail );
@@ -546,6 +795,13 @@ function bp_blog_latest_post_has_featured_image( $thumbnail = 'thumbnail' ) {
546
  return apply_filters( 'bp_blog_latest_post_has_featured_image', ! empty( $image ), $thumbnail, $image );
547
  }
548
 
 
 
 
 
 
 
 
549
  function bp_blog_hidden_fields() {
550
  if ( isset( $_REQUEST['s'] ) )
551
  echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ). '" name="search_terms" />';
@@ -557,25 +813,52 @@ function bp_blog_hidden_fields() {
557
  echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
558
  }
559
 
 
 
 
560
  function bp_total_blog_count() {
561
  echo bp_get_total_blog_count();
562
  }
 
 
 
 
 
563
  function bp_get_total_blog_count() {
564
  return apply_filters( 'bp_get_total_blog_count', bp_blogs_total_blogs() );
565
  }
566
  add_filter( 'bp_get_total_blog_count', 'bp_core_number_format' );
567
 
 
 
 
 
 
568
  function bp_total_blog_count_for_user( $user_id = 0 ) {
569
  echo bp_get_total_blog_count_for_user( $user_id );
570
  }
 
 
 
 
 
 
571
  function bp_get_total_blog_count_for_user( $user_id = 0 ) {
572
  return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) );
573
  }
574
  add_filter( 'bp_get_total_blog_count_for_user', 'bp_core_number_format' );
575
 
576
 
577
- /* Blog registration template tags */
578
 
 
 
 
 
 
 
 
 
579
  function bp_blog_signup_enabled() {
580
  global $bp;
581
 
@@ -589,6 +872,14 @@ function bp_blog_signup_enabled() {
589
  return true;
590
  }
591
 
 
 
 
 
 
 
 
 
592
  function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') {
593
  global $current_user;
594
 
@@ -629,6 +920,14 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
629
  }
630
  }
631
 
 
 
 
 
 
 
 
 
632
  function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
633
  global $current_site;
634
 
@@ -693,19 +992,19 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
693
  }
694
 
695
  /**
696
- * Echo the value of bp_blogs_get_subdomain_base()
697
  *
698
- * @since BuddyPress (1.6)
699
  */
700
  function bp_blogs_subdomain_base() {
701
  echo bp_blogs_get_subdomain_base();
702
  }
703
  /**
704
- * Return the base URL to be displayed when a user chooses an address for a new blog, on
705
- * a subdomain installation of WordPress MS
 
706
  *
707
- * @since BuddyPress (1.6)
708
- * @return string The base URL - eg, 'example.com' for site_url() example.com or www.example.com
709
  */
710
  function bp_blogs_get_subdomain_base() {
711
  global $current_site;
@@ -713,6 +1012,13 @@ function bp_blogs_subdomain_base() {
713
  return apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
714
  }
715
 
 
 
 
 
 
 
 
716
  function bp_blogs_validate_blog_signup() {
717
  global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path, $current_site;
718
 
@@ -747,6 +1053,13 @@ function bp_blogs_validate_blog_signup() {
747
  return true;
748
  }
749
 
 
 
 
 
 
 
 
750
  function bp_blogs_validate_blog_form() {
751
  $user = '';
752
  if ( is_user_logged_in() )
@@ -755,6 +1068,16 @@ function bp_blogs_validate_blog_form() {
755
  return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
756
  }
757
 
 
 
 
 
 
 
 
 
 
 
758
  function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = '' ) {
759
  $protocol = is_ssl() ? 'https://' : 'http://';
760
  $blog_url = $protocol . $domain . $path; ?>
@@ -768,11 +1091,19 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
768
  do_action('signup_finished');
769
  }
770
 
 
 
 
771
  function bp_create_blog_link() {
772
  if ( bp_is_my_profile() )
773
  echo apply_filters( 'bp_create_blog_link', '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
774
  }
775
 
 
 
 
 
 
776
  function bp_blogs_blog_tabs() {
777
 
778
  // Don't show these tabs on a user's own profile
@@ -791,36 +1122,51 @@ function bp_blogs_blog_tabs() {
791
  do_action( 'bp_blogs_blog_tabs' );
792
  }
793
 
 
 
 
794
  function bp_directory_blogs_search_form() {
795
-
796
  $default_search_value = bp_get_search_default_text();
797
- $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>
798
 
799
- <form action="" method="get" id="search-blogs-form">
800
- <label><input type="text" name="s" id="blogs_search" placeholder="<?php echo esc_attr( $search_value ) ?>" /></label>
801
- <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
802
- </form>
803
 
804
- <?php
805
  }
806
 
807
  /**
808
- * bp_blogs_visit_blog_button()
809
  *
810
- * Output button for visiting a blog in a loop
811
  *
812
- * @param array $args Custom button properties
813
  */
814
  function bp_blogs_visit_blog_button( $args = '' ) {
815
  echo bp_get_blogs_visit_blog_button( $args );
816
  }
817
  /**
818
- * bp_get_blogs_visit_blog_button()
819
  *
820
- * Return button for visiting a blog in a loop
 
821
  *
822
- * @param array $args Custom button properties
823
- * @return string
 
 
 
 
 
 
 
 
 
 
 
 
824
  */
825
  function bp_get_blogs_visit_blog_button( $args = '' ) {
826
  $defaults = array(
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Blogs Template Tags.
5
  *
6
  * @package BuddyPress
7
  * @subpackage BlogsTemplate
11
  if ( !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
  */
21
  echo bp_get_blogs_slug();
22
  }
23
  /**
24
+ * Return the blogs component slug.
25
+ *
26
+ * @since BuddyPress (1.5.0)
27
  *
28
+ * @return string The 'blogs' slug.
 
 
29
  */
30
  function bp_get_blogs_slug() {
31
  return apply_filters( 'bp_get_blogs_slug', buddypress()->blogs->slug );
32
  }
33
 
34
  /**
35
+ * Output the blogs component root slug.
36
  *
37
+ * @since BuddyPress (1.5.0)
 
 
38
  *
39
  * @uses bp_get_blogs_root_slug()
40
  */
42
  echo bp_get_blogs_root_slug();
43
  }
44
  /**
45
+ * Return the blogs component root slug.
46
+ *
47
+ * @since BuddyPress (1.5.0)
48
  *
49
+ * @return string The 'blogs' root slug.
 
 
50
  */
51
  function bp_get_blogs_root_slug() {
52
  return apply_filters( 'bp_get_blogs_root_slug', buddypress()->blogs->root_slug );
53
  }
54
 
55
  /**
56
+ * Output blog directory permalink.
57
+ *
58
+ * @since BuddyPress (1.5.0)
59
  *
 
 
 
60
  * @uses bp_get_blogs_directory_permalink()
61
  */
62
  function bp_blogs_directory_permalink() {
63
  echo bp_get_blogs_directory_permalink();
64
  }
65
  /**
66
+ * Return blog directory permalink.
67
+ *
68
+ * @since BuddyPress (1.5.0)
69
  *
 
 
 
70
  * @uses apply_filters()
71
+ * @uses trailingslashit()
72
  * @uses bp_get_root_domain()
73
  * @uses bp_get_blogs_root_slug()
74
+ * @return string The URL of the Blogs directory.
75
  */
76
  function bp_get_blogs_directory_permalink() {
77
  return apply_filters( 'bp_get_blogs_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) );
78
  }
79
 
80
+ /**
81
+ * The main blog template loop class.
82
+ *
83
+ * Responsible for loading a group of blogs into a loop for display.
84
  */
 
85
  class BP_Blogs_Template {
86
+
87
+ /**
88
+ * The loop iterator.
89
+ *
90
+ * @access public
91
+ * @var int
92
+ */
93
  var $current_blog = -1;
94
+
95
+ /**
96
+ * The number of blogs returned by the paged query.
97
+ *
98
+ * @access public
99
+ * @var int
100
+ */
101
  var $blog_count;
102
+
103
+ /**
104
+ * Array of blogs located by the query..
105
+ *
106
+ * @access public
107
+ * @var array
108
+ */
109
  var $blogs;
110
+
111
+ /**
112
+ * The blog object currently being iterated on.
113
+ *
114
+ * @access public
115
+ * @var object
116
+ */
117
  var $blog;
118
 
119
+ /**
120
+ * A flag for whether the loop is currently being iterated.
121
+ *
122
+ * @access public
123
+ * @var bool
124
+ */
125
  var $in_the_loop;
126
 
127
+ /**
128
+ * The page number being requested.
129
+ *
130
+ * @access public
131
+ * @var public
132
+ */
133
  var $pag_page;
134
+
135
+ /**
136
+ * The number of items being requested per page.
137
+ *
138
+ * @access public
139
+ * @var public
140
+ */
141
  var $pag_num;
142
+
143
+ /**
144
+ * An HTML string containing pagination links.
145
+ *
146
+ * @access public
147
+ * @var string
148
+ */
149
  var $pag_links;
150
+
151
+ /**
152
+ * The total number of blogs matching the query parameters.
153
+ *
154
+ * @access public
155
+ * @var int
156
+ */
157
  var $total_blog_count;
158
 
159
+ /**
160
+ * Constructor method.
161
+ *
162
+ * @see BP_Blogs_Blog::get() for a description of parameters.
163
+ *
164
+ * @param string $type See {@link BP_Blogs_Blog::get()}.
165
+ * @param string $page See {@link BP_Blogs_Blog::get()}.
166
+ * @param string $per_page See {@link BP_Blogs_Blog::get()}.
167
+ * @param string $max See {@link BP_Blogs_Blog::get()}.
168
+ * @param string $user_id See {@link BP_Blogs_Blog::get()}.
169
+ * @param string $search_terms See {@link BP_Blogs_Blog::get()}.
170
+ * @param string $page_arg The string used as a query parameter in
171
+ * pagination links. Default: 'bpage'.
172
+ */
173
  function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage' ) {
174
 
175
  $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page;
210
  }
211
  }
212
 
213
+ /**
214
+ * Whether there are blogs available in the loop.
215
+ *
216
+ * @see bp_has_blogs()
217
+ *
218
+ * @return bool True if there are items in the loop, otherwise false.
219
+ */
220
  function has_blogs() {
221
  if ( $this->blog_count )
222
  return true;
224
  return false;
225
  }
226
 
227
+ /**
228
+ * Set up the next blog and iterate index.
229
+ *
230
+ * @return object The next blog to iterate over.
231
+ */
232
  function next_blog() {
233
  $this->current_blog++;
234
  $this->blog = $this->blogs[$this->current_blog];
236
  return $this->blog;
237
  }
238
 
239
+ /**
240
+ * Rewind the blogs and reset blog index.
241
+ */
242
  function rewind_blogs() {
243
  $this->current_blog = -1;
244
  if ( $this->blog_count > 0 ) {
246
  }
247
  }
248
 
249
+ /**
250
+ * Whether there are blogs left in the loop to iterate over.
251
+ *
252
+ * This method is used by {@link bp_blogs()} as part of the while loop
253
+ * that controls iteration inside the blogs loop, eg:
254
+ * while ( bp_blogs() ) { ...
255
+ *
256
+ * @see bp_blogs()
257
+ *
258
+ * @return bool True if there are more blogs to show, otherwise false.
259
+ */
260
  function blogs() {
261
  if ( $this->current_blog + 1 < $this->blog_count ) {
262
  return true;
270
  return false;
271
  }
272
 
273
+ /**
274
+ * Set up the current blog inside the loop.
275
+ *
276
+ * Used by {@link bp_the_blog()} to set up the current blog data while
277
+ * looping, so that template tags used during that iteration make
278
+ * reference to the current blog.
279
+ *
280
+ * @see bp_the_blog()
281
+ */
282
  function the_blog() {
283
 
284
  $this->in_the_loop = true;
289
  }
290
  }
291
 
292
+ /**
293
+ * Rewind the blogs and reset blog index.
294
+ */
295
  function bp_rewind_blogs() {
296
  global $blogs_template;
297
 
298
  $blogs_template->rewind_blogs();
299
  }
300
 
301
+ /**
302
+ * Initialize the blogs loop.
303
+ *
304
+ * Based on the $args passed, bp_has_blogs() populates the $blogs_template
305
+ * global, enabling the use of BuddyPress templates and template functions to
306
+ * display a list of activity items.
307
+ *
308
+ * @global object $blogs_template {@link BP_Blogs_Template}
309
+ *
310
+ * @param array $args {
311
+ * Arguments for limiting the contents of the blogs loop. Most arguments
312
+ * are in the same format as {@link BP_Blogs_Blog::get()}. However, because
313
+ * the format of the arguments accepted here differs in a number of ways,
314
+ * and because bp_has_blogs() determines some default arguments in a
315
+ * dynamic fashion, we list all accepted arguments here as well.
316
+ *
317
+ * Arguments can be passed as an associative array, or as a URL query
318
+ * string (eg, 'user_id=4&per_page=3').
319
+ *
320
+ * @type int $page Which page of results to fetch. Using page=1 without
321
+ * per_page will result in no pagination. Default: 1.
322
+ * @type int|bool $per_page Number of results per page. Default: 20.
323
+ * @type string $page_arg The string used as a query parameter in
324
+ * pagination links. Default: 'bpage'.
325
+ * @type int|bool $max Maximum number of results to return.
326
+ * Default: false (unlimited).
327
+ * @type string $type The order in which results should be fetched.
328
+ 'active', 'alphabetical', 'newest', or 'random'.
329
+ * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
330
+ * @type string $search_terms Limit results by a search term. Default: null.
331
+ * @type int $user_id The ID of the user whose blogs should be retrieved.
332
+ * When viewing a user profile page, 'user_id' defaults to the ID of
333
+ * the displayed user. Otherwise the default is false.
334
+ * }
335
+ * @return bool Returns true when blogs are found, otherwise false.
336
+ */
337
  function bp_has_blogs( $args = '' ) {
338
  global $blogs_template;
339
 
382
  return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template );
383
  }
384
 
385
+ /**
386
+ * Determine if there are still blogs left in the loop.
387
+ *
388
+ * @global object $blogs_template {@link BP_Blogs_Template}
389
+ *
390
+ * @return bool Returns true when blogs are found.
391
+ */
392
  function bp_blogs() {
393
  global $blogs_template;
394
 
395
  return $blogs_template->blogs();
396
  }
397
 
398
+ /**
399
+ * Get the current blog object in the loop.
400
+ *
401
+ * @global object $blogs_template {@link BP_Blogs_Template}
402
+ *
403
+ * @return object The current blog within the loop.
404
+ */
405
  function bp_the_blog() {
406
  global $blogs_template;
407
 
408
  return $blogs_template->the_blog();
409
  }
410
 
411
+ /**
412
+ * Output the blogs pagination count.
413
+ *
414
+ * @global object $blogs_template {@link BP_Blogs_Template}
415
+ */
416
  function bp_blogs_pagination_count() {
417
  global $blogs_template;
418
 
421
  $to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) );
422
  $total = bp_core_number_format( $blogs_template->total_blog_count );
423
 
424
+ echo sprintf( _n( 'Viewing site %1$s to %2$s (of %3$s site)', 'Viewing site %1$s to %2$s (of %3$s sites)', $total, 'buddypress' ), $from_num, $to_num, $total );
425
  }
426
 
427
+ /**
428
+ * Output the blogs pagination links.
429
+ */
430
  function bp_blogs_pagination_links() {
431
  echo bp_get_blogs_pagination_links();
432
  }
433
+ /**
434
+ * Return the blogs pagination links.
435
+ *
436
+ * @global object $blogs_template {@link BP_Blogs_Template}
437
+ *
438
+ * @return string HTML pagination links.
439
+ */
440
  function bp_get_blogs_pagination_links() {
441
  global $blogs_template;
442
 
443
  return apply_filters( 'bp_get_blogs_pagination_links', $blogs_template->pag_links );
444
  }
445
 
446
+ /**
447
+ * Output a blog's avatar.
448
+ *
449
+ * @see bp_get_blog_avatar() for description of arguments.
450
+ *
451
+ * @param array $args See {@link bp_get_blog_avatar()}.
452
+ */
453
  function bp_blog_avatar( $args = '' ) {
454
  echo bp_get_blog_avatar( $args );
455
  }
456
+ /**
457
+ * Get a blog's avatar.
458
+ *
459
+ * At the moment, blog avatars are simply the user avatars of the blog
460
+ * admin. Filter 'bp_get_blog_avatar_' . $blog_id to customize.
461
+ *
462
+ * @see bp_core_fetch_avatar() For a description of arguments and
463
+ * return values.
464
+ *
465
+ * @param array $args {
466
+ * Arguments are listed here with an explanation of their defaults.
467
+ * For more information about the arguments, see
468
+ * {@link bp_core_fetch_avatar()}.
469
+ * @type string $alt Default: 'Profile picture of site author
470
+ * [user name]'.
471
+ * @type string $class Default: 'avatar'.
472
+ * @type string $type Default: 'full'.
473
+ * @type int|bool $width Default: false.
474
+ * @type int|bool $height Default: false.
475
+ * @type bool $id Currently unused.
476
+ * @type bool $no_grav Default: false.
477
+ * }
478
+ * @return string User avatar string.
479
+ */
480
  function bp_get_blog_avatar( $args = '' ) {
481
  global $blogs_template;
482
 
525
  return apply_filters( 'bp_get_blog_permalink', $permalink );
526
  }
527
 
528
+ /**
529
+ * Output the name of the current blog in the loop.
530
+ */
531
  function bp_blog_name() {
532
  echo bp_get_blog_name();
533
  }
534
+ /**
535
+ * Return the name of the current blog in the loop.
536
+ *
537
+ * @return string The name of the current blog in the loop.
538
+ */
539
  function bp_get_blog_name() {
540
  global $blogs_template;
541
 
543
  }
544
 
545
  /**
546
+ * Output the ID of the current blog in the loop.
547
  *
548
+ * @since BuddyPress (1.7.0)
549
  */
550
  function bp_blog_id() {
551
  echo bp_get_blog_id();
552
  }
553
  /**
554
+ * Return the ID of the current blog in the loop.
555
  *
556
+ * @since BuddyPress (1.7.0)
557
+ *
558
+ * @return int ID of the current blog in the loop.
559
  */
560
  function bp_get_blog_id() {
561
  global $blogs_template;
563
  return apply_filters( 'bp_get_blog_id', $blogs_template->blog->blog_id );
564
  }
565
 
566
+ /**
567
+ * Output the description of the current blog in the loop.
568
+ */
569
  function bp_blog_description() {
570
  echo apply_filters( 'bp_blog_description', bp_get_blog_description() );
571
  }
572
+ /**
573
+ * Return the description of the current blog in the loop.
574
+ *
575
+ * @return string Description of the current blog in the loop.
576
+ */
577
  function bp_get_blog_description() {
578
  global $blogs_template;
579
 
580
  return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description );
581
  }
582
 
 
583
  /**
584
+ * Output the row class of the current blog in the loop.
585
  *
586
+ * @since BuddyPress (1.7.0)
587
  */
588
  function bp_blog_class() {
589
  echo bp_get_blog_class();
590
  }
591
  /**
592
+ * Return the row class of the current blog in the loop.
593
+ *
594
+ * @since BuddyPress (1.7.0)
595
  *
596
  * @global BP_Blogs_Template $blogs_template
597
+ *
598
+ * @return string Row class of the site.
599
  */
600
  function bp_get_blog_class() {
601
  global $blogs_template;
616
  return $retval;
617
  }
618
 
619
+ /**
620
+ * Output the last active date of the current blog in the loop.
621
+ */
622
  function bp_blog_last_active() {
623
  echo bp_get_blog_last_active();
624
  }
625
+ /**
626
+ * Return the last active date of the current blog in the loop.
627
+ *
628
+ * @return string Last active date.
629
+ */
630
  function bp_get_blog_last_active() {
631
  global $blogs_template;
632
 
633
  return apply_filters( 'bp_blog_last_active', bp_core_get_last_activity( $blogs_template->blog->last_activity, __( 'active %s', 'buddypress' ) ) );
634
  }
635
 
636
+ /**
637
+ * Output the latest post from the current blog in the loop.
638
+ */
639
  function bp_blog_latest_post() {
640
  echo bp_get_blog_latest_post();
641
  }
642
+ /**
643
+ * Return the latest post from the current blog in the loop.
644
+ *
645
+ * @return string $retval String of the form 'Latest Post: [link to post]'.
646
+ */
647
  function bp_get_blog_latest_post() {
648
  global $blogs_template;
649
 
656
  }
657
 
658
  /**
659
+ * Output the title of the latest post on the current blog in the loop.
660
  *
661
+ * @since BuddyPress (1.7.0)
662
  *
663
  * @see bp_get_blog_latest_post_title()
664
  */
666
  echo bp_get_blog_latest_post_title();
667
  }
668
  /**
669
+ * Return the title of the latest post on the current blog in the loop.
670
  *
671
+ * @since BuddyPress (1.7.0)
672
  *
673
  * @global BP_Blogs_Template
674
+ *
675
+ * @return string Post title.
676
  */
677
  function bp_get_blog_latest_post_title() {
678
  global $blogs_template;
686
  }
687
 
688
  /**
689
+ * Output the permalink of the latest post on the current blog in the loop.
690
+ *
691
+ * @since BuddyPress (1.7.0)
692
  *
693
  * @see bp_get_blog_latest_post_title()
 
694
  */
695
  function bp_blog_latest_post_permalink() {
696
  echo bp_get_blog_latest_post_permalink();
697
  }
698
  /**
699
+ * Return the permalink of the latest post on the current blog in the loop.
700
+ *
701
+ * @since BuddyPress (1.7.0)
702
  *
703
  * @global BP_Blogs_Template
704
+ *
705
+ * @return string URL of the blog's latest post.
706
  */
707
  function bp_get_blog_latest_post_permalink() {
708
  global $blogs_template;
716
  }
717
 
718
  /**
719
+ * Output the content of the latest post on the current blog in the loop.
720
  *
721
+ * @since BuddyPress (1.7.0)
722
  *
723
  * @uses bp_get_blog_latest_post_content()
724
  */
726
  echo bp_get_blog_latest_post_content();
727
  }
728
  /**
729
+ * Return the content of the latest post on the current blog in the loop.
730
  *
731
+ * @since BuddyPress (1.7.0)
732
  *
733
  * @global BP_Blogs_Template
734
+ *
735
+ * @return string Content of the blog's latest post.
736
  */
737
  function bp_get_blog_latest_post_content() {
738
  global $blogs_template;
746
  }
747
 
748
  /**
749
+ * Output the featured image of the latest post on the current blog in the loop.
750
+ *
751
+ * @since BuddyPress (1.7.0)
752
  *
753
+ * @see bp_get_blog_latest_post_content() For description of parameters.
754
  *
755
+ * @param string $size See {@link bp_get_blog_latest_post_featured_image()}.
 
756
  */
757
  function bp_blog_latest_post_featured_image( $size = 'thumbnail' ) {
758
  echo bp_get_blog_latest_post_featured_image( $size );
759
  }
760
  /**
761
+ * Return the featured image of the latest post on the current blog in the loop.
762
  *
763
+ * @since BuddyPress (1.7.0)
764
  *
765
  * @global BP_Blogs_Template
766
+ *
767
+ * @param string $size Image version to return. 'thumbnail', 'medium',
768
+ * 'large', or 'post-thumbnail'. Default: 'thumbnail'.
769
+ * @return string URL of the image.
770
  */
771
  function bp_get_blog_latest_post_featured_image( $size = 'thumbnail' ) {
772
  global $blogs_template;
782
  /**
783
  * Does the latest blog post have a featured image?
784
  *
785
+ * @since BuddyPress (1.7.0)
786
+ *
787
+ * @param string $size Image version to return. 'thumbnail', 'medium', 'large',
788
+ * or 'post-thumbnail'. Default: 'thumbnail'.
789
+ * @return bool True if the latest blog post from the current blog has a
790
+ * featured image of the given size.
791
  */
792
  function bp_blog_latest_post_has_featured_image( $thumbnail = 'thumbnail' ) {
793
  $image = bp_get_blog_latest_post_featured_image( $thumbnail );
795
  return apply_filters( 'bp_blog_latest_post_has_featured_image', ! empty( $image ), $thumbnail, $image );
796
  }
797
 
798
+ /**
799
+ * Output hidden fields to help with form submissions in Sites directory.
800
+ *
801
+ * This function detects whether 's', 'letter', or 'blogs_search' requests are
802
+ * currently being made (as in a URL parameter), and creates corresponding
803
+ * hidden fields.
804
+ */
805
  function bp_blog_hidden_fields() {
806
  if ( isset( $_REQUEST['s'] ) )
807
  echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ). '" name="search_terms" />';
813
  echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
814
  }
815
 
816
+ /**
817
+ * Output the total number of blogs on the site.
818
+ */
819
  function bp_total_blog_count() {
820
  echo bp_get_total_blog_count();
821
  }
822
+ /**
823
+ * Return the total number of blogs on the site.
824
+ *
825
+ * @return int Total number of blogs.
826
+ */
827
  function bp_get_total_blog_count() {
828
  return apply_filters( 'bp_get_total_blog_count', bp_blogs_total_blogs() );
829
  }
830
  add_filter( 'bp_get_total_blog_count', 'bp_core_number_format' );
831
 
832
+ /**
833
+ * Output the total number of blogs for a given user.
834
+ *
835
+ * @param int $user_id ID of the user.
836
+ */
837
  function bp_total_blog_count_for_user( $user_id = 0 ) {
838
  echo bp_get_total_blog_count_for_user( $user_id );
839
  }
840
+ /**
841
+ * Return the total number of blogs for a given user.
842
+ *
843
+ * @param int $user_id ID of the user.
844
+ * @return int Total number of blogs for the user.
845
+ */
846
  function bp_get_total_blog_count_for_user( $user_id = 0 ) {
847
  return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) );
848
  }
849
  add_filter( 'bp_get_total_blog_count_for_user', 'bp_core_number_format' );
850
 
851
 
852
+ /** Blog Registration ********************************************************/
853
 
854
+ /**
855
+ * Checks whether blog creation is enabled.
856
+ *
857
+ * Returns true when blog creation is enabled for logged-in users only, or
858
+ * when it's enabled for new registrations.
859
+ *
860
+ * @return bool True if blog registration is enabled.
861
+ */
862
  function bp_blog_signup_enabled() {
863
  global $bp;
864
 
872
  return true;
873
  }
874
 
875
+ /**
876
+ * Output the wrapper markup for the blog signup form.
877
+ *
878
+ * @param string $blogname Optional. The default blog name (path or domain).
879
+ * @param string $blog_title Optional. The default blog title.
880
+ * @param string|WP_Error Optional. The WP_Error object returned by a previous
881
+ * submission attempt.
882
+ */
883
  function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') {
884
  global $current_user;
885
 
920
  }
921
  }
922
 
923
+ /**
924
+ * Output the input fields for the blog creation form.
925
+ *
926
+ * @param string $blogname Optional. The default blog name (path or domain).
927
+ * @param string $blog_title Optional. The default blog title.
928
+ * @param string|WP_Error Optional. The WP_Error object returned by a previous
929
+ * submission attempt.
930
+ */
931
  function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
932
  global $current_site;
933
 
992
  }
993
 
994
  /**
995
+ * Output the base URL for subdomain installations of WordPress Multisite.
996
  *
997
+ * @since BuddyPress (1.6.0)
998
  */
999
  function bp_blogs_subdomain_base() {
1000
  echo bp_blogs_get_subdomain_base();
1001
  }
1002
  /**
1003
+ * Return the base URL for subdomain installations of WordPress Multisite.
1004
+ *
1005
+ * @since BuddyPress (1.6.0)
1006
  *
1007
+ * @return string The base URL - eg, 'example.com' for site_url() example.com or www.example.com.
 
1008
  */
1009
  function bp_blogs_get_subdomain_base() {
1010
  global $current_site;
1012
  return apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
1013
  }
1014
 
1015
+ /**
1016
+ * Process a blog registration submission.
1017
+ *
1018
+ * Passes submitted values to {@link wpmu_create_blog()}.
1019
+ *
1020
+ * @return bool True on success, false on failure.
1021
+ */
1022
  function bp_blogs_validate_blog_signup() {
1023
  global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path, $current_site;
1024
 
1053
  return true;
1054
  }
1055
 
1056
+ /**
1057
+ * Validate a blog creation submission.
1058
+ *
1059
+ * Essentially, a wrapper for {@link wpmu_validate_blog_signup()}.
1060
+ *
1061
+ * @return array Contains the new site data and error messages.
1062
+ */
1063
  function bp_blogs_validate_blog_form() {
1064
  $user = '';
1065
  if ( is_user_logged_in() )
1068
  return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
1069
  }
1070
 
1071
+ /**
1072
+ * Display a message after successful blog registration.
1073
+ *
1074
+ * @param string $domain The new blog's domain.
1075
+ * @param string $path The new blog's path.
1076
+ * @param string $blog_title The new blog's title.
1077
+ * @param string $user_name The user name of the user who created the blog. Unused.
1078
+ * @param string $user_email The email of the user who created the blog. Unused.
1079
+ * @param string|array $meta Meta values associated with the new blog. Unused.
1080
+ */
1081
  function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = '' ) {
1082
  $protocol = is_ssl() ? 'https://' : 'http://';
1083
  $blog_url = $protocol . $domain . $path; ?>
1091
  do_action('signup_finished');
1092
  }
1093
 
1094
+ /**
1095
+ * Output a "Create a Site" link for users viewing their own profiles.
1096
+ */
1097
  function bp_create_blog_link() {
1098
  if ( bp_is_my_profile() )
1099
  echo apply_filters( 'bp_create_blog_link', '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
1100
  }
1101
 
1102
+ /**
1103
+ * Output navigation tabs for a user Blogs page.
1104
+ *
1105
+ * Currently unused by BuddyPress.
1106
+ */
1107
  function bp_blogs_blog_tabs() {
1108
 
1109
  // Don't show these tabs on a user's own profile
1122
  do_action( 'bp_blogs_blog_tabs' );
1123
  }
1124
 
1125
+ /**
1126
+ * Output the blog directory search form.
1127
+ */
1128
  function bp_directory_blogs_search_form() {
 
1129
  $default_search_value = bp_get_search_default_text();
1130
+ $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
1131
 
1132
+ $search_form_html = '<form action="" method="get" id="search-blogs-form">
1133
+ <label><input type="text" name="s" id="blogs_search" placeholder="'. esc_attr( $search_value ) .'" /></label>
1134
+ <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
1135
+ </form>';
1136
 
1137
+ echo apply_filters( 'bp_directory_blogs_search_form', $search_form_html );
1138
  }
1139
 
1140
  /**
1141
+ * Output button for visiting a blog in a loop.
1142
  *
1143
+ * @see bp_get_blogs_visit_blog_button() for description of arguments.
1144
  *
1145
+ * @param array $args See {@link bp_get_blogs_visit_blog_button()}.
1146
  */
1147
  function bp_blogs_visit_blog_button( $args = '' ) {
1148
  echo bp_get_blogs_visit_blog_button( $args );
1149
  }
1150
  /**
1151
+ * Return button for visiting a blog in a loop.
1152
  *
1153
+ * @see BP_Button for a complete description of arguments and return
1154
+ * value.
1155
  *
1156
+ * @param array $args {
1157
+ * Arguments are listed below, with their default values. For a
1158
+ * complete description of arguments, see {@link BP_Button}.
1159
+ * @type string $id Default: 'visit_blog'.
1160
+ * @type string $component Default: 'blogs'.
1161
+ * @type bool $must_be_logged_in Default: false.
1162
+ * @type bool $block_self Default: false.
1163
+ * @type string $wrapper_class Default: 'blog-button visit'.
1164
+ * @type string $link_href Permalink of the current blog in the loop.
1165
+ * @type string $link_class Default: 'blog-button visit'.
1166
+ * @type string $link_text Default: 'Visit Site'.
1167
+ * @type string $link_title Default: 'Visit Site'.
1168
+ * }
1169
+ * @return string The HTML for the Visit button.
1170
  */
1171
  function bp_get_blogs_visit_blog_button( $args = '' ) {
1172
  $defaults = array(
bp-blogs/bp-blogs-widgets.php CHANGED
@@ -10,7 +10,9 @@
10
  // Exit if accessed directly
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
- // @todo not use create_function()
 
 
14
  function bp_blogs_register_widgets() {
15
  global $wpdb;
16
 
@@ -24,6 +26,9 @@ add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
24
  */
25
  class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
26
 
 
 
 
27
  function __construct() {
28
  $widget_ops = array(
29
  'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ),
@@ -32,6 +37,14 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
32
  parent::__construct( false, $name = _x( '(BuddyPress) Recent Networkwide Posts', 'widget name', 'buddypress' ), $widget_ops );
33
  }
34
 
 
 
 
 
 
 
 
 
35
  function widget( $args, $instance ) {
36
 
37
  $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : __( 'Recent Networkwide Posts', 'buddypress' );
@@ -83,6 +96,13 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
83
  <?php
84
  }
85
 
 
 
 
 
 
 
 
86
  function update( $new_instance, $old_instance ) {
87
  $instance = $old_instance;
88
  $instance['title'] = strip_tags( $new_instance['title'] );
@@ -92,6 +112,11 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
92
  return $instance;
93
  }
94
 
 
 
 
 
 
95
  function form( $instance ) {
96
  $instance = wp_parse_args( (array) $instance, array(
97
  'title' => __( 'Recent Networkwide Posts', 'buddypress' ),
10
  // Exit if accessed directly
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
+ /**
14
+ * Register the widgets for the Blogs component.
15
+ */
16
  function bp_blogs_register_widgets() {
17
  global $wpdb;
18
 
26
  */
27
  class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
28
 
29
+ /**
30
+ * Constructor method.
31
+ */
32
  function __construct() {
33
  $widget_ops = array(
34
  'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ),
37
  parent::__construct( false, $name = _x( '(BuddyPress) Recent Networkwide Posts', 'widget name', 'buddypress' ), $widget_ops );
38
  }
39
 
40
+ /**
41
+ * Display the networkwide posts widget.
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
  function widget( $args, $instance ) {
49
 
50
  $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : __( 'Recent Networkwide Posts', 'buddypress' );
96
  <?php
97
  }
98
 
99
+ /**
100
+ * Update the networkwide posts widget options.
101
+ *
102
+ * @param array $new_instance The new instance options.
103
+ * @param array $old_instance The old instance options.
104
+ * @return array $instance The parsed options to be saved.
105
+ */
106
  function update( $new_instance, $old_instance ) {
107
  $instance = $old_instance;
108
  $instance['title'] = strip_tags( $new_instance['title'] );
112
  return $instance;
113
  }
114
 
115
+ /**
116
+ * Output the networkwide posts widget options form.
117
+ *
118
+ * @param $instance Settings for this widget.
119
+ */
120
  function form( $instance ) {
121
  $instance = wp_parse_args( (array) $instance, array(
122
  'title' => __( 'Recent Networkwide Posts', 'buddypress' ),
bp-core/admin/bp-core-actions.php CHANGED
@@ -3,9 +3,6 @@
3
  /**
4
  * BuddyPress Admin Actions
5
  *
6
- * @package BuddyPress
7
- * @subpackage Admin
8
- *
9
  * This file contains the actions that are used through-out BuddyPress Admin. They
10
  * are consolidated here to make searching for them easier, and to help developers
11
  * understand at a glance the order in which things occur.
@@ -15,6 +12,8 @@
15
  * - BuddyPress: In {@link BuddyPress::setup_actions()} in BuddyPress.php
16
  * - Admin: More in {@link bp_Admin::setup_actions()} in admin.php
17
  *
 
 
18
  * @see bp-core-actions.php
19
  * @see bp-core-filters.php
20
  */
@@ -131,13 +130,17 @@ function bp_admin_notices() {
131
  }
132
 
133
  /**
134
- * Piggy back admin_notices action
135
  *
136
- * @since BuddyPress (1.7)
137
- * @uses do_action() Calls 'bp_admin_notices'
 
 
 
 
138
  */
139
- function bp_admin_enqueue_scripts() {
140
- do_action( 'bp_admin_enqueue_scripts' );
141
  }
142
 
143
  /**
3
  /**
4
  * BuddyPress Admin Actions
5
  *
 
 
 
6
  * This file contains the actions that are used through-out BuddyPress Admin. They
7
  * are consolidated here to make searching for them easier, and to help developers
8
  * understand at a glance the order in which things occur.
12
  * - BuddyPress: In {@link BuddyPress::setup_actions()} in BuddyPress.php
13
  * - Admin: More in {@link bp_Admin::setup_actions()} in admin.php
14
  *
15
+ * @package BuddyPress
16
+ * @subpackage Admin
17
  * @see bp-core-actions.php
18
  * @see bp-core-filters.php
19
  */
130
  }
131
 
132
  /**
133
+ * Piggy back admin_enqueue_scripts action.
134
  *
135
+ * @since BuddyPress (1.7.0)
136
+ *
137
+ * @uses do_action() Calls 'bp_admin_enqueue_scripts''.
138
+ *
139
+ * @param string $hook_suffix The current admin page, passed to
140
+ * 'admin_enqueue_scripts'.
141
  */
142
+ function bp_admin_enqueue_scripts( $hook_suffix = '' ) {
143
+ do_action( 'bp_admin_enqueue_scripts', $hook_suffix );
144
  }
145
 
146
  /**
bp-core/admin/bp-core-components.php CHANGED
@@ -58,12 +58,20 @@ function bp_core_admin_components_options() {
58
  'xprofile' => array(
59
  'title' => __( 'Extended Profiles', 'buddypress' ),
60
  'description' => __( 'Customize your community with fully editable profile fields that allow your users to describe themselves.', 'buddypress' )
61
- )
 
 
 
 
 
 
 
 
62
  );
63
 
64
  $optional_components = bp_core_admin_get_components( 'optional' );
65
  $required_components = bp_core_admin_get_components( 'required' );
66
- $retired_components = bp_core_admin_get_components( 'retired' );
67
 
68
  // Don't show Forums component in optional components if it's disabled
69
  if ( ! bp_is_active( 'forums' ) ) {
@@ -371,6 +379,10 @@ function bp_core_admin_get_components( $type = 'all' ) {
371
  'title' => __( 'Activity Streams', 'buddypress' ),
372
  'description' => __( 'Global, personal, and group activity streams with threaded commenting, direct posting, favoriting and @mentions, all with full RSS feed and email notification support.', 'buddypress' )
373
  ),
 
 
 
 
374
  'groups' => array(
375
  'title' => __( 'User Groups', 'buddypress' ),
376
  'description' => __( 'Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings.', 'buddypress' )
58
  'xprofile' => array(
59
  'title' => __( 'Extended Profiles', 'buddypress' ),
60
  'description' => __( 'Customize your community with fully editable profile fields that allow your users to describe themselves.', 'buddypress' )
61
+ ),
62
+ 'settings' => array(
63
+ 'title' => __( 'Account Settings', 'buddypress' ),
64
+ 'description' => __( 'Allow your users to modify their account and notification settings directly from within their profiles.', 'buddypress' )
65
+ ),
66
+ 'notifications' => array(
67
+ 'title' => __( 'Notifications', 'buddypress' ),
68
+ 'description' => __( 'Notify members of relevant activity with a toolbar bubble and/or via email, and allow them to customize their notification settings.', 'buddypress' )
69
+ ),
70
  );
71
 
72
  $optional_components = bp_core_admin_get_components( 'optional' );
73
  $required_components = bp_core_admin_get_components( 'required' );
74
+ $retired_components = bp_core_admin_get_components( 'retired' );
75
 
76
  // Don't show Forums component in optional components if it's disabled
77
  if ( ! bp_is_active( 'forums' ) ) {
379
  'title' => __( 'Activity Streams', 'buddypress' ),
380
  'description' => __( 'Global, personal, and group activity streams with threaded commenting, direct posting, favoriting and @mentions, all with full RSS feed and email notification support.', 'buddypress' )
381
  ),
382
+ 'notifications' => array(
383
+ 'title' => __( 'Notifications', 'buddypress' ),
384
+ 'description' => __( 'Notify members of relevant activity with a toolbar bubble and/or via email, and allow them to customize their notification settings.', 'buddypress' )
385
+ ),
386
  'groups' => array(
387
  'title' => __( 'User Groups', 'buddypress' ),
388
  'description' => __( 'Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings.', 'buddypress' )
bp-core/admin/bp-core-functions.php CHANGED
@@ -120,27 +120,35 @@ function bp_core_admin_backpat_page() {
120
  * @uses bp_is_root_blog()
121
  */
122
  function bp_core_print_admin_notices() {
123
- $bp = buddypress();
124
 
125
  // Only the super admin should see messages
126
- if ( !bp_current_user_can( 'bp_moderate' ) )
127
  return;
 
128
 
129
- // On multisite installs, don't show on the Site Admin of a non-root blog, unless
130
- // do_network_admin is overridden
131
- if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() )
132
  return;
 
 
 
 
133
 
134
  // Show the messages
135
- if ( !empty( $bp->admin->notices ) ) {
136
- ?>
137
  <div id="message" class="updated fade">
138
- <?php foreach ( $bp->admin->notices as $notice ) : ?>
139
- <p><?php echo $notice ?></p>
140
- <?php endforeach ?>
 
 
 
 
141
  </div>
142
- <?php
143
- }
144
  }
145
  add_action( 'admin_notices', 'bp_core_print_admin_notices' );
146
  add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
@@ -157,14 +165,20 @@ add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
157
  *
158
  * @param string $notice The notice you are adding to the queue
159
  */
160
- function bp_core_add_admin_notice( $notice ) {
161
- $bp = buddypress();
 
 
 
 
162
 
163
- if ( empty( $bp->admin->notices ) ) {
164
- $bp->admin->notices = array();
 
165
  }
166
 
167
- $bp->admin->notices[] = $notice;
 
168
  }
169
 
170
  /**
@@ -186,12 +200,14 @@ function bp_core_activation_notice() {
186
  $bp = buddypress();
187
 
188
  // Only the super admin gets warnings
189
- if ( !bp_current_user_can( 'bp_moderate' ) )
190
  return;
 
191
 
192
  // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden
193
- if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() )
194
  return;
 
195
 
196
  /**
197
  * Check to make sure that the blog setup routine has run. This can't happen during the
@@ -209,8 +225,9 @@ function bp_core_activation_notice() {
209
  /**
210
  * Are pretty permalinks enabled?
211
  */
212
- if ( isset( $_POST['permalink_structure'] ) )
213
  return;
 
214
 
215
  if ( empty( $wp_rewrite->permalink_structure ) ) {
216
  bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) );
@@ -247,8 +264,9 @@ function bp_core_activation_notice() {
247
  }
248
 
249
  // On the first admin screen after a new installation, this isn't set, so grab it to supress a misleading error message.
250
- if ( empty( $bp->pages->members ) )
251
  $bp->pages = bp_core_get_directory_pages();
 
252
 
253
  foreach( $wp_page_components as $component ) {
254
  if ( !isset( $bp->pages->{$component['id']} ) ) {
@@ -642,3 +660,108 @@ function bp_admin_list_table_current_bulk_action() {
642
 
643
  return $action;
644
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  * @uses bp_is_root_blog()
121
  */
122
  function bp_core_print_admin_notices() {
 
123
 
124
  // Only the super admin should see messages
125
+ if ( ! bp_current_user_can( 'bp_moderate' ) ) {
126
  return;
127
+ }
128
 
129
+ // On multisite installs, don't show on a non-root blog, unless
130
+ // 'do_network_admin' is overridden.
131
+ if ( is_multisite() && bp_core_do_network_admin() && ! bp_is_root_blog() ) {
132
  return;
133
+ }
134
+
135
+ // Get the admin notices
136
+ $admin_notices = buddypress()->admin->notices;
137
 
138
  // Show the messages
139
+ if ( !empty( $admin_notices ) ) : ?>
140
+
141
  <div id="message" class="updated fade">
142
+
143
+ <?php foreach ( $admin_notices as $notice ) : ?>
144
+
145
+ <p><?php echo $notice; ?></p>
146
+
147
+ <?php endforeach; ?>
148
+
149
  </div>
150
+
151
+ <?php endif;
152
  }
153
  add_action( 'admin_notices', 'bp_core_print_admin_notices' );
154
  add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
165
  *
166
  * @param string $notice The notice you are adding to the queue
167
  */
168
+ function bp_core_add_admin_notice( $notice = '' ) {
169
+
170
+ // Do not add if the notice is empty
171
+ if ( empty( $notice ) ) {
172
+ return;
173
+ }
174
 
175
+ // Double check the object before referencing it
176
+ if ( ! isset( buddypress()->admin->notices ) ) {
177
+ buddypress()->admin->notices = array();
178
  }
179
 
180
+ // Add the notice
181
+ buddypress()->admin->notices[] = $notice;
182
  }
183
 
184
  /**
200
  $bp = buddypress();
201
 
202
  // Only the super admin gets warnings
203
+ if ( ! bp_current_user_can( 'bp_moderate' ) ) {
204
  return;
205
+ }
206
 
207
  // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden
208
+ if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() ) {
209
  return;
210
+ }
211
 
212
  /**
213
  * Check to make sure that the blog setup routine has run. This can't happen during the
225
  /**
226
  * Are pretty permalinks enabled?
227
  */
228
+ if ( isset( $_POST['permalink_structure'] ) ) {
229
  return;
230
+ }
231
 
232
  if ( empty( $wp_rewrite->permalink_structure ) ) {
233
  bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) );
264
  }
265
 
266
  // On the first admin screen after a new installation, this isn't set, so grab it to supress a misleading error message.
267
+ if ( empty( $bp->pages->members ) ) {
268
  $bp->pages = bp_core_get_directory_pages();
269
+ }
270
 
271
  foreach( $wp_page_components as $component ) {
272
  if ( !isset( $bp->pages->{$component['id']} ) ) {
660
 
661
  return $action;
662
  }
663
+
664
+ /** Menus *********************************************************************/
665
+
666
+ /**
667
+ * Register meta box and associated JS for BuddyPress WP Nav Menu .
668
+ *
669
+ * @since BuddyPress (1.9.0)
670
+ */
671
+ function bp_admin_wp_nav_menu_meta_box() {
672
+ if ( ! bp_is_root_blog() ) {
673
+ return;
674
+ }
675
+
676
+ add_meta_box( 'add-buddypress-nav-menu', __( 'BuddyPress', 'buddypress' ), 'bp_admin_do_wp_nav_menu_meta_box', 'nav-menus', 'side', 'default' );
677
+
678
+ add_action( 'admin_print_footer_scripts', 'bp_admin_wp_nav_menu_restrict_items' );
679
+ }
680
+
681
+ /**
682
+ * Build and populate the BuddyPress accordion on Appearance > Menus.
683
+ *
684
+ * @since BuddyPress (1.9.0)
685
+ *
686
+ * @global $nav_menu_selected_id
687
+ */
688
+ function bp_admin_do_wp_nav_menu_meta_box() {
689
+ global $nav_menu_selected_id;
690
+
691
+ $walker = new BP_Walker_Nav_Menu_Checklist( false );
692
+ $args = array( 'walker' => $walker );
693
+
694
+ $post_type_name = 'buddypress';
695
+ $current_tab = 'loggedin';
696
+
697
+ $tabs = array();
698
+
699
+ $tabs['loggedin']['label'] = __( 'Logged-In', 'buddypress' );
700
+ $tabs['loggedin']['pages'] = bp_nav_menu_get_loggedin_pages();
701
+
702
+ $tabs['loggedout']['label'] = __( 'Logged-Out', 'buddypress' );
703
+ $tabs['loggedout']['pages'] = bp_nav_menu_get_loggedout_pages();
704
+
705
+ ?>
706
+
707
+ <div id="buddypress-menu" class="posttypediv">
708
+ <h4><?php _e( 'Logged-In', 'buddypress' ) ?></h4>
709
+ <p><?php _e( '<em>Logged-In</em> links are relative to the current user, and are not visible to visitors who are not logged in.', 'buddypress' ) ?></p>
710
+
711
+ <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-loggedin" class="tabs-panel tabs-panel-active">
712
+ <ul id="buddypress-menu-checklist-loggedin" class="categorychecklist form-no-clear">
713
+ <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $tabs['loggedin']['pages'] ), 0, (object) $args );?>
714
+ </ul>
715
+ </div>
716
+
717
+ <h4><?php _e( 'Logged-Out', 'buddypress' ) ?></h4>
718
+ <p><?php _e( '<em>Logged-Out</em> links are not visible to users who are logged in.', 'buddypress' ) ?></p>
719
+
720
+ <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-loggedout" class="tabs-panel tabs-panel-active">
721
+ <ul id="buddypress-menu-checklist-loggedout" class="categorychecklist form-no-clear">
722
+ <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $tabs['loggedout']['pages'] ), 0, (object) $args );?>
723
+ </ul>
724
+ </div>
725
+
726
+ <p class="button-controls">
727
+ <span class="add-to-menu">
728
+ <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="submit-buddypress-menu" />
729
+ <span class="spinner"></span>
730
+ </span>
731
+ </p>
732
+ </div><!-- /#buddypress-menu -->
733
+
734
+ <?php
735
+ }
736
+
737
+ /**
738
+ * Restrict various items from view if editing a BuddyPress menu.
739
+ *
740
+ * If a person is editing a BP menu item, that person should not be able to
741
+ * see or edit the following fields:
742
+ *
743
+ * - CSS Classes - We use the 'bp-menu' CSS class to determine if the
744
+ * menu item belongs to BP, so we cannot allow manipulation of this field to
745
+ * occur.
746
+ * - URL - This field is automatically generated by BP on output, so this
747
+ * field is useless and can cause confusion.
748
+ *
749
+ * Note: These restrictions are only enforced if javascript is enabled.
750
+ *
751
+ * @since BuddyPress (1.9.0)
752
+ */
753
+ function bp_admin_wp_nav_menu_restrict_items() {
754
+ ?>
755
+ <script type="text/javascript">
756
+ jQuery( '#menu-to-edit').on( 'click', 'a.item-edit', function() {
757
+ var settings = jQuery(this).closest( '.menu-item-bar' ).next( '.menu-item-settings' );
758
+ var css_class = settings.find( '.edit-menu-item-classes' );
759
+
760
+ if( css_class.val().indexOf( 'bp-menu' ) == 0 ) {
761
+ css_class.attr( 'readonly', 'readonly' );
762
+ settings.find( '.field-url' ).css( 'display', 'none' );
763
+ }
764
+ });
765
+ </script>
766
+ <?php
767
+ }
bp-core/admin/bp-core-schema.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  // Exit if accessed directly
4
  if ( !defined( 'ABSPATH' ) ) exit;
@@ -17,8 +23,9 @@ function bp_core_install( $active_components = false ) {
17
  if ( empty( $active_components ) )
18
  $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
19
 
20
- // Core DB Tables
21
- bp_core_install_notifications();
 
22
 
23
  // Activity Streams
24
  if ( !empty( $active_components['activity'] ) )
1
  <?php
2
+ /**
3
+ * BuddyPress DB schema
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage CoreAdministration
7
+ */
8
 
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
23
  if ( empty( $active_components ) )
24
  $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
25
 
26
+ // Notifications
27
+ if ( !empty( $active_components['notifications'] ) )
28
+ bp_core_install_notifications();
29
 
30
  // Activity Streams
31
  if ( !empty( $active_components['activity'] ) )
bp-core/bp-core-actions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Filters & Actions
5
  *
6
  * @package BuddyPress
7
  * @subpackage Hooks
@@ -16,7 +16,7 @@
16
  if ( !defined( 'ABSPATH' ) ) exit;
17
 
18
  /**
19
- * Attach BuddyPress to WordPress
20
  *
21
  * BuddyPress uses its own internal actions to help aid in third-party plugin
22
  * development, and to limit the amount of potential future code changes when
@@ -33,6 +33,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
33
  */
34
  add_action( 'plugins_loaded', 'bp_loaded', 10 );
35
  add_action( 'init', 'bp_init', 10 );
 
36
  add_action( 'wp', 'bp_ready', 10 );
37
  add_action( 'set_current_user', 'bp_setup_current_user', 10 );
38
  add_action( 'setup_theme', 'bp_setup_theme', 10 );
@@ -69,6 +70,8 @@ add_action( 'bp_init', 'bp_setup_nav', 6 );
69
  add_action( 'bp_init', 'bp_setup_title', 8 );
70
  add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 );
71
  add_action( 'bp_init', 'bp_add_rewrite_tags', 20 );
 
 
72
 
73
  /**
74
  * bp_template_redirect - Attached to 'template_redirect' above
@@ -79,10 +82,13 @@ add_action( 'bp_init', 'bp_add_rewrite_tags', 20 );
79
  * Note that we currently use template_redirect versus template include because
80
  * BuddyPress is a bully and overrides the existing themes output in many
81
  * places. This won't always be this way, we promise.
82
- * v---Load order
83
  */
84
- add_action( 'bp_template_redirect', 'bp_actions', 4 );
85
- add_action( 'bp_template_redirect', 'bp_screens', 6 );
 
 
 
86
 
87
  /**
88
  * Add the BuddyPress functions file
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Filters & Actions.
5
  *
6
  * @package BuddyPress
7
  * @subpackage Hooks
16
  if ( !defined( 'ABSPATH' ) ) exit;
17
 
18
  /**
19
+ * Attach BuddyPress to WordPress.
20
  *
21
  * BuddyPress uses its own internal actions to help aid in third-party plugin
22
  * development, and to limit the amount of potential future code changes when
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 );
70
  add_action( 'bp_init', 'bp_setup_title', 8 );
71
  add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 );
72
  add_action( 'bp_init', 'bp_add_rewrite_tags', 20 );
73
+ add_action( 'bp_init', 'bp_add_rewrite_rules', 30 );
74
+ add_action( 'bp_init', 'bp_add_permastructs', 40 );
75
 
76
  /**
77
  * bp_template_redirect - Attached to 'template_redirect' above
82
  * Note that we currently use template_redirect versus template include because
83
  * BuddyPress is a bully and overrides the existing themes output in many
84
  * places. This won't always be this way, we promise.
85
+ * v---Load order
86
  */
87
+ add_action( 'bp_template_redirect', 'bp_redirect_canonical', 2 );
88
+ add_action( 'bp_template_redirect', 'bp_actions', 4 );
89
+ add_action( 'bp_template_redirect', 'bp_screens', 6 );
90
+ add_action( 'bp_template_redirect', 'bp_post_request', 10 );
91
+ add_action( 'bp_template_redirect', 'bp_get_request', 10 );
92
 
93
  /**
94
  * Add the BuddyPress functions file
bp-core/bp-core-admin.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * Main BuddyPress Admin Class
5
  *
6
  * @package BuddyPress
7
  * @subpackage CoreAdministration
@@ -12,53 +12,73 @@ if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  if ( !class_exists( 'BP_Admin' ) ) :
14
  /**
15
- * Loads BuddyPress plugin admin area
16
  *
17
  * @package BuddyPress
18
  * @subpackage CoreAdministration
19
- * @since BuddyPress (1.6)
 
20
  */
21
  class BP_Admin {
22
 
23
  /** Directory *************************************************************/
24
 
25
  /**
26
- * @var string Path to the BuddyPress admin directory
 
 
27
  */
28
  public $admin_dir = '';
29
 
30
  /** URLs ******************************************************************/
31
 
32
  /**
33
- * @var string URL to the BuddyPress admin directory
 
 
34
  */
35
  public $admin_url = '';
36
 
37
  /**
38
- * @var string URL to the BuddyPress images directory
 
 
39
  */
40
  public $images_url = '';
41
 
42
  /**
43
- * @var string URL to the BuddyPress admin CSS directory
 
 
44
  */
45
  public $css_url = '';
46
 
47
  /**
48
- * @var string URL to the BuddyPress admin JS directory
 
 
49
  */
50
  public $js_url = '';
51
 
 
 
 
 
 
 
 
 
 
52
  /** Methods ***************************************************************/
53
 
54
  /**
55
- * The main BuddyPress admin loader
56
  *
57
- * @since BuddyPress (1.6)
58
  *
59
- * @uses BP_Admin::setup_globals() Setup the globals needed
60
- * @uses BP_Admin::includes() Include the required files
61
- * @uses BP_Admin::setup_actions() Setup the hooks and actions
62
  */
63
  public function __construct() {
64
  $this->setup_globals();
@@ -67,10 +87,10 @@ class BP_Admin {
67
  }
68
 
69
  /**
70
- * Admin globals
71
  *
72
- * @since BuddyPress (1.6)
73
  * @access private
 
74
  */
75
  private function setup_globals() {
76
  $bp = buddypress();
@@ -87,9 +107,9 @@ class BP_Admin {
87
  }
88
 
89
  /**
90
- * Include required files
91
  *
92
- * @since BuddyPress (1.6)
93
  * @access private
94
  */
95
  private function includes() {
@@ -101,13 +121,13 @@ class BP_Admin {
101
  }
102
 
103
  /**
104
- * Setup the admin hooks, actions and filters
105
  *
106
- * @since BuddyPress (1.6)
107
  * @access private
 
108
  *
109
- * @uses add_action() To add various actions
110
- * @uses add_filter() To add various filters
111
  */
112
  private function setup_actions() {
113
 
@@ -124,6 +144,9 @@ class BP_Admin {
124
 
125
  /** BuddyPress Actions ************************************************/
126
 
 
 
 
127
  // Add settings
128
  add_action( 'bp_register_admin_settings', array( $this, 'register_admin_settings' ) );
129
 
@@ -135,13 +158,13 @@ class BP_Admin {
135
  }
136
 
137
  /**
138
- * Add the navigational menu elements
139
  *
140
  * @since BuddyPress (1.6)
141
  *
142
- * @uses add_management_page() To add the Recount page in Tools section
143
  * @uses add_options_page() To add the Forums settings page in Settings
144
- * section
145
  */
146
  public function admin_menus() {
147
 
@@ -223,13 +246,13 @@ class BP_Admin {
223
  }
224
 
225
  /**
226
- * Register the settings
227
  *
228
- * @since BuddyPress (1.6)
229
  *
230
- * @uses add_settings_section() To add our own settings section
231
- * @uses add_settings_field() To add various settings fields
232
- * @uses register_setting() To register various settings
233
  */
234
  public function register_admin_settings() {
235
 
@@ -312,13 +335,13 @@ class BP_Admin {
312
  }
313
 
314
  /**
315
- * Add Settings link to plugins area
316
  *
317
- * @since BuddyPress (1.6)
318
  *
319
- * @param array $links Links array in which we would prepend our link
320
- * @param string $file Current plugin basename
321
- * @return array Processed links
322
  */
323
  public function modify_plugin_action_links( $links, $file ) {
324
 
@@ -334,9 +357,9 @@ class BP_Admin {
334
  }
335
 
336
  /**
337
- * Add some general styling to the admin area
338
  *
339
- * @since BuddyPress (1.6)
340
  */
341
  public function admin_head() {
342
 
@@ -350,9 +373,9 @@ class BP_Admin {
350
  }
351
 
352
  /**
353
- * Add some general styling to the admin area
354
  *
355
- * @since BuddyPress (1.6)
356
  */
357
  public function enqueue_scripts() {
358
 
@@ -366,9 +389,9 @@ class BP_Admin {
366
  /** About *****************************************************************/
367
 
368
  /**
369
- * Output the about screen
370
  *
371
- * @since BuddyPress (1.7)
372
  */
373
  public function about_screen() {
374
  global $wp_rewrite;
@@ -403,7 +426,9 @@ class BP_Admin {
403
 
404
  <div class="feature-section">
405
  <h4><?php _e( 'Your Default Setup', 'buddypress' ); ?></h4>
406
- <p><?php printf(
 
 
407
  __( 'BuddyPress&#8217;s powerful features help your users connect and collaborate. To help get your community started, we&#8217;ve activated two of the most commonly used tools in BP: <strong>Extended Profiles</strong> and <strong>Activity Streams</strong>. See these components in action at the %1$s and %2$s directories, and be sure to spend a few minutes <a href="%3$s">configuring user profiles</a>. Want to explore more of BP&#8217;s features? Visit the <a href="%4$s">Components panel</a>.', 'buddypress' ),
408
  $pretty_permalinks_enabled ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '">' . __( 'Members', 'buddypress' ) . '</a>' : __( 'Members', 'buddypress' ),
409
  $pretty_permalinks_enabled ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() ) . '">' . __( 'Activity', 'buddypress' ) . '</a>' : __( 'Activity', 'buddypress' ),
@@ -411,6 +436,14 @@ class BP_Admin {
411
  bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) )
412
  ); ?></p>
413
 
 
 
 
 
 
 
 
 
414
  <h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
415
  <p><?php _e( 'Looking for help? The <a href="http://codex.buddypress.org/">BuddyPress Codex</a> has you covered, with dozens of user-contributed guides on how to configure and use your BP site. Can&#8217;t find what you need? Stop by <a href="http://buddypress.org/support/">our support forums</a>, where a vibrant community of BuddyPress users and developers is waiting to share tips, show off their sites, talk about the future of BuddyPress, and much more.', 'buddypress' ) ?></p>
416
  </div>
@@ -477,12 +510,12 @@ class BP_Admin {
477
  }
478
 
479
  /**
480
- * Output the credits screen
481
  *
482
- * Hardcoding this in here is pretty janky. It's fine for 2.2, but we'll
483
  * want to leverage api.wordpress.org eventually.
484
  *
485
- * @since BuddyPress (1.7)
486
  */
487
  public function credits_screen() {
488
 
@@ -609,9 +642,9 @@ class BP_Admin {
609
  endif; // class_exists check
610
 
611
  /**
612
- * Setup BuddyPress Admin
613
  *
614
- * @since BuddyPress (1.6)
615
  *
616
  * @uses BP_Admin
617
  */
1
  <?php
2
 
3
  /**
4
+ * Main BuddyPress Admin Class.
5
  *
6
  * @package BuddyPress
7
  * @subpackage CoreAdministration
12
 
13
  if ( !class_exists( 'BP_Admin' ) ) :
14
  /**
15
+ * Load BuddyPress plugin admin area.
16
  *
17
  * @package BuddyPress
18
  * @subpackage CoreAdministration
19
+ *
20
+ * @since BuddyPress (1.6.0)
21
  */
22
  class BP_Admin {
23
 
24
  /** Directory *************************************************************/
25
 
26
  /**
27
+ * Path to the BuddyPress admin directory.
28
+ *
29
+ * @var string $admin_dir
30
  */
31
  public $admin_dir = '';
32
 
33
  /** URLs ******************************************************************/
34
 
35
  /**
36
+ * URL to the BuddyPress admin directory.
37
+ *
38
+ * @var string $admin_url
39
  */
40
  public $admin_url = '';
41
 
42
  /**
43
+ * URL to the BuddyPress images directory.
44
+ *
45
+ * @var string $images_url
46
  */
47
  public $images_url = '';
48
 
49
  /**
50
+ * URL to the BuddyPress admin CSS directory.
51
+ *
52
+ * @var string $css_url
53
  */
54
  public $css_url = '';
55
 
56
  /**
57
+ * URL to the BuddyPress admin JS directory.
58
+ *
59
+ * @var string
60
  */
61
  public $js_url = '';
62
 
63
+ /** Other *****************************************************************/
64
+
65
+ /**
66
+ * Notices used for user feedback, like saving settings.
67
+ *
68
+ * @var array()
69
+ */
70
+ public $notices = array();
71
+
72
  /** Methods ***************************************************************/
73
 
74
  /**
75
+ * The main BuddyPress admin loader.
76
  *
77
+ * @since BuddyPress (1.6.0)
78
  *
79
+ * @uses BP_Admin::setup_globals() Setup the globals needed.
80
+ * @uses BP_Admin::includes() Include the required files.
81
+ * @uses BP_Admin::setup_actions() Setup the hooks and actions.
82
  */
83
  public function __construct() {
84
  $this->setup_globals();
87
  }
88
 
89
  /**
90
+ * Set admin-related globals.
91
  *
 
92
  * @access private
93
+ * @since BuddyPress (1.6.0)
94
  */
95
  private function setup_globals() {
96
  $bp = buddypress();
107
  }
108
 
109
  /**
110
+ * Include required files.
111
  *
112
+ * @since BuddyPress (1.6.0)
113
  * @access private
114
  */
115
  private function includes() {
121
  }
122
 
123
  /**
124
+ * Set up the admin hooks, actions, and filters.
125
  *
 
126
  * @access private
127
+ * @since BuddyPress (1.6.0)
128
  *
129
+ * @uses add_action() To add various actions.
130
+ * @uses add_filter() To add various filters.
131
  */
132
  private function setup_actions() {
133
 
144
 
145
  /** BuddyPress Actions ************************************************/
146
 
147
+ // Load the BuddyPress metabox in the WP Nav Menu Admin UI
148
+ add_action( 'load-nav-menus.php', 'bp_admin_wp_nav_menu_meta_box' );
149
+
150
  // Add settings
151
  add_action( 'bp_register_admin_settings', array( $this, 'register_admin_settings' ) );
152
 
158
  }
159
 
160
  /**
161
+ * Add the navigational menu elements.
162
  *
163
  * @since BuddyPress (1.6)
164
  *
165
+ * @uses add_management_page() To add the Recount page in Tools section.
166
  * @uses add_options_page() To add the Forums settings page in Settings
167
+ * section.
168
  */
169
  public function admin_menus() {
170
 
246
  }
247
 
248
  /**
249
+ * Register the settings.
250
  *
251
+ * @since BuddyPress (1.6.0)
252
  *
253
+ * @uses add_settings_section() To add our own settings section.
254
+ * @uses add_settings_field() To add various settings fields.
255
+ * @uses register_setting() To register various settings.
256
  */
257
  public function register_admin_settings() {
258
 
335
  }
336
 
337
  /**
338
+ * Add Settings link to plugins area.
339
  *
340
+ * @since BuddyPress (1.6.0)
341
  *
342
+ * @param array $links Links array in which we would prepend our link.
343
+ * @param string $file Current plugin basename.
344
+ * @return array Processed links.
345
  */
346
  public function modify_plugin_action_links( $links, $file ) {
347
 
357
  }
358
 
359
  /**
360
+ * Add some general styling to the admin area.
361
  *
362
+ * @since BuddyPress (1.6.0)
363
  */
364
  public function admin_head() {
365
 
373
  }
374
 
375
  /**
376
+ * Add some general styling to the admin area.
377
  *
378
+ * @since BuddyPress (1.6.0)
379
  */
380
  public function enqueue_scripts() {
381
 
389
  /** About *****************************************************************/
390
 
391
  /**
392
+ * Output the about screen.
393
  *
394
+ * @since BuddyPress (1.7.0)
395
  */
396
  public function about_screen() {
397
  global $wp_rewrite;
426
 
427
  <div class="feature-section">
428
  <h4><?php _e( 'Your Default Setup', 'buddypress' ); ?></h4>
429
+
430
+ <?php if ( bp_is_active( 'members' ) && bp_is_active( 'activity' ) ) : ?>
431
+ <p><?php printf(
432
  __( 'BuddyPress&#8217;s powerful features help your users connect and collaborate. To help get your community started, we&#8217;ve activated two of the most commonly used tools in BP: <strong>Extended Profiles</strong> and <strong>Activity Streams</strong>. See these components in action at the %1$s and %2$s directories, and be sure to spend a few minutes <a href="%3$s">configuring user profiles</a>. Want to explore more of BP&#8217;s features? Visit the <a href="%4$s">Components panel</a>.', 'buddypress' ),
433
  $pretty_permalinks_enabled ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '">' . __( 'Members', 'buddypress' ) . '</a>' : __( 'Members', 'buddypress' ),
434
  $pretty_permalinks_enabled ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() ) . '">' . __( 'Activity', 'buddypress' ) . '</a>' : __( 'Activity', 'buddypress' ),
436
  bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) )
437
  ); ?></p>
438
 
439
+ <?php else : ?>
440
+ <p><?php printf(
441
+ __( 'BuddyPress&#8217;s powerful features help your users connect and collaborate. Want to explore BP&#8217;s features? Visit the <a href="%s">Components panel</a>.', 'buddypress' ),
442
+ bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) )
443
+ ); ?></p>
444
+
445
+ <?php endif; ?>
446
+
447
  <h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
448
  <p><?php _e( 'Looking for help? The <a href="http://codex.buddypress.org/">BuddyPress Codex</a> has you covered, with dozens of user-contributed guides on how to configure and use your BP site. Can&#8217;t find what you need? Stop by <a href="http://buddypress.org/support/">our support forums</a>, where a vibrant community of BuddyPress users and developers is waiting to share tips, show off their sites, talk about the future of BuddyPress, and much more.', 'buddypress' ) ?></p>
449
  </div>
510
  }
511
 
512
  /**
513
+ * Output the credits screen.
514
  *
515
+ * Hardcoding this in here is pretty janky. It's fine for now, but we'll
516
  * want to leverage api.wordpress.org eventually.
517
  *
518
+ * @since BuddyPress (1.7.0)
519
  */
520
  public function credits_screen() {
521
 
642
  endif; // class_exists check
643
 
644
  /**
645
+ * Setup BuddyPress Admin.
646
  *
647
+ * @since BuddyPress (1.6.0)
648
  *
649
  * @uses BP_Admin
650
  */
bp-core/bp-core-adminbar.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Core Toolbar
5
  *
6
- * Handles the core functions related to the WordPress Toolbar
7
  *
8
  * @package BuddyPress
9
  * @subpackage Core
@@ -13,9 +13,10 @@
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
- * Adds the secondary BuddyPress area to the my-account menu
 
 
17
  *
18
- * @since BuddyPress 1.6
19
  * @global WP_Admin_Bar $wp_admin_bar
20
  */
21
  function bp_admin_bar_my_account_root() {
@@ -43,22 +44,22 @@ function bp_admin_bar_my_account_root() {
43
  add_action( 'admin_bar_menu', 'bp_admin_bar_my_account_root', 100 );
44
 
45
  /**
46
- * Handle the Toolbar/BuddyBar business
47
  *
48
- * @since BuddyPress (1.2)
49
  *
50
  * @global string $wp_version
51
  * @uses bp_get_option()
52
  * @uses is_user_logged_in()
53
  * @uses bp_use_wp_admin_bar()
54
  * @uses show_admin_bar()
55
- * @uses add_action() To hook 'bp_adminbar_logo' to 'bp_adminbar_logo'
56
- * @uses add_action() To hook 'bp_adminbar_login_menu' to 'bp_adminbar_menus'
57
- * @uses add_action() To hook 'bp_adminbar_account_menu' to 'bp_adminbar_menus'
58
- * @uses add_action() To hook 'bp_adminbar_thisblog_menu' to 'bp_adminbar_menus'
59
- * @uses add_action() To hook 'bp_adminbar_random_menu' to 'bp_adminbar_menus'
60
- * @uses add_action() To hook 'bp_core_admin_bar' to 'wp_footer'
61
- * @uses add_action() To hook 'bp_core_admin_bar' to 'admin_footer'
62
  */
63
  function bp_core_load_admin_bar() {
64
 
@@ -88,9 +89,9 @@ function bp_core_load_admin_bar() {
88
  add_action( 'init', 'bp_core_load_admin_bar', 9 );
89
 
90
  /**
91
- * Handle the Toolbar CSS
92
  *
93
- * @since BuddyPress 1.5
94
  */
95
  function bp_core_load_admin_bar_css() {
96
  global $wp_styles;
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Core Toolbar.
5
  *
6
+ * Handles the core functions related to the WordPress Toolbar.
7
  *
8
  * @package BuddyPress
9
  * @subpackage Core
13
  if ( !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
  */
22
  function bp_admin_bar_my_account_root() {
44
  add_action( 'admin_bar_menu', 'bp_admin_bar_my_account_root', 100 );
45
 
46
  /**
47
+ * Handle the Toolbar/BuddyBar business.
48
  *
49
+ * @since BuddyPress (1.2.0)
50
  *
51
  * @global string $wp_version
52
  * @uses bp_get_option()
53
  * @uses is_user_logged_in()
54
  * @uses bp_use_wp_admin_bar()
55
  * @uses show_admin_bar()
56
+ * @uses add_action() To hook 'bp_adminbar_logo' to 'bp_adminbar_logo'.
57
+ * @uses add_action() To hook 'bp_adminbar_login_menu' to 'bp_adminbar_menus'.
58
+ * @uses add_action() To hook 'bp_adminbar_account_menu' to 'bp_adminbar_menus'.
59
+ * @uses add_action() To hook 'bp_adminbar_thisblog_menu' to 'bp_adminbar_menus'.
60
+ * @uses add_action() To hook 'bp_adminbar_random_menu' to 'bp_adminbar_menus'.
61
+ * @uses add_action() To hook 'bp_core_admin_bar' to 'wp_footer'.
62
+ * @uses add_action() To hook 'bp_core_admin_bar' to 'admin_footer'.
63
  */
64
  function bp_core_load_admin_bar() {
65
 
89
  add_action( 'init', 'bp_core_load_admin_bar', 9 );
90
 
91
  /**
92
+ * Handle the Toolbar CSS.
93
  *
94
+ * @since BuddyPress (1.5.0)
95
  */
96
  function bp_core_load_admin_bar_css() {
97
  global $wp_styles;
bp-core/bp-core-avatars.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Avatars
5
  */
6
 
7
  // Exit if accessed directly
8
  if ( !defined( 'ABSPATH' ) ) exit;
9
 
10
  /***
11
- * Set up the constants we need for avatar support
12
  */
13
  function bp_core_set_avatar_constants() {
14
 
@@ -50,6 +50,11 @@ function bp_core_set_avatar_constants() {
50
  }
51
  add_action( 'bp_init', 'bp_core_set_avatar_constants', 3 );
52
 
 
 
 
 
 
53
  function bp_core_set_avatar_globals() {
54
  $bp = buddypress();
55
 
@@ -92,14 +97,87 @@ function bp_core_set_avatar_globals() {
92
  add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
93
 
94
  /**
95
- * bp_core_fetch_avatar()
 
 
 
96
  *
97
- * Fetches an avatar from a BuddyPress object. Supports user/group/blog as
98
- * default, but can be extended to include your own custom components too.
 
 
99
  *
100
- * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
101
- * @param array $args Determine the output of this function
102
- * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  */
104
  function bp_core_fetch_avatar( $args = '' ) {
105
 
@@ -404,15 +482,19 @@ function bp_core_fetch_avatar( $args = '' ) {
404
  }
405
 
406
  /**
407
- * Delete an existing avatar
408
- *
409
- * Accepted values for $args are:
410
- * item_id - item id which relates to the object type.
411
- * object - the objetc type user, group, blog, etc.
412
- * avatar_dir - The directory where the avatars to be uploaded.
413
  *
414
- * @param mixed $args
415
- * @return bool Success/failure
 
 
 
 
 
 
 
 
 
416
  */
417
  function bp_core_delete_existing_avatar( $args = '' ) {
418
 
@@ -472,17 +554,20 @@ function bp_core_delete_existing_avatar( $args = '' ) {
472
  }
473
 
474
  /**
475
- * Handles avatar uploading.
476
  *
477
- * The functions starts off by checking that the file has been uploaded properly using bp_core_check_avatar_upload().
478
- * It then checks that the file size is within limits, and that it has an accepted file extension (jpg, gif, png).
479
- * If everything checks out, crop the image and move it to its real location.
 
 
480
  *
481
- * @param array $file The appropriate entry the from $_FILES superglobal.
482
- * @param string $upload_dir_filter A filter to be applied to upload_dir
483
- * @return bool Success/failure
484
  * @see bp_core_check_avatar_upload()
485
  * @see bp_core_check_avatar_type()
 
 
 
 
486
  */
487
  function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
488
 
@@ -598,7 +683,7 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
598
  }
599
 
600
  /**
601
- * Crop an uploaded avatar
602
  *
603
  * $args has the following parameters:
604
  * object - What component the avatar is for, e.g. "user"
@@ -610,8 +695,23 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
610
  * crop_x - The horizontal starting point of the crop
611
  * crop_y - The vertical starting point of the crop
612
  *
613
- * @param mixed $args
614
- * @return bool Success/failure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
615
  */
616
  function bp_core_avatar_handle_crop( $args = '' ) {
617
 
@@ -690,18 +790,16 @@ function bp_core_avatar_handle_crop( $args = '' ) {
690
  }
691
 
692
  /**
693
- * bp_core_fetch_avatar_filter()
694
  *
695
- * Attempts to filter get_avatar function and let BuddyPress have a go
696
- * at finding an avatar that may have been uploaded locally.
697
  *
698
- * @global array $authordata
699
- * @param string $avatar The result of get_avatar from before-filter
700
- * @param int|string|object $user A user ID, email address, or comment object
701
- * @param int $size Size of the avatar image (thumb/full)
702
- * @param string $default URL to a default image to use if no avatar is available
703
- * @param string $alt Alternate text to use in image tag. Defaults to blank
704
- * @return string
705
  */
706
  function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = '' ) {
707
  global $pagenow;
@@ -733,8 +831,21 @@ function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = ''
733
  $alt = sprintf( __( 'Avatar of %s', 'buddypress' ), bp_core_get_user_displayname( $id ) );
734
  }
735
 
 
 
 
 
 
 
 
736
  // Let BuddyPress handle the fetching of the avatar
737
- $bp_avatar = bp_core_fetch_avatar( array( 'item_id' => $id, 'width' => $size, 'height' => $size, 'alt' => $alt ) );
 
 
 
 
 
 
738
 
739
  // If BuddyPress found an avatar, use it. If not, use the result of get_avatar
740
  return ( !$bp_avatar ) ? $avatar : $bp_avatar;
@@ -742,10 +853,10 @@ function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = ''
742
  add_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );
743
 
744
  /**
745
- * Has the current avatar upload generated an error?
746
  *
747
- * @param array $file
748
- * @return bool
749
  */
750
  function bp_core_check_avatar_upload( $file ) {
751
  if ( isset( $file['error'] ) && $file['error'] )
@@ -757,8 +868,8 @@ function bp_core_check_avatar_upload( $file ) {
757
  /**
758
  * Is the file size of the current avatar upload permitted?
759
  *
760
- * @param array $file
761
- * @return bool
762
  */
763
  function bp_core_check_avatar_size( $file ) {
764
  if ( $file['file']['size'] > bp_core_avatar_original_max_filesize() )
@@ -772,8 +883,8 @@ function bp_core_check_avatar_size( $file ) {
772
  *
773
  * Permitted file types are JPG, GIF and PNG.
774
  *
775
- * @param string $file
776
- * @return bool
777
  */
778
  function bp_core_check_avatar_type($file) {
779
  if ( ( !empty( $file['file']['type'] ) && !preg_match('/(jpe?g|gif|png)$/i', $file['file']['type'] ) ) || !preg_match( '/(jpe?g|gif|png)$/i', $file['file']['name'] ) )
@@ -783,7 +894,7 @@ function bp_core_check_avatar_type($file) {
783
  }
784
 
785
  /**
786
- * Fetches data from the BP root blog's upload directory.
787
  *
788
  * Handy for multisite instances because all uploads are made on the BP root
789
  * blog and we need to query the BP root blog for the upload directory data.
@@ -791,13 +902,13 @@ function bp_core_check_avatar_type($file) {
791
  * This function ensures that we only need to use {@link switch_to_blog()}
792
  * once to get what we need.
793
  *
794
- * @since BuddyPress (1.8)
795
  *
796
  * @uses wp_upload_dir()
797
  *
798
- * @param string $type The variable we want to return from the $bp->avatars object.
799
- * Only 'upload_path' and 'url' are supported.
800
- * @return string
801
  */
802
  function bp_core_get_upload_dir( $type = 'upload_path' ) {
803
  $bp = buddypress();
@@ -875,35 +986,34 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) {
875
  }
876
 
877
  /**
878
- * bp_core_avatar_upload_path()
879
- *
880
- * Returns the absolute upload path for the WP installation
881
  *
882
  * @uses wp_upload_dir To get upload directory info
883
- * @return string Absolute path to WP upload directory
 
884
  */
885
  function bp_core_avatar_upload_path() {
886
  return apply_filters( 'bp_core_avatar_upload_path', bp_core_get_upload_dir() );
887
  }
888
 
889
  /**
890
- * bp_core_avatar_url()
891
  *
892
- * Returns the raw base URL for root site upload location
893
  *
894
- * @uses wp_upload_dir To get upload directory info
895
- * @return string Full URL to current upload location
896
  */
897
  function bp_core_avatar_url() {
898
  return apply_filters( 'bp_core_avatar_url', bp_core_get_upload_dir( 'url' ) );
899
  }
900
 
901
  /**
902
- * Check if a given user ID has an uploaded avatar
 
 
903
  *
904
- * @since BuddyPress (1.0)
905
- * @param int $user_id
906
- * @return boolean
907
  */
908
  function bp_get_user_has_avatar( $user_id = 0 ) {
909
 
@@ -918,14 +1028,15 @@ function bp_get_user_has_avatar( $user_id = 0 ) {
918
  }
919
 
920
  /**
921
- * Utility function for fetching an avatar dimension setting
922
  *
923
- * @package BuddyPress
924
- * @since BuddyPress (1.5)
925
  *
926
- * @param string $type 'thumb' for thumbs, otherwise full
927
- * @param string $h_or_w 'height' for height, otherwise width
928
- * @return int $dim The dimension
 
 
929
  */
930
  function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
931
  $bp = buddypress();
@@ -935,96 +1046,88 @@ function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
935
  }
936
 
937
  /**
938
- * Get the avatar thumb width setting
939
  *
940
- * @package BuddyPress
941
- * @since BuddyPress (1.5)
942
  *
943
- * @return int The thumb width
944
  */
945
  function bp_core_avatar_thumb_width() {
946
  return apply_filters( 'bp_core_avatar_thumb_width', bp_core_avatar_dimension( 'thumb', 'width' ) );
947
  }
948
 
949
  /**
950
- * Get the avatar thumb height setting
951
  *
952
- * @package BuddyPress
953
- * @since BuddyPress (1.5)
954
  *
955
- * @return int The thumb height
956
  */
957
  function bp_core_avatar_thumb_height() {
958
  return apply_filters( 'bp_core_avatar_thumb_height', bp_core_avatar_dimension( 'thumb', 'height' ) );
959
  }
960
 
961
  /**
962
- * Get the avatar full width setting
963
  *
964
- * @package BuddyPress
965
- * @since BuddyPress (1.5)
966
  *
967
- * @return int The full width
968
  */
969
  function bp_core_avatar_full_width() {
970
  return apply_filters( 'bp_core_avatar_full_width', bp_core_avatar_dimension( 'full', 'width' ) );
971
  }
972
 
973
  /**
974
- * Get the avatar full height setting
975
  *
976
- * @package BuddyPress
977
- * @since BuddyPress (1.5)
978
  *
979
- * @return int The full height
980
  */
981
  function bp_core_avatar_full_height() {
982
  return apply_filters( 'bp_core_avatar_full_height', bp_core_avatar_dimension( 'full', 'height' ) );
983
  }
984
 
985
  /**
986
- * Get the max width for original avatar uploads
987
  *
988
- * @package BuddyPress
989
- * @since BuddyPress (1.5)
990
  *
991
- * @return int The width
992
  */
993
  function bp_core_avatar_original_max_width() {
994
  return apply_filters( 'bp_core_avatar_original_max_width', (int) buddypress()->avatar->original_max_width );
995
  }
996
 
997
  /**
998
- * Get the max filesize for original avatar uploads
999
  *
1000
- * @package BuddyPress
1001
- * @since BuddyPress (1.5)
1002
  *
1003
- * @return int The filesize
1004
  */
1005
  function bp_core_avatar_original_max_filesize() {
1006
  return apply_filters( 'bp_core_avatar_original_max_filesize', (int) buddypress()->avatar->original_max_filesize );
1007
  }
1008
 
1009
  /**
1010
- * Get the default avatar
1011
  *
1012
- * @package BuddyPress
1013
- * @since BuddyPress (1.5)
1014
  *
1015
- * @return int The URL of the default avatar
1016
  */
1017
  function bp_core_avatar_default() {
1018
  return apply_filters( 'bp_core_avatar_default', buddypress()->avatar->full->default );
1019
  }
1020
 
1021
  /**
1022
- * Get the default avatar thumb
1023
  *
1024
- * @package BuddyPress
1025
- * @since BuddyPress (1.5)
1026
  *
1027
- * @return int The URL of the default avatar thumb
1028
  */
1029
  function bp_core_avatar_default_thumb() {
1030
  return apply_filters( 'bp_core_avatar_thumb', buddypress()->avatar->thumb->default );
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Avatars.
5
  */
6
 
7
  // Exit if accessed directly
8
  if ( !defined( 'ABSPATH' ) ) exit;
9
 
10
  /***
11
+ * Set up the constants we need for avatar support.
12
  */
13
  function bp_core_set_avatar_constants() {
14
 
50
  }
51
  add_action( 'bp_init', 'bp_core_set_avatar_constants', 3 );
52
 
53
+ /**
54
+ * Set up global variables related to avatars.
55
+ *
56
+ * @since BuddyPress (1.5.0)
57
+ */
58
  function bp_core_set_avatar_globals() {
59
  $bp = buddypress();
60
 
97
  add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
98
 
99
  /**
100
+ * Get an avatar for a BuddyPress object.
101
+ *
102
+ * Supports avatars for users, groups, and blogs by default, but can be
103
+ * extended to support custom components as well.
104
  *
105
+ * This function gives precedence to locally-uploaded avatars. When a local
106
+ * avatar is not found, Gravatar is queried. To disable Gravatar fallbacks
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 = '' ) {
183
 
482
  }
483
 
484
  /**
485
+ * Delete an existing avatar.
 
 
 
 
 
486
  *
487
+ * @param array $args {
488
+ * Array of function parameters.
489
+ * @type bool|int $item_id ID of the item whose avatar you're deleting.
490
+ * Defaults to the current item of type $object.
491
+ * @type string $object Object type of the item whose avatar you're
492
+ * deleting. 'user', 'group', 'blog', or custom. Default: 'user'.
493
+ * @type bool|string $avatar_dir Subdirectory where avatar is located.
494
+ * Default: false, which falls back on the default location
495
+ * corresponding to the $object.
496
+ * }
497
+ * @return bool True on success, false on failure.
498
  */
499
  function bp_core_delete_existing_avatar( $args = '' ) {
500
 
554
  }
555
 
556
  /**
557
+ * Handle avatar uploading.
558
  *
559
+ * The functions starts off by checking that the file has been uploaded
560
+ * properly using bp_core_check_avatar_upload(). It then checks that the file
561
+ * size is within limits, and that it has an accepted file extension (jpg, gif,
562
+ * png). If everything checks out, crop the image and move it to its real
563
+ * location.
564
  *
 
 
 
565
  * @see bp_core_check_avatar_upload()
566
  * @see bp_core_check_avatar_type()
567
+ *
568
+ * @param array $file The appropriate entry the from $_FILES superglobal.
569
+ * @param string $upload_dir_filter A filter to be applied to 'upload_dir'.
570
+ * @return bool True on success, false on failure.
571
  */
572
  function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
573
 
683
  }
684
 
685
  /**
686
+ * Crop an uploaded avatar.
687
  *
688
  * $args has the following parameters:
689
  * object - What component the avatar is for, e.g. "user"
695
  * crop_x - The horizontal starting point of the crop
696
  * crop_y - The vertical starting point of the crop
697
  *
698
+ * @param array $args {
699
+ * Array of function parameters.
700
+ * @type string $object Object type of the item whose avatar you're
701
+ * handling. 'user', 'group', 'blog', or custom. Default: 'user'.
702
+ * @type string $avatar_dir Subdirectory where avatar should be stored.
703
+ * Default: 'avatars'.
704
+ * @type bool|int $item_id ID of the item that the avatar belongs to.
705
+ * @type bool|string $original_file Absolute papth to the original avatar
706
+ * file.
707
+ * @type int $crop_w Crop width. Default: the global 'full' avatar width,
708
+ * as retrieved by bp_core_avatar_full_width().
709
+ * @type int $crop_h Crop height. Default: the global 'full' avatar height,
710
+ * as retrieved by bp_core_avatar_full_height().
711
+ * @type int $crop_x The horizontal starting point of the crop. Default: 0.
712
+ * @type int $crop_y The vertical starting point of the crop. Default: 0.
713
+ * }
714
+ * @return bool True on success, false on failure.
715
  */
716
  function bp_core_avatar_handle_crop( $args = '' ) {
717
 
790
  }
791
 
792
  /**
793
+ * Replace default WordPress avatars with BP avatars, if available.
794
  *
795
+ * Filters 'get_avatar'.
 
796
  *
797
+ * @param string $avatar The avatar path passed to 'get_avatar'.
798
+ * @param int|string|object $user A user ID, email address, or comment object.
799
+ * @param int $size Size of the avatar image ('thumb' or 'full').
800
+ * @param string $default URL to a default image to use if no avatar is available.
801
+ * @param string $alt Alternate text to use in image tag. Default: ''.
802
+ * @return string BP avatar path, if found; else the original avatar path.
 
803
  */
804
  function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = '' ) {
805
  global $pagenow;
831
  $alt = sprintf( __( 'Avatar of %s', 'buddypress' ), bp_core_get_user_displayname( $id ) );
832
  }
833
 
834
+ // Use the 'thumb' type, unless the requested width is bigger than
835
+ // BP's thumb width.
836
+ $type = 'thumb';
837
+ if ( (int) $size > bp_core_avatar_thumb_width() ) {
838
+ $type = 'full';
839
+ }
840
+
841
  // Let BuddyPress handle the fetching of the avatar
842
+ $bp_avatar = bp_core_fetch_avatar( array(
843
+ 'item_id' => $id,
844
+ 'type' => $type,
845
+ 'width' => $size,
846
+ 'height' => $size,
847
+ 'alt' => $alt,
848
+ ) );
849
 
850
  // If BuddyPress found an avatar, use it. If not, use the result of get_avatar
851
  return ( !$bp_avatar ) ? $avatar : $bp_avatar;
853
  add_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );
854
 
855
  /**
856
+ * Is the current avatar upload error-free?
857
  *
858
+ * @param array $file The $_FILES array.
859
+ * @return bool True if no errors are found. False if there are errors.
860
  */
861
  function bp_core_check_avatar_upload( $file ) {
862
  if ( isset( $file['error'] ) && $file['error'] )
868
  /**
869
  * Is the file size of the current avatar upload permitted?
870
  *
871
+ * @param array $file The $_FILES array.
872
+ * @return bool True if the avatar is under the size limit, otherwise false.
873
  */
874
  function bp_core_check_avatar_size( $file ) {
875
  if ( $file['file']['size'] > bp_core_avatar_original_max_filesize() )
883
  *
884
  * Permitted file types are JPG, GIF and PNG.
885
  *
886
+ * @param array $file The $_FILES array.
887
+ * @return bool True if the file extension is permitted, otherwise false.
888
  */
889
  function bp_core_check_avatar_type($file) {
890
  if ( ( !empty( $file['file']['type'] ) && !preg_match('/(jpe?g|gif|png)$/i', $file['file']['type'] ) ) || !preg_match( '/(jpe?g|gif|png)$/i', $file['file']['name'] ) )
894
  }
895
 
896
  /**
897
+ * Fetch data from the BP root blog's upload directory.
898
  *
899
  * Handy for multisite instances because all uploads are made on the BP root
900
  * blog and we need to query the BP root blog for the upload directory data.
902
  * This function ensures that we only need to use {@link switch_to_blog()}
903
  * once to get what we need.
904
  *
905
+ * @since BuddyPress (1.8.0)
906
  *
907
  * @uses wp_upload_dir()
908
  *
909
+ * @param string $type The variable we want to return from the $bp->avatars
910
+ * object. Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
911
+ * @return string The avatar upload directory path.
912
  */
913
  function bp_core_get_upload_dir( $type = 'upload_path' ) {
914
  $bp = buddypress();
986
  }
987
 
988
  /**
989
+ * Get the absolute upload path for the WP installation.
 
 
990
  *
991
  * @uses wp_upload_dir To get upload directory info
992
+ *
993
+ * @return string Absolute path to WP upload directory.
994
  */
995
  function bp_core_avatar_upload_path() {
996
  return apply_filters( 'bp_core_avatar_upload_path', bp_core_get_upload_dir() );
997
  }
998
 
999
  /**
1000
+ * Get the raw base URL for root site upload location.
1001
  *
1002
+ * @uses wp_upload_dir To get upload directory info.
1003
  *
1004
+ * @return string Full URL to current upload location.
 
1005
  */
1006
  function bp_core_avatar_url() {
1007
  return apply_filters( 'bp_core_avatar_url', bp_core_get_upload_dir( 'url' ) );
1008
  }
1009
 
1010
  /**
1011
+ * Check if a given user ID has an uploaded avatar.
1012
+ *
1013
+ * @since BuddyPress (1.0.0)
1014
  *
1015
+ * @param int $user_id ID of the user whose avatar is being checked.
1016
+ * @return bool True if the user has uploaded a local avatar. Otherwise false.
 
1017
  */
1018
  function bp_get_user_has_avatar( $user_id = 0 ) {
1019
 
1028
  }
1029
 
1030
  /**
1031
+ * Utility function for fetching an avatar dimension setting.
1032
  *
1033
+ * @since BuddyPress (1.5.0)
 
1034
  *
1035
+ * @param string $type Dimension type you're fetching dimensions for. 'thumb'
1036
+ * or 'full'. Default: 'thumb'.
1037
+ * @param string $h_or_w Which dimension is being fetched. 'height' or 'width'.
1038
+ * Default: 'height'.
1039
+ * @return int $dim The dimension.
1040
  */
1041
  function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
1042
  $bp = buddypress();
1046
  }
1047
 
1048
  /**
1049
+ * Get the 'thumb' avatar width setting.
1050
  *
1051
+ * @since BuddyPress (1.5.0)
 
1052
  *
1053
+ * @return int The 'thumb' width.
1054
  */
1055
  function bp_core_avatar_thumb_width() {
1056
  return apply_filters( 'bp_core_avatar_thumb_width', bp_core_avatar_dimension( 'thumb', 'width' ) );
1057
  }
1058
 
1059
  /**
1060
+ * Get the 'thumb' avatar height setting.
1061
  *
1062
+ * @since BuddyPress (1.5.0)
 
1063
  *
1064
+ * @return int The 'thumb' height.
1065
  */
1066
  function bp_core_avatar_thumb_height() {
1067
  return apply_filters( 'bp_core_avatar_thumb_height', bp_core_avatar_dimension( 'thumb', 'height' ) );
1068
  }
1069
 
1070
  /**
1071
+ * Get the 'full' avatar width setting
1072
  *
1073
+ * @since BuddyPress (1.5.0)
 
1074
  *
1075
+ * @return int The 'full' width.
1076
  */
1077
  function bp_core_avatar_full_width() {
1078
  return apply_filters( 'bp_core_avatar_full_width', bp_core_avatar_dimension( 'full', 'width' ) );
1079
  }
1080
 
1081
  /**
1082
+ * Get the 'full' avatar height setting.
1083
  *
1084
+ * @since BuddyPress (1.5.0)
 
1085
  *
1086
+ * @return int The 'full' height.
1087
  */
1088
  function bp_core_avatar_full_height() {
1089
  return apply_filters( 'bp_core_avatar_full_height', bp_core_avatar_dimension( 'full', 'height' ) );
1090
  }
1091
 
1092
  /**
1093
+ * Get the max width for original avatar uploads.
1094
  *
1095
+ * @since BuddyPress (1.5.0)
 
1096
  *
1097
+ * @return int The max width for original avatar uploads.
1098
  */
1099
  function bp_core_avatar_original_max_width() {
1100
  return apply_filters( 'bp_core_avatar_original_max_width', (int) buddypress()->avatar->original_max_width );
1101
  }
1102
 
1103
  /**
1104
+ * Get the max filesize for original avatar uploads.
1105
  *
1106
+ * @since BuddyPress (1.5.0)
 
1107
  *
1108
+ * @return int The max filesize for original avatar uploads.
1109
  */
1110
  function bp_core_avatar_original_max_filesize() {
1111
  return apply_filters( 'bp_core_avatar_original_max_filesize', (int) buddypress()->avatar->original_max_filesize );
1112
  }
1113
 
1114
  /**
1115
+ * Get the URL of the 'full' default avatar.
1116
  *
1117
+ * @since BuddyPress (1.5.0)
 
1118
  *
1119
+ * @return string The URL of the default avatar.
1120
  */
1121
  function bp_core_avatar_default() {
1122
  return apply_filters( 'bp_core_avatar_default', buddypress()->avatar->full->default );
1123
  }
1124
 
1125
  /**
1126
+ * Get the URL of the 'thumb' default avatar.
1127
  *
1128
+ * @since BuddyPress (1.5.0)
 
1129
  *
1130
+ * @return string The URL of the default avatar thumb.
1131
  */
1132
  function bp_core_avatar_default_thumb() {
1133
  return apply_filters( 'bp_core_avatar_thumb', buddypress()->avatar->thumb->default );
bp-core/bp-core-buddybar.php CHANGED
@@ -1,21 +1,41 @@
1
  <?php
2
 
3
  /**
4
- * Core BuddyPress Navigational Functions
5
  *
6
  * @package BuddyPress
7
  * @subpackage Core
8
- * @todo Deprecate BuddyBar functions
9
  */
10
 
11
  // Exit if accessed directly
12
  if ( !defined( 'ABSPATH' ) ) exit;
13
 
14
  /**
15
- * Adds a navigation item to the main navigation array used in BuddyPress themes.
16
  *
17
- * @package BuddyPress Core
18
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  */
20
  function bp_core_new_nav_item( $args = '' ) {
21
  global $bp;
@@ -97,10 +117,17 @@ function bp_core_new_nav_item( $args = '' ) {
97
  }
98
 
99
  /**
100
- * Modify the default subnav item to load when a top level nav item is clicked.
101
  *
102
- * @package BuddyPress Core
103
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
 
 
 
 
104
  */
105
  function bp_core_new_nav_default( $args = '' ) {
106
  global $bp;
@@ -163,11 +190,14 @@ function bp_core_new_nav_default( $args = '' ) {
163
  }
164
 
165
  /**
166
- * We can only sort nav items by their position integer at a later point in time, once all
167
- * plugins have registered their navigation items.
 
 
168
  *
169
- * @package BuddyPress Core
170
  * @global BuddyPress $bp The one true BuddyPress instance
 
 
171
  */
172
  function bp_core_sort_nav_items() {
173
  global $bp;
@@ -197,10 +227,34 @@ add_action( 'wp_head', 'bp_core_sort_nav_items' );
197
  add_action( 'admin_head', 'bp_core_sort_nav_items' );
198
 
199
  /**
200
- * Adds a navigation item to the sub navigation array used in BuddyPress themes.
201
  *
202
- * @package BuddyPress Core
203
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  */
205
  function bp_core_new_subnav_item( $args = '' ) {
206
  global $bp;
@@ -318,6 +372,13 @@ function bp_core_new_subnav_item( $args = '' ) {
318
  }
319
  }
320
 
 
 
 
 
 
 
 
321
  function bp_core_sort_subnav_items() {
322
  global $bp;
323
 
@@ -349,13 +410,14 @@ add_action( 'wp_head', 'bp_core_sort_subnav_items' );
349
  add_action( 'admin_head', 'bp_core_sort_subnav_items' );
350
 
351
  /**
352
- * Determines whether a given nav item has subnav items
353
  *
354
- * @package BuddyPress
355
- * @since BuddyPress (1.5)
356
  *
357
- * @param string $nav_item The id of the top-level nav item whose nav items you're checking
358
- * @return bool $has_subnav True if the nav item is found and has subnav items; false otherwise
 
 
359
  */
360
  function bp_nav_item_has_subnav( $nav_item = '' ) {
361
  global $bp;
@@ -369,11 +431,10 @@ function bp_nav_item_has_subnav( $nav_item = '' ) {
369
  }
370
 
371
  /**
372
- * Removes a navigation item from the sub navigation array used in BuddyPress themes.
373
  *
374
- * @package BuddyPress Core
375
- * @param int $parent_id The id of the parent navigation item.
376
- * @param bool|string false if the parent item doesn't exist or $slug the slug of the sub navigation item.
377
  */
378
  function bp_core_remove_nav_item( $parent_id ) {
379
  global $bp;
@@ -399,11 +460,10 @@ function bp_core_remove_nav_item( $parent_id ) {
399
  }
400
 
401
  /**
402
- * Removes a navigation item from the sub navigation array used in BuddyPress themes.
403
  *
404
- * @package BuddyPress Core
405
- * @param string $parent_id The id of the parent navigation item.
406
- * @param string $slug The slug of the sub navigation item.
407
  */
408
  function bp_core_remove_subnav_item( $parent_id, $slug ) {
409
  global $bp;
@@ -424,11 +484,11 @@ function bp_core_remove_subnav_item( $parent_id, $slug ) {
424
  }
425
 
426
  /**
427
- * Clear the subnav items for a specific nav item.
428
  *
429
- * @package BuddyPress Core
430
- * @param string $parent_id The id of the parent navigation item.
431
- * @global BuddyPress $bp The one true BuddyPress instance
432
  */
433
  function bp_core_reset_subnav_items( $parent_slug ) {
434
  global $bp;
@@ -436,8 +496,13 @@ function bp_core_reset_subnav_items( $parent_slug ) {
436
  unset( $bp->bp_options_nav[$parent_slug] );
437
  }
438
 
439
- /** Template functions ********************************************************/
440
 
 
 
 
 
 
441
  function bp_core_admin_bar() {
442
  global $bp;
443
 
@@ -465,12 +530,20 @@ function bp_core_admin_bar() {
465
  $bp->doing_admin_bar = false;
466
  }
467
 
468
- // **** Default BuddyPress Toolbar logo ********
 
 
469
  function bp_adminbar_logo() {
470
  echo '<a href="' . bp_get_root_domain() . '" id="admin-bar-logo">' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . '</a>';
471
  }
472
 
473
- // **** "Log In" and "Sign Up" links (Visible when not logged in) ********
 
 
 
 
 
 
474
  function bp_adminbar_login_menu() {
475
 
476
  if ( is_user_logged_in() )
@@ -483,8 +556,11 @@ function bp_adminbar_login_menu() {
483
  echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page() . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
484
  }
485
 
486
-
487
- // **** "My Account" Menu ******
 
 
 
488
  function bp_adminbar_account_menu() {
489
  global $bp;
490
 
@@ -557,8 +633,11 @@ function bp_adminbar_thisblog_menu() {
557
  }
558
  }
559
 
560
-
561
- // **** "Random" Menu (visible when not logged in) ********
 
 
 
562
  function bp_adminbar_random_menu() {
563
  ?>
564
 
@@ -592,14 +671,14 @@ function bp_adminbar_random_menu() {
592
  *
593
  * This is a direct copy of WP's private _get_admin_bar_pref()
594
  *
595
- * @since BuddyPress (1.5)
596
- *
597
- * @param string $context Context of this preference check, either 'admin' or 'front'.
598
- * @param int $user Optional. ID of the user to check, defaults to 0 for current user.
599
  *
600
  * @uses get_user_option()
601
  *
602
- * @return bool Whether the Toolbar should be showing for this user.
 
 
 
603
  */
604
  function bp_get_admin_bar_pref( $context, $user = 0 ) {
605
  $pref = get_user_option( "show_admin_bar_{$context}", $user );
@@ -610,7 +689,7 @@ function bp_get_admin_bar_pref( $context, $user = 0 ) {
610
  }
611
 
612
  /**
613
- * Handle the BuddyBar CSS
614
  */
615
  function bp_core_load_buddybar_css() {
616
  global $wp_styles;
1
  <?php
2
 
3
  /**
4
+ * Core BuddyPress Navigational Functions.
5
  *
6
  * @package BuddyPress
7
  * @subpackage Core
8
+ * @todo Deprecate BuddyBar functions.
9
  */
10
 
11
  // Exit if accessed directly
12
  if ( !defined( 'ABSPATH' ) ) exit;
13
 
14
  /**
15
+ * Add an item to the main BuddyPress navigation array.
16
  *
17
+ * @global BuddyPress $bp The one true BuddyPress instance.
18
+ *
19
+ * @param array $args {
20
+ * Array describing the new nav item.
21
+ * @type string $name Display name for the nav item.
22
+ * @type string $slug Unique URL slug for the nav item.
23
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav
24
+ * item. Default: the value of $slug.
25
+ * @type bool $show_for_displayed_user Optional. Whether the nav item
26
+ * should be visible when viewing a member profile other than your
27
+ * own. Default: true.
28
+ * @type bool $site_admin_only Optional. Whether the nav item should be
29
+ * visible only to site admins (those with the 'bp_moderate' cap).
30
+ * Default: false.
31
+ * @type int $position Optional. Numerical index specifying where the item
32
+ * should appear in the nav array. Default: 99.
33
+ * @type callable $screen_function The callback function that will run
34
+ * when the nav item is clicked.
35
+ * @type bool|string $default_subnav_slug Optional. The slug of the default
36
+ * subnav item to select when the nav item is clicked.
37
+ * }
38
+ * @return bool|null Returns false on failure.
39
  */
40
  function bp_core_new_nav_item( $args = '' ) {
41
  global $bp;
117
  }
118
 
119
  /**
120
+ * Modify the default subnav item that loads when a top level nav item is clicked.
121
  *
122
+ * @global BuddyPress $bp The one true BuddyPress instance.
123
+ *
124
+ * @param array $args {
125
+ * @type string $parent_slug The slug of the nav item whose default is
126
+ * being changed.
127
+ * @type callable $screen_function The new default callback function that
128
+ * will run when the nav item is clicked.
129
+ * @type string $subnav_slug The slug of the new default subnav item.
130
+ * }
131
  */
132
  function bp_core_new_nav_default( $args = '' ) {
133
  global $bp;
190
  }
191
 
192
  /**
193
+ * Sort the navigation menu items.
194
+ *
195
+ * The sorting is split into a separate function because it can only happen
196
+ * after all plugins have had a chance to register their navigation items.
197
  *
 
198
  * @global BuddyPress $bp The one true BuddyPress instance
199
+ *
200
+ * @return bool|null Returns false on failure.
201
  */
202
  function bp_core_sort_nav_items() {
203
  global $bp;
227
  add_action( 'admin_head', 'bp_core_sort_nav_items' );
228
 
229
  /**
230
+ * Add a subnav item to the BuddyPress navigation.
231
  *
232
+ * @global BuddyPress $bp The one true BuddyPress instance.
233
+ *
234
+ * @param array $args {
235
+ * Array describing the new subnav item.
236
+ * @type string $name Display name for the subnav item.
237
+ * @type string $slug Unique URL slug for the subnav item.
238
+ * @type string $parent_slug Slug of the top-level nav item under which the
239
+ * new subnav item should be added.
240
+ * @type string $parent_url URL of the parent nav item.
241
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav
242
+ * item. Default: the value of $slug.
243
+ * @type bool $user_has_access Optional. True if the logged-in user has
244
+ * access to the subnav item, otherwise false. Can be set dynamically
245
+ * when registering the subnav; eg, use bp_is_my_profile() to restrict
246
+ * access to profile owners only. Default: true.
247
+ * @type bool $site_admin_only Optional. Whether the nav item should be
248
+ * visible only to site admins (those with the 'bp_moderate' cap).
249
+ * Default: false.
250
+ * @type int $position Optional. Numerical index specifying where the item
251
+ * should appear in the subnav array. Default: 90.
252
+ * @type callable $screen_function The callback function that will run
253
+ * when the nav item is clicked.
254
+ * @type string $link Optional. The URL that the subnav item should point
255
+ * to. Defaults to a value generated from the $parent_url + $slug.
256
+ * }
257
+ * @return bool|null Returns false on failure.
258
  */
259
  function bp_core_new_subnav_item( $args = '' ) {
260
  global $bp;
372
  }
373
  }
374
 
375
+ /**
376
+ * Sort all subnavigation arrays.
377
+ *
378
+ * @global BuddyPress $bp The one true BuddyPress instance
379
+ *
380
+ * @return bool|null Returns false on failure.
381
+ */
382
  function bp_core_sort_subnav_items() {
383
  global $bp;
384
 
410
  add_action( 'admin_head', 'bp_core_sort_subnav_items' );
411
 
412
  /**
413
+ * Check whether a given nav item has subnav items.
414
  *
415
+ * @since BuddyPress (1.5.0)
 
416
  *
417
+ * @param string $nav_item The slug of the top-level nav item whose subnav
418
+ * items you're checking. Default: the current component slug.
419
+ * @return bool $has_subnav True if the nav item is found and has subnav
420
+ * items; false otherwise.
421
  */
422
  function bp_nav_item_has_subnav( $nav_item = '' ) {
423
  global $bp;
431
  }
432
 
433
  /**
434
+ * Remove a nav item from the navigation array.
435
  *
436
+ * @param int $parent_id The slug of the parent navigation item.
437
+ * @param bool Returns false on failure, ie if the nav item can't be found.
 
438
  */
439
  function bp_core_remove_nav_item( $parent_id ) {
440
  global $bp;
460
  }
461
 
462
  /**
463
+ * Remove a subnav item from the navigation array.
464
  *
465
+ * @param string $parent_id The slug of the parent navigation item.
466
+ * @param string $slug The slug of the subnav item to be removed.
 
467
  */
468
  function bp_core_remove_subnav_item( $parent_id, $slug ) {
469
  global $bp;
484
  }
485
 
486
  /**
487
+ * Clear all subnav items from a specific nav item.
488
  *
489
+ * @global BuddyPress $bp The one true BuddyPress instance.
490
+ *
491
+ * @param string $parent_slug The slug of the parent navigation item.
492
  */
493
  function bp_core_reset_subnav_items( $parent_slug ) {
494
  global $bp;
496
  unset( $bp->bp_options_nav[$parent_slug] );
497
  }
498
 
499
+ /** BuddyBar Template functions ***********************************************/
500
 
501
+ /**
502
+ * Wrapper function for rendering the BuddyBar.
503
+ *
504
+ * @return bool|null Returns false if the BuddyBar is disabled.
505
+ */
506
  function bp_core_admin_bar() {
507
  global $bp;
508
 
530
  $bp->doing_admin_bar = false;
531
  }
532
 
533
+ /**
534
+ * Output the BuddyBar logo.
535
+ */
536
  function bp_adminbar_logo() {
537
  echo '<a href="' . bp_get_root_domain() . '" id="admin-bar-logo">' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . '</a>';
538
  }
539
 
540
+ /**
541
+ * Output the "Log In" and "Sign Up" names to the BuddyBar.
542
+ *
543
+ * Visible only to visitors who are not logged in.
544
+ *
545
+ * @return bool|null Returns false if the current user is logged in.
546
+ */
547
  function bp_adminbar_login_menu() {
548
 
549
  if ( is_user_logged_in() )
556
  echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page() . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
557
  }
558
 
559
+ /**
560
+ * Output the My Account BuddyBar menu.
561
+ *
562
+ * @return bool|null Returns false on failure.
563
+ */
564
  function bp_adminbar_account_menu() {
565
  global $bp;
566
 
633
  }
634
  }
635
 
636
+ /**
637
+ * Output the Random BuddyBar menu.
638
+ *
639
+ * Not visible for logged-in users.
640
+ */
641
  function bp_adminbar_random_menu() {
642
  ?>
643
 
671
  *
672
  * This is a direct copy of WP's private _get_admin_bar_pref()
673
  *
674
+ * @since BuddyPress (1.5.0)
 
 
 
675
  *
676
  * @uses get_user_option()
677
  *
678
+ * @param string $context Context of this preference check. 'admin' or 'front'.
679
+ * @param int $user Optional. ID of the user to check. Default: 0 (which falls
680
+ * back to the logged-in user's ID).
681
+ * @return bool True if the toolbar should be showing for this user.
682
  */
683
  function bp_get_admin_bar_pref( $context, $user = 0 ) {
684
  $pref = get_user_option( "show_admin_bar_{$context}", $user );
689
  }
690
 
691
  /**
692
+ * Enqueue the BuddyBar CSS.
693
  */
694
  function bp_core_load_buddybar_css() {
695
  global $wp_styles;
bp-core/bp-core-cache.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
  /**
 
 
3
  * Caching functions handle the clearing of cached objects and pages on specific
4
  * actions throughout BuddyPress.
5
  */
@@ -8,12 +10,12 @@
8
  if ( !defined( 'ABSPATH' ) ) exit;
9
 
10
  /**
11
- * REQUIRES WP-SUPER-CACHE
 
 
12
  *
13
  * When wp-super-cache is installed this function will clear cached pages
14
  * so that success/error messages are not cached, or time sensitive content.
15
- *
16
- * @package BuddyPress Core
17
  */
18
  function bp_core_clear_cache() {
19
  global $cache_path;
@@ -25,9 +27,7 @@ function bp_core_clear_cache() {
25
  }
26
 
27
  /**
28
- * Add's 'bp' to global group of network wide cachable objects
29
- *
30
- * @package BuddyPress Core
31
  */
32
  function bp_core_add_global_group() {
33
  if ( function_exists( 'wp_cache_add_global_groups' ) ) {
@@ -37,16 +37,14 @@ function bp_core_add_global_group() {
37
  add_action( 'bp_loaded', 'bp_core_add_global_group' );
38
 
39
  /**
40
- * Clears all cached objects for a user, or a user is part of.
41
- *
42
- * @package BuddyPress Core
43
  */
44
  function bp_core_clear_user_object_cache( $user_id ) {
45
  wp_cache_delete( 'bp_user_' . $user_id, 'bp' );
46
  }
47
 
48
  /**
49
- * Clears member count caches and transients
50
  */
51
  function bp_core_clear_member_count_caches() {
52
  wp_cache_delete( 'bp_total_member_count', 'bp' );
@@ -61,10 +59,29 @@ add_action( 'deleted_user', 'bp_core_clear_member_count_caches
61
  /**
62
  * Update the metadata cache for the specified objects.
63
  *
64
- * @since BuddyPress (1.6)
65
- * @global $wpdb WordPress database object for queries.
66
- * @param array $args See $defaults definition for more details
67
- * @return mixed Metadata cache for the specified objects, or false on failure.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  */
69
  function bp_update_meta_cache( $args = array() ) {
70
  global $wpdb;
1
  <?php
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
  */
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
+ * Prune the WP Super Cache.
14
+ *
15
+ * @see prune_super_cache()
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;
27
  }
28
 
29
  /**
30
+ * Add 'bp' to global group of network wide cachable objects.
 
 
31
  */
32
  function bp_core_add_global_group() {
33
  if ( function_exists( 'wp_cache_add_global_groups' ) ) {
37
  add_action( 'bp_loaded', 'bp_core_add_global_group' );
38
 
39
  /**
40
+ * Clear all cached objects for a user, or those that a user is part of.
 
 
41
  */
42
  function bp_core_clear_user_object_cache( $user_id ) {
43
  wp_cache_delete( 'bp_user_' . $user_id, 'bp' );
44
  }
45
 
46
  /**
47
+ * Clear member count caches and transients.
48
  */
49
  function bp_core_clear_member_count_caches() {
50
  wp_cache_delete( 'bp_total_member_count', 'bp' );
59
  /**
60
  * Update the metadata cache for the specified objects.
61
  *
62
+ * Based on WordPress's {@link update_meta_cache()}, this function primes the
63
+ * cache with metadata related to a set of objects. This is typically done when
64
+ * querying for a loop of objects; pre-fetching metadata for each queried
65
+ * object can lead to dramatic performance improvements when using metadata
66
+ * in the context of template loops.
67
+ *
68
+ * @since BuddyPress (1.6.0)
69
+ *
70
+ * @global $wpdb WordPress database object for queries..
71
+ *
72
+ * @param array $args {
73
+ * Array of arguments.
74
+ * @type array|string $object_ids List of object IDs to fetch metadata for.
75
+ * Accepts an array or a comma-separated list of numeric IDs.
76
+ * @type string $object_type The type of object, eg 'groups' or 'activity'.
77
+ * @type string $meta_table The name of the metadata table being queried.
78
+ * @type string $object_column Optional. The name of the database column
79
+ * where IDs (those provided by $object_ids) are found. Eg, 'group_id'
80
+ * for the groups metadata tables. Default: $object_type . '_id'.
81
+ * @type string $cache_key_prefix Optional. The prefix to use when creating
82
+ * cache key names. Default: the value of $meta_table.
83
+ * }
84
+ * @return array|bool Metadata cache for the specified objects, or false on failure.
85
  */
86
  function bp_update_meta_cache( $args = array() ) {
87
  global $wpdb;
bp-core/bp-core-caps.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Capabilites
5
  *
6
  * @package BuddyPress
7
  * @subpackage Capabilities
@@ -11,15 +11,15 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Adds capabilities to WordPress user roles.
15
  *
16
  * This is called on plugin activation.
17
  *
18
- * @since BuddyPress (1.6)
19
  *
20
- * @uses get_role() To get the administrator, default and moderator roles
21
- * @uses WP_Role::add_cap() To add various capabilities
22
- * @uses do_action() Calls 'bp_add_caps'
23
  */
24
  function bp_add_caps() {
25
  global $wp_roles;
@@ -39,15 +39,15 @@ function bp_add_caps() {
39
  }
40
 
41
  /**
42
- * Removes capabilities from WordPress user roles.
43
  *
44
  * This is called on plugin deactivation.
45
  *
46
- * @since BuddyPress (1.6)
47
  *
48
- * @uses get_role() To get the administrator and default roles
49
- * @uses WP_Role::remove_cap() To remove various capabilities
50
- * @uses do_action() Calls 'bp_remove_caps'
51
  */
52
  function bp_remove_caps() {
53
  global $wp_roles;
@@ -67,31 +67,35 @@ function bp_remove_caps() {
67
  }
68
 
69
  /**
70
- * Maps community caps to built in WordPress caps
71
- *
72
- * @since BuddyPress (1.6)
73
- *
74
- * @param array $caps Capabilities for meta capability
75
- * @param string $cap Capability name
76
- * @param int $user_id User id
77
- * @param mixed $args Arguments
78
- * @uses get_post() To get the post
79
- * @uses get_post_type_object() To get the post type object
80
- * @uses apply_filters() Calls 'bp_map_meta_caps' with caps, cap, user id and
81
- * args
82
- * @return array Actual capabilities for meta capability
 
 
 
83
  */
84
  function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
85
  return apply_filters( 'bp_map_meta_caps', $caps, $cap, $user_id, $args );
86
  }
87
 
88
  /**
89
- * Return community capabilities
90
  *
91
- * @since BuddyPress (1.6)
92
  *
93
- * @uses apply_filters() Calls 'bp_get_community_caps' with the capabilities
94
- * @return array Forum capabilities
 
95
  */
96
  function bp_get_community_caps() {
97
 
@@ -102,14 +106,14 @@ function bp_get_community_caps() {
102
  }
103
 
104
  /**
105
- * Returns an array of capabilities based on the role that is being requested.
106
  *
107
- * @since BuddyPress (1.6)
108
  *
109
- * @param string $role Optional. Defaults to The role to load caps for
110
- * @uses apply_filters() Allow return value to be filtered
111
  *
112
- * @return array Capabilities for $role
 
113
  */
114
  function bp_get_caps_for_role( $role = '' ) {
115
 
@@ -138,12 +142,14 @@ function bp_get_caps_for_role( $role = '' ) {
138
  }
139
 
140
  /**
141
- * Give a user the default 'Forum Participant' role when creating a topic/reply
142
- * on a site they do not have a role or capability on.
143
  *
144
- * @since BuddyPress (1.6)
 
145
  *
146
- * @global BuddyPress $bp
 
 
147
  *
148
  * @uses is_multisite()
149
  * @uses bp_allow_global_access()
@@ -171,14 +177,15 @@ function bp_set_current_user_default_role() {
171
  }
172
 
173
  /**
174
- * Whether current user has a capability or role. Can be passed blog ID, or will
175
- * use the root blod by default
176
  *
177
- * @since BuddyPress (1.6)
 
 
178
  *
179
  * @param string $capability Capability or role name.
180
- * @param int $blog_id Blog ID
181
- * @return bool
182
  */
183
  function bp_current_user_can( $capability, $blog_id = 0 ) {
184
 
@@ -192,27 +199,31 @@ function bp_current_user_can( $capability, $blog_id = 0 ) {
192
  }
193
 
194
  /**
195
- * Temporary implementation of 'bp_moderate' cap
196
  *
197
- * In BuddyPress 1.6, the 'bp_moderate' cap was introduced. In order to enforce that
198
- * bp_current_user_can( 'bp_moderate' ) always returns true for Administrators, we must manually
199
- * add the 'bp_moderate' cap to the list of user caps for Admins.
 
200
  *
201
- * Note that this level of enforcement is only necessary in the case of non-Multisite. This is
202
- * because WordPress automatically assigns every capability - and thus 'bp_moderate' - to Super
203
- * Admins on a Multisite installation. See WP_User::has_cap().
 
204
  *
205
- * This implementation of 'bp_moderate' is temporary, until BuddyPress properly matches caps to
206
- * roles and stores them in the database. Plugin authors: Do not use this function.
 
207
  *
208
- * @since BuddyPress (1.6)
209
- * @see WP_User::has_cap()
210
  * @access private
 
 
 
211
  *
212
- * @param array $allcaps The caps that WP associates with the given role
213
- * @param array $caps The caps being tested for in WP_User::has_cap()
214
- * @param array $args Miscellaneous arguments passed to the user_has_cap filter
215
- * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant
216
  */
217
  function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
218
 
@@ -240,9 +251,8 @@ add_filter( 'map_meta_cap', '_bp_enforce_bp_moderate_cap_for_admins', 10, 4 );
240
  *
241
  * This is called on plugin activation.
242
  *
243
- * @since BuddyPress (1.6)
244
- *
245
- * @deprecated since version 1.7
246
  */
247
  function bp_add_roles() {
248
  _doing_it_wrong( 'bp_add_roles', __( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
@@ -253,9 +263,8 @@ function bp_add_roles() {
253
  *
254
  * This is called on plugin deactivation.
255
  *
256
- * @since BuddyPress (1.6)
257
- *
258
- * @deprecated since version 1.7
259
  */
260
  function bp_remove_roles() {
261
  _doing_it_wrong( 'bp_remove_roles', __( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
@@ -263,25 +272,23 @@ function bp_remove_roles() {
263
 
264
 
265
  /**
266
- * The participant role for registered users without roles
267
  *
268
  * This is primarily for multisite compatibility when users without roles on
269
- * sites that have global communities enabled
270
  *
271
  * @since BuddyPress (1.6)
272
- *
273
- * @deprecated since version 1.7
274
  */
275
  function bp_get_participant_role() {
276
  _doing_it_wrong( 'bp_get_participant_role', __( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
277
  }
278
 
279
  /**
280
- * The moderator role for BuddyPress users
281
- *
282
- * @since BuddyPress (1.6)
283
  *
284
- * @deprecated since version 1.7
 
285
  */
286
  function bp_get_moderator_role() {
287
  _doing_it_wrong( 'bp_get_moderator_role', __( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Capabilites.
5
  *
6
  * @package BuddyPress
7
  * @subpackage Capabilities
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
+ * Add capabilities to WordPress user roles.
15
  *
16
  * This is called on plugin activation.
17
  *
18
+ * @since BuddyPress (1.6.0)
19
  *
20
+ * @uses get_role() To get the administrator, default and moderator roles.
21
+ * @uses WP_Role::add_cap() To add various capabilities.
22
+ * @uses do_action() Calls 'bp_add_caps'.
23
  */
24
  function bp_add_caps() {
25
  global $wp_roles;
39
  }
40
 
41
  /**
42
+ * Remove capabilities from WordPress user roles.
43
  *
44
  * This is called on plugin deactivation.
45
  *
46
+ * @since BuddyPress (1.6.0)
47
  *
48
+ * @uses get_role() To get the administrator and default roles.
49
+ * @uses WP_Role::remove_cap() To remove various capabilities.
50
+ * @uses do_action() Calls 'bp_remove_caps'.
51
  */
52
  function bp_remove_caps() {
53
  global $wp_roles;
67
  }
68
 
69
  /**
70
+ * Map community caps to built in WordPress caps.
71
+ *
72
+ * @since BuddyPress (1.6.0)
73
+ *
74
+ * @see WP_User::has_cap() for description of the arguments passed to the
75
+ * 'map_meta_cap' filter.
76
+ * @uses get_post() To get the post.
77
+ * @uses get_post_type_object() To get the post type object.
78
+ * @uses apply_filters() Calls 'bp_map_meta_caps' with caps, cap, user ID and
79
+ * args.
80
+ *
81
+ * @param array $caps See {@link WP_User::has_cap()}.
82
+ * @param string $cap See {@link WP_User::has_cap()}.
83
+ * @param int $user_id See {@link WP_User::has_cap()}.
84
+ * @param mixed $args See {@link WP_User::has_cap()}.
85
+ * @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}.
86
  */
87
  function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
88
  return apply_filters( 'bp_map_meta_caps', $caps, $cap, $user_id, $args );
89
  }
90
 
91
  /**
92
+ * Return community capabilities.
93
  *
94
+ * @since BuddyPress (1.6.0)
95
  *
96
+ * @uses apply_filters() Calls 'bp_get_community_caps' with the capabilities.
97
+ *
98
+ * @return array Community capabilities.
99
  */
100
  function bp_get_community_caps() {
101
 
106
  }
107
 
108
  /**
109
+ * Return an array of capabilities based on the role that is being requested.
110
  *
111
+ * @since BuddyPress (1.6.0)
112
  *
113
+ * @uses apply_filters() Allow return value to be filtered.
 
114
  *
115
+ * @param string $role The role for which you're loading caps.
116
+ * @return array Capabilities for $role.
117
  */
118
  function bp_get_caps_for_role( $role = '' ) {
119
 
142
  }
143
 
144
  /**
145
+ * Set a default role for the current user.
 
146
  *
147
+ * Give a user the default role when creating content on a site they do not
148
+ * already have a role or capability on.
149
  *
150
+ * @since BuddyPress (1.6.0)
151
+ *
152
+ * @global BuddyPress $bp Global BuddyPress settings object.
153
  *
154
  * @uses is_multisite()
155
  * @uses bp_allow_global_access()
177
  }
178
 
179
  /**
180
+ * Check whether the current user has a given capability.
 
181
  *
182
+ * Can be passed blog ID, or will use the root blog by default.
183
+ *
184
+ * @since BuddyPress (1.6.0)
185
  *
186
  * @param string $capability Capability or role name.
187
+ * @param int $blog_id Optional. Blog ID. Defaults to the BP root blog.
188
+ * @return bool True if the user has the cap for the given blog.
189
  */
190
  function bp_current_user_can( $capability, $blog_id = 0 ) {
191
 
199
  }
200
 
201
  /**
202
+ * Temporary implementation of 'bp_moderate' cap.
203
  *
204
+ * In BuddyPress 1.6, the 'bp_moderate' cap was introduced. In order to
205
+ * enforce that bp_current_user_can( 'bp_moderate' ) always returns true for
206
+ * Administrators, we must manually add the 'bp_moderate' cap to the list of
207
+ * user caps for Admins.
208
  *
209
+ * Note that this level of enforcement is only necessary in the case of
210
+ * non-Multisite. This is because WordPress automatically assigns every
211
+ * capability - and thus 'bp_moderate' - to Super Admins on a Multisite
212
+ * installation. See {@link WP_User::has_cap()}.
213
  *
214
+ * This implementation of 'bp_moderate' is temporary, until BuddyPress properly
215
+ * matches caps to roles and stores them in the database. Plugin authors: Do
216
+ * not use this function.
217
  *
 
 
218
  * @access private
219
+ * @since BuddyPress (1.6.0)
220
+ *
221
+ * @see WP_User::has_cap()
222
  *
223
+ * @param array $allcaps The caps that WP associates with the given role.
224
+ * @param array $caps The caps being tested for in WP_User::has_cap().
225
+ * @param array $args Miscellaneous arguments passed to the user_has_cap filter.
226
+ * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
227
  */
228
  function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
229
 
251
  *
252
  * This is called on plugin activation.
253
  *
254
+ * @since BuddyPress (1.6.0)
255
+ * @deprecated 1.7.0
 
256
  */
257
  function bp_add_roles() {
258
  _doing_it_wrong( 'bp_add_roles', __( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
263
  *
264
  * This is called on plugin deactivation.
265
  *
266
+ * @since BuddyPress (1.6.0)
267
+ * @deprecated 1.7.0
 
268
  */
269
  function bp_remove_roles() {
270
  _doing_it_wrong( 'bp_remove_roles', __( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
272
 
273
 
274
  /**
275
+ * The participant role for registered users without roles.
276
  *
277
  * This is primarily for multisite compatibility when users without roles on
278
+ * sites that have global communities enabled.
279
  *
280
  * @since BuddyPress (1.6)
281
+ * @deprecated 1.7.0
 
282
  */
283
  function bp_get_participant_role() {
284
  _doing_it_wrong( 'bp_get_participant_role', __( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
285
  }
286
 
287
  /**
288
+ * The moderator role for BuddyPress users.
 
 
289
  *
290
+ * @since BuddyPress (1.6.0)
291
+ * @deprecated 1.7.0
292
  */
293
  function bp_get_moderator_role() {
294
  _doing_it_wrong( 'bp_get_moderator_role', __( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
bp-core/bp-core-catchuri.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress URI catcher
5
  *
6
  * Functions for parsing the URI and determining which BuddyPress template file
7
  * to use on-screen.
@@ -14,12 +14,13 @@
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
  /**
17
- * Analyzes the URI structure and breaks it down into parts for use in code.
18
- * BuddyPress can use complete custom friendly URI's without the user having to
19
- * add new re-write rules. Custom components are able to use their own custom
 
20
  * URI structures with very little work.
21
  *
22
- * The URI's are broken down as follows:
23
  * - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
24
  * - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
25
  *
@@ -29,8 +30,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
29
  * - $bp->current_action: string 'edit'
30
  * - $bp->action_variables: array ['group', 5]
31
  *
32
- * @package BuddyPress Core
33
- * @since BuddyPress (1.0)
34
  */
35
  function bp_core_set_uri_globals() {
36
  global $bp, $current_blog, $wp_rewrite;
@@ -210,10 +210,6 @@ function bp_core_set_uri_globals() {
210
  $matches[] = 1;
211
  $match = $bp->pages->members;
212
  $match->key = 'members';
213
-
214
- // Without the 'members' URL chunk, WordPress won't know which page to load
215
- // This filter intercepts the WP query and tells it to load the members page
216
- add_filter( 'request', create_function( '$query_args', '$query_args["pagename"] = "' . $match->name . '"; return $query_args;' ) );
217
  }
218
  }
219
 
@@ -316,10 +312,11 @@ function bp_core_set_uri_globals() {
316
  }
317
 
318
  /**
319
- * Are root profiles enabled and allowed
 
 
320
  *
321
- * @since BuddyPress (1.6)
322
- * @return bool True if yes, false if no
323
  */
324
  function bp_core_enable_root_profiles() {
325
 
@@ -339,9 +336,8 @@ function bp_core_enable_root_profiles() {
339
  * Loads:
340
  * wp-content/themes/[activated_theme]/members/index.php
341
  *
342
- * @package BuddyPress Core
343
- * @param string $username Username to check.
344
- * @return int|bool The user ID of the matched user, or false.
345
  */
346
  function bp_core_load_template( $templates ) {
347
  global $post, $bp, $wp_query, $wpdb;
@@ -364,7 +360,7 @@ function bp_core_load_template( $templates ) {
364
 
365
  // Make the queried/post object an actual valid page
366
  if ( !empty( $object_id ) ) {
367
- $wp_query->queried_object = &get_post( $object_id );
368
  $wp_query->queried_object_id = $object_id;
369
  $post = $wp_query->queried_object;
370
  }
@@ -383,7 +379,7 @@ function bp_core_load_template( $templates ) {
383
  status_header( 200 );
384
  $wp_query->is_page = true;
385
  $wp_query->is_singular = true;
386
- $wp_query->is_404 = false;
387
 
388
  do_action( 'bp_core_pre_load_template', $located_template );
389
 
@@ -404,7 +400,7 @@ function bp_core_load_template( $templates ) {
404
  status_header( 200 );
405
  $wp_query->is_page = true;
406
  $wp_query->is_singular = true;
407
- $wp_query->is_404 = false;
408
  }
409
 
410
  do_action( 'bp_setup_theme_compat' );
@@ -412,11 +408,7 @@ function bp_core_load_template( $templates ) {
412
  }
413
 
414
  /**
415
- * bp_core_catch_profile_uri()
416
- *
417
- * If the extended profiles component is not installed we still need
418
- * to catch the /profile URI's and display whatever we have installed.
419
- *
420
  */
421
  function bp_core_catch_profile_uri() {
422
  if ( !bp_is_active( 'xprofile' ) ) {
@@ -425,10 +417,9 @@ function bp_core_catch_profile_uri() {
425
  }
426
 
427
  /**
428
- * Catches invalid access to BuddyPress pages and redirects them accordingly.
429
  *
430
- * @package BuddyPress Core
431
- * @since BuddyPress (1.5)
432
  */
433
  function bp_core_catch_no_access() {
434
  global $bp, $wp_query;
@@ -445,12 +436,26 @@ function bp_core_catch_no_access() {
445
  add_action( 'bp_template_redirect', 'bp_core_catch_no_access', 1 );
446
 
447
  /**
448
- * Redirects a user to login for BP pages that require access control and adds an error message (if
449
- * one is provided).
 
 
450
  * If authenticated, redirects user back to requested content by default.
451
  *
452
- * @package BuddyPress Core
453
- * @since BuddyPress (1.5)
 
 
 
 
 
 
 
 
 
 
 
 
454
  */
455
  function bp_core_no_access( $args = '' ) {
456
 
@@ -512,12 +517,13 @@ function bp_core_no_access( $args = '' ) {
512
  }
513
 
514
  /**
515
- * Adds an error message to wp-login.php.
 
516
  * Hooks into the "bpnoaccess" action defined in bp_core_no_access().
517
  *
518
- * @package BuddyPress Core
519
- * @global $error
520
- * @since BuddyPress (1.5)
521
  */
522
  function bp_core_no_access_wp_login_error() {
523
  global $error;
@@ -530,17 +536,19 @@ function bp_core_no_access_wp_login_error() {
530
  add_action( 'login_form_bpnoaccess', 'bp_core_no_access_wp_login_error' );
531
 
532
  /**
533
- * Canonicalizes BuddyPress URLs
534
  *
535
- * This function ensures that requests for BuddyPress content are always redirected to their
536
- * canonical versions. Canonical versions are always trailingslashed, and are typically the most
537
- * general possible versions of the URL - eg, example.com/groups/mygroup/ instead of
538
- * example.com/groups/mygroup/home/
 
539
  *
540
- * @since BuddyPress (1.6)
541
- * @see BP_Members_Component::setup_globals() where $bp->canonical_stack['base_url'] and
542
- * ['component'] may be set
543
- * @see bp_core_new_nav_item() where $bp->canonical_stack['action'] may be set
 
544
  * @uses bp_get_canonical_url()
545
  * @uses bp_get_requested_url()
546
  */
@@ -588,9 +596,9 @@ function bp_redirect_canonical() {
588
  }
589
 
590
  /**
591
- * Output rel=canonical header tag for BuddyPress content
592
  *
593
- * @since BuddyPress (1.6)
594
  */
595
  function bp_rel_canonical() {
596
  $canonical_url = bp_get_canonical_url();
@@ -600,12 +608,18 @@ function bp_rel_canonical() {
600
  }
601
 
602
  /**
603
- * Returns the canonical URL of the current page
 
 
 
 
604
  *
605
- * @since BuddyPress (1.6)
606
- * @uses apply_filters() Filter bp_get_canonical_url to modify return value
607
- * @param array $args
608
- * @return string
 
 
609
  */
610
  function bp_get_canonical_url( $args = array() ) {
611
  global $bp;
@@ -621,6 +635,27 @@ function bp_get_canonical_url( $args = array() ) {
621
  $r = wp_parse_args( $args, $defaults );
622
  extract( $r );
623
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
624
  if ( empty( $bp->canonical_stack['canonical_url'] ) ) {
625
  // Build the URL in the address bar
626
  $requested_url = bp_get_requested_url();
@@ -654,17 +689,19 @@ function bp_get_canonical_url( $args = array() ) {
654
  $canonical_url = $bp->canonical_stack['canonical_url'];
655
 
656
  if ( !$include_query_args ) {
657
- $canonical_url = array_pop( array_reverse( explode( '?', $canonical_url ) ) );
 
658
  }
659
 
660
  return apply_filters( 'bp_get_canonical_url', $canonical_url, $args );
661
  }
662
 
663
  /**
664
- * Returns the URL as requested on the current page load by the user agent
 
 
665
  *
666
- * @since BuddyPress (1.6)
667
- * @return string
668
  */
669
  function bp_get_requested_url() {
670
  global $bp;
@@ -678,14 +715,16 @@ function bp_get_requested_url() {
678
  }
679
 
680
  /**
681
- * Remove WordPress's really awesome canonical redirect if we are trying to load
682
- * BuddyPress specific content. Avoids issues with WordPress thinking that a
683
- * BuddyPress URL might actually be a blog post or page.
 
684
  *
685
  * This function should be considered temporary, and may be removed without
686
  * notice in future versions of BuddyPress.
687
  *
688
- * @since BuddyPress (1.6)
 
689
  * @uses bp_is_blog_page()
690
  */
691
  function _bp_maybe_remove_redirect_canonical() {
@@ -695,7 +734,7 @@ function _bp_maybe_remove_redirect_canonical() {
695
  add_action( 'bp_init', '_bp_maybe_remove_redirect_canonical' );
696
 
697
  /**
698
- * Rehook maybe_redirect_404() to run later than the default
699
  *
700
  * WordPress's maybe_redirect_404() allows admins on a multisite installation
701
  * to define 'NOBLOGREDIRECT', a URL to which 404 requests will be redirected.
@@ -730,13 +769,12 @@ function _bp_rehook_maybe_redirect_404() {
730
  add_action( 'template_redirect', '_bp_rehook_maybe_redirect_404', 1 );
731
 
732
  /**
733
- * Remove WordPress's rel=canonical HTML tag if we are trying to load BuddyPress
734
- * specific content.
735
  *
736
  * This function should be considered temporary, and may be removed without
737
  * notice in future versions of BuddyPress.
738
  *
739
- * @since BuddyPress (1.6)
740
  */
741
  function _bp_maybe_remove_rel_canonical() {
742
  if ( ! bp_is_blog_page() && ! is_404() ) {
1
  <?php
2
 
3
  /**
4
+ * BuddyPress URI catcher.
5
  *
6
  * Functions for parsing the URI and determining which BuddyPress template file
7
  * to use on-screen.
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
  /**
17
+ * Analyze the URI and break it down into BuddyPress-usable chunks.
18
+ *
19
+ * BuddyPress can use complete custom friendly URIs without the user having to
20
+ * add new rewrite rules. Custom components are able to use their own custom
21
  * URI structures with very little work.
22
  *
23
+ * The URIs are broken down as follows:
24
  * - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
25
  * - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
26
  *
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 $bp, $current_blog, $wp_rewrite;
210
  $matches[] = 1;
211
  $match = $bp->pages->members;
212
  $match->key = 'members';
 
 
 
 
213
  }
214
  }
215
 
312
  }
313
 
314
  /**
315
+ * Are root profiles enabled and allowed?
316
+ *
317
+ * @since BuddyPress (1.6.0)
318
  *
319
+ * @return bool True if yes, false if no.
 
320
  */
321
  function bp_core_enable_root_profiles() {
322
 
336
  * Loads:
337
  * wp-content/themes/[activated_theme]/members/index.php
338
  *
339
+ * @param array $templates Array of templates to attempt to load.
340
+ * @return bool|null Returns false on failure.
 
341
  */
342
  function bp_core_load_template( $templates ) {
343
  global $post, $bp, $wp_query, $wpdb;
360
 
361
  // Make the queried/post object an actual valid page
362
  if ( !empty( $object_id ) ) {
363
+ $wp_query->queried_object = get_post( $object_id );
364
  $wp_query->queried_object_id = $object_id;
365
  $post = $wp_query->queried_object;
366
  }
379
  status_header( 200 );
380
  $wp_query->is_page = true;
381
  $wp_query->is_singular = true;
382
+ $wp_query->is_404 = false;
383
 
384
  do_action( 'bp_core_pre_load_template', $located_template );
385
 
400
  status_header( 200 );
401
  $wp_query->is_page = true;
402
  $wp_query->is_singular = true;
403
+ $wp_query->is_404 = false;
404
  }
405
 
406
  do_action( 'bp_setup_theme_compat' );
408
  }
409
 
410
  /**
411
+ * Redirect away from /profile URIs if XProfile is not enabled.
 
 
 
 
412
  */
413
  function bp_core_catch_profile_uri() {
414
  if ( !bp_is_active( 'xprofile' ) ) {
417
  }
418
 
419
  /**
420
+ * Catch unauthorized access to certain BuddyPress pages and redirect accordingly.
421
  *
422
+ * @since BuddyPress (1.5.0)
 
423
  */
424
  function bp_core_catch_no_access() {
425
  global $bp, $wp_query;
436
  add_action( 'bp_template_redirect', 'bp_core_catch_no_access', 1 );
437
 
438
  /**
439
+ * Redirect a user to log in for BP pages that require access control.
440
+ *
441
+ * Add an error message (if one is provided).
442
+ *
443
  * If authenticated, redirects user back to requested content by default.
444
  *
445
+ * @since BuddyPress (1.5.0)
446
+ *
447
+ * @param array $args {
448
+ * @type int $mode Specifies the destintation of the redirect. 1 will
449
+ * direct to the root domain (home page), which assumes you have a
450
+ * log-in form there; 2 directs to wp-login.php. Default: 2.
451
+ * @type string $redirect The URL the user will be redirected to after
452
+ * successfully logging in. Default: the URL originally requested.
453
+ * @type string $root The root URL of the site, used in case of error or
454
+ * mode 1 redirects. Default: the value of {@link bp_get_root_domain()}.
455
+ * @type string $message An error message to display to the user on the
456
+ * log-in page. Default: "You must log in to access the page you
457
+ * requested."
458
+ * }
459
  */
460
  function bp_core_no_access( $args = '' ) {
461
 
517
  }
518
 
519
  /**
520
+ * Add an error message to wp-login.php.
521
+ *
522
  * Hooks into the "bpnoaccess" action defined in bp_core_no_access().
523
  *
524
+ * @since BuddyPress (1.5.0)
525
+ *
526
+ * @global $error Error message to pass to wp-login.php
527
  */
528
  function bp_core_no_access_wp_login_error() {
529
  global $error;
536
  add_action( 'login_form_bpnoaccess', 'bp_core_no_access_wp_login_error' );
537
 
538
  /**
539
+ * Canonicalize BuddyPress URLs.
540
  *
541
+ * This function ensures that requests for BuddyPress content are always
542
+ * redirected to their canonical versions. Canonical versions are always
543
+ * trailingslashed, and are typically the most general possible versions of the
544
+ * URL - eg, example.com/groups/mygroup/ instead of
545
+ * example.com/groups/mygroup/home/.
546
  *
547
+ * @since BuddyPress (1.6.0)
548
+ *
549
+ * @see BP_Members_Component::setup_globals() where
550
+ * $bp->canonical_stack['base_url'] and ['component'] may be set.
551
+ * @see bp_core_new_nav_item() where $bp->canonical_stack['action'] may be set.
552
  * @uses bp_get_canonical_url()
553
  * @uses bp_get_requested_url()
554
  */
596
  }
597
 
598
  /**
599
+ * Output rel=canonical header tag for BuddyPress content.
600
  *
601
+ * @since BuddyPress (1.6.0)
602
  */
603
  function bp_rel_canonical() {
604
  $canonical_url = bp_get_canonical_url();
608
  }
609
 
610
  /**
611
+ * Get the canonical URL of the current page.
612
+ *
613
+ * @since BuddyPress (1.6.0)
614
+ *
615
+ * @uses apply_filters() Filter bp_get_canonical_url to modify return value.
616
  *
617
+ * @param array $args {
618
+ * Optional array of arguments.
619
+ * @type bool $include_query_args Whether to include current URL arguments
620
+ * in the canonical URL returned from the function.
621
+ * }
622
+ * @return string Canonical URL for the current page.
623
  */
624
  function bp_get_canonical_url( $args = array() ) {
625
  global $bp;
635
  $r = wp_parse_args( $args, $defaults );
636
  extract( $r );
637
 
638
+ // Special case: when a BuddyPress directory (eg example.com/members)
639
+ // is set to be the front page, ensure that the current canonical URL
640
+ // is the home page URL.
641
+ if ( 'page' == get_option( 'show_on_front' ) && $page_on_front = (int) get_option( 'page_on_front' ) ) {
642
+ $front_page_component = array_search( $page_on_front, bp_core_get_directory_page_ids() );
643
+
644
+ // If requesting the front page component directory, canonical
645
+ // URL is the front page. We detect whether we're detecting a
646
+ // component *directory* by checking that bp_current_action()
647
+ // is empty - ie, this not a single item or a feed
648
+ if ( false !== $front_page_component && bp_is_current_component( $front_page_component ) && ! bp_current_action() ) {
649
+ $bp->canonical_stack['canonical_url'] = trailingslashit( bp_get_root_domain() );
650
+
651
+ // Except when the front page is set to the registration page
652
+ // and the current user is logged in. In this case we send to
653
+ // the members directory to avoid redirect loops
654
+ } else if ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
655
+ $bp->canonical_stack['canonical_url'] = apply_filters( 'bp_loggedin_register_page_redirect_to', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
656
+ }
657
+ }
658
+
659
  if ( empty( $bp->canonical_stack['canonical_url'] ) ) {
660
  // Build the URL in the address bar
661
  $requested_url = bp_get_requested_url();
689
  $canonical_url = $bp->canonical_stack['canonical_url'];
690
 
691
  if ( !$include_query_args ) {
692
+ $canonical_url = array_reverse( explode( '?', $canonical_url ) );
693
+ $canonical_url = array_pop( $canonical_url );
694
  }
695
 
696
  return apply_filters( 'bp_get_canonical_url', $canonical_url, $args );
697
  }
698
 
699
  /**
700
+ * Return the URL as requested on the current page load by the user agent.
701
+ *
702
+ * @since BuddyPress (1.6.0)
703
  *
704
+ * @return string Requested URL string.
 
705
  */
706
  function bp_get_requested_url() {
707
  global $bp;
715
  }
716
 
717
  /**
718
+ * Remove WP's canonical redirect when we are trying to load BP-specific content.
719
+ *
720
+ * Avoids issues with WordPress thinking that a BuddyPress URL might actually
721
+ * be a blog post or page.
722
  *
723
  * This function should be considered temporary, and may be removed without
724
  * notice in future versions of BuddyPress.
725
  *
726
+ * @since BuddyPress (1.6.0)
727
+ *
728
  * @uses bp_is_blog_page()
729
  */
730
  function _bp_maybe_remove_redirect_canonical() {
734
  add_action( 'bp_init', '_bp_maybe_remove_redirect_canonical' );
735
 
736
  /**
737
+ * Rehook maybe_redirect_404() to run later than the default.
738
  *
739
  * WordPress's maybe_redirect_404() allows admins on a multisite installation
740
  * to define 'NOBLOGREDIRECT', a URL to which 404 requests will be redirected.
769
  add_action( 'template_redirect', '_bp_rehook_maybe_redirect_404', 1 );
770
 
771
  /**
772
+ * Remove WP's rel=canonical HTML tag if we are trying to load BP-specific content.
 
773
  *
774
  * This function should be considered temporary, and may be removed without
775
  * notice in future versions of BuddyPress.
776
  *
777
+ * @since BuddyPress (1.6.0)
778
  */
779
  function _bp_maybe_remove_rel_canonical() {
780
  if ( ! bp_is_blog_page() && ! is_404() ) {
bp-core/bp-core-classes.php CHANGED
@@ -1,108 +1,121 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  // Exit if accessed directly
4
  if ( !defined( 'ABSPATH' ) ) exit;
5
 
6
  /**
7
- * BuddyPress User Query class
8
  *
9
  * Used for querying users in a BuddyPress context, in situations where
10
  * WP_User_Query won't do the trick: Member directories, the Friends component,
11
  * etc.
12
  *
13
- * Accepted parameters:
14
- * type - Determines sort order. Select from 'newest', 'active',
15
- * 'online', 'random', 'popular', 'alphabetical'
16
- * per_page - Number of results to return
17
- * page - Page offset (together with per_page)
18
- * user_id - Pass a single numeric user id to limit results to
19
- * friends of that user. Requires the Friends component
20
- * search_terms - Terms to search by. Search happens across xprofile
21
- * fields. Requires XProfile component
22
- * include - An array or comma-separated list of user ids. Results
23
- * will be limited to users in this list
24
- * exclude - An array or comma-separated list of user ids. Results
25
- * will not include any users in this list
26
- * user_ids - An array or comma-separated list of user ids. When
27
- * this parameter is passed, it will override all other
28
- * parameters; BP User objects will be constructed using
29
- * these IDs only
30
- * meta_key - Limit results to users that have usermeta associated
31
- * with this meta_key. Usually used with meta_value
32
- * meta_value - When used with meta_key, limits results to users whose
33
- * usermeta value associated with meta_key matches
34
- * meta_value
35
- * populate_extras - Boolean. True if you want to fetch extra metadata about
36
- * returned users, such as total group and friend counts
37
- * count_total - Determines how BP_User_Query will do a count of total
38
- * users matching the other filter criteria. Default value
39
- * is 'count_query', which does a separate SELECT COUNT
40
- * query to determine the total. 'sql_count_found_rows'
41
- * uses SQL_COUNT_FOUND_ROWS and SELECT FOUND_ROWS(). Pass
42
- * an empty string to skip the total user count query.
43
  *
44
- * @since BuddyPress (1.7)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  */
46
  class BP_User_Query {
47
 
48
  /** Variables *************************************************************/
49
 
50
  /**
51
- * Unaltered params as passed to the constructor
52
  *
53
- * @since BuddyPress (1.8)
54
  * @var array
55
  */
56
  public $query_vars_raw = array();
57
 
58
  /**
59
- * Array of variables to query with
60
  *
61
- * @since BuddyPress (1.7)
62
  * @var array
63
  */
64
  public $query_vars = array();
65
 
66
  /**
67
- * List of found users and their respective data
68
  *
69
- * @since BuddyPress (1.7)
70
- * @access public To allow components to manipulate them
71
  * @var array
72
  */
73
  public $results = array();
74
 
75
  /**
76
- * Total number of found users for the current query
77
  *
78
- * @since BuddyPress (1.7)
79
- * @access public To allow components to manipulate it
80
  * @var int
81
  */
82
  public $total_users = 0;
83
 
84
  /**
85
- * List of found user ID's
86
  *
87
- * @since BuddyPress (1.7)
88
- * @access public To allow components to manipulate it
89
  * @var array
90
  */
91
  public $user_ids = array();
92
 
93
  /**
94
- * SQL clauses for the user ID query
95
  *
96
- * @since BuddyPress (1.7)
97
- * @access public To allow components to manipulate it
98
- * @var array()
99
  */
100
  public $uid_clauses = array();
101
 
102
  /**
103
- * SQL database column name to order by
104
  *
105
- * @since BuddyPress (1.7)
106
  * @var string
107
  */
108
  public $uid_name = '';
@@ -110,8 +123,8 @@ class BP_User_Query {
110
  /**
111
  * Standard response when the query should not return any rows.
112
  *
113
- * @since BuddyPress (1.7)
114
  * @access protected
 
115
  * @var string
116
  */
117
  protected $no_results = array( 'join' => '', 'where' => '0 = 1' );
@@ -120,11 +133,11 @@ class BP_User_Query {
120
  /** Methods ***************************************************************/
121
 
122
  /**
123
- * Constructor
124
  *
125
- * @since BuddyPress (1.7)
126
  *
127
- * @param string|array $query The query variables
128
  */
129
  public function __construct( $query = null ) {
130
 
@@ -177,7 +190,7 @@ class BP_User_Query {
177
  }
178
 
179
  /**
180
- * Allow extending classes to set up action/filter hooks
181
  *
182
  * When extending BP_User_Query, you may need to use some of its
183
  * internal hooks to modify the output. It's not convenient to call
@@ -186,16 +199,16 @@ class BP_User_Query {
186
  * you may not want to override in your class. Define this method in
187
  * your own class if you need a place where your extending class can
188
  * add its hooks early in the query-building process. See
189
- * BP_Group_Member_Query::setup_hooks() for an example.
190
  *
191
- * @since BuddyPress (1.8)
192
  */
193
  public function setup_hooks() {}
194
 
195
  /**
196
- * Prepare the query for user_ids
197
  *
198
- * @since BuddyPress (1.7)
199
  */
200
  public function prepare_user_ids_query() {
201
  global $wpdb, $bp;
@@ -396,12 +409,14 @@ class BP_User_Query {
396
  }
397
 
398
  /**
 
 
399
  * Perform a database query to specifically get only user IDs, using
400
  * existing query variables set previously in the constructor.
401
  *
402
  * Also used to quickly perform user total counts.
403
  *
404
- * @since BuddyPress (1.7)
405
  */
406
  public function do_user_ids_query() {
407
  global $wpdb;
@@ -424,10 +439,9 @@ class BP_User_Query {
424
  }
425
 
426
  /**
427
- * Perform a database query using the WP_User_Query() object, using existing
428
- * fields, variables, and user ID's set previously in this class.
429
  *
430
- * @since BuddyPress (1.7)
431
  */
432
  public function do_wp_user_query() {
433
  $wp_user_query = new WP_User_Query( apply_filters( 'bp_wp_user_query_args', array(
@@ -461,20 +475,21 @@ class BP_User_Query {
461
  }
462
 
463
  /**
464
- * Fetches the ids of users to put in the IN clause of the main query
465
  *
466
  * By default, returns the value passed to it
467
  * ($this->query_vars['include']). Having this abstracted into a
468
  * standalone method means that extending classes can override the
469
  * logic, parsing together their own user_id limits with the 'include'
470
- * ids passed to the class constructor. See BP_Group_Member_Query for
471
- * an example.
 
 
472
  *
473
- * @since BuddyPress (1.8)
474
- * @param array Sanitized array of user ids, as passed to the 'include'
475
- * parameter of the class constructor
476
  * @return array The list of users to which the main query should be
477
- * limited
478
  */
479
  public function get_include_ids( $include = array() ) {
480
  return $include;
@@ -482,14 +497,14 @@ class BP_User_Query {
482
 
483
  /**
484
  * Perform a database query to populate any extra metadata we might need.
 
485
  * Different components will hook into the 'bp_user_query_populate_extras'
486
  * action to loop in the things they want.
487
  *
488
- * @since BuddyPress (1.7)
489
  *
490
- * @global BuddyPress $bp
491
- * @global WPDB $wpdb
492
- * @return
493
  */
494
  public function populate_extras() {
495
  global $wpdb;
@@ -599,6 +614,8 @@ class BP_User_Query {
599
  }
600
 
601
  /**
 
 
602
  * BP_Core_User class can be used by any component. It will fetch useful
603
  * details for any user when provided with a user_id.
604
  *
@@ -608,8 +625,6 @@ class BP_User_Query {
608
  * $user_email = $user->email;
609
  * $user_status = $user->status;
610
  * etc.
611
- *
612
- * @package BuddyPress Core
613
  */
614
  class BP_Core_User {
615
 
@@ -618,56 +633,56 @@ class BP_Core_User {
618
  *
619
  * @var integer
620
  */
621
- var $id;
622
 
623
  /**
624
  * The URL to the full size of the avatar for the user.
625
  *
626
  * @var string
627
  */
628
- var $avatar;
629
 
630
  /**
631
  * The URL to the thumb size of the avatar for the user.
632
  *
633
  * @var string
634
  */
635
- var $avatar_thumb;
636
 
637
  /**
638
  * The URL to the mini size of the avatar for the user.
639
  *
640
  * @var string
641
  */
642
- var $avatar_mini;
643
 
644
  /**
645
  * The full name of the user
646
  *
647
  * @var string
648
  */
649
- var $fullname;
650
 
651
  /**
652
  * The email for the user.
653
  *
654
  * @var string
655
  */
656
- var $email;
657
 
658
  /**
659
  * The absolute url for the user's profile.
660
  *
661
  * @var string
662
  */
663
- var $user_url;
664
 
665
  /**
666
  * The HTML for the user link, with the link text being the user's full name.
667
  *
668
  * @var string
669
  */
670
- var $user_link;
671
 
672
  /**
673
  * Contains a formatted string when the last time the user was active.
@@ -676,7 +691,7 @@ class BP_Core_User {
676
  *
677
  * @var string
678
  */
679
- var $last_active;
680
 
681
  /* Extras */
682
 
@@ -685,7 +700,7 @@ class BP_Core_User {
685
  *
686
  * @var integer
687
  */
688
- var $total_friends;
689
 
690
  /**
691
  * The total number of blog posts posted by the user
@@ -693,7 +708,7 @@ class BP_Core_User {
693
  * @var integer
694
  * @deprecated No longer used
695
  */
696
- var $total_blogs;
697
 
698
  /**
699
  * The total number of groups the user is a part of.
@@ -702,12 +717,12 @@ class BP_Core_User {
702
  *
703
  * @var string
704
  */
705
- var $total_groups;
706
 
707
  /**
708
  * Profile information for the specific user.
709
  *
710
- * @since BuddyPress (1.2)
711
  * @var array
712
  */
713
  public $profile_data;
@@ -717,10 +732,11 @@ class BP_Core_User {
717
  /**
718
  * Class constructor.
719
  *
720
- * @param integer $user_id The ID for the user
721
- * @param boolean $populate_extras Whether to fetch extra information such as group/friendship counts or not.
 
722
  */
723
- function __construct( $user_id, $populate_extras = false ) {
724
  if ( !empty( $user_id ) ) {
725
  $this->id = $user_id;
726
  $this->populate();
@@ -731,19 +747,22 @@ class BP_Core_User {
731
  }
732
  }
733
 
734
- /** Private Methods *******************************************************/
735
-
736
  /**
737
  * Populate the instantiated class with data based on the User ID provided.
738
  *
739
- * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
740
- * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
741
- * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
742
- * @uses bp_get_user_meta() BP function returns the value of passed usermeta name from usermeta table
 
 
 
 
743
  * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
744
- * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
 
745
  */
746
- function populate() {
747
 
748
  if ( bp_is_active( 'xprofile' ) )
749
  $this->profile_data = $this->get_profile_data();
@@ -770,13 +789,13 @@ class BP_Core_User {
770
  $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Avatar of %s', 'buddypress' ), $this->fullname ) ) );
771
  $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Avatar of %s', 'buddypress' ), $this->fullname ) ) );
772
  $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Avatar of %s', 'buddypress' ), $this->fullname ), 'width' => 30, 'height' => 30 ) );
773
- $this->last_active = bp_core_get_last_activity( bp_get_user_meta( $this->id, 'last_activity', true ), __( 'active %s', 'buddypress' ) );
774
  }
775
 
776
  /**
777
  * Populates extra fields such as group and friendship counts.
778
  */
779
- function populate_extras() {
780
 
781
  if ( bp_is_active( 'friends' ) ) {
782
  $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
@@ -788,13 +807,52 @@ class BP_Core_User {
788
  }
789
  }
790
 
791
- function get_profile_data() {
 
 
 
 
 
 
 
 
792
  return BP_XProfile_ProfileData::get_all_for_user( $this->id );
793
  }
794
 
795
  /** Static Methods ********************************************************/
796
 
797
- function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
798
  global $wpdb, $bp;
799
 
800
  _deprecated_function( __METHOD__, '1.7', 'BP_User_Query' );
@@ -969,19 +1027,22 @@ class BP_Core_User {
969
 
970
 
971
  /**
972
- * Fetches the user details for all the users who username starts with the letter given.
 
 
 
973
  *
974
- * @global BuddyPress $bp The one true BuddyPress instance
975
- * @global wpdb $wpdb WordPress database object
976
  * @param string $letter The letter the users names are to start with.
977
- * @param integer $limit The number of users we wish to retrive.
978
- * @param integer $page The page number we are currently on, used in conjunction with $limit to get the start position for the limit.
979
- * @param boolean $populate_extras Populate extra user fields?
980
- * @param string $exclude Comma-separated IDs of users whose results aren't to be fetched.
 
 
 
981
  * @return mixed False on error, otherwise associative array of results.
982
- * @static
983
  */
984
- function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) {
985
  global $bp, $wpdb;
986
 
987
  $pag_sql = '';
@@ -1036,17 +1097,19 @@ class BP_Core_User {
1036
  }
1037
 
1038
  /**
1039
- * Get details of specific users from the database
1040
  *
1041
- * @global wpdb $wpdb WordPress database object
1042
- * @param array $user_ids The user IDs of the users who we wish to fetch information on.
1043
- * @param integer $limit The limit of results we want.
1044
- * @param integer $page The page we are on for pagination.
1045
- * @param boolean $populate_extras Populate extra user fields?
1046
- * @return array Associative array
1047
- * @static
 
 
1048
  */
1049
- function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {
1050
  global $wpdb;
1051
 
1052
  $pag_sql = '';
@@ -1081,16 +1144,17 @@ class BP_Core_User {
1081
  /**
1082
  * Find users who match on the value of an xprofile data.
1083
  *
1084
- * @global BuddyPress $bp The one true BuddyPress instance
1085
- * @global wpdb $wpdb WordPress database object
1086
- * @param string $search_terms The terms to search the profile table value column for.
 
 
1087
  * @param integer $limit The limit of results we want.
1088
  * @param integer $page The page we are on for pagination.
1089
  * @param boolean $populate_extras Populate extra user fields?
1090
- * @return array Associative array
1091
- * @static
1092
  */
1093
- function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
1094
  global $bp, $wpdb;
1095
 
1096
  $user_ids = array();
@@ -1124,15 +1188,15 @@ class BP_Core_User {
1124
  *
1125
  * Accepts multiple user IDs to fetch data for.
1126
  *
1127
- * @global BuddyPress $bp The one true BuddyPress instance
1128
- * @global wpdb $wpdb WordPress database object
1129
- * @param array $paged_users an array of stdClass containing the users
1130
- * @param string $user_ids the user ids to select information about
1131
- * @param string $type the type of fields we wish to get
 
1132
  * @return mixed False on error, otherwise associative array of results.
1133
- * @static
1134
  */
1135
- function get_user_extras( &$paged_users, &$user_ids, $type = false ) {
1136
  global $bp, $wpdb;
1137
 
1138
  if ( empty( $user_ids ) )
@@ -1210,12 +1274,12 @@ class BP_Core_User {
1210
  /**
1211
  * Get WordPress user details for a specified user.
1212
  *
1213
- * @global wpdb $wpdb WordPress database object
1214
- * @param integer $user_id User ID
1215
- * @return array Associative array
1216
- * @static
1217
  */
1218
- function get_core_userdata( $user_id ) {
1219
  global $wpdb;
1220
 
1221
  if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) )
@@ -1227,12 +1291,13 @@ class BP_Core_User {
1227
 
1228
 
1229
  /**
1230
- * BP_Core_Notification class can be used by any component.
1231
- * It will handle the fetching, saving and deleting of a user notification.
 
1232
  *
1233
  * @package BuddyPress Core
 
1234
  */
1235
-
1236
  class BP_Core_Notification {
1237
 
1238
  /**
@@ -1240,56 +1305,56 @@ class BP_Core_Notification {
1240
  *
1241
  * @var integer
1242
  */
1243
- var $id;
1244
 
1245
  /**
1246
  * The ID to which the notification relates to within the component.
1247
  *
1248
  * @var integer
1249
  */
1250
- var $item_id;
1251
 
1252
  /**
1253
  * The secondary ID to which the notification relates to within the component.
1254
  *
1255
  * @var integer
1256
  */
1257
- var $secondary_item_id = null;
1258
 
1259
  /**
1260
  * The user ID for who the notification is for.
1261
  *
1262
  * @var integer
1263
  */
1264
- var $user_id;
1265
 
1266
  /**
1267
  * The name of the component that the notification is for.
1268
  *
1269
  * @var string
1270
  */
1271
- var $component_name;
1272
 
1273
  /**
1274
  * The action within the component which the notification is related to.
1275
  *
1276
  * @var string
1277
  */
1278
- var $component_action;
1279
 
1280
  /**
1281
  * The date the notification was created.
1282
  *
1283
  * @var string
1284
  */
1285
- var $date_notified;
1286
 
1287
  /**
1288
  * Is the notification new or has it already been read.
1289
  *
1290
  * @var boolean
1291
  */
1292
- var $is_new;
1293
 
1294
  /** Public Methods ********************************************************/
1295
 
@@ -1298,7 +1363,7 @@ class BP_Core_Notification {
1298
  *
1299
  * @param integer $id
1300
  */
1301
- function __construct( $id = 0 ) {
1302
  if ( !empty( $id ) ) {
1303
  $this->id = $id;
1304
  $this->populate();
@@ -1312,7 +1377,7 @@ class BP_Core_Notification {
1312
  * @global wpdb $wpdb WordPress database object
1313
  * @return bool Success or failure
1314
  */
1315
- function save() {
1316
  global $bp, $wpdb;
1317
 
1318
  // Update
@@ -1340,7 +1405,7 @@ class BP_Core_Notification {
1340
  * @global BuddyPress $bp The one true BuddyPress instance
1341
  * @global wpdb $wpdb WordPress database object
1342
  */
1343
- function populate() {
1344
  global $bp, $wpdb;
1345
 
1346
  if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
@@ -1356,7 +1421,7 @@ class BP_Core_Notification {
1356
 
1357
  /** Static Methods ********************************************************/
1358
 
1359
- function check_access( $user_id, $notification_id ) {
1360
  global $wpdb, $bp;
1361
 
1362
  return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );
@@ -1372,7 +1437,7 @@ class BP_Core_Notification {
1372
  * @return array Associative array
1373
  * @static
1374
  */
1375
- function get_all_for_user( $user_id, $status = 'is_new' ) {
1376
  global $bp, $wpdb;
1377
 
1378
  $is_new = ( 'is_new' == $status ) ? ' AND is_new = 1 ' : '';
@@ -1390,7 +1455,7 @@ class BP_Core_Notification {
1390
  * @param string $component_action
1391
  * @static
1392
  */
1393
- function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
1394
  global $bp, $wpdb;
1395
 
1396
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
@@ -1408,7 +1473,7 @@ class BP_Core_Notification {
1408
  * @param integer $secondary_item_id (optional) The secondary item id of the notifications that we wish to use to delete.
1409
  * @static
1410
  */
1411
- function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
1412
  global $bp, $wpdb;
1413
 
1414
  $secondary_item_sql = !empty( $secondary_item_id ) ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) : '';
@@ -1426,7 +1491,7 @@ class BP_Core_Notification {
1426
  * @param string $component_action The action of the component the notification was sent from.
1427
  * @static
1428
  */
1429
- function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
1430
  global $bp, $wpdb;
1431
 
1432
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
@@ -1443,7 +1508,7 @@ class BP_Core_Notification {
1443
  * @param string $secondary_item_id Optional secondary item id that the notifications are to have.
1444
  * @static
1445
  */
1446
- function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
1447
  global $bp, $wpdb;
1448
 
1449
  if ( $component_action )
@@ -1461,40 +1526,51 @@ class BP_Core_Notification {
1461
  }
1462
 
1463
  /**
1464
- * BP_Button
1465
- *
1466
- * API to create BuddyPress buttons
1467
- *
1468
- * component: Which component this button is for
1469
- * must_be_logged_in: Button only appears for logged in users
1470
- * block_self: Button will not appear when viewing your own profile.
1471
- * wrapper: div|span|p|li|false for no wrapper
1472
- * wrapper_id: The DOM ID of the button wrapper
1473
- * wrapper_class: The DOM class of the button wrapper
1474
- * link_href: The destination link of the button
1475
- * link_title: Title of the button
1476
- * link_id: The DOM ID of the button
1477
- * link_class: The DOM class of the button
1478
- * link_rel: The DOM rel of the button
1479
- * link_text: The text of the button
1480
- * contents: The contents of the button
1481
  *
1482
- * @package BuddyPress Core
1483
  * @since BuddyPress (1.2.6)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1484
  */
1485
  class BP_Button {
1486
 
1487
  /** Button properties *****************************************************/
1488
 
1489
  /**
1490
- * The button ID
1491
  *
1492
- * @var integer
1493
  */
1494
  public $id = '';
1495
 
1496
  /**
1497
- * The component name that button belongs to.
1498
  *
1499
  * @var string
1500
  */
@@ -1503,37 +1579,35 @@ class BP_Button {
1503
  /**
1504
  * Does the user need to be logged in to see this button?
1505
  *
1506
- * @var boolean
1507
  */
1508
  public $must_be_logged_in = true;
1509
 
1510
  /**
1511
- * True or false if the button should not be displayed while viewing your
1512
- * own profile.
1513
  *
1514
- * @var boolean
1515
  */
1516
  public $block_self = true;
1517
 
1518
  /** Wrapper ***************************************************************/
1519
 
1520
  /**
1521
- * What type of DOM element to use for a wrapper.
1522
- *
1523
  *
1524
- * @var mixed div|span|p|li, or false for no wrapper
1525
  */
1526
  public $wrapper = 'div';
1527
 
1528
  /**
1529
- * The DOM class of the button wrapper
1530
  *
1531
  * @var string
1532
  */
1533
  public $wrapper_class = '';
1534
 
1535
  /**
1536
- * The DOM ID of the button wrapper
1537
  *
1538
  * @var string
1539
  */
@@ -1542,42 +1616,42 @@ class BP_Button {
1542
  /** Button ****************************************************************/
1543
 
1544
  /**
1545
- * The destination link of the button
1546
  *
1547
  * @var string
1548
  */
1549
  public $link_href = '';
1550
 
1551
  /**
1552
- * The DOM class of the button link
1553
  *
1554
  * @var string
1555
  */
1556
  public $link_class = '';
1557
 
1558
  /**
1559
- * The DOM ID of the button link
1560
  *
1561
  * @var string
1562
  */
1563
  public $link_id = '';
1564
 
1565
  /**
1566
- * The DOM rel value of the button link
1567
  *
1568
  * @var string
1569
  */
1570
  public $link_rel = '';
1571
 
1572
  /**
1573
- * Title of the button link
1574
  *
1575
  * @var string
1576
  */
1577
  public $link_title = '';
1578
 
1579
  /**
1580
- * The contents of the button link
1581
  *
1582
  * @var string
1583
  */
@@ -1590,12 +1664,13 @@ class BP_Button {
1590
  /** Methods ***************************************************************/
1591
 
1592
  /**
1593
- * Builds the button based on class parameters:
1594
  *
1595
  * @since BuddyPress (1.2.6)
1596
  *
1597
- * @param array $args
1598
- * @return bool False if not allowed
 
1599
  */
1600
  public function __construct( $args = '' ) {
1601
 
@@ -1668,18 +1743,18 @@ class BP_Button {
1668
  }
1669
 
1670
  /**
1671
- * Return contents of button
1672
  *
1673
  * @since BuddyPress (1.2.6)
1674
  *
1675
- * @return string
1676
  */
1677
  public function contents() {
1678
  return $this->contents;
1679
  }
1680
 
1681
  /**
1682
- * Output contents of button
1683
  *
1684
  * @since BuddyPress (1.2.6)
1685
  */
@@ -1690,12 +1765,12 @@ class BP_Button {
1690
  }
1691
 
1692
  /**
1693
- * BP_Embed
1694
  *
1695
  * Extends WP_Embed class for use with BuddyPress.
1696
  *
1697
- * @package BuddyPress Core
1698
- * @since BuddyPress (1.5)
1699
  * @see WP_Embed
1700
  */
1701
  class BP_Embed extends WP_Embed {
@@ -1703,9 +1778,9 @@ class BP_Embed extends WP_Embed {
1703
  /**
1704
  * Constructor
1705
  *
1706
- * @global unknown $wp_embed
1707
  */
1708
- function __construct() {
1709
  global $wp_embed;
1710
 
1711
  // Make sure we populate the WP_Embed handlers array.
@@ -1740,9 +1815,12 @@ class BP_Embed extends WP_Embed {
1740
  /**
1741
  * The {@link do_shortcode()} callback function.
1742
  *
1743
- * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
1744
- * Next, checks the URL against the regex of registered {@link WP_oEmbed} providers if oEmbed discovery is false.
1745
- * If none of the regex matches and it's enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()} for oEmbed parsing.
 
 
 
1746
  *
1747
  * @uses wp_parse_args()
1748
  * @uses wp_embed_defaults()
@@ -1754,7 +1832,7 @@ class BP_Embed extends WP_Embed {
1754
  * @param string $url The URL attempting to be embeded.
1755
  * @return string The embed HTML on success, otherwise the original URL.
1756
  */
1757
- function shortcode( $attr, $url = '' ) {
1758
  if ( empty( $url ) )
1759
  return '';
1760
 
@@ -1806,20 +1884,25 @@ class BP_Embed extends WP_Embed {
1806
  }
1807
 
1808
  /**
1809
- * Base function so BP components / plugins can parse links to be embedded.
 
1810
  * View an example to add support in {@link bp_activity_embed()}.
1811
  *
1812
  * @uses apply_filters() Filters cache.
1813
  * @uses do_action() To save cache.
1814
- * @uses wp_oembed_get() Connects to oEmbed provider and returns HTML on success.
1815
- * @uses WP_Embed::maybe_make_link() Process URL for hyperlinking on oEmbed failure.
 
 
 
1816
  * @param int $id ID to do the caching for.
1817
  * @param string $url The URL attempting to be embedded.
1818
  * @param array $attr Shortcode attributes from {@link WP_Embed::shortcode()}.
1819
- * @param array $rawattr Untouched shortcode attributes from {@link WP_Embed::shortcode()}.
 
1820
  * @return string The embed HTML on success, otherwise the original URL.
1821
  */
1822
- function parse_oembed( $id, $url, $attr, $rawattr ) {
1823
  $id = intval( $id );
1824
 
1825
  if ( $id ) {
@@ -1854,19 +1937,24 @@ class BP_Embed extends WP_Embed {
1854
  }
1855
 
1856
  /**
1857
- * Create HTML list of BP nav items
1858
  *
1859
- * @since BuddyPress (1.7)
1860
  */
1861
  class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
 
1862
  /**
1863
- * @since BuddyPress (1.7)
 
 
1864
  * @var array
1865
  */
1866
  var $db_fields = array( 'id' => 'css_id', 'parent' => 'parent' );
1867
 
1868
  /**
1869
- * @since BuddyPress (1.7)
 
 
1870
  * @var string
1871
  */
1872
  var $tree_type = array();
@@ -1874,20 +1962,25 @@ class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
1874
  /**
1875
  * Display array of elements hierarchically.
1876
  *
1877
- * This method is almost identical to the version in {@link Walker::walk()}. The only change is on one line
1878
- * which has been commented. An IF was comparing 0 to a non-empty string which was preventing child elements
 
1879
  * being grouped under their parent menu element.
1880
  *
1881
- * This caused a problem for BuddyPress because our primary/secondary navigations doesn't have a unique numerical
1882
- * ID that describes a hierarchy (we use a slug). Obviously, WordPress Menus use Posts, and those have ID/post_parent.
 
 
 
 
1883
  *
1884
- * @param array $elements
1885
- * @param int $max_depth
1886
- * @return string
1887
  * @see Walker::walk()
1888
- * @since BuddyPress (1.7)
 
 
 
1889
  */
1890
- function walk( $elements, $max_depth ) {
1891
  $args = array_slice( func_get_args(), 2 );
1892
  $output = '';
1893
 
@@ -1965,16 +2058,21 @@ class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
1965
  }
1966
 
1967
  /**
1968
- * Displays the current <li> that we are on.
 
 
 
 
1969
  *
1970
- * @param string $output Passed by reference. Used to append additional content.
 
1971
  * @param object $item Menu item data object.
1972
- * @param int $depth Depth of menu item. Used for padding. Optional, defaults to 0.
1973
- * @param array $args Optional
 
1974
  * @param int $current_page Menu item ID. Optional.
1975
- * @since BuddyPress (1.7)
1976
  */
1977
- function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
1978
  // If we're someway down the tree, indent the HTML with the appropriate number of tabs
1979
  $indent = $depth ? str_repeat( "\t", $depth ) : '';
1980
 
@@ -2004,3 +2102,110 @@ class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
2004
  $output .= apply_filters( 'bp_walker_nav_menu_start_el', $item_output, $item, $depth, $args );
2005
  }
2006
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ /**
3
+ * Core component classes.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Core
7
+ */
8
 
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
+ * BuddyPress User Query class.
14
  *
15
  * Used for querying users in a BuddyPress context, in situations where
16
  * WP_User_Query won't do the trick: Member directories, the Friends component,
17
  * etc.
18
  *
19
+ * @since BuddyPress (1.7.0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  *
21
+ * @param array $query {
22
+ * Query arguments. All items are optional.
23
+ * @type string $type Determines sort order. Select from 'newest', 'active',
24
+ * 'online', 'random', 'popular', 'alphabetical'. Default: 'newest'.
25
+ * @type int $per_page Number of results to return. Default: 0 (no limit).
26
+ * @type int $page Page offset (together with $per_page). Default: 0 (no
27
+ * limit).
28
+ * @type int $user_id ID of a user. If present, and if the friends
29
+ * component is activated, results will be limited to the friends of
30
+ * that user. Default: 0.
31
+ * @type string|bool $search_terms Terms to search by. Search happens
32
+ * across xprofile fields. Requires XProfile component.
33
+ * Default: false.
34
+ * @type array|string|bool $include An array or comma-separated list of
35
+ * user IDs to which query should be limited.
36
+ * Default: false.
37
+ * @type array|string|bool $exclude An array or comma-separated list of
38
+ * user IDs that will be excluded from query results. Default: false.
39
+ * @type array|string|bool $user_ids An array or comma-separated list of
40
+ * IDs corresponding to the users that should be returned. When this
41
+ * parameter is passed, it will override all others; BP User objects
42
+ * will be constructed using these IDs only. Default: false.
43
+ * @type string|bool $meta_key Limit results to users that have usermeta
44
+ * associated with this meta_key. Usually used with $meta_value.
45
+ * Default: false.
46
+ * @type string|bool $meta_value When used with $meta_key, limits results
47
+ * to users whose usermeta value associated with $meta_key matches
48
+ * $meta_value. Default: false.
49
+ * @type bool $populate_extras True if you want to fetch extra metadata
50
+ * about returned users, such as total group and friend counts.
51
+ * @type string $count_total Determines how BP_User_Query will do a count
52
+ * of total users matching the other filter criteria. Default value
53
+ * is 'count_query', which does a separate SELECT COUNT query to
54
+ * determine the total. 'sql_count_found_rows' uses
55
+ * SQL_COUNT_FOUND_ROWS and SELECT FOUND_ROWS(). Pass an empty string
56
+ * to skip the total user count query.
57
+ * }
58
  */
59
  class BP_User_Query {
60
 
61
  /** Variables *************************************************************/
62
 
63
  /**
64
+ * Unaltered params as passed to the constructor.
65
  *
66
+ * @since BuddyPress (1.8.0)
67
  * @var array
68
  */
69
  public $query_vars_raw = array();
70
 
71
  /**
72
+ * Array of variables to query with.
73
  *
74
+ * @since BuddyPress (1.7.0)
75
  * @var array
76
  */
77
  public $query_vars = array();
78
 
79
  /**
80
+ * List of found users and their respective data.
81
  *
82
+ * @access public To allow components to manipulate them.
83
+ * @since BuddyPress (1.7.0)
84
  * @var array
85
  */
86
  public $results = array();
87
 
88
  /**
89
+ * Total number of found users for the current query.
90
  *
91
+ * @access public To allow components to manipulate it.
92
+ * @since BuddyPress (1.7.0)
93
  * @var int
94
  */
95
  public $total_users = 0;
96
 
97
  /**
98
+ * List of found user IDs.
99
  *
100
+ * @access public To allow components to manipulate it.
101
+ * @since BuddyPress (1.7.0)
102
  * @var array
103
  */
104
  public $user_ids = array();
105
 
106
  /**
107
+ * SQL clauses for the user ID query.
108
  *
109
+ * @access public To allow components to manipulate it.
110
+ * @since BuddyPress (1.7.0)
111
+ * @var array
112
  */
113
  public $uid_clauses = array();
114
 
115
  /**
116
+ * SQL database column name to order by.
117
  *
118
+ * @since BuddyPress (1.7.0)
119
  * @var string
120
  */
121
  public $uid_name = '';
123
  /**
124
  * Standard response when the query should not return any rows.
125
  *
 
126
  * @access protected
127
+ * @since BuddyPress (1.7.0)
128
  * @var string
129
  */
130
  protected $no_results = array( 'join' => '', 'where' => '0 = 1' );
133
  /** Methods ***************************************************************/
134
 
135
  /**
136
+ * Constructor.
137
  *
138
+ * @since BuddyPress (1.7.0)
139
  *
140
+ * @param string|array $query See {@link BP_User_Query}.
141
  */
142
  public function __construct( $query = null ) {
143
 
190
  }
191
 
192
  /**
193
+ * Allow extending classes to set up action/filter hooks.
194
  *
195
  * When extending BP_User_Query, you may need to use some of its
196
  * internal hooks to modify the output. It's not convenient to call
199
  * you may not want to override in your class. Define this method in
200
  * your own class if you need a place where your extending class can
201
  * add its hooks early in the query-building process. See
202
+ * {@link BP_Group_Member_Query::setup_hooks()} for an example.
203
  *
204
+ * @since BuddyPress (1.8.0)
205
  */
206
  public function setup_hooks() {}
207
 
208
  /**
209
+ * Prepare the query for user_ids.
210
  *
211
+ * @since BuddyPress (1.7.0)
212
  */
213
  public function prepare_user_ids_query() {
214
  global $wpdb, $bp;
409
  }
410
 
411
  /**
412
+ * Query for IDs of users that match the query parameters.
413
+ *
414
  * Perform a database query to specifically get only user IDs, using
415
  * existing query variables set previously in the constructor.
416
  *
417
  * Also used to quickly perform user total counts.
418
  *
419
+ * @since BuddyPress (1.7.0)
420
  */
421
  public function do_user_ids_query() {
422
  global $wpdb;
439
  }
440
 
441
  /**
442
+ * Use WP_User_Query() to pull data for the user IDs retrieved in the main query.
 
443
  *
444
+ * @since BuddyPress (1.7.0)
445
  */
446
  public function do_wp_user_query() {
447
  $wp_user_query = new WP_User_Query( apply_filters( 'bp_wp_user_query_args', array(
475
  }
476
 
477
  /**
478
+ * Fetch the IDs of users to put in the IN clause of the main query.
479
  *
480
  * By default, returns the value passed to it
481
  * ($this->query_vars['include']). Having this abstracted into a
482
  * standalone method means that extending classes can override the
483
  * logic, parsing together their own user_id limits with the 'include'
484
+ * ids passed to the class constructor. See {@link BP_Group_Member_Query}
485
+ * for an example.
486
+ *
487
+ * @since BuddyPress (1.8.0)
488
  *
489
+ * @param array Sanitized array of user IDs, as passed to the 'include'
490
+ * parameter of the class constructor.
 
491
  * @return array The list of users to which the main query should be
492
+ * limited.
493
  */
494
  public function get_include_ids( $include = array() ) {
495
  return $include;
497
 
498
  /**
499
  * Perform a database query to populate any extra metadata we might need.
500
+ *
501
  * Different components will hook into the 'bp_user_query_populate_extras'
502
  * action to loop in the things they want.
503
  *
504
+ * @since BuddyPress (1.7.0)
505
  *
506
+ * @global BuddyPress $bp Global BuddyPress settings object.
507
+ * @global WPDB $wpdb Global WordPress database access object.
 
508
  */
509
  public function populate_extras() {
510
  global $wpdb;
614
  }
615
 
616
  /**
617
+ * Fetch data about a BuddyPress user.
618
+ *
619
  * BP_Core_User class can be used by any component. It will fetch useful
620
  * details for any user when provided with a user_id.
621
  *
625
  * $user_email = $user->email;
626
  * $user_status = $user->status;
627
  * etc.
 
 
628
  */
629
  class BP_Core_User {
630
 
633
  *
634
  * @var integer
635
  */
636
+ public $id;
637
 
638
  /**
639
  * The URL to the full size of the avatar for the user.
640
  *
641
  * @var string
642
  */
643
+ public $avatar;
644
 
645
  /**
646
  * The URL to the thumb size of the avatar for the user.
647
  *
648
  * @var string
649
  */
650
+ public $avatar_thumb;
651
 
652
  /**
653
  * The URL to the mini size of the avatar for the user.
654
  *
655
  * @var string
656
  */
657
+ public $avatar_mini;
658
 
659
  /**
660
  * The full name of the user
661
  *
662
  * @var string
663
  */
664
+ public $fullname;
665
 
666
  /**
667
  * The email for the user.
668
  *
669
  * @var string
670
  */
671
+ public $email;
672
 
673
  /**
674
  * The absolute url for the user's profile.
675
  *
676
  * @var string
677
  */
678
+ public $user_url;
679
 
680
  /**
681
  * The HTML for the user link, with the link text being the user's full name.
682
  *
683
  * @var string
684
  */
685
+ public $user_link;
686
 
687
  /**
688
  * Contains a formatted string when the last time the user was active.
691
  *
692
  * @var string
693
  */
694
+ public $last_active;
695
 
696
  /* Extras */
697
 
700
  *
701
  * @var integer
702
  */
703
+ public $total_friends;
704
 
705
  /**
706
  * The total number of blog posts posted by the user
708
  * @var integer
709
  * @deprecated No longer used
710
  */
711
+ public $total_blogs;
712
 
713
  /**
714
  * The total number of groups the user is a part of.
717
  *
718
  * @var string
719
  */
720
+ public $total_groups;
721
 
722
  /**
723
  * Profile information for the specific user.
724
  *
725
+ * @since BuddyPress (1.2.0)
726
  * @var array
727
  */
728
  public $profile_data;
732
  /**
733
  * Class constructor.
734
  *
735
+ * @param integer $user_id The ID for the user being queried.
736
+ * @param bool $populate_extras Whether to fetch extra information
737
+ * such as group/friendship counts or not. Default: false.
738
  */
739
+ public function __construct( $user_id, $populate_extras = false ) {
740
  if ( !empty( $user_id ) ) {
741
  $this->id = $user_id;
742
  $this->populate();
747
  }
748
  }
749
 
 
 
750
  /**
751
  * Populate the instantiated class with data based on the User ID provided.
752
  *
753
+ * @uses bp_core_get_userurl() Returns the URL with no HTML markup for
754
+ * a user based on their user id.
755
+ * @uses bp_core_get_userlink() Returns a HTML formatted link for a
756
+ * user with the user's full name as the link text.
757
+ * @uses bp_core_get_user_email() Returns the email address for the
758
+ * user based on user ID.
759
+ * @uses bp_get_user_meta() BP function returns the value of passed
760
+ * usermeta name from usermeta table.
761
  * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
762
+ * @uses bp_profile_last_updated_date() Returns the last updated date
763
+ * for a user.
764
  */
765
+ public function populate() {
766
 
767
  if ( bp_is_active( 'xprofile' ) )
768
  $this->profile_data = $this->get_profile_data();
789
  $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Avatar of %s', 'buddypress' ), $this->fullname ) ) );
790
  $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Avatar of %s', 'buddypress' ), $this->fullname ) ) );
791
  $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Avatar of %s', 'buddypress' ), $this->fullname ), 'width' => 30, 'height' => 30 ) );
792
+ $this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), __( 'active %s', 'buddypress' ) );
793
  }
794
 
795
  /**
796
  * Populates extra fields such as group and friendship counts.
797
  */
798
+ public function populate_extras() {
799
 
800
  if ( bp_is_active( 'friends' ) ) {
801
  $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
807
  }
808
  }
809
 
810
+ /**
811
+ * Fetch xprofile data for the current user.
812
+ *
813
+ * @see BP_XProfile_ProfileData::get_all_for_user() for description of
814
+ * return value.
815
+ *
816
+ * @return array See {@link BP_XProfile_Profile_Data::get_all_for_user()}.
817
+ */
818
+ public function get_profile_data() {
819
  return BP_XProfile_ProfileData::get_all_for_user( $this->id );
820
  }
821
 
822
  /** Static Methods ********************************************************/
823
 
824
+ /**
825
+ * Get a list of users that match the query parameters.
826
+ *
827
+ * Since BuddyPress 1.7, use {@link BP_User_Query} instead.
828
+ *
829
+ * @deprecated 1.7.0 Use {@link BP_User_Query}.
830
+ *
831
+ * @see BP_User_Query for a description of parameters, most of which
832
+ * are used there in the same way.
833
+ *
834
+ * @param string $type See {@link BP_User_Query}.
835
+ * @param int $limit See {@link BP_User_Query}. Default: 0.
836
+ * @param int $page See {@link BP_User_Query}. Default: 1.
837
+ * @param int $user_id See {@link BP_User_Query}. Default: 0.
838
+ * @param mixed $include See {@link BP_User_Query}. Default: false.
839
+ * @param string|bool $search_terms See {@link BP_User_Query}.
840
+ * Default: false.
841
+ * @param bool $populate_extras See {@link BP_User_Query}.
842
+ * Default: true.
843
+ * @param mixed $exclude See {@link BP_User_Query}. Default: false.
844
+ * @param string|bool $meta_key See {@link BP_User_Query}.
845
+ * Default: false.
846
+ * @param string|bool $meta_value See {@link BP_User_Query}.
847
+ * Default: false.
848
+ * @return array {
849
+ * @type int $total_users Total number of users matched by query
850
+ * params.
851
+ * @type array $paged_users The current page of users matched by
852
+ * query params.
853
+ * }
854
+ */
855
+ public static function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) {
856
  global $wpdb, $bp;
857
 
858
  _deprecated_function( __METHOD__, '1.7', 'BP_User_Query' );
1027
 
1028
 
1029
  /**
1030
+ * Fetch the details for all users whose usernames start with the given letter.
1031
+ *
1032
+ * @global BuddyPress $bp The one true BuddyPress instance.
1033
+ * @global wpdb $wpdb WordPress database object.
1034
  *
 
 
1035
  * @param string $letter The letter the users names are to start with.
1036
+ * @param int $limit The number of users we wish to retrive.
1037
+ * @param int $page The page number we are currently on, used in
1038
+ * conjunction with $limit to get the start position for the
1039
+ * limit.
1040
+ * @param bool $populate_extras Populate extra user fields?
1041
+ * @param string $exclude Comma-separated IDs of users whose results
1042
+ * aren't to be fetched.
1043
  * @return mixed False on error, otherwise associative array of results.
 
1044
  */
1045
+ public static function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) {
1046
  global $bp, $wpdb;
1047
 
1048
  $pag_sql = '';
1097
  }
1098
 
1099
  /**
1100
+ * Get details of specific users from the database.
1101
  *
1102
+ * Use {@link BP_User_Query} with the 'user_ids' param instead.
1103
+ *
1104
+ * @global wpdb $wpdb WordPress database object.
1105
+ * @param array $user_ids The user IDs of the users who we wish to
1106
+ * fetch information on.
1107
+ * @param int $limit The limit of results we want.
1108
+ * @param int $page The page we are on for pagination.
1109
+ * @param bool $populate_extras Populate extra user fields?
1110
+ * @return array Associative array.
1111
  */
1112
+ public static function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {
1113
  global $wpdb;
1114
 
1115
  $pag_sql = '';
1144
  /**
1145
  * Find users who match on the value of an xprofile data.
1146
  *
1147
+ * @global BuddyPress $bp The one true BuddyPress instance.
1148
+ * @global wpdb $wpdb WordPress database object.
1149
+ *
1150
+ * @param string $search_terms The terms to search the profile table
1151
+ * value column for.
1152
  * @param integer $limit The limit of results we want.
1153
  * @param integer $page The page we are on for pagination.
1154
  * @param boolean $populate_extras Populate extra user fields?
1155
+ * @return array Associative array.
 
1156
  */
1157
+ public static function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
1158
  global $bp, $wpdb;
1159
 
1160
  $user_ids = array();
1188
  *
1189
  * Accepts multiple user IDs to fetch data for.
1190
  *
1191
+ * @global BuddyPress $bp The one true BuddyPress instance.
1192
+ * @global wpdb $wpdb WordPress database object.
1193
+ *
1194
+ * @param array $paged_users An array of stdClass containing the users.
1195
+ * @param string $user_ids The user ids to select information about.
1196
+ * @param string $type The type of fields we wish to get.
1197
  * @return mixed False on error, otherwise associative array of results.
 
1198
  */
1199
+ public static function get_user_extras( &$paged_users, &$user_ids, $type = false ) {
1200
  global $bp, $wpdb;
1201
 
1202
  if ( empty( $user_ids ) )
1274
  /**
1275
  * Get WordPress user details for a specified user.
1276
  *
1277
+ * @global wpdb $wpdb WordPress database object.
1278
+ *
1279
+ * @param integer $user_id User ID.
1280
+ * @return array Associative array.
1281
  */
1282
+ public static function get_core_userdata( $user_id ) {
1283
  global $wpdb;
1284
 
1285
  if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) )
1291
 
1292
 
1293
  /**
1294
+ * BP_Core_Notification is deprecated.
1295
+ *
1296
+ * Use BP_Notifications_Notification instead.
1297
  *
1298
  * @package BuddyPress Core
1299
+ * @deprecated since BuddyPress (1.9)
1300
  */
 
1301
  class BP_Core_Notification {
1302
 
1303
  /**
1305
  *
1306
  * @var integer
1307
  */
1308
+ public $id;
1309
 
1310
  /**
1311
  * The ID to which the notification relates to within the component.
1312
  *
1313
  * @var integer
1314
  */
1315
+ public $item_id;
1316
 
1317
  /**
1318
  * The secondary ID to which the notification relates to within the component.
1319
  *
1320
  * @var integer
1321
  */
1322
+ public $secondary_item_id = null;
1323
 
1324
  /**
1325
  * The user ID for who the notification is for.
1326
  *
1327
  * @var integer
1328
  */
1329
+ public $user_id;
1330
 
1331
  /**
1332
  * The name of the component that the notification is for.
1333
  *
1334
  * @var string
1335
  */
1336
+ public $component_name;
1337
 
1338
  /**
1339
  * The action within the component which the notification is related to.
1340
  *
1341
  * @var string
1342
  */
1343
+ public $component_action;
1344
 
1345
  /**
1346
  * The date the notification was created.
1347
  *
1348
  * @var string
1349
  */
1350
+ public $date_notified;
1351
 
1352
  /**
1353
  * Is the notification new or has it already been read.
1354
  *
1355
  * @var boolean
1356
  */
1357
+ public $is_new;
1358
 
1359
  /** Public Methods ********************************************************/
1360
 
1363
  *
1364
  * @param integer $id
1365
  */
1366
+ public function __construct( $id = 0 ) {
1367
  if ( !empty( $id ) ) {
1368
  $this->id = $id;
1369
  $this->populate();
1377
  * @global wpdb $wpdb WordPress database object
1378
  * @return bool Success or failure
1379
  */
1380
+ public function save() {
1381
  global $bp, $wpdb;
1382
 
1383
  // Update
1405
  * @global BuddyPress $bp The one true BuddyPress instance
1406
  * @global wpdb $wpdb WordPress database object
1407
  */
1408
+ public function populate() {
1409
  global $bp, $wpdb;
1410
 
1411
  if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
1421
 
1422
  /** Static Methods ********************************************************/
1423
 
1424
+ public static function check_access( $user_id, $notification_id ) {
1425
  global $wpdb, $bp;
1426
 
1427
  return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );
1437
  * @return array Associative array
1438
  * @static
1439
  */
1440
+ public static function get_all_for_user( $user_id, $status = 'is_new' ) {
1441
  global $bp, $wpdb;
1442
 
1443
  $is_new = ( 'is_new' == $status ) ? ' AND is_new = 1 ' : '';
1455
  * @param string $component_action
1456
  * @static
1457
  */
1458
+ public static function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
1459
  global $bp, $wpdb;
1460
 
1461
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
1473
  * @param integer $secondary_item_id (optional) The secondary item id of the notifications that we wish to use to delete.
1474
  * @static
1475
  */
1476
+ public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
1477
  global $bp, $wpdb;
1478
 
1479
  $secondary_item_sql = !empty( $secondary_item_id ) ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) : '';
1491
  * @param string $component_action The action of the component the notification was sent from.
1492
  * @static
1493
  */
1494
+ public static function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
1495
  global $bp, $wpdb;
1496
 
1497
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
1508
  * @param string $secondary_item_id Optional secondary item id that the notifications are to have.
1509
  * @static
1510
  */
1511
+ public static function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
1512
  global $bp, $wpdb;
1513
 
1514
  if ( $component_action )
1526
  }
1527
 
1528
  /**
1529
+ * API to create BuddyPress buttons.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1530
  *
 
1531
  * @since BuddyPress (1.2.6)
1532
+ *
1533
+ * @param array $args {
1534
+ * Array of arguments.
1535
+ * @type string $id String describing the button type.
1536
+ * @type string $component The name of the component the button belongs to.
1537
+ * Default: 'core'.
1538
+ * @type bool $must_be_logged_in Optional. Does the user need to be logged
1539
+ * in to see this button? Default: true.
1540
+ * @type bool $block_self Optional. True if the button should be hidden
1541
+ * when a user is viewing his own profile. Default: true.
1542
+ * @type string|bool $wrapper Optional. HTML element type that should wrap
1543
+ * the button: 'div', 'span', 'p', or 'li'. False for no wrapper at
1544
+ * all. Default: 'div'.
1545
+ * @type string $wrapper_id Optional. DOM ID of the button wrapper element.
1546
+ * Default: ''.
1547
+ * @type string $wrapper_class Optional. DOM class of the button wrapper
1548
+ * element. Default: ''.
1549
+ * @type string $link_href Optional. Destination link of the button.
1550
+ * Default: ''.
1551
+ * @type string $link_class Optional. DOM class of the button. Default: ''.
1552
+ * @type string $link_id Optional. DOM ID of the button. Default: ''.
1553
+ * @type string $link_rel Optional. DOM 'rel' attribute of the button.
1554
+ * Default: ''.
1555
+ * @type string $link_title Optional. Title attribute of the button.
1556
+ * Default: ''.
1557
+ * @type string $link_text Optional. Text to appear on the button.
1558
+ * Default: ''.
1559
+ * }
1560
  */
1561
  class BP_Button {
1562
 
1563
  /** Button properties *****************************************************/
1564
 
1565
  /**
1566
+ * The button ID.
1567
  *
1568
+ * @var string
1569
  */
1570
  public $id = '';
1571
 
1572
  /**
1573
+ * The name of the component that the button belongs to.
1574
  *
1575
  * @var string
1576
  */
1579
  /**
1580
  * Does the user need to be logged in to see this button?
1581
  *
1582
+ * @var bool
1583
  */
1584
  public $must_be_logged_in = true;
1585
 
1586
  /**
1587
+ * Whether the button should be hidden when viewing your own profile.
 
1588
  *
1589
+ * @var bool
1590
  */
1591
  public $block_self = true;
1592
 
1593
  /** Wrapper ***************************************************************/
1594
 
1595
  /**
1596
+ * The type of DOM element to use for a wrapper.
 
1597
  *
1598
+ * @var string|bool 'div', 'span', 'p', 'li', or false for no wrapper.
1599
  */
1600
  public $wrapper = 'div';
1601
 
1602
  /**
1603
+ * The DOM class of the button wrapper.
1604
  *
1605
  * @var string
1606
  */
1607
  public $wrapper_class = '';
1608
 
1609
  /**
1610
+ * The DOM ID of the button wrapper.
1611
  *
1612
  * @var string
1613
  */
1616
  /** Button ****************************************************************/
1617
 
1618
  /**
1619
+ * The destination link of the button.
1620
  *
1621
  * @var string
1622
  */
1623
  public $link_href = '';
1624
 
1625
  /**
1626
+ * The DOM class of the button link.
1627
  *
1628
  * @var string
1629
  */
1630
  public $link_class = '';
1631
 
1632
  /**
1633
+ * The DOM ID of the button link.
1634
  *
1635
  * @var string
1636
  */
1637
  public $link_id = '';
1638
 
1639
  /**
1640
+ * The DOM rel value of the button link.
1641
  *
1642
  * @var string
1643
  */
1644
  public $link_rel = '';
1645
 
1646
  /**
1647
+ * Title of the button link.
1648
  *
1649
  * @var string
1650
  */
1651
  public $link_title = '';
1652
 
1653
  /**
1654
+ * The contents of the button link.
1655
  *
1656
  * @var string
1657
  */
1664
  /** Methods ***************************************************************/
1665
 
1666
  /**
1667
+ * Builds the button based on class parameters.
1668
  *
1669
  * @since BuddyPress (1.2.6)
1670
  *
1671
+ * @param array $args See {@BP_Button}.
1672
+ * @return bool|null Returns false when the button is not allowed for
1673
+ * the current context.
1674
  */
1675
  public function __construct( $args = '' ) {
1676
 
1743
  }
1744
 
1745
  /**
1746
+ * Return the markup for the generated button.
1747
  *
1748
  * @since BuddyPress (1.2.6)
1749
  *
1750
+ * @return string Button markup.
1751
  */
1752
  public function contents() {
1753
  return $this->contents;
1754
  }
1755
 
1756
  /**
1757
+ * Output the markup of button.
1758
  *
1759
  * @since BuddyPress (1.2.6)
1760
  */
1765
  }
1766
 
1767
  /**
1768
+ * Enable oEmbeds in BuddyPress contexts.
1769
  *
1770
  * Extends WP_Embed class for use with BuddyPress.
1771
  *
1772
+ * @since BuddyPress (1.5.0)
1773
+ *
1774
  * @see WP_Embed
1775
  */
1776
  class BP_Embed extends WP_Embed {
1778
  /**
1779
  * Constructor
1780
  *
1781
+ * @global WP_Embed $wp_embed
1782
  */
1783
+ public function __construct() {
1784
  global $wp_embed;
1785
 
1786
  // Make sure we populate the WP_Embed handlers array.
1815
  /**
1816
  * The {@link do_shortcode()} callback function.
1817
  *
1818
+ * Attempts to convert a URL into embed HTML. Starts by checking the
1819
+ * URL against the regex of the registered embed handlers. Next, checks
1820
+ * the URL against the regex of registered {@link WP_oEmbed} providers
1821
+ * if oEmbed discovery is false. If none of the regex matches and it's
1822
+ * enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()}
1823
+ * for oEmbed parsing.
1824
  *
1825
  * @uses wp_parse_args()
1826
  * @uses wp_embed_defaults()
1832
  * @param string $url The URL attempting to be embeded.
1833
  * @return string The embed HTML on success, otherwise the original URL.
1834
  */
1835
+ public function shortcode( $attr, $url = '' ) {
1836
  if ( empty( $url ) )
1837
  return '';
1838
 
1884
  }
1885
 
1886
  /**
1887
+ * Base function so BP components/plugins can parse links to be embedded.
1888
+ *
1889
  * View an example to add support in {@link bp_activity_embed()}.
1890
  *
1891
  * @uses apply_filters() Filters cache.
1892
  * @uses do_action() To save cache.
1893
+ * @uses wp_oembed_get() Connects to oEmbed provider and returns HTML
1894
+ * on success.
1895
+ * @uses WP_Embed::maybe_make_link() Process URL for hyperlinking on
1896
+ * oEmbed failure.
1897
+ *
1898
  * @param int $id ID to do the caching for.
1899
  * @param string $url The URL attempting to be embedded.
1900
  * @param array $attr Shortcode attributes from {@link WP_Embed::shortcode()}.
1901
+ * @param array $rawattr Untouched shortcode attributes from
1902
+ * {@link WP_Embed::shortcode()}.
1903
  * @return string The embed HTML on success, otherwise the original URL.
1904
  */
1905
+ public function parse_oembed( $id, $url, $attr, $rawattr ) {
1906
  $id = intval( $id );
1907
 
1908
  if ( $id ) {
1937
  }
1938
 
1939
  /**
1940
+ * Create HTML list of BP nav items.
1941
  *
1942
+ * @since BuddyPress (1.7.0)
1943
  */
1944
  class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
1945
+
1946
  /**
1947
+ * Description of fields indexes for building markup.
1948
+ *
1949
+ * @since BuddyPress (1.7.0)
1950
  * @var array
1951
  */
1952
  var $db_fields = array( 'id' => 'css_id', 'parent' => 'parent' );
1953
 
1954
  /**
1955
+ * Tree type.
1956
+ *
1957
+ * @since BuddyPress (1.7.0)
1958
  * @var string
1959
  */
1960
  var $tree_type = array();
1962
  /**
1963
  * Display array of elements hierarchically.
1964
  *
1965
+ * This method is almost identical to the version in {@link Walker::walk()}.
1966
+ * The only change is on one line which has been commented. An IF was
1967
+ * comparing 0 to a non-empty string which was preventing child elements
1968
  * being grouped under their parent menu element.
1969
  *
1970
+ * This caused a problem for BuddyPress because our primary/secondary
1971
+ * navigations don't have a unique numerical ID that describes a
1972
+ * hierarchy (we use a slug). Obviously, WordPress Menus use Posts, and
1973
+ * those have ID/post_parent.
1974
+ *
1975
+ * @since BuddyPress (1.7.0)
1976
  *
 
 
 
1977
  * @see Walker::walk()
1978
+ *
1979
+ * @param array $elements See {@link Walker::walk()}.
1980
+ * @param int $max_depth See {@link Walker::walk()}.
1981
+ * @return string See {@link Walker::walk()}.
1982
  */
1983
+ public function walk( $elements, $max_depth ) {
1984
  $args = array_slice( func_get_args(), 2 );
1985
  $output = '';
1986
 
2058
  }
2059
 
2060
  /**
2061
+ * Display the current <li> that we are on.
2062
+ *
2063
+ * @see Walker::start_el() for complete description of parameters .
2064
+ *
2065
+ * @since BuddyPress (1.7.0)
2066
  *
2067
+ * @param string $output Passed by reference. Used to append
2068
+ * additional content.
2069
  * @param object $item Menu item data object.
2070
+ * @param int $depth Depth of menu item. Used for padding. Optional,
2071
+ * defaults to 0.
2072
+ * @param array $args Optional. See {@link Walker::start_el()}.
2073
  * @param int $current_page Menu item ID. Optional.
 
2074
  */
2075
+ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
2076
  // If we're someway down the tree, indent the HTML with the appropriate number of tabs
2077
  $indent = $depth ? str_repeat( "\t", $depth ) : '';
2078
 
2102
  $output .= apply_filters( 'bp_walker_nav_menu_start_el', $item_output, $item, $depth, $args );
2103
  }
2104
  }
2105
+
2106
+ /**
2107
+ * Create a set of BuddyPress-specific links for use in the Menus admin UI.
2108
+ *
2109
+ * Borrowed heavily from {@link Walker_Nav_Menu_Checklist}, but modified so as not
2110
+ * to require an actual post type or taxonomy, and to force certain CSS classes
2111
+ *
2112
+ * @since BuddyPress (1.9.0)
2113
+ */
2114
+ class BP_Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
2115
+
2116
+ /**
2117
+ * Constructor.
2118
+ *
2119
+ * @see Walker_Nav_Menu::__construct() for a description of parameters.
2120
+ *
2121
+ * @param array $fields See {@link Walker_Nav_Menu::__construct()}.
2122
+ */
2123
+ public function __construct( $fields = false ) {
2124
+ if ( $fields ) {
2125
+ $this->db_fields = $fields;
2126
+ }
2127
+ }
2128
+
2129
+ /**
2130
+ * Create the markup to start a tree level.
2131
+ *
2132
+ * @see Walker_Nav_Menu::start_lvl() for description of parameters.
2133
+ *
2134
+ * @param string $output See {@Walker_Nav_Menu::start_lvl()}.
2135
+ * @param int $depth See {@Walker_Nav_Menu::start_lvl()}.
2136
+ * @param array $args See {@Walker_Nav_Menu::start_lvl()}.
2137
+ */
2138
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {
2139
+ $indent = str_repeat( "\t", $depth );
2140
+ $output .= "\n$indent<ul class='children'>\n";
2141
+ }
2142
+
2143
+ /**
2144
+ * Create the markup to end a tree level.
2145
+ *
2146
+ * @see Walker_Nav_Menu::end_lvl() for description of parameters.
2147
+ *
2148
+ * @param string $output See {@Walker_Nav_Menu::end_lvl()}.
2149
+ * @param int $depth See {@Walker_Nav_Menu::end_lvl()}.
2150
+ * @param array $args See {@Walker_Nav_Menu::end_lvl()}.
2151
+ */
2152
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {
2153
+ $indent = str_repeat( "\t", $depth );
2154
+ $output .= "\n$indent</ul>";
2155
+ }
2156
+
2157
+ /**
2158
+ * Create the markup to start an element.
2159
+ *
2160
+ * @see Walker::start_el() for description of parameters.
2161
+ *
2162
+ * @param string $output Passed by reference. Used to append additional
2163
+ * content.
2164
+ * @param object $item Menu item data object.
2165
+ * @param int $depth Depth of menu item. Used for padding.
2166
+ * @param object $args See {@Walker::start_el()}.
2167
+ * @param int $id See {@Walker::start_el()}.
2168
+ */
2169
+ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
2170
+ global $_nav_menu_placeholder;
2171
+
2172
+ $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
2173
+ $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
2174
+ $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
2175
+
2176
+ $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
2177
+
2178
+ $output .= $indent . '<li>';
2179
+ $output .= '<label class="menu-item-title">';
2180
+ $output .= '<input type="checkbox" class="menu-item-checkbox';
2181
+
2182
+ if ( property_exists( $item, 'label' ) ) {
2183
+ $title = $item->label;
2184
+ }
2185
+
2186
+ $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> ';
2187
+ $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
2188
+ $output .= '</label>';
2189
+
2190
+ if ( empty( $item->url ) ) {
2191
+ $item->url = $item->guid;
2192
+ }
2193
+
2194
+ if ( ! in_array( array( 'bp-menu', 'bp-'. $item->post_excerpt .'-nav' ), $item->classes ) ) {
2195
+ $item->classes[] = 'bp-menu';
2196
+ $item->classes[] = 'bp-'. $item->post_excerpt .'-nav';
2197
+ }
2198
+
2199
+ // Menu item hidden fields
2200
+ $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
2201
+ $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
2202
+ $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />';
2203
+ $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="custom" />';
2204
+ $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
2205
+ $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
2206
+ $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
2207
+ $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
2208
+ $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />';
2209
+ $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
2210
+ }
2211
+ }
bp-core/bp-core-component.php CHANGED
@@ -1,11 +1,17 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  // Exit if accessed directly
4
  if ( !defined( 'ABSPATH' ) ) exit;
5
 
6
  if ( !class_exists( 'BP_Component' ) ) :
7
  /**
8
- * BuddyPress Component Class
9
  *
10
  * The BuddyPress component class is responsible for simplifying the creation
11
  * of components that share similar behaviors and routines. It is used
@@ -15,88 +21,113 @@ if ( !class_exists( 'BP_Component' ) ) :
15
  * @package BuddyPress
16
  * @subpackage Component
17
  *
18
- * @since BuddyPress (1.5)
19
  */
20
  class BP_Component {
21
 
22
  /** Variables *************************************************************/
23
 
24
  /**
25
- * @var string Unique name (for internal identification)
 
26
  * @internal
 
27
  */
28
  public $name = '';
29
 
30
  /**
31
- * @var Unique ID (normally for custom post type)
 
 
32
  */
33
  public $id = '';
34
 
35
  /**
36
- * @var string Unique slug (used in query string and permalinks)
 
 
37
  */
38
  public $slug = '';
39
 
40
  /**
41
- * @var bool Does this component need a top-level directory?
 
 
42
  */
43
  public $has_directory = false;
44
 
45
  /**
46
- * @var string The path to the component's files
 
 
47
  */
48
  public $path = '';
49
 
50
  /**
51
- * @var WP_Query The loop for this component
 
 
52
  */
53
  public $query = false;
54
 
55
  /**
56
- * @var string The current ID of the queried object
 
 
57
  */
58
  public $current_id = '';
59
 
60
  /**
61
- * @var string Function to call for notifications
 
 
62
  */
63
  public $notification_callback = '';
64
 
65
  /**
66
- * @var array WordPress Toolbar links
 
 
67
  */
68
  public $admin_menu = '';
69
 
70
  /**
71
- * Search input box placeholder string for the component
72
  *
73
- * @since BuddyPress (1.5)
74
- * @var string
75
  */
76
  public $search_string = '';
77
 
78
  /**
79
- * Component's root slug
80
  *
81
- * @since BuddyPress (1.5)
82
- * @var string
83
  */
84
  public $root_slug = '';
85
 
86
  /** Methods ***************************************************************/
87
 
88
  /**
89
- * Component loader
90
  *
91
- * @since BuddyPress (1.5)
92
  *
93
- * @param string $id Unique ID (for internal identification). Letters, numbers, and underscores only
94
- * @param string $name Unique name. This should be a translatable name, eg __( 'Groups', 'buddypress' )
95
- * @param string $path The file path for the component's files. Used by BP_Component::includes()
96
  *
97
- * @uses bp_Component::setup_actions() Setup the hooks and actions
 
 
 
 
 
 
 
 
 
98
  */
99
- public function start( $id = '', $name = '', $path = '' ) {
100
 
101
  // Internal identifier of component
102
  $this->id = $id;
@@ -107,27 +138,62 @@ class BP_Component {
107
  // Path for includes
108
  $this->path = $path;
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  // Move on to the next step
111
  $this->setup_actions();
112
  }
113
 
114
  /**
115
- * Component global variables
116
  *
117
  * @since BuddyPress (1.5)
118
  *
119
- * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_id'
120
- * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_slug'
121
  *
122
- * @param array $args Optional
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  */
124
  public function setup_globals( $args = array() ) {
125
 
126
  /** Slugs *************************************************************/
127
 
 
 
 
 
128
  $r = wp_parse_args( $args, array(
129
  'slug' => $this->id,
130
- 'root_slug' => '',
131
  'has_directory' => false,
132
  'notification_callback' => '',
133
  'search_string' => '',
@@ -171,28 +237,34 @@ class BP_Component {
171
  }
172
 
173
  /**
174
- * Include required files
175
  *
176
- * Please note that, by default, this method is fired on the bp_include hook, with priority
177
- * 8. This is necessary so that core components are loaded in time to be available to
178
- * third-party plugins. However, this load order means that third-party plugins whose main
179
- * files are loaded at bp_include with priority 10 (as recommended), will not be loaded in
180
- * time for their includes() method to fire automatically.
 
181
  *
182
- * For this reason, it is recommended that your plugin has its own method or function for
183
- * requiring necessary files. If you must use this method, you will have to call it manually
184
- * in your constructor class, ie
 
185
  * $this->includes();
186
  *
187
- * Note that when you pass an array value like 'actions' to includes, it looks for the
188
- * following three files (assuming your component is called 'my_component'):
 
189
  * - ./actions
190
  * - ./bp-my_component/actions
191
  * - ./bp-my_component/bp-my_component-actions.php
192
  *
193
- * @since BuddyPress (1.5)
 
 
194
  *
195
- * @uses do_action() Calls 'bp_{@link bp_Component::name}includes'
 
196
  */
197
  public function includes( $includes = array() ) {
198
 
@@ -221,7 +293,7 @@ class BP_Component {
221
  foreach ( $paths as $path ) {
222
  if ( @is_file( $slashed_path . $path ) ) {
223
  require( $slashed_path . $path );
224
- continue;
225
  }
226
  }
227
  }
@@ -231,12 +303,12 @@ class BP_Component {
231
  }
232
 
233
  /**
234
- * Setup the actions
235
  *
236
- * @since BuddyPress (1.5)
237
  *
238
- * @uses add_action() To add various actions
239
- * @uses do_action() Calls 'bp_{@link BP_Component::name}setup_actions'
240
  */
241
  public function setup_actions() {
242
 
@@ -254,7 +326,7 @@ class BP_Component {
254
  add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 );
255
 
256
  // Setup WP Toolbar menus
257
- add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar' ), 10 );
258
 
259
  // Setup component title
260
  add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 );
@@ -268,6 +340,15 @@ class BP_Component {
268
  // Add the rewrite tags
269
  add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10 );
270
 
 
 
 
 
 
 
 
 
 
271
  // Generate rewrite rules
272
  add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
273
 
@@ -276,10 +357,18 @@ class BP_Component {
276
  }
277
 
278
  /**
279
- * Setup the navigation
 
 
 
 
 
280
  *
281
- * @param array $main_nav Optional
282
- * @param array $sub_nav Optional
 
 
 
283
  */
284
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
285
 
@@ -300,10 +389,16 @@ class BP_Component {
300
  }
301
 
302
  /**
303
- * Setup the Toolbar
304
  *
 
 
305
  * @global obj $wp_admin_bar
306
- * @param array $wp_admin_menus
 
 
 
 
307
  */
308
  public function setup_admin_bar( $wp_admin_nav = array() ) {
309
 
@@ -315,6 +410,9 @@ class BP_Component {
315
  if ( !bp_use_wp_admin_bar() )
316
  return;
317
 
 
 
 
318
  // Do we have Toolbar menus to add?
319
  if ( !empty( $wp_admin_nav ) ) {
320
 
@@ -335,49 +433,83 @@ class BP_Component {
335
  }
336
 
337
  /**
338
- * Setup the component title
339
  *
340
- * @since BuddyPress (1.5)
341
  *
342
- * @uses do_action() Calls 'bp_{@link bp_Component::name}setup_title'
343
  */
344
  public function setup_title() {
345
  do_action( 'bp_' . $this->id . '_setup_title' );
346
  }
347
 
348
  /**
349
- * Setup the component post types
350
  *
351
- * @since BuddyPress (1.5)
352
  *
353
- * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_post_types'
354
  */
355
  public function register_post_types() {
356
  do_action( 'bp_' . $this->id . '_register_post_types' );
357
  }
358
 
359
  /**
360
- * Register component specific taxonomies
361
  *
362
- * @since BuddyPress (1.5)
363
  *
364
- * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_taxonomies'
365
  */
366
  public function register_taxonomies() {
367
  do_action( 'bp_' . $this->id . '_register_taxonomies' );
368
  }
369
 
370
  /**
371
- * Add any additional rewrite tags
372
  *
373
- * @since BuddyPress (1.5)
374
  *
375
- * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_tags'
376
  */
377
  public function add_rewrite_tags() {
378
  do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
379
  }
380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  /**
382
  * Generate any additional rewrite rules
383
  *
1
  <?php
2
+ /**
3
+ * Component classes.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Core
7
+ */
8
 
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  if ( !class_exists( 'BP_Component' ) ) :
13
  /**
14
+ * BuddyPress Component Class.
15
  *
16
  * The BuddyPress component class is responsible for simplifying the creation
17
  * of components that share similar behaviors and routines. It is used
21
  * @package BuddyPress
22
  * @subpackage Component
23
  *
24
+ * @since BuddyPress (1.5.0)
25
  */
26
  class BP_Component {
27
 
28
  /** Variables *************************************************************/
29
 
30
  /**
31
+ * Translatable name for the component.
32
+ *
33
  * @internal
34
+ * @var string $name
35
  */
36
  public $name = '';
37
 
38
  /**
39
+ * Unique ID for the component.
40
+ *
41
+ * @var string $id
42
  */
43
  public $id = '';
44
 
45
  /**
46
+ * Unique slug for the component, for use in query strings and URLs.
47
+ *
48
+ * @var string $slug
49
  */
50
  public $slug = '';
51
 
52
  /**
53
+ * Does the component need a top-level directory?
54
+ *
55
+ * @var bool $has_directory
56
  */
57
  public $has_directory = false;
58
 
59
  /**
60
+ * The path to the component's files.
61
+ *
62
+ * @var string $path
63
  */
64
  public $path = '';
65
 
66
  /**
67
+ * The WP_Query loop for this component.
68
+ *
69
+ * @var WP_Query $query
70
  */
71
  public $query = false;
72
 
73
  /**
74
+ * The current ID of the queried object.
75
+ *
76
+ * @var string $current_id
77
  */
78
  public $current_id = '';
79
 
80
  /**
81
+ * Callback for formatting notifications.
82
+ *
83
+ * @var callable $notification_callback
84
  */
85
  public $notification_callback = '';
86
 
87
  /**
88
+ * WordPress Toolbar links.
89
+ *
90
+ * @var array $admin_menu
91
  */
92
  public $admin_menu = '';
93
 
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 = '';
101
 
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
  /** Methods ***************************************************************/
111
 
112
  /**
113
+ * Component loader.
114
  *
115
+ * @since BuddyPress (1.5.0)
116
  *
117
+ * @uses BP_Component::setup_actions() Set up the hooks and actions.
 
 
118
  *
119
+ * @param string $id Unique ID (for internal identification). Letters,
120
+ * numbers, and underscores only.
121
+ * @param string $name Unique name. This should be a translatable name,
122
+ * eg __( 'Groups', 'buddypress' ).
123
+ * @param string $path The file path for the component's files. Used by
124
+ * {@link BP_Component::includes()}.
125
+ * @param array $params Additional parameters used by the component.
126
+ * The config array supports the following values:
127
+ * - 'adminbar_myaccount_order' Sets the position for our
128
+ * component menu under the WP Toolbar's "My Account" menu.
129
  */
130
+ public function start( $id = '', $name = '', $path = '', $params = array() ) {
131
 
132
  // Internal identifier of component
133
  $this->id = $id;
138
  // Path for includes
139
  $this->path = $path;
140
 
141
+ // Miscellaneous component parameters that need to be set early on
142
+ if ( ! empty( $params ) ) {
143
+ // Sets the position for our menu under the WP Toolbar's "My Account" menu
144
+ if ( ! empty( $params['adminbar_myaccount_order'] ) ) {
145
+ $this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order'];
146
+ }
147
+
148
+ // Set defaults if not passed
149
+ } else {
150
+ // new component menus are added before the settings menu if not set
151
+ $this->adminbar_myaccount_order = 90;
152
+ }
153
+
154
  // Move on to the next step
155
  $this->setup_actions();
156
  }
157
 
158
  /**
159
+ * Set up component global variables.
160
  *
161
  * @since BuddyPress (1.5)
162
  *
163
+ * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_id'.
164
+ * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_slug'.
165
  *
166
+ * @param array $args {
167
+ * All values are optional.
168
+ * @type string $slug The component slug. Used to construct certain
169
+ * URLs, such as 'friends' in http://example.com/members/joe/friends/
170
+ * Default: the value of $this->id.
171
+ * @type string $root_slug The component root slug. Note that this
172
+ * value is generally unused if the component has a root
173
+ * directory (the slug will be overridden by the post_name of
174
+ * the directory page). Default: the slug of the directory
175
+ * page if one is found, otherwise an empty string.
176
+ * @type bool $has_directory Set to true if the component requires
177
+ * an associated WordPress page.
178
+ * @type callable $notification_callback Optional. The callable
179
+ * function that formats the component's notifications.
180
+ * @type string $search_term Optional. The placeholder text in the
181
+ * component directory search box. Eg, 'Search Groups...'.
182
+ * @type array $global_tables Optional. An array of database table
183
+ * names.
184
+ * }
185
  */
186
  public function setup_globals( $args = array() ) {
187
 
188
  /** Slugs *************************************************************/
189
 
190
+ // If a WP directory page exists for the component, it should
191
+ // be the default value of 'root_slug'.
192
+ $default_root_slug = isset( buddypress()->pages->{$this->id}->slug ) ? buddypress()->pages->{$this->id}->slug : '';
193
+
194
  $r = wp_parse_args( $args, array(
195
  'slug' => $this->id,
196
+ 'root_slug' => $default_root_slug,
197
  'has_directory' => false,
198
  'notification_callback' => '',
199
  'search_string' => '',
237
  }
238
 
239
  /**
240
+ * Include required files.
241
  *
242
+ * Please note that, by default, this method is fired on the bp_include
243
+ * hook, with priority 8. This is necessary so that core components are
244
+ * loaded in time to be available to third-party plugins. However, this
245
+ * load order means that third-party plugins whose main files are
246
+ * loaded at bp_include with priority 10 (as recommended), will not be
247
+ * loaded in time for their includes() method to fire automatically.
248
  *
249
+ * For this reason, it is recommended that your plugin has its own
250
+ * method or function for requiring necessary files. If you must use
251
+ * this method, you will have to call it manually in your constructor
252
+ * class, ie
253
  * $this->includes();
254
  *
255
+ * Note that when you pass an array value like 'actions' to includes,
256
+ * it looks for the following three files (assuming your component is
257
+ * called 'my_component'):
258
  * - ./actions
259
  * - ./bp-my_component/actions
260
  * - ./bp-my_component/bp-my_component-actions.php
261
  *
262
+ * @since BuddyPress (1.5.0)
263
+ *
264
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}includes'.
265
  *
266
+ * @param array $includes An array of file names, or file name chunks,
267
+ * to be parsed and then included.
268
  */
269
  public function includes( $includes = array() ) {
270
 
293
  foreach ( $paths as $path ) {
294
  if ( @is_file( $slashed_path . $path ) ) {
295
  require( $slashed_path . $path );
296
+ break;
297
  }
298
  }
299
  }
303
  }
304
 
305
  /**
306
+ * Set up the actions.
307
  *
308
+ * @since BuddyPress (1.5.0)
309
  *
310
+ * @uses add_action() To add various actions.
311
+ * @uses do_action() Calls 'bp_{@link BP_Component::name}setup_actions'.
312
  */
313
  public function setup_actions() {
314
 
326
  add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 );
327
 
328
  // Setup WP Toolbar menus
329
+ add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar' ), $this->adminbar_myaccount_order );
330
 
331
  // Setup component title
332
  add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 );
340
  // Add the rewrite tags
341
  add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10 );
342
 
343
+ // Add the rewrite rules
344
+ add_action( 'bp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ), 10 );
345
+
346
+ // Add the permalink structure
347
+ add_action( 'bp_add_permastructs', array( $this, 'add_permastructs' ), 10 );
348
+
349
+ // Allow components to parse the main query
350
+ add_action( 'bp_parse_query', array( $this, 'parse_query' ), 10 );
351
+
352
  // Generate rewrite rules
353
  add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
354
 
357
  }
358
 
359
  /**
360
+ * Set up component navigation.
361
+ *
362
+ * @see bp_core_new_nav_item() For a description of the $main_nav
363
+ * parameter formatting.
364
+ * @see bp_core_new_subnav_item() For a description of how each item
365
+ * in the $sub_nav parameter array should be formatted.
366
  *
367
+ * @param array $main_nav Optional. Passed directly to
368
+ * bp_core_new_nav_item(). See that function for a description.
369
+ * @param array $sub_nav Optional. Multidimensional array, each item in
370
+ * which is passed to bp_core_new_subnav_item(). See that
371
+ * function for a description.
372
  */
373
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
374
 
389
  }
390
 
391
  /**
392
+ * Set up the component entries in the WordPress Admin Bar.
393
  *
394
+ * @see WP_Admin_Bar::add_menu() for a description of the syntax
395
+ * required by each item in the $wp_admin_nav parameter array.
396
  * @global obj $wp_admin_bar
397
+ *
398
+ * @param array $wp_admin_nav An array of nav item arguments. Each item
399
+ * in this parameter array is passed to {@link WP_Admin_Bar::add_menu()}.
400
+ * See that method for a description of the required syntax for
401
+ * each item.
402
  */
403
  public function setup_admin_bar( $wp_admin_nav = array() ) {
404
 
410
  if ( !bp_use_wp_admin_bar() )
411
  return;
412
 
413
+ // Filter the passed admin nav
414
+ $wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
415
+
416
  // Do we have Toolbar menus to add?
417
  if ( !empty( $wp_admin_nav ) ) {
418
 
433
  }
434
 
435
  /**
436
+ * Set up the component title.
437
  *
438
+ * @since BuddyPress (1.5.0)
439
  *
440
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}setup_title'.
441
  */
442
  public function setup_title() {
443
  do_action( 'bp_' . $this->id . '_setup_title' );
444
  }
445
 
446
  /**
447
+ * Set up the component post types.
448
  *
449
+ * @since BuddyPress (1.5.0)
450
  *
451
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_post_types'.
452
  */
453
  public function register_post_types() {
454
  do_action( 'bp_' . $this->id . '_register_post_types' );
455
  }
456
 
457
  /**
458
+ * Register component-specific taxonomies.
459
  *
460
+ * @since BuddyPress (1.5.0)
461
  *
462
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_register_taxonomies'.
463
  */
464
  public function register_taxonomies() {
465
  do_action( 'bp_' . $this->id . '_register_taxonomies' );
466
  }
467
 
468
  /**
469
+ * Add any additional rewrite tags.
470
  *
471
+ * @since BuddyPress (1.5.0)
472
  *
473
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_tags'.
474
  */
475
  public function add_rewrite_tags() {
476
  do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
477
  }
478
 
479
+ /**
480
+ * Add any additional rewrite rules.
481
+ *
482
+ * @since BuddyPress (1.9.0)
483
+ *
484
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_rules'.
485
+ */
486
+ public function add_rewrite_rules() {
487
+ do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
488
+ }
489
+
490
+ /**
491
+ * Add any permalink structures
492
+ *
493
+ * @since BuddyPress (1.9)
494
+ *
495
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_add_permastruct'
496
+ */
497
+ public function add_permastructs() {
498
+ do_action( 'bp_' . $this->id . '_add_permastructs' );
499
+ }
500
+
501
+ /**
502
+ * Allow components to parse the main query
503
+ *
504
+ * @since BuddyPress (1.9)
505
+ *
506
+ * @uses do_action() Calls 'bp_{@link bp_Component::name}_parse_query'
507
+ * @param object The main WP_Query
508
+ */
509
+ public function parse_query( $query ) {
510
+ do_action_ref_array( 'bp_' . $this->id . '_parse_query', array( &$query ) );
511
+ }
512
+
513
  /**
514
  * Generate any additional rewrite rules
515
  *
bp-core/bp-core-cssjs.php CHANGED
@@ -1,8 +1,17 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  // Exit if accessed directly
4
  if ( !defined( 'ABSPATH' ) ) exit;
5
 
 
 
 
6
  function bp_core_confirmation_js() {
7
 
8
  if ( is_multisite() && ! bp_is_root_blog() )
@@ -29,11 +38,7 @@ add_action( 'wp_head', 'bp_core_confirmation_js', 100 );
29
  add_action( 'admin_head', 'bp_core_confirmation_js', 100 );
30
 
31
  /**
32
- * bp_core_add_jquery_cropper()
33
- *
34
- * Makes sure the jQuery jCrop library is loaded.
35
- *
36
- * @package BuddyPress Core
37
  */
38
  function bp_core_add_jquery_cropper() {
39
  wp_enqueue_style( 'jcrop' );
@@ -43,11 +48,7 @@ function bp_core_add_jquery_cropper() {
43
  }
44
 
45
  /**
46
- * bp_core_add_cropper_inline_js()
47
- *
48
- * Adds the inline JS needed for the cropper to work on a per-page basis.
49
- *
50
- * @package BuddyPress Core
51
  */
52
  function bp_core_add_cropper_inline_js() {
53
 
@@ -68,8 +69,8 @@ function bp_core_add_cropper_inline_js() {
68
  }
69
 
70
  // Default cropper coordinates
71
- $crop_left = $image[0] / 4;
72
- $crop_top = $image[1] / 4;
73
  $crop_right = $image[0] - $crop_left;
74
  $crop_bottom = $image[1] - $crop_top; ?>
75
 
@@ -113,9 +114,7 @@ function bp_core_add_cropper_inline_js() {
113
  }
114
 
115
  /**
116
- * bp_core_add_cropper_inline_css()
117
- *
118
- * Adds the inline CSS needed for the cropper to work on a per-page basis.
119
  *
120
  * @package BuddyPress Core
121
  */
@@ -137,9 +136,9 @@ function bp_core_add_cropper_inline_css() {
137
  }
138
 
139
  /**
140
- * Adds AJAX target URL so themes can access the WordPress AJAX functionality.
141
  *
142
- * @since BuddyPress (1.1)
143
  */
144
  function bp_core_add_ajax_url_js() {
145
  ?>
@@ -151,14 +150,14 @@ function bp_core_add_ajax_url_js() {
151
  add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
152
 
153
  /**
154
- * Returns the proper value for BP's ajaxurl
155
  *
156
  * Designed to be sensitive to FORCE_SSL_ADMIN and non-standard multisite
157
  * configurations.
158
  *
159
- * @since BuddyPress (1.7)
160
  *
161
- * @return string
162
  */
163
  function bp_core_ajax_url() {
164
  return apply_filters( 'bp_core_ajax_url', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
1
  <?php
2
+ /**
3
+ * Core component CSS & JS.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Core
7
+ */
8
 
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
+ /**
13
+ * Load the JS for "Are you sure?" .confirm links.
14
+ */
15
  function bp_core_confirmation_js() {
16
 
17
  if ( is_multisite() && ! bp_is_root_blog() )
38
  add_action( 'admin_head', 'bp_core_confirmation_js', 100 );
39
 
40
  /**
41
+ * Enqueues jCrop library and hooks BP's custom cropper JS.
 
 
 
 
42
  */
43
  function bp_core_add_jquery_cropper() {
44
  wp_enqueue_style( 'jcrop' );
48
  }
49
 
50
  /**
51
+ * Output the inline JS needed for the cropper to work on a per-page basis.
 
 
 
 
52
  */
53
  function bp_core_add_cropper_inline_js() {
54
 
69
  }
70
 
71
  // Default cropper coordinates
72
+ $crop_left = round( $image[0] / 4 );
73
+ $crop_top = round( $image[1] / 4 );
74
  $crop_right = $image[0] - $crop_left;
75
  $crop_bottom = $image[1] - $crop_top; ?>
76
 
114
  }
115
 
116
  /**
117
+ * Output the inline CSS for the BP image cropper.
 
 
118
  *
119
  * @package BuddyPress Core
120
  */
136
  }
137
 
138
  /**
139
+ * Define the 'ajaxurl' JS variable, used by themes as an AJAX endpoint.
140
  *
141
+ * @since BuddyPress (1.1.0)
142
  */
143
  function bp_core_add_ajax_url_js() {
144
  ?>
150
  add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
151
 
152
  /**
153
+ * Get the proper value for BP's ajaxurl.
154
  *
155
  * Designed to be sensitive to FORCE_SSL_ADMIN and non-standard multisite
156
  * configurations.
157
  *
158
+ * @since BuddyPress (1.7.0)
159
  *
160
+ * @return string AJAX endpoint URL.
161
  */
162
  function bp_core_ajax_url() {
163
  return apply_filters( 'bp_core_ajax_url', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
bp-core/bp-core-dependency.php CHANGED
@@ -1,52 +1,52 @@
1
  <?php
2
 
3
  /**
4
- * Plugin Dependency
5
  *
6
  * The purpose of the following hooks is to mimic the behavior of something
7
  * called 'plugin dependency' which enables a plugin to have plugins of their
8
  * own in a safe and reliable way.
9
  *
10
- * We do this in BuddyPress by mirroring existing WordPress hookss in many places
11
  * allowing dependant plugins to hook into the BuddyPress specific ones, thus
12
  * guaranteeing proper code execution only when BuddyPress is active.
13
  *
14
- * The following functions are wrappers for hookss, allowing them to be
15
  * manually called and/or piggy-backed on top of other hooks if needed.
16
  *
17
  * @todo use anonymous functions when PHP minimun requirement allows (5.3)
18
  */
19
 
20
  /**
21
- * Include files on this action
22
  */
23
  function bp_include() {
24
  do_action( 'bp_include' );
25
  }
26
 
27
  /**
28
- * Include files on this action
29
  */
30
  function bp_setup_components() {
31
  do_action( 'bp_setup_components' );
32
  }
33
 
34
  /**
35
- * Setup global variables and objects
36
  */
37
  function bp_setup_globals() {
38
  do_action( 'bp_setup_globals' );
39
  }
40
 
41
  /**
42
- * Set navigation elements
43
  */
44
  function bp_setup_nav() {
45
  do_action( 'bp_setup_nav' );
46
  }
47
 
48
  /**
49
- * Set up BuddyPress implementation of the WP Toolbar
50
  */
51
  function bp_setup_admin_bar() {
52
  if ( bp_use_wp_admin_bar() )
@@ -54,24 +54,24 @@ function bp_setup_admin_bar() {
54
  }
55
 
56
  /**
57
- * Set the page title
58
  */
59
  function bp_setup_title() {
60
  do_action( 'bp_setup_title' );
61
  }
62
 
63
  /**
64
- * Register widgets
65
  */
66
  function bp_setup_widgets() {
67
  do_action( 'bp_register_widgets' );
68
  }
69
 
70
  /**
71
- * Setup the currently logged-in user
72
  *
73
- * @uses did_action() To make sure the user isn't loaded out of order
74
- * @uses do_action() Calls 'bp_setup_current_user'
75
  */
76
  function bp_setup_current_user() {
77
 
@@ -85,49 +85,63 @@ function bp_setup_current_user() {
85
  }
86
 
87
  /**
88
- * Initlialize code
89
  */
90
  function bp_init() {
91
  do_action( 'bp_init' );
92
  }
93
 
94
  /**
95
- * Attached to plugins_loaded
 
 
96
  */
97
  function bp_loaded() {
98
  do_action( 'bp_loaded' );
99
  }
100
 
101
  /**
102
- * Attached to wp
 
 
103
  */
104
  function bp_ready() {
105
  do_action( 'bp_ready' );
106
  }
107
 
108
  /**
109
- * Attach potential template actions
 
 
 
110
  */
111
  function bp_actions() {
112
  do_action( 'bp_actions' );
113
  }
114
 
115
  /**
116
- * Attach potential template screens
 
 
 
117
  */
118
  function bp_screens() {
119
  do_action( 'bp_screens' );
120
  }
121
 
122
  /**
123
- * Initialize widgets
 
 
124
  */
125
  function bp_widgets_init() {
126
  do_action ( 'bp_widgets_init' );
127
  }
128
 
129
  /**
130
- * BuddyPress head scripts
 
 
131
  */
132
  function bp_head() {
133
  do_action ( 'bp_head' );
@@ -136,10 +150,13 @@ function bp_head() {
136
  /** Theme Permissions *********************************************************/
137
 
138
  /**
139
- * The main action used for redirecting BuddyPress theme actions that are not
140
- * permitted by the current_user
 
 
 
141
  *
142
- * @since BuddyPress (1.6)
143
  *
144
  * @uses do_action()
145
  */
@@ -150,9 +167,12 @@ function bp_template_redirect() {
150
  /** Theme Helpers *************************************************************/
151
 
152
  /**
153
- * The main action used registering theme directory
 
 
 
 
154
  *
155
- * @since BuddyPress (1.5)
156
  * @uses do_action()
157
  */
158
  function bp_register_theme_directory() {
@@ -160,9 +180,12 @@ function bp_register_theme_directory() {
160
  }
161
 
162
  /**
163
- * The main action used registering theme packages
 
 
 
 
164
  *
165
- * @since BuddyPress (1.7)
166
  * @uses do_action()
167
  */
168
  function bp_register_theme_packages() {
@@ -170,49 +193,76 @@ function bp_register_theme_packages() {
170
  }
171
 
172
  /**
173
- * Enqueue BuddyPress specific CSS and JS
174
  *
175
- * @since BuddyPress (1.6)
176
  *
177
- * @uses do_action() Calls 'bp_enqueue_scripts'
178
  */
179
  function bp_enqueue_scripts() {
180
  do_action ( 'bp_enqueue_scripts' );
181
  }
182
 
183
  /**
184
- * Add the BuddyPress-specific rewrite tags
185
  *
186
- * @since BuddyPress (1.8)
187
- * @uses do_action() Calls 'bp_add_rewrite_tags'
 
188
  */
189
  function bp_add_rewrite_tags() {
190
  do_action( 'bp_add_rewrite_tags' );
191
  }
192
 
193
  /**
194
- * Piggy back action for BuddyPress sepecific theme actions before the theme has
195
- * been setup and the theme's functions.php has loaded.
196
  *
197
- * @since BuddyPress (1.6)
198
  *
199
- * @uses do_action() Calls 'bp_setup_theme'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  */
201
  function bp_setup_theme() {
202
  do_action ( 'bp_setup_theme' );
203
  }
204
 
205
  /**
206
- * Piggy back action for BuddyPress sepecific theme actions once the theme has
207
- * been setup and the theme's functions.php has loaded.
 
 
208
  *
209
  * Hooked to 'after_setup_theme' with a priority of 100. This allows plenty of
210
  * time for other themes to load their features, such as BuddyPress support,
211
  * before our theme compatibility layer kicks in.
212
  *
213
- * @since BuddyPress (1.6)
214
  *
215
- * @uses do_action() Calls 'bp_after_setup_theme'
216
  */
217
  function bp_after_setup_theme() {
218
  do_action ( 'bp_after_setup_theme' );
@@ -221,61 +271,120 @@ function bp_after_setup_theme() {
221
  /** Theme Compatibility Filter ************************************************/
222
 
223
  /**
224
- * Piggy back filter for WordPress's 'request' filter
 
 
225
  *
226
- * @since BuddyPress (1.7)
227
- * @param array $query_vars
228
- * @return array
 
229
  */
230
  function bp_request( $query_vars = array() ) {
231
  return apply_filters( 'bp_request', $query_vars );
232
  }
233
 
234
  /**
235
- * Piggy back filter to handle login redirects.
236
  *
237
- * @since BuddyPress (1.7)
238
  *
239
- * @param string $redirect_to
240
- * @param string $redirect_to_raw
241
- * @param string $user
242
  */
243
  function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = false ) {
244
  return apply_filters( 'bp_login_redirect', $redirect_to, $redirect_to_raw, $user );
245
  }
246
 
247
  /**
248
- * The main filter used for theme compatibility and displaying custom BuddyPress
249
- * theme files.
 
250
  *
251
- * @since BuddyPress (1.6)
252
  *
253
  * @uses apply_filters()
254
  *
255
- * @param string $template
256
- * @return string Template file to use
257
  */
258
  function bp_template_include( $template = '' ) {
259
  return apply_filters( 'bp_template_include', $template );
260
  }
261
 
262
  /**
263
- * Generate BuddyPress-specific rewrite rules
 
 
 
 
264
  *
265
- * @since BuddyPress (1.7)
266
- * @param WP_Rewrite $wp_rewrite
267
- * @uses do_action() Calls 'bp_generate_rewrite_rules' with {@link WP_Rewrite}
268
  */
269
  function bp_generate_rewrite_rules( $wp_rewrite ) {
270
  do_action_ref_array( 'bp_generate_rewrite_rules', array( &$wp_rewrite ) );
271
  }
272
 
273
  /**
274
- * Filter the allowed themes list for BuddyPress specific themes
275
  *
276
- * @since BuddyPress (1.7)
277
- * @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list
 
 
 
278
  */
279
  function bp_allowed_themes( $themes ) {
280
  return apply_filters( 'bp_allowed_themes', $themes );
281
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
  /**
4
+ * Plugin Dependency Action Hooks.
5
  *
6
  * The purpose of the following hooks is to mimic the behavior of something
7
  * called 'plugin dependency' which enables a plugin to have plugins of their
8
  * own in a safe and reliable way.
9
  *
10
+ * We do this in BuddyPress by mirroring existing WordPress hooks in many places
11
  * allowing dependant plugins to hook into the BuddyPress specific ones, thus
12
  * guaranteeing proper code execution only when BuddyPress is active.
13
  *
14
+ * The following functions are wrappers for hooks, allowing them to be
15
  * manually called and/or piggy-backed on top of other hooks if needed.
16
  *
17
  * @todo use anonymous functions when PHP minimun requirement allows (5.3)
18
  */
19
 
20
  /**
21
+ * Fire the 'bp_include' action, where plugins should include files.
22
  */
23
  function bp_include() {
24
  do_action( 'bp_include' );
25
  }
26
 
27
  /**
28
+ * Fire the 'bp_setup_components' action, where plugins should initialize components.
29
  */
30
  function bp_setup_components() {
31
  do_action( 'bp_setup_components' );
32
  }
33
 
34
  /**
35
+ * Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
36
  */
37
  function bp_setup_globals() {
38
  do_action( 'bp_setup_globals' );
39
  }
40
 
41
  /**
42
+ * Fire the 'bp_setup_nav' action, where plugins should register their navigation items.
43
  */
44
  function bp_setup_nav() {
45
  do_action( 'bp_setup_nav' );
46
  }
47
 
48
  /**
49
+ * Fire the 'bp_setup_admin_bar' action, where plugins should add items to the WP admin bar.
50
  */
51
  function bp_setup_admin_bar() {
52
  if ( bp_use_wp_admin_bar() )
54
  }
55
 
56
  /**
57
+ * Fire the 'bp_setup_title' action, where plugins should modify the page title.
58
  */
59
  function bp_setup_title() {
60
  do_action( 'bp_setup_title' );
61
  }
62
 
63
  /**
64
+ * Fire the 'bp_register_widgets' action, where plugins should register widgets.
65
  */
66
  function bp_setup_widgets() {
67
  do_action( 'bp_register_widgets' );
68
  }
69
 
70
  /**
71
+ * Set up the currently logged-in user.
72
  *
73
+ * @uses did_action() To make sure the user isn't loaded out of order.
74
+ * @uses do_action() Calls 'bp_setup_current_user'.
75
  */
76
  function bp_setup_current_user() {
77
 
85
  }
86
 
87
  /**
88
+ * Fire the 'bp_init' action, BuddyPress's main initialization hook.
89
  */
90
  function bp_init() {
91
  do_action( 'bp_init' );
92
  }
93
 
94
  /**
95
+ * Fire the 'bp_loaded' action, which fires after BP's core plugin files have been loaded.
96
+ *
97
+ * Attached to 'plugins_loaded'.
98
  */
99
  function bp_loaded() {
100
  do_action( 'bp_loaded' );
101
  }
102
 
103
  /**
104
+ * Fire the 'bp_ready' action, which runs after BP is set up and the page is about to render.
105
+ *
106
+ * Attached to 'wp'.
107
  */
108
  function bp_ready() {
109
  do_action( 'bp_ready' );
110
  }
111
 
112
  /**
113
+ * Fire the 'bp_actions' action, which runs just before rendering.
114
+ *
115
+ * Attach potential template actions, such as catching form requests or routing
116
+ * custom URLs.
117
  */
118
  function bp_actions() {
119
  do_action( 'bp_actions' );
120
  }
121
 
122
  /**
123
+ * Fire the 'bp_screens' action, which runs just before rendering.
124
+ *
125
+ * Runs just after 'bp_actions'. Use this hook to attach your template
126
+ * loaders.
127
  */
128
  function bp_screens() {
129
  do_action( 'bp_screens' );
130
  }
131
 
132
  /**
133
+ * Fire 'bp_widgets_init', which runs after widgets have been set up.
134
+ *
135
+ * Hooked to 'widgets_init'.
136
  */
137
  function bp_widgets_init() {
138
  do_action ( 'bp_widgets_init' );
139
  }
140
 
141
  /**
142
+ * Fire 'bp_head', which is used to hook scripts and styles in the <head>.
143
+ *
144
+ * Hooked to 'wp_head'.
145
  */
146
  function bp_head() {
147
  do_action ( 'bp_head' );
150
  /** Theme Permissions *********************************************************/
151
 
152
  /**
153
+ * Fire the 'bp_template_redirect' action.
154
+ *
155
+ * Run at 'template_redirect', just before WordPress selects and loads a theme
156
+ * template. The main purpose of this hook in BuddyPress is to redirect users
157
+ * who do not have the proper permission to access certain content.
158
  *
159
+ * @since BuddyPress (1.6.0)
160
  *
161
  * @uses do_action()
162
  */
167
  /** Theme Helpers *************************************************************/
168
 
169
  /**
170
+ * Fire the 'bp_register_theme_directory' action.
171
+ *
172
+ * The main action used registering theme directories.
173
+ *
174
+ * @since BuddyPress (1.5.0)
175
  *
 
176
  * @uses do_action()
177
  */
178
  function bp_register_theme_directory() {
180
  }
181
 
182
  /**
183
+ * Fire the 'bp_register_theme_packages' action.
184
+ *
185
+ * The main action used registering theme packages.
186
+ *
187
+ * @since BuddyPress (1.7.0)
188
  *
 
189
  * @uses do_action()
190
  */
191
  function bp_register_theme_packages() {
193
  }
194
 
195
  /**
196
+ * Fire the 'bp_enqueue_scripts' action, where BP enqueues its CSS and JS.
197
  *
198
+ * @since BuddyPress (1.6.0)
199
  *
200
+ * @uses do_action() Calls 'bp_enqueue_scripts'.
201
  */
202
  function bp_enqueue_scripts() {
203
  do_action ( 'bp_enqueue_scripts' );
204
  }
205
 
206
  /**
207
+ * Fire the 'bp_add_rewrite_tag' action, where BP adds its custom rewrite tags.
208
  *
209
+ * @since BuddyPress (1.8.0)
210
+ *
211
+ * @uses do_action() Calls 'bp_add_rewrite_tags'.
212
  */
213
  function bp_add_rewrite_tags() {
214
  do_action( 'bp_add_rewrite_tags' );
215
  }
216
 
217
  /**
218
+ * Fire the 'bp_add_rewrite_rules' action, where BP adds its custom rewrite rules.
 
219
  *
220
+ * @since BuddyPress (1.9.0)
221
  *
222
+ * @uses do_action() Calls 'bp_add_rewrite_rules'.
223
+ */
224
+ function bp_add_rewrite_rules() {
225
+ do_action( 'bp_add_rewrite_rules' );
226
+ }
227
+
228
+ /**
229
+ * Fire the 'bp_add_permastructs' action, where BP adds its BP-specific permalink structure.
230
+ *
231
+ * @since BuddyPress (1.9.0)
232
+ *
233
+ * @uses do_action() Calls 'bp_add_permastructs'.
234
+ */
235
+ function bp_add_permastructs() {
236
+ do_action( 'bp_add_permastructs' );
237
+ }
238
+
239
+ /**
240
+ * Fire the 'bp_setup_theme' action.
241
+ *
242
+ * The main purpose of 'bp_setup_theme' is give themes a place to load their
243
+ * BuddyPress-specific functionality.
244
+ *
245
+ * @since BuddyPress (1.6.0)
246
+ *
247
+ * @uses do_action() Calls 'bp_setup_theme'.
248
  */
249
  function bp_setup_theme() {
250
  do_action ( 'bp_setup_theme' );
251
  }
252
 
253
  /**
254
+ * Fire the 'bp_after_setup_theme' action.
255
+ *
256
+ * Piggy-back action for BuddyPress-specific theme actions once the theme has
257
+ * been set up and the theme's functions.php has loaded.
258
  *
259
  * Hooked to 'after_setup_theme' with a priority of 100. This allows plenty of
260
  * time for other themes to load their features, such as BuddyPress support,
261
  * before our theme compatibility layer kicks in.
262
  *
263
+ * @since BuddyPress (1.6.0)
264
  *
265
+ * @uses do_action() Calls 'bp_after_setup_theme'.
266
  */
267
  function bp_after_setup_theme() {
268
  do_action ( 'bp_after_setup_theme' );
271
  /** Theme Compatibility Filter ************************************************/
272
 
273
  /**
274
+ * Fire the 'bp_request' filter, a piggy-back of WP's 'request'.
275
+ *
276
+ * @since BuddyPress (1.7.0)
277
  *
278
+ * @see WP::parse_request() for a description of parameters.
279
+ *
280
+ * @param array $query_vars See {@link WP::parse_request()}.
281
+ * @return array $query_vars See {@link WP::parse_request()}.
282
  */
283
  function bp_request( $query_vars = array() ) {
284
  return apply_filters( 'bp_request', $query_vars );
285
  }
286
 
287
  /**
288
+ * Fire the 'bp_login_redirect' filter, a piggy-back of WP's 'login_redirect'.
289
  *
290
+ * @since BuddyPress (1.7.0)
291
  *
292
+ * @param string $redirect_to See 'login_redirect'.
293
+ * @param string $redirect_to_raw See 'login_redirect'.
294
+ * @param string $user See 'login_redirect'.
295
  */
296
  function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = false ) {
297
  return apply_filters( 'bp_login_redirect', $redirect_to, $redirect_to_raw, $user );
298
  }
299
 
300
  /**
301
+ * Fire 'bp_template_include', main filter used for theme compatibility and displaying custom BP theme files.
302
+ *
303
+ * Hooked to 'template_include'.
304
  *
305
+ * @since BuddyPress (1.6.0)
306
  *
307
  * @uses apply_filters()
308
  *
309
+ * @param string $template See 'template_include'.
310
+ * @return string Template file to use.
311
  */
312
  function bp_template_include( $template = '' ) {
313
  return apply_filters( 'bp_template_include', $template );
314
  }
315
 
316
  /**
317
+ * Fire the 'bp_generate_rewrite_rules' filter, where BP generates its rewrite rules.
318
+ *
319
+ * @since BuddyPress (1.7.0)
320
+ *
321
+ * @uses do_action() Calls 'bp_generate_rewrite_rules' with {@link WP_Rewrite}.
322
  *
323
+ * @param WP_Rewrite $wp_rewrite See 'generate_rewrite_rules'.
 
 
324
  */
325
  function bp_generate_rewrite_rules( $wp_rewrite ) {
326
  do_action_ref_array( 'bp_generate_rewrite_rules', array( &$wp_rewrite ) );
327
  }
328
 
329
  /**
330
+ * Fire the 'bp_allowed_themes' filter.
331
  *
332
+ * Filter the allowed themes list for BuddyPress-specific themes.
333
+ *
334
+ * @since BuddyPress (1.7.0)
335
+ *
336
+ * @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list.
337
  */
338
  function bp_allowed_themes( $themes ) {
339
  return apply_filters( 'bp_allowed_themes', $themes );
340
  }
341
+
342
+ /** Requests ******************************************************************/
343
+
344
+ /**
345
+ * The main action used for handling theme-side POST requests
346
+ *
347
+ * @since BuddyPress (1.9.0)
348
+ * @uses do_action()
349
+ */
350
+ function bp_post_request() {
351
+
352
+ // Bail if not a POST action
353
+ if ( ! bp_is_post_request() )
354
+ return;
355
+
356
+ // Bail if no action
357
+ if ( empty( $_POST['action'] ) )
358
+ return;
359
+
360
+ // This dynamic action is probably the one you want to use. It narrows down
361
+ // the scope of the 'action' without needing to check it in your function.
362
+ do_action( 'bp_post_request_' . $_POST['action'] );
363
+
364
+ // Use this static action if you don't mind checking the 'action' yourself.
365
+ do_action( 'bp_post_request', $_POST['action'] );
366
+ }
367
+
368
+ /**
369
+ * The main action used for handling theme-side GET requests
370
+ *
371
+ * @since BuddyPress (1.9.0)
372
+ * @uses do_action()
373
+ */
374
+ function bp_get_request() {
375
+
376
+ // Bail if not a POST action
377
+ if ( ! bp_is_get_request() )
378
+ return;
379
+
380
+ // Bail if no action
381
+ if ( empty( $_GET['action'] ) )
382
+ return;
383
+
384
+ // This dynamic action is probably the one you want to use. It narrows down
385
+ // the scope of the 'action' without needing to check it in your function.
386
+ do_action( 'bp_get_request_' . $_GET['action'] );
387
+
388
+ // Use this static action if you don't mind checking the 'action' yourself.
389
+ do_action( 'bp_get_request', $_GET['action'] );
390
+ }
bp-core/bp-core-filters.php CHANGED
@@ -1,16 +1,13 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Filters
5
  *
6
- * @package BuddyPress
7
- * @subpackage Core
8
- *
9
- * This file contains the filters that are used through-out BuddyPress. They are
10
  * consolidated here to make searching for them easier, and to help developers
11
  * understand at a glance the order in which things occur.
12
  *
13
- * There are a few common places that additional filters can currently be found
14
  *
15
  * - BuddyPress: In {@link BuddyPress::setup_actions()} in buddypress.php
16
  * - Component: In {@link BP_Component::setup_actions()} in
@@ -18,6 +15,8 @@
18
  * - Admin: More in {@link BP_Admin::setup_actions()} in
19
  * bp-core/bp-core-admin.php
20
  *
 
 
21
  * @see bp-core-actions.php
22
  */
23
 
@@ -25,7 +24,7 @@
25
  if ( !defined( 'ABSPATH' ) ) exit;
26
 
27
  /**
28
- * Attach BuddyPress to WordPress
29
  *
30
  * BuddyPress uses its own internal actions to help aid in third-party plugin
31
  * development, and to limit the amount of potential future code changes when
@@ -54,7 +53,7 @@ add_filter( 'bp_core_render_message_content', 'shortcode_unautop' );
54
  add_filter( 'bp_core_render_message_content', 'wp_kses_data', 5 );
55
 
56
  /**
57
- * Template Compatibility
58
  *
59
  * If you want to completely bypass this and manage your own custom BuddyPress
60
  * template hierarchy, start here by removing this filter, then look at how
@@ -70,13 +69,13 @@ add_filter( 'bp_get_template_stack', 'bp_add_template_stack_locations'
70
  add_filter( 'comments_open', 'bp_comments_open', 10, 2 );
71
 
72
  /**
73
- * bp_core_exclude_pages()
74
- *
75
- * Excludes specific pages from showing on page listings, for example the "Activation" page.
76
  *
77
- * @package BuddyPress Core
78
  * @uses bp_is_active() checks if a BuddyPress component is active.
79
- * @return array The list of page ID's to exclude
 
 
 
80
  */
81
  function bp_core_exclude_pages( $pages = array() ) {
82
 
@@ -100,13 +99,11 @@ function bp_core_exclude_pages( $pages = array() ) {
100
  add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
101
 
102
  /**
103
- * bp_core_email_from_name_filter()
104
  *
105
- * Sets the "From" name in emails sent to the name of the site and not "WordPress"
106
  *
107
- * @package BuddyPress Core
108
- * @uses bp_get_option() fetches the value for a meta_key in the wp_X_options table
109
- * @return string The blog name for the root blog
110
  */
111
  function bp_core_email_from_name_filter() {
112
  return apply_filters( 'bp_core_email_from_name_filter', bp_get_option( 'blogname', 'WordPress' ) );
@@ -114,11 +111,11 @@ function bp_core_email_from_name_filter() {
114
  add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
115
 
116
  /**
117
- * bp_core_filter_comments()
118
- *
119
  * Filter the blog post comments array and insert BuddyPress URLs for users.
120
  *
121
- * @package BuddyPress Core
 
 
122
  */
123
  function bp_core_filter_comments( $comments, $post_id ) {
124
  global $wpdb;
@@ -151,17 +148,17 @@ function bp_core_filter_comments( $comments, $post_id ) {
151
  add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
152
 
153
  /**
154
- * When a user logs in, redirect him in a logical way
155
  *
156
- * @package BuddyPress Core
 
157
  *
158
- * @uses apply_filters Filter bp_core_login_redirect to modify where users are redirected to on
159
- * login
160
- * @param string $redirect_to The URL to be redirected to, sanitized in wp-login.php
161
  * @param string $redirect_to_raw The unsanitized redirect_to URL ($_REQUEST['redirect_to'])
162
- * @param WP_User $user The WP_User object corresponding to a successfully logged-in user. Otherwise
163
- * a WP_Error object
164
- * @return string The redirect URL
165
  */
166
  function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
167
 
@@ -192,19 +189,22 @@ function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
192
  return wp_get_referer();
193
  }
194
 
195
- return bp_get_root_domain();
196
  }
197
  add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
198
 
199
- /***
200
- * bp_core_filter_user_welcome_email()
201
  *
202
- * Replace the generated password in the welcome email.
203
- * This will not filter when the site admin registers a user.
 
204
  *
205
- * @uses locate_template To see if custom registration files exist
206
- * @param string $welcome_email Complete email passed through WordPress
207
- * @return string Filtered $welcome_email with 'PASSWORD' replaced by [User Set]
 
 
208
  */
209
  function bp_core_filter_user_welcome_email( $welcome_email ) {
210
 
@@ -217,18 +217,20 @@ function bp_core_filter_user_welcome_email( $welcome_email ) {
217
  }
218
  add_filter( 'update_welcome_user_email', 'bp_core_filter_user_welcome_email' );
219
 
220
- /***
221
- * bp_core_filter_blog_welcome_email()
222
  *
223
- * Replace the generated password in the welcome email.
224
- * This will not filter when the site admin registers a user.
 
225
  *
226
- * @uses locate_template To see if custom registration files exist
227
- * @param string $welcome_email Complete email passed through WordPress
228
- * @param integer $blog_id ID of the blog user is joining
229
- * @param integer $user_id ID of the user joining
230
- * @param string $password Password of user
231
- * @return string Filtered $welcome_email with $password replaced by [User Set]
 
232
  */
233
  function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
234
 
@@ -241,29 +243,44 @@ function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id,
241
  }
242
  add_filter( 'update_welcome_email', 'bp_core_filter_blog_welcome_email', 10, 4 );
243
 
244
- // Notify user of signup success.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
246
 
247
- // Send email with activation link.
248
  $activate_url = bp_get_activation_page() ."?key=$key";
249
  $activate_url = esc_url( $activate_url );
250
 
251
- $admin_email = get_site_option( 'admin_email' );
 
 
252
 
253
- if ( empty( $admin_email ) )
254
- $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
 
 
255
 
256
- $from_name = bp_get_option( 'blogname', 'WordPress' );
257
- $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option( 'blog_charset' ) . "\"\n";
258
- $message = sprintf( __( "Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%1\$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%2\$s", 'buddypress' ), $activate_url, esc_url( "http://{$domain}{$path}" ) );
259
- $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
260
 
261
- // Send the message
262
- $to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email, $domain, $path, $title, $user, $user_email, $key, $meta );
263
- $subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject, $domain, $path, $title, $user, $user_email, $key, $meta );
264
- $message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message, $domain, $path, $title, $user, $user_email, $key, $meta );
265
-
266
- wp_mail( $to, $subject, $message, $message_headers );
267
 
268
  do_action( 'bp_core_sent_blog_signup_email', $admin_email, $subject, $message, $domain, $path, $title, $user, $user_email, $key, $meta );
269
 
@@ -272,26 +289,37 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
272
  }
273
  add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_notification', 1, 7 );
274
 
 
 
 
 
 
 
 
 
 
 
 
275
  function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
276
 
 
277
  $activate_url = bp_get_activation_page() . "?key=$key";
278
- $activate_url = esc_url($activate_url);
279
- $admin_email = get_site_option( 'admin_email' );
280
-
281
- if ( empty( $admin_email ) )
282
- $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
283
 
284
- $from_name = bp_get_option( 'blogname', 'WordPress' );
285
- $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option( 'blog_charset' ) . "\"\n";
286
- $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
287
- $subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
288
 
289
- // Send the message
290
  $to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta );
291
  $subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta );
292
  $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta );
293
 
294
- wp_mail( $to, $subject, $message, $message_headers );
 
 
 
 
295
 
296
  do_action( 'bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta );
297
 
@@ -301,15 +329,17 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
301
  add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
302
 
303
  /**
304
- * Filter the page title for BuddyPress pages
 
 
305
  *
306
- * @global object $bp BuddyPress global settings
307
- * @param string $title Original page title
308
- * @param string $sep How to separate the various items within the page title.
309
- * @param string $seplocation Direction to display title
310
- * @return string new page title
311
  * @see wp_title()
312
- * @since BuddyPress (1.5)
 
 
 
 
 
313
  */
314
  function bp_modify_page_title( $title, $sep, $seplocation ) {
315
  global $bp;
@@ -387,3 +417,74 @@ add_filter( 'wp_title', 'bp_modify_page_title', 10, 3 );
387
  add_filter( 'bp_modify_page_title', 'wptexturize' );
388
  add_filter( 'bp_modify_page_title', 'convert_chars' );
389
  add_filter( 'bp_modify_page_title', 'esc_html' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Filters.
5
  *
6
+ * This file contains the filters that are used throughout BuddyPress. They are
 
 
 
7
  * consolidated here to make searching for them easier, and to help developers
8
  * understand at a glance the order in which things occur.
9
  *
10
+ * There are a few common places that additional filters can currently be found.
11
  *
12
  * - BuddyPress: In {@link BuddyPress::setup_actions()} in buddypress.php
13
  * - Component: In {@link BP_Component::setup_actions()} in
15
  * - Admin: More in {@link BP_Admin::setup_actions()} in
16
  * bp-core/bp-core-admin.php
17
  *
18
+ * @package BuddyPress
19
+ * @subpackage Core
20
  * @see bp-core-actions.php
21
  */
22
 
24
  if ( !defined( 'ABSPATH' ) ) exit;
25
 
26
  /**
27
+ * Attach BuddyPress to WordPress.
28
  *
29
  * BuddyPress uses its own internal actions to help aid in third-party plugin
30
  * development, and to limit the amount of potential future code changes when
53
  add_filter( 'bp_core_render_message_content', 'wp_kses_data', 5 );
54
 
55
  /**
56
+ * Template Compatibility.
57
  *
58
  * If you want to completely bypass this and manage your own custom BuddyPress
59
  * template hierarchy, start here by removing this filter, then look at how
69
  add_filter( 'comments_open', 'bp_comments_open', 10, 2 );
70
 
71
  /**
72
+ * Prevent specific pages (eg 'Activate') from showing on page listings.
 
 
73
  *
 
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() ) {
81
 
99
  add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
100
 
101
  /**
102
+ * Set "From" name in outgoing email to the site name.
103
  *
104
+ * @uses bp_get_option() fetches the value for a meta_key in the wp_X_options table.
105
  *
106
+ * @return string The blog name for the root blog.
 
 
107
  */
108
  function bp_core_email_from_name_filter() {
109
  return apply_filters( 'bp_core_email_from_name_filter', bp_get_option( 'blogname', 'WordPress' ) );
111
  add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
112
 
113
  /**
 
 
114
  * Filter the blog post comments array and insert BuddyPress URLs for users.
115
  *
116
+ * @param array $comments The array of comments supplied to the comments template.
117
+ * @param int $post->ID The post ID.
118
+ * @return array $comments The modified comment array.
119
  */
120
  function bp_core_filter_comments( $comments, $post_id ) {
121
  global $wpdb;
148
  add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
149
 
150
  /**
151
+ * When a user logs in, redirect him in a logical way.
152
  *
153
+ * @uses apply_filters() Filter 'bp_core_login_redirect' to modify where users
154
+ * are redirected to on login.
155
  *
156
+ * @param string $redirect_to The URL to be redirected to, sanitized
157
+ * in wp-login.php.
 
158
  * @param string $redirect_to_raw The unsanitized redirect_to URL ($_REQUEST['redirect_to'])
159
+ * @param WP_User $user The WP_User object corresponding to a successfully
160
+ * logged-in user. Otherwise a WP_Error object.
161
+ * @return string The redirect URL.
162
  */
163
  function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
164
 
189
  return wp_get_referer();
190
  }
191
 
192
+ return apply_filters( 'bp_core_login_redirect_to', bp_get_root_domain() );
193
  }
194
  add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
195
 
196
+ /**
197
+ * Replace the generated password in the welcome email with '[User Set]'.
198
  *
199
+ * On a standard BP installation, users who register themselves also set their
200
+ * own passwords. Therefore there is no need for the insecure practice of
201
+ * emailing the plaintext password to the user in the welcome email.
202
  *
203
+ * This filter will not fire when a user is registered by the site admin.
204
+ *
205
+ * @param string $welcome_email Complete email passed through WordPress.
206
+ * @return string Filtered $welcome_email with the password replaced
207
+ * by '[User Set]'.
208
  */
209
  function bp_core_filter_user_welcome_email( $welcome_email ) {
210
 
217
  }
218
  add_filter( 'update_welcome_user_email', 'bp_core_filter_user_welcome_email' );
219
 
220
+ /**
221
+ * Replace the generated password in the welcome email with '[User Set]'.
222
  *
223
+ * On a standard BP installation, users who register themselves also set their
224
+ * own passwords. Therefore there is no need for the insecure practice of
225
+ * emailing the plaintext password to the user in the welcome email.
226
  *
227
+ * This filter will not fire when a user is registered by the site admin.
228
+ *
229
+ * @param string $welcome_email Complete email passed through WordPress.
230
+ * @param int $blog_id ID of the blog user is joining.
231
+ * @param int $user_id ID of the user joining.
232
+ * @param string $password Password of user.
233
+ * @return string Filtered $welcome_email with $password replaced by '[User Set]'.
234
  */
235
  function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
236
 
243
  }
244
  add_filter( 'update_welcome_email', 'bp_core_filter_blog_welcome_email', 10, 4 );
245
 
246
+ /**
247
+ * Notify new users of a successful registration (with blog).
248
+ *
249
+ * This function filter's WP's 'wpmu_signup_blog_notification', and replaces
250
+ * WP's default welcome email with a BuddyPress-specific message.
251
+ *
252
+ * @see wpmu_signup_blog_notification() for a description of parameters.
253
+ *
254
+ * @param string $domain The new blog domain.
255
+ * @param string $path The new blog path.
256
+ * @param string $title The site title.
257
+ * @param string $user The user's login name.
258
+ * @param string $user_email The user's email address.
259
+ * @param string $key The activation key created in wpmu_signup_blog()
260
+ * @param array $meta By default, contains the requested privacy setting and
261
+ * lang_id.
262
+ * @return bool True on success, false on failure.
263
+ */
264
  function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
265
 
266
+ // Set up activation link
267
  $activate_url = bp_get_activation_page() ."?key=$key";
268
  $activate_url = esc_url( $activate_url );
269
 
270
+ // Email contents
271
+ $message = sprintf( __( "Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%1\$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%2\$s", 'buddypress' ), $activate_url, esc_url( "http://{$domain}{$path}" ) );
272
+ $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
273
 
274
+ // Email filters
275
+ $to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email, $domain, $path, $title, $user, $user_email, $key, $meta );
276
+ $subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject, $domain, $path, $title, $user, $user_email, $key, $meta );
277
+ $message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message, $domain, $path, $title, $user, $user_email, $key, $meta );
278
 
279
+ // Send the email
280
+ wp_mail( $to, $subject, $message );
 
 
281
 
282
+ // Set up the $admin_email to pass to the filter
283
+ $admin_email = bp_get_option( 'admin_email' );
 
 
 
 
284
 
285
  do_action( 'bp_core_sent_blog_signup_email', $admin_email, $subject, $message, $domain, $path, $title, $user, $user_email, $key, $meta );
286
 
289
  }
290
  add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_notification', 1, 7 );
291
 
292
+ /**
293
+ * Notify new users of a successful registration (without blog).
294
+ *
295
+ * @see wpmu_signup_user_notification() for a full description of params.
296
+ *
297
+ * @param string $user The user's login name.
298
+ * @param string $user_email The user's email address.
299
+ * @param string $key The activation key created in wpmu_signup_user()
300
+ * @param array $meta By default, an empty array.
301
+ * @return bool True on success, false on failure.
302
+ */
303
  function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
304
 
305
+ // Set up activation link
306
  $activate_url = bp_get_activation_page() . "?key=$key";
307
+ $activate_url = esc_url( $activate_url );
 
 
 
 
308
 
309
+ // Email contents
310
+ $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
311
+ $subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
 
312
 
313
+ // Email filters
314
  $to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta );
315
  $subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta );
316
  $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta );
317
 
318
+ // Send the email
319
+ wp_mail( $to, $subject, $message );
320
+
321
+ // Set up the $admin_email to pass to the filter
322
+ $admin_email = bp_get_option( 'admin_email' );
323
 
324
  do_action( 'bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta );
325
 
329
  add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
330
 
331
  /**
332
+ * Filter the page title for BuddyPress pages.
333
+ *
334
+ * @since BuddyPress (1.5.0)
335
  *
 
 
 
 
 
336
  * @see wp_title()
337
+ * @global object $bp BuddyPress global settings.
338
+ *
339
+ * @param string $title Original page title.
340
+ * @param string $sep How to separate the various items within the page title.
341
+ * @param string $seplocation Direction to display title.
342
+ * @return string New page title.
343
  */
344
  function bp_modify_page_title( $title, $sep, $seplocation ) {
345
  global $bp;
417
  add_filter( 'bp_modify_page_title', 'wptexturize' );
418
  add_filter( 'bp_modify_page_title', 'convert_chars' );
419
  add_filter( 'bp_modify_page_title', 'esc_html' );
420
+
421
+ /**
422
+ * Add BuddyPress-specific items to the wp_nav_menu.
423
+ *
424
+ * @since BuddyPress (1.9.0)
425
+ *
426
+ * @param WP_Post $menu_item The menu item.
427
+ * @return obj The modified WP_Post object.
428
+ */
429
+ function bp_setup_nav_menu_item( $menu_item ) {
430
+ if ( is_admin() ) {
431
+ return $menu_item;
432
+ }
433
+
434
+ // We use information stored in the CSS class to determine what kind of
435
+ // menu item this is, and how it should be treated
436
+ $css_target = preg_match( '/\sbp-(.*)-nav/', implode( ' ', $menu_item->classes), $matches );
437
+
438
+ // If this isn't a BP menu item, we can stop here
439
+ if ( empty( $matches[1] ) ) {
440
+ return $menu_item;
441
+ }
442
+
443
+ switch ( $matches[1] ) {
444
+ case 'login' :
445
+ if ( is_user_logged_in() ) {
446
+ $menu_item->_invalid = true;
447
+ } else {
448
+ $menu_item->url = wp_login_url( wp_guess_url() );
449
+ }
450
+
451
+ break;
452
+
453
+ case 'logout' :
454
+ if ( ! is_user_logged_in() ) {
455
+ $menu_item->_invalid = true;
456
+ } else {
457
+ $menu_item->url = wp_logout_url( wp_guess_url() );
458
+ }
459
+
460
+ break;
461
+
462
+ // Don't show the Register link to logged-in users
463
+ case 'register' :
464
+ if ( is_user_logged_in() ) {
465
+ $menu_item->_invalid = true;
466
+ }
467
+
468
+ break;
469
+
470
+ // All other BP nav items are specific to the logged-in user,
471
+ // and so are not relevant to logged-out users
472
+ default:
473
+ if ( is_user_logged_in() ) {
474
+ $menu_item->url = bp_nav_menu_get_item_url( $matches[1] );
475
+ } else {
476
+ $menu_item->_invalid = true;
477
+ }
478
+
479
+ break;
480
+ }
481
+
482
+ // Highlight the current page
483
+ $current = bp_get_requested_url();
484
+ if ( strpos( $current, $menu_item->url ) !== false ) {
485
+ $menu_item->classes[] = 'current_page_item';
486
+ }
487
+
488
+ return $menu_item;
489
+ }
490
+ add_filter( 'wp_setup_nav_menu_item', 'bp_setup_nav_menu_item', 10, 1 );
bp-core/bp-core-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Common Functions
5
  *
6
  * @package BuddyPress
7
  * @subpackage Functions
@@ -13,48 +13,52 @@ if ( !defined( 'ABSPATH' ) ) exit;
13
  /** Versions ******************************************************************/
14
 
15
  /**
16
- * Output the BuddyPress version
17
  *
18
- * @since BuddyPress (1.6)
19
- * @uses bp_get_version() To get the BuddyPress version
 
20
  */
21
  function bp_version() {
22
  echo bp_get_version();
23
  }
24
  /**
25
- * Return the BuddyPress version
26
  *
27
- * @since BuddyPress (1.6)
28
- * @return string The BuddyPress version
 
29
  */
30
  function bp_get_version() {
31
  return buddypress()->version;
32
  }
33
 
34
  /**
35
- * Output the BuddyPress database version
36
  *
37
- * @since BuddyPress (1.6)
38
- * @uses bp_get_db_version() To get the BuddyPress version
 
39
  */
40
  function bp_db_version() {
41
  echo bp_get_db_version();
42
  }
43
  /**
44
- * Return the BuddyPress database version
45
  *
46
- * @since BuddyPress (1.6)
47
- * @return string The BuddyPress version
48
  */
49
  function bp_get_db_version() {
50
  return buddypress()->db_version;
51
  }
52
 
53
  /**
54
- * Output the BuddyPress database version
55
  *
56
- * @since BuddyPress (1.6)
57
- * @uses bp_get_db_version_raw() To get the current BuddyPress version
 
58
  */
59
  function bp_db_version_raw() {
60
  echo bp_get_db_version_raw();
@@ -63,7 +67,8 @@ function bp_db_version_raw() {
63
  * Return the BuddyPress database version
64
  *
65
  * @since BuddyPress (1.6)
66
- * @return string The BuddyPress version direct from the database
 
67
  */
68
  function bp_get_db_version_raw() {
69
  $bp = buddypress();
@@ -73,10 +78,13 @@ function bp_db_version_raw() {
73
  /** Functions *****************************************************************/
74
 
75
  /**
76
- * Allow filtering of database prefix. Intended for use in multinetwork installations.
 
 
77
  *
78
- * @global object $wpdb WordPress database object
79
- * @return string Filtered database prefix
 
80
  */
81
  function bp_core_get_table_prefix() {
82
  global $wpdb;
@@ -85,11 +93,57 @@ function bp_core_get_table_prefix() {
85
  }
86
 
87
  /**
88
- * Format numbers the BuddyPress way
 
 
 
 
 
 
 
89
  *
90
- * @param int $number
91
- * @param bool $decimals
92
- * @return string
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  */
94
  function bp_core_number_format( $number, $decimals = false ) {
95
 
@@ -131,9 +185,9 @@ function bp_core_number_format( $number, $decimals = false ) {
131
  * For the second argument, $func_args, you should just pass the value of func_get_args().
132
  *
133
  * @since BuddyPress (1.6)
134
- * @param array $old_args_keys
135
- * @param array $func_args
136
- * @return array $new_args
137
  */
138
  function bp_core_parse_args_array( $old_args_keys, $func_args ) {
139
  $new_args = array();
@@ -148,14 +202,15 @@ function bp_core_parse_args_array( $old_args_keys, $func_args ) {
148
  }
149
 
150
  /**
151
- * Sanitize an 'order' parameter for use in building SQL queries
152
  *
153
  * Strings like 'DESC', 'desc', ' desc' will be interpreted into 'DESC'.
154
  * Everything else becomes 'ASC'.
155
  *
156
- * @since BuddyPress (1.8)
157
- * @param string $order The 'order' string, as passed to the SQL constructor
158
- * @return string The sanitized value 'DESC' or 'ASC'
 
159
  */
160
  function bp_esc_sql_order( $order = '' ) {
161
  $order = strtoupper( trim( $order ) );
@@ -165,12 +220,13 @@ function bp_esc_sql_order( $order = '' ) {
165
  /**
166
  * Are we running username compatibility mode?
167
  *
168
- * @package BuddyPress
169
- * @since BuddyPress (1.5)
170
  *
171
- * @uses apply_filters() Filter 'bp_is_username_compatibility_mode' to alter
172
- * @return bool False when compatibility mode is disabled (default); true when enabled
173
  * @todo Move to members component?
 
 
 
174
  */
175
  function bp_is_username_compatibility_mode() {
176
  return apply_filters( 'bp_is_username_compatibility_mode', defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) && BP_ENABLE_USERNAME_COMPATIBILITY_MODE );
@@ -179,12 +235,15 @@ function bp_is_username_compatibility_mode() {
179
  /**
180
  * Should we use the WP Toolbar?
181
  *
182
- * The WP Toolbar, introduced in WP 3.1, is fully supported in BuddyPress as of BP 1.5.
183
- * For BP 1.6, the WP Toolbar is the default.
 
 
 
 
184
  *
185
- * @return bool False when WP Toolbar support is disabled; true when enabled (default)
186
- * @since BuddyPress (1.5)
187
- * @uses apply_filters() Filter 'bp_use_wp_admin_bar' to alter
188
  */
189
  function bp_use_wp_admin_bar() {
190
  $use_admin_bar = true;
@@ -203,10 +262,12 @@ function bp_use_wp_admin_bar() {
203
  /** Directory *****************************************************************/
204
 
205
  /**
206
- * Fetches BP pages from the meta table, depending on setup
207
  *
208
- * @package BuddyPress Core
209
- * @since BuddyPress (1.5)
 
 
210
  */
211
  function bp_core_get_directory_page_ids() {
212
  $page_ids = bp_get_option( 'bp-pages' );
@@ -224,27 +285,27 @@ function bp_core_get_directory_page_ids() {
224
  }
225
 
226
  /**
227
- * Stores BP pages in the meta table, depending on setup
228
  *
229
- * bp-pages data is stored in site_options (falls back to options on non-MS), in an array keyed by
230
- * blog_id. This allows you to change your bp_get_root_blog_id() and go through the setup process again.
 
231
  *
232
- * @package BuddyPress Core
233
- * @since BuddyPress (1.5)
234
  *
235
- * @param array $blog_page_ids The IDs of the WP pages corresponding to BP component directories
 
236
  */
237
  function bp_core_update_directory_page_ids( $blog_page_ids ) {
238
  bp_update_option( 'bp-pages', $blog_page_ids );
239
  }
240
 
241
  /**
242
- * Get bp-pages names and slugs
243
  *
244
- * @package BuddyPress Core
245
- * @since BuddyPress (1.5)
246
  *
247
- * @return object Page names, IDs, and slugs
248
  */
249
  function bp_core_get_directory_pages() {
250
  global $wpdb;
@@ -293,13 +354,17 @@ function bp_core_get_directory_pages() {
293
  }
294
 
295
  /**
296
- * Add the pages for the component mapping. These are most often used by components with directories (e.g. groups, members).
 
 
 
 
 
297
  *
298
- * @param array $default_components Optional components to create pages for
299
  * @param string $existing 'delete' if you want to delete existing page
300
- * mappings and replace with new ones. Otherwise existing page mappings
301
- * are kept, and the gaps filled in with new pages
302
- * @since BuddyPress (1.7)
303
  */
304
  function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
305
 
@@ -374,27 +439,27 @@ function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
374
  }
375
 
376
  /**
377
- * Creates a default component slug from a WP page root_slug
378
  *
379
  * Since 1.5, BP components get their root_slug (the slug used immediately
380
  * following the root domain) from the slug of a corresponding WP page.
381
  *
382
  * E.g. if your BP installation at example.com has its members page at
383
- * example.com/community/people, $bp->members->root_slug will be 'community/people'.
 
384
  *
385
  * By default, this function creates a shorter version of the root_slug for
386
  * use elsewhere in the URL, by returning the content after the final '/'
387
  * in the root_slug ('people' in the example above).
388
  *
389
  * Filter on 'bp_core_component_slug_from_root_slug' to override this method
390
- * in general, or define a specific component slug constant (e.g. BP_MEMBERS_SLUG)
391
- * to override specific component slugs.
392
  *
393
- * @package BuddyPress Core
394
- * @since BuddyPress (1.5)
395
  *
396
- * @param string $root_slug The root slug, which comes from $bp->pages->[component]->slug
397
- * @return string The short slug for use in the middle of URLs
398
  */
399
  function bp_core_component_slug_from_root_slug( $root_slug ) {
400
  $slug_chunks = explode( '/', $root_slug );
@@ -404,12 +469,16 @@ function bp_core_component_slug_from_root_slug( $root_slug ) {
404
  }
405
 
406
  /**
407
- * This function originally let plugins add support for pages in the root of the install.
408
- * These root level pages are now handled by actual WordPress pages and this function is now
409
- * a convenience for compatibility with the new method.
410
  *
411
- * @global $bp BuddyPress global settings
412
- * @param string $slug The slug of the component
 
 
 
 
 
 
413
  */
414
  function bp_core_add_root_component( $slug ) {
415
  global $bp;
@@ -437,6 +506,9 @@ function bp_core_add_root_component( $slug ) {
437
  }
438
  }
439
 
 
 
 
440
  function bp_core_create_root_component_page() {
441
  global $bp;
442
 
@@ -450,8 +522,7 @@ function bp_core_create_root_component_page() {
450
  }
451
 
452
  /**
453
- * Adds illegal names to WP so that root components will not conflict with
454
- * blog names on a subdirectory installation.
455
  *
456
  * For example, it would stop someone creating a blog with the slug "groups".
457
  *
@@ -461,14 +532,27 @@ function bp_core_add_illegal_names() {
461
  update_site_option( 'illegal_names', get_site_option( 'illegal_names' ), array() );
462
  }
463
 
 
 
 
 
 
 
 
 
 
 
 
 
464
  /** URI ***********************************************************************/
465
 
466
  /**
467
- * Returns the domain for the root blog.
468
- * eg: http://domain.com/ OR https://domain.com
 
469
  *
470
- * @package BuddyPress Core
471
  * @uses get_blog_option() WordPress function to fetch blog meta.
 
472
  * @return string The domain URL for the blog.
473
  */
474
  function bp_core_get_root_domain() {
@@ -479,10 +563,13 @@ function bp_core_get_root_domain() {
479
  }
480
 
481
  /**
482
- * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
483
  *
484
- * @package BuddyPress Core
485
  * @uses wp_safe_redirect()
 
 
 
 
486
  */
487
  function bp_core_redirect( $location, $status = 302 ) {
488
 
@@ -501,10 +588,9 @@ function bp_core_redirect( $location, $status = 302 ) {
501
  }
502
 
503
  /**
504
- * Returns the referrer URL without the http(s)://
505
  *
506
- * @package BuddyPress Core
507
- * @return string The referrer URL
508
  */
509
  function bp_core_referrer() {
510
  $referer = explode( '/', wp_get_referer() );
@@ -515,10 +601,9 @@ function bp_core_referrer() {
515
  /**
516
  * Get the path of of the current site.
517
  *
518
- * @package BuddyPress Core
519
- *
520
  * @global object $current_site
521
- * @return string
 
522
  */
523
  function bp_core_get_site_path() {
524
  global $current_site;
@@ -549,10 +634,12 @@ function bp_core_get_site_path() {
549
  /** Time **********************************************************************/
550
 
551
  /**
552
- * Get the current GMT time to save into the DB
553
  *
554
- * @package BuddyPress Core
555
  * @since BuddyPress (1.2.6)
 
 
 
556
  */
557
  function bp_core_current_time( $gmt = true ) {
558
  // Get current time in MYSQL format
@@ -562,6 +649,8 @@ function bp_core_current_time( $gmt = true ) {
562
  }
563
 
564
  /**
 
 
565
  * Based on function created by Dunstan Orchard - http://1976design.com
566
  *
567
  * This function will return an English representation of the time elapsed
@@ -574,12 +663,16 @@ function bp_core_current_time( $gmt = true ) {
574
  * an interval of 3 minutes will be represented by "3 minutes ago", as will an
575
  * interval of 3 minutes 59 seconds.
576
  *
577
- * @package BuddyPress Core
578
- * @uses apply_filters() Filter 'bp_core_time_since_pre' to bypass BP's calculations
579
- * @uses apply_filters() Filter 'bp_core_time_since' to modify BP's calculations
580
- * @param int $older_date Unix timestamp of date you want to calculate the time since for
581
- * @param int $newer_date Unix timestamp of date to compare older date to. Default false (current time).
582
- * @return string The time since.
 
 
 
 
583
  */
584
  function bp_core_time_since( $older_date, $newer_date = false ) {
585
 
@@ -727,14 +820,13 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
727
  /** Messages ******************************************************************/
728
 
729
  /**
730
- * Adds a feedback (error/success) message to the WP cookie so it can be
731
- * displayed after the page reloads.
732
  *
733
- * @package BuddyPress Core
734
  *
735
- * @global BuddyPress $bp The one true BuddyPress instance
736
- * @param string $message Feedback to give to user
737
- * @param string $type updated|success|error|warning
738
  */
739
  function bp_core_add_message( $message, $type = '' ) {
740
  global $bp;
@@ -756,16 +848,16 @@ function bp_core_add_message( $message, $type = '' ) {
756
  }
757
 
758
  /**
759
- * Checks if there is a feedback message in the WP cookie, if so, adds a
760
- * "template_notices" action so that the message can be parsed into the template
761
- * and displayed to the user.
 
 
762
  *
763
  * After the message is displayed, it removes the message vars from the cookie
764
  * so that the message is not shown to the user multiple times.
765
  *
766
- * @package BuddyPress Core
767
- * @global $bp_message The message text
768
- * @global $bp_message_type The type of message (error/success)
769
  * @uses setcookie() Sets a cookie value for the user.
770
  */
771
  function bp_core_setup_message() {
@@ -787,11 +879,12 @@ function bp_core_setup_message() {
787
  add_action( 'bp_actions', 'bp_core_setup_message', 5 );
788
 
789
  /**
790
- * Renders a feedback message (either error or success message) to the theme template.
791
- * The hook action 'template_notices' is used to call this function, it is not called directly.
 
 
792
  *
793
- * @package BuddyPress Core
794
- * @global BuddyPress $bp The one true BuddyPress instance
795
  */
796
  function bp_core_render_message() {
797
  global $bp;
@@ -816,13 +909,17 @@ function bp_core_render_message() {
816
  /** Last active ***************************************************************/
817
 
818
  /**
819
- * Record user activity to the database. Many functions use a "last active" feature to
820
- * show the length of time since the user was last active.
821
- * This function will update that time as a usermeta setting for the user every 5 minutes.
822
  *
823
- * @package BuddyPress Core
824
- * @global $userdata WordPress user data for the current logged in user.
825
- * @uses bp_update_user_meta() BP function to update user metadata in the usermeta table.
 
 
 
 
 
 
826
  */
827
  function bp_core_record_activity() {
828
 
@@ -834,7 +931,7 @@ function bp_core_record_activity() {
834
  if ( bp_is_user_inactive( $user_id ) )
835
  return false;
836
 
837
- $activity = bp_get_user_meta( $user_id, 'last_activity', true );
838
 
839
  if ( !is_numeric( $activity ) )
840
  $activity = strtotime( $activity );
@@ -847,18 +944,21 @@ function bp_core_record_activity() {
847
  do_action( 'bp_first_activity_for_member', $user_id );
848
  }
849
 
850
- if ( empty( $activity ) || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )
851
- bp_update_user_meta( $user_id, 'last_activity', $current_time );
 
852
  }
853
  add_action( 'wp_head', 'bp_core_record_activity' );
854
 
855
  /**
856
- * Formats last activity based on time since date given.
857
  *
858
- * @package BuddyPress Core
859
- * @param string $last_activity_date The date of last activity.
860
- * @param string $string
861
- * @uses bp_core_time_since() This function will return an English representation of the time elapsed.
 
 
862
  */
863
  function bp_core_get_last_activity( $last_activity_date, $string ) {
864
 
@@ -875,81 +975,87 @@ function bp_core_get_last_activity( $last_activity_date, $string ) {
875
  /**
876
  * Get the meta_key for a given piece of user metadata
877
  *
878
- * BuddyPress stores a number of pieces of userdata in the WordPress central usermeta table. In
879
- * order to allow plugins to enable multiple instances of BuddyPress on a single WP installation,
880
- * BP's usermeta keys are filtered with this function, so that they can be altered on the fly.
 
881
  *
882
- * Plugin authors should use BP's _user_meta() functions, which bakes in bp_get_user_meta_key().
 
883
  * $last_active = bp_get_user_meta( $user_id, 'last_activity', true );
884
- * If you have to use WP's _user_meta() functions for some reason, you should use this function, eg
 
885
  * $last_active = get_user_meta( $user_id, bp_get_user_meta_key( 'last_activity' ), true );
886
  * If using the WP functions, do not not hardcode your meta keys.
887
  *
888
- * @package BuddyPress
889
- * @since BuddyPress (1.5)
 
890
  *
891
- * @uses apply_filters() Filter bp_get_user_meta_key to modify keys individually
892
- * @param string $key
893
- * @return string $key
894
  */
895
  function bp_get_user_meta_key( $key = false ) {
896
  return apply_filters( 'bp_get_user_meta_key', $key );
897
  }
898
 
899
  /**
900
- * Get a piece of usermeta
901
  *
902
- * This is a wrapper for get_user_meta() that allows for easy use of bp_get_user_meta_key(), thereby
903
- * increasing compatibility with non-standard BP setups.
 
904
  *
905
- * @package BuddyPress
906
- * @since BuddyPress (1.5)
 
 
907
  *
908
- * @uses bp_get_user_meta_key() For a filterable version of the meta key
909
- * @uses get_user_meta() See get_user_meta() docs for more details on parameters
910
- * @param int $user_id The id of the user whose meta you're fetching
911
  * @param string $key The meta key to retrieve.
912
  * @param bool $single Whether to return a single value.
913
  * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
914
- * is true.
915
  */
916
  function bp_get_user_meta( $user_id, $key, $single = false ) {
917
  return get_user_meta( $user_id, bp_get_user_meta_key( $key ), $single );
918
  }
919
 
920
  /**
921
- * Update a piece of usermeta
922
  *
923
- * This is a wrapper for update_user_meta() that allows for easy use of bp_get_user_meta_key(),
924
- * thereby increasing compatibility with non-standard BP setups.
 
925
  *
926
- * @package BuddyPress
927
- * @since BuddyPress (1.5)
928
  *
929
- * @uses bp_get_user_meta_key() For a filterable version of the meta key
930
- * @uses update_user_meta() See update_user_meta() docs for more details on parameters
931
- * @param int $user_id The id of the user whose meta you're setting
 
932
  * @param string $key The meta key to set.
933
  * @param mixed $value Metadata value.
934
  * @param mixed $prev_value Optional. Previous value to check before removing.
935
- * @return bool False on failure, true if success.
936
  */
937
  function bp_update_user_meta( $user_id, $key, $value, $prev_value = '' ) {
938
  return update_user_meta( $user_id, bp_get_user_meta_key( $key ), $value, $prev_value );
939
  }
940
 
941
  /**
942
- * Delete a piece of usermeta
943
  *
944
- * This is a wrapper for delete_user_meta() that allows for easy use of bp_get_user_meta_key(),
945
- * thereby increasing compatibility with non-standard BP setups.
 
946
  *
947
- * @package BuddyPress
948
- * @since BuddyPress (1.5)
 
 
949
  *
950
- * @uses bp_get_user_meta_key() For a filterable version of the meta key
951
- * @uses delete_user_meta() See delete_user_meta() docs for more details on parameters
952
- * @param int $user_id The id of the user whose meta you're deleting
953
  * @param string $key The meta key to delete.
954
  * @param mixed $value Optional. Metadata value.
955
  * @return bool False for failure. True for success.
@@ -963,9 +1069,9 @@ function bp_delete_user_meta( $user_id, $key, $value = '' ) {
963
  /**
964
  * Initializes {@link BP_Embed} after everything is loaded.
965
  *
966
- * @global object $bp BuddyPress global settings
967
- * @package BuddyPress Core
968
- * @since BuddyPress (1.5)
969
  */
970
  function bp_embed_init() {
971
  global $bp;
@@ -978,8 +1084,10 @@ add_action( 'bp_init', 'bp_embed_init', 9 );
978
  /**
979
  * Are oembeds allowed in activity items?
980
  *
981
- * @return bool False when activity embed support is disabled; true when enabled (default)
982
- * @since BuddyPress (1.5)
 
 
983
  */
984
  function bp_use_embed_in_activity() {
985
  return apply_filters( 'bp_use_oembed_in_activity', !defined( 'BP_EMBED_DISABLE_ACTIVITY' ) || !BP_EMBED_DISABLE_ACTIVITY );
@@ -988,8 +1096,10 @@ function bp_use_embed_in_activity() {
988
  /**
989
  * Are oembeds allwoed in activity replies?
990
  *
991
- * @return bool False when activity replies embed support is disabled; true when enabled (default)
992
- * @since BuddyPress (1.5)
 
 
993
  */
994
  function bp_use_embed_in_activity_replies() {
995
  return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES );
@@ -998,8 +1108,10 @@ function bp_use_embed_in_activity_replies() {
998
  /**
999
  * Are oembeds allowed in forum posts?
1000
  *
1001
- * @return bool False when form post embed support is disabled; true when enabled (default)
1002
- * @since BuddyPress (1.5)
 
 
1003
  */
1004
  function bp_use_embed_in_forum_posts() {
1005
  return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS );
@@ -1008,8 +1120,10 @@ function bp_use_embed_in_forum_posts() {
1008
  /**
1009
  * Are oembeds allowed in private messages?
1010
  *
1011
- * @return bool False when form post embed support is disabled; true when enabled (default)
1012
- * @since BuddyPress (1.5)
 
 
1013
  */
1014
  function bp_use_embed_in_private_messages() {
1015
  return apply_filters( 'bp_use_embed_in_private_messages', !defined( 'BP_EMBED_DISABLE_PRIVATE_MESSAGES' ) || !BP_EMBED_DISABLE_PRIVATE_MESSAGES );
@@ -1018,31 +1132,33 @@ function bp_use_embed_in_private_messages() {
1018
  /** Admin *********************************************************************/
1019
 
1020
  /**
1021
- * Output the correct URL based on BuddyPress and WordPress configuration
1022
  *
1023
- * @package BuddyPress
1024
- * @since BuddyPress (1.5)
1025
  *
1026
- * @param string $path
1027
- * @param string $scheme
1028
  *
1029
- * @uses bp_get_admin_url()
 
1030
  */
1031
  function bp_admin_url( $path = '', $scheme = 'admin' ) {
1032
  echo bp_get_admin_url( $path, $scheme );
1033
  }
1034
  /**
1035
- * Return the correct URL based on BuddyPress and WordPress configuration
1036
  *
1037
- * @package BuddyPress
1038
- * @since BuddyPress (1.5)
1039
- *
1040
- * @param string $path
1041
- * @param string $scheme
1042
  *
1043
  * @uses bp_core_do_network_admin()
1044
  * @uses network_admin_url()
1045
  * @uses admin_url()
 
 
 
 
 
 
 
1046
  */
1047
  function bp_get_admin_url( $path = '', $scheme = 'admin' ) {
1048
 
@@ -1059,18 +1175,19 @@ function bp_admin_url( $path = '', $scheme = 'admin' ) {
1059
  }
1060
 
1061
  /**
1062
- * Should BuddyPress appear in network admin, or site admin?
1063
  *
1064
  * Because BuddyPress can be installed in multiple ways and with multiple
1065
  * configurations, we need to check a few things to be confident about where
1066
  * to hook into certain areas of WordPress's admin.
1067
  *
1068
- * This function defaults to BuddyPress being network activated.
1069
- * @since BuddyPress (1.5)
1070
  *
1071
  * @uses bp_is_network_activated()
1072
  * @uses bp_is_multiblog_mode()
1073
- * @return boolean
 
 
1074
  */
1075
  function bp_core_do_network_admin() {
1076
 
@@ -1083,6 +1200,18 @@ function bp_core_do_network_admin() {
1083
  return (bool) apply_filters( 'bp_core_do_network_admin', $retval );
1084
  }
1085
 
 
 
 
 
 
 
 
 
 
 
 
 
1086
  function bp_core_admin_hook() {
1087
  $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
1088
 
@@ -1092,12 +1221,11 @@ function bp_core_admin_hook() {
1092
  /** Multisite *****************************************************************/
1093
 
1094
  /**
1095
- * Is this the root blog ID?
1096
  *
1097
- * @package BuddyPress
1098
- * @since BuddyPress (1.5)
1099
  *
1100
- * @param int $blog_id Optional. Defaults to the current blog id.
1101
  * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
1102
  */
1103
  function bp_is_root_blog( $blog_id = 0 ) {
@@ -1117,12 +1245,15 @@ function bp_is_root_blog( $blog_id = 0 ) {
1117
  }
1118
 
1119
  /**
1120
- * Is this bp_get_root_blog_id()?
1121
  *
1122
- * @package BuddyPress
1123
- * @since BuddyPress (1.5)
 
 
 
1124
  *
1125
- * @return int Return the root site ID
1126
  */
1127
  function bp_get_root_blog_id() {
1128
  global $bp;
@@ -1153,11 +1284,12 @@ function bp_get_root_blog_id() {
1153
  * a very small use-case with large architectural shortcomings, so do not go
1154
  * down this road unless you specifically need to.
1155
  *
1156
- * @package BuddyPress
1157
- * @since BuddyPress (1.5)
1158
  *
1159
- * @uses apply_filters() Filter 'bp_is_multiblog_mode' to alter
1160
- * @return bool False when multiblog mode is disabled (default); true when enabled
 
 
1161
  */
1162
  function bp_is_multiblog_mode() {
1163
 
@@ -1184,10 +1316,12 @@ function bp_is_multiblog_mode() {
1184
  *
1185
  * Used to determine admin menu placement, and where settings and options are
1186
  * stored. If you're being *really* clever and manually pulling BuddyPress in
1187
- * with an mu-plugin or some other method, you'll want to
 
 
 
1188
  *
1189
- * @since BuddyPress (1.7)
1190
- * @return boolean
1191
  */
1192
  function bp_is_network_activated() {
1193
 
@@ -1208,11 +1342,13 @@ function bp_is_network_activated() {
1208
  /** Global Manipulators *******************************************************/
1209
 
1210
  /**
1211
- * Set the $bp->is_directory global
 
 
1212
  *
1213
- * @global BuddyPress $bp The one true BuddyPress instance
1214
- * @param bool $is_directory
1215
- * @param string $component
1216
  */
1217
  function bp_update_is_directory( $is_directory = false, $component = '' ) {
1218
  global $bp;
@@ -1224,11 +1360,13 @@ function bp_update_is_directory( $is_directory = false, $component = '' ) {
1224
  }
1225
 
1226
  /**
1227
- * Set the $bp->is_item_admin global
1228
  *
1229
- * @global BuddyPress $bp The one true BuddyPress instance
1230
- * @param bool $is_item_admin
1231
- * @param string $component
 
 
1232
  */
1233
  function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
1234
  global $bp;
@@ -1240,11 +1378,13 @@ function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
1240
  }
1241
 
1242
  /**
1243
- * Set the $bp->is_item_mod global
 
 
1244
  *
1245
- * @global BuddyPress $bp The one true BuddyPress instance
1246
- * @param bool $is_item_mod
1247
- * @param string $component
1248
  */
1249
  function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1250
  global $bp;
@@ -1256,12 +1396,14 @@ function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1256
  }
1257
 
1258
  /**
1259
- * Trigger a 404
 
 
1260
  *
1261
- * @global BuddyPress $bp The one true BuddyPress instance
1262
- * @global WP_Query $wp_query WordPress query object
1263
- * @param string $redirect If 'remove_canonical_direct', remove WordPress' "helpful" redirect_canonical action.
1264
- * @since BuddyPress (1.5)
1265
  */
1266
  function bp_do_404( $redirect = 'remove_canonical_direct' ) {
1267
  global $wp_query;
@@ -1283,25 +1425,57 @@ function bp_do_404( $redirect = 'remove_canonical_direct' ) {
1283
  *
1284
  * To avoid security exploits within the theme.
1285
  *
1286
- * @since BuddyPress (1.6)
1287
  *
1288
  * @uses do_action() Calls 'bp_verify_nonce_request' on $action.
1289
- * @param string $action Action nonce
1290
- * @param string $query_arg where to look for nonce in $_REQUEST
 
 
1291
  */
1292
  function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
1293
 
1294
- // Get the home URL
1295
- $home_url = strtolower( home_url() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1296
 
1297
- $requested_url = bp_get_requested_url();
 
1298
 
1299
  // Check the nonce
1300
  $result = isset( $_REQUEST[$query_arg] ) ? wp_verify_nonce( $_REQUEST[$query_arg], $action ) : false;
1301
 
1302
  // Nonce check failed
1303
- if ( empty( $result ) || empty( $action ) || ( strpos( $requested_url, $home_url ) !== 0 ) )
1304
  $result = false;
 
1305
 
1306
  // Do extra things
1307
  do_action( 'bp_verify_nonce_request', $action, $result );
@@ -1309,12 +1483,37 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
1309
  return $result;
1310
  }
1311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1312
  /** Miscellaneous hooks *******************************************************/
1313
 
1314
  /**
1315
- * Load the buddypress translation file for current language
 
 
1316
  *
1317
- * @package BuddyPress Core
1318
  */
1319
  function bp_core_load_buddypress_textdomain() {
1320
  // Try to load via load_plugin_textdomain() first, for future
@@ -1332,9 +1531,8 @@ function bp_core_load_buddypress_textdomain() {
1332
  add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
1333
 
1334
  /**
1335
- * A javascript free implementation of the search functions in BuddyPress
1336
  *
1337
- * @package BuddyPress Core
1338
  * @param string $slug The slug to redirect to for searching.
1339
  */
1340
  function bp_core_action_search_site( $slug = '' ) {
@@ -1398,9 +1596,7 @@ function bp_core_action_search_site( $slug = '' ) {
1398
  add_action( 'bp_init', 'bp_core_action_search_site', 7 );
1399
 
1400
  /**
1401
- * Prints the generation time in the footer of the site.
1402
- *
1403
- * @package BuddyPress Core
1404
  */
1405
  function bp_core_print_generation_time() {
1406
  ?>
@@ -1410,3 +1606,178 @@ function bp_core_print_generation_time() {
1410
  <?php
1411
  }
1412
  add_action( 'wp_footer', 'bp_core_print_generation_time' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Common Functions.
5
  *
6
  * @package BuddyPress
7
  * @subpackage Functions
13
  /** Versions ******************************************************************/
14
 
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
  */
22
  function bp_version() {
23
  echo bp_get_version();
24
  }
25
  /**
26
+ * Return the BuddyPress version.
27
  *
28
+ * @since BuddyPress (1.6.0)
29
+ *
30
+ * @return string The BuddyPress version.
31
  */
32
  function bp_get_version() {
33
  return buddypress()->version;
34
  }
35
 
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
  */
43
  function bp_db_version() {
44
  echo bp_get_db_version();
45
  }
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() {
53
  return buddypress()->db_version;
54
  }
55
 
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
  */
63
  function bp_db_version_raw() {
64
  echo bp_get_db_version_raw();
67
  * Return the BuddyPress database version
68
  *
69
  * @since BuddyPress (1.6)
70
+ *
71
+ * @return string The BuddyPress version direct from the database.
72
  */
73
  function bp_get_db_version_raw() {
74
  $bp = buddypress();
78
  /** Functions *****************************************************************/
79
 
80
  /**
81
+ * Get the $wpdb base prefix, run through the 'bp_core_get_table_prefix' filter.
82
+ *
83
+ * The filter is intended primarily for use in multinetwork installations.
84
  *
85
+ * @global object $wpdb WordPress database object.
86
+ *
87
+ * @return string Filtered database prefix.
88
  */
89
  function bp_core_get_table_prefix() {
90
  global $wpdb;
93
  }
94
 
95
  /**
96
+ * Sort an array of objects or arrays by alphabetically sorting by a specific key/property.
97
+ *
98
+ * For instance, if you have an array of WordPress post objects, you can sort
99
+ * them by post_name as follows:
100
+ * $sorted_posts = bp_alpha_sort_by_key( $posts, 'post_name' );
101
+ *
102
+ * The main purpose for this function is so that you can avoid having to create
103
+ * your own awkward callback function for usort().
104
  *
105
+ * @since BuddyPress (1.9.0)
106
+ *
107
+ * @param array $items The array to be sorted. Its constituent items can be
108
+ * either associative arrays or objects.
109
+ * @param string|int $key The array index or property name to sort by.
110
+ * @return array $items The sorted array.
111
+ */
112
+ function bp_alpha_sort_by_key( $items, $key ) {
113
+ usort( $items, create_function( '$a, $b', '
114
+ $values = array( 0 => false, 1 => false, );
115
+ foreach ( func_get_args() as $indexi => $index ) {
116
+ if ( isset( $index->' . $key . ' ) ) {
117
+ $values[ $indexi ] = $index->' . $key . ';
118
+ } else if ( isset( $index["' . $key . '"] ) ) {
119
+ $values[ $indexi ] = $index["' . $key . '"];
120
+ }
121
+ }
122
+
123
+ if ( $values[0] && $values[1] ) {
124
+ $cmp = strcmp( $values[0], $values[1] );
125
+ if ( 0 > $cmp ) {
126
+ $retval = -1;
127
+ } else if ( 0 < $cmp ) {
128
+ $retval = 1;
129
+ } else {
130
+ $retval = 0;
131
+ }
132
+ return $retval;
133
+ } else {
134
+ return 0;
135
+ }
136
+ ') );
137
+
138
+ return $items;
139
+ }
140
+
141
+ /**
142
+ * Format numbers the BuddyPress way.
143
+ *
144
+ * @param int $number The number to be formatted.
145
+ * @param bool $decimals Whether to use decimals. See {@link number_format_i18n()}.
146
+ * @return string The formatted number.
147
  */
148
  function bp_core_number_format( $number, $decimals = false ) {
149
 
185
  * For the second argument, $func_args, you should just pass the value of func_get_args().
186
  *
187
  * @since BuddyPress (1.6)
188
+ * @param array $old_args_keys Old argument indexs, keyed to their positions.
189
+ * @param array $func_args The parameters passed to the originating function.
190
+ * @return array $new_args The parsed arguments.
191
  */
192
  function bp_core_parse_args_array( $old_args_keys, $func_args ) {
193
  $new_args = array();
202
  }
203
 
204
  /**
205
+ * Sanitize an 'order' parameter for use in building SQL queries.
206
  *
207
  * Strings like 'DESC', 'desc', ' desc' will be interpreted into 'DESC'.
208
  * Everything else becomes 'ASC'.
209
  *
210
+ * @since BuddyPress (1.8.0)
211
+ *
212
+ * @param string $order The 'order' string, as passed to the SQL constructor.
213
+ * @return string The sanitized value 'DESC' or 'ASC'.
214
  */
215
  function bp_esc_sql_order( $order = '' ) {
216
  $order = strtoupper( trim( $order ) );
220
  /**
221
  * Are we running username compatibility mode?
222
  *
223
+ * @since BuddyPress (1.5.0)
 
224
  *
225
+ * @uses apply_filters() Filter 'bp_is_username_compatibility_mode' to alter.
 
226
  * @todo Move to members component?
227
+ *
228
+ * @return bool False when compatibility mode is disabled, true when enabled.
229
+ * Default: false.
230
  */
231
  function bp_is_username_compatibility_mode() {
232
  return apply_filters( 'bp_is_username_compatibility_mode', defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) && BP_ENABLE_USERNAME_COMPATIBILITY_MODE );
235
  /**
236
  * Should we use the WP Toolbar?
237
  *
238
+ * The WP Toolbar, introduced in WP 3.1, is fully supported in BuddyPress as
239
+ * of BP 1.5. For BP 1.6, the WP Toolbar is the default.
240
+ *
241
+ * @since BuddyPress (1.5.0)
242
+ *
243
+ * @uses apply_filters() Filter 'bp_use_wp_admin_bar' to alter.
244
  *
245
+ * @return bool False when WP Toolbar support is disabled, true when enabled.
246
+ * Default: true.
 
247
  */
248
  function bp_use_wp_admin_bar() {
249
  $use_admin_bar = true;
262
  /** Directory *****************************************************************/
263
 
264
  /**
265
+ * Fetch a list of BP directory pages from the appropriate meta table.
266
  *
267
+ * @since BuddyPress (1.5.0)
268
+ *
269
+ * @return array|string An array of page IDs, keyed by component names, or an
270
+ * empty string if the list is not found.
271
  */
272
  function bp_core_get_directory_page_ids() {
273
  $page_ids = bp_get_option( 'bp-pages' );
285
  }
286
 
287
  /**
288
+ * Store the list of BP directory pages in the appropriate meta table.
289
  *
290
+ * bp-pages data is stored in site_options (falls back to options on non-MS),
291
+ * in an array keyed by blog_id. This allows you to change your
292
+ * bp_get_root_blog_id() and go through the setup process again.
293
  *
294
+ * @since BuddyPress (1.5.0)
 
295
  *
296
+ * @param array $blog_page_ids The IDs of the WP pages corresponding to BP
297
+ * component directories.
298
  */
299
  function bp_core_update_directory_page_ids( $blog_page_ids ) {
300
  bp_update_option( 'bp-pages', $blog_page_ids );
301
  }
302
 
303
  /**
304
+ * Get names and slugs for BuddyPress component directory pages.
305
  *
306
+ * @since BuddyPress (1.5.0).
 
307
  *
308
+ * @return object Page names, IDs, and slugs.
309
  */
310
  function bp_core_get_directory_pages() {
311
  global $wpdb;
354
  }
355
 
356
  /**
357
+ * Creates necessary directory pages.
358
+ *
359
+ * Directory pages are those WordPress pages used by BP components to display
360
+ * content (eg, the 'groups' page created by BP).
361
+ *
362
+ * @since BuddyPress (1.7.0)
363
  *
364
+ * @param array $default_components Components to create pages for.
365
  * @param string $existing 'delete' if you want to delete existing page
366
+ * mappings and replace with new ones. Otherwise existing page mappings
367
+ * are kept, and the gaps filled in with new pages. Default: 'keep'.
 
368
  */
369
  function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
370
 
439
  }
440
 
441
  /**
442
+ * Create a default component slug from a WP page root_slug.
443
  *
444
  * Since 1.5, BP components get their root_slug (the slug used immediately
445
  * following the root domain) from the slug of a corresponding WP page.
446
  *
447
  * E.g. if your BP installation at example.com has its members page at
448
+ * example.com/community/people, $bp->members->root_slug will be
449
+ * 'community/people'.
450
  *
451
  * By default, this function creates a shorter version of the root_slug for
452
  * use elsewhere in the URL, by returning the content after the final '/'
453
  * in the root_slug ('people' in the example above).
454
  *
455
  * Filter on 'bp_core_component_slug_from_root_slug' to override this method
456
+ * in general, or define a specific component slug constant (e.g.
457
+ * BP_MEMBERS_SLUG) to override specific component slugs.
458
  *
459
+ * @since BuddyPress (1.5.0)
 
460
  *
461
+ * @param string $root_slug The root slug, which comes from $bp->pages->[component]->slug.
462
+ * @return string The short slug for use in the middle of URLs.
463
  */
464
  function bp_core_component_slug_from_root_slug( $root_slug ) {
465
  $slug_chunks = explode( '/', $root_slug );
469
  }
470
 
471
  /**
472
+ * Add support for a top-level ("root") component.
 
 
473
  *
474
+ * This function originally (pre-1.5) let plugins add support for pages in the
475
+ * root of the install. These root level pages are now handled by actual
476
+ * WordPress pages and this function is now a convenience for compatibility
477
+ * with the new method.
478
+ *
479
+ * @global $bp BuddyPress global settings.
480
+ *
481
+ * @param string $slug The slug of the component being added to the root list.
482
  */
483
  function bp_core_add_root_component( $slug ) {
484
  global $bp;
506
  }
507
  }
508
 
509
+ /**
510
+ * Create WordPress pages to be used as BP component directories.
511
+ */
512
  function bp_core_create_root_component_page() {
513
  global $bp;
514
 
522
  }
523
 
524
  /**
525
+ * Add illegal blog names to WP so that root components will not conflict with blog names on a subdirectory installation.
 
526
  *
527
  * For example, it would stop someone creating a blog with the slug "groups".
528
  *
532
  update_site_option( 'illegal_names', get_site_option( 'illegal_names' ), array() );
533
  }
534
 
535
+ /**
536
+ * Determine whether BuddyPress should register the bp-themes directory.
537
+ *
538
+ * @since BuddyPress (1.9.0)
539
+ *
540
+ * @return bool True if bp-themes should be registered, false otherwise.
541
+ */
542
+ function bp_do_register_theme_directory() {
543
+ $register = 'bp-default' === get_stylesheet() || 'bp-default' === get_template();
544
+ return apply_filters( 'bp_do_register_theme_directory', $register );
545
+ }
546
+
547
  /** URI ***********************************************************************/
548
 
549
  /**
550
+ * Return the domain for the root blog.
551
+ *
552
+ * eg: http://domain.com OR https://domain.com
553
  *
 
554
  * @uses get_blog_option() WordPress function to fetch blog meta.
555
+ *
556
  * @return string The domain URL for the blog.
557
  */
558
  function bp_core_get_root_domain() {
563
  }
564
 
565
  /**
566
+ * Perform a status-safe wp_redirect() that is compatible with BP's URI parser.
567
  *
 
568
  * @uses wp_safe_redirect()
569
+ *
570
+ * @param string $location The redirect URL.
571
+ * @param int $status Optional. The numeric code to give in the redirect
572
+ * headers. Default: 302.
573
  */
574
  function bp_core_redirect( $location, $status = 302 ) {
575
 
588
  }
589
 
590
  /**
591
+ * Return the referrer URL without the http(s)://
592
  *
593
+ * @return string The referrer URL.
 
594
  */
595
  function bp_core_referrer() {
596
  $referer = explode( '/', wp_get_referer() );
601
  /**
602
  * Get the path of of the current site.
603
  *
 
 
604
  * @global object $current_site
605
+ *
606
+ * @return string URL to the current site.
607
  */
608
  function bp_core_get_site_path() {
609
  global $current_site;
634
  /** Time **********************************************************************/
635
 
636
  /**
637
+ * Get the current GMT time to save into the DB.
638
  *
 
639
  * @since BuddyPress (1.2.6)
640
+ *
641
+ * @param bool $gmt True to use GMT (rather than local) time. Default: true.
642
+ * @return string Current time in 'Y-m-d h:i:s' format.
643
  */
644
  function bp_core_current_time( $gmt = true ) {
645
  // Get current time in MYSQL format
649
  }
650
 
651
  /**
652
+ * Get an English-language representation of the time elapsed since a given date.
653
+ *
654
  * Based on function created by Dunstan Orchard - http://1976design.com
655
  *
656
  * This function will return an English representation of the time elapsed
663
  * an interval of 3 minutes will be represented by "3 minutes ago", as will an
664
  * interval of 3 minutes 59 seconds.
665
  *
666
+ * @uses apply_filters() Filter 'bp_core_time_since_pre' to bypass BP's calculations.
667
+ * @uses apply_filters() Filter 'bp_core_time_since' to modify BP's calculations.
668
+ *
669
+ * @param int|string $older_date The earlier time from which you're calculating
670
+ * the time elapsed. Enter either as an integer Unix timestamp, or as a
671
+ * date string of the format 'Y-m-d h:i:s'.
672
+ * @param int $newer_date Optional. Unix timestamp of date to compare older
673
+ * date to. Default: false (current time).
674
+ * @return string String representing the time since the older date, eg
675
+ * "2 hours and 50 minutes".
676
  */
677
  function bp_core_time_since( $older_date, $newer_date = false ) {
678
 
820
  /** Messages ******************************************************************/
821
 
822
  /**
823
+ * Add a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
 
824
  *
825
+ * @global BuddyPress $bp The one true BuddyPress instance.
826
  *
827
+ * @param string $message Feedback message to be displayed.
828
+ * @param string $type Message type. 'updated', 'success', 'error', 'warning'.
829
+ * Default: 'success'.
830
  */
831
  function bp_core_add_message( $message, $type = '' ) {
832
  global $bp;
848
  }
849
 
850
  /**
851
+ * Set up the display of the 'template_notices' feedback message.
852
+ *
853
+ * Checks whether there is a feedback message in the WP cookie and, if so, adds
854
+ * a "template_notices" action so that the message can be parsed into the
855
+ * template and displayed to the user.
856
  *
857
  * After the message is displayed, it removes the message vars from the cookie
858
  * so that the message is not shown to the user multiple times.
859
  *
860
+ * @global BuddyPress $bp BuddyPress global settings object.
 
 
861
  * @uses setcookie() Sets a cookie value for the user.
862
  */
863
  function bp_core_setup_message() {
879
  add_action( 'bp_actions', 'bp_core_setup_message', 5 );
880
 
881
  /**
882
+ * Render the 'template_notices' feedback message.
883
+ *
884
+ * The hook action 'template_notices' is used to call this function, it is not
885
+ * called directly.
886
  *
887
+ * @global BuddyPress $bp The one true BuddyPress instance.
 
888
  */
889
  function bp_core_render_message() {
890
  global $bp;
909
  /** Last active ***************************************************************/
910
 
911
  /**
912
+ * Listener function for the logged-in user's 'last_activity' metadata.
 
 
913
  *
914
+ * Many functions use a "last active" feature to show the length of time since
915
+ * the user was last active. This function will update that time as a usermeta
916
+ * setting for the user every 5 minutes while the user is actively browsing the
917
+ * site.
918
+ *
919
+ * @uses bp_update_user_meta() BP function to update user metadata in the
920
+ * usermeta table.
921
+ *
922
+ * @return bool|null Returns false if there is nothing to do.
923
  */
924
  function bp_core_record_activity() {
925
 
931
  if ( bp_is_user_inactive( $user_id ) )
932
  return false;
933
 
934
+ $activity = bp_get_user_last_activity( $user_id );
935
 
936
  if ( !is_numeric( $activity ) )
937
  $activity = strtotime( $activity );
944
  do_action( 'bp_first_activity_for_member', $user_id );
945
  }
946
 
947
+ if ( empty( $activity ) || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) ) {
948
+ bp_update_user_last_activity( $user_id, $current_time );
949
+ }
950
  }
951
  add_action( 'wp_head', 'bp_core_record_activity' );
952
 
953
  /**
954
+ * Format last activity string based on time since date given.
955
  *
956
+ * @uses bp_core_time_since() This function will return an English
957
+ * representation of the time elapsed.
958
+ *
959
+ * @param int|string $last_activity_date The date of last activity.
960
+ * @param string $string A sprintf()-able statement of the form '% ago'.
961
+ * @return string $last_active A string of the form '3 years ago'.
962
  */
963
  function bp_core_get_last_activity( $last_activity_date, $string ) {
964
 
975
  /**
976
  * Get the meta_key for a given piece of user metadata
977
  *
978
+ * BuddyPress stores a number of pieces of userdata in the WordPress central
979
+ * usermeta table. In order to allow plugins to enable multiple instances of
980
+ * BuddyPress on a single WP installation, BP's usermeta keys are filtered
981
+ * through this function, so that they can be altered on the fly.
982
  *
983
+ * Plugin authors should use BP's _user_meta() functions, which bakes in
984
+ * bp_get_user_meta_key():
985
  * $last_active = bp_get_user_meta( $user_id, 'last_activity', true );
986
+ * If you must use WP's _user_meta() functions directly for some reason, you
987
+ * should use this function to determine the $key parameter, eg
988
  * $last_active = get_user_meta( $user_id, bp_get_user_meta_key( 'last_activity' ), true );
989
  * If using the WP functions, do not not hardcode your meta keys.
990
  *
991
+ * @since BuddyPress (1.5.0)
992
+ *
993
+ * @uses apply_filters() Filter 'bp_get_user_meta_key' to modify keys individually.
994
  *
995
+ * @param string $key The usermeta meta_key.
996
+ * @return string $key The usermeta meta_key.
 
997
  */
998
  function bp_get_user_meta_key( $key = false ) {
999
  return apply_filters( 'bp_get_user_meta_key', $key );
1000
  }
1001
 
1002
  /**
1003
+ * Get a piece of usermeta.
1004
  *
1005
+ * This is a wrapper for get_user_meta() that allows for easy use of
1006
+ * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1007
+ * BP setups.
1008
  *
1009
+ * @since BuddyPress (1.5.0)
1010
+ *
1011
+ * @see get_user_meta() For complete details about parameters and return values.
1012
+ * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1013
  *
1014
+ * @param int $user_id The ID of the user whose meta you're fetching.
 
 
1015
  * @param string $key The meta key to retrieve.
1016
  * @param bool $single Whether to return a single value.
1017
  * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
1018
+ * is true.
1019
  */
1020
  function bp_get_user_meta( $user_id, $key, $single = false ) {
1021
  return get_user_meta( $user_id, bp_get_user_meta_key( $key ), $single );
1022
  }
1023
 
1024
  /**
1025
+ * Update a piece of usermeta.
1026
  *
1027
+ * This is a wrapper for update_user_meta() that allows for easy use of
1028
+ * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1029
+ * BP setups.
1030
  *
1031
+ * @since BuddyPress (1.5.0)
 
1032
  *
1033
+ * @see update_user_meta() For complete details about parameters and return values.
1034
+ * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1035
+ *
1036
+ * @param int $user_id The ID of the user whose meta you're setting.
1037
  * @param string $key The meta key to set.
1038
  * @param mixed $value Metadata value.
1039
  * @param mixed $prev_value Optional. Previous value to check before removing.
1040
+ * @return bool False on failure, true on success.
1041
  */
1042
  function bp_update_user_meta( $user_id, $key, $value, $prev_value = '' ) {
1043
  return update_user_meta( $user_id, bp_get_user_meta_key( $key ), $value, $prev_value );
1044
  }
1045
 
1046
  /**
1047
+ * Delete a piece of usermeta.
1048
  *
1049
+ * This is a wrapper for delete_user_meta() that allows for easy use of
1050
+ * bp_get_user_meta_key(), thereby increasing compatibility with non-standard
1051
+ * BP setups.
1052
  *
1053
+ * @since BuddyPress (1.5.0)
1054
+ *
1055
+ * @see delete_user_meta() For complete details about parameters and return values.
1056
+ * @uses bp_get_user_meta_key() For a filterable version of the meta key.
1057
  *
1058
+ * @param int $user_id The ID of the user whose meta you're deleting.
 
 
1059
  * @param string $key The meta key to delete.
1060
  * @param mixed $value Optional. Metadata value.
1061
  * @return bool False for failure. True for success.
1069
  /**
1070
  * Initializes {@link BP_Embed} after everything is loaded.
1071
  *
1072
+ * @since BuddyPress (1.5.0)
1073
+ *
1074
+ * @global BuddyPress $bp BuddyPress global settings.
1075
  */
1076
  function bp_embed_init() {
1077
  global $bp;
1084
  /**
1085
  * Are oembeds allowed in activity items?
1086
  *
1087
+ * @since BuddyPress (1.5.0)
1088
+ *
1089
+ * @return bool False when activity embed support is disabled; true when
1090
+ * enabled. Default: true.
1091
  */
1092
  function bp_use_embed_in_activity() {
1093
  return apply_filters( 'bp_use_oembed_in_activity', !defined( 'BP_EMBED_DISABLE_ACTIVITY' ) || !BP_EMBED_DISABLE_ACTIVITY );
1096
  /**
1097
  * Are oembeds allwoed in activity replies?
1098
  *
1099
+ * @since BuddyPress (1.5.0)
1100
+ *
1101
+ * @return bool False when activity replies embed support is disabled; true
1102
+ * when enabled. Default: true.
1103
  */
1104
  function bp_use_embed_in_activity_replies() {
1105
  return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES );
1108
  /**
1109
  * Are oembeds allowed in forum posts?
1110
  *
1111
+ * @since BuddyPress (1.5.0)
1112
+ *
1113
+ * @return bool False when forum post embed support is disabled; true when
1114
+ * enabled. Default: true.
1115
  */
1116
  function bp_use_embed_in_forum_posts() {
1117
  return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS );
1120
  /**
1121
  * Are oembeds allowed in private messages?
1122
  *
1123
+ * @since BuddyPress (1.5.0)
1124
+ *
1125
+ * @return bool False when private message embed support is disabled; true when
1126
+ * enabled. Default: true.
1127
  */
1128
  function bp_use_embed_in_private_messages() {
1129
  return apply_filters( 'bp_use_embed_in_private_messages', !defined( 'BP_EMBED_DISABLE_PRIVATE_MESSAGES' ) || !BP_EMBED_DISABLE_PRIVATE_MESSAGES );
1132
  /** Admin *********************************************************************/
1133
 
1134
  /**
1135
+ * Output the correct admin URL based on BuddyPress and WordPress configuration.
1136
  *
1137
+ * @since BuddyPress (1.5.0)
 
1138
  *
1139
+ * @see bp_get_admin_url() For description of parameters.
 
1140
  *
1141
+ * @param string $path See {@link bp_get_admin_url()}.
1142
+ * @param string $scheme See {@link bp_get_admin_url()}.
1143
  */
1144
  function bp_admin_url( $path = '', $scheme = 'admin' ) {
1145
  echo bp_get_admin_url( $path, $scheme );
1146
  }
1147
  /**
1148
+ * Return the correct admin URL based on BuddyPress and WordPress configuration.
1149
  *
1150
+ * @since BuddyPress (1.5.0)
 
 
 
 
1151
  *
1152
  * @uses bp_core_do_network_admin()
1153
  * @uses network_admin_url()
1154
  * @uses admin_url()
1155
+ *
1156
+ * @param string $path Optional. The sub-path under /wp-admin to be
1157
+ * appended to the admin URL.
1158
+ * @param string $scheme The scheme to use. Default is 'admin', which
1159
+ * obeys {@link force_ssl_admin()} and {@link is_ssl()}. 'http'
1160
+ * or 'https' can be passed to force those schemes.
1161
+ * @return string Admin url link with optional path appended.
1162
  */
1163
  function bp_get_admin_url( $path = '', $scheme = 'admin' ) {
1164
 
1175
  }
1176
 
1177
  /**
1178
+ * Should BuddyPress appear in network admin (vs a single site Dashboard)?
1179
  *
1180
  * Because BuddyPress can be installed in multiple ways and with multiple
1181
  * configurations, we need to check a few things to be confident about where
1182
  * to hook into certain areas of WordPress's admin.
1183
  *
1184
+ * @since BuddyPress (1.5.0)
 
1185
  *
1186
  * @uses bp_is_network_activated()
1187
  * @uses bp_is_multiblog_mode()
1188
+ *
1189
+ * @return bool True if the BP admin screen should appear in the Network Admin,
1190
+ * otherwise false.
1191
  */
1192
  function bp_core_do_network_admin() {
1193
 
1200
  return (bool) apply_filters( 'bp_core_do_network_admin', $retval );
1201
  }
1202
 
1203
+ /**
1204
+ * Return the action name that BuddyPress nav setup callbacks should be hooked to.
1205
+ *
1206
+ * Functions used to set up BP Dashboard pages (wrapping such admin-panel
1207
+ * functions as add_submenu_page()) should use bp_core_admin_hook() for the
1208
+ * first parameter in add_action(). BuddyPress will then determine
1209
+ * automatically whether to load the panels in the Network Admin. Ie:
1210
+ *
1211
+ * add_action( bp_core_admin_hook(), 'myplugin_dashboard_panel_setup' );
1212
+ *
1213
+ * @return string $hook The proper hook ('network_admin_menu' or 'admin_menu').
1214
+ */
1215
  function bp_core_admin_hook() {
1216
  $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
1217
 
1221
  /** Multisite *****************************************************************/
1222
 
1223
  /**
1224
+ * Is this the root blog?
1225
  *
1226
+ * @since BuddyPress (1.5.0)
 
1227
  *
1228
+ * @param int $blog_id Optional. Default: the ID of the current blog.
1229
  * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
1230
  */
1231
  function bp_is_root_blog( $blog_id = 0 ) {
1245
  }
1246
 
1247
  /**
1248
+ * Get the ID of the root blog.
1249
  *
1250
+ * The "root blog" is the blog on a WordPress network where BuddyPress content
1251
+ * appears (where member profile URLs resolve, where a given theme is loaded,
1252
+ * etc.).
1253
+ *
1254
+ * @since BuddyPress (1.5.0)
1255
  *
1256
+ * @return int The root site ID.
1257
  */
1258
  function bp_get_root_blog_id() {
1259
  global $bp;
1284
  * a very small use-case with large architectural shortcomings, so do not go
1285
  * down this road unless you specifically need to.
1286
  *
1287
+ * @since BuddyPress (1.5.0)
 
1288
  *
1289
+ * @uses apply_filters() Filter 'bp_is_multiblog_mode' to alter.
1290
+ *
1291
+ * @return bool False when multiblog mode is disabled; true when enabled.
1292
+ * Default: false.
1293
  */
1294
  function bp_is_multiblog_mode() {
1295
 
1316
  *
1317
  * Used to determine admin menu placement, and where settings and options are
1318
  * stored. If you're being *really* clever and manually pulling BuddyPress in
1319
+ * with an mu-plugin or some other method, you'll want to filter
1320
+ * 'bp_is_network_activated' and override the auto-determined value.
1321
+ *
1322
+ * @since BuddyPress (1.7.0)
1323
  *
1324
+ * @return bool True if BuddyPress is network activated.
 
1325
  */
1326
  function bp_is_network_activated() {
1327
 
1342
  /** Global Manipulators *******************************************************/
1343
 
1344
  /**
1345
+ * Set the $bp->is_directory global.
1346
+ *
1347
+ * @global BuddyPress $bp The one true BuddyPress instance.
1348
  *
1349
+ * @param bool $is_directory Optional. Default: false.
1350
+ * @param string $component Optional. Component name. Default: the current
1351
+ * component.
1352
  */
1353
  function bp_update_is_directory( $is_directory = false, $component = '' ) {
1354
  global $bp;
1360
  }
1361
 
1362
  /**
1363
+ * Set the $bp->is_item_admin global.
1364
  *
1365
+ * @global BuddyPress $bp The one true BuddyPress instance.
1366
+ *
1367
+ * @param bool $is_item_admin Optional. Default: false.
1368
+ * @param string $component. Optional. Component name. Default: the current
1369
+ * component.
1370
  */
1371
  function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
1372
  global $bp;
1378
  }
1379
 
1380
  /**
1381
+ * Set the $bp->is_item_mod global.
1382
+ *
1383
+ * @global BuddyPress $bp The one true BuddyPress instance.
1384
  *
1385
+ * @param bool $is_item_mod Optional. Default: false.
1386
+ * @param string $component. Optional. Component name. Default: the current
1387
+ * component.
1388
  */
1389
  function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
1390
  global $bp;
1396
  }
1397
 
1398
  /**
1399
+ * Trigger a 404.
1400
+ *
1401
+ * @since BuddyPress (1.5.0)
1402
  *
1403
+ * @global WP_Query $wp_query WordPress query object.
1404
+ *
1405
+ * @param string $redirect If 'remove_canonical_direct', remove WordPress'
1406
+ * "helpful" redirect_canonical action. Default: 'remove_canonical_redirect'.
1407
  */
1408
  function bp_do_404( $redirect = 'remove_canonical_direct' ) {
1409
  global $wp_query;
1425
  *
1426
  * To avoid security exploits within the theme.
1427
  *
1428
+ * @since BuddyPress (1.6.0)
1429
  *
1430
  * @uses do_action() Calls 'bp_verify_nonce_request' on $action.
1431
+ *
1432
+ * @param string $action Action nonce.
1433
+ * @param string $query_arg where to look for nonce in $_REQUEST.
1434
+ * @return bool True if the nonce is verified, otherwise false.
1435
  */
1436
  function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
1437
 
1438
+ /** Home URL **************************************************************/
1439
+
1440
+ // Parse home_url() into pieces to remove query-strings, strange characters,
1441
+ // and other funny things that plugins might to do to it.
1442
+ $parsed_home = parse_url( home_url( '/', ( is_ssl() ? 'https://' : 'http://' ) ) );
1443
+
1444
+ // Maybe include the port, if it's included
1445
+ if ( isset( $parsed_home['port'] ) ) {
1446
+ $parsed_host = $parsed_home['host'] . ':' . $parsed_home['port'];
1447
+ } else {
1448
+ $parsed_host = $parsed_home['host'];
1449
+ }
1450
+
1451
+ // Set the home URL for use in comparisons
1452
+ $home_url = trim( strtolower( $parsed_home['scheme'] . '://' . $parsed_host . $parsed_home['path'] ), '/' );
1453
+
1454
+ /** Requested URL *********************************************************/
1455
+
1456
+ // Maybe include the port, if it's included in home_url()
1457
+ if ( isset( $parsed_home['port'] ) ) {
1458
+ $request_host = $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'];
1459
+ } else {
1460
+ $request_host = $_SERVER['HTTP_HOST'];
1461
+ }
1462
+
1463
+ // Build the currently requested URL
1464
+ $scheme = is_ssl() ? 'https://' : 'http://';
1465
+ $requested_url = strtolower( $scheme . $request_host . $_SERVER['REQUEST_URI'] );
1466
+
1467
+ /** Look for match ********************************************************/
1468
 
1469
+ // Filter the requested URL, for configurations like reverse proxying
1470
+ $matched_url = apply_filters( 'bp_verify_nonce_request_url', $requested_url );
1471
 
1472
  // Check the nonce
1473
  $result = isset( $_REQUEST[$query_arg] ) ? wp_verify_nonce( $_REQUEST[$query_arg], $action ) : false;
1474
 
1475
  // Nonce check failed
1476
+ if ( empty( $result ) || empty( $action ) || ( strpos( $matched_url, $home_url ) !== 0 ) ) {
1477
  $result = false;
1478
+ }
1479
 
1480
  // Do extra things
1481
  do_action( 'bp_verify_nonce_request', $action, $result );
1483
  return $result;
1484
  }
1485
 
1486
+ /** Requests ******************************************************************/
1487
+
1488
+ /**
1489
+ * Return true|false if this is a POST request
1490
+ *
1491
+ * @since BuddyPress (1.9.0)
1492
+ * @return bool
1493
+ */
1494
+ function bp_is_post_request() {
1495
+ return (bool) ( 'POST' === strtoupper( $_SERVER['REQUEST_METHOD'] ) );
1496
+ }
1497
+
1498
+ /**
1499
+ * Return true|false if this is a GET request
1500
+ *
1501
+ * @since BuddyPress (1.9.0)
1502
+ * @return bool
1503
+ */
1504
+ function bp_is_get_request() {
1505
+ return (bool) ( 'GET' === strtoupper( $_SERVER['REQUEST_METHOD'] ) );
1506
+ }
1507
+
1508
+
1509
  /** Miscellaneous hooks *******************************************************/
1510
 
1511
  /**
1512
+ * Load the buddypress translation file for current language.
1513
+ *
1514
+ * @see load_textdomain() for a description of return values.
1515
  *
1516
+ * @return bool True on success, false on failure.
1517
  */
1518
  function bp_core_load_buddypress_textdomain() {
1519
  // Try to load via load_plugin_textdomain() first, for future
1531
  add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
1532
 
1533
  /**
1534
+ * A javascript-free implementation of the search functions in BuddyPress.
1535
  *
 
1536
  * @param string $slug The slug to redirect to for searching.
1537
  */
1538
  function bp_core_action_search_site( $slug = '' ) {
1596
  add_action( 'bp_init', 'bp_core_action_search_site', 7 );
1597
 
1598
  /**
1599
+ * Print the generation time in the footer of the site.
 
 
1600
  */
1601
  function bp_core_print_generation_time() {
1602
  ?>
1606
  <?php
1607
  }
1608
  add_action( 'wp_footer', 'bp_core_print_generation_time' );
1609
+
1610
+ /** Nav Menu ******************************************************************/
1611
+
1612
+ /**
1613
+ * Create fake "post" objects for BP's logged-in nav menu for use in the WordPress "Menus" settings page.
1614
+ *
1615
+ * WordPress nav menus work by representing post or tax term data as a custom
1616
+ * post type, which is then used to populate the checkboxes that appear on
1617
+ * Dashboard > Appearance > Menu as well as the menu as rendered on the front
1618
+ * end. Most of the items in the BuddyPress set of nav items are neither posts
1619
+ * nor tax terms, so we fake a post-like object so as to be compatible with the
1620
+ * menu.
1621
+ *
1622
+ * This technique also allows us to generate links dynamically, so that, for
1623
+ * example, "My Profile" will always point to the URL of the profile of the
1624
+ * logged-in user.
1625
+ *
1626
+ * @since BuddyPress (1.9.0)
1627
+ *
1628
+ * @return mixed A URL or an array of dummy pages.
1629
+ */
1630
+ function bp_nav_menu_get_loggedin_pages() {
1631
+
1632
+ // Try to catch the cached version first
1633
+ if ( ! empty( buddypress()->wp_nav_menu_items->loggedin ) ) {
1634
+ return buddypress()->wp_nav_menu_items->loggedin;
1635
+ }
1636
+
1637
+ // Pull up a list of items registered in BP's top-level nav array
1638
+ $bp_menu_items = buddypress()->bp_nav;
1639
+
1640
+ // Alphabetize
1641
+ $bp_menu_items = bp_alpha_sort_by_key( $bp_menu_items, 'name' );
1642
+
1643
+ // Some BP nav menu items will not be represented in bp_nav, because
1644
+ // they are not real BP components. We add them manually here.
1645
+ $bp_menu_items[] = array(
1646
+ 'name' => __( 'Log Out', 'buddypress' ),
1647
+ 'slug' => 'logout',
1648
+ 'link' => wp_logout_url(),
1649
+ );
1650
+
1651
+ // If there's nothing to show, we're done
1652
+ if ( count( $bp_menu_items ) < 1 ) {
1653
+ return false;
1654
+ }
1655
+
1656
+ $page_args = array();
1657
+
1658
+ foreach ( $bp_menu_items as $bp_item ) {
1659
+ $item_name = '';
1660
+
1661
+ // Remove <span>number</span>
1662
+ $item_name = preg_replace( '/([.0-9]+)/', '', $bp_item['name'] );
1663
+ $item_name = trim( strip_tags( $item_name ) );
1664
+
1665
+ $page_args[ $bp_item['slug'] ] = (object) array(
1666
+ 'ID' => -1,
1667
+ 'post_title' => $item_name,
1668
+ 'post_author' => 0,
1669
+ 'post_date' => 0,
1670
+ 'post_excerpt' => $bp_item['slug'],
1671
+ 'post_type' => 'page',
1672
+ 'post_status' => 'publish',
1673
+ 'comment_status' => 'closed',
1674
+ 'guid' => $bp_item['link']
1675
+ );
1676
+ }
1677
+
1678
+ if ( empty( buddypress()->wp_nav_menu_items ) ) {
1679
+ buddypress()->wp_nav_menu_items = new stdClass;
1680
+ }
1681
+
1682
+ buddypress()->wp_nav_menu_items->loggedin = $page_args;
1683
+
1684
+ return $page_args;
1685
+ }
1686
+
1687
+ /**
1688
+ * Create fake "post" objects for BP's logged-out nav menu for use in the WordPress "Menus" settings page.
1689
+ *
1690
+ * WordPress nav menus work by representing post or tax term data as a custom
1691
+ * post type, which is then used to populate the checkboxes that appear on
1692
+ * Dashboard > Appearance > Menu as well as the menu as rendered on the front
1693
+ * end. Most of the items in the BuddyPress set of nav items are neither posts
1694
+ * nor tax terms, so we fake a post-like object so as to be compatible with the
1695
+ * menu.
1696
+ *
1697
+ * @since BuddyPress (1.9.0)
1698
+ *
1699
+ * @return mixed A URL or an array of dummy pages.
1700
+ */
1701
+ function bp_nav_menu_get_loggedout_pages() {
1702
+
1703
+ // Try to catch the cached version first
1704
+ if ( ! empty( buddypress()->wp_nav_menu_items->loggedout ) ) {
1705
+ return buddypress()->wp_nav_menu_items->loggedout;
1706
+ }
1707
+
1708
+ $bp_menu_items = array();
1709
+
1710
+ // Some BP nav menu items will not be represented in bp_nav, because
1711
+ // they are not real BP components. We add them manually here.
1712
+ $bp_menu_items[] = array(
1713
+ 'name' => __( 'Log In', 'buddypress' ),
1714
+ 'slug' => 'login',
1715
+ 'link' => wp_login_url(),
1716
+ );
1717
+
1718
+ // The Register page will not always be available (ie, when
1719
+ // registration is disabled)
1720
+ $bp_directory_page_ids = bp_core_get_directory_page_ids();
1721
+
1722
+ if( ! empty( $bp_directory_page_ids['register'] ) ) {
1723
+ $register_page = get_post( $bp_directory_page_ids['register'] );
1724
+ $bp_menu_items[] = array(
1725
+ 'name' => $register_page->post_title,
1726
+ 'slug' => $register_page->post_name,
1727
+ 'link' => get_permalink( $register_page->ID ),
1728
+ );
1729
+ }
1730
+
1731
+ // If there's nothing to show, we're done
1732
+ if ( count( $bp_menu_items ) < 1 ) {
1733
+ return false;
1734
+ }
1735
+
1736
+ $page_args = array();
1737
+
1738
+ foreach ( $bp_menu_items as $bp_item ) {
1739
+ $page_args[ $bp_item['slug'] ] = (object) array(
1740
+ 'ID' => -1,
1741
+ 'post_title' => $bp_item['name'],
1742
+ 'post_author' => 0,
1743
+ 'post_date' => 0,
1744
+ 'post_excerpt' => $bp_item['slug'],
1745
+ 'post_type' => 'page',
1746
+ 'post_status' => 'publish',
1747
+ 'comment_status' => 'closed',
1748
+ 'guid' => $bp_item['link']
1749
+ );
1750
+ }
1751
+
1752
+ if ( empty( buddypress()->wp_nav_menu_items ) ) {
1753
+ buddypress()->wp_nav_menu_items = new stdClass;
1754
+ }
1755
+
1756
+ buddypress()->wp_nav_menu_items->loggedout = $page_args;
1757
+
1758
+ return $page_args;
1759
+ }
1760
+
1761
+ /**
1762
+ * Get the URL for a BuddyPress WP nav menu item, based on slug.
1763
+ *
1764
+ * BuddyPress-specific WP nav menu items have dynamically generated URLs,
1765
+ * based on the identity of the current user. This function lets you fetch the
1766
+ * proper URL for a given nav item slug (such as 'login' or 'messages').
1767
+ *
1768
+ * @since BuddyPress (1.9.0)
1769
+ *
1770
+ * @param string $slug The slug of the nav item: login, register, or one of the
1771
+ * slugs from buddypress()->bp_nav.
1772
+ * @return string $nav_item_url The URL generated for the current user.
1773
+ */
1774
+ function bp_nav_menu_get_item_url( $slug ) {
1775
+ $nav_item_url = '';
1776
+ $nav_menu_items = bp_nav_menu_get_loggedin_pages();
1777
+
1778
+ if ( isset( $nav_menu_items[ $slug ] ) ) {
1779
+ $nav_item_url = $nav_menu_items[ $slug ]->guid;
1780
+ }
1781
+
1782
+ return $nav_item_url;
1783
+ }
bp-core/bp-core-loader.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Core Loader
5
  *
6
- * Core contains the commonly used functions, classes, and API's
7
  *
8
  * @package BuddyPress
9
  * @subpackage Core
@@ -15,9 +15,9 @@ if ( !defined( 'ABSPATH' ) ) exit;
15
  class BP_Core extends BP_Component {
16
 
17
  /**
18
- * Start the members component creation process
19
  *
20
- * @since BuddyPress (1.5)
21
  *
22
  * @uses BP_Core::bootstrap()
23
  */
@@ -32,17 +32,15 @@ class BP_Core extends BP_Component {
32
  }
33
 
34
  /**
35
- * Populate the global data needed before BuddyPress can continue
36
  *
37
  * This involves figuring out the currently required, active, deactive,
38
  * and optional components.
39
  *
40
- * @since BuddyPress (1.5)
41
- *
42
- * @global BuddyPress $bp
43
  */
44
  private function bootstrap() {
45
- global $bp;
46
 
47
  /**
48
  * At this point in the stack, BuddyPress core has been loaded but
@@ -56,7 +54,7 @@ class BP_Core extends BP_Component {
56
  /** Components ********************************************************/
57
 
58
  // Set the included and optional components.
59
- $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'settings', 'xprofile' ) );
60
 
61
  // Set the required components
62
  $bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
@@ -110,6 +108,13 @@ class BP_Core extends BP_Component {
110
  $bp->required_components[] = 'core';
111
  }
112
 
 
 
 
 
 
 
 
113
  public function includes( $includes = array() ) {
114
 
115
  if ( !is_admin() )
@@ -123,15 +128,19 @@ class BP_Core extends BP_Component {
123
  }
124
 
125
  /**
 
 
126
  * Sets up a majority of the BuddyPress globals that require a minimal
127
  * amount of processing, meaning they cannot be set in the BuddyPress class.
128
  *
129
- * @since BuddyPress (1.5)
 
 
130
  *
131
- * @global BuddyPress $bp
132
  */
133
  public function setup_globals( $args = array() ) {
134
- global $bp;
135
 
136
  /** Database **********************************************************/
137
 
@@ -168,7 +177,8 @@ class BP_Core extends BP_Component {
168
  $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user );
169
  $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user );
170
 
171
- // Notifications Table
 
172
  $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
173
 
174
  /**
@@ -188,21 +198,23 @@ class BP_Core extends BP_Component {
188
  }
189
 
190
  /**
191
- * Setup BuddyBar navigation
192
  *
193
- * @since BuddyPress (1.5)
194
  *
195
- * @global BuddyPress $bp
 
 
 
 
 
196
  */
197
- public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
198
- global $bp;
199
 
200
  // If xprofile component is disabled, revert to WordPress profile
201
  if ( !bp_is_active( 'xprofile' ) ) {
202
 
203
- // Define local variable
204
- $sub_nav = array();
205
-
206
  // Fallback values if xprofile is disabled
207
  if ( ! isset( $bp->core->profile ) ) {
208
  $bp->core->profile = new stdClass;
@@ -236,14 +248,13 @@ class BP_Core extends BP_Component {
236
  }
237
 
238
  /**
239
- * Setup the BuddyPress Core component
240
  *
241
- * @since BuddyPress (1.6)
242
  *
243
- * @global BuddyPress $bp
244
  */
245
  function bp_setup_core() {
246
- global $bp;
247
- $bp->core = new BP_Core();
248
  }
249
  add_action( 'bp_setup_components', 'bp_setup_core', 2 );
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Core Loader.
5
  *
6
+ * Core contains the commonly used functions, classes, and APIs.
7
  *
8
  * @package BuddyPress
9
  * @subpackage Core
15
  class BP_Core extends BP_Component {
16
 
17
  /**
18
+ * Start the members component creation process.
19
  *
20
+ * @since BuddyPress (1.5.0)
21
  *
22
  * @uses BP_Core::bootstrap()
23
  */
32
  }
33
 
34
  /**
35
+ * Populate the global data needed before BuddyPress can continue.
36
  *
37
  * This involves figuring out the currently required, active, deactive,
38
  * and optional components.
39
  *
40
+ * @since BuddyPress (1.5.0)
 
 
41
  */
42
  private function bootstrap() {
43
+ $bp = buddypress();
44
 
45
  /**
46
  * At this point in the stack, BuddyPress core has been loaded but
54
  /** Components ********************************************************/
55
 
56
  // Set the included and optional components.
57
+ $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) );
58
 
59
  // Set the required components
60
  $bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
108
  $bp->required_components[] = 'core';
109
  }
110
 
111
+ /**
112
+ * Include bp-core files.
113
+ *
114
+ * @see BP_Component::includes() for description of parameters.
115
+ *
116
+ * @param array $includes See {@link BP_Component::includes()}.
117
+ */
118
  public function includes( $includes = array() ) {
119
 
120
  if ( !is_admin() )
128
  }
129
 
130
  /**
131
+ * Set up bp-core global settings.
132
+ *
133
  * Sets up a majority of the BuddyPress globals that require a minimal
134
  * amount of processing, meaning they cannot be set in the BuddyPress class.
135
  *
136
+ * @since BuddyPress (1.5.0)
137
+ *
138
+ * @see BP_Component::setup_globals() for description of parameters.
139
  *
140
+ * @param array $args See {@link BP_Component::setup_globals()}.
141
  */
142
  public function setup_globals( $args = array() ) {
143
+ $bp = buddypress();
144
 
145
  /** Database **********************************************************/
146
 
177
  $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user );
178
  $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user );
179
 
180
+ // Notifications table. Included here for legacy purposes. Use
181
+ // bp-notifications instead.
182
  $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
183
 
184
  /**
198
  }
199
 
200
  /**
201
+ * Set up component navigation.
202
  *
203
+ * @since BuddyPress (1.5.0)
204
  *
205
+ * @see BP_Component::setup_nav() for a description of arguments.
206
+ *
207
+ * @param array $main_nav Optional. See BP_Component::setup_nav() for
208
+ * description.
209
+ * @param array $sub_nav Optional. See BP_Component::setup_nav() for
210
+ * description.
211
  */
212
+ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
213
+ $bp = buddypress();
214
 
215
  // If xprofile component is disabled, revert to WordPress profile
216
  if ( !bp_is_active( 'xprofile' ) ) {
217
 
 
 
 
218
  // Fallback values if xprofile is disabled
219
  if ( ! isset( $bp->core->profile ) ) {
220
  $bp->core->profile = new stdClass;
248
  }
249
 
250
  /**
251
+ * Set up the BuddyPress Core component.
252
  *
253
+ * @since BuddyPress (1.6.0)
254
  *
255
+ * @global BuddyPress $bp BuddyPress global settings object.
256
  */
257
  function bp_setup_core() {
258
+ buddypress()->core = new BP_Core();
 
259
  }
260
  add_action( 'bp_setup_components', 'bp_setup_core', 2 );
bp-core/bp-core-moderation.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /**
3
- * BuddyPress Moderation Functions
4
  *
5
  * @package BuddyPress
6
  * @subpackage Core
7
- * @since BuddyPress (1.6)
8
  */
9
 
10
  // Exit if accessed directly
@@ -13,18 +13,20 @@ if ( !defined( 'ABSPATH' ) ) exit;
13
  /** Moderation ****************************************************************/
14
 
15
  /**
16
- * Check for flooding
17
  *
18
  * Check to make sure that a user is not making too many posts in a short amount
19
  * of time.
20
  *
21
- * @param int $user_id User id to check for flood
22
- * @return bool True if there is no flooding, true if there is
23
- * @since BuddyPress (1.6)
24
- * @uses current_user_can() To check if the current user can throttle
25
- * @uses bp_get_option() To get the throttle time
26
- * @uses get_transient() To get the last posted transient of the ip
27
- * @uses get_user_meta() To get the last posted meta of the user
 
 
28
  */
29
  function bp_core_check_for_flood( $user_id = 0 ) {
30
 
@@ -44,16 +46,18 @@ function bp_core_check_for_flood( $user_id = 0 ) {
44
  }
45
 
46
  /**
47
- * Check for moderation keys and too many links
 
 
 
 
 
 
48
  *
49
- * @param int $user_id Topic or reply author ID
50
- * @param string $title The title of the content
51
- * @param string $content The content being posted
52
- * @return bool True if test is passed, false if fail
53
- * @since BuddyPress (1.6)
54
- * @uses bp_current_author_ip() To get current user IP address
55
- * @uses bp_current_author_ua() To get current user agent
56
- * @uses bp_current_user_can() Allow super admins to bypass blacklist
57
  */
58
  function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {
59
 
@@ -150,16 +154,18 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = ''
150
  }
151
 
152
  /**
153
- * Checks for blocked keys
154
  *
155
- * @param int $user_id Topic or reply author ID
156
- * @param string $title The title of the content
157
- * @param string $content The content being posted
158
- * @return bool True if test is passed, false if fail
159
- * @uses bp_current_author_ip() To get current user IP address
160
- * @uses bp_current_author_ua() To get current user agent
161
- * @uses bp_current_user_can() Allow super admins to bypass blacklist
162
- * @since BuddyPress (1.6)
 
 
163
  */
164
  function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {
165
 
@@ -238,10 +244,11 @@ function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' )
238
  }
239
 
240
  /**
241
- * Get the current-user IP address
242
  *
243
- * @return string
244
- * @since BuddyPress (1.6)
 
245
  */
246
  function bp_core_current_user_ip() {
247
  $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
@@ -250,10 +257,11 @@ function bp_core_current_user_ip() {
250
  }
251
 
252
  /**
253
- * Get the current-user user-agent
 
 
254
  *
255
- * @return string
256
- * @since BuddyPress (1.6)
257
  */
258
  function bp_core_current_user_ua() {
259
 
1
  <?php
2
  /**
3
+ * BuddyPress Moderation Functions.
4
  *
5
  * @package BuddyPress
6
  * @subpackage Core
7
+ * @since BuddyPress (1.6.0)
8
  */
9
 
10
  // Exit if accessed directly
13
  /** Moderation ****************************************************************/
14
 
15
  /**
16
+ * Check for flooding.
17
  *
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.
25
+ * @uses get_transient() To get the last posted transient of the ip.
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 ) {
32
 
46
  }
47
 
48
  /**
49
+ * Check for moderation keys and too many links.
50
+ *
51
+ * @since BuddyPress (1.6.0)
52
+ *
53
+ * @uses bp_current_author_ip() To get current user IP address.
54
+ * @uses bp_current_author_ua() To get current user agent.
55
+ * @uses bp_current_user_can() Allow super admins to bypass blacklist.
56
  *
57
+ * @param int $user_id Topic or reply author ID.
58
+ * @param string $title The title of the content.
59
+ * @param string $content The content being posted.
60
+ * @return bool True if test is passed, false if fail.
 
 
 
 
61
  */
62
  function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {
63
 
154
  }
155
 
156
  /**
157
+ * Check for blocked keys.
158
  *
159
+ * @since BuddyPress (1.6.0)
160
+ *
161
+ * @uses bp_current_author_ip() To get current user IP address.
162
+ * @uses bp_current_author_ua() To get current user agent.
163
+ * @uses bp_current_user_can() Allow super admins to bypass blacklist.
164
+ *
165
+ * @param int $user_id Topic or reply author ID.
166
+ * @param string $title The title of the content.
167
+ * @param string $content The content being posted.
168
+ * @return bool True if test is passed, false if fail.
169
  */
170
  function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {
171
 
244
  }
245
 
246
  /**
247
+ * Get the current user's IP address.
248
  *
249
+ * @since BuddyPress (1.6.0)
250
+ *
251
+ * @return string IP address.
252
  */
253
  function bp_core_current_user_ip() {
254
  $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
257
  }
258
 
259
  /**
260
+ * Get the current user's user-agent.
261
+ *
262
+ * @since BuddyPress (1.6.0)
263
  *
264
+ * @return string User agent string.
 
265
  */
266
  function bp_core_current_user_ua() {
267
 
bp-core/bp-core-options.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Options
5
  *
6
  * @package BuddyPress
7
  * @subpackage Options
@@ -11,11 +11,11 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Get the default site options and their values
15
  *
16
- * @since BuddyPress (1.6)
17
  *
18
- * @return array Filtered option names and values
19
  */
20
  function bp_get_default_options() {
21
 
@@ -86,16 +86,18 @@ function bp_get_default_options() {
86
  }
87
 
88
  /**
89
- * Add default options
90
  *
91
  * Hooked to bp_activate, it is only called once when BuddyPress is activated.
92
  * This is non-destructive, so existing settings will not be overridden.
93
  *
94
- * @since BuddyPress (1.6)
95
  *
96
- * @uses bp_get_default_options() To get default options
97
- * @uses add_option() Adds default options
98
- * @uses do_action() Calls 'bp_add_options'
 
 
99
  */
100
  function bp_add_options() {
101
 
@@ -111,16 +113,18 @@ function bp_add_options() {
111
  }
112
 
113
  /**
114
- * Delete default options
115
  *
116
  * Hooked to bp_uninstall, it is only called once when BuddyPress is uninstalled.
117
  * This is destructive, so existing settings will be destroyed.
118
  *
119
- * @since BuddyPress (1.6)
120
  *
121
- * @uses bp_get_default_options() To get default options
122
- * @uses delete_option() Removes default options
123
- * @uses do_action() Calls 'bp_delete_options'
 
 
124
  */
125
  function bp_delete_options() {
126
 
@@ -136,14 +140,15 @@ function bp_delete_options() {
136
  }
137
 
138
  /**
139
- * Add filters to each BuddyPress option and allow them to be overloaded from
140
- * inside the $bp->options array.
141
  *
142
- * @since BuddyPress (1.6)
143
  *
144
- * @uses bp_get_default_options() To get default options
145
- * @uses add_filter() To add filters to 'pre_option_{$key}'
146
- * @uses do_action() Calls 'bp_add_option_filters'
 
 
147
  */
148
  function bp_setup_option_filters() {
149
 
@@ -159,8 +164,9 @@ function bp_setup_option_filters() {
159
  }
160
 
161
  /**
162
- * Filter default options and allow them to be overloaded from inside the
163
- * $bp->options array.
 
164
  *
165
  * @since BuddyPress (1.6)
166
  *
@@ -186,20 +192,21 @@ function bp_pre_get_option( $value = false ) {
186
  }
187
 
188
  /**
189
- * Retrieve an option
190
  *
191
- * This is a wrapper for get_blog_option(), which in turn stores settings data (such as bp-pages)
192
- * on the appropriate blog, given your current setup.
193
  *
194
  * The 'bp_get_option' filter is primarily for backward-compatibility.
195
  *
196
- * @package BuddyPress
197
- * @since BuddyPress (1.5)
198
  *
199
  * @uses bp_get_root_blog_id()
200
- * @param string $option_name The option to be retrieved
201
- * @param string $default Optional. Default value to be returned if the option isn't set
202
- * @return mixed The value for the option
 
 
203
  */
204
  function bp_get_option( $option_name, $default = '' ) {
205
  $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default );
@@ -208,46 +215,49 @@ function bp_get_option( $option_name, $default = '' ) {
208
  }
209
 
210
  /**
211
- * Save an option
212
  *
213
- * This is a wrapper for update_blog_option(), which in turn stores settings data (such as bp-pages)
214
- * on the appropriate blog, given your current setup.
 
215
  *
216
- * @package BuddyPress
217
- * @since BuddyPress (1.5)
218
  *
219
  * @uses bp_get_root_blog_id()
220
- * @param string $option_name The option key to be set
221
- * @param string $value The value to be set
 
222
  */
223
  function bp_update_option( $option_name, $value ) {
224
  update_blog_option( bp_get_root_blog_id(), $option_name, $value );
225
  }
226
 
227
  /**
228
- * Delete an option
229
  *
230
- * This is a wrapper for delete_blog_option(), which in turn deletes settings data (such as
231
- * bp-pages) on the appropriate blog, given your current setup.
 
232
  *
233
- * @package BuddyPress
234
- * @since BuddyPress (1.5)
235
  *
236
  * @uses bp_get_root_blog_id()
237
- * @param string $option_name The option key to be set
 
238
  */
239
  function bp_delete_option( $option_name ) {
240
  delete_blog_option( bp_get_root_blog_id(), $option_name );
241
  }
242
 
243
  /**
244
- * When switching from single to multisite we need to copy blog options to
245
- * site options.
 
 
246
  *
247
- * This function is no longer used
248
  *
249
- * @package BuddyPress Core
250
- * @deprecated Since BuddyPress (1.6)
251
  */
252
  function bp_core_activate_site_options( $keys = array() ) {
253
  global $bp;
@@ -274,12 +284,15 @@ function bp_core_activate_site_options( $keys = array() ) {
274
  }
275
 
276
  /**
 
 
277
  * BuddyPress uses common options to store configuration settings. Many of these
278
  * settings are needed at run time. Instead of fetching them all and adding many
279
  * initial queries to each page load, let's fetch them all in one go.
280
  *
281
- * @package BuddyPress Core
282
- * @todo Use settings API and audit these methods
 
283
  */
284
  function bp_core_get_root_options() {
285
  global $wpdb;
@@ -375,12 +388,13 @@ function bp_core_get_root_options() {
375
  /**
376
  * Is profile sycing disabled?
377
  *
378
- * @since BuddyPress (1.6)
379
  *
380
- * @param bool $default Optional.Default value true
381
  *
382
- * @uses bp_get_option() To get the profile sync option
383
- * @return bool Is profile sync enabled or not
 
384
  */
385
  function bp_disable_profile_sync( $default = true ) {
386
  return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) );
@@ -389,12 +403,14 @@ function bp_disable_profile_sync( $default = true ) {
389
  /**
390
  * Is the Toolbar hidden for logged out users?
391
  *
392
- * @since BuddyPress (1.6)
393
  *
394
- * @param bool $default Optional.Default value true
395
  *
396
- * @uses bp_get_option() To get the logged out Toolbar option
397
- * @return bool Is logged out Toolbar enabled or not
 
 
398
  */
399
  function bp_hide_loggedout_adminbar( $default = true ) {
400
  return (bool) apply_filters( 'bp_hide_loggedout_adminbar', (bool) bp_get_option( 'hide-loggedout-adminbar', $default ) );
@@ -403,12 +419,13 @@ function bp_hide_loggedout_adminbar( $default = true ) {
403
  /**
404
  * Are members able to upload their own avatars?
405
  *
406
- * @since BuddyPress (1.6)
407
  *
408
- * @param bool $default Optional. Default value true
409
  *
410
- * @uses bp_get_option() To get the avatar uploads option
411
- * @return bool Are avatar uploads allowed?
 
412
  */
413
  function bp_disable_avatar_uploads( $default = true ) {
414
  return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
@@ -417,12 +434,14 @@ function bp_disable_avatar_uploads( $default = true ) {
417
  /**
418
  * Are members able to delete their own accounts?
419
  *
420
- * @since BuddyPress (1.6)
421
  *
422
- * @param bool $default Optional. Default value
423
  *
424
- * @uses bp_get_option() To get the account deletion option
425
- * @return bool Is account deletion allowed?
 
 
426
  */
427
  function bp_disable_account_deletion( $default = false ) {
428
  return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $default ) );
@@ -431,12 +450,15 @@ function bp_disable_account_deletion( $default = false ) {
431
  /**
432
  * Are blog and forum activity stream comments disabled?
433
  *
434
- * @since BuddyPress (1.6)
435
  *
436
- * @param bool $default Optional. Default value false
437
- * @todo split and move into blog and forum components
438
- * @uses bp_get_option() To get the blog/forum comments option
439
- * @return bool Is blog/forum comments allowed?
 
 
 
440
  */
441
  function bp_disable_blogforum_comments( $default = false ) {
442
  return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $default ) );
@@ -445,93 +467,98 @@ function bp_disable_blogforum_comments( $default = false ) {
445
  /**
446
  * Is group creation turned off?
447
  *
448
- * @since BuddyPress (1.6)
449
  *
450
- * @param bool $default Optional. Default value true
 
451
  *
452
- * @todo Move into groups component
453
- * @uses bp_get_option() To get the group creation
454
- * @return bool Allow group creation?
455
  */
456
  function bp_restrict_group_creation( $default = true ) {
457
  return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
458
  }
459
 
460
  /**
461
- * Have we migrated to using the WordPress Toolbar?
462
  *
463
- * @since BuddyPress (1.6)
464
  *
465
- * @param bool $default Optional. Default value true
466
  *
467
- * @todo Move into groups component
468
- * @uses bp_get_option() To get the WP editor option
469
- * @return bool Use WP editor?
470
  */
471
  function bp_force_buddybar( $default = true ) {
472
  return (bool) apply_filters( 'bp_force_buddybar', (bool) bp_get_option( '_bp_force_buddybar', $default ) );
473
  }
474
 
475
  /**
476
- * Output the group forums root parent forum id
477
  *
478
- * @since BuddyPress (1.6)
479
  *
480
- * @param bool $default Optional. Default value
481
  */
482
  function bp_group_forums_root_id( $default = '0' ) {
483
  echo bp_get_group_forums_root_id( $default );
484
  }
485
  /**
486
- * Return the group forums root parent forum id
487
  *
488
- * @since BuddyPress (1.6)
489
  *
490
- * @param bool $default Optional. Default value 0
491
  *
492
- * @uses bp_get_option() To get the maximum title length
493
- * @return int Is anonymous posting allowed?
494
  */
495
  function bp_get_group_forums_root_id( $default = '0' ) {
496
  return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) );
497
  }
498
 
499
  /**
500
- * Checks if BuddyPress Group Forums are enabled
501
  *
502
- * @since BuddyPress (1.6)
503
  *
504
- * @param bool $default Optional. Default value true
505
  *
506
- * @uses bp_get_option() To get the group forums option
507
- * @return bool Is group forums enabled or not
 
508
  */
509
  function bp_is_group_forums_active( $default = true ) {
510
  return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) );
511
  }
512
 
513
  /**
514
- * Checks if Akismet is enabled
515
  *
516
- * @since BuddyPress (1.6)
517
  *
518
- * @param bool $default Optional. Default value true
519
  *
520
- * @uses bp_get_option() To get the Akismet option
521
- * @return bool Is Akismet enabled or not
 
522
  */
523
  function bp_is_akismet_active( $default = true ) {
524
  return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $default ) );
525
  }
526
 
527
  /**
528
- * Get the current theme package ID
 
 
529
  *
530
- * @since BuddyPress (1.7)
531
  *
532
- * @param string $default Optional. Default value 'default'
533
- * @uses get_option() To get the subtheme option
534
- * @return string ID of the subtheme
535
  */
536
  function bp_get_theme_package_id( $default = 'legacy' ) {
537
  return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $default ) );
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Options.
5
  *
6
  * @package BuddyPress
7
  * @subpackage Options
11
  if ( !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
  */
20
  function bp_get_default_options() {
21
 
86
  }
87
 
88
  /**
89
+ * Add default options when BuddyPress is first activated.
90
  *
91
  * Hooked to bp_activate, it is only called once when BuddyPress is activated.
92
  * This is non-destructive, so existing settings will not be overridden.
93
  *
94
+ * Currently unused.
95
  *
96
+ * @since BuddyPress (1.6.0)
97
+ *
98
+ * @uses bp_get_default_options() To get default options.
99
+ * @uses add_option() Adds default options.
100
+ * @uses do_action() Calls 'bp_add_options'.
101
  */
102
  function bp_add_options() {
103
 
113
  }
114
 
115
  /**
116
+ * Delete default options.
117
  *
118
  * Hooked to bp_uninstall, it is only called once when BuddyPress is uninstalled.
119
  * This is destructive, so existing settings will be destroyed.
120
  *
121
+ * Currently unused.
122
  *
123
+ * @since BuddyPress (1.6.0)
124
+ *
125
+ * @uses bp_get_default_options() To get default options.
126
+ * @uses delete_option() Removes default options.
127
+ * @uses do_action() Calls 'bp_delete_options'.
128
  */
129
  function bp_delete_options() {
130
 
140
  }
141
 
142
  /**
143
+ * Add filters to each BP option, allowing them to be overloaded from inside the $bp->options array.
 
144
  *
145
+ * Currently unused.
146
  *
147
+ * @since BuddyPress (1.6.0)
148
+ *
149
+ * @uses bp_get_default_options() To get default options.
150
+ * @uses add_filter() To add filters to 'pre_option_{$key}'.
151
+ * @uses do_action() Calls 'bp_add_option_filters'.
152
  */
153
  function bp_setup_option_filters() {
154
 
164
  }
165
 
166
  /**
167
+ * Filter default options and allow them to be overloaded from inside the $bp->options array.
168
+ *
169
+ * Currently unused.
170
  *
171
  * @since BuddyPress (1.6)
172
  *
192
  }
193
 
194
  /**
195
+ * Retrieve an option.
196
  *
197
+ * This is a wrapper for {@link get_blog_option()}, which in turn stores settings data
198
+ * (such as bp-pages) on the appropriate blog, given your current setup.
199
  *
200
  * The 'bp_get_option' filter is primarily for backward-compatibility.
201
  *
202
+ * @since BuddyPress (1.5.0)
 
203
  *
204
  * @uses bp_get_root_blog_id()
205
+ *
206
+ * @param string $option_name The option to be retrieved.
207
+ * @param string $default Optional. Default value to be returned if the option
208
+ * isn't set. See {@link get_blog_option()}.
209
+ * @return mixed The value for the option.
210
  */
211
  function bp_get_option( $option_name, $default = '' ) {
212
  $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default );
215
  }
216
 
217
  /**
218
+ * Save an option.
219
  *
220
+ * This is a wrapper for {@link update_blog_option()}, which in turn stores
221
+ * settings data (such as bp-pages) on the appropriate blog, given your current
222
+ * setup.
223
  *
224
+ * @since BuddyPress (1.5.0)
 
225
  *
226
  * @uses bp_get_root_blog_id()
227
+ *
228
+ * @param string $option_name The option key to be set.
229
+ * @param string $value The value to be set.
230
  */
231
  function bp_update_option( $option_name, $value ) {
232
  update_blog_option( bp_get_root_blog_id(), $option_name, $value );
233
  }
234
 
235
  /**
236
+ * Delete an option.
237
  *
238
+ * This is a wrapper for {@link delete_blog_option()}, which in turn deletes
239
+ * settings data (such as bp-pages) on the appropriate blog, given your current
240
+ * setup.
241
  *
242
+ * @since BuddyPress (1.5.0)
 
243
  *
244
  * @uses bp_get_root_blog_id()
245
+ *
246
+ * @param string $option_name The option key to be deleted.
247
  */
248
  function bp_delete_option( $option_name ) {
249
  delete_blog_option( bp_get_root_blog_id(), $option_name );
250
  }
251
 
252
  /**
253
+ * Copy BP options from a single site to multisite config.
254
+ *
255
+ * Run when switching from single to multisite and we need to copy blog options
256
+ * to site options.
257
  *
258
+ * This function is no longer used.
259
  *
260
+ * @deprecated 1.6.0
 
261
  */
262
  function bp_core_activate_site_options( $keys = array() ) {
263
  global $bp;
284
  }
285
 
286
  /**
287
+ * Fetch global BP options.
288
+ *
289
  * BuddyPress uses common options to store configuration settings. Many of these
290
  * settings are needed at run time. Instead of fetching them all and adding many
291
  * initial queries to each page load, let's fetch them all in one go.
292
  *
293
+ * @todo Use settings API and audit these methods.
294
+ *
295
+ * @return array $root_blog_options_meta List of options.
296
  */
297
  function bp_core_get_root_options() {
298
  global $wpdb;
388
  /**
389
  * Is profile sycing disabled?
390
  *
391
+ * @since BuddyPress (1.6.0)
392
  *
393
+ * @uses bp_get_option() To get the profile sync option.
394
  *
395
+ * @param bool $default Optional. Fallback value if not found in the database.
396
+ * Default: true.
397
+ * @return bool True if profile sync is enabled, otherwise false.
398
  */
399
  function bp_disable_profile_sync( $default = true ) {
400
  return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) );
403
  /**
404
  * Is the Toolbar hidden for logged out users?
405
  *
406
+ * @since BuddyPress (1.6.0)
407
  *
408
+ * @uses bp_get_option() To get the logged out Toolbar option.
409
  *
410
+ * @param bool $default Optional. Fallback value if not found in the database.
411
+ * Default: true.
412
+ * @return bool True if the admin bar should be hidden for logged-out users,
413
+ * otherwise false.
414
  */
415
  function bp_hide_loggedout_adminbar( $default = true ) {
416
  return (bool) apply_filters( 'bp_hide_loggedout_adminbar', (bool) bp_get_option( 'hide-loggedout-adminbar', $default ) );
419
  /**
420
  * Are members able to upload their own avatars?
421
  *
422
+ * @since BuddyPress (1.6.0)
423
  *
424
+ * @uses bp_get_option() To get the avatar uploads option.
425
  *
426
+ * @param bool $default Optional. Fallback value if not found in the database.
427
+ * Default: true.
428
+ * @return bool True if avatar uploads are disabled, otherwise false.
429
  */
430
  function bp_disable_avatar_uploads( $default = true ) {
431
  return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
434
  /**
435
  * Are members able to delete their own accounts?
436
  *
437
+ * @since BuddyPress (1.6.0)
438
  *
439
+ * @uses bp_get_option() To get the account deletion option.
440
  *
441
+ * @param bool $default Optional. Fallback value if not found in the database.
442
+ * Default: true.
443
+ * @return bool True if users are able to delete their own accounts, otherwise
444
+ * false.
445
  */
446
  function bp_disable_account_deletion( $default = false ) {
447
  return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $default ) );
450
  /**
451
  * Are blog and forum activity stream comments disabled?
452
  *
453
+ * @since BuddyPress (1.6.0)
454
  *
455
+ * @todo split and move into blog and forum components.
456
+ * @uses bp_get_option() To get the blog/forum comments option.
457
+ *
458
+ * @param bool $default Optional. Fallback value if not found in the database.
459
+ * Default: false.
460
+ * @return bool True if activity comments are disabled for blog and forum
461
+ * items, otherwise false.
462
  */
463
  function bp_disable_blogforum_comments( $default = false ) {
464
  return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $default ) );
467
  /**
468
  * Is group creation turned off?
469
  *
470
+ * @since BuddyPress (1.6.0)
471
  *
472
+ * @todo Move into groups component.
473
+ * @uses bp_get_option() To get the group creation.
474
  *
475
+ * @param bool $default Optional. Fallback value if not found in the database.
476
+ * Default: true.
477
+ * @return bool True if group creation is restricted, otherwise false.
478
  */
479
  function bp_restrict_group_creation( $default = true ) {
480
  return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
481
  }
482
 
483
  /**
484
+ * Should the old BuddyBar be forced in place of the WP admin bar?
485
  *
486
+ * @since BuddyPress (1.6.0)
487
  *
488
+ * @uses bp_get_option() To get the BuddyBar option.
489
  *
490
+ * @param bool $default Optional. Fallback value if not found in the database.
491
+ * Default: true.
492
+ * @return bool True if the BuddyBar should be forced on, otherwise false.
493
  */
494
  function bp_force_buddybar( $default = true ) {
495
  return (bool) apply_filters( 'bp_force_buddybar', (bool) bp_get_option( '_bp_force_buddybar', $default ) );
496
  }
497
 
498
  /**
499
+ * Output the group forums root parent forum id.
500
  *
501
+ * @since BuddyPress (1.6.0)
502
  *
503
+ * @param bool $default Optional. Default: '0'.
504
  */
505
  function bp_group_forums_root_id( $default = '0' ) {
506
  echo bp_get_group_forums_root_id( $default );
507
  }
508
  /**
509
+ * Return the group forums root parent forum id.
510
  *
511
+ * @since BuddyPress (1.6.0)
512
  *
513
+ * @uses bp_get_option() To get the root forum ID from the database.
514
  *
515
+ * @param bool $default Optional. Default: '0'.
516
+ * @return int The ID of the group forums root forum.
517
  */
518
  function bp_get_group_forums_root_id( $default = '0' ) {
519
  return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) );
520
  }
521
 
522
  /**
523
+ * Check whether BuddyPress Group Forums are enabled.
524
  *
525
+ * @since BuddyPress (1.6.0)
526
  *
527
+ * @uses bp_get_option() To get the group forums option.
528
  *
529
+ * @param bool $default Optional. Fallback value if not found in the database.
530
+ * Default: true.
531
+ * @return bool True if group forums are active, otherwise false.
532
  */
533
  function bp_is_group_forums_active( $default = true ) {
534
  return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) );
535
  }
536
 
537
  /**
538
+ * Check whether Akismet is enabled.
539
  *
540
+ * @since BuddyPress (1.6.0)
541
  *
542
+ * @uses bp_get_option() To get the Akismet option.
543
  *
544
+ * @param bool $default Optional. Fallback value if not found in the database.
545
+ * Default: true.
546
+ * @return bool True if Akismet is enabled, otherwise false.
547
  */
548
  function bp_is_akismet_active( $default = true ) {
549
  return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $default ) );
550
  }
551
 
552
  /**
553
+ * Get the current theme package ID.
554
+ *
555
+ * @since BuddyPress (1.7.0)
556
  *
557
+ * @uses get_option() To get the theme package option.
558
  *
559
+ * @param bool $default Optional. Fallback value if not found in the database.
560
+ * Default: 'legacy'.
561
+ * @return string ID of the theme package.
562
  */
563
  function bp_get_theme_package_id( $default = 'legacy' ) {
564
  return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $default ) );
bp-core/bp-core-template-loader.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Template Functions
5
  *
6
  * This file contains functions necessary to mirror the WordPress core template
7
  * loading process. Many of those functions are not filterable, and even then
@@ -15,15 +15,19 @@
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
17
  /**
18
- * Adds BuddyPress theme support to any active WordPress theme
19
  *
20
- * @since BuddyPress (1.7)
21
  *
22
- * @param string $slug
23
- * @param string $name Optional. Default null
24
  * @uses bp_locate_template()
25
  * @uses load_template()
26
  * @uses get_template_part()
 
 
 
 
 
 
27
  */
28
  function bp_get_template_part( $slug, $name = null ) {
29
 
@@ -50,12 +54,13 @@ function bp_get_template_part( $slug, $name = null ) {
50
  * inherit from a parent theme can just overload one file. If the template is
51
  * not found in either of those, it looks in the theme-compat folder last.
52
  *
53
- * @since BuddyPress (1.7)
54
  *
55
  * @param string|array $template_names Template file(s) to search for, in order.
56
- * @param bool $load If true the template file will be loaded if it is found.
57
- * @param bool $require_once Whether to require_once or require. Default true.
58
- * Has no effect if $load is false.
 
59
  * @return string The template filename if one is located.
60
  */
61
  function bp_locate_template( $template_names, $load = false, $require_once = true ) {
@@ -97,17 +102,20 @@ function bp_locate_template( $template_names, $load = false, $require_once = tru
97
  }
98
 
99
  /**
100
- * This is really cool. This function registers a new template stack location,
101
- * using WordPress's built in filters API.
102
  *
103
  * This allows for templates to live in places beyond just the parent/child
104
  * relationship, to allow for custom template locations. Used in conjunction
105
  * with bp_locate_template(), this allows for easy template overrides.
106
  *
107
- * @since BuddyPress (1.7)
108
  *
109
- * @param string $location Callback function that returns the stack location
110
- * @param int $priority
 
 
 
 
111
  */
112
  function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
113
 
@@ -120,13 +128,16 @@ function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
120
  }
121
 
122
  /**
123
- * Deregisters a previously registered template stack location.
124
  *
125
- * @since BuddyPress (1.7)
126
  *
127
- * @param string $location Callback function that returns the stack location
128
- * @param int $priority
129
  * @see bp_register_template_stack()
 
 
 
 
 
130
  */
131
  function bp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
132
 
@@ -139,17 +150,19 @@ function bp_deregister_template_stack( $location_callback = '', $priority = 10 )
139
  }
140
 
141
  /**
142
- * Call the functions added to the 'bp_template_stack' filter hook, and return
 
 
143
  * an array of the template locations.
144
  *
145
  * @see bp_register_template_stack()
146
  *
147
- * @since BuddyPress (1.7)
148
- *
149
- * @global array $wp_filter Stores all of the filters
150
- * @global array $merged_filters Merges the filter hooks using this function.
151
- * @global array $wp_current_filter stores the list of current filters with the current one last
152
  *
 
 
 
 
153
  * @return array The filtered value after all hooked functions are applied to it.
154
  */
155
  function bp_get_template_stack() {
@@ -191,13 +204,17 @@ function bp_get_template_stack() {
191
  }
192
 
193
  /**
194
- * Get a template part in an output buffer, and return it
195
  *
196
- * @since BuddyPress (1.7)
 
 
197
  *
198
- * @param string $slug
199
- * @param string $name
200
- * @return string
 
 
201
  */
202
  function bp_buffer_template_part( $slug, $name = null, $echo = true ) {
203
  ob_start();
@@ -222,20 +239,21 @@ function bp_buffer_template_part( $slug, $name = null, $echo = true ) {
222
  }
223
 
224
  /**
225
- * Retrieve path to a template
226
  *
227
  * Used to quickly retrieve the path of a template without including the file
228
  * extension. It will also check the parent theme and theme-compat theme with
229
  * the use of {@link bp_locate_template()}. Allows for more generic template
230
  * locations without the use of the other get_*_template() functions.
231
  *
232
- * @since BuddyPress (1.7)
233
  *
234
- * @param string $type Filename without extension.
235
- * @param array $templates An optional list of template candidates
236
  * @uses bp_set_theme_compat_templates()
237
  * @uses bp_locate_template()
238
  * @uses bp_set_theme_compat_template()
 
 
 
239
  * @return string Full path to file.
240
  */
241
  function bp_get_query_template( $type, $templates = array() ) {
@@ -271,12 +289,12 @@ function bp_get_template_locations( $templates = array() ) {
271
  }
272
 
273
  /**
274
- * Add template locations to template files being searched for
275
  *
276
- * @since BuddyPress (1.7)
277
  *
278
- * @param array $stacks
279
- * @return array()
280
  */
281
  function bp_add_template_stack_locations( $stacks = array() ) {
282
  $retval = array();
@@ -293,9 +311,9 @@ function bp_add_template_stack_locations( $stacks = array() ) {
293
  }
294
 
295
  /**
296
- * Add checks for BuddyPress conditions to parse_query action
297
  *
298
- * @since BuddyPress (1.7)
299
  *
300
  * @param WP_Query $posts_query
301
  */
@@ -318,7 +336,7 @@ function bp_parse_query( $posts_query ) {
318
  }
319
 
320
  /**
321
- * Possibly intercept the template being loaded
322
  *
323
  * Listens to the 'template_include' filter and waits for any BuddyPress specific
324
  * template condition to be met. If one is met and the template file exists,
@@ -327,11 +345,10 @@ function bp_parse_query( $posts_query ) {
327
  * Note that the _edit() checks are ahead of their counterparts, to prevent them
328
  * from being stomped on accident.
329
  *
330
- * @since BuddyPress (1.7)
331
  *
332
  * @param string $template
333
- *
334
- * @return string The path to the template file that is being used
335
  */
336
  function bp_template_include_theme_supports( $template = '' ) {
337
 
@@ -348,11 +365,12 @@ function bp_template_include_theme_supports( $template = '' ) {
348
  }
349
 
350
  /**
351
- * Set the included template
 
 
352
  *
353
- * @since BuddyPress (1.8)
354
- * @param mixed $template Default false
355
- * @return mixed False if empty. Template name if template included
356
  */
357
  function bp_set_template_included( $template = false ) {
358
  buddypress()->theme_compat->found_template = $template;
@@ -363,29 +381,41 @@ function bp_set_template_included( $template = false ) {
363
  /**
364
  * Is a BuddyPress template being included?
365
  *
366
- * @since BuddyPress (1.8)
367
- * @return bool True if yes, false if no
368
  */
369
  function bp_is_template_included() {
370
  return ! empty( buddypress()->theme_compat->found_template );
371
  }
372
 
373
  /**
374
- * Attempt to load a custom BuddyPress functions file, similar to each themes
375
- * functions.php file.
376
  *
377
- * @since BuddyPress (1.7)
378
  *
379
  * @global string $pagenow
380
  * @uses bp_locate_template()
381
  */
382
  function bp_load_theme_functions() {
383
- global $pagenow;
 
 
 
 
 
384
 
385
  // Do not include on BuddyPress deactivation
386
  if ( bp_is_deactivation() )
387
  return;
388
 
 
 
 
 
 
 
 
 
389
  // Only include if not installing or if activating via wp-activate.php
390
  if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
391
  bp_locate_template( 'buddypress-functions.php', true );
@@ -393,12 +423,11 @@ function bp_load_theme_functions() {
393
  }
394
 
395
  /**
396
- * Get the templates to use as the endpoint for BuddyPress template parts
397
  *
398
- * @since BuddyPress (1.7)
399
  *
400
- * @uses apply_filters()
401
- * @return array Of possible root level wrapper template files
402
  */
403
  function bp_get_theme_compat_templates() {
404
  $templates = array(
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Template Functions.
5
  *
6
  * This file contains functions necessary to mirror the WordPress core template
7
  * loading process. Many of those functions are not filterable, and even then
15
  if ( !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
 
54
  * inherit from a parent theme can just overload one file. If the template is
55
  * not found in either of those, it looks in the theme-compat folder last.
56
  *
57
+ * @since BuddyPress (1.7.0)
58
  *
59
  * @param string|array $template_names Template file(s) to search for, in order.
60
+ * @param bool $load Optional. If true, the template file will be loaded when
61
+ * found. If false, the path will be returned. Default: false.
62
+ * @param bool $require_once Optional. Whether to require_once or require. Has
63
+ * no effect if $load is false. Default: true.
64
  * @return string The template filename if one is located.
65
  */
66
  function bp_locate_template( $template_names, $load = false, $require_once = true ) {
102
  }
103
 
104
  /**
105
+ * Register a new template stack location.
 
106
  *
107
  * This allows for templates to live in places beyond just the parent/child
108
  * relationship, to allow for custom template locations. Used in conjunction
109
  * with bp_locate_template(), this allows for easy template overrides.
110
  *
111
+ * @since BuddyPress (1.7.0)
112
  *
113
+ * @todo Make 'callable' instead of 'function'.
114
+ *
115
+ * @param string $location Callback function that returns the stack location.
116
+ * @param int $priority Optional. The priority parameter as passed to
117
+ * add_filter(). Default: 10.
118
+ * @return bool See {@link add_filter()}.
119
  */
120
  function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
121
 
128
  }
129
 
130
  /**
131
+ * Deregister a previously registered template stack location.
132
  *
133
+ * @since BuddyPress (1.7.0)
134
  *
 
 
135
  * @see bp_register_template_stack()
136
+ *
137
+ * @param string $location Callback function that returns the stack location.
138
+ * @param int $priority Optional. The priority parameter passed to
139
+ * {@link bp_register_template_stack()}. Default: 10.
140
+ * @return bool See {@link remove_filter()}.
141
  */
142
  function bp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
143
 
150
  }
151
 
152
  /**
153
+ * Get the "template stack", a list of registered directories where templates can be found.
154
+ *
155
+ * Calls the functions added to the 'bp_template_stack' filter hook, and return
156
  * an array of the template locations.
157
  *
158
  * @see bp_register_template_stack()
159
  *
160
+ * @since BuddyPress (1.7.0)
 
 
 
 
161
  *
162
+ * @global array $wp_filter Stores all of the filters.
163
+ * @global array $merged_filters Merges the filter hooks using this function..
164
+ * @global array $wp_current_filter stores the list of current filters with
165
+ * the current one last.
166
  * @return array The filtered value after all hooked functions are applied to it.
167
  */
168
  function bp_get_template_stack() {
204
  }
205
 
206
  /**
207
+ * Put a template part into an output buffer, and return it.
208
  *
209
+ * @since BuddyPress (1.7.0)
210
+ *
211
+ * @see bp_get_template_part() for a description of $slug and $name params.
212
  *
213
+ * @param string $slug See {@link bp_get_template_part()}.
214
+ * @param string $name See {@link bp_get_template_part()}.
215
+ * @param bool $echo If true, template content will be echoed. If false,
216
+ * returned. Default: true.
217
+ * @return string|null If $echo, returns the template content.
218
  */
219
  function bp_buffer_template_part( $slug, $name = null, $echo = true ) {
220
  ob_start();
239
  }
240
 
241
  /**
242
+ * Retrieve the path to a template.
243
  *
244
  * Used to quickly retrieve the path of a template without including the file
245
  * extension. It will also check the parent theme and theme-compat theme with
246
  * the use of {@link bp_locate_template()}. Allows for more generic template
247
  * locations without the use of the other get_*_template() functions.
248
  *
249
+ * @since BuddyPress (1.7.0)
250
  *
 
 
251
  * @uses bp_set_theme_compat_templates()
252
  * @uses bp_locate_template()
253
  * @uses bp_set_theme_compat_template()
254
+ *
255
+ * @param string $type Filename without extension.
256
+ * @param array $templates An optional list of template candidates.
257
  * @return string Full path to file.
258
  */
259
  function bp_get_query_template( $type, $templates = array() ) {
289
  }
290
 
291
  /**
292
+ * Add template locations to template files being searched for.
293
  *
294
+ * @since BuddyPress (1.7.0)
295
  *
296
+ * @param array $stacks Array of template locations.
297
+ * @return array() Array of all template locations registered so far.
298
  */
299
  function bp_add_template_stack_locations( $stacks = array() ) {
300
  $retval = array();
311
  }
312
 
313
  /**
314
+ * Add checks for BuddyPress conditions to 'parse_query' action.
315
  *
316
+ * @since BuddyPress (1.7.0)
317
  *
318
  * @param WP_Query $posts_query
319
  */
336
  }
337
 
338
  /**
339
+ * Possibly intercept the template being loaded.
340
  *
341
  * Listens to the 'template_include' filter and waits for any BuddyPress specific
342
  * template condition to be met. If one is met and the template file exists,
345
  * Note that the _edit() checks are ahead of their counterparts, to prevent them
346
  * from being stomped on accident.
347
  *
348
+ * @since BuddyPress (1.7.0)
349
  *
350
  * @param string $template
351
+ * @return string The path to the template file that is being used.
 
352
  */
353
  function bp_template_include_theme_supports( $template = '' ) {
354
 
365
  }
366
 
367
  /**
368
+ * Set the included template.
369
+ *
370
+ * @since BuddyPress (1.8.0)
371
  *
372
+ * @param mixed $template Default: false.
373
+ * @return mixed False if empty. Template name if template included.
 
374
  */
375
  function bp_set_template_included( $template = false ) {
376
  buddypress()->theme_compat->found_template = $template;
381
  /**
382
  * Is a BuddyPress template being included?
383
  *
384
+ * @since BuddyPress (1.8.0)
385
+ * @return bool True if yes, false if no.
386
  */
387
  function bp_is_template_included() {
388
  return ! empty( buddypress()->theme_compat->found_template );
389
  }
390
 
391
  /**
392
+ * Attempt to load a custom BP functions file, similar to each themes functions.php file.
 
393
  *
394
+ * @since BuddyPress (1.7.0)
395
  *
396
  * @global string $pagenow
397
  * @uses bp_locate_template()
398
  */
399
  function bp_load_theme_functions() {
400
+ global $pagenow, $wp_query;
401
+
402
+ // do not load our custom BP functions file if theme compat is disabled
403
+ if ( ! bp_use_theme_compat_with_current_theme() ) {
404
+ return;
405
+ }
406
 
407
  // Do not include on BuddyPress deactivation
408
  if ( bp_is_deactivation() )
409
  return;
410
 
411
+ // If the $wp_query global is empty (the main query has not been run,
412
+ // or has been reset), load_template() will fail at setting certain
413
+ // global values. This does not happen on a normal page load, but can
414
+ // cause problems when running automated tests
415
+ if ( ! is_a( $wp_query, 'WP_Query' ) ) {
416
+ return;
417
+ }
418
+
419
  // Only include if not installing or if activating via wp-activate.php
420
  if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
421
  bp_locate_template( 'buddypress-functions.php', true );
423
  }
424
 
425
  /**
426
+ * Get the templates to use as the endpoint for BuddyPress template parts.
427
  *
428
+ * @since BuddyPress (1.7.0)
429
  *
430
+ * @return array Array of possible root level wrapper template files.
 
431
  */
432
  function bp_get_theme_compat_templates() {
433
  $templates = array(
bp-core/bp-core-template.php CHANGED
@@ -1,21 +1,31 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  // Exit if accessed directly
4
  if ( !defined( 'ABSPATH' ) ) exit;
5
 
6
  /**
7
- * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component.
8
- * Each component adds to its sub navigation array within its own setup_nav() function.
 
 
 
9
  *
10
- * This sub navigation array is the secondary level navigation, so for profile it contains:
 
11
  * [Public, Edit Profile, Change Avatar]
12
  *
13
- * The function will also analyze the current action for the current component to determine whether
14
- * or not to highlight a particular sub nav item.
15
  *
16
- * @package BuddyPress Core
17
- * @global BuddyPress $bp The one true BuddyPress instance
18
- * @uses bp_get_user_nav() Renders the navigation for a profile of a currently viewed user.
19
  */
20
  function bp_get_options_nav() {
21
  global $bp;
@@ -58,6 +68,12 @@ function bp_get_options_nav() {
58
  }
59
  }
60
 
 
 
 
 
 
 
61
  function bp_get_options_title() {
62
  global $bp;
63
 
@@ -70,11 +86,18 @@ function bp_get_options_title() {
70
  /** Avatars *******************************************************************/
71
 
72
  /**
73
- * Check to see if there is an options avatar. An options avatar is an avatar for something
74
- * like a group, or a friend. Basically an avatar that appears in the sub nav options bar.
 
 
75
  *
76
- * @package BuddyPress Core
77
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
 
 
78
  */
79
  function bp_has_options_avatar() {
80
  global $bp;
@@ -85,12 +108,26 @@ function bp_has_options_avatar() {
85
  return true;
86
  }
87
 
 
 
 
 
 
 
 
88
  function bp_get_options_avatar() {
89
  global $bp;
90
 
91
  echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_avatar );
92
  }
93
 
 
 
 
 
 
 
 
94
  function bp_comment_author_avatar() {
95
  global $comment;
96
 
@@ -100,6 +137,13 @@ function bp_comment_author_avatar() {
100
  get_avatar();
101
  }
102
 
 
 
 
 
 
 
 
103
  function bp_post_author_avatar() {
104
  global $post;
105
 
@@ -109,9 +153,18 @@ function bp_post_author_avatar() {
109
  get_avatar();
110
  }
111
 
 
 
 
112
  function bp_avatar_admin_step() {
113
  echo bp_get_avatar_admin_step();
114
  }
 
 
 
 
 
 
115
  function bp_get_avatar_admin_step() {
116
  global $bp;
117
 
@@ -123,9 +176,17 @@ function bp_avatar_admin_step() {
123
  return apply_filters( 'bp_get_avatar_admin_step', $step );
124
  }
125
 
 
 
 
126
  function bp_avatar_to_crop() {
127
  echo bp_get_avatar_to_crop();
128
  }
 
 
 
 
 
129
  function bp_get_avatar_to_crop() {
130
  global $bp;
131
 
@@ -137,15 +198,30 @@ function bp_avatar_to_crop() {
137
  return apply_filters( 'bp_get_avatar_to_crop', $url );
138
  }
139
 
 
 
 
140
  function bp_avatar_to_crop_src() {
141
  echo bp_get_avatar_to_crop_src();
142
  }
 
 
 
 
 
143
  function bp_get_avatar_to_crop_src() {
144
  global $bp;
145
 
146
  return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) );
147
  }
148
 
 
 
 
 
 
 
 
149
  function bp_avatar_cropper() {
150
  global $bp;
151
 
@@ -153,20 +229,32 @@ function bp_avatar_cropper() {
153
  }
154
 
155
  /**
156
- * Echoes bp_get_site_name()
157
  */
158
  function bp_site_name() {
159
  echo bp_get_site_name();
160
  }
161
  /**
162
- * Returns the name of the BP site. Used in RSS headers
163
  *
164
- * @since BuddyPress (1.6)
165
  */
166
  function bp_get_site_name() {
167
  return apply_filters( 'bp_site_name', get_bloginfo( 'name', 'display' ) );
168
  }
169
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  function bp_format_time( $time, $just_date = false, $localize_time = true ) {
171
  if ( !isset( $time ) || !is_numeric( $time ) )
172
  return false;
@@ -194,6 +282,24 @@ function bp_format_time( $time, $just_date = false, $localize_time = true ) {
194
  return apply_filters( 'bp_format_time', $date );
195
  }
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
198
 
199
  if ( !empty( $capitalize ) )
@@ -217,7 +323,13 @@ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true
217
  }
218
  }
219
 
220
-
 
 
 
 
 
 
221
  function bp_styles() {
222
  do_action( 'bp_styles' );
223
  wp_print_styles();
@@ -225,15 +337,21 @@ function bp_styles() {
225
 
226
  /** Search Form ***************************************************************/
227
 
 
 
 
 
 
228
  function bp_search_form_action() {
229
  return apply_filters( 'bp_search_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_search_slug() ) );
230
  }
231
 
232
  /**
233
- * Generates the basic search form as used in BP-Default's header.
 
 
234
  *
235
- * @return string HTML <select> element
236
- * @since BuddyPress (1.0)
237
  */
238
  function bp_search_form_type_select() {
239
 
@@ -267,15 +385,25 @@ function bp_search_form_type_select() {
267
  }
268
 
269
  /**
270
- * Get the default text for the search box for a given component.
271
  *
272
- * @global object $bp BuddyPress global settings
273
- * @return string
274
- * @since BuddyPress (1.5)
 
 
275
  */
276
  function bp_search_default_text( $component = '' ) {
277
  echo bp_get_search_default_text( $component );
278
  }
 
 
 
 
 
 
 
 
279
  function bp_get_search_default_text( $component = '' ) {
280
  global $bp;
281
 
@@ -302,54 +430,53 @@ function bp_search_default_text( $component = '' ) {
302
  return apply_filters( 'bp_get_search_default_text', $default_text, $component );
303
  }
304
 
 
 
 
 
 
 
 
305
  function bp_custom_profile_boxes() {
306
  do_action( 'bp_custom_profile_boxes' );
307
  }
308
 
 
 
 
 
 
 
 
309
  function bp_custom_profile_sidebar_boxes() {
310
  do_action( 'bp_custom_profile_sidebar_boxes' );
311
  }
312
 
313
  /**
314
- * Creates and outputs a button.
315
  *
316
- * @param array $args See bp_get_button() for the list of arguments.
317
  * @see bp_get_button()
 
 
318
  */
319
  function bp_button( $args = '' ) {
320
  echo bp_get_button( $args );
321
  }
322
  /**
323
- * Creates and returns a button.
324
  *
325
- * Args:
326
- * component: Which component this button is for
327
- * must_be_logged_in: Button only appears for logged in users
328
- * block_self: Button will not appear when viewing your own profile.
329
- * wrapper: div|span|p|li|
330
- * wrapper_id: The DOM ID of the button wrapper
331
- * wrapper_class: The DOM class of the button wrapper
332
- * link_href: The destination link of the button
333
- * link_title: Title of the button
334
- * link_id: The DOM ID of the button
335
- * link_class: The DOM class of the button
336
- * link_rel: The DOM rel of the button
337
- * link_text: The contents of the button
338
  *
339
- * @param array $button
340
- * @return string
341
- * @see bp_add_friend_button()
342
- * @see bp_send_public_message_button()
343
- * @see bp_send_private_message_button()
344
  */
345
  function bp_get_button( $args = '' ) {
346
  $button = new BP_Button( $args );
347
  return apply_filters( 'bp_get_button', $button->contents, $args, $button );
348
  }
349
 
350
-
351
  /**
352
- * Truncates text.
353
  *
354
  * Cuts a string to the length of $length and replaces the last characters
355
  * with the ending if the text is longer than length.
@@ -364,11 +491,20 @@ function bp_button( $args = '' ) {
364
  * - `html` If true, HTML tags would be handled correctly
365
  * - `filter_shortcodes` If true, shortcodes will be stripped before truncating
366
  *
367
- * @package BuddyPress
368
- *
369
- * @param string $text String to truncate.
370
- * @param integer $length Length of returned string, including ellipsis.
371
- * @param array $options An array of html attributes and options.
 
 
 
 
 
 
 
 
 
372
  * @return string Trimmed string.
373
  */
374
  function bp_create_excerpt( $text, $length = 225, $options = array() ) {
@@ -489,30 +625,46 @@ add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
489
  add_filter( 'bp_create_excerpt', 'force_balance_tags' );
490
 
491
  /**
492
- * Echoes the output of bp_get_total_member_count()
493
  */
494
  function bp_total_member_count() {
495
  echo bp_get_total_member_count();
496
  }
497
  /**
498
- * Returns the total member count in your BP instance
 
 
 
 
 
499
  *
500
- * Since BuddyPress 1.6, this function has used bp_core_get_active_member_count(), which
501
- * counts non-spam, non-deleted users who have last_activity. This value will correctly
502
- * match the total member count number used for pagination on member directories.
503
  *
504
- * Before BuddyPress 1.6, this function used bp_core_get_total_member_count(), which did
505
- * not take into account last_activity, and thus often resulted in higher counts than
506
- * shown by member directory pagination.
507
  */
508
  function bp_get_total_member_count() {
509
  return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() );
510
  }
511
  add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
512
 
 
 
 
 
 
513
  function bp_blog_signup_allowed() {
514
  echo bp_get_blog_signup_allowed();
515
  }
 
 
 
 
 
 
 
 
516
  function bp_get_blog_signup_allowed() {
517
  global $bp;
518
 
@@ -526,6 +678,12 @@ function bp_blog_signup_allowed() {
526
  return false;
527
  }
528
 
 
 
 
 
 
 
529
  function bp_account_was_activated() {
530
  global $bp;
531
 
@@ -534,20 +692,41 @@ function bp_account_was_activated() {
534
  return $activation_complete;
535
  }
536
 
 
 
 
 
 
 
 
 
 
537
  function bp_registration_needs_activation() {
538
  return apply_filters( 'bp_registration_needs_activation', true );
539
  }
540
 
541
  /**
542
- * Retrieve a client friendly version of the root blog name, plus take care of
543
- * the typical formatting bits and bobs.
544
  *
545
  * The blogname option is escaped with esc_html on the way into the database in
546
  * sanitize_option, we want to reverse this for the plain text arena of emails.
547
  *
548
- * @link http://buddypress.trac.wordpress.org/ticket/4401
549
- * @since BuddyPress (1.7)
550
- * @return string
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  */
552
  function bp_get_email_subject( $args = array() ) {
553
 
@@ -564,14 +743,17 @@ function bp_get_email_subject( $args = array() ) {
564
  }
565
 
566
  /**
567
- * Allow templates to pass parameters directly into the template loops via AJAX
 
 
 
568
  *
569
- * For the most part this will be filtered in a theme's functions.php for example
570
- * in the default theme it is filtered via bp_dtheme_ajax_querystring()
 
571
  *
572
- * By using this template tag in the templates it will stop them from showing errors
573
- * if someone copies the templates from the default theme into another WordPress theme
574
- * without coping the functions from functions.php.
575
  */
576
  function bp_ajax_querystring( $object = false ) {
577
  global $bp;
@@ -584,18 +766,33 @@ function bp_ajax_querystring( $object = false ) {
584
 
585
  /** Template Classes and _is functions ****************************************/
586
 
 
 
 
 
 
587
  function bp_current_component() {
588
  global $bp;
589
  $current_component = !empty( $bp->current_component ) ? $bp->current_component : false;
590
  return apply_filters( 'bp_current_component', $current_component );
591
  }
592
 
 
 
 
 
 
593
  function bp_current_action() {
594
  global $bp;
595
  $current_action = !empty( $bp->current_action ) ? $bp->current_action : '';
596
  return apply_filters( 'bp_current_action', $current_action );
597
  }
598
 
 
 
 
 
 
599
  function bp_current_item() {
600
  global $bp;
601
  $current_item = !empty( $bp->current_item ) ? $bp->current_item : false;
@@ -603,11 +800,10 @@ function bp_current_item() {
603
  }
604
 
605
  /**
606
- * Return the value of $bp->action_variables
607
- *
608
- * @package BuddyPress
609
  *
610
- * @param mixed $action_variables The action variables array, or false if the array is empty
 
611
  */
612
  function bp_action_variables() {
613
  global $bp;
@@ -616,13 +812,13 @@ function bp_action_variables() {
616
  }
617
 
618
  /**
619
- * Return the value of a given action variable
620
  *
621
- * @package BuddyPress
622
- * @since BuddyPress (1.5)
623
  *
624
- * @param int $position The key of the action_variables array that you want
625
- * @return string $action_variable The value of that position in the array
 
626
  */
627
  function bp_action_variable( $position = 0 ) {
628
  $action_variables = bp_action_variables();
@@ -631,9 +827,17 @@ function bp_action_variable( $position = 0 ) {
631
  return apply_filters( 'bp_action_variable', $action_variable, $position );
632
  }
633
 
 
 
 
634
  function bp_root_domain() {
635
  echo bp_get_root_domain();
636
  }
 
 
 
 
 
637
  function bp_get_root_domain() {
638
  global $bp;
639
 
@@ -648,35 +852,46 @@ function bp_root_domain() {
648
  }
649
 
650
  /**
651
- * Echoes the output of bp_get_root_slug()
652
  *
653
- * @package BuddyPress Core
654
- * @since BuddyPress (1.5)
 
655
  */
656
  function bp_root_slug( $component = '' ) {
657
  echo bp_get_root_slug( $component );
658
  }
659
  /**
660
- * Gets the root slug for a component slug
 
 
 
 
 
 
 
661
  *
662
- * In order to maintain backward compatibility, the following procedure is used:
 
663
  * 1) Use the short slug to get the canonical component name from the
664
  * active component array
665
- * 2) Use the component name to get the root slug out of the appropriate part of the $bp
666
- * global
667
- * 3) If nothing turns up, it probably means that $component is itself a root slug
 
 
 
 
 
 
 
668
  *
669
- * Example: If your groups directory is at /community/companies, this function first uses
670
- * the short slug 'companies' (ie the current component) to look up the canonical name
671
- * 'groups' in $bp->active_components. Then it uses 'groups' to get the root slug, from
672
- * $bp->groups->root_slug.
673
  *
674
- * @package BuddyPress Core
675
- * @since BuddyPress (1.5)
676
  *
677
- * @global BuddyPress $bp The one true BuddyPress instance
678
- * @param string $component Optional. Defaults to the current component
679
- * @return string $root_slug The root slug
680
  */
681
  function bp_get_root_slug( $component = '' ) {
682
  global $bp;
@@ -707,12 +922,14 @@ function bp_root_slug( $component = '' ) {
707
  }
708
 
709
  /**
710
- * Return the component name based on the current root slug
711
  *
712
- * @since BuddyPress (1.5)
713
- * @global BuddyPress $bp The one true BuddyPress instance
714
- * @param string $root_slug Needle to our active component haystack
715
- * @return mixed False if none found, component name if found
 
 
716
  */
717
  function bp_get_name_from_root_slug( $root_slug = '' ) {
718
  global $bp;
@@ -742,10 +959,9 @@ function bp_user_has_access() {
742
  }
743
 
744
  /**
745
- * Output the search slug
746
  *
747
- * @package BuddyPress
748
- * @since BuddyPress (1.5)
749
  *
750
  * @uses bp_get_search_slug()
751
  */
@@ -753,20 +969,22 @@ function bp_search_slug() {
753
  echo bp_get_search_slug();
754
  }
755
  /**
756
- * Return the search slug
757
  *
758
- * @package BuddyPress
759
- * @since BuddyPress (1.5)
 
760
  */
761
  function bp_get_search_slug() {
762
  return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
763
  }
764
 
765
  /**
766
- * Get the id of the currently displayed user
 
 
767
  *
768
- * @uses apply_filters() Filter 'bp_displayed_user_id' to change this value
769
- * @return int
770
  */
771
  function bp_displayed_user_id() {
772
  $bp = buddypress();
@@ -776,10 +994,11 @@ function bp_displayed_user_id() {
776
  }
777
 
778
  /**
779
- * Get the id of the currently logged-in user
780
  *
781
- * @uses apply_filters() Filter 'bp_loggedin_user_id' to change this value
782
- * @return int
 
783
  */
784
  function bp_loggedin_user_id() {
785
  $bp = buddypress();
@@ -791,7 +1010,7 @@ function bp_loggedin_user_id() {
791
  /** is_() functions to determine the current page *****************************/
792
 
793
  /**
794
- * Checks to see whether the current page belongs to the specified component
795
  *
796
  * This function is designed to be generous, accepting several different kinds
797
  * of value for the $component parameter. It checks $component_name against:
@@ -799,20 +1018,26 @@ function bp_loggedin_user_id() {
799
  * - the component's regular slug
800
  * - the component's id, or 'canonical' name
801
  *
802
- * @package BuddyPress Core
803
- * @since BuddyPress (1.5)
 
804
  * @return bool Returns true if the component matches, or else false.
805
  */
806
  function bp_is_current_component( $component ) {
807
- global $bp;
808
 
809
  $is_current_component = false;
810
 
 
 
 
 
 
811
  // Backward compatibility: 'xprofile' should be read as 'profile'
812
  if ( 'xprofile' == $component )
813
  $component = 'profile';
814
 
815
- if ( !empty( $bp->current_component ) ) {
816
 
817
  // First, check to see whether $component_name and the current
818
  // component are a simple match
@@ -854,7 +1079,7 @@ function bp_is_current_component( $component ) {
854
  }
855
 
856
  // Page template fallback check if $bp->current_component is empty
857
- } elseif ( !is_admin() && is_page() ) {
858
  global $wp_query;
859
  $page = $wp_query->get_queried_object();
860
  $custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
@@ -872,19 +1097,19 @@ function bp_is_current_component( $component ) {
872
  /**
873
  * Check to see whether the current page matches a given action.
874
  *
875
- * Along with bp_is_current_component() and bp_is_action_variable(), this function is mostly used
876
- * to help determine when to use a given screen function.
 
877
  *
878
- * In BP parlance, the current_action is the URL chunk that comes directly after the
879
- * current item slug. E.g., in
880
  * http://example.com/groups/my-group/members
881
  * the current_action is 'members'.
882
  *
883
- * @package BuddyPress
884
- * @since BuddyPress (1.5)
885
  *
886
- * @param string $action The action being tested against
887
- * @return bool True if the current action matches $action
888
  */
889
  function bp_is_current_action( $action = '' ) {
890
  if ( $action == bp_current_action() )
@@ -896,22 +1121,22 @@ function bp_is_current_action( $action = '' ) {
896
  /**
897
  * Check to see whether the current page matches a given action_variable.
898
  *
899
- * Along with bp_is_current_component() and bp_is_current_action(), this function is mostly used
900
- * to help determine when to use a given screen function.
 
901
  *
902
- * In BP parlance, action_variables are an array made up of the URL chunks appearing after the
903
- * current_action in a URL. For example,
904
  * http://example.com/groups/my-group/admin/group-settings
905
  * $action_variables[0] is 'group-settings'.
906
  *
907
- * @package BuddyPress
908
- * @since BuddyPress (1.5)
909
  *
910
- * @param string $action_variable The action_variable being tested against
911
- * @param int $position The array key you're testing against. If you don't provide a $position,
912
- * the function will return true if the $action_variable is found *anywhere* in the action
913
- * variables array.
914
- * @return bool
915
  */
916
  function bp_is_action_variable( $action_variable = '', $position = false ) {
917
  $is_action_variable = false;
@@ -933,6 +1158,12 @@ function bp_is_action_variable( $action_variable = '', $position = false ) {
933
  return apply_filters( 'bp_is_action_variable', $is_action_variable, $action_variable, $position );
934
  }
935
 
 
 
 
 
 
 
936
  function bp_is_current_item( $item = '' ) {
937
  if ( !empty( $item ) && $item == bp_current_item() )
938
  return true;
@@ -940,6 +1171,11 @@ function bp_is_current_item( $item = '' ) {
940
  return false;
941
  }
942
 
 
 
 
 
 
943
  function bp_is_single_item() {
944
  global $bp;
945
 
@@ -949,6 +1185,12 @@ function bp_is_single_item() {
949
  return false;
950
  }
951
 
 
 
 
 
 
 
952
  function bp_is_item_admin() {
953
  global $bp;
954
 
@@ -958,6 +1200,12 @@ function bp_is_item_admin() {
958
  return false;
959
  }
960
 
 
 
 
 
 
 
961
  function bp_is_item_mod() {
962
  global $bp;
963
 
@@ -967,6 +1215,12 @@ function bp_is_item_mod() {
967
  return false;
968
  }
969
 
 
 
 
 
 
 
970
  function bp_is_directory() {
971
  global $bp;
972
 
@@ -977,13 +1231,11 @@ function bp_is_directory() {
977
  }
978
 
979
  /**
980
- * Checks to see if a component's URL should be in the root, not under a
981
- * member page:
982
  *
983
- * Yes: http://domain.com/groups/the-group
984
- * No: http://domain.com/members/andy/groups/the-group
985
  *
986
- * @package BuddyPress Core
987
  * @return bool True if root component, else false.
988
  */
989
  function bp_is_root_component( $component_name ) {
@@ -1001,14 +1253,19 @@ function bp_is_root_component( $component_name ) {
1001
  }
1002
 
1003
  /**
1004
- * Checks if the site's front page is set to the specified BuddyPress component
1005
- * page in wp-admin's Settings > Reading screen.
 
 
 
1006
  *
1007
- * @global BuddyPress $bp The one true BuddyPress instance
1008
- * @global $current_blog WordPress global for the current blog
1009
- * @param string $component Optional; Name of the component to check for.
1010
- * @return bool True If the specified component is set to be the site's front page.
1011
- * @since BuddyPress (1.5)
 
 
1012
  */
1013
  function bp_is_component_front_page( $component = '' ) {
1014
  global $bp, $current_blog;
@@ -1027,11 +1284,10 @@ function bp_is_component_front_page( $component = '' ) {
1027
  /**
1028
  * Is this a blog page, ie a non-BP page?
1029
  *
1030
- * You can tell if a page is displaying BP content by whether the current_component has been defined
1031
- *
1032
- * @package BuddyPress
1033
  *
1034
- * @return bool True if it's a non-BP page, false otherwise
1035
  */
1036
  function bp_is_blog_page() {
1037
 
@@ -1050,16 +1306,15 @@ function bp_is_blog_page() {
1050
  * Is this a BuddyPress component?
1051
  *
1052
  * You can tell if a page is displaying BP content by whether the
1053
- * current_component has been defined
1054
  *
1055
  * Generally, we can just check to see that there's no current component.
1056
  * The one exception is single user home tabs, where $bp->current_component
1057
  * is unset. Thus the addition of the bp_is_user() check.
1058
  *
1059
- * @since BuddyPress (1.7)
1060
  *
1061
- * @package BuddyPress
1062
- * @return bool True if it's a BuddyPress page, false otherwise
1063
  */
1064
  function is_buddypress() {
1065
  $retval = (bool) ( bp_current_component() || bp_is_user() );
@@ -1069,6 +1324,12 @@ function is_buddypress() {
1069
 
1070
  /** Components ****************************************************************/
1071
 
 
 
 
 
 
 
1072
  function bp_is_active( $component ) {
1073
  global $bp;
1074
 
@@ -1078,6 +1339,11 @@ function bp_is_active( $component ) {
1078
  return false;
1079
  }
1080
 
 
 
 
 
 
1081
  function bp_is_members_component() {
1082
  if ( bp_is_current_component( 'members' ) )
1083
  return true;
@@ -1085,6 +1351,11 @@ function bp_is_members_component() {
1085
  return false;
1086
  }
1087
 
 
 
 
 
 
1088
  function bp_is_profile_component() {
1089
  if ( bp_is_current_component( 'xprofile' ) )
1090
  return true;
@@ -1092,6 +1363,11 @@ function bp_is_profile_component() {
1092
  return false;
1093
  }
1094
 
 
 
 
 
 
1095
  function bp_is_activity_component() {
1096
  if ( bp_is_current_component( 'activity' ) )
1097
  return true;
@@ -1099,6 +1375,11 @@ function bp_is_activity_component() {
1099
  return false;
1100
  }
1101
 
 
 
 
 
 
1102
  function bp_is_blogs_component() {
1103
  if ( is_multisite() && bp_is_current_component( 'blogs' ) )
1104
  return true;
@@ -1106,6 +1387,11 @@ function bp_is_blogs_component() {
1106
  return false;
1107
  }
1108
 
 
 
 
 
 
1109
  function bp_is_messages_component() {
1110
  if ( bp_is_current_component( 'messages' ) )
1111
  return true;
@@ -1113,6 +1399,11 @@ function bp_is_messages_component() {
1113
  return false;
1114
  }
1115
 
 
 
 
 
 
1116
  function bp_is_friends_component() {
1117
  if ( bp_is_current_component( 'friends' ) )
1118
  return true;
@@ -1120,6 +1411,11 @@ function bp_is_friends_component() {
1120
  return false;
1121
  }
1122
 
 
 
 
 
 
1123
  function bp_is_groups_component() {
1124
  if ( bp_is_current_component( 'groups' ) )
1125
  return true;
@@ -1127,6 +1423,11 @@ function bp_is_groups_component() {
1127
  return false;
1128
  }
1129
 
 
 
 
 
 
1130
  function bp_is_forums_component() {
1131
  if ( bp_is_current_component( 'forums' ) )
1132
  return true;
@@ -1134,6 +1435,26 @@ function bp_is_forums_component() {
1134
  return false;
1135
  }
1136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1137
  function bp_is_settings_component() {
1138
  if ( bp_is_current_component( 'settings' ) )
1139
  return true;
@@ -1142,7 +1463,7 @@ function bp_is_settings_component() {
1142
  }
1143
 
1144
  /**
1145
- * Is the current component an active core component.
1146
  *
1147
  * Use this function when you need to check if the current component is an
1148
  * active core component of BuddyPress. If the current component is inactive, it
@@ -1150,8 +1471,8 @@ function bp_is_settings_component() {
1150
  * it will return false. If the current component is active, and is part of
1151
  * BuddyPress core, it will return true.
1152
  *
1153
- * @since BuddyPress (1.7)
1154
- * @return boolean
1155
  */
1156
  function bp_is_current_component_core() {
1157
  $retval = false;
@@ -1169,6 +1490,11 @@ function bp_is_current_component_core() {
1169
 
1170
  /** Activity ******************************************************************/
1171
 
 
 
 
 
 
1172
  function bp_is_single_activity() {
1173
  if ( bp_is_activity_component() && is_numeric( bp_current_action() ) )
1174
  return true;
@@ -1178,6 +1504,14 @@ function bp_is_single_activity() {
1178
 
1179
  /** User **********************************************************************/
1180
 
 
 
 
 
 
 
 
 
1181
  function bp_is_my_profile() {
1182
  if ( is_user_logged_in() && bp_loggedin_user_id() == bp_displayed_user_id() )
1183
  $my_profile = true;
@@ -1187,6 +1521,13 @@ function bp_is_my_profile() {
1187
  return apply_filters( 'bp_is_my_profile', $my_profile );
1188
  }
1189
 
 
 
 
 
 
 
 
1190
  function bp_is_user() {
1191
  if ( bp_displayed_user_id() )
1192
  return true;
@@ -1194,6 +1535,13 @@ function bp_is_user() {
1194
  return false;
1195
  }
1196
 
 
 
 
 
 
 
 
1197
  function bp_is_user_activity() {
1198
  if ( bp_is_user() && bp_is_activity_component() )
1199
  return true;
@@ -1201,6 +1549,13 @@ function bp_is_user_activity() {
1201
  return false;
1202
  }
1203
 
 
 
 
 
 
 
 
1204
  function bp_is_user_friends_activity() {
1205
 
1206
  if ( !bp_is_active( 'friends' ) )
@@ -1217,6 +1572,13 @@ function bp_is_user_friends_activity() {
1217
  return false;
1218
  }
1219
 
 
 
 
 
 
 
 
1220
  function bp_is_user_groups_activity() {
1221
 
1222
  if ( !bp_is_active( 'groups' ) )
@@ -1233,6 +1595,13 @@ function bp_is_user_groups_activity() {
1233
  return false;
1234
  }
1235
 
 
 
 
 
 
 
 
1236
  function bp_is_user_profile() {
1237
  if ( bp_is_profile_component() || bp_is_current_component( 'profile' ) )
1238
  return true;
@@ -1240,6 +1609,13 @@ function bp_is_user_profile() {
1240
  return false;
1241
  }
1242
 
 
 
 
 
 
 
 
1243
  function bp_is_user_profile_edit() {
1244
  if ( bp_is_profile_component() && bp_is_current_action( 'edit' ) )
1245
  return true;
@@ -1257,9 +1633,9 @@ function bp_is_user_change_avatar() {
1257
  /**
1258
  * Is this a user's forums page?
1259
  *
1260
- * @package BuddyPress
1261
  *
1262
- * @return bool
1263
  */
1264
  function bp_is_user_forums() {
1265
 
@@ -1275,10 +1651,11 @@ function bp_is_user_forums() {
1275
  /**
1276
  * Is this a user's "Topics Started" page?
1277
  *
1278
- * @package BuddyPress
1279
- * @since BuddyPress (1.5)
1280
  *
1281
- * @return bool
 
 
1282
  */
1283
  function bp_is_user_forums_started() {
1284
  if ( bp_is_user_forums() && bp_is_current_action( 'topics' ) )
@@ -1290,10 +1667,11 @@ function bp_is_user_forums_started() {
1290
  /**
1291
  * Is this a user's "Replied To" page?
1292
  *
1293
- * @package BuddyPress
1294
- * @since BuddyPress (1.5)
1295
  *
1296
- * @return bool
 
 
1297
  */
1298
  function bp_is_user_forums_replied_to() {
1299
  if ( bp_is_user_forums() && bp_is_current_action( 'replies' ) )
@@ -1302,6 +1680,13 @@ function bp_is_user_forums_replied_to() {
1302
  return false;
1303
  }
1304
 
 
 
 
 
 
 
 
1305
  function bp_is_user_groups() {
1306
  if ( bp_is_user() && bp_is_groups_component() )
1307
  return true;
@@ -1309,6 +1694,13 @@ function bp_is_user_groups() {
1309
  return false;
1310
  }
1311
 
 
 
 
 
 
 
 
1312
  function bp_is_user_blogs() {
1313
  if ( bp_is_user() && bp_is_blogs_component() )
1314
  return true;
@@ -1316,6 +1708,13 @@ function bp_is_user_blogs() {
1316
  return false;
1317
  }
1318
 
 
 
 
 
 
 
 
1319
  function bp_is_user_recent_posts() {
1320
  if ( bp_is_user_blogs() && bp_is_current_action( 'recent-posts' ) )
1321
  return true;
@@ -1323,6 +1722,13 @@ function bp_is_user_recent_posts() {
1323
  return false;
1324
  }
1325
 
 
 
 
 
 
 
 
1326
  function bp_is_user_recent_commments() {
1327
  if ( bp_is_user_blogs() && bp_is_current_action( 'recent-comments' ) )
1328
  return true;
@@ -1330,6 +1736,13 @@ function bp_is_user_recent_commments() {
1330
  return false;
1331
  }
1332
 
 
 
 
 
 
 
 
1333
  function bp_is_user_friends() {
1334
  if ( bp_is_user() && bp_is_friends_component() )
1335
  return true;
@@ -1337,6 +1750,13 @@ function bp_is_user_friends() {
1337
  return false;
1338
  }
1339
 
 
 
 
 
 
 
 
1340
  function bp_is_user_friend_requests() {
1341
  if ( bp_is_user_friends() && bp_is_current_action( 'requests' ) )
1342
  return true;
@@ -1344,12 +1764,29 @@ function bp_is_user_friend_requests() {
1344
  return false;
1345
  }
1346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1347
  /**
1348
  * Is this a user's settings page?
1349
  *
1350
- * @package BuddyPress
1351
  *
1352
- * @return bool
1353
  */
1354
  function bp_is_user_settings() {
1355
  if ( bp_is_user() && bp_is_settings_component() )
@@ -1361,10 +1798,11 @@ function bp_is_user_settings() {
1361
  /**
1362
  * Is this a user's General Settings page?
1363
  *
1364
- * @package BuddyPress
1365
- * @since BuddyPress (1.5)
1366
  *
1367
- * @return bool
 
 
1368
  */
1369
  function bp_is_user_settings_general() {
1370
  if ( bp_is_user_settings() && bp_is_current_action( 'general' ) )
@@ -1376,10 +1814,11 @@ function bp_is_user_settings_general() {
1376
  /**
1377
  * Is this a user's Notification Settings page?
1378
  *
1379
- * @package BuddyPress
1380
- * @since BuddyPress (1.5)
1381
  *
1382
- * @return bool
 
 
1383
  */
1384
  function bp_is_user_settings_notifications() {
1385
  if ( bp_is_user_settings() && bp_is_current_action( 'notifications' ) )
@@ -1391,10 +1830,11 @@ function bp_is_user_settings_notifications() {
1391
  /**
1392
  * Is this a user's Account Deletion page?
1393
  *
1394
- * @package BuddyPress
1395
- * @since BuddyPress (1.5)
1396
  *
1397
- * @return bool
 
 
1398
  */
1399
  function bp_is_user_settings_account_delete() {
1400
  if ( bp_is_user_settings() && bp_is_current_action( 'delete-account' ) )
@@ -1403,9 +1843,15 @@ function bp_is_user_settings_account_delete() {
1403
  return false;
1404
  }
1405
 
 
1406
 
1407
- /** Groups ******************************************************************/
1408
-
 
 
 
 
 
1409
  function bp_is_group() {
1410
  global $bp;
1411
 
@@ -1415,6 +1861,14 @@ function bp_is_group() {
1415
  return false;
1416
  }
1417
 
 
 
 
 
 
 
 
 
1418
  function bp_is_group_home() {
1419
  if ( bp_is_single_item() && bp_is_groups_component() && ( !bp_current_action() || bp_is_current_action( 'home' ) ) )
1420
  return true;
@@ -1422,6 +1876,11 @@ function bp_is_group_home() {
1422
  return false;
1423
  }
1424
 
 
 
 
 
 
1425
  function bp_is_group_create() {
1426
  if ( bp_is_groups_component() && bp_is_current_action( 'create' ) )
1427
  return true;
@@ -1429,6 +1888,13 @@ function bp_is_group_create() {
1429
  return false;
1430
  }
1431
 
 
 
 
 
 
 
 
1432
  function bp_is_group_admin_page() {
1433
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) )
1434
  return true;
@@ -1436,6 +1902,13 @@ function bp_is_group_admin_page() {
1436
  return false;
1437
  }
1438
 
 
 
 
 
 
 
 
1439
  function bp_is_group_forum() {
1440
  $retval = false;
1441
 
@@ -1453,6 +1926,11 @@ function bp_is_group_forum() {
1453
  return $retval;
1454
  }
1455
 
 
 
 
 
 
1456
  function bp_is_group_activity() {
1457
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) )
1458
  return true;
@@ -1460,6 +1938,13 @@ function bp_is_group_activity() {
1460
  return false;
1461
  }
1462
 
 
 
 
 
 
 
 
1463
  function bp_is_group_forum_topic() {
1464
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) )
1465
  return true;
@@ -1467,6 +1952,13 @@ function bp_is_group_forum_topic() {
1467
  return false;
1468
  }
1469
 
 
 
 
 
 
 
 
1470
  function bp_is_group_forum_topic_edit() {
1471
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_is_action_variable( 'edit', 2 ) )
1472
  return true;
@@ -1474,6 +1966,13 @@ function bp_is_group_forum_topic_edit() {
1474
  return false;
1475
  }
1476
 
 
 
 
 
 
 
 
1477
  function bp_is_group_members() {
1478
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) )
1479
  return true;
@@ -1481,6 +1980,13 @@ function bp_is_group_members() {
1481
  return false;
1482
  }
1483
 
 
 
 
 
 
 
 
1484
  function bp_is_group_invites() {
1485
  if ( bp_is_groups_component() && bp_is_current_action( 'send-invites' ) )
1486
  return true;
@@ -1488,6 +1994,13 @@ function bp_is_group_invites() {
1488
  return false;
1489
  }
1490
 
 
 
 
 
 
 
 
1491
  function bp_is_group_membership_request() {
1492
  if ( bp_is_groups_component() && bp_is_current_action( 'request-membership' ) )
1493
  return true;
@@ -1495,6 +2008,11 @@ function bp_is_group_membership_request() {
1495
  return false;
1496
  }
1497
 
 
 
 
 
 
1498
  function bp_is_group_leave() {
1499
 
1500
  if ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) )
@@ -1503,6 +2021,15 @@ function bp_is_group_leave() {
1503
  return false;
1504
  }
1505
 
 
 
 
 
 
 
 
 
 
1506
  function bp_is_group_single() {
1507
  if ( bp_is_groups_component() && bp_is_single_item() )
1508
  return true;
@@ -1510,6 +2037,13 @@ function bp_is_group_single() {
1510
  return false;
1511
  }
1512
 
 
 
 
 
 
 
 
1513
  function bp_is_create_blog() {
1514
  if ( bp_is_blogs_component() && bp_is_current_action( 'create' ) )
1515
  return true;
@@ -1519,6 +2053,13 @@ function bp_is_create_blog() {
1519
 
1520
  /** Messages ******************************************************************/
1521
 
 
 
 
 
 
 
 
1522
  function bp_is_user_messages() {
1523
  if ( bp_is_user() && bp_is_messages_component() )
1524
  return true;
@@ -1526,6 +2067,13 @@ function bp_is_user_messages() {
1526
  return false;
1527
  }
1528
 
 
 
 
 
 
 
 
1529
  function bp_is_messages_inbox() {
1530
  if ( bp_is_user_messages() && ( !bp_current_action() || bp_is_current_action( 'inbox' ) ) )
1531
  return true;
@@ -1533,6 +2081,13 @@ function bp_is_messages_inbox() {
1533
  return false;
1534
  }
1535
 
 
 
 
 
 
 
 
1536
  function bp_is_messages_sentbox() {
1537
  if ( bp_is_user_messages() && bp_is_current_action( 'sentbox' ) )
1538
  return true;
@@ -1540,6 +2095,13 @@ function bp_is_messages_sentbox() {
1540
  return false;
1541
  }
1542
 
 
 
 
 
 
 
 
1543
  function bp_is_messages_compose_screen() {
1544
  if ( bp_is_user_messages() && bp_is_current_action( 'compose' ) )
1545
  return true;
@@ -1547,6 +2109,13 @@ function bp_is_messages_compose_screen() {
1547
  return false;
1548
  }
1549
 
 
 
 
 
 
 
 
1550
  function bp_is_notices() {
1551
  if ( bp_is_user_messages() && bp_is_current_action( 'notices' ) )
1552
  return true;
@@ -1554,6 +2123,11 @@ function bp_is_notices() {
1554
  return false;
1555
  }
1556
 
 
 
 
 
 
1557
  function bp_is_messages_conversation() {
1558
  if ( bp_is_user_messages() && ( bp_is_current_action( 'view' ) ) )
1559
  return true;
@@ -1561,6 +2135,11 @@ function bp_is_messages_conversation() {
1561
  return false;
1562
  }
1563
 
 
 
 
 
 
1564
  function bp_is_single( $component, $callback ) {
1565
  if ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) )
1566
  return true;
@@ -1570,6 +2149,13 @@ function bp_is_single( $component, $callback ) {
1570
 
1571
  /** Registration **************************************************************/
1572
 
 
 
 
 
 
 
 
1573
  function bp_is_activation_page() {
1574
  if ( bp_is_current_component( 'activate' ) )
1575
  return true;
@@ -1577,6 +2163,13 @@ function bp_is_activation_page() {
1577
  return false;
1578
  }
1579
 
 
 
 
 
 
 
 
1580
  function bp_is_register_page() {
1581
  if ( bp_is_current_component( 'register' ) )
1582
  return true;
@@ -1585,14 +2178,13 @@ function bp_is_register_page() {
1585
  }
1586
 
1587
  /**
1588
- * Use the above is_() functions to output a body class for each scenario
1589
  *
1590
- * @package BuddyPress
1591
- * @subpackage Core Template
1592
  *
1593
- * @param array $wp_classes The body classes coming from WP
1594
- * @param array $custom_classes Classes that were passed to get_body_class()
1595
- * @return array $classes The BP-adjusted body classes
1596
  */
1597
  function bp_the_body_class() {
1598
  echo bp_get_the_body_class();
@@ -1791,13 +2383,16 @@ function bp_the_body_class() {
1791
  /**
1792
  * Sort BuddyPress nav menu items by their position property.
1793
  *
1794
- * This is an internal convenience function and it will probably be removed in a later release. Do not use.
 
1795
  *
1796
  * @access private
1797
- * @param array $a First item
1798
- * @param array $b Second item
1799
- * @return int Returns an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
1800
- * @since BuddyPress (1.7)
 
 
1801
  */
1802
  function _bp_nav_menu_sort( $a, $b ) {
1803
  if ( $a["position"] == $b["position"] )
@@ -1811,10 +2406,11 @@ function _bp_nav_menu_sort( $a, $b ) {
1811
  }
1812
 
1813
  /**
1814
- * Get an array of all the items registered in the primary and secondary BuddyPress navigation menus
 
 
1815
  *
1816
- * @return array
1817
- * @since BuddyPress (1.7)
1818
  */
1819
  function bp_get_nav_menu_items() {
1820
  $menus = $selected_menus = array();
@@ -1888,34 +2484,40 @@ function bp_get_nav_menu_items() {
1888
  }
1889
 
1890
  /**
1891
- * Displays a navigation menu.
1892
- *
1893
- * @param string|array $args Optional arguments:
1894
- * - before Text before the link text.
1895
- * - container Whether to wrap the ul, and what to wrap it with.
1896
- * Defaults to div.
1897
- * - container_class The class that is applied to the container. Defaults to
1898
- * 'menu-bp-container'.
1899
- * - container_id The ID that is applied to the container. Defaults to
1900
- * blank.
1901
- * - depth How many levels of the hierarchy are to be included. 0
1902
- * means all. Defaults to 0.
1903
- * - echo Whether to echo the menu or return it. Defaults to echo.
1904
- * - fallback_cb If the menu doesn't exists, a callback function will
1905
- * fire. Defaults to false (no fallback).
1906
- * - items_wrap How the list items should be wrapped. Defaults to a ul
1907
- * with an id and class. Uses printf() format with numbered
1908
- * placeholders.
1909
- * - link_after Text after the link.
1910
- * - link_before Text before the link.
1911
- * - menu_class CSS class to use for the ul element which forms the menu.
1912
- * Defaults to 'menu'.
1913
- * - menu_id The ID that is applied to the ul element which forms the
1914
- * menu. Defaults to 'menu-bp', incremented.
1915
- * - walker Allows a custom walker to be specified. Defaults to
1916
- * 'BP_Walker_Nav_Menu'.
1917
- *
1918
- * @since BuddyPress (1.7)
 
 
 
 
 
 
1919
  */
1920
  function bp_nav_menu( $args = array() ) {
1921
  static $menu_id_slugs = array();
1
  <?php
2
+ /**
3
+ * Core component template tag functions
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage TemplateFunctions
7
+ */
8
 
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
+ * Output the "options nav", the secondary-level single item navigation menu.
14
+ *
15
+ * Uses the $bp->bp_options_nav global to render out the sub navigation for the
16
+ * current component. Each component adds to its sub navigation array within
17
+ * its own setup_nav() function.
18
  *
19
+ * This sub navigation array is the secondary level navigation, so for profile
20
+ * it contains:
21
  * [Public, Edit Profile, Change Avatar]
22
  *
23
+ * The function will also analyze the current action for the current component
24
+ * to determine whether or not to highlight a particular sub nav item.
25
  *
26
+ * @global BuddyPress $bp The one true BuddyPress instance.
27
+ * @uses bp_get_user_nav() Renders the navigation for a profile of a currently
28
+ * viewed user.
29
  */
30
  function bp_get_options_nav() {
31
  global $bp;
68
  }
69
  }
70
 
71
+ /**
72
+ * Get the 'bp_options_title' property from the BP global.
73
+ *
74
+ * Not currently used in BuddyPress.
75
+ * @todo Deprecate.
76
+ */
77
  function bp_get_options_title() {
78
  global $bp;
79
 
86
  /** Avatars *******************************************************************/
87
 
88
  /**
89
+ * Check to see if there is an options avatar.
90
+ *
91
+ * An options avatar is an avatar for something like a group, or a friend.
92
+ * Basically an avatar that appears in the sub nav options bar.
93
  *
94
+ * Not currently used in BuddyPress.
95
+ *
96
+ * @global BuddyPress $bp The one true BuddyPress instance.
97
+ * @todo Deprecate.
98
+ *
99
+ * @return bool Returns true if an options avatar has been set, otherwise
100
+ * false.
101
  */
102
  function bp_has_options_avatar() {
103
  global $bp;
108
  return true;
109
  }
110
 
111
+ /**
112
+ * Output the options avatar.
113
+ *
114
+ * Not currently used in BuddyPress.
115
+ *
116
+ * @todo Deprecate.
117
+ */
118
  function bp_get_options_avatar() {
119
  global $bp;
120
 
121
  echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_avatar );
122
  }
123
 
124
+ /**
125
+ * Output a comment author's avatar.
126
+ *
127
+ * Not currently used in BuddyPress.
128
+ *
129
+ * @todo Deprecate.
130
+ */
131
  function bp_comment_author_avatar() {
132
  global $comment;
133
 
137
  get_avatar();
138
  }
139
 
140
+ /**
141
+ * Output a post author's avatar.
142
+ *
143
+ * Not currently used in BuddyPress.
144
+ *
145
+ * @todo Deprecate.
146
+ */
147
  function bp_post_author_avatar() {
148
  global $post;
149
 
153
  get_avatar();
154
  }
155
 
156
+ /**
157
+ * Output the current avatar upload step.
158
+ */
159
  function bp_avatar_admin_step() {
160
  echo bp_get_avatar_admin_step();
161
  }
162
+ /**
163
+ * Return the current avatar upload step.
164
+ *
165
+ * @return string The current avatar upload step. Returns 'upload-image'
166
+ * if none is found.
167
+ */
168
  function bp_get_avatar_admin_step() {
169
  global $bp;
170
 
176
  return apply_filters( 'bp_get_avatar_admin_step', $step );
177
  }
178
 
179
+ /**
180
+ * Output the URL of the avatar to crop.
181
+ */
182
  function bp_avatar_to_crop() {
183
  echo bp_get_avatar_to_crop();
184
  }
185
+ /**
186
+ * Return the URL of the avatar to crop.
187
+ *
188
+ * @return string URL of the avatar awaiting cropping.
189
+ */
190
  function bp_get_avatar_to_crop() {
191
  global $bp;
192
 
198
  return apply_filters( 'bp_get_avatar_to_crop', $url );
199
  }
200
 
201
+ /**
202
+ * Output the relative file path to the avatar to crop.
203
+ */
204
  function bp_avatar_to_crop_src() {
205
  echo bp_get_avatar_to_crop_src();
206
  }
207
+ /**
208
+ * Return the relative file path to the avatar to crop.
209
+ *
210
+ * @return string Relative file path to the avatar.
211
+ */
212
  function bp_get_avatar_to_crop_src() {
213
  global $bp;
214
 
215
  return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) );
216
  }
217
 
218
+ /**
219
+ * Output the avatar cropper <img> markup.
220
+ *
221
+ * No longer used in BuddyPress.
222
+ *
223
+ * @todo Deprecate.
224
+ */
225
  function bp_avatar_cropper() {
226
  global $bp;
227
 
229
  }
230
 
231
  /**
232
+ * Output the name of the BP site. Used in RSS headers.
233
  */
234
  function bp_site_name() {
235
  echo bp_get_site_name();
236
  }
237
  /**
238
+ * Returns the name of the BP site. Used in RSS headers.
239
  *
240
+ * @since BuddyPress (1.6.0)
241
  */
242
  function bp_get_site_name() {
243
  return apply_filters( 'bp_site_name', get_bloginfo( 'name', 'display' ) );
244
  }
245
 
246
+ /**
247
+ * Format a date.
248
+ *
249
+ * @param int $time The UNIX timestamp to be formatted.
250
+ * @param bool $just_date Optional. True to return only the month + day, false
251
+ * to return month, day, and time. Default: false.
252
+ * @param bool $localize_time Optional. True to display in local time, false to
253
+ * leave in GMT. Default: true.
254
+ * @return string|bool $localize_time Optional. A string representation of
255
+ * $time, in the format "January 1, 2010 at 9:50pm" (or whatever your
256
+ * 'date_format' and 'time_format' settings are). False on failure.
257
+ */
258
  function bp_format_time( $time, $just_date = false, $localize_time = true ) {
259
  if ( !isset( $time ) || !is_numeric( $time ) )
260
  return false;
282
  return apply_filters( 'bp_format_time', $date );
283
  }
284
 
285
+ /**
286
+ * Select between two dynamic strings, according to context.
287
+ *
288
+ * This function can be used in cases where a phrase used in a template will
289
+ * differ for a user looking at his own profile and a user looking at another
290
+ * user's profile (eg, "My Friends" and "Joe's Friends"). Pass both versions
291
+ * of the phrase, and bp_word_or_name() will detect which is appropriate, and
292
+ * do the necessary argument swapping for dynamic phrases.
293
+ *
294
+ * @param string $youtext The "you" version of the phrase (eg "Your Friends").
295
+ * @param string $nametext The other-user version of the phrase. Should be in
296
+ * a format appropriate for sprintf() - use %s in place of the displayed
297
+ * user's name (eg "%'s Friends").
298
+ * @param bool $capitalize Optional. Force into title case. Default: true.
299
+ * @param bool $echo Optional. True to echo the results, false to return them.
300
+ * Default: true.
301
+ * @return string|null If ! $echo, returns the appropriate string.
302
+ */
303
  function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
304
 
305
  if ( !empty( $capitalize ) )
323
  }
324
  }
325
 
326
+ /**
327
+ * Do the 'bp_styles' action, and call wp_print_styles().
328
+ *
329
+ * No longer used in BuddyPress.
330
+ *
331
+ * @todo Deprecate.
332
+ */
333
  function bp_styles() {
334
  do_action( 'bp_styles' );
335
  wp_print_styles();
337
 
338
  /** Search Form ***************************************************************/
339
 
340
+ /**
341
+ * Return the "action" attribute for search forms.
342
+ *
343
+ * @return string URL action attribute for search forms, eg example.com/search/.
344
+ */
345
  function bp_search_form_action() {
346
  return apply_filters( 'bp_search_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_search_slug() ) );
347
  }
348
 
349
  /**
350
+ * Generate the basic search form as used in BP-Default's header.
351
+ *
352
+ * @since BuddyPress (1.0.0)
353
  *
354
+ * @return string HTML <select> element.
 
355
  */
356
  function bp_search_form_type_select() {
357
 
385
  }
386
 
387
  /**
388
+ * Output the default text for the search box for a given component.
389
  *
390
+ * @since BuddyPress (1.5.0)
391
+ *
392
+ * @see bp_get_search_default_text()
393
+ *
394
+ * @param string $component See {@link bp_get_search_default_text()}.
395
  */
396
  function bp_search_default_text( $component = '' ) {
397
  echo bp_get_search_default_text( $component );
398
  }
399
+ /**
400
+ * Return the default text for the search box for a given component.
401
+ *
402
+ * @since BuddyPress (1.5.0)
403
+ *
404
+ * @param string $component Component name. Default: current component.
405
+ * @return string Placeholder text for search field.
406
+ */
407
  function bp_get_search_default_text( $component = '' ) {
408
  global $bp;
409
 
430
  return apply_filters( 'bp_get_search_default_text', $default_text, $component );
431
  }
432
 
433
+ /**
434
+ * Fire the 'bp_custom_profile_boxes' action.
435
+ *
436
+ * No longer used in BuddyPress.
437
+ *
438
+ * @todo Deprecate.
439
+ */
440
  function bp_custom_profile_boxes() {
441
  do_action( 'bp_custom_profile_boxes' );
442
  }
443
 
444
+ /**
445
+ * Fire the 'bp_custom_profile_sidebar_boxes' action.
446
+ *
447
+ * No longer used in BuddyPress.
448
+ *
449
+ * @todo Deprecate.
450
+ */
451
  function bp_custom_profile_sidebar_boxes() {
452
  do_action( 'bp_custom_profile_sidebar_boxes' );
453
  }
454
 
455
  /**
456
+ * Create and output a button.
457
  *
 
458
  * @see bp_get_button()
459
+ *
460
+ * @param array $args See {@link BP_Button}.
461
  */
462
  function bp_button( $args = '' ) {
463
  echo bp_get_button( $args );
464
  }
465
  /**
466
+ * Create and return a button.
467
  *
468
+ * @see BP_Button for a description of arguments and return value.
 
 
 
 
 
 
 
 
 
 
 
 
469
  *
470
+ * @param array $args See {@link BP_Button}.
471
+ * @return string HTML markup for the button.
 
 
 
472
  */
473
  function bp_get_button( $args = '' ) {
474
  $button = new BP_Button( $args );
475
  return apply_filters( 'bp_get_button', $button->contents, $args, $button );
476
  }
477
 
 
478
  /**
479
+ * Truncate text.
480
  *
481
  * Cuts a string to the length of $length and replaces the last characters
482
  * with the ending if the text is longer than length.
491
  * - `html` If true, HTML tags would be handled correctly
492
  * - `filter_shortcodes` If true, shortcodes will be stripped before truncating
493
  *
494
+ * @param string $text String to truncate.
495
+ * @param int $length Optional. Length of returned string, including ellipsis.
496
+ * Default: 225.
497
+ * @param array $options {
498
+ * An array of HTML attributes and options. Each item is optional.
499
+ * @type string $ending The string used after truncation.
500
+ * Default: ' [&hellip;]'.
501
+ * @type bool $exact If true, $text will be trimmed to exactly $length.
502
+ * If false, $text will not be cut mid-word. Default: false.
503
+ * @type bool $html If true, don't include HTML tags when calculating
504
+ * excerpt length. Default: true.
505
+ * @type bool $filter_shortcodes If true, shortcodes will be stripped.
506
+ * Default: true.
507
+ * }
508
  * @return string Trimmed string.
509
  */
510
  function bp_create_excerpt( $text, $length = 225, $options = array() ) {
625
  add_filter( 'bp_create_excerpt', 'force_balance_tags' );
626
 
627
  /**
628
+ * Output the total member count for the site.
629
  */
630
  function bp_total_member_count() {
631
  echo bp_get_total_member_count();
632
  }
633
  /**
634
+ * Return the total member count in your BP instance.
635
+ *
636
+ * Since BuddyPress 1.6, this function has used bp_core_get_active_member_count(),
637
+ * which counts non-spam, non-deleted users who have last_activity.
638
+ * This value will correctly match the total member count number used
639
+ * for pagination on member directories.
640
  *
641
+ * Before BuddyPress 1.6, this function used bp_core_get_total_member_count(),
642
+ * which did not take into account last_activity, and thus often
643
+ * resulted in higher counts than shown by member directory pagination.
644
  *
645
+ * @return int Member count.
 
 
646
  */
647
  function bp_get_total_member_count() {
648
  return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() );
649
  }
650
  add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
651
 
652
+ /**
653
+ * Output whether blog signup is allowed.
654
+ *
655
+ * @todo Deprecate. It doesn't make any sense to echo a boolean.
656
+ */
657
  function bp_blog_signup_allowed() {
658
  echo bp_get_blog_signup_allowed();
659
  }
660
+ /**
661
+ * Is blog signup allowed?
662
+ *
663
+ * Returns true if is_multisite() and blog creation is enabled at
664
+ * Network Admin > Settings.
665
+ *
666
+ * @return bool True if blog signup is allowed, otherwise false.
667
+ */
668
  function bp_get_blog_signup_allowed() {
669
  global $bp;
670
 
678
  return false;
679
  }
680
 
681
+ /**
682
+ * Check whether an activation has just been completed.
683
+ *
684
+ * @return bool True if the activation_complete global flag has been set,
685
+ * otherwise false.
686
+ */
687
  function bp_account_was_activated() {
688
  global $bp;
689
 
692
  return $activation_complete;
693
  }
694
 
695
+ /**
696
+ * Check whether registrations require activation on this installation.
697
+ *
698
+ * On a normal BuddyPress installation, all registrations require email
699
+ * activation. This filter exists so that customizations that omit activation
700
+ * can remove certain notification text from the registration screen.
701
+ *
702
+ * @return bool True by default.
703
+ */
704
  function bp_registration_needs_activation() {
705
  return apply_filters( 'bp_registration_needs_activation', true );
706
  }
707
 
708
  /**
709
+ * Retrieve a client friendly version of the root blog name.
 
710
  *
711
  * The blogname option is escaped with esc_html on the way into the database in
712
  * sanitize_option, we want to reverse this for the plain text arena of emails.
713
  *
714
+ * @since BuddyPress (1.7.0)
715
+ *
716
+ * @see http://buddypress.trac.wordpress.org/ticket/4401
717
+ *
718
+ * @param array $args {
719
+ * Array of optional parameters.
720
+ * @type string $before String to appear before the site name in the
721
+ * email subject. Default: '['.
722
+ * @type string $after String to appear after the site name in the
723
+ * email subject. Default: ']'.
724
+ * @type string $default The default site name, to be used when none is
725
+ * found in the database. Default: 'Community'.
726
+ * @type string $text Text to append to the site name (ie, the main text of
727
+ * the email subject).
728
+ * }
729
+ * @return string Sanitized email subject.
730
  */
731
  function bp_get_email_subject( $args = array() ) {
732
 
743
  }
744
 
745
  /**
746
+ * Allow templates to pass parameters directly into the template loops via AJAX.
747
+ *
748
+ * For the most part this will be filtered in a theme's functions.php for
749
+ * example in the default theme it is filtered via bp_dtheme_ajax_querystring().
750
  *
751
+ * By using this template tag in the templates it will stop them from showing
752
+ * errors if someone copies the templates from the default theme into another
753
+ * WordPress theme without coping the functions from functions.php.
754
  *
755
+ * @param string $object
756
+ * @return string The AJAX querystring.
 
757
  */
758
  function bp_ajax_querystring( $object = false ) {
759
  global $bp;
766
 
767
  /** Template Classes and _is functions ****************************************/
768
 
769
+ /**
770
+ * Return the name of the current component.
771
+ *
772
+ * @return string Component name.
773
+ */
774
  function bp_current_component() {
775
  global $bp;
776
  $current_component = !empty( $bp->current_component ) ? $bp->current_component : false;
777
  return apply_filters( 'bp_current_component', $current_component );
778
  }
779
 
780
+ /**
781
+ * Return the name of the current action.
782
+ *
783
+ * @return string Action name.
784
+ */
785
  function bp_current_action() {
786
  global $bp;
787
  $current_action = !empty( $bp->current_action ) ? $bp->current_action : '';
788
  return apply_filters( 'bp_current_action', $current_action );
789
  }
790
 
791
+ /**
792
+ * Return the name of the current item.
793
+ *
794
+ * @return unknown
795
+ */
796
  function bp_current_item() {
797
  global $bp;
798
  $current_item = !empty( $bp->current_item ) ? $bp->current_item : false;
800
  }
801
 
802
  /**
803
+ * Return the value of $bp->action_variables.
 
 
804
  *
805
+ * @return array|bool $action_variables The action variables array, or false
806
+ * if the array is empty.
807
  */
808
  function bp_action_variables() {
809
  global $bp;
812
  }
813
 
814
  /**
815
+ * Return the value of a given action variable.
816
  *
817
+ * @since BuddyPress (1.5.0)
 
818
  *
819
+ * @param int $position The key of the action_variables array that you want.
820
+ * @return string|bool $action_variable The value of that position in the
821
+ * array, or false if not found.
822
  */
823
  function bp_action_variable( $position = 0 ) {
824
  $action_variables = bp_action_variables();
827
  return apply_filters( 'bp_action_variable', $action_variable, $position );
828
  }
829
 
830
+ /**
831
+ * Output the "root domain", the URL of the BP root blog.
832
+ */
833
  function bp_root_domain() {
834
  echo bp_get_root_domain();
835
  }
836
+ /**
837
+ * Return the "root domain", the URL of the BP root blog.
838
+ *
839
+ * @return string URL of the BP root blog.
840
+ */
841
  function bp_get_root_domain() {
842
  global $bp;
843
 
852
  }
853
 
854
  /**
855
+ * Output the root slug for a given component.
856
  *
857
+ * @since BuddyPress (1.5.0)
858
+ *
859
+ * @param string $component The component name.
860
  */
861
  function bp_root_slug( $component = '' ) {
862
  echo bp_get_root_slug( $component );
863
  }
864
  /**
865
+ * Get the root slug for given component.
866
+ *
867
+ * The "root slug" is the string used when concatenating component
868
+ * directory URLs. For example, on an installation where the Groups
869
+ * component's directory is located at http://example.com/groups/, the
870
+ * root slug for the Groups component is 'groups'. This string
871
+ * generally corresponds to page_name of the component's directory
872
+ * page.
873
  *
874
+ * In order to maintain backward compatibility, the following procedure
875
+ * is used:
876
  * 1) Use the short slug to get the canonical component name from the
877
  * active component array
878
+ * 2) Use the component name to get the root slug out of the
879
+ * appropriate part of the $bp global
880
+ * 3) If nothing turns up, it probably means that $component is itself
881
+ * a root slug
882
+ *
883
+ * Example: If your groups directory is at /community/companies, this
884
+ * function first uses the short slug 'companies' (ie the current
885
+ * component) to look up the canonical name 'groups' in
886
+ * $bp->active_components. Then it uses 'groups' to get the root slug,
887
+ * from $bp->groups->root_slug.
888
  *
889
+ * @since BuddyPress (1.5.0)
 
 
 
890
  *
891
+ * @global BuddyPress $bp The one true BuddyPress instance.
 
892
  *
893
+ * @param string $component Optional. Defaults to the current component.
894
+ * @return string $root_slug The root slug.
 
895
  */
896
  function bp_get_root_slug( $component = '' ) {
897
  global $bp;
922
  }
923
 
924
  /**
925
+ * Return the component name based on a root slug.
926
  *
927
+ * @since BuddyPress (1.5.0)
928
+ *
929
+ * @global BuddyPress $bp The one true BuddyPress instance.
930
+ *
931
+ * @param string $root_slug Needle to our active component haystack.
932
+ * @return mixed False if none found, component name if found.
933
  */
934
  function bp_get_name_from_root_slug( $root_slug = '' ) {
935
  global $bp;
959
  }
960
 
961
  /**
962
+ * Output the search slug.
963
  *
964
+ * @since BuddyPress (1.5.0)
 
965
  *
966
  * @uses bp_get_search_slug()
967
  */
969
  echo bp_get_search_slug();
970
  }
971
  /**
972
+ * Return the search slug.
973
  *
974
+ * @since BuddyPress (1.5.0)
975
+ *
976
+ * @return string The search slug. Default: 'search'.
977
  */
978
  function bp_get_search_slug() {
979
  return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
980
  }
981
 
982
  /**
983
+ * Get the ID of the currently displayed user.
984
+ *
985
+ * @uses apply_filters() Filter 'bp_displayed_user_id' to change this value.
986
  *
987
+ * @return int ID of the currently displayed user.
 
988
  */
989
  function bp_displayed_user_id() {
990
  $bp = buddypress();
994
  }
995
 
996
  /**
997
+ * Get the ID of the currently logged-in user.
998
  *
999
+ * @uses apply_filters() Filter 'bp_loggedin_user_id' to change this value.
1000
+ *
1001
+ * @return int ID of the logged-in user.
1002
  */
1003
  function bp_loggedin_user_id() {
1004
  $bp = buddypress();
1010
  /** is_() functions to determine the current page *****************************/
1011
 
1012
  /**
1013
+ * Check to see whether the current page belongs to the specified component.
1014
  *
1015
  * This function is designed to be generous, accepting several different kinds
1016
  * of value for the $component parameter. It checks $component_name against:
1018
  * - the component's regular slug
1019
  * - the component's id, or 'canonical' name
1020
  *
1021
+ * @since BuddyPress (1.5.0)
1022
+ *
1023
+ * @param string $component Name of the component being checked.
1024
  * @return bool Returns true if the component matches, or else false.
1025
  */
1026
  function bp_is_current_component( $component ) {
1027
+ global $bp, $wp_query;
1028
 
1029
  $is_current_component = false;
1030
 
1031
+ // Always return false if a null value is passed to the function
1032
+ if ( empty( $component ) ) {
1033
+ return false;
1034
+ }
1035
+
1036
  // Backward compatibility: 'xprofile' should be read as 'profile'
1037
  if ( 'xprofile' == $component )
1038
  $component = 'profile';
1039
 
1040
+ if ( ! empty( $bp->current_component ) ) {
1041
 
1042
  // First, check to see whether $component_name and the current
1043
  // component are a simple match
1079
  }
1080
 
1081
  // Page template fallback check if $bp->current_component is empty
1082
+ } elseif ( !is_admin() && is_a( $wp_query, 'WP_Query' ) && is_page() ) {
1083
  global $wp_query;
1084
  $page = $wp_query->get_queried_object();
1085
  $custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
1097
  /**
1098
  * Check to see whether the current page matches a given action.
1099
  *
1100
+ * Along with bp_is_current_component() and bp_is_action_variable(), this
1101
+ * function is mostly used to help determine when to use a given screen
1102
+ * function.
1103
  *
1104
+ * In BP parlance, the current_action is the URL chunk that comes directly
1105
+ * after the current item slug. E.g., in
1106
  * http://example.com/groups/my-group/members
1107
  * the current_action is 'members'.
1108
  *
1109
+ * @since BuddyPress (1.5.0)
 
1110
  *
1111
+ * @param string $action The action being tested against.
1112
+ * @return bool True if the current action matches $action.
1113
  */
1114
  function bp_is_current_action( $action = '' ) {
1115
  if ( $action == bp_current_action() )
1121
  /**
1122
  * Check to see whether the current page matches a given action_variable.
1123
  *
1124
+ * Along with bp_is_current_component() and bp_is_current_action(), this
1125
+ * function is mostly used to help determine when to use a given screen
1126
+ * function.
1127
  *
1128
+ * In BP parlance, action_variables are an array made up of the URL chunks
1129
+ * appearing after the current_action in a URL. For example,
1130
  * http://example.com/groups/my-group/admin/group-settings
1131
  * $action_variables[0] is 'group-settings'.
1132
  *
1133
+ * @since BuddyPress (1.5.0)
 
1134
  *
1135
+ * @param string $action_variable The action_variable being tested against.
1136
+ * @param int $position Optional. The array key you're testing against. If you
1137
+ * don't provide a $position, the function will return true if the
1138
+ * $action_variable is found *anywhere* in the action variables array.
1139
+ * @return bool True if $action_variable matches at the $position provided.
1140
  */
1141
  function bp_is_action_variable( $action_variable = '', $position = false ) {
1142
  $is_action_variable = false;
1158
  return apply_filters( 'bp_is_action_variable', $is_action_variable, $action_variable, $position );
1159
  }
1160
 
1161
+ /**
1162
+ * Check against the current_item.
1163
+ *
1164
+ * @param string $item The item being checked.
1165
+ * @return bool True if $item is the current item.
1166
+ */
1167
  function bp_is_current_item( $item = '' ) {
1168
  if ( !empty( $item ) && $item == bp_current_item() )
1169
  return true;
1171
  return false;
1172
  }
1173
 
1174
+ /**
1175
+ * Are we looking at a single item? (group, user, etc)
1176
+ *
1177
+ * @return bool True if looking at a single item, otherwise false.
1178
+ */
1179
  function bp_is_single_item() {
1180
  global $bp;
1181
 
1185
  return false;
1186
  }
1187
 
1188
+ /**
1189
+ * Is the logged-in user an admin for the current item?
1190
+ *
1191
+ * @return bool True if the current user is an admin for the current item,
1192
+ * otherwise false.
1193
+ */
1194
  function bp_is_item_admin() {
1195
  global $bp;
1196
 
1200
  return false;
1201
  }
1202
 
1203
+ /**
1204
+ * Is the logged-in user a mod for the current item?
1205
+ *
1206
+ * @return bool True if the current user is a mod for the current item,
1207
+ * otherwise false.
1208
+ */
1209
  function bp_is_item_mod() {
1210
  global $bp;
1211
 
1215
  return false;
1216
  }
1217
 
1218
+ /**
1219
+ * Is this a component directory page?
1220
+ *
1221
+ * @return bool True if the current page is a component directory, otherwise
1222
+ * false.
1223
+ */
1224
  function bp_is_directory() {
1225
  global $bp;
1226
 
1231
  }
1232
 
1233
  /**
1234
+ * Check to see if a component's URL should be in the root, not under a member page.
 
1235
  *
1236
+ * Yes ('groups' is root): http://domain.com/groups/the-group
1237
+ * No ('groups' is not-root): http://domain.com/members/andy/groups/the-group
1238
  *
 
1239
  * @return bool True if root component, else false.
1240
  */
1241
  function bp_is_root_component( $component_name ) {
1253
  }
1254
 
1255
  /**
1256
+ * Check if the specified BuddyPress component directory is set to be the front page.
1257
+ *
1258
+ * Corresponds to the setting in wp-admin's Settings > Reading screen.
1259
+ *
1260
+ * @since BuddyPress (1.5.0)
1261
  *
1262
+ * @global BuddyPress $bp The one true BuddyPress instance.
1263
+ * @global $current_blog WordPress global for the current blog.
1264
+ *
1265
+ * @param string $component Optional. Name of the component to check for.
1266
+ * Default: current component.
1267
+ * @return bool True if the specified component is set to be the site's front
1268
+ * page, otherwise false.
1269
  */
1270
  function bp_is_component_front_page( $component = '' ) {
1271
  global $bp, $current_blog;
1284
  /**
1285
  * Is this a blog page, ie a non-BP page?
1286
  *
1287
+ * You can tell if a page is displaying BP content by whether the
1288
+ * current_component has been defined.
 
1289
  *
1290
+ * @return bool True if it's a non-BP page, false otherwise.
1291
  */
1292
  function bp_is_blog_page() {
1293
 
1306
  * Is this a BuddyPress component?
1307
  *
1308
  * You can tell if a page is displaying BP content by whether the
1309
+ * current_component has been defined.
1310
  *
1311
  * Generally, we can just check to see that there's no current component.
1312
  * The one exception is single user home tabs, where $bp->current_component
1313
  * is unset. Thus the addition of the bp_is_user() check.
1314
  *
1315
+ * @since BuddyPress (1.7.0)
1316
  *
1317
+ * @return bool True if it's a BuddyPress page, false otherwise.
 
1318
  */
1319
  function is_buddypress() {
1320
  $retval = (bool) ( bp_current_component() || bp_is_user() );
1324
 
1325
  /** Components ****************************************************************/
1326
 
1327
+ /**
1328
+ * Check whether a given component has been activated by the admin.
1329
+ *
1330
+ * @param string $component The component name.
1331
+ * @return bool True if the component is active, otherwise false.
1332
+ */
1333
  function bp_is_active( $component ) {
1334
  global $bp;
1335
 
1339
  return false;
1340
  }
1341
 
1342
+ /**
1343
+ * Check whether the current page is part of the Members component.
1344
+ *
1345
+ * @return bool True if the current page is part of the Members component.
1346
+ */
1347
  function bp_is_members_component() {
1348
  if ( bp_is_current_component( 'members' ) )
1349
  return true;
1351
  return false;
1352
  }
1353
 
1354
+ /**
1355
+ * Check whether the current page is part of the Profile component.
1356
+ *
1357
+ * @return bool True if the current page is part of the Profile component.
1358
+ */
1359
  function bp_is_profile_component() {
1360
  if ( bp_is_current_component( 'xprofile' ) )
1361
  return true;
1363
  return false;
1364
  }
1365
 
1366
+ /**
1367
+ * Check whether the current page is part of the Activity component.
1368
+ *
1369
+ * @return bool True if the current page is part of the Activity component.
1370
+ */
1371
  function bp_is_activity_component() {
1372
  if ( bp_is_current_component( 'activity' ) )
1373
  return true;
1375
  return false;
1376
  }
1377
 
1378
+ /**
1379
+ * Check whether the current page is part of the Blogs component.
1380
+ *
1381
+ * @return bool True if the current page is part of the Blogs component.
1382
+ */
1383
  function bp_is_blogs_component() {
1384
  if ( is_multisite() && bp_is_current_component( 'blogs' ) )
1385
  return true;
1387
  return false;
1388
  }
1389
 
1390
+ /**
1391
+ * Check whether the current page is part of the Messages component.
1392
+ *
1393
+ * @return bool True if the current page is part of the Messages component.
1394
+ */
1395
  function bp_is_messages_component() {
1396
  if ( bp_is_current_component( 'messages' ) )
1397
  return true;
1399
  return false;
1400
  }
1401
 
1402
+ /**
1403
+ * Check whether the current page is part of the Friends component.
1404
+ *
1405
+ * @return bool True if the current page is part of the Friends component.
1406
+ */
1407
  function bp_is_friends_component() {
1408
  if ( bp_is_current_component( 'friends' ) )
1409
  return true;
1411
  return false;
1412
  }
1413
 
1414
+ /**
1415
+ * Check whether the current page is part of the Groups component.
1416
+ *
1417
+ * @return bool True if the current page is part of the Groups component.
1418
+ */
1419
  function bp_is_groups_component() {
1420
  if ( bp_is_current_component( 'groups' ) )
1421
  return true;
1423
  return false;
1424
  }
1425
 
1426
+ /**
1427
+ * Check whether the current page is part of the Forums component.
1428
+ *
1429
+ * @return bool True if the current page is part of the Forums component.
1430
+ */
1431
  function bp_is_forums_component() {
1432
  if ( bp_is_current_component( 'forums' ) )
1433
  return true;
1435
  return false;
1436
  }
1437
 
1438
+ /**
1439
+ * Check whether the current page is part of the Notifications component.
1440
+ *
1441
+ * @since BuddyPress (1.9.0)
1442
+ *
1443
+ * @return bool True if the current page is part of the Notifications component.
1444
+ */
1445
+ function bp_is_notifications_component() {
1446
+ if ( bp_is_current_component( 'notifications' ) ) {
1447
+ return true;
1448
+ }
1449
+
1450
+ return false;
1451
+ }
1452
+
1453
+ /**
1454
+ * Check whether the current page is part of the Settings component.
1455
+ *
1456
+ * @return bool True if the current page is part of the Settings component.
1457
+ */
1458
  function bp_is_settings_component() {
1459
  if ( bp_is_current_component( 'settings' ) )
1460
  return true;
1463
  }
1464
 
1465
  /**
1466
+ * Is the current component an active core component?
1467
  *
1468
  * Use this function when you need to check if the current component is an
1469
  * active core component of BuddyPress. If the current component is inactive, it
1471
  * it will return false. If the current component is active, and is part of
1472
  * BuddyPress core, it will return true.
1473
  *
1474
+ * @return bool True if the current component is active and is one of BP's
1475
+ * packaged components.
1476
  */
1477
  function bp_is_current_component_core() {
1478
  $retval = false;
1490
 
1491
  /** Activity ******************************************************************/
1492
 
1493
+ /**
1494
+ * Is the current page a single activity item permalink?
1495
+ *
1496
+ * @return True if the current page is a single activity item permalink.
1497
+ */
1498
  function bp_is_single_activity() {
1499
  if ( bp_is_activity_component() && is_numeric( bp_current_action() ) )
1500
  return true;
1504
 
1505
  /** User **********************************************************************/
1506
 
1507
+ /**
1508
+ * Is the current page part of the profile of the logged-in user?
1509
+ *
1510
+ * Will return true for any subpage of the logged-in user's profile, eg
1511
+ * http://example.com/members/joe/friends/.
1512
+ *
1513
+ * @return True if the current page is part of the profile of the logged-in user.
1514
+ */
1515
  function bp_is_my_profile() {
1516
  if ( is_user_logged_in() && bp_loggedin_user_id() == bp_displayed_user_id() )
1517
  $my_profile = true;
1521
  return apply_filters( 'bp_is_my_profile', $my_profile );
1522
  }
1523
 
1524
+ /**
1525
+ * Is the current page a user page?
1526
+ *
1527
+ * Will return true anytime there is a displayed user.
1528
+ *
1529
+ * @return True if the current page is a user page.
1530
+ */
1531
  function bp_is_user() {
1532
  if ( bp_displayed_user_id() )
1533
  return true;
1535
  return false;
1536
  }
1537
 
1538
+ /**
1539
+ * Is the current page a user's activity stream page?
1540
+ *
1541
+ * Eg http://example.com/members/joe/activity/ (or any subpages thereof).
1542
+ *
1543
+ * @return True if the current page is a user's activity stream page.
1544
+ */
1545
  function bp_is_user_activity() {
1546
  if ( bp_is_user() && bp_is_activity_component() )
1547
  return true;
1549
  return false;
1550
  }
1551
 
1552
+ /**
1553
+ * Is the current page a user's Friends activity stream?
1554
+ *
1555
+ * Eg http://example.com/members/joe/friends/
1556
+ *
1557
+ * @return True if the current page is a user's Friends activity stream.
1558
+ */
1559
  function bp_is_user_friends_activity() {
1560
 
1561
  if ( !bp_is_active( 'friends' ) )
1572
  return false;
1573
  }
1574
 
1575
+ /**
1576
+ * Is the current page a user's Groups activity stream?
1577
+ *
1578
+ * Eg http://example.com/members/joe/groups/
1579
+ *
1580
+ * @return True if the current page is a user's Groups activity stream.
1581
+ */
1582
  function bp_is_user_groups_activity() {
1583
 
1584
  if ( !bp_is_active( 'groups' ) )
1595
  return false;
1596
  }
1597
 
1598
+ /**
1599
+ * Is the current page part of a user's extended profile?
1600
+ *
1601
+ * Eg http://example.com/members/joe/profile/ (or a subpage thereof).
1602
+ *
1603
+ * @return True if the current page is part of a user's extended profile.
1604
+ */
1605
  function bp_is_user_profile() {
1606
  if ( bp_is_profile_component() || bp_is_current_component( 'profile' ) )
1607
  return true;
1609
  return false;
1610
  }
1611
 
1612
+ /**
1613
+ * Is the current page part of a user's profile editing section?
1614
+ *
1615
+ * Eg http://example.com/members/joe/profile/edit/ (or a subpage thereof).
1616
+ *
1617
+ * @return True if the current page is a user's profile edit page.
1618
+ */
1619
  function bp_is_user_profile_edit() {
1620
  if ( bp_is_profile_component() && bp_is_current_action( 'edit' ) )
1621
  return true;
1633
  /**
1634
  * Is this a user's forums page?
1635
  *
1636
+ * Eg http://example.com/members/joe/forums/ (or a subpage thereof).
1637
  *
1638
+ * @return bool True if the current page is a user's forums page.
1639
  */
1640
  function bp_is_user_forums() {
1641
 
1651
  /**
1652
  * Is this a user's "Topics Started" page?
1653
  *
1654
+ * Eg http://example.com/members/joe/forums/topics/.
 
1655
  *
1656
+ * @since BuddyPress (1.5.0)
1657
+ *
1658
+ * @return bool True if the current page is a user's Topics Started page.
1659
  */
1660
  function bp_is_user_forums_started() {
1661
  if ( bp_is_user_forums() && bp_is_current_action( 'topics' ) )
1667
  /**
1668
  * Is this a user's "Replied To" page?
1669
  *
1670
+ * Eg http://example.com/members/joe/forums/replies/.
 
1671
  *
1672
+ * @since BuddyPress (1.5.0)
1673
+ *
1674
+ * @return bool True if the current page is a user's Replied To forums page.
1675
  */
1676
  function bp_is_user_forums_replied_to() {
1677
  if ( bp_is_user_forums() && bp_is_current_action( 'replies' ) )
1680
  return false;
1681
  }
1682
 
1683
+ /**
1684
+ * Is the current page part of a user's Groups page?
1685
+ *
1686
+ * Eg http://example.com/members/joe/groups/ (or a subpage thereof).
1687
+ *
1688
+ * @return bool True if the current page is a user's Groups page.
1689
+ */
1690
  function bp_is_user_groups() {
1691
  if ( bp_is_user() && bp_is_groups_component() )
1692
  return true;
1694
  return false;
1695
  }
1696
 
1697
+ /**
1698
+ * Is the current page part of a user's Blogs page?
1699
+ *
1700
+ * Eg http://example.com/members/joe/blogs/ (or a subpage thereof).
1701
+ *
1702
+ * @return bool True if the current page is a user's Blogs page.
1703
+ */
1704
  function bp_is_user_blogs() {
1705
  if ( bp_is_user() && bp_is_blogs_component() )
1706
  return true;
1708
  return false;
1709
  }
1710
 
1711
+ /**
1712
+ * Is the current page a user's Recent Blog Posts page?
1713
+ *
1714
+ * Eg http://example.com/members/joe/blogs/recent-posts/.
1715
+ *
1716
+ * @return bool True if the current page is a user's Recent Blog Posts page.
1717
+ */
1718
  function bp_is_user_recent_posts() {
1719
  if ( bp_is_user_blogs() && bp_is_current_action( 'recent-posts' ) )
1720
  return true;
1722
  return false;
1723
  }
1724
 
1725
+ /**
1726
+ * Is the current page a user's Recent Blog Comments page?
1727
+ *
1728
+ * Eg http://example.com/members/joe/blogs/recent-comments/.
1729
+ *
1730
+ * @return bool True if the current page is a user's Recent Blog Comments page.
1731
+ */
1732
  function bp_is_user_recent_commments() {
1733
  if ( bp_is_user_blogs() && bp_is_current_action( 'recent-comments' ) )
1734
  return true;
1736
  return false;
1737
  }
1738
 
1739
+ /**
1740
+ * Is the current page a user's Friends page?
1741
+ *
1742
+ * Eg http://example.com/members/joe/blogs/friends/ (or a subpage thereof).
1743
+ *
1744
+ * @return bool True if the current page is a user's Friends page.
1745
+ */
1746
  function bp_is_user_friends() {
1747
  if ( bp_is_user() && bp_is_friends_component() )
1748
  return true;
1750
  return false;
1751
  }
1752
 
1753
+ /**
1754
+ * Is the current page a user's Friend Requests page?
1755
+ *
1756
+ * Eg http://example.com/members/joe/friends/requests/.
1757
+ *
1758
+ * @return bool True if the current page is a user's Friends Requests page.
1759
+ */
1760
  function bp_is_user_friend_requests() {
1761
  if ( bp_is_user_friends() && bp_is_current_action( 'requests' ) )
1762
  return true;
1764
  return false;
1765
  }
1766
 
1767
+ /**
1768
+ * Is this a user's notifications page?
1769
+ *
1770
+ * Eg http://example.com/members/joe/notifications/ (or a subpage thereof).
1771
+ *
1772
+ * @since BuddyPress (1.9.0)
1773
+ *
1774
+ * @return bool True if the current page is a user's Notifications page.
1775
+ */
1776
+ function bp_is_user_notifications() {
1777
+ if ( bp_is_user() && bp_is_notifications_component() ) {
1778
+ return true;
1779
+ }
1780
+
1781
+ return false;
1782
+ }
1783
+
1784
  /**
1785
  * Is this a user's settings page?
1786
  *
1787
+ * Eg http://example.com/members/joe/settings/ (or a subpage thereof).
1788
  *
1789
+ * @return bool True if the current page is a user's Settings page.
1790
  */
1791
  function bp_is_user_settings() {
1792
  if ( bp_is_user() && bp_is_settings_component() )
1798
  /**
1799
  * Is this a user's General Settings page?
1800
  *
1801
+ * Eg http://example.com/members/joe/settings/general/.
 
1802
  *
1803
+ * @since BuddyPress (1.5.0)
1804
+ *
1805
+ * @return bool True if the current page is a user's General Settings page.
1806
  */
1807
  function bp_is_user_settings_general() {
1808
  if ( bp_is_user_settings() && bp_is_current_action( 'general' ) )
1814
  /**
1815
  * Is this a user's Notification Settings page?
1816
  *
1817
+ * Eg http://example.com/members/joe/settings/notifications/.
 
1818
  *
1819
+ * @since BuddyPress (1.5.0)
1820
+ *
1821
+ * @return bool True if the current page is a user's Notification Settings page.
1822
  */
1823
  function bp_is_user_settings_notifications() {
1824
  if ( bp_is_user_settings() && bp_is_current_action( 'notifications' ) )
1830
  /**
1831
  * Is this a user's Account Deletion page?
1832
  *
1833
+ * Eg http://example.com/members/joe/settings/delete-account/.
 
1834
  *
1835
+ * @since BuddyPress (1.5.0)
1836
+ *
1837
+ * @return bool True if the current page is a user's Delete Account page.
1838
  */
1839
  function bp_is_user_settings_account_delete() {
1840
  if ( bp_is_user_settings() && bp_is_current_action( 'delete-account' ) )
1843
  return false;
1844
  }
1845
 
1846
+ /** Groups ********************************************************************/
1847
 
1848
+ /**
1849
+ * Does the current page belong to a single group?
1850
+ *
1851
+ * Will return true for any subpage of a single group.
1852
+ *
1853
+ * @return bool True if the current page is part of a single group.
1854
+ */
1855
  function bp_is_group() {
1856
  global $bp;
1857
 
1861
  return false;
1862
  }
1863
 
1864
+ /**
1865
+ * Is the current page a single group's home page?
1866
+ *
1867
+ * URL will vary depending on which group tab is set to be the "home". By
1868
+ * default, it's the group's recent activity.
1869
+ *
1870
+ * @return bool True if the current page is a single group's home page.
1871
+ */
1872
  function bp_is_group_home() {
1873
  if ( bp_is_single_item() && bp_is_groups_component() && ( !bp_current_action() || bp_is_current_action( 'home' ) ) )
1874
  return true;
1876
  return false;
1877
  }
1878
 
1879
+ /**
1880
+ * Is the current page part of the group creation process?
1881
+ *
1882
+ * @return bool True if the current page is part of the group creation process.
1883
+ */
1884
  function bp_is_group_create() {
1885
  if ( bp_is_groups_component() && bp_is_current_action( 'create' ) )
1886
  return true;
1888
  return false;
1889
  }
1890
 
1891
+ /**
1892
+ * Is the current page part of a single group's admin screens?
1893
+ *
1894
+ * Eg http://example.com/groups/mygroup/admin/settings/.
1895
+ *
1896
+ * @return bool True if the current page is part of a single group's admin.
1897
+ */
1898
  function bp_is_group_admin_page() {
1899
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) )
1900
  return true;
1902
  return false;
1903
  }
1904
 
1905
+ /**
1906
+ * Is the current page a group's forum page?
1907
+ *
1908
+ * Only applies to legacy bbPress forums.
1909
+ *
1910
+ * @return bool True if the current page is a group forum page.
1911
+ */
1912
  function bp_is_group_forum() {
1913
  $retval = false;
1914
 
1926
  return $retval;
1927
  }
1928
 
1929
+ /**
1930
+ * Is the current page a group's activity page?
1931
+ *
1932
+ * @return True if the current page is a group's activity page.
1933
+ */
1934
  function bp_is_group_activity() {
1935
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) )
1936
  return true;
1938
  return false;
1939
  }
1940
 
1941
+ /**
1942
+ * Is the current page a group forum topic?
1943
+ *
1944
+ * Only applies to legacy bbPress (1.x) forums.
1945
+ *
1946
+ * @return bool True if the current page is part of a group forum topic.
1947
+ */
1948
  function bp_is_group_forum_topic() {
1949
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) )
1950
  return true;
1952
  return false;
1953
  }
1954
 
1955
+ /**
1956
+ * Is the current page a group forum topic edit page?
1957
+ *
1958
+ * Only applies to legacy bbPress (1.x) forums.
1959
+ *
1960
+ * @return bool True if the current page is part of a group forum topic edit page.
1961
+ */
1962
  function bp_is_group_forum_topic_edit() {
1963
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_is_action_variable( 'edit', 2 ) )
1964
  return true;
1966
  return false;
1967
  }
1968
 
1969
+ /**
1970
+ * Is the current page a group's Members page?
1971
+ *
1972
+ * Eg http://example.com/groups/mygroup/members/.
1973
+ *
1974
+ * @return bool True if the current page is part of a group's Members page.
1975
+ */
1976
  function bp_is_group_members() {
1977
  if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) )
1978
  return true;
1980
  return false;
1981
  }
1982
 
1983
+ /**
1984
+ * Is the current page a group's Invites page?
1985
+ *
1986
+ * Eg http://example.com/groups/mygroup/send-invites/.
1987
+ *
1988
+ * @return bool True if the current page is a group's Send Invites page.
1989
+ */
1990
  function bp_is_group_invites() {
1991
  if ( bp_is_groups_component() && bp_is_current_action( 'send-invites' ) )
1992
  return true;
1994
  return false;
1995
  }
1996
 
1997
+ /**
1998
+ * Is the current page a group's Request Membership page?
1999
+ *
2000
+ * Eg http://example.com/groups/mygroup/request-membership/.
2001
+ *
2002
+ * @return bool True if the current page is a group's Request Membership page.
2003
+ */
2004
  function bp_is_group_membership_request() {
2005
  if ( bp_is_groups_component() && bp_is_current_action( 'request-membership' ) )
2006
  return true;
2008
  return false;
2009
  }
2010
 
2011
+ /**
2012
+ * Is the current page a leave group attempt?
2013
+ *
2014
+ * @return bool True if the current page is a Leave Group attempt.
2015
+ */
2016
  function bp_is_group_leave() {
2017
 
2018
  if ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) )
2021
  return false;
2022
  }
2023
 
2024
+ /**
2025
+ * Is the current page part of a single group?
2026
+ *
2027
+ * Not currently used by BuddyPress.
2028
+ *
2029
+ * @todo How is this functionally different from bp_is_group()?
2030
+ *
2031
+ * @return bool True if the current page is part of a single group.
2032
+ */
2033
  function bp_is_group_single() {
2034
  if ( bp_is_groups_component() && bp_is_single_item() )
2035
  return true;
2037
  return false;
2038
  }
2039
 
2040
+ /**
2041
+ * Is the current page the Create a Blog page?
2042
+ *
2043
+ * Eg http://example.com/sites/create/.
2044
+ *
2045
+ * @return bool True if the current page is the Create a Blog page.
2046
+ */
2047
  function bp_is_create_blog() {
2048
  if ( bp_is_blogs_component() && bp_is_current_action( 'create' ) )
2049
  return true;
2053
 
2054
  /** Messages ******************************************************************/
2055
 
2056
+ /**
2057
+ * Is the current page part of a user's Messages pages?
2058
+ *
2059
+ * Eg http://example.com/members/joe/messages/ (or a subpage thereof).
2060
+ *
2061
+ * @return bool True if the current page is part of a user's Messages pages.
2062
+ */
2063
  function bp_is_user_messages() {
2064
  if ( bp_is_user() && bp_is_messages_component() )
2065
  return true;
2067
  return false;
2068
  }
2069
 
2070
+ /**
2071
+ * Is the current page a user's Messages Inbox?
2072
+ *
2073
+ * Eg http://example.com/members/joe/messages/inbox/.
2074
+ *
2075
+ * @return bool True if the current page is a user's Messages Inbox.
2076
+ */
2077
  function bp_is_messages_inbox() {
2078
  if ( bp_is_user_messages() && ( !bp_current_action() || bp_is_current_action( 'inbox' ) ) )
2079
  return true;
2081
  return false;
2082
  }
2083
 
2084
+ /**
2085
+ * Is the current page a user's Messages Sentbox?
2086
+ *
2087
+ * Eg http://example.com/members/joe/messages/sentbox/.
2088
+ *
2089
+ * @return bool True if the current page is a user's Messages Sentbox.
2090
+ */
2091
  function bp_is_messages_sentbox() {
2092
  if ( bp_is_user_messages() && bp_is_current_action( 'sentbox' ) )
2093
  return true;
2095
  return false;
2096
  }
2097
 
2098
+ /**
2099
+ * Is the current page a user's Messages Compose screen??
2100
+ *
2101
+ * Eg http://example.com/members/joe/messages/compose/.
2102
+ *
2103
+ * @return bool True if the current page is a user's Messages Compose screen.
2104
+ */
2105
  function bp_is_messages_compose_screen() {
2106
  if ( bp_is_user_messages() && bp_is_current_action( 'compose' ) )
2107
  return true;
2109
  return false;
2110
  }
2111
 
2112
+ /**
2113
+ * Is the current page the Notices screen?
2114
+ *
2115
+ * Eg http://example.com/members/joe/messages/notices/.
2116
+ *
2117
+ * @return bool True if the current page is the Notices screen.
2118
+ */
2119
  function bp_is_notices() {
2120
  if ( bp_is_user_messages() && bp_is_current_action( 'notices' ) )
2121
  return true;
2123
  return false;
2124
  }
2125
 
2126
+ /**
2127
+ * Is the current page a single Messages conversation thread?
2128
+ *
2129
+ * @return bool True if the current page a single Messages conversation thread?
2130
+ */
2131
  function bp_is_messages_conversation() {
2132
  if ( bp_is_user_messages() && ( bp_is_current_action( 'view' ) ) )
2133
  return true;
2135
  return false;
2136
  }
2137
 
2138
+ /**
2139
+ * Not currently used by BuddyPress.
2140
+ *
2141
+ * @return bool
2142
+ */
2143
  function bp_is_single( $component, $callback ) {
2144
  if ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) )
2145
  return true;
2149
 
2150
  /** Registration **************************************************************/
2151
 
2152
+ /**
2153
+ * Is the current page the Activate page?
2154
+ *
2155
+ * Eg http://example.com/activate/.
2156
+ *
2157
+ * @return bool True if the current page is the Activate page.
2158
+ */
2159
  function bp_is_activation_page() {
2160
  if ( bp_is_current_component( 'activate' ) )
2161
  return true;
2163
  return false;
2164
  }
2165
 
2166
+ /**
2167
+ * Is the current page the Register page?
2168
+ *
2169
+ * Eg http://example.com/register/.
2170
+ *
2171
+ * @return bool True if the current page is the Register page.
2172
+ */
2173
  function bp_is_register_page() {
2174
  if ( bp_is_current_component( 'register' ) )
2175
  return true;
2178
  }
2179
 
2180
  /**
2181
+ * Customize the body class, according to the currently displayed BP content.
2182
  *
2183
+ * Uses the above is_() functions to output a body class for each scenario.
 
2184
  *
2185
+ * @param array $wp_classes The body classes coming from WP.
2186
+ * @param array $custom_classes Classes that were passed to get_body_class().
2187
+ * @return array $classes The BP-adjusted body classes.
2188
  */
2189
  function bp_the_body_class() {
2190
  echo bp_get_the_body_class();
2383
  /**
2384
  * Sort BuddyPress nav menu items by their position property.
2385
  *
2386
+ * This is an internal convenience function and it will probably be removed in
2387
+ * a later release. Do not use.
2388
  *
2389
  * @access private
2390
+ * @since BuddyPress (1.7.0)
2391
+ *
2392
+ * @param array $a First item.
2393
+ * @param array $b Second item.
2394
+ * @return int Returns an integer less than, equal to, or greater than zero if
2395
+ * the first argument is considered to be respectively less than, equal to, or greater than the second.
2396
  */
2397
  function _bp_nav_menu_sort( $a, $b ) {
2398
  if ( $a["position"] == $b["position"] )
2406
  }
2407
 
2408
  /**
2409
+ * Get the items registered in the primary and secondary BuddyPress navigation menus.
2410
+ *
2411
+ * @since BuddyPress (1.7.0)
2412
  *
2413
+ * @return array A multidimensional array of all navigation items.
 
2414
  */
2415
  function bp_get_nav_menu_items() {
2416
  $menus = $selected_menus = array();
2484
  }
2485
 
2486
  /**
2487
+ * Display a navigation menu.
2488
+ *
2489
+ * @since BuddyPress (1.7.0)
2490
+ *
2491
+ * @param string|array $args {
2492
+ * An array of optional arguments.
2493
+ * @type string $after Text after the link text. Default: ''.
2494
+ * @type string $before Text before the link text. Default: ''.
2495
+ * @type string $container The name of the element to wrap the navigation
2496
+ * with. 'div' or 'nav'. Default: 'div'.
2497
+ * @type string $container_class The class that is applied to the container.
2498
+ * Default: 'menu-bp-container'.
2499
+ * @type string $container_id The ID that is applied to the container.
2500
+ * Default: ''.
2501
+ * @type int depth How many levels of the hierarchy are to be included. 0
2502
+ * means all. Default: 0.
2503
+ * @type bool $echo True to echo the menu, false to return it.
2504
+ * Default: true.
2505
+ * @type bool $fallback_cb If the menu doesn't exist, should a callback
2506
+ * function be fired? Default: false (no fallback).
2507
+ * @type string $items_wrap How the list items should be wrapped. Should be
2508
+ * in the form of a printf()-friendly string, using numbered
2509
+ * placeholders. Default: '<ul id="%1$s" class="%2$s">%3$s</ul>'.
2510
+ * @type string $link_after Text after the link. Default: ''.
2511
+ * @type string $link_before Text before the link. Default: ''.
2512
+ * @type string $menu_class CSS class to use for the <ul> element which
2513
+ * forms the menu. Default: 'menu'.
2514
+ * @type string $menu_id The ID that is applied to the <ul> element which
2515
+ * forms the menu. Default: 'menu-bp', incremented.
2516
+ * @type string $walker Allows a custom walker class to be specified.
2517
+ * Default: 'BP_Walker_Nav_Menu'.
2518
+ * }
2519
+ * @return string|null If $echo is false, returns a string containing the nav
2520
+ * menu markup.
2521
  */
2522
  function bp_nav_menu( $args = array() ) {
2523
  static $menu_id_slugs = array();
bp-core/bp-core-theme-compatibility.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Core Theme Compatibility
5
  *
6
  * @package BuddyPress
7
  * @subpackage ThemeCompatibility
@@ -25,27 +25,33 @@ if ( !defined( 'ABSPATH' ) ) exit;
25
  /** Base Class ****************************************************************/
26
 
27
  /**
28
- * Theme Compatibility base class
29
  *
30
  * This is only intended to be extended, and is included here as a basic guide
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)
35
- * @todo We should probably do something similar to BP_Component::start()
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  */
37
  class BP_Theme_Compat {
38
 
39
  /**
40
- * Should be like:
41
  *
42
- * array(
43
- * 'id' => ID of the theme (should be unique)
44
- * 'name' => Name of the theme (should match style.css)
45
- * 'version' => Theme version for cache busting scripts and styling
46
- * 'dir' => Path to theme
47
- * 'url' => URL to theme
48
- * );
49
  * @var array
50
  */
51
  protected $_data = array();
@@ -53,42 +59,23 @@ class BP_Theme_Compat {
53
  /**
54
  * Pass the $properties to the object on creation.
55
  *
56
- * @since BuddyPress (1.7)
57
- * @param array $properties
58
  */
59
  public function __construct( Array $properties = array() ) {
60
  $this->_data = $properties;
61
  }
62
 
63
-
64
  /**
65
- * Themes shoud use this method in their constructor.
66
- *
67
- * In this method, we check all types of conditions where theme compatibility
68
- * should *not* run.
69
  *
70
- * If we pass all conditions, then we setup some additional methods to use.
71
  *
72
- * @since BuddyPress (1.7)
73
  */
74
  protected function start() {
75
-
76
- // If the theme supports 'buddypress', bail.
77
- if ( current_theme_supports( 'buddypress' ) ) {
78
  return;
79
-
80
- // If the theme doesn't support BP, do some additional checks
81
- } else {
82
- // Bail if theme is a derivative of bp-default
83
- if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
84
- return;
85
- }
86
-
87
- // Bruteforce check for a BP template
88
- // Examples are clones of bp-default
89
- if ( locate_template( 'members/members-loop.php', false, false ) ) {
90
- return;
91
- }
92
  }
93
 
94
  // Setup methods
@@ -97,26 +84,33 @@ class BP_Theme_Compat {
97
  }
98
 
99
  /**
100
- * Meant to be extended in your class.
 
 
 
101
  *
102
- * @since BuddyPress (1.7)
103
  */
104
  protected function setup_globals() {}
105
 
106
  /**
107
- * Meant to be extended in your class.
 
 
 
108
  *
109
- * @since BuddyPress (1.7)
110
  */
111
  protected function setup_actions() {}
112
 
113
  /**
114
  * Set a theme's property.
115
  *
116
- * @since BuddyPress (1.7)
117
- * @param string $property
118
- * @param mixed $value
119
- * @return mixed
 
120
  */
121
  public function __set( $property, $value ) {
122
  return $this->_data[$property] = $value;
@@ -125,10 +119,11 @@ class BP_Theme_Compat {
125
  /**
126
  * Get a theme's property.
127
  *
128
- * @since BuddyPress (1.7)
129
- * @param string $property
130
- * @param mixed $value
131
- * @return mixed
 
132
  */
133
  public function __get( $property ) {
134
  return array_key_exists( $property, $this->_data ) ? $this->_data[$property] : '';
@@ -138,10 +133,11 @@ class BP_Theme_Compat {
138
  /** Functions *****************************************************************/
139
 
140
  /**
141
- * Setup the default theme compat theme
142
  *
143
- * @since BuddyPress (1.7)
144
- * @param BP_Theme_Compat $theme
 
145
  */
146
  function bp_setup_theme_compat( $theme = '' ) {
147
  $bp = buddypress();
@@ -156,80 +152,159 @@ function bp_setup_theme_compat( $theme = '' ) {
156
  }
157
 
158
  /**
159
- * Gets the name of the BuddyPress compatable theme used, in the event the
160
- * currently active WordPress theme does not explicitly support BuddyPress.
161
  * This can be filtered or set manually. Tricky theme authors can override the
162
  * default and include their own BuddyPress compatability layers for their themes.
163
  *
164
- * @since BuddyPress (1.7)
 
165
  * @uses apply_filters()
166
- * @return string
 
167
  */
168
  function bp_get_theme_compat_id() {
169
  return apply_filters( 'bp_get_theme_compat_id', buddypress()->theme_compat->theme->id );
170
  }
171
 
172
  /**
173
- * Gets the name of the BuddyPress compatable theme used, in the event the
174
- * currently active WordPress theme does not explicitly support BuddyPress.
175
  * This can be filtered or set manually. Tricky theme authors can override the
176
  * default and include their own BuddyPress compatability layers for their themes.
177
  *
178
- * @since BuddyPress (1.7)
 
179
  * @uses apply_filters()
180
- * @return string
 
181
  */
182
  function bp_get_theme_compat_name() {
183
  return apply_filters( 'bp_get_theme_compat_name', buddypress()->theme_compat->theme->name );
184
  }
185
 
186
  /**
187
- * Gets the version of the BuddyPress compatable theme used, in the event the
188
- * currently active WordPress theme does not explicitly support BuddyPress.
189
  * This can be filtered or set manually. Tricky theme authors can override the
190
  * default and include their own BuddyPress compatability layers for their themes.
191
  *
192
- * @since BuddyPress (1.7)
 
193
  * @uses apply_filters()
194
- * @return string
 
195
  */
196
  function bp_get_theme_compat_version() {
197
  return apply_filters( 'bp_get_theme_compat_version', buddypress()->theme_compat->theme->version );
198
  }
199
 
200
  /**
201
- * Gets the BuddyPress compatable theme used in the event the currently active
202
- * WordPress theme does not explicitly support BuddyPress. This can be filtered,
203
  * or set manually. Tricky theme authors can override the default and include
204
  * their own BuddyPress compatability layers for their themes.
205
  *
206
- * @since BuddyPress (1.7)
 
207
  * @uses apply_filters()
208
- * @return string
 
209
  */
210
  function bp_get_theme_compat_dir() {
211
  return apply_filters( 'bp_get_theme_compat_dir', buddypress()->theme_compat->theme->dir );
212
  }
213
 
214
  /**
215
- * Gets the BuddyPress compatable theme used in the event the currently active
216
- * WordPress theme does not explicitly support BuddyPress. This can be filtered,
217
- * or set manually. Tricky theme authors can override the default and include
218
- * their own BuddyPress compatability layers for their themes.
 
 
 
219
  *
220
- * @since BuddyPress (1.7)
221
  * @uses apply_filters()
222
- * @return string
 
223
  */
224
  function bp_get_theme_compat_url() {
225
  return apply_filters( 'bp_get_theme_compat_url', buddypress()->theme_compat->theme->url );
226
  }
227
 
228
  /**
229
- * Gets true/false if the current, loaded page uses theme compatibility
230
  *
231
- * @since BuddyPress (1.7)
232
- * @return bool
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  */
234
  function bp_is_theme_compat_active() {
235
  $bp = buddypress();
@@ -241,11 +316,12 @@ function bp_is_theme_compat_active() {
241
  }
242
 
243
  /**
244
- * Sets true/false if page is currently inside theme compatibility
245
  *
246
- * @since BuddyPress (1.7)
247
- * @param bool $set
248
- * @return bool
 
249
  */
250
  function bp_set_theme_compat_active( $set = true ) {
251
  buddypress()->theme_compat->active = $set;
@@ -254,12 +330,15 @@ function bp_set_theme_compat_active( $set = true ) {
254
  }
255
 
256
  /**
257
- * Set the theme compat templates global
258
  *
259
  * Stash possible template files for the current query. Useful if plugins want
260
  * to override them, or see what files are being scanned for inclusion.
261
  *
262
- * @since BuddyPress (1.7)
 
 
 
263
  */
264
  function bp_set_theme_compat_templates( $templates = array() ) {
265
  buddypress()->theme_compat->templates = $templates;
@@ -268,12 +347,15 @@ function bp_set_theme_compat_templates( $templates = array() ) {
268
  }
269
 
270
  /**
271
- * Set the theme compat template global
272
  *
273
  * Stash the template file for the current query. Useful if plugins want
274
  * to override it, or see what file is being included.
275
  *
276
- * @since BuddyPress (1.7)
 
 
 
277
  */
278
  function bp_set_theme_compat_template( $template = '' ) {
279
  buddypress()->theme_compat->template = $template;
@@ -282,12 +364,15 @@ function bp_set_theme_compat_template( $template = '' ) {
282
  }
283
 
284
  /**
285
- * Set the theme compat original_template global
286
  *
287
  * Stash the original template file for the current query. Useful for checking
288
  * if BuddyPress was able to find a more appropriate template.
289
  *
290
- * @since BuddyPress (1.7)
 
 
 
291
  */
292
  function bp_set_theme_compat_original_template( $template = '' ) {
293
  buddypress()->theme_compat->original_template = $template;
@@ -296,12 +381,13 @@ function bp_set_theme_compat_original_template( $template = '' ) {
296
  }
297
 
298
  /**
299
- * Set the theme compat original_template global
300
  *
301
- * Stash the original template file for the current query. Useful for checking
302
- * if BuddyPress was able to find a more appropriate template.
303
  *
304
- * @since BuddyPress (1.7)
 
 
305
  */
306
  function bp_is_theme_compat_original_template( $template = '' ) {
307
  $bp = buddypress();
@@ -313,23 +399,18 @@ function bp_is_theme_compat_original_template( $template = '' ) {
313
  }
314
 
315
  /**
316
- * Register a new BuddyPress theme package to the active theme packages array
317
- *
318
- * The $theme parameter is an array, which takes the following values:
319
- *
320
- * 'id' - ID for your theme package; should be alphanumeric only
321
- * 'name' - Name of your theme package
322
- * 'version' - Version of your theme package
323
- * 'dir' - Directory where your theme package resides
324
- * 'url' - URL where your theme package resides
325
  *
326
  * For an example of how this function is used, see:
327
  * {@link BuddyPress::register_theme_packages()}.
328
  *
329
  * @since BuddyPress (1.7)
330
  *
331
- * @param array $theme The theme package arguments. See phpDoc for more details.
 
 
332
  * @param bool $override If true, overrides whatever package is currently set.
 
333
  */
334
  function bp_register_theme_package( $theme = array(), $override = true ) {
335
 
@@ -354,13 +435,20 @@ function bp_register_theme_package( $theme = array(), $override = true ) {
354
  }
355
 
356
  /**
357
- * This fun little function fills up some WordPress globals with dummy data to
358
- * stop your average page template from complaining about it missing.
359
  *
360
- * @since BuddyPress (1.7)
361
- * @global WP_Query $wp_query
362
- * @global object $post
363
- * @param array $args
 
 
 
 
 
 
 
 
364
  */
365
  function bp_theme_compat_reset_post( $args = array() ) {
366
  global $wp_query, $post;
@@ -471,32 +559,38 @@ function bp_theme_compat_reset_post( $args = array() ) {
471
  }
472
 
473
  /**
474
- * Reset main query vars and filter 'the_content' to output a BuddyPress
475
- * template part as needed.
476
- *
477
- * @since BuddyPress (1.7)
478
- *
479
- * @param string $template
480
- * @uses bp_is_single_user() To check if page is single user
481
- * @uses bp_get_single_user_template() To get user template
482
- * @uses bp_is_single_user_edit() To check if page is single user edit
483
- * @uses bp_get_single_user_edit_template() To get user edit template
484
- * @uses bp_is_single_view() To check if page is single view
485
- * @uses bp_get_single_view_template() To get view template
486
- * @uses bp_is_forum_edit() To check if page is forum edit
487
- * @uses bp_get_forum_edit_template() To get forum edit template
488
- * @uses bp_is_topic_merge() To check if page is topic merge
489
- * @uses bp_get_topic_merge_template() To get topic merge template
490
- * @uses bp_is_topic_split() To check if page is topic split
491
- * @uses bp_get_topic_split_template() To get topic split template
492
- * @uses bp_is_topic_edit() To check if page is topic edit
493
- * @uses bp_get_topic_edit_template() To get topic edit template
494
- * @uses bp_is_reply_edit() To check if page is reply edit
495
- * @uses bp_get_reply_edit_template() To get reply edit template
496
- * @uses bp_set_theme_compat_template() To set the global theme compat template
 
497
  */
498
  function bp_template_include_theme_compat( $template = '' ) {
499
 
 
 
 
 
 
500
  /**
501
  * Use this action to execute code that will communicate to BuddyPress's
502
  * theme compatibility layer whether or not we're replacing the_content()
@@ -540,13 +634,16 @@ function bp_template_include_theme_compat( $template = '' ) {
540
  }
541
 
542
  /**
 
 
543
  * Replaces the_content() if the post_type being displayed is one that would
544
  * normally be handled by BuddyPress, but proper single page templates do not
545
  * exist in the currently active theme.
546
  *
547
- * @since BuddyPress (1.7)
548
- * @param string $content
549
- * @return string
 
550
  */
551
  function bp_replace_the_content( $content = '' ) {
552
 
@@ -579,10 +676,12 @@ function bp_replace_the_content( $content = '' ) {
579
  }
580
 
581
  /**
582
- * Are we replacing the_content
 
 
583
  *
584
- * @since BuddyPress (1.8)
585
- * @return bool
586
  */
587
  function bp_do_theme_compat() {
588
  return (bool) ( ! bp_is_template_included() && in_the_loop() && bp_is_theme_compat_active() );
@@ -591,15 +690,21 @@ function bp_do_theme_compat() {
591
  /** Filters *******************************************************************/
592
 
593
  /**
594
- * Removes all filters from a WordPress filter, and stashes them in the $bp
595
- * global in the event they need to be restored later.
 
 
 
 
596
  *
597
- * @since BuddyPress (1.7)
598
  * @global WP_filter $wp_filter
599
  * @global array $merged_filters
600
- * @param string $tag
601
- * @param int $priority
602
- * @return bool
 
 
 
603
  */
604
  function bp_remove_all_filters( $tag, $priority = false ) {
605
  global $wp_filter, $merged_filters;
@@ -643,15 +748,19 @@ function bp_remove_all_filters( $tag, $priority = false ) {
643
  }
644
 
645
  /**
646
- * Restores filters from the $bp global that were removed using
647
- * bp_remove_all_filters()
 
648
  *
649
- * @since BuddyPress (1.7)
650
  * @global WP_filter $wp_filter
651
  * @global array $merged_filters
652
- * @param string $tag
653
- * @param int $priority
654
- * @return bool
 
 
 
 
655
  */
656
  function bp_restore_all_filters( $tag, $priority = false ) {
657
  global $wp_filter, $merged_filters;
@@ -695,12 +804,13 @@ function bp_restore_all_filters( $tag, $priority = false ) {
695
  }
696
 
697
  /**
698
- * Force comments_status to 'closed' for BuddyPress post types
699
  *
700
- * @since BuddyPress (1.7)
701
- * @param bool $open True if open, false if closed
702
- * @param int $post_id ID of the post to check
703
- * @return bool True if open, false if closed
 
704
  */
705
  function bp_comments_open( $open, $post_id = 0 ) {
706
 
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Core Theme Compatibility.
5
  *
6
  * @package BuddyPress
7
  * @subpackage ThemeCompatibility
25
  /** Base Class ****************************************************************/
26
 
27
  /**
28
+ * Theme Compatibility base class.
29
  *
30
  * This is only intended to be extended, and is included here as a basic guide
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 {
51
 
52
  /**
53
+ * Template package properties, as passed to the constructor.
54
  *
 
 
 
 
 
 
 
55
  * @var array
56
  */
57
  protected $_data = array();
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;
66
  }
67
 
 
68
  /**
69
+ * Set up the BuddyPress-specific theme compat methods.
 
 
 
70
  *
71
+ * Themes shoud use this method in their constructor.
72
  *
73
+ * @since BuddyPress (1.7.0)
74
  */
75
  protected function start() {
76
+ // Sanity check
77
+ if ( ! bp_use_theme_compat_with_current_theme() ) {
 
78
  return;
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  // Setup methods
84
  }
85
 
86
  /**
87
+ * Set up global data for your template package.
88
+ *
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
 
96
  /**
97
+ * Set up theme hooks for your template package.
98
+ *
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 ) {
116
  return $this->_data[$property] = $value;
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] : '';
133
  /** Functions *****************************************************************/
134
 
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
  */
142
  function bp_setup_theme_compat( $theme = '' ) {
143
  $bp = buddypress();
152
  }
153
 
154
  /**
155
+ * Get the ID of the theme package being used.
156
+ *
157
  * This can be filtered or set manually. Tricky theme authors can override the
158
  * default and include their own BuddyPress compatability layers for their themes.
159
  *
160
+ * @since BuddyPress (1.7.0)
161
+ *
162
  * @uses apply_filters()
163
+ *
164
+ * @return string ID of the theme package in use.
165
  */
166
  function bp_get_theme_compat_id() {
167
  return apply_filters( 'bp_get_theme_compat_id', buddypress()->theme_compat->theme->id );
168
  }
169
 
170
  /**
171
+ * Get the name of the theme package being used.
172
+ *
173
  * This can be filtered or set manually. Tricky theme authors can override the
174
  * default and include their own BuddyPress compatability layers for their themes.
175
  *
176
+ * @since BuddyPress (1.7.0)
177
+ *
178
  * @uses apply_filters()
179
+ *
180
+ * @return string Name of the theme package currently in use.
181
  */
182
  function bp_get_theme_compat_name() {
183
  return apply_filters( 'bp_get_theme_compat_name', buddypress()->theme_compat->theme->name );
184
  }
185
 
186
  /**
187
+ * Get the version of the theme package being used.
188
+ *
189
  * This can be filtered or set manually. Tricky theme authors can override the
190
  * default and include their own BuddyPress compatability layers for their themes.
191
  *
192
+ * @since BuddyPress (1.7.0)
193
+ *
194
  * @uses apply_filters()
195
+ *
196
+ * @return string The version string of the theme package currently in use.
197
  */
198
  function bp_get_theme_compat_version() {
199
  return apply_filters( 'bp_get_theme_compat_version', buddypress()->theme_compat->theme->version );
200
  }
201
 
202
  /**
203
+ * Get the absolute path of the theme package being used.
204
+ *
205
  * or set manually. Tricky theme authors can override the default and include
206
  * their own BuddyPress compatability layers for their themes.
207
  *
208
+ * @since BuddyPress (1.7.0)
209
+ *
210
  * @uses apply_filters()
211
+ *
212
+ * @return string The absolute path of the theme package currently in use.
213
  */
214
  function bp_get_theme_compat_dir() {
215
  return apply_filters( 'bp_get_theme_compat_dir', buddypress()->theme_compat->theme->dir );
216
  }
217
 
218
  /**
219
+ * Get the URL of the theme package being used.
220
+ *
221
+ * This can be filtered, or set manually. Tricky theme authors can override
222
+ * the default and include their own BuddyPress compatability layers for their
223
+ * themes.
224
+ *
225
+ * @since BuddyPress (1.7.0)
226
  *
 
227
  * @uses apply_filters()
228
+ *
229
+ * @return string URL of the theme package currently in use.
230
  */
231
  function bp_get_theme_compat_url() {
232
  return apply_filters( 'bp_get_theme_compat_url', buddypress()->theme_compat->theme->url );
233
  }
234
 
235
  /**
236
+ * Should we use theme compat for this theme?
237
  *
238
+ * If the current theme's need for theme compat hasn't yet been detected, we
239
+ * do so using bp_detect_theme_compat_with_current_theme().
240
+ *
241
+ * @since BuddyPress (1.9.0)
242
+ *
243
+ * @uses bp_detect_theme_compat_with_current_theme()
244
+ *
245
+ * @return bool True if the current theme needs theme compatibility.
246
+ */
247
+ function bp_use_theme_compat_with_current_theme() {
248
+ if ( ! isset( buddypress()->theme_compat->use_with_current_theme ) ) {
249
+ bp_detect_theme_compat_with_current_theme();
250
+ }
251
+
252
+ return buddypress()->theme_compat->use_with_current_theme;
253
+ }
254
+
255
+ /**
256
+ * Set our flag to determine whether theme compat should be enabled.
257
+ *
258
+ * Theme compat is disabled when a theme meets one of the following criteria:
259
+ * 1) It declares BP support with add_theme_support( 'buddypress' )
260
+ * 2) It is bp-default, or a child theme of bp-default
261
+ * 3) A legacy template is found at members/members-loop.php. This is a
262
+ * fallback check for themes that were derived from bp-default, and have
263
+ * not been updated for BP 1.7+; we make the assumption that any theme in
264
+ * this category will have the members-loop.php template, and so use its
265
+ * presence as an indicator that theme compatibility is not required
266
+ *
267
+ * @since BuddyPress (1.9.0)
268
+ *
269
+ * @return bool True if the current theme needs theme compatibility.
270
+ */
271
+ function bp_detect_theme_compat_with_current_theme() {
272
+ if ( isset( buddypress()->theme_compat->use_with_current_theme ) ) {
273
+ return buddypress()->theme_compat->use_with_current_theme;
274
+ }
275
+
276
+ // theme compat enabled by default
277
+ $theme_compat = true;
278
+
279
+ // If the theme supports 'buddypress', bail.
280
+ if ( current_theme_supports( 'buddypress' ) ) {
281
+ $theme_compat = false;
282
+
283
+ // If the theme doesn't support BP, do some additional checks
284
+ } else {
285
+ // Bail if theme is a derivative of bp-default
286
+ if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
287
+ $theme_compat = false;
288
+
289
+ // Bruteforce check for a BP template
290
+ // Examples are clones of bp-default
291
+ } else if ( locate_template( 'members/members-loop.php', false, false ) ) {
292
+ $theme_compat = false;
293
+ }
294
+ }
295
+
296
+ // set a flag in the buddypress() singleton so we don't have to run this again
297
+ buddypress()->theme_compat->use_with_current_theme = $theme_compat;
298
+
299
+ return $theme_compat;
300
+ }
301
+
302
+ /**
303
+ * Is the current page using theme compatibility?
304
+ *
305
+ * @since BuddyPress (1.7.0)
306
+ *
307
+ * @return bool True if the current page uses theme compatibility.
308
  */
309
  function bp_is_theme_compat_active() {
310
  $bp = buddypress();
316
  }
317
 
318
  /**
319
+ * Set the flag that tells whether the current page is using theme compatibility.
320
  *
321
+ * @since BuddyPress (1.7.0)
322
+ *
323
+ * @param bool $set True to set the flag to true, false to set it to false.
324
+ * @return bool Returns the value of $set.
325
  */
326
  function bp_set_theme_compat_active( $set = true ) {
327
  buddypress()->theme_compat->active = $set;
330
  }
331
 
332
  /**
333
+ * Set the theme compat templates global.
334
  *
335
  * Stash possible template files for the current query. Useful if plugins want
336
  * to override them, or see what files are being scanned for inclusion.
337
  *
338
+ * @since BuddyPress (1.7.0)
339
+ *
340
+ * @param array $templates The template stack.
341
+ * @return array The template stack (value of $templates).
342
  */
343
  function bp_set_theme_compat_templates( $templates = array() ) {
344
  buddypress()->theme_compat->templates = $templates;
347
  }
348
 
349
  /**
350
+ * Set the theme compat template global.
351
  *
352
  * Stash the template file for the current query. Useful if plugins want
353
  * to override it, or see what file is being included.
354
  *
355
+ * @since BuddyPress (1.7.0)
356
+ *
357
+ * @param string $template The template currently in use.
358
+ * @return string The template currently in use (value of $template).
359
  */
360
  function bp_set_theme_compat_template( $template = '' ) {
361
  buddypress()->theme_compat->template = $template;
364
  }
365
 
366
  /**
367
+ * Set the theme compat original_template global.
368
  *
369
  * Stash the original template file for the current query. Useful for checking
370
  * if BuddyPress was able to find a more appropriate template.
371
  *
372
+ * @since BuddyPress (1.7.0)
373
+ *
374
+ * @param string $template The template originally selected by WP.
375
+ * @return string The template originally selected by WP (value of $template).
376
  */
377
  function bp_set_theme_compat_original_template( $template = '' ) {
378
  buddypress()->theme_compat->original_template = $template;
381
  }
382
 
383
  /**
384
+ * Check whether a given template is the one that WP originally selected to display current page.
385
  *
386
+ * @since BuddyPress (1.7.0)
 
387
  *
388
+ * @param string $template The template name to check.
389
+ * @return bool True if the value of $template is the same as the
390
+ * "original_template" originally selected by WP. Otherwise false.
391
  */
392
  function bp_is_theme_compat_original_template( $template = '' ) {
393
  $bp = buddypress();
399
  }
400
 
401
  /**
402
+ * Register a new BuddyPress theme package in the active theme packages array.
 
 
 
 
 
 
 
 
403
  *
404
  * For an example of how this function is used, see:
405
  * {@link BuddyPress::register_theme_packages()}.
406
  *
407
  * @since BuddyPress (1.7)
408
  *
409
+ * @see BP_Theme_Compat for a description of the $theme parameter arguments.
410
+ *
411
+ * @param array $theme See {@link BP_Theme_Compat}.
412
  * @param bool $override If true, overrides whatever package is currently set.
413
+ * Default: true.
414
  */
415
  function bp_register_theme_package( $theme = array(), $override = true ) {
416
 
435
  }
436
 
437
  /**
438
+ * Populate various WordPress globals with dummy data to prevent errors.
 
439
  *
440
+ * This dummy data is necessary because theme compatibility essentially fakes
441
+ * WordPress into thinking that there is content where, in fact, there is none
442
+ * (at least, no WordPress post content). By providing dummy data, we ensure
443
+ * that template functions - things like is_page() - don't throw errors.
444
+ *
445
+ * @since BuddyPress (1.7.0)
446
+ *
447
+ * @global WP_Query $wp_query WordPress database access object.
448
+ * @global object $post Current post object.
449
+ *
450
+ * @param array $args Array of optional arguments. Arguments parallel the
451
+ * properties of {@link WP_Post}; see that class for more details.
452
  */
453
  function bp_theme_compat_reset_post( $args = array() ) {
454
  global $wp_query, $post;
559
  }
560
 
561
  /**
562
+ * Reset main query vars and filter 'the_content' to output a BuddyPress template part as needed.
563
+ *
564
+ * @since BuddyPress (1.7.0)
565
+ *
566
+ * @uses bp_is_single_user() To check if page is single user.
567
+ * @uses bp_get_single_user_template() To get user template.
568
+ * @uses bp_is_single_user_edit() To check if page is single user edit.
569
+ * @uses bp_get_single_user_edit_template() To get user edit template.
570
+ * @uses bp_is_single_view() To check if page is single view.
571
+ * @uses bp_get_single_view_template() To get view template.
572
+ * @uses bp_is_forum_edit() To check if page is forum edit.
573
+ * @uses bp_get_forum_edit_template() To get forum edit template.
574
+ * @uses bp_is_topic_merge() To check if page is topic merge.
575
+ * @uses bp_get_topic_merge_template() To get topic merge template.
576
+ * @uses bp_is_topic_split() To check if page is topic split.
577
+ * @uses bp_get_topic_split_template() To get topic split template.
578
+ * @uses bp_is_topic_edit() To check if page is topic edit.
579
+ * @uses bp_get_topic_edit_template() To get topic edit template.
580
+ * @uses bp_is_reply_edit() To check if page is reply edit.
581
+ * @uses bp_get_reply_edit_template() To get reply edit template.
582
+ * @uses bp_set_theme_compat_template() To set the global theme compat template.
583
+ *
584
+ * @param string $template Template name.
585
+ * @return string $template Template name.
586
  */
587
  function bp_template_include_theme_compat( $template = '' ) {
588
 
589
+ // If the current theme doesn't need theme compat, bail at this point.
590
+ if ( ! bp_use_theme_compat_with_current_theme() ) {
591
+ return $template;
592
+ }
593
+
594
  /**
595
  * Use this action to execute code that will communicate to BuddyPress's
596
  * theme compatibility layer whether or not we're replacing the_content()
634
  }
635
 
636
  /**
637
+ * Conditionally replace 'the_content'.
638
+ *
639
  * Replaces the_content() if the post_type being displayed is one that would
640
  * normally be handled by BuddyPress, but proper single page templates do not
641
  * exist in the currently active theme.
642
  *
643
+ * @since BuddyPress (1.7.0)
644
+ *
645
+ * @param string $content Original post content.
646
+ * @return string $content Post content, potentially modified.
647
  */
648
  function bp_replace_the_content( $content = '' ) {
649
 
676
  }
677
 
678
  /**
679
+ * Are we currently replacing the_content?
680
+ *
681
+ * @since BuddyPress (1.8.0)
682
  *
683
+ * @return bool True if the_content is currently in the process of being
684
+ * filtered and replaced.
685
  */
686
  function bp_do_theme_compat() {
687
  return (bool) ( ! bp_is_template_included() && in_the_loop() && bp_is_theme_compat_active() );
690
  /** Filters *******************************************************************/
691
 
692
  /**
693
+ * Remove all filters from a WordPress filter hook.
694
+ *
695
+ * Removed filters are stashed in the $bp global, in case they need to be
696
+ * restored later.
697
+ *
698
+ * @since BuddyPress (1.7.0)
699
  *
 
700
  * @global WP_filter $wp_filter
701
  * @global array $merged_filters
702
+ *
703
+ * @param string $tag The filter tag to remove filters from.
704
+ * @param int $priority Optional. If present, only those callbacks attached
705
+ * at a given priority will be removed. Otherwise, all callbacks
706
+ * attached to the tag will be removed, regardless of priority.
707
+ * @return bool True on success.
708
  */
709
  function bp_remove_all_filters( $tag, $priority = false ) {
710
  global $wp_filter, $merged_filters;
748
  }
749
 
750
  /**
751
+ * Restore filters that were removed using bp_remove_all_filters().
752
+ *
753
+ * @since BuddyPress (1.7.0)
754
  *
 
755
  * @global WP_filter $wp_filter
756
  * @global array $merged_filters
757
+ *
758
+ * @param string $tag The tag to which filters should be restored.
759
+ * @param int $priority Optional. If present, only those filters that were
760
+ * originally attached to the tag with $priority will be restored.
761
+ * Otherwise, all available filters will be restored, regardless of
762
+ * priority.
763
+ * @return bool True on success.
764
  */
765
  function bp_restore_all_filters( $tag, $priority = false ) {
766
  global $wp_filter, $merged_filters;
804
  }
805
 
806
  /**
807
+ * Force comments_status to 'closed' for BuddyPress post types.
808
  *
809
+ * @since BuddyPress (1.7.0)
810
+ *
811
+ * @param bool $open True if open, false if closed.
812
+ * @param int $post_id ID of the post to check.
813
+ * @return bool True if open, false if closed.
814
  */
815
  function bp_comments_open( $open, $post_id = 0 ) {
816
 
bp-core/bp-core-update.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Updater
5
  *
6
  * @package BuddyPress
7
  * @subpackage Updater
@@ -11,26 +11,34 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * If there is no raw DB version, this is the first installation
15
  *
16
- * @since BuddyPress (1.7)
 
 
17
  *
18
  * @uses get_option()
19
- * @uses bp_get_db_version() To get BuddyPress's database version
20
- * @return bool True if update, False if not
 
21
  */
22
  function bp_is_install() {
23
  return ! bp_get_db_version_raw();
24
  }
25
 
26
  /**
27
- * Compare the BuddyPress version to the DB version to determine if updating
28
  *
29
- * @since BuddyPress (1.6)
 
 
 
 
30
  *
31
  * @uses get_option()
32
- * @uses bp_get_db_version() To get BuddyPress's database version
33
- * @return bool True if update, False if not
 
34
  */
35
  function bp_is_update() {
36
 
@@ -46,12 +54,13 @@ function bp_is_update() {
46
  }
47
 
48
  /**
49
- * Determine if BuddyPress is being activated
50
  *
51
- * @since BuddyPress (1.6)
52
  *
53
  * @uses buddypress()
54
- * @return bool True if activating BuddyPress, false if not
 
55
  */
56
  function bp_is_activation( $basename = '' ) {
57
  $bp = buddypress();
@@ -90,12 +99,13 @@ function bp_is_activation( $basename = '' ) {
90
  }
91
 
92
  /**
93
- * Determine if BuddyPress is being deactivated
94
  *
95
- * @since BuddyPress (1.6)
96
  *
97
  * @uses buddypress()
98
- * @return bool True if deactivating BuddyPress, false if not
 
99
  */
100
  function bp_is_deactivation( $basename = '' ) {
101
  $bp = buddypress();
@@ -134,22 +144,21 @@ function bp_is_deactivation( $basename = '' ) {
134
  }
135
 
136
  /**
137
- * Update the DB to the latest version
138
  *
139
- * @since BuddyPress (1.6)
140
  *
141
- * @uses update_option()
142
- * @uses bp_get_db_version() To get BuddyPress's database version
143
- * @uses bp_update_option() To update BuddyPress's database version
144
  */
145
  function bp_version_bump() {
146
  bp_update_option( '_bp_db_version', bp_get_db_version() );
147
  }
148
 
149
  /**
150
- * Setup the BuddyPress updater
151
  *
152
- * @since BuddyPress (1.6)
153
  */
154
  function bp_setup_updater() {
155
 
@@ -161,20 +170,30 @@ function bp_setup_updater() {
161
  }
162
 
163
  /**
 
 
164
  * BuddyPress's version updater looks at what the current database version is,
165
- * and runs whatever other code is needed.
 
166
  *
167
- * This is most-often used when the data schema changes, but should also be used
168
  * to correct issues with BuddyPress metadata silently on software update.
169
  *
170
- * @since BuddyPress (1.7)
171
  */
172
  function bp_version_updater() {
173
 
174
  // Get the raw database version
175
  $raw_db_version = (int) bp_get_db_version_raw();
176
 
177
- $default_components = apply_filters( 'bp_new_install_default_components', array( 'activity' => 1, 'members' => 1, 'xprofile' => 1, ) );
 
 
 
 
 
 
 
178
  require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-schema.php' );
179
 
180
  // Install BP schema and activate only Activity and XProfile
@@ -201,6 +220,11 @@ function bp_version_updater() {
201
  if ( $raw_db_version < 6067 ) {
202
  bp_update_to_1_6();
203
  }
 
 
 
 
 
204
  }
205
 
206
  /** All done! *************************************************************/
@@ -210,9 +234,11 @@ function bp_version_updater() {
210
  }
211
 
212
  /**
213
- * Database update methods based on version numbers
214
  *
215
- * @since BuddyPress (1.7)
 
 
216
  */
217
  function bp_update_to_1_5() {
218
 
@@ -226,9 +252,11 @@ function bp_update_to_1_5() {
226
  }
227
 
228
  /**
229
- * Database update methods based on version numbers
 
 
230
  *
231
- * @since BuddyPress (1.7)
232
  */
233
  function bp_update_to_1_6() {
234
 
@@ -246,13 +274,40 @@ function bp_update_to_1_6() {
246
  }
247
 
248
  /**
249
- * Redirect user to BuddyPress's What's New page on activation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  *
251
- * @since BuddyPress (1.7)
252
  *
253
- * @internal Used internally to redirect BuddyPress to the about page on activation
254
  *
255
- * @uses set_transient() To drop the activation transient for 30 seconds
256
  */
257
  function bp_add_activation_redirect() {
258
 
@@ -273,11 +328,13 @@ function bp_add_activation_redirect() {
273
  /** Activation Actions ********************************************************/
274
 
275
  /**
276
- * Runs on BuddyPress activation
277
  *
278
- * @since BuddyPress (1.6)
279
  *
280
- * @uses do_action() Calls 'bp_activation' hook
 
 
281
  */
282
  function bp_activation() {
283
 
@@ -292,11 +349,13 @@ function bp_activation() {
292
  }
293
 
294
  /**
295
- * Runs on BuddyPress deactivation
 
 
296
  *
297
- * @since BuddyPress (1.6)
298
  *
299
- * @uses do_action() Calls 'bp_deactivation' hook
300
  */
301
  function bp_deactivation() {
302
 
@@ -319,11 +378,13 @@ function bp_deactivation() {
319
  }
320
 
321
  /**
322
- * Runs when uninstalling BuddyPress
 
 
323
  *
324
- * @since BuddyPress (1.6)
325
  *
326
- * @uses do_action() Calls 'bp_uninstall' hook
327
  */
328
  function bp_uninstall() {
329
  do_action( 'bp_uninstall' );
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Updater.
5
  *
6
  * @package BuddyPress
7
  * @subpackage Updater
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
+ * Is this a fresh installation of BuddyPress?
15
  *
16
+ * If there is no raw DB version, we infer that this is the first installation.
17
+ *
18
+ * @since BuddyPress (1.7.0)
19
  *
20
  * @uses get_option()
21
+ * @uses bp_get_db_version() To get BuddyPress's database version.
22
+ *
23
+ * @return bool True if this is a fresh BP install, otherwise false.
24
  */
25
  function bp_is_install() {
26
  return ! bp_get_db_version_raw();
27
  }
28
 
29
  /**
30
+ * Is this a BuddyPress update?
31
  *
32
+ * Determined by comparing the registered BuddyPress version to the version
33
+ * number stored in the database. If the registered version is greater, it's
34
+ * an update.
35
+ *
36
+ * @since BuddyPress (1.6.0)
37
  *
38
  * @uses get_option()
39
+ * @uses bp_get_db_version() To get BuddyPress's database version.
40
+ *
41
+ * @return bool True if update, otherwise false.
42
  */
43
  function bp_is_update() {
44
 
54
  }
55
 
56
  /**
57
+ * Determine whether BuddyPress is in the process of being activated.
58
  *
59
+ * @since BuddyPress (1.6.0)
60
  *
61
  * @uses buddypress()
62
+ *
63
+ * @return bool True if activating BuddyPress, false if not.
64
  */
65
  function bp_is_activation( $basename = '' ) {
66
  $bp = buddypress();
99
  }
100
 
101
  /**
102
+ * Determine whether BuddyPress is in the process of being deactivated.
103
  *
104
+ * @since BuddyPress (1.6.0)
105
  *
106
  * @uses buddypress()
107
+ *
108
+ * @return bool True if deactivating BuddyPress, false if not.
109
  */
110
  function bp_is_deactivation( $basename = '' ) {
111
  $bp = buddypress();
144
  }
145
 
146
  /**
147
+ * Update the BP version stored in the database to the current version.
148
  *
149
+ * @since BuddyPress (1.6.0)
150
  *
151
+ * @uses bp_get_db_version() To get BuddyPress's database version.
152
+ * @uses bp_update_option() To update BuddyPress's database version.
 
153
  */
154
  function bp_version_bump() {
155
  bp_update_option( '_bp_db_version', bp_get_db_version() );
156
  }
157
 
158
  /**
159
+ * Set up the BuddyPress updater.
160
  *
161
+ * @since BuddyPress (1.6.0)
162
  */
163
  function bp_setup_updater() {
164
 
170
  }
171
 
172
  /**
173
+ * Initialize an update or installation of BuddyPress.
174
+ *
175
  * BuddyPress's version updater looks at what the current database version is,
176
+ * and runs whatever other code is needed - either the "update" or "install"
177
+ * code.
178
  *
179
+ * This is most often used when the data schema changes, but should also be used
180
  * to correct issues with BuddyPress metadata silently on software update.
181
  *
182
+ * @since BuddyPress (1.7.0)
183
  */
184
  function bp_version_updater() {
185
 
186
  // Get the raw database version
187
  $raw_db_version = (int) bp_get_db_version_raw();
188
 
189
+ $default_components = apply_filters( 'bp_new_install_default_components', array(
190
+ 'activity' => 1,
191
+ 'members' => 1,
192
+ 'settings' => 1,
193
+ 'xprofile' => 1,
194
+ 'notifications' => 1,
195
+ ) );
196
+
197
  require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-schema.php' );
198
 
199
  // Install BP schema and activate only Activity and XProfile
220
  if ( $raw_db_version < 6067 ) {
221
  bp_update_to_1_6();
222
  }
223
+
224
+ // 1.9
225
+ if ( $raw_db_version < 7553 ) {
226
+ bp_update_to_1_9();
227
+ }
228
  }
229
 
230
  /** All done! *************************************************************/
234
  }
235
 
236
  /**
237
+ * Remove unused metadata from database when upgrading from < 1.5.
238
  *
239
+ * Database update methods based on version numbers.
240
+ *
241
+ * @since BuddyPress (1.7.0)
242
  */
243
  function bp_update_to_1_5() {
244
 
252
  }
253
 
254
  /**
255
+ * Remove unused metadata from database when upgrading from < 1.6.
256
+ *
257
+ * Database update methods based on version numbers.
258
  *
259
+ * @since BuddyPress (1.7.0)
260
  */
261
  function bp_update_to_1_6() {
262
 
274
  }
275
 
276
  /**
277
+ * Add the notifications component to active components.
278
+ *
279
+ * Notifications was added in 1.9.0, and previous installations will already
280
+ * have the core notifications API active. We need to add the new Notifications
281
+ * component to the active components option to retain existing functionality.
282
+ *
283
+ * @since BuddyPress (1.9.0)
284
+ */
285
+ function bp_update_to_1_9() {
286
+
287
+ // Setup hardcoded keys
288
+ $active_components_key = 'bp-active-components';
289
+ $notifications_component_id = 'notifications';
290
+
291
+ // Get the active components
292
+ $active_components = bp_get_option( $active_components_key );
293
+
294
+ // Add notifications
295
+ if ( ! in_array( $notifications_component_id, $active_components ) ) {
296
+ $active_components[ $notifications_component_id ] = 1;
297
+ }
298
+
299
+ // Update the active components option
300
+ bp_update_option( $active_components_key, $active_components );
301
+ }
302
+
303
+ /**
304
+ * Redirect user to BP's What's New page on first page load after activation.
305
  *
306
+ * @since BuddyPress (1.7.0)
307
  *
308
+ * @internal Used internally to redirect BuddyPress to the about page on activation.
309
  *
310
+ * @uses set_transient() To drop the activation transient for 30 seconds.
311
  */
312
  function bp_add_activation_redirect() {
313
 
328
  /** Activation Actions ********************************************************/
329
 
330
  /**
331
+ * Fire activation hooks and events.
332
  *
333
+ * Runs on BuddyPress activation.
334
  *
335
+ * @since BuddyPress (1.6.0)
336
+ *
337
+ * @uses do_action() Calls 'bp_activation' hook.
338
  */
339
  function bp_activation() {
340
 
349
  }
350
 
351
  /**
352
+ * Fire deactivation hooks and events.
353
+ *
354
+ * Runs on BuddyPress deactivation.
355
  *
356
+ * @since BuddyPress (1.6.0)
357
  *
358
+ * @uses do_action() Calls 'bp_deactivation' hook.
359
  */
360
  function bp_deactivation() {
361
 
378
  }
379
 
380
  /**
381
+ * Fire uninstall hook.
382
+ *
383
+ * Runs when uninstalling BuddyPress.
384
  *
385
+ * @since BuddyPress (1.6.0)
386
  *
387
+ * @uses do_action() Calls 'bp_uninstall' hook.
388
  */
389
  function bp_uninstall() {
390
  do_action( 'bp_uninstall' );
bp-core/bp-core-widgets.php CHANGED
@@ -1,19 +1,152 @@
1
  <?php
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( !defined( 'ABSPATH' ) ) exit;
4
 
5
- /* Register widgets for the core component */
 
 
6
  function bp_core_register_widgets() {
 
7
  add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
8
  add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
9
  add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
10
  }
11
  add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
12
 
13
- /*** MEMBERS WIDGET *****************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  class BP_Core_Members_Widget extends WP_Widget {
16
 
 
 
 
17
  function __construct() {
18
  $widget_ops = array(
19
  'description' => __( 'A dynamic list of recently active, popular, and newest members', 'buddypress' ),
@@ -27,6 +160,14 @@ class BP_Core_Members_Widget extends WP_Widget {
27
  }
28
  }
29
 
 
 
 
 
 
 
 
 
30
  function widget( $args, $instance ) {
31
 
32
  extract( $args );
@@ -97,6 +238,13 @@ class BP_Core_Members_Widget extends WP_Widget {
97
  <?php
98
  }
99
 
 
 
 
 
 
 
 
100
  function update( $new_instance, $old_instance ) {
101
  $instance = $old_instance;
102
 
@@ -108,6 +256,11 @@ class BP_Core_Members_Widget extends WP_Widget {
108
  return $instance;
109
  }
110
 
 
 
 
 
 
111
  function form( $instance ) {
112
  $defaults = array(
113
  'title' => __( 'Members', 'buddypress' ),
@@ -147,6 +300,9 @@ class BP_Core_Members_Widget extends WP_Widget {
147
 
148
  class BP_Core_Whos_Online_Widget extends WP_Widget {
149
 
 
 
 
150
  function __construct() {
151
  $widget_ops = array(
152
  'description' => __( 'Avatars of users who are currently online', 'buddypress' ),
@@ -155,6 +311,14 @@ class BP_Core_Whos_Online_Widget extends WP_Widget {
155
  parent::__construct( false, $name = _x( "(BuddyPress) Who's Online", 'widget name', 'buddypress' ), $widget_ops );
156
  }
157
 
 
 
 
 
 
 
 
 
158
  function widget($args, $instance) {
159
 
160
  extract( $args );
@@ -186,6 +350,13 @@ class BP_Core_Whos_Online_Widget extends WP_Widget {
186
  <?php
187
  }
188
 
 
 
 
 
 
 
 
189
  function update( $new_instance, $old_instance ) {
190
  $instance = $old_instance;
191
  $instance['title'] = strip_tags( $new_instance['title'] );
@@ -194,6 +365,11 @@ class BP_Core_Whos_Online_Widget extends WP_Widget {
194
  return $instance;
195
  }
196
 
 
 
 
 
 
197
  function form( $instance ) {
198
  $defaults = array(
199
  'title' => __( "Who's Online", 'buddypress' ),
@@ -216,6 +392,9 @@ class BP_Core_Whos_Online_Widget extends WP_Widget {
216
 
217
  class BP_Core_Recently_Active_Widget extends WP_Widget {
218
 
 
 
 
219
  function __construct() {
220
  $widget_ops = array(
221
  'description' => __( 'Avatars of recently active members', 'buddypress' ),
@@ -224,6 +403,14 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
224
  parent::__construct( false, $name = _x( '(BuddyPress) Recently Active Members', 'widget name', 'buddypress' ), $widget_ops );
225
  }
226
 
 
 
 
 
 
 
 
 
227
  function widget( $args, $instance ) {
228
 
229
  extract( $args );
@@ -255,6 +442,13 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
255
  <?php
256
  }
257
 
 
 
 
 
 
 
 
258
  function update( $new_instance, $old_instance ) {
259
  $instance = $old_instance;
260
  $instance['title'] = strip_tags( $new_instance['title'] );
@@ -263,9 +457,14 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
263
  return $instance;
264
  }
265
 
 
 
 
 
 
266
  function form( $instance ) {
267
  $defaults = array(
268
- 'title' => 'Recently Active Members',
269
  'max_members' => 15
270
  );
271
  $instance = wp_parse_args( (array) $instance, $defaults );
@@ -281,8 +480,9 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
281
  }
282
  }
283
 
284
- /** Widget AJAX ******************/
285
-
 
286
  function bp_core_ajax_widget_members() {
287
 
288
  check_ajax_referer( 'bp_core_widget_members' );
1
  <?php
2
+ /**
3
+ * BuddyPress Core Component Widgets.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Core
7
+ */
8
+
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
+ /**
13
+ * Register bp-core widgets.
14
+ */
15
  function bp_core_register_widgets() {
16
+ add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Login_Widget");') );
17
  add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
18
  add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
19
  add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
20
  }
21
  add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
22
 
23
+ /**
24
+ * BuddyPress Login Widget.
25
+ *
26
+ * @since BuddyPress (1.9.0)
27
+ */
28
+ class BP_Core_Login_Widget extends WP_Widget {
29
+
30
+ /**
31
+ * Constructor method.
32
+ */
33
+ public function __construct() {
34
+ parent::__construct(
35
+ false,
36
+ _x( '(BuddyPress) Log In', 'Title of the login widget', 'buddypress' ),
37
+ array(
38
+ 'description' => __( 'Show a Log In form to logged-out visitors, and a Log Out link to those who are logged in.', 'buddypress' ),
39
+ 'classname' => 'widget_bp_core_login_widget buddypress widget',
40
+ )
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Display the login widget.
46
+ *
47
+ * @see WP_Widget::widget() for description of parameters.
48
+ *
49
+ * @param array $args Widget arguments.
50
+ * @param array $instance Widget settings, as saved by the user.
51
+ */
52
+ public function widget( $args, $instance ) {
53
+ $title = apply_filters( 'widget_title', $instance['title'] );
54
+
55
+ echo $args['before_widget'];
56
+
57
+ echo $args['before_title'] . esc_html( $title ) . $args['after_title']; ?>
58
+
59
+ <?php if ( is_user_logged_in() ) : ?>
60
+
61
+ <?php do_action( 'bp_before_login_widget_loggedin' ); ?>
62
+
63
+ <div class="bp-login-widget-user-avatar">
64
+ <a href="<?php echo bp_loggedin_user_domain(); ?>">
65
+ <?php bp_loggedin_user_avatar( 'type=thumb&width=50&height=50' ); ?>
66
+ </a>
67
+ </div>
68
+
69
+ <div class="bp-login-widget-user-links">
70
+ <div class="bp-login-widget-user-link"><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></div>
71
+ <div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( wp_guess_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div>
72
+ </div>
73
+
74
+ <?php do_action( 'bp_after_login_widget_loggedin' ); ?>
75
+
76
+ <?php else : ?>
77
+
78
+ <?php do_action( 'bp_before_login_widget_loggedout' ); ?>
79
+
80
+ <form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
81
+ <label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label>
82
+ <input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
83
+
84
+ <label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label>
85
+ <input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" />
86
+
87
+ <div class="forgetmenot"><label><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div>
88
+
89
+ <input type="submit" name="wp-submit" id="bp-login-widget-submit" value="<?php _e( 'Log In', 'buddypress' ); ?>" />
90
+
91
+ <?php if ( bp_get_signup_allowed() ) : ?>
92
 
93
+ <span class="bp-login-widget-register-link"><?php printf( __( '<a href="%s" title="Register for a new account">Register</a>', 'buddypress' ), bp_get_signup_page() ); ?></span>
94
+
95
+ <?php endif; ?>
96
+
97
+ </form>
98
+
99
+ <?php do_action( 'bp_after_login_widget_loggedout' ); ?>
100
+
101
+ <?php endif;
102
+
103
+ echo $args['after_widget'];
104
+ }
105
+
106
+ /**
107
+ * Update the login widget options.
108
+ *
109
+ * @param array $new_instance The new instance options.
110
+ * @param array $old_instance The old instance options.
111
+ * @return array $instance The parsed options to be saved.
112
+ */
113
+ public function update( $new_instance, $old_instance ) {
114
+ $instance = $old_instance;
115
+ $instance['title'] = strip_tags( $new_instance['title'] );
116
+ $instance['register'] = esc_url_raw( $new_instance['register'] );
117
+ $instance['lostpass'] = esc_url_raw( $new_instance['lostpass'] );
118
+
119
+ return $instance;
120
+ }
121
+
122
+ /**
123
+ * Output the login widget options form.
124
+ *
125
+ * @param $instance Settings for this widget.
126
+ */
127
+ public function form( $instance = array() ) {
128
+
129
+ $settings = wp_parse_args( $instance, array(
130
+ 'title' => '',
131
+ ) ); ?>
132
+
133
+ <p>
134
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'buddypress' ); ?>
135
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $settings['title'] ); ?>" /></label>
136
+ </p>
137
+
138
+ <?php
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Members Widget.
144
+ */
145
  class BP_Core_Members_Widget extends WP_Widget {
146
 
147
+ /**
148
+ * Constructor method.
149
+ */
150
  function __construct() {
151
  $widget_ops = array(
152
  'description' => __( 'A dynamic list of recently active, popular, and newest members', 'buddypress' ),
160
  }
161
  }
162
 
163
+ /**
164
+ * Display the Members widget.
165
+ *
166
+ * @see WP_Widget::widget() for description of parameters.
167
+ *
168
+ * @param array $args Widget arguments.
169
+ * @param array $instance Widget settings, as saved by the user.
170
+ */
171
  function widget( $args, $instance ) {
172
 
173
  extract( $args );
238
  <?php
239
  }
240
 
241
+ /**
242
+ * Update the Members widget options.
243
+ *
244
+ * @param array $new_instance The new instance options.
245
+ * @param array $old_instance The old instance options.
246
+ * @return array $instance The parsed options to be saved.
247
+ */
248
  function update( $new_instance, $old_instance ) {
249
  $instance = $old_instance;
250
 
256
  return $instance;
257
  }
258
 
259
+ /**
260
+ * Output the Members widget options form.
261
+ *
262
+ * @param $instance Settings for this widget.
263
+ */
264
  function form( $instance ) {
265
  $defaults = array(
266
  'title' => __( 'Members', 'buddypress' ),
300
 
301
  class BP_Core_Whos_Online_Widget extends WP_Widget {
302
 
303
+ /**
304
+ * Constructor method.
305
+ */
306
  function __construct() {
307
  $widget_ops = array(
308
  'description' => __( 'Avatars of users who are currently online', 'buddypress' ),
311
  parent::__construct( false, $name = _x( "(BuddyPress) Who's Online", 'widget name', 'buddypress' ), $widget_ops );
312
  }
313
 
314
+ /**
315
+ * Display the Who's Online widget.
316
+ *
317
+ * @see WP_Widget::widget() for description of parameters.
318
+ *
319
+ * @param array $args Widget arguments.
320
+ * @param array $instance Widget settings, as saved by the user.
321
+ */
322
  function widget($args, $instance) {
323
 
324
  extract( $args );
350
  <?php
351
  }
352
 
353
+ /**
354
+ * Update the Who's Online widget options.
355
+ *
356
+ * @param array $new_instance The new instance options.
357
+ * @param array $old_instance The old instance options.
358
+ * @return array $instance The parsed options to be saved.
359
+ */
360
  function update( $new_instance, $old_instance ) {
361
  $instance = $old_instance;
362
  $instance['title'] = strip_tags( $new_instance['title'] );
365
  return $instance;
366
  }
367
 
368
+ /**
369
+ * Output the Who's Online widget options form.
370
+ *
371
+ * @param $instance Settings for this widget.
372
+ */
373
  function form( $instance ) {
374
  $defaults = array(
375
  'title' => __( "Who's Online", 'buddypress' ),
392
 
393
  class BP_Core_Recently_Active_Widget extends WP_Widget {
394
 
395
+ /**
396
+ * Constructor method.
397
+ */
398
  function __construct() {
399
  $widget_ops = array(
400
  'description' => __( 'Avatars of recently active members', 'buddypress' ),
403
  parent::__construct( false, $name = _x( '(BuddyPress) Recently Active Members', 'widget name', 'buddypress' ), $widget_ops );
404
  }
405
 
406
+ /**
407
+ * Display the Recently Active widget.
408
+ *
409
+ * @see WP_Widget::widget() for description of parameters.
410
+ *
411
+ * @param array $args Widget arguments.
412
+ * @param array $instance Widget settings, as saved by the user.
413
+ */
414
  function widget( $args, $instance ) {
415
 
416
  extract( $args );
442
  <?php
443
  }
444
 
445
+ /**
446
+ * Update the Recently Active widget options.
447
+ *
448
+ * @param array $new_instance The new instance options.
449
+ * @param array $old_instance The old instance options.
450
+ * @return array $instance The parsed options to be saved.
451
+ */
452
  function update( $new_instance, $old_instance ) {
453
  $instance = $old_instance;
454
  $instance['title'] = strip_tags( $new_instance['title'] );
457
  return $instance;
458
  }
459
 
460
+ /**
461
+ * Output the Recently Active widget options form.
462
+ *
463
+ * @param $instance Settings for this widget.
464
+ */
465
  function form( $instance ) {
466
  $defaults = array(
467
+ 'title' => __( 'Recently Active Members', 'buddypress' ),
468
  'max_members' => 15
469
  );
470
  $instance = wp_parse_args( (array) $instance, $defaults );
480
  }
481
  }
482
 
483
+ /**
484
+ * AJAX request handler for Members widgets.
485
+ */
486
  function bp_core_ajax_widget_members() {
487
 
488
  check_ajax_referer( 'bp_core_widget_members' );
bp-core/bp-core-wpabstraction.php CHANGED
@@ -1,22 +1,24 @@
1
  <?php
2
- /*****
3
- * WordPress Abstraction
4
  *
5
- * The functions within this file will detect the version of WordPress you are running
6
- * and will alter the environment so BuddyPress can run regardless.
7
  *
8
- * The code below mostly contains function mappings. This file is subject to change at any time.
 
9
  */
10
 
11
  // Exit if accessed directly
12
  if ( !defined( 'ABSPATH' ) ) exit;
13
 
14
  /**
15
- * Parse the WordPress core version number into the major release
16
  *
17
  * @since BuddyPress (1.5.2)
 
18
  * @global string $wp_version
19
- * @return string
20
  */
21
  function bp_get_major_wp_version() {
22
  global $wp_version;
@@ -34,48 +36,72 @@ if ( !is_multisite() ) {
34
  $wpdb->blogid = BP_ROOT_BLOG;
35
 
36
  if ( !function_exists( 'get_blog_option' ) ) {
 
 
 
37
  function get_blog_option( $blog_id, $option_name, $default = false ) {
38
  return get_option( $option_name, $default );
39
  }
40
  }
41
 
42
  if ( !function_exists( 'update_blog_option' ) ) {
 
 
 
43
  function update_blog_option( $blog_id, $option_name, $value ) {
44
  return update_option( $option_name, $value );
45
  }
46
  }
47
 
48
  if ( !function_exists( 'delete_blog_option' ) ) {
 
 
 
49
  function delete_blog_option( $blog_id, $option_name ) {
50
  return delete_option( $option_name );
51
  }
52
  }
53
 
54
  if ( !function_exists( 'switch_to_blog' ) ) {
 
 
 
55
  function switch_to_blog() {
56
  return bp_get_root_blog_id();
57
  }
58
  }
59
 
60
  if ( !function_exists( 'restore_current_blog' ) ) {
 
 
 
61
  function restore_current_blog() {
62
  return bp_get_root_blog_id();
63
  }
64
  }
65
 
66
  if ( !function_exists( 'get_blogs_of_user' ) ) {
 
 
 
67
  function get_blogs_of_user() {
68
  return false;
69
  }
70
  }
71
 
72
  if ( !function_exists( 'update_blog_status' ) ) {
 
 
 
73
  function update_blog_status() {
74
  return true;
75
  }
76
  }
77
 
78
  if ( !function_exists( 'is_subdomain_install' ) ) {
 
 
 
79
  function is_subdomain_install() {
80
  if ( ( defined( 'VHOST' ) && 'yes' == VHOST ) || ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) )
81
  return true;
@@ -85,6 +111,15 @@ if ( !is_multisite() ) {
85
  }
86
  }
87
 
 
 
 
 
 
 
 
 
 
88
  function bp_core_get_status_sql( $prefix = false ) {
89
  if ( !is_multisite() )
90
  return "{$prefix}user_status = 0";
@@ -102,10 +137,11 @@ function bp_core_get_status_sql( $prefix = false ) {
102
  */
103
  if ( !function_exists( 'mb_strlen' ) ) {
104
  /**
105
- * Fallback implementation of mb_strlen, hardcoded to UTF-8.
106
- * @param string $str
107
- * @param string $enc optional encoding; ignored
108
- * @return int
 
109
  */
110
  function mb_strlen( $str, $enc = '' ) {
111
  $counts = count_chars( $str );
@@ -126,12 +162,13 @@ if ( !function_exists( 'mb_strlen' ) ) {
126
 
127
  if ( !function_exists( 'mb_strpos' ) ) {
128
  /**
129
- * Fallback implementation of mb_strpos, hardcoded to UTF-8.
130
- * @param string $haystack
131
- * @param string $needle
132
- * @param int $offset optional; start position.
133
- * @param string $encoding optional; not used.
134
- * @return int
 
135
  */
136
  function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
137
  $needle = preg_quote( $needle, '/' );
@@ -149,12 +186,13 @@ if ( !function_exists( 'mb_strpos' ) ) {
149
 
150
  if ( !function_exists( 'mb_strrpos' ) ) {
151
  /**
152
- * Fallback implementation of mb_strrpos, hardcoded to UTF-8.
153
- * @param string $haystack
154
- * @param string $needle
155
- * @param int $offset optional; start position.
156
- * @param string $encoding optional; not used.
157
- * @return int
 
158
  */
159
  function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
160
  $needle = preg_quote( $needle, '/' );
1
  <?php
2
+ /**
3
+ * WordPress Abstraction.
4
  *
5
+ * The functions within this file will detect the version of WordPress you are
6
+ * running and will alter the environment so BuddyPress can run regardless.
7
  *
8
+ * The code below mostly contains function mappings. This file is subject to
9
+ * change at any time.
10
  */
11
 
12
  // Exit if accessed directly
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
+ * Parse the WordPress core version number into the major release.
17
  *
18
  * @since BuddyPress (1.5.2)
19
+ *
20
  * @global string $wp_version
21
+ * @return string $wp_version
22
  */
23
  function bp_get_major_wp_version() {
24
  global $wp_version;
36
  $wpdb->blogid = BP_ROOT_BLOG;
37
 
38
  if ( !function_exists( 'get_blog_option' ) ) {
39
+ /**
40
+ * @see get_blog_option()
41
+ */
42
  function get_blog_option( $blog_id, $option_name, $default = false ) {
43
  return get_option( $option_name, $default );
44
  }
45
  }
46
 
47
  if ( !function_exists( 'update_blog_option' ) ) {
48
+ /**
49
+ * @see update_blog_option()
50
+ */
51
  function update_blog_option( $blog_id, $option_name, $value ) {
52
  return update_option( $option_name, $value );
53
  }
54
  }
55
 
56
  if ( !function_exists( 'delete_blog_option' ) ) {
57
+ /**
58
+ * @see delete_blog_option()
59
+ */
60
  function delete_blog_option( $blog_id, $option_name ) {
61
  return delete_option( $option_name );
62
  }
63
  }
64
 
65
  if ( !function_exists( 'switch_to_blog' ) ) {
66
+ /**
67
+ * @see switch_to_blog()
68
+ */
69
  function switch_to_blog() {
70
  return bp_get_root_blog_id();
71
  }
72
  }
73
 
74
  if ( !function_exists( 'restore_current_blog' ) ) {
75
+ /**
76
+ * @see restore_current_blog()
77
+ */
78
  function restore_current_blog() {
79
  return bp_get_root_blog_id();
80
  }
81
  }
82
 
83
  if ( !function_exists( 'get_blogs_of_user' ) ) {
84
+ /**
85
+ * @see get_blogs_of_user()
86
+ */
87
  function get_blogs_of_user() {
88
  return false;
89
  }
90
  }
91
 
92
  if ( !function_exists( 'update_blog_status' ) ) {
93
+ /**
94
+ * @see update_blog_status()
95
+ */
96
  function update_blog_status() {
97
  return true;
98
  }
99
  }
100
 
101
  if ( !function_exists( 'is_subdomain_install' ) ) {
102
+ /**
103
+ * @see is_subdomain_install()
104
+ */
105
  function is_subdomain_install() {
106
  if ( ( defined( 'VHOST' ) && 'yes' == VHOST ) || ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) )
107
  return true;
111
  }
112
  }
113
 
114
+ /**
115
+ * Get SQL chunk for filtering spam users from member queries.
116
+ *
117
+ * @internal
118
+ * @todo Why is this function defined in this file?
119
+ *
120
+ * @param string $prefix Global table prefix.
121
+ * @return string SQL chunk.
122
+ */
123
  function bp_core_get_status_sql( $prefix = false ) {
124
  if ( !is_multisite() )
125
  return "{$prefix}user_status = 0";
137
  */
138
  if ( !function_exists( 'mb_strlen' ) ) {
139
  /**
140
+ * Fallback implementation of mb_strlen(), hardcoded to UTF-8.
141
+ *
142
+ * @param string $str String to be measured.
143
+ * @param string $enc Optional. Encoding type. Ignored.
144
+ * @return int String length.
145
  */
146
  function mb_strlen( $str, $enc = '' ) {
147
  $counts = count_chars( $str );
162
 
163
  if ( !function_exists( 'mb_strpos' ) ) {
164
  /**
165
+ * Fallback implementation of mb_strpos(), hardcoded to UTF-8.
166
+ *
167
+ * @param string $haystack String to search in.
168
+ * @param string $needle String to search for.
169
+ * @param int $offset Optional. Start position for the search. Default: 0.
170
+ * @param string $enc Optional. Encoding type. Ignored.
171
+ * @return int|bool Position of needle in haystack if found, else false.
172
  */
173
  function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
174
  $needle = preg_quote( $needle, '/' );
186
 
187
  if ( !function_exists( 'mb_strrpos' ) ) {
188
  /**
189
+ * Fallback implementation of mb_strrpos(), hardcoded to UTF-8.
190
+ *
191
+ * @param string $haystack String to search in.
192
+ * @param string $needle String to search for.
193
+ * @param int $offset Optional. Start position for the search. Default: 0.
194
+ * @param string $enc Optional. Encoding type. Ignored.
195
+ * @return int Position of last needle in haystack if found, else false.
196
  */
197
  function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
198
  $needle = preg_quote( $needle, '/' );
bp-core/deprecated/1.2.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  /**
4
  * Retrieve sitewide activity
1
  <?php
2
+ /**
3
+ * Deprecated Functions
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Core
7
+ */
8
 
9
  /**
10
  * Retrieve sitewide activity
bp-forums/bp-forums-actions.php CHANGED
@@ -1,3 +1,10 @@
1
  <?php
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( !defined( 'ABSPATH' ) ) exit;
1
  <?php
2
+ /**
3
+ * BuddyPress Forums Actions.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Forums
7
+ */
8
+
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
bp-forums/bp-forums-bbpress-sa.php CHANGED
@@ -1,7 +1,19 @@
1
  <?php
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( !defined( 'ABSPATH' ) ) exit;
4
 
 
 
 
 
 
5
  function bp_forums_load_bbpress() {
6
  global $bp, $wpdb, $wp_roles, $current_user, $wp_users_object;
7
  global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
@@ -114,9 +126,30 @@ function bp_forums_load_bbpress() {
114
  }
115
  add_action( 'bbpress_init', 'bp_forums_load_bbpress' );
116
 
117
- /* WP to bbP wrapper functions */
 
 
 
 
 
 
118
  function bb_get_current_user() { global $current_user; return $current_user; }
 
 
 
 
 
 
 
119
  function bb_get_user( $user_id ) { return get_userdata( $user_id ); }
 
 
 
 
 
 
 
 
120
  function bb_cache_users( $users ) {}
121
 
122
  /**
@@ -133,8 +166,7 @@ class BP_Forums_BB_Auth {
133
  }
134
 
135
  /**
136
- * bbPress needs the DB class to be BPDB, but we want to use WPDB, so we can
137
- * extend it and use this.
138
  *
139
  * The class is pluggable, so that plugins that swap out WPDB with a custom
140
  * database class (such as HyperDB and SharDB) can provide their own versions
@@ -144,6 +176,11 @@ if ( ! class_exists( 'BPDB' ) ) :
144
  class BPDB extends WPDB {
145
  var $db_servers = array();
146
 
 
 
 
 
 
147
  function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
148
  parent::__construct( $dbuser, $dbpassword, $dbname, $dbhost );
149
 
@@ -157,9 +194,19 @@ if ( ! class_exists( 'BPDB' ) ) :
157
  /**
158
  * Determine if a database supports a particular feature.
159
  *
160
- * Overriden here to work around differences between bbPress', and WordPress', implementation differences.
161
- * In particular, when BuddyPress tries to run bbPress' SQL installation script, the collation check always
162
- * failed. The capability is long supported by WordPress' minimum required MySQL version, so this is safe.
 
 
 
 
 
 
 
 
 
 
163
  */
164
  function has_cap( $db_cap, $_table_name='' ) {
165
  if ( 'collation' == $db_cap )
@@ -169,8 +216,12 @@ if ( ! class_exists( 'BPDB' ) ) :
169
  }
170
 
171
  /**
172
- * Initialises the class variables based on provided arguments.
173
- * Based on, and taken from, the BackPress class in turn taken from the 1.0 branch of bbPress.
 
 
 
 
174
  */
175
  function init( $args ) {
176
  if ( 4 == func_num_args() ) {
@@ -197,13 +248,29 @@ if ( ! class_exists( 'BPDB' ) ) :
197
  return wp_parse_args( $args, $defaults );
198
  }
199
 
 
 
 
 
 
 
 
 
 
200
  function escape_deep( $data ) {
201
  return $this->escape( $data );
202
  }
203
  }
204
  endif; // class_exists( 'BPDB' )
205
 
206
- /* BBPress needs this function to convert vars */
 
 
 
 
 
 
 
207
  function backpress_convert_object( &$object, $output ) {
208
  if ( is_array( $object ) ) {
209
  foreach ( array_keys( $object ) as $key )
@@ -218,12 +285,16 @@ function backpress_convert_object( &$object, $output ) {
218
  }
219
 
220
  /**
 
 
221
  * Copied from wp-admin/includes/upgrade.php, this will take care of creating
222
  * the bbPress stand-alone tables without loading a conflicting WP Admin.
223
  *
224
- * @param array $queries
225
- * @param bool $execute Optional; defaults to true.
226
- * @return array
 
 
227
  */
228
  function bp_bb_dbDelta($queries, $execute = true) {
229
  global $wpdb;
1
  <?php
2
+ /**
3
+ * BuddyPress bbPress 1.x integration.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Forums
7
+ */
8
+
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
+ /**
13
+ * Bootstrap bbPress 1.x, and manipulate globals to integrate with BuddyPress.
14
+ *
15
+ * @return bool|null Returns false on failure.
16
+ */
17
  function bp_forums_load_bbpress() {
18
  global $bp, $wpdb, $wp_roles, $current_user, $wp_users_object;
19
  global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
126
  }
127
  add_action( 'bbpress_init', 'bp_forums_load_bbpress' );
128
 
129
+ /** WP to bbPress wrapper functions ******************************************/
130
+
131
+ /**
132
+ * Get the current bbPress user.
133
+ *
134
+ * @return object $current_user Current user object from WordPress.
135
+ */
136
  function bb_get_current_user() { global $current_user; return $current_user; }
137
+
138
+ /**
139
+ * Get userdata for a bbPress user.
140
+ *
141
+ * @param int $user_id User ID.
142
+ * @return object User data from WordPress.
143
+ */
144
  function bb_get_user( $user_id ) { return get_userdata( $user_id ); }
145
+
146
+ /**
147
+ * Cache users.
148
+ *
149
+ * Noop.
150
+ *
151
+ * @param array $users
152
+ */
153
  function bb_cache_users( $users ) {}
154
 
155
  /**
166
  }
167
 
168
  /**
169
+ * bbPress needs the DB class to be BPDB, but we want to use WPDB, so we can extend it and use this.
 
170
  *
171
  * The class is pluggable, so that plugins that swap out WPDB with a custom
172
  * database class (such as HyperDB and SharDB) can provide their own versions
176
  class BPDB extends WPDB {
177
  var $db_servers = array();
178
 
179
+ /**
180
+ * Constructor
181
+ *
182
+ * @see WPDB::__construct() for description of parameters.
183
+ */
184
  function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
185
  parent::__construct( $dbuser, $dbpassword, $dbname, $dbhost );
186
 
194
  /**
195
  * Determine if a database supports a particular feature.
196
  *
197
+ * Overriden here to work around differences between bbPress's
198
+ * and WordPress's implementations. In particular, when
199
+ * BuddyPress tries to run bbPress' SQL installation script,
200
+ * the collation check always failed. The capability is long
201
+ * supported by WordPress' minimum required MySQL version, so
202
+ * this is safe.
203
+ *
204
+ * @see WPDB::has_cap() for a description of parameters and
205
+ * return values.
206
+ *
207
+ * @param string $db_cap See {@link WPDB::has_cap()}.
208
+ * @param string $_table_name See {@link WPDB::has_cap()}.
209
+ * @return bool See {@link WPDB::has_cap()}.
210
  */
211
  function has_cap( $db_cap, $_table_name='' ) {
212
  if ( 'collation' == $db_cap )
216
  }
217
 
218
  /**
219
+ * Initialize the class variables based on provided arguments.
220
+ *
221
+ * Based on, and taken from, the BackPress class in turn taken
222
+ * from the 1.0 branch of bbPress.
223
+ *
224
+ * @see BBDB::__construct() for a description of params.
225
  */
226
  function init( $args ) {
227
  if ( 4 == func_num_args() ) {
248
  return wp_parse_args( $args, $defaults );
249
  }
250
 
251
+ /**
252
+ * Stub for escape_deep() compatibility.
253
+ *
254
+ * @see WPDB::escape_deep() for description of parameters and
255
+ * return values.
256
+ *
257
+ * @param mixed $data See {@link WPDB::escape_deep()}.
258
+ * @return mixed $data See {@link WPDB::escape_deep()}.
259
+ */
260
  function escape_deep( $data ) {
261
  return $this->escape( $data );
262
  }
263
  }
264
  endif; // class_exists( 'BPDB' )
265
 
266
+ /**
267
+ * Convert object to given output format.
268
+ *
269
+ * bbPress needs this to convert vars.
270
+ *
271
+ * @param object $object Object to convert.
272
+ * @param string $output Type of object to return. OBJECT, ARRAY_A, or ARRAY_N.
273
+ */
274
  function backpress_convert_object( &$object, $output ) {
275
  if ( is_array( $object ) ) {
276
  foreach ( array_keys( $object ) as $key )
285
  }
286
 
287
  /**
288
+ * Parse and execute queries for updating a set of database tables.
289
+ *
290
  * Copied from wp-admin/includes/upgrade.php, this will take care of creating
291
  * the bbPress stand-alone tables without loading a conflicting WP Admin.
292
  *
293
+ * @see dbDelta() for a description of parameters and return value.
294
+ *
295
+ * @param array $queries See {@link dbDelta()}.
296
+ * @param bool $execute See {@link dbDelta()}.
297
+ * @return array See {@link dbDelta()}.
298
  */
299
  function bp_bb_dbDelta($queries, $execute = true) {
300
  global $wpdb;
bp-forums/bp-forums-filters.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( !defined( 'ABSPATH' ) ) exit;
4
 
@@ -47,6 +54,12 @@ add_filter( 'bp_get_the_topic_title', 'bp_forums_make_nofollow_filter' );
47
  add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_make_nofollow_filter' );
48
  add_filter( 'bp_get_the_topic_post_content', 'bp_forums_make_nofollow_filter' );
49
 
 
 
 
 
 
 
50
  function bp_forums_filter_kses( $content ) {
51
  global $allowedtags;
52
 
@@ -74,6 +87,15 @@ function bp_forums_filter_kses( $content ) {
74
  return wp_kses( $content, $forums_allowedtags );
75
  }
76
 
 
 
 
 
 
 
 
 
 
77
  function bp_forums_filter_tag_link( $link, $tag, $page, $context ) {
78
  global $bp;
79
 
@@ -81,9 +103,21 @@ function bp_forums_filter_tag_link( $link, $tag, $page, $context ) {
81
  }
82
  add_filter( 'bb_get_tag_link', 'bp_forums_filter_tag_link', 10, 4);
83
 
 
 
 
 
 
 
84
  function bp_forums_make_nofollow_filter( $text ) {
85
  return preg_replace_callback( '|<a (.+?)>|i', 'bp_forums_make_nofollow_filter_callback', $text );
86
  }
 
 
 
 
 
 
87
  function bp_forums_make_nofollow_filter_callback( $matches ) {
88
  $text = $matches[1];
89
  $text = str_replace( array( ' rel="nofollow"', " rel='nofollow'"), '', $text );
@@ -91,17 +125,17 @@ function bp_forums_make_nofollow_filter( $text ) {
91
  }
92
 
93
  /**
94
- * bp_forums_add_forum_topic_to_page_title( $title )
95
  *
96
- * Append forum topic to page title
97
  *
98
- * @global object $bp
99
- * @param string $title New page title; see bp_modify_page_title()
100
- * @param string $title Original page title
101
- * @param string $sep How to separate the various items within the page title.
102
- * @param string $seplocation Direction to display title
103
- * @return string
104
  * @see bp_modify_page_title()
 
 
 
 
 
 
105
  */
106
  function bp_forums_add_forum_topic_to_page_title( $title, $original_title, $sep, $seplocation ) {
107
  global $bp;
@@ -115,14 +149,14 @@ function bp_forums_add_forum_topic_to_page_title( $title, $original_title, $sep,
115
  add_filter( 'bp_modify_page_title', 'bp_forums_add_forum_topic_to_page_title', 9, 4 );
116
 
117
  /**
118
- * bp_forums_strip_mentions_on_post_edit( $title )
119
  *
120
- * Removes the anchor tag autogenerated for at-mentions when forum topics and posts are edited.
121
  * Prevents embedded anchor tags.
122
  *
123
- * @global object $bp
124
- * @param string $content
125
- * @return string $content
 
126
  */
127
  function bp_forums_strip_mentions_on_post_edit( $content ) {
128
  global $bp;
@@ -138,20 +172,17 @@ function bp_forums_strip_mentions_on_post_edit( $content ) {
138
  add_filter( 'bp_get_the_topic_post_edit_text', 'bp_forums_strip_mentions_on_post_edit' );
139
  add_filter( 'bp_get_the_topic_text', 'bp_forums_strip_mentions_on_post_edit' );
140
 
141
- /**
142
- * "REPLIED TO" SQL FILTERS
143
- */
144
 
145
  /**
146
- * Filters the get_topics_distinct portion of the Forums sql when on a user's Replied To page.
147
  *
148
- * This filter is added in bp_has_forum_topics()
149
  *
150
- * @package BuddyPress
151
- * @since BuddyPress (1.5)
152
  *
153
- * @param string $sql
154
- * @return string $sql
155
  */
156
  function bp_forums_add_replied_distinct_sql( $sql ) {
157
  $sql = "DISTINCT t.topic_id, ";
@@ -160,17 +191,16 @@ function bp_forums_add_replied_distinct_sql( $sql ) {
160
  }
161
 
162
  /**
163
- * Filters the get_topics_join portion of the Forums sql when on a user's Replied To page.
164
  *
165
- * This filter is added in bp_has_forum_topics()
166
  *
167
- * @package BuddyPress
168
- * @since BuddyPress (1.5)
169
  *
170
- * @global object $bbdb The bbPress database global
171
- * @global object $wpdb The WordPress database global
172
- * @param string $sql
173
- * @return string $sql
174
  */
175
  function bp_forums_add_replied_join_sql( $sql ) {
176
  global $bbdb;
@@ -181,16 +211,16 @@ function bp_forums_add_replied_join_sql( $sql ) {
181
  }
182
 
183
  /**
184
- * Filters the get_topics_where portion of the Forums sql when on a user's Replied To page.
185
  *
186
- * This filter is added in bp_has_forum_topics()
187
  *
188
- * @package BuddyPress
189
- * @since BuddyPress (1.5)
 
190
  *
191
- * @global object $wpdb The WordPress database global
192
- * @param string $sql
193
- * @return string $sql
194
  */
195
  function bp_forums_add_replied_where_sql( $sql ) {
196
  global $wpdb;
1
  <?php
2
+ /**
3
+ * BuddyPress Forums Filters.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Forums
7
+ */
8
+
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
54
  add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_make_nofollow_filter' );
55
  add_filter( 'bp_get_the_topic_post_content', 'bp_forums_make_nofollow_filter' );
56
 
57
+ /**
58
+ * Custom KSES filter for the Forums component.
59
+ *
60
+ * @param string $content Content to sanitize.
61
+ * @return string Sanitized string.
62
+ */
63
  function bp_forums_filter_kses( $content ) {
64
  global $allowedtags;
65
 
87
  return wp_kses( $content, $forums_allowedtags );
88
  }
89
 
90
+ /**
91
+ * Get a link for a forum topic tags directory.
92
+ *
93
+ * @param string $link Link passed from filter.
94
+ * @param string $tag Name of the tag.
95
+ * @param string $page Page number, passed from the filter.
96
+ * @param string $context Passed from the filter but unused here.
97
+ * @return string Link of the form http://example.com/forums/tag/tagname/.
98
+ */
99
  function bp_forums_filter_tag_link( $link, $tag, $page, $context ) {
100
  global $bp;
101
 
103
  }
104
  add_filter( 'bb_get_tag_link', 'bp_forums_filter_tag_link', 10, 4);
105
 
106
+ /**
107
+ * Add rel="nofollow" to bbPress content.
108
+ *
109
+ * @param string $text Post content.
110
+ * @return string Modified post content.
111
+ */
112
  function bp_forums_make_nofollow_filter( $text ) {
113
  return preg_replace_callback( '|<a (.+?)>|i', 'bp_forums_make_nofollow_filter_callback', $text );
114
  }
115
+ /**
116
+ * Callback for preg_replace_callback() in bp_forums_make_nofollow_filter().
117
+ *
118
+ * @param array $matches Regex matches from {@link bp_forums_make_nofollow_filter()}.
119
+ * @return string Text with nofollow links.
120
+ */
121
  function bp_forums_make_nofollow_filter_callback( $matches ) {
122
  $text = $matches[1];
123
  $text = str_replace( array( ' rel="nofollow"', " rel='nofollow'"), '', $text );
125
  }
126
 
127
  /**
128
+ * Append forum topic to page title.
129
  *
130
+ * @global object $bp Global BuddyPress settings object.
131
  *
 
 
 
 
 
 
132
  * @see bp_modify_page_title()
133
+ *
134
+ * @param string $title New page title; see {@link bp_modify_page_title()}.
135
+ * @param string $original_title Original page title.
136
+ * @param string $sep How to separate the various items within the page title.
137
+ * @param string $seplocation Direction to display title.
138
+ * @return string Page title with forum topic title appended.
139
  */
140
  function bp_forums_add_forum_topic_to_page_title( $title, $original_title, $sep, $seplocation ) {
141
  global $bp;
149
  add_filter( 'bp_modify_page_title', 'bp_forums_add_forum_topic_to_page_title', 9, 4 );
150
 
151
  /**
152
+ * Remove the anchor tag autogenerated for at-mentions when forum topics and posts are edited.
153
  *
 
154
  * Prevents embedded anchor tags.
155
  *
156
+ * @global object $bp Global BuddyPress settings object.
157
+ *
158
+ * @param string $content Edited post content.
159
+ * @return string $content Sanitized post content.
160
  */
161
  function bp_forums_strip_mentions_on_post_edit( $content ) {
162
  global $bp;
172
  add_filter( 'bp_get_the_topic_post_edit_text', 'bp_forums_strip_mentions_on_post_edit' );
173
  add_filter( 'bp_get_the_topic_text', 'bp_forums_strip_mentions_on_post_edit' );
174
 
175
+ /** "Replied to" SQL filters *************************************************/
 
 
176
 
177
  /**
178
+ * Filter the get_topics_distinct portion of the Forums SQL when on a user's Replied To page.
179
  *
180
+ * This filter is added in bp_has_forum_topics().
181
  *
182
+ * @since BuddyPress (1.5.0)
 
183
  *
184
+ * @param string $sql SQL fragment.
185
+ * @return string $sql SQL fragment of the form "DISTINCT t.topic_id, ".
186
  */
187
  function bp_forums_add_replied_distinct_sql( $sql ) {
188
  $sql = "DISTINCT t.topic_id, ";
191
  }
192
 
193
  /**
194
+ * Filter the get_topics_join portion of the Forums sql when on a user's Replied To page.
195
  *
196
+ * This filter is added in bp_has_forum_topics().
197
  *
198
+ * @since BuddyPress (1.5.0)
 
199
  *
200
+ * @global object $bbdb The bbPress database global.
201
+ *
202
+ * @param string $sql SQL statement.
203
+ * @return string $sql SQL statement.
204
  */
205
  function bp_forums_add_replied_join_sql( $sql ) {
206
  global $bbdb;
211
  }
212
 
213
  /**
214
+ * Filter the get_topics_where portion of the Forums sql when on a user's Replied To page.
215
  *
216
+ * This filter is added in bp_has_forum_topics().
217
  *
218
+ * @since BuddyPress (1.5.0)
219
+ *
220
+ * @global object $wpdb The WordPress database global.
221
  *
222
+ * @param string $sql SQL fragment.
223
+ * @return string $sql SQL fragment.
 
224
  */
225
  function bp_forums_add_replied_where_sql( $sql ) {
226
  global $wpdb;
bp-forums/bp-forums-functions.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  // Exit if accessed directly
4
  if ( !defined( 'ABSPATH' ) ) exit;
@@ -6,10 +12,11 @@ if ( !defined( 'ABSPATH' ) ) exit;
6
  /** bbPress 2.x ***************************************************************/
7
 
8
  /**
9
- * Used to see if bbPress 2.x is installed and active
10
  *
11
- * @since BuddyPress (1.6)
12
- * @return boolean True if bbPress 2.x is active, false if not
 
13
  */
14
  function bp_forums_is_bbpress_active() {
15
 
@@ -28,10 +35,14 @@ function bp_forums_is_bbpress_active() {
28
  /** bbPress 1.x ***************************************************************/
29
 
30
  /**
31
- * If the bb-config-location option exists, bbPress 1.x was previously installed
 
 
 
 
 
32
  *
33
- * @since BuddyPress (1.2)
34
- * @return boolean True if option exists, false if not
35
  */
36
  function bp_forums_is_installed_correctly() {
37
  $bp = buddypress();
@@ -43,12 +54,15 @@ function bp_forums_is_installed_correctly() {
43
  }
44
 
45
  /**
 
 
46
  * Checks $bp pages global and looks for directory page
47
  *
48
- * @since BuddyPress (1.5)
 
 
49
  *
50
- * @global BuddyPress $bp The one true BuddyPress instance
51
- * @return bool True if set, False if empty
52
  */
53
  function bp_forums_has_directory() {
54
  return (bool) !empty( buddypress()->pages->forums->id );
@@ -56,11 +70,35 @@ function bp_forums_has_directory() {
56
 
57
  /** Forum Functions ***********************************************************/
58
 
 
 
 
 
 
 
 
 
59
  function bp_forums_get_forum( $forum_id ) {
60
  do_action( 'bbpress_init' );
61
  return bb_get_forum( $forum_id );
62
  }
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  function bp_forums_new_forum( $args = '' ) {
65
  do_action( 'bbpress_init' );
66
 
@@ -76,6 +114,23 @@ function bp_forums_new_forum( $args = '' ) {
76
  return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  function bp_forums_update_forum( $args = '' ) {
80
  do_action( 'bbpress_init' );
81
 
@@ -93,6 +148,11 @@ function bp_forums_update_forum( $args = '' ) {
93
  return bb_update_forum( array( 'forum_id' => (int) $forum_id, 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_slug' => stripslashes( $forum_slug ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
94
  }
95
 
 
 
 
 
 
96
  function bp_forums_delete_group_forum( $group_id ) {
97
  $forum_id = groups_get_groupmeta( $group_id, 'forum_id' );
98
 
@@ -105,6 +165,28 @@ add_action( 'groups_delete_group', 'bp_forums_delete_group_forum' );
105
 
106
  /** Topic Functions ***********************************************************/
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  function bp_forums_get_forum_topics( $args = '' ) {
109
  do_action( 'bbpress_init' );
110
 
@@ -151,6 +233,12 @@ function bp_forums_get_forum_topics( $args = '' ) {
151
  return apply_filters_ref_array( 'bp_forums_get_forum_topics', array( &$topics, &$r ) );
152
  }
153
 
 
 
 
 
 
 
154
  function bp_forums_get_topic_details( $topic_id ) {
155
  do_action( 'bbpress_init' );
156
 
@@ -159,6 +247,14 @@ function bp_forums_get_topic_details( $topic_id ) {
159
  return $query->results[0];
160
  }
161
 
 
 
 
 
 
 
 
 
162
  function bp_forums_get_topic_id_from_slug( $topic_slug ) {
163
  do_action( 'bbpress_init' );
164
 
@@ -168,6 +264,34 @@ function bp_forums_get_topic_id_from_slug( $topic_slug ) {
168
  return bb_get_id_from_slug( 'topic', $topic_slug );
169
  }
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  function bp_forums_new_topic( $args = '' ) {
172
  global $bp;
173
 
@@ -215,6 +339,20 @@ function bp_forums_new_topic( $args = '' ) {
215
  return $topic_id;
216
  }
217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  function bp_forums_update_topic( $args = '' ) {
219
  do_action( 'bbpress_init' );
220
 
@@ -263,6 +401,16 @@ function bp_forums_sticky_topic( $args = '' ) {
263
  return false;
264
  }
265
 
 
 
 
 
 
 
 
 
 
 
266
  function bp_forums_openclose_topic( $args = '' ) {
267
  do_action( 'bbpress_init' );
268
 
@@ -280,6 +428,14 @@ function bp_forums_openclose_topic( $args = '' ) {
280
  return false;
281
  }
282
 
 
 
 
 
 
 
 
 
283
  function bp_forums_delete_topic( $args = '' ) {
284
  do_action( 'bbpress_init' );
285
 
@@ -291,6 +447,11 @@ function bp_forums_delete_topic( $args = '' ) {
291
  return bb_delete_topic( $topic_id, 1 );
292
  }
293
 
 
 
 
 
 
294
  function bp_forums_total_topic_count() {
295
  global $bbdb;
296
 
@@ -315,13 +476,15 @@ function bp_forums_total_topic_count() {
315
 
316
  /**
317
  * Check to see whether a user has already left this particular reply on a given post.
318
- * Prevents dupes.
319
  *
320
- * @since BuddyPress (1.6)
 
 
321
  *
322
- * @param string $text The text of the comment
323
- * @param int $topic_id The topic id
324
- * @param int $user_id The user id
 
325
  */
326
  function bp_forums_reply_exists( $text = '', $topic_id = 0, $user_id = 0 ) {
327
 
@@ -354,24 +517,26 @@ function bp_forums_reply_exists( $text = '', $topic_id = 0, $user_id = 0 ) {
354
  /**
355
  * Private one-time-use function used in conjunction with bp_forums_reply_exists()
356
  *
357
- * @since BuddyPress (1.7)
358
  * @access private
359
- * @global WPDB $wpdb
360
- * @param string $where
361
- * @return string
 
 
 
362
  */
363
  function _bp_forums_reply_exists_posts_where( $where = '' ) {
364
  return $where . " AND p.post_text = '" . buddypress()->forums->reply_exists_text . "'";
365
  }
366
 
367
  /**
368
- * Get a total "Topics Started" count for a given user
369
- *
370
- * @package BuddyPress
371
  *
372
- * @param int $user_id ID of the user being queried. Falls back on displayed user, then loggedin
373
- * @param string $type The current filter/sort type. 'active', 'popular', 'unreplied'
374
- * @return int $count The topic count
 
 
375
  */
376
  function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) {
377
  do_action( 'bbpress_init' );
@@ -401,15 +566,16 @@ function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' )
401
  }
402
 
403
  /**
404
- * Return the total number of topics replied to by a given user
405
  *
406
- * Uses an unfortunate technique to count unique topics, due to limitations in BB_Query.
 
407
  *
408
- * @package BuddyPress
409
- * @since BuddyPress (1.5)
410
  *
411
- * @param int $user_id Defaults to displayed user, then to logged-in user
412
- * @return int $count
 
413
  */
414
  function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active' ) {
415
  do_action( 'bbpress_init' );
@@ -446,6 +612,17 @@ function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active'
446
  return apply_filters( 'bp_forums_total_replied_count_for_user', $count, $user_id );
447
  }
448
 
 
 
 
 
 
 
 
 
 
 
 
449
  function bp_forums_get_topic_extras( $topics ) {
450
  global $wpdb, $bbdb;
451
 
@@ -503,6 +680,18 @@ function bp_forums_get_topic_extras( $topics ) {
503
 
504
  /** Post Functions ************************************************************/
505
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  function bp_forums_get_topic_posts( $args = '' ) {
507
  do_action( 'bbpress_init' );
508
 
@@ -519,11 +708,29 @@ function bp_forums_get_topic_posts( $args = '' ) {
519
  return bp_forums_get_post_extras( $query->results );
520
  }
521
 
 
 
 
 
 
 
 
 
522
  function bp_forums_get_post( $post_id ) {
523
  do_action( 'bbpress_init' );
524
  return bb_get_post( $post_id );
525
  }
526
 
 
 
 
 
 
 
 
 
 
 
527
  function bp_forums_delete_post( $args = '' ) {
528
  do_action( 'bbpress_init' );
529
 
@@ -536,6 +743,25 @@ function bp_forums_delete_post( $args = '' ) {
536
  return bb_delete_post( $post_id, 1 );
537
  }
538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
  function bp_forums_insert_post( $args = '' ) {
540
  do_action( 'bbpress_init' );
541
 
@@ -582,6 +808,16 @@ function bp_forums_insert_post( $args = '' ) {
582
  return $post_id;
583
  }
584
 
 
 
 
 
 
 
 
 
 
 
585
  function bp_forums_get_post_extras( $posts ) {
586
  global $bp, $wpdb;
587
 
@@ -620,6 +856,13 @@ function bp_forums_get_post_extras( $posts ) {
620
  return apply_filters( 'bp_forums_get_post_extras', $posts );
621
  }
622
 
 
 
 
 
 
 
 
623
  function bp_forums_get_forum_topicpost_count( $forum_id ) {
624
  global $wpdb, $bbdb;
625
 
@@ -629,6 +872,12 @@ function bp_forums_get_forum_topicpost_count( $forum_id ) {
629
  return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );
630
  }
631
 
 
 
 
 
 
 
632
  function bp_forums_filter_caps( $allcaps ) {
633
  global $wp_roles, $bb_table_prefix;
634
 
@@ -649,12 +898,11 @@ function bp_forums_filter_caps( $allcaps ) {
649
  add_filter( 'user_has_cap', 'bp_forums_filter_caps' );
650
 
651
  /**
652
- * Returns the parent forum id for the bbPress abstraction layer
653
  *
654
- * @package BuddyPress
655
- * @since BuddyPress (1.5)
656
  *
657
- * @return int
658
  */
659
  function bp_forums_parent_forum_id() {
660
  return apply_filters( 'bp_forums_parent_forum_id', BP_FORUMS_PARENT_FORUM_ID );
@@ -663,23 +911,22 @@ function bp_forums_parent_forum_id() {
663
  /**
664
  * Should sticky topics be broken out of regular topic order on forum directories?
665
  *
666
- * Defaults to false. Define BP_FORUMS_ENABLE_GLOBAL_DIRECTORY_STICKIES, or filter
667
- * bp_forums_enable_global_directory_stickies, to change this behavior.
668
  *
669
- * @package BuddyPress
670
- * @since BuddyPress (1.5)
671
  *
672
- * @return bool True if stickies should be displayed at the top of the global directory, false
673
- * otherwise.
674
  */
675
  function bp_forums_enable_global_directory_stickies() {
676
  return apply_filters( 'bp_forums_enable_global_directory_stickies', defined( 'BP_FORUMS_ENABLE_GLOBAL_DIRECTORY_STICKIES' ) && BP_FORUMS_ENABLE_GLOBAL_DIRECTORY_STICKIES );
677
  }
678
 
679
 
680
- /********************************************************************************
681
- * Caching
682
- *
683
  * Caching functions handle the clearing of cached objects and pages on specific
684
  * actions throughout BuddyPress.
685
  */
@@ -693,14 +940,16 @@ add_action( 'bp_forums_new_post', 'bp_core_clear_cache' );
693
  /** Embeds *******************************************************************/
694
 
695
  /**
 
 
696
  * Grabs the topic post ID and attempts to retrieve the oEmbed cache (if it exists)
697
  * during the forum topic loop. If no cache and link is embeddable, cache it.
698
  *
 
 
699
  * @see BP_Embed
700
  * @see bp_embed_forum_cache()
701
  * @see bp_embed_forum_save_cache()
702
- * @package BuddyPress_Forums
703
- * @since BuddyPress (1.5)
704
  */
705
  function bp_forums_embed() {
706
  add_filter( 'embed_post_id', 'bp_get_the_topic_post_id' );
@@ -710,9 +959,10 @@ function bp_forums_embed() {
710
  add_action( 'topic_loop_start', 'bp_forums_embed' );
711
 
712
  /**
713
- * Wrapper function for {@link bb_get_postmeta()}.
714
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_forums_embed()}.
715
  *
 
 
716
  * @package BuddyPress_Forums
717
  * @since BuddyPress (1.5)
718
  */
@@ -721,11 +971,11 @@ function bp_embed_forum_cache( $cache, $id, $cachekey ) {
721
  }
722
 
723
  /**
724
- * Wrapper function for {@link bb_update_postmeta()}.
725
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_forums_embed()}.
726
  *
727
- * @package BuddyPress_Forums
728
- * @since BuddyPress (1.5)
 
729
  */
730
  function bp_embed_forum_save_cache( $cache, $cachekey, $id ) {
731
  bb_update_postmeta( $id, $cachekey, $cache );
1
  <?php
2
+ /**
3
+ * BuddyPress Forums Functions.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Forums
7
+ */
8
 
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
12
  /** bbPress 2.x ***************************************************************/
13
 
14
  /**
15
+ * Is see bbPress 2.x is installed and active?
16
  *
17
+ * @since BuddyPress (1.6.0)
18
+ *
19
+ * @return boolean True if bbPress 2.x is active, false if not.
20
  */
21
  function bp_forums_is_bbpress_active() {
22
 
35
  /** bbPress 1.x ***************************************************************/
36
 
37
  /**
38
+ * See if bbPress 1.x is installed correctly.
39
+ *
40
+ * "Installed correctly" means that the bb-config-location option is set, and
41
+ * the referenced file exists.
42
+ *
43
+ * @since BuddyPress (1.2.0)
44
  *
45
+ * @return boolean True if option exists, false if not.
 
46
  */
47
  function bp_forums_is_installed_correctly() {
48
  $bp = buddypress();
54
  }
55
 
56
  /**
57
+ * Does the forums component have a directory page registered?
58
+ *
59
  * Checks $bp pages global and looks for directory page
60
  *
61
+ * @since BuddyPress (1.5.0)
62
+ *
63
+ * @global BuddyPress $bp The one true BuddyPress instance.
64
  *
65
+ * @return bool True if set, False if empty.
 
66
  */
67
  function bp_forums_has_directory() {
68
  return (bool) !empty( buddypress()->pages->forums->id );
70
 
71
  /** Forum Functions ***********************************************************/
72
 
73
+ /**
74
+ * Get a forum by ID.
75
+ *
76
+ * Wrapper for {@link bb_get_forum()}.
77
+ *
78
+ * @param int $forum_id ID of the forum being fetched.
79
+ * @return object bbPress forum object.
80
+ */
81
  function bp_forums_get_forum( $forum_id ) {
82
  do_action( 'bbpress_init' );
83
  return bb_get_forum( $forum_id );
84
  }
85
 
86
+ /**
87
+ * Create a forum.
88
+ *
89
+ * Wrapper for {@link bb_new_forum()}.
90
+ *
91
+ * @param array $args {
92
+ * Forum setup arguments.
93
+ * @type string $forum_name Name of the forum.
94
+ * @type string $forum_desc Description of the forum.
95
+ * @type int $forum_parent_id ID of the forum parent. Default: value of
96
+ * {@link bp_forums_parent_forums_id()}.
97
+ * @type bool $forum_order Order.
98
+ * @type int $forum_is_category Whether the forum is a category. Default: 0.
99
+ * }
100
+ * @return int ID of the newly created forum.
101
+ */
102
  function bp_forums_new_forum( $args = '' ) {
103
  do_action( 'bbpress_init' );
104
 
114
  return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
115
  }
116
 
117
+ /**
118
+ * Update a forum.
119
+ *
120
+ * Wrapper for {@link bb_update_forum(}.
121
+ *
122
+ * @param array $args {
123
+ * Forum setup arguments.
124
+ * @type int $forum_id ID of the forum to be updated.
125
+ * @type string $forum_name Name of the forum.
126
+ * @type string $forum_desc Description of the forum.
127
+ * @type int $forum_parent_id ID of the forum parent. Default: value of
128
+ * {@link bp_forums_parent_forums_id()}.
129
+ * @type bool $forum_order Order.
130
+ * @type int $forum_is_category Whether the forum is a category. Default: 0.
131
+ * }
132
+ * @return bool Ttrue on success, false on failure.
133
+ */
134
  function bp_forums_update_forum( $args = '' ) {
135
  do_action( 'bbpress_init' );
136
 
148
  return bb_update_forum( array( 'forum_id' => (int) $forum_id, 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_slug' => stripslashes( $forum_slug ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
149
  }
150
 
151
+ /**
152
+ * Delete a group forum by the group id.
153
+ *
154
+ * @param int $group_id ID of the group whose forum is to be deleted.
155
+ */
156
  function bp_forums_delete_group_forum( $group_id ) {
157
  $forum_id = groups_get_groupmeta( $group_id, 'forum_id' );
158
 
165
 
166
  /** Topic Functions ***********************************************************/
167
 
168
+ /**
169
+ * Fetch a set of forum topics.
170
+ *
171
+ * @param array $args {
172
+ * @type string @type Order or filter type. Default: 'newest'.
173
+ * @type int $forum_id Optional. Pass a forum ID to limit results to topics
174
+ * associated with that forum.
175
+ * @type int $user_id Optional. Pass a user ID to limit results to topics
176
+ * belonging to that user.
177
+ * @type int $page Optional. Number of the results page to return.
178
+ * Default: 1.
179
+ * @type int $per_page Optional. Number of results to return per page.
180
+ * Default: 15.
181
+ * @type int $offset Optional. Numeric offset for results.
182
+ * @type int $number
183
+ * @type array $exclude Optional. Topic IDs to exclude.
184
+ * @type string $show_stickies Whether to show sticky topics.
185
+ * @type mixed $filter If $type = 'tag', filter is the tag name. Otherwise,
186
+ * $filter is terms to search on.
187
+ * }
188
+ * @return array Found topics.
189
+ */
190
  function bp_forums_get_forum_topics( $args = '' ) {
191
  do_action( 'bbpress_init' );
192
 
233
  return apply_filters_ref_array( 'bp_forums_get_forum_topics', array( &$topics, &$r ) );
234
  }
235
 
236
+ /**
237
+ * Get additional details about a given forum topic.
238
+ *
239
+ * @param int $topic_id ID of the topic for which you're fetching details.
240
+ * @return object Details about the topic.
241
+ */
242
  function bp_forums_get_topic_details( $topic_id ) {
243
  do_action( 'bbpress_init' );
244
 
247
  return $query->results[0];
248
  }
249
 
250
+ /**
251
+ * Get the numeric ID of a topic from the topic slug.
252
+ *
253
+ * Wrapper for {@link bb_get_id_from_slug()}.
254
+ *
255
+ * @param string $topic_slug Slug of the topic.
256
+ * @return int|bool ID of the topic (if found), false on failure.
257
+ */
258
  function bp_forums_get_topic_id_from_slug( $topic_slug ) {
259
  do_action( 'bbpress_init' );
260
 
264
  return bb_get_id_from_slug( 'topic', $topic_slug );
265
  }
266
 
267
+ /**
268
+ * Create a new forum topic.
269
+ *
270
+ * @param array $args {
271
+ * @type string $topic_title Title of the new topic.
272
+ * @type string $topic_slug Slug of the new topic.
273
+ * @type string $topic_text Text of the new topic.
274
+ * @type int $topic_poster ID of the user posting the topic. Default: ID of
275
+ * the logged-in user.
276
+ * @type string $topic_poster_name Display name of the user posting the
277
+ * topic. Default: 'fullname' of the logged-in user.
278
+ * @type id $topic_last_poster ID of the user who last posted to the topic.
279
+ * Default: ID of the logged-in user.
280
+ * @type string $topic_last_poster_name Display name of the user who last
281
+ * posted to the topic. Default: 'fullname' of the logged-in user.
282
+ * @type string $topic_start_time Date/time when the topic was created.
283
+ * Default: the current time, as reported by bp_core_current_time().
284
+ * @type string $topic_time Date/time when the topic was created.
285
+ * Default: the current time, as reported by bp_core_current_time().
286
+ * @type int $topic_open Whether the topic is open. Default: 1 (open).
287
+ * @type array|string|bool $topic_tags Array or comma-separated list of
288
+ * topic tags. False to leave empty. Default: false.
289
+ * @type int $forum_id ID of the forum to which the topic belongs.
290
+ * Default: 0.
291
+ * }
292
+ * @return object Details about the new topic, as returned by
293
+ * {@link bp_forums_get_topic_details()}.
294
+ */
295
  function bp_forums_new_topic( $args = '' ) {
296
  global $bp;
297
 
339
  return $topic_id;
340
  }
341
 
342
+ /**
343
+ * Update a topic's details.
344
+ *
345
+ * @param array $args {
346
+ * Array of arguments.
347
+ * @type int $topic_id ID of the topic being updated.
348
+ * @type string $topic_title Updated title of the topic.
349
+ * @type string $topic_title Updated text of the topic.
350
+ * @type array|string|bool $topic_tags Array or comma-separated list of
351
+ * topic tags. False to leave empty. Default: false.
352
+ * }
353
+ * @return object Details about the new topic, as returned by
354
+ * {@link bp_forums_get_topic_details()}.
355
+ */
356
  function bp_forums_update_topic( $args = '' ) {
357
  do_action( 'bbpress_init' );
358
 
401
  return false;
402
  }
403
 
404
+ /**
405
+ * Set a topic's open/closed status.
406
+ *
407
+ * @param array $args {
408
+ * @type int $topic_id ID of the topic whose status is being changed.
409
+ * @type string $mode New status of the topic. 'open' or 'close'.
410
+ * Default: 'close'.
411
+ * }
412
+ * @return bool True on success, false on failure.
413
+ */
414
  function bp_forums_openclose_topic( $args = '' ) {
415
  do_action( 'bbpress_init' );
416
 
428
  return false;
429
  }
430
 
431
+ /**
432
+ * Delete a topic.
433
+ *
434
+ * @param array $args {
435
+ * @type int $topic_id ID of the topic being deleted.
436
+ * }
437
+ * @return bool True on success, false on failure.
438
+ */
439
  function bp_forums_delete_topic( $args = '' ) {
440
  do_action( 'bbpress_init' );
441
 
447
  return bb_delete_topic( $topic_id, 1 );
448
  }
449
 
450
+ /**
451
+ * Get a count of the total topics on the site.
452
+ *
453
+ * @return int $count Total topic count.
454
+ */
455
  function bp_forums_total_topic_count() {
456
  global $bbdb;
457
 
476
 
477
  /**
478
  * Check to see whether a user has already left this particular reply on a given post.
 
479
  *
480
+ * Used to prevent dupes.
481
+ *
482
+ * @since BuddyPress (1.6.0)
483
  *
484
+ * @param string $text The text of the comment.
485
+ * @param int $topic_id The topic id.
486
+ * @param int $user_id The user id.
487
+ * @return bool True if a duplicate reply exists, otherwise false.
488
  */
489
  function bp_forums_reply_exists( $text = '', $topic_id = 0, $user_id = 0 ) {
490
 
517
  /**
518
  * Private one-time-use function used in conjunction with bp_forums_reply_exists()
519
  *
 
520
  * @access private
521
+ * @since BuddyPress (1.7.0)
522
+ *
523
+ * @global WPDB $wpdb WordPress database access object.
524
+ *
525
+ * @param string $where SQL fragment.
526
+ * @return string SQL fragment.
527
  */
528
  function _bp_forums_reply_exists_posts_where( $where = '' ) {
529
  return $where . " AND p.post_text = '" . buddypress()->forums->reply_exists_text . "'";
530
  }
531
 
532
  /**
533
+ * Get a total "Topics Started" count for a given user.
 
 
534
  *
535
+ * @param int $user_id ID of the user being queried. Falls back on displayed
536
+ * user, then loggedin.
537
+ * @param string $type The current filter/sort type. 'active', 'popular',
538
+ * 'unreplied'.
539
+ * @return int $count The topic count.
540
  */
541
  function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) {
542
  do_action( 'bbpress_init' );
566
  }
567
 
568
  /**
569
+ * Return the total number of topics replied to by a given user.
570
  *
571
+ * Uses an unfortunate technique to count unique topics, due to limitations in
572
+ * BB_Query.
573
  *
574
+ * @since BuddyPress (1.5.0)
 
575
  *
576
+ * @param int $user_id ID of the user whose replied topics are being counted.
577
+ * Defaults to displayed user, then to logged-in user.
578
+ * @return int $count Topic count.
579
  */
580
  function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active' ) {
581
  do_action( 'bbpress_init' );
612
  return apply_filters( 'bp_forums_total_replied_count_for_user', $count, $user_id );
613
  }
614
 
615
+ /**
616
+ * Fetch BP-specific details for an array of topics.
617
+ *
618
+ * Done in one fell swoop to reduce query overhead. Currently determines the
619
+ * following:
620
+ * - details about the last poster
621
+ * - information about topic users that may have been deleted/spammed
622
+ *
623
+ * @param array $topics Array of topics.
624
+ * @return array $topics Topics with BP details added.
625
+ */
626
  function bp_forums_get_topic_extras( $topics ) {
627
  global $wpdb, $bbdb;
628
 
680
 
681
  /** Post Functions ************************************************************/
682
 
683
+ /**
684
+ * Get the posts belonging to a topic.
685
+ *
686
+ * @param array $args {
687
+ * @type int $topic_id ID of the topic for which posts are being fetched.
688
+ * @type int $page Optional. Page of results to return. Default: 1.
689
+ * @type int $page Optional. Number of results to return per page.
690
+ * Default: 15.
691
+ * @type string $order 'ASC' or 'DESC'. Default: 'ASC'.
692
+ * }
693
+ * @return array List of posts.
694
+ */
695
  function bp_forums_get_topic_posts( $args = '' ) {
696
  do_action( 'bbpress_init' );
697
 
708
  return bp_forums_get_post_extras( $query->results );
709
  }
710
 
711
+ /**
712
+ * Get a single post object by ID.
713
+ *
714
+ * Wrapper for {@link bb_get_post()}.
715
+ *
716
+ * @param int $post_id ID of the post being fetched.
717
+ * @return object Post object.
718
+ */
719
  function bp_forums_get_post( $post_id ) {
720
  do_action( 'bbpress_init' );
721
  return bb_get_post( $post_id );
722
  }
723
 
724
+ /**
725
+ * Delete a post.
726
+ *
727
+ * Wrapper for {@link bb_delete_post()}.
728
+ *
729
+ * @param array $args {
730
+ * @type int $post_id ID of the post being deleted.
731
+ * }
732
+ * @return bool True on success, false on failure.
733
+ */
734
  function bp_forums_delete_post( $args = '' ) {
735
  do_action( 'bbpress_init' );
736
 
743
  return bb_delete_post( $post_id, 1 );
744
  }
745
 
746
+ /**
747
+ * Create a new post.
748
+ *
749
+ * @param array $args {
750
+ * @type int $post_id Optional. ID of an existing post, if you want to
751
+ * update rather than create. Default: false.
752
+ * @type int $topic_id ID of the topic to which the post belongs.
753
+ * @type string $post_text Contents of the post.
754
+ * @type string $post_time Optional. Time when the post was recorded.
755
+ * Default: current time, as reported by {@link bp_core_current_time()}.
756
+ * @type int $poster_id Optional. ID of the user creating the post.
757
+ * Default: ID of the logged-in user.
758
+ * @type string $poster_ip Optional. IP address of the user creating the
759
+ * post. Default: the IP address found in $_SERVER['REMOTE_ADDR'].
760
+ * @type int $post_status Post status. Default: 0.
761
+ * @type int $post_position Optional. Default: false (auto).
762
+ * }
763
+ * @return int|bool ID of the new post on success, false on failure.
764
+ */
765
  function bp_forums_insert_post( $args = '' ) {
766
  do_action( 'bbpress_init' );
767
 
808
  return $post_id;
809
  }
810
 
811
+ /**
812
+ * Get BP-specific details about a set of posts.
813
+ *
814
+ * Currently fetches the following:
815
+ * - WP userdata for each poster
816
+ * - BP fullname for each poster
817
+ *
818
+ * @param array $posts List of posts.
819
+ * @return array Posts with BP-data added.
820
+ */
821
  function bp_forums_get_post_extras( $posts ) {
822
  global $bp, $wpdb;
823
 
856
  return apply_filters( 'bp_forums_get_post_extras', $posts );
857
  }
858
 
859
+ /**
860
+ * Get topic and post counts for a given forum.
861
+ *
862
+ * @param int $forum_id ID of the forum.
863
+ * @return object Object with properties $topics (topic count) and $posts
864
+ * (post count).
865
+ */
866
  function bp_forums_get_forum_topicpost_count( $forum_id ) {
867
  global $wpdb, $bbdb;
868
 
872
  return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );
873
  }
874
 
875
+ /**
876
+ * Map WordPress caps onto bbPress users, to ensure that they can post.
877
+ *
878
+ * @param array $allcaps Array of capabilities.
879
+ * @return array Caps array with bbPress caps added.
880
+ */
881
  function bp_forums_filter_caps( $allcaps ) {
882
  global $wp_roles, $bb_table_prefix;
883
 
898
  add_filter( 'user_has_cap', 'bp_forums_filter_caps' );
899
 
900
  /**
901
+ * Return the parent forum ID for the bbPress abstraction layer.
902
  *
903
+ * @since BuddyPress (1.5.0)
 
904
  *
905
+ * @return int Forum ID.
906
  */
907
  function bp_forums_parent_forum_id() {
908
  return apply_filters( 'bp_forums_parent_forum_id', BP_FORUMS_PARENT_FORUM_ID );
911
  /**
912
  * Should sticky topics be broken out of regular topic order on forum directories?
913
  *
914
+ * Defaults to false. Define BP_FORUMS_ENABLE_GLOBAL_DIRECTORY_STICKIES, or
915
+ * filter 'bp_forums_enable_global_directory_stickies', to change this behavior.
916
  *
917
+ * @since BuddyPress (1.5.0)
 
918
  *
919
+ * @return bool True if stickies should be displayed at the top of the global
920
+ * directory, otherwise false.
921
  */
922
  function bp_forums_enable_global_directory_stickies() {
923
  return apply_filters( 'bp_forums_enable_global_directory_stickies', defined( 'BP_FORUMS_ENABLE_GLOBAL_DIRECTORY_STICKIES' ) && BP_FORUMS_ENABLE_GLOBAL_DIRECTORY_STICKIES );
924
  }
925
 
926
 
927
+ /** Caching ******************************************************************/
928
+
929
+ /**
930
  * Caching functions handle the clearing of cached objects and pages on specific
931
  * actions throughout BuddyPress.
932
  */
940
  /** Embeds *******************************************************************/
941
 
942
  /**
943
+ * Attempt to retrieve the oEmbed cache for a forum topic.
944
+ *
945
  * Grabs the topic post ID and attempts to retrieve the oEmbed cache (if it exists)
946
  * during the forum topic loop. If no cache and link is embeddable, cache it.
947
  *
948
+ * @since BuddyPress (1.5.0)
949
+ *
950
  * @see BP_Embed
951
  * @see bp_embed_forum_cache()
952
  * @see bp_embed_forum_save_cache()
 
 
953
  */
954
  function bp_forums_embed() {
955
  add_filter( 'embed_post_id', 'bp_get_the_topic_post_id' );
959
  add_action( 'topic_loop_start', 'bp_forums_embed' );
960
 
961
  /**
 
962
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_forums_embed()}.
963
  *
964
+ * Wrapper function for {@link bb_get_postmeta()}.
965
+ *
966
  * @package BuddyPress_Forums
967
  * @since BuddyPress (1.5)
968
  */
971
  }
972
 
973
  /**
 
974
  * Used during {@link BP_Embed::parse_oembed()} via {@link bp_forums_embed()}.
975
  *
976
+ * Wrapper function for {@link bb_update_postmeta()}.
977
+ *
978
+ * @since BuddyPress (1.5.0)
979
  */
980
  function bp_embed_forum_save_cache( $cache, $cachekey, $id ) {
981
  bb_update_postmeta( $id, $cachekey, $cache );
bp-forums/bp-forums-loader.php CHANGED
@@ -5,8 +5,11 @@
5
  *
6
  * A discussion forums component. Comes bundled with bbPress stand-alone.
7
  *
 
 
 
8
  * @package BuddyPress
9
- * @subpackage Forums Core
10
  */
11
 
12
  // Exit if accessed directly
@@ -15,25 +18,32 @@ if ( !defined( 'ABSPATH' ) ) exit;
15
  class BP_Forums_Component extends BP_Component {
16
 
17
  /**
18
- * Start the forums component creation process
19
  *
20
- * @since BuddyPress (1.5)
21
  */
22
  function __construct() {
23
  parent::start(
24
  'forums',
25
  __( 'Discussion Forums', 'buddypress' ),
26
- BP_PLUGIN_DIR
 
 
 
27
  );
28
  }
29
 
30
  /**
31
- * Setup globals
32
  *
33
  * The BP_FORUMS_SLUG constant is deprecated, and only used here for
34
  * backwards compatibility.
35
  *
36
- * @since BuddyPress (1.5)
 
 
 
 
37
  */
38
  public function setup_globals( $args = array() ) {
39
  $bp = buddypress();
@@ -64,7 +74,11 @@ class BP_Forums_Component extends BP_Component {
64
  }
65
 
66
  /**
67
- * Include files
 
 
 
 
68
  */
69
  public function includes( $includes = array() ) {
70
 
@@ -92,7 +106,16 @@ class BP_Forums_Component extends BP_Component {
92
  }
93
 
94
  /**
95
- * Setup BuddyBar navigation
 
 
 
 
 
 
 
 
 
96
  */
97
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
98
 
@@ -152,13 +175,17 @@ class BP_Forums_Component extends BP_Component {
152
  }
153
 
154
  /**
155
- * Set up the Toolbar
 
 
 
 
 
 
 
156
  */
157
  public function setup_admin_bar( $wp_admin_nav = array() ) {
158
 
159
- // Prevent debug notices
160
- $wp_admin_nav = array();
161
-
162
  // Menus for logged in user
163
  if ( is_user_logged_in() ) {
164
 
@@ -202,7 +229,7 @@ class BP_Forums_Component extends BP_Component {
202
  }
203
 
204
  /**
205
- * Sets up the title for pages and <title>
206
  */
207
  function setup_title() {
208
  $bp = buddypress();
@@ -225,6 +252,9 @@ class BP_Forums_Component extends BP_Component {
225
  }
226
  }
227
 
 
 
 
228
  function bp_setup_forums() {
229
  buddypress()->forums = new BP_Forums_Component();
230
  }
5
  *
6
  * A discussion forums component. Comes bundled with bbPress stand-alone.
7
  *
8
+ * Note: The bp-forums component has been retired. Use the bbPress WordPress
9
+ * plugin instead.
10
+ *
11
  * @package BuddyPress
12
+ * @subpackage Forums
13
  */
14
 
15
  // Exit if accessed directly
18
  class BP_Forums_Component extends BP_Component {
19
 
20
  /**
21
+ * Start the forums component creation process.
22
  *
23
+ * @since BuddyPress (1.5.0)
24
  */
25
  function __construct() {
26
  parent::start(
27
  'forums',
28
  __( 'Discussion Forums', 'buddypress' ),
29
+ BP_PLUGIN_DIR,
30
+ array(
31
+ 'adminbar_myaccount_order' => 80
32
+ )
33
  );
34
  }
35
 
36
  /**
37
+ * Set up bp-forums global settings.
38
  *
39
  * The BP_FORUMS_SLUG constant is deprecated, and only used here for
40
  * backwards compatibility.
41
  *
42
+ * @since BuddyPress (1.5.0)
43
+ *
44
+ * @see BP_Component::setup_globals() for description of parameters.
45
+ *
46
+ * @param array $args See {@link BP_Component::setup_globals()}.
47
  */
48
  public function setup_globals( $args = array() ) {
49
  $bp = buddypress();
74
  }
75
 
76
  /**
77
+ * Include bp-forums files.
78
+ *
79
+ * @see BP_Component::includes() for description of parameters.
80
+ *
81
+ * @param array $includes See {@link BP_Component::includes()}.
82
  */
83
  public function includes( $includes = array() ) {
84
 
106
  }
107
 
108
  /**
109
+ * Set up component navigation.
110
+ *
111
+ * @since BuddyPress (1.5.0)
112
+ *
113
+ * @see BP_Component::setup_nav() for a description of arguments.
114
+ *
115
+ * @param array $main_nav Optional. See BP_Component::setup_nav() for
116
+ * description.
117
+ * @param array $sub_nav Optional. See BP_Component::setup_nav() for
118
+ * description.
119
  */
120
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
121
 
175
  }
176
 
177
  /**
178
+ * Set up bp-forums integration with the WordPress admin bar.
179
+ *
180
+ * @since BuddyPress (1.5.0)
181
+ *
182
+ * @see BP_Component::setup_admin_bar() for a description of arguments.
183
+ *
184
+ * @param array $wp_admin_nav See BP_Component::setup_admin_bar()
185
+ * for description.
186
  */
187
  public function setup_admin_bar( $wp_admin_nav = array() ) {
188
 
 
 
 
189
  // Menus for logged in user
190
  if ( is_user_logged_in() ) {
191
 
229
  }
230
 
231
  /**
232
+ * Set up the title for pages and the <title> element.
233
  */
234
  function setup_title() {
235
  $bp = buddypress();
252
  }
253
  }
254
 
255
+ /**
256
+ * Set up the bp-forums component.
257
+ */
258
  function bp_setup_forums() {
259
  buddypress()->forums = new BP_Forums_Component();
260
  }
bp-forums/bp-forums-screens.php CHANGED
@@ -1,7 +1,17 @@
1
  <?php
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( !defined( 'ABSPATH' ) ) exit;
4
 
 
 
 
5
  function bp_forums_directory_forums_setup() {
6
 
7
  // Get BuddyPress once
@@ -72,12 +82,18 @@ function bp_forums_directory_forums_setup() {
72
  }
73
  add_action( 'bp_screens', 'bp_forums_directory_forums_setup', 2 );
74
 
 
 
 
75
  function bp_member_forums_screen_topics() {
76
  do_action( 'bp_member_forums_screen_topics' );
77
 
78
  bp_core_load_template( apply_filters( 'bp_member_forums_screen_topics', 'members/single/home' ) );
79
  }
80
 
 
 
 
81
  function bp_member_forums_screen_replies() {
82
  do_action( 'bp_member_forums_screen_replies' );
83
 
@@ -85,11 +101,9 @@ function bp_member_forums_screen_replies() {
85
  }
86
 
87
  /**
88
- * Loads the template content for a user's Favorites forum tab.
89
  *
90
  * Note that this feature is not fully implemented at the moment.
91
- *
92
- * @package BuddyPress Forums
93
  */
94
  function bp_member_forums_screen_favorites() {
95
  do_action( 'bp_member_forums_screen_favorites' );
@@ -97,6 +111,9 @@ function bp_member_forums_screen_favorites() {
97
  bp_core_load_template( apply_filters( 'bp_member_forums_screen_favorites', 'members/single/home' ) );
98
  }
99
 
 
 
 
100
  function bp_forums_screen_single_forum() {
101
 
102
  if ( !bp_is_forums_component() || !bp_is_current_action( 'forum' ) || !bp_action_variable( 0 ) )
@@ -108,6 +125,9 @@ function bp_forums_screen_single_forum() {
108
  }
109
  add_action( 'bp_screens', 'bp_forums_screen_single_forum' );
110
 
 
 
 
111
  function bp_forums_screen_single_topic() {
112
 
113
  if ( !bp_is_forums_component() || !bp_is_current_action( 'topic' ) || !bp_action_variable( 0 ) )
@@ -123,19 +143,19 @@ add_action( 'bp_screens', 'bp_forums_screen_single_topic' );
123
  /** Theme Compatability *******************************************************/
124
 
125
  /**
126
- * The main theme compat class for legacy BuddyPress forums, as powered by bbPress 1.x
127
  *
128
  * This class sets up the necessary theme compatability actions to safely output
129
  * old forum template parts to the_title and the_content areas of a theme.
130
  *
131
- * @since BuddyPress (1.7)
132
  */
133
  class BP_Forum_Legacy_Theme_Compat {
134
 
135
  /**
136
- * Setup the old forums component theme compatibility
137
  *
138
- * @since BuddyPress (1.7)
139
  */
140
  public function __construct() {
141
  add_action( 'bp_setup_theme_compat', array( $this, 'is_legacy_forum' ) );
@@ -144,7 +164,7 @@ class BP_Forum_Legacy_Theme_Compat {
144
  /**
145
  * Are we looking at something that needs old forum theme compatability?
146
  *
147
- * @since BuddyPress (1.7)
148
  */
149
  public function is_legacy_forum() {
150
 
@@ -177,9 +197,9 @@ class BP_Forum_Legacy_Theme_Compat {
177
  /** Directory *************************************************************/
178
 
179
  /**
180
- * Update the global $post with directory data
181
  *
182
- * @since BuddyPress (1.7)
183
  */
184
  public function directory_dummy_post() {
185
 
@@ -204,12 +224,12 @@ class BP_Forum_Legacy_Theme_Compat {
204
  }
205
 
206
  /**
207
- * Filter the_content with the old forum index template part
208
  *
209
- * @since BuddyPress (1.7)
210
  */
211
  public function directory_content() {
212
- bp_buffer_template_part( 'forums/index' );
213
  }
214
  }
215
  new BP_Forum_Legacy_Theme_Compat();
1
  <?php
2
+ /**
3
+ * BuddyPress Forums Screen Functions.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Forums
7
+ */
8
+
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
+ /**
13
+ * Load the Forums directory.
14
+ */
15
  function bp_forums_directory_forums_setup() {
16
 
17
  // Get BuddyPress once
82
  }
83
  add_action( 'bp_screens', 'bp_forums_directory_forums_setup', 2 );
84
 
85
+ /**
86
+ * Load the Topics Started screen.
87
+ */
88
  function bp_member_forums_screen_topics() {
89
  do_action( 'bp_member_forums_screen_topics' );
90
 
91
  bp_core_load_template( apply_filters( 'bp_member_forums_screen_topics', 'members/single/home' ) );
92
  }
93
 
94
+ /**
95
+ * Load the Replied To screen.
96
+ */
97
  function bp_member_forums_screen_replies() {
98
  do_action( 'bp_member_forums_screen_replies' );
99
 
101
  }
102
 
103
  /**
104
+ * Load the template content for a user's Favorites forum tab.
105
  *
106
  * Note that this feature is not fully implemented at the moment.
 
 
107
  */
108
  function bp_member_forums_screen_favorites() {
109
  do_action( 'bp_member_forums_screen_favorites' );
111
  bp_core_load_template( apply_filters( 'bp_member_forums_screen_favorites', 'members/single/home' ) );
112
  }
113
 
114
+ /**
115
+ * Load a single forum page.
116
+ */
117
  function bp_forums_screen_single_forum() {
118
 
119
  if ( !bp_is_forums_component() || !bp_is_current_action( 'forum' ) || !bp_action_variable( 0 ) )
125
  }
126
  add_action( 'bp_screens', 'bp_forums_screen_single_forum' );
127
 
128
+ /**
129
+ * Load a single forum topic page.
130
+ */
131
  function bp_forums_screen_single_topic() {
132
 
133
  if ( !bp_is_forums_component() || !bp_is_current_action( 'topic' ) || !bp_action_variable( 0 ) )
143
  /** Theme Compatability *******************************************************/
144
 
145
  /**
146
+ * The main theme compat class for legacy BuddyPress forums.
147
  *
148
  * This class sets up the necessary theme compatability actions to safely output
149
  * old forum template parts to the_title and the_content areas of a theme.
150
  *
151
+ * @since BuddyPress (1.7.0)
152
  */
153
  class BP_Forum_Legacy_Theme_Compat {
154
 
155
  /**
156
+ * Set up theme compatibility for the legacy forums component.
157
  *
158
+ * @since BuddyPress (1.7.0)
159
  */
160
  public function __construct() {
161
  add_action( 'bp_setup_theme_compat', array( $this, 'is_legacy_forum' ) );
164
  /**
165
  * Are we looking at something that needs old forum theme compatability?
166
  *
167
+ * @since BuddyPress (1.7.0)
168
  */
169
  public function is_legacy_forum() {
170
 
197
  /** Directory *************************************************************/
198
 
199
  /**
200
+ * Update the global $post with directory data.
201
  *
202
+ * @since BuddyPress (1.7.0)
203
  */
204
  public function directory_dummy_post() {
205
 
224
  }
225
 
226
  /**
227
+ * Filter the_content with the old forum index template part.
228
  *
229
+ * @since BuddyPress (1.7.0)
230
  */
231
  public function directory_content() {
232
+ return bp_buffer_template_part( 'forums/index', null, false );
233
  }
234
  }
235
  new BP_Forum_Legacy_Theme_Compat();
bp-forums/bp-forums-template.php CHANGED
@@ -1,13 +1,18 @@
1
  <?php
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( !defined( 'ABSPATH' ) ) exit;
4
 
5
  /**
6
- * Output the forums component slug
7
  *
8
- * @package BuddyPress
9
- * @subpackage Forums Template
10
- * @since BuddyPress (1.5)
11
  *
12
  * @uses bp_get_forums_slug()
13
  */
@@ -15,11 +20,11 @@ function bp_forums_slug() {
15
  echo bp_get_forums_slug();
16
  }
17
  /**
18
- * Return the forums component slug
19
  *
20
- * @package BuddyPress
21
- * @subpackage Forums Template
22
- * @since BuddyPress (1.5)
23
  */
24
  function bp_get_forums_slug() {
25
  global $bp;
@@ -27,11 +32,9 @@ function bp_forums_slug() {
27
  }
28
 
29
  /**
30
- * Output the forums component root slug
31
  *
32
- * @package BuddyPress
33
- * @subpackage Forums Template
34
- * @since BuddyPress (1.5)
35
  *
36
  * @uses bp_get_forums_root_slug()
37
  */
@@ -39,11 +42,11 @@ function bp_forums_root_slug() {
39
  echo bp_get_forums_root_slug();
40
  }
41
  /**
42
- * Return the forums component root slug
43
  *
44
- * @package BuddyPress
45
- * @subpackage Forums Template
46
- * @since BuddyPress (1.5)
47
  */
48
  function bp_get_forums_root_slug() {
49
  global $bp;
@@ -51,52 +54,157 @@ function bp_forums_root_slug() {
51
  }
52
 
53
  /**
54
- * Output forum directory permalink
 
 
55
  *
56
- * @package BuddyPress
57
- * @subpackage Forums Template
58
- * @since BuddyPress (1.5)
59
  * @uses bp_get_forums_directory_permalink()
60
  */
61
  function bp_forums_directory_permalink() {
62
  echo bp_get_forums_directory_permalink();
63
  }
64
  /**
65
- * Return forum directory permalink
 
 
66
  *
67
- * @package BuddyPress
68
- * @subpackage Forums Template
69
- * @since BuddyPress (1.5)
70
  * @uses apply_filters()
71
  * @uses traisingslashit()
72
  * @uses bp_get_root_domain()
73
  * @uses bp_get_forums_root_slug()
74
- * @return string
 
75
  */
76
  function bp_get_forums_directory_permalink() {
77
  return apply_filters( 'bp_get_forums_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() ) );
78
  }
79
 
 
 
 
 
 
80
  class BP_Forums_Template_Forum {
 
 
 
 
 
 
81
  var $current_topic = -1;
 
 
 
 
 
 
 
82
  var $topic_count;
 
 
 
 
 
 
 
83
  var $topics;
 
 
 
 
 
 
 
84
  var $topic;
85
 
 
 
 
 
 
 
86
  var $forum_id;
87
 
 
 
 
 
 
 
88
  var $in_the_loop;
89
 
 
 
 
 
 
 
90
  var $pag_page;
 
 
 
 
 
 
 
91
  var $pag_num;
 
 
 
 
 
 
 
92
  var $pag_links;
 
 
 
 
 
 
 
93
  var $total_topic_count;
94
 
 
 
 
 
 
 
95
  var $single_topic = false;
96
 
 
 
 
 
 
 
97
  var $sort_by;
 
 
 
 
 
 
 
98
  var $order;
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  function __construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) {
101
  global $bp;
102
 
@@ -192,6 +300,13 @@ class BP_Forums_Template_Forum {
192
  }
193
  }
194
 
 
 
 
 
 
 
 
195
  function has_topics() {
196
  if ( $this->topic_count )
197
  return true;
@@ -199,6 +314,11 @@ class BP_Forums_Template_Forum {
199
  return false;
200
  }
201
 
 
 
 
 
 
202
  function next_topic() {
203
  $this->current_topic++;
204
  $this->topic = $this->topics[$this->current_topic];
@@ -206,6 +326,9 @@ class BP_Forums_Template_Forum {
206
  return $this->topic;
207
  }
208
 
 
 
 
209
  function rewind_topics() {
210
  $this->current_topic = -1;
211
  if ( $this->topic_count > 0 ) {
@@ -213,6 +336,17 @@ class BP_Forums_Template_Forum {
213
  }
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
216
  function user_topics() {
217
  if ( $this->current_topic + 1 < $this->topic_count ) {
218
  return true;
@@ -226,6 +360,11 @@ class BP_Forums_Template_Forum {
226
  return false;
227
  }
228
 
 
 
 
 
 
229
  function the_topic() {
230
  global $topic;
231
 
@@ -241,16 +380,41 @@ class BP_Forums_Template_Forum {
241
  /**
242
  * Initiate the forum topics loop.
243
  *
244
- * Like other BuddyPress custom loops, the default arguments for this function are determined
245
- * dynamically, depending on your current page. All of these $defaults can be overridden in the
246
- * $args parameter.
247
  *
248
- * @package BuddyPress
249
- * @uses apply_filters() Filter bp_has_topics to manipulate the $forums_template global before
250
- * it's rendered, or to modify the value of has_topics().
251
  *
252
- * @param array $args See inline definition of $defaults for explanation of arguments
253
- * @return bool Returns true when forum topics are found corresponding to the args, false otherwise.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  */
255
  function bp_has_forum_topics( $args = '' ) {
256
  global $forum_template, $bp;
@@ -418,46 +582,92 @@ function bp_has_forum_topics( $args = '' ) {
418
  return apply_filters( 'bp_has_topics', $forum_template->has_topics(), $forum_template );
419
  }
420
 
 
 
 
 
 
 
 
421
  function bp_forum_topics() {
422
  global $forum_template;
423
  return $forum_template->user_topics();
424
  }
425
 
 
 
 
 
 
 
 
426
  function bp_the_forum_topic() {
427
  global $forum_template;
428
  return $forum_template->the_topic();
429
  }
430
 
 
 
 
431
  function bp_the_topic_id() {
432
  echo bp_get_the_topic_id();
433
  }
 
 
 
 
 
434
  function bp_get_the_topic_id() {
435
  global $forum_template;
436
 
437
  return apply_filters( 'bp_get_the_topic_id', $forum_template->topic->topic_id );
438
  }
439
 
 
 
 
440
  function bp_the_topic_title() {
441
  echo bp_get_the_topic_title();
442
  }
 
 
 
 
 
443
  function bp_get_the_topic_title() {
444
  global $forum_template;
445
 
446
  return apply_filters( 'bp_get_the_topic_title', stripslashes( $forum_template->topic->topic_title ) );
447
  }
448
 
 
 
 
449
  function bp_the_topic_slug() {
450
  echo bp_get_the_topic_slug();
451
  }
 
 
 
 
 
452
  function bp_get_the_topic_slug() {
453
  global $forum_template;
454
 
455
  return apply_filters( 'bp_get_the_topic_slug', $forum_template->topic->topic_slug );
456
  }
457
 
 
 
 
458
  function bp_the_topic_text() {
459
  echo bp_get_the_topic_text();
460
  }
 
 
 
 
 
461
  function bp_get_the_topic_text() {
462
  global $forum_template;
463
 
@@ -465,18 +675,51 @@ function bp_the_topic_text() {
465
  return apply_filters( 'bp_get_the_topic_text', esc_attr( $post->post_text ) );
466
  }
467
 
 
 
 
468
  function bp_the_topic_poster_id() {
469
  echo bp_get_the_topic_poster_id();
470
  }
 
 
 
 
 
471
  function bp_get_the_topic_poster_id() {
472
  global $forum_template;
473
 
474
  return apply_filters( 'bp_get_the_topic_poster_id', $forum_template->topic->topic_poster );
475
  }
476
 
 
 
 
 
 
 
 
477
  function bp_the_topic_poster_avatar( $args = '' ) {
478
  echo bp_get_the_topic_poster_avatar( $args );
479
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  function bp_get_the_topic_poster_avatar( $args = '' ) {
481
  global $forum_template;
482
 
@@ -493,9 +736,17 @@ function bp_the_topic_poster_avatar( $args = '' ) {
493
  return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
494
  }
495
 
 
 
 
496
  function bp_the_topic_poster_name() {
497
  echo bp_get_the_topic_poster_name();
498
  }
 
 
 
 
 
499
  function bp_get_the_topic_poster_name() {
500
  global $forum_template;
501
 
@@ -507,18 +758,39 @@ function bp_the_topic_poster_name() {
507
  return apply_filters( 'bp_get_the_topic_poster_name', $name );
508
  }
509
 
 
 
 
510
  function bp_the_topic_object_id() {
511
  echo bp_get_the_topic_object_id();
512
  }
 
 
 
 
 
 
 
513
  function bp_get_the_topic_object_id() {
514
  global $forum_template;
515
 
516
  return apply_filters( 'bp_get_the_topic_object_id', $forum_template->topic->object_id );
517
  }
518
 
 
 
 
519
  function bp_the_topic_object_name() {
520
  echo bp_get_the_topic_object_name();
521
  }
 
 
 
 
 
 
 
 
522
  function bp_get_the_topic_object_name() {
523
  global $forum_template;
524
 
@@ -530,18 +802,40 @@ function bp_the_topic_object_name() {
530
  return apply_filters( 'bp_get_the_topic_object_name', $retval );
531
  }
532
 
 
 
 
533
  function bp_the_topic_object_slug() {
534
  echo bp_get_the_topic_object_slug();
535
  }
 
 
 
 
 
 
 
 
536
  function bp_get_the_topic_object_slug() {
537
  global $forum_template;
538
 
539
  return apply_filters( 'bp_get_the_topic_object_slug', $forum_template->topic->object_slug );
540
  }
541
 
 
 
 
542
  function bp_the_topic_object_permalink() {
543
  echo bp_get_the_topic_object_permalink();
544
  }
 
 
 
 
 
 
 
 
545
  function bp_get_the_topic_object_permalink() {
546
 
547
  // Currently this will only work with group forums, extended support in the future
@@ -553,9 +847,18 @@ function bp_the_topic_object_permalink() {
553
  return apply_filters( 'bp_get_the_topic_object_permalink', $permalink );
554
  }
555
 
 
 
 
556
  function bp_the_topic_last_poster_name() {
557
  echo bp_get_the_topic_last_poster_name();
558
  }
 
 
 
 
 
 
559
  function bp_get_the_topic_last_poster_name() {
560
  global $forum_template;
561
 
@@ -569,9 +872,37 @@ function bp_the_topic_last_poster_name() {
569
  return apply_filters( 'bp_get_the_topic_last_poster_name', '<a href="' . $domain . '">' . $forum_template->topic->topic_last_poster_displayname . '</a>' );
570
  }
571
 
 
 
 
 
 
 
 
572
  function bp_the_topic_object_avatar( $args = '' ) {
573
  echo bp_get_the_topic_object_avatar( $args );
574
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
  function bp_get_the_topic_object_avatar( $args = '' ) {
576
  global $forum_template;
577
 
@@ -591,9 +922,34 @@ function bp_the_topic_object_avatar( $args = '' ) {
591
  return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
592
  }
593
 
 
 
 
 
 
 
 
594
  function bp_the_topic_last_poster_avatar( $args = '' ) {
595
  echo bp_get_the_topic_last_poster_avatar( $args );
596
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  function bp_get_the_topic_last_poster_avatar( $args = '' ) {
598
  global $forum_template;
599
 
@@ -610,72 +966,136 @@ function bp_the_topic_last_poster_avatar( $args = '' ) {
610
  return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'email' => $forum_template->topic->topic_last_poster_email, 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
611
  }
612
 
 
 
 
613
  function bp_the_topic_start_time() {
614
  echo bp_get_the_topic_start_time();
615
  }
 
 
 
 
 
616
  function bp_get_the_topic_start_time() {
617
  global $forum_template;
618
 
619
  return apply_filters( 'bp_get_the_topic_start_time', $forum_template->topic->topic_start_time );
620
  }
621
 
 
 
 
622
  function bp_the_topic_time() {
623
  echo bp_get_the_topic_time();
624
  }
 
 
 
 
 
625
  function bp_get_the_topic_time() {
626
  global $forum_template;
627
 
628
  return apply_filters( 'bp_get_the_topic_time', $forum_template->topic->topic_time );
629
  }
630
 
 
 
 
631
  function bp_the_topic_forum_id() {
632
  echo bp_get_the_topic_forum_id();
633
  }
 
 
 
 
 
634
  function bp_get_the_topic_forum_id() {
635
  global $forum_template;
636
 
637
  return apply_filters( 'bp_get_the_topic_forum_id', $forum_template->topic->forum_id );
638
  }
639
 
 
 
 
640
  function bp_the_topic_status() {
641
  echo bp_get_the_topic_status();
642
  }
 
 
 
 
 
643
  function bp_get_the_topic_status() {
644
  global $forum_template;
645
 
646
  return apply_filters( 'bp_get_the_topic_status', $forum_template->topic->topic_status );
647
  }
648
 
 
 
 
649
  function bp_the_topic_is_topic_open() {
650
  echo bp_get_the_topic_is_topic_open();
651
  }
 
 
 
 
 
652
  function bp_get_the_topic_is_topic_open() {
653
  global $forum_template;
654
 
655
  return apply_filters( 'bp_get_the_topic_is_topic_open', $forum_template->topic->topic_open );
656
  }
657
 
 
 
 
658
  function bp_the_topic_last_post_id() {
659
  echo bp_get_the_topic_last_post_id();
660
  }
 
 
 
 
 
661
  function bp_get_the_topic_last_post_id() {
662
  global $forum_template;
663
 
664
  return apply_filters( 'bp_get_the_topic_last_post_id', $forum_template->topic->topic_last_post_id );
665
  }
666
 
 
 
 
667
  function bp_the_topic_is_sticky() {
668
  echo bp_get_the_topic_is_sticky();
669
  }
 
 
 
 
 
670
  function bp_get_the_topic_is_sticky() {
671
  global $forum_template;
672
 
673
  return apply_filters( 'bp_get_the_topic_is_sticky', $forum_template->topic->topic_sticky );
674
  }
675
 
 
 
 
676
  function bp_the_topic_total_post_count() {
677
  echo bp_get_the_topic_total_post_count();
678
  }
 
 
 
 
 
679
  function bp_get_the_topic_total_post_count() {
680
  global $forum_template;
681
 
@@ -685,27 +1105,51 @@ function bp_the_topic_total_post_count() {
685
  return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) );
686
  }
687
 
 
 
 
688
  function bp_the_topic_total_posts() {
689
  echo bp_get_the_topic_total_posts();
690
  }
 
 
 
 
 
691
  function bp_get_the_topic_total_posts() {
692
  global $forum_template;
693
 
694
  return apply_filters( 'bp_get_the_topic_total_posts', $forum_template->topic->topic_posts );
695
  }
696
 
 
 
 
697
  function bp_the_topic_tag_count() {
698
  echo bp_get_the_topic_tag_count();
699
  }
 
 
 
 
 
700
  function bp_get_the_topic_tag_count() {
701
  global $forum_template;
702
 
703
  return apply_filters( 'bp_get_the_topic_tag_count', $forum_template->topic->tag_count );
704
  }
705
 
 
 
 
706
  function bp_the_topic_permalink() {
707
  echo bp_get_the_topic_permalink();
708
  }
 
 
 
 
 
709
  function bp_get_the_topic_permalink() {
710
  global $forum_template, $bp;
711
 
@@ -729,18 +1173,39 @@ function bp_the_topic_permalink() {
729
  return apply_filters( 'bp_get_the_topic_permalink', trailingslashit( $permalink . 'topic/' . $forum_template->topic->topic_slug ) );
730
  }
731
 
 
 
 
732
  function bp_the_topic_time_since_created() {
733
  echo bp_get_the_topic_time_since_created();
734
  }
 
 
 
 
 
 
 
735
  function bp_get_the_topic_time_since_created() {
736
  global $forum_template;
737
 
738
  return apply_filters( 'bp_get_the_topic_time_since_created', bp_core_time_since( strtotime( $forum_template->topic->topic_start_time ) ) );
739
  }
740
 
 
 
 
741
  function bp_the_topic_latest_post_excerpt( $args = '' ) {
742
  echo bp_get_the_topic_latest_post_excerpt( $args );
743
  }
 
 
 
 
 
 
 
 
744
  function bp_get_the_topic_latest_post_excerpt( $args = '' ) {
745
  global $forum_template;
746
 
@@ -757,27 +1222,62 @@ function bp_the_topic_latest_post_excerpt( $args = '' ) {
757
  return apply_filters( 'bp_get_the_topic_latest_post_excerpt', $post, $length );
758
  }
759
 
 
 
 
760
  function bp_the_topic_time_since_last_post() {
761
  echo bp_get_the_topic_time_since_last_post();
762
  }
 
 
 
 
 
 
 
763
  function bp_get_the_topic_time_since_last_post() {
764
  global $forum_template;
765
 
766
  return apply_filters( 'bp_get_the_topic_time_since_last_post', bp_core_time_since( strtotime( $forum_template->topic->topic_time ) ) );
767
  }
768
 
 
 
 
769
  function bp_the_topic_is_mine() {
770
  echo bp_get_the_topic_is_mine();
771
  }
 
 
 
 
 
 
772
  function bp_get_the_topic_is_mine() {
773
  global $forum_template;
774
 
775
  return bp_loggedin_user_id() == $forum_template->topic->topic_poster;
776
  }
777
 
778
- function bp_the_topic_admin_links( $args = '' ) {
779
- echo bp_get_the_topic_admin_links( $args );
780
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
781
  function bp_get_the_topic_admin_links( $args = '' ) {
782
  global $forum_template;
783
 
@@ -807,10 +1307,20 @@ function bp_the_topic_admin_links( $args = '' ) {
807
  return implode( ' ' . $seperator . ' ', (array) $links );
808
  }
809
 
 
 
 
810
  function bp_the_topic_css_class() {
811
  echo bp_get_the_topic_css_class();
812
  }
813
-
 
 
 
 
 
 
 
814
  function bp_get_the_topic_css_class() {
815
  global $forum_template;
816
 
@@ -828,46 +1338,87 @@ function bp_the_topic_css_class() {
828
  return apply_filters( 'bp_get_the_topic_css_class', trim( $class ) );
829
  }
830
 
 
 
 
831
  function bp_my_forum_topics_link() {
832
  echo bp_get_my_forum_topics_link();
833
  }
 
 
 
 
 
834
  function bp_get_my_forum_topics_link() {
835
  global $bp;
836
 
837
  return apply_filters( 'bp_get_my_forum_topics_link', bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/personal/' );
838
  }
839
 
 
 
 
840
  function bp_unreplied_forum_topics_link() {
841
  echo bp_get_unreplied_forum_topics_link();
842
  }
 
 
 
 
 
843
  function bp_get_unreplied_forum_topics_link() {
844
  global $bp;
845
 
846
  return apply_filters( 'bp_get_unreplied_forum_topics_link', bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/unreplied/' );
847
  }
848
 
849
-
 
 
850
  function bp_popular_forum_topics_link() {
851
  echo bp_get_popular_forum_topics_link();
852
  }
 
 
 
 
 
853
  function bp_get_popular_forum_topics_link() {
854
  global $bp;
855
 
856
  return apply_filters( 'bp_get_popular_forum_topics_link', bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/popular/' );
857
  }
858
 
 
 
 
859
  function bp_newest_forum_topics_link() {
860
  echo bp_get_newest_forum_topics_link();
861
  }
 
 
 
 
 
862
  function bp_get_newest_forum_topics_link() {
863
  global $bp;
864
 
865
  return apply_filters( 'bp_get_newest_forum_topics_link', bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/' );
866
  }
867
 
 
 
 
868
  function bp_forum_topic_type() {
869
  echo bp_get_forum_topic_type();
870
  }
 
 
 
 
 
 
 
871
  function bp_get_forum_topic_type() {
872
  global $bp;
873
 
@@ -878,22 +1429,21 @@ function bp_forum_topic_type() {
878
  }
879
 
880
  /**
881
- * Echoes the output of bp_get_forum_topic_new_reply_link()
882
  *
883
- * @package BuddyPress
884
- * @since BuddyPress (1.5)
885
  */
886
  function bp_forum_topic_new_reply_link() {
887
  echo bp_get_forum_topic_new_reply_link();
888
  }
889
  /**
890
- * Returns the permalink for the New Reply button at the top of forum topics
891
  *
892
- * @package BuddyPress
893
- * @since BuddyPress (1.5)
894
  *
895
- * @uses apply_filters() Filter bp_get_forum_topic_new_reply_link to modify
896
- * @return string The URL for the New Reply link
 
897
  */
898
  function bp_get_forum_topic_new_reply_link() {
899
  global $topic_template;
@@ -914,18 +1464,16 @@ function bp_forum_topic_new_reply_link() {
914
  }
915
 
916
  /**
917
- * Echoes the output of bp_get_forums_tag_name()
918
  *
919
- * @package BuddyPress
920
  * @todo Deprecate?
921
  */
922
  function bp_forums_tag_name() {
923
  echo bp_get_forums_tag_name();
924
  }
925
  /**
926
- * Outputs the currently viewed tag name
927
  *
928
- * @package BuddyPress
929
  * @todo Deprecate? Seems unused
930
  */
931
  function bp_get_forums_tag_name() {
@@ -934,18 +1482,36 @@ function bp_forums_tag_name() {
934
  return apply_filters( 'bp_get_forums_tag_name', $tag_name );
935
  }
936
 
 
 
 
937
  function bp_forum_pagination() {
938
  echo bp_get_forum_pagination();
939
  }
 
 
 
 
 
940
  function bp_get_forum_pagination() {
941
  global $forum_template;
942
 
943
  return apply_filters( 'bp_get_forum_pagination', $forum_template->pag_links );
944
  }
945
 
 
 
 
946
  function bp_forum_pagination_count() {
947
  echo bp_get_forum_pagination_count();
948
  }
 
 
 
 
 
 
 
949
  function bp_get_forum_pagination_count() {
950
  global $bp, $forum_template;
951
 
@@ -958,9 +1524,14 @@ function bp_forum_pagination_count() {
958
  if ( 'tags' == $forum_template->type && !empty( $forum_template->search_terms ) )
959
  $pag_filter = sprintf( __( ' matching tag "%s"', 'buddypress' ), $forum_template->search_terms );
960
 
961
- return apply_filters( 'bp_get_forum_pagination_count', sprintf( __( 'Viewing topic %s to %s (of %s total topics%s)', 'buddypress' ), $from_num, $to_num, $total, $pag_filter ) );
962
  }
963
 
 
 
 
 
 
964
  function bp_is_edit_topic() {
965
  global $bp;
966
 
@@ -970,36 +1541,149 @@ function bp_is_edit_topic() {
970
  return true;
971
  }
972
 
 
 
 
 
 
973
  class BP_Forums_Template_Topic {
 
 
 
 
 
 
974
  var $current_post = -1;
 
 
 
 
 
 
 
975
  var $post_count;
 
 
 
 
 
 
 
976
  var $posts;
 
 
 
 
 
 
 
977
  var $post;
978
 
 
 
 
 
 
 
979
  var $forum_id;
 
 
 
 
 
 
 
980
  var $topic_id;
 
 
 
 
 
 
 
981
  var $topic;
982
 
 
 
 
 
 
 
983
  var $in_the_loop;
984
 
985
  /**
986
- * Contains a 'total_pages' property holding total number of pages in this loop.
 
987
  *
988
- * @since BuddyPress (1.2)
989
  * @var stdClass
990
  */
991
  public $pag;
992
 
 
 
 
 
 
 
993
  var $pag_page;
 
 
 
 
 
 
 
994
  var $pag_num;
 
 
 
 
 
 
 
995
  var $pag_links;
 
 
 
 
 
 
 
996
  var $total_post_count;
997
 
 
 
 
 
 
 
998
  var $single_post = false;
999
 
 
 
 
 
 
 
1000
  var $sort_by;
 
 
 
 
 
 
 
1001
  var $order;
1002
 
 
 
 
 
 
 
 
 
1003
  function __construct( $topic_id, $per_page, $max, $order ) {
1004
  global $bp, $current_user, $forum_template;
1005
 
@@ -1060,6 +1744,13 @@ class BP_Forums_Template_Topic {
1060
  }
1061
  }
1062
 
 
 
 
 
 
 
 
1063
  function has_posts() {
1064
  if ( $this->post_count )
1065
  return true;
@@ -1067,6 +1758,11 @@ class BP_Forums_Template_Topic {
1067
  return false;
1068
  }
1069
 
 
 
 
 
 
1070
  function next_post() {
1071
  $this->current_post++;
1072
  $this->post = $this->posts[$this->current_post];
@@ -1074,6 +1770,9 @@ class BP_Forums_Template_Topic {
1074
  return $this->post;
1075
  }
1076
 
 
 
 
1077
  function rewind_posts() {
1078
  $this->current_post = -1;
1079
  if ( $this->post_count > 0 ) {
@@ -1081,6 +1780,17 @@ class BP_Forums_Template_Topic {
1081
  }
1082
  }
1083
 
 
 
 
 
 
 
 
 
 
 
 
1084
  function user_posts() {
1085
  if ( $this->current_post + 1 < $this->post_count ) {
1086
  return true;
@@ -1094,6 +1804,11 @@ class BP_Forums_Template_Topic {
1094
  return false;
1095
  }
1096
 
 
 
 
 
 
1097
  function the_post() {
1098
  global $post;
1099
 
@@ -1106,6 +1821,19 @@ class BP_Forums_Template_Topic {
1106
  }
1107
  }
1108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1109
  function bp_has_forum_topic_posts( $args = '' ) {
1110
  global $topic_template;
1111
 
@@ -1138,38 +1866,75 @@ function bp_has_forum_topic_posts( $args = '' ) {
1138
  return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), $topic_template );
1139
  }
1140
 
 
 
 
 
 
1141
  function bp_forum_topic_posts() {
1142
  global $topic_template;
1143
  return $topic_template->user_posts();
1144
  }
1145
 
 
 
 
 
 
1146
  function bp_the_forum_topic_post() {
1147
  global $topic_template;
1148
  return $topic_template->the_post();
1149
  }
1150
 
 
 
 
1151
  function bp_the_topic_post_id() {
1152
  echo bp_get_the_topic_post_id();
1153
  }
 
 
 
 
 
1154
  function bp_get_the_topic_post_id() {
1155
  global $topic_template;
1156
 
1157
  return apply_filters( 'bp_get_the_topic_post_id', $topic_template->post->post_id );
1158
  }
1159
 
 
 
 
1160
  function bp_the_topic_post_content() {
1161
  echo bp_get_the_topic_post_content();
1162
  }
 
 
 
 
 
1163
  function bp_get_the_topic_post_content() {
1164
  global $topic_template;
1165
 
1166
  return apply_filters( 'bp_get_the_topic_post_content', stripslashes( $topic_template->post->post_text ) );
1167
  }
1168
 
 
 
 
1169
  function bp_the_topic_post_css_class() {
1170
  echo bp_get_the_topic_post_css_class();
1171
  }
1172
-
 
 
 
 
 
 
 
 
1173
  function bp_get_the_topic_post_css_class() {
1174
  global $topic_template;
1175
 
@@ -1187,9 +1952,34 @@ function bp_the_topic_post_css_class() {
1187
  return apply_filters( 'bp_get_the_topic_post_css_class', trim( $class ) );
1188
  }
1189
 
 
 
 
 
 
 
 
1190
  function bp_the_topic_post_poster_avatar( $args = '' ) {
1191
  echo bp_get_the_topic_post_poster_avatar( $args );
1192
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1193
  function bp_get_the_topic_post_poster_avatar( $args = '' ) {
1194
  global $topic_template;
1195
 
@@ -1206,9 +1996,17 @@ function bp_the_topic_post_poster_avatar( $args = '' ) {
1206
  return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
1207
  }
1208
 
 
 
 
1209
  function bp_the_topic_post_poster_name() {
1210
  echo bp_get_the_topic_post_poster_name();
1211
  }
 
 
 
 
 
1212
  function bp_get_the_topic_post_poster_name() {
1213
  global $topic_template;
1214
 
@@ -1218,36 +2016,80 @@ function bp_the_topic_post_poster_name() {
1218
  return apply_filters( 'bp_get_the_topic_post_poster_name', '<a href="' . $link . '" title="' . $topic_template->post->poster_name . '">' . $topic_template->post->poster_name . '</a>' );
1219
  }
1220
 
 
 
 
1221
  function bp_the_topic_post_poster_link() {
1222
  echo bp_get_the_topic_post_poster_link();
1223
  }
 
 
 
 
 
 
1224
  function bp_get_the_topic_post_poster_link() {
1225
  global $topic_template;
1226
 
1227
  return apply_filters( 'bp_the_topic_post_poster_link', bp_core_get_user_domain( $topic_template->post->poster_id ) );
1228
  }
1229
 
 
 
 
1230
  function bp_the_topic_post_time_since() {
1231
  echo bp_get_the_topic_post_time_since();
1232
  }
 
 
 
 
 
 
 
1233
  function bp_get_the_topic_post_time_since() {
1234
  global $topic_template;
1235
 
1236
  return apply_filters( 'bp_get_the_topic_post_time_since', bp_core_time_since( strtotime( $topic_template->post->post_time ) ) );
1237
  }
1238
 
 
 
 
1239
  function bp_the_topic_post_is_mine() {
1240
  echo bp_the_topic_post_is_mine();
1241
  }
 
 
 
 
 
 
1242
  function bp_get_the_topic_post_is_mine() {
1243
  global $bp, $topic_template;
1244
 
1245
  return bp_loggedin_user_id() == $topic_template->post->poster_id;
1246
  }
1247
 
 
 
 
 
 
 
 
1248
  function bp_the_topic_post_admin_links( $args = '' ) {
1249
  echo bp_get_the_topic_post_admin_links( $args );
1250
  }
 
 
 
 
 
 
 
 
 
1251
  function bp_get_the_topic_post_admin_links( $args = '' ) {
1252
  global $topic_template;
1253
 
@@ -1273,23 +2115,46 @@ function bp_the_topic_post_admin_links( $args = '' ) {
1273
  return apply_filters( 'bp_get_the_topic_post_admin_links', implode( $separator, $links ), $links, $r );
1274
  }
1275
 
 
 
 
1276
  function bp_the_topic_post_edit_text() {
1277
  echo bp_get_the_topic_post_edit_text();
1278
  }
 
 
 
 
 
1279
  function bp_get_the_topic_post_edit_text() {
1280
  $post = bp_forums_get_post( bp_action_variable( 4 ) );
1281
  return apply_filters( 'bp_get_the_topic_post_edit_text', esc_attr( $post->post_text ) );
1282
  }
1283
 
 
 
 
1284
  function bp_the_topic_pagination() {
1285
  echo bp_get_the_topic_pagination();
1286
  }
 
 
 
 
 
1287
  function bp_get_the_topic_pagination() {
1288
  global $topic_template;
1289
 
1290
  return apply_filters( 'bp_get_the_topic_pagination', $topic_template->pag_links );
1291
  }
1292
 
 
 
 
 
 
 
 
1293
  function bp_the_topic_pagination_count() {
1294
  global $bp, $topic_template;
1295
 
@@ -1298,35 +2163,59 @@ function bp_the_topic_pagination_count() {
1298
  $to_num = bp_core_number_format( ( $start_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $start_num + ( $topic_template->pag_num - 1 ) );
1299
  $total = bp_core_number_format( $topic_template->total_post_count );
1300
 
1301
- echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %1$s to %2$s (%3$s total posts)', 'buddypress' ), $from_num, $to_num, $total ) );
1302
  }
1303
 
 
 
 
1304
  function bp_the_topic_is_last_page() {
1305
  echo bp_get_the_topic_is_last_page();
1306
  }
 
 
 
 
 
 
1307
  function bp_get_the_topic_is_last_page() {
1308
  global $topic_template;
1309
 
1310
  return apply_filters( 'bp_get_the_topic_is_last_page', $topic_template->pag_page == $topic_template->pag->total_pages );
1311
  }
1312
 
 
 
 
1313
  function bp_directory_forums_search_form() {
1314
- global $bp;
1315
-
1316
  $default_search_value = bp_get_search_default_text( 'forums' );
1317
- $search_value = !empty( $_REQUEST['fs'] ) ? stripslashes( $_REQUEST['fs'] ) : $default_search_value; ?>
1318
 
1319
- <form action="" method="get" id="search-forums-form">
1320
- <label><input type="text" name="s" id="forums_search" placeholder="<?php echo esc_attr( $search_value ); ?>" /></label>
1321
- <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ); ?>" />
1322
- </form>
1323
 
1324
- <?php
1325
  }
1326
 
 
 
 
 
 
 
 
1327
  function bp_forum_permalink( $forum_id = 0 ) {
1328
  echo bp_get_forum_permalink( $forum_id );
1329
  }
 
 
 
 
 
 
 
1330
  function bp_get_forum_permalink( $forum_id = 0 ) {
1331
  global $bp;
1332
 
@@ -1348,9 +2237,23 @@ function bp_forum_permalink( $forum_id = 0 ) {
1348
  return apply_filters( 'bp_get_forum_permalink', trailingslashit( $permalink ) );
1349
  }
1350
 
 
 
 
 
 
 
 
1351
  function bp_forum_name( $forum_id = 0 ) {
1352
  echo bp_get_forum_name( $forum_id );
1353
  }
 
 
 
 
 
 
 
1354
  function bp_get_forum_name( $forum_id = 0 ) {
1355
  global $bp;
1356
 
@@ -1366,6 +2269,20 @@ function bp_forum_name( $forum_id = 0 ) {
1366
  return false;
1367
  }
1368
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1369
  function bp_forums_tag_heat_map( $args = '' ) {
1370
  $defaults = array(
1371
  'smallest' => '10',
@@ -1381,21 +2298,20 @@ function bp_forums_tag_heat_map( $args = '' ) {
1381
  }
1382
 
1383
  /**
1384
- * Echo the current topic's tag list, comma-separated
1385
  *
1386
- * @package BuddyPress
1387
- * @since BuddyPress (1.5)
1388
  */
1389
  function bp_forum_topic_tag_list() {
1390
  echo bp_get_forum_topic_tag_list();
1391
  }
1392
  /**
1393
- * Get the current topic's tag list
1394
  *
1395
- * @package BuddyPress
1396
- * @since BuddyPress (1.5)
1397
  *
1398
- * @param string $format 'string' returns comma-separated string; otherwise returns array
 
1399
  * @return mixed $tags
1400
  */
1401
  function bp_get_forum_topic_tag_list( $format = 'string' ) {
@@ -1418,12 +2334,11 @@ function bp_forum_topic_tag_list() {
1418
  }
1419
 
1420
  /**
1421
- * Returns true if the current topic has tags
1422
  *
1423
- * @package BuddyPress
1424
- * @since BuddyPress (1.5)
1425
  *
1426
- * @return bool
1427
  */
1428
  function bp_forum_topic_has_tags() {
1429
  global $topic_template;
@@ -1436,32 +2351,72 @@ function bp_forum_topic_has_tags() {
1436
  return apply_filters( 'bp_forum_topic_has_tags', $has_tags );
1437
  }
1438
 
 
 
 
1439
  function bp_forum_action() {
1440
  echo bp_get_forum_action();
1441
  }
 
 
 
 
 
1442
  function bp_get_forum_action() {
1443
  global $topic_template;
1444
 
1445
  return apply_filters( 'bp_get_forum_action', bp_get_root_domain() . esc_attr( $_SERVER['REQUEST_URI'] ) );
1446
  }
1447
 
 
 
 
1448
  function bp_forum_topic_action() {
1449
  echo bp_get_forum_topic_action();
1450
  }
 
 
 
 
 
1451
  function bp_get_forum_topic_action() {
1452
  return apply_filters( 'bp_get_forum_topic_action', $_SERVER['REQUEST_URI'] );
1453
  }
1454
 
 
 
 
 
 
 
 
1455
  function bp_forum_topic_count_for_user( $user_id = 0 ) {
1456
  echo bp_get_forum_topic_count_for_user( $user_id );
1457
  }
 
 
 
 
 
1458
  function bp_get_forum_topic_count_for_user( $user_id = 0 ) {
1459
  return apply_filters( 'bp_get_forum_topic_count_for_user', bp_forums_total_topic_count_for_user( $user_id ) );
1460
  }
1461
 
 
 
 
 
 
 
 
1462
  function bp_forum_topic_count( $user_id = 0 ) {
1463
  echo bp_get_forum_topic_count( $user_id );
1464
  }
 
 
 
 
 
1465
  function bp_get_forum_topic_count( $user_id = 0 ) {
1466
  return apply_filters( 'bp_get_forum_topic_count', bp_forums_total_topic_count( $user_id ) );
1467
  }
1
  <?php
2
+ /**
3
+ * BuddyPress Forums Template Tags.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Forums
7
+ */
8
+
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
+ * Output the forums component slug.
14
  *
15
+ * @since BuddyPress (1.5.0)
 
 
16
  *
17
  * @uses bp_get_forums_slug()
18
  */
20
  echo bp_get_forums_slug();
21
  }
22
  /**
23
+ * Return the forums component slug.
24
  *
25
+ * @since BuddyPress (1.5.0)
26
+ *
27
+ * @return string Slug for the forums component.
28
  */
29
  function bp_get_forums_slug() {
30
  global $bp;
32
  }
33
 
34
  /**
35
+ * Output the forums component root slug.
36
  *
37
+ * @since BuddyPress (1.5.0)
 
 
38
  *
39
  * @uses bp_get_forums_root_slug()
40
  */
42
  echo bp_get_forums_root_slug();
43
  }
44
  /**
45
+ * Return the forums component root slug.
46
  *
47
+ * @since BuddyPress (1.5.0)
48
+ *
49
+ * @return string Root slug for the forums component.
50
  */
51
  function bp_get_forums_root_slug() {
52
  global $bp;
54
  }
55
 
56
  /**
57
+ * Output permalink for the forum directory.
58
+ *
59
+ * @since BuddyPress (1.5.0)
60
  *
 
 
 
61
  * @uses bp_get_forums_directory_permalink()
62
  */
63
  function bp_forums_directory_permalink() {
64
  echo bp_get_forums_directory_permalink();
65
  }
66
  /**
67
+ * Return permalink for the forum directory.
68
+ *
69
+ * @since BuddyPress (1.5.0)
70
  *
 
 
 
71
  * @uses apply_filters()
72
  * @uses traisingslashit()
73
  * @uses bp_get_root_domain()
74
  * @uses bp_get_forums_root_slug()
75
+ *
76
+ * @return string The permalink for the forums component directory.
77
  */
78
  function bp_get_forums_directory_permalink() {
79
  return apply_filters( 'bp_get_forums_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() ) );
80
  }
81
 
82
+ /**
83
+ * The main forums template loop class.
84
+ *
85
+ * Responsible for loading a group of forum topics into a loop for display.
86
+ */
87
  class BP_Forums_Template_Forum {
88
+ /**
89
+ * The loop iterator.
90
+ *
91
+ * @access public
92
+ * @var int
93
+ */
94
  var $current_topic = -1;
95
+
96
+ /**
97
+ * The number of topics returned by the paged query.
98
+ *
99
+ * @access public
100
+ * @var int
101
+ */
102
  var $topic_count;
103
+
104
+ /**
105
+ * Array of topics located by the query.
106
+ *
107
+ * @access public
108
+ * @var array
109
+ */
110
  var $topics;
111
+
112
+ /**
113
+ * The topic object currently being iterated on.
114
+ *
115
+ * @access public
116
+ * @var object
117
+ */
118
  var $topic;
119
 
120
+ /**
121
+ * The ID of the forum whose topics are being queried.
122
+ *
123
+ * @access public
124
+ * @var int
125
+ */
126
  var $forum_id;
127
 
128
+ /**
129
+ * A flag for whether the loop is currently being iterated.
130
+ *
131
+ * @access public
132
+ * @var bool
133
+ */
134
  var $in_the_loop;
135
 
136
+ /**
137
+ * The page number being requested.
138
+ *
139
+ * @access public
140
+ * @var public
141
+ */
142
  var $pag_page;
143
+
144
+ /**
145
+ * The number of items being requested per page.
146
+ *
147
+ * @access public
148
+ * @var public
149
+ */
150
  var $pag_num;
151
+
152
+ /**
153
+ * An HTML string containing pagination links.
154
+ *
155
+ * @access public
156
+ * @var string
157
+ */
158
  var $pag_links;
159
+
160
+ /**
161
+ * The total number of topics matching the query parameters.
162
+ *
163
+ * @access public
164
+ * @var int
165
+ */
166
  var $total_topic_count;
167
 
168
+ /**
169
+ * Whether requesting a single topic. Not currently used.
170
+ *
171
+ * @access public
172
+ * @var bool
173
+ */
174
  var $single_topic = false;
175
 
176
+ /**
177
+ * Term to sort by. Not currently used.
178
+ *
179
+ * @access public
180
+ * @var string
181
+ */
182
  var $sort_by;
183
+
184
+ /**
185
+ * Sort order. Not currently used.
186
+ *
187
+ * @access public
188
+ * @var string
189
+ */
190
  var $order;
191
 
192
+ /**
193
+ * Constructor method.
194
+ *
195
+ * @param string $type The 'type' is the sort order/kind. 'newest',
196
+ * 'popular', 'unreplied', 'tags'.
197
+ * @param int $forum_id The ID of the forum for which topics are being
198
+ * queried.
199
+ * @param int $user_id The ID of the user to whom topics should be
200
+ * limited. Pass false to remove this filter.
201
+ * @param int $page The number of the page being requested.
202
+ * @param int $per_page The number of items being requested perpage.
203
+ * @param string $no_stickies Requested sticky format.
204
+ * @param string $search_terms Filter results by a string.
205
+ * @param int $offset Optional. Offset results by a given numeric value.
206
+ * @param int $number Optional. Total number of items to retrieve.
207
+ */
208
  function __construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) {
209
  global $bp;
210
 
300
  }
301
  }
302
 
303
+ /**
304
+ * Whether there are topics available in the loop.
305
+ *
306
+ * @see bp_has_forum_topics()
307
+ *
308
+ * @return bool True if there are items in the loop, otherwise false.
309
+ */
310
  function has_topics() {
311
  if ( $this->topic_count )
312
  return true;
314
  return false;
315
  }
316
 
317
+ /**
318
+ * Set up the next topic and iterate index.
319
+ *
320
+ * @return object The next topic to iterate over.
321
+ */
322
  function next_topic() {
323
  $this->current_topic++;
324
  $this->topic = $this->topics[$this->current_topic];
326
  return $this->topic;
327
  }
328
 
329
+ /**
330
+ * Rewind the topics and reset topic index.
331
+ */
332
  function rewind_topics() {
333
  $this->current_topic = -1;
334
  if ( $this->topic_count > 0 ) {
336
  }
337
  }
338
 
339
+ /**
340
+ * Whether there are blogs left in the loop to iterate over.
341
+ *
342
+ * This method is used by {@link bp_forum_topics()} as part of the while loop
343
+ * that controls iteration inside the blogs loop, eg:
344
+ * while ( bp_forum_topics() ) { ...
345
+ *
346
+ * @see bp_forum_topics()
347
+ *
348
+ * @return bool True if there are more topics to show, otherwise false.
349
+ */
350
  function user_topics() {
351
  if ( $this->current_topic + 1 < $this->topic_count ) {
352
  return true;
360
  return false;
361
  }
362
 
363
+ /**
364
+ * Set up the current topic in the loop.
365
+ *
366
+ * @see bp_the_forum_topic()
367
+ */
368
  function the_topic() {
369
  global $topic;
370
 
380
  /**
381
  * Initiate the forum topics loop.
382
  *
383
+ * Like other BuddyPress custom loops, the default arguments for this function
384
+ * are determined dynamically, depending on your current page. All of these
385
+ * $defaults can be overridden in the $args parameter.
386
  *
387
+ * @uses apply_filters() Filter 'bp_has_topics' to manipulate the
388
+ * $forums_template global before it's rendered, or to modify the value
389
+ * of has_topics().
390
  *
391
+ * @param array $args {
392
+ * Arguments for limiting the contents of the forum topics loop.
393
+ *
394
+ * @type string $type The 'type' is the sort order/kind. 'newest',
395
+ * 'popular', 'unreplied', 'tags'. Default: 'newest'.
396
+ * @type int $forum_id The ID of the forum for which topics are being
397
+ * queried. Default: the ID of the forum belonging to the current
398
+ * group, if available.
399
+ * @type int $user_id The ID of a user to whom to limit results. If viewing
400
+ * a member's profile, defaults to that member's ID; otherwise
401
+ * defaults to 0.
402
+ * @type int $page The number of the page being requested. Default: 1, or
403
+ * the value of $_GET['p'].
404
+ * @type int $per_pag The number items to return per page. Default: 20, or
405
+ * the value of $_GET['n'].
406
+ * @type int $max Optional. Max records to return. Default: false (no max).
407
+ * @type int $number Optional. Number of records to return. Default: false.
408
+ * @type int $offset Optional. Offset results by a given value.
409
+ * Default: false.
410
+ * @type string $search_terms Optional. A string to which results should be
411
+ * limited. Default: false, or the value of $_GET['fs'].
412
+ * @type string|bool $do_stickies Whether to move stickies to the top of
413
+ * the sort order. Default: true if looking at a group forum,
414
+ * otherwise false.
415
+ * }
416
+ * @return bool True when forum topics are found corresponding to the args,
417
+ * false otherwise.
418
  */
419
  function bp_has_forum_topics( $args = '' ) {
420
  global $forum_template, $bp;
582
  return apply_filters( 'bp_has_topics', $forum_template->has_topics(), $forum_template );
583
  }
584
 
585
+ /**
586
+ * Determine whether there are still topics left in the loop.
587
+ *
588
+ * @global BP_Forums_Template_Forum $forum_template Template global.
589
+ *
590
+ * @return bool Returns true when topics are found.
591
+ */
592
  function bp_forum_topics() {
593
  global $forum_template;
594
  return $forum_template->user_topics();
595
  }
596
 
597
+ /**
598
+ * Get the current topic object in the loop.
599
+ *
600
+ * @global BP_Forums_Template_Forum $forum_template Template global.
601
+ *
602
+ * @return object The current topic object.
603
+ */
604
  function bp_the_forum_topic() {
605
  global $forum_template;
606
  return $forum_template->the_topic();
607
  }
608
 
609
+ /**
610
+ * Output the ID of the current topic in the loop.
611
+ */
612
  function bp_the_topic_id() {
613
  echo bp_get_the_topic_id();
614
  }
615
+ /**
616
+ * Return the ID of the current topic in the loop.
617
+ *
618
+ * @return int ID of the current topic in the loop.
619
+ */
620
  function bp_get_the_topic_id() {
621
  global $forum_template;
622
 
623
  return apply_filters( 'bp_get_the_topic_id', $forum_template->topic->topic_id );
624
  }
625
 
626
+ /**
627
+ * Output the title of the current topic in the loop.
628
+ */
629
  function bp_the_topic_title() {
630
  echo bp_get_the_topic_title();
631
  }
632
+ /**
633
+ * Return the title of the current topic in the loop.
634
+ *
635
+ * @return string Title of the current topic in the loop.
636
+ */
637
  function bp_get_the_topic_title() {
638
  global $forum_template;
639
 
640
  return apply_filters( 'bp_get_the_topic_title', stripslashes( $forum_template->topic->topic_title ) );
641
  }
642
 
643
+ /**
644
+ * Output the slug of the current topic in the loop.
645
+ */
646
  function bp_the_topic_slug() {
647
  echo bp_get_the_topic_slug();
648
  }
649
+ /**
650
+ * Return the slug of the current topic in the loop.
651
+ *
652
+ * @return string Slug of the current topic in the loop.
653
+ */
654
  function bp_get_the_topic_slug() {
655
  global $forum_template;
656
 
657
  return apply_filters( 'bp_get_the_topic_slug', $forum_template->topic->topic_slug );
658
  }
659
 
660
+ /**
661
+ * Output the text of the first post in the current topic in the loop.
662
+ */
663
  function bp_the_topic_text() {
664
  echo bp_get_the_topic_text();
665
  }
666
+ /**
667
+ * Return the text of the first post in the current topic in the loop.
668
+ *
669
+ * @return string Text of the first post in the current topic.
670
+ */
671
  function bp_get_the_topic_text() {
672
  global $forum_template;
673
 
675
  return apply_filters( 'bp_get_the_topic_text', esc_attr( $post->post_text ) );
676
  }
677
 
678
+ /**
679
+ * Output the ID of the user who posted the current topic in the loop.
680
+ */
681
  function bp_the_topic_poster_id() {
682
  echo bp_get_the_topic_poster_id();
683
  }
684
+ /**
685
+ * Return the ID of the user who posted the current topic in the loop.
686
+ *
687
+ * @return int ID of the user who posted the current topic.
688
+ */
689
  function bp_get_the_topic_poster_id() {
690
  global $forum_template;
691
 
692
  return apply_filters( 'bp_get_the_topic_poster_id', $forum_template->topic->topic_poster );
693
  }
694
 
695
+ /**
696
+ * Output the avatar of the user who posted the current topic in the loop.
697
+ *
698
+ * @see bp_get_the_topic_poster_avatar() for a description of arguments.
699
+ *
700
+ * @param array $args See {@link bp_get_the_topic_poster_avatar()}.
701
+ */
702
  function bp_the_topic_poster_avatar( $args = '' ) {
703
  echo bp_get_the_topic_poster_avatar( $args );
704
  }
705
+ /**
706
+ * Return the avatar of the user who posted the current topic in the loop.
707
+ *
708
+ * @param array $args {
709
+ * Arguments for building the avatar.
710
+ * @type string $type Avatar type. 'thumb' or 'full'. Default:
711
+ * 'thumb'.
712
+ * @type int $width Width of the avatar, in pixels. Default: the
713
+ * width corresponding to $type.
714
+ * See {@link bp_core_fetch_avatar()}.
715
+ * @type int $height Height of the avatar, in pixels. Default: the
716
+ * height corresponding to $type.
717
+ * See {@link bp_core_fetch_avatar()}.
718
+ * @type string $alt The text of the image's 'alt' attribute.
719
+ * Default: 'Profile picture of [user name]'.
720
+ * }
721
+ * @return string HTML of user avatar.
722
+ */
723
  function bp_get_the_topic_poster_avatar( $args = '' ) {
724
  global $forum_template;
725
 
736
  return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
737
  }
738
 
739
+ /**
740
+ * Output the name of the user who posted the current topic in the loop.
741
+ */
742
  function bp_the_topic_poster_name() {
743
  echo bp_get_the_topic_poster_name();
744
  }
745
+ /**
746
+ * Return the name of the user who posted the current topic in the loop.
747
+ *
748
+ * @return string Name of the user who posted the current topic.
749
+ */
750
  function bp_get_the_topic_poster_name() {
751
  global $forum_template;
752
 
758
  return apply_filters( 'bp_get_the_topic_poster_name', $name );
759
  }
760
 
761
+ /**
762
+ * Output the ID of the object associated with the current topic in the loop.
763
+ */
764
  function bp_the_topic_object_id() {
765
  echo bp_get_the_topic_object_id();
766
  }
767
+ /**
768
+ * Return the ID of the object associated with the current topic in the loop.
769
+ *
770
+ * Objects are things like associated groups.
771
+ *
772
+ * @return int ID of the associated object.
773
+ */
774
  function bp_get_the_topic_object_id() {
775
  global $forum_template;
776
 
777
  return apply_filters( 'bp_get_the_topic_object_id', $forum_template->topic->object_id );
778
  }
779
 
780
+ /**
781
+ * Output the name of the object associated with the current topic in the loop.
782
+ */
783
  function bp_the_topic_object_name() {
784
  echo bp_get_the_topic_object_name();
785
  }
786
+ /**
787
+ * Return the name of the object associated with the current topic in the loop.
788
+ *
789
+ * Objects are things like groups. So this function would return the
790
+ * name of the group associated with the forum topic, if it exists.
791
+ *
792
+ * @return string Object name.
793
+ */
794
  function bp_get_the_topic_object_name() {
795
  global $forum_template;
796
 
802
  return apply_filters( 'bp_get_the_topic_object_name', $retval );
803
  }
804
 
805
+ /**
806
+ * Output the slug of the object associated with the current topic in the loop.
807
+ */
808
  function bp_the_topic_object_slug() {
809
  echo bp_get_the_topic_object_slug();
810
  }
811
+ /**
812
+ * Return the slug of the object associated with the current topic in the loop.
813
+ *
814
+ * Objects are things like groups. So this function would return the
815
+ * slug of the group associated with the forum topic, if it exists.
816
+ *
817
+ * @return string Object slug.
818
+ */
819
  function bp_get_the_topic_object_slug() {
820
  global $forum_template;
821
 
822
  return apply_filters( 'bp_get_the_topic_object_slug', $forum_template->topic->object_slug );
823
  }
824
 
825
+ /**
826
+ * Output the permalink of the object associated with the current topic in the loop.
827
+ */
828
  function bp_the_topic_object_permalink() {
829
  echo bp_get_the_topic_object_permalink();
830
  }
831
+ /**
832
+ * Return the permalink of the object associated with the current topic in the loop.
833
+ *
834
+ * Objects are things like groups. So this function would return the
835
+ * permalink of the group associated with the forum topic, if it exists.
836
+ *
837
+ * @return string Object permalink.
838
+ */
839
  function bp_get_the_topic_object_permalink() {
840
 
841
  // Currently this will only work with group forums, extended support in the future
847
  return apply_filters( 'bp_get_the_topic_object_permalink', $permalink );
848
  }
849
 
850
+ /**
851
+ * Output the linked name of the user who last posted to the current topic in the loop.
852
+ */
853
  function bp_the_topic_last_poster_name() {
854
  echo bp_get_the_topic_last_poster_name();
855
  }
856
+ /**
857
+ * Return the linked name of the user who last posted to the current topic in the loop.
858
+ *
859
+ * @return string HTML link to the profile of the user who last posted
860
+ * to the current topic.
861
+ */
862
  function bp_get_the_topic_last_poster_name() {
863
  global $forum_template;
864
 
872
  return apply_filters( 'bp_get_the_topic_last_poster_name', '<a href="' . $domain . '">' . $forum_template->topic->topic_last_poster_displayname . '</a>' );
873
  }
874
 
875
+ /**
876
+ * Output the permalink of the object associated with the current topic in the loop.
877
+ *
878
+ * @see bp_get_the_topic_object_avatar() for description of arguments.
879
+ *
880
+ * @param array $args See {@bp_get_the_topic_object_avatar()}.
881
+ */
882
  function bp_the_topic_object_avatar( $args = '' ) {
883
  echo bp_get_the_topic_object_avatar( $args );
884
  }
885
+ /**
886
+ * Return the avatar of the object associated with the current topic in the loop.
887
+ *
888
+ * Objects are things like groups. So this function would return the
889
+ * avatar of the group associated with the forum topic, if it exists.
890
+ *
891
+ * @param array $args {
892
+ * Arguments for building the avatar.
893
+ * @type string $type Avatar type. 'thumb' or 'full'. Default:
894
+ * 'thumb'.
895
+ * @type int $width Width of the avatar, in pixels. Default: the
896
+ * width corresponding to $type.
897
+ * See {@link bp_core_fetch_avatar()}.
898
+ * @type int $height Height of the avatar, in pixels. Default:
899
+ * the height corresponding to $type.
900
+ * See {@link bp_core_fetch_avatar()}.
901
+ * @type string $alt The text of the image's 'alt' attribute.
902
+ * Default: 'Group logo for [group name]'.
903
+ * }
904
+ * @return string Object avatar.
905
+ */
906
  function bp_get_the_topic_object_avatar( $args = '' ) {
907
  global $forum_template;
908
 
922
  return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
923
  }
924
 
925
+ /**
926
+ * Output the avatar for the user who last posted to the current topic in the loop.
927
+ *
928
+ * @see bp_get_the_topic_last_poster_avatar() for description of arguments.
929
+ *
930
+ * @param array $args See {@bp_get_the_topic_last_poster_avatar()}.
931
+ */
932
  function bp_the_topic_last_poster_avatar( $args = '' ) {
933
  echo bp_get_the_topic_last_poster_avatar( $args );
934
  }
935
+ /**
936
+ * Return the avatar for the user who last posted to the current topic in the loop.
937
+ *
938
+ * @param array $args {
939
+ * Arguments for building the avatar.
940
+ * @type string $type Avatar type. 'thumb' or 'full'. Default:
941
+ * 'thumb'.
942
+ * @type int $width Width of the avatar, in pixels. Default: the
943
+ * width corresponding to $type.
944
+ * See {@link bp_core_fetch_avatar()}.
945
+ * @type int $height Height of the avatar, in pixels. Default:
946
+ * the height corresponding to $type.
947
+ * See {@link bp_core_fetch_avatar()}.
948
+ * @type string $alt The text of the image's 'alt' attribute.
949
+ * Default: 'Profile picture of [group name]'.
950
+ * }
951
+ * @return string User avatar.
952
+ */
953
  function bp_get_the_topic_last_poster_avatar( $args = '' ) {
954
  global $forum_template;
955
 
966
  return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'email' => $forum_template->topic->topic_last_poster_email, 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
967
  }
968
 
969
+ /**
970
+ * Output the start time of the current topic in the loop.
971
+ */
972
  function bp_the_topic_start_time() {
973
  echo bp_get_the_topic_start_time();
974
  }
975
+ /**
976
+ * Return the start time of the current topic in the loop.
977
+ *
978
+ * @return string Start time of the current topic.
979
+ */
980
  function bp_get_the_topic_start_time() {
981
  global $forum_template;
982
 
983
  return apply_filters( 'bp_get_the_topic_start_time', $forum_template->topic->topic_start_time );
984
  }
985
 
986
+ /**
987
+ * Output the topic time of the current topic in the loop.
988
+ */
989
  function bp_the_topic_time() {
990
  echo bp_get_the_topic_time();
991
  }
992
+ /**
993
+ * Return the topic time of the current topic in the loop.
994
+ *
995
+ * @return string Topic time of the current topic.
996
+ */
997
  function bp_get_the_topic_time() {
998
  global $forum_template;
999
 
1000
  return apply_filters( 'bp_get_the_topic_time', $forum_template->topic->topic_time );
1001
  }
1002
 
1003
+ /**
1004
+ * Output the ID of the forum associated with the current topic in the loop.
1005
+ */
1006
  function bp_the_topic_forum_id() {
1007
  echo bp_get_the_topic_forum_id();
1008
  }
1009
+ /**
1010
+ * Return the ID of the forum associated with the current topic in the loop.
1011
+ *
1012
+ * @return int ID of the forum associated with the current topic.
1013
+ */
1014
  function bp_get_the_topic_forum_id() {
1015
  global $forum_template;
1016
 
1017
  return apply_filters( 'bp_get_the_topic_forum_id', $forum_template->topic->forum_id );
1018
  }
1019
 
1020
+ /**
1021
+ * Output the status of the current topic in the loop.
1022
+ */
1023
  function bp_the_topic_status() {
1024
  echo bp_get_the_topic_status();
1025
  }
1026
+ /**
1027
+ * Return the status of the current topic in the loop.
1028
+ *
1029
+ * @return string Status of the current topic.
1030
+ */
1031
  function bp_get_the_topic_status() {
1032
  global $forum_template;
1033
 
1034
  return apply_filters( 'bp_get_the_topic_status', $forum_template->topic->topic_status );
1035
  }
1036
 
1037
+ /**
1038
+ * Output whether the current topic in the loop is open.
1039
+ */
1040
  function bp_the_topic_is_topic_open() {
1041
  echo bp_get_the_topic_is_topic_open();
1042
  }
1043
+ /**
1044
+ * Return whether the current topic in the loop is open.
1045
+ *
1046
+ * @return unknown
1047
+ */
1048
  function bp_get_the_topic_is_topic_open() {
1049
  global $forum_template;
1050
 
1051
  return apply_filters( 'bp_get_the_topic_is_topic_open', $forum_template->topic->topic_open );
1052
  }
1053
 
1054
+ /**
1055
+ * Output the ID of the last post in the current topic in the loop.
1056
+ */
1057
  function bp_the_topic_last_post_id() {
1058
  echo bp_get_the_topic_last_post_id();
1059
  }
1060
+ /**
1061
+ * Return the ID of the last post in the current topic in the loop.
1062
+ *
1063
+ * @return int ID of the last post in the current topic.
1064
+ */
1065
  function bp_get_the_topic_last_post_id() {
1066
  global $forum_template;
1067
 
1068
  return apply_filters( 'bp_get_the_topic_last_post_id', $forum_template->topic->topic_last_post_id );
1069
  }
1070
 
1071
+ /**
1072
+ * Output whether the current topic in the loop is sticky.
1073
+ */
1074
  function bp_the_topic_is_sticky() {
1075
  echo bp_get_the_topic_is_sticky();
1076
  }
1077
+ /**
1078
+ * Return whether the current topic in the loop is sticky.
1079
+ *
1080
+ * @return unknown
1081
+ */
1082
  function bp_get_the_topic_is_sticky() {
1083
  global $forum_template;
1084
 
1085
  return apply_filters( 'bp_get_the_topic_is_sticky', $forum_template->topic->topic_sticky );
1086
  }
1087
 
1088
+ /**
1089
+ * Output a 'x posts' string with the number of posts in the current topic.
1090
+ */
1091
  function bp_the_topic_total_post_count() {
1092
  echo bp_get_the_topic_total_post_count();
1093
  }
1094
+ /**
1095
+ * Return a 'x posts' string with the number of posts in the current topic.
1096
+ *
1097
+ * @return string String of the form 'x posts'.
1098
+ */
1099
  function bp_get_the_topic_total_post_count() {
1100
  global $forum_template;
1101
 
1105
  return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) );
1106
  }
1107
 
1108
+ /**
1109
+ * Output the total number of posts in the current topic in the loop.
1110
+ */
1111
  function bp_the_topic_total_posts() {
1112
  echo bp_get_the_topic_total_posts();
1113
  }
1114
+ /**
1115
+ * Return the total number of posts in the current topic in the loop.
1116
+ *
1117
+ * @return int Total number of posts in the current topic.
1118
+ */
1119
  function bp_get_the_topic_total_posts() {
1120
  global $forum_template;
1121
 
1122
  return apply_filters( 'bp_get_the_topic_total_posts', $forum_template->topic->topic_posts );
1123
  }
1124
 
1125
+ /**
1126
+ * Output the tag count for the current topic in the loop.
1127
+ */
1128
  function bp_the_topic_tag_count() {
1129
  echo bp_get_the_topic_tag_count();
1130
  }
1131
+ /**
1132
+ * Return the tag count for the current topic in the loop.
1133
+ *
1134
+ * @return int Tag count for the current topic.
1135
+ */
1136
  function bp_get_the_topic_tag_count() {
1137
  global $forum_template;
1138
 
1139
  return apply_filters( 'bp_get_the_topic_tag_count', $forum_template->topic->tag_count );
1140
  }
1141
 
1142
+ /**
1143
+ * Output the permalink of the current topic in the loop.
1144
+ */
1145
  function bp_the_topic_permalink() {
1146
  echo bp_get_the_topic_permalink();
1147
  }
1148
+ /**
1149
+ * Return the permalink for the current topic in the loop.
1150
+ *
1151
+ * @return string Permalink for the current topic.
1152
+ */
1153
  function bp_get_the_topic_permalink() {
1154
  global $forum_template, $bp;
1155
 
1173
  return apply_filters( 'bp_get_the_topic_permalink', trailingslashit( $permalink . 'topic/' . $forum_template->topic->topic_slug ) );
1174
  }
1175
 
1176
+ /**
1177
+ * Output a 'since' string describing when the current topic was created.
1178
+ */
1179
  function bp_the_topic_time_since_created() {
1180
  echo bp_get_the_topic_time_since_created();
1181
  }
1182
+ /**
1183
+ * Return a 'since' string describing when the current topic was created.
1184
+ *
1185
+ * @see bp_core_time_since() for a description of return value.
1186
+ *
1187
+ * @return string
1188
+ */
1189
  function bp_get_the_topic_time_since_created() {
1190
  global $forum_template;
1191
 
1192
  return apply_filters( 'bp_get_the_topic_time_since_created', bp_core_time_since( strtotime( $forum_template->topic->topic_start_time ) ) );
1193
  }
1194
 
1195
+ /**
1196
+ * Output an excerpt from the latest post of the current topic in the loop.
1197
+ */
1198
  function bp_the_topic_latest_post_excerpt( $args = '' ) {
1199
  echo bp_get_the_topic_latest_post_excerpt( $args );
1200
  }
1201
+ /**
1202
+ * Return an excerpt from the latest post of the current topic in the loop.
1203
+ *
1204
+ * @param array $args {
1205
+ * @type int $length The length of the excerpted text. Default: 225.
1206
+ * }
1207
+ * @return string Post excerpt.
1208
+ */
1209
  function bp_get_the_topic_latest_post_excerpt( $args = '' ) {
1210
  global $forum_template;
1211
 
1222
  return apply_filters( 'bp_get_the_topic_latest_post_excerpt', $post, $length );
1223
  }
1224
 
1225
+ /**
1226
+ * Output a 'since' string describing when the last post in the current topic was created.
1227
+ */
1228
  function bp_the_topic_time_since_last_post() {
1229
  echo bp_get_the_topic_time_since_last_post();
1230
  }
1231
+ /**
1232
+ * Return a 'since' string describing when the last post in the current topic was created.
1233
+ *
1234
+ * @see bp_core_time_since() for a description of return value.
1235
+ *
1236
+ * @return string
1237
+ */
1238
  function bp_get_the_topic_time_since_last_post() {
1239
  global $forum_template;
1240
 
1241
  return apply_filters( 'bp_get_the_topic_time_since_last_post', bp_core_time_since( strtotime( $forum_template->topic->topic_time ) ) );
1242
  }
1243
 
1244
+ /**
1245
+ * Output whether the current topic in the loop belongs to the logged-in user.
1246
+ */
1247
  function bp_the_topic_is_mine() {
1248
  echo bp_get_the_topic_is_mine();
1249
  }
1250
+ /**
1251
+ * Does the current topic belong to the logged-in user?
1252
+ *
1253
+ * @return bool True if the current topic in the loop was created by
1254
+ * the logged-in user, otherwise false.
1255
+ */
1256
  function bp_get_the_topic_is_mine() {
1257
  global $forum_template;
1258
 
1259
  return bp_loggedin_user_id() == $forum_template->topic->topic_poster;
1260
  }
1261
 
1262
+ /**
1263
+ * Output the admin links for the current topic in the loop.
1264
+ *
1265
+ * @see bp_get_the_topic_admin_links() for a description of arguments.
1266
+ *
1267
+ * @param array $args See {@link bp_get_the_topic_admin_links()}.
1268
+ */
1269
+ function bp_the_topic_admin_links( $args = '' ) {
1270
+ echo bp_get_the_topic_admin_links( $args );
1271
+ }
1272
+ /**
1273
+ * Return the admin links for the current topic in the loop.
1274
+ *
1275
+ * @param array $args {
1276
+ * @type string $seperator The character to use when separating
1277
+ * links. Default: '|'.
1278
+ * }
1279
+ * @return HTML string containing the admin links for the current topic.
1280
+ */
1281
  function bp_get_the_topic_admin_links( $args = '' ) {
1282
  global $forum_template;
1283
 
1307
  return implode( ' ' . $seperator . ' ', (array) $links );
1308
  }
1309
 
1310
+ /**
1311
+ * Output the CSS class for the current topic in the loop.
1312
+ */
1313
  function bp_the_topic_css_class() {
1314
  echo bp_get_the_topic_css_class();
1315
  }
1316
+ /**
1317
+ * Return the CSS class for the current topic in the loop.
1318
+ *
1319
+ * This class may contain keywords like 'alt', 'sticky', or 'closed',
1320
+ * based on context.
1321
+ *
1322
+ * @return string Contents of the 'class' attribute.
1323
+ */
1324
  function bp_get_the_topic_css_class() {
1325
  global $forum_template;
1326
 
1338
  return apply_filters( 'bp_get_the_topic_css_class', trim( $class ) );
1339
  }
1340
 
1341
+ /**
1342
+ * Output the permalink to the 'personal' topics tab.
1343
+ */
1344
  function bp_my_forum_topics_link() {
1345
  echo bp_get_my_forum_topics_link();
1346
  }
1347
+ /**
1348
+ * Return the permalink to the 'personal' topics tab.
1349
+ *
1350
+ * @return string Link to the 'personal' topics tab.
1351
+ */
1352
  function bp_get_my_forum_topics_link() {
1353
  global $bp;
1354
 
1355
  return apply_filters( 'bp_get_my_forum_topics_link', bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/personal/' );
1356
  }
1357
 
1358
+ /**
1359
+ * Output the permalink to the 'unreplied' topics tab.
1360
+ */
1361
  function bp_unreplied_forum_topics_link() {
1362
  echo bp_get_unreplied_forum_topics_link();
1363
  }
1364
+ /**
1365
+ * Return the permalink to the 'unreplied' topics tab.
1366
+ *
1367
+ * @return string Link to the 'unreplied' topics tab.
1368
+ */
1369
  function bp_get_unreplied_forum_topics_link() {
1370
  global $bp;
1371
 
1372
  return apply_filters( 'bp_get_unreplied_forum_topics_link', bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/unreplied/' );
1373
  }
1374
 
1375
+ /**
1376
+ * Output the permalink to the 'popular' topics tab.
1377
+ */
1378
  function bp_popular_forum_topics_link() {
1379
  echo bp_get_popular_forum_topics_link();
1380
  }
1381
+ /**
1382
+ * Return the permalink to the 'popular' topics tab.
1383
+ *
1384
+ * @return string Link to the 'popular' topics tab.
1385
+ */
1386
  function bp_get_popular_forum_topics_link() {
1387
  global $bp;
1388
 
1389
  return apply_filters( 'bp_get_popular_forum_topics_link', bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/popular/' );
1390
  }
1391
 
1392
+ /**
1393
+ * Output the link to the forums directory.
1394
+ */
1395
  function bp_newest_forum_topics_link() {
1396
  echo bp_get_newest_forum_topics_link();
1397
  }
1398
+ /**
1399
+ * Return the link to the forums directory.
1400
+ *
1401
+ * @return string Link to the forums directory.
1402
+ */
1403
  function bp_get_newest_forum_topics_link() {
1404
  global $bp;
1405
 
1406
  return apply_filters( 'bp_get_newest_forum_topics_link', bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/' );
1407
  }
1408
 
1409
+ /**
1410
+ * Output the currently viewed topic list type.
1411
+ */
1412
  function bp_forum_topic_type() {
1413
  echo bp_get_forum_topic_type();
1414
  }
1415
+ /**
1416
+ * Return the currently viewed topic list type.
1417
+ *
1418
+ * Eg, 'newest', 'popular', etc.
1419
+ *
1420
+ * @return string Type of the currently viewed topic list.
1421
+ */
1422
  function bp_get_forum_topic_type() {
1423
  global $bp;
1424
 
1429
  }
1430
 
1431
  /**
1432
+ * Output the value of bp_get_forum_topic_new_reply_link().
1433
  *
1434
+ * @since BuddyPress (1.5.0)
 
1435
  */
1436
  function bp_forum_topic_new_reply_link() {
1437
  echo bp_get_forum_topic_new_reply_link();
1438
  }
1439
  /**
1440
+ * Return the permalink for the New Reply button at the top of forum topics.
1441
  *
1442
+ * @since BuddyPress (1.5.0)
 
1443
  *
1444
+ * @uses apply_filters() Filter bp_get_forum_topic_new_reply_link to
1445
+ * modify.
1446
+ * @return string The URL for the New Reply link.
1447
  */
1448
  function bp_get_forum_topic_new_reply_link() {
1449
  global $topic_template;
1464
  }
1465
 
1466
  /**
1467
+ * Output the currently viewed tag name.
1468
  *
 
1469
  * @todo Deprecate?
1470
  */
1471
  function bp_forums_tag_name() {
1472
  echo bp_get_forums_tag_name();
1473
  }
1474
  /**
1475
+ * Return the currently viewed tag name.
1476
  *
 
1477
  * @todo Deprecate? Seems unused
1478
  */
1479
  function bp_get_forums_tag_name() {
1482
  return apply_filters( 'bp_get_forums_tag_name', $tag_name );
1483
  }
1484
 
1485
+ /**
1486
+ * Output the pagination links for the current topic list.
1487
+ */
1488
  function bp_forum_pagination() {
1489
  echo bp_get_forum_pagination();
1490
  }
1491
+ /**
1492
+ * Return the pagination links for the current topic list.
1493
+ *
1494
+ * @return string HTML pagination links.
1495
+ */
1496
  function bp_get_forum_pagination() {
1497
  global $forum_template;
1498
 
1499
  return apply_filters( 'bp_get_forum_pagination', $forum_template->pag_links );
1500
  }
1501
 
1502
+ /**
1503
+ * Output the pagination count for the current topic list.
1504
+ */
1505
  function bp_forum_pagination_count() {
1506
  echo bp_get_forum_pagination_count();
1507
  }
1508
+ /**
1509
+ * Return the pagination count for the current topic list.
1510
+ *
1511
+ * The "count" is a string of the form "Viewing x of y topics".
1512
+ *
1513
+ * @return string
1514
+ */
1515
  function bp_get_forum_pagination_count() {
1516
  global $bp, $forum_template;
1517
 
1524
  if ( 'tags' == $forum_template->type && !empty( $forum_template->search_terms ) )
1525
  $pag_filter = sprintf( __( ' matching tag "%s"', 'buddypress' ), $forum_template->search_terms );
1526
 
1527
+ return apply_filters( 'bp_get_forum_pagination_count', sprintf( _n( 'Viewing topic %s to %s (of %d topic%s)', 'Viewing topic %s to %s (of %d total topics%s)', $total, 'buddypress' ), $from_num, $to_num, $total, $pag_filter ), $from_num, $to_num, $total );
1528
  }
1529
 
1530
+ /**
1531
+ * Are we currently on an Edit Topic screen?
1532
+ *
1533
+ * @return bool True if currently editing a topic, otherwise false.
1534
+ */
1535
  function bp_is_edit_topic() {
1536
  global $bp;
1537
 
1541
  return true;
1542
  }
1543
 
1544
+ /**
1545
+ * The single forum topic template loop class.
1546
+ *
1547
+ * Responsible for loading a topic's posts into a loop for display.
1548
+ */
1549
  class BP_Forums_Template_Topic {
1550
+ /**
1551
+ * The loop iterator.
1552
+ *
1553
+ * @access public
1554
+ * @var int
1555
+ */
1556
  var $current_post = -1;
1557
+
1558
+ /**
1559
+ * The number of posts returned by the paged query.
1560
+ *
1561
+ * @access public
1562
+ * @var int
1563
+ */
1564
  var $post_count;
1565
+
1566
+ /**
1567
+ * Array of posts located by the query.
1568
+ *
1569
+ * @access public
1570
+ * @var array
1571
+ */
1572
  var $posts;
1573
+
1574
+ /**
1575
+ * The post object currently being iterated on.
1576
+ *
1577
+ * @access public
1578
+ * @var object
1579
+ */
1580
  var $post;
1581
 
1582
+ /**
1583
+ * The ID of the forum whose topic is being queried.
1584
+ *
1585
+ * @access public
1586
+ * @var int
1587
+ */
1588
  var $forum_id;
1589
+
1590
+ /**
1591
+ * The ID of the topic whose posts are being queried.
1592
+ *
1593
+ * @access public
1594
+ * @var int
1595
+ */
1596
  var $topic_id;
1597
+
1598
+ /**
1599
+ * The topic object to which the posts belong.
1600
+ *
1601
+ * @access public
1602
+ * @var object
1603
+ */
1604
  var $topic;
1605
 
1606
+ /**
1607
+ * A flag for whether the loop is currently being iterated.
1608
+ *
1609
+ * @access public
1610
+ * @var bool
1611
+ */
1612
  var $in_the_loop;
1613
 
1614
  /**
1615
+ * Contains a 'total_pages' property holding total number of pages in
1616
+ * this loop.
1617
  *
1618
+ * @since BuddyPress (1.2.0)
1619
  * @var stdClass
1620
  */
1621
  public $pag;
1622
 
1623
+ /**
1624
+ * The page number being requested.
1625
+ *
1626
+ * @access public
1627
+ * @var public
1628
+ */
1629
  var $pag_page;
1630
+
1631
+ /**
1632
+ * The number of items being requested per page.
1633
+ *
1634
+ * @access public
1635
+ * @var public
1636
+ */
1637
  var $pag_num;
1638
+
1639
+ /**
1640
+ * An HTML string containing pagination links.
1641
+ *
1642
+ * @access public
1643
+ * @var string
1644
+ */
1645
  var $pag_links;
1646
+
1647
+ /**
1648
+ * The total number of posts matching the query parameters.
1649
+ *
1650
+ * @access public
1651
+ * @var int
1652
+ */
1653
  var $total_post_count;
1654
 
1655
+ /**
1656
+ * Whether requesting a single topic. Not currently used.
1657
+ *
1658
+ * @access public
1659
+ * @var bool
1660
+ */
1661
  var $single_post = false;
1662
 
1663
+ /**
1664
+ * Term to sort by.
1665
+ *
1666
+ * @access public
1667
+ * @var string
1668
+ */
1669
  var $sort_by;
1670
+
1671
+ /**
1672
+ * Sort order.
1673
+ *
1674
+ * @access public
1675
+ * @var string
1676
+ */
1677
  var $order;
1678
 
1679
+ /**
1680
+ * Constructor method.
1681
+ *
1682
+ * @param int $topic_id ID of the topic whose posts are being requested.
1683
+ * @param int $per_page Number of items to return per page.
1684
+ * @param int $max Max records to return.
1685
+ * @param string $order Direction to order results.
1686
+ */
1687
  function __construct( $topic_id, $per_page, $max, $order ) {
1688
  global $bp, $current_user, $forum_template;
1689
 
1744
  }
1745
  }
1746
 
1747
+ /**
1748
+ * Whether there are posts available in the loop.
1749
+ *
1750
+ * @see bp_has_forum_topic_posts()
1751
+ *
1752
+ * @return bool True if there are items in the loop, otherwise false.
1753
+ */
1754
  function has_posts() {
1755
  if ( $this->post_count )
1756
  return true;
1758
  return false;
1759
  }
1760
 
1761
+ /**
1762
+ * Set up the next post and iterate index.
1763
+ *
1764
+ * @return object The next post to iterate over.
1765
+ */
1766
  function next_post() {
1767
  $this->current_post++;
1768
  $this->post = $this->posts[$this->current_post];
1770
  return $this->post;
1771
  }
1772
 
1773
+ /**
1774
+ * Rewind the posts and reset post index.
1775
+ */
1776
  function rewind_posts() {
1777
  $this->current_post = -1;
1778
  if ( $this->post_count > 0 ) {
1780
  }
1781
  }
1782
 
1783
+ /**
1784
+ * Whether there are posts left in the loop to iterate over.
1785
+ *
1786
+ * This method is used by {@link bp_forum_topic_posts()} as part of
1787
+ * the while loop that controls iteration inside the blogs loop, eg:
1788
+ * while ( bp_forum_topic_posts() ) { ...
1789
+ *
1790
+ * @see bp_forum_topic_posts()
1791
+ *
1792
+ * @return bool True if there are more posts to show, otherwise false.
1793
+ */
1794
  function user_posts() {
1795
  if ( $this->current_post + 1 < $this->post_count ) {
1796
  return true;
1804
  return false;
1805
  }
1806
 
1807
+ /**
1808
+ * Set up the current topic in the loop.
1809
+ *
1810
+ * @see bp_the_forum_topic_post()
1811
+ */
1812
  function the_post() {
1813
  global $post;
1814
 
1821
  }
1822
  }
1823
 
1824
+ /**
1825
+ * Initiate the loop for a single topic's posts.
1826
+ *
1827
+ * @param array $args {
1828
+ * Arguments for limiting the contents of the topic posts loop.
1829
+ * @type int $topic_id ID of the topic to which the posts belong.
1830
+ * @type int $per_page Number of items to return per page. Default: 15.
1831
+ * @type int $max Max items to return. Default: false.
1832
+ * @type string $order 'ASC' or 'DESC'.
1833
+ * }
1834
+ * @return bool True when posts are found corresponding to the args,
1835
+ * otherwise false.
1836
+ */
1837
  function bp_has_forum_topic_posts( $args = '' ) {
1838
  global $topic_template;
1839
 
1866
  return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), $topic_template );
1867
  }
1868
 
1869
+ /**
1870
+ * Determine whether there are posts left in the loop.
1871
+ *
1872
+ * @return bool True when posts are found.
1873
+ */
1874
  function bp_forum_topic_posts() {
1875
  global $topic_template;
1876
  return $topic_template->user_posts();
1877
  }
1878
 
1879
+ /**
1880
+ * Set up the current post in the loop.
1881
+ *
1882
+ * @return object
1883
+ */
1884
  function bp_the_forum_topic_post() {
1885
  global $topic_template;
1886
  return $topic_template->the_post();
1887
  }
1888
 
1889
+ /**
1890
+ * Output the ID of the current post in the loop.
1891
+ */
1892
  function bp_the_topic_post_id() {
1893
  echo bp_get_the_topic_post_id();
1894
  }
1895
+ /**
1896
+ * Return the ID of the current post in the loop.
1897
+ *
1898
+ * @return int ID of the current post in the loop.
1899
+ */
1900
  function bp_get_the_topic_post_id() {
1901
  global $topic_template;
1902
 
1903
  return apply_filters( 'bp_get_the_topic_post_id', $topic_template->post->post_id );
1904
  }
1905
 
1906
+ /**
1907
+ * Output the content of the current post in the loop.
1908
+ */
1909
  function bp_the_topic_post_content() {
1910
  echo bp_get_the_topic_post_content();
1911
  }
1912
+ /**
1913
+ * Return the content of the current post in the loop.
1914
+ *
1915
+ * @return string Content of the current post.
1916
+ */
1917
  function bp_get_the_topic_post_content() {
1918
  global $topic_template;
1919
 
1920
  return apply_filters( 'bp_get_the_topic_post_content', stripslashes( $topic_template->post->post_text ) );
1921
  }
1922
 
1923
+ /**
1924
+ * Output the CSS class of the current post in the loop.
1925
+ */
1926
  function bp_the_topic_post_css_class() {
1927
  echo bp_get_the_topic_post_css_class();
1928
  }
1929
+ /**
1930
+ * Return the CSS class of the current post in the loop.
1931
+ *
1932
+ * May contain strings 'alt', 'deleted', or 'open', depending on
1933
+ * context.
1934
+ *
1935
+ * @return string String to put in the 'class' attribute of the current
1936
+ * post.
1937
+ */
1938
  function bp_get_the_topic_post_css_class() {
1939
  global $topic_template;
1940
 
1952
  return apply_filters( 'bp_get_the_topic_post_css_class', trim( $class ) );
1953
  }
1954
 
1955
+ /**
1956
+ * Output the avatar of the user who posted the current post in the loop.
1957
+ *
1958
+ * @see bp_get_the_topic_post_poster_avatar() for a description of arguments.
1959
+ *
1960
+ * @param array $args See {@link bp_get_the_topic_post_poster_avatar()}.
1961
+ */
1962
  function bp_the_topic_post_poster_avatar( $args = '' ) {
1963
  echo bp_get_the_topic_post_poster_avatar( $args );
1964
  }
1965
+ /**
1966
+ * Return the avatar of the user who posted the current post in the loop.
1967
+ *
1968
+ * @param array $args {
1969
+ * Arguments for building the avatar.
1970
+ * @type string $type Avatar type. 'thumb' or 'full'. Default:
1971
+ * 'thumb'.
1972
+ * @type int $width Width of the avatar, in pixels. Default: the
1973
+ * width corresponding to $type.
1974
+ * See {@link bp_core_fetch_avatar()}.
1975
+ * @type int $height Height of the avatar, in pixels. Default: the
1976
+ * height corresponding to $type.
1977
+ * See {@link bp_core_fetch_avatar()}.
1978
+ * @type string $alt The text of the image's 'alt' attribute.
1979
+ * Default: 'Profile picture of [user name]'.
1980
+ * }
1981
+ * @return string HTML of user avatar.
1982
+ */
1983
  function bp_get_the_topic_post_poster_avatar( $args = '' ) {
1984
  global $topic_template;
1985
 
1996
  return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
1997
  }
1998
 
1999
+ /**
2000
+ * Output the name of the user who posted the current post in the loop.
2001
+ */
2002
  function bp_the_topic_post_poster_name() {
2003
  echo bp_get_the_topic_post_poster_name();
2004
  }
2005
+ /**
2006
+ * Return the name of the user who posted the current post in the loop.
2007
+ *
2008
+ * @return string Name of the user who posted the current post.
2009
+ */
2010
  function bp_get_the_topic_post_poster_name() {
2011
  global $topic_template;
2012
 
2016
  return apply_filters( 'bp_get_the_topic_post_poster_name', '<a href="' . $link . '" title="' . $topic_template->post->poster_name . '">' . $topic_template->post->poster_name . '</a>' );
2017
  }
2018
 
2019
+ /**
2020
+ * Output a link to the profile of the user who posted the current post.
2021
+ */
2022
  function bp_the_topic_post_poster_link() {
2023
  echo bp_get_the_topic_post_poster_link();
2024
  }
2025
+ /**
2026
+ * Return a link to the profile of the user who posted the current post.
2027
+ *
2028
+ * @return string Link to the profile of the user who posted the
2029
+ * current post.
2030
+ */
2031
  function bp_get_the_topic_post_poster_link() {
2032
  global $topic_template;
2033
 
2034
  return apply_filters( 'bp_the_topic_post_poster_link', bp_core_get_user_domain( $topic_template->post->poster_id ) );
2035
  }
2036
 
2037
+ /**
2038
+ * Output a 'since' string describing when the current post in the loop was posted.
2039
+ */
2040
  function bp_the_topic_post_time_since() {
2041
  echo bp_get_the_topic_post_time_since();
2042
  }
2043
+ /**
2044
+ * Return a 'since' string describing when the current post in the loop was posted.
2045
+ *
2046
+ * @see bp_core_time_since() for a description of return value.
2047
+ *
2048
+ * @return string
2049
+ */
2050
  function bp_get_the_topic_post_time_since() {
2051
  global $topic_template;
2052
 
2053
  return apply_filters( 'bp_get_the_topic_post_time_since', bp_core_time_since( strtotime( $topic_template->post->post_time ) ) );
2054
  }
2055
 
2056
+ /**
2057
+ * Output whether the current post in the loop belongs to the logged-in user.
2058
+ */
2059
  function bp_the_topic_post_is_mine() {
2060
  echo bp_the_topic_post_is_mine();
2061
  }
2062
+ /**
2063
+ * Does the current post belong to the logged-in user?
2064
+ *
2065
+ * @return bool True if the current post in the loop was created by
2066
+ * the logged-in user, otherwise false.
2067
+ */
2068
  function bp_get_the_topic_post_is_mine() {
2069
  global $bp, $topic_template;
2070
 
2071
  return bp_loggedin_user_id() == $topic_template->post->poster_id;
2072
  }
2073
 
2074
+ /**
2075
+ * Output the admin links for the current post in the loop.
2076
+ *
2077
+ * @see bp_get_the_post_admin_links() for a description of arguments.
2078
+ *
2079
+ * @param array $args See {@link bp_get_the_post_admin_links()}.
2080
+ */
2081
  function bp_the_topic_post_admin_links( $args = '' ) {
2082
  echo bp_get_the_topic_post_admin_links( $args );
2083
  }
2084
+ /**
2085
+ * Return the admin links for the current post in the loop.
2086
+ *
2087
+ * @param array $args {
2088
+ * @type string $separator The character to use when separating
2089
+ * links. Default: '|'.
2090
+ * }
2091
+ * @return HTML string containing the admin links for the current post.
2092
+ */
2093
  function bp_get_the_topic_post_admin_links( $args = '' ) {
2094
  global $topic_template;
2095
 
2115
  return apply_filters( 'bp_get_the_topic_post_admin_links', implode( $separator, $links ), $links, $r );
2116
  }
2117
 
2118
+ /**
2119
+ * Output the text to edit when editing a post.
2120
+ */
2121
  function bp_the_topic_post_edit_text() {
2122
  echo bp_get_the_topic_post_edit_text();
2123
  }
2124
+ /**
2125
+ * Return the text to edit when editing a post.
2126
+ *
2127
+ * @return string Editable text.
2128
+ */
2129
  function bp_get_the_topic_post_edit_text() {
2130
  $post = bp_forums_get_post( bp_action_variable( 4 ) );
2131
  return apply_filters( 'bp_get_the_topic_post_edit_text', esc_attr( $post->post_text ) );
2132
  }
2133
 
2134
+ /**
2135
+ * Output the pagination links for the current topic.
2136
+ */
2137
  function bp_the_topic_pagination() {
2138
  echo bp_get_the_topic_pagination();
2139
  }
2140
+ /**
2141
+ * Return the pagination links for the current topic page.
2142
+ *
2143
+ * @return string HTML pagination links.
2144
+ */
2145
  function bp_get_the_topic_pagination() {
2146
  global $topic_template;
2147
 
2148
  return apply_filters( 'bp_get_the_topic_pagination', $topic_template->pag_links );
2149
  }
2150
 
2151
+ /**
2152
+ * Return the pagination count for the current topic page.
2153
+ *
2154
+ * The "count" is a string of the form "Viewing x of y posts".
2155
+ *
2156
+ * @return string
2157
+ */
2158
  function bp_the_topic_pagination_count() {
2159
  global $bp, $topic_template;
2160
 
2163
  $to_num = bp_core_number_format( ( $start_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $start_num + ( $topic_template->pag_num - 1 ) );
2164
  $total = bp_core_number_format( $topic_template->total_post_count );
2165
 
2166
+ echo apply_filters( 'bp_the_topic_pagination_count', sprintf( _n( 'Viewing post %1$s to %2$s (%3$s post)', 'Viewing post %1$s to %2$s (%3$s total posts)', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
2167
  }
2168
 
2169
+ /**
2170
+ * Output whether this is the last page in the current topic.
2171
+ */
2172
  function bp_the_topic_is_last_page() {
2173
  echo bp_get_the_topic_is_last_page();
2174
  }
2175
+ /**
2176
+ * Is this the last page in the current topic?
2177
+ *
2178
+ * @return bool True if this is the last page of posts for the current
2179
+ * topic, otherwise false.
2180
+ */
2181
  function bp_get_the_topic_is_last_page() {
2182
  global $topic_template;
2183
 
2184
  return apply_filters( 'bp_get_the_topic_is_last_page', $topic_template->pag_page == $topic_template->pag->total_pages );
2185
  }
2186
 
2187
+ /**
2188
+ * Output the forums directory search form.
2189
+ */
2190
  function bp_directory_forums_search_form() {
 
 
2191
  $default_search_value = bp_get_search_default_text( 'forums' );
2192
+ $search_value = !empty( $_REQUEST['fs'] ) ? stripslashes( $_REQUEST['fs'] ) : $default_search_value;
2193
 
2194
+ $search_form_html = '<form action="" method="get" id="search-forums-form">
2195
+ <label><input type="text" name="s" id="forums_search" placeholder="'. esc_attr( $search_value ) .'" /></label>
2196
+ <input type="submit" id="forums_search_submit" name="forums_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
2197
+ </form>';
2198
 
2199
+ echo apply_filters( 'bp_directory_forums_search_form', $search_form_html );
2200
  }
2201
 
2202
+ /**
2203
+ * Output the link to a given forum.
2204
+ *
2205
+ * @see bp_get_forum_permalink() for a description of arguments.
2206
+ *
2207
+ * @param int $forum_id See {@link bp_get_forum_permalink()}.
2208
+ */
2209
  function bp_forum_permalink( $forum_id = 0 ) {
2210
  echo bp_get_forum_permalink( $forum_id );
2211
  }
2212
+ /**
2213
+ * Return the permalink to a given forum.
2214
+ *
2215
+ * @param int $forum_id Optional. Defaults to the current forum, if
2216
+ * there is one.
2217
+ * @return string|bool False on failure, a URL on success.
2218
+ */
2219
  function bp_get_forum_permalink( $forum_id = 0 ) {
2220
  global $bp;
2221
 
2237
  return apply_filters( 'bp_get_forum_permalink', trailingslashit( $permalink ) );
2238
  }
2239
 
2240
+ /**
2241
+ * Output the name of a given forum.
2242
+ *
2243
+ * @see bp_get_forum_name() for a description of parameters.
2244
+ *
2245
+ * @param int $forum_id See {@link bp_get_forum_name()}.
2246
+ */
2247
  function bp_forum_name( $forum_id = 0 ) {
2248
  echo bp_get_forum_name( $forum_id );
2249
  }
2250
+ /**
2251
+ * Return the name of a given forum.
2252
+ *
2253
+ * @param int $forum_id Optional. Defaults to the current forum, if
2254
+ * there is one.
2255
+ * @return string|bool False on failure, a name on success.
2256
+ */
2257
  function bp_get_forum_name( $forum_id = 0 ) {
2258
  global $bp;
2259
 
2269
  return false;
2270
  }
2271
 
2272
+ /**
2273
+ * Get a heatmap of forum tags for the installation.
2274
+ *
2275
+ * A wrapper for {@link bb_tag_heat_map}, which provides it with BP-friendly
2276
+ * defaults.
2277
+ *
2278
+ * @param array $args {
2279
+ * An array of optional arguments.
2280
+ * @type int $smallest Size of the smallest link. Default: 10.
2281
+ * @type int $largest Size of the largest link. Default: 42.
2282
+ * @type string $sizing Unit for $largest and $smallest. Default: 'px'.
2283
+ * @type int $limit Max number of tags to display. Default: 50.
2284
+ * }
2285
+ */
2286
  function bp_forums_tag_heat_map( $args = '' ) {
2287
  $defaults = array(
2288
  'smallest' => '10',
2298
  }
2299
 
2300
  /**
2301
+ * Output the current topic's tag list, comma-separated
2302
  *
2303
+ * @since BuddyPress (1.5.0)
 
2304
  */
2305
  function bp_forum_topic_tag_list() {
2306
  echo bp_get_forum_topic_tag_list();
2307
  }
2308
  /**
2309
+ * Get the current topic's tag list.
2310
  *
2311
+ * @since BuddyPress (1.5.0)
 
2312
  *
2313
+ * @param string $format 'string' returns comma-separated string;
2314
+ * otherwise returns array.
2315
  * @return mixed $tags
2316
  */
2317
  function bp_get_forum_topic_tag_list( $format = 'string' ) {
2334
  }
2335
 
2336
  /**
2337
+ * Does the current topic have any tags?
2338
  *
2339
+ * @since BuddyPress (1.5.0)
 
2340
  *
2341
+ * @return bool True if the current topic has tags, otherwise false.
2342
  */
2343
  function bp_forum_topic_has_tags() {
2344
  global $topic_template;
2351
  return apply_filters( 'bp_forum_topic_has_tags', $has_tags );
2352
  }
2353
 
2354
+ /**
2355
+ * Output a URL to use in as a forum form 'action'.
2356
+ */
2357
  function bp_forum_action() {
2358
  echo bp_get_forum_action();
2359
  }
2360
+ /**
2361
+ * Get a URL to use in as a forum form 'action'.
2362
+ *
2363
+ * @return string URL of the current page, minus query args.
2364
+ */
2365
  function bp_get_forum_action() {
2366
  global $topic_template;
2367
 
2368
  return apply_filters( 'bp_get_forum_action', bp_get_root_domain() . esc_attr( $_SERVER['REQUEST_URI'] ) );
2369
  }
2370
 
2371
+ /**
2372
+ * Output a URL to use in as a forum topic form 'action'.
2373
+ */
2374
  function bp_forum_topic_action() {
2375
  echo bp_get_forum_topic_action();
2376
  }
2377
+ /**
2378
+ * Get a URL to use in as a forum topic form 'action'.
2379
+ *
2380
+ * @return string URL of the current page, minus query args.
2381
+ */
2382
  function bp_get_forum_topic_action() {
2383
  return apply_filters( 'bp_get_forum_topic_action', $_SERVER['REQUEST_URI'] );
2384
  }
2385
 
2386
+ /**
2387
+ * Output the total topic count for a given user.
2388
+ *
2389
+ * @see bp_get_forum_topic_count_for_user() for description of parameters.
2390
+ *
2391
+ * @param int $user_id See {@link bp_get_forum_topic_count_for_user()}.
2392
+ */
2393
  function bp_forum_topic_count_for_user( $user_id = 0 ) {
2394
  echo bp_get_forum_topic_count_for_user( $user_id );
2395
  }
2396
+ /**
2397
+ * Return the total topic count for a given user.
2398
+ *
2399
+ * @param int $user_id See {@link bp_forums_total_topic_count_for_user}.
2400
+ */
2401
  function bp_get_forum_topic_count_for_user( $user_id = 0 ) {
2402
  return apply_filters( 'bp_get_forum_topic_count_for_user', bp_forums_total_topic_count_for_user( $user_id ) );
2403
  }
2404
 
2405
+ /**
2406
+ * Output the total topic count for a given user.
2407
+ *
2408
+ * @see bp_get_forum_topic_count() for description of parameters.
2409
+ *
2410
+ * @param int $user_id See {@link bp_get_forum_topic_count()}.
2411
+ */
2412
  function bp_forum_topic_count( $user_id = 0 ) {
2413
  echo bp_get_forum_topic_count( $user_id );
2414
  }
2415
+ /**
2416
+ * Return the total topic count for a given user.
2417
+ *
2418
+ * @param int $user_id See {@link bp_forums_total_topic_count()}.
2419
+ */
2420
  function bp_get_forum_topic_count( $user_id = 0 ) {
2421
  return apply_filters( 'bp_get_forum_topic_count', bp_forums_total_topic_count( $user_id ) );
2422
  }
bp-friends/bp-friends-actions.php CHANGED
@@ -3,9 +3,9 @@
3
  /**
4
  * BuddyPress Friends Actions
5
  *
6
- * Action functions are exactly the same as screen functions, however they do not
7
- * have a template screen associated with them. Usually they will send the user
8
- * back to the default screen after execution.
9
  *
10
  * @package BuddyPress
11
  * @subpackage FriendsActions
@@ -14,6 +14,9 @@
14
  // Exit if accessed directly
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
 
 
 
17
  function friends_action_add_friend() {
18
  if ( !bp_is_friends_component() || !bp_is_current_action( 'add-friend' ) )
19
  return false;
@@ -49,6 +52,9 @@ function friends_action_add_friend() {
49
  }
50
  add_action( 'bp_init', 'friends_action_add_friend' );
51
 
 
 
 
52
  function friends_action_remove_friend() {
53
  if ( !bp_is_friends_component() || !bp_is_current_action( 'remove-friend' ) )
54
  return false;
3
  /**
4
  * BuddyPress Friends Actions
5
  *
6
+ * Action functions are exactly the same as screen functions, however they do
7
+ * not have a template screen associated with them. Usually they will send the
8
+ * user back to the default screen after execution.
9
  *
10
  * @package BuddyPress
11
  * @subpackage FriendsActions
14
  // Exit if accessed directly
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
17
+ /**
18
+ * Catch and process friendship requests.
19
+ */
20
  function friends_action_add_friend() {
21
  if ( !bp_is_friends_component() || !bp_is_current_action( 'add-friend' ) )
22
  return false;
52
  }
53
  add_action( 'bp_init', 'friends_action_add_friend' );
54
 
55
+ /**
56
+ * Catch and process Remove Friendship requests.
57
+ */
58
  function friends_action_remove_friend() {
59
  if ( !bp_is_friends_component() || !bp_is_current_action( 'remove-friend' ) )
60
  return false;
bp-friends/bp-friends-activity.php CHANGED
@@ -13,6 +13,24 @@
13
  // Exit if accessed directly
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  function friends_record_activity( $args = '' ) {
17
  global $bp;
18
 
@@ -38,6 +56,20 @@ function friends_record_activity( $args = '' ) {
38
  return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
39
  }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  function friends_delete_activity( $args ) {
42
  global $bp;
43
 
@@ -47,6 +79,9 @@ function friends_delete_activity( $args ) {
47
  }
48
  }
49
 
 
 
 
50
  function friends_register_activity_actions() {
51
  global $bp;
52
 
@@ -65,15 +100,16 @@ function friends_register_activity_actions() {
65
  add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
66
 
67
  /**
68
- * Format the BuddyBar/Toolbar notifications for the Friends component
69
- *
70
- * @package BuddyPress
71
  *
72
- * @param string $action The kind of notification being rendered
73
- * @param int $item_id The primary item id
74
- * @param int $secondary_item_id The secondary item id
75
- * @param int $total_items The total number of messaging-related notifications waiting for the user
76
- * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
 
 
 
77
  */
78
  function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
79
 
13
  // Exit if accessed directly
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
+ /**
17
+ * Record an activity item related to the Friends component.
18
+ *
19
+ * A wrapper for {@link bp_activity_add()} that provides some Friends-specific
20
+ * defaults.
21
+ *
22
+ * @see bp_activity_add() for more detailed description of parameters and
23
+ * return values.
24
+ *
25
+ * @param array $args {
26
+ * An array of arguments for the new activity item. Accepts all parameters
27
+ * of {@link bp_activity_add()}. The one difference is the following
28
+ * argument, which has a different default here:
29
+ * @type string $component Default: the id of your Friends component
30
+ * (usually 'friends').
31
+ * }
32
+ * @return bool See {@link bp_activity_add()}.
33
+ */
34
  function friends_record_activity( $args = '' ) {
35
  global $bp;
36
 
56
  return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
57
  }
58
 
59
+ /**
60
+ * Delete an activity item related to the Friends component.
61
+ *
62
+ * @param array $args {
63
+ * An array of arguments for the item to delete.
64
+ * @type int $item_id ID of the 'item' associated with the activity item.
65
+ * For Friends activity items, this is usually the user ID of one
66
+ * of the friends.
67
+ * @type string $type The 'type' of the activity item (eg
68
+ * 'friendship_accepted').
69
+ * @type int $user_id ID of the user associated with the activity item.
70
+ * }
71
+ * @return bool True on success, false on failure.
72
+ */
73
  function friends_delete_activity( $args ) {
74
  global $bp;
75
 
79
  }
80
  }
81
 
82
+ /**
83
+ * Register the activity actions for bp-friends.
84
+ */
85
  function friends_register_activity_actions() {
86
  global $bp;
87
 
100
  add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
101
 
102
  /**
103
+ * Notification formatting callback for bp-friends notifications.
 
 
104
  *
105
+ * @param string $action The kind of notification being rendered.
106
+ * @param int $item_id The primary item ID.
107
+ * @param int $secondary_item_id The secondary item ID.
108
+ * @param int $total_items The total number of messaging-related notifications
109
+ * waiting for the user.
110
+ * @param string $format 'string' for BuddyBar-compatible notifications;
111
+ * 'array' for WP Toolbar. Default: 'string'.
112
+ * @return array|string
113
  */
114
  function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
115
 
bp-friends/bp-friends-cache.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Friends Caching
5
  *
6
  * Caching functions handle the clearing of cached objects and pages on specific
7
  * actions throughout BuddyPress.
@@ -14,6 +14,12 @@
14
  // Exit if accessed directly
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
 
 
 
 
 
 
17
  function friends_clear_friend_object_cache( $friendship_id ) {
18
  if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) )
19
  return false;
@@ -22,11 +28,13 @@ function friends_clear_friend_object_cache( $friendship_id ) {
22
  wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );
23
  }
24
 
 
 
 
25
  function friends_clear_friend_notifications() {
26
- global $bp;
27
-
28
- if ( isset( $_GET['new'] ) )
29
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->friends->id, 'friendship_accepted' );
30
  }
31
  add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
32
 
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Friends Caching.
5
  *
6
  * Caching functions handle the clearing of cached objects and pages on specific
7
  * actions throughout BuddyPress.
14
  // Exit if accessed directly
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
17
+ /**
18
+ * Clear friends-related cache for members of a specific friendship.
19
+ *
20
+ * @param int $friendship_id ID of the friendship whose two members should
21
+ * have their friends cache busted.
22
+ */
23
  function friends_clear_friend_object_cache( $friendship_id ) {
24
  if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) )
25
  return false;
28
  wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );
29
  }
30
 
31
+ /**
32
+ * Clear friend-related notifications when ?new=1.
33
+ */
34
  function friends_clear_friend_notifications() {
35
+ if ( isset( $_GET['new'] ) ) {
36
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
37
+ }
 
38
  }
39
  add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
40
 
bp-friends/bp-friends-classes.php CHANGED
@@ -1,22 +1,104 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  // Exit if accessed directly
4
  if ( !defined( 'ABSPATH' ) ) exit;
5
 
 
 
 
6
  class BP_Friends_Friendship {
7
- var $id;
8
- var $initiator_user_id;
9
- var $friend_user_id;
10
- var $is_confirmed;
11
- var $is_limited;
12
- var $date_created;
13
 
14
- var $is_request;
15
- var $populate_friend_details;
16
-
17
- var $friend;
18
-
19
- function __construct( $id = null, $is_request = false, $populate_friend_details = true ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  $this->is_request = $is_request;
21
 
22
  if ( !empty( $id ) ) {
@@ -26,7 +108,10 @@ class BP_Friends_Friendship {
26
  }
27
  }
28
 
29
- function populate() {
 
 
 
30
  global $wpdb, $bp;
31
 
32
  if ( $friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ) ) {
@@ -46,7 +131,12 @@ class BP_Friends_Friendship {
46
  }
47
  }
48
 
49
- function save() {
 
 
 
 
 
50
  global $wpdb, $bp;
51
 
52
  $this->initiator_user_id = apply_filters( 'friends_friendship_initiator_user_id_before_save', $this->initiator_user_id, $this->id );
@@ -72,15 +162,24 @@ class BP_Friends_Friendship {
72
  return $result;
73
  }
74
 
75
- function delete() {
76
  global $wpdb, $bp;
77
-
78
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) );
79
  }
80
 
81
  /** Static Methods ********************************************************/
82
 
83
- function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
 
 
 
 
 
 
 
 
 
 
84
  global $wpdb, $bp;
85
 
86
  if ( !empty( $friend_requests_only ) ) {
@@ -105,19 +204,42 @@ class BP_Friends_Friendship {
105
  return $fids;
106
  }
107
 
108
- function get_friendship_id( $user_id, $friend_id ) {
 
 
 
 
 
 
 
 
109
  global $wpdb, $bp;
110
 
111
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE ( initiator_user_id = %d AND friend_user_id = %d ) OR ( initiator_user_id = %d AND friend_user_id = %d ) AND is_confirmed = 1", $user_id, $friend_id, $friend_id, $user_id ) );
112
  }
113
 
114
- function get_friendship_request_user_ids( $user_id ) {
 
 
 
 
 
 
 
115
  global $wpdb, $bp;
116
 
117
  return $wpdb->get_col( $wpdb->prepare( "SELECT initiator_user_id FROM {$bp->friends->table_name} WHERE friend_user_id = %d AND is_confirmed = 0", $user_id ) );
118
  }
119
 
120
- function total_friend_count( $user_id = 0 ) {
 
 
 
 
 
 
 
 
121
  global $wpdb, $bp;
122
 
123
  if ( empty( $user_id ) )
@@ -133,10 +255,26 @@ class BP_Friends_Friendship {
133
  return 0;
134
 
135
  bp_update_user_meta( $user_id, 'total_friend_count', (int) $count );
136
- return (int) $count;
 
137
  }
138
 
139
- function search_friends( $filter, $user_id, $limit = null, $page = null ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  global $wpdb, $bp;
141
 
142
  // TODO: Optimize this function.
@@ -146,6 +284,7 @@ class BP_Friends_Friendship {
146
 
147
  $filter = esc_sql( like_escape( $filter ) );
148
 
 
149
  if ( !empty( $limit ) && !empty( $page ) )
150
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
151
 
@@ -176,26 +315,53 @@ class BP_Friends_Friendship {
176
  return array( 'friends' => $filtered_friend_ids, 'total' => (int) $total_friend_ids );
177
  }
178
 
179
- function check_is_friend( $loggedin_userid, $possible_friend_userid ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  global $wpdb, $bp;
181
 
182
- if ( empty( $loggedin_userid ) || empty( $possible_friend_userid ) )
183
  return false;
 
184
 
185
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $loggedin_userid, $possible_friend_userid, $possible_friend_userid, $loggedin_userid ) );
186
 
187
- if ( !empty( $result ) ) {
188
  if ( 0 == (int) $result[0]->is_confirmed ) {
189
- return 'pending';
190
  } else {
191
- return 'is_friend';
192
  }
193
  } else {
194
- return 'not_friends';
195
  }
 
 
196
  }
197
 
198
- function get_bulk_last_active( $user_ids ) {
 
 
 
 
 
 
 
 
 
199
  global $wpdb;
200
 
201
  $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
@@ -203,25 +369,52 @@ class BP_Friends_Friendship {
203
  return $wpdb->get_results( $wpdb->prepare( "SELECT meta_value as last_activity, user_id FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} ) ORDER BY meta_value DESC", bp_get_user_meta_key( 'last_activity' ) ) );
204
  }
205
 
206
- function accept($friendship_id) {
 
 
 
 
 
 
207
  global $wpdb, $bp;
208
-
209
  return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = %s WHERE id = %d AND friend_user_id = %d", bp_core_current_time(), $friendship_id, bp_loggedin_user_id() ) );
210
  }
211
 
212
- function withdraw($friendship_id) {
 
 
 
 
 
 
213
  global $wpdb, $bp;
214
-
215
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND initiator_user_id = %d", $friendship_id, bp_loggedin_user_id() ) );
216
  }
217
 
218
- function reject($friendship_id) {
 
 
 
 
 
 
219
  global $wpdb, $bp;
220
-
221
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND friend_user_id = %d", $friendship_id, bp_loggedin_user_id() ) );
222
  }
223
 
224
- function search_users( $filter, $user_id, $limit = null, $page = null ) {
 
 
 
 
 
 
 
 
 
 
 
 
225
  global $wpdb, $bp;
226
 
227
  $filter = esc_sql( like_escape( $filter ) );
@@ -229,6 +422,7 @@ class BP_Friends_Friendship {
229
  $usermeta_table = $wpdb->base_prefix . 'usermeta';
230
  $users_table = $wpdb->base_prefix . 'users';
231
 
 
232
  if ( !empty( $limit ) && !empty( $page ) )
233
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) );
234
 
@@ -247,7 +441,15 @@ class BP_Friends_Friendship {
247
  return $filtered_fids;
248
  }
249
 
250
- function search_users_count( $filter ) {
 
 
 
 
 
 
 
 
251
  global $wpdb, $bp;
252
 
253
  $filter = esc_sql( like_escape( $filter ) );
@@ -270,7 +472,15 @@ class BP_Friends_Friendship {
270
  return $user_count[0];
271
  }
272
 
273
- function sort_by_name( $user_ids ) {
 
 
 
 
 
 
 
 
274
  global $wpdb, $bp;
275
 
276
  if ( !bp_is_active( 'xprofile' ) )
@@ -281,7 +491,16 @@ class BP_Friends_Friendship {
281
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->profile->table_name_data} pd, {$bp->profile->table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC", bp_xprofile_fullname_field_name() ) );
282
  }
283
 
284
- function get_random_friends( $user_id, $total_friends = 5 ) {
 
 
 
 
 
 
 
 
 
285
  global $wpdb, $bp;
286
 
287
  $fids = array();
@@ -299,7 +518,20 @@ class BP_Friends_Friendship {
299
  return false;
300
  }
301
 
302
- function get_invitable_friend_count( $user_id, $group_id ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
  // Setup some data we'll use below
305
  $is_group_admin = BP_Groups_Member::check_is_admin( $user_id, $group_id );
@@ -326,13 +558,23 @@ class BP_Friends_Friendship {
326
  return $invitable_count;
327
  }
328
 
329
- function get_user_ids_for_friendship( $friendship_id ) {
 
 
 
 
 
 
330
  global $wpdb, $bp;
331
-
332
  return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) );
333
  }
334
 
335
- function delete_all_for_user( $user_id ) {
 
 
 
 
 
336
  global $wpdb, $bp;
337
 
338
  // Get friends of $user_id
@@ -341,8 +583,11 @@ class BP_Friends_Friendship {
341
  // Delete all friendships related to $user_id
342
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) );
343
 
344
- // Delete friend request notifications for members who have a notification from this user.
345
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id ) );
 
 
 
346
 
347
  // Loop through friend_ids and update their counts
348
  foreach ( (array) $friend_ids as $friend_id ) {
1
  <?php
2
+ /**
3
+ * BuddyPress Friends Classes
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage FriendsClasses
7
+ */
8
 
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
+ /**
13
+ * BuddyPress Friendship object.
14
+ */
15
  class BP_Friends_Friendship {
 
 
 
 
 
 
16
 
17
+ /**
18
+ * ID of the friendship.
19
+ *
20
+ * @access public
21
+ * @var int
22
+ */
23
+ public $id;
24
+
25
+ /**
26
+ * User ID of the friendship initiator.
27
+ *
28
+ * @access public
29
+ * @var int
30
+ */
31
+ public $initiator_user_id;
32
+
33
+ /**
34
+ * User ID of the 'friend' - the one invited to the friendship.
35
+ *
36
+ * @access public
37
+ * @var int
38
+ */
39
+ public $friend_user_id;
40
+
41
+ /**
42
+ * Has the friendship been confirmed/accepted?
43
+ *
44
+ * @access public
45
+ * @var int
46
+ */
47
+ public $is_confirmed;
48
+
49
+ /**
50
+ * Is this a "limited" friendship?
51
+ *
52
+ * Not currently used by BuddyPress.
53
+ *
54
+ * @access public
55
+ * @var int
56
+ */
57
+ public $is_limited;
58
+
59
+ /**
60
+ * Date the friendship was created.
61
+ *
62
+ * @access public
63
+ * @var string
64
+ */
65
+ public $date_created;
66
+
67
+ /**
68
+ * Is this a request?
69
+ *
70
+ * Not currently used in BuddyPress.
71
+ *
72
+ * @access public
73
+ * @var unknown
74
+ */
75
+ public $is_request;
76
+
77
+ /**
78
+ * Should additional friend details be queried?
79
+ *
80
+ * @access public
81
+ * @var bool
82
+ */
83
+ public $populate_friend_details;
84
+
85
+ /**
86
+ * Details about the friend.
87
+ *
88
+ * @access public
89
+ * @var BP_Core_User
90
+ */
91
+ public $friend;
92
+
93
+ /**
94
+ * Constructor method.
95
+ *
96
+ * @param int $id Optional. The ID of an existing friendship.
97
+ * @param bool $is_request Deprecated.
98
+ * @param bool $populate_friend_details True if friend details should
99
+ * be queried.
100
+ */
101
+ public function __construct( $id = null, $is_request = false, $populate_friend_details = true ) {
102
  $this->is_request = $is_request;
103
 
104
  if ( !empty( $id ) ) {
108
  }
109
  }
110
 
111
+ /**
112
+ * Set up data about the current friendship.
113
+ */
114
+ public function populate() {
115
  global $wpdb, $bp;
116
 
117
  if ( $friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ) ) {
131
  }
132
  }
133
 
134
+ /**
135
+ * Save the current friendship to the database.
136
+ *
137
+ * @return bool True on success, false on failure.
138
+ */
139
+ public function save() {
140
  global $wpdb, $bp;
141
 
142
  $this->initiator_user_id = apply_filters( 'friends_friendship_initiator_user_id_before_save', $this->initiator_user_id, $this->id );
162
  return $result;
163
  }
164
 
165
+ public function delete() {
166
  global $wpdb, $bp;
 
167
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) );
168
  }
169
 
170
  /** Static Methods ********************************************************/
171
 
172
+ /**
173
+ * Get the IDs of a given user's friends.
174
+ *
175
+ * @param int $user_id ID of the user whose friends are being retreived.
176
+ * @param bool $friend_requests_only Optional. Whether to fetch
177
+ * unaccepted requests only. Default: false.
178
+ * @param bool $assoc_arr Optional. True to receive an array of arrays
179
+ * keyed as 'user_id' => $user_id; false to get a one-dimensional
180
+ * array of user IDs. Default: false.
181
+ */
182
+ public static function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
183
  global $wpdb, $bp;
184
 
185
  if ( !empty( $friend_requests_only ) ) {
204
  return $fids;
205
  }
206
 
207
+ /**
208
+ * Get the ID of the friendship object, if any, between a pair of users.
209
+ *
210
+ * @param int $user_id The ID of the first user.
211
+ * @param int $friend_id The ID of the second user.
212
+ * @return int|bool The ID of the friendship object if found, otherwise
213
+ * false.
214
+ */
215
+ public static function get_friendship_id( $user_id, $friend_id ) {
216
  global $wpdb, $bp;
217
 
218
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE ( initiator_user_id = %d AND friend_user_id = %d ) OR ( initiator_user_id = %d AND friend_user_id = %d ) AND is_confirmed = 1", $user_id, $friend_id, $friend_id, $user_id ) );
219
  }
220
 
221
+ /**
222
+ * Get a list of IDs of users who have requested friendship of a given user.
223
+ *
224
+ * @param int $user_id The ID of the user who has received the
225
+ * friendship requests.
226
+ * @return array|bool An array of user IDs, or false if none are found.
227
+ */
228
+ public static function get_friendship_request_user_ids( $user_id ) {
229
  global $wpdb, $bp;
230
 
231
  return $wpdb->get_col( $wpdb->prepare( "SELECT initiator_user_id FROM {$bp->friends->table_name} WHERE friend_user_id = %d AND is_confirmed = 0", $user_id ) );
232
  }
233
 
234
+ /**
235
+ * Get a total friend count for a given user.
236
+ *
237
+ * @param int $user_id Optional. ID of the user whose friendships you
238
+ * are counting. Default: displayed user (if any), otherwise
239
+ * logged-in user.
240
+ * @return int Friend count for the user.
241
+ */
242
+ public static function total_friend_count( $user_id = 0 ) {
243
  global $wpdb, $bp;
244
 
245
  if ( empty( $user_id ) )
255
  return 0;
256
 
257
  bp_update_user_meta( $user_id, 'total_friend_count', (int) $count );
258
+
259
+ return absint( $count );
260
  }
261
 
262
+ /**
263
+ * Search the friends of a user by a search string.
264
+ *
265
+ * @param string $filter The search string, matched against xprofile
266
+ * fields (if available), or usermeta 'nickname' field.
267
+ * @param int $user_id ID of the user whose friends are being searched.
268
+ * @param int $limit Optional. Max number of friends to return.
269
+ * @param int $page Optional. The page of results to return. Default:
270
+ * null (no pagination - return all results).
271
+ * @return array|bool On success, an array: {
272
+ * @type array $friends IDs of friends returned by the query.
273
+ * @type int $count Total number of friends (disregarding
274
+ * pagination) who match the search.
275
+ * }. Returns false on failure.
276
+ */
277
+ public static function search_friends( $filter, $user_id, $limit = null, $page = null ) {
278
  global $wpdb, $bp;
279
 
280
  // TODO: Optimize this function.
284
 
285
  $filter = esc_sql( like_escape( $filter ) );
286
 
287
+ $pag_sql = '';
288
  if ( !empty( $limit ) && !empty( $page ) )
289
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
290
 
315
  return array( 'friends' => $filtered_friend_ids, 'total' => (int) $total_friend_ids );
316
  }
317
 
318
+ /**
319
+ * Check friendship status between two users.
320
+ *
321
+ * Note that 'pending' means that $initiator_userid has sent a friend
322
+ * request to $possible_friend_userid that has not yet been approved,
323
+ * while 'awaiting_response' is the other way around ($possible_friend_userid
324
+ * sent the initial request)
325
+ *
326
+ * @param int $initiator_userid The ID of the user who is the initiator
327
+ * of the potential friendship/request.
328
+ * @param int $possible_friend_userid The ID of the user who is the
329
+ * recipient of the potential friendship/request.
330
+ * @return string The friendship status, from among 'not_friends',
331
+ * 'is_friend', 'pending', and 'awaiting_response'.
332
+ */
333
+ public static function check_is_friend( $initiator_userid, $possible_friend_userid ) {
334
  global $wpdb, $bp;
335
 
336
+ if ( empty( $initiator_userid ) || empty( $possible_friend_userid ) ) {
337
  return false;
338
+ }
339
 
340
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, initiator_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $initiator_userid, $possible_friend_userid, $possible_friend_userid, $initiator_userid ) );
341
 
342
+ if ( ! empty( $result ) ) {
343
  if ( 0 == (int) $result[0]->is_confirmed ) {
344
+ $status = $initiator_userid == $result[0]->initiator_user_id ? 'pending' : 'awaiting_response';
345
  } else {
346
+ $status = 'is_friend';
347
  }
348
  } else {
349
+ $status = 'not_friends';
350
  }
351
+
352
+ return $status;
353
  }
354
 
355
+ /**
356
+ * Get the last active date of many users at once.
357
+ *
358
+ * @todo Why is this in the Friends component?
359
+ *
360
+ * @param array $user_ids IDs of users whose last_active meta is
361
+ * being queried.
362
+ * @return array Array of last_active values + user_ids.
363
+ */
364
+ public static function get_bulk_last_active( $user_ids ) {
365
  global $wpdb;
366
 
367
  $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
369
  return $wpdb->get_results( $wpdb->prepare( "SELECT meta_value as last_activity, user_id FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} ) ORDER BY meta_value DESC", bp_get_user_meta_key( 'last_activity' ) ) );
370
  }
371
 
372
+ /**
373
+ * Mark a friendship as accepted.
374
+ *
375
+ * @param int $friendship_id ID of the friendship to be accepted.
376
+ * @return int Number of database rows updated.
377
+ */
378
+ public static function accept($friendship_id) {
379
  global $wpdb, $bp;
 
380
  return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = %s WHERE id = %d AND friend_user_id = %d", bp_core_current_time(), $friendship_id, bp_loggedin_user_id() ) );
381
  }
382
 
383
+ /**
384
+ * Remove a friendship or a friendship request INITIATED BY the logged-in user.
385
+ *
386
+ * @param int $friendship_id ID of the friendship to be withdrawn.
387
+ * @return int Number of database rows deleted.
388
+ */
389
+ public static function withdraw($friendship_id) {
390
  global $wpdb, $bp;
 
391
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND initiator_user_id = %d", $friendship_id, bp_loggedin_user_id() ) );
392
  }
393
 
394
+ /**
395
+ * Remove a friendship or a friendship request MADE OF the logged-in user.
396
+ *
397
+ * @param int $friendship_id ID of the friendship to be rejected.
398
+ * @return int Number of database rows deleted.
399
+ */
400
+ public static function reject($friendship_id) {
401
  global $wpdb, $bp;
 
402
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND friend_user_id = %d", $friendship_id, bp_loggedin_user_id() ) );
403
  }
404
 
405
+ /**
406
+ * Search users.
407
+ *
408
+ * @todo Why does this exist, and why is it in bp-friends?
409
+ *
410
+ * @param string $filter String to search by.
411
+ * @param int $user_id A user ID param that is unused.
412
+ * @param int $limit Optional. Max number of records to return.
413
+ * @param int $page Optional. Number of the page to return. Default:
414
+ * false (no pagination - return all results).
415
+ * @return array $filtered_ids IDs of users who match the query.
416
+ */
417
+ public static function search_users( $filter, $user_id, $limit = null, $page = null ) {
418
  global $wpdb, $bp;
419
 
420
  $filter = esc_sql( like_escape( $filter ) );
422
  $usermeta_table = $wpdb->base_prefix . 'usermeta';
423
  $users_table = $wpdb->base_prefix . 'users';
424
 
425
+ $pag_sql = '';
426
  if ( !empty( $limit ) && !empty( $page ) )
427
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) );
428
 
441
  return $filtered_fids;
442
  }
443
 
444
+ /**
445
+ * Get a count of users who match a search term.
446
+ *
447
+ * @todo Why does this exist, and why is it in bp-friends?
448
+ *
449
+ * @param string $filter Search term.
450
+ * @return int Count of users matching the search term.
451
+ */
452
+ public static function search_users_count( $filter ) {
453
  global $wpdb, $bp;
454
 
455
  $filter = esc_sql( like_escape( $filter ) );
472
  return $user_count[0];
473
  }
474
 
475
+ /**
476
+ * Sort a list of user IDs by their display names.
477
+ *
478
+ * @todo Why does this exist, and why is it in bp-friends?
479
+ *
480
+ * @param array $user_ids Array of user IDs.
481
+ * @return array User IDs, sorted by the associated display names.
482
+ */
483
+ public static function sort_by_name( $user_ids ) {
484
  global $wpdb, $bp;
485
 
486
  if ( !bp_is_active( 'xprofile' ) )
491
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->profile->table_name_data} pd, {$bp->profile->table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC", bp_xprofile_fullname_field_name() ) );
492
  }
493
 
494
+ /**
495
+ * Get a list of random friend IDs.
496
+ *
497
+ * @param int $user_id ID of the user whose friends are being retrieved.
498
+ * @param int $total_friends Optional. Number of random friends to get.
499
+ * Default: 5.
500
+ * @return array|bool An array of random friend user IDs on success;
501
+ * false if none are found.
502
+ */
503
+ public static function get_random_friends( $user_id, $total_friends = 5 ) {
504
  global $wpdb, $bp;
505
 
506
  $fids = array();
518
  return false;
519
  }
520
 
521
+ /**
522
+ * Get a count of a user's friends who can be invited to a given group.
523
+ *
524
+ * Users can invite any of their friends except:
525
+ *
526
+ * - users who are already in the group
527
+ * - users who have a pending invite to the group
528
+ * - users who have been banned from the group
529
+ *
530
+ * @param int $user_id ID of the user whose friends are being counted.
531
+ * @param int $group_id ID of the group friends are being invited to.
532
+ * @return int $invitable_count Eligible friend count.
533
+ */
534
+ public static function get_invitable_friend_count( $user_id, $group_id ) {
535
 
536
  // Setup some data we'll use below
537
  $is_group_admin = BP_Groups_Member::check_is_admin( $user_id, $group_id );
558
  return $invitable_count;
559
  }
560
 
561
+ /**
562
+ * Get the friend user IDs for a given friendship.
563
+ *
564
+ * @param int $friendship_id ID of the friendship.
565
+ * @return object friend_user_id and initiator_user_id.
566
+ */
567
+ public static function get_user_ids_for_friendship( $friendship_id ) {
568
  global $wpdb, $bp;
 
569
  return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) );
570
  }
571
 
572
+ /**
573
+ * Delete all friendships and friend notifications related to a user.
574
+ *
575
+ * @param int $user_id ID of the user being expunged.
576
+ */
577
+ public static function delete_all_for_user( $user_id ) {
578
  global $wpdb, $bp;
579
 
580
  // Get friends of $user_id
583
  // Delete all friendships related to $user_id
584
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) );
585
 
586
+ // Delete friend request notifications for members who have a
587
+ // notification from this user.
588
+ if ( bp_is_active( 'notifications' ) ) {
589
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->notifications->table_name} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id ) );
590
+ }
591
 
592
  // Loop through friend_ids and update their counts
593
  foreach ( (array) $friend_ids as $friend_id ) {
bp-friends/bp-friends-filters.php CHANGED
@@ -8,14 +8,16 @@
8
  */
9
 
10
  /**
11
- * Filter BP_User_Query::populate_extras to override each queried users fullname
12
  *
13
- * @since BuddyPress (1.7)
14
  *
15
- * @global BuddyPress $bp
16
- * @global WPDB $wpdb
17
- * @param BP_User_Query $user_query
18
- * @param string $user_ids_sql
 
 
19
  */
20
  function bp_friends_filter_user_query_populate_extras( BP_User_Query $user_query, $user_ids_sql ) {
21
  global $bp, $wpdb;
8
  */
9
 
10
  /**
11
+ * Filter BP_User_Query::populate_extras to override each queried users fullname.
12
  *
13
+ * @since BuddyPress (1.7.0)
14
  *
15
+ * @global BuddyPress $bp Global BuddyPress settings.
16
+ * @global WPDB $wpdb WordPress database access object.
17
+ *
18
+ * @param BP_User_Query $user_query The BP_User_Query object.
19
+ * @param string $user_ids_sql Comma-separated list of user IDs to fetch extra
20
+ * data for, as determined by BP_User_Query.
21
  */
22
  function bp_friends_filter_user_query_populate_extras( BP_User_Query $user_query, $user_ids_sql ) {
23
  global $bp, $wpdb;
bp-friends/bp-friends-functions.php CHANGED
@@ -15,6 +15,19 @@
15
  // Exit if accessed directly
16
  if ( !defined( 'ABSPATH' ) ) exit;
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
19
  global $bp;
20
 
@@ -55,6 +68,15 @@ function friends_add_friend( $initiator_userid, $friend_userid, $force_accept =
55
  return false;
56
  }
57
 
 
 
 
 
 
 
 
 
 
58
  function friends_remove_friend( $initiator_userid, $friend_userid ) {
59
 
60
  $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
@@ -80,6 +102,14 @@ function friends_remove_friend( $initiator_userid, $friend_userid ) {
80
  return false;
81
  }
82
 
 
 
 
 
 
 
 
 
83
  function friends_accept_friendship( $friendship_id ) {
84
  global $bp;
85
 
@@ -89,7 +119,7 @@ function friends_accept_friendship( $friendship_id ) {
89
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
90
 
91
  // Remove the friend request notice
92
- bp_core_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
93
 
94
  // Add a friend accepted notice for the initiating user
95
  bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
@@ -127,14 +157,21 @@ function friends_accept_friendship( $friendship_id ) {
127
  return false;
128
  }
129
 
 
 
 
 
 
 
130
  function friends_reject_friendship( $friendship_id ) {
131
  global $bp;
132
 
133
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
134
 
135
  if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
 
136
  // Remove the friend request notice
137
- bp_core_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
138
 
139
  do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
140
  return true;
@@ -143,6 +180,14 @@ function friends_reject_friendship( $friendship_id ) {
143
  return false;
144
  }
145
 
 
 
 
 
 
 
 
 
146
  function friends_withdraw_friendship( $initiator_userid, $friend_userid ) {
147
  global $bp;
148
 
@@ -160,6 +205,13 @@ function friends_withdraw_friendship( $initiator_userid, $friend_userid ) {
160
  return false;
161
  }
162
 
 
 
 
 
 
 
 
163
  function friends_check_friendship( $user_id, $possible_friend_id ) {
164
 
165
  if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
@@ -168,11 +220,25 @@ function friends_check_friendship( $user_id, $possible_friend_id ) {
168
  return false;
169
  }
170
 
171
- // Returns - 'is_friend', 'not_friends', 'pending'
 
 
 
 
 
 
 
 
172
  function friends_check_friendship_status( $user_id, $possible_friend_id ) {
173
  return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
174
  }
175
 
 
 
 
 
 
 
176
  function friends_get_total_friend_count( $user_id = 0 ) {
177
  if ( empty( $user_id ) )
178
  $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
@@ -184,6 +250,12 @@ function friends_get_total_friend_count( $user_id = 0 ) {
184
  return apply_filters( 'friends_get_total_friend_count', $count );
185
  }
186
 
 
 
 
 
 
 
187
  function friends_check_user_has_friends( $user_id ) {
188
  $friend_count = friends_get_total_friend_count( $user_id );
189
 
@@ -196,34 +268,124 @@ function friends_check_user_has_friends( $user_id ) {
196
  return true;
197
  }
198
 
 
 
 
 
 
 
 
199
  function friends_get_friendship_id( $initiator_user_id, $friend_user_id ) {
200
  return BP_Friends_Friendship::get_friendship_id( $initiator_user_id, $friend_user_id );
201
  }
202
 
 
 
 
 
 
 
 
 
 
 
203
  function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
204
  return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr );
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  function friends_search_friends( $search_terms, $user_id, $pag_num = 10, $pag_page = 1 ) {
208
  return BP_Friends_Friendship::search_friends( $search_terms, $user_id, $pag_num, $pag_page );
209
  }
210
 
 
 
 
 
 
 
 
211
  function friends_get_friendship_request_user_ids( $user_id ) {
212
  return BP_Friends_Friendship::get_friendship_request_user_ids( $user_id );
213
  }
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
216
  return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
217
  }
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
220
  return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
224
  return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
225
  }
226
 
 
 
 
 
 
 
 
 
 
227
  function friends_get_bulk_last_active( $friend_ids ) {
228
  return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
229
  }
@@ -234,10 +396,12 @@ function friends_get_bulk_last_active( $friend_ids ) {
234
  * Excludes friends that are already in the group, and banned friends if the
235
  * user is not a group admin.
236
  *
237
- * @since BuddyPress (1.0)
238
- * @param int $user_id User ID whose friends to see can be invited
239
- * @param int $group_id Group to check possible invitations against
240
- * @return mixed False if no friends, array of users if friends
 
 
241
  */
242
  function friends_get_friends_invite_list( $user_id = 0, $group_id = 0 ) {
243
 
@@ -302,14 +466,45 @@ function friends_get_friends_invite_list( $user_id = 0, $group_id = 0 ) {
302
  return apply_filters( 'bp_friends_get_invite_list', $friends, $user_id, $group_id );
303
  }
304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  function friends_count_invitable_friends( $user_id, $group_id ) {
306
  return BP_Friends_Friendship::get_invitable_friend_count( $user_id, $group_id );
307
  }
308
 
 
 
 
 
 
 
 
309
  function friends_get_friend_count_for_user( $user_id ) {
310
  return BP_Friends_Friendship::total_friend_count( $user_id );
311
  }
312
 
 
 
 
 
 
 
 
 
 
 
 
313
  function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) {
314
 
315
  $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
@@ -324,11 +519,30 @@ function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page
324
  return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count( $search_terms ) );
325
  }
326
 
 
 
 
 
 
 
327
  function friends_is_friendship_confirmed( $friendship_id ) {
328
  $friendship = new BP_Friends_Friendship( $friendship_id );
329
  return $friendship->is_confirmed;
330
  }
331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
333
 
334
  if ( 'add' == $status ) {
@@ -340,6 +554,17 @@ function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $sta
340
  }
341
  }
342
 
 
 
 
 
 
 
 
 
 
 
 
343
  function friends_remove_data( $user_id ) {
344
  global $bp;
345
 
15
  // Exit if accessed directly
16
  if ( !defined( 'ABSPATH' ) ) exit;
17
 
18
+ /**
19
+ * Create a new friendship.
20
+ *
21
+ * @param int $initiator_userid ID of the "initiator" user (the user who is
22
+ * sending the friendship request).
23
+ * @param int $friend_userid ID of the "friend" user (the user whose friendship
24
+ * is being requested).
25
+ * @param bool $force_accept Optional. Whether to force acceptance. When false,
26
+ * running friends_add_friend() will result in a friendship request.
27
+ * When true, running friends_add_friend() will result in an accepted
28
+ * friendship, with no notifications being sent. Default: false.
29
+ * @return bool True on success, false on failure.
30
+ */
31
  function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
32
  global $bp;
33
 
68
  return false;
69
  }
70
 
71
+ /**
72
+ * Remove a friendship.
73
+ *
74
+ * Will also delete the related "friendship_accepted" activity item.
75
+ *
76
+ * @param int $initiator_userid ID of the friendship initiator.
77
+ * @param int $friend_userid ID of the friend user.
78
+ * @return bool True on success, false on failure.
79
+ */
80
  function friends_remove_friend( $initiator_userid, $friend_userid ) {
81
 
82
  $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
102
  return false;
103
  }
104
 
105
+ /**
106
+ * Mark a friendship request as accepted.
107
+ *
108
+ * Also initiates a "friendship_accepted" activity item.
109
+ *
110
+ * @param int $friendship_id ID of the pending friendship object.
111
+ * @return bool True on success, false on failure.
112
+ */
113
  function friends_accept_friendship( $friendship_id ) {
114
  global $bp;
115
 
119
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
120
 
121
  // Remove the friend request notice
122
+ bp_core_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
123
 
124
  // Add a friend accepted notice for the initiating user
125
  bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
157
  return false;
158
  }
159
 
160
+ /**
161
+ * Mark a friendship request as rejected.
162
+ *
163
+ * @param int $friendship_id ID of the pending friendship object.
164
+ * @return bool True on success, false on failure.
165
+ */
166
  function friends_reject_friendship( $friendship_id ) {
167
  global $bp;
168
 
169
  $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
170
 
171
  if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
172
+
173
  // Remove the friend request notice
174
+ bp_core_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
175
 
176
  do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
177
  return true;
180
  return false;
181
  }
182
 
183
+ /**
184
+ * Withdraw a friendship request.
185
+ *
186
+ * @param int $initiator_userid ID of the friendship initiator - this is the
187
+ * user who requested the friendship, and is doing the withdrawing.
188
+ * @param int $friend_userid ID of the requested friend.
189
+ * @return bool True on success, false on failure.
190
+ */
191
  function friends_withdraw_friendship( $initiator_userid, $friend_userid ) {
192
  global $bp;
193
 
205
  return false;
206
  }
207
 
208
+ /**
209
+ * Check whether two users are friends.
210
+ *
211
+ * @param int $user_id ID of the first user.
212
+ * @param int $possible_friend_id ID of the other user.
213
+ * @return bool Returns true if the two users are friends, otherwise false.
214
+ */
215
  function friends_check_friendship( $user_id, $possible_friend_id ) {
216
 
217
  if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
220
  return false;
221
  }
222
 
223
+ /**
224
+ * Get the friendship status of two friends.
225
+ *
226
+ * Will return 'is_friends', 'not_friends', or 'pending'.
227
+ *
228
+ * @param int $user_id ID of the first user.
229
+ * @param int $possible_friend_id ID of the other user.
230
+ * @return string Friend status of the two users.
231
+ */
232
  function friends_check_friendship_status( $user_id, $possible_friend_id ) {
233
  return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
234
  }
235
 
236
+ /**
237
+ * Get the friend count of a given user.
238
+ *
239
+ * @param int $user_id ID of the user whose friends are being counted.
240
+ * @return int Friend count of the user.
241
+ */
242
  function friends_get_total_friend_count( $user_id = 0 ) {
243
  if ( empty( $user_id ) )
244
  $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
250
  return apply_filters( 'friends_get_total_friend_count', $count );
251
  }
252
 
253
+ /**
254
+ * Check whether a given user has any friends.
255
+ *
256
+ * @param int $user_id ID of the user whose friends are being checked.
257
+ * @return bool True if the user has friends, otherwise false.
258
+ */
259
  function friends_check_user_has_friends( $user_id ) {
260
  $friend_count = friends_get_total_friend_count( $user_id );
261
 
268
  return true;
269
  }
270
 
271
+ /**
272
+ * Get the ID of two users' friendship, if it exists.
273
+ *
274
+ * @param int $initiator_user_id ID of the first user.
275
+ * @param int $friend_user_id ID of the second user.
276
+ * @return int|bool ID of the friendship if found, otherwise false.
277
+ */
278
  function friends_get_friendship_id( $initiator_user_id, $friend_user_id ) {
279
  return BP_Friends_Friendship::get_friendship_id( $initiator_user_id, $friend_user_id );
280
  }
281
 
282
+ /**
283
+ * Get the IDs of a given user's friends.
284
+ *
285
+ * @param int $user_id ID of the user whose friends are being retreived.
286
+ * @param bool $friend_requests_only Optional. Whether to fetch unaccepted
287
+ * requests only. Default: false.
288
+ * @param bool $assoc_arr Optional. True to receive an array of arrays keyed as
289
+ * 'user_id' => $user_id; false to get a one-dimensional array of user
290
+ * IDs. Default: false.
291
+ */
292
  function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
293
  return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr );
294
  }
295
 
296
+ /**
297
+ * Search the friends of a user by a search string.
298
+ *
299
+ * @param string $filter The search string, matched against xprofile fields (if
300
+ * available), or usermeta 'nickname' field.
301
+ * @param int $user_id ID of the user whose friends are being searched.
302
+ * @param int $limit Optional. Max number of friends to return.
303
+ * @param int $page Optional. The page of results to return. Default: null (no
304
+ * pagination - return all results).
305
+ * @return array|bool On success, an array: {
306
+ * @type array $friends IDs of friends returned by the query.
307
+ * @type int $count Total number of friends (disregarding
308
+ * pagination) who match the search.
309
+ * }. Returns false on failure.
310
+ */
311
  function friends_search_friends( $search_terms, $user_id, $pag_num = 10, $pag_page = 1 ) {
312
  return BP_Friends_Friendship::search_friends( $search_terms, $user_id, $pag_num, $pag_page );
313
  }
314
 
315
+ /**
316
+ * Get a list of IDs of users who have requested friendship of a given user.
317
+ *
318
+ * @param int $user_id The ID of the user who has received the friendship
319
+ * requests.
320
+ * @return array|bool An array of user IDs, or false if none are found.
321
+ */
322
  function friends_get_friendship_request_user_ids( $user_id ) {
323
  return BP_Friends_Friendship::get_friendship_request_user_ids( $user_id );
324
  }
325
 
326
+ /**
327
+ * Get a user's most recently active friends.
328
+ *
329
+ * @see BP_Core_User::get_users() for a description of return value.
330
+ *
331
+ * @param int $user_id ID of the user whose friends are being retreived.
332
+ * @param int $per_page Optional. Number of results to return per page.
333
+ * Default: 0 (no pagination; show all results).
334
+ * @param int $page Optional. Number of the page of results to return.
335
+ * Default: 0 (no pagination; show all results).
336
+ * @param string $filter Optional. Limit results to those matching a search
337
+ * string.
338
+ * @return array See {@link BP_Core_User::get_users()}.
339
+ */
340
  function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
341
  return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
342
  }
343
 
344
+ /**
345
+ * Get a user's friends, in alphabetical order.
346
+ *
347
+ * @see BP_Core_User::get_users() for a description of return value.
348
+ *
349
+ * @param int $user_id ID of the user whose friends are being retreived.
350
+ * @param int $per_page Optional. Number of results to return per page.
351
+ * Default: 0 (no pagination; show all results).
352
+ * @param int $page Optional. Number of the page of results to return.
353
+ * Default: 0 (no pagination; show all results).
354
+ * @param string $filter Optional. Limit results to those matching a search
355
+ * string.
356
+ * @return array See {@link BP_Core_User::get_users()}.
357
+ */
358
  function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
359
  return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
360
  }
361
 
362
+ /**
363
+ * Get a user's friends, in the order in which they joined the site.
364
+ *
365
+ * @see BP_Core_User::get_users() for a description of return value.
366
+ *
367
+ * @param int $user_id ID of the user whose friends are being retreived.
368
+ * @param int $per_page Optional. Number of results to return per page.
369
+ * Default: 0 (no pagination; show all results).
370
+ * @param int $page Optional. Number of the page of results to return.
371
+ * Default: 0 (no pagination; show all results).
372
+ * @param string $filter Optional. Limit results to those matching a search
373
+ * string.
374
+ * @return array See {@link BP_Core_User::get_users()}.
375
+ */
376
  function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
377
  return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
378
  }
379
 
380
+ /**
381
+ * Get the last active date of many users at once.
382
+ *
383
+ * @see BP_Friends_Friendship::get_bulk_last_active() for a description of
384
+ * arguments and return value.
385
+ *
386
+ * @param array $user_ids See BP_Friends_Friendship::get_bulk_last_active().
387
+ * @return array $user_ids See BP_Friends_Friendship::get_bulk_last_active().
388
+ */
389
  function friends_get_bulk_last_active( $friend_ids ) {
390
  return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
391
  }
396
  * Excludes friends that are already in the group, and banned friends if the
397
  * user is not a group admin.
398
  *
399
+ * @since BuddyPress (1.0.0)
400
+ *
401
+ * @param int $user_id User ID whose friends to see can be invited. Default:
402
+ * ID of the logged-in user.
403
+ * @param int $group_id Group to check possible invitations against.
404
+ * @return mixed False if no friends, array of users if friends.
405
  */
406
  function friends_get_friends_invite_list( $user_id = 0, $group_id = 0 ) {
407
 
466
  return apply_filters( 'bp_friends_get_invite_list', $friends, $user_id, $group_id );
467
  }
468
 
469
+ /**
470
+ * Get a count of a user's friends who can be invited to a given group.
471
+ *
472
+ * Users can invite any of their friends except:
473
+ *
474
+ * - users who are already in the group
475
+ * - users who have a pending invite to the group
476
+ * - users who have been banned from the group
477
+ *
478
+ * @param int $user_id ID of the user whose friends are being counted.
479
+ * @param int $group_id ID of the group friends are being invited to.
480
+ * @return int $invitable_count Eligible friend count.
481
+ */
482
  function friends_count_invitable_friends( $user_id, $group_id ) {
483
  return BP_Friends_Friendship::get_invitable_friend_count( $user_id, $group_id );
484
  }
485
 
486
+ /**
487
+ * Get a total friend count for a given user.
488
+ *
489
+ * @param int $user_id Optional. ID of the user whose friendships you are
490
+ * counting. Default: displayed user (if any), otherwise logged-in user.
491
+ * @return int Friend count for the user.
492
+ */
493
  function friends_get_friend_count_for_user( $user_id ) {
494
  return BP_Friends_Friendship::total_friend_count( $user_id );
495
  }
496
 
497
+ /**
498
+ * Return a list of a user's friends, filtered by a search term.
499
+ *
500
+ * @param string $search_terms Search term to filter on.
501
+ * @param int $user_id ID of the user whose friends are being searched.
502
+ * @param int $pag_num Number of results to return per page. Default: 0 (no
503
+ * pagination - show all results).
504
+ * @param int $pag_num Number of the page being requested. Default: 0 (no
505
+ * pagination - show all results).
506
+ * @return array Array of BP_Core_User objects corresponding to friends.
507
+ */
508
  function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) {
509
 
510
  $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
519
  return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count( $search_terms ) );
520
  }
521
 
522
+ /**
523
+ * Has a friendship been confirmed (accepted)?
524
+ *
525
+ * @param int $friendship_id The ID of the friendship being checked.
526
+ * @return bool True if the friendship is confirmed, otherwise false.
527
+ */
528
  function friends_is_friendship_confirmed( $friendship_id ) {
529
  $friendship = new BP_Friends_Friendship( $friendship_id );
530
  return $friendship->is_confirmed;
531
  }
532
 
533
+ /**
534
+ * Update user friend counts.
535
+ *
536
+ * Friend counts are cached in usermeta for performance reasons. After a
537
+ * friendship event (acceptance, deletion), call this function to regenerate
538
+ * the cached values.
539
+ *
540
+ * @param int $initiator_user_id ID of the first user.
541
+ * @param int $friend_user_id ID of the second user.
542
+ * @param string $status Optional. The friendship event that's been triggered.
543
+ * 'add' will ++ each user's friend counts, while any other string
544
+ * will --.
545
+ */
546
  function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
547
 
548
  if ( 'add' == $status ) {
554
  }
555
  }
556
 
557
+ /**
558
+ * Remove all friends-related data concerning a given user.
559
+ *
560
+ * Removes the following:
561
+ *
562
+ * - Friendships of which the user is a member
563
+ * - Cached friend count for the user
564
+ * - Notifications of friendship requests sent by the user
565
+ *
566
+ * @param int $user_id ID of the user whose friend data is being removed.
567
+ */
568
  function friends_remove_data( $user_id ) {
569
  global $bp;
570
 
bp-friends/bp-friends-loader.php CHANGED
@@ -2,10 +2,10 @@
2
  /**
3
  * BuddyPress Friends Streams Loader
4
  *
5
- * The friends component is for users to create relationships with each other
6
  *
7
  * @package BuddyPress
8
- * @subpackage Friends Core
9
  */
10
 
11
  // Exit if accessed directly
@@ -14,23 +14,29 @@ if ( !defined( 'ABSPATH' ) ) exit;
14
  class BP_Friends_Component extends BP_Component {
15
 
16
  /**
17
- * Start the friends component creation process
18
  *
19
- * @since BuddyPress (1.5)
20
  */
21
  function __construct() {
22
  parent::start(
23
  'friends',
24
  __( 'Friend Connections', 'buddypress' ),
25
- BP_PLUGIN_DIR
 
 
 
26
  );
27
  }
28
 
29
  /**
30
- * Include files
 
 
 
 
31
  */
32
  public function includes( $includes = array() ) {
33
- // Files to include
34
  $includes = array(
35
  'actions',
36
  'screens',
@@ -40,24 +46,32 @@ class BP_Friends_Component extends BP_Component {
40
  'template',
41
  'functions',
42
  'notifications',
 
43
  );
44
 
45
  parent::includes( $includes );
46
  }
47
 
48
  /**
49
- * Setup globals
50
  *
51
  * The BP_FRIENDS_SLUG constant is deprecated, and only used here for
52
  * backwards compatibility.
53
  *
54
- * @since BuddyPress (1.5)
55
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
56
  */
57
  public function setup_globals( $args = array() ) {
58
- global $bp;
59
 
60
- define ( 'BP_FRIENDS_DB_VERSION', '1800' );
 
 
 
 
61
 
62
  // Define a slug, if necessary
63
  if ( !defined( 'BP_FRIENDS_SLUG' ) )
@@ -71,7 +85,7 @@ class BP_Friends_Component extends BP_Component {
71
 
72
  // All globals for the friends component.
73
  // Note that global_tables is included in this array.
74
- $globals = array(
75
  'slug' => BP_FRIENDS_SLUG,
76
  'has_directory' => false,
77
  'search_string' => __( 'Search Friends...', 'buddypress' ),
@@ -79,18 +93,23 @@ class BP_Friends_Component extends BP_Component {
79
  'global_tables' => $global_tables
80
  );
81
 
82
- parent::setup_globals( $globals );
83
  }
84
 
85
  /**
86
- * Setup BuddyBar navigation
 
 
 
 
87
  *
88
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
89
  */
90
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
91
- global $bp;
92
-
93
- $sub_nav = array();
94
 
95
  // Add 'Friends' to the main navigation
96
  $main_nav = array(
@@ -138,15 +157,17 @@ class BP_Friends_Component extends BP_Component {
138
  }
139
 
140
  /**
141
- * Set up the Toolbar
 
 
142
  *
143
- * @global BuddyPress $bp The one true BuddyPress instance
 
 
 
144
  */
145
  public function setup_admin_bar( $wp_admin_nav = array() ) {
146
- global $bp;
147
-
148
- // Prevent debug notices
149
- $wp_admin_nav = array();
150
 
151
  // Menus for logged in user
152
  if ( is_user_logged_in() ) {
@@ -194,12 +215,10 @@ class BP_Friends_Component extends BP_Component {
194
  }
195
 
196
  /**
197
- * Sets up the title for pages and <title>
198
- *
199
- * @global BuddyPress $bp The one true BuddyPress instance
200
  */
201
  function setup_title() {
202
- global $bp;
203
 
204
  // Adjust title
205
  if ( bp_is_friends_component() ) {
@@ -219,8 +238,10 @@ class BP_Friends_Component extends BP_Component {
219
  }
220
  }
221
 
 
 
 
222
  function bp_setup_friends() {
223
- global $bp;
224
- $bp->friends = new BP_Friends_Component();
225
  }
226
  add_action( 'bp_setup_components', 'bp_setup_friends', 6 );
2
  /**
3
  * BuddyPress Friends Streams Loader
4
  *
5
+ * The friends component is for users to create relationships with each other.
6
  *
7
  * @package BuddyPress
8
+ * @subpackage Friends
9
  */
10
 
11
  // Exit if accessed directly
14
  class BP_Friends_Component extends BP_Component {
15
 
16
  /**
17
+ * Start the friends component creation process.
18
  *
19
+ * @since BuddyPress (1.5.0)
20
  */
21
  function __construct() {
22
  parent::start(
23
  'friends',
24
  __( 'Friend Connections', 'buddypress' ),
25
+ BP_PLUGIN_DIR,
26
+ array(
27
+ 'adminbar_myaccount_order' => 60
28
+ )
29
  );
30
  }
31
 
32
  /**
33
+ * Include bp-friends files.
34
+ *
35
+ * @see BP_Component::includes() for description of parameters.
36
+ *
37
+ * @param array $includes See {@link BP_Component::includes()}.
38
  */
39
  public function includes( $includes = array() ) {
 
40
  $includes = array(
41
  'actions',
42
  'screens',
46
  'template',
47
  'functions',
48
  'notifications',
49
+ 'widgets',
50
  );
51
 
52
  parent::includes( $includes );
53
  }
54
 
55
  /**
56
+ * Set up bp-friends global settings.
57
  *
58
  * The BP_FRIENDS_SLUG constant is deprecated, and only used here for
59
  * backwards compatibility.
60
  *
61
+ * @since BuddyPress (1.5.0)
62
+ *
63
+ * @see BP_Component::setup_globals() for description of parameters.
64
+ *
65
+ * @param array $args See {@link BP_Component::setup_globals()}.
66
  */
67
  public function setup_globals( $args = array() ) {
68
+ $bp = buddypress();
69
 
70
+ // Deprecated. Do not use.
71
+ // Defined conditionally to support unit tests.
72
+ if ( ! defined( 'BP_FRIENDS_DB_VERSION' ) ) {
73
+ define( 'BP_FRIENDS_DB_VERSION', '1800' );
74
+ }
75
 
76
  // Define a slug, if necessary
77
  if ( !defined( 'BP_FRIENDS_SLUG' ) )
85
 
86
  // All globals for the friends component.
87
  // Note that global_tables is included in this array.
88
+ $args = array(
89
  'slug' => BP_FRIENDS_SLUG,
90
  'has_directory' => false,
91
  'search_string' => __( 'Search Friends...', 'buddypress' ),
93
  'global_tables' => $global_tables
94
  );
95
 
96
+ parent::setup_globals( $args );
97
  }
98
 
99
  /**
100
+ * Set up component navigation.
101
+ *
102
+ * @since BuddyPress (1.5.0)
103
+ *
104
+ * @see BP_Component::setup_nav() for a description of arguments.
105
  *
106
+ * @param array $main_nav Optional. See BP_Component::setup_nav() for
107
+ * description.
108
+ * @param array $sub_nav Optional. See BP_Component::setup_nav() for
109
+ * description.
110
  */
111
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
112
+ $bp = buddypress();
 
 
113
 
114
  // Add 'Friends' to the main navigation
115
  $main_nav = array(
157
  }
158
 
159
  /**
160
+ * Set up bp-friends integration with the WordPress admin bar.
161
+ *
162
+ * @since BuddyPress (1.5.0)
163
  *
164
+ * @see BP_Component::setup_admin_bar() for a description of arguments.
165
+ *
166
+ * @param array $wp_admin_nav See BP_Component::setup_admin_bar()
167
+ * for description.
168
  */
169
  public function setup_admin_bar( $wp_admin_nav = array() ) {
170
+ $bp = buddypress();
 
 
 
171
 
172
  // Menus for logged in user
173
  if ( is_user_logged_in() ) {
215
  }
216
 
217
  /**
218
+ * Set up the title for pages and <title>.
 
 
219
  */
220
  function setup_title() {
221
+ $bp = buddypress();
222
 
223
  // Adjust title
224
  if ( bp_is_friends_component() ) {
238
  }
239
  }
240
 
241
+ /**
242
+ * Set up the bp-forums component.
243
+ */
244
  function bp_setup_friends() {
245
+ buddypress()->friends = new BP_Friends_Component();
 
246
  }
247
  add_action( 'bp_setup_components', 'bp_setup_friends', 6 );
bp-friends/bp-friends-notifications.php CHANGED
@@ -13,6 +13,16 @@
13
  // Exit if accessed directly
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
 
 
 
 
 
 
 
 
 
 
16
  function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
17
 
18
  $initiator_name = bp_core_get_user_displayname( $initiator_id );
@@ -54,6 +64,16 @@ To view %3$s\'s profile: %4$s
54
  do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id );
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
57
  function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
58
 
59
  $friend_name = bp_core_get_user_displayname( $friend_id );
13
  // Exit if accessed directly
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
+ /**
17
+ * Send notifications related to a new friendship request.
18
+ *
19
+ * When a friendship is requested, an email and a BP notification are sent to
20
+ * the user of whom friendship has been requested ($friend_id).
21
+ *
22
+ * @param int $friendship_id ID of the friendship object.
23
+ * @param int $initiator_id ID of the user who initiated the request.
24
+ * @param int $friend_id ID of the request recipient.
25
+ */
26
  function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
27
 
28
  $initiator_name = bp_core_get_user_displayname( $initiator_id );
64
  do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id );
65
  }
66
 
67
+ /**
68
+ * Send notifications related to the acceptance of a friendship request.
69
+ *
70
+ * When a friendship request is accepted, an email and a BP notification are
71
+ * sent to the user who requested the friendship ($initiator_id).
72
+ *
73
+ * @param int $friendship_id ID of the friendship object.
74
+ * @param int $initiator_id ID of the user who initiated the request.
75
+ * @param int $friend_id ID of the request recipient.
76
+ */
77
  function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
78
 
79
  $friend_name = bp_core_get_user_displayname( $friend_id );
bp-friends/bp-friends-screens.php CHANGED
@@ -3,9 +3,9 @@
3
  /**
4
  * BuddyPress Friends Screen Functions
5
  *
6
- * Screen functions are the controllers of BuddyPress. They will execute when their
7
- * specific URL is caught. They will first save or manipulate data using business
8
- * functions, then pass on the user to a template file.
9
  *
10
  * @package BuddyPress
11
  * @subpackage FriendsScreens
@@ -14,17 +14,22 @@
14
  // Exit if accessed directly
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
 
 
 
17
  function friends_screen_my_friends() {
18
- global $bp;
19
 
20
  // Delete any friendship acceptance notifications for the user when viewing a profile
21
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->friends->id, 'friendship_accepted' );
22
 
23
  do_action( 'friends_screen_my_friends' );
24
 
25
  bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
26
  }
27
 
 
 
 
28
  function friends_screen_requests() {
29
  if ( bp_is_action_variable( 'accept', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
30
  // Check the nonce
@@ -62,12 +67,16 @@ function friends_screen_requests() {
62
 
63
  do_action( 'friends_screen_requests' );
64
 
65
- if ( isset( $_GET['new'] ) )
66
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), 'friends', 'friendship_request' );
 
67
 
68
  bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
69
  }
70
 
 
 
 
71
  function friends_screen_notification_settings() {
72
 
73
  if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) )
3
  /**
4
  * BuddyPress Friends Screen Functions
5
  *
6
+ * Screen functions are the controllers of BuddyPress. They will execute when
7
+ * their specific URL is caught. They will first save or manipulate data using
8
+ * business functions, then pass on the user to a template file.
9
  *
10
  * @package BuddyPress
11
  * @subpackage FriendsScreens
14
  // Exit if accessed directly
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
17
+ /**
18
+ * Catch and process the My Friends page.
19
+ */
20
  function friends_screen_my_friends() {
 
21
 
22
  // Delete any friendship acceptance notifications for the user when viewing a profile
23
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
24
 
25
  do_action( 'friends_screen_my_friends' );
26
 
27
  bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
28
  }
29
 
30
+ /**
31
+ * Catch and process the Requests page.
32
+ */
33
  function friends_screen_requests() {
34
  if ( bp_is_action_variable( 'accept', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
35
  // Check the nonce
67
 
68
  do_action( 'friends_screen_requests' );
69
 
70
+ if ( isset( $_GET['new'] ) ) {
71
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_request' );
72
+ }
73
 
74
  bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
75
  }
76
 
77
+ /**
78
+ * Add Friends-related settings to the Settings > Notifications page.
79
+ */
80
  function friends_screen_notification_settings() {
81
 
82
  if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) )
bp-friends/bp-friends-template.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * BuddyPress Friends Template Functions
5
  *
6
  * @package BuddyPress
7
  * @subpackage FriendsTemplate
@@ -11,11 +11,9 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
- * Output the friends component slug
15
  *
16
- * @package BuddyPress
17
- * @subpackage Friends Template
18
- * @since BuddyPress (1.5)
19
  *
20
  * @uses bp_get_friends_slug()
21
  */
@@ -23,11 +21,9 @@ function bp_friends_slug() {
23
  echo bp_get_friends_slug();
24
  }
25
  /**
26
- * Return the friends component slug
27
  *
28
- * @package BuddyPress
29
- * @subpackage Friends Template
30
- * @since BuddyPress (1.5)
31
  */
32
  function bp_get_friends_slug() {
33
  global $bp;
@@ -35,11 +31,9 @@ function bp_friends_slug() {
35
  }
36
 
37
  /**
38
- * Output the friends component root slug
39
  *
40
- * @package BuddyPress
41
- * @subpackage Friends Template
42
- * @since BuddyPress (1.5)
43
  *
44
  * @uses bp_get_friends_root_slug()
45
  */
@@ -47,17 +41,22 @@ function bp_friends_root_slug() {
47
  echo bp_get_friends_root_slug();
48
  }
49
  /**
50
- * Return the friends component root slug
51
  *
52
- * @package BuddyPress
53
- * @subpackage Friends Template
54
- * @since BuddyPress (1.5)
55
  */
56
  function bp_get_friends_root_slug() {
57
  global $bp;
58
  return apply_filters( 'bp_get_friends_root_slug', $bp->friends->root_slug );
59
  }
60
 
 
 
 
 
 
 
 
61
  function bp_friends_random_friends() {
62
 
63
  if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) {
@@ -98,13 +97,13 @@ function bp_friends_random_friends() {
98
  }
99
 
100
  /**
101
- * Pull up a group of random members, and display some profile data about them
102
  *
103
  * This function is no longer used by BuddyPress core.
104
  *
105
- * @package BuddyPress
106
  *
107
- * @param int $total_members The number of members to retrieve
108
  */
109
  function bp_friends_random_members( $total_members = 5 ) {
110
 
@@ -163,6 +162,13 @@ function bp_friends_random_members( $total_members = 5 ) {
163
  <?php
164
  }
165
 
 
 
 
 
 
 
 
166
  function bp_friend_search_form() {
167
 
168
  $action = bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/search/';
@@ -182,6 +188,9 @@ function bp_friend_search_form() {
182
  <?php
183
  }
184
 
 
 
 
185
  function bp_member_add_friend_button() {
186
  global $members_template;
187
 
@@ -194,9 +203,19 @@ function bp_member_add_friend_button() {
194
  }
195
  add_action( 'bp_directory_members_actions', 'bp_member_add_friend_button' );
196
 
 
 
 
197
  function bp_member_total_friend_count() {
198
  echo bp_get_member_total_friend_count();
199
  }
 
 
 
 
 
 
 
200
  function bp_get_member_total_friend_count() {
201
  global $members_template;
202
 
@@ -207,24 +226,23 @@ function bp_member_total_friend_count() {
207
  }
208
 
209
  /**
210
- * bp_potential_friend_id( $user_id )
211
  *
212
- * Outputs the ID of the potential friend
213
  *
214
- * @uses bp_get_potential_friend_id()
215
- * @param int $user_id Optional
216
  */
217
  function bp_potential_friend_id( $user_id = 0 ) {
218
  echo bp_get_potential_friend_id( $user_id );
219
  }
220
  /**
221
- * bp_get_potential_friend_id( $user_id )
222
- *
223
- * Returns the ID of the potential friend
224
  *
225
  * @global object $friends_template
226
- * @param int $user_id
227
- * @return int ID of potential friend
 
 
228
  */
229
  function bp_get_potential_friend_id( $user_id = 0 ) {
230
  global $friends_template;
@@ -238,12 +256,13 @@ function bp_potential_friend_id( $user_id = 0 ) {
238
  }
239
 
240
  /**
241
- * bp_is_friend( $user_id )
242
  *
243
- * Returns - 'is_friend', 'not_friends', 'pending'
244
  *
245
- * @param int $potential_friend_id
246
- * @return string
 
247
  */
248
  function bp_is_friend( $user_id = 0 ) {
249
 
@@ -259,9 +278,25 @@ function bp_is_friend( $user_id = 0 ) {
259
  return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id );
260
  }
261
 
 
 
 
 
 
 
 
 
262
  function bp_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
263
  echo bp_get_add_friend_button( $potential_friend_id, $friend_status );
264
  }
 
 
 
 
 
 
 
 
265
  function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
266
 
267
  if ( empty( $potential_friend_id ) )
@@ -290,6 +325,23 @@ function bp_add_friend_button( $potential_friend_id = 0, $friend_status = false
290
  );
291
  break;
292
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  case 'is_friend' :
294
  $button = array(
295
  'id' => 'is_friend',
@@ -329,6 +381,14 @@ function bp_add_friend_button( $potential_friend_id = 0, $friend_status = false
329
  return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) );
330
  }
331
 
 
 
 
 
 
 
 
 
332
  function bp_get_friend_ids( $user_id = 0 ) {
333
 
334
  if ( empty( $user_id ) )
@@ -343,13 +403,14 @@ function bp_get_friend_ids( $user_id = 0 ) {
343
  }
344
 
345
  /**
346
- * Get a user's friendship requests
347
  *
348
- * Note that we return a 0 if no pending requests are found. This is necessary because of the
349
- * structure of the $include parameter in bp_has_members().
350
  *
351
- * @param int $user_id Defaults to displayed user
352
- * @return mixed Returns an array of users if found, or a 0 if none are found
 
353
  */
354
  function bp_get_friendship_requests( $user_id = 0 ) {
355
  if ( !$user_id ) {
@@ -371,9 +432,17 @@ function bp_get_friendship_requests( $user_id = 0 ) {
371
  return apply_filters( 'bp_get_friendship_requests', $requests );
372
  }
373
 
 
 
 
374
  function bp_friend_friendship_id() {
375
  echo bp_get_friend_friendship_id();
376
  }
 
 
 
 
 
377
  function bp_get_friend_friendship_id() {
378
  global $members_template;
379
 
@@ -385,9 +454,17 @@ function bp_friend_friendship_id() {
385
  return apply_filters( 'bp_get_friend_friendship_id', $friendship_id );
386
  }
387
 
 
 
 
388
  function bp_friend_accept_request_link() {
389
  echo bp_get_friend_accept_request_link();
390
  }
 
 
 
 
 
391
  function bp_get_friend_accept_request_link() {
392
  global $members_template;
393
 
@@ -399,9 +476,17 @@ function bp_friend_accept_request_link() {
399
  return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) );
400
  }
401
 
 
 
 
402
  function bp_friend_reject_request_link() {
403
  echo bp_get_friend_reject_request_link();
404
  }
 
 
 
 
 
405
  function bp_get_friend_reject_request_link() {
406
  global $members_template;
407
 
@@ -413,17 +498,42 @@ function bp_friend_reject_request_link() {
413
  return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) );
414
  }
415
 
 
 
 
 
 
416
  function bp_total_friend_count( $user_id = 0 ) {
417
  echo bp_get_total_friend_count( $user_id );
418
  }
 
 
 
 
 
 
419
  function bp_get_total_friend_count( $user_id = 0 ) {
420
  return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) );
421
  }
422
  add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' );
423
 
 
 
 
 
 
 
 
424
  function bp_friend_total_requests_count( $user_id = 0 ) {
425
  echo bp_friend_get_total_requests_count( $user_id );
426
  }
 
 
 
 
 
 
 
427
  function bp_friend_get_total_requests_count( $user_id = 0 ) {
428
  if ( empty( $user_id ) )
429
  $user_id = bp_loggedin_user_id();
1
  <?php
2
 
3
  /**
4
+ * BuddyPress Friends Template Functions.
5
  *
6
  * @package BuddyPress
7
  * @subpackage FriendsTemplate
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  /**
14
+ * Output the friends component slug.
15
  *
16
+ * @since BuddyPress (1.5.0)
 
 
17
  *
18
  * @uses bp_get_friends_slug()
19
  */
21
  echo bp_get_friends_slug();
22
  }
23
  /**
24
+ * Return the friends component slug.
25
  *
26
+ * @since BuddyPress (1.5.0)
 
 
27
  */
28
  function bp_get_friends_slug() {
29
  global $bp;
31
  }
32
 
33
  /**
34
+ * Output the friends component root slug.
35
  *
36
+ * @since BuddyPress (1.5.0)
 
 
37
  *
38
  * @uses bp_get_friends_root_slug()
39
  */
41
  echo bp_get_friends_root_slug();
42
  }
43
  /**
44
+ * Return the friends component root slug.
45
  *
46
+ * @since BuddyPress (1.5.0)
 
 
47
  */
48
  function bp_get_friends_root_slug() {
49
  global $bp;
50
  return apply_filters( 'bp_get_friends_root_slug', $bp->friends->root_slug );
51
  }
52
 
53
+ /**
54
+ * Output a block of random friends.
55
+ *
56
+ * No longer used in BuddyPress.
57
+ *
58
+ * @todo Deprecate
59
+ */
60
  function bp_friends_random_friends() {
61
 
62
  if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) {
97
  }
98
 
99
  /**
100
+ * Pull up a group of random members, and display some profile data about them.
101
  *
102
  * This function is no longer used by BuddyPress core.
103
  *
104
+ * @todo Deprecate
105
  *
106
+ * @param int $total_members The number of members to retrieve.
107
  */
108
  function bp_friends_random_members( $total_members = 5 ) {
109
 
162
  <?php
163
  }
164
 
165
+ /**
166
+ * Display a Friends search form.
167
+ *
168
+ * No longer used in BuddyPress.
169
+ *
170
+ * @todo Deprecate
171
+ */
172
  function bp_friend_search_form() {
173
 
174
  $action = bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/search/';
188
  <?php
189
  }
190
 
191
+ /**
192
+ * Output the Add Friend button in member directories.
193
+ */
194
  function bp_member_add_friend_button() {
195
  global $members_template;
196
 
203
  }
204
  add_action( 'bp_directory_members_actions', 'bp_member_add_friend_button' );
205
 
206
+ /**
207
+ * Output the friend count for the current member in the loop.
208
+ */
209
  function bp_member_total_friend_count() {
210
  echo bp_get_member_total_friend_count();
211
  }
212
+ /**
213
+ * Return the friend count for the current member in the loop.
214
+ *
215
+ * Return value is a string of the form "x friends".
216
+ *
217
+ * @return string A string of the form "x friends".
218
+ */
219
  function bp_get_member_total_friend_count() {
220
  global $members_template;
221
 
226
  }
227
 
228
  /**
229
+ * Output the ID of the current user in the friend request loop.
230
  *
231
+ * @see bp_get_potential_friend_id() for a description of arguments.
232
  *
233
+ * @param int $user_id See {@link bp_get_potential_friend_id()}.
 
234
  */
235
  function bp_potential_friend_id( $user_id = 0 ) {
236
  echo bp_get_potential_friend_id( $user_id );
237
  }
238
  /**
239
+ * Return the ID of current user in the friend request loop.
 
 
240
  *
241
  * @global object $friends_template
242
+ *
243
+ * @param int $user_id Optional. If provided, the function will simply
244
+ * return this value.
245
+ * @return int ID of potential friend.
246
  */
247
  function bp_get_potential_friend_id( $user_id = 0 ) {
248
  global $friends_template;
256
  }
257
 
258
  /**
259
+ * Check whether a given user is a friend of the logged-in user.
260
  *
261
+ * Returns - 'is_friend', 'not_friends', 'pending'.
262
  *
263
+ * @param int $user_id ID of the potential friend. Default: the value of
264
+ * {@link bp_get_potential_friend_id()}.
265
+ * @return string 'is_friend', 'not_friends', or 'pending'.
266
  */
267
  function bp_is_friend( $user_id = 0 ) {
268
 
278
  return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id );
279
  }
280
 
281
+ /**
282
+ * Output the Add Friend button.
283
+ *
284
+ * @see bp_get_add_friend_button() for information on arguments.
285
+ *
286
+ * @param int $potential_friend_id See {@link bp_get_add_friend_button()}.
287
+ * @param int $friend_status See {@link bp_get_add_friend_button()}.
288
+ */
289
  function bp_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
290
  echo bp_get_add_friend_button( $potential_friend_id, $friend_status );
291
  }
292
+ /**
293
+ * Create the Add Friend button.
294
+ *
295
+ * @param int $potential_friend_id ID of the user to whom the button
296
+ * applies. Default: value of {@link bp_get_potential_friend_id()}.
297
+ * @param bool $friend_status Not currently used.
298
+ * @return string HTML for the Add Friend button.
299
+ */
300
  function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
301
 
302
  if ( empty( $potential_friend_id ) )
325
  );
326
  break;
327
 
328
+ case 'awaiting_response' :
329
+ $button = array(
330
+ 'id' => 'awaiting_response',
331
+ 'component' => 'friends',
332
+ 'must_be_logged_in' => true,
333
+ 'block_self' => true,
334
+ 'wrapper_class' => 'friendship-button awaiting_response_friend',
335
+ 'wrapper_id' => 'friendship-button-' . $potential_friend_id,
336
+ 'link_href' => bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/',
337
+ 'link_text' => __( 'Friendship Requested', 'buddypress' ),
338
+ 'link_title' => __( 'Friendship Requested', 'buddypress' ),
339
+ 'link_id' => 'friend-' . $potential_friend_id,
340
+ 'link_rel' => 'remove',
341
+ 'link_class' => 'friendship-button awaiting_response_friend requested'
342
+ );
343
+ break;
344
+
345
  case 'is_friend' :
346
  $button = array(
347
  'id' => 'is_friend',
381
  return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) );
382
  }
383
 
384
+ /**
385
+ * Get a comma-separated list of IDs of a user's friends.
386
+ *
387
+ * @param int $user_id Optional. Default: the displayed user's ID, or the
388
+ * logged-in user's ID.
389
+ * @return string|bool A comma-separated list of friend IDs if any are found,
390
+ * otherwise false.
391
+ */
392
  function bp_get_friend_ids( $user_id = 0 ) {
393
 
394
  if ( empty( $user_id ) )
403
  }
404
 
405
  /**
406
+ * Get a user's friendship requests.
407
  *
408
+ * Note that we return a 0 if no pending requests are found. This is necessary
409
+ * because of the structure of the $include parameter in bp_has_members().
410
  *
411
+ * @param int $user_id ID of the user whose requests are being retrieved.
412
+ * Defaults to displayed user.
413
+ * @return array|int An array of user IDs if found, or a 0 if none are found.
414
  */
415
  function bp_get_friendship_requests( $user_id = 0 ) {
416
  if ( !$user_id ) {
432
  return apply_filters( 'bp_get_friendship_requests', $requests );
433
  }
434
 
435
+ /**
436
+ * Output the ID of the friendship between the logged-in user and the current user in the loop.
437
+ */
438
  function bp_friend_friendship_id() {
439
  echo bp_get_friend_friendship_id();
440
  }
441
+ /**
442
+ * Return the ID of the frinedship between the logged-in user and the current user in the loop.
443
+ *
444
+ * @return int ID of the friendship.
445
+ */
446
  function bp_get_friend_friendship_id() {
447
  global $members_template;
448
 
454
  return apply_filters( 'bp_get_friend_friendship_id', $friendship_id );
455
  }
456
 
457
+ /**
458
+ * Output the URL for accepting the current friendship request in the loop.
459
+ */
460
  function bp_friend_accept_request_link() {
461
  echo bp_get_friend_accept_request_link();
462
  }
463
+ /**
464
+ * Return the URL for accepting the current friendship request in the loop.
465
+ *
466
+ * @return string accept-friendship URL.
467
+ */
468
  function bp_get_friend_accept_request_link() {
469
  global $members_template;
470
 
476
  return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) );
477
  }
478
 
479
+ /**
480
+ * Output the URL for rejecting the current friendship request in the loop.
481
+ */
482
  function bp_friend_reject_request_link() {
483
  echo bp_get_friend_reject_request_link();
484
  }
485
+ /**
486
+ * Return the URL for rejecting the current friendship request in the loop.
487
+ *
488
+ * @return string reject-friendship URL.
489
+ */
490
  function bp_get_friend_reject_request_link() {
491
  global $members_template;
492
 
498
  return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) );
499
  }
500
 
501
+ /**
502
+ * Output the total friend count for a given user.
503
+ *
504
+ * @param int $user_id See {@link friends_get_total_friend_count()}.
505
+ */
506
  function bp_total_friend_count( $user_id = 0 ) {
507
  echo bp_get_total_friend_count( $user_id );
508
  }
509
+ /**
510
+ * Return the total friend count for a given user.
511
+ *
512
+ * @param int $user_id See {@link friends_get_total_friend_count()}.
513
+ * @return int Total friend count.
514
+ */
515
  function bp_get_total_friend_count( $user_id = 0 ) {
516
  return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) );
517
  }
518
  add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' );
519
 
520
+ /**
521
+ * Output the total friendship request count for a given user.
522
+ *
523
+ * @see bp_friend_get_total_requests_count() for description of arguments.
524
+ *
525
+ * @param int $user_id See {@link bp_friend_get_total_requests_count().
526
+ */
527
  function bp_friend_total_requests_count( $user_id = 0 ) {
528
  echo bp_friend_get_total_requests_count( $user_id );
529
  }
530
+ /**
531
+ * Return the total friendship request count for a given user.
532
+ *
533
+ * @param int $user_id ID of the user whose requests are being counted.
534
+ * Default: ID of the logged-in user.
535
+ * @return int Friend count.
536
+ */
537
  function bp_friend_get_total_requests_count( $user_id = 0 ) {
538
  if ( empty( $user_id ) )
539
  $user_id = bp_loggedin_user_id();
bp-friends/bp-friends-widgets.php ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BuddyPress Widgets
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage Friends
7
+ * @since 1.9.0
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ /**
14
+ * Register the friends widget.
15
+ *
16
+ * @since BuddyPress (1.9.0)
17
+ */
18
+ function bp_friends_register_widgets() {
19
+ if ( ! bp_is_active( 'friends' ) ) {
20
+ return;
21
+ }
22
+
23
+ add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Core_Friends_Widget");' ) );
24
+ }
25
+ add_action( 'bp_register_widgets', 'bp_friends_register_widgets' );
26
+
27
+ /*** MEMBER FRIENDS WIDGET *****************/
28
+
29
+ /**
30
+ * The User Friends widget class.
31
+ *
32
+ * @since BuddyPress (1.9.0)
33
+ */
34
+ class BP_Core_Friends_Widget extends WP_Widget {
35
+
36
+ /**
37
+ * Class constructor.
38
+ */
39
+ function __construct() {
40
+ $widget_ops = array(
41
+ 'description' => __( 'A dynamic list of recently active, popular, and newest Friends of the displayed member. Widget is only shown when viewing a member profile.', 'buddypress' ),
42
+ 'classname' => 'widget_bp_core_friends_widget buddypress widget',
43
+ );
44
+ parent::__construct( false, $name = _x( '(BuddyPress) Friends', 'widget name', 'buddypress' ), $widget_ops );
45
+
46
+ }
47
+
48
+ /**
49
+ * Display the widget.
50
+ *
51
+ * @param array $args Widget arguments.
52
+ * @param array $instance The widget settings, as saved by the user.
53
+ */
54
+ function widget( $args, $instance ) {
55
+ extract( $args );
56
+
57
+ if ( ! bp_displayed_user_id() ) {
58
+ return;
59
+ }
60
+
61
+ $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
62
+ wp_enqueue_script( 'bp_core_widget_friends-js', BP_PLUGIN_URL . "bp-friends/js/widget-friends{$min}.js", array( 'jquery' ), bp_get_version() );
63
+
64
+ $user_id = bp_displayed_user_id();
65
+ $link = trailingslashit( bp_displayed_user_domain() . bp_get_friends_slug() );
66
+ $instance['title'] = sprintf( __( '%s&#8217;s Friends', 'buddypress' ), bp_get_displayed_user_fullname() );
67
+
68
+ if ( empty( $instance['friend_default'] ) ) {
69
+ $instance['friend_default'] = 'active';
70
+ }
71
+
72
+ $title = apply_filters( 'widget_title', $instance['title'] );
73
+
74
+ echo $before_widget;
75
+
76
+ $title = $instance['link_title'] ? '<a href="' . esc_url( $link ) . '">' . esc_html( $title ) . '</a>' : esc_html( $title );
77
+
78
+ echo $before_title . $title . $after_title;
79
+
80
+ $members_args = array(
81
+ 'user_id' => absint( $user_id ),
82
+ 'type' => sanitize_text_field( $instance['friend_default'] ),
83
+ 'max' => absint( $instance['max_friends'] ),
84
+ 'populate_extras' => 1,
85
+ );
86
+
87
+ ?>
88
+
89
+ <?php if ( bp_has_members( $members_args ) ) : ?>
90
+ <div class="item-options" id="friends-list-options">
91
+ <a href="<?php bp_members_directory_permalink(); ?>" id="newest-friends" <?php if ( $instance['friend_default'] == 'newest' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ) ?></a>
92
+ | <a href="<?php bp_members_directory_permalink(); ?>" id="recently-active-friends" <?php if ( $instance['friend_default'] == 'active' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ) ?></a>
93
+ | <a href="<?php bp_members_directory_permalink(); ?>" id="popular-friends" <?php if ( $instance['friend_default'] == 'popular' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ) ?></a>
94
+ </div>
95
+
96
+ <ul id="friends-list" class="item-list">
97
+ <?php while ( bp_members() ) : bp_the_member(); ?>
98
+ <li class="vcard">
99
+ <div class="item-avatar">
100
+ <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
101
+ </div>
102
+
103
+ <div class="item">
104
+ <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
105
+ <div class="item-meta">
106
+ <span class="activity">
107
+ <?php
108
+ if ( 'newest' == $instance['friend_default'] )
109
+ bp_member_registered();
110
+ if ( 'active' == $instance['friend_default'] )
111
+ bp_member_last_active();
112
+ if ( 'popular' == $instance['friend_default'] )
113
+ bp_member_total_friend_count();
114
+ ?>
115
+ </span>
116
+ </div>
117
+ </div>
118
+ </li>
119
+
120
+ <?php endwhile; ?>
121
+ </ul>
122
+ <?php wp_nonce_field( 'bp_core_widget_friends', '_wpnonce-friends' ); ?>
123
+ <input type="hidden" name="friends_widget_max" id="friends_widget_max" value="<?php echo absint( $instance['max_friends'] ); ?>" />
124
+
125
+ <?php else: ?>
126
+
127
+ <div class="widget-error">
128
+ <?php _e( 'Sorry, no members were found.', 'buddypress' ); ?>
129
+ </div>
130
+
131
+ <?php endif; ?>
132
+
133
+ <?php echo $after_widget; ?>
134
+ <?php
135
+ }
136
+
137
+ /**
138
+ * Process a widget save.
139
+ *
140
+ * @param array $new_instance The parameters saved by the user.
141
+ * @param array $old_instance The paramaters as previously saved to the database.
142
+ * @return array $instance The processed settings to save.
143
+ */
144
+ function update( $new_instance, $old_instance ) {
145
+ $instance = $old_instance;
146
+
147
+ $instance['max_friends'] = absint( $new_instance['max_friends'] );
148
+ $instance['friend_default'] = sanitize_text_field( $new_instance['friend_default'] );
149
+ $instance['link_title'] = (bool) $new_instance['link_title'];
150
+
151
+ return $instance;
152
+ }
153
+
154
+ /**
155
+ * Render the widget edit form.
156
+ *
157
+ * @param array $instance The saved widget settings.
158
+ */
159
+ function form( $instance ) {
160
+ $defaults = array(
161
+ 'max_friends' => 5,
162
+ 'friend_default' => 'active',
163
+ 'link_title' => false
164
+ );
165
+ $instance = wp_parse_args( (array) $instance, $defaults );
166
+
167
+ $max_friends = $instance['max_friends'];
168
+ $friend_default = $instance['friend_default'];
169
+ $link_title = (bool) $instance['link_title'];
170
+ ?>
171
+
172
+ <p><label for="<?php echo $this->get_field_name( 'link_title' ) ?>"><input type="checkbox" name="<?php echo $this->get_field_name('link_title') ?>" value="1" <?php checked( $link_title ) ?> /> <?php _e( 'Link widget title to Members directory', 'buddypress' ) ?></label></p>
173
+
174
+ <p><label for="bp-core-widget-friends-max"><?php _e( 'Max friends to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_friends' ); ?>" name="<?php echo $this->get_field_name( 'max_friends' ); ?>" type="text" value="<?php echo absint( $max_friends ); ?>" style="width: 30%" /></label></p>
175
+
176
+ <p>
177
+ <label for="bp-core-widget-friends-default"><?php _e( 'Default friends to show:', 'buddypress' ); ?>
178
+ <select name="<?php echo $this->get_field_name( 'friend_default' ) ?>">
179
+ <option value="newest" <?php selected( $friend_default, 'newest' ); ?>><?php _e( 'Newest', 'buddypress' ) ?></option>
180
+ <option value="active" <?php selected( $friend_default, 'active' );?>><?php _e( 'Active', 'buddypress' ) ?></option>
181
+ <option value="popular" <?php selected( $friend_default, 'popular' ); ?>><?php _e( 'Popular', 'buddypress' ) ?></option>
182
+ </select>
183
+ </label>
184
+ </p>
185
+
186
+ <?php
187
+ }
188
+ }
189
+
190
+ /** Widget AJAX ******************/
191
+
192
+ /**
193
+ * Process AJAX pagination or filtering for the Friends widget.
194
+ *
195
+ * @since BuddyPress (1.9.0)
196
+ */
197
+ function bp_core_ajax_widget_friends() {
198
+
199
+ check_ajax_referer( 'bp_core_widget_friends' );
200
+
201
+ switch ( $_POST['filter'] ) {
202
+ case 'newest-friends':
203
+ $type = 'newest';
204
+ break;
205
+
206
+ case 'recently-active-friends':
207
+ $type = 'active';
208
+ break;
209
+
210
+ case 'popular-friends':
211
+ $type = 'popular';
212
+ break;
213
+ }
214
+
215
+ $members_args = array(
216
+ 'user_id' => bp_displayed_user_id(),
217
+ 'type' => $type,
218
+ 'max' => absint( $_POST['max-friends'] ),
219
+ 'populate_extras' => 1,
220
+ );
221
+
222
+ if ( bp_has_members( $members_args ) ) : ?>
223
+ <?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. ?>
224
+ <?php while ( bp_members() ) : bp_the_member(); ?>
225
+ <li class="vcard">
226
+ <div class="item-avatar">
227
+ <a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
228
+ </div>
229
+
230
+ <div class="item">
231
+ <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
232
+ <?php if ( 'active' == $type ) : ?>
233
+ <div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div>
234
+ <?php elseif ( 'newest' == $type ) : ?>
235
+ <div class="item-meta"><span class="activity"><?php bp_member_registered() ?></span></div>
236
+ <?php elseif ( bp_is_active( 'friends' ) ) : ?>
237
+ <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div>
238
+ <?php endif; ?>
239
+ </div>
240
+ </li>
241
+ <?php endwhile; ?>
242
+
243
+ <?php else: ?>
244
+ <?php echo "-1[[SPLIT]]<li>"; ?>
245
+ <?php _e( 'There were no members found, please try another filter.', 'buddypress' ) ?>
246
+ <?php echo "</li>"; ?>
247
+ <?php endif;
248
+ }
249
+ add_action( 'wp_ajax_widget_friends', 'bp_core_ajax_widget_friends' );
250
+ add_action( 'wp_ajax_nopriv_widget_friends', 'bp_core_ajax_widget_friends' );
251
+
bp-friends/js/widget-friends.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function() {
2
+ jQuery(".widget div#friends-list-options a").on('click',
3
+ function() {
4
+ var link = this;
5
+ jQuery(link).addClass('loading');
6
+
7
+ jQuery(".widget div#friends-list-options a").removeClass("selected");
8
+ jQuery(this).addClass('selected');
9
+
10
+ jQuery.post( ajaxurl, {
11
+ action: 'widget_friends',
12
+ 'cookie': encodeURIComponent(document.cookie),
13
+ '_wpnonce': jQuery("input#_wpnonce-friends").val(),
14
+ 'max-friends': jQuery("input#friends_widget_max").val(),
15
+ 'filter': jQuery(this).attr('id')
16
+ },
17
+ function(response)
18
+ {
19
+ jQuery(link).removeClass('loading');
20
+ friend_wiget_response(response);
21
+ });
22
+
23
+ return false;
24
+ }
25
+ );
26
+ });
27
+
28
+ function friend_wiget_response(response) {
29
+ response = response.substr(0, response.length-1);
30
+ response = response.split('[[SPLIT]]');
31
+
32
+ if ( response[0] != "-1" ) {
33
+ jQuery(".widget ul#friends-list").fadeOut(200,
34
+ function() {
35
+ jQuery(".widget ul#friends-list").html(response[1]);
36
+ jQuery(".widget ul#friends-list").fadeIn(200);
37
+ }
38
+ );
39
+
40
+ } else {
41
+ jQuery(".widget ul#friends-list").fadeOut(200,
42
+ function() {
43
+ var message = '<p>' + response[1] + '</p>';
44
+ jQuery(".widget ul#friends-list").html(message);
45
+ jQuery(".widget ul#friends-list").fadeIn(200);
46
+ }
47
+ );
48
+ }
49
+ }
bp-friends/js/widget-friends.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(){jQuery(".widget div#friends-list-options a").on("click",function(){var a=this;jQuery(a).addClass("loading");jQuery(".widget div#friends-list-options a").removeClass("selected");jQuery(this).addClass("selected");jQuery.post(ajaxurl,{action:"widget_friends",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-friends").val(),"max-friends":jQuery("input#friends_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading");friend_wiget_response(b)});return false})});function friend_wiget_response(a){a=a.substr(0,a.length-1);a=a.split("[[SPLIT]]");if(a[0]!="-1"){jQuery(".widget ul#friends-list").fadeOut(200,function(){jQuery(".widget ul#friends-list").html(a[1]);jQuery(".widget ul#friends-list").fadeIn(200)})}else{jQuery(".widget ul#friends-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#friends-list").html(b);jQuery(".widget ul#friends-list").fadeIn(200)})}};
bp-groups/bp-groups-actions.php CHANGED
@@ -3,9 +3,9 @@
3
  /**
4
  * BuddyPress Groups Actions
5
  *
6
- * Action functions are exactly the same as screen functions, however they do not
7
- * have a template screen associated with them. Usually they will send the user
8
- * back to the default screen after execution.
9
  *
10
  * @package BuddyPress
11
  * @subpackage GroupsActions
@@ -14,6 +14,9 @@
14
  // Exit if accessed directly
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
 
 
 
17
  function groups_action_create_group() {
18
  global $bp;
19
 
@@ -42,7 +45,8 @@ function groups_action_create_group() {
42
  setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
43
 
44
  $reset_steps = true;
45
- bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
 
46
  }
47
 
48
  // If this is a creation step that is not recognized, just redirect them back to the first screen
@@ -133,7 +137,8 @@ function groups_action_create_group() {
133
 
134
  // If we have completed all steps and hit done on the final step we
135
  // can redirect to the completed group
136
- if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && bp_get_groups_current_create_step() == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
 
137
  unset( $bp->groups->current_create_step );
138
  unset( $bp->groups->completed_create_steps );
139
 
@@ -152,7 +157,7 @@ function groups_action_create_group() {
152
  * Since we don't know what the next step is going to be (any plugin can insert steps)
153
  * we need to loop the step array and fetch the next step that way.
154
  */
155
- foreach ( (array) $bp->groups->group_creation_steps as $key => $value ) {
156
  if ( $key == bp_get_groups_current_create_step() ) {
157
  $next = 1;
158
  continue;
@@ -235,38 +240,58 @@ function groups_action_join_group() {
235
  }
236
  add_action( 'bp_actions', 'groups_action_join_group' );
237
 
238
-
 
 
 
 
 
 
 
 
 
 
239
  function groups_action_leave_group() {
240
- global $bp;
241
-
242
- if ( !bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action( 'leave-group' ) )
243
  return false;
 
244
 
245
  // Nonce check
246
- if ( !check_admin_referer( 'groups_leave_group' ) )
247
  return false;
 
248
 
249
  // User wants to leave any group
250
- if ( groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
 
251
 
252
  // Stop sole admins from abandoning their group
253
- $group_admins = groups_get_group_admins( $bp->groups->current_group->id );
254
- if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == bp_loggedin_user_id() )
255
- bp_core_add_message( __( 'This group must have at least one admin', 'buddypress' ), 'error' );
256
 
257
- elseif ( !groups_leave_group( $bp->groups->current_group->id ) )
 
 
258
  bp_core_add_message( __( 'There was an error leaving the group.', 'buddypress' ), 'error' );
259
- else
260
  bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
 
 
 
 
 
 
 
261
 
262
- bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
263
  }
264
 
265
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
266
  }
267
  add_action( 'bp_actions', 'groups_action_leave_group' );
268
 
269
-
 
 
270
  function groups_action_sort_creation_steps() {
271
  global $bp;
272
 
@@ -292,7 +317,7 @@ function groups_action_sort_creation_steps() {
292
  }
293
 
294
  /**
295
- * Catches requests for a random group page (example.com/groups/?random-group) and redirects
296
  */
297
  function groups_action_redirect_to_random_group() {
298
 
@@ -305,9 +330,9 @@ function groups_action_redirect_to_random_group() {
305
  add_action( 'bp_actions', 'groups_action_redirect_to_random_group' );
306
 
307
  /**
308
- * Load the activity feed for the specific group.
309
  *
310
- * @since BuddyPress (v1.2)
311
  */
312
  function groups_action_group_feed() {
313
 
3
  /**
4
  * BuddyPress Groups Actions
5
  *
6
+ * Action functions are exactly the same as screen functions, however they do
7
+ * not have a template screen associated with them. Usually they will send the
8
+ * user back to the default screen after execution.
9
  *
10
  * @package BuddyPress
11
  * @subpackage GroupsActions
14
  // Exit if accessed directly
15
  if ( !defined( 'ABSPATH' ) ) exit;
16
 
17
+ /**
18
+ * Catch and process group creation form submissions.
19
+ */
20
  function groups_action_create_group() {
21
  global $bp;
22
 
45
  setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
46
 
47
  $reset_steps = true;
48
+ $keys = array_keys( $bp->groups->group_creation_steps );
49
+ bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . array_shift( $keys ) . '/' );
50
  }
51
 
52
  // If this is a creation step that is not recognized, just redirect them back to the first screen
137
 
138
  // If we have completed all steps and hit done on the final step we
139
  // can redirect to the completed group
140
+ $keys = array_keys( $bp->groups->group_creation_steps );
141
+ if ( count( $bp->groups->completed_create_steps ) == count( $keys ) && bp_get_groups_current_create_step() == array_pop( $keys ) ) {
142
  unset( $bp->groups->current_create_step );
143
  unset( $bp->groups->completed_create_steps );
144
 
157
  * Since we don't know what the next step is going to be (any plugin can insert steps)
158
  * we need to loop the step array and fetch the next step that way.
159
  */
160
+ foreach ( $keys as $key ) {
161
  if ( $key == bp_get_groups_current_create_step() ) {
162
  $next = 1;
163
  continue;
240
  }
241
  add_action( 'bp_actions', 'groups_action_join_group' );
242
 
243
+ /**
244
+ * Catch and process "Leave Group" button clicks.
245
+ *
246
+ * When a group member clicks on the "Leave Group" button from a group's page,
247
+ * this function is run.
248
+ *
249
+ * Note: When leaving a group from the group directory, AJAX is used and
250
+ * another function handles this. See {@link bp_legacy_theme_ajax_joinleave_group()}.
251
+ *
252
+ * @since BuddyPress (1.2.4)
253
+ */
254
  function groups_action_leave_group() {
255
+ if ( ! bp_is_single_item() || ! bp_is_groups_component() || ! bp_is_current_action( 'leave-group' ) ) {
 
 
256
  return false;
257
+ }
258
 
259
  // Nonce check
260
+ if ( ! check_admin_referer( 'groups_leave_group' ) ) {
261
  return false;
262
+ }
263
 
264
  // User wants to leave any group
265
+ if ( groups_is_user_member( bp_loggedin_user_id(), bp_get_current_group_id() ) ) {
266
+ $bp = buddypress();
267
 
268
  // Stop sole admins from abandoning their group
269
+ $group_admins = groups_get_group_admins( bp_get_current_group_id() );
 
 
270
 
271
+ if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == bp_loggedin_user_id() ) {
272
+ bp_core_add_message( __( 'This group must have at least one admin', 'buddypress' ), 'error' );
273
+ } elseif ( ! groups_leave_group( $bp->groups->current_group->id ) ) {
274
  bp_core_add_message( __( 'There was an error leaving the group.', 'buddypress' ), 'error' );
275
+ } else {
276
  bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
277
+ }
278
+
279
+ $redirect = bp_get_group_permalink( groups_get_current_group() );
280
+
281
+ if( 'hidden' == $bp->groups->current_group->status ) {
282
+ $redirect = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() );
283
+ }
284
 
285
+ bp_core_redirect( $redirect );
286
  }
287
 
288
  bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
289
  }
290
  add_action( 'bp_actions', 'groups_action_leave_group' );
291
 
292
+ /**
293
+ * Sort the group creation steps.
294
+ */
295
  function groups_action_sort_creation_steps() {
296
  global $bp;
297
 
317
  }
318
 
319
  /**
320
+ * Catch requests for a random group page (example.com/groups/?random-group) and redirect.
321
  */
322
  function groups_action_redirect_to_random_group() {
323
 
330
  add_action( 'bp_actions', 'groups_action_redirect_to_random_group' );
331
 
332
  /**
333
+ * Load the activity feed for the current group.
334
  *
335
+ * @since BuddyPress (1.2.0)
336
  */
337
  function groups_action_group_feed() {
338
 
bp-groups/bp-groups-activity.php CHANGED
@@ -13,6 +13,9 @@
13
  // Exit if accessed directly
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
 
 
 
16
  function groups_register_activity_actions() {
17
  global $bp;
18
 
@@ -35,6 +38,26 @@ function groups_register_activity_actions() {
35
  }
36
  add_action( 'bp_register_activity_actions', 'groups_register_activity_actions' );
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  function groups_record_activity( $args = '' ) {
39
  global $bp;
40
 
@@ -75,6 +98,12 @@ function groups_record_activity( $args = '' ) {
75
  return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
76
  }
77
 
 
 
 
 
 
 
78
  function groups_update_last_activity( $group_id = 0 ) {
79
  global $bp;
80
 
13
  // Exit if accessed directly
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
+ /**
17
+ * Register activity actions for the Groups component.
18
+ */
19
  function groups_register_activity_actions() {
20
  global $bp;
21
 
38
  }
39
  add_action( 'bp_register_activity_actions', 'groups_register_activity_actions' );
40
 
41
+ /**
42
+ * Record an activity item related to the Groups component.
43
+ *
44
+ * A wrapper for {@link bp_activity_add()} that provides some Groups-specific
45
+ * defaults.
46
+ *
47
+ * @see bp_activity_add() for more detailed description of parameters and
48
+ * return values.
49
+ *
50
+ * @param array $args {
51
+ * An array of arguments for the new activity item. Accepts all parameters
52
+ * of {@link bp_activity_add()}. However, this wrapper provides some
53
+ * additional defaults, as described below:
54
+ * @type string $component Default: the id of your Groups component
55
+ * (usually 'groups').
56
+ * @type bool $hide_sitewide Default: True if the current group is not
57
+ * public, otherwise false.
58
+ * }
59
+ * @return bool See {@link bp_activity_add()}.
60
+ */
61
  function groups_record_activity( $args = '' ) {
62
  global $bp;
63
 
98
  return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
99
  }
100
 
101
+ /**
102
+ * Update the last_activity meta value for a given group.
103
+ *
104
+ * @param int $group_id Optional. The ID of the group whose last_activity is
105
+ * being updated. Default: the current group's ID.
106
+ */
107
  function groups_update_last_activity( $group_id = 0 ) {
108
  global $bp;
109
 
bp-groups/bp-groups-admin.php CHANGED
@@ -2,11 +2,11 @@
2
  /**
3
  * BuddyPress Groups component admin screen
4
  *
5
- * Props to WordPress core for the Comments admin screen, and its contextual help text,
6
- * on which this implementation is heavily based.
7
  *
8
  * @package BuddyPress
9
- * @since BuddyPress (1.7)
10
  * @subpackage Groups
11
  */
12
 
@@ -21,20 +21,17 @@ if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-groups' == $_REQUEST['pag
21
  add_filter( 'set-screen-option', 'bp_groups_admin_screen_options', 10, 3 );
22
 
23
  /**
24
- * Registers the Groups component admin screen
25
  *
26
- * @since BuddyPress (1.7)
27
  */
28
  function bp_groups_add_admin_menu() {
29
 
30
- if ( ! bp_current_user_can( 'bp_moderate' ) )
31
- return;
32
-
33
  // Add our screen
34
  $hook = add_menu_page(
35
  __( 'Groups', 'buddypress' ),
36
  __( 'Groups', 'buddypress' ),
37
- 'manage_options',
38
  'bp-groups',
39
  'bp_groups_admin',
40
  'div'
@@ -46,12 +43,15 @@ function bp_groups_add_admin_menu() {
46
  add_action( bp_core_admin_hook(), 'bp_groups_add_admin_menu' );
47
 
48
  /**
49
- * Add groups component to custom menus array
 
 
 
50
  *
51
- * @since BuddyPress (1.7)
52
  *
53
- * @param array $custom_menus
54
- * @return array
55
  */
56
  function bp_groups_admin_menu_order( $custom_menus = array() ) {
57
  array_push( $custom_menus, 'bp-groups' );
@@ -60,11 +60,16 @@ function bp_groups_admin_menu_order( $custom_menus = array() ) {
60
  add_filter( 'bp_admin_menu_order', 'bp_groups_admin_menu_order' );
61
 
62
  /**
63
- * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page.
 
 
 
 
 
 
64
  *
65
  * @global object $bp BuddyPress global settings
66
  * @global BP_Groups_List_Table $bp_groups_list_table Groups screen list table
67
- * @since BuddyPress (1.7)
68
  */
69
  function bp_groups_admin_load() {
70
  global $bp_groups_list_table;
@@ -236,12 +241,16 @@ function bp_groups_admin_load() {
236
 
237
  // Make sure the user exists before attempting
238
  // to add to the group
239
- if ( ! $user_id = username_exists( $un ) ) {
240
- $error_new[] = $un;
241
- } else if ( ! groups_join_group( $group_id, $user_id ) ) {
242
- $error_new[] = $un;
243
  } else {
244
- $success_new[] = $un;
 
 
 
 
245
  }
246
  }
247
  }
@@ -374,13 +383,13 @@ function bp_groups_admin_load() {
374
  }
375
 
376
  /**
377
- * Handle save/update of screen options for the Groups component admin screen
378
  *
379
- * @since BuddyPress (1.7)
380
  *
381
  * @param string $value Will always be false unless another plugin filters it first.
382
- * @param string $option Screen option name
383
- * @param string $new_value Screen option form value
384
  * @return string Option value. False to abandon update.
385
  */
386
  function bp_groups_admin_screen_options( $value, $option, $new_value ) {
@@ -396,13 +405,13 @@ function bp_groups_admin_screen_options( $value, $option, $new_value ) {
396
  }
397
 
398
  /**
399
- * Outputs the Groups component admin screens
400
  *
401
- * @since BuddyPress (1.7)
402
  */
403
  function bp_groups_admin() {
404
  // Decide whether to load the index or edit screen
405
- $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
406
 
407
  // Display the single group edit screen
408
  if ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) {
@@ -419,13 +428,13 @@ function bp_groups_admin() {
419
  }
420
 
421
  /**
422
- * Display the single groups edit screen
423
  *
424
- * @since BuddyPress (1.7)
425
  */
426
  function bp_groups_admin_edit() {
427
 
428
- if ( ! is_super_admin() )
429
  die( '-1' );
430
 
431
  $messages = array();
@@ -542,12 +551,12 @@ function bp_groups_admin_edit() {
542
  }
543
 
544
  /**
545
- * Display the Group delete confirmation screen
546
  *
547
  * We include a separate confirmation because group deletion is truly
548
  * irreversible.
549
  *
550
- * @since (BuddyPress) 1.7
551
  */
552
  function bp_groups_admin_delete() {
553
 
@@ -559,7 +568,11 @@ function bp_groups_admin_delete() {
559
  $group_ids = explode( ',', $group_ids );
560
  }
561
  $group_ids = wp_parse_id_list( $group_ids );
562
- $groups = groups_get_groups( array( 'include' => $group_ids, 'show_hidden' => true, ) );
 
 
 
 
563
 
564
  // Create a new list of group ids, based on those that actually exist
565
  $gids = array();
@@ -590,12 +603,14 @@ function bp_groups_admin_delete() {
590
  }
591
 
592
  /**
593
- * Display the Groups admin index screen, which contains a list of all your
594
- * BuddyPress groups.
 
595
  *
596
- * @global BP_Group_List_Table $bp_groups_list_table Group screen list table
597
- * @global string $plugin_page
598
- * @since BuddyPress (1.7)
 
599
  */
600
  function bp_groups_admin_index() {
601
  global $bp_groups_list_table, $plugin_page;
@@ -651,10 +666,11 @@ function bp_groups_admin_index() {
651
  }
652
 
653
  /**
654
- * Settings metabox
 
 
655
  *
656
- * @param object $item Group item
657
- * @since BuddyPress (1.7)
658
  */
659
  function bp_groups_admin_edit_metabox_settings( $item ) {
660
 
@@ -689,9 +705,9 @@ function bp_groups_admin_edit_metabox_settings( $item ) {
689
  }
690
 
691
  /**
692
- * Add New Members metabox
693
  *
694
- * @since BuddyPress (1.7)
695
  */
696
  function bp_groups_admin_edit_metabox_add_new_members( $item ) {
697
  ?>
@@ -702,11 +718,12 @@ function bp_groups_admin_edit_metabox_add_new_members( $item ) {
702
  }
703
 
704
  /**
705
- * Members metabox
706
  *
707
- * @param BP_Groups_Group $item The BP_Groups_Group object
708
  *
709
- * @since BuddyPress (1.7)
 
710
  */
711
  function bp_groups_admin_edit_metabox_members( $item ) {
712
  global $members_template;
@@ -842,10 +859,11 @@ function bp_groups_admin_edit_metabox_members( $item ) {
842
  }
843
 
844
  /**
845
- * Status metabox for the Groups admin edit screen
 
 
846
  *
847
- * @param object $item Group item
848
- * @since BuddyPress (1.7)
849
  */
850
  function bp_groups_admin_edit_metabox_status( $item ) {
851
  $base_url = add_query_arg( array(
@@ -870,7 +888,7 @@ function bp_groups_admin_edit_metabox_status( $item ) {
870
  }
871
 
872
  /**
873
- * Create pagination links out of a BP_Group_Member_Query
874
  *
875
  * This function is intended to create pagination links for use under the
876
  * Manage Members section of the Groups Admin Dashboard pages. It is a stopgap
@@ -878,9 +896,11 @@ function bp_groups_admin_edit_metabox_status( $item ) {
878
  * Plugin authors should not use this function, as it is likely to be
879
  * deprecated soon.
880
  *
881
- * @since BuddyPress (1.8)
882
- * @param object $query A BP_Group_Member_Query object
883
- * @param string $member_type member|mod|admin|banned
 
 
884
  */
885
  function bp_groups_admin_create_pagination_links( BP_Group_Member_Query $query, $member_type ) {
886
  $pagination = '';
@@ -927,9 +947,12 @@ function bp_groups_admin_create_pagination_links( BP_Group_Member_Query $query,
927
  }
928
 
929
  /**
930
- * Match a set of user ids up to a set of usernames
 
 
931
  *
932
- * @since BuddyPress (1.7)
 
933
  */
934
  function bp_groups_admin_get_usernames_from_ids( $user_ids = array() ) {
935
 
@@ -944,9 +967,9 @@ function bp_groups_admin_get_usernames_from_ids( $user_ids = array() ) {
944
  }
945
 
946
  /**
947
- * AJAX handler for group member autocomplete requests
948
  *
949
- * @since BuddyPress (1.7)
950
  */
951
  function bp_groups_admin_autocomplete_handler() {
952
 
@@ -980,8 +1003,8 @@ function bp_groups_admin_autocomplete_handler() {
980
  foreach ( (array) $users as $user ) {
981
  $return[] = array(
982
  /* translators: 1: user_login, 2: user_email */
983
- 'label' => sprintf( __( '%1$s (%2$s)' ), $user->user_login, $user->user_email ),
984
- 'value' => $user->user_login,
985
  );
986
  }
987
 
@@ -992,28 +1015,36 @@ add_action( 'wp_ajax_bp_group_admin_member_autocomplete', 'bp_groups_admin_autoc
992
  /**
993
  * List table class for the Groups component admin page.
994
  *
995
- * @since BuddyPress (1.7)
996
  */
997
  class BP_Groups_List_Table extends WP_List_Table {
998
 
999
  /**
1000
- * What type of view is being displayed? e.g. "All", "Pending", "Approved", "Spam"...
1001
  *
1002
- * @since BuddyPress (1.7)
1003
- */
 
 
 
 
 
1004
  public $view = 'all';
1005
 
1006
  /**
1007
- * Group counts for each group type
 
 
1008
  *
1009
- * @since BuddyPress (1.7)
 
1010
  */
1011
  public $group_counts = 0;
1012
 
1013
  /**
1014
  * Constructor
1015
  *
1016
- * @since BuddyPress (1.7)
1017
  */
1018
  public function __construct() {
1019
 
@@ -1026,9 +1057,12 @@ class BP_Groups_List_Table extends WP_List_Table {
1026
  }
1027
 
1028
  /**
1029
- * Handle filtering of data, sorting, pagination, and any other data-manipulation required prior to rendering.
1030
  *
1031
- * @since BuddyPress (1.7)
 
 
 
1032
  */
1033
  function prepare_items() {
1034
  global $groups_template;
@@ -1131,10 +1165,11 @@ class BP_Groups_List_Table extends WP_List_Table {
1131
  }
1132
 
1133
  /**
1134
- * Get an array of all the columns on the page
 
 
1135
  *
1136
- * @return array
1137
- * @since BuddyPress (1.7)
1138
  */
1139
  function get_column_info() {
1140
  $this->_column_headers = array(
@@ -1147,18 +1182,18 @@ class BP_Groups_List_Table extends WP_List_Table {
1147
  }
1148
 
1149
  /**
1150
- * Displays a message on screen when no items are found (e.g. no search matches)
1151
  *
1152
- * @since BuddyPress (1.7)
1153
  */
1154
  function no_items() {
1155
  _e( 'No groups found.', 'buddypress' );
1156
  }
1157
 
1158
  /**
1159
- * Outputs the Groups data table
1160
  *
1161
- * @since BuddyPress (1.7)
1162
  */
1163
  function display() {
1164
  extract( $this->_args );
@@ -1188,29 +1223,37 @@ class BP_Groups_List_Table extends WP_List_Table {
1188
  }
1189
 
1190
  /**
1191
- * Generates content for a single row of the table
 
 
1192
  *
1193
- * @param object $item The current item
1194
- * @since BuddyPress (1.7)
1195
  */
1196
  function single_row( $item = array() ) {
1197
- static $row_class = '';
1198
 
1199
- if ( empty( $row_class ) ) {
1200
- $row_class = ' class="alternate odd"';
 
 
1201
  } else {
1202
- $row_class = ' class="even"';
1203
  }
1204
 
 
 
 
1205
  echo '<tr' . $row_class . ' id="group-' . esc_attr( $item['id'] ) . '" data-parent_id="' . esc_attr( $item['id'] ) . '" data-root_id="' . esc_attr( $item['id'] ) . '">';
1206
  echo $this->single_row_columns( $item );
1207
  echo '</tr>';
 
 
1208
  }
1209
 
1210
  /**
1211
  * Get the list of views available on this table (e.g. "all", "public").
1212
  *
1213
- * @since BuddyPress (1.7)
1214
  */
1215
  function get_views() {
1216
  $url_base = bp_get_admin_url( 'admin.php?page=bp-groups' ); ?>
@@ -1227,10 +1270,11 @@ class BP_Groups_List_Table extends WP_List_Table {
1227
  }
1228
 
1229
  /**
1230
- * Get bulk actions
 
 
1231
  *
1232
- * @return array Key/value pairs for the bulk actions dropdown
1233
- * @since BuddyPress (1.7)
1234
  */
1235
  function get_bulk_actions() {
1236
  return apply_filters( 'bp_groups_list_table_get_bulk_actions', array(
@@ -1241,9 +1285,11 @@ class BP_Groups_List_Table extends WP_List_Table {
1241
  /**
1242
  * Get the table column titles.
1243
  *
 
 
1244
  * @see WP_List_Table::single_row_columns()
1245
- * @return array
1246
- * @since BuddyPress (1.7)
1247
  */
1248
  function get_columns() {
1249
  return array(
@@ -1268,8 +1314,9 @@ class BP_Groups_List_Table extends WP_List_Table {
1268
  * the sort order - ie, to make it ASC. Thus last_active is set to
1269
  * $desc_first = false.
1270
  *
1271
- * @return array
1272
- * @since BuddyPress (1.7)
 
1273
  */
1274
  function get_sortable_columns() {
1275
  return array(
@@ -1281,22 +1328,26 @@ class BP_Groups_List_Table extends WP_List_Table {
1281
  }
1282
 
1283
  /**
1284
- * Checkbox column
 
 
1285
  *
1286
- * @param array $item A singular item (one full row)
1287
  * @see WP_List_Table::single_row_columns()
1288
- * @since BuddyPress (1.7)
 
1289
  */
1290
  function column_cb( $item = array() ) {
1291
- printf( '<label class="screen-reader-text" for="aid-%1$d">' . __( 'Select group %1$d', 'buddypress' ) . '</label><input type="checkbox" name="aid[]" value="%1$d" id="aid-%1$d" />', $item['id'] );
1292
  }
1293
 
1294
  /**
1295
- * Group id column
 
 
1296
  *
1297
- * @param array $item A singular item (one full row)
1298
  * @see WP_List_Table::single_row_columns()
1299
- * @since BuddyPress (1.7)
 
1300
  */
1301
  function column_gid( $item = array() ) {
1302
  echo '<strong>' . $item['id'] . '</strong>';
@@ -1307,9 +1358,11 @@ class BP_Groups_List_Table extends WP_List_Table {
1307
  *
1308
  * Called "comment" in the CSS so we can re-use some WP core CSS.
1309
  *
1310
- * @param array $item A singular item (one full row)
 
1311
  * @see WP_List_Table::single_row_columns()
1312
- * @since BuddyPress (1.7)
 
1313
  */
1314
  function column_comment( $item = array() ) {
1315
 
@@ -1361,18 +1414,22 @@ class BP_Groups_List_Table extends WP_List_Table {
1361
  }
1362
 
1363
  /**
1364
- * Description column
 
 
1365
  *
1366
- * @since BuddyPress (1.7)
1367
  */
1368
  function column_description( $item = array() ) {
1369
  echo apply_filters_ref_array( 'bp_get_group_description', array( $item['description'], $item ) );
1370
  }
1371
 
1372
  /**
1373
- * Status column
 
 
1374
  *
1375
- * @since BuddyPress (1.7)
1376
  */
1377
  function column_status( $item = array() ) {
1378
  $status = $item['status'];
@@ -1396,9 +1453,11 @@ class BP_Groups_List_Table extends WP_List_Table {
1396
  }
1397
 
1398
  /**
1399
- * Number of Members column
1400
  *
1401
- * @since BuddyPress (1.7)
 
 
1402
  */
1403
  function column_members( $item = array() ) {
1404
  $count = groups_get_groupmeta( $item['id'], 'total_member_count' );
@@ -1406,9 +1465,11 @@ class BP_Groups_List_Table extends WP_List_Table {
1406
  }
1407
 
1408
  /**
1409
- * Last Active column
 
 
1410
  *
1411
- * @since BuddyPress (1.7)
1412
  */
1413
  function column_last_active( $item = array() ) {
1414
  $last_active = groups_get_groupmeta( $item['id'], 'last_activity' );
2
  /**
3
  * BuddyPress Groups component admin screen
4
  *
5
+ * Props to WordPress core for the Comments admin screen, and its contextual
6
+ * help text, on which this implementation is heavily based.
7
  *
8
  * @package BuddyPress
9
+ * @since BuddyPress (1.7.0)
10
  * @subpackage Groups
11
  */
12
 
21
  add_filter( 'set-screen-option', 'bp_groups_admin_screen_options', 10, 3 );
22
 
23
  /**
24
+ * Register the Groups component admin screen.
25
  *
26
+ * @since BuddyPress (1.7.0)
27
  */
28
  function bp_groups_add_admin_menu() {
29
 
 
 
 
30
  // Add our screen
31
  $hook = add_menu_page(
32
  __( 'Groups', 'buddypress' ),
33
  __( 'Groups', 'buddypress' ),
34
+ 'bp_moderate',
35
  'bp-groups',
36
  'bp_groups_admin',
37
  'div'
43
  add_action( bp_core_admin_hook(), 'bp_groups_add_admin_menu' );
44
 
45
  /**
46
+ * Add groups component to custom menus array.
47
+ *
48
+ * This ensures that the Groups menu item appears in the proper order on the
49
+ * main Dashboard menu.
50
  *
51
+ * @since BuddyPress (1.7.0)
52
  *
53
+ * @param array $custom_menus Array of BP top-level menu items.
54
+ * @return array Menu item array, with Groups added.
55
  */
56
  function bp_groups_admin_menu_order( $custom_menus = array() ) {
57
  array_push( $custom_menus, 'bp-groups' );
60
  add_filter( 'bp_admin_menu_order', 'bp_groups_admin_menu_order' );
61
 
62
  /**
63
+ * Set up the Groups admin page.
64
+ *
65
+ * Loaded before the page is rendered, this function does all initial setup,
66
+ * including: processing form requests, registering contextual help, and
67
+ * setting up screen options.
68
+ *
69
+ * @since BuddyPress (1.7.0)
70
  *
71
  * @global object $bp BuddyPress global settings
72
  * @global BP_Groups_List_Table $bp_groups_list_table Groups screen list table
 
73
  */
74
  function bp_groups_admin_load() {
75
  global $bp_groups_list_table;
241
 
242
  // Make sure the user exists before attempting
243
  // to add to the group
244
+ $user = get_user_by( 'slug', $un );
245
+
246
+ if ( empty( $user ) ) {
247
+ $error_new[] = $un;
248
  } else {
249
+ if ( ! groups_join_group( $group_id, $user->ID ) ) {
250
+ $error_new[] = $un;
251
+ } else {
252
+ $success_new[] = $un;
253
+ }
254
  }
255
  }
256
  }
383
  }
384
 
385
  /**
386
+ * Handle save/update of screen options for the Groups component admin screen.
387
  *
388
+ * @since BuddyPress (1.7.0)
389
  *
390
  * @param string $value Will always be false unless another plugin filters it first.
391
+ * @param string $option Screen option name.
392
+ * @param string $new_value Screen option form value.
393
  * @return string Option value. False to abandon update.
394
  */
395
  function bp_groups_admin_screen_options( $value, $option, $new_value ) {
405
  }
406
 
407
  /**
408
+ * Select the appropirate Groups admin screen, and output it.
409
  *
410
+ * @since BuddyPress (1.7.0)
411
  */
412
  function bp_groups_admin() {
413
  // Decide whether to load the index or edit screen
414
+ $doaction = bp_admin_list_table_current_bulk_action();
415
 
416
  // Display the single group edit screen
417
  if ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) {
428
  }
429
 
430
  /**
431
+ * Display the single groups edit screen.
432
  *
433
+ * @since BuddyPress (1.7.0)
434
  */
435
  function bp_groups_admin_edit() {
436
 
437
+ if ( ! current_user_can( 'bp_moderate' ) )
438
  die( '-1' );
439
 
440
  $messages = array();
551
  }
552
 
553
  /**
554
+ * Display the Group delete confirmation screen.
555
  *
556
  * We include a separate confirmation because group deletion is truly
557
  * irreversible.
558
  *
559
+ * @since BuddyPress (1.7.0)
560
  */
561
  function bp_groups_admin_delete() {
562
 
568
  $group_ids = explode( ',', $group_ids );
569
  }
570
  $group_ids = wp_parse_id_list( $group_ids );
571
+ $groups = groups_get_groups( array(
572
+ 'include' => $group_ids,
573
+ 'show_hidden' => true,
574
+ 'per_page' => null, // Return all results
575
+ ) );
576
 
577
  // Create a new list of group ids, based on those that actually exist
578
  $gids = array();
603
  }
604
 
605
  /**
606
+ * Display the Groups admin index screen.
607
+ *
608
+ * This screen contains a list of all BuddyPress groups.
609
  *
610
+ * @since BuddyPress (1.7.0)
611
+ *
612
+ * @global BP_Group_List_Table $bp_groups_list_table Group screen list table.
613
+ * @global string $plugin_page Currently viewed plugin page.
614
  */
615
  function bp_groups_admin_index() {
616
  global $bp_groups_list_table, $plugin_page;
666
  }
667
 
668
  /**
669
+ * Markup for the single group's Settings metabox.
670
+ *
671
+ * @since BuddyPress (1.7.0)
672
  *
673
+ * @param object $item Information about the current group.
 
674
  */
675
  function bp_groups_admin_edit_metabox_settings( $item ) {
676
 
705
  }
706
 
707
  /**
708
+ * Output the markup for a single group's Add New Members metabox.
709
  *
710
+ * @since BuddyPress (1.7.0)
711
  */
712
  function bp_groups_admin_edit_metabox_add_new_members( $item ) {
713
  ?>
718
  }
719
 
720
  /**
721
+ * Renders the Members metabox on single group pages.
722
  *
723
+ * @since BuddyPress (1.7.0)
724
  *
725
+ * @param BP_Groups_Group $item The BP_Groups_Group object for the current
726
+ * group.
727
  */
728
  function bp_groups_admin_edit_metabox_members( $item ) {
729
  global $members_template;
859
  }
860
 
861
  /**
862
+ * Renders the Status metabox for the Groups admin edit screen.
863
+ *
864
+ * @since BuddyPress (1.7.0)
865
  *
866
+ * @param object $item Information about the currently displayed group.
 
867
  */
868
  function bp_groups_admin_edit_metabox_status( $item ) {
869
  $base_url = add_query_arg( array(
888
  }
889
 
890
  /**
891
+ * Create pagination links out of a BP_Group_Member_Query.
892
  *
893
  * This function is intended to create pagination links for use under the
894
  * Manage Members section of the Groups Admin Dashboard pages. It is a stopgap
896
  * Plugin authors should not use this function, as it is likely to be
897
  * deprecated soon.
898
  *
899
+ * @since BuddyPress (1.8.0)
900
+ *
901
+ * @param BP_Group_Member_Query $query A BP_Group_Member_Query object.
902
+ * @param string $member_type member|mod|admin|banned.
903
+ * @return string Pagination links HTML.
904
  */
905
  function bp_groups_admin_create_pagination_links( BP_Group_Member_Query $query, $member_type ) {
906
  $pagination = '';
947
  }
948
 
949
  /**
950
+ * Get a set of usernames corresponding to a set of user IDs.
951
+ *
952
+ * @since BuddyPress (1.7.0)
953
  *
954
+ * @param array $user_ids Array of user IDs.
955
+ * @return array Array of user_logins corresponding to $user_ids.
956
  */
957
  function bp_groups_admin_get_usernames_from_ids( $user_ids = array() ) {
958
 
967
  }
968
 
969
  /**
970
+ * AJAX handler for group member autocomplete requests.
971
  *
972
+ * @since BuddyPress (1.7.0)
973
  */
974
  function bp_groups_admin_autocomplete_handler() {
975
 
1003
  foreach ( (array) $users as $user ) {
1004
  $return[] = array(
1005
  /* translators: 1: user_login, 2: user_email */
1006
+ 'label' => sprintf( __( '%1$s (%2$s)' ), bp_is_username_compatibility_mode() ? $user->user_login : $user->user_nicename, $user->user_email ),
1007
+ 'value' => $user->user_nicename,
1008
  );
1009
  }
1010
 
1015
  /**
1016
  * List table class for the Groups component admin page.
1017
  *
1018
+ * @since BuddyPress (1.7.0)
1019
  */
1020
  class BP_Groups_List_Table extends WP_List_Table {
1021
 
1022
  /**
1023
+ * The type of view currently being displayed.
1024
  *
1025
+ * e.g. "All", "Pending", "Approved", "Spam"...
1026
+ *
1027
+ * @since BuddyPress (1.7.0)
1028
+ *
1029
+ * @access public
1030
+ * @var string
1031
+ */
1032
  public $view = 'all';
1033
 
1034
  /**
1035
+ * Group counts for each group type.
1036
+ *
1037
+ * @since BuddyPress (1.7.0)
1038
  *
1039
+ * @access public
1040
+ * @var int
1041
  */
1042
  public $group_counts = 0;
1043
 
1044
  /**
1045
  * Constructor
1046
  *
1047
+ * @since BuddyPress (1.7.0)
1048
  */
1049
  public function __construct() {
1050
 
1057
  }
1058
 
1059
  /**
1060
+ * Set up items for display in the list table.
1061
  *
1062
+ * Handles filtering of data, sorting, pagination, and any other data
1063
+ * manipulation required prior to rendering.
1064
+ *
1065
+ * @since BuddyPress (1.7.0)
1066
  */
1067
  function prepare_items() {
1068
  global $groups_template;
1165
  }
1166
 
1167
  /**
1168
+ * Get an array of all the columns on the page.
1169
+ *
1170
+ * @since BuddyPress (1.7.0)
1171
  *
1172
+ * @return array Array of column headers.
 
1173
  */
1174
  function get_column_info() {
1175
  $this->_column_headers = array(
1182
  }
1183
 
1184
  /**
1185
+ * Display a message on screen when no items are found ("No groups found").
1186
  *
1187
+ * @since BuddyPress (1.7.0)
1188
  */
1189
  function no_items() {
1190
  _e( 'No groups found.', 'buddypress' );
1191
  }
1192
 
1193
  /**
1194
+ * Output the Groups data table.
1195
  *
1196
+ * @since BuddyPress (1.7.0)
1197
  */
1198
  function display() {
1199
  extract( $this->_args );
1223
  }
1224
 
1225
  /**
1226
+ * Generate content for a single row of the table.
1227
+ *
1228
+ * @since BuddyPress (1.7.0)
1229
  *
1230
+ * @param object $item The current group item in the loop.
 
1231
  */
1232
  function single_row( $item = array() ) {
1233
+ static $even = false;
1234
 
1235
+ $row_classes = array();
1236
+
1237
+ if ( $even ) {
1238
+ $row_classes = array( 'even' );
1239
  } else {
1240
+ $row_classes = array( 'alternate', 'odd' );
1241
  }
1242
 
1243
+ $row_classes = apply_filters( 'bp_groups_admin_row_class', $row_classes, $item['id'] );
1244
+ $row_class = ' class="' . implode( ' ', $row_classes ) . '"';
1245
+
1246
  echo '<tr' . $row_class . ' id="group-' . esc_attr( $item['id'] ) . '" data-parent_id="' . esc_attr( $item['id'] ) . '" data-root_id="' . esc_attr( $item['id'] ) . '">';
1247
  echo $this->single_row_columns( $item );
1248
  echo '</tr>';
1249
+
1250
+ $even = ! $even;
1251
  }
1252
 
1253
  /**
1254
  * Get the list of views available on this table (e.g. "all", "public").
1255
  *
1256
+ * @since BuddyPress (1.7.0)
1257
  */
1258
  function get_views() {
1259
  $url_base = bp_get_admin_url( 'admin.php?page=bp-groups' ); ?>
1270
  }
1271
 
1272
  /**
1273
+ * Get bulk actions for single group row.
1274
+ *
1275
+ * @since BuddyPress (1.7.0)
1276
  *
1277
+ * @return array Key/value pairs for the bulk actions dropdown.
 
1278
  */
1279
  function get_bulk_actions() {
1280
  return apply_filters( 'bp_groups_list_table_get_bulk_actions', array(
1285
  /**
1286
  * Get the table column titles.
1287
  *
1288
+ * @since BuddyPress (1.7.0)
1289
+ *
1290
  * @see WP_List_Table::single_row_columns()
1291
+ *
1292
+ * @return array Array of column titles.
1293
  */
1294
  function get_columns() {
1295
  return array(
1314
  * the sort order - ie, to make it ASC. Thus last_active is set to
1315
  * $desc_first = false.
1316
  *
1317
+ * @since BuddyPress (1.7.0)
1318
+ *
1319
+ * @return array Array of sortable column names.
1320
  */
1321
  function get_sortable_columns() {
1322
  return array(
1328
  }
1329
 
1330
  /**
1331
+ * Markup for the Checkbox column.
1332
+ *
1333
+ * @since BuddyPress (1.7.0)
1334
  *
 
1335
  * @see WP_List_Table::single_row_columns()
1336
+ *
1337
+ * @param array $item A singular item (one full row).
1338
  */
1339
  function column_cb( $item = array() ) {
1340
+ printf( '<label class="screen-reader-text" for="gid-%1$d">' . __( 'Select group %1$d', 'buddypress' ) . '</label><input type="checkbox" name="gid[]" value="%1$d" id="gid-%1$d" />', $item['id'] );
1341
  }
1342
 
1343
  /**
1344
+ * Markup for the Group ID column.
1345
+ *
1346
+ * @since BuddyPress (1.7.0)
1347
  *
 
1348
  * @see WP_List_Table::single_row_columns()
1349
+ *
1350
+ * @param array $item A singular item (one full row).
1351
  */
1352
  function column_gid( $item = array() ) {
1353
  echo '<strong>' . $item['id'] . '</strong>';
1358
  *
1359
  * Called "comment" in the CSS so we can re-use some WP core CSS.
1360
  *
1361
+ * @since BuddyPress (1.7.0)
1362
+ *
1363
  * @see WP_List_Table::single_row_columns()
1364
+ *
1365
+ * @param array $item A singular item (one full row).
1366
  */
1367
  function column_comment( $item = array() ) {
1368
 
1414
  }
1415
 
1416
  /**
1417
+ * Markup for the Description column.
1418
+ *
1419
+ * @since BuddyPress (1.7.0)
1420
  *
1421
+ * @param array Information about the current row.
1422
  */
1423
  function column_description( $item = array() ) {
1424
  echo apply_filters_ref_array( 'bp_get_group_description', array( $item['description'], $item ) );
1425
  }
1426
 
1427
  /**
1428
+ * Markup for the Status column.
1429
+ *
1430
+ * @since BuddyPress (1.7.0)
1431
  *
1432
+ * @param array Information about the current row.
1433
  */
1434
  function column_status( $item = array() ) {
1435
  $status = $item['status'];
1453
  }
1454
 
1455
  /**
1456
+ * Markup for the Number of Members column.
1457
  *
1458
+ * @since BuddyPress (1.7.0)
1459
+ *
1460
+ * @param array Information about the current row.
1461
  */
1462
  function column_members( $item = array() ) {
1463
  $count = groups_get_groupmeta( $item['id'], 'total_member_count' );
1465
  }
1466
 
1467
  /**
1468
+ * Markup for the Last Active column.
1469
+ *
1470
+ * @since BuddyPress (1.7.0)
1471
  *
1472
+ * @param array Information about the current row.
1473
  */
1474
  function column_last_active( $item = array() ) {
1475
  $last_active = groups_get_groupmeta( $item['id'], 'last_activity' );
bp-groups/bp-groups-adminbar.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * BuddyPress Groups Toolbar
5
  *
6
- * Handles the groups functions related to the WordPress Toolbar
7
  *
8
  * @package BuddyPress
9
  * @subpackage Groups
@@ -13,12 +13,11 @@
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
- * Adds the Group Admin top-level menu to group pages
17
  *
18
- * @package BuddyPress
19
- * @since BuddyPress (1.5)
20
  *
21
- * @todo Add dynamic menu items for group extensions
22
  */
23
  function bp_groups_group_admin_menu() {
24
  global $wp_admin_bar, $bp;
@@ -106,9 +105,9 @@ function bp_groups_group_admin_menu() {
106
  add_action( 'admin_bar_menu', 'bp_groups_group_admin_menu', 99 );
107
 
108
  /**
109
- * Remove rogue WP core edit menu when viewing a group
110
  *
111
- * @since BuddyPress (1.6)
112
  */
113
  function bp_groups_remove_edit_page_menu() {
114
  if ( bp_is_group() ) {
3
  /**
4
  * BuddyPress Groups Toolbar
5
  *
6
+ * Handles the groups functions related to the WordPress Toolbar.
7
  *
8
  * @package BuddyPress
9
  * @subpackage Groups
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
+ * Add the Group Admin top-level menu when viewing group pages.
17
  *
18
+ * @since BuddyPress (1.5.0)
 
19
  *
20
+ * @todo Add dynamic menu items for group extensions.
21
  */
22
  function bp_groups_group_admin_menu() {
23
  global $wp_admin_bar, $bp;
105
  add_action( 'admin_bar_menu', 'bp_groups_group_admin_menu', 99 );
106
 
107
  /**
108
+ * Remove rogue WP core Edit menu when viewing a single group.
109
  *
110
+ * @since BuddyPress (1.6.0)
111
  */
112
  function bp_groups_remove_edit_page_menu() {
113
  if ( bp_is_group() ) {
bp-groups/bp-groups-classes.php CHANGED
@@ -11,18 +11,18 @@
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  class BP_Groups_Group {
14
- var $id;
15
- var $creator_id;
16
- var $name;
17
- var $slug;
18
- var $description;
19
- var $status;
20
- var $enable_forum;
21
- var $date_created;
22
 
23
- var $admins;
24
- var $mods;
25
- var $total_member_count;
26
 
27
  /**
28
  * Is the current user a member of this group?
@@ -32,6 +32,22 @@ class BP_Groups_Group {
32
  */
33
  public $is_member;
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  /**
36
  * Timestamp of the last activity that happened in this group.
37
  *
@@ -48,14 +64,14 @@ class BP_Groups_Group {
48
  */
49
  public $user_has_access;
50
 
51
- function __construct( $id = null ) {
52
  if ( !empty( $id ) ) {
53
  $this->id = $id;
54
  $this->populate();
55
  }
56
  }
57
 
58
- function populate() {
59
  global $wpdb, $bp;
60
 
61
  if ( $group = $wpdb->get_row( $wpdb->prepare( "SELECT g.* FROM {$bp->groups->table_name} g WHERE g.id = %d", $this->id ) ) ) {
@@ -72,6 +88,8 @@ class BP_Groups_Group {
72
  $this->last_activity = groups_get_groupmeta( $this->id, 'last_activity' );
73
  $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
74
  $this->is_member = BP_Groups_Member::check_is_member( bp_loggedin_user_id(), $this->id );
 
 
75
 
76
  // If this is a private or hidden group, does the current user have access?
77
  if ( 'private' == $this->status || 'hidden' == $this->status ) {
@@ -96,7 +114,7 @@ class BP_Groups_Group {
96
  }
97
  }
98
 
99
- function save() {
100
  global $wpdb, $bp;
101
 
102
  $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id );
@@ -167,7 +185,7 @@ class BP_Groups_Group {
167
  return true;
168
  }
169
 
170
- function delete() {
171
  global $wpdb, $bp;
172
 
173
  // Delete groupmeta for the group
@@ -196,7 +214,7 @@ class BP_Groups_Group {
196
 
197
  /** Static Methods ********************************************************/
198
 
199
- function group_exists( $slug, $table_name = false ) {
200
  global $wpdb, $bp;
201
 
202
  if ( empty( $table_name ) )
@@ -205,19 +223,19 @@ class BP_Groups_Group {
205
  if ( empty( $slug ) )
206
  return false;
207
 
208
- return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", $slug ) );
209
  }
210
 
211
- function get_id_from_slug( $slug ) {
212
  return BP_Groups_Group::group_exists( $slug );
213
  }
214
 
215
- function get_invites( $user_id, $group_id ) {
216
  global $wpdb, $bp;
217
  return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d and is_confirmed = 0 AND inviter_id = %d", $group_id, $user_id ) );
218
  }
219
 
220
- function filter_user_groups( $filter, $user_id = 0, $order = false, $limit = null, $page = null ) {
221
  global $wpdb, $bp;
222
 
223
  if ( empty( $user_id ) )
@@ -225,6 +243,8 @@ class BP_Groups_Group {
225
 
226
  $filter = esc_sql( like_escape( $filter ) );
227
 
 
 
228
  if ( !empty( $limit ) && !empty( $page ) )
229
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
230
 
@@ -245,11 +265,13 @@ class BP_Groups_Group {
245
  /**
246
  * @todo Deprecate in favor of get()
247
  */
248
- function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
249
  global $wpdb, $bp;
250
 
251
  $filter = esc_sql( like_escape( $filter ) );
252
 
 
 
253
  if ( !empty( $limit ) && !empty( $page ) )
254
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
255
 
@@ -268,19 +290,19 @@ class BP_Groups_Group {
268
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
269
  }
270
 
271
- function check_slug( $slug ) {
272
  global $wpdb, $bp;
273
 
274
  return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) );
275
  }
276
 
277
- function get_slug( $group_id ) {
278
  global $wpdb, $bp;
279
 
280
  return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) );
281
  }
282
 
283
- function has_members( $group_id ) {
284
  global $wpdb, $bp;
285
 
286
  $members = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
@@ -291,13 +313,13 @@ class BP_Groups_Group {
291
  return true;
292
  }
293
 
294
- function has_membership_requests( $group_id ) {
295
  global $wpdb, $bp;
296
 
297
  return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) );
298
  }
299
 
300
- function get_membership_requests( $group_id, $limit = null, $page = null ) {
301
  global $wpdb, $bp;
302
 
303
  if ( !empty( $limit ) && !empty( $page ) ) {
@@ -310,7 +332,7 @@ class BP_Groups_Group {
310
  return array( 'requests' => $paged_requests, 'total' => $total_requests );
311
  }
312
 
313
- function get( $args = array() ) {
314
  global $wpdb, $bp;
315
 
316
  // Backward compatibility with old method of passing arguments
@@ -441,7 +463,7 @@ class BP_Groups_Group {
441
  }
442
 
443
  // Get paginated results
444
- $paged_groups_sql = apply_filters( 'bp_groups_get_paged_groups_sql', join( ' ', (array) $sql ), $sql );
445
  $paged_groups = $wpdb->get_results( $paged_groups_sql );
446
 
447
  $total_sql['select'] = "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name} g, {$bp->groups->table_name_members} gm1, {$bp->groups->table_name_groupmeta} gm2";
@@ -494,7 +516,7 @@ class BP_Groups_Group {
494
  }
495
 
496
  // Get total group results
497
- $total_groups_sql = apply_filters( 'bp_groups_get_total_groups_sql', $t_sql, $total_sql );
498
  $total_groups = $wpdb->get_var( $total_groups_sql );
499
 
500
  $group_ids = array();
@@ -504,7 +526,6 @@ class BP_Groups_Group {
504
 
505
  // Populate some extra information instead of querying each time in the loop
506
  if ( !empty( $r['populate_extras'] ) ) {
507
- $group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
508
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, $r['type'] );
509
  }
510
 
@@ -584,7 +605,7 @@ class BP_Groups_Group {
584
  * @param string $type The 'type' shorthand param
585
  * @return array 'order' and 'orderby'
586
  */
587
- protected function convert_type_to_order_orderby( $type = '' ) {
588
  $order = $orderby = '';
589
 
590
  switch ( $type ) {
@@ -625,7 +646,7 @@ class BP_Groups_Group {
625
  * @param string $orderby
626
  * @return string $order_by_term
627
  */
628
- protected function convert_orderby_to_order_by_term( $orderby ) {
629
  $order_by_term = '';
630
 
631
  switch ( $orderby ) {
@@ -654,7 +675,7 @@ class BP_Groups_Group {
654
  return $order_by_term;
655
  }
656
 
657
- function get_by_most_forum_topics( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
658
  global $wpdb, $bp, $bbdb;
659
 
660
  if ( empty( $bbdb ) )
@@ -687,15 +708,16 @@ class BP_Groups_Group {
687
  }
688
 
689
  if ( !empty( $populate_extras ) ) {
690
- foreach ( (array) $paged_groups as $group ) $group_ids[] = $group->id;
691
- $group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
 
692
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );
693
  }
694
 
695
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
696
  }
697
 
698
- function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true, $exclude = false ) {
699
  global $wpdb, $bp, $bbdb;
700
 
701
  if ( empty( $bbdb ) )
@@ -728,17 +750,20 @@ class BP_Groups_Group {
728
  }
729
 
730
  if ( !empty( $populate_extras ) ) {
731
- foreach ( (array) $paged_groups as $group ) $group_ids[] = $group->id;
732
- $group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
 
733
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );
734
  }
735
 
736
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
737
  }
738
 
739
- function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) {
740
  global $wpdb, $bp;
741
 
 
 
742
  // Multibyte compliance
743
  if ( function_exists( 'mb_strlen' ) ) {
744
  if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
@@ -762,23 +787,23 @@ class BP_Groups_Group {
762
 
763
  if ( !empty( $limit ) && !empty( $page ) ) {
764
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
765
- $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '{$letter}%%' {$hidden_sql} {$exclude_sql}" );
766
  }
767
 
 
 
768
  $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '{$letter}%%' {$hidden_sql} {$exclude_sql} ORDER BY g.name ASC {$pag_sql}" );
769
 
770
  if ( !empty( $populate_extras ) ) {
771
  foreach ( (array) $paged_groups as $group ) {
772
  $group_ids[] = $group->id;
773
  }
774
- $group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
775
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );
776
  }
777
 
778
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
779
  }
780
 
781
- function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
782
  global $wpdb, $bp;
783
 
784
  $pag_sql = $hidden_sql = $search_sql = $exclude_sql = '';
@@ -810,15 +835,16 @@ class BP_Groups_Group {
810
  }
811
 
812
  if ( !empty( $populate_extras ) ) {
813
- foreach ( (array) $paged_groups as $group ) $group_ids[] = $group->id;
814
- $group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
 
815
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );
816
  }
817
 
818
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
819
  }
820
 
821
- function get_group_extras( &$paged_groups, &$group_ids, $type = false ) {
822
  global $bp, $wpdb;
823
 
824
  if ( empty( $group_ids ) )
@@ -827,14 +853,30 @@ class BP_Groups_Group {
827
  // Sanitize group IDs
828
  $group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
829
 
830
- // Fetch the logged in users status within each group
831
- $user_status = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id IN ( {$group_ids} ) AND is_confirmed = 1 AND is_banned = 0", bp_loggedin_user_id() ) );
 
832
  for ( $i = 0, $count = count( $paged_groups ); $i < $count; ++$i ) {
833
- $paged_groups[$i]->is_member = false;
 
 
834
 
835
- foreach ( (array) $user_status as $group_id ) {
836
- if ( $group_id == $paged_groups[$i]->id ) {
837
- $paged_groups[$i]->is_member = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
838
  }
839
  }
840
  }
@@ -853,13 +895,13 @@ class BP_Groups_Group {
853
  return $paged_groups;
854
  }
855
 
856
- function delete_all_invites( $group_id ) {
857
  global $wpdb, $bp;
858
 
859
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
860
  }
861
 
862
- function get_total_group_count() {
863
  global $wpdb, $bp;
864
 
865
  $hidden_sql = '';
@@ -869,7 +911,7 @@ class BP_Groups_Group {
869
  return $wpdb->get_var( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql}" );
870
  }
871
 
872
- function get_global_forum_topic_count( $type ) {
873
  global $bbdb, $wpdb, $bp;
874
 
875
  if ( 'unreplied' == $type )
@@ -885,7 +927,7 @@ class BP_Groups_Group {
885
  return $wpdb->get_var( "SELECT COUNT(t.topic_id) FROM {$bbdb->topics} AS t, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND t.topic_status = '0' AND t.topic_sticky != '2' {$extra_sql} " );
886
  }
887
 
888
- function get_total_member_count( $group_id ) {
889
  global $wpdb, $bp;
890
 
891
  return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) );
@@ -900,7 +942,7 @@ class BP_Groups_Group {
900
  * @param string $status 'public', 'private', 'hidden', 'all' Which group types to count
901
  * @return int The topic count
902
  */
903
- function get_global_topic_count( $status = 'public', $search_terms = false ) {
904
  global $bbdb, $wpdb, $bp;
905
 
906
  switch ( $status ) {
@@ -946,7 +988,7 @@ class BP_Groups_Group {
946
  *
947
  * @return array
948
  */
949
- function get_group_type_ids() {
950
  global $wpdb, $bp;
951
 
952
  $ids = array();
@@ -1004,7 +1046,7 @@ class BP_Group_Member_Query extends BP_User_Query {
1004
  * @param array
1005
  * @return array
1006
  */
1007
- public function get_include_ids( $include ) {
1008
  // The following args are specific to group member queries, and
1009
  // are not present in the query_vars of a normal BP_User_Query.
1010
  // We loop through to make sure that defaults are set (though
@@ -1196,7 +1238,7 @@ class BP_Groups_Member {
1196
  var $invite_sent;
1197
  var $user;
1198
 
1199
- function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true ) {
1200
 
1201
  // User and group are not empty, and ID is
1202
  if ( !empty( $user_id ) && !empty( $group_id ) && empty( $id ) ) {
@@ -1218,7 +1260,7 @@ class BP_Groups_Member {
1218
  }
1219
  }
1220
 
1221
- function populate() {
1222
  global $wpdb, $bp;
1223
 
1224
  if ( $this->user_id && $this->group_id && !$this->id )
@@ -1247,7 +1289,7 @@ class BP_Groups_Member {
1247
  }
1248
  }
1249
 
1250
- function save() {
1251
  global $wpdb, $bp;
1252
 
1253
  $this->user_id = apply_filters( 'groups_member_user_id_before_save', $this->user_id, $this->id );
@@ -1291,7 +1333,7 @@ class BP_Groups_Member {
1291
  return true;
1292
  }
1293
 
1294
- function promote( $status = 'mod' ) {
1295
  if ( 'mod' == $status ) {
1296
  $this->is_admin = 0;
1297
  $this->is_mod = 1;
@@ -1307,7 +1349,7 @@ class BP_Groups_Member {
1307
  return $this->save();
1308
  }
1309
 
1310
- function demote() {
1311
  $this->is_mod = 0;
1312
  $this->is_admin = 0;
1313
  $this->user_title = false;
@@ -1315,7 +1357,7 @@ class BP_Groups_Member {
1315
  return $this->save();
1316
  }
1317
 
1318
- function ban() {
1319
  if ( !empty( $this->is_admin ) )
1320
  return false;
1321
 
@@ -1325,7 +1367,7 @@ class BP_Groups_Member {
1325
  return $this->save();
1326
  }
1327
 
1328
- function unban() {
1329
  if ( !empty( $this->is_admin ) )
1330
  return false;
1331
 
@@ -1334,18 +1376,18 @@ class BP_Groups_Member {
1334
  return $this->save();
1335
  }
1336
 
1337
- function accept_invite() {
1338
  $this->inviter_id = 0;
1339
  $this->is_confirmed = 1;
1340
  $this->date_modified = bp_core_current_time();
1341
  }
1342
 
1343
- function accept_request() {
1344
  $this->is_confirmed = 1;
1345
  $this->date_modified = bp_core_current_time();
1346
  }
1347
 
1348
- function remove() {
1349
  global $wpdb, $bp;
1350
 
1351
  $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
@@ -1386,7 +1428,7 @@ class BP_Groups_Member {
1386
  return groups_update_groupmeta( $group_id, 'total_member_count', (int) BP_Groups_Group::get_total_member_count( $group_id ) );
1387
  }
1388
 
1389
- function delete( $user_id, $group_id ) {
1390
  global $wpdb, $bp;
1391
 
1392
  $remove = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
@@ -1400,7 +1442,7 @@ class BP_Groups_Member {
1400
  return $remove;
1401
  }
1402
 
1403
- function get_group_ids( $user_id, $limit = false, $page = false ) {
1404
  global $wpdb, $bp;
1405
 
1406
  $pag_sql = '';
@@ -1421,7 +1463,7 @@ class BP_Groups_Member {
1421
  return array( 'groups' => $groups, 'total' => (int) $total_groups );
1422
  }
1423
 
1424
- function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
1425
  global $wpdb, $bp;
1426
 
1427
  $pag_sql = $hidden_sql = $filter_sql = '';
@@ -1443,7 +1485,7 @@ class BP_Groups_Member {
1443
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
1444
  }
1445
 
1446
- function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
1447
  global $wpdb, $bp;
1448
 
1449
  $pag_sql = $hidden_sql = $filter_sql = '';
@@ -1465,7 +1507,7 @@ class BP_Groups_Member {
1465
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
1466
  }
1467
 
1468
- function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
1469
  global $wpdb, $bp;
1470
 
1471
  $pag_sql = $hidden_sql = $filter_sql = '';
@@ -1487,7 +1529,7 @@ class BP_Groups_Member {
1487
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
1488
  }
1489
 
1490
- function total_group_count( $user_id = 0 ) {
1491
  global $bp, $wpdb;
1492
 
1493
  if ( empty( $user_id ) )
@@ -1500,7 +1542,7 @@ class BP_Groups_Member {
1500
  }
1501
  }
1502
 
1503
- function get_invites( $user_id, $limit = false, $page = false, $exclude = false ) {
1504
  global $wpdb, $bp;
1505
 
1506
  $pag_sql = ( !empty( $limit ) && !empty( $page ) ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
@@ -1518,7 +1560,7 @@ class BP_Groups_Member {
1518
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
1519
  }
1520
 
1521
- function check_has_invite( $user_id, $group_id, $type = 'sent' ) {
1522
  global $wpdb, $bp;
1523
 
1524
  if ( empty( $user_id ) )
@@ -1532,7 +1574,7 @@ class BP_Groups_Member {
1532
  return $wpdb->get_var( $wpdb->prepare( $sql, $user_id, $group_id ) );
1533
  }
1534
 
1535
- function delete_invite( $user_id, $group_id ) {
1536
  global $wpdb, $bp;
1537
 
1538
  if ( empty( $user_id ) )
@@ -1541,7 +1583,7 @@ class BP_Groups_Member {
1541
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
1542
  }
1543
 
1544
- function delete_request( $user_id, $group_id ) {
1545
  global $wpdb, $bp;
1546
 
1547
  if ( empty( $user_id ) )
@@ -1550,7 +1592,7 @@ class BP_Groups_Member {
1550
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id = 0 AND invite_sent = 0", $user_id, $group_id ) );
1551
  }
1552
 
1553
- function check_is_admin( $user_id, $group_id ) {
1554
  global $wpdb, $bp;
1555
 
1556
  if ( empty( $user_id ) )
@@ -1559,7 +1601,7 @@ class BP_Groups_Member {
1559
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_admin = 1 AND is_banned = 0", $user_id, $group_id ) );
1560
  }
1561
 
1562
- function check_is_mod( $user_id, $group_id ) {
1563
  global $wpdb, $bp;
1564
 
1565
  if ( empty( $user_id ) )
@@ -1568,7 +1610,7 @@ class BP_Groups_Member {
1568
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_mod = 1 AND is_banned = 0", $user_id, $group_id ) );
1569
  }
1570
 
1571
- function check_is_member( $user_id, $group_id ) {
1572
  global $wpdb, $bp;
1573
 
1574
  if ( empty( $user_id ) )
@@ -1577,7 +1619,7 @@ class BP_Groups_Member {
1577
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) );
1578
  }
1579
 
1580
- function check_is_banned( $user_id, $group_id ) {
1581
  global $wpdb, $bp;
1582
 
1583
  if ( empty( $user_id ) )
@@ -1595,7 +1637,7 @@ class BP_Groups_Member {
1595
  * @param int $group_id
1596
  * @since BuddyPress (1.2.6)
1597
  */
1598
- function check_is_creator( $user_id, $group_id ) {
1599
  global $bp, $wpdb;
1600
 
1601
  if ( empty( $user_id ) )
@@ -1604,7 +1646,7 @@ class BP_Groups_Member {
1604
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name} WHERE creator_id = %d AND id = %d", $user_id, $group_id ) );
1605
  }
1606
 
1607
- function check_for_membership_request( $user_id, $group_id ) {
1608
  global $wpdb, $bp;
1609
 
1610
  if ( empty( $user_id ) )
@@ -1613,7 +1655,7 @@ class BP_Groups_Member {
1613
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) );
1614
  }
1615
 
1616
- function get_random_groups( $user_id = 0, $total_groups = 5 ) {
1617
  global $wpdb, $bp;
1618
 
1619
  // If the user is logged in and viewing their random groups, we can show hidden and private groups
@@ -1624,31 +1666,31 @@ class BP_Groups_Member {
1624
  }
1625
  }
1626
 
1627
- function get_group_member_ids( $group_id ) {
1628
  global $bp, $wpdb;
1629
 
1630
  return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) );
1631
  }
1632
 
1633
- function get_group_administrator_ids( $group_id ) {
1634
  global $bp, $wpdb;
1635
 
1636
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) );
1637
  }
1638
 
1639
- function get_group_moderator_ids( $group_id ) {
1640
  global $bp, $wpdb;
1641
 
1642
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) );
1643
  }
1644
 
1645
- function get_all_membership_request_user_ids( $group_id ) {
1646
  global $bp, $wpdb;
1647
 
1648
  return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
1649
  }
1650
 
1651
- function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false ) {
1652
  global $bp, $wpdb;
1653
 
1654
  _deprecated_function( __METHOD__, '1.8', 'BP_Group_Member_Query' );
@@ -1707,7 +1749,7 @@ class BP_Groups_Member {
1707
  return array( 'members' => $members, 'count' => $total_member_count );
1708
  }
1709
 
1710
- function delete_all( $group_id ) {
1711
  global $wpdb, $bp;
1712
 
1713
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
@@ -1722,7 +1764,7 @@ class BP_Groups_Member {
1722
  * @since BuddyPress (1.0)
1723
  * @uses BP_Groups_Member
1724
  */
1725
- function delete_all_for_user( $user_id ) {
1726
  global $bp, $wpdb;
1727
 
1728
  // Get all the group ids for the current user's groups and update counts
@@ -2247,7 +2289,7 @@ class BP_Group_Extension {
2247
 
2248
  // The create screen requires an additional nonce field
2249
  // due to a quirk in the way the templates are built
2250
- wp_nonce_field( 'groups_create_save_' . bp_get_groups_current_create_step() );
2251
  }
2252
 
2253
  /**
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
  class BP_Groups_Group {
14
+ public $id;
15
+ public $creator_id;
16
+ public $name;
17
+ public $slug;
18
+ public $description;
19
+ public $status;
20
+ public $enable_forum;
21
+ public $date_created;
22
 
23
+ public $admins;
24
+ public $mods;
25
+ public $total_member_count;
26
 
27
  /**
28
  * Is the current user a member of this group?
32
  */
33
  public $is_member;
34
 
35
+ /**
36
+ * Does the current user have an outstanding invitation to this group?
37
+ *
38
+ * @since BuddyPress (1.9.0)
39
+ * @var bool
40
+ */
41
+ public $is_invited;
42
+
43
+ /**
44
+ * Does the current user have a pending membership request to this group?
45
+ *
46
+ * @since BuddyPress (1.9.0)
47
+ * @var bool
48
+ */
49
+ public $is_pending;
50
+
51
  /**
52
  * Timestamp of the last activity that happened in this group.
53
  *
64
  */
65
  public $user_has_access;
66
 
67
+ public function __construct( $id = null ) {
68
  if ( !empty( $id ) ) {
69
  $this->id = $id;
70
  $this->populate();
71
  }
72
  }
73
 
74
+ public function populate() {
75
  global $wpdb, $bp;
76
 
77
  if ( $group = $wpdb->get_row( $wpdb->prepare( "SELECT g.* FROM {$bp->groups->table_name} g WHERE g.id = %d", $this->id ) ) ) {
88
  $this->last_activity = groups_get_groupmeta( $this->id, 'last_activity' );
89
  $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
90
  $this->is_member = BP_Groups_Member::check_is_member( bp_loggedin_user_id(), $this->id );
91
+ $this->is_invited = BP_Groups_Member::check_has_invite( bp_loggedin_user_id(), $this->id );
92
+ $this->is_pending = BP_Groups_Member::check_for_membership_request( bp_loggedin_user_id(), $this->id );
93
 
94
  // If this is a private or hidden group, does the current user have access?
95
  if ( 'private' == $this->status || 'hidden' == $this->status ) {
114
  }
115
  }
116
 
117
+ public function save() {
118
  global $wpdb, $bp;
119
 
120
  $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id );
185
  return true;
186
  }
187
 
188
+ public function delete() {
189
  global $wpdb, $bp;
190
 
191
  // Delete groupmeta for the group
214
 
215
  /** Static Methods ********************************************************/
216
 
217
+ public static function group_exists( $slug, $table_name = false ) {
218
  global $wpdb, $bp;
219
 
220
  if ( empty( $table_name ) )
223
  if ( empty( $slug ) )
224
  return false;
225
 
226
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", strtolower( $slug ) ) );
227
  }
228
 
229
+ public static function get_id_from_slug( $slug ) {
230
  return BP_Groups_Group::group_exists( $slug );
231
  }
232
 
233
+ public static function get_invites( $user_id, $group_id ) {
234
  global $wpdb, $bp;
235
  return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d and is_confirmed = 0 AND inviter_id = %d", $group_id, $user_id ) );
236
  }
237
 
238
+ public static function filter_user_groups( $filter, $user_id = 0, $order = false, $limit = null, $page = null ) {
239
  global $wpdb, $bp;
240
 
241
  if ( empty( $user_id ) )
243
 
244
  $filter = esc_sql( like_escape( $filter ) );
245
 
246
+ $pag_sql = $order_sql = $hidden_sql = '';
247
+
248
  if ( !empty( $limit ) && !empty( $page ) )
249
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
250
 
265
  /**
266
  * @todo Deprecate in favor of get()
267
  */
268
+ public static function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
269
  global $wpdb, $bp;
270
 
271
  $filter = esc_sql( like_escape( $filter ) );
272
 
273
+ $pag_sql = $order_sql = $hidden_sql = '';
274
+
275
  if ( !empty( $limit ) && !empty( $page ) )
276
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
277
 
290
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
291
  }
292
 
293
+ public static function check_slug( $slug ) {
294
  global $wpdb, $bp;
295
 
296
  return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) );
297
  }
298
 
299
+ public static function get_slug( $group_id ) {
300
  global $wpdb, $bp;
301
 
302
  return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) );
303
  }
304
 
305
+ public static function has_members( $group_id ) {
306
  global $wpdb, $bp;
307
 
308
  $members = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
313
  return true;
314
  }
315
 
316
+ public static function has_membership_requests( $group_id ) {
317
  global $wpdb, $bp;
318
 
319
  return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) );
320
  }
321
 
322
+ public static function get_membership_requests( $group_id, $limit = null, $page = null ) {
323
  global $wpdb, $bp;
324
 
325
  if ( !empty( $limit ) && !empty( $page ) ) {
332
  return array( 'requests' => $paged_requests, 'total' => $total_requests );
333
  }
334
 
335
+ public static function get( $args = array() ) {
336
  global $wpdb, $bp;
337
 
338
  // Backward compatibility with old method of passing arguments
463
  }
464
 
465
  // Get paginated results
466
+ $paged_groups_sql = apply_filters( 'bp_groups_get_paged_groups_sql', join( ' ', (array) $sql ), $sql, $r );
467
  $paged_groups = $wpdb->get_results( $paged_groups_sql );
468
 
469
  $total_sql['select'] = "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name} g, {$bp->groups->table_name_members} gm1, {$bp->groups->table_name_groupmeta} gm2";
516
  }
517
 
518
  // Get total group results
519
+ $total_groups_sql = apply_filters( 'bp_groups_get_total_groups_sql', $t_sql, $total_sql, $r );
520
  $total_groups = $wpdb->get_var( $total_groups_sql );
521
 
522
  $group_ids = array();
526
 
527
  // Populate some extra information instead of querying each time in the loop
528
  if ( !empty( $r['populate_extras'] ) ) {
 
529
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, $r['type'] );
530
  }
531
 
605
  * @param string $type The 'type' shorthand param
606
  * @return array 'order' and 'orderby'
607
  */
608
+ protected static function convert_type_to_order_orderby( $type = '' ) {
609
  $order = $orderby = '';
610
 
611
  switch ( $type ) {
646
  * @param string $orderby
647
  * @return string $order_by_term
648
  */
649
+ protected static function convert_orderby_to_order_by_term( $orderby ) {
650
  $order_by_term = '';
651
 
652
  switch ( $orderby ) {
675
  return $order_by_term;
676
  }
677
 
678
+ public static function get_by_most_forum_topics( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
679
  global $wpdb, $bp, $bbdb;
680
 
681
  if ( empty( $bbdb ) )
708
  }
709
 
710
  if ( !empty( $populate_extras ) ) {
711
+ foreach ( (array) $paged_groups as $group ) {
712
+ $group_ids[] = $group->id;
713
+ }
714
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );
715
  }
716
 
717
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
718
  }
719
 
720
+ public static function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true, $exclude = false ) {
721
  global $wpdb, $bp, $bbdb;
722
 
723
  if ( empty( $bbdb ) )
750
  }
751
 
752
  if ( !empty( $populate_extras ) ) {
753
+ foreach ( (array) $paged_groups as $group ) {
754
+ $group_ids[] = $group->id;
755
+ }
756
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );
757
  }
758
 
759
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
760
  }
761
 
762
+ public static function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) {
763
  global $wpdb, $bp;
764
 
765
+ $pag_sql = $hidden_sql = $exclude_sql = '';
766
+
767
  // Multibyte compliance
768
  if ( function_exists( 'mb_strlen' ) ) {
769
  if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
787
 
788
  if ( !empty( $limit ) && !empty( $page ) ) {
789
  $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
 
790
  }
791
 
792
+ $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '{$letter}%%' {$hidden_sql} {$exclude_sql}" );
793
+
794
  $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '{$letter}%%' {$hidden_sql} {$exclude_sql} ORDER BY g.name ASC {$pag_sql}" );
795
 
796
  if ( !empty( $populate_extras ) ) {
797
  foreach ( (array) $paged_groups as $group ) {
798
  $group_ids[] = $group->id;
799
  }
 
800
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );
801
  }
802
 
803
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
804
  }
805
 
806
+ public static function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
807
  global $wpdb, $bp;
808
 
809
  $pag_sql = $hidden_sql = $search_sql = $exclude_sql = '';
835
  }
836
 
837
  if ( !empty( $populate_extras ) ) {
838
+ foreach ( (array) $paged_groups as $group ) {
839
+ $group_ids[] = $group->id;
840
+ }
841
  $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' );
842
  }
843
 
844
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
845
  }
846
 
847
+ public static function get_group_extras( &$paged_groups, &$group_ids, $type = false ) {
848
  global $bp, $wpdb;
849
 
850
  if ( empty( $group_ids ) )
853
  // Sanitize group IDs
854
  $group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
855
 
856
+ // Fetch the logged-in user's status within each group
857
+ $user_status = $wpdb->get_results( $wpdb->prepare( "SELECT group_id, is_confirmed, invite_sent FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id IN ( {$group_ids} ) AND is_banned = 0", bp_loggedin_user_id() ) );
858
+
859
  for ( $i = 0, $count = count( $paged_groups ); $i < $count; ++$i ) {
860
+ foreach ( (array) $user_status as $group ) {
861
+ if ( $group->group_id == $paged_groups[ $i ]->id ) {
862
+ $is_member = $is_invited = $is_pending = '0';
863
 
864
+ // is_confirmed means the user is a member
865
+ if ( $group->is_confirmed ) {
866
+ $is_member = '1';
867
+
868
+ // invite_sent means the user has been invited
869
+ } else if ( $group->invite_sent ) {
870
+ $is_invited = '1';
871
+
872
+ // User has sent request, but has not been confirmed
873
+ } else {
874
+ $is_pending = '1';
875
+ }
876
+
877
+ $paged_groups[ $i ]->is_member = $is_member;
878
+ $paged_groups[ $i ]->is_invited = $is_invited;
879
+ $paged_groups[ $i ]->is_pending = $is_pending;
880
  }
881
  }
882
  }
895
  return $paged_groups;
896
  }
897
 
898
+ public static function delete_all_invites( $group_id ) {
899
  global $wpdb, $bp;
900
 
901
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
902
  }
903
 
904
+ public static function get_total_group_count() {
905
  global $wpdb, $bp;
906
 
907
  $hidden_sql = '';
911
  return $wpdb->get_var( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql}" );
912
  }
913
 
914
+ public static function get_global_forum_topic_count( $type ) {
915
  global $bbdb, $wpdb, $bp;
916
 
917
  if ( 'unreplied' == $type )
927
  return $wpdb->get_var( "SELECT COUNT(t.topic_id) FROM {$bbdb->topics} AS t, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND t.topic_status = '0' AND t.topic_sticky != '2' {$extra_sql} " );
928
  }
929
 
930
+ public static function get_total_member_count( $group_id ) {
931
  global $wpdb, $bp;
932
 
933
  return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) );
942
  * @param string $status 'public', 'private', 'hidden', 'all' Which group types to count
943
  * @return int The topic count
944
  */
945
+ public static function get_global_topic_count( $status = 'public', $search_terms = false ) {
946
  global $bbdb, $wpdb, $bp;
947
 
948
  switch ( $status ) {
988
  *
989
  * @return array
990
  */
991
+ public static function get_group_type_ids() {
992
  global $wpdb, $bp;
993
 
994
  $ids = array();
1046
  * @param array
1047
  * @return array
1048
  */
1049
+ public function get_include_ids( $include = array() ) {
1050
  // The following args are specific to group member queries, and
1051
  // are not present in the query_vars of a normal BP_User_Query.
1052
  // We loop through to make sure that defaults are set (though
1238
  var $invite_sent;
1239
  var $user;
1240
 
1241
+ public function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true ) {
1242
 
1243
  // User and group are not empty, and ID is
1244
  if ( !empty( $user_id ) && !empty( $group_id ) && empty( $id ) ) {
1260
  }
1261
  }
1262
 
1263
+ public function populate() {
1264
  global $wpdb, $bp;
1265
 
1266
  if ( $this->user_id && $this->group_id && !$this->id )
1289
  }
1290
  }
1291
 
1292
+ public function save() {
1293
  global $wpdb, $bp;
1294
 
1295
  $this->user_id = apply_filters( 'groups_member_user_id_before_save', $this->user_id, $this->id );
1333
  return true;
1334
  }
1335
 
1336
+ public function promote( $status = 'mod' ) {
1337
  if ( 'mod' == $status ) {
1338
  $this->is_admin = 0;
1339
  $this->is_mod = 1;
1349
  return $this->save();
1350
  }
1351
 
1352
+ public function demote() {
1353
  $this->is_mod = 0;
1354
  $this->is_admin = 0;
1355
  $this->user_title = false;
1357
  return $this->save();
1358
  }
1359
 
1360
+ public function ban() {
1361
  if ( !empty( $this->is_admin ) )
1362
  return false;
1363
 
1367
  return $this->save();
1368
  }
1369
 
1370
+ public function unban() {
1371
  if ( !empty( $this->is_admin ) )
1372
  return false;
1373
 
1376
  return $this->save();
1377
  }
1378
 
1379
+ public function accept_invite() {
1380
  $this->inviter_id = 0;
1381
  $this->is_confirmed = 1;
1382
  $this->date_modified = bp_core_current_time();
1383
  }
1384
 
1385
+ public function accept_request() {
1386
  $this->is_confirmed = 1;
1387
  $this->date_modified = bp_core_current_time();
1388
  }
1389
 
1390
+ public function remove() {
1391
  global $wpdb, $bp;
1392
 
1393
  $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
1428
  return groups_update_groupmeta( $group_id, 'total_member_count', (int) BP_Groups_Group::get_total_member_count( $group_id ) );
1429
  }
1430
 
1431
+ public static function delete( $user_id, $group_id ) {
1432
  global $wpdb, $bp;
1433
 
1434
  $remove = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
1442
  return $remove;
1443
  }
1444
 
1445
+ public static function get_group_ids( $user_id, $limit = false, $page = false ) {
1446
  global $wpdb, $bp;
1447
 
1448
  $pag_sql = '';
1463
  return array( 'groups' => $groups, 'total' => (int) $total_groups );
1464
  }
1465
 
1466
+ public static function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
1467
  global $wpdb, $bp;
1468
 
1469
  $pag_sql = $hidden_sql = $filter_sql = '';
1485
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
1486
  }
1487
 
1488
+ public static function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
1489
  global $wpdb, $bp;
1490
 
1491
  $pag_sql = $hidden_sql = $filter_sql = '';
1507
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
1508
  }
1509
 
1510
+ public static function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
1511
  global $wpdb, $bp;
1512
 
1513
  $pag_sql = $hidden_sql = $filter_sql = '';
1529
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
1530
  }
1531
 
1532
+ public static function total_group_count( $user_id = 0 ) {
1533
  global $bp, $wpdb;
1534
 
1535
  if ( empty( $user_id ) )
1542
  }
1543
  }
1544
 
1545
+ public static function get_invites( $user_id, $limit = false, $page = false, $exclude = false ) {
1546
  global $wpdb, $bp;
1547
 
1548
  $pag_sql = ( !empty( $limit ) && !empty( $page ) ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
1560
  return array( 'groups' => $paged_groups, 'total' => $total_groups );
1561
  }
1562
 
1563
+ public static function check_has_invite( $user_id, $group_id, $type = 'sent' ) {
1564
  global $wpdb, $bp;
1565
 
1566
  if ( empty( $user_id ) )
1574
  return $wpdb->get_var( $wpdb->prepare( $sql, $user_id, $group_id ) );
1575
  }
1576
 
1577
+ public static function delete_invite( $user_id, $group_id ) {
1578
  global $wpdb, $bp;
1579
 
1580
  if ( empty( $user_id ) )
1583
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
1584
  }
1585
 
1586
+ public static function delete_request( $user_id, $group_id ) {
1587
  global $wpdb, $bp;
1588
 
1589
  if ( empty( $user_id ) )
1592
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id = 0 AND invite_sent = 0", $user_id, $group_id ) );
1593
  }
1594
 
1595
+ public static function check_is_admin( $user_id, $group_id ) {
1596
  global $wpdb, $bp;
1597
 
1598
  if ( empty( $user_id ) )
1601
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_admin = 1 AND is_banned = 0", $user_id, $group_id ) );
1602
  }
1603
 
1604
+ public static function check_is_mod( $user_id, $group_id ) {
1605
  global $wpdb, $bp;
1606
 
1607
  if ( empty( $user_id ) )
1610
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_mod = 1 AND is_banned = 0", $user_id, $group_id ) );
1611
  }
1612
 
1613
+ public static function check_is_member( $user_id, $group_id ) {
1614
  global $wpdb, $bp;
1615
 
1616
  if ( empty( $user_id ) )
1619
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) );
1620
  }
1621
 
1622
+ public static function check_is_banned( $user_id, $group_id ) {
1623
  global $wpdb, $bp;
1624
 
1625
  if ( empty( $user_id ) )
1637
  * @param int $group_id
1638
  * @since BuddyPress (1.2.6)
1639
  */
1640
+ public static function check_is_creator( $user_id, $group_id ) {
1641
  global $bp, $wpdb;
1642
 
1643
  if ( empty( $user_id ) )
1646
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name} WHERE creator_id = %d AND id = %d", $user_id, $group_id ) );
1647
  }
1648
 
1649
+ public static function check_for_membership_request( $user_id, $group_id ) {
1650
  global $wpdb, $bp;
1651
 
1652
  if ( empty( $user_id ) )
1655
  return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) );
1656
  }
1657
 
1658
+ public static function get_random_groups( $user_id = 0, $total_groups = 5 ) {
1659
  global $wpdb, $bp;
1660
 
1661
  // If the user is logged in and viewing their random groups, we can show hidden and private groups
1666
  }
1667
  }
1668
 
1669
+ public static function get_group_member_ids( $group_id ) {
1670
  global $bp, $wpdb;
1671
 
1672
  return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) );
1673
  }
1674
 
1675
+ public static function get_group_administrator_ids( $group_id ) {
1676
  global $bp, $wpdb;
1677
 
1678
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) );
1679
  }
1680
 
1681
+ public static function get_group_moderator_ids( $group_id ) {
1682
  global $bp, $wpdb;
1683
 
1684
  return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) );
1685
  }
1686
 
1687
+ public static function get_all_membership_request_user_ids( $group_id ) {
1688
  global $bp, $wpdb;
1689
 
1690
  return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
1691
  }
1692
 
1693
+ public static function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false ) {
1694
  global $bp, $wpdb;
1695
 
1696
  _deprecated_function( __METHOD__, '1.8', 'BP_Group_Member_Query' );
1749
  return array( 'members' => $members, 'count' => $total_member_count );
1750
  }
1751
 
1752
+ public static function delete_all( $group_id ) {
1753
  global $wpdb, $bp;
1754
 
1755
  return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
1764
  * @since BuddyPress (1.0)
1765
  * @uses BP_Groups_Member
1766
  */
1767
+ public static function delete_all_for_user( $user_id ) {
1768
  global $bp, $wpdb;
1769
 
1770
  // Get all the group ids for the current user's groups and update counts
2289
 
2290
  // The create screen requires an additional nonce field
2291
  // due to a quirk in the way the templates are built
2292
+ wp_nonce_field( 'groups_create_save_' . bp_get_groups_current_create_step(), '_wpnonce', false );
2293
  }
2294
 
2295
  /**
bp-groups/bp-groups-functions.php CHANGED
@@ -202,10 +202,6 @@ function groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_
202
  function groups_delete_group( $group_id ) {
203
  global $bp;
204
 
205
- // Check the user is the group admin.
206
- if ( ! bp_is_item_admin() )
207
- return false;
208
-
209
  do_action( 'groups_before_delete_group', $group_id );
210
 
211
  // Get the group object
@@ -303,7 +299,7 @@ function groups_leave_group( $group_id, $user_id = 0 ) {
303
  * joined_group activity so users cannot flood the activity stream by
304
  * joining/leaving the group in quick succession.
305
  */
306
- if ( bp_is_active( 'activity' ) && gmmktime() <= strtotime( '+5 minutes', (int)strtotime( $membership->date_modified ) ) )
307
  bp_activity_delete( array( 'component' => $bp->groups->id, 'type' => 'joined_group', 'user_id' => $user_id, 'item_id' => $group_id ) );
308
 
309
  bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
@@ -654,7 +650,12 @@ function groups_invite_user( $args = '' ) {
654
  if ( empty( $user_id ) || empty( $group_id ) )
655
  return false;
656
 
657
- if ( !groups_is_user_member( $user_id, $group_id ) && !groups_check_user_has_invite( $user_id, $group_id, 'all' ) ) {
 
 
 
 
 
658
  $invite = new BP_Groups_Member;
659
  $invite->group_id = $group_id;
660
  $invite->user_id = $user_id;
@@ -691,7 +692,6 @@ function groups_uninvite_user( $user_id, $group_id ) {
691
  * @return bool True when the user is a member of the group, otherwise false
692
  */
693
  function groups_accept_invite( $user_id, $group_id ) {
694
- global $bp;
695
 
696
  // If the user is already a member (because BP at one point allowed two invitations to
697
  // slip through), delete all existing invitations/requests and return true
@@ -718,7 +718,7 @@ function groups_accept_invite( $user_id, $group_id ) {
718
  // Modify group meta
719
  groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
720
 
721
- bp_core_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
722
 
723
  do_action( 'groups_accept_invite', $user_id, $group_id );
724
  return true;
@@ -734,12 +734,12 @@ function groups_reject_invite( $user_id, $group_id ) {
734
  }
735
 
736
  function groups_delete_invite( $user_id, $group_id ) {
737
- global $bp;
738
 
739
  $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
740
 
741
- if ( $delete )
742
- bp_core_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
 
743
 
744
  return $delete;
745
  }
@@ -872,6 +872,12 @@ function groups_send_membership_request( $requesting_user_id, $group_id ) {
872
  if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) )
873
  return false;
874
 
 
 
 
 
 
 
875
  $requesting_user = new BP_Groups_Member;
876
  $requesting_user->group_id = $group_id;
877
  $requesting_user->user_id = $requesting_user_id;
@@ -1044,8 +1050,9 @@ function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
1044
 
1045
  $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
1046
 
1047
- if ( is_string( $meta_value ) )
1048
- $meta_value = stripslashes( esc_sql( $meta_value ) );
 
1049
 
1050
  $meta_value = maybe_serialize( $meta_value );
1051
 
202
  function groups_delete_group( $group_id ) {
203
  global $bp;
204
 
 
 
 
 
205
  do_action( 'groups_before_delete_group', $group_id );
206
 
207
  // Get the group object
299
  * joined_group activity so users cannot flood the activity stream by
300
  * joining/leaving the group in quick succession.
301
  */
302
+ if ( bp_is_active( 'activity' ) && time() <= strtotime( '+5 minutes', (int)strtotime( $membership->date_modified ) ) )
303
  bp_activity_delete( array( 'component' => $bp->groups->id, 'type' => 'joined_group', 'user_id' => $user_id, 'item_id' => $group_id ) );
304
 
305
  bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
650
  if ( empty( $user_id ) || empty( $group_id ) )
651
  return false;
652
 
653
+ // if the user has already requested membership, accept the request
654
+ if ( $membership_id = groups_check_for_membership_request( $user_id, $group_id ) ) {
655
+ groups_accept_membership_request( $membership_id, $user_id, $group_id );
656
+
657
+ // Otherwise, create a new invitation
658
+ } else if ( ! groups_is_user_member( $user_id, $group_id ) && ! groups_check_user_has_invite( $user_id, $group_id, 'all' ) ) {
659
  $invite = new BP_Groups_Member;
660
  $invite->group_id = $group_id;
661
  $invite->user_id = $user_id;
692
  * @return bool True when the user is a member of the group, otherwise false
693
  */
694
  function groups_accept_invite( $user_id, $group_id ) {
 
695
 
696
  // If the user is already a member (because BP at one point allowed two invitations to
697
  // slip through), delete all existing invitations/requests and return true
718
  // Modify group meta
719
  groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
720
 
721
+ bp_core_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
722
 
723
  do_action( 'groups_accept_invite', $user_id, $group_id );
724
  return true;
734
  }
735
 
736
  function groups_delete_invite( $user_id, $group_id ) {
 
737
 
738
  $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
739
 
740
+ if ( !empty( $delete ) ) {
741
+ bp_core_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
742
+ }
743
 
744
  return $delete;
745
  }
872
  if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) )
873
  return false;
874
 
875
+ // Check if the user is already invited - if so, simply accept invite
876
+ if ( groups_check_user_has_invite( $requesting_user_id, $group_id ) ) {
877
+ groups_accept_invite( $requesting_user_id, $group_id );
878
+ return true;
879
+ }
880
+
881
  $requesting_user = new BP_Groups_Member;
882
  $requesting_user->group_id = $group_id;
883
  $requesting_user->user_id = $requesting_user_id;
1050
 
1051
  $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
1052
 
1053
+ if ( is_string( $meta_value ) ) {
1054
+ $meta_value = stripslashes( $meta_value );
1055
+ }
1056
 
1057
  $meta_value = maybe_serialize( $meta_value );
1058
 
bp-groups/bp-groups-loader.php CHANGED
@@ -81,7 +81,10 @@ class BP_Groups_Component extends BP_Component {
81
  parent::start(
82
  'groups',
83
  __( 'User Groups', 'buddypress' ),
84
- BP_PLUGIN_DIR
 
 
 
85
  );
86
  }
87
 
@@ -118,10 +121,9 @@ class BP_Groups_Component extends BP_Component {
118
  * backwards compatibility.
119
  *
120
  * @since BuddyPress (1.5)
121
- * @global BuddyPress $bp The one true BuddyPress instance
122
  */
123
  public function setup_globals( $args = array() ) {
124
- global $bp;
125
 
126
  // Define a slug, if necessary
127
  if ( !defined( 'BP_GROUPS_SLUG' ) )
@@ -136,7 +138,7 @@ class BP_Groups_Component extends BP_Component {
136
 
137
  // All globals for groups component.
138
  // Note that global_tables is included in this array.
139
- $globals = array(
140
  'slug' => BP_GROUPS_SLUG,
141
  'root_slug' => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG,
142
  'has_directory' => true,
@@ -145,7 +147,7 @@ class BP_Groups_Component extends BP_Component {
145
  'global_tables' => $global_tables
146
  );
147
 
148
- parent::setup_globals( $globals );
149
 
150
  /** Single Group Globals **********************************************/
151
 
@@ -338,12 +340,9 @@ class BP_Groups_Component extends BP_Component {
338
  */
339
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
340
 
341
- // Define local variables
342
- $sub_nav = array();
343
-
344
  // Add 'Groups' to the main navigation
345
  $main_nav = array(
346
- 'name' => sprintf( __( 'Groups <span>%d</span>', 'buddypress' ), bp_get_total_group_count_for_user() ),
347
  'slug' => $this->slug,
348
  'position' => 70,
349
  'screen_function' => 'groups_screen_my_groups',
@@ -416,13 +415,17 @@ class BP_Groups_Component extends BP_Component {
416
  'item_css_id' => 'home'
417
  );
418
 
419
- // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
 
 
420
  if ( is_user_logged_in() &&
421
- !bp_current_user_can( 'bp_moderate' ) &&
422
- !$this->current_group->is_user_member &&
423
- !groups_check_for_membership_request( bp_loggedin_user_id(), $this->current_group->id ) &&
424
- $this->current_group->status == 'private'
 
425
  ) {
 
426
  $sub_nav[] = array(
427
  'name' => __( 'Request Membership', 'buddypress' ),
428
  'slug' => 'request-membership',
@@ -488,22 +491,18 @@ class BP_Groups_Component extends BP_Component {
488
  parent::setup_nav( $main_nav, $sub_nav );
489
  }
490
 
491
- if ( isset( $this->current_group->user_has_access ) )
492
  do_action( 'groups_setup_nav', $this->current_group->user_has_access );
493
- else
494
  do_action( 'groups_setup_nav');
 
495
  }
496
 
497
  /**
498
  * Set up the Toolbar
499
- *
500
- * @global BuddyPress $bp The one true BuddyPress instance
501
  */
502
  public function setup_admin_bar( $wp_admin_nav = array() ) {
503
- global $bp;
504
-
505
- // Prevent debug notices
506
- $wp_admin_nav = array();
507
 
508
  // Menus for logged in user
509
  if ( is_user_logged_in() ) {
@@ -562,20 +561,16 @@ class BP_Groups_Component extends BP_Component {
562
 
563
  /**
564
  * Sets up the title for pages and <title>
565
- *
566
- * @global BuddyPress $bp The one true BuddyPress instance
567
  */
568
  function setup_title() {
569
- global $bp;
570
 
571
  if ( bp_is_groups_component() ) {
572
 
573
  if ( bp_is_my_profile() && !bp_is_single_item() ) {
574
-
575
  $bp->bp_options_title = __( 'Memberships', 'buddypress' );
576
 
577
  } else if ( !bp_is_my_profile() && !bp_is_single_item() ) {
578
-
579
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
580
  'item_id' => bp_displayed_user_id(),
581
  'type' => 'thumb',
@@ -594,8 +589,9 @@ class BP_Groups_Component extends BP_Component {
594
  'avatar_dir' => 'group-avatars',
595
  'alt' => __( 'Group Avatar', 'buddypress' )
596
  ) );
 
597
  if ( empty( $bp->bp_options_avatar ) ) {
598
- $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
599
  }
600
  }
601
  }
@@ -606,8 +602,6 @@ class BP_Groups_Component extends BP_Component {
606
 
607
 
608
  function bp_setup_groups() {
609
- global $bp;
610
-
611
- $bp->groups = new BP_Groups_Component();
612
  }
613
  add_action( 'bp_setup_components', 'bp_setup_groups', 6 );
81
  parent::start(
82
  'groups',
83
  __( 'User Groups', 'buddypress' ),
84
+ BP_PLUGIN_DIR,
85
+ array(
86
+ 'adminbar_myaccount_order' => 70
87
+ )
88
  );
89
  }
90
 
121
  * backwards compatibility.
122
  *
123
  * @since BuddyPress (1.5)
 
124
  */
125
  public function setup_globals( $args = array() ) {
126
+ $bp = buddypress();
127
 
128
  // Define a slug, if necessary
129
  if ( !defined( 'BP_GROUPS_SLUG' ) )
138
 
139
  // All globals for groups component.
140
  // Note that global_tables is included in this array.
141
+ $args = array(
142
  'slug' => BP_GROUPS_SLUG,
143
  'root_slug' => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG,
144
  'has_directory' => true,
147
  'global_tables' => $global_tables
148
  );
149
 
150
+ parent::setup_globals( $args );
151
 
152
  /** Single Group Globals **********************************************/
153
 
340
  */
341
  public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
342
 
 
 
 
343
  // Add 'Groups' to the main navigation
344
  $main_nav = array(
345
+ 'name' => sprintf( __( 'Groups <span>%s</span>', 'buddypress' ), bp_get_total_group_count_for_user() ),
346
  'slug' => $this->slug,
347
  'position' => 70,
348
  'screen_function' => 'groups_screen_my_groups',
415
  'item_css_id' => 'home'
416
  );
417
 
418
+ // If this is a private group, and the user is not a
419
+ // member and does not have an outstanding invitation,
420
+ // show a "Request Membership" nav item.
421
  if ( is_user_logged_in() &&
422
+ ! bp_current_user_can( 'bp_moderate' ) &&
423
+ ! $this->current_group->is_user_member &&
424
+ ! groups_check_for_membership_request( bp_loggedin_user_id(), $this->current_group->id ) &&
425
+ $this->current_group->status == 'private' &&
426
+ ! groups_check_user_has_invite( bp_loggedin_user_id(), $this->current_group->id )
427
  ) {
428
+
429
  $sub_nav[] = array(
430
  'name' => __( 'Request Membership', 'buddypress' ),
431
  'slug' => 'request-membership',
491
  parent::setup_nav( $main_nav, $sub_nav );
492
  }
493
 
494
+ if ( isset( $this->current_group->user_has_access ) ) {
495
  do_action( 'groups_setup_nav', $this->current_group->user_has_access );
496
+ } else {
497
  do_action( 'groups_setup_nav');
498
+ }
499
  }
500
 
501
  /**
502
  * Set up the Toolbar
 
 
503
  */
504
  public function setup_admin_bar( $wp_admin_nav = array() ) {
505
+ $bp = buddypress();
 
 
 
506
 
507
  // Menus for logged in user
508
  if ( is_user_logged_in() ) {
561
 
562
  /**
563
  * Sets up the title for pages and <title>
 
 
564
  */
565
  function setup_title() {
566
+ $bp = buddypress();
567
 
568
  if ( bp_is_groups_component() ) {
569
 
570
  if ( bp_is_my_profile() && !bp_is_single_item() ) {
 
571
  $bp->bp_options_title = __( 'Memberships', 'buddypress' );
572
 
573
  } else if ( !bp_is_my_profile() && !bp_is_single_item() ) {
 
574
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
575
  'item_id' => bp_displayed_user_id(),
576
  'type' => 'thumb',
589
  'avatar_dir' => 'group-avatars',
590
  'alt' => __( 'Group Avatar', 'buddypress' )
591
  ) );
592
+
593
  if ( empty( $bp->bp_options_avatar ) ) {
594
+ $bp->bp_options_avatar = bp_group_current_avatar();
595
  }
596
  }
597
  }
602
 
603
 
604
  function bp_setup_groups() {
605
+ buddypress()->groups = new BP_Groups_Component();
 
 
606
  }
607
  add_action( 'bp_setup_components', 'bp_setup_groups', 6 );
bp-groups/bp-groups-screens.php CHANGED
@@ -31,10 +31,10 @@ function groups_screen_my_groups() {
31
 
32
  // Delete group request notifications for the user
33
  if ( isset( $_GET['n'] ) ) {
34
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
35
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
36
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod' );
37
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin' );
38
  }
39
 
40
  do_action( 'groups_screen_my_groups' );
@@ -65,7 +65,13 @@ function groups_screen_group_invites() {
65
  ) );
66
  }
67
 
68
- bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action() ) );
 
 
 
 
 
 
69
 
70
  } else if ( bp_is_action_variable( 'reject' ) && is_numeric( $group_id ) ) {
71
  // Check the nonce
@@ -78,11 +84,17 @@ function groups_screen_group_invites() {
78
  bp_core_add_message( __( 'Group invite rejected', 'buddypress' ) );
79
  }
80
 
81
- bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action() ) );
 
 
 
 
 
 
82
  }
83
 
84
  // Remove notifications
85
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), 'groups', 'group_invite' );
86
 
87
  do_action( 'groups_screen_group_invites', $group_id );
88
 
@@ -97,10 +109,10 @@ function groups_screen_group_home() {
97
  $bp = buddypress();
98
 
99
  if ( isset( $_GET['n'] ) ) {
100
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
101
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
102
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod' );
103
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin' );
104
  }
105
 
106
  do_action( 'groups_screen_group_home' );
@@ -467,6 +479,15 @@ function groups_screen_group_request_membership() {
467
  if ( 'private' != $bp->groups->current_group->status )
468
  return false;
469
 
 
 
 
 
 
 
 
 
 
470
  // If the user has submitted a request, send it.
471
  if ( isset( $_POST['group-request-send']) ) {
472
 
@@ -563,7 +584,7 @@ function groups_screen_group_admin_settings() {
563
 
564
  // Checked against a whitelist for security
565
  $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) );
566
- $invite_status = in_array( $_POST['group-invite-status'], (array) $allowed_invite_status ) ? $_POST['group-invite-status'] : 'members';
567
 
568
  // Check the nonce
569
  if ( !check_admin_referer( 'groups_edit_group_settings' ) )
@@ -792,7 +813,7 @@ function groups_screen_group_admin_requests() {
792
  return false;
793
 
794
  // Remove any screen notifications
795
- bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request' );
796
 
797
  $request_action = (string)bp_action_variable( 1 );
798
  $membership_id = (int)bp_action_variable( 2 );
@@ -1048,7 +1069,7 @@ class BP_Groups_Theme_Compat {
1048
  * @since BuddyPress (1.7)
1049
  */
1050
  public function directory_content() {
1051
- bp_buffer_template_part( 'groups/index' );
1052
  }
1053
 
1054
  /** Create ****************************************************************/
@@ -1109,7 +1130,7 @@ class BP_Groups_Theme_Compat {
1109
  * @since BuddyPress (1.7)
1110
  */
1111
  public function create_content() {
1112
- bp_buffer_template_part( 'groups/create' );
1113
  }
1114
 
1115
  /** Single ****************************************************************/
@@ -1169,7 +1190,7 @@ class BP_Groups_Theme_Compat {
1169
  * @since BuddyPress (1.7)
1170
  */
1171
  public function single_content() {
1172
- bp_buffer_template_part( 'groups/single/home' );
1173
  }
1174
  }
1175
  new BP_Groups_Theme_Compat();
31
 
32
  // Delete group request notifications for the user
33
  if ( isset( $_GET['n'] ) ) {
34
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
35
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
36
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod' );
37
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin' );
38
  }
39
 
40
  do_action( 'groups_screen_my_groups' );
65
  ) );
66
  }
67
 
68
+ if ( isset( $_GET['redirect_to'] ) ) {
69
+ $redirect_to = urldecode( $_GET['redirect_to'] );
70
+ } else {
71
+ $redirect_to = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action() );
72
+ }
73
+
74
+ bp_core_redirect( $redirect_to );
75
 
76
  } else if ( bp_is_action_variable( 'reject' ) && is_numeric( $group_id ) ) {
77
  // Check the nonce
84
  bp_core_add_message( __( 'Group invite rejected', 'buddypress' ) );
85
  }
86
 
87
+ if ( isset( $_GET['redirect_to'] ) ) {
88
+ $redirect_to = urldecode( $_GET['redirect_to'] );
89
+ } else {
90
+ $redirect_to = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action() );
91
+ }
92
+
93
+ bp_core_redirect( $redirect_to );
94
  }
95
 
96
  // Remove notifications
97
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );
98
 
99
  do_action( 'groups_screen_group_invites', $group_id );
100
 
109
  $bp = buddypress();
110
 
111
  if ( isset( $_GET['n'] ) ) {
112
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
113
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
114
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod' );
115
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin' );
116
  }
117
 
118
  do_action( 'groups_screen_group_home' );
479
  if ( 'private' != $bp->groups->current_group->status )
480
  return false;
481
 
482
+ // If the user is already invited, accept invitation
483
+ if ( groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
484
+ if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
485
+ bp_core_add_message( __( 'Group invite accepted', 'buddypress' ) );
486
+ else
487
+ bp_core_add_message( __( 'There was an error accepting the group invitation, please try again.', 'buddypress' ), 'error' );
488
+ bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
489
+ }
490
+
491
  // If the user has submitted a request, send it.
492
  if ( isset( $_POST['group-request-send']) ) {
493
 
584
 
585
  // Checked against a whitelist for security
586
  $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) );
587
+ $invite_status = isset( $_POST['group-invite-status'] ) && in_array( $_POST['group-invite-status'], (array) $allowed_invite_status ) ? $_POST['group-invite-status'] : 'members';
588
 
589
  // Check the nonce
590
  if ( !check_admin_referer( 'groups_edit_group_settings' ) )
813
  return false;
814
 
815
  // Remove any screen notifications
816
+ bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request' );
817
 
818
  $request_action = (string)bp_action_variable( 1 );
819
  $membership_id = (int)bp_action_variable( 2 );
1069
  * @since BuddyPress (1.7)
1070
  */
1071
  public function directory_content() {
1072
+ return bp_buffer_template_part( 'groups/index', null, false );
1073
  }
1074
 
1075
  /** Create ****************************************************************/
1130
  * @since BuddyPress (1.7)
1131
  */
1132
  public function create_content() {
1133
+ return bp_buffer_template_part( 'groups/create', null, false );
1134
  }
1135
 
1136
  /** Single ****************************************************************/
1190
  * @since BuddyPress (1.7)
1191
  */
1192
  public function single_content() {
1193
+ return bp_buffer_template_part( 'groups/single/home', null, false );
1194
  }
1195
  }
1196
  new BP_Groups_Theme_Compat();
bp-groups/bp-groups-template.php CHANGED
@@ -521,7 +521,7 @@ function bp_group_avatar( $args = '' ) {
521
 
522
  /* Fetch the avatar from the folder, if not provide backwards compat. */
523
  if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'title' => $groups_template->group->name, 'alt' => $alt ) ) )
524
- $avatar = '<img src="' . esc_attr( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />';
525
 
526
  return apply_filters( 'bp_get_group_avatar', $avatar );
527
  }
@@ -884,14 +884,14 @@ function bp_group_search_form() {
884
  $label = __('Filter Groups', 'buddypress');
885
  $name = 'group-filter-box';
886
 
887
- ?>
888
- <form action="<?php echo $action ?>" id="group-search-form" method="post">
889
- <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?></label>
890
- <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> />
891
 
892
- <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?>
893
- </form>
894
- <?php
 
895
  }
896
 
897
  function bp_group_show_no_groups_message() {
@@ -929,7 +929,7 @@ function bp_groups_pagination_count() {
929
  $to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) );
930
  $total = bp_core_number_format( $groups_template->total_group_count );
931
 
932
- return apply_filters( 'bp_get_groups_pagination_count', sprintf( __( 'Viewing group %1$s to %2$s (of %3$s groups)', 'buddypress' ), $from_num, $to_num, $total ) );
933
  }
934
 
935
  function bp_groups_auto_join() {
@@ -1780,23 +1780,25 @@ function bp_group_join_button( $group = false ) {
1780
 
1781
  case 'private' :
1782
 
1783
- // Member has not requested membership yet
1784
- if ( !bp_group_has_requested_membership( $group ) ) {
 
1785
  $button = array(
1786
- 'id' => 'request_membership',
1787
  'component' => 'groups',
1788
  'must_be_logged_in' => true,
1789
  'block_self' => false,
1790
  'wrapper_class' => 'group-button ' . $group->status,
1791
  'wrapper_id' => 'groupbutton-' . $group->id,
1792
- 'link_href' => wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ),
1793
- 'link_text' => __( 'Request Membership', 'buddypress' ),
1794
- 'link_title' => __( 'Request Membership', 'buddypress' ),
1795
- 'link_class' => 'group-button request-membership',
1796
  );
1797
 
1798
- // Member has requested membership already
1799
- } else {
 
1800
  $button = array(
1801
  'id' => 'membership_requested',
1802
  'component' => 'groups',
@@ -1809,6 +1811,22 @@ function bp_group_join_button( $group = false ) {
1809
  'link_title' => __( 'Request Sent', 'buddypress' ),
1810
  'link_class' => 'group-button pending membership-requested',
1811
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1812
  }
1813
 
1814
  break;
@@ -1878,6 +1896,7 @@ function bp_total_group_count_for_user( $user_id = 0 ) {
1878
  function bp_get_total_group_count_for_user( $user_id = 0 ) {
1879
  return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ), $user_id );
1880
  }
 
1881
 
1882
 
1883
  /***************************************************************************
@@ -2150,7 +2169,7 @@ function bp_group_member_pagination_count() {
2150
  $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
2151
  $total = bp_core_number_format( $members_template->total_member_count );
2152
 
2153
- return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %1$s to %2$s (of %3$s members)', 'buddypress' ), $from_num, $to_num, $total ) );
2154
  }
2155
 
2156
  function bp_group_member_admin_pagination() {
@@ -2204,8 +2223,10 @@ function bp_group_creation_tabs() {
2204
  if ( !is_array( $bp->groups->group_creation_steps ) )
2205
  return false;
2206
 
2207
- if ( !bp_get_groups_current_create_step() )
2208
- $bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
 
 
2209
 
2210
  $counter = 1;
2211
 
@@ -2233,8 +2254,10 @@ function bp_group_creation_form_action() {
2233
  function bp_get_group_creation_form_action() {
2234
  global $bp;
2235
 
2236
- if ( !bp_action_variable( 1 ) )
2237
- $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
 
 
2238
 
2239
  return apply_filters( 'bp_get_group_creation_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_action_variable( 1 ) ) );
2240
  }
@@ -2247,7 +2270,8 @@ function bp_is_group_creation_step( $step_slug ) {
2247
  return false;
2248
 
2249
  /* If this the first step, we can just accept and return true */
2250
- if ( !bp_action_variable( 1 ) && array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug )
 
2251
  return true;
2252
 
2253
  /* Before allowing a user to see a group creation step we must make sure previous steps are completed */
@@ -2289,7 +2313,8 @@ function bp_are_previous_group_creation_steps_complete( $step_slug ) {
2289
  global $bp;
2290
 
2291
  /* If this is the first group creation step, return true */
2292
- if ( array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug )
 
2293
  return true;
2294
 
2295
  reset( $bp->groups->group_creation_steps );
@@ -2433,7 +2458,8 @@ function bp_groups_current_create_step() {
2433
  function bp_is_last_group_creation_step() {
2434
  global $bp;
2435
 
2436
- $last_step = array_pop( array_keys( $bp->groups->group_creation_steps ) );
 
2437
 
2438
  if ( $last_step == bp_get_groups_current_create_step() )
2439
  return true;
@@ -2444,7 +2470,8 @@ function bp_is_last_group_creation_step() {
2444
  function bp_is_first_group_creation_step() {
2445
  global $bp;
2446
 
2447
- $first_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
 
2448
 
2449
  if ( $first_step == bp_get_groups_current_create_step() )
2450
  return true;
@@ -2496,14 +2523,15 @@ function bp_new_group_invite_friend_list() {
2496
  function bp_directory_groups_search_form() {
2497
 
2498
  $default_search_value = bp_get_search_default_text( 'groups' );
2499
- $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>
2500
 
2501
- <form action="" method="get" id="search-groups-form">
2502
- <label><input type="text" name="s" id="groups_search" placeholder="<?php echo esc_attr( $search_value ) ?>" /></label>
2503
- <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
2504
- </form>
 
 
2505
 
2506
- <?php
2507
  }
2508
 
2509
  /**
@@ -2603,11 +2631,11 @@ function bp_group_current_avatar() {
2603
 
2604
  if ( $bp->groups->current_group->avatar_full ) { ?>
2605
 
2606
- <img src="<?php echo esc_attr( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
2607
 
2608
  <?php } else { ?>
2609
 
2610
- <img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
2611
 
2612
  <?php }
2613
  }
521
 
522
  /* Fetch the avatar from the folder, if not provide backwards compat. */
523
  if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'title' => $groups_template->group->name, 'alt' => $alt ) ) )
524
+ $avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />';
525
 
526
  return apply_filters( 'bp_get_group_avatar', $avatar );
527
  }
884
  $label = __('Filter Groups', 'buddypress');
885
  $name = 'group-filter-box';
886
 
887
+ $search_form_html = '<form action="' . $action . '" id="group-search-form" method="post">
888
+ <label for="'. $name .'" id="'. $name .'-label">'. $label .'</label>
889
+ <input type="search" name="'. $name . '" id="'. $name .'" value="'. $value .'"'. $disabled .' />
 
890
 
891
+ '. wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter', true, false ) .'
892
+ </form>';
893
+
894
+ echo apply_filters( 'bp_group_search_form', $search_form_html );
895
  }
896
 
897
  function bp_group_show_no_groups_message() {
929
  $to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) );
930
  $total = bp_core_number_format( $groups_template->total_group_count );
931
 
932
+ return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing group %1$s to %2$s (of %3$s group)', 'Viewing group %1$s to %2$s (of %3$s groups)', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
933
  }
934
 
935
  function bp_groups_auto_join() {
1780
 
1781
  case 'private' :
1782
 
1783
+ // Member has outstanding invitation -
1784
+ // show an "Accept Invitation" button
1785
+ if ( $group->is_invited ) {
1786
  $button = array(
1787
+ 'id' => 'accept_invite',
1788
  'component' => 'groups',
1789
  'must_be_logged_in' => true,
1790
  'block_self' => false,
1791
  'wrapper_class' => 'group-button ' . $group->status,
1792
  'wrapper_id' => 'groupbutton-' . $group->id,
1793
+ 'link_href' => add_query_arg( 'redirect_to', bp_get_group_permalink( $group ), bp_get_group_accept_invite_link( $group ) ),
1794
+ 'link_text' => __( 'Accept Invitation', 'buddypress' ),
1795
+ 'link_title' => __( 'Accept Invitation', 'buddypress' ),
1796
+ 'link_class' => 'group-button accept-invite',
1797
  );
1798
 
1799
+ // Member has requested membership but request is pending -
1800
+ // show a "Request Sent" button
1801
+ } elseif ( $group->is_pending ) {
1802
  $button = array(
1803
  'id' => 'membership_requested',
1804
  'component' => 'groups',
1811
  'link_title' => __( 'Request Sent', 'buddypress' ),
1812
  'link_class' => 'group-button pending membership-requested',
1813
  );
1814
+
1815
+ // Member has not requested membership yet -
1816
+ // show a "Request Membership" button
1817
+ } else {
1818
+ $button = array(
1819
+ 'id' => 'request_membership',
1820
+ 'component' => 'groups',
1821
+ 'must_be_logged_in' => true,
1822
+ 'block_self' => false,
1823
+ 'wrapper_class' => 'group-button ' . $group->status,
1824
+ 'wrapper_id' => 'groupbutton-' . $group->id,
1825
+ 'link_href' => wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ),
1826
+ 'link_text' => __( 'Request Membership', 'buddypress' ),
1827
+ 'link_title' => __( 'Request Membership', 'buddypress' ),
1828
+ 'link_class' => 'group-button request-membership',
1829
+ );
1830
  }
1831
 
1832
  break;
1896
  function bp_get_total_group_count_for_user( $user_id = 0 ) {
1897
  return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ), $user_id );
1898
  }
1899
+ add_filter( 'bp_get_total_group_count_for_user', 'bp_core_number_format' );
1900
 
1901
 
1902
  /***************************************************************************
2169
  $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
2170
  $total = bp_core_number_format( $members_template->total_member_count );
2171
 
2172
+ return apply_filters( 'bp_get_group_member_pagination_count', sprintf( _n( 'Viewing member %1$s to %2$s (of %3$s member)', 'Viewing members %1$s to %2$s (of %3$s members)', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
2173
  }
2174
 
2175
  function bp_group_member_admin_pagination() {
2223
  if ( !is_array( $bp->groups->group_creation_steps ) )
2224
  return false;
2225
 
2226
+ if ( !bp_get_groups_current_create_step() ) {
2227
+ $keys = array_keys( $bp->groups->group_creation_steps );
2228
+ $bp->groups->current_create_step = array_shift( $keys );
2229
+ }
2230
 
2231
  $counter = 1;
2232
 
2254
  function bp_get_group_creation_form_action() {
2255
  global $bp;
2256
 
2257
+ if ( !bp_action_variable( 1 ) ) {
2258
+ $keys = array_keys( $bp->groups->group_creation_steps );
2259
+ $bp->action_variables[1] = array_shift( $keys );
2260
+ }
2261
 
2262
  return apply_filters( 'bp_get_group_creation_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_action_variable( 1 ) ) );
2263
  }
2270
  return false;
2271
 
2272
  /* If this the first step, we can just accept and return true */
2273
+ $keys = array_keys( $bp->groups->group_creation_steps );
2274
+ if ( !bp_action_variable( 1 ) && array_shift( $keys ) == $step_slug )
2275
  return true;
2276
 
2277
  /* Before allowing a user to see a group creation step we must make sure previous steps are completed */
2313
  global $bp;
2314
 
2315
  /* If this is the first group creation step, return true */
2316
+ $keys = array_keys( $bp->groups->group_creation_steps );
2317
+ if ( array_shift( $keys ) == $step_slug )
2318
  return true;
2319
 
2320
  reset( $bp->groups->group_creation_steps );
2458
  function bp_is_last_group_creation_step() {
2459
  global $bp;
2460
 
2461
+ $keys = array_keys( $bp->groups->group_creation_steps );
2462
+ $last_step = array_pop( $keys );
2463
 
2464
  if ( $last_step == bp_get_groups_current_create_step() )
2465
  return true;
2470
  function bp_is_first_group_creation_step() {
2471
  global $bp;
2472
 
2473
+ $keys = array_keys( $bp->groups->group_creation_steps );
2474
+ $first_step = array_shift( $keys );
2475
 
2476
  if ( $first_step == bp_get_groups_current_create_step() )
2477
  return true;
2523
  function bp_directory_groups_search_form() {
2524
 
2525
  $default_search_value = bp_get_search_default_text( 'groups' );
2526
+ $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
2527
 
2528
+ $search_form_html = '<form action="" method="get" id="search-groups-form">
2529
+ <label><input type="text" name="s" id="groups_search" placeholder="'. esc_attr( $search_value ) .'" /></label>
2530
+ <input type="submit" id="groups_search_submit" name="groups_search_submit" value="'. __( 'Search', 'buddypress' ) .'" />
2531
+ </form>';
2532
+
2533
+ echo apply_filters( 'bp_directory_groups_search_form', $search_form_html );
2534
 
 
2535
  }
2536
 
2537
  /**
2631
 
2632
  if ( $bp->groups->current_group->avatar_full ) { ?>
2633
 
2634
+ <img src="<?php echo esc_url( $bp->groups->current_group->avatar_full ); ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
2635
 
2636
  <?php } else { ?>
2637
 
2638
+ <img src="<?php echo esc_url( $bp->groups->image_base . '/none.gif' ); ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
2639
 
2640
  <?php }
2641
  }
bp-groups/bp-groups-widgets.php CHANGED
@@ -19,10 +19,6 @@ add_action( 'bp_register_widgets', 'groups_register_widgets' );
19
  /*** GROUPS WIDGET *****************/
20
 
21
  class BP_Groups_Widget extends WP_Widget {
22
- function bp_groups_widget() {
23
- $this->_construct();
24
- }
25
-
26
  function __construct() {
27
  $widget_ops = array(
28
  'description' => __( 'A dynamic list of recently active, popular, and newest groups', 'buddypress' ),
@@ -36,6 +32,15 @@ class BP_Groups_Widget extends WP_Widget {
36
  }
37
  }
38
 
 
 
 
 
 
 
 
 
 
39
  function widget( $args, $instance ) {
40
  $user_id = apply_filters( 'bp_group_widget_user_id', '0' );
41
 
@@ -64,7 +69,7 @@ class BP_Groups_Widget extends WP_Widget {
64
 
65
  <ul id="groups-list" class="item-list">
66
  <?php while ( bp_groups() ) : bp_the_group(); ?>
67
- <li>
68
  <div class="item-avatar">
69
  <a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_avatar_thumb() ?></a>
70
  </div>
@@ -167,7 +172,7 @@ function groups_ajax_widget_groups_list() {
167
  if ( bp_has_groups( 'type=' . $type . '&per_page=' . $_POST['max_groups'] . '&max=' . $_POST['max_groups'] ) ) : ?>
168
  <?php echo "0[[SPLIT]]"; ?>
169
  <?php while ( bp_groups() ) : bp_the_group(); ?>
170
- <li>
171
  <div class="item-avatar">
172
  <a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar_thumb() ?></a>
173
  </div>
19
  /*** GROUPS WIDGET *****************/
20
 
21
  class BP_Groups_Widget extends WP_Widget {
 
 
 
 
22
  function __construct() {
23
  $widget_ops = array(
24
  'description' => __( 'A dynamic list of recently active, popular, and newest groups', 'buddypress' ),
32
  }
33
  }
34
 
35
+ /**
36
+ * PHP4 constructor
37
+ *
38
+ * For backward compatibility only
39
+ */
40
+ function bp_groups_widget() {
41
+ $this->_construct();
42
+ }
43
+
44
  function widget( $args, $instance ) {
45
  $user_id = apply_filters( 'bp_group_widget_user_id', '0' );
46
 
69
 
70
  <ul id="groups-list" class="item-list">
71
  <?php while ( bp_groups() ) : bp_the_group(); ?>
72
+ <li <?php bp_group_class(); ?>>
73
  <div class="item-avatar">
74
  <a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_avatar_thumb() ?></a>
75
  </div>
172
  if ( bp_has_groups( 'type=' . $type . '&per_page=' . $_POST['max_groups'] . '&max=' . $_POST['max_groups'] ) ) : ?>
173
  <?php echo "0[[SPLIT]]"; ?>
174
  <?php while ( bp_groups() ) : bp_the_group(); ?>
175
+ <li <?php bp_group_class(); ?>>
176
  <div class="item-avatar">
177
  <a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar_thumb() ?></a>
178
  </div>
bp-languages/buddypress.pot CHANGED
@@ -3,8 +3,8 @@
3
  msgid ""
4
  msgstr ""
5
  "Project-Id-Version: BuddyPress \n"
6
- "Report-Msgid-Bugs-To: http://wppolyglots.wordpress.com\n"
7
- "POT-Creation-Date: 2013-07-27 18:35:29+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -20,66 +20,66 @@ msgstr ""
20
  msgid "There was an error when deleting that activity"
21
  msgstr ""
22
 
23
- #: bp-activity/bp-activity-actions.php:213
24
  msgid "The activity item has been marked as spam and is no longer visible."
25
  msgstr ""
26
 
27
- #: bp-activity/bp-activity-actions.php:262
28
- #: bp-templates/bp-legacy/buddypress-functions.php:621
29
  #: bp-themes/bp-default/_inc/ajax.php:276
30
  msgid "Please enter some content to post."
31
  msgstr ""
32
 
33
- #: bp-activity/bp-activity-actions.php:283
34
  msgid "Update Posted!"
35
  msgstr ""
36
 
37
- #: bp-activity/bp-activity-actions.php:285
38
  msgid "There was an error when posting your update, please try again."
39
  msgstr ""
40
 
41
- #: bp-activity/bp-activity-actions.php:322
42
- #: bp-templates/bp-legacy/buddypress-functions.php:669
43
  #: bp-themes/bp-default/_inc/ajax.php:324
44
  msgid "Please do not leave the comment area blank."
45
  msgstr ""
46
 
47
- #: bp-activity/bp-activity-actions.php:333
48
  msgid "Reply Posted!"
49
  msgstr ""
50
 
51
- #: bp-activity/bp-activity-actions.php:335
52
- #: bp-templates/bp-legacy/buddypress-functions.php:672
53
- #: bp-templates/bp-legacy/buddypress-functions.php:681
54
  #: bp-themes/bp-default/_inc/ajax.php:327
55
  #: bp-themes/bp-default/_inc/ajax.php:336
56
  msgid "There was an error posting that reply, please try again."
57
  msgstr ""
58
 
59
- #: bp-activity/bp-activity-actions.php:367
60
  msgid "Activity marked as favorite."
61
  msgstr ""
62
 
63
- #: bp-activity/bp-activity-actions.php:369
64
  msgid "There was an error marking that activity as a favorite, please try again."
65
  msgstr ""
66
 
67
- #: bp-activity/bp-activity-actions.php:401
68
  msgid "Activity removed as favorite."
69
  msgstr ""
70
 
71
- #: bp-activity/bp-activity-actions.php:403
72
  msgid "There was an error removing that activity as a favorite, please try again."
73
  msgstr ""
74
 
75
  #. translators: Sitewide activity RSS title - "[Site Name] | Site Wide
76
  #. Activity"
77
 
78
- #: bp-activity/bp-activity-actions.php:434
79
  msgid "%s | Site Wide Activity"
80
  msgstr ""
81
 
82
- #: bp-activity/bp-activity-actions.php:437
83
  msgid "Activity feed for the entire site."
84
  msgstr ""
85
 
@@ -88,314 +88,325 @@ msgstr ""
88
  #. translators: Group activity RSS title - "[Site Name] | [Group Name] |
89
  #. Activity"
90
 
91
- #: bp-activity/bp-activity-actions.php:465 bp-groups/bp-groups-actions.php:331
92
  msgid "%1$s | %2$s | Activity"
93
  msgstr ""
94
 
95
- #: bp-activity/bp-activity-actions.php:468
96
  msgid "Activity feed for %s."
97
  msgstr ""
98
 
99
  #. translators: Friends activity RSS title - "[Site Name] | [User Display Name]
100
  #. | Friends Activity"
101
 
102
- #: bp-activity/bp-activity-actions.php:499
103
  msgid "%1$s | %2$s | Friends Activity"
104
  msgstr ""
105
 
106
- #: bp-activity/bp-activity-actions.php:502
107
  msgid "Activity feed for %s's friends."
108
  msgstr ""
109
 
110
  #. translators: Member groups activity RSS title - "[Site Name] | [User Display
111
  #. Name] | Groups Activity"
112
 
113
- #: bp-activity/bp-activity-actions.php:537
114
  msgid "%1$s | %2$s | Group Activity"
115
  msgstr ""
116
 
117
- #: bp-activity/bp-activity-actions.php:540
118
  msgid "Public group activity feed of which %s is a member of."
119
  msgstr ""
120
 
 
 
 
 
 
 
 
 
 
 
 
121
  #. translators: User activity favorites RSS title - "[Site Name] | [User
122
  #. Display Name] | Favorites"
123
 
124
- #: bp-activity/bp-activity-actions.php:608
125
  msgid "%1$s | %2$s | Favorites"
126
  msgstr ""
127
 
128
- #: bp-activity/bp-activity-actions.php:611
129
  msgid "Activity feed of %s's favorites."
130
  msgstr ""
131
 
132
- #: bp-activity/bp-activity-admin.php:35 bp-activity/bp-activity-admin.php:36
133
- #: bp-activity/bp-activity-admin.php:852 bp-activity/bp-activity-admin.php:1167
134
- #: bp-activity/bp-activity-loader.php:118
135
- #: bp-activity/bp-activity-loader.php:246
136
  #: bp-activity/bp-activity-screens.php:284
137
- #: bp-activity/bp-activity-screens.php:451 bp-core/bp-core-admin.php:409
138
  msgid "Activity"
139
  msgstr ""
140
 
141
- #: bp-activity/bp-activity-admin.php:85
142
  msgid "ERROR: Please type a reply."
143
  msgstr ""
144
 
145
- #: bp-activity/bp-activity-admin.php:90
146
  msgid "ERROR: The item you are trying to reply to cannot be found, or it has been deleted."
147
  msgstr ""
148
 
149
- #: bp-activity/bp-activity-admin.php:197 bp-activity/bp-activity-admin.php:244
150
- #: bp-core/admin/bp-core-functions.php:412
151
  #: bp-core/admin/bp-core-functions.php:430
152
- #: bp-core/admin/bp-core-functions.php:449
153
- #: bp-core/admin/bp-core-functions.php:468 bp-groups/bp-groups-admin.php:107
154
- #: bp-groups/bp-groups-admin.php:143
 
155
  msgid "Overview"
156
  msgstr ""
157
 
158
- #: bp-activity/bp-activity-admin.php:199
159
  msgid "You edit activities made on your site similar to the way you edit a comment. This is useful if you need to change which page the activity links to, or when you notice that the author has made a typographical error."
160
  msgstr ""
161
 
162
- #: bp-activity/bp-activity-admin.php:200
163
  msgid "The two big editing areas for the activity title and content are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Primary Item/Secondary Item, Link, Type, Author ID) or to choose a 1- or 2-column layout for this screen."
164
  msgstr ""
165
 
166
- #: bp-activity/bp-activity-admin.php:201
167
  msgid "You can also moderate the activity from this screen using the Status box, where you can also change the timestamp of the activity."
168
  msgstr ""
169
 
170
- #: bp-activity/bp-activity-admin.php:206
171
  msgid "Item, Link, Type"
172
  msgstr ""
173
 
174
- #: bp-activity/bp-activity-admin.php:208
175
  msgid "<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields."
176
  msgstr ""
177
 
178
- #: bp-activity/bp-activity-admin.php:209
179
- msgid "<strong>Link</strong> - Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set."
180
  msgstr ""
181
 
182
- #: bp-activity/bp-activity-admin.php:210
183
  msgid "<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group."
184
  msgstr ""
185
 
186
- #: bp-activity/bp-activity-admin.php:211
187
  msgid "For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side."
188
  msgstr ""
189
 
190
- #: bp-activity/bp-activity-admin.php:216 bp-activity/bp-activity-admin.php:261
191
- #: bp-core/admin/bp-core-functions.php:418
192
  #: bp-core/admin/bp-core-functions.php:436
193
- #: bp-core/admin/bp-core-functions.php:455
194
- #: bp-core/admin/bp-core-functions.php:474 bp-groups/bp-groups-admin.php:115
195
- #: bp-groups/bp-groups-admin.php:159
 
196
  msgid "For more information:"
197
  msgstr ""
198
 
199
- #: bp-activity/bp-activity-admin.php:217
200
  msgid "<a href=\"http://codex.buddypress.org/buddypress-site-administration/managing-activity/\">Managing Activity</a>"
201
  msgstr ""
202
 
203
- #: bp-activity/bp-activity-admin.php:218 bp-activity/bp-activity-admin.php:262
204
- #: bp-core/admin/bp-core-functions.php:420
205
  #: bp-core/admin/bp-core-functions.php:438
206
- #: bp-core/admin/bp-core-functions.php:457
207
- #: bp-core/admin/bp-core-functions.php:476 bp-groups/bp-groups-admin.php:160
 
208
  msgid "<a href=\"http://buddypress.org/support/\">Support Forums</a>"
209
  msgstr ""
210
 
211
- #: bp-activity/bp-activity-admin.php:222
212
  msgctxt "activity admin edit screen"
213
  msgid "Status"
214
  msgstr ""
215
 
216
- #: bp-activity/bp-activity-admin.php:223
217
  msgctxt "activity admin edit screen"
218
  msgid "Primary Item/Secondary Item"
219
  msgstr ""
220
 
221
- #: bp-activity/bp-activity-admin.php:224
222
  msgctxt "activity admin edit screen"
223
  msgid "Link"
224
  msgstr ""
225
 
226
- #: bp-activity/bp-activity-admin.php:225
227
  msgctxt "activity admin edit screen"
228
  msgid "Type"
229
  msgstr ""
230
 
231
- #: bp-activity/bp-activity-admin.php:226
232
  msgctxt "activity admin edit screen"
233
  msgid "Author ID"
234
  msgstr ""
235
 
236
- #: bp-activity/bp-activity-admin.php:239
237
  msgctxt "Activity items per page (screen options)"
238
  msgid "Activity"
239
  msgstr ""
240
 
241
- #: bp-activity/bp-activity-admin.php:246
242
  msgid "You can manage activities made on your site similar to the way you manage comments and other content. This screen is customizable in the same ways as other management screens, and you can act on activities using the on-hover action links or the Bulk Actions."
243
  msgstr ""
244
 
245
- #: bp-activity/bp-activity-admin.php:247
246
  msgid "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."
247
  msgstr ""
248
 
249
- #: bp-activity/bp-activity-admin.php:253
250
  msgid "Moderating Activity"
251
  msgstr ""
252
 
253
- #: bp-activity/bp-activity-admin.php:255
254
  msgid "In the <strong>Activity</strong> column, above each activity it says &#8220;Submitted on,&#8221; followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity."
255
  msgstr ""
256
 
257
- #: bp-activity/bp-activity-admin.php:256
258
  msgid "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."
259
  msgstr ""
260
 
261
- #: bp-activity/bp-activity-admin.php:582
262
  msgid "Editing Activity (ID #%s)"
263
  msgstr ""
264
 
265
- #: bp-activity/bp-activity-admin.php:593
266
  msgid "Action"
267
  msgstr ""
268
 
269
- #: bp-activity/bp-activity-admin.php:600
270
  msgid "Content"
271
  msgstr ""
272
 
273
- #: bp-activity/bp-activity-admin.php:625
274
  msgid "No activity found with this ID. <a href=\"%s\">Go back and try again</a>."
275
  msgstr ""
276
 
277
- #: bp-activity/bp-activity-admin.php:647
278
  msgid "View Activity"
279
  msgstr ""
280
 
281
- #: bp-activity/bp-activity-admin.php:655
282
  msgid "Approved"
283
  msgstr ""
284
 
285
- #: bp-activity/bp-activity-admin.php:656 bp-activity/bp-activity-admin.php:1288
286
- #: bp-activity/bp-activity-akismet.php:178
287
- #: bp-activity/bp-activity-akismet.php:207
288
  msgid "Spam"
289
  msgstr ""
290
 
291
  #. translators: Publish box date format, see http:php.net/date
292
 
293
- #: bp-activity/bp-activity-admin.php:662
294
  msgid "M j, Y @ G:i"
295
  msgstr ""
296
 
297
- #: bp-activity/bp-activity-admin.php:665
298
  msgid "Submitted on: <strong>%1$s</strong>"
299
  msgstr ""
300
 
301
- #: bp-activity/bp-activity-admin.php:665 bp-activity/bp-activity-admin.php:1281
302
- #: bp-forums/bp-forums-template.php:1270 bp-groups/bp-groups-admin.php:1338
303
  #: bp-themes/bp-default/functions.php:509 bp-xprofile/bp-xprofile-admin.php:456
304
- #: bp-xprofile/bp-xprofile-loader.php:185
305
- #: bp-xprofile/bp-xprofile-loader.php:245
306
  msgid "Edit"
307
  msgstr ""
308
 
309
- #: bp-activity/bp-activity-admin.php:678
310
  msgid "Update"
311
  msgstr ""
312
 
313
- #: bp-activity/bp-activity-admin.php:697
314
  msgid "Link"
315
  msgstr ""
316
 
317
- #: bp-activity/bp-activity-admin.php:699
318
- msgid "Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item."
319
  msgstr ""
320
 
321
- #: bp-activity/bp-activity-admin.php:713
322
  msgid "Author ID"
323
  msgstr ""
324
 
325
- #: bp-activity/bp-activity-admin.php:764
326
  msgid "Primary Item ID"
327
  msgstr ""
328
 
329
- #: bp-activity/bp-activity-admin.php:768
330
  msgid "Secondary Item ID"
331
  msgstr ""
332
 
333
- #: bp-activity/bp-activity-admin.php:771
334
  msgid "These identify the object that created this activity. For example, the fields could reference a pair of site and comment IDs."
335
  msgstr ""
336
 
337
- #: bp-activity/bp-activity-admin.php:809
338
  msgid "%s activity item has been permanently deleted."
339
  msgid_plural "%s activity items have been permanently deleted."
340
  msgstr[0] ""
341
  msgstr[1] ""
342
 
343
- #: bp-activity/bp-activity-admin.php:813
344
  msgid "An error occurred when trying to update activity ID #%s."
345
  msgstr ""
346
 
347
- #: bp-activity/bp-activity-admin.php:816
348
  msgid "Errors occurred when trying to update these activity items:"
349
  msgstr ""
350
 
351
  #. Translators: This is a bulleted list of item IDs
352
 
353
- #: bp-activity/bp-activity-admin.php:822
354
  msgid "#%s"
355
  msgstr ""
356
 
357
- #: bp-activity/bp-activity-admin.php:831
358
  msgid "%s activity item has been successfully spammed."
359
  msgid_plural "%s activity items have been successfully spammed."
360
  msgstr[0] ""
361
  msgstr[1] ""
362
 
363
- #: bp-activity/bp-activity-admin.php:834
364
  msgid "%s activity item has been successfully unspammed."
365
  msgid_plural "%s activity items have been successfully unspammed."
366
  msgstr[0] ""
367
  msgstr[1] ""
368
 
369
- #: bp-activity/bp-activity-admin.php:837
370
  msgid "The activity item has been updated succesfully."
371
  msgstr ""
372
 
373
- #: bp-activity/bp-activity-admin.php:850
374
  msgid "Activity related to ID #%s"
375
  msgstr ""
376
 
377
- #: bp-activity/bp-activity-admin.php:856 bp-groups/bp-groups-admin.php:630
378
  msgid "Search results for &#8220;%s&#8221;"
379
  msgstr ""
380
 
381
- #: bp-activity/bp-activity-admin.php:869
382
  msgid "Search all Activity"
383
  msgstr ""
384
 
385
- #: bp-activity/bp-activity-admin.php:880
386
  msgid "Reply to Activity"
387
  msgstr ""
388
 
389
- #: bp-activity/bp-activity-admin.php:884 bp-groups/bp-groups-admin.php:586
390
  #: bp-templates/bp-legacy/buddypress/activity/entry.php:102
391
  #: bp-templates/bp-legacy/buddypress/forums/index.php:116
392
  #: bp-themes/bp-default/forums/index.php:134
393
- #: bp-xprofile/bp-xprofile-classes.php:406
394
- #: bp-xprofile/bp-xprofile-classes.php:928
395
  msgid "Cancel"
396
  msgstr ""
397
 
398
- #: bp-activity/bp-activity-admin.php:885 bp-activity/bp-activity-admin.php:1278
399
  #: bp-templates/bp-legacy/buddypress/activity/comment.php:37
400
  #: bp-templates/bp-legacy/buddypress/groups/single/forum/edit.php:10
401
  #: bp-themes/bp-default/activity/comment.php:40
@@ -403,133 +414,133 @@ msgstr ""
403
  msgid "Reply"
404
  msgstr ""
405
 
406
- #: bp-activity/bp-activity-admin.php:1069
407
  msgid "No activities found."
408
  msgstr ""
409
 
410
- #: bp-activity/bp-activity-admin.php:1133 bp-groups/bp-groups-admin.php:1219
411
- #: bp-messages/bp-messages-template.php:434
412
  msgid "All"
413
  msgstr ""
414
 
415
- #: bp-activity/bp-activity-admin.php:1134
416
  msgid "Spam <span class=\"count\">(%s)</span>"
417
  msgstr ""
418
 
419
- #: bp-activity/bp-activity-admin.php:1149
420
  msgid "Mark as Spam"
421
  msgstr ""
422
 
423
- #: bp-activity/bp-activity-admin.php:1150
424
- #: bp-activity/bp-activity-admin.php:1286
425
  msgid "Not Spam"
426
  msgstr ""
427
 
428
- #: bp-activity/bp-activity-admin.php:1151
429
- #: bp-activity/bp-activity-admin.php:1291 bp-groups/bp-groups-admin.php:585
430
  msgid "Delete Permanently"
431
  msgstr ""
432
 
433
- #: bp-activity/bp-activity-admin.php:1166
434
  msgid "Author"
435
  msgstr ""
436
 
437
- #: bp-activity/bp-activity-admin.php:1168
438
  msgid "In Response To"
439
  msgstr ""
440
 
441
- #: bp-activity/bp-activity-admin.php:1206
442
  msgid "Show all activity types"
443
  msgstr ""
444
 
445
- #: bp-activity/bp-activity-admin.php:1213
446
  msgid "Filter"
447
  msgstr ""
448
 
449
- #: bp-activity/bp-activity-admin.php:1227
450
  msgid "Select activity item %1$d"
451
  msgstr ""
452
 
453
- #: bp-activity/bp-activity-admin.php:1291 bp-core/bp-core-cssjs.php:20
454
  msgid "Are you sure?"
455
  msgstr ""
456
 
457
  #. translators: 2: activity admin ui date/time
458
 
459
- #: bp-activity/bp-activity-admin.php:1300
460
  msgid "Submitted on <a href=\"%1$s\">%2$s at %3$s</a>"
461
  msgstr ""
462
 
463
- #: bp-activity/bp-activity-admin.php:1330
464
  msgid "%s related activity"
465
  msgid_plural "%s related activities"
466
  msgstr[0] ""
467
  msgstr[1] ""
468
 
469
- #: bp-activity/bp-activity-admin.php:1341
470
  msgid "<a href=\"%1$s\">View Activity</a>"
471
  msgstr ""
472
 
473
- #: bp-activity/bp-activity-akismet.php:80
474
  msgid "Flagged as spam by Akismet"
475
  msgstr ""
476
 
477
- #: bp-activity/bp-activity-akismet.php:83
478
  msgid "Cleared by Akismet"
479
  msgstr ""
480
 
481
- #: bp-activity/bp-activity-akismet.php:89
482
  msgid "Flagged as spam by %s"
483
  msgstr ""
484
 
485
- #: bp-activity/bp-activity-akismet.php:91
486
  msgid "Un-spammed by %s"
487
  msgstr ""
488
 
489
- #: bp-activity/bp-activity-akismet.php:100
490
  msgid "History"
491
  msgstr ""
492
 
493
- #: bp-activity/bp-activity-akismet.php:345
494
  msgid "%s reported this activity as spam"
495
  msgstr ""
496
 
497
- #: bp-activity/bp-activity-akismet.php:361
498
  msgid "%s reported this activity as not spam"
499
  msgstr ""
500
 
501
- #: bp-activity/bp-activity-akismet.php:384
502
  msgid "Akismet caught this item as spam"
503
  msgstr ""
504
 
505
- #: bp-activity/bp-activity-akismet.php:389
506
  msgid "Akismet cleared this item"
507
  msgstr ""
508
 
509
- #: bp-activity/bp-activity-akismet.php:394
510
  msgid "Akismet was unable to check this item (response: %s), will automatically retry again later."
511
  msgstr ""
512
 
513
- #: bp-activity/bp-activity-akismet.php:502
514
  msgid "Activity History"
515
  msgstr ""
516
 
517
- #: bp-activity/bp-activity-akismet.php:520
518
  msgctxt "x hours ago - akismet cleared this item"
519
  msgid "<span>%1$s</span> &mdash; %2$s"
520
  msgstr ""
521
 
522
- #: bp-activity/bp-activity-classes.php:120
523
- #: bp-activity/bp-activity-template.php:120 bp-groups/bp-groups-classes.php:318
524
  #: bp-groups/bp-groups-template.php:114
525
  msgid "Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details."
526
  msgstr ""
527
 
528
- #: bp-activity/bp-activity-classes.php:844
529
  msgid "RSS feed 'id' must be defined"
530
  msgstr ""
531
 
532
- #: bp-activity/bp-activity-classes.php:941
533
  msgid "In reply to"
534
  msgstr ""
535
 
@@ -541,115 +552,116 @@ msgstr ""
541
  msgid "&hellip;"
542
  msgstr ""
543
 
544
- #: bp-activity/bp-activity-functions.php:223
545
  msgid "@%s Mentions"
546
  msgstr ""
547
 
548
- #: bp-activity/bp-activity-functions.php:226
549
  msgid "You have %1$d new mentions"
550
  msgstr ""
551
 
552
- #: bp-activity/bp-activity-functions.php:230
553
  msgid "%1$s mentioned you"
554
  msgstr ""
555
 
556
- #: bp-activity/bp-activity-functions.php:867
557
  msgid "Posted a status update"
558
  msgstr ""
559
 
560
- #: bp-activity/bp-activity-functions.php:868
561
  msgid "Replied to a status update"
562
  msgstr ""
563
 
564
- #: bp-activity/bp-activity-functions.php:1119
565
  msgid "%s posted an update"
566
  msgstr ""
567
 
568
- #: bp-activity/bp-activity-functions.php:1188
569
  #: tests/testcases/activity/class.BP_Activity_Activity.php:202
570
  msgid "%s posted a new activity comment"
571
  msgstr ""
572
 
573
- #: bp-activity/bp-activity-functions.php:1565
574
  msgid "Thumbnail"
575
  msgstr ""
576
 
577
  #: bp-activity/bp-activity-loader.php:30
578
- #: bp-core/admin/bp-core-components.php:371
579
  msgid "Activity Streams"
580
  msgstr ""
581
 
582
- #: bp-activity/bp-activity-loader.php:93
583
  msgid "Search Activity..."
584
  msgstr ""
585
 
586
- #: bp-activity/bp-activity-loader.php:144
587
- #: bp-activity/bp-activity-loader.php:264
588
  msgid "Personal"
589
  msgstr ""
590
 
591
- #: bp-activity/bp-activity-loader.php:155
592
- #: bp-activity/bp-activity-loader.php:238
593
  #: bp-templates/bp-legacy/buddypress/activity/index.php:59
594
  #: bp-themes/bp-default/activity/index.php:79
595
  msgid "Mentions"
596
  msgstr ""
597
 
598
- #: bp-activity/bp-activity-loader.php:167
599
- #: bp-activity/bp-activity-loader.php:272
600
  msgid "Favorites"
601
  msgstr ""
602
 
603
- #: bp-activity/bp-activity-loader.php:179
604
- #: bp-activity/bp-activity-loader.php:281 bp-friends/bp-friends-loader.php:164
605
- #: bp-friends/bp-friends-screens.php:83
606
  msgid "Friends"
607
  msgstr ""
608
 
609
- #: bp-activity/bp-activity-loader.php:192
610
- #: bp-activity/bp-activity-loader.php:291 bp-core/bp-core-template.php:246
611
- #: bp-groups/bp-groups-activity.php:150 bp-groups/bp-groups-activity.php:186
612
- #: bp-groups/bp-groups-activity.php:222 bp-groups/bp-groups-activity.php:258
613
- #: bp-groups/bp-groups-admin.php:35 bp-groups/bp-groups-admin.php:36
614
- #: bp-groups/bp-groups-admin.php:623 bp-groups/bp-groups-loader.php:517
615
- #: bp-groups/bp-groups-screens.php:895 bp-groups/bp-groups-screens.php:1027
616
- #: bp-groups/bp-groups-screens.php:1029 bp-groups/bp-groups-screens.php:1088
617
- #: bp-groups/bp-groups-screens.php:1090 bp-groups/bp-groups-widgets.php:48
618
- #: bp-groups/bp-groups-widgets.php:119
619
  msgid "Groups"
620
  msgstr ""
621
 
622
- #: bp-activity/bp-activity-loader.php:236
623
  msgid "Mentions <span class=\"count\">%s</span>"
624
  msgstr ""
625
 
626
- #: bp-activity/bp-activity-loader.php:316
627
  msgid "My Activity"
628
  msgstr ""
629
 
630
- #: bp-activity/bp-activity-loader.php:321
631
- #: bp-activity/bp-activity-template.php:985
632
- #: bp-activity/bp-activity-template.php:1121
633
- #: bp-activity/bp-activity-template.php:1132 bp-blogs/bp-blogs-loader.php:218
634
- #: bp-forums/bp-forums-loader.php:218 bp-forums/bp-forums-template.php:487
635
- #: bp-forums/bp-forums-template.php:604 bp-forums/bp-forums-template.php:1200
636
- #: bp-friends/bp-friends-loader.php:212 bp-groups/bp-groups-loader.php:582
637
  #: bp-groups/bp-groups-template.php:770 bp-groups/bp-groups-template.php:793
638
  #: bp-groups/bp-groups-template.php:1222 bp-groups/bp-groups-template.php:1238
639
  #: bp-groups/bp-groups-template.php:1287 bp-groups/bp-groups-template.php:1303
640
- #: bp-groups/bp-groups-template.php:2012 bp-groups/bp-groups-template.php:2021
641
- #: bp-groups/bp-groups-template.php:2030 bp-groups/bp-groups-template.php:2778
642
- #: bp-members/bp-members-buddybar.php:90 bp-members/bp-members-loader.php:198
643
  #: bp-members/bp-members-template.php:520
644
  #: bp-members/bp-members-template.php:820
645
  #: bp-members/bp-members-template.php:839
646
- #: bp-messages/bp-messages-loader.php:264
647
- #: bp-messages/bp-messages-template.php:326
 
648
  #: bp-templates/bp-legacy/buddypress/groups/single/admin.php:185
649
  #: bp-templates/bp-legacy/buddypress/groups/single/admin.php:212
650
  #: bp-themes/bp-default/groups/single/admin.php:185
651
  #: bp-themes/bp-default/groups/single/admin.php:212
652
- #: bp-xprofile/bp-xprofile-loader.php:277
653
  msgid "Profile picture of %s"
654
  msgstr ""
655
 
@@ -682,8 +694,8 @@ msgstr ""
682
  #: bp-activity/bp-activity-notifications.php:100
683
  #: bp-activity/bp-activity-notifications.php:178
684
  #: bp-activity/bp-activity-notifications.php:226 bp-core/deprecated/1.5.php:364
685
- #: bp-friends/bp-friends-notifications.php:44
686
- #: bp-friends/bp-friends-notifications.php:82
687
  #: bp-groups/bp-groups-notifications.php:42
688
  #: bp-groups/bp-groups-notifications.php:92
689
  #: bp-groups/bp-groups-notifications.php:150
@@ -727,19 +739,19 @@ msgstr ""
727
  msgid "You do not have access to this activity."
728
  msgstr ""
729
 
730
- #: bp-activity/bp-activity-screens.php:285 bp-blogs/bp-blogs-template.php:683
731
- #: bp-friends/bp-friends-screens.php:84 bp-groups/bp-groups-screens.php:896
732
  #: bp-messages/bp-messages-screens.php:169
733
- #: bp-templates/bp-legacy/buddypress/members/register.php:223
734
- #: bp-themes/bp-default/registration/register.php:228
735
  msgid "Yes"
736
  msgstr ""
737
 
738
- #: bp-activity/bp-activity-screens.php:286 bp-blogs/bp-blogs-template.php:687
739
- #: bp-friends/bp-friends-screens.php:85 bp-groups/bp-groups-screens.php:897
740
  #: bp-messages/bp-messages-screens.php:170
741
- #: bp-templates/bp-legacy/buddypress/members/register.php:224
742
- #: bp-themes/bp-default/registration/register.php:229
743
  msgid "No"
744
  msgstr ""
745
 
@@ -755,44 +767,47 @@ msgstr ""
755
  msgid "Sitewide Activity"
756
  msgstr ""
757
 
758
- #: bp-activity/bp-activity-template.php:221
759
  msgctxt "Activity pagination previous text"
760
  msgid "&larr;"
761
  msgstr ""
762
 
763
- #: bp-activity/bp-activity-template.php:222
764
  msgctxt "Activity pagination next text"
765
  msgid "&rarr;"
766
  msgstr ""
767
 
768
- #: bp-activity/bp-activity-template.php:536
769
- msgid "Viewing item %1$s to %2$s (of %3$s items)"
770
- msgstr ""
 
 
771
 
772
- #: bp-activity/bp-activity-template.php:985
773
  msgid "Profile picture"
774
  msgstr ""
775
 
776
- #: bp-activity/bp-activity-template.php:1097
777
  msgid "Group logo"
778
  msgstr ""
779
 
780
- #: bp-activity/bp-activity-template.php:1100 bp-groups/bp-groups-admin.php:1352
781
  #: bp-groups/bp-groups-template.php:516
782
  msgid "Group logo of %s"
783
  msgstr ""
784
 
785
- #: bp-activity/bp-activity-template.php:1111
786
  msgid "Profile picture of the author of the site %s"
787
  msgstr ""
788
 
789
- #: bp-activity/bp-activity-template.php:1336
790
  msgid "View Discussion"
791
  msgstr ""
792
 
793
- #: bp-activity/bp-activity-template.php:2205
794
- #: bp-forums/bp-forums-template.php:1271 bp-groups/bp-groups-admin.php:1237
795
- #: bp-groups/bp-groups-admin.php:1341 bp-groups/bp-groups-template.php:1486
 
796
  #: bp-templates/bp-legacy/buddypress/activity/comment.php:43
797
  #: bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php:51
798
  #: bp-templates/bp-legacy/buddypress/members/single/messages/single.php:24
@@ -803,35 +818,35 @@ msgstr ""
803
  msgid "Delete"
804
  msgstr ""
805
 
806
- #: bp-activity/bp-activity-template.php:2252
807
  #: bp-core/admin/bp-core-slugs.php:109 bp-core/admin/bp-core-slugs.php:172
808
- #: bp-core/bp-core-loader.php:226 bp-members/bp-members-loader.php:172
809
  #: bp-members/bp-members-template.php:625
810
- #: bp-templates/bp-legacy/buddypress-functions.php:237
811
  #: bp-themes/bp-default/activity/entry.php:37
812
  #: bp-themes/bp-default/functions.php:166
813
- #: bp-xprofile/bp-xprofile-loader.php:175
814
- #: bp-xprofile/bp-xprofile-loader.php:237
815
  msgid "View"
816
  msgstr ""
817
 
818
- #: bp-activity/bp-activity-template.php:2346
819
  msgid "Clear Filter"
820
  msgstr ""
821
 
822
- #: bp-activity/bp-activity-template.php:2537
823
  msgid "a user"
824
  msgstr ""
825
 
826
- #: bp-activity/bp-activity-template.php:2577
827
  msgid "Send a public message on your activity stream."
828
  msgstr ""
829
 
830
- #: bp-activity/bp-activity-template.php:2578
831
  msgid "Public Message"
832
  msgstr ""
833
 
834
- #: bp-activity/bp-activity-template.php:3000
835
  msgid "Site Wide Activity RSS Feed"
836
  msgstr ""
837
 
@@ -847,98 +862,102 @@ msgstr ""
847
  msgid "New post comment posted"
848
  msgstr ""
849
 
850
- #: bp-blogs/bp-blogs-buddybar.php:43 bp-blogs/bp-blogs-loader.php:131
851
- #: bp-blogs/bp-blogs-loader.php:179 bp-blogs/bp-blogs-loader.php:209
852
  msgid "My Sites"
853
  msgstr ""
854
 
855
- #: bp-blogs/bp-blogs-buddybar.php:55 bp-core/bp-core-buddybar.php:545
856
  msgid "Dashboard"
857
  msgstr ""
858
 
859
- #: bp-blogs/bp-blogs-buddybar.php:56 bp-core/bp-core-buddybar.php:549
860
  msgid "New Post"
861
  msgstr ""
862
 
863
- #: bp-blogs/bp-blogs-buddybar.php:57 bp-core/bp-core-buddybar.php:550
864
  msgid "Manage Posts"
865
  msgstr ""
866
 
867
- #: bp-blogs/bp-blogs-buddybar.php:58 bp-core/bp-core-buddybar.php:551
868
  msgid "Manage Comments"
869
  msgstr ""
870
 
871
- #: bp-blogs/bp-blogs-buddybar.php:71
872
  msgid "Create a Site!"
873
  msgstr ""
874
 
875
- #: bp-blogs/bp-blogs-functions.php:175
876
  msgid "%s created the site %s"
877
  msgstr ""
878
 
879
- #: bp-blogs/bp-blogs-functions.php:252
880
  msgid "%1$s wrote a new post, %2$s, on the site %3$s"
881
  msgstr ""
882
 
883
- #: bp-blogs/bp-blogs-functions.php:254
884
  msgid "%1$s wrote a new post, %2$s"
885
  msgstr ""
886
 
887
- #: bp-blogs/bp-blogs-functions.php:360
888
  msgid "%1$s commented on the post, %2$s, on the site %3$s"
889
  msgstr ""
890
 
891
- #: bp-blogs/bp-blogs-functions.php:362
892
  msgid "%1$s commented on the post, %2$s"
893
  msgstr ""
894
 
895
- #: bp-blogs/bp-blogs-loader.php:25 bp-core/admin/bp-core-components.php:383
896
  msgid "Site Tracking"
897
  msgstr ""
898
 
899
- #: bp-blogs/bp-blogs-loader.php:58
900
  msgid "Search sites..."
901
  msgstr ""
902
 
903
- #: bp-blogs/bp-blogs-loader.php:111
904
  msgid "Sites <span>%d</span>"
905
  msgstr ""
906
 
907
- #: bp-blogs/bp-blogs-loader.php:171
 
 
908
  msgid "Sites"
909
  msgstr ""
910
 
911
- #: bp-blogs/bp-blogs-loader.php:188 bp-blogs/bp-blogs-screens.php:135
912
- #: bp-blogs/bp-blogs-screens.php:196
913
- msgid "Create a Blog"
 
 
914
  msgstr ""
915
 
916
- #: bp-blogs/bp-blogs-screens.php:135 bp-blogs/bp-blogs-screens.php:137
917
- #: bp-blogs/bp-blogs-screens.php:196 bp-blogs/bp-blogs-screens.php:198
918
- #: bp-core/bp-core-template.php:249
919
- msgid "Blogs"
920
  msgstr ""
921
 
922
- #: bp-blogs/bp-blogs-template.php:136
923
  msgctxt "Blog pagination previous text"
924
  msgid "&larr;"
925
  msgstr ""
926
 
927
- #: bp-blogs/bp-blogs-template.php:137
928
  msgctxt "Blog pagination next text"
929
  msgid "&rarr;"
930
  msgstr ""
931
 
932
- #: bp-blogs/bp-blogs-template.php:261
933
- msgid "Viewing site %1$s to %2$s (of %3$s sites)"
934
- msgstr ""
 
 
935
 
936
- #: bp-blogs/bp-blogs-template.php:285
937
  msgid "Profile picture of site author %s"
938
  msgstr ""
939
 
940
- #: bp-blogs/bp-blogs-template.php:403 bp-core/bp-core-classes.php:774
941
- #: bp-groups/bp-groups-widgets.php:80 bp-groups/bp-groups-widgets.php:183
942
  #: bp-members/bp-members-template.php:596
943
  #: bp-members/bp-members-template.php:871
944
  #: bp-templates/bp-legacy/buddypress/groups/groups-loop.php:47
@@ -948,134 +967,128 @@ msgstr ""
948
  msgid "active %s"
949
  msgstr ""
950
 
951
- #: bp-blogs/bp-blogs-template.php:415
952
  msgid "Latest Post: %s"
953
  msgstr ""
954
 
955
- #: bp-blogs/bp-blogs-template.php:609
956
  msgid "There was a problem, please correct the form below and try again."
957
  msgstr ""
958
 
959
- #: bp-blogs/bp-blogs-template.php:612
960
  msgid "By filling out the form below, you can <strong>add a site to your account</strong>. There is no limit to the number of sites that you can have, so create to your heart's content, but blog responsibly!"
961
  msgstr ""
962
 
963
- #: bp-blogs/bp-blogs-template.php:614
964
  msgid "If you&#8217;re not going to use a great domain, leave it for a new user. Now have at it!"
965
  msgstr ""
966
 
967
- #: bp-blogs/bp-blogs-template.php:623
968
  msgid "Create Site"
969
  msgstr ""
970
 
971
- #: bp-blogs/bp-blogs-template.php:637
972
  msgid "Site Name:"
973
  msgstr ""
974
 
975
- #: bp-blogs/bp-blogs-template.php:639
976
  msgid "Site Domain:"
977
  msgstr ""
978
 
979
- #: bp-blogs/bp-blogs-template.php:653
980
  msgid "Your address will be "
981
  msgstr ""
982
 
983
- #: bp-blogs/bp-blogs-template.php:656
984
  msgid "blogname"
985
  msgstr ""
986
 
987
- #: bp-blogs/bp-blogs-template.php:658
988
  msgid "domain."
989
  msgstr ""
990
 
991
- #: bp-blogs/bp-blogs-template.php:661
992
  msgid "Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)"
993
  msgstr ""
994
 
995
- #: bp-blogs/bp-blogs-template.php:667
996
  msgid "Site Title:"
997
  msgstr ""
998
 
999
- #: bp-blogs/bp-blogs-template.php:678
1000
  msgid "Privacy:"
1001
  msgstr ""
1002
 
1003
- #: bp-blogs/bp-blogs-template.php:679
1004
- #: bp-templates/bp-legacy/buddypress/members/register.php:220
1005
- #: bp-themes/bp-default/registration/register.php:225
1006
  msgid "I would like my site to appear in search engines, and in public listings around this network."
1007
  msgstr ""
1008
 
1009
- #: bp-blogs/bp-blogs-template.php:762
1010
  msgid "Congratulations! You have successfully registered a new site."
1011
  msgstr ""
1012
 
1013
- #: bp-blogs/bp-blogs-template.php:764
1014
  msgid "<a href=\"%1$s\">%2$s</a> is your new site. <a href=\"%3$s\">Login</a> as \"%4$s\" using your existing password."
1015
  msgstr ""
1016
 
1017
- #: bp-blogs/bp-blogs-template.php:773 bp-core/bp-core-filters.php:378
1018
- #: bp-themes/bp-default/blogs/create.php:21
1019
- #: bp-themes/bp-default/blogs/index.php:21
1020
- msgid "Create a Site"
1021
- msgstr ""
1022
-
1023
- #: bp-blogs/bp-blogs-template.php:785
1024
  msgid "%s's Sites"
1025
  msgstr ""
1026
 
1027
- #: bp-blogs/bp-blogs-template.php:786
1028
  msgid "%s's Recent Posts"
1029
  msgstr ""
1030
 
1031
- #: bp-blogs/bp-blogs-template.php:787
1032
  msgid "%s's Recent Comments"
1033
  msgstr ""
1034
 
1035
- #: bp-blogs/bp-blogs-template.php:801 bp-core/deprecated/1.5.php:417
1036
- #: bp-forums/bp-forums-template.php:1321 bp-groups/bp-groups-template.php:2503
1037
  #: bp-members/bp-members-template.php:710
1038
- #: bp-messages/bp-messages-template.php:367 bp-themes/bp-default/header.php:30
1039
  #: bp-themes/bp-default/searchform.php:5
1040
  msgid "Search"
1041
  msgstr ""
1042
 
1043
- #: bp-blogs/bp-blogs-template.php:834 bp-blogs/bp-blogs-template.php:835
1044
  msgid "Visit Site"
1045
  msgstr ""
1046
 
1047
- #: bp-blogs/bp-blogs-widgets.php:29
1048
  msgid "A list of recently published posts from across your network."
1049
  msgstr ""
1050
 
1051
- #: bp-blogs/bp-blogs-widgets.php:32
1052
  msgctxt "widget name"
1053
  msgid "(BuddyPress) Recent Networkwide Posts"
1054
  msgstr ""
1055
 
1056
- #: bp-blogs/bp-blogs-widgets.php:37 bp-blogs/bp-blogs-widgets.php:97
1057
  msgid "Recent Networkwide Posts"
1058
  msgstr ""
1059
 
1060
- #: bp-blogs/bp-blogs-widgets.php:78
1061
  msgid "Sorry, there were no posts found. Why not write one?"
1062
  msgstr ""
1063
 
1064
- #: bp-blogs/bp-blogs-widgets.php:108
1065
  msgctxt "Label for the Title field of the Recent Networkwide Posts widget"
1066
  msgid "Title:"
1067
  msgstr ""
1068
 
1069
- #: bp-blogs/bp-blogs-widgets.php:109
1070
  msgid "Link widget title to Blogs directory"
1071
  msgstr ""
1072
 
1073
- #: bp-blogs/bp-blogs-widgets.php:110
1074
  msgid "Max posts to show:"
1075
  msgstr ""
1076
 
1077
  #: bp-core/admin/bp-core-components.php:26
1078
- #: bp-core/admin/bp-core-functions.php:354
1079
  msgid "Components"
1080
  msgstr ""
1081
 
@@ -1085,140 +1098,157 @@ msgid "Save Settings"
1085
  msgstr ""
1086
 
1087
  #: bp-core/admin/bp-core-components.php:59
1088
- #: bp-core/admin/bp-core-components.php:355
1089
  #: bp-xprofile/bp-xprofile-loader.php:41
1090
  msgid "Extended Profiles"
1091
  msgstr ""
1092
 
1093
  #: bp-core/admin/bp-core-components.php:60
1094
- #: bp-core/admin/bp-core-components.php:356
1095
  msgid "Customize your community with fully editable profile fields that allow your users to describe themselves."
1096
  msgstr ""
1097
 
1098
- #: bp-core/admin/bp-core-components.php:136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1099
  msgctxt "plugins"
1100
  msgid "All <span class=\"count\">(%s)</span>"
1101
  msgid_plural "All <span class=\"count\">(%s)</span>"
1102
  msgstr[0] ""
1103
  msgstr[1] ""
1104
 
1105
- #: bp-core/admin/bp-core-components.php:137
1106
  msgid "Active <span class=\"count\">(%s)</span>"
1107
  msgid_plural "Active <span class=\"count\">(%s)</span>"
1108
  msgstr[0] ""
1109
  msgstr[1] ""
1110
 
1111
- #: bp-core/admin/bp-core-components.php:138
1112
  msgid "Inactive <span class=\"count\">(%s)</span>"
1113
  msgid_plural "Inactive <span class=\"count\">(%s)</span>"
1114
  msgstr[0] ""
1115
  msgstr[1] ""
1116
 
1117
- #: bp-core/admin/bp-core-components.php:139
1118
  msgid "Must-Use <span class=\"count\">(%s)</span>"
1119
  msgid_plural "Must-Use <span class=\"count\">(%s)</span>"
1120
  msgstr[0] ""
1121
  msgstr[1] ""
1122
 
1123
- #: bp-core/admin/bp-core-components.php:140
1124
  msgid "Retired <span class=\"count\">(%s)</span>"
1125
  msgid_plural "Retired <span class=\"count\">(%s)</span>"
1126
  msgstr[0] ""
1127
  msgstr[1] ""
1128
 
1129
- #: bp-core/admin/bp-core-components.php:147
1130
  #: bp-core/admin/bp-core-components.php:155
 
1131
  msgid "Component"
1132
  msgstr ""
1133
 
1134
- #: bp-core/admin/bp-core-components.php:148
1135
  #: bp-core/admin/bp-core-components.php:156
 
1136
  msgid "Description"
1137
  msgstr ""
1138
 
1139
- #: bp-core/admin/bp-core-components.php:181
1140
  msgid "Select %s"
1141
  msgstr ""
1142
 
1143
- #: bp-core/admin/bp-core-components.php:206
1144
  msgid "No components found."
1145
  msgstr ""
1146
 
1147
- #: bp-core/admin/bp-core-components.php:335 bp-core/bp-core-loader.php:27
1148
  msgid "BuddyPress Core"
1149
  msgstr ""
1150
 
1151
- #: bp-core/admin/bp-core-components.php:336
1152
  msgid "It&#8216;s what makes <del>time travel</del> BuddyPress possible!"
1153
  msgstr ""
1154
 
1155
- #: bp-core/admin/bp-core-components.php:339
1156
  msgid "Community Members"
1157
  msgstr ""
1158
 
1159
- #: bp-core/admin/bp-core-components.php:340
1160
  msgid "Everything in a BuddyPress community revolves around its members."
1161
  msgstr ""
1162
 
1163
- #: bp-core/admin/bp-core-components.php:347
1164
  #: bp-templates/bp-legacy/buddypress/groups/create.php:105
1165
  #: bp-themes/bp-default/groups/create.php:112
1166
  msgid "Group Forums"
1167
  msgstr ""
1168
 
1169
- #: bp-core/admin/bp-core-components.php:348
1170
  msgid "BuddyPress Forums are retired. Use %s."
1171
  msgstr ""
1172
 
1173
- #: bp-core/admin/bp-core-components.php:359
1174
- msgid "Account Settings"
1175
- msgstr ""
1176
-
1177
- #: bp-core/admin/bp-core-components.php:360
1178
- msgid "Allow your users to modify their account and notification settings directly from within their profiles."
1179
- msgstr ""
1180
-
1181
- #: bp-core/admin/bp-core-components.php:363 bp-friends/bp-friends-loader.php:24
1182
  msgid "Friend Connections"
1183
  msgstr ""
1184
 
1185
- #: bp-core/admin/bp-core-components.php:364
1186
  msgid "Let your users make connections so they can track the activity of others and focus on the people they care about the most."
1187
  msgstr ""
1188
 
1189
- #: bp-core/admin/bp-core-components.php:367
1190
  msgid "Private Messaging"
1191
  msgstr ""
1192
 
1193
- #: bp-core/admin/bp-core-components.php:368
1194
  msgid "Allow your users to talk to each other directly and in private. Not just limited to one-on-one discussions, messages can be sent between any number of members."
1195
  msgstr ""
1196
 
1197
- #: bp-core/admin/bp-core-components.php:372
1198
  msgid "Global, personal, and group activity streams with threaded commenting, direct posting, favoriting and @mentions, all with full RSS feed and email notification support."
1199
  msgstr ""
1200
 
1201
- #: bp-core/admin/bp-core-components.php:375 bp-groups/bp-groups-loader.php:83
1202
  msgid "User Groups"
1203
  msgstr ""
1204
 
1205
- #: bp-core/admin/bp-core-components.php:376
1206
  msgid "Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings."
1207
  msgstr ""
1208
 
1209
- #: bp-core/admin/bp-core-components.php:379
1210
  msgid "Group Forums (Legacy)"
1211
  msgstr ""
1212
 
1213
- #: bp-core/admin/bp-core-components.php:380
1214
  msgid "Group forums allow for focused, bulletin-board style conversations."
1215
  msgstr ""
1216
 
1217
- #: bp-core/admin/bp-core-components.php:384
1218
  msgid "Record activity for new posts and comments from your site."
1219
  msgstr ""
1220
 
1221
- #: bp-core/admin/bp-core-components.php:391
1222
  msgid "Record activity for new sites, posts, and comments across your network."
1223
  msgstr ""
1224
 
@@ -1234,88 +1264,115 @@ msgstr ""
1234
  msgid "Components, Pages, Settings, and Forums, have been moved to <a href=\"%s\">Settings &gt; BuddyPress</a>. Profile Fields has been moved into the <a href=\"%s\">Users</a> menu."
1235
  msgstr ""
1236
 
1237
- #: bp-core/admin/bp-core-functions.php:216
1238
  msgid "<strong>BuddyPress is almost ready</strong>. You must <a href=\"%s\">update your permalink structure</a> to something other than the default for it to work."
1239
  msgstr ""
1240
 
1241
- #: bp-core/admin/bp-core-functions.php:240 bp-core/admin/bp-core-slugs.php:135
1242
- #: bp-messages/bp-messages-template.php:558
1243
  #: bp-templates/bp-legacy/buddypress/members/activate.php:29
1244
  #: bp-themes/bp-default/registration/activate.php:38
1245
  msgid "Activate"
1246
  msgstr ""
1247
 
1248
- #: bp-core/admin/bp-core-functions.php:245 bp-core/admin/bp-core-slugs.php:134
1249
  #: bp-members/bp-members-adminbar.php:60
1250
  msgid "Register"
1251
  msgstr ""
1252
 
1253
- #: bp-core/admin/bp-core-functions.php:270
1254
  msgid "The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href=\"%1$s\" class=\"button-secondary\">Repair</a>"
1255
  msgstr ""
1256
 
1257
- #: bp-core/admin/bp-core-functions.php:292
1258
  msgid "Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href=\"%1$s\" class=\"button-secondary\">Repair</a>"
1259
  msgstr ""
1260
 
1261
- #: bp-core/admin/bp-core-functions.php:358 bp-core/admin/bp-core-slugs.php:26
1262
  msgid "Pages"
1263
  msgstr ""
1264
 
1265
- #: bp-core/admin/bp-core-functions.php:362
1266
- #: bp-core/admin/bp-core-settings.php:258 bp-core/bp-core-admin.php:331
1267
- #: bp-groups/bp-groups-loader.php:302 bp-groups/bp-groups-template.php:1468
1268
  #: bp-settings/bp-settings-loader.php:23 bp-settings/bp-settings-loader.php:73
1269
- #: bp-settings/bp-settings-loader.php:165
1270
  msgid "Settings"
1271
  msgstr ""
1272
 
1273
- #: bp-core/admin/bp-core-functions.php:374 bp-core/bp-core-template.php:252
1274
- #: bp-forums/bp-forums-loader.php:109 bp-forums/bp-forums-loader.php:172
1275
- #: bp-forums/bp-forums-loader.php:213 bp-forums/bp-forums-screens.php:188
1276
- #: bp-forums/bp-forums-screens.php:190 bp-forums/deprecated/1.6.php:42
1277
  #: bp-forums/deprecated/1.7.php:25 bp-forums/deprecated/1.7.php:100
1278
  msgid "Forums"
1279
  msgstr ""
1280
 
1281
- #: bp-core/admin/bp-core-functions.php:419
1282
  msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-components\">Managing Components</a>"
1283
  msgstr ""
1284
 
1285
- #: bp-core/admin/bp-core-functions.php:437
1286
  msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-pages\">Managing Pages</a>"
1287
  msgstr ""
1288
 
1289
- #: bp-core/admin/bp-core-functions.php:456
1290
  msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-settings\">Managing Settings</a>"
1291
  msgstr ""
1292
 
1293
- #: bp-core/admin/bp-core-functions.php:475
1294
  msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#users-profile-fields\">Managing Profile Fields</a>"
1295
  msgstr ""
1296
 
1297
- #: bp-core/admin/bp-core-functions.php:493
1298
  msgid "By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site."
1299
  msgstr ""
1300
 
1301
- #: bp-core/admin/bp-core-functions.php:497
1302
  msgid "BuddyPress Components use WordPress Pages for their root directory/archive pages. Here you can change the page associations for each active component."
1303
  msgstr ""
1304
 
1305
- #: bp-core/admin/bp-core-functions.php:501
1306
  msgid "Extra configuration settings."
1307
  msgstr ""
1308
 
1309
- #: bp-core/admin/bp-core-functions.php:505
1310
  msgid "Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.</br></br>Note: Any fields in the first group will appear on the signup page."
1311
  msgstr ""
1312
 
1313
- #: bp-core/admin/bp-core-schema.php:244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1314
  msgctxt "First field-group name"
1315
  msgid "General"
1316
  msgstr ""
1317
 
1318
- #: bp-core/admin/bp-core-schema.php:248
1319
  msgctxt "Display name field"
1320
  msgid "Display Name"
1321
  msgstr ""
@@ -1391,8 +1448,8 @@ msgstr ""
1391
  #: bp-core/admin/bp-core-slugs.php:105 bp-core/admin/bp-core-slugs.php:168
1392
  #: bp-templates/bp-legacy/buddypress/members/single/settings/capabilities.php:13
1393
  #: bp-themes/bp-default/members/single/settings/capabilities.php:61
1394
- #: bp-xprofile/bp-xprofile-classes.php:401
1395
- #: bp-xprofile/bp-xprofile-classes.php:927
1396
  msgid "Save"
1397
  msgstr ""
1398
 
@@ -1404,358 +1461,359 @@ msgstr ""
1404
  msgid "Associate WordPress Pages with the following BuddyPress Registration pages."
1405
  msgstr ""
1406
 
1407
- #: bp-core/bp-core-admin.php:154 bp-core/bp-core-admin.php:155
1408
- #: bp-core/bp-core-admin.php:163 bp-core/bp-core-admin.php:164
1409
  msgid "Welcome to BuddyPress"
1410
  msgstr ""
1411
 
1412
- #: bp-core/bp-core-admin.php:174 bp-core/bp-core-admin.php:175
1413
- #: bp-core/bp-core-admin.php:195
1414
- msgid "BuddyPress"
1415
- msgstr ""
1416
-
1417
- #: bp-core/bp-core-admin.php:184
1418
  msgid "BuddyPress Help"
1419
  msgstr ""
1420
 
1421
- #: bp-core/bp-core-admin.php:185
1422
  msgid "Help"
1423
  msgstr ""
1424
 
1425
- #: bp-core/bp-core-admin.php:194
1426
  msgid "BuddyPress Components"
1427
  msgstr ""
1428
 
1429
- #: bp-core/bp-core-admin.php:203 bp-core/bp-core-admin.php:204
1430
  msgid "BuddyPress Pages"
1431
  msgstr ""
1432
 
1433
- #: bp-core/bp-core-admin.php:212 bp-core/bp-core-admin.php:213
1434
  msgid "BuddyPress Settings"
1435
  msgstr ""
1436
 
1437
- #: bp-core/bp-core-admin.php:239
1438
  msgid "Main Settings"
1439
  msgstr ""
1440
 
1441
- #: bp-core/bp-core-admin.php:242 bp-core/bp-core-admin.php:247
1442
  msgid "Toolbar"
1443
  msgstr ""
1444
 
1445
- #: bp-core/bp-core-admin.php:252
1446
  msgid "Account Deletion"
1447
  msgstr ""
1448
 
1449
- #: bp-core/bp-core-admin.php:260
1450
  msgid "Profile Settings"
1451
  msgstr ""
1452
 
1453
- #: bp-core/bp-core-admin.php:263
1454
  msgid "Avatar Uploads"
1455
  msgstr ""
1456
 
1457
- #: bp-core/bp-core-admin.php:267
1458
  msgid "Profile Syncing"
1459
  msgstr ""
1460
 
1461
- #: bp-core/bp-core-admin.php:276
1462
  msgid "Groups Settings"
1463
  msgstr ""
1464
 
1465
- #: bp-core/bp-core-admin.php:279
1466
  msgid "Group Creation"
1467
  msgstr ""
1468
 
1469
- #: bp-core/bp-core-admin.php:288
1470
  msgid "Legacy Group Forums"
1471
  msgstr ""
1472
 
1473
- #: bp-core/bp-core-admin.php:291
1474
  msgid "bbPress Configuration"
1475
  msgstr ""
1476
 
1477
- #: bp-core/bp-core-admin.php:300
1478
  msgid "Activity Settings"
1479
  msgstr ""
1480
 
1481
- #: bp-core/bp-core-admin.php:303
1482
  msgid "Blog &amp; Forum Comments"
1483
  msgstr ""
1484
 
1485
- #: bp-core/bp-core-admin.php:308
1486
  msgid "Akismet"
1487
  msgstr ""
1488
 
1489
- #: bp-core/bp-core-admin.php:332
1490
  msgid "About"
1491
  msgstr ""
1492
 
1493
- #: bp-core/bp-core-admin.php:383 bp-core/bp-core-admin.php:492
1494
  msgid "Welcome to BuddyPress %s"
1495
  msgstr ""
1496
 
1497
- #: bp-core/bp-core-admin.php:386
1498
  msgid "BuddyPress %s is our safest, fastest, most flexible version ever."
1499
  msgstr ""
1500
 
1501
- #: bp-core/bp-core-admin.php:388
1502
  msgid "Thank you for updating! BuddyPress %s is our safest, fastest, most flexible version ever."
1503
  msgstr ""
1504
 
1505
- #: bp-core/bp-core-admin.php:391 bp-core/bp-core-admin.php:494
1506
  msgid "Version %s"
1507
  msgstr ""
1508
 
1509
- #: bp-core/bp-core-admin.php:395 bp-core/bp-core-admin.php:498
1510
  msgid "What&#8217;s New"
1511
  msgstr ""
1512
 
1513
- #: bp-core/bp-core-admin.php:397 bp-core/bp-core-admin.php:500
1514
  msgid "Credits"
1515
  msgstr ""
1516
 
1517
- #: bp-core/bp-core-admin.php:402
1518
  msgid "Getting Started"
1519
  msgstr ""
1520
 
1521
- #: bp-core/bp-core-admin.php:405
1522
  msgid "Your Default Setup"
1523
  msgstr ""
1524
 
1525
- #: bp-core/bp-core-admin.php:407
1526
  msgid "BuddyPress&#8217;s powerful features help your users connect and collaborate. To help get your community started, we&#8217;ve activated two of the most commonly used tools in BP: <strong>Extended Profiles</strong> and <strong>Activity Streams</strong>. See these components in action at the %1$s and %2$s directories, and be sure to spend a few minutes <a href=\"%3$s\">configuring user profiles</a>. Want to explore more of BP&#8217;s features? Visit the <a href=\"%4$s\">Components panel</a>."
1527
  msgstr ""
1528
 
1529
- #: bp-core/bp-core-admin.php:408 bp-core/bp-core-template.php:243
1530
- #: bp-core/bp-core-widgets.php:113 bp-groups/bp-groups-admin.php:759
1531
  #: bp-groups/bp-groups-template.php:1476 bp-members/bp-members-loader.php:24
1532
- #: bp-members/bp-members-screens.php:355
1533
  #: bp-templates/bp-legacy/buddypress/groups/single/admin.php:231
1534
  #: bp-themes/bp-default/groups/single/admin.php:231
1535
  msgid "Members"
1536
  msgstr ""
1537
 
1538
- #: bp-core/bp-core-admin.php:414
 
 
 
 
1539
  msgid "Community and Support"
1540
  msgstr ""
1541
 
1542
- #: bp-core/bp-core-admin.php:415
1543
  msgid "Looking for help? The <a href=\"http://codex.buddypress.org/\">BuddyPress Codex</a> has you covered, with dozens of user-contributed guides on how to configure and use your BP site. Can&#8217;t find what you need? Stop by <a href=\"http://buddypress.org/support/\">our support forums</a>, where a vibrant community of BuddyPress users and developers is waiting to share tips, show off their sites, talk about the future of BuddyPress, and much more."
1544
  msgstr ""
1545
 
1546
- #: bp-core/bp-core-admin.php:421
1547
  msgid "Improved Theme Integration"
1548
  msgstr ""
1549
 
1550
- #: bp-core/bp-core-admin.php:424
1551
  msgid "Hey, Good Lookin&#8217;"
1552
  msgstr ""
1553
 
1554
- #: bp-core/bp-core-admin.php:425
1555
  msgid "We&#8217;ve streamlined our stylesheets, so that BuddyPress content looks more at home in your theme. And theme developers will love BP&#8217;s new hierarchies that make it easy to override specific top-level templates, stylesheets, and JavaScript files."
1556
  msgstr ""
1557
 
1558
- #: bp-core/bp-core-admin.php:430
1559
  msgid "Better Group Member Management"
1560
  msgstr ""
1561
 
1562
- #: bp-core/bp-core-admin.php:433
1563
  msgid "<em>Add</em>, <em>Remove</em>, and More, in a Snap"
1564
  msgstr ""
1565
 
1566
- #: bp-core/bp-core-admin.php:436
1567
  msgid "Groups administration panel"
1568
  msgstr ""
1569
 
1570
- #: bp-core/bp-core-admin.php:443
1571
  msgid "The Manage Members section of the %s has been rewritten, to make it easier to handle groups with many members. We&#8217;ve also made the interface nicer to use, to ensure that you don&#8217;t make changes and then forget to save them."
1572
  msgstr ""
1573
 
1574
- #: bp-core/bp-core-admin.php:450
1575
  msgid "Under the Hood"
1576
  msgstr ""
1577
 
1578
- #: bp-core/bp-core-admin.php:454
1579
  msgid "Superpowered Group Extensions"
1580
  msgstr ""
1581
 
1582
- #: bp-core/bp-core-admin.php:455
1583
  msgid "<code>BP_Group_Extension</code> has been overhauled, making it easier than ever before to add custom functionality to groups."
1584
  msgstr ""
1585
 
1586
- #: bp-core/bp-core-admin.php:457
1587
  msgid "Filter Groups or Activity by Metadata"
1588
  msgstr ""
1589
 
1590
- #: bp-core/bp-core-admin.php:458
1591
  msgid "<code>bp_has_groups()</code> and <code>bp_has_activities()</code> now accept a <code>meta_query</code> paramater, for more powerful directory queries."
1592
  msgstr ""
1593
 
1594
- #: bp-core/bp-core-admin.php:462
1595
  msgid "Feed Me, Seymour"
1596
  msgstr ""
1597
 
1598
- #: bp-core/bp-core-admin.php:463
1599
  msgid "The new <code>BP_Activity_Feed</code> class centralizes BP&#8217;s RSS logic, making our feeds more standards-compliant, and giving developers more tools for building custom feeds."
1600
  msgstr ""
1601
 
1602
- #: bp-core/bp-core-admin.php:465
1603
  msgid "Disable @-Mentions"
1604
  msgstr ""
1605
 
1606
- #: bp-core/bp-core-admin.php:466
1607
  msgid "Not using @-mentions? Disable them with <code>add_filter( 'bp_activity_do_mentions', '__return_false' );</code>"
1608
  msgstr ""
1609
 
1610
- #: bp-core/bp-core-admin.php:471 bp-core/bp-core-admin.php:601
1611
  msgid "Go to the BuddyPress Settings page"
1612
  msgstr ""
1613
 
1614
- #: bp-core/bp-core-admin.php:493
1615
  msgid "Thank you for updating to the latest version! BuddyPress %s is ready to make your community a safer, faster, and better looking place to hang out!"
1616
  msgstr ""
1617
 
1618
- #: bp-core/bp-core-admin.php:504
1619
  msgid "BuddyPress is created by a worldwide network of friendly folks."
1620
  msgstr ""
1621
 
1622
- #: bp-core/bp-core-admin.php:506
1623
  msgid "Project Leaders"
1624
  msgstr ""
1625
 
1626
- #: bp-core/bp-core-admin.php:511
1627
  msgid "Founding Developer"
1628
  msgstr ""
1629
 
1630
- #: bp-core/bp-core-admin.php:516
1631
  msgid "Project Lead"
1632
  msgstr ""
1633
 
1634
- #: bp-core/bp-core-admin.php:521 bp-core/bp-core-admin.php:526
1635
  msgid "Lead Developer"
1636
  msgstr ""
1637
 
1638
- #: bp-core/bp-core-admin.php:530
1639
  msgid "Core Developers"
1640
  msgstr ""
1641
 
1642
- #: bp-core/bp-core-admin.php:538
1643
  msgid "Recent Rockstars"
1644
  msgstr ""
1645
 
1646
- #: bp-core/bp-core-admin.php:543
1647
  msgid "Design Officer"
1648
  msgstr ""
1649
 
1650
- #: bp-core/bp-core-admin.php:548
1651
  msgid "Support Officer"
1652
  msgstr ""
1653
 
1654
- #: bp-core/bp-core-admin.php:552
1655
  msgid "Core Contributors to BuddyPress 1.8"
1656
  msgstr ""
1657
 
1658
- #: bp-core/bp-core-adminbar.php:35 bp-core/bp-core-buddybar.php:495
1659
  msgid "My Account"
1660
  msgstr ""
1661
 
1662
- #: bp-core/bp-core-avatars.php:231
1663
  msgid "Avatar Image"
1664
  msgstr ""
1665
 
1666
- #: bp-core/bp-core-avatars.php:499
1667
  msgid "The image was uploaded successfully"
1668
  msgstr ""
1669
 
1670
- #: bp-core/bp-core-avatars.php:500 bp-core/bp-core-avatars.php:501
1671
  msgid "The image exceeds the maximum allowed file size of: "
1672
  msgstr ""
1673
 
1674
- #: bp-core/bp-core-avatars.php:502
1675
  msgid "The uploaded file was only partially uploaded."
1676
  msgstr ""
1677
 
1678
- #: bp-core/bp-core-avatars.php:503
1679
  msgid "The image was not uploaded."
1680
  msgstr ""
1681
 
1682
- #: bp-core/bp-core-avatars.php:504
1683
  msgid "Missing a temporary folder."
1684
  msgstr ""
1685
 
1686
- #: bp-core/bp-core-avatars.php:508
1687
  msgid "Your upload failed, please try again. Error was: %s"
1688
  msgstr ""
1689
 
1690
- #: bp-core/bp-core-avatars.php:513
1691
  msgid "The file you uploaded is too big. Please upload a file under %s"
1692
  msgstr ""
1693
 
1694
- #: bp-core/bp-core-avatars.php:518
1695
  msgid "Please upload only JPG, GIF or PNG photos."
1696
  msgstr ""
1697
 
1698
- #: bp-core/bp-core-avatars.php:535 bp-core/bp-core-avatars.php:572
1699
  msgid "Upload Failed! Error was: %s"
1700
  msgstr ""
1701
 
1702
- #: bp-core/bp-core-avatars.php:590
1703
  msgid "Upload failed! Error was: %s"
1704
  msgstr ""
1705
 
1706
- #: bp-core/bp-core-avatars.php:733 bp-core/bp-core-classes.php:771
1707
- #: bp-core/bp-core-classes.php:772 bp-core/bp-core-classes.php:773
1708
- #: bp-core/bp-core-template.php:98 bp-core/bp-core-template.php:107
1709
  msgid "Avatar of %s"
1710
  msgstr ""
1711
 
1712
- #: bp-core/bp-core-buddybar.php:302
1713
  msgid "You do not have access to this page."
1714
  msgstr ""
1715
 
1716
- #: bp-core/bp-core-buddybar.php:479 bp-themes/bp-default/sidebar.php:52
 
1717
  msgid "Log In"
1718
  msgstr ""
1719
 
1720
- #: bp-core/bp-core-buddybar.php:483
1721
  msgid "Sign Up"
1722
  msgstr ""
1723
 
1724
- #: bp-core/bp-core-buddybar.php:537 bp-core/deprecated/1.5.php:307
 
1725
  #: bp-members/bp-members-template.php:774 bp-themes/bp-default/sidebar.php:18
1726
  msgid "Log Out"
1727
  msgstr ""
1728
 
1729
- #: bp-core/bp-core-buddybar.php:566 bp-groups/bp-groups-admin.php:1335
1730
  msgid "Visit"
1731
  msgstr ""
1732
 
1733
- #: bp-core/bp-core-buddybar.php:568
1734
  msgid "Random Member"
1735
  msgstr ""
1736
 
1737
- #: bp-core/bp-core-buddybar.php:572
1738
  msgid "Random Group"
1739
  msgstr ""
1740
 
1741
- #: bp-core/bp-core-buddybar.php:578
1742
  msgid "Random Site"
1743
  msgstr ""
1744
 
1745
- #: bp-core/bp-core-caps.php:248 bp-core/bp-core-caps.php:261
1746
- #: bp-core/bp-core-caps.php:276 bp-core/bp-core-caps.php:287
1747
  msgid "Special community roles no longer exist. Use mapped capabilities instead"
1748
  msgstr ""
1749
 
1750
- #: bp-core/bp-core-catchuri.php:280
1751
  msgid "This user has been marked as a spammer. Only site admins can view this profile."
1752
  msgstr ""
1753
 
1754
- #: bp-core/bp-core-catchuri.php:466 bp-core/bp-core-catchuri.php:525
1755
  msgid "You must log in to access the page you requested."
1756
  msgstr ""
1757
 
1758
- #: bp-core/bp-core-classes.php:788
1759
  msgid "%d group"
1760
  msgid_plural "%d groups"
1761
  msgstr[0] ""
@@ -1765,11 +1823,11 @@ msgstr[1] ""
1765
  msgid "The current user is being initialized without using $wp->init()."
1766
  msgstr ""
1767
 
1768
- #: bp-core/bp-core-filters.php:216 bp-core/bp-core-filters.php:240
1769
  msgid "[User Set]"
1770
  msgstr ""
1771
 
1772
- #: bp-core/bp-core-filters.php:258
1773
  msgid ""
1774
  "Thanks for registering! To complete the activation of your account and blog, please click the following link:\n"
1775
  "\n"
@@ -1782,11 +1840,11 @@ msgid ""
1782
  "%2$s"
1783
  msgstr ""
1784
 
1785
- #: bp-core/bp-core-filters.php:259
1786
  msgid "Activate %s"
1787
  msgstr ""
1788
 
1789
- #: bp-core/bp-core-filters.php:286 bp-members/bp-members-functions.php:1390
1790
  msgid ""
1791
  "Thanks for registering! To complete the activation of your account please click the following link:\n"
1792
  "\n"
@@ -1794,157 +1852,161 @@ msgid ""
1794
  "\n"
1795
  msgstr ""
1796
 
1797
- #: bp-core/bp-core-filters.php:287 bp-members/bp-members-functions.php:1391
1798
  msgid "Activate Your Account"
1799
  msgstr ""
1800
 
1801
- #: bp-core/bp-core-filters.php:343
1802
  msgctxt "Construct the page title. 1 = user name, 2 = component name, 3 = seperator"
1803
  msgid "%1$s %3$s %2$s"
1804
  msgstr ""
1805
 
1806
  #. translators: "group name | group nav section name"
1807
 
1808
- #: bp-core/bp-core-filters.php:349
1809
  msgid "%1$s | %2$s"
1810
  msgstr ""
1811
 
1812
  #. translators: "component item name | component nav section name | root
1813
  #. component name"
1814
 
1815
- #: bp-core/bp-core-filters.php:354
1816
  msgid "%1$s | %2$s | %3$s"
1817
  msgstr ""
1818
 
1819
- #: bp-core/bp-core-filters.php:359 bp-core/bp-core-filters.php:361
1820
  msgid "%s Directory"
1821
  msgstr ""
1822
 
1823
- #: bp-core/bp-core-filters.php:366 bp-members/bp-members-screens.php:512
1824
  #: bp-themes/bp-default/registration/register.php:23
1825
  msgid "Create an Account"
1826
  msgstr ""
1827
 
1828
- #: bp-core/bp-core-filters.php:370 bp-members/bp-members-screens.php:520
1829
  #: bp-themes/bp-default/registration/activate.php:13
1830
  msgid "Activate your Account"
1831
  msgstr ""
1832
 
1833
- #: bp-core/bp-core-filters.php:374 bp-groups/bp-groups-loader.php:554
1834
- #: bp-groups/bp-groups-screens.php:1027 bp-groups/bp-groups-screens.php:1088
1835
  #: bp-themes/bp-default/groups/create.php:18
1836
  #: bp-themes/bp-default/groups/index.php:21
1837
  msgid "Create a Group"
1838
  msgstr ""
1839
 
1840
- #: bp-core/bp-core-functions.php:322
1841
  msgctxt "Page title for the Activity directory."
1842
  msgid "Activity"
1843
  msgstr ""
1844
 
1845
- #: bp-core/bp-core-functions.php:323
1846
  msgctxt "Page title for the Groups directory."
1847
  msgid "Groups"
1848
  msgstr ""
1849
 
1850
- #: bp-core/bp-core-functions.php:324
1851
  msgctxt "Page title for the Sites directory."
1852
  msgid "Sites"
1853
  msgstr ""
1854
 
1855
- #: bp-core/bp-core-functions.php:325
1856
  msgctxt "Page title for the user account activation screen."
1857
  msgid "Activate"
1858
  msgstr ""
1859
 
1860
- #: bp-core/bp-core-functions.php:326
1861
  msgctxt "Page title for the Members directory."
1862
  msgid "Members"
1863
  msgstr ""
1864
 
1865
- #: bp-core/bp-core-functions.php:327
1866
  msgctxt "Page title for the user registration screen."
1867
  msgid "Register"
1868
  msgstr ""
1869
 
1870
- #: bp-core/bp-core-functions.php:592
1871
  msgid "sometime"
1872
  msgstr ""
1873
 
1874
- #: bp-core/bp-core-functions.php:593
1875
  msgid "right now"
1876
  msgstr ""
1877
 
1878
- #: bp-core/bp-core-functions.php:594
1879
  msgid "%s ago"
1880
  msgstr ""
1881
 
1882
- #: bp-core/bp-core-functions.php:655
1883
  msgid "%s year"
1884
  msgid_plural "%s years"
1885
  msgstr[0] ""
1886
  msgstr[1] ""
1887
 
1888
- #: bp-core/bp-core-functions.php:658 bp-core/bp-core-functions.php:692
1889
  msgid "%s month"
1890
  msgid_plural "%s months"
1891
  msgstr[0] ""
1892
  msgstr[1] ""
1893
 
1894
- #: bp-core/bp-core-functions.php:661 bp-core/bp-core-functions.php:695
1895
  msgid "%s week"
1896
  msgid_plural "%s weeks"
1897
  msgstr[0] ""
1898
  msgstr[1] ""
1899
 
1900
- #: bp-core/bp-core-functions.php:664 bp-core/bp-core-functions.php:698
1901
  msgid "%s day"
1902
  msgid_plural "%s days"
1903
  msgstr[0] ""
1904
  msgstr[1] ""
1905
 
1906
- #: bp-core/bp-core-functions.php:667 bp-core/bp-core-functions.php:701
1907
  msgid "%s hour"
1908
  msgid_plural "%s hours"
1909
  msgstr[0] ""
1910
  msgstr[1] ""
1911
 
1912
- #: bp-core/bp-core-functions.php:670 bp-core/bp-core-functions.php:704
1913
  msgid "%s minute"
1914
  msgid_plural "%s minutes"
1915
  msgstr[0] ""
1916
  msgstr[1] ""
1917
 
1918
- #: bp-core/bp-core-functions.php:673 bp-core/bp-core-functions.php:707
1919
  msgid "%s second"
1920
  msgid_plural "%s seconds"
1921
  msgstr[0] ""
1922
  msgstr[1] ""
1923
 
1924
- #: bp-core/bp-core-functions.php:688
1925
  msgctxt "Separator in time since"
1926
  msgid ","
1927
  msgstr ""
1928
 
1929
- #: bp-core/bp-core-functions.php:866
1930
  msgid "Not recently active"
1931
  msgstr ""
1932
 
1933
- #: bp-core/bp-core-loader.php:215 bp-members/bp-members-loader.php:158
1934
- #: bp-xprofile/bp-xprofile-loader.php:154
1935
- #: bp-xprofile/bp-xprofile-loader.php:229
1936
  msgid "Profile"
1937
  msgstr ""
1938
 
1939
- #: bp-core/bp-core-template.php:65
1940
  msgid "Options"
1941
  msgstr ""
1942
 
1943
- #: bp-core/bp-core-template.php:191
1944
  msgid "%1$s at %2$s"
1945
  msgstr ""
1946
 
1947
- #: bp-core/bp-core-template.php:254
 
 
 
 
1948
  #: bp-templates/bp-legacy/buddypress/activity/index.php:83
1949
  #: bp-templates/bp-legacy/buddypress/forums/forums-loop.php:40
1950
  #: bp-templates/bp-legacy/buddypress/members/single/activity.php:27
@@ -1954,34 +2016,75 @@ msgstr ""
1954
  msgid "Posts"
1955
  msgstr ""
1956
 
1957
- #: bp-core/bp-core-template.php:257
1958
  msgid "Search these:"
1959
  msgstr ""
1960
 
1961
- #: bp-core/bp-core-template.php:285
1962
  msgid "Search anything..."
1963
  msgstr ""
1964
 
1965
- #: bp-core/bp-core-template.php:379
1966
  msgid " [&hellip;]"
1967
  msgstr ""
1968
 
1969
- #: bp-core/bp-core-template.php:557
1970
  msgid "Community"
1971
  msgstr ""
1972
 
1973
- #: bp-core/bp-core-widgets.php:19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1974
  msgid "A dynamic list of recently active, popular, and newest members"
1975
  msgstr ""
1976
 
1977
- #: bp-core/bp-core-widgets.php:22
1978
  msgctxt "widget name"
1979
  msgid "(BuddyPress) Members"
1980
  msgstr ""
1981
 
1982
- #: bp-core/bp-core-widgets.php:49 bp-core/bp-core-widgets.php:135
1983
  #: bp-core/deprecated/1.6.php:129 bp-core/deprecated/1.6.php:152
1984
- #: bp-groups/bp-groups-widgets.php:60 bp-groups/bp-groups-widgets.php:141
 
1985
  #: bp-templates/bp-legacy/buddypress/blogs/index.php:39
1986
  #: bp-templates/bp-legacy/buddypress/members/single/blogs.php:22
1987
  #: bp-themes/bp-default/blogs/index.php:56
@@ -1989,78 +2092,73 @@ msgstr ""
1989
  msgid "Newest"
1990
  msgstr ""
1991
 
1992
- #: bp-core/bp-core-widgets.php:50 bp-core/bp-core-widgets.php:136
1993
- #: bp-groups/bp-groups-widgets.php:61 bp-groups/bp-groups-widgets.php:142
 
1994
  msgid "Active"
1995
  msgstr ""
1996
 
1997
- #: bp-core/bp-core-widgets.php:54 bp-core/bp-core-widgets.php:137
1998
- #: bp-groups/bp-groups-widgets.php:62 bp-groups/bp-groups-widgets.php:143
 
1999
  msgid "Popular"
2000
  msgstr ""
2001
 
2002
- #: bp-core/bp-core-widgets.php:91
2003
  msgid "No one has signed up yet!"
2004
  msgstr ""
2005
 
2006
- #: bp-core/bp-core-widgets.php:126 bp-core/bp-core-widgets.php:208
2007
- #: bp-core/bp-core-widgets.php:277 bp-groups/bp-groups-widgets.php:132
2008
- #: bp-templates/bp-legacy/buddypress/forums/index.php:86
2009
- #: bp-templates/bp-legacy/buddypress/groups/single/forum/edit.php:47
2010
- #: bp-templates/bp-legacy/buddypress/groups/single/forum.php:75
2011
- #: bp-themes/bp-default/forums/index.php:104
2012
- #: bp-themes/bp-default/groups/single/forum/edit.php:47
2013
- #: bp-themes/bp-default/groups/single/forum.php:75
2014
- msgid "Title:"
2015
- msgstr ""
2016
-
2017
- #: bp-core/bp-core-widgets.php:128
2018
  msgid "Link widget title to Members directory"
2019
  msgstr ""
2020
 
2021
- #: bp-core/bp-core-widgets.php:130
2022
  msgid "Max members to show:"
2023
  msgstr ""
2024
 
2025
- #: bp-core/bp-core-widgets.php:133
2026
  msgid "Default members to show:"
2027
  msgstr ""
2028
 
2029
- #: bp-core/bp-core-widgets.php:152
2030
  msgid "Avatars of users who are currently online"
2031
  msgstr ""
2032
 
2033
- #: bp-core/bp-core-widgets.php:155
2034
  msgctxt "widget name"
2035
  msgid "(BuddyPress) Who's Online"
2036
  msgstr ""
2037
 
2038
- #: bp-core/bp-core-widgets.php:180
2039
  msgid "There are no users currently online"
2040
  msgstr ""
2041
 
2042
- #: bp-core/bp-core-widgets.php:199
2043
  msgid "Who's Online"
2044
  msgstr ""
2045
 
2046
- #: bp-core/bp-core-widgets.php:210 bp-core/bp-core-widgets.php:279
2047
  msgid "Max Members to show:"
2048
  msgstr ""
2049
 
2050
- #: bp-core/bp-core-widgets.php:221
2051
  msgid "Avatars of recently active members"
2052
  msgstr ""
2053
 
2054
- #: bp-core/bp-core-widgets.php:224
2055
  msgctxt "widget name"
2056
  msgid "(BuddyPress) Recently Active Members"
2057
  msgstr ""
2058
 
2059
- #: bp-core/bp-core-widgets.php:249
2060
  msgid "There are no recently active members"
2061
  msgstr ""
2062
 
2063
- #: bp-core/bp-core-widgets.php:331
 
 
 
 
2064
  msgid "There were no members found, please try another filter."
2065
  msgstr ""
2066
 
@@ -2069,7 +2167,7 @@ msgstr ""
2069
  #: bp-templates/bp-legacy/buddypress/members/single/profile/profile-wp.php:8
2070
  #: bp-themes/bp-default/activity/post-form.php:45
2071
  #: bp-themes/bp-default/members/single/profile/profile-wp.php:8
2072
- #: bp-xprofile/bp-xprofile-loader.php:272
2073
  msgid "My Profile"
2074
  msgstr ""
2075
 
@@ -2116,64 +2214,64 @@ msgid "%1$s mentioned you in the group \"%2$s\""
2116
  msgstr ""
2117
 
2118
  #: bp-core/deprecated/1.6.php:128 bp-core/deprecated/1.6.php:149
2119
- #: bp-groups/bp-groups-template.php:2518 bp-groups/bp-groups-template.php:2540
2120
  msgid "Recently Active"
2121
  msgstr ""
2122
 
2123
  #: bp-core/deprecated/1.6.php:130 bp-core/deprecated/1.6.php:155
2124
- #: bp-groups/bp-groups-template.php:2523 bp-groups/bp-groups-template.php:2555
2125
  msgid "Alphabetically"
2126
  ms
3
  msgid ""
4
  msgstr ""
5
  "Project-Id-Version: BuddyPress \n"
6
+ "Report-Msgid-Bugs-To: http://make.wordpress.org/polyglots\n"
7
+ "POT-Creation-Date: 2013-11-16 23:36:46+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
20
  msgid "There was an error when deleting that activity"
21
  msgstr ""
22
 
23
+ #: bp-activity/bp-activity-actions.php:214
24
  msgid "The activity item has been marked as spam and is no longer visible."
25
  msgstr ""
26
 
27
+ #: bp-activity/bp-activity-actions.php:269
28
+ #: bp-templates/bp-legacy/buddypress-functions.php:625
29
  #: bp-themes/bp-default/_inc/ajax.php:276
30
  msgid "Please enter some content to post."
31
  msgstr ""
32
 
33
+ #: bp-activity/bp-activity-actions.php:290
34
  msgid "Update Posted!"
35
  msgstr ""
36
 
37
+ #: bp-activity/bp-activity-actions.php:292
38
  msgid "There was an error when posting your update, please try again."
39
  msgstr ""
40
 
41
+ #: bp-activity/bp-activity-actions.php:329
42
+ #: bp-templates/bp-legacy/buddypress-functions.php:673
43
  #: bp-themes/bp-default/_inc/ajax.php:324
44
  msgid "Please do not leave the comment area blank."
45
  msgstr ""
46
 
47
+ #: bp-activity/bp-activity-actions.php:340
48
  msgid "Reply Posted!"
49
  msgstr ""
50
 
51
+ #: bp-activity/bp-activity-actions.php:342
52
+ #: bp-templates/bp-legacy/buddypress-functions.php:676
53
+ #: bp-templates/bp-legacy/buddypress-functions.php:685
54
  #: bp-themes/bp-default/_inc/ajax.php:327
55
  #: bp-themes/bp-default/_inc/ajax.php:336
56
  msgid "There was an error posting that reply, please try again."
57
  msgstr ""
58
 
59
+ #: bp-activity/bp-activity-actions.php:374
60
  msgid "Activity marked as favorite."
61
  msgstr ""
62
 
63
+ #: bp-activity/bp-activity-actions.php:376
64
  msgid "There was an error marking that activity as a favorite, please try again."
65
  msgstr ""
66
 
67
+ #: bp-activity/bp-activity-actions.php:408
68
  msgid "Activity removed as favorite."
69
  msgstr ""
70
 
71
+ #: bp-activity/bp-activity-actions.php:410
72
  msgid "There was an error removing that activity as a favorite, please try again."
73
  msgstr ""
74
 
75
  #. translators: Sitewide activity RSS title - "[Site Name] | Site Wide
76
  #. Activity"
77
 
78
+ #: bp-activity/bp-activity-actions.php:440
79
  msgid "%s | Site Wide Activity"
80
  msgstr ""
81
 
82
+ #: bp-activity/bp-activity-actions.php:443
83
  msgid "Activity feed for the entire site."
84
  msgstr ""
85
 
88
  #. translators: Group activity RSS title - "[Site Name] | [Group Name] |
89
  #. Activity"
90
 
91
+ #: bp-activity/bp-activity-actions.php:470 bp-groups/bp-groups-actions.php:356
92
  msgid "%1$s | %2$s | Activity"
93
  msgstr ""
94
 
95
+ #: bp-activity/bp-activity-actions.php:473
96
  msgid "Activity feed for %s."
97
  msgstr ""
98
 
99
  #. translators: Friends activity RSS title - "[Site Name] | [User Display Name]
100
  #. | Friends Activity"
101
 
102
+ #: bp-activity/bp-activity-actions.php:503
103
  msgid "%1$s | %2$s | Friends Activity"
104
  msgstr ""
105
 
106
+ #: bp-activity/bp-activity-actions.php:506
107
  msgid "Activity feed for %s's friends."
108
  msgstr ""
109
 
110
  #. translators: Member groups activity RSS title - "[Site Name] | [User Display
111
  #. Name] | Groups Activity"
112
 
113
+ #: bp-activity/bp-activity-actions.php:540
114
  msgid "%1$s | %2$s | Group Activity"
115
  msgstr ""
116
 
117
+ #: bp-activity/bp-activity-actions.php:543
118
  msgid "Public group activity feed of which %s is a member of."
119
  msgstr ""
120
 
121
+ #. translators: User mentions activity RSS title - "[Site Name] | [User Display
122
+ #. Name] | Mentions"
123
+
124
+ #: bp-activity/bp-activity-actions.php:579
125
+ msgid "%1$s | %2$s | Mentions"
126
+ msgstr ""
127
+
128
+ #: bp-activity/bp-activity-actions.php:582
129
+ msgid "Activity feed mentioning %s."
130
+ msgstr ""
131
+
132
  #. translators: User activity favorites RSS title - "[Site Name] | [User
133
  #. Display Name] | Favorites"
134
 
135
+ #: bp-activity/bp-activity-actions.php:616
136
  msgid "%1$s | %2$s | Favorites"
137
  msgstr ""
138
 
139
+ #: bp-activity/bp-activity-actions.php:619
140
  msgid "Activity feed of %s's favorites."
141
  msgstr ""
142
 
143
+ #: bp-activity/bp-activity-admin.php:32 bp-activity/bp-activity-admin.php:33
144
+ #: bp-activity/bp-activity-admin.php:871 bp-activity/bp-activity-admin.php:1204
145
+ #: bp-activity/bp-activity-loader.php:132
146
+ #: bp-activity/bp-activity-loader.php:261
147
  #: bp-activity/bp-activity-screens.php:284
148
+ #: bp-activity/bp-activity-screens.php:451 bp-core/bp-core-admin.php:434
149
  msgid "Activity"
150
  msgstr ""
151
 
152
+ #: bp-activity/bp-activity-admin.php:88
153
  msgid "ERROR: Please type a reply."
154
  msgstr ""
155
 
156
+ #: bp-activity/bp-activity-admin.php:93
157
  msgid "ERROR: The item you are trying to reply to cannot be found, or it has been deleted."
158
  msgstr ""
159
 
160
+ #: bp-activity/bp-activity-admin.php:209 bp-activity/bp-activity-admin.php:256
 
161
  #: bp-core/admin/bp-core-functions.php:430
162
+ #: bp-core/admin/bp-core-functions.php:448
163
+ #: bp-core/admin/bp-core-functions.php:467
164
+ #: bp-core/admin/bp-core-functions.php:486 bp-groups/bp-groups-admin.php:112
165
+ #: bp-groups/bp-groups-admin.php:148
166
  msgid "Overview"
167
  msgstr ""
168
 
169
+ #: bp-activity/bp-activity-admin.php:211
170
  msgid "You edit activities made on your site similar to the way you edit a comment. This is useful if you need to change which page the activity links to, or when you notice that the author has made a typographical error."
171
  msgstr ""
172
 
173
+ #: bp-activity/bp-activity-admin.php:212
174
  msgid "The two big editing areas for the activity title and content are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Primary Item/Secondary Item, Link, Type, Author ID) or to choose a 1- or 2-column layout for this screen."
175
  msgstr ""
176
 
177
+ #: bp-activity/bp-activity-admin.php:213
178
  msgid "You can also moderate the activity from this screen using the Status box, where you can also change the timestamp of the activity."
179
  msgstr ""
180
 
181
+ #: bp-activity/bp-activity-admin.php:218
182
  msgid "Item, Link, Type"
183
  msgstr ""
184
 
185
+ #: bp-activity/bp-activity-admin.php:220
186
  msgid "<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields."
187
  msgstr ""
188
 
189
+ #: bp-activity/bp-activity-admin.php:221
190
+ msgid "<strong>Link</strong> - Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set."
191
  msgstr ""
192
 
193
+ #: bp-activity/bp-activity-admin.php:222
194
  msgid "<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group."
195
  msgstr ""
196
 
197
+ #: bp-activity/bp-activity-admin.php:223
198
  msgid "For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side."
199
  msgstr ""
200
 
201
+ #: bp-activity/bp-activity-admin.php:228 bp-activity/bp-activity-admin.php:273
 
202
  #: bp-core/admin/bp-core-functions.php:436
203
+ #: bp-core/admin/bp-core-functions.php:454
204
+ #: bp-core/admin/bp-core-functions.php:473
205
+ #: bp-core/admin/bp-core-functions.php:492 bp-groups/bp-groups-admin.php:120
206
+ #: bp-groups/bp-groups-admin.php:164
207
  msgid "For more information:"
208
  msgstr ""
209
 
210
+ #: bp-activity/bp-activity-admin.php:229
211
  msgid "<a href=\"http://codex.buddypress.org/buddypress-site-administration/managing-activity/\">Managing Activity</a>"
212
  msgstr ""
213
 
214
+ #: bp-activity/bp-activity-admin.php:230 bp-activity/bp-activity-admin.php:274
 
215
  #: bp-core/admin/bp-core-functions.php:438
216
+ #: bp-core/admin/bp-core-functions.php:456
217
+ #: bp-core/admin/bp-core-functions.php:475
218
+ #: bp-core/admin/bp-core-functions.php:494 bp-groups/bp-groups-admin.php:165
219
  msgid "<a href=\"http://buddypress.org/support/\">Support Forums</a>"
220
  msgstr ""
221
 
222
+ #: bp-activity/bp-activity-admin.php:234
223
  msgctxt "activity admin edit screen"
224
  msgid "Status"
225
  msgstr ""
226
 
227
+ #: bp-activity/bp-activity-admin.php:235
228
  msgctxt "activity admin edit screen"
229
  msgid "Primary Item/Secondary Item"
230
  msgstr ""
231
 
232
+ #: bp-activity/bp-activity-admin.php:236
233
  msgctxt "activity admin edit screen"
234
  msgid "Link"
235
  msgstr ""
236
 
237
+ #: bp-activity/bp-activity-admin.php:237
238
  msgctxt "activity admin edit screen"
239
  msgid "Type"
240
  msgstr ""
241
 
242
+ #: bp-activity/bp-activity-admin.php:238
243
  msgctxt "activity admin edit screen"
244
  msgid "Author ID"
245
  msgstr ""
246
 
247
+ #: bp-activity/bp-activity-admin.php:251
248
  msgctxt "Activity items per page (screen options)"
249
  msgid "Activity"
250
  msgstr ""
251
 
252
+ #: bp-activity/bp-activity-admin.php:258
253
  msgid "You can manage activities made on your site similar to the way you manage comments and other content. This screen is customizable in the same ways as other management screens, and you can act on activities using the on-hover action links or the Bulk Actions."
254
  msgstr ""
255
 
256
+ #: bp-activity/bp-activity-admin.php:259
257
  msgid "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."
258
  msgstr ""
259
 
260
+ #: bp-activity/bp-activity-admin.php:265
261
  msgid "Moderating Activity"
262
  msgstr ""
263
 
264
+ #: bp-activity/bp-activity-admin.php:267
265
  msgid "In the <strong>Activity</strong> column, above each activity it says &#8220;Submitted on,&#8221; followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity."
266
  msgstr ""
267
 
268
+ #: bp-activity/bp-activity-admin.php:268
269
  msgid "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."
270
  msgstr ""
271
 
272
+ #: bp-activity/bp-activity-admin.php:593
273
  msgid "Editing Activity (ID #%s)"
274
  msgstr ""
275
 
276
+ #: bp-activity/bp-activity-admin.php:604
277
  msgid "Action"
278
  msgstr ""
279
 
280
+ #: bp-activity/bp-activity-admin.php:611
281
  msgid "Content"
282
  msgstr ""
283
 
284
+ #: bp-activity/bp-activity-admin.php:636
285
  msgid "No activity found with this ID. <a href=\"%s\">Go back and try again</a>."
286
  msgstr ""
287
 
288
+ #: bp-activity/bp-activity-admin.php:659
289
  msgid "View Activity"
290
  msgstr ""
291
 
292
+ #: bp-activity/bp-activity-admin.php:667
293
  msgid "Approved"
294
  msgstr ""
295
 
296
+ #: bp-activity/bp-activity-admin.php:668 bp-activity/bp-activity-admin.php:1336
297
+ #: bp-activity/bp-activity-akismet.php:197
298
+ #: bp-activity/bp-activity-akismet.php:226
299
  msgid "Spam"
300
  msgstr ""
301
 
302
  #. translators: Publish box date format, see http:php.net/date
303
 
304
+ #: bp-activity/bp-activity-admin.php:674
305
  msgid "M j, Y @ G:i"
306
  msgstr ""
307
 
308
+ #: bp-activity/bp-activity-admin.php:677
309
  msgid "Submitted on: <strong>%1$s</strong>"
310
  msgstr ""
311
 
312
+ #: bp-activity/bp-activity-admin.php:677 bp-activity/bp-activity-admin.php:1329
313
+ #: bp-forums/bp-forums-template.php:2112 bp-groups/bp-groups-admin.php:1391
314
  #: bp-themes/bp-default/functions.php:509 bp-xprofile/bp-xprofile-admin.php:456
315
+ #: bp-xprofile/bp-xprofile-loader.php:193
316
+ #: bp-xprofile/bp-xprofile-loader.php:251
317
  msgid "Edit"
318
  msgstr ""
319
 
320
+ #: bp-activity/bp-activity-admin.php:690
321
  msgid "Update"
322
  msgstr ""
323
 
324
+ #: bp-activity/bp-activity-admin.php:710
325
  msgid "Link"
326
  msgstr ""
327
 
328
+ #: bp-activity/bp-activity-admin.php:712
329
+ msgid "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."
330
  msgstr ""
331
 
332
+ #: bp-activity/bp-activity-admin.php:727
333
  msgid "Author ID"
334
  msgstr ""
335
 
336
+ #: bp-activity/bp-activity-admin.php:781
337
  msgid "Primary Item ID"
338
  msgstr ""
339
 
340
+ #: bp-activity/bp-activity-admin.php:785
341
  msgid "Secondary Item ID"
342
  msgstr ""
343
 
344
+ #: bp-activity/bp-activity-admin.php:788
345
  msgid "These identify the object that created this activity. For example, the fields could reference a pair of site and comment IDs."
346
  msgstr ""
347
 
348
+ #: bp-activity/bp-activity-admin.php:828
349
  msgid "%s activity item has been permanently deleted."
350
  msgid_plural "%s activity items have been permanently deleted."
351
  msgstr[0] ""
352
  msgstr[1] ""
353
 
354
+ #: bp-activity/bp-activity-admin.php:832
355
  msgid "An error occurred when trying to update activity ID #%s."
356
  msgstr ""
357
 
358
+ #: bp-activity/bp-activity-admin.php:835
359
  msgid "Errors occurred when trying to update these activity items:"
360
  msgstr ""
361
 
362
  #. Translators: This is a bulleted list of item IDs
363
 
364
+ #: bp-activity/bp-activity-admin.php:841
365
  msgid "#%s"
366
  msgstr ""
367
 
368
+ #: bp-activity/bp-activity-admin.php:850
369
  msgid "%s activity item has been successfully spammed."
370
  msgid_plural "%s activity items have been successfully spammed."
371
  msgstr[0] ""
372
  msgstr[1] ""
373
 
374
+ #: bp-activity/bp-activity-admin.php:853
375
  msgid "%s activity item has been successfully unspammed."
376
  msgid_plural "%s activity items have been successfully unspammed."
377
  msgstr[0] ""
378
  msgstr[1] ""
379
 
380
+ #: bp-activity/bp-activity-admin.php:856
381
  msgid "The activity item has been updated succesfully."
382
  msgstr ""
383
 
384
+ #: bp-activity/bp-activity-admin.php:869
385
  msgid "Activity related to ID #%s"
386
  msgstr ""
387
 
388
+ #: bp-activity/bp-activity-admin.php:875 bp-groups/bp-groups-admin.php:645
389
  msgid "Search results for &#8220;%s&#8221;"
390
  msgstr ""
391
 
392
+ #: bp-activity/bp-activity-admin.php:888
393
  msgid "Search all Activity"
394
  msgstr ""
395
 
396
+ #: bp-activity/bp-activity-admin.php:899
397
  msgid "Reply to Activity"
398
  msgstr ""
399
 
400
+ #: bp-activity/bp-activity-admin.php:903 bp-groups/bp-groups-admin.php:599
401
  #: bp-templates/bp-legacy/buddypress/activity/entry.php:102
402
  #: bp-templates/bp-legacy/buddypress/forums/index.php:116
403
  #: bp-themes/bp-default/forums/index.php:134
404
+ #: bp-xprofile/bp-xprofile-classes.php:407
405
+ #: bp-xprofile/bp-xprofile-classes.php:877
406
  msgid "Cancel"
407
  msgstr ""
408
 
409
+ #: bp-activity/bp-activity-admin.php:904 bp-activity/bp-activity-admin.php:1326
410
  #: bp-templates/bp-legacy/buddypress/activity/comment.php:37
411
  #: bp-templates/bp-legacy/buddypress/groups/single/forum/edit.php:10
412
  #: bp-themes/bp-default/activity/comment.php:40
414
  msgid "Reply"
415
  msgstr ""
416
 
417
+ #: bp-activity/bp-activity-admin.php:1094
418
  msgid "No activities found."
419
  msgstr ""
420
 
421
+ #: bp-activity/bp-activity-admin.php:1167 bp-groups/bp-groups-admin.php:1262
422
+ #: bp-messages/bp-messages-template.php:481
423
  msgid "All"
424
  msgstr ""
425
 
426
+ #: bp-activity/bp-activity-admin.php:1168
427
  msgid "Spam <span class=\"count\">(%s)</span>"
428
  msgstr ""
429
 
430
+ #: bp-activity/bp-activity-admin.php:1184
431
  msgid "Mark as Spam"
432
  msgstr ""
433
 
434
+ #: bp-activity/bp-activity-admin.php:1185
435
+ #: bp-activity/bp-activity-admin.php:1334
436
  msgid "Not Spam"
437
  msgstr ""
438
 
439
+ #: bp-activity/bp-activity-admin.php:1186
440
+ #: bp-activity/bp-activity-admin.php:1339 bp-groups/bp-groups-admin.php:598
441
  msgid "Delete Permanently"
442
  msgstr ""
443
 
444
+ #: bp-activity/bp-activity-admin.php:1203
445
  msgid "Author"
446
  msgstr ""
447
 
448
+ #: bp-activity/bp-activity-admin.php:1205
449
  msgid "In Response To"
450
  msgstr ""
451
 
452
+ #: bp-activity/bp-activity-admin.php:1248
453
  msgid "Show all activity types"
454
  msgstr ""
455
 
456
+ #: bp-activity/bp-activity-admin.php:1255
457
  msgid "Filter"
458
  msgstr ""
459
 
460
+ #: bp-activity/bp-activity-admin.php:1271
461
  msgid "Select activity item %1$d"
462
  msgstr ""
463
 
464
+ #: bp-activity/bp-activity-admin.php:1339 bp-core/bp-core-cssjs.php:29
465
  msgid "Are you sure?"
466
  msgstr ""
467
 
468
  #. translators: 2: activity admin ui date/time
469
 
470
+ #: bp-activity/bp-activity-admin.php:1348
471
  msgid "Submitted on <a href=\"%1$s\">%2$s at %3$s</a>"
472
  msgstr ""
473
 
474
+ #: bp-activity/bp-activity-admin.php:1380
475
  msgid "%s related activity"
476
  msgid_plural "%s related activities"
477
  msgstr[0] ""
478
  msgstr[1] ""
479
 
480
+ #: bp-activity/bp-activity-admin.php:1391
481
  msgid "<a href=\"%1$s\">View Activity</a>"
482
  msgstr ""
483
 
484
+ #: bp-activity/bp-activity-akismet.php:86
485
  msgid "Flagged as spam by Akismet"
486
  msgstr ""
487
 
488
+ #: bp-activity/bp-activity-akismet.php:89
489
  msgid "Cleared by Akismet"
490
  msgstr ""
491
 
492
+ #: bp-activity/bp-activity-akismet.php:95
493
  msgid "Flagged as spam by %s"
494
  msgstr ""
495
 
496
+ #: bp-activity/bp-activity-akismet.php:97
497
  msgid "Un-spammed by %s"
498
  msgstr ""
499
 
500
+ #: bp-activity/bp-activity-akismet.php:106
501
  msgid "History"
502
  msgstr ""
503
 
504
+ #: bp-activity/bp-activity-akismet.php:373
505
  msgid "%s reported this activity as spam"
506
  msgstr ""
507
 
508
+ #: bp-activity/bp-activity-akismet.php:390
509
  msgid "%s reported this activity as not spam"
510
  msgstr ""
511
 
512
+ #: bp-activity/bp-activity-akismet.php:414
513
  msgid "Akismet caught this item as spam"
514
  msgstr ""
515
 
516
+ #: bp-activity/bp-activity-akismet.php:419
517
  msgid "Akismet cleared this item"
518
  msgstr ""
519
 
520
+ #: bp-activity/bp-activity-akismet.php:424
521
  msgid "Akismet was unable to check this item (response: %s), will automatically retry again later."
522
  msgstr ""
523
 
524
+ #: bp-activity/bp-activity-akismet.php:538
525
  msgid "Activity History"
526
  msgstr ""
527
 
528
+ #: bp-activity/bp-activity-akismet.php:558
529
  msgctxt "x hours ago - akismet cleared this item"
530
  msgid "<span>%1$s</span> &mdash; %2$s"
531
  msgstr ""
532
 
533
+ #: bp-activity/bp-activity-classes.php:257
534
+ #: bp-activity/bp-activity-template.php:143 bp-groups/bp-groups-classes.php:340
535
  #: bp-groups/bp-groups-template.php:114
536
  msgid "Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details."
537
  msgstr ""
538
 
539
+ #: bp-activity/bp-activity-classes.php:1151
540
  msgid "RSS feed 'id' must be defined"
541
  msgstr ""
542
 
543
+ #: bp-activity/bp-activity-classes.php:1264
544
  msgid "In reply to"
545
  msgstr ""
546
 
552
  msgid "&hellip;"
553
  msgstr ""
554
 
555
+ #: bp-activity/bp-activity-functions.php:219
556
  msgid "@%s Mentions"
557
  msgstr ""
558
 
559
+ #: bp-activity/bp-activity-functions.php:222
560
  msgid "You have %1$d new mentions"
561
  msgstr ""
562
 
563
+ #: bp-activity/bp-activity-functions.php:226
564
  msgid "%1$s mentioned you"
565
  msgstr ""
566
 
567
+ #: bp-activity/bp-activity-functions.php:928
568
  msgid "Posted a status update"
569
  msgstr ""
570
 
571
+ #: bp-activity/bp-activity-functions.php:929
572
  msgid "Replied to a status update"
573
  msgstr ""
574
 
575
+ #: bp-activity/bp-activity-functions.php:1217
576
  msgid "%s posted an update"
577
  msgstr ""
578
 
579
+ #: bp-activity/bp-activity-functions.php:1295
580
  #: tests/testcases/activity/class.BP_Activity_Activity.php:202
581
  msgid "%s posted a new activity comment"
582
  msgstr ""
583
 
584
+ #: bp-activity/bp-activity-functions.php:1681
585
  msgid "Thumbnail"
586
  msgstr ""
587
 
588
  #: bp-activity/bp-activity-loader.php:30
589
+ #: bp-core/admin/bp-core-components.php:379
590
  msgid "Activity Streams"
591
  msgstr ""
592
 
593
+ #: bp-activity/bp-activity-loader.php:104
594
  msgid "Search Activity..."
595
  msgstr ""
596
 
597
+ #: bp-activity/bp-activity-loader.php:158
598
+ #: bp-activity/bp-activity-loader.php:279
599
  msgid "Personal"
600
  msgstr ""
601
 
602
+ #: bp-activity/bp-activity-loader.php:169
603
+ #: bp-activity/bp-activity-loader.php:253
604
  #: bp-templates/bp-legacy/buddypress/activity/index.php:59
605
  #: bp-themes/bp-default/activity/index.php:79
606
  msgid "Mentions"
607
  msgstr ""
608
 
609
+ #: bp-activity/bp-activity-loader.php:181
610
+ #: bp-activity/bp-activity-loader.php:287
611
  msgid "Favorites"
612
  msgstr ""
613
 
614
+ #: bp-activity/bp-activity-loader.php:193
615
+ #: bp-activity/bp-activity-loader.php:296 bp-friends/bp-friends-loader.php:185
616
+ #: bp-friends/bp-friends-screens.php:92
617
  msgid "Friends"
618
  msgstr ""
619
 
620
+ #: bp-activity/bp-activity-loader.php:206
621
+ #: bp-activity/bp-activity-loader.php:306 bp-core/bp-core-template.php:364
622
+ #: bp-groups/bp-groups-activity.php:179 bp-groups/bp-groups-activity.php:215
623
+ #: bp-groups/bp-groups-activity.php:251 bp-groups/bp-groups-activity.php:287
624
+ #: bp-groups/bp-groups-admin.php:32 bp-groups/bp-groups-admin.php:33
625
+ #: bp-groups/bp-groups-admin.php:638 bp-groups/bp-groups-loader.php:516
626
+ #: bp-groups/bp-groups-screens.php:916 bp-groups/bp-groups-screens.php:1048
627
+ #: bp-groups/bp-groups-screens.php:1050 bp-groups/bp-groups-screens.php:1109
628
+ #: bp-groups/bp-groups-screens.php:1111 bp-groups/bp-groups-widgets.php:53
629
+ #: bp-groups/bp-groups-widgets.php:124
630
  msgid "Groups"
631
  msgstr ""
632
 
633
+ #: bp-activity/bp-activity-loader.php:251
634
  msgid "Mentions <span class=\"count\">%s</span>"
635
  msgstr ""
636
 
637
+ #: bp-activity/bp-activity-loader.php:330
638
  msgid "My Activity"
639
  msgstr ""
640
 
641
+ #: bp-activity/bp-activity-loader.php:335
642
+ #: bp-activity/bp-activity-template.php:1167
643
+ #: bp-activity/bp-activity-template.php:1313
644
+ #: bp-activity/bp-activity-template.php:1324 bp-blogs/bp-blogs-loader.php:231
645
+ #: bp-forums/bp-forums-loader.php:245 bp-forums/bp-forums-template.php:730
646
+ #: bp-forums/bp-forums-template.php:960 bp-forums/bp-forums-template.php:1990
647
+ #: bp-friends/bp-friends-loader.php:231 bp-groups/bp-groups-loader.php:577
648
  #: bp-groups/bp-groups-template.php:770 bp-groups/bp-groups-template.php:793
649
  #: bp-groups/bp-groups-template.php:1222 bp-groups/bp-groups-template.php:1238
650
  #: bp-groups/bp-groups-template.php:1287 bp-groups/bp-groups-template.php:1303
651
+ #: bp-groups/bp-groups-template.php:2031 bp-groups/bp-groups-template.php:2040
652
+ #: bp-groups/bp-groups-template.php:2049 bp-groups/bp-groups-template.php:2806
653
+ #: bp-members/bp-members-buddybar.php:64 bp-members/bp-members-loader.php:208
654
  #: bp-members/bp-members-template.php:520
655
  #: bp-members/bp-members-template.php:820
656
  #: bp-members/bp-members-template.php:839
657
+ #: bp-messages/bp-messages-loader.php:258
658
+ #: bp-messages/bp-messages-template.php:360
659
+ #: bp-notifications/bp-notifications-loader.php:226
660
  #: bp-templates/bp-legacy/buddypress/groups/single/admin.php:185
661
  #: bp-templates/bp-legacy/buddypress/groups/single/admin.php:212
662
  #: bp-themes/bp-default/groups/single/admin.php:185
663
  #: bp-themes/bp-default/groups/single/admin.php:212
664
+ #: bp-xprofile/bp-xprofile-loader.php:281
665
  msgid "Profile picture of %s"
666
  msgstr ""
667
 
694
  #: bp-activity/bp-activity-notifications.php:100
695
  #: bp-activity/bp-activity-notifications.php:178
696
  #: bp-activity/bp-activity-notifications.php:226 bp-core/deprecated/1.5.php:364
697
+ #: bp-friends/bp-friends-notifications.php:54
698
+ #: bp-friends/bp-friends-notifications.php:102
699
  #: bp-groups/bp-groups-notifications.php:42
700
  #: bp-groups/bp-groups-notifications.php:92
701
  #: bp-groups/bp-groups-notifications.php:150
739
  msgid "You do not have access to this activity."
740
  msgstr ""
741
 
742
+ #: bp-activity/bp-activity-screens.php:285 bp-blogs/bp-blogs-template.php:982
743
+ #: bp-friends/bp-friends-screens.php:93 bp-groups/bp-groups-screens.php:917
744
  #: bp-messages/bp-messages-screens.php:169
745
+ #: bp-templates/bp-legacy/buddypress/members/register.php:227
746
+ #: bp-themes/bp-default/registration/register.php:232
747
  msgid "Yes"
748
  msgstr ""
749
 
750
+ #: bp-activity/bp-activity-screens.php:286 bp-blogs/bp-blogs-template.php:986
751
+ #: bp-friends/bp-friends-screens.php:94 bp-groups/bp-groups-screens.php:918
752
  #: bp-messages/bp-messages-screens.php:170
753
+ #: bp-templates/bp-legacy/buddypress/members/register.php:228
754
+ #: bp-themes/bp-default/registration/register.php:233
755
  msgid "No"
756
  msgstr ""
757
 
767
  msgid "Sitewide Activity"
768
  msgstr ""
769
 
770
+ #: bp-activity/bp-activity-template.php:244
771
  msgctxt "Activity pagination previous text"
772
  msgid "&larr;"
773
  msgstr ""
774
 
775
+ #: bp-activity/bp-activity-template.php:245
776
  msgctxt "Activity pagination next text"
777
  msgid "&rarr;"
778
  msgstr ""
779
 
780
+ #: bp-activity/bp-activity-template.php:701
781
+ msgid "Viewing item %1$s to %2$s (of %3$s item)"
782
+ msgid_plural "Viewing item %1$s to %2$s (of %3$s items)"
783
+ msgstr[0] ""
784
+ msgstr[1] ""
785
 
786
+ #: bp-activity/bp-activity-template.php:1167
787
  msgid "Profile picture"
788
  msgstr ""
789
 
790
+ #: bp-activity/bp-activity-template.php:1289
791
  msgid "Group logo"
792
  msgstr ""
793
 
794
+ #: bp-activity/bp-activity-template.php:1292 bp-groups/bp-groups-admin.php:1405
795
  #: bp-groups/bp-groups-template.php:516
796
  msgid "Group logo of %s"
797
  msgstr ""
798
 
799
+ #: bp-activity/bp-activity-template.php:1303
800
  msgid "Profile picture of the author of the site %s"
801
  msgstr ""
802
 
803
+ #: bp-activity/bp-activity-template.php:1533
804
  msgid "View Discussion"
805
  msgstr ""
806
 
807
+ #: bp-activity/bp-activity-template.php:2417
808
+ #: bp-forums/bp-forums-template.php:2113 bp-groups/bp-groups-admin.php:1281
809
+ #: bp-groups/bp-groups-admin.php:1394 bp-groups/bp-groups-template.php:1486
810
+ #: bp-notifications/bp-notifications-template.php:826
811
  #: bp-templates/bp-legacy/buddypress/activity/comment.php:43
812
  #: bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php:51
813
  #: bp-templates/bp-legacy/buddypress/members/single/messages/single.php:24
818
  msgid "Delete"
819
  msgstr ""
820
 
821
+ #: bp-activity/bp-activity-template.php:2465
822
  #: bp-core/admin/bp-core-slugs.php:109 bp-core/admin/bp-core-slugs.php:172
823
+ #: bp-core/bp-core-loader.php:238 bp-members/bp-members-loader.php:182
824
  #: bp-members/bp-members-template.php:625
825
+ #: bp-templates/bp-legacy/buddypress-functions.php:244
826
  #: bp-themes/bp-default/activity/entry.php:37
827
  #: bp-themes/bp-default/functions.php:166
828
+ #: bp-xprofile/bp-xprofile-loader.php:183
829
+ #: bp-xprofile/bp-xprofile-loader.php:243
830
  msgid "View"
831
  msgstr ""
832
 
833
+ #: bp-activity/bp-activity-template.php:2563
834
  msgid "Clear Filter"
835
  msgstr ""
836
 
837
+ #: bp-activity/bp-activity-template.php:2759
838
  msgid "a user"
839
  msgstr ""
840
 
841
+ #: bp-activity/bp-activity-template.php:2813
842
  msgid "Send a public message on your activity stream."
843
  msgstr ""
844
 
845
+ #: bp-activity/bp-activity-template.php:2814
846
  msgid "Public Message"
847
  msgstr ""
848
 
849
+ #: bp-activity/bp-activity-template.php:3267
850
  msgid "Site Wide Activity RSS Feed"
851
  msgstr ""
852
 
862
  msgid "New post comment posted"
863
  msgstr ""
864
 
865
+ #: bp-blogs/bp-blogs-buddybar.php:42 bp-blogs/bp-blogs-loader.php:144
866
+ #: bp-blogs/bp-blogs-loader.php:194 bp-blogs/bp-blogs-loader.php:222
867
  msgid "My Sites"
868
  msgstr ""
869
 
870
+ #: bp-blogs/bp-blogs-buddybar.php:54 bp-core/bp-core-buddybar.php:621
871
  msgid "Dashboard"
872
  msgstr ""
873
 
874
+ #: bp-blogs/bp-blogs-buddybar.php:55 bp-core/bp-core-buddybar.php:625
875
  msgid "New Post"
876
  msgstr ""
877
 
878
+ #: bp-blogs/bp-blogs-buddybar.php:56 bp-core/bp-core-buddybar.php:626
879
  msgid "Manage Posts"
880
  msgstr ""
881
 
882
+ #: bp-blogs/bp-blogs-buddybar.php:57 bp-core/bp-core-buddybar.php:627
883
  msgid "Manage Comments"
884
  msgstr ""
885
 
886
+ #: bp-blogs/bp-blogs-buddybar.php:70
887
  msgid "Create a Site!"
888
  msgstr ""
889
 
890
+ #: bp-blogs/bp-blogs-functions.php:206
891
  msgid "%s created the site %s"
892
  msgstr ""
893
 
894
+ #: bp-blogs/bp-blogs-functions.php:331
895
  msgid "%1$s wrote a new post, %2$s, on the site %3$s"
896
  msgstr ""
897
 
898
+ #: bp-blogs/bp-blogs-functions.php:333
899
  msgid "%1$s wrote a new post, %2$s"
900
  msgstr ""
901
 
902
+ #: bp-blogs/bp-blogs-functions.php:440
903
  msgid "%1$s commented on the post, %2$s, on the site %3$s"
904
  msgstr ""
905
 
906
+ #: bp-blogs/bp-blogs-functions.php:442
907
  msgid "%1$s commented on the post, %2$s"
908
  msgstr ""
909
 
910
+ #: bp-blogs/bp-blogs-loader.php:25 bp-core/admin/bp-core-components.php:395
911
  msgid "Site Tracking"
912
  msgstr ""
913
 
914
+ #: bp-blogs/bp-blogs-loader.php:64
915
  msgid "Search sites..."
916
  msgstr ""
917
 
918
+ #: bp-blogs/bp-blogs-loader.php:124
919
  msgid "Sites <span>%d</span>"
920
  msgstr ""
921
 
922
+ #: bp-blogs/bp-blogs-loader.php:186 bp-blogs/bp-blogs-screens.php:146
923
+ #: bp-blogs/bp-blogs-screens.php:148 bp-blogs/bp-blogs-screens.php:209
924
+ #: bp-blogs/bp-blogs-screens.php:211
925
  msgid "Sites"
926
  msgstr ""
927
 
928
+ #: bp-blogs/bp-blogs-loader.php:203 bp-blogs/bp-blogs-screens.php:209
929
+ #: bp-blogs/bp-blogs-template.php:1099 bp-core/bp-core-filters.php:408
930
+ #: bp-themes/bp-default/blogs/create.php:21
931
+ #: bp-themes/bp-default/blogs/index.php:21
932
+ msgid "Create a Site"
933
  msgstr ""
934
 
935
+ #: bp-blogs/bp-blogs-screens.php:146
936
+ msgid "Create a Sites"
 
 
937
  msgstr ""
938
 
939
+ #: bp-blogs/bp-blogs-template.php:206
940
  msgctxt "Blog pagination previous text"
941
  msgid "&larr;"
942
  msgstr ""
943
 
944
+ #: bp-blogs/bp-blogs-template.php:207
945
  msgctxt "Blog pagination next text"
946
  msgid "&rarr;"
947
  msgstr ""
948
 
949
+ #: bp-blogs/bp-blogs-template.php:424
950
+ msgid "Viewing site %1$s to %2$s (of %3$s site)"
951
+ msgid_plural "Viewing site %1$s to %2$s (of %3$s sites)"
952
+ msgstr[0] ""
953
+ msgstr[1] ""
954
 
955
+ #: bp-blogs/bp-blogs-template.php:489
956
  msgid "Profile picture of site author %s"
957
  msgstr ""
958
 
959
+ #: bp-blogs/bp-blogs-template.php:633 bp-core/bp-core-classes.php:792
960
+ #: bp-groups/bp-groups-widgets.php:85 bp-groups/bp-groups-widgets.php:188
961
  #: bp-members/bp-members-template.php:596
962
  #: bp-members/bp-members-template.php:871
963
  #: bp-templates/bp-legacy/buddypress/groups/groups-loop.php:47
967
  msgid "active %s"
968
  msgstr ""
969
 
970
+ #: bp-blogs/bp-blogs-template.php:653
971
  msgid "Latest Post: %s"
972
  msgstr ""
973
 
974
+ #: bp-blogs/bp-blogs-template.php:900
975
  msgid "There was a problem, please correct the form below and try again."
976
  msgstr ""
977
 
978
+ #: bp-blogs/bp-blogs-template.php:903
979
  msgid "By filling out the form below, you can <strong>add a site to your account</strong>. There is no limit to the number of sites that you can have, so create to your heart's content, but blog responsibly!"
980
  msgstr ""
981
 
982
+ #: bp-blogs/bp-blogs-template.php:905
983
  msgid "If you&#8217;re not going to use a great domain, leave it for a new user. Now have at it!"
984
  msgstr ""
985
 
986
+ #: bp-blogs/bp-blogs-template.php:914
987
  msgid "Create Site"
988
  msgstr ""
989
 
990
+ #: bp-blogs/bp-blogs-template.php:936
991
  msgid "Site Name:"
992
  msgstr ""
993
 
994
+ #: bp-blogs/bp-blogs-template.php:938
995
  msgid "Site Domain:"
996
  msgstr ""
997
 
998
+ #: bp-blogs/bp-blogs-template.php:952
999
  msgid "Your address will be "
1000
  msgstr ""
1001
 
1002
+ #: bp-blogs/bp-blogs-template.php:955
1003
  msgid "blogname"
1004
  msgstr ""
1005
 
1006
+ #: bp-blogs/bp-blogs-template.php:957
1007
  msgid "domain."
1008
  msgstr ""
1009
 
1010
+ #: bp-blogs/bp-blogs-template.php:960
1011
  msgid "Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)"
1012
  msgstr ""
1013
 
1014
+ #: bp-blogs/bp-blogs-template.php:966
1015
  msgid "Site Title:"
1016
  msgstr ""
1017
 
1018
+ #: bp-blogs/bp-blogs-template.php:977
1019
  msgid "Privacy:"
1020
  msgstr ""
1021
 
1022
+ #: bp-blogs/bp-blogs-template.php:978
1023
+ #: bp-templates/bp-legacy/buddypress/members/register.php:224
1024
+ #: bp-themes/bp-default/registration/register.php:229
1025
  msgid "I would like my site to appear in search engines, and in public listings around this network."
1026
  msgstr ""
1027
 
1028
+ #: bp-blogs/bp-blogs-template.php:1085
1029
  msgid "Congratulations! You have successfully registered a new site."
1030
  msgstr ""
1031
 
1032
+ #: bp-blogs/bp-blogs-template.php:1087
1033
  msgid "<a href=\"%1$s\">%2$s</a> is your new site. <a href=\"%3$s\">Login</a> as \"%4$s\" using your existing password."
1034
  msgstr ""
1035
 
1036
+ #: bp-blogs/bp-blogs-template.php:1116
 
 
 
 
 
 
1037
  msgid "%s's Sites"
1038
  msgstr ""
1039
 
1040
+ #: bp-blogs/bp-blogs-template.php:1117
1041
  msgid "%s's Recent Posts"
1042
  msgstr ""
1043
 
1044
+ #: bp-blogs/bp-blogs-template.php:1118
1045
  msgid "%s's Recent Comments"
1046
  msgstr ""
1047
 
1048
+ #: bp-blogs/bp-blogs-template.php:1134 bp-core/deprecated/1.5.php:417
1049
+ #: bp-forums/bp-forums-template.php:2196 bp-groups/bp-groups-template.php:2530
1050
  #: bp-members/bp-members-template.php:710
1051
+ #: bp-messages/bp-messages-template.php:414 bp-themes/bp-default/header.php:30
1052
  #: bp-themes/bp-default/searchform.php:5
1053
  msgid "Search"
1054
  msgstr ""
1055
 
1056
+ #: bp-blogs/bp-blogs-template.php:1180 bp-blogs/bp-blogs-template.php:1181
1057
  msgid "Visit Site"
1058
  msgstr ""
1059
 
1060
+ #: bp-blogs/bp-blogs-widgets.php:34
1061
  msgid "A list of recently published posts from across your network."
1062
  msgstr ""
1063
 
1064
+ #: bp-blogs/bp-blogs-widgets.php:37
1065
  msgctxt "widget name"
1066
  msgid "(BuddyPress) Recent Networkwide Posts"
1067
  msgstr ""
1068
 
1069
+ #: bp-blogs/bp-blogs-widgets.php:50 bp-blogs/bp-blogs-widgets.php:122
1070
  msgid "Recent Networkwide Posts"
1071
  msgstr ""
1072
 
1073
+ #: bp-blogs/bp-blogs-widgets.php:91
1074
  msgid "Sorry, there were no posts found. Why not write one?"
1075
  msgstr ""
1076
 
1077
+ #: bp-blogs/bp-blogs-widgets.php:133
1078
  msgctxt "Label for the Title field of the Recent Networkwide Posts widget"
1079
  msgid "Title:"
1080
  msgstr ""
1081
 
1082
+ #: bp-blogs/bp-blogs-widgets.php:134
1083
  msgid "Link widget title to Blogs directory"
1084
  msgstr ""
1085
 
1086
+ #: bp-blogs/bp-blogs-widgets.php:135
1087
  msgid "Max posts to show:"
1088
  msgstr ""
1089
 
1090
  #: bp-core/admin/bp-core-components.php:26
1091
+ #: bp-core/admin/bp-core-functions.php:372
1092
  msgid "Components"
1093
  msgstr ""
1094
 
1098
  msgstr ""
1099
 
1100
  #: bp-core/admin/bp-core-components.php:59
1101
+ #: bp-core/admin/bp-core-components.php:363
1102
  #: bp-xprofile/bp-xprofile-loader.php:41
1103
  msgid "Extended Profiles"
1104
  msgstr ""
1105
 
1106
  #: bp-core/admin/bp-core-components.php:60
1107
+ #: bp-core/admin/bp-core-components.php:364
1108
  msgid "Customize your community with fully editable profile fields that allow your users to describe themselves."
1109
  msgstr ""
1110
 
1111
+ #: bp-core/admin/bp-core-components.php:63
1112
+ #: bp-core/admin/bp-core-components.php:367
1113
+ msgid "Account Settings"
1114
+ msgstr ""
1115
+
1116
+ #: bp-core/admin/bp-core-components.php:64
1117
+ #: bp-core/admin/bp-core-components.php:368
1118
+ msgid "Allow your users to modify their account and notification settings directly from within their profiles."
1119
+ msgstr ""
1120
+
1121
+ #: bp-core/admin/bp-core-components.php:67
1122
+ #: bp-core/admin/bp-core-components.php:383
1123
+ #: bp-notifications/bp-notifications-buddybar.php:28
1124
+ #: bp-notifications/bp-notifications-loader.php:26
1125
+ #: bp-notifications/bp-notifications-loader.php:178
1126
+ #: bp-notifications/bp-notifications-loader.php:221
1127
+ #: bp-settings/bp-settings-loader.php:179
1128
+ msgid "Notifications"
1129
+ msgstr ""
1130
+
1131
+ #: bp-core/admin/bp-core-components.php:68
1132
+ #: bp-core/admin/bp-core-components.php:384
1133
+ msgid "Notify members of relevant activity with a toolbar bubble and/or via email, and allow them to customize their notification settings."
1134
+ msgstr ""
1135
+
1136
+ #: bp-core/admin/bp-core-components.php:144
1137
  msgctxt "plugins"
1138
  msgid "All <span class=\"count\">(%s)</span>"
1139
  msgid_plural "All <span class=\"count\">(%s)</span>"
1140
  msgstr[0] ""
1141
  msgstr[1] ""
1142
 
1143
+ #: bp-core/admin/bp-core-components.php:145
1144
  msgid "Active <span class=\"count\">(%s)</span>"
1145
  msgid_plural "Active <span class=\"count\">(%s)</span>"
1146
  msgstr[0] ""
1147
  msgstr[1] ""
1148
 
1149
+ #: bp-core/admin/bp-core-components.php:146
1150
  msgid "Inactive <span class=\"count\">(%s)</span>"
1151
  msgid_plural "Inactive <span class=\"count\">(%s)</span>"
1152
  msgstr[0] ""
1153
  msgstr[1] ""
1154
 
1155
+ #: bp-core/admin/bp-core-components.php:147
1156
  msgid "Must-Use <span class=\"count\">(%s)</span>"
1157
  msgid_plural "Must-Use <span class=\"count\">(%s)</span>"
1158
  msgstr[0] ""
1159
  msgstr[1] ""
1160
 
1161
+ #: bp-core/admin/bp-core-components.php:148
1162
  msgid "Retired <span class=\"count\">(%s)</span>"
1163
  msgid_plural "Retired <span class=\"count\">(%s)</span>"
1164
  msgstr[0] ""
1165
  msgstr[1] ""
1166
 
 
1167
  #: bp-core/admin/bp-core-components.php:155
1168
+ #: bp-core/admin/bp-core-components.php:163
1169
  msgid "Component"
1170
  msgstr ""
1171
 
 
1172
  #: bp-core/admin/bp-core-components.php:156
1173
+ #: bp-core/admin/bp-core-components.php:164
1174
  msgid "Description"
1175
  msgstr ""
1176
 
1177
+ #: bp-core/admin/bp-core-components.php:189
1178
  msgid "Select %s"
1179
  msgstr ""
1180
 
1181
+ #: bp-core/admin/bp-core-components.php:214
1182
  msgid "No components found."
1183
  msgstr ""
1184
 
1185
+ #: bp-core/admin/bp-core-components.php:343 bp-core/bp-core-loader.php:27
1186
  msgid "BuddyPress Core"
1187
  msgstr ""
1188
 
1189
+ #: bp-core/admin/bp-core-components.php:344
1190
  msgid "It&#8216;s what makes <del>time travel</del> BuddyPress possible!"
1191
  msgstr ""
1192
 
1193
+ #: bp-core/admin/bp-core-components.php:347
1194
  msgid "Community Members"
1195
  msgstr ""
1196
 
1197
+ #: bp-core/admin/bp-core-components.php:348
1198
  msgid "Everything in a BuddyPress community revolves around its members."
1199
  msgstr ""
1200
 
1201
+ #: bp-core/admin/bp-core-components.php:355
1202
  #: bp-templates/bp-legacy/buddypress/groups/create.php:105
1203
  #: bp-themes/bp-default/groups/create.php:112
1204
  msgid "Group Forums"
1205
  msgstr ""
1206
 
1207
+ #: bp-core/admin/bp-core-components.php:356
1208
  msgid "BuddyPress Forums are retired. Use %s."
1209
  msgstr ""
1210
 
1211
+ #: bp-core/admin/bp-core-components.php:371 bp-friends/bp-friends-loader.php:24
 
 
 
 
 
 
 
 
1212
  msgid "Friend Connections"
1213
  msgstr ""
1214
 
1215
+ #: bp-core/admin/bp-core-components.php:372
1216
  msgid "Let your users make connections so they can track the activity of others and focus on the people they care about the most."
1217
  msgstr ""
1218
 
1219
+ #: bp-core/admin/bp-core-components.php:375
1220
  msgid "Private Messaging"
1221
  msgstr ""
1222
 
1223
+ #: bp-core/admin/bp-core-components.php:376
1224
  msgid "Allow your users to talk to each other directly and in private. Not just limited to one-on-one discussions, messages can be sent between any number of members."
1225
  msgstr ""
1226
 
1227
+ #: bp-core/admin/bp-core-components.php:380
1228
  msgid "Global, personal, and group activity streams with threaded commenting, direct posting, favoriting and @mentions, all with full RSS feed and email notification support."
1229
  msgstr ""
1230
 
1231
+ #: bp-core/admin/bp-core-components.php:387 bp-groups/bp-groups-loader.php:83
1232
  msgid "User Groups"
1233
  msgstr ""
1234
 
1235
+ #: bp-core/admin/bp-core-components.php:388
1236
  msgid "Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings."
1237
  msgstr ""
1238
 
1239
+ #: bp-core/admin/bp-core-components.php:391
1240
  msgid "Group Forums (Legacy)"
1241
  msgstr ""
1242
 
1243
+ #: bp-core/admin/bp-core-components.php:392
1244
  msgid "Group forums allow for focused, bulletin-board style conversations."
1245
  msgstr ""
1246
 
1247
+ #: bp-core/admin/bp-core-components.php:396
1248
  msgid "Record activity for new posts and comments from your site."
1249
  msgstr ""
1250
 
1251
+ #: bp-core/admin/bp-core-components.php:403
1252
  msgid "Record activity for new sites, posts, and comments across your network."
1253
  msgstr ""
1254
 
1264
  msgid "Components, Pages, Settings, and Forums, have been moved to <a href=\"%s\">Settings &gt; BuddyPress</a>. Profile Fields has been moved into the <a href=\"%s\">Users</a> menu."
1265
  msgstr ""
1266
 
1267
+ #: bp-core/admin/bp-core-functions.php:233
1268
  msgid "<strong>BuddyPress is almost ready</strong>. You must <a href=\"%s\">update your permalink structure</a> to something other than the default for it to work."
1269
  msgstr ""
1270
 
1271
+ #: bp-core/admin/bp-core-functions.php:257 bp-core/admin/bp-core-slugs.php:135
1272
+ #: bp-messages/bp-messages-template.php:605
1273
  #: bp-templates/bp-legacy/buddypress/members/activate.php:29
1274
  #: bp-themes/bp-default/registration/activate.php:38
1275
  msgid "Activate"
1276
  msgstr ""
1277
 
1278
+ #: bp-core/admin/bp-core-functions.php:262 bp-core/admin/bp-core-slugs.php:134
1279
  #: bp-members/bp-members-adminbar.php:60
1280
  msgid "Register"
1281
  msgstr ""
1282
 
1283
+ #: bp-core/admin/bp-core-functions.php:288
1284
  msgid "The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href=\"%1$s\" class=\"button-secondary\">Repair</a>"
1285
  msgstr ""
1286
 
1287
+ #: bp-core/admin/bp-core-functions.php:310
1288
  msgid "Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href=\"%1$s\" class=\"button-secondary\">Repair</a>"
1289
  msgstr ""
1290
 
1291
+ #: bp-core/admin/bp-core-functions.php:376 bp-core/admin/bp-core-slugs.php:26
1292
  msgid "Pages"
1293
  msgstr ""
1294
 
1295
+ #: bp-core/admin/bp-core-functions.php:380
1296
+ #: bp-core/admin/bp-core-settings.php:258 bp-core/bp-core-admin.php:354
1297
+ #: bp-groups/bp-groups-loader.php:304 bp-groups/bp-groups-template.php:1468
1298
  #: bp-settings/bp-settings-loader.php:23 bp-settings/bp-settings-loader.php:73
1299
+ #: bp-settings/bp-settings-loader.php:163
1300
  msgid "Settings"
1301
  msgstr ""
1302
 
1303
+ #: bp-core/admin/bp-core-functions.php:392 bp-core/bp-core-template.php:370
1304
+ #: bp-forums/bp-forums-loader.php:132 bp-forums/bp-forums-loader.php:199
1305
+ #: bp-forums/bp-forums-loader.php:240 bp-forums/bp-forums-screens.php:208
1306
+ #: bp-forums/bp-forums-screens.php:210 bp-forums/deprecated/1.6.php:42
1307
  #: bp-forums/deprecated/1.7.php:25 bp-forums/deprecated/1.7.php:100
1308
  msgid "Forums"
1309
  msgstr ""
1310
 
1311
+ #: bp-core/admin/bp-core-functions.php:437
1312
  msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-components\">Managing Components</a>"
1313
  msgstr ""
1314
 
1315
+ #: bp-core/admin/bp-core-functions.php:455
1316
  msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-pages\">Managing Pages</a>"
1317
  msgstr ""
1318
 
1319
+ #: bp-core/admin/bp-core-functions.php:474
1320
  msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-settings\">Managing Settings</a>"
1321
  msgstr ""
1322
 
1323
+ #: bp-core/admin/bp-core-functions.php:493
1324
  msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#users-profile-fields\">Managing Profile Fields</a>"
1325
  msgstr ""
1326
 
1327
+ #: bp-core/admin/bp-core-functions.php:511
1328
  msgid "By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site."
1329
  msgstr ""
1330
 
1331
+ #: bp-core/admin/bp-core-functions.php:515
1332
  msgid "BuddyPress Components use WordPress Pages for their root directory/archive pages. Here you can change the page associations for each active component."
1333
  msgstr ""
1334
 
1335
+ #: bp-core/admin/bp-core-functions.php:519
1336
  msgid "Extra configuration settings."
1337
  msgstr ""
1338
 
1339
+ #: bp-core/admin/bp-core-functions.php:523
1340
  msgid "Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.</br></br>Note: Any fields in the first group will appear on the signup page."
1341
  msgstr ""
1342
 
1343
+ #: bp-core/admin/bp-core-functions.php:676 bp-core/bp-core-admin.php:197
1344
+ #: bp-core/bp-core-admin.php:198 bp-core/bp-core-admin.php:218
1345
+ msgid "BuddyPress"
1346
+ msgstr ""
1347
+
1348
+ #: bp-core/admin/bp-core-functions.php:699
1349
+ #: bp-core/admin/bp-core-functions.php:708
1350
+ msgid "Logged-In"
1351
+ msgstr ""
1352
+
1353
+ #: bp-core/admin/bp-core-functions.php:702
1354
+ #: bp-core/admin/bp-core-functions.php:717
1355
+ msgid "Logged-Out"
1356
+ msgstr ""
1357
+
1358
+ #: bp-core/admin/bp-core-functions.php:709
1359
+ msgid "<em>Logged-In</em> links are relative to the current user, and are not visible to visitors who are not logged in."
1360
+ msgstr ""
1361
+
1362
+ #: bp-core/admin/bp-core-functions.php:718
1363
+ msgid "<em>Logged-Out</em> links are not visible to users who are logged in."
1364
+ msgstr ""
1365
+
1366
+ #: bp-core/admin/bp-core-functions.php:728
1367
+ msgid "Add to Menu"
1368
+ msgstr ""
1369
+
1370
+ #: bp-core/admin/bp-core-schema.php:251
1371
  msgctxt "First field-group name"
1372
  msgid "General"
1373
  msgstr ""
1374
 
1375
+ #: bp-core/admin/bp-core-schema.php:255
1376
  msgctxt "Display name field"
1377
  msgid "Display Name"
1378
  msgstr ""
1448
  #: bp-core/admin/bp-core-slugs.php:105 bp-core/admin/bp-core-slugs.php:168
1449
  #: bp-templates/bp-legacy/buddypress/members/single/settings/capabilities.php:13
1450
  #: bp-themes/bp-default/members/single/settings/capabilities.php:61
1451
+ #: bp-xprofile/bp-xprofile-classes.php:402
1452
+ #: bp-xprofile/bp-xprofile-classes.php:874
1453
  msgid "Save"
1454
  msgstr ""
1455
 
1461
  msgid "Associate WordPress Pages with the following BuddyPress Registration pages."
1462
  msgstr ""
1463
 
1464
+ #: bp-core/bp-core-admin.php:177 bp-core/bp-core-admin.php:178
1465
+ #: bp-core/bp-core-admin.php:186 bp-core/bp-core-admin.php:187
1466
  msgid "Welcome to BuddyPress"
1467
  msgstr ""
1468
 
1469
+ #: bp-core/bp-core-admin.php:207
 
 
 
 
 
1470
  msgid "BuddyPress Help"
1471
  msgstr ""
1472
 
1473
+ #: bp-core/bp-core-admin.php:208
1474
  msgid "Help"
1475
  msgstr ""
1476
 
1477
+ #: bp-core/bp-core-admin.php:217
1478
  msgid "BuddyPress Components"
1479
  msgstr ""
1480
 
1481
+ #: bp-core/bp-core-admin.php:226 bp-core/bp-core-admin.php:227
1482
  msgid "BuddyPress Pages"
1483
  msgstr ""
1484
 
1485
+ #: bp-core/bp-core-admin.php:235 bp-core/bp-core-admin.php:236
1486
  msgid "BuddyPress Settings"
1487
  msgstr ""
1488
 
1489
+ #: bp-core/bp-core-admin.php:262
1490
  msgid "Main Settings"
1491
  msgstr ""
1492
 
1493
+ #: bp-core/bp-core-admin.php:265 bp-core/bp-core-admin.php:270
1494
  msgid "Toolbar"
1495
  msgstr ""
1496
 
1497
+ #: bp-core/bp-core-admin.php:275
1498
  msgid "Account Deletion"
1499
  msgstr ""
1500
 
1501
+ #: bp-core/bp-core-admin.php:283
1502
  msgid "Profile Settings"
1503
  msgstr ""
1504
 
1505
+ #: bp-core/bp-core-admin.php:286
1506
  msgid "Avatar Uploads"
1507
  msgstr ""
1508
 
1509
+ #: bp-core/bp-core-admin.php:290
1510
  msgid "Profile Syncing"
1511
  msgstr ""
1512
 
1513
+ #: bp-core/bp-core-admin.php:299
1514
  msgid "Groups Settings"
1515
  msgstr ""
1516
 
1517
+ #: bp-core/bp-core-admin.php:302
1518
  msgid "Group Creation"
1519
  msgstr ""
1520
 
1521
+ #: bp-core/bp-core-admin.php:311
1522
  msgid "Legacy Group Forums"
1523
  msgstr ""
1524
 
1525
+ #: bp-core/bp-core-admin.php:314
1526
  msgid "bbPress Configuration"
1527
  msgstr ""
1528
 
1529
+ #: bp-core/bp-core-admin.php:323
1530
  msgid "Activity Settings"
1531
  msgstr ""
1532
 
1533
+ #: bp-core/bp-core-admin.php:326
1534
  msgid "Blog &amp; Forum Comments"
1535
  msgstr ""
1536
 
1537
+ #: bp-core/bp-core-admin.php:331
1538
  msgid "Akismet"
1539
  msgstr ""
1540
 
1541
+ #: bp-core/bp-core-admin.php:355
1542
  msgid "About"
1543
  msgstr ""
1544
 
1545
+ #: bp-core/bp-core-admin.php:406 bp-core/bp-core-admin.php:525
1546
  msgid "Welcome to BuddyPress %s"
1547
  msgstr ""
1548
 
1549
+ #: bp-core/bp-core-admin.php:409
1550
  msgid "BuddyPress %s is our safest, fastest, most flexible version ever."
1551
  msgstr ""
1552
 
1553
+ #: bp-core/bp-core-admin.php:411
1554
  msgid "Thank you for updating! BuddyPress %s is our safest, fastest, most flexible version ever."
1555
  msgstr ""
1556
 
1557
+ #: bp-core/bp-core-admin.php:414 bp-core/bp-core-admin.php:527
1558
  msgid "Version %s"
1559
  msgstr ""
1560
 
1561
+ #: bp-core/bp-core-admin.php:418 bp-core/bp-core-admin.php:531
1562
  msgid "What&#8217;s New"
1563
  msgstr ""
1564
 
1565
+ #: bp-core/bp-core-admin.php:420 bp-core/bp-core-admin.php:533
1566
  msgid "Credits"
1567
  msgstr ""
1568
 
1569
+ #: bp-core/bp-core-admin.php:425
1570
  msgid "Getting Started"
1571
  msgstr ""
1572
 
1573
+ #: bp-core/bp-core-admin.php:428
1574
  msgid "Your Default Setup"
1575
  msgstr ""
1576
 
1577
+ #: bp-core/bp-core-admin.php:432
1578
  msgid "BuddyPress&#8217;s powerful features help your users connect and collaborate. To help get your community started, we&#8217;ve activated two of the most commonly used tools in BP: <strong>Extended Profiles</strong> and <strong>Activity Streams</strong>. See these components in action at the %1$s and %2$s directories, and be sure to spend a few minutes <a href=\"%3$s\">configuring user profiles</a>. Want to explore more of BP&#8217;s features? Visit the <a href=\"%4$s\">Components panel</a>."
1579
  msgstr ""
1580
 
1581
+ #: bp-core/bp-core-admin.php:433 bp-core/bp-core-template.php:361
1582
+ #: bp-core/bp-core-widgets.php:266 bp-groups/bp-groups-admin.php:776
1583
  #: bp-groups/bp-groups-template.php:1476 bp-members/bp-members-loader.php:24
1584
+ #: bp-members/bp-members-screens.php:368
1585
  #: bp-templates/bp-legacy/buddypress/groups/single/admin.php:231
1586
  #: bp-themes/bp-default/groups/single/admin.php:231
1587
  msgid "Members"
1588
  msgstr ""
1589
 
1590
+ #: bp-core/bp-core-admin.php:441
1591
+ msgid "BuddyPress&#8217;s powerful features help your users connect and collaborate. Want to explore BP&#8217;s features? Visit the <a href=\"%s\">Components panel</a>."
1592
+ msgstr ""
1593
+
1594
+ #: bp-core/bp-core-admin.php:447
1595
  msgid "Community and Support"
1596
  msgstr ""
1597
 
1598
+ #: bp-core/bp-core-admin.php:448
1599
  msgid "Looking for help? The <a href=\"http://codex.buddypress.org/\">BuddyPress Codex</a> has you covered, with dozens of user-contributed guides on how to configure and use your BP site. Can&#8217;t find what you need? Stop by <a href=\"http://buddypress.org/support/\">our support forums</a>, where a vibrant community of BuddyPress users and developers is waiting to share tips, show off their sites, talk about the future of BuddyPress, and much more."
1600
  msgstr ""
1601
 
1602
+ #: bp-core/bp-core-admin.php:454
1603
  msgid "Improved Theme Integration"
1604
  msgstr ""
1605
 
1606
+ #: bp-core/bp-core-admin.php:457
1607
  msgid "Hey, Good Lookin&#8217;"
1608
  msgstr ""
1609
 
1610
+ #: bp-core/bp-core-admin.php:458
1611
  msgid "We&#8217;ve streamlined our stylesheets, so that BuddyPress content looks more at home in your theme. And theme developers will love BP&#8217;s new hierarchies that make it easy to override specific top-level templates, stylesheets, and JavaScript files."
1612
  msgstr ""
1613
 
1614
+ #: bp-core/bp-core-admin.php:463
1615
  msgid "Better Group Member Management"
1616
  msgstr ""
1617
 
1618
+ #: bp-core/bp-core-admin.php:466
1619
  msgid "<em>Add</em>, <em>Remove</em>, and More, in a Snap"
1620
  msgstr ""
1621
 
1622
+ #: bp-core/bp-core-admin.php:469
1623
  msgid "Groups administration panel"
1624
  msgstr ""
1625
 
1626
+ #: bp-core/bp-core-admin.php:476
1627
  msgid "The Manage Members section of the %s has been rewritten, to make it easier to handle groups with many members. We&#8217;ve also made the interface nicer to use, to ensure that you don&#8217;t make changes and then forget to save them."
1628
  msgstr ""
1629
 
1630
+ #: bp-core/bp-core-admin.php:483
1631
  msgid "Under the Hood"
1632
  msgstr ""
1633
 
1634
+ #: bp-core/bp-core-admin.php:487
1635
  msgid "Superpowered Group Extensions"
1636
  msgstr ""
1637
 
1638
+ #: bp-core/bp-core-admin.php:488
1639
  msgid "<code>BP_Group_Extension</code> has been overhauled, making it easier than ever before to add custom functionality to groups."
1640
  msgstr ""
1641
 
1642
+ #: bp-core/bp-core-admin.php:490
1643
  msgid "Filter Groups or Activity by Metadata"
1644
  msgstr ""
1645
 
1646
+ #: bp-core/bp-core-admin.php:491
1647
  msgid "<code>bp_has_groups()</code> and <code>bp_has_activities()</code> now accept a <code>meta_query</code> paramater, for more powerful directory queries."
1648
  msgstr ""
1649
 
1650
+ #: bp-core/bp-core-admin.php:495
1651
  msgid "Feed Me, Seymour"
1652
  msgstr ""
1653
 
1654
+ #: bp-core/bp-core-admin.php:496
1655
  msgid "The new <code>BP_Activity_Feed</code> class centralizes BP&#8217;s RSS logic, making our feeds more standards-compliant, and giving developers more tools for building custom feeds."
1656
  msgstr ""
1657
 
1658
+ #: bp-core/bp-core-admin.php:498
1659
  msgid "Disable @-Mentions"
1660
  msgstr ""
1661
 
1662
+ #: bp-core/bp-core-admin.php:499
1663
  msgid "Not using @-mentions? Disable them with <code>add_filter( 'bp_activity_do_mentions', '__return_false' );</code>"
1664
  msgstr ""
1665
 
1666
+ #: bp-core/bp-core-admin.php:504 bp-core/bp-core-admin.php:634
1667
  msgid "Go to the BuddyPress Settings page"
1668
  msgstr ""
1669
 
1670
+ #: bp-core/bp-core-admin.php:526
1671
  msgid "Thank you for updating to the latest version! BuddyPress %s is ready to make your community a safer, faster, and better looking place to hang out!"
1672
  msgstr ""
1673
 
1674
+ #: bp-core/bp-core-admin.php:537
1675
  msgid "BuddyPress is created by a worldwide network of friendly folks."
1676
  msgstr ""
1677
 
1678
+ #: bp-core/bp-core-admin.php:539
1679
  msgid "Project Leaders"
1680
  msgstr ""
1681
 
1682
+ #: bp-core/bp-core-admin.php:544
1683
  msgid "Founding Developer"
1684
  msgstr ""
1685
 
1686
+ #: bp-core/bp-core-admin.php:549
1687
  msgid "Project Lead"
1688
  msgstr ""
1689
 
1690
+ #: bp-core/bp-core-admin.php:554 bp-core/bp-core-admin.php:559
1691
  msgid "Lead Developer"
1692
  msgstr ""
1693
 
1694
+ #: bp-core/bp-core-admin.php:563
1695
  msgid "Core Developers"
1696
  msgstr ""
1697
 
1698
+ #: bp-core/bp-core-admin.php:571
1699
  msgid "Recent Rockstars"
1700
  msgstr ""
1701
 
1702
+ #: bp-core/bp-core-admin.php:576
1703
  msgid "Design Officer"
1704
  msgstr ""
1705
 
1706
+ #: bp-core/bp-core-admin.php:581
1707
  msgid "Support Officer"
1708
  msgstr ""
1709
 
1710
+ #: bp-core/bp-core-admin.php:585
1711
  msgid "Core Contributors to BuddyPress 1.8"
1712
  msgstr ""
1713
 
1714
+ #: bp-core/bp-core-adminbar.php:36 bp-core/bp-core-buddybar.php:571
1715
  msgid "My Account"
1716
  msgstr ""
1717
 
1718
+ #: bp-core/bp-core-avatars.php:309
1719
  msgid "Avatar Image"
1720
  msgstr ""
1721
 
1722
+ #: bp-core/bp-core-avatars.php:584
1723
  msgid "The image was uploaded successfully"
1724
  msgstr ""
1725
 
1726
+ #: bp-core/bp-core-avatars.php:585 bp-core/bp-core-avatars.php:586
1727
  msgid "The image exceeds the maximum allowed file size of: "
1728
  msgstr ""
1729
 
1730
+ #: bp-core/bp-core-avatars.php:587
1731
  msgid "The uploaded file was only partially uploaded."
1732
  msgstr ""
1733
 
1734
+ #: bp-core/bp-core-avatars.php:588
1735
  msgid "The image was not uploaded."
1736
  msgstr ""
1737
 
1738
+ #: bp-core/bp-core-avatars.php:589
1739
  msgid "Missing a temporary folder."
1740
  msgstr ""
1741
 
1742
+ #: bp-core/bp-core-avatars.php:593
1743
  msgid "Your upload failed, please try again. Error was: %s"
1744
  msgstr ""
1745
 
1746
+ #: bp-core/bp-core-avatars.php:598
1747
  msgid "The file you uploaded is too big. Please upload a file under %s"
1748
  msgstr ""
1749
 
1750
+ #: bp-core/bp-core-avatars.php:603
1751
  msgid "Please upload only JPG, GIF or PNG photos."
1752
  msgstr ""
1753
 
1754
+ #: bp-core/bp-core-avatars.php:620 bp-core/bp-core-avatars.php:657
1755
  msgid "Upload Failed! Error was: %s"
1756
  msgstr ""
1757
 
1758
+ #: bp-core/bp-core-avatars.php:675
1759
  msgid "Upload failed! Error was: %s"
1760
  msgstr ""
1761
 
1762
+ #: bp-core/bp-core-avatars.php:831 bp-core/bp-core-classes.php:789
1763
+ #: bp-core/bp-core-classes.php:790 bp-core/bp-core-classes.php:791
1764
+ #: bp-core/bp-core-template.php:135 bp-core/bp-core-template.php:151
1765
  msgid "Avatar of %s"
1766
  msgstr ""
1767
 
1768
+ #: bp-core/bp-core-buddybar.php:356
1769
  msgid "You do not have access to this page."
1770
  msgstr ""
1771
 
1772
+ #: bp-core/bp-core-buddybar.php:552 bp-core/bp-core-functions.php:1713
1773
+ #: bp-core/bp-core-widgets.php:89 bp-themes/bp-default/sidebar.php:52
1774
  msgid "Log In"
1775
  msgstr ""
1776
 
1777
+ #: bp-core/bp-core-buddybar.php:556
1778
  msgid "Sign Up"
1779
  msgstr ""
1780
 
1781
+ #: bp-core/bp-core-buddybar.php:613 bp-core/bp-core-functions.php:1646
1782
+ #: bp-core/bp-core-widgets.php:71 bp-core/deprecated/1.5.php:307
1783
  #: bp-members/bp-members-template.php:774 bp-themes/bp-default/sidebar.php:18
1784
  msgid "Log Out"
1785
  msgstr ""
1786
 
1787
+ #: bp-core/bp-core-buddybar.php:645 bp-groups/bp-groups-admin.php:1388
1788
  msgid "Visit"
1789
  msgstr ""
1790
 
1791
+ #: bp-core/bp-core-buddybar.php:647
1792
  msgid "Random Member"
1793
  msgstr ""
1794
 
1795
+ #: bp-core/bp-core-buddybar.php:651
1796
  msgid "Random Group"
1797
  msgstr ""
1798
 
1799
+ #: bp-core/bp-core-buddybar.php:657
1800
  msgid "Random Site"
1801
  msgstr ""
1802
 
1803
+ #: bp-core/bp-core-caps.php:258 bp-core/bp-core-caps.php:270
1804
+ #: bp-core/bp-core-caps.php:284 bp-core/bp-core-caps.php:294
1805
  msgid "Special community roles no longer exist. Use mapped capabilities instead"
1806
  msgstr ""
1807
 
1808
+ #: bp-core/bp-core-catchuri.php:276
1809
  msgid "This user has been marked as a spammer. Only site admins can view this profile."
1810
  msgstr ""
1811
 
1812
+ #: bp-core/bp-core-catchuri.php:471 bp-core/bp-core-catchuri.php:531
1813
  msgid "You must log in to access the page you requested."
1814
  msgstr ""
1815
 
1816
+ #: bp-core/bp-core-classes.php:806
1817
  msgid "%d group"
1818
  msgid_plural "%d groups"
1819
  msgstr[0] ""
1823
  msgid "The current user is being initialized without using $wp->init()."
1824
  msgstr ""
1825
 
1826
+ #: bp-core/bp-core-filters.php:216 bp-core/bp-core-filters.php:242
1827
  msgid "[User Set]"
1828
  msgstr ""
1829
 
1830
+ #: bp-core/bp-core-filters.php:271
1831
  msgid ""
1832
  "Thanks for registering! To complete the activation of your account and blog, please click the following link:\n"
1833
  "\n"
1840
  "%2$s"
1841
  msgstr ""
1842
 
1843
+ #: bp-core/bp-core-filters.php:272
1844
  msgid "Activate %s"
1845
  msgstr ""
1846
 
1847
+ #: bp-core/bp-core-filters.php:310 bp-members/bp-members-functions.php:1464
1848
  msgid ""
1849
  "Thanks for registering! To complete the activation of your account please click the following link:\n"
1850
  "\n"
1852
  "\n"
1853
  msgstr ""
1854
 
1855
+ #: bp-core/bp-core-filters.php:311 bp-members/bp-members-functions.php:1465
1856
  msgid "Activate Your Account"
1857
  msgstr ""
1858
 
1859
+ #: bp-core/bp-core-filters.php:373
1860
  msgctxt "Construct the page title. 1 = user name, 2 = component name, 3 = seperator"
1861
  msgid "%1$s %3$s %2$s"
1862
  msgstr ""
1863
 
1864
  #. translators: "group name | group nav section name"
1865
 
1866
+ #: bp-core/bp-core-filters.php:379
1867
  msgid "%1$s | %2$s"
1868
  msgstr ""
1869
 
1870
  #. translators: "component item name | component nav section name | root
1871
  #. component name"
1872
 
1873
+ #: bp-core/bp-core-filters.php:384
1874
  msgid "%1$s | %2$s | %3$s"
1875
  msgstr ""
1876
 
1877
+ #: bp-core/bp-core-filters.php:389 bp-core/bp-core-filters.php:391
1878
  msgid "%s Directory"
1879
  msgstr ""
1880
 
1881
+ #: bp-core/bp-core-filters.php:396 bp-members/bp-members-screens.php:525
1882
  #: bp-themes/bp-default/registration/register.php:23
1883
  msgid "Create an Account"
1884
  msgstr ""
1885
 
1886
+ #: bp-core/bp-core-filters.php:400 bp-members/bp-members-screens.php:533
1887
  #: bp-themes/bp-default/registration/activate.php:13
1888
  msgid "Activate your Account"
1889
  msgstr ""
1890
 
1891
+ #: bp-core/bp-core-filters.php:404 bp-groups/bp-groups-loader.php:553
1892
+ #: bp-groups/bp-groups-screens.php:1048 bp-groups/bp-groups-screens.php:1109
1893
  #: bp-themes/bp-default/groups/create.php:18
1894
  #: bp-themes/bp-default/groups/index.php:21
1895
  msgid "Create a Group"
1896
  msgstr ""
1897
 
1898
+ #: bp-core/bp-core-functions.php:387
1899
  msgctxt "Page title for the Activity directory."
1900
  msgid "Activity"
1901
  msgstr ""
1902
 
1903
+ #: bp-core/bp-core-functions.php:388
1904
  msgctxt "Page title for the Groups directory."
1905
  msgid "Groups"
1906
  msgstr ""
1907
 
1908
+ #: bp-core/bp-core-functions.php:389
1909
  msgctxt "Page title for the Sites directory."
1910
  msgid "Sites"
1911
  msgstr ""
1912
 
1913
+ #: bp-core/bp-core-functions.php:390
1914
  msgctxt "Page title for the user account activation screen."
1915
  msgid "Activate"
1916
  msgstr ""
1917
 
1918
+ #: bp-core/bp-core-functions.php:391
1919
  msgctxt "Page title for the Members directory."
1920
  msgid "Members"
1921
  msgstr ""
1922
 
1923
+ #: bp-core/bp-core-functions.php:392
1924
  msgctxt "Page title for the user registration screen."
1925
  msgid "Register"
1926
  msgstr ""
1927
 
1928
+ #: bp-core/bp-core-functions.php:685
1929
  msgid "sometime"
1930
  msgstr ""
1931
 
1932
+ #: bp-core/bp-core-functions.php:686
1933
  msgid "right now"
1934
  msgstr ""
1935
 
1936
+ #: bp-core/bp-core-functions.php:687
1937
  msgid "%s ago"
1938
  msgstr ""
1939
 
1940
+ #: bp-core/bp-core-functions.php:748
1941
  msgid "%s year"
1942
  msgid_plural "%s years"
1943
  msgstr[0] ""
1944
  msgstr[1] ""
1945
 
1946
+ #: bp-core/bp-core-functions.php:751 bp-core/bp-core-functions.php:785
1947
  msgid "%s month"
1948
  msgid_plural "%s months"
1949
  msgstr[0] ""
1950
  msgstr[1] ""
1951
 
1952
+ #: bp-core/bp-core-functions.php:754 bp-core/bp-core-functions.php:788
1953
  msgid "%s week"
1954
  msgid_plural "%s weeks"
1955
  msgstr[0] ""
1956
  msgstr[1] ""
1957
 
1958
+ #: bp-core/bp-core-functions.php:757 bp-core/bp-core-functions.php:791
1959
  msgid "%s day"
1960
  msgid_plural "%s days"
1961
  msgstr[0] ""
1962
  msgstr[1] ""
1963
 
1964
+ #: bp-core/bp-core-functions.php:760 bp-core/bp-core-functions.php:794
1965
  msgid "%s hour"
1966
  msgid_plural "%s hours"
1967
  msgstr[0] ""
1968
  msgstr[1] ""
1969
 
1970
+ #: bp-core/bp-core-functions.php:763 bp-core/bp-core-functions.php:797
1971
  msgid "%s minute"
1972
  msgid_plural "%s minutes"
1973
  msgstr[0] ""
1974
  msgstr[1] ""
1975
 
1976
+ #: bp-core/bp-core-functions.php:766 bp-core/bp-core-functions.php:800
1977
  msgid "%s second"
1978
  msgid_plural "%s seconds"
1979
  msgstr[0] ""
1980
  msgstr[1] ""
1981
 
1982
+ #: bp-core/bp-core-functions.php:781
1983
  msgctxt "Separator in time since"
1984
  msgid ","
1985
  msgstr ""
1986
 
1987
+ #: bp-core/bp-core-functions.php:966
1988
  msgid "Not recently active"
1989
  msgstr ""
1990
 
1991
+ #: bp-core/bp-core-loader.php:227 bp-members/bp-members-loader.php:168
1992
+ #: bp-xprofile/bp-xprofile-loader.php:162
1993
+ #: bp-xprofile/bp-xprofile-loader.php:235
1994
  msgid "Profile"
1995
  msgstr ""
1996
 
1997
+ #: bp-core/bp-core-template.php:81
1998
  msgid "Options"
1999
  msgstr ""
2000
 
2001
+ #: bp-core/bp-core-template.php:279
2002
  msgid "%1$s at %2$s"
2003
  msgstr ""
2004
 
2005
+ #: bp-core/bp-core-template.php:367
2006
+ msgid "Blogs"
2007
+ msgstr ""
2008
+
2009
+ #: bp-core/bp-core-template.php:372
2010
  #: bp-templates/bp-legacy/buddypress/activity/index.php:83
2011
  #: bp-templates/bp-legacy/buddypress/forums/forums-loop.php:40
2012
  #: bp-templates/bp-legacy/buddypress/members/single/activity.php:27
2016
  msgid "Posts"
2017
  msgstr ""
2018
 
2019
+ #: bp-core/bp-core-template.php:375
2020
  msgid "Search these:"
2021
  msgstr ""
2022
 
2023
+ #: bp-core/bp-core-template.php:413
2024
  msgid "Search anything..."
2025
  msgstr ""
2026
 
2027
+ #: bp-core/bp-core-template.php:515
2028
  msgid " [&hellip;]"
2029
  msgstr ""
2030
 
2031
+ #: bp-core/bp-core-template.php:736
2032
  msgid "Community"
2033
  msgstr ""
2034
 
2035
+ #: bp-core/bp-core-widgets.php:36
2036
+ msgctxt "Title of the login widget"
2037
+ msgid "(BuddyPress) Log In"
2038
+ msgstr ""
2039
+
2040
+ #: bp-core/bp-core-widgets.php:38
2041
+ msgid "Show a Log In form to logged-out visitors, and a Log Out link to those who are logged in."
2042
+ msgstr ""
2043
+
2044
+ #: bp-core/bp-core-widgets.php:81
2045
+ #: bp-templates/bp-legacy/buddypress/members/register.php:32
2046
+ #: bp-themes/bp-default/registration/register.php:37
2047
+ #: bp-themes/bp-default/sidebar.php:44
2048
+ msgid "Username"
2049
+ msgstr ""
2050
+
2051
+ #: bp-core/bp-core-widgets.php:84 bp-themes/bp-default/sidebar.php:47
2052
+ msgid "Password"
2053
+ msgstr ""
2054
+
2055
+ #: bp-core/bp-core-widgets.php:87 bp-themes/bp-default/sidebar.php:50
2056
+ msgid "Remember Me"
2057
+ msgstr ""
2058
+
2059
+ #: bp-core/bp-core-widgets.php:93
2060
+ msgid "<a href=\"%s\" title=\"Register for a new account\">Register</a>"
2061
+ msgstr ""
2062
+
2063
+ #: bp-core/bp-core-widgets.php:134 bp-core/bp-core-widgets.php:279
2064
+ #: bp-core/bp-core-widgets.php:384 bp-core/bp-core-widgets.php:476
2065
+ #: bp-groups/bp-groups-widgets.php:137 bp-messages/bp-messages-widgets.php:110
2066
+ #: bp-templates/bp-legacy/buddypress/forums/index.php:86
2067
+ #: bp-templates/bp-legacy/buddypress/groups/single/forum/edit.php:47
2068
+ #: bp-templates/bp-legacy/buddypress/groups/single/forum.php:75
2069
+ #: bp-themes/bp-default/forums/index.php:104
2070
+ #: bp-themes/bp-default/groups/single/forum/edit.php:47
2071
+ #: bp-themes/bp-default/groups/single/forum.php:75
2072
+ msgid "Title:"
2073
+ msgstr ""
2074
+
2075
+ #: bp-core/bp-core-widgets.php:152
2076
  msgid "A dynamic list of recently active, popular, and newest members"
2077
  msgstr ""
2078
 
2079
+ #: bp-core/bp-core-widgets.php:155
2080
  msgctxt "widget name"
2081
  msgid "(BuddyPress) Members"
2082
  msgstr ""
2083
 
2084
+ #: bp-core/bp-core-widgets.php:190 bp-core/bp-core-widgets.php:288
2085
  #: bp-core/deprecated/1.6.php:129 bp-core/deprecated/1.6.php:152
2086
+ #: bp-friends/bp-friends-widgets.php:91 bp-friends/bp-friends-widgets.php:179
2087
+ #: bp-groups/bp-groups-widgets.php:65 bp-groups/bp-groups-widgets.php:146
2088
  #: bp-templates/bp-legacy/buddypress/blogs/index.php:39
2089
  #: bp-templates/bp-legacy/buddypress/members/single/blogs.php:22
2090
  #: bp-themes/bp-default/blogs/index.php:56
2092
  msgid "Newest"
2093
  msgstr ""
2094
 
2095
+ #: bp-core/bp-core-widgets.php:191 bp-core/bp-core-widgets.php:289
2096
+ #: bp-friends/bp-friends-widgets.php:92 bp-friends/bp-friends-widgets.php:180
2097
+ #: bp-groups/bp-groups-widgets.php:66 bp-groups/bp-groups-widgets.php:147
2098
  msgid "Active"
2099
  msgstr ""
2100
 
2101
+ #: bp-core/bp-core-widgets.php:195 bp-core/bp-core-widgets.php:290
2102
+ #: bp-friends/bp-friends-widgets.php:93 bp-friends/bp-friends-widgets.php:181
2103
+ #: bp-groups/bp-groups-widgets.php:67 bp-groups/bp-groups-widgets.php:148
2104
  msgid "Popular"
2105
  msgstr ""
2106
 
2107
+ #: bp-core/bp-core-widgets.php:232
2108
  msgid "No one has signed up yet!"
2109
  msgstr ""
2110
 
2111
+ #: bp-core/bp-core-widgets.php:281 bp-friends/bp-friends-widgets.php:172
 
 
 
 
 
 
 
 
 
 
 
2112
  msgid "Link widget title to Members directory"
2113
  msgstr ""
2114
 
2115
+ #: bp-core/bp-core-widgets.php:283
2116
  msgid "Max members to show:"
2117
  msgstr ""
2118
 
2119
+ #: bp-core/bp-core-widgets.php:286
2120
  msgid "Default members to show:"
2121
  msgstr ""
2122
 
2123
+ #: bp-core/bp-core-widgets.php:308
2124
  msgid "Avatars of users who are currently online"
2125
  msgstr ""
2126
 
2127
+ #: bp-core/bp-core-widgets.php:311
2128
  msgctxt "widget name"
2129
  msgid "(BuddyPress) Who's Online"
2130
  msgstr ""
2131
 
2132
+ #: bp-core/bp-core-widgets.php:344
2133
  msgid "There are no users currently online"
2134
  msgstr ""
2135
 
2136
+ #: bp-core/bp-core-widgets.php:375
2137
  msgid "Who's Online"
2138
  msgstr ""
2139
 
2140
+ #: bp-core/bp-core-widgets.php:386 bp-core/bp-core-widgets.php:478
2141
  msgid "Max Members to show:"
2142
  msgstr ""
2143
 
2144
+ #: bp-core/bp-core-widgets.php:400
2145
  msgid "Avatars of recently active members"
2146
  msgstr ""
2147
 
2148
+ #: bp-core/bp-core-widgets.php:403
2149
  msgctxt "widget name"
2150
  msgid "(BuddyPress) Recently Active Members"
2151
  msgstr ""
2152
 
2153
+ #: bp-core/bp-core-widgets.php:436
2154
  msgid "There are no recently active members"
2155
  msgstr ""
2156
 
2157
+ #: bp-core/bp-core-widgets.php:467
2158
+ msgid "Recently Active Members"
2159
+ msgstr ""
2160
+
2161
+ #: bp-core/bp-core-widgets.php:531 bp-friends/bp-friends-widgets.php:245
2162
  msgid "There were no members found, please try another filter."
2163
  msgstr ""
2164
 
2167
  #: bp-templates/bp-legacy/buddypress/members/single/profile/profile-wp.php:8
2168
  #: bp-themes/bp-default/activity/post-form.php:45
2169
  #: bp-themes/bp-default/members/single/profile/profile-wp.php:8
2170
+ #: bp-xprofile/bp-xprofile-loader.php:276
2171
  msgid "My Profile"
2172
  msgstr ""
2173
 
2214
  msgstr ""
2215
 
2216
  #: bp-core/deprecated/1.6.php:128 bp-core/deprecated/1.6.php:149
2217
+ #: bp-groups/bp-groups-template.php:2546 bp-groups/bp-groups-template.php:2568
2218
  msgid "Recently Active"
2219
  msgstr ""
2220
 
2221
  #: bp-core/deprecated/1.6.php:130 bp-core/deprecated/1.6.php:155
2222
+ #: bp-groups/bp-groups-template.php:2551 bp-groups/bp-groups-template.php:2583
2223
  msgid "Alphabetically"
2224
  ms